summaryrefslogtreecommitdiff
path: root/drivers/staging
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/staging')
-rw-r--r--drivers/staging/Kconfig22
-rw-r--r--drivers/staging/Makefile11
-rw-r--r--drivers/staging/android/Kconfig36
-rw-r--r--drivers/staging/android/Makefile4
-rw-r--r--drivers/staging/android/alarm-dev.c172
-rw-r--r--drivers/staging/android/alarm.c601
-rw-r--r--drivers/staging/android/android_alarm.h59
-rw-r--r--drivers/staging/android/ashmem.c22
-rw-r--r--drivers/staging/android/binder.c54
-rw-r--r--drivers/staging/android/binder.h10
-rw-r--r--drivers/staging/android/logger.c123
-rw-r--r--drivers/staging/android/persistent_ram.c473
-rw-r--r--drivers/staging/android/persistent_ram.h78
-rw-r--r--drivers/staging/android/ram_console.c179
-rw-r--r--drivers/staging/android/switch/Kconfig11
-rw-r--r--drivers/staging/android/switch/Makefile4
-rw-r--r--drivers/staging/android/switch/switch.h53
-rw-r--r--drivers/staging/android/switch/switch_class.c174
-rw-r--r--drivers/staging/android/switch/switch_gpio.c172
-rw-r--r--drivers/staging/android/timed_output.c5
-rw-r--r--drivers/staging/asus_oled/asus_oled.c6
-rw-r--r--drivers/staging/bcm/Adapter.h817
-rw-r--r--drivers/staging/bcm/Bcmchar.c32
-rw-r--r--drivers/staging/bcm/Bcmnet.c18
-rw-r--r--drivers/staging/bcm/CmHost.c111
-rw-r--r--drivers/staging/bcm/CmHost.h10
-rw-r--r--drivers/staging/bcm/DDRInit.c92
-rw-r--r--drivers/staging/bcm/DDRInit.h4
-rw-r--r--drivers/staging/bcm/Debug.h5
-rw-r--r--drivers/staging/bcm/HandleControlPacket.c10
-rw-r--r--drivers/staging/bcm/IPv6Protocol.c409
-rw-r--r--drivers/staging/bcm/IPv6ProtocolHdr.h10
-rw-r--r--drivers/staging/bcm/InterfaceAdapter.h2
-rw-r--r--drivers/staging/bcm/InterfaceDld.c14
-rw-r--r--drivers/staging/bcm/InterfaceIdleMode.c12
-rw-r--r--drivers/staging/bcm/InterfaceIdleMode.h10
-rw-r--r--drivers/staging/bcm/InterfaceInit.c8
-rw-r--r--drivers/staging/bcm/InterfaceIsr.c2
-rw-r--r--drivers/staging/bcm/InterfaceIsr.h4
-rw-r--r--drivers/staging/bcm/InterfaceMisc.c2
-rw-r--r--drivers/staging/bcm/InterfaceMisc.h2
-rw-r--r--drivers/staging/bcm/InterfaceRx.c12
-rw-r--r--drivers/staging/bcm/InterfaceTx.c6
-rw-r--r--drivers/staging/bcm/LeakyBucket.c16
-rw-r--r--drivers/staging/bcm/Macros.h13
-rw-r--r--drivers/staging/bcm/Misc.c182
-rw-r--r--drivers/staging/bcm/PHSDefines.h1
-rw-r--r--drivers/staging/bcm/PHSModule.c68
-rw-r--r--drivers/staging/bcm/PHSModule.h6
-rw-r--r--drivers/staging/bcm/Protocol.h8
-rw-r--r--drivers/staging/bcm/Prototypes.h168
-rw-r--r--drivers/staging/bcm/Qos.c84
-rw-r--r--drivers/staging/bcm/Transmit.c14
-rw-r--r--drivers/staging/bcm/cntrl_SignalingInterface.h2
-rw-r--r--drivers/staging/bcm/hostmibs.c6
-rw-r--r--drivers/staging/bcm/led_control.c22
-rw-r--r--drivers/staging/bcm/nvm.c6460
-rw-r--r--drivers/staging/bcm/sort.c16
-rw-r--r--drivers/staging/bcm/vendorspecificextn.c6
-rw-r--r--drivers/staging/bcm/vendorspecificextn.h6
-rw-r--r--drivers/staging/ccg/Kconfig20
-rw-r--r--drivers/staging/ccg/Makefile4
-rw-r--r--drivers/staging/ccg/TODO6
-rw-r--r--drivers/staging/ccg/ccg.c1295
-rw-r--r--drivers/staging/ccg/sysfs-class-ccg_usb158
-rw-r--r--drivers/staging/comedi/Kconfig384
-rw-r--r--drivers/staging/comedi/comedi.h2
-rw-r--r--drivers/staging/comedi/comedi_compat32.c2
-rw-r--r--drivers/staging/comedi/comedi_compat32.h6
-rw-r--r--drivers/staging/comedi/comedi_fops.c874
-rw-r--r--drivers/staging/comedi/comedi_fops.h11
-rw-r--r--drivers/staging/comedi/comedi_internal.h (renamed from drivers/staging/comedi/internal.h)15
-rw-r--r--drivers/staging/comedi/comedidev.h115
-rw-r--r--drivers/staging/comedi/drivers.c461
-rw-r--r--drivers/staging/comedi/drivers/8255.c266
-rw-r--r--drivers/staging/comedi/drivers/8255.h8
-rw-r--r--drivers/staging/comedi/drivers/Makefile3
-rw-r--r--drivers/staging/comedi/drivers/acl7225b.c82
-rw-r--r--drivers/staging/comedi/drivers/addi-data/addi_amcc_s5933.h6
-rw-r--r--drivers/staging/comedi/drivers/addi-data/addi_common.c3538
-rw-r--r--drivers/staging/comedi/drivers/addi-data/addi_common.h146
-rw-r--r--drivers/staging/comedi/drivers/addi-data/amcc_s5933_58.h4
-rw-r--r--drivers/staging/comedi/drivers/addi-data/hwdrv_APCI1710.c5
-rw-r--r--drivers/staging/comedi/drivers/addi-data/hwdrv_apci16xx.h15
-rw-r--r--drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c18
-rw-r--r--drivers/staging/comedi/drivers/addi-data/hwdrv_apci3xxx.h14
-rw-r--r--drivers/staging/comedi/drivers/adl_pci6208.c526
-rw-r--r--drivers/staging/comedi/drivers/adl_pci7230.c199
-rw-r--r--drivers/staging/comedi/drivers/adl_pci7296.c216
-rw-r--r--drivers/staging/comedi/drivers/adl_pci7432.c264
-rw-r--r--drivers/staging/comedi/drivers/adl_pci8164.c319
-rw-r--r--drivers/staging/comedi/drivers/adl_pci9111.c231
-rw-r--r--drivers/staging/comedi/drivers/adl_pci9118.c311
-rw-r--r--drivers/staging/comedi/drivers/adq12b.c279
-rw-r--r--drivers/staging/comedi/drivers/adv_pci1710.c357
-rw-r--r--drivers/staging/comedi/drivers/adv_pci1723.c207
-rw-r--r--drivers/staging/comedi/drivers/adv_pci_dio.c259
-rw-r--r--drivers/staging/comedi/drivers/aio_aio12_8.c44
-rw-r--r--drivers/staging/comedi/drivers/aio_iiro_16.c125
-rw-r--r--drivers/staging/comedi/drivers/amplc_dio200.c536
-rw-r--r--drivers/staging/comedi/drivers/amplc_pc236.c653
-rw-r--r--drivers/staging/comedi/drivers/amplc_pc263.c534
-rw-r--r--drivers/staging/comedi/drivers/amplc_pci224.c377
-rw-r--r--drivers/staging/comedi/drivers/amplc_pci230.c1543
-rw-r--r--drivers/staging/comedi/drivers/c6xdigio.c48
-rw-r--r--drivers/staging/comedi/drivers/cb_das16_cs.c584
-rw-r--r--drivers/staging/comedi/drivers/cb_pcidas.c1816
-rw-r--r--drivers/staging/comedi/drivers/cb_pcidas64.c283
-rw-r--r--drivers/staging/comedi/drivers/cb_pcidda.c273
-rw-r--r--drivers/staging/comedi/drivers/cb_pcidio.c250
-rw-r--r--drivers/staging/comedi/drivers/cb_pcimdas.c277
-rw-r--r--drivers/staging/comedi/drivers/cb_pcimdda.c143
-rw-r--r--drivers/staging/comedi/drivers/comedi_bond.c216
-rw-r--r--drivers/staging/comedi/drivers/comedi_parport.c54
-rw-r--r--drivers/staging/comedi/drivers/comedi_pci.h60
-rw-r--r--drivers/staging/comedi/drivers/comedi_test.c377
-rw-r--r--drivers/staging/comedi/drivers/contec_pci_dio.c270
-rw-r--r--drivers/staging/comedi/drivers/daqboard2000.c229
-rw-r--r--drivers/staging/comedi/drivers/das08.c1038
-rw-r--r--drivers/staging/comedi/drivers/das08.h16
-rw-r--r--drivers/staging/comedi/drivers/das08_cs.c189
-rw-r--r--drivers/staging/comedi/drivers/das16.c1001
-rw-r--r--drivers/staging/comedi/drivers/das16m1.c236
-rw-r--r--drivers/staging/comedi/drivers/das1800.c1240
-rw-r--r--drivers/staging/comedi/drivers/das6402.c82
-rw-r--r--drivers/staging/comedi/drivers/das800.c59
-rw-r--r--drivers/staging/comedi/drivers/dmm32at.c645
-rw-r--r--drivers/staging/comedi/drivers/dt2801.c287
-rw-r--r--drivers/staging/comedi/drivers/dt2811.c318
-rw-r--r--drivers/staging/comedi/drivers/dt2814.c120
-rw-r--r--drivers/staging/comedi/drivers/dt2815.c49
-rw-r--r--drivers/staging/comedi/drivers/dt2817.c43
-rw-r--r--drivers/staging/comedi/drivers/dt282x.c473
-rw-r--r--drivers/staging/comedi/drivers/dt3000.c272
-rw-r--r--drivers/staging/comedi/drivers/dt9812.c50
-rw-r--r--drivers/staging/comedi/drivers/dyna_pci10xx.c234
-rw-r--r--drivers/staging/comedi/drivers/fl512.c53
-rw-r--r--drivers/staging/comedi/drivers/gsc_hpdi.c119
-rw-r--r--drivers/staging/comedi/drivers/icp_multi.c301
-rw-r--r--drivers/staging/comedi/drivers/icp_multi.h1
-rw-r--r--drivers/staging/comedi/drivers/ii_pci20kc.c52
-rw-r--r--drivers/staging/comedi/drivers/jr3_pci.c109
-rw-r--r--drivers/staging/comedi/drivers/ke_counter.c214
-rw-r--r--drivers/staging/comedi/drivers/me4000.c813
-rw-r--r--drivers/staging/comedi/drivers/me4000.h37
-rw-r--r--drivers/staging/comedi/drivers/me_daq.c209
-rw-r--r--drivers/staging/comedi/drivers/mite.c1
-rw-r--r--drivers/staging/comedi/drivers/mite.h4
-rw-r--r--drivers/staging/comedi/drivers/mpc624.c237
-rw-r--r--drivers/staging/comedi/drivers/mpc8260cpm.c118
-rw-r--r--drivers/staging/comedi/drivers/multiq3.c52
-rw-r--r--drivers/staging/comedi/drivers/ni_6527.c28
-rw-r--r--drivers/staging/comedi/drivers/ni_65xx.c21
-rw-r--r--drivers/staging/comedi/drivers/ni_660x.c24
-rw-r--r--drivers/staging/comedi/drivers/ni_670x.c356
-rw-r--r--drivers/staging/comedi/drivers/ni_at_a2150.c362
-rw-r--r--drivers/staging/comedi/drivers/ni_at_ao.c246
-rw-r--r--drivers/staging/comedi/drivers/ni_atmio.c94
-rw-r--r--drivers/staging/comedi/drivers/ni_atmio16d.c125
-rw-r--r--drivers/staging/comedi/drivers/ni_daq_700.c527
-rw-r--r--drivers/staging/comedi/drivers/ni_daq_dio24.c23
-rw-r--r--drivers/staging/comedi/drivers/ni_labpc.c17
-rw-r--r--drivers/staging/comedi/drivers/ni_labpc.h2
-rw-r--r--drivers/staging/comedi/drivers/ni_labpc_cs.c10
-rw-r--r--drivers/staging/comedi/drivers/ni_mio_common.c23
-rw-r--r--drivers/staging/comedi/drivers/ni_mio_cs.c13
-rw-r--r--drivers/staging/comedi/drivers/ni_pcidio.c150
-rw-r--r--drivers/staging/comedi/drivers/ni_pcimio.c202
-rw-r--r--drivers/staging/comedi/drivers/ni_tio_internal.h36
-rw-r--r--drivers/staging/comedi/drivers/pcl711.c114
-rw-r--r--drivers/staging/comedi/drivers/pcl724.c91
-rw-r--r--drivers/staging/comedi/drivers/pcl725.c53
-rw-r--r--drivers/staging/comedi/drivers/pcl726.c93
-rw-r--r--drivers/staging/comedi/drivers/pcl730.c84
-rw-r--r--drivers/staging/comedi/drivers/pcl812.c405
-rw-r--r--drivers/staging/comedi/drivers/pcl816.c245
-rw-r--r--drivers/staging/comedi/drivers/pcl818.c279
-rw-r--r--drivers/staging/comedi/drivers/pcm3724.c71
-rw-r--r--drivers/staging/comedi/drivers/pcm3730.c51
-rw-r--r--drivers/staging/comedi/drivers/pcmad.c77
-rw-r--r--drivers/staging/comedi/drivers/pcmda12.c219
-rw-r--r--drivers/staging/comedi/drivers/pcmmio.c677
-rw-r--r--drivers/staging/comedi/drivers/pcmuio.c565
-rw-r--r--drivers/staging/comedi/drivers/poc.c222
-rw-r--r--drivers/staging/comedi/drivers/quatech_daqp_cs.c20
-rw-r--r--drivers/staging/comedi/drivers/rtd520.c1793
-rw-r--r--drivers/staging/comedi/drivers/rti800.c74
-rw-r--r--drivers/staging/comedi/drivers/rti802.c46
-rw-r--r--drivers/staging/comedi/drivers/s526.c505
-rw-r--r--drivers/staging/comedi/drivers/s626.c2595
-rw-r--r--drivers/staging/comedi/drivers/s626.h12
-rw-r--r--drivers/staging/comedi/drivers/serial2002.c99
-rw-r--r--drivers/staging/comedi/drivers/skel.c26
-rw-r--r--drivers/staging/comedi/drivers/ssv_dnp.c228
-rw-r--r--drivers/staging/comedi/drivers/unioxx5.c455
-rw-r--r--drivers/staging/comedi/drivers/usbdux.c510
-rw-r--r--drivers/staging/comedi/drivers/usbduxfast.c417
-rw-r--r--drivers/staging/comedi/drivers/usbduxsigma.c492
-rw-r--r--drivers/staging/comedi/drivers/vmk80xx.c296
-rw-r--r--drivers/staging/comedi/proc.c2
-rw-r--r--drivers/staging/comedi/range.c2
-rw-r--r--drivers/staging/cptm1217/clearpad_tm1217.c4
-rw-r--r--drivers/staging/cptm1217/cp_tm1217.h3
-rw-r--r--drivers/staging/csr/Kconfig9
-rw-r--r--drivers/staging/csr/LICENSE.txt39
-rw-r--r--drivers/staging/csr/Makefile75
-rw-r--r--drivers/staging/csr/bh.c391
-rw-r--r--drivers/staging/csr/csr_formatted_io.c27
-rw-r--r--drivers/staging/csr/csr_formatted_io.h25
-rw-r--r--drivers/staging/csr/csr_framework_ext.c148
-rw-r--r--drivers/staging/csr/csr_framework_ext.h248
-rw-r--r--drivers/staging/csr/csr_framework_ext_types.h63
-rw-r--r--drivers/staging/csr/csr_lib.h188
-rw-r--r--drivers/staging/csr/csr_log.h249
-rw-r--r--drivers/staging/csr/csr_log_configure.h134
-rw-r--r--drivers/staging/csr/csr_log_text.h132
-rw-r--r--drivers/staging/csr/csr_macro.h114
-rw-r--r--drivers/staging/csr/csr_msg_transport.h25
-rw-r--r--drivers/staging/csr/csr_msgconv.c292
-rw-r--r--drivers/staging/csr/csr_msgconv.h87
-rw-r--r--drivers/staging/csr/csr_panic.c21
-rw-r--r--drivers/staging/csr/csr_panic.h53
-rw-r--r--drivers/staging/csr/csr_prim_defs.h62
-rw-r--r--drivers/staging/csr/csr_result.h25
-rw-r--r--drivers/staging/csr/csr_sched.h292
-rw-r--r--drivers/staging/csr/csr_sdio.h731
-rw-r--r--drivers/staging/csr/csr_serialize_primitive_types.c101
-rw-r--r--drivers/staging/csr/csr_time.c43
-rw-r--r--drivers/staging/csr/csr_time.h114
-rw-r--r--drivers/staging/csr/csr_util.c15
-rw-r--r--drivers/staging/csr/csr_wifi_common.h109
-rw-r--r--drivers/staging/csr/csr_wifi_fsm.h248
-rw-r--r--drivers/staging/csr/csr_wifi_fsm_event.h50
-rw-r--r--drivers/staging/csr/csr_wifi_fsm_types.h440
-rw-r--r--drivers/staging/csr/csr_wifi_hip_card.h123
-rw-r--r--drivers/staging/csr/csr_wifi_hip_card_sdio.c4163
-rw-r--r--drivers/staging/csr/csr_wifi_hip_card_sdio.h702
-rw-r--r--drivers/staging/csr/csr_wifi_hip_card_sdio_intr.c2595
-rw-r--r--drivers/staging/csr/csr_wifi_hip_card_sdio_mem.c1713
-rw-r--r--drivers/staging/csr/csr_wifi_hip_chiphelper.c793
-rw-r--r--drivers/staging/csr/csr_wifi_hip_chiphelper.h471
-rw-r--r--drivers/staging/csr/csr_wifi_hip_chiphelper_private.h208
-rw-r--r--drivers/staging/csr/csr_wifi_hip_conversions.h81
-rw-r--r--drivers/staging/csr/csr_wifi_hip_download.c835
-rw-r--r--drivers/staging/csr/csr_wifi_hip_dump.c865
-rw-r--r--drivers/staging/csr/csr_wifi_hip_packing.c4804
-rw-r--r--drivers/staging/csr/csr_wifi_hip_send.c422
-rw-r--r--drivers/staging/csr/csr_wifi_hip_signals.c1313
-rw-r--r--drivers/staging/csr/csr_wifi_hip_signals.h137
-rw-r--r--drivers/staging/csr/csr_wifi_hip_sigs.h1425
-rw-r--r--drivers/staging/csr/csr_wifi_hip_ta_sampling.c541
-rw-r--r--drivers/staging/csr/csr_wifi_hip_ta_sampling.h75
-rw-r--r--drivers/staging/csr/csr_wifi_hip_udi.c268
-rw-r--r--drivers/staging/csr/csr_wifi_hip_unifi.h880
-rw-r--r--drivers/staging/csr/csr_wifi_hip_unifi_signal_names.c46
-rw-r--r--drivers/staging/csr/csr_wifi_hip_unifi_udi.h76
-rw-r--r--drivers/staging/csr/csr_wifi_hip_unifihw.h67
-rw-r--r--drivers/staging/csr/csr_wifi_hip_unifiversion.h38
-rw-r--r--drivers/staging/csr/csr_wifi_hip_xbv.c1076
-rw-r--r--drivers/staging/csr/csr_wifi_hip_xbv.h127
-rw-r--r--drivers/staging/csr/csr_wifi_hostio_prim.h27
-rw-r--r--drivers/staging/csr/csr_wifi_lib.h112
-rw-r--r--drivers/staging/csr/csr_wifi_msgconv.h58
-rw-r--r--drivers/staging/csr/csr_wifi_nme_ap_converter_init.c90
-rw-r--r--drivers/staging/csr/csr_wifi_nme_ap_converter_init.h49
-rw-r--r--drivers/staging/csr/csr_wifi_nme_ap_free_downstream_contents.c84
-rw-r--r--drivers/staging/csr/csr_wifi_nme_ap_free_upstream_contents.c39
-rw-r--r--drivers/staging/csr/csr_wifi_nme_ap_lib.h523
-rw-r--r--drivers/staging/csr/csr_wifi_nme_ap_prim.h503
-rw-r--r--drivers/staging/csr/csr_wifi_nme_ap_sef.c30
-rw-r--r--drivers/staging/csr/csr_wifi_nme_ap_sef.h31
-rw-r--r--drivers/staging/csr/csr_wifi_nme_ap_serialize.c909
-rw-r--r--drivers/staging/csr/csr_wifi_nme_ap_serialize.h103
-rw-r--r--drivers/staging/csr/csr_wifi_nme_converter_init.h46
-rw-r--r--drivers/staging/csr/csr_wifi_nme_lib.h1054
-rw-r--r--drivers/staging/csr/csr_wifi_nme_prim.h1666
-rw-r--r--drivers/staging/csr/csr_wifi_nme_serialize.h174
-rw-r--r--drivers/staging/csr/csr_wifi_nme_task.h38
-rw-r--r--drivers/staging/csr/csr_wifi_private_common.h89
-rw-r--r--drivers/staging/csr/csr_wifi_result.h35
-rw-r--r--drivers/staging/csr/csr_wifi_router_converter_init.c82
-rw-r--r--drivers/staging/csr/csr_wifi_router_converter_init.h42
-rw-r--r--drivers/staging/csr/csr_wifi_router_ctrl_converter_init.c134
-rw-r--r--drivers/staging/csr/csr_wifi_router_ctrl_converter_init.h42
-rw-r--r--drivers/staging/csr/csr_wifi_router_ctrl_free_downstream_contents.c108
-rw-r--r--drivers/staging/csr/csr_wifi_router_ctrl_free_upstream_contents.c87
-rw-r--r--drivers/staging/csr/csr_wifi_router_ctrl_lib.h2092
-rw-r--r--drivers/staging/csr/csr_wifi_router_ctrl_prim.h2122
-rw-r--r--drivers/staging/csr/csr_wifi_router_ctrl_sef.c45
-rw-r--r--drivers/staging/csr/csr_wifi_router_ctrl_sef.h58
-rw-r--r--drivers/staging/csr/csr_wifi_router_ctrl_serialize.c2591
-rw-r--r--drivers/staging/csr/csr_wifi_router_ctrl_serialize.h341
-rw-r--r--drivers/staging/csr/csr_wifi_router_free_downstream_contents.c53
-rw-r--r--drivers/staging/csr/csr_wifi_router_free_upstream_contents.c53
-rw-r--r--drivers/staging/csr/csr_wifi_router_lib.h427
-rw-r--r--drivers/staging/csr/csr_wifi_router_prim.h430
-rw-r--r--drivers/staging/csr/csr_wifi_router_sef.c19
-rw-r--r--drivers/staging/csr/csr_wifi_router_sef.h33
-rw-r--r--drivers/staging/csr/csr_wifi_router_serialize.c418
-rw-r--r--drivers/staging/csr/csr_wifi_router_serialize.h75
-rw-r--r--drivers/staging/csr/csr_wifi_router_task.h33
-rw-r--r--drivers/staging/csr/csr_wifi_router_transport.c199
-rw-r--r--drivers/staging/csr/csr_wifi_serialize_primitive_types.c256
-rw-r--r--drivers/staging/csr/csr_wifi_sme_ap_lib.h783
-rw-r--r--drivers/staging/csr/csr_wifi_sme_ap_prim.h1038
-rw-r--r--drivers/staging/csr/csr_wifi_sme_converter_init.c201
-rw-r--r--drivers/staging/csr/csr_wifi_sme_converter_init.h42
-rw-r--r--drivers/staging/csr/csr_wifi_sme_free_downstream_contents.c187
-rw-r--r--drivers/staging/csr/csr_wifi_sme_free_upstream_contents.c275
-rw-r--r--drivers/staging/csr/csr_wifi_sme_lib.h4313
-rw-r--r--drivers/staging/csr/csr_wifi_sme_prim.h6519
-rw-r--r--drivers/staging/csr/csr_wifi_sme_sef.c85
-rw-r--r--drivers/staging/csr/csr_wifi_sme_sef.h101
-rw-r--r--drivers/staging/csr/csr_wifi_sme_serialize.c5809
-rw-r--r--drivers/staging/csr/csr_wifi_sme_serialize.h670
-rw-r--r--drivers/staging/csr/csr_wifi_sme_task.h33
-rw-r--r--drivers/staging/csr/csr_wifi_vif_utils.h108
-rw-r--r--drivers/staging/csr/data_tx.c57
-rw-r--r--drivers/staging/csr/drv.c2262
-rw-r--r--drivers/staging/csr/firmware.c413
-rw-r--r--drivers/staging/csr/inet.c106
-rw-r--r--drivers/staging/csr/init_hw.c108
-rw-r--r--drivers/staging/csr/io.c1166
-rw-r--r--drivers/staging/csr/mlme.c436
-rw-r--r--drivers/staging/csr/monitor.c399
-rw-r--r--drivers/staging/csr/netdev.c3993
-rw-r--r--drivers/staging/csr/os.c483
-rw-r--r--drivers/staging/csr/putest.c685
-rw-r--r--drivers/staging/csr/sdio_events.c134
-rw-r--r--drivers/staging/csr/sdio_mmc.c1340
-rw-r--r--drivers/staging/csr/sdio_stubs.c82
-rw-r--r--drivers/staging/csr/sme_blocking.c1535
-rw-r--r--drivers/staging/csr/sme_mgt.c1012
-rw-r--r--drivers/staging/csr/sme_native.c591
-rw-r--r--drivers/staging/csr/sme_sys.c3262
-rw-r--r--drivers/staging/csr/sme_userspace.c315
-rw-r--r--drivers/staging/csr/sme_userspace.h38
-rw-r--r--drivers/staging/csr/sme_wext.c3381
-rw-r--r--drivers/staging/csr/ul_int.c532
-rw-r--r--drivers/staging/csr/unifi_clients.h129
-rw-r--r--drivers/staging/csr/unifi_config.h34
-rw-r--r--drivers/staging/csr/unifi_dbg.c110
-rw-r--r--drivers/staging/csr/unifi_event.c700
-rw-r--r--drivers/staging/csr/unifi_native.h257
-rw-r--r--drivers/staging/csr/unifi_os.h145
-rw-r--r--drivers/staging/csr/unifi_pdu_processing.c3755
-rw-r--r--drivers/staging/csr/unifi_priv.h1177
-rw-r--r--drivers/staging/csr/unifi_sme.c1239
-rw-r--r--drivers/staging/csr/unifi_sme.h245
-rw-r--r--drivers/staging/csr/unifi_wext.h124
-rw-r--r--drivers/staging/csr/unifiio.h398
-rw-r--r--drivers/staging/csr/wext_events.c285
-rw-r--r--drivers/staging/echo/echo.c9
-rw-r--r--drivers/staging/echo/echo.h28
-rw-r--r--drivers/staging/et131x/et131x.c69
-rw-r--r--drivers/staging/frontier/alphatrack.c15
-rw-r--r--drivers/staging/frontier/tranzport.c18
-rw-r--r--drivers/staging/ft1000/ft1000-pcmcia/ft1000_hw.c72
-rw-r--r--drivers/staging/ft1000/ft1000-pcmcia/ft1000_proc.c10
-rw-r--r--drivers/staging/ft1000/ft1000-usb/ft1000_debug.c2
-rw-r--r--drivers/staging/ft1000/ft1000-usb/ft1000_hw.c9
-rw-r--r--drivers/staging/ft1000/ft1000-usb/ft1000_usb.c18
-rw-r--r--drivers/staging/ft1000/ft1000-usb/ft1000_usb.h177
-rw-r--r--drivers/staging/gdm72xx/Kconfig46
-rw-r--r--drivers/staging/gdm72xx/Makefile6
-rw-r--r--drivers/staging/gdm72xx/TODO5
-rw-r--r--drivers/staging/gdm72xx/gdm_qos.c458
-rw-r--r--drivers/staging/gdm72xx/gdm_qos.h93
-rw-r--r--drivers/staging/gdm72xx/gdm_sdio.c750
-rw-r--r--drivers/staging/gdm72xx/gdm_sdio.h72
-rw-r--r--drivers/staging/gdm72xx/gdm_usb.c801
-rw-r--r--drivers/staging/gdm72xx/gdm_usb.h85
-rw-r--r--drivers/staging/gdm72xx/gdm_wimax.c1018
-rw-r--r--drivers/staging/gdm72xx/gdm_wimax.h91
-rw-r--r--drivers/staging/gdm72xx/hci.h218
-rw-r--r--drivers/staging/gdm72xx/netlink_k.c153
-rw-r--r--drivers/staging/gdm72xx/netlink_k.h24
-rw-r--r--drivers/staging/gdm72xx/sdio_boot.c158
-rw-r--r--drivers/staging/gdm72xx/sdio_boot.h21
-rw-r--r--drivers/staging/gdm72xx/usb_boot.c403
-rw-r--r--drivers/staging/gdm72xx/usb_boot.h22
-rw-r--r--drivers/staging/gdm72xx/usb_ids.h82
-rw-r--r--drivers/staging/gdm72xx/wm_ioctl.h97
-rw-r--r--drivers/staging/iio/Documentation/device.txt14
-rw-r--r--drivers/staging/iio/Documentation/generic_buffer.c75
-rw-r--r--drivers/staging/iio/Documentation/iio_event_monitor.c16
-rw-r--r--drivers/staging/iio/Documentation/iio_utils.h33
-rw-r--r--drivers/staging/iio/Documentation/light/sysfs-bus-iio-light-tsl25836
-rw-r--r--drivers/staging/iio/Documentation/light/sysfs-bus-iio-light-tsl2x7x13
-rw-r--r--drivers/staging/iio/Documentation/overview.txt2
-rw-r--r--drivers/staging/iio/Documentation/ring.txt4
-rw-r--r--drivers/staging/iio/Documentation/sysfs-bus-iio741
-rw-r--r--drivers/staging/iio/Documentation/sysfs-bus-iio-ad719220
-rw-r--r--drivers/staging/iio/Documentation/sysfs-bus-iio-dds81
-rw-r--r--drivers/staging/iio/Documentation/sysfs-bus-iio-light40
-rw-r--r--drivers/staging/iio/Documentation/trigger.txt2
-rw-r--r--drivers/staging/iio/Kconfig47
-rw-r--r--drivers/staging/iio/Makefile9
-rw-r--r--drivers/staging/iio/TODO2
-rw-r--r--drivers/staging/iio/accel/adis16201_core.c148
-rw-r--r--drivers/staging/iio/accel/adis16201_ring.c14
-rw-r--r--drivers/staging/iio/accel/adis16201_trigger.c10
-rw-r--r--drivers/staging/iio/accel/adis16203_core.c134
-rw-r--r--drivers/staging/iio/accel/adis16203_ring.c21
-rw-r--r--drivers/staging/iio/accel/adis16203_trigger.c10
-rw-r--r--drivers/staging/iio/accel/adis16204_core.c210
-rw-r--r--drivers/staging/iio/accel/adis16204_ring.c21
-rw-r--r--drivers/staging/iio/accel/adis16204_trigger.c10
-rw-r--r--drivers/staging/iio/accel/adis16209_core.c188
-rw-r--r--drivers/staging/iio/accel/adis16209_ring.c22
-rw-r--r--drivers/staging/iio/accel/adis16209_trigger.c10
-rw-r--r--drivers/staging/iio/accel/adis16220_core.c63
-rw-r--r--drivers/staging/iio/accel/adis16240_core.c152
-rw-r--r--drivers/staging/iio/accel/adis16240_ring.c21
-rw-r--r--drivers/staging/iio/accel/adis16240_trigger.c10
-rw-r--r--drivers/staging/iio/accel/kxsd9.c16
-rw-r--r--drivers/staging/iio/accel/lis3l02dq_core.c50
-rw-r--r--drivers/staging/iio/accel/lis3l02dq_ring.c33
-rw-r--r--drivers/staging/iio/accel/sca3000_core.c68
-rw-r--r--drivers/staging/iio/accel/sca3000_ring.c12
-rw-r--r--drivers/staging/iio/adc/Kconfig33
-rw-r--r--drivers/staging/iio/adc/Makefile1
-rw-r--r--drivers/staging/iio/adc/ad7192.c128
-rw-r--r--drivers/staging/iio/adc/ad7280a.c31
-rw-r--r--drivers/staging/iio/adc/ad7291.c26
-rw-r--r--drivers/staging/iio/adc/ad7298.h6
-rw-r--r--drivers/staging/iio/adc/ad7298_core.c90
-rw-r--r--drivers/staging/iio/adc/ad7298_ring.c90
-rw-r--r--drivers/staging/iio/adc/ad7476.h1
-rw-r--r--drivers/staging/iio/adc/ad7476_core.c69
-rw-r--r--drivers/staging/iio/adc/ad7476_ring.c92
-rw-r--r--drivers/staging/iio/adc/ad7606_core.c49
-rw-r--r--drivers/staging/iio/adc/ad7606_par.c2
-rw-r--r--drivers/staging/iio/adc/ad7606_ring.c62
-rw-r--r--drivers/staging/iio/adc/ad7606_spi.c2
-rw-r--r--drivers/staging/iio/adc/ad7780.c44
-rw-r--r--drivers/staging/iio/adc/ad7793.c158
-rw-r--r--drivers/staging/iio/adc/ad7816.c28
-rw-r--r--drivers/staging/iio/adc/ad7887.h1
-rw-r--r--drivers/staging/iio/adc/ad7887_core.c29
-rw-r--r--drivers/staging/iio/adc/ad7887_ring.c71
-rw-r--r--drivers/staging/iio/adc/ad799x.h3
-rw-r--r--drivers/staging/iio/adc/ad799x_core.c92
-rw-r--r--drivers/staging/iio/adc/ad799x_ring.c97
-rw-r--r--drivers/staging/iio/adc/adt7310.c49
-rw-r--r--drivers/staging/iio/adc/adt7410.c104
-rw-r--r--drivers/staging/iio/adc/lpc32xx_adc.c39
-rw-r--r--drivers/staging/iio/adc/max1363_core.c33
-rw-r--r--drivers/staging/iio/adc/max1363_ring.c19
-rw-r--r--drivers/staging/iio/adc/spear_adc.c448
-rw-r--r--drivers/staging/iio/addac/adt7316.c152
-rw-r--r--drivers/staging/iio/buffer.h193
-rw-r--r--drivers/staging/iio/cdc/ad7150.c30
-rw-r--r--drivers/staging/iio/cdc/ad7152.c30
-rw-r--r--drivers/staging/iio/cdc/ad7746.c49
-rw-r--r--drivers/staging/iio/consumer.h96
-rw-r--r--drivers/staging/iio/dac/Kconfig121
-rw-r--r--drivers/staging/iio/dac/Makefile15
-rw-r--r--drivers/staging/iio/dac/ad5064.c559
-rw-r--r--drivers/staging/iio/dac/ad5360.c570
-rw-r--r--drivers/staging/iio/dac/ad5380.c676
-rw-r--r--drivers/staging/iio/dac/ad5421.c544
-rw-r--r--drivers/staging/iio/dac/ad5421.h32
-rw-r--r--drivers/staging/iio/dac/ad5446.c440
-rw-r--r--drivers/staging/iio/dac/ad5446.h103
-rw-r--r--drivers/staging/iio/dac/ad5504.c396
-rw-r--r--drivers/staging/iio/dac/ad5504.h65
-rw-r--r--drivers/staging/iio/dac/ad5624r.h79
-rw-r--r--drivers/staging/iio/dac/ad5624r_spi.c353
-rw-r--r--drivers/staging/iio/dac/ad5686.c454
-rw-r--r--drivers/staging/iio/dac/ad5764.c382
-rw-r--r--drivers/staging/iio/dac/ad5791.c420
-rw-r--r--drivers/staging/iio/dac/ad5791.h112
-rw-r--r--drivers/staging/iio/dac/dac.h6
-rw-r--r--drivers/staging/iio/dac/max517.c293
-rw-r--r--drivers/staging/iio/dac/max517.h19
-rw-r--r--drivers/staging/iio/dds/dds.h110
-rw-r--r--drivers/staging/iio/driver.h34
-rw-r--r--drivers/staging/iio/events.h105
-rw-r--r--drivers/staging/iio/frequency/Kconfig (renamed from drivers/staging/iio/dds/Kconfig)0
-rw-r--r--drivers/staging/iio/frequency/Makefile (renamed from drivers/staging/iio/dds/Makefile)0
-rw-r--r--drivers/staging/iio/frequency/ad5930.c (renamed from drivers/staging/iio/dds/ad5930.c)12
-rw-r--r--drivers/staging/iio/frequency/ad9832.c (renamed from drivers/staging/iio/dds/ad9832.c)36
-rw-r--r--drivers/staging/iio/frequency/ad9832.h (renamed from drivers/staging/iio/dds/ad9832.h)0
-rw-r--r--drivers/staging/iio/frequency/ad9834.c (renamed from drivers/staging/iio/dds/ad9834.c)74
-rw-r--r--drivers/staging/iio/frequency/ad9834.h (renamed from drivers/staging/iio/dds/ad9834.h)0
-rw-r--r--drivers/staging/iio/frequency/ad9850.c (renamed from drivers/staging/iio/dds/ad9850.c)12
-rw-r--r--drivers/staging/iio/frequency/ad9852.c (renamed from drivers/staging/iio/dds/ad9852.c)12
-rw-r--r--drivers/staging/iio/frequency/ad9910.c (renamed from drivers/staging/iio/dds/ad9910.c)12
-rw-r--r--drivers/staging/iio/frequency/ad9951.c (renamed from drivers/staging/iio/dds/ad9951.c)12
-rw-r--r--drivers/staging/iio/frequency/dds.h110
-rw-r--r--drivers/staging/iio/gyro/adis16060_core.c18
-rw-r--r--drivers/staging/iio/gyro/adis16080_core.c18
-rw-r--r--drivers/staging/iio/gyro/adis16130_core.c12
-rw-r--r--drivers/staging/iio/gyro/adis16260_core.c137
-rw-r--r--drivers/staging/iio/gyro/adis16260_ring.c21
-rw-r--r--drivers/staging/iio/gyro/adis16260_trigger.c10
-rw-r--r--drivers/staging/iio/gyro/adxrs450.h2
-rw-r--r--drivers/staging/iio/gyro/adxrs450_core.c24
-rw-r--r--drivers/staging/iio/iio.h471
-rw-r--r--drivers/staging/iio/iio_core.h56
-rw-r--r--drivers/staging/iio/iio_core_trigger.h46
-rw-r--r--drivers/staging/iio/iio_dummy_evgen.c4
-rw-r--r--drivers/staging/iio/iio_hwmon.c16
-rw-r--r--drivers/staging/iio/iio_simple_dummy.c45
-rw-r--r--drivers/staging/iio/iio_simple_dummy_buffer.c39
-rw-r--r--drivers/staging/iio/iio_simple_dummy_events.c8
-rw-r--r--drivers/staging/iio/impedance-analyzer/ad5933.c83
-rw-r--r--drivers/staging/iio/imu/adis16400.h3
-rw-r--r--drivers/staging/iio/imu/adis16400_core.c175
-rw-r--r--drivers/staging/iio/imu/adis16400_ring.c33
-rw-r--r--drivers/staging/iio/imu/adis16400_trigger.c10
-rw-r--r--drivers/staging/iio/industrialio-buffer.c734
-rw-r--r--drivers/staging/iio/industrialio-core.c927
-rw-r--r--drivers/staging/iio/industrialio-event.c453
-rw-r--r--drivers/staging/iio/industrialio-trigger.c509
-rw-r--r--drivers/staging/iio/inkern.c293
-rw-r--r--drivers/staging/iio/kfifo_buf.c151
-rw-r--r--drivers/staging/iio/kfifo_buf.h8
-rw-r--r--drivers/staging/iio/light/Kconfig37
-rw-r--r--drivers/staging/iio/light/Makefile2
-rw-r--r--drivers/staging/iio/light/isl29018.c227
-rw-r--r--drivers/staging/iio/light/isl29028.c566
-rw-r--r--drivers/staging/iio/light/tsl2563.c24
-rw-r--r--drivers/staging/iio/light/tsl2583.c36
-rw-r--r--drivers/staging/iio/light/tsl2x7x.h100
-rw-r--r--drivers/staging/iio/light/tsl2x7x_core.c2080
-rw-r--r--drivers/staging/iio/machine.h24
-rw-r--r--drivers/staging/iio/magnetometer/Kconfig10
-rw-r--r--drivers/staging/iio/magnetometer/ak8975.c113
-rw-r--r--drivers/staging/iio/magnetometer/hmc5843.c528
-rw-r--r--drivers/staging/iio/meter/ade7753.c22
-rw-r--r--drivers/staging/iio/meter/ade7754.c22
-rw-r--r--drivers/staging/iio/meter/ade7758.h1
-rw-r--r--drivers/staging/iio/meter/ade7758_core.c306
-rw-r--r--drivers/staging/iio/meter/ade7758_ring.c34
-rw-r--r--drivers/staging/iio/meter/ade7758_trigger.c10
-rw-r--r--drivers/staging/iio/meter/ade7759.c22
-rw-r--r--drivers/staging/iio/meter/ade7854-i2c.c22
-rw-r--r--drivers/staging/iio/meter/ade7854-spi.c22
-rw-r--r--drivers/staging/iio/meter/ade7854.c28
-rw-r--r--drivers/staging/iio/meter/meter.h2
-rw-r--r--drivers/staging/iio/resolver/ad2s1200.c12
-rw-r--r--drivers/staging/iio/resolver/ad2s1210.c38
-rw-r--r--drivers/staging/iio/resolver/ad2s90.c11
-rw-r--r--drivers/staging/iio/ring_sw.c6
-rw-r--r--drivers/staging/iio/ring_sw.h2
-rw-r--r--drivers/staging/iio/sysfs.h117
-rw-r--r--drivers/staging/iio/trigger.h119
-rw-r--r--drivers/staging/iio/trigger/iio-trig-bfin-timer.c14
-rw-r--r--drivers/staging/iio/trigger/iio-trig-gpio.c10
-rw-r--r--drivers/staging/iio/trigger/iio-trig-periodic-rtc.c12
-rw-r--r--drivers/staging/iio/trigger/iio-trig-sysfs.c12
-rw-r--r--drivers/staging/iio/trigger_consumer.h52
-rw-r--r--drivers/staging/iio/types.h53
-rw-r--r--drivers/staging/ipack/Kconfig20
-rw-r--r--drivers/staging/ipack/Makefile6
-rw-r--r--drivers/staging/ipack/TODO43
-rw-r--r--drivers/staging/ipack/bridges/Kconfig8
-rw-r--r--drivers/staging/ipack/bridges/Makefile1
-rw-r--r--drivers/staging/ipack/bridges/tpci200.c902
-rw-r--r--drivers/staging/ipack/bridges/tpci200.h157
-rw-r--r--drivers/staging/ipack/devices/Kconfig7
-rw-r--r--drivers/staging/ipack/devices/Makefile1
-rw-r--r--drivers/staging/ipack/devices/ipoctal.c892
-rw-r--r--drivers/staging/ipack/devices/ipoctal.h41
-rw-r--r--drivers/staging/ipack/devices/scc2698.h228
-rw-r--r--drivers/staging/ipack/ipack.c173
-rw-r--r--drivers/staging/ipack/ipack.h183
-rw-r--r--drivers/staging/keucr/init.c3
-rw-r--r--drivers/staging/keucr/scsiglue.c11
-rw-r--r--drivers/staging/line6/config.h48
-rw-r--r--drivers/staging/line6/control.c4
-rw-r--r--drivers/staging/line6/driver.c92
-rw-r--r--drivers/staging/line6/driver.h4
-rw-r--r--drivers/staging/line6/midi.c2
-rw-r--r--drivers/staging/line6/midibuf.c2
-rw-r--r--drivers/staging/line6/pcm.c2
-rw-r--r--drivers/staging/line6/pod.c16
-rw-r--r--drivers/staging/line6/pod.h2
-rw-r--r--drivers/staging/line6/toneport.c2
-rw-r--r--drivers/staging/line6/variax.c8
-rw-r--r--drivers/staging/media/as102/as102_drv.c34
-rw-r--r--drivers/staging/media/as102/as102_usb_drv.c12
-rw-r--r--drivers/staging/media/as102/as102_usb_drv.h2
-rw-r--r--drivers/staging/media/easycap/easycap_ioctl.c1
-rw-r--r--drivers/staging/media/easycap/easycap_main.c9
-rw-r--r--drivers/staging/media/go7007/README2
-rw-r--r--drivers/staging/media/go7007/go7007.txt1
-rw-r--r--drivers/staging/media/go7007/s2250-loader.c26
-rw-r--r--drivers/staging/media/go7007/wis-i2c.h5
-rw-r--r--drivers/staging/media/lirc/lirc_imon.c80
-rw-r--r--drivers/staging/media/lirc/lirc_sasem.c100
-rw-r--r--drivers/staging/media/lirc/lirc_ttusbir.c13
-rw-r--r--drivers/staging/mei/Kconfig28
-rw-r--r--drivers/staging/mei/Makefile11
-rw-r--r--drivers/staging/mei/TODO10
-rw-r--r--drivers/staging/mei/hw.h332
-rw-r--r--drivers/staging/mei/init.c735
-rw-r--r--drivers/staging/mei/interface.c428
-rw-r--r--drivers/staging/mei/interface.h76
-rw-r--r--drivers/staging/mei/interrupt.c1590
-rw-r--r--drivers/staging/mei/iorw.c590
-rw-r--r--drivers/staging/mei/main.c1237
-rw-r--r--drivers/staging/mei/mei-amt-version.c481
-rw-r--r--drivers/staging/mei/mei.h110
-rw-r--r--drivers/staging/mei/mei.txt215
-rw-r--r--drivers/staging/mei/mei_dev.h428
-rw-r--r--drivers/staging/mei/wd.c379
-rw-r--r--drivers/staging/net/Kconfig38
-rw-r--r--drivers/staging/net/Makefile5
-rw-r--r--drivers/staging/net/TODO5
-rw-r--r--drivers/staging/net/pc300-falc-lh.h1238
-rw-r--r--drivers/staging/net/pc300.h436
-rw-r--r--drivers/staging/net/pc300_drv.c3670
-rw-r--r--drivers/staging/net/pc300_tty.c1079
-rw-r--r--drivers/staging/nvec/Kconfig9
-rw-r--r--drivers/staging/nvec/Makefile2
-rw-r--r--drivers/staging/nvec/nvec.c85
-rw-r--r--drivers/staging/nvec/nvec.h2
-rw-r--r--drivers/staging/nvec/nvec_kbd.c16
-rw-r--r--drivers/staging/nvec/nvec_paz00.c (renamed from drivers/staging/nvec/nvec_leds.c)46
-rw-r--r--drivers/staging/nvec/nvec_power.c32
-rw-r--r--drivers/staging/nvec/nvec_ps2.c35
-rw-r--r--drivers/staging/octeon/ethernet-mdio.c28
-rw-r--r--drivers/staging/octeon/ethernet-rx.c2
-rw-r--r--drivers/staging/octeon/ethernet-tx.c12
-rw-r--r--drivers/staging/octeon/ethernet-util.h2
-rw-r--r--drivers/staging/octeon/ethernet.c155
-rw-r--r--drivers/staging/octeon/octeon-ethernet.h3
-rw-r--r--drivers/staging/olpc_dcon/olpc_dcon.c29
-rw-r--r--drivers/staging/olpc_dcon/olpc_dcon_xo_1.c2
-rw-r--r--drivers/staging/omap-thermal/Kconfig46
-rw-r--r--drivers/staging/omap-thermal/Makefile5
-rw-r--r--drivers/staging/omap-thermal/TODO28
-rw-r--r--drivers/staging/omap-thermal/omap-bandgap.c1187
-rw-r--r--drivers/staging/omap-thermal/omap-bandgap.h441
-rw-r--r--drivers/staging/omap-thermal/omap-thermal-common.c364
-rw-r--r--drivers/staging/omap-thermal/omap-thermal.h108
-rw-r--r--drivers/staging/omap-thermal/omap4-thermal.c259
-rw-r--r--drivers/staging/omap-thermal/omap5-thermal.c297
-rw-r--r--drivers/staging/omap-thermal/omap_bandgap.txt30
-rw-r--r--drivers/staging/omapdrm/Makefile1
-rw-r--r--drivers/staging/omapdrm/TODO7
-rw-r--r--drivers/staging/omapdrm/omap_crtc.c9
-rw-r--r--drivers/staging/omapdrm/omap_dmm_priv.h1
-rw-r--r--drivers/staging/omapdrm/omap_dmm_tiler.c48
-rw-r--r--drivers/staging/omapdrm/omap_drv.c10
-rw-r--r--drivers/staging/omapdrm/omap_drv.h16
-rw-r--r--drivers/staging/omapdrm/omap_encoder.c2
-rw-r--r--drivers/staging/omapdrm/omap_fb.c7
-rw-r--r--drivers/staging/omapdrm/omap_fbdev.c10
-rw-r--r--drivers/staging/omapdrm/omap_gem.c130
-rw-r--r--drivers/staging/omapdrm/omap_gem_dmabuf.c220
-rw-r--r--drivers/staging/omapdrm/omap_priv.h55
-rw-r--r--drivers/staging/omapdrm/tcm-sita.c2
-rw-r--r--drivers/staging/ozwpan/README2
-rw-r--r--drivers/staging/ozwpan/TODO11
-rw-r--r--drivers/staging/ozwpan/ozappif.h18
-rw-r--r--drivers/staging/ozwpan/ozcdev.c45
-rw-r--r--drivers/staging/ozwpan/ozevent.c195
-rw-r--r--drivers/staging/ozwpan/ozevent.h11
-rw-r--r--drivers/staging/ozwpan/ozeventdef.h19
-rw-r--r--drivers/staging/ozwpan/ozhcd.c6
-rw-r--r--drivers/staging/ozwpan/ozmain.c8
-rw-r--r--drivers/staging/ozwpan/ozpd.c182
-rw-r--r--drivers/staging/ozwpan/ozpd.h3
-rw-r--r--drivers/staging/ozwpan/ozproto.c6
-rw-r--r--drivers/staging/ozwpan/ozprotocol.h1
-rw-r--r--drivers/staging/ozwpan/ozusbsvc.c2
-rw-r--r--drivers/staging/panel/panel.c62
-rw-r--r--drivers/staging/phison/phison.c13
-rw-r--r--drivers/staging/quatech_usb2/Kconfig15
-rw-r--r--drivers/staging/quatech_usb2/Makefile1
-rw-r--r--drivers/staging/quatech_usb2/TODO8
-rw-r--r--drivers/staging/quatech_usb2/quatech_usb2.c1976
-rw-r--r--drivers/staging/ramster/Kconfig2
-rw-r--r--drivers/staging/ramster/cluster/tcp.c6
-rw-r--r--drivers/staging/ramster/r2net.c4
-rw-r--r--drivers/staging/ramster/xvmalloc.c2
-rw-r--r--drivers/staging/ramster/zcache-main.c14
-rw-r--r--drivers/staging/rtl8187se/Makefile2
-rw-r--r--drivers/staging/rtl8187se/ieee80211/dot11d.c2
-rw-r--r--drivers/staging/rtl8187se/ieee80211/ieee80211.h14
-rw-r--r--drivers/staging/rtl8187se/ieee80211/ieee80211_softmac.c26
-rw-r--r--drivers/staging/rtl8187se/ieee80211/ieee80211_softmac_wx.c2
-rw-r--r--drivers/staging/rtl8187se/ieee80211/ieee80211_tx.c7
-rw-r--r--drivers/staging/rtl8187se/ieee80211/ieee80211_wx.c2
-rw-r--r--drivers/staging/rtl8187se/r8180.h10
-rw-r--r--drivers/staging/rtl8187se/r8180_core.c33
-rw-r--r--drivers/staging/rtl8187se/r8180_dm.c16
-rw-r--r--drivers/staging/rtl8187se/r8180_rtl8225z2.c4
-rw-r--r--drivers/staging/rtl8187se/r8180_wx.c10
-rw-r--r--drivers/staging/rtl8187se/r8180_wx.h2
-rw-r--r--drivers/staging/rtl8187se/r8185b_init.c1329
-rw-r--r--drivers/staging/rtl8192e/Kconfig4
-rw-r--r--drivers/staging/rtl8192e/rtl8192e/r8192E_cmdpkt.c3
-rw-r--r--drivers/staging/rtl8192e/rtl8192e/r8192E_firmware.c2
-rw-r--r--drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c2
-rw-r--r--drivers/staging/rtl8192e/rtl8192e/r819xE_phyreg.h4
-rw-r--r--drivers/staging/rtl8192e/rtl8192e/rtl_core.c13
-rw-r--r--drivers/staging/rtl8192e/rtl8192e/rtl_core.h3
-rw-r--r--drivers/staging/rtl8192e/rtl8192e/rtl_dm.c22
-rw-r--r--drivers/staging/rtl8192e/rtl8192e/rtl_wx.c8
-rw-r--r--drivers/staging/rtl8192e/rtl819x_TSProc.c2
-rw-r--r--drivers/staging/rtl8192e/rtllib.h18
-rw-r--r--drivers/staging/rtl8192e/rtllib_rx.c10
-rw-r--r--drivers/staging/rtl8192e/rtllib_softmac.c35
-rw-r--r--drivers/staging/rtl8192e/rtllib_softmac_wx.c4
-rw-r--r--drivers/staging/rtl8192e/rtllib_tx.c14
-rw-r--r--drivers/staging/rtl8192e/rtllib_wx.c4
-rw-r--r--drivers/staging/rtl8192u/ieee80211/ieee80211_module.c2
-rw-r--r--drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c4
-rw-r--r--drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c2
-rw-r--r--drivers/staging/rtl8192u/ieee80211/ieee80211_tx.c7
-rw-r--r--drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c2
-rw-r--r--drivers/staging/rtl8192u/r8180_93cx6.c2
-rw-r--r--drivers/staging/rtl8192u/r8180_93cx6.h2
-rw-r--r--drivers/staging/rtl8192u/r8192U.h9
-rw-r--r--drivers/staging/rtl8192u/r8192U_core.c60
-rw-r--r--drivers/staging/rtl8192u/r8192U_dm.c74
-rw-r--r--drivers/staging/rtl8192u/r8192U_hw.h2
-rw-r--r--drivers/staging/rtl8192u/r8192U_wx.c12
-rw-r--r--drivers/staging/rtl8192u/r8192U_wx.h2
-rw-r--r--drivers/staging/rtl8192u/r819xU_HTType.h2
-rw-r--r--drivers/staging/rtl8192u/r819xU_cmdpkt.c12
-rw-r--r--drivers/staging/rtl8192u/r819xU_firmware.c4
-rw-r--r--drivers/staging/rtl8192u/r819xU_phy.c16
-rw-r--r--drivers/staging/rtl8192u/r819xU_phyreg.h2
-rw-r--r--drivers/staging/rtl8712/big_endian.h94
-rw-r--r--drivers/staging/rtl8712/drv_types.h2
-rw-r--r--drivers/staging/rtl8712/generic.h178
-rw-r--r--drivers/staging/rtl8712/hal_init.c1
-rw-r--r--drivers/staging/rtl8712/ieee80211.h2
-rw-r--r--drivers/staging/rtl8712/if_ether.h141
-rw-r--r--drivers/staging/rtl8712/ip.h137
-rw-r--r--drivers/staging/rtl8712/little_endian.h94
-rw-r--r--drivers/staging/rtl8712/os_intfs.c4
-rw-r--r--drivers/staging/rtl8712/osdep_service.h3
-rw-r--r--drivers/staging/rtl8712/rtl8712_cmd.c7
-rw-r--r--drivers/staging/rtl8712/rtl8712_cmd.h2
-rw-r--r--drivers/staging/rtl8712/rtl8712_efuse.c2
-rw-r--r--drivers/staging/rtl8712/rtl8712_gp_bitdef.h2
-rw-r--r--drivers/staging/rtl8712/rtl8712_hal.h4
-rw-r--r--drivers/staging/rtl8712/rtl8712_led.c6
-rw-r--r--drivers/staging/rtl8712/rtl8712_recv.c9
-rw-r--r--drivers/staging/rtl8712/rtl8712_xmit.c1
-rw-r--r--drivers/staging/rtl8712/rtl871x_byteorder.h32
-rw-r--r--drivers/staging/rtl8712/rtl871x_cmd.c1
-rw-r--r--drivers/staging/rtl8712/rtl871x_cmd.h2
-rw-r--r--drivers/staging/rtl8712/rtl871x_io.h2
-rw-r--r--drivers/staging/rtl8712/rtl871x_ioctl_linux.c19
-rw-r--r--drivers/staging/rtl8712/rtl871x_ioctl_set.c2
-rw-r--r--drivers/staging/rtl8712/rtl871x_mlme.c8
-rw-r--r--drivers/staging/rtl8712/rtl871x_mlme.h6
-rw-r--r--drivers/staging/rtl8712/rtl871x_mp_phy_regdef.h4
-rw-r--r--drivers/staging/rtl8712/rtl871x_recv.c4
-rw-r--r--drivers/staging/rtl8712/rtl871x_xmit.c3
-rw-r--r--drivers/staging/rtl8712/rtl871x_xmit.h2
-rw-r--r--drivers/staging/rtl8712/swab.h131
-rw-r--r--drivers/staging/rtl8712/usb_halinit.c4
-rw-r--r--drivers/staging/rtl8712/usb_intf.c42
-rw-r--r--drivers/staging/rtl8712/usb_ops.c1
-rw-r--r--drivers/staging/rtl8712/wifi.h1
-rw-r--r--drivers/staging/rtl8712/xmit_linux.c6
-rw-r--r--drivers/staging/rts5139/ms.c11
-rw-r--r--drivers/staging/rts5139/ms.h2
-rw-r--r--drivers/staging/rts5139/ms_mg.c4
-rw-r--r--drivers/staging/rts5139/rts51x.c83
-rw-r--r--drivers/staging/rts5139/rts51x.h10
-rw-r--r--drivers/staging/rts5139/rts51x_card.c62
-rw-r--r--drivers/staging/rts5139/rts51x_card.h11
-rw-r--r--drivers/staging/rts5139/rts51x_chip.c183
-rw-r--r--drivers/staging/rts5139/rts51x_chip.h97
-rw-r--r--drivers/staging/rts5139/rts51x_fop.c6
-rw-r--r--drivers/staging/rts5139/rts51x_fop.h5
-rw-r--r--drivers/staging/rts5139/rts51x_scsi.c93
-rw-r--r--drivers/staging/rts5139/rts51x_scsi.h7
-rw-r--r--drivers/staging/rts5139/rts51x_sys.h54
-rw-r--r--drivers/staging/rts5139/rts51x_transport.c282
-rw-r--r--drivers/staging/rts5139/rts51x_transport.h12
-rw-r--r--drivers/staging/rts5139/sd.c142
-rw-r--r--drivers/staging/rts5139/sd.h29
-rw-r--r--drivers/staging/rts5139/sd_cprm.c172
-rw-r--r--drivers/staging/rts5139/xd.c122
-rw-r--r--drivers/staging/rts5139/xd.h2
-rw-r--r--drivers/staging/rts_pstor/ms.c4
-rw-r--r--drivers/staging/rts_pstor/rtsx.c4
-rw-r--r--drivers/staging/rts_pstor/rtsx_transport.c4
-rw-r--r--drivers/staging/rts_pstor/sd.c11
-rw-r--r--drivers/staging/sbe-2t3e3/2t3e3.h3
-rw-r--r--drivers/staging/sbe-2t3e3/cpld.c15
-rw-r--r--drivers/staging/sbe-2t3e3/ctrl.c19
-rw-r--r--drivers/staging/sbe-2t3e3/dc.c19
-rw-r--r--drivers/staging/sbe-2t3e3/exar7250.c40
-rw-r--r--drivers/staging/sbe-2t3e3/exar7300.c17
-rw-r--r--drivers/staging/sbe-2t3e3/intr.c60
-rw-r--r--drivers/staging/sbe-2t3e3/io.c23
-rw-r--r--drivers/staging/sbe-2t3e3/module.c13
-rw-r--r--drivers/staging/sep/sep_crypto.c123
-rw-r--r--drivers/staging/sep/sep_driver_api.h8
-rw-r--r--drivers/staging/sep/sep_driver_config.h10
-rw-r--r--drivers/staging/sep/sep_main.c113
-rw-r--r--drivers/staging/serial/68360serial.c2979
-rw-r--r--drivers/staging/serial/Kconfig16
-rw-r--r--drivers/staging/serial/Makefile1
-rw-r--r--drivers/staging/serial/TODO6
-rw-r--r--drivers/staging/serqt_usb2/serqt_usb2.c83
-rw-r--r--drivers/staging/slicoss/slicoss.c7
-rw-r--r--drivers/staging/sm7xx/Kconfig8
-rw-r--r--drivers/staging/sm7xx/Makefile3
-rw-r--r--drivers/staging/sm7xxfb/Kconfig13
-rw-r--r--drivers/staging/sm7xxfb/Makefile1
-rw-r--r--drivers/staging/sm7xxfb/TODO (renamed from drivers/staging/sm7xx/TODO)2
-rw-r--r--drivers/staging/sm7xxfb/sm7xx.h (renamed from drivers/staging/sm7xx/smtcfb.h)9
-rw-r--r--drivers/staging/sm7xxfb/sm7xxfb.c (renamed from drivers/staging/sm7xx/smtcfb.c)695
-rw-r--r--drivers/staging/speakup/i18n.c2
-rw-r--r--drivers/staging/speakup/main.c2
-rw-r--r--drivers/staging/speakup/selection.c6
-rw-r--r--drivers/staging/speakup/speakup_acnt.h2
-rw-r--r--drivers/staging/speakup/speakup_decpc.c2
-rw-r--r--drivers/staging/speakup/synth.c2
-rw-r--r--drivers/staging/ste_rmi4/synaptics_i2c_rmi4.c8
-rw-r--r--drivers/staging/telephony/ixj.c232
-rw-r--r--drivers/staging/tidspbridge/core/io_sm.c706
-rw-r--r--drivers/staging/tidspbridge/core/tiomap3430.c27
-rw-r--r--drivers/staging/tidspbridge/core/ue_deh.c2
-rw-r--r--drivers/staging/tidspbridge/dynload/cload.c69
-rw-r--r--drivers/staging/usbip/stub_dev.c12
-rw-r--r--drivers/staging/usbip/usbip_common.h17
-rw-r--r--drivers/staging/usbip/usbip_protocol.txt2
-rw-r--r--drivers/staging/usbip/userspace/libsrc/vhci_driver.c20
-rw-r--r--drivers/staging/usbip/userspace/src/Makefile.am5
-rw-r--r--drivers/staging/usbip/vhci.h7
-rw-r--r--drivers/staging/usbip/vhci_hcd.c47
-rw-r--r--drivers/staging/usbip/vhci_rx.c2
-rw-r--r--drivers/staging/usbip/vhci_sysfs.c4
-rw-r--r--drivers/staging/vme/Kconfig19
-rw-r--r--drivers/staging/vme/Makefile7
-rw-r--r--drivers/staging/vme/TODO5
-rw-r--r--drivers/staging/vme/boards/Kconfig9
-rw-r--r--drivers/staging/vme/boards/Makefile5
-rw-r--r--drivers/staging/vme/boards/vme_vmivme7805.c123
-rw-r--r--drivers/staging/vme/boards/vme_vmivme7805.h37
-rw-r--r--drivers/staging/vme/bridges/Kconfig15
-rw-r--r--drivers/staging/vme/bridges/Makefile2
-rw-r--r--drivers/staging/vme/bridges/vme_ca91cx42.c1959
-rw-r--r--drivers/staging/vme/bridges/vme_ca91cx42.h583
-rw-r--r--drivers/staging/vme/bridges/vme_tsi148.c2660
-rw-r--r--drivers/staging/vme/bridges/vme_tsi148.h1409
-rw-r--r--drivers/staging/vme/devices/Kconfig3
-rw-r--r--drivers/staging/vme/devices/vme_pio2_cntr.c2
-rw-r--r--drivers/staging/vme/devices/vme_pio2_core.c3
-rw-r--r--drivers/staging/vme/devices/vme_pio2_gpio.c5
-rw-r--r--drivers/staging/vme/devices/vme_user.c48
-rw-r--r--drivers/staging/vme/vme.c1526
-rw-r--r--drivers/staging/vme/vme.h174
-rw-r--r--drivers/staging/vme/vme_api.txt396
-rw-r--r--drivers/staging/vme/vme_bridge.h174
-rw-r--r--drivers/staging/vt6655/80211hdr.h2
-rw-r--r--drivers/staging/vt6655/baseband.c2
-rw-r--r--drivers/staging/vt6655/baseband.h30
-rw-r--r--drivers/staging/vt6655/bssdb.c6
-rw-r--r--drivers/staging/vt6655/desc.h11
-rw-r--r--drivers/staging/vt6655/device.h15
-rw-r--r--drivers/staging/vt6655/device_main.c37
-rw-r--r--drivers/staging/vt6655/dpc.c1
-rw-r--r--drivers/staging/vt6655/hostap.c6
-rw-r--r--drivers/staging/vt6655/iwctl.c36
-rw-r--r--drivers/staging/vt6655/mac.h24
-rw-r--r--drivers/staging/vt6655/mib.h2
-rw-r--r--drivers/staging/vt6655/rf.c78
-rw-r--r--drivers/staging/vt6655/rf.h1
-rw-r--r--drivers/staging/vt6655/tether.h3
-rw-r--r--drivers/staging/vt6655/vntwifi.c2
-rw-r--r--drivers/staging/vt6655/wcmd.c24
-rw-r--r--drivers/staging/vt6655/wpa.c4
-rw-r--r--drivers/staging/vt6656/80211hdr.h2
-rw-r--r--drivers/staging/vt6656/bssdb.c9
-rw-r--r--drivers/staging/vt6656/bssdb.h2
-rw-r--r--drivers/staging/vt6656/card.c1
-rw-r--r--drivers/staging/vt6656/card.h1
-rw-r--r--drivers/staging/vt6656/channel.c2
-rw-r--r--drivers/staging/vt6656/desc.h19
-rw-r--r--drivers/staging/vt6656/device.h4
-rw-r--r--drivers/staging/vt6656/dpc.c2
-rw-r--r--drivers/staging/vt6656/hostap.c63
-rw-r--r--drivers/staging/vt6656/int.c43
-rw-r--r--drivers/staging/vt6656/int.h43
-rw-r--r--drivers/staging/vt6656/ioctl.c24
-rw-r--r--drivers/staging/vt6656/iwctl.c2050
-rw-r--r--drivers/staging/vt6656/iwctl.h262
-rw-r--r--drivers/staging/vt6656/main_usb.c44
-rw-r--r--drivers/staging/vt6656/mib.h1
-rw-r--r--drivers/staging/vt6656/rxtx.c2
-rw-r--r--drivers/staging/vt6656/tether.h2
-rw-r--r--drivers/staging/vt6656/usbpipe.c3
-rw-r--r--drivers/staging/vt6656/wcmd.c85
-rw-r--r--drivers/staging/vt6656/wpa.c4
-rw-r--r--drivers/staging/winbond/mds_s.h2
-rw-r--r--drivers/staging/winbond/mto.c2
-rw-r--r--drivers/staging/winbond/wbusb.c8
-rw-r--r--drivers/staging/wlags49_h2/README.ubuntu2
-rw-r--r--drivers/staging/wlags49_h2/dhf.c1
-rw-r--r--drivers/staging/wlags49_h2/dhf.h1
-rw-r--r--drivers/staging/wlags49_h2/hcf.c18
-rw-r--r--drivers/staging/wlags49_h2/hcf.h13
-rw-r--r--drivers/staging/wlags49_h2/hcfcfg.h1
-rw-r--r--drivers/staging/wlags49_h2/mdd.h1
-rw-r--r--drivers/staging/wlags49_h2/mmd.c13
-rw-r--r--drivers/staging/wlags49_h2/mmd.h1
-rw-r--r--drivers/staging/wlags49_h2/wl_cs.c3
-rw-r--r--drivers/staging/wlags49_h2/wl_main.c4
-rw-r--r--drivers/staging/wlags49_h2/wl_netdev.c9
-rw-r--r--drivers/staging/wlags49_h2/wl_pci.c4
-rw-r--r--drivers/staging/wlags49_h2/wl_profile.c8
-rw-r--r--drivers/staging/wlags49_h2/wl_util.c11
-rw-r--r--drivers/staging/wlan-ng/cfg80211.c30
-rw-r--r--drivers/staging/wlan-ng/prism2fw.c134
-rw-r--r--drivers/staging/wlan-ng/prism2mgmt.c4
-rw-r--r--drivers/staging/wlan-ng/prism2sta.c8
-rw-r--r--drivers/staging/xgifb/XGI_main.h243
-rw-r--r--drivers/staging/xgifb/XGI_main_26.c579
-rw-r--r--drivers/staging/xgifb/XGIfb.h17
-rw-r--r--drivers/staging/xgifb/vb_def.h22
-rw-r--r--drivers/staging/xgifb/vb_init.c551
-rw-r--r--drivers/staging/xgifb/vb_setmode.c2352
-rw-r--r--drivers/staging/xgifb/vb_struct.h104
-rw-r--r--drivers/staging/xgifb/vb_table.h998
-rw-r--r--drivers/staging/xgifb/vb_util.c8
-rw-r--r--drivers/staging/xgifb/vgatypes.h37
-rw-r--r--drivers/staging/zcache/Kconfig5
-rw-r--r--drivers/staging/zcache/tmem.c63
-rw-r--r--drivers/staging/zcache/zcache-main.c188
-rw-r--r--drivers/staging/zram/Kconfig5
-rw-r--r--drivers/staging/zram/zram_drv.c132
-rw-r--r--drivers/staging/zram/zram_drv.h21
-rw-r--r--drivers/staging/zram/zram_sysfs.c6
-rw-r--r--drivers/staging/zsmalloc/Kconfig4
-rw-r--r--drivers/staging/zsmalloc/zsmalloc-main.c269
-rw-r--r--drivers/staging/zsmalloc/zsmalloc.h20
-rw-r--r--drivers/staging/zsmalloc/zsmalloc_int.h8
942 files changed, 145799 insertions, 76376 deletions
diff --git a/drivers/staging/Kconfig b/drivers/staging/Kconfig
index 97d412d91458..e3402d5644dd 100644
--- a/drivers/staging/Kconfig
+++ b/drivers/staging/Kconfig
@@ -24,8 +24,6 @@ menuconfig STAGING
if STAGING
-source "drivers/staging/serial/Kconfig"
-
source "drivers/staging/et131x/Kconfig"
source "drivers/staging/slicoss/Kconfig"
@@ -68,14 +66,10 @@ source "drivers/staging/octeon/Kconfig"
source "drivers/staging/serqt_usb2/Kconfig"
-source "drivers/staging/quatech_usb2/Kconfig"
-
source "drivers/staging/vt6655/Kconfig"
source "drivers/staging/vt6656/Kconfig"
-source "drivers/staging/vme/Kconfig"
-
source "drivers/staging/sep/Kconfig"
source "drivers/staging/iio/Kconfig"
@@ -90,7 +84,7 @@ source "drivers/staging/wlags49_h2/Kconfig"
source "drivers/staging/wlags49_h25/Kconfig"
-source "drivers/staging/sm7xx/Kconfig"
+source "drivers/staging/sm7xxfb/Kconfig"
source "drivers/staging/crystalhd/Kconfig"
@@ -116,12 +110,12 @@ source "drivers/staging/cptm1217/Kconfig"
source "drivers/staging/ste_rmi4/Kconfig"
-source "drivers/staging/mei/Kconfig"
-
source "drivers/staging/nvec/Kconfig"
source "drivers/staging/media/Kconfig"
+source "drivers/staging/net/Kconfig"
+
source "drivers/staging/omapdrm/Kconfig"
source "drivers/staging/android/Kconfig"
@@ -132,4 +126,14 @@ source "drivers/staging/ramster/Kconfig"
source "drivers/staging/ozwpan/Kconfig"
+source "drivers/staging/ccg/Kconfig"
+
+source "drivers/staging/ipack/Kconfig"
+
+source "drivers/staging/gdm72xx/Kconfig"
+
+source "drivers/staging/csr/Kconfig"
+
+source "drivers/staging/omap-thermal/Kconfig"
+
endif # STAGING
diff --git a/drivers/staging/Makefile b/drivers/staging/Makefile
index ffe7d44374e6..3be59d02cae4 100644
--- a/drivers/staging/Makefile
+++ b/drivers/staging/Makefile
@@ -3,8 +3,8 @@
# fix for build system bug...
obj-$(CONFIG_STAGING) += staging.o
-obj-y += serial/
obj-y += media/
+obj-y += net/
obj-$(CONFIG_ET131X) += et131x/
obj-$(CONFIG_SLICOSS) += slicoss/
obj-$(CONFIG_USBIP_CORE) += usbip/
@@ -25,11 +25,11 @@ obj-$(CONFIG_TRANZPORT) += frontier/
obj-$(CONFIG_IDE_PHISON) += phison/
obj-$(CONFIG_LINE6_USB) += line6/
obj-$(CONFIG_USB_SERIAL_QUATECH2) += serqt_usb2/
-obj-$(CONFIG_USB_SERIAL_QUATECH_USB2) += quatech_usb2/
obj-$(CONFIG_OCTEON_ETHERNET) += octeon/
obj-$(CONFIG_VT6655) += vt6655/
obj-$(CONFIG_VT6656) += vt6656/
obj-$(CONFIG_VME_BUS) += vme/
+obj-$(CONFIG_IPACK_BUS) += ipack/
obj-$(CONFIG_DX_SEP) += sep/
obj-$(CONFIG_IIO) += iio/
obj-$(CONFIG_ZRAM) += zram/
@@ -37,7 +37,7 @@ obj-$(CONFIG_ZCACHE) += zcache/
obj-$(CONFIG_ZSMALLOC) += zsmalloc/
obj-$(CONFIG_WLAGS49_H2) += wlags49_h2/
obj-$(CONFIG_WLAGS49_H25) += wlags49_h25/
-obj-$(CONFIG_FB_SM7XX) += sm7xx/
+obj-$(CONFIG_FB_SM7XX) += sm7xxfb/
obj-$(CONFIG_CRYSTALHD) += crystalhd/
obj-$(CONFIG_CXT1E1) += cxt1e1/
obj-$(CONFIG_FB_XGI) += xgifb/
@@ -50,10 +50,13 @@ obj-$(CONFIG_FT1000) += ft1000/
obj-$(CONFIG_SPEAKUP) += speakup/
obj-$(CONFIG_TOUCHSCREEN_CLEARPAD_TM1217) += cptm1217/
obj-$(CONFIG_TOUCHSCREEN_SYNAPTICS_I2C_RMI4) += ste_rmi4/
-obj-$(CONFIG_INTEL_MEI) += mei/
obj-$(CONFIG_MFD_NVEC) += nvec/
obj-$(CONFIG_DRM_OMAP) += omapdrm/
obj-$(CONFIG_ANDROID) += android/
obj-$(CONFIG_PHONE) += telephony/
obj-$(CONFIG_RAMSTER) += ramster/
obj-$(CONFIG_USB_WPAN_HCD) += ozwpan/
+obj-$(CONFIG_USB_G_CCG) += ccg/
+obj-$(CONFIG_WIMAX_GDM72XX) += gdm72xx/
+obj-$(CONFIG_CSR_WIFI) += csr/
+obj-$(CONFIG_OMAP_BANDGAP) += omap-thermal/
diff --git a/drivers/staging/android/Kconfig b/drivers/staging/android/Kconfig
index eb1dee26bda3..0ce50d12c30f 100644
--- a/drivers/staging/android/Kconfig
+++ b/drivers/staging/android/Kconfig
@@ -25,19 +25,6 @@ config ANDROID_LOGGER
tristate "Android log driver"
default n
-config ANDROID_PERSISTENT_RAM
- bool
- depends on HAVE_MEMBLOCK
- select REED_SOLOMON
- select REED_SOLOMON_ENC8
- select REED_SOLOMON_DEC8
-
-config ANDROID_RAM_CONSOLE
- bool "Android RAM buffer console"
- depends on !S390 && !UML && HAVE_MEMBLOCK
- select ANDROID_PERSISTENT_RAM
- default n
-
config ANDROID_TIMED_OUTPUT
bool "Timed output class driver"
default y
@@ -53,33 +40,14 @@ config ANDROID_LOW_MEMORY_KILLER
---help---
Register processes to be killed when memory is low
-source "drivers/staging/android/switch/Kconfig"
-
-config ANDROID_INTF_ALARM
+config ANDROID_INTF_ALARM_DEV
bool "Android alarm driver"
depends on RTC_CLASS
default n
help
Provides non-wakeup and rtc backed wakeup alarms based on rtc or
elapsed realtime, and a non-wakeup alarm on the monotonic clock.
- Also provides an interface to set the wall time which must be used
- for elapsed realtime to work.
-
-config ANDROID_INTF_ALARM_DEV
- bool "Android alarm device"
- depends on ANDROID_INTF_ALARM
- default y
- help
- Exports the alarm interface to user-space.
-
-config ANDROID_ALARM_OLDDRV_COMPAT
- bool "Android Alarm compatability with old drivers"
- depends on ANDROID_INTF_ALARM
- default n
- help
- Provides preprocessor alias to aid compatability with
- older out-of-tree drivers that use the Android Alarm
- in-kernel API. This will be removed eventually.
+ Also exports the alarm interface to user-space.
endif # if ANDROID
diff --git a/drivers/staging/android/Makefile b/drivers/staging/android/Makefile
index 9b6c9ed91f69..e16fcd51716e 100644
--- a/drivers/staging/android/Makefile
+++ b/drivers/staging/android/Makefile
@@ -1,11 +1,7 @@
obj-$(CONFIG_ANDROID_BINDER_IPC) += binder.o
obj-$(CONFIG_ASHMEM) += ashmem.o
obj-$(CONFIG_ANDROID_LOGGER) += logger.o
-obj-$(CONFIG_ANDROID_PERSISTENT_RAM) += persistent_ram.o
-obj-$(CONFIG_ANDROID_RAM_CONSOLE) += ram_console.o
obj-$(CONFIG_ANDROID_TIMED_OUTPUT) += timed_output.o
obj-$(CONFIG_ANDROID_TIMED_GPIO) += timed_gpio.o
obj-$(CONFIG_ANDROID_LOW_MEMORY_KILLER) += lowmemorykiller.o
-obj-$(CONFIG_ANDROID_SWITCH) += switch/
-obj-$(CONFIG_ANDROID_INTF_ALARM) += alarm.o
obj-$(CONFIG_ANDROID_INTF_ALARM_DEV) += alarm-dev.o
diff --git a/drivers/staging/android/alarm-dev.c b/drivers/staging/android/alarm-dev.c
index 03efb34cbe2e..5b7064005188 100644
--- a/drivers/staging/android/alarm-dev.c
+++ b/drivers/staging/android/alarm-dev.c
@@ -22,51 +22,85 @@
#include <linux/sched.h>
#include <linux/spinlock.h>
#include <linux/uaccess.h>
+#include <linux/alarmtimer.h>
#include "android_alarm.h"
-/* XXX - Hack out wakelocks, while they are out of tree */
-struct wake_lock {
- int i;
-};
-#define wake_lock(x)
-#define wake_lock_timeout(x, y)
-#define wake_unlock(x)
-#define WAKE_LOCK_SUSPEND 0
-#define wake_lock_init(x, y, z) ((x)->i = 1)
-#define wake_lock_destroy(x)
-
#define ANDROID_ALARM_PRINT_INFO (1U << 0)
#define ANDROID_ALARM_PRINT_IO (1U << 1)
#define ANDROID_ALARM_PRINT_INT (1U << 2)
-
static int debug_mask = ANDROID_ALARM_PRINT_INFO;
module_param_named(debug_mask, debug_mask, int, S_IRUGO | S_IWUSR | S_IWGRP);
-#define pr_alarm(debug_level_mask, args...) \
- do { \
- if (debug_mask & ANDROID_ALARM_PRINT_##debug_level_mask) { \
- pr_info(args); \
- } \
- } while (0)
+#define alarm_dbg(debug_level_mask, fmt, ...) \
+do { \
+ if (debug_mask & ANDROID_ALARM_PRINT_##debug_level_mask) \
+ pr_info(fmt, ##__VA_ARGS__); \
+} while (0)
#define ANDROID_ALARM_WAKEUP_MASK ( \
ANDROID_ALARM_RTC_WAKEUP_MASK | \
ANDROID_ALARM_ELAPSED_REALTIME_WAKEUP_MASK)
-/* support old usespace code */
+/* support old userspace code */
#define ANDROID_ALARM_SET_OLD _IOW('a', 2, time_t) /* set alarm */
#define ANDROID_ALARM_SET_AND_WAIT_OLD _IOW('a', 3, time_t)
static int alarm_opened;
static DEFINE_SPINLOCK(alarm_slock);
-static struct wake_lock alarm_wake_lock;
+static struct wakeup_source alarm_wake_lock;
static DECLARE_WAIT_QUEUE_HEAD(alarm_wait_queue);
static uint32_t alarm_pending;
static uint32_t alarm_enabled;
static uint32_t wait_pending;
-static struct android_alarm alarms[ANDROID_ALARM_TYPE_COUNT];
+struct devalarm {
+ union {
+ struct hrtimer hrt;
+ struct alarm alrm;
+ } u;
+ enum android_alarm_type type;
+};
+
+static struct devalarm alarms[ANDROID_ALARM_TYPE_COUNT];
+
+
+static int is_wakeup(enum android_alarm_type type)
+{
+ if (type == ANDROID_ALARM_RTC_WAKEUP ||
+ type == ANDROID_ALARM_ELAPSED_REALTIME_WAKEUP)
+ return 1;
+ return 0;
+}
+
+
+static void devalarm_start(struct devalarm *alrm, ktime_t exp)
+{
+ if (is_wakeup(alrm->type))
+ alarm_start(&alrm->u.alrm, exp);
+ else
+ hrtimer_start(&alrm->u.hrt, exp, HRTIMER_MODE_ABS);
+}
+
+
+static int devalarm_try_to_cancel(struct devalarm *alrm)
+{
+ int ret;
+ if (is_wakeup(alrm->type))
+ ret = alarm_try_to_cancel(&alrm->u.alrm);
+ else
+ ret = hrtimer_try_to_cancel(&alrm->u.hrt);
+ return ret;
+}
+
+static void devalarm_cancel(struct devalarm *alrm)
+{
+ if (is_wakeup(alrm->type))
+ alarm_cancel(&alrm->u.alrm);
+ else
+ hrtimer_cancel(&alrm->u.hrt);
+}
+
static long alarm_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
{
@@ -75,6 +109,8 @@ static long alarm_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
struct timespec new_alarm_time;
struct timespec new_rtc_time;
struct timespec tmp_time;
+ struct rtc_time new_rtc_tm;
+ struct rtc_device *rtc_dev;
enum android_alarm_type alarm_type = ANDROID_ALARM_IOCTL_TO_TYPE(cmd);
uint32_t alarm_type_mask = 1U << alarm_type;
@@ -100,12 +136,12 @@ static long alarm_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
switch (ANDROID_ALARM_BASE_CMD(cmd)) {
case ANDROID_ALARM_CLEAR(0):
spin_lock_irqsave(&alarm_slock, flags);
- pr_alarm(IO, "alarm %d clear\n", alarm_type);
- android_alarm_try_to_cancel(&alarms[alarm_type]);
+ alarm_dbg(IO, "alarm %d clear\n", alarm_type);
+ devalarm_try_to_cancel(&alarms[alarm_type]);
if (alarm_pending) {
alarm_pending &= ~alarm_type_mask;
if (!alarm_pending && !wait_pending)
- wake_unlock(&alarm_wake_lock);
+ __pm_relax(&alarm_wake_lock);
}
alarm_enabled &= ~alarm_type_mask;
spin_unlock_irqrestore(&alarm_slock, flags);
@@ -129,11 +165,11 @@ static long alarm_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
}
from_old_alarm_set:
spin_lock_irqsave(&alarm_slock, flags);
- pr_alarm(IO, "alarm %d set %ld.%09ld\n", alarm_type,
- new_alarm_time.tv_sec, new_alarm_time.tv_nsec);
+ alarm_dbg(IO, "alarm %d set %ld.%09ld\n",
+ alarm_type,
+ new_alarm_time.tv_sec, new_alarm_time.tv_nsec);
alarm_enabled |= alarm_type_mask;
- android_alarm_start_range(&alarms[alarm_type],
- timespec_to_ktime(new_alarm_time),
+ devalarm_start(&alarms[alarm_type],
timespec_to_ktime(new_alarm_time));
spin_unlock_irqrestore(&alarm_slock, flags);
if (ANDROID_ALARM_BASE_CMD(cmd) != ANDROID_ALARM_SET_AND_WAIT(0)
@@ -142,9 +178,9 @@ from_old_alarm_set:
/* fall though */
case ANDROID_ALARM_WAIT:
spin_lock_irqsave(&alarm_slock, flags);
- pr_alarm(IO, "alarm wait\n");
+ alarm_dbg(IO, "alarm wait\n");
if (!alarm_pending && wait_pending) {
- wake_unlock(&alarm_wake_lock);
+ __pm_relax(&alarm_wake_lock);
wait_pending = 0;
}
spin_unlock_irqrestore(&alarm_slock, flags);
@@ -163,7 +199,13 @@ from_old_alarm_set:
rv = -EFAULT;
goto err1;
}
- rv = android_alarm_set_rtc(new_rtc_time);
+ rtc_time_to_tm(new_rtc_time.tv_sec, &new_rtc_tm);
+ rtc_dev = alarmtimer_get_rtcdev();
+ rv = do_settimeofday(&new_rtc_time);
+ if (rv < 0)
+ goto err1;
+ if (rtc_dev)
+ rv = rtc_set_time(rtc_dev, &new_rtc_tm);
spin_lock_irqsave(&alarm_slock, flags);
alarm_pending |= ANDROID_ALARM_TIME_CHANGE_MASK;
wake_up(&alarm_wait_queue);
@@ -179,8 +221,7 @@ from_old_alarm_set:
break;
case ANDROID_ALARM_ELAPSED_REALTIME_WAKEUP:
case ANDROID_ALARM_ELAPSED_REALTIME:
- tmp_time =
- ktime_to_timespec(alarm_get_elapsed_realtime());
+ get_monotonic_boottime(&tmp_time);
break;
case ANDROID_ALARM_TYPE_COUNT:
case ANDROID_ALARM_SYSTEMTIME:
@@ -196,7 +237,6 @@ from_old_alarm_set:
default:
rv = -EINVAL;
- goto err1;
}
err1:
return rv;
@@ -214,24 +254,25 @@ static int alarm_release(struct inode *inode, struct file *file)
unsigned long flags;
spin_lock_irqsave(&alarm_slock, flags);
- if (file->private_data != 0) {
+ if (file->private_data) {
for (i = 0; i < ANDROID_ALARM_TYPE_COUNT; i++) {
uint32_t alarm_type_mask = 1U << i;
if (alarm_enabled & alarm_type_mask) {
- pr_alarm(INFO, "alarm_release: clear alarm, "
- "pending %d\n",
- !!(alarm_pending & alarm_type_mask));
+ alarm_dbg(INFO,
+ "%s: clear alarm, pending %d\n",
+ __func__,
+ !!(alarm_pending & alarm_type_mask));
alarm_enabled &= ~alarm_type_mask;
}
spin_unlock_irqrestore(&alarm_slock, flags);
- android_alarm_cancel(&alarms[i]);
+ devalarm_cancel(&alarms[i]);
spin_lock_irqsave(&alarm_slock, flags);
}
if (alarm_pending | wait_pending) {
if (alarm_pending)
- pr_alarm(INFO, "alarm_release: clear "
- "pending alarms %x\n", alarm_pending);
- wake_unlock(&alarm_wake_lock);
+ alarm_dbg(INFO, "%s: clear pending alarms %x\n",
+ __func__, alarm_pending);
+ __pm_relax(&alarm_wake_lock);
wait_pending = 0;
alarm_pending = 0;
}
@@ -241,15 +282,15 @@ static int alarm_release(struct inode *inode, struct file *file)
return 0;
}
-static void alarm_triggered(struct android_alarm *alarm)
+static void devalarm_triggered(struct devalarm *alarm)
{
unsigned long flags;
uint32_t alarm_type_mask = 1U << alarm->type;
- pr_alarm(INT, "alarm_triggered type %d\n", alarm->type);
+ alarm_dbg(INT, "%s: type %d\n", __func__, alarm->type);
spin_lock_irqsave(&alarm_slock, flags);
if (alarm_enabled & alarm_type_mask) {
- wake_lock_timeout(&alarm_wake_lock, 5 * HZ);
+ __pm_wakeup_event(&alarm_wake_lock, 5000); /* 5secs */
alarm_enabled &= ~alarm_type_mask;
alarm_pending |= alarm_type_mask;
wake_up(&alarm_wait_queue);
@@ -257,6 +298,25 @@ static void alarm_triggered(struct android_alarm *alarm)
spin_unlock_irqrestore(&alarm_slock, flags);
}
+
+static enum hrtimer_restart devalarm_hrthandler(struct hrtimer *hrt)
+{
+ struct devalarm *devalrm = container_of(hrt, struct devalarm, u.hrt);
+
+ devalarm_triggered(devalrm);
+ return HRTIMER_NORESTART;
+}
+
+static enum alarmtimer_restart devalarm_alarmhandler(struct alarm *alrm,
+ ktime_t now)
+{
+ struct devalarm *devalrm = container_of(alrm, struct devalarm, u.alrm);
+
+ devalarm_triggered(devalrm);
+ return ALARMTIMER_NORESTART;
+}
+
+
static const struct file_operations alarm_fops = {
.owner = THIS_MODULE,
.unlocked_ioctl = alarm_ioctl,
@@ -279,17 +339,31 @@ static int __init alarm_dev_init(void)
if (err)
return err;
- for (i = 0; i < ANDROID_ALARM_TYPE_COUNT; i++)
- android_alarm_init(&alarms[i], i, alarm_triggered);
- wake_lock_init(&alarm_wake_lock, WAKE_LOCK_SUSPEND, "alarm");
+ alarm_init(&alarms[ANDROID_ALARM_RTC_WAKEUP].u.alrm,
+ ALARM_REALTIME, devalarm_alarmhandler);
+ hrtimer_init(&alarms[ANDROID_ALARM_RTC].u.hrt,
+ CLOCK_REALTIME, HRTIMER_MODE_ABS);
+ alarm_init(&alarms[ANDROID_ALARM_ELAPSED_REALTIME_WAKEUP].u.alrm,
+ ALARM_BOOTTIME, devalarm_alarmhandler);
+ hrtimer_init(&alarms[ANDROID_ALARM_ELAPSED_REALTIME].u.hrt,
+ CLOCK_BOOTTIME, HRTIMER_MODE_ABS);
+ hrtimer_init(&alarms[ANDROID_ALARM_SYSTEMTIME].u.hrt,
+ CLOCK_MONOTONIC, HRTIMER_MODE_ABS);
+
+ for (i = 0; i < ANDROID_ALARM_TYPE_COUNT; i++) {
+ alarms[i].type = i;
+ if (!is_wakeup(i))
+ alarms[i].u.hrt.function = devalarm_hrthandler;
+ }
+ wakeup_source_init(&alarm_wake_lock, "alarm");
return 0;
}
static void __exit alarm_dev_exit(void)
{
misc_deregister(&alarm_device);
- wake_lock_destroy(&alarm_wake_lock);
+ wakeup_source_trash(&alarm_wake_lock);
}
module_init(alarm_dev_init);
diff --git a/drivers/staging/android/alarm.c b/drivers/staging/android/alarm.c
deleted file mode 100644
index c68950b9e08f..000000000000
--- a/drivers/staging/android/alarm.c
+++ /dev/null
@@ -1,601 +0,0 @@
-/* drivers/rtc/alarm.c
- *
- * Copyright (C) 2007-2009 Google, Inc.
- *
- * This software is licensed under the terms of the GNU General Public
- * License version 2, as published by the Free Software Foundation, and
- * may be copied, distributed, and modified under those terms.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- */
-
-#include <linux/time.h>
-#include <linux/module.h>
-#include <linux/device.h>
-#include <linux/miscdevice.h>
-#include <linux/platform_device.h>
-#include <linux/rtc.h>
-#include <linux/sched.h>
-#include <linux/spinlock.h>
-#include "android_alarm.h"
-
-/* XXX - Hack out wakelocks, while they are out of tree */
-struct wake_lock {
- int i;
-};
-#define wake_lock(x)
-#define wake_lock_timeout(x, y)
-#define wake_unlock(x)
-#define WAKE_LOCK_SUSPEND 0
-#define wake_lock_init(x, y, z) ((x)->i = 1)
-#define wake_lock_destroy(x)
-
-#define ANDROID_ALARM_PRINT_ERROR (1U << 0)
-#define ANDROID_ALARM_PRINT_INIT_STATUS (1U << 1)
-#define ANDROID_ALARM_PRINT_TSET (1U << 2)
-#define ANDROID_ALARM_PRINT_CALL (1U << 3)
-#define ANDROID_ALARM_PRINT_SUSPEND (1U << 4)
-#define ANDROID_ALARM_PRINT_INT (1U << 5)
-#define ANDROID_ALARM_PRINT_FLOW (1U << 6)
-
-static int debug_mask = ANDROID_ALARM_PRINT_ERROR | \
- ANDROID_ALARM_PRINT_INIT_STATUS;
-module_param_named(debug_mask, debug_mask, int, S_IRUGO | S_IWUSR | S_IWGRP);
-
-#define pr_alarm(debug_level_mask, args...) \
- do { \
- if (debug_mask & ANDROID_ALARM_PRINT_##debug_level_mask) { \
- pr_info(args); \
- } \
- } while (0)
-
-#define ANDROID_ALARM_WAKEUP_MASK ( \
- ANDROID_ALARM_RTC_WAKEUP_MASK | \
- ANDROID_ALARM_ELAPSED_REALTIME_WAKEUP_MASK)
-
-/* support old usespace code */
-#define ANDROID_ALARM_SET_OLD _IOW('a', 2, time_t) /* set alarm */
-#define ANDROID_ALARM_SET_AND_WAIT_OLD _IOW('a', 3, time_t)
-
-struct alarm_queue {
- struct rb_root alarms;
- struct rb_node *first;
- struct hrtimer timer;
- ktime_t delta;
- bool stopped;
- ktime_t stopped_time;
-};
-
-static struct rtc_device *alarm_rtc_dev;
-static DEFINE_SPINLOCK(alarm_slock);
-static DEFINE_MUTEX(alarm_setrtc_mutex);
-static struct wake_lock alarm_rtc_wake_lock;
-static struct platform_device *alarm_platform_dev;
-struct alarm_queue alarms[ANDROID_ALARM_TYPE_COUNT];
-static bool suspended;
-
-static void update_timer_locked(struct alarm_queue *base, bool head_removed)
-{
- struct android_alarm *alarm;
- bool is_wakeup = base == &alarms[ANDROID_ALARM_RTC_WAKEUP] ||
- base == &alarms[ANDROID_ALARM_ELAPSED_REALTIME_WAKEUP];
-
- if (base->stopped) {
- pr_alarm(FLOW, "changed alarm while setting the wall time\n");
- return;
- }
-
- if (is_wakeup && !suspended && head_removed)
- wake_unlock(&alarm_rtc_wake_lock);
-
- if (!base->first)
- return;
-
- alarm = container_of(base->first, struct android_alarm, node);
-
- pr_alarm(FLOW, "selected alarm, type %d, func %pF at %lld\n",
- alarm->type, alarm->function, ktime_to_ns(alarm->expires));
-
- if (is_wakeup && suspended) {
- pr_alarm(FLOW, "changed alarm while suspened\n");
- wake_lock_timeout(&alarm_rtc_wake_lock, 1 * HZ);
- return;
- }
-
- hrtimer_try_to_cancel(&base->timer);
- base->timer.node.expires = ktime_add(base->delta, alarm->expires);
- base->timer._softexpires = ktime_add(base->delta, alarm->softexpires);
- hrtimer_start_expires(&base->timer, HRTIMER_MODE_ABS);
-}
-
-static void alarm_enqueue_locked(struct android_alarm *alarm)
-{
- struct alarm_queue *base = &alarms[alarm->type];
- struct rb_node **link = &base->alarms.rb_node;
- struct rb_node *parent = NULL;
- struct android_alarm *entry;
- int leftmost = 1;
- bool was_first = false;
-
- pr_alarm(FLOW, "added alarm, type %d, func %pF at %lld\n",
- alarm->type, alarm->function, ktime_to_ns(alarm->expires));
-
- if (base->first == &alarm->node) {
- base->first = rb_next(&alarm->node);
- was_first = true;
- }
- if (!RB_EMPTY_NODE(&alarm->node)) {
- rb_erase(&alarm->node, &base->alarms);
- RB_CLEAR_NODE(&alarm->node);
- }
-
- while (*link) {
- parent = *link;
- entry = rb_entry(parent, struct android_alarm, node);
- /*
- * We dont care about collisions. Nodes with
- * the same expiry time stay together.
- */
- if (alarm->expires.tv64 < entry->expires.tv64) {
- link = &(*link)->rb_left;
- } else {
- link = &(*link)->rb_right;
- leftmost = 0;
- }
- }
- if (leftmost)
- base->first = &alarm->node;
- if (leftmost || was_first)
- update_timer_locked(base, was_first);
-
- rb_link_node(&alarm->node, parent, link);
- rb_insert_color(&alarm->node, &base->alarms);
-}
-
-/**
- * android_alarm_init - initialize an alarm
- * @alarm: the alarm to be initialized
- * @type: the alarm type to be used
- * @function: alarm callback function
- */
-void android_alarm_init(struct android_alarm *alarm,
- enum android_alarm_type type, void (*function)(struct android_alarm *))
-{
- RB_CLEAR_NODE(&alarm->node);
- alarm->type = type;
- alarm->function = function;
-
- pr_alarm(FLOW, "created alarm, type %d, func %pF\n", type, function);
-}
-
-
-/**
- * android_alarm_start_range - (re)start an alarm
- * @alarm: the alarm to be added
- * @start: earliest expiry time
- * @end: expiry time
- */
-void android_alarm_start_range(struct android_alarm *alarm, ktime_t start,
- ktime_t end)
-{
- unsigned long flags;
-
- spin_lock_irqsave(&alarm_slock, flags);
- alarm->softexpires = start;
- alarm->expires = end;
- alarm_enqueue_locked(alarm);
- spin_unlock_irqrestore(&alarm_slock, flags);
-}
-
-/**
- * android_alarm_try_to_cancel - try to deactivate an alarm
- * @alarm: alarm to stop
- *
- * Returns:
- * 0 when the alarm was not active
- * 1 when the alarm was active
- * -1 when the alarm may currently be excuting the callback function and
- * cannot be stopped (it may also be inactive)
- */
-int android_alarm_try_to_cancel(struct android_alarm *alarm)
-{
- struct alarm_queue *base = &alarms[alarm->type];
- unsigned long flags;
- bool first = false;
- int ret = 0;
-
- spin_lock_irqsave(&alarm_slock, flags);
- if (!RB_EMPTY_NODE(&alarm->node)) {
- pr_alarm(FLOW, "canceled alarm, type %d, func %pF at %lld\n",
- alarm->type, alarm->function,
- ktime_to_ns(alarm->expires));
- ret = 1;
- if (base->first == &alarm->node) {
- base->first = rb_next(&alarm->node);
- first = true;
- }
- rb_erase(&alarm->node, &base->alarms);
- RB_CLEAR_NODE(&alarm->node);
- if (first)
- update_timer_locked(base, true);
- } else
- pr_alarm(FLOW, "tried to cancel alarm, type %d, func %pF\n",
- alarm->type, alarm->function);
- spin_unlock_irqrestore(&alarm_slock, flags);
- if (!ret && hrtimer_callback_running(&base->timer))
- ret = -1;
- return ret;
-}
-
-/**
- * android_alarm_cancel - cancel an alarm and wait for the handler to finish.
- * @alarm: the alarm to be cancelled
- *
- * Returns:
- * 0 when the alarm was not active
- * 1 when the alarm was active
- */
-int android_alarm_cancel(struct android_alarm *alarm)
-{
- for (;;) {
- int ret = android_alarm_try_to_cancel(alarm);
- if (ret >= 0)
- return ret;
- cpu_relax();
- }
-}
-
-/**
- * alarm_set_rtc - set the kernel and rtc walltime
- * @new_time: timespec value containing the new time
- */
-int android_alarm_set_rtc(struct timespec new_time)
-{
- int i;
- int ret;
- unsigned long flags;
- struct rtc_time rtc_new_rtc_time;
- struct timespec tmp_time;
-
- rtc_time_to_tm(new_time.tv_sec, &rtc_new_rtc_time);
-
- pr_alarm(TSET, "set rtc %ld %ld - rtc %02d:%02d:%02d %02d/%02d/%04d\n",
- new_time.tv_sec, new_time.tv_nsec,
- rtc_new_rtc_time.tm_hour, rtc_new_rtc_time.tm_min,
- rtc_new_rtc_time.tm_sec, rtc_new_rtc_time.tm_mon + 1,
- rtc_new_rtc_time.tm_mday,
- rtc_new_rtc_time.tm_year + 1900);
-
- mutex_lock(&alarm_setrtc_mutex);
- spin_lock_irqsave(&alarm_slock, flags);
- wake_lock(&alarm_rtc_wake_lock);
- getnstimeofday(&tmp_time);
- for (i = 0; i < ANDROID_ALARM_SYSTEMTIME; i++) {
- hrtimer_try_to_cancel(&alarms[i].timer);
- alarms[i].stopped = true;
- alarms[i].stopped_time = timespec_to_ktime(tmp_time);
- }
- alarms[ANDROID_ALARM_ELAPSED_REALTIME_WAKEUP].delta =
- alarms[ANDROID_ALARM_ELAPSED_REALTIME].delta =
- ktime_sub(alarms[ANDROID_ALARM_ELAPSED_REALTIME].delta,
- timespec_to_ktime(timespec_sub(tmp_time, new_time)));
- spin_unlock_irqrestore(&alarm_slock, flags);
- ret = do_settimeofday(&new_time);
- spin_lock_irqsave(&alarm_slock, flags);
- for (i = 0; i < ANDROID_ALARM_SYSTEMTIME; i++) {
- alarms[i].stopped = false;
- update_timer_locked(&alarms[i], false);
- }
- spin_unlock_irqrestore(&alarm_slock, flags);
- if (ret < 0) {
- pr_alarm(ERROR, "alarm_set_rtc: Failed to set time\n");
- goto err;
- }
- if (!alarm_rtc_dev) {
- pr_alarm(ERROR,
- "alarm_set_rtc: no RTC, time will be lost on reboot\n");
- goto err;
- }
- ret = rtc_set_time(alarm_rtc_dev, &rtc_new_rtc_time);
- if (ret < 0)
- pr_alarm(ERROR, "alarm_set_rtc: "
- "Failed to set RTC, time will be lost on reboot\n");
-err:
- wake_unlock(&alarm_rtc_wake_lock);
- mutex_unlock(&alarm_setrtc_mutex);
- return ret;
-}
-
-/**
- * alarm_get_elapsed_realtime - get the elapsed real time in ktime_t format
- *
- * returns the time in ktime_t format
- */
-ktime_t alarm_get_elapsed_realtime(void)
-{
- ktime_t now;
- unsigned long flags;
- struct alarm_queue *base = &alarms[ANDROID_ALARM_ELAPSED_REALTIME];
-
- spin_lock_irqsave(&alarm_slock, flags);
- now = base->stopped ? base->stopped_time : ktime_get_real();
- now = ktime_sub(now, base->delta);
- spin_unlock_irqrestore(&alarm_slock, flags);
- return now;
-}
-
-static enum hrtimer_restart alarm_timer_triggered(struct hrtimer *timer)
-{
- struct alarm_queue *base;
- struct android_alarm *alarm;
- unsigned long flags;
- ktime_t now;
-
- spin_lock_irqsave(&alarm_slock, flags);
-
- base = container_of(timer, struct alarm_queue, timer);
- now = base->stopped ? base->stopped_time : hrtimer_cb_get_time(timer);
- now = ktime_sub(now, base->delta);
-
- pr_alarm(INT, "alarm_timer_triggered type %ld at %lld\n",
- base - alarms, ktime_to_ns(now));
-
- while (base->first) {
- alarm = container_of(base->first, struct android_alarm, node);
- if (alarm->softexpires.tv64 > now.tv64) {
- pr_alarm(FLOW, "don't call alarm, %pF, %lld (s %lld)\n",
- alarm->function, ktime_to_ns(alarm->expires),
- ktime_to_ns(alarm->softexpires));
- break;
- }
- base->first = rb_next(&alarm->node);
- rb_erase(&alarm->node, &base->alarms);
- RB_CLEAR_NODE(&alarm->node);
- pr_alarm(CALL, "call alarm, type %d, func %pF, %lld (s %lld)\n",
- alarm->type, alarm->function,
- ktime_to_ns(alarm->expires),
- ktime_to_ns(alarm->softexpires));
- spin_unlock_irqrestore(&alarm_slock, flags);
- alarm->function(alarm);
- spin_lock_irqsave(&alarm_slock, flags);
- }
- if (!base->first)
- pr_alarm(FLOW, "no more alarms of type %ld\n", base - alarms);
- update_timer_locked(base, true);
- spin_unlock_irqrestore(&alarm_slock, flags);
- return HRTIMER_NORESTART;
-}
-
-static void alarm_triggered_func(void *p)
-{
- struct rtc_device *rtc = alarm_rtc_dev;
- if (!(rtc->irq_data & RTC_AF))
- return;
- pr_alarm(INT, "rtc alarm triggered\n");
- wake_lock_timeout(&alarm_rtc_wake_lock, 1 * HZ);
-}
-
-static int alarm_suspend(struct platform_device *pdev, pm_message_t state)
-{
- int err = 0;
- unsigned long flags;
- struct rtc_wkalrm rtc_alarm;
- struct rtc_time rtc_current_rtc_time;
- unsigned long rtc_current_time;
- unsigned long rtc_alarm_time;
- struct timespec rtc_delta;
- struct timespec wall_time;
- struct alarm_queue *wakeup_queue = NULL;
- struct alarm_queue *tmp_queue = NULL;
-
- pr_alarm(SUSPEND, "alarm_suspend(%p, %d)\n", pdev, state.event);
-
- spin_lock_irqsave(&alarm_slock, flags);
- suspended = true;
- spin_unlock_irqrestore(&alarm_slock, flags);
-
- hrtimer_cancel(&alarms[ANDROID_ALARM_RTC_WAKEUP].timer);
- hrtimer_cancel(&alarms[
- ANDROID_ALARM_ELAPSED_REALTIME_WAKEUP].timer);
-
- tmp_queue = &alarms[ANDROID_ALARM_RTC_WAKEUP];
- if (tmp_queue->first)
- wakeup_queue = tmp_queue;
- tmp_queue = &alarms[ANDROID_ALARM_ELAPSED_REALTIME_WAKEUP];
- if (tmp_queue->first && (!wakeup_queue ||
- hrtimer_get_expires(&tmp_queue->timer).tv64 <
- hrtimer_get_expires(&wakeup_queue->timer).tv64))
- wakeup_queue = tmp_queue;
- if (wakeup_queue) {
- rtc_read_time(alarm_rtc_dev, &rtc_current_rtc_time);
- getnstimeofday(&wall_time);
- rtc_tm_to_time(&rtc_current_rtc_time, &rtc_current_time);
- set_normalized_timespec(&rtc_delta,
- wall_time.tv_sec - rtc_current_time,
- wall_time.tv_nsec);
-
- rtc_alarm_time = timespec_sub(ktime_to_timespec(
- hrtimer_get_expires(&wakeup_queue->timer)),
- rtc_delta).tv_sec;
-
- rtc_time_to_tm(rtc_alarm_time, &rtc_alarm.time);
- rtc_alarm.enabled = 1;
- rtc_set_alarm(alarm_rtc_dev, &rtc_alarm);
- rtc_read_time(alarm_rtc_dev, &rtc_current_rtc_time);
- rtc_tm_to_time(&rtc_current_rtc_time, &rtc_current_time);
- pr_alarm(SUSPEND,
- "rtc alarm set at %ld, now %ld, rtc delta %ld.%09ld\n",
- rtc_alarm_time, rtc_current_time,
- rtc_delta.tv_sec, rtc_delta.tv_nsec);
- if (rtc_current_time + 1 >= rtc_alarm_time) {
- pr_alarm(SUSPEND, "alarm about to go off\n");
- memset(&rtc_alarm, 0, sizeof(rtc_alarm));
- rtc_alarm.enabled = 0;
- rtc_set_alarm(alarm_rtc_dev, &rtc_alarm);
-
- spin_lock_irqsave(&alarm_slock, flags);
- suspended = false;
- wake_lock_timeout(&alarm_rtc_wake_lock, 2 * HZ);
- update_timer_locked(&alarms[ANDROID_ALARM_RTC_WAKEUP],
- false);
- update_timer_locked(&alarms[
- ANDROID_ALARM_ELAPSED_REALTIME_WAKEUP], false);
- err = -EBUSY;
- spin_unlock_irqrestore(&alarm_slock, flags);
- }
- }
- return err;
-}
-
-static int alarm_resume(struct platform_device *pdev)
-{
- struct rtc_wkalrm alarm;
- unsigned long flags;
-
- pr_alarm(SUSPEND, "alarm_resume(%p)\n", pdev);
-
- memset(&alarm, 0, sizeof(alarm));
- alarm.enabled = 0;
- rtc_set_alarm(alarm_rtc_dev, &alarm);
-
- spin_lock_irqsave(&alarm_slock, flags);
- suspended = false;
- update_timer_locked(&alarms[ANDROID_ALARM_RTC_WAKEUP], false);
- update_timer_locked(&alarms[ANDROID_ALARM_ELAPSED_REALTIME_WAKEUP],
- false);
- spin_unlock_irqrestore(&alarm_slock, flags);
-
- return 0;
-}
-
-static struct rtc_task alarm_rtc_task = {
- .func = alarm_triggered_func
-};
-
-static int rtc_alarm_add_device(struct device *dev,
- struct class_interface *class_intf)
-{
- int err;
- struct rtc_device *rtc = to_rtc_device(dev);
-
- mutex_lock(&alarm_setrtc_mutex);
-
- if (alarm_rtc_dev) {
- err = -EBUSY;
- goto err1;
- }
-
- alarm_platform_dev =
- platform_device_register_simple("alarm", -1, NULL, 0);
- if (IS_ERR(alarm_platform_dev)) {
- err = PTR_ERR(alarm_platform_dev);
- goto err2;
- }
- err = rtc_irq_register(rtc, &alarm_rtc_task);
- if (err)
- goto err3;
- alarm_rtc_dev = rtc;
- pr_alarm(INIT_STATUS, "using rtc device, %s, for alarms", rtc->name);
- mutex_unlock(&alarm_setrtc_mutex);
-
- return 0;
-
-err3:
- platform_device_unregister(alarm_platform_dev);
-err2:
-err1:
- mutex_unlock(&alarm_setrtc_mutex);
- return err;
-}
-
-static void rtc_alarm_remove_device(struct device *dev,
- struct class_interface *class_intf)
-{
- if (dev == &alarm_rtc_dev->dev) {
- pr_alarm(INIT_STATUS, "lost rtc device for alarms");
- rtc_irq_unregister(alarm_rtc_dev, &alarm_rtc_task);
- platform_device_unregister(alarm_platform_dev);
- alarm_rtc_dev = NULL;
- }
-}
-
-static struct class_interface rtc_alarm_interface = {
- .add_dev = &rtc_alarm_add_device,
- .remove_dev = &rtc_alarm_remove_device,
-};
-
-static struct platform_driver alarm_driver = {
- .suspend = alarm_suspend,
- .resume = alarm_resume,
- .driver = {
- .name = "alarm"
- }
-};
-
-static int __init alarm_late_init(void)
-{
- unsigned long flags;
- struct timespec tmp_time, system_time;
-
- /* this needs to run after the rtc is read at boot */
- spin_lock_irqsave(&alarm_slock, flags);
- /* We read the current rtc and system time so we can later calulate
- * elasped realtime to be (boot_systemtime + rtc - boot_rtc) ==
- * (rtc - (boot_rtc - boot_systemtime))
- */
- getnstimeofday(&tmp_time);
- ktime_get_ts(&system_time);
- alarms[ANDROID_ALARM_ELAPSED_REALTIME_WAKEUP].delta =
- alarms[ANDROID_ALARM_ELAPSED_REALTIME].delta =
- timespec_to_ktime(timespec_sub(tmp_time, system_time));
-
- spin_unlock_irqrestore(&alarm_slock, flags);
- return 0;
-}
-
-static int __init alarm_driver_init(void)
-{
- int err;
- int i;
-
- for (i = 0; i < ANDROID_ALARM_SYSTEMTIME; i++) {
- hrtimer_init(&alarms[i].timer,
- CLOCK_REALTIME, HRTIMER_MODE_ABS);
- alarms[i].timer.function = alarm_timer_triggered;
- }
- hrtimer_init(&alarms[ANDROID_ALARM_SYSTEMTIME].timer,
- CLOCK_MONOTONIC, HRTIMER_MODE_ABS);
- alarms[ANDROID_ALARM_SYSTEMTIME].timer.function = alarm_timer_triggered;
- err = platform_driver_register(&alarm_driver);
- if (err < 0)
- goto err1;
- wake_lock_init(&alarm_rtc_wake_lock, WAKE_LOCK_SUSPEND, "alarm_rtc");
- rtc_alarm_interface.class = rtc_class;
- err = class_interface_register(&rtc_alarm_interface);
- if (err < 0)
- goto err2;
-
- return 0;
-
-err2:
- wake_lock_destroy(&alarm_rtc_wake_lock);
- platform_driver_unregister(&alarm_driver);
-err1:
- return err;
-}
-
-static void __exit alarm_exit(void)
-{
- class_interface_unregister(&rtc_alarm_interface);
- wake_lock_destroy(&alarm_rtc_wake_lock);
- platform_driver_unregister(&alarm_driver);
-}
-
-late_initcall(alarm_late_init);
-module_init(alarm_driver_init);
-module_exit(alarm_exit);
-
diff --git a/drivers/staging/android/android_alarm.h b/drivers/staging/android/android_alarm.h
index 6eecbde2ef6f..d0cafd637199 100644
--- a/drivers/staging/android/android_alarm.h
+++ b/drivers/staging/android/android_alarm.h
@@ -33,65 +33,6 @@ enum android_alarm_type {
/* ANDROID_ALARM_TIME_CHANGE = 16 */
};
-#ifdef __KERNEL__
-
-#include <linux/ktime.h>
-#include <linux/rbtree.h>
-
-/*
- * The alarm interface is similar to the hrtimer interface but adds support
- * for wakeup from suspend. It also adds an elapsed realtime clock that can
- * be used for periodic timers that need to keep runing while the system is
- * suspended and not be disrupted when the wall time is set.
- */
-
-/**
- * struct alarm - the basic alarm structure
- * @node: red black tree node for time ordered insertion
- * @type: alarm type. rtc/elapsed-realtime/systemtime, wakeup/non-wakeup.
- * @softexpires: the absolute earliest expiry time of the alarm.
- * @expires: the absolute expiry time.
- * @function: alarm expiry callback function
- *
- * The alarm structure must be initialized by alarm_init()
- *
- */
-
-struct android_alarm {
- struct rb_node node;
- enum android_alarm_type type;
- ktime_t softexpires;
- ktime_t expires;
- void (*function)(struct android_alarm *);
-};
-
-void android_alarm_init(struct android_alarm *alarm,
- enum android_alarm_type type, void (*function)(struct android_alarm *));
-void android_alarm_start_range(struct android_alarm *alarm, ktime_t start,
- ktime_t end);
-int android_alarm_try_to_cancel(struct android_alarm *alarm);
-int android_alarm_cancel(struct android_alarm *alarm);
-ktime_t alarm_get_elapsed_realtime(void);
-
-/* set rtc while preserving elapsed realtime */
-int android_alarm_set_rtc(const struct timespec ts);
-
-#ifdef CONFIG_ANDROID_ALARM_OLDDRV_COMPAT
-/*
- * Some older drivers depend on the old API,
- * so provide compatability macros for now.
- */
-#define alarm android_alarm
-#define alarm_init(x, y, z) android_alarm_init(x, y, z)
-#define alarm_start_range(x, y, z) android_alarm_start_range(x, y, z)
-#define alarm_try_to_cancel(x) android_alarm_try_to_cancel(x)
-#define alarm_cancel(x) android_alarm_cancel(x)
-#define alarm_set_rtc(x) android_alarm_set_rtc(x)
-#endif
-
-
-#endif
-
enum android_alarm_return_flags {
ANDROID_ALARM_RTC_WAKEUP_MASK = 1U << ANDROID_ALARM_RTC_WAKEUP,
ANDROID_ALARM_RTC_MASK = 1U << ANDROID_ALARM_RTC,
diff --git a/drivers/staging/android/ashmem.c b/drivers/staging/android/ashmem.c
index 4511420849bc..69cf2db1d69c 100644
--- a/drivers/staging/android/ashmem.c
+++ b/drivers/staging/android/ashmem.c
@@ -16,9 +16,12 @@
** GNU General Public License for more details.
*/
+#define pr_fmt(fmt) "ashmem: " fmt
+
#include <linux/module.h>
#include <linux/file.h>
#include <linux/fs.h>
+#include <linux/falloc.h>
#include <linux/miscdevice.h>
#include <linux/security.h>
#include <linux/mm.h>
@@ -363,11 +366,12 @@ static int ashmem_shrink(struct shrinker *s, struct shrink_control *sc)
mutex_lock(&ashmem_mutex);
list_for_each_entry_safe(range, next, &ashmem_lru_list, lru) {
- struct inode *inode = range->asma->file->f_dentry->d_inode;
loff_t start = range->pgstart * PAGE_SIZE;
- loff_t end = (range->pgend + 1) * PAGE_SIZE - 1;
+ loff_t end = (range->pgend + 1) * PAGE_SIZE;
- vmtruncate_range(inode, start, end);
+ do_fallocate(range->asma->file,
+ FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE,
+ start, end - start);
range->purged = ASHMEM_WAS_PURGED;
lru_del(range);
@@ -705,7 +709,7 @@ static int __init ashmem_init(void)
sizeof(struct ashmem_area),
0, 0, NULL);
if (unlikely(!ashmem_area_cachep)) {
- printk(KERN_ERR "ashmem: failed to create slab cache\n");
+ pr_err("failed to create slab cache\n");
return -ENOMEM;
}
@@ -713,19 +717,19 @@ static int __init ashmem_init(void)
sizeof(struct ashmem_range),
0, 0, NULL);
if (unlikely(!ashmem_range_cachep)) {
- printk(KERN_ERR "ashmem: failed to create slab cache\n");
+ pr_err("failed to create slab cache\n");
return -ENOMEM;
}
ret = misc_register(&ashmem_misc);
if (unlikely(ret)) {
- printk(KERN_ERR "ashmem: failed to register misc device!\n");
+ pr_err("failed to register misc device!\n");
return ret;
}
register_shrinker(&ashmem_shrinker);
- printk(KERN_INFO "ashmem: initialized\n");
+ pr_info("initialized\n");
return 0;
}
@@ -738,12 +742,12 @@ static void __exit ashmem_exit(void)
ret = misc_deregister(&ashmem_misc);
if (unlikely(ret))
- printk(KERN_ERR "ashmem: failed to unregister misc device!\n");
+ pr_err("failed to unregister misc device!\n");
kmem_cache_destroy(ashmem_range_cachep);
kmem_cache_destroy(ashmem_area_cachep);
- printk(KERN_INFO "ashmem: unloaded\n");
+ pr_info("unloaded\n");
}
module_init(ashmem_init);
diff --git a/drivers/staging/android/binder.c b/drivers/staging/android/binder.c
index c2832124bb3e..574e99210c36 100644
--- a/drivers/staging/android/binder.c
+++ b/drivers/staging/android/binder.c
@@ -124,13 +124,13 @@ module_param_call(stop_on_user_error, binder_set_stop_on_user_error,
#define binder_debug(mask, x...) \
do { \
if (binder_debug_mask & mask) \
- printk(KERN_INFO x); \
+ pr_info(x); \
} while (0)
#define binder_user_error(x...) \
do { \
if (binder_debug_mask & BINDER_DEBUG_USER_ERROR) \
- printk(KERN_INFO x); \
+ pr_info(x); \
if (binder_stop_on_user_error) \
binder_stop_on_user_error = 2; \
} while (0)
@@ -418,7 +418,7 @@ repeat:
#if 1
/* Sanity check */
if (fdt->fd[fd] != NULL) {
- printk(KERN_WARNING "get_unused_fd: slot %d not NULL!\n", fd);
+ pr_warn("get_unused_fd: slot %d not NULL!\n", fd);
fdt->fd[fd] = NULL;
}
#endif
@@ -644,7 +644,7 @@ static int binder_update_page_range(struct binder_proc *proc, int allocate,
goto free_range;
if (vma == NULL) {
- printk(KERN_ERR "binder: %d: binder_alloc_buf failed to "
+ pr_err("binder: %d: binder_alloc_buf failed to "
"map pages in userspace, no vma\n", proc->pid);
goto err_no_vma;
}
@@ -657,7 +657,7 @@ static int binder_update_page_range(struct binder_proc *proc, int allocate,
BUG_ON(*page);
*page = alloc_page(GFP_KERNEL | __GFP_ZERO);
if (*page == NULL) {
- printk(KERN_ERR "binder: %d: binder_alloc_buf failed "
+ pr_err("binder: %d: binder_alloc_buf failed "
"for page at %p\n", proc->pid, page_addr);
goto err_alloc_page_failed;
}
@@ -666,7 +666,7 @@ static int binder_update_page_range(struct binder_proc *proc, int allocate,
page_array_ptr = page;
ret = map_vm_area(&tmp_area, PAGE_KERNEL, &page_array_ptr);
if (ret) {
- printk(KERN_ERR "binder: %d: binder_alloc_buf failed "
+ pr_err("binder: %d: binder_alloc_buf failed "
"to map page at %p in kernel\n",
proc->pid, page_addr);
goto err_map_kernel_failed;
@@ -675,7 +675,7 @@ static int binder_update_page_range(struct binder_proc *proc, int allocate,
(uintptr_t)page_addr + proc->user_buffer_offset;
ret = vm_insert_page(vma, user_page_addr, page[0]);
if (ret) {
- printk(KERN_ERR "binder: %d: binder_alloc_buf failed "
+ pr_err("binder: %d: binder_alloc_buf failed "
"to map page at %lx in userspace\n",
proc->pid, user_page_addr);
goto err_vm_insert_page_failed;
@@ -724,7 +724,7 @@ static struct binder_buffer *binder_alloc_buf(struct binder_proc *proc,
size_t size;
if (proc->vma == NULL) {
- printk(KERN_ERR "binder: %d: binder_alloc_buf, no vma\n",
+ pr_err("binder: %d: binder_alloc_buf, no vma\n",
proc->pid);
return NULL;
}
@@ -762,7 +762,7 @@ static struct binder_buffer *binder_alloc_buf(struct binder_proc *proc,
}
}
if (best_fit == NULL) {
- printk(KERN_ERR "binder: %d: binder_alloc_buf size %zd failed, "
+ pr_err("binder: %d: binder_alloc_buf size %zd failed, "
"no address space\n", proc->pid, size);
return NULL;
}
@@ -997,7 +997,7 @@ static int binder_inc_node(struct binder_node *node, int strong, int internal,
node->internal_strong_refs == 0 &&
!(node == binder_context_mgr_node &&
node->has_strong_ref)) {
- printk(KERN_ERR "binder: invalid inc strong "
+ pr_err("binder: invalid inc strong "
"node for %d\n", node->debug_id);
return -EINVAL;
}
@@ -1013,7 +1013,7 @@ static int binder_inc_node(struct binder_node *node, int strong, int internal,
node->local_weak_refs++;
if (!node->has_weak_ref && list_empty(&node->work.entry)) {
if (target_list == NULL) {
- printk(KERN_ERR "binder: invalid inc weak node "
+ pr_err("binder: invalid inc weak node "
"for %d\n", node->debug_id);
return -EINVAL;
}
@@ -1276,7 +1276,7 @@ static void binder_send_failed_reply(struct binder_transaction *t,
target_thread->return_error = error_code;
wake_up_interruptible(&target_thread->wait);
} else {
- printk(KERN_ERR "binder: reply failed, target "
+ pr_err("binder: reply failed, target "
"thread, %d:%d, has error code %d "
"already\n", target_thread->proc->pid,
target_thread->pid,
@@ -1331,7 +1331,7 @@ static void binder_transaction_buffer_release(struct binder_proc *proc,
if (*offp > buffer->data_size - sizeof(*fp) ||
buffer->data_size < sizeof(*fp) ||
!IS_ALIGNED(*offp, sizeof(void *))) {
- printk(KERN_ERR "binder: transaction release %d bad"
+ pr_err("binder: transaction release %d bad"
"offset %zd, size %zd\n", debug_id,
*offp, buffer->data_size);
continue;
@@ -1342,7 +1342,7 @@ static void binder_transaction_buffer_release(struct binder_proc *proc,
case BINDER_TYPE_WEAK_BINDER: {
struct binder_node *node = binder_get_node(proc, fp->binder);
if (node == NULL) {
- printk(KERN_ERR "binder: transaction release %d"
+ pr_err("binder: transaction release %d"
" bad node %p\n", debug_id, fp->binder);
break;
}
@@ -1355,7 +1355,7 @@ static void binder_transaction_buffer_release(struct binder_proc *proc,
case BINDER_TYPE_WEAK_HANDLE: {
struct binder_ref *ref = binder_get_ref(proc, fp->handle);
if (ref == NULL) {
- printk(KERN_ERR "binder: transaction release %d"
+ pr_err("binder: transaction release %d"
" bad handle %ld\n", debug_id,
fp->handle);
break;
@@ -1374,7 +1374,7 @@ static void binder_transaction_buffer_release(struct binder_proc *proc,
break;
default:
- printk(KERN_ERR "binder: transaction release %d bad "
+ pr_err("binder: transaction release %d bad "
"object type %lx\n", debug_id, fp->type);
break;
}
@@ -1925,10 +1925,10 @@ int binder_thread_write(struct binder_proc *proc, struct binder_thread *thread,
break;
}
case BC_ATTEMPT_ACQUIRE:
- printk(KERN_ERR "binder: BC_ATTEMPT_ACQUIRE not supported\n");
+ pr_err("binder: BC_ATTEMPT_ACQUIRE not supported\n");
return -EINVAL;
case BC_ACQUIRE_RESULT:
- printk(KERN_ERR "binder: BC_ACQUIRE_RESULT not supported\n");
+ pr_err("binder: BC_ACQUIRE_RESULT not supported\n");
return -EINVAL;
case BC_FREE_BUFFER: {
@@ -2165,7 +2165,7 @@ int binder_thread_write(struct binder_proc *proc, struct binder_thread *thread,
} break;
default:
- printk(KERN_ERR "binder: %d:%d unknown command %d\n",
+ pr_err("binder: %d:%d unknown command %d\n",
proc->pid, thread->pid, cmd);
return -EINVAL;
}
@@ -2635,7 +2635,7 @@ static long binder_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
unsigned int size = _IOC_SIZE(cmd);
void __user *ubuf = (void __user *)arg;
- /*printk(KERN_INFO "binder_ioctl: %d:%d %x %lx\n", proc->pid, current->pid, cmd, arg);*/
+ /*pr_info("binder_ioctl: %d:%d %x %lx\n", proc->pid, current->pid, cmd, arg);*/
ret = wait_event_interruptible(binder_user_error_wait, binder_stop_on_user_error < 2);
if (ret)
@@ -2701,13 +2701,13 @@ static long binder_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
break;
case BINDER_SET_CONTEXT_MGR:
if (binder_context_mgr_node != NULL) {
- printk(KERN_ERR "binder: BINDER_SET_CONTEXT_MGR already set\n");
+ pr_err("binder: BINDER_SET_CONTEXT_MGR already set\n");
ret = -EBUSY;
goto err;
}
if (binder_context_mgr_uid != -1) {
if (binder_context_mgr_uid != current->cred->euid) {
- printk(KERN_ERR "binder: BINDER_SET_"
+ pr_err("binder: BINDER_SET_"
"CONTEXT_MGR bad uid %d != %d\n",
current->cred->euid,
binder_context_mgr_uid);
@@ -2753,7 +2753,7 @@ err:
mutex_unlock(&binder_lock);
wait_event_interruptible(binder_user_error_wait, binder_stop_on_user_error < 2);
if (ret && ret != -ERESTARTSYS)
- printk(KERN_INFO "binder: %d:%d ioctl %x %lx returned %d\n", proc->pid, current->pid, cmd, arg, ret);
+ pr_info("binder: %d:%d ioctl %x %lx returned %d\n", proc->pid, current->pid, cmd, arg, ret);
return ret;
}
@@ -2829,7 +2829,7 @@ static int binder_mmap(struct file *filp, struct vm_area_struct *vma)
#ifdef CONFIG_CPU_CACHE_VIPT
if (cache_is_vipt_aliasing()) {
while (CACHE_COLOUR((vma->vm_start ^ (uint32_t)proc->buffer))) {
- printk(KERN_INFO "binder_mmap: %d %lx-%lx maps %p bad alignment\n", proc->pid, vma->vm_start, vma->vm_end, proc->buffer);
+ pr_info("binder_mmap: %d %lx-%lx maps %p bad alignment\n", proc->pid, vma->vm_start, vma->vm_end, proc->buffer);
vma->vm_start += PAGE_SIZE;
}
}
@@ -2861,7 +2861,7 @@ static int binder_mmap(struct file *filp, struct vm_area_struct *vma)
proc->vma = vma;
proc->vma_vm_mm = vma->vm_mm;
- /*printk(KERN_INFO "binder_mmap: %d %lx-%lx maps %p\n",
+ /*pr_info("binder_mmap: %d %lx-%lx maps %p\n",
proc->pid, vma->vm_start, vma->vm_end, proc->buffer);*/
return 0;
@@ -2876,7 +2876,7 @@ err_get_vm_area_failed:
err_already_mapped:
mutex_unlock(&binder_mmap_lock);
err_bad_arg:
- printk(KERN_ERR "binder_mmap: %d %lx-%lx %s failed %d\n",
+ pr_err("binder_mmap: %d %lx-%lx %s failed %d\n",
proc->pid, vma->vm_start, vma->vm_end, failure_string, ret);
return ret;
}
@@ -3031,7 +3031,7 @@ static void binder_deferred_release(struct binder_proc *proc)
if (t) {
t->buffer = NULL;
buffer->transaction = NULL;
- printk(KERN_ERR "binder: release proc %d, "
+ pr_err("binder: release proc %d, "
"transaction %d, not freed\n",
proc->pid, t->debug_id);
/*BUG();*/
diff --git a/drivers/staging/android/binder.h b/drivers/staging/android/binder.h
index 25ab6f2759e9..2f7d195d8b15 100644
--- a/drivers/staging/android/binder.h
+++ b/drivers/staging/android/binder.h
@@ -53,17 +53,17 @@ struct flat_binder_object {
/* 8 bytes of data. */
union {
- void *binder; /* local object */
+ void __user *binder; /* local object */
signed long handle; /* remote object */
};
/* extra data associated with local object */
- void *cookie;
+ void __user *cookie;
};
/*
* On 64-bit platforms where user code may run in 32-bits the driver must
- * translate the buffer (and local binder) addresses apropriately.
+ * translate the buffer (and local binder) addresses appropriately.
*/
struct binder_write_read {
@@ -139,9 +139,9 @@ struct binder_transaction_data {
union {
struct {
/* transaction data */
- const void *buffer;
+ const void __user *buffer;
/* offsets from buffer to flat_binder_object structs */
- const void *offsets;
+ const void __user *offsets;
} ptr;
uint8_t buf[8];
} data;
diff --git a/drivers/staging/android/logger.c b/drivers/staging/android/logger.c
index ea69b6a77dac..f7b8237d5be7 100644
--- a/drivers/staging/android/logger.c
+++ b/drivers/staging/android/logger.c
@@ -17,6 +17,8 @@
* GNU General Public License for more details.
*/
+#define pr_fmt(fmt) "logger: " fmt
+
#include <linux/sched.h>
#include <linux/module.h>
#include <linux/fs.h>
@@ -25,6 +27,7 @@
#include <linux/poll.h>
#include <linux/slab.h>
#include <linux/time.h>
+#include <linux/vmalloc.h>
#include "logger.h"
#include <asm/ioctls.h>
@@ -45,8 +48,12 @@ struct logger_log {
size_t w_off; /* current write head offset */
size_t head; /* new readers start here */
size_t size; /* size of the log */
+ struct list_head logs; /* list of log channels (myself)*/
};
+static LIST_HEAD(log_list);
+
+
/*
* struct logger_reader - a logging device open for reading
*
@@ -60,9 +67,9 @@ struct logger_reader {
};
/* logger_offset - returns index 'n' into the log via (optimized) modulus */
-size_t logger_offset(struct logger_log *log, size_t n)
+static size_t logger_offset(struct logger_log *log, size_t n)
{
- return n & (log->size-1);
+ return n & (log->size - 1);
}
@@ -348,7 +355,7 @@ static ssize_t do_write_log_from_user(struct logger_log *log,
* writev(), and aio_write(). Writes are our fast path, and we try to optimize
* them above all else.
*/
-ssize_t logger_aio_write(struct kiocb *iocb, const struct iovec *iov,
+static ssize_t logger_aio_write(struct kiocb *iocb, const struct iovec *iov,
unsigned long nr_segs, loff_t ppos)
{
struct logger_log *log = file_get_log(iocb->ki_filp);
@@ -408,7 +415,15 @@ ssize_t logger_aio_write(struct kiocb *iocb, const struct iovec *iov,
return ret;
}
-static struct logger_log *get_log_from_minor(int);
+static struct logger_log *get_log_from_minor(int minor)
+{
+ struct logger_log *log;
+
+ list_for_each_entry(log, &log_list, logs)
+ if (log->misc.minor == minor)
+ return log;
+ return NULL;
+}
/*
* logger_open - the log's open() file operation
@@ -565,80 +580,84 @@ static const struct file_operations logger_fops = {
};
/*
- * Defines a log structure with name 'NAME' and a size of 'SIZE' bytes, which
- * must be a power of two, greater than LOGGER_ENTRY_MAX_LEN, and less than
- * LONG_MAX minus LOGGER_ENTRY_MAX_LEN.
+ * Log size must be a power of two, greater than LOGGER_ENTRY_MAX_LEN,
+ * and less than LONG_MAX minus LOGGER_ENTRY_MAX_LEN.
*/
-#define DEFINE_LOGGER_DEVICE(VAR, NAME, SIZE) \
-static unsigned char _buf_ ## VAR[SIZE]; \
-static struct logger_log VAR = { \
- .buffer = _buf_ ## VAR, \
- .misc = { \
- .minor = MISC_DYNAMIC_MINOR, \
- .name = NAME, \
- .fops = &logger_fops, \
- .parent = NULL, \
- }, \
- .wq = __WAIT_QUEUE_HEAD_INITIALIZER(VAR .wq), \
- .readers = LIST_HEAD_INIT(VAR .readers), \
- .mutex = __MUTEX_INITIALIZER(VAR .mutex), \
- .w_off = 0, \
- .head = 0, \
- .size = SIZE, \
-};
+static int __init create_log(char *log_name, int size)
+{
+ int ret = 0;
+ struct logger_log *log;
+ unsigned char *buffer;
-DEFINE_LOGGER_DEVICE(log_main, LOGGER_LOG_MAIN, 256*1024)
-DEFINE_LOGGER_DEVICE(log_events, LOGGER_LOG_EVENTS, 256*1024)
-DEFINE_LOGGER_DEVICE(log_radio, LOGGER_LOG_RADIO, 256*1024)
-DEFINE_LOGGER_DEVICE(log_system, LOGGER_LOG_SYSTEM, 256*1024)
+ buffer = vmalloc(size);
+ if (buffer == NULL)
+ return -ENOMEM;
-static struct logger_log *get_log_from_minor(int minor)
-{
- if (log_main.misc.minor == minor)
- return &log_main;
- if (log_events.misc.minor == minor)
- return &log_events;
- if (log_radio.misc.minor == minor)
- return &log_radio;
- if (log_system.misc.minor == minor)
- return &log_system;
- return NULL;
-}
+ log = kzalloc(sizeof(struct logger_log), GFP_KERNEL);
+ if (log == NULL) {
+ ret = -ENOMEM;
+ goto out_free_buffer;
+ }
+ log->buffer = buffer;
-static int __init init_log(struct logger_log *log)
-{
- int ret;
+ log->misc.minor = MISC_DYNAMIC_MINOR;
+ log->misc.name = kstrdup(log_name, GFP_KERNEL);
+ if (log->misc.name == NULL) {
+ ret = -ENOMEM;
+ goto out_free_log;
+ }
+
+ log->misc.fops = &logger_fops;
+ log->misc.parent = NULL;
+ init_waitqueue_head(&log->wq);
+ INIT_LIST_HEAD(&log->readers);
+ mutex_init(&log->mutex);
+ log->w_off = 0;
+ log->head = 0;
+ log->size = size;
+
+ INIT_LIST_HEAD(&log->logs);
+ list_add_tail(&log->logs, &log_list);
+
+ /* finally, initialize the misc device for this log */
ret = misc_register(&log->misc);
if (unlikely(ret)) {
- printk(KERN_ERR "logger: failed to register misc "
- "device for log '%s'!\n", log->misc.name);
- return ret;
+ pr_err("failed to register misc device for log '%s'!\n",
+ log->misc.name);
+ goto out_free_log;
}
- printk(KERN_INFO "logger: created %luK log '%s'\n",
- (unsigned long) log->size >> 10, log->misc.name);
+ pr_info("created %luK log '%s'\n",
+ (unsigned long) log->size >> 10, log->misc.name);
return 0;
+
+out_free_log:
+ kfree(log);
+
+out_free_buffer:
+ vfree(buffer);
+ return ret;
}
static int __init logger_init(void)
{
int ret;
- ret = init_log(&log_main);
+ ret = create_log(LOGGER_LOG_MAIN, 256*1024);
if (unlikely(ret))
goto out;
- ret = init_log(&log_events);
+ ret = create_log(LOGGER_LOG_EVENTS, 256*1024);
if (unlikely(ret))
goto out;
- ret = init_log(&log_radio);
+ ret = create_log(LOGGER_LOG_RADIO, 256*1024);
if (unlikely(ret))
goto out;
- ret = init_log(&log_system);
+ ret = create_log(LOGGER_LOG_SYSTEM, 256*1024);
if (unlikely(ret))
goto out;
diff --git a/drivers/staging/android/persistent_ram.c b/drivers/staging/android/persistent_ram.c
deleted file mode 100644
index 8d8c1e33e0ff..000000000000
--- a/drivers/staging/android/persistent_ram.c
+++ /dev/null
@@ -1,473 +0,0 @@
-/*
- * Copyright (C) 2012 Google, Inc.
- *
- * This software is licensed under the terms of the GNU General Public
- * License version 2, as published by the Free Software Foundation, and
- * may be copied, distributed, and modified under those terms.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- */
-
-#include <linux/device.h>
-#include <linux/err.h>
-#include <linux/errno.h>
-#include <linux/kernel.h>
-#include <linux/init.h>
-#include <linux/io.h>
-#include <linux/list.h>
-#include <linux/memblock.h>
-#include <linux/rslib.h>
-#include <linux/slab.h>
-#include <linux/vmalloc.h>
-#include "persistent_ram.h"
-
-struct persistent_ram_buffer {
- uint32_t sig;
- atomic_t start;
- atomic_t size;
- uint8_t data[0];
-};
-
-#define PERSISTENT_RAM_SIG (0x43474244) /* DBGC */
-
-static __initdata LIST_HEAD(persistent_ram_list);
-
-static inline size_t buffer_size(struct persistent_ram_zone *prz)
-{
- return atomic_read(&prz->buffer->size);
-}
-
-static inline size_t buffer_start(struct persistent_ram_zone *prz)
-{
- return atomic_read(&prz->buffer->start);
-}
-
-/* increase and wrap the start pointer, returning the old value */
-static inline size_t buffer_start_add(struct persistent_ram_zone *prz, size_t a)
-{
- int old;
- int new;
-
- do {
- old = atomic_read(&prz->buffer->start);
- new = old + a;
- while (unlikely(new > prz->buffer_size))
- new -= prz->buffer_size;
- } while (atomic_cmpxchg(&prz->buffer->start, old, new) != old);
-
- return old;
-}
-
-/* increase the size counter until it hits the max size */
-static inline void buffer_size_add(struct persistent_ram_zone *prz, size_t a)
-{
- size_t old;
- size_t new;
-
- if (atomic_read(&prz->buffer->size) == prz->buffer_size)
- return;
-
- do {
- old = atomic_read(&prz->buffer->size);
- new = old + a;
- if (new > prz->buffer_size)
- new = prz->buffer_size;
- } while (atomic_cmpxchg(&prz->buffer->size, old, new) != old);
-}
-
-/* increase the size counter, retuning an error if it hits the max size */
-static inline ssize_t buffer_size_add_clamp(struct persistent_ram_zone *prz,
- size_t a)
-{
- size_t old;
- size_t new;
-
- do {
- old = atomic_read(&prz->buffer->size);
- new = old + a;
- if (new > prz->buffer_size)
- return -ENOMEM;
- } while (atomic_cmpxchg(&prz->buffer->size, old, new) != old);
-
- return 0;
-}
-
-static void notrace persistent_ram_encode_rs8(struct persistent_ram_zone *prz,
- uint8_t *data, size_t len, uint8_t *ecc)
-{
- int i;
- uint16_t par[prz->ecc_size];
-
- /* Initialize the parity buffer */
- memset(par, 0, sizeof(par));
- encode_rs8(prz->rs_decoder, data, len, par, 0);
- for (i = 0; i < prz->ecc_size; i++)
- ecc[i] = par[i];
-}
-
-static int persistent_ram_decode_rs8(struct persistent_ram_zone *prz,
- void *data, size_t len, uint8_t *ecc)
-{
- int i;
- uint16_t par[prz->ecc_size];
-
- for (i = 0; i < prz->ecc_size; i++)
- par[i] = ecc[i];
- return decode_rs8(prz->rs_decoder, data, par, len,
- NULL, 0, NULL, 0, NULL);
-}
-
-static void notrace persistent_ram_update_ecc(struct persistent_ram_zone *prz,
- unsigned int start, unsigned int count)
-{
- struct persistent_ram_buffer *buffer = prz->buffer;
- uint8_t *buffer_end = buffer->data + prz->buffer_size;
- uint8_t *block;
- uint8_t *par;
- int ecc_block_size = prz->ecc_block_size;
- int ecc_size = prz->ecc_size;
- int size = prz->ecc_block_size;
-
- if (!prz->ecc)
- return;
-
- block = buffer->data + (start & ~(ecc_block_size - 1));
- par = prz->par_buffer + (start / ecc_block_size) * prz->ecc_size;
-
- do {
- if (block + ecc_block_size > buffer_end)
- size = buffer_end - block;
- persistent_ram_encode_rs8(prz, block, size, par);
- block += ecc_block_size;
- par += ecc_size;
- } while (block < buffer->data + start + count);
-}
-
-static void persistent_ram_update_header_ecc(struct persistent_ram_zone *prz)
-{
- struct persistent_ram_buffer *buffer = prz->buffer;
-
- if (!prz->ecc)
- return;
-
- persistent_ram_encode_rs8(prz, (uint8_t *)buffer, sizeof(*buffer),
- prz->par_header);
-}
-
-static void persistent_ram_ecc_old(struct persistent_ram_zone *prz)
-{
- struct persistent_ram_buffer *buffer = prz->buffer;
- uint8_t *block;
- uint8_t *par;
-
- if (!prz->ecc)
- return;
-
- block = buffer->data;
- par = prz->par_buffer;
- while (block < buffer->data + buffer_size(prz)) {
- int numerr;
- int size = prz->ecc_block_size;
- if (block + size > buffer->data + prz->buffer_size)
- size = buffer->data + prz->buffer_size - block;
- numerr = persistent_ram_decode_rs8(prz, block, size, par);
- if (numerr > 0) {
- pr_devel("persistent_ram: error in block %p, %d\n",
- block, numerr);
- prz->corrected_bytes += numerr;
- } else if (numerr < 0) {
- pr_devel("persistent_ram: uncorrectable error in block %p\n",
- block);
- prz->bad_blocks++;
- }
- block += prz->ecc_block_size;
- par += prz->ecc_size;
- }
-}
-
-static int persistent_ram_init_ecc(struct persistent_ram_zone *prz,
- size_t buffer_size)
-{
- int numerr;
- struct persistent_ram_buffer *buffer = prz->buffer;
- int ecc_blocks;
-
- if (!prz->ecc)
- return 0;
-
- prz->ecc_block_size = 128;
- prz->ecc_size = 16;
- prz->ecc_symsize = 8;
- prz->ecc_poly = 0x11d;
-
- ecc_blocks = DIV_ROUND_UP(prz->buffer_size, prz->ecc_block_size);
- prz->buffer_size -= (ecc_blocks + 1) * prz->ecc_size;
-
- if (prz->buffer_size > buffer_size) {
- pr_err("persistent_ram: invalid size %zu, non-ecc datasize %zu\n",
- buffer_size, prz->buffer_size);
- return -EINVAL;
- }
-
- prz->par_buffer = buffer->data + prz->buffer_size;
- prz->par_header = prz->par_buffer + ecc_blocks * prz->ecc_size;
-
- /*
- * first consecutive root is 0
- * primitive element to generate roots = 1
- */
- prz->rs_decoder = init_rs(prz->ecc_symsize, prz->ecc_poly, 0, 1,
- prz->ecc_size);
- if (prz->rs_decoder == NULL) {
- pr_info("persistent_ram: init_rs failed\n");
- return -EINVAL;
- }
-
- prz->corrected_bytes = 0;
- prz->bad_blocks = 0;
-
- numerr = persistent_ram_decode_rs8(prz, buffer, sizeof(*buffer),
- prz->par_header);
- if (numerr > 0) {
- pr_info("persistent_ram: error in header, %d\n", numerr);
- prz->corrected_bytes += numerr;
- } else if (numerr < 0) {
- pr_info("persistent_ram: uncorrectable error in header\n");
- prz->bad_blocks++;
- }
-
- return 0;
-}
-
-ssize_t persistent_ram_ecc_string(struct persistent_ram_zone *prz,
- char *str, size_t len)
-{
- ssize_t ret;
-
- if (prz->corrected_bytes || prz->bad_blocks)
- ret = snprintf(str, len, ""
- "\n%d Corrected bytes, %d unrecoverable blocks\n",
- prz->corrected_bytes, prz->bad_blocks);
- else
- ret = snprintf(str, len, "\nNo errors detected\n");
-
- return ret;
-}
-
-static void notrace persistent_ram_update(struct persistent_ram_zone *prz,
- const void *s, unsigned int start, unsigned int count)
-{
- struct persistent_ram_buffer *buffer = prz->buffer;
- memcpy(buffer->data + start, s, count);
- persistent_ram_update_ecc(prz, start, count);
-}
-
-static void __init
-persistent_ram_save_old(struct persistent_ram_zone *prz)
-{
- struct persistent_ram_buffer *buffer = prz->buffer;
- size_t size = buffer_size(prz);
- size_t start = buffer_start(prz);
- char *dest;
-
- persistent_ram_ecc_old(prz);
-
- dest = kmalloc(size, GFP_KERNEL);
- if (dest == NULL) {
- pr_err("persistent_ram: failed to allocate buffer\n");
- return;
- }
-
- prz->old_log = dest;
- prz->old_log_size = size;
- memcpy(prz->old_log, &buffer->data[start], size - start);
- memcpy(prz->old_log + size - start, &buffer->data[0], start);
-}
-
-int notrace persistent_ram_write(struct persistent_ram_zone *prz,
- const void *s, unsigned int count)
-{
- int rem;
- int c = count;
- size_t start;
-
- if (unlikely(c > prz->buffer_size)) {
- s += c - prz->buffer_size;
- c = prz->buffer_size;
- }
-
- buffer_size_add_clamp(prz, c);
-
- start = buffer_start_add(prz, c);
-
- rem = prz->buffer_size - start;
- if (unlikely(rem < c)) {
- persistent_ram_update(prz, s, start, rem);
- s += rem;
- c -= rem;
- start = 0;
- }
- persistent_ram_update(prz, s, start, c);
-
- persistent_ram_update_header_ecc(prz);
-
- return count;
-}
-
-size_t persistent_ram_old_size(struct persistent_ram_zone *prz)
-{
- return prz->old_log_size;
-}
-
-void *persistent_ram_old(struct persistent_ram_zone *prz)
-{
- return prz->old_log;
-}
-
-void persistent_ram_free_old(struct persistent_ram_zone *prz)
-{
- kfree(prz->old_log);
- prz->old_log = NULL;
- prz->old_log_size = 0;
-}
-
-static int persistent_ram_buffer_map(phys_addr_t start, phys_addr_t size,
- struct persistent_ram_zone *prz)
-{
- struct page **pages;
- phys_addr_t page_start;
- unsigned int page_count;
- pgprot_t prot;
- unsigned int i;
-
- page_start = start - offset_in_page(start);
- page_count = DIV_ROUND_UP(size + offset_in_page(start), PAGE_SIZE);
-
- prot = pgprot_noncached(PAGE_KERNEL);
-
- pages = kmalloc(sizeof(struct page *) * page_count, GFP_KERNEL);
- if (!pages) {
- pr_err("%s: Failed to allocate array for %u pages\n", __func__,
- page_count);
- return -ENOMEM;
- }
-
- for (i = 0; i < page_count; i++) {
- phys_addr_t addr = page_start + i * PAGE_SIZE;
- pages[i] = pfn_to_page(addr >> PAGE_SHIFT);
- }
- prz->vaddr = vmap(pages, page_count, VM_MAP, prot);
- kfree(pages);
- if (!prz->vaddr) {
- pr_err("%s: Failed to map %u pages\n", __func__, page_count);
- return -ENOMEM;
- }
-
- prz->buffer = prz->vaddr + offset_in_page(start);
- prz->buffer_size = size - sizeof(struct persistent_ram_buffer);
-
- return 0;
-}
-
-static int __init persistent_ram_buffer_init(const char *name,
- struct persistent_ram_zone *prz)
-{
- int i;
- struct persistent_ram *ram;
- struct persistent_ram_descriptor *desc;
- phys_addr_t start;
-
- list_for_each_entry(ram, &persistent_ram_list, node) {
- start = ram->start;
- for (i = 0; i < ram->num_descs; i++) {
- desc = &ram->descs[i];
- if (!strcmp(desc->name, name))
- return persistent_ram_buffer_map(start,
- desc->size, prz);
- start += desc->size;
- }
- }
-
- return -EINVAL;
-}
-
-static __init
-struct persistent_ram_zone *__persistent_ram_init(struct device *dev, bool ecc)
-{
- struct persistent_ram_zone *prz;
- int ret = -ENOMEM;
-
- prz = kzalloc(sizeof(struct persistent_ram_zone), GFP_KERNEL);
- if (!prz) {
- pr_err("persistent_ram: failed to allocate persistent ram zone\n");
- goto err;
- }
-
- INIT_LIST_HEAD(&prz->node);
-
- ret = persistent_ram_buffer_init(dev_name(dev), prz);
- if (ret) {
- pr_err("persistent_ram: failed to initialize buffer\n");
- goto err;
- }
-
- prz->ecc = ecc;
- ret = persistent_ram_init_ecc(prz, prz->buffer_size);
- if (ret)
- goto err;
-
- if (prz->buffer->sig == PERSISTENT_RAM_SIG) {
- if (buffer_size(prz) > prz->buffer_size ||
- buffer_start(prz) > buffer_size(prz))
- pr_info("persistent_ram: found existing invalid buffer,"
- " size %ld, start %ld\n",
- buffer_size(prz), buffer_start(prz));
- else {
- pr_info("persistent_ram: found existing buffer,"
- " size %ld, start %ld\n",
- buffer_size(prz), buffer_start(prz));
- persistent_ram_save_old(prz);
- }
- } else {
- pr_info("persistent_ram: no valid data in buffer"
- " (sig = 0x%08x)\n", prz->buffer->sig);
- }
-
- prz->buffer->sig = PERSISTENT_RAM_SIG;
- atomic_set(&prz->buffer->start, 0);
- atomic_set(&prz->buffer->size, 0);
-
- return prz;
-err:
- kfree(prz);
- return ERR_PTR(ret);
-}
-
-struct persistent_ram_zone * __init
-persistent_ram_init_ringbuffer(struct device *dev, bool ecc)
-{
- return __persistent_ram_init(dev, ecc);
-}
-
-int __init persistent_ram_early_init(struct persistent_ram *ram)
-{
- int ret;
-
- ret = memblock_reserve(ram->start, ram->size);
- if (ret) {
- pr_err("Failed to reserve persistent memory from %08lx-%08lx\n",
- (long)ram->start, (long)(ram->start + ram->size - 1));
- return ret;
- }
-
- list_add_tail(&ram->node, &persistent_ram_list);
-
- pr_info("Initialized persistent memory from %08lx-%08lx\n",
- (long)ram->start, (long)(ram->start + ram->size - 1));
-
- return 0;
-}
diff --git a/drivers/staging/android/persistent_ram.h b/drivers/staging/android/persistent_ram.h
deleted file mode 100644
index f41e2086c645..000000000000
--- a/drivers/staging/android/persistent_ram.h
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * Copyright (C) 2011 Google, 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.
- *
- */
-
-#ifndef __LINUX_PERSISTENT_RAM_H__
-#define __LINUX_PERSISTENT_RAM_H__
-
-#include <linux/device.h>
-#include <linux/kernel.h>
-#include <linux/list.h>
-#include <linux/types.h>
-
-struct persistent_ram_buffer;
-
-struct persistent_ram_descriptor {
- const char *name;
- phys_addr_t size;
-};
-
-struct persistent_ram {
- phys_addr_t start;
- phys_addr_t size;
-
- int num_descs;
- struct persistent_ram_descriptor *descs;
-
- struct list_head node;
-};
-
-struct persistent_ram_zone {
- struct list_head node;
- void *vaddr;
- struct persistent_ram_buffer *buffer;
- size_t buffer_size;
-
- /* ECC correction */
- bool ecc;
- char *par_buffer;
- char *par_header;
- struct rs_control *rs_decoder;
- int corrected_bytes;
- int bad_blocks;
- int ecc_block_size;
- int ecc_size;
- int ecc_symsize;
- int ecc_poly;
-
- char *old_log;
- size_t old_log_size;
- size_t old_log_footer_size;
- bool early;
-};
-
-int persistent_ram_early_init(struct persistent_ram *ram);
-
-struct persistent_ram_zone *persistent_ram_init_ringbuffer(struct device *dev,
- bool ecc);
-
-int persistent_ram_write(struct persistent_ram_zone *prz, const void *s,
- unsigned int count);
-
-size_t persistent_ram_old_size(struct persistent_ram_zone *prz);
-void *persistent_ram_old(struct persistent_ram_zone *prz);
-void persistent_ram_free_old(struct persistent_ram_zone *prz);
-ssize_t persistent_ram_ecc_string(struct persistent_ram_zone *prz,
- char *str, size_t len);
-
-#endif
diff --git a/drivers/staging/android/ram_console.c b/drivers/staging/android/ram_console.c
deleted file mode 100644
index ce140ffc54ea..000000000000
--- a/drivers/staging/android/ram_console.c
+++ /dev/null
@@ -1,179 +0,0 @@
-/* drivers/android/ram_console.c
- *
- * Copyright (C) 2007-2008 Google, Inc.
- *
- * This software is licensed under the terms of the GNU General Public
- * License version 2, as published by the Free Software Foundation, and
- * may be copied, distributed, and modified under those terms.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- */
-
-#include <linux/console.h>
-#include <linux/init.h>
-#include <linux/module.h>
-#include <linux/platform_device.h>
-#include <linux/proc_fs.h>
-#include <linux/string.h>
-#include <linux/uaccess.h>
-#include <linux/io.h>
-#include "persistent_ram.h"
-#include "ram_console.h"
-
-static struct persistent_ram_zone *ram_console_zone;
-static const char *bootinfo;
-static size_t bootinfo_size;
-
-static void
-ram_console_write(struct console *console, const char *s, unsigned int count)
-{
- struct persistent_ram_zone *prz = console->data;
- persistent_ram_write(prz, s, count);
-}
-
-static struct console ram_console = {
- .name = "ram",
- .write = ram_console_write,
- .flags = CON_PRINTBUFFER | CON_ENABLED | CON_ANYTIME,
- .index = -1,
-};
-
-void ram_console_enable_console(int enabled)
-{
- if (enabled)
- ram_console.flags |= CON_ENABLED;
- else
- ram_console.flags &= ~CON_ENABLED;
-}
-
-static int __init ram_console_probe(struct platform_device *pdev)
-{
- struct ram_console_platform_data *pdata = pdev->dev.platform_data;
- struct persistent_ram_zone *prz;
-
- prz = persistent_ram_init_ringbuffer(&pdev->dev, true);
- if (IS_ERR(prz))
- return PTR_ERR(prz);
-
-
- if (pdata) {
- bootinfo = kstrdup(pdata->bootinfo, GFP_KERNEL);
- if (bootinfo)
- bootinfo_size = strlen(bootinfo);
- }
-
- ram_console_zone = prz;
- ram_console.data = prz;
-
- register_console(&ram_console);
-
- return 0;
-}
-
-static struct platform_driver ram_console_driver = {
- .driver = {
- .name = "ram_console",
- },
-};
-
-static int __init ram_console_module_init(void)
-{
- return platform_driver_probe(&ram_console_driver, ram_console_probe);
-}
-
-#ifndef CONFIG_PRINTK
-#define dmesg_restrict 0
-#endif
-
-static ssize_t ram_console_read_old(struct file *file, char __user *buf,
- size_t len, loff_t *offset)
-{
- loff_t pos = *offset;
- ssize_t count;
- struct persistent_ram_zone *prz = ram_console_zone;
- size_t old_log_size = persistent_ram_old_size(prz);
- const char *old_log = persistent_ram_old(prz);
- char *str;
- int ret;
-
- if (dmesg_restrict && !capable(CAP_SYSLOG))
- return -EPERM;
-
- /* Main last_kmsg log */
- if (pos < old_log_size) {
- count = min(len, (size_t)(old_log_size - pos));
- if (copy_to_user(buf, old_log + pos, count))
- return -EFAULT;
- goto out;
- }
-
- /* ECC correction notice */
- pos -= old_log_size;
- count = persistent_ram_ecc_string(prz, NULL, 0);
- if (pos < count) {
- str = kmalloc(count, GFP_KERNEL);
- if (!str)
- return -ENOMEM;
- persistent_ram_ecc_string(prz, str, count + 1);
- count = min(len, (size_t)(count - pos));
- ret = copy_to_user(buf, str + pos, count);
- kfree(str);
- if (ret)
- return -EFAULT;
- goto out;
- }
-
- /* Boot info passed through pdata */
- pos -= count;
- if (pos < bootinfo_size) {
- count = min(len, (size_t)(bootinfo_size - pos));
- if (copy_to_user(buf, bootinfo + pos, count))
- return -EFAULT;
- goto out;
- }
-
- /* EOF */
- return 0;
-
-out:
- *offset += count;
- return count;
-}
-
-static const struct file_operations ram_console_file_ops = {
- .owner = THIS_MODULE,
- .read = ram_console_read_old,
-};
-
-static int __init ram_console_late_init(void)
-{
- struct proc_dir_entry *entry;
- struct persistent_ram_zone *prz = ram_console_zone;
-
- if (!prz)
- return 0;
-
- if (persistent_ram_old_size(prz) == 0)
- return 0;
-
- entry = create_proc_entry("last_kmsg", S_IFREG | S_IRUGO, NULL);
- if (!entry) {
- printk(KERN_ERR "ram_console: failed to create proc entry\n");
- persistent_ram_free_old(prz);
- return 0;
- }
-
- entry->proc_fops = &ram_console_file_ops;
- entry->size = persistent_ram_old_size(prz) +
- persistent_ram_ecc_string(prz, NULL, 0) +
- bootinfo_size;
-
- return 0;
-}
-
-late_initcall(ram_console_late_init);
-postcore_initcall(ram_console_module_init);
diff --git a/drivers/staging/android/switch/Kconfig b/drivers/staging/android/switch/Kconfig
deleted file mode 100644
index 36846f62f4bc..000000000000
--- a/drivers/staging/android/switch/Kconfig
+++ /dev/null
@@ -1,11 +0,0 @@
-menuconfig ANDROID_SWITCH
- tristate "Android Switch class support"
- help
- Say Y here to enable Android switch class support. This allows
- monitoring switches by userspace via sysfs and uevent.
-
-config ANDROID_SWITCH_GPIO
- tristate "Android GPIO Switch support"
- depends on GENERIC_GPIO && ANDROID_SWITCH
- help
- Say Y here to enable GPIO based switch support.
diff --git a/drivers/staging/android/switch/Makefile b/drivers/staging/android/switch/Makefile
deleted file mode 100644
index d76bfdcedfaf..000000000000
--- a/drivers/staging/android/switch/Makefile
+++ /dev/null
@@ -1,4 +0,0 @@
-# Android Switch Class Driver
-obj-$(CONFIG_ANDROID_SWITCH) += switch_class.o
-obj-$(CONFIG_ANDROID_SWITCH_GPIO) += switch_gpio.o
-
diff --git a/drivers/staging/android/switch/switch.h b/drivers/staging/android/switch/switch.h
deleted file mode 100644
index 4fcb3109875a..000000000000
--- a/drivers/staging/android/switch/switch.h
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Switch class driver
- *
- * Copyright (C) 2008 Google, Inc.
- * Author: Mike Lockwood <lockwood@android.com>
- *
- * This software is licensed under the terms of the GNU General Public
- * License version 2, as published by the Free Software Foundation, and
- * may be copied, distributed, and modified under those terms.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
-*/
-
-#ifndef __LINUX_SWITCH_H__
-#define __LINUX_SWITCH_H__
-
-struct switch_dev {
- const char *name;
- struct device *dev;
- int index;
- int state;
-
- ssize_t (*print_name)(struct switch_dev *sdev, char *buf);
- ssize_t (*print_state)(struct switch_dev *sdev, char *buf);
-};
-
-struct gpio_switch_platform_data {
- const char *name;
- unsigned gpio;
-
- /* if NULL, switch_dev.name will be printed */
- const char *name_on;
- const char *name_off;
- /* if NULL, "0" or "1" will be printed */
- const char *state_on;
- const char *state_off;
-};
-
-extern int switch_dev_register(struct switch_dev *sdev);
-extern void switch_dev_unregister(struct switch_dev *sdev);
-
-static inline int switch_get_state(struct switch_dev *sdev)
-{
- return sdev->state;
-}
-
-extern void switch_set_state(struct switch_dev *sdev, int state);
-
-#endif /* __LINUX_SWITCH_H__ */
diff --git a/drivers/staging/android/switch/switch_class.c b/drivers/staging/android/switch/switch_class.c
deleted file mode 100644
index 74680446fc66..000000000000
--- a/drivers/staging/android/switch/switch_class.c
+++ /dev/null
@@ -1,174 +0,0 @@
-/*
- * switch_class.c
- *
- * Copyright (C) 2008 Google, Inc.
- * Author: Mike Lockwood <lockwood@android.com>
- *
- * This software is licensed under the terms of the GNU General Public
- * License version 2, as published by the Free Software Foundation, and
- * may be copied, distributed, and modified under those terms.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
-*/
-
-#include <linux/module.h>
-#include <linux/types.h>
-#include <linux/init.h>
-#include <linux/device.h>
-#include <linux/fs.h>
-#include <linux/err.h>
-#include "switch.h"
-
-struct class *switch_class;
-static atomic_t device_count;
-
-static ssize_t state_show(struct device *dev, struct device_attribute *attr,
- char *buf)
-{
- struct switch_dev *sdev = (struct switch_dev *)
- dev_get_drvdata(dev);
-
- if (sdev->print_state) {
- int ret = sdev->print_state(sdev, buf);
- if (ret >= 0)
- return ret;
- }
- return sprintf(buf, "%d\n", sdev->state);
-}
-
-static ssize_t name_show(struct device *dev, struct device_attribute *attr,
- char *buf)
-{
- struct switch_dev *sdev = (struct switch_dev *)
- dev_get_drvdata(dev);
-
- if (sdev->print_name) {
- int ret = sdev->print_name(sdev, buf);
- if (ret >= 0)
- return ret;
- }
- return sprintf(buf, "%s\n", sdev->name);
-}
-
-static DEVICE_ATTR(state, S_IRUGO | S_IWUSR, state_show, NULL);
-static DEVICE_ATTR(name, S_IRUGO | S_IWUSR, name_show, NULL);
-
-void switch_set_state(struct switch_dev *sdev, int state)
-{
- char name_buf[120];
- char state_buf[120];
- char *prop_buf;
- char *envp[3];
- int env_offset = 0;
- int length;
-
- if (sdev->state != state) {
- sdev->state = state;
-
- prop_buf = (char *)get_zeroed_page(GFP_KERNEL);
- if (prop_buf) {
- length = name_show(sdev->dev, NULL, prop_buf);
- if (length > 0) {
- if (prop_buf[length - 1] == '\n')
- prop_buf[length - 1] = 0;
- snprintf(name_buf, sizeof(name_buf),
- "SWITCH_NAME=%s", prop_buf);
- envp[env_offset++] = name_buf;
- }
- length = state_show(sdev->dev, NULL, prop_buf);
- if (length > 0) {
- if (prop_buf[length - 1] == '\n')
- prop_buf[length - 1] = 0;
- snprintf(state_buf, sizeof(state_buf),
- "SWITCH_STATE=%s", prop_buf);
- envp[env_offset++] = state_buf;
- }
- envp[env_offset] = NULL;
- kobject_uevent_env(&sdev->dev->kobj, KOBJ_CHANGE, envp);
- free_page((unsigned long)prop_buf);
- } else {
- printk(KERN_ERR "out of memory in switch_set_state\n");
- kobject_uevent(&sdev->dev->kobj, KOBJ_CHANGE);
- }
- }
-}
-EXPORT_SYMBOL_GPL(switch_set_state);
-
-static int create_switch_class(void)
-{
- if (!switch_class) {
- switch_class = class_create(THIS_MODULE, "switch");
- if (IS_ERR(switch_class))
- return PTR_ERR(switch_class);
- atomic_set(&device_count, 0);
- }
-
- return 0;
-}
-
-int switch_dev_register(struct switch_dev *sdev)
-{
- int ret;
-
- if (!switch_class) {
- ret = create_switch_class();
- if (ret < 0)
- return ret;
- }
-
- sdev->index = atomic_inc_return(&device_count);
- sdev->dev = device_create(switch_class, NULL,
- MKDEV(0, sdev->index), NULL, sdev->name);
- if (IS_ERR(sdev->dev))
- return PTR_ERR(sdev->dev);
-
- ret = device_create_file(sdev->dev, &dev_attr_state);
- if (ret < 0)
- goto err_create_file_1;
- ret = device_create_file(sdev->dev, &dev_attr_name);
- if (ret < 0)
- goto err_create_file_2;
-
- dev_set_drvdata(sdev->dev, sdev);
- sdev->state = 0;
- return 0;
-
-err_create_file_2:
- device_remove_file(sdev->dev, &dev_attr_state);
-err_create_file_1:
- device_destroy(switch_class, MKDEV(0, sdev->index));
- printk(KERN_ERR "switch: Failed to register driver %s\n", sdev->name);
-
- return ret;
-}
-EXPORT_SYMBOL_GPL(switch_dev_register);
-
-void switch_dev_unregister(struct switch_dev *sdev)
-{
- device_remove_file(sdev->dev, &dev_attr_name);
- device_remove_file(sdev->dev, &dev_attr_state);
- device_destroy(switch_class, MKDEV(0, sdev->index));
- dev_set_drvdata(sdev->dev, NULL);
-}
-EXPORT_SYMBOL_GPL(switch_dev_unregister);
-
-static int __init switch_class_init(void)
-{
- return create_switch_class();
-}
-
-static void __exit switch_class_exit(void)
-{
- class_destroy(switch_class);
-}
-
-module_init(switch_class_init);
-module_exit(switch_class_exit);
-
-MODULE_AUTHOR("Mike Lockwood <lockwood@android.com>");
-MODULE_DESCRIPTION("Switch class driver");
-MODULE_LICENSE("GPL");
diff --git a/drivers/staging/android/switch/switch_gpio.c b/drivers/staging/android/switch/switch_gpio.c
deleted file mode 100644
index 38b2c2f6004e..000000000000
--- a/drivers/staging/android/switch/switch_gpio.c
+++ /dev/null
@@ -1,172 +0,0 @@
-/*
- * switch_gpio.c
- *
- * Copyright (C) 2008 Google, Inc.
- * Author: Mike Lockwood <lockwood@android.com>
- *
- * This software is licensed under the terms of the GNU General Public
- * License version 2, as published by the Free Software Foundation, and
- * may be copied, distributed, and modified under those terms.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
-*/
-
-#include <linux/module.h>
-#include <linux/kernel.h>
-#include <linux/init.h>
-#include <linux/interrupt.h>
-#include <linux/platform_device.h>
-#include <linux/slab.h>
-#include <linux/workqueue.h>
-#include <linux/gpio.h>
-#include "switch.h"
-
-struct gpio_switch_data {
- struct switch_dev sdev;
- unsigned gpio;
- const char *name_on;
- const char *name_off;
- const char *state_on;
- const char *state_off;
- int irq;
- struct work_struct work;
-};
-
-static void gpio_switch_work(struct work_struct *work)
-{
- int state;
- struct gpio_switch_data *data =
- container_of(work, struct gpio_switch_data, work);
-
- state = gpio_get_value(data->gpio);
- switch_set_state(&data->sdev, state);
-}
-
-static irqreturn_t gpio_irq_handler(int irq, void *dev_id)
-{
- struct gpio_switch_data *switch_data =
- (struct gpio_switch_data *)dev_id;
-
- schedule_work(&switch_data->work);
- return IRQ_HANDLED;
-}
-
-static ssize_t switch_gpio_print_state(struct switch_dev *sdev, char *buf)
-{
- struct gpio_switch_data *switch_data =
- container_of(sdev, struct gpio_switch_data, sdev);
- const char *state;
- if (switch_get_state(sdev))
- state = switch_data->state_on;
- else
- state = switch_data->state_off;
-
- if (state)
- return sprintf(buf, "%s\n", state);
- return -1;
-}
-
-static int gpio_switch_probe(struct platform_device *pdev)
-{
- struct gpio_switch_platform_data *pdata = pdev->dev.platform_data;
- struct gpio_switch_data *switch_data;
- int ret = 0;
-
- if (!pdata)
- return -EBUSY;
-
- switch_data = kzalloc(sizeof(struct gpio_switch_data), GFP_KERNEL);
- if (!switch_data)
- return -ENOMEM;
-
- switch_data->sdev.name = pdata->name;
- switch_data->gpio = pdata->gpio;
- switch_data->name_on = pdata->name_on;
- switch_data->name_off = pdata->name_off;
- switch_data->state_on = pdata->state_on;
- switch_data->state_off = pdata->state_off;
- switch_data->sdev.print_state = switch_gpio_print_state;
-
- ret = switch_dev_register(&switch_data->sdev);
- if (ret < 0)
- goto err_switch_dev_register;
-
- ret = gpio_request(switch_data->gpio, pdev->name);
- if (ret < 0)
- goto err_request_gpio;
-
- ret = gpio_direction_input(switch_data->gpio);
- if (ret < 0)
- goto err_set_gpio_input;
-
- INIT_WORK(&switch_data->work, gpio_switch_work);
-
- switch_data->irq = gpio_to_irq(switch_data->gpio);
- if (switch_data->irq < 0) {
- ret = switch_data->irq;
- goto err_detect_irq_num_failed;
- }
-
- ret = request_irq(switch_data->irq, gpio_irq_handler,
- IRQF_TRIGGER_LOW, pdev->name, switch_data);
- if (ret < 0)
- goto err_request_irq;
-
- /* Perform initial detection */
- gpio_switch_work(&switch_data->work);
-
- return 0;
-
-err_request_irq:
-err_detect_irq_num_failed:
-err_set_gpio_input:
- gpio_free(switch_data->gpio);
-err_request_gpio:
- switch_dev_unregister(&switch_data->sdev);
-err_switch_dev_register:
- kfree(switch_data);
-
- return ret;
-}
-
-static int __devexit gpio_switch_remove(struct platform_device *pdev)
-{
- struct gpio_switch_data *switch_data = platform_get_drvdata(pdev);
-
- cancel_work_sync(&switch_data->work);
- gpio_free(switch_data->gpio);
- switch_dev_unregister(&switch_data->sdev);
- kfree(switch_data);
-
- return 0;
-}
-
-static struct platform_driver gpio_switch_driver = {
- .probe = gpio_switch_probe,
- .remove = __devexit_p(gpio_switch_remove),
- .driver = {
- .name = "switch-gpio",
- .owner = THIS_MODULE,
- },
-};
-
-static int __init gpio_switch_init(void)
-{
- return platform_driver_register(&gpio_switch_driver);
-}
-
-static void __exit gpio_switch_exit(void)
-{
- platform_driver_unregister(&gpio_switch_driver);
-}
-
-module_init(gpio_switch_init);
-module_exit(gpio_switch_exit);
-
-MODULE_AUTHOR("Mike Lockwood <lockwood@android.com>");
-MODULE_DESCRIPTION("GPIO Switch driver");
-MODULE_LICENSE("GPL");
diff --git a/drivers/staging/android/timed_output.c b/drivers/staging/android/timed_output.c
index f373422308e0..ec9e2ae2de0d 100644
--- a/drivers/staging/android/timed_output.c
+++ b/drivers/staging/android/timed_output.c
@@ -14,6 +14,8 @@
*
*/
+#define pr_fmt(fmt) "timed_output: " fmt
+
#include <linux/module.h>
#include <linux/types.h>
#include <linux/device.h>
@@ -90,7 +92,7 @@ int timed_output_dev_register(struct timed_output_dev *tdev)
err_create_file:
device_destroy(timed_output_class, MKDEV(0, tdev->index));
- printk(KERN_ERR "timed_output: Failed to register driver %s\n",
+ pr_err("failed to register driver %s\n",
tdev->name);
return ret;
@@ -99,6 +101,7 @@ EXPORT_SYMBOL_GPL(timed_output_dev_register);
void timed_output_dev_unregister(struct timed_output_dev *tdev)
{
+ tdev->enable(tdev, 0);
device_remove_file(tdev->dev, &dev_attr_enable);
device_destroy(timed_output_class, MKDEV(0, tdev->index));
dev_set_drvdata(tdev->dev, NULL);
diff --git a/drivers/staging/asus_oled/asus_oled.c b/drivers/staging/asus_oled/asus_oled.c
index 83549d9cfefc..f63c1d3aeb64 100644
--- a/drivers/staging/asus_oled/asus_oled.c
+++ b/drivers/staging/asus_oled/asus_oled.c
@@ -782,20 +782,20 @@ static int __init asus_oled_init(void)
oled_class = class_create(THIS_MODULE, ASUS_OLED_UNDERSCORE_NAME);
if (IS_ERR(oled_class)) {
- err("Error creating " ASUS_OLED_UNDERSCORE_NAME " class");
+ pr_err("Error creating " ASUS_OLED_UNDERSCORE_NAME " class\n");
return PTR_ERR(oled_class);
}
retval = class_create_file(oled_class, &class_attr_version.attr);
if (retval) {
- err("Error creating class version file");
+ pr_err("Error creating class version file\n");
goto error;
}
retval = usb_register(&oled_driver);
if (retval) {
- err("usb_register failed. Error number %d", retval);
+ pr_err("usb_register failed. Error number %d\n", retval);
goto error;
}
diff --git a/drivers/staging/bcm/Adapter.h b/drivers/staging/bcm/Adapter.h
index 20cca24ff5f0..4d490a99110c 100644
--- a/drivers/staging/bcm/Adapter.h
+++ b/drivers/staging/bcm/Adapter.h
@@ -7,168 +7,98 @@
#define MAX_FRAGMENTEDIP_CLASSIFICATION_ENTRIES 256
#include "Debug.h"
-struct _LEADER
-{
- USHORT Vcid;
- USHORT PLength;
- UCHAR Status;
+struct bcm_leader {
+ USHORT Vcid;
+ USHORT PLength;
+ UCHAR Status;
UCHAR Unused[3];
-}__attribute__((packed));
-typedef struct _LEADER LEADER,*PLEADER;
+} __packed;
-struct _PACKETTOSEND
-{
- LEADER Leader;
+struct bcm_packettosend {
+ struct bcm_leader Leader;
UCHAR ucPayload;
-}__attribute__((packed));
-typedef struct _PACKETTOSEND PACKETTOSEND, *PPACKETTOSEND;
+} __packed;
-
-struct _CONTROL_PACKET
-{
+struct bcm_control_packet {
PVOID ControlBuff;
UINT ControlBuffLen;
- struct _CONTROL_PACKET* next;
-}__attribute__((packed));
-typedef struct _CONTROL_PACKET CONTROL_PACKET,*PCONTROL_PACKET;
-
+ struct bcm_control_packet *next;
+} __packed;
-struct link_request
-{
- LEADER Leader;
+struct bcm_link_request {
+ struct bcm_leader Leader;
UCHAR szData[4];
-}__attribute__((packed));
-typedef struct link_request LINK_REQUEST, *PLINK_REQUEST;
-
-
-//classification extension is added
-typedef struct _ADD_CONNECTION
-{
- ULONG SrcIpAddressCount;
- ULONG SrcIpAddress[MAX_CONNECTIONS];
- ULONG SrcIpMask[MAX_CONNECTIONS];
-
- ULONG DestIpAddressCount;
- ULONG DestIpAddress[MAX_CONNECTIONS];
- ULONG DestIpMask[MAX_CONNECTIONS];
-
- USHORT SrcPortBegin;
- USHORT SrcPortEnd;
-
- USHORT DestPortBegin;
- USHORT DestPortEnd;
-
- UCHAR SrcTOS;
- UCHAR SrcProtocol;
-} ADD_CONNECTION,*PADD_CONNECTION;
-
-
-typedef struct _CLASSIFICATION_RULE
-{
- UCHAR ucIPSrcAddrLen;
- UCHAR ucIPSrcAddr[32];
- UCHAR ucIPDestAddrLen;
- UCHAR ucIPDestAddr[32];
- UCHAR ucSrcPortRangeLen;
- UCHAR ucSrcPortRange[4];
- UCHAR ucDestPortRangeLen;
- UCHAR ucDestPortRange[4];
- USHORT usVcid;
-} CLASSIFICATION_RULE,*PCLASSIFICATION_RULE;
-
-typedef struct _CLASSIFICATION_ONLY
-{
- USHORT usVcid;
- ULONG DestIpAddress;
- ULONG DestIpMask;
- USHORT usPortLo;
- USHORT usPortHi;
- BOOLEAN bIpVersion;
- UCHAR ucDestinationAddress[16];
-} CLASSIFICATION_ONLY, *PCLASSIFICATION_ONLY;
-
+} __packed;
#define MAX_IP_RANGE_LENGTH 4
#define MAX_PORT_RANGE 4
#define MAX_PROTOCOL_LENGTH 32
#define IPV6_ADDRESS_SIZEINBYTES 0x10
-typedef union _U_IP_ADDRESS
-{
- struct
- {
- ULONG ulIpv4Addr[MAX_IP_RANGE_LENGTH];//Source Ip Address Range
- ULONG ulIpv4Mask[MAX_IP_RANGE_LENGTH];//Source Ip Mask Address Range
+typedef union _U_IP_ADDRESS {
+ struct {
+ ULONG ulIpv4Addr[MAX_IP_RANGE_LENGTH]; /* Source Ip Address Range */
+ ULONG ulIpv4Mask[MAX_IP_RANGE_LENGTH]; /* Source Ip Mask Address Range */
};
- struct
- {
- ULONG ulIpv6Addr[MAX_IP_RANGE_LENGTH * 4];//Source Ip Address Range
- ULONG ulIpv6Mask[MAX_IP_RANGE_LENGTH * 4];//Source Ip Mask Address Range
-
+ struct {
+ ULONG ulIpv6Addr[MAX_IP_RANGE_LENGTH * 4]; /* Source Ip Address Range */
+ ULONG ulIpv6Mask[MAX_IP_RANGE_LENGTH * 4]; /* Source Ip Mask Address Range */
};
- struct
- {
- UCHAR ucIpv4Address[MAX_IP_RANGE_LENGTH * IP_LENGTH_OF_ADDRESS];
- UCHAR ucIpv4Mask[MAX_IP_RANGE_LENGTH * IP_LENGTH_OF_ADDRESS];
+ struct {
+ UCHAR ucIpv4Address[MAX_IP_RANGE_LENGTH * IP_LENGTH_OF_ADDRESS];
+ UCHAR ucIpv4Mask[MAX_IP_RANGE_LENGTH * IP_LENGTH_OF_ADDRESS];
};
- struct
- {
- UCHAR ucIpv6Address[MAX_IP_RANGE_LENGTH * IPV6_ADDRESS_SIZEINBYTES];
- UCHAR ucIpv6Mask[MAX_IP_RANGE_LENGTH * IPV6_ADDRESS_SIZEINBYTES];
+ struct {
+ UCHAR ucIpv6Address[MAX_IP_RANGE_LENGTH * IPV6_ADDRESS_SIZEINBYTES];
+ UCHAR ucIpv6Mask[MAX_IP_RANGE_LENGTH * IPV6_ADDRESS_SIZEINBYTES];
};
-}U_IP_ADDRESS;
-struct _packet_info;
+} U_IP_ADDRESS;
+
+struct bcm_hdr_suppression_contextinfo {
+ UCHAR ucaHdrSuppressionInBuf[MAX_PHS_LENGTHS]; /* Intermediate buffer to accumulate pkt Header for PHS */
+ UCHAR ucaHdrSuppressionOutBuf[MAX_PHS_LENGTHS + PHSI_LEN]; /* Intermediate buffer containing pkt Header after PHS */
+};
-typedef struct _S_HDR_SUPRESSION_CONTEXTINFO
-{
+struct bcm_classifier_rule {
+ ULONG ulSFID;
+ UCHAR ucReserved[2];
+ B_UINT16 uiClassifierRuleIndex;
+ BOOLEAN bUsed;
+ USHORT usVCID_Value;
+ B_UINT8 u8ClassifierRulePriority; /* This field detemines the Classifier Priority */
+ U_IP_ADDRESS stSrcIpAddress;
+ UCHAR ucIPSourceAddressLength; /* Ip Source Address Length */
- UCHAR ucaHdrSupressionInBuf[MAX_PHS_LENGTHS]; //Intermediate buffer to accumulate pkt Header for PHS
- UCHAR ucaHdrSupressionOutBuf[MAX_PHS_LENGTHS + PHSI_LEN]; //Intermediate buffer containing pkt Header after PHS
+ U_IP_ADDRESS stDestIpAddress;
+ UCHAR ucIPDestinationAddressLength; /* Ip Destination Address Length */
+ UCHAR ucIPTypeOfServiceLength; /* Type of service Length */
+ UCHAR ucTosLow; /* Tos Low */
+ UCHAR ucTosHigh; /* Tos High */
+ UCHAR ucTosMask; /* Tos Mask */
-}S_HDR_SUPRESSION_CONTEXTINFO;
+ UCHAR ucProtocolLength; /* protocol Length */
+ UCHAR ucProtocol[MAX_PROTOCOL_LENGTH]; /* protocol Length */
+ USHORT usSrcPortRangeLo[MAX_PORT_RANGE];
+ USHORT usSrcPortRangeHi[MAX_PORT_RANGE];
+ UCHAR ucSrcPortRangeLength;
+ USHORT usDestPortRangeLo[MAX_PORT_RANGE];
+ USHORT usDestPortRangeHi[MAX_PORT_RANGE];
+ UCHAR ucDestPortRangeLength;
-typedef struct _S_CLASSIFIER_RULE
-{
- ULONG ulSFID;
- UCHAR ucReserved[2];
- B_UINT16 uiClassifierRuleIndex;
- BOOLEAN bUsed;
- USHORT usVCID_Value;
- B_UINT8 u8ClassifierRulePriority; //This field detemines the Classifier Priority
- U_IP_ADDRESS stSrcIpAddress;
- UCHAR ucIPSourceAddressLength;//Ip Source Address Length
-
- U_IP_ADDRESS stDestIpAddress;
- UCHAR ucIPDestinationAddressLength;//Ip Destination Address Length
- UCHAR ucIPTypeOfServiceLength;//Type of service Length
- UCHAR ucTosLow;//Tos Low
- UCHAR ucTosHigh;//Tos High
- UCHAR ucTosMask;//Tos Mask
-
- UCHAR ucProtocolLength;//protocol Length
- UCHAR ucProtocol[MAX_PROTOCOL_LENGTH];//protocol Length
- USHORT usSrcPortRangeLo[MAX_PORT_RANGE];
- USHORT usSrcPortRangeHi[MAX_PORT_RANGE];
- UCHAR ucSrcPortRangeLength;
-
- USHORT usDestPortRangeLo[MAX_PORT_RANGE];
- USHORT usDestPortRangeHi[MAX_PORT_RANGE];
- UCHAR ucDestPortRangeLength;
-
- BOOLEAN bProtocolValid;
- BOOLEAN bTOSValid;
- BOOLEAN bDestIpValid;
- BOOLEAN bSrcIpValid;
-
- //For IPv6 Addressing
- UCHAR ucDirection;
- BOOLEAN bIpv6Protocol;
- UINT32 u32PHSRuleID;
- S_PHS_RULE sPhsRule;
- UCHAR u8AssociatedPHSI;
-
- //Classification fields for ETH CS
+ BOOLEAN bProtocolValid;
+ BOOLEAN bTOSValid;
+ BOOLEAN bDestIpValid;
+ BOOLEAN bSrcIpValid;
+
+ /* For IPv6 Addressing */
+ UCHAR ucDirection;
+ BOOLEAN bIpv6Protocol;
+ UINT32 u32PHSRuleID;
+ S_PHS_RULE sPhsRule;
+ UCHAR u8AssociatedPHSI;
+
+ /* Classification fields for ETH CS */
UCHAR ucEthCSSrcMACLen;
UCHAR au8EThCSSrcMAC[MAC_ADDRESS_SIZE];
UCHAR au8EThCSSrcMACMask[MAC_ADDRESS_SIZE];
@@ -180,71 +110,66 @@ typedef struct _S_CLASSIFIER_RULE
UCHAR usUserPriority[2];
USHORT usVLANID;
USHORT usValidityBitMap;
-}S_CLASSIFIER_RULE;
-//typedef struct _S_CLASSIFIER_RULE S_CLASSIFIER_RULE;
-
-typedef struct _S_FRAGMENTED_PACKET_INFO
-{
- BOOLEAN bUsed;
- ULONG ulSrcIpAddress;
- USHORT usIpIdentification;
- S_CLASSIFIER_RULE *pstMatchedClassifierEntry;
- BOOLEAN bOutOfOrderFragment;
-}S_FRAGMENTED_PACKET_INFO,*PS_FRAGMENTED_PACKET_INFO;
-
-struct _packet_info
-{
- //classification extension Rule
- ULONG ulSFID;
- USHORT usVCID_Value;
- UINT uiThreshold;
- // This field determines the priority of the SF Queues
- B_UINT8 u8TrafficPriority;
-
- BOOLEAN bValid;
- BOOLEAN bActive;
- BOOLEAN bActivateRequestSent;
-
- B_UINT8 u8QueueType;//BE or rtPS
-
- UINT uiMaxBucketSize;//maximum size of the bucket for the queue
- UINT uiCurrentQueueDepthOnTarget;
- UINT uiCurrentBytesOnHost;
- UINT uiCurrentPacketsOnHost;
- UINT uiDroppedCountBytes;
- UINT uiDroppedCountPackets;
- UINT uiSentBytes;
- UINT uiSentPackets;
- UINT uiCurrentDrainRate;
- UINT uiThisPeriodSentBytes;
+};
+
+struct bcm_fragmented_packet_info {
+ BOOLEAN bUsed;
+ ULONG ulSrcIpAddress;
+ USHORT usIpIdentification;
+ struct bcm_classifier_rule *pstMatchedClassifierEntry;
+ BOOLEAN bOutOfOrderFragment;
+};
+
+struct bcm_packet_info {
+ /* classification extension Rule */
+ ULONG ulSFID;
+ USHORT usVCID_Value;
+ UINT uiThreshold;
+ /* This field determines the priority of the SF Queues */
+ B_UINT8 u8TrafficPriority;
+
+ BOOLEAN bValid;
+ BOOLEAN bActive;
+ BOOLEAN bActivateRequestSent;
+
+ B_UINT8 u8QueueType; /* BE or rtPS */
+
+ UINT uiMaxBucketSize; /* maximum size of the bucket for the queue */
+ UINT uiCurrentQueueDepthOnTarget;
+ UINT uiCurrentBytesOnHost;
+ UINT uiCurrentPacketsOnHost;
+ UINT uiDroppedCountBytes;
+ UINT uiDroppedCountPackets;
+ UINT uiSentBytes;
+ UINT uiSentPackets;
+ UINT uiCurrentDrainRate;
+ UINT uiThisPeriodSentBytes;
LARGE_INTEGER liDrainCalculated;
- UINT uiCurrentTokenCount;
- LARGE_INTEGER liLastUpdateTokenAt;
- UINT uiMaxAllowedRate;
- UINT NumOfPacketsSent;
- UCHAR ucDirection;
- USHORT usCID;
+ UINT uiCurrentTokenCount;
+ LARGE_INTEGER liLastUpdateTokenAt;
+ UINT uiMaxAllowedRate;
+ UINT NumOfPacketsSent;
+ UCHAR ucDirection;
+ USHORT usCID;
S_MIBS_EXTSERVICEFLOW_PARAMETERS stMibsExtServiceFlowTable;
- UINT uiCurrentRxRate;
- UINT uiThisPeriodRxBytes;
- UINT uiTotalRxBytes;
- UINT uiTotalTxBytes;
- UINT uiPendedLast;
- UCHAR ucIpVersion;
-
- union
- {
- struct
- {
- struct sk_buff* FirstTxQueue;
- struct sk_buff* LastTxQueue;
+ UINT uiCurrentRxRate;
+ UINT uiThisPeriodRxBytes;
+ UINT uiTotalRxBytes;
+ UINT uiTotalTxBytes;
+ UINT uiPendedLast;
+ UCHAR ucIpVersion;
+
+ union {
+ struct {
+ struct sk_buff *FirstTxQueue;
+ struct sk_buff *LastTxQueue;
};
- struct
- {
- struct sk_buff* ControlHead;
- struct sk_buff* ControlTail;
+ struct {
+ struct sk_buff *ControlHead;
+ struct sk_buff *ControlTail;
};
};
+
BOOLEAN bProtocolValid;
BOOLEAN bTOSValid;
BOOLEAN bDestIpValid;
@@ -255,226 +180,127 @@ struct _packet_info
BOOLEAN bAuthorizedSet;
BOOLEAN bClassifierPriority;
UCHAR ucServiceClassName[MAX_CLASS_NAME_LENGTH];
- BOOLEAN bHeaderSuppressionEnabled;
+ BOOLEAN bHeaderSuppressionEnabled;
spinlock_t SFQueueLock;
- void *pstSFIndication;
+ void *pstSFIndication;
struct timeval stLastUpdateTokenAt;
- atomic_t uiPerSFTxResourceCount;
+ atomic_t uiPerSFTxResourceCount;
UINT uiMaxLatency;
- UCHAR bIPCSSupport;
- UCHAR bEthCSSupport;
+ UCHAR bIPCSSupport;
+ UCHAR bEthCSSupport;
};
-typedef struct _packet_info PacketInfo;
-
-
-typedef struct _PER_TARANG_DATA
-{
- struct _PER_TARANG_DATA * next;
- struct _MINI_ADAPTER * Adapter;
- struct sk_buff* RxAppControlHead;
- struct sk_buff* RxAppControlTail;
- volatile INT AppCtrlQueueLen;
- BOOLEAN MacTracingEnabled;
- BOOLEAN bApplicationToExit;
- S_MIBS_DROPPED_APP_CNTRL_MESSAGES stDroppedAppCntrlMsgs;
- ULONG RxCntrlMsgBitMask;
-} PER_TARANG_DATA, *PPER_TARANG_DATA;
-
-
-#ifdef REL_4_1
-typedef struct _TARGET_PARAMS
-{
- B_UINT32 m_u32CfgVersion;
-
- // Scanning Related Params
- B_UINT32 m_u32CenterFrequency;
- B_UINT32 m_u32BandAScan;
- B_UINT32 m_u32BandBScan;
- B_UINT32 m_u32BandCScan;
-
- // QoS Params
- B_UINT32 m_u32minGrantsize; // size of minimum grant is 0 or 6
- B_UINT32 m_u32PHSEnable;
-
- // HO Params
- B_UINT32 m_u32HoEnable;
- B_UINT32 m_u32HoReserved1;
- B_UINT32 m_u32HoReserved2;
-
- // Power Control Params
- B_UINT32 m_u32MimoEnable;
- B_UINT32 m_u32SecurityEnable;
- /*
- * bit 1: 1 Idlemode enable;
- * bit 2: 1 Sleepmode Enable
- */
- B_UINT32 m_u32PowerSavingModesEnable;
- /* PowerSaving Mode Options:
- bit 0 = 1: CPE mode - to keep pcmcia if alive;
- bit 1 = 1: CINR reporing in Idlemode Msg
- bit 2 = 1: Default PSC Enable in sleepmode*/
- B_UINT32 m_u32PowerSavingModeOptions;
-
- B_UINT32 m_u32ArqEnable;
-
- // From Version #3, the HARQ section renamed as general
- B_UINT32 m_u32HarqEnable;
- // EEPROM Param Location
- B_UINT32 m_u32EEPROMFlag;
- /* BINARY TYPE - 4th MSByte:
- * Interface Type - 3rd MSByte:
- * Vendor Type - 2nd MSByte
- */
- // Unused - LSByte
- B_UINT32 m_u32Customize;
- B_UINT32 m_u32ConfigBW; /* In Hz */
- B_UINT32 m_u32ShutDownTimer;
-
-
- B_UINT32 m_u32RadioParameter;
- B_UINT32 m_u32PhyParameter1;
- B_UINT32 m_u32PhyParameter2;
- B_UINT32 m_u32PhyParameter3;
-
- /* in eval mode only;
- * lower 16bits = basic cid for testing;
- * then bit 16 is test cqich,
- * bit 17 test init rang;
- * bit 18 test periodic rang
- * bit 19 is test harq ack/nack
- */
- B_UINT32 m_u32TestOptions;
-
- B_UINT32 m_u32MaxMACDataperDLFrame;
- B_UINT32 m_u32MaxMACDataperULFrame;
-
- B_UINT32 m_u32Corr2MacFlags;
-
- //adding driver params.
- B_UINT32 HostDrvrConfig1;
- B_UINT32 HostDrvrConfig2;
- B_UINT32 HostDrvrConfig3;
- B_UINT32 HostDrvrConfig4;
- B_UINT32 HostDrvrConfig5;
- B_UINT32 HostDrvrConfig6;
- B_UINT32 m_u32SegmentedPUSCenable;
-
- // BAMC enable - but 4.x does not support this feature
- // This is added just to sync 4.x and 5.x CFGs
- B_UINT32 m_u32BandAMCEnable;
-} STARGETPARAMS, *PSTARGETPARAMS;
-#endif
-
-typedef struct _STTARGETDSXBUFFER
-{
- ULONG ulTargetDsxBuffer;
- B_UINT16 tid;
- BOOLEAN valid;
-}STTARGETDSXBUFFER, *PSTTARGETDSXBUFFER;
-
-typedef INT (*FP_FLASH_WRITE)(struct _MINI_ADAPTER*,UINT,PVOID);
-
-typedef INT (*FP_FLASH_WRITE_STATUS)(struct _MINI_ADAPTER*,UINT,PVOID);
-
-/**
-Driver adapter data structure
-*/
-struct _MINI_ADAPTER
-{
- struct _MINI_ADAPTER *next;
+
+struct bcm_tarang_data {
+ struct bcm_tarang_data *next;
+ struct bcm_mini_adapter *Adapter;
+ struct sk_buff *RxAppControlHead;
+ struct sk_buff *RxAppControlTail;
+ int AppCtrlQueueLen;
+ BOOLEAN MacTracingEnabled;
+ BOOLEAN bApplicationToExit;
+ S_MIBS_DROPPED_APP_CNTRL_MESSAGES stDroppedAppCntrlMsgs;
+ ULONG RxCntrlMsgBitMask;
+};
+
+struct bcm_targetdsx_buffer {
+ ULONG ulTargetDsxBuffer;
+ B_UINT16 tid;
+ BOOLEAN valid;
+};
+
+typedef int (*FP_FLASH_WRITE)(struct bcm_mini_adapter *, UINT, PVOID);
+
+typedef int (*FP_FLASH_WRITE_STATUS)(struct bcm_mini_adapter *, UINT, PVOID);
+
+/*
+ * Driver adapter data structure
+ */
+struct bcm_mini_adapter {
+ struct bcm_mini_adapter *next;
struct net_device *dev;
u32 msg_enable;
-
- CHAR *caDsxReqResp;
+ CHAR *caDsxReqResp;
atomic_t ApplicationRunning;
- volatile INT CtrlQueueLen;
- atomic_t AppCtrlQueueLen;
- BOOLEAN AppCtrlQueueOverFlow;
+ BOOLEAN AppCtrlQueueOverFlow;
atomic_t CurrentApplicationCount;
- atomic_t RegisteredApplicationCount;
- BOOLEAN LinkUpStatus;
- BOOLEAN TimerActive;
+ atomic_t RegisteredApplicationCount;
+ BOOLEAN LinkUpStatus;
+ BOOLEAN TimerActive;
u32 StatisticsPointer;
struct sk_buff *RxControlHead;
struct sk_buff *RxControlTail;
-
struct semaphore RxAppControlQueuelock;
struct semaphore fw_download_sema;
-
- PPER_TARANG_DATA pTarangs;
- spinlock_t control_queue_lock;
+ struct bcm_tarang_data *pTarangs;
+ spinlock_t control_queue_lock;
wait_queue_head_t process_read_wait_queue;
- // the pointer to the first packet we have queued in send
- // deserialized miniport support variables
- atomic_t TotalPacketCount;
- atomic_t TxPktAvail;
-
- // this to keep track of the Tx and Rx MailBox Registers.
- atomic_t CurrNumFreeTxDesc;
- // to keep track the no of byte received
- USHORT PrevNumRecvDescs;
- USHORT CurrNumRecvDescs;
- UINT u32TotalDSD;
- PacketInfo PackInfo[NO_OF_QUEUES];
- S_CLASSIFIER_RULE astClassifierTable[MAX_CLASSIFIERS];
- BOOLEAN TransferMode;
+ /* the pointer to the first packet we have queued in send
+ * deserialized miniport support variables
+ */
+ atomic_t TotalPacketCount;
+ atomic_t TxPktAvail;
+
+ /* this to keep track of the Tx and Rx MailBox Registers. */
+ atomic_t CurrNumFreeTxDesc;
+ /* to keep track the no of byte received */
+ USHORT PrevNumRecvDescs;
+ USHORT CurrNumRecvDescs;
+ UINT u32TotalDSD;
+ struct bcm_packet_info PackInfo[NO_OF_QUEUES];
+ struct bcm_classifier_rule astClassifierTable[MAX_CLASSIFIERS];
+ BOOLEAN TransferMode;
/*************** qos ******************/
- BOOLEAN bETHCSEnabled;
-
- ULONG BEBucketSize;
- ULONG rtPSBucketSize;
- UCHAR LinkStatus;
- BOOLEAN AutoLinkUp;
- BOOLEAN AutoSyncup;
-
- int major;
- int minor;
- wait_queue_head_t tx_packet_wait_queue;
- wait_queue_head_t process_rx_cntrlpkt;
- atomic_t process_waiting;
- BOOLEAN fw_download_done;
-
- char *txctlpacket[MAX_CNTRL_PKTS];
- atomic_t cntrlpktCnt ;
- atomic_t index_app_read_cntrlpkt;
- atomic_t index_wr_txcntrlpkt;
- atomic_t index_rd_txcntrlpkt;
- UINT index_datpkt;
- struct semaphore rdmwrmsync;
-
- STTARGETDSXBUFFER astTargetDsxBuffer[MAX_TARGET_DSX_BUFFERS];
+ BOOLEAN bETHCSEnabled;
+ ULONG BEBucketSize;
+ ULONG rtPSBucketSize;
+ UCHAR LinkStatus;
+ BOOLEAN AutoLinkUp;
+ BOOLEAN AutoSyncup;
+
+ int major;
+ int minor;
+ wait_queue_head_t tx_packet_wait_queue;
+ wait_queue_head_t process_rx_cntrlpkt;
+ atomic_t process_waiting;
+ BOOLEAN fw_download_done;
+
+ char *txctlpacket[MAX_CNTRL_PKTS];
+ atomic_t cntrlpktCnt ;
+ atomic_t index_app_read_cntrlpkt;
+ atomic_t index_wr_txcntrlpkt;
+ atomic_t index_rd_txcntrlpkt;
+ UINT index_datpkt;
+ struct semaphore rdmwrmsync;
+
+ struct bcm_targetdsx_buffer astTargetDsxBuffer[MAX_TARGET_DSX_BUFFERS];
ULONG ulFreeTargetBufferCnt;
- ULONG ulCurrentTargetBuffer;
- ULONG ulTotalTargetBuffersAvailable;
-
- unsigned long chip_id;
-
- wait_queue_head_t lowpower_mode_wait_queue;
-
+ ULONG ulCurrentTargetBuffer;
+ ULONG ulTotalTargetBuffersAvailable;
+ unsigned long chip_id;
+ wait_queue_head_t lowpower_mode_wait_queue;
BOOLEAN bFlashBoot;
BOOLEAN bBinDownloaded;
BOOLEAN bCfgDownloaded;
BOOLEAN bSyncUpRequestSent;
USHORT usBestEffortQueueIndex;
-
- wait_queue_head_t ioctl_fw_dnld_wait_queue;
- BOOLEAN waiting_to_fw_download_done;
- pid_t fw_download_process_pid;
+ wait_queue_head_t ioctl_fw_dnld_wait_queue;
+ BOOLEAN waiting_to_fw_download_done;
+ pid_t fw_download_process_pid;
PSTARGETPARAMS pstargetparams;
- BOOLEAN device_removed;
- BOOLEAN DeviceAccess;
- BOOLEAN bIsAutoCorrectEnabled;
- BOOLEAN bDDRInitDone;
- INT DDRSetting;
- ULONG ulPowerSaveMode;
- spinlock_t txtransmitlock;
- B_UINT8 txtransmit_running;
+ BOOLEAN device_removed;
+ BOOLEAN DeviceAccess;
+ BOOLEAN bIsAutoCorrectEnabled;
+ BOOLEAN bDDRInitDone;
+ int DDRSetting;
+ ULONG ulPowerSaveMode;
+ spinlock_t txtransmitlock;
+ B_UINT8 txtransmit_running;
/* Thread for control packet handling */
- struct task_struct *control_packet_handler;
+ struct task_struct *control_packet_handler;
/* thread for transmitting packets. */
- struct task_struct *transmit_packet_thread;
+ struct task_struct *transmit_packet_thread;
/* LED Related Structures */
LED_INFO_STRUCT LEDInfo;
@@ -482,42 +308,41 @@ struct _MINI_ADAPTER
/* Driver State for LED Blinking */
LedEventInfo_t DriverState;
/* Interface Specific */
- PVOID pvInterfaceAdapter;
- int (*bcm_file_download)( PVOID,
- struct file *,
- unsigned int);
- int (*bcm_file_readback_from_chip)( PVOID,
- struct file *,
- unsigned int);
- INT (*interface_rdm)(PVOID,
- UINT ,
- PVOID ,
- INT);
- INT (*interface_wrm)(PVOID,
- UINT ,
- PVOID ,
- INT);
+ PVOID pvInterfaceAdapter;
+ int (*bcm_file_download)(PVOID,
+ struct file *,
+ unsigned int);
+ int (*bcm_file_readback_from_chip)(PVOID,
+ struct file *,
+ unsigned int);
+ int (*interface_rdm)(PVOID,
+ UINT,
+ PVOID,
+ int);
+ int (*interface_wrm)(PVOID,
+ UINT,
+ PVOID,
+ int);
int (*interface_transmit)(PVOID, PVOID , UINT);
BOOLEAN IdleMode;
BOOLEAN bDregRequestSentInIdleMode;
BOOLEAN bTriedToWakeUpFromlowPowerMode;
BOOLEAN bShutStatus;
BOOLEAN bWakeUpDevice;
- unsigned int usIdleModePattern;
- //BOOLEAN bTriedToWakeUpFromShutdown;
+ unsigned int usIdleModePattern;
+ /* BOOLEAN bTriedToWakeUpFromShutdown; */
BOOLEAN bLinkDownRequested;
-
- int downloadDDR;
- PHS_DEVICE_EXTENSION stBCMPhsContext;
- S_HDR_SUPRESSION_CONTEXTINFO stPhsTxContextInfo;
+ int downloadDDR;
+ PHS_DEVICE_EXTENSION stBCMPhsContext;
+ struct bcm_hdr_suppression_contextinfo stPhsTxContextInfo;
uint8_t ucaPHSPktRestoreBuf[2048];
uint8_t bPHSEnabled;
BOOLEAN AutoFirmDld;
- BOOLEAN bMipsConfig;
- BOOLEAN bDPLLConfig;
+ BOOLEAN bMipsConfig;
+ BOOLEAN bDPLLConfig;
UINT32 aTxPktSizeHist[MIBS_MAX_HIST_ENTRIES];
UINT32 aRxPktSizeHist[MIBS_MAX_HIST_ENTRIES];
- S_FRAGMENTED_PACKET_INFO astFragmentedPktClassifierTable[MAX_FRAGMENTEDIP_CLASSIFICATION_ENTRIES];
+ struct bcm_fragmented_packet_info astFragmentedPktClassifierTable[MAX_FRAGMENTEDIP_CLASSIFICATION_ENTRIES];
atomic_t uiMBupdate;
UINT32 PmuMode;
NVM_TYPE eNVMType;
@@ -527,108 +352,93 @@ struct _MINI_ADAPTER
BOOLEAN bStatusWrite;
UINT uiNVMDSDSize;
UINT uiVendorExtnFlag;
- //it will always represent chosen DSD at any point of time.
- // Generally it is Active DSD but in case of NVM RD/WR it might be different.
+ /* it will always represent chosen DSD at any point of time.
+ * Generally it is Active DSD but in case of NVM RD/WR it might be different.
+ */
UINT ulFlashCalStart;
- ULONG ulFlashControlSectionStart;
- ULONG ulFlashWriteSize;
- ULONG ulFlashID;
- FP_FLASH_WRITE fpFlashWrite;
- FP_FLASH_WRITE_STATUS fpFlashWriteWithStatusCheck;
-
+ ULONG ulFlashControlSectionStart;
+ ULONG ulFlashWriteSize;
+ ULONG ulFlashID;
+ FP_FLASH_WRITE fpFlashWrite;
+ FP_FLASH_WRITE_STATUS fpFlashWriteWithStatusCheck;
struct semaphore NVMRdmWrmLock;
+ struct device *pstCreatedClassDevice;
- struct device *pstCreatedClassDevice;
-
-// BOOLEAN InterfaceUpStatus;
- PFLASH2X_CS_INFO psFlash2xCSInfo;
- PFLASH_CS_INFO psFlashCSInfo ;
+ /* BOOLEAN InterfaceUpStatus; */
+ PFLASH2X_CS_INFO psFlash2xCSInfo;
+ PFLASH_CS_INFO psFlashCSInfo;
PFLASH2X_VENDORSPECIFIC_INFO psFlash2xVendorInfo;
- UINT uiFlashBaseAdd; //Flash start address
- UINT uiActiveISOOffset; //Active ISO offset chosen before f/w download
- FLASH2X_SECTION_VAL eActiveISO; //Active ISO section val
- FLASH2X_SECTION_VAL eActiveDSD; //Active DSD val chosen before f/w download
- UINT uiActiveDSDOffsetAtFwDld; //For accessing Active DSD chosen before f/w download
- UINT uiFlashLayoutMajorVersion ;
- UINT uiFlashLayoutMinorVersion;
- BOOLEAN bAllDSDWriteAllow ;
- BOOLEAN bSigCorrupted ;
- //this should be set who so ever want to change the Headers. after Wrtie it should be reset immediately.
- BOOLEAN bHeaderChangeAllowed ;
- INT SelectedChip ;
- BOOLEAN bEndPointHalted;
- //while bFlashRawRead will be true, Driver ignore map lay out and consider flash as of without any map.
- BOOLEAN bFlashRawRead;
- BOOLEAN bPreparingForLowPowerMode ;
- BOOLEAN bDoSuspend ;
- UINT syscfgBefFwDld ;
- BOOLEAN StopAllXaction ;
- UINT32 liTimeSinceLastNetEntry; //Used to Support extended CAPI requirements from
+ UINT uiFlashBaseAdd; /* Flash start address */
+ UINT uiActiveISOOffset; /* Active ISO offset chosen before f/w download */
+ FLASH2X_SECTION_VAL eActiveISO; /* Active ISO section val */
+ FLASH2X_SECTION_VAL eActiveDSD; /* Active DSD val chosen before f/w download */
+ UINT uiActiveDSDOffsetAtFwDld; /* For accessing Active DSD chosen before f/w download */
+ UINT uiFlashLayoutMajorVersion;
+ UINT uiFlashLayoutMinorVersion;
+ BOOLEAN bAllDSDWriteAllow;
+ BOOLEAN bSigCorrupted;
+ /* this should be set who so ever want to change the Headers. after Wrtie it should be reset immediately. */
+ BOOLEAN bHeaderChangeAllowed;
+ int SelectedChip;
+ BOOLEAN bEndPointHalted;
+ /* while bFlashRawRead will be true, Driver ignore map lay out and consider flash as of without any map. */
+ BOOLEAN bFlashRawRead;
+ BOOLEAN bPreparingForLowPowerMode;
+ BOOLEAN bDoSuspend;
+ UINT syscfgBefFwDld;
+ BOOLEAN StopAllXaction;
+ UINT32 liTimeSinceLastNetEntry; /* Used to Support extended CAPI requirements from */
struct semaphore LowPowerModeSync;
- ULONG liDrainCalculated;
- UINT gpioBitMap;
-
- S_BCM_DEBUG_STATE stDebugState;
-
+ ULONG liDrainCalculated;
+ UINT gpioBitMap;
+ S_BCM_DEBUG_STATE stDebugState;
};
-typedef struct _MINI_ADAPTER MINI_ADAPTER, *PMINI_ADAPTER;
-
-#define GET_BCM_ADAPTER(net_dev) netdev_priv(net_dev)
-struct _ETH_HEADER_STRUC {
- UCHAR au8DestinationAddress[6];
- UCHAR au8SourceAddress[6];
- USHORT u16Etype;
-}__attribute__((packed));
-typedef struct _ETH_HEADER_STRUC ETH_HEADER_STRUC, *PETH_HEADER_STRUC;
+#define GET_BCM_ADAPTER(net_dev) netdev_priv(net_dev)
+struct bcm_eth_header {
+ UCHAR au8DestinationAddress[6];
+ UCHAR au8SourceAddress[6];
+ USHORT u16Etype;
+} __packed;
-typedef struct FirmwareInfo
-{
- void __user * pvMappedFirmwareAddress;
- ULONG u32FirmwareLength;
- ULONG u32StartingAddress;
-}__attribute__((packed)) FIRMWARE_INFO, *PFIRMWARE_INFO;
+struct bcm_firmware_info {
+ void __user *pvMappedFirmwareAddress;
+ ULONG u32FirmwareLength;
+ ULONG u32StartingAddress;
+} __packed;
-// holds the value of net_device structure..
+/* holds the value of net_device structure.. */
extern struct net_device *gblpnetdev;
-typedef struct _cntl_pkt{
- PMINI_ADAPTER Adapter;
- PLEADER PLeader;
-}cntl_pkt;
-typedef LINK_REQUEST CONTROL_MESSAGE;
-
-typedef struct _DDR_SETTING
-{
+
+struct bcm_ddr_setting {
UINT ulRegAddress;
UINT ulRegValue;
-}DDR_SETTING, *PDDR_SETTING;
-typedef DDR_SETTING DDR_SET_NODE, *PDDR_SET_NODE;
-INT
-InitAdapter(PMINI_ADAPTER psAdapter);
-
-// =====================================================================
-// Beceem vendor request codes for EP0
-// =====================================================================
+};
+int InitAdapter(struct bcm_mini_adapter *psAdapter);
-#define BCM_REQUEST_READ 0x2
-#define BCM_REQUEST_WRITE 0x1
-#define EP2_MPS_REG 0x0F0110A0
-#define EP2_MPS 0x40
+/* =====================================================================
+ * Beceem vendor request codes for EP0
+ * =====================================================================
+ */
-#define EP2_CFG_REG 0x0F0110A8
-#define EP2_CFG_INT 0x27
-#define EP2_CFG_BULK 0x25
+#define BCM_REQUEST_READ 0x2
+#define BCM_REQUEST_WRITE 0x1
+#define EP2_MPS_REG 0x0F0110A0
+#define EP2_MPS 0x40
-#define EP4_MPS_REG 0x0F0110F0
-#define EP4_MPS 0x8C
+#define EP2_CFG_REG 0x0F0110A8
+#define EP2_CFG_INT 0x27
+#define EP2_CFG_BULK 0x25
-#define EP4_CFG_REG 0x0F0110F8
+#define EP4_MPS_REG 0x0F0110F0
+#define EP4_MPS 0x8C
-#define ISO_MPS_REG 0x0F0110C8
-#define ISO_MPS 0x00000000
+#define EP4_CFG_REG 0x0F0110F8
+#define ISO_MPS_REG 0x0F0110C8
+#define ISO_MPS 0x00000000
#define EP1 0
#define EP2 1
@@ -637,12 +447,9 @@ InitAdapter(PMINI_ADAPTER psAdapter);
#define EP5 4
#define EP6 5
-
-typedef enum eInterface_setting
-{
+enum bcm_einterface_setting {
DEFAULT_SETTING_0 = 0,
ALTERNATE_SETTING_1 = 1,
-}INTERFACE_SETTING;
-
-#endif //__ADAPTER_H__
+};
+#endif /* __ADAPTER_H__ */
diff --git a/drivers/staging/bcm/Bcmchar.c b/drivers/staging/bcm/Bcmchar.c
index cf3059216958..cf411d1706b1 100644
--- a/drivers/staging/bcm/Bcmchar.c
+++ b/drivers/staging/bcm/Bcmchar.c
@@ -15,11 +15,11 @@
static int bcm_char_open(struct inode *inode, struct file * filp)
{
- PMINI_ADAPTER Adapter = NULL;
- PPER_TARANG_DATA pTarang = NULL;
+ struct bcm_mini_adapter *Adapter = NULL;
+ struct bcm_tarang_data *pTarang = NULL;
Adapter = GET_BCM_ADAPTER(gblpnetdev);
- pTarang = kzalloc(sizeof(PER_TARANG_DATA), GFP_KERNEL);
+ pTarang = kzalloc(sizeof(struct bcm_tarang_data), GFP_KERNEL);
if (!pTarang)
return -ENOMEM;
@@ -43,11 +43,11 @@ static int bcm_char_open(struct inode *inode, struct file * filp)
static int bcm_char_release(struct inode *inode, struct file *filp)
{
- PPER_TARANG_DATA pTarang, tmp, ptmp;
- PMINI_ADAPTER Adapter = NULL;
+ struct bcm_tarang_data *pTarang, *tmp, *ptmp;
+ struct bcm_mini_adapter *Adapter = NULL;
struct sk_buff *pkt, *npkt;
- pTarang = (PPER_TARANG_DATA)filp->private_data;
+ pTarang = (struct bcm_tarang_data *)filp->private_data;
if (pTarang == NULL) {
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0,
@@ -97,8 +97,8 @@ static int bcm_char_release(struct inode *inode, struct file *filp)
static ssize_t bcm_char_read(struct file *filp, char __user *buf, size_t size,
loff_t *f_pos)
{
- PPER_TARANG_DATA pTarang = filp->private_data;
- PMINI_ADAPTER Adapter = pTarang->Adapter;
+ struct bcm_tarang_data *pTarang = filp->private_data;
+ struct bcm_mini_adapter *Adapter = pTarang->Adapter;
struct sk_buff *Packet = NULL;
ssize_t PktLen = 0;
int wait_ret_val = 0;
@@ -155,9 +155,9 @@ static ssize_t bcm_char_read(struct file *filp, char __user *buf, size_t size,
static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg)
{
- PPER_TARANG_DATA pTarang = filp->private_data;
+ struct bcm_tarang_data *pTarang = filp->private_data;
void __user *argp = (void __user *)arg;
- PMINI_ADAPTER Adapter = pTarang->Adapter;
+ struct bcm_mini_adapter *Adapter = pTarang->Adapter;
INT Status = STATUS_FAILURE;
int timeout = 0;
IOCTL_BUFFER IoBuffer;
@@ -722,7 +722,7 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg)
if (copy_from_user(&IoBuffer, argp, sizeof(IOCTL_BUFFER)))
return -EFAULT;
- if (IoBuffer.InputLength < sizeof(struct link_request))
+ if (IoBuffer.InputLength < sizeof(struct bcm_link_request))
return -EINVAL;
if (IoBuffer.InputLength > MAX_CNTL_PKT_SIZE)
@@ -787,7 +787,7 @@ cntrlEnd:
}
case IOCTL_BCM_BUFFER_DOWNLOAD: {
- FIRMWARE_INFO *psFwInfo = NULL;
+ struct bcm_firmware_info *psFwInfo = NULL;
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Starting the firmware download PID =0x%x!!!!\n", current->pid);
if (!down_trylock(&Adapter->fw_download_sema)) {
@@ -807,7 +807,7 @@ cntrlEnd:
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0,
"Length for FW DLD is : %lx\n", IoBuffer.InputLength);
- if (IoBuffer.InputLength > sizeof(FIRMWARE_INFO)) {
+ if (IoBuffer.InputLength > sizeof(struct bcm_firmware_info)) {
up(&Adapter->fw_download_sema);
return -EINVAL;
}
@@ -971,7 +971,7 @@ cntrlEnd:
break;
case IOCTL_GET_PACK_INFO:
- if (copy_to_user(argp, &Adapter->PackInfo, sizeof(PacketInfo)*NO_OF_QUEUES))
+ if (copy_to_user(argp, &Adapter->PackInfo, sizeof(struct bcm_packet_info)*NO_OF_QUEUES))
return -EFAULT;
Status = STATUS_SUCCESS;
break;
@@ -2014,7 +2014,7 @@ static const struct file_operations bcm_fops = {
.llseek = no_llseek,
};
-int register_control_device_interface(PMINI_ADAPTER Adapter)
+int register_control_device_interface(struct bcm_mini_adapter *Adapter)
{
if (Adapter->major > 0)
@@ -2039,7 +2039,7 @@ int register_control_device_interface(PMINI_ADAPTER Adapter)
return 0;
}
-void unregister_control_device_interface(PMINI_ADAPTER Adapter)
+void unregister_control_device_interface(struct bcm_mini_adapter *Adapter)
{
if (Adapter->major > 0) {
device_destroy(bcm_class, MKDEV(Adapter->major, 0));
diff --git a/drivers/staging/bcm/Bcmnet.c b/drivers/staging/bcm/Bcmnet.c
index 133e146a3dd4..6e8c7f523214 100644
--- a/drivers/staging/bcm/Bcmnet.c
+++ b/drivers/staging/bcm/Bcmnet.c
@@ -4,7 +4,7 @@ struct net_device *gblpnetdev;
static INT bcm_open(struct net_device *dev)
{
- PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(dev);
+ struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(dev);
if (Adapter->fw_download_done == FALSE) {
pr_notice(PFX "%s: link up failed (download in progress)\n",
@@ -28,7 +28,7 @@ static INT bcm_open(struct net_device *dev)
static INT bcm_close(struct net_device *dev)
{
- PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(dev);
+ struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(dev);
if (netif_msg_ifdown(Adapter))
pr_info(PFX "%s: disabling interface\n", dev->name);
@@ -59,7 +59,7 @@ static u16 bcm_select_queue(struct net_device *dev, struct sk_buff *skb)
static netdev_tx_t bcm_transmit(struct sk_buff *skb, struct net_device *dev)
{
- PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(dev);
+ struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(dev);
u16 qindex = skb_get_queue_mapping(skb);
@@ -141,7 +141,7 @@ static int bcm_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
static void bcm_get_drvinfo(struct net_device *dev,
struct ethtool_drvinfo *info)
{
- PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(dev);
+ struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(dev);
PS_INTERFACE_ADAPTER psIntfAdapter = Adapter->pvInterfaceAdapter;
struct usb_device *udev = interface_to_usbdev(psIntfAdapter->interface);
@@ -156,21 +156,21 @@ static void bcm_get_drvinfo(struct net_device *dev,
static u32 bcm_get_link(struct net_device *dev)
{
- PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(dev);
+ struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(dev);
return Adapter->LinkUpStatus;
}
static u32 bcm_get_msglevel(struct net_device *dev)
{
- PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(dev);
+ struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(dev);
return Adapter->msg_enable;
}
static void bcm_set_msglevel(struct net_device *dev, u32 level)
{
- PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(dev);
+ struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(dev);
Adapter->msg_enable = level;
}
@@ -183,7 +183,7 @@ static const struct ethtool_ops bcm_ethtool_ops = {
.set_msglevel = bcm_set_msglevel,
};
-int register_networkdev(PMINI_ADAPTER Adapter)
+int register_networkdev(struct bcm_mini_adapter *Adapter)
{
struct net_device *net = Adapter->dev;
PS_INTERFACE_ADAPTER IntfAdapter = Adapter->pvInterfaceAdapter;
@@ -224,7 +224,7 @@ int register_networkdev(PMINI_ADAPTER Adapter)
return 0;
}
-void unregister_networkdev(PMINI_ADAPTER Adapter)
+void unregister_networkdev(struct bcm_mini_adapter *Adapter)
{
struct net_device *net = Adapter->dev;
PS_INTERFACE_ADAPTER IntfAdapter = Adapter->pvInterfaceAdapter;
diff --git a/drivers/staging/bcm/CmHost.c b/drivers/staging/bcm/CmHost.c
index 7e38af5e1765..b54ec974477f 100644
--- a/drivers/staging/bcm/CmHost.c
+++ b/drivers/staging/bcm/CmHost.c
@@ -4,7 +4,6 @@
* Management.
************************************************************/
-/* #define CONN_MSG */
#include "headers.h"
enum E_CLASSIFIER_ACTION {
@@ -14,7 +13,7 @@ enum E_CLASSIFIER_ACTION {
eDeleteClassifier
};
-static ULONG GetNextTargetBufferLocation(PMINI_ADAPTER Adapter, B_UINT16 tid);
+static ULONG GetNextTargetBufferLocation(struct bcm_mini_adapter *Adapter, B_UINT16 tid);
/************************************************************
* Function - SearchSfid
@@ -28,7 +27,7 @@ static ULONG GetNextTargetBufferLocation(PMINI_ADAPTER Adapter, B_UINT16 tid);
* Returns - Queue index for this SFID(If matched)
* Else Invalid Queue Index(If Not matched)
************************************************************/
-int SearchSfid(PMINI_ADAPTER Adapter, UINT uiSfid)
+int SearchSfid(struct bcm_mini_adapter *Adapter, UINT uiSfid)
{
int i;
@@ -49,7 +48,7 @@ int SearchSfid(PMINI_ADAPTER Adapter, UINT uiSfid)
* Returns - Queue index for the free SFID
* Else returns Invalid Index.
****************************************************************/
-static int SearchFreeSfid(PMINI_ADAPTER Adapter)
+static int SearchFreeSfid(struct bcm_mini_adapter *Adapter)
{
int i;
@@ -63,12 +62,12 @@ static int SearchFreeSfid(PMINI_ADAPTER Adapter)
/*
* Function: SearchClsid
* Description: This routinue would search Classifier having specified ClassifierID as input parameter
- * Input parameters: PMINI_ADAPTER Adapter - Adapter Context
+ * Input parameters: struct bcm_mini_adapter *Adapter - Adapter Context
* unsigned int uiSfid - The SF in which the classifier is to searched
* B_UINT16 uiClassifierID - The classifier ID to be searched
* Return: int :Classifier table index of matching entry
*/
-static int SearchClsid(PMINI_ADAPTER Adapter, ULONG ulSFID, B_UINT16 uiClassifierID)
+static int SearchClsid(struct bcm_mini_adapter *Adapter, ULONG ulSFID, B_UINT16 uiClassifierID)
{
int i;
@@ -87,7 +86,7 @@ static int SearchClsid(PMINI_ADAPTER Adapter, ULONG ulSFID, B_UINT16 uiClassifi
* This routinue would search Free available Classifier entry in classifier table.
* @return free Classifier Entry index in classifier table for specified SF
*/
-static int SearchFreeClsid(PMINI_ADAPTER Adapter /**Adapter Context*/)
+static int SearchFreeClsid(struct bcm_mini_adapter *Adapter /**Adapter Context*/)
{
int i;
@@ -99,7 +98,7 @@ static int SearchFreeClsid(PMINI_ADAPTER Adapter /**Adapter Context*/)
return MAX_CLASSIFIERS+1;
}
-static VOID deleteSFBySfid(PMINI_ADAPTER Adapter, UINT uiSearchRuleIndex)
+static VOID deleteSFBySfid(struct bcm_mini_adapter *Adapter, UINT uiSearchRuleIndex)
{
/* deleting all the packet held in the SF */
flush_queue(Adapter, uiSearchRuleIndex);
@@ -112,7 +111,7 @@ static VOID deleteSFBySfid(PMINI_ADAPTER Adapter, UINT uiSearchRuleIndex)
}
static inline VOID
-CopyIpAddrToClassifier(S_CLASSIFIER_RULE *pstClassifierEntry,
+CopyIpAddrToClassifier(struct bcm_classifier_rule *pstClassifierEntry,
B_UINT8 u8IpAddressLen, B_UINT8 *pu8IpAddressMaskSrc,
BOOLEAN bIpVersion6, E_IPADDR_CONTEXT eIpAddrContext)
{
@@ -120,7 +119,7 @@ CopyIpAddrToClassifier(S_CLASSIFIER_RULE *pstClassifierEntry,
UINT nSizeOfIPAddressInBytes = IP_LENGTH_OF_ADDRESS;
UCHAR *ptrClassifierIpAddress = NULL;
UCHAR *ptrClassifierIpMask = NULL;
- PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev);
+ struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev);
if (bIpVersion6)
nSizeOfIPAddressInBytes = IPV6_ADDRESS_SIZEINBYTES;
@@ -214,7 +213,7 @@ CopyIpAddrToClassifier(S_CLASSIFIER_RULE *pstClassifierEntry,
}
}
-void ClearTargetDSXBuffer(PMINI_ADAPTER Adapter, B_UINT16 TID, BOOLEAN bFreeAll)
+void ClearTargetDSXBuffer(struct bcm_mini_adapter *Adapter, B_UINT16 TID, BOOLEAN bFreeAll)
{
int i;
@@ -236,9 +235,9 @@ void ClearTargetDSXBuffer(PMINI_ADAPTER Adapter, B_UINT16 TID, BOOLEAN bFreeAll)
* @ingroup ctrl_pkt_functions
* copy classifier rule into the specified SF index
*/
-static inline VOID CopyClassifierRuleToSF(PMINI_ADAPTER Adapter, stConvergenceSLTypes *psfCSType, UINT uiSearchRuleIndex, UINT nClassifierIndex)
+static inline VOID CopyClassifierRuleToSF(struct bcm_mini_adapter *Adapter, stConvergenceSLTypes *psfCSType, UINT uiSearchRuleIndex, UINT nClassifierIndex)
{
- S_CLASSIFIER_RULE *pstClassifierEntry = NULL;
+ struct bcm_classifier_rule *pstClassifierEntry = NULL;
/* VOID *pvPhsContext = NULL; */
int i;
/* UCHAR ucProtocolLength=0; */
@@ -365,9 +364,9 @@ static inline VOID CopyClassifierRuleToSF(PMINI_ADAPTER Adapter, stConvergenceSL
/*
* @ingroup ctrl_pkt_functions
*/
-static inline VOID DeleteClassifierRuleFromSF(PMINI_ADAPTER Adapter, UINT uiSearchRuleIndex, UINT nClassifierIndex)
+static inline VOID DeleteClassifierRuleFromSF(struct bcm_mini_adapter *Adapter, UINT uiSearchRuleIndex, UINT nClassifierIndex)
{
- S_CLASSIFIER_RULE *pstClassifierEntry = NULL;
+ struct bcm_classifier_rule *pstClassifierEntry = NULL;
B_UINT16 u16PacketClassificationRuleIndex;
USHORT usVCID;
/* VOID *pvPhsContext = NULL; */
@@ -386,7 +385,7 @@ static inline VOID DeleteClassifierRuleFromSF(PMINI_ADAPTER Adapter, UINT uiSear
if (pstClassifierEntry) {
pstClassifierEntry->bUsed = FALSE;
pstClassifierEntry->uiClassifierRuleIndex = 0;
- memset(pstClassifierEntry, 0, sizeof(S_CLASSIFIER_RULE));
+ memset(pstClassifierEntry, 0, sizeof(struct bcm_classifier_rule));
/* Delete the PHS Rule for this classifier */
PhsDeleteClassifierRule(&Adapter->stBCMPhsContext, usVCID, u16PacketClassificationRuleIndex);
@@ -396,9 +395,9 @@ static inline VOID DeleteClassifierRuleFromSF(PMINI_ADAPTER Adapter, UINT uiSear
/*
* @ingroup ctrl_pkt_functions
*/
-VOID DeleteAllClassifiersForSF(PMINI_ADAPTER Adapter, UINT uiSearchRuleIndex)
+VOID DeleteAllClassifiersForSF(struct bcm_mini_adapter *Adapter, UINT uiSearchRuleIndex)
{
- S_CLASSIFIER_RULE *pstClassifierEntry = NULL;
+ struct bcm_classifier_rule *pstClassifierEntry = NULL;
int i;
/* B_UINT16 u16PacketClassificationRuleIndex; */
USHORT ulVCID;
@@ -428,7 +427,7 @@ VOID DeleteAllClassifiersForSF(PMINI_ADAPTER Adapter, UINT uiSearchRuleIndex)
* related data into the Adapter structure.
* @ingroup ctrl_pkt_functions
*/
-static VOID CopyToAdapter(register PMINI_ADAPTER Adapter, /* <Pointer to the Adapter structure */
+static VOID CopyToAdapter(register struct bcm_mini_adapter *Adapter, /* <Pointer to the Adapter structure */
register pstServiceFlowParamSI psfLocalSet, /* <Pointer to the ServiceFlowParamSI structure */
register UINT uiSearchRuleIndex, /* <Index of Queue, to which this data belongs */
register UCHAR ucDsxType,
@@ -836,7 +835,7 @@ static VOID DumpCmControlPacket(PVOID pvBuffer)
int nIndex;
stLocalSFAddIndicationAlt *pstAddIndication;
UINT nCurClassifierCnt;
- PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev);
+ struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev);
pstAddIndication = (stLocalSFAddIndicationAlt *)pvBuffer;
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "======>");
@@ -967,24 +966,18 @@ static VOID DumpCmControlPacket(PVOID pvBuffer)
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8EthernetDestMacAddressLength: 0x%02X ",
psfCSType->cCPacketClassificationRule.u8EthernetDestMacAddressLength);
- BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8EthernetDestMacAddress[6]: 0x %02X %02X %02X %02X %02X %02X",
- psfCSType->cCPacketClassificationRule.u8EthernetDestMacAddress[0],
- psfCSType->cCPacketClassificationRule.u8EthernetDestMacAddress[1],
- psfCSType->cCPacketClassificationRule.u8EthernetDestMacAddress[2],
- psfCSType->cCPacketClassificationRule.u8EthernetDestMacAddress[3],
- psfCSType->cCPacketClassificationRule.u8EthernetDestMacAddress[4],
- psfCSType->cCPacketClassificationRule.u8EthernetDestMacAddress[5]);
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL,
+ DBG_LVL_ALL, "u8EthernetDestMacAddress[6]: %pM",
+ psfCSType->cCPacketClassificationRule.
+ u8EthernetDestMacAddress);
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8EthernetSourceMACAddressLength: 0x%02X ",
psfCSType->cCPacketClassificationRule.u8EthernetDestMacAddressLength);
- BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8EthernetSourceMACAddress[6]: 0x %02X %02X %02X %02X %02X %02X",
- psfCSType->cCPacketClassificationRule.u8EthernetSourceMACAddress[0],
- psfCSType->cCPacketClassificationRule.u8EthernetSourceMACAddress[1],
- psfCSType->cCPacketClassificationRule.u8EthernetSourceMACAddress[2],
- psfCSType->cCPacketClassificationRule.u8EthernetSourceMACAddress[3],
- psfCSType->cCPacketClassificationRule.u8EthernetSourceMACAddress[4],
- psfCSType->cCPacketClassificationRule.u8EthernetSourceMACAddress[5]);
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL,
+ DBG_LVL_ALL, "u8EthernetSourceMACAddress[6]: "
+ "%pM", psfCSType->cCPacketClassificationRule.
+ u8EthernetSourceMACAddress);
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8EthertypeLength: 0x%02X ",
psfCSType->cCPacketClassificationRule.u8EthertypeLength);
@@ -1123,24 +1116,18 @@ static VOID DumpCmControlPacket(PVOID pvBuffer)
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8EthernetDestMacAddressLength: 0x%02X ",
psfCSType->cCPacketClassificationRule.u8EthernetDestMacAddressLength);
- BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8EthernetDestMacAddress[6]: 0x %02X %02X %02X %02X %02X %02X",
- psfCSType->cCPacketClassificationRule.u8EthernetDestMacAddress[0],
- psfCSType->cCPacketClassificationRule.u8EthernetDestMacAddress[1],
- psfCSType->cCPacketClassificationRule.u8EthernetDestMacAddress[2],
- psfCSType->cCPacketClassificationRule.u8EthernetDestMacAddress[3],
- psfCSType->cCPacketClassificationRule.u8EthernetDestMacAddress[4],
- psfCSType->cCPacketClassificationRule.u8EthernetDestMacAddress[5]);
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL,
+ DBG_LVL_ALL, "u8EthernetDestMacAddress[6]: %pM",
+ psfCSType->cCPacketClassificationRule.
+ u8EthernetDestMacAddress);
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8EthernetSourceMACAddressLength: 0x%02X ",
psfCSType->cCPacketClassificationRule.u8EthernetDestMacAddressLength);
- BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8EthernetSourceMACAddress[6]: 0x %02X %02X %02X %02X %02X %02X",
- psfCSType->cCPacketClassificationRule.u8EthernetSourceMACAddress[0],
- psfCSType->cCPacketClassificationRule.u8EthernetSourceMACAddress[1],
- psfCSType->cCPacketClassificationRule.u8EthernetSourceMACAddress[2],
- psfCSType->cCPacketClassificationRule.u8EthernetSourceMACAddress[3],
- psfCSType->cCPacketClassificationRule.u8EthernetSourceMACAddress[4],
- psfCSType->cCPacketClassificationRule.u8EthernetSourceMACAddress[5]);
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL,
+ DBG_LVL_ALL, "u8EthernetSourceMACAddress[6]: "
+ "%pM", psfCSType->cCPacketClassificationRule.
+ u8EthernetSourceMACAddress);
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8EthertypeLength: 0x%02X ", psfCSType->cCPacketClassificationRule.u8EthertypeLength);
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8Ethertype[3]: 0x%02X %02X %02X",
@@ -1325,7 +1312,7 @@ static VOID DumpCmControlPacket(PVOID pvBuffer)
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " bValid: 0x%X", pstAddIndication->sfActiveSet.bValid);
}
-static inline ULONG RestoreSFParam(PMINI_ADAPTER Adapter, ULONG ulAddrSFParamSet, PUCHAR pucDestBuffer)
+static inline ULONG RestoreSFParam(struct bcm_mini_adapter *Adapter, ULONG ulAddrSFParamSet, PUCHAR pucDestBuffer)
{
UINT nBytesToRead = sizeof(stServiceFlowParamSI);
@@ -1342,7 +1329,7 @@ static inline ULONG RestoreSFParam(PMINI_ADAPTER Adapter, ULONG ulAddrSFParamSet
return 1;
}
-static ULONG StoreSFParam(PMINI_ADAPTER Adapter, PUCHAR pucSrcBuffer, ULONG ulAddrSFParamSet)
+static ULONG StoreSFParam(struct bcm_mini_adapter *Adapter, PUCHAR pucSrcBuffer, ULONG ulAddrSFParamSet)
{
UINT nBytesToWrite = sizeof(stServiceFlowParamSI);
int ret = 0;
@@ -1358,7 +1345,7 @@ static ULONG StoreSFParam(PMINI_ADAPTER Adapter, PUCHAR pucSrcBuffer, ULONG ulAd
return 1;
}
-ULONG StoreCmControlResponseMessage(PMINI_ADAPTER Adapter, PVOID pvBuffer, UINT *puBufferLength)
+ULONG StoreCmControlResponseMessage(struct bcm_mini_adapter *Adapter, PVOID pvBuffer, UINT *puBufferLength)
{
stLocalSFAddIndicationAlt *pstAddIndicationAlt = NULL;
stLocalSFAddIndication *pstAddIndication = NULL;
@@ -1473,7 +1460,7 @@ ULONG StoreCmControlResponseMessage(PMINI_ADAPTER Adapter, PVOID pvBuffer, UINT
}
static inline stLocalSFAddIndicationAlt
-*RestoreCmControlResponseMessage(register PMINI_ADAPTER Adapter, register PVOID pvBuffer)
+*RestoreCmControlResponseMessage(register struct bcm_mini_adapter *Adapter, register PVOID pvBuffer)
{
ULONG ulStatus = 0;
stLocalSFAddIndication *pstAddIndication = NULL;
@@ -1551,7 +1538,7 @@ failed_restore_sf_param:
return NULL;
}
-ULONG SetUpTargetDsxBuffers(PMINI_ADAPTER Adapter)
+ULONG SetUpTargetDsxBuffers(struct bcm_mini_adapter *Adapter)
{
ULONG ulTargetDsxBuffersBase = 0;
ULONG ulCntTargetBuffers;
@@ -1598,7 +1585,7 @@ ULONG SetUpTargetDsxBuffers(PMINI_ADAPTER Adapter)
return 1;
}
-static ULONG GetNextTargetBufferLocation(PMINI_ADAPTER Adapter, B_UINT16 tid)
+static ULONG GetNextTargetBufferLocation(struct bcm_mini_adapter *Adapter, B_UINT16 tid)
{
ULONG ulTargetDSXBufferAddress;
ULONG ulTargetDsxBufferIndexToUse, ulMaxTry;
@@ -1632,7 +1619,7 @@ static ULONG GetNextTargetBufferLocation(PMINI_ADAPTER Adapter, B_UINT16 tid)
return ulTargetDSXBufferAddress;
}
-int AllocAdapterDsxBuffer(PMINI_ADAPTER Adapter)
+int AllocAdapterDsxBuffer(struct bcm_mini_adapter *Adapter)
{
/*
* Need to Allocate memory to contain the SUPER Large structures
@@ -1645,7 +1632,7 @@ int AllocAdapterDsxBuffer(PMINI_ADAPTER Adapter)
return 0;
}
-int FreeAdapterDsxBuffer(PMINI_ADAPTER Adapter)
+int FreeAdapterDsxBuffer(struct bcm_mini_adapter *Adapter)
{
kfree(Adapter->caDsxReqResp);
return 0;
@@ -1657,13 +1644,13 @@ int FreeAdapterDsxBuffer(PMINI_ADAPTER Adapter)
* for the Connection Management.
* @return - Queue index for the free SFID else returns Invalid Index.
*/
-BOOLEAN CmControlResponseMessage(PMINI_ADAPTER Adapter, /* <Pointer to the Adapter structure */
+BOOLEAN CmControlResponseMessage(struct bcm_mini_adapter *Adapter, /* <Pointer to the Adapter structure */
PVOID pvBuffer /* Starting Address of the Buffer, that contains the AddIndication Data */)
{
stServiceFlowParamSI *psfLocalSet = NULL;
stLocalSFAddIndicationAlt *pstAddIndication = NULL;
stLocalSFChangeIndicationAlt *pstChangeIndication = NULL;
- PLEADER pLeader = NULL;
+ struct bcm_leader *pLeader = NULL;
/*
* Otherwise the message contains a target address from where we need to
@@ -1678,7 +1665,7 @@ BOOLEAN CmControlResponseMessage(PMINI_ADAPTER Adapter, /* <Pointer to the Adap
DumpCmControlPacket(pstAddIndication);
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "====>");
- pLeader = (PLEADER)Adapter->caDsxReqResp;
+ pLeader = (struct bcm_leader *)Adapter->caDsxReqResp;
pLeader->Status = CM_CONTROL_NEWDSX_MULTICLASSIFIER_REQ;
pLeader->Vcid = 0;
@@ -1915,10 +1902,10 @@ BOOLEAN CmControlResponseMessage(PMINI_ADAPTER Adapter, /* <Pointer to the Adap
return TRUE;
}
-int get_dsx_sf_data_to_application(PMINI_ADAPTER Adapter, UINT uiSFId, void __user *user_buffer)
+int get_dsx_sf_data_to_application(struct bcm_mini_adapter *Adapter, UINT uiSFId, void __user *user_buffer)
{
int status = 0;
- struct _packet_info *psSfInfo = NULL;
+ struct bcm_packet_info *psSfInfo = NULL;
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "status =%d", status);
status = SearchSfid(Adapter, uiSFId);
@@ -1937,7 +1924,7 @@ int get_dsx_sf_data_to_application(PMINI_ADAPTER Adapter, UINT uiSFId, void __us
return STATUS_SUCCESS;
}
-VOID OverrideServiceFlowParams(PMINI_ADAPTER Adapter, PUINT puiBuffer)
+VOID OverrideServiceFlowParams(struct bcm_mini_adapter *Adapter, PUINT puiBuffer)
{
B_UINT32 u32NumofSFsinMsg = ntohl(*(puiBuffer + 1));
stIM_SFHostNotify *pHostInfo = NULL;
diff --git a/drivers/staging/bcm/CmHost.h b/drivers/staging/bcm/CmHost.h
index 8f689769b4ba..4cc6f93f2321 100644
--- a/drivers/staging/bcm/CmHost.h
+++ b/drivers/staging/bcm/CmHost.h
@@ -148,14 +148,14 @@ typedef struct stLocalSFChangeIndicationAlt{
}stLocalSFChangeIndicationAlt;
-ULONG StoreCmControlResponseMessage(PMINI_ADAPTER Adapter,PVOID pvBuffer,UINT *puBufferLength);
+ULONG StoreCmControlResponseMessage(struct bcm_mini_adapter *Adapter, PVOID pvBuffer,UINT *puBufferLength);
-INT AllocAdapterDsxBuffer(PMINI_ADAPTER Adapter);
+INT AllocAdapterDsxBuffer(struct bcm_mini_adapter *Adapter);
-INT FreeAdapterDsxBuffer(PMINI_ADAPTER Adapter);
-ULONG SetUpTargetDsxBuffers(PMINI_ADAPTER Adapter);
+INT FreeAdapterDsxBuffer(struct bcm_mini_adapter *Adapter);
+ULONG SetUpTargetDsxBuffers(struct bcm_mini_adapter *Adapter);
-BOOLEAN CmControlResponseMessage(PMINI_ADAPTER Adapter,PVOID pvBuffer);
+BOOLEAN CmControlResponseMessage(struct bcm_mini_adapter *Adapter, PVOID pvBuffer);
#pragma pack (pop)
diff --git a/drivers/staging/bcm/DDRInit.c b/drivers/staging/bcm/DDRInit.c
index 1c7db81a1ee8..8c696b64ab24 100644
--- a/drivers/staging/bcm/DDRInit.c
+++ b/drivers/staging/bcm/DDRInit.c
@@ -7,7 +7,7 @@
//DDR INIT-133Mhz
#define T3_SKIP_CLOCK_PROGRAM_DUMP_133MHZ 12 //index for 0x0F007000
-static DDR_SET_NODE asT3_DDRSetting133MHz[]= {// # DPLL Clock Setting
+static struct bcm_ddr_setting asT3_DDRSetting133MHz[]= {// # DPLL Clock Setting
{0x0F000800,0x00007212},
{0x0f000820,0x07F13FFF},
{0x0f000810,0x00000F95},
@@ -65,7 +65,7 @@ static DDR_SET_NODE asT3_DDRSetting133MHz[]= {// # DPLL Clock Setting
};
//80Mhz
#define T3_SKIP_CLOCK_PROGRAM_DUMP_80MHZ 10 //index for 0x0F007000
-static DDR_SET_NODE asT3_DDRSetting80MHz[]= {// # DPLL Clock Setting
+static struct bcm_ddr_setting asT3_DDRSetting80MHz[]= {// # DPLL Clock Setting
{0x0f000810,0x00000F95},
{0x0f000820,0x07f1ffff},
{0x0f000860,0x00000000},
@@ -117,7 +117,7 @@ static DDR_SET_NODE asT3_DDRSetting80MHz[]= {// # DPLL Clock Setting
};
//100Mhz
#define T3_SKIP_CLOCK_PROGRAM_DUMP_100MHZ 13 //index for 0x0F007000
-static DDR_SET_NODE asT3_DDRSetting100MHz[]= {// # DPLL Clock Setting
+static struct bcm_ddr_setting asT3_DDRSetting100MHz[]= {// # DPLL Clock Setting
{0x0F000800,0x00007008},
{0x0f000810,0x00000F95},
{0x0f000820,0x07F13E3F},
@@ -177,7 +177,7 @@ static DDR_SET_NODE asT3_DDRSetting100MHz[]= {// # DPLL Clock Setting
//Net T3B DDR Settings
//DDR INIT-133Mhz
-static DDR_SET_NODE asDPLL_266MHZ[] = {
+static struct bcm_ddr_setting asDPLL_266MHZ[] = {
{0x0F000800,0x00007212},
{0x0f000820,0x07F13FFF},
{0x0f000810,0x00000F95},
@@ -189,7 +189,7 @@ static DDR_SET_NODE asDPLL_266MHZ[] = {
};
#define T3B_SKIP_CLOCK_PROGRAM_DUMP_133MHZ 11 //index for 0x0F007000
-static DDR_SET_NODE asT3B_DDRSetting133MHz[] = {// # DPLL Clock Setting
+static struct bcm_ddr_setting asT3B_DDRSetting133MHz[] = {// # DPLL Clock Setting
{0x0f000810,0x00000F95},
{0x0f000810,0x00000F95},
{0x0f000810,0x00000F95},
@@ -247,7 +247,7 @@ static DDR_SET_NODE asT3B_DDRSetting133MHz[] = {// # DPLL Clock Setting
};
#define T3B_SKIP_CLOCK_PROGRAM_DUMP_80MHZ 9 //index for 0x0F007000
-static DDR_SET_NODE asT3B_DDRSetting80MHz[] = {// # DPLL Clock Setting
+static struct bcm_ddr_setting asT3B_DDRSetting80MHz[] = {// # DPLL Clock Setting
{0x0f000810,0x00000F95},
{0x0f000820,0x07F13FFF},
{0x0f000840,0x0FFF1F00},
@@ -301,7 +301,7 @@ static DDR_SET_NODE asT3B_DDRSetting80MHz[] = {// # DPLL Clock Setting
//100Mhz
#define T3B_SKIP_CLOCK_PROGRAM_DUMP_100MHZ 9 //index for 0x0F007000
-static DDR_SET_NODE asT3B_DDRSetting100MHz[] = {// # DPLL Clock Setting
+static struct bcm_ddr_setting asT3B_DDRSetting100MHz[] = {// # DPLL Clock Setting
{0x0f000810,0x00000F95},
{0x0f000820,0x07F1369B},
{0x0f000840,0x0FFF0800},
@@ -356,7 +356,7 @@ static DDR_SET_NODE asT3B_DDRSetting100MHz[] = {// # DPLL Clock Setting
#define T3LP_SKIP_CLOCK_PROGRAM_DUMP_133MHZ 9 //index for 0x0F007000
-static DDR_SET_NODE asT3LP_DDRSetting133MHz[]= {// # DPLL Clock Setting
+static struct bcm_ddr_setting asT3LP_DDRSetting133MHz[]= {// # DPLL Clock Setting
{0x0f000820,0x03F1365B},
{0x0f000810,0x00002F95},
{0x0f000880,0x000003DD},
@@ -416,7 +416,7 @@ static DDR_SET_NODE asT3LP_DDRSetting133MHz[]= {// # DPLL Clock Setting
};
#define T3LP_SKIP_CLOCK_PROGRAM_DUMP_100MHZ 11 //index for 0x0F007000
-static DDR_SET_NODE asT3LP_DDRSetting100MHz[]= {// # DPLL Clock Setting
+static struct bcm_ddr_setting asT3LP_DDRSetting100MHz[]= {// # DPLL Clock Setting
{0x0f000810,0x00002F95},
{0x0f000820,0x03F1369B},
{0x0f000840,0x0fff0000},
@@ -476,7 +476,7 @@ static DDR_SET_NODE asT3LP_DDRSetting100MHz[]= {// # DPLL Clock Setting
};
#define T3LP_SKIP_CLOCK_PROGRAM_DUMP_80MHZ 9 //index for 0x0F007000
-static DDR_SET_NODE asT3LP_DDRSetting80MHz[]= {// # DPLL Clock Setting
+static struct bcm_ddr_setting asT3LP_DDRSetting80MHz[]= {// # DPLL Clock Setting
{0x0f000820,0x07F13FFF},
{0x0f000810,0x00002F95},
{0x0f000860,0x00000000},
@@ -536,7 +536,7 @@ static DDR_SET_NODE asT3LP_DDRSetting80MHz[]= {// # DPLL Clock Setting
///T3 LP-B (UMA-B)
#define T3LPB_SKIP_CLOCK_PROGRAM_DUMP_160MHZ 7 //index for 0x0F007000
-static DDR_SET_NODE asT3LPB_DDRSetting160MHz[]= {// # DPLL Clock Setting
+static struct bcm_ddr_setting asT3LPB_DDRSetting160MHz[]= {// # DPLL Clock Setting
{0x0f000820,0x03F137DB},
{0x0f000810,0x01842795},
@@ -594,7 +594,7 @@ static DDR_SET_NODE asT3LPB_DDRSetting160MHz[]= {// # DPLL Clock Setting
#define T3LPB_SKIP_CLOCK_PROGRAM_DUMP_133MHZ 7 //index for 0x0F007000
-static DDR_SET_NODE asT3LPB_DDRSetting133MHz[]= {// # DPLL Clock Setting
+static struct bcm_ddr_setting asT3LPB_DDRSetting133MHz[]= {// # DPLL Clock Setting
{0x0f000820,0x03F1365B},
{0x0f000810,0x00002F95},
{0x0f000880,0x000003DD},
@@ -655,7 +655,7 @@ static DDR_SET_NODE asT3LPB_DDRSetting133MHz[]= {// # DPLL Clock Setting
};
#define T3LPB_SKIP_CLOCK_PROGRAM_DUMP_100MHZ 8 //index for 0x0F007000
-static DDR_SET_NODE asT3LPB_DDRSetting100MHz[]= {// # DPLL Clock Setting
+static struct bcm_ddr_setting asT3LPB_DDRSetting100MHz[]= {// # DPLL Clock Setting
{0x0f000810,0x00002F95},
{0x0f000820,0x03F1369B},
{0x0f000840,0x0fff0000},
@@ -716,7 +716,7 @@ static DDR_SET_NODE asT3LPB_DDRSetting100MHz[]= {// # DPLL Clock Setting
};
#define T3LPB_SKIP_CLOCK_PROGRAM_DUMP_80MHZ 7 //index for 0x0F007000
-static DDR_SET_NODE asT3LPB_DDRSetting80MHz[]= {// # DPLL Clock Setting
+static struct bcm_ddr_setting asT3LPB_DDRSetting80MHz[]= {// # DPLL Clock Setting
{0x0f000820,0x07F13FFF},
{0x0f000810,0x00002F95},
{0x0f000860,0x00000000},
@@ -772,9 +772,9 @@ static DDR_SET_NODE asT3LPB_DDRSetting80MHz[]= {// # DPLL Clock Setting
};
-int ddr_init(MINI_ADAPTER *Adapter)
+int ddr_init(struct bcm_mini_adapter *Adapter)
{
- PDDR_SETTING psDDRSetting=NULL;
+ struct bcm_ddr_setting *psDDRSetting=NULL;
ULONG RegCount=0;
UINT value = 0;
UINT uiResetValue = 0;
@@ -789,17 +789,17 @@ int ddr_init(MINI_ADAPTER *Adapter)
case DDR_80_MHZ:
psDDRSetting=asT3LP_DDRSetting80MHz;
RegCount=(sizeof(asT3LP_DDRSetting80MHz)/
- sizeof(DDR_SETTING));
+ sizeof(struct bcm_ddr_setting));
break;
case DDR_100_MHZ:
psDDRSetting=asT3LP_DDRSetting100MHz;
RegCount=(sizeof(asT3LP_DDRSetting100MHz)/
- sizeof(DDR_SETTING));
+ sizeof(struct bcm_ddr_setting));
break;
case DDR_133_MHZ:
psDDRSetting=asT3LP_DDRSetting133MHz;
RegCount=(sizeof(asT3LP_DDRSetting133MHz)/
- sizeof(DDR_SETTING));
+ sizeof(struct bcm_ddr_setting));
if(Adapter->bMipsConfig == MIPS_200_MHZ)
{
uiClockSetting = 0x03F13652;
@@ -846,17 +846,17 @@ int ddr_init(MINI_ADAPTER *Adapter)
case DDR_80_MHZ:
psDDRSetting = asT3LPB_DDRSetting80MHz;
RegCount=(sizeof(asT3B_DDRSetting80MHz)/
- sizeof(DDR_SETTING));
+ sizeof(struct bcm_ddr_setting));
break;
case DDR_100_MHZ:
psDDRSetting=asT3LPB_DDRSetting100MHz;
RegCount=(sizeof(asT3B_DDRSetting100MHz)/
- sizeof(DDR_SETTING));
+ sizeof(struct bcm_ddr_setting));
break;
case DDR_133_MHZ:
psDDRSetting = asT3LPB_DDRSetting133MHz;
RegCount=(sizeof(asT3B_DDRSetting133MHz)/
- sizeof(DDR_SETTING));
+ sizeof(struct bcm_ddr_setting));
if(Adapter->bMipsConfig == MIPS_200_MHZ)
{
@@ -870,7 +870,7 @@ int ddr_init(MINI_ADAPTER *Adapter)
case DDR_160_MHZ:
psDDRSetting = asT3LPB_DDRSetting160MHz;
- RegCount = sizeof(asT3LPB_DDRSetting160MHz)/sizeof(DDR_SETTING);
+ RegCount = sizeof(asT3LPB_DDRSetting160MHz)/sizeof(struct bcm_ddr_setting);
if(Adapter->bMipsConfig == MIPS_200_MHZ)
{
@@ -894,17 +894,17 @@ int ddr_init(MINI_ADAPTER *Adapter)
case DDR_80_MHZ:
psDDRSetting = asT3_DDRSetting80MHz;
RegCount = (sizeof(asT3_DDRSetting80MHz)/
- sizeof(DDR_SETTING));
+ sizeof(struct bcm_ddr_setting));
break;
case DDR_100_MHZ:
psDDRSetting = asT3_DDRSetting100MHz;
RegCount = (sizeof(asT3_DDRSetting100MHz)/
- sizeof(DDR_SETTING));
+ sizeof(struct bcm_ddr_setting));
break;
case DDR_133_MHZ:
psDDRSetting = asT3_DDRSetting133MHz;
RegCount = (sizeof(asT3_DDRSetting133MHz)/
- sizeof(DDR_SETTING));
+ sizeof(struct bcm_ddr_setting));
break;
default:
return -EINVAL;
@@ -916,12 +916,12 @@ int ddr_init(MINI_ADAPTER *Adapter)
case DDR_80_MHZ:
psDDRSetting = asT3B_DDRSetting80MHz;
RegCount=(sizeof(asT3B_DDRSetting80MHz)/
- sizeof(DDR_SETTING));
+ sizeof(struct bcm_ddr_setting));
break;
case DDR_100_MHZ:
psDDRSetting=asT3B_DDRSetting100MHz;
RegCount=(sizeof(asT3B_DDRSetting100MHz)/
- sizeof(DDR_SETTING));
+ sizeof(struct bcm_ddr_setting));
break;
case DDR_133_MHZ:
@@ -931,13 +931,13 @@ int ddr_init(MINI_ADAPTER *Adapter)
sizeof(asDPLL_266MHZ));
psDDRSetting = asT3B_DDRSetting133MHz;
RegCount=(sizeof(asT3B_DDRSetting133MHz)/
- sizeof(DDR_SETTING));
+ sizeof(struct bcm_ddr_setting));
}
else
{
psDDRSetting = asT3B_DDRSetting133MHz;
RegCount=(sizeof(asT3B_DDRSetting133MHz)/
- sizeof(DDR_SETTING));
+ sizeof(struct bcm_ddr_setting));
if(Adapter->bMipsConfig == MIPS_200_MHZ)
{
uiClockSetting = 0x07F13652;
@@ -1099,9 +1099,9 @@ int ddr_init(MINI_ADAPTER *Adapter)
return retval;
}
-int download_ddr_settings(PMINI_ADAPTER Adapter)
+int download_ddr_settings(struct bcm_mini_adapter *Adapter)
{
- PDDR_SET_NODE psDDRSetting=NULL;
+ struct bcm_ddr_setting *psDDRSetting=NULL;
ULONG RegCount=0;
unsigned long ul_ddr_setting_load_addr = DDR_DUMP_INTERNAL_DEVICE_MEMORY;
UINT value = 0;
@@ -1115,20 +1115,20 @@ int download_ddr_settings(PMINI_ADAPTER Adapter)
{
case DDR_80_MHZ:
psDDRSetting = asT3LP_DDRSetting80MHz;
- RegCount = (sizeof(asT3LP_DDRSetting80MHz)/sizeof(DDR_SET_NODE));
+ RegCount = ARRAY_SIZE(asT3LP_DDRSetting80MHz);
RegCount -= T3LP_SKIP_CLOCK_PROGRAM_DUMP_80MHZ ;
psDDRSetting += T3LP_SKIP_CLOCK_PROGRAM_DUMP_80MHZ;
break;
case DDR_100_MHZ:
psDDRSetting = asT3LP_DDRSetting100MHz;
- RegCount = (sizeof(asT3LP_DDRSetting100MHz)/sizeof(DDR_SET_NODE));
+ RegCount = ARRAY_SIZE(asT3LP_DDRSetting100MHz);
RegCount -= T3LP_SKIP_CLOCK_PROGRAM_DUMP_100MHZ ;
psDDRSetting += T3LP_SKIP_CLOCK_PROGRAM_DUMP_100MHZ;
break;
case DDR_133_MHZ:
bOverrideSelfRefresh = TRUE;
psDDRSetting = asT3LP_DDRSetting133MHz;
- RegCount = (sizeof(asT3LP_DDRSetting133MHz)/sizeof(DDR_SET_NODE));
+ RegCount = ARRAY_SIZE(asT3LP_DDRSetting133MHz);
RegCount -= T3LP_SKIP_CLOCK_PROGRAM_DUMP_133MHZ ;
psDDRSetting += T3LP_SKIP_CLOCK_PROGRAM_DUMP_133MHZ;
break;
@@ -1146,20 +1146,20 @@ int download_ddr_settings(PMINI_ADAPTER Adapter)
{
case DDR_80_MHZ:
psDDRSetting = asT3LPB_DDRSetting80MHz;
- RegCount=(sizeof(asT3LPB_DDRSetting80MHz)/sizeof(DDR_SET_NODE));
+ RegCount=ARRAY_SIZE(asT3LPB_DDRSetting80MHz);
RegCount -= T3LPB_SKIP_CLOCK_PROGRAM_DUMP_80MHZ ;
psDDRSetting += T3LPB_SKIP_CLOCK_PROGRAM_DUMP_80MHZ;
break;
case DDR_100_MHZ:
psDDRSetting = asT3LPB_DDRSetting100MHz;
- RegCount = (sizeof(asT3LPB_DDRSetting100MHz)/sizeof(DDR_SET_NODE));
+ RegCount = ARRAY_SIZE(asT3LPB_DDRSetting100MHz);
RegCount -= T3LPB_SKIP_CLOCK_PROGRAM_DUMP_100MHZ ;
psDDRSetting += T3LPB_SKIP_CLOCK_PROGRAM_DUMP_100MHZ;
break;
case DDR_133_MHZ:
bOverrideSelfRefresh = TRUE;
psDDRSetting = asT3LPB_DDRSetting133MHz;
- RegCount = (sizeof(asT3LPB_DDRSetting133MHz)/sizeof(DDR_SET_NODE));
+ RegCount = ARRAY_SIZE(asT3LPB_DDRSetting133MHz);
RegCount -= T3LPB_SKIP_CLOCK_PROGRAM_DUMP_133MHZ ;
psDDRSetting += T3LPB_SKIP_CLOCK_PROGRAM_DUMP_133MHZ;
break;
@@ -1167,7 +1167,7 @@ int download_ddr_settings(PMINI_ADAPTER Adapter)
case DDR_160_MHZ:
bOverrideSelfRefresh = TRUE;
psDDRSetting = asT3LPB_DDRSetting160MHz;
- RegCount = sizeof(asT3LPB_DDRSetting160MHz)/sizeof(DDR_SET_NODE);
+ RegCount = ARRAY_SIZE(asT3LPB_DDRSetting160MHz);
RegCount -= T3LPB_SKIP_CLOCK_PROGRAM_DUMP_160MHZ;
psDDRSetting += T3LPB_SKIP_CLOCK_PROGRAM_DUMP_160MHZ;
@@ -1181,19 +1181,19 @@ int download_ddr_settings(PMINI_ADAPTER Adapter)
{
case DDR_80_MHZ:
psDDRSetting = asT3_DDRSetting80MHz;
- RegCount = (sizeof(asT3_DDRSetting80MHz)/sizeof(DDR_SET_NODE));
+ RegCount = ARRAY_SIZE(asT3_DDRSetting80MHz);
RegCount-=T3_SKIP_CLOCK_PROGRAM_DUMP_80MHZ ;
psDDRSetting += T3_SKIP_CLOCK_PROGRAM_DUMP_80MHZ;
break;
case DDR_100_MHZ:
psDDRSetting = asT3_DDRSetting100MHz;
- RegCount = (sizeof(asT3_DDRSetting100MHz)/sizeof(DDR_SET_NODE));
+ RegCount = ARRAY_SIZE(asT3_DDRSetting100MHz);
RegCount-=T3_SKIP_CLOCK_PROGRAM_DUMP_100MHZ ;
psDDRSetting += T3_SKIP_CLOCK_PROGRAM_DUMP_100MHZ;
break;
case DDR_133_MHZ:
psDDRSetting = asT3_DDRSetting133MHz;
- RegCount = (sizeof(asT3_DDRSetting133MHz)/sizeof(DDR_SET_NODE));
+ RegCount = ARRAY_SIZE(asT3_DDRSetting133MHz);
RegCount-=T3_SKIP_CLOCK_PROGRAM_DUMP_133MHZ ;
psDDRSetting += T3_SKIP_CLOCK_PROGRAM_DUMP_133MHZ ;
break;
@@ -1207,20 +1207,20 @@ int download_ddr_settings(PMINI_ADAPTER Adapter)
{
case DDR_80_MHZ:
psDDRSetting = asT3B_DDRSetting80MHz;
- RegCount = (sizeof(asT3B_DDRSetting80MHz)/sizeof(DDR_SET_NODE));
+ RegCount = ARRAY_SIZE(asT3B_DDRSetting80MHz);
RegCount -= T3B_SKIP_CLOCK_PROGRAM_DUMP_80MHZ ;
psDDRSetting += T3B_SKIP_CLOCK_PROGRAM_DUMP_80MHZ;
break;
case DDR_100_MHZ:
psDDRSetting = asT3B_DDRSetting100MHz;
- RegCount = (sizeof(asT3B_DDRSetting100MHz)/sizeof(DDR_SET_NODE));
+ RegCount = ARRAY_SIZE(asT3B_DDRSetting100MHz);
RegCount -= T3B_SKIP_CLOCK_PROGRAM_DUMP_100MHZ ;
psDDRSetting += T3B_SKIP_CLOCK_PROGRAM_DUMP_100MHZ;
break;
case DDR_133_MHZ:
bOverrideSelfRefresh = TRUE;
psDDRSetting = asT3B_DDRSetting133MHz;
- RegCount = (sizeof(asT3B_DDRSetting133MHz)/sizeof(DDR_SET_NODE));
+ RegCount = ARRAY_SIZE(asT3B_DDRSetting133MHz);
RegCount -= T3B_SKIP_CLOCK_PROGRAM_DUMP_133MHZ ;
psDDRSetting += T3B_SKIP_CLOCK_PROGRAM_DUMP_133MHZ;
break;
@@ -1250,7 +1250,7 @@ int download_ddr_settings(PMINI_ADAPTER Adapter)
}
ul_ddr_setting_load_addr+=sizeof(ULONG);
- RegCount*=(sizeof(DDR_SETTING)/sizeof(ULONG));
+ RegCount*=(sizeof(struct bcm_ddr_setting)/sizeof(ULONG));
while(RegCount && !retval)
{
diff --git a/drivers/staging/bcm/DDRInit.h b/drivers/staging/bcm/DDRInit.h
index 550e260df539..b0196fce9255 100644
--- a/drivers/staging/bcm/DDRInit.h
+++ b/drivers/staging/bcm/DDRInit.h
@@ -3,7 +3,7 @@
-int ddr_init(PMINI_ADAPTER psAdapter);
-int download_ddr_settings(PMINI_ADAPTER psAdapter);
+int ddr_init(struct bcm_mini_adapter *psAdapter);
+int download_ddr_settings(struct bcm_mini_adapter *psAdapter);
#endif
diff --git a/drivers/staging/bcm/Debug.h b/drivers/staging/bcm/Debug.h
index 420382d1cacf..8018a189f817 100644
--- a/drivers/staging/bcm/Debug.h
+++ b/drivers/staging/bcm/Debug.h
@@ -42,10 +42,6 @@
#define ARP_REQ (TX<<5)
#define ARP_RESP (TX<<6)
-// dhcp.c
-//#define DHCP TX
-//#define DHCP_REQ (DHCP<<7)
-
// Leakybucket.c
#define TOKEN_COUNTS (TX<<8)
#define CHECK_TOKENS (TX<<9)
@@ -147,7 +143,6 @@ DriverEntry.c, bcmfwup.c, ChipDetectTask.c, HaltnReset.c, InterfaceDDR.c */
#define HOST_MIBS (OTHERS << 28)
#define CONN_MSG (CMHOST << 29)
-//#define OTHERS_MISC (OTHERS << 29) // ProcSupport.c
/*-----------------END SUBTYPEs------------------------------------------*/
diff --git a/drivers/staging/bcm/HandleControlPacket.c b/drivers/staging/bcm/HandleControlPacket.c
index b058e30b2ca6..25e5c68bfe85 100644
--- a/drivers/staging/bcm/HandleControlPacket.c
+++ b/drivers/staging/bcm/HandleControlPacket.c
@@ -11,9 +11,9 @@
* Enqueue the control packet for Application.
* @return None
*/
-static VOID handle_rx_control_packet(PMINI_ADAPTER Adapter, struct sk_buff *skb)
+static VOID handle_rx_control_packet(struct bcm_mini_adapter *Adapter, struct sk_buff *skb)
{
- PPER_TARANG_DATA pTarang = NULL;
+ struct bcm_tarang_data *pTarang = NULL;
BOOLEAN HighPriorityMessage = FALSE;
struct sk_buff *newPacket = NULL;
CHAR cntrl_msg_mask_bit = 0;
@@ -154,7 +154,7 @@ static VOID handle_rx_control_packet(PMINI_ADAPTER Adapter, struct sk_buff *skb)
* @ingroup ctrl_pkt_functions
* Thread to handle control pkt reception
*/
-int control_packet_handler(PMINI_ADAPTER Adapter /* pointer to adapter object*/)
+int control_packet_handler(struct bcm_mini_adapter *Adapter /* pointer to adapter object*/)
{
struct sk_buff *ctrl_packet = NULL;
unsigned long flags = 0;
@@ -213,8 +213,8 @@ int control_packet_handler(PMINI_ADAPTER Adapter /* pointer to adapter object*/)
INT flushAllAppQ(void)
{
- PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev);
- PPER_TARANG_DATA pTarang = NULL;
+ struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev);
+ struct bcm_tarang_data *pTarang = NULL;
struct sk_buff *PacketToDrop = NULL;
for (pTarang = Adapter->pTarangs; pTarang; pTarang = pTarang->next) {
while (pTarang->RxAppControlHead != NULL) {
diff --git a/drivers/staging/bcm/IPv6Protocol.c b/drivers/staging/bcm/IPv6Protocol.c
index 5b4fd372ec36..4745ddd62f5b 100644
--- a/drivers/staging/bcm/IPv6Protocol.c
+++ b/drivers/staging/bcm/IPv6Protocol.c
@@ -1,51 +1,52 @@
#include "headers.h"
-static BOOLEAN MatchSrcIpv6Address(S_CLASSIFIER_RULE *pstClassifierRule,IPV6Header *pstIpv6Header);
-static BOOLEAN MatchDestIpv6Address(S_CLASSIFIER_RULE *pstClassifierRule,IPV6Header *pstIpv6Header);
+static BOOLEAN MatchSrcIpv6Address(struct bcm_classifier_rule *pstClassifierRule,
+ IPV6Header *pstIpv6Header);
+static BOOLEAN MatchDestIpv6Address(struct bcm_classifier_rule *pstClassifierRule,
+ IPV6Header *pstIpv6Header);
static VOID DumpIpv6Header(IPV6Header *pstIpv6Header);
-static UCHAR * GetNextIPV6ChainedHeader(UCHAR **ppucPayload,UCHAR *pucNextHeader,BOOLEAN *bParseDone,USHORT *pusPayloadLength)
+static UCHAR *GetNextIPV6ChainedHeader(UCHAR **ppucPayload,
+ UCHAR *pucNextHeader, BOOLEAN *bParseDone, USHORT *pusPayloadLength)
{
UCHAR *pucRetHeaderPtr = NULL;
UCHAR *pucPayloadPtr = NULL;
USHORT usNextHeaderOffset = 0 ;
- PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev);
+ struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev);
- if((NULL == ppucPayload) || (*pusPayloadLength == 0) || (*bParseDone))
- {
+ if ((ppucPayload == NULL) || (*pusPayloadLength == 0) ||
+ (*bParseDone)) {
*bParseDone = TRUE;
return NULL;
-
}
pucRetHeaderPtr = *ppucPayload;
pucPayloadPtr = *ppucPayload;
- if(!pucRetHeaderPtr || !pucPayloadPtr)
- {
+ if (!pucRetHeaderPtr || !pucPayloadPtr) {
*bParseDone = TRUE;
return NULL;
}
- //Get the Nextt Header Type
+ /* Get the Nextt Header Type */
*bParseDone = FALSE;
-
- switch(*pucNextHeader)
- {
+ switch (*pucNextHeader) {
case IPV6HDR_TYPE_HOPBYHOP:
{
- BCM_DEBUG_PRINT( Adapter,DBG_TYPE_TX, IPV6_DBG, DBG_LVL_ALL, "\nIPv6 HopByHop Header");
- usNextHeaderOffset+=sizeof(IPV6HopByHopOptionsHeader);
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV6_DBG,
+ DBG_LVL_ALL, "\nIPv6 HopByHop Header");
+ usNextHeaderOffset += sizeof(IPV6HopByHopOptionsHeader);
}
break;
case IPV6HDR_TYPE_ROUTING:
{
IPV6RoutingHeader *pstIpv6RoutingHeader;
- BCM_DEBUG_PRINT( Adapter,DBG_TYPE_TX, IPV6_DBG, DBG_LVL_ALL, "\nIPv6 Routing Header");
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV6_DBG,
+ DBG_LVL_ALL, "\nIPv6 Routing Header");
pstIpv6RoutingHeader = (IPV6RoutingHeader *)pucPayloadPtr;
usNextHeaderOffset += sizeof(IPV6RoutingHeader);
usNextHeaderOffset += pstIpv6RoutingHeader->ucNumAddresses * IPV6_ADDRESS_SIZEINBYTES;
@@ -54,8 +55,10 @@ static UCHAR * GetNextIPV6ChainedHeader(UCHAR **ppucPayload,UCHAR *pucNextHeader
break;
case IPV6HDR_TYPE_FRAGMENTATION:
{
- BCM_DEBUG_PRINT( Adapter,DBG_TYPE_TX, IPV6_DBG, DBG_LVL_ALL, "\nIPv6 Fragmentation Header");
- usNextHeaderOffset+= sizeof(IPV6FragmentHeader);
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV6_DBG,
+ DBG_LVL_ALL,
+ "\nIPv6 Fragmentation Header");
+ usNextHeaderOffset += sizeof(IPV6FragmentHeader);
}
break;
@@ -63,9 +66,11 @@ static UCHAR * GetNextIPV6ChainedHeader(UCHAR **ppucPayload,UCHAR *pucNextHeader
{
IPV6DestOptionsHeader *pstIpv6DestOptsHdr = (IPV6DestOptionsHeader *)pucPayloadPtr;
int nTotalOptions = pstIpv6DestOptsHdr->ucHdrExtLen;
- BCM_DEBUG_PRINT( Adapter,DBG_TYPE_TX, IPV6_DBG, DBG_LVL_ALL, "\nIPv6 DestOpts Header Header");
- usNextHeaderOffset+= sizeof(IPV6DestOptionsHeader);
- usNextHeaderOffset+= nTotalOptions * IPV6_DESTOPTS_HDR_OPTIONSIZE ;
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV6_DBG,
+ DBG_LVL_ALL,
+ "\nIPv6 DestOpts Header Header");
+ usNextHeaderOffset += sizeof(IPV6DestOptionsHeader);
+ usNextHeaderOffset += nTotalOptions * IPV6_DESTOPTS_HDR_OPTIONSIZE ;
}
break;
@@ -73,36 +78,43 @@ static UCHAR * GetNextIPV6ChainedHeader(UCHAR **ppucPayload,UCHAR *pucNextHeader
{
IPV6AuthenticationHeader *pstIpv6AuthHdr = (IPV6AuthenticationHeader *)pucPayloadPtr;
int nHdrLen = pstIpv6AuthHdr->ucLength;
- BCM_DEBUG_PRINT( Adapter,DBG_TYPE_TX, IPV6_DBG, DBG_LVL_ALL, "\nIPv6 Authentication Header");
- usNextHeaderOffset+= nHdrLen * 4;
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV6_DBG,
+ DBG_LVL_ALL,
+ "\nIPv6 Authentication Header");
+ usNextHeaderOffset += nHdrLen * 4;
}
break;
case IPV6HDR_TYPE_ENCRYPTEDSECURITYPAYLOAD:
{
- BCM_DEBUG_PRINT( Adapter,DBG_TYPE_TX, IPV6_DBG, DBG_LVL_ALL, "\nIPv6 Encrypted Security Payload Header");
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV6_DBG,
+ DBG_LVL_ALL,
+ "\nIPv6 Encrypted Security Payload Header");
*bParseDone = TRUE;
}
break;
case IPV6_ICMP_HDR_TYPE:
{
- BCM_DEBUG_PRINT( Adapter,DBG_TYPE_TX, IPV6_DBG, DBG_LVL_ALL, " ICMP Header");
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV6_DBG,
+ DBG_LVL_ALL, "\nICMP Header");
*bParseDone = TRUE;
}
break;
case TCP_HEADER_TYPE:
{
- BCM_DEBUG_PRINT( Adapter,DBG_TYPE_TX, IPV6_DBG, DBG_LVL_ALL, " \nTCP Header");
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV6_DBG,
+ DBG_LVL_ALL, "\nTCP Header");
*bParseDone = TRUE;
}
break;
case UDP_HEADER_TYPE:
{
- BCM_DEBUG_PRINT( Adapter,DBG_TYPE_TX, IPV6_DBG, DBG_LVL_ALL, " \nUDP Header");
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV6_DBG,
+ DBG_LVL_ALL, "\nUDP Header");
*bParseDone = TRUE;
}
break;
- default :
+ default:
{
*bParseDone = TRUE;
@@ -112,53 +124,49 @@ static UCHAR * GetNextIPV6ChainedHeader(UCHAR **ppucPayload,UCHAR *pucNextHeader
}
- if(*bParseDone == FALSE)
- {
- if(*pusPayloadLength <= usNextHeaderOffset)
- {
+ if (*bParseDone == FALSE) {
+ if (*pusPayloadLength <= usNextHeaderOffset) {
*bParseDone = TRUE;
- }
- else
- {
+ } else {
*pucNextHeader = *pucPayloadPtr;
- pucPayloadPtr+=usNextHeaderOffset;
- (*pusPayloadLength)-=usNextHeaderOffset;
+ pucPayloadPtr += usNextHeaderOffset;
+ (*pusPayloadLength) -= usNextHeaderOffset;
}
}
-
-
*ppucPayload = pucPayloadPtr;
return pucRetHeaderPtr;
}
-static UCHAR GetIpv6ProtocolPorts(UCHAR *pucPayload,USHORT *pusSrcPort,USHORT *pusDestPort,USHORT usPayloadLength,UCHAR ucNextHeader)
+static UCHAR GetIpv6ProtocolPorts(UCHAR *pucPayload, USHORT *pusSrcPort,
+ USHORT *pusDestPort, USHORT usPayloadLength, UCHAR ucNextHeader)
{
UCHAR *pIpv6HdrScanContext = pucPayload;
BOOLEAN bDone = FALSE;
- UCHAR ucHeaderType =0;
+ UCHAR ucHeaderType = 0;
UCHAR *pucNextHeader = NULL;
- PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev);
+ struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev);
- if( !pucPayload || (usPayloadLength == 0))
- {
+ if (!pucPayload || (usPayloadLength == 0))
return 0;
- }
*pusSrcPort = *pusDestPort = 0;
ucHeaderType = ucNextHeader;
- while(!bDone)
- {
- pucNextHeader = GetNextIPV6ChainedHeader(&pIpv6HdrScanContext,&ucHeaderType,&bDone,&usPayloadLength);
- if(bDone)
- {
- if((ucHeaderType==TCP_HEADER_TYPE) || (ucHeaderType == UDP_HEADER_TYPE))
- {
- *pusSrcPort=*((PUSHORT)(pucNextHeader));
- *pusDestPort=*((PUSHORT)(pucNextHeader+2));
- BCM_DEBUG_PRINT( Adapter,DBG_TYPE_TX, IPV6_DBG, DBG_LVL_ALL, " \nProtocol Ports - Src Port :0x%x Dest Port : 0x%x",ntohs(*pusSrcPort),ntohs(*pusDestPort));
+ while (!bDone) {
+ pucNextHeader = GetNextIPV6ChainedHeader(&pIpv6HdrScanContext,
+ &ucHeaderType, &bDone, &usPayloadLength);
+ if (bDone) {
+ if ((ucHeaderType == TCP_HEADER_TYPE) ||
+ (ucHeaderType == UDP_HEADER_TYPE)) {
+ *pusSrcPort = *((PUSHORT)(pucNextHeader));
+ *pusDestPort = *((PUSHORT)(pucNextHeader+2));
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV6_DBG,
+ DBG_LVL_ALL,
+ "\nProtocol Ports - Src Port :0x%x Dest Port : 0x%x",
+ ntohs(*pusSrcPort),
+ ntohs(*pusDestPort));
}
break;
@@ -168,92 +176,111 @@ static UCHAR GetIpv6ProtocolPorts(UCHAR *pucPayload,USHORT *pusSrcPort,USHORT *p
}
-
-USHORT IpVersion6(PMINI_ADAPTER Adapter, /**< Pointer to the driver control structure */
- PVOID pcIpHeader, /**<Pointer to the IP Hdr of the packet*/
- S_CLASSIFIER_RULE *pstClassifierRule )
+/*
+ * Arg 1 struct bcm_mini_adapter *Adapter is a pointer ot the driver contorl structure
+ * Arg 2 PVOID pcIpHeader is a pointer to the IP header of the packet
+ */
+USHORT IpVersion6(struct bcm_mini_adapter *Adapter, PVOID pcIpHeader,
+ struct bcm_classifier_rule *pstClassifierRule)
{
USHORT ushDestPort = 0;
USHORT ushSrcPort = 0;
- UCHAR ucNextProtocolAboveIP =0;
+ UCHAR ucNextProtocolAboveIP = 0;
IPV6Header *pstIpv6Header = NULL;
BOOLEAN bClassificationSucceed = FALSE;
- BCM_DEBUG_PRINT( Adapter,DBG_TYPE_TX, IPV6_DBG, DBG_LVL_ALL, "IpVersion6 ==========>\n");
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV6_DBG,
+ DBG_LVL_ALL, "IpVersion6 ==========>\n");
pstIpv6Header = (IPV6Header *)pcIpHeader;
DumpIpv6Header(pstIpv6Header);
- //Try to get the next higher layer protocol and the Ports Nos if TCP or UDP
+ /*
+ * Try to get the next higher layer protocol
+ * and the Ports Nos if TCP or UDP
+ */
ucNextProtocolAboveIP = GetIpv6ProtocolPorts((UCHAR *)(pcIpHeader + sizeof(IPV6Header)),
&ushSrcPort,
&ushDestPort,
pstIpv6Header->usPayloadLength,
pstIpv6Header->ucNextHeader);
- do
- {
- if(0 == pstClassifierRule->ucDirection)
- {
- //cannot be processed for classification.
- // it is a down link connection
+ do {
+ if (pstClassifierRule->ucDirection == 0) {
+ /*
+ * cannot be processed for classification.
+ * it is a down link connection
+ */
break;
}
- if(!pstClassifierRule->bIpv6Protocol)
- {
- //We are looking for Ipv6 Classifiers . Lets ignore this classifier and try the next one.
+ if (!pstClassifierRule->bIpv6Protocol) {
+ /*
+ * We are looking for Ipv6 Classifiers
+ * Lets ignore this classifier and try the next one
+ */
break;
}
- bClassificationSucceed=MatchSrcIpv6Address(pstClassifierRule,pstIpv6Header);
- if(!bClassificationSucceed)
- break;
+ bClassificationSucceed = MatchSrcIpv6Address(pstClassifierRule,
+ pstIpv6Header);
+ if (!bClassificationSucceed)
+ break;
- bClassificationSucceed=MatchDestIpv6Address(pstClassifierRule,pstIpv6Header);
- if(!bClassificationSucceed)
- break;
+ bClassificationSucceed = MatchDestIpv6Address(pstClassifierRule,
+ pstIpv6Header);
+ if (!bClassificationSucceed)
+ break;
- //Match the protocol type.For IPv6 the next protocol at end of Chain of IPv6 prot headers
- bClassificationSucceed=MatchProtocol(pstClassifierRule,ucNextProtocolAboveIP);
- if(!bClassificationSucceed)
- break;
- BCM_DEBUG_PRINT( Adapter,DBG_TYPE_TX, IPV6_DBG, DBG_LVL_ALL, "\nIPv6 Protocol Matched");
+ /*
+ * Match the protocol type.
+ * For IPv6 the next protocol at end of
+ * Chain of IPv6 prot headers
+ */
+ bClassificationSucceed = MatchProtocol(pstClassifierRule,
+ ucNextProtocolAboveIP);
+ if (!bClassificationSucceed)
+ break;
- if((ucNextProtocolAboveIP == TCP_HEADER_TYPE) || (ucNextProtocolAboveIP == UDP_HEADER_TYPE))
- {
- //Match Src Port
- BCM_DEBUG_PRINT( Adapter,DBG_TYPE_TX, IPV6_DBG, DBG_LVL_ALL, "\nIPv6 Source Port:%x\n",ntohs(ushSrcPort));
- bClassificationSucceed=MatchSrcPort(pstClassifierRule,ntohs(ushSrcPort));
- if(!bClassificationSucceed)
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV6_DBG,
+ DBG_LVL_ALL, "\nIPv6 Protocol Matched");
+
+ if ((ucNextProtocolAboveIP == TCP_HEADER_TYPE) ||
+ (ucNextProtocolAboveIP == UDP_HEADER_TYPE)) {
+ /* Match Src Port */
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV6_DBG,
+ DBG_LVL_ALL, "\nIPv6 Source Port:%x\n",
+ ntohs(ushSrcPort));
+ bClassificationSucceed = MatchSrcPort(pstClassifierRule,
+ ntohs(ushSrcPort));
+ if (!bClassificationSucceed)
break;
- BCM_DEBUG_PRINT( Adapter,DBG_TYPE_TX, IPV6_DBG, DBG_LVL_ALL, "\nIPv6 Src Port Matched");
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV6_DBG,
+ DBG_LVL_ALL, "\nIPv6 Src Port Matched");
- //Match Dest Port
- BCM_DEBUG_PRINT( Adapter,DBG_TYPE_TX, IPV6_DBG, DBG_LVL_ALL, "\nIPv6 Destination Port:%x\n",ntohs(ushDestPort));
- bClassificationSucceed=MatchDestPort(pstClassifierRule,ntohs(ushDestPort));
- if(!bClassificationSucceed)
+ /* Match Dest Port */
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV6_DBG,
+ DBG_LVL_ALL, "\nIPv6 Destination Port:%x\n",
+ ntohs(ushDestPort));
+ bClassificationSucceed = MatchDestPort(pstClassifierRule,
+ ntohs(ushDestPort));
+ if (!bClassificationSucceed)
break;
- BCM_DEBUG_PRINT( Adapter,DBG_TYPE_TX, IPV6_DBG, DBG_LVL_ALL, "\nIPv6 Dest Port Matched");
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV6_DBG,
+ DBG_LVL_ALL, "\nIPv6 Dest Port Matched");
}
- }while(0);
+ } while (0);
- if(TRUE==bClassificationSucceed)
- {
+ if (bClassificationSucceed == TRUE) {
INT iMatchedSFQueueIndex = 0;
- iMatchedSFQueueIndex = SearchSfid(Adapter,pstClassifierRule->ulSFID);
- if(iMatchedSFQueueIndex >= NO_OF_QUEUES)
- {
+ iMatchedSFQueueIndex = SearchSfid(Adapter, pstClassifierRule->ulSFID);
+ if (iMatchedSFQueueIndex >= NO_OF_QUEUES) {
bClassificationSucceed = FALSE;
- }
- else
- {
- if(FALSE == Adapter->PackInfo[iMatchedSFQueueIndex].bActive)
- {
+ } else {
+ if (Adapter->PackInfo[iMatchedSFQueueIndex].bActive == FALSE)
bClassificationSucceed = FALSE;
- }
}
}
@@ -261,52 +288,55 @@ USHORT IpVersion6(PMINI_ADAPTER Adapter, /**< Pointer to the driver control stru
}
-static BOOLEAN MatchSrcIpv6Address(S_CLASSIFIER_RULE *pstClassifierRule,IPV6Header *pstIpv6Header)
+static BOOLEAN MatchSrcIpv6Address(struct bcm_classifier_rule *pstClassifierRule,
+ IPV6Header *pstIpv6Header)
{
- UINT uiLoopIndex=0;
- UINT uiIpv6AddIndex=0;
- UINT uiIpv6AddrNoLongWords = 4;
+ UINT uiLoopIndex = 0;
+ UINT uiIpv6AddIndex = 0;
+ UINT uiIpv6AddrNoLongWords = 4;
ULONG aulSrcIP[4];
- PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev);
+ struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev);
/*
- //This is the no. of Src Addresses ie Range of IP Addresses contained
- //in the classifier rule for which we need to match
- */
+ * This is the no. of Src Addresses ie Range of IP Addresses contained
+ * in the classifier rule for which we need to match
+ */
UINT uiCountIPSrcAddresses = (UINT)pstClassifierRule->ucIPSourceAddressLength;
- if(0 == uiCountIPSrcAddresses)
+ if (uiCountIPSrcAddresses == 0)
return TRUE;
- //First Convert the Ip Address in the packet to Host Endian order
- for(uiIpv6AddIndex=0;uiIpv6AddIndex<uiIpv6AddrNoLongWords;uiIpv6AddIndex++)
- {
- aulSrcIP[uiIpv6AddIndex]=ntohl(pstIpv6Header->ulSrcIpAddress[uiIpv6AddIndex]);
- }
+ /* First Convert the Ip Address in the packet to Host Endian order */
+ for (uiIpv6AddIndex = 0; uiIpv6AddIndex < uiIpv6AddrNoLongWords; uiIpv6AddIndex++)
+ aulSrcIP[uiIpv6AddIndex] = ntohl(pstIpv6Header->ulSrcIpAddress[uiIpv6AddIndex]);
- for(uiLoopIndex=0;uiLoopIndex<uiCountIPSrcAddresses;uiLoopIndex+=uiIpv6AddrNoLongWords)
- {
- BCM_DEBUG_PRINT( Adapter,DBG_TYPE_TX, IPV6_DBG, DBG_LVL_ALL, "\n Src Ipv6 Address In Received Packet : \n ");
+ for (uiLoopIndex = 0; uiLoopIndex < uiCountIPSrcAddresses; uiLoopIndex += uiIpv6AddrNoLongWords) {
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV6_DBG, DBG_LVL_ALL,
+ "\n Src Ipv6 Address In Received Packet :\n ");
DumpIpv6Address(aulSrcIP);
- BCM_DEBUG_PRINT( Adapter,DBG_TYPE_TX, IPV6_DBG, DBG_LVL_ALL, "\n Src Ipv6 Mask In Classifier Rule: \n");
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV6_DBG, DBG_LVL_ALL,
+ "\n Src Ipv6 Mask In Classifier Rule:\n");
DumpIpv6Address(&pstClassifierRule->stSrcIpAddress.ulIpv6Mask[uiLoopIndex]);
- BCM_DEBUG_PRINT( Adapter,DBG_TYPE_TX, IPV6_DBG, DBG_LVL_ALL, "\n Src Ipv6 Address In Classifier Rule : \n");
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV6_DBG, DBG_LVL_ALL,
+ "\n Src Ipv6 Address In Classifier Rule :\n");
DumpIpv6Address(&pstClassifierRule->stSrcIpAddress.ulIpv6Addr[uiLoopIndex]);
- for(uiIpv6AddIndex=0;uiIpv6AddIndex<uiIpv6AddrNoLongWords;uiIpv6AddIndex++)
- {
- if((pstClassifierRule->stSrcIpAddress.ulIpv6Mask[uiLoopIndex+uiIpv6AddIndex] & aulSrcIP[uiIpv6AddIndex])
- != pstClassifierRule->stSrcIpAddress.ulIpv6Addr[uiLoopIndex+uiIpv6AddIndex])
- {
- //Match failed for current Ipv6 Address.Try next Ipv6 Address
+ for (uiIpv6AddIndex = 0; uiIpv6AddIndex < uiIpv6AddrNoLongWords; uiIpv6AddIndex++) {
+ if ((pstClassifierRule->stSrcIpAddress.ulIpv6Mask[uiLoopIndex+uiIpv6AddIndex] & aulSrcIP[uiIpv6AddIndex])
+ != pstClassifierRule->stSrcIpAddress.ulIpv6Addr[uiLoopIndex+uiIpv6AddIndex]) {
+ /*
+ * Match failed for current Ipv6 Address
+ * Try next Ipv6 Address
+ */
break;
}
- if(uiIpv6AddIndex == uiIpv6AddrNoLongWords-1)
- {
- //Match Found
- BCM_DEBUG_PRINT( Adapter,DBG_TYPE_TX, IPV6_DBG, DBG_LVL_ALL, "Ipv6 Src Ip Address Matched\n");
+ if (uiIpv6AddIndex == uiIpv6AddrNoLongWords-1) {
+ /* Match Found */
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV6_DBG,
+ DBG_LVL_ALL,
+ "Ipv6 Src Ip Address Matched\n");
return TRUE;
}
}
@@ -314,52 +344,56 @@ static BOOLEAN MatchSrcIpv6Address(S_CLASSIFIER_RULE *pstClassifierRule,IPV6Head
return FALSE;
}
-static BOOLEAN MatchDestIpv6Address(S_CLASSIFIER_RULE *pstClassifierRule,IPV6Header *pstIpv6Header)
+static BOOLEAN MatchDestIpv6Address(struct bcm_classifier_rule *pstClassifierRule,
+ IPV6Header *pstIpv6Header)
{
- UINT uiLoopIndex=0;
- UINT uiIpv6AddIndex=0;
- UINT uiIpv6AddrNoLongWords = 4;
+ UINT uiLoopIndex = 0;
+ UINT uiIpv6AddIndex = 0;
+ UINT uiIpv6AddrNoLongWords = 4;
ULONG aulDestIP[4];
- PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev);
+ struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev);
/*
- //This is the no. of Destination Addresses ie Range of IP Addresses contained
- //in the classifier rule for which we need to match
- */
+ * This is the no. of Destination Addresses
+ * ie Range of IP Addresses contained in the classifier rule
+ * for which we need to match
+ */
UINT uiCountIPDestinationAddresses = (UINT)pstClassifierRule->ucIPDestinationAddressLength;
- if(0 == uiCountIPDestinationAddresses)
+ if (uiCountIPDestinationAddresses == 0)
return TRUE;
- //First Convert the Ip Address in the packet to Host Endian order
- for(uiIpv6AddIndex=0;uiIpv6AddIndex<uiIpv6AddrNoLongWords;uiIpv6AddIndex++)
- {
- aulDestIP[uiIpv6AddIndex]=ntohl(pstIpv6Header->ulDestIpAddress[uiIpv6AddIndex]);
- }
+ /* First Convert the Ip Address in the packet to Host Endian order */
+ for (uiIpv6AddIndex = 0; uiIpv6AddIndex < uiIpv6AddrNoLongWords; uiIpv6AddIndex++)
+ aulDestIP[uiIpv6AddIndex] = ntohl(pstIpv6Header->ulDestIpAddress[uiIpv6AddIndex]);
- for(uiLoopIndex=0;uiLoopIndex<uiCountIPDestinationAddresses;uiLoopIndex+=uiIpv6AddrNoLongWords)
- {
- BCM_DEBUG_PRINT( Adapter,DBG_TYPE_TX, IPV6_DBG, DBG_LVL_ALL, "\n Destination Ipv6 Address In Received Packet : \n ");
+ for (uiLoopIndex = 0; uiLoopIndex < uiCountIPDestinationAddresses; uiLoopIndex += uiIpv6AddrNoLongWords) {
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV6_DBG, DBG_LVL_ALL,
+ "\n Destination Ipv6 Address In Received Packet :\n ");
DumpIpv6Address(aulDestIP);
- BCM_DEBUG_PRINT( Adapter,DBG_TYPE_TX, IPV6_DBG, DBG_LVL_ALL, "\n Destination Ipv6 Mask In Classifier Rule: \n");
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV6_DBG, DBG_LVL_ALL,
+ "\n Destination Ipv6 Mask In Classifier Rule :\n");
DumpIpv6Address(&pstClassifierRule->stDestIpAddress.ulIpv6Mask[uiLoopIndex]);
- BCM_DEBUG_PRINT( Adapter,DBG_TYPE_TX, IPV6_DBG, DBG_LVL_ALL, "\n Destination Ipv6 Address In Classifier Rule : \n");
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV6_DBG, DBG_LVL_ALL,
+ "\n Destination Ipv6 Address In Classifier Rule :\n");
DumpIpv6Address(&pstClassifierRule->stDestIpAddress.ulIpv6Addr[uiLoopIndex]);
- for(uiIpv6AddIndex=0;uiIpv6AddIndex<uiIpv6AddrNoLongWords;uiIpv6AddIndex++)
- {
- if((pstClassifierRule->stDestIpAddress.ulIpv6Mask[uiLoopIndex+uiIpv6AddIndex] & aulDestIP[uiIpv6AddIndex])
- != pstClassifierRule->stDestIpAddress.ulIpv6Addr[uiLoopIndex+uiIpv6AddIndex])
- {
- //Match failed for current Ipv6 Address.Try next Ipv6 Address
+ for (uiIpv6AddIndex = 0; uiIpv6AddIndex < uiIpv6AddrNoLongWords; uiIpv6AddIndex++) {
+ if ((pstClassifierRule->stDestIpAddress.ulIpv6Mask[uiLoopIndex+uiIpv6AddIndex] & aulDestIP[uiIpv6AddIndex])
+ != pstClassifierRule->stDestIpAddress.ulIpv6Addr[uiLoopIndex+uiIpv6AddIndex]) {
+ /*
+ * Match failed for current Ipv6 Address.
+ * Try next Ipv6 Address
+ */
break;
}
- if(uiIpv6AddIndex == uiIpv6AddrNoLongWords-1)
- {
- //Match Found
- BCM_DEBUG_PRINT( Adapter,DBG_TYPE_TX, IPV6_DBG, DBG_LVL_ALL, "Ipv6 Destination Ip Address Matched\n");
+ if (uiIpv6AddIndex == uiIpv6AddrNoLongWords-1) {
+ /* Match Found */
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV6_DBG,
+ DBG_LVL_ALL,
+ "Ipv6 Destination Ip Address Matched\n");
return TRUE;
}
}
@@ -371,11 +405,11 @@ static BOOLEAN MatchDestIpv6Address(S_CLASSIFIER_RULE *pstClassifierRule,IPV6Hea
VOID DumpIpv6Address(ULONG *puIpv6Address)
{
UINT uiIpv6AddrNoLongWords = 4;
- UINT uiIpv6AddIndex=0;
- PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev);
- for(uiIpv6AddIndex=0;uiIpv6AddIndex<uiIpv6AddrNoLongWords;uiIpv6AddIndex++)
- {
- BCM_DEBUG_PRINT( Adapter,DBG_TYPE_TX, IPV6_DBG, DBG_LVL_ALL, ":%lx",puIpv6Address[uiIpv6AddIndex]);
+ UINT uiIpv6AddIndex = 0;
+ struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev);
+ for (uiIpv6AddIndex = 0; uiIpv6AddIndex < uiIpv6AddrNoLongWords; uiIpv6AddIndex++) {
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV6_DBG, DBG_LVL_ALL,
+ ":%lx", puIpv6Address[uiIpv6AddIndex]);
}
}
@@ -383,22 +417,35 @@ VOID DumpIpv6Address(ULONG *puIpv6Address)
static VOID DumpIpv6Header(IPV6Header *pstIpv6Header)
{
UCHAR ucVersion;
- UCHAR ucPrio ;
- PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev);
- BCM_DEBUG_PRINT( Adapter,DBG_TYPE_TX, IPV6_DBG, DBG_LVL_ALL, "----Ipv6 Header---");
+ UCHAR ucPrio;
+ struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev);
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV6_DBG, DBG_LVL_ALL,
+ "----Ipv6 Header---");
ucVersion = pstIpv6Header->ucVersionPrio & 0xf0;
- BCM_DEBUG_PRINT( Adapter,DBG_TYPE_TX, IPV6_DBG, DBG_LVL_ALL, "Version : %x \n",ucVersion);
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV6_DBG, DBG_LVL_ALL,
+ "Version : %x\n", ucVersion);
ucPrio = pstIpv6Header->ucVersionPrio & 0x0f;
- BCM_DEBUG_PRINT( Adapter,DBG_TYPE_TX, IPV6_DBG, DBG_LVL_ALL, "Priority : %x \n",ucPrio);
- //BCM_DEBUG_PRINT( Adapter,DBG_TYPE_TX, IPV6_DBG, DBG_LVL_ALL, "Flow Label : %x \n",(pstIpv6Header->ucVersionPrio &0xf0);
- BCM_DEBUG_PRINT( Adapter,DBG_TYPE_TX, IPV6_DBG, DBG_LVL_ALL, "Payload Length : %x \n",ntohs(pstIpv6Header->usPayloadLength));
- BCM_DEBUG_PRINT( Adapter,DBG_TYPE_TX, IPV6_DBG, DBG_LVL_ALL, "Next Header : %x \n",pstIpv6Header->ucNextHeader);
- BCM_DEBUG_PRINT( Adapter,DBG_TYPE_TX, IPV6_DBG, DBG_LVL_ALL, "Hop Limit : %x \n",pstIpv6Header->ucHopLimit);
- BCM_DEBUG_PRINT( Adapter,DBG_TYPE_TX, IPV6_DBG, DBG_LVL_ALL, "Src Address :\n");
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV6_DBG, DBG_LVL_ALL,
+ "Priority : %x\n", ucPrio);
+ /*
+ * BCM_DEBUG_PRINT( Adapter,DBG_TYPE_TX, IPV6_DBG, DBG_LVL_ALL,
+ * "Flow Label : %x\n",(pstIpv6Header->ucVersionPrio &0xf0);
+ */
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV6_DBG, DBG_LVL_ALL,
+ "Payload Length : %x\n",
+ ntohs(pstIpv6Header->usPayloadLength));
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV6_DBG, DBG_LVL_ALL,
+ "Next Header : %x\n", pstIpv6Header->ucNextHeader);
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV6_DBG, DBG_LVL_ALL,
+ "Hop Limit : %x\n", pstIpv6Header->ucHopLimit);
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV6_DBG, DBG_LVL_ALL,
+ "Src Address :\n");
DumpIpv6Address(pstIpv6Header->ulSrcIpAddress);
- BCM_DEBUG_PRINT( Adapter,DBG_TYPE_TX, IPV6_DBG, DBG_LVL_ALL, "Dest Address :\n");
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV6_DBG, DBG_LVL_ALL,
+ "Dest Address :\n");
DumpIpv6Address(pstIpv6Header->ulDestIpAddress);
- BCM_DEBUG_PRINT( Adapter,DBG_TYPE_TX, IPV6_DBG, DBG_LVL_ALL, "----Ipv6 Header End---");
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV6_DBG, DBG_LVL_ALL,
+ "----Ipv6 Header End---");
}
diff --git a/drivers/staging/bcm/IPv6ProtocolHdr.h b/drivers/staging/bcm/IPv6ProtocolHdr.h
index a0db5a1de763..8ba88a5b081c 100644
--- a/drivers/staging/bcm/IPv6ProtocolHdr.h
+++ b/drivers/staging/bcm/IPv6ProtocolHdr.h
@@ -102,15 +102,15 @@ typedef enum _E_IPADDR_CONTEXT
//Function Prototypes
-USHORT IpVersion6(PMINI_ADAPTER Adapter, /**< Pointer to the driver control structure */
+USHORT IpVersion6(struct bcm_mini_adapter *Adapter, /**< Pointer to the driver control structure */
PVOID pcIpHeader, /**<Pointer to the IP Hdr of the packet*/
- S_CLASSIFIER_RULE *pstClassifierRule );
+ struct bcm_classifier_rule *pstClassifierRule );
VOID DumpIpv6Address(ULONG *puIpv6Address);
-extern BOOLEAN MatchSrcPort(S_CLASSIFIER_RULE *pstClassifierRule,USHORT ushSrcPort);
-extern BOOLEAN MatchDestPort(S_CLASSIFIER_RULE *pstClassifierRule,USHORT ushSrcPort);
-extern BOOLEAN MatchProtocol(S_CLASSIFIER_RULE *pstClassifierRule,UCHAR ucProtocol);
+extern BOOLEAN MatchSrcPort(struct bcm_classifier_rule *pstClassifierRule,USHORT ushSrcPort);
+extern BOOLEAN MatchDestPort(struct bcm_classifier_rule *pstClassifierRule,USHORT ushSrcPort);
+extern BOOLEAN MatchProtocol(struct bcm_classifier_rule *pstClassifierRule,UCHAR ucProtocol);
#endif
diff --git a/drivers/staging/bcm/InterfaceAdapter.h b/drivers/staging/bcm/InterfaceAdapter.h
index 6397c20f4f6a..4607c265d981 100644
--- a/drivers/staging/bcm/InterfaceAdapter.h
+++ b/drivers/staging/bcm/InterfaceAdapter.h
@@ -85,7 +85,7 @@ typedef struct _S_INTERFACE_ADAPTER
atomic_t uNumRcbUsed;
atomic_t uCurrRcb;
- PMINI_ADAPTER psAdapter;
+ struct bcm_mini_adapter *psAdapter;
BOOLEAN bFlashBoot;
BOOLEAN bHighSpeedDevice ;
diff --git a/drivers/staging/bcm/InterfaceDld.c b/drivers/staging/bcm/InterfaceDld.c
index 65c352f35681..3a89e33733ee 100644
--- a/drivers/staging/bcm/InterfaceDld.c
+++ b/drivers/staging/bcm/InterfaceDld.c
@@ -7,7 +7,7 @@ int InterfaceFileDownload(PVOID arg, struct file *flp, unsigned int on_chip_loc)
int errno = 0, len = 0; /* ,is_config_file = 0 */
loff_t pos = 0;
PS_INTERFACE_ADAPTER psIntfAdapter = (PS_INTERFACE_ADAPTER)arg;
- /* PMINI_ADAPTER Adapter = psIntfAdapter->psAdapter; */
+ /* struct bcm_mini_adapter *Adapter = psIntfAdapter->psAdapter; */
char *buff = kmalloc(MAX_TRANSFER_CTRL_BYTE_USB, GFP_KERNEL);
if (!buff)
@@ -132,7 +132,7 @@ exit:
return Status;
}
-static int bcm_download_config_file(PMINI_ADAPTER Adapter, FIRMWARE_INFO *psFwInfo)
+static int bcm_download_config_file(struct bcm_mini_adapter *Adapter, struct bcm_firmware_info *psFwInfo)
{
int retval = STATUS_SUCCESS;
B_UINT32 value = 0;
@@ -208,7 +208,7 @@ static int bcm_download_config_file(PMINI_ADAPTER Adapter, FIRMWARE_INFO *psFwIn
static int bcm_compare_buff_contents(unsigned char *readbackbuff, unsigned char *buff, unsigned int len)
{
int retval = STATUS_SUCCESS;
- PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev);
+ struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev);
if ((len-sizeof(unsigned int)) < 4) {
if (memcmp(readbackbuff , buff, len))
retval = -EINVAL;
@@ -229,7 +229,7 @@ static int bcm_compare_buff_contents(unsigned char *readbackbuff, unsigned char
return retval;
}
-int bcm_ioctl_fw_download(PMINI_ADAPTER Adapter, FIRMWARE_INFO *psFwInfo)
+int bcm_ioctl_fw_download(struct bcm_mini_adapter *Adapter, struct bcm_firmware_info *psFwInfo)
{
int retval = STATUS_SUCCESS;
PUCHAR buff = NULL;
@@ -278,7 +278,7 @@ error:
return retval;
}
-static INT buffDnld(PMINI_ADAPTER Adapter, PUCHAR mappedbuffer, UINT u32FirmwareLength, ULONG u32StartingAddress)
+static INT buffDnld(struct bcm_mini_adapter *Adapter, PUCHAR mappedbuffer, UINT u32FirmwareLength, ULONG u32StartingAddress)
{
unsigned int len = 0;
int retval = STATUS_SUCCESS;
@@ -299,7 +299,7 @@ static INT buffDnld(PMINI_ADAPTER Adapter, PUCHAR mappedbuffer, UINT u32Firmware
return retval;
}
-static INT buffRdbkVerify(PMINI_ADAPTER Adapter, PUCHAR mappedbuffer, UINT u32FirmwareLength, ULONG u32StartingAddress)
+static INT buffRdbkVerify(struct bcm_mini_adapter *Adapter, PUCHAR mappedbuffer, UINT u32FirmwareLength, ULONG u32StartingAddress)
{
UINT len = u32FirmwareLength;
INT retval = STATUS_SUCCESS;
@@ -334,7 +334,7 @@ static INT buffRdbkVerify(PMINI_ADAPTER Adapter, PUCHAR mappedbuffer, UINT u32Fi
return retval;
}
-INT buffDnldVerify(PMINI_ADAPTER Adapter, unsigned char *mappedbuffer, unsigned int u32FirmwareLength, unsigned long u32StartingAddress)
+INT buffDnldVerify(struct bcm_mini_adapter *Adapter, unsigned char *mappedbuffer, unsigned int u32FirmwareLength, unsigned long u32StartingAddress)
{
INT status = STATUS_SUCCESS;
diff --git a/drivers/staging/bcm/InterfaceIdleMode.c b/drivers/staging/bcm/InterfaceIdleMode.c
index faeb03e62c06..4f2f490921e1 100644
--- a/drivers/staging/bcm/InterfaceIdleMode.c
+++ b/drivers/staging/bcm/InterfaceIdleMode.c
@@ -7,7 +7,7 @@ Description: This is the hardware specific Function for waking up HW device fr
A software abort pattern is written to the device to wake it and necessary power state
transitions from host are performed here.
-Input parameters: IN PMINI_ADAPTER Adapter - Miniport Adapter Context
+Input parameters: IN struct bcm_mini_adapter *Adapter - Miniport Adapter Context
Return: BCM_STATUS_SUCCESS - If Wakeup of the HW Interface was successful.
@@ -22,7 +22,7 @@ Description: This is the hardware specific Function for responding to Idle mod
Necessary power state transitions from host for idle mode or other device specific
initializations are performed here.
-Input parameters: IN PMINI_ADAPTER Adapter - Miniport Adapter Context
+Input parameters: IN struct bcm_mini_adapter * Adapter - Miniport Adapter Context
Return: BCM_STATUS_SUCCESS - If Idle mode response related HW configuration was successful.
@@ -42,7 +42,7 @@ send to f/w with in 200 ms after the Idle/Shutdown req issued
*/
-int InterfaceIdleModeRespond(PMINI_ADAPTER Adapter, unsigned int* puiBuffer)
+int InterfaceIdleModeRespond(struct bcm_mini_adapter *Adapter, unsigned int* puiBuffer)
{
int status = STATUS_SUCCESS;
unsigned int uiRegRead = 0;
@@ -147,7 +147,7 @@ int InterfaceIdleModeRespond(PMINI_ADAPTER Adapter, unsigned int* puiBuffer)
return status;
}
-static int InterfaceAbortIdlemode(PMINI_ADAPTER Adapter, unsigned int Pattern)
+static int InterfaceAbortIdlemode(struct bcm_mini_adapter *Adapter, unsigned int Pattern)
{
int status = STATUS_SUCCESS;
unsigned int value;
@@ -246,7 +246,7 @@ static int InterfaceAbortIdlemode(PMINI_ADAPTER Adapter, unsigned int Pattern)
}
return status;
}
-int InterfaceIdleModeWakeup(PMINI_ADAPTER Adapter)
+int InterfaceIdleModeWakeup(struct bcm_mini_adapter *Adapter)
{
ULONG Status = 0;
if(Adapter->bTriedToWakeUpFromlowPowerMode)
@@ -263,7 +263,7 @@ int InterfaceIdleModeWakeup(PMINI_ADAPTER Adapter)
return Status;
}
-void InterfaceHandleShutdownModeWakeup(PMINI_ADAPTER Adapter)
+void InterfaceHandleShutdownModeWakeup(struct bcm_mini_adapter *Adapter)
{
unsigned int uiRegVal = 0;
INT Status = 0;
diff --git a/drivers/staging/bcm/InterfaceIdleMode.h b/drivers/staging/bcm/InterfaceIdleMode.h
index 859a2ffba6b7..c3338c8a1dc8 100644
--- a/drivers/staging/bcm/InterfaceIdleMode.h
+++ b/drivers/staging/bcm/InterfaceIdleMode.h
@@ -1,14 +1,14 @@
#ifndef _INTERFACE_IDLEMODE_H
#define _INTERFACE_IDLEMODE_H
-INT InterfaceIdleModeWakeup(PMINI_ADAPTER Adapter);
+INT InterfaceIdleModeWakeup(struct bcm_mini_adapter *Adapter);
-INT InterfaceIdleModeRespond(PMINI_ADAPTER Adapter, unsigned int *puiBuffer);
+INT InterfaceIdleModeRespond(struct bcm_mini_adapter *Adapter, unsigned int *puiBuffer);
-VOID InterfaceWriteIdleModeWakePattern(PMINI_ADAPTER Adapter);
+VOID InterfaceWriteIdleModeWakePattern(struct bcm_mini_adapter *Adapter);
-INT InterfaceWakeUp(PMINI_ADAPTER Adapter);
+INT InterfaceWakeUp(struct bcm_mini_adapter * Adapter);
-VOID InterfaceHandleShutdownModeWakeup(PMINI_ADAPTER Adapter);
+VOID InterfaceHandleShutdownModeWakeup(struct bcm_mini_adapter *Adapter);
#endif
diff --git a/drivers/staging/bcm/InterfaceInit.c b/drivers/staging/bcm/InterfaceInit.c
index 8e3c586a699c..8f85de6a57ba 100644
--- a/drivers/staging/bcm/InterfaceInit.c
+++ b/drivers/staging/bcm/InterfaceInit.c
@@ -65,7 +65,7 @@ static void InterfaceAdapterFree(PS_INTERFACE_ADAPTER psIntfAdapter)
AdapterFree(psIntfAdapter->psAdapter);
}
-static void ConfigureEndPointTypesThroughEEPROM(PMINI_ADAPTER Adapter)
+static void ConfigureEndPointTypesThroughEEPROM(struct bcm_mini_adapter *Adapter)
{
unsigned long ulReg = 0;
int bytes;
@@ -143,12 +143,12 @@ static int usbbcm_device_probe(struct usb_interface *intf, const struct usb_devi
{
struct usb_device *udev = interface_to_usbdev(intf);
int retval;
- PMINI_ADAPTER psAdapter;
+ struct bcm_mini_adapter *psAdapter;
PS_INTERFACE_ADAPTER psIntfAdapter;
struct net_device *ndev;
/* Reserve one extra queue for the bit-bucket */
- ndev = alloc_etherdev_mq(sizeof(MINI_ADAPTER), NO_OF_QUEUES+1);
+ ndev = alloc_etherdev_mq(sizeof(struct bcm_mini_adapter), NO_OF_QUEUES+1);
if (ndev == NULL) {
dev_err(&udev->dev, DRV_NAME ": no memory for device\n");
return -ENOMEM;
@@ -257,7 +257,7 @@ static int usbbcm_device_probe(struct usb_interface *intf, const struct usb_devi
static void usbbcm_disconnect(struct usb_interface *intf)
{
PS_INTERFACE_ADAPTER psIntfAdapter = usb_get_intfdata(intf);
- PMINI_ADAPTER psAdapter;
+ struct bcm_mini_adapter *psAdapter;
struct usb_device *udev = interface_to_usbdev(intf);
if (psIntfAdapter == NULL)
diff --git a/drivers/staging/bcm/InterfaceIsr.c b/drivers/staging/bcm/InterfaceIsr.c
index 67719d57256d..6ee3428daa55 100644
--- a/drivers/staging/bcm/InterfaceIsr.c
+++ b/drivers/staging/bcm/InterfaceIsr.c
@@ -5,7 +5,7 @@ static void read_int_callback(struct urb *urb/*, struct pt_regs *regs*/)
{
int status = urb->status;
PS_INTERFACE_ADAPTER psIntfAdapter = (PS_INTERFACE_ADAPTER)urb->context;
- PMINI_ADAPTER Adapter = psIntfAdapter->psAdapter ;
+ struct bcm_mini_adapter *Adapter = psIntfAdapter->psAdapter ;
if (netif_msg_intr(Adapter))
pr_info(PFX "%s: interrupt status %d\n",
diff --git a/drivers/staging/bcm/InterfaceIsr.h b/drivers/staging/bcm/InterfaceIsr.h
index 6065a7141bca..40399788c419 100644
--- a/drivers/staging/bcm/InterfaceIsr.h
+++ b/drivers/staging/bcm/InterfaceIsr.h
@@ -7,9 +7,9 @@ int CreateInterruptUrb(PS_INTERFACE_ADAPTER psIntfAdapter);
INT StartInterruptUrb(PS_INTERFACE_ADAPTER psIntfAdapter);
-VOID InterfaceEnableInterrupt(PMINI_ADAPTER Adapter);
+VOID InterfaceEnableInterrupt(struct bcm_mini_adapter *Adapter);
-VOID InterfaceDisableInterrupt(PMINI_ADAPTER Adapter);
+VOID InterfaceDisableInterrupt(struct bcm_mini_adapter *Adapter);
#endif
diff --git a/drivers/staging/bcm/InterfaceMisc.c b/drivers/staging/bcm/InterfaceMisc.c
index 2218faeaf8ac..bbe909946091 100644
--- a/drivers/staging/bcm/InterfaceMisc.c
+++ b/drivers/staging/bcm/InterfaceMisc.c
@@ -133,7 +133,7 @@ INT BcmWRM(PVOID arg,
return InterfaceWRM((PS_INTERFACE_ADAPTER)arg, addr, buff, len);
}
-INT Bcm_clear_halt_of_endpoints(PMINI_ADAPTER Adapter)
+INT Bcm_clear_halt_of_endpoints(struct bcm_mini_adapter *Adapter)
{
PS_INTERFACE_ADAPTER psIntfAdapter = (PS_INTERFACE_ADAPTER)(Adapter->pvInterfaceAdapter);
INT status = STATUS_SUCCESS;
diff --git a/drivers/staging/bcm/InterfaceMisc.h b/drivers/staging/bcm/InterfaceMisc.h
index 6c9e39bf9889..1dfabdc3aadd 100644
--- a/drivers/staging/bcm/InterfaceMisc.h
+++ b/drivers/staging/bcm/InterfaceMisc.h
@@ -33,7 +33,7 @@ int BcmWRM(PVOID arg,
PVOID buff,
INT len);
-INT Bcm_clear_halt_of_endpoints(PMINI_ADAPTER Adapter);
+INT Bcm_clear_halt_of_endpoints(struct bcm_mini_adapter *Adapter);
VOID Bcm_kill_all_URBs(PS_INTERFACE_ADAPTER psIntfAdapter);
diff --git a/drivers/staging/bcm/InterfaceRx.c b/drivers/staging/bcm/InterfaceRx.c
index d495828a731f..8a9f90fbdf13 100644
--- a/drivers/staging/bcm/InterfaceRx.c
+++ b/drivers/staging/bcm/InterfaceRx.c
@@ -1,6 +1,6 @@
#include "headers.h"
-static int SearchVcid(PMINI_ADAPTER Adapter,unsigned short usVcid)
+static int SearchVcid(struct bcm_mini_adapter *Adapter,unsigned short usVcid)
{
int iIndex=0;
@@ -45,8 +45,8 @@ static void read_bulk_callback(struct urb *urb)
//int idleflag = 0 ;
PUSB_RCB pRcb = (PUSB_RCB)urb->context;
PS_INTERFACE_ADAPTER psIntfAdapter = pRcb->psIntfAdapter;
- PMINI_ADAPTER Adapter = psIntfAdapter->psAdapter;
- PLEADER pLeader = urb->transfer_buffer;
+ struct bcm_mini_adapter *Adapter = psIntfAdapter->psAdapter;
+ struct bcm_leader *pLeader = urb->transfer_buffer;
if (unlikely(netif_msg_rx_status(Adapter)))
pr_info(PFX "%s: rx urb status %d length %d\n",
@@ -126,7 +126,7 @@ static void read_bulk_callback(struct urb *urb)
BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_RX, RX_CTRL, DBG_LVL_ALL, "Received control pkt...");
*(PUSHORT)skb->data = pLeader->Status;
memcpy(skb->data+sizeof(USHORT), urb->transfer_buffer +
- (sizeof(LEADER)), pLeader->PLength);
+ (sizeof(struct bcm_leader)), pLeader->PLength);
skb->len = pLeader->PLength + sizeof(USHORT);
spin_lock(&Adapter->control_queue_lock);
@@ -144,7 +144,7 @@ static void read_bulk_callback(struct urb *urb)
*/
BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_RX, RX_DATA, DBG_LVL_ALL, "Received Data pkt...");
skb_reserve(skb, 2 + SKB_RESERVE_PHS_BYTES);
- memcpy(skb->data+ETH_HLEN, (PUCHAR)urb->transfer_buffer + sizeof(LEADER), pLeader->PLength);
+ memcpy(skb->data+ETH_HLEN, (PUCHAR)urb->transfer_buffer + sizeof(struct bcm_leader), pLeader->PLength);
skb->dev = Adapter->dev;
/* currently skb->len has extra ETH_HLEN bytes in the beginning */
@@ -232,7 +232,7 @@ Function: InterfaceRx
Description: This is the hardware specific Function for Receiving
data packet/control packets from the device.
-Input parameters: IN PMINI_ADAPTER Adapter - Miniport Adapter Context
+Input parameters: IN struct bcm_mini_adapter *Adapter - Miniport Adapter Context
diff --git a/drivers/staging/bcm/InterfaceTx.c b/drivers/staging/bcm/InterfaceTx.c
index a842de9de6b5..7e2b53be4d9e 100644
--- a/drivers/staging/bcm/InterfaceTx.c
+++ b/drivers/staging/bcm/InterfaceTx.c
@@ -5,10 +5,10 @@ static void write_bulk_callback(struct urb *urb/*, struct pt_regs *regs*/)
{
PUSB_TCB pTcb= (PUSB_TCB)urb->context;
PS_INTERFACE_ADAPTER psIntfAdapter = pTcb->psIntfAdapter;
- CONTROL_MESSAGE *pControlMsg = (CONTROL_MESSAGE *)urb->transfer_buffer;
- PMINI_ADAPTER psAdapter = psIntfAdapter->psAdapter ;
+ struct bcm_link_request *pControlMsg = (struct bcm_link_request *)urb->transfer_buffer;
+ struct bcm_mini_adapter *psAdapter = psIntfAdapter->psAdapter ;
BOOLEAN bpowerDownMsg = FALSE ;
- PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev);
+ struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev);
if (unlikely(netif_msg_tx_done(Adapter)))
pr_info(PFX "%s: transmit status %d\n", Adapter->dev->name, urb->status);
diff --git a/drivers/staging/bcm/LeakyBucket.c b/drivers/staging/bcm/LeakyBucket.c
index a55d4228e8e0..6e8a3279698b 100644
--- a/drivers/staging/bcm/LeakyBucket.c
+++ b/drivers/staging/bcm/LeakyBucket.c
@@ -15,7 +15,7 @@
* Returns - None
**********************************************************************/
-static VOID UpdateTokenCount(register PMINI_ADAPTER Adapter)
+static VOID UpdateTokenCount(register struct bcm_mini_adapter *Adapter)
{
ULONG liCurrentTime;
INT i = 0;
@@ -75,7 +75,7 @@ static VOID UpdateTokenCount(register PMINI_ADAPTER Adapter)
* Returns - The number of bytes allowed for transmission.
*
***********************************************************************/
-static ULONG GetSFTokenCount(PMINI_ADAPTER Adapter, PacketInfo *psSF)
+static ULONG GetSFTokenCount(struct bcm_mini_adapter *Adapter, struct bcm_packet_info *psSF)
{
BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TOKEN_COUNTS, DBG_LVL_ALL, "IsPacketAllowedForFlow ===>");
/* Validate the parameters */
@@ -112,8 +112,8 @@ static ULONG GetSFTokenCount(PMINI_ADAPTER Adapter, PacketInfo *psSF)
This function despatches packet from the specified queue.
@return Zero(success) or Negative value(failure)
*/
-static INT SendPacketFromQueue(PMINI_ADAPTER Adapter,/**<Logical Adapter*/
- PacketInfo *psSF, /**<Queue identifier*/
+static INT SendPacketFromQueue(struct bcm_mini_adapter *Adapter,/**<Logical Adapter*/
+ struct bcm_packet_info *psSF, /**<Queue identifier*/
struct sk_buff* Packet) /**<Pointer to the packet to be sent*/
{
INT Status=STATUS_FAILURE;
@@ -156,7 +156,7 @@ static INT SendPacketFromQueue(PMINI_ADAPTER Adapter,/**<Logical Adapter*/
* Returns - None.
*
****************************************************************************/
-static VOID CheckAndSendPacketFromIndex(PMINI_ADAPTER Adapter, PacketInfo *psSF)
+static VOID CheckAndSendPacketFromIndex(struct bcm_mini_adapter *Adapter, struct bcm_packet_info *psSF)
{
struct sk_buff *QueuePacket=NULL;
char *pControlPacket = NULL;
@@ -243,10 +243,10 @@ static VOID CheckAndSendPacketFromIndex(PMINI_ADAPTER Adapter, PacketInfo *psSF)
{
spin_lock_bh(&psSF->SFQueueLock);
psSF->NumOfPacketsSent++;
- psSF->uiSentBytes+=((PLEADER)pControlPacket)->PLength;
+ psSF->uiSentBytes+=((struct bcm_leader *)pControlPacket)->PLength;
psSF->uiSentPackets++;
atomic_dec(&Adapter->TotalPacketCount);
- psSF->uiCurrentBytesOnHost -= ((PLEADER)pControlPacket)->PLength;
+ psSF->uiCurrentBytesOnHost -= ((struct bcm_leader *)pControlPacket)->PLength;
psSF->uiCurrentPacketsOnHost--;
atomic_inc(&Adapter->index_rd_txcntrlpkt);
spin_unlock_bh(&psSF->SFQueueLock);
@@ -273,7 +273,7 @@ static VOID CheckAndSendPacketFromIndex(PMINI_ADAPTER Adapter, PacketInfo *psSF)
*
* Returns - None.
********************************************************************/
-VOID transmit_packets(PMINI_ADAPTER Adapter)
+VOID transmit_packets(struct bcm_mini_adapter *Adapter)
{
UINT uiPrevTotalCount = 0;
int iIndex = 0;
diff --git a/drivers/staging/bcm/Macros.h b/drivers/staging/bcm/Macros.h
index 46ed99c53764..46f5f0feea88 100644
--- a/drivers/staging/bcm/Macros.h
+++ b/drivers/staging/bcm/Macros.h
@@ -6,7 +6,6 @@
#define TX_TIMER_PERIOD 10 /*10 msec*/
#define MAX_CLASSIFIERS 100
-/* #define MAX_CLASSIFIERS_PER_SF 20 */
#define MAX_TARGET_DSX_BUFFERS 24
#define MAX_CNTRL_PKTS 100
@@ -108,11 +107,11 @@
/*Leader related terms */
#define LEADER_STATUS 0x00
#define LEADER_STATUS_TCP_ACK 0x1
-#define LEADER_SIZE sizeof(LEADER)
-#define MAC_ADDR_REQ_SIZE sizeof(PACKETTOSEND)
-#define SS_INFO_REQ_SIZE sizeof(PACKETTOSEND)
+#define LEADER_SIZE sizeof(struct bcm_leader)
+#define MAC_ADDR_REQ_SIZE sizeof(struct bcm_packettosend)
+#define SS_INFO_REQ_SIZE sizeof(struct bcm_packettosend)
#define CM_REQUEST_SIZE (LEADER_SIZE + sizeof(stLocalSFChangeRequest))
-#define IDLE_REQ_SIZE sizeof(PACKETTOSEND)
+#define IDLE_REQ_SIZE sizeof(struct bcm_packettosend)
#define MAX_TRANSFER_CTRL_BYTE_USB (2*1024)
@@ -252,11 +251,7 @@ typedef enum _E_PHS_DSC_ACTION {
#define IDLE_MODE_WAKEUP_NOTIFIER_ADDRESS 0x1FC02FA8
#define IDLE_MODE_MAX_RETRY_COUNT 1000
-#ifdef REL_4_1
-#define CONFIG_BEGIN_ADDR 0xBF60B004
-#else
#define CONFIG_BEGIN_ADDR 0xBF60B000
-#endif
#define FIRMWARE_BEGIN_ADDR 0xBFC00000
diff --git a/drivers/staging/bcm/Misc.c b/drivers/staging/bcm/Misc.c
index c7725e141fd5..9a60d4cd2184 100644
--- a/drivers/staging/bcm/Misc.c
+++ b/drivers/staging/bcm/Misc.c
@@ -1,12 +1,12 @@
#include "headers.h"
-static int BcmFileDownload(PMINI_ADAPTER Adapter, const char *path, unsigned int loc);
-static VOID doPowerAutoCorrection(PMINI_ADAPTER psAdapter);
-static void HandleShutDownModeRequest(PMINI_ADAPTER Adapter, PUCHAR pucBuffer);
-static int bcm_parse_target_params(PMINI_ADAPTER Adapter);
-static void beceem_protocol_reset(PMINI_ADAPTER Adapter);
+static int BcmFileDownload(struct bcm_mini_adapter *Adapter, const char *path, unsigned int loc);
+static VOID doPowerAutoCorrection(struct bcm_mini_adapter *psAdapter);
+static void HandleShutDownModeRequest(struct bcm_mini_adapter *Adapter, PUCHAR pucBuffer);
+static int bcm_parse_target_params(struct bcm_mini_adapter *Adapter);
+static void beceem_protocol_reset(struct bcm_mini_adapter *Adapter);
-static VOID default_wimax_protocol_initialize(PMINI_ADAPTER Adapter)
+static VOID default_wimax_protocol_initialize(struct bcm_mini_adapter *Adapter)
{
UINT uiLoopIndex;
@@ -24,7 +24,7 @@ static VOID default_wimax_protocol_initialize(PMINI_ADAPTER Adapter)
return;
}
-INT InitAdapter(PMINI_ADAPTER psAdapter)
+INT InitAdapter(struct bcm_mini_adapter *psAdapter)
{
int i = 0;
INT Status = STATUS_SUCCESS;
@@ -93,7 +93,7 @@ INT InitAdapter(PMINI_ADAPTER psAdapter)
return STATUS_SUCCESS;
}
-VOID AdapterFree(PMINI_ADAPTER Adapter)
+VOID AdapterFree(struct bcm_mini_adapter *Adapter)
{
int count;
beceem_protocol_reset(Adapter);
@@ -134,7 +134,7 @@ VOID AdapterFree(PMINI_ADAPTER Adapter)
free_netdev(Adapter->dev);
}
-static int create_worker_threads(PMINI_ADAPTER psAdapter)
+static int create_worker_threads(struct bcm_mini_adapter *psAdapter)
{
/* Rx Control Packets Processing */
psAdapter->control_packet_handler = kthread_run((int (*)(void *))
@@ -155,7 +155,7 @@ static int create_worker_threads(PMINI_ADAPTER psAdapter)
return 0;
}
-static struct file *open_firmware_file(PMINI_ADAPTER Adapter, const char *path)
+static struct file *open_firmware_file(struct bcm_mini_adapter *Adapter, const char *path)
{
struct file *flp = NULL;
mm_segment_t oldfs;
@@ -179,7 +179,7 @@ static struct file *open_firmware_file(PMINI_ADAPTER Adapter, const char *path)
* Path to image file
* Download Address on the chip
*/
-static int BcmFileDownload(PMINI_ADAPTER Adapter, const char *path, unsigned int loc)
+static int BcmFileDownload(struct bcm_mini_adapter *Adapter, const char *path, unsigned int loc)
{
int errorno = 0;
struct file *flp = NULL;
@@ -231,13 +231,13 @@ exit_download:
* Logical Adapter
* Control Packet Buffer
*/
-INT CopyBufferToControlPacket(PMINI_ADAPTER Adapter, PVOID ioBuffer)
+INT CopyBufferToControlPacket(struct bcm_mini_adapter *Adapter, PVOID ioBuffer)
{
- PLEADER pLeader = NULL;
+ struct bcm_leader *pLeader = NULL;
INT Status = 0;
unsigned char *ctrl_buff = NULL;
UINT pktlen = 0;
- PLINK_REQUEST pLinkReq = NULL;
+ struct bcm_link_request *pLinkReq = NULL;
PUCHAR pucAddIndication = NULL;
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL, "======>");
@@ -246,8 +246,8 @@ INT CopyBufferToControlPacket(PMINI_ADAPTER Adapter, PVOID ioBuffer)
return -EINVAL;
}
- pLinkReq = (PLINK_REQUEST)ioBuffer;
- pLeader = (PLEADER)ioBuffer; /* ioBuffer Contains sw_Status and Payload */
+ pLinkReq = (struct bcm_link_request *)ioBuffer;
+ pLeader = (struct bcm_leader *)ioBuffer; /* ioBuffer Contains sw_Status and Payload */
if (Adapter->bShutStatus == TRUE &&
pLinkReq->szData[0] == LINK_DOWN_REQ_PAYLOAD &&
@@ -373,7 +373,7 @@ INT CopyBufferToControlPacket(PMINI_ADAPTER Adapter, PVOID ioBuffer)
memset(ctrl_buff, 0, pktlen+LEADER_SIZE);
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL, "Copying the Control Packet Buffer with length=%d\n", pLeader->PLength);
- *(PLEADER)ctrl_buff = *pLeader;
+ *(struct bcm_leader *)ctrl_buff = *pLeader;
memcpy(ctrl_buff + LEADER_SIZE, ((PUCHAR)ioBuffer + LEADER_SIZE), pLeader->PLength);
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL, "Enqueuing the Control Packet");
@@ -402,30 +402,6 @@ INT CopyBufferToControlPacket(PMINI_ADAPTER Adapter, PVOID ioBuffer)
return Status;
}
-#if 0
-/*****************************************************************
-* Function - SendStatisticsPointerRequest()
-*
-* Description - This function builds and forwards the Statistics
-* Pointer Request control Packet.
-*
-* Parameters - Adapter : Pointer to Adapter structure.
-* - pstStatisticsPtrRequest : Pointer to link request.
-*
-* Returns - None.
-*****************************************************************/
-static VOID SendStatisticsPointerRequest(PMINI_ADAPTER Adapter, PLINK_REQUEST pstStatisticsPtrRequest)
-{
- BCM_DEBUG_PRINT(Adapter, DBG_TYPE_RX, RX_DPC, DBG_LVL_ALL, "======>");
- pstStatisticsPtrRequest->Leader.Status = STATS_POINTER_REQ_STATUS;
- pstStatisticsPtrRequest->Leader.PLength = sizeof(ULONG); /* minimum 4 bytes */
- pstStatisticsPtrRequest->szData[0] = STATISTICS_POINTER_REQ;
- CopyBufferToControlPacket(Adapter, pstStatisticsPtrRequest);
- BCM_DEBUG_PRINT(Adapter, DBG_TYPE_RX, RX_DPC, DBG_LVL_ALL, "<=====");
- return;
-}
-#endif
-
/******************************************************************
* Function - LinkMessage()
*
@@ -436,12 +412,12 @@ static VOID SendStatisticsPointerRequest(PMINI_ADAPTER Adapter, PLINK_REQUEST ps
*
* Returns - None.
*******************************************************************/
-VOID LinkMessage(PMINI_ADAPTER Adapter)
+VOID LinkMessage(struct bcm_mini_adapter *Adapter)
{
- PLINK_REQUEST pstLinkRequest = NULL;
+ struct bcm_link_request *pstLinkRequest = NULL;
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, LINK_UP_MSG, DBG_LVL_ALL, "=====>");
if (Adapter->LinkStatus == SYNC_UP_REQUEST && Adapter->AutoSyncup) {
- pstLinkRequest = kzalloc(sizeof(LINK_REQUEST), GFP_ATOMIC);
+ pstLinkRequest = kzalloc(sizeof(struct bcm_link_request), GFP_ATOMIC);
if (!pstLinkRequest) {
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, LINK_UP_MSG, DBG_LVL_ALL, "Can not allocate memory for Link request!");
return;
@@ -456,7 +432,7 @@ VOID LinkMessage(PMINI_ADAPTER Adapter)
Adapter->bSyncUpRequestSent = TRUE;
} else if (Adapter->LinkStatus == PHY_SYNC_ACHIVED && Adapter->AutoLinkUp) {
- pstLinkRequest = kzalloc(sizeof(LINK_REQUEST), GFP_ATOMIC);
+ pstLinkRequest = kzalloc(sizeof(struct bcm_link_request), GFP_ATOMIC);
if (!pstLinkRequest) {
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, LINK_UP_MSG, DBG_LVL_ALL, "Can not allocate memory for Link request!");
return;
@@ -487,7 +463,7 @@ VOID LinkMessage(PMINI_ADAPTER Adapter)
*
* Returns - None.
************************************************************************/
-VOID StatisticsResponse(PMINI_ADAPTER Adapter, PVOID pvBuffer)
+VOID StatisticsResponse(struct bcm_mini_adapter *Adapter, PVOID pvBuffer)
{
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "%s====>", __func__);
Adapter->StatisticsPointer = ntohl(*(__be32 *)pvBuffer);
@@ -506,7 +482,7 @@ VOID StatisticsResponse(PMINI_ADAPTER Adapter, PVOID pvBuffer)
*
* Returns - None.
***********************************************************************/
-VOID LinkControlResponseMessage(PMINI_ADAPTER Adapter, PUCHAR pucBuffer)
+VOID LinkControlResponseMessage(struct bcm_mini_adapter *Adapter, PUCHAR pucBuffer)
{
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_RX, RX_DPC, DBG_LVL_ALL, "=====>");
@@ -580,11 +556,11 @@ VOID LinkControlResponseMessage(PMINI_ADAPTER Adapter, PUCHAR pucBuffer)
return;
}
-void SendIdleModeResponse(PMINI_ADAPTER Adapter)
+void SendIdleModeResponse(struct bcm_mini_adapter *Adapter)
{
INT status = 0, NVMAccess = 0, lowPwrAbortMsg = 0;
struct timeval tv;
- CONTROL_MESSAGE stIdleResponse = {{0} };
+ struct bcm_link_request stIdleResponse = {{0} };
memset(&tv, 0, sizeof(tv));
stIdleResponse.Leader.Status = IDLE_MESSAGE;
stIdleResponse.Leader.PLength = IDLE_MODE_PAYLOAD_LENGTH;
@@ -679,12 +655,12 @@ void SendIdleModeResponse(PMINI_ADAPTER Adapter)
*
* Returns - None.
*******************************************************************/
-VOID DumpPackInfo(PMINI_ADAPTER Adapter)
+VOID DumpPackInfo(struct bcm_mini_adapter *Adapter)
{
UINT uiLoopIndex = 0;
UINT uiIndex = 0;
UINT uiClsfrIndex = 0;
- S_CLASSIFIER_RULE *pstClassifierEntry = NULL;
+ struct bcm_classifier_rule *pstClassifierEntry = NULL;
for (uiLoopIndex = 0; uiLoopIndex < NO_OF_QUEUES; uiLoopIndex++) {
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "*********** Showing Details Of Queue %d***** ******", uiLoopIndex);
@@ -808,10 +784,10 @@ VOID DumpPackInfo(PMINI_ADAPTER Adapter)
return;
}
-int reset_card_proc(PMINI_ADAPTER ps_adapter)
+int reset_card_proc(struct bcm_mini_adapter *ps_adapter)
{
int retval = STATUS_SUCCESS;
- PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev);
+ struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev);
PS_INTERFACE_ADAPTER psIntfAdapter = NULL;
unsigned int value = 0, uiResetValue = 0;
int bytes;
@@ -835,7 +811,7 @@ int reset_card_proc(PMINI_ADAPTER ps_adapter)
Bcm_kill_all_URBs(psIntfAdapter);
/* Reset the UMA-B Device */
if (ps_adapter->chip_id >= T3LPB) {
- BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Reseting UMA-B\n");
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Resetting UMA-B\n");
retval = usb_reset_device(psIntfAdapter->udev);
psIntfAdapter->psAdapter->StopAllXaction = FALSE;
@@ -926,7 +902,7 @@ err_exit:
return retval;
}
-int run_card_proc(PMINI_ADAPTER ps_adapter)
+int run_card_proc(struct bcm_mini_adapter *ps_adapter)
{
int status = STATUS_SUCCESS;
int bytes;
@@ -953,7 +929,7 @@ int run_card_proc(PMINI_ADAPTER ps_adapter)
return status;
}
-int InitCardAndDownloadFirmware(PMINI_ADAPTER ps_adapter)
+int InitCardAndDownloadFirmware(struct bcm_mini_adapter *ps_adapter)
{
int status;
UINT value = 0;
@@ -1077,7 +1053,7 @@ OUT:
return status;
}
-static int bcm_parse_target_params(PMINI_ADAPTER Adapter)
+static int bcm_parse_target_params(struct bcm_mini_adapter *Adapter)
{
struct file *flp = NULL;
mm_segment_t oldfs = {0};
@@ -1128,7 +1104,7 @@ static int bcm_parse_target_params(PMINI_ADAPTER Adapter)
return STATUS_SUCCESS;
}
-void beceem_parse_target_struct(PMINI_ADAPTER Adapter)
+void beceem_parse_target_struct(struct bcm_mini_adapter *Adapter)
{
UINT uiHostDrvrCfg6 = 0, uiEEPROMFlag = 0;
@@ -1186,7 +1162,7 @@ void beceem_parse_target_struct(PMINI_ADAPTER Adapter)
doPowerAutoCorrection(Adapter);
}
-static VOID doPowerAutoCorrection(PMINI_ADAPTER psAdapter)
+static VOID doPowerAutoCorrection(struct bcm_mini_adapter *psAdapter)
{
UINT reporting_mode;
@@ -1217,45 +1193,6 @@ static VOID doPowerAutoCorrection(PMINI_ADAPTER psAdapter)
}
}
-#if 0
-static unsigned char *ReadMacAddrEEPROM(PMINI_ADAPTER Adapter, ulong dwAddress)
-{
- int status = 0, i = 0;
- unsigned int temp = 0;
- unsigned char *pucmacaddr = kmalloc(MAC_ADDRESS_SIZE, GFP_KERNEL);
- int bytes;
-
- if (!pucmacaddr) {
- BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "No Buffers to Read the EEPROM Address\n");
- return NULL;
- }
-
- dwAddress |= 0x5b000000;
- status = wrmalt(Adapter, EEPROM_COMMAND_Q_REG, (PUINT)&dwAddress, sizeof(UINT));
- if (status != STATUS_SUCCESS) {
- BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "wrm Failed..\n");
- kfree(pucmacaddr);
- pucmacaddr = NULL;
- goto OUT;
- }
-
- for (i = 0; i < MAC_ADDRESS_SIZE; i++) {
- bytes = rdmalt(Adapter, EEPROM_READ_DATA_Q_REG, &temp, sizeof(temp));
- if (bytes < 0) {
- status = bytes;
- BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "rdm Failed..\n");
- kfree(pucmacaddr);
- pucmacaddr = NULL;
- goto OUT;
- }
- pucmacaddr[i] = temp & 0xff;
- BCM_DEBUG_PRINT(Adapter, DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "%x\n", pucmacaddr[i]);
- }
-OUT:
- return pucmacaddr;
-}
-#endif
-
static void convertEndian(B_UINT8 rwFlag, PUINT puiBuffer, UINT uiByteCount)
{
UINT uiIndex = 0;
@@ -1269,16 +1206,13 @@ static void convertEndian(B_UINT8 rwFlag, PUINT puiBuffer, UINT uiByteCount)
}
}
-#define CACHE_ADDRESS_MASK 0x80000000
-#define UNCACHE_ADDRESS_MASK 0xa0000000
-
-int rdm(PMINI_ADAPTER Adapter, UINT uiAddress, PCHAR pucBuff, size_t sSize)
+int rdm(struct bcm_mini_adapter *Adapter, UINT uiAddress, PCHAR pucBuff, size_t sSize)
{
return Adapter->interface_rdm(Adapter->pvInterfaceAdapter,
uiAddress, pucBuff, sSize);
}
-int wrm(PMINI_ADAPTER Adapter, UINT uiAddress, PCHAR pucBuff, size_t sSize)
+int wrm(struct bcm_mini_adapter *Adapter, UINT uiAddress, PCHAR pucBuff, size_t sSize)
{
int iRetVal;
@@ -1287,13 +1221,13 @@ int wrm(PMINI_ADAPTER Adapter, UINT uiAddress, PCHAR pucBuff, size_t sSize)
return iRetVal;
}
-int wrmalt(PMINI_ADAPTER Adapter, UINT uiAddress, PUINT pucBuff, size_t size)
+int wrmalt(struct bcm_mini_adapter *Adapter, UINT uiAddress, PUINT pucBuff, size_t size)
{
convertEndian(RWM_WRITE, pucBuff, size);
return wrm(Adapter, uiAddress, (PUCHAR)pucBuff, size);
}
-int rdmalt(PMINI_ADAPTER Adapter, UINT uiAddress, PUINT pucBuff, size_t size)
+int rdmalt(struct bcm_mini_adapter *Adapter, UINT uiAddress, PUINT pucBuff, size_t size)
{
INT uiRetVal = 0;
@@ -1303,7 +1237,7 @@ int rdmalt(PMINI_ADAPTER Adapter, UINT uiAddress, PUINT pucBuff, size_t size)
return uiRetVal;
}
-int wrmWithLock(PMINI_ADAPTER Adapter, UINT uiAddress, PCHAR pucBuff, size_t sSize)
+int wrmWithLock(struct bcm_mini_adapter *Adapter, UINT uiAddress, PCHAR pucBuff, size_t sSize)
{
INT status = STATUS_SUCCESS;
down(&Adapter->rdmwrmsync);
@@ -1322,7 +1256,7 @@ exit:
return status;
}
-int wrmaltWithLock(PMINI_ADAPTER Adapter, UINT uiAddress, PUINT pucBuff, size_t size)
+int wrmaltWithLock(struct bcm_mini_adapter *Adapter, UINT uiAddress, PUINT pucBuff, size_t size)
{
int iRetVal = STATUS_SUCCESS;
@@ -1342,7 +1276,7 @@ exit:
return iRetVal;
}
-int rdmaltWithLock(PMINI_ADAPTER Adapter, UINT uiAddress, PUINT pucBuff, size_t size)
+int rdmaltWithLock(struct bcm_mini_adapter *Adapter, UINT uiAddress, PUINT pucBuff, size_t size)
{
INT uiRetVal = STATUS_SUCCESS;
@@ -1361,7 +1295,7 @@ exit:
return uiRetVal;
}
-static VOID HandleShutDownModeWakeup(PMINI_ADAPTER Adapter)
+static VOID HandleShutDownModeWakeup(struct bcm_mini_adapter *Adapter)
{
int clear_abort_pattern = 0, Status = 0;
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, MP_SHUTDOWN, DBG_LVL_ALL, "====>\n");
@@ -1390,13 +1324,13 @@ static VOID HandleShutDownModeWakeup(PMINI_ADAPTER Adapter)
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, MP_SHUTDOWN, DBG_LVL_ALL, "<====\n");
}
-static VOID SendShutModeResponse(PMINI_ADAPTER Adapter)
+static VOID SendShutModeResponse(struct bcm_mini_adapter *Adapter)
{
- CONTROL_MESSAGE stShutdownResponse;
+ struct bcm_link_request stShutdownResponse;
UINT NVMAccess = 0, lowPwrAbortMsg = 0;
UINT Status = 0;
- memset(&stShutdownResponse, 0, sizeof(CONTROL_MESSAGE));
+ memset(&stShutdownResponse, 0, sizeof(struct bcm_link_request));
stShutdownResponse.Leader.Status = LINK_UP_CONTROL_REQ;
stShutdownResponse.Leader.PLength = 8; /* 8 bytes; */
stShutdownResponse.szData[0] = LINK_UP_ACK;
@@ -1474,7 +1408,7 @@ static VOID SendShutModeResponse(PMINI_ADAPTER Adapter)
}
}
-static void HandleShutDownModeRequest(PMINI_ADAPTER Adapter, PUCHAR pucBuffer)
+static void HandleShutDownModeRequest(struct bcm_mini_adapter *Adapter, PUCHAR pucBuffer)
{
B_UINT32 uiResetValue = 0;
@@ -1503,7 +1437,7 @@ static void HandleShutDownModeRequest(PMINI_ADAPTER Adapter, PUCHAR pucBuffer)
return;
}
-VOID ResetCounters(PMINI_ADAPTER Adapter)
+VOID ResetCounters(struct bcm_mini_adapter *Adapter)
{
beceem_protocol_reset(Adapter);
Adapter->CurrNumRecvDescs = 0;
@@ -1519,7 +1453,7 @@ VOID ResetCounters(PMINI_ADAPTER Adapter)
Adapter->bShutStatus = FALSE;
}
-S_CLASSIFIER_RULE *GetFragIPClsEntry(PMINI_ADAPTER Adapter, USHORT usIpIdentification, ULONG SrcIP)
+struct bcm_classifier_rule *GetFragIPClsEntry(struct bcm_mini_adapter *Adapter, USHORT usIpIdentification, ULONG SrcIP)
{
UINT uiIndex = 0;
for (uiIndex = 0; uiIndex < MAX_FRAGMENTEDIP_CLASSIFICATION_ENTRIES; uiIndex++) {
@@ -1533,18 +1467,18 @@ S_CLASSIFIER_RULE *GetFragIPClsEntry(PMINI_ADAPTER Adapter, USHORT usIpIdentific
return NULL;
}
-void AddFragIPClsEntry(PMINI_ADAPTER Adapter, PS_FRAGMENTED_PACKET_INFO psFragPktInfo)
+void AddFragIPClsEntry(struct bcm_mini_adapter *Adapter, struct bcm_fragmented_packet_info *psFragPktInfo)
{
UINT uiIndex = 0;
for (uiIndex = 0; uiIndex < MAX_FRAGMENTEDIP_CLASSIFICATION_ENTRIES; uiIndex++) {
if (!Adapter->astFragmentedPktClassifierTable[uiIndex].bUsed) {
- memcpy(&Adapter->astFragmentedPktClassifierTable[uiIndex], psFragPktInfo, sizeof(S_FRAGMENTED_PACKET_INFO));
+ memcpy(&Adapter->astFragmentedPktClassifierTable[uiIndex], psFragPktInfo, sizeof(struct bcm_fragmented_packet_info));
break;
}
}
}
-void DelFragIPClsEntry(PMINI_ADAPTER Adapter, USHORT usIpIdentification, ULONG SrcIp)
+void DelFragIPClsEntry(struct bcm_mini_adapter *Adapter, USHORT usIpIdentification, ULONG SrcIp)
{
UINT uiIndex = 0;
for (uiIndex = 0; uiIndex < MAX_FRAGMENTEDIP_CLASSIFICATION_ENTRIES; uiIndex++) {
@@ -1552,11 +1486,11 @@ void DelFragIPClsEntry(PMINI_ADAPTER Adapter, USHORT usIpIdentification, ULONG S
(Adapter->astFragmentedPktClassifierTable[uiIndex].usIpIdentification == usIpIdentification) &&
(Adapter->astFragmentedPktClassifierTable[uiIndex].ulSrcIpAddress == SrcIp))
- memset(&Adapter->astFragmentedPktClassifierTable[uiIndex], 0, sizeof(S_FRAGMENTED_PACKET_INFO));
+ memset(&Adapter->astFragmentedPktClassifierTable[uiIndex], 0, sizeof(struct bcm_fragmented_packet_info));
}
}
-void update_per_cid_rx(PMINI_ADAPTER Adapter)
+void update_per_cid_rx(struct bcm_mini_adapter *Adapter)
{
UINT qindex = 0;
@@ -1580,7 +1514,7 @@ void update_per_cid_rx(PMINI_ADAPTER Adapter)
Adapter->liDrainCalculated = jiffies;
}
-void update_per_sf_desc_cnts(PMINI_ADAPTER Adapter)
+void update_per_sf_desc_cnts(struct bcm_mini_adapter *Adapter)
{
INT iIndex = 0;
u32 uibuff[MAX_TARGET_DSX_BUFFERS];
@@ -1606,7 +1540,7 @@ void update_per_sf_desc_cnts(PMINI_ADAPTER Adapter)
atomic_set(&Adapter->uiMBupdate, FALSE);
}
-void flush_queue(PMINI_ADAPTER Adapter, UINT iQIndex)
+void flush_queue(struct bcm_mini_adapter *Adapter, UINT iQIndex)
{
struct sk_buff *PacketToDrop = NULL;
struct net_device_stats *netstats = &Adapter->dev->stats;
@@ -1630,7 +1564,7 @@ void flush_queue(PMINI_ADAPTER Adapter, UINT iQIndex)
spin_unlock_bh(&Adapter->PackInfo[iQIndex].SFQueueLock);
}
-static void beceem_protocol_reset(PMINI_ADAPTER Adapter)
+static void beceem_protocol_reset(struct bcm_mini_adapter *Adapter)
{
int i;
if (netif_msg_link(Adapter))
@@ -1652,7 +1586,7 @@ static void beceem_protocol_reset(PMINI_ADAPTER Adapter)
if (Adapter->TimerActive == TRUE)
Adapter->TimerActive = FALSE;
- memset(Adapter->astFragmentedPktClassifierTable, 0, sizeof(S_FRAGMENTED_PACKET_INFO) * MAX_FRAGMENTEDIP_CLASSIFICATION_ENTRIES);
+ memset(Adapter->astFragmentedPktClassifierTable, 0, sizeof(struct bcm_fragmented_packet_info) * MAX_FRAGMENTEDIP_CLASSIFICATION_ENTRIES);
for (i = 0; i < HiPriority; i++) {
/* resetting only the first size (S_MIBS_SERVICEFLOW_TABLE) for the SF. */
diff --git a/drivers/staging/bcm/PHSDefines.h b/drivers/staging/bcm/PHSDefines.h
index eed4cfc6e538..6016fc502d2d 100644
--- a/drivers/staging/bcm/PHSDefines.h
+++ b/drivers/staging/bcm/PHSDefines.h
@@ -27,7 +27,6 @@
#define PHS_BUFFER_SIZE 1532
-//#define MAX_PHS_LENGTHS 100
#define MAX_PHSRULE_PER_SF 20
#define MAX_SERVICEFLOWS 17
diff --git a/drivers/staging/bcm/PHSModule.c b/drivers/staging/bcm/PHSModule.c
index 4aa2b71a40eb..479574234e4c 100644
--- a/drivers/staging/bcm/PHSModule.c
+++ b/drivers/staging/bcm/PHSModule.c
@@ -54,11 +54,11 @@ Function: PHSTransmit
Description: This routine handle PHS(Payload Header Suppression for Tx path.
It extracts a fragment of the NDIS_PACKET containing the header
- to be suppressed.It then supresses the header by invoking PHS exported compress routine.
- The header data after supression is copied back to the NDIS_PACKET.
+ to be suppressed. It then suppresses the header by invoking PHS exported compress routine.
+ The header data after suppression is copied back to the NDIS_PACKET.
-Input parameters: IN PMINI_ADAPTER Adapter - Miniport Adapter Context
+Input parameters: IN struct bcm_mini_adapter *Adapter - Miniport Adapter Context
IN Packet - NDIS packet containing data to be transmitted
IN USHORT Vcid - vcid pertaining to connection on which the packet is being sent.Used to
identify PHS rule to be applied.
@@ -69,7 +69,7 @@ Return: STATUS_SUCCESS - If the send was successful.
Other - If an error occured.
*/
-int PHSTransmit(PMINI_ADAPTER Adapter,
+int PHSTransmit(struct bcm_mini_adapter *Adapter,
struct sk_buff **pPacket,
USHORT Vcid,
B_UINT16 uiClassifierRuleID,
@@ -84,10 +84,10 @@ int PHSTransmit(PMINI_ADAPTER Adapter,
UINT unPHSNewPktHeaderLen = 0;
/* Pointer to PHS IN Hdr Buffer */
PUCHAR pucPHSPktHdrInBuf =
- Adapter->stPhsTxContextInfo.ucaHdrSupressionInBuf;
+ Adapter->stPhsTxContextInfo.ucaHdrSuppressionInBuf;
/* Pointer to PHS OUT Hdr Buffer */
PUCHAR pucPHSPktHdrOutBuf =
- Adapter->stPhsTxContextInfo.ucaHdrSupressionOutBuf;
+ Adapter->stPhsTxContextInfo.ucaHdrSuppressionOutBuf;
UINT usPacketType;
UINT BytesToRemove=0;
BOOLEAN bPHSI = 0;
@@ -101,7 +101,7 @@ int PHSTransmit(PMINI_ADAPTER Adapter,
if(!bEthCSSupport)
BytesToRemove=ETH_HLEN;
/*
- Accumulate the header upto the size we support supression
+ Accumulate the header upto the size we support suppression
from NDIS packet
*/
@@ -125,7 +125,7 @@ int PHSTransmit(PMINI_ADAPTER Adapter,
{
- // Step 2 Supress Header using PHS and fill into intermediate ucaPHSPktHdrOutBuf.
+ // Step 2 Suppress Header using PHS and fill into intermediate ucaPHSPktHdrOutBuf.
// Suppress only if IP Header and PHS Enabled For the Service Flow
if(((usPacketType == ETHERNET_FRAMETYPE_IPV4) ||
(usPacketType == ETHERNET_FRAMETYPE_IPV6)) &&
@@ -209,7 +209,7 @@ int PHSTransmit(PMINI_ADAPTER Adapter,
return STATUS_SUCCESS;
}
-int PHSReceive(PMINI_ADAPTER Adapter,
+int PHSReceive(struct bcm_mini_adapter *Adapter,
USHORT usVcid,
struct sk_buff *packet,
UINT *punPacketLen,
@@ -217,7 +217,7 @@ int PHSReceive(PMINI_ADAPTER Adapter,
UINT bHeaderSuppressionEnabled)
{
u32 nStandardPktHdrLen = 0;
- u32 nTotalsupressedPktHdrBytes = 0;
+ u32 nTotalsuppressedPktHdrBytes = 0;
int ulPhsStatus = 0;
PUCHAR pucInBuff = NULL ;
UINT TotalBytesAdded = 0;
@@ -235,11 +235,11 @@ int PHSReceive(PMINI_ADAPTER Adapter,
usVcid,
pucInBuff,
Adapter->ucaPHSPktRestoreBuf,
- &nTotalsupressedPktHdrBytes,
+ &nTotalsuppressedPktHdrBytes,
&nStandardPktHdrLen);
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_RECEIVE,DBG_LVL_ALL,"\nSupressed PktHdrLen : 0x%x Restored PktHdrLen : 0x%x",
- nTotalsupressedPktHdrBytes,nStandardPktHdrLen);
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_RECEIVE,DBG_LVL_ALL,"\nSuppressed PktHdrLen : 0x%x Restored PktHdrLen : 0x%x",
+ nTotalsuppressedPktHdrBytes,nStandardPktHdrLen);
if(ulPhsStatus != STATUS_PHS_COMPRESSED)
{
@@ -248,7 +248,7 @@ int PHSReceive(PMINI_ADAPTER Adapter,
}
else
{
- TotalBytesAdded = nStandardPktHdrLen - nTotalsupressedPktHdrBytes - PHSI_LEN;
+ TotalBytesAdded = nStandardPktHdrLen - nTotalsuppressedPktHdrBytes - PHSI_LEN;
if(TotalBytesAdded)
{
if(skb_headroom(packet) >= (SKB_RESERVE_ETHERNET_HEADER + TotalBytesAdded))
@@ -273,7 +273,7 @@ int PHSReceive(PMINI_ADAPTER Adapter,
void DumpFullPacket(UCHAR *pBuf,UINT nPktLen)
{
- PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev);
+ struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev);
BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL,"Dumping Data Packet");
BCM_DEBUG_PRINT_BUFFER(Adapter,DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL,pBuf,nPktLen);
}
@@ -291,7 +291,7 @@ void DumpFullPacket(UCHAR *pBuf,UINT nPktLen)
// TRUE(1) -If allocation of memory was success full.
// FALSE -If allocation of memory fails.
//-----------------------------------------------------------------------------
-int phs_init(PPHS_DEVICE_EXTENSION pPhsdeviceExtension,PMINI_ADAPTER Adapter)
+int phs_init(PPHS_DEVICE_EXTENSION pPhsdeviceExtension, struct bcm_mini_adapter *Adapter)
{
int i;
S_SERVICEFLOW_TABLE *pstServiceFlowTable;
@@ -398,7 +398,7 @@ ULONG PhsUpdateClassifierRule(IN void* pvContext,
ULONG lStatus =0;
UINT nSFIndex =0 ;
S_SERVICEFLOW_ENTRY *pstServiceFlowEntry = NULL;
- PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev);
+ struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev);
@@ -462,7 +462,7 @@ ULONG PhsDeletePHSRule(IN void* pvContext,IN B_UINT16 uiVcid,IN B_UINT8 u8PHSI)
UINT nSFIndex =0, nClsidIndex =0 ;
S_SERVICEFLOW_ENTRY *pstServiceFlowEntry = NULL;
S_CLASSIFIER_TABLE *pstClassifierRulesTable = NULL;
- PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev);
+ struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev);
PPHS_DEVICE_EXTENSION pDeviceExtension= (PPHS_DEVICE_EXTENSION)pvContext;
@@ -528,7 +528,7 @@ ULONG PhsDeleteClassifierRule(IN void* pvContext,IN B_UINT16 uiVcid ,IN B_UINT16
UINT nSFIndex =0, nClsidIndex =0 ;
S_SERVICEFLOW_ENTRY *pstServiceFlowEntry = NULL;
S_CLASSIFIER_ENTRY *pstClassifierEntry = NULL;
- PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev);
+ struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev);
PPHS_DEVICE_EXTENSION pDeviceExtension= (PPHS_DEVICE_EXTENSION)pvContext;
if(pDeviceExtension)
@@ -592,7 +592,7 @@ ULONG PhsDeleteSFRules(IN void* pvContext,IN B_UINT16 uiVcid)
UINT nSFIndex =0, nClsidIndex =0 ;
S_SERVICEFLOW_ENTRY *pstServiceFlowEntry = NULL;
S_CLASSIFIER_TABLE *pstClassifierRulesTable = NULL;
- PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev);
+ struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev);
PPHS_DEVICE_EXTENSION pDeviceExtension= (PPHS_DEVICE_EXTENSION)pvContext;
BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL,"====> \n");
@@ -684,7 +684,7 @@ ULONG PhsCompress(IN void* pvContext,
S_CLASSIFIER_ENTRY *pstClassifierEntry = NULL;
S_PHS_RULE *pstPhsRule = NULL;
ULONG lStatus =0;
- PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev);
+ struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev);
@@ -778,7 +778,7 @@ ULONG PhsDeCompress(IN void* pvContext,
S_SERVICEFLOW_ENTRY *pstServiceFlowEntry = NULL;
S_PHS_RULE *pstPhsRule = NULL;
UINT phsi;
- PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev);
+ struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev);
PPHS_DEVICE_EXTENSION pDeviceExtension=
(PPHS_DEVICE_EXTENSION)pvContext;
@@ -847,7 +847,7 @@ ULONG PhsDeCompress(IN void* pvContext,
static void free_phs_serviceflow_rules(S_SERVICEFLOW_TABLE *psServiceFlowRulesTable)
{
int i,j;
- PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev);
+ struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev);
BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL, "=======>\n");
if(psServiceFlowRulesTable)
@@ -1057,7 +1057,7 @@ UINT CreateClassiferToPHSRuleMapping(IN B_UINT16 uiVcid,
UINT uiStatus =PHS_SUCCESS;
UINT nClassifierIndex = 0;
S_CLASSIFIER_TABLE *psaClassifiertable = NULL;
- PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev);
+ struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev);
psaClassifiertable = pstServiceFlowEntry->pstClassifierTable;
BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL, "==>");
@@ -1148,7 +1148,7 @@ static UINT CreateClassifierPHSRule(IN B_UINT16 uiClsId,
BOOLEAN bFreeEntryFound = FALSE;
S_CLASSIFIER_ENTRY *psClassifierRules = NULL;
UINT nStatus = PHS_SUCCESS;
- PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev);
+ struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev);
BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL,"Inside CreateClassifierPHSRule");
if(psaClassifiertable == NULL)
{
@@ -1259,7 +1259,7 @@ static UINT UpdateClassifierPHSRule(IN B_UINT16 uiClsId,
S_PHS_RULE *pstAddPhsRule = NULL;
UINT nPhsRuleIndex = 0;
BOOLEAN bPHSRuleOrphaned = FALSE;
- PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev);
+ struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev);
psPhsRule->u8RefCnt =0;
/* Step 1 Deref Any Exisiting PHS Rule in this classifier Entry*/
@@ -1334,7 +1334,7 @@ static BOOLEAN DerefPhsRule(IN B_UINT16 uiClsId,S_CLASSIFIER_TABLE *psaClassifi
void DumpPhsRules(PPHS_DEVICE_EXTENSION pDeviceExtension)
{
int i,j,k,l;
- PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev);
+ struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev);
BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "\n Dumping PHS Rules : \n");
for(i=0;i<MAX_SERVICEFLOWS;i++)
{
@@ -1415,7 +1415,7 @@ int phs_decompress(unsigned char *in_buf,unsigned char *out_buf,
int bit,i=0;
unsigned char *phsf,*phsm;
int in_buf_len = *header_size-1;
- PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev);
+ struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev);
in_buf++;
BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_RECEIVE,DBG_LVL_ALL,"====>\n");
*header_size = 0;
@@ -1494,8 +1494,8 @@ static int phs_compress(S_PHS_RULE *phs_rule,unsigned char *in_buf
,unsigned char *out_buf,UINT *header_size,UINT *new_header_size)
{
unsigned char *old_addr = out_buf;
- int supress = 0;
- PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev);
+ int suppress = 0;
+ struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev);
if(phs_rule == NULL)
{
BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL,"\nphs_compress(): phs_rule null!");
@@ -1514,10 +1514,10 @@ static int phs_compress(S_PHS_RULE *phs_rule,unsigned char *in_buf
}
//To copy PHSI
out_buf++;
- supress = verify_suppress_phsf(in_buf,out_buf,phs_rule->u8PHSF,
+ suppress = verify_suppress_phsf(in_buf,out_buf,phs_rule->u8PHSF,
phs_rule->u8PHSM, phs_rule->u8PHSS, phs_rule->u8PHSV,new_header_size);
- if(supress == STATUS_PHS_COMPRESSED)
+ if(suppress == STATUS_PHS_COMPRESSED)
{
*old_addr = (unsigned char)phs_rule->u8PHSI;
BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL,"\nCOMP:In phs_compress phsi %d",phs_rule->u8PHSI);
@@ -1527,7 +1527,7 @@ static int phs_compress(S_PHS_RULE *phs_rule,unsigned char *in_buf
*old_addr = ZERO_PHSI;
BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL,"\nCOMP:In phs_compress PHSV Verification failed");
}
- return supress;
+ return suppress;
}
@@ -1557,7 +1557,7 @@ static int verify_suppress_phsf(unsigned char *in_buffer,unsigned char *out_buff
{
unsigned int size=0;
int bit,i=0;
- PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev);
+ struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev);
BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL,"\nCOMP:In verify_phsf PHSM - 0x%X",*phsm);
diff --git a/drivers/staging/bcm/PHSModule.h b/drivers/staging/bcm/PHSModule.h
index c629585d0a8c..b5f21157ac47 100644
--- a/drivers/staging/bcm/PHSModule.h
+++ b/drivers/staging/bcm/PHSModule.h
@@ -1,7 +1,7 @@
#ifndef BCM_MINIPORT_PHSMODULE_H
#define BCM_MINIPORT_PHSMODULE_H
-int PHSTransmit(PMINI_ADAPTER Adapter,
+int PHSTransmit(struct bcm_mini_adapter *Adapter,
struct sk_buff **pPacket,
USHORT Vcid,
B_UINT16 uiClassifierRuleID,
@@ -9,7 +9,7 @@ int PHSTransmit(PMINI_ADAPTER Adapter,
PUINT PacketLen,
UCHAR bEthCSSupport);
-int PHSReceive(PMINI_ADAPTER Adapter,
+int PHSReceive(struct bcm_mini_adapter *Adapter,
USHORT usVcid,
struct sk_buff *packet,
UINT *punPacketLen,
@@ -25,7 +25,7 @@ void DumpFullPacket(UCHAR *pBuf,UINT nPktLen);
void DumpPhsRules(PPHS_DEVICE_EXTENSION pDeviceExtension);
-int phs_init(PPHS_DEVICE_EXTENSION pPhsdeviceExtension,PMINI_ADAPTER Adapter);
+int phs_init(PPHS_DEVICE_EXTENSION pPhsdeviceExtension,struct bcm_mini_adapter *Adapter);
int PhsCleanup(PPHS_DEVICE_EXTENSION pPHSDeviceExt);
diff --git a/drivers/staging/bcm/Protocol.h b/drivers/staging/bcm/Protocol.h
index b8a4009bdf0c..562d4dd81a7c 100644
--- a/drivers/staging/bcm/Protocol.h
+++ b/drivers/staging/bcm/Protocol.h
@@ -55,7 +55,7 @@ typedef struct _S_ETHCS_PKT_INFO
typedef struct _ETH_CS_802_Q_FRAME
{
- ETH_HEADER_STRUC EThHdr;
+ struct bcm_eth_header EThHdr;
USHORT UserPriority:3;
USHORT CFI:1;
USHORT VLANID:12;
@@ -64,7 +64,7 @@ typedef struct _ETH_CS_802_Q_FRAME
typedef struct _ETH_CS_802_LLC_FRAME
{
- ETH_HEADER_STRUC EThHdr;
+ struct bcm_eth_header EThHdr;
unsigned char DSAP;
unsigned char SSAP;
unsigned char Control;
@@ -72,7 +72,7 @@ typedef struct _ETH_CS_802_LLC_FRAME
typedef struct _ETH_CS_802_LLC_SNAP_FRAME
{
- ETH_HEADER_STRUC EThHdr;
+ struct bcm_eth_header EThHdr;
unsigned char DSAP;
unsigned char SSAP;
unsigned char Control;
@@ -82,7 +82,7 @@ typedef struct _ETH_CS_802_LLC_SNAP_FRAME
typedef struct _ETH_CS_ETH2_FRAME
{
- ETH_HEADER_STRUC EThHdr;
+ struct bcm_eth_header EThHdr;
} __attribute__((packed)) ETH_CS_ETH2_FRAME;
#define ETHERNET_FRAMETYPE_IPV4 ntohs(0x0800)
diff --git a/drivers/staging/bcm/Prototypes.h b/drivers/staging/bcm/Prototypes.h
index b80b806c90a3..3c8cc5ba2e2e 100644
--- a/drivers/staging/bcm/Prototypes.h
+++ b/drivers/staging/bcm/Prototypes.h
@@ -1,172 +1,172 @@
#ifndef _PROTOTYPES_H_
#define _PROTOTYPES_H_
-VOID LinkControlResponseMessage(PMINI_ADAPTER Adapter, PUCHAR pucBuffer);
+VOID LinkControlResponseMessage(struct bcm_mini_adapter *Adapter, PUCHAR pucBuffer);
-VOID StatisticsResponse(PMINI_ADAPTER Adapter,PVOID pvBuffer);
+VOID StatisticsResponse(struct bcm_mini_adapter *Adapter,PVOID pvBuffer);
-VOID IdleModeResponse(PMINI_ADAPTER Adapter,PUINT puiBuffer);
+VOID IdleModeResponse(struct bcm_mini_adapter *Adapter,PUINT puiBuffer);
-int control_packet_handler (PMINI_ADAPTER Adapter);
+int control_packet_handler (struct bcm_mini_adapter *Adapter);
-VOID DeleteAllClassifiersForSF(PMINI_ADAPTER Adapter,UINT uiSearchRuleIndex);
+VOID DeleteAllClassifiersForSF(struct bcm_mini_adapter *Adapter,UINT uiSearchRuleIndex);
-VOID flush_all_queues(PMINI_ADAPTER Adapter);
+VOID flush_all_queues(struct bcm_mini_adapter *Adapter);
-int register_control_device_interface(PMINI_ADAPTER ps_adapter);
+int register_control_device_interface(struct bcm_mini_adapter *ps_adapter);
-void unregister_control_device_interface(PMINI_ADAPTER Adapter);
+void unregister_control_device_interface(struct bcm_mini_adapter *Adapter);
-INT CopyBufferToControlPacket(PMINI_ADAPTER Adapter,/**<Logical Adapter*/
+INT CopyBufferToControlPacket(struct bcm_mini_adapter *Adapter,/**<Logical Adapter*/
PVOID ioBuffer/**<Control Packet Buffer*/
);
-VOID SortPackInfo(PMINI_ADAPTER Adapter);
+VOID SortPackInfo(struct bcm_mini_adapter *Adapter);
-VOID SortClassifiers(PMINI_ADAPTER Adapter);
+VOID SortClassifiers(struct bcm_mini_adapter *Adapter);
-VOID flush_all_queues(PMINI_ADAPTER Adapter);
+VOID flush_all_queues(struct bcm_mini_adapter *Adapter);
-VOID PruneQueueAllSF(PMINI_ADAPTER Adapter);
+VOID PruneQueueAllSF(struct bcm_mini_adapter *Adapter);
-INT SearchSfid(PMINI_ADAPTER Adapter,UINT uiSfid);
+INT SearchSfid(struct bcm_mini_adapter *Adapter,UINT uiSfid);
-USHORT ClassifyPacket(PMINI_ADAPTER Adapter,struct sk_buff* skb);
+USHORT ClassifyPacket(struct bcm_mini_adapter *Adapter,struct sk_buff* skb);
-BOOLEAN MatchSrcPort(S_CLASSIFIER_RULE *pstClassifierRule,USHORT ushSrcPort);
-BOOLEAN MatchDestPort(S_CLASSIFIER_RULE *pstClassifierRule,USHORT ushSrcPort);
-BOOLEAN MatchProtocol(S_CLASSIFIER_RULE *pstClassifierRule,UCHAR ucProtocol);
+BOOLEAN MatchSrcPort(struct bcm_classifier_rule *pstClassifierRule,USHORT ushSrcPort);
+BOOLEAN MatchDestPort(struct bcm_classifier_rule *pstClassifierRule,USHORT ushSrcPort);
+BOOLEAN MatchProtocol(struct bcm_classifier_rule *pstClassifierRule,UCHAR ucProtocol);
-INT SetupNextSend(PMINI_ADAPTER Adapter, /**<Logical Adapter*/
+INT SetupNextSend(struct bcm_mini_adapter *Adapter, /**<Logical Adapter*/
struct sk_buff *Packet, /**<data buffer*/
USHORT Vcid) ;
-VOID LinkMessage(PMINI_ADAPTER Adapter);
+VOID LinkMessage(struct bcm_mini_adapter *Adapter);
-VOID transmit_packets(PMINI_ADAPTER Adapter);
+VOID transmit_packets(struct bcm_mini_adapter *Adapter);
-INT SendControlPacket(PMINI_ADAPTER Adapter, /**<Logical Adapter*/
+INT SendControlPacket(struct bcm_mini_adapter *Adapter, /**<Logical Adapter*/
char *pControlPacket/**<Control Packet*/
);
-int register_networkdev(PMINI_ADAPTER Adapter);
-void unregister_networkdev(PMINI_ADAPTER Adapter);
+int register_networkdev(struct bcm_mini_adapter *Adapter);
+void unregister_networkdev(struct bcm_mini_adapter *Adapter);
-INT AllocAdapterDsxBuffer(PMINI_ADAPTER Adapter);
+INT AllocAdapterDsxBuffer(struct bcm_mini_adapter *Adapter);
-VOID AdapterFree(PMINI_ADAPTER Adapter);
+VOID AdapterFree(struct bcm_mini_adapter *Adapter);
-INT FreeAdapterDsxBuffer(PMINI_ADAPTER Adapter);
+INT FreeAdapterDsxBuffer(struct bcm_mini_adapter *Adapter);
-int tx_pkt_handler(PMINI_ADAPTER Adapter);
+int tx_pkt_handler(struct bcm_mini_adapter *Adapter);
-int reset_card_proc(PMINI_ADAPTER Adapter );
+int reset_card_proc(struct bcm_mini_adapter *Adapter );
-int run_card_proc(PMINI_ADAPTER Adapter );
+int run_card_proc(struct bcm_mini_adapter *Adapter );
-int InitCardAndDownloadFirmware(PMINI_ADAPTER ps_adapter);
+int InitCardAndDownloadFirmware(struct bcm_mini_adapter *ps_adapter);
-INT ReadMacAddressFromNVM(PMINI_ADAPTER Adapter);
+INT ReadMacAddressFromNVM(struct bcm_mini_adapter *Adapter);
-int register_control_device_interface(PMINI_ADAPTER ps_adapter);
+int register_control_device_interface(struct bcm_mini_adapter *ps_adapter);
-void DumpPackInfo(PMINI_ADAPTER Adapter);
+void DumpPackInfo(struct bcm_mini_adapter *Adapter);
-int rdm(PMINI_ADAPTER Adapter, UINT uiAddress, PCHAR pucBuff, size_t size);
+int rdm(struct bcm_mini_adapter *Adapter, UINT uiAddress, PCHAR pucBuff, size_t size);
-int wrm(PMINI_ADAPTER Adapter, UINT uiAddress, PCHAR pucBuff, size_t size);
+int wrm(struct bcm_mini_adapter *Adapter, UINT uiAddress, PCHAR pucBuff, size_t size);
-int wrmalt (PMINI_ADAPTER Adapter, UINT uiAddress, PUINT pucBuff, size_t sSize);
+int wrmalt (struct bcm_mini_adapter *Adapter, UINT uiAddress, PUINT pucBuff, size_t sSize);
-int rdmalt (PMINI_ADAPTER Adapter, UINT uiAddress, PUINT pucBuff, size_t sSize);
+int rdmalt (struct bcm_mini_adapter *Adapter, UINT uiAddress, PUINT pucBuff, size_t sSize);
-int get_dsx_sf_data_to_application(PMINI_ADAPTER Adapter, UINT uiSFId, void __user * user_buffer);
+int get_dsx_sf_data_to_application(struct bcm_mini_adapter *Adapter, UINT uiSFId, void __user * user_buffer);
-void SendIdleModeResponse(PMINI_ADAPTER Adapter);
+void SendIdleModeResponse(struct bcm_mini_adapter *Adapter);
-int ProcessGetHostMibs(PMINI_ADAPTER Adapter, S_MIBS_HOST_STATS_MIBS *buf);
-void GetDroppedAppCntrlPktMibs(S_MIBS_HOST_STATS_MIBS *ioBuffer, PPER_TARANG_DATA pTarang);
-void beceem_parse_target_struct(PMINI_ADAPTER Adapter);
+int ProcessGetHostMibs(struct bcm_mini_adapter *Adapter, S_MIBS_HOST_STATS_MIBS *buf);
+void GetDroppedAppCntrlPktMibs(S_MIBS_HOST_STATS_MIBS *ioBuffer, struct bcm_tarang_data *pTarang);
+void beceem_parse_target_struct(struct bcm_mini_adapter *Adapter);
-int bcm_ioctl_fw_download(PMINI_ADAPTER Adapter, FIRMWARE_INFO *psFwInfo);
+int bcm_ioctl_fw_download(struct bcm_mini_adapter *Adapter, struct bcm_firmware_info *psFwInfo);
-void CopyMIBSExtendedSFParameters(PMINI_ADAPTER Adapter,
+void CopyMIBSExtendedSFParameters(struct bcm_mini_adapter *Adapter,
CServiceFlowParamSI *psfLocalSet, UINT uiSearchRuleIndex);
-VOID ResetCounters(PMINI_ADAPTER Adapter);
+VOID ResetCounters(struct bcm_mini_adapter *Adapter);
-int InitLedSettings(PMINI_ADAPTER Adapter);
+int InitLedSettings(struct bcm_mini_adapter *Adapter);
-S_CLASSIFIER_RULE *GetFragIPClsEntry(PMINI_ADAPTER Adapter,USHORT usIpIdentification,ULONG SrcIP);
+struct bcm_classifier_rule *GetFragIPClsEntry(struct bcm_mini_adapter *Adapter,USHORT usIpIdentification,ULONG SrcIP);
-void AddFragIPClsEntry(PMINI_ADAPTER Adapter,PS_FRAGMENTED_PACKET_INFO psFragPktInfo);
+void AddFragIPClsEntry(struct bcm_mini_adapter *Adapter, struct bcm_fragmented_packet_info *psFragPktInfo);
-void DelFragIPClsEntry(PMINI_ADAPTER Adapter,USHORT usIpIdentification,ULONG SrcIp);
+void DelFragIPClsEntry(struct bcm_mini_adapter *Adapter,USHORT usIpIdentification,ULONG SrcIp);
-void update_per_cid_rx (PMINI_ADAPTER Adapter);
+void update_per_cid_rx (struct bcm_mini_adapter *Adapter);
-void update_per_sf_desc_cnts( PMINI_ADAPTER Adapter);
+void update_per_sf_desc_cnts( struct bcm_mini_adapter *Adapter);
-void ClearTargetDSXBuffer(PMINI_ADAPTER Adapter,B_UINT16 TID,BOOLEAN bFreeAll);
+void ClearTargetDSXBuffer(struct bcm_mini_adapter *Adapter,B_UINT16 TID,BOOLEAN bFreeAll);
-void flush_queue(PMINI_ADAPTER Adapter, UINT iQIndex);
+void flush_queue(struct bcm_mini_adapter *Adapter, UINT iQIndex);
INT flushAllAppQ(VOID);
INT BeceemEEPROMBulkRead(
- PMINI_ADAPTER Adapter,
+ struct bcm_mini_adapter *Adapter,
PUINT pBuffer,
UINT uiOffset,
UINT uiNumBytes);
-INT WriteBeceemEEPROM(PMINI_ADAPTER Adapter,UINT uiEEPROMOffset, UINT uiData);
+INT WriteBeceemEEPROM(struct bcm_mini_adapter *Adapter,UINT uiEEPROMOffset, UINT uiData);
-INT PropagateCalParamsFromFlashToMemory(PMINI_ADAPTER Adapter);
+INT PropagateCalParamsFromFlashToMemory(struct bcm_mini_adapter *Adapter);
INT BeceemEEPROMBulkWrite(
- PMINI_ADAPTER Adapter,
+ struct bcm_mini_adapter *Adapter,
PUCHAR pBuffer,
UINT uiOffset,
UINT uiNumBytes,
BOOLEAN bVerify);
-INT ReadBeceemEEPROM(PMINI_ADAPTER Adapter,UINT dwAddress, UINT *pdwData);
+INT ReadBeceemEEPROM(struct bcm_mini_adapter *Adapter,UINT dwAddress, UINT *pdwData);
INT BeceemNVMRead(
- PMINI_ADAPTER Adapter,
+ struct bcm_mini_adapter *Adapter,
PUINT pBuffer,
UINT uiOffset,
UINT uiNumBytes);
INT BeceemNVMWrite(
- PMINI_ADAPTER Adapter,
+ struct bcm_mini_adapter *Adapter,
PUINT pBuffer,
UINT uiOffset,
UINT uiNumBytes,
BOOLEAN bVerify);
-INT BcmInitNVM(PMINI_ADAPTER Adapter);
+INT BcmInitNVM(struct bcm_mini_adapter *Adapter);
-INT BcmUpdateSectorSize(PMINI_ADAPTER Adapter,UINT uiSectorSize);
-BOOLEAN IsSectionExistInFlash(PMINI_ADAPTER Adapter, FLASH2X_SECTION_VAL section);
+INT BcmUpdateSectorSize(struct bcm_mini_adapter *Adapter,UINT uiSectorSize);
+BOOLEAN IsSectionExistInFlash(struct bcm_mini_adapter *Adapter, FLASH2X_SECTION_VAL section);
-INT BcmGetFlash2xSectionalBitMap(PMINI_ADAPTER Adapter, PFLASH2X_BITMAP psFlash2xBitMap);
+INT BcmGetFlash2xSectionalBitMap(struct bcm_mini_adapter *Adapter, PFLASH2X_BITMAP psFlash2xBitMap);
INT BcmFlash2xBulkWrite(
- PMINI_ADAPTER Adapter,
+ struct bcm_mini_adapter *Adapter,
PUINT pBuffer,
FLASH2X_SECTION_VAL eFlashSectionVal,
UINT uiOffset,
@@ -174,45 +174,45 @@ INT BcmFlash2xBulkWrite(
UINT bVerify);
INT BcmFlash2xBulkRead(
- PMINI_ADAPTER Adapter,
+ struct bcm_mini_adapter *Adapter,
PUINT pBuffer,
FLASH2X_SECTION_VAL eFlashSectionVal,
UINT uiOffsetWithinSectionVal,
UINT uiNumBytes);
-INT BcmGetSectionValStartOffset(PMINI_ADAPTER Adapter, FLASH2X_SECTION_VAL eFlashSectionVal);
+INT BcmGetSectionValStartOffset(struct bcm_mini_adapter *Adapter, FLASH2X_SECTION_VAL eFlashSectionVal);
-INT BcmSetActiveSection(PMINI_ADAPTER Adapter, FLASH2X_SECTION_VAL eFlash2xSectVal);
-INT BcmAllocFlashCSStructure(PMINI_ADAPTER psAdapter);
-INT BcmDeAllocFlashCSStructure(PMINI_ADAPTER psAdapter);
+INT BcmSetActiveSection(struct bcm_mini_adapter *Adapter, FLASH2X_SECTION_VAL eFlash2xSectVal);
+INT BcmAllocFlashCSStructure(struct bcm_mini_adapter *psAdapter);
+INT BcmDeAllocFlashCSStructure(struct bcm_mini_adapter *psAdapter);
-INT BcmCopyISO(PMINI_ADAPTER Adapter, FLASH2X_COPY_SECTION sCopySectStrut);
-INT BcmFlash2xCorruptSig(PMINI_ADAPTER Adapter, FLASH2X_SECTION_VAL eFlash2xSectionVal);
-INT BcmFlash2xWriteSig(PMINI_ADAPTER Adapter, FLASH2X_SECTION_VAL eFlashSectionVal);
-INT validateFlash2xReadWrite(PMINI_ADAPTER Adapter, PFLASH2X_READWRITE psFlash2xReadWrite);
-INT IsFlash2x(PMINI_ADAPTER Adapter);
-INT BcmCopySection(PMINI_ADAPTER Adapter,
+INT BcmCopyISO(struct bcm_mini_adapter *Adapter, FLASH2X_COPY_SECTION sCopySectStrut);
+INT BcmFlash2xCorruptSig(struct bcm_mini_adapter *Adapter, FLASH2X_SECTION_VAL eFlash2xSectionVal);
+INT BcmFlash2xWriteSig(struct bcm_mini_adapter *Adapter, FLASH2X_SECTION_VAL eFlashSectionVal);
+INT validateFlash2xReadWrite(struct bcm_mini_adapter *Adapter, PFLASH2X_READWRITE psFlash2xReadWrite);
+INT IsFlash2x(struct bcm_mini_adapter *Adapter);
+INT BcmCopySection(struct bcm_mini_adapter *Adapter,
FLASH2X_SECTION_VAL SrcSection,
FLASH2X_SECTION_VAL DstSection,
UINT offset,
UINT numOfBytes);
-BOOLEAN IsNonCDLessDevice(PMINI_ADAPTER Adapter);
+BOOLEAN IsNonCDLessDevice(struct bcm_mini_adapter *Adapter);
-VOID OverrideServiceFlowParams(PMINI_ADAPTER Adapter,PUINT puiBuffer);
+VOID OverrideServiceFlowParams(struct bcm_mini_adapter *Adapter,PUINT puiBuffer);
-int wrmaltWithLock (PMINI_ADAPTER Adapter, UINT uiAddress, PUINT pucBuff, size_t sSize);
-int rdmaltWithLock (PMINI_ADAPTER Adapter, UINT uiAddress, PUINT pucBuff, size_t sSize);
+int wrmaltWithLock (struct bcm_mini_adapter *Adapter, UINT uiAddress, PUINT pucBuff, size_t sSize);
+int rdmaltWithLock (struct bcm_mini_adapter *Adapter, UINT uiAddress, PUINT pucBuff, size_t sSize);
-int wrmWithLock(PMINI_ADAPTER Adapter, UINT uiAddress, PCHAR pucBuff, size_t size);
-INT buffDnldVerify(PMINI_ADAPTER Adapter, unsigned char *mappedbuffer, unsigned int u32FirmwareLength,
+int wrmWithLock(struct bcm_mini_adapter *Adapter, UINT uiAddress, PCHAR pucBuff, size_t size);
+INT buffDnldVerify(struct bcm_mini_adapter *Adapter, unsigned char *mappedbuffer, unsigned int u32FirmwareLength,
unsigned long u32StartingAddress);
VOID putUsbSuspend(struct work_struct *work);
-BOOLEAN IsReqGpioIsLedInNVM(PMINI_ADAPTER Adapter, UINT gpios);
+BOOLEAN IsReqGpioIsLedInNVM(struct bcm_mini_adapter *Adapter, UINT gpios);
#endif
diff --git a/drivers/staging/bcm/Qos.c b/drivers/staging/bcm/Qos.c
index c97020f0fb6a..1b857bd887f0 100644
--- a/drivers/staging/bcm/Qos.c
+++ b/drivers/staging/bcm/Qos.c
@@ -4,13 +4,13 @@ This file contains the routines related to Quality of Service.
*/
#include "headers.h"
-static void EThCSGetPktInfo(PMINI_ADAPTER Adapter,PVOID pvEthPayload,PS_ETHCS_PKT_INFO pstEthCsPktInfo);
-static BOOLEAN EThCSClassifyPkt(PMINI_ADAPTER Adapter,struct sk_buff* skb,PS_ETHCS_PKT_INFO pstEthCsPktInfo,S_CLASSIFIER_RULE *pstClassifierRule, B_UINT8 EthCSCupport);
+static void EThCSGetPktInfo(struct bcm_mini_adapter *Adapter,PVOID pvEthPayload,PS_ETHCS_PKT_INFO pstEthCsPktInfo);
+static BOOLEAN EThCSClassifyPkt(struct bcm_mini_adapter *Adapter,struct sk_buff* skb,PS_ETHCS_PKT_INFO pstEthCsPktInfo,struct bcm_classifier_rule *pstClassifierRule, B_UINT8 EthCSCupport);
-static USHORT IpVersion4(PMINI_ADAPTER Adapter, struct iphdr *iphd,
- S_CLASSIFIER_RULE *pstClassifierRule );
+static USHORT IpVersion4(struct bcm_mini_adapter *Adapter, struct iphdr *iphd,
+ struct bcm_classifier_rule *pstClassifierRule );
-static VOID PruneQueue(PMINI_ADAPTER Adapter, INT iIndex);
+static VOID PruneQueue(struct bcm_mini_adapter *Adapter, INT iIndex);
/*******************************************************************
@@ -24,11 +24,11 @@ static VOID PruneQueue(PMINI_ADAPTER Adapter, INT iIndex);
*
* Returns - TRUE(If address matches) else FAIL .
*********************************************************************/
-BOOLEAN MatchSrcIpAddress(S_CLASSIFIER_RULE *pstClassifierRule,ULONG ulSrcIP)
+BOOLEAN MatchSrcIpAddress(struct bcm_classifier_rule *pstClassifierRule,ULONG ulSrcIP)
{
UCHAR ucLoopIndex=0;
- PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev);
+ struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev);
ulSrcIP=ntohl(ulSrcIP);
if(0 == pstClassifierRule->ucIPSourceAddressLength)
@@ -58,10 +58,10 @@ BOOLEAN MatchSrcIpAddress(S_CLASSIFIER_RULE *pstClassifierRule,ULONG ulSrcIP)
*
* Returns - TRUE(If address matches) else FAIL .
*********************************************************************/
-BOOLEAN MatchDestIpAddress(S_CLASSIFIER_RULE *pstClassifierRule,ULONG ulDestIP)
+BOOLEAN MatchDestIpAddress(struct bcm_classifier_rule *pstClassifierRule,ULONG ulDestIP)
{
UCHAR ucLoopIndex=0;
- PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev);
+ struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev);
ulDestIP=ntohl(ulDestIP);
if(0 == pstClassifierRule->ucIPDestinationAddressLength)
@@ -91,10 +91,10 @@ BOOLEAN MatchDestIpAddress(S_CLASSIFIER_RULE *pstClassifierRule,ULONG ulDestIP)
*
* Returns - TRUE(If address matches) else FAIL.
**************************************************************************/
-BOOLEAN MatchTos(S_CLASSIFIER_RULE *pstClassifierRule,UCHAR ucTypeOfService)
+BOOLEAN MatchTos(struct bcm_classifier_rule *pstClassifierRule,UCHAR ucTypeOfService)
{
- PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev);
+ struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev);
if( 3 != pstClassifierRule->ucIPTypeOfServiceLength )
return TRUE;
@@ -117,10 +117,10 @@ BOOLEAN MatchTos(S_CLASSIFIER_RULE *pstClassifierRule,UCHAR ucTypeOfService)
*
* Returns - TRUE(If address matches) else FAIL.
****************************************************************************/
-BOOLEAN MatchProtocol(S_CLASSIFIER_RULE *pstClassifierRule,UCHAR ucProtocol)
+BOOLEAN MatchProtocol(struct bcm_classifier_rule *pstClassifierRule,UCHAR ucProtocol)
{
UCHAR ucLoopIndex=0;
- PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev);
+ struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev);
if(0 == pstClassifierRule->ucProtocolLength)
return TRUE;
for(ucLoopIndex=0;ucLoopIndex<pstClassifierRule->ucProtocolLength;ucLoopIndex++)
@@ -146,11 +146,11 @@ BOOLEAN MatchProtocol(S_CLASSIFIER_RULE *pstClassifierRule,UCHAR ucProtocol)
*
* Returns - TRUE(If address matches) else FAIL.
***************************************************************************/
-BOOLEAN MatchSrcPort(S_CLASSIFIER_RULE *pstClassifierRule,USHORT ushSrcPort)
+BOOLEAN MatchSrcPort(struct bcm_classifier_rule *pstClassifierRule,USHORT ushSrcPort)
{
UCHAR ucLoopIndex=0;
- PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev);
+ struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev);
if(0 == pstClassifierRule->ucSrcPortRangeLength)
@@ -178,10 +178,10 @@ BOOLEAN MatchSrcPort(S_CLASSIFIER_RULE *pstClassifierRule,USHORT ushSrcPort)
*
* Returns - TRUE(If address matches) else FAIL.
***************************************************************************/
-BOOLEAN MatchDestPort(S_CLASSIFIER_RULE *pstClassifierRule,USHORT ushDestPort)
+BOOLEAN MatchDestPort(struct bcm_classifier_rule *pstClassifierRule,USHORT ushDestPort)
{
UCHAR ucLoopIndex=0;
- PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev);
+ struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev);
if(0 == pstClassifierRule->ucDestPortRangeLength)
return TRUE;
@@ -204,9 +204,9 @@ BOOLEAN MatchDestPort(S_CLASSIFIER_RULE *pstClassifierRule,USHORT ushDestPort)
Compares IPV4 Ip address and port number
@return Queue Index.
*/
-static USHORT IpVersion4(PMINI_ADAPTER Adapter,
+static USHORT IpVersion4(struct bcm_mini_adapter *Adapter,
struct iphdr *iphd,
- S_CLASSIFIER_RULE *pstClassifierRule )
+ struct bcm_classifier_rule *pstClassifierRule)
{
xporthdr *xprt_hdr=NULL;
BOOLEAN bClassificationSucceed=FALSE;
@@ -302,7 +302,7 @@ static USHORT IpVersion4(PMINI_ADAPTER Adapter,
return bClassificationSucceed;
}
-VOID PruneQueueAllSF(PMINI_ADAPTER Adapter)
+VOID PruneQueueAllSF(struct bcm_mini_adapter *Adapter)
{
UINT iIndex = 0;
@@ -323,7 +323,7 @@ is less than number of bytes in the queue. If so -
drops packets from the Head till the number of bytes is
less than or equal to max queue size for the queue.
*/
-static VOID PruneQueue(PMINI_ADAPTER Adapter, INT iIndex)
+static VOID PruneQueue(struct bcm_mini_adapter *Adapter, INT iIndex)
{
struct sk_buff* PacketToDrop=NULL;
struct net_device_stats *netstats;
@@ -392,7 +392,7 @@ static VOID PruneQueue(PMINI_ADAPTER Adapter, INT iIndex)
BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, PRUNE_QUEUE, DBG_LVL_ALL, "<=====");
}
-VOID flush_all_queues(PMINI_ADAPTER Adapter)
+VOID flush_all_queues(struct bcm_mini_adapter *Adapter)
{
INT iQIndex;
UINT uiTotalPacketLength;
@@ -442,10 +442,10 @@ VOID flush_all_queues(PMINI_ADAPTER Adapter)
BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "<=====");
}
-USHORT ClassifyPacket(PMINI_ADAPTER Adapter,struct sk_buff* skb)
+USHORT ClassifyPacket(struct bcm_mini_adapter *Adapter,struct sk_buff* skb)
{
INT uiLoopIndex=0;
- S_CLASSIFIER_RULE *pstClassifierRule = NULL;
+ struct bcm_classifier_rule *pstClassifierRule = NULL;
S_ETHCS_PKT_INFO stEthCsPktInfo;
PVOID pvEThPayload = NULL;
struct iphdr *pIpHeader = NULL;
@@ -631,7 +631,7 @@ USHORT ClassifyPacket(PMINI_ADAPTER Adapter,struct sk_buff* skb)
if(bFragmentedPkt && (usCurrFragment == 0))
{
//First Fragment of Fragmented Packet. Create Frag CLS Entry
- S_FRAGMENTED_PACKET_INFO stFragPktInfo;
+ struct bcm_fragmented_packet_info stFragPktInfo;
stFragPktInfo.bUsed = TRUE;
stFragPktInfo.ulSrcIpAddress = pIpHeader->saddr;
stFragPktInfo.usIpIdentification = pIpHeader->id;
@@ -649,10 +649,10 @@ USHORT ClassifyPacket(PMINI_ADAPTER Adapter,struct sk_buff* skb)
return INVALID_QUEUE_INDEX;
}
-static BOOLEAN EthCSMatchSrcMACAddress(S_CLASSIFIER_RULE *pstClassifierRule,PUCHAR Mac)
+static BOOLEAN EthCSMatchSrcMACAddress(struct bcm_classifier_rule *pstClassifierRule,PUCHAR Mac)
{
UINT i=0;
- PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev);
+ struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev);
if(pstClassifierRule->ucEthCSSrcMACLen==0)
return TRUE;
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "%s \n",__FUNCTION__);
@@ -666,10 +666,10 @@ static BOOLEAN EthCSMatchSrcMACAddress(S_CLASSIFIER_RULE *pstClassifierRule,PUCH
return TRUE;
}
-static BOOLEAN EthCSMatchDestMACAddress(S_CLASSIFIER_RULE *pstClassifierRule,PUCHAR Mac)
+static BOOLEAN EthCSMatchDestMACAddress(struct bcm_classifier_rule *pstClassifierRule,PUCHAR Mac)
{
UINT i=0;
- PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev);
+ struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev);
if(pstClassifierRule->ucEthCSDestMACLen==0)
return TRUE;
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "%s \n",__FUNCTION__);
@@ -683,9 +683,9 @@ static BOOLEAN EthCSMatchDestMACAddress(S_CLASSIFIER_RULE *pstClassifierRule,PUC
return TRUE;
}
-static BOOLEAN EthCSMatchEThTypeSAP(S_CLASSIFIER_RULE *pstClassifierRule,struct sk_buff* skb,PS_ETHCS_PKT_INFO pstEthCsPktInfo)
+static BOOLEAN EthCSMatchEThTypeSAP(struct bcm_classifier_rule *pstClassifierRule,struct sk_buff* skb,PS_ETHCS_PKT_INFO pstEthCsPktInfo)
{
- PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev);
+ struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev);
if((pstClassifierRule->ucEtherTypeLen==0)||
(pstClassifierRule->au8EthCSEtherType[0] == 0))
return TRUE;
@@ -718,12 +718,12 @@ static BOOLEAN EthCSMatchEThTypeSAP(S_CLASSIFIER_RULE *pstClassifierRule,struct
}
-static BOOLEAN EthCSMatchVLANRules(S_CLASSIFIER_RULE *pstClassifierRule,struct sk_buff* skb,PS_ETHCS_PKT_INFO pstEthCsPktInfo)
+static BOOLEAN EthCSMatchVLANRules(struct bcm_classifier_rule *pstClassifierRule,struct sk_buff* skb,PS_ETHCS_PKT_INFO pstEthCsPktInfo)
{
BOOLEAN bClassificationSucceed = FALSE;
USHORT usVLANID;
B_UINT8 uPriority = 0;
- PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev);
+ struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev);
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "%s CLS UserPrio:%x CLS VLANID:%x\n",__FUNCTION__,ntohs(*((USHORT *)pstClassifierRule->usUserPriority)),pstClassifierRule->usVLANID);
@@ -733,7 +733,7 @@ static BOOLEAN EthCSMatchVLANRules(S_CLASSIFIER_RULE *pstClassifierRule,struct s
if(pstEthCsPktInfo->eNwpktEthFrameType!=eEth802QVLANFrame)
return FALSE;
- uPriority = (ntohs(*(USHORT *)(skb->data + sizeof(ETH_HEADER_STRUC))) & 0xF000) >> 13;
+ uPriority = (ntohs(*(USHORT *)(skb->data + sizeof(struct bcm_eth_header))) & 0xF000) >> 13;
if((uPriority >= pstClassifierRule->usUserPriority[0]) && (uPriority <= pstClassifierRule->usUserPriority[1]))
bClassificationSucceed = TRUE;
@@ -751,7 +751,7 @@ static BOOLEAN EthCSMatchVLANRules(S_CLASSIFIER_RULE *pstClassifierRule,struct s
if(pstEthCsPktInfo->eNwpktEthFrameType!=eEth802QVLANFrame)
return FALSE;
- usVLANID = ntohs(*(USHORT *)(skb->data + sizeof(ETH_HEADER_STRUC))) & 0xFFF;
+ usVLANID = ntohs(*(USHORT *)(skb->data + sizeof(struct bcm_eth_header))) & 0xFFF;
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "%s Pkt VLANID %x Priority: %d\n",__FUNCTION__,usVLANID, uPriority);
@@ -768,18 +768,18 @@ static BOOLEAN EthCSMatchVLANRules(S_CLASSIFIER_RULE *pstClassifierRule,struct s
}
-static BOOLEAN EThCSClassifyPkt(PMINI_ADAPTER Adapter,struct sk_buff* skb,
+static BOOLEAN EThCSClassifyPkt(struct bcm_mini_adapter *Adapter,struct sk_buff* skb,
PS_ETHCS_PKT_INFO pstEthCsPktInfo,
- S_CLASSIFIER_RULE *pstClassifierRule,
+ struct bcm_classifier_rule *pstClassifierRule,
B_UINT8 EthCSCupport)
{
BOOLEAN bClassificationSucceed = FALSE;
- bClassificationSucceed = EthCSMatchSrcMACAddress(pstClassifierRule,((ETH_HEADER_STRUC *)(skb->data))->au8SourceAddress);
+ bClassificationSucceed = EthCSMatchSrcMACAddress(pstClassifierRule,((struct bcm_eth_header *)(skb->data))->au8SourceAddress);
if(!bClassificationSucceed)
return FALSE;
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "ETH CS SrcMAC Matched\n");
- bClassificationSucceed = EthCSMatchDestMACAddress(pstClassifierRule,((ETH_HEADER_STRUC*)(skb->data))->au8DestinationAddress);
+ bClassificationSucceed = EthCSMatchDestMACAddress(pstClassifierRule,((struct bcm_eth_header *)(skb->data))->au8DestinationAddress);
if(!bClassificationSucceed)
return FALSE;
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "ETH CS DestMAC Matched\n");
@@ -801,10 +801,10 @@ static BOOLEAN EThCSClassifyPkt(PMINI_ADAPTER Adapter,struct sk_buff* skb,
return bClassificationSucceed;
}
-static void EThCSGetPktInfo(PMINI_ADAPTER Adapter,PVOID pvEthPayload,
+static void EThCSGetPktInfo(struct bcm_mini_adapter *Adapter,PVOID pvEthPayload,
PS_ETHCS_PKT_INFO pstEthCsPktInfo)
{
- USHORT u16Etype = ntohs(((ETH_HEADER_STRUC*)pvEthPayload)->u16Etype);
+ USHORT u16Etype = ntohs(((struct bcm_eth_header *)pvEthPayload)->u16Etype);
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "EthCSGetPktInfo : Eth Hdr Type : %X\n",u16Etype);
if(u16Etype > 0x5dc)
@@ -845,7 +845,7 @@ static void EThCSGetPktInfo(PMINI_ADAPTER Adapter,PVOID pvEthPayload,
else
pstEthCsPktInfo->eNwpktIPFrameType = eNonIPPacket;
- pstEthCsPktInfo->usEtherType = ((ETH_HEADER_STRUC*)pvEthPayload)->u16Etype;
+ pstEthCsPktInfo->usEtherType = ((struct bcm_eth_header *)pvEthPayload)->u16Etype;
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "EthCsPktInfo->eNwpktIPFrameType : %x\n",pstEthCsPktInfo->eNwpktIPFrameType);
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "EthCsPktInfo->eNwpktEthFrameType : %x\n",pstEthCsPktInfo->eNwpktEthFrameType);
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "EthCsPktInfo->usEtherType : %x\n",pstEthCsPktInfo->usEtherType);
diff --git a/drivers/staging/bcm/Transmit.c b/drivers/staging/bcm/Transmit.c
index d5e4a7404f71..5e603ce76fea 100644
--- a/drivers/staging/bcm/Transmit.c
+++ b/drivers/staging/bcm/Transmit.c
@@ -41,9 +41,9 @@ SendPacketFromQueue->SetupNextSend->bcm_cmd53
This function dispatches control packet to the h/w interface
@return zero(success) or -ve value(failure)
*/
-INT SendControlPacket(PMINI_ADAPTER Adapter, char *pControlPacket)
+INT SendControlPacket(struct bcm_mini_adapter *Adapter, char *pControlPacket)
{
- PLEADER PLeader = (PLEADER)pControlPacket;
+ struct bcm_leader *PLeader = (struct bcm_leader *)pControlPacket;
BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL, "Tx");
if(!pControlPacket || !Adapter)
@@ -84,13 +84,13 @@ This function despatches the IP packets with the given vcid
to the target via the host h/w interface.
@return zero(success) or -ve value(failure)
*/
-INT SetupNextSend(PMINI_ADAPTER Adapter, struct sk_buff *Packet, USHORT Vcid)
+INT SetupNextSend(struct bcm_mini_adapter *Adapter, struct sk_buff *Packet, USHORT Vcid)
{
int status=0;
BOOLEAN bHeaderSupressionEnabled = FALSE;
B_UINT16 uiClassifierRuleID;
u16 QueueIndex = skb_get_queue_mapping(Packet);
- LEADER Leader={0};
+ struct bcm_leader Leader={0};
if(Packet->len > MAX_DEVICE_DESC_SIZE)
{
@@ -143,7 +143,7 @@ INT SetupNextSend(PMINI_ADAPTER Adapter, struct sk_buff *Packet, USHORT Vcid)
else
{
Leader.PLength = Packet->len - ETH_HLEN;
- memcpy((LEADER*)skb_pull(Packet, (ETH_HLEN - LEADER_SIZE)), &Leader, LEADER_SIZE);
+ memcpy((struct bcm_leader *)skb_pull(Packet, (ETH_HLEN - LEADER_SIZE)), &Leader, LEADER_SIZE);
}
status = Adapter->interface_transmit(Adapter->pvInterfaceAdapter,
@@ -180,7 +180,7 @@ errExit:
return status;
}
-static int tx_pending(PMINI_ADAPTER Adapter)
+static int tx_pending(struct bcm_mini_adapter *Adapter)
{
return (atomic_read(&Adapter->TxPktAvail)
&& MINIMUM_PENDING_DESCRIPTORS < atomic_read(&Adapter->CurrNumFreeTxDesc))
@@ -191,7 +191,7 @@ static int tx_pending(PMINI_ADAPTER Adapter)
@ingroup tx_functions
Transmit thread
*/
-int tx_pkt_handler(PMINI_ADAPTER Adapter /**< pointer to adapter object*/
+int tx_pkt_handler(struct bcm_mini_adapter *Adapter /**< pointer to adapter object*/
)
{
int status = 0;
diff --git a/drivers/staging/bcm/cntrl_SignalingInterface.h b/drivers/staging/bcm/cntrl_SignalingInterface.h
index ab131806e2c9..7619e4b819bd 100644
--- a/drivers/staging/bcm/cntrl_SignalingInterface.h
+++ b/drivers/staging/bcm/cntrl_SignalingInterface.h
@@ -117,7 +117,7 @@ typedef struct _stPhsRuleSI {
B_UINT8 u8PHSM[MAX_PHS_LENGTHS];
/** 8bit Total number of bytes to be suppressed for the Service Flow*/
B_UINT8 u8PHSS;
- /** 8bit Indicates whether or not Packet Header contents need to be verified prior to supression */
+ /** 8bit Indicates whether or not Packet Header contents need to be verified prior to suppression */
B_UINT8 u8PHSV;
/** Vendor Specific PHS param Length Of The Service Flow*/
B_UINT8 u8VendorSpecificPHSParamsLength;
diff --git a/drivers/staging/bcm/hostmibs.c b/drivers/staging/bcm/hostmibs.c
index 101c4e31249e..08d13a4dfd70 100644
--- a/drivers/staging/bcm/hostmibs.c
+++ b/drivers/staging/bcm/hostmibs.c
@@ -9,7 +9,7 @@
#include "headers.h"
-INT ProcessGetHostMibs(PMINI_ADAPTER Adapter, S_MIBS_HOST_STATS_MIBS *pstHostMibs)
+INT ProcessGetHostMibs(struct bcm_mini_adapter *Adapter, S_MIBS_HOST_STATS_MIBS *pstHostMibs)
{
S_SERVICEFLOW_ENTRY *pstServiceFlowEntry = NULL;
S_PHS_RULE *pstPhsRule = NULL;
@@ -94,14 +94,14 @@ INT ProcessGetHostMibs(PMINI_ADAPTER Adapter, S_MIBS_HOST_STATS_MIBS *pstHostMib
return STATUS_SUCCESS;
}
-VOID GetDroppedAppCntrlPktMibs(S_MIBS_HOST_STATS_MIBS *pstHostMibs, const PPER_TARANG_DATA pTarang)
+VOID GetDroppedAppCntrlPktMibs(S_MIBS_HOST_STATS_MIBS *pstHostMibs, struct bcm_tarang_data *pTarang)
{
memcpy(&(pstHostMibs->stDroppedAppCntrlMsgs),
&(pTarang->stDroppedAppCntrlMsgs),
sizeof(S_MIBS_DROPPED_APP_CNTRL_MESSAGES));
}
-VOID CopyMIBSExtendedSFParameters(PMINI_ADAPTER Adapter, CServiceFlowParamSI *psfLocalSet, UINT uiSearchRuleIndex)
+VOID CopyMIBSExtendedSFParameters(struct bcm_mini_adapter *Adapter, CServiceFlowParamSI *psfLocalSet, UINT uiSearchRuleIndex)
{
S_MIBS_EXTSERVICEFLOW_PARAMETERS *t = &Adapter->PackInfo[uiSearchRuleIndex].stMibsExtServiceFlowTable;
diff --git a/drivers/staging/bcm/led_control.c b/drivers/staging/bcm/led_control.c
index c7f488629722..252a1b31d618 100644
--- a/drivers/staging/bcm/led_control.c
+++ b/drivers/staging/bcm/led_control.c
@@ -13,7 +13,7 @@ static B_UINT16 CFG_CalculateChecksum(B_UINT8 *pu8Buffer, B_UINT32 u32Size)
return u16CheckSum;
}
-BOOLEAN IsReqGpioIsLedInNVM(PMINI_ADAPTER Adapter, UINT gpios)
+BOOLEAN IsReqGpioIsLedInNVM(struct bcm_mini_adapter *Adapter, UINT gpios)
{
INT Status;
Status = (Adapter->gpioBitMap & gpios) ^ gpios;
@@ -23,7 +23,7 @@ BOOLEAN IsReqGpioIsLedInNVM(PMINI_ADAPTER Adapter, UINT gpios)
return TRUE;
}
-static INT LED_Blink(PMINI_ADAPTER Adapter, UINT GPIO_Num, UCHAR uiLedIndex,
+static INT LED_Blink(struct bcm_mini_adapter *Adapter, UINT GPIO_Num, UCHAR uiLedIndex,
ULONG timeout, INT num_of_time, LedEventInfo_t currdriverstate)
{
int Status = STATUS_SUCCESS;
@@ -95,7 +95,7 @@ static INT ScaleRateofTransfer(ULONG rate)
-static INT LED_Proportional_Blink(PMINI_ADAPTER Adapter, UCHAR GPIO_Num_tx,
+static INT LED_Proportional_Blink(struct bcm_mini_adapter *Adapter, UCHAR GPIO_Num_tx,
UCHAR uiTxLedIndex, UCHAR GPIO_Num_rx, UCHAR uiRxLedIndex,
LedEventInfo_t currdriverstate)
{
@@ -261,7 +261,7 @@ static INT LED_Proportional_Blink(PMINI_ADAPTER Adapter, UCHAR GPIO_Num_tx,
* <OSAL_STATUS_CODE>
* -----------------------------------------------------------------------------
*/
-static INT ValidateDSDParamsChecksum(PMINI_ADAPTER Adapter, ULONG ulParamOffset,
+static INT ValidateDSDParamsChecksum(struct bcm_mini_adapter *Adapter, ULONG ulParamOffset,
USHORT usParamLen)
{
INT Status = STATUS_SUCCESS;
@@ -347,7 +347,7 @@ exit:
* <OSAL_STATUS_CODE>
* -----------------------------------------------------------------------------
*/
-static INT ValidateHWParmStructure(PMINI_ADAPTER Adapter, ULONG ulHwParamOffset)
+static INT ValidateHWParmStructure(struct bcm_mini_adapter *Adapter, ULONG ulHwParamOffset)
{
INT Status = STATUS_SUCCESS;
@@ -371,7 +371,7 @@ static INT ValidateHWParmStructure(PMINI_ADAPTER Adapter, ULONG ulHwParamOffset)
return Status;
} /* ValidateHWParmStructure() */
-static int ReadLEDInformationFromEEPROM(PMINI_ADAPTER Adapter,
+static int ReadLEDInformationFromEEPROM(struct bcm_mini_adapter *Adapter,
UCHAR GPIO_Array[])
{
int Status = STATUS_SUCCESS;
@@ -477,7 +477,7 @@ static int ReadLEDInformationFromEEPROM(PMINI_ADAPTER Adapter,
}
-static int ReadConfigFileStructure(PMINI_ADAPTER Adapter,
+static int ReadConfigFileStructure(struct bcm_mini_adapter *Adapter,
BOOLEAN *bEnableThread)
{
int Status = STATUS_SUCCESS;
@@ -580,7 +580,7 @@ static int ReadConfigFileStructure(PMINI_ADAPTER Adapter,
*
* -----------------------------------------------------------------------------
*/
-static VOID LedGpioInit(PMINI_ADAPTER Adapter)
+static VOID LedGpioInit(struct bcm_mini_adapter *Adapter)
{
UINT uiResetValue = 0;
UINT uiIndex = 0;
@@ -605,7 +605,7 @@ static VOID LedGpioInit(PMINI_ADAPTER Adapter)
Adapter->LEDInfo.bIdle_led_off = FALSE;
}
-static INT BcmGetGPIOPinInfo(PMINI_ADAPTER Adapter, UCHAR *GPIO_num_tx,
+static INT BcmGetGPIOPinInfo(struct bcm_mini_adapter *Adapter, UCHAR *GPIO_num_tx,
UCHAR *GPIO_num_rx, UCHAR *uiLedTxIndex, UCHAR *uiLedRxIndex,
LedEventInfo_t currdriverstate)
{
@@ -645,7 +645,7 @@ static INT BcmGetGPIOPinInfo(PMINI_ADAPTER Adapter, UCHAR *GPIO_num_tx,
}
return STATUS_SUCCESS;
}
-static VOID LEDControlThread(PMINI_ADAPTER Adapter)
+static VOID LEDControlThread(struct bcm_mini_adapter *Adapter)
{
UINT uiIndex = 0;
UCHAR GPIO_num = 0;
@@ -857,7 +857,7 @@ static VOID LEDControlThread(PMINI_ADAPTER Adapter)
Adapter->LEDInfo.led_thread_running = BCM_LED_THREAD_DISABLED;
}
-int InitLedSettings(PMINI_ADAPTER Adapter)
+int InitLedSettings(struct bcm_mini_adapter *Adapter)
{
int Status = STATUS_SUCCESS;
BOOLEAN bEnableThread = TRUE;
diff --git a/drivers/staging/bcm/nvm.c b/drivers/staging/bcm/nvm.c
index 7d703cb3c5e0..b179dbab93b5 100644
--- a/drivers/staging/bcm/nvm.c
+++ b/drivers/staging/bcm/nvm.c
@@ -2,195 +2,181 @@
#define DWORD unsigned int
-static INT BcmDoChipSelect(PMINI_ADAPTER Adapter, UINT offset);
-static INT BcmGetActiveDSD(PMINI_ADAPTER Adapter);
-static INT BcmGetActiveISO(PMINI_ADAPTER Adapter);
-static UINT BcmGetEEPROMSize(PMINI_ADAPTER Adapter);
-static INT BcmGetFlashCSInfo(PMINI_ADAPTER Adapter);
-static UINT BcmGetFlashSectorSize(PMINI_ADAPTER Adapter, UINT FlashSectorSizeSig, UINT FlashSectorSize);
-
-static VOID BcmValidateNvmType(PMINI_ADAPTER Adapter);
-static INT BcmGetNvmSize(PMINI_ADAPTER Adapter);
-static UINT BcmGetFlashSize(PMINI_ADAPTER Adapter);
-static NVM_TYPE BcmGetNvmType(PMINI_ADAPTER Adapter);
-
-static INT BcmGetSectionValEndOffset(PMINI_ADAPTER Adapter, FLASH2X_SECTION_VAL eFlash2xSectionVal);
-
-static B_UINT8 IsOffsetWritable(PMINI_ADAPTER Adapter, UINT uiOffset);
-static INT IsSectionWritable(PMINI_ADAPTER Adapter, FLASH2X_SECTION_VAL Section);
-static INT IsSectionExistInVendorInfo(PMINI_ADAPTER Adapter, FLASH2X_SECTION_VAL section);
-
-static INT ReadDSDPriority(PMINI_ADAPTER Adapter, FLASH2X_SECTION_VAL dsd);
-static INT ReadDSDSignature(PMINI_ADAPTER Adapter, FLASH2X_SECTION_VAL dsd);
-static INT ReadISOPriority(PMINI_ADAPTER Adapter, FLASH2X_SECTION_VAL iso);
-static INT ReadISOSignature(PMINI_ADAPTER Adapter, FLASH2X_SECTION_VAL iso);
-
-static INT CorruptDSDSig(PMINI_ADAPTER Adapter, FLASH2X_SECTION_VAL eFlash2xSectionVal);
-static INT CorruptISOSig(PMINI_ADAPTER Adapter, FLASH2X_SECTION_VAL eFlash2xSectionVal);
-static INT SaveHeaderIfPresent(PMINI_ADAPTER Adapter, PUCHAR pBuff, UINT uiSectAlignAddr);
-static INT WriteToFlashWithoutSectorErase(PMINI_ADAPTER Adapter, PUINT pBuff,
- FLASH2X_SECTION_VAL eFlash2xSectionVal,
- UINT uiOffset, UINT uiNumBytes);
-static FLASH2X_SECTION_VAL getHighestPriDSD(PMINI_ADAPTER Adapter);
-static FLASH2X_SECTION_VAL getHighestPriISO(PMINI_ADAPTER Adapter);
-
-static INT BeceemFlashBulkRead(
- PMINI_ADAPTER Adapter,
+static int BcmDoChipSelect(struct bcm_mini_adapter *Adapter, unsigned int offset);
+static int BcmGetActiveDSD(struct bcm_mini_adapter *Adapter);
+static int BcmGetActiveISO(struct bcm_mini_adapter *Adapter);
+static unsigned int BcmGetEEPROMSize(struct bcm_mini_adapter *Adapter);
+static int BcmGetFlashCSInfo(struct bcm_mini_adapter *Adapter);
+static unsigned int BcmGetFlashSectorSize(struct bcm_mini_adapter *Adapter, unsigned int FlashSectorSizeSig, unsigned int FlashSectorSize);
+
+static VOID BcmValidateNvmType(struct bcm_mini_adapter *Adapter);
+static int BcmGetNvmSize(struct bcm_mini_adapter *Adapter);
+static unsigned int BcmGetFlashSize(struct bcm_mini_adapter *Adapter);
+static NVM_TYPE BcmGetNvmType(struct bcm_mini_adapter *Adapter);
+
+static int BcmGetSectionValEndOffset(struct bcm_mini_adapter *Adapter, FLASH2X_SECTION_VAL eFlash2xSectionVal);
+
+static B_UINT8 IsOffsetWritable(struct bcm_mini_adapter *Adapter, unsigned int uiOffset);
+static int IsSectionWritable(struct bcm_mini_adapter *Adapter, FLASH2X_SECTION_VAL Section);
+static int IsSectionExistInVendorInfo(struct bcm_mini_adapter *Adapter, FLASH2X_SECTION_VAL section);
+
+static int ReadDSDPriority(struct bcm_mini_adapter *Adapter, FLASH2X_SECTION_VAL dsd);
+static int ReadDSDSignature(struct bcm_mini_adapter *Adapter, FLASH2X_SECTION_VAL dsd);
+static int ReadISOPriority(struct bcm_mini_adapter *Adapter, FLASH2X_SECTION_VAL iso);
+static int ReadISOSignature(struct bcm_mini_adapter *Adapter, FLASH2X_SECTION_VAL iso);
+
+static int CorruptDSDSig(struct bcm_mini_adapter *Adapter, FLASH2X_SECTION_VAL eFlash2xSectionVal);
+static int CorruptISOSig(struct bcm_mini_adapter *Adapter, FLASH2X_SECTION_VAL eFlash2xSectionVal);
+static int SaveHeaderIfPresent(struct bcm_mini_adapter *Adapter, PUCHAR pBuff, unsigned int uiSectAlignAddr);
+static int WriteToFlashWithoutSectorErase(struct bcm_mini_adapter *Adapter, PUINT pBuff,
+ FLASH2X_SECTION_VAL eFlash2xSectionVal,
+ unsigned int uiOffset, unsigned int uiNumBytes);
+static FLASH2X_SECTION_VAL getHighestPriDSD(struct bcm_mini_adapter *Adapter);
+static FLASH2X_SECTION_VAL getHighestPriISO(struct bcm_mini_adapter *Adapter);
+
+static int BeceemFlashBulkRead(
+ struct bcm_mini_adapter *Adapter,
PUINT pBuffer,
- UINT uiOffset,
- UINT uiNumBytes);
+ unsigned int uiOffset,
+ unsigned int uiNumBytes);
-static INT BeceemFlashBulkWrite(
- PMINI_ADAPTER Adapter,
+static int BeceemFlashBulkWrite(
+ struct bcm_mini_adapter *Adapter,
PUINT pBuffer,
- UINT uiOffset,
- UINT uiNumBytes,
+ unsigned int uiOffset,
+ unsigned int uiNumBytes,
BOOLEAN bVerify);
-static INT GetFlashBaseAddr(PMINI_ADAPTER Adapter);
+static int GetFlashBaseAddr(struct bcm_mini_adapter *Adapter);
-static INT ReadBeceemEEPROMBulk(PMINI_ADAPTER Adapter,UINT dwAddress, UINT *pdwData, UINT dwNumData);
+static int ReadBeceemEEPROMBulk(struct bcm_mini_adapter *Adapter, unsigned int dwAddress, unsigned int *pdwData, unsigned int dwNumData);
-// Procedure: ReadEEPROMStatusRegister
-//
-// Description: Reads the standard EEPROM Status Register.
-//
-// Arguments:
-// Adapter - ptr to Adapter object instance
-// Returns:
-// OSAL_STATUS_CODE
-//
-//-----------------------------------------------------------------------------
-
-static UCHAR ReadEEPROMStatusRegister( PMINI_ADAPTER Adapter )
+/* Procedure: ReadEEPROMStatusRegister
+ *
+ * Description: Reads the standard EEPROM Status Register.
+ *
+ * Arguments:
+ * Adapter - ptr to Adapter object instance
+ * Returns:
+ * OSAL_STATUS_CODE
+ */
+static UCHAR ReadEEPROMStatusRegister(struct bcm_mini_adapter *Adapter)
{
UCHAR uiData = 0;
- DWORD dwRetries = MAX_EEPROM_RETRIES*RETRIES_PER_DELAY;
- UINT uiStatus = 0;
- UINT value = 0;
- UINT value1 = 0;
+ DWORD dwRetries = MAX_EEPROM_RETRIES * RETRIES_PER_DELAY;
+ unsigned int uiStatus = 0;
+ unsigned int value = 0;
+ unsigned int value1 = 0;
/* Read the EEPROM status register */
- value = EEPROM_READ_STATUS_REGISTER ;
- wrmalt( Adapter, EEPROM_CMDQ_SPI_REG, &value, sizeof(value));
+ value = EEPROM_READ_STATUS_REGISTER;
+ wrmalt(Adapter, EEPROM_CMDQ_SPI_REG, &value, sizeof(value));
- while ( dwRetries != 0 )
- {
- value=0;
- uiStatus = 0 ;
+ while (dwRetries != 0) {
+ value = 0;
+ uiStatus = 0;
rdmalt(Adapter, EEPROM_SPI_Q_STATUS1_REG, &uiStatus, sizeof(uiStatus));
- if(Adapter->device_removed == TRUE)
- {
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Modem has got removed hence exiting....");
+ if (Adapter->device_removed == TRUE) {
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Modem has got removed hence exiting....");
break;
}
/* Wait for Avail bit to be set. */
- if ( ( uiStatus & EEPROM_READ_DATA_AVAIL) != 0 )
- {
+ if ((uiStatus & EEPROM_READ_DATA_AVAIL) != 0) {
/* Clear the Avail/Full bits - which ever is set. */
value = uiStatus & (EEPROM_READ_DATA_AVAIL | EEPROM_READ_DATA_FULL);
- wrmalt( Adapter, EEPROM_SPI_Q_STATUS1_REG, &value, sizeof(value));
+ wrmalt(Adapter, EEPROM_SPI_Q_STATUS1_REG, &value, sizeof(value));
- value =0;
+ value = 0;
rdmalt(Adapter, EEPROM_READ_DATAQ_REG, &value, sizeof(value));
uiData = (UCHAR)value;
break;
}
- dwRetries-- ;
- if ( dwRetries == 0 )
- {
- rdmalt(Adapter, EEPROM_SPI_Q_STATUS1_REG, &value, sizeof(value));
- rdmalt(Adapter, EEPROM_SPI_Q_STATUS_REG, &value1, sizeof(value1));
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"0x3004 = %x 0x3008 = %x, retries = %d failed.\n",value,value1, MAX_EEPROM_RETRIES*RETRIES_PER_DELAY);
+ dwRetries--;
+ if (dwRetries == 0) {
+ rdmalt(Adapter, EEPROM_SPI_Q_STATUS1_REG, &value, sizeof(value));
+ rdmalt(Adapter, EEPROM_SPI_Q_STATUS_REG, &value1, sizeof(value1));
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "0x3004 = %x 0x3008 = %x, retries = %d failed.\n", value, value1, MAX_EEPROM_RETRIES * RETRIES_PER_DELAY);
return uiData;
}
- if( !(dwRetries%RETRIES_PER_DELAY) )
- msleep(1);
+ if (!(dwRetries%RETRIES_PER_DELAY))
+ udelay(1000);
uiStatus = 0 ;
}
return uiData;
} /* ReadEEPROMStatusRegister */
-//-----------------------------------------------------------------------------
-// Procedure: ReadBeceemEEPROMBulk
-//
-// Description: This routine reads 16Byte data from EEPROM
-//
-// Arguments:
-// Adapter - ptr to Adapter object instance
-// dwAddress - EEPROM Offset to read the data from.
-// pdwData - Pointer to double word where data needs to be stored in. // dwNumWords - Number of words. Valid values are 4 ONLY.
-//
-// Returns:
-// OSAL_STATUS_CODE:
-//-----------------------------------------------------------------------------
-
-INT ReadBeceemEEPROMBulk( PMINI_ADAPTER Adapter,
- DWORD dwAddress,
- DWORD *pdwData,
- DWORD dwNumWords
- )
+/*
+ * Procedure: ReadBeceemEEPROMBulk
+ *
+ * Description: This routine reads 16Byte data from EEPROM
+ *
+ * Arguments:
+ * Adapter - ptr to Adapter object instance
+ * dwAddress - EEPROM Offset to read the data from.
+ * pdwData - Pointer to double word where data needs to be stored in. // dwNumWords - Number of words. Valid values are 4 ONLY.
+ *
+ * Returns:
+ * OSAL_STATUS_CODE:
+ */
+
+int ReadBeceemEEPROMBulk(struct bcm_mini_adapter *Adapter,
+ DWORD dwAddress,
+ DWORD *pdwData,
+ DWORD dwNumWords)
{
DWORD dwIndex = 0;
- DWORD dwRetries = MAX_EEPROM_RETRIES*RETRIES_PER_DELAY;
- UINT uiStatus = 0;
- UINT value= 0;
- UINT value1 = 0;
+ DWORD dwRetries = MAX_EEPROM_RETRIES * RETRIES_PER_DELAY;
+ unsigned int uiStatus = 0;
+ unsigned int value = 0;
+ unsigned int value1 = 0;
UCHAR *pvalue;
/* Flush the read and cmd queue. */
- value=( EEPROM_READ_QUEUE_FLUSH | EEPROM_CMD_QUEUE_FLUSH );
- wrmalt( Adapter, SPI_FLUSH_REG, &value, sizeof(value) );
- value=0;
- wrmalt( Adapter, SPI_FLUSH_REG, &value, sizeof(value));
+ value = (EEPROM_READ_QUEUE_FLUSH | EEPROM_CMD_QUEUE_FLUSH);
+ wrmalt(Adapter, SPI_FLUSH_REG, &value, sizeof(value));
+ value = 0;
+ wrmalt(Adapter, SPI_FLUSH_REG, &value, sizeof(value));
/* Clear the Avail/Full bits. */
- value=( EEPROM_READ_DATA_AVAIL | EEPROM_READ_DATA_FULL );
- wrmalt( Adapter, EEPROM_SPI_Q_STATUS1_REG,&value, sizeof(value));
+ value = (EEPROM_READ_DATA_AVAIL | EEPROM_READ_DATA_FULL);
+ wrmalt(Adapter, EEPROM_SPI_Q_STATUS1_REG, &value, sizeof(value));
- value= dwAddress | ( (dwNumWords == 4) ? EEPROM_16_BYTE_PAGE_READ : EEPROM_4_BYTE_PAGE_READ );
- wrmalt( Adapter, EEPROM_CMDQ_SPI_REG, &value, sizeof(value));
-
- while ( dwRetries != 0 )
- {
+ value = dwAddress | ((dwNumWords == 4) ? EEPROM_16_BYTE_PAGE_READ : EEPROM_4_BYTE_PAGE_READ);
+ wrmalt(Adapter, EEPROM_CMDQ_SPI_REG, &value, sizeof(value));
+ while (dwRetries != 0) {
uiStatus = 0;
rdmalt(Adapter, EEPROM_SPI_Q_STATUS1_REG, &uiStatus, sizeof(uiStatus));
- if(Adapter->device_removed == TRUE)
- {
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Modem has got Removed.hence exiting from loop...");
+ if (Adapter->device_removed == TRUE) {
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Modem has got Removed.hence exiting from loop...");
return -ENODEV;
}
/* If we are reading 16 bytes we want to be sure that the queue
* is full before we read. In the other cases we are ok if the
- * queue has data available */
- if ( dwNumWords == 4 )
- {
- if ( ( uiStatus & EEPROM_READ_DATA_FULL ) != 0 )
- {
+ * queue has data available
+ */
+ if (dwNumWords == 4) {
+ if ((uiStatus & EEPROM_READ_DATA_FULL) != 0) {
/* Clear the Avail/Full bits - which ever is set. */
- value = ( uiStatus & (EEPROM_READ_DATA_AVAIL | EEPROM_READ_DATA_FULL) ) ;
- wrmalt( Adapter, EEPROM_SPI_Q_STATUS1_REG,&value, sizeof(value));
+ value = (uiStatus & (EEPROM_READ_DATA_AVAIL | EEPROM_READ_DATA_FULL));
+ wrmalt(Adapter, EEPROM_SPI_Q_STATUS1_REG, &value, sizeof(value));
break;
}
- }
- else if ( dwNumWords == 1 )
- {
-
- if ( ( uiStatus & EEPROM_READ_DATA_AVAIL ) != 0 )
- {
+ } else if (dwNumWords == 1) {
+ if ((uiStatus & EEPROM_READ_DATA_AVAIL) != 0) {
/* We just got Avail and we have to read 32bits so we
- * need this sleep for Cardbus kind of devices. */
- if (Adapter->chip_id == 0xBECE0210 )
- udelay(800);
+ * need this sleep for Cardbus kind of devices.
+ */
+ if (Adapter->chip_id == 0xBECE0210)
+ udelay(800);
/* Clear the Avail/Full bits - which ever is set. */
- value=( uiStatus & (EEPROM_READ_DATA_AVAIL | EEPROM_READ_DATA_FULL) );
- wrmalt( Adapter, EEPROM_SPI_Q_STATUS1_REG,&value, sizeof(value));
+ value = (uiStatus & (EEPROM_READ_DATA_AVAIL | EEPROM_READ_DATA_FULL));
+ wrmalt(Adapter, EEPROM_SPI_Q_STATUS1_REG, &value, sizeof(value));
break;
}
}
@@ -198,25 +184,25 @@ INT ReadBeceemEEPROMBulk( PMINI_ADAPTER Adapter,
uiStatus = 0;
dwRetries--;
- if(dwRetries == 0)
- {
- value=0;
- value1=0;
+ if (dwRetries == 0) {
+ value = 0;
+ value1 = 0;
rdmalt(Adapter, EEPROM_SPI_Q_STATUS1_REG, &value, sizeof(value));
rdmalt(Adapter, EEPROM_SPI_Q_STATUS_REG, &value1, sizeof(value1));
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "dwNumWords %d 0x3004 = %x 0x3008 = %x retries = %d failed.\n", dwNumWords, value, value1, MAX_EEPROM_RETRIES*RETRIES_PER_DELAY);
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "dwNumWords %d 0x3004 = %x 0x3008 = %x retries = %d failed.\n",
+ dwNumWords, value, value1, MAX_EEPROM_RETRIES * RETRIES_PER_DELAY);
return STATUS_FAILURE;
}
- if( !(dwRetries%RETRIES_PER_DELAY) )
- msleep(1);
+
+ if (!(dwRetries%RETRIES_PER_DELAY))
+ udelay(1000);
}
- for ( dwIndex = 0; dwIndex < dwNumWords ; dwIndex++ )
- {
+ for (dwIndex = 0; dwIndex < dwNumWords; dwIndex++) {
/* We get only a byte at a time - from LSB to MSB. We shift it into an integer. */
pvalue = (PUCHAR)(pdwData + dwIndex);
- value =0;
+ value = 0;
rdmalt(Adapter, EEPROM_READ_DATAQ_REG, &value, sizeof(value));
pvalue[0] = value;
@@ -226,7 +212,7 @@ INT ReadBeceemEEPROMBulk( PMINI_ADAPTER Adapter,
pvalue[1] = value;
- value =0;
+ value = 0;
rdmalt(Adapter, EEPROM_READ_DATAQ_REG, &value, sizeof(value));
pvalue[2] = value;
@@ -240,31 +226,30 @@ INT ReadBeceemEEPROMBulk( PMINI_ADAPTER Adapter,
return STATUS_SUCCESS;
} /* ReadBeceemEEPROMBulk() */
-//-----------------------------------------------------------------------------
-// Procedure: ReadBeceemEEPROM
-//
-// Description: This routine reads 4 data from EEPROM. It uses 1 or 2 page
-// reads to do this operation.
-//
-// Arguments:
-// Adapter - ptr to Adapter object instance
-// uiOffset - EEPROM Offset to read the data from.
-// pBuffer - Pointer to word where data needs to be stored in.
-//
-// Returns:
-// OSAL_STATUS_CODE:
-//-----------------------------------------------------------------------------
-
-INT ReadBeceemEEPROM( PMINI_ADAPTER Adapter,
- DWORD uiOffset,
- DWORD *pBuffer
- )
+/*
+ * Procedure: ReadBeceemEEPROM
+ *
+ * Description: This routine reads 4 data from EEPROM. It uses 1 or 2 page
+ * reads to do this operation.
+ *
+ * Arguments:
+ * Adapter - ptr to Adapter object instance
+ * uiOffset - EEPROM Offset to read the data from.
+ * pBuffer - Pointer to word where data needs to be stored in.
+ *
+ * Returns:
+ * OSAL_STATUS_CODE:
+ */
+
+int ReadBeceemEEPROM(struct bcm_mini_adapter *Adapter,
+ DWORD uiOffset,
+ DWORD *pBuffer)
{
- UINT uiData[8] = {0};
- UINT uiByteOffset = 0;
- UINT uiTempOffset = 0;
+ unsigned int uiData[8] = {0};
+ unsigned int uiByteOffset = 0;
+ unsigned int uiTempOffset = 0;
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL," ====> ");
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, " ====> ");
uiTempOffset = uiOffset - (uiOffset % MAX_RW_SIZE);
uiByteOffset = uiOffset - uiTempOffset;
@@ -272,22 +257,19 @@ INT ReadBeceemEEPROM( PMINI_ADAPTER Adapter,
ReadBeceemEEPROMBulk(Adapter, uiTempOffset, (PUINT)&uiData[0], 4);
/* A word can overlap at most over 2 pages. In that case we read the
- * next page too. */
- if ( uiByteOffset > 12 )
- {
+ * next page too.
+ */
+ if (uiByteOffset > 12)
ReadBeceemEEPROMBulk(Adapter, uiTempOffset + MAX_RW_SIZE, (PUINT)&uiData[4], 4);
- }
- memcpy( (PUCHAR) pBuffer, ( ((PUCHAR)&uiData[0]) + uiByteOffset ), 4);
+ memcpy((PUCHAR)pBuffer, (((PUCHAR)&uiData[0]) + uiByteOffset), 4);
return STATUS_SUCCESS;
} /* ReadBeceemEEPROM() */
-
-
-INT ReadMacAddressFromNVM(PMINI_ADAPTER Adapter)
+int ReadMacAddressFromNVM(struct bcm_mini_adapter *Adapter)
{
- INT Status;
+ int Status;
unsigned char puMacAddr[6];
Status = BeceemNVMRead(Adapter,
@@ -295,182 +277,154 @@ INT ReadMacAddressFromNVM(PMINI_ADAPTER Adapter)
INIT_PARAMS_1_MACADDRESS_ADDRESS,
MAC_ADDRESS_SIZE);
- if(Status == STATUS_SUCCESS)
+ if (Status == STATUS_SUCCESS)
memcpy(Adapter->dev->dev_addr, puMacAddr, MAC_ADDRESS_SIZE);
return Status;
}
-//-----------------------------------------------------------------------------
-// Procedure: BeceemEEPROMBulkRead
-//
-// Description: Reads the EEPROM and returns the Data.
-//
-// Arguments:
-// Adapter - ptr to Adapter object instance
-// pBuffer - Buffer to store the data read from EEPROM
-// uiOffset - Offset of EEPROM from where data should be read
-// uiNumBytes - Number of bytes to be read from the EEPROM.
-//
-// Returns:
-// OSAL_STATUS_SUCCESS - if EEPROM read is successful.
-// <FAILURE> - if failed.
-//-----------------------------------------------------------------------------
-
-INT BeceemEEPROMBulkRead(
- PMINI_ADAPTER Adapter,
- PUINT pBuffer,
- UINT uiOffset,
- UINT uiNumBytes)
+/*
+ * Procedure: BeceemEEPROMBulkRead
+ *
+ * Description: Reads the EEPROM and returns the Data.
+ *
+ * Arguments:
+ * Adapter - ptr to Adapter object instance
+ * pBuffer - Buffer to store the data read from EEPROM
+ * uiOffset - Offset of EEPROM from where data should be read
+ * uiNumBytes - Number of bytes to be read from the EEPROM.
+ *
+ * Returns:
+ * OSAL_STATUS_SUCCESS - if EEPROM read is successful.
+ * <FAILURE> - if failed.
+ */
+
+int BeceemEEPROMBulkRead(struct bcm_mini_adapter *Adapter,
+ PUINT pBuffer,
+ unsigned int uiOffset,
+ unsigned int uiNumBytes)
{
- UINT uiData[4] = {0};
- //UINT uiAddress = 0;
- UINT uiBytesRemaining = uiNumBytes;
- UINT uiIndex = 0;
- UINT uiTempOffset = 0;
- UINT uiExtraBytes = 0;
- UINT uiFailureRetries = 0;
+ unsigned int uiData[4] = {0};
+ /* unsigned int uiAddress = 0; */
+ unsigned int uiBytesRemaining = uiNumBytes;
+ unsigned int uiIndex = 0;
+ unsigned int uiTempOffset = 0;
+ unsigned int uiExtraBytes = 0;
+ unsigned int uiFailureRetries = 0;
PUCHAR pcBuff = (PUCHAR)pBuffer;
-
- if(uiOffset%MAX_RW_SIZE&& uiBytesRemaining)
- {
- uiTempOffset = uiOffset - (uiOffset%MAX_RW_SIZE);
- uiExtraBytes = uiOffset-uiTempOffset;
- ReadBeceemEEPROMBulk(Adapter,uiTempOffset,(PUINT)&uiData[0],4);
- if(uiBytesRemaining >= (MAX_RW_SIZE - uiExtraBytes))
- {
- memcpy(pBuffer,(((PUCHAR)&uiData[0])+uiExtraBytes),MAX_RW_SIZE - uiExtraBytes);
-
+ if (uiOffset % MAX_RW_SIZE && uiBytesRemaining) {
+ uiTempOffset = uiOffset - (uiOffset % MAX_RW_SIZE);
+ uiExtraBytes = uiOffset - uiTempOffset;
+ ReadBeceemEEPROMBulk(Adapter, uiTempOffset, (PUINT)&uiData[0], 4);
+ if (uiBytesRemaining >= (MAX_RW_SIZE - uiExtraBytes)) {
+ memcpy(pBuffer, (((PUCHAR)&uiData[0]) + uiExtraBytes), MAX_RW_SIZE - uiExtraBytes);
uiBytesRemaining -= (MAX_RW_SIZE - uiExtraBytes);
uiIndex += (MAX_RW_SIZE - uiExtraBytes);
uiOffset += (MAX_RW_SIZE - uiExtraBytes);
- }
- else
- {
- memcpy(pBuffer,(((PUCHAR)&uiData[0])+uiExtraBytes),uiBytesRemaining);
+ } else {
+ memcpy(pBuffer, (((PUCHAR)&uiData[0]) + uiExtraBytes), uiBytesRemaining);
uiIndex += uiBytesRemaining;
uiOffset += uiBytesRemaining;
uiBytesRemaining = 0;
}
-
-
}
-
- while(uiBytesRemaining && uiFailureRetries != 128)
- {
- if(Adapter->device_removed )
- {
+ while (uiBytesRemaining && uiFailureRetries != 128) {
+ if (Adapter->device_removed)
return -1;
- }
- if(uiBytesRemaining >= MAX_RW_SIZE)
- {
+ if (uiBytesRemaining >= MAX_RW_SIZE) {
/* For the requests more than or equal to 16 bytes, use bulk
* read function to make the access faster.
- * We read 4 Dwords of data */
- if(0 == ReadBeceemEEPROMBulk(Adapter,uiOffset,&uiData[0],4))
- {
- memcpy(pcBuff+uiIndex,&uiData[0],MAX_RW_SIZE);
+ * We read 4 Dwords of data
+ */
+ if (ReadBeceemEEPROMBulk(Adapter, uiOffset, &uiData[0], 4) == 0) {
+ memcpy(pcBuff + uiIndex, &uiData[0], MAX_RW_SIZE);
uiOffset += MAX_RW_SIZE;
uiBytesRemaining -= MAX_RW_SIZE;
uiIndex += MAX_RW_SIZE;
- }
- else
- {
+ } else {
uiFailureRetries++;
- mdelay(3);//sleep for a while before retry...
+ mdelay(3); /* sleep for a while before retry... */
}
- }
- else if(uiBytesRemaining >= 4)
- {
- if(0 == ReadBeceemEEPROM(Adapter,uiOffset,&uiData[0]))
- {
- memcpy(pcBuff+uiIndex,&uiData[0],4);
+ } else if (uiBytesRemaining >= 4) {
+ if (ReadBeceemEEPROM(Adapter, uiOffset, &uiData[0]) == 0) {
+ memcpy(pcBuff + uiIndex, &uiData[0], 4);
uiOffset += 4;
uiBytesRemaining -= 4;
- uiIndex +=4;
- }
- else
- {
+ uiIndex += 4;
+ } else {
uiFailureRetries++;
- mdelay(3);//sleep for a while before retry...
+ mdelay(3); /* sleep for a while before retry... */
}
- }
- else
- { // Handle the reads less than 4 bytes...
+ } else {
+ /* Handle the reads less than 4 bytes... */
PUCHAR pCharBuff = (PUCHAR)pBuffer;
pCharBuff += uiIndex;
- if(0 == ReadBeceemEEPROM(Adapter,uiOffset,&uiData[0]))
- {
- memcpy(pCharBuff,&uiData[0],uiBytesRemaining);//copy only bytes requested.
+ if (ReadBeceemEEPROM(Adapter, uiOffset, &uiData[0]) == 0) {
+ memcpy(pCharBuff, &uiData[0], uiBytesRemaining); /* copy only bytes requested. */
uiBytesRemaining = 0;
- }
- else
- {
+ } else {
uiFailureRetries++;
- mdelay(3);//sleep for a while before retry...
+ mdelay(3); /* sleep for a while before retry... */
}
}
-
}
return 0;
}
-//-----------------------------------------------------------------------------
-// Procedure: BeceemFlashBulkRead
-//
-// Description: Reads the FLASH and returns the Data.
-//
-// Arguments:
-// Adapter - ptr to Adapter object instance
-// pBuffer - Buffer to store the data read from FLASH
-// uiOffset - Offset of FLASH from where data should be read
-// uiNumBytes - Number of bytes to be read from the FLASH.
-//
-// Returns:
-// OSAL_STATUS_SUCCESS - if FLASH read is successful.
-// <FAILURE> - if failed.
-//-----------------------------------------------------------------------------
-
-static INT BeceemFlashBulkRead(
- PMINI_ADAPTER Adapter,
- PUINT pBuffer,
- UINT uiOffset,
- UINT uiNumBytes)
+/*
+ * Procedure: BeceemFlashBulkRead
+ *
+ * Description: Reads the FLASH and returns the Data.
+ *
+ * Arguments:
+ * Adapter - ptr to Adapter object instance
+ * pBuffer - Buffer to store the data read from FLASH
+ * uiOffset - Offset of FLASH from where data should be read
+ * uiNumBytes - Number of bytes to be read from the FLASH.
+ *
+ * Returns:
+ * OSAL_STATUS_SUCCESS - if FLASH read is successful.
+ * <FAILURE> - if failed.
+ */
+
+static int BeceemFlashBulkRead(struct bcm_mini_adapter *Adapter,
+ PUINT pBuffer,
+ unsigned int uiOffset,
+ unsigned int uiNumBytes)
{
- UINT uiIndex = 0;
- UINT uiBytesToRead = uiNumBytes;
- INT Status = 0;
- UINT uiPartOffset = 0;
+ unsigned int uiIndex = 0;
+ unsigned int uiBytesToRead = uiNumBytes;
+ int Status = 0;
+ unsigned int uiPartOffset = 0;
int bytes;
- if(Adapter->device_removed )
- {
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Device Got Removed ");
+ if (Adapter->device_removed) {
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Device Got Removed");
return -ENODEV;
}
- //Adding flash Base address
-// uiOffset = uiOffset + GetFlashBaseAddr(Adapter);
-#if defined(BCM_SHM_INTERFACE) && !defined(FLASH_DIRECT_ACCESS)
- Status = bcmflash_raw_read((uiOffset/FLASH_PART_SIZE),(uiOffset % FLASH_PART_SIZE),( unsigned char *)pBuffer,uiNumBytes);
- return Status;
-#endif
+ /* Adding flash Base address
+ * uiOffset = uiOffset + GetFlashBaseAddr(Adapter);
+ */
+ #if defined(BCM_SHM_INTERFACE) && !defined(FLASH_DIRECT_ACCESS)
+ Status = bcmflash_raw_read((uiOffset/FLASH_PART_SIZE), (uiOffset % FLASH_PART_SIZE), (unsigned char *)pBuffer, uiNumBytes);
+ return Status;
+ #endif
Adapter->SelectedChip = RESET_CHIP_SELECT;
- if(uiOffset % MAX_RW_SIZE)
- {
- BcmDoChipSelect(Adapter,uiOffset);
+ if (uiOffset % MAX_RW_SIZE) {
+ BcmDoChipSelect(Adapter, uiOffset);
uiPartOffset = (uiOffset & (FLASH_PART_SIZE - 1)) + GetFlashBaseAddr(Adapter);
- uiBytesToRead = MAX_RW_SIZE - (uiOffset%MAX_RW_SIZE);
- uiBytesToRead = MIN(uiNumBytes,uiBytesToRead);
+ uiBytesToRead = MAX_RW_SIZE - (uiOffset % MAX_RW_SIZE);
+ uiBytesToRead = MIN(uiNumBytes, uiBytesToRead);
- bytes = rdm(Adapter, uiPartOffset, (PCHAR)pBuffer+uiIndex, uiBytesToRead);
+ bytes = rdm(Adapter, uiPartOffset, (PCHAR)pBuffer + uiIndex, uiBytesToRead);
if (bytes < 0) {
Status = bytes;
Adapter->SelectedChip = RESET_CHIP_SELECT;
@@ -482,142 +436,122 @@ static INT BeceemFlashBulkRead(
uiNumBytes -= uiBytesToRead;
}
- while(uiNumBytes)
- {
- BcmDoChipSelect(Adapter,uiOffset);
+ while (uiNumBytes) {
+ BcmDoChipSelect(Adapter, uiOffset);
uiPartOffset = (uiOffset & (FLASH_PART_SIZE - 1)) + GetFlashBaseAddr(Adapter);
- uiBytesToRead = MIN(uiNumBytes,MAX_RW_SIZE);
+ uiBytesToRead = MIN(uiNumBytes, MAX_RW_SIZE);
- bytes = rdm(Adapter, uiPartOffset, (PCHAR)pBuffer+uiIndex, uiBytesToRead);
+ bytes = rdm(Adapter, uiPartOffset, (PCHAR)pBuffer + uiIndex, uiBytesToRead);
if (bytes < 0) {
Status = bytes;
break;
}
-
uiIndex += uiBytesToRead;
uiOffset += uiBytesToRead;
uiNumBytes -= uiBytesToRead;
-
}
Adapter->SelectedChip = RESET_CHIP_SELECT;
return Status;
}
-//-----------------------------------------------------------------------------
-// Procedure: BcmGetFlashSize
-//
-// Description: Finds the size of FLASH.
-//
-// Arguments:
-// Adapter - ptr to Adapter object instance
-//
-// Returns:
-// UINT - size of the FLASH Storage.
-//
-//-----------------------------------------------------------------------------
-
-static UINT BcmGetFlashSize(PMINI_ADAPTER Adapter)
+/*
+ * Procedure: BcmGetFlashSize
+ *
+ * Description: Finds the size of FLASH.
+ *
+ * Arguments:
+ * Adapter - ptr to Adapter object instance
+ *
+ * Returns:
+ * unsigned int - size of the FLASH Storage.
+ *
+ */
+
+static unsigned int BcmGetFlashSize(struct bcm_mini_adapter *Adapter)
{
- if(IsFlash2x(Adapter))
- return (Adapter->psFlash2xCSInfo->OffsetFromDSDStartForDSDHeader + sizeof(DSD_HEADER));
+ if (IsFlash2x(Adapter))
+ return Adapter->psFlash2xCSInfo->OffsetFromDSDStartForDSDHeader + sizeof(DSD_HEADER);
else
- return 32*1024;
-
-
+ return 32 * 1024;
}
-//-----------------------------------------------------------------------------
-// Procedure: BcmGetEEPROMSize
-//
-// Description: Finds the size of EEPROM.
-//
-// Arguments:
-// Adapter - ptr to Adapter object instance
-//
-// Returns:
-// UINT - size of the EEPROM Storage.
-//
-//-----------------------------------------------------------------------------
-
-static UINT BcmGetEEPROMSize(PMINI_ADAPTER Adapter)
+/*
+ * Procedure: BcmGetEEPROMSize
+ *
+ * Description: Finds the size of EEPROM.
+ *
+ * Arguments:
+ * Adapter - ptr to Adapter object instance
+ *
+ * Returns:
+ * unsigned int - size of the EEPROM Storage.
+ *
+ */
+
+static unsigned int BcmGetEEPROMSize(struct bcm_mini_adapter *Adapter)
{
- UINT uiData = 0;
- UINT uiIndex = 0;
-
-//
-// if EEPROM is present and already Calibrated,it will have
-// 'BECM' string at 0th offset.
-// To find the EEPROM size read the possible boundaries of the
-// EEPROM like 4K,8K etc..accessing the EEPROM beyond its size will
-// result in wrap around. So when we get the End of the EEPROM we will
-// get 'BECM' string which is indeed at offset 0.
-//
- BeceemEEPROMBulkRead(Adapter,&uiData,0x0,4);
- if(uiData == BECM)
- {
- for(uiIndex = 2;uiIndex <=256; uiIndex*=2)
- {
- BeceemEEPROMBulkRead(Adapter,&uiData,uiIndex*1024,4);
- if(uiData == BECM)
- {
- return uiIndex*1024;
- }
- }
- }
- else
- {
-//
-// EEPROM may not be present or not programmed
-//
+ unsigned int uiData = 0;
+ unsigned int uiIndex = 0;
- uiData = 0xBABEFACE;
- if(0 == BeceemEEPROMBulkWrite(Adapter,(PUCHAR)&uiData,0,4,TRUE))
- {
+ /*
+ * if EEPROM is present and already Calibrated,it will have
+ * 'BECM' string at 0th offset.
+ * To find the EEPROM size read the possible boundaries of the
+ * EEPROM like 4K,8K etc..accessing the EEPROM beyond its size will
+ * result in wrap around. So when we get the End of the EEPROM we will
+ * get 'BECM' string which is indeed at offset 0.
+ */
+ BeceemEEPROMBulkRead(Adapter, &uiData, 0x0, 4);
+ if (uiData == BECM) {
+ for (uiIndex = 2; uiIndex <= 256; uiIndex *= 2) {
+ BeceemEEPROMBulkRead(Adapter, &uiData, uiIndex * 1024, 4);
+ if (uiData == BECM)
+ return uiIndex * 1024;
+ }
+ } else {
+ /*
+ * EEPROM may not be present or not programmed
+ */
+ uiData = 0xBABEFACE;
+ if (BeceemEEPROMBulkWrite(Adapter, (PUCHAR)&uiData, 0, 4, TRUE) == 0) {
uiData = 0;
- for(uiIndex = 2;uiIndex <=256; uiIndex*=2)
- {
- BeceemEEPROMBulkRead(Adapter,&uiData,uiIndex*1024,4);
- if(uiData == 0xBABEFACE)
- {
- return uiIndex*1024;
- }
+ for (uiIndex = 2; uiIndex <= 256; uiIndex *= 2) {
+ BeceemEEPROMBulkRead(Adapter, &uiData, uiIndex * 1024, 4);
+ if (uiData == 0xBABEFACE)
+ return uiIndex * 1024;
}
}
-
}
return 0;
}
-
-//-----------------------------------------------------------------------------
-// Procedure: FlashSectorErase
-//
-// Description: Finds the sector size of the FLASH.
-//
-// Arguments:
-// Adapter - ptr to Adapter object instance
-// addr - sector start address
-// numOfSectors - number of sectors to be erased.
-//
-// Returns:
-// OSAL_STATUS_CODE
-//
-//-----------------------------------------------------------------------------
-
-
-static INT FlashSectorErase(PMINI_ADAPTER Adapter,
- UINT addr,
- UINT numOfSectors)
+/*
+ * Procedure: FlashSectorErase
+ *
+ * Description: Finds the sector size of the FLASH.
+ *
+ * Arguments:
+ * Adapter - ptr to Adapter object instance
+ * addr - sector start address
+ * numOfSectors - number of sectors to be erased.
+ *
+ * Returns:
+ * OSAL_STATUS_CODE
+ *
+ */
+
+static int FlashSectorErase(struct bcm_mini_adapter *Adapter,
+ unsigned int addr,
+ unsigned int numOfSectors)
{
- UINT iIndex = 0, iRetries = 0;
- UINT uiStatus = 0;
- UINT value;
+ unsigned int iIndex = 0, iRetries = 0;
+ unsigned int uiStatus = 0;
+ unsigned int value;
int bytes;
- for(iIndex=0;iIndex<numOfSectors;iIndex++)
- {
+ for (iIndex = 0; iIndex < numOfSectors; iIndex++) {
value = 0x06000000;
wrmalt(Adapter, FLASH_SPI_CMDQ_REG, &value, sizeof(value));
@@ -625,12 +559,10 @@ static INT FlashSectorErase(PMINI_ADAPTER Adapter,
wrmalt(Adapter, FLASH_SPI_CMDQ_REG, &value, sizeof(value));
iRetries = 0;
- do
- {
+ do {
value = (FLASH_CMD_STATUS_REG_READ << 24);
- if(wrmalt(Adapter, FLASH_SPI_CMDQ_REG, &value, sizeof(value)) < 0)
- {
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Programing of FLASH_SPI_CMDQ_REG fails");
+ if (wrmalt(Adapter, FLASH_SPI_CMDQ_REG, &value, sizeof(value)) < 0) {
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Programing of FLASH_SPI_CMDQ_REG fails");
return STATUS_FAILURE;
}
@@ -641,15 +573,15 @@ static INT FlashSectorErase(PMINI_ADAPTER Adapter,
return uiStatus;
}
iRetries++;
- //After every try lets make the CPU free for 10 ms. generally time taken by the
- //the sector erase cycle is 500 ms to 40000 msec. hence sleeping 10 ms
- //won't hamper performance in any case.
- msleep(10);
- }while((uiStatus & 0x1) && (iRetries < 400));
-
- if(uiStatus & 0x1)
- {
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"iRetries crossing the limit of 80000\n");
+ /* After every try lets make the CPU free for 10 ms. generally time taken by the
+ * the sector erase cycle is 500 ms to 40000 msec. hence sleeping 10 ms
+ * won't hamper performance in any case.
+ */
+ udelay(10000);
+ } while ((uiStatus & 0x1) && (iRetries < 400));
+
+ if (uiStatus & 0x1) {
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "iRetries crossing the limit of 80000\n");
return STATUS_FAILURE;
}
@@ -657,158 +589,137 @@ static INT FlashSectorErase(PMINI_ADAPTER Adapter,
}
return 0;
}
-//-----------------------------------------------------------------------------
-// Procedure: flashByteWrite
-//
-// Description: Performs Byte by Byte write to flash
-//
-// Arguments:
-// Adapter - ptr to Adapter object instance
-// uiOffset - Offset of the flash where data needs to be written to.
-// pData - Address of Data to be written.
-// Returns:
-// OSAL_STATUS_CODE
-//
-//-----------------------------------------------------------------------------
-
-static INT flashByteWrite(
- PMINI_ADAPTER Adapter,
- UINT uiOffset,
- PVOID pData)
+/*
+ * Procedure: flashByteWrite
+ *
+ * Description: Performs Byte by Byte write to flash
+ *
+ * Arguments:
+ * Adapter - ptr to Adapter object instance
+ * uiOffset - Offset of the flash where data needs to be written to.
+ * pData - Address of Data to be written.
+ * Returns:
+ * OSAL_STATUS_CODE
+ *
+ */
+
+static int flashByteWrite(struct bcm_mini_adapter *Adapter,
+ unsigned int uiOffset,
+ PVOID pData)
{
-
- UINT uiStatus = 0;
- INT iRetries = MAX_FLASH_RETRIES * FLASH_PER_RETRIES_DELAY; //3
-
- UINT value;
+ unsigned int uiStatus = 0;
+ int iRetries = MAX_FLASH_RETRIES * FLASH_PER_RETRIES_DELAY; /* 3 */
+ unsigned int value;
ULONG ulData = *(PUCHAR)pData;
int bytes;
+ /*
+ * need not write 0xFF because write requires an erase and erase will
+ * make whole sector 0xFF.
+ */
-//
-// need not write 0xFF because write requires an erase and erase will
-// make whole sector 0xFF.
-//
-
- if(0xFF == ulData)
- {
+ if (0xFF == ulData)
return STATUS_SUCCESS;
- }
-// DumpDebug(NVM_RW,("flashWrite ====>\n"));
+ /* DumpDebug(NVM_RW,("flashWrite ====>\n")); */
value = (FLASH_CMD_WRITE_ENABLE << 24);
- if(wrmalt(Adapter, FLASH_SPI_CMDQ_REG,&value, sizeof(value)) < 0)
- {
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Write enable in FLASH_SPI_CMDQ_REG register fails");
+ if (wrmalt(Adapter, FLASH_SPI_CMDQ_REG, &value, sizeof(value)) < 0) {
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Write enable in FLASH_SPI_CMDQ_REG register fails");
return STATUS_FAILURE;
}
- if(wrm(Adapter,FLASH_SPI_WRITEQ_REG, (PCHAR)&ulData, 4) < 0 )
- {
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"DATA Write on FLASH_SPI_WRITEQ_REG fails");
+
+ if (wrm(Adapter, FLASH_SPI_WRITEQ_REG, (PCHAR)&ulData, 4) < 0) {
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "DATA Write on FLASH_SPI_WRITEQ_REG fails");
return STATUS_FAILURE;
}
value = (0x02000000 | (uiOffset & 0xFFFFFF));
- if(wrmalt(Adapter, FLASH_SPI_CMDQ_REG,&value, sizeof(value)) < 0 )
- {
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Programming of FLASH_SPI_CMDQ_REG fails");
+ if (wrmalt(Adapter, FLASH_SPI_CMDQ_REG, &value, sizeof(value)) < 0) {
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Programming of FLASH_SPI_CMDQ_REG fails");
return STATUS_FAILURE;
}
- //__udelay(950);
+ /* __udelay(950); */
- do
- {
+ do {
value = (FLASH_CMD_STATUS_REG_READ << 24);
- if(wrmalt(Adapter, FLASH_SPI_CMDQ_REG, &value, sizeof(value)) < 0)
- {
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Programing of FLASH_SPI_CMDQ_REG fails");
+ if (wrmalt(Adapter, FLASH_SPI_CMDQ_REG, &value, sizeof(value)) < 0) {
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Programing of FLASH_SPI_CMDQ_REG fails");
return STATUS_FAILURE;
- }
- //__udelay(1);
+ }
+ /* __udelay(1); */
bytes = rdmalt(Adapter, FLASH_SPI_READQ_REG, &uiStatus, sizeof(uiStatus));
if (bytes < 0) {
uiStatus = bytes;
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Reading status of FLASH_SPI_READQ_REG fails");
return uiStatus;
}
- iRetries--;
- if( iRetries && ((iRetries % FLASH_PER_RETRIES_DELAY) == 0))
- msleep(1);
+ iRetries--;
+ if (iRetries && ((iRetries % FLASH_PER_RETRIES_DELAY) == 0))
+ udelay(1000);
- }while((uiStatus & 0x1) && (iRetries >0) );
+ } while ((uiStatus & 0x1) && (iRetries > 0));
- if(uiStatus & 0x1)
- {
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Flash Write fails even after checking status for 200 times.");
- return STATUS_FAILURE ;
+ if (uiStatus & 0x1) {
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Flash Write fails even after checking status for 200 times.");
+ return STATUS_FAILURE;
}
return STATUS_SUCCESS;
}
-
-
-//-----------------------------------------------------------------------------
-// Procedure: flashWrite
-//
-// Description: Performs write to flash
-//
-// Arguments:
-// Adapter - ptr to Adapter object instance
-// uiOffset - Offset of the flash where data needs to be written to.
-// pData - Address of Data to be written.
-// Returns:
-// OSAL_STATUS_CODE
-//
-//-----------------------------------------------------------------------------
-
-static INT flashWrite(
- PMINI_ADAPTER Adapter,
- UINT uiOffset,
- PVOID pData)
-
+/*
+ * Procedure: flashWrite
+ *
+ * Description: Performs write to flash
+ *
+ * Arguments:
+ * Adapter - ptr to Adapter object instance
+ * uiOffset - Offset of the flash where data needs to be written to.
+ * pData - Address of Data to be written.
+ * Returns:
+ * OSAL_STATUS_CODE
+ *
+ */
+
+static int flashWrite(struct bcm_mini_adapter *Adapter,
+ unsigned int uiOffset,
+ PVOID pData)
{
- //UINT uiStatus = 0;
- //INT iRetries = 0;
- //UINT uiReadBack = 0;
-
- UINT uiStatus = 0;
- INT iRetries = MAX_FLASH_RETRIES * FLASH_PER_RETRIES_DELAY; //3
-
- UINT value;
- UINT uiErasePattern[4] = {0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF};
+ /* unsigned int uiStatus = 0;
+ * int iRetries = 0;
+ * unsigned int uiReadBack = 0;
+ */
+ unsigned int uiStatus = 0;
+ int iRetries = MAX_FLASH_RETRIES * FLASH_PER_RETRIES_DELAY; /* 3 */
+ unsigned int value;
+ unsigned int uiErasePattern[4] = {0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF};
int bytes;
-//
-// need not write 0xFFFFFFFF because write requires an erase and erase will
-// make whole sector 0xFFFFFFFF.
-//
+ /*
+ * need not write 0xFFFFFFFF because write requires an erase and erase will
+ * make whole sector 0xFFFFFFFF.
+ */
if (!memcmp(pData, uiErasePattern, MAX_RW_SIZE))
- {
return 0;
- }
value = (FLASH_CMD_WRITE_ENABLE << 24);
- if(wrmalt(Adapter, FLASH_SPI_CMDQ_REG,&value, sizeof(value)) < 0 )
- {
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Write Enable of FLASH_SPI_CMDQ_REG fails");
+ if (wrmalt(Adapter, FLASH_SPI_CMDQ_REG, &value, sizeof(value)) < 0) {
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Write Enable of FLASH_SPI_CMDQ_REG fails");
return STATUS_FAILURE;
}
- if(wrm(Adapter, uiOffset, (PCHAR)pData, MAX_RW_SIZE) < 0)
- {
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Data write fails...");
+
+ if (wrm(Adapter, uiOffset, (PCHAR)pData, MAX_RW_SIZE) < 0) {
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Data write fails...");
return STATUS_FAILURE;
}
- //__udelay(950);
- do
- {
+ /* __udelay(950); */
+ do {
value = (FLASH_CMD_STATUS_REG_READ << 24);
- if(wrmalt(Adapter, FLASH_SPI_CMDQ_REG, &value, sizeof(value)) < 0)
- {
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Programing of FLASH_SPI_CMDQ_REG fails");
+ if (wrmalt(Adapter, FLASH_SPI_CMDQ_REG, &value, sizeof(value)) < 0) {
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Programing of FLASH_SPI_CMDQ_REG fails");
return STATUS_FAILURE;
- }
- //__udelay(1);
+ }
+ /* __udelay(1); */
bytes = rdmalt(Adapter, FLASH_SPI_READQ_REG, &uiStatus, sizeof(uiStatus));
if (bytes < 0) {
uiStatus = bytes;
@@ -817,88 +728,80 @@ static INT flashWrite(
}
iRetries--;
- //this will ensure that in there will be no changes in the current path.
- //currently one rdm/wrm takes 125 us.
- //Hence 125 *2 * FLASH_PER_RETRIES_DELAY > 3 ms(worst case delay)
- //Hence current implementation cycle will intoduce no delay in current path
- if(iRetries && ((iRetries % FLASH_PER_RETRIES_DELAY) == 0))
- msleep(1);
- }while((uiStatus & 0x1) && (iRetries > 0));
-
- if(uiStatus & 0x1)
- {
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Flash Write fails even after checking status for 200 times.");
- return STATUS_FAILURE ;
+ /* this will ensure that in there will be no changes in the current path.
+ * currently one rdm/wrm takes 125 us.
+ * Hence 125 *2 * FLASH_PER_RETRIES_DELAY > 3 ms(worst case delay)
+ * Hence current implementation cycle will intoduce no delay in current path
+ */
+ if (iRetries && ((iRetries % FLASH_PER_RETRIES_DELAY) == 0))
+ udelay(1000);
+ } while ((uiStatus & 0x1) && (iRetries > 0));
+
+ if (uiStatus & 0x1) {
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Flash Write fails even after checking status for 200 times.");
+ return STATUS_FAILURE;
}
return STATUS_SUCCESS;
}
-//-----------------------------------------------------------------------------
-// Procedure: flashByteWriteStatus
-//
-// Description: Performs byte by byte write to flash with write done status check
-//
-// Arguments:
-// Adapter - ptr to Adapter object instance
-// uiOffset - Offset of the flash where data needs to be written to.
-// pData - Address of the Data to be written.
-// Returns:
-// OSAL_STATUS_CODE
-//
-//-----------------------------------------------------------------------------
-static INT flashByteWriteStatus(
- PMINI_ADAPTER Adapter,
- UINT uiOffset,
- PVOID pData)
+/*-----------------------------------------------------------------------------
+ * Procedure: flashByteWriteStatus
+ *
+ * Description: Performs byte by byte write to flash with write done status check
+ *
+ * Arguments:
+ * Adapter - ptr to Adapter object instance
+ * uiOffset - Offset of the flash where data needs to be written to.
+ * pData - Address of the Data to be written.
+ * Returns:
+ * OSAL_STATUS_CODE
+ *
+ */
+static int flashByteWriteStatus(struct bcm_mini_adapter *Adapter,
+ unsigned int uiOffset,
+ PVOID pData)
{
- UINT uiStatus = 0;
- INT iRetries = MAX_FLASH_RETRIES * FLASH_PER_RETRIES_DELAY; //3
+ unsigned int uiStatus = 0;
+ int iRetries = MAX_FLASH_RETRIES * FLASH_PER_RETRIES_DELAY; /* 3 */
ULONG ulData = *(PUCHAR)pData;
- UINT value;
+ unsigned int value;
int bytes;
-//
-// need not write 0xFFFFFFFF because write requires an erase and erase will
-// make whole sector 0xFFFFFFFF.
-//
+ /*
+ * need not write 0xFFFFFFFF because write requires an erase and erase will
+ * make whole sector 0xFFFFFFFF.
+ */
- if(0xFF == ulData)
- {
+ if (0xFF == ulData)
return STATUS_SUCCESS;
- }
- // DumpDebug(NVM_RW,("flashWrite ====>\n"));
+ /* DumpDebug(NVM_RW,("flashWrite ====>\n")); */
value = (FLASH_CMD_WRITE_ENABLE << 24);
- if(wrmalt(Adapter, FLASH_SPI_CMDQ_REG,&value, sizeof(value)) < 0)
- {
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Write enable in FLASH_SPI_CMDQ_REG register fails");
+ if (wrmalt(Adapter, FLASH_SPI_CMDQ_REG, &value, sizeof(value)) < 0) {
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Write enable in FLASH_SPI_CMDQ_REG register fails");
return STATUS_SUCCESS;
}
- if(wrm(Adapter,FLASH_SPI_WRITEQ_REG, (PCHAR)&ulData, 4) < 0)
- {
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"DATA Write on FLASH_SPI_WRITEQ_REG fails");
+ if (wrm(Adapter, FLASH_SPI_WRITEQ_REG, (PCHAR)&ulData, 4) < 0) {
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "DATA Write on FLASH_SPI_WRITEQ_REG fails");
return STATUS_FAILURE;
}
value = (0x02000000 | (uiOffset & 0xFFFFFF));
- if(wrmalt(Adapter, FLASH_SPI_CMDQ_REG,&value, sizeof(value)) < 0)
- {
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Programming of FLASH_SPI_CMDQ_REG fails");
+ if (wrmalt(Adapter, FLASH_SPI_CMDQ_REG, &value, sizeof(value)) < 0) {
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Programming of FLASH_SPI_CMDQ_REG fails");
return STATUS_FAILURE;
}
- //msleep(1);
+ /* msleep(1); */
- do
- {
+ do {
value = (FLASH_CMD_STATUS_REG_READ << 24);
- if(wrmalt(Adapter, FLASH_SPI_CMDQ_REG, &value, sizeof(value)) < 0)
- {
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Programing of FLASH_SPI_CMDQ_REG fails");
+ if (wrmalt(Adapter, FLASH_SPI_CMDQ_REG, &value, sizeof(value)) < 0) {
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Programing of FLASH_SPI_CMDQ_REG fails");
return STATUS_FAILURE;
}
- //__udelay(1);
+ /* __udelay(1); */
bytes = rdmalt(Adapter, FLASH_SPI_READQ_REG, &uiStatus, sizeof(uiStatus));
if (bytes < 0) {
uiStatus = bytes;
@@ -907,405 +810,361 @@ static INT flashByteWriteStatus(
}
iRetries--;
- if( iRetries && ((iRetries % FLASH_PER_RETRIES_DELAY) == 0))
- msleep(1);
- }while((uiStatus & 0x1) && (iRetries > 0));
+ if (iRetries && ((iRetries % FLASH_PER_RETRIES_DELAY) == 0))
+ udelay(1000);
- if(uiStatus & 0x1)
- {
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Flash Write fails even after checking status for 200 times.");
- return STATUS_FAILURE ;
+ } while ((uiStatus & 0x1) && (iRetries > 0));
+
+ if (uiStatus & 0x1) {
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Flash Write fails even after checking status for 200 times.");
+ return STATUS_FAILURE;
}
return STATUS_SUCCESS;
-
}
-//-----------------------------------------------------------------------------
-// Procedure: flashWriteStatus
-//
-// Description: Performs write to flash with write done status check
-//
-// Arguments:
-// Adapter - ptr to Adapter object instance
-// uiOffset - Offset of the flash where data needs to be written to.
-// pData - Address of the Data to be written.
-// Returns:
-// OSAL_STATUS_CODE
-//
-//-----------------------------------------------------------------------------
-
-static INT flashWriteStatus(
- PMINI_ADAPTER Adapter,
- UINT uiOffset,
- PVOID pData)
+/*
+ * Procedure: flashWriteStatus
+ *
+ * Description: Performs write to flash with write done status check
+ *
+ * Arguments:
+ * Adapter - ptr to Adapter object instance
+ * uiOffset - Offset of the flash where data needs to be written to.
+ * pData - Address of the Data to be written.
+ * Returns:
+ * OSAL_STATUS_CODE
+ *
+ */
+
+static int flashWriteStatus(struct bcm_mini_adapter *Adapter,
+ unsigned int uiOffset,
+ PVOID pData)
{
- UINT uiStatus = 0;
- INT iRetries = MAX_FLASH_RETRIES * FLASH_PER_RETRIES_DELAY; //3
- //UINT uiReadBack = 0;
- UINT value;
- UINT uiErasePattern[4] = {0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF};
+ unsigned int uiStatus = 0;
+ int iRetries = MAX_FLASH_RETRIES * FLASH_PER_RETRIES_DELAY; /* 3 */
+ /* unsigned int uiReadBack = 0; */
+ unsigned int value;
+ unsigned int uiErasePattern[4] = {0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF};
int bytes;
-//
-// need not write 0xFFFFFFFF because write requires an erase and erase will
-// make whole sector 0xFFFFFFFF.
-//
- if (!memcmp(pData,uiErasePattern,MAX_RW_SIZE))
- {
+ /*
+ * need not write 0xFFFFFFFF because write requires an erase and erase will
+ * make whole sector 0xFFFFFFFF.
+ */
+ if (!memcmp(pData, uiErasePattern, MAX_RW_SIZE))
return 0;
- }
value = (FLASH_CMD_WRITE_ENABLE << 24);
- if(wrmalt(Adapter, FLASH_SPI_CMDQ_REG,&value, sizeof(value)) < 0)
- {
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Write Enable of FLASH_SPI_CMDQ_REG fails");
+ if (wrmalt(Adapter, FLASH_SPI_CMDQ_REG, &value, sizeof(value)) < 0) {
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Write Enable of FLASH_SPI_CMDQ_REG fails");
return STATUS_FAILURE;
}
- if(wrm(Adapter, uiOffset, (PCHAR)pData, MAX_RW_SIZE) < 0)
- {
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Data write fails...");
+
+ if (wrm(Adapter, uiOffset, (PCHAR)pData, MAX_RW_SIZE) < 0) {
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Data write fails...");
return STATUS_FAILURE;
}
- // __udelay(1);
+ /* __udelay(1); */
- do
- {
+ do {
value = (FLASH_CMD_STATUS_REG_READ << 24);
- if(wrmalt(Adapter, FLASH_SPI_CMDQ_REG, &value, sizeof(value)) < 0)
- {
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Programing of FLASH_SPI_CMDQ_REG fails");
+ if (wrmalt(Adapter, FLASH_SPI_CMDQ_REG, &value, sizeof(value)) < 0) {
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Programing of FLASH_SPI_CMDQ_REG fails");
return STATUS_FAILURE;
- }
- //__udelay(1);
+ }
+ /* __udelay(1); */
bytes = rdmalt(Adapter, FLASH_SPI_READQ_REG, &uiStatus, sizeof(uiStatus));
if (bytes < 0) {
uiStatus = bytes;
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Reading status of FLASH_SPI_READQ_REG fails");
return uiStatus;
}
- iRetries--;
- //this will ensure that in there will be no changes in the current path.
- //currently one rdm/wrm takes 125 us.
- //Hence 125 *2 * FLASH_PER_RETRIES_DELAY >3 ms(worst case delay)
- //Hence current implementation cycle will intoduce no delay in current path
- if(iRetries && ((iRetries % FLASH_PER_RETRIES_DELAY) == 0))
- msleep(1);
- }while((uiStatus & 0x1) && (iRetries >0));
-
- if(uiStatus & 0x1)
- {
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Flash Write fails even after checking status for 200 times.");
- return STATUS_FAILURE ;
+ iRetries--;
+ /* this will ensure that in there will be no changes in the current path.
+ * currently one rdm/wrm takes 125 us.
+ * Hence 125 *2 * FLASH_PER_RETRIES_DELAY >3 ms(worst case delay)
+ * Hence current implementation cycle will intoduce no delay in current path
+ */
+ if (iRetries && ((iRetries % FLASH_PER_RETRIES_DELAY) == 0))
+ udelay(1000);
+
+ } while ((uiStatus & 0x1) && (iRetries > 0));
+
+ if (uiStatus & 0x1) {
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Flash Write fails even after checking status for 200 times.");
+ return STATUS_FAILURE;
}
return STATUS_SUCCESS;
}
-//-----------------------------------------------------------------------------
-// Procedure: BcmRestoreBlockProtectStatus
-//
-// Description: Restores the original block protection status.
-//
-// Arguments:
-// Adapter - ptr to Adapter object instance
-// ulWriteStatus -Original status
-// Returns:
-// <VOID>
-//
-//-----------------------------------------------------------------------------
-
-static VOID BcmRestoreBlockProtectStatus(PMINI_ADAPTER Adapter,ULONG ulWriteStatus)
+/*
+ * Procedure: BcmRestoreBlockProtectStatus
+ *
+ * Description: Restores the original block protection status.
+ *
+ * Arguments:
+ * Adapter - ptr to Adapter object instance
+ * ulWriteStatus -Original status
+ * Returns:
+ * <VOID>
+ *
+ */
+
+static VOID BcmRestoreBlockProtectStatus(struct bcm_mini_adapter *Adapter, ULONG ulWriteStatus)
{
- UINT value;
- value = (FLASH_CMD_WRITE_ENABLE<< 24);
+ unsigned int value;
+ value = (FLASH_CMD_WRITE_ENABLE << 24);
wrmalt(Adapter, FLASH_SPI_CMDQ_REG, &value, sizeof(value));
udelay(20);
- value = (FLASH_CMD_STATUS_REG_WRITE<<24)|(ulWriteStatus << 16);
+ value = (FLASH_CMD_STATUS_REG_WRITE << 24) | (ulWriteStatus << 16);
wrmalt(Adapter, FLASH_SPI_CMDQ_REG, &value, sizeof(value));
udelay(20);
}
-//-----------------------------------------------------------------------------
-// Procedure: BcmFlashUnProtectBlock
-//
-// Description: UnProtects appropriate blocks for writing.
-//
-// Arguments:
-// Adapter - ptr to Adapter object instance
-// uiOffset - Offset of the flash where data needs to be written to. This should be Sector aligned.
-// Returns:
-// ULONG - Status value before UnProtect.
-//
-//-----------------------------------------------------------------------------
-static ULONG BcmFlashUnProtectBlock(PMINI_ADAPTER Adapter,UINT uiOffset, UINT uiLength)
+
+/*
+ * Procedure: BcmFlashUnProtectBlock
+ *
+ * Description: UnProtects appropriate blocks for writing.
+ *
+ * Arguments:
+ * Adapter - ptr to Adapter object instance
+ * uiOffset - Offset of the flash where data needs to be written to. This should be Sector aligned.
+ * Returns:
+ * ULONG - Status value before UnProtect.
+ *
+ */
+
+static ULONG BcmFlashUnProtectBlock(struct bcm_mini_adapter *Adapter, unsigned int uiOffset, unsigned int uiLength)
{
- ULONG ulStatus = 0;
- ULONG ulWriteStatus = 0;
- UINT value;
- uiOffset = uiOffset&0x000FFFFF;
+ ULONG ulStatus = 0;
+ ULONG ulWriteStatus = 0;
+ unsigned int value;
-//
-// Implemented only for 1MB Flash parts.
-//
- if(FLASH_PART_SST25VF080B == Adapter->ulFlashID)
- {
- //
- // Get Current BP status.
- //
+ uiOffset = uiOffset&0x000FFFFF;
+ /*
+ * Implemented only for 1MB Flash parts.
+ */
+ if (FLASH_PART_SST25VF080B == Adapter->ulFlashID) {
+ /*
+ * Get Current BP status.
+ */
value = (FLASH_CMD_STATUS_REG_READ << 24);
wrmalt(Adapter, FLASH_SPI_CMDQ_REG, &value, sizeof(value));
udelay(10);
- //
- // Read status will be WWXXYYZZ. We have to take only WW.
- //
+ /*
+ * Read status will be WWXXYYZZ. We have to take only WW.
+ */
rdmalt(Adapter, FLASH_SPI_READQ_REG, (PUINT)&ulStatus, sizeof(ulStatus));
ulStatus >>= 24;
ulWriteStatus = ulStatus;
-
- //
- // Bits [5-2] give current block level protection status.
- // Bit5: BP3 - DONT CARE
- // BP2-BP0: 0 - NO PROTECTION, 1 - UPPER 1/16, 2 - UPPER 1/8, 3 - UPPER 1/4
- // 4 - UPPER 1/2. 5 to 7 - ALL BLOCKS
- //
-
- if(ulStatus)
- {
- if((uiOffset+uiLength) <= 0x80000)
- {
- //
- // Offset comes in lower half of 1MB. Protect the upper half.
- // Clear BP1 and BP0 and set BP2.
- //
+ /*
+ * Bits [5-2] give current block level protection status.
+ * Bit5: BP3 - DONT CARE
+ * BP2-BP0: 0 - NO PROTECTION, 1 - UPPER 1/16, 2 - UPPER 1/8, 3 - UPPER 1/4
+ * 4 - UPPER 1/2. 5 to 7 - ALL BLOCKS
+ */
+
+ if (ulStatus) {
+ if ((uiOffset+uiLength) <= 0x80000) {
+ /*
+ * Offset comes in lower half of 1MB. Protect the upper half.
+ * Clear BP1 and BP0 and set BP2.
+ */
ulWriteStatus |= (0x4<<2);
ulWriteStatus &= ~(0x3<<2);
- }
- else if((uiOffset+uiLength) <= 0xC0000)
- {
- //
- // Offset comes below Upper 1/4. Upper 1/4 can be protected.
- // Clear BP2 and set BP1 and BP0.
- //
+ } else if ((uiOffset + uiLength) <= 0xC0000) {
+ /*
+ * Offset comes below Upper 1/4. Upper 1/4 can be protected.
+ * Clear BP2 and set BP1 and BP0.
+ */
ulWriteStatus |= (0x3<<2);
ulWriteStatus &= ~(0x1<<4);
+ } else if ((uiOffset + uiLength) <= 0xE0000) {
+ /*
+ * Offset comes below Upper 1/8. Upper 1/8 can be protected.
+ * Clear BP2 and BP0 and set BP1
+ */
+ ulWriteStatus |= (0x1<<3);
+ ulWriteStatus &= ~(0x5<<2);
+ } else if ((uiOffset + uiLength) <= 0xF0000) {
+ /*
+ * Offset comes below Upper 1/16. Only upper 1/16 can be protected.
+ * Set BP0 and Clear BP2,BP1.
+ */
+ ulWriteStatus |= (0x1<<2);
+ ulWriteStatus &= ~(0x3<<3);
+ } else {
+ /*
+ * Unblock all.
+ * Clear BP2,BP1 and BP0.
+ */
+ ulWriteStatus &= ~(0x7<<2);
}
- else if((uiOffset+uiLength) <= 0xE0000)
- {
- //
- // Offset comes below Upper 1/8. Upper 1/8 can be protected.
- // Clear BP2 and BP0 and set BP1
- //
- ulWriteStatus |= (0x1<<3);
- ulWriteStatus &= ~(0x5<<2);
-
- }
- else if((uiOffset+uiLength) <= 0xF0000)
- {
- //
- // Offset comes below Upper 1/16. Only upper 1/16 can be protected.
- // Set BP0 and Clear BP2,BP1.
- //
- ulWriteStatus |= (0x1<<2);
- ulWriteStatus &= ~(0x3<<3);
- }
- else
- {
- //
- // Unblock all.
- // Clear BP2,BP1 and BP0.
- //
- ulWriteStatus &= ~(0x7<<2);
- }
-
- value = (FLASH_CMD_WRITE_ENABLE<< 24);
+
+ value = (FLASH_CMD_WRITE_ENABLE << 24);
wrmalt(Adapter, FLASH_SPI_CMDQ_REG, &value, sizeof(value));
udelay(20);
- value = (FLASH_CMD_STATUS_REG_WRITE<<24)|(ulWriteStatus << 16);
+ value = (FLASH_CMD_STATUS_REG_WRITE << 24) | (ulWriteStatus << 16);
wrmalt(Adapter, FLASH_SPI_CMDQ_REG, &value, sizeof(value));
udelay(20);
-
}
-
}
return ulStatus;
}
-//-----------------------------------------------------------------------------
-// Procedure: BeceemFlashBulkWrite
-//
-// Description: Performs write to the flash
-//
-// Arguments:
-// Adapter - ptr to Adapter object instance
-// pBuffer - Data to be written.
-// uiOffset - Offset of the flash where data needs to be written to.
-// uiNumBytes - Number of bytes to be written.
-// bVerify - read verify flag.
-// Returns:
-// OSAL_STATUS_CODE
-//
-//-----------------------------------------------------------------------------
-
-static INT BeceemFlashBulkWrite(
- PMINI_ADAPTER Adapter,
- PUINT pBuffer,
- UINT uiOffset,
- UINT uiNumBytes,
- BOOLEAN bVerify)
+
+/*
+ * Procedure: BeceemFlashBulkWrite
+ *
+ * Description: Performs write to the flash
+ *
+ * Arguments:
+ * Adapter - ptr to Adapter object instance
+ * pBuffer - Data to be written.
+ * uiOffset - Offset of the flash where data needs to be written to.
+ * uiNumBytes - Number of bytes to be written.
+ * bVerify - read verify flag.
+ * Returns:
+ * OSAL_STATUS_CODE
+ *
+ */
+
+static int BeceemFlashBulkWrite(struct bcm_mini_adapter *Adapter,
+ PUINT pBuffer,
+ unsigned int uiOffset,
+ unsigned int uiNumBytes,
+ BOOLEAN bVerify)
{
- PCHAR pTempBuff = NULL;
- PUCHAR pcBuffer = (PUCHAR)pBuffer;
- UINT uiIndex = 0;
- UINT uiOffsetFromSectStart = 0;
- UINT uiSectAlignAddr = 0;
- UINT uiCurrSectOffsetAddr = 0;
- UINT uiSectBoundary = 0;
- UINT uiNumSectTobeRead = 0;
- UCHAR ucReadBk[16] = {0};
- ULONG ulStatus = 0;
- INT Status = STATUS_SUCCESS;
- UINT uiTemp = 0;
- UINT index = 0;
- UINT uiPartOffset = 0;
-
-#if defined(BCM_SHM_INTERFACE) && !defined(FLASH_DIRECT_ACCESS)
- Status = bcmflash_raw_write((uiOffset/FLASH_PART_SIZE),(uiOffset % FLASH_PART_SIZE),( unsigned char *)pBuffer,uiNumBytes);
- return Status;
-#endif
-
- uiOffsetFromSectStart = uiOffset & ~(Adapter->uiSectorSize - 1);
-
- //Adding flash Base address
-// uiOffset = uiOffset + GetFlashBaseAddr(Adapter);
-
- uiSectAlignAddr = uiOffset & ~(Adapter->uiSectorSize - 1);
- uiCurrSectOffsetAddr = uiOffset & (Adapter->uiSectorSize - 1);
- uiSectBoundary = uiSectAlignAddr + Adapter->uiSectorSize;
+ PCHAR pTempBuff = NULL;
+ PUCHAR pcBuffer = (PUCHAR)pBuffer;
+ unsigned int uiIndex = 0;
+ unsigned int uiOffsetFromSectStart = 0;
+ unsigned int uiSectAlignAddr = 0;
+ unsigned int uiCurrSectOffsetAddr = 0;
+ unsigned int uiSectBoundary = 0;
+ unsigned int uiNumSectTobeRead = 0;
+ UCHAR ucReadBk[16] = {0};
+ ULONG ulStatus = 0;
+ int Status = STATUS_SUCCESS;
+ unsigned int uiTemp = 0;
+ unsigned int index = 0;
+ unsigned int uiPartOffset = 0;
+
+ #if defined(BCM_SHM_INTERFACE) && !defined(FLASH_DIRECT_ACCESS)
+ Status = bcmflash_raw_write((uiOffset / FLASH_PART_SIZE), (uiOffset % FLASH_PART_SIZE), (unsigned char *)pBuffer, uiNumBytes);
+ return Status;
+ #endif
+
+ uiOffsetFromSectStart = uiOffset & ~(Adapter->uiSectorSize - 1);
+
+ /* Adding flash Base address
+ * uiOffset = uiOffset + GetFlashBaseAddr(Adapter);
+ */
+
+ uiSectAlignAddr = uiOffset & ~(Adapter->uiSectorSize - 1);
+ uiCurrSectOffsetAddr = uiOffset & (Adapter->uiSectorSize - 1);
+ uiSectBoundary = uiSectAlignAddr + Adapter->uiSectorSize;
pTempBuff = kmalloc(Adapter->uiSectorSize, GFP_KERNEL);
- if(NULL == pTempBuff)
+ if (!pTempBuff)
goto BeceemFlashBulkWrite_EXIT;
-//
-// check if the data to be written is overlapped across sectors
-//
- if(uiOffset+uiNumBytes < uiSectBoundary)
- {
+ /*
+ * check if the data to be written is overlapped across sectors
+ */
+ if (uiOffset+uiNumBytes < uiSectBoundary) {
uiNumSectTobeRead = 1;
- }
- else
- {
- // Number of sectors = Last sector start address/First sector start address
- uiNumSectTobeRead = (uiCurrSectOffsetAddr+uiNumBytes)/Adapter->uiSectorSize;
- if((uiCurrSectOffsetAddr+uiNumBytes)%Adapter->uiSectorSize)
- {
+ } else {
+ /* Number of sectors = Last sector start address/First sector start address */
+ uiNumSectTobeRead = (uiCurrSectOffsetAddr + uiNumBytes) / Adapter->uiSectorSize;
+ if ((uiCurrSectOffsetAddr + uiNumBytes)%Adapter->uiSectorSize)
uiNumSectTobeRead++;
- }
}
- //Check whether Requested sector is writable or not in case of flash2x write. But if write call is
- // for DSD calibration, allow it without checking of sector permission
+ /* Check whether Requested sector is writable or not in case of flash2x write. But if write call is
+ * for DSD calibration, allow it without checking of sector permission
+ */
- if(IsFlash2x(Adapter) && (Adapter->bAllDSDWriteAllow == FALSE))
- {
+ if (IsFlash2x(Adapter) && (Adapter->bAllDSDWriteAllow == FALSE)) {
index = 0;
- uiTemp = uiNumSectTobeRead ;
- while(uiTemp)
- {
- if(IsOffsetWritable(Adapter, uiOffsetFromSectStart + index * Adapter->uiSectorSize ) == FALSE)
- {
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Sector Starting at offset <0X%X> is not writable",
- (uiOffsetFromSectStart + index * Adapter->uiSectorSize));
+ uiTemp = uiNumSectTobeRead;
+ while (uiTemp) {
+ if (IsOffsetWritable(Adapter, uiOffsetFromSectStart + index * Adapter->uiSectorSize) == FALSE) {
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Sector Starting at offset <0X%X> is not writable",
+ (uiOffsetFromSectStart + index * Adapter->uiSectorSize));
Status = SECTOR_IS_NOT_WRITABLE;
goto BeceemFlashBulkWrite_EXIT;
- }
- uiTemp = uiTemp - 1;
- index = index + 1 ;
+ }
+ uiTemp = uiTemp - 1;
+ index = index + 1 ;
}
}
Adapter->SelectedChip = RESET_CHIP_SELECT;
- while(uiNumSectTobeRead)
- {
- //do_gettimeofday(&tv1);
- //BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "\nTime In start of write :%ld ms\n",(tv1.tv_sec *1000 + tv1.tv_usec /1000));
+ while (uiNumSectTobeRead) {
+ /* do_gettimeofday(&tv1);
+ * BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "\nTime In start of write :%ld ms\n",(tv1.tv_sec *1000 + tv1.tv_usec /1000));
+ */
uiPartOffset = (uiSectAlignAddr & (FLASH_PART_SIZE - 1)) + GetFlashBaseAddr(Adapter);
- BcmDoChipSelect(Adapter,uiSectAlignAddr);
+ BcmDoChipSelect(Adapter, uiSectAlignAddr);
- if(0 != BeceemFlashBulkRead(Adapter,
+ if (0 != BeceemFlashBulkRead(Adapter,
(PUINT)pTempBuff,
uiOffsetFromSectStart,
- Adapter->uiSectorSize))
- {
+ Adapter->uiSectorSize)) {
Status = -1;
goto BeceemFlashBulkWrite_EXIT;
}
- //do_gettimeofday(&tr);
- //BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Total time taken by Read :%ld ms\n", (tr.tv_sec *1000 + tr.tv_usec/1000) - (tv1.tv_sec *1000 + tv1.tv_usec/1000));
-
- ulStatus = BcmFlashUnProtectBlock(Adapter,uiSectAlignAddr,Adapter->uiSectorSize);
-
-
- if(uiNumSectTobeRead > 1)
- {
-
- memcpy(&pTempBuff[uiCurrSectOffsetAddr],pcBuffer,uiSectBoundary-(uiSectAlignAddr+uiCurrSectOffsetAddr));
- pcBuffer += ((uiSectBoundary-(uiSectAlignAddr+uiCurrSectOffsetAddr)));
- uiNumBytes -= (uiSectBoundary-(uiSectAlignAddr+uiCurrSectOffsetAddr));
- }
- else
- {
- memcpy(&pTempBuff[uiCurrSectOffsetAddr],pcBuffer,uiNumBytes);
- }
-
- if(IsFlash2x(Adapter))
- {
- SaveHeaderIfPresent(Adapter,(PUCHAR)pTempBuff,uiOffsetFromSectStart);
+ /* do_gettimeofday(&tr);
+ * BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Total time taken by Read :%ld ms\n", (tr.tv_sec *1000 + tr.tv_usec/1000) - (tv1.tv_sec *1000 + tv1.tv_usec/1000));
+ */
+ ulStatus = BcmFlashUnProtectBlock(Adapter, uiSectAlignAddr, Adapter->uiSectorSize);
+
+ if (uiNumSectTobeRead > 1) {
+ memcpy(&pTempBuff[uiCurrSectOffsetAddr], pcBuffer, uiSectBoundary - (uiSectAlignAddr + uiCurrSectOffsetAddr));
+ pcBuffer += ((uiSectBoundary - (uiSectAlignAddr + uiCurrSectOffsetAddr)));
+ uiNumBytes -= (uiSectBoundary - (uiSectAlignAddr + uiCurrSectOffsetAddr));
+ } else {
+ memcpy(&pTempBuff[uiCurrSectOffsetAddr], pcBuffer, uiNumBytes);
}
- FlashSectorErase(Adapter,uiPartOffset,1);
- //do_gettimeofday(&te);
- //BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Total time taken by Erase :%ld ms\n", (te.tv_sec *1000 + te.tv_usec/1000) - (tr.tv_sec *1000 + tr.tv_usec/1000));
+ if (IsFlash2x(Adapter))
+ SaveHeaderIfPresent(Adapter, (PUCHAR)pTempBuff, uiOffsetFromSectStart);
- for(uiIndex = 0; uiIndex < Adapter->uiSectorSize; uiIndex +=Adapter->ulFlashWriteSize)
- {
- if(Adapter->device_removed)
- {
+ FlashSectorErase(Adapter, uiPartOffset, 1);
+ /* do_gettimeofday(&te);
+ * BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Total time taken by Erase :%ld ms\n", (te.tv_sec *1000 + te.tv_usec/1000) - (tr.tv_sec *1000 + tr.tv_usec/1000));
+ */
+ for (uiIndex = 0; uiIndex < Adapter->uiSectorSize; uiIndex += Adapter->ulFlashWriteSize) {
+ if (Adapter->device_removed) {
Status = -1;
goto BeceemFlashBulkWrite_EXIT;
}
- if(STATUS_SUCCESS != (*Adapter->fpFlashWrite)(Adapter,uiPartOffset+uiIndex,(&pTempBuff[uiIndex])))
- {
+
+ if (STATUS_SUCCESS != (*Adapter->fpFlashWrite)(Adapter, uiPartOffset + uiIndex, (&pTempBuff[uiIndex]))) {
Status = -1;
goto BeceemFlashBulkWrite_EXIT;
}
}
- //do_gettimeofday(&tw);
- //BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Total time taken in Write to Flash :%ld ms\n", (tw.tv_sec *1000 + tw.tv_usec/1000) - (te.tv_sec *1000 + te.tv_usec/1000));
- for(uiIndex = 0;uiIndex < Adapter->uiSectorSize;uiIndex += MAX_RW_SIZE)
- {
- if(STATUS_SUCCESS == BeceemFlashBulkRead(Adapter,(PUINT)ucReadBk,uiOffsetFromSectStart+uiIndex,MAX_RW_SIZE))
- {
- if(Adapter->ulFlashWriteSize == 1)
- {
- UINT uiReadIndex = 0;
- for(uiReadIndex = 0; uiReadIndex < 16; uiReadIndex++)
- {
- if(ucReadBk[uiReadIndex] != pTempBuff[uiIndex+uiReadIndex])
- {
- if(STATUS_SUCCESS != (*Adapter->fpFlashWriteWithStatusCheck)(Adapter,uiPartOffset+uiIndex+uiReadIndex,&pTempBuff[uiIndex+uiReadIndex]))
- {
+ /* do_gettimeofday(&tw);
+ * BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Total time taken in Write to Flash :%ld ms\n", (tw.tv_sec *1000 + tw.tv_usec/1000) - (te.tv_sec *1000 + te.tv_usec/1000));
+ */
+ for (uiIndex = 0; uiIndex < Adapter->uiSectorSize; uiIndex += MAX_RW_SIZE) {
+ if (STATUS_SUCCESS == BeceemFlashBulkRead(Adapter, (PUINT)ucReadBk, uiOffsetFromSectStart + uiIndex, MAX_RW_SIZE)) {
+ if (Adapter->ulFlashWriteSize == 1) {
+ unsigned int uiReadIndex = 0;
+ for (uiReadIndex = 0; uiReadIndex < 16; uiReadIndex++) {
+ if (ucReadBk[uiReadIndex] != pTempBuff[uiIndex + uiReadIndex]) {
+ if (STATUS_SUCCESS != (*Adapter->fpFlashWriteWithStatusCheck)(Adapter, uiPartOffset + uiIndex + uiReadIndex, &pTempBuff[uiIndex+uiReadIndex])) {
Status = STATUS_FAILURE;
goto BeceemFlashBulkWrite_EXIT;
}
}
}
- }
- else
- {
- if(memcmp(ucReadBk,&pTempBuff[uiIndex],MAX_RW_SIZE))
- {
- if(STATUS_SUCCESS != (*Adapter->fpFlashWriteWithStatusCheck)(Adapter,uiPartOffset+uiIndex,&pTempBuff[uiIndex]))
- {
+ } else {
+ if (memcmp(ucReadBk, &pTempBuff[uiIndex], MAX_RW_SIZE)) {
+ if (STATUS_SUCCESS != (*Adapter->fpFlashWriteWithStatusCheck)(Adapter, uiPartOffset + uiIndex, &pTempBuff[uiIndex])) {
Status = STATUS_FAILURE;
goto BeceemFlashBulkWrite_EXIT;
}
@@ -1313,13 +1172,11 @@ static INT BeceemFlashBulkWrite(
}
}
}
- //do_gettimeofday(&twv);
- //BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Total time taken in Write to Flash verification :%ld ms\n", (twv.tv_sec *1000 + twv.tv_usec/1000) - (tw.tv_sec *1000 + tw.tv_usec/1000));
-
-
- if(ulStatus)
- {
- BcmRestoreBlockProtectStatus(Adapter,ulStatus);
+ /* do_gettimeofday(&twv);
+ * BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Total time taken in Write to Flash verification :%ld ms\n", (twv.tv_sec *1000 + twv.tv_usec/1000) - (tw.tv_sec *1000 + tw.tv_usec/1000));
+ */
+ if (ulStatus) {
+ BcmRestoreBlockProtectStatus(Adapter, ulStatus);
ulStatus = 0;
}
@@ -1329,185 +1186,153 @@ static INT BeceemFlashBulkWrite(
uiOffsetFromSectStart += Adapter->uiSectorSize;
uiNumSectTobeRead--;
}
- //do_gettimeofday(&tv2);
- //BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Time after Write :%ld ms\n",(tv2.tv_sec *1000 + tv2.tv_usec/1000));
- //BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Total time taken by in Write is :%ld ms\n", (tv2.tv_sec *1000 + tv2.tv_usec/1000) - (tv1.tv_sec *1000 + tv1.tv_usec/1000));
-//
-// Cleanup.
-//
+ /* do_gettimeofday(&tv2);
+ * BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Time after Write :%ld ms\n",(tv2.tv_sec *1000 + tv2.tv_usec/1000));
+ * BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Total time taken by in Write is :%ld ms\n", (tv2.tv_sec *1000 + tv2.tv_usec/1000) - (tv1.tv_sec *1000 + tv1.tv_usec/1000));
+ *
+ * Cleanup.
+ */
BeceemFlashBulkWrite_EXIT:
- if(ulStatus)
- {
- BcmRestoreBlockProtectStatus(Adapter,ulStatus);
- }
-
+ if (ulStatus)
+ BcmRestoreBlockProtectStatus(Adapter, ulStatus);
+
kfree(pTempBuff);
Adapter->SelectedChip = RESET_CHIP_SELECT;
return Status;
}
-
-//-----------------------------------------------------------------------------
-// Procedure: BeceemFlashBulkWriteStatus
-//
-// Description: Writes to Flash. Checks the SPI status after each write.
-//
-// Arguments:
-// Adapter - ptr to Adapter object instance
-// pBuffer - Data to be written.
-// uiOffset - Offset of the flash where data needs to be written to.
-// uiNumBytes - Number of bytes to be written.
-// bVerify - read verify flag.
-// Returns:
-// OSAL_STATUS_CODE
-//
-//-----------------------------------------------------------------------------
-
-static INT BeceemFlashBulkWriteStatus(
- PMINI_ADAPTER Adapter,
- PUINT pBuffer,
- UINT uiOffset,
- UINT uiNumBytes,
- BOOLEAN bVerify)
+/*
+ * Procedure: BeceemFlashBulkWriteStatus
+ *
+ * Description: Writes to Flash. Checks the SPI status after each write.
+ *
+ * Arguments:
+ * Adapter - ptr to Adapter object instance
+ * pBuffer - Data to be written.
+ * uiOffset - Offset of the flash where data needs to be written to.
+ * uiNumBytes - Number of bytes to be written.
+ * bVerify - read verify flag.
+ * Returns:
+ * OSAL_STATUS_CODE
+ *
+ */
+
+static int BeceemFlashBulkWriteStatus(struct bcm_mini_adapter *Adapter,
+ PUINT pBuffer,
+ unsigned int uiOffset,
+ unsigned int uiNumBytes,
+ BOOLEAN bVerify)
{
- PCHAR pTempBuff = NULL;
- PUCHAR pcBuffer = (PUCHAR)pBuffer;
- UINT uiIndex = 0;
- UINT uiOffsetFromSectStart = 0;
- UINT uiSectAlignAddr = 0;
- UINT uiCurrSectOffsetAddr = 0;
- UINT uiSectBoundary = 0;
- UINT uiNumSectTobeRead = 0;
- UCHAR ucReadBk[16] = {0};
- ULONG ulStatus = 0;
- UINT Status = STATUS_SUCCESS;
- UINT uiTemp = 0;
- UINT index = 0;
- UINT uiPartOffset = 0;
-
- uiOffsetFromSectStart = uiOffset & ~(Adapter->uiSectorSize - 1);
-
- //uiOffset += Adapter->ulFlashCalStart;
- //Adding flash Base address
-// uiOffset = uiOffset + GetFlashBaseAddr(Adapter);
-
- uiSectAlignAddr = uiOffset & ~(Adapter->uiSectorSize - 1);
- uiCurrSectOffsetAddr = uiOffset & (Adapter->uiSectorSize - 1);
- uiSectBoundary = uiSectAlignAddr + Adapter->uiSectorSize;
+ PCHAR pTempBuff = NULL;
+ PUCHAR pcBuffer = (PUCHAR)pBuffer;
+ unsigned int uiIndex = 0;
+ unsigned int uiOffsetFromSectStart = 0;
+ unsigned int uiSectAlignAddr = 0;
+ unsigned int uiCurrSectOffsetAddr = 0;
+ unsigned int uiSectBoundary = 0;
+ unsigned int uiNumSectTobeRead = 0;
+ UCHAR ucReadBk[16] = {0};
+ ULONG ulStatus = 0;
+ unsigned int Status = STATUS_SUCCESS;
+ unsigned int uiTemp = 0;
+ unsigned int index = 0;
+ unsigned int uiPartOffset = 0;
+
+ uiOffsetFromSectStart = uiOffset & ~(Adapter->uiSectorSize - 1);
+
+ /* uiOffset += Adapter->ulFlashCalStart;
+ * Adding flash Base address
+ * uiOffset = uiOffset + GetFlashBaseAddr(Adapter);
+ */
+ uiSectAlignAddr = uiOffset & ~(Adapter->uiSectorSize - 1);
+ uiCurrSectOffsetAddr = uiOffset & (Adapter->uiSectorSize - 1);
+ uiSectBoundary = uiSectAlignAddr + Adapter->uiSectorSize;
pTempBuff = kmalloc(Adapter->uiSectorSize, GFP_KERNEL);
- if(NULL == pTempBuff)
+ if (!pTempBuff)
goto BeceemFlashBulkWriteStatus_EXIT;
-//
-// check if the data to be written is overlapped across sectors
-//
- if(uiOffset+uiNumBytes < uiSectBoundary)
- {
+ /*
+ * check if the data to be written is overlapped across sectors
+ */
+ if (uiOffset+uiNumBytes < uiSectBoundary) {
uiNumSectTobeRead = 1;
- }
- else
- {
-// Number of sectors = Last sector start address/First sector start address
- uiNumSectTobeRead = (uiCurrSectOffsetAddr+uiNumBytes)/Adapter->uiSectorSize;
- if((uiCurrSectOffsetAddr+uiNumBytes)%Adapter->uiSectorSize)
- {
+ } else {
+ /* Number of sectors = Last sector start address/First sector start address */
+ uiNumSectTobeRead = (uiCurrSectOffsetAddr + uiNumBytes) / Adapter->uiSectorSize;
+ if ((uiCurrSectOffsetAddr + uiNumBytes)%Adapter->uiSectorSize)
uiNumSectTobeRead++;
- }
}
- if(IsFlash2x(Adapter) && (Adapter->bAllDSDWriteAllow == FALSE))
- {
+ if (IsFlash2x(Adapter) && (Adapter->bAllDSDWriteAllow == FALSE)) {
index = 0;
- uiTemp = uiNumSectTobeRead ;
- while(uiTemp)
- {
- if(IsOffsetWritable(Adapter,uiOffsetFromSectStart + index * Adapter->uiSectorSize ) == FALSE)
- {
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Sector Starting at offset <0X%x> is not writable",
- (uiOffsetFromSectStart + index * Adapter->uiSectorSize));
+ uiTemp = uiNumSectTobeRead;
+ while (uiTemp) {
+ if (IsOffsetWritable(Adapter, uiOffsetFromSectStart + index * Adapter->uiSectorSize) == FALSE) {
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Sector Starting at offset <0X%x> is not writable",
+ (uiOffsetFromSectStart + index * Adapter->uiSectorSize));
Status = SECTOR_IS_NOT_WRITABLE;
goto BeceemFlashBulkWriteStatus_EXIT;
- }
- uiTemp = uiTemp - 1;
- index = index + 1 ;
+ }
+ uiTemp = uiTemp - 1;
+ index = index + 1 ;
}
}
Adapter->SelectedChip = RESET_CHIP_SELECT;
- while(uiNumSectTobeRead)
- {
+ while (uiNumSectTobeRead) {
uiPartOffset = (uiSectAlignAddr & (FLASH_PART_SIZE - 1)) + GetFlashBaseAddr(Adapter);
- BcmDoChipSelect(Adapter,uiSectAlignAddr);
- if(0 != BeceemFlashBulkRead(Adapter,
+ BcmDoChipSelect(Adapter, uiSectAlignAddr);
+ if (0 != BeceemFlashBulkRead(Adapter,
(PUINT)pTempBuff,
uiOffsetFromSectStart,
- Adapter->uiSectorSize))
- {
+ Adapter->uiSectorSize)) {
Status = -1;
goto BeceemFlashBulkWriteStatus_EXIT;
}
- ulStatus = BcmFlashUnProtectBlock(Adapter,uiOffsetFromSectStart,Adapter->uiSectorSize);
-
- if(uiNumSectTobeRead > 1)
- {
+ ulStatus = BcmFlashUnProtectBlock(Adapter, uiOffsetFromSectStart, Adapter->uiSectorSize);
- memcpy(&pTempBuff[uiCurrSectOffsetAddr],pcBuffer,uiSectBoundary-(uiSectAlignAddr+uiCurrSectOffsetAddr));
- pcBuffer += ((uiSectBoundary-(uiSectAlignAddr+uiCurrSectOffsetAddr)));
- uiNumBytes -= (uiSectBoundary-(uiSectAlignAddr+uiCurrSectOffsetAddr));
- }
- else
- {
- memcpy(&pTempBuff[uiCurrSectOffsetAddr],pcBuffer,uiNumBytes);
+ if (uiNumSectTobeRead > 1) {
+ memcpy(&pTempBuff[uiCurrSectOffsetAddr], pcBuffer, uiSectBoundary - (uiSectAlignAddr + uiCurrSectOffsetAddr));
+ pcBuffer += ((uiSectBoundary - (uiSectAlignAddr + uiCurrSectOffsetAddr)));
+ uiNumBytes -= (uiSectBoundary - (uiSectAlignAddr + uiCurrSectOffsetAddr));
+ } else {
+ memcpy(&pTempBuff[uiCurrSectOffsetAddr], pcBuffer, uiNumBytes);
}
- if(IsFlash2x(Adapter))
- {
- SaveHeaderIfPresent(Adapter,(PUCHAR)pTempBuff,uiOffsetFromSectStart);
- }
+ if (IsFlash2x(Adapter))
+ SaveHeaderIfPresent(Adapter, (PUCHAR)pTempBuff, uiOffsetFromSectStart);
- FlashSectorErase(Adapter,uiPartOffset,1);
+ FlashSectorErase(Adapter, uiPartOffset, 1);
- for(uiIndex = 0; uiIndex < Adapter->uiSectorSize; uiIndex +=Adapter->ulFlashWriteSize)
-
- {
- if(Adapter->device_removed)
- {
+ for (uiIndex = 0; uiIndex < Adapter->uiSectorSize; uiIndex += Adapter->ulFlashWriteSize) {
+ if (Adapter->device_removed) {
Status = -1;
goto BeceemFlashBulkWriteStatus_EXIT;
}
- if(STATUS_SUCCESS != (*Adapter->fpFlashWriteWithStatusCheck)(Adapter,uiPartOffset+uiIndex,&pTempBuff[uiIndex]))
- {
+ if (STATUS_SUCCESS != (*Adapter->fpFlashWriteWithStatusCheck)(Adapter, uiPartOffset+uiIndex, &pTempBuff[uiIndex])) {
Status = -1;
goto BeceemFlashBulkWriteStatus_EXIT;
}
}
- if(bVerify)
- {
- for(uiIndex = 0;uiIndex < Adapter->uiSectorSize;uiIndex += MAX_RW_SIZE)
- {
-
- if(STATUS_SUCCESS == BeceemFlashBulkRead(Adapter,(PUINT)ucReadBk,uiOffsetFromSectStart+uiIndex,MAX_RW_SIZE))
- {
- if(memcmp(ucReadBk,&pTempBuff[uiIndex],MAX_RW_SIZE))
- {
+ if (bVerify) {
+ for (uiIndex = 0; uiIndex < Adapter->uiSectorSize; uiIndex += MAX_RW_SIZE) {
+ if (STATUS_SUCCESS == BeceemFlashBulkRead(Adapter, (PUINT)ucReadBk, uiOffsetFromSectStart + uiIndex, MAX_RW_SIZE)) {
+ if (memcmp(ucReadBk, &pTempBuff[uiIndex], MAX_RW_SIZE)) {
Status = STATUS_FAILURE;
goto BeceemFlashBulkWriteStatus_EXIT;
}
-
}
-
}
}
- if(ulStatus)
- {
- BcmRestoreBlockProtectStatus(Adapter,ulStatus);
+ if (ulStatus) {
+ BcmRestoreBlockProtectStatus(Adapter, ulStatus);
ulStatus = 0;
}
@@ -1517,265 +1342,231 @@ static INT BeceemFlashBulkWriteStatus(
uiOffsetFromSectStart += Adapter->uiSectorSize;
uiNumSectTobeRead--;
}
-//
-// Cleanup.
-//
+/*
+ * Cleanup.
+ */
BeceemFlashBulkWriteStatus_EXIT:
- if(ulStatus)
- {
- BcmRestoreBlockProtectStatus(Adapter,ulStatus);
- }
+ if (ulStatus)
+ BcmRestoreBlockProtectStatus(Adapter, ulStatus);
kfree(pTempBuff);
Adapter->SelectedChip = RESET_CHIP_SELECT;
return Status;
-
}
-//-----------------------------------------------------------------------------
-// Procedure: PropagateCalParamsFromEEPROMToMemory
-//
-// Description: Dumps the calibration section of EEPROM to DDR.
-//
-// Arguments:
-// Adapter - ptr to Adapter object instance
-// Returns:
-// OSAL_STATUS_CODE
-//
-//-----------------------------------------------------------------------------
-
-
-INT PropagateCalParamsFromEEPROMToMemory(PMINI_ADAPTER Adapter)
+/*
+ * Procedure: PropagateCalParamsFromEEPROMToMemory
+ *
+ * Description: Dumps the calibration section of EEPROM to DDR.
+ *
+ * Arguments:
+ * Adapter - ptr to Adapter object instance
+ * Returns:
+ * OSAL_STATUS_CODE
+ *
+ */
+
+int PropagateCalParamsFromEEPROMToMemory(struct bcm_mini_adapter *Adapter)
{
PCHAR pBuff = kmalloc(BUFFER_4K, GFP_KERNEL);
- UINT uiEepromSize = 0;
- UINT uiIndex = 0;
- UINT uiBytesToCopy = 0;
- UINT uiCalStartAddr = EEPROM_CALPARAM_START;
- UINT uiMemoryLoc = EEPROM_CAL_DATA_INTERNAL_LOC;
- UINT value;
- INT Status = 0;
- if(pBuff == NULL)
- {
- return -1;
- }
-
- if(0 != BeceemEEPROMBulkRead(Adapter,&uiEepromSize,EEPROM_SIZE_OFFSET,4))
- {
+ unsigned int uiEepromSize = 0;
+ unsigned int uiIndex = 0;
+ unsigned int uiBytesToCopy = 0;
+ unsigned int uiCalStartAddr = EEPROM_CALPARAM_START;
+ unsigned int uiMemoryLoc = EEPROM_CAL_DATA_INTERNAL_LOC;
+ unsigned int value;
+ int Status = 0;
+
+ if (!pBuff)
+ return -ENOMEM;
+ if (0 != BeceemEEPROMBulkRead(Adapter, &uiEepromSize, EEPROM_SIZE_OFFSET, 4)) {
kfree(pBuff);
return -1;
}
uiEepromSize >>= 16;
- if(uiEepromSize > 1024*1024)
- {
+ if (uiEepromSize > 1024 * 1024) {
kfree(pBuff);
return -1;
}
+ uiBytesToCopy = MIN(BUFFER_4K, uiEepromSize);
- uiBytesToCopy = MIN(BUFFER_4K,uiEepromSize);
-
- while(uiBytesToCopy)
- {
- if(0 != BeceemEEPROMBulkRead(Adapter,(PUINT)pBuff,uiCalStartAddr,uiBytesToCopy))
- {
+ while (uiBytesToCopy) {
+ if (0 != BeceemEEPROMBulkRead(Adapter, (PUINT)pBuff, uiCalStartAddr, uiBytesToCopy)) {
Status = -1;
break;
}
- wrm(Adapter,uiMemoryLoc,(PCHAR)(((PULONG)pBuff)+uiIndex),uiBytesToCopy);
+ wrm(Adapter, uiMemoryLoc, (PCHAR)(((PULONG)pBuff) + uiIndex), uiBytesToCopy);
uiMemoryLoc += uiBytesToCopy;
uiEepromSize -= uiBytesToCopy;
uiCalStartAddr += uiBytesToCopy;
- uiIndex += uiBytesToCopy/4;
- uiBytesToCopy = MIN(BUFFER_4K,uiEepromSize);
+ uiIndex += uiBytesToCopy / 4;
+ uiBytesToCopy = MIN(BUFFER_4K, uiEepromSize);
}
value = 0xbeadbead;
- wrmalt(Adapter, EEPROM_CAL_DATA_INTERNAL_LOC-4,&value, sizeof(value));
+ wrmalt(Adapter, EEPROM_CAL_DATA_INTERNAL_LOC - 4, &value, sizeof(value));
value = 0xbeadbead;
- wrmalt(Adapter, EEPROM_CAL_DATA_INTERNAL_LOC-8,&value, sizeof(value));
+ wrmalt(Adapter, EEPROM_CAL_DATA_INTERNAL_LOC - 8, &value, sizeof(value));
kfree(pBuff);
return Status;
-
}
-//-----------------------------------------------------------------------------
-// Procedure: PropagateCalParamsFromFlashToMemory
-//
-// Description: Dumps the calibration section of EEPROM to DDR.
-//
-// Arguments:
-// Adapter - ptr to Adapter object instance
-// Returns:
-// OSAL_STATUS_CODE
-//
-//-----------------------------------------------------------------------------
-
-INT PropagateCalParamsFromFlashToMemory(PMINI_ADAPTER Adapter)
+/*
+ * Procedure: PropagateCalParamsFromFlashToMemory
+ *
+ * Description: Dumps the calibration section of EEPROM to DDR.
+ *
+ * Arguments:
+ * Adapter - ptr to Adapter object instance
+ * Returns:
+ * OSAL_STATUS_CODE
+ *
+ */
+
+int PropagateCalParamsFromFlashToMemory(struct bcm_mini_adapter *Adapter)
{
PCHAR pBuff, pPtr;
- UINT uiEepromSize = 0;
- UINT uiBytesToCopy = 0;
- //UINT uiIndex = 0;
- UINT uiCalStartAddr = EEPROM_CALPARAM_START;
- UINT uiMemoryLoc = EEPROM_CAL_DATA_INTERNAL_LOC;
- UINT value;
- INT Status = 0;
-//
-// Write the signature first. This will ensure firmware does not access EEPROM.
-//
+ unsigned int uiEepromSize = 0;
+ unsigned int uiBytesToCopy = 0;
+ /* unsigned int uiIndex = 0; */
+ unsigned int uiCalStartAddr = EEPROM_CALPARAM_START;
+ unsigned int uiMemoryLoc = EEPROM_CAL_DATA_INTERNAL_LOC;
+ unsigned int value;
+ int Status = 0;
+
+ /*
+ * Write the signature first. This will ensure firmware does not access EEPROM.
+ */
value = 0xbeadbead;
wrmalt(Adapter, EEPROM_CAL_DATA_INTERNAL_LOC - 4, &value, sizeof(value));
value = 0xbeadbead;
wrmalt(Adapter, EEPROM_CAL_DATA_INTERNAL_LOC - 8, &value, sizeof(value));
- if(0 != BeceemNVMRead(Adapter,&uiEepromSize,EEPROM_SIZE_OFFSET, 4))
- {
+ if (0 != BeceemNVMRead(Adapter, &uiEepromSize, EEPROM_SIZE_OFFSET, 4))
return -1;
- }
+
uiEepromSize = ntohl(uiEepromSize);
uiEepromSize >>= 16;
-//
-// subtract the auto init section size
-//
+ /*
+ * subtract the auto init section size
+ */
uiEepromSize -= EEPROM_CALPARAM_START;
- if(uiEepromSize > 1024*1024)
- {
+ if (uiEepromSize > 1024 * 1024)
return -1;
- }
pBuff = kmalloc(uiEepromSize, GFP_KERNEL);
- if ( pBuff == NULL )
- return -1;
+ if (pBuff == NULL)
+ return -ENOMEM;
- if(0 != BeceemNVMRead(Adapter,(PUINT)pBuff,uiCalStartAddr, uiEepromSize))
- {
+ if (0 != BeceemNVMRead(Adapter, (PUINT)pBuff, uiCalStartAddr, uiEepromSize)) {
kfree(pBuff);
return -1;
}
pPtr = pBuff;
- uiBytesToCopy = MIN(BUFFER_4K,uiEepromSize);
+ uiBytesToCopy = MIN(BUFFER_4K, uiEepromSize);
- while(uiBytesToCopy)
- {
- Status = wrm(Adapter,uiMemoryLoc,(PCHAR)pPtr,uiBytesToCopy);
- if(Status)
- {
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"wrm failed with status :%d",Status);
+ while (uiBytesToCopy) {
+ Status = wrm(Adapter, uiMemoryLoc, (PCHAR)pPtr, uiBytesToCopy);
+ if (Status) {
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "wrm failed with status :%d", Status);
break;
}
pPtr += uiBytesToCopy;
uiEepromSize -= uiBytesToCopy;
uiMemoryLoc += uiBytesToCopy;
- uiBytesToCopy = MIN(BUFFER_4K,uiEepromSize);
+ uiBytesToCopy = MIN(BUFFER_4K, uiEepromSize);
}
kfree(pBuff);
return Status;
-
}
-//-----------------------------------------------------------------------------
-// Procedure: BeceemEEPROMReadBackandVerify
-//
-// Description: Read back the data written and verifies.
-//
-// Arguments:
-// Adapter - ptr to Adapter object instance
-// pBuffer - Data to be written.
-// uiOffset - Offset of the flash where data needs to be written to.
-// uiNumBytes - Number of bytes to be written.
-// Returns:
-// OSAL_STATUS_CODE
-//
-//-----------------------------------------------------------------------------
-
-static INT BeceemEEPROMReadBackandVerify(
- PMINI_ADAPTER Adapter,
- PUINT pBuffer,
- UINT uiOffset,
- UINT uiNumBytes)
+/*
+ * Procedure: BeceemEEPROMReadBackandVerify
+ *
+ * Description: Read back the data written and verifies.
+ *
+ * Arguments:
+ * Adapter - ptr to Adapter object instance
+ * pBuffer - Data to be written.
+ * uiOffset - Offset of the flash where data needs to be written to.
+ * uiNumBytes - Number of bytes to be written.
+ * Returns:
+ * OSAL_STATUS_CODE
+ *
+ */
+
+static int BeceemEEPROMReadBackandVerify(struct bcm_mini_adapter *Adapter,
+ PUINT pBuffer,
+ unsigned int uiOffset,
+ unsigned int uiNumBytes)
{
- UINT uiRdbk = 0;
- UINT uiIndex = 0;
- UINT uiData = 0;
- UINT auiData[4] = {0};
+ unsigned int uiRdbk = 0;
+ unsigned int uiIndex = 0;
+ unsigned int uiData = 0;
+ unsigned int auiData[4] = {0};
- while(uiNumBytes)
- {
- if(Adapter->device_removed )
- {
+ while (uiNumBytes) {
+ if (Adapter->device_removed)
return -1;
- }
- if(uiNumBytes >= MAX_RW_SIZE)
- {// for the requests more than or equal to MAX_RW_SIZE bytes, use bulk read function to make the access faster.
- BeceemEEPROMBulkRead(Adapter,&auiData[0],uiOffset,MAX_RW_SIZE);
+ if (uiNumBytes >= MAX_RW_SIZE) {
+ /* for the requests more than or equal to MAX_RW_SIZE bytes, use bulk read function to make the access faster. */
+ BeceemEEPROMBulkRead(Adapter, &auiData[0], uiOffset, MAX_RW_SIZE);
- if(memcmp(&pBuffer[uiIndex],&auiData[0],MAX_RW_SIZE))
- {
- // re-write
- BeceemEEPROMBulkWrite(Adapter,(PUCHAR)(pBuffer+uiIndex),uiOffset,MAX_RW_SIZE,FALSE);
+ if (memcmp(&pBuffer[uiIndex], &auiData[0], MAX_RW_SIZE)) {
+ /* re-write */
+ BeceemEEPROMBulkWrite(Adapter, (PUCHAR)(pBuffer + uiIndex), uiOffset, MAX_RW_SIZE, FALSE);
mdelay(3);
- BeceemEEPROMBulkRead(Adapter,&auiData[0],uiOffset,MAX_RW_SIZE);
+ BeceemEEPROMBulkRead(Adapter, &auiData[0], uiOffset, MAX_RW_SIZE);
- if(memcmp(&pBuffer[uiIndex],&auiData[0],MAX_RW_SIZE))
- {
+ if (memcmp(&pBuffer[uiIndex], &auiData[0], MAX_RW_SIZE))
return -1;
- }
}
uiOffset += MAX_RW_SIZE;
uiNumBytes -= MAX_RW_SIZE;
uiIndex += 4;
-
- }
- else if(uiNumBytes >= 4)
- {
- BeceemEEPROMBulkRead(Adapter,&uiData,uiOffset,4);
- if(uiData != pBuffer[uiIndex])
- {
- //re-write
- BeceemEEPROMBulkWrite(Adapter,(PUCHAR)(pBuffer+uiIndex),uiOffset,4,FALSE);
+ } else if (uiNumBytes >= 4) {
+ BeceemEEPROMBulkRead(Adapter, &uiData, uiOffset, 4);
+ if (uiData != pBuffer[uiIndex]) {
+ /* re-write */
+ BeceemEEPROMBulkWrite(Adapter, (PUCHAR)(pBuffer + uiIndex), uiOffset, 4, FALSE);
mdelay(3);
- BeceemEEPROMBulkRead(Adapter,&uiData,uiOffset,4);
- if(uiData != pBuffer[uiIndex])
- {
+ BeceemEEPROMBulkRead(Adapter, &uiData, uiOffset, 4);
+ if (uiData != pBuffer[uiIndex])
return -1;
- }
}
uiOffset += 4;
uiNumBytes -= 4;
uiIndex++;
-
- }
- else
- { // Handle the reads less than 4 bytes...
+ } else {
+ /* Handle the reads less than 4 bytes... */
uiData = 0;
- memcpy(&uiData,((PUCHAR)pBuffer)+(uiIndex*sizeof(UINT)),uiNumBytes);
- BeceemEEPROMBulkRead(Adapter,&uiRdbk,uiOffset,4);
+ memcpy(&uiData, ((PUCHAR)pBuffer) + (uiIndex * sizeof(unsigned int)), uiNumBytes);
+ BeceemEEPROMBulkRead(Adapter, &uiRdbk, uiOffset, 4);
- if(memcmp(&uiData, &uiRdbk, uiNumBytes))
+ if (memcmp(&uiData, &uiRdbk, uiNumBytes))
return -1;
uiNumBytes = 0;
}
-
}
return 0;
}
-static VOID BcmSwapWord(UINT *ptr1) {
-
- UINT tempval = (UINT)*ptr1;
+static VOID BcmSwapWord(unsigned int *ptr1)
+{
+ unsigned int tempval = (unsigned int)*ptr1;
char *ptr2 = (char *)&tempval;
char *ptr = (char *)ptr1;
@@ -1785,495 +1576,436 @@ static VOID BcmSwapWord(UINT *ptr1) {
ptr[3] = ptr2[0];
}
-//-----------------------------------------------------------------------------
-// Procedure: BeceemEEPROMWritePage
-//
-// Description: Performs page write (16bytes) to the EEPROM
-//
-// Arguments:
-// Adapter - ptr to Adapter object instance
-// uiData - Data to be written.
-// uiOffset - Offset of the EEPROM where data needs to be written to.
-// Returns:
-// OSAL_STATUS_CODE
-//
-//-----------------------------------------------------------------------------
-static INT BeceemEEPROMWritePage( PMINI_ADAPTER Adapter, UINT uiData[], UINT uiOffset )
+/*
+ * Procedure: BeceemEEPROMWritePage
+ *
+ * Description: Performs page write (16bytes) to the EEPROM
+ *
+ * Arguments:
+ * Adapter - ptr to Adapter object instance
+ * uiData - Data to be written.
+ * uiOffset - Offset of the EEPROM where data needs to be written to.
+ * Returns:
+ * OSAL_STATUS_CODE
+ *
+ */
+
+static int BeceemEEPROMWritePage(struct bcm_mini_adapter *Adapter, unsigned int uiData[], unsigned int uiOffset)
{
- UINT uiRetries = MAX_EEPROM_RETRIES*RETRIES_PER_DELAY;
- UINT uiStatus = 0;
+ unsigned int uiRetries = MAX_EEPROM_RETRIES * RETRIES_PER_DELAY;
+ unsigned int uiStatus = 0;
UCHAR uiEpromStatus = 0;
- UINT value =0 ;
+ unsigned int value = 0;
/* Flush the Write/Read/Cmd queues. */
- value = ( EEPROM_WRITE_QUEUE_FLUSH | EEPROM_CMD_QUEUE_FLUSH | EEPROM_READ_QUEUE_FLUSH );
- wrmalt( Adapter, SPI_FLUSH_REG, &value, sizeof(value));
- value = 0 ;
- wrmalt( Adapter, SPI_FLUSH_REG, &value, sizeof(value) );
+ value = (EEPROM_WRITE_QUEUE_FLUSH | EEPROM_CMD_QUEUE_FLUSH | EEPROM_READ_QUEUE_FLUSH);
+ wrmalt(Adapter, SPI_FLUSH_REG, &value, sizeof(value));
+ value = 0;
+ wrmalt(Adapter, SPI_FLUSH_REG, &value, sizeof(value));
/* Clear the Empty/Avail/Full bits. After this it has been confirmed
* that the bit was cleared by reading back the register. See NOTE below.
* We also clear the Read queues as we do a EEPROM status register read
- * later. */
- value = ( EEPROM_WRITE_QUEUE_EMPTY | EEPROM_WRITE_QUEUE_AVAIL | EEPROM_WRITE_QUEUE_FULL | EEPROM_READ_DATA_AVAIL | EEPROM_READ_DATA_FULL ) ;
- wrmalt( Adapter, EEPROM_SPI_Q_STATUS1_REG,&value, sizeof(value));
+ * later.
+ */
+ value = (EEPROM_WRITE_QUEUE_EMPTY | EEPROM_WRITE_QUEUE_AVAIL | EEPROM_WRITE_QUEUE_FULL | EEPROM_READ_DATA_AVAIL | EEPROM_READ_DATA_FULL);
+ wrmalt(Adapter, EEPROM_SPI_Q_STATUS1_REG, &value, sizeof(value));
/* Enable write */
- value = EEPROM_WRITE_ENABLE ;
- wrmalt( Adapter, EEPROM_CMDQ_SPI_REG,&value, sizeof(value) );
+ value = EEPROM_WRITE_ENABLE;
+ wrmalt(Adapter, EEPROM_CMDQ_SPI_REG, &value, sizeof(value));
/* We can write back to back 8bits * 16 into the queue and as we have
- * checked for the queue to be empty we can write in a burst. */
+ * checked for the queue to be empty we can write in a burst.
+ */
value = uiData[0];
BcmSwapWord(&value);
- wrm( Adapter, EEPROM_WRITE_DATAQ_REG, (PUCHAR)&value, 4);
+ wrm(Adapter, EEPROM_WRITE_DATAQ_REG, (PUCHAR)&value, 4);
value = uiData[1];
BcmSwapWord(&value);
- wrm( Adapter, EEPROM_WRITE_DATAQ_REG, (PUCHAR)&value, 4);
+ wrm(Adapter, EEPROM_WRITE_DATAQ_REG, (PUCHAR)&value, 4);
value = uiData[2];
BcmSwapWord(&value);
- wrm( Adapter, EEPROM_WRITE_DATAQ_REG, (PUCHAR)&value, 4);
+ wrm(Adapter, EEPROM_WRITE_DATAQ_REG, (PUCHAR)&value, 4);
value = uiData[3];
BcmSwapWord(&value);
- wrm( Adapter, EEPROM_WRITE_DATAQ_REG, (PUCHAR)&value, 4);
+ wrm(Adapter, EEPROM_WRITE_DATAQ_REG, (PUCHAR)&value, 4);
/* NOTE : After this write, on readback of EEPROM_SPI_Q_STATUS1_REG
* shows that we see 7 for the EEPROM data write. Which means that
* queue got full, also space is available as well as the queue is empty.
- * This may happen in sequence. */
- value = EEPROM_16_BYTE_PAGE_WRITE | uiOffset ;
- wrmalt( Adapter, EEPROM_CMDQ_SPI_REG, &value, sizeof(value) );
+ * This may happen in sequence.
+ */
+ value = EEPROM_16_BYTE_PAGE_WRITE | uiOffset;
+ wrmalt(Adapter, EEPROM_CMDQ_SPI_REG, &value, sizeof(value));
/* Ideally we should loop here without tries and eventually succeed.
* What we are checking if the previous write has completed, and this
- * may take time. We should wait till the Empty bit is set. */
+ * may take time. We should wait till the Empty bit is set.
+ */
uiStatus = 0;
rdmalt(Adapter, EEPROM_SPI_Q_STATUS1_REG, &uiStatus, sizeof(uiStatus));
- while ( ( uiStatus & EEPROM_WRITE_QUEUE_EMPTY ) == 0 )
- {
+ while ((uiStatus & EEPROM_WRITE_QUEUE_EMPTY) == 0) {
uiRetries--;
- if ( uiRetries == 0 )
- {
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "0x0f003004 = %x, %d retries failed.\n", uiStatus, MAX_EEPROM_RETRIES *RETRIES_PER_DELAY);
- return STATUS_FAILURE ;
+ if (uiRetries == 0) {
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "0x0f003004 = %x, %d retries failed.\n", uiStatus, MAX_EEPROM_RETRIES * RETRIES_PER_DELAY);
+ return STATUS_FAILURE;
}
- if( !(uiRetries%RETRIES_PER_DELAY) )
- msleep(1);
+ if (!(uiRetries%RETRIES_PER_DELAY))
+ udelay(1000);
uiStatus = 0;
rdmalt(Adapter, EEPROM_SPI_Q_STATUS1_REG, &uiStatus, sizeof(uiStatus));
- if(Adapter->device_removed == TRUE)
- {
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Modem got removed hence exiting from loop....");
+ if (Adapter->device_removed == TRUE) {
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Modem got removed hence exiting from loop....");
return -ENODEV;
}
-
}
- if ( uiRetries != 0 )
- {
+ if (uiRetries != 0) {
/* Clear the ones that are set - either, Empty/Full/Avail bits */
- value = ( uiStatus & ( EEPROM_WRITE_QUEUE_EMPTY | EEPROM_WRITE_QUEUE_AVAIL | EEPROM_WRITE_QUEUE_FULL ) );
- wrmalt( Adapter, EEPROM_SPI_Q_STATUS1_REG, &value, sizeof(value));
+ value = (uiStatus & (EEPROM_WRITE_QUEUE_EMPTY | EEPROM_WRITE_QUEUE_AVAIL | EEPROM_WRITE_QUEUE_FULL));
+ wrmalt(Adapter, EEPROM_SPI_Q_STATUS1_REG, &value, sizeof(value));
}
/* Here we should check if the EEPROM status register is correct before
* proceeding. Bit 0 in the EEPROM Status register should be 0 before
* we proceed further. A 1 at Bit 0 indicates that the EEPROM is busy
* with the previous write. Note also that issuing this read finally
- * means the previous write to the EEPROM has completed. */
- uiRetries = MAX_EEPROM_RETRIES*RETRIES_PER_DELAY;
+ * means the previous write to the EEPROM has completed.
+ */
+ uiRetries = MAX_EEPROM_RETRIES * RETRIES_PER_DELAY;
uiEpromStatus = 0;
- while ( uiRetries != 0 )
- {
- uiEpromStatus = ReadEEPROMStatusRegister( Adapter) ;
- if(Adapter->device_removed == TRUE)
- {
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Modem has got removed hence exiting from loop...");
+ while (uiRetries != 0) {
+ uiEpromStatus = ReadEEPROMStatusRegister(Adapter);
+ if (Adapter->device_removed == TRUE) {
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Modem has got removed hence exiting from loop...");
return -ENODEV;
}
- if ( ( EEPROM_STATUS_REG_WRITE_BUSY & uiEpromStatus ) == 0 )
- {
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "EEPROM status register = %x tries = %d\n", uiEpromStatus, (MAX_EEPROM_RETRIES * RETRIES_PER_DELAY- uiRetries) );
- return STATUS_SUCCESS ;
+ if ((EEPROM_STATUS_REG_WRITE_BUSY & uiEpromStatus) == 0) {
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "EEPROM status register = %x tries = %d\n", uiEpromStatus, (MAX_EEPROM_RETRIES * RETRIES_PER_DELAY - uiRetries));
+ return STATUS_SUCCESS;
}
uiRetries--;
- if ( uiRetries == 0 )
- {
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "0x0f003004 = %x, for EEPROM status read %d retries failed.\n", uiEpromStatus, MAX_EEPROM_RETRIES *RETRIES_PER_DELAY);
- return STATUS_FAILURE ;
+ if (uiRetries == 0) {
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "0x0f003004 = %x, for EEPROM status read %d retries failed.\n", uiEpromStatus, MAX_EEPROM_RETRIES * RETRIES_PER_DELAY);
+ return STATUS_FAILURE;
}
uiEpromStatus = 0;
- if( !(uiRetries%RETRIES_PER_DELAY) )
- msleep(1);
+ if (!(uiRetries%RETRIES_PER_DELAY))
+ udelay(1000);
}
- return STATUS_SUCCESS ;
+ return STATUS_SUCCESS;
} /* BeceemEEPROMWritePage */
-
-//-----------------------------------------------------------------------------
-// Procedure: BeceemEEPROMBulkWrite
-//
-// Description: Performs write to the EEPROM
-//
-// Arguments:
-// Adapter - ptr to Adapter object instance
-// pBuffer - Data to be written.
-// uiOffset - Offset of the EEPROM where data needs to be written to.
-// uiNumBytes - Number of bytes to be written.
-// bVerify - read verify flag.
-// Returns:
-// OSAL_STATUS_CODE
-//
-//-----------------------------------------------------------------------------
-
-INT BeceemEEPROMBulkWrite(
- PMINI_ADAPTER Adapter,
- PUCHAR pBuffer,
- UINT uiOffset,
- UINT uiNumBytes,
- BOOLEAN bVerify)
+/*
+ * Procedure: BeceemEEPROMBulkWrite
+ *
+ * Description: Performs write to the EEPROM
+ *
+ * Arguments:
+ * Adapter - ptr to Adapter object instance
+ * pBuffer - Data to be written.
+ * uiOffset - Offset of the EEPROM where data needs to be written to.
+ * uiNumBytes - Number of bytes to be written.
+ * bVerify - read verify flag.
+ * Returns:
+ * OSAL_STATUS_CODE
+ *
+ */
+
+int BeceemEEPROMBulkWrite(struct bcm_mini_adapter *Adapter,
+ PUCHAR pBuffer,
+ unsigned int uiOffset,
+ unsigned int uiNumBytes,
+ BOOLEAN bVerify)
{
- UINT uiBytesToCopy = uiNumBytes;
- //UINT uiRdbk = 0;
- UINT uiData[4] = {0};
- UINT uiIndex = 0;
- UINT uiTempOffset = 0;
- UINT uiExtraBytes = 0;
- //PUINT puiBuffer = (PUINT)pBuffer;
- //INT value;
-
- if(uiOffset%MAX_RW_SIZE && uiBytesToCopy)
- {
- uiTempOffset = uiOffset - (uiOffset%MAX_RW_SIZE);
- uiExtraBytes = uiOffset-uiTempOffset;
-
-
- BeceemEEPROMBulkRead(Adapter,&uiData[0],uiTempOffset,MAX_RW_SIZE);
-
- if(uiBytesToCopy >= (16 -uiExtraBytes))
- {
- memcpy((((PUCHAR)&uiData[0])+uiExtraBytes),pBuffer,MAX_RW_SIZE- uiExtraBytes);
-
- if ( STATUS_FAILURE == BeceemEEPROMWritePage( Adapter, uiData, uiTempOffset ) )
- return STATUS_FAILURE;
+ unsigned int uiBytesToCopy = uiNumBytes;
+ /* unsigned int uiRdbk = 0; */
+ unsigned int uiData[4] = {0};
+ unsigned int uiIndex = 0;
+ unsigned int uiTempOffset = 0;
+ unsigned int uiExtraBytes = 0;
+ /* PUINT puiBuffer = (PUINT)pBuffer;
+ * int value;
+ */
+
+ if (uiOffset % MAX_RW_SIZE && uiBytesToCopy) {
+ uiTempOffset = uiOffset - (uiOffset % MAX_RW_SIZE);
+ uiExtraBytes = uiOffset - uiTempOffset;
+
+ BeceemEEPROMBulkRead(Adapter, &uiData[0], uiTempOffset, MAX_RW_SIZE);
+
+ if (uiBytesToCopy >= (16 - uiExtraBytes)) {
+ memcpy((((PUCHAR)&uiData[0]) + uiExtraBytes), pBuffer, MAX_RW_SIZE - uiExtraBytes);
+
+ if (STATUS_FAILURE == BeceemEEPROMWritePage(Adapter, uiData, uiTempOffset))
+ return STATUS_FAILURE;
uiBytesToCopy -= (MAX_RW_SIZE - uiExtraBytes);
uiIndex += (MAX_RW_SIZE - uiExtraBytes);
uiOffset += (MAX_RW_SIZE - uiExtraBytes);
- }
- else
- {
- memcpy((((PUCHAR)&uiData[0])+uiExtraBytes),pBuffer,uiBytesToCopy);
+ } else {
+ memcpy((((PUCHAR)&uiData[0]) + uiExtraBytes), pBuffer, uiBytesToCopy);
- if ( STATUS_FAILURE == BeceemEEPROMWritePage( Adapter, uiData, uiTempOffset ) )
- return STATUS_FAILURE;
+ if (STATUS_FAILURE == BeceemEEPROMWritePage(Adapter, uiData, uiTempOffset))
+ return STATUS_FAILURE;
uiIndex += uiBytesToCopy;
uiOffset += uiBytesToCopy;
uiBytesToCopy = 0;
}
-
-
}
- while(uiBytesToCopy)
- {
- if(Adapter->device_removed)
- {
+ while (uiBytesToCopy) {
+ if (Adapter->device_removed)
return -1;
- }
- if(uiBytesToCopy >= MAX_RW_SIZE)
- {
-
- if (STATUS_FAILURE == BeceemEEPROMWritePage( Adapter, (PUINT) &pBuffer[uiIndex], uiOffset ) )
- return STATUS_FAILURE;
+ if (uiBytesToCopy >= MAX_RW_SIZE) {
+ if (STATUS_FAILURE == BeceemEEPROMWritePage(Adapter, (PUINT) &pBuffer[uiIndex], uiOffset))
+ return STATUS_FAILURE;
uiIndex += MAX_RW_SIZE;
uiOffset += MAX_RW_SIZE;
- uiBytesToCopy -= MAX_RW_SIZE;
- }
- else
- {
- //
- // To program non 16byte aligned data, read 16byte and then update.
- //
- BeceemEEPROMBulkRead(Adapter,&uiData[0],uiOffset,16);
- memcpy(&uiData[0],pBuffer+uiIndex,uiBytesToCopy);
-
+ uiBytesToCopy -= MAX_RW_SIZE;
+ } else {
+ /*
+ * To program non 16byte aligned data, read 16byte and then update.
+ */
+ BeceemEEPROMBulkRead(Adapter, &uiData[0], uiOffset, 16);
+ memcpy(&uiData[0], pBuffer + uiIndex, uiBytesToCopy);
+
+ if (STATUS_FAILURE == BeceemEEPROMWritePage(Adapter, uiData, uiOffset))
+ return STATUS_FAILURE;
- if ( STATUS_FAILURE == BeceemEEPROMWritePage( Adapter, uiData, uiOffset ) )
- return STATUS_FAILURE;
uiBytesToCopy = 0;
}
-
}
return 0;
}
-//-----------------------------------------------------------------------------
-// Procedure: BeceemNVMRead
-//
-// Description: Reads n number of bytes from NVM.
-//
-// Arguments:
-// Adapter - ptr to Adapter object instance
-// pBuffer - Buffer to store the data read from NVM
-// uiOffset - Offset of NVM from where data should be read
-// uiNumBytes - Number of bytes to be read from the NVM.
-//
-// Returns:
-// OSAL_STATUS_SUCCESS - if NVM read is successful.
-// <FAILURE> - if failed.
-//-----------------------------------------------------------------------------
-
-INT BeceemNVMRead(
- PMINI_ADAPTER Adapter,
- PUINT pBuffer,
- UINT uiOffset,
- UINT uiNumBytes)
+/*
+ * Procedure: BeceemNVMRead
+ *
+ * Description: Reads n number of bytes from NVM.
+ *
+ * Arguments:
+ * Adapter - ptr to Adapter object instance
+ * pBuffer - Buffer to store the data read from NVM
+ * uiOffset - Offset of NVM from where data should be read
+ * uiNumBytes - Number of bytes to be read from the NVM.
+ *
+ * Returns:
+ * OSAL_STATUS_SUCCESS - if NVM read is successful.
+ * <FAILURE> - if failed.
+ */
+
+int BeceemNVMRead(struct bcm_mini_adapter *Adapter,
+ PUINT pBuffer,
+ unsigned int uiOffset,
+ unsigned int uiNumBytes)
{
- INT Status = 0;
-#if !defined(BCM_SHM_INTERFACE) || defined(FLASH_DIRECT_ACCESS)
- UINT uiTemp = 0, value;
-#endif
+ int Status = 0;
- if(Adapter->eNVMType == NVM_FLASH)
- {
- if(Adapter->bFlashRawRead == FALSE)
- {
- if (IsSectionExistInVendorInfo(Adapter,Adapter->eActiveDSD))
- return vendorextnReadSection(Adapter,(PUCHAR)pBuffer,Adapter->eActiveDSD,uiOffset,uiNumBytes);
- uiOffset = uiOffset+ Adapter->ulFlashCalStart ;
+ #if !defined(BCM_SHM_INTERFACE) || defined(FLASH_DIRECT_ACCESS)
+ unsigned int uiTemp = 0, value;
+ #endif
+
+ if (Adapter->eNVMType == NVM_FLASH) {
+ if (Adapter->bFlashRawRead == FALSE) {
+ if (IsSectionExistInVendorInfo(Adapter, Adapter->eActiveDSD))
+ return vendorextnReadSection(Adapter, (PUCHAR)pBuffer, Adapter->eActiveDSD, uiOffset, uiNumBytes);
+
+ uiOffset = uiOffset + Adapter->ulFlashCalStart;
}
-#if defined(BCM_SHM_INTERFACE) && !defined(FLASH_DIRECT_ACCESS)
- Status = bcmflash_raw_read((uiOffset/FLASH_PART_SIZE),(uiOffset % FLASH_PART_SIZE),( unsigned char *)pBuffer,uiNumBytes);
-#else
- rdmalt(Adapter, 0x0f000C80, &uiTemp, sizeof(uiTemp));
- value = 0;
- wrmalt(Adapter, 0x0f000C80,&value, sizeof(value));
- Status = BeceemFlashBulkRead(Adapter,
+ #if defined(BCM_SHM_INTERFACE) && !defined(FLASH_DIRECT_ACCESS)
+ Status = bcmflash_raw_read((uiOffset / FLASH_PART_SIZE), (uiOffset % FLASH_PART_SIZE), (unsigned char *)pBuffer, uiNumBytes);
+ #else
+ rdmalt(Adapter, 0x0f000C80, &uiTemp, sizeof(uiTemp));
+ value = 0;
+ wrmalt(Adapter, 0x0f000C80, &value, sizeof(value));
+ Status = BeceemFlashBulkRead(Adapter,
pBuffer,
uiOffset,
uiNumBytes);
- wrmalt(Adapter, 0x0f000C80, &uiTemp, sizeof(uiTemp));
-#endif
- }
- else if(Adapter->eNVMType == NVM_EEPROM)
- {
+ wrmalt(Adapter, 0x0f000C80, &uiTemp, sizeof(uiTemp));
+ #endif
+ } else if (Adapter->eNVMType == NVM_EEPROM) {
Status = BeceemEEPROMBulkRead(Adapter,
pBuffer,
uiOffset,
uiNumBytes);
- }
- else
- {
+ } else {
Status = -1;
}
+
return Status;
}
-//-----------------------------------------------------------------------------
-// Procedure: BeceemNVMWrite
-//
-// Description: Writes n number of bytes to NVM.
-//
-// Arguments:
-// Adapter - ptr to Adapter object instance
-// pBuffer - Buffer contains the data to be written.
-// uiOffset - Offset of NVM where data to be written to.
-// uiNumBytes - Number of bytes to be written..
-//
-// Returns:
-// OSAL_STATUS_SUCCESS - if NVM write is successful.
-// <FAILURE> - if failed.
-//-----------------------------------------------------------------------------
-
-INT BeceemNVMWrite(
- PMINI_ADAPTER Adapter,
- PUINT pBuffer,
- UINT uiOffset,
- UINT uiNumBytes,
- BOOLEAN bVerify)
+/*
+ * Procedure: BeceemNVMWrite
+ *
+ * Description: Writes n number of bytes to NVM.
+ *
+ * Arguments:
+ * Adapter - ptr to Adapter object instance
+ * pBuffer - Buffer contains the data to be written.
+ * uiOffset - Offset of NVM where data to be written to.
+ * uiNumBytes - Number of bytes to be written..
+ *
+ * Returns:
+ * OSAL_STATUS_SUCCESS - if NVM write is successful.
+ * <FAILURE> - if failed.
+ */
+
+int BeceemNVMWrite(struct bcm_mini_adapter *Adapter,
+ PUINT pBuffer,
+ unsigned int uiOffset,
+ unsigned int uiNumBytes,
+ BOOLEAN bVerify)
{
- INT Status = 0;
- UINT uiTemp = 0;
- UINT uiMemoryLoc = EEPROM_CAL_DATA_INTERNAL_LOC;
- UINT uiIndex = 0;
-#if !defined(BCM_SHM_INTERFACE) || defined(FLASH_DIRECT_ACCESS)
- UINT value;
-#endif
- UINT uiFlashOffset = 0;
-
- if(Adapter->eNVMType == NVM_FLASH)
- {
- if (IsSectionExistInVendorInfo(Adapter,Adapter->eActiveDSD))
- Status = vendorextnWriteSection(Adapter,(PUCHAR)pBuffer,Adapter->eActiveDSD,uiOffset,uiNumBytes,bVerify);
- else
- {
- uiFlashOffset = uiOffset + Adapter->ulFlashCalStart;
+ int Status = 0;
+ unsigned int uiTemp = 0;
+ unsigned int uiMemoryLoc = EEPROM_CAL_DATA_INTERNAL_LOC;
+ unsigned int uiIndex = 0;
-#if defined(BCM_SHM_INTERFACE) && !defined(FLASH_DIRECT_ACCESS)
- Status = bcmflash_raw_write((uiFlashOffset/FLASH_PART_SIZE), (uiFlashOffset % FLASH_PART_SIZE), (unsigned char *)pBuffer,uiNumBytes);
-#else
- rdmalt(Adapter, 0x0f000C80, &uiTemp, sizeof(uiTemp));
- value = 0;
- wrmalt(Adapter, 0x0f000C80, &value, sizeof(value));
+ #if !defined(BCM_SHM_INTERFACE) || defined(FLASH_DIRECT_ACCESS)
+ unsigned int value;
+ #endif
- if(Adapter->bStatusWrite == TRUE)
- {
- Status = BeceemFlashBulkWriteStatus(Adapter,
- pBuffer,
- uiFlashOffset,
- uiNumBytes ,
- bVerify);
- }
- else
- {
+ unsigned int uiFlashOffset = 0;
- Status = BeceemFlashBulkWrite(Adapter,
- pBuffer,
- uiFlashOffset,
- uiNumBytes,
- bVerify);
- }
-#endif
- }
+ if (Adapter->eNVMType == NVM_FLASH) {
+ if (IsSectionExistInVendorInfo(Adapter, Adapter->eActiveDSD))
+ Status = vendorextnWriteSection(Adapter, (PUCHAR)pBuffer, Adapter->eActiveDSD, uiOffset, uiNumBytes, bVerify);
+ else {
+ uiFlashOffset = uiOffset + Adapter->ulFlashCalStart;
+
+ #if defined(BCM_SHM_INTERFACE) && !defined(FLASH_DIRECT_ACCESS)
+ Status = bcmflash_raw_write((uiFlashOffset / FLASH_PART_SIZE), (uiFlashOffset % FLASH_PART_SIZE), (unsigned char *)pBuffer, uiNumBytes);
+ #else
+ rdmalt(Adapter, 0x0f000C80, &uiTemp, sizeof(uiTemp));
+ value = 0;
+ wrmalt(Adapter, 0x0f000C80, &value, sizeof(value));
+
+ if (Adapter->bStatusWrite == TRUE)
+ Status = BeceemFlashBulkWriteStatus(Adapter,
+ pBuffer,
+ uiFlashOffset,
+ uiNumBytes ,
+ bVerify);
+ else
+ Status = BeceemFlashBulkWrite(Adapter,
+ pBuffer,
+ uiFlashOffset,
+ uiNumBytes,
+ bVerify);
+ #endif
+ }
- if(uiOffset >= EEPROM_CALPARAM_START)
- {
+ if (uiOffset >= EEPROM_CALPARAM_START) {
uiMemoryLoc += (uiOffset - EEPROM_CALPARAM_START);
- while(uiNumBytes)
- {
- if(uiNumBytes > BUFFER_4K)
- {
- wrm(Adapter,(uiMemoryLoc+uiIndex),(PCHAR)(pBuffer+(uiIndex/4)),BUFFER_4K);
+ while (uiNumBytes) {
+ if (uiNumBytes > BUFFER_4K) {
+ wrm(Adapter, (uiMemoryLoc+uiIndex), (PCHAR)(pBuffer + (uiIndex / 4)), BUFFER_4K);
uiNumBytes -= BUFFER_4K;
uiIndex += BUFFER_4K;
- }
- else
- {
- wrm(Adapter,uiMemoryLoc+uiIndex,(PCHAR)(pBuffer+(uiIndex/4)),uiNumBytes);
+ } else {
+ wrm(Adapter, uiMemoryLoc+uiIndex, (PCHAR)(pBuffer + (uiIndex / 4)), uiNumBytes);
uiNumBytes = 0;
break;
}
}
- }
- else
- {
- if((uiOffset+uiNumBytes) > EEPROM_CALPARAM_START)
- {
+ } else {
+ if ((uiOffset + uiNumBytes) > EEPROM_CALPARAM_START) {
ULONG ulBytesTobeSkipped = 0;
- PUCHAR pcBuffer = (PUCHAR)pBuffer;// char pointer to take care of odd byte cases.
+ PUCHAR pcBuffer = (PUCHAR)pBuffer; /* char pointer to take care of odd byte cases. */
uiNumBytes -= (EEPROM_CALPARAM_START - uiOffset);
ulBytesTobeSkipped += (EEPROM_CALPARAM_START - uiOffset);
uiOffset += (EEPROM_CALPARAM_START - uiOffset);
- while(uiNumBytes)
- {
- if(uiNumBytes > BUFFER_4K)
- {
- wrm(Adapter,uiMemoryLoc+uiIndex,(PCHAR )&pcBuffer[ulBytesTobeSkipped+uiIndex],BUFFER_4K);
+ while (uiNumBytes) {
+ if (uiNumBytes > BUFFER_4K) {
+ wrm(Adapter, uiMemoryLoc + uiIndex, (PCHAR)&pcBuffer[ulBytesTobeSkipped + uiIndex], BUFFER_4K);
uiNumBytes -= BUFFER_4K;
uiIndex += BUFFER_4K;
- }
- else
- {
- wrm(Adapter,uiMemoryLoc+uiIndex,(PCHAR)&pcBuffer[ulBytesTobeSkipped+uiIndex],uiNumBytes);
+ } else {
+ wrm(Adapter, uiMemoryLoc + uiIndex, (PCHAR)&pcBuffer[ulBytesTobeSkipped + uiIndex], uiNumBytes);
uiNumBytes = 0;
break;
}
}
-
}
}
-
- // restore the values.
- wrmalt(Adapter,0x0f000C80,&uiTemp, sizeof(uiTemp));
- }
- else if(Adapter->eNVMType == NVM_EEPROM)
- {
+ /* restore the values. */
+ wrmalt(Adapter, 0x0f000C80, &uiTemp, sizeof(uiTemp));
+ } else if (Adapter->eNVMType == NVM_EEPROM) {
Status = BeceemEEPROMBulkWrite(Adapter,
(PUCHAR)pBuffer,
uiOffset,
uiNumBytes,
bVerify);
- if(bVerify)
- {
- Status = BeceemEEPROMReadBackandVerify(Adapter,(PUINT)pBuffer,uiOffset,uiNumBytes);
- }
- }
- else
- {
+ if (bVerify)
+ Status = BeceemEEPROMReadBackandVerify(Adapter, (PUINT)pBuffer, uiOffset, uiNumBytes);
+ } else {
Status = -1;
}
return Status;
}
-//-----------------------------------------------------------------------------
-// Procedure: BcmUpdateSectorSize
-//
-// Description: Updates the sector size to FLASH.
-//
-// Arguments:
-// Adapter - ptr to Adapter object instance
-// uiSectorSize - sector size
-//
-// Returns:
-// OSAL_STATUS_SUCCESS - if NVM write is successful.
-// <FAILURE> - if failed.
-//-----------------------------------------------------------------------------
-
-INT BcmUpdateSectorSize(PMINI_ADAPTER Adapter,UINT uiSectorSize)
+/*
+ * Procedure: BcmUpdateSectorSize
+ *
+ * Description: Updates the sector size to FLASH.
+ *
+ * Arguments:
+ * Adapter - ptr to Adapter object instance
+ * uiSectorSize - sector size
+ *
+ * Returns:
+ * OSAL_STATUS_SUCCESS - if NVM write is successful.
+ * <FAILURE> - if failed.
+ */
+
+int BcmUpdateSectorSize(struct bcm_mini_adapter *Adapter, unsigned int uiSectorSize)
{
- INT Status = -1;
+ int Status = -1;
FLASH_CS_INFO sFlashCsInfo = {0};
- UINT uiTemp = 0;
-
- UINT uiSectorSig = 0;
- UINT uiCurrentSectorSize = 0;
-
- UINT value;
-
-
+ unsigned int uiTemp = 0;
+ unsigned int uiSectorSig = 0;
+ unsigned int uiCurrentSectorSize = 0;
+ unsigned int value;
rdmalt(Adapter, 0x0f000C80, &uiTemp, sizeof(uiTemp));
value = 0;
- wrmalt(Adapter, 0x0f000C80,&value, sizeof(value));
+ wrmalt(Adapter, 0x0f000C80, &value, sizeof(value));
-//
-// Before updating the sector size in the reserved area, check if already present.
-//
- BeceemFlashBulkRead(Adapter,(PUINT)&sFlashCsInfo,Adapter->ulFlashControlSectionStart,sizeof(sFlashCsInfo));
+ /*
+ * Before updating the sector size in the reserved area, check if already present.
+ */
+ BeceemFlashBulkRead(Adapter, (PUINT)&sFlashCsInfo, Adapter->ulFlashControlSectionStart, sizeof(sFlashCsInfo));
uiSectorSig = ntohl(sFlashCsInfo.FlashSectorSizeSig);
uiCurrentSectorSize = ntohl(sFlashCsInfo.FlashSectorSize);
- if(uiSectorSig == FLASH_SECTOR_SIZE_SIG)
- {
-
- if((uiCurrentSectorSize <= MAX_SECTOR_SIZE) && (uiCurrentSectorSize >= MIN_SECTOR_SIZE))
- {
- if(uiSectorSize == uiCurrentSectorSize)
- {
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL,"Provided sector size is same as programmed in Flash");
+ if (uiSectorSig == FLASH_SECTOR_SIZE_SIG) {
+ if ((uiCurrentSectorSize <= MAX_SECTOR_SIZE) && (uiCurrentSectorSize >= MIN_SECTOR_SIZE)) {
+ if (uiSectorSize == uiCurrentSectorSize) {
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "Provided sector size is same as programmed in Flash");
Status = STATUS_SUCCESS;
- goto Restore ;
+ goto Restore;
}
}
}
- if((uiSectorSize <= MAX_SECTOR_SIZE) && (uiSectorSize >= MIN_SECTOR_SIZE))
- {
-
+ if ((uiSectorSize <= MAX_SECTOR_SIZE) && (uiSectorSize >= MIN_SECTOR_SIZE)) {
sFlashCsInfo.FlashSectorSize = htonl(uiSectorSize);
sFlashCsInfo.FlashSectorSizeSig = htonl(FLASH_SECTOR_SIZE_SIG);
@@ -2282,152 +2014,128 @@ INT BcmUpdateSectorSize(PMINI_ADAPTER Adapter,UINT uiSectorSize)
Adapter->ulFlashControlSectionStart,
sizeof(sFlashCsInfo),
TRUE);
-
-
}
- Restore :
- // restore the values.
- wrmalt(Adapter, 0x0f000C80,&uiTemp, sizeof(uiTemp));
-
+Restore:
+ /* restore the values. */
+ wrmalt(Adapter, 0x0f000C80, &uiTemp, sizeof(uiTemp));
return Status;
-
}
-//-----------------------------------------------------------------------------
-// Procedure: BcmGetFlashSectorSize
-//
-// Description: Finds the sector size of the FLASH.
-//
-// Arguments:
-// Adapter - ptr to Adapter object instance
-//
-// Returns:
-// UINT - sector size.
-//
-//-----------------------------------------------------------------------------
-
-static UINT BcmGetFlashSectorSize(PMINI_ADAPTER Adapter, UINT FlashSectorSizeSig, UINT FlashSectorSize)
+/*
+ * Procedure: BcmGetFlashSectorSize
+ *
+ * Description: Finds the sector size of the FLASH.
+ *
+ * Arguments:
+ * Adapter - ptr to Adapter object instance
+ *
+ * Returns:
+ * unsigned int - sector size.
+ *
+ */
+
+static unsigned int BcmGetFlashSectorSize(struct bcm_mini_adapter *Adapter, unsigned int FlashSectorSizeSig, unsigned int FlashSectorSize)
{
- UINT uiSectorSize = 0;
- UINT uiSectorSig = 0;
+ unsigned int uiSectorSize = 0;
+ unsigned int uiSectorSig = 0;
- if(Adapter->bSectorSizeOverride &&
+ if (Adapter->bSectorSizeOverride &&
(Adapter->uiSectorSizeInCFG <= MAX_SECTOR_SIZE &&
- Adapter->uiSectorSizeInCFG >= MIN_SECTOR_SIZE))
- {
+ Adapter->uiSectorSizeInCFG >= MIN_SECTOR_SIZE)) {
Adapter->uiSectorSize = Adapter->uiSectorSizeInCFG;
- }
- else
- {
-
+ } else {
uiSectorSig = FlashSectorSizeSig;
- if(uiSectorSig == FLASH_SECTOR_SIZE_SIG)
- {
+ if (uiSectorSig == FLASH_SECTOR_SIZE_SIG) {
uiSectorSize = FlashSectorSize;
- //
- // If the sector size stored in the FLASH makes sense then use it.
- //
- if(uiSectorSize <= MAX_SECTOR_SIZE && uiSectorSize >= MIN_SECTOR_SIZE)
- {
+ /*
+ * If the sector size stored in the FLASH makes sense then use it.
+ */
+ if (uiSectorSize <= MAX_SECTOR_SIZE && uiSectorSize >= MIN_SECTOR_SIZE) {
Adapter->uiSectorSize = uiSectorSize;
- }
- //No valid size in FLASH, check if Config file has it.
- else if(Adapter->uiSectorSizeInCFG <= MAX_SECTOR_SIZE &&
- Adapter->uiSectorSizeInCFG >= MIN_SECTOR_SIZE)
- {
+ } else if (Adapter->uiSectorSizeInCFG <= MAX_SECTOR_SIZE &&
+ Adapter->uiSectorSizeInCFG >= MIN_SECTOR_SIZE) {
+ /* No valid size in FLASH, check if Config file has it. */
Adapter->uiSectorSize = Adapter->uiSectorSizeInCFG;
- }
- // Init to Default, if none of the above works.
- else
- {
+ } else {
+ /* Init to Default, if none of the above works. */
Adapter->uiSectorSize = DEFAULT_SECTOR_SIZE;
}
-
- }
- else
- {
- if(Adapter->uiSectorSizeInCFG <= MAX_SECTOR_SIZE &&
- Adapter->uiSectorSizeInCFG >= MIN_SECTOR_SIZE)
- {
+ } else {
+ if (Adapter->uiSectorSizeInCFG <= MAX_SECTOR_SIZE &&
+ Adapter->uiSectorSizeInCFG >= MIN_SECTOR_SIZE)
Adapter->uiSectorSize = Adapter->uiSectorSizeInCFG;
- }
else
- {
Adapter->uiSectorSize = DEFAULT_SECTOR_SIZE;
- }
}
}
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "Sector size :%x \n", Adapter->uiSectorSize);
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "Sector size :%x\n", Adapter->uiSectorSize);
+
return Adapter->uiSectorSize;
}
-//-----------------------------------------------------------------------------
-// Procedure: BcmInitEEPROMQueues
-//
-// Description: Initialization of EEPROM queues.
-//
-// Arguments:
-// Adapter - ptr to Adapter object instance
-//
-// Returns:
-// <OSAL_STATUS_CODE>
-//-----------------------------------------------------------------------------
-
-static INT BcmInitEEPROMQueues(PMINI_ADAPTER Adapter)
+/*
+ * Procedure: BcmInitEEPROMQueues
+ *
+ * Description: Initialization of EEPROM queues.
+ *
+ * Arguments:
+ * Adapter - ptr to Adapter object instance
+ *
+ * Returns:
+ * <OSAL_STATUS_CODE>
+ */
+
+static int BcmInitEEPROMQueues(struct bcm_mini_adapter *Adapter)
{
- UINT value = 0;
+ unsigned int value = 0;
/* CHIP Bug : Clear the Avail bits on the Read queue. The default
* value on this register is supposed to be 0x00001102.
- * But we get 0x00001122. */
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL,"Fixing reset value on 0x0f003004 register\n" );
+ * But we get 0x00001122.
+ */
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "Fixing reset value on 0x0f003004 register\n");
value = EEPROM_READ_DATA_AVAIL;
- wrmalt( Adapter, EEPROM_SPI_Q_STATUS1_REG, &value, sizeof(value));
+ wrmalt(Adapter, EEPROM_SPI_Q_STATUS1_REG, &value, sizeof(value));
/* Flush the all the EEPROM queues. */
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, " Flushing the queues\n");
- value =EEPROM_ALL_QUEUE_FLUSH ;
- wrmalt( Adapter, SPI_FLUSH_REG, &value, sizeof(value));
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, " Flushing the queues\n");
+ value = EEPROM_ALL_QUEUE_FLUSH;
+ wrmalt(Adapter, SPI_FLUSH_REG, &value, sizeof(value));
value = 0;
- wrmalt( Adapter, SPI_FLUSH_REG, &value, sizeof(value) );
+ wrmalt(Adapter, SPI_FLUSH_REG, &value, sizeof(value));
/* Read the EEPROM Status Register. Just to see, no real purpose. */
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "EEPROM Status register value = %x\n", ReadEEPROMStatusRegister(Adapter) );
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "EEPROM Status register value = %x\n", ReadEEPROMStatusRegister(Adapter));
return STATUS_SUCCESS;
} /* BcmInitEEPROMQueues() */
-//-----------------------------------------------------------------------------
-// Procedure: BcmInitNVM
-//
-// Description: Initialization of NVM, EEPROM size,FLASH size, sector size etc.
-//
-// Arguments:
-// Adapter - ptr to Adapter object instance
-//
-// Returns:
-// <OSAL_STATUS_CODE>
-//-----------------------------------------------------------------------------
-
-INT BcmInitNVM(PMINI_ADAPTER ps_adapter)
+/*
+ * Procedure: BcmInitNVM
+ *
+ * Description: Initialization of NVM, EEPROM size,FLASH size, sector size etc.
+ *
+ * Arguments:
+ * Adapter - ptr to Adapter object instance
+ *
+ * Returns:
+ * <OSAL_STATUS_CODE>
+ */
+
+int BcmInitNVM(struct bcm_mini_adapter *ps_adapter)
{
BcmValidateNvmType(ps_adapter);
BcmInitEEPROMQueues(ps_adapter);
- if(ps_adapter->eNVMType == NVM_AUTODETECT)
- {
+ if (ps_adapter->eNVMType == NVM_AUTODETECT) {
ps_adapter->eNVMType = BcmGetNvmType(ps_adapter);
- if(ps_adapter->eNVMType == NVM_UNKNOWN)
- {
- BCM_DEBUG_PRINT(ps_adapter,DBG_TYPE_PRINTK, 0, 0, "NVM Type is unknown!!\n");
- }
- }
- else if(ps_adapter->eNVMType == NVM_FLASH)
- {
+ if (ps_adapter->eNVMType == NVM_UNKNOWN)
+ BCM_DEBUG_PRINT(ps_adapter, DBG_TYPE_PRINTK, 0, 0, "NVM Type is unknown!!\n");
+ } else if (ps_adapter->eNVMType == NVM_FLASH) {
BcmGetFlashCSInfo(ps_adapter);
}
@@ -2435,115 +2143,107 @@ INT BcmInitNVM(PMINI_ADAPTER ps_adapter)
return STATUS_SUCCESS;
}
-/***************************************************************************/
-/*BcmGetNvmSize : set the EEPROM or flash size in Adapter.
-*
-*Input Parameter:
-* Adapter data structure
-*Return Value :
-* 0. means success;
-*/
-/***************************************************************************/
-
-static INT BcmGetNvmSize(PMINI_ADAPTER Adapter)
+
+/* BcmGetNvmSize : set the EEPROM or flash size in Adapter.
+ *
+ * Input Parameter:
+ * Adapter data structure
+ * Return Value :
+ * 0. means success;
+ */
+
+static int BcmGetNvmSize(struct bcm_mini_adapter *Adapter)
{
- if(Adapter->eNVMType == NVM_EEPROM)
- {
+ if (Adapter->eNVMType == NVM_EEPROM)
Adapter->uiNVMDSDSize = BcmGetEEPROMSize(Adapter);
- }
- else if(Adapter->eNVMType == NVM_FLASH)
- {
+ else if (Adapter->eNVMType == NVM_FLASH)
Adapter->uiNVMDSDSize = BcmGetFlashSize(Adapter);
- }
+
return 0;
}
-//-----------------------------------------------------------------------------
-// Procedure: BcmValidateNvm
-//
-// Description: Validates the NVM Type option selected against the device
-//
-// Arguments:
-// Adapter - ptr to Adapter object instance
-//
-// Returns:
-// <VOID>
-//-----------------------------------------------------------------------------
-static VOID BcmValidateNvmType(PMINI_ADAPTER Adapter)
+/*
+ * Procedure: BcmValidateNvm
+ *
+ * Description: Validates the NVM Type option selected against the device
+ *
+ * Arguments:
+ * Adapter - ptr to Adapter object instance
+ *
+ * Returns:
+ * <VOID>
+ */
+
+static VOID BcmValidateNvmType(struct bcm_mini_adapter *Adapter)
{
+ /*
+ * if forcing the FLASH through CFG file, we should ensure device really has a FLASH.
+ * Accessing the FLASH address without the FLASH being present can cause hang/freeze etc.
+ * So if NVM_FLASH is selected for older chipsets, change it to AUTODETECT where EEPROM is 1st choice.
+ */
- //
- // if forcing the FLASH through CFG file, we should ensure device really has a FLASH.
- // Accessing the FLASH address without the FLASH being present can cause hang/freeze etc.
- // So if NVM_FLASH is selected for older chipsets, change it to AUTODETECT where EEPROM is 1st choice.
- //
-
- if(Adapter->eNVMType == NVM_FLASH &&
+ if (Adapter->eNVMType == NVM_FLASH &&
Adapter->chip_id < 0xBECE3300)
- {
Adapter->eNVMType = NVM_AUTODETECT;
- }
}
-//-----------------------------------------------------------------------------
-// Procedure: BcmReadFlashRDID
-//
-// Description: Reads ID from Serial Flash
-//
-// Arguments:
-// Adapter - ptr to Adapter object instance
-//
-// Returns:
-// Flash ID
-//-----------------------------------------------------------------------------
-static ULONG BcmReadFlashRDID(PMINI_ADAPTER Adapter)
+
+/*
+ * Procedure: BcmReadFlashRDID
+ *
+ * Description: Reads ID from Serial Flash
+ *
+ * Arguments:
+ * Adapter - ptr to Adapter object instance
+ *
+ * Returns:
+ * Flash ID
+ */
+
+static ULONG BcmReadFlashRDID(struct bcm_mini_adapter *Adapter)
{
ULONG ulRDID = 0;
- UINT value;
-//
-// Read ID Instruction.
-//
- value = (FLASH_CMD_READ_ID<<24);
- wrmalt(Adapter, FLASH_SPI_CMDQ_REG,&value, sizeof(value));
-
-//Delay
- udelay(10);
-//
-// Read SPI READQ REG. The output will be WWXXYYZZ.
-// The ID is 3Bytes long and is WWXXYY. ZZ needs to be Ignored.
-//
- rdmalt(Adapter, FLASH_SPI_READQ_REG, (PUINT)&ulRDID, sizeof(ulRDID));
+ unsigned int value;
+
+ /*
+ * Read ID Instruction.
+ */
+ value = (FLASH_CMD_READ_ID << 24);
+ wrmalt(Adapter, FLASH_SPI_CMDQ_REG, &value, sizeof(value));
- return (ulRDID >>8);
+ /* Delay */
+ udelay(10);
+ /*
+ * Read SPI READQ REG. The output will be WWXXYYZZ.
+ * The ID is 3Bytes long and is WWXXYY. ZZ needs to be Ignored.
+ */
+ rdmalt(Adapter, FLASH_SPI_READQ_REG, (PUINT)&ulRDID, sizeof(ulRDID));
+ return ulRDID >> 8;
}
-INT BcmAllocFlashCSStructure(PMINI_ADAPTER psAdapter)
+int BcmAllocFlashCSStructure(struct bcm_mini_adapter *psAdapter)
{
- if(psAdapter == NULL)
- {
- BCM_DEBUG_PRINT(psAdapter,DBG_TYPE_PRINTK, 0, 0, "Adapter structure point is NULL");
+ if (!psAdapter) {
+ BCM_DEBUG_PRINT(psAdapter, DBG_TYPE_PRINTK, 0, 0, "Adapter structure point is NULL");
return -EINVAL;
}
psAdapter->psFlashCSInfo = (PFLASH_CS_INFO)kzalloc(sizeof(FLASH_CS_INFO), GFP_KERNEL);
- if(psAdapter->psFlashCSInfo == NULL)
- {
- BCM_DEBUG_PRINT(psAdapter,DBG_TYPE_PRINTK, 0, 0,"Can't Allocate memory for Flash 1.x");
+ if (psAdapter->psFlashCSInfo == NULL) {
+ BCM_DEBUG_PRINT(psAdapter, DBG_TYPE_PRINTK, 0, 0, "Can't Allocate memory for Flash 1.x");
return -ENOMEM;
}
psAdapter->psFlash2xCSInfo = (PFLASH2X_CS_INFO)kzalloc(sizeof(FLASH2X_CS_INFO), GFP_KERNEL);
- if(psAdapter->psFlash2xCSInfo == NULL)
- {
- BCM_DEBUG_PRINT(psAdapter,DBG_TYPE_PRINTK, 0, 0,"Can't Allocate memory for Flash 2.x");
+ if (!psAdapter->psFlash2xCSInfo) {
+ BCM_DEBUG_PRINT(psAdapter, DBG_TYPE_PRINTK, 0, 0, "Can't Allocate memory for Flash 2.x");
kfree(psAdapter->psFlashCSInfo);
return -ENOMEM;
}
psAdapter->psFlash2xVendorInfo = (PFLASH2X_VENDORSPECIFIC_INFO)kzalloc(sizeof(FLASH2X_VENDORSPECIFIC_INFO), GFP_KERNEL);
- if(psAdapter->psFlash2xVendorInfo == NULL)
- {
- BCM_DEBUG_PRINT(psAdapter,DBG_TYPE_PRINTK, 0, 0,"Can't Allocate Vendor Info Memory for Flash 2.x");
+ if (!psAdapter->psFlash2xVendorInfo) {
+ BCM_DEBUG_PRINT(psAdapter, DBG_TYPE_PRINTK, 0, 0, "Can't Allocate Vendor Info Memory for Flash 2.x");
kfree(psAdapter->psFlashCSInfo);
kfree(psAdapter->psFlash2xCSInfo);
return -ENOMEM;
@@ -2552,91 +2252,90 @@ INT BcmAllocFlashCSStructure(PMINI_ADAPTER psAdapter)
return STATUS_SUCCESS;
}
-INT BcmDeAllocFlashCSStructure(PMINI_ADAPTER psAdapter)
+int BcmDeAllocFlashCSStructure(struct bcm_mini_adapter *psAdapter)
{
- if(psAdapter == NULL)
- {
- BCM_DEBUG_PRINT(psAdapter,DBG_TYPE_PRINTK, 0, 0," Adapter structure point is NULL");
+ if (!psAdapter) {
+ BCM_DEBUG_PRINT(psAdapter, DBG_TYPE_PRINTK, 0, 0, "Adapter structure point is NULL");
return -EINVAL;
}
kfree(psAdapter->psFlashCSInfo);
kfree(psAdapter->psFlash2xCSInfo);
kfree(psAdapter->psFlash2xVendorInfo);
- return STATUS_SUCCESS ;
+ return STATUS_SUCCESS;
}
-static INT BcmDumpFlash2XCSStructure(PFLASH2X_CS_INFO psFlash2xCSInfo,PMINI_ADAPTER Adapter)
+static int BcmDumpFlash2XCSStructure(PFLASH2X_CS_INFO psFlash2xCSInfo, struct bcm_mini_adapter *Adapter)
{
- UINT Index = 0;
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "**********************FLASH2X CS Structure *******************");
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "Signature is :%x", (psFlash2xCSInfo->MagicNumber));
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "Flash Major Version :%d", MAJOR_VERSION(psFlash2xCSInfo->FlashLayoutVersion));
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "Flash Minor Version :%d", MINOR_VERSION(psFlash2xCSInfo->FlashLayoutVersion));
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, " ISOImageMajorVersion:0x%x", (psFlash2xCSInfo->ISOImageVersion));
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "SCSIFirmwareMajorVersion :0x%x", (psFlash2xCSInfo->SCSIFirmwareVersion));
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "OffsetFromZeroForPart1ISOImage :0x%x", (psFlash2xCSInfo->OffsetFromZeroForPart1ISOImage));
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "OffsetFromZeroForScsiFirmware :0x%x", (psFlash2xCSInfo->OffsetFromZeroForScsiFirmware));
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "SizeOfScsiFirmware :0x%x", (psFlash2xCSInfo->SizeOfScsiFirmware ));
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "OffsetFromZeroForPart2ISOImage :0x%x", (psFlash2xCSInfo->OffsetFromZeroForPart2ISOImage));
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "OffsetFromZeroForDSDStart :0x%x", (psFlash2xCSInfo->OffsetFromZeroForDSDStart));
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "OffsetFromZeroForDSDEnd :0x%x", (psFlash2xCSInfo->OffsetFromZeroForDSDEnd));
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "OffsetFromZeroForVSAStart :0x%x", (psFlash2xCSInfo->OffsetFromZeroForVSAStart));
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "OffsetFromZeroForVSAEnd :0x%x", (psFlash2xCSInfo->OffsetFromZeroForVSAEnd));
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "OffsetFromZeroForControlSectionStart :0x%x", (psFlash2xCSInfo->OffsetFromZeroForControlSectionStart));
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "OffsetFromZeroForControlSectionData :0x%x", (psFlash2xCSInfo->OffsetFromZeroForControlSectionData));
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "CDLessInactivityTimeout :0x%x", (psFlash2xCSInfo->CDLessInactivityTimeout));
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "NewImageSignature :0x%x", (psFlash2xCSInfo->NewImageSignature));
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "FlashSectorSizeSig :0x%x", (psFlash2xCSInfo->FlashSectorSizeSig));
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "FlashSectorSize :0x%x", (psFlash2xCSInfo->FlashSectorSize));
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "FlashWriteSupportSize :0x%x", (psFlash2xCSInfo->FlashWriteSupportSize));
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "TotalFlashSize :0x%X", (psFlash2xCSInfo->TotalFlashSize));
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "FlashBaseAddr :0x%x", (psFlash2xCSInfo->FlashBaseAddr));
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "FlashPartMaxSize :0x%x", (psFlash2xCSInfo->FlashPartMaxSize));
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "IsCDLessDeviceBootSig :0x%x", (psFlash2xCSInfo->IsCDLessDeviceBootSig));
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "MassStorageTimeout :0x%x", (psFlash2xCSInfo->MassStorageTimeout));
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "OffsetISOImage1Part1Start :0x%x", (psFlash2xCSInfo->OffsetISOImage1Part1Start));
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "OffsetISOImage1Part1End :0x%x", (psFlash2xCSInfo->OffsetISOImage1Part1End));
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "OffsetISOImage1Part2Start :0x%x", (psFlash2xCSInfo->OffsetISOImage1Part2Start));
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "OffsetISOImage1Part2End :0x%x", (psFlash2xCSInfo->OffsetISOImage1Part2End));
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "OffsetISOImage1Part3Start :0x%x", (psFlash2xCSInfo->OffsetISOImage1Part3Start));
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "OffsetISOImage1Part3End :0x%x", (psFlash2xCSInfo->OffsetISOImage1Part3End));
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "OffsetISOImage2Part1Start :0x%x", (psFlash2xCSInfo->OffsetISOImage2Part1Start));
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "OffsetISOImage2Part1End :0x%x", (psFlash2xCSInfo->OffsetISOImage2Part1End));
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "OffsetISOImage2Part2Start :0x%x", (psFlash2xCSInfo->OffsetISOImage2Part2Start));
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "OffsetISOImage2Part2End :0x%x", (psFlash2xCSInfo->OffsetISOImage2Part2End));
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "OffsetISOImage2Part3Start :0x%x", (psFlash2xCSInfo->OffsetISOImage2Part3Start));
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "OffsetISOImage2Part3End :0x%x", (psFlash2xCSInfo->OffsetISOImage2Part3End));
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "OffsetFromDSDStartForDSDHeader :0x%x", (psFlash2xCSInfo->OffsetFromDSDStartForDSDHeader));
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "OffsetFromZeroForDSD1Start :0x%x", (psFlash2xCSInfo->OffsetFromZeroForDSD1Start));
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "OffsetFromZeroForDSD1End :0x%x", (psFlash2xCSInfo->OffsetFromZeroForDSD1End));
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "OffsetFromZeroForDSD2Start :0x%x", (psFlash2xCSInfo->OffsetFromZeroForDSD2Start));
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "OffsetFromZeroForDSD2End :0x%x", (psFlash2xCSInfo->OffsetFromZeroForDSD2End));
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "OffsetFromZeroForVSA1Start :0x%x", (psFlash2xCSInfo->OffsetFromZeroForVSA1Start));
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "OffsetFromZeroForVSA1End :0x%x", (psFlash2xCSInfo->OffsetFromZeroForVSA1End));
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "OffsetFromZeroForVSA2Start :0x%x", (psFlash2xCSInfo->OffsetFromZeroForVSA2Start));
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "OffsetFromZeroForVSA2End :0x%x", (psFlash2xCSInfo->OffsetFromZeroForVSA2End));
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "Sector Access Bit Map is Defined as :");
- for(Index =0; Index <(FLASH2X_TOTAL_SIZE/(DEFAULT_SECTOR_SIZE *16)); Index++)
- {
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "SectorAccessBitMap[%d] :0x%x", Index,
+ unsigned int Index = 0;
+
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "**********************FLASH2X CS Structure *******************");
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "Signature is :%x", (psFlash2xCSInfo->MagicNumber));
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "Flash Major Version :%d", MAJOR_VERSION(psFlash2xCSInfo->FlashLayoutVersion));
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "Flash Minor Version :%d", MINOR_VERSION(psFlash2xCSInfo->FlashLayoutVersion));
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, " ISOImageMajorVersion:0x%x", (psFlash2xCSInfo->ISOImageVersion));
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "SCSIFirmwareMajorVersion :0x%x", (psFlash2xCSInfo->SCSIFirmwareVersion));
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "OffsetFromZeroForPart1ISOImage :0x%x", (psFlash2xCSInfo->OffsetFromZeroForPart1ISOImage));
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "OffsetFromZeroForScsiFirmware :0x%x", (psFlash2xCSInfo->OffsetFromZeroForScsiFirmware));
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "SizeOfScsiFirmware :0x%x", (psFlash2xCSInfo->SizeOfScsiFirmware));
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "OffsetFromZeroForPart2ISOImage :0x%x", (psFlash2xCSInfo->OffsetFromZeroForPart2ISOImage));
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "OffsetFromZeroForDSDStart :0x%x", (psFlash2xCSInfo->OffsetFromZeroForDSDStart));
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "OffsetFromZeroForDSDEnd :0x%x", (psFlash2xCSInfo->OffsetFromZeroForDSDEnd));
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "OffsetFromZeroForVSAStart :0x%x", (psFlash2xCSInfo->OffsetFromZeroForVSAStart));
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "OffsetFromZeroForVSAEnd :0x%x", (psFlash2xCSInfo->OffsetFromZeroForVSAEnd));
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "OffsetFromZeroForControlSectionStart :0x%x", (psFlash2xCSInfo->OffsetFromZeroForControlSectionStart));
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "OffsetFromZeroForControlSectionData :0x%x", (psFlash2xCSInfo->OffsetFromZeroForControlSectionData));
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "CDLessInactivityTimeout :0x%x", (psFlash2xCSInfo->CDLessInactivityTimeout));
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "NewImageSignature :0x%x", (psFlash2xCSInfo->NewImageSignature));
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "FlashSectorSizeSig :0x%x", (psFlash2xCSInfo->FlashSectorSizeSig));
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "FlashSectorSize :0x%x", (psFlash2xCSInfo->FlashSectorSize));
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "FlashWriteSupportSize :0x%x", (psFlash2xCSInfo->FlashWriteSupportSize));
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "TotalFlashSize :0x%X", (psFlash2xCSInfo->TotalFlashSize));
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "FlashBaseAddr :0x%x", (psFlash2xCSInfo->FlashBaseAddr));
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "FlashPartMaxSize :0x%x", (psFlash2xCSInfo->FlashPartMaxSize));
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "IsCDLessDeviceBootSig :0x%x", (psFlash2xCSInfo->IsCDLessDeviceBootSig));
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "MassStorageTimeout :0x%x", (psFlash2xCSInfo->MassStorageTimeout));
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "OffsetISOImage1Part1Start :0x%x", (psFlash2xCSInfo->OffsetISOImage1Part1Start));
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "OffsetISOImage1Part1End :0x%x", (psFlash2xCSInfo->OffsetISOImage1Part1End));
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "OffsetISOImage1Part2Start :0x%x", (psFlash2xCSInfo->OffsetISOImage1Part2Start));
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "OffsetISOImage1Part2End :0x%x", (psFlash2xCSInfo->OffsetISOImage1Part2End));
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "OffsetISOImage1Part3Start :0x%x", (psFlash2xCSInfo->OffsetISOImage1Part3Start));
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "OffsetISOImage1Part3End :0x%x", (psFlash2xCSInfo->OffsetISOImage1Part3End));
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "OffsetISOImage2Part1Start :0x%x", (psFlash2xCSInfo->OffsetISOImage2Part1Start));
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "OffsetISOImage2Part1End :0x%x", (psFlash2xCSInfo->OffsetISOImage2Part1End));
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "OffsetISOImage2Part2Start :0x%x", (psFlash2xCSInfo->OffsetISOImage2Part2Start));
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "OffsetISOImage2Part2End :0x%x", (psFlash2xCSInfo->OffsetISOImage2Part2End));
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "OffsetISOImage2Part3Start :0x%x", (psFlash2xCSInfo->OffsetISOImage2Part3Start));
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "OffsetISOImage2Part3End :0x%x", (psFlash2xCSInfo->OffsetISOImage2Part3End));
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "OffsetFromDSDStartForDSDHeader :0x%x", (psFlash2xCSInfo->OffsetFromDSDStartForDSDHeader));
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "OffsetFromZeroForDSD1Start :0x%x", (psFlash2xCSInfo->OffsetFromZeroForDSD1Start));
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "OffsetFromZeroForDSD1End :0x%x", (psFlash2xCSInfo->OffsetFromZeroForDSD1End));
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "OffsetFromZeroForDSD2Start :0x%x", (psFlash2xCSInfo->OffsetFromZeroForDSD2Start));
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "OffsetFromZeroForDSD2End :0x%x", (psFlash2xCSInfo->OffsetFromZeroForDSD2End));
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "OffsetFromZeroForVSA1Start :0x%x", (psFlash2xCSInfo->OffsetFromZeroForVSA1Start));
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "OffsetFromZeroForVSA1End :0x%x", (psFlash2xCSInfo->OffsetFromZeroForVSA1End));
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "OffsetFromZeroForVSA2Start :0x%x", (psFlash2xCSInfo->OffsetFromZeroForVSA2Start));
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "OffsetFromZeroForVSA2End :0x%x", (psFlash2xCSInfo->OffsetFromZeroForVSA2End));
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "Sector Access Bit Map is Defined as :");
+
+ for (Index = 0; Index < (FLASH2X_TOTAL_SIZE / (DEFAULT_SECTOR_SIZE * 16)); Index++)
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "SectorAccessBitMap[%d] :0x%x", Index,
(psFlash2xCSInfo->SectorAccessBitMap[Index]));
- }
return STATUS_SUCCESS;
}
-
-static INT ConvertEndianOf2XCSStructure(PFLASH2X_CS_INFO psFlash2xCSInfo)
+static int ConvertEndianOf2XCSStructure(PFLASH2X_CS_INFO psFlash2xCSInfo)
{
- UINT Index = 0;
+ unsigned int Index = 0;
+
psFlash2xCSInfo->MagicNumber = ntohl(psFlash2xCSInfo->MagicNumber);
- psFlash2xCSInfo->FlashLayoutVersion= ntohl(psFlash2xCSInfo->FlashLayoutVersion);
- //psFlash2xCSInfo->FlashLayoutMinorVersion = ntohs(psFlash2xCSInfo->FlashLayoutMinorVersion);
+ psFlash2xCSInfo->FlashLayoutVersion = ntohl(psFlash2xCSInfo->FlashLayoutVersion);
+ /* psFlash2xCSInfo->FlashLayoutMinorVersion = ntohs(psFlash2xCSInfo->FlashLayoutMinorVersion); */
psFlash2xCSInfo->ISOImageVersion = ntohl(psFlash2xCSInfo->ISOImageVersion);
- psFlash2xCSInfo->SCSIFirmwareVersion =ntohl(psFlash2xCSInfo->SCSIFirmwareVersion);
+ psFlash2xCSInfo->SCSIFirmwareVersion = ntohl(psFlash2xCSInfo->SCSIFirmwareVersion);
psFlash2xCSInfo->OffsetFromZeroForPart1ISOImage = ntohl(psFlash2xCSInfo->OffsetFromZeroForPart1ISOImage);
psFlash2xCSInfo->OffsetFromZeroForScsiFirmware = ntohl(psFlash2xCSInfo->OffsetFromZeroForScsiFirmware);
- psFlash2xCSInfo->SizeOfScsiFirmware = ntohl(psFlash2xCSInfo->SizeOfScsiFirmware );
+ psFlash2xCSInfo->SizeOfScsiFirmware = ntohl(psFlash2xCSInfo->SizeOfScsiFirmware);
psFlash2xCSInfo->OffsetFromZeroForPart2ISOImage = ntohl(psFlash2xCSInfo->OffsetFromZeroForPart2ISOImage);
psFlash2xCSInfo->OffsetFromZeroForDSDStart = ntohl(psFlash2xCSInfo->OffsetFromZeroForDSDStart);
psFlash2xCSInfo->OffsetFromZeroForDSDEnd = ntohl(psFlash2xCSInfo->OffsetFromZeroForDSDEnd);
@@ -2675,119 +2374,115 @@ static INT ConvertEndianOf2XCSStructure(PFLASH2X_CS_INFO psFlash2xCSInfo)
psFlash2xCSInfo->OffsetFromZeroForVSA1End = ntohl(psFlash2xCSInfo->OffsetFromZeroForVSA1End);
psFlash2xCSInfo->OffsetFromZeroForVSA2Start = ntohl(psFlash2xCSInfo->OffsetFromZeroForVSA2Start);
psFlash2xCSInfo->OffsetFromZeroForVSA2End = ntohl(psFlash2xCSInfo->OffsetFromZeroForVSA2End);
- for(Index =0; Index <(FLASH2X_TOTAL_SIZE/(DEFAULT_SECTOR_SIZE *16)); Index++)
- {
- psFlash2xCSInfo->SectorAccessBitMap[Index] = ntohl(psFlash2xCSInfo->SectorAccessBitMap[Index]);
- }
+
+ for (Index = 0; Index < (FLASH2X_TOTAL_SIZE / (DEFAULT_SECTOR_SIZE * 16)); Index++)
+ psFlash2xCSInfo->SectorAccessBitMap[Index] = ntohl(psFlash2xCSInfo->SectorAccessBitMap[Index]);
+
return STATUS_SUCCESS;
}
-static INT ConvertEndianOfCSStructure(PFLASH_CS_INFO psFlashCSInfo)
+static int ConvertEndianOfCSStructure(PFLASH_CS_INFO psFlashCSInfo)
{
- //UINT Index = 0;
- psFlashCSInfo->MagicNumber =ntohl(psFlashCSInfo->MagicNumber);
- psFlashCSInfo->FlashLayoutVersion =ntohl(psFlashCSInfo->FlashLayoutVersion);
- psFlashCSInfo->ISOImageVersion = ntohl(psFlashCSInfo->ISOImageVersion);
- //won't convert according to old assumption
- psFlashCSInfo->SCSIFirmwareVersion =(psFlashCSInfo->SCSIFirmwareVersion);
-
- psFlashCSInfo->OffsetFromZeroForPart1ISOImage = ntohl(psFlashCSInfo->OffsetFromZeroForPart1ISOImage);
- psFlashCSInfo->OffsetFromZeroForScsiFirmware = ntohl(psFlashCSInfo->OffsetFromZeroForScsiFirmware);
- psFlashCSInfo->SizeOfScsiFirmware = ntohl(psFlashCSInfo->SizeOfScsiFirmware );
- psFlashCSInfo->OffsetFromZeroForPart2ISOImage = ntohl(psFlashCSInfo->OffsetFromZeroForPart2ISOImage);
- psFlashCSInfo->OffsetFromZeroForCalibrationStart = ntohl(psFlashCSInfo->OffsetFromZeroForCalibrationStart);
- psFlashCSInfo->OffsetFromZeroForCalibrationEnd = ntohl(psFlashCSInfo->OffsetFromZeroForCalibrationEnd);
- psFlashCSInfo->OffsetFromZeroForVSAStart = ntohl(psFlashCSInfo->OffsetFromZeroForVSAStart);
- psFlashCSInfo->OffsetFromZeroForVSAEnd = ntohl(psFlashCSInfo->OffsetFromZeroForVSAEnd);
- psFlashCSInfo->OffsetFromZeroForControlSectionStart = ntohl(psFlashCSInfo->OffsetFromZeroForControlSectionStart);
- psFlashCSInfo->OffsetFromZeroForControlSectionData = ntohl(psFlashCSInfo->OffsetFromZeroForControlSectionData);
- psFlashCSInfo->CDLessInactivityTimeout = ntohl(psFlashCSInfo->CDLessInactivityTimeout);
- psFlashCSInfo->NewImageSignature = ntohl(psFlashCSInfo->NewImageSignature);
- psFlashCSInfo->FlashSectorSizeSig = ntohl(psFlashCSInfo->FlashSectorSizeSig);
- psFlashCSInfo->FlashSectorSize = ntohl(psFlashCSInfo->FlashSectorSize);
- psFlashCSInfo->FlashWriteSupportSize = ntohl(psFlashCSInfo->FlashWriteSupportSize);
- psFlashCSInfo->TotalFlashSize = ntohl(psFlashCSInfo->TotalFlashSize);
- psFlashCSInfo->FlashBaseAddr = ntohl(psFlashCSInfo->FlashBaseAddr);
- psFlashCSInfo->FlashPartMaxSize = ntohl(psFlashCSInfo->FlashPartMaxSize);
- psFlashCSInfo->IsCDLessDeviceBootSig = ntohl(psFlashCSInfo->IsCDLessDeviceBootSig);
- psFlashCSInfo->MassStorageTimeout = ntohl(psFlashCSInfo->MassStorageTimeout);
+ /* unsigned int Index = 0; */
+ psFlashCSInfo->MagicNumber = ntohl(psFlashCSInfo->MagicNumber);
+ psFlashCSInfo->FlashLayoutVersion = ntohl(psFlashCSInfo->FlashLayoutVersion);
+ psFlashCSInfo->ISOImageVersion = ntohl(psFlashCSInfo->ISOImageVersion);
+ /* won't convert according to old assumption */
+ psFlashCSInfo->SCSIFirmwareVersion = (psFlashCSInfo->SCSIFirmwareVersion);
+ psFlashCSInfo->OffsetFromZeroForPart1ISOImage = ntohl(psFlashCSInfo->OffsetFromZeroForPart1ISOImage);
+ psFlashCSInfo->OffsetFromZeroForScsiFirmware = ntohl(psFlashCSInfo->OffsetFromZeroForScsiFirmware);
+ psFlashCSInfo->SizeOfScsiFirmware = ntohl(psFlashCSInfo->SizeOfScsiFirmware);
+ psFlashCSInfo->OffsetFromZeroForPart2ISOImage = ntohl(psFlashCSInfo->OffsetFromZeroForPart2ISOImage);
+ psFlashCSInfo->OffsetFromZeroForCalibrationStart = ntohl(psFlashCSInfo->OffsetFromZeroForCalibrationStart);
+ psFlashCSInfo->OffsetFromZeroForCalibrationEnd = ntohl(psFlashCSInfo->OffsetFromZeroForCalibrationEnd);
+ psFlashCSInfo->OffsetFromZeroForVSAStart = ntohl(psFlashCSInfo->OffsetFromZeroForVSAStart);
+ psFlashCSInfo->OffsetFromZeroForVSAEnd = ntohl(psFlashCSInfo->OffsetFromZeroForVSAEnd);
+ psFlashCSInfo->OffsetFromZeroForControlSectionStart = ntohl(psFlashCSInfo->OffsetFromZeroForControlSectionStart);
+ psFlashCSInfo->OffsetFromZeroForControlSectionData = ntohl(psFlashCSInfo->OffsetFromZeroForControlSectionData);
+ psFlashCSInfo->CDLessInactivityTimeout = ntohl(psFlashCSInfo->CDLessInactivityTimeout);
+ psFlashCSInfo->NewImageSignature = ntohl(psFlashCSInfo->NewImageSignature);
+ psFlashCSInfo->FlashSectorSizeSig = ntohl(psFlashCSInfo->FlashSectorSizeSig);
+ psFlashCSInfo->FlashSectorSize = ntohl(psFlashCSInfo->FlashSectorSize);
+ psFlashCSInfo->FlashWriteSupportSize = ntohl(psFlashCSInfo->FlashWriteSupportSize);
+ psFlashCSInfo->TotalFlashSize = ntohl(psFlashCSInfo->TotalFlashSize);
+ psFlashCSInfo->FlashBaseAddr = ntohl(psFlashCSInfo->FlashBaseAddr);
+ psFlashCSInfo->FlashPartMaxSize = ntohl(psFlashCSInfo->FlashPartMaxSize);
+ psFlashCSInfo->IsCDLessDeviceBootSig = ntohl(psFlashCSInfo->IsCDLessDeviceBootSig);
+ psFlashCSInfo->MassStorageTimeout = ntohl(psFlashCSInfo->MassStorageTimeout);
return STATUS_SUCCESS;
}
-static INT IsSectionExistInVendorInfo(PMINI_ADAPTER Adapter, FLASH2X_SECTION_VAL section)
+static int IsSectionExistInVendorInfo(struct bcm_mini_adapter *Adapter, FLASH2X_SECTION_VAL section)
{
- return ( Adapter->uiVendorExtnFlag &&
- (Adapter->psFlash2xVendorInfo->VendorSection[section].AccessFlags & FLASH2X_SECTION_PRESENT) &&
- (Adapter->psFlash2xVendorInfo->VendorSection[section].OffsetFromZeroForSectionStart != UNINIT_PTR_IN_CS) );
+ return (Adapter->uiVendorExtnFlag &&
+ (Adapter->psFlash2xVendorInfo->VendorSection[section].AccessFlags & FLASH2X_SECTION_PRESENT) &&
+ (Adapter->psFlash2xVendorInfo->VendorSection[section].OffsetFromZeroForSectionStart != UNINIT_PTR_IN_CS));
}
-static VOID UpdateVendorInfo(PMINI_ADAPTER Adapter)
+static VOID UpdateVendorInfo(struct bcm_mini_adapter *Adapter)
{
B_UINT32 i = 0;
- UINT uiSizeSection = 0;
+ unsigned int uiSizeSection = 0;
Adapter->uiVendorExtnFlag = FALSE;
- for(i = 0;i < TOTAL_SECTIONS;i++)
+ for (i = 0; i < TOTAL_SECTIONS; i++)
Adapter->psFlash2xVendorInfo->VendorSection[i].OffsetFromZeroForSectionStart = UNINIT_PTR_IN_CS;
- if(STATUS_SUCCESS != vendorextnGetSectionInfo(Adapter, Adapter->psFlash2xVendorInfo))
+ if (STATUS_SUCCESS != vendorextnGetSectionInfo(Adapter, Adapter->psFlash2xVendorInfo))
return;
i = 0;
- while(i < TOTAL_SECTIONS)
- {
- if(!(Adapter->psFlash2xVendorInfo->VendorSection[i].AccessFlags & FLASH2X_SECTION_PRESENT))
- {
+ while (i < TOTAL_SECTIONS) {
+ if (!(Adapter->psFlash2xVendorInfo->VendorSection[i].AccessFlags & FLASH2X_SECTION_PRESENT)) {
i++;
continue;
}
Adapter->uiVendorExtnFlag = TRUE;
uiSizeSection = (Adapter->psFlash2xVendorInfo->VendorSection[i].OffsetFromZeroForSectionEnd -
- Adapter->psFlash2xVendorInfo->VendorSection[i].OffsetFromZeroForSectionStart);
+ Adapter->psFlash2xVendorInfo->VendorSection[i].OffsetFromZeroForSectionStart);
- switch(i)
- {
+ switch (i) {
case DSD0:
- if(( uiSizeSection >= (Adapter->psFlash2xCSInfo->OffsetFromDSDStartForDSDHeader + sizeof(DSD_HEADER))) &&
- (UNINIT_PTR_IN_CS != Adapter->psFlash2xVendorInfo->VendorSection[i].OffsetFromZeroForSectionStart))
+ if ((uiSizeSection >= (Adapter->psFlash2xCSInfo->OffsetFromDSDStartForDSDHeader + sizeof(DSD_HEADER))) &&
+ (UNINIT_PTR_IN_CS != Adapter->psFlash2xVendorInfo->VendorSection[i].OffsetFromZeroForSectionStart))
Adapter->psFlash2xCSInfo->OffsetFromZeroForDSDStart = Adapter->psFlash2xCSInfo->OffsetFromZeroForDSDEnd = VENDOR_PTR_IN_CS;
else
Adapter->psFlash2xCSInfo->OffsetFromZeroForDSDStart = Adapter->psFlash2xCSInfo->OffsetFromZeroForDSDEnd = UNINIT_PTR_IN_CS;
break;
case DSD1:
- if(( uiSizeSection >= (Adapter->psFlash2xCSInfo->OffsetFromDSDStartForDSDHeader + sizeof(DSD_HEADER))) &&
- (UNINIT_PTR_IN_CS != Adapter->psFlash2xVendorInfo->VendorSection[i].OffsetFromZeroForSectionStart))
+ if ((uiSizeSection >= (Adapter->psFlash2xCSInfo->OffsetFromDSDStartForDSDHeader + sizeof(DSD_HEADER))) &&
+ (UNINIT_PTR_IN_CS != Adapter->psFlash2xVendorInfo->VendorSection[i].OffsetFromZeroForSectionStart))
Adapter->psFlash2xCSInfo->OffsetFromZeroForDSD1Start = Adapter->psFlash2xCSInfo->OffsetFromZeroForDSD1End = VENDOR_PTR_IN_CS;
else
Adapter->psFlash2xCSInfo->OffsetFromZeroForDSD1Start = Adapter->psFlash2xCSInfo->OffsetFromZeroForDSD1End = UNINIT_PTR_IN_CS;
break;
case DSD2:
- if(( uiSizeSection >= (Adapter->psFlash2xCSInfo->OffsetFromDSDStartForDSDHeader + sizeof(DSD_HEADER))) &&
- (UNINIT_PTR_IN_CS != Adapter->psFlash2xVendorInfo->VendorSection[i].OffsetFromZeroForSectionStart))
+ if ((uiSizeSection >= (Adapter->psFlash2xCSInfo->OffsetFromDSDStartForDSDHeader + sizeof(DSD_HEADER))) &&
+ (UNINIT_PTR_IN_CS != Adapter->psFlash2xVendorInfo->VendorSection[i].OffsetFromZeroForSectionStart))
Adapter->psFlash2xCSInfo->OffsetFromZeroForDSD2Start = Adapter->psFlash2xCSInfo->OffsetFromZeroForDSD2End = VENDOR_PTR_IN_CS;
else
Adapter->psFlash2xCSInfo->OffsetFromZeroForDSD2Start = Adapter->psFlash2xCSInfo->OffsetFromZeroForDSD2End = UNINIT_PTR_IN_CS;
break;
case VSA0:
- if(UNINIT_PTR_IN_CS != Adapter->psFlash2xVendorInfo->VendorSection[i].OffsetFromZeroForSectionStart)
+ if (UNINIT_PTR_IN_CS != Adapter->psFlash2xVendorInfo->VendorSection[i].OffsetFromZeroForSectionStart)
Adapter->psFlash2xCSInfo->OffsetFromZeroForVSAStart = Adapter->psFlash2xCSInfo->OffsetFromZeroForVSAEnd = VENDOR_PTR_IN_CS;
else
Adapter->psFlash2xCSInfo->OffsetFromZeroForVSAStart = Adapter->psFlash2xCSInfo->OffsetFromZeroForVSAEnd = UNINIT_PTR_IN_CS;
break;
case VSA1:
- if(UNINIT_PTR_IN_CS != Adapter->psFlash2xVendorInfo->VendorSection[i].OffsetFromZeroForSectionStart)
+ if (UNINIT_PTR_IN_CS != Adapter->psFlash2xVendorInfo->VendorSection[i].OffsetFromZeroForSectionStart)
Adapter->psFlash2xCSInfo->OffsetFromZeroForVSA1Start = Adapter->psFlash2xCSInfo->OffsetFromZeroForVSA1End = VENDOR_PTR_IN_CS;
else
Adapter->psFlash2xCSInfo->OffsetFromZeroForVSA1Start = Adapter->psFlash2xCSInfo->OffsetFromZeroForVSA1End = UNINIT_PTR_IN_CS;
break;
case VSA2:
- if(UNINIT_PTR_IN_CS != Adapter->psFlash2xVendorInfo->VendorSection[i].OffsetFromZeroForSectionStart)
+ if (UNINIT_PTR_IN_CS != Adapter->psFlash2xVendorInfo->VendorSection[i].OffsetFromZeroForSectionStart)
Adapter->psFlash2xCSInfo->OffsetFromZeroForVSA2Start = Adapter->psFlash2xCSInfo->OffsetFromZeroForVSA2End = VENDOR_PTR_IN_CS;
else
Adapter->psFlash2xCSInfo->OffsetFromZeroForVSA2Start = Adapter->psFlash2xCSInfo->OffsetFromZeroForVSA2End = UNINIT_PTR_IN_CS;
@@ -2798,133 +2493,111 @@ static VOID UpdateVendorInfo(PMINI_ADAPTER Adapter)
}
i++;
}
-
}
-//-----------------------------------------------------------------------------
-// Procedure: BcmGetFlashCSInfo
-//
-// Description: Reads control structure and gets Cal section addresses.
-//
-// Arguments:
-// Adapter - ptr to Adapter object instance
-//
-// Returns:
-// <VOID>
-//-----------------------------------------------------------------------------
-
-static INT BcmGetFlashCSInfo(PMINI_ADAPTER Adapter)
+/*
+ * Procedure: BcmGetFlashCSInfo
+ *
+ * Description: Reads control structure and gets Cal section addresses.
+ *
+ * Arguments:
+ * Adapter - ptr to Adapter object instance
+ *
+ * Returns:
+ * <VOID>
+ */
+
+static int BcmGetFlashCSInfo(struct bcm_mini_adapter *Adapter)
{
- //FLASH_CS_INFO sFlashCsInfo = {0};
+ /* FLASH_CS_INFO sFlashCsInfo = {0}; */
-#if !defined(BCM_SHM_INTERFACE) || defined(FLASH_DIRECT_ACCESS)
- UINT value;
-#endif
- UINT uiFlashLayoutMajorVersion;
+ #if !defined(BCM_SHM_INTERFACE) || defined(FLASH_DIRECT_ACCESS)
+ unsigned int value;
+ #endif
+
+ unsigned int uiFlashLayoutMajorVersion;
Adapter->uiFlashLayoutMinorVersion = 0;
Adapter->uiFlashLayoutMajorVersion = 0;
Adapter->ulFlashControlSectionStart = FLASH_CS_INFO_START_ADDR;
-
Adapter->uiFlashBaseAdd = 0;
Adapter->ulFlashCalStart = 0;
- memset(Adapter->psFlashCSInfo, 0 ,sizeof(FLASH_CS_INFO));
- memset(Adapter->psFlash2xCSInfo, 0 ,sizeof(FLASH2X_CS_INFO));
+ memset(Adapter->psFlashCSInfo, 0 , sizeof(FLASH_CS_INFO));
+ memset(Adapter->psFlash2xCSInfo, 0 , sizeof(FLASH2X_CS_INFO));
- if(!Adapter->bDDRInitDone)
- {
- {
- value = FLASH_CONTIGIOUS_START_ADDR_BEFORE_INIT;
- wrmalt(Adapter, 0xAF00A080, &value, sizeof(value));
- }
+ if (!Adapter->bDDRInitDone) {
+ value = FLASH_CONTIGIOUS_START_ADDR_BEFORE_INIT;
+ wrmalt(Adapter, 0xAF00A080, &value, sizeof(value));
}
-
- // Reading first 8 Bytes to get the Flash Layout
- // MagicNumber(4 bytes) +FlashLayoutMinorVersion(2 Bytes) +FlashLayoutMajorVersion(2 Bytes)
- BeceemFlashBulkRead(Adapter,(PUINT)Adapter->psFlashCSInfo,Adapter->ulFlashControlSectionStart,8);
+ /* Reading first 8 Bytes to get the Flash Layout
+ * MagicNumber(4 bytes) +FlashLayoutMinorVersion(2 Bytes) +FlashLayoutMajorVersion(2 Bytes)
+ */
+ BeceemFlashBulkRead(Adapter, (PUINT)Adapter->psFlashCSInfo, Adapter->ulFlashControlSectionStart, 8);
Adapter->psFlashCSInfo->FlashLayoutVersion = ntohl(Adapter->psFlashCSInfo->FlashLayoutVersion);
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "Flash Layout Version :%X", (Adapter->psFlashCSInfo->FlashLayoutVersion));
- //BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "Flash Layout Minor Version :%d\n", ntohs(sFlashCsInfo.FlashLayoutMinorVersion));
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "Signature is :%x\n", ntohl(Adapter->psFlashCSInfo->MagicNumber));
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "Flash Layout Version :%X", (Adapter->psFlashCSInfo->FlashLayoutVersion));
+ /* BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "Flash Layout Minor Version :%d\n", ntohs(sFlashCsInfo.FlashLayoutMinorVersion)); */
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "Signature is :%x\n", ntohl(Adapter->psFlashCSInfo->MagicNumber));
- if(FLASH_CONTROL_STRUCT_SIGNATURE == ntohl(Adapter->psFlashCSInfo->MagicNumber))
- {
+ if (FLASH_CONTROL_STRUCT_SIGNATURE == ntohl(Adapter->psFlashCSInfo->MagicNumber)) {
uiFlashLayoutMajorVersion = MAJOR_VERSION((Adapter->psFlashCSInfo->FlashLayoutVersion));
Adapter->uiFlashLayoutMinorVersion = MINOR_VERSION((Adapter->psFlashCSInfo->FlashLayoutVersion));
- }
- else
- {
+ } else {
Adapter->uiFlashLayoutMinorVersion = 0;
uiFlashLayoutMajorVersion = 0;
}
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL,"FLASH LAYOUT MAJOR VERSION :%X", uiFlashLayoutMajorVersion);
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "FLASH LAYOUT MAJOR VERSION :%X", uiFlashLayoutMajorVersion);
- if(uiFlashLayoutMajorVersion < FLASH_2X_MAJOR_NUMBER)
- {
- BeceemFlashBulkRead(Adapter,(PUINT)Adapter->psFlashCSInfo,Adapter->ulFlashControlSectionStart,sizeof(FLASH_CS_INFO));
+ if (uiFlashLayoutMajorVersion < FLASH_2X_MAJOR_NUMBER) {
+ BeceemFlashBulkRead(Adapter, (PUINT)Adapter->psFlashCSInfo, Adapter->ulFlashControlSectionStart, sizeof(FLASH_CS_INFO));
ConvertEndianOfCSStructure(Adapter->psFlashCSInfo);
Adapter->ulFlashCalStart = (Adapter->psFlashCSInfo->OffsetFromZeroForCalibrationStart);
- if(!((Adapter->uiFlashLayoutMajorVersion == 1) && (Adapter->uiFlashLayoutMinorVersion == 1)))
- {
+ if (!((Adapter->uiFlashLayoutMajorVersion == 1) && (Adapter->uiFlashLayoutMinorVersion == 1)))
Adapter->ulFlashControlSectionStart = Adapter->psFlashCSInfo->OffsetFromZeroForControlSectionStart;
- }
- if((FLASH_CONTROL_STRUCT_SIGNATURE == (Adapter->psFlashCSInfo->MagicNumber)) &&
- (SCSI_FIRMWARE_MINOR_VERSION <= MINOR_VERSION(Adapter->psFlashCSInfo->SCSIFirmwareVersion)) &&
- (FLASH_SECTOR_SIZE_SIG == (Adapter->psFlashCSInfo->FlashSectorSizeSig)) &&
- (BYTE_WRITE_SUPPORT == (Adapter->psFlashCSInfo->FlashWriteSupportSize)))
- {
+ if ((FLASH_CONTROL_STRUCT_SIGNATURE == (Adapter->psFlashCSInfo->MagicNumber)) &&
+ (SCSI_FIRMWARE_MINOR_VERSION <= MINOR_VERSION(Adapter->psFlashCSInfo->SCSIFirmwareVersion)) &&
+ (FLASH_SECTOR_SIZE_SIG == (Adapter->psFlashCSInfo->FlashSectorSizeSig)) &&
+ (BYTE_WRITE_SUPPORT == (Adapter->psFlashCSInfo->FlashWriteSupportSize))) {
Adapter->ulFlashWriteSize = (Adapter->psFlashCSInfo->FlashWriteSupportSize);
- Adapter->fpFlashWrite = flashByteWrite;
- Adapter->fpFlashWriteWithStatusCheck = flashByteWriteStatus;
- }
- else
- {
+ Adapter->fpFlashWrite = flashByteWrite;
+ Adapter->fpFlashWriteWithStatusCheck = flashByteWriteStatus;
+ } else {
Adapter->ulFlashWriteSize = MAX_RW_SIZE;
Adapter->fpFlashWrite = flashWrite;
- Adapter->fpFlashWriteWithStatusCheck = flashWriteStatus;
+ Adapter->fpFlashWriteWithStatusCheck = flashWriteStatus;
}
BcmGetFlashSectorSize(Adapter, (Adapter->psFlashCSInfo->FlashSectorSizeSig),
- (Adapter->psFlashCSInfo->FlashSectorSize));
-
-
+ (Adapter->psFlashCSInfo->FlashSectorSize));
Adapter->uiFlashBaseAdd = Adapter->psFlashCSInfo->FlashBaseAddr & 0xFCFFFFFF;
-
-
- }
- else
- {
- if(BcmFlash2xBulkRead(Adapter,(PUINT)Adapter->psFlash2xCSInfo,NO_SECTION_VAL,
- Adapter->ulFlashControlSectionStart,sizeof(FLASH2X_CS_INFO)))
- {
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Unable to read CS structure \n");
+ } else {
+ if (BcmFlash2xBulkRead(Adapter, (PUINT)Adapter->psFlash2xCSInfo, NO_SECTION_VAL,
+ Adapter->ulFlashControlSectionStart, sizeof(FLASH2X_CS_INFO))) {
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Unable to read CS structure\n");
return STATUS_FAILURE;
}
+
ConvertEndianOf2XCSStructure(Adapter->psFlash2xCSInfo);
- BcmDumpFlash2XCSStructure(Adapter->psFlash2xCSInfo,Adapter);
- if((FLASH_CONTROL_STRUCT_SIGNATURE == Adapter->psFlash2xCSInfo->MagicNumber) &&
- (SCSI_FIRMWARE_MINOR_VERSION <= MINOR_VERSION(Adapter->psFlash2xCSInfo->SCSIFirmwareVersion)) &&
- (FLASH_SECTOR_SIZE_SIG == Adapter->psFlash2xCSInfo->FlashSectorSizeSig) &&
- (BYTE_WRITE_SUPPORT == Adapter->psFlash2xCSInfo->FlashWriteSupportSize))
- {
+ BcmDumpFlash2XCSStructure(Adapter->psFlash2xCSInfo, Adapter);
+ if ((FLASH_CONTROL_STRUCT_SIGNATURE == Adapter->psFlash2xCSInfo->MagicNumber) &&
+ (SCSI_FIRMWARE_MINOR_VERSION <= MINOR_VERSION(Adapter->psFlash2xCSInfo->SCSIFirmwareVersion)) &&
+ (FLASH_SECTOR_SIZE_SIG == Adapter->psFlash2xCSInfo->FlashSectorSizeSig) &&
+ (BYTE_WRITE_SUPPORT == Adapter->psFlash2xCSInfo->FlashWriteSupportSize)) {
Adapter->ulFlashWriteSize = Adapter->psFlash2xCSInfo->FlashWriteSupportSize;
- Adapter->fpFlashWrite = flashByteWrite;
- Adapter->fpFlashWriteWithStatusCheck = flashByteWriteStatus;
- }
- else
- {
+ Adapter->fpFlashWrite = flashByteWrite;
+ Adapter->fpFlashWriteWithStatusCheck = flashByteWriteStatus;
+ } else {
Adapter->ulFlashWriteSize = MAX_RW_SIZE;
Adapter->fpFlashWrite = flashWrite;
- Adapter->fpFlashWriteWithStatusCheck = flashWriteStatus;
+ Adapter->fpFlashWriteWithStatusCheck = flashWriteStatus;
}
BcmGetFlashSectorSize(Adapter, Adapter->psFlash2xCSInfo->FlashSectorSizeSig,
- Adapter->psFlash2xCSInfo->FlashSectorSize);
+ Adapter->psFlash2xCSInfo->FlashSectorSize);
UpdateVendorInfo(Adapter);
@@ -2932,426 +2605,394 @@ static INT BcmGetFlashCSInfo(PMINI_ADAPTER Adapter)
BcmGetActiveISO(Adapter);
Adapter->uiFlashBaseAdd = Adapter->psFlash2xCSInfo->FlashBaseAddr & 0xFCFFFFFF;
Adapter->ulFlashControlSectionStart = Adapter->psFlash2xCSInfo->OffsetFromZeroForControlSectionStart;
-
}
/*
- Concerns: what if CS sector size does not match with this sector size ???
- what is the indication of AccessBitMap in CS in flash 2.x ????
- */
+ * Concerns: what if CS sector size does not match with this sector size ???
+ * what is the indication of AccessBitMap in CS in flash 2.x ????
+ */
Adapter->ulFlashID = BcmReadFlashRDID(Adapter);
-
Adapter->uiFlashLayoutMajorVersion = uiFlashLayoutMajorVersion;
-
- return STATUS_SUCCESS ;
+ return STATUS_SUCCESS;
}
-
-//-----------------------------------------------------------------------------
-// Procedure: BcmGetNvmType
-//
-// Description: Finds the type of NVM used.
-//
-// Arguments:
-// Adapter - ptr to Adapter object instance
-//
-// Returns:
-// NVM_TYPE
-//
-//-----------------------------------------------------------------------------
-
-static NVM_TYPE BcmGetNvmType(PMINI_ADAPTER Adapter)
+/*
+ * Procedure: BcmGetNvmType
+ *
+ * Description: Finds the type of NVM used.
+ *
+ * Arguments:
+ * Adapter - ptr to Adapter object instance
+ *
+ * Returns:
+ * NVM_TYPE
+ *
+ */
+
+static NVM_TYPE BcmGetNvmType(struct bcm_mini_adapter *Adapter)
{
- UINT uiData = 0;
+ unsigned int uiData = 0;
- BeceemEEPROMBulkRead(Adapter,&uiData,0x0,4);
- if(uiData == BECM)
- {
+ BeceemEEPROMBulkRead(Adapter, &uiData, 0x0, 4);
+ if (uiData == BECM)
return NVM_EEPROM;
- }
- //
- // Read control struct and get cal addresses before accessing the flash
- //
+
+ /*
+ * Read control struct and get cal addresses before accessing the flash
+ */
BcmGetFlashCSInfo(Adapter);
- BeceemFlashBulkRead(Adapter,&uiData,0x0 + Adapter->ulFlashCalStart,4);
- if(uiData == BECM)
- {
+ BeceemFlashBulkRead(Adapter, &uiData, 0x0 + Adapter->ulFlashCalStart, 4);
+ if (uiData == BECM)
return NVM_FLASH;
- }
-//
-// even if there is no valid signature on EEPROM/FLASH find out if they really exist.
-// if exist select it.
-//
- if(BcmGetEEPROMSize(Adapter))
- {
- return NVM_EEPROM;
- }
-
-//TBD for Flash.
+ /*
+ * even if there is no valid signature on EEPROM/FLASH find out if they really exist.
+ * if exist select it.
+ */
+ if (BcmGetEEPROMSize(Adapter))
+ return NVM_EEPROM;
+ /* TBD for Flash. */
return NVM_UNKNOWN;
}
-/**
-* BcmGetSectionValStartOffset - this will calculate the section's starting offset if section val is given
-* @Adapter : Drivers Private Data structure
-* @eFlashSectionVal : Flash secion value defined in enum FLASH2X_SECTION_VAL
-*
-* Return value:-
-* On success it return the start offset of the provided section val
-* On Failure -returns STATUS_FAILURE
-**/
-
-INT BcmGetSectionValStartOffset(PMINI_ADAPTER Adapter, FLASH2X_SECTION_VAL eFlashSectionVal)
+/*
+ * BcmGetSectionValStartOffset - this will calculate the section's starting offset if section val is given
+ * @Adapter : Drivers Private Data structure
+ * @eFlashSectionVal : Flash secion value defined in enum FLASH2X_SECTION_VAL
+ *
+ * Return value:-
+ * On success it return the start offset of the provided section val
+ * On Failure -returns STATUS_FAILURE
+ */
+
+int BcmGetSectionValStartOffset(struct bcm_mini_adapter *Adapter, FLASH2X_SECTION_VAL eFlashSectionVal)
{
/*
- * Considering all the section for which end offset can be calculated or directly given
- * in CS Structure. if matching case does not exist, return STATUS_FAILURE indicating section
- * endoffset can't be calculated or given in CS Structure.
- */
+ * Considering all the section for which end offset can be calculated or directly given
+ * in CS Structure. if matching case does not exist, return STATUS_FAILURE indicating section
+ * endoffset can't be calculated or given in CS Structure.
+ */
- INT SectStartOffset = 0 ;
+ int SectStartOffset = 0;
- SectStartOffset = INVALID_OFFSET ;
+ SectStartOffset = INVALID_OFFSET;
- if(IsSectionExistInVendorInfo(Adapter,eFlashSectionVal))
- {
+ if (IsSectionExistInVendorInfo(Adapter, eFlashSectionVal))
return Adapter->psFlash2xVendorInfo->VendorSection[eFlashSectionVal].OffsetFromZeroForSectionStart;
- }
- switch(eFlashSectionVal)
- {
- case ISO_IMAGE1 :
- if((Adapter->psFlash2xCSInfo->OffsetISOImage1Part1Start != UNINIT_PTR_IN_CS) &&
- (IsNonCDLessDevice(Adapter) == FALSE))
- SectStartOffset = (Adapter->psFlash2xCSInfo->OffsetISOImage1Part1Start);
- break;
- case ISO_IMAGE2 :
- if((Adapter->psFlash2xCSInfo->OffsetISOImage2Part1Start != UNINIT_PTR_IN_CS) &&
- (IsNonCDLessDevice(Adapter) == FALSE))
- SectStartOffset = (Adapter->psFlash2xCSInfo->OffsetISOImage2Part1Start);
- break;
- case DSD0 :
- if(Adapter->psFlash2xCSInfo->OffsetFromZeroForDSDStart != UNINIT_PTR_IN_CS)
- SectStartOffset = (Adapter->psFlash2xCSInfo->OffsetFromZeroForDSDStart);
- break;
- case DSD1 :
- if(Adapter->psFlash2xCSInfo->OffsetFromZeroForDSD1Start != UNINIT_PTR_IN_CS)
- SectStartOffset = (Adapter->psFlash2xCSInfo->OffsetFromZeroForDSD1Start);
- break;
- case DSD2 :
- if(Adapter->psFlash2xCSInfo->OffsetFromZeroForDSD2Start != UNINIT_PTR_IN_CS)
- SectStartOffset = (Adapter->psFlash2xCSInfo->OffsetFromZeroForDSD2Start);
- break;
- case VSA0 :
- if(Adapter->psFlash2xCSInfo->OffsetFromZeroForVSAStart != UNINIT_PTR_IN_CS)
- SectStartOffset = (Adapter->psFlash2xCSInfo->OffsetFromZeroForVSAStart);
- break;
- case VSA1 :
- if(Adapter->psFlash2xCSInfo->OffsetFromZeroForVSA1Start != UNINIT_PTR_IN_CS)
- SectStartOffset = (Adapter->psFlash2xCSInfo->OffsetFromZeroForVSA1Start);
- break;
- case VSA2 :
- if(Adapter->psFlash2xCSInfo->OffsetFromZeroForVSA2Start != UNINIT_PTR_IN_CS)
- SectStartOffset = (Adapter->psFlash2xCSInfo->OffsetFromZeroForVSA2Start);
- break;
- case SCSI :
- if(Adapter->psFlash2xCSInfo->OffsetFromZeroForScsiFirmware != UNINIT_PTR_IN_CS)
- SectStartOffset = (Adapter->psFlash2xCSInfo->OffsetFromZeroForScsiFirmware);
- break;
- case CONTROL_SECTION :
- if(Adapter->psFlash2xCSInfo->OffsetFromZeroForControlSectionStart != UNINIT_PTR_IN_CS)
- SectStartOffset = (Adapter->psFlash2xCSInfo->OffsetFromZeroForControlSectionStart);
- break;
- case ISO_IMAGE1_PART2 :
- if(Adapter->psFlash2xCSInfo->OffsetISOImage1Part2Start != UNINIT_PTR_IN_CS)
- SectStartOffset = (Adapter->psFlash2xCSInfo->OffsetISOImage1Part2Start);
- break;
- case ISO_IMAGE1_PART3 :
- if(Adapter->psFlash2xCSInfo->OffsetISOImage1Part3Start != UNINIT_PTR_IN_CS)
- SectStartOffset = (Adapter->psFlash2xCSInfo->OffsetISOImage1Part3Start);
- break;
- case ISO_IMAGE2_PART2 :
- if(Adapter->psFlash2xCSInfo->OffsetISOImage2Part2Start != UNINIT_PTR_IN_CS)
- SectStartOffset = (Adapter->psFlash2xCSInfo->OffsetISOImage2Part2Start);
- break;
- case ISO_IMAGE2_PART3 :
- if(Adapter->psFlash2xCSInfo->OffsetISOImage2Part3Start != UNINIT_PTR_IN_CS)
- SectStartOffset = (Adapter->psFlash2xCSInfo->OffsetISOImage2Part3Start);
- break;
- default :
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Section Does not exist in Flash 2.x");
- SectStartOffset = INVALID_OFFSET;
+ switch (eFlashSectionVal) {
+ case ISO_IMAGE1:
+ if ((Adapter->psFlash2xCSInfo->OffsetISOImage1Part1Start != UNINIT_PTR_IN_CS) &&
+ (IsNonCDLessDevice(Adapter) == FALSE))
+ SectStartOffset = (Adapter->psFlash2xCSInfo->OffsetISOImage1Part1Start);
+ break;
+ case ISO_IMAGE2:
+ if ((Adapter->psFlash2xCSInfo->OffsetISOImage2Part1Start != UNINIT_PTR_IN_CS) &&
+ (IsNonCDLessDevice(Adapter) == FALSE))
+ SectStartOffset = (Adapter->psFlash2xCSInfo->OffsetISOImage2Part1Start);
+ break;
+ case DSD0:
+ if (Adapter->psFlash2xCSInfo->OffsetFromZeroForDSDStart != UNINIT_PTR_IN_CS)
+ SectStartOffset = (Adapter->psFlash2xCSInfo->OffsetFromZeroForDSDStart);
+ break;
+ case DSD1:
+ if (Adapter->psFlash2xCSInfo->OffsetFromZeroForDSD1Start != UNINIT_PTR_IN_CS)
+ SectStartOffset = (Adapter->psFlash2xCSInfo->OffsetFromZeroForDSD1Start);
+ break;
+ case DSD2:
+ if (Adapter->psFlash2xCSInfo->OffsetFromZeroForDSD2Start != UNINIT_PTR_IN_CS)
+ SectStartOffset = (Adapter->psFlash2xCSInfo->OffsetFromZeroForDSD2Start);
+ break;
+ case VSA0:
+ if (Adapter->psFlash2xCSInfo->OffsetFromZeroForVSAStart != UNINIT_PTR_IN_CS)
+ SectStartOffset = (Adapter->psFlash2xCSInfo->OffsetFromZeroForVSAStart);
+ break;
+ case VSA1:
+ if (Adapter->psFlash2xCSInfo->OffsetFromZeroForVSA1Start != UNINIT_PTR_IN_CS)
+ SectStartOffset = (Adapter->psFlash2xCSInfo->OffsetFromZeroForVSA1Start);
+ break;
+ case VSA2:
+ if (Adapter->psFlash2xCSInfo->OffsetFromZeroForVSA2Start != UNINIT_PTR_IN_CS)
+ SectStartOffset = (Adapter->psFlash2xCSInfo->OffsetFromZeroForVSA2Start);
+ break;
+ case SCSI:
+ if (Adapter->psFlash2xCSInfo->OffsetFromZeroForScsiFirmware != UNINIT_PTR_IN_CS)
+ SectStartOffset = (Adapter->psFlash2xCSInfo->OffsetFromZeroForScsiFirmware);
+ break;
+ case CONTROL_SECTION:
+ if (Adapter->psFlash2xCSInfo->OffsetFromZeroForControlSectionStart != UNINIT_PTR_IN_CS)
+ SectStartOffset = (Adapter->psFlash2xCSInfo->OffsetFromZeroForControlSectionStart);
+ break;
+ case ISO_IMAGE1_PART2:
+ if (Adapter->psFlash2xCSInfo->OffsetISOImage1Part2Start != UNINIT_PTR_IN_CS)
+ SectStartOffset = (Adapter->psFlash2xCSInfo->OffsetISOImage1Part2Start);
+ break;
+ case ISO_IMAGE1_PART3:
+ if (Adapter->psFlash2xCSInfo->OffsetISOImage1Part3Start != UNINIT_PTR_IN_CS)
+ SectStartOffset = (Adapter->psFlash2xCSInfo->OffsetISOImage1Part3Start);
+ break;
+ case ISO_IMAGE2_PART2:
+ if (Adapter->psFlash2xCSInfo->OffsetISOImage2Part2Start != UNINIT_PTR_IN_CS)
+ SectStartOffset = (Adapter->psFlash2xCSInfo->OffsetISOImage2Part2Start);
+ break;
+ case ISO_IMAGE2_PART3:
+ if (Adapter->psFlash2xCSInfo->OffsetISOImage2Part3Start != UNINIT_PTR_IN_CS)
+ SectStartOffset = (Adapter->psFlash2xCSInfo->OffsetISOImage2Part3Start);
+ break;
+ default:
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Section Does not exist in Flash 2.x");
+ SectStartOffset = INVALID_OFFSET;
}
+
return SectStartOffset;
}
-/**
-* BcmGetSectionValEndOffset - this will calculate the section's Ending offset if section val is given
-* @Adapter : Drivers Private Data structure
-* @eFlashSectionVal : Flash secion value defined in enum FLASH2X_SECTION_VAL
-*
-* Return value:-
-* On success it return the end offset of the provided section val
-* On Failure -returns STATUS_FAILURE
-**/
-
-INT BcmGetSectionValEndOffset(PMINI_ADAPTER Adapter, FLASH2X_SECTION_VAL eFlash2xSectionVal)
+/*
+ * BcmGetSectionValEndOffset - this will calculate the section's Ending offset if section val is given
+ * @Adapter : Drivers Private Data structure
+ * @eFlashSectionVal : Flash secion value defined in enum FLASH2X_SECTION_VAL
+ *
+ * Return value:-
+ * On success it return the end offset of the provided section val
+ * On Failure -returns STATUS_FAILURE
+ */
+
+int BcmGetSectionValEndOffset(struct bcm_mini_adapter *Adapter, FLASH2X_SECTION_VAL eFlash2xSectionVal)
{
- INT SectEndOffset = 0 ;
- SectEndOffset = INVALID_OFFSET;
+ int SectEndOffset = 0;
- if(IsSectionExistInVendorInfo(Adapter,eFlash2xSectionVal))
- {
+ SectEndOffset = INVALID_OFFSET;
+ if (IsSectionExistInVendorInfo(Adapter, eFlash2xSectionVal))
return Adapter->psFlash2xVendorInfo->VendorSection[eFlash2xSectionVal].OffsetFromZeroForSectionEnd;
- }
- switch(eFlash2xSectionVal)
- {
- case ISO_IMAGE1 :
- if((Adapter->psFlash2xCSInfo->OffsetISOImage1Part1End!= UNINIT_PTR_IN_CS) &&
- (IsNonCDLessDevice(Adapter) == FALSE))
- SectEndOffset = (Adapter->psFlash2xCSInfo->OffsetISOImage1Part1End);
- break;
- case ISO_IMAGE2 :
- if((Adapter->psFlash2xCSInfo->OffsetISOImage2Part1End!= UNINIT_PTR_IN_CS) &&
- (IsNonCDLessDevice(Adapter) == FALSE))
- SectEndOffset = (Adapter->psFlash2xCSInfo->OffsetISOImage2Part1End);
- break;
- case DSD0 :
- if(Adapter->psFlash2xCSInfo->OffsetFromZeroForDSDEnd != UNINIT_PTR_IN_CS)
- SectEndOffset = (Adapter->psFlash2xCSInfo->OffsetFromZeroForDSDEnd);
- break;
- case DSD1 :
- if(Adapter->psFlash2xCSInfo->OffsetFromZeroForDSD1End != UNINIT_PTR_IN_CS)
- SectEndOffset = (Adapter->psFlash2xCSInfo->OffsetFromZeroForDSD1End);
- break;
- case DSD2 :
- if(Adapter->psFlash2xCSInfo->OffsetFromZeroForDSD2End != UNINIT_PTR_IN_CS)
- SectEndOffset = (Adapter->psFlash2xCSInfo->OffsetFromZeroForDSD2End);
- break;
- case VSA0 :
- if(Adapter->psFlash2xCSInfo->OffsetFromZeroForVSAEnd != UNINIT_PTR_IN_CS)
- SectEndOffset = (Adapter->psFlash2xCSInfo->OffsetFromZeroForVSAEnd);
- break;
- case VSA1 :
- if(Adapter->psFlash2xCSInfo->OffsetFromZeroForVSA1End != UNINIT_PTR_IN_CS)
- SectEndOffset = (Adapter->psFlash2xCSInfo->OffsetFromZeroForVSA1End);
- break;
- case VSA2 :
- if(Adapter->psFlash2xCSInfo->OffsetFromZeroForVSA2End != UNINIT_PTR_IN_CS)
- SectEndOffset = (Adapter->psFlash2xCSInfo->OffsetFromZeroForVSA2End);
- break;
- case SCSI :
- if(Adapter->psFlash2xCSInfo->OffsetFromZeroForScsiFirmware != UNINIT_PTR_IN_CS)
- SectEndOffset = ((Adapter->psFlash2xCSInfo->OffsetFromZeroForScsiFirmware) +
+ switch (eFlash2xSectionVal) {
+ case ISO_IMAGE1:
+ if ((Adapter->psFlash2xCSInfo->OffsetISOImage1Part1End != UNINIT_PTR_IN_CS) &&
+ (IsNonCDLessDevice(Adapter) == FALSE))
+ SectEndOffset = (Adapter->psFlash2xCSInfo->OffsetISOImage1Part1End);
+ break;
+ case ISO_IMAGE2:
+ if ((Adapter->psFlash2xCSInfo->OffsetISOImage2Part1End != UNINIT_PTR_IN_CS) &&
+ (IsNonCDLessDevice(Adapter) == FALSE))
+ SectEndOffset = (Adapter->psFlash2xCSInfo->OffsetISOImage2Part1End);
+ break;
+ case DSD0:
+ if (Adapter->psFlash2xCSInfo->OffsetFromZeroForDSDEnd != UNINIT_PTR_IN_CS)
+ SectEndOffset = (Adapter->psFlash2xCSInfo->OffsetFromZeroForDSDEnd);
+ break;
+ case DSD1:
+ if (Adapter->psFlash2xCSInfo->OffsetFromZeroForDSD1End != UNINIT_PTR_IN_CS)
+ SectEndOffset = (Adapter->psFlash2xCSInfo->OffsetFromZeroForDSD1End);
+ break;
+ case DSD2:
+ if (Adapter->psFlash2xCSInfo->OffsetFromZeroForDSD2End != UNINIT_PTR_IN_CS)
+ SectEndOffset = (Adapter->psFlash2xCSInfo->OffsetFromZeroForDSD2End);
+ break;
+ case VSA0:
+ if (Adapter->psFlash2xCSInfo->OffsetFromZeroForVSAEnd != UNINIT_PTR_IN_CS)
+ SectEndOffset = (Adapter->psFlash2xCSInfo->OffsetFromZeroForVSAEnd);
+ break;
+ case VSA1:
+ if (Adapter->psFlash2xCSInfo->OffsetFromZeroForVSA1End != UNINIT_PTR_IN_CS)
+ SectEndOffset = (Adapter->psFlash2xCSInfo->OffsetFromZeroForVSA1End);
+ break;
+ case VSA2:
+ if (Adapter->psFlash2xCSInfo->OffsetFromZeroForVSA2End != UNINIT_PTR_IN_CS)
+ SectEndOffset = (Adapter->psFlash2xCSInfo->OffsetFromZeroForVSA2End);
+ break;
+ case SCSI:
+ if (Adapter->psFlash2xCSInfo->OffsetFromZeroForScsiFirmware != UNINIT_PTR_IN_CS)
+ SectEndOffset = ((Adapter->psFlash2xCSInfo->OffsetFromZeroForScsiFirmware) +
(Adapter->psFlash2xCSInfo->SizeOfScsiFirmware));
- break;
- case CONTROL_SECTION :
- //Not Clear So Putting failure. confirm and fix it.
- SectEndOffset = STATUS_FAILURE;
- case ISO_IMAGE1_PART2 :
- if(Adapter->psFlash2xCSInfo->OffsetISOImage1Part2End!= UNINIT_PTR_IN_CS)
- SectEndOffset = (Adapter->psFlash2xCSInfo->OffsetISOImage1Part2End);
- break;
- case ISO_IMAGE1_PART3 :
- if(Adapter->psFlash2xCSInfo->OffsetISOImage1Part3End!= UNINIT_PTR_IN_CS)
- SectEndOffset = (Adapter->psFlash2xCSInfo->OffsetISOImage1Part3End);
- break;
- case ISO_IMAGE2_PART2 :
- if(Adapter->psFlash2xCSInfo->OffsetISOImage2Part2End != UNINIT_PTR_IN_CS)
- SectEndOffset = (Adapter->psFlash2xCSInfo->OffsetISOImage2Part2End);
- break;
- case ISO_IMAGE2_PART3 :
- if(Adapter->psFlash2xCSInfo->OffsetISOImage2Part3End!= UNINIT_PTR_IN_CS)
- SectEndOffset = (Adapter->psFlash2xCSInfo->OffsetISOImage2Part3End);
- break;
-
- default :
- SectEndOffset = INVALID_OFFSET;
+ break;
+ case CONTROL_SECTION:
+ /* Not Clear So Putting failure. confirm and fix it. */
+ SectEndOffset = STATUS_FAILURE;
+ case ISO_IMAGE1_PART2:
+ if (Adapter->psFlash2xCSInfo->OffsetISOImage1Part2End != UNINIT_PTR_IN_CS)
+ SectEndOffset = (Adapter->psFlash2xCSInfo->OffsetISOImage1Part2End);
+ break;
+ case ISO_IMAGE1_PART3:
+ if (Adapter->psFlash2xCSInfo->OffsetISOImage1Part3End != UNINIT_PTR_IN_CS)
+ SectEndOffset = (Adapter->psFlash2xCSInfo->OffsetISOImage1Part3End);
+ break;
+ case ISO_IMAGE2_PART2:
+ if (Adapter->psFlash2xCSInfo->OffsetISOImage2Part2End != UNINIT_PTR_IN_CS)
+ SectEndOffset = (Adapter->psFlash2xCSInfo->OffsetISOImage2Part2End);
+ break;
+ case ISO_IMAGE2_PART3:
+ if (Adapter->psFlash2xCSInfo->OffsetISOImage2Part3End != UNINIT_PTR_IN_CS)
+ SectEndOffset = (Adapter->psFlash2xCSInfo->OffsetISOImage2Part3End);
+ break;
+ default:
+ SectEndOffset = INVALID_OFFSET;
}
+
return SectEndOffset ;
}
/*
-* BcmFlash2xBulkRead:- Read API for Flash Map 2.x .
-* @Adapter :Driver Private Data Structure
-* @pBuffer : Buffer where data has to be put after reading
-* @eFlashSectionVal :Flash Section Val defined in FLASH2X_SECTION_VAL
-* @uiOffsetWithinSectionVal :- Offset with in provided section
-* @uiNumBytes : Number of Bytes for Read
-*
-* Return value:-
-* return true on success and STATUS_FAILURE on fail.
-*/
-
-INT BcmFlash2xBulkRead(
- PMINI_ADAPTER Adapter,
- PUINT pBuffer,
- FLASH2X_SECTION_VAL eFlash2xSectionVal,
- UINT uiOffsetWithinSectionVal,
- UINT uiNumBytes)
+ * BcmFlash2xBulkRead:- Read API for Flash Map 2.x .
+ * @Adapter :Driver Private Data Structure
+ * @pBuffer : Buffer where data has to be put after reading
+ * @eFlashSectionVal :Flash Section Val defined in FLASH2X_SECTION_VAL
+ * @uiOffsetWithinSectionVal :- Offset with in provided section
+ * @uiNumBytes : Number of Bytes for Read
+ *
+ * Return value:-
+ * return true on success and STATUS_FAILURE on fail.
+ */
+
+int BcmFlash2xBulkRead(struct bcm_mini_adapter *Adapter,
+ PUINT pBuffer,
+ FLASH2X_SECTION_VAL eFlash2xSectionVal,
+ unsigned int uiOffsetWithinSectionVal,
+ unsigned int uiNumBytes)
{
+ int Status = STATUS_SUCCESS;
+ int SectionStartOffset = 0;
+ unsigned int uiAbsoluteOffset = 0;
+ unsigned int uiTemp = 0, value = 0;
- INT Status = STATUS_SUCCESS;
- INT SectionStartOffset = 0;
- UINT uiAbsoluteOffset = 0 ;
- UINT uiTemp =0, value =0 ;
- if(Adapter == NULL)
- {
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Adapter structure is NULL");
+ if (!Adapter) {
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Adapter structure is NULL");
return -EINVAL;
}
- if(Adapter->device_removed )
- {
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Device has been removed");
+ if (Adapter->device_removed) {
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Device has been removed");
return -ENODEV;
}
- //NO_SECTION_VAL means absolute offset is given.
- if(eFlash2xSectionVal == NO_SECTION_VAL)
+ /* NO_SECTION_VAL means absolute offset is given. */
+ if (eFlash2xSectionVal == NO_SECTION_VAL)
SectionStartOffset = 0;
else
- SectionStartOffset = BcmGetSectionValStartOffset(Adapter,eFlash2xSectionVal);
+ SectionStartOffset = BcmGetSectionValStartOffset(Adapter, eFlash2xSectionVal);
- if(SectionStartOffset == STATUS_FAILURE )
- {
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"This Section<%d> does not exixt in Flash 2.x Map ",eFlash2xSectionVal);
+ if (SectionStartOffset == STATUS_FAILURE) {
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "This Section<%d> does not exixt in Flash 2.x Map ", eFlash2xSectionVal);
return -EINVAL;
}
- if(IsSectionExistInVendorInfo(Adapter,eFlash2xSectionVal))
- return vendorextnReadSection(Adapter,(PUCHAR)pBuffer, eFlash2xSectionVal, uiOffsetWithinSectionVal, uiNumBytes);
+ if (IsSectionExistInVendorInfo(Adapter, eFlash2xSectionVal))
+ return vendorextnReadSection(Adapter, (PUCHAR)pBuffer, eFlash2xSectionVal, uiOffsetWithinSectionVal, uiNumBytes);
- //calculating the absolute offset from FLASH;
+ /* calculating the absolute offset from FLASH; */
uiAbsoluteOffset = uiOffsetWithinSectionVal + SectionStartOffset;
rdmalt(Adapter, 0x0f000C80, &uiTemp, sizeof(uiTemp));
value = 0;
- wrmalt(Adapter, 0x0f000C80,&value, sizeof(value));
-
- Status= BeceemFlashBulkRead(Adapter, pBuffer,uiAbsoluteOffset,uiNumBytes) ;
-
+ wrmalt(Adapter, 0x0f000C80, &value, sizeof(value));
+ Status = BeceemFlashBulkRead(Adapter, pBuffer, uiAbsoluteOffset, uiNumBytes);
wrmalt(Adapter, 0x0f000C80, &uiTemp, sizeof(uiTemp));
- if(Status)
- {
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Flash Read Failed with Status :%d", Status);
- return Status ;
+ if (Status) {
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Flash Read Failed with Status :%d", Status);
+ return Status;
}
return Status;
}
/*
-* BcmFlash2xBulkWrite :-API for Writing on the Flash Map 2.x.
-* @Adapter :Driver Private Data Structure
-* @pBuffer : Buffer From where data has to taken for writing
-* @eFlashSectionVal :Flash Section Val defined in FLASH2X_SECTION_VAL
-* @uiOffsetWithinSectionVal :- Offset with in provided section
-* @uiNumBytes : Number of Bytes for Write
-*
-* Return value:-
-* return true on success and STATUS_FAILURE on fail.
-*
-*/
-
-INT BcmFlash2xBulkWrite(
- PMINI_ADAPTER Adapter,
- PUINT pBuffer,
- FLASH2X_SECTION_VAL eFlash2xSectVal,
- UINT uiOffset,
- UINT uiNumBytes,
- UINT bVerify)
+ * BcmFlash2xBulkWrite :-API for Writing on the Flash Map 2.x.
+ * @Adapter :Driver Private Data Structure
+ * @pBuffer : Buffer From where data has to taken for writing
+ * @eFlashSectionVal :Flash Section Val defined in FLASH2X_SECTION_VAL
+ * @uiOffsetWithinSectionVal :- Offset with in provided section
+ * @uiNumBytes : Number of Bytes for Write
+ *
+ * Return value:-
+ * return true on success and STATUS_FAILURE on fail.
+ *
+ */
+
+int BcmFlash2xBulkWrite(struct bcm_mini_adapter *Adapter,
+ PUINT pBuffer,
+ FLASH2X_SECTION_VAL eFlash2xSectVal,
+ unsigned int uiOffset,
+ unsigned int uiNumBytes,
+ unsigned int bVerify)
{
+ int Status = STATUS_SUCCESS;
+ unsigned int FlashSectValStartOffset = 0;
+ unsigned int uiTemp = 0, value = 0;
- INT Status = STATUS_SUCCESS;
- UINT FlashSectValStartOffset = 0;
- UINT uiTemp = 0, value = 0;
- if(Adapter == NULL)
- {
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Adapter structure is NULL");
+ if (!Adapter) {
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Adapter structure is NULL");
return -EINVAL;
}
- if(Adapter->device_removed )
- {
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Device has been removed");
+
+ if (Adapter->device_removed) {
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Device has been removed");
return -ENODEV;
}
- //NO_SECTION_VAL means absolute offset is given.
- if(eFlash2xSectVal == NO_SECTION_VAL)
+ /* NO_SECTION_VAL means absolute offset is given. */
+ if (eFlash2xSectVal == NO_SECTION_VAL)
FlashSectValStartOffset = 0;
else
- FlashSectValStartOffset = BcmGetSectionValStartOffset(Adapter,eFlash2xSectVal);
+ FlashSectValStartOffset = BcmGetSectionValStartOffset(Adapter, eFlash2xSectVal);
- if(FlashSectValStartOffset == STATUS_FAILURE )
- {
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"This Section<%d> does not exixt in Flash Map 2.x",eFlash2xSectVal);
+ if (FlashSectValStartOffset == STATUS_FAILURE) {
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "This Section<%d> does not exixt in Flash Map 2.x", eFlash2xSectVal);
return -EINVAL;
}
- if(IsSectionExistInVendorInfo(Adapter,eFlash2xSectVal))
+ if (IsSectionExistInVendorInfo(Adapter, eFlash2xSectVal))
return vendorextnWriteSection(Adapter, (PUCHAR)pBuffer, eFlash2xSectVal, uiOffset, uiNumBytes, bVerify);
- //calculating the absolute offset from FLASH;
+ /* calculating the absolute offset from FLASH; */
uiOffset = uiOffset + FlashSectValStartOffset;
rdmalt(Adapter, 0x0f000C80, &uiTemp, sizeof(uiTemp));
value = 0;
- wrmalt(Adapter, 0x0f000C80,&value, sizeof(value));
+ wrmalt(Adapter, 0x0f000C80, &value, sizeof(value));
- Status = BeceemFlashBulkWrite(Adapter, pBuffer,uiOffset,uiNumBytes,bVerify);
+ Status = BeceemFlashBulkWrite(Adapter, pBuffer, uiOffset, uiNumBytes, bVerify);
wrmalt(Adapter, 0x0f000C80, &uiTemp, sizeof(uiTemp));
- if(Status)
- {
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Flash Write failed with Status :%d", Status);
- return Status ;
+ if (Status) {
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Flash Write failed with Status :%d", Status);
+ return Status;
}
return Status;
-
}
-/**
-* BcmGetActiveDSD : Set the Active DSD in Adapter Structure which has to be dumped in DDR
-* @Adapter :-Drivers private Data Structure
-*
-* Return Value:-
-* Return STATUS_SUCESS if get success in setting the right DSD else negaive error code
-*
-**/
-static INT BcmGetActiveDSD(PMINI_ADAPTER Adapter)
+/*
+ * BcmGetActiveDSD : Set the Active DSD in Adapter Structure which has to be dumped in DDR
+ * @Adapter :-Drivers private Data Structure
+ *
+ * Return Value:-
+ * Return STATUS_SUCESS if get success in setting the right DSD else negaive error code
+ *
+ */
+
+static int BcmGetActiveDSD(struct bcm_mini_adapter *Adapter)
{
- FLASH2X_SECTION_VAL uiHighestPriDSD = 0 ;
+ FLASH2X_SECTION_VAL uiHighestPriDSD = 0;
uiHighestPriDSD = getHighestPriDSD(Adapter);
Adapter->eActiveDSD = uiHighestPriDSD;
- if(DSD0 == uiHighestPriDSD)
+ if (DSD0 == uiHighestPriDSD)
Adapter->ulFlashCalStart = Adapter->psFlash2xCSInfo->OffsetFromZeroForDSDStart;
- if(DSD1 == uiHighestPriDSD)
+ if (DSD1 == uiHighestPriDSD)
Adapter->ulFlashCalStart = Adapter->psFlash2xCSInfo->OffsetFromZeroForDSD1Start;
- if(DSD2 == uiHighestPriDSD)
+ if (DSD2 == uiHighestPriDSD)
Adapter->ulFlashCalStart = Adapter->psFlash2xCSInfo->OffsetFromZeroForDSD2Start;
- if(Adapter->eActiveDSD)
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "Active DSD :%d", Adapter->eActiveDSD);
- if(Adapter->eActiveDSD == 0)
- {
- //if No DSD gets Active, Make Active the DSD with WR permission
- if(IsSectionWritable(Adapter,DSD2))
- {
+ if (Adapter->eActiveDSD)
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "Active DSD :%d", Adapter->eActiveDSD);
+ if (Adapter->eActiveDSD == 0) {
+ /* if No DSD gets Active, Make Active the DSD with WR permission */
+ if (IsSectionWritable(Adapter, DSD2)) {
Adapter->eActiveDSD = DSD2;
Adapter->ulFlashCalStart = Adapter->psFlash2xCSInfo->OffsetFromZeroForDSD2Start;
- }
- else if(IsSectionWritable(Adapter,DSD1))
- {
+ } else if (IsSectionWritable(Adapter, DSD1)) {
Adapter->eActiveDSD = DSD1;
Adapter->ulFlashCalStart = Adapter->psFlash2xCSInfo->OffsetFromZeroForDSD1Start;
- }
- else if(IsSectionWritable(Adapter,DSD0))
- {
+ } else if (IsSectionWritable(Adapter, DSD0)) {
Adapter->eActiveDSD = DSD0;
Adapter->ulFlashCalStart = Adapter->psFlash2xCSInfo->OffsetFromZeroForDSDStart;
}
@@ -3360,1398 +3001,1230 @@ static INT BcmGetActiveDSD(PMINI_ADAPTER Adapter)
return STATUS_SUCCESS;
}
-
-/**
-* BcmGetActiveISO :- Set the Active ISO in Adapter Data Structue
-* @Adapter : Driver private Data Structure
-*
-* Return Value:-
-* Sucsess:- STATUS_SUCESS
-* Failure- : negative erro code
-*
-**/
-
-static INT BcmGetActiveISO(PMINI_ADAPTER Adapter)
+/*
+ * BcmGetActiveISO :- Set the Active ISO in Adapter Data Structue
+ * @Adapter : Driver private Data Structure
+ *
+ * Return Value:-
+ * Sucsess:- STATUS_SUCESS
+ * Failure- : negative erro code
+ *
+ */
+
+static int BcmGetActiveISO(struct bcm_mini_adapter *Adapter)
{
+ int HighestPriISO = 0;
- INT HighestPriISO = 0 ;
HighestPriISO = getHighestPriISO(Adapter);
- Adapter->eActiveISO = HighestPriISO ;
- if(Adapter->eActiveISO == ISO_IMAGE2)
+ Adapter->eActiveISO = HighestPriISO;
+ if (Adapter->eActiveISO == ISO_IMAGE2)
Adapter->uiActiveISOOffset = (Adapter->psFlash2xCSInfo->OffsetISOImage2Part1Start);
- else if(Adapter->eActiveISO == ISO_IMAGE1)
+ else if (Adapter->eActiveISO == ISO_IMAGE1)
Adapter->uiActiveISOOffset = (Adapter->psFlash2xCSInfo->OffsetISOImage1Part1Start);
- if(Adapter->eActiveISO)
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL,"Active ISO :%x", Adapter->eActiveISO);
+ if (Adapter->eActiveISO)
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "Active ISO :%x", Adapter->eActiveISO);
return STATUS_SUCCESS;
}
-/**
-* IsOffsetWritable :- it will tell the access permission of the sector having passed offset
-* @Adapter : Drivers Private Data Structure
-* @uiOffset : Offset provided in the Flash
-*
-* Return Value:-
-* Success:-TRUE , offset is writable
-* Failure:-FALSE, offset is RO
-*
-**/
-B_UINT8 IsOffsetWritable(PMINI_ADAPTER Adapter, UINT uiOffset)
+/*
+ * IsOffsetWritable :- it will tell the access permission of the sector having passed offset
+ * @Adapter : Drivers Private Data Structure
+ * @uiOffset : Offset provided in the Flash
+ *
+ * Return Value:-
+ * Success:-TRUE , offset is writable
+ * Failure:-FALSE, offset is RO
+ *
+ */
+
+B_UINT8 IsOffsetWritable(struct bcm_mini_adapter *Adapter, unsigned int uiOffset)
{
- UINT uiSectorNum = 0;
- UINT uiWordOfSectorPermission =0;
- UINT uiBitofSectorePermission = 0;
+ unsigned int uiSectorNum = 0;
+ unsigned int uiWordOfSectorPermission = 0;
+ unsigned int uiBitofSectorePermission = 0;
B_UINT32 permissionBits = 0;
+
uiSectorNum = uiOffset/Adapter->uiSectorSize;
- //calculating the word having this Sector Access permission from SectorAccessBitMap Array
- uiWordOfSectorPermission = Adapter->psFlash2xCSInfo->SectorAccessBitMap[uiSectorNum /16];
+ /* calculating the word having this Sector Access permission from SectorAccessBitMap Array */
+ uiWordOfSectorPermission = Adapter->psFlash2xCSInfo->SectorAccessBitMap[uiSectorNum / 16];
- //calculating the bit index inside the word for this sector
- uiBitofSectorePermission = 2*(15 - uiSectorNum %16);
+ /* calculating the bit index inside the word for this sector */
+ uiBitofSectorePermission = 2 * (15 - uiSectorNum % 16);
- //Setting Access permission
- permissionBits = uiWordOfSectorPermission & (0x3 << uiBitofSectorePermission) ;
+ /* Setting Access permission */
+ permissionBits = uiWordOfSectorPermission & (0x3 << uiBitofSectorePermission);
permissionBits = (permissionBits >> uiBitofSectorePermission) & 0x3;
- if(permissionBits == SECTOR_READWRITE_PERMISSION)
- return TRUE;
+ if (permissionBits == SECTOR_READWRITE_PERMISSION)
+ return TRUE;
else
return FALSE;
}
-static INT BcmDumpFlash2xSectionBitMap(PFLASH2X_BITMAP psFlash2xBitMap)
+static int BcmDumpFlash2xSectionBitMap(PFLASH2X_BITMAP psFlash2xBitMap)
{
- PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev);
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "***************Flash 2.x Section Bitmap***************");
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL,"ISO_IMAGE1 :0X%x", psFlash2xBitMap->ISO_IMAGE1);
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL,"ISO_IMAGE2 :0X%x", psFlash2xBitMap->ISO_IMAGE2);
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL,"DSD0 :0X%x", psFlash2xBitMap->DSD0);
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL,"DSD1 :0X%x", psFlash2xBitMap->DSD1);
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL,"DSD2 :0X%x", psFlash2xBitMap->DSD2);
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL,"VSA0 :0X%x", psFlash2xBitMap->VSA0);
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL,"VSA1 :0X%x", psFlash2xBitMap->VSA1);
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL,"VSA2 :0X%x", psFlash2xBitMap->VSA2);
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL,"SCSI :0X%x", psFlash2xBitMap->SCSI);
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL,"CONTROL_SECTION :0X%x", psFlash2xBitMap->CONTROL_SECTION);
+ struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev);
+
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "***************Flash 2.x Section Bitmap***************");
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "ISO_IMAGE1 :0X%x", psFlash2xBitMap->ISO_IMAGE1);
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "ISO_IMAGE2 :0X%x", psFlash2xBitMap->ISO_IMAGE2);
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "DSD0 :0X%x", psFlash2xBitMap->DSD0);
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "DSD1 :0X%x", psFlash2xBitMap->DSD1);
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "DSD2 :0X%x", psFlash2xBitMap->DSD2);
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "VSA0 :0X%x", psFlash2xBitMap->VSA0);
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "VSA1 :0X%x", psFlash2xBitMap->VSA1);
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "VSA2 :0X%x", psFlash2xBitMap->VSA2);
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "SCSI :0X%x", psFlash2xBitMap->SCSI);
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "CONTROL_SECTION :0X%x", psFlash2xBitMap->CONTROL_SECTION);
return STATUS_SUCCESS;
}
-/**
-* BcmGetFlash2xSectionalBitMap :- It will provide the bit map of all the section present in Flash
-* 8bit has been assigned to every section.
- bit[0] :Section present or not
- bit[1] :section is valid or not
- bit[2] : Secton is read only or has write permission too.
- bit[3] : Active Section -
- bit[7...4] = Reserved .
-
- @Adapter:-Driver private Data Structure
-*
-* Return value:-
-* Success:- STATUS_SUCESS
-* Failure:- negative error code
-**/
-
-INT BcmGetFlash2xSectionalBitMap(PMINI_ADAPTER Adapter, PFLASH2X_BITMAP psFlash2xBitMap)
+/*
+ * BcmGetFlash2xSectionalBitMap :- It will provide the bit map of all the section present in Flash
+ * 8bit has been assigned to every section.
+ * bit[0] :Section present or not
+ * bit[1] :section is valid or not
+ * bit[2] : Secton is read only or has write permission too.
+ * bit[3] : Active Section -
+ * bit[7...4] = Reserved .
+ *
+ * @Adapter:-Driver private Data Structure
+ *
+ * Return value:-
+ * Success:- STATUS_SUCESS
+ * Failure:- negative error code
+ */
+
+int BcmGetFlash2xSectionalBitMap(struct bcm_mini_adapter *Adapter, PFLASH2X_BITMAP psFlash2xBitMap)
{
-
-
PFLASH2X_CS_INFO psFlash2xCSInfo = Adapter->psFlash2xCSInfo;
- FLASH2X_SECTION_VAL uiHighestPriDSD = 0 ;
- FLASH2X_SECTION_VAL uiHighestPriISO= 0 ;
- BOOLEAN SetActiveDSDDone = FALSE ;
- BOOLEAN SetActiveISODone = FALSE ;
-
- //For 1.x map all the section except DSD0 will be shown as not present
- //This part will be used by calibration tool to detect the number of DSD present in Flash.
- if(IsFlash2x(Adapter) == FALSE)
- {
+ FLASH2X_SECTION_VAL uiHighestPriDSD = 0;
+ FLASH2X_SECTION_VAL uiHighestPriISO = 0;
+ BOOLEAN SetActiveDSDDone = FALSE;
+ BOOLEAN SetActiveISODone = FALSE;
+
+ /* For 1.x map all the section except DSD0 will be shown as not present
+ * This part will be used by calibration tool to detect the number of DSD present in Flash.
+ */
+ if (IsFlash2x(Adapter) == FALSE) {
psFlash2xBitMap->ISO_IMAGE2 = 0;
psFlash2xBitMap->ISO_IMAGE1 = 0;
- psFlash2xBitMap->DSD0 = FLASH2X_SECTION_VALID | FLASH2X_SECTION_ACT | FLASH2X_SECTION_PRESENT; //0xF; //0000(Reseved)1(Active)0(RW)1(valid)1(present)
- psFlash2xBitMap->DSD1 = 0 ;
- psFlash2xBitMap->DSD2 = 0 ;
- psFlash2xBitMap->VSA0 = 0 ;
- psFlash2xBitMap->VSA1 = 0 ;
- psFlash2xBitMap->VSA2 = 0 ;
- psFlash2xBitMap->CONTROL_SECTION = 0 ;
- psFlash2xBitMap->SCSI= 0 ;
- psFlash2xBitMap->Reserved0 = 0 ;
- psFlash2xBitMap->Reserved1 = 0 ;
- psFlash2xBitMap->Reserved2 = 0 ;
- return STATUS_SUCCESS ;
+ psFlash2xBitMap->DSD0 = FLASH2X_SECTION_VALID | FLASH2X_SECTION_ACT | FLASH2X_SECTION_PRESENT; /* 0xF; 0000(Reseved)1(Active)0(RW)1(valid)1(present) */
+ psFlash2xBitMap->DSD1 = 0;
+ psFlash2xBitMap->DSD2 = 0;
+ psFlash2xBitMap->VSA0 = 0;
+ psFlash2xBitMap->VSA1 = 0;
+ psFlash2xBitMap->VSA2 = 0;
+ psFlash2xBitMap->CONTROL_SECTION = 0;
+ psFlash2xBitMap->SCSI = 0;
+ psFlash2xBitMap->Reserved0 = 0;
+ psFlash2xBitMap->Reserved1 = 0;
+ psFlash2xBitMap->Reserved2 = 0;
+ return STATUS_SUCCESS;
}
uiHighestPriDSD = getHighestPriDSD(Adapter);
uiHighestPriISO = getHighestPriISO(Adapter);
- ///
- // IS0 IMAGE 2
- ///
- if((psFlash2xCSInfo->OffsetISOImage2Part1Start) != UNINIT_PTR_IN_CS)
- {
- //Setting the 0th Bit representing the Section is present or not.
- psFlash2xBitMap->ISO_IMAGE2= psFlash2xBitMap->ISO_IMAGE2 | FLASH2X_SECTION_PRESENT;
-
+ /*
+ * IS0 IMAGE 2
+ */
+ if ((psFlash2xCSInfo->OffsetISOImage2Part1Start) != UNINIT_PTR_IN_CS) {
+ /* Setting the 0th Bit representing the Section is present or not. */
+ psFlash2xBitMap->ISO_IMAGE2 = psFlash2xBitMap->ISO_IMAGE2 | FLASH2X_SECTION_PRESENT;
- if(ReadISOSignature(Adapter,ISO_IMAGE2)== ISO_IMAGE_MAGIC_NUMBER)
+ if (ReadISOSignature(Adapter, ISO_IMAGE2) == ISO_IMAGE_MAGIC_NUMBER)
psFlash2xBitMap->ISO_IMAGE2 |= FLASH2X_SECTION_VALID;
-
- //Calculation for extrating the Access permission
- if(IsSectionWritable(Adapter, ISO_IMAGE2) == FALSE)
+ /* Calculation for extrating the Access permission */
+ if (IsSectionWritable(Adapter, ISO_IMAGE2) == FALSE)
psFlash2xBitMap->ISO_IMAGE2 |= FLASH2X_SECTION_RO;
- if(SetActiveISODone == FALSE && uiHighestPriISO == ISO_IMAGE2)
- {
- psFlash2xBitMap->ISO_IMAGE2 |= FLASH2X_SECTION_ACT ;
+ if (SetActiveISODone == FALSE && uiHighestPriISO == ISO_IMAGE2) {
+ psFlash2xBitMap->ISO_IMAGE2 |= FLASH2X_SECTION_ACT;
SetActiveISODone = TRUE;
}
-
}
- ///
- // IS0 IMAGE 1
- ///
- if((psFlash2xCSInfo->OffsetISOImage1Part1Start) != UNINIT_PTR_IN_CS)
- {
- //Setting the 0th Bit representing the Section is present or not.
+ /*
+ * IS0 IMAGE 1
+ */
+ if ((psFlash2xCSInfo->OffsetISOImage1Part1Start) != UNINIT_PTR_IN_CS) {
+ /* Setting the 0th Bit representing the Section is present or not. */
psFlash2xBitMap->ISO_IMAGE1 = psFlash2xBitMap->ISO_IMAGE1 | FLASH2X_SECTION_PRESENT;
- if(ReadISOSignature(Adapter,ISO_IMAGE1) == ISO_IMAGE_MAGIC_NUMBER)
+ if (ReadISOSignature(Adapter, ISO_IMAGE1) == ISO_IMAGE_MAGIC_NUMBER)
psFlash2xBitMap->ISO_IMAGE1 |= FLASH2X_SECTION_VALID;
- // Calculation for extrating the Access permission
- if(IsSectionWritable(Adapter, ISO_IMAGE1) == FALSE)
+ /* Calculation for extrating the Access permission */
+ if (IsSectionWritable(Adapter, ISO_IMAGE1) == FALSE)
psFlash2xBitMap->ISO_IMAGE1 |= FLASH2X_SECTION_RO;
- if(SetActiveISODone == FALSE && uiHighestPriISO == ISO_IMAGE1)
- {
- psFlash2xBitMap->ISO_IMAGE1 |= FLASH2X_SECTION_ACT ;
+ if (SetActiveISODone == FALSE && uiHighestPriISO == ISO_IMAGE1) {
+ psFlash2xBitMap->ISO_IMAGE1 |= FLASH2X_SECTION_ACT;
SetActiveISODone = TRUE;
}
}
+ /*
+ * DSD2
+ */
+ if ((psFlash2xCSInfo->OffsetFromZeroForDSD2Start) != UNINIT_PTR_IN_CS) {
+ /* Setting the 0th Bit representing the Section is present or not. */
+ psFlash2xBitMap->DSD2 = psFlash2xBitMap->DSD2 | FLASH2X_SECTION_PRESENT;
-
- ///
- // DSD2
- ///
- if((psFlash2xCSInfo->OffsetFromZeroForDSD2Start) != UNINIT_PTR_IN_CS)
- {
- //Setting the 0th Bit representing the Section is present or not.
- psFlash2xBitMap->DSD2= psFlash2xBitMap->DSD2 | FLASH2X_SECTION_PRESENT;
-
- if(ReadDSDSignature(Adapter,DSD2)== DSD_IMAGE_MAGIC_NUMBER)
+ if (ReadDSDSignature(Adapter, DSD2) == DSD_IMAGE_MAGIC_NUMBER)
psFlash2xBitMap->DSD2 |= FLASH2X_SECTION_VALID;
- //Calculation for extrating the Access permission
- if(IsSectionWritable(Adapter, DSD2) == FALSE)
- {
+ /* Calculation for extrating the Access permission */
+ if (IsSectionWritable(Adapter, DSD2) == FALSE) {
psFlash2xBitMap->DSD2 |= FLASH2X_SECTION_RO;
-
- }
- else
- {
- //Means section is writable
- if((SetActiveDSDDone == FALSE) && (uiHighestPriDSD == DSD2))
- {
- psFlash2xBitMap->DSD2 |= FLASH2X_SECTION_ACT ;
- SetActiveDSDDone =TRUE ;
+ } else {
+ /* Means section is writable */
+ if ((SetActiveDSDDone == FALSE) && (uiHighestPriDSD == DSD2)) {
+ psFlash2xBitMap->DSD2 |= FLASH2X_SECTION_ACT;
+ SetActiveDSDDone = TRUE;
}
}
}
- ///
- // DSD 1
- ///
- if((psFlash2xCSInfo->OffsetFromZeroForDSD1Start) != UNINIT_PTR_IN_CS)
- {
- //Setting the 0th Bit representing the Section is present or not.
- psFlash2xBitMap->DSD1= psFlash2xBitMap->DSD1 | FLASH2X_SECTION_PRESENT;
-
+ /*
+ * DSD 1
+ */
+ if ((psFlash2xCSInfo->OffsetFromZeroForDSD1Start) != UNINIT_PTR_IN_CS) {
+ /* Setting the 0th Bit representing the Section is present or not. */
+ psFlash2xBitMap->DSD1 = psFlash2xBitMap->DSD1 | FLASH2X_SECTION_PRESENT;
- if(ReadDSDSignature(Adapter,DSD1)== DSD_IMAGE_MAGIC_NUMBER)
+ if (ReadDSDSignature(Adapter, DSD1) == DSD_IMAGE_MAGIC_NUMBER)
psFlash2xBitMap->DSD1 |= FLASH2X_SECTION_VALID;
- //Calculation for extrating the Access permission
- if(IsSectionWritable(Adapter, DSD1) == FALSE)
- {
+ /* Calculation for extrating the Access permission */
+ if (IsSectionWritable(Adapter, DSD1) == FALSE) {
psFlash2xBitMap->DSD1 |= FLASH2X_SECTION_RO;
- }
- else
- {
- //Means section is writable
- if((SetActiveDSDDone == FALSE) && (uiHighestPriDSD == DSD1))
- {
- psFlash2xBitMap->DSD1 |= FLASH2X_SECTION_ACT ;
- SetActiveDSDDone =TRUE ;
+ } else {
+ /* Means section is writable */
+ if ((SetActiveDSDDone == FALSE) && (uiHighestPriDSD == DSD1)) {
+ psFlash2xBitMap->DSD1 |= FLASH2X_SECTION_ACT;
+ SetActiveDSDDone = TRUE;
}
}
-
}
- ///
- //For DSD 0
- //
- if((psFlash2xCSInfo->OffsetFromZeroForDSDStart) != UNINIT_PTR_IN_CS)
- {
- //Setting the 0th Bit representing the Section is present or not.
+ /*
+ * For DSD 0
+ */
+ if ((psFlash2xCSInfo->OffsetFromZeroForDSDStart) != UNINIT_PTR_IN_CS) {
+ /* Setting the 0th Bit representing the Section is present or not. */
psFlash2xBitMap->DSD0 = psFlash2xBitMap->DSD0 | FLASH2X_SECTION_PRESENT;
- if(ReadDSDSignature(Adapter,DSD0) == DSD_IMAGE_MAGIC_NUMBER)
+ if (ReadDSDSignature(Adapter, DSD0) == DSD_IMAGE_MAGIC_NUMBER)
psFlash2xBitMap->DSD0 |= FLASH2X_SECTION_VALID;
- //Setting Access permission
- if(IsSectionWritable(Adapter, DSD0) == FALSE)
- {
+ /* Setting Access permission */
+ if (IsSectionWritable(Adapter, DSD0) == FALSE) {
psFlash2xBitMap->DSD0 |= FLASH2X_SECTION_RO;
- }
- else
- {
- //Means section is writable
- if((SetActiveDSDDone == FALSE) &&(uiHighestPriDSD == DSD0))
- {
- psFlash2xBitMap->DSD0 |= FLASH2X_SECTION_ACT ;
- SetActiveDSDDone =TRUE ;
+ } else {
+ /* Means section is writable */
+ if ((SetActiveDSDDone == FALSE) && (uiHighestPriDSD == DSD0)) {
+ psFlash2xBitMap->DSD0 |= FLASH2X_SECTION_ACT;
+ SetActiveDSDDone = TRUE;
}
}
}
- ///
- // VSA 0
- ///
- if((psFlash2xCSInfo->OffsetFromZeroForVSAStart) != UNINIT_PTR_IN_CS)
- {
- //Setting the 0th Bit representing the Section is present or not.
- psFlash2xBitMap->VSA0= psFlash2xBitMap->VSA0 | FLASH2X_SECTION_PRESENT;
+ /*
+ * VSA 0
+ */
+ if ((psFlash2xCSInfo->OffsetFromZeroForVSAStart) != UNINIT_PTR_IN_CS) {
+ /* Setting the 0th Bit representing the Section is present or not. */
+ psFlash2xBitMap->VSA0 = psFlash2xBitMap->VSA0 | FLASH2X_SECTION_PRESENT;
- //Setting the Access Bit. Map is not defined hece setting it always valid
+ /* Setting the Access Bit. Map is not defined hece setting it always valid */
psFlash2xBitMap->VSA0 |= FLASH2X_SECTION_VALID;
- //Calculation for extrating the Access permission
- if(IsSectionWritable(Adapter, VSA0) == FALSE)
+ /* Calculation for extrating the Access permission */
+ if (IsSectionWritable(Adapter, VSA0) == FALSE)
psFlash2xBitMap->VSA0 |= FLASH2X_SECTION_RO;
- //By Default section is Active
- psFlash2xBitMap->VSA0 |= FLASH2X_SECTION_ACT ;
-
+ /* By Default section is Active */
+ psFlash2xBitMap->VSA0 |= FLASH2X_SECTION_ACT;
}
+ /*
+ * VSA 1
+ */
+ if ((psFlash2xCSInfo->OffsetFromZeroForVSA1Start) != UNINIT_PTR_IN_CS) {
+ /* Setting the 0th Bit representing the Section is present or not. */
+ psFlash2xBitMap->VSA1 = psFlash2xBitMap->VSA1 | FLASH2X_SECTION_PRESENT;
- ///
- // VSA 1
- ///
-
- if((psFlash2xCSInfo->OffsetFromZeroForVSA1Start) != UNINIT_PTR_IN_CS)
- {
- //Setting the 0th Bit representing the Section is present or not.
- psFlash2xBitMap->VSA1= psFlash2xBitMap->VSA1 | FLASH2X_SECTION_PRESENT;
-
- //Setting the Access Bit. Map is not defined hece setting it always valid
- psFlash2xBitMap->VSA1|= FLASH2X_SECTION_VALID;
+ /* Setting the Access Bit. Map is not defined hece setting it always valid */
+ psFlash2xBitMap->VSA1 |= FLASH2X_SECTION_VALID;
- //Checking For Access permission
- if(IsSectionWritable(Adapter, VSA1) == FALSE)
+ /* Checking For Access permission */
+ if (IsSectionWritable(Adapter, VSA1) == FALSE)
psFlash2xBitMap->VSA1 |= FLASH2X_SECTION_RO;
- //By Default section is Active
- psFlash2xBitMap->VSA1 |= FLASH2X_SECTION_ACT ;
-
+ /* By Default section is Active */
+ psFlash2xBitMap->VSA1 |= FLASH2X_SECTION_ACT;
}
+ /*
+ * VSA 2
+ */
+ if ((psFlash2xCSInfo->OffsetFromZeroForVSA2Start) != UNINIT_PTR_IN_CS) {
+ /* Setting the 0th Bit representing the Section is present or not. */
+ psFlash2xBitMap->VSA2 = psFlash2xBitMap->VSA2 | FLASH2X_SECTION_PRESENT;
- ///
- // VSA 2
- ///
-
- if((psFlash2xCSInfo->OffsetFromZeroForVSA2Start) != UNINIT_PTR_IN_CS)
- {
- //Setting the 0th Bit representing the Section is present or not.
- psFlash2xBitMap->VSA2= psFlash2xBitMap->VSA2 | FLASH2X_SECTION_PRESENT;
-
-
- //Setting the Access Bit. Map is not defined hece setting it always valid
+ /* Setting the Access Bit. Map is not defined hece setting it always valid */
psFlash2xBitMap->VSA2 |= FLASH2X_SECTION_VALID;
- //Checking For Access permission
- if(IsSectionWritable(Adapter, VSA2) == FALSE)
+ /* Checking For Access permission */
+ if (IsSectionWritable(Adapter, VSA2) == FALSE)
psFlash2xBitMap->VSA2 |= FLASH2X_SECTION_RO;
- //By Default section is Active
- psFlash2xBitMap->VSA2 |= FLASH2X_SECTION_ACT ;
+ /* By Default section is Active */
+ psFlash2xBitMap->VSA2 |= FLASH2X_SECTION_ACT;
}
- ///
- // SCSI Section
- ///
- if((psFlash2xCSInfo->OffsetFromZeroForScsiFirmware) != UNINIT_PTR_IN_CS)
- {
- //Setting the 0th Bit representing the Section is present or not.
- psFlash2xBitMap->SCSI= psFlash2xBitMap->SCSI | FLASH2X_SECTION_PRESENT;
-
+ /*
+ * SCSI Section
+ */
+ if ((psFlash2xCSInfo->OffsetFromZeroForScsiFirmware) != UNINIT_PTR_IN_CS) {
+ /* Setting the 0th Bit representing the Section is present or not. */
+ psFlash2xBitMap->SCSI = psFlash2xBitMap->SCSI | FLASH2X_SECTION_PRESENT;
- //Setting the Access Bit. Map is not defined hece setting it always valid
- psFlash2xBitMap->SCSI|= FLASH2X_SECTION_VALID;
+ /* Setting the Access Bit. Map is not defined hece setting it always valid */
+ psFlash2xBitMap->SCSI |= FLASH2X_SECTION_VALID;
- //Checking For Access permission
- if(IsSectionWritable(Adapter, SCSI) == FALSE)
+ /* Checking For Access permission */
+ if (IsSectionWritable(Adapter, SCSI) == FALSE)
psFlash2xBitMap->SCSI |= FLASH2X_SECTION_RO;
- //By Default section is Active
- psFlash2xBitMap->SCSI |= FLASH2X_SECTION_ACT ;
-
+ /* By Default section is Active */
+ psFlash2xBitMap->SCSI |= FLASH2X_SECTION_ACT;
}
-
- ///
- // Control Section
- ///
- if((psFlash2xCSInfo->OffsetFromZeroForControlSectionStart) != UNINIT_PTR_IN_CS)
- {
- //Setting the 0th Bit representing the Section is present or not.
+ /*
+ * Control Section
+ */
+ if ((psFlash2xCSInfo->OffsetFromZeroForControlSectionStart) != UNINIT_PTR_IN_CS) {
+ /* Setting the 0th Bit representing the Section is present or not. */
psFlash2xBitMap->CONTROL_SECTION = psFlash2xBitMap->CONTROL_SECTION | (FLASH2X_SECTION_PRESENT);
-
- //Setting the Access Bit. Map is not defined hece setting it always valid
+ /* Setting the Access Bit. Map is not defined hece setting it always valid */
psFlash2xBitMap->CONTROL_SECTION |= FLASH2X_SECTION_VALID;
- //Checking For Access permission
- if(IsSectionWritable(Adapter, CONTROL_SECTION) == FALSE)
+ /* Checking For Access permission */
+ if (IsSectionWritable(Adapter, CONTROL_SECTION) == FALSE)
psFlash2xBitMap->CONTROL_SECTION |= FLASH2X_SECTION_RO;
- //By Default section is Active
- psFlash2xBitMap->CONTROL_SECTION |= FLASH2X_SECTION_ACT ;
-
+ /* By Default section is Active */
+ psFlash2xBitMap->CONTROL_SECTION |= FLASH2X_SECTION_ACT;
}
- ///
- // For Reserved Sections
- ///
+ /*
+ * For Reserved Sections
+ */
psFlash2xBitMap->Reserved0 = 0;
psFlash2xBitMap->Reserved0 = 0;
psFlash2xBitMap->Reserved0 = 0;
-
BcmDumpFlash2xSectionBitMap(psFlash2xBitMap);
- return STATUS_SUCCESS ;
-
+ return STATUS_SUCCESS;
}
-/**
-BcmSetActiveSection :- Set Active section is used to make priority field highest over other
- section of same type.
-
-@Adapater :- Bcm Driver Private Data Structure
-@eFlash2xSectionVal :- Flash section val whose priority has to be made highest.
-
-Return Value:- Make the priorit highest else return erorr code
-**/
-INT BcmSetActiveSection(PMINI_ADAPTER Adapter, FLASH2X_SECTION_VAL eFlash2xSectVal)
+/*
+ * BcmSetActiveSection :- Set Active section is used to make priority field highest over other
+ * section of same type.
+ *
+ * @Adapater :- Bcm Driver Private Data Structure
+ * @eFlash2xSectionVal :- Flash section val whose priority has to be made highest.
+ *
+ * Return Value:- Make the priorit highest else return erorr code
+ *
+ */
+
+int BcmSetActiveSection(struct bcm_mini_adapter *Adapter, FLASH2X_SECTION_VAL eFlash2xSectVal)
{
unsigned int SectImagePriority = 0;
- INT Status =STATUS_SUCCESS;
-
- //DSD_HEADER sDSD = {0};
- //ISO_HEADER sISO = {0};
- INT HighestPriDSD = 0 ;
- INT HighestPriISO = 0;
-
+ int Status = STATUS_SUCCESS;
+ /* DSD_HEADER sDSD = {0};
+ * ISO_HEADER sISO = {0};
+ */
+ int HighestPriDSD = 0 ;
+ int HighestPriISO = 0;
- Status = IsSectionWritable(Adapter,eFlash2xSectVal) ;
- if(Status != TRUE )
- {
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Provided Section <%d> is not writable",eFlash2xSectVal);
+ Status = IsSectionWritable(Adapter, eFlash2xSectVal);
+ if (Status != TRUE) {
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Provided Section <%d> is not writable", eFlash2xSectVal);
return STATUS_FAILURE;
}
- Adapter->bHeaderChangeAllowed = TRUE ;
- switch(eFlash2xSectVal)
- {
- case ISO_IMAGE1 :
- case ISO_IMAGE2 :
- if(ReadISOSignature(Adapter,eFlash2xSectVal)== ISO_IMAGE_MAGIC_NUMBER )
- {
- HighestPriISO = getHighestPriISO(Adapter);
+ Adapter->bHeaderChangeAllowed = TRUE;
+ switch (eFlash2xSectVal) {
+ case ISO_IMAGE1:
+ case ISO_IMAGE2:
+ if (ReadISOSignature(Adapter, eFlash2xSectVal) == ISO_IMAGE_MAGIC_NUMBER) {
+ HighestPriISO = getHighestPriISO(Adapter);
+
+ if (HighestPriISO == eFlash2xSectVal) {
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "Given ISO<%x> already has highest priority", eFlash2xSectVal);
+ Status = STATUS_SUCCESS;
+ break;
+ }
+
+ SectImagePriority = ReadISOPriority(Adapter, HighestPriISO) + 1;
- if(HighestPriISO == eFlash2xSectVal )
- {
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL,"Given ISO<%x> already has highest priority",eFlash2xSectVal );
- Status = STATUS_SUCCESS ;
+ if ((SectImagePriority <= 0) && IsSectionWritable(Adapter, HighestPriISO)) {
+ /* This is a SPECIAL Case which will only happen if the current highest priority ISO has priority value = 0x7FFFFFFF.
+ * We will write 1 to the current Highest priority ISO And then shall increase the priority of the requested ISO
+ * by user
+ */
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "SectImagePriority wraparound happened, eFlash2xSectVal: 0x%x\n", eFlash2xSectVal);
+ SectImagePriority = htonl(0x1);
+ Status = BcmFlash2xBulkWrite(Adapter,
+ &SectImagePriority,
+ HighestPriISO,
+ 0 + FIELD_OFFSET_IN_HEADER(PISO_HEADER, ISOImagePriority),
+ SIGNATURE_SIZE,
+ TRUE);
+ if (Status) {
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Priority has not been written properly");
+ Status = STATUS_FAILURE;
break;
}
- SectImagePriority = ReadISOPriority(Adapter, HighestPriISO) + 1;
-
- if((SectImagePriority <= 0) && IsSectionWritable(Adapter,HighestPriISO))
- {
- // This is a SPECIAL Case which will only happen if the current highest priority ISO has priority value = 0x7FFFFFFF.
- // We will write 1 to the current Highest priority ISO And then shall increase the priority of the requested ISO
- // by user
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "SectImagePriority wraparound happened, eFlash2xSectVal: 0x%x\n",eFlash2xSectVal);
- SectImagePriority = htonl(0x1);
- Status = BcmFlash2xBulkWrite(Adapter,
- &SectImagePriority,
- HighestPriISO,
- 0 + FIELD_OFFSET_IN_HEADER(PISO_HEADER, ISOImagePriority),
- SIGNATURE_SIZE,
- TRUE);
-
- if(Status)
- {
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Priority has not been written properly");
- Status = STATUS_FAILURE;
- break ;
- }
-
- HighestPriISO = getHighestPriISO(Adapter);
-
- if(HighestPriISO == eFlash2xSectVal )
- {
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL,"Given ISO<%x> already has highest priority",eFlash2xSectVal );
- Status = STATUS_SUCCESS ;
- break;
- }
+ HighestPriISO = getHighestPriISO(Adapter);
- SectImagePriority = 2;
- }
+ if (HighestPriISO == eFlash2xSectVal) {
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "Given ISO<%x> already has highest priority", eFlash2xSectVal);
+ Status = STATUS_SUCCESS;
+ break;
+ }
+ SectImagePriority = 2;
+ }
- SectImagePriority = htonl(SectImagePriority);
+ SectImagePriority = htonl(SectImagePriority);
- Status = BcmFlash2xBulkWrite(Adapter,
- &SectImagePriority,
- eFlash2xSectVal,
- 0 + FIELD_OFFSET_IN_HEADER(PISO_HEADER, ISOImagePriority),
- SIGNATURE_SIZE,
- TRUE);
- if(Status)
- {
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Priority has not been written properly");
- break ;
- }
- }
- else
- {
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Signature is currupted. Hence can't increase the priority");
- Status = STATUS_FAILURE ;
+ Status = BcmFlash2xBulkWrite(Adapter,
+ &SectImagePriority,
+ eFlash2xSectVal,
+ 0 + FIELD_OFFSET_IN_HEADER(PISO_HEADER, ISOImagePriority),
+ SIGNATURE_SIZE,
+ TRUE);
+ if (Status) {
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Priority has not been written properly");
break;
}
+ } else {
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Signature is currupted. Hence can't increase the priority");
+ Status = STATUS_FAILURE;
break;
- case DSD0 :
- case DSD1 :
- case DSD2 :
- if(ReadDSDSignature(Adapter,eFlash2xSectVal)== DSD_IMAGE_MAGIC_NUMBER)
- {
- HighestPriDSD = getHighestPriDSD(Adapter);
+ }
+ break;
+ case DSD0:
+ case DSD1:
+ case DSD2:
+ if (ReadDSDSignature(Adapter, eFlash2xSectVal) == DSD_IMAGE_MAGIC_NUMBER) {
+ HighestPriDSD = getHighestPriDSD(Adapter);
+ if ((HighestPriDSD == eFlash2xSectVal)) {
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "Given DSD<%x> already has highest priority", eFlash2xSectVal);
+ Status = STATUS_SUCCESS;
+ break;
+ }
+
+ SectImagePriority = ReadDSDPriority(Adapter, HighestPriDSD) + 1;
+ if (SectImagePriority <= 0) {
+ /* This is a SPECIAL Case which will only happen if the current highest priority DSD has priority value = 0x7FFFFFFF.
+ * We will write 1 to the current Highest priority DSD And then shall increase the priority of the requested DSD
+ * by user
+ */
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, NVM_RW, DBG_LVL_ALL, "SectImagePriority wraparound happened, eFlash2xSectVal: 0x%x\n", eFlash2xSectVal);
+ SectImagePriority = htonl(0x1);
- if((HighestPriDSD == eFlash2xSectVal))
- {
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL,"Given DSD<%x> already has highest priority", eFlash2xSectVal);
- Status = STATUS_SUCCESS ;
+ Status = BcmFlash2xBulkWrite(Adapter,
+ &SectImagePriority,
+ HighestPriDSD,
+ Adapter->psFlash2xCSInfo->OffsetFromDSDStartForDSDHeader + FIELD_OFFSET_IN_HEADER(PDSD_HEADER, DSDImagePriority),
+ SIGNATURE_SIZE,
+ TRUE);
+ if (Status) {
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Priority has not been written properly");
break;
}
- SectImagePriority = ReadDSDPriority(Adapter, HighestPriDSD) + 1 ;
- if(SectImagePriority <= 0)
- {
- // This is a SPECIAL Case which will only happen if the current highest priority DSD has priority value = 0x7FFFFFFF.
- // We will write 1 to the current Highest priority DSD And then shall increase the priority of the requested DSD
- // by user
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, NVM_RW, DBG_LVL_ALL, "SectImagePriority wraparound happened, eFlash2xSectVal: 0x%x\n",eFlash2xSectVal);
- SectImagePriority = htonl(0x1);
-
- Status = BcmFlash2xBulkWrite(Adapter,
- &SectImagePriority,
- HighestPriDSD,
- Adapter->psFlash2xCSInfo->OffsetFromDSDStartForDSDHeader + FIELD_OFFSET_IN_HEADER(PDSD_HEADER, DSDImagePriority),
- SIGNATURE_SIZE,
- TRUE);
-
- if(Status)
- {
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Priority has not been written properly");
- break ;
- }
-
- HighestPriDSD = getHighestPriDSD(Adapter);
-
- if((HighestPriDSD == eFlash2xSectVal))
- {
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL,"Made the DSD: %x highest by reducing priority of other\n", eFlash2xSectVal);
- Status = STATUS_SUCCESS ;
- break;
- }
-
- SectImagePriority = htonl(0x2);
- Status = BcmFlash2xBulkWrite(Adapter,
- &SectImagePriority,
- HighestPriDSD,
- Adapter->psFlash2xCSInfo->OffsetFromDSDStartForDSDHeader + FIELD_OFFSET_IN_HEADER(PDSD_HEADER, DSDImagePriority),
- SIGNATURE_SIZE,
- TRUE);
-
- if(Status)
- {
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Priority has not been written properly");
- break ;
- }
-
- HighestPriDSD = getHighestPriDSD(Adapter);
-
- if((HighestPriDSD == eFlash2xSectVal))
- {
- Status = STATUS_SUCCESS ;
- break;
- }
- SectImagePriority = 3 ;
+ HighestPriDSD = getHighestPriDSD(Adapter);
+ if ((HighestPriDSD == eFlash2xSectVal)) {
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "Made the DSD: %x highest by reducing priority of other\n", eFlash2xSectVal);
+ Status = STATUS_SUCCESS;
+ break;
}
- SectImagePriority = htonl(SectImagePriority);
+
+ SectImagePriority = htonl(0x2);
Status = BcmFlash2xBulkWrite(Adapter,
- &SectImagePriority,
- eFlash2xSectVal,
- Adapter->psFlash2xCSInfo->OffsetFromDSDStartForDSDHeader + FIELD_OFFSET_IN_HEADER(PDSD_HEADER, DSDImagePriority),
- SIGNATURE_SIZE ,
- TRUE);
- if(Status)
- {
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Priority has not been written properly");
- Status = STATUS_FAILURE ;
- break ;
+ &SectImagePriority,
+ HighestPriDSD,
+ Adapter->psFlash2xCSInfo->OffsetFromDSDStartForDSDHeader + FIELD_OFFSET_IN_HEADER(PDSD_HEADER, DSDImagePriority),
+ SIGNATURE_SIZE,
+ TRUE);
+ if (Status) {
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Priority has not been written properly");
+ break;
}
+
+ HighestPriDSD = getHighestPriDSD(Adapter);
+ if ((HighestPriDSD == eFlash2xSectVal)) {
+ Status = STATUS_SUCCESS;
+ break;
+ }
+
+ SectImagePriority = 3;
}
- else
- {
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Signature is currupted. Hence can't increase the priority");
- Status = STATUS_FAILURE ;
+ SectImagePriority = htonl(SectImagePriority);
+ Status = BcmFlash2xBulkWrite(Adapter,
+ &SectImagePriority,
+ eFlash2xSectVal,
+ Adapter->psFlash2xCSInfo->OffsetFromDSDStartForDSDHeader + FIELD_OFFSET_IN_HEADER(PDSD_HEADER, DSDImagePriority),
+ SIGNATURE_SIZE,
+ TRUE);
+ if (Status) {
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Priority has not been written properly");
+ Status = STATUS_FAILURE;
break;
}
+ } else {
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Signature is currupted. Hence can't increase the priority");
+ Status = STATUS_FAILURE;
break;
- case VSA0 :
- case VSA1 :
- case VSA2 :
- //Has to be decided
- break ;
- default :
- Status = STATUS_FAILURE ;
- break;
-
+ }
+ break;
+ case VSA0:
+ case VSA1:
+ case VSA2:
+ /* Has to be decided */
+ break;
+ default:
+ Status = STATUS_FAILURE;
+ break;
}
- Adapter->bHeaderChangeAllowed = FALSE ;
+ Adapter->bHeaderChangeAllowed = FALSE;
return Status;
-
}
-/**
-BcmCopyISO - Used only for copying the ISO section
-@Adapater :- Bcm Driver Private Data Structure
-@sCopySectStrut :- Section copy structure
-
-Return value:- SUCCESS if copies successfully else negative error code
-
-**/
-INT BcmCopyISO(PMINI_ADAPTER Adapter, FLASH2X_COPY_SECTION sCopySectStrut)
+/*
+ * BcmCopyISO - Used only for copying the ISO section
+ * @Adapater :- Bcm Driver Private Data Structure
+ * @sCopySectStrut :- Section copy structure
+ *
+ * Return value:- SUCCESS if copies successfully else negative error code
+ *
+ */
+
+int BcmCopyISO(struct bcm_mini_adapter *Adapter, FLASH2X_COPY_SECTION sCopySectStrut)
{
-
PCHAR Buff = NULL;
- FLASH2X_SECTION_VAL eISOReadPart = 0,eISOWritePart = 0;
- UINT uiReadOffsetWithinPart = 0, uiWriteOffsetWithinPart = 0;
- UINT uiTotalDataToCopy = 0;
- BOOLEAN IsThisHeaderSector = FALSE ;
- UINT sigOffset = 0;
- UINT ISOLength = 0;
- UINT Status = STATUS_SUCCESS;
- UINT SigBuff[MAX_RW_SIZE];
- UINT i = 0;
-
- if(ReadISOSignature(Adapter,sCopySectStrut.SrcSection) != ISO_IMAGE_MAGIC_NUMBER)
- {
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "error as Source ISO Section does not have valid signature");
+ FLASH2X_SECTION_VAL eISOReadPart = 0, eISOWritePart = 0;
+ unsigned int uiReadOffsetWithinPart = 0, uiWriteOffsetWithinPart = 0;
+ unsigned int uiTotalDataToCopy = 0;
+ BOOLEAN IsThisHeaderSector = FALSE;
+ unsigned int sigOffset = 0;
+ unsigned int ISOLength = 0;
+ unsigned int Status = STATUS_SUCCESS;
+ unsigned int SigBuff[MAX_RW_SIZE];
+ unsigned int i = 0;
+
+ if (ReadISOSignature(Adapter, sCopySectStrut.SrcSection) != ISO_IMAGE_MAGIC_NUMBER) {
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "error as Source ISO Section does not have valid signature");
return STATUS_FAILURE;
}
Status = BcmFlash2xBulkRead(Adapter,
- &ISOLength,
- sCopySectStrut.SrcSection,
- 0 + FIELD_OFFSET_IN_HEADER(PISO_HEADER,ISOImageSize),
- 4);
-
- if(Status)
- {
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Read failed while copying ISO\n");
+ &ISOLength,
+ sCopySectStrut.SrcSection,
+ 0 + FIELD_OFFSET_IN_HEADER(PISO_HEADER, ISOImageSize),
+ 4);
+ if (Status) {
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Read failed while copying ISO\n");
return Status;
}
ISOLength = htonl(ISOLength);
-
- if(ISOLength % Adapter->uiSectorSize)
- {
- ISOLength = Adapter->uiSectorSize*(1 + ISOLength/Adapter->uiSectorSize);
- }
+ if (ISOLength % Adapter->uiSectorSize)
+ ISOLength = Adapter->uiSectorSize * (1 + ISOLength/Adapter->uiSectorSize);
sigOffset = FIELD_OFFSET_IN_HEADER(PISO_HEADER, ISOImageMagicNumber);
Buff = kzalloc(Adapter->uiSectorSize, GFP_KERNEL);
- if(Buff == NULL)
- {
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Memory allocation failed for section size");
- return -ENOMEM;
+ if (!Buff) {
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Memory allocation failed for section size");
+ return -ENOMEM;
}
- if(sCopySectStrut.SrcSection ==ISO_IMAGE1 && sCopySectStrut.DstSection ==ISO_IMAGE2)
- {
- eISOReadPart = ISO_IMAGE1 ;
- eISOWritePart = ISO_IMAGE2 ;
+ if (sCopySectStrut.SrcSection == ISO_IMAGE1 && sCopySectStrut.DstSection == ISO_IMAGE2) {
+ eISOReadPart = ISO_IMAGE1;
+ eISOWritePart = ISO_IMAGE2;
uiReadOffsetWithinPart = 0;
- uiWriteOffsetWithinPart = 0 ;
-
- uiTotalDataToCopy =(Adapter->psFlash2xCSInfo->OffsetISOImage1Part1End) -
- (Adapter->psFlash2xCSInfo->OffsetISOImage1Part1Start)+
- (Adapter->psFlash2xCSInfo->OffsetISOImage1Part2End) -
- (Adapter->psFlash2xCSInfo->OffsetISOImage1Part2Start)+
- (Adapter->psFlash2xCSInfo->OffsetISOImage1Part3End) -
- (Adapter->psFlash2xCSInfo->OffsetISOImage1Part3Start);
-
- if(uiTotalDataToCopy < ISOLength)
- {
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"error as Source ISO Section does not have valid signature");
+ uiWriteOffsetWithinPart = 0;
+
+ uiTotalDataToCopy = (Adapter->psFlash2xCSInfo->OffsetISOImage1Part1End) -
+ (Adapter->psFlash2xCSInfo->OffsetISOImage1Part1Start) +
+ (Adapter->psFlash2xCSInfo->OffsetISOImage1Part2End) -
+ (Adapter->psFlash2xCSInfo->OffsetISOImage1Part2Start) +
+ (Adapter->psFlash2xCSInfo->OffsetISOImage1Part3End) -
+ (Adapter->psFlash2xCSInfo->OffsetISOImage1Part3Start);
+
+ if (uiTotalDataToCopy < ISOLength) {
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "error as Source ISO Section does not have valid signature");
Status = STATUS_FAILURE;
goto out;
}
- uiTotalDataToCopy =(Adapter->psFlash2xCSInfo->OffsetISOImage2Part1End) -
- (Adapter->psFlash2xCSInfo->OffsetISOImage2Part1Start)+
- (Adapter->psFlash2xCSInfo->OffsetISOImage2Part2End) -
- (Adapter->psFlash2xCSInfo->OffsetISOImage2Part2Start)+
- (Adapter->psFlash2xCSInfo->OffsetISOImage2Part3End) -
- (Adapter->psFlash2xCSInfo->OffsetISOImage2Part3Start);
+ uiTotalDataToCopy = (Adapter->psFlash2xCSInfo->OffsetISOImage2Part1End) -
+ (Adapter->psFlash2xCSInfo->OffsetISOImage2Part1Start) +
+ (Adapter->psFlash2xCSInfo->OffsetISOImage2Part2End) -
+ (Adapter->psFlash2xCSInfo->OffsetISOImage2Part2Start) +
+ (Adapter->psFlash2xCSInfo->OffsetISOImage2Part3End) -
+ (Adapter->psFlash2xCSInfo->OffsetISOImage2Part3Start);
- if(uiTotalDataToCopy < ISOLength)
- {
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"error as Dest ISO Section does not have enough section size");
+ if (uiTotalDataToCopy < ISOLength) {
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "error as Dest ISO Section does not have enough section size");
Status = STATUS_FAILURE;
goto out;
}
uiTotalDataToCopy = ISOLength;
- CorruptISOSig(Adapter,ISO_IMAGE2);
-
- while(uiTotalDataToCopy)
- {
- if(uiTotalDataToCopy == Adapter->uiSectorSize)
- {
- //Setting for write of first sector. First sector is assumed to be written in last
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL,"Writing the signature sector");
- eISOReadPart = ISO_IMAGE1 ;
+ CorruptISOSig(Adapter, ISO_IMAGE2);
+ while (uiTotalDataToCopy) {
+ if (uiTotalDataToCopy == Adapter->uiSectorSize) {
+ /* Setting for write of first sector. First sector is assumed to be written in last */
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "Writing the signature sector");
+ eISOReadPart = ISO_IMAGE1;
uiReadOffsetWithinPart = 0;
eISOWritePart = ISO_IMAGE2;
- uiWriteOffsetWithinPart = 0 ;
- IsThisHeaderSector = TRUE ;
-
- }
- else
- {
- uiReadOffsetWithinPart = uiReadOffsetWithinPart + Adapter->uiSectorSize ;
- uiWriteOffsetWithinPart = uiWriteOffsetWithinPart + Adapter->uiSectorSize ;
+ uiWriteOffsetWithinPart = 0;
+ IsThisHeaderSector = TRUE;
+ } else {
+ uiReadOffsetWithinPart = uiReadOffsetWithinPart + Adapter->uiSectorSize;
+ uiWriteOffsetWithinPart = uiWriteOffsetWithinPart + Adapter->uiSectorSize;
- if((eISOReadPart == ISO_IMAGE1) && (uiReadOffsetWithinPart == (Adapter->psFlash2xCSInfo->OffsetISOImage1Part1End - Adapter->psFlash2xCSInfo->OffsetISOImage1Part1Start) ))
- {
- eISOReadPart = ISO_IMAGE1_PART2 ;
+ if ((eISOReadPart == ISO_IMAGE1) && (uiReadOffsetWithinPart == (Adapter->psFlash2xCSInfo->OffsetISOImage1Part1End - Adapter->psFlash2xCSInfo->OffsetISOImage1Part1Start))) {
+ eISOReadPart = ISO_IMAGE1_PART2;
uiReadOffsetWithinPart = 0;
}
- if((eISOReadPart == ISO_IMAGE1_PART2) && (uiReadOffsetWithinPart == (Adapter->psFlash2xCSInfo->OffsetISOImage1Part2End - Adapter->psFlash2xCSInfo->OffsetISOImage1Part2Start)))
- {
- eISOReadPart = ISO_IMAGE1_PART3 ;
+
+ if ((eISOReadPart == ISO_IMAGE1_PART2) && (uiReadOffsetWithinPart == (Adapter->psFlash2xCSInfo->OffsetISOImage1Part2End - Adapter->psFlash2xCSInfo->OffsetISOImage1Part2Start))) {
+ eISOReadPart = ISO_IMAGE1_PART3;
uiReadOffsetWithinPart = 0;
}
- if((eISOWritePart == ISO_IMAGE2) && (uiWriteOffsetWithinPart == (Adapter->psFlash2xCSInfo->OffsetISOImage2Part1End - Adapter->psFlash2xCSInfo->OffsetISOImage2Part1Start)))
- {
- eISOWritePart = ISO_IMAGE2_PART2 ;
+
+ if ((eISOWritePart == ISO_IMAGE2) && (uiWriteOffsetWithinPart == (Adapter->psFlash2xCSInfo->OffsetISOImage2Part1End - Adapter->psFlash2xCSInfo->OffsetISOImage2Part1Start))) {
+ eISOWritePart = ISO_IMAGE2_PART2;
uiWriteOffsetWithinPart = 0;
}
- if((eISOWritePart == ISO_IMAGE2_PART2) && (uiWriteOffsetWithinPart == (Adapter->psFlash2xCSInfo->OffsetISOImage2Part2End - Adapter->psFlash2xCSInfo->OffsetISOImage2Part2Start)))
- {
- eISOWritePart = ISO_IMAGE2_PART3 ;
+
+ if ((eISOWritePart == ISO_IMAGE2_PART2) && (uiWriteOffsetWithinPart == (Adapter->psFlash2xCSInfo->OffsetISOImage2Part2End - Adapter->psFlash2xCSInfo->OffsetISOImage2Part2Start))) {
+ eISOWritePart = ISO_IMAGE2_PART3;
uiWriteOffsetWithinPart = 0;
}
}
Status = BcmFlash2xBulkRead(Adapter,
- (PUINT)Buff,
- eISOReadPart,
- uiReadOffsetWithinPart,
- Adapter->uiSectorSize
- );
-
- if(Status)
- {
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Read failed while copying ISO: Part: %x, OffsetWithinPart: %x\n", eISOReadPart, uiReadOffsetWithinPart);
+ (PUINT)Buff,
+ eISOReadPart,
+ uiReadOffsetWithinPart,
+ Adapter->uiSectorSize);
+ if (Status) {
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Read failed while copying ISO: Part: %x, OffsetWithinPart: %x\n", eISOReadPart, uiReadOffsetWithinPart);
break;
}
- if(IsThisHeaderSector == TRUE)
- {
- //If this is header sector write 0xFFFFFFFF at the sig time and in last write sig
+ if (IsThisHeaderSector == TRUE) {
+ /* If this is header sector write 0xFFFFFFFF at the sig time and in last write sig */
memcpy(SigBuff, Buff + sigOffset, MAX_RW_SIZE);
- for(i = 0; i < MAX_RW_SIZE;i++)
+ for (i = 0; i < MAX_RW_SIZE; i++)
*(Buff + sigOffset + i) = 0xFF;
}
- Adapter->bHeaderChangeAllowed = TRUE ;
-
+ Adapter->bHeaderChangeAllowed = TRUE;
Status = BcmFlash2xBulkWrite(Adapter,
- (PUINT)Buff,
- eISOWritePart,
- uiWriteOffsetWithinPart,
- Adapter->uiSectorSize,
- TRUE);
- if(Status)
- {
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Write failed while copying ISO: Part: %x, OffsetWithinPart: %x\n", eISOWritePart, uiWriteOffsetWithinPart);
+ (PUINT)Buff,
+ eISOWritePart,
+ uiWriteOffsetWithinPart,
+ Adapter->uiSectorSize,
+ TRUE);
+ if (Status) {
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Write failed while copying ISO: Part: %x, OffsetWithinPart: %x\n", eISOWritePart, uiWriteOffsetWithinPart);
break;
}
Adapter->bHeaderChangeAllowed = FALSE;
-
- if(IsThisHeaderSector == TRUE)
- {
+ if (IsThisHeaderSector == TRUE) {
WriteToFlashWithoutSectorErase(Adapter,
- SigBuff,
- eISOWritePart,
- sigOffset,
- MAX_RW_SIZE);
- IsThisHeaderSector = FALSE ;
+ SigBuff,
+ eISOWritePart,
+ sigOffset,
+ MAX_RW_SIZE);
+ IsThisHeaderSector = FALSE;
}
- //subtracting the written Data
- uiTotalDataToCopy = uiTotalDataToCopy - Adapter->uiSectorSize ;
+ /* subtracting the written Data */
+ uiTotalDataToCopy = uiTotalDataToCopy - Adapter->uiSectorSize;
}
+ }
+ if (sCopySectStrut.SrcSection == ISO_IMAGE2 && sCopySectStrut.DstSection == ISO_IMAGE1) {
+ eISOReadPart = ISO_IMAGE2;
+ eISOWritePart = ISO_IMAGE1;
+ uiReadOffsetWithinPart = 0;
+ uiWriteOffsetWithinPart = 0;
- }
+ uiTotalDataToCopy = (Adapter->psFlash2xCSInfo->OffsetISOImage2Part1End) -
+ (Adapter->psFlash2xCSInfo->OffsetISOImage2Part1Start) +
+ (Adapter->psFlash2xCSInfo->OffsetISOImage2Part2End) -
+ (Adapter->psFlash2xCSInfo->OffsetISOImage2Part2Start) +
+ (Adapter->psFlash2xCSInfo->OffsetISOImage2Part3End) -
+ (Adapter->psFlash2xCSInfo->OffsetISOImage2Part3Start);
- if(sCopySectStrut.SrcSection ==ISO_IMAGE2 && sCopySectStrut.DstSection ==ISO_IMAGE1)
- {
- eISOReadPart = ISO_IMAGE2 ;
- eISOWritePart = ISO_IMAGE1 ;
- uiReadOffsetWithinPart = 0;
- uiWriteOffsetWithinPart = 0 ;
-
- uiTotalDataToCopy =(Adapter->psFlash2xCSInfo->OffsetISOImage2Part1End) -
- (Adapter->psFlash2xCSInfo->OffsetISOImage2Part1Start)+
- (Adapter->psFlash2xCSInfo->OffsetISOImage2Part2End) -
- (Adapter->psFlash2xCSInfo->OffsetISOImage2Part2Start)+
- (Adapter->psFlash2xCSInfo->OffsetISOImage2Part3End) -
- (Adapter->psFlash2xCSInfo->OffsetISOImage2Part3Start);
-
- if(uiTotalDataToCopy < ISOLength)
- {
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"error as Source ISO Section does not have valid signature");
+ if (uiTotalDataToCopy < ISOLength) {
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "error as Source ISO Section does not have valid signature");
Status = STATUS_FAILURE;
goto out;
}
- uiTotalDataToCopy =(Adapter->psFlash2xCSInfo->OffsetISOImage1Part1End) -
- (Adapter->psFlash2xCSInfo->OffsetISOImage1Part1Start)+
- (Adapter->psFlash2xCSInfo->OffsetISOImage1Part2End) -
- (Adapter->psFlash2xCSInfo->OffsetISOImage1Part2Start)+
- (Adapter->psFlash2xCSInfo->OffsetISOImage1Part3End) -
- (Adapter->psFlash2xCSInfo->OffsetISOImage1Part3Start);
+ uiTotalDataToCopy = (Adapter->psFlash2xCSInfo->OffsetISOImage1Part1End) -
+ (Adapter->psFlash2xCSInfo->OffsetISOImage1Part1Start) +
+ (Adapter->psFlash2xCSInfo->OffsetISOImage1Part2End) -
+ (Adapter->psFlash2xCSInfo->OffsetISOImage1Part2Start) +
+ (Adapter->psFlash2xCSInfo->OffsetISOImage1Part3End) -
+ (Adapter->psFlash2xCSInfo->OffsetISOImage1Part3Start);
- if(uiTotalDataToCopy < ISOLength)
- {
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"error as Dest ISO Section does not have enough section size");
+ if (uiTotalDataToCopy < ISOLength) {
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "error as Dest ISO Section does not have enough section size");
Status = STATUS_FAILURE;
goto out;
}
uiTotalDataToCopy = ISOLength;
- CorruptISOSig(Adapter,ISO_IMAGE1);
+ CorruptISOSig(Adapter, ISO_IMAGE1);
- while(uiTotalDataToCopy)
- {
- if(uiTotalDataToCopy == Adapter->uiSectorSize)
- {
- //Setting for write of first sector. First sector is assumed to be written in last
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL,"Writing the signature sector");
- eISOReadPart = ISO_IMAGE2 ;
+ while (uiTotalDataToCopy) {
+ if (uiTotalDataToCopy == Adapter->uiSectorSize) {
+ /* Setting for write of first sector. First sector is assumed to be written in last */
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "Writing the signature sector");
+ eISOReadPart = ISO_IMAGE2;
uiReadOffsetWithinPart = 0;
eISOWritePart = ISO_IMAGE1;
- uiWriteOffsetWithinPart = 0 ;
+ uiWriteOffsetWithinPart = 0;
IsThisHeaderSector = TRUE;
+ } else {
+ uiReadOffsetWithinPart = uiReadOffsetWithinPart + Adapter->uiSectorSize;
+ uiWriteOffsetWithinPart = uiWriteOffsetWithinPart + Adapter->uiSectorSize;
- }
- else
- {
- uiReadOffsetWithinPart = uiReadOffsetWithinPart + Adapter->uiSectorSize ;
- uiWriteOffsetWithinPart = uiWriteOffsetWithinPart + Adapter->uiSectorSize ;
-
- if((eISOReadPart == ISO_IMAGE2) && (uiReadOffsetWithinPart == (Adapter->psFlash2xCSInfo->OffsetISOImage2Part1End - Adapter->psFlash2xCSInfo->OffsetISOImage2Part1Start) ))
- {
- eISOReadPart = ISO_IMAGE2_PART2 ;
+ if ((eISOReadPart == ISO_IMAGE2) && (uiReadOffsetWithinPart == (Adapter->psFlash2xCSInfo->OffsetISOImage2Part1End - Adapter->psFlash2xCSInfo->OffsetISOImage2Part1Start))) {
+ eISOReadPart = ISO_IMAGE2_PART2;
uiReadOffsetWithinPart = 0;
}
- if((eISOReadPart == ISO_IMAGE2_PART2) && (uiReadOffsetWithinPart == (Adapter->psFlash2xCSInfo->OffsetISOImage2Part2End - Adapter->psFlash2xCSInfo->OffsetISOImage2Part2Start)))
- {
- eISOReadPart = ISO_IMAGE2_PART3 ;
+
+ if ((eISOReadPart == ISO_IMAGE2_PART2) && (uiReadOffsetWithinPart == (Adapter->psFlash2xCSInfo->OffsetISOImage2Part2End - Adapter->psFlash2xCSInfo->OffsetISOImage2Part2Start))) {
+ eISOReadPart = ISO_IMAGE2_PART3;
uiReadOffsetWithinPart = 0;
}
- if((eISOWritePart == ISO_IMAGE1) && (uiWriteOffsetWithinPart == (Adapter->psFlash2xCSInfo->OffsetISOImage1Part1End - Adapter->psFlash2xCSInfo->OffsetISOImage1Part1Start)))
- {
- eISOWritePart = ISO_IMAGE1_PART2 ;
+
+ if ((eISOWritePart == ISO_IMAGE1) && (uiWriteOffsetWithinPart == (Adapter->psFlash2xCSInfo->OffsetISOImage1Part1End - Adapter->psFlash2xCSInfo->OffsetISOImage1Part1Start))) {
+ eISOWritePart = ISO_IMAGE1_PART2;
uiWriteOffsetWithinPart = 0;
}
- if((eISOWritePart == ISO_IMAGE1_PART2) && (uiWriteOffsetWithinPart == (Adapter->psFlash2xCSInfo->OffsetISOImage1Part2End - Adapter->psFlash2xCSInfo->OffsetISOImage1Part2Start)))
- {
- eISOWritePart = ISO_IMAGE1_PART3 ;
+
+ if ((eISOWritePart == ISO_IMAGE1_PART2) && (uiWriteOffsetWithinPart == (Adapter->psFlash2xCSInfo->OffsetISOImage1Part2End - Adapter->psFlash2xCSInfo->OffsetISOImage1Part2Start))) {
+ eISOWritePart = ISO_IMAGE1_PART3;
uiWriteOffsetWithinPart = 0;
}
}
Status = BcmFlash2xBulkRead(Adapter,
- (PUINT)Buff,
- eISOReadPart,
- uiReadOffsetWithinPart,
- Adapter->uiSectorSize
- );
- if(Status)
- {
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Read failed while copying ISO: Part: %x, OffsetWithinPart: %x\n", eISOReadPart, uiReadOffsetWithinPart);
+ (PUINT)Buff,
+ eISOReadPart,
+ uiReadOffsetWithinPart,
+ Adapter->uiSectorSize);
+ if (Status) {
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Read failed while copying ISO: Part: %x, OffsetWithinPart: %x\n", eISOReadPart, uiReadOffsetWithinPart);
break;
}
- if(IsThisHeaderSector == TRUE)
- {
- //If this is header sector write 0xFFFFFFFF at the sig time and in last write sig
+ if (IsThisHeaderSector == TRUE) {
+ /* If this is header sector write 0xFFFFFFFF at the sig time and in last write sig */
memcpy(SigBuff, Buff + sigOffset, MAX_RW_SIZE);
- for(i = 0; i < MAX_RW_SIZE;i++)
+ for (i = 0; i < MAX_RW_SIZE; i++)
*(Buff + sigOffset + i) = 0xFF;
-
}
- Adapter->bHeaderChangeAllowed = TRUE ;
+ Adapter->bHeaderChangeAllowed = TRUE;
Status = BcmFlash2xBulkWrite(Adapter,
- (PUINT)Buff,
- eISOWritePart,
- uiWriteOffsetWithinPart,
- Adapter->uiSectorSize,
- TRUE);
-
- if(Status)
- {
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Write failed while copying ISO: Part: %x, OffsetWithinPart: %x\n", eISOWritePart, uiWriteOffsetWithinPart);
+ (PUINT)Buff,
+ eISOWritePart,
+ uiWriteOffsetWithinPart,
+ Adapter->uiSectorSize,
+ TRUE);
+ if (Status) {
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Write failed while copying ISO: Part: %x, OffsetWithinPart: %x\n", eISOWritePart, uiWriteOffsetWithinPart);
break;
}
- Adapter->bHeaderChangeAllowed = FALSE ;
-
- if(IsThisHeaderSector == TRUE)
- {
+ Adapter->bHeaderChangeAllowed = FALSE;
+ if (IsThisHeaderSector == TRUE) {
WriteToFlashWithoutSectorErase(Adapter,
- SigBuff,
- eISOWritePart,
- sigOffset,
- MAX_RW_SIZE);
- IsThisHeaderSector = FALSE ;
+ SigBuff,
+ eISOWritePart,
+ sigOffset,
+ MAX_RW_SIZE);
+
+ IsThisHeaderSector = FALSE;
}
- //subtracting the written Data
- uiTotalDataToCopy = uiTotalDataToCopy - Adapter->uiSectorSize ;
+ /* subtracting the written Data */
+ uiTotalDataToCopy = uiTotalDataToCopy - Adapter->uiSectorSize;
}
-
-
}
-
out:
kfree(Buff);
return Status;
}
-/**
-BcmFlash2xCorruptSig : this API is used to corrupt the written sig in Bcm Header present in flash section.
- It will corrupt the sig, if Section is writable, by making first bytes as zero.
-@Adapater :- Bcm Driver Private Data Structure
-@eFlash2xSectionVal :- Flash section val which has header
-
-Return Value :-
- Success :- If Section is present and writable, corrupt the sig and return STATUS_SUCCESS
- Failure :-Return negative error code
-
-**/
-INT BcmFlash2xCorruptSig(PMINI_ADAPTER Adapter, FLASH2X_SECTION_VAL eFlash2xSectionVal)
+/*
+ * BcmFlash2xCorruptSig : this API is used to corrupt the written sig in Bcm Header present in flash section.
+ * It will corrupt the sig, if Section is writable, by making first bytes as zero.
+ * @Adapater :- Bcm Driver Private Data Structure
+ * @eFlash2xSectionVal :- Flash section val which has header
+ *
+ * Return Value :-
+ * Success :- If Section is present and writable, corrupt the sig and return STATUS_SUCCESS
+ * Failure :-Return negative error code
+ */
+
+int BcmFlash2xCorruptSig(struct bcm_mini_adapter *Adapter, FLASH2X_SECTION_VAL eFlash2xSectionVal)
{
+ int Status = STATUS_SUCCESS;
- INT Status = STATUS_SUCCESS ;
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Section Value :%x \n", eFlash2xSectionVal);
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Section Value :%x\n", eFlash2xSectionVal);
- if((eFlash2xSectionVal == DSD0) || (eFlash2xSectionVal == DSD1) || (eFlash2xSectionVal == DSD2))
- {
+ if ((eFlash2xSectionVal == DSD0) || (eFlash2xSectionVal == DSD1) || (eFlash2xSectionVal == DSD2)) {
Status = CorruptDSDSig(Adapter, eFlash2xSectionVal);
- }
- else if(eFlash2xSectionVal == ISO_IMAGE1 || eFlash2xSectionVal == ISO_IMAGE2)
- {
+ } else if (eFlash2xSectionVal == ISO_IMAGE1 || eFlash2xSectionVal == ISO_IMAGE2) {
Status = CorruptISOSig(Adapter, eFlash2xSectionVal);
- }
- else
- {
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL,"Given Section <%d>does not have Header",eFlash2xSectionVal);
+ } else {
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "Given Section <%d>does not have Header", eFlash2xSectionVal);
return STATUS_SUCCESS;
}
return Status;
}
-/**
-BcmFlash2xWriteSig :-this API is used to Write the sig if requested Section has
- header and Write Permission.
-@Adapater :- Bcm Driver Private Data Structure
-@eFlashSectionVal :- Flash section val which has header
-
-Return Value :-
- Success :- If Section is present and writable write the sig and return STATUS_SUCCESS
- Failure :-Return negative error code
-
-**/
-INT BcmFlash2xWriteSig(PMINI_ADAPTER Adapter, FLASH2X_SECTION_VAL eFlashSectionVal)
-{
- UINT uiSignature = 0 ;
- UINT uiOffset = 0;
- //DSD_HEADER dsdHeader = {0};
+/*
+ *BcmFlash2xWriteSig :-this API is used to Write the sig if requested Section has
+ * header and Write Permission.
+ * @Adapater :- Bcm Driver Private Data Structure
+ * @eFlashSectionVal :- Flash section val which has header
+ *
+ * Return Value :-
+ * Success :- If Section is present and writable write the sig and return STATUS_SUCCESS
+ * Failure :-Return negative error code
+ */
+
+int BcmFlash2xWriteSig(struct bcm_mini_adapter *Adapter, FLASH2X_SECTION_VAL eFlashSectionVal)
+{
+ unsigned int uiSignature = 0;
+ unsigned int uiOffset = 0;
- if(Adapter->bSigCorrupted == FALSE)
- {
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL,"Signature is not corrupted by driver, hence not restoring\n");
+ /* DSD_HEADER dsdHeader = {0}; */
+ if (Adapter->bSigCorrupted == FALSE) {
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "Signature is not corrupted by driver, hence not restoring\n");
return STATUS_SUCCESS;
}
- if(Adapter->bAllDSDWriteAllow == FALSE)
- {
- if(IsSectionWritable(Adapter,eFlashSectionVal) == FALSE)
- {
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Section is not Writable...Hence can't Write signature");
+
+ if (Adapter->bAllDSDWriteAllow == FALSE) {
+ if (IsSectionWritable(Adapter, eFlashSectionVal) == FALSE) {
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Section is not Writable...Hence can't Write signature");
return SECTOR_IS_NOT_WRITABLE;
}
}
- if((eFlashSectionVal == DSD0) ||(eFlashSectionVal == DSD1) || (eFlashSectionVal == DSD2))
- {
- uiSignature = htonl(DSD_IMAGE_MAGIC_NUMBER) ;
- uiOffset = Adapter->psFlash2xCSInfo->OffsetFromDSDStartForDSDHeader ;
- uiOffset += FIELD_OFFSET_IN_HEADER(PDSD_HEADER,DSDImageMagicNumber);
+ if ((eFlashSectionVal == DSD0) || (eFlashSectionVal == DSD1) || (eFlashSectionVal == DSD2)) {
+ uiSignature = htonl(DSD_IMAGE_MAGIC_NUMBER);
+ uiOffset = Adapter->psFlash2xCSInfo->OffsetFromDSDStartForDSDHeader;
+
+ uiOffset += FIELD_OFFSET_IN_HEADER(PDSD_HEADER, DSDImageMagicNumber);
- if((ReadDSDSignature(Adapter,eFlashSectionVal) & 0xFF000000) != CORRUPTED_PATTERN)
- {
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Corrupted Pattern is not there. Hence won't write sig");
+ if ((ReadDSDSignature(Adapter, eFlashSectionVal) & 0xFF000000) != CORRUPTED_PATTERN) {
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Corrupted Pattern is not there. Hence won't write sig");
return STATUS_FAILURE;
}
-
- }
- else if((eFlashSectionVal == ISO_IMAGE1) || (eFlashSectionVal == ISO_IMAGE2))
- {
+ } else if ((eFlashSectionVal == ISO_IMAGE1) || (eFlashSectionVal == ISO_IMAGE2)) {
uiSignature = htonl(ISO_IMAGE_MAGIC_NUMBER);
- //uiOffset = 0;
- uiOffset = FIELD_OFFSET_IN_HEADER(PISO_HEADER,ISOImageMagicNumber);
- if((ReadISOSignature(Adapter,eFlashSectionVal) & 0xFF000000) != CORRUPTED_PATTERN)
- {
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Currupted Pattern is not there. Hence won't write sig");
+ /* uiOffset = 0; */
+ uiOffset = FIELD_OFFSET_IN_HEADER(PISO_HEADER, ISOImageMagicNumber);
+ if ((ReadISOSignature(Adapter, eFlashSectionVal) & 0xFF000000) != CORRUPTED_PATTERN) {
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Currupted Pattern is not there. Hence won't write sig");
return STATUS_FAILURE;
}
- }
- else
- {
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"GIVEN SECTION< %d > IS NOT VALID FOR SIG WRITE...", eFlashSectionVal);
+ } else {
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "GIVEN SECTION< %d > IS NOT VALID FOR SIG WRITE...", eFlashSectionVal);
return STATUS_FAILURE;
}
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL,"Restoring the signature");
-
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "Restoring the signature");
Adapter->bHeaderChangeAllowed = TRUE;
Adapter->bSigCorrupted = FALSE;
- BcmFlash2xBulkWrite(Adapter, &uiSignature,eFlashSectionVal,uiOffset,SIGNATURE_SIZE,TRUE);
+ BcmFlash2xBulkWrite(Adapter, &uiSignature, eFlashSectionVal, uiOffset, SIGNATURE_SIZE, TRUE);
Adapter->bHeaderChangeAllowed = FALSE;
-
-
return STATUS_SUCCESS;
}
-/**
-validateFlash2xReadWrite :- This API is used to validate the user request for Read/Write.
- if requested Bytes goes beyond the Requested section, it reports error.
-@Adapater :- Bcm Driver Private Data Structure
-@psFlash2xReadWrite :-Flash2x Read/write structure pointer
-
-Return values:-Return TRUE is request is valid else FALSE.
-
-**/
-INT validateFlash2xReadWrite(PMINI_ADAPTER Adapter, PFLASH2X_READWRITE psFlash2xReadWrite)
+/*
+ * validateFlash2xReadWrite :- This API is used to validate the user request for Read/Write.
+ * if requested Bytes goes beyond the Requested section, it reports error.
+ * @Adapater :- Bcm Driver Private Data Structure
+ * @psFlash2xReadWrite :-Flash2x Read/write structure pointer
+ *
+ * Return values:-Return TRUE is request is valid else FALSE.
+ */
+
+int validateFlash2xReadWrite(struct bcm_mini_adapter *Adapter, PFLASH2X_READWRITE psFlash2xReadWrite)
{
- UINT uiNumOfBytes = 0 ;
- UINT uiSectStartOffset = 0 ;
- UINT uiSectEndOffset = 0;
+ unsigned int uiNumOfBytes = 0;
+ unsigned int uiSectStartOffset = 0;
+ unsigned int uiSectEndOffset = 0;
+
uiNumOfBytes = psFlash2xReadWrite->numOfBytes;
- if(IsSectionExistInFlash(Adapter,psFlash2xReadWrite->Section) != TRUE)
- {
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Section<%x> does not exixt in Flash",psFlash2xReadWrite->Section);
+ if (IsSectionExistInFlash(Adapter, psFlash2xReadWrite->Section) != TRUE) {
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Section<%x> does not exixt in Flash", psFlash2xReadWrite->Section);
return FALSE;
}
- uiSectStartOffset = BcmGetSectionValStartOffset(Adapter,psFlash2xReadWrite->Section);
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "Start offset :%x ,section :%d\n",uiSectStartOffset,psFlash2xReadWrite->Section);
- if((psFlash2xReadWrite->Section == ISO_IMAGE1) ||(psFlash2xReadWrite->Section == ISO_IMAGE2))
- {
- if(psFlash2xReadWrite->Section == ISO_IMAGE1)
- {
- uiSectEndOffset = BcmGetSectionValEndOffset(Adapter,ISO_IMAGE1) -
- BcmGetSectionValStartOffset(Adapter,ISO_IMAGE1)+
- BcmGetSectionValEndOffset(Adapter,ISO_IMAGE1_PART2) -
- BcmGetSectionValStartOffset(Adapter,ISO_IMAGE1_PART2)+
- BcmGetSectionValEndOffset(Adapter,ISO_IMAGE1_PART3) -
- BcmGetSectionValStartOffset(Adapter,ISO_IMAGE1_PART3);
+ uiSectStartOffset = BcmGetSectionValStartOffset(Adapter, psFlash2xReadWrite->Section);
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "Start offset :%x ,section :%d\n", uiSectStartOffset, psFlash2xReadWrite->Section);
+ if ((psFlash2xReadWrite->Section == ISO_IMAGE1) || (psFlash2xReadWrite->Section == ISO_IMAGE2)) {
+ if (psFlash2xReadWrite->Section == ISO_IMAGE1) {
+ uiSectEndOffset = BcmGetSectionValEndOffset(Adapter, ISO_IMAGE1) -
+ BcmGetSectionValStartOffset(Adapter, ISO_IMAGE1) +
+ BcmGetSectionValEndOffset(Adapter, ISO_IMAGE1_PART2) -
+ BcmGetSectionValStartOffset(Adapter, ISO_IMAGE1_PART2) +
+ BcmGetSectionValEndOffset(Adapter, ISO_IMAGE1_PART3) -
+ BcmGetSectionValStartOffset(Adapter, ISO_IMAGE1_PART3);
+ } else if (psFlash2xReadWrite->Section == ISO_IMAGE2) {
+ uiSectEndOffset = BcmGetSectionValEndOffset(Adapter, ISO_IMAGE2) -
+ BcmGetSectionValStartOffset(Adapter, ISO_IMAGE2) +
+ BcmGetSectionValEndOffset(Adapter, ISO_IMAGE2_PART2) -
+ BcmGetSectionValStartOffset(Adapter, ISO_IMAGE2_PART2) +
+ BcmGetSectionValEndOffset(Adapter, ISO_IMAGE2_PART3) -
+ BcmGetSectionValStartOffset(Adapter, ISO_IMAGE2_PART3);
}
- else if(psFlash2xReadWrite->Section == ISO_IMAGE2)
- {
- uiSectEndOffset = BcmGetSectionValEndOffset(Adapter,ISO_IMAGE2) -
- BcmGetSectionValStartOffset(Adapter,ISO_IMAGE2)+
- BcmGetSectionValEndOffset(Adapter,ISO_IMAGE2_PART2) -
- BcmGetSectionValStartOffset(Adapter,ISO_IMAGE2_PART2)+
- BcmGetSectionValEndOffset(Adapter,ISO_IMAGE2_PART3) -
- BcmGetSectionValStartOffset(Adapter,ISO_IMAGE2_PART3);
- }
+ /* since this uiSectEndoffset is the size of iso Image. hence for calculating the vitual endoffset
+ * it should be added in startoffset. so that check done in last of this function can be valued.
+ */
+ uiSectEndOffset = uiSectStartOffset + uiSectEndOffset;
- //since this uiSectEndoffset is the size of iso Image. hence for calculating the vitual endoffset
- //it should be added in startoffset. so that check done in last of this function can be valued.
- uiSectEndOffset = uiSectStartOffset + uiSectEndOffset ;
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "Total size of the ISO Image :%x", uiSectEndOffset);
+ } else
+ uiSectEndOffset = BcmGetSectionValEndOffset(Adapter, psFlash2xReadWrite->Section);
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL,"Total size of the ISO Image :%x",uiSectEndOffset);
- }
- else
- uiSectEndOffset = BcmGetSectionValEndOffset(Adapter,psFlash2xReadWrite->Section);
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "End offset :%x \n",uiSectEndOffset);
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "End offset :%x\n", uiSectEndOffset);
- //Checking the boundary condition
- if((uiSectStartOffset + psFlash2xReadWrite->offset + uiNumOfBytes) <= uiSectEndOffset)
+ /* Checking the boundary condition */
+ if ((uiSectStartOffset + psFlash2xReadWrite->offset + uiNumOfBytes) <= uiSectEndOffset)
return TRUE;
- else
- {
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Invalid Request....");
+ else {
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Invalid Request....");
return FALSE;
}
-
}
-/**
-IsFlash2x :- check for Flash 2.x
-@Adapater :- Bcm Driver Private Data Structure
-
-Return value:-
- return TRUE if flah2.x of hgher version else return false.
-**/
-
-INT IsFlash2x(PMINI_ADAPTER Adapter)
+/*
+ * IsFlash2x :- check for Flash 2.x
+ * Adapater :- Bcm Driver Private Data Structure
+ *
+ * Return value:-
+ * return TRUE if flah2.x of hgher version else return false.
+ */
+
+int IsFlash2x(struct bcm_mini_adapter *Adapter)
{
- if(Adapter->uiFlashLayoutMajorVersion >= FLASH_2X_MAJOR_NUMBER)
- return TRUE ;
+ if (Adapter->uiFlashLayoutMajorVersion >= FLASH_2X_MAJOR_NUMBER)
+ return TRUE;
else
return FALSE;
}
-/**
-GetFlashBaseAddr :- Calculate the Flash Base address
-@Adapater :- Bcm Driver Private Data Structure
-
-Return Value:-
- Success :- Base Address of the Flash
-**/
-static INT GetFlashBaseAddr(PMINI_ADAPTER Adapter)
+/*
+ * GetFlashBaseAddr :- Calculate the Flash Base address
+ * @Adapater :- Bcm Driver Private Data Structure
+ *
+ * Return Value:-
+ * Success :- Base Address of the Flash
+ */
+
+static int GetFlashBaseAddr(struct bcm_mini_adapter *Adapter)
{
+ unsigned int uiBaseAddr = 0;
- UINT uiBaseAddr = 0;
-
- if(Adapter->bDDRInitDone)
- {
+ if (Adapter->bDDRInitDone) {
/*
- For All Valid Flash Versions... except 1.1, take the value from FlashBaseAddr
- In case of Raw Read... use the default value
- */
- if(Adapter->uiFlashLayoutMajorVersion && (Adapter->bFlashRawRead == FALSE) &&
- !((Adapter->uiFlashLayoutMajorVersion == 1) && (Adapter->uiFlashLayoutMinorVersion == 1))
- )
- uiBaseAddr = Adapter->uiFlashBaseAdd ;
+ * For All Valid Flash Versions... except 1.1, take the value from FlashBaseAddr
+ * In case of Raw Read... use the default value
+ */
+ if (Adapter->uiFlashLayoutMajorVersion && (Adapter->bFlashRawRead == FALSE) &&
+ !((Adapter->uiFlashLayoutMajorVersion == 1) && (Adapter->uiFlashLayoutMinorVersion == 1)))
+ uiBaseAddr = Adapter->uiFlashBaseAdd;
else
uiBaseAddr = FLASH_CONTIGIOUS_START_ADDR_AFTER_INIT;
- }
- else
- {
+ } else {
/*
- For All Valid Flash Versions... except 1.1, take the value from FlashBaseAddr
- In case of Raw Read... use the default value
- */
- if(Adapter->uiFlashLayoutMajorVersion && (Adapter->bFlashRawRead == FALSE) &&
- !((Adapter->uiFlashLayoutMajorVersion == 1) && (Adapter->uiFlashLayoutMinorVersion == 1))
- )
+ * For All Valid Flash Versions... except 1.1, take the value from FlashBaseAddr
+ * In case of Raw Read... use the default value
+ */
+ if (Adapter->uiFlashLayoutMajorVersion && (Adapter->bFlashRawRead == FALSE) &&
+ !((Adapter->uiFlashLayoutMajorVersion == 1) && (Adapter->uiFlashLayoutMinorVersion == 1)))
uiBaseAddr = Adapter->uiFlashBaseAdd | FLASH_CONTIGIOUS_START_ADDR_BEFORE_INIT;
else
uiBaseAddr = FLASH_CONTIGIOUS_START_ADDR_BEFORE_INIT;
}
- return uiBaseAddr ;
+ return uiBaseAddr;
}
-/**
-BcmCopySection :- This API is used to copy the One section in another. Both section should
- be contiuous and of same size. Hence this Will not be applicabe to copy ISO.
-
-@Adapater :- Bcm Driver Private Data Structure
-@SrcSection :- Source section From where data has to be copied
-@DstSection :- Destination section to which data has to be copied
-@offset :- Offset from/to where data has to be copied from one section to another.
-@numOfBytes :- number of byes that has to be copyed from one section to another at given offset.
- in case of numofBytes equal zero complete section will be copied.
-
-Return Values-
- Success : Return STATUS_SUCCESS
- Faillure :- return negative error code
-
-**/
-
-INT BcmCopySection(PMINI_ADAPTER Adapter,
- FLASH2X_SECTION_VAL SrcSection,
- FLASH2X_SECTION_VAL DstSection,
- UINT offset,
- UINT numOfBytes)
+
+/*
+ * BcmCopySection :- This API is used to copy the One section in another. Both section should
+ * be contiuous and of same size. Hence this Will not be applicabe to copy ISO.
+ *
+ * @Adapater :- Bcm Driver Private Data Structure
+ * @SrcSection :- Source section From where data has to be copied
+ * @DstSection :- Destination section to which data has to be copied
+ * @offset :- Offset from/to where data has to be copied from one section to another.
+ * @numOfBytes :- number of byes that has to be copyed from one section to another at given offset.
+ * in case of numofBytes equal zero complete section will be copied.
+ * Return Values-
+ * Success : Return STATUS_SUCCESS
+ * Faillure :- return negative error code
+ */
+
+int BcmCopySection(struct bcm_mini_adapter *Adapter,
+ FLASH2X_SECTION_VAL SrcSection,
+ FLASH2X_SECTION_VAL DstSection,
+ unsigned int offset,
+ unsigned int numOfBytes)
{
- UINT BuffSize = 0 ;
- UINT BytesToBeCopied = 0;
- PUCHAR pBuff = NULL ;
- INT Status = STATUS_SUCCESS ;
- if(SrcSection == DstSection)
- {
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Source and Destination should be different ...try again");
+ unsigned int BuffSize = 0;
+ unsigned int BytesToBeCopied = 0;
+ PUCHAR pBuff = NULL;
+ int Status = STATUS_SUCCESS;
+
+ if (SrcSection == DstSection) {
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Source and Destination should be different ...try again");
return -EINVAL;
}
- if((SrcSection != DSD0) && (SrcSection != DSD1) && (SrcSection != DSD2))
- {
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Source should be DSD subsection");
- return -EINVAL;
- }
- if((DstSection != DSD0) && (DstSection != DSD1) && (DstSection != DSD2))
- {
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Destination should be DSD subsection");
- return -EINVAL;
+
+ if ((SrcSection != DSD0) && (SrcSection != DSD1) && (SrcSection != DSD2)) {
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Source should be DSD subsection");
+ return -EINVAL;
}
- //if offset zero means have to copy complete secton
+ if ((DstSection != DSD0) && (DstSection != DSD1) && (DstSection != DSD2)) {
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Destination should be DSD subsection");
+ return -EINVAL;
+ }
- if(numOfBytes == 0)
- {
- numOfBytes = BcmGetSectionValEndOffset(Adapter,SrcSection)
- - BcmGetSectionValStartOffset(Adapter,SrcSection);
+ /* if offset zero means have to copy complete secton */
+ if (numOfBytes == 0) {
+ numOfBytes = BcmGetSectionValEndOffset(Adapter, SrcSection)
+ - BcmGetSectionValStartOffset(Adapter, SrcSection);
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL," Section Size :0x%x",numOfBytes);
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "Section Size :0x%x", numOfBytes);
}
- if((offset + numOfBytes) > BcmGetSectionValEndOffset(Adapter,SrcSection)
- - BcmGetSectionValStartOffset(Adapter,SrcSection))
- {
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0," Input parameters going beyond the section offS: %x numB: %x of Source Section\n",
- offset, numOfBytes);
+ if ((offset + numOfBytes) > BcmGetSectionValEndOffset(Adapter, SrcSection)
+ - BcmGetSectionValStartOffset(Adapter, SrcSection)) {
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, " Input parameters going beyond the section offS: %x numB: %x of Source Section\n",
+ offset, numOfBytes);
return -EINVAL;
}
- if((offset + numOfBytes) > BcmGetSectionValEndOffset(Adapter,DstSection)
- - BcmGetSectionValStartOffset(Adapter,DstSection))
- {
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0," Input parameters going beyond the section offS: %x numB: %x of Destination Section\n",
- offset, numOfBytes);
+ if ((offset + numOfBytes) > BcmGetSectionValEndOffset(Adapter, DstSection)
+ - BcmGetSectionValStartOffset(Adapter, DstSection)) {
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Input parameters going beyond the section offS: %x numB: %x of Destination Section\n",
+ offset, numOfBytes);
return -EINVAL;
}
-
- if(numOfBytes > Adapter->uiSectorSize )
+ if (numOfBytes > Adapter->uiSectorSize)
BuffSize = Adapter->uiSectorSize;
else
- BuffSize = numOfBytes ;
+ BuffSize = numOfBytes;
pBuff = (PCHAR)kzalloc(BuffSize, GFP_KERNEL);
- if(pBuff == NULL)
- {
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Memory allocation failed.. ");
+ if (!pBuff) {
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Memory allocation failed.. ");
return -ENOMEM;
}
-
- BytesToBeCopied = Adapter->uiSectorSize ;
- if(offset % Adapter->uiSectorSize)
+ BytesToBeCopied = Adapter->uiSectorSize;
+ if (offset % Adapter->uiSectorSize)
BytesToBeCopied = Adapter->uiSectorSize - (offset % Adapter->uiSectorSize);
- if(BytesToBeCopied > numOfBytes)
- BytesToBeCopied = numOfBytes ;
-
-
+ if (BytesToBeCopied > numOfBytes)
+ BytesToBeCopied = numOfBytes;
Adapter->bHeaderChangeAllowed = TRUE;
- do
- {
- Status = BcmFlash2xBulkRead(Adapter, (PUINT)pBuff, SrcSection , offset,BytesToBeCopied);
- if(Status)
- {
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Read failed at offset :%d for NOB :%d", SrcSection,BytesToBeCopied);
+ do {
+ Status = BcmFlash2xBulkRead(Adapter, (PUINT)pBuff, SrcSection , offset, BytesToBeCopied);
+ if (Status) {
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Read failed at offset :%d for NOB :%d", SrcSection, BytesToBeCopied);
break;
}
- Status = BcmFlash2xBulkWrite(Adapter,(PUINT)pBuff,DstSection,offset,BytesToBeCopied,FALSE);
- if(Status)
- {
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Write failed at offset :%d for NOB :%d", DstSection,BytesToBeCopied);
+ Status = BcmFlash2xBulkWrite(Adapter, (PUINT)pBuff, DstSection, offset, BytesToBeCopied, FALSE);
+ if (Status) {
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Write failed at offset :%d for NOB :%d", DstSection, BytesToBeCopied);
break;
}
offset = offset + BytesToBeCopied;
- numOfBytes = numOfBytes - BytesToBeCopied ;
- if(numOfBytes)
- {
- if(numOfBytes > Adapter->uiSectorSize )
+ numOfBytes = numOfBytes - BytesToBeCopied;
+ if (numOfBytes) {
+ if (numOfBytes > Adapter->uiSectorSize)
BytesToBeCopied = Adapter->uiSectorSize;
else
BytesToBeCopied = numOfBytes;
}
- }while(numOfBytes > 0) ;
+ } while (numOfBytes > 0);
+
kfree(pBuff);
- Adapter->bHeaderChangeAllowed = FALSE ;
+ Adapter->bHeaderChangeAllowed = FALSE;
+
return Status;
}
-/**
-SaveHeaderIfPresent :- This API is use to Protect the Header in case of Header Sector write
-@Adapater :- Bcm Driver Private Data Structure
-@pBuff :- Data buffer that has to be written in sector having the header map.
-@uiOffset :- Flash offset that has to be written.
-
-Return value :-
- Success :- On success return STATUS_SUCCESS
- Faillure :- Return negative error code
-
-**/
-
-INT SaveHeaderIfPresent(PMINI_ADAPTER Adapter, PUCHAR pBuff, UINT uiOffset)
+/*
+ * SaveHeaderIfPresent :- This API is use to Protect the Header in case of Header Sector write
+ * @Adapater :- Bcm Driver Private Data Structure
+ * @pBuff :- Data buffer that has to be written in sector having the header map.
+ * @uiOffset :- Flash offset that has to be written.
+ *
+ * Return value :-
+ * Success :- On success return STATUS_SUCCESS
+ * Faillure :- Return negative error code
+ */
+
+int SaveHeaderIfPresent(struct bcm_mini_adapter *Adapter, PUCHAR pBuff, unsigned int uiOffset)
{
- UINT offsetToProtect = 0,HeaderSizeToProtect =0;
- BOOLEAN bHasHeader = FALSE ;
- PUCHAR pTempBuff =NULL;
- UINT uiSectAlignAddr = 0;
- UINT sig = 0;
+ unsigned int offsetToProtect = 0, HeaderSizeToProtect = 0;
+ BOOLEAN bHasHeader = FALSE;
+ PUCHAR pTempBuff = NULL;
+ unsigned int uiSectAlignAddr = 0;
+ unsigned int sig = 0;
- //making the offset sector aligned
+ /* making the offset sector aligned */
uiSectAlignAddr = uiOffset & ~(Adapter->uiSectorSize - 1);
-
- if((uiSectAlignAddr == BcmGetSectionValEndOffset(Adapter,DSD2)- Adapter->uiSectorSize)||
- (uiSectAlignAddr == BcmGetSectionValEndOffset(Adapter,DSD1)- Adapter->uiSectorSize)||
- (uiSectAlignAddr == BcmGetSectionValEndOffset(Adapter,DSD0)- Adapter->uiSectorSize))
- {
-
- //offset from the sector boundary having the header map
+ if ((uiSectAlignAddr == BcmGetSectionValEndOffset(Adapter, DSD2) - Adapter->uiSectorSize) ||
+ (uiSectAlignAddr == BcmGetSectionValEndOffset(Adapter, DSD1) - Adapter->uiSectorSize) ||
+ (uiSectAlignAddr == BcmGetSectionValEndOffset(Adapter, DSD0) - Adapter->uiSectorSize)) {
+ /* offset from the sector boundary having the header map */
offsetToProtect = Adapter->psFlash2xCSInfo->OffsetFromDSDStartForDSDHeader % Adapter->uiSectorSize;
HeaderSizeToProtect = sizeof(DSD_HEADER);
- bHasHeader = TRUE ;
+ bHasHeader = TRUE;
}
- if(uiSectAlignAddr == BcmGetSectionValStartOffset(Adapter,ISO_IMAGE1) ||
- uiSectAlignAddr == BcmGetSectionValStartOffset(Adapter,ISO_IMAGE2))
- {
+ if (uiSectAlignAddr == BcmGetSectionValStartOffset(Adapter, ISO_IMAGE1) ||
+ uiSectAlignAddr == BcmGetSectionValStartOffset(Adapter, ISO_IMAGE2)) {
offsetToProtect = 0;
HeaderSizeToProtect = sizeof(ISO_HEADER);
bHasHeader = TRUE;
}
- //If Header is present overwrite passed buffer with this
- if(bHasHeader && (Adapter->bHeaderChangeAllowed == FALSE))
- {
+ /* If Header is present overwrite passed buffer with this */
+ if (bHasHeader && (Adapter->bHeaderChangeAllowed == FALSE)) {
pTempBuff = (PUCHAR)kzalloc(HeaderSizeToProtect, GFP_KERNEL);
- if(pTempBuff == NULL)
- {
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Memory allocation failed ");
+ if (!pTempBuff) {
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Memory allocation failed");
return -ENOMEM;
}
- //Read header
- BeceemFlashBulkRead(Adapter,(PUINT)pTempBuff,(uiSectAlignAddr + offsetToProtect),HeaderSizeToProtect);
- BCM_DEBUG_PRINT_BUFFER(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL,pTempBuff ,HeaderSizeToProtect);
- //Replace Buffer content with Header
- memcpy(pBuff +offsetToProtect,pTempBuff,HeaderSizeToProtect);
+ /* Read header */
+ BeceemFlashBulkRead(Adapter, (PUINT)pTempBuff, (uiSectAlignAddr + offsetToProtect), HeaderSizeToProtect);
+ BCM_DEBUG_PRINT_BUFFER(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, pTempBuff, HeaderSizeToProtect);
+ /* Replace Buffer content with Header */
+ memcpy(pBuff + offsetToProtect, pTempBuff, HeaderSizeToProtect);
kfree(pTempBuff);
}
- if(bHasHeader && Adapter->bSigCorrupted)
- {
- sig = *((PUINT)(pBuff + offsetToProtect + FIELD_OFFSET_IN_HEADER(PDSD_HEADER,DSDImageMagicNumber)));
+ if (bHasHeader && Adapter->bSigCorrupted) {
+ sig = *((PUINT)(pBuff + offsetToProtect + FIELD_OFFSET_IN_HEADER(PDSD_HEADER, DSDImageMagicNumber)));
sig = ntohl(sig);
- if((sig & 0xFF000000) != CORRUPTED_PATTERN)
- {
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL,"Desired pattern is not at sig offset. Hence won't restore");
+ if ((sig & 0xFF000000) != CORRUPTED_PATTERN) {
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "Desired pattern is not at sig offset. Hence won't restore");
Adapter->bSigCorrupted = FALSE;
return STATUS_SUCCESS;
}
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL," Corrupted sig is :%X", sig);
- *((PUINT)(pBuff + offsetToProtect + FIELD_OFFSET_IN_HEADER(PDSD_HEADER,DSDImageMagicNumber)))= htonl(DSD_IMAGE_MAGIC_NUMBER);
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL,"Restoring the signature in Header Write only");
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, " Corrupted sig is :%X", sig);
+ *((PUINT)(pBuff + offsetToProtect + FIELD_OFFSET_IN_HEADER(PDSD_HEADER, DSDImageMagicNumber))) = htonl(DSD_IMAGE_MAGIC_NUMBER);
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "Restoring the signature in Header Write only");
Adapter->bSigCorrupted = FALSE;
}
- return STATUS_SUCCESS ;
+ return STATUS_SUCCESS;
}
-/**
-BcmDoChipSelect : This will selcet the appropriate chip for writing.
-@Adapater :- Bcm Driver Private Data Structure
-
-OutPut:-
- Select the Appropriate chip and retrn status Success
-**/
-static INT BcmDoChipSelect(PMINI_ADAPTER Adapter, UINT offset)
+/*
+ * BcmDoChipSelect : This will selcet the appropriate chip for writing.
+ * @Adapater :- Bcm Driver Private Data Structure
+ *
+ * OutPut:-
+ * Select the Appropriate chip and retrn status Success
+ */
+static int BcmDoChipSelect(struct bcm_mini_adapter *Adapter, unsigned int offset)
{
- UINT FlashConfig = 0;
- INT ChipNum = 0;
- UINT GPIOConfig = 0;
- UINT PartNum = 0;
+ unsigned int FlashConfig = 0;
+ int ChipNum = 0;
+ unsigned int GPIOConfig = 0;
+ unsigned int PartNum = 0;
- ChipNum = offset / FLASH_PART_SIZE ;
+ ChipNum = offset / FLASH_PART_SIZE;
- //
- // Chip Select mapping to enable flash0.
- // To select flash 0, we have to OR with (0<<12).
- // ORing 0 will have no impact so not doing that part.
- // In future if Chip select value changes from 0 to non zero,
- // That needs be taken care with backward comaptibility. No worries for now.
- //
+ /*
+ * Chip Select mapping to enable flash0.
+ * To select flash 0, we have to OR with (0<<12).
+ * ORing 0 will have no impact so not doing that part.
+ * In future if Chip select value changes from 0 to non zero,
+ * That needs be taken care with backward comaptibility. No worries for now.
+ */
/*
- SelectedChip Variable is the selection that the host is 100% Sure the same as what the register will hold. This can be ONLY ensured
- if the Chip doesn't goes to low power mode while the flash operation is in progress (NVMRdmWrmLock is taken)
- Before every new Flash Write operation, we reset the variable. This is to ensure that after any wake-up from
- power down modes (Idle mode/shutdown mode), the values in the register will be different.
- */
+ * SelectedChip Variable is the selection that the host is 100% Sure the same as what the register will hold. This can be ONLY ensured
+ * if the Chip doesn't goes to low power mode while the flash operation is in progress (NVMRdmWrmLock is taken)
+ * Before every new Flash Write operation, we reset the variable. This is to ensure that after any wake-up from
+ * power down modes (Idle mode/shutdown mode), the values in the register will be different.
+ */
- if(Adapter->SelectedChip == ChipNum)
- return STATUS_SUCCESS;
+ if (Adapter->SelectedChip == ChipNum)
+ return STATUS_SUCCESS;
- //BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "Selected Chip :%x", ChipNum);
- Adapter->SelectedChip = ChipNum ;
+ /* BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "Selected Chip :%x", ChipNum); */
+ Adapter->SelectedChip = ChipNum;
- //bit[13..12] will select the appropriate chip
+ /* bit[13..12] will select the appropriate chip */
rdmalt(Adapter, FLASH_CONFIG_REG, &FlashConfig, 4);
rdmalt(Adapter, FLASH_GPIO_CONFIG_REG, &GPIOConfig, 4);
-
{
- switch(ChipNum)
- {
+ switch (ChipNum) {
case 0:
PartNum = 0;
break;
@@ -4770,453 +4243,422 @@ static INT BcmDoChipSelect(PMINI_ADAPTER Adapter, UINT offset)
}
}
/* In case the bits already written in the FLASH_CONFIG_REG is same as what the user desired,
- nothing to do... can return immediately.
- ASSUMPTION: FLASH_GPIO_CONFIG_REG will be in sync with FLASH_CONFIG_REG.
- Even if the chip goes to low power mode, it should wake with values in each register in sync with each other.
- These values are not written by host other than during CHIP_SELECT.
- */
- if(PartNum == ((FlashConfig >> CHIP_SELECT_BIT12) & 0x3))
+ * nothing to do... can return immediately.
+ * ASSUMPTION: FLASH_GPIO_CONFIG_REG will be in sync with FLASH_CONFIG_REG.
+ * Even if the chip goes to low power mode, it should wake with values in each register in sync with each other.
+ * These values are not written by host other than during CHIP_SELECT.
+ */
+ if (PartNum == ((FlashConfig >> CHIP_SELECT_BIT12) & 0x3))
return STATUS_SUCCESS;
- //clearing the bit[13..12]
+ /* clearing the bit[13..12] */
FlashConfig &= 0xFFFFCFFF;
- FlashConfig = (FlashConfig | (PartNum<<CHIP_SELECT_BIT12)); //00
+ FlashConfig = (FlashConfig | (PartNum<<CHIP_SELECT_BIT12)); /* 00 */
- wrmalt(Adapter,FLASH_GPIO_CONFIG_REG, &GPIOConfig, 4);
+ wrmalt(Adapter, FLASH_GPIO_CONFIG_REG, &GPIOConfig, 4);
udelay(100);
- wrmalt(Adapter,FLASH_CONFIG_REG, &FlashConfig, 4);
+ wrmalt(Adapter, FLASH_CONFIG_REG, &FlashConfig, 4);
udelay(100);
return STATUS_SUCCESS;
-
}
-INT ReadDSDSignature(PMINI_ADAPTER Adapter, FLASH2X_SECTION_VAL dsd)
-{
- UINT uiDSDsig = 0;
- //UINT sigoffsetInMap = 0;
- //DSD_HEADER dsdHeader = {0};
+int ReadDSDSignature(struct bcm_mini_adapter *Adapter, FLASH2X_SECTION_VAL dsd)
+{
+ unsigned int uiDSDsig = 0;
+ /* unsigned int sigoffsetInMap = 0;
+ * DSD_HEADER dsdHeader = {0};
+ */
- //sigoffsetInMap =(PUCHAR)&(dsdHeader.DSDImageMagicNumber) -(PUCHAR)&dsdHeader;
+ /* sigoffsetInMap =(PUCHAR)&(dsdHeader.DSDImageMagicNumber) -(PUCHAR)&dsdHeader; */
- if(dsd != DSD0 && dsd != DSD1 && dsd != DSD2)
- {
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"passed section value is not for DSDs");
- return STATUS_FAILURE;
- }
- BcmFlash2xBulkRead(Adapter,
- &uiDSDsig,
- dsd,
- Adapter->psFlash2xCSInfo->OffsetFromDSDStartForDSDHeader + FIELD_OFFSET_IN_HEADER(PDSD_HEADER,DSDImageMagicNumber),
- SIGNATURE_SIZE);
+ if (dsd != DSD0 && dsd != DSD1 && dsd != DSD2) {
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "passed section value is not for DSDs");
+ return STATUS_FAILURE;
+ }
+ BcmFlash2xBulkRead(Adapter,
+ &uiDSDsig,
+ dsd,
+ Adapter->psFlash2xCSInfo->OffsetFromDSDStartForDSDHeader + FIELD_OFFSET_IN_HEADER(PDSD_HEADER, DSDImageMagicNumber),
+ SIGNATURE_SIZE);
- uiDSDsig = ntohl(uiDSDsig);
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL,"DSD SIG :%x", uiDSDsig);
+ uiDSDsig = ntohl(uiDSDsig);
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "DSD SIG :%x", uiDSDsig);
- return uiDSDsig ;
+ return uiDSDsig;
}
-INT ReadDSDPriority(PMINI_ADAPTER Adapter, FLASH2X_SECTION_VAL dsd)
+
+int ReadDSDPriority(struct bcm_mini_adapter *Adapter, FLASH2X_SECTION_VAL dsd)
{
- //UINT priOffsetInMap = 0 ;
+ /* unsigned int priOffsetInMap = 0 ; */
unsigned int uiDSDPri = STATUS_FAILURE;
- //DSD_HEADER dsdHeader = {0};
- //priOffsetInMap = (PUCHAR)&(dsdHeader.DSDImagePriority) -(PUCHAR)&dsdHeader;
- if(IsSectionWritable(Adapter,dsd))
- {
- if(ReadDSDSignature(Adapter,dsd)== DSD_IMAGE_MAGIC_NUMBER)
- {
+ /* DSD_HEADER dsdHeader = {0};
+ * priOffsetInMap = (PUCHAR)&(dsdHeader.DSDImagePriority) -(PUCHAR)&dsdHeader;
+ */
+ if (IsSectionWritable(Adapter, dsd)) {
+ if (ReadDSDSignature(Adapter, dsd) == DSD_IMAGE_MAGIC_NUMBER) {
BcmFlash2xBulkRead(Adapter,
- &uiDSDPri,
- dsd,
- Adapter->psFlash2xCSInfo->OffsetFromDSDStartForDSDHeader +FIELD_OFFSET_IN_HEADER(PDSD_HEADER, DSDImagePriority),
- 4);
+ &uiDSDPri,
+ dsd,
+ Adapter->psFlash2xCSInfo->OffsetFromDSDStartForDSDHeader + FIELD_OFFSET_IN_HEADER(PDSD_HEADER, DSDImagePriority),
+ 4);
uiDSDPri = ntohl(uiDSDPri);
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL,"DSD<%x> Priority :%x", dsd, uiDSDPri);
-
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "DSD<%x> Priority :%x", dsd, uiDSDPri);
}
}
+
return uiDSDPri;
}
-FLASH2X_SECTION_VAL getHighestPriDSD(PMINI_ADAPTER Adapter)
+
+FLASH2X_SECTION_VAL getHighestPriDSD(struct bcm_mini_adapter *Adapter)
{
- INT DSDHighestPri = STATUS_FAILURE;
- INT DsdPri= 0 ;
- FLASH2X_SECTION_VAL HighestPriDSD = 0 ;
+ int DSDHighestPri = STATUS_FAILURE;
+ int DsdPri = 0;
+ FLASH2X_SECTION_VAL HighestPriDSD = 0;
- if(IsSectionWritable(Adapter,DSD2))
- {
- DSDHighestPri = ReadDSDPriority(Adapter,DSD2);
- HighestPriDSD = DSD2 ;
+ if (IsSectionWritable(Adapter, DSD2)) {
+ DSDHighestPri = ReadDSDPriority(Adapter, DSD2);
+ HighestPriDSD = DSD2;
}
- if(IsSectionWritable(Adapter,DSD1))
- {
- DsdPri = ReadDSDPriority(Adapter,DSD1);
- if(DSDHighestPri < DsdPri)
- {
- DSDHighestPri = DsdPri ;
+
+ if (IsSectionWritable(Adapter, DSD1)) {
+ DsdPri = ReadDSDPriority(Adapter, DSD1);
+ if (DSDHighestPri < DsdPri) {
+ DSDHighestPri = DsdPri;
HighestPriDSD = DSD1;
- }
+ }
}
- if(IsSectionWritable(Adapter,DSD0))
- {
- DsdPri = ReadDSDPriority(Adapter,DSD0);
- if(DSDHighestPri < DsdPri)
- {
- DSDHighestPri = DsdPri ;
+
+ if (IsSectionWritable(Adapter, DSD0)) {
+ DsdPri = ReadDSDPriority(Adapter, DSD0);
+ if (DSDHighestPri < DsdPri) {
+ DSDHighestPri = DsdPri;
HighestPriDSD = DSD0;
- }
+ }
}
- if(HighestPriDSD)
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL,"Highest DSD :%x , and its Pri :%x", HighestPriDSD, DSDHighestPri);
- return HighestPriDSD ;
+ if (HighestPriDSD)
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "Highest DSD :%x , and its Pri :%x", HighestPriDSD, DSDHighestPri);
+
+ return HighestPriDSD;
}
-INT ReadISOSignature(PMINI_ADAPTER Adapter, FLASH2X_SECTION_VAL iso)
+int ReadISOSignature(struct bcm_mini_adapter *Adapter, FLASH2X_SECTION_VAL iso)
{
- UINT uiISOsig = 0;
- //UINT sigoffsetInMap = 0;
- //ISO_HEADER ISOHeader = {0};
-
-
- //sigoffsetInMap =(PUCHAR)&(ISOHeader.ISOImageMagicNumber) -(PUCHAR)&ISOHeader;
-
- if(iso != ISO_IMAGE1 && iso != ISO_IMAGE2)
- {
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"passed section value is not for ISOs");
- return STATUS_FAILURE;
- }
- BcmFlash2xBulkRead(Adapter,
- &uiISOsig,
- iso,
- 0 + FIELD_OFFSET_IN_HEADER(PISO_HEADER,ISOImageMagicNumber),
- SIGNATURE_SIZE);
+ unsigned int uiISOsig = 0;
+ /* unsigned int sigoffsetInMap = 0;
+ * ISO_HEADER ISOHeader = {0};
+ * sigoffsetInMap =(PUCHAR)&(ISOHeader.ISOImageMagicNumber) -(PUCHAR)&ISOHeader;
+ */
+ if (iso != ISO_IMAGE1 && iso != ISO_IMAGE2) {
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "passed section value is not for ISOs");
+ return STATUS_FAILURE;
+ }
+ BcmFlash2xBulkRead(Adapter,
+ &uiISOsig,
+ iso,
+ 0 + FIELD_OFFSET_IN_HEADER(PISO_HEADER, ISOImageMagicNumber),
+ SIGNATURE_SIZE);
- uiISOsig = ntohl(uiISOsig);
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL,"ISO SIG :%x", uiISOsig);
+ uiISOsig = ntohl(uiISOsig);
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "ISO SIG :%x", uiISOsig);
- return uiISOsig ;
+ return uiISOsig;
}
-INT ReadISOPriority(PMINI_ADAPTER Adapter, FLASH2X_SECTION_VAL iso)
-{
+int ReadISOPriority(struct bcm_mini_adapter *Adapter, FLASH2X_SECTION_VAL iso)
+{
unsigned int ISOPri = STATUS_FAILURE;
- if(IsSectionWritable(Adapter,iso))
- {
- if(ReadISOSignature(Adapter,iso)== ISO_IMAGE_MAGIC_NUMBER)
- {
+ if (IsSectionWritable(Adapter, iso)) {
+ if (ReadISOSignature(Adapter, iso) == ISO_IMAGE_MAGIC_NUMBER) {
BcmFlash2xBulkRead(Adapter,
- &ISOPri,
- iso,
- 0 + FIELD_OFFSET_IN_HEADER(PISO_HEADER, ISOImagePriority),
- 4);
+ &ISOPri,
+ iso,
+ 0 + FIELD_OFFSET_IN_HEADER(PISO_HEADER, ISOImagePriority),
+ 4);
ISOPri = ntohl(ISOPri);
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL,"ISO<%x> Priority :%x", iso, ISOPri);
-
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "ISO<%x> Priority :%x", iso, ISOPri);
}
}
+
return ISOPri;
}
-FLASH2X_SECTION_VAL getHighestPriISO(PMINI_ADAPTER Adapter)
+
+FLASH2X_SECTION_VAL getHighestPriISO(struct bcm_mini_adapter *Adapter)
{
- INT ISOHighestPri = STATUS_FAILURE;
- INT ISOPri= 0 ;
- FLASH2X_SECTION_VAL HighestPriISO = NO_SECTION_VAL ;
+ int ISOHighestPri = STATUS_FAILURE;
+ int ISOPri = 0;
+ FLASH2X_SECTION_VAL HighestPriISO = NO_SECTION_VAL;
- if(IsSectionWritable(Adapter,ISO_IMAGE2))
- {
- ISOHighestPri = ReadISOPriority(Adapter,ISO_IMAGE2);
- HighestPriISO = ISO_IMAGE2 ;
+ if (IsSectionWritable(Adapter, ISO_IMAGE2)) {
+ ISOHighestPri = ReadISOPriority(Adapter, ISO_IMAGE2);
+ HighestPriISO = ISO_IMAGE2;
}
- if(IsSectionWritable(Adapter,ISO_IMAGE1))
- {
- ISOPri = ReadISOPriority(Adapter,ISO_IMAGE1);
- if(ISOHighestPri < ISOPri)
- {
- ISOHighestPri = ISOPri ;
+
+ if (IsSectionWritable(Adapter, ISO_IMAGE1)) {
+ ISOPri = ReadISOPriority(Adapter, ISO_IMAGE1);
+ if (ISOHighestPri < ISOPri) {
+ ISOHighestPri = ISOPri;
HighestPriISO = ISO_IMAGE1;
- }
+ }
}
- if(HighestPriISO)
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL,"Highest ISO :%x and its Pri :%x",HighestPriISO,ISOHighestPri);
- return HighestPriISO ;
+ if (HighestPriISO)
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "Highest ISO :%x and its Pri :%x", HighestPriISO, ISOHighestPri);
+
+ return HighestPriISO;
}
-INT WriteToFlashWithoutSectorErase(PMINI_ADAPTER Adapter,
- PUINT pBuff,
- FLASH2X_SECTION_VAL eFlash2xSectionVal,
- UINT uiOffset,
- UINT uiNumBytes
- )
+
+int WriteToFlashWithoutSectorErase(struct bcm_mini_adapter *Adapter,
+ PUINT pBuff,
+ FLASH2X_SECTION_VAL eFlash2xSectionVal,
+ unsigned int uiOffset,
+ unsigned int uiNumBytes)
{
-#if !defined(BCM_SHM_INTERFACE) || defined(FLASH_DIRECT_ACCESS)
- UINT uiTemp = 0, value = 0 ;
- UINT i = 0;
- UINT uiPartOffset = 0;
-#endif
- UINT uiStartOffset = 0;
- //Adding section start address
- INT Status = STATUS_SUCCESS;
+ #if !defined(BCM_SHM_INTERFACE) || defined(FLASH_DIRECT_ACCESS)
+ unsigned int uiTemp = 0, value = 0;
+ unsigned int i = 0;
+ unsigned int uiPartOffset = 0;
+ #endif
+ unsigned int uiStartOffset = 0;
+ /* Adding section start address */
+ int Status = STATUS_SUCCESS;
PUCHAR pcBuff = (PUCHAR)pBuff;
- if(uiNumBytes % Adapter->ulFlashWriteSize)
- {
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Writing without Sector Erase for non-FlashWriteSize number of bytes 0x%x\n", uiNumBytes);
+ if (uiNumBytes % Adapter->ulFlashWriteSize) {
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Writing without Sector Erase for non-FlashWriteSize number of bytes 0x%x\n", uiNumBytes);
return STATUS_FAILURE;
}
- uiStartOffset = BcmGetSectionValStartOffset(Adapter,eFlash2xSectionVal);
+ uiStartOffset = BcmGetSectionValStartOffset(Adapter, eFlash2xSectionVal);
- if(IsSectionExistInVendorInfo(Adapter,eFlash2xSectionVal))
- {
+ if (IsSectionExistInVendorInfo(Adapter, eFlash2xSectionVal))
return vendorextnWriteSectionWithoutErase(Adapter, pcBuff, eFlash2xSectionVal, uiOffset, uiNumBytes);
- }
uiOffset = uiOffset + uiStartOffset;
-#if defined(BCM_SHM_INTERFACE) && !defined(FLASH_DIRECT_ACCESS)
- Status = bcmflash_raw_writenoerase((uiOffset/FLASH_PART_SIZE),(uiOffset % FLASH_PART_SIZE), pcBuff,uiNumBytes);
-#else
- rdmalt(Adapter, 0x0f000C80, &uiTemp, sizeof(uiTemp));
- value = 0;
- wrmalt(Adapter, 0x0f000C80,&value, sizeof(value));
+ #if defined(BCM_SHM_INTERFACE) && !defined(FLASH_DIRECT_ACCESS)
+ Status = bcmflash_raw_writenoerase((uiOffset / FLASH_PART_SIZE), (uiOffset % FLASH_PART_SIZE), pcBuff, uiNumBytes);
+ #else
+ rdmalt(Adapter, 0x0f000C80, &uiTemp, sizeof(uiTemp));
+ value = 0;
+ wrmalt(Adapter, 0x0f000C80, &value, sizeof(value));
- Adapter->SelectedChip = RESET_CHIP_SELECT;
- BcmDoChipSelect(Adapter,uiOffset);
- uiPartOffset = (uiOffset & (FLASH_PART_SIZE - 1)) + GetFlashBaseAddr(Adapter);
+ Adapter->SelectedChip = RESET_CHIP_SELECT;
+ BcmDoChipSelect(Adapter, uiOffset);
+ uiPartOffset = (uiOffset & (FLASH_PART_SIZE - 1)) + GetFlashBaseAddr(Adapter);
- for(i = 0 ; i< uiNumBytes; i += Adapter->ulFlashWriteSize)
- {
- if(Adapter->ulFlashWriteSize == BYTE_WRITE_SUPPORT)
- Status = flashByteWrite(Adapter,uiPartOffset, pcBuff);
- else
- Status = flashWrite(Adapter,uiPartOffset, pcBuff);
+ for (i = 0 ; i < uiNumBytes; i += Adapter->ulFlashWriteSize) {
+ if (Adapter->ulFlashWriteSize == BYTE_WRITE_SUPPORT)
+ Status = flashByteWrite(Adapter, uiPartOffset, pcBuff);
+ else
+ Status = flashWrite(Adapter, uiPartOffset, pcBuff);
- if(Status != STATUS_SUCCESS)
- break;
+ if (Status != STATUS_SUCCESS)
+ break;
- pcBuff = pcBuff + Adapter->ulFlashWriteSize;
- uiPartOffset = uiPartOffset + Adapter->ulFlashWriteSize;
- }
- wrmalt(Adapter, 0x0f000C80, &uiTemp, sizeof(uiTemp));
- Adapter->SelectedChip = RESET_CHIP_SELECT;
-#endif
+ pcBuff = pcBuff + Adapter->ulFlashWriteSize;
+ uiPartOffset = uiPartOffset + Adapter->ulFlashWriteSize;
+ }
+ wrmalt(Adapter, 0x0f000C80, &uiTemp, sizeof(uiTemp));
+ Adapter->SelectedChip = RESET_CHIP_SELECT;
+ #endif
return Status;
}
-BOOLEAN IsSectionExistInFlash(PMINI_ADAPTER Adapter, FLASH2X_SECTION_VAL section)
+BOOLEAN IsSectionExistInFlash(struct bcm_mini_adapter *Adapter, FLASH2X_SECTION_VAL section)
{
+ BOOLEAN SectionPresent = FALSE;
+
+ switch (section) {
+ case ISO_IMAGE1:
+ if ((Adapter->psFlash2xCSInfo->OffsetISOImage1Part1Start != UNINIT_PTR_IN_CS) &&
+ (IsNonCDLessDevice(Adapter) == FALSE))
+ SectionPresent = TRUE;
+ break;
+ case ISO_IMAGE2:
+ if ((Adapter->psFlash2xCSInfo->OffsetISOImage2Part1Start != UNINIT_PTR_IN_CS) &&
+ (IsNonCDLessDevice(Adapter) == FALSE))
+ SectionPresent = TRUE;
+ break;
+ case DSD0:
+ if (Adapter->psFlash2xCSInfo->OffsetFromZeroForDSDStart != UNINIT_PTR_IN_CS)
+ SectionPresent = TRUE;
+ break;
+ case DSD1:
+ if (Adapter->psFlash2xCSInfo->OffsetFromZeroForDSD1Start != UNINIT_PTR_IN_CS)
+ SectionPresent = TRUE;
+ break;
+ case DSD2:
+ if (Adapter->psFlash2xCSInfo->OffsetFromZeroForDSD2Start != UNINIT_PTR_IN_CS)
+ SectionPresent = TRUE;
+ break;
+ case VSA0:
+ if (Adapter->psFlash2xCSInfo->OffsetFromZeroForVSAStart != UNINIT_PTR_IN_CS)
+ SectionPresent = TRUE;
+ break;
+ case VSA1:
+ if (Adapter->psFlash2xCSInfo->OffsetFromZeroForVSA1Start != UNINIT_PTR_IN_CS)
+ SectionPresent = TRUE;
+ break;
+ case VSA2:
+ if (Adapter->psFlash2xCSInfo->OffsetFromZeroForVSA2Start != UNINIT_PTR_IN_CS)
+ SectionPresent = TRUE;
+ break;
+ case SCSI:
+ if (Adapter->psFlash2xCSInfo->OffsetFromZeroForScsiFirmware != UNINIT_PTR_IN_CS)
+ SectionPresent = TRUE;
+ break;
+ case CONTROL_SECTION:
+ if (Adapter->psFlash2xCSInfo->OffsetFromZeroForControlSectionStart != UNINIT_PTR_IN_CS)
+ SectionPresent = TRUE;
+ break;
+ default:
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Section Does not exist in Flash 2.x");
+ SectionPresent = FALSE;
+ }
+
+ return SectionPresent;
+}
- BOOLEAN SectionPresent = FALSE ;
+int IsSectionWritable(struct bcm_mini_adapter *Adapter, FLASH2X_SECTION_VAL Section)
+{
+ int offset = STATUS_FAILURE;
+ int Status = FALSE;
- switch(section)
- {
+ if (IsSectionExistInFlash(Adapter, Section) == FALSE) {
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Section <%d> does not exixt", Section);
+ return FALSE;
+ }
- case ISO_IMAGE1 :
- if((Adapter->psFlash2xCSInfo->OffsetISOImage1Part1Start != UNINIT_PTR_IN_CS) &&
- (IsNonCDLessDevice(Adapter) == FALSE))
- SectionPresent = TRUE ;
- break;
- case ISO_IMAGE2 :
- if((Adapter->psFlash2xCSInfo->OffsetISOImage2Part1Start != UNINIT_PTR_IN_CS) &&
- (IsNonCDLessDevice(Adapter) == FALSE))
- SectionPresent = TRUE ;
- break;
- case DSD0 :
- if(Adapter->psFlash2xCSInfo->OffsetFromZeroForDSDStart != UNINIT_PTR_IN_CS)
- SectionPresent = TRUE ;
- break;
- case DSD1 :
- if(Adapter->psFlash2xCSInfo->OffsetFromZeroForDSD1Start != UNINIT_PTR_IN_CS)
- SectionPresent = TRUE ;
- break;
- case DSD2 :
- if(Adapter->psFlash2xCSInfo->OffsetFromZeroForDSD2Start != UNINIT_PTR_IN_CS)
- SectionPresent = TRUE ;
- break;
- case VSA0 :
- if(Adapter->psFlash2xCSInfo->OffsetFromZeroForVSAStart != UNINIT_PTR_IN_CS)
- SectionPresent = TRUE ;
- break;
- case VSA1 :
- if(Adapter->psFlash2xCSInfo->OffsetFromZeroForVSA1Start != UNINIT_PTR_IN_CS)
- SectionPresent = TRUE ;
- break;
- case VSA2 :
- if(Adapter->psFlash2xCSInfo->OffsetFromZeroForVSA2Start != UNINIT_PTR_IN_CS)
- SectionPresent = TRUE ;
- break;
- case SCSI :
- if(Adapter->psFlash2xCSInfo->OffsetFromZeroForScsiFirmware != UNINIT_PTR_IN_CS)
- SectionPresent = TRUE ;
- break;
- case CONTROL_SECTION :
- if(Adapter->psFlash2xCSInfo->OffsetFromZeroForControlSectionStart != UNINIT_PTR_IN_CS)
- SectionPresent = TRUE ;
- break;
- default :
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Section Does not exist in Flash 2.x");
- SectionPresent = FALSE;
+ offset = BcmGetSectionValStartOffset(Adapter, Section);
+ if (offset == INVALID_OFFSET) {
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Section<%d> does not exixt", Section);
+ return FALSE;
}
- return SectionPresent ;
-}
-INT IsSectionWritable(PMINI_ADAPTER Adapter, FLASH2X_SECTION_VAL Section)
-{
- INT offset = STATUS_FAILURE;
- INT Status = FALSE;
- if(IsSectionExistInFlash(Adapter,Section) == FALSE)
- {
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Section <%d> does not exixt", Section);
- return FALSE;
- }
- offset = BcmGetSectionValStartOffset(Adapter,Section);
- if(offset == INVALID_OFFSET)
- {
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Section<%d> does not exixt", Section);
- return FALSE;
- }
- if(IsSectionExistInVendorInfo(Adapter,Section))
- {
- return !(Adapter->psFlash2xVendorInfo->VendorSection[Section].AccessFlags & FLASH2X_SECTION_RO);
- }
+ if (IsSectionExistInVendorInfo(Adapter, Section))
+ return !(Adapter->psFlash2xVendorInfo->VendorSection[Section].AccessFlags & FLASH2X_SECTION_RO);
- Status = IsOffsetWritable(Adapter,offset);
- return Status ;
+ Status = IsOffsetWritable(Adapter, offset);
+ return Status;
}
-static INT CorruptDSDSig(PMINI_ADAPTER Adapter, FLASH2X_SECTION_VAL eFlash2xSectionVal)
+static int CorruptDSDSig(struct bcm_mini_adapter *Adapter, FLASH2X_SECTION_VAL eFlash2xSectionVal)
{
-
PUCHAR pBuff = NULL;
- UINT sig = 0;
- UINT uiOffset = 0;
- UINT BlockStatus = 0;
- UINT uiSectAlignAddr = 0;
+ unsigned int sig = 0;
+ unsigned int uiOffset = 0;
+ unsigned int BlockStatus = 0;
+ unsigned int uiSectAlignAddr = 0;
Adapter->bSigCorrupted = FALSE;
-
- if(Adapter->bAllDSDWriteAllow == FALSE)
- {
- if(IsSectionWritable(Adapter,eFlash2xSectionVal) != TRUE)
- {
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Section is not Writable...Hence can't Corrupt signature");
+ if (Adapter->bAllDSDWriteAllow == FALSE) {
+ if (IsSectionWritable(Adapter, eFlash2xSectionVal) != TRUE) {
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Section is not Writable...Hence can't Corrupt signature");
return SECTOR_IS_NOT_WRITABLE;
}
}
pBuff = (PUCHAR)kzalloc(MAX_RW_SIZE, GFP_KERNEL);
- if(pBuff == NULL)
- {
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Can't allocate memorey");
- return -ENOMEM ;
+ if (!pBuff) {
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Can't allocate memorey");
+ return -ENOMEM;
}
uiOffset = Adapter->psFlash2xCSInfo->OffsetFromDSDStartForDSDHeader + sizeof(DSD_HEADER);
- uiOffset -= MAX_RW_SIZE ;
+ uiOffset -= MAX_RW_SIZE;
- BcmFlash2xBulkRead(Adapter, (PUINT)pBuff,eFlash2xSectionVal,uiOffset,MAX_RW_SIZE);
+ BcmFlash2xBulkRead(Adapter, (PUINT)pBuff, eFlash2xSectionVal, uiOffset, MAX_RW_SIZE);
-
- sig = *((PUINT)(pBuff +12));
- sig =ntohl(sig);
- BCM_DEBUG_PRINT_BUFFER(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL,pBuff,MAX_RW_SIZE);
- //Now corrupting the sig by corrupting 4th last Byte.
+ sig = *((PUINT)(pBuff + 12));
+ sig = ntohl(sig);
+ BCM_DEBUG_PRINT_BUFFER(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, pBuff, MAX_RW_SIZE);
+ /* Now corrupting the sig by corrupting 4th last Byte. */
*(pBuff + 12) = 0;
- if(sig == DSD_IMAGE_MAGIC_NUMBER)
- {
+ if (sig == DSD_IMAGE_MAGIC_NUMBER) {
Adapter->bSigCorrupted = TRUE;
- if(Adapter->ulFlashWriteSize == BYTE_WRITE_SUPPORT)
- {
- uiSectAlignAddr = uiOffset & ~(Adapter->uiSectorSize -1);
- BlockStatus = BcmFlashUnProtectBlock(Adapter,uiSectAlignAddr,Adapter->uiSectorSize);
-
- WriteToFlashWithoutSectorErase(Adapter,(PUINT)(pBuff + 12),eFlash2xSectionVal,
- (uiOffset + 12),BYTE_WRITE_SUPPORT);
- if(BlockStatus)
- {
- BcmRestoreBlockProtectStatus(Adapter,BlockStatus);
+ if (Adapter->ulFlashWriteSize == BYTE_WRITE_SUPPORT) {
+ uiSectAlignAddr = uiOffset & ~(Adapter->uiSectorSize - 1);
+ BlockStatus = BcmFlashUnProtectBlock(Adapter, uiSectAlignAddr, Adapter->uiSectorSize);
+
+ WriteToFlashWithoutSectorErase(Adapter, (PUINT)(pBuff + 12), eFlash2xSectionVal,
+ (uiOffset + 12), BYTE_WRITE_SUPPORT);
+ if (BlockStatus) {
+ BcmRestoreBlockProtectStatus(Adapter, BlockStatus);
BlockStatus = 0;
}
+ } else {
+ WriteToFlashWithoutSectorErase(Adapter, (PUINT)pBuff, eFlash2xSectionVal,
+ uiOffset, MAX_RW_SIZE);
}
- else
- {
- WriteToFlashWithoutSectorErase(Adapter,(PUINT)pBuff,eFlash2xSectionVal,
- uiOffset ,MAX_RW_SIZE);
- }
- }
- else
- {
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"BCM Signature is not present in header");
+ } else {
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "BCM Signature is not present in header");
kfree(pBuff);
+
return STATUS_FAILURE;
}
kfree(pBuff);
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL,"Corrupted the signature");
- return STATUS_SUCCESS ;
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "Corrupted the signature");
+
+ return STATUS_SUCCESS;
}
-static INT CorruptISOSig(PMINI_ADAPTER Adapter, FLASH2X_SECTION_VAL eFlash2xSectionVal)
+static int CorruptISOSig(struct bcm_mini_adapter *Adapter, FLASH2X_SECTION_VAL eFlash2xSectionVal)
{
-
PUCHAR pBuff = NULL;
- UINT sig = 0;
- UINT uiOffset = 0;
+ unsigned int sig = 0;
+ unsigned int uiOffset = 0;
Adapter->bSigCorrupted = FALSE;
- if(IsSectionWritable(Adapter,eFlash2xSectionVal) != TRUE)
- {
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Section is not Writable...Hence can't Corrupt signature");
+ if (IsSectionWritable(Adapter, eFlash2xSectionVal) != TRUE) {
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Section is not Writable...Hence can't Corrupt signature");
return SECTOR_IS_NOT_WRITABLE;
}
pBuff = (PUCHAR)kzalloc(MAX_RW_SIZE, GFP_KERNEL);
- if(pBuff == NULL)
- {
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Can't allocate memorey");
- return -ENOMEM ;
+ if (!pBuff) {
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Can't allocate memorey");
+ return -ENOMEM;
}
uiOffset = 0;
- BcmFlash2xBulkRead(Adapter, (PUINT)pBuff,eFlash2xSectionVal,uiOffset, MAX_RW_SIZE);
+ BcmFlash2xBulkRead(Adapter, (PUINT)pBuff, eFlash2xSectionVal, uiOffset, MAX_RW_SIZE);
sig = *((PUINT)pBuff);
- sig =ntohl(sig);
+ sig = ntohl(sig);
- //corrupt signature
+ /* corrupt signature */
*pBuff = 0;
- if(sig == ISO_IMAGE_MAGIC_NUMBER)
- {
+ if (sig == ISO_IMAGE_MAGIC_NUMBER) {
Adapter->bSigCorrupted = TRUE;
- WriteToFlashWithoutSectorErase(Adapter,(PUINT)pBuff,eFlash2xSectionVal,
- uiOffset ,Adapter->ulFlashWriteSize);
- }
- else
- {
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"BCM Signature is not present in header");
+ WriteToFlashWithoutSectorErase(Adapter, (PUINT)pBuff, eFlash2xSectionVal,
+ uiOffset, Adapter->ulFlashWriteSize);
+ } else {
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "BCM Signature is not present in header");
kfree(pBuff);
+
return STATUS_FAILURE;
}
- BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL,"Corrupted the signature");
- BCM_DEBUG_PRINT_BUFFER(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL,pBuff,MAX_RW_SIZE);
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, "Corrupted the signature");
+ BCM_DEBUG_PRINT_BUFFER(Adapter, DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL, pBuff, MAX_RW_SIZE);
kfree(pBuff);
- return STATUS_SUCCESS ;
+ return STATUS_SUCCESS;
}
-BOOLEAN IsNonCDLessDevice(PMINI_ADAPTER Adapter)
+BOOLEAN IsNonCDLessDevice(struct bcm_mini_adapter *Adapter)
{
- if(Adapter->psFlash2xCSInfo->IsCDLessDeviceBootSig == NON_CDLESS_DEVICE_BOOT_SIG)
+ if (Adapter->psFlash2xCSInfo->IsCDLessDeviceBootSig == NON_CDLESS_DEVICE_BOOT_SIG)
return TRUE;
else
- return FALSE ;
+ return FALSE;
}
-
diff --git a/drivers/staging/bcm/sort.c b/drivers/staging/bcm/sort.c
index 63c966a02546..d518c4217f13 100644
--- a/drivers/staging/bcm/sort.c
+++ b/drivers/staging/bcm/sort.c
@@ -13,8 +13,8 @@
static int compare_packet_info(void const *a, void const *b)
{
- PacketInfo const *pa = a;
- PacketInfo const *pb = b;
+ struct bcm_packet_info const *pa = a;
+ struct bcm_packet_info const *pb = b;
if (!pa->bValid || !pb->bValid)
return 0;
@@ -22,19 +22,19 @@ static int compare_packet_info(void const *a, void const *b)
return pa->u8TrafficPriority - pb->u8TrafficPriority;
}
-VOID SortPackInfo(PMINI_ADAPTER Adapter)
+VOID SortPackInfo(struct bcm_mini_adapter *Adapter)
{
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG,
DBG_LVL_ALL, "<=======");
- sort(Adapter->PackInfo, NO_OF_QUEUES, sizeof(PacketInfo),
+ sort(Adapter->PackInfo, NO_OF_QUEUES, sizeof(struct bcm_packet_info),
compare_packet_info, NULL);
}
static int compare_classifiers(void const *a, void const *b)
{
- S_CLASSIFIER_RULE const *pa = a;
- S_CLASSIFIER_RULE const *pb = b;
+ struct bcm_classifier_rule const *pa = a;
+ struct bcm_classifier_rule const *pb = b;
if (!pa->bUsed || !pb->bUsed)
return 0;
@@ -42,11 +42,11 @@ static int compare_classifiers(void const *a, void const *b)
return pa->u8ClassifierRulePriority - pb->u8ClassifierRulePriority;
}
-VOID SortClassifiers(PMINI_ADAPTER Adapter)
+VOID SortClassifiers(struct bcm_mini_adapter *Adapter)
{
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG,
DBG_LVL_ALL, "<=======");
sort(Adapter->astClassifierTable, MAX_CLASSIFIERS,
- sizeof(S_CLASSIFIER_RULE), compare_classifiers, NULL);
+ sizeof(struct bcm_classifier_rule), compare_classifiers, NULL);
}
diff --git a/drivers/staging/bcm/vendorspecificextn.c b/drivers/staging/bcm/vendorspecificextn.c
index 4178cd161da3..833883c21a22 100644
--- a/drivers/staging/bcm/vendorspecificextn.c
+++ b/drivers/staging/bcm/vendorspecificextn.c
@@ -28,7 +28,7 @@ INT vendorextnGetSectionInfo(PVOID pContext,PFLASH2X_VENDORSPECIFIC_INFO pVendo
// STATUS_SUCCESS/STATUS_FAILURE
//
//-----------------------------------------------------------------------------
-INT vendorextnInit(PMINI_ADAPTER Adapter)
+INT vendorextnInit(struct bcm_mini_adapter *Adapter)
{
return STATUS_SUCCESS;
}
@@ -45,7 +45,7 @@ INT vendorextnInit(PMINI_ADAPTER Adapter)
// STATUS_SUCCESS/STATUS_FAILURE
//
//-----------------------------------------------------------------------------
-INT vendorextnExit(PMINI_ADAPTER Adapter)
+INT vendorextnExit(struct bcm_mini_adapter *Adapter)
{
return STATUS_SUCCESS;
}
@@ -65,7 +65,7 @@ INT vendorextnExit(PMINI_ADAPTER Adapter)
// STATUS_SUCCESS/STATUS_FAILURE as per the IOCTL return value
//
//--------------------------------------------------------------------------
-INT vendorextnIoctl(PMINI_ADAPTER Adapter, UINT cmd, ULONG arg)
+INT vendorextnIoctl(struct bcm_mini_adapter *Adapter, UINT cmd, ULONG arg)
{
return CONTINUE_COMMON_PATH;
}
diff --git a/drivers/staging/bcm/vendorspecificextn.h b/drivers/staging/bcm/vendorspecificextn.h
index 7ff14951f0ca..f237891b9f29 100644
--- a/drivers/staging/bcm/vendorspecificextn.h
+++ b/drivers/staging/bcm/vendorspecificextn.h
@@ -5,9 +5,9 @@
#define CONTINUE_COMMON_PATH 0xFFFF
INT vendorextnGetSectionInfo(PVOID pContext,PFLASH2X_VENDORSPECIFIC_INFO pVendorInfo);
-INT vendorextnExit(PMINI_ADAPTER Adapter);
-INT vendorextnInit(PMINI_ADAPTER Adapter);
-INT vendorextnIoctl(PMINI_ADAPTER Adapter, UINT cmd, ULONG arg);
+INT vendorextnExit(struct bcm_mini_adapter *Adapter);
+INT vendorextnInit(struct bcm_mini_adapter *Adapter);
+INT vendorextnIoctl(struct bcm_mini_adapter *Adapter, UINT cmd, ULONG arg);
INT vendorextnReadSection(PVOID pContext, PUCHAR pBuffer, FLASH2X_SECTION_VAL SectionVal,
UINT offset, UINT numOfBytes);
INT vendorextnWriteSection(PVOID pContext, PUCHAR pBuffer, FLASH2X_SECTION_VAL SectionVal,
diff --git a/drivers/staging/ccg/Kconfig b/drivers/staging/ccg/Kconfig
new file mode 100644
index 000000000000..1f00d701da25
--- /dev/null
+++ b/drivers/staging/ccg/Kconfig
@@ -0,0 +1,20 @@
+if USB_GADGET
+
+config USB_G_CCG
+ tristate "Configurable Composite Gadget (STAGING)"
+ depends on STAGING && BLOCK && !USB_ZERO && !USB_ZERO_HNPTEST && !USB_AUDIO && !GADGET_UAC1 && !USB_ETH && !USB_ETH_RNDIS && !USB_ETH_EEM && !USB_G_NCM && !USB_GADGETFS && !USB_FUNCTIONFS && !USB_FUNCTIONFS_ETH && !USB_FUNCTIONFS_RNDIS && !USB_FUNCTIONFS_GENERIC && !USB_FILE_STORAGE && !USB_FILE_STORAGE_TEST && !USB_MASS_STORAGE && !USB_G_SERIAL && !USB_MIDI_GADGET && !USB_G_PRINTER && !USB_CDC_COMPOSITE && !USB_G_NOKIA && !USB_G_ACM_MS && !USB_G_MULTI && !USB_G_MULTI_RNDIS && !USB_G_MULTI_CDC && !USB_G_HID && !USB_G_DBGP && !USB_G_WEBCAM
+ help
+ The Configurable Composite Gadget supports multiple USB
+ functions: acm, mass storage, rndis and FunctionFS.
+ Each function can be configured and enabled/disabled
+ dynamically from userspace through a sysfs interface.
+
+ In order to compile this (either as a module or built-in),
+ "USB Gadget Drivers" and anything under it must not be
+ selected compiled-in in
+ Device Drivers->USB Support->USB Gadget Support.
+ However, you can say "M" there, if you do, the
+ Configurable Composite Gadget can be compiled "M" only
+ or not at all.
+
+endif # USB_GADGET
diff --git a/drivers/staging/ccg/Makefile b/drivers/staging/ccg/Makefile
new file mode 100644
index 000000000000..693da637a6d8
--- /dev/null
+++ b/drivers/staging/ccg/Makefile
@@ -0,0 +1,4 @@
+g_ccg-y := ccg.o
+ccflags-y += -Idrivers/usb/gadget
+
+obj-$(CONFIG_USB_G_CCG) += g_ccg.o
diff --git a/drivers/staging/ccg/TODO b/drivers/staging/ccg/TODO
new file mode 100644
index 000000000000..18612fe70171
--- /dev/null
+++ b/drivers/staging/ccg/TODO
@@ -0,0 +1,6 @@
+TODO:
+ - change configuration interface from sysfs to configfs
+
+Please send patches to Greg Kroah-Hartmann <gregkh@linuxfoundation.org>,
+Andrzej Pietrasiewicz <andrzej.p@samsung.com>, and
+Cc: Mike Lockwood <lockwood@android.com>
diff --git a/drivers/staging/ccg/ccg.c b/drivers/staging/ccg/ccg.c
new file mode 100644
index 000000000000..6a7aab8d9bf5
--- /dev/null
+++ b/drivers/staging/ccg/ccg.c
@@ -0,0 +1,1295 @@
+/*
+ * Configurable Composite Gadget
+ *
+ * Initially contributed as "Android Composite Gdaget" by:
+ *
+ * Copyright (C) 2008 Google, Inc.
+ * Author: Mike Lockwood <lockwood@android.com>
+ * Benoit Goby <benoit@android.com>
+ *
+ * Tailoring it to become a generic Configurable Composite Gadget is
+ *
+ * Copyright (C) 2012 Samsung Electronics
+ * Author: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
+ *
+ * This software is licensed under the terms of the GNU General Public
+ * License version 2, as published by the Free Software Foundation, and
+ * may be copied, distributed, and modified under those terms.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ */
+
+#include <linux/init.h>
+#include <linux/module.h>
+#include <linux/fs.h>
+#include <linux/delay.h>
+#include <linux/kernel.h>
+#include <linux/utsname.h>
+#include <linux/platform_device.h>
+
+#include <linux/usb/ch9.h>
+#include <linux/usb/composite.h>
+#include <linux/usb/gadget.h>
+
+#include "gadget_chips.h"
+
+/*
+ * Kbuild is not very cooperative with respect to linking separately
+ * compiled library objects into one module. So for now we won't use
+ * separate compilation ... ensuring init/exit sections work to shrink
+ * the runtime footprint, and giving us at least some parts of what
+ * a "gcc --combine ... part1.c part2.c part3.c ... " build would.
+ */
+#include "../../usb/gadget/usbstring.c"
+#include "../../usb/gadget/config.c"
+#include "../../usb/gadget/epautoconf.c"
+#include "../../usb/gadget/composite.c"
+
+#include "../../usb/gadget/f_mass_storage.c"
+#include "../../usb/gadget/u_serial.c"
+#include "../../usb/gadget/f_acm.c"
+#define USB_ETH_RNDIS y
+#include "../../usb/gadget/f_rndis.c"
+#include "../../usb/gadget/rndis.c"
+#include "../../usb/gadget/u_ether.c"
+#include "../../usb/gadget/f_fs.c"
+
+MODULE_AUTHOR("Mike Lockwood, Andrzej Pietrasiewicz");
+MODULE_DESCRIPTION("Configurable Composite USB Gadget");
+MODULE_LICENSE("GPL");
+MODULE_VERSION("1.0");
+
+static const char longname[] = "Configurable Composite Gadget";
+
+/* Default vendor and product IDs, overridden by userspace */
+#define VENDOR_ID 0x1d6b /* Linux Foundation */
+#define PRODUCT_ID 0x0107
+#define GFS_MAX_DEVS 10
+
+struct ccg_usb_function {
+ char *name;
+ void *config;
+
+ struct device *dev;
+ char *dev_name;
+ struct device_attribute **attributes;
+
+ /* for ccg_dev.enabled_functions */
+ struct list_head enabled_list;
+
+ /* Optional: initialization during gadget bind */
+ int (*init)(struct ccg_usb_function *, struct usb_composite_dev *);
+ /* Optional: cleanup during gadget unbind */
+ void (*cleanup)(struct ccg_usb_function *);
+
+ int (*bind_config)(struct ccg_usb_function *,
+ struct usb_configuration *);
+
+ /* Optional: called when the configuration is removed */
+ void (*unbind_config)(struct ccg_usb_function *,
+ struct usb_configuration *);
+ /* Optional: handle ctrl requests before the device is configured */
+ int (*ctrlrequest)(struct ccg_usb_function *,
+ struct usb_composite_dev *,
+ const struct usb_ctrlrequest *);
+};
+
+struct ffs_obj {
+ const char *name;
+ bool mounted;
+ bool desc_ready;
+ bool used;
+ struct ffs_data *ffs_data;
+};
+
+struct ccg_dev {
+ struct ccg_usb_function **functions;
+ struct list_head enabled_functions;
+ struct usb_composite_dev *cdev;
+ struct device *dev;
+
+ bool enabled;
+ struct mutex mutex;
+ bool connected;
+ bool sw_connected;
+ struct work_struct work;
+
+ unsigned int max_func_num;
+ unsigned int func_num;
+ struct ffs_obj ffs_tab[GFS_MAX_DEVS];
+};
+
+static struct class *ccg_class;
+static struct ccg_dev *_ccg_dev;
+static int ccg_bind_config(struct usb_configuration *c);
+static void ccg_unbind_config(struct usb_configuration *c);
+
+static char func_names_buf[256];
+
+static struct usb_device_descriptor device_desc = {
+ .bLength = sizeof(device_desc),
+ .bDescriptorType = USB_DT_DEVICE,
+ .bcdUSB = __constant_cpu_to_le16(0x0200),
+ .bDeviceClass = USB_CLASS_PER_INTERFACE,
+ .idVendor = __constant_cpu_to_le16(VENDOR_ID),
+ .idProduct = __constant_cpu_to_le16(PRODUCT_ID),
+ .bcdDevice = __constant_cpu_to_le16(0xffff),
+ .bNumConfigurations = 1,
+};
+
+static struct usb_configuration ccg_config_driver = {
+ .label = "ccg",
+ .unbind = ccg_unbind_config,
+ .bConfigurationValue = 1,
+ .bmAttributes = USB_CONFIG_ATT_ONE | USB_CONFIG_ATT_SELFPOWER,
+ .bMaxPower = 0xFA, /* 500ma */
+};
+
+static void ccg_work(struct work_struct *data)
+{
+ struct ccg_dev *dev = container_of(data, struct ccg_dev, work);
+ struct usb_composite_dev *cdev = dev->cdev;
+ static char *disconnected[2] = { "USB_STATE=DISCONNECTED", NULL };
+ static char *connected[2] = { "USB_STATE=CONNECTED", NULL };
+ static char *configured[2] = { "USB_STATE=CONFIGURED", NULL };
+ char **uevent_envp = NULL;
+ unsigned long flags;
+
+ spin_lock_irqsave(&cdev->lock, flags);
+ if (cdev->config)
+ uevent_envp = configured;
+ else if (dev->connected != dev->sw_connected)
+ uevent_envp = dev->connected ? connected : disconnected;
+ dev->sw_connected = dev->connected;
+ spin_unlock_irqrestore(&cdev->lock, flags);
+
+ if (uevent_envp) {
+ kobject_uevent_env(&dev->dev->kobj, KOBJ_CHANGE, uevent_envp);
+ pr_info("%s: sent uevent %s\n", __func__, uevent_envp[0]);
+ } else {
+ pr_info("%s: did not send uevent (%d %d %p)\n", __func__,
+ dev->connected, dev->sw_connected, cdev->config);
+ }
+}
+
+
+/*-------------------------------------------------------------------------*/
+/* Supported functions initialization */
+
+static struct ffs_obj *functionfs_find_dev(struct ccg_dev *dev,
+ const char *dev_name)
+{
+ int i;
+
+ for (i = 0; i < dev->max_func_num; i++)
+ if (strcmp(dev->ffs_tab[i].name, dev_name) == 0)
+ return &dev->ffs_tab[i];
+
+ return NULL;
+}
+
+static bool functionfs_all_ready(struct ccg_dev *dev)
+{
+ int i;
+
+ for (i = 0; i < dev->max_func_num; i++)
+ if (dev->ffs_tab[i].used && !dev->ffs_tab[i].desc_ready)
+ return false;
+
+ return true;
+}
+
+static int functionfs_ready_callback(struct ffs_data *ffs)
+{
+ struct ffs_obj *ffs_obj;
+ int ret;
+
+ mutex_lock(&_ccg_dev->mutex);
+
+ ffs_obj = ffs->private_data;
+ if (!ffs_obj) {
+ ret = -EINVAL;
+ goto done;
+ }
+ if (WARN_ON(ffs_obj->desc_ready)) {
+ ret = -EBUSY;
+ goto done;
+ }
+ ffs_obj->ffs_data = ffs;
+
+ if (functionfs_all_ready(_ccg_dev)) {
+ ret = -EBUSY;
+ goto done;
+ }
+ ffs_obj->desc_ready = true;
+
+done:
+ mutex_unlock(&_ccg_dev->mutex);
+ return ret;
+}
+
+static void reset_usb(struct ccg_dev *dev)
+{
+ /* Cancel pending control requests */
+ usb_ep_dequeue(dev->cdev->gadget->ep0, dev->cdev->req);
+ usb_remove_config(dev->cdev, &ccg_config_driver);
+ dev->enabled = false;
+ usb_gadget_disconnect(dev->cdev->gadget);
+}
+
+static void functionfs_closed_callback(struct ffs_data *ffs)
+{
+ struct ffs_obj *ffs_obj;
+
+ mutex_lock(&_ccg_dev->mutex);
+
+ ffs_obj = ffs->private_data;
+ if (!ffs_obj)
+ goto done;
+
+ ffs_obj->desc_ready = false;
+
+ if (_ccg_dev->enabled)
+ reset_usb(_ccg_dev);
+
+done:
+ mutex_unlock(&_ccg_dev->mutex);
+}
+
+static void *functionfs_acquire_dev_callback(const char *dev_name)
+{
+ struct ffs_obj *ffs_dev;
+
+ mutex_lock(&_ccg_dev->mutex);
+
+ ffs_dev = functionfs_find_dev(_ccg_dev, dev_name);
+ if (!ffs_dev) {
+ ffs_dev = ERR_PTR(-ENODEV);
+ goto done;
+ }
+
+ if (ffs_dev->mounted) {
+ ffs_dev = ERR_PTR(-EBUSY);
+ goto done;
+ }
+ ffs_dev->mounted = true;
+
+done:
+ mutex_unlock(&_ccg_dev->mutex);
+ return ffs_dev;
+}
+
+static void functionfs_release_dev_callback(struct ffs_data *ffs_data)
+{
+ struct ffs_obj *ffs_dev;
+
+ mutex_lock(&_ccg_dev->mutex);
+
+ ffs_dev = ffs_data->private_data;
+ if (ffs_dev)
+ ffs_dev->mounted = false;
+
+ mutex_unlock(&_ccg_dev->mutex);
+}
+
+static int functionfs_function_init(struct ccg_usb_function *f,
+ struct usb_composite_dev *cdev)
+{
+ return functionfs_init();
+}
+
+static void functionfs_function_cleanup(struct ccg_usb_function *f)
+{
+ functionfs_cleanup();
+}
+
+static int functionfs_function_bind_config(struct ccg_usb_function *f,
+ struct usb_configuration *c)
+{
+ struct ccg_dev *dev = _ccg_dev;
+ int i, ret;
+
+ for (i = dev->max_func_num; i--; ) {
+ if (!dev->ffs_tab[i].used)
+ continue;
+ ret = functionfs_bind(dev->ffs_tab[i].ffs_data, c->cdev);
+ if (unlikely(ret < 0)) {
+ while (++i < dev->max_func_num)
+ functionfs_unbind(dev->ffs_tab[i].ffs_data);
+ return ret;
+ }
+ }
+
+ for (i = dev->max_func_num; i--; ) {
+ if (!dev->ffs_tab[i].used)
+ continue;
+ ret = functionfs_bind_config(c->cdev, c,
+ dev->ffs_tab[i].ffs_data);
+ if (unlikely(ret < 0))
+ return ret;
+ }
+
+ return 0;
+}
+
+static void functionfs_function_unbind_config(struct ccg_usb_function *f,
+ struct usb_configuration *c)
+{
+ struct ccg_dev *dev = _ccg_dev;
+ int i;
+
+ for (i = dev->max_func_num; i--; )
+ if (dev->ffs_tab[i].ffs_data)
+ functionfs_unbind(dev->ffs_tab[i].ffs_data);
+}
+
+static ssize_t functionfs_user_functions_show(struct device *_dev,
+ struct device_attribute *attr,
+ char *buf)
+{
+ struct ccg_dev *dev = _ccg_dev;
+ char *buff = buf;
+ int i;
+
+ mutex_lock(&dev->mutex);
+
+ for (i = 0; i < dev->max_func_num; i++)
+ buff += snprintf(buff, PAGE_SIZE + buf - buff, "%s,",
+ dev->ffs_tab[i].name);
+
+ mutex_unlock(&dev->mutex);
+
+ if (buff != buf)
+ *(buff - 1) = '\n';
+ return buff - buf;
+}
+
+static ssize_t functionfs_user_functions_store(struct device *_dev,
+ struct device_attribute *attr,
+ const char *buff, size_t size)
+{
+ struct ccg_dev *dev = _ccg_dev;
+ char *name, *b;
+ ssize_t ret = size;
+ int i;
+
+ buff = skip_spaces(buff);
+ if (!*buff)
+ return -EINVAL;
+
+ mutex_lock(&dev->mutex);
+
+ if (dev->enabled) {
+ ret = -EBUSY;
+ goto end;
+ }
+
+ for (i = 0; i < dev->max_func_num; i++)
+ if (dev->ffs_tab[i].mounted) {
+ ret = -EBUSY;
+ goto end;
+ }
+
+ strlcpy(func_names_buf, buff, sizeof(func_names_buf));
+ b = strim(func_names_buf);
+
+ /* replace the list of functions */
+ dev->max_func_num = 0;
+ while (b) {
+ name = strsep(&b, ",");
+ if (dev->max_func_num == GFS_MAX_DEVS) {
+ ret = -ENOSPC;
+ goto end;
+ }
+ if (functionfs_find_dev(dev, name)) {
+ ret = -EEXIST;
+ continue;
+ }
+ dev->ffs_tab[dev->max_func_num++].name = name;
+ }
+
+end:
+ mutex_unlock(&dev->mutex);
+ return ret;
+}
+
+static DEVICE_ATTR(user_functions, S_IRUGO | S_IWUSR,
+ functionfs_user_functions_show,
+ functionfs_user_functions_store);
+
+static ssize_t functionfs_max_user_functions_show(struct device *_dev,
+ struct device_attribute *attr,
+ char *buf)
+{
+ return sprintf(buf, "%d", GFS_MAX_DEVS);
+}
+
+static DEVICE_ATTR(max_user_functions, S_IRUGO,
+ functionfs_max_user_functions_show, NULL);
+
+static struct device_attribute *functionfs_function_attributes[] = {
+ &dev_attr_user_functions,
+ &dev_attr_max_user_functions,
+ NULL
+};
+
+static struct ccg_usb_function functionfs_function = {
+ .name = "fs",
+ .init = functionfs_function_init,
+ .cleanup = functionfs_function_cleanup,
+ .bind_config = functionfs_function_bind_config,
+ .unbind_config = functionfs_function_unbind_config,
+ .attributes = functionfs_function_attributes,
+};
+
+#define MAX_ACM_INSTANCES 4
+struct acm_function_config {
+ int instances;
+};
+
+static int
+acm_function_init(struct ccg_usb_function *f, struct usb_composite_dev *cdev)
+{
+ f->config = kzalloc(sizeof(struct acm_function_config), GFP_KERNEL);
+ if (!f->config)
+ return -ENOMEM;
+
+ return gserial_setup(cdev->gadget, MAX_ACM_INSTANCES);
+}
+
+static void acm_function_cleanup(struct ccg_usb_function *f)
+{
+ gserial_cleanup();
+ kfree(f->config);
+ f->config = NULL;
+}
+
+static int
+acm_function_bind_config(struct ccg_usb_function *f,
+ struct usb_configuration *c)
+{
+ int i;
+ int ret = 0;
+ struct acm_function_config *config = f->config;
+
+ for (i = 0; i < config->instances; i++) {
+ ret = acm_bind_config(c, i);
+ if (ret) {
+ pr_err("Could not bind acm%u config\n", i);
+ break;
+ }
+ }
+
+ return ret;
+}
+
+static ssize_t acm_instances_show(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+ struct ccg_usb_function *f = dev_get_drvdata(dev);
+ struct acm_function_config *config = f->config;
+ return sprintf(buf, "%d\n", config->instances);
+}
+
+static ssize_t acm_instances_store(struct device *dev,
+ struct device_attribute *attr, const char *buf, size_t size)
+{
+ struct ccg_usb_function *f = dev_get_drvdata(dev);
+ struct acm_function_config *config = f->config;
+ int value;
+ int ret = 0;
+
+ ret = kstrtoint(buf, 10, &value);
+ if (ret)
+ return ret;
+
+ if (value > MAX_ACM_INSTANCES)
+ return -EINVAL;
+
+ config->instances = value;
+
+ return size;
+}
+
+static DEVICE_ATTR(instances, S_IRUGO | S_IWUSR, acm_instances_show,
+ acm_instances_store);
+static struct device_attribute *acm_function_attributes[] = {
+ &dev_attr_instances,
+ NULL
+};
+
+static struct ccg_usb_function acm_function = {
+ .name = "acm",
+ .init = acm_function_init,
+ .cleanup = acm_function_cleanup,
+ .bind_config = acm_function_bind_config,
+ .attributes = acm_function_attributes,
+};
+
+struct rndis_function_config {
+ u8 ethaddr[ETH_ALEN];
+ u32 vendorID;
+ char manufacturer[256];
+ /* "Wireless" RNDIS; auto-detected by Windows */
+ bool wceis;
+};
+
+static int rndis_function_init(struct ccg_usb_function *f,
+ struct usb_composite_dev *cdev)
+{
+ f->config = kzalloc(sizeof(struct rndis_function_config), GFP_KERNEL);
+ if (!f->config)
+ return -ENOMEM;
+ return 0;
+}
+
+static void rndis_function_cleanup(struct ccg_usb_function *f)
+{
+ kfree(f->config);
+ f->config = NULL;
+}
+
+static int rndis_function_bind_config(struct ccg_usb_function *f,
+ struct usb_configuration *c)
+{
+ int ret;
+ struct rndis_function_config *rndis = f->config;
+
+ if (!rndis) {
+ pr_err("%s: rndis_pdata\n", __func__);
+ return -1;
+ }
+
+ pr_info("%s MAC: %pM\n", __func__, rndis->ethaddr);
+
+ ret = gether_setup_name(c->cdev->gadget, rndis->ethaddr, "rndis");
+ if (ret) {
+ pr_err("%s: gether_setup failed\n", __func__);
+ return ret;
+ }
+
+ if (rndis->wceis) {
+ /* "Wireless" RNDIS; auto-detected by Windows */
+ rndis_iad_descriptor.bFunctionClass =
+ USB_CLASS_WIRELESS_CONTROLLER;
+ rndis_iad_descriptor.bFunctionSubClass = 0x01;
+ rndis_iad_descriptor.bFunctionProtocol = 0x03;
+ rndis_control_intf.bInterfaceClass =
+ USB_CLASS_WIRELESS_CONTROLLER;
+ rndis_control_intf.bInterfaceSubClass = 0x01;
+ rndis_control_intf.bInterfaceProtocol = 0x03;
+ }
+
+ return rndis_bind_config_vendor(c, rndis->ethaddr, rndis->vendorID,
+ rndis->manufacturer);
+}
+
+static void rndis_function_unbind_config(struct ccg_usb_function *f,
+ struct usb_configuration *c)
+{
+ gether_cleanup();
+}
+
+static ssize_t rndis_manufacturer_show(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+ struct ccg_usb_function *f = dev_get_drvdata(dev);
+ struct rndis_function_config *config = f->config;
+ return sprintf(buf, "%s\n", config->manufacturer);
+}
+
+static ssize_t rndis_manufacturer_store(struct device *dev,
+ struct device_attribute *attr, const char *buf, size_t size)
+{
+ struct ccg_usb_function *f = dev_get_drvdata(dev);
+ struct rndis_function_config *config = f->config;
+
+ if (size >= sizeof(config->manufacturer))
+ return -EINVAL;
+ memcpy(config->manufacturer, buf, size);
+ config->manufacturer[size] = 0;
+
+ return size;
+}
+
+static DEVICE_ATTR(manufacturer, S_IRUGO | S_IWUSR, rndis_manufacturer_show,
+ rndis_manufacturer_store);
+
+static ssize_t rndis_wceis_show(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+ struct ccg_usb_function *f = dev_get_drvdata(dev);
+ struct rndis_function_config *config = f->config;
+ return sprintf(buf, "%d\n", config->wceis);
+}
+
+static ssize_t rndis_wceis_store(struct device *dev,
+ struct device_attribute *attr, const char *buf, size_t size)
+{
+ struct ccg_usb_function *f = dev_get_drvdata(dev);
+ struct rndis_function_config *config = f->config;
+ int value;
+ int ret;
+
+ ret = kstrtoint(buf, 10, &value);
+ if (ret)
+ return ret;
+
+ config->wceis = value;
+
+ return size;
+}
+
+static DEVICE_ATTR(wceis, S_IRUGO | S_IWUSR, rndis_wceis_show,
+ rndis_wceis_store);
+
+static ssize_t rndis_ethaddr_show(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+ struct ccg_usb_function *f = dev_get_drvdata(dev);
+ struct rndis_function_config *rndis = f->config;
+ return sprintf(buf, "%pM\n", rndis->ethaddr);
+}
+
+static ssize_t rndis_ethaddr_store(struct device *dev,
+ struct device_attribute *attr, const char *buf, size_t size)
+{
+ struct ccg_usb_function *f = dev_get_drvdata(dev);
+ struct rndis_function_config *rndis = f->config;
+ unsigned char tmp[6];
+
+ if (sscanf(buf, "%hhx:%hhx:%hhx:%hhx:%hhx:%hhx",
+ tmp + 0, tmp + 1, tmp + 2, tmp + 3, tmp + 4, tmp + 5) !=
+ ETH_ALEN)
+ return -EINVAL;
+
+ memcpy(rndis->ethaddr, tmp, ETH_ALEN);
+
+ return ETH_ALEN;
+
+}
+
+static DEVICE_ATTR(ethaddr, S_IRUGO | S_IWUSR, rndis_ethaddr_show,
+ rndis_ethaddr_store);
+
+static ssize_t rndis_vendorID_show(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+ struct ccg_usb_function *f = dev_get_drvdata(dev);
+ struct rndis_function_config *config = f->config;
+ return sprintf(buf, "%04x\n", config->vendorID);
+}
+
+static ssize_t rndis_vendorID_store(struct device *dev,
+ struct device_attribute *attr, const char *buf, size_t size)
+{
+ struct ccg_usb_function *f = dev_get_drvdata(dev);
+ struct rndis_function_config *config = f->config;
+ int value;
+ int ret;
+
+ ret = kstrtou32(buf, 16, &value);
+ if (ret)
+ return ret;
+
+ config->vendorID = value;
+
+ return size;
+}
+
+static DEVICE_ATTR(vendorID, S_IRUGO | S_IWUSR, rndis_vendorID_show,
+ rndis_vendorID_store);
+
+static struct device_attribute *rndis_function_attributes[] = {
+ &dev_attr_manufacturer,
+ &dev_attr_wceis,
+ &dev_attr_ethaddr,
+ &dev_attr_vendorID,
+ NULL
+};
+
+static struct ccg_usb_function rndis_function = {
+ .name = "rndis",
+ .init = rndis_function_init,
+ .cleanup = rndis_function_cleanup,
+ .bind_config = rndis_function_bind_config,
+ .unbind_config = rndis_function_unbind_config,
+ .attributes = rndis_function_attributes,
+};
+
+static int mass_storage_function_init(struct ccg_usb_function *f,
+ struct usb_composite_dev *cdev)
+{
+ struct fsg_config fsg;
+ struct fsg_common *common;
+ int err;
+
+ memset(&fsg, 0, sizeof fsg);
+ fsg.nluns = 1;
+ fsg.luns[0].removable = 1;
+ fsg.vendor_name = iManufacturer;
+ fsg.product_name = iProduct;
+
+ common = fsg_common_init(NULL, cdev, &fsg);
+ if (IS_ERR(common))
+ return PTR_ERR(common);
+
+ err = sysfs_create_link(&f->dev->kobj,
+ &common->luns[0].dev.kobj,
+ "lun");
+ if (err) {
+ fsg_common_put(common);
+ return err;
+ }
+
+ f->config = common;
+ return 0;
+}
+
+static void mass_storage_function_cleanup(struct ccg_usb_function *f)
+{
+ fsg_common_put(f->config);
+ f->config = NULL;
+}
+
+static int mass_storage_function_bind_config(struct ccg_usb_function *f,
+ struct usb_configuration *c)
+{
+ struct fsg_common *common = f->config;
+ return fsg_bind_config(c->cdev, c, common);
+}
+
+static struct ccg_usb_function mass_storage_function = {
+ .name = "mass_storage",
+ .init = mass_storage_function_init,
+ .cleanup = mass_storage_function_cleanup,
+ .bind_config = mass_storage_function_bind_config,
+};
+
+static struct ccg_usb_function *supported_functions[] = {
+ &functionfs_function,
+ &acm_function,
+ &rndis_function,
+ &mass_storage_function,
+ NULL
+};
+
+
+static int ccg_init_functions(struct ccg_usb_function **functions,
+ struct usb_composite_dev *cdev)
+{
+ struct ccg_dev *dev = _ccg_dev;
+ struct ccg_usb_function *f;
+ struct device_attribute **attrs;
+ struct device_attribute *attr;
+ int err;
+ int index = 0;
+
+ for (; (f = *functions++); index++) {
+ f->dev_name = kasprintf(GFP_KERNEL, "f_%s", f->name);
+ if (!f->dev_name) {
+ pr_err("%s: Failed to alloc name %s", __func__,
+ f->name);
+ err = -ENOMEM;
+ goto err_alloc;
+ }
+ f->dev = device_create(ccg_class, dev->dev,
+ MKDEV(0, index), f, f->dev_name);
+ if (IS_ERR(f->dev)) {
+ pr_err("%s: Failed to create dev %s", __func__,
+ f->dev_name);
+ err = PTR_ERR(f->dev);
+ f->dev = NULL;
+ goto err_create;
+ }
+
+ if (f->init) {
+ err = f->init(f, cdev);
+ if (err) {
+ pr_err("%s: Failed to init %s", __func__,
+ f->name);
+ goto err_out;
+ }
+ }
+
+ attrs = f->attributes;
+ if (attrs) {
+ while ((attr = *attrs++) && !err)
+ err = device_create_file(f->dev, attr);
+ }
+ if (err) {
+ pr_err("%s: Failed to create function %s attributes",
+ __func__, f->name);
+ goto err_uninit;
+ }
+ }
+ return 0;
+
+err_uninit:
+ if (f->cleanup)
+ f->cleanup(f);
+err_out:
+ device_destroy(ccg_class, f->dev->devt);
+ f->dev = NULL;
+err_create:
+ kfree(f->dev_name);
+err_alloc:
+ return err;
+}
+
+static void ccg_cleanup_functions(struct ccg_usb_function **functions)
+{
+ struct ccg_usb_function *f;
+
+ while (*functions) {
+ f = *functions++;
+
+ if (f->dev) {
+ if (f->cleanup)
+ f->cleanup(f);
+ device_destroy(ccg_class, f->dev->devt);
+ kfree(f->dev_name);
+ }
+ }
+}
+
+static int ccg_bind_enabled_functions(struct ccg_dev *dev,
+ struct usb_configuration *c)
+{
+ struct ccg_usb_function *f;
+ int ret;
+
+ list_for_each_entry(f, &dev->enabled_functions, enabled_list) {
+ ret = f->bind_config(f, c);
+ if (ret) {
+ pr_err("%s: %s failed", __func__, f->name);
+ return ret;
+ }
+ }
+ return 0;
+}
+
+static void ccg_unbind_enabled_functions(struct ccg_dev *dev,
+ struct usb_configuration *c)
+{
+ struct ccg_usb_function *f;
+
+ list_for_each_entry(f, &dev->enabled_functions, enabled_list)
+ if (f->unbind_config)
+ f->unbind_config(f, c);
+}
+
+static int ccg_enable_function(struct ccg_dev *dev, char *name)
+{
+ struct ccg_usb_function **functions = dev->functions;
+ struct ccg_usb_function *f;
+ while ((f = *functions++)) {
+ if (!strcmp(name, f->name)) {
+ list_add_tail(&f->enabled_list,
+ &dev->enabled_functions);
+ return 0;
+ }
+ }
+ return -EINVAL;
+}
+
+/*-------------------------------------------------------------------------*/
+/* /sys/class/ccg_usb/ccg%d/ interface */
+
+static ssize_t
+functions_show(struct device *pdev, struct device_attribute *attr, char *buf)
+{
+ struct ccg_dev *dev = dev_get_drvdata(pdev);
+ struct ccg_usb_function *f;
+ char *buff = buf;
+ int i;
+
+ mutex_lock(&dev->mutex);
+
+ list_for_each_entry(f, &dev->enabled_functions, enabled_list)
+ buff += sprintf(buff, "%s,", f->name);
+ for (i = 0; i < dev->max_func_num; i++)
+ if (dev->ffs_tab[i].used)
+ buff += sprintf(buff, "%s", dev->ffs_tab[i].name);
+
+ mutex_unlock(&dev->mutex);
+
+ if (buff != buf)
+ *(buff-1) = '\n';
+ return buff - buf;
+}
+
+static ssize_t
+functions_store(struct device *pdev, struct device_attribute *attr,
+ const char *buff, size_t size)
+{
+ struct ccg_dev *dev = dev_get_drvdata(pdev);
+ char *name;
+ char buf[256], *b;
+ int err, i;
+ bool functionfs_enabled;
+
+ buff = skip_spaces(buff);
+ if (!*buff)
+ return -EINVAL;
+
+ mutex_lock(&dev->mutex);
+
+ if (dev->enabled) {
+ mutex_unlock(&dev->mutex);
+ return -EBUSY;
+ }
+
+ INIT_LIST_HEAD(&dev->enabled_functions);
+ functionfs_enabled = false;
+ for (i = 0; i < dev->max_func_num; i++)
+ dev->ffs_tab[i].used = false;
+
+ strlcpy(buf, buff, sizeof(buf));
+ b = strim(buf);
+
+ while (b) {
+ struct ffs_obj *user_func;
+
+ name = strsep(&b, ",");
+ /* handle FunctionFS implicitly */
+ if (!strcmp(name, functionfs_function.name)) {
+ pr_err("ccg_usb: Cannot explicitly enable '%s'", name);
+ continue;
+ }
+ user_func = functionfs_find_dev(dev, name);
+ if (user_func)
+ name = functionfs_function.name;
+ err = 0;
+ if (!user_func || !functionfs_enabled)
+ err = ccg_enable_function(dev, name);
+ if (err)
+ pr_err("ccg_usb: Cannot enable '%s'", name);
+ else if (user_func) {
+ user_func->used = true;
+ dev->func_num++;
+ functionfs_enabled = true;
+ }
+ }
+
+ mutex_unlock(&dev->mutex);
+
+ return size;
+}
+
+static ssize_t enable_show(struct device *pdev, struct device_attribute *attr,
+ char *buf)
+{
+ struct ccg_dev *dev = dev_get_drvdata(pdev);
+ return sprintf(buf, "%d\n", dev->enabled);
+}
+
+static ssize_t enable_store(struct device *pdev, struct device_attribute *attr,
+ const char *buff, size_t size)
+{
+ struct ccg_dev *dev = dev_get_drvdata(pdev);
+ struct usb_composite_dev *cdev = dev->cdev;
+ int enabled = 0;
+
+ mutex_lock(&dev->mutex);
+ sscanf(buff, "%d", &enabled);
+ if (enabled && dev->func_num && !functionfs_all_ready(dev)) {
+ mutex_unlock(&dev->mutex);
+ return -ENODEV;
+ }
+
+ if (enabled && !dev->enabled) {
+ int ret;
+
+ cdev->next_string_id = 0;
+ /*
+ * Update values in composite driver's copy of
+ * device descriptor.
+ */
+ cdev->desc.bDeviceClass = device_desc.bDeviceClass;
+ cdev->desc.bDeviceSubClass = device_desc.bDeviceSubClass;
+ cdev->desc.bDeviceProtocol = device_desc.bDeviceProtocol;
+ cdev->desc.idVendor = idVendor;
+ cdev->desc.idProduct = idProduct;
+ cdev->desc.bcdDevice = bcdDevice;
+
+ usb_add_config(cdev, &ccg_config_driver, ccg_bind_config);
+ dev->enabled = true;
+ ret = usb_gadget_connect(cdev->gadget);
+ if (ret) {
+ dev->enabled = false;
+ usb_remove_config(cdev, &ccg_config_driver);
+ }
+ } else if (!enabled && dev->enabled) {
+ reset_usb(dev);
+ } else {
+ pr_err("ccg_usb: already %s\n",
+ dev->enabled ? "enabled" : "disabled");
+ }
+
+ mutex_unlock(&dev->mutex);
+ return size;
+}
+
+static ssize_t state_show(struct device *pdev, struct device_attribute *attr,
+ char *buf)
+{
+ struct ccg_dev *dev = dev_get_drvdata(pdev);
+ struct usb_composite_dev *cdev = dev->cdev;
+ char *state = "DISCONNECTED";
+ unsigned long flags;
+
+ if (!cdev)
+ goto out;
+
+ spin_lock_irqsave(&cdev->lock, flags);
+ if (cdev->config)
+ state = "CONFIGURED";
+ else if (dev->connected)
+ state = "CONNECTED";
+ spin_unlock_irqrestore(&cdev->lock, flags);
+out:
+ return sprintf(buf, "%s\n", state);
+}
+
+#define DESCRIPTOR_ATTR(field, format_string) \
+static ssize_t \
+field ## _show(struct device *dev, struct device_attribute *attr, \
+ char *buf) \
+{ \
+ return sprintf(buf, format_string, device_desc.field); \
+} \
+static ssize_t \
+field ## _store(struct device *dev, struct device_attribute *attr, \
+ const char *buf, size_t size) \
+{ \
+ int value; \
+ if (sscanf(buf, format_string, &value) == 1) { \
+ device_desc.field = value; \
+ return size; \
+ } \
+ return -1; \
+} \
+static DEVICE_ATTR(field, S_IRUGO | S_IWUSR, field ## _show, field ## _store);
+
+DESCRIPTOR_ATTR(bDeviceClass, "%d\n")
+DESCRIPTOR_ATTR(bDeviceSubClass, "%d\n")
+DESCRIPTOR_ATTR(bDeviceProtocol, "%d\n")
+
+static DEVICE_ATTR(functions, S_IRUGO | S_IWUSR, functions_show,
+ functions_store);
+static DEVICE_ATTR(enable, S_IRUGO | S_IWUSR, enable_show, enable_store);
+static DEVICE_ATTR(state, S_IRUGO, state_show, NULL);
+
+static struct device_attribute *ccg_usb_attributes[] = {
+ &dev_attr_bDeviceClass,
+ &dev_attr_bDeviceSubClass,
+ &dev_attr_bDeviceProtocol,
+ &dev_attr_functions,
+ &dev_attr_enable,
+ &dev_attr_state,
+ NULL
+};
+
+/*-------------------------------------------------------------------------*/
+/* Composite driver */
+
+static int ccg_bind_config(struct usb_configuration *c)
+{
+ struct ccg_dev *dev = _ccg_dev;
+ int ret = 0;
+
+ ret = ccg_bind_enabled_functions(dev, c);
+ if (ret)
+ return ret;
+
+ return 0;
+}
+
+static void ccg_unbind_config(struct usb_configuration *c)
+{
+ struct ccg_dev *dev = _ccg_dev;
+
+ ccg_unbind_enabled_functions(dev, c);
+
+ usb_ep_autoconfig_reset(dev->cdev->gadget);
+}
+
+static int ccg_bind(struct usb_composite_dev *cdev)
+{
+ struct ccg_dev *dev = _ccg_dev;
+ struct usb_gadget *gadget = cdev->gadget;
+ int gcnum, ret;
+
+ /*
+ * Start disconnected. Userspace will connect the gadget once
+ * it is done configuring the functions.
+ */
+ usb_gadget_disconnect(gadget);
+
+ ret = ccg_init_functions(dev->functions, cdev);
+ if (ret)
+ return ret;
+
+ gcnum = usb_gadget_controller_number(gadget);
+ if (gcnum >= 0)
+ device_desc.bcdDevice = cpu_to_le16(0x0200 + gcnum);
+ else {
+ pr_warn("%s: controller '%s' not recognized\n",
+ longname, gadget->name);
+ device_desc.bcdDevice = __constant_cpu_to_le16(0x9999);
+ }
+
+ usb_gadget_set_selfpowered(gadget);
+ dev->cdev = cdev;
+
+ return 0;
+}
+
+static int ccg_usb_unbind(struct usb_composite_dev *cdev)
+{
+ struct ccg_dev *dev = _ccg_dev;
+
+ cancel_work_sync(&dev->work);
+ ccg_cleanup_functions(dev->functions);
+ return 0;
+}
+
+static struct usb_composite_driver ccg_usb_driver = {
+ .name = "configurable_usb",
+ .dev = &device_desc,
+ .unbind = ccg_usb_unbind,
+ .needs_serial = true,
+ .iManufacturer = "Linux Foundation",
+ .iProduct = longname,
+ .iSerialNumber = "1234567890123456",
+};
+
+static int ccg_setup(struct usb_gadget *gadget, const struct usb_ctrlrequest *c)
+{
+ struct ccg_dev *dev = _ccg_dev;
+ struct usb_composite_dev *cdev = get_gadget_data(gadget);
+ struct usb_request *req = cdev->req;
+ struct ccg_usb_function *f;
+ int value = -EOPNOTSUPP;
+ unsigned long flags;
+
+ req->zero = 0;
+ req->complete = composite_setup_complete;
+ req->length = 0;
+ gadget->ep0->driver_data = cdev;
+
+ list_for_each_entry(f, &dev->enabled_functions, enabled_list) {
+ if (f->ctrlrequest) {
+ value = f->ctrlrequest(f, cdev, c);
+ if (value >= 0)
+ break;
+ }
+ }
+
+ if (value < 0)
+ value = composite_setup(gadget, c);
+
+ spin_lock_irqsave(&cdev->lock, flags);
+ if (!dev->connected) {
+ dev->connected = 1;
+ schedule_work(&dev->work);
+ } else if (c->bRequest == USB_REQ_SET_CONFIGURATION &&
+ cdev->config) {
+ schedule_work(&dev->work);
+ }
+ spin_unlock_irqrestore(&cdev->lock, flags);
+
+ return value;
+}
+
+static void ccg_disconnect(struct usb_gadget *gadget)
+{
+ struct ccg_dev *dev = _ccg_dev;
+ struct usb_composite_dev *cdev = get_gadget_data(gadget);
+ unsigned long flags;
+
+ composite_disconnect(gadget);
+
+ spin_lock_irqsave(&cdev->lock, flags);
+ dev->connected = 0;
+ schedule_work(&dev->work);
+ spin_unlock_irqrestore(&cdev->lock, flags);
+}
+
+static int ccg_create_device(struct ccg_dev *dev)
+{
+ struct device_attribute **attrs = ccg_usb_attributes;
+ struct device_attribute *attr;
+ int err;
+
+ dev->dev = device_create(ccg_class, NULL, MKDEV(0, 0), NULL, "ccg0");
+ if (IS_ERR(dev->dev))
+ return PTR_ERR(dev->dev);
+
+ dev_set_drvdata(dev->dev, dev);
+
+ while ((attr = *attrs++)) {
+ err = device_create_file(dev->dev, attr);
+ if (err) {
+ device_destroy(ccg_class, dev->dev->devt);
+ return err;
+ }
+ }
+ return 0;
+}
+
+
+static int __init init(void)
+{
+ struct ccg_dev *dev;
+ int err;
+
+ ccg_class = class_create(THIS_MODULE, "ccg_usb");
+ if (IS_ERR(ccg_class))
+ return PTR_ERR(ccg_class);
+
+ dev = kzalloc(sizeof(*dev), GFP_KERNEL);
+ if (!dev)
+ return -ENOMEM;
+
+ dev->functions = supported_functions;
+ INIT_LIST_HEAD(&dev->enabled_functions);
+ INIT_WORK(&dev->work, ccg_work);
+ mutex_init(&dev->mutex);
+
+ err = ccg_create_device(dev);
+ if (err) {
+ class_destroy(ccg_class);
+ kfree(dev);
+ return err;
+ }
+
+ _ccg_dev = dev;
+
+ /* Override composite driver functions */
+ composite_driver.setup = ccg_setup;
+ composite_driver.disconnect = ccg_disconnect;
+
+ err = usb_composite_probe(&ccg_usb_driver, ccg_bind);
+ if (err) {
+ class_destroy(ccg_class);
+ kfree(dev);
+ }
+
+ return err;
+}
+module_init(init);
+
+static void __exit cleanup(void)
+{
+ usb_composite_unregister(&ccg_usb_driver);
+ class_destroy(ccg_class);
+ kfree(_ccg_dev);
+ _ccg_dev = NULL;
+}
+module_exit(cleanup);
diff --git a/drivers/staging/ccg/sysfs-class-ccg_usb b/drivers/staging/ccg/sysfs-class-ccg_usb
new file mode 100644
index 000000000000..dd12a332fb00
--- /dev/null
+++ b/drivers/staging/ccg/sysfs-class-ccg_usb
@@ -0,0 +1,158 @@
+What: /sys/class/ccg_usb
+Date: May 2012
+KernelVersion: 3.4
+Contact: linux-usb@vger.kernel.org
+Description:
+ The ccg_usb/ class subdirectory belongs to ccg
+ USB gadget.
+
+What: /sys/class/ccg_usb/ccgX
+Date: May 2012
+KernelVersion: 3.4
+Contact: linux-usb@vger.kernel.org
+Description:
+ The /sys/class/ccg_usb/ccg{0,1,2,3...} class
+ subdirectories correspond to each ccg gadget device;
+ at the time of this writing there is only ccg0 and it
+ represents the ccg gadget.
+
+What: /sys/class/ccg_usb/ccgX/functions
+Date: May 2012
+KernelVersion: 3.4
+Contact: linux-usb@vger.kernel.org
+Description:
+ A comma-separated list of USB function names to be activated
+ in this ccg gadget. It includes both the functions provided
+ in-kernel by the ccg gadget and the functions provided from
+ userspace through FunctionFS.
+
+What: /sys/class/ccg_usb/ccgX/enable
+Date: May 2012
+KernelVersion: 3.4
+Contact: linux-usb@vger.kernel.org
+Description:
+ A flag activating/deactivating the ccg usb gadget.
+
+What: /sys/class/ccg_usb/ccgX/state
+Date: May 2012
+KernelVersion: 3.4
+Contact: linux-usb@vger.kernel.org
+Description:
+ Configurable usb gadget state:
+
+ DISCONNECTED
+ CONNECTED
+ CONFIGURED
+
+What: /sys/class/ccg_usb/ccgX/f_acm/
+Date: May 2012
+KernelVersion: 3.4
+Contact: linux-usb@vger.kernel.org
+Description:
+ The /sys/class/ccg_usb/ccgX/f_acm subdirectory
+ corresponds to the gadget's USB CDC serial (ACM) function
+ driver.
+
+What: /sys/class/ccg_usb/ccgX/f_acm/instances
+Date: May 2012
+KernelVersion: 3.4
+Contact: linux-usb@vger.kernel.org
+Description:
+ Maximum number of the /dev/ttyGS<X> interface the driver uses.
+
+What: /sys/class/ccg_usb/ccgX/f_fs
+Date: May 2012
+KernelVersion: 3.4
+Contact: linux-usb@vger.kernel.org
+Description:
+ The /sys/class/ccg_usb/ccgX/f_fs subdirectory
+ corresponds to the gadget's FunctionFS driver.
+
+What: /sys/class/ccg_usb/ccgX/f_fs/user_functions
+Date: May 2012
+KernelVersion: 3.4
+Contact: linux-usb@vger.kernel.org
+Description:
+ A comma-separeted list of USB function names to be supported
+ from userspace. No other userspace FunctionFS functions can
+ be supported than listed here. However, the actual activation
+ of these functions is still done through
+ /sys/class/ccg_usb/ccgX/functions, where it is possible
+ to specify any subset (including maximum and empty) of
+ /sys/class/ccg_usb/ccgX/f_fs/user_functions.
+
+What: /sys/class/ccg_usb/ccgX/f_fs/max_user_functions
+Date: May 2012
+KernelVersion: 3.4
+Contact: linux-usb@vger.kernel.org
+Description:
+ Maximum number of USB functions to be supported from userspace.
+
+What: /sys/class/ccg_usb/ccgX/f_rndis
+Date: May 2012
+KernelVersion: 3.4
+Contact: linux-usb@vger.kernel.org
+Description:
+ The /sys/class/ccg_usb/ccgX/f_rndis subdirectory
+ corresponds to the gadget's RNDIS driver.
+
+What: /sys/class/ccg_usb/ccgX/f_rndis/manufacturer
+Date: May 2012
+KernelVersion: 3.4
+Contact: linux-usb@vger.kernel.org
+Description:
+ RNDIS Ethernet port manufacturer string.
+
+What: /sys/class/ccg_usb/ccgX/f_rndis/wceis
+Date: May 2012
+KernelVersion: 3.4
+Contact: linux-usb@vger.kernel.org
+Description:
+ RNDIS Ethernet port wireless flag.
+
+What: /sys/class/ccg_usb/ccgX/f_rndis/ethaddr
+Date: May 2012
+KernelVersion: 3.4
+Contact: linux-usb@vger.kernel.org
+Description:
+ RNDIS Ethernet port Ethernet address.
+
+What: /sys/class/ccg_usb/ccgX/f_rndis/vendorID
+Date: May 2012
+KernelVersion: 3.4
+Contact: linux-usb@vger.kernel.org
+Description:
+ RNDIS Ethernet port vendor ID.
+
+What: /sys/class/ccg_usb/ccgX/f_mass_storage
+Date: May 2012
+KernelVersion: 3.4
+Contact: linux-usb@vger.kernel.org
+Description:
+ The /sys/class/ccg_usb/ccgX/f_mass_storage subdirectory
+ corresponds to the gadget's USB mass storage driver.
+
+What: /sys/class/ccg_usb/ccgX/f_mass_storage/lun
+Date: May 2012
+KernelVersion: 3.4
+Contact: linux-usb@vger.kernel.org
+Description:
+ The /sys/class/ccg_usb/ccgX/f_mass_storage/lun
+ subdirectory corresponds to the gadget's USB mass storage
+ driver and its underlying storage.
+
+What: /sys/class/ccg_usb/ccgX/f_mass_storage/lun
+Date: May 2012
+KernelVersion: 3.4
+Contact: linux-usb@vger.kernel.org
+Description:
+ The /sys/class/ccg_usb/ccgX/f_mass_storage/lun
+ subdirectory corresponds to the gadget's USB mass storage
+ driver and its underlying storage.
+
+What: /sys/class/ccg_usb/ccgX/f_mass_storage/lun/file
+Date: May 2012
+KernelVersion: 3.4
+Contact: linux-usb@vger.kernel.org
+Description:
+ Gadget's USB mass storage underlying file.
diff --git a/drivers/staging/comedi/Kconfig b/drivers/staging/comedi/Kconfig
index 12c691d90900..6cee7855b019 100644
--- a/drivers/staging/comedi/Kconfig
+++ b/drivers/staging/comedi/Kconfig
@@ -1,23 +1,39 @@
config COMEDI
tristate "Data acquisition support (comedi)"
- default N
depends on m
depends on BROKEN || FRV || M32R || MN10300 || SUPERH || TILE || X86
---help---
Enable support a wide range of data acquisition devices
for Linux.
+if COMEDI
+
config COMEDI_DEBUG
bool "Comedi debugging"
- depends on COMEDI != n
---help---
This is an option for use by developers; most people should
say N here. This enables comedi core and driver debugging.
+config COMEDI_DEFAULT_BUF_SIZE_KB
+ int "Comedi default initial asynchronous buffer size in KiB"
+ default "2048"
+ ---help---
+ This is the default asynchronous buffer size which is used for
+ commands running in the background in kernel space. This
+ defaults to 2048 KiB of memory so that a 16 channel card
+ running at 10 kHz has of 2-4 seconds of buffer.
+
+config COMEDI_DEFAULT_BUF_MAXSIZE_KB
+ int "Comedi default maximum asynchronous buffer size in KiB"
+ default "20480"
+ ---help---
+ This is the default maximum asynchronous buffer size which can
+ be requested by a userspace program without root privileges.
+ This is set to 20480 KiB so that a fast I/O card with 16
+ channels running at 100 kHz has 2-4 seconds of buffer.
+
menuconfig COMEDI_MISC_DRIVERS
- tristate "Comedi misc drivers"
- depends on COMEDI
- default N
+ bool "Comedi misc drivers"
---help---
Enable comedi misc drivers to be built
@@ -35,7 +51,6 @@ config COMEDI_KCOMEDILIB
config COMEDI_BOND
tristate "Device bonding support"
depends on COMEDI_KCOMEDILIB
- default N
---help---
Enable support for a driver to 'bond' (merge) multiple subdevices
from multiple devices together as one.
@@ -46,7 +61,6 @@ config COMEDI_BOND
config COMEDI_TEST
tristate "Fake waveform generator support"
select COMEDI_FC
- default N
---help---
Enable support for the fake waveform generator.
This driver is mainly for testing purposes, but can also be used to
@@ -58,7 +72,6 @@ config COMEDI_TEST
config COMEDI_PARPORT
tristate "Parallel port support"
- default N
---help---
Enable support for the standard parallel port.
A cheap and easy way to get a few more digital I/O lines. Steal
@@ -70,7 +83,6 @@ config COMEDI_PARPORT
config COMEDI_SERIAL2002
tristate "Driver for serial connected hardware"
- default N
---help---
Enable support for serial connected hardware
@@ -79,7 +91,6 @@ config COMEDI_SERIAL2002
config COMEDI_SKEL
tristate "Comedi skeleton driver"
- default N
---help---
Build the Skeleton driver, an example for driver writers
@@ -89,9 +100,8 @@ config COMEDI_SKEL
endif # COMEDI_MISC_DRIVERS
menuconfig COMEDI_ISA_DRIVERS
- tristate "Comedi ISA and PC/104 drivers"
- depends on COMEDI && ISA
- default N
+ bool "Comedi ISA and PC/104 drivers"
+ depends on ISA
---help---
Enable comedi ISA and PC/104 drivers to be built
@@ -99,11 +109,10 @@ menuconfig COMEDI_ISA_DRIVERS
kernel: saying N will just cause the configurator to skip all
the questions about ISA and PC/104 comedi drivers.
-if COMEDI_ISA_DRIVERS && ISA
+if COMEDI_ISA_DRIVERS
config COMEDI_ACL7225B
tristate "ADlink NuDAQ ACL-7225b and compatibles support"
- default N
---help---
Enable support for ADlink NuDAQ ACL-7225b and compatibles,
ADlink ACL-7225b (acl7225b), ICP P16R16DIO (p16r16dio)
@@ -113,7 +122,6 @@ config COMEDI_ACL7225B
config COMEDI_PCL711
tristate "Advantech PCL-711/711b and ADlink ACL-8112 ISA card support"
- default N
---help---
Enable support for Advantech PCL-711 and 711b, ADlink ACL-8112
@@ -123,7 +131,6 @@ config COMEDI_PCL711
config COMEDI_PCL724
tristate "Advantech PCL-722/724/731 and ADlink ACL-7122/7124/PET-48DIO"
select COMEDI_8255
- default N
---help---
Enable support for Advantech PCL-724, PCL-722, PCL-731 and
ADlink ACL-7122, ACL-7124, PET-48DIO ISA cards
@@ -133,7 +140,6 @@ config COMEDI_PCL724
config COMEDI_PCL725
tristate "Advantech PCL-725 and compatible ISA card support"
- default N
---help---
Enable support for Advantech PCL-725 and compatible ISA cards.
@@ -142,7 +148,6 @@ config COMEDI_PCL725
config COMEDI_PCL726
tristate "Advantech PCL-726 and compatible ISA card support"
- default N
---help---
Enable support for Advantech PCL-726 and compatible ISA cards.
@@ -151,7 +156,6 @@ config COMEDI_PCL726
config COMEDI_PCL730
tristate "Advantech PCL-730 and ADlink ACL-7130 ISA card support"
- default N
---help---
Enable support for Advantech PCL-730, ICP ISO-730 and ADlink
ACL-7130 ISA cards
@@ -162,7 +166,6 @@ config COMEDI_PCL730
config COMEDI_PCL812
tristate "Advantech PCL-812/813 and ADlink ACL-8112/8113/8113/8216"
depends on VIRT_TO_BUS
- default N
---help---
Enable support for Advantech PCL-812/PG, PCL-813/B, ADLink
ACL-8112DG/HG/PG, ACL-8113, ACL-8216, ICP DAS A-821PGH/PGL/PGL-NDA,
@@ -174,7 +177,6 @@ config COMEDI_PCL812
config COMEDI_PCL816
tristate "Advantech PCL-814 and PCL-816 ISA card support"
depends on VIRT_TO_BUS
- default N
---help---
Enable support for Advantech PCL-814 and PCL-816 ISA cards
@@ -184,7 +186,6 @@ config COMEDI_PCL816
config COMEDI_PCL818
tristate "Advantech PCL-718 and PCL-818 ISA card support"
depends on VIRT_TO_BUS
- default N
---help---
Enable support for Advantech PCL-818 ISA cards
PCL-818L, PCL-818H, PCL-818HD, PCL-818HG, PCL-818 and PCL-718
@@ -195,7 +196,6 @@ config COMEDI_PCL818
config COMEDI_PCM3724
tristate "Advantech PCM-3724 PC/104 card support"
select COMEDI_8255
- default N
---help---
Enable support for Advantech PCM-3724 PC/104 cards.
@@ -204,16 +204,42 @@ config COMEDI_PCM3724
config COMEDI_PCM3730
tristate "Advantech PCM-3730 and clone PC/104 board support"
- default N
---help---
Enable support for Advantech PCM-3730 and clone PC/104 boards
To compile this driver as a module, choose M here: the module will be
called pcm3730.
+config COMEDI_AMPLC_DIO200_ISA
+ tristate "Amplicon PC212E/PC214E/PC215E/PC218E/PC272E"
+ select COMEDI_AMPLC_DIO200
+ ---help---
+ Enable support for Amplicon PC212E, PC214E, PC215E, PC218E and
+ PC272E ISA DIO boards
+
+ To compile this driver as a module, choose M here: the module will be
+ called amplc_dio200.
+
+config COMEDI_AMPLC_PC236_ISA
+ tristate "Amplicon PC36AT DIO board support"
+ select COMEDI_AMPLC_PC236
+ ---help---
+ Enable support for Amplicon PC36AT ISA DIO board.
+
+ To compile this driver as a module, choose M here: the module will be
+ called amplc_pc236.
+
+config COMEDI_AMPLC_PC263_ISA
+ tristate "Amplicon PC263 relay board support"
+ select COMEDI_AMPLC_PC263
+ ---help---
+ Enable support for Amplicon PC263 ISA relay board.
+
+ To compile this driver as a module, choose M here: the module will be
+ called amplc_pc263.
+
config COMEDI_RTI800
tristate "Analog Devices RTI-800/815 ISA card support"
- default N
---help---
Enable support for Analog Devices RTI-800/815 ISA cards
@@ -222,7 +248,6 @@ config COMEDI_RTI800
config COMEDI_RTI802
tristate "Analog Devices RTI-802 ISA card support"
- default N
---help---
Enable support for Analog Devices RTI-802 ISA cards
@@ -233,18 +258,29 @@ config COMEDI_DAS16M1
tristate "MeasurementComputing CIO-DAS16/M1DAS-16 ISA card support"
select COMEDI_8255
select COMEDI_FC
- default N
---help---
Enable support for Measurement Computing CIO-DAS16/M1 ISA cards.
To compile this driver as a module, choose M here: the module will be
called das16m1.
+config COMEDI_DAS08_ISA
+ tristate "DAS-08 compatible ISA and PC/104 card support"
+ select COMEDI_DAS08
+ ---help---
+ Enable support for Keithley Metrabyte/ComputerBoards DAS08
+ and compatible ISA and PC/104 cards:
+ Keithley Metrabyte/ComputerBoards DAS08, DAS08-PGM, DAS08-PGH,
+ DAS08-PGL, DAS08-AOH, DAS08-AOL, DAS08-AOM, DAS08/JR-AO,
+ DAS08/JR-16-AO, PC104-DAS08, DAS08/JR/16.
+
+ To compile this driver as a module, choose M here: the module will be
+ called das08.
+
config COMEDI_DAS16
tristate "DAS-16 compatible ISA and PC/104 card support"
select COMEDI_8255
select COMEDI_FC
- default N
---help---
Enable support for Keithley Metrabyte/ComputerBoards DAS16
and compatible ISA and PC/104 cards:
@@ -261,7 +297,6 @@ config COMEDI_DAS16
config COMEDI_DAS800
tristate "DAS800 and compatible ISA card support"
select COMEDI_FC
- default N
---help---
Enable support for Keithley Metrabyte DAS800 and compatible ISA cards
Keithley Metrabyte DAS-800, DAS-801, DAS-802
@@ -275,7 +310,6 @@ config COMEDI_DAS1800
tristate "DAS1800 and compatible ISA card support"
depends on VIRT_TO_BUS
select COMEDI_FC
- default N
---help---
Enable support for DAS1800 and compatible ISA cards
Keithley Metrabyte DAS-1701ST, DAS-1701ST-DA, DAS-1701/AO,
@@ -289,7 +323,6 @@ config COMEDI_DAS1800
config COMEDI_DAS6402
tristate "DAS6402 and compatible ISA card support"
- default N
---help---
Enable support for DAS6402 and compatible ISA cards
Computerboards, Keithley Metrabyte DAS6402 and compatibles
@@ -299,7 +332,6 @@ config COMEDI_DAS6402
config COMEDI_DT2801
tristate "Data Translation DT2801 ISA card support"
- default N
---help---
Enable support for Data Translation DT2801 ISA cards
@@ -308,7 +340,6 @@ config COMEDI_DT2801
config COMEDI_DT2811
tristate "Data Translation DT2811 ISA card support"
- default N
---help---
Enable support for Data Translation DT2811 ISA cards
@@ -317,7 +348,6 @@ config COMEDI_DT2811
config COMEDI_DT2814
tristate "Data Translation DT2814 ISA card support"
- default N
---help---
Enable support for Data Translation DT2814 ISA cards
@@ -326,7 +356,6 @@ config COMEDI_DT2814
config COMEDI_DT2815
tristate "Data Translation DT2815 ISA card support"
- default N
---help---
Enable support for Data Translation DT2815 ISA cards
@@ -335,7 +364,6 @@ config COMEDI_DT2815
config COMEDI_DT2817
tristate "Data Translation DT2817 ISA card support"
- default N
---help---
Enable support for Data Translation DT2817 ISA cards
@@ -346,7 +374,6 @@ config COMEDI_DT282X
tristate "Data Translation DT2821 series and DT-EZ ISA card support"
select COMEDI_FC
depends on VIRT_TO_BUS
- default N
---help---
Enable support for Data Translation DT2821 series including DT-EZ
DT2821, DT2821-F-16SE, DT2821-F-8DI, DT2821-G-16SE, DT2821-G-8DI,
@@ -358,7 +385,6 @@ config COMEDI_DT282X
config COMEDI_DMM32AT
tristate "Diamond Systems MM-32-AT PC/104 board support"
- default N
---help---
Enable support for Diamond Systems MM-32-AT PC/104 boards
@@ -367,7 +393,6 @@ config COMEDI_DMM32AT
config COMEDI_FL512
tristate "FL512 ISA card support"
- default N
---help---
Enable support for FL512 ISA card
@@ -377,7 +402,6 @@ config COMEDI_FL512
config COMEDI_AIO_AIO12_8
tristate "I/O Products PC/104 AIO12-8 Analog I/O Board support"
select COMEDI_8255
- default N
---help---
Enable support for I/O Products PC/104 AIO12-8 Analog I/O Board
@@ -386,7 +410,6 @@ config COMEDI_AIO_AIO12_8
config COMEDI_AIO_IIRO_16
tristate "I/O Products PC/104 IIRO16 Board support"
- default N
---help---
Enable support for I/O Products PC/104 IIRO16 Relay And Isolated
Input Board
@@ -396,7 +419,6 @@ config COMEDI_AIO_IIRO_16
config COMEDI_C6XDIGIO
tristate "Mechatronic Systems Inc. C6x_DIGIO DSP daughter card support"
- default N
---help---
Enable support for Mechatronic Systems Inc. C6x_DIGIO DSP daughter
card
@@ -406,7 +428,6 @@ config COMEDI_C6XDIGIO
config COMEDI_MPC624
tristate "Micro/sys MPC-624 PC/104 board support"
- default N
---help---
Enable support for Micro/sys MPC-624 PC/104 board
@@ -415,7 +436,6 @@ config COMEDI_MPC624
config COMEDI_ADQ12B
tristate "MicroAxial ADQ12-B data acquisition and control card support"
- default N
---help---
Enable MicroAxial ADQ12-B daq and control card support.
@@ -424,9 +444,7 @@ config COMEDI_ADQ12B
config COMEDI_NI_AT_A2150
tristate "NI AT-A2150 ISA card support"
- depends on COMEDI_NI_COMMON
depends on VIRT_TO_BUS
- default N
---help---
Enable support for National Instruments AT-A2150 cards
@@ -435,8 +453,6 @@ config COMEDI_NI_AT_A2150
config COMEDI_NI_AT_AO
tristate "NI AT-AO-6/10 EISA card support"
- depends on COMEDI_NI_COMMON
- default N
---help---
Enable support for National Instruments AT-AO-6/10 cards
@@ -445,9 +461,9 @@ config COMEDI_NI_AT_AO
config COMEDI_NI_ATMIO
tristate "NI AT-MIO E series ISA-PNP card support"
- depends on ISAPNP && COMEDI_NI_TIO && COMEDI_NI_COMMON
+ depends on ISAPNP
select COMEDI_8255
- default N
+ select COMEDI_NI_TIO
---help---
Enable support for National Instruments AT-MIO E series cards
National Instruments AT-MIO-16E-1 (ni_atmio),
@@ -459,9 +475,8 @@ config COMEDI_NI_ATMIO
config COMEDI_NI_ATMIO16D
tristate "NI AT-MIO16/AT-MIO16D series ISA-PNP card support"
- depends on ISAPNP && COMEDI_NI_COMMON
+ depends on ISAPNP
select COMEDI_8255
- default N
---help---
Enable support for National Instruments AT-MIO16/AT-MIO16D cards.
@@ -470,7 +485,6 @@ config COMEDI_NI_ATMIO16D
config COMEDI_PCMAD
tristate "Winsystems PCM-A/D12 and PCM-A/D16 PC/104 board support"
- default N
---help---
Enable support for Winsystems PCM-A/D12 and PCM-A/D16 PC/104 boards.
@@ -479,7 +493,6 @@ config COMEDI_PCMAD
config COMEDI_PCMDA12
tristate "Winsystems PCM-D/A-12 8-channel AO PC/104 board support"
- default N
---help---
Enable support for Winsystems PCM-D/A-12 8-channel AO PC/104 boards.
Note that the board is not ISA-PNP capable and thus needs the I/O
@@ -490,7 +503,6 @@ config COMEDI_PCMDA12
config COMEDI_PCMMIO
tristate "Winsystems PCM-MIO PC/104 board support"
- default N
---help---
Enable support for Winsystems PCM-MIO multifunction PC/104 boards.
@@ -499,7 +511,6 @@ config COMEDI_PCMMIO
config COMEDI_PCMUIO
tristate "Winsystems PCM-UIO48A and PCM-UIO96A PC/104 board support"
- default N
---help---
Enable support for PCM-UIO48A and PCM-UIO96A PC/104 boards.
@@ -508,7 +519,6 @@ config COMEDI_PCMUIO
config COMEDI_MULTIQ3
tristate "Quanser Consulting MultiQ-3 ISA card support"
- default N
---help---
Enable support for Quanser Consulting MultiQ-3 ISA cards
@@ -517,7 +527,6 @@ config COMEDI_MULTIQ3
config COMEDI_POC
tristate "Generic driver for very simple devices"
- default N
---help---
Enable generic support for very simple / POC (Piece of Crap) boards,
Keithley Metrabyte DAC-02 (dac02), Advantech PCL-733 (pcl733) and
@@ -529,9 +538,8 @@ config COMEDI_POC
endif # COMEDI_ISA_DRIVERS
menuconfig COMEDI_PCI_DRIVERS
- tristate "Comedi PCI drivers"
- depends on COMEDI && PCI
- default N
+ bool "Comedi PCI drivers"
+ depends on PCI
---help---
Enable comedi PCI drivers to be built
@@ -539,12 +547,11 @@ menuconfig COMEDI_PCI_DRIVERS
kernel: saying N will just cause the configurator to skip all
the questions about PCI comedi drivers.
-if COMEDI_PCI_DRIVERS && PCI
+if COMEDI_PCI_DRIVERS
config COMEDI_ADDI_APCI_035
tristate "ADDI-DATA APCI_035 support"
depends on VIRT_TO_BUS
- default N
---help---
Enable support for ADDI-DATA APCI_035 cards
@@ -554,7 +561,6 @@ config COMEDI_ADDI_APCI_035
config COMEDI_ADDI_APCI_1032
tristate "ADDI-DATA APCI_1032 support"
depends on VIRT_TO_BUS
- default N
---help---
Enable support for ADDI-DATA APCI_1032 cards
@@ -564,7 +570,6 @@ config COMEDI_ADDI_APCI_1032
config COMEDI_ADDI_APCI_1500
tristate "ADDI-DATA APCI_1500 support"
depends on VIRT_TO_BUS
- default N
---help---
Enable support for ADDI-DATA APCI_1500 cards
@@ -574,7 +579,6 @@ config COMEDI_ADDI_APCI_1500
config COMEDI_ADDI_APCI_1516
tristate "ADDI-DATA APCI_1516 support"
depends on VIRT_TO_BUS
- default N
---help---
Enable support for ADDI-DATA APCI_1516 cards
@@ -584,7 +588,6 @@ config COMEDI_ADDI_APCI_1516
config COMEDI_ADDI_APCI_1564
tristate "ADDI-DATA APCI_1564 support"
depends on VIRT_TO_BUS
- default N
---help---
Enable support for ADDI-DATA APCI_1564 cards
@@ -594,7 +597,6 @@ config COMEDI_ADDI_APCI_1564
config COMEDI_ADDI_APCI_16XX
tristate "ADDI-DATA APCI_16xx support"
depends on VIRT_TO_BUS
- default N
---help---
Enable support for ADDI-DATA APCI_16xx cards
@@ -604,7 +606,6 @@ config COMEDI_ADDI_APCI_16XX
config COMEDI_ADDI_APCI_2016
tristate "ADDI-DATA APCI_2016 support"
depends on VIRT_TO_BUS
- default N
---help---
Enable support for ADDI-DATA APCI_2016 cards
@@ -614,7 +615,6 @@ config COMEDI_ADDI_APCI_2016
config COMEDI_ADDI_APCI_2032
tristate "ADDI-DATA APCI_2032 support"
depends on VIRT_TO_BUS
- default N
---help---
Enable support for ADDI-DATA APCI_2032 cards
@@ -624,7 +624,6 @@ config COMEDI_ADDI_APCI_2032
config COMEDI_ADDI_APCI_2200
tristate "ADDI-DATA APCI_2200 support"
depends on VIRT_TO_BUS
- default N
---help---
Enable support for ADDI-DATA APCI_2200 cards
@@ -635,7 +634,6 @@ config COMEDI_ADDI_APCI_3001
tristate "ADDI-DATA APCI_3001 support"
depends on VIRT_TO_BUS
select COMEDI_FC
- default N
---help---
Enable support for ADDI-DATA APCI_3001 cards
@@ -646,7 +644,6 @@ config COMEDI_ADDI_APCI_3120
tristate "ADDI-DATA APCI_3520 support"
depends on VIRT_TO_BUS
select COMEDI_FC
- default N
---help---
Enable support for ADDI-DATA APCI_3520 cards
@@ -656,7 +653,6 @@ config COMEDI_ADDI_APCI_3120
config COMEDI_ADDI_APCI_3501
tristate "ADDI-DATA APCI_3501 support"
depends on VIRT_TO_BUS
- default N
---help---
Enable support for ADDI-DATA APCI_3501 cards
@@ -666,7 +662,6 @@ config COMEDI_ADDI_APCI_3501
config COMEDI_ADDI_APCI_3XXX
tristate "ADDI-DATA APCI_3xxx support"
depends on VIRT_TO_BUS
- default N
---help---
Enable support for ADDI-DATA APCI_3xxx cards
@@ -675,8 +670,6 @@ config COMEDI_ADDI_APCI_3XXX
config COMEDI_ADL_PCI6208
tristate "ADLink PCI-6208A support"
- select COMEDI_8255
- default N
---help---
Enable support for ADLink PCI-6208A cards
@@ -685,7 +678,6 @@ config COMEDI_ADL_PCI6208
config COMEDI_ADL_PCI7230
tristate "ADLink PCI-7230 digital io board support"
- default N
---help---
Enable support for ADlink PCI-7230 digital io board support
@@ -694,7 +686,7 @@ config COMEDI_ADL_PCI7230
config COMEDI_ADL_PCI7296
tristate "ADLink PCI-7296 96 ch. digital io board support"
- default N
+ select COMEDI_8255
---help---
Enable support for ADlink PCI-7296 96 ch. digital io board support
@@ -703,7 +695,6 @@ config COMEDI_ADL_PCI7296
config COMEDI_ADL_PCI7432
tristate "ADLink PCI-7432 64 ch. isolated digital io board support"
- default N
---help---
Enable support for ADlink PCI-7432 64 ch. isolated digital io board
@@ -712,7 +703,6 @@ config COMEDI_ADL_PCI7432
config COMEDI_ADL_PCI8164
tristate "ADLink PCI-8164 4 Axes Motion Control board support"
- default N
---help---
Enable support for ADlink PCI-8164 4 Axes Motion Control board
@@ -722,7 +712,6 @@ config COMEDI_ADL_PCI8164
config COMEDI_ADL_PCI9111
tristate "ADLink PCI-9111HR support"
select COMEDI_FC
- default N
---help---
Enable support for ADlink PCI9111 cards
@@ -733,7 +722,6 @@ config COMEDI_ADL_PCI9118
tristate "ADLink PCI-9118DG, PCI-9118HG, PCI-9118HR support"
select COMEDI_FC
depends on VIRT_TO_BUS
- default N
---help---
Enable support for ADlink PCI-9118DG, PCI-9118HG, PCI-9118HR cards
@@ -742,7 +730,6 @@ config COMEDI_ADL_PCI9118
config COMEDI_ADV_PCI1710
tristate "Advantech PCI-171x, PCI-1720 and PCI-1731 support"
- default N
---help---
Enable support for Advantech PCI-1710, PCI-1710HG, PCI-1711,
PCI-1713, PCI-1720 and PCI-1731
@@ -752,7 +739,6 @@ config COMEDI_ADV_PCI1710
config COMEDI_ADV_PCI1723
tristate "Advantech PCI-1723 support"
- default N
---help---
Enable support for Advantech PCI-1723 cards
@@ -762,7 +748,6 @@ config COMEDI_ADV_PCI1723
config COMEDI_ADV_PCI_DIO
tristate "Advantech PCI DIO card support"
select COMEDI_8255
- default N
---help---
Enable support for Advantech PCI DIO cards
PCI-1730, PCI-1733, PCI-1734, PCI-1735U, PCI-1736UP, PCI-1739U,
@@ -772,31 +757,29 @@ config COMEDI_ADV_PCI_DIO
To compile this driver as a module, choose M here: the module will be
called adv_pci_dio.
-config COMEDI_AMPLC_DIO200
- tristate "Amplicon PC272E and PCI272 DIO board support"
- select COMEDI_8255
- default N
+config COMEDI_AMPLC_DIO200_PCI
+ tristate "Amplicon PCI215 and PCI272 DIO board support"
+ select COMEDI_AMPLC_DIO200
---help---
- Enable support for Amplicon PC272E and PCI272 DIO boards
+ Enable support for Amplicon PCI215 and PCI272 DIO boards.
To compile this driver as a module, choose M here: the module will be
called amplc_dio200.
-config COMEDI_AMPLC_PC236
- tristate "Amplicon PC36AT and PCI236 DIO board support"
- select COMEDI_8255
- default N
+config COMEDI_AMPLC_PC236_PCI
+ tristate "Amplicon PCI236 DIO board support"
+ select COMEDI_AMPLC_PC236
---help---
- Enable support for Amplicon PC36AT and PCI236 DIO boards
+ Enable support for Amplicon PCI236 DIO board.
To compile this driver as a module, choose M here: the module will be
called amplc_pc236.
-config COMEDI_AMPLC_PC263
- tristate "Amplicon PC263 and PCI263 relay board support"
- default N
+config COMEDI_AMPLC_PC263_PCI
+ tristate "Amplicon PCI263 relay board support"
+ select COMEDI_AMPLC_PC263
---help---
- Enable support for Amplicon PC263 and PCI263 relay boards
+ Enable support for Amplicon PCI263 relay board.
To compile this driver as a module, choose M here: the module will be
called amplc_pc263.
@@ -804,7 +787,6 @@ config COMEDI_AMPLC_PC263
config COMEDI_AMPLC_PCI224
tristate "Amplicon PCI224 and PCI234 support"
select COMEDI_FC
- default N
---help---
Enable support for Amplicon PCI224 and PCI234 AO boards
@@ -814,7 +796,6 @@ config COMEDI_AMPLC_PCI224
config COMEDI_AMPLC_PCI230
tristate "Amplicon PCI230 and PCI260 support"
select COMEDI_8255
- default N
---help---
Enable support for Amplicon PCI230 and PCI260 Multifunction I/O
boards
@@ -824,16 +805,23 @@ config COMEDI_AMPLC_PCI230
config COMEDI_CONTEC_PCI_DIO
tristate "Contec PIO1616L digital I/O board support"
- default N
---help---
Enable support for the Contec PIO1616L digital I/O board
To compile this driver as a module, choose M here: the module will be
called contec_pci_dio.
+config COMEDI_DAS08_PCI
+ tristate "DAS-08 PCI support"
+ select COMEDI_DAS08
+ ---help---
+ Enable support for PCI DAS-08 cards.
+
+ To compile this driver as a module, choose M here: the module will be
+ called das08.
+
config COMEDI_DT3000
tristate "Data Translation DT3000 series support"
- default N
---help---
Enable support for Data Translation DT3000 series
DT3001, DT3001-PGL, DT3002, DT3003, DT3003-PGL, DT3004, DT3005 and
@@ -844,7 +832,6 @@ config COMEDI_DT3000
config COMEDI_DYNA_PCI10XX
tristate "Dynalog PCI DAQ series support"
- default N
---help---
Enable support for Dynalog PCI DAQ series
PCI-1050
@@ -854,7 +841,6 @@ config COMEDI_DYNA_PCI10XX
config COMEDI_UNIOXX5
tristate "Fastwel UNIOxx-5 analog and digital io board support"
- default N
---help---
Enable support for Fastwel UNIOxx-5 (analog and digital i/o) boards
@@ -864,7 +850,6 @@ config COMEDI_UNIOXX5
config COMEDI_GSC_HPDI
tristate "General Standards PCI-HPDI32 / PMC-HPDI32 support"
select COMEDI_FC
- default N
---help---
Enable support for General Standards Corporation high speed parallel
digital interface rs485 boards PCI-HPDI32 and PMC-HPDI32.
@@ -875,7 +860,6 @@ config COMEDI_GSC_HPDI
config COMEDI_ICP_MULTI
tristate "Inova ICP_MULTI support"
- default N
---help---
Enable support for Inova ICP_MULTI card
@@ -884,7 +868,6 @@ config COMEDI_ICP_MULTI
config COMEDI_II_PCI20KC
tristate "Intelligent Instruments PCI-20001C carrier support"
- default N
---help---
Enable support for Intelligent Instruments PCI-20001C carrier
PCI-20001, PCI-20006 and PCI-20341
@@ -895,7 +878,6 @@ config COMEDI_II_PCI20KC
config COMEDI_DAQBOARD2000
tristate "IOtech DAQboard/2000 support"
select COMEDI_8255
- default N
---help---
Enable support for the IOtech DAQboard/2000
@@ -904,7 +886,6 @@ config COMEDI_DAQBOARD2000
config COMEDI_JR3_PCI
tristate "JR3/PCI force sensor board support"
- default N
---help---
Enable support for JR3/PCI force sensor boards
@@ -913,7 +894,6 @@ config COMEDI_JR3_PCI
config COMEDI_KE_COUNTER
tristate "Kolter-Electronic PCI Counter 1 card support"
- default N
---help---
Enable support for Kolter-Electronic PCI Counter 1 cards
@@ -924,7 +904,6 @@ config COMEDI_CB_PCIDAS64
tristate "MeasurementComputing PCI-DAS 64xx, 60xx, and 4020 support"
select COMEDI_8255
select COMEDI_FC
- default N
---help---
Enable support for ComputerBoards/MeasurementComputing PCI-DAS 64xx,
60xx, and 4020 series with the PLX 9080 PCI controller
@@ -936,7 +915,6 @@ config COMEDI_CB_PCIDAS
tristate "MeasurementComputing PCI-DAS support"
select COMEDI_8255
select COMEDI_FC
- default N
---help---
Enable support for ComputerBoards/MeasurementComputing PCI-DAS with
AMCC S5933 PCIcontroller: PCI-DAS1602/16, PCI-DAS1602/16jr,
@@ -949,7 +927,6 @@ config COMEDI_CB_PCIDAS
config COMEDI_CB_PCIDDA
tristate "MeasurementComputing PCI-DDA series support"
select COMEDI_8255
- default N
---help---
Enable support for ComputerBoards/MeasurementComputing PCI-DDA
series: PCI-DDA08/12, PCI-DDA04/12, PCI-DDA02/12, PCI-DDA08/16,
@@ -961,7 +938,6 @@ config COMEDI_CB_PCIDDA
config COMEDI_CB_PCIDIO
tristate "MeasurementComputing PCI-DIO series support"
select COMEDI_8255
- default N
---help---
Enable support for ComputerBoards/MeasurementComputing PCI-DIO series
PCI-DIO24, PCI-DIO24H and PCI-DIO48H
@@ -972,7 +948,6 @@ config COMEDI_CB_PCIDIO
config COMEDI_CB_PCIMDAS
tristate "MeasurementComputing PCIM-DAS1602/16 support"
select COMEDI_8255
- default N
---help---
Enable support for ComputerBoards/MeasurementComputing PCI Migration
series PCIM-DAS1602/16
@@ -983,7 +958,6 @@ config COMEDI_CB_PCIMDAS
config COMEDI_CB_PCIMDDA
tristate "MeasurementComputing PCIM-DDA06-16 support"
select COMEDI_8255
- default N
---help---
Enable support for ComputerBoards/MeasurementComputing PCIM-DDA06-16
@@ -992,7 +966,6 @@ config COMEDI_CB_PCIMDDA
config COMEDI_ME4000
tristate "Meilhaus ME-4000 support"
- default N
---help---
Enable support for Meilhaus PCI data acquisition cards
ME-4650, ME-4670i, ME-4680, ME-4680i and ME-4680is
@@ -1002,7 +975,6 @@ config COMEDI_ME4000
config COMEDI_ME_DAQ
tristate "Meilhaus ME-2000i, ME-2600i, ME-3000vm1 support"
- default N
---help---
Enable support for Meilhaus PCI data acquisition cards
ME-2000i, ME-2600i and ME-3000vm1
@@ -1012,8 +984,7 @@ config COMEDI_ME_DAQ
config COMEDI_NI_6527
tristate "NI 6527 support"
- depends on COMEDI_MITE
- default N
+ select COMEDI_MITE
---help---
Enable support for the National Instruments 6527 PCI card
@@ -1022,8 +993,7 @@ config COMEDI_NI_6527
config COMEDI_NI_65XX
tristate "NI 65xx static dio PCI card support"
- depends on COMEDI_MITE
- default N
+ select COMEDI_MITE
---help---
Enable support for National Instruments 65xx static dio boards.
Supported devices: National Instruments PCI-6509 (ni_65xx),
@@ -1036,8 +1006,7 @@ config COMEDI_NI_65XX
config COMEDI_NI_660X
tristate "NI 660x counter/timer PCI card support"
- depends on COMEDI_NI_TIO && COMEDI_NI_COMMON
- default N
+ select COMEDI_NI_TIOCMD
---help---
Enable support for National Instruments PCI-6601 (ni_660x), PCI-6602,
PXI-6602 and PXI-6608.
@@ -1047,19 +1016,32 @@ config COMEDI_NI_660X
config COMEDI_NI_670X
tristate "NI 670x PCI card support"
- depends on COMEDI_MITE
- default N
+ select COMEDI_MITE
---help---
Enable support for National Instruments PCI-6703 and PCI-6704
To compile this driver as a module, choose M here: the module will be
called ni_670x.
+config COMEDI_NI_LABPC
+ tristate "NI Lab-PC and compatibles ISA and PCI support"
+ select COMEDI_MITE
+ select COMEDI_8255
+ select COMEDI_FC
+ depends on VIRT_TO_BUS
+ ---help---
+ Enable support for National Instruments Lab-PC and compatibles
+ Lab-PC-1200, Lab-PC-1200AI, Lab-PC+ and PCI-1200.
+ Kernel-level ISA plug-and-play support for the lab-pc-1200 boards has
+ not yet been added to the driver.
+
+ To compile this driver as a module, choose M here: the module will be
+ called ni_labpc.
+
config COMEDI_NI_PCIDIO
tristate "NI PCI-DIO32HS, PCI-DIO96, PCI-6533, PCI-6503 support"
- depends on COMEDI_MITE
+ select COMEDI_MITE
select COMEDI_8255
- default N
---help---
Enable support for National Instruments PCI-DIO-32HS, PXI-6533,
PCI-DIO-96, PCI-DIO-96B, PXI-6508, PCI-6503, PCI-6503B, PCI-6503X,
@@ -1072,10 +1054,9 @@ config COMEDI_NI_PCIDIO
config COMEDI_NI_PCIMIO
tristate "NI PCI-MIO-E series and M series support"
- depends on COMEDI_NI_TIO && COMEDI_NI_COMMON
+ select COMEDI_NI_TIOCMD
select COMEDI_8255
select COMEDI_FC
- default N
---help---
Enable support for National Instruments PCI-MIO-E series and M series
(all boards): PCI-MIO-16XE-10, PXI-6030E, PCI-MIO-16E-1,
@@ -1093,8 +1074,6 @@ config COMEDI_NI_PCIMIO
config COMEDI_RTD520
tristate "Real Time Devices PCI4520/DM7520 support"
- select COMEDI_8255
- default N
---help---
Enable support for Real Time Devices PCI4520/DM7520
@@ -1103,7 +1082,6 @@ config COMEDI_RTD520
config COMEDI_S526
tristate "Sensoray s526 support"
- default N
---help---
Enable support for Sensoray s526
@@ -1113,7 +1091,6 @@ config COMEDI_S526
config COMEDI_S626
tristate "Sensoray 626 support"
select COMEDI_FC
- default N
---help---
Enable support for Sensoray 626
@@ -1122,19 +1099,25 @@ config COMEDI_S626
config COMEDI_SSV_DNP
tristate "SSV Embedded Systems DIL/Net-PC support"
- default N
---help---
Enable support for SSV Embedded Systems DIL/Net-PC
To compile this driver as a module, choose M here: the module will be
called ssv_dnp.
+config COMEDI_MITE
+ tristate
+
+config COMEDI_NI_TIOCMD
+ tristate
+ select COMEDI_NI_TIO
+ select COMEDI_MITE
+
endif # COMEDI_PCI_DRIVERS
menuconfig COMEDI_PCMCIA_DRIVERS
- tristate "Comedi PCMCIA drivers"
- depends on COMEDI && (PCMCIA || PCCARD)
- default N
+ bool "Comedi PCMCIA drivers"
+ depends on PCMCIA
---help---
Enable comedi PCMCIA and PCCARD drivers to be built
@@ -1142,11 +1125,10 @@ menuconfig COMEDI_PCMCIA_DRIVERS
kernel: saying N will just cause the configurator to skip all
the questions about PCMCIA comedi drivers.
-if COMEDI_PCMCIA_DRIVERS && PCMCIA
+if COMEDI_PCMCIA_DRIVERS
config COMEDI_CB_DAS16_CS
tristate "CB DAS16 series PCMCIA support"
- default N
---help---
Enable support for the ComputerBoards/MeasurementComputing PCMCIA
cards DAS16/16, PCM-DAS16D/12 and PCM-DAS16s/16
@@ -1157,7 +1139,6 @@ config COMEDI_CB_DAS16_CS
config COMEDI_DAS08_CS
tristate "CB DAS08 PCMCIA support"
select COMEDI_DAS08
- default N
---help---
Enable support for the ComputerBoards/MeasurementComputing DAS-08
PCMCIA card
@@ -1167,8 +1148,6 @@ config COMEDI_DAS08_CS
config COMEDI_NI_DAQ_700_CS
tristate "NI DAQCard-700 PCMCIA support"
- depends on COMEDI_NI_COMMON
- default N
---help---
Enable support for the National Instruments PCMCIA DAQCard-700 DIO
@@ -1177,9 +1156,7 @@ config COMEDI_NI_DAQ_700_CS
config COMEDI_NI_DAQ_DIO24_CS
tristate "NI DAQ-Card DIO-24 PCMCIA support"
- depends on COMEDI_NI_COMMON
select COMEDI_8255
- default N
---help---
Enable support for the National Instruments PCMCIA DAQ-Card DIO-24
@@ -1189,7 +1166,6 @@ config COMEDI_NI_DAQ_DIO24_CS
config COMEDI_NI_LABPC_CS
tristate "NI DAQCard-1200 PCMCIA support"
depends on COMEDI_NI_LABPC
- default N
---help---
Enable support for the National Instruments PCMCIA DAQCard-1200
@@ -1198,10 +1174,9 @@ config COMEDI_NI_LABPC_CS
config COMEDI_NI_MIO_CS
tristate "NI DAQCard E series PCMCIA support"
- depends on COMEDI_NI_TIO && COMEDI_NI_COMMON
+ select COMEDI_NI_TIO
select COMEDI_8255
select COMEDI_FC
- default N
---help---
Enable support for the National Instruments PCMCIA DAQCard E series
DAQCard-ai-16xe-50, DAQCard-ai-16e-4, DAQCard-6062E, DAQCard-6024E
@@ -1212,7 +1187,6 @@ config COMEDI_NI_MIO_CS
config COMEDI_QUATECH_DAQP_CS
tristate "Quatech DAQP PCMCIA data capture card support"
- default N
---help---
Enable support for the Quatech DAQP PCMCIA data capture cards
DAQP-208 and DAQP-308
@@ -1223,9 +1197,8 @@ config COMEDI_QUATECH_DAQP_CS
endif # COMEDI_PCMCIA_DRIVERS
menuconfig COMEDI_USB_DRIVERS
- tristate "Comedi USB drivers"
- depends on COMEDI && USB
- default N
+ bool "Comedi USB drivers"
+ depends on USB
---help---
Enable comedi USB drivers to be built
@@ -1233,11 +1206,10 @@ menuconfig COMEDI_USB_DRIVERS
kernel: saying N will just cause the configurator to skip all
the questions about USB comedi drivers.
-if COMEDI_USB_DRIVERS && USB
+if COMEDI_USB_DRIVERS
config COMEDI_DT9812
tristate "DataTranslation DT9812 USB module support"
- default N
---help---
Enable support for the Data Translation DT9812 USB module
@@ -1246,7 +1218,6 @@ config COMEDI_DT9812
config COMEDI_USBDUX
tristate "ITL USB-DUX-D support"
- default N
---help---
Enable support for the Incite Technology Ltd USB-DUX-D Board
@@ -1256,7 +1227,6 @@ config COMEDI_USBDUX
config COMEDI_USBDUXFAST
tristate "ITL USB-DUXfast support"
select COMEDI_FC
- default N
---help---
Enable support for the Incite Technology Ltd USB-DUXfast Board
@@ -1266,7 +1236,6 @@ config COMEDI_USBDUXFAST
config COMEDI_USBDUXSIGMA
tristate "ITL USB-DUXsigma support"
select COMEDI_FC
- default N
---help---
Enable support for the Incite Technology Ltd USB-DUXsigma Board
@@ -1275,7 +1244,6 @@ config COMEDI_USBDUXSIGMA
config COMEDI_VMK80XX
tristate "Velleman VM110/VM140 USB Board support"
- default N
---help---
Build the Velleman USB Board Low-Level Driver supporting the
K8055/K8061 aka VM110/VM140 devices
@@ -1285,65 +1253,8 @@ config COMEDI_VMK80XX
endif # COMEDI_USB_DRIVERS
-menuconfig COMEDI_NI_COMMON
- tristate "Comedi National Instruments card support"
- depends on COMEDI
- default N
- ---help---
- Enable comedi support for National Instruments cards.
- Modules in this section are used by many comedi NI drivers.
-
- Note that the answer to this question won't directly affect the
- kernel: saying N will just cause the configurator to skip all
- the questions about National Instruments cards.
-
-if COMEDI_NI_COMMON
-
-config COMEDI_MITE
- tristate "NI Mite PCI interface chip support"
- depends on PCI
- default N
- ---help---
- Enable support for National Instruments Mite PCI interface chip
-
- To compile this driver as a module, choose M here: the module will be
- called mite.
-
-config COMEDI_NI_TIO
- tristate "NI general purpose counter support"
- depends on COMEDI_MITE
- default N
- ---help---
- Enable support for National Instruments general purpose counters.
- This module is not used directly by end-users. Rather, it
- is used by other drivers (for example ni_660x and ni_pcimio)
- to provide support for NI's general purpose counters.
-
- To compile this driver as a modules, choose M here: two modules will
- be build: ni_tio and ni_tiocmd.
-
-config COMEDI_NI_LABPC
- tristate "NI Lab-PC and compatibles ISA and PCI support"
- depends on COMEDI_MITE
- select COMEDI_8255
- select COMEDI_FC
- depends on VIRT_TO_BUS
- default N
- ---help---
- Enable support for National Instruments Lab-PC and compatibles
- Lab-PC-1200, Lab-PC-1200AI, Lab-PC+ and PCI-1200.
- Kernel-level ISA plug-and-play support for the lab-pc-1200 boards has
- not yet been added to the driver.
-
- To compile this driver as a module, choose M here: the module will be
- called ni_labpc.
-
-endif # COMEDI_NI_COMMON
-
config COMEDI_8255
tristate "Generic 8255 support"
- depends on COMEDI
- default N
---help---
Enable generic 8255 support.
@@ -1357,28 +1268,25 @@ config COMEDI_8255
To compile this driver as a module, choose M here: the module will be
called 8255.
-config COMEDI_DAS08
- tristate "DAS-08 compatible support"
- depends on COMEDI
+config COMEDI_FC
+ tristate
+
+config COMEDI_AMPLC_DIO200
+ tristate
select COMEDI_8255
- default N
- ---help---
- Enable support for DAS08 and compatible ISA, PC/104 and PCI cards.
- Note that PCMCIA DAS08 cards are not directly supported by this
- driver, and need a separate driver as a wrapper.
+config COMEDI_AMPLC_PC236
+ tristate
+ select COMEDI_8255
- To compile this driver as a module, choose M here: the module will be
- called das08.
+config COMEDI_AMPLC_PC263
+ tristate
-config COMEDI_FC
- tristate "Comedi shared functions for low-level driver support"
- depends on COMEDI
- default N
- ---help---
- Enable support for shared functions for low-level drivers.
- This module is not used directly by end-users. Rather, it
- is used by many other comedi drivers.
+config COMEDI_DAS08
+ tristate
+ select COMEDI_8255
- To compile this driver as a module, choose M here: the module will be
- called comedi_fc.
+config COMEDI_NI_TIO
+ tristate
+
+endif # COMEDI
diff --git a/drivers/staging/comedi/comedi.h b/drivers/staging/comedi/comedi.h
index 14ea35ac0156..8ea55aef10a7 100644
--- a/drivers/staging/comedi/comedi.h
+++ b/drivers/staging/comedi/comedi.h
@@ -465,7 +465,7 @@
/* only relevant to kernel modules. */
#define COMEDI_CB_EOS 1 /* end of scan */
-#define COMEDI_CB_EOA 2 /* end of acquisition */
+#define COMEDI_CB_EOA 2 /* end of acquisition/output */
#define COMEDI_CB_BLOCK 4 /* data has arrived:
* wakes up read() / write() */
#define COMEDI_CB_EOBUF 8 /* DEPRECATED: end of buffer */
diff --git a/drivers/staging/comedi/comedi_compat32.c b/drivers/staging/comedi/comedi_compat32.c
index 41a7a62ba49a..0a5057f0919b 100644
--- a/drivers/staging/comedi/comedi_compat32.c
+++ b/drivers/staging/comedi/comedi_compat32.c
@@ -26,6 +26,8 @@
#define __NO_VERSION__
#include <linux/uaccess.h>
+#include <linux/compat.h>
+#include <linux/fs.h>
#include "comedi.h"
#include "comedi_compat32.h"
diff --git a/drivers/staging/comedi/comedi_compat32.h b/drivers/staging/comedi/comedi_compat32.h
index 0340a8949c6b..60cf51c4a793 100644
--- a/drivers/staging/comedi/comedi_compat32.h
+++ b/drivers/staging/comedi/comedi_compat32.h
@@ -27,17 +27,15 @@
#ifndef _COMEDI_COMPAT32_H
#define _COMEDI_COMPAT32_H
-#include <linux/compat.h>
-#include <linux/fs.h>
-
#ifdef CONFIG_COMPAT
+struct file;
extern long comedi_compat_ioctl(struct file *file, unsigned int cmd,
unsigned long arg);
#else /* CONFIG_COMPAT */
-#define comedi_compat_ioctl 0 /* NULL */
+#define comedi_compat_ioctl NULL
#endif /* CONFIG_COMPAT */
diff --git a/drivers/staging/comedi/comedi_fops.c b/drivers/staging/comedi/comedi_fops.c
index 9bcf87ae4c00..e82126407e95 100644
--- a/drivers/staging/comedi/comedi_fops.c
+++ b/drivers/staging/comedi/comedi_fops.c
@@ -24,7 +24,6 @@
#undef DEBUG
#define __NO_VERSION__
-#include "comedi_fops.h"
#include "comedi_compat32.h"
#include <linux/module.h>
@@ -49,7 +48,7 @@
#include <linux/io.h>
#include <linux/uaccess.h>
-#include "internal.h"
+#include "comedi_internal.h"
MODULE_AUTHOR("http://www.comedi.org");
MODULE_DESCRIPTION("Comedi core module");
@@ -58,49 +57,40 @@ MODULE_LICENSE("GPL");
#ifdef CONFIG_COMEDI_DEBUG
int comedi_debug;
EXPORT_SYMBOL(comedi_debug);
-module_param(comedi_debug, int, 0644);
+module_param(comedi_debug, int, S_IRUGO | S_IWUSR);
+MODULE_PARM_DESC(comedi_debug,
+ "enable comedi core and driver debugging if non-zero (default 0)"
+ );
#endif
bool comedi_autoconfig = 1;
-module_param(comedi_autoconfig, bool, 0444);
+module_param(comedi_autoconfig, bool, S_IRUGO);
+MODULE_PARM_DESC(comedi_autoconfig,
+ "enable drivers to auto-configure comedi devices (default 1)");
static int comedi_num_legacy_minors;
-module_param(comedi_num_legacy_minors, int, 0444);
+module_param(comedi_num_legacy_minors, int, S_IRUGO);
+MODULE_PARM_DESC(comedi_num_legacy_minors,
+ "number of comedi minor devices to reserve for non-auto-configured devices (default 0)"
+ );
+
+unsigned int comedi_default_buf_size_kb = CONFIG_COMEDI_DEFAULT_BUF_SIZE_KB;
+module_param(comedi_default_buf_size_kb, uint, S_IRUGO | S_IWUSR);
+MODULE_PARM_DESC(comedi_default_buf_size_kb,
+ "default asynchronous buffer size in KiB (default "
+ __MODULE_STRING(CONFIG_COMEDI_DEFAULT_BUF_SIZE_KB) ")");
+
+unsigned int comedi_default_buf_maxsize_kb
+ = CONFIG_COMEDI_DEFAULT_BUF_MAXSIZE_KB;
+module_param(comedi_default_buf_maxsize_kb, uint, S_IRUGO | S_IWUSR);
+MODULE_PARM_DESC(comedi_default_buf_maxsize_kb,
+ "default maximum size of asynchronous buffer in KiB (default "
+ __MODULE_STRING(CONFIG_COMEDI_DEFAULT_BUF_MAXSIZE_KB) ")");
static DEFINE_SPINLOCK(comedi_file_info_table_lock);
static struct comedi_device_file_info
*comedi_file_info_table[COMEDI_NUM_MINORS];
-static int do_devconfig_ioctl(struct comedi_device *dev,
- struct comedi_devconfig __user *arg);
-static int do_bufconfig_ioctl(struct comedi_device *dev,
- struct comedi_bufconfig __user *arg);
-static int do_devinfo_ioctl(struct comedi_device *dev,
- struct comedi_devinfo __user *arg,
- struct file *file);
-static int do_subdinfo_ioctl(struct comedi_device *dev,
- struct comedi_subdinfo __user *arg, void *file);
-static int do_chaninfo_ioctl(struct comedi_device *dev,
- struct comedi_chaninfo __user *arg);
-static int do_bufinfo_ioctl(struct comedi_device *dev,
- struct comedi_bufinfo __user *arg, void *file);
-static int do_cmd_ioctl(struct comedi_device *dev,
- struct comedi_cmd __user *arg, void *file);
-static int do_lock_ioctl(struct comedi_device *dev, unsigned int arg,
- void *file);
-static int do_unlock_ioctl(struct comedi_device *dev, unsigned int arg,
- void *file);
-static int do_cancel_ioctl(struct comedi_device *dev, unsigned int arg,
- void *file);
-static int do_cmdtest_ioctl(struct comedi_device *dev,
- struct comedi_cmd __user *arg, void *file);
-static int do_insnlist_ioctl(struct comedi_device *dev,
- struct comedi_insnlist __user *arg, void *file);
-static int do_insn_ioctl(struct comedi_device *dev,
- struct comedi_insn __user *arg, void *file);
-static int do_poll_ioctl(struct comedi_device *dev, unsigned int subd,
- void *file);
-
static void do_become_nonbusy(struct comedi_device *dev,
struct comedi_subdevice *s);
static int do_cancel(struct comedi_device *dev, struct comedi_subdevice *s);
@@ -108,108 +98,226 @@ static int do_cancel(struct comedi_device *dev, struct comedi_subdevice *s);
static int comedi_fasync(int fd, struct file *file, int on);
static int is_device_busy(struct comedi_device *dev);
+
static int resize_async_buffer(struct comedi_device *dev,
struct comedi_subdevice *s,
- struct comedi_async *async, unsigned new_size);
+ struct comedi_async *async, unsigned new_size)
+{
+ int retval;
-/* declarations for sysfs attribute files */
-static struct device_attribute dev_attr_max_read_buffer_kb;
-static struct device_attribute dev_attr_read_buffer_kb;
-static struct device_attribute dev_attr_max_write_buffer_kb;
-static struct device_attribute dev_attr_write_buffer_kb;
+ if (new_size > async->max_bufsize)
+ return -EPERM;
-static long comedi_unlocked_ioctl(struct file *file, unsigned int cmd,
- unsigned long arg)
-{
- const unsigned minor = iminor(file->f_dentry->d_inode);
- struct comedi_device_file_info *dev_file_info =
- comedi_get_device_file_info(minor);
- struct comedi_device *dev;
- int rc;
+ if (s->busy) {
+ DPRINTK("subdevice is busy, cannot resize buffer\n");
+ return -EBUSY;
+ }
+ if (async->mmap_count) {
+ DPRINTK("subdevice is mmapped, cannot resize buffer\n");
+ return -EBUSY;
+ }
- if (dev_file_info == NULL || dev_file_info->device == NULL)
- return -ENODEV;
- dev = dev_file_info->device;
+ if (!async->prealloc_buf)
+ return -EINVAL;
- mutex_lock(&dev->mutex);
+ /* make sure buffer is an integral number of pages
+ * (we round up) */
+ new_size = (new_size + PAGE_SIZE - 1) & PAGE_MASK;
- /* Device config is special, because it must work on
- * an unconfigured device. */
- if (cmd == COMEDI_DEVCONFIG) {
- rc = do_devconfig_ioctl(dev,
- (struct comedi_devconfig __user *)arg);
- goto done;
- }
+ retval = comedi_buf_alloc(dev, s, new_size);
+ if (retval < 0)
+ return retval;
- if (!dev->attached) {
- DPRINTK("no driver configured on /dev/comedi%i\n", dev->minor);
- rc = -ENODEV;
- goto done;
+ if (s->buf_change) {
+ retval = s->buf_change(dev, s, new_size);
+ if (retval < 0)
+ return retval;
}
- switch (cmd) {
- case COMEDI_BUFCONFIG:
- rc = do_bufconfig_ioctl(dev,
- (struct comedi_bufconfig __user *)arg);
- break;
- case COMEDI_DEVINFO:
- rc = do_devinfo_ioctl(dev, (struct comedi_devinfo __user *)arg,
- file);
- break;
- case COMEDI_SUBDINFO:
- rc = do_subdinfo_ioctl(dev,
- (struct comedi_subdinfo __user *)arg,
- file);
- break;
- case COMEDI_CHANINFO:
- rc = do_chaninfo_ioctl(dev, (void __user *)arg);
- break;
- case COMEDI_RANGEINFO:
- rc = do_rangeinfo_ioctl(dev, (void __user *)arg);
- break;
- case COMEDI_BUFINFO:
- rc = do_bufinfo_ioctl(dev,
- (struct comedi_bufinfo __user *)arg,
- file);
- break;
- case COMEDI_LOCK:
- rc = do_lock_ioctl(dev, arg, file);
- break;
- case COMEDI_UNLOCK:
- rc = do_unlock_ioctl(dev, arg, file);
- break;
- case COMEDI_CANCEL:
- rc = do_cancel_ioctl(dev, arg, file);
- break;
- case COMEDI_CMD:
- rc = do_cmd_ioctl(dev, (struct comedi_cmd __user *)arg, file);
- break;
- case COMEDI_CMDTEST:
- rc = do_cmdtest_ioctl(dev, (struct comedi_cmd __user *)arg,
- file);
- break;
- case COMEDI_INSNLIST:
- rc = do_insnlist_ioctl(dev,
- (struct comedi_insnlist __user *)arg,
- file);
- break;
- case COMEDI_INSN:
- rc = do_insn_ioctl(dev, (struct comedi_insn __user *)arg,
- file);
- break;
- case COMEDI_POLL:
- rc = do_poll_ioctl(dev, arg, file);
- break;
- default:
- rc = -ENOTTY;
- break;
- }
+ DPRINTK("comedi%i subd %d buffer resized to %i bytes\n",
+ dev->minor, (int)(s - dev->subdevices), async->prealloc_bufsz);
+ return 0;
+}
-done:
- mutex_unlock(&dev->mutex);
- return rc;
+/* sysfs attribute files */
+
+static ssize_t show_max_read_buffer_kb(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+ struct comedi_device_file_info *info = dev_get_drvdata(dev);
+ struct comedi_subdevice *s = comedi_get_read_subdevice(info);
+ unsigned int size = 0;
+
+ mutex_lock(&info->device->mutex);
+ if (s && (s->subdev_flags & SDF_CMD_READ) && s->async)
+ size = s->async->max_bufsize / 1024;
+ mutex_unlock(&info->device->mutex);
+
+ return snprintf(buf, PAGE_SIZE, "%i\n", size);
+}
+
+static ssize_t store_max_read_buffer_kb(struct device *dev,
+ struct device_attribute *attr,
+ const char *buf, size_t count)
+{
+ struct comedi_device_file_info *info = dev_get_drvdata(dev);
+ struct comedi_subdevice *s = comedi_get_read_subdevice(info);
+ unsigned int size;
+ int err;
+
+ err = kstrtouint(buf, 10, &size);
+ if (err)
+ return err;
+ if (size > (UINT_MAX / 1024))
+ return -EINVAL;
+ size *= 1024;
+
+ mutex_lock(&info->device->mutex);
+ if (s && (s->subdev_flags & SDF_CMD_READ) && s->async)
+ s->async->max_bufsize = size;
+ else
+ err = -EINVAL;
+ mutex_unlock(&info->device->mutex);
+
+ return err ? err : count;
+}
+
+static ssize_t show_read_buffer_kb(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+ struct comedi_device_file_info *info = dev_get_drvdata(dev);
+ struct comedi_subdevice *s = comedi_get_read_subdevice(info);
+ unsigned int size = 0;
+
+ mutex_lock(&info->device->mutex);
+ if (s && (s->subdev_flags & SDF_CMD_READ) && s->async)
+ size = s->async->prealloc_bufsz / 1024;
+ mutex_unlock(&info->device->mutex);
+
+ return snprintf(buf, PAGE_SIZE, "%i\n", size);
+}
+
+static ssize_t store_read_buffer_kb(struct device *dev,
+ struct device_attribute *attr,
+ const char *buf, size_t count)
+{
+ struct comedi_device_file_info *info = dev_get_drvdata(dev);
+ struct comedi_subdevice *s = comedi_get_read_subdevice(info);
+ unsigned int size;
+ int err;
+
+ err = kstrtouint(buf, 10, &size);
+ if (err)
+ return err;
+ if (size > (UINT_MAX / 1024))
+ return -EINVAL;
+ size *= 1024;
+
+ mutex_lock(&info->device->mutex);
+ if (s && (s->subdev_flags & SDF_CMD_READ) && s->async)
+ err = resize_async_buffer(info->device, s, s->async, size);
+ else
+ err = -EINVAL;
+ mutex_unlock(&info->device->mutex);
+
+ return err ? err : count;
+}
+
+static ssize_t show_max_write_buffer_kb(struct device *dev,
+ struct device_attribute *attr,
+ char *buf)
+{
+ struct comedi_device_file_info *info = dev_get_drvdata(dev);
+ struct comedi_subdevice *s = comedi_get_write_subdevice(info);
+ unsigned int size = 0;
+
+ mutex_lock(&info->device->mutex);
+ if (s && (s->subdev_flags & SDF_CMD_WRITE) && s->async)
+ size = s->async->max_bufsize / 1024;
+ mutex_unlock(&info->device->mutex);
+
+ return snprintf(buf, PAGE_SIZE, "%i\n", size);
+}
+
+static ssize_t store_max_write_buffer_kb(struct device *dev,
+ struct device_attribute *attr,
+ const char *buf, size_t count)
+{
+ struct comedi_device_file_info *info = dev_get_drvdata(dev);
+ struct comedi_subdevice *s = comedi_get_write_subdevice(info);
+ unsigned int size;
+ int err;
+
+ err = kstrtouint(buf, 10, &size);
+ if (err)
+ return err;
+ if (size > (UINT_MAX / 1024))
+ return -EINVAL;
+ size *= 1024;
+
+ mutex_lock(&info->device->mutex);
+ if (s && (s->subdev_flags & SDF_CMD_WRITE) && s->async)
+ s->async->max_bufsize = size;
+ else
+ err = -EINVAL;
+ mutex_unlock(&info->device->mutex);
+
+ return err ? err : count;
+}
+
+static ssize_t show_write_buffer_kb(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+ struct comedi_device_file_info *info = dev_get_drvdata(dev);
+ struct comedi_subdevice *s = comedi_get_write_subdevice(info);
+ unsigned int size = 0;
+
+ mutex_lock(&info->device->mutex);
+ if (s && (s->subdev_flags & SDF_CMD_WRITE) && s->async)
+ size = s->async->prealloc_bufsz / 1024;
+ mutex_unlock(&info->device->mutex);
+
+ return snprintf(buf, PAGE_SIZE, "%i\n", size);
+}
+
+static ssize_t store_write_buffer_kb(struct device *dev,
+ struct device_attribute *attr,
+ const char *buf, size_t count)
+{
+ struct comedi_device_file_info *info = dev_get_drvdata(dev);
+ struct comedi_subdevice *s = comedi_get_write_subdevice(info);
+ unsigned int size;
+ int err;
+
+ err = kstrtouint(buf, 10, &size);
+ if (err)
+ return err;
+ if (size > (UINT_MAX / 1024))
+ return -EINVAL;
+ size *= 1024;
+
+ mutex_lock(&info->device->mutex);
+ if (s && (s->subdev_flags & SDF_CMD_WRITE) && s->async)
+ err = resize_async_buffer(info->device, s, s->async, size);
+ else
+ err = -EINVAL;
+ mutex_unlock(&info->device->mutex);
+
+ return err ? err : count;
}
+static struct device_attribute comedi_dev_attrs[] = {
+ __ATTR(max_read_buffer_kb, S_IRUGO | S_IWUSR,
+ show_max_read_buffer_kb, store_max_read_buffer_kb),
+ __ATTR(read_buffer_kb, S_IRUGO | S_IWUSR | S_IWGRP,
+ show_read_buffer_kb, store_read_buffer_kb),
+ __ATTR(max_write_buffer_kb, S_IRUGO | S_IWUSR,
+ show_max_write_buffer_kb, store_max_write_buffer_kb),
+ __ATTR(write_buffer_kb, S_IRUGO | S_IWUSR | S_IWGRP,
+ show_write_buffer_kb, store_write_buffer_kb),
+ __ATTR_NULL
+};
+
/*
COMEDI_DEVCONFIG
device config ioctl
@@ -280,7 +388,7 @@ static int do_devconfig_ioctl(struct comedi_device *dev,
if (ret == 0) {
if (!try_module_get(dev->driver->module)) {
comedi_device_detach(dev);
- return -ENOSYS;
+ ret = -ENOSYS;
}
}
@@ -1420,6 +1528,98 @@ static int do_poll_ioctl(struct comedi_device *dev, unsigned int arg,
return -EINVAL;
}
+static long comedi_unlocked_ioctl(struct file *file, unsigned int cmd,
+ unsigned long arg)
+{
+ const unsigned minor = iminor(file->f_dentry->d_inode);
+ struct comedi_device_file_info *dev_file_info =
+ comedi_get_device_file_info(minor);
+ struct comedi_device *dev;
+ int rc;
+
+ if (dev_file_info == NULL || dev_file_info->device == NULL)
+ return -ENODEV;
+ dev = dev_file_info->device;
+
+ mutex_lock(&dev->mutex);
+
+ /* Device config is special, because it must work on
+ * an unconfigured device. */
+ if (cmd == COMEDI_DEVCONFIG) {
+ rc = do_devconfig_ioctl(dev,
+ (struct comedi_devconfig __user *)arg);
+ goto done;
+ }
+
+ if (!dev->attached) {
+ DPRINTK("no driver configured on /dev/comedi%i\n", dev->minor);
+ rc = -ENODEV;
+ goto done;
+ }
+
+ switch (cmd) {
+ case COMEDI_BUFCONFIG:
+ rc = do_bufconfig_ioctl(dev,
+ (struct comedi_bufconfig __user *)arg);
+ break;
+ case COMEDI_DEVINFO:
+ rc = do_devinfo_ioctl(dev, (struct comedi_devinfo __user *)arg,
+ file);
+ break;
+ case COMEDI_SUBDINFO:
+ rc = do_subdinfo_ioctl(dev,
+ (struct comedi_subdinfo __user *)arg,
+ file);
+ break;
+ case COMEDI_CHANINFO:
+ rc = do_chaninfo_ioctl(dev, (void __user *)arg);
+ break;
+ case COMEDI_RANGEINFO:
+ rc = do_rangeinfo_ioctl(dev, (void __user *)arg);
+ break;
+ case COMEDI_BUFINFO:
+ rc = do_bufinfo_ioctl(dev,
+ (struct comedi_bufinfo __user *)arg,
+ file);
+ break;
+ case COMEDI_LOCK:
+ rc = do_lock_ioctl(dev, arg, file);
+ break;
+ case COMEDI_UNLOCK:
+ rc = do_unlock_ioctl(dev, arg, file);
+ break;
+ case COMEDI_CANCEL:
+ rc = do_cancel_ioctl(dev, arg, file);
+ break;
+ case COMEDI_CMD:
+ rc = do_cmd_ioctl(dev, (struct comedi_cmd __user *)arg, file);
+ break;
+ case COMEDI_CMDTEST:
+ rc = do_cmdtest_ioctl(dev, (struct comedi_cmd __user *)arg,
+ file);
+ break;
+ case COMEDI_INSNLIST:
+ rc = do_insnlist_ioctl(dev,
+ (struct comedi_insnlist __user *)arg,
+ file);
+ break;
+ case COMEDI_INSN:
+ rc = do_insn_ioctl(dev, (struct comedi_insn __user *)arg,
+ file);
+ break;
+ case COMEDI_POLL:
+ rc = do_poll_ioctl(dev, arg, file);
+ break;
+ default:
+ rc = -ENOTTY;
+ break;
+ }
+
+done:
+ mutex_unlock(&dev->mutex);
+ return rc;
+}
+
static int do_cancel(struct comedi_device *dev, struct comedi_subdevice *s)
{
int ret = 0;
@@ -1545,7 +1745,7 @@ done:
return retval;
}
-static unsigned int comedi_poll(struct file *file, poll_table * wait)
+static unsigned int comedi_poll(struct file *file, poll_table *wait)
{
unsigned int mask = 0;
const unsigned minor = iminor(file->f_dentry->d_inode);
@@ -1981,7 +2181,7 @@ static int comedi_fasync(int fd, struct file *file, int on)
return fasync_helper(fd, file, on, &dev->async_queue);
}
-const struct file_operations comedi_fops = {
+static const struct file_operations comedi_fops = {
.owner = THIS_MODULE,
.unlocked_ioctl = comedi_unlocked_ioctl,
.compat_ioctl = comedi_compat_ioctl,
@@ -1995,7 +2195,7 @@ const struct file_operations comedi_fops = {
.llseek = noop_llseek,
};
-struct class *comedi_class;
+static struct class *comedi_class;
static struct cdev comedi_cdev;
static void comedi_cleanup_legacy_minors(void)
@@ -2054,6 +2254,8 @@ static int __init comedi_init(void)
return PTR_ERR(comedi_class);
}
+ comedi_class->dev_attrs = comedi_dev_attrs;
+
/* XXX requires /proc interface */
comedi_proc_init();
@@ -2192,11 +2394,9 @@ static void comedi_device_cleanup(struct comedi_device *dev)
int comedi_alloc_board_minor(struct device *hardware_device)
{
- unsigned long flags;
struct comedi_device_file_info *info;
struct device *csdev;
unsigned i;
- int retval;
info = kzalloc(sizeof(struct comedi_device_file_info), GFP_KERNEL);
if (info == NULL)
@@ -2206,15 +2406,16 @@ int comedi_alloc_board_minor(struct device *hardware_device)
kfree(info);
return -ENOMEM;
}
+ info->hardware_device = hardware_device;
comedi_device_init(info->device);
- spin_lock_irqsave(&comedi_file_info_table_lock, flags);
+ spin_lock(&comedi_file_info_table_lock);
for (i = 0; i < COMEDI_NUM_BOARD_MINORS; ++i) {
if (comedi_file_info_table[i] == NULL) {
comedi_file_info_table[i] = info;
break;
}
}
- spin_unlock_irqrestore(&comedi_file_info_table_lock, flags);
+ spin_unlock(&comedi_file_info_table_lock);
if (i == COMEDI_NUM_BOARD_MINORS) {
comedi_device_cleanup(info->device);
kfree(info->device);
@@ -2230,55 +2431,19 @@ int comedi_alloc_board_minor(struct device *hardware_device)
if (!IS_ERR(csdev))
info->device->class_dev = csdev;
dev_set_drvdata(csdev, info);
- retval = device_create_file(csdev, &dev_attr_max_read_buffer_kb);
- if (retval) {
- printk(KERN_ERR
- "comedi: "
- "failed to create sysfs attribute file \"%s\".\n",
- dev_attr_max_read_buffer_kb.attr.name);
- comedi_free_board_minor(i);
- return retval;
- }
- retval = device_create_file(csdev, &dev_attr_read_buffer_kb);
- if (retval) {
- printk(KERN_ERR
- "comedi: "
- "failed to create sysfs attribute file \"%s\".\n",
- dev_attr_read_buffer_kb.attr.name);
- comedi_free_board_minor(i);
- return retval;
- }
- retval = device_create_file(csdev, &dev_attr_max_write_buffer_kb);
- if (retval) {
- printk(KERN_ERR
- "comedi: "
- "failed to create sysfs attribute file \"%s\".\n",
- dev_attr_max_write_buffer_kb.attr.name);
- comedi_free_board_minor(i);
- return retval;
- }
- retval = device_create_file(csdev, &dev_attr_write_buffer_kb);
- if (retval) {
- printk(KERN_ERR
- "comedi: "
- "failed to create sysfs attribute file \"%s\".\n",
- dev_attr_write_buffer_kb.attr.name);
- comedi_free_board_minor(i);
- return retval;
- }
+
return i;
}
void comedi_free_board_minor(unsigned minor)
{
- unsigned long flags;
struct comedi_device_file_info *info;
BUG_ON(minor >= COMEDI_NUM_BOARD_MINORS);
- spin_lock_irqsave(&comedi_file_info_table_lock, flags);
+ spin_lock(&comedi_file_info_table_lock);
info = comedi_file_info_table[minor];
comedi_file_info_table[minor] = NULL;
- spin_unlock_irqrestore(&comedi_file_info_table_lock, flags);
+ spin_unlock(&comedi_file_info_table_lock);
if (info) {
struct comedi_device *dev = info->device;
@@ -2294,14 +2459,29 @@ void comedi_free_board_minor(unsigned minor)
}
}
+int comedi_find_board_minor(struct device *hardware_device)
+{
+ int minor;
+ struct comedi_device_file_info *info;
+
+ for (minor = 0; minor < COMEDI_NUM_BOARD_MINORS; minor++) {
+ spin_lock(&comedi_file_info_table_lock);
+ info = comedi_file_info_table[minor];
+ if (info && info->hardware_device == hardware_device) {
+ spin_unlock(&comedi_file_info_table_lock);
+ return minor;
+ }
+ spin_unlock(&comedi_file_info_table_lock);
+ }
+ return -ENODEV;
+}
+
int comedi_alloc_subdevice_minor(struct comedi_device *dev,
struct comedi_subdevice *s)
{
- unsigned long flags;
struct comedi_device_file_info *info;
struct device *csdev;
unsigned i;
- int retval;
info = kmalloc(sizeof(struct comedi_device_file_info), GFP_KERNEL);
if (info == NULL)
@@ -2309,14 +2489,14 @@ int comedi_alloc_subdevice_minor(struct comedi_device *dev,
info->device = dev;
info->read_subdevice = s;
info->write_subdevice = s;
- spin_lock_irqsave(&comedi_file_info_table_lock, flags);
+ spin_lock(&comedi_file_info_table_lock);
for (i = COMEDI_FIRST_SUBDEVICE_MINOR; i < COMEDI_NUM_MINORS; ++i) {
if (comedi_file_info_table[i] == NULL) {
comedi_file_info_table[i] = info;
break;
}
}
- spin_unlock_irqrestore(&comedi_file_info_table_lock, flags);
+ spin_unlock(&comedi_file_info_table_lock);
if (i == COMEDI_NUM_MINORS) {
kfree(info);
printk(KERN_ERR
@@ -2331,48 +2511,12 @@ int comedi_alloc_subdevice_minor(struct comedi_device *dev,
if (!IS_ERR(csdev))
s->class_dev = csdev;
dev_set_drvdata(csdev, info);
- retval = device_create_file(csdev, &dev_attr_max_read_buffer_kb);
- if (retval) {
- printk(KERN_ERR
- "comedi: "
- "failed to create sysfs attribute file \"%s\".\n",
- dev_attr_max_read_buffer_kb.attr.name);
- comedi_free_subdevice_minor(s);
- return retval;
- }
- retval = device_create_file(csdev, &dev_attr_read_buffer_kb);
- if (retval) {
- printk(KERN_ERR
- "comedi: "
- "failed to create sysfs attribute file \"%s\".\n",
- dev_attr_read_buffer_kb.attr.name);
- comedi_free_subdevice_minor(s);
- return retval;
- }
- retval = device_create_file(csdev, &dev_attr_max_write_buffer_kb);
- if (retval) {
- printk(KERN_ERR
- "comedi: "
- "failed to create sysfs attribute file \"%s\".\n",
- dev_attr_max_write_buffer_kb.attr.name);
- comedi_free_subdevice_minor(s);
- return retval;
- }
- retval = device_create_file(csdev, &dev_attr_write_buffer_kb);
- if (retval) {
- printk(KERN_ERR
- "comedi: "
- "failed to create sysfs attribute file \"%s\".\n",
- dev_attr_write_buffer_kb.attr.name);
- comedi_free_subdevice_minor(s);
- return retval;
- }
+
return i;
}
void comedi_free_subdevice_minor(struct comedi_subdevice *s)
{
- unsigned long flags;
struct comedi_device_file_info *info;
if (s == NULL)
@@ -2383,10 +2527,10 @@ void comedi_free_subdevice_minor(struct comedi_subdevice *s)
BUG_ON(s->minor >= COMEDI_NUM_MINORS);
BUG_ON(s->minor < COMEDI_FIRST_SUBDEVICE_MINOR);
- spin_lock_irqsave(&comedi_file_info_table_lock, flags);
+ spin_lock(&comedi_file_info_table_lock);
info = comedi_file_info_table[s->minor];
comedi_file_info_table[s->minor] = NULL;
- spin_unlock_irqrestore(&comedi_file_info_table_lock, flags);
+ spin_unlock(&comedi_file_info_table_lock);
if (s->class_dev) {
device_destroy(comedi_class, MKDEV(COMEDI_MAJOR, s->minor));
@@ -2397,310 +2541,12 @@ void comedi_free_subdevice_minor(struct comedi_subdevice *s)
struct comedi_device_file_info *comedi_get_device_file_info(unsigned minor)
{
- unsigned long flags;
struct comedi_device_file_info *info;
BUG_ON(minor >= COMEDI_NUM_MINORS);
- spin_lock_irqsave(&comedi_file_info_table_lock, flags);
+ spin_lock(&comedi_file_info_table_lock);
info = comedi_file_info_table[minor];
- spin_unlock_irqrestore(&comedi_file_info_table_lock, flags);
+ spin_unlock(&comedi_file_info_table_lock);
return info;
}
EXPORT_SYMBOL_GPL(comedi_get_device_file_info);
-
-static int resize_async_buffer(struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_async *async, unsigned new_size)
-{
- int retval;
-
- if (new_size > async->max_bufsize)
- return -EPERM;
-
- if (s->busy) {
- DPRINTK("subdevice is busy, cannot resize buffer\n");
- return -EBUSY;
- }
- if (async->mmap_count) {
- DPRINTK("subdevice is mmapped, cannot resize buffer\n");
- return -EBUSY;
- }
-
- if (!async->prealloc_buf)
- return -EINVAL;
-
- /* make sure buffer is an integral number of pages
- * (we round up) */
- new_size = (new_size + PAGE_SIZE - 1) & PAGE_MASK;
-
- retval = comedi_buf_alloc(dev, s, new_size);
- if (retval < 0)
- return retval;
-
- if (s->buf_change) {
- retval = s->buf_change(dev, s, new_size);
- if (retval < 0)
- return retval;
- }
-
- DPRINTK("comedi%i subd %d buffer resized to %i bytes\n",
- dev->minor, (int)(s - dev->subdevices), async->prealloc_bufsz);
- return 0;
-}
-
-/* sysfs attribute files */
-
-static const unsigned bytes_per_kibi = 1024;
-
-static ssize_t show_max_read_buffer_kb(struct device *dev,
- struct device_attribute *attr, char *buf)
-{
- ssize_t retval;
- struct comedi_device_file_info *info = dev_get_drvdata(dev);
- unsigned max_buffer_size_kb = 0;
- struct comedi_subdevice *const read_subdevice =
- comedi_get_read_subdevice(info);
-
- mutex_lock(&info->device->mutex);
- if (read_subdevice &&
- (read_subdevice->subdev_flags & SDF_CMD_READ) &&
- read_subdevice->async) {
- max_buffer_size_kb = read_subdevice->async->max_bufsize /
- bytes_per_kibi;
- }
- retval = snprintf(buf, PAGE_SIZE, "%i\n", max_buffer_size_kb);
- mutex_unlock(&info->device->mutex);
-
- return retval;
-}
-
-static ssize_t store_max_read_buffer_kb(struct device *dev,
- struct device_attribute *attr,
- const char *buf, size_t count)
-{
- struct comedi_device_file_info *info = dev_get_drvdata(dev);
- unsigned int new_max_size_kb;
- unsigned int new_max_size;
- int ret;
- struct comedi_subdevice *const read_subdevice =
- comedi_get_read_subdevice(info);
-
- ret = kstrtouint(buf, 10, &new_max_size_kb);
- if (ret)
- return ret;
- if (new_max_size_kb > (UINT_MAX / bytes_per_kibi))
- return -EINVAL;
- new_max_size = new_max_size_kb * bytes_per_kibi;
-
- mutex_lock(&info->device->mutex);
- if (read_subdevice == NULL ||
- (read_subdevice->subdev_flags & SDF_CMD_READ) == 0 ||
- read_subdevice->async == NULL) {
- mutex_unlock(&info->device->mutex);
- return -EINVAL;
- }
- read_subdevice->async->max_bufsize = new_max_size;
- mutex_unlock(&info->device->mutex);
-
- return count;
-}
-
-static struct device_attribute dev_attr_max_read_buffer_kb = {
- .attr = {
- .name = "max_read_buffer_kb",
- .mode = S_IRUGO | S_IWUSR},
- .show = &show_max_read_buffer_kb,
- .store = &store_max_read_buffer_kb
-};
-
-static ssize_t show_read_buffer_kb(struct device *dev,
- struct device_attribute *attr, char *buf)
-{
- ssize_t retval;
- struct comedi_device_file_info *info = dev_get_drvdata(dev);
- unsigned buffer_size_kb = 0;
- struct comedi_subdevice *const read_subdevice =
- comedi_get_read_subdevice(info);
-
- mutex_lock(&info->device->mutex);
- if (read_subdevice &&
- (read_subdevice->subdev_flags & SDF_CMD_READ) &&
- read_subdevice->async) {
- buffer_size_kb = read_subdevice->async->prealloc_bufsz /
- bytes_per_kibi;
- }
- retval = snprintf(buf, PAGE_SIZE, "%i\n", buffer_size_kb);
- mutex_unlock(&info->device->mutex);
-
- return retval;
-}
-
-static ssize_t store_read_buffer_kb(struct device *dev,
- struct device_attribute *attr,
- const char *buf, size_t count)
-{
- struct comedi_device_file_info *info = dev_get_drvdata(dev);
- unsigned int new_size_kb;
- unsigned int new_size;
- int retval;
- int ret;
- struct comedi_subdevice *const read_subdevice =
- comedi_get_read_subdevice(info);
-
- ret = kstrtouint(buf, 10, &new_size_kb);
- if (ret)
- return ret;
- if (new_size_kb > (UINT_MAX / bytes_per_kibi))
- return -EINVAL;
- new_size = new_size_kb * bytes_per_kibi;
-
- mutex_lock(&info->device->mutex);
- if (read_subdevice == NULL ||
- (read_subdevice->subdev_flags & SDF_CMD_READ) == 0 ||
- read_subdevice->async == NULL) {
- mutex_unlock(&info->device->mutex);
- return -EINVAL;
- }
- retval = resize_async_buffer(info->device, read_subdevice,
- read_subdevice->async, new_size);
- mutex_unlock(&info->device->mutex);
-
- if (retval < 0)
- return retval;
- return count;
-}
-
-static struct device_attribute dev_attr_read_buffer_kb = {
- .attr = {
- .name = "read_buffer_kb",
- .mode = S_IRUGO | S_IWUSR | S_IWGRP},
- .show = &show_read_buffer_kb,
- .store = &store_read_buffer_kb
-};
-
-static ssize_t show_max_write_buffer_kb(struct device *dev,
- struct device_attribute *attr,
- char *buf)
-{
- ssize_t retval;
- struct comedi_device_file_info *info = dev_get_drvdata(dev);
- unsigned max_buffer_size_kb = 0;
- struct comedi_subdevice *const write_subdevice =
- comedi_get_write_subdevice(info);
-
- mutex_lock(&info->device->mutex);
- if (write_subdevice &&
- (write_subdevice->subdev_flags & SDF_CMD_WRITE) &&
- write_subdevice->async) {
- max_buffer_size_kb = write_subdevice->async->max_bufsize /
- bytes_per_kibi;
- }
- retval = snprintf(buf, PAGE_SIZE, "%i\n", max_buffer_size_kb);
- mutex_unlock(&info->device->mutex);
-
- return retval;
-}
-
-static ssize_t store_max_write_buffer_kb(struct device *dev,
- struct device_attribute *attr,
- const char *buf, size_t count)
-{
- struct comedi_device_file_info *info = dev_get_drvdata(dev);
- unsigned int new_max_size_kb;
- unsigned int new_max_size;
- int ret;
- struct comedi_subdevice *const write_subdevice =
- comedi_get_write_subdevice(info);
-
- ret = kstrtouint(buf, 10, &new_max_size_kb);
- if (ret)
- return ret;
- if (new_max_size_kb > (UINT_MAX / bytes_per_kibi))
- return -EINVAL;
- new_max_size = new_max_size_kb * bytes_per_kibi;
-
- mutex_lock(&info->device->mutex);
- if (write_subdevice == NULL ||
- (write_subdevice->subdev_flags & SDF_CMD_WRITE) == 0 ||
- write_subdevice->async == NULL) {
- mutex_unlock(&info->device->mutex);
- return -EINVAL;
- }
- write_subdevice->async->max_bufsize = new_max_size;
- mutex_unlock(&info->device->mutex);
-
- return count;
-}
-
-static struct device_attribute dev_attr_max_write_buffer_kb = {
- .attr = {
- .name = "max_write_buffer_kb",
- .mode = S_IRUGO | S_IWUSR},
- .show = &show_max_write_buffer_kb,
- .store = &store_max_write_buffer_kb
-};
-
-static ssize_t show_write_buffer_kb(struct device *dev,
- struct device_attribute *attr, char *buf)
-{
- ssize_t retval;
- struct comedi_device_file_info *info = dev_get_drvdata(dev);
- unsigned buffer_size_kb = 0;
- struct comedi_subdevice *const write_subdevice =
- comedi_get_write_subdevice(info);
-
- mutex_lock(&info->device->mutex);
- if (write_subdevice &&
- (write_subdevice->subdev_flags & SDF_CMD_WRITE) &&
- write_subdevice->async) {
- buffer_size_kb = write_subdevice->async->prealloc_bufsz /
- bytes_per_kibi;
- }
- retval = snprintf(buf, PAGE_SIZE, "%i\n", buffer_size_kb);
- mutex_unlock(&info->device->mutex);
-
- return retval;
-}
-
-static ssize_t store_write_buffer_kb(struct device *dev,
- struct device_attribute *attr,
- const char *buf, size_t count)
-{
- struct comedi_device_file_info *info = dev_get_drvdata(dev);
- unsigned int new_size_kb;
- unsigned int new_size;
- int retval;
- int ret;
- struct comedi_subdevice *const write_subdevice =
- comedi_get_write_subdevice(info);
-
- ret = kstrtouint(buf, 10, &new_size_kb);
- if (ret)
- return ret;
- if (new_size_kb > (UINT_MAX / bytes_per_kibi))
- return -EINVAL;
- new_size = ((uint64_t) new_size_kb) * bytes_per_kibi;
-
- mutex_lock(&info->device->mutex);
- if (write_subdevice == NULL ||
- (write_subdevice->subdev_flags & SDF_CMD_WRITE) == 0 ||
- write_subdevice->async == NULL) {
- mutex_unlock(&info->device->mutex);
- return -EINVAL;
- }
- retval = resize_async_buffer(info->device, write_subdevice,
- write_subdevice->async, new_size);
- mutex_unlock(&info->device->mutex);
-
- if (retval < 0)
- return retval;
- return count;
-}
-
-static struct device_attribute dev_attr_write_buffer_kb = {
- .attr = {
- .name = "write_buffer_kb",
- .mode = S_IRUGO | S_IWUSR | S_IWGRP},
- .show = &show_write_buffer_kb,
- .store = &store_write_buffer_kb
-};
diff --git a/drivers/staging/comedi/comedi_fops.h b/drivers/staging/comedi/comedi_fops.h
deleted file mode 100644
index 006cf14c577a..000000000000
--- a/drivers/staging/comedi/comedi_fops.h
+++ /dev/null
@@ -1,11 +0,0 @@
-
-#ifndef _COMEDI_FOPS_H
-#define _COMEDI_FOPS_H
-#include <linux/types.h>
-
-extern struct class *comedi_class;
-extern const struct file_operations comedi_fops;
-extern bool comedi_autoconfig;
-extern struct comedi_driver *comedi_drivers;
-
-#endif /* _COMEDI_FOPS_H */
diff --git a/drivers/staging/comedi/internal.h b/drivers/staging/comedi/comedi_internal.h
index 434ce3433368..e70ef0515d9a 100644
--- a/drivers/staging/comedi/internal.h
+++ b/drivers/staging/comedi/comedi_internal.h
@@ -1,5 +1,10 @@
+#ifndef _COMEDI_INTERNAL_H
+#define _COMEDI_INTERNAL_H
+
+#include <linux/types.h>
+
/*
- * various internal comedi functions
+ * various internal comedi stuff
*/
int do_rangeinfo_ioctl(struct comedi_device *dev,
struct comedi_rangeinfo __user *arg);
@@ -7,6 +12,14 @@ int insn_inval(struct comedi_device *dev, struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data);
int comedi_alloc_board_minor(struct device *hardware_device);
void comedi_free_board_minor(unsigned minor);
+int comedi_find_board_minor(struct device *hardware_device);
void comedi_reset_async_buf(struct comedi_async *async);
int comedi_buf_alloc(struct comedi_device *dev, struct comedi_subdevice *s,
unsigned long new_size);
+
+extern unsigned int comedi_default_buf_size_kb;
+extern unsigned int comedi_default_buf_maxsize_kb;
+extern bool comedi_autoconfig;
+extern struct comedi_driver *comedi_drivers;
+
+#endif /* _COMEDI_INTERNAL_H */
diff --git a/drivers/staging/comedi/comedidev.h b/drivers/staging/comedi/comedidev.h
index 7a0d4bcbc355..f713783ef624 100644
--- a/drivers/staging/comedi/comedidev.h
+++ b/drivers/staging/comedi/comedidev.h
@@ -40,6 +40,7 @@
#include <linux/uaccess.h>
#include <linux/io.h>
#include <linux/timer.h>
+#include <linux/pci.h>
#include "comedi.h"
@@ -77,7 +78,7 @@ struct comedi_subdevice {
unsigned runflags;
spinlock_t spin_lock;
- int io_bits;
+ unsigned int io_bits;
unsigned int maxdata; /* if maxdata==0, use list */
const unsigned int *maxdata_list; /* list is channel specific */
@@ -180,13 +181,17 @@ struct comedi_async {
unsigned int x);
};
+struct usb_interface;
+
struct comedi_driver {
struct comedi_driver *next;
const char *driver_name;
struct module *module;
int (*attach) (struct comedi_device *, struct comedi_devconfig *);
- int (*detach) (struct comedi_device *);
+ void (*detach) (struct comedi_device *);
+ int (*attach_pci) (struct comedi_device *, struct pci_dev *);
+ int (*attach_usb) (struct comedi_device *, struct usb_interface *);
/* number of elements in board_name and board_id arrays */
unsigned int num_names;
@@ -230,10 +235,16 @@ struct comedi_device {
void (*close) (struct comedi_device *dev);
};
+static inline const void *comedi_board(struct comedi_device *dev)
+{
+ return dev->board_ptr;
+}
+
struct comedi_device_file_info {
struct comedi_device *device;
struct comedi_subdevice *read_subdevice;
struct comedi_subdevice *write_subdevice;
+ struct device *hardware_device;
};
#ifdef CONFIG_COMEDI_DEBUG
@@ -281,12 +292,65 @@ static inline struct comedi_subdevice *comedi_get_write_subdevice(
return info->device->write_subdev;
}
+int comedi_alloc_subdevices(struct comedi_device *, int);
+
void comedi_device_detach(struct comedi_device *dev);
int comedi_device_attach(struct comedi_device *dev,
struct comedi_devconfig *it);
int comedi_driver_register(struct comedi_driver *);
int comedi_driver_unregister(struct comedi_driver *);
+/**
+ * module_comedi_driver() - Helper macro for registering a comedi driver
+ * @__comedi_driver: comedi_driver struct
+ *
+ * Helper macro for comedi drivers which do not do anything special in module
+ * init/exit. This eliminates a lot of boilerplate. Each module may only use
+ * this macro once, and calling it replaces module_init() and module_exit().
+ */
+#define module_comedi_driver(__comedi_driver) \
+ module_driver(__comedi_driver, comedi_driver_register, \
+ comedi_driver_unregister)
+
+int comedi_pci_enable(struct pci_dev *, const char *);
+void comedi_pci_disable(struct pci_dev *);
+
+int comedi_pci_driver_register(struct comedi_driver *, struct pci_driver *);
+void comedi_pci_driver_unregister(struct comedi_driver *, struct pci_driver *);
+
+/**
+ * module_comedi_pci_driver() - Helper macro for registering a comedi PCI driver
+ * @__comedi_driver: comedi_driver struct
+ * @__pci_driver: pci_driver struct
+ *
+ * Helper macro for comedi PCI drivers which do not do anything special
+ * in module init/exit. This eliminates a lot of boilerplate. Each
+ * module may only use this macro once, and calling it replaces
+ * module_init() and module_exit()
+ */
+#define module_comedi_pci_driver(__comedi_driver, __pci_driver) \
+ module_driver(__comedi_driver, comedi_pci_driver_register, \
+ comedi_pci_driver_unregister, &(__pci_driver))
+
+struct usb_driver;
+
+int comedi_usb_driver_register(struct comedi_driver *, struct usb_driver *);
+void comedi_usb_driver_unregister(struct comedi_driver *, struct usb_driver *);
+
+/**
+ * module_comedi_usb_driver() - Helper macro for registering a comedi USB driver
+ * @__comedi_driver: comedi_driver struct
+ * @__usb_driver: usb_driver struct
+ *
+ * Helper macro for comedi USB drivers which do not do anything special
+ * in module init/exit. This eliminates a lot of boilerplate. Each
+ * module may only use this macro once, and calling it replaces
+ * module_init() and module_exit()
+ */
+#define module_comedi_usb_driver(__comedi_driver, __usb_driver) \
+ module_driver(__comedi_driver, comedi_usb_driver_register, \
+ comedi_usb_driver_unregister, &(__usb_driver))
+
void init_polling(void);
void cleanup_polling(void);
void start_polling(struct comedi_device *);
@@ -351,26 +415,6 @@ struct comedi_lrange {
/* some silly little inline functions */
-static inline int alloc_subdevices(struct comedi_device *dev,
- unsigned int num_subdevices)
-{
- unsigned i;
-
- dev->n_subdevices = num_subdevices;
- dev->subdevices =
- kcalloc(num_subdevices, sizeof(struct comedi_subdevice),
- GFP_KERNEL);
- if (!dev->subdevices)
- return -ENOMEM;
- for (i = 0; i < num_subdevices; ++i) {
- dev->subdevices[i].device = dev;
- dev->subdevices[i].async_dma_dir = DMA_NONE;
- spin_lock_init(&dev->subdevices[i].spin_lock);
- dev->subdevices[i].minor = -1;
- }
- return 0;
-}
-
static inline int alloc_private(struct comedi_device *dev, int size)
{
dev->private = kzalloc(size, GFP_KERNEL);
@@ -402,6 +446,11 @@ static inline void comedi_set_hw_dev(struct comedi_device *dev,
}
}
+static inline struct pci_dev *comedi_to_pci_dev(struct comedi_device *dev)
+{
+ return dev->hw_dev ? to_pci_dev(dev->hw_dev) : NULL;
+}
+
int comedi_buf_put(struct comedi_async *async, short x);
int comedi_buf_get(struct comedi_async *async, short *x);
@@ -456,23 +505,11 @@ static inline void *comedi_aux_data(int options[], int n)
int comedi_alloc_subdevice_minor(struct comedi_device *dev,
struct comedi_subdevice *s);
void comedi_free_subdevice_minor(struct comedi_subdevice *s);
-int comedi_pci_auto_config(struct pci_dev *pcidev, const char *board_name);
+int comedi_pci_auto_config(struct pci_dev *pcidev,
+ struct comedi_driver *driver);
void comedi_pci_auto_unconfig(struct pci_dev *pcidev);
-struct usb_device; /* forward declaration */
-int comedi_usb_auto_config(struct usb_device *usbdev, const char *board_name);
-void comedi_usb_auto_unconfig(struct usb_device *usbdev);
-
-#ifdef CONFIG_COMEDI_PCI_DRIVERS
-#define CONFIG_COMEDI_PCI
-#endif
-#ifdef CONFIG_COMEDI_PCI_DRIVERS_MODULE
-#define CONFIG_COMEDI_PCI
-#endif
-#ifdef CONFIG_COMEDI_PCMCIA_DRIVERS
-#define CONFIG_COMEDI_PCMCIA
-#endif
-#ifdef CONFIG_COMEDI_PCMCIA_DRIVERS_MODULE
-#define CONFIG_COMEDI_PCMCIA
-#endif
+int comedi_usb_auto_config(struct usb_interface *intf,
+ struct comedi_driver *driver);
+void comedi_usb_auto_unconfig(struct usb_interface *intf);
#endif /* _COMEDIDEV_H */
diff --git a/drivers/staging/comedi/drivers.c b/drivers/staging/comedi/drivers.c
index bf185e2807d1..c0fdb00783ed 100644
--- a/drivers/staging/comedi/drivers.c
+++ b/drivers/staging/comedi/drivers.c
@@ -24,12 +24,12 @@
#define _GNU_SOURCE
#define __NO_VERSION__
-#include "comedi_fops.h"
#include <linux/device.h>
#include <linux/module.h>
#include <linux/pci.h>
#include <linux/usb.h>
#include <linux/errno.h>
+#include <linux/kconfig.h>
#include <linux/kernel.h>
#include <linux/sched.h>
#include <linux/fcntl.h>
@@ -44,7 +44,7 @@
#include <linux/io.h>
#include "comedidev.h"
-#include "internal.h"
+#include "comedi_internal.h"
static int postconfig(struct comedi_device *dev);
static int insn_rw_emulate_bits(struct comedi_device *dev,
@@ -56,6 +56,31 @@ static int poll_invalid(struct comedi_device *dev, struct comedi_subdevice *s);
struct comedi_driver *comedi_drivers;
+int comedi_alloc_subdevices(struct comedi_device *dev, int num_subdevices)
+{
+ struct comedi_subdevice *s;
+ int i;
+
+ if (num_subdevices < 1)
+ return -EINVAL;
+
+ s = kcalloc(num_subdevices, sizeof(*s), GFP_KERNEL);
+ if (!s)
+ return -ENOMEM;
+ dev->subdevices = s;
+ dev->n_subdevices = num_subdevices;
+
+ for (i = 0; i < num_subdevices; ++i) {
+ s = dev->subdevices + i;
+ s->device = dev;
+ s->async_dma_dir = DMA_NONE;
+ spin_lock_init(&s->spin_lock);
+ s->minor = -1;
+ }
+ return 0;
+}
+EXPORT_SYMBOL_GPL(comedi_alloc_subdevices);
+
static void cleanup_device(struct comedi_device *dev)
{
int i;
@@ -106,6 +131,26 @@ void comedi_device_detach(struct comedi_device *dev)
__comedi_device_detach(dev);
}
+/* do a little post-config cleanup */
+/* called with module refcount incremented, decrements it */
+static int comedi_device_postconfig(struct comedi_device *dev)
+{
+ int ret = postconfig(dev);
+ module_put(dev->driver->module);
+ if (ret < 0) {
+ __comedi_device_detach(dev);
+ return ret;
+ }
+ if (!dev->board_name) {
+ printk(KERN_WARNING "BUG: dev->board_name=<%p>\n",
+ dev->board_name);
+ dev->board_name = "BUG";
+ }
+ smp_wmb();
+ dev->attached = 1;
+ return 0;
+}
+
int comedi_device_attach(struct comedi_device *dev, struct comedi_devconfig *it)
{
struct comedi_driver *driv;
@@ -121,59 +166,36 @@ int comedi_device_attach(struct comedi_device *dev, struct comedi_devconfig *it)
}
if (driv->num_names) {
dev->board_ptr = comedi_recognize(driv, it->board_name);
- if (dev->board_ptr == NULL) {
- module_put(driv->module);
- continue;
- }
- } else {
- if (strcmp(driv->driver_name, it->board_name)) {
- module_put(driv->module);
+ if (dev->board_ptr)
+ break;
+ } else if (strcmp(driv->driver_name, it->board_name))
+ break;
+ module_put(driv->module);
+ }
+ if (driv == NULL) {
+ /* recognize has failed if we get here */
+ /* report valid board names before returning error */
+ for (driv = comedi_drivers; driv; driv = driv->next) {
+ if (!try_module_get(driv->module)) {
+ printk(KERN_INFO
+ "comedi: failed to increment module count\n");
continue;
}
+ comedi_report_boards(driv);
+ module_put(driv->module);
}
- /* initialize dev->driver here so
- * comedi_error() can be called from attach */
- dev->driver = driv;
- ret = driv->attach(dev, it);
- if (ret < 0) {
- module_put(dev->driver->module);
- __comedi_device_detach(dev);
- return ret;
- }
- goto attached;
- }
-
- /* recognize has failed if we get here */
- /* report valid board names before returning error */
- for (driv = comedi_drivers; driv; driv = driv->next) {
- if (!try_module_get(driv->module)) {
- printk(KERN_INFO
- "comedi: failed to increment module count\n");
- continue;
- }
- comedi_report_boards(driv);
- module_put(driv->module);
+ return -EIO;
}
- return -EIO;
-
-attached:
- /* do a little post-config cleanup */
- ret = postconfig(dev);
- module_put(dev->driver->module);
+ /* initialize dev->driver here so
+ * comedi_error() can be called from attach */
+ dev->driver = driv;
+ ret = driv->attach(dev, it);
if (ret < 0) {
+ module_put(dev->driver->module);
__comedi_device_detach(dev);
return ret;
}
-
- if (!dev->board_name) {
- printk(KERN_WARNING "BUG: dev->board_name=<%p>\n",
- dev->board_name);
- dev->board_name = "BUG";
- }
- smp_wmb();
- dev->attached = 1;
-
- return 0;
+ return comedi_device_postconfig(dev);
}
int comedi_driver_register(struct comedi_driver *driver)
@@ -242,6 +264,8 @@ static int postconfig(struct comedi_device *dev)
s->len_chanlist = 1;
if (s->do_cmd) {
+ unsigned int buf_size;
+
BUG_ON((s->subdev_flags & (SDF_CMD_READ |
SDF_CMD_WRITE)) == 0);
BUG_ON(!s->do_cmdtest);
@@ -257,19 +281,20 @@ static int postconfig(struct comedi_device *dev)
async->subdevice = s;
s->async = async;
-#define DEFAULT_BUF_MAXSIZE (64*1024)
-#define DEFAULT_BUF_SIZE (64*1024)
-
- async->max_bufsize = DEFAULT_BUF_MAXSIZE;
+ async->max_bufsize =
+ comedi_default_buf_maxsize_kb * 1024;
+ buf_size = comedi_default_buf_size_kb * 1024;
+ if (buf_size > async->max_bufsize)
+ buf_size = async->max_bufsize;
async->prealloc_buf = NULL;
async->prealloc_bufsz = 0;
- if (comedi_buf_alloc(dev, s, DEFAULT_BUF_SIZE) < 0) {
+ if (comedi_buf_alloc(dev, s, buf_size) < 0) {
printk(KERN_INFO "Buffer allocation failed\n");
return -ENOMEM;
}
if (s->buf_change) {
- ret = s->buf_change(dev, s, DEFAULT_BUF_SIZE);
+ ret = s->buf_change(dev, s, buf_size);
if (ret < 0)
return ret;
}
@@ -300,18 +325,41 @@ static int postconfig(struct comedi_device *dev)
return 0;
}
-/* generic recognize function for drivers
- * that register their supported board names */
+/*
+ * Generic recognize function for drivers that register their supported
+ * board names.
+ *
+ * 'driv->board_name' points to a 'const char *' member within the
+ * zeroth element of an array of some private board information
+ * structure, say 'struct foo_board' containing a member 'const char
+ * *board_name' that is initialized to point to a board name string that
+ * is one of the candidates matched against this function's 'name'
+ * parameter.
+ *
+ * 'driv->offset' is the size of the private board information
+ * structure, say 'sizeof(struct foo_board)', and 'driv->num_names' is
+ * the length of the array of private board information structures.
+ *
+ * If one of the board names in the array of private board information
+ * structures matches the name supplied to this function, the function
+ * returns a pointer to the pointer to the board name, otherwise it
+ * returns NULL. The return value ends up in the 'board_ptr' member of
+ * a 'struct comedi_device' that the low-level comedi driver's
+ * 'attach()' hook can convert to a point to a particular element of its
+ * array of private board information structures by subtracting the
+ * offset of the member that points to the board name. (No subtraction
+ * is required if the board name pointer is the first member of the
+ * private board information structure, which is generally the case.)
+ */
static void *comedi_recognize(struct comedi_driver *driv, const char *name)
{
- unsigned i;
- const char *const *name_ptr = driv->board_name;
+ char **name_ptr = (char **)driv->board_name;
+ int i;
+
for (i = 0; i < driv->num_names; i++) {
if (strcmp(*name_ptr, name) == 0)
- return (void *)name_ptr;
- name_ptr =
- (const char *const *)((const char *)name_ptr +
- driv->offset);
+ return name_ptr;
+ name_ptr = (void *)name_ptr + driv->offset;
}
return NULL;
@@ -384,39 +432,6 @@ static int insn_rw_emulate_bits(struct comedi_device *dev,
return 1;
}
-static inline unsigned long uvirt_to_kva(pgd_t *pgd, unsigned long adr)
-{
- unsigned long ret = 0UL;
- pmd_t *pmd;
- pte_t *ptep, pte;
- pud_t *pud;
-
- if (!pgd_none(*pgd)) {
- pud = pud_offset(pgd, adr);
- pmd = pmd_offset(pud, adr);
- if (!pmd_none(*pmd)) {
- ptep = pte_offset_kernel(pmd, adr);
- pte = *ptep;
- if (pte_present(pte)) {
- ret = (unsigned long)
- page_address(pte_page(pte));
- ret |= (adr & (PAGE_SIZE - 1));
- }
- }
- }
- return ret;
-}
-
-static inline unsigned long kvirt_to_kva(unsigned long adr)
-{
- unsigned long va, kva;
-
- va = adr;
- kva = uvirt_to_kva(pgd_offset_k(va), va);
-
- return kva;
-}
-
int comedi_buf_alloc(struct comedi_device *dev, struct comedi_subdevice *s,
unsigned long new_size)
{
@@ -814,67 +829,136 @@ void comedi_reset_async_buf(struct comedi_async *async)
async->events = 0;
}
-static int comedi_auto_config(struct device *hardware_device,
- const char *board_name, const int *options,
- unsigned num_options)
+static int
+comedi_auto_config_helper(struct device *hardware_device,
+ struct comedi_driver *driver,
+ int (*attach_wrapper) (struct comedi_device *,
+ void *), void *context)
{
- struct comedi_devconfig it;
int minor;
struct comedi_device_file_info *dev_file_info;
- int retval;
- unsigned *private_data = NULL;
+ struct comedi_device *comedi_dev;
+ int ret;
- if (!comedi_autoconfig) {
- dev_set_drvdata(hardware_device, NULL);
+ if (!comedi_autoconfig)
return 0;
- }
minor = comedi_alloc_board_minor(hardware_device);
if (minor < 0)
return minor;
- private_data = kmalloc(sizeof(unsigned), GFP_KERNEL);
- if (private_data == NULL) {
- retval = -ENOMEM;
- goto cleanup;
+ dev_file_info = comedi_get_device_file_info(minor);
+ comedi_dev = dev_file_info->device;
+
+ mutex_lock(&comedi_dev->mutex);
+ if (comedi_dev->attached)
+ ret = -EBUSY;
+ else if (!try_module_get(driver->module)) {
+ printk(KERN_INFO "comedi: failed to increment module count\n");
+ ret = -EIO;
+ } else {
+ /* set comedi_dev->driver here for attach wrapper */
+ comedi_dev->driver = driver;
+ ret = (*attach_wrapper)(comedi_dev, context);
+ if (ret < 0) {
+ module_put(driver->module);
+ __comedi_device_detach(comedi_dev);
+ } else {
+ ret = comedi_device_postconfig(comedi_dev);
+ }
}
- *private_data = minor;
- dev_set_drvdata(hardware_device, private_data);
+ mutex_unlock(&comedi_dev->mutex);
- dev_file_info = comedi_get_device_file_info(minor);
+ if (ret < 0)
+ comedi_free_board_minor(minor);
+ return ret;
+}
+
+static int comedi_auto_config_wrapper(struct comedi_device *dev, void *context)
+{
+ struct comedi_devconfig *it = context;
+ struct comedi_driver *driv = dev->driver;
+
+ if (driv->num_names) {
+ /* look for generic board entry matching driver name, which
+ * has already been copied to it->board_name */
+ dev->board_ptr = comedi_recognize(driv, it->board_name);
+ if (dev->board_ptr == NULL) {
+ printk(KERN_WARNING
+ "comedi: auto config failed to find board entry"
+ " '%s' for driver '%s'\n", it->board_name,
+ driv->driver_name);
+ comedi_report_boards(driv);
+ return -EINVAL;
+ }
+ }
+ return driv->attach(dev, it);
+}
+
+static int comedi_auto_config(struct device *hardware_device,
+ struct comedi_driver *driver, const int *options,
+ unsigned num_options)
+{
+ struct comedi_devconfig it;
memset(&it, 0, sizeof(it));
- strncpy(it.board_name, board_name, COMEDI_NAMELEN);
+ strncpy(it.board_name, driver->driver_name, COMEDI_NAMELEN);
it.board_name[COMEDI_NAMELEN - 1] = '\0';
BUG_ON(num_options > COMEDI_NDEVCONFOPTS);
memcpy(it.options, options, num_options * sizeof(int));
-
- mutex_lock(&dev_file_info->device->mutex);
- retval = comedi_device_attach(dev_file_info->device, &it);
- mutex_unlock(&dev_file_info->device->mutex);
-
-cleanup:
- if (retval < 0) {
- kfree(private_data);
- comedi_free_board_minor(minor);
- }
- return retval;
+ return comedi_auto_config_helper(hardware_device, driver,
+ comedi_auto_config_wrapper, &it);
}
static void comedi_auto_unconfig(struct device *hardware_device)
{
- unsigned *minor = (unsigned *)dev_get_drvdata(hardware_device);
- if (minor == NULL)
+ int minor;
+
+ if (hardware_device == NULL)
+ return;
+ minor = comedi_find_board_minor(hardware_device);
+ if (minor < 0)
return;
+ BUG_ON(minor >= COMEDI_NUM_BOARD_MINORS);
+ comedi_free_board_minor(minor);
+}
+
+/**
+ * comedi_pci_enable() - Enable the PCI device and request the regions.
+ * @pdev: pci_dev struct
+ * @res_name: name for the requested reqource
+ */
+int comedi_pci_enable(struct pci_dev *pdev, const char *res_name)
+{
+ int rc;
- BUG_ON(*minor >= COMEDI_NUM_BOARD_MINORS);
+ rc = pci_enable_device(pdev);
+ if (rc < 0)
+ return rc;
- comedi_free_board_minor(*minor);
- dev_set_drvdata(hardware_device, NULL);
- kfree(minor);
+ rc = pci_request_regions(pdev, res_name);
+ if (rc < 0)
+ pci_disable_device(pdev);
+
+ return rc;
+}
+EXPORT_SYMBOL_GPL(comedi_pci_enable);
+
+/**
+ * comedi_pci_disable() - Release the regions and disable the PCI device.
+ * @pdev: pci_dev struct
+ *
+ * This must be matched with a previous successful call to comedi_pci_enable().
+ */
+void comedi_pci_disable(struct pci_dev *pdev)
+{
+ pci_release_regions(pdev);
+ pci_disable_device(pdev);
}
+EXPORT_SYMBOL_GPL(comedi_pci_disable);
-int comedi_pci_auto_config(struct pci_dev *pcidev, const char *board_name)
+static int comedi_old_pci_auto_config(struct pci_dev *pcidev,
+ struct comedi_driver *driver)
{
int options[2];
@@ -883,9 +967,30 @@ int comedi_pci_auto_config(struct pci_dev *pcidev, const char *board_name)
/* pci slot */
options[1] = PCI_SLOT(pcidev->devfn);
- return comedi_auto_config(&pcidev->dev, board_name,
+ return comedi_auto_config(&pcidev->dev, driver,
options, ARRAY_SIZE(options));
}
+
+static int comedi_pci_attach_wrapper(struct comedi_device *dev, void *pcidev)
+{
+ return dev->driver->attach_pci(dev, pcidev);
+}
+
+static int comedi_new_pci_auto_config(struct pci_dev *pcidev,
+ struct comedi_driver *driver)
+{
+ return comedi_auto_config_helper(&pcidev->dev, driver,
+ comedi_pci_attach_wrapper, pcidev);
+}
+
+int comedi_pci_auto_config(struct pci_dev *pcidev, struct comedi_driver *driver)
+{
+
+ if (driver->attach_pci)
+ return comedi_new_pci_auto_config(pcidev, driver);
+ else
+ return comedi_old_pci_auto_config(pcidev, driver);
+}
EXPORT_SYMBOL_GPL(comedi_pci_auto_config);
void comedi_pci_auto_unconfig(struct pci_dev *pcidev)
@@ -894,16 +999,100 @@ void comedi_pci_auto_unconfig(struct pci_dev *pcidev)
}
EXPORT_SYMBOL_GPL(comedi_pci_auto_unconfig);
-int comedi_usb_auto_config(struct usb_device *usbdev, const char *board_name)
+int comedi_pci_driver_register(struct comedi_driver *comedi_driver,
+ struct pci_driver *pci_driver)
{
- BUG_ON(usbdev == NULL);
- return comedi_auto_config(&usbdev->dev, board_name, NULL, 0);
+ int ret;
+
+ ret = comedi_driver_register(comedi_driver);
+ if (ret < 0)
+ return ret;
+
+ /* FIXME: Remove this test after auditing all comedi pci drivers */
+ if (!pci_driver->name)
+ pci_driver->name = comedi_driver->driver_name;
+
+ ret = pci_register_driver(pci_driver);
+ if (ret < 0) {
+ comedi_driver_unregister(comedi_driver);
+ return ret;
+ }
+
+ return 0;
+}
+EXPORT_SYMBOL_GPL(comedi_pci_driver_register);
+
+void comedi_pci_driver_unregister(struct comedi_driver *comedi_driver,
+ struct pci_driver *pci_driver)
+{
+ pci_unregister_driver(pci_driver);
+ comedi_driver_unregister(comedi_driver);
+}
+EXPORT_SYMBOL_GPL(comedi_pci_driver_unregister);
+
+#if IS_ENABLED(CONFIG_USB)
+
+static int comedi_old_usb_auto_config(struct usb_interface *intf,
+ struct comedi_driver *driver)
+{
+ return comedi_auto_config(&intf->dev, driver, NULL, 0);
+}
+
+static int comedi_usb_attach_wrapper(struct comedi_device *dev, void *intf)
+{
+ return dev->driver->attach_usb(dev, intf);
+}
+
+static int comedi_new_usb_auto_config(struct usb_interface *intf,
+ struct comedi_driver *driver)
+{
+ return comedi_auto_config_helper(&intf->dev, driver,
+ comedi_usb_attach_wrapper, intf);
+}
+
+int comedi_usb_auto_config(struct usb_interface *intf,
+ struct comedi_driver *driver)
+{
+ BUG_ON(intf == NULL);
+ if (driver->attach_usb)
+ return comedi_new_usb_auto_config(intf, driver);
+ else
+ return comedi_old_usb_auto_config(intf, driver);
}
EXPORT_SYMBOL_GPL(comedi_usb_auto_config);
-void comedi_usb_auto_unconfig(struct usb_device *usbdev)
+void comedi_usb_auto_unconfig(struct usb_interface *intf)
{
- BUG_ON(usbdev == NULL);
- comedi_auto_unconfig(&usbdev->dev);
+ BUG_ON(intf == NULL);
+ comedi_auto_unconfig(&intf->dev);
}
EXPORT_SYMBOL_GPL(comedi_usb_auto_unconfig);
+
+int comedi_usb_driver_register(struct comedi_driver *comedi_driver,
+ struct usb_driver *usb_driver)
+{
+ int ret;
+
+ ret = comedi_driver_register(comedi_driver);
+ if (ret < 0)
+ return ret;
+
+ ret = usb_register(usb_driver);
+ if (ret < 0) {
+ comedi_driver_unregister(comedi_driver);
+ return ret;
+ }
+
+ return 0;
+}
+EXPORT_SYMBOL_GPL(comedi_usb_driver_register);
+
+void comedi_usb_driver_unregister(struct comedi_driver *comedi_driver,
+ struct usb_driver *usb_driver)
+{
+ usb_deregister(usb_driver);
+ comedi_driver_unregister(comedi_driver);
+}
+EXPORT_SYMBOL_GPL(comedi_usb_driver_unregister);
+
+#endif
diff --git a/drivers/staging/comedi/drivers/8255.c b/drivers/staging/comedi/drivers/8255.c
index 6c26ac887eee..4c9977b8a5ae 100644
--- a/drivers/staging/comedi/drivers/8255.c
+++ b/drivers/staging/comedi/drivers/8255.c
@@ -60,15 +60,15 @@ I/O port base address can be found in the output of 'lspci -v'.
set up the subdevice in the attach function of the driver by
calling:
- subdev_8255_init(device, subdevice, callback_function, arg)
+ subdev_8255_init(device, subdevice, io_function, iobase)
device and subdevice are pointers to the device and subdevice
- structures. callback_function will be called to provide the
+ structures. io_function will be called to provide the
low-level input/output to the device, i.e., actual register
- access. callback_function will be called with the value of arg
+ access. io_function will be called with the value of iobase
as the last parameter. If the 8255 device is mapped as 4
- consecutive I/O ports, you can use NULL for callback_function
- and the I/O port base for arg, and an internal function will
+ consecutive I/O ports, you can use NULL for io_function
+ and the I/O port base for iobase, and an internal function will
handle the register access.
In addition, if the main driver handles interrupts, you can
@@ -84,10 +84,10 @@ I/O port base address can be found in the output of 'lspci -v'.
#include <linux/slab.h>
#include "8255.h"
-#define _8255_SIZE 4
+#define _8255_SIZE 4
-#define _8255_DATA 0
-#define _8255_CR 3
+#define _8255_DATA 0
+#define _8255_CR 3
#define CR_C_LO_IO 0x01
#define CR_B_IO 0x02
@@ -97,48 +97,30 @@ I/O port base address can be found in the output of 'lspci -v'.
#define CR_A_MODE(a) ((a)<<5)
#define CR_CW 0x80
-struct subdev_8255_struct {
- unsigned long cb_arg;
- int (*cb_func) (int, int, int, unsigned long);
- int have_irq;
-};
-
-#define CALLBACK_ARG (((struct subdev_8255_struct *)s->private)->cb_arg)
-#define CALLBACK_FUNC (((struct subdev_8255_struct *)s->private)->cb_func)
-#define subdevpriv ((struct subdev_8255_struct *)s->private)
-
-static int dev_8255_attach(struct comedi_device *dev,
- struct comedi_devconfig *it);
-static int dev_8255_detach(struct comedi_device *dev);
-static struct comedi_driver driver_8255 = {
- .driver_name = "8255",
- .module = THIS_MODULE,
- .attach = dev_8255_attach,
- .detach = dev_8255_detach,
+struct subdev_8255_private {
+ unsigned long iobase;
+ int (*io) (int, int, int, unsigned long);
};
-static int __init driver_8255_init_module(void)
+static int subdev_8255_io(int dir, int port, int data, unsigned long iobase)
{
- return comedi_driver_register(&driver_8255);
-}
-
-static void __exit driver_8255_cleanup_module(void)
-{
- comedi_driver_unregister(&driver_8255);
+ if (dir) {
+ outb(data, iobase + port);
+ return 0;
+ } else {
+ return inb(iobase + port);
+ }
}
-module_init(driver_8255_init_module);
-module_exit(driver_8255_cleanup_module);
-
-static void do_config(struct comedi_device *dev, struct comedi_subdevice *s);
-
void subdev_8255_interrupt(struct comedi_device *dev,
struct comedi_subdevice *s)
{
+ struct subdev_8255_private *spriv = s->private;
+ unsigned long iobase = spriv->iobase;
short d;
- d = CALLBACK_FUNC(0, _8255_DATA, 0, CALLBACK_ARG);
- d |= (CALLBACK_FUNC(0, _8255_DATA + 1, 0, CALLBACK_ARG) << 8);
+ d = spriv->io(0, _8255_DATA, 0, iobase);
+ d |= (spriv->io(0, _8255_DATA + 1, 0, iobase) << 8);
comedi_buf_put(s->async, d);
s->async->events |= COMEDI_CB_EOS;
@@ -147,42 +129,62 @@ void subdev_8255_interrupt(struct comedi_device *dev,
}
EXPORT_SYMBOL(subdev_8255_interrupt);
-static int subdev_8255_cb(int dir, int port, int data, unsigned long arg)
+static int subdev_8255_insn(struct comedi_device *dev,
+ struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
- unsigned long iobase = arg;
+ struct subdev_8255_private *spriv = s->private;
+ unsigned long iobase = spriv->iobase;
+ unsigned int mask;
+ unsigned int bits;
+ unsigned int v;
- if (dir) {
- outb(data, iobase + port);
- return 0;
- } else {
- return inb(iobase + port);
+ mask = data[0];
+ bits = data[1];
+
+ if (mask) {
+ v = s->state;
+ v &= ~mask;
+ v |= (bits & mask);
+
+ if (mask & 0xff)
+ spriv->io(1, _8255_DATA, v & 0xff, iobase);
+ if (mask & 0xff00)
+ spriv->io(1, _8255_DATA + 1, (v >> 8) & 0xff, iobase);
+ if (mask & 0xff0000)
+ spriv->io(1, _8255_DATA + 2, (v >> 16) & 0xff, iobase);
+
+ s->state = v;
}
+
+ v = spriv->io(0, _8255_DATA, 0, iobase);
+ v |= (spriv->io(0, _8255_DATA + 1, 0, iobase) << 8);
+ v |= (spriv->io(0, _8255_DATA + 2, 0, iobase) << 16);
+
+ data[1] = v;
+
+ return insn->n;
}
-static int subdev_8255_insn(struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data)
+static void subdev_8255_do_config(struct comedi_device *dev,
+ struct comedi_subdevice *s)
{
- if (data[0]) {
- s->state &= ~data[0];
- s->state |= (data[0] & data[1]);
-
- if (data[0] & 0xff)
- CALLBACK_FUNC(1, _8255_DATA, s->state & 0xff,
- CALLBACK_ARG);
- if (data[0] & 0xff00)
- CALLBACK_FUNC(1, _8255_DATA + 1, (s->state >> 8) & 0xff,
- CALLBACK_ARG);
- if (data[0] & 0xff0000)
- CALLBACK_FUNC(1, _8255_DATA + 2,
- (s->state >> 16) & 0xff, CALLBACK_ARG);
- }
+ struct subdev_8255_private *spriv = s->private;
+ unsigned long iobase = spriv->iobase;
+ int config;
- data[1] = CALLBACK_FUNC(0, _8255_DATA, 0, CALLBACK_ARG);
- data[1] |= (CALLBACK_FUNC(0, _8255_DATA + 1, 0, CALLBACK_ARG) << 8);
- data[1] |= (CALLBACK_FUNC(0, _8255_DATA + 2, 0, CALLBACK_ARG) << 16);
+ config = CR_CW;
+ /* 1 in io_bits indicates output, 1 in config indicates input */
+ if (!(s->io_bits & 0x0000ff))
+ config |= CR_A_IO;
+ if (!(s->io_bits & 0x00ff00))
+ config |= CR_B_IO;
+ if (!(s->io_bits & 0x0f0000))
+ config |= CR_C_LO_IO;
+ if (!(s->io_bits & 0xf00000))
+ config |= CR_C_HI_IO;
- return 2;
+ spriv->io(1, _8255_CR, config, iobase);
}
static int subdev_8255_insn_config(struct comedi_device *dev,
@@ -217,28 +219,11 @@ static int subdev_8255_insn_config(struct comedi_device *dev,
return -EINVAL;
}
- do_config(dev, s);
+ subdev_8255_do_config(dev, s);
return 1;
}
-static void do_config(struct comedi_device *dev, struct comedi_subdevice *s)
-{
- int config;
-
- config = CR_CW;
- /* 1 in io_bits indicates output, 1 in config indicates input */
- if (!(s->io_bits & 0x0000ff))
- config |= CR_A_IO;
- if (!(s->io_bits & 0x00ff00))
- config |= CR_B_IO;
- if (!(s->io_bits & 0x0f0000))
- config |= CR_C_LO_IO;
- if (!(s->io_bits & 0xf00000))
- config |= CR_C_HI_IO;
- CALLBACK_FUNC(1, _8255_CR, config, CALLBACK_ARG);
-}
-
static int subdev_8255_cmdtest(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_cmd *cmd)
@@ -332,50 +317,50 @@ static int subdev_8255_cancel(struct comedi_device *dev,
}
int subdev_8255_init(struct comedi_device *dev, struct comedi_subdevice *s,
- int (*cb) (int, int, int, unsigned long),
- unsigned long arg)
+ int (*io) (int, int, int, unsigned long),
+ unsigned long iobase)
{
- s->type = COMEDI_SUBD_DIO;
- s->subdev_flags = SDF_READABLE | SDF_WRITABLE;
- s->n_chan = 24;
- s->range_table = &range_digital;
- s->maxdata = 1;
-
- s->private = kmalloc(sizeof(struct subdev_8255_struct), GFP_KERNEL);
- if (!s->private)
+ struct subdev_8255_private *spriv;
+
+ spriv = kzalloc(sizeof(*spriv), GFP_KERNEL);
+ if (!spriv)
return -ENOMEM;
- CALLBACK_ARG = arg;
- if (cb == NULL)
- CALLBACK_FUNC = subdev_8255_cb;
- else
- CALLBACK_FUNC = cb;
- s->insn_bits = subdev_8255_insn;
- s->insn_config = subdev_8255_insn_config;
+ spriv->iobase = iobase;
+ spriv->io = io ? io : subdev_8255_io;
+
+ s->private = spriv;
+
+ s->type = COMEDI_SUBD_DIO;
+ s->subdev_flags = SDF_READABLE | SDF_WRITABLE;
+ s->n_chan = 24;
+ s->range_table = &range_digital;
+ s->maxdata = 1;
+ s->insn_bits = subdev_8255_insn;
+ s->insn_config = subdev_8255_insn_config;
- s->state = 0;
- s->io_bits = 0;
- do_config(dev, s);
+ s->state = 0;
+ s->io_bits = 0;
+
+ subdev_8255_do_config(dev, s);
return 0;
}
EXPORT_SYMBOL(subdev_8255_init);
int subdev_8255_init_irq(struct comedi_device *dev, struct comedi_subdevice *s,
- int (*cb) (int, int, int, unsigned long),
- unsigned long arg)
+ int (*io) (int, int, int, unsigned long),
+ unsigned long iobase)
{
int ret;
- ret = subdev_8255_init(dev, s, cb, arg);
- if (ret < 0)
+ ret = subdev_8255_init(dev, s, io, iobase);
+ if (ret)
return ret;
- s->do_cmdtest = subdev_8255_cmdtest;
- s->do_cmd = subdev_8255_cmd;
- s->cancel = subdev_8255_cancel;
-
- subdevpriv->have_irq = 1;
+ s->do_cmdtest = subdev_8255_cmdtest;
+ s->do_cmd = subdev_8255_cmd;
+ s->cancel = subdev_8255_cancel;
return 0;
}
@@ -396,6 +381,7 @@ EXPORT_SYMBOL(subdev_8255_cleanup);
static int dev_8255_attach(struct comedi_device *dev,
struct comedi_devconfig *it)
{
+ struct comedi_subdevice *s;
int ret;
unsigned long iobase;
int i;
@@ -408,60 +394,58 @@ static int dev_8255_attach(struct comedi_device *dev,
break;
}
if (i == 0) {
- printk(KERN_WARNING
- "comedi%d: 8255: no devices specified\n", dev->minor);
+ dev_warn(dev->class_dev, "no devices specified\n");
return -EINVAL;
}
- ret = alloc_subdevices(dev, i);
- if (ret < 0) {
- /* FIXME this printk call should give a proper message, the
- * below line just maintains previous functionality */
- printk("comedi%d: 8255:", dev->minor);
+ ret = comedi_alloc_subdevices(dev, i);
+ if (ret)
return ret;
- }
-
- printk(KERN_INFO "comedi%d: 8255:", dev->minor);
for (i = 0; i < dev->n_subdevices; i++) {
+ s = dev->subdevices + i;
iobase = it->options[i];
- printk(" 0x%04lx", iobase);
if (!request_region(iobase, _8255_SIZE, "8255")) {
- printk(" (I/O port conflict)");
+ dev_warn(dev->class_dev,
+ "0x%04lx (I/O port conflict)\n", iobase);
- dev->subdevices[i].type = COMEDI_SUBD_UNUSED;
+ s->type = COMEDI_SUBD_UNUSED;
} else {
- subdev_8255_init(dev, dev->subdevices + i, NULL,
- iobase);
+ ret = subdev_8255_init(dev, s, NULL, iobase);
+ if (ret)
+ return ret;
+ dev_info(dev->class_dev, "0x%04lx\n", iobase);
}
}
- printk("\n");
-
return 0;
}
-static int dev_8255_detach(struct comedi_device *dev)
+static void dev_8255_detach(struct comedi_device *dev)
{
- int i;
- unsigned long iobase;
struct comedi_subdevice *s;
-
- printk(KERN_INFO "comedi%d: 8255: remove\n", dev->minor);
+ struct subdev_8255_private *spriv;
+ int i;
for (i = 0; i < dev->n_subdevices; i++) {
s = dev->subdevices + i;
if (s->type != COMEDI_SUBD_UNUSED) {
- iobase = CALLBACK_ARG;
- release_region(iobase, _8255_SIZE);
+ spriv = s->private;
+ release_region(spriv->iobase, _8255_SIZE);
}
subdev_8255_cleanup(dev, s);
}
-
- return 0;
}
+static struct comedi_driver dev_8255_driver = {
+ .driver_name = "8255",
+ .module = THIS_MODULE,
+ .attach = dev_8255_attach,
+ .detach = dev_8255_detach,
+};
+module_comedi_driver(dev_8255_driver);
+
MODULE_AUTHOR("Comedi http://www.comedi.org");
MODULE_DESCRIPTION("Comedi low-level driver");
MODULE_LICENSE("GPL");
diff --git a/drivers/staging/comedi/drivers/8255.h b/drivers/staging/comedi/drivers/8255.h
index b6314c9b7eae..1e589b4b8b73 100644
--- a/drivers/staging/comedi/drivers/8255.h
+++ b/drivers/staging/comedi/drivers/8255.h
@@ -27,11 +27,11 @@
#include "../comedidev.h"
int subdev_8255_init(struct comedi_device *dev, struct comedi_subdevice *s,
- int (*cb) (int, int, int, unsigned long),
- unsigned long arg);
+ int (*io) (int, int, int, unsigned long),
+ unsigned long iobase);
int subdev_8255_init_irq(struct comedi_device *dev, struct comedi_subdevice *s,
- int (*cb) (int, int, int, unsigned long),
- unsigned long arg);
+ int (*io) (int, int, int, unsigned long),
+ unsigned long iobase);
void subdev_8255_cleanup(struct comedi_device *dev, struct comedi_subdevice *s);
void subdev_8255_interrupt(struct comedi_device *dev,
struct comedi_subdevice *s);
diff --git a/drivers/staging/comedi/drivers/Makefile b/drivers/staging/comedi/drivers/Makefile
index 170da6091959..57b19e44d867 100644
--- a/drivers/staging/comedi/drivers/Makefile
+++ b/drivers/staging/comedi/drivers/Makefile
@@ -55,7 +55,6 @@ obj-$(CONFIG_COMEDI_MULTIQ3) += multiq3.o
obj-$(CONFIG_COMEDI_POC) += poc.o
# Comedi PCI drivers
-obj-$(CONFIG_COMEDI_PCI_DRIVERS) += 8255.o
obj-$(CONFIG_COMEDI_ADDI_APCI_035) += addi_apci_035.o
obj-$(CONFIG_COMEDI_ADDI_APCI_1032) += addi_apci_1032.o
obj-$(CONFIG_COMEDI_ADDI_APCI_1500) += addi_apci_1500.o
@@ -132,7 +131,7 @@ obj-$(CONFIG_COMEDI_VMK80XX) += vmk80xx.o
# Comedi NI drivers
obj-$(CONFIG_COMEDI_MITE) += mite.o
obj-$(CONFIG_COMEDI_NI_TIO) += ni_tio.o
-obj-$(CONFIG_COMEDI_NI_TIO) += ni_tiocmd.o
+obj-$(CONFIG_COMEDI_NI_TIOCMD) += ni_tiocmd.o
obj-$(CONFIG_COMEDI_NI_LABPC) += ni_labpc.o
obj-$(CONFIG_COMEDI_8255) += 8255.o
diff --git a/drivers/staging/comedi/drivers/acl7225b.c b/drivers/staging/comedi/drivers/acl7225b.c
index 9def2250bb80..ddba5db1e2e1 100644
--- a/drivers/staging/comedi/drivers/acl7225b.c
+++ b/drivers/staging/comedi/drivers/acl7225b.c
@@ -22,53 +22,15 @@ Devices: [Adlink] ACL-7225b (acl7225b), [ICP] P16R16DIO (p16r16dio)
#define ACL7225_DI_LO 2 /* Digital input low byte (DI0-DI7) */
#define ACL7225_DI_HI 3 /* Digital input high byte (DI8-DI15) */
-static int acl7225b_attach(struct comedi_device *dev,
- struct comedi_devconfig *it);
-static int acl7225b_detach(struct comedi_device *dev);
-
struct boardtype {
const char *name; /* driver name */
int io_range; /* len of I/O space */
};
-static const struct boardtype boardtypes[] = {
- {"acl7225b", ACL7225_SIZE,},
- {"p16r16dio", P16R16DIO_SIZE,},
-};
-
-#define n_boardtypes (sizeof(boardtypes)/sizeof(struct boardtype))
-#define this_board ((const struct boardtype *)dev->board_ptr)
-
-static struct comedi_driver driver_acl7225b = {
- .driver_name = "acl7225b",
- .module = THIS_MODULE,
- .attach = acl7225b_attach,
- .detach = acl7225b_detach,
- .board_name = &boardtypes[0].name,
- .num_names = n_boardtypes,
- .offset = sizeof(struct boardtype),
-};
-
-static int __init driver_acl7225b_init_module(void)
-{
- return comedi_driver_register(&driver_acl7225b);
-}
-
-static void __exit driver_acl7225b_cleanup_module(void)
-{
- comedi_driver_unregister(&driver_acl7225b);
-}
-
-module_init(driver_acl7225b_init_module);
-module_exit(driver_acl7225b_cleanup_module);
-
static int acl7225b_do_insn(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
- if (insn->n != 2)
- return -EINVAL;
-
if (data[0]) {
s->state &= ~data[0];
s->state |= (data[0] & data[1]);
@@ -81,43 +43,43 @@ static int acl7225b_do_insn(struct comedi_device *dev,
data[1] = s->state;
- return 2;
+ return insn->n;
}
static int acl7225b_di_insn(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
- if (insn->n != 2)
- return -EINVAL;
-
data[1] = inb(dev->iobase + (unsigned long)s->private) |
(inb(dev->iobase + (unsigned long)s->private + 1) << 8);
- return 2;
+ return insn->n;
}
static int acl7225b_attach(struct comedi_device *dev,
struct comedi_devconfig *it)
{
+ const struct boardtype *board = comedi_board(dev);
struct comedi_subdevice *s;
int iobase, iorange;
+ int ret;
iobase = it->options[0];
- iorange = this_board->io_range;
+ iorange = board->io_range;
printk(KERN_INFO "comedi%d: acl7225b: board=%s 0x%04x\n", dev->minor,
- this_board->name, iobase);
+ board->name, iobase);
if (!request_region(iobase, iorange, "acl7225b")) {
printk(KERN_ERR "comedi%d: request_region failed - I/O port conflict\n",
dev->minor);
return -EIO;
}
- dev->board_name = this_board->name;
+ dev->board_name = board->name;
dev->iobase = iobase;
dev->irq = 0;
- if (alloc_subdevices(dev, 3) < 0)
- return -ENOMEM;
+ ret = comedi_alloc_subdevices(dev, 3);
+ if (ret)
+ return ret;
s = dev->subdevices + 0;
/* Relays outputs */
@@ -152,16 +114,30 @@ static int acl7225b_attach(struct comedi_device *dev,
return 0;
}
-static int acl7225b_detach(struct comedi_device *dev)
+static void acl7225b_detach(struct comedi_device *dev)
{
- printk(KERN_INFO "comedi%d: acl7225b: remove\n", dev->minor);
+ const struct boardtype *board = comedi_board(dev);
if (dev->iobase)
- release_region(dev->iobase, this_board->io_range);
-
- return 0;
+ release_region(dev->iobase, board->io_range);
}
+static const struct boardtype boardtypes[] = {
+ { "acl7225b", ACL7225_SIZE, },
+ { "p16r16dio", P16R16DIO_SIZE, },
+};
+
+static struct comedi_driver acl7225b_driver = {
+ .driver_name = "acl7225b",
+ .module = THIS_MODULE,
+ .attach = acl7225b_attach,
+ .detach = acl7225b_detach,
+ .board_name = &boardtypes[0].name,
+ .num_names = ARRAY_SIZE(boardtypes),
+ .offset = sizeof(struct boardtype),
+};
+module_comedi_driver(acl7225b_driver);
+
MODULE_AUTHOR("Comedi http://www.comedi.org");
MODULE_DESCRIPTION("Comedi low-level driver");
MODULE_LICENSE("GPL");
diff --git a/drivers/staging/comedi/drivers/addi-data/addi_amcc_s5933.h b/drivers/staging/comedi/drivers/addi-data/addi_amcc_s5933.h
index 35a3ea19359f..95f7dc61cd00 100644
--- a/drivers/staging/comedi/drivers/addi-data/addi_amcc_s5933.h
+++ b/drivers/staging/comedi/drivers/addi-data/addi_amcc_s5933.h
@@ -22,12 +22,6 @@
#include "../../comedidev.h"
-#include "../comedi_pci.h"
-
-#ifdef PCI_SUPPORT_VER1
-#error No support for 2.1.55 and older
-#endif
-
/* written on base0 */
#define FIFO_ADVANCE_ON_BYTE_2 0x20000000
diff --git a/drivers/staging/comedi/drivers/addi-data/addi_common.c b/drivers/staging/comedi/drivers/addi-data/addi_common.c
index ca5bd9b8704a..a3d4ed25fb0d 100644
--- a/drivers/staging/comedi/drivers/addi-data/addi_common.c
+++ b/drivers/staging/comedi/drivers/addi-data/addi_common.c
@@ -224,2318 +224,1190 @@ MODULE_DEVICE_TABLE(pci, addi_apci_tbl);
static const struct addi_board boardtypes[] = {
#ifdef CONFIG_APCI_3120
- {"apci3120",
- APCI3120_BOARD_VENDOR_ID,
- 0x818D,
- AMCC_OP_REG_SIZE,
- APCI3120_ADDRESS_RANGE,
- 8,
- 0,
- ADDIDATA_NO_EEPROM,
- NULL,
- 16,
- 8,
- 16,
- 8,
- 0xffff,
- 0x3fff,
- &range_apci3120_ai,
- &range_apci3120_ao,
- 4,
- 4,
- 0x0f,
- 0,
- NULL,
- 1,
- 1,
- 1,
- 10000,
- 100000,
- v_APCI3120_Interrupt,
- i_APCI3120_Reset,
- i_APCI3120_InsnConfigAnalogInput,
- i_APCI3120_InsnReadAnalogInput,
- NULL,
- NULL,
- i_APCI3120_CommandTestAnalogInput,
- i_APCI3120_CommandAnalogInput,
- i_APCI3120_StopCyclicAcquisition,
- NULL,
- i_APCI3120_InsnWriteAnalogOutput,
- NULL,
- NULL,
- i_APCI3120_InsnReadDigitalInput,
- NULL,
- i_APCI3120_InsnBitsDigitalInput,
- i_APCI3120_InsnConfigDigitalOutput,
- i_APCI3120_InsnWriteDigitalOutput,
- i_APCI3120_InsnBitsDigitalOutput,
- NULL,
- i_APCI3120_InsnConfigTimer,
- i_APCI3120_InsnWriteTimer,
- i_APCI3120_InsnReadTimer,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL},
+ {
+ .pc_DriverName = "apci3120",
+ .i_VendorId = APCI3120_BOARD_VENDOR_ID,
+ .i_DeviceId = 0x818D,
+ .i_IorangeBase0 = AMCC_OP_REG_SIZE,
+ .i_IorangeBase1 = APCI3120_ADDRESS_RANGE,
+ .i_IorangeBase2 = 8,
+ .i_PCIEeprom = ADDIDATA_NO_EEPROM,
+ .i_NbrAiChannel = 16,
+ .i_NbrAiChannelDiff = 8,
+ .i_AiChannelList = 16,
+ .i_NbrAoChannel = 8,
+ .i_AiMaxdata = 0xffff,
+ .i_AoMaxdata = 0x3fff,
+ .pr_AiRangelist = &range_apci3120_ai,
+ .pr_AoRangelist = &range_apci3120_ao,
+ .i_NbrDiChannel = 4,
+ .i_NbrDoChannel = 4,
+ .i_DoMaxdata = 0x0f,
+ .i_Dma = 1,
+ .i_Timer = 1,
+ .b_AvailableConvertUnit = 1,
+ .ui_MinAcquisitiontimeNs = 10000,
+ .ui_MinDelaytimeNs = 100000,
+ .interrupt = v_APCI3120_Interrupt,
+ .reset = i_APCI3120_Reset,
+ .ai_config = i_APCI3120_InsnConfigAnalogInput,
+ .ai_read = i_APCI3120_InsnReadAnalogInput,
+ .ai_cmdtest = i_APCI3120_CommandTestAnalogInput,
+ .ai_cmd = i_APCI3120_CommandAnalogInput,
+ .ai_cancel = i_APCI3120_StopCyclicAcquisition,
+ .ao_write = i_APCI3120_InsnWriteAnalogOutput,
+ .di_read = i_APCI3120_InsnReadDigitalInput,
+ .di_bits = i_APCI3120_InsnBitsDigitalInput,
+ .do_config = i_APCI3120_InsnConfigDigitalOutput,
+ .do_write = i_APCI3120_InsnWriteDigitalOutput,
+ .do_bits = i_APCI3120_InsnBitsDigitalOutput,
+ .timer_config = i_APCI3120_InsnConfigTimer,
+ .timer_write = i_APCI3120_InsnWriteTimer,
+ .timer_read = i_APCI3120_InsnReadTimer,
+ },
#endif
#ifdef CONFIG_APCI_1032
- {"apci1032",
- APCI1032_BOARD_VENDOR_ID,
- 0x1003,
- 4,
- APCI1032_ADDRESS_RANGE,
- 0,
- 0,
- ADDIDATA_EEPROM,
- ADDIDATA_93C76,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- NULL,
- NULL,
- 32,
- 0,
- 0,
- 0,
- NULL,
- 0,
- 0,
- 0,
- 0,
- 0,
- v_APCI1032_Interrupt,
- i_APCI1032_Reset,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- i_APCI1032_ConfigDigitalInput,
- i_APCI1032_Read1DigitalInput,
- NULL,
- i_APCI1032_ReadMoreDigitalInput,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL},
+ {
+ .pc_DriverName = "apci1032",
+ .i_VendorId = APCI1032_BOARD_VENDOR_ID,
+ .i_DeviceId = 0x1003,
+ .i_IorangeBase0 = 4,
+ .i_IorangeBase1 = APCI1032_ADDRESS_RANGE,
+ .i_PCIEeprom = ADDIDATA_EEPROM,
+ .pc_EepromChip = ADDIDATA_93C76,
+ .i_NbrDiChannel = 32,
+ .interrupt = v_APCI1032_Interrupt,
+ .reset = i_APCI1032_Reset,
+ .di_config = i_APCI1032_ConfigDigitalInput,
+ .di_read = i_APCI1032_Read1DigitalInput,
+ .di_bits = i_APCI1032_ReadMoreDigitalInput,
+ },
#endif
#ifdef CONFIG_APCI_1516
- {"apci1516",
- APCI1516_BOARD_VENDOR_ID,
- 0x1001,
- 128,
- APCI1516_ADDRESS_RANGE,
- 32,
- 0,
- ADDIDATA_EEPROM,
- ADDIDATA_S5920,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- NULL,
- NULL,
- 8,
- 8,
- 0,
- 0,
- NULL,
- 0,
- 1,
- 0,
- 0,
- 0,
- NULL,
- i_APCI1516_Reset,
- NULL, NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- i_APCI1516_Read1DigitalInput,
- NULL,
- i_APCI1516_ReadMoreDigitalInput,
- i_APCI1516_ConfigDigitalOutput,
- i_APCI1516_WriteDigitalOutput,
- i_APCI1516_ReadDigitalOutput,
- NULL,
- i_APCI1516_ConfigWatchdog,
- i_APCI1516_StartStopWriteWatchdog,
- i_APCI1516_ReadWatchdog,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL},
+ {
+ .pc_DriverName = "apci1516",
+ .i_VendorId = APCI1516_BOARD_VENDOR_ID,
+ .i_DeviceId = 0x1001,
+ .i_IorangeBase0 = 128,
+ .i_IorangeBase1 = APCI1516_ADDRESS_RANGE,
+ .i_IorangeBase2 = 32,
+ .i_PCIEeprom = ADDIDATA_EEPROM,
+ .pc_EepromChip = ADDIDATA_S5920,
+ .i_NbrDiChannel = 8,
+ .i_NbrDoChannel = 8,
+ .i_Timer = 1,
+ .reset = i_APCI1516_Reset,
+ .di_read = i_APCI1516_Read1DigitalInput,
+ .di_bits = i_APCI1516_ReadMoreDigitalInput,
+ .do_config = i_APCI1516_ConfigDigitalOutput,
+ .do_write = i_APCI1516_WriteDigitalOutput,
+ .do_bits = i_APCI1516_ReadDigitalOutput,
+ .timer_config = i_APCI1516_ConfigWatchdog,
+ .timer_write = i_APCI1516_StartStopWriteWatchdog,
+ .timer_read = i_APCI1516_ReadWatchdog,
+ },
#endif
#ifdef CONFIG_APCI_2016
- {"apci2016",
- APCI2016_BOARD_VENDOR_ID,
- 0x1002,
- 128,
- APCI2016_ADDRESS_RANGE,
- 32,
- 0,
- ADDIDATA_EEPROM,
- ADDIDATA_S5920,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- NULL,
- NULL,
- 0,
- 16,
- 0,
- 0,
- NULL,
- 0,
- 1,
- 0,
- 0,
- 0,
- NULL,
- i_APCI2016_Reset,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- i_APCI2016_ConfigDigitalOutput,
- i_APCI2016_WriteDigitalOutput,
- i_APCI2016_BitsDigitalOutput,
- NULL,
- i_APCI2016_ConfigWatchdog,
- i_APCI2016_StartStopWriteWatchdog,
- i_APCI2016_ReadWatchdog,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL},
+ {
+ .pc_DriverName = "apci2016",
+ .i_VendorId = APCI2016_BOARD_VENDOR_ID,
+ .i_DeviceId = 0x1002,
+ .i_IorangeBase0 = 128,
+ .i_IorangeBase1 = APCI2016_ADDRESS_RANGE,
+ .i_IorangeBase2 = 32,
+ .i_PCIEeprom = ADDIDATA_EEPROM,
+ .pc_EepromChip = ADDIDATA_S5920,
+ .i_NbrDoChannel = 16,
+ .i_Timer = 1,
+ .reset = i_APCI2016_Reset,
+ .do_config = i_APCI2016_ConfigDigitalOutput,
+ .do_write = i_APCI2016_WriteDigitalOutput,
+ .do_bits = i_APCI2016_BitsDigitalOutput,
+ .timer_config = i_APCI2016_ConfigWatchdog,
+ .timer_write = i_APCI2016_StartStopWriteWatchdog,
+ .timer_read = i_APCI2016_ReadWatchdog,
+ },
#endif
#ifdef CONFIG_APCI_2032
- {"apci2032",
- APCI2032_BOARD_VENDOR_ID,
- 0x1004,
- 4,
- APCI2032_ADDRESS_RANGE,
- 0,
- 0,
- ADDIDATA_EEPROM,
- ADDIDATA_93C76,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- NULL,
- NULL,
- 0,
- 32,
- 0xffffffff,
- 0,
- NULL,
- 0,
- 1,
- 0,
- 0,
- 0,
- v_APCI2032_Interrupt,
- i_APCI2032_Reset,
- NULL, NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- i_APCI2032_ConfigDigitalOutput,
- i_APCI2032_WriteDigitalOutput,
- i_APCI2032_ReadDigitalOutput,
- i_APCI2032_ReadInterruptStatus,
- i_APCI2032_ConfigWatchdog,
- i_APCI2032_StartStopWriteWatchdog,
- i_APCI2032_ReadWatchdog,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL},
+ {
+ .pc_DriverName = "apci2032",
+ .i_VendorId = APCI2032_BOARD_VENDOR_ID,
+ .i_DeviceId = 0x1004,
+ .i_IorangeBase0 = 4,
+ .i_IorangeBase1 = APCI2032_ADDRESS_RANGE,
+ .i_PCIEeprom = ADDIDATA_EEPROM,
+ .pc_EepromChip = ADDIDATA_93C76,
+ .i_NbrDoChannel = 32,
+ .i_DoMaxdata = 0xffffffff,
+ .i_Timer = 1,
+ .interrupt = v_APCI2032_Interrupt,
+ .reset = i_APCI2032_Reset,
+ .do_config = i_APCI2032_ConfigDigitalOutput,
+ .do_write = i_APCI2032_WriteDigitalOutput,
+ .do_bits = i_APCI2032_ReadDigitalOutput,
+ .do_read = i_APCI2032_ReadInterruptStatus,
+ .timer_config = i_APCI2032_ConfigWatchdog,
+ .timer_write = i_APCI2032_StartStopWriteWatchdog,
+ .timer_read = i_APCI2032_ReadWatchdog,
+ },
#endif
#ifdef CONFIG_APCI_2200
- {"apci2200",
- APCI2200_BOARD_VENDOR_ID,
- 0x1005,
- 4,
- APCI2200_ADDRESS_RANGE,
- 0,
- 0,
- ADDIDATA_EEPROM,
- ADDIDATA_93C76,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- NULL,
- NULL,
- 8,
- 16,
- 0,
- 0,
- NULL,
- 0,
- 1,
- 0,
- 0,
- 0,
- NULL,
- i_APCI2200_Reset,
- NULL, NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- i_APCI2200_Read1DigitalInput,
- NULL,
- i_APCI2200_ReadMoreDigitalInput,
- i_APCI2200_ConfigDigitalOutput,
- i_APCI2200_WriteDigitalOutput,
- i_APCI2200_ReadDigitalOutput,
- NULL,
- i_APCI2200_ConfigWatchdog,
- i_APCI2200_StartStopWriteWatchdog,
- i_APCI2200_ReadWatchdog,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL},
+ {
+ .pc_DriverName = "apci2200",
+ .i_VendorId = APCI2200_BOARD_VENDOR_ID,
+ .i_DeviceId = 0x1005,
+ .i_IorangeBase0 = 4,
+ .i_IorangeBase1 = APCI2200_ADDRESS_RANGE,
+ .i_PCIEeprom = ADDIDATA_EEPROM,
+ .pc_EepromChip = ADDIDATA_93C76,
+ .i_NbrDiChannel = 8,
+ .i_NbrDoChannel = 16,
+ .i_Timer = 1,
+ .reset = i_APCI2200_Reset,
+ .di_read = i_APCI2200_Read1DigitalInput,
+ .di_bits = i_APCI2200_ReadMoreDigitalInput,
+ .do_config = i_APCI2200_ConfigDigitalOutput,
+ .do_write = i_APCI2200_WriteDigitalOutput,
+ .do_bits = i_APCI2200_ReadDigitalOutput,
+ .timer_config = i_APCI2200_ConfigWatchdog,
+ .timer_write = i_APCI2200_StartStopWriteWatchdog,
+ .timer_read = i_APCI2200_ReadWatchdog,
+ },
#endif
#ifdef CONFIG_APCI_1564
- {"apci1564",
- APCI1564_BOARD_VENDOR_ID,
- 0x1006,
- 128,
- APCI1564_ADDRESS_RANGE,
- 0,
- 0,
- ADDIDATA_EEPROM,
- ADDIDATA_93C76,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- NULL,
- NULL,
- 32,
- 32,
- 0xffffffff,
- 0,
- NULL,
- 0,
- 1,
- 0,
- 0,
- 0,
- v_APCI1564_Interrupt,
- i_APCI1564_Reset,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- i_APCI1564_ConfigDigitalInput,
- i_APCI1564_Read1DigitalInput,
- NULL,
- i_APCI1564_ReadMoreDigitalInput,
- i_APCI1564_ConfigDigitalOutput,
- i_APCI1564_WriteDigitalOutput,
- i_APCI1564_ReadDigitalOutput,
- i_APCI1564_ReadInterruptStatus,
- i_APCI1564_ConfigTimerCounterWatchdog,
- i_APCI1564_StartStopWriteTimerCounterWatchdog,
- i_APCI1564_ReadTimerCounterWatchdog,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL},
+ {
+ .pc_DriverName = "apci1564",
+ .i_VendorId = APCI1564_BOARD_VENDOR_ID,
+ .i_DeviceId = 0x1006,
+ .i_IorangeBase0 = 128,
+ .i_IorangeBase1 = APCI1564_ADDRESS_RANGE,
+ .i_PCIEeprom = ADDIDATA_EEPROM,
+ .pc_EepromChip = ADDIDATA_93C76,
+ .i_NbrDiChannel = 32,
+ .i_NbrDoChannel = 32,
+ .i_DoMaxdata = 0xffffffff,
+ .i_Timer = 1,
+ .interrupt = v_APCI1564_Interrupt,
+ .reset = i_APCI1564_Reset,
+ .di_config = i_APCI1564_ConfigDigitalInput,
+ .di_read = i_APCI1564_Read1DigitalInput,
+ .di_bits = i_APCI1564_ReadMoreDigitalInput,
+ .do_config = i_APCI1564_ConfigDigitalOutput,
+ .do_write = i_APCI1564_WriteDigitalOutput,
+ .do_bits = i_APCI1564_ReadDigitalOutput,
+ .do_read = i_APCI1564_ReadInterruptStatus,
+ .timer_config = i_APCI1564_ConfigTimerCounterWatchdog,
+ .timer_write = i_APCI1564_StartStopWriteTimerCounterWatchdog,
+ .timer_read = i_APCI1564_ReadTimerCounterWatchdog,
+ },
#endif
#ifdef CONFIG_APCI_1500
- {"apci1500",
- APCI1500_BOARD_VENDOR_ID,
- 0x80fc,
- 128,
- APCI1500_ADDRESS_RANGE,
- 4,
- 0,
- ADDIDATA_NO_EEPROM,
- NULL,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- NULL,
- NULL,
- 16,
- 16,
- 0xffff,
- 0,
- NULL,
- 0,
- 1,
- 0,
- 0,
- 0,
- v_APCI1500_Interrupt,
- i_APCI1500_Reset,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- i_APCI1500_ConfigDigitalInputEvent,
- i_APCI1500_Initialisation,
- i_APCI1500_StartStopInputEvent,
- i_APCI1500_ReadMoreDigitalInput,
- i_APCI1500_ConfigDigitalOutputErrorInterrupt,
- i_APCI1500_WriteDigitalOutput,
- i_APCI1500_ConfigureInterrupt,
- NULL,
- i_APCI1500_ConfigCounterTimerWatchdog,
- i_APCI1500_StartStopTriggerTimerCounterWatchdog,
- i_APCI1500_ReadInterruptMask,
- i_APCI1500_ReadCounterTimerWatchdog,
- NULL,
- NULL,
- NULL,
- NULL},
+ {
+ .pc_DriverName = "apci1500",
+ .i_VendorId = APCI1500_BOARD_VENDOR_ID,
+ .i_DeviceId = 0x80fc,
+ .i_IorangeBase0 = 128,
+ .i_IorangeBase1 = APCI1500_ADDRESS_RANGE,
+ .i_IorangeBase2 = 4,
+ .i_PCIEeprom = ADDIDATA_NO_EEPROM,
+ .i_NbrDiChannel = 16,
+ .i_NbrDoChannel = 16,
+ .i_DoMaxdata = 0xffff,
+ .i_Timer = 1,
+ .interrupt = v_APCI1500_Interrupt,
+ .reset = i_APCI1500_Reset,
+ .di_config = i_APCI1500_ConfigDigitalInputEvent,
+ .di_read = i_APCI1500_Initialisation,
+ .di_write = i_APCI1500_StartStopInputEvent,
+ .di_bits = i_APCI1500_ReadMoreDigitalInput,
+ .do_config = i_APCI1500_ConfigDigitalOutputErrorInterrupt,
+ .do_write = i_APCI1500_WriteDigitalOutput,
+ .do_bits = i_APCI1500_ConfigureInterrupt,
+ .timer_config = i_APCI1500_ConfigCounterTimerWatchdog,
+ .timer_write = i_APCI1500_StartStopTriggerTimerCounterWatchdog,
+ .timer_read = i_APCI1500_ReadInterruptMask,
+ .timer_bits = i_APCI1500_ReadCounterTimerWatchdog,
+ },
#endif
#ifdef CONFIG_APCI_3001
- {"apci3001",
- APCI3120_BOARD_VENDOR_ID,
- 0x828D,
- AMCC_OP_REG_SIZE,
- APCI3120_ADDRESS_RANGE,
- 8,
- 0,
- ADDIDATA_NO_EEPROM,
- NULL,
- 16,
- 8,
- 16,
- 0,
- 0xfff,
- 0,
- &range_apci3120_ai,
- NULL,
- 4,
- 4,
- 0x0f,
- 0,
- NULL,
- 1,
- 1,
- 1,
- 10000,
- 100000,
- v_APCI3120_Interrupt,
- i_APCI3120_Reset,
- i_APCI3120_InsnConfigAnalogInput,
- i_APCI3120_InsnReadAnalogInput,
- NULL,
- NULL,
- i_APCI3120_CommandTestAnalogInput,
- i_APCI3120_CommandAnalogInput,
- i_APCI3120_StopCyclicAcquisition,
- NULL,
- NULL,
- NULL,
- NULL,
- i_APCI3120_InsnReadDigitalInput,
- NULL,
- i_APCI3120_InsnBitsDigitalInput,
- i_APCI3120_InsnConfigDigitalOutput,
- i_APCI3120_InsnWriteDigitalOutput,
- i_APCI3120_InsnBitsDigitalOutput,
- NULL,
- i_APCI3120_InsnConfigTimer,
- i_APCI3120_InsnWriteTimer,
- i_APCI3120_InsnReadTimer,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL},
+ {
+ .pc_DriverName = "apci3001",
+ .i_VendorId = APCI3120_BOARD_VENDOR_ID,
+ .i_DeviceId = 0x828D,
+ .i_IorangeBase0 = AMCC_OP_REG_SIZE,
+ .i_IorangeBase1 = APCI3120_ADDRESS_RANGE,
+ .i_IorangeBase2 = 8,
+ .i_PCIEeprom = ADDIDATA_NO_EEPROM,
+ .i_NbrAiChannel = 16,
+ .i_NbrAiChannelDiff = 8,
+ .i_AiChannelList = 16,
+ .i_AiMaxdata = 0xfff,
+ .pr_AiRangelist = &range_apci3120_ai,
+ .i_NbrDiChannel = 4,
+ .i_NbrDoChannel = 4,
+ .i_DoMaxdata = 0x0f,
+ .i_Dma = 1,
+ .i_Timer = 1,
+ .b_AvailableConvertUnit = 1,
+ .ui_MinAcquisitiontimeNs = 10000,
+ .ui_MinDelaytimeNs = 100000,
+ .interrupt = v_APCI3120_Interrupt,
+ .reset = i_APCI3120_Reset,
+ .ai_config = i_APCI3120_InsnConfigAnalogInput,
+ .ai_read = i_APCI3120_InsnReadAnalogInput,
+ .ai_cmdtest = i_APCI3120_CommandTestAnalogInput,
+ .ai_cmd = i_APCI3120_CommandAnalogInput,
+ .ai_cancel = i_APCI3120_StopCyclicAcquisition,
+ .di_read = i_APCI3120_InsnReadDigitalInput,
+ .di_bits = i_APCI3120_InsnBitsDigitalInput,
+ .do_config = i_APCI3120_InsnConfigDigitalOutput,
+ .do_write = i_APCI3120_InsnWriteDigitalOutput,
+ .do_bits = i_APCI3120_InsnBitsDigitalOutput,
+ .timer_config = i_APCI3120_InsnConfigTimer,
+ .timer_write = i_APCI3120_InsnWriteTimer,
+ .timer_read = i_APCI3120_InsnReadTimer,
+ },
#endif
#ifdef CONFIG_APCI_3501
- {"apci3501",
- APCI3501_BOARD_VENDOR_ID,
- 0x3001,
- 64,
- APCI3501_ADDRESS_RANGE,
- 0,
- 0,
- ADDIDATA_EEPROM,
- ADDIDATA_S5933,
- 0,
- 0,
- 0,
- 8,
- 0,
- 16383,
- NULL,
- &range_apci3501_ao,
- 2,
- 2,
- 0x3,
- 0,
- NULL,
- 0,
- 1,
- 0,
- 0,
- 0,
- v_APCI3501_Interrupt,
- i_APCI3501_Reset,
- NULL, NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- i_APCI3501_ConfigAnalogOutput,
- i_APCI3501_WriteAnalogOutput,
- NULL,
- NULL,
- NULL,
- NULL,
- i_APCI3501_ReadDigitalInput,
- i_APCI3501_ConfigDigitalOutput,
- i_APCI3501_WriteDigitalOutput,
- i_APCI3501_ReadDigitalOutput,
- NULL,
- i_APCI3501_ConfigTimerCounterWatchdog,
- i_APCI3501_StartStopWriteTimerCounterWatchdog,
- i_APCI3501_ReadTimerCounterWatchdog,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL},
+ {
+ .pc_DriverName = "apci3501",
+ .i_VendorId = APCI3501_BOARD_VENDOR_ID,
+ .i_DeviceId = 0x3001,
+ .i_IorangeBase0 = 64,
+ .i_IorangeBase1 = APCI3501_ADDRESS_RANGE,
+ .i_PCIEeprom = ADDIDATA_EEPROM,
+ .pc_EepromChip = ADDIDATA_S5933,
+ .i_AoMaxdata = 16383,
+ .pr_AoRangelist = &range_apci3501_ao,
+ .i_NbrDiChannel = 2,
+ .i_NbrDoChannel = 2,
+ .i_DoMaxdata = 0x3,
+ .i_Timer = 1,
+ .interrupt = v_APCI3501_Interrupt,
+ .reset = i_APCI3501_Reset,
+ .ao_config = i_APCI3501_ConfigAnalogOutput,
+ .ao_write = i_APCI3501_WriteAnalogOutput,
+ .di_bits = i_APCI3501_ReadDigitalInput,
+ .do_config = i_APCI3501_ConfigDigitalOutput,
+ .do_write = i_APCI3501_WriteDigitalOutput,
+ .do_bits = i_APCI3501_ReadDigitalOutput,
+ .timer_config = i_APCI3501_ConfigTimerCounterWatchdog,
+ .timer_write = i_APCI3501_StartStopWriteTimerCounterWatchdog,
+ .timer_read = i_APCI3501_ReadTimerCounterWatchdog,
+ },
#endif
#ifdef CONFIG_APCI_035
- {"apci035",
- APCI035_BOARD_VENDOR_ID,
- 0x0300,
- 127,
- APCI035_ADDRESS_RANGE,
- 0,
- 0,
- 1,
- ADDIDATA_S5920,
- 16,
- 8,
- 16,
- 0,
- 0xff,
- 0,
- &range_apci035_ai,
- NULL,
- 0,
- 0,
- 0,
- 0,
- NULL,
- 0,
- 1,
- 0,
- 10000,
- 100000,
- v_APCI035_Interrupt,
- i_APCI035_Reset,
- i_APCI035_ConfigAnalogInput,
- i_APCI035_ReadAnalogInput,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- i_APCI035_ConfigTimerWatchdog,
- i_APCI035_StartStopWriteTimerWatchdog,
- i_APCI035_ReadTimerWatchdog,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL},
+ {
+ .pc_DriverName = "apci035",
+ .i_VendorId = APCI035_BOARD_VENDOR_ID,
+ .i_DeviceId = 0x0300,
+ .i_IorangeBase0 = 127,
+ .i_IorangeBase1 = APCI035_ADDRESS_RANGE,
+ .i_PCIEeprom = 1,
+ .pc_EepromChip = ADDIDATA_S5920,
+ .i_NbrAiChannel = 16,
+ .i_NbrAiChannelDiff = 8,
+ .i_AiChannelList = 16,
+ .i_AiMaxdata = 0xff,
+ .pr_AiRangelist = &range_apci035_ai,
+ .i_Timer = 1,
+ .ui_MinAcquisitiontimeNs = 10000,
+ .ui_MinDelaytimeNs = 100000,
+ .interrupt = v_APCI035_Interrupt,
+ .reset = i_APCI035_Reset,
+ .ai_config = i_APCI035_ConfigAnalogInput,
+ .ai_read = i_APCI035_ReadAnalogInput,
+ .timer_config = i_APCI035_ConfigTimerWatchdog,
+ .timer_write = i_APCI035_StartStopWriteTimerWatchdog,
+ .timer_read = i_APCI035_ReadTimerWatchdog,
+ },
#endif
#ifdef CONFIG_APCI_3200
- {"apci3200",
- APCI3200_BOARD_VENDOR_ID,
- 0x3000,
- 128,
- 256,
- 4,
- 4,
- ADDIDATA_EEPROM,
- ADDIDATA_S5920,
- 16,
- 8,
- 16,
- 0,
- 0x3ffff,
- 0,
- &range_apci3200_ai,
- NULL,
- 4,
- 4,
- 0,
- 0,
- NULL,
- 0,
- 0,
- 0,
- 10000,
- 100000,
- v_APCI3200_Interrupt,
- i_APCI3200_Reset,
- i_APCI3200_ConfigAnalogInput,
- i_APCI3200_ReadAnalogInput,
- i_APCI3200_InsnWriteReleaseAnalogInput,
- i_APCI3200_InsnBits_AnalogInput_Test,
- i_APCI3200_CommandTestAnalogInput,
- i_APCI3200_CommandAnalogInput,
- i_APCI3200_StopCyclicAcquisition,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- i_APCI3200_ReadDigitalInput,
- i_APCI3200_ConfigDigitalOutput,
- i_APCI3200_WriteDigitalOutput,
- i_APCI3200_ReadDigitalOutput,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL},
+ {
+ .pc_DriverName = "apci3200",
+ .i_VendorId = APCI3200_BOARD_VENDOR_ID,
+ .i_DeviceId = 0x3000,
+ .i_IorangeBase0 = 128,
+ .i_IorangeBase1 = 256,
+ .i_IorangeBase2 = 4,
+ .i_IorangeBase3 = 4,
+ .i_PCIEeprom = ADDIDATA_EEPROM,
+ .pc_EepromChip = ADDIDATA_S5920,
+ .i_NbrAiChannel = 16,
+ .i_NbrAiChannelDiff = 8,
+ .i_AiChannelList = 16,
+ .i_AiMaxdata = 0x3ffff,
+ .pr_AiRangelist = &range_apci3200_ai,
+ .i_NbrDiChannel = 4,
+ .i_NbrDoChannel = 4,
+ .ui_MinAcquisitiontimeNs = 10000,
+ .ui_MinDelaytimeNs = 100000,
+ .interrupt = v_APCI3200_Interrupt,
+ .reset = i_APCI3200_Reset,
+ .ai_config = i_APCI3200_ConfigAnalogInput,
+ .ai_read = i_APCI3200_ReadAnalogInput,
+ .ai_write = i_APCI3200_InsnWriteReleaseAnalogInput,
+ .ai_bits = i_APCI3200_InsnBits_AnalogInput_Test,
+ .ai_cmdtest = i_APCI3200_CommandTestAnalogInput,
+ .ai_cmd = i_APCI3200_CommandAnalogInput,
+ .ai_cancel = i_APCI3200_StopCyclicAcquisition,
+ .di_bits = i_APCI3200_ReadDigitalInput,
+ .do_config = i_APCI3200_ConfigDigitalOutput,
+ .do_write = i_APCI3200_WriteDigitalOutput,
+ .do_bits = i_APCI3200_ReadDigitalOutput,
+ },
#endif
#ifdef CONFIG_APCI_3300
/* Begin JK .20.10.2004 = APCI-3300 integration */
- {"apci3300",
- APCI3200_BOARD_VENDOR_ID,
- 0x3007,
- 128,
- 256,
- 4,
- 4,
- ADDIDATA_EEPROM,
- ADDIDATA_S5920,
- 0,
- 8,
- 8,
- 0,
- 0x3ffff,
- 0,
- &range_apci3300_ai,
- NULL,
- 4,
- 4,
- 0,
- 0,
- NULL,
- 0,
- 0,
- 0,
- 10000,
- 100000,
- v_APCI3200_Interrupt,
- i_APCI3200_Reset,
- i_APCI3200_ConfigAnalogInput,
- i_APCI3200_ReadAnalogInput,
- i_APCI3200_InsnWriteReleaseAnalogInput,
- i_APCI3200_InsnBits_AnalogInput_Test,
- i_APCI3200_CommandTestAnalogInput,
- i_APCI3200_CommandAnalogInput,
- i_APCI3200_StopCyclicAcquisition,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- i_APCI3200_ReadDigitalInput,
- i_APCI3200_ConfigDigitalOutput,
- i_APCI3200_WriteDigitalOutput,
- i_APCI3200_ReadDigitalOutput,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL},
+ {
+ .pc_DriverName = "apci3300",
+ .i_VendorId = APCI3200_BOARD_VENDOR_ID,
+ .i_DeviceId = 0x3007,
+ .i_IorangeBase0 = 128,
+ .i_IorangeBase1 = 256,
+ .i_IorangeBase2 = 4,
+ .i_IorangeBase3 = 4,
+ .i_PCIEeprom = ADDIDATA_EEPROM,
+ .pc_EepromChip = ADDIDATA_S5920,
+ .i_NbrAiChannelDiff = 8,
+ .i_AiChannelList = 8,
+ .i_AiMaxdata = 0x3ffff,
+ .pr_AiRangelist = &range_apci3300_ai,
+ .i_NbrDiChannel = 4,
+ .i_NbrDoChannel = 4,
+ .ui_MinAcquisitiontimeNs = 10000,
+ .ui_MinDelaytimeNs = 100000,
+ .interrupt = v_APCI3200_Interrupt,
+ .reset = i_APCI3200_Reset,
+ .ai_config = i_APCI3200_ConfigAnalogInput,
+ .ai_read = i_APCI3200_ReadAnalogInput,
+ .ai_write = i_APCI3200_InsnWriteReleaseAnalogInput,
+ .ai_bits = i_APCI3200_InsnBits_AnalogInput_Test,
+ .ai_cmdtest = i_APCI3200_CommandTestAnalogInput,
+ .ai_cmd = i_APCI3200_CommandAnalogInput,
+ .ai_cancel = i_APCI3200_StopCyclicAcquisition,
+ .di_bits = i_APCI3200_ReadDigitalInput,
+ .do_config = i_APCI3200_ConfigDigitalOutput,
+ .do_write = i_APCI3200_WriteDigitalOutput,
+ .do_bits = i_APCI3200_ReadDigitalOutput,
+ },
#endif
#ifdef CONFIG_APCI_1710
- {"apci1710", APCI1710_BOARD_VENDOR_ID, APCI1710_BOARD_DEVICE_ID,
- 128,
- 8,
- 256,
- 0,
- ADDIDATA_NO_EEPROM,
- NULL,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- NULL,
- NULL,
- 0,
- 0,
- 0,
- 0,
- NULL,
- 0,
- 0,
- 0,
- 0,
- 0,
- v_APCI1710_Interrupt,
- i_APCI1710_Reset,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL},
+ {
+ .pc_DriverName = "apci1710",
+ .i_VendorId = APCI1710_BOARD_VENDOR_ID,
+ .i_DeviceId = APCI1710_BOARD_DEVICE_ID,
+ .i_IorangeBase0 = 128,
+ .i_IorangeBase1 = 8,
+ .i_IorangeBase2 = 256,
+ .i_PCIEeprom = ADDIDATA_NO_EEPROM,
+ .interrupt = v_APCI1710_Interrupt,
+ .reset = i_APCI1710_Reset,
+ },
#endif
#ifdef CONFIG_APCI_16XX
- {"apci1648",
- PCI_VENDOR_ID_ADDIDATA,
- 0x1009,
- 128,
- 0,
- 0,
- 0,
- ADDIDATA_NO_EEPROM,
- NULL,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- NULL,
- NULL,
- 0,
- 0,
- 0,
- 48,
- &range_apci16xx_ttl,
- 0,
- 0,
- 0,
- 0,
- 0,
- NULL,
- i_APCI16XX_Reset,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- i_APCI16XX_InsnConfigInitTTLIO,
- i_APCI16XX_InsnBitsReadTTLIO,
- i_APCI16XX_InsnReadTTLIOAllPortValue,
- i_APCI16XX_InsnBitsWriteTTLIO},
-
- {"apci1696",
- PCI_VENDOR_ID_ADDIDATA,
- 0x100A,
- 128,
- 0,
- 0,
- 0,
- ADDIDATA_NO_EEPROM,
- NULL,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- NULL,
- NULL,
- 0,
- 0,
- 0,
- 96,
- &range_apci16xx_ttl,
- 0,
- 0,
- 0,
- 0,
- 0,
- NULL,
- i_APCI16XX_Reset,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- i_APCI16XX_InsnConfigInitTTLIO,
- i_APCI16XX_InsnBitsReadTTLIO,
- i_APCI16XX_InsnReadTTLIOAllPortValue,
- i_APCI16XX_InsnBitsWriteTTLIO},
+ {
+ .pc_DriverName = "apci1648",
+ .i_VendorId = PCI_VENDOR_ID_ADDIDATA,
+ .i_DeviceId = 0x1009,
+ .i_IorangeBase0 = 128,
+ .i_PCIEeprom = ADDIDATA_NO_EEPROM,
+ .i_NbrTTLChannel = 48,
+ .reset = i_APCI16XX_Reset,
+ .ttl_config = i_APCI16XX_InsnConfigInitTTLIO,
+ .ttl_bits = i_APCI16XX_InsnBitsReadTTLIO,
+ .ttl_read = i_APCI16XX_InsnReadTTLIOAllPortValue,
+ .ttl_write = i_APCI16XX_InsnBitsWriteTTLIO,
+ }, {
+ .pc_DriverName = "apci1696",
+ .i_VendorId = PCI_VENDOR_ID_ADDIDATA,
+ .i_DeviceId = 0x100A,
+ .i_IorangeBase0 = 128,
+ .i_PCIEeprom = ADDIDATA_NO_EEPROM,
+ .i_NbrTTLChannel = 96,
+ .reset = i_APCI16XX_Reset,
+ .ttl_config = i_APCI16XX_InsnConfigInitTTLIO,
+ .ttl_bits = i_APCI16XX_InsnBitsReadTTLIO,
+ .ttl_read = i_APCI16XX_InsnReadTTLIOAllPortValue,
+ .ttl_write = i_APCI16XX_InsnBitsWriteTTLIO,
+ },
#endif
#ifdef CONFIG_APCI_3XXX
- {"apci3000-16",
- PCI_VENDOR_ID_ADDIDATA,
- 0x3010,
- 256,
- 256,
- 256,
- 256,
- ADDIDATA_NO_EEPROM,
- ADDIDATA_9054,
- 16,
- 8,
- 16,
- 0,
- 4095,
- 0,
- &range_apci3XXX_ai,
- NULL,
- 0,
- 0,
- 0,
- 24,
- &range_apci3XXX_ttl,
- 0,
- 0,
- 6,
- 10000,
- 0,
- v_APCI3XXX_Interrupt,
- i_APCI3XXX_Reset,
- i_APCI3XXX_InsnConfigAnalogInput,
- i_APCI3XXX_InsnReadAnalogInput,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- i_APCI3XXX_InsnConfigInitTTLIO,
- i_APCI3XXX_InsnBitsTTLIO,
- i_APCI3XXX_InsnReadTTLIO,
- i_APCI3XXX_InsnWriteTTLIO},
-
- {"apci3000-8",
- PCI_VENDOR_ID_ADDIDATA,
- 0x300F,
- 256,
- 256,
- 256,
- 256,
- ADDIDATA_NO_EEPROM,
- ADDIDATA_9054,
- 8,
- 4,
- 8,
- 0,
- 4095,
- 0,
- &range_apci3XXX_ai,
- NULL,
- 0,
- 0,
- 0,
- 24,
- &range_apci3XXX_ttl,
- 0,
- 0,
- 6,
- 10000,
- 0,
- v_APCI3XXX_Interrupt,
- i_APCI3XXX_Reset,
- i_APCI3XXX_InsnConfigAnalogInput,
- i_APCI3XXX_InsnReadAnalogInput,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- i_APCI3XXX_InsnConfigInitTTLIO,
- i_APCI3XXX_InsnBitsTTLIO,
- i_APCI3XXX_InsnReadTTLIO,
- i_APCI3XXX_InsnWriteTTLIO},
-
- {"apci3000-4",
- PCI_VENDOR_ID_ADDIDATA,
- 0x300E,
- 256,
- 256,
- 256,
- 256,
- ADDIDATA_NO_EEPROM,
- ADDIDATA_9054,
- 4,
- 2,
- 4,
- 0,
- 4095,
- 0,
- &range_apci3XXX_ai,
- NULL,
- 0,
- 0,
- 0,
- 24,
- &range_apci3XXX_ttl,
- 0,
- 0,
- 6,
- 10000,
- 0,
- v_APCI3XXX_Interrupt,
- i_APCI3XXX_Reset,
- i_APCI3XXX_InsnConfigAnalogInput,
- i_APCI3XXX_InsnReadAnalogInput,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- i_APCI3XXX_InsnConfigInitTTLIO,
- i_APCI3XXX_InsnBitsTTLIO,
- i_APCI3XXX_InsnReadTTLIO,
- i_APCI3XXX_InsnWriteTTLIO},
-
- {"apci3006-16",
- PCI_VENDOR_ID_ADDIDATA,
- 0x3013,
- 256,
- 256,
- 256,
- 256,
- ADDIDATA_NO_EEPROM,
- ADDIDATA_9054,
- 16,
- 8,
- 16,
- 0,
- 65535,
- 0,
- &range_apci3XXX_ai,
- NULL,
- 0,
- 0,
- 0,
- 24,
- &range_apci3XXX_ttl,
- 0,
- 0,
- 6,
- 10000,
- 0,
- v_APCI3XXX_Interrupt,
- i_APCI3XXX_Reset,
- i_APCI3XXX_InsnConfigAnalogInput,
- i_APCI3XXX_InsnReadAnalogInput,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- i_APCI3XXX_InsnConfigInitTTLIO,
- i_APCI3XXX_InsnBitsTTLIO,
- i_APCI3XXX_InsnReadTTLIO,
- i_APCI3XXX_InsnWriteTTLIO},
-
- {"apci3006-8",
- PCI_VENDOR_ID_ADDIDATA,
- 0x3014,
- 256,
- 256,
- 256,
- 256,
- ADDIDATA_NO_EEPROM,
- ADDIDATA_9054,
- 8,
- 4,
- 8,
- 0,
- 65535,
- 0,
- &range_apci3XXX_ai,
- NULL,
- 0,
- 0,
- 0,
- 24,
- &range_apci3XXX_ttl,
- 0,
- 0,
- 6,
- 10000,
- 0,
- v_APCI3XXX_Interrupt,
- i_APCI3XXX_Reset,
- i_APCI3XXX_InsnConfigAnalogInput,
- i_APCI3XXX_InsnReadAnalogInput,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- i_APCI3XXX_InsnConfigInitTTLIO,
- i_APCI3XXX_InsnBitsTTLIO,
- i_APCI3XXX_InsnReadTTLIO,
- i_APCI3XXX_InsnWriteTTLIO},
-
- {"apci3006-4",
- PCI_VENDOR_ID_ADDIDATA,
- 0x3015,
- 256,
- 256,
- 256,
- 256,
- ADDIDATA_NO_EEPROM,
- ADDIDATA_9054,
- 4,
- 2,
- 4,
- 0,
- 65535,
- 0,
- &range_apci3XXX_ai,
- NULL,
- 0,
- 0,
- 0,
- 24,
- &range_apci3XXX_ttl,
- 0,
- 0,
- 6,
- 10000,
- 0,
- v_APCI3XXX_Interrupt,
- i_APCI3XXX_Reset,
- i_APCI3XXX_InsnConfigAnalogInput,
- i_APCI3XXX_InsnReadAnalogInput,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- i_APCI3XXX_InsnConfigInitTTLIO,
- i_APCI3XXX_InsnBitsTTLIO,
- i_APCI3XXX_InsnReadTTLIO,
- i_APCI3XXX_InsnWriteTTLIO},
-
- {"apci3010-16",
- PCI_VENDOR_ID_ADDIDATA,
- 0x3016,
- 256,
- 256,
- 256,
- 256,
- ADDIDATA_NO_EEPROM,
- ADDIDATA_9054,
- 16,
- 8,
- 16,
- 0,
- 4095,
- 0,
- &range_apci3XXX_ai,
- NULL,
- 4,
- 4,
- 1,
- 24,
- &range_apci3XXX_ttl,
- 0,
- 0,
- 6,
- 5000,
- 0,
- v_APCI3XXX_Interrupt,
- i_APCI3XXX_Reset,
- i_APCI3XXX_InsnConfigAnalogInput,
- i_APCI3XXX_InsnReadAnalogInput,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- i_APCI3XXX_InsnReadDigitalInput,
- NULL,
- i_APCI3XXX_InsnBitsDigitalInput,
- NULL,
- i_APCI3XXX_InsnWriteDigitalOutput,
- i_APCI3XXX_InsnBitsDigitalOutput,
- i_APCI3XXX_InsnReadDigitalOutput,
- NULL,
- NULL,
- NULL,
- NULL,
- i_APCI3XXX_InsnConfigInitTTLIO,
- i_APCI3XXX_InsnBitsTTLIO,
- i_APCI3XXX_InsnReadTTLIO,
- i_APCI3XXX_InsnWriteTTLIO},
-
- {"apci3010-8",
- PCI_VENDOR_ID_ADDIDATA,
- 0x3017,
- 256,
- 256,
- 256,
- 256,
- ADDIDATA_NO_EEPROM,
- ADDIDATA_9054,
- 8,
- 4,
- 8,
- 0,
- 4095,
- 0,
- &range_apci3XXX_ai,
- NULL,
- 4,
- 4,
- 1,
- 24,
- &range_apci3XXX_ttl,
- 0,
- 0,
- 6,
- 5000,
- 0,
- v_APCI3XXX_Interrupt,
- i_APCI3XXX_Reset,
- i_APCI3XXX_InsnConfigAnalogInput,
- i_APCI3XXX_InsnReadAnalogInput,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- i_APCI3XXX_InsnReadDigitalInput,
- NULL,
- i_APCI3XXX_InsnBitsDigitalInput,
- NULL,
- i_APCI3XXX_InsnWriteDigitalOutput,
- i_APCI3XXX_InsnBitsDigitalOutput,
- i_APCI3XXX_InsnReadDigitalOutput,
- NULL,
- NULL,
- NULL,
- NULL,
- i_APCI3XXX_InsnConfigInitTTLIO,
- i_APCI3XXX_InsnBitsTTLIO,
- i_APCI3XXX_InsnReadTTLIO,
- i_APCI3XXX_InsnWriteTTLIO},
-
- {"apci3010-4",
- PCI_VENDOR_ID_ADDIDATA,
- 0x3018,
- 256,
- 256,
- 256,
- 256,
- ADDIDATA_NO_EEPROM,
- ADDIDATA_9054,
- 4,
- 2,
- 4,
- 0,
- 4095,
- 0,
- &range_apci3XXX_ai,
- NULL,
- 4,
- 4,
- 1,
- 24,
- &range_apci3XXX_ttl,
- 0,
- 0,
- 6,
- 5000,
- 0,
- v_APCI3XXX_Interrupt,
- i_APCI3XXX_Reset,
- i_APCI3XXX_InsnConfigAnalogInput,
- i_APCI3XXX_InsnReadAnalogInput,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- i_APCI3XXX_InsnReadDigitalInput,
- NULL,
- i_APCI3XXX_InsnBitsDigitalInput,
- NULL,
- i_APCI3XXX_InsnWriteDigitalOutput,
- i_APCI3XXX_InsnBitsDigitalOutput,
- i_APCI3XXX_InsnReadDigitalOutput,
- NULL,
- NULL,
- NULL,
- NULL,
- i_APCI3XXX_InsnConfigInitTTLIO,
- i_APCI3XXX_InsnBitsTTLIO,
- i_APCI3XXX_InsnReadTTLIO,
- i_APCI3XXX_InsnWriteTTLIO},
-
- {"apci3016-16",
- PCI_VENDOR_ID_ADDIDATA,
- 0x3019,
- 256,
- 256,
- 256,
- 256,
- ADDIDATA_NO_EEPROM,
- ADDIDATA_9054,
- 16,
- 8,
- 16,
- 0,
- 65535,
- 0,
- &range_apci3XXX_ai,
- NULL,
- 4,
- 4,
- 1,
- 24,
- &range_apci3XXX_ttl,
- 0,
- 0,
- 6,
- 5000,
- 0,
- v_APCI3XXX_Interrupt,
- i_APCI3XXX_Reset,
- i_APCI3XXX_InsnConfigAnalogInput,
- i_APCI3XXX_InsnReadAnalogInput,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- i_APCI3XXX_InsnReadDigitalInput,
- NULL,
- i_APCI3XXX_InsnBitsDigitalInput,
- NULL,
- i_APCI3XXX_InsnWriteDigitalOutput,
- i_APCI3XXX_InsnBitsDigitalOutput,
- i_APCI3XXX_InsnReadDigitalOutput,
- NULL,
- NULL,
- NULL,
- NULL,
- i_APCI3XXX_InsnConfigInitTTLIO,
- i_APCI3XXX_InsnBitsTTLIO,
- i_APCI3XXX_InsnReadTTLIO,
- i_APCI3XXX_InsnWriteTTLIO},
-
- {"apci3016-8",
- PCI_VENDOR_ID_ADDIDATA,
- 0x301A,
- 256,
- 256,
- 256,
- 256,
- ADDIDATA_NO_EEPROM,
- ADDIDATA_9054,
- 8,
- 4,
- 8,
- 0,
- 65535,
- 0,
- &range_apci3XXX_ai,
- NULL,
- 4,
- 4,
- 1,
- 24,
- &range_apci3XXX_ttl,
- 0,
- 0,
- 6,
- 5000,
- 0,
- v_APCI3XXX_Interrupt,
- i_APCI3XXX_Reset,
- i_APCI3XXX_InsnConfigAnalogInput,
- i_APCI3XXX_InsnReadAnalogInput,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- i_APCI3XXX_InsnReadDigitalInput,
- NULL,
- i_APCI3XXX_InsnBitsDigitalInput,
- NULL,
- i_APCI3XXX_InsnWriteDigitalOutput,
- i_APCI3XXX_InsnBitsDigitalOutput,
- i_APCI3XXX_InsnReadDigitalOutput,
- NULL,
- NULL,
- NULL,
- NULL,
- i_APCI3XXX_InsnConfigInitTTLIO,
- i_APCI3XXX_InsnBitsTTLIO,
- i_APCI3XXX_InsnReadTTLIO,
- i_APCI3XXX_InsnWriteTTLIO},
-
- {"apci3016-4",
- PCI_VENDOR_ID_ADDIDATA,
- 0x301B,
- 256,
- 256,
- 256,
- 256,
- ADDIDATA_NO_EEPROM,
- ADDIDATA_9054,
- 4,
- 2,
- 4,
- 0,
- 65535,
- 0,
- &range_apci3XXX_ai,
- NULL,
- 4,
- 4,
- 1,
- 24,
- &range_apci3XXX_ttl,
- 0,
- 0,
- 6,
- 5000,
- 0,
- v_APCI3XXX_Interrupt,
- i_APCI3XXX_Reset,
- i_APCI3XXX_InsnConfigAnalogInput,
- i_APCI3XXX_InsnReadAnalogInput,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- i_APCI3XXX_InsnReadDigitalInput,
- NULL,
- i_APCI3XXX_InsnBitsDigitalInput,
- NULL,
- i_APCI3XXX_InsnWriteDigitalOutput,
- i_APCI3XXX_InsnBitsDigitalOutput,
- i_APCI3XXX_InsnReadDigitalOutput,
- NULL,
- NULL,
- NULL,
- NULL,
- i_APCI3XXX_InsnConfigInitTTLIO,
- i_APCI3XXX_InsnBitsTTLIO,
- i_APCI3XXX_InsnReadTTLIO,
- i_APCI3XXX_InsnWriteTTLIO},
-
- {"apci3100-16-4",
- PCI_VENDOR_ID_ADDIDATA,
- 0x301C,
- 256,
- 256,
- 256,
- 256,
- ADDIDATA_NO_EEPROM,
- ADDIDATA_9054,
- 16,
- 8,
- 16,
- 4,
- 4095,
- 4095,
- &range_apci3XXX_ai,
- &range_apci3XXX_ao,
- 0,
- 0,
- 0,
- 24,
- &range_apci3XXX_ttl,
- 0,
- 0,
- 6,
- 10000,
- 0,
- v_APCI3XXX_Interrupt,
- i_APCI3XXX_Reset,
- i_APCI3XXX_InsnConfigAnalogInput,
- i_APCI3XXX_InsnReadAnalogInput,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- i_APCI3XXX_InsnWriteAnalogOutput,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- i_APCI3XXX_InsnConfigInitTTLIO,
- i_APCI3XXX_InsnBitsTTLIO,
- i_APCI3XXX_InsnReadTTLIO,
- i_APCI3XXX_InsnWriteTTLIO},
-
- {"apci3100-8-4",
- PCI_VENDOR_ID_ADDIDATA,
- 0x301D,
- 256,
- 256,
- 256,
- 256,
- ADDIDATA_NO_EEPROM,
- ADDIDATA_9054,
- 8,
- 4,
- 8,
- 4,
- 4095,
- 4095,
- &range_apci3XXX_ai,
- &range_apci3XXX_ao,
- 0,
- 0,
- 0,
- 24,
- &range_apci3XXX_ttl,
- 0,
- 0,
- 6,
- 10000,
- 0,
- v_APCI3XXX_Interrupt,
- i_APCI3XXX_Reset,
- i_APCI3XXX_InsnConfigAnalogInput,
- i_APCI3XXX_InsnReadAnalogInput,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- i_APCI3XXX_InsnWriteAnalogOutput,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- i_APCI3XXX_InsnConfigInitTTLIO,
- i_APCI3XXX_InsnBitsTTLIO,
- i_APCI3XXX_InsnReadTTLIO,
- i_APCI3XXX_InsnWriteTTLIO},
-
- {"apci3106-16-4",
- PCI_VENDOR_ID_ADDIDATA,
- 0x301E,
- 256,
- 256,
- 256,
- 256,
- ADDIDATA_NO_EEPROM,
- ADDIDATA_9054,
- 16,
- 8,
- 16,
- 4,
- 65535,
- 4095,
- &range_apci3XXX_ai,
- &range_apci3XXX_ao,
- 0,
- 0,
- 0,
- 24,
- &range_apci3XXX_ttl,
- 0,
- 0,
- 6,
- 10000,
- 0,
- v_APCI3XXX_Interrupt,
- i_APCI3XXX_Reset,
- i_APCI3XXX_InsnConfigAnalogInput,
- i_APCI3XXX_InsnReadAnalogInput,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- i_APCI3XXX_InsnWriteAnalogOutput,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- i_APCI3XXX_InsnConfigInitTTLIO,
- i_APCI3XXX_InsnBitsTTLIO,
- i_APCI3XXX_InsnReadTTLIO,
- i_APCI3XXX_InsnWriteTTLIO},
-
- {"apci3106-8-4",
- PCI_VENDOR_ID_ADDIDATA,
- 0x301F,
- 256,
- 256,
- 256,
- 256,
- ADDIDATA_NO_EEPROM,
- ADDIDATA_9054,
- 8,
- 4,
- 8,
- 4,
- 65535,
- 4095,
- &range_apci3XXX_ai,
- &range_apci3XXX_ao,
- 0,
- 0,
- 0,
- 24,
- &range_apci3XXX_ttl,
- 0,
- 0,
- 6,
- 10000,
- 0,
- v_APCI3XXX_Interrupt,
- i_APCI3XXX_Reset,
- i_APCI3XXX_InsnConfigAnalogInput,
- i_APCI3XXX_InsnReadAnalogInput,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- i_APCI3XXX_InsnWriteAnalogOutput,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- i_APCI3XXX_InsnConfigInitTTLIO,
- i_APCI3XXX_InsnBitsTTLIO,
- i_APCI3XXX_InsnReadTTLIO,
- i_APCI3XXX_InsnWriteTTLIO},
-
- {"apci3110-16-4",
- PCI_VENDOR_ID_ADDIDATA,
- 0x3020,
- 256,
- 256,
- 256,
- 256,
- ADDIDATA_NO_EEPROM,
- ADDIDATA_9054,
- 16,
- 8,
- 16,
- 4,
- 4095,
- 4095,
- &range_apci3XXX_ai,
- &range_apci3XXX_ao,
- 4,
- 4,
- 1,
- 24,
- &range_apci3XXX_ttl,
- 0,
- 0,
- 6,
- 5000,
- 0,
- v_APCI3XXX_Interrupt,
- i_APCI3XXX_Reset,
- i_APCI3XXX_InsnConfigAnalogInput,
- i_APCI3XXX_InsnReadAnalogInput,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- i_APCI3XXX_InsnWriteAnalogOutput,
- NULL,
- NULL,
- i_APCI3XXX_InsnReadDigitalInput,
- NULL,
- i_APCI3XXX_InsnBitsDigitalInput,
- NULL,
- i_APCI3XXX_InsnWriteDigitalOutput,
- i_APCI3XXX_InsnBitsDigitalOutput,
- i_APCI3XXX_InsnReadDigitalOutput,
- NULL,
- NULL,
- NULL,
- NULL,
- i_APCI3XXX_InsnConfigInitTTLIO,
- i_APCI3XXX_InsnBitsTTLIO,
- i_APCI3XXX_InsnReadTTLIO,
- i_APCI3XXX_InsnWriteTTLIO},
-
- {"apci3110-8-4",
- PCI_VENDOR_ID_ADDIDATA,
- 0x3021,
- 256,
- 256,
- 256,
- 256,
- ADDIDATA_NO_EEPROM,
- ADDIDATA_9054,
- 8,
- 4,
- 8,
- 4,
- 4095,
- 4095,
- &range_apci3XXX_ai,
- &range_apci3XXX_ao,
- 4,
- 4,
- 1,
- 24,
- &range_apci3XXX_ttl,
- 0,
- 0,
- 6,
- 5000,
- 0,
- v_APCI3XXX_Interrupt,
- i_APCI3XXX_Reset,
- i_APCI3XXX_InsnConfigAnalogInput,
- i_APCI3XXX_InsnReadAnalogInput,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- i_APCI3XXX_InsnWriteAnalogOutput,
- NULL,
- NULL,
- i_APCI3XXX_InsnReadDigitalInput,
- NULL,
- i_APCI3XXX_InsnBitsDigitalInput,
- NULL,
- i_APCI3XXX_InsnWriteDigitalOutput,
- i_APCI3XXX_InsnBitsDigitalOutput,
- i_APCI3XXX_InsnReadDigitalOutput,
- NULL,
- NULL,
- NULL,
- NULL,
- i_APCI3XXX_InsnConfigInitTTLIO,
- i_APCI3XXX_InsnBitsTTLIO,
- i_APCI3XXX_InsnReadTTLIO,
- i_APCI3XXX_InsnWriteTTLIO},
-
- {"apci3116-16-4",
- PCI_VENDOR_ID_ADDIDATA,
- 0x3022,
- 256,
- 256,
- 256,
- 256,
- ADDIDATA_NO_EEPROM,
- ADDIDATA_9054,
- 16,
- 8,
- 16,
- 4,
- 65535,
- 4095,
- &range_apci3XXX_ai,
- &range_apci3XXX_ao,
- 4,
- 4,
- 1,
- 24,
- &range_apci3XXX_ttl,
- 0,
- 0,
- 6,
- 5000,
- 0,
- v_APCI3XXX_Interrupt,
- i_APCI3XXX_Reset,
- i_APCI3XXX_InsnConfigAnalogInput,
- i_APCI3XXX_InsnReadAnalogInput,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- i_APCI3XXX_InsnWriteAnalogOutput,
- NULL,
- NULL,
- i_APCI3XXX_InsnReadDigitalInput,
- NULL,
- i_APCI3XXX_InsnBitsDigitalInput,
- NULL,
- i_APCI3XXX_InsnWriteDigitalOutput,
- i_APCI3XXX_InsnBitsDigitalOutput,
- i_APCI3XXX_InsnReadDigitalOutput,
- NULL,
- NULL,
- NULL,
- NULL,
- i_APCI3XXX_InsnConfigInitTTLIO,
- i_APCI3XXX_InsnBitsTTLIO,
- i_APCI3XXX_InsnReadTTLIO,
- i_APCI3XXX_InsnWriteTTLIO},
-
- {"apci3116-8-4",
- PCI_VENDOR_ID_ADDIDATA,
- 0x3023,
- 256,
- 256,
- 256,
- 256,
- ADDIDATA_NO_EEPROM,
- ADDIDATA_9054,
- 8,
- 4,
- 8,
- 4,
- 65535,
- 4095,
- &range_apci3XXX_ai,
- &range_apci3XXX_ao,
- 4,
- 4,
- 1,
- 24,
- &range_apci3XXX_ttl,
- 0,
- 0,
- 6,
- 5000,
- 0,
- v_APCI3XXX_Interrupt,
- i_APCI3XXX_Reset,
- i_APCI3XXX_InsnConfigAnalogInput,
- i_APCI3XXX_InsnReadAnalogInput,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- i_APCI3XXX_InsnWriteAnalogOutput,
- NULL,
- NULL,
- i_APCI3XXX_InsnReadDigitalInput,
- NULL,
- i_APCI3XXX_InsnBitsDigitalInput,
- NULL,
- i_APCI3XXX_InsnWriteDigitalOutput,
- i_APCI3XXX_InsnBitsDigitalOutput,
- i_APCI3XXX_InsnReadDigitalOutput,
- NULL,
- NULL,
- NULL,
- NULL,
- i_APCI3XXX_InsnConfigInitTTLIO,
- i_APCI3XXX_InsnBitsTTLIO,
- i_APCI3XXX_InsnReadTTLIO,
- i_APCI3XXX_InsnWriteTTLIO},
-
- {"apci3003",
- PCI_VENDOR_ID_ADDIDATA,
- 0x300B,
- 256,
- 256,
- 256,
- 256,
- ADDIDATA_NO_EEPROM,
- ADDIDATA_9054,
- 0,
- 4,
- 4,
- 0,
- 65535,
- 0,
- &range_apci3XXX_ai,
- NULL,
- 4,
- 4,
- 1,
- 0,
- NULL,
- 0,
- 0,
- 7,
- 2500,
- 0,
- v_APCI3XXX_Interrupt,
- i_APCI3XXX_Reset,
- i_APCI3XXX_InsnConfigAnalogInput,
- i_APCI3XXX_InsnReadAnalogInput,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- i_APCI3XXX_InsnReadDigitalInput,
- NULL,
- i_APCI3XXX_InsnBitsDigitalInput,
- NULL,
- i_APCI3XXX_InsnWriteDigitalOutput,
- i_APCI3XXX_InsnBitsDigitalOutput,
- i_APCI3XXX_InsnReadDigitalOutput,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL},
-
- {"apci3002-16",
- PCI_VENDOR_ID_ADDIDATA,
- 0x3002,
- 256,
- 256,
- 256,
- 256,
- ADDIDATA_NO_EEPROM,
- ADDIDATA_9054,
- 0,
- 16,
- 16,
- 0,
- 65535,
- 0,
- &range_apci3XXX_ai,
- NULL,
- 4,
- 4,
- 1,
- 0,
- NULL,
- 0,
- 0,
- 6,
- 5000,
- 0,
- v_APCI3XXX_Interrupt,
- i_APCI3XXX_Reset,
- i_APCI3XXX_InsnConfigAnalogInput,
- i_APCI3XXX_InsnReadAnalogInput,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- i_APCI3XXX_InsnReadDigitalInput,
- NULL,
- i_APCI3XXX_InsnBitsDigitalInput,
- NULL,
- i_APCI3XXX_InsnWriteDigitalOutput,
- i_APCI3XXX_InsnBitsDigitalOutput,
- i_APCI3XXX_InsnReadDigitalOutput,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL},
-
- {"apci3002-8",
- PCI_VENDOR_ID_ADDIDATA,
- 0x3003,
- 256,
- 256,
- 256,
- 256,
- ADDIDATA_NO_EEPROM,
- ADDIDATA_9054,
- 0,
- 8,
- 8,
- 0,
- 65535,
- 0,
- &range_apci3XXX_ai,
- NULL,
- 4,
- 4,
- 1,
- 0,
- NULL,
- 0,
- 0,
- 6,
- 5000,
- 0,
- v_APCI3XXX_Interrupt,
- i_APCI3XXX_Reset,
- i_APCI3XXX_InsnConfigAnalogInput,
- i_APCI3XXX_InsnReadAnalogInput,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- i_APCI3XXX_InsnReadDigitalInput,
- NULL,
- i_APCI3XXX_InsnBitsDigitalInput,
- NULL,
- i_APCI3XXX_InsnWriteDigitalOutput,
- i_APCI3XXX_InsnBitsDigitalOutput,
- i_APCI3XXX_InsnReadDigitalOutput,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL},
-
- {"apci3002-4",
- PCI_VENDOR_ID_ADDIDATA,
- 0x3004,
- 256,
- 256,
- 256,
- 256,
- ADDIDATA_NO_EEPROM,
- ADDIDATA_9054,
- 0,
- 4,
- 4,
- 0,
- 65535,
- 0,
- &range_apci3XXX_ai,
- NULL,
- 4,
- 4,
- 1,
- 0,
- NULL,
- 0,
- 0,
- 6,
- 5000,
- 0,
- v_APCI3XXX_Interrupt,
- i_APCI3XXX_Reset,
- i_APCI3XXX_InsnConfigAnalogInput,
- i_APCI3XXX_InsnReadAnalogInput,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- i_APCI3XXX_InsnReadDigitalInput,
- NULL,
- i_APCI3XXX_InsnBitsDigitalInput,
- NULL,
- i_APCI3XXX_InsnWriteDigitalOutput,
- i_APCI3XXX_InsnBitsDigitalOutput,
- i_APCI3XXX_InsnReadDigitalOutput,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL},
-
- {"apci3500",
- PCI_VENDOR_ID_ADDIDATA,
- 0x3024,
- 256,
- 256,
- 256,
- 256,
- ADDIDATA_NO_EEPROM,
- ADDIDATA_9054,
- 0,
- 0,
- 0,
- 4,
- 0,
- 4095,
- NULL,
- &range_apci3XXX_ao,
- 0,
- 0,
- 0,
- 24,
- &range_apci3XXX_ttl,
- 0,
- 0,
- 0,
- 0,
- 0,
- v_APCI3XXX_Interrupt,
- i_APCI3XXX_Reset,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- i_APCI3XXX_InsnWriteAnalogOutput,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- i_APCI3XXX_InsnConfigInitTTLIO,
- i_APCI3XXX_InsnBitsTTLIO,
- i_APCI3XXX_InsnReadTTLIO,
- i_APCI3XXX_InsnWriteTTLIO},
+ {
+ .pc_DriverName = "apci3000-16",
+ .i_VendorId = PCI_VENDOR_ID_ADDIDATA,
+ .i_DeviceId = 0x3010,
+ .i_IorangeBase0 = 256,
+ .i_IorangeBase1 = 256,
+ .i_IorangeBase2 = 256,
+ .i_IorangeBase3 = 256,
+ .i_PCIEeprom = ADDIDATA_NO_EEPROM,
+ .pc_EepromChip = ADDIDATA_9054,
+ .i_NbrAiChannel = 16,
+ .i_NbrAiChannelDiff = 8,
+ .i_AiChannelList = 16,
+ .i_AiMaxdata = 4095,
+ .pr_AiRangelist = &range_apci3XXX_ai,
+ .i_NbrTTLChannel = 24,
+ .b_AvailableConvertUnit = 6,
+ .ui_MinAcquisitiontimeNs = 10000,
+ .interrupt = v_APCI3XXX_Interrupt,
+ .reset = i_APCI3XXX_Reset,
+ .ai_config = i_APCI3XXX_InsnConfigAnalogInput,
+ .ai_read = i_APCI3XXX_InsnReadAnalogInput,
+ .ttl_config = i_APCI3XXX_InsnConfigInitTTLIO,
+ .ttl_bits = i_APCI3XXX_InsnBitsTTLIO,
+ .ttl_read = i_APCI3XXX_InsnReadTTLIO,
+ .ttl_write = i_APCI3XXX_InsnWriteTTLIO,
+ }, {
+ .pc_DriverName = "apci3000-8",
+ .i_VendorId = PCI_VENDOR_ID_ADDIDATA,
+ .i_DeviceId = 0x300F,
+ .i_IorangeBase0 = 256,
+ .i_IorangeBase1 = 256,
+ .i_IorangeBase2 = 256,
+ .i_IorangeBase3 = 256,
+ .i_PCIEeprom = ADDIDATA_NO_EEPROM,
+ .pc_EepromChip = ADDIDATA_9054,
+ .i_NbrAiChannel = 8,
+ .i_NbrAiChannelDiff = 4,
+ .i_AiChannelList = 8,
+ .i_AiMaxdata = 4095,
+ .pr_AiRangelist = &range_apci3XXX_ai,
+ .i_NbrTTLChannel = 24,
+ .b_AvailableConvertUnit = 6,
+ .ui_MinAcquisitiontimeNs = 10000,
+ .interrupt = v_APCI3XXX_Interrupt,
+ .reset = i_APCI3XXX_Reset,
+ .ai_config = i_APCI3XXX_InsnConfigAnalogInput,
+ .ai_read = i_APCI3XXX_InsnReadAnalogInput,
+ .ttl_config = i_APCI3XXX_InsnConfigInitTTLIO,
+ .ttl_bits = i_APCI3XXX_InsnBitsTTLIO,
+ .ttl_read = i_APCI3XXX_InsnReadTTLIO,
+ .ttl_write = i_APCI3XXX_InsnWriteTTLIO,
+ }, {
+ .pc_DriverName = "apci3000-4",
+ .i_VendorId = PCI_VENDOR_ID_ADDIDATA,
+ .i_DeviceId = 0x300E,
+ .i_IorangeBase0 = 256,
+ .i_IorangeBase1 = 256,
+ .i_IorangeBase2 = 256,
+ .i_IorangeBase3 = 256,
+ .i_PCIEeprom = ADDIDATA_NO_EEPROM,
+ .pc_EepromChip = ADDIDATA_9054,
+ .i_NbrAiChannel = 4,
+ .i_NbrAiChannelDiff = 2,
+ .i_AiChannelList = 4,
+ .i_AiMaxdata = 4095,
+ .pr_AiRangelist = &range_apci3XXX_ai,
+ .i_NbrTTLChannel = 24,
+ .b_AvailableConvertUnit = 6,
+ .ui_MinAcquisitiontimeNs = 10000,
+ .interrupt = v_APCI3XXX_Interrupt,
+ .reset = i_APCI3XXX_Reset,
+ .ai_config = i_APCI3XXX_InsnConfigAnalogInput,
+ .ai_read = i_APCI3XXX_InsnReadAnalogInput,
+ .ttl_config = i_APCI3XXX_InsnConfigInitTTLIO,
+ .ttl_bits = i_APCI3XXX_InsnBitsTTLIO,
+ .ttl_read = i_APCI3XXX_InsnReadTTLIO,
+ .ttl_write = i_APCI3XXX_InsnWriteTTLIO,
+ }, {
+ .pc_DriverName = "apci3006-16",
+ .i_VendorId = PCI_VENDOR_ID_ADDIDATA,
+ .i_DeviceId = 0x3013,
+ .i_IorangeBase0 = 256,
+ .i_IorangeBase1 = 256,
+ .i_IorangeBase2 = 256,
+ .i_IorangeBase3 = 256,
+ .i_PCIEeprom = ADDIDATA_NO_EEPROM,
+ .pc_EepromChip = ADDIDATA_9054,
+ .i_NbrAiChannel = 16,
+ .i_NbrAiChannelDiff = 8,
+ .i_AiChannelList = 16,
+ .i_AiMaxdata = 65535,
+ .pr_AiRangelist = &range_apci3XXX_ai,
+ .i_NbrTTLChannel = 24,
+ .b_AvailableConvertUnit = 6,
+ .ui_MinAcquisitiontimeNs = 10000,
+ .interrupt = v_APCI3XXX_Interrupt,
+ .reset = i_APCI3XXX_Reset,
+ .ai_config = i_APCI3XXX_InsnConfigAnalogInput,
+ .ai_read = i_APCI3XXX_InsnReadAnalogInput,
+ .ttl_config = i_APCI3XXX_InsnConfigInitTTLIO,
+ .ttl_bits = i_APCI3XXX_InsnBitsTTLIO,
+ .ttl_read = i_APCI3XXX_InsnReadTTLIO,
+ .ttl_write = i_APCI3XXX_InsnWriteTTLIO,
+ }, {
+ .pc_DriverName = "apci3006-8",
+ .i_VendorId = PCI_VENDOR_ID_ADDIDATA,
+ .i_DeviceId = 0x3014,
+ .i_IorangeBase0 = 256,
+ .i_IorangeBase1 = 256,
+ .i_IorangeBase2 = 256,
+ .i_IorangeBase3 = 256,
+ .i_PCIEeprom = ADDIDATA_NO_EEPROM,
+ .pc_EepromChip = ADDIDATA_9054,
+ .i_NbrAiChannel = 8,
+ .i_NbrAiChannelDiff = 4,
+ .i_AiChannelList = 8,
+ .i_AiMaxdata = 65535,
+ .pr_AiRangelist = &range_apci3XXX_ai,
+ .i_NbrTTLChannel = 24,
+ .b_AvailableConvertUnit = 6,
+ .ui_MinAcquisitiontimeNs = 10000,
+ .interrupt = v_APCI3XXX_Interrupt,
+ .reset = i_APCI3XXX_Reset,
+ .ai_config = i_APCI3XXX_InsnConfigAnalogInput,
+ .ai_read = i_APCI3XXX_InsnReadAnalogInput,
+ .ttl_config = i_APCI3XXX_InsnConfigInitTTLIO,
+ .ttl_bits = i_APCI3XXX_InsnBitsTTLIO,
+ .ttl_read = i_APCI3XXX_InsnReadTTLIO,
+ .ttl_write = i_APCI3XXX_InsnWriteTTLIO,
+ }, {
+ .pc_DriverName = "apci3006-4",
+ .i_VendorId = PCI_VENDOR_ID_ADDIDATA,
+ .i_DeviceId = 0x3015,
+ .i_IorangeBase0 = 256,
+ .i_IorangeBase1 = 256,
+ .i_IorangeBase2 = 256,
+ .i_IorangeBase3 = 256,
+ .i_PCIEeprom = ADDIDATA_NO_EEPROM,
+ .pc_EepromChip = ADDIDATA_9054,
+ .i_NbrAiChannel = 4,
+ .i_NbrAiChannelDiff = 2,
+ .i_AiChannelList = 4,
+ .i_AiMaxdata = 65535,
+ .pr_AiRangelist = &range_apci3XXX_ai,
+ .i_NbrTTLChannel = 24,
+ .b_AvailableConvertUnit = 6,
+ .ui_MinAcquisitiontimeNs = 10000,
+ .interrupt = v_APCI3XXX_Interrupt,
+ .reset = i_APCI3XXX_Reset,
+ .ai_config = i_APCI3XXX_InsnConfigAnalogInput,
+ .ai_read = i_APCI3XXX_InsnReadAnalogInput,
+ .ttl_config = i_APCI3XXX_InsnConfigInitTTLIO,
+ .ttl_bits = i_APCI3XXX_InsnBitsTTLIO,
+ .ttl_read = i_APCI3XXX_InsnReadTTLIO,
+ .ttl_write = i_APCI3XXX_InsnWriteTTLIO,
+ }, {
+ .pc_DriverName = "apci3010-16",
+ .i_VendorId = PCI_VENDOR_ID_ADDIDATA,
+ .i_DeviceId = 0x3016,
+ .i_IorangeBase0 = 256,
+ .i_IorangeBase1 = 256,
+ .i_IorangeBase2 = 256,
+ .i_IorangeBase3 = 256,
+ .i_PCIEeprom = ADDIDATA_NO_EEPROM,
+ .pc_EepromChip = ADDIDATA_9054,
+ .i_NbrAiChannel = 16,
+ .i_NbrAiChannelDiff = 8,
+ .i_AiChannelList = 16,
+ .i_AiMaxdata = 4095,
+ .pr_AiRangelist = &range_apci3XXX_ai,
+ .i_NbrDiChannel = 4,
+ .i_NbrDoChannel = 4,
+ .i_DoMaxdata = 1,
+ .i_NbrTTLChannel = 24,
+ .b_AvailableConvertUnit = 6,
+ .ui_MinAcquisitiontimeNs = 5000,
+ .interrupt = v_APCI3XXX_Interrupt,
+ .reset = i_APCI3XXX_Reset,
+ .ai_config = i_APCI3XXX_InsnConfigAnalogInput,
+ .ai_read = i_APCI3XXX_InsnReadAnalogInput,
+ .di_read = i_APCI3XXX_InsnReadDigitalInput,
+ .di_bits = i_APCI3XXX_InsnBitsDigitalInput,
+ .do_write = i_APCI3XXX_InsnWriteDigitalOutput,
+ .do_bits = i_APCI3XXX_InsnBitsDigitalOutput,
+ .do_read = i_APCI3XXX_InsnReadDigitalOutput,
+ .ttl_config = i_APCI3XXX_InsnConfigInitTTLIO,
+ .ttl_bits = i_APCI3XXX_InsnBitsTTLIO,
+ .ttl_read = i_APCI3XXX_InsnReadTTLIO,
+ .ttl_write = i_APCI3XXX_InsnWriteTTLIO,
+ }, {
+ .pc_DriverName = "apci3010-8",
+ .i_VendorId = PCI_VENDOR_ID_ADDIDATA,
+ .i_DeviceId = 0x3017,
+ .i_IorangeBase0 = 256,
+ .i_IorangeBase1 = 256,
+ .i_IorangeBase2 = 256,
+ .i_IorangeBase3 = 256,
+ .i_PCIEeprom = ADDIDATA_NO_EEPROM,
+ .pc_EepromChip = ADDIDATA_9054,
+ .i_NbrAiChannel = 8,
+ .i_NbrAiChannelDiff = 4,
+ .i_AiChannelList = 8,
+ .i_AiMaxdata = 4095,
+ .pr_AiRangelist = &range_apci3XXX_ai,
+ .i_NbrDiChannel = 4,
+ .i_NbrDoChannel = 4,
+ .i_DoMaxdata = 1,
+ .i_NbrTTLChannel = 24,
+ .b_AvailableConvertUnit = 6,
+ .ui_MinAcquisitiontimeNs = 5000,
+ .interrupt = v_APCI3XXX_Interrupt,
+ .reset = i_APCI3XXX_Reset,
+ .ai_config = i_APCI3XXX_InsnConfigAnalogInput,
+ .ai_read = i_APCI3XXX_InsnReadAnalogInput,
+ .di_read = i_APCI3XXX_InsnReadDigitalInput,
+ .di_bits = i_APCI3XXX_InsnBitsDigitalInput,
+ .do_write = i_APCI3XXX_InsnWriteDigitalOutput,
+ .do_bits = i_APCI3XXX_InsnBitsDigitalOutput,
+ .do_read = i_APCI3XXX_InsnReadDigitalOutput,
+ .ttl_config = i_APCI3XXX_InsnConfigInitTTLIO,
+ .ttl_bits = i_APCI3XXX_InsnBitsTTLIO,
+ .ttl_read = i_APCI3XXX_InsnReadTTLIO,
+ .ttl_write = i_APCI3XXX_InsnWriteTTLIO,
+ }, {
+ .pc_DriverName = "apci3010-4",
+ .i_VendorId = PCI_VENDOR_ID_ADDIDATA,
+ .i_DeviceId = 0x3018,
+ .i_IorangeBase0 = 256,
+ .i_IorangeBase1 = 256,
+ .i_IorangeBase2 = 256,
+ .i_IorangeBase3 = 256,
+ .i_PCIEeprom = ADDIDATA_NO_EEPROM,
+ .pc_EepromChip = ADDIDATA_9054,
+ .i_NbrAiChannel = 4,
+ .i_NbrAiChannelDiff = 2,
+ .i_AiChannelList = 4,
+ .i_AiMaxdata = 4095,
+ .pr_AiRangelist = &range_apci3XXX_ai,
+ .i_NbrDiChannel = 4,
+ .i_NbrDoChannel = 4,
+ .i_DoMaxdata = 1,
+ .i_NbrTTLChannel = 24,
+ .b_AvailableConvertUnit = 6,
+ .ui_MinAcquisitiontimeNs = 5000,
+ .interrupt = v_APCI3XXX_Interrupt,
+ .reset = i_APCI3XXX_Reset,
+ .ai_config = i_APCI3XXX_InsnConfigAnalogInput,
+ .ai_read = i_APCI3XXX_InsnReadAnalogInput,
+ .di_read = i_APCI3XXX_InsnReadDigitalInput,
+ .di_bits = i_APCI3XXX_InsnBitsDigitalInput,
+ .do_write = i_APCI3XXX_InsnWriteDigitalOutput,
+ .do_bits = i_APCI3XXX_InsnBitsDigitalOutput,
+ .do_read = i_APCI3XXX_InsnReadDigitalOutput,
+ .ttl_config = i_APCI3XXX_InsnConfigInitTTLIO,
+ .ttl_bits = i_APCI3XXX_InsnBitsTTLIO,
+ .ttl_read = i_APCI3XXX_InsnReadTTLIO,
+ .ttl_write = i_APCI3XXX_InsnWriteTTLIO,
+ }, {
+ .pc_DriverName = "apci3016-16",
+ .i_VendorId = PCI_VENDOR_ID_ADDIDATA,
+ .i_DeviceId = 0x3019,
+ .i_IorangeBase0 = 256,
+ .i_IorangeBase1 = 256,
+ .i_IorangeBase2 = 256,
+ .i_IorangeBase3 = 256,
+ .i_PCIEeprom = ADDIDATA_NO_EEPROM,
+ .pc_EepromChip = ADDIDATA_9054,
+ .i_NbrAiChannel = 16,
+ .i_NbrAiChannelDiff = 8,
+ .i_AiChannelList = 16,
+ .i_AiMaxdata = 65535,
+ .pr_AiRangelist = &range_apci3XXX_ai,
+ .i_NbrDiChannel = 4,
+ .i_NbrDoChannel = 4,
+ .i_DoMaxdata = 1,
+ .i_NbrTTLChannel = 24,
+ .b_AvailableConvertUnit = 6,
+ .ui_MinAcquisitiontimeNs = 5000,
+ .interrupt = v_APCI3XXX_Interrupt,
+ .reset = i_APCI3XXX_Reset,
+ .ai_config = i_APCI3XXX_InsnConfigAnalogInput,
+ .ai_read = i_APCI3XXX_InsnReadAnalogInput,
+ .di_read = i_APCI3XXX_InsnReadDigitalInput,
+ .di_bits = i_APCI3XXX_InsnBitsDigitalInput,
+ .do_write = i_APCI3XXX_InsnWriteDigitalOutput,
+ .do_bits = i_APCI3XXX_InsnBitsDigitalOutput,
+ .do_read = i_APCI3XXX_InsnReadDigitalOutput,
+ .ttl_config = i_APCI3XXX_InsnConfigInitTTLIO,
+ .ttl_bits = i_APCI3XXX_InsnBitsTTLIO,
+ .ttl_read = i_APCI3XXX_InsnReadTTLIO,
+ .ttl_write = i_APCI3XXX_InsnWriteTTLIO,
+ }, {
+ .pc_DriverName = "apci3016-8",
+ .i_VendorId = PCI_VENDOR_ID_ADDIDATA,
+ .i_DeviceId = 0x301A,
+ .i_IorangeBase0 = 256,
+ .i_IorangeBase1 = 256,
+ .i_IorangeBase2 = 256,
+ .i_IorangeBase3 = 256,
+ .i_PCIEeprom = ADDIDATA_NO_EEPROM,
+ .pc_EepromChip = ADDIDATA_9054,
+ .i_NbrAiChannel = 8,
+ .i_NbrAiChannelDiff = 4,
+ .i_AiChannelList = 8,
+ .i_AiMaxdata = 65535,
+ .pr_AiRangelist = &range_apci3XXX_ai,
+ .i_NbrDiChannel = 4,
+ .i_NbrDoChannel = 4,
+ .i_DoMaxdata = 1,
+ .i_NbrTTLChannel = 24,
+ .b_AvailableConvertUnit = 6,
+ .ui_MinAcquisitiontimeNs = 5000,
+ .interrupt = v_APCI3XXX_Interrupt,
+ .reset = i_APCI3XXX_Reset,
+ .ai_config = i_APCI3XXX_InsnConfigAnalogInput,
+ .ai_read = i_APCI3XXX_InsnReadAnalogInput,
+ .di_read = i_APCI3XXX_InsnReadDigitalInput,
+ .di_bits = i_APCI3XXX_InsnBitsDigitalInput,
+ .do_write = i_APCI3XXX_InsnWriteDigitalOutput,
+ .do_bits = i_APCI3XXX_InsnBitsDigitalOutput,
+ .do_read = i_APCI3XXX_InsnReadDigitalOutput,
+ .ttl_config = i_APCI3XXX_InsnConfigInitTTLIO,
+ .ttl_bits = i_APCI3XXX_InsnBitsTTLIO,
+ .ttl_read = i_APCI3XXX_InsnReadTTLIO,
+ .ttl_write = i_APCI3XXX_InsnWriteTTLIO,
+ }, {
+ .pc_DriverName = "apci3016-4",
+ .i_VendorId = PCI_VENDOR_ID_ADDIDATA,
+ .i_DeviceId = 0x301B,
+ .i_IorangeBase0 = 256,
+ .i_IorangeBase1 = 256,
+ .i_IorangeBase2 = 256,
+ .i_IorangeBase3 = 256,
+ .i_PCIEeprom = ADDIDATA_NO_EEPROM,
+ .pc_EepromChip = ADDIDATA_9054,
+ .i_NbrAiChannel = 4,
+ .i_NbrAiChannelDiff = 2,
+ .i_AiChannelList = 4,
+ .i_AiMaxdata = 65535,
+ .pr_AiRangelist = &range_apci3XXX_ai,
+ .i_NbrDiChannel = 4,
+ .i_NbrDoChannel = 4,
+ .i_DoMaxdata = 1,
+ .i_NbrTTLChannel = 24,
+ .b_AvailableConvertUnit = 6,
+ .ui_MinAcquisitiontimeNs = 5000,
+ .interrupt = v_APCI3XXX_Interrupt,
+ .reset = i_APCI3XXX_Reset,
+ .ai_config = i_APCI3XXX_InsnConfigAnalogInput,
+ .ai_read = i_APCI3XXX_InsnReadAnalogInput,
+ .di_read = i_APCI3XXX_InsnReadDigitalInput,
+ .di_bits = i_APCI3XXX_InsnBitsDigitalInput,
+ .do_write = i_APCI3XXX_InsnWriteDigitalOutput,
+ .do_bits = i_APCI3XXX_InsnBitsDigitalOutput,
+ .do_read = i_APCI3XXX_InsnReadDigitalOutput,
+ .ttl_config = i_APCI3XXX_InsnConfigInitTTLIO,
+ .ttl_bits = i_APCI3XXX_InsnBitsTTLIO,
+ .ttl_read = i_APCI3XXX_InsnReadTTLIO,
+ .ttl_write = i_APCI3XXX_InsnWriteTTLIO,
+ }, {
+ .pc_DriverName = "apci3100-16-4",
+ .i_VendorId = PCI_VENDOR_ID_ADDIDATA,
+ .i_DeviceId = 0x301C,
+ .i_IorangeBase0 = 256,
+ .i_IorangeBase1 = 256,
+ .i_IorangeBase2 = 256,
+ .i_IorangeBase3 = 256,
+ .i_PCIEeprom = ADDIDATA_NO_EEPROM,
+ .pc_EepromChip = ADDIDATA_9054,
+ .i_NbrAiChannel = 16,
+ .i_NbrAiChannelDiff = 8,
+ .i_AiChannelList = 16,
+ .i_NbrAoChannel = 4,
+ .i_AiMaxdata = 4095,
+ .i_AoMaxdata = 4095,
+ .pr_AiRangelist = &range_apci3XXX_ai,
+ .pr_AoRangelist = &range_apci3XXX_ao,
+ .i_NbrTTLChannel = 24,
+ .b_AvailableConvertUnit = 6,
+ .ui_MinAcquisitiontimeNs = 10000,
+ .interrupt = v_APCI3XXX_Interrupt,
+ .reset = i_APCI3XXX_Reset,
+ .ai_config = i_APCI3XXX_InsnConfigAnalogInput,
+ .ai_read = i_APCI3XXX_InsnReadAnalogInput,
+ .ao_write = i_APCI3XXX_InsnWriteAnalogOutput,
+ .ttl_config = i_APCI3XXX_InsnConfigInitTTLIO,
+ .ttl_bits = i_APCI3XXX_InsnBitsTTLIO,
+ .ttl_read = i_APCI3XXX_InsnReadTTLIO,
+ .ttl_write = i_APCI3XXX_InsnWriteTTLIO,
+ }, {
+ .pc_DriverName = "apci3100-8-4",
+ .i_VendorId = PCI_VENDOR_ID_ADDIDATA,
+ .i_DeviceId = 0x301D,
+ .i_IorangeBase0 = 256,
+ .i_IorangeBase1 = 256,
+ .i_IorangeBase2 = 256,
+ .i_IorangeBase3 = 256,
+ .i_PCIEeprom = ADDIDATA_NO_EEPROM,
+ .pc_EepromChip = ADDIDATA_9054,
+ .i_NbrAiChannel = 8,
+ .i_NbrAiChannelDiff = 4,
+ .i_AiChannelList = 8,
+ .i_NbrAoChannel = 4,
+ .i_AiMaxdata = 4095,
+ .i_AoMaxdata = 4095,
+ .pr_AiRangelist = &range_apci3XXX_ai,
+ .pr_AoRangelist = &range_apci3XXX_ao,
+ .i_NbrTTLChannel = 24,
+ .b_AvailableConvertUnit = 6,
+ .ui_MinAcquisitiontimeNs = 10000,
+ .interrupt = v_APCI3XXX_Interrupt,
+ .reset = i_APCI3XXX_Reset,
+ .ai_config = i_APCI3XXX_InsnConfigAnalogInput,
+ .ai_read = i_APCI3XXX_InsnReadAnalogInput,
+ .ao_write = i_APCI3XXX_InsnWriteAnalogOutput,
+ .ttl_config = i_APCI3XXX_InsnConfigInitTTLIO,
+ .ttl_bits = i_APCI3XXX_InsnBitsTTLIO,
+ .ttl_read = i_APCI3XXX_InsnReadTTLIO,
+ .ttl_write = i_APCI3XXX_InsnWriteTTLIO,
+ }, {
+ .pc_DriverName = "apci3106-16-4",
+ .i_VendorId = PCI_VENDOR_ID_ADDIDATA,
+ .i_DeviceId = 0x301E,
+ .i_IorangeBase0 = 256,
+ .i_IorangeBase1 = 256,
+ .i_IorangeBase2 = 256,
+ .i_IorangeBase3 = 256,
+ .i_PCIEeprom = ADDIDATA_NO_EEPROM,
+ .pc_EepromChip = ADDIDATA_9054,
+ .i_NbrAiChannel = 16,
+ .i_NbrAiChannelDiff = 8,
+ .i_AiChannelList = 16,
+ .i_NbrAoChannel = 4,
+ .i_AiMaxdata = 65535,
+ .i_AoMaxdata = 4095,
+ .pr_AiRangelist = &range_apci3XXX_ai,
+ .pr_AoRangelist = &range_apci3XXX_ao,
+ .i_NbrTTLChannel = 24,
+ .b_AvailableConvertUnit = 6,
+ .ui_MinAcquisitiontimeNs = 10000,
+ .interrupt = v_APCI3XXX_Interrupt,
+ .reset = i_APCI3XXX_Reset,
+ .ai_config = i_APCI3XXX_InsnConfigAnalogInput,
+ .ai_read = i_APCI3XXX_InsnReadAnalogInput,
+ .ao_write = i_APCI3XXX_InsnWriteAnalogOutput,
+ .ttl_config = i_APCI3XXX_InsnConfigInitTTLIO,
+ .ttl_bits = i_APCI3XXX_InsnBitsTTLIO,
+ .ttl_read = i_APCI3XXX_InsnReadTTLIO,
+ .ttl_write = i_APCI3XXX_InsnWriteTTLIO,
+ }, {
+ .pc_DriverName = "apci3106-8-4",
+ .i_VendorId = PCI_VENDOR_ID_ADDIDATA,
+ .i_DeviceId = 0x301F,
+ .i_IorangeBase0 = 256,
+ .i_IorangeBase1 = 256,
+ .i_IorangeBase2 = 256,
+ .i_IorangeBase3 = 256,
+ .i_PCIEeprom = ADDIDATA_NO_EEPROM,
+ .pc_EepromChip = ADDIDATA_9054,
+ .i_NbrAiChannel = 8,
+ .i_NbrAiChannelDiff = 4,
+ .i_AiChannelList = 8,
+ .i_NbrAoChannel = 4,
+ .i_AiMaxdata = 65535,
+ .i_AoMaxdata = 4095,
+ .pr_AiRangelist = &range_apci3XXX_ai,
+ .pr_AoRangelist = &range_apci3XXX_ao,
+ .i_NbrTTLChannel = 24,
+ .b_AvailableConvertUnit = 6,
+ .ui_MinAcquisitiontimeNs = 10000,
+ .interrupt = v_APCI3XXX_Interrupt,
+ .reset = i_APCI3XXX_Reset,
+ .ai_config = i_APCI3XXX_InsnConfigAnalogInput,
+ .ai_read = i_APCI3XXX_InsnReadAnalogInput,
+ .ao_write = i_APCI3XXX_InsnWriteAnalogOutput,
+ .ttl_config = i_APCI3XXX_InsnConfigInitTTLIO,
+ .ttl_bits = i_APCI3XXX_InsnBitsTTLIO,
+ .ttl_read = i_APCI3XXX_InsnReadTTLIO,
+ .ttl_write = i_APCI3XXX_InsnWriteTTLIO,
+ }, {
+ .pc_DriverName = "apci3110-16-4",
+ .i_VendorId = PCI_VENDOR_ID_ADDIDATA,
+ .i_DeviceId = 0x3020,
+ .i_IorangeBase0 = 256,
+ .i_IorangeBase1 = 256,
+ .i_IorangeBase2 = 256,
+ .i_IorangeBase3 = 256,
+ .i_PCIEeprom = ADDIDATA_NO_EEPROM,
+ .pc_EepromChip = ADDIDATA_9054,
+ .i_NbrAiChannel = 16,
+ .i_NbrAiChannelDiff = 8,
+ .i_AiChannelList = 16,
+ .i_NbrAoChannel = 4,
+ .i_AiMaxdata = 4095,
+ .i_AoMaxdata = 4095,
+ .pr_AiRangelist = &range_apci3XXX_ai,
+ .pr_AoRangelist = &range_apci3XXX_ao,
+ .i_NbrDiChannel = 4,
+ .i_NbrDoChannel = 4,
+ .i_DoMaxdata = 1,
+ .i_NbrTTLChannel = 24,
+ .b_AvailableConvertUnit = 6,
+ .ui_MinAcquisitiontimeNs = 5000,
+ .interrupt = v_APCI3XXX_Interrupt,
+ .reset = i_APCI3XXX_Reset,
+ .ai_config = i_APCI3XXX_InsnConfigAnalogInput,
+ .ai_read = i_APCI3XXX_InsnReadAnalogInput,
+ .ao_write = i_APCI3XXX_InsnWriteAnalogOutput,
+ .di_read = i_APCI3XXX_InsnReadDigitalInput,
+ .di_bits = i_APCI3XXX_InsnBitsDigitalInput,
+ .do_write = i_APCI3XXX_InsnWriteDigitalOutput,
+ .do_bits = i_APCI3XXX_InsnBitsDigitalOutput,
+ .do_read = i_APCI3XXX_InsnReadDigitalOutput,
+ .ttl_config = i_APCI3XXX_InsnConfigInitTTLIO,
+ .ttl_bits = i_APCI3XXX_InsnBitsTTLIO,
+ .ttl_read = i_APCI3XXX_InsnReadTTLIO,
+ .ttl_write = i_APCI3XXX_InsnWriteTTLIO,
+ }, {
+ .pc_DriverName = "apci3110-8-4",
+ .i_VendorId = PCI_VENDOR_ID_ADDIDATA,
+ .i_DeviceId = 0x3021,
+ .i_IorangeBase0 = 256,
+ .i_IorangeBase1 = 256,
+ .i_IorangeBase2 = 256,
+ .i_IorangeBase3 = 256,
+ .i_PCIEeprom = ADDIDATA_NO_EEPROM,
+ .pc_EepromChip = ADDIDATA_9054,
+ .i_NbrAiChannel = 8,
+ .i_NbrAiChannelDiff = 4,
+ .i_AiChannelList = 8,
+ .i_NbrAoChannel = 4,
+ .i_AiMaxdata = 4095,
+ .i_AoMaxdata = 4095,
+ .pr_AiRangelist = &range_apci3XXX_ai,
+ .pr_AoRangelist = &range_apci3XXX_ao,
+ .i_NbrDiChannel = 4,
+ .i_NbrDoChannel = 4,
+ .i_DoMaxdata = 1,
+ .i_NbrTTLChannel = 24,
+ .b_AvailableConvertUnit = 6,
+ .ui_MinAcquisitiontimeNs = 5000,
+ .interrupt = v_APCI3XXX_Interrupt,
+ .reset = i_APCI3XXX_Reset,
+ .ai_config = i_APCI3XXX_InsnConfigAnalogInput,
+ .ai_read = i_APCI3XXX_InsnReadAnalogInput,
+ .ao_write = i_APCI3XXX_InsnWriteAnalogOutput,
+ .di_read = i_APCI3XXX_InsnReadDigitalInput,
+ .di_bits = i_APCI3XXX_InsnBitsDigitalInput,
+ .do_write = i_APCI3XXX_InsnWriteDigitalOutput,
+ .do_bits = i_APCI3XXX_InsnBitsDigitalOutput,
+ .do_read = i_APCI3XXX_InsnReadDigitalOutput,
+ .ttl_config = i_APCI3XXX_InsnConfigInitTTLIO,
+ .ttl_bits = i_APCI3XXX_InsnBitsTTLIO,
+ .ttl_read = i_APCI3XXX_InsnReadTTLIO,
+ .ttl_write = i_APCI3XXX_InsnWriteTTLIO,
+ }, {
+ .pc_DriverName = "apci3116-16-4",
+ .i_VendorId = PCI_VENDOR_ID_ADDIDATA,
+ .i_DeviceId = 0x3022,
+ .i_IorangeBase0 = 256,
+ .i_IorangeBase1 = 256,
+ .i_IorangeBase2 = 256,
+ .i_IorangeBase3 = 256,
+ .i_PCIEeprom = ADDIDATA_NO_EEPROM,
+ .pc_EepromChip = ADDIDATA_9054,
+ .i_NbrAiChannel = 16,
+ .i_NbrAiChannelDiff = 8,
+ .i_AiChannelList = 16,
+ .i_NbrAoChannel = 4,
+ .i_AiMaxdata = 65535,
+ .i_AoMaxdata = 4095,
+ .pr_AiRangelist = &range_apci3XXX_ai,
+ .pr_AoRangelist = &range_apci3XXX_ao,
+ .i_NbrDiChannel = 4,
+ .i_NbrDoChannel = 4,
+ .i_DoMaxdata = 1,
+ .i_NbrTTLChannel = 24,
+ .b_AvailableConvertUnit = 6,
+ .ui_MinAcquisitiontimeNs = 5000,
+ .interrupt = v_APCI3XXX_Interrupt,
+ .reset = i_APCI3XXX_Reset,
+ .ai_config = i_APCI3XXX_InsnConfigAnalogInput,
+ .ai_read = i_APCI3XXX_InsnReadAnalogInput,
+ .ao_write = i_APCI3XXX_InsnWriteAnalogOutput,
+ .di_read = i_APCI3XXX_InsnReadDigitalInput,
+ .di_bits = i_APCI3XXX_InsnBitsDigitalInput,
+ .do_write = i_APCI3XXX_InsnWriteDigitalOutput,
+ .do_bits = i_APCI3XXX_InsnBitsDigitalOutput,
+ .do_read = i_APCI3XXX_InsnReadDigitalOutput,
+ .ttl_config = i_APCI3XXX_InsnConfigInitTTLIO,
+ .ttl_bits = i_APCI3XXX_InsnBitsTTLIO,
+ .ttl_read = i_APCI3XXX_InsnReadTTLIO,
+ .ttl_write = i_APCI3XXX_InsnWriteTTLIO,
+ }, {
+ .pc_DriverName = "apci3116-8-4",
+ .i_VendorId = PCI_VENDOR_ID_ADDIDATA,
+ .i_DeviceId = 0x3023,
+ .i_IorangeBase0 = 256,
+ .i_IorangeBase1 = 256,
+ .i_IorangeBase2 = 256,
+ .i_IorangeBase3 = 256,
+ .i_PCIEeprom = ADDIDATA_NO_EEPROM,
+ .pc_EepromChip = ADDIDATA_9054,
+ .i_NbrAiChannel = 8,
+ .i_NbrAiChannelDiff = 4,
+ .i_AiChannelList = 8,
+ .i_NbrAoChannel = 4,
+ .i_AiMaxdata = 65535,
+ .i_AoMaxdata = 4095,
+ .pr_AiRangelist = &range_apci3XXX_ai,
+ .pr_AoRangelist = &range_apci3XXX_ao,
+ .i_NbrDiChannel = 4,
+ .i_NbrDoChannel = 4,
+ .i_DoMaxdata = 1,
+ .i_NbrTTLChannel = 24,
+ .b_AvailableConvertUnit = 6,
+ .ui_MinAcquisitiontimeNs = 5000,
+ .interrupt = v_APCI3XXX_Interrupt,
+ .reset = i_APCI3XXX_Reset,
+ .ai_config = i_APCI3XXX_InsnConfigAnalogInput,
+ .ai_read = i_APCI3XXX_InsnReadAnalogInput,
+ .ao_write = i_APCI3XXX_InsnWriteAnalogOutput,
+ .di_read = i_APCI3XXX_InsnReadDigitalInput,
+ .di_bits = i_APCI3XXX_InsnBitsDigitalInput,
+ .do_write = i_APCI3XXX_InsnWriteDigitalOutput,
+ .do_bits = i_APCI3XXX_InsnBitsDigitalOutput,
+ .do_read = i_APCI3XXX_InsnReadDigitalOutput,
+ .ttl_config = i_APCI3XXX_InsnConfigInitTTLIO,
+ .ttl_bits = i_APCI3XXX_InsnBitsTTLIO,
+ .ttl_read = i_APCI3XXX_InsnReadTTLIO,
+ .ttl_write = i_APCI3XXX_InsnWriteTTLIO,
+ }, {
+ .pc_DriverName = "apci3003",
+ .i_VendorId = PCI_VENDOR_ID_ADDIDATA,
+ .i_DeviceId = 0x300B,
+ .i_IorangeBase0 = 256,
+ .i_IorangeBase1 = 256,
+ .i_IorangeBase2 = 256,
+ .i_IorangeBase3 = 256,
+ .i_PCIEeprom = ADDIDATA_NO_EEPROM,
+ .pc_EepromChip = ADDIDATA_9054,
+ .i_NbrAiChannelDiff = 4,
+ .i_AiChannelList = 4,
+ .i_AiMaxdata = 65535,
+ .pr_AiRangelist = &range_apci3XXX_ai,
+ .i_NbrDiChannel = 4,
+ .i_NbrDoChannel = 4,
+ .i_DoMaxdata = 1,
+ .b_AvailableConvertUnit = 7,
+ .ui_MinAcquisitiontimeNs = 2500,
+ .interrupt = v_APCI3XXX_Interrupt,
+ .reset = i_APCI3XXX_Reset,
+ .ai_config = i_APCI3XXX_InsnConfigAnalogInput,
+ .ai_read = i_APCI3XXX_InsnReadAnalogInput,
+ .di_read = i_APCI3XXX_InsnReadDigitalInput,
+ .di_bits = i_APCI3XXX_InsnBitsDigitalInput,
+ .do_write = i_APCI3XXX_InsnWriteDigitalOutput,
+ .do_bits = i_APCI3XXX_InsnBitsDigitalOutput,
+ .do_read = i_APCI3XXX_InsnReadDigitalOutput,
+ }, {
+ .pc_DriverName = "apci3002-16",
+ .i_VendorId = PCI_VENDOR_ID_ADDIDATA,
+ .i_DeviceId = 0x3002,
+ .i_IorangeBase0 = 256,
+ .i_IorangeBase1 = 256,
+ .i_IorangeBase2 = 256,
+ .i_IorangeBase3 = 256,
+ .i_PCIEeprom = ADDIDATA_NO_EEPROM,
+ .pc_EepromChip = ADDIDATA_9054,
+ .i_NbrAiChannelDiff = 16,
+ .i_AiChannelList = 16,
+ .i_AiMaxdata = 65535,
+ .pr_AiRangelist = &range_apci3XXX_ai,
+ .i_NbrDiChannel = 4,
+ .i_NbrDoChannel = 4,
+ .i_DoMaxdata = 1,
+ .b_AvailableConvertUnit = 6,
+ .ui_MinAcquisitiontimeNs = 5000,
+ .interrupt = v_APCI3XXX_Interrupt,
+ .reset = i_APCI3XXX_Reset,
+ .ai_config = i_APCI3XXX_InsnConfigAnalogInput,
+ .ai_read = i_APCI3XXX_InsnReadAnalogInput,
+ .di_read = i_APCI3XXX_InsnReadDigitalInput,
+ .di_bits = i_APCI3XXX_InsnBitsDigitalInput,
+ .do_write = i_APCI3XXX_InsnWriteDigitalOutput,
+ .do_bits = i_APCI3XXX_InsnBitsDigitalOutput,
+ .do_read = i_APCI3XXX_InsnReadDigitalOutput,
+ }, {
+ .pc_DriverName = "apci3002-8",
+ .i_VendorId = PCI_VENDOR_ID_ADDIDATA,
+ .i_DeviceId = 0x3003,
+ .i_IorangeBase0 = 256,
+ .i_IorangeBase1 = 256,
+ .i_IorangeBase2 = 256,
+ .i_IorangeBase3 = 256,
+ .i_PCIEeprom = ADDIDATA_NO_EEPROM,
+ .pc_EepromChip = ADDIDATA_9054,
+ .i_NbrAiChannelDiff = 8,
+ .i_AiChannelList = 8,
+ .i_AiMaxdata = 65535,
+ .pr_AiRangelist = &range_apci3XXX_ai,
+ .i_NbrDiChannel = 4,
+ .i_NbrDoChannel = 4,
+ .i_DoMaxdata = 1,
+ .b_AvailableConvertUnit = 6,
+ .ui_MinAcquisitiontimeNs = 5000,
+ .interrupt = v_APCI3XXX_Interrupt,
+ .reset = i_APCI3XXX_Reset,
+ .ai_config = i_APCI3XXX_InsnConfigAnalogInput,
+ .ai_read = i_APCI3XXX_InsnReadAnalogInput,
+ .di_read = i_APCI3XXX_InsnReadDigitalInput,
+ .di_bits = i_APCI3XXX_InsnBitsDigitalInput,
+ .do_write = i_APCI3XXX_InsnWriteDigitalOutput,
+ .do_bits = i_APCI3XXX_InsnBitsDigitalOutput,
+ .do_read = i_APCI3XXX_InsnReadDigitalOutput,
+ }, {
+ .pc_DriverName = "apci3002-4",
+ .i_VendorId = PCI_VENDOR_ID_ADDIDATA,
+ .i_DeviceId = 0x3004,
+ .i_IorangeBase0 = 256,
+ .i_IorangeBase1 = 256,
+ .i_IorangeBase2 = 256,
+ .i_IorangeBase3 = 256,
+ .i_PCIEeprom = ADDIDATA_NO_EEPROM,
+ .pc_EepromChip = ADDIDATA_9054,
+ .i_NbrAiChannelDiff = 4,
+ .i_AiChannelList = 4,
+ .i_AiMaxdata = 65535,
+ .pr_AiRangelist = &range_apci3XXX_ai,
+ .i_NbrDiChannel = 4,
+ .i_NbrDoChannel = 4,
+ .i_DoMaxdata = 1,
+ .b_AvailableConvertUnit = 6,
+ .ui_MinAcquisitiontimeNs = 5000,
+ .interrupt = v_APCI3XXX_Interrupt,
+ .reset = i_APCI3XXX_Reset,
+ .ai_config = i_APCI3XXX_InsnConfigAnalogInput,
+ .ai_read = i_APCI3XXX_InsnReadAnalogInput,
+ .di_read = i_APCI3XXX_InsnReadDigitalInput,
+ .di_bits = i_APCI3XXX_InsnBitsDigitalInput,
+ .do_write = i_APCI3XXX_InsnWriteDigitalOutput,
+ .do_bits = i_APCI3XXX_InsnBitsDigitalOutput,
+ .do_read = i_APCI3XXX_InsnReadDigitalOutput,
+ }, {
+ .pc_DriverName = "apci3500",
+ .i_VendorId = PCI_VENDOR_ID_ADDIDATA,
+ .i_DeviceId = 0x3024,
+ .i_IorangeBase0 = 256,
+ .i_IorangeBase1 = 256,
+ .i_IorangeBase2 = 256,
+ .i_IorangeBase3 = 256,
+ .i_PCIEeprom = ADDIDATA_NO_EEPROM,
+ .pc_EepromChip = ADDIDATA_9054,
+ .i_NbrAoChannel = 4,
+ .i_AoMaxdata = 4095,
+ .pr_AoRangelist = &range_apci3XXX_ao,
+ .i_NbrTTLChannel = 24,
+ .interrupt = v_APCI3XXX_Interrupt,
+ .reset = i_APCI3XXX_Reset,
+ .ao_write = i_APCI3XXX_InsnWriteAnalogOutput,
+ .ttl_config = i_APCI3XXX_InsnConfigInitTTLIO,
+ .ttl_bits = i_APCI3XXX_InsnBitsTTLIO,
+ .ttl_read = i_APCI3XXX_InsnReadTTLIO,
+ .ttl_write = i_APCI3XXX_InsnWriteTTLIO,
+ },
#endif
};
-#define n_boardtypes (sizeof(boardtypes)/sizeof(struct addi_board))
-
static struct comedi_driver driver_addi = {
.driver_name = ADDIDATA_DRIVER_NAME,
.module = THIS_MODULE,
.attach = i_ADDI_Attach,
.detach = i_ADDI_Detach,
- .num_names = n_boardtypes,
+ .num_names = ARRAY_SIZE(boardtypes),
.board_name = &boardtypes[0].pc_DriverName,
.offset = sizeof(struct addi_board),
};
@@ -2543,7 +1415,7 @@ static struct comedi_driver driver_addi = {
static int __devinit driver_addi_pci_probe(struct pci_dev *dev,
const struct pci_device_id *ent)
{
- return comedi_pci_auto_config(dev, driver_addi.driver_name);
+ return comedi_pci_auto_config(dev, &driver_addi);
}
static void __devexit driver_addi_pci_remove(struct pci_dev *dev)
@@ -2791,10 +1663,9 @@ static int i_ADDI_Attach(struct comedi_device *dev, struct comedi_devconfig *it)
devpriv->s_BoardInfos.ui_Address = io_addr[2];
#endif
} else {
- /* Update-0.7.57->0.7.68dev->n_subdevices = 7; */
n_subdevices = 7;
- ret = alloc_subdevices(dev, n_subdevices);
- if (ret < 0)
+ ret = comedi_alloc_subdevices(dev, n_subdevices);
+ if (ret)
return ret;
/* Allocate and Initialise AI Subdevice Structures */
@@ -2821,16 +1692,13 @@ static int i_ADDI_Attach(struct comedi_device *dev, struct comedi_devconfig *it)
/* Set the initialisation flag */
devpriv->b_AiInitialisation = 1;
- s->insn_config =
- this_board->i_hwdrv_InsnConfigAnalogInput;
- s->insn_read = this_board->i_hwdrv_InsnReadAnalogInput;
- s->insn_write =
- this_board->i_hwdrv_InsnWriteAnalogInput;
- s->insn_bits = this_board->i_hwdrv_InsnBitsAnalogInput;
- s->do_cmdtest =
- this_board->i_hwdrv_CommandTestAnalogInput;
- s->do_cmd = this_board->i_hwdrv_CommandAnalogInput;
- s->cancel = this_board->i_hwdrv_CancelAnalogInput;
+ s->insn_config = this_board->ai_config;
+ s->insn_read = this_board->ai_read;
+ s->insn_write = this_board->ai_write;
+ s->insn_bits = this_board->ai_bits;
+ s->do_cmdtest = this_board->ai_cmdtest;
+ s->do_cmd = this_board->ai_cmd;
+ s->cancel = this_board->ai_cancel;
} else {
s->type = COMEDI_SUBD_UNUSED;
@@ -2846,10 +1714,8 @@ static int i_ADDI_Attach(struct comedi_device *dev, struct comedi_devconfig *it)
s->len_chanlist =
devpriv->s_EeParameters.i_NbrAoChannel;
s->range_table = this_board->pr_AoRangelist;
- s->insn_config =
- this_board->i_hwdrv_InsnConfigAnalogOutput;
- s->insn_write =
- this_board->i_hwdrv_InsnWriteAnalogOutput;
+ s->insn_config = this_board->ao_config;
+ s->insn_write = this_board->ao_write;
} else {
s->type = COMEDI_SUBD_UNUSED;
}
@@ -2864,12 +1730,10 @@ static int i_ADDI_Attach(struct comedi_device *dev, struct comedi_devconfig *it)
devpriv->s_EeParameters.i_NbrDiChannel;
s->range_table = &range_digital;
s->io_bits = 0; /* all bits input */
- s->insn_config =
- this_board->i_hwdrv_InsnConfigDigitalInput;
- s->insn_read = this_board->i_hwdrv_InsnReadDigitalInput;
- s->insn_write =
- this_board->i_hwdrv_InsnWriteDigitalInput;
- s->insn_bits = this_board->i_hwdrv_InsnBitsDigitalInput;
+ s->insn_config = this_board->di_config;
+ s->insn_read = this_board->di_read;
+ s->insn_write = this_board->di_write;
+ s->insn_bits = this_board->di_bits;
} else {
s->type = COMEDI_SUBD_UNUSED;
}
@@ -2886,13 +1750,11 @@ static int i_ADDI_Attach(struct comedi_device *dev, struct comedi_devconfig *it)
s->range_table = &range_digital;
s->io_bits = 0xf; /* all bits output */
- s->insn_config = this_board->i_hwdrv_InsnConfigDigitalOutput; /* for digital output memory.. */
- s->insn_write =
- this_board->i_hwdrv_InsnWriteDigitalOutput;
- s->insn_bits =
- this_board->i_hwdrv_InsnBitsDigitalOutput;
- s->insn_read =
- this_board->i_hwdrv_InsnReadDigitalOutput;
+ /* insn_config - for digital output memory */
+ s->insn_config = this_board->do_config;
+ s->insn_write = this_board->do_write;
+ s->insn_bits = this_board->do_bits;
+ s->insn_read = this_board->do_read;
} else {
s->type = COMEDI_SUBD_UNUSED;
}
@@ -2907,10 +1769,10 @@ static int i_ADDI_Attach(struct comedi_device *dev, struct comedi_devconfig *it)
s->len_chanlist = 1;
s->range_table = &range_digital;
- s->insn_write = this_board->i_hwdrv_InsnWriteTimer;
- s->insn_read = this_board->i_hwdrv_InsnReadTimer;
- s->insn_config = this_board->i_hwdrv_InsnConfigTimer;
- s->insn_bits = this_board->i_hwdrv_InsnBitsTimer;
+ s->insn_write = this_board->timer_write;
+ s->insn_read = this_board->timer_read;
+ s->insn_config = this_board->timer_config;
+ s->insn_bits = this_board->timer_bits;
} else {
s->type = COMEDI_SUBD_UNUSED;
}
@@ -2926,10 +1788,10 @@ static int i_ADDI_Attach(struct comedi_device *dev, struct comedi_devconfig *it)
s->io_bits = 0; /* all bits input */
s->len_chanlist = this_board->i_NbrTTLChannel;
s->range_table = &range_digital;
- s->insn_config = this_board->i_hwdr_ConfigInitTTLIO;
- s->insn_bits = this_board->i_hwdr_ReadTTLIOBits;
- s->insn_read = this_board->i_hwdr_ReadTTLIOAllPortValue;
- s->insn_write = this_board->i_hwdr_WriteTTLIOChlOnOff;
+ s->insn_config = this_board->ttl_config;
+ s->insn_bits = this_board->ttl_bits;
+ s->insn_read = this_board->ttl_read;
+ s->insn_write = this_board->ttl_write;
} else {
s->type = COMEDI_SUBD_UNUSED;
}
@@ -2953,50 +1815,22 @@ static int i_ADDI_Attach(struct comedi_device *dev, struct comedi_devconfig *it)
return 0;
}
-/*
-+----------------------------------------------------------------------------+
-| Function name : static int i_ADDI_Detach(struct comedi_device *dev) |
-| |
-| |
-+----------------------------------------------------------------------------+
-| Task : Deallocates resources of the addi_common driver |
-| Free the DMA buffers, unregister irq. |
-| |
-+----------------------------------------------------------------------------+
-| Input Parameters : struct comedi_device *dev |
-| |
-| |
-+----------------------------------------------------------------------------+
-| Return Value : 0 |
-| |
-+----------------------------------------------------------------------------+
-*/
-
-static int i_ADDI_Detach(struct comedi_device *dev)
+static void i_ADDI_Detach(struct comedi_device *dev)
{
-
if (dev->private) {
- if (devpriv->b_ValidDriver) {
+ if (devpriv->b_ValidDriver)
i_ADDI_Reset(dev);
- }
-
- if (dev->irq) {
+ if (dev->irq)
free_irq(dev->irq, dev);
- }
-
- if ((this_board->pc_EepromChip == NULL)
- || (strcmp(this_board->pc_EepromChip,
- ADDIDATA_9054) != 0)) {
- if (devpriv->allocated) {
+ if ((this_board->pc_EepromChip == NULL) ||
+ (strcmp(this_board->pc_EepromChip, ADDIDATA_9054) != 0)) {
+ if (devpriv->allocated)
i_pci_card_free(devpriv->amcc);
- }
-
if (devpriv->ul_DmaBufferVirtual[0]) {
free_pages((unsigned long)devpriv->
ul_DmaBufferVirtual[0],
devpriv->ui_DmaBufferPages[0]);
}
-
if (devpriv->ul_DmaBufferVirtual[1]) {
free_pages((unsigned long)devpriv->
ul_DmaBufferVirtual[1],
@@ -3004,20 +1838,14 @@ static int i_ADDI_Detach(struct comedi_device *dev)
}
} else {
iounmap(devpriv->dw_AiBase);
-
- if (devpriv->allocated) {
+ if (devpriv->allocated)
i_pci_card_free(devpriv->amcc);
- }
}
-
if (pci_list_builded) {
- /* v_pci_card_list_cleanup(PCI_VENDOR_ID_AMCC); */
v_pci_card_list_cleanup(this_board->i_VendorId);
pci_list_builded = 0;
}
}
-
- return 0;
}
/*
@@ -3041,7 +1869,7 @@ static int i_ADDI_Detach(struct comedi_device *dev)
static int i_ADDI_Reset(struct comedi_device *dev)
{
- this_board->i_hwdrv_Reset(dev);
+ this_board->reset(dev);
return 0;
}
@@ -3067,7 +1895,7 @@ static int i_ADDI_Reset(struct comedi_device *dev)
static irqreturn_t v_ADDI_Interrupt(int irq, void *d)
{
struct comedi_device *dev = d;
- this_board->v_hwdrv_Interrupt(irq, d);
+ this_board->interrupt(irq, d);
return IRQ_RETVAL(1);
}
diff --git a/drivers/staging/comedi/drivers/addi-data/addi_common.h b/drivers/staging/comedi/drivers/addi-data/addi_common.h
index c6980b7dfea0..b7bbb7164f58 100644
--- a/drivers/staging/comedi/drivers/addi-data/addi_common.h
+++ b/drivers/staging/comedi/drivers/addi-data/addi_common.h
@@ -85,7 +85,6 @@ struct addi_board {
int i_DoMaxdata; /* data to set all channels high */
int i_NbrTTLChannel; /* Number of TTL channels */
- const struct comedi_lrange *pr_TTLRangelist; /* rangelist for TTL */
int i_Dma; /* dma present or not */
int i_Timer; /* timer subdevice present or not */
@@ -94,111 +93,72 @@ struct addi_board {
unsigned int ui_MinDelaytimeNs; /* Minimum Delay in Nano secs */
/* interrupt and reset */
- void (*v_hwdrv_Interrupt)(int irq, void *d);
- int (*i_hwdrv_Reset)(struct comedi_device *dev);
+ void (*interrupt)(int irq, void *d);
+ int (*reset)(struct comedi_device *);
/* Subdevice functions */
/* ANALOG INPUT */
- int (*i_hwdrv_InsnConfigAnalogInput)(struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_insn *insn,
- unsigned int *data);
- int (*i_hwdrv_InsnReadAnalogInput)(struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_insn *insn,
- unsigned int *data);
- int (*i_hwdrv_InsnWriteAnalogInput)(struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_insn *insn,
- unsigned int *data);
- int (*i_hwdrv_InsnBitsAnalogInput)(struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_insn *insn,
- unsigned int *data);
- int (*i_hwdrv_CommandTestAnalogInput)(struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_cmd *cmd);
- int (*i_hwdrv_CommandAnalogInput)(struct comedi_device *dev,
- struct comedi_subdevice *s);
- int (*i_hwdrv_CancelAnalogInput)(struct comedi_device *dev,
- struct comedi_subdevice *s);
+ int (*ai_config)(struct comedi_device *, struct comedi_subdevice *,
+ struct comedi_insn *, unsigned int *);
+ int (*ai_read)(struct comedi_device *, struct comedi_subdevice *,
+ struct comedi_insn *, unsigned int *);
+ int (*ai_write)(struct comedi_device *, struct comedi_subdevice *,
+ struct comedi_insn *, unsigned int *);
+ int (*ai_bits)(struct comedi_device *, struct comedi_subdevice *,
+ struct comedi_insn *, unsigned int *);
+ int (*ai_cmdtest)(struct comedi_device *, struct comedi_subdevice *,
+ struct comedi_cmd *);
+ int (*ai_cmd)(struct comedi_device *, struct comedi_subdevice *);
+ int (*ai_cancel)(struct comedi_device *, struct comedi_subdevice *);
/* Analog Output */
- int (*i_hwdrv_InsnConfigAnalogOutput)(struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_insn *insn,
- unsigned int *data);
- int (*i_hwdrv_InsnWriteAnalogOutput)(struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_insn *insn,
- unsigned int *data);
- int (*i_hwdrv_InsnBitsAnalogOutput)(struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_insn *insn,
- unsigned int *data);
+ int (*ao_config)(struct comedi_device *, struct comedi_subdevice *,
+ struct comedi_insn *, unsigned int *);
+ int (*ao_write)(struct comedi_device *, struct comedi_subdevice *,
+ struct comedi_insn *, unsigned int *);
+ int (*ao_bits)(struct comedi_device *, struct comedi_subdevice *,
+ struct comedi_insn *, unsigned int *);
/* Digital Input */
- int (*i_hwdrv_InsnConfigDigitalInput) (struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_insn *insn,
- unsigned int *data);
- int (*i_hwdrv_InsnReadDigitalInput) (struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_insn *insn,
- unsigned int *data);
- int (*i_hwdrv_InsnWriteDigitalInput) (struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_insn *insn,
- unsigned int *data);
- int (*i_hwdrv_InsnBitsDigitalInput) (struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_insn *insn,
- unsigned int *data);
+ int (*di_config)(struct comedi_device *, struct comedi_subdevice *,
+ struct comedi_insn *, unsigned int *);
+ int (*di_read)(struct comedi_device *, struct comedi_subdevice *,
+ struct comedi_insn *, unsigned int *);
+ int (*di_write)(struct comedi_device *, struct comedi_subdevice *,
+ struct comedi_insn *, unsigned int *);
+ int (*di_bits)(struct comedi_device *, struct comedi_subdevice *,
+ struct comedi_insn *, unsigned int *);
/* Digital Output */
- int (*i_hwdrv_InsnConfigDigitalOutput)(struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_insn *insn,
- unsigned int *data);
- int (*i_hwdrv_InsnWriteDigitalOutput)(struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_insn *insn,
- unsigned int *data);
- int (*i_hwdrv_InsnBitsDigitalOutput)(struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_insn *insn,
- unsigned int *data);
- int (*i_hwdrv_InsnReadDigitalOutput)(struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_insn *insn,
- unsigned int *data);
+ int (*do_config)(struct comedi_device *, struct comedi_subdevice *,
+ struct comedi_insn *, unsigned int *);
+ int (*do_write)(struct comedi_device *, struct comedi_subdevice *,
+ struct comedi_insn *, unsigned int *);
+ int (*do_bits)(struct comedi_device *, struct comedi_subdevice *,
+ struct comedi_insn *, unsigned int *);
+ int (*do_read)(struct comedi_device *, struct comedi_subdevice *,
+ struct comedi_insn *, unsigned int *);
/* TIMER */
- int (*i_hwdrv_InsnConfigTimer)(struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data);
- int (*i_hwdrv_InsnWriteTimer)(struct comedi_device *dev,
- struct comedi_subdevice *s, struct comedi_insn *insn,
- unsigned int *data);
- int (*i_hwdrv_InsnReadTimer)(struct comedi_device *dev, struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data);
- int (*i_hwdrv_InsnBitsTimer)(struct comedi_device *dev, struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data);
+ int (*timer_config)(struct comedi_device *, struct comedi_subdevice *,
+ struct comedi_insn *, unsigned int *);
+ int (*timer_write)(struct comedi_device *, struct comedi_subdevice *,
+ struct comedi_insn *, unsigned int *);
+ int (*timer_read)(struct comedi_device *, struct comedi_subdevice *,
+ struct comedi_insn *, unsigned int *);
+ int (*timer_bits)(struct comedi_device *, struct comedi_subdevice *,
+ struct comedi_insn *, unsigned int *);
/* TTL IO */
- int (*i_hwdr_ConfigInitTTLIO)(struct comedi_device *dev,
- struct comedi_subdevice *s, struct comedi_insn *insn,
- unsigned int *data);
- int (*i_hwdr_ReadTTLIOBits)(struct comedi_device *dev, struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data);
- int (*i_hwdr_ReadTTLIOAllPortValue)(struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_insn *insn,
- unsigned int *data);
- int (*i_hwdr_WriteTTLIOChlOnOff)(struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data);
+ int (*ttl_config)(struct comedi_device *, struct comedi_subdevice *,
+ struct comedi_insn *, unsigned int *);
+ int (*ttl_bits)(struct comedi_device *, struct comedi_subdevice *,
+ struct comedi_insn *, unsigned int *);
+ int (*ttl_read)(struct comedi_device *, struct comedi_subdevice *,
+ struct comedi_insn *, unsigned int *);
+ int (*ttl_write)(struct comedi_device *, struct comedi_subdevice *,
+ struct comedi_insn *, unsigned int *);
};
/* MODULE INFO STRUCTURE */
@@ -455,7 +415,7 @@ static unsigned short pci_list_builded; /* set to 1 when list of card is known *
/* Function declarations */
static int i_ADDI_Attach(struct comedi_device *dev, struct comedi_devconfig *it);
-static int i_ADDI_Detach(struct comedi_device *dev);
+static void i_ADDI_Detach(struct comedi_device *dev);
static int i_ADDI_Reset(struct comedi_device *dev);
static irqreturn_t v_ADDI_Interrupt(int irq, void *d);
diff --git a/drivers/staging/comedi/drivers/addi-data/amcc_s5933_58.h b/drivers/staging/comedi/drivers/addi-data/amcc_s5933_58.h
index 349e93c23e91..c26c28c31b97 100644
--- a/drivers/staging/comedi/drivers/addi-data/amcc_s5933_58.h
+++ b/drivers/staging/comedi/drivers/addi-data/amcc_s5933_58.h
@@ -23,10 +23,6 @@
#include <linux/pci.h>
#include "../../comedidev.h"
-#ifdef PCI_SUPPORT_VER1
-#error Sorry, no support for 2.1.55 and older! :-((((
-#endif
-
/***********Added by sarath for compatibility with APCI3120
*************************/
diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_APCI1710.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_APCI1710.c
index a76ed2553fb4..595238feaf42 100644
--- a/drivers/staging/comedi/drivers/addi-data/hwdrv_APCI1710.c
+++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_APCI1710.c
@@ -62,9 +62,8 @@ void i_ADDI_AttachPCI1710(struct comedi_device *dev)
int ret = 0;
int n_subdevices = 9;
- /* Update-0.7.57->0.7.68dev->n_subdevices = 9; */
- ret = alloc_subdevices(dev, n_subdevices);
- if (ret < 0)
+ ret = comedi_alloc_subdevices(dev, n_subdevices);
+ if (ret)
return;
/* Allocate and Initialise Timer Subdevice Structures */
diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci16xx.h b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci16xx.h
index 5bf91e13a035..a12df4bc88ac 100644
--- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci16xx.h
+++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci16xx.h
@@ -41,21 +41,6 @@
#ifdef __KERNEL__
-static const struct comedi_lrange range_apci16xx_ttl = { 12,
- {BIP_RANGE(1),
- BIP_RANGE(1),
- BIP_RANGE(1),
- BIP_RANGE(1),
- BIP_RANGE(1),
- BIP_RANGE(1),
- BIP_RANGE(1),
- BIP_RANGE(1),
- BIP_RANGE(1),
- BIP_RANGE(1),
- BIP_RANGE(1),
- BIP_RANGE(1)}
-};
-
/*
+----------------------------------------------------------------------------+
| TTL INISIALISATION FUNCTION |
diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
index e886ced4978f..ffe390c6da83 100644
--- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
+++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
@@ -156,7 +156,7 @@ int i_APCI3120_InsnReadAnalogInput(struct comedi_device *dev, struct comedi_subd
} else
us_ConvertTiming = (unsigned short) (devpriv->ui_EocEosConversionTime / 1000); /* nano to useconds */
- /* this_board->i_hwdrv_InsnReadAnalogInput(dev,us_ConvertTiming,insn->n,&insn->chanspec,data,insn->unused[0]); */
+ /* this_board->ai_read(dev,us_ConvertTiming,insn->n,&insn->chanspec,data,insn->unused[0]); */
/* Clear software registers */
devpriv->b_TimerSelectMode = 0;
@@ -670,7 +670,7 @@ int i_APCI3120_CommandAnalogInput(struct comedi_device *dev, struct comedi_subde
/* mode 1 */
devpriv->ui_AiTimer0 = cmd->convert_arg; /* timer constant in nano seconds */
- /* return this_board->i_hwdrv_CommandAnalogInput(1,dev,s); */
+ /* return this_board->ai_cmd(1,dev,s); */
return i_APCI3120_CyclicAnalogInput(1, dev, s);
}
@@ -680,7 +680,7 @@ int i_APCI3120_CommandAnalogInput(struct comedi_device *dev, struct comedi_subde
/* mode 2 */
devpriv->ui_AiTimer1 = cmd->scan_begin_arg;
devpriv->ui_AiTimer0 = cmd->convert_arg; /* variable changed timer2 to timer0 */
- /* return this_board->i_hwdrv_CommandAnalogInput(2,dev,s); */
+ /* return this_board->ai_cmd(2,dev,s); */
return i_APCI3120_CyclicAnalogInput(2, dev, s);
}
return -1;
@@ -1922,7 +1922,7 @@ int i_APCI3120_InsnConfigTimer(struct comedi_device *dev, struct comedi_subdevic
ui_Timervalue2 = data[1] / 1000; /* convert nano seconds to u seconds */
- /* this_board->i_hwdrv_InsnConfigTimer(dev, ui_Timervalue2,(unsigned char)data[0]); */
+ /* this_board->timer_config(dev, ui_Timervalue2,(unsigned char)data[0]); */
us_TmpValue = (unsigned short) inw(devpriv->iobase + APCI3120_RD_STATUS);
/*
@@ -2092,7 +2092,7 @@ int i_APCI3120_InsnWriteTimer(struct comedi_device *dev, struct comedi_subdevice
ui_Timervalue2 = 0;
}
- /* this_board->i_hwdrv_InsnWriteTimer(dev,data[0],ui_Timervalue2); */
+ /* this_board->timer_write(dev,data[0],ui_Timervalue2); */
switch (data[0]) {
case APCI3120_START:
@@ -2260,7 +2260,7 @@ int i_APCI3120_InsnReadTimer(struct comedi_device *dev, struct comedi_subdevice
comedi_error(dev, "\nread:timer2 not configured ");
}
- /* this_board->i_hwdrv_InsnReadTimer(dev,data); */
+ /* this_board->timer_read(dev,data); */
if (devpriv->b_Timer2Mode == APCI3120_TIMER) {
/* Read the LOW unsigned short of Timer 2 register */
@@ -2331,7 +2331,7 @@ int i_APCI3120_InsnReadDigitalInput(struct comedi_device *dev,
ui_Chan = CR_CHAN(insn->chanspec); /* channel specified */
- /* this_board->i_hwdrv_InsnReadDigitalInput(dev,ui_Chan,data); */
+ /* this_board->di_read(dev,ui_Chan,data); */
if (ui_Chan <= 3) {
ui_TmpValue = (unsigned int) inw(devpriv->iobase + APCI3120_RD_STATUS);
@@ -2379,7 +2379,7 @@ int i_APCI3120_InsnBitsDigitalInput(struct comedi_device *dev, struct comedi_sub
*****/
*data = (ui_TmpValue >> 8) & 0xf;
- /* this_board->i_hwdrv_InsnBitsDigitalInput(dev,data); */
+ /* this_board->di_bits(dev,data); */
return insn->n;
}
@@ -2595,7 +2595,7 @@ int i_APCI3120_InsnWriteAnalogOutput(struct comedi_device *dev,
ui_Range = CR_RANGE(insn->chanspec);
ui_Channel = CR_CHAN(insn->chanspec);
- /* this_board->i_hwdrv_InsnWriteAnalogOutput(dev, ui_Range, ui_Channel,data[0]); */
+ /* this_board->ao_write(dev, ui_Range, ui_Channel,data[0]); */
if (ui_Range) { /* if 1 then unipolar */
if (data[0] != 0)
diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3xxx.h b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3xxx.h
index cce9e12e820f..e10b7e510335 100644
--- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3xxx.h
+++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3xxx.h
@@ -42,20 +42,6 @@ static const struct comedi_lrange range_apci3XXX_ai = { 8, {BIP_RANGE(10),
UNI_RANGE(1)}
};
-static const struct comedi_lrange range_apci3XXX_ttl = { 12, {BIP_RANGE(1),
- BIP_RANGE(1),
- BIP_RANGE(1),
- BIP_RANGE(1),
- BIP_RANGE(1),
- BIP_RANGE(1),
- BIP_RANGE(1),
- BIP_RANGE(1),
- BIP_RANGE(1),
- BIP_RANGE(1),
- BIP_RANGE(1),
- BIP_RANGE(1)}
-};
-
static const struct comedi_lrange range_apci3XXX_ao = { 2, {BIP_RANGE(10),
UNI_RANGE(10)}
};
diff --git a/drivers/staging/comedi/drivers/adl_pci6208.c b/drivers/staging/comedi/drivers/adl_pci6208.c
index 4fc9e8520217..3bec0f6e4a8c 100644
--- a/drivers/staging/comedi/drivers/adl_pci6208.c
+++ b/drivers/staging/comedi/drivers/adl_pci6208.c
@@ -41,406 +41,264 @@ References:
- adl_pci9111.c copied the entire pci setup section
- adl_pci9118.c
*/
+
+#include "../comedidev.h"
+
/*
- * These headers should be followed by a blank line, and any comments
- * you wish to say about the driver. The comment area is the place
- * to put any known bugs, limitations, unsupported features, supported
- * command triggers, whether or not commands are supported on particular
- * subdevices, etc.
- *
- * Somewhere in the comment should be information about configuration
- * options that are used with comedi_config.
+ * PCI-6208/6216-GL register map
*/
-#include "../comedidev.h"
-#include "comedi_pci.h"
+#define PCI6208_AO_CONTROL(x) (0x00 + (2 * (x)))
+#define PCI6208_AO_STATUS 0x00
+#define PCI6208_AO_STATUS_DATA_SEND (1 << 0)
+#define PCI6208_DIO 0x40
+#define PCI6208_DIO_DO_MASK (0x0f)
+#define PCI6208_DIO_DO_SHIFT (0)
+#define PCI6208_DIO_DI_MASK (0xf0)
+#define PCI6208_DIO_DI_SHIFT (4)
-#define PCI6208_DRIVER_NAME "adl_pci6208"
+#define PCI6208_MAX_AO_CHANNELS 8
-/* Board descriptions */
struct pci6208_board {
const char *name;
- unsigned short dev_id; /* `lspci` will show you this */
+ unsigned short dev_id;
int ao_chans;
- /* int ao_bits; */
};
static const struct pci6208_board pci6208_boards[] = {
- /*{
- .name = "pci6208v",
- .dev_id = 0x6208, // not sure
- .ao_chans = 8
- // , .ao_bits = 16
- },
- {
- .name = "pci6216v",
- .dev_id = 0x6208, // not sure
- .ao_chans = 16
- // , .ao_bits = 16
- }, */
{
- .name = "pci6208a",
- .dev_id = 0x6208,
- .ao_chans = 8
- /* , .ao_bits = 16 */
- }
-};
-
-/* This is used by modprobe to translate PCI IDs to drivers. Should
- * only be used for PCI and ISA-PnP devices */
-static DEFINE_PCI_DEVICE_TABLE(pci6208_pci_table) = {
- /* { PCI_VENDOR_ID_ADLINK, 0x6208, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, */
- /* { PCI_VENDOR_ID_ADLINK, 0x6208, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, */
- { PCI_DEVICE(PCI_VENDOR_ID_ADLINK, 0x6208) },
- { 0 }
+ .name = "pci6208a",
+ .dev_id = 0x6208,
+ .ao_chans = 8,
+ },
};
-MODULE_DEVICE_TABLE(pci, pci6208_pci_table);
-
-/* Will be initialized in pci6208_find device(). */
-#define thisboard ((const struct pci6208_board *)dev->board_ptr)
-
struct pci6208_private {
- int data;
- struct pci_dev *pci_dev; /* for a PCI device */
- unsigned int ao_readback[2]; /* Used for AO readback */
+ unsigned int ao_readback[PCI6208_MAX_AO_CHANNELS];
};
-#define devpriv ((struct pci6208_private *)dev->private)
-
-static int pci6208_attach(struct comedi_device *dev,
- struct comedi_devconfig *it);
-static int pci6208_detach(struct comedi_device *dev);
-
-static struct comedi_driver driver_pci6208 = {
- .driver_name = PCI6208_DRIVER_NAME,
- .module = THIS_MODULE,
- .attach = pci6208_attach,
- .detach = pci6208_detach,
-};
-
-static int __devinit driver_pci6208_pci_probe(struct pci_dev *dev,
- const struct pci_device_id *ent)
-{
- return comedi_pci_auto_config(dev, driver_pci6208.driver_name);
-}
-
-static void __devexit driver_pci6208_pci_remove(struct pci_dev *dev)
+static int pci6208_ao_winsn(struct comedi_device *dev,
+ struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
- comedi_pci_auto_unconfig(dev);
-}
-
-static struct pci_driver driver_pci6208_pci_driver = {
- .id_table = pci6208_pci_table,
- .probe = &driver_pci6208_pci_probe,
- .remove = __devexit_p(&driver_pci6208_pci_remove)
-};
+ struct pci6208_private *devpriv = dev->private;
+ int chan = CR_CHAN(insn->chanspec);
+ unsigned long invert = 1 << (16 - 1);
+ unsigned long value = 0;
+ unsigned short status;
+ int i;
-static int __init driver_pci6208_init_module(void)
-{
- int retval;
+ for (i = 0; i < insn->n; i++) {
+ value = data[i] ^ invert;
- retval = comedi_driver_register(&driver_pci6208);
- if (retval < 0)
- return retval;
+ do {
+ status = inw(dev->iobase + PCI6208_AO_STATUS);
+ } while (status & PCI6208_AO_STATUS_DATA_SEND);
- driver_pci6208_pci_driver.name = (char *)driver_pci6208.driver_name;
- return pci_register_driver(&driver_pci6208_pci_driver);
-}
+ outw(value, dev->iobase + PCI6208_AO_CONTROL(chan));
+ }
+ devpriv->ao_readback[chan] = value;
-static void __exit driver_pci6208_cleanup_module(void)
-{
- pci_unregister_driver(&driver_pci6208_pci_driver);
- comedi_driver_unregister(&driver_pci6208);
+ return insn->n;
}
-module_init(driver_pci6208_init_module);
-module_exit(driver_pci6208_cleanup_module);
-
-static int pci6208_find_device(struct comedi_device *dev, int bus, int slot);
-static int
-pci6208_pci_setup(struct pci_dev *pci_dev, unsigned long *io_base_ptr,
- int dev_minor);
-
-/*read/write functions*/
-static int pci6208_ao_winsn(struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data);
static int pci6208_ao_rinsn(struct comedi_device *dev,
struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data);
-/* static int pci6208_dio_insn_bits (struct comedi_device *dev,
- * struct comedi_subdevice *s, */
-/* struct comedi_insn *insn,unsigned int *data); */
-/* static int pci6208_dio_insn_config(struct comedi_device *dev,
- * struct comedi_subdevice *s, */
-/* struct comedi_insn *insn,unsigned int *data); */
-
-/*
- * Attach is called by the Comedi core to configure the driver
- * for a particular board. If you specified a board_name array
- * in the driver structure, dev->board_ptr contains that
- * address.
- */
-static int pci6208_attach(struct comedi_device *dev,
- struct comedi_devconfig *it)
+ struct comedi_insn *insn, unsigned int *data)
{
- struct comedi_subdevice *s;
- int retval;
- unsigned long io_base;
-
- printk(KERN_INFO "comedi%d: pci6208: ", dev->minor);
-
- retval = alloc_private(dev, sizeof(struct pci6208_private));
- if (retval < 0)
- return retval;
-
- retval = pci6208_find_device(dev, it->options[0], it->options[1]);
- if (retval < 0)
- return retval;
-
- retval = pci6208_pci_setup(devpriv->pci_dev, &io_base, dev->minor);
- if (retval < 0)
- return retval;
-
- dev->iobase = io_base;
- dev->board_name = thisboard->name;
-
-/*
- * Allocate the subdevice structures. alloc_subdevice() is a
- * convenient macro defined in comedidev.h.
- */
- if (alloc_subdevices(dev, 2) < 0)
- return -ENOMEM;
-
- s = dev->subdevices + 0;
- /* analog output subdevice */
- s->type = COMEDI_SUBD_AO;
- s->subdev_flags = SDF_WRITABLE; /* anything else to add here?? */
- s->n_chan = thisboard->ao_chans;
- s->maxdata = 0xffff; /* 16-bit DAC */
- s->range_table = &range_bipolar10; /* this needs to be checked. */
- s->insn_write = pci6208_ao_winsn;
- s->insn_read = pci6208_ao_rinsn;
-
- /* s=dev->subdevices+1; */
- /* digital i/o subdevice */
- /* s->type=COMEDI_SUBD_DIO; */
- /* s->subdev_flags=SDF_READABLE|SDF_WRITABLE; */
- /* s->n_chan=16; */
- /* s->maxdata=1; */
- /* s->range_table=&range_digital; */
- /* s->insn_bits = pci6208_dio_insn_bits; */
- /* s->insn_config = pci6208_dio_insn_config; */
+ struct pci6208_private *devpriv = dev->private;
+ int chan = CR_CHAN(insn->chanspec);
+ int i;
- printk(KERN_INFO "attached\n");
+ for (i = 0; i < insn->n; i++)
+ data[i] = devpriv->ao_readback[chan];
- return 1;
+ return insn->n;
}
-/*
- * _detach is called to deconfigure a device. It should deallocate
- * resources.
- * This function is also called when _attach() fails, so it should be
- * careful not to release resources that were not necessarily
- * allocated by _attach(). dev->private and dev->subdevices are
- * deallocated automatically by the core.
- */
-static int pci6208_detach(struct comedi_device *dev)
+static int pci6208_dio_insn_bits(struct comedi_device *dev,
+ struct comedi_subdevice *s,
+ struct comedi_insn *insn,
+ unsigned int *data)
{
- printk(KERN_INFO "comedi%d: pci6208: remove\n", dev->minor);
+ unsigned int mask = data[0] & PCI6208_DIO_DO_MASK;
+ unsigned int bits = data[1];
- if (devpriv && devpriv->pci_dev) {
- if (dev->iobase)
- comedi_pci_disable(devpriv->pci_dev);
- pci_dev_put(devpriv->pci_dev);
- }
+ if (mask) {
+ s->state &= ~mask;
+ s->state |= bits & mask;
- return 0;
-}
-
-static int pci6208_ao_winsn(struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data)
-{
- int i = 0, Data_Read;
- unsigned short chan = CR_CHAN(insn->chanspec);
- unsigned long invert = 1 << (16 - 1);
- unsigned long out_value;
- /* Writing a list of values to an AO channel is probably not
- * very useful, but that's how the interface is defined. */
- for (i = 0; i < insn->n; i++) {
- out_value = data[i] ^ invert;
- /* a typical programming sequence */
- do {
- Data_Read = (inw(dev->iobase) & 1);
- } while (Data_Read);
- outw(out_value, dev->iobase + (0x02 * chan));
- devpriv->ao_readback[chan] = out_value;
+ outw(s->state, dev->iobase + PCI6208_DIO);
}
- /* return the number of samples read/written */
- return i;
+ s->state = inw(dev->iobase + PCI6208_DIO);
+ data[1] = s->state;
+
+ return insn->n;
}
-/* AO subdevices should have a read insn as well as a write insn.
- * Usually this means copying a value stored in devpriv. */
-static int pci6208_ao_rinsn(struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data)
+static int pci6208_dio_insn_config(struct comedi_device *dev,
+ struct comedi_subdevice *s,
+ struct comedi_insn *insn,
+ unsigned int *data)
{
- int i;
int chan = CR_CHAN(insn->chanspec);
+ unsigned int mask = 1 << chan;
+
+ switch (data[0]) {
+ case INSN_CONFIG_DIO_QUERY:
+ data[1] = (s->io_bits & mask) ? COMEDI_OUTPUT : COMEDI_INPUT;
+ break;
+ default:
+ return -EINVAL;
+ }
- for (i = 0; i < insn->n; i++)
- data[i] = devpriv->ao_readback[chan];
-
- return i;
+ return insn->n;
}
-/* DIO devices are slightly special. Although it is possible to
- * implement the insn_read/insn_write interface, it is much more
- * useful to applications if you implement the insn_bits interface.
- * This allows packed reading/writing of the DIO channels. The
- * comedi core can convert between insn_bits and insn_read/write */
-/* static int pci6208_dio_insn_bits(struct comedi_device *dev,
- * struct comedi_subdevice *s, */
-/* struct comedi_insn *insn,unsigned int *data) */
-/* { */
-/* if(insn->n!=2)return -EINVAL; */
-
- /* The insn data is a mask in data[0] and the new data
- * in data[1], each channel cooresponding to a bit. */
-/* if(data[0]){ */
-/* s->state &= ~data[0]; */
-/* s->state |= data[0]&data[1]; */
- /* Write out the new digital output lines */
- /* outw(s->state,dev->iobase + SKEL_DIO); */
-/* } */
-
- /* on return, data[1] contains the value of the digital
- * input and output lines. */
- /* data[1]=inw(dev->iobase + SKEL_DIO); */
- /* or we could just return the software copy of the output values if
- * it was a purely digital output subdevice */
- /* data[1]=s->state; */
-
-/* return 2; */
-/* } */
-
-/* static int pci6208_dio_insn_config(struct comedi_device *dev,
- * struct comedi_subdevice *s, */
-/* struct comedi_insn *insn,unsigned int *data) */
-/* { */
-/* int chan=CR_CHAN(insn->chanspec); */
-
- /* The input or output configuration of each digital line is
- * configured by a special insn_config instruction. chanspec
- * contains the channel to be changed, and data[0] contains the
- * value COMEDI_INPUT or COMEDI_OUTPUT. */
-
-/* if(data[0]==COMEDI_OUTPUT){ */
-/* s->io_bits |= 1<<chan; */
-/* }else{ */
-/* s->io_bits &= ~(1<<chan); */
-/* } */
- /* outw(s->io_bits,dev->iobase + SKEL_DIO_CONFIG); */
-
-/* return 1; */
-/* } */
-
-static int pci6208_find_device(struct comedi_device *dev, int bus, int slot)
+static struct pci_dev *pci6208_find_device(struct comedi_device *dev,
+ struct comedi_devconfig *it)
{
+ const struct pci6208_board *thisboard;
struct pci_dev *pci_dev = NULL;
+ int bus = it->options[0];
+ int slot = it->options[1];
int i;
for_each_pci_dev(pci_dev) {
- if (pci_dev->vendor == PCI_VENDOR_ID_ADLINK) {
- for (i = 0; i < ARRAY_SIZE(pci6208_boards); i++) {
- if (pci6208_boards[i].dev_id ==
- pci_dev->device) {
- /*
- * was a particular bus/slot requested?
- */
- if ((bus != 0) || (slot != 0)) {
- /*
- * are we on the
- * wrong bus/slot?
- */
- if (pci_dev->bus->number
- != bus ||
- PCI_SLOT(pci_dev->devfn)
- != slot) {
- continue;
- }
- }
- dev->board_ptr = pci6208_boards + i;
- goto found;
- }
+ if (pci_dev->vendor != PCI_VENDOR_ID_ADLINK)
+ continue;
+ for (i = 0; i < ARRAY_SIZE(pci6208_boards); i++) {
+ thisboard = &pci6208_boards[i];
+ if (thisboard->dev_id != pci_dev->device)
+ continue;
+ /* was a particular bus/slot requested? */
+ if (bus || slot) {
+ /* are we on the wrong bus/slot? */
+ if (pci_dev->bus->number != bus ||
+ PCI_SLOT(pci_dev->devfn) != slot)
+ continue;
}
+ dev_dbg(dev->class_dev,
+ "Found %s on bus %d, slot, %d, irq=%d\n",
+ thisboard->name,
+ pci_dev->bus->number,
+ PCI_SLOT(pci_dev->devfn),
+ pci_dev->irq);
+ dev->board_ptr = thisboard;
+ return pci_dev;
}
}
+ dev_err(dev->class_dev,
+ "No supported board found! (req. bus %d, slot %d)\n",
+ bus, slot);
+ return NULL;
+}
- printk(KERN_ERR "comedi%d: no supported board found! "
- "(req. bus/slot : %d/%d)\n",
- dev->minor, bus, slot);
- return -EIO;
+static int pci6208_attach(struct comedi_device *dev,
+ struct comedi_devconfig *it)
+{
+ const struct pci6208_board *thisboard;
+ struct pci6208_private *devpriv;
+ struct pci_dev *pcidev;
+ struct comedi_subdevice *s;
+ int ret;
+
+ ret = alloc_private(dev, sizeof(*devpriv));
+ if (ret < 0)
+ return ret;
+ devpriv = dev->private;
+
+ pcidev = pci6208_find_device(dev, it);
+ if (!pcidev)
+ return -EIO;
+ comedi_set_hw_dev(dev, &pcidev->dev);
+ thisboard = comedi_board(dev);
+
+ dev->board_name = thisboard->name;
-found:
- printk("comedi%d: found %s (b:s:f=%d:%d:%d) , irq=%d\n",
- dev->minor,
- pci6208_boards[i].name,
- pci_dev->bus->number,
- PCI_SLOT(pci_dev->devfn),
- PCI_FUNC(pci_dev->devfn), pci_dev->irq);
+ ret = comedi_pci_enable(pcidev, dev->driver->driver_name);
+ if (ret) {
+ dev_err(dev->class_dev,
+ "Failed to enable PCI device and request regions\n");
+ return ret;
+ }
+ dev->iobase = pci_resource_start(pcidev, 2);
- /* TODO: Warn about non-tested boards. */
- /* switch(board->device_id) */
- /* { */
- /* }; */
+ ret = comedi_alloc_subdevices(dev, 2);
+ if (ret)
+ return ret;
- devpriv->pci_dev = pci_dev;
+ s = dev->subdevices + 0;
+ /* analog output subdevice */
+ s->type = COMEDI_SUBD_AO;
+ s->subdev_flags = SDF_WRITABLE;
+ s->n_chan = thisboard->ao_chans;
+ s->maxdata = 0xffff;
+ s->range_table = &range_bipolar10;
+ s->insn_write = pci6208_ao_winsn;
+ s->insn_read = pci6208_ao_rinsn;
+
+ s = dev->subdevices + 1;
+ /* digital i/o subdevice */
+ s->type = COMEDI_SUBD_DIO;
+ s->subdev_flags = SDF_READABLE | SDF_WRITABLE;
+ s->n_chan = 8;
+ s->maxdata = 1;
+ s->range_table = &range_digital;
+ s->insn_bits = pci6208_dio_insn_bits;
+ s->insn_config = pci6208_dio_insn_config;
+
+ s->io_bits = 0x0f;
+ s->state = inw(dev->iobase + PCI6208_DIO);
+
+ dev_info(dev->class_dev, "%s: %s, I/O base=0x%04lx\n",
+ dev->driver->driver_name, dev->board_name, dev->iobase);
return 0;
}
-static int
-pci6208_pci_setup(struct pci_dev *pci_dev, unsigned long *io_base_ptr,
- int dev_minor)
+static void pci6208_detach(struct comedi_device *dev)
{
- unsigned long io_base, io_range, lcr_io_base, lcr_io_range;
+ struct pci_dev *pcidev = comedi_to_pci_dev(dev);
- /* Enable PCI device and request regions */
- if (comedi_pci_enable(pci_dev, PCI6208_DRIVER_NAME) < 0) {
- printk(KERN_ERR "comedi%d: Failed to enable PCI device "
- "and request regions\n",
- dev_minor);
- return -EIO;
+ if (pcidev) {
+ if (dev->iobase)
+ comedi_pci_disable(pcidev);
+ pci_dev_put(pcidev);
}
- /* Read local configuration register
- * base address [PCI_BASE_ADDRESS #1].
- */
- lcr_io_base = pci_resource_start(pci_dev, 1);
- lcr_io_range = pci_resource_len(pci_dev, 1);
+}
- printk(KERN_INFO "comedi%d: local config registers at address"
- " 0x%4lx [0x%4lx]\n",
- dev_minor, lcr_io_base, lcr_io_range);
+static struct comedi_driver adl_pci6208_driver = {
+ .driver_name = "adl_pci6208",
+ .module = THIS_MODULE,
+ .attach = pci6208_attach,
+ .detach = pci6208_detach,
+};
- /* Read PCI6208 register base address [PCI_BASE_ADDRESS #2]. */
- io_base = pci_resource_start(pci_dev, 2);
- io_range = pci_resource_end(pci_dev, 2) - io_base + 1;
+static int __devinit adl_pci6208_pci_probe(struct pci_dev *dev,
+ const struct pci_device_id *ent)
+{
+ return comedi_pci_auto_config(dev, &adl_pci6208_driver);
+}
- printk("comedi%d: 6208 registers at address 0x%4lx [0x%4lx]\n",
- dev_minor, io_base, io_range);
+static void __devexit adl_pci6208_pci_remove(struct pci_dev *dev)
+{
+ comedi_pci_auto_unconfig(dev);
+}
- *io_base_ptr = io_base;
- /* devpriv->io_range = io_range; */
- /* devpriv->is_valid=0; */
- /* devpriv->lcr_io_base=lcr_io_base; */
- /* devpriv->lcr_io_range=lcr_io_range; */
+static DEFINE_PCI_DEVICE_TABLE(adl_pci6208_pci_table) = {
+ { PCI_DEVICE(PCI_VENDOR_ID_ADLINK, 0x6208) },
+ { 0 }
+};
+MODULE_DEVICE_TABLE(pci, adl_pci6208_pci_table);
- return 0;
-}
+static struct pci_driver adl_pci6208_pci_driver = {
+ .name = "adl_pci6208",
+ .id_table = adl_pci6208_pci_table,
+ .probe = adl_pci6208_pci_probe,
+ .remove = __devexit_p(adl_pci6208_pci_remove),
+};
+module_comedi_pci_driver(adl_pci6208_driver, adl_pci6208_pci_driver);
MODULE_AUTHOR("Comedi http://www.comedi.org");
MODULE_DESCRIPTION("Comedi low-level driver");
diff --git a/drivers/staging/comedi/drivers/adl_pci7230.c b/drivers/staging/comedi/drivers/adl_pci7230.c
index 20d570554fa4..7df4c960d5e4 100644
--- a/drivers/staging/comedi/drivers/adl_pci7230.c
+++ b/drivers/staging/comedi/drivers/adl_pci7230.c
@@ -36,87 +36,81 @@ Configuration Options:
#include "../comedidev.h"
#include <linux/kernel.h>
-#include "comedi_pci.h"
#define PCI7230_DI 0x00
#define PCI7230_DO 0x00
#define PCI_DEVICE_ID_PCI7230 0x7230
-static DEFINE_PCI_DEVICE_TABLE(adl_pci7230_pci_table) = {
- { PCI_DEVICE(PCI_VENDOR_ID_ADLINK, PCI_DEVICE_ID_PCI7230) },
- {0}
-};
-
-MODULE_DEVICE_TABLE(pci, adl_pci7230_pci_table);
-
-struct adl_pci7230_private {
- int data;
- struct pci_dev *pci_dev;
-};
-
-#define devpriv ((struct adl_pci7230_private *)dev->private)
+static int adl_pci7230_do_insn_bits(struct comedi_device *dev,
+ struct comedi_subdevice *s,
+ struct comedi_insn *insn,
+ unsigned int *data)
+{
+ if (data[0]) {
+ s->state &= ~data[0];
+ s->state |= (data[0] & data[1]);
-static int adl_pci7230_attach(struct comedi_device *dev,
- struct comedi_devconfig *it);
-static int adl_pci7230_detach(struct comedi_device *dev);
-static struct comedi_driver driver_adl_pci7230 = {
- .driver_name = "adl_pci7230",
- .module = THIS_MODULE,
- .attach = adl_pci7230_attach,
- .detach = adl_pci7230_detach,
-};
+ outl((s->state << 16) & 0xffffffff, dev->iobase + PCI7230_DO);
+ }
-/* Digital IO */
+ return insn->n;
+}
static int adl_pci7230_di_insn_bits(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn,
- unsigned int *data);
+ unsigned int *data)
+{
+ data[1] = inl(dev->iobase + PCI7230_DI) & 0xffffffff;
-static int adl_pci7230_do_insn_bits(struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_insn *insn,
- unsigned int *data);
+ return insn->n;
+}
-static int adl_pci7230_attach(struct comedi_device *dev,
+static struct pci_dev *adl_pci7230_find_pci(struct comedi_device *dev,
struct comedi_devconfig *it)
{
struct pci_dev *pcidev = NULL;
+ int bus = it->options[0];
+ int slot = it->options[1];
+
+ for_each_pci_dev(pcidev) {
+ if (pcidev->vendor != PCI_VENDOR_ID_ADLINK ||
+ pcidev->device != PCI_DEVICE_ID_PCI7230)
+ continue;
+ if (bus || slot) {
+ /* requested particular bus/slot */
+ if (pcidev->bus->number != bus ||
+ PCI_SLOT(pcidev->devfn) != slot)
+ continue;
+ }
+ return pcidev;
+ }
+ printk(KERN_ERR "comedi%d: no supported board found! (req. bus/slot : %d/%d)\n",
+ dev->minor, bus, slot);
+ return NULL;
+}
+
+static int adl_pci7230_attach(struct comedi_device *dev,
+ struct comedi_devconfig *it)
+{
struct comedi_subdevice *s;
- int bus, slot;
+ struct pci_dev *pcidev;
+ int ret;
printk(KERN_INFO "comedi%d: adl_pci7230\n", dev->minor);
dev->board_name = "pci7230";
- bus = it->options[0];
- slot = it->options[1];
-
- if (alloc_private(dev, sizeof(struct adl_pci7230_private)) < 0)
- return -ENOMEM;
- if (alloc_subdevices(dev, 2) < 0)
- return -ENOMEM;
+ ret = comedi_alloc_subdevices(dev, 2);
+ if (ret)
+ return ret;
- for_each_pci_dev(pcidev) {
- if (pcidev->vendor == PCI_VENDOR_ID_ADLINK &&
- pcidev->device == PCI_DEVICE_ID_PCI7230) {
- if (bus || slot) {
- /* requested particular bus/slot */
- if (pcidev->bus->number != bus ||
- PCI_SLOT(pcidev->devfn) != slot) {
- continue;
- }
- }
- devpriv->pci_dev = pcidev;
- break;
- }
- }
- if (pcidev == NULL) {
- printk(KERN_ERR "comedi%d: no supported board found! (req. bus/slot : %d/%d)\n",
- dev->minor, bus, slot);
+ pcidev = adl_pci7230_find_pci(dev, it);
+ if (!pcidev)
return -EIO;
- }
+ comedi_set_hw_dev(dev, &pcidev->dev);
+
if (comedi_pci_enable(pcidev, "adl_pci7230") < 0) {
printk(KERN_ERR "comedi%d: Failed to enable PCI device and request regions\n",
dev->minor);
@@ -148,89 +142,48 @@ static int adl_pci7230_attach(struct comedi_device *dev,
return 1;
}
-static int adl_pci7230_detach(struct comedi_device *dev)
+static void adl_pci7230_detach(struct comedi_device *dev)
{
- printk(KERN_DEBUG "comedi%d: pci7230: remove\n", dev->minor);
+ struct pci_dev *pcidev = comedi_to_pci_dev(dev);
- if (devpriv && devpriv->pci_dev) {
+ if (pcidev) {
if (dev->iobase)
- comedi_pci_disable(devpriv->pci_dev);
- pci_dev_put(devpriv->pci_dev);
+ comedi_pci_disable(pcidev);
+ pci_dev_put(pcidev);
}
-
- return 0;
}
-static int adl_pci7230_do_insn_bits(struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_insn *insn,
- unsigned int *data)
-{
- if (insn->n != 2)
- return -EINVAL;
-
- if (data[0]) {
- s->state &= ~data[0];
- s->state |= (data[0] & data[1]);
-
- outl((s->state << 16) & 0xffffffff, dev->iobase + PCI7230_DO);
- }
-
- return 2;
-}
-
-static int adl_pci7230_di_insn_bits(struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_insn *insn,
- unsigned int *data)
-{
- if (insn->n != 2)
- return -EINVAL;
-
- data[1] = inl(dev->iobase + PCI7230_DI) & 0xffffffff;
-
- return 2;
-}
+static struct comedi_driver adl_pci7230_driver = {
+ .driver_name = "adl_pci7230",
+ .module = THIS_MODULE,
+ .attach = adl_pci7230_attach,
+ .detach = adl_pci7230_detach,
+};
-static int __devinit driver_adl_pci7230_pci_probe(struct pci_dev *dev,
- const struct pci_device_id
- *ent)
+static int __devinit adl_pci7230_pci_probe(struct pci_dev *dev,
+ const struct pci_device_id *ent)
{
- return comedi_pci_auto_config(dev, driver_adl_pci7230.driver_name);
+ return comedi_pci_auto_config(dev, &adl_pci7230_driver);
}
-static void __devexit driver_adl_pci7230_pci_remove(struct pci_dev *dev)
+static void __devexit adl_pci7230_pci_remove(struct pci_dev *dev)
{
comedi_pci_auto_unconfig(dev);
}
-static struct pci_driver driver_adl_pci7230_pci_driver = {
- .id_table = adl_pci7230_pci_table,
- .probe = &driver_adl_pci7230_pci_probe,
- .remove = __devexit_p(&driver_adl_pci7230_pci_remove)
+static DEFINE_PCI_DEVICE_TABLE(adl_pci7230_pci_table) = {
+ { PCI_DEVICE(PCI_VENDOR_ID_ADLINK, PCI_DEVICE_ID_PCI7230) },
+ { 0 }
};
+MODULE_DEVICE_TABLE(pci, adl_pci7230_pci_table);
-static int __init driver_adl_pci7230_init_module(void)
-{
- int retval;
-
- retval = comedi_driver_register(&driver_adl_pci7230);
- if (retval < 0)
- return retval;
-
- driver_adl_pci7230_pci_driver.name =
- (char *)driver_adl_pci7230.driver_name;
- return pci_register_driver(&driver_adl_pci7230_pci_driver);
-}
-
-static void __exit driver_adl_pci7230_cleanup_module(void)
-{
- pci_unregister_driver(&driver_adl_pci7230_pci_driver);
- comedi_driver_unregister(&driver_adl_pci7230);
-}
-
-module_init(driver_adl_pci7230_init_module);
-module_exit(driver_adl_pci7230_cleanup_module);
+static struct pci_driver adl_pci7230_pci_driver = {
+ .name = "adl_pci7230",
+ .id_table = adl_pci7230_pci_table,
+ .probe = adl_pci7230_pci_probe,
+ .remove = __devexit_p(adl_pci7230_pci_remove),
+};
+module_comedi_pci_driver(adl_pci7230_driver, adl_pci7230_pci_driver);
MODULE_AUTHOR("Comedi http://www.comedi.org");
MODULE_DESCRIPTION("Comedi low-level driver");
diff --git a/drivers/staging/comedi/drivers/adl_pci7296.c b/drivers/staging/comedi/drivers/adl_pci7296.c
index 9a2320537bdb..19b47af9c10e 100644
--- a/drivers/staging/comedi/drivers/adl_pci7296.c
+++ b/drivers/staging/comedi/drivers/adl_pci7296.c
@@ -37,7 +37,6 @@ Configuration Options:
#include "../comedidev.h"
#include <linux/kernel.h>
-#include "comedi_pci.h"
#include "8255.h"
/* #include "8253.h" */
@@ -48,169 +47,136 @@ Configuration Options:
#define PCI_DEVICE_ID_PCI7296 0x7296
-static DEFINE_PCI_DEVICE_TABLE(adl_pci7296_pci_table) = {
- { PCI_DEVICE(PCI_VENDOR_ID_ADLINK, PCI_DEVICE_ID_PCI7296) },
- {0}
-};
-
-MODULE_DEVICE_TABLE(pci, adl_pci7296_pci_table);
-
-struct adl_pci7296_private {
- int data;
- struct pci_dev *pci_dev;
-};
-
-#define devpriv ((struct adl_pci7296_private *)dev->private)
+static struct pci_dev *adl_pci7296_find_pci(struct comedi_device *dev,
+ struct comedi_devconfig *it)
+{
+ struct pci_dev *pcidev = NULL;
+ int bus = it->options[0];
+ int slot = it->options[1];
-static int adl_pci7296_attach(struct comedi_device *dev,
- struct comedi_devconfig *it);
-static int adl_pci7296_detach(struct comedi_device *dev);
-static struct comedi_driver driver_adl_pci7296 = {
- .driver_name = "adl_pci7296",
- .module = THIS_MODULE,
- .attach = adl_pci7296_attach,
- .detach = adl_pci7296_detach,
-};
+ for_each_pci_dev(pcidev) {
+ if (pcidev->vendor != PCI_VENDOR_ID_ADLINK ||
+ pcidev->device != PCI_DEVICE_ID_PCI7296)
+ continue;
+ if (bus || slot) {
+ /* requested particular bus/slot */
+ if (pcidev->bus->number != bus ||
+ PCI_SLOT(pcidev->devfn) != slot)
+ continue;
+ }
+ return pcidev;
+ }
+ printk(KERN_ERR
+ "comedi%d: no supported board found! (req. bus/slot : %d/%d)\n",
+ dev->minor, bus, slot);
+ return NULL;
+}
static int adl_pci7296_attach(struct comedi_device *dev,
struct comedi_devconfig *it)
{
- struct pci_dev *pcidev = NULL;
+ struct pci_dev *pcidev;
struct comedi_subdevice *s;
- int bus, slot;
int ret;
printk(KERN_INFO "comedi%d: attach adl_pci7432\n", dev->minor);
dev->board_name = "pci7432";
- bus = it->options[0];
- slot = it->options[1];
- if (alloc_private(dev, sizeof(struct adl_pci7296_private)) < 0)
- return -ENOMEM;
+ ret = comedi_alloc_subdevices(dev, 4);
+ if (ret)
+ return ret;
- if (alloc_subdevices(dev, 4) < 0)
- return -ENOMEM;
+ pcidev = adl_pci7296_find_pci(dev, it);
+ if (!pcidev)
+ return -EIO;
+ comedi_set_hw_dev(dev, &pcidev->dev);
- for_each_pci_dev(pcidev) {
- if (pcidev->vendor == PCI_VENDOR_ID_ADLINK &&
- pcidev->device == PCI_DEVICE_ID_PCI7296) {
- if (bus || slot) {
- /* requested particular bus/slot */
- if (pcidev->bus->number != bus
- || PCI_SLOT(pcidev->devfn) != slot) {
- continue;
- }
- }
- devpriv->pci_dev = pcidev;
- if (comedi_pci_enable(pcidev, "adl_pci7296") < 0) {
- printk(KERN_ERR "comedi%d: Failed to enable PCI device and request regions\n",
- dev->minor);
- return -EIO;
- }
-
- dev->iobase = pci_resource_start(pcidev, 2);
- printk(KERN_INFO "comedi: base addr %4lx\n",
- dev->iobase);
-
- /* four 8255 digital io subdevices */
- s = dev->subdevices + 0;
- subdev_8255_init(dev, s, NULL,
- (unsigned long)(dev->iobase));
-
- s = dev->subdevices + 1;
- ret = subdev_8255_init(dev, s, NULL,
- (unsigned long)(dev->iobase +
- PORT2A));
- if (ret < 0)
- return ret;
-
- s = dev->subdevices + 2;
- ret = subdev_8255_init(dev, s, NULL,
- (unsigned long)(dev->iobase +
- PORT3A));
- if (ret < 0)
- return ret;
-
- s = dev->subdevices + 3;
- ret = subdev_8255_init(dev, s, NULL,
- (unsigned long)(dev->iobase +
- PORT4A));
- if (ret < 0)
- return ret;
-
- printk(KERN_DEBUG "comedi%d: adl_pci7432 attached\n",
- dev->minor);
-
- return 1;
- }
+ if (comedi_pci_enable(pcidev, "adl_pci7296") < 0) {
+ printk(KERN_ERR
+ "comedi%d: Failed to enable PCI device and request regions\n",
+ dev->minor);
+ return -EIO;
}
- printk(KERN_ERR "comedi%d: no supported board found! (req. bus/slot : %d/%d)\n",
- dev->minor, bus, slot);
- return -EIO;
+ dev->iobase = pci_resource_start(pcidev, 2);
+ printk(KERN_INFO "comedi: base addr %4lx\n", dev->iobase);
+
+ /* four 8255 digital io subdevices */
+ s = dev->subdevices + 0;
+ subdev_8255_init(dev, s, NULL, (unsigned long)(dev->iobase));
+
+ s = dev->subdevices + 1;
+ ret = subdev_8255_init(dev, s, NULL,
+ (unsigned long)(dev->iobase + PORT2A));
+ if (ret < 0)
+ return ret;
+
+ s = dev->subdevices + 2;
+ ret = subdev_8255_init(dev, s, NULL,
+ (unsigned long)(dev->iobase + PORT3A));
+ if (ret < 0)
+ return ret;
+
+ s = dev->subdevices + 3;
+ ret = subdev_8255_init(dev, s, NULL,
+ (unsigned long)(dev->iobase + PORT4A));
+ if (ret < 0)
+ return ret;
+
+ printk(KERN_DEBUG "comedi%d: adl_pci7432 attached\n", dev->minor);
+
+ return 0;
}
-static int adl_pci7296_detach(struct comedi_device *dev)
+static void adl_pci7296_detach(struct comedi_device *dev)
{
- printk(KERN_INFO "comedi%d: pci7432: remove\n", dev->minor);
+ struct pci_dev *pcidev = comedi_to_pci_dev(dev);
- if (devpriv && devpriv->pci_dev) {
+ if (pcidev) {
if (dev->iobase)
- comedi_pci_disable(devpriv->pci_dev);
- pci_dev_put(devpriv->pci_dev);
+ comedi_pci_disable(pcidev);
+ pci_dev_put(pcidev);
}
- /* detach four 8255 digital io subdevices */
if (dev->subdevices) {
subdev_8255_cleanup(dev, dev->subdevices + 0);
subdev_8255_cleanup(dev, dev->subdevices + 1);
subdev_8255_cleanup(dev, dev->subdevices + 2);
subdev_8255_cleanup(dev, dev->subdevices + 3);
-
}
-
- return 0;
}
-static int __devinit driver_adl_pci7296_pci_probe(struct pci_dev *dev,
- const struct pci_device_id
- *ent)
+static struct comedi_driver adl_pci7296_driver = {
+ .driver_name = "adl_pci7296",
+ .module = THIS_MODULE,
+ .attach = adl_pci7296_attach,
+ .detach = adl_pci7296_detach,
+};
+
+static int __devinit adl_pci7296_pci_probe(struct pci_dev *dev,
+ const struct pci_device_id *ent)
{
- return comedi_pci_auto_config(dev, driver_adl_pci7296.driver_name);
+ return comedi_pci_auto_config(dev, &adl_pci7296_driver);
}
-static void __devexit driver_adl_pci7296_pci_remove(struct pci_dev *dev)
+static void __devexit adl_pci7296_pci_remove(struct pci_dev *dev)
{
comedi_pci_auto_unconfig(dev);
}
-static struct pci_driver driver_adl_pci7296_pci_driver = {
- .id_table = adl_pci7296_pci_table,
- .probe = &driver_adl_pci7296_pci_probe,
- .remove = __devexit_p(&driver_adl_pci7296_pci_remove)
+static DEFINE_PCI_DEVICE_TABLE(adl_pci7296_pci_table) = {
+ { PCI_DEVICE(PCI_VENDOR_ID_ADLINK, PCI_DEVICE_ID_PCI7296) },
+ { 0 }
};
+MODULE_DEVICE_TABLE(pci, adl_pci7296_pci_table);
-static int __init driver_adl_pci7296_init_module(void)
-{
- int retval;
-
- retval = comedi_driver_register(&driver_adl_pci7296);
- if (retval < 0)
- return retval;
-
- driver_adl_pci7296_pci_driver.name =
- (char *)driver_adl_pci7296.driver_name;
- return pci_register_driver(&driver_adl_pci7296_pci_driver);
-}
-
-static void __exit driver_adl_pci7296_cleanup_module(void)
-{
- pci_unregister_driver(&driver_adl_pci7296_pci_driver);
- comedi_driver_unregister(&driver_adl_pci7296);
-}
-
-module_init(driver_adl_pci7296_init_module);
-module_exit(driver_adl_pci7296_cleanup_module);
+static struct pci_driver adl_pci7296_pci_driver = {
+ .name = "adl_pci7296",
+ .id_table = adl_pci7296_pci_table,
+ .probe = adl_pci7296_pci_probe,
+ .remove = __devexit_p(adl_pci7296_pci_remove),
+};
+module_comedi_pci_driver(adl_pci7296_driver, adl_pci7296_pci_driver);
MODULE_AUTHOR("Comedi http://www.comedi.org");
MODULE_DESCRIPTION("Comedi low-level driver");
diff --git a/drivers/staging/comedi/drivers/adl_pci7432.c b/drivers/staging/comedi/drivers/adl_pci7432.c
index 86ee21976041..6b8d9408e3bc 100644
--- a/drivers/staging/comedi/drivers/adl_pci7432.c
+++ b/drivers/staging/comedi/drivers/adl_pci7432.c
@@ -36,136 +36,12 @@ Configuration Options:
#include "../comedidev.h"
#include <linux/kernel.h>
-#include "comedi_pci.h"
#define PCI7432_DI 0x00
#define PCI7432_DO 0x00
#define PCI_DEVICE_ID_PCI7432 0x7432
-static DEFINE_PCI_DEVICE_TABLE(adl_pci7432_pci_table) = {
- { PCI_DEVICE(PCI_VENDOR_ID_ADLINK, PCI_DEVICE_ID_PCI7432) },
- {0}
-};
-
-MODULE_DEVICE_TABLE(pci, adl_pci7432_pci_table);
-
-struct adl_pci7432_private {
- int data;
- struct pci_dev *pci_dev;
-};
-
-#define devpriv ((struct adl_pci7432_private *)dev->private)
-
-static int adl_pci7432_attach(struct comedi_device *dev,
- struct comedi_devconfig *it);
-static int adl_pci7432_detach(struct comedi_device *dev);
-static struct comedi_driver driver_adl_pci7432 = {
- .driver_name = "adl_pci7432",
- .module = THIS_MODULE,
- .attach = adl_pci7432_attach,
- .detach = adl_pci7432_detach,
-};
-
-/* Digital IO */
-
-static int adl_pci7432_di_insn_bits(struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_insn *insn,
- unsigned int *data);
-
-static int adl_pci7432_do_insn_bits(struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_insn *insn,
- unsigned int *data);
-
-/* */
-
-static int adl_pci7432_attach(struct comedi_device *dev,
- struct comedi_devconfig *it)
-{
- struct pci_dev *pcidev = NULL;
- struct comedi_subdevice *s;
- int bus, slot;
-
- printk(KERN_INFO "comedi%d: attach adl_pci7432\n", dev->minor);
-
- dev->board_name = "pci7432";
- bus = it->options[0];
- slot = it->options[1];
-
- if (alloc_private(dev, sizeof(struct adl_pci7432_private)) < 0)
- return -ENOMEM;
-
- if (alloc_subdevices(dev, 2) < 0)
- return -ENOMEM;
-
- for_each_pci_dev(pcidev) {
- if (pcidev->vendor == PCI_VENDOR_ID_ADLINK &&
- pcidev->device == PCI_DEVICE_ID_PCI7432) {
- if (bus || slot) {
- /* requested particular bus/slot */
- if (pcidev->bus->number != bus
- || PCI_SLOT(pcidev->devfn) != slot) {
- continue;
- }
- }
- devpriv->pci_dev = pcidev;
- if (comedi_pci_enable(pcidev, "adl_pci7432") < 0) {
- printk(KERN_ERR "comedi%d: Failed to enable PCI device and request regions\n",
- dev->minor);
- return -EIO;
- }
- dev->iobase = pci_resource_start(pcidev, 2);
- printk(KERN_INFO "comedi: base addr %4lx\n",
- dev->iobase);
-
- s = dev->subdevices + 0;
- s->type = COMEDI_SUBD_DI;
- s->subdev_flags =
- SDF_READABLE | SDF_GROUND | SDF_COMMON;
- s->n_chan = 32;
- s->maxdata = 1;
- s->len_chanlist = 32;
- s->io_bits = 0x00000000;
- s->range_table = &range_digital;
- s->insn_bits = adl_pci7432_di_insn_bits;
-
- s = dev->subdevices + 1;
- s->type = COMEDI_SUBD_DO;
- s->subdev_flags =
- SDF_WRITABLE | SDF_GROUND | SDF_COMMON;
- s->n_chan = 32;
- s->maxdata = 1;
- s->len_chanlist = 32;
- s->io_bits = 0xffffffff;
- s->range_table = &range_digital;
- s->insn_bits = adl_pci7432_do_insn_bits;
-
- printk(KERN_DEBUG "comedi%d: adl_pci7432 attached\n",
- dev->minor);
- return 1;
- }
- }
-
- printk(KERN_ERR "comedi%d: no supported board found! (req. bus/slot : %d/%d)\n",
- dev->minor, bus, slot);
- return -EIO;
-}
-
-static int adl_pci7432_detach(struct comedi_device *dev)
-{
- printk(KERN_INFO "comedi%d: pci7432: remove\n", dev->minor);
-
- if (devpriv && devpriv->pci_dev) {
- if (dev->iobase)
- comedi_pci_disable(devpriv->pci_dev);
- pci_dev_put(devpriv->pci_dev);
- }
-
- return 0;
-}
-
static int adl_pci7432_do_insn_bits(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn,
@@ -174,9 +50,6 @@ static int adl_pci7432_do_insn_bits(struct comedi_device *dev,
printk(KERN_DEBUG "comedi: pci7432_do_insn_bits called\n");
printk(KERN_DEBUG "comedi: data0: %8x data1: %8x\n", data[0], data[1]);
- if (insn->n != 2)
- return -EINVAL;
-
if (data[0]) {
s->state &= ~data[0];
s->state |= (data[0] & data[1]);
@@ -185,7 +58,7 @@ static int adl_pci7432_do_insn_bits(struct comedi_device *dev,
dev->iobase + PCI7432_DO);
outl(s->state & 0xffffffff, dev->iobase + PCI7432_DO);
}
- return 2;
+ return insn->n;
}
static int adl_pci7432_di_insn_bits(struct comedi_device *dev,
@@ -196,54 +69,131 @@ static int adl_pci7432_di_insn_bits(struct comedi_device *dev,
printk(KERN_DEBUG "comedi: pci7432_di_insn_bits called\n");
printk(KERN_DEBUG "comedi: data0: %8x data1: %8x\n", data[0], data[1]);
- if (insn->n != 2)
- return -EINVAL;
-
data[1] = inl(dev->iobase + PCI7432_DI) & 0xffffffff;
printk(KERN_DEBUG "comedi: data1 %8x\n", data[1]);
- return 2;
+ return insn->n;
}
-static int __devinit driver_adl_pci7432_pci_probe(struct pci_dev *dev,
- const struct pci_device_id
- *ent)
+static struct pci_dev *adl_pci7432_find_pci(struct comedi_device *dev,
+ struct comedi_devconfig *it)
{
- return comedi_pci_auto_config(dev, driver_adl_pci7432.driver_name);
+ struct pci_dev *pcidev = NULL;
+ int bus = it->options[0];
+ int slot = it->options[1];
+
+ for_each_pci_dev(pcidev) {
+ if (pcidev->vendor != PCI_VENDOR_ID_ADLINK ||
+ pcidev->device != PCI_DEVICE_ID_PCI7432)
+ continue;
+ if (bus || slot) {
+ /* requested particular bus/slot */
+ if (pcidev->bus->number != bus ||
+ PCI_SLOT(pcidev->devfn) != slot)
+ continue;
+ }
+ return pcidev;
+ }
+ printk(KERN_ERR
+ "comedi%d: no supported board found! (req. bus/slot : %d/%d)\n",
+ dev->minor, bus, slot);
+ return NULL;
}
-static void __devexit driver_adl_pci7432_pci_remove(struct pci_dev *dev)
+static int adl_pci7432_attach(struct comedi_device *dev,
+ struct comedi_devconfig *it)
{
- comedi_pci_auto_unconfig(dev);
-}
+ struct pci_dev *pcidev;
+ struct comedi_subdevice *s;
+ int ret;
-static struct pci_driver driver_adl_pci7432_pci_driver = {
- .id_table = adl_pci7432_pci_table,
- .probe = &driver_adl_pci7432_pci_probe,
- .remove = __devexit_p(&driver_adl_pci7432_pci_remove)
-};
+ printk(KERN_INFO "comedi%d: attach adl_pci7432\n", dev->minor);
-static int __init driver_adl_pci7432_init_module(void)
+ dev->board_name = "pci7432";
+
+ ret = comedi_alloc_subdevices(dev, 2);
+ if (ret)
+ return ret;
+
+ pcidev = adl_pci7432_find_pci(dev, it);
+ if (!pcidev)
+ return -EIO;
+ comedi_set_hw_dev(dev, &pcidev->dev);
+
+ if (comedi_pci_enable(pcidev, "adl_pci7432") < 0) {
+ printk(KERN_ERR "comedi%d: Failed to enable PCI device and request regions\n",
+ dev->minor);
+ return -EIO;
+ }
+ dev->iobase = pci_resource_start(pcidev, 2);
+ printk(KERN_INFO "comedi: base addr %4lx\n", dev->iobase);
+
+ s = dev->subdevices + 0;
+ s->type = COMEDI_SUBD_DI;
+ s->subdev_flags = SDF_READABLE | SDF_GROUND | SDF_COMMON;
+ s->n_chan = 32;
+ s->maxdata = 1;
+ s->len_chanlist = 32;
+ s->io_bits = 0x00000000;
+ s->range_table = &range_digital;
+ s->insn_bits = adl_pci7432_di_insn_bits;
+
+ s = dev->subdevices + 1;
+ s->type = COMEDI_SUBD_DO;
+ s->subdev_flags = SDF_WRITABLE | SDF_GROUND | SDF_COMMON;
+ s->n_chan = 32;
+ s->maxdata = 1;
+ s->len_chanlist = 32;
+ s->io_bits = 0xffffffff;
+ s->range_table = &range_digital;
+ s->insn_bits = adl_pci7432_do_insn_bits;
+
+ printk(KERN_DEBUG "comedi%d: adl_pci7432 attached\n", dev->minor);
+ return 0;
+}
+
+static void adl_pci7432_detach(struct comedi_device *dev)
{
- int retval;
+ struct pci_dev *pcidev = comedi_to_pci_dev(dev);
- retval = comedi_driver_register(&driver_adl_pci7432);
- if (retval < 0)
- return retval;
+ if (pcidev) {
+ if (dev->iobase)
+ comedi_pci_disable(pcidev);
+ pci_dev_put(pcidev);
+ }
+}
- driver_adl_pci7432_pci_driver.name =
- (char *)driver_adl_pci7432.driver_name;
- return pci_register_driver(&driver_adl_pci7432_pci_driver);
+static struct comedi_driver adl_pci7432_driver = {
+ .driver_name = "adl_pci7432",
+ .module = THIS_MODULE,
+ .attach = adl_pci7432_attach,
+ .detach = adl_pci7432_detach,
+};
+
+static int __devinit adl_pci7432_pci_probe(struct pci_dev *dev,
+ const struct pci_device_id *ent)
+{
+ return comedi_pci_auto_config(dev, &adl_pci7432_driver);
}
-static void __exit driver_adl_pci7432_cleanup_module(void)
+static void __devexit adl_pci7432_pci_remove(struct pci_dev *dev)
{
- pci_unregister_driver(&driver_adl_pci7432_pci_driver);
- comedi_driver_unregister(&driver_adl_pci7432);
+ comedi_pci_auto_unconfig(dev);
}
-module_init(driver_adl_pci7432_init_module);
-module_exit(driver_adl_pci7432_cleanup_module);
+static DEFINE_PCI_DEVICE_TABLE(adl_pci7432_pci_table) = {
+ { PCI_DEVICE(PCI_VENDOR_ID_ADLINK, PCI_DEVICE_ID_PCI7432) },
+ { 0 }
+};
+MODULE_DEVICE_TABLE(pci, adl_pci7432_pci_table);
+
+static struct pci_driver adl_pci7432_pci_driver = {
+ .name = "adl_pci7432",
+ .id_table = adl_pci7432_pci_table,
+ .probe = adl_pci7432_pci_probe,
+ .remove = __devexit_p(adl_pci7432_pci_remove),
+};
+module_comedi_pci_driver(adl_pci7432_driver, adl_pci7432_pci_driver);
MODULE_AUTHOR("Comedi http://www.comedi.org");
MODULE_DESCRIPTION("Comedi low-level driver");
diff --git a/drivers/staging/comedi/drivers/adl_pci8164.c b/drivers/staging/comedi/drivers/adl_pci8164.c
index 3b83d65bc1bc..247ef00a7c6c 100644
--- a/drivers/staging/comedi/drivers/adl_pci8164.c
+++ b/drivers/staging/comedi/drivers/adl_pci8164.c
@@ -38,7 +38,6 @@ Configuration Options:
#include <linux/kernel.h>
#include <linux/delay.h>
#include "comedi_fc.h"
-#include "comedi_pci.h"
#include "8253.h"
#define PCI8164_AXIS_X 0x00
@@ -56,173 +55,6 @@ Configuration Options:
#define PCI_DEVICE_ID_PCI8164 0x8164
-static DEFINE_PCI_DEVICE_TABLE(adl_pci8164_pci_table) = {
- { PCI_DEVICE(PCI_VENDOR_ID_ADLINK, PCI_DEVICE_ID_PCI8164) },
- {0}
-};
-
-MODULE_DEVICE_TABLE(pci, adl_pci8164_pci_table);
-
-struct adl_pci8164_private {
- int data;
- struct pci_dev *pci_dev;
-};
-
-#define devpriv ((struct adl_pci8164_private *)dev->private)
-
-static int adl_pci8164_attach(struct comedi_device *dev,
- struct comedi_devconfig *it);
-static int adl_pci8164_detach(struct comedi_device *dev);
-static struct comedi_driver driver_adl_pci8164 = {
- .driver_name = "adl_pci8164",
- .module = THIS_MODULE,
- .attach = adl_pci8164_attach,
- .detach = adl_pci8164_detach,
-};
-
-static int adl_pci8164_insn_read_msts(struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_insn *insn,
- unsigned int *data);
-
-static int adl_pci8164_insn_read_ssts(struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_insn *insn,
- unsigned int *data);
-
-static int adl_pci8164_insn_read_buf0(struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_insn *insn,
- unsigned int *data);
-
-static int adl_pci8164_insn_read_buf1(struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_insn *insn,
- unsigned int *data);
-
-static int adl_pci8164_insn_write_cmd(struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_insn *insn,
- unsigned int *data);
-
-static int adl_pci8164_insn_write_otp(struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_insn *insn,
- unsigned int *data);
-
-static int adl_pci8164_insn_write_buf0(struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_insn *insn,
- unsigned int *data);
-
-static int adl_pci8164_insn_write_buf1(struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_insn *insn,
- unsigned int *data);
-
-static int adl_pci8164_attach(struct comedi_device *dev,
- struct comedi_devconfig *it)
-{
- struct pci_dev *pcidev = NULL;
- struct comedi_subdevice *s;
- int bus, slot;
-
- printk(KERN_INFO "comedi: attempt to attach...\n");
- printk(KERN_INFO "comedi%d: adl_pci8164\n", dev->minor);
-
- dev->board_name = "pci8164";
- bus = it->options[0];
- slot = it->options[1];
-
- if (alloc_private(dev, sizeof(struct adl_pci8164_private)) < 0)
- return -ENOMEM;
-
- if (alloc_subdevices(dev, 4) < 0)
- return -ENOMEM;
-
- for_each_pci_dev(pcidev) {
- if (pcidev->vendor == PCI_VENDOR_ID_ADLINK &&
- pcidev->device == PCI_DEVICE_ID_PCI8164) {
- if (bus || slot) {
- /* requested particular bus/slot */
- if (pcidev->bus->number != bus
- || PCI_SLOT(pcidev->devfn) != slot)
- continue;
- }
- devpriv->pci_dev = pcidev;
- if (comedi_pci_enable(pcidev, "adl_pci8164") < 0) {
- printk(KERN_ERR "comedi%d: Failed to enable "
- "PCI device and request regions\n", dev->minor);
- return -EIO;
- }
- dev->iobase = pci_resource_start(pcidev, 2);
- printk(KERN_DEBUG "comedi: base addr %4lx\n",
- dev->iobase);
-
- s = dev->subdevices + 0;
- s->type = COMEDI_SUBD_PROC;
- s->subdev_flags = SDF_READABLE | SDF_WRITABLE;
- s->n_chan = 4;
- s->maxdata = 0xffff;
- s->len_chanlist = 4;
- /* s->range_table = &range_axis; */
- s->insn_read = adl_pci8164_insn_read_msts;
- s->insn_write = adl_pci8164_insn_write_cmd;
-
- s = dev->subdevices + 1;
- s->type = COMEDI_SUBD_PROC;
- s->subdev_flags = SDF_READABLE | SDF_WRITABLE;
- s->n_chan = 4;
- s->maxdata = 0xffff;
- s->len_chanlist = 4;
- /* s->range_table = &range_axis; */
- s->insn_read = adl_pci8164_insn_read_ssts;
- s->insn_write = adl_pci8164_insn_write_otp;
-
- s = dev->subdevices + 2;
- s->type = COMEDI_SUBD_PROC;
- s->subdev_flags = SDF_READABLE | SDF_WRITABLE;
- s->n_chan = 4;
- s->maxdata = 0xffff;
- s->len_chanlist = 4;
- /* s->range_table = &range_axis; */
- s->insn_read = adl_pci8164_insn_read_buf0;
- s->insn_write = adl_pci8164_insn_write_buf0;
-
- s = dev->subdevices + 3;
- s->type = COMEDI_SUBD_PROC;
- s->subdev_flags = SDF_READABLE | SDF_WRITABLE;
- s->n_chan = 4;
- s->maxdata = 0xffff;
- s->len_chanlist = 4;
- /* s->range_table = &range_axis; */
- s->insn_read = adl_pci8164_insn_read_buf1;
- s->insn_write = adl_pci8164_insn_write_buf1;
-
- printk(KERN_INFO "comedi: attached\n");
-
- return 1;
- }
- }
-
- printk(KERN_ERR "comedi%d: no supported board found!"
- "(req. bus/slot : %d/%d)\n", dev->minor, bus, slot);
- return -EIO;
-}
-
-static int adl_pci8164_detach(struct comedi_device *dev)
-{
- printk(KERN_INFO "comedi%d: pci8164: remove\n", dev->minor);
-
- if (devpriv && devpriv->pci_dev) {
- if (dev->iobase)
- comedi_pci_disable(devpriv->pci_dev);
- pci_dev_put(devpriv->pci_dev);
- }
-
- return 0;
-}
-
/*
all the read commands are the same except for the addition a constant
* const to the data for inw()
@@ -384,45 +216,146 @@ static int adl_pci8164_insn_write_buf1(struct comedi_device *dev,
return 2;
}
-static int __devinit driver_adl_pci8164_pci_probe(struct pci_dev *dev,
- const struct pci_device_id
- *ent)
+static struct pci_dev *adl_pci8164_find_pci(struct comedi_device *dev,
+ struct comedi_devconfig *it)
{
- return comedi_pci_auto_config(dev, driver_adl_pci8164.driver_name);
+ struct pci_dev *pcidev = NULL;
+ int bus = it->options[0];
+ int slot = it->options[1];
+
+ for_each_pci_dev(pcidev) {
+ if (pcidev->vendor != PCI_VENDOR_ID_ADLINK ||
+ pcidev->device != PCI_DEVICE_ID_PCI8164)
+ continue;
+ if (bus || slot) {
+ /* requested particular bus/slot */
+ if (pcidev->bus->number != bus ||
+ PCI_SLOT(pcidev->devfn) != slot)
+ continue;
+ }
+ return pcidev;
+ }
+ printk(KERN_ERR
+ "comedi%d: no supported board found! (req. bus/slot : %d/%d)\n",
+ dev->minor, bus, slot);
+ return NULL;
}
-static void __devexit driver_adl_pci8164_pci_remove(struct pci_dev *dev)
+static int adl_pci8164_attach(struct comedi_device *dev,
+ struct comedi_devconfig *it)
{
- comedi_pci_auto_unconfig(dev);
-}
+ struct pci_dev *pcidev;
+ struct comedi_subdevice *s;
+ int ret;
-static struct pci_driver driver_adl_pci8164_pci_driver = {
- .id_table = adl_pci8164_pci_table,
- .probe = &driver_adl_pci8164_pci_probe,
- .remove = __devexit_p(&driver_adl_pci8164_pci_remove)
-};
+ printk(KERN_INFO "comedi: attempt to attach...\n");
+ printk(KERN_INFO "comedi%d: adl_pci8164\n", dev->minor);
+
+ dev->board_name = "pci8164";
+
+ ret = comedi_alloc_subdevices(dev, 4);
+ if (ret)
+ return ret;
-static int __init driver_adl_pci8164_init_module(void)
+ pcidev = adl_pci8164_find_pci(dev, it);
+ if (!pcidev)
+ return -EIO;
+ comedi_set_hw_dev(dev, &pcidev->dev);
+
+ if (comedi_pci_enable(pcidev, "adl_pci8164") < 0) {
+ printk(KERN_ERR "comedi%d: Failed to enable "
+ "PCI device and request regions\n", dev->minor);
+ return -EIO;
+ }
+ dev->iobase = pci_resource_start(pcidev, 2);
+ printk(KERN_DEBUG "comedi: base addr %4lx\n", dev->iobase);
+
+ s = dev->subdevices + 0;
+ s->type = COMEDI_SUBD_PROC;
+ s->subdev_flags = SDF_READABLE | SDF_WRITABLE;
+ s->n_chan = 4;
+ s->maxdata = 0xffff;
+ s->len_chanlist = 4;
+ /* s->range_table = &range_axis; */
+ s->insn_read = adl_pci8164_insn_read_msts;
+ s->insn_write = adl_pci8164_insn_write_cmd;
+
+ s = dev->subdevices + 1;
+ s->type = COMEDI_SUBD_PROC;
+ s->subdev_flags = SDF_READABLE | SDF_WRITABLE;
+ s->n_chan = 4;
+ s->maxdata = 0xffff;
+ s->len_chanlist = 4;
+ /* s->range_table = &range_axis; */
+ s->insn_read = adl_pci8164_insn_read_ssts;
+ s->insn_write = adl_pci8164_insn_write_otp;
+
+ s = dev->subdevices + 2;
+ s->type = COMEDI_SUBD_PROC;
+ s->subdev_flags = SDF_READABLE | SDF_WRITABLE;
+ s->n_chan = 4;
+ s->maxdata = 0xffff;
+ s->len_chanlist = 4;
+ /* s->range_table = &range_axis; */
+ s->insn_read = adl_pci8164_insn_read_buf0;
+ s->insn_write = adl_pci8164_insn_write_buf0;
+
+ s = dev->subdevices + 3;
+ s->type = COMEDI_SUBD_PROC;
+ s->subdev_flags = SDF_READABLE | SDF_WRITABLE;
+ s->n_chan = 4;
+ s->maxdata = 0xffff;
+ s->len_chanlist = 4;
+ /* s->range_table = &range_axis; */
+ s->insn_read = adl_pci8164_insn_read_buf1;
+ s->insn_write = adl_pci8164_insn_write_buf1;
+
+ printk(KERN_INFO "comedi: attached\n");
+ return 0;
+}
+
+static void adl_pci8164_detach(struct comedi_device *dev)
{
- int retval;
+ struct pci_dev *pcidev = comedi_to_pci_dev(dev);
+
+ if (pcidev) {
+ if (dev->iobase)
+ comedi_pci_disable(pcidev);
+ pci_dev_put(pcidev);
+ }
+}
- retval = comedi_driver_register(&driver_adl_pci8164);
- if (retval < 0)
- return retval;
+static struct comedi_driver adl_pci8164_driver = {
+ .driver_name = "adl_pci8164",
+ .module = THIS_MODULE,
+ .attach = adl_pci8164_attach,
+ .detach = adl_pci8164_detach,
+};
- driver_adl_pci8164_pci_driver.name =
- (char *)driver_adl_pci8164.driver_name;
- return pci_register_driver(&driver_adl_pci8164_pci_driver);
+static int __devinit adl_pci8164_pci_probe(struct pci_dev *dev,
+ const struct pci_device_id *ent)
+{
+ return comedi_pci_auto_config(dev, &adl_pci8164_driver);
}
-static void __exit driver_adl_pci8164_cleanup_module(void)
+static void __devexit adl_pci8164_pci_remove(struct pci_dev *dev)
{
- pci_unregister_driver(&driver_adl_pci8164_pci_driver);
- comedi_driver_unregister(&driver_adl_pci8164);
+ comedi_pci_auto_unconfig(dev);
}
-module_init(driver_adl_pci8164_init_module);
-module_exit(driver_adl_pci8164_cleanup_module);
+static DEFINE_PCI_DEVICE_TABLE(adl_pci8164_pci_table) = {
+ { PCI_DEVICE(PCI_VENDOR_ID_ADLINK, PCI_DEVICE_ID_PCI8164) },
+ {0}
+};
+MODULE_DEVICE_TABLE(pci, adl_pci8164_pci_table);
+
+static struct pci_driver adl_pci8164_pci_driver = {
+ .name = "adl_pci8164",
+ .id_table = adl_pci8164_pci_table,
+ .probe = adl_pci8164_pci_probe,
+ .remove = __devexit_p(adl_pci8164_pci_remove),
+};
+module_comedi_pci_driver(adl_pci8164_driver, adl_pci8164_pci_driver);
MODULE_AUTHOR("Comedi http://www.comedi.org");
MODULE_DESCRIPTION("Comedi low-level driver");
diff --git a/drivers/staging/comedi/drivers/adl_pci9111.c b/drivers/staging/comedi/drivers/adl_pci9111.c
index 2a9bd88a4abb..a31dae6e07df 100644
--- a/drivers/staging/comedi/drivers/adl_pci9111.c
+++ b/drivers/staging/comedi/drivers/adl_pci9111.c
@@ -81,7 +81,6 @@ TODO:
#include <linux/interrupt.h>
#include "8253.h"
-#include "comedi_pci.h"
#include "comedi_fc.h"
#define PCI9111_DRIVER_NAME "adl_pci9111"
@@ -289,16 +288,6 @@ TODO:
PCI9111_IO_BASE+PCI9111_REGISTER_8254_COUNTER_2); \
} while (0)
-/* Function prototypes */
-
-static int pci9111_attach(struct comedi_device *dev,
- struct comedi_devconfig *it);
-static int pci9111_detach(struct comedi_device *dev);
-static void pci9111_ai_munge(struct comedi_device *dev,
- struct comedi_subdevice *s, void *data,
- unsigned int num_bytes,
- unsigned int start_chan_index);
-
static const struct comedi_lrange pci9111_hr_ai_range = {
5,
{
@@ -310,14 +299,6 @@ static const struct comedi_lrange pci9111_hr_ai_range = {
}
};
-static DEFINE_PCI_DEVICE_TABLE(pci9111_pci_table) = {
- { PCI_DEVICE(PCI_VENDOR_ID_ADLINK, PCI9111_HR_DEVICE_ID) },
- /* { PCI_DEVICE(PCI_VENDOR_ID_ADLINK, PCI9111_HG_DEVICE_ID) }, */
- { 0 }
-};
-
-MODULE_DEVICE_TABLE(pci, pci9111_pci_table);
-
/* */
/* Board specification structure */
/* */
@@ -354,55 +335,9 @@ static const struct pci9111_board pci9111_boards[] = {
#define pci9111_board_nbr \
(sizeof(pci9111_boards)/sizeof(struct pci9111_board))
-static struct comedi_driver pci9111_driver = {
- .driver_name = PCI9111_DRIVER_NAME,
- .module = THIS_MODULE,
- .attach = pci9111_attach,
- .detach = pci9111_detach,
-};
-
-static int __devinit pci9111_driver_pci_probe(struct pci_dev *dev,
- const struct pci_device_id *ent)
-{
- return comedi_pci_auto_config(dev, pci9111_driver.driver_name);
-}
-
-static void __devexit pci9111_driver_pci_remove(struct pci_dev *dev)
-{
- comedi_pci_auto_unconfig(dev);
-}
-
-static struct pci_driver pci9111_driver_pci_driver = {
- .id_table = pci9111_pci_table,
- .probe = &pci9111_driver_pci_probe,
- .remove = __devexit_p(&pci9111_driver_pci_remove)
-};
-
-static int __init pci9111_driver_init_module(void)
-{
- int retval;
-
- retval = comedi_driver_register(&pci9111_driver);
- if (retval < 0)
- return retval;
-
- pci9111_driver_pci_driver.name = (char *)pci9111_driver.driver_name;
- return pci_register_driver(&pci9111_driver_pci_driver);
-}
-
-static void __exit pci9111_driver_cleanup_module(void)
-{
- pci_unregister_driver(&pci9111_driver_pci_driver);
- comedi_driver_unregister(&pci9111_driver);
-}
-
-module_init(pci9111_driver_init_module);
-module_exit(pci9111_driver_cleanup_module);
-
/* Private data structure */
struct pci9111_private_data {
- struct pci_dev *pci_device;
unsigned long io_range; /* PCI6503 io range */
unsigned long lcr_io_base; /* Local configuration register base
@@ -1217,7 +1152,7 @@ static int pci9111_di_insn_bits(struct comedi_device *dev,
bits = pci9111_di_get_bits();
data[1] = bits;
- return 2;
+ return insn->n;
}
/* Digital outputs */
@@ -1243,7 +1178,7 @@ static int pci9111_do_insn_bits(struct comedi_device *dev,
data[1] = bits;
- return 2;
+ return insn->n;
}
/* ------------------------------------------------------------------ */
@@ -1273,17 +1208,48 @@ static int pci9111_reset(struct comedi_device *dev)
return 0;
}
-/* Attach */
-/* - Register PCI device */
-/* - Declare device driver capability */
+static struct pci_dev *pci9111_find_pci(struct comedi_device *dev,
+ struct comedi_devconfig *it)
+{
+ struct pci_dev *pcidev = NULL;
+ int bus = it->options[0];
+ int slot = it->options[1];
+ int i;
+
+ for_each_pci_dev(pcidev) {
+ if (pcidev->vendor != PCI_VENDOR_ID_ADLINK)
+ continue;
+ for (i = 0; i < pci9111_board_nbr; i++) {
+ if (pcidev->device != pci9111_boards[i].device_id)
+ continue;
+ if (bus || slot) {
+ /* requested particular bus/slot */
+ if (pcidev->bus->number != bus ||
+ PCI_SLOT(pcidev->devfn) != slot)
+ continue;
+ }
+ dev->board_ptr = pci9111_boards + i;
+ printk(KERN_ERR
+ "comedi%d: found %s (b:s:f=%d:%d:%d), irq=%d\n",
+ dev->minor, pci9111_boards[i].name,
+ pcidev->bus->number, PCI_SLOT(pcidev->devfn),
+ PCI_FUNC(pcidev->devfn), pcidev->irq);
+ return pcidev;
+ }
+ }
+ printk(KERN_ERR
+ "comedi%d: no supported board found! (req. bus/slot : %d/%d)\n",
+ dev->minor, bus, slot);
+ return NULL;
+}
static int pci9111_attach(struct comedi_device *dev,
struct comedi_devconfig *it)
{
+ struct pci_dev *pcidev;
struct comedi_subdevice *subdevice;
unsigned long io_base, io_range, lcr_io_base, lcr_io_range;
- struct pci_dev *pci_device = NULL;
- int error, i;
+ int error;
const struct pci9111_board *board;
if (alloc_private(dev, sizeof(struct pci9111_private_data)) < 0)
@@ -1293,65 +1259,26 @@ static int pci9111_attach(struct comedi_device *dev,
printk(KERN_ERR "comedi%d: " PCI9111_DRIVER_NAME " driver\n",
dev->minor);
- for_each_pci_dev(pci_device) {
- if (pci_device->vendor == PCI_VENDOR_ID_ADLINK) {
- for (i = 0; i < pci9111_board_nbr; i++) {
- if (pci9111_boards[i].device_id ==
- pci_device->device) {
- /* was a particular bus/slot
- * requested? */
- if ((it->options[0] != 0)
- || (it->options[1] != 0)) {
- /* are we on the wrong
- * bus/slot? */
- if (pci_device->bus->number !=
- it->options[0]
- ||
- PCI_SLOT(pci_device->devfn)
- != it->options[1]) {
- continue;
- }
- }
-
- dev->board_ptr = pci9111_boards + i;
- board =
- (struct pci9111_board *)
- dev->board_ptr;
- dev_private->pci_device = pci_device;
- goto found;
- }
- }
- }
- }
-
- printk(KERN_ERR
- "comedi%d: no supported board found! (req. bus/slot : %d/%d)\n",
- dev->minor, it->options[0], it->options[1]);
- return -EIO;
-
-found:
-
- printk(KERN_ERR "comedi%d: found %s (b:s:f=%d:%d:%d) , irq=%d\n",
- dev->minor,
- pci9111_boards[i].name,
- pci_device->bus->number,
- PCI_SLOT(pci_device->devfn),
- PCI_FUNC(pci_device->devfn), pci_device->irq);
+ pcidev = pci9111_find_pci(dev, it);
+ if (!pcidev)
+ return -EIO;
+ comedi_set_hw_dev(dev, &pcidev->dev);
+ board = (struct pci9111_board *)dev->board_ptr;
/* TODO: Warn about non-tested boards. */
/* Read local configuration register base address
* [PCI_BASE_ADDRESS #1]. */
- lcr_io_base = pci_resource_start(pci_device, 1);
- lcr_io_range = pci_resource_len(pci_device, 1);
+ lcr_io_base = pci_resource_start(pcidev, 1);
+ lcr_io_range = pci_resource_len(pcidev, 1);
printk
("comedi%d: local configuration registers at address 0x%4lx [0x%4lx]\n",
dev->minor, lcr_io_base, lcr_io_range);
/* Enable PCI device and request regions */
- if (comedi_pci_enable(pci_device, PCI9111_DRIVER_NAME) < 0) {
+ if (comedi_pci_enable(pcidev, PCI9111_DRIVER_NAME) < 0) {
printk
("comedi%d: Failed to enable PCI device and request regions\n",
dev->minor);
@@ -1359,8 +1286,8 @@ found:
}
/* Read PCI6308 register base address [PCI_BASE_ADDRESS #2]. */
- io_base = pci_resource_start(pci_device, 2);
- io_range = pci_resource_len(pci_device, 2);
+ io_base = pci_resource_start(pcidev, 2);
+ io_range = pci_resource_len(pcidev, 2);
printk(KERN_ERR "comedi%d: 6503 registers at address 0x%4lx [0x%4lx]\n",
dev->minor, io_base, io_range);
@@ -1377,21 +1304,22 @@ found:
/* Irq setup */
dev->irq = 0;
- if (pci_device->irq > 0) {
- if (request_irq(pci_device->irq, pci9111_interrupt,
+ if (pcidev->irq > 0) {
+ dev->irq = pcidev->irq;
+
+ if (request_irq(dev->irq, pci9111_interrupt,
IRQF_SHARED, PCI9111_DRIVER_NAME, dev) != 0) {
printk(KERN_ERR
"comedi%d: unable to allocate irq %u\n",
- dev->minor, pci_device->irq);
+ dev->minor, dev->irq);
return -EINVAL;
}
}
- dev->irq = pci_device->irq;
/* TODO: Add external multiplexer setup (according to option[2]). */
- error = alloc_subdevices(dev, 4);
- if (error < 0)
+ error = comedi_alloc_subdevices(dev, 4);
+ if (error)
return error;
subdevice = dev->subdevices + 0;
@@ -1445,31 +1373,56 @@ found:
return 0;
}
-/* Detach */
-
-static int pci9111_detach(struct comedi_device *dev)
+static void pci9111_detach(struct comedi_device *dev)
{
- /* Reset device */
+ struct pci_dev *pcidev = comedi_to_pci_dev(dev);
if (dev->private != NULL) {
if (dev_private->is_valid)
pci9111_reset(dev);
-
}
- /* Release previously allocated irq */
-
if (dev->irq != 0)
free_irq(dev->irq, dev);
-
- if (dev_private != NULL && dev_private->pci_device != NULL) {
+ if (pcidev) {
if (dev->iobase)
- comedi_pci_disable(dev_private->pci_device);
- pci_dev_put(dev_private->pci_device);
+ comedi_pci_disable(pcidev);
+ pci_dev_put(pcidev);
}
+}
- return 0;
+static struct comedi_driver adl_pci9111_driver = {
+ .driver_name = "adl_pci9111",
+ .module = THIS_MODULE,
+ .attach = pci9111_attach,
+ .detach = pci9111_detach,
+};
+
+static int __devinit pci9111_pci_probe(struct pci_dev *dev,
+ const struct pci_device_id *ent)
+{
+ return comedi_pci_auto_config(dev, &adl_pci9111_driver);
+}
+
+static void __devexit pci9111_pci_remove(struct pci_dev *dev)
+{
+ comedi_pci_auto_unconfig(dev);
}
+static DEFINE_PCI_DEVICE_TABLE(pci9111_pci_table) = {
+ { PCI_DEVICE(PCI_VENDOR_ID_ADLINK, PCI9111_HR_DEVICE_ID) },
+ /* { PCI_DEVICE(PCI_VENDOR_ID_ADLINK, PCI9111_HG_DEVICE_ID) }, */
+ { 0 }
+};
+MODULE_DEVICE_TABLE(pci, pci9111_pci_table);
+
+static struct pci_driver adl_pci9111_pci_driver = {
+ .name = "adl_pci9111",
+ .id_table = pci9111_pci_table,
+ .probe = pci9111_pci_probe,
+ .remove = __devexit_p(pci9111_pci_remove),
+};
+module_comedi_pci_driver(adl_pci9111_driver, adl_pci9111_pci_driver);
+
MODULE_AUTHOR("Comedi http://www.comedi.org");
MODULE_DESCRIPTION("Comedi low-level driver");
MODULE_LICENSE("GPL");
diff --git a/drivers/staging/comedi/drivers/adl_pci9118.c b/drivers/staging/comedi/drivers/adl_pci9118.c
index f17654e44aef..a1f74c2590e8 100644
--- a/drivers/staging/comedi/drivers/adl_pci9118.c
+++ b/drivers/staging/comedi/drivers/adl_pci9118.c
@@ -71,7 +71,6 @@ Configuration options:
#include "amcc_s5933.h"
#include "8253.h"
-#include "comedi_pci.h"
#include "comedi_fc.h"
#define PCI_VENDOR_ID_AMCC 0x10e8
@@ -221,10 +220,6 @@ static const struct comedi_lrange range_pci9118hg = { 8, {
* of BIP/UNI ranges
*/
-static int pci9118_attach(struct comedi_device *dev,
- struct comedi_devconfig *it);
-static int pci9118_detach(struct comedi_device *dev);
-
struct boardtype {
const char *name; /* board name */
int vendor_id; /* PCI vendor a device ID of card */
@@ -252,85 +247,9 @@ struct boardtype {
};
-static DEFINE_PCI_DEVICE_TABLE(pci9118_pci_table) = {
- { PCI_DEVICE(PCI_VENDOR_ID_AMCC, 0x80d9) },
- { 0 }
-};
-
-MODULE_DEVICE_TABLE(pci, pci9118_pci_table);
-
-static const struct boardtype boardtypes[] = {
- {"pci9118dg", PCI_VENDOR_ID_AMCC, 0x80d9,
- AMCC_OP_REG_SIZE, IORANGE_9118,
- 16, 8, 256, PCI9118_CHANLEN, 2, 0x0fff, 0x0fff,
- &range_pci9118dg_hr, &range_bipolar10,
- 3000, 12, 512},
- {"pci9118hg", PCI_VENDOR_ID_AMCC, 0x80d9,
- AMCC_OP_REG_SIZE, IORANGE_9118,
- 16, 8, 256, PCI9118_CHANLEN, 2, 0x0fff, 0x0fff,
- &range_pci9118hg, &range_bipolar10,
- 3000, 12, 512},
- {"pci9118hr", PCI_VENDOR_ID_AMCC, 0x80d9,
- AMCC_OP_REG_SIZE, IORANGE_9118,
- 16, 8, 256, PCI9118_CHANLEN, 2, 0xffff, 0x0fff,
- &range_pci9118dg_hr, &range_bipolar10,
- 10000, 40, 512},
-};
-
-#define n_boardtypes (sizeof(boardtypes)/sizeof(struct boardtype))
-
-static struct comedi_driver driver_pci9118 = {
- .driver_name = "adl_pci9118",
- .module = THIS_MODULE,
- .attach = pci9118_attach,
- .detach = pci9118_detach,
- .num_names = n_boardtypes,
- .board_name = &boardtypes[0].name,
- .offset = sizeof(struct boardtype),
-};
-
-static int __devinit driver_pci9118_pci_probe(struct pci_dev *dev,
- const struct pci_device_id *ent)
-{
- return comedi_pci_auto_config(dev, driver_pci9118.driver_name);
-}
-
-static void __devexit driver_pci9118_pci_remove(struct pci_dev *dev)
-{
- comedi_pci_auto_unconfig(dev);
-}
-
-static struct pci_driver driver_pci9118_pci_driver = {
- .id_table = pci9118_pci_table,
- .probe = &driver_pci9118_pci_probe,
- .remove = __devexit_p(&driver_pci9118_pci_remove)
-};
-
-static int __init driver_pci9118_init_module(void)
-{
- int retval;
-
- retval = comedi_driver_register(&driver_pci9118);
- if (retval < 0)
- return retval;
-
- driver_pci9118_pci_driver.name = (char *)driver_pci9118.driver_name;
- return pci_register_driver(&driver_pci9118_pci_driver);
-}
-
-static void __exit driver_pci9118_cleanup_module(void)
-{
- pci_unregister_driver(&driver_pci9118_pci_driver);
- comedi_driver_unregister(&driver_pci9118);
-}
-
-module_init(driver_pci9118_init_module);
-module_exit(driver_pci9118_cleanup_module);
-
struct pci9118_private {
unsigned long iobase_a; /* base+size for AMCC chip */
unsigned int master; /* master capable */
- struct pci_dev *pcidev; /* ptr to actual pcidev */
unsigned int usemux; /* we want to use external multiplexor! */
#ifdef PCI9118_PARANOIDCHECK
unsigned short chanlist[PCI9118_CHANLEN + 1]; /*
@@ -379,7 +298,7 @@ struct pci9118_private {
short *ai_data;
short ao_data[2]; /* data output buffer */
unsigned int ai_scans; /* number of scans to do */
- char dma_doublebuf; /* we can use double buffring */
+ char dma_doublebuf; /* we can use double buffering */
unsigned int dma_actbuf; /* which buffer is used now */
short *dmabuf_virt[2]; /*
* pointers to begin of
@@ -572,7 +491,7 @@ static int pci9118_insn_bits_di(struct comedi_device *dev,
{
data[1] = inl(dev->iobase + PCI9118_DI) & 0xf;
- return 2;
+ return insn->n;
}
/*
@@ -589,7 +508,7 @@ static int pci9118_insn_bits_do(struct comedi_device *dev,
}
data[1] = s->state;
- return 2;
+ return insn->n;
}
/*
@@ -1815,7 +1734,7 @@ static int check_channel_list(struct comedi_device *dev,
"can't be mixtured!");
return 0;
}
- if ((!devpriv->usemux) & (differencial) &
+ if (!devpriv->usemux && differencial &&
(CR_CHAN(chanlist[i]) >= this_board->n_aichand)) {
comedi_error(dev,
"If AREF_DIFF is used then is "
@@ -2190,27 +2109,56 @@ static int pci9118_reset(struct comedi_device *dev)
return 0;
}
-/*
-==============================================================================
-*/
+static struct pci_dev *pci9118_find_pci(struct comedi_device *dev,
+ struct comedi_devconfig *it)
+{
+ struct pci_dev *pcidev = NULL;
+ int bus = it->options[0];
+ int slot = it->options[1];
+
+ for_each_pci_dev(pcidev) {
+ if (pcidev->vendor != PCI_VENDOR_ID_AMCC)
+ continue;
+ if (pcidev->device != this_board->device_id)
+ continue;
+ if (bus || slot) {
+ /* requested particular bus/slot */
+ if (pcidev->bus->number != bus ||
+ PCI_SLOT(pcidev->devfn) != slot)
+ continue;
+ }
+ /*
+ * Look for device that isn't in use.
+ * Enable PCI device and request regions.
+ */
+ if (comedi_pci_enable(pcidev, "adl_pci9118"))
+ continue;
+ printk(KERN_ERR ", b:s:f=%d:%d:%d, io=0x%4lx, 0x%4lx",
+ pcidev->bus->number,
+ PCI_SLOT(pcidev->devfn),
+ PCI_FUNC(pcidev->devfn),
+ (unsigned long)pci_resource_start(pcidev, 2),
+ (unsigned long)pci_resource_start(pcidev, 0));
+ return pcidev;
+ }
+ printk(KERN_ERR
+ "comedi%d: no supported board found! (req. bus/slot : %d/%d)\n",
+ dev->minor, bus, slot);
+ return NULL;
+}
+
static int pci9118_attach(struct comedi_device *dev,
struct comedi_devconfig *it)
{
+ struct pci_dev *pcidev;
struct comedi_subdevice *s;
int ret, pages, i;
unsigned short master;
unsigned int irq;
- unsigned long iobase_a, iobase_9;
- struct pci_dev *pcidev;
- int opt_bus, opt_slot;
- const char *errstr;
- unsigned char pci_bus, pci_slot, pci_func;
u16 u16w;
printk("comedi%d: adl_pci9118: board=%s", dev->minor, this_board->name);
- opt_bus = it->options[0];
- opt_slot = it->options[1];
if (it->options[3] & 1)
master = 0; /* user don't want use bus master */
else
@@ -2222,61 +2170,20 @@ static int pci9118_attach(struct comedi_device *dev,
return -ENOMEM;
}
- /* Look for matching PCI device */
- errstr = "not found!";
- pcidev = NULL;
- while (NULL != (pcidev = pci_get_device(PCI_VENDOR_ID_AMCC,
- this_board->device_id,
- pcidev))) {
- /* Found matching vendor/device. */
- if (opt_bus || opt_slot) {
- /* Check bus/slot. */
- if (opt_bus != pcidev->bus->number
- || opt_slot != PCI_SLOT(pcidev->devfn))
- continue; /* no match */
- }
- /*
- * Look for device that isn't in use.
- * Enable PCI device and request regions.
- */
- if (comedi_pci_enable(pcidev, "adl_pci9118")) {
- errstr =
- "failed to enable PCI device and request regions!";
- continue;
- }
- break;
- }
-
- if (!pcidev) {
- if (opt_bus || opt_slot) {
- printk(KERN_ERR " - Card at b:s %d:%d %s\n",
- opt_bus, opt_slot, errstr);
- } else {
- printk(KERN_ERR " - Card %s\n", errstr);
- }
+ pcidev = pci9118_find_pci(dev, it);
+ if (!pcidev)
return -EIO;
- }
+ comedi_set_hw_dev(dev, &pcidev->dev);
if (master)
pci_set_master(pcidev);
-
- pci_bus = pcidev->bus->number;
- pci_slot = PCI_SLOT(pcidev->devfn);
- pci_func = PCI_FUNC(pcidev->devfn);
irq = pcidev->irq;
- iobase_a = pci_resource_start(pcidev, 0);
- iobase_9 = pci_resource_start(pcidev, 2);
-
- printk(KERN_ERR ", b:s:f=%d:%d:%d, io=0x%4lx, 0x%4lx", pci_bus,
- pci_slot, pci_func, iobase_9, iobase_a);
+ devpriv->iobase_a = pci_resource_start(pcidev, 0);
+ dev->iobase = pci_resource_start(pcidev, 2);
- dev->iobase = iobase_9;
dev->board_name = this_board->name;
- devpriv->pcidev = pcidev;
- devpriv->iobase_a = iobase_a;
-
pci9118_reset(dev);
if (it->options[3] & 2)
@@ -2358,12 +2265,12 @@ static int pci9118_attach(struct comedi_device *dev,
printk(".\n");
- pci_read_config_word(devpriv->pcidev, PCI_COMMAND, &u16w);
- pci_write_config_word(devpriv->pcidev, PCI_COMMAND, u16w | 64);
+ pci_read_config_word(pcidev, PCI_COMMAND, &u16w);
+ pci_write_config_word(pcidev, PCI_COMMAND, u16w | 64);
/* Enable parity check for parity error */
- ret = alloc_subdevices(dev, 4);
- if (ret < 0)
+ ret = comedi_alloc_subdevices(dev, 4);
+ if (ret)
return ret;
s = dev->subdevices + 0;
@@ -2435,22 +2342,15 @@ static int pci9118_attach(struct comedi_device *dev,
return 0;
}
-/*
-==============================================================================
-*/
-static int pci9118_detach(struct comedi_device *dev)
+static void pci9118_detach(struct comedi_device *dev)
{
+ struct pci_dev *pcidev = comedi_to_pci_dev(dev);
+
if (dev->private) {
if (devpriv->valid)
pci9118_reset(dev);
if (dev->irq)
free_irq(dev->irq, dev);
- if (devpriv->pcidev) {
- if (dev->iobase)
- comedi_pci_disable(devpriv->pcidev);
-
- pci_dev_put(devpriv->pcidev);
- }
if (devpriv->dmabuf_virt[0])
free_pages((unsigned long)devpriv->dmabuf_virt[0],
devpriv->dmabuf_pages[0]);
@@ -2458,13 +2358,106 @@ static int pci9118_detach(struct comedi_device *dev)
free_pages((unsigned long)devpriv->dmabuf_virt[1],
devpriv->dmabuf_pages[1]);
}
+ if (pcidev) {
+ if (dev->iobase)
+ comedi_pci_disable(pcidev);
- return 0;
+ pci_dev_put(pcidev);
+ }
}
-/*
-==============================================================================
-*/
+static const struct boardtype boardtypes[] = {
+ {
+ .name = "pci9118dg",
+ .vendor_id = PCI_VENDOR_ID_AMCC,
+ .device_id = 0x80d9,
+ .iorange_amcc = AMCC_OP_REG_SIZE,
+ .iorange_9118 = IORANGE_9118,
+ .n_aichan = 16,
+ .n_aichand = 8,
+ .mux_aichan = 256,
+ .n_aichanlist = PCI9118_CHANLEN,
+ .n_aochan = 2,
+ .ai_maxdata = 0x0fff,
+ .ao_maxdata = 0x0fff,
+ .rangelist_ai = &range_pci9118dg_hr,
+ .rangelist_ao = &range_bipolar10,
+ .ai_ns_min = 3000,
+ .ai_pacer_min = 12,
+ .half_fifo_size = 512,
+ }, {
+ .name = "pci9118hg",
+ .vendor_id = PCI_VENDOR_ID_AMCC,
+ .device_id = 0x80d9,
+ .iorange_amcc = AMCC_OP_REG_SIZE,
+ .iorange_9118 = IORANGE_9118,
+ .n_aichan = 16,
+ .n_aichand = 8,
+ .mux_aichan = 256,
+ .n_aichanlist = PCI9118_CHANLEN,
+ .n_aochan = 2,
+ .ai_maxdata = 0x0fff,
+ .ao_maxdata = 0x0fff,
+ .rangelist_ai = &range_pci9118hg,
+ .rangelist_ao = &range_bipolar10,
+ .ai_ns_min = 3000,
+ .ai_pacer_min = 12,
+ .half_fifo_size = 512,
+ }, {
+ .name = "pci9118hr",
+ .vendor_id = PCI_VENDOR_ID_AMCC,
+ .device_id = 0x80d9,
+ .iorange_amcc = AMCC_OP_REG_SIZE,
+ .iorange_9118 = IORANGE_9118,
+ .n_aichan = 16,
+ .n_aichand = 8,
+ .mux_aichan = 256,
+ .n_aichanlist = PCI9118_CHANLEN,
+ .n_aochan = 2,
+ .ai_maxdata = 0xffff,
+ .ao_maxdata = 0x0fff,
+ .rangelist_ai = &range_pci9118dg_hr,
+ .rangelist_ao = &range_bipolar10,
+ .ai_ns_min = 10000,
+ .ai_pacer_min = 40,
+ .half_fifo_size = 512,
+ },
+};
+
+static struct comedi_driver adl_pci9118_driver = {
+ .driver_name = "adl_pci9118",
+ .module = THIS_MODULE,
+ .attach = pci9118_attach,
+ .detach = pci9118_detach,
+ .num_names = ARRAY_SIZE(boardtypes),
+ .board_name = &boardtypes[0].name,
+ .offset = sizeof(struct boardtype),
+};
+
+static int __devinit adl_pci9118_pci_probe(struct pci_dev *dev,
+ const struct pci_device_id *ent)
+{
+ return comedi_pci_auto_config(dev, &adl_pci9118_driver);
+}
+
+static void __devexit adl_pci9118_pci_remove(struct pci_dev *dev)
+{
+ comedi_pci_auto_unconfig(dev);
+}
+
+static DEFINE_PCI_DEVICE_TABLE(adl_pci9118_pci_table) = {
+ { PCI_DEVICE(PCI_VENDOR_ID_AMCC, 0x80d9) },
+ { 0 }
+};
+MODULE_DEVICE_TABLE(pci, adl_pci9118_pci_table);
+
+static struct pci_driver adl_pci9118_pci_driver = {
+ .name = "adl_pci9118",
+ .id_table = adl_pci9118_pci_table,
+ .probe = adl_pci9118_pci_probe,
+ .remove = __devexit_p(adl_pci9118_pci_remove),
+};
+module_comedi_pci_driver(adl_pci9118_driver, adl_pci9118_pci_driver);
MODULE_AUTHOR("Comedi http://www.comedi.org");
MODULE_DESCRIPTION("Comedi low-level driver");
diff --git a/drivers/staging/comedi/drivers/adq12b.c b/drivers/staging/comedi/drivers/adq12b.c
index 5361f318b010..6df51c8a602a 100644
--- a/drivers/staging/comedi/drivers/adq12b.c
+++ b/drivers/staging/comedi/drivers/adq12b.c
@@ -125,26 +125,6 @@ struct adq12b_board {
int do_chans;
};
-static const struct adq12b_board adq12b_boards[] = {
- {
- .name = "adq12b",
- .ai_se_chans = 16,
- .ai_diff_chans = 8,
- .ai_bits = 12,
- .di_chans = 5,
- .do_chans = 8}
-/* potentially, more adq-based deviced will be added */
-/*,
- .name = "adq12b",
- .ai_chans = 16, // this is just for reference, hardcoded again later
- .ai_bits = 12,
- .di_chans = 8,
- .do_chans = 5
- }*/
-};
-
-#define thisboard ((const struct adq12b_board *)dev->board_ptr)
-
struct adq12b_private {
int unipolar; /* option 2 of comedi_config (1 is iobase) */
int differential; /* option 3 of comedi_config */
@@ -156,46 +136,95 @@ struct adq12b_private {
#define devpriv ((struct adq12b_private *)dev->private)
/*
- * The struct comedi_driver structure tells the Comedi core module
- * which functions to call to configure/deconfigure (attach/detach)
- * the board, and also about the kernel module that contains
- * the device code.
+ * "instructions" read/write data in "one-shot" or "software-triggered"
+ * mode.
*/
-static int adq12b_attach(struct comedi_device *dev,
- struct comedi_devconfig *it);
-static int adq12b_detach(struct comedi_device *dev);
-
-static struct comedi_driver driver_adq12b = {
- .driver_name = "adq12b",
- .module = THIS_MODULE,
- .attach = adq12b_attach,
- .detach = adq12b_detach,
- .board_name = &adq12b_boards[0].name,
- .offset = sizeof(struct adq12b_board),
- .num_names = ARRAY_SIZE(adq12b_boards),
-};
static int adq12b_ai_rinsn(struct comedi_device *dev,
struct comedi_subdevice *s, struct comedi_insn *insn,
- unsigned int *data);
+ unsigned int *data)
+{
+ int n, i;
+ int range, channel;
+ unsigned char hi, lo, status;
+
+ /* change channel and range only if it is different from the previous */
+ range = CR_RANGE(insn->chanspec);
+ channel = CR_CHAN(insn->chanspec);
+ if (channel != devpriv->last_channel || range != devpriv->last_range) {
+ outb((range << 4) | channel, dev->iobase + ADQ12B_CTREG);
+ udelay(50); /* wait for the mux to settle */
+ }
+
+ /* trigger conversion */
+ status = inb(dev->iobase + ADQ12B_ADLOW);
+
+ /* convert n samples */
+ for (n = 0; n < insn->n; n++) {
+
+ /* wait for end of conversion */
+ i = 0;
+ do {
+ /* udelay(1); */
+ status = inb(dev->iobase + ADQ12B_STINR);
+ status = status & ADQ12B_EOC;
+ } while (status == 0 && ++i < TIMEOUT);
+ /* } while (++i < 10); */
+
+ /* read data */
+ hi = inb(dev->iobase + ADQ12B_ADHIG);
+ lo = inb(dev->iobase + ADQ12B_ADLOW);
+
+ /* printk("debug: chan=%d range=%d status=%d hi=%d lo=%d\n",
+ channel, range, status, hi, lo); */
+ data[n] = (hi << 8) | lo;
+
+ }
+
+ /* return the number of samples read/written */
+ return n;
+}
+
static int adq12b_di_insn_bits(struct comedi_device *dev,
struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data);
+ struct comedi_insn *insn, unsigned int *data)
+{
+
+ /* only bits 0-4 have information about digital inputs */
+ data[1] = (inb(dev->iobase + ADQ12B_STINR) & (0x1f));
+
+ return insn->n;
+}
+
static int adq12b_do_insn_bits(struct comedi_device *dev,
struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data);
+ struct comedi_insn *insn, unsigned int *data)
+{
+ int channel;
+
+ for (channel = 0; channel < 8; channel++)
+ if (((data[0] >> channel) & 0x01) != 0)
+ outb((((data[1] >> channel) & 0x01) << 3) | channel,
+ dev->iobase + ADQ12B_OUTBR);
+
+ /* store information to retrieve when asked for reading */
+ if (data[0]) {
+ devpriv->digital_state &= ~data[0];
+ devpriv->digital_state |= (data[0] & data[1]);
+ }
+
+ data[1] = devpriv->digital_state;
+
+ return insn->n;
+}
-/*
- * Attach is called by the Comedi core to configure the driver
- * for a particular board. If you specified a board_name array
- * in the driver structure, dev->board_ptr contains that
- * address.
- */
static int adq12b_attach(struct comedi_device *dev, struct comedi_devconfig *it)
{
+ const struct adq12b_board *board = comedi_board(dev);
struct comedi_subdevice *s;
unsigned long iobase;
int unipolar, differential;
+ int ret;
iobase = it->options[0];
unipolar = it->options[1];
@@ -221,11 +250,7 @@ static int adq12b_attach(struct comedi_device *dev, struct comedi_devconfig *it)
}
dev->iobase = iobase;
-/*
- * Initialize dev->board_name. Note that we can use the "thisboard"
- * macro now, since we just initialized it in the last line.
- */
- dev->board_name = thisboard->name;
+ dev->board_name = board->name;
/*
* Allocate the private structure area. alloc_private() is a
@@ -243,22 +268,19 @@ static int adq12b_attach(struct comedi_device *dev, struct comedi_devconfig *it)
devpriv->last_channel = -1;
devpriv->last_range = -1;
-/*
- * Allocate the subdevice structures. alloc_subdevice() is a
- * convenient macro defined in comedidev.h.
- */
- if (alloc_subdevices(dev, 3) < 0)
- return -ENOMEM;
+ ret = comedi_alloc_subdevices(dev, 3);
+ if (ret)
+ return ret;
s = dev->subdevices + 0;
/* analog input subdevice */
s->type = COMEDI_SUBD_AI;
if (differential) {
s->subdev_flags = SDF_READABLE | SDF_GROUND | SDF_DIFF;
- s->n_chan = thisboard->ai_diff_chans;
+ s->n_chan = board->ai_diff_chans;
} else {
s->subdev_flags = SDF_READABLE | SDF_GROUND;
- s->n_chan = thisboard->ai_se_chans;
+ s->n_chan = board->ai_se_chans;
}
if (unipolar)
@@ -266,7 +288,7 @@ static int adq12b_attach(struct comedi_device *dev, struct comedi_devconfig *it)
else
s->range_table = &range_adq12b_ai_bipolar;
- s->maxdata = (1 << thisboard->ai_bits) - 1;
+ s->maxdata = (1 << board->ai_bits) - 1;
s->len_chanlist = 4; /* This is the maximum chanlist length that
the board can handle */
@@ -276,7 +298,7 @@ static int adq12b_attach(struct comedi_device *dev, struct comedi_devconfig *it)
/* digital input subdevice */
s->type = COMEDI_SUBD_DI;
s->subdev_flags = SDF_READABLE;
- s->n_chan = thisboard->di_chans;
+ s->n_chan = board->di_chans;
s->maxdata = 1;
s->range_table = &range_digital;
s->insn_bits = adq12b_di_insn_bits;
@@ -285,7 +307,7 @@ static int adq12b_attach(struct comedi_device *dev, struct comedi_devconfig *it)
/* digital output subdevice */
s->type = COMEDI_SUBD_DO;
s->subdev_flags = SDF_WRITABLE;
- s->n_chan = thisboard->do_chans;
+ s->n_chan = board->do_chans;
s->maxdata = 1;
s->range_table = &range_digital;
s->insn_bits = adq12b_do_insn_bits;
@@ -295,125 +317,34 @@ static int adq12b_attach(struct comedi_device *dev, struct comedi_devconfig *it)
return 0;
}
-/*
- * _detach is called to deconfigure a device. It should deallocate
- * resources.
- * This function is also called when _attach() fails, so it should be
- * careful not to release resources that were not necessarily
- * allocated by _attach(). dev->private and dev->subdevices are
- * deallocated automatically by the core.
- */
-static int adq12b_detach(struct comedi_device *dev)
+static void adq12b_detach(struct comedi_device *dev)
{
if (dev->iobase)
release_region(dev->iobase, ADQ12B_SIZE);
-
kfree(devpriv);
-
- printk(KERN_INFO "comedi%d: adq12b: removed\n", dev->minor);
-
- return 0;
}
-/*
- * "instructions" read/write data in "one-shot" or "software-triggered"
- * mode.
- */
-
-static int adq12b_ai_rinsn(struct comedi_device *dev,
- struct comedi_subdevice *s, struct comedi_insn *insn,
- unsigned int *data)
-{
- int n, i;
- int range, channel;
- unsigned char hi, lo, status;
-
- /* change channel and range only if it is different from the previous */
- range = CR_RANGE(insn->chanspec);
- channel = CR_CHAN(insn->chanspec);
- if (channel != devpriv->last_channel || range != devpriv->last_range) {
- outb((range << 4) | channel, dev->iobase + ADQ12B_CTREG);
- udelay(50); /* wait for the mux to settle */
- }
-
- /* trigger conversion */
- status = inb(dev->iobase + ADQ12B_ADLOW);
-
- /* convert n samples */
- for (n = 0; n < insn->n; n++) {
-
- /* wait for end of conversion */
- i = 0;
- do {
- /* udelay(1); */
- status = inb(dev->iobase + ADQ12B_STINR);
- status = status & ADQ12B_EOC;
- } while (status == 0 && ++i < TIMEOUT);
- /* } while (++i < 10); */
-
- /* read data */
- hi = inb(dev->iobase + ADQ12B_ADHIG);
- lo = inb(dev->iobase + ADQ12B_ADLOW);
-
- /* printk("debug: chan=%d range=%d status=%d hi=%d lo=%d\n",
- channel, range, status, hi, lo); */
- data[n] = (hi << 8) | lo;
-
- }
-
- /* return the number of samples read/written */
- return n;
-}
-
-static int adq12b_di_insn_bits(struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data)
-{
-
- /* only bits 0-4 have information about digital inputs */
- data[1] = (inb(dev->iobase + ADQ12B_STINR) & (0x1f));
-
- return 2;
-}
-
-static int adq12b_do_insn_bits(struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data)
-{
- int channel;
-
- for (channel = 0; channel < 8; channel++)
- if (((data[0] >> channel) & 0x01) != 0)
- outb((((data[1] >> channel) & 0x01) << 3) | channel,
- dev->iobase + ADQ12B_OUTBR);
-
- /* store information to retrieve when asked for reading */
- if (data[0]) {
- devpriv->digital_state &= ~data[0];
- devpriv->digital_state |= (data[0] & data[1]);
- }
-
- data[1] = devpriv->digital_state;
-
- return 2;
-}
-
-/*
- * A convenient macro that defines init_module() and cleanup_module(),
- * as necessary.
- */
-static int __init driver_adq12b_init_module(void)
-{
- return comedi_driver_register(&driver_adq12b);
-}
-
-static void __exit driver_adq12b_cleanup_module(void)
-{
- comedi_driver_unregister(&driver_adq12b);
-}
+static const struct adq12b_board adq12b_boards[] = {
+ {
+ .name = "adq12b",
+ .ai_se_chans = 16,
+ .ai_diff_chans = 8,
+ .ai_bits = 12,
+ .di_chans = 5,
+ .do_chans = 8,
+ },
+};
-module_init(driver_adq12b_init_module);
-module_exit(driver_adq12b_cleanup_module);
+static struct comedi_driver adq12b_driver = {
+ .driver_name = "adq12b",
+ .module = THIS_MODULE,
+ .attach = adq12b_attach,
+ .detach = adq12b_detach,
+ .board_name = &adq12b_boards[0].name,
+ .offset = sizeof(struct adq12b_board),
+ .num_names = ARRAY_SIZE(adq12b_boards),
+};
+module_comedi_driver(adq12b_driver);
MODULE_AUTHOR("Comedi http://www.comedi.org");
MODULE_DESCRIPTION("Comedi low-level driver");
diff --git a/drivers/staging/comedi/drivers/adv_pci1710.c b/drivers/staging/comedi/drivers/adv_pci1710.c
index 8318c82a555a..31986608eaf1 100644
--- a/drivers/staging/comedi/drivers/adv_pci1710.c
+++ b/drivers/staging/comedi/drivers/adv_pci1710.c
@@ -45,8 +45,6 @@ Configuration options:
#include "../comedidev.h"
-#include "comedi_pci.h"
-
#include "8253.h"
#include "amcc_s5933.h"
@@ -191,10 +189,6 @@ static const struct comedi_lrange range_pci171x_da = { 2, {
}
};
-static int pci1710_attach(struct comedi_device *dev,
- struct comedi_devconfig *it);
-static int pci1710_detach(struct comedi_device *dev);
-
struct boardtype {
const char *name; /* board name */
int device_id;
@@ -216,17 +210,6 @@ struct boardtype {
unsigned int fifo_half_size; /* size of FIFO/2 */
};
-static DEFINE_PCI_DEVICE_TABLE(pci1710_pci_table) = {
- { PCI_DEVICE(PCI_VENDOR_ID_ADVANTECH, 0x1710) },
- { PCI_DEVICE(PCI_VENDOR_ID_ADVANTECH, 0x1711) },
- { PCI_DEVICE(PCI_VENDOR_ID_ADVANTECH, 0x1713) },
- { PCI_DEVICE(PCI_VENDOR_ID_ADVANTECH, 0x1720) },
- { PCI_DEVICE(PCI_VENDOR_ID_ADVANTECH, 0x1731) },
- { 0 }
-};
-
-MODULE_DEVICE_TABLE(pci, pci1710_pci_table);
-
static const struct boardtype boardtypes[] = {
{"pci1710", 0x1710,
IORANGE_171x, 1, TYPE_PCI171X,
@@ -264,20 +247,7 @@ static const struct boardtype boardtypes[] = {
{.name = DRV_NAME},
};
-#define n_boardtypes (sizeof(boardtypes)/sizeof(struct boardtype))
-
-static struct comedi_driver driver_pci1710 = {
- .driver_name = DRV_NAME,
- .module = THIS_MODULE,
- .attach = pci1710_attach,
- .detach = pci1710_detach,
- .num_names = n_boardtypes,
- .board_name = &boardtypes[0].name,
- .offset = sizeof(struct boardtype),
-};
-
struct pci1710_private {
- struct pci_dev *pcidev; /* ptr to PCI device */
char valid; /* card is usable */
char neverending_ai; /* we do unlimited AI */
unsigned int CntrlReg; /* Control register */
@@ -464,7 +434,7 @@ static int pci171x_insn_bits_di(struct comedi_device *dev,
{
data[1] = inw(dev->iobase + PCI171x_DI);
- return 2;
+ return insn->n;
}
/*
@@ -481,7 +451,7 @@ static int pci171x_insn_bits_do(struct comedi_device *dev,
}
data[1] = s->state;
- return 2;
+ return insn->n;
}
/*
@@ -676,7 +646,9 @@ static void interrupt_pci1710_every_sample(void *d)
s->async->buf_int_count, s->async->buf_int_ptr,
s->async->buf_user_count, s->async->buf_user_ptr);
DPRINTK("adv_pci1710 EDBG: EOS2\n");
- if ((!devpriv->neverending_ai) && (devpriv->ai_act_scan >= devpriv->ai_scans)) { /* all data sampled */
+ if ((!devpriv->neverending_ai) &&
+ (devpriv->ai_act_scan >= devpriv->ai_scans)) {
+ /* all data sampled */
pci171x_ai_cancel(dev, s);
s->async->events |= COMEDI_CB_EOA;
comedi_event(dev, s);
@@ -804,8 +776,8 @@ static irqreturn_t interrupt_service_pci1710(int irq, void *d)
irq);
if (!dev->attached) /* is device attached? */
return IRQ_NONE; /* no, exit */
-
- if (!(inw(dev->iobase + PCI171x_STATUS) & Status_IRQ)) /* is this interrupt from our board? */
+ /* is this interrupt from our board? */
+ if (!(inw(dev->iobase + PCI171x_STATUS) & Status_IRQ))
return IRQ_NONE; /* no, exit */
DPRINTK("adv_pci1710 EDBG: interrupt_service_pci1710() ST: %4x\n",
@@ -814,7 +786,7 @@ static irqreturn_t interrupt_service_pci1710(int irq, void *d)
if (devpriv->ai_et) { /* Switch from initial TRIG_EXT to TRIG_xxx. */
devpriv->ai_et = 0;
devpriv->CntrlReg &= Control_CNT0;
- devpriv->CntrlReg |= Control_SW; /* set software trigger */
+ devpriv->CntrlReg |= Control_SW; /* set software trigger */
outw(devpriv->CntrlReg, dev->iobase + PCI171x_CONTROL);
devpriv->CntrlReg = devpriv->ai_et_CntrlReg;
outb(0, dev->iobase + PCI171x_CLRFIFO);
@@ -865,7 +837,8 @@ static int pci171x_ai_docmd_and_mode(int mode, struct comedi_device *dev,
devpriv->neverending_ai = 0;
devpriv->CntrlReg &= Control_CNT0;
- if ((devpriv->ai_flags & TRIG_WAKE_EOS)) { /* don't we want wake up every scan? devpriv->ai_eos=1; */
+ /* don't we want wake up every scan? devpriv->ai_eos=1; */
+ if ((devpriv->ai_flags & TRIG_WAKE_EOS)) {
devpriv->ai_eos = 1;
} else {
devpriv->CntrlReg |= Control_ONEFH;
@@ -982,13 +955,13 @@ static int pci171x_ai_cmdtest(struct comedi_device *dev,
#ifdef PCI171X_EXTDEBUG
pci171x_cmdtest_out(1, cmd);
#endif
- DPRINTK
- ("adv_pci1710 EDBG: BGN: pci171x_ai_cmdtest(...) err=%d ret=1\n",
- err);
+ DPRINTK(
+ "adv_pci1710 EDBG: BGN: pci171x_ai_cmdtest(...) err=%d ret=1\n",
+ err);
return 1;
}
- /* step 2: make sure trigger sources are unique and mutually compatible */
+ /* step2: make sure trigger srcs are unique and mutually compatible */
if (cmd->start_src != TRIG_NOW && cmd->start_src != TRIG_EXT) {
cmd->start_src = TRIG_NOW;
@@ -1015,9 +988,9 @@ static int pci171x_ai_cmdtest(struct comedi_device *dev,
#ifdef PCI171X_EXTDEBUG
pci171x_cmdtest_out(2, cmd);
#endif
- DPRINTK
- ("adv_pci1710 EDBG: BGN: pci171x_ai_cmdtest(...) err=%d ret=2\n",
- err);
+ DPRINTK(
+ "adv_pci1710 EDBG: BGN: pci171x_ai_cmdtest(...) err=%d ret=2\n",
+ err);
return 2;
}
@@ -1065,9 +1038,9 @@ static int pci171x_ai_cmdtest(struct comedi_device *dev,
#ifdef PCI171X_EXTDEBUG
pci171x_cmdtest_out(3, cmd);
#endif
- DPRINTK
- ("adv_pci1710 EDBG: BGN: pci171x_ai_cmdtest(...) err=%d ret=3\n",
- err);
+ DPRINTK(
+ "adv_pci1710 EDBG: BGN: pci171x_ai_cmdtest(...) err=%d ret=3\n",
+ err);
return 3;
}
@@ -1160,48 +1133,41 @@ static int check_channel_list(struct comedi_device *dev,
return 0;
}
- if (n_chan > 1) {
- chansegment[0] = chanlist[0]; /* first channel is every time ok */
- for (i = 1, seglen = 1; i < n_chan; i++, seglen++) { /* build part of chanlist */
- /* printk("%d. %d %d\n",i,CR_CHAN(chanlist[i]),CR_RANGE(chanlist[i])); */
- if (chanlist[0] == chanlist[i])
- break; /* we detect loop, this must by finish */
- if (CR_CHAN(chanlist[i]) & 1) /* odd channel cann't by differencial */
- if (CR_AREF(chanlist[i]) == AREF_DIFF) {
- comedi_error(dev,
- "Odd channel can't be differential input!\n");
- return 0;
- }
- nowmustbechan =
- (CR_CHAN(chansegment[i - 1]) + 1) % s->n_chan;
- if (CR_AREF(chansegment[i - 1]) == AREF_DIFF)
- nowmustbechan = (nowmustbechan + 1) % s->n_chan;
- if (nowmustbechan != CR_CHAN(chanlist[i])) { /* channel list isn't continuous :-( */
- printk
- ("channel list must be continuous! chanlist[%i]=%d but must be %d or %d!\n",
- i, CR_CHAN(chanlist[i]), nowmustbechan,
- CR_CHAN(chanlist[0]));
- return 0;
- }
- chansegment[i] = chanlist[i]; /* well, this is next correct channel in list */
+ if (n_chan == 1)
+ return 1; /* seglen=1 */
+
+ chansegment[0] = chanlist[0]; /* first channel is every time ok */
+ for (i = 1, seglen = 1; i < n_chan; i++, seglen++) {
+ if (chanlist[0] == chanlist[i])
+ break; /* we detected a loop, stop */
+ if ((CR_CHAN(chanlist[i]) & 1) &&
+ (CR_AREF(chanlist[i]) == AREF_DIFF)) {
+ comedi_error(dev, "Odd channel cannot be differential input!\n");
+ return 0;
}
+ nowmustbechan = (CR_CHAN(chansegment[i - 1]) + 1) % s->n_chan;
+ if (CR_AREF(chansegment[i - 1]) == AREF_DIFF)
+ nowmustbechan = (nowmustbechan + 1) % s->n_chan;
+ if (nowmustbechan != CR_CHAN(chanlist[i])) {
+ printk("channel list must be continuous! chanlist[%i]=%d but must be %d or %d!\n",
+ i, CR_CHAN(chanlist[i]), nowmustbechan,
+ CR_CHAN(chanlist[0]));
+ return 0;
+ }
+ chansegment[i] = chanlist[i]; /* next correct channel in list */
+ }
- for (i = 0, segpos = 0; i < n_chan; i++) { /* check whole chanlist */
- /* printk("%d %d=%d %d\n",CR_CHAN(chansegment[i%seglen]),CR_RANGE(chansegment[i%seglen]),CR_CHAN(chanlist[i]),CR_RANGE(chanlist[i])); */
- if (chanlist[i] != chansegment[i % seglen]) {
- printk
- ("bad channel, reference or range number! chanlist[%i]=%d,%d,%d and not %d,%d,%d!\n",
- i, CR_CHAN(chansegment[i]),
- CR_RANGE(chansegment[i]),
- CR_AREF(chansegment[i]),
- CR_CHAN(chanlist[i % seglen]),
- CR_RANGE(chanlist[i % seglen]),
- CR_AREF(chansegment[i % seglen]));
- return 0; /* chan/gain list is strange */
- }
+ for (i = 0, segpos = 0; i < n_chan; i++) {
+ if (chanlist[i] != chansegment[i % seglen]) {
+ printk("bad channel, reference or range number! chanlist[%i]=%d,%d,%d and not %d,%d,%d!\n",
+ i, CR_CHAN(chansegment[i]),
+ CR_RANGE(chansegment[i]),
+ CR_AREF(chansegment[i]),
+ CR_CHAN(chanlist[i % seglen]),
+ CR_RANGE(chanlist[i % seglen]),
+ CR_AREF(chansegment[i % seglen]));
+ return 0;
}
- } else {
- seglen = 1;
}
return seglen;
}
@@ -1221,14 +1187,14 @@ static void setup_channel_list(struct comedi_device *dev,
DPRINTK("SegLen: %d\n", seglen);
for (i = 0; i < seglen; i++) { /* store range list to card */
chanprog = muxonechan[CR_CHAN(chanlist[i])];
- outw(chanprog, dev->iobase + PCI171x_MUX); /* select channel */
+ outw(chanprog, dev->iobase + PCI171x_MUX); /* select channel */
range = this_board->rangecode_ai[CR_RANGE(chanlist[i])];
if (CR_AREF(chanlist[i]) == AREF_DIFF)
range |= 0x0020;
- outw(range, dev->iobase + PCI171x_RANGE); /* select gain */
+ outw(range, dev->iobase + PCI171x_RANGE); /* select gain */
#ifdef PCI171x_PARANOIDCHECK
devpriv->act_chanlist[i] =
- (CR_CHAN(chanlist[i]) << 12) & 0xf000;
+ (CR_CHAN(chanlist[i]) << 12) & 0xf000;
#endif
DPRINTK("GS: %2d. [%4x]=%4x %4x\n", i, chanprog, range,
devpriv->act_chanlist[i]);
@@ -1236,13 +1202,14 @@ static void setup_channel_list(struct comedi_device *dev,
#ifdef PCI171x_PARANOIDCHECK
for ( ; i < n_chan; i++) { /* store remainder of channel list */
devpriv->act_chanlist[i] =
- (CR_CHAN(chanlist[i]) << 12) & 0xf000;
+ (CR_CHAN(chanlist[i]) << 12) & 0xf000;
}
#endif
devpriv->ai_et_MuxVal =
- CR_CHAN(chanlist[0]) | (CR_CHAN(chanlist[seglen - 1]) << 8);
- outw(devpriv->ai_et_MuxVal, dev->iobase + PCI171x_MUX); /* select channel interval to scan */
+ CR_CHAN(chanlist[0]) | (CR_CHAN(chanlist[seglen - 1]) << 8);
+ /* select channel interval to scan */
+ outw(devpriv->ai_et_MuxVal, dev->iobase + PCI171x_MUX);
DPRINTK("MUX: %4x L%4x.H%4x\n",
CR_CHAN(chanlist[0]) | (CR_CHAN(chanlist[seglen - 1]) << 8),
CR_CHAN(chanlist[0]), CR_CHAN(chanlist[seglen - 1]));
@@ -1365,96 +1332,75 @@ static int pci1710_reset(struct comedi_device *dev)
DPRINTK("adv_pci1710 EDBG: END: pci1710_reset(...)\n");
}
-/*
-==============================================================================
-*/
-static int pci1710_attach(struct comedi_device *dev,
- struct comedi_devconfig *it)
+static struct pci_dev *pci1710_find_pci_dev(struct comedi_device *dev,
+ struct comedi_devconfig *it)
{
- struct comedi_subdevice *s;
- int ret, subdev, n_subdevices;
- unsigned int irq;
- unsigned long iobase;
- struct pci_dev *pcidev;
- int opt_bus, opt_slot;
- const char *errstr;
- unsigned char pci_bus, pci_slot, pci_func;
+ struct pci_dev *pcidev = NULL;
+ int bus = it->options[0];
+ int slot = it->options[1];
+ int board_index = this_board - boardtypes;
int i;
- int board_index;
- dev_info(dev->hw_dev, "comedi%d: adv_pci1710:\n", dev->minor);
-
- opt_bus = it->options[0];
- opt_slot = it->options[1];
-
- ret = alloc_private(dev, sizeof(struct pci1710_private));
- if (ret < 0)
- return -ENOMEM;
+ for_each_pci_dev(pcidev) {
+ if (bus || slot) {
+ if (bus != pcidev->bus->number ||
+ slot != PCI_SLOT(pcidev->devfn))
+ continue;
+ }
+ if (pcidev->vendor != PCI_VENDOR_ID_ADVANTECH)
+ continue;
+ if (pci_is_enabled(pcidev))
+ continue;
- /* Look for matching PCI device */
- errstr = "not found!";
- pcidev = NULL;
- board_index = this_board - boardtypes;
- while (NULL != (pcidev = pci_get_device(PCI_VENDOR_ID_ADVANTECH,
- PCI_ANY_ID, pcidev))) {
if (strcmp(this_board->name, DRV_NAME) == 0) {
- for (i = 0; i < n_boardtypes; ++i) {
+ for (i = 0; i < ARRAY_SIZE(boardtypes); ++i) {
if (pcidev->device == boardtypes[i].device_id) {
board_index = i;
break;
}
}
- if (i == n_boardtypes)
+ if (i == ARRAY_SIZE(boardtypes))
continue;
} else {
if (pcidev->device != boardtypes[board_index].device_id)
continue;
}
-
- /* Found matching vendor/device. */
- if (opt_bus || opt_slot) {
- /* Check bus/slot. */
- if (opt_bus != pcidev->bus->number
- || opt_slot != PCI_SLOT(pcidev->devfn))
- continue; /* no match */
- }
- /*
- * Look for device that isn't in use.
- * Enable PCI device and request regions.
- */
- if (comedi_pci_enable(pcidev, DRV_NAME)) {
- errstr =
- "failed to enable PCI device and request regions!";
- continue;
- }
- /* fixup board_ptr in case we were using the dummy entry with the driver name */
dev->board_ptr = &boardtypes[board_index];
- break;
+ return pcidev;
}
+ dev_err(dev->class_dev,
+ "No supported board found! (req. bus %d, slot %d)\n",
+ bus, slot);
+ return NULL;
+}
- if (!pcidev) {
- if (opt_bus || opt_slot) {
- dev_err(dev->hw_dev, "- Card at b:s %d:%d %s\n",
- opt_bus, opt_slot, errstr);
- } else {
- dev_err(dev->hw_dev, "- Card %s\n", errstr);
- }
- return -EIO;
- }
+static int pci1710_attach(struct comedi_device *dev,
+ struct comedi_devconfig *it)
+{
+ struct pci_dev *pcidev;
+ struct comedi_subdevice *s;
+ int ret, subdev, n_subdevices;
+ unsigned int irq;
- pci_bus = pcidev->bus->number;
- pci_slot = PCI_SLOT(pcidev->devfn);
- pci_func = PCI_FUNC(pcidev->devfn);
- irq = pcidev->irq;
- iobase = pci_resource_start(pcidev, 2);
+ dev_info(dev->class_dev, DRV_NAME ": attach\n");
- dev_dbg(dev->hw_dev, "b:s:f=%d:%d:%d, io=0x%4lx\n", pci_bus, pci_slot,
- pci_func, iobase);
+ ret = alloc_private(dev, sizeof(struct pci1710_private));
+ if (ret < 0)
+ return -ENOMEM;
- dev->iobase = iobase;
+ pcidev = pci1710_find_pci_dev(dev, it);
+ if (!pcidev)
+ return -EIO;
+ comedi_set_hw_dev(dev, &pcidev->dev);
+
+ ret = comedi_pci_enable(pcidev, DRV_NAME);
+ if (ret)
+ return ret;
+
+ dev->iobase = pci_resource_start(pcidev, 2);
+ irq = pcidev->irq;
dev->board_name = this_board->name;
- devpriv->pcidev = pcidev;
n_subdevices = 0;
if (this_board->n_aichan)
@@ -1468,8 +1414,8 @@ static int pci1710_attach(struct comedi_device *dev,
if (this_board->n_counter)
n_subdevices++;
- ret = alloc_subdevices(dev, n_subdevices);
- if (ret < 0)
+ ret = comedi_alloc_subdevices(dev, n_subdevices);
+ if (ret)
return ret;
pci1710_reset(dev);
@@ -1479,14 +1425,15 @@ static int pci1710_attach(struct comedi_device *dev,
if (request_irq(irq, interrupt_service_pci1710,
IRQF_SHARED, "Advantech PCI-1710",
dev)) {
- dev_dbg(dev->hw_dev, "unable to allocate IRQ %d, DISABLING IT",
+ dev_dbg(dev->class_dev,
+ "unable to allocate IRQ %d, DISABLING IT",
irq);
irq = 0; /* Can't use IRQ */
} else {
- dev_dbg(dev->hw_dev, "irq=%u", irq);
+ dev_dbg(dev->class_dev, "irq=%u", irq);
}
} else {
- dev_dbg(dev->hw_dev, "IRQ disabled");
+ dev_dbg(dev->class_dev, "IRQ disabled");
}
} else {
irq = 0;
@@ -1584,71 +1531,61 @@ static int pci1710_attach(struct comedi_device *dev,
return 0;
}
-/*
-==============================================================================
-*/
-static int pci1710_detach(struct comedi_device *dev)
+static void pci1710_detach(struct comedi_device *dev)
{
+ struct pci_dev *pcidev = comedi_to_pci_dev(dev);
if (dev->private) {
if (devpriv->valid)
pci1710_reset(dev);
if (dev->irq)
free_irq(dev->irq, dev);
- if (devpriv->pcidev) {
- if (dev->iobase)
- comedi_pci_disable(devpriv->pcidev);
-
- pci_dev_put(devpriv->pcidev);
- }
}
-
- return 0;
+ if (pcidev) {
+ if (dev->iobase)
+ comedi_pci_disable(pcidev);
+ pci_dev_put(pcidev);
+ }
}
-/*
-==============================================================================
-*/
-static int __devinit driver_pci1710_pci_probe(struct pci_dev *dev,
- const struct pci_device_id *ent)
+static struct comedi_driver adv_pci1710_driver = {
+ .driver_name = "adv_pci1710",
+ .module = THIS_MODULE,
+ .attach = pci1710_attach,
+ .detach = pci1710_detach,
+ .num_names = ARRAY_SIZE(boardtypes),
+ .board_name = &boardtypes[0].name,
+ .offset = sizeof(struct boardtype),
+};
+
+static int __devinit adv_pci1710_pci_probe(struct pci_dev *dev,
+ const struct pci_device_id *ent)
{
- return comedi_pci_auto_config(dev, driver_pci1710.driver_name);
+ return comedi_pci_auto_config(dev, &adv_pci1710_driver);
}
-static void __devexit driver_pci1710_pci_remove(struct pci_dev *dev)
+static void __devexit adv_pci1710_pci_remove(struct pci_dev *dev)
{
comedi_pci_auto_unconfig(dev);
}
-static struct pci_driver driver_pci1710_pci_driver = {
- .id_table = pci1710_pci_table,
- .probe = &driver_pci1710_pci_probe,
- .remove = __devexit_p(&driver_pci1710_pci_remove)
+static DEFINE_PCI_DEVICE_TABLE(adv_pci1710_pci_table) = {
+ { PCI_DEVICE(PCI_VENDOR_ID_ADVANTECH, 0x1710) },
+ { PCI_DEVICE(PCI_VENDOR_ID_ADVANTECH, 0x1711) },
+ { PCI_DEVICE(PCI_VENDOR_ID_ADVANTECH, 0x1713) },
+ { PCI_DEVICE(PCI_VENDOR_ID_ADVANTECH, 0x1720) },
+ { PCI_DEVICE(PCI_VENDOR_ID_ADVANTECH, 0x1731) },
+ { 0 }
};
+MODULE_DEVICE_TABLE(pci, adv_pci1710_pci_table);
-static int __init driver_pci1710_init_module(void)
-{
- int retval;
-
- retval = comedi_driver_register(&driver_pci1710);
- if (retval < 0)
- return retval;
-
- driver_pci1710_pci_driver.name = (char *)driver_pci1710.driver_name;
- return pci_register_driver(&driver_pci1710_pci_driver);
-}
-
-static void __exit driver_pci1710_cleanup_module(void)
-{
- pci_unregister_driver(&driver_pci1710_pci_driver);
- comedi_driver_unregister(&driver_pci1710);
-}
-
-module_init(driver_pci1710_init_module);
-module_exit(driver_pci1710_cleanup_module);
-/*
-==============================================================================
-*/
+static struct pci_driver adv_pci1710_pci_driver = {
+ .name = "adv_pci1710",
+ .id_table = adv_pci1710_pci_table,
+ .probe = adv_pci1710_pci_probe,
+ .remove = __devexit_p(adv_pci1710_pci_remove),
+};
+module_comedi_pci_driver(adv_pci1710_driver, adv_pci1710_pci_driver);
MODULE_AUTHOR("Comedi http://www.comedi.org");
MODULE_DESCRIPTION("Comedi low-level driver");
diff --git a/drivers/staging/comedi/drivers/adv_pci1723.c b/drivers/staging/comedi/drivers/adv_pci1723.c
index 29455a8e88b4..da5ee69d2c9d 100644
--- a/drivers/staging/comedi/drivers/adv_pci1723.c
+++ b/drivers/staging/comedi/drivers/adv_pci1723.c
@@ -50,8 +50,6 @@ TODO:
#include "../comedidev.h"
-#include "comedi_pci.h"
-
#define PCI_VENDOR_ID_ADVANTECH 0x13fe /* Advantech PCI vendor ID */
/* hardware types of the cards */
@@ -150,41 +148,10 @@ static const struct pci1723_board boardtypes[] = {
},
};
-/*
- * This is used by modprobe to translate PCI IDs to drivers.
- * Should only be used for PCI and ISA-PnP devices
- */
-static DEFINE_PCI_DEVICE_TABLE(pci1723_pci_table) = {
- { PCI_DEVICE(PCI_VENDOR_ID_ADVANTECH, 0x1723) },
- { 0 }
-};
-
-MODULE_DEVICE_TABLE(pci, pci1723_pci_table);
-
-/*
- * The struct comedi_driver structure tells the Comedi core module
- * which functions to call to configure/deconfigure (attach/detach)
- * the board, and also about the kernel module that contains
- * the device code.
- */
-static int pci1723_attach(struct comedi_device *dev,
- struct comedi_devconfig *it);
-static int pci1723_detach(struct comedi_device *dev);
-
-#define n_boardtypes (sizeof(boardtypes)/sizeof(struct pci1723_board))
-
-static struct comedi_driver driver_pci1723 = {
- .driver_name = "adv_pci1723",
- .module = THIS_MODULE,
- .attach = pci1723_attach,
- .detach = pci1723_detach,
-};
-
/* This structure is for data unique to this hardware driver. */
struct pci1723_private {
int valid; /* card is usable; */
- struct pci_dev *pcidev;
unsigned char da_range[8]; /* D/A output range for each channel */
short ao_data[8]; /* data output buffer */
@@ -316,83 +283,62 @@ static int pci1723_dio_insn_bits(struct comedi_device *dev,
outw(s->state, dev->iobase + PCI1723_WRITE_DIGITAL_OUTPUT_CMD);
}
data[1] = inw(dev->iobase + PCI1723_READ_DIGITAL_INPUT_DATA);
- return 2;
+ return insn->n;
+}
+
+static struct pci_dev *pci1723_find_pci_dev(struct comedi_device *dev,
+ struct comedi_devconfig *it)
+{
+ struct pci_dev *pcidev = NULL;
+ int bus = it->options[0];
+ int slot = it->options[1];
+
+ for_each_pci_dev(pcidev) {
+ if (bus || slot) {
+ if (bus != pcidev->bus->number ||
+ slot != PCI_SLOT(pcidev->devfn))
+ continue;
+ }
+ if (pcidev->vendor != PCI_VENDOR_ID_ADVANTECH)
+ continue;
+ if (pci_is_enabled(pcidev))
+ continue;
+ return pcidev;
+ }
+ dev_err(dev->class_dev,
+ "No supported board found! (req. bus %d, slot %d)\n",
+ bus, slot);
+ return NULL;
}
-/*
- * Attach is called by the Comedi core to configure the driver
- * for a pci1723 board.
- */
static int pci1723_attach(struct comedi_device *dev,
struct comedi_devconfig *it)
{
+ struct pci_dev *pcidev;
struct comedi_subdevice *s;
int ret, subdev, n_subdevices;
- struct pci_dev *pcidev;
- unsigned int iobase;
- unsigned char pci_bus, pci_slot, pci_func;
- int opt_bus, opt_slot;
- const char *errstr;
printk(KERN_ERR "comedi%d: adv_pci1723: board=%s",
dev->minor, this_board->name);
- opt_bus = it->options[0];
- opt_slot = it->options[1];
-
ret = alloc_private(dev, sizeof(struct pci1723_private));
if (ret < 0) {
printk(" - Allocation failed!\n");
return -ENOMEM;
}
- /* Look for matching PCI device */
- errstr = "not found!";
- pcidev = NULL;
- while (NULL != (pcidev =
- pci_get_device(PCI_VENDOR_ID_ADVANTECH,
- this_board->device_id, pcidev))) {
- /* Found matching vendor/device. */
- if (opt_bus || opt_slot) {
- /* Check bus/slot. */
- if (opt_bus != pcidev->bus->number
- || opt_slot != PCI_SLOT(pcidev->devfn))
- continue; /* no match */
- }
- /*
- * Look for device that isn't in use.
- * Enable PCI device and request regions.
- */
- if (comedi_pci_enable(pcidev, "adv_pci1723")) {
- errstr =
- "failed to enable PCI device and request regions!";
- continue;
- }
- break;
- }
-
- if (!pcidev) {
- if (opt_bus || opt_slot) {
- printk(KERN_ERR " - Card at b:s %d:%d %s\n",
- opt_bus, opt_slot, errstr);
- } else {
- printk(KERN_ERR " - Card %s\n", errstr);
- }
+ pcidev = pci1723_find_pci_dev(dev, it);
+ if (!pcidev)
return -EIO;
- }
+ comedi_set_hw_dev(dev, &pcidev->dev);
- pci_bus = pcidev->bus->number;
- pci_slot = PCI_SLOT(pcidev->devfn);
- pci_func = PCI_FUNC(pcidev->devfn);
- iobase = pci_resource_start(pcidev, 2);
-
- printk(KERN_ERR ", b:s:f=%d:%d:%d, io=0x%4x",
- pci_bus, pci_slot, pci_func, iobase);
+ ret = comedi_pci_enable(pcidev, "adv_pci1723");
+ if (ret)
+ return ret;
- dev->iobase = iobase;
+ dev->iobase = pci_resource_start(pcidev, 2);
dev->board_name = this_board->name;
- devpriv->pcidev = pcidev;
n_subdevices = 0;
@@ -401,11 +347,9 @@ static int pci1723_attach(struct comedi_device *dev,
if (this_board->n_diochan)
n_subdevices++;
- ret = alloc_subdevices(dev, n_subdevices);
- if (ret < 0) {
- printk(" - Allocation failed!\n");
+ ret = comedi_alloc_subdevices(dev, n_subdevices);
+ if (ret)
return ret;
- }
pci1723_reset(dev);
subdev = 0;
@@ -465,73 +409,52 @@ static int pci1723_attach(struct comedi_device *dev,
return 0;
}
-/*
- * _detach is called to deconfigure a device. It should deallocate
- * resources.
- * This function is also called when _attach() fails, so it should be
- * careful not to release resources that were not necessarily
- * allocated by _attach(). dev->private and dev->subdevices are
- * deallocated automatically by the core.
- */
-static int pci1723_detach(struct comedi_device *dev)
+static void pci1723_detach(struct comedi_device *dev)
{
- printk(KERN_ERR "comedi%d: pci1723: remove\n", dev->minor);
+ struct pci_dev *pcidev = comedi_to_pci_dev(dev);
if (dev->private) {
if (devpriv->valid)
pci1723_reset(dev);
-
- if (devpriv->pcidev) {
- if (dev->iobase)
- comedi_pci_disable(devpriv->pcidev);
- pci_dev_put(devpriv->pcidev);
- }
}
-
- return 0;
+ if (pcidev) {
+ if (dev->iobase)
+ comedi_pci_disable(pcidev);
+ pci_dev_put(pcidev);
+ }
}
-/*
- * A convenient macro that defines init_module() and cleanup_module(),
- * as necessary.
- */
-static int __devinit driver_pci1723_pci_probe(struct pci_dev *dev,
- const struct pci_device_id *ent)
+static struct comedi_driver adv_pci1723_driver = {
+ .driver_name = "adv_pci1723",
+ .module = THIS_MODULE,
+ .attach = pci1723_attach,
+ .detach = pci1723_detach,
+};
+
+static int __devinit adv_pci1723_pci_probe(struct pci_dev *dev,
+ const struct pci_device_id *ent)
{
- return comedi_pci_auto_config(dev, driver_pci1723.driver_name);
+ return comedi_pci_auto_config(dev, &adv_pci1723_driver);
}
-static void __devexit driver_pci1723_pci_remove(struct pci_dev *dev)
+static void __devexit adv_pci1723_pci_remove(struct pci_dev *dev)
{
comedi_pci_auto_unconfig(dev);
}
-static struct pci_driver driver_pci1723_pci_driver = {
- .id_table = pci1723_pci_table,
- .probe = &driver_pci1723_pci_probe,
- .remove = __devexit_p(&driver_pci1723_pci_remove)
+static DEFINE_PCI_DEVICE_TABLE(adv_pci1723_pci_table) = {
+ { PCI_DEVICE(PCI_VENDOR_ID_ADVANTECH, 0x1723) },
+ { 0 }
};
+MODULE_DEVICE_TABLE(pci, adv_pci1723_pci_table);
-static int __init driver_pci1723_init_module(void)
-{
- int retval;
-
- retval = comedi_driver_register(&driver_pci1723);
- if (retval < 0)
- return retval;
-
- driver_pci1723_pci_driver.name = (char *)driver_pci1723.driver_name;
- return pci_register_driver(&driver_pci1723_pci_driver);
-}
-
-static void __exit driver_pci1723_cleanup_module(void)
-{
- pci_unregister_driver(&driver_pci1723_pci_driver);
- comedi_driver_unregister(&driver_pci1723);
-}
-
-module_init(driver_pci1723_init_module);
-module_exit(driver_pci1723_cleanup_module);
+static struct pci_driver adv_pci1723_pci_driver = {
+ .name = "adv_pci1723",
+ .id_table = adv_pci1723_pci_table,
+ .probe = adv_pci1723_pci_probe,
+ .remove = __devexit_p(adv_pci1723_pci_remove),
+};
+module_comedi_pci_driver(adv_pci1723_driver, adv_pci1723_pci_driver);
MODULE_AUTHOR("Comedi http://www.comedi.org");
MODULE_DESCRIPTION("Comedi low-level driver");
diff --git a/drivers/staging/comedi/drivers/adv_pci_dio.c b/drivers/staging/comedi/drivers/adv_pci_dio.c
index 7af068f4a749..97f06dc8e48d 100644
--- a/drivers/staging/comedi/drivers/adv_pci_dio.c
+++ b/drivers/staging/comedi/drivers/adv_pci_dio.c
@@ -33,7 +33,6 @@ Configuration options:
#include <linux/delay.h>
-#include "comedi_pci.h"
#include "8255.h"
#include "8253.h"
@@ -237,10 +236,6 @@ enum hw_io_access {
#define OMBCMD_RETRY 0x03 /* 3 times try request before error */
-static int pci_dio_attach(struct comedi_device *dev,
- struct comedi_devconfig *it);
-static int pci_dio_detach(struct comedi_device *dev);
-
struct diosubd_data {
int chans; /* num of chans */
int addr; /* PCI address ofset */
@@ -263,26 +258,6 @@ struct dio_boardtype {
enum hw_io_access io_access;
};
-static DEFINE_PCI_DEVICE_TABLE(pci_dio_pci_table) = {
- { PCI_DEVICE(PCI_VENDOR_ID_ADVANTECH, 0x1730) },
- { PCI_DEVICE(PCI_VENDOR_ID_ADVANTECH, 0x1733) },
- { PCI_DEVICE(PCI_VENDOR_ID_ADVANTECH, 0x1734) },
- { PCI_DEVICE(PCI_VENDOR_ID_ADVANTECH, 0x1735) },
- { PCI_DEVICE(PCI_VENDOR_ID_ADVANTECH, 0x1736) },
- { PCI_DEVICE(PCI_VENDOR_ID_ADVANTECH, 0x1739) },
- { PCI_DEVICE(PCI_VENDOR_ID_ADVANTECH, 0x1750) },
- { PCI_DEVICE(PCI_VENDOR_ID_ADVANTECH, 0x1751) },
- { PCI_DEVICE(PCI_VENDOR_ID_ADVANTECH, 0x1752) },
- { PCI_DEVICE(PCI_VENDOR_ID_ADVANTECH, 0x1753) },
- { PCI_DEVICE(PCI_VENDOR_ID_ADVANTECH, 0x1754) },
- { PCI_DEVICE(PCI_VENDOR_ID_ADVANTECH, 0x1756) },
- { PCI_DEVICE(PCI_VENDOR_ID_ADVANTECH, 0x1760) },
- { PCI_DEVICE(PCI_VENDOR_ID_ADVANTECH, 0x1762) },
- { 0 }
-};
-
-MODULE_DEVICE_TABLE(pci, pci_dio_pci_table);
-
static const struct dio_boardtype boardtypes[] = {
{"pci1730", PCI_VENDOR_ID_ADVANTECH, 0x1730, PCIDIO_MAINREG,
TYPE_PCI1730,
@@ -406,19 +381,7 @@ static const struct dio_boardtype boardtypes[] = {
IO_16b}
};
-#define n_boardtypes (sizeof(boardtypes)/sizeof(struct dio_boardtype))
-
-static struct comedi_driver driver_pci_dio = {
- .driver_name = "adv_pci_dio",
- .module = THIS_MODULE,
- .attach = pci_dio_attach,
- .detach = pci_dio_detach
-};
-
struct pci_dio_private {
- struct pci_dio_private *prev; /* previous private struct */
- struct pci_dio_private *next; /* next private struct */
- struct pci_dev *pcidev; /* pointer to board's pci_dev */
char valid; /* card is usable */
char GlobalIrqEnabled; /* 1= any IRQ source is enabled */
/* PCI-1760 specific data */
@@ -438,8 +401,6 @@ struct pci_dio_private {
unsigned short IDIFiltrHigh[8]; /* IDI's filter value high signal */
};
-static struct pci_dio_private *pci_priv; /* list of allocated cards */
-
#define devpriv ((struct pci_dio_private *)dev->private)
#define this_board ((const struct dio_boardtype *)dev->board_ptr)
@@ -458,7 +419,7 @@ static int pci_dio_insn_bits_di_b(struct comedi_device *dev,
data[1] |= inb(dev->iobase + d->addr + i) << (8 * i);
- return 2;
+ return insn->n;
}
/*
@@ -475,7 +436,7 @@ static int pci_dio_insn_bits_di_w(struct comedi_device *dev,
for (i = 0; i < d->regs; i++)
data[1] |= inw(dev->iobase + d->addr + 2 * i) << (16 * i);
- return 2;
+ return insn->n;
}
/*
@@ -497,7 +458,7 @@ static int pci_dio_insn_bits_do_b(struct comedi_device *dev,
}
data[1] = s->state;
- return 2;
+ return insn->n;
}
/*
@@ -519,7 +480,7 @@ static int pci_dio_insn_bits_do_w(struct comedi_device *dev,
}
data[1] = s->state;
- return 2;
+ return insn->n;
}
/*
@@ -668,7 +629,7 @@ static int pci1760_insn_bits_di(struct comedi_device *dev,
{
data[1] = inb(dev->iobase + IMB3);
- return 2;
+ return insn->n;
}
/*
@@ -697,7 +658,7 @@ static int pci1760_insn_bits_do(struct comedi_device *dev,
}
data[1] = s->state;
- return 2;
+ return insn->n;
}
/*
@@ -1089,89 +1050,60 @@ static int pci_dio_add_8254(struct comedi_device *dev,
return 0;
}
-/*
-==============================================================================
-*/
-static int CheckAndAllocCard(struct comedi_device *dev,
- struct comedi_devconfig *it,
- struct pci_dev *pcidev)
+static struct pci_dev *pci_dio_find_pci_dev(struct comedi_device *dev,
+ struct comedi_devconfig *it)
{
- struct pci_dio_private *pr, *prev;
-
- for (pr = pci_priv, prev = NULL; pr != NULL; prev = pr, pr = pr->next) {
- if (pr->pcidev == pcidev)
- return 0; /* this card is used, look for another */
-
- }
+ struct pci_dev *pcidev = NULL;
+ int bus = it->options[0];
+ int slot = it->options[1];
+ int i;
- if (prev) {
- devpriv->prev = prev;
- prev->next = devpriv;
- } else {
- pci_priv = devpriv;
+ for_each_pci_dev(pcidev) {
+ if (bus || slot) {
+ if (bus != pcidev->bus->number ||
+ slot != PCI_SLOT(pcidev->devfn))
+ continue;
+ }
+ if (pci_is_enabled(pcidev))
+ continue;
+ for (i = 0; i < ARRAY_SIZE(boardtypes); ++i) {
+ if (boardtypes[i].vendor_id != pcidev->vendor)
+ continue;
+ if (boardtypes[i].device_id != pcidev->device)
+ continue;
+ dev->board_ptr = boardtypes + i;
+ return pcidev;
+ }
}
-
- devpriv->pcidev = pcidev;
-
- return 1;
+ dev_err(dev->class_dev,
+ "No supported board found! (req. bus %d, slot %d)\n",
+ bus, slot);
+ return NULL;
}
-/*
-==============================================================================
-*/
static int pci_dio_attach(struct comedi_device *dev,
struct comedi_devconfig *it)
{
+ struct pci_dev *pcidev;
struct comedi_subdevice *s;
int ret, subdev, n_subdevices, i, j;
- unsigned long iobase;
- struct pci_dev *pcidev = NULL;
-
ret = alloc_private(dev, sizeof(struct pci_dio_private));
if (ret < 0)
return -ENOMEM;
- for_each_pci_dev(pcidev) {
- /* loop through cards supported by this driver */
- for (i = 0; i < n_boardtypes; ++i) {
- if (boardtypes[i].vendor_id != pcidev->vendor)
- continue;
- if (boardtypes[i].device_id != pcidev->device)
- continue;
- /* was a particular bus/slot requested? */
- if (it->options[0] || it->options[1]) {
- /* are we on the wrong bus/slot? */
- if (pcidev->bus->number != it->options[0] ||
- PCI_SLOT(pcidev->devfn) != it->options[1]) {
- continue;
- }
- }
- ret = CheckAndAllocCard(dev, it, pcidev);
- if (ret != 1)
- continue;
- dev->board_ptr = boardtypes + i;
- break;
- }
- if (dev->board_ptr)
- break;
- }
-
- if (!dev->board_ptr) {
- dev_err(dev->hw_dev, "Error: Requested type of the card was not found!\n");
+ pcidev = pci_dio_find_pci_dev(dev, it);
+ if (!pcidev)
return -EIO;
- }
+ comedi_set_hw_dev(dev, &pcidev->dev);
- if (comedi_pci_enable(pcidev, driver_pci_dio.driver_name)) {
- dev_err(dev->hw_dev, "Error: Can't enable PCI device and request regions!\n");
+ if (comedi_pci_enable(pcidev, dev->driver->driver_name)) {
+ dev_err(dev->class_dev,
+ "Error: Can't enable PCI device and request regions!\n");
return -EIO;
}
- iobase = pci_resource_start(pcidev, this_board->main_pci_region);
- dev_dbg(dev->hw_dev, "b:s:f=%d:%d:%d, io=0x%4lx\n",
- pcidev->bus->number, PCI_SLOT(pcidev->devfn),
- PCI_FUNC(pcidev->devfn), iobase);
- dev->iobase = iobase;
+ dev->iobase = pci_resource_start(pcidev, this_board->main_pci_region);
dev->board_name = this_board->name;
if (this_board->cardtype == TYPE_PCI1760) {
@@ -1193,8 +1125,8 @@ static int pci_dio_attach(struct comedi_device *dev,
n_subdevices++;
}
- ret = alloc_subdevices(dev, n_subdevices);
- if (ret < 0)
+ ret = comedi_alloc_subdevices(dev, n_subdevices);
+ if (ret)
return ret;
subdev = 0;
@@ -1246,11 +1178,9 @@ static int pci_dio_attach(struct comedi_device *dev,
return 0;
}
-/*
-==============================================================================
-*/
-static int pci_dio_detach(struct comedi_device *dev)
+static void pci_dio_detach(struct comedi_device *dev)
{
+ struct pci_dev *pcidev = comedi_to_pci_dev(dev);
int i, j;
struct comedi_subdevice *s;
int subdev;
@@ -1258,20 +1188,14 @@ static int pci_dio_detach(struct comedi_device *dev)
if (dev->private) {
if (devpriv->valid)
pci_dio_reset(dev);
-
-
- /* This shows the silliness of using this kind of
- * scheme for numbering subdevices. Don't do it. --ds */
subdev = 0;
for (i = 0; i < MAX_DI_SUBDEVS; i++) {
if (this_board->sdi[i].chans)
subdev++;
-
}
for (i = 0; i < MAX_DO_SUBDEVS; i++) {
if (this_board->sdo[i].chans)
subdev++;
-
}
for (i = 0; i < MAX_DIO_SUBDEVG; i++) {
for (j = 0; j < this_board->sdio[i].regs; j++) {
@@ -1280,82 +1204,67 @@ static int pci_dio_detach(struct comedi_device *dev)
subdev++;
}
}
-
if (this_board->boardid.chans)
subdev++;
-
for (i = 0; i < MAX_8254_SUBDEVS; i++)
if (this_board->s8254[i].chans)
subdev++;
-
for (i = 0; i < dev->n_subdevices; i++) {
s = dev->subdevices + i;
s->private = NULL;
}
-
- if (devpriv->pcidev) {
- if (dev->iobase)
- comedi_pci_disable(devpriv->pcidev);
-
- pci_dev_put(devpriv->pcidev);
- }
-
- if (devpriv->prev)
- devpriv->prev->next = devpriv->next;
- else
- pci_priv = devpriv->next;
-
- if (devpriv->next)
- devpriv->next->prev = devpriv->prev;
-
}
-
- return 0;
+ if (pcidev) {
+ if (dev->iobase)
+ comedi_pci_disable(pcidev);
+ pci_dev_put(pcidev);
+ }
}
-/*
-==============================================================================
-*/
-static int __devinit driver_pci_dio_pci_probe(struct pci_dev *dev,
- const struct pci_device_id *ent)
+static struct comedi_driver adv_pci_dio_driver = {
+ .driver_name = "adv_pci_dio",
+ .module = THIS_MODULE,
+ .attach = pci_dio_attach,
+ .detach = pci_dio_detach
+};
+
+static int __devinit adv_pci_dio_pci_probe(struct pci_dev *dev,
+ const struct pci_device_id *ent)
{
- return comedi_pci_auto_config(dev, driver_pci_dio.driver_name);
+ return comedi_pci_auto_config(dev, &adv_pci_dio_driver);
}
-static void __devexit driver_pci_dio_pci_remove(struct pci_dev *dev)
+static void __devexit adv_pci_dio_pci_remove(struct pci_dev *dev)
{
comedi_pci_auto_unconfig(dev);
}
-static struct pci_driver driver_pci_dio_pci_driver = {
- .id_table = pci_dio_pci_table,
- .probe = &driver_pci_dio_pci_probe,
- .remove = __devexit_p(&driver_pci_dio_pci_remove)
+static DEFINE_PCI_DEVICE_TABLE(adv_pci_dio_pci_table) = {
+ { PCI_DEVICE(PCI_VENDOR_ID_ADVANTECH, 0x1730) },
+ { PCI_DEVICE(PCI_VENDOR_ID_ADVANTECH, 0x1733) },
+ { PCI_DEVICE(PCI_VENDOR_ID_ADVANTECH, 0x1734) },
+ { PCI_DEVICE(PCI_VENDOR_ID_ADVANTECH, 0x1735) },
+ { PCI_DEVICE(PCI_VENDOR_ID_ADVANTECH, 0x1736) },
+ { PCI_DEVICE(PCI_VENDOR_ID_ADVANTECH, 0x1739) },
+ { PCI_DEVICE(PCI_VENDOR_ID_ADVANTECH, 0x1750) },
+ { PCI_DEVICE(PCI_VENDOR_ID_ADVANTECH, 0x1751) },
+ { PCI_DEVICE(PCI_VENDOR_ID_ADVANTECH, 0x1752) },
+ { PCI_DEVICE(PCI_VENDOR_ID_ADVANTECH, 0x1753) },
+ { PCI_DEVICE(PCI_VENDOR_ID_ADVANTECH, 0x1754) },
+ { PCI_DEVICE(PCI_VENDOR_ID_ADVANTECH, 0x1756) },
+ { PCI_DEVICE(PCI_VENDOR_ID_ADVANTECH, 0x1760) },
+ { PCI_DEVICE(PCI_VENDOR_ID_ADVANTECH, 0x1762) },
+ { 0 }
};
+MODULE_DEVICE_TABLE(pci, adv_pci_dio_pci_table);
-static int __init driver_pci_dio_init_module(void)
-{
- int retval;
-
- retval = comedi_driver_register(&driver_pci_dio);
- if (retval < 0)
- return retval;
-
- driver_pci_dio_pci_driver.name = (char *)driver_pci_dio.driver_name;
- return pci_register_driver(&driver_pci_dio_pci_driver);
-}
-
-static void __exit driver_pci_dio_cleanup_module(void)
-{
- pci_unregister_driver(&driver_pci_dio_pci_driver);
- comedi_driver_unregister(&driver_pci_dio);
-}
-
-module_init(driver_pci_dio_init_module);
-module_exit(driver_pci_dio_cleanup_module);
-/*
-==============================================================================
-*/
+static struct pci_driver adv_pci_dio_pci_driver = {
+ .name = "adv_pci_dio",
+ .id_table = adv_pci_dio_pci_table,
+ .probe = adv_pci_dio_pci_probe,
+ .remove = __devexit_p(adv_pci_dio_pci_remove),
+};
+module_comedi_pci_driver(adv_pci_dio_driver, adv_pci_dio_pci_driver);
MODULE_AUTHOR("Comedi http://www.comedi.org");
MODULE_DESCRIPTION("Comedi low-level driver");
diff --git a/drivers/staging/comedi/drivers/aio_aio12_8.c b/drivers/staging/comedi/drivers/aio_aio12_8.c
index b0f98e5e4bf3..f7d453f8fe33 100644
--- a/drivers/staging/comedi/drivers/aio_aio12_8.c
+++ b/drivers/staging/comedi/drivers/aio_aio12_8.c
@@ -80,8 +80,6 @@ static const struct aio12_8_boardtype board_types[] = {
.name = "aio_aio12_8"},
};
-#define thisboard ((const struct aio12_8_boardtype *) dev->board_ptr)
-
struct aio12_8_private {
unsigned int ao_readback[4];
};
@@ -167,8 +165,10 @@ static const struct comedi_lrange range_aio_aio12_8 = {
static int aio_aio12_8_attach(struct comedi_device *dev,
struct comedi_devconfig *it)
{
+ const struct aio12_8_boardtype *board = comedi_board(dev);
int iobase;
struct comedi_subdevice *s;
+ int ret;
iobase = it->options[0];
if (!request_region(iobase, 24, "aio_aio12_8")) {
@@ -176,15 +176,16 @@ static int aio_aio12_8_attach(struct comedi_device *dev,
return -EIO;
}
- dev->board_name = thisboard->name;
+ dev->board_name = board->name;
dev->iobase = iobase;
if (alloc_private(dev, sizeof(struct aio12_8_private)) < 0)
return -ENOMEM;
- if (alloc_subdevices(dev, 3) < 0)
- return -ENOMEM;
+ ret = comedi_alloc_subdevices(dev, 3);
+ if (ret)
+ return ret;
s = &dev->subdevices[0];
s->type = COMEDI_SUBD_AI;
@@ -209,36 +210,23 @@ static int aio_aio12_8_attach(struct comedi_device *dev,
return 0;
}
-static int aio_aio12_8_detach(struct comedi_device *dev)
+static void aio_aio12_8_detach(struct comedi_device *dev)
{
subdev_8255_cleanup(dev, &dev->subdevices[2]);
if (dev->iobase)
release_region(dev->iobase, 24);
- return 0;
}
-static struct comedi_driver driver_aio_aio12_8 = {
- .driver_name = "aio_aio12_8",
- .module = THIS_MODULE,
- .attach = aio_aio12_8_attach,
- .detach = aio_aio12_8_detach,
- .board_name = &board_types[0].name,
- .num_names = 1,
- .offset = sizeof(struct aio12_8_boardtype),
+static struct comedi_driver aio_aio12_8_driver = {
+ .driver_name = "aio_aio12_8",
+ .module = THIS_MODULE,
+ .attach = aio_aio12_8_attach,
+ .detach = aio_aio12_8_detach,
+ .board_name = &board_types[0].name,
+ .num_names = ARRAY_SIZE(board_types),
+ .offset = sizeof(struct aio12_8_boardtype),
};
-
-static int __init driver_aio_aio12_8_init_module(void)
-{
- return comedi_driver_register(&driver_aio_aio12_8);
-}
-
-static void __exit driver_aio_aio12_8_cleanup_module(void)
-{
- comedi_driver_unregister(&driver_aio_aio12_8);
-}
-
-module_init(driver_aio_aio12_8_init_module);
-module_exit(driver_aio_aio12_8_cleanup_module);
+module_comedi_driver(aio_aio12_8_driver);
MODULE_AUTHOR("Comedi http://www.comedi.org");
MODULE_DESCRIPTION("Comedi low-level driver");
diff --git a/drivers/staging/comedi/drivers/aio_iiro_16.c b/drivers/staging/comedi/drivers/aio_iiro_16.c
index 160b0a0f4f1e..ba1e3bbf2df8 100644
--- a/drivers/staging/comedi/drivers/aio_iiro_16.c
+++ b/drivers/staging/comedi/drivers/aio_iiro_16.c
@@ -57,50 +57,47 @@ static const struct aio_iiro_16_board aio_iiro_16_boards[] = {
.do_ = 16},
};
-#define thisboard ((const struct aio_iiro_16_board *) dev->board_ptr)
-
-struct aio_iiro_16_private {
- int data;
- struct pci_dev *pci_dev;
- unsigned int ao_readback[2];
-};
+static int aio_iiro_16_dio_insn_bits_write(struct comedi_device *dev,
+ struct comedi_subdevice *s,
+ struct comedi_insn *insn,
+ unsigned int *data)
+{
+ if (data[0]) {
+ s->state &= ~data[0];
+ s->state |= data[0] & data[1];
+ outb(s->state & 0xff, dev->iobase + AIO_IIRO_16_RELAY_0_7);
+ outb((s->state >> 8) & 0xff,
+ dev->iobase + AIO_IIRO_16_RELAY_8_15);
+ }
-#define devpriv ((struct aio_iiro_16_private *) dev->private)
+ data[1] = s->state;
-static int aio_iiro_16_attach(struct comedi_device *dev,
- struct comedi_devconfig *it);
-
-static int aio_iiro_16_detach(struct comedi_device *dev);
-
-static struct comedi_driver driver_aio_iiro_16 = {
- .driver_name = "aio_iiro_16",
- .module = THIS_MODULE,
- .attach = aio_iiro_16_attach,
- .detach = aio_iiro_16_detach,
- .board_name = &aio_iiro_16_boards[0].name,
- .offset = sizeof(struct aio_iiro_16_board),
- .num_names = ARRAY_SIZE(aio_iiro_16_boards),
-};
+ return insn->n;
+}
static int aio_iiro_16_dio_insn_bits_read(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn,
- unsigned int *data);
+ unsigned int *data)
+{
+ data[1] = 0;
+ data[1] |= inb(dev->iobase + AIO_IIRO_16_INPUT_0_7);
+ data[1] |= inb(dev->iobase + AIO_IIRO_16_INPUT_8_15) << 8;
-static int aio_iiro_16_dio_insn_bits_write(struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_insn *insn,
- unsigned int *data);
+ return insn->n;
+}
static int aio_iiro_16_attach(struct comedi_device *dev,
struct comedi_devconfig *it)
{
+ const struct aio_iiro_16_board *board = comedi_board(dev);
int iobase;
struct comedi_subdevice *s;
+ int ret;
printk(KERN_INFO "comedi%d: aio_iiro_16: ", dev->minor);
- dev->board_name = thisboard->name;
+ dev->board_name = board->name;
iobase = it->options[0];
@@ -111,11 +108,9 @@ static int aio_iiro_16_attach(struct comedi_device *dev,
dev->iobase = iobase;
- if (alloc_private(dev, sizeof(struct aio_iiro_16_private)) < 0)
- return -ENOMEM;
-
- if (alloc_subdevices(dev, 2) < 0)
- return -ENOMEM;
+ ret = comedi_alloc_subdevices(dev, 2);
+ if (ret)
+ return ret;
s = dev->subdevices + 0;
s->type = COMEDI_SUBD_DIO;
@@ -138,64 +133,22 @@ static int aio_iiro_16_attach(struct comedi_device *dev,
return 1;
}
-static int aio_iiro_16_detach(struct comedi_device *dev)
+static void aio_iiro_16_detach(struct comedi_device *dev)
{
- printk(KERN_INFO "comedi%d: aio_iiro_16: remove\n", dev->minor);
-
if (dev->iobase)
release_region(dev->iobase, AIO_IIRO_16_SIZE);
-
- return 0;
}
-static int aio_iiro_16_dio_insn_bits_write(struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_insn *insn,
- unsigned int *data)
-{
- if (insn->n != 2)
- return -EINVAL;
-
- if (data[0]) {
- s->state &= ~data[0];
- s->state |= data[0] & data[1];
- outb(s->state & 0xff, dev->iobase + AIO_IIRO_16_RELAY_0_7);
- outb((s->state >> 8) & 0xff,
- dev->iobase + AIO_IIRO_16_RELAY_8_15);
- }
-
- data[1] = s->state;
-
- return 2;
-}
-
-static int aio_iiro_16_dio_insn_bits_read(struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_insn *insn,
- unsigned int *data)
-{
- if (insn->n != 2)
- return -EINVAL;
-
- data[1] = 0;
- data[1] |= inb(dev->iobase + AIO_IIRO_16_INPUT_0_7);
- data[1] |= inb(dev->iobase + AIO_IIRO_16_INPUT_8_15) << 8;
-
- return 2;
-}
-
-static int __init driver_aio_iiro_16_init_module(void)
-{
- return comedi_driver_register(&driver_aio_iiro_16);
-}
-
-static void __exit driver_aio_iiro_16_cleanup_module(void)
-{
- comedi_driver_unregister(&driver_aio_iiro_16);
-}
-
-module_init(driver_aio_iiro_16_init_module);
-module_exit(driver_aio_iiro_16_cleanup_module);
+static struct comedi_driver aio_iiro_16_driver = {
+ .driver_name = "aio_iiro_16",
+ .module = THIS_MODULE,
+ .attach = aio_iiro_16_attach,
+ .detach = aio_iiro_16_detach,
+ .board_name = &aio_iiro_16_boards[0].name,
+ .offset = sizeof(struct aio_iiro_16_board),
+ .num_names = ARRAY_SIZE(aio_iiro_16_boards),
+};
+module_comedi_driver(aio_iiro_16_driver);
MODULE_AUTHOR("Comedi http://www.comedi.org");
MODULE_DESCRIPTION("Comedi low-level driver");
diff --git a/drivers/staging/comedi/drivers/amplc_dio200.c b/drivers/staging/comedi/drivers/amplc_dio200.c
index 566cc4411452..6c81e377262c 100644
--- a/drivers/staging/comedi/drivers/amplc_dio200.c
+++ b/drivers/staging/comedi/drivers/amplc_dio200.c
@@ -210,8 +210,6 @@ order they appear in the channel list.
#include "../comedidev.h"
-#include "comedi_pci.h"
-
#include "8255.h"
#include "8253.h"
@@ -274,10 +272,14 @@ enum dio200_model {
};
enum dio200_layout {
+#if IS_ENABLED(CONFIG_COMEDI_AMPLC_DIO200_ISA)
pc212_layout,
pc214_layout,
+#endif
pc215_layout,
+#if IS_ENABLED(CONFIG_COMEDI_AMPLC_DIO200_ISA)
pc218_layout,
+#endif
pc272_layout
};
@@ -290,6 +292,7 @@ struct dio200_board {
};
static const struct dio200_board dio200_boards[] = {
+#if IS_ENABLED(CONFIG_COMEDI_AMPLC_DIO200_ISA)
{
.name = "pc212e",
.bustype = isa_bustype,
@@ -308,15 +311,6 @@ static const struct dio200_board dio200_boards[] = {
.model = pc215e_model,
.layout = pc215_layout,
},
-#ifdef CONFIG_COMEDI_PCI
- {
- .name = "pci215",
- .devid = PCI_DEVICE_ID_AMPLICON_PCI215,
- .bustype = pci_bustype,
- .model = pci215_model,
- .layout = pc215_layout,
- },
-#endif
{
.name = "pc218e",
.bustype = isa_bustype,
@@ -329,7 +323,15 @@ static const struct dio200_board dio200_boards[] = {
.model = pc272e_model,
.layout = pc272_layout,
},
-#ifdef CONFIG_COMEDI_PCI
+#endif
+#if IS_ENABLED(CONFIG_COMEDI_AMPLC_DIO200_PCI)
+ {
+ .name = "pci215",
+ .devid = PCI_DEVICE_ID_AMPLICON_PCI215,
+ .bustype = pci_bustype,
+ .model = pci215_model,
+ .layout = pc215_layout,
+ },
{
.name = "pci272",
.devid = PCI_DEVICE_ID_AMPLICON_PCI272,
@@ -337,8 +339,6 @@ static const struct dio200_board dio200_boards[] = {
.model = pci272_model,
.layout = pc272_layout,
},
-#endif
-#ifdef CONFIG_COMEDI_PCI
{
.name = DIO200_DRIVER_NAME,
.devid = PCI_DEVICE_ID_INVALID,
@@ -367,6 +367,7 @@ struct dio200_layout_struct {
};
static const struct dio200_layout_struct dio200_layouts[] = {
+#if IS_ENABLED(CONFIG_COMEDI_AMPLC_DIO200_ISA)
[pc212_layout] = {
.n_subdevs = 6,
.sdtype = {sd_8255, sd_8254, sd_8254, sd_8254,
@@ -385,6 +386,7 @@ static const struct dio200_layout_struct dio200_layouts[] = {
.has_int_sce = 0,
.has_clk_gat_sce = 0,
},
+#endif
[pc215_layout] = {
.n_subdevs = 5,
.sdtype = {sd_8255, sd_8255, sd_8254,
@@ -394,6 +396,7 @@ static const struct dio200_layout_struct dio200_layouts[] = {
.has_int_sce = 1,
.has_clk_gat_sce = 1,
},
+#if IS_ENABLED(CONFIG_COMEDI_AMPLC_DIO200_ISA)
[pc218_layout] = {
.n_subdevs = 7,
.sdtype = {sd_8254, sd_8254, sd_8255, sd_8254,
@@ -405,6 +408,7 @@ static const struct dio200_layout_struct dio200_layouts[] = {
.has_int_sce = 1,
.has_clk_gat_sce = 1,
},
+#endif
[pc272_layout] = {
.n_subdevs = 4,
.sdtype = {sd_8255, sd_8255, sd_8255,
@@ -415,40 +419,14 @@ static const struct dio200_layout_struct dio200_layouts[] = {
},
};
-/*
- * PCI driver table.
- */
-
-#ifdef CONFIG_COMEDI_PCI
-static DEFINE_PCI_DEVICE_TABLE(dio200_pci_table) = {
- { PCI_DEVICE(PCI_VENDOR_ID_AMPLICON, PCI_DEVICE_ID_AMPLICON_PCI215) },
- { PCI_DEVICE(PCI_VENDOR_ID_AMPLICON, PCI_DEVICE_ID_AMPLICON_PCI272) },
- {0}
-};
-
-MODULE_DEVICE_TABLE(pci, dio200_pci_table);
-#endif /* CONFIG_COMEDI_PCI */
-
-/*
- * Useful for shorthand access to the particular board structure
- */
-#define thisboard ((const struct dio200_board *)dev->board_ptr)
-#define thislayout (&dio200_layouts[((struct dio200_board *) \
- dev->board_ptr)->layout])
-
/* this structure is for data unique to this hardware driver. If
several hardware drivers keep similar information in this structure,
feel free to suggest moving the variable to the struct comedi_device struct.
*/
struct dio200_private {
-#ifdef CONFIG_COMEDI_PCI
- struct pci_dev *pci_dev; /* PCI device */
-#endif
int intr_sd;
};
-#define devpriv ((struct dio200_private *)dev->private)
-
struct dio200_subdev_8254 {
unsigned long iobase; /* Counter base address */
unsigned long clk_sce_iobase; /* CLK_SCE base address */
@@ -472,151 +450,74 @@ struct dio200_subdev_intr {
};
/*
- * The struct comedi_driver structure tells the Comedi core module
- * which functions to call to configure/deconfigure (attach/detach)
- * the board, and also about the kernel module that contains
- * the device code.
+ * This function looks for a board matching the supplied PCI device.
*/
-static int dio200_attach(struct comedi_device *dev,
- struct comedi_devconfig *it);
-static int dio200_detach(struct comedi_device *dev);
-static struct comedi_driver driver_amplc_dio200 = {
- .driver_name = DIO200_DRIVER_NAME,
- .module = THIS_MODULE,
- .attach = dio200_attach,
- .detach = dio200_detach,
- .board_name = &dio200_boards[0].name,
- .offset = sizeof(struct dio200_board),
- .num_names = ARRAY_SIZE(dio200_boards),
-};
-
-#ifdef CONFIG_COMEDI_PCI
-static int __devinit driver_amplc_dio200_pci_probe(struct pci_dev *dev,
- const struct pci_device_id
- *ent)
-{
- return comedi_pci_auto_config(dev, driver_amplc_dio200.driver_name);
-}
-
-static void __devexit driver_amplc_dio200_pci_remove(struct pci_dev *dev)
-{
- comedi_pci_auto_unconfig(dev);
-}
-
-static struct pci_driver driver_amplc_dio200_pci_driver = {
- .id_table = dio200_pci_table,
- .probe = &driver_amplc_dio200_pci_probe,
- .remove = __devexit_p(&driver_amplc_dio200_pci_remove)
-};
-
-static int __init driver_amplc_dio200_init_module(void)
+static const struct dio200_board *
+dio200_find_pci_board(struct pci_dev *pci_dev)
{
- int retval;
+ unsigned int i;
- retval = comedi_driver_register(&driver_amplc_dio200);
- if (retval < 0)
- return retval;
-
- driver_amplc_dio200_pci_driver.name =
- (char *)driver_amplc_dio200.driver_name;
- return pci_register_driver(&driver_amplc_dio200_pci_driver);
-}
-
-static void __exit driver_amplc_dio200_cleanup_module(void)
-{
- pci_unregister_driver(&driver_amplc_dio200_pci_driver);
- comedi_driver_unregister(&driver_amplc_dio200);
-}
-
-module_init(driver_amplc_dio200_init_module);
-module_exit(driver_amplc_dio200_cleanup_module);
-#else
-static int __init driver_amplc_dio200_init_module(void)
-{
- return comedi_driver_register(&driver_amplc_dio200);
-}
-
-static void __exit driver_amplc_dio200_cleanup_module(void)
-{
- comedi_driver_unregister(&driver_amplc_dio200);
+ for (i = 0; i < ARRAY_SIZE(dio200_boards); i++)
+ if (dio200_boards[i].bustype == pci_bustype &&
+ pci_dev->device == dio200_boards[i].devid)
+ return &dio200_boards[i];
+ return NULL;
}
-module_init(driver_amplc_dio200_init_module);
-module_exit(driver_amplc_dio200_cleanup_module);
-#endif
-
/*
* This function looks for a PCI device matching the requested board name,
* bus and slot.
*/
-#ifdef CONFIG_COMEDI_PCI
-static int
-dio200_find_pci(struct comedi_device *dev, int bus, int slot,
- struct pci_dev **pci_dev_p)
+static struct pci_dev *dio200_find_pci_dev(struct comedi_device *dev,
+ struct comedi_devconfig *it)
{
+ const struct dio200_board *thisboard = comedi_board(dev);
struct pci_dev *pci_dev = NULL;
+ int bus = it->options[0];
+ int slot = it->options[1];
- *pci_dev_p = NULL;
-
- /* Look for matching PCI device. */
- for (pci_dev = pci_get_device(PCI_VENDOR_ID_AMPLICON, PCI_ANY_ID, NULL);
- pci_dev != NULL;
- pci_dev = pci_get_device(PCI_VENDOR_ID_AMPLICON,
- PCI_ANY_ID, pci_dev)) {
- /* If bus/slot specified, check them. */
+ for_each_pci_dev(pci_dev) {
if (bus || slot) {
- if (bus != pci_dev->bus->number
- || slot != PCI_SLOT(pci_dev->devfn))
+ if (bus != pci_dev->bus->number ||
+ slot != PCI_SLOT(pci_dev->devfn))
continue;
}
+ if (pci_dev->vendor != PCI_VENDOR_ID_AMPLICON)
+ continue;
+
if (thisboard->model == anypci_model) {
- /* Match any supported model. */
- int i;
-
- for (i = 0; i < ARRAY_SIZE(dio200_boards); i++) {
- if (dio200_boards[i].bustype != pci_bustype)
- continue;
- if (pci_dev->device == dio200_boards[i].devid) {
- /* Change board_ptr to matched board. */
- dev->board_ptr = &dio200_boards[i];
- break;
- }
- }
- if (i == ARRAY_SIZE(dio200_boards))
+ /* Wildcard board matches any supported PCI board. */
+ const struct dio200_board *foundboard;
+
+ foundboard = dio200_find_pci_board(pci_dev);
+ if (foundboard == NULL)
continue;
+ /* Replace wildcard board_ptr. */
+ dev->board_ptr = foundboard;
} else {
/* Match specific model name. */
if (pci_dev->device != thisboard->devid)
continue;
}
-
- /* Found a match. */
- *pci_dev_p = pci_dev;
- return 0;
- }
- /* No match found. */
- if (bus || slot) {
- printk(KERN_ERR
- "comedi%d: error! no %s found at pci %02x:%02x!\n",
- dev->minor, thisboard->name, bus, slot);
- } else {
- printk(KERN_ERR "comedi%d: error! no %s found!\n",
- dev->minor, thisboard->name);
+ return pci_dev;
}
- return -EIO;
+ dev_err(dev->class_dev,
+ "No supported board found! (req. bus %d, slot %d)\n",
+ bus, slot);
+ return NULL;
}
-#endif
/*
* This function checks and requests an I/O region, reporting an error
* if there is a conflict.
*/
static int
-dio200_request_region(unsigned minor, unsigned long from, unsigned long extent)
+dio200_request_region(struct comedi_device *dev,
+ unsigned long from, unsigned long extent)
{
if (!from || !request_region(from, extent, DIO200_DRIVER_NAME)) {
- printk(KERN_ERR "comedi%d: I/O port conflict (%#lx,%lu)!\n",
- minor, from, extent);
+ dev_err(dev->class_dev, "I/O port conflict (%#lx,%lu)!\n",
+ from, extent);
return -EIO;
}
return 0;
@@ -640,7 +541,7 @@ dio200_subdev_intr_insn_bits(struct comedi_device *dev,
data[0] = 0;
}
- return 2;
+ return insn->n;
}
/*
@@ -1014,8 +915,7 @@ dio200_subdev_intr_init(struct comedi_device *dev, struct comedi_subdevice *s,
subpriv = kzalloc(sizeof(*subpriv), GFP_KERNEL);
if (!subpriv) {
- printk(KERN_ERR "comedi%d: error! out of memory!\n",
- dev->minor);
+ dev_err(dev->class_dev, "error! out of memory!\n");
return -ENOMEM;
}
subpriv->iobase = iobase;
@@ -1064,6 +964,7 @@ dio200_subdev_intr_cleanup(struct comedi_device *dev,
static irqreturn_t dio200_interrupt(int irq, void *d)
{
struct comedi_device *dev = d;
+ struct dio200_private *devpriv = dev->private;
int handled;
if (!dev->attached)
@@ -1268,8 +1169,7 @@ dio200_subdev_8254_init(struct comedi_device *dev, struct comedi_subdevice *s,
subpriv = kzalloc(sizeof(*subpriv), GFP_KERNEL);
if (!subpriv) {
- printk(KERN_ERR "comedi%d: error! out of memory!\n",
- dev->minor);
+ dev_err(dev->class_dev, "error! out of memory!\n");
return -ENOMEM;
}
@@ -1321,95 +1221,52 @@ dio200_subdev_8254_cleanup(struct comedi_device *dev,
kfree(subpriv);
}
-/*
- * Attach is called by the Comedi core to configure the driver
- * for a particular board. If you specified a board_name array
- * in the driver structure, dev->board_ptr contains that
- * address.
- */
-static int dio200_attach(struct comedi_device *dev, struct comedi_devconfig *it)
+static void dio200_report_attach(struct comedi_device *dev, unsigned int irq)
{
+ const struct dio200_board *thisboard = comedi_board(dev);
+ struct pci_dev *pcidev = comedi_to_pci_dev(dev);
+ char tmpbuf[60];
+ int tmplen;
+
+ if (IS_ENABLED(CONFIG_COMEDI_AMPLC_DIO200_ISA) &&
+ thisboard->bustype == isa_bustype)
+ tmplen = scnprintf(tmpbuf, sizeof(tmpbuf),
+ "(base %#lx) ", dev->iobase);
+ else if (IS_ENABLED(CONFIG_COMEDI_AMPLC_DIO200_PCI) &&
+ thisboard->bustype == pci_bustype)
+ tmplen = scnprintf(tmpbuf, sizeof(tmpbuf),
+ "(pci %s) ", pci_name(pcidev));
+ else
+ tmplen = 0;
+ if (irq)
+ tmplen += scnprintf(&tmpbuf[tmplen], sizeof(tmpbuf) - tmplen,
+ "(irq %u%s) ", irq,
+ (dev->irq ? "" : " UNAVAILABLE"));
+ else
+ tmplen += scnprintf(&tmpbuf[tmplen], sizeof(tmpbuf) - tmplen,
+ "(no irq) ");
+ dev_info(dev->class_dev, "%s %sattached\n", dev->board_name, tmpbuf);
+}
+
+static int dio200_common_attach(struct comedi_device *dev, unsigned long iobase,
+ unsigned int irq, unsigned long req_irq_flags)
+{
+ const struct dio200_board *thisboard = comedi_board(dev);
+ struct dio200_private *devpriv = dev->private;
+ const struct dio200_layout_struct *layout =
+ &dio200_layouts[thisboard->layout];
struct comedi_subdevice *s;
- unsigned long iobase = 0;
- unsigned int irq = 0;
-#ifdef CONFIG_COMEDI_PCI
- struct pci_dev *pci_dev = NULL;
- int bus = 0, slot = 0;
-#endif
- const struct dio200_layout_struct *layout;
- int share_irq = 0;
int sdx;
- unsigned n;
+ unsigned int n;
int ret;
- printk(KERN_DEBUG "comedi%d: %s: attach\n", dev->minor,
- DIO200_DRIVER_NAME);
-
- ret = alloc_private(dev, sizeof(struct dio200_private));
- if (ret < 0) {
- printk(KERN_ERR "comedi%d: error! out of memory!\n",
- dev->minor);
- return ret;
- }
-
- /* Process options. */
- switch (thisboard->bustype) {
- case isa_bustype:
- iobase = it->options[0];
- irq = it->options[1];
- share_irq = 0;
- break;
-#ifdef CONFIG_COMEDI_PCI
- case pci_bustype:
- bus = it->options[0];
- slot = it->options[1];
- share_irq = 1;
-
- ret = dio200_find_pci(dev, bus, slot, &pci_dev);
- if (ret < 0)
- return ret;
- devpriv->pci_dev = pci_dev;
- break;
-#endif
- default:
- printk(KERN_ERR
- "comedi%d: %s: BUG! cannot determine board type!\n",
- dev->minor, DIO200_DRIVER_NAME);
- return -EINVAL;
- break;
- }
-
devpriv->intr_sd = -1;
-
- /* Enable device and reserve I/O spaces. */
-#ifdef CONFIG_COMEDI_PCI
- if (pci_dev) {
- ret = comedi_pci_enable(pci_dev, DIO200_DRIVER_NAME);
- if (ret < 0) {
- printk(KERN_ERR
- "comedi%d: error! cannot enable PCI device and request regions!\n",
- dev->minor);
- return ret;
- }
- iobase = pci_resource_start(pci_dev, 2);
- irq = pci_dev->irq;
- } else
-#endif
- {
- ret = dio200_request_region(dev->minor, iobase, DIO200_IO_SIZE);
- if (ret < 0)
- return ret;
- }
dev->iobase = iobase;
+ dev->board_name = thisboard->name;
- layout = thislayout;
-
- ret = alloc_subdevices(dev, layout->n_subdevs);
- if (ret < 0) {
- printk(KERN_ERR "comedi%d: error! out of memory!\n",
- dev->minor);
+ ret = comedi_alloc_subdevices(dev, layout->n_subdevs);
+ if (ret)
return ret;
- }
for (n = 0; n < dev->n_subdevices; n++) {
s = &dev->subdevices[n];
@@ -1421,7 +1278,6 @@ static int dio200_attach(struct comedi_device *dev, struct comedi_devconfig *it)
layout->has_clk_gat_sce);
if (ret < 0)
return ret;
-
break;
case sd_8255:
/* digital i/o subdevice (8255) */
@@ -1429,7 +1285,6 @@ static int dio200_attach(struct comedi_device *dev, struct comedi_devconfig *it)
iobase + layout->sdinfo[n]);
if (ret < 0)
return ret;
-
break;
case sd_intr:
/* 'INTERRUPT' subdevice */
@@ -1442,7 +1297,6 @@ static int dio200_attach(struct comedi_device *dev, struct comedi_devconfig *it)
has_int_sce);
if (ret < 0)
return ret;
-
devpriv->intr_sd = n;
} else {
s->type = COMEDI_SUBD_UNUSED;
@@ -1453,64 +1307,125 @@ static int dio200_attach(struct comedi_device *dev, struct comedi_devconfig *it)
break;
}
}
-
sdx = devpriv->intr_sd;
if (sdx >= 0 && sdx < dev->n_subdevices)
dev->read_subdev = &dev->subdevices[sdx];
-
- dev->board_name = thisboard->name;
-
if (irq) {
- unsigned long flags = share_irq ? IRQF_SHARED : 0;
-
- if (request_irq(irq, dio200_interrupt, flags,
+ if (request_irq(irq, dio200_interrupt, req_irq_flags,
DIO200_DRIVER_NAME, dev) >= 0) {
dev->irq = irq;
} else {
- printk(KERN_WARNING
- "comedi%d: warning! irq %u unavailable!\n",
- dev->minor, irq);
+ dev_warn(dev->class_dev,
+ "warning! irq %u unavailable!\n", irq);
}
}
+ dio200_report_attach(dev, irq);
+ return 1;
+}
- printk(KERN_INFO "comedi%d: %s ", dev->minor, dev->board_name);
- if (thisboard->bustype == isa_bustype) {
- printk("(base %#lx) ", iobase);
- } else {
-#ifdef CONFIG_COMEDI_PCI
- printk("(pci %s) ", pci_name(pci_dev));
-#endif
+static int dio200_pci_common_attach(struct comedi_device *dev,
+ struct pci_dev *pci_dev)
+{
+ unsigned long iobase;
+ int ret;
+
+ comedi_set_hw_dev(dev, &pci_dev->dev);
+
+ ret = comedi_pci_enable(pci_dev, DIO200_DRIVER_NAME);
+ if (ret < 0) {
+ dev_err(dev->class_dev,
+ "error! cannot enable PCI device and request regions!\n");
+ return ret;
}
- if (irq)
- printk("(irq %u%s) ", irq, (dev->irq ? "" : " UNAVAILABLE"));
- else
- printk("(no irq) ");
+ iobase = pci_resource_start(pci_dev, 2);
+ return dio200_common_attach(dev, iobase, pci_dev->irq, IRQF_SHARED);
+}
- printk("attached\n");
+/*
+ * Attach is called by the Comedi core to configure the driver
+ * for a particular board. If you specified a board_name array
+ * in the driver structure, dev->board_ptr contains that
+ * address.
+ */
+static int dio200_attach(struct comedi_device *dev, struct comedi_devconfig *it)
+{
+ const struct dio200_board *thisboard = comedi_board(dev);
+ int ret;
- return 1;
+ dev_info(dev->class_dev, DIO200_DRIVER_NAME ": attach\n");
+
+ ret = alloc_private(dev, sizeof(struct dio200_private));
+ if (ret < 0) {
+ dev_err(dev->class_dev, "error! out of memory!\n");
+ return ret;
+ }
+
+ /* Process options and reserve resources according to bus type. */
+ if (IS_ENABLED(CONFIG_COMEDI_AMPLC_DIO200_ISA) &&
+ thisboard->bustype == isa_bustype) {
+ unsigned long iobase;
+ unsigned int irq;
+
+ iobase = it->options[0];
+ irq = it->options[1];
+ ret = dio200_request_region(dev, iobase, DIO200_IO_SIZE);
+ if (ret < 0)
+ return ret;
+ return dio200_common_attach(dev, iobase, irq, 0);
+ } else if (IS_ENABLED(CONFIG_COMEDI_AMPLC_DIO200_PCI) &&
+ thisboard->bustype == pci_bustype) {
+ struct pci_dev *pci_dev;
+
+ pci_dev = dio200_find_pci_dev(dev, it);
+ if (!pci_dev)
+ return -EIO;
+ return dio200_pci_common_attach(dev, pci_dev);
+ } else {
+ dev_err(dev->class_dev, DIO200_DRIVER_NAME
+ ": BUG! cannot determine board type!\n");
+ return -EINVAL;
+ }
}
/*
- * _detach is called to deconfigure a device. It should deallocate
- * resources.
- * This function is also called when _attach() fails, so it should be
- * careful not to release resources that were not necessarily
- * allocated by _attach(). dev->private and dev->subdevices are
- * deallocated automatically by the core.
+ * The attach_pci hook (if non-NULL) is called at PCI probe time in preference
+ * to the "manual" attach hook. dev->board_ptr is NULL on entry. There should
+ * be a board entry matching the supplied PCI device.
*/
-static int dio200_detach(struct comedi_device *dev)
+static int __devinit dio200_attach_pci(struct comedi_device *dev,
+ struct pci_dev *pci_dev)
+{
+ int ret;
+
+ if (!IS_ENABLED(CONFIG_COMEDI_AMPLC_DIO200_PCI))
+ return -EINVAL;
+
+ dev_info(dev->class_dev, DIO200_DRIVER_NAME ": attach pci %s\n",
+ pci_name(pci_dev));
+ ret = alloc_private(dev, sizeof(struct dio200_private));
+ if (ret < 0) {
+ dev_err(dev->class_dev, "error! out of memory!\n");
+ return ret;
+ }
+ dev->board_ptr = dio200_find_pci_board(pci_dev);
+ if (dev->board_ptr == NULL) {
+ dev_err(dev->class_dev, "BUG! cannot determine board type!\n");
+ return -EINVAL;
+ }
+ return dio200_pci_common_attach(dev, pci_dev);
+}
+
+static void dio200_detach(struct comedi_device *dev)
{
+ const struct dio200_board *thisboard = comedi_board(dev);
+ struct pci_dev *pcidev = comedi_to_pci_dev(dev);
const struct dio200_layout_struct *layout;
unsigned n;
- printk(KERN_DEBUG "comedi%d: %s: detach\n", dev->minor,
- DIO200_DRIVER_NAME);
-
if (dev->irq)
free_irq(dev->irq, dev);
if (dev->subdevices) {
- layout = thislayout;
+ layout = &dio200_layouts[thisboard->layout];
for (n = 0; n < dev->n_subdevices; n++) {
struct comedi_subdevice *s = &dev->subdevices[n];
switch (layout->sdtype[n]) {
@@ -1528,26 +1443,65 @@ static int dio200_detach(struct comedi_device *dev)
}
}
}
- if (devpriv) {
-#ifdef CONFIG_COMEDI_PCI
- if (devpriv->pci_dev) {
- if (dev->iobase)
- comedi_pci_disable(devpriv->pci_dev);
- pci_dev_put(devpriv->pci_dev);
- } else
-#endif
- {
- if (dev->iobase)
- release_region(dev->iobase, DIO200_IO_SIZE);
- }
+ if (pcidev) {
+ if (dev->iobase)
+ comedi_pci_disable(pcidev);
+ pci_dev_put(pcidev);
+ } else {
+ if (dev->iobase)
+ release_region(dev->iobase, DIO200_IO_SIZE);
}
- if (dev->board_name)
- printk(KERN_INFO "comedi%d: %s removed\n",
- dev->minor, dev->board_name);
+}
- return 0;
+/*
+ * The struct comedi_driver structure tells the Comedi core module
+ * which functions to call to configure/deconfigure (attach/detach)
+ * the board, and also about the kernel module that contains
+ * the device code.
+ */
+static struct comedi_driver amplc_dio200_driver = {
+ .driver_name = DIO200_DRIVER_NAME,
+ .module = THIS_MODULE,
+ .attach = dio200_attach,
+ .attach_pci = dio200_attach_pci,
+ .detach = dio200_detach,
+ .board_name = &dio200_boards[0].name,
+ .offset = sizeof(struct dio200_board),
+ .num_names = ARRAY_SIZE(dio200_boards),
+};
+
+#if IS_ENABLED(CONFIG_COMEDI_AMPLC_DIO200_PCI)
+static DEFINE_PCI_DEVICE_TABLE(dio200_pci_table) = {
+ { PCI_DEVICE(PCI_VENDOR_ID_AMPLICON, PCI_DEVICE_ID_AMPLICON_PCI215) },
+ { PCI_DEVICE(PCI_VENDOR_ID_AMPLICON, PCI_DEVICE_ID_AMPLICON_PCI272) },
+ {0}
+};
+
+MODULE_DEVICE_TABLE(pci, dio200_pci_table);
+
+static int __devinit amplc_dio200_pci_probe(struct pci_dev *dev,
+ const struct pci_device_id
+ *ent)
+{
+ return comedi_pci_auto_config(dev, &amplc_dio200_driver);
+}
+
+static void __devexit amplc_dio200_pci_remove(struct pci_dev *dev)
+{
+ comedi_pci_auto_unconfig(dev);
}
+static struct pci_driver amplc_dio200_pci_driver = {
+ .name = DIO200_DRIVER_NAME,
+ .id_table = dio200_pci_table,
+ .probe = &amplc_dio200_pci_probe,
+ .remove = __devexit_p(&amplc_dio200_pci_remove)
+};
+module_comedi_pci_driver(amplc_dio200_driver, amplc_dio200_pci_driver);
+#else
+module_comedi_driver(amplc_dio200_driver);
+#endif
+
MODULE_AUTHOR("Comedi http://www.comedi.org");
MODULE_DESCRIPTION("Comedi low-level driver");
MODULE_LICENSE("GPL");
diff --git a/drivers/staging/comedi/drivers/amplc_pc236.c b/drivers/staging/comedi/drivers/amplc_pc236.c
index 7972cadd403e..aabba9886b7d 100644
--- a/drivers/staging/comedi/drivers/amplc_pc236.c
+++ b/drivers/staging/comedi/drivers/amplc_pc236.c
@@ -56,8 +56,6 @@ unused.
#include "../comedidev.h"
-#include "comedi_pci.h"
-
#include "8255.h"
#include "plx9052.h"
@@ -100,411 +98,110 @@ enum pc236_model { pc36at_model, pci236_model, anypci_model };
struct pc236_board {
const char *name;
- const char *fancy_name;
unsigned short devid;
enum pc236_bustype bustype;
enum pc236_model model;
};
static const struct pc236_board pc236_boards[] = {
+#if IS_ENABLED(CONFIG_COMEDI_AMPLC_PC236_ISA)
{
- .name = "pc36at",
- .fancy_name = "PC36AT",
- .bustype = isa_bustype,
- .model = pc36at_model,
- },
-#ifdef CONFIG_COMEDI_PCI
- {
- .name = "pci236",
- .fancy_name = "PCI236",
- .devid = PCI_DEVICE_ID_AMPLICON_PCI236,
- .bustype = pci_bustype,
- .model = pci236_model,
- },
+ .name = "pc36at",
+ .bustype = isa_bustype,
+ .model = pc36at_model,
+ },
#endif
-#ifdef CONFIG_COMEDI_PCI
+#if IS_ENABLED(CONFIG_COMEDI_AMPLC_PC236_PCI)
+ {
+ .name = "pci236",
+ .devid = PCI_DEVICE_ID_AMPLICON_PCI236,
+ .bustype = pci_bustype,
+ .model = pci236_model,
+ },
{
- .name = PC236_DRIVER_NAME,
- .fancy_name = PC236_DRIVER_NAME,
- .devid = PCI_DEVICE_ID_INVALID,
- .bustype = pci_bustype,
- .model = anypci_model, /* wildcard */
- },
+ .name = PC236_DRIVER_NAME,
+ .devid = PCI_DEVICE_ID_INVALID,
+ .bustype = pci_bustype,
+ .model = anypci_model, /* wildcard */
+ },
#endif
};
-#ifdef CONFIG_COMEDI_PCI
-static DEFINE_PCI_DEVICE_TABLE(pc236_pci_table) = {
- { PCI_DEVICE(PCI_VENDOR_ID_AMPLICON, PCI_DEVICE_ID_AMPLICON_PCI236) },
- {0}
-};
-
-MODULE_DEVICE_TABLE(pci, pc236_pci_table);
-#endif /* CONFIG_COMEDI_PCI */
-
-/*
- * Useful for shorthand access to the particular board structure
- */
-#define thisboard ((const struct pc236_board *)dev->board_ptr)
-
/* this structure is for data unique to this hardware driver. If
several hardware drivers keep similar information in this structure,
feel free to suggest moving the variable to the struct comedi_device struct.
*/
struct pc236_private {
-#ifdef CONFIG_COMEDI_PCI
- /* PCI device */
- struct pci_dev *pci_dev;
unsigned long lcr_iobase; /* PLX PCI9052 config registers in PCIBAR1 */
-#endif
int enable_irq;
};
-#define devpriv ((struct pc236_private *)dev->private)
-
/*
- * The struct comedi_driver structure tells the Comedi core module
- * which functions to call to configure/deconfigure (attach/detach)
- * the board, and also about the kernel module that contains
- * the device code.
+ * This function looks for a board matching the supplied PCI device.
*/
-static int pc236_attach(struct comedi_device *dev, struct comedi_devconfig *it);
-static int pc236_detach(struct comedi_device *dev);
-static struct comedi_driver driver_amplc_pc236 = {
- .driver_name = PC236_DRIVER_NAME,
- .module = THIS_MODULE,
- .attach = pc236_attach,
- .detach = pc236_detach,
- .board_name = &pc236_boards[0].name,
- .offset = sizeof(struct pc236_board),
- .num_names = ARRAY_SIZE(pc236_boards),
-};
-
-#ifdef CONFIG_COMEDI_PCI
-static int __devinit driver_amplc_pc236_pci_probe(struct pci_dev *dev,
- const struct pci_device_id
- *ent)
+static const struct pc236_board *pc236_find_pci_board(struct pci_dev *pci_dev)
{
- return comedi_pci_auto_config(dev, driver_amplc_pc236.driver_name);
-}
+ unsigned int i;
-static void __devexit driver_amplc_pc236_pci_remove(struct pci_dev *dev)
-{
- comedi_pci_auto_unconfig(dev);
+ for (i = 0; i < ARRAY_SIZE(pc236_boards); i++)
+ if (pc236_boards[i].bustype == pci_bustype &&
+ pci_dev->device == pc236_boards[i].devid)
+ return &pc236_boards[i];
+ return NULL;
}
-static struct pci_driver driver_amplc_pc236_pci_driver = {
- .id_table = pc236_pci_table,
- .probe = &driver_amplc_pc236_pci_probe,
- .remove = __devexit_p(&driver_amplc_pc236_pci_remove)
-};
-
-static int __init driver_amplc_pc236_init_module(void)
-{
- int retval;
-
- retval = comedi_driver_register(&driver_amplc_pc236);
- if (retval < 0)
- return retval;
-
- driver_amplc_pc236_pci_driver.name =
- (char *)driver_amplc_pc236.driver_name;
- return pci_register_driver(&driver_amplc_pc236_pci_driver);
-}
-
-static void __exit driver_amplc_pc236_cleanup_module(void)
-{
- pci_unregister_driver(&driver_amplc_pc236_pci_driver);
- comedi_driver_unregister(&driver_amplc_pc236);
-}
-
-module_init(driver_amplc_pc236_init_module);
-module_exit(driver_amplc_pc236_cleanup_module);
-#else
-static int __init driver_amplc_pc236_init_module(void)
-{
- return comedi_driver_register(&driver_amplc_pc236);
-}
-
-static void __exit driver_amplc_pc236_cleanup_module(void)
-{
- comedi_driver_unregister(&driver_amplc_pc236);
-}
-
-module_init(driver_amplc_pc236_init_module);
-module_exit(driver_amplc_pc236_cleanup_module);
-#endif
-
-static int pc236_request_region(unsigned minor, unsigned long from,
- unsigned long extent);
-static void pc236_intr_disable(struct comedi_device *dev);
-static void pc236_intr_enable(struct comedi_device *dev);
-static int pc236_intr_check(struct comedi_device *dev);
-static int pc236_intr_insn(struct comedi_device *dev,
- struct comedi_subdevice *s, struct comedi_insn *insn,
- unsigned int *data);
-static int pc236_intr_cmdtest(struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_cmd *cmd);
-static int pc236_intr_cmd(struct comedi_device *dev,
- struct comedi_subdevice *s);
-static int pc236_intr_cancel(struct comedi_device *dev,
- struct comedi_subdevice *s);
-static irqreturn_t pc236_interrupt(int irq, void *d);
-
/*
* This function looks for a PCI device matching the requested board name,
* bus and slot.
*/
-#ifdef CONFIG_COMEDI_PCI
-static int
-pc236_find_pci(struct comedi_device *dev, int bus, int slot,
- struct pci_dev **pci_dev_p)
+static struct pci_dev *pc236_find_pci_dev(struct comedi_device *dev,
+ struct comedi_devconfig *it)
{
+ const struct pc236_board *thisboard = comedi_board(dev);
struct pci_dev *pci_dev = NULL;
+ int bus = it->options[0];
+ int slot = it->options[1];
- *pci_dev_p = NULL;
-
- /* Look for matching PCI device. */
- for (pci_dev = pci_get_device(PCI_VENDOR_ID_AMPLICON, PCI_ANY_ID, NULL);
- pci_dev != NULL;
- pci_dev = pci_get_device(PCI_VENDOR_ID_AMPLICON,
- PCI_ANY_ID, pci_dev)) {
- /* If bus/slot specified, check them. */
+ for_each_pci_dev(pci_dev) {
if (bus || slot) {
- if (bus != pci_dev->bus->number
- || slot != PCI_SLOT(pci_dev->devfn))
+ if (bus != pci_dev->bus->number ||
+ slot != PCI_SLOT(pci_dev->devfn))
continue;
}
+ if (pci_dev->vendor != PCI_VENDOR_ID_AMPLICON)
+ continue;
+
if (thisboard->model == anypci_model) {
- /* Match any supported model. */
- int i;
-
- for (i = 0; i < ARRAY_SIZE(pc236_boards); i++) {
- if (pc236_boards[i].bustype != pci_bustype)
- continue;
- if (pci_dev->device == pc236_boards[i].devid) {
- /* Change board_ptr to matched board. */
- dev->board_ptr = &pc236_boards[i];
- break;
- }
- }
- if (i == ARRAY_SIZE(pc236_boards))
+ /* Wildcard board matches any supported PCI board. */
+ const struct pc236_board *foundboard;
+
+ foundboard = pc236_find_pci_board(pci_dev);
+ if (foundboard == NULL)
continue;
+ /* Replace wildcard board_ptr. */
+ dev->board_ptr = foundboard;
} else {
/* Match specific model name. */
if (pci_dev->device != thisboard->devid)
continue;
}
-
- /* Found a match. */
- *pci_dev_p = pci_dev;
- return 0;
- }
- /* No match found. */
- if (bus || slot) {
- printk(KERN_ERR
- "comedi%d: error! no %s found at pci %02x:%02x!\n",
- dev->minor, thisboard->name, bus, slot);
- } else {
- printk(KERN_ERR "comedi%d: error! no %s found!\n",
- dev->minor, thisboard->name);
- }
- return -EIO;
-}
-#endif
-
-/*
- * Attach is called by the Comedi core to configure the driver
- * for a particular board. If you specified a board_name array
- * in the driver structure, dev->board_ptr contains that
- * address.
- */
-static int pc236_attach(struct comedi_device *dev, struct comedi_devconfig *it)
-{
- struct comedi_subdevice *s;
- unsigned long iobase = 0;
- unsigned int irq = 0;
-#ifdef CONFIG_COMEDI_PCI
- struct pci_dev *pci_dev = NULL;
- int bus = 0, slot = 0;
-#endif
- int share_irq = 0;
- int ret;
-
- printk(KERN_DEBUG "comedi%d: %s: attach\n", dev->minor,
- PC236_DRIVER_NAME);
-/*
- * Allocate the private structure area. alloc_private() is a
- * convenient macro defined in comedidev.h.
- */
- ret = alloc_private(dev, sizeof(struct pc236_private));
- if (ret < 0) {
- printk(KERN_ERR "comedi%d: error! out of memory!\n",
- dev->minor);
- return ret;
- }
- /* Process options. */
- switch (thisboard->bustype) {
- case isa_bustype:
- iobase = it->options[0];
- irq = it->options[1];
- share_irq = 0;
- break;
-#ifdef CONFIG_COMEDI_PCI
- case pci_bustype:
- bus = it->options[0];
- slot = it->options[1];
- share_irq = 1;
-
- ret = pc236_find_pci(dev, bus, slot, &pci_dev);
- if (ret < 0)
- return ret;
- devpriv->pci_dev = pci_dev;
- break;
-#endif /* CONFIG_COMEDI_PCI */
- default:
- printk(KERN_ERR
- "comedi%d: %s: BUG! cannot determine board type!\n",
- dev->minor, PC236_DRIVER_NAME);
- return -EINVAL;
- break;
- }
-
-/*
- * Initialize dev->board_name.
- */
- dev->board_name = thisboard->name;
-
- /* Enable device and reserve I/O spaces. */
-#ifdef CONFIG_COMEDI_PCI
- if (pci_dev) {
-
- ret = comedi_pci_enable(pci_dev, PC236_DRIVER_NAME);
- if (ret < 0) {
- printk(KERN_ERR
- "comedi%d: error! cannot enable PCI device and request regions!\n",
- dev->minor);
- return ret;
- }
- devpriv->lcr_iobase = pci_resource_start(pci_dev, 1);
- iobase = pci_resource_start(pci_dev, 2);
- irq = pci_dev->irq;
- } else
-#endif
- {
- ret = pc236_request_region(dev->minor, iobase, PC236_IO_SIZE);
- if (ret < 0)
- return ret;
+ return pci_dev;
}
- dev->iobase = iobase;
-
-/*
- * Allocate the subdevice structures. alloc_subdevice() is a
- * convenient macro defined in comedidev.h.
- */
- ret = alloc_subdevices(dev, 2);
- if (ret < 0) {
- printk(KERN_ERR "comedi%d: error! out of memory!\n",
- dev->minor);
- return ret;
- }
-
- s = dev->subdevices + 0;
- /* digital i/o subdevice (8255) */
- ret = subdev_8255_init(dev, s, NULL, iobase);
- if (ret < 0) {
- printk(KERN_ERR "comedi%d: error! out of memory!\n",
- dev->minor);
- return ret;
- }
- s = dev->subdevices + 1;
- dev->read_subdev = s;
- s->type = COMEDI_SUBD_UNUSED;
- pc236_intr_disable(dev);
- if (irq) {
- unsigned long flags = share_irq ? IRQF_SHARED : 0;
-
- if (request_irq(irq, pc236_interrupt, flags,
- PC236_DRIVER_NAME, dev) >= 0) {
- dev->irq = irq;
- s->type = COMEDI_SUBD_DI;
- s->subdev_flags = SDF_READABLE | SDF_CMD_READ;
- s->n_chan = 1;
- s->maxdata = 1;
- s->range_table = &range_digital;
- s->insn_bits = pc236_intr_insn;
- s->do_cmdtest = pc236_intr_cmdtest;
- s->do_cmd = pc236_intr_cmd;
- s->cancel = pc236_intr_cancel;
- }
- }
- printk(KERN_INFO "comedi%d: %s ", dev->minor, dev->board_name);
- if (thisboard->bustype == isa_bustype) {
- printk("(base %#lx) ", iobase);
- } else {
-#ifdef CONFIG_COMEDI_PCI
- printk("(pci %s) ", pci_name(pci_dev));
-#endif
- }
- if (irq)
- printk("(irq %u%s) ", irq, (dev->irq ? "" : " UNAVAILABLE"));
- else
- printk("(no irq) ");
-
- printk("attached\n");
-
- return 1;
-}
-
-/*
- * _detach is called to deconfigure a device. It should deallocate
- * resources.
- * This function is also called when _attach() fails, so it should be
- * careful not to release resources that were not necessarily
- * allocated by _attach(). dev->private and dev->subdevices are
- * deallocated automatically by the core.
- */
-static int pc236_detach(struct comedi_device *dev)
-{
- printk(KERN_DEBUG "comedi%d: %s: detach\n", dev->minor,
- PC236_DRIVER_NAME);
- if (devpriv)
- pc236_intr_disable(dev);
-
- if (dev->irq)
- free_irq(dev->irq, dev);
- if (dev->subdevices)
- subdev_8255_cleanup(dev, dev->subdevices + 0);
- if (devpriv) {
-#ifdef CONFIG_COMEDI_PCI
- if (devpriv->pci_dev) {
- if (dev->iobase)
- comedi_pci_disable(devpriv->pci_dev);
- pci_dev_put(devpriv->pci_dev);
- } else
-#endif
- {
- if (dev->iobase)
- release_region(dev->iobase, PC236_IO_SIZE);
- }
- }
- if (dev->board_name) {
- printk(KERN_INFO "comedi%d: %s removed\n",
- dev->minor, dev->board_name);
- }
- return 0;
+ dev_err(dev->class_dev,
+ "No supported board found! (req. bus %d, slot %d)\n",
+ bus, slot);
+ return NULL;
}
/*
* This function checks and requests an I/O region, reporting an error
* if there is a conflict.
*/
-static int pc236_request_region(unsigned minor, unsigned long from,
+static int pc236_request_region(struct comedi_device *dev, unsigned long from,
unsigned long extent)
{
if (!from || !request_region(from, extent, PC236_DRIVER_NAME)) {
- printk(KERN_ERR "comedi%d: I/O port conflict (%#lx,%lu)!\n",
- minor, from, extent);
+ dev_err(dev->class_dev, "I/O port conflict (%#lx,%lu)!\n",
+ from, extent);
return -EIO;
}
return 0;
@@ -517,14 +214,13 @@ static int pc236_request_region(unsigned minor, unsigned long from,
*/
static void pc236_intr_disable(struct comedi_device *dev)
{
+ struct pc236_private *devpriv = dev->private;
unsigned long flags;
spin_lock_irqsave(&dev->spinlock, flags);
devpriv->enable_irq = 0;
-#ifdef CONFIG_COMEDI_PCI
- if (devpriv->lcr_iobase)
+ if (IS_ENABLED(CONFIG_COMEDI_AMPLC_PC236_PCI) && devpriv->lcr_iobase)
outl(PCI236_INTR_DISABLE, devpriv->lcr_iobase + PLX9052_INTCSR);
-#endif
spin_unlock_irqrestore(&dev->spinlock, flags);
}
@@ -535,14 +231,13 @@ static void pc236_intr_disable(struct comedi_device *dev)
*/
static void pc236_intr_enable(struct comedi_device *dev)
{
+ struct pc236_private *devpriv = dev->private;
unsigned long flags;
spin_lock_irqsave(&dev->spinlock, flags);
devpriv->enable_irq = 1;
-#ifdef CONFIG_COMEDI_PCI
- if (devpriv->lcr_iobase)
+ if (IS_ENABLED(CONFIG_COMEDI_AMPLC_PC236_PCI) && devpriv->lcr_iobase)
outl(PCI236_INTR_ENABLE, devpriv->lcr_iobase + PLX9052_INTCSR);
-#endif
spin_unlock_irqrestore(&dev->spinlock, flags);
}
@@ -555,14 +250,15 @@ static void pc236_intr_enable(struct comedi_device *dev)
*/
static int pc236_intr_check(struct comedi_device *dev)
{
+ struct pc236_private *devpriv = dev->private;
int retval = 0;
unsigned long flags;
spin_lock_irqsave(&dev->spinlock, flags);
if (devpriv->enable_irq) {
retval = 1;
-#ifdef CONFIG_COMEDI_PCI
- if (devpriv->lcr_iobase) {
+ if (IS_ENABLED(CONFIG_COMEDI_AMPLC_PC236_PCI) &&
+ devpriv->lcr_iobase) {
if ((inl(devpriv->lcr_iobase + PLX9052_INTCSR)
& PLX9052_INTCSR_LI1STAT_MASK)
== PLX9052_INTCSR_LI1STAT_INACTIVE) {
@@ -573,7 +269,6 @@ static int pc236_intr_check(struct comedi_device *dev)
devpriv->lcr_iobase + PLX9052_INTCSR);
}
}
-#endif
}
spin_unlock_irqrestore(&dev->spinlock, flags);
@@ -589,7 +284,7 @@ static int pc236_intr_insn(struct comedi_device *dev,
unsigned int *data)
{
data[1] = 0;
- return 2;
+ return insn->n;
}
/*
@@ -712,6 +407,236 @@ static irqreturn_t pc236_interrupt(int irq, void *d)
return IRQ_RETVAL(handled);
}
+static void pc236_report_attach(struct comedi_device *dev, unsigned int irq)
+{
+ const struct pc236_board *thisboard = comedi_board(dev);
+ struct pci_dev *pcidev = comedi_to_pci_dev(dev);
+ char tmpbuf[60];
+ int tmplen;
+
+ if (IS_ENABLED(CONFIG_COMEDI_AMPLC_PC236_ISA) &&
+ thisboard->bustype == isa_bustype)
+ tmplen = scnprintf(tmpbuf, sizeof(tmpbuf),
+ "(base %#lx) ", dev->iobase);
+ else if (IS_ENABLED(CONFIG_COMEDI_AMPLC_PC236_PCI) &&
+ thisboard->bustype == pci_bustype) {
+ tmplen = scnprintf(tmpbuf, sizeof(tmpbuf),
+ "(pci %s) ", pci_name(pcidev));
+ } else
+ tmplen = 0;
+ if (irq)
+ tmplen += scnprintf(&tmpbuf[tmplen], sizeof(tmpbuf) - tmplen,
+ "(irq %u%s) ", irq,
+ (dev->irq ? "" : " UNAVAILABLE"));
+ else
+ tmplen += scnprintf(&tmpbuf[tmplen], sizeof(tmpbuf) - tmplen,
+ "(no irq) ");
+ dev_info(dev->class_dev, "%s %sattached\n",
+ dev->board_name, tmpbuf);
+}
+
+static int pc236_common_attach(struct comedi_device *dev, unsigned long iobase,
+ unsigned int irq, unsigned long req_irq_flags)
+{
+ const struct pc236_board *thisboard = comedi_board(dev);
+ struct comedi_subdevice *s;
+ int ret;
+
+ dev->board_name = thisboard->name;
+ dev->iobase = iobase;
+
+ ret = comedi_alloc_subdevices(dev, 2);
+ if (ret)
+ return ret;
+
+ s = dev->subdevices + 0;
+ /* digital i/o subdevice (8255) */
+ ret = subdev_8255_init(dev, s, NULL, iobase);
+ if (ret < 0) {
+ dev_err(dev->class_dev, "error! out of memory!\n");
+ return ret;
+ }
+ s = dev->subdevices + 1;
+ dev->read_subdev = s;
+ s->type = COMEDI_SUBD_UNUSED;
+ pc236_intr_disable(dev);
+ if (irq) {
+ if (request_irq(irq, pc236_interrupt, req_irq_flags,
+ PC236_DRIVER_NAME, dev) >= 0) {
+ dev->irq = irq;
+ s->type = COMEDI_SUBD_DI;
+ s->subdev_flags = SDF_READABLE | SDF_CMD_READ;
+ s->n_chan = 1;
+ s->maxdata = 1;
+ s->range_table = &range_digital;
+ s->insn_bits = pc236_intr_insn;
+ s->do_cmdtest = pc236_intr_cmdtest;
+ s->do_cmd = pc236_intr_cmd;
+ s->cancel = pc236_intr_cancel;
+ }
+ }
+ pc236_report_attach(dev, irq);
+ return 1;
+}
+
+static int pc236_pci_common_attach(struct comedi_device *dev,
+ struct pci_dev *pci_dev)
+{
+ struct pc236_private *devpriv = dev->private;
+ unsigned long iobase;
+ int ret;
+
+ comedi_set_hw_dev(dev, &pci_dev->dev);
+
+ ret = comedi_pci_enable(pci_dev, PC236_DRIVER_NAME);
+ if (ret < 0) {
+ dev_err(dev->class_dev,
+ "error! cannot enable PCI device and request regions!\n");
+ return ret;
+ }
+ devpriv->lcr_iobase = pci_resource_start(pci_dev, 1);
+ iobase = pci_resource_start(pci_dev, 2);
+ return pc236_common_attach(dev, iobase, pci_dev->irq, IRQF_SHARED);
+}
+
+/*
+ * Attach is called by the Comedi core to configure the driver
+ * for a particular board. If you specified a board_name array
+ * in the driver structure, dev->board_ptr contains that
+ * address.
+ */
+static int pc236_attach(struct comedi_device *dev, struct comedi_devconfig *it)
+{
+ const struct pc236_board *thisboard = comedi_board(dev);
+ int ret;
+
+ dev_info(dev->class_dev, PC236_DRIVER_NAME ": attach\n");
+ ret = alloc_private(dev, sizeof(struct pc236_private));
+ if (ret < 0) {
+ dev_err(dev->class_dev, "error! out of memory!\n");
+ return ret;
+ }
+ /* Process options according to bus type. */
+ if (IS_ENABLED(CONFIG_COMEDI_AMPLC_PC236_ISA) &&
+ thisboard->bustype == isa_bustype) {
+ unsigned long iobase = it->options[0];
+ unsigned int irq = it->options[1];
+ ret = pc236_request_region(dev, iobase, PC236_IO_SIZE);
+ if (ret < 0)
+ return ret;
+ return pc236_common_attach(dev, iobase, irq, 0);
+ } else if (IS_ENABLED(CONFIG_COMEDI_AMPLC_PC236_PCI) &&
+ thisboard->bustype == pci_bustype) {
+ struct pci_dev *pci_dev;
+
+ pci_dev = pc236_find_pci_dev(dev, it);
+ if (!pci_dev)
+ return -EIO;
+ return pc236_pci_common_attach(dev, pci_dev);
+ } else {
+ dev_err(dev->class_dev, PC236_DRIVER_NAME
+ ": BUG! cannot determine board type!\n");
+ return -EINVAL;
+ }
+}
+
+/*
+ * The attach_pci hook (if non-NULL) is called at PCI probe time in preference
+ * to the "manual" attach hook. dev->board_ptr is NULL on entry. There should
+ * be a board entry matching the supplied PCI device.
+ */
+static int __devinit pc236_attach_pci(struct comedi_device *dev,
+ struct pci_dev *pci_dev)
+{
+ int ret;
+
+ if (!IS_ENABLED(CONFIG_COMEDI_AMPLC_PC236_PCI))
+ return -EINVAL;
+
+ dev_info(dev->class_dev, PC236_DRIVER_NAME ": attach pci %s\n",
+ pci_name(pci_dev));
+ ret = alloc_private(dev, sizeof(struct pc236_private));
+ if (ret < 0) {
+ dev_err(dev->class_dev, "error! out of memory!\n");
+ return ret;
+ }
+ dev->board_ptr = pc236_find_pci_board(pci_dev);
+ if (dev->board_ptr == NULL) {
+ dev_err(dev->class_dev, "BUG! cannot determine board type!\n");
+ return -EINVAL;
+ }
+ return pc236_pci_common_attach(dev, pci_dev);
+}
+
+static void pc236_detach(struct comedi_device *dev)
+{
+ struct pc236_private *devpriv = dev->private;
+ struct pci_dev *pcidev = comedi_to_pci_dev(dev);
+
+ if (devpriv)
+ pc236_intr_disable(dev);
+ if (dev->irq)
+ free_irq(dev->irq, dev);
+ if (dev->subdevices)
+ subdev_8255_cleanup(dev, dev->subdevices + 0);
+ if (pcidev) {
+ if (dev->iobase)
+ comedi_pci_disable(pcidev);
+ pci_dev_put(pcidev);
+ } else {
+ if (dev->iobase)
+ release_region(dev->iobase, PC236_IO_SIZE);
+ }
+}
+
+/*
+ * The struct comedi_driver structure tells the Comedi core module
+ * which functions to call to configure/deconfigure (attach/detach)
+ * the board, and also about the kernel module that contains
+ * the device code.
+ */
+static struct comedi_driver amplc_pc236_driver = {
+ .driver_name = PC236_DRIVER_NAME,
+ .module = THIS_MODULE,
+ .attach = pc236_attach,
+ .attach_pci = pc236_attach_pci,
+ .detach = pc236_detach,
+ .board_name = &pc236_boards[0].name,
+ .offset = sizeof(struct pc236_board),
+ .num_names = ARRAY_SIZE(pc236_boards),
+};
+
+#if IS_ENABLED(CONFIG_COMEDI_AMPLC_PC236_PCI)
+static DEFINE_PCI_DEVICE_TABLE(pc236_pci_table) = {
+ { PCI_DEVICE(PCI_VENDOR_ID_AMPLICON, PCI_DEVICE_ID_AMPLICON_PCI236) },
+ {0}
+};
+
+MODULE_DEVICE_TABLE(pci, pc236_pci_table);
+
+static int __devinit amplc_pc236_pci_probe(struct pci_dev *dev,
+ const struct pci_device_id *ent)
+{
+ return comedi_pci_auto_config(dev, &amplc_pc236_driver);
+}
+
+static void __devexit amplc_pc236_pci_remove(struct pci_dev *dev)
+{
+ comedi_pci_auto_unconfig(dev);
+}
+
+static struct pci_driver amplc_pc236_pci_driver = {
+ .name = PC236_DRIVER_NAME,
+ .id_table = pc236_pci_table,
+ .probe = &amplc_pc236_pci_probe,
+ .remove = __devexit_p(&amplc_pc236_pci_remove)
+};
+
+module_comedi_pci_driver(amplc_pc236_driver, amplc_pc236_pci_driver);
+#else
+module_comedi_driver(amplc_pc236_driver);
+#endif
+
MODULE_AUTHOR("Comedi http://www.comedi.org");
MODULE_DESCRIPTION("Comedi low-level driver");
MODULE_LICENSE("GPL");
diff --git a/drivers/staging/comedi/drivers/amplc_pc263.c b/drivers/staging/comedi/drivers/amplc_pc263.c
index 191ac0d23ce7..40ec1ffebba6 100644
--- a/drivers/staging/comedi/drivers/amplc_pc263.c
+++ b/drivers/staging/comedi/drivers/amplc_pc263.c
@@ -46,8 +46,6 @@ The state of the outputs can be read.
#include "../comedidev.h"
-#include "comedi_pci.h"
-
#define PC263_DRIVER_NAME "amplc_pc263"
/* PCI263 PCI configuration register information */
@@ -67,421 +65,301 @@ enum pc263_model { pc263_model, pci263_model, anypci_model };
struct pc263_board {
const char *name;
- const char *fancy_name;
unsigned short devid;
enum pc263_bustype bustype;
enum pc263_model model;
};
static const struct pc263_board pc263_boards[] = {
+#if IS_ENABLED(CONFIG_COMEDI_AMPLC_PC263_ISA)
{
- .name = "pc263",
- .fancy_name = "PC263",
- .bustype = isa_bustype,
- .model = pc263_model,
- },
-#ifdef CONFIG_COMEDI_PCI
- {
- .name = "pci263",
- .fancy_name = "PCI263",
- .devid = PCI_DEVICE_ID_AMPLICON_PCI263,
- .bustype = pci_bustype,
- .model = pci263_model,
- },
+ .name = "pc263",
+ .bustype = isa_bustype,
+ .model = pc263_model,
+ },
#endif
-#ifdef CONFIG_COMEDI_PCI
+#if IS_ENABLED(CONFIG_COMEDI_AMPLC_PC263_PCI)
+ {
+ .name = "pci263",
+ .devid = PCI_DEVICE_ID_AMPLICON_PCI263,
+ .bustype = pci_bustype,
+ .model = pci263_model,
+ },
{
- .name = PC263_DRIVER_NAME,
- .fancy_name = PC263_DRIVER_NAME,
- .devid = PCI_DEVICE_ID_INVALID,
- .bustype = pci_bustype,
- .model = anypci_model, /* wildcard */
- },
+ .name = PC263_DRIVER_NAME,
+ .devid = PCI_DEVICE_ID_INVALID,
+ .bustype = pci_bustype,
+ .model = anypci_model, /* wildcard */
+ },
#endif
};
-#ifdef CONFIG_COMEDI_PCI
-static DEFINE_PCI_DEVICE_TABLE(pc263_pci_table) = {
- { PCI_DEVICE(PCI_VENDOR_ID_AMPLICON, PCI_DEVICE_ID_AMPLICON_PCI263) },
- {0}
-};
-
-MODULE_DEVICE_TABLE(pci, pc263_pci_table);
-#endif /* CONFIG_COMEDI_PCI */
-
/*
- * Useful for shorthand access to the particular board structure
+ * This function looks for a board matching the supplied PCI device.
*/
-#define thisboard ((const struct pc263_board *)dev->board_ptr)
-
-/* this structure is for data unique to this hardware driver. If
- several hardware drivers keep similar information in this structure,
- feel free to suggest moving the variable to the struct comedi_device struct.
-*/
-#ifdef CONFIG_COMEDI_PCI
-struct pc263_private {
- /* PCI device. */
- struct pci_dev *pci_dev;
-};
-
-#define devpriv ((struct pc263_private *)dev->private)
-#endif /* CONFIG_COMEDI_PCI */
+static const struct pc263_board *pc263_find_pci_board(struct pci_dev *pci_dev)
+{
+ unsigned int i;
-/*
- * The struct comedi_driver structure tells the Comedi core module
- * which functions to call to configure/deconfigure (attach/detach)
- * the board, and also about the kernel module that contains
- * the device code.
- */
-static int pc263_attach(struct comedi_device *dev, struct comedi_devconfig *it);
-static int pc263_detach(struct comedi_device *dev);
-static struct comedi_driver driver_amplc_pc263 = {
- .driver_name = PC263_DRIVER_NAME,
- .module = THIS_MODULE,
- .attach = pc263_attach,
- .detach = pc263_detach,
- .board_name = &pc263_boards[0].name,
- .offset = sizeof(struct pc263_board),
- .num_names = ARRAY_SIZE(pc263_boards),
-};
+ for (i = 0; i < ARRAY_SIZE(pc263_boards); i++)
+ if (pc263_boards[i].bustype == pci_bustype &&
+ pci_dev->device == pc263_boards[i].devid)
+ return &pc263_boards[i];
+ return NULL;
+}
-static int pc263_request_region(unsigned minor, unsigned long from,
- unsigned long extent);
-static int pc263_dio_insn_bits(struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data);
-static int pc263_dio_insn_config(struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data);
/*
* This function looks for a PCI device matching the requested board name,
* bus and slot.
*/
-#ifdef CONFIG_COMEDI_PCI
-static int
-pc263_find_pci(struct comedi_device *dev, int bus, int slot,
- struct pci_dev **pci_dev_p)
+static struct pci_dev *pc263_find_pci_dev(struct comedi_device *dev,
+ struct comedi_devconfig *it)
{
+ const struct pc263_board *thisboard = comedi_board(dev);
struct pci_dev *pci_dev = NULL;
+ int bus = it->options[0];
+ int slot = it->options[1];
- *pci_dev_p = NULL;
-
- /* Look for matching PCI device. */
- for (pci_dev = pci_get_device(PCI_VENDOR_ID_AMPLICON, PCI_ANY_ID, NULL);
- pci_dev != NULL;
- pci_dev = pci_get_device(PCI_VENDOR_ID_AMPLICON,
- PCI_ANY_ID, pci_dev)) {
- /* If bus/slot specified, check them. */
+ for_each_pci_dev(pci_dev) {
if (bus || slot) {
- if (bus != pci_dev->bus->number
- || slot != PCI_SLOT(pci_dev->devfn))
+ if (bus != pci_dev->bus->number ||
+ slot != PCI_SLOT(pci_dev->devfn))
continue;
}
+ if (pci_dev->vendor != PCI_VENDOR_ID_AMPLICON)
+ continue;
+
if (thisboard->model == anypci_model) {
- /* Match any supported model. */
- int i;
-
- for (i = 0; i < ARRAY_SIZE(pc263_boards); i++) {
- if (pc263_boards[i].bustype != pci_bustype)
- continue;
- if (pci_dev->device == pc263_boards[i].devid) {
- /* Change board_ptr to matched board. */
- dev->board_ptr = &pc263_boards[i];
- break;
- }
- }
- if (i == ARRAY_SIZE(pc263_boards))
+ /* Wildcard board matches any supported PCI board. */
+ const struct pc263_board *foundboard;
+
+ foundboard = pc263_find_pci_board(pci_dev);
+ if (foundboard == NULL)
continue;
+ /* Replace wildcard board_ptr. */
+ dev->board_ptr = thisboard = foundboard;
} else {
/* Match specific model name. */
if (pci_dev->device != thisboard->devid)
continue;
}
-
- /* Found a match. */
- *pci_dev_p = pci_dev;
- return 0;
+ return pci_dev;
}
- /* No match found. */
- if (bus || slot) {
- printk(KERN_ERR
- "comedi%d: error! no %s found at pci %02x:%02x!\n",
- dev->minor, thisboard->name, bus, slot);
- } else {
- printk(KERN_ERR "comedi%d: error! no %s found!\n",
- dev->minor, thisboard->name);
- }
- return -EIO;
+ dev_err(dev->class_dev,
+ "No supported board found! (req. bus %d, slot %d)\n",
+ bus, slot);
+ return NULL;
}
-#endif
-
/*
- * Attach is called by the Comedi core to configure the driver
- * for a particular board. If you specified a board_name array
- * in the driver structure, dev->board_ptr contains that
- * address.
+ * This function checks and requests an I/O region, reporting an error
+ * if there is a conflict.
*/
-static int pc263_attach(struct comedi_device *dev, struct comedi_devconfig *it)
+static int pc263_request_region(struct comedi_device *dev, unsigned long from,
+ unsigned long extent)
{
- struct comedi_subdevice *s;
- unsigned long iobase = 0;
-#ifdef CONFIG_COMEDI_PCI
- struct pci_dev *pci_dev = NULL;
- int bus = 0, slot = 0;
-#endif
- int ret;
-
- printk(KERN_DEBUG "comedi%d: %s: attach\n", dev->minor,
- PC263_DRIVER_NAME);
-/*
- * Allocate the private structure area. alloc_private() is a
- * convenient macro defined in comedidev.h.
- */
-#ifdef CONFIG_COMEDI_PCI
- ret = alloc_private(dev, sizeof(struct pc263_private));
- if (ret < 0) {
- printk(KERN_ERR "comedi%d: error! out of memory!\n",
- dev->minor);
- return ret;
+ if (!from || !request_region(from, extent, PC263_DRIVER_NAME)) {
+ dev_err(dev->class_dev, "I/O port conflict (%#lx,%lu)!\n",
+ from, extent);
+ return -EIO;
}
-#endif
- /* Process options. */
- switch (thisboard->bustype) {
- case isa_bustype:
- iobase = it->options[0];
- break;
-#ifdef CONFIG_COMEDI_PCI
- case pci_bustype:
- bus = it->options[0];
- slot = it->options[1];
-
- ret = pc263_find_pci(dev, bus, slot, &pci_dev);
- if (ret < 0)
- return ret;
- devpriv->pci_dev = pci_dev;
- break;
-#endif /* CONFIG_COMEDI_PCI */
- default:
- printk(KERN_ERR
- "comedi%d: %s: BUG! cannot determine board type!\n",
- dev->minor, PC263_DRIVER_NAME);
- return -EINVAL;
- break;
+ return 0;
+}
+
+static int pc263_do_insn_bits(struct comedi_device *dev,
+ struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
+{
+ /* The insn data is a mask in data[0] and the new data
+ * in data[1], each channel cooresponding to a bit. */
+ if (data[0]) {
+ s->state &= ~data[0];
+ s->state |= data[0] & data[1];
+ /* Write out the new digital output lines */
+ outb(s->state & 0xFF, dev->iobase);
+ outb(s->state >> 8, dev->iobase + 1);
}
+ return insn->n;
+}
-/*
- * Initialize dev->board_name.
- */
- dev->board_name = thisboard->name;
+static void pc263_report_attach(struct comedi_device *dev)
+{
+ const struct pc263_board *thisboard = comedi_board(dev);
+ struct pci_dev *pcidev = comedi_to_pci_dev(dev);
+ char tmpbuf[40];
+
+ if (IS_ENABLED(CONFIG_COMEDI_AMPLC_PC263_ISA) &&
+ thisboard->bustype == isa_bustype)
+ snprintf(tmpbuf, sizeof(tmpbuf), "(base %#lx) ", dev->iobase);
+ else if (IS_ENABLED(CONFIG_COMEDI_AMPLC_PC263_PCI) &&
+ thisboard->bustype == pci_bustype)
+ snprintf(tmpbuf, sizeof(tmpbuf), "(pci %s) ",
+ pci_name(pcidev));
+ else
+ tmpbuf[0] = '\0';
+ dev_info(dev->class_dev, "%s %sattached\n", dev->board_name, tmpbuf);
+}
- /* Enable device and reserve I/O spaces. */
-#ifdef CONFIG_COMEDI_PCI
- if (pci_dev) {
- ret = comedi_pci_enable(pci_dev, PC263_DRIVER_NAME);
- if (ret < 0) {
- printk(KERN_ERR
- "comedi%d: error! cannot enable PCI device and "
- "request regions!\n",
- dev->minor);
- return ret;
- }
- iobase = pci_resource_start(pci_dev, 2);
- } else
-#endif
- {
- ret = pc263_request_region(dev->minor, iobase, PC263_IO_SIZE);
- if (ret < 0)
- return ret;
- }
+static int pc263_common_attach(struct comedi_device *dev, unsigned long iobase)
+{
+ const struct pc263_board *thisboard = comedi_board(dev);
+ struct comedi_subdevice *s;
+ int ret;
+
+ dev->board_name = thisboard->name;
dev->iobase = iobase;
-/*
- * Allocate the subdevice structures. alloc_subdevice() is a
- * convenient macro defined in comedidev.h.
- */
- ret = alloc_subdevices(dev, 1);
- if (ret < 0) {
- printk(KERN_ERR "comedi%d: error! out of memory!\n",
- dev->minor);
+ ret = comedi_alloc_subdevices(dev, 1);
+ if (ret)
return ret;
- }
s = dev->subdevices + 0;
- /* digital i/o subdevice */
- s->type = COMEDI_SUBD_DIO;
+ /* digital output subdevice */
+ s->type = COMEDI_SUBD_DO;
s->subdev_flags = SDF_READABLE | SDF_WRITABLE;
s->n_chan = 16;
s->maxdata = 1;
s->range_table = &range_digital;
- s->insn_bits = pc263_dio_insn_bits;
- s->insn_config = pc263_dio_insn_config;
- /* all outputs */
- s->io_bits = 0xffff;
+ s->insn_bits = pc263_do_insn_bits;
/* read initial relay state */
- s->state = inb(dev->iobase);
- s->state = s->state | (inb(dev->iobase) << 8);
-
- printk(KERN_INFO "comedi%d: %s ", dev->minor, dev->board_name);
- if (thisboard->bustype == isa_bustype) {
- printk("(base %#lx) ", iobase);
- } else {
-#ifdef CONFIG_COMEDI_PCI
- printk("(pci %s) ", pci_name(pci_dev));
-#endif
- }
-
- printk("attached\n");
+ s->state = inb(dev->iobase) | (inb(dev->iobase + 1) << 8);
+ pc263_report_attach(dev);
return 1;
}
-/*
- * _detach is called to deconfigure a device. It should deallocate
- * resources.
- * This function is also called when _attach() fails, so it should be
- * careful not to release resources that were not necessarily
- * allocated by _attach(). dev->private and dev->subdevices are
- * deallocated automatically by the core.
- */
-static int pc263_detach(struct comedi_device *dev)
+static int pc263_pci_common_attach(struct comedi_device *dev,
+ struct pci_dev *pci_dev)
{
- printk(KERN_DEBUG "comedi%d: %s: detach\n", dev->minor,
- PC263_DRIVER_NAME);
+ unsigned long iobase;
+ int ret;
-#ifdef CONFIG_COMEDI_PCI
- if (devpriv) {
-#endif
-#ifdef CONFIG_COMEDI_PCI
- if (devpriv->pci_dev) {
- if (dev->iobase)
- comedi_pci_disable(devpriv->pci_dev);
- pci_dev_put(devpriv->pci_dev);
- } else
-#endif
- {
- if (dev->iobase)
- release_region(dev->iobase, PC263_IO_SIZE);
- }
- }
- if (dev->board_name) {
- printk(KERN_INFO "comedi%d: %s removed\n",
- dev->minor, dev->board_name);
+ comedi_set_hw_dev(dev, &pci_dev->dev);
+
+ ret = comedi_pci_enable(pci_dev, PC263_DRIVER_NAME);
+ if (ret < 0) {
+ dev_err(dev->class_dev,
+ "error! cannot enable PCI device and request regions!\n");
+ return ret;
}
- return 0;
+ iobase = pci_resource_start(pci_dev, 2);
+ return pc263_common_attach(dev, iobase);
}
/*
- * This function checks and requests an I/O region, reporting an error
- * if there is a conflict.
+ * Attach is called by the Comedi core to configure the driver
+ * for a particular board. If you specified a board_name array
+ * in the driver structure, dev->board_ptr contains that
+ * address.
*/
-static int pc263_request_region(unsigned minor, unsigned long from,
- unsigned long extent)
+static int pc263_attach(struct comedi_device *dev, struct comedi_devconfig *it)
{
- if (!from || !request_region(from, extent, PC263_DRIVER_NAME)) {
- printk(KERN_ERR "comedi%d: I/O port conflict (%#lx,%lu)!\n",
- minor, from, extent);
- return -EIO;
+ const struct pc263_board *thisboard = comedi_board(dev);
+ int ret;
+
+ dev_info(dev->class_dev, PC263_DRIVER_NAME ": attach\n");
+
+ /* Process options and reserve resources according to bus type. */
+ if (IS_ENABLED(CONFIG_COMEDI_AMPLC_PC263_ISA) &&
+ thisboard->bustype == isa_bustype) {
+ unsigned long iobase = it->options[0];
+ ret = pc263_request_region(dev, iobase, PC263_IO_SIZE);
+ if (ret < 0)
+ return ret;
+ return pc263_common_attach(dev, iobase);
+ } else if (IS_ENABLED(CONFIG_COMEDI_AMPLC_PC263_PCI) &&
+ thisboard->bustype == pci_bustype) {
+ struct pci_dev *pci_dev;
+
+ pci_dev = pc263_find_pci_dev(dev, it);
+ if (!pci_dev)
+ return -EIO;
+ return pc263_pci_common_attach(dev, pci_dev);
+ } else {
+ dev_err(dev->class_dev, PC263_DRIVER_NAME
+ ": BUG! cannot determine board type!\n");
+ return -EINVAL;
}
- return 0;
}
-
-/* DIO devices are slightly special. Although it is possible to
- * implement the insn_read/insn_write interface, it is much more
- * useful to applications if you implement the insn_bits interface.
- * This allows packed reading/writing of the DIO channels. The
- * comedi core can convert between insn_bits and insn_read/write */
-static int pc263_dio_insn_bits(struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data)
+/*
+ * The attach_pci hook (if non-NULL) is called at PCI probe time in preference
+ * to the "manual" attach hook. dev->board_ptr is NULL on entry. There should
+ * be a board entry matching the supplied PCI device.
+ */
+static int __devinit pc263_attach_pci(struct comedi_device *dev,
+ struct pci_dev *pci_dev)
{
- if (insn->n != 2)
+ if (!IS_ENABLED(CONFIG_COMEDI_AMPLC_PC263_PCI))
return -EINVAL;
- /* The insn data is a mask in data[0] and the new data
- * in data[1], each channel cooresponding to a bit. */
- if (data[0]) {
- s->state &= ~data[0];
- s->state |= data[0] & data[1];
- /* Write out the new digital output lines */
- outb(s->state & 0xFF, dev->iobase);
- outb(s->state >> 8, dev->iobase + 1);
+ dev_info(dev->class_dev, PC263_DRIVER_NAME ": attach pci %s\n",
+ pci_name(pci_dev));
+ dev->board_ptr = pc263_find_pci_board(pci_dev);
+ if (dev->board_ptr == NULL) {
+ dev_err(dev->class_dev, "BUG! cannot determine board type!\n");
+ return -EINVAL;
}
-
- /* on return, data[1] contains the value of the digital
- * input and output lines. */
- /* or we could just return the software copy of the output values if
- * it was a purely digital output subdevice */
- data[1] = s->state;
-
- return 2;
+ return pc263_pci_common_attach(dev, pci_dev);
}
-static int pc263_dio_insn_config(struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data)
+static void pc263_detach(struct comedi_device *dev)
{
- if (insn->n != 1)
- return -EINVAL;
- return 1;
+ struct pci_dev *pcidev = comedi_to_pci_dev(dev);
+
+ if (pcidev) {
+ if (dev->iobase)
+ comedi_pci_disable(pcidev);
+ pci_dev_put(pcidev);
+ } else {
+ if (dev->iobase)
+ release_region(dev->iobase, PC263_IO_SIZE);
+ }
}
/*
- * A convenient macro that defines init_module() and cleanup_module(),
- * as necessary.
+ * The struct comedi_driver structure tells the Comedi core module
+ * which functions to call to configure/deconfigure (attach/detach)
+ * the board, and also about the kernel module that contains
+ * the device code.
*/
-#ifdef CONFIG_COMEDI_PCI
-static int __devinit driver_amplc_pc263_pci_probe(struct pci_dev *dev,
+static struct comedi_driver amplc_pc263_driver = {
+ .driver_name = PC263_DRIVER_NAME,
+ .module = THIS_MODULE,
+ .attach = pc263_attach,
+ .attach_pci = pc263_attach_pci,
+ .detach = pc263_detach,
+ .board_name = &pc263_boards[0].name,
+ .offset = sizeof(struct pc263_board),
+ .num_names = ARRAY_SIZE(pc263_boards),
+};
+
+#if IS_ENABLED(CONFIG_COMEDI_AMPLC_PC263_PCI)
+static DEFINE_PCI_DEVICE_TABLE(pc263_pci_table) = {
+ { PCI_DEVICE(PCI_VENDOR_ID_AMPLICON, PCI_DEVICE_ID_AMPLICON_PCI263) },
+ {0}
+};
+MODULE_DEVICE_TABLE(pci, pc263_pci_table);
+
+static int __devinit amplc_pc263_pci_probe(struct pci_dev *dev,
const struct pci_device_id
*ent)
{
- return comedi_pci_auto_config(dev, driver_amplc_pc263.driver_name);
+ return comedi_pci_auto_config(dev, &amplc_pc263_driver);
}
-static void __devexit driver_amplc_pc263_pci_remove(struct pci_dev *dev)
+static void __devexit amplc_pc263_pci_remove(struct pci_dev *dev)
{
comedi_pci_auto_unconfig(dev);
}
-static struct pci_driver driver_amplc_pc263_pci_driver = {
+static struct pci_driver amplc_pc263_pci_driver = {
+ .name = PC263_DRIVER_NAME,
.id_table = pc263_pci_table,
- .probe = &driver_amplc_pc263_pci_probe,
- .remove = __devexit_p(&driver_amplc_pc263_pci_remove)
+ .probe = &amplc_pc263_pci_probe,
+ .remove = __devexit_p(&amplc_pc263_pci_remove)
};
-
-static int __init driver_amplc_pc263_init_module(void)
-{
- int retval;
-
- retval = comedi_driver_register(&driver_amplc_pc263);
- if (retval < 0)
- return retval;
-
- driver_amplc_pc263_pci_driver.name =
- (char *)driver_amplc_pc263.driver_name;
- return pci_register_driver(&driver_amplc_pc263_pci_driver);
-}
-
-static void __exit driver_amplc_pc263_cleanup_module(void)
-{
- pci_unregister_driver(&driver_amplc_pc263_pci_driver);
- comedi_driver_unregister(&driver_amplc_pc263);
-}
-
-module_init(driver_amplc_pc263_init_module);
-module_exit(driver_amplc_pc263_cleanup_module);
+module_comedi_pci_driver(amplc_pc263_driver, amplc_pc263_pci_driver);
#else
-static int __init driver_amplc_pc263_init_module(void)
-{
- return comedi_driver_register(&driver_amplc_pc263);
-}
-
-static void __exit driver_amplc_pc263_cleanup_module(void)
-{
- comedi_driver_unregister(&driver_amplc_pc263);
-}
-
-module_init(driver_amplc_pc263_init_module);
-module_exit(driver_amplc_pc263_cleanup_module);
+module_comedi_driver(amplc_pc263_driver);
#endif
MODULE_AUTHOR("Comedi http://www.comedi.org");
diff --git a/drivers/staging/comedi/drivers/amplc_pci224.c b/drivers/staging/comedi/drivers/amplc_pci224.c
index b278917cec25..4e17f13e57f6 100644
--- a/drivers/staging/comedi/drivers/amplc_pci224.c
+++ b/drivers/staging/comedi/drivers/amplc_pci224.c
@@ -108,8 +108,6 @@ Caveats:
#include "../comedidev.h"
-#include "comedi_pci.h"
-
#include "comedi_fc.h"
#include "8253.h"
@@ -267,9 +265,6 @@ Caveats:
/* Combine old and new bits. */
#define COMBINE(old, new, mask) (((old) & ~(mask)) | ((new) & (mask)))
-/* A generic null function pointer value. */
-#define NULLFUNC 0
-
/* Current CPU. XXX should this be hard_smp_processor_id()? */
#define THISCPU smp_processor_id()
@@ -379,28 +374,10 @@ static const struct pci224_board pci224_boards[] = {
},
};
-/*
- * PCI driver table.
- */
-
-static DEFINE_PCI_DEVICE_TABLE(pci224_pci_table) = {
- { PCI_DEVICE(PCI_VENDOR_ID_AMPLICON, PCI_DEVICE_ID_AMPLICON_PCI224) },
- { PCI_DEVICE(PCI_VENDOR_ID_AMPLICON, PCI_DEVICE_ID_AMPLICON_PCI234) },
- {0}
-};
-
-MODULE_DEVICE_TABLE(pci, pci224_pci_table);
-
-/*
- * Useful for shorthand access to the particular board structure
- */
-#define thisboard ((struct pci224_board *)dev->board_ptr)
-
/* this structure is for data unique to this hardware driver. If
several hardware drivers keep similar information in this structure,
feel free to suggest moving the variable to the struct comedi_device struct. */
struct pci224_private {
- struct pci_dev *pci_dev; /* PCI device */
const unsigned short *hwrange;
unsigned long iobase1;
unsigned long state;
@@ -419,67 +396,6 @@ struct pci224_private {
unsigned char intsce;
};
-#define devpriv ((struct pci224_private *)dev->private)
-
-/*
- * The struct comedi_driver structure tells the Comedi core module
- * which functions to call to configure/deconfigure (attach/detach)
- * the board, and also about the kernel module that contains
- * the device code.
- */
-static int pci224_attach(struct comedi_device *dev,
- struct comedi_devconfig *it);
-static int pci224_detach(struct comedi_device *dev);
-static struct comedi_driver driver_amplc_pci224 = {
- .driver_name = DRIVER_NAME,
- .module = THIS_MODULE,
- .attach = pci224_attach,
- .detach = pci224_detach,
- .board_name = &pci224_boards[0].name,
- .offset = sizeof(struct pci224_board),
- .num_names = ARRAY_SIZE(pci224_boards),
-};
-
-static int __devinit driver_amplc_pci224_pci_probe(struct pci_dev *dev,
- const struct pci_device_id
- *ent)
-{
- return comedi_pci_auto_config(dev, driver_amplc_pci224.driver_name);
-}
-
-static void __devexit driver_amplc_pci224_pci_remove(struct pci_dev *dev)
-{
- comedi_pci_auto_unconfig(dev);
-}
-
-static struct pci_driver driver_amplc_pci224_pci_driver = {
- .id_table = pci224_pci_table,
- .probe = &driver_amplc_pci224_pci_probe,
- .remove = __devexit_p(&driver_amplc_pci224_pci_remove)
-};
-
-static int __init driver_amplc_pci224_init_module(void)
-{
- int retval;
-
- retval = comedi_driver_register(&driver_amplc_pci224);
- if (retval < 0)
- return retval;
-
- driver_amplc_pci224_pci_driver.name =
- (char *)driver_amplc_pci224.driver_name;
- return pci_register_driver(&driver_amplc_pci224_pci_driver);
-}
-
-static void __exit driver_amplc_pci224_cleanup_module(void)
-{
- pci_unregister_driver(&driver_amplc_pci224_pci_driver);
- comedi_driver_unregister(&driver_amplc_pci224);
-}
-
-module_init(driver_amplc_pci224_init_module);
-module_exit(driver_amplc_pci224_cleanup_module);
-
/*
* Called from the 'insn_write' function to perform a single write.
*/
@@ -487,6 +403,8 @@ static void
pci224_ao_set_data(struct comedi_device *dev, int chan, int range,
unsigned int data)
{
+ const struct pci224_board *thisboard = comedi_board(dev);
+ struct pci224_private *devpriv = dev->private;
unsigned short mangled;
/* Store unmangled data for readback. */
@@ -549,6 +467,7 @@ static int
pci224_ao_insn_read(struct comedi_device *dev, struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
+ struct pci224_private *devpriv = dev->private;
int i;
int chan;
@@ -577,6 +496,7 @@ pci224_cascade_ns_to_timer(int osc_base, unsigned int *d1, unsigned int *d2,
static void pci224_ao_stop(struct comedi_device *dev,
struct comedi_subdevice *s)
{
+ struct pci224_private *devpriv = dev->private;
unsigned long flags;
if (!test_and_clear_bit(AO_CMD_STARTED, &devpriv->state))
@@ -620,6 +540,7 @@ static void pci224_ao_stop(struct comedi_device *dev,
static void pci224_ao_start(struct comedi_device *dev,
struct comedi_subdevice *s)
{
+ struct pci224_private *devpriv = dev->private;
struct comedi_cmd *cmd = &s->async->cmd;
unsigned long flags;
@@ -648,6 +569,7 @@ static void pci224_ao_start(struct comedi_device *dev,
static void pci224_ao_handle_fifo(struct comedi_device *dev,
struct comedi_subdevice *s)
{
+ struct pci224_private *devpriv = dev->private;
struct comedi_cmd *cmd = &s->async->cmd;
unsigned int num_scans;
unsigned int room;
@@ -699,8 +621,7 @@ static void pci224_ao_handle_fifo(struct comedi_device *dev,
/* Nothing left to put in the FIFO. */
pci224_ao_stop(dev, s);
s->async->events |= COMEDI_CB_OVERFLOW;
- printk(KERN_ERR "comedi%d: "
- "AO buffer underrun\n", dev->minor);
+ dev_err(dev->class_dev, "AO buffer underrun\n");
}
}
/* Determine how many new scans can be put in the FIFO. */
@@ -778,7 +699,7 @@ pci224_ao_inttrig_start(struct comedi_device *dev, struct comedi_subdevice *s,
if (trignum != 0)
return -EINVAL;
- s->async->inttrig = NULLFUNC;
+ s->async->inttrig = NULL;
pci224_ao_start(dev, s);
return 1;
@@ -795,6 +716,7 @@ static int
pci224_ao_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
struct comedi_cmd *cmd)
{
+ struct pci224_private *devpriv = dev->private;
int err = 0;
unsigned int tmp;
@@ -1065,6 +987,7 @@ pci224_ao_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
*/
static int pci224_ao_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
{
+ struct pci224_private *devpriv = dev->private;
struct comedi_cmd *cmd = &s->async->cmd;
int range;
unsigned int i, j;
@@ -1237,6 +1160,8 @@ static void
pci224_ao_munge(struct comedi_device *dev, struct comedi_subdevice *s,
void *data, unsigned int num_bytes, unsigned int chan_index)
{
+ const struct pci224_board *thisboard = comedi_board(dev);
+ struct pci224_private *devpriv = dev->private;
struct comedi_async *async = s->async;
short *array = data;
unsigned int length = num_bytes / sizeof(*array);
@@ -1267,6 +1192,7 @@ pci224_ao_munge(struct comedi_device *dev, struct comedi_subdevice *s,
static irqreturn_t pci224_interrupt(int irq, void *d)
{
struct comedi_device *dev = d;
+ struct pci224_private *devpriv = dev->private;
struct comedi_subdevice *s = &dev->subdevices[0];
struct comedi_cmd *cmd;
unsigned char intstat, valid_intstat;
@@ -1312,99 +1238,96 @@ static irqreturn_t pci224_interrupt(int irq, void *d)
}
/*
+ * This function looks for a board matching the supplied PCI device.
+ */
+static const struct pci224_board
+*pci224_find_pci_board(struct pci_dev *pci_dev)
+{
+ int i;
+
+ for (i = 0; i < ARRAY_SIZE(pci224_boards); i++)
+ if (pci_dev->device == pci224_boards[i].devid)
+ return &pci224_boards[i];
+ return NULL;
+}
+
+/*
* This function looks for a PCI device matching the requested board name,
* bus and slot.
*/
-static int
-pci224_find_pci(struct comedi_device *dev, int bus, int slot,
- struct pci_dev **pci_dev_p)
+static struct pci_dev *pci224_find_pci_dev(struct comedi_device *dev,
+ struct comedi_devconfig *it)
{
+ const struct pci224_board *thisboard = comedi_board(dev);
struct pci_dev *pci_dev = NULL;
+ int bus = it->options[0];
+ int slot = it->options[1];
- *pci_dev_p = NULL;
-
- /* Look for matching PCI device. */
- for (pci_dev = pci_get_device(PCI_VENDOR_ID_AMPLICON, PCI_ANY_ID, NULL);
- pci_dev != NULL;
- pci_dev = pci_get_device(PCI_VENDOR_ID_AMPLICON, PCI_ANY_ID,
- pci_dev)) {
- /* If bus/slot specified, check them. */
+ for_each_pci_dev(pci_dev) {
if (bus || slot) {
- if (bus != pci_dev->bus->number
- || slot != PCI_SLOT(pci_dev->devfn))
+ if (bus != pci_dev->bus->number ||
+ slot != PCI_SLOT(pci_dev->devfn))
continue;
}
+ if (pci_dev->vendor != PCI_VENDOR_ID_AMPLICON)
+ continue;
+
if (thisboard->model == any_model) {
/* Match any supported model. */
- int i;
+ const struct pci224_board *board_ptr;
- for (i = 0; i < ARRAY_SIZE(pci224_boards); i++) {
- if (pci_dev->device == pci224_boards[i].devid) {
- /* Change board_ptr to matched board. */
- dev->board_ptr = &pci224_boards[i];
- break;
- }
- }
- if (i == ARRAY_SIZE(pci224_boards))
+ board_ptr = pci224_find_pci_board(pci_dev);
+ if (board_ptr == NULL)
continue;
+ /* Change board_ptr to matched board. */
+ dev->board_ptr = board_ptr;
} else {
/* Match specific model name. */
if (thisboard->devid != pci_dev->device)
continue;
}
-
- /* Found a match. */
- *pci_dev_p = pci_dev;
- return 0;
- }
- /* No match found. */
- if (bus || slot) {
- printk(KERN_ERR "comedi%d: error! "
- "no %s found at pci %02x:%02x!\n",
- dev->minor, thisboard->name, bus, slot);
- } else {
- printk(KERN_ERR "comedi%d: error! no %s found!\n",
- dev->minor, thisboard->name);
+ return pci_dev;
}
- return -EIO;
+ dev_err(dev->class_dev,
+ "No supported board found! (req. bus %d, slot %d)\n",
+ bus, slot);
+ return NULL;
+}
+
+static void pci224_report_attach(struct comedi_device *dev, unsigned int irq)
+{
+ struct pci_dev *pcidev = comedi_to_pci_dev(dev);
+ char tmpbuf[30];
+
+ if (irq)
+ snprintf(tmpbuf, sizeof(tmpbuf), "irq %u%s", irq,
+ (dev->irq ? "" : " UNAVAILABLE"));
+ else
+ snprintf(tmpbuf, sizeof(tmpbuf), "no irq");
+ dev_info(dev->class_dev, "%s (pci %s) (%s) attached\n",
+ dev->board_name, pci_name(pcidev), tmpbuf);
}
/*
- * Attach is called by the Comedi core to configure the driver
- * for a particular board. If you specified a board_name array
- * in the driver structure, dev->board_ptr contains that
- * address.
+ * Common part of attach and attach_pci.
*/
-static int pci224_attach(struct comedi_device *dev, struct comedi_devconfig *it)
+static int pci224_attach_common(struct comedi_device *dev,
+ struct pci_dev *pci_dev, int *options)
{
+ const struct pci224_board *thisboard = comedi_board(dev);
+ struct pci224_private *devpriv = dev->private;
struct comedi_subdevice *s;
- struct pci_dev *pci_dev;
unsigned int irq;
- int bus = 0, slot = 0;
unsigned n;
int ret;
- printk(KERN_DEBUG "comedi%d: %s: attach\n", dev->minor, DRIVER_NAME);
+ comedi_set_hw_dev(dev, &pci_dev->dev);
- bus = it->options[0];
- slot = it->options[1];
- ret = alloc_private(dev, sizeof(struct pci224_private));
- if (ret < 0) {
- printk(KERN_ERR "comedi%d: error! out of memory!\n",
- dev->minor);
- return ret;
- }
-
- ret = pci224_find_pci(dev, bus, slot, &pci_dev);
- if (ret < 0)
- return ret;
-
- devpriv->pci_dev = pci_dev;
ret = comedi_pci_enable(pci_dev, DRIVER_NAME);
if (ret < 0) {
- printk(KERN_ERR
- "comedi%d: error! cannot enable PCI device "
- "and request regions!\n", dev->minor);
+ dev_err(dev->class_dev,
+ "error! cannot enable PCI device and request regions!\n"
+ );
return ret;
}
spin_lock_init(&devpriv->ao_spinlock);
@@ -1448,13 +1371,9 @@ static int pci224_attach(struct comedi_device *dev, struct comedi_devconfig *it)
outw(devpriv->daccon | PCI224_DACCON_FIFORESET,
dev->iobase + PCI224_DACCON);
- /* Allocate subdevices. There is only one! */
- ret = alloc_subdevices(dev, 1);
- if (ret < 0) {
- printk(KERN_ERR "comedi%d: error! out of memory!\n",
- dev->minor);
+ ret = comedi_alloc_subdevices(dev, 1);
+ if (ret)
return ret;
- }
s = dev->subdevices + 0;
/* Analog output subdevice. */
@@ -1483,24 +1402,25 @@ static int pci224_attach(struct comedi_device *dev, struct comedi_devconfig *it)
if (!s->range_table_list)
return -ENOMEM;
- for (n = 2; n < 3 + s->n_chan; n++) {
- if (it->options[n] < 0 || it->options[n] > 1) {
- printk(KERN_WARNING "comedi%d: %s: warning! "
- "bad options[%u]=%d\n",
- dev->minor, DRIVER_NAME, n,
- it->options[n]);
+ if (options) {
+ for (n = 2; n < 3 + s->n_chan; n++) {
+ if (options[n] < 0 || options[n] > 1) {
+ dev_warn(dev->class_dev, DRIVER_NAME
+ ": warning! bad options[%u]=%d\n",
+ n, options[n]);
+ }
}
}
for (n = 0; n < s->n_chan; n++) {
- if (n < COMEDI_NDEVCONFOPTS - 3 &&
- it->options[3 + n] == 1) {
- if (it->options[2] == 1)
+ if (n < COMEDI_NDEVCONFOPTS - 3 && options &&
+ options[3 + n] == 1) {
+ if (options[2] == 1)
range_table_list[n] = &range_pci234_ext;
else
range_table_list[n] = &range_bipolar5;
} else {
- if (it->options[2] == 1) {
+ if (options && options[2] == 1) {
range_table_list[n] =
&range_pci234_ext2;
} else {
@@ -1511,14 +1431,14 @@ static int pci224_attach(struct comedi_device *dev, struct comedi_devconfig *it)
devpriv->hwrange = hwrange_pci234;
} else {
/* PCI224 range options. */
- if (it->options[2] == 1) {
+ if (options && options[2] == 1) {
s->range_table = &range_pci224_external;
devpriv->hwrange = hwrange_pci224_external;
} else {
- if (it->options[2] != 0) {
- printk(KERN_WARNING "comedi%d: %s: warning! "
- "bad options[2]=%d\n",
- dev->minor, DRIVER_NAME, it->options[2]);
+ if (options && options[2] != 0) {
+ dev_warn(dev->class_dev, DRIVER_NAME
+ ": warning! bad options[2]=%d\n",
+ options[2]);
}
s->range_table = &range_pci224_internal;
devpriv->hwrange = hwrange_pci224_internal;
@@ -1531,42 +1451,68 @@ static int pci224_attach(struct comedi_device *dev, struct comedi_devconfig *it)
ret = request_irq(irq, pci224_interrupt, IRQF_SHARED,
DRIVER_NAME, dev);
if (ret < 0) {
- printk(KERN_ERR "comedi%d: error! "
- "unable to allocate irq %u\n", dev->minor, irq);
+ dev_err(dev->class_dev,
+ "error! unable to allocate irq %u\n", irq);
return ret;
} else {
dev->irq = irq;
}
}
- printk(KERN_INFO "comedi%d: %s ", dev->minor, dev->board_name);
- printk("(pci %s) ", pci_name(pci_dev));
- if (irq)
- printk("(irq %u%s) ", irq, (dev->irq ? "" : " UNAVAILABLE"));
- else
- printk("(no irq) ");
+ pci224_report_attach(dev, irq);
+ return 1;
+}
+
+static int pci224_attach(struct comedi_device *dev, struct comedi_devconfig *it)
+{
+ struct pci_dev *pci_dev;
+ int ret;
+ dev_info(dev->class_dev, DRIVER_NAME ": attach\n");
- printk("attached\n");
+ ret = alloc_private(dev, sizeof(struct pci224_private));
+ if (ret < 0) {
+ dev_err(dev->class_dev, "error! out of memory!\n");
+ return ret;
+ }
- return 1;
+ pci_dev = pci224_find_pci_dev(dev, it);
+ if (!pci_dev)
+ return -EIO;
+
+ return pci224_attach_common(dev, pci_dev, it->options);
}
-/*
- * _detach is called to deconfigure a device. It should deallocate
- * resources.
- * This function is also called when _attach() fails, so it should be
- * careful not to release resources that were not necessarily
- * allocated by _attach(). dev->private and dev->subdevices are
- * deallocated automatically by the core.
- */
-static int pci224_detach(struct comedi_device *dev)
+static int __devinit
+pci224_attach_pci(struct comedi_device *dev, struct pci_dev *pci_dev)
+{
+ int ret;
+
+ dev_info(dev->class_dev, DRIVER_NAME ": attach_pci %s\n",
+ pci_name(pci_dev));
+
+ ret = alloc_private(dev, sizeof(struct pci224_private));
+ if (ret < 0) {
+ dev_err(dev->class_dev, "error! out of memory!\n");
+ return ret;
+ }
+
+ dev->board_ptr = pci224_find_pci_board(pci_dev);
+ if (dev->board_ptr == NULL) {
+ dev_err(dev->class_dev,
+ DRIVER_NAME ": BUG! cannot determine board type!\n");
+ return -EINVAL;
+ }
+ return pci224_attach_common(dev, pci_dev, NULL);
+}
+
+static void pci224_detach(struct comedi_device *dev)
{
- printk(KERN_DEBUG "comedi%d: %s: detach\n", dev->minor, DRIVER_NAME);
+ struct pci224_private *devpriv = dev->private;
+ struct pci_dev *pcidev = comedi_to_pci_dev(dev);
if (dev->irq)
free_irq(dev->irq, dev);
-
if (dev->subdevices) {
struct comedi_subdevice *s;
@@ -1578,21 +1524,52 @@ static int pci224_detach(struct comedi_device *dev)
kfree(devpriv->ao_readback);
kfree(devpriv->ao_scan_vals);
kfree(devpriv->ao_scan_order);
- if (devpriv->pci_dev) {
- if (dev->iobase)
- comedi_pci_disable(devpriv->pci_dev);
-
- pci_dev_put(devpriv->pci_dev);
- }
}
- if (dev->board_name) {
- printk(KERN_INFO "comedi%d: %s removed\n",
- dev->minor, dev->board_name);
+ if (pcidev) {
+ if (dev->iobase)
+ comedi_pci_disable(pcidev);
+ pci_dev_put(pcidev);
}
+}
- return 0;
+static struct comedi_driver amplc_pci224_driver = {
+ .driver_name = "amplc_pci224",
+ .module = THIS_MODULE,
+ .attach = pci224_attach,
+ .detach = pci224_detach,
+ .attach_pci = pci224_attach_pci,
+ .board_name = &pci224_boards[0].name,
+ .offset = sizeof(struct pci224_board),
+ .num_names = ARRAY_SIZE(pci224_boards),
+};
+
+static int __devinit amplc_pci224_pci_probe(struct pci_dev *dev,
+ const struct pci_device_id
+ *ent)
+{
+ return comedi_pci_auto_config(dev, &amplc_pci224_driver);
}
+static void __devexit amplc_pci224_pci_remove(struct pci_dev *dev)
+{
+ comedi_pci_auto_unconfig(dev);
+}
+
+static DEFINE_PCI_DEVICE_TABLE(amplc_pci224_pci_table) = {
+ { PCI_DEVICE(PCI_VENDOR_ID_AMPLICON, PCI_DEVICE_ID_AMPLICON_PCI224) },
+ { PCI_DEVICE(PCI_VENDOR_ID_AMPLICON, PCI_DEVICE_ID_AMPLICON_PCI234) },
+ { 0 }
+};
+MODULE_DEVICE_TABLE(pci, amplc_pci224_pci_table);
+
+static struct pci_driver amplc_pci224_pci_driver = {
+ .name = "amplc_pci224",
+ .id_table = amplc_pci224_pci_table,
+ .probe = amplc_pci224_pci_probe,
+ .remove = __devexit_p(amplc_pci224_pci_remove),
+};
+module_comedi_pci_driver(amplc_pci224_driver, amplc_pci224_pci_driver);
+
MODULE_AUTHOR("Comedi http://www.comedi.org");
MODULE_DESCRIPTION("Comedi low-level driver");
MODULE_LICENSE("GPL");
diff --git a/drivers/staging/comedi/drivers/amplc_pci230.c b/drivers/staging/comedi/drivers/amplc_pci230.c
index 538979551c8e..1b67d0c61fa7 100644
--- a/drivers/staging/comedi/drivers/amplc_pci230.c
+++ b/drivers/staging/comedi/drivers/amplc_pci230.c
@@ -193,7 +193,6 @@ for (or detection of) various hardware problems added by Ian Abbott.
#include <linux/delay.h>
#include <linux/interrupt.h>
-#include "comedi_pci.h"
#include "8253.h"
#include "8255.h"
@@ -431,9 +430,6 @@ enum {
/* Combine old and new bits. */
#define COMBINE(old, new, mask) (((old) & ~(mask)) | ((new) & (mask)))
-/* A generic null function pointer value. */
-#define NULLFUNC 0
-
/* Current CPU. XXX should this be hard_smp_processor_id()? */
#define THISCPU smp_processor_id()
@@ -500,24 +496,10 @@ static const struct pci230_board pci230_boards[] = {
},
};
-static DEFINE_PCI_DEVICE_TABLE(pci230_pci_table) = {
- { PCI_DEVICE(PCI_VENDOR_ID_AMPLICON, PCI_DEVICE_ID_PCI230) },
- { PCI_DEVICE(PCI_VENDOR_ID_AMPLICON, PCI_DEVICE_ID_PCI260) },
- {0}
-};
-
-MODULE_DEVICE_TABLE(pci, pci230_pci_table);
-/*
- * Useful for shorthand access to the particular board structure
- */
-#define n_pci230_boards ARRAY_SIZE(pci230_boards)
-#define thisboard ((const struct pci230_board *)dev->board_ptr)
-
/* this structure is for data unique to this hardware driver. If
several hardware drivers keep similar information in this structure,
feel free to suggest moving the variable to the struct comedi_device struct. */
struct pci230_private {
- struct pci_dev *pci_dev;
spinlock_t isr_spinlock; /* Interrupt spin lock */
spinlock_t res_spinlock; /* Shared resources spin lock */
spinlock_t ai_stop_spinlock; /* Spin lock for stopping AI command */
@@ -556,8 +538,6 @@ struct pci230_private {
unsigned char res_owner[NUM_RESOURCES]; /* Shared resource owners. */
};
-#define devpriv ((struct pci230_private *)dev->private)
-
/* PCI230 clock source periods in ns */
static const unsigned int pci230_timebase[8] = {
[CLK_10MHZ] = TIMEBASE_10MHZ,
@@ -595,108 +575,14 @@ static const struct comedi_lrange pci230_ao_range = { 2, {
/* PCI230 daccon bipolar flag for each analogue output range. */
static const unsigned char pci230_ao_bipolar[2] = { 0, 1 };
-/*
- * The struct comedi_driver structure tells the Comedi core module
- * which functions to call to configure/deconfigure (attach/detach)
- * the board, and also about the kernel module that contains
- * the device code.
- */
-static int pci230_attach(struct comedi_device *dev,
- struct comedi_devconfig *it);
-static int pci230_detach(struct comedi_device *dev);
-static struct comedi_driver driver_amplc_pci230 = {
- .driver_name = "amplc_pci230",
- .module = THIS_MODULE,
- .attach = pci230_attach,
- .detach = pci230_detach,
- .board_name = &pci230_boards[0].name,
- .offset = sizeof(pci230_boards[0]),
- .num_names = ARRAY_SIZE(pci230_boards),
-};
-
-static int __devinit driver_amplc_pci230_pci_probe(struct pci_dev *dev,
- const struct pci_device_id
- *ent)
-{
- return comedi_pci_auto_config(dev, driver_amplc_pci230.driver_name);
-}
-
-static void __devexit driver_amplc_pci230_pci_remove(struct pci_dev *dev)
-{
- comedi_pci_auto_unconfig(dev);
-}
-
-static struct pci_driver driver_amplc_pci230_pci_driver = {
- .id_table = pci230_pci_table,
- .probe = &driver_amplc_pci230_pci_probe,
- .remove = __devexit_p(&driver_amplc_pci230_pci_remove)
-};
-
-static int __init driver_amplc_pci230_init_module(void)
-{
- int retval;
-
- retval = comedi_driver_register(&driver_amplc_pci230);
- if (retval < 0)
- return retval;
-
- driver_amplc_pci230_pci_driver.name =
- (char *)driver_amplc_pci230.driver_name;
- return pci_register_driver(&driver_amplc_pci230_pci_driver);
-}
-
-static void __exit driver_amplc_pci230_cleanup_module(void)
-{
- pci_unregister_driver(&driver_amplc_pci230_pci_driver);
- comedi_driver_unregister(&driver_amplc_pci230);
-}
-
-module_init(driver_amplc_pci230_init_module);
-module_exit(driver_amplc_pci230_cleanup_module);
-
-static int pci230_ai_rinsn(struct comedi_device *dev,
- struct comedi_subdevice *s, struct comedi_insn *insn,
- unsigned int *data);
-static int pci230_ao_winsn(struct comedi_device *dev,
- struct comedi_subdevice *s, struct comedi_insn *insn,
- unsigned int *data);
-static int pci230_ao_rinsn(struct comedi_device *dev,
- struct comedi_subdevice *s, struct comedi_insn *insn,
- unsigned int *data);
-static void pci230_ct_setup_ns_mode(struct comedi_device *dev, unsigned int ct,
- unsigned int mode, uint64_t ns,
- unsigned int round);
-static void pci230_ns_to_single_timer(unsigned int *ns, unsigned int round);
-static void pci230_cancel_ct(struct comedi_device *dev, unsigned int ct);
-static irqreturn_t pci230_interrupt(int irq, void *d);
-static int pci230_ao_cmdtest(struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_cmd *cmd);
-static int pci230_ao_cmd(struct comedi_device *dev, struct comedi_subdevice *s);
-static int pci230_ao_cancel(struct comedi_device *dev,
- struct comedi_subdevice *s);
-static void pci230_ao_stop(struct comedi_device *dev,
- struct comedi_subdevice *s);
-static void pci230_handle_ao_nofifo(struct comedi_device *dev,
- struct comedi_subdevice *s);
-static int pci230_handle_ao_fifo(struct comedi_device *dev,
- struct comedi_subdevice *s);
-static int pci230_ai_cmdtest(struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_cmd *cmd);
-static int pci230_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s);
-static int pci230_ai_cancel(struct comedi_device *dev,
- struct comedi_subdevice *s);
-static void pci230_ai_stop(struct comedi_device *dev,
- struct comedi_subdevice *s);
-static void pci230_handle_ai(struct comedi_device *dev,
- struct comedi_subdevice *s);
-
static short pci230_ai_read(struct comedi_device *dev)
{
- /* Read sample. */
- short data = (short)inw(dev->iobase + PCI230_ADCDATA);
+ const struct pci230_board *thisboard = comedi_board(dev);
+ struct pci230_private *devpriv = dev->private;
+ short data;
+ /* Read sample. */
+ data = (short)inw(dev->iobase + PCI230_ADCDATA);
/* PCI230 is 12 bit - stored in upper bits of 16 bit register (lower
* four bits reserved for expansion). */
/* PCI230+ is 16 bit AI. */
@@ -713,12 +599,14 @@ static short pci230_ai_read(struct comedi_device *dev)
static inline unsigned short pci230_ao_mangle_datum(struct comedi_device *dev,
short datum)
{
+ const struct pci230_board *thisboard = comedi_board(dev);
+ struct pci230_private *devpriv = dev->private;
+
/* If a bipolar range was specified, mangle it (straight binary->twos
* complement). */
if (devpriv->ao_bipolar)
datum ^= 1 << (thisboard->ao_bits - 1);
-
/* PCI230 is 12 bit - stored in upper bits of 16 bit register (lower
* four bits reserved for expansion). */
/* PCI230+ is also 12 bit AO. */
@@ -729,6 +617,8 @@ static inline unsigned short pci230_ao_mangle_datum(struct comedi_device *dev,
static inline void pci230_ao_write_nofifo(struct comedi_device *dev,
short datum, unsigned int chan)
{
+ struct pci230_private *devpriv = dev->private;
+
/* Store unmangled datum to be read back later. */
devpriv->ao_readback[chan] = datum;
@@ -742,6 +632,8 @@ static inline void pci230_ao_write_nofifo(struct comedi_device *dev,
static inline void pci230_ao_write_fifo(struct comedi_device *dev, short datum,
unsigned int chan)
{
+ struct pci230_private *devpriv = dev->private;
+
/* Store unmangled datum to be read back later. */
devpriv->ao_readback[chan] = datum;
@@ -750,293 +642,10 @@ static inline void pci230_ao_write_fifo(struct comedi_device *dev, short datum,
dev->iobase + PCI230P2_DACDATA);
}
-/*
- * Attach is called by the Comedi core to configure the driver
- * for a particular board. If you specified a board_name array
- * in the driver structure, dev->board_ptr contains that
- * address.
- */
-static int pci230_attach(struct comedi_device *dev, struct comedi_devconfig *it)
-{
- struct comedi_subdevice *s;
- unsigned long iobase1, iobase2;
- /* PCI230's I/O spaces 1 and 2 respectively. */
- struct pci_dev *pci_dev = NULL;
- int i = 0, irq_hdl, rc;
-
- printk("comedi%d: amplc_pci230: attach %s %d,%d\n", dev->minor,
- thisboard->name, it->options[0], it->options[1]);
-
- /* Allocate the private structure area using alloc_private().
- * Macro defined in comedidev.h - memsets struct fields to 0. */
- if ((alloc_private(dev, sizeof(struct pci230_private))) < 0)
- return -ENOMEM;
-
- spin_lock_init(&devpriv->isr_spinlock);
- spin_lock_init(&devpriv->res_spinlock);
- spin_lock_init(&devpriv->ai_stop_spinlock);
- spin_lock_init(&devpriv->ao_stop_spinlock);
- /* Find card */
- for_each_pci_dev(pci_dev) {
- if (it->options[0] || it->options[1]) {
- /* Match against bus/slot options. */
- if (it->options[0] != pci_dev->bus->number ||
- it->options[1] != PCI_SLOT(pci_dev->devfn))
- continue;
- }
- if (pci_dev->vendor != PCI_VENDOR_ID_AMPLICON)
- continue;
- if (thisboard->id == PCI_DEVICE_ID_INVALID) {
- /* The name was specified as "amplc_pci230" which is
- * used to match any supported device. Replace the
- * current dev->board_ptr with one that matches the
- * PCI device ID. */
- for (i = 0; i < n_pci230_boards; i++) {
- if (pci_dev->device == pci230_boards[i].id) {
- if (pci230_boards[i].min_hwver > 0) {
- /* Check for a '+' model.
- * First check length of
- * registers. */
- if (pci_resource_len(pci_dev, 3)
- < 32) {
- /* Not a '+' model. */
- continue;
- }
- /* TODO: temporarily enable the
- * PCI device and read the
- * hardware version register.
- * For now assume it's okay. */
- }
- /* Change board_ptr to matched board */
- dev->board_ptr = &pci230_boards[i];
- break;
- }
- }
- if (i < n_pci230_boards)
- break;
- } else {
- /* The name was specified as a specific device name.
- * The current dev->board_ptr is correct. Check
- * whether it matches the PCI device ID. */
- if (thisboard->id == pci_dev->device) {
- /* Check minimum hardware version. */
- if (thisboard->min_hwver > 0) {
- /* Looking for a '+' model. First
- * check length of registers. */
- if (pci_resource_len(pci_dev, 3) < 32) {
- /* Not a '+' model. */
- continue;
- }
- /* TODO: temporarily enable the PCI
- * device and read the hardware version
- * register. For now, assume it's
- * okay. */
- break;
- } else {
- break;
- }
- }
- }
- }
- if (!pci_dev) {
- printk("comedi%d: No %s card found\n", dev->minor,
- thisboard->name);
- return -EIO;
- }
- devpriv->pci_dev = pci_dev;
-
- /*
- * Initialize dev->board_name.
- */
- dev->board_name = thisboard->name;
-
- /* Enable PCI device and reserve I/O spaces. */
- if (comedi_pci_enable(pci_dev, "amplc_pci230") < 0) {
- printk("comedi%d: failed to enable PCI device "
- "and request regions\n", dev->minor);
- return -EIO;
- }
-
- /* Read base addresses of the PCI230's two I/O regions from PCI
- * configuration register. */
- iobase1 = pci_resource_start(pci_dev, 2);
- iobase2 = pci_resource_start(pci_dev, 3);
-
- printk("comedi%d: %s I/O region 1 0x%04lx I/O region 2 0x%04lx\n",
- dev->minor, dev->board_name, iobase1, iobase2);
-
- devpriv->iobase1 = iobase1;
- dev->iobase = iobase2;
-
- /* Read bits of DACCON register - only the output range. */
- devpriv->daccon = inw(dev->iobase + PCI230_DACCON) & PCI230_DAC_OR_MASK;
-
- /* Read hardware version register and set extended function register
- * if they exist. */
- if (pci_resource_len(pci_dev, 3) >= 32) {
- unsigned short extfunc = 0;
-
- devpriv->hwver = inw(dev->iobase + PCI230P_HWVER);
- if (devpriv->hwver < thisboard->min_hwver) {
- printk("comedi%d: %s - bad hardware version "
- "- got %u, need %u\n", dev->minor,
- dev->board_name, devpriv->hwver,
- thisboard->min_hwver);
- return -EIO;
- }
- if (devpriv->hwver > 0) {
- if (!thisboard->have_dio) {
- /* No DIO ports. Route counters' external gates
- * to the EXTTRIG signal (PCI260+ pin 17).
- * (Otherwise, they would be routed to DIO
- * inputs PC0, PC1 and PC2 which don't exist
- * on PCI260[+].) */
- extfunc |= PCI230P_EXTFUNC_GAT_EXTTRIG;
- }
- if ((thisboard->ao_chans > 0)
- && (devpriv->hwver >= 2)) {
- /* Enable DAC FIFO functionality. */
- extfunc |= PCI230P2_EXTFUNC_DACFIFO;
- }
- }
- outw(extfunc, dev->iobase + PCI230P_EXTFUNC);
- if ((extfunc & PCI230P2_EXTFUNC_DACFIFO) != 0) {
- /* Temporarily enable DAC FIFO, reset it and disable
- * FIFO wraparound. */
- outw(devpriv->daccon | PCI230P2_DAC_FIFO_EN
- | PCI230P2_DAC_FIFO_RESET,
- dev->iobase + PCI230_DACCON);
- /* Clear DAC FIFO channel enable register. */
- outw(0, dev->iobase + PCI230P2_DACEN);
- /* Disable DAC FIFO. */
- outw(devpriv->daccon, dev->iobase + PCI230_DACCON);
- }
- }
-
- /* Disable board's interrupts. */
- outb(0, devpriv->iobase1 + PCI230_INT_SCE);
-
- /* Set ADC to a reasonable state. */
- devpriv->adcg = 0;
- devpriv->adccon = PCI230_ADC_TRIG_NONE | PCI230_ADC_IM_SE
- | PCI230_ADC_IR_BIP;
- outw(1 << 0, dev->iobase + PCI230_ADCEN);
- outw(devpriv->adcg, dev->iobase + PCI230_ADCG);
- outw(devpriv->adccon | PCI230_ADC_FIFO_RESET,
- dev->iobase + PCI230_ADCCON);
-
- /* Register the interrupt handler. */
- irq_hdl = request_irq(devpriv->pci_dev->irq, pci230_interrupt,
- IRQF_SHARED, "amplc_pci230", dev);
- if (irq_hdl < 0) {
- printk("comedi%d: unable to register irq, "
- "commands will not be available %d\n", dev->minor,
- devpriv->pci_dev->irq);
- } else {
- dev->irq = devpriv->pci_dev->irq;
- printk("comedi%d: registered irq %u\n", dev->minor,
- devpriv->pci_dev->irq);
- }
-
- /*
- * Allocate the subdevice structures. alloc_subdevice() is a
- * convenient macro defined in comedidev.h.
- */
- if (alloc_subdevices(dev, 3) < 0)
- return -ENOMEM;
-
- s = dev->subdevices + 0;
- /* analog input subdevice */
- s->type = COMEDI_SUBD_AI;
- s->subdev_flags = SDF_READABLE | SDF_DIFF | SDF_GROUND;
- s->n_chan = thisboard->ai_chans;
- s->maxdata = (1 << thisboard->ai_bits) - 1;
- s->range_table = &pci230_ai_range;
- s->insn_read = &pci230_ai_rinsn;
- s->len_chanlist = 256; /* but there are restrictions. */
- /* Only register commands if the interrupt handler is installed. */
- if (irq_hdl == 0) {
- dev->read_subdev = s;
- s->subdev_flags |= SDF_CMD_READ;
- s->do_cmd = &pci230_ai_cmd;
- s->do_cmdtest = &pci230_ai_cmdtest;
- s->cancel = pci230_ai_cancel;
- }
-
- s = dev->subdevices + 1;
- /* analog output subdevice */
- if (thisboard->ao_chans > 0) {
- s->type = COMEDI_SUBD_AO;
- s->subdev_flags = SDF_WRITABLE | SDF_GROUND;
- s->n_chan = thisboard->ao_chans;
- s->maxdata = (1 << thisboard->ao_bits) - 1;
- s->range_table = &pci230_ao_range;
- s->insn_write = &pci230_ao_winsn;
- s->insn_read = &pci230_ao_rinsn;
- s->len_chanlist = thisboard->ao_chans;
- /* Only register commands if the interrupt handler is
- * installed. */
- if (irq_hdl == 0) {
- dev->write_subdev = s;
- s->subdev_flags |= SDF_CMD_WRITE;
- s->do_cmd = &pci230_ao_cmd;
- s->do_cmdtest = &pci230_ao_cmdtest;
- s->cancel = pci230_ao_cancel;
- }
- } else {
- s->type = COMEDI_SUBD_UNUSED;
- }
-
- s = dev->subdevices + 2;
- /* digital i/o subdevice */
- if (thisboard->have_dio) {
- rc = subdev_8255_init(dev, s, NULL,
- (devpriv->iobase1 + PCI230_PPI_X_BASE));
- if (rc < 0)
- return rc;
- } else {
- s->type = COMEDI_SUBD_UNUSED;
- }
-
- printk("comedi%d: attached\n", dev->minor);
-
- return 1;
-}
-
-/*
- * _detach is called to deconfigure a device. It should deallocate
- * resources.
- * This function is also called when _attach() fails, so it should be
- * careful not to release resources that were not necessarily
- * allocated by _attach(). dev->private and dev->subdevices are
- * deallocated automatically by the core.
- */
-static int pci230_detach(struct comedi_device *dev)
-{
- printk("comedi%d: amplc_pci230: remove\n", dev->minor);
-
- if (dev->subdevices && thisboard->have_dio)
- /* Clean up dio subdevice. */
- subdev_8255_cleanup(dev, dev->subdevices + 2);
-
- if (dev->irq)
- free_irq(dev->irq, dev);
-
- if (devpriv) {
- if (devpriv->pci_dev) {
- if (dev->iobase)
- comedi_pci_disable(devpriv->pci_dev);
-
- pci_dev_put(devpriv->pci_dev);
- }
- }
-
- return 0;
-}
-
static int get_resources(struct comedi_device *dev, unsigned int res_mask,
unsigned char owner)
{
+ struct pci230_private *devpriv = dev->private;
int ok;
unsigned int i;
unsigned int b;
@@ -1079,6 +688,7 @@ static inline int get_one_resource(struct comedi_device *dev,
static void put_resources(struct comedi_device *dev, unsigned int res_mask,
unsigned char owner)
{
+ struct pci230_private *devpriv = dev->private;
unsigned int i;
unsigned int b;
unsigned long irqflags;
@@ -1108,6 +718,86 @@ static inline void put_all_resources(struct comedi_device *dev,
put_resources(dev, (1U << NUM_RESOURCES) - 1, owner);
}
+static unsigned int divide_ns(uint64_t ns, unsigned int timebase,
+ unsigned int round_mode)
+{
+ uint64_t div;
+ unsigned int rem;
+
+ div = ns;
+ rem = do_div(div, timebase);
+ round_mode &= TRIG_ROUND_MASK;
+ switch (round_mode) {
+ default:
+ case TRIG_ROUND_NEAREST:
+ div += (rem + (timebase / 2)) / timebase;
+ break;
+ case TRIG_ROUND_DOWN:
+ break;
+ case TRIG_ROUND_UP:
+ div += (rem + timebase - 1) / timebase;
+ break;
+ }
+ return div > UINT_MAX ? UINT_MAX : (unsigned int)div;
+}
+
+/* Given desired period in ns, returns the required internal clock source
+ * and gets the initial count. */
+static unsigned int pci230_choose_clk_count(uint64_t ns, unsigned int *count,
+ unsigned int round_mode)
+{
+ unsigned int clk_src, cnt;
+
+ for (clk_src = CLK_10MHZ;; clk_src++) {
+ cnt = divide_ns(ns, pci230_timebase[clk_src], round_mode);
+ if ((cnt <= 65536) || (clk_src == CLK_1KHZ))
+ break;
+
+ }
+ *count = cnt;
+ return clk_src;
+}
+
+static void pci230_ns_to_single_timer(unsigned int *ns, unsigned int round)
+{
+ unsigned int count;
+ unsigned int clk_src;
+
+ clk_src = pci230_choose_clk_count(*ns, &count, round);
+ *ns = count * pci230_timebase[clk_src];
+ return;
+}
+
+static void pci230_ct_setup_ns_mode(struct comedi_device *dev, unsigned int ct,
+ unsigned int mode, uint64_t ns,
+ unsigned int round)
+{
+ struct pci230_private *devpriv = dev->private;
+ unsigned int clk_src;
+ unsigned int count;
+
+ /* Set mode. */
+ i8254_set_mode(devpriv->iobase1 + PCI230_Z2_CT_BASE, 0, ct, mode);
+ /* Determine clock source and count. */
+ clk_src = pci230_choose_clk_count(ns, &count, round);
+ /* Program clock source. */
+ outb(CLK_CONFIG(ct, clk_src), devpriv->iobase1 + PCI230_ZCLK_SCE);
+ /* Set initial count. */
+ if (count >= 65536)
+ count = 0;
+
+ i8254_write(devpriv->iobase1 + PCI230_Z2_CT_BASE, 0, ct, count);
+}
+
+static void pci230_cancel_ct(struct comedi_device *dev, unsigned int ct)
+{
+ struct pci230_private *devpriv = dev->private;
+
+ i8254_set_mode(devpriv->iobase1 + PCI230_Z2_CT_BASE, 0, ct,
+ I8254_MODE1);
+ /* Counter ct, 8254 mode 1, initial count not written. */
+}
+
/*
* COMEDI_SUBD_AI instruction;
*/
@@ -1115,6 +805,7 @@ static int pci230_ai_rinsn(struct comedi_device *dev,
struct comedi_subdevice *s, struct comedi_insn *insn,
unsigned int *data)
{
+ struct pci230_private *devpriv = dev->private;
unsigned int n, i;
unsigned int chan, range, aref;
unsigned int gainshift;
@@ -1200,9 +891,7 @@ static int pci230_ai_rinsn(struct comedi_device *dev,
udelay(1);
}
if (i == TIMEOUT) {
- /* printk() should be used instead of printk()
- * whenever the code can be called from real-time. */
- printk("timeout\n");
+ dev_err(dev->class_dev, "timeout\n");
return -ETIMEDOUT;
}
@@ -1221,6 +910,7 @@ static int pci230_ao_winsn(struct comedi_device *dev,
struct comedi_subdevice *s, struct comedi_insn *insn,
unsigned int *data)
{
+ struct pci230_private *devpriv = dev->private;
int i;
int chan, range;
@@ -1250,6 +940,7 @@ static int pci230_ao_rinsn(struct comedi_device *dev,
struct comedi_subdevice *s, struct comedi_insn *insn,
unsigned int *data)
{
+ struct pci230_private *devpriv = dev->private;
int i;
int chan = CR_CHAN(insn->chanspec);
@@ -1262,6 +953,8 @@ static int pci230_ao_rinsn(struct comedi_device *dev,
static int pci230_ao_cmdtest(struct comedi_device *dev,
struct comedi_subdevice *s, struct comedi_cmd *cmd)
{
+ const struct pci230_board *thisboard = comedi_board(dev);
+ struct pci230_private *devpriv = dev->private;
int err = 0;
unsigned int tmp;
@@ -1471,10 +1164,201 @@ static int pci230_ao_cmdtest(struct comedi_device *dev,
return 0;
}
+static void pci230_ao_stop(struct comedi_device *dev,
+ struct comedi_subdevice *s)
+{
+ struct pci230_private *devpriv = dev->private;
+ unsigned long irqflags;
+ unsigned char intsrc;
+ int started;
+ struct comedi_cmd *cmd;
+
+ spin_lock_irqsave(&devpriv->ao_stop_spinlock, irqflags);
+ started = test_and_clear_bit(AO_CMD_STARTED, &devpriv->state);
+ spin_unlock_irqrestore(&devpriv->ao_stop_spinlock, irqflags);
+ if (!started)
+ return;
+ cmd = &s->async->cmd;
+ if (cmd->scan_begin_src == TRIG_TIMER) {
+ /* Stop scan rate generator. */
+ pci230_cancel_ct(dev, 1);
+ }
+ /* Determine interrupt source. */
+ if (devpriv->hwver < 2) {
+ /* Not using DAC FIFO. Using CT1 interrupt. */
+ intsrc = PCI230_INT_ZCLK_CT1;
+ } else {
+ /* Using DAC FIFO interrupt. */
+ intsrc = PCI230P2_INT_DAC;
+ }
+ /* Disable interrupt and wait for interrupt routine to finish running
+ * unless we are called from the interrupt routine. */
+ spin_lock_irqsave(&devpriv->isr_spinlock, irqflags);
+ devpriv->int_en &= ~intsrc;
+ while (devpriv->intr_running && devpriv->intr_cpuid != THISCPU) {
+ spin_unlock_irqrestore(&devpriv->isr_spinlock, irqflags);
+ spin_lock_irqsave(&devpriv->isr_spinlock, irqflags);
+ }
+ if (devpriv->ier != devpriv->int_en) {
+ devpriv->ier = devpriv->int_en;
+ outb(devpriv->ier, devpriv->iobase1 + PCI230_INT_SCE);
+ }
+ spin_unlock_irqrestore(&devpriv->isr_spinlock, irqflags);
+ if (devpriv->hwver >= 2) {
+ /* Using DAC FIFO. Reset FIFO, clear underrun error,
+ * disable FIFO. */
+ devpriv->daccon &= PCI230_DAC_OR_MASK;
+ outw(devpriv->daccon | PCI230P2_DAC_FIFO_RESET
+ | PCI230P2_DAC_FIFO_UNDERRUN_CLEAR,
+ dev->iobase + PCI230_DACCON);
+ }
+ /* Release resources. */
+ put_all_resources(dev, OWNER_AOCMD);
+}
+
+static void pci230_handle_ao_nofifo(struct comedi_device *dev,
+ struct comedi_subdevice *s)
+{
+ struct pci230_private *devpriv = dev->private;
+ short data;
+ int i, ret;
+ struct comedi_async *async = s->async;
+ struct comedi_cmd *cmd = &async->cmd;
+
+ if (!devpriv->ao_continuous && (devpriv->ao_scan_count == 0))
+ return;
+ for (i = 0; i < cmd->chanlist_len; i++) {
+ /* Read sample from Comedi's circular buffer. */
+ ret = comedi_buf_get(s->async, &data);
+ if (ret == 0) {
+ s->async->events |= COMEDI_CB_OVERFLOW;
+ pci230_ao_stop(dev, s);
+ comedi_error(dev, "AO buffer underrun");
+ return;
+ }
+ /* Write value to DAC. */
+ pci230_ao_write_nofifo(dev, data, CR_CHAN(cmd->chanlist[i]));
+ }
+ async->events |= COMEDI_CB_BLOCK | COMEDI_CB_EOS;
+ if (!devpriv->ao_continuous) {
+ devpriv->ao_scan_count--;
+ if (devpriv->ao_scan_count == 0) {
+ /* End of acquisition. */
+ async->events |= COMEDI_CB_EOA;
+ pci230_ao_stop(dev, s);
+ }
+ }
+}
+
+/* Loads DAC FIFO (if using it) from buffer. */
+/* Returns 0 if AO finished due to completion or error, 1 if still going. */
+static int pci230_handle_ao_fifo(struct comedi_device *dev,
+ struct comedi_subdevice *s)
+{
+ struct pci230_private *devpriv = dev->private;
+ struct comedi_async *async = s->async;
+ struct comedi_cmd *cmd = &async->cmd;
+ unsigned int num_scans;
+ unsigned int room;
+ unsigned short dacstat;
+ unsigned int i, n;
+ unsigned int bytes_per_scan;
+ unsigned int events = 0;
+ int running;
+
+ /* Get DAC FIFO status. */
+ dacstat = inw(dev->iobase + PCI230_DACCON);
+ /* Determine number of scans available in buffer. */
+ bytes_per_scan = cmd->chanlist_len * sizeof(short);
+ num_scans = comedi_buf_read_n_available(async) / bytes_per_scan;
+ if (!devpriv->ao_continuous) {
+ /* Fixed number of scans. */
+ if (num_scans > devpriv->ao_scan_count)
+ num_scans = devpriv->ao_scan_count;
+ if (devpriv->ao_scan_count == 0) {
+ /* End of acquisition. */
+ events |= COMEDI_CB_EOA;
+ }
+ }
+ if (events == 0) {
+ /* Check for FIFO underrun. */
+ if ((dacstat & PCI230P2_DAC_FIFO_UNDERRUN_LATCHED) != 0) {
+ comedi_error(dev, "AO FIFO underrun");
+ events |= COMEDI_CB_OVERFLOW | COMEDI_CB_ERROR;
+ }
+ /* Check for buffer underrun if FIFO less than half full
+ * (otherwise there will be loads of "DAC FIFO not half full"
+ * interrupts). */
+ if ((num_scans == 0)
+ && ((dacstat & PCI230P2_DAC_FIFO_HALF) == 0)) {
+ comedi_error(dev, "AO buffer underrun");
+ events |= COMEDI_CB_OVERFLOW | COMEDI_CB_ERROR;
+ }
+ }
+ if (events == 0) {
+ /* Determine how much room is in the FIFO (in samples). */
+ if ((dacstat & PCI230P2_DAC_FIFO_FULL) != 0)
+ room = PCI230P2_DAC_FIFOROOM_FULL;
+ else if ((dacstat & PCI230P2_DAC_FIFO_HALF) != 0)
+ room = PCI230P2_DAC_FIFOROOM_HALFTOFULL;
+ else if ((dacstat & PCI230P2_DAC_FIFO_EMPTY) != 0)
+ room = PCI230P2_DAC_FIFOROOM_EMPTY;
+ else
+ room = PCI230P2_DAC_FIFOROOM_ONETOHALF;
+ /* Convert room to number of scans that can be added. */
+ room /= cmd->chanlist_len;
+ /* Determine number of scans to process. */
+ if (num_scans > room)
+ num_scans = room;
+ /* Process scans. */
+ for (n = 0; n < num_scans; n++) {
+ for (i = 0; i < cmd->chanlist_len; i++) {
+ short datum;
+
+ comedi_buf_get(async, &datum);
+ pci230_ao_write_fifo(dev, datum,
+ CR_CHAN(cmd->chanlist[i]));
+ }
+ }
+ events |= COMEDI_CB_EOS | COMEDI_CB_BLOCK;
+ if (!devpriv->ao_continuous) {
+ devpriv->ao_scan_count -= num_scans;
+ if (devpriv->ao_scan_count == 0) {
+ /* All data for the command has been written
+ * to FIFO. Set FIFO interrupt trigger level
+ * to 'empty'. */
+ devpriv->daccon = (devpriv->daccon
+ &
+ ~PCI230P2_DAC_INT_FIFO_MASK)
+ | PCI230P2_DAC_INT_FIFO_EMPTY;
+ outw(devpriv->daccon,
+ dev->iobase + PCI230_DACCON);
+ }
+ }
+ /* Check if FIFO underrun occurred while writing to FIFO. */
+ dacstat = inw(dev->iobase + PCI230_DACCON);
+ if ((dacstat & PCI230P2_DAC_FIFO_UNDERRUN_LATCHED) != 0) {
+ comedi_error(dev, "AO FIFO underrun");
+ events |= COMEDI_CB_OVERFLOW | COMEDI_CB_ERROR;
+ }
+ }
+ if ((events & (COMEDI_CB_EOA | COMEDI_CB_ERROR | COMEDI_CB_OVERFLOW))
+ != 0) {
+ /* Stopping AO due to completion or error. */
+ pci230_ao_stop(dev, s);
+ running = 0;
+ } else {
+ running = 1;
+ }
+ async->events |= events;
+ return running;
+}
+
static int pci230_ao_inttrig_scan_begin(struct comedi_device *dev,
struct comedi_subdevice *s,
unsigned int trig_num)
{
+ struct pci230_private *devpriv = dev->private;
unsigned long irqflags;
if (trig_num != 0)
@@ -1499,6 +1383,8 @@ static int pci230_ao_inttrig_scan_begin(struct comedi_device *dev,
/* Delay. Should driver be responsible for this? */
/* XXX TODO: See if DAC busy bit can be used. */
udelay(8);
+ } else {
+ spin_unlock_irqrestore(&devpriv->ao_stop_spinlock, irqflags);
}
return 1;
@@ -1507,6 +1393,7 @@ static int pci230_ao_inttrig_scan_begin(struct comedi_device *dev,
static void pci230_ao_start(struct comedi_device *dev,
struct comedi_subdevice *s)
{
+ struct pci230_private *devpriv = dev->private;
struct comedi_async *async = s->async;
struct comedi_cmd *cmd = &async->cmd;
unsigned long irqflags;
@@ -1600,7 +1487,7 @@ static int pci230_ao_inttrig_start(struct comedi_device *dev,
if (trig_num != 0)
return -EINVAL;
- s->async->inttrig = NULLFUNC;
+ s->async->inttrig = NULL;
pci230_ao_start(dev, s);
return 1;
@@ -1608,6 +1495,7 @@ static int pci230_ao_inttrig_start(struct comedi_device *dev,
static int pci230_ao_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
{
+ struct pci230_private *devpriv = dev->private;
unsigned short daccon;
unsigned int range;
@@ -1683,6 +1571,13 @@ static int pci230_ao_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
return 0;
}
+static int pci230_ao_cancel(struct comedi_device *dev,
+ struct comedi_subdevice *s)
+{
+ pci230_ao_stop(dev, s);
+ return 0;
+}
+
static int pci230_ai_check_scan_period(struct comedi_cmd *cmd)
{
unsigned int min_scan_period, chanlist_len;
@@ -1710,6 +1605,8 @@ static int pci230_ai_check_scan_period(struct comedi_cmd *cmd)
static int pci230_ai_cmdtest(struct comedi_device *dev,
struct comedi_subdevice *s, struct comedi_cmd *cmd)
{
+ const struct pci230_board *thisboard = comedi_board(dev);
+ struct pci230_private *devpriv = dev->private;
int err = 0;
unsigned int tmp;
@@ -2075,13 +1972,9 @@ static int pci230_ai_cmdtest(struct comedi_device *dev,
(s->n_chan / 2) - 1);
}
if ((errors & buggy_chan0_err) != 0) {
- /* Use printk instead of DPRINTK here. */
- printk("comedi: comedi%d: amplc_pci230: "
- "ai_cmdtest: Buggy PCI230+/260+ "
- "h/w version %u requires first channel "
- "of multi-channel sequence to be 0 "
- "(corrected in h/w version 4)\n",
- dev->minor, devpriv->hwver);
+ dev_info(dev->class_dev,
+ "amplc_pci230: ai_cmdtest: Buggy PCI230+/260+ h/w version %u requires first channel of multi-channel sequence to be 0 (corrected in h/w version 4)\n",
+ devpriv->hwver);
}
}
}
@@ -2095,6 +1988,7 @@ static int pci230_ai_cmdtest(struct comedi_device *dev,
static void pci230_ai_update_fifo_trigger_level(struct comedi_device *dev,
struct comedi_subdevice *s)
{
+ struct pci230_private *devpriv = dev->private;
struct comedi_cmd *cmd = &s->async->cmd;
unsigned int scanlen = cmd->scan_end_arg;
unsigned int wake;
@@ -2139,6 +2033,7 @@ static int pci230_ai_inttrig_convert(struct comedi_device *dev,
struct comedi_subdevice *s,
unsigned int trig_num)
{
+ struct pci230_private *devpriv = dev->private;
unsigned long irqflags;
if (trig_num != 0)
@@ -2181,6 +2076,7 @@ static int pci230_ai_inttrig_scan_begin(struct comedi_device *dev,
struct comedi_subdevice *s,
unsigned int trig_num)
{
+ struct pci230_private *devpriv = dev->private;
unsigned long irqflags;
unsigned char zgat;
@@ -2200,9 +2096,56 @@ static int pci230_ai_inttrig_scan_begin(struct comedi_device *dev,
return 1;
}
+static void pci230_ai_stop(struct comedi_device *dev,
+ struct comedi_subdevice *s)
+{
+ struct pci230_private *devpriv = dev->private;
+ unsigned long irqflags;
+ struct comedi_cmd *cmd;
+ int started;
+
+ spin_lock_irqsave(&devpriv->ai_stop_spinlock, irqflags);
+ started = test_and_clear_bit(AI_CMD_STARTED, &devpriv->state);
+ spin_unlock_irqrestore(&devpriv->ai_stop_spinlock, irqflags);
+ if (!started)
+ return;
+ cmd = &s->async->cmd;
+ if (cmd->convert_src == TRIG_TIMER) {
+ /* Stop conversion rate generator. */
+ pci230_cancel_ct(dev, 2);
+ }
+ if (cmd->scan_begin_src != TRIG_FOLLOW) {
+ /* Stop scan period monostable. */
+ pci230_cancel_ct(dev, 0);
+ }
+ spin_lock_irqsave(&devpriv->isr_spinlock, irqflags);
+ /* Disable ADC interrupt and wait for interrupt routine to finish
+ * running unless we are called from the interrupt routine. */
+ devpriv->int_en &= ~PCI230_INT_ADC;
+ while (devpriv->intr_running && devpriv->intr_cpuid != THISCPU) {
+ spin_unlock_irqrestore(&devpriv->isr_spinlock, irqflags);
+ spin_lock_irqsave(&devpriv->isr_spinlock, irqflags);
+ }
+ if (devpriv->ier != devpriv->int_en) {
+ devpriv->ier = devpriv->int_en;
+ outb(devpriv->ier, devpriv->iobase1 + PCI230_INT_SCE);
+ }
+ spin_unlock_irqrestore(&devpriv->isr_spinlock, irqflags);
+ /* Reset FIFO, disable FIFO and set start conversion source to none.
+ * Keep se/diff and bip/uni settings */
+ devpriv->adccon = (devpriv->adccon & (PCI230_ADC_IR_MASK
+ | PCI230_ADC_IM_MASK)) |
+ PCI230_ADC_TRIG_NONE;
+ outw(devpriv->adccon | PCI230_ADC_FIFO_RESET,
+ dev->iobase + PCI230_ADCCON);
+ /* Release resources. */
+ put_all_resources(dev, OWNER_AICMD);
+}
+
static void pci230_ai_start(struct comedi_device *dev,
struct comedi_subdevice *s)
{
+ struct pci230_private *devpriv = dev->private;
unsigned long irqflags;
unsigned short conv;
struct comedi_async *async = s->async;
@@ -2345,14 +2288,108 @@ static int pci230_ai_inttrig_start(struct comedi_device *dev,
if (trig_num != 0)
return -EINVAL;
- s->async->inttrig = NULLFUNC;
+ s->async->inttrig = NULL;
pci230_ai_start(dev, s);
return 1;
}
+static void pci230_handle_ai(struct comedi_device *dev,
+ struct comedi_subdevice *s)
+{
+ struct pci230_private *devpriv = dev->private;
+ unsigned int events = 0;
+ unsigned int status_fifo;
+ unsigned int i;
+ unsigned int todo;
+ unsigned int fifoamount;
+ struct comedi_async *async = s->async;
+ unsigned int scanlen = async->cmd.scan_end_arg;
+
+ /* Determine number of samples to read. */
+ if (devpriv->ai_continuous) {
+ todo = PCI230_ADC_FIFOLEVEL_HALFFULL;
+ } else if (devpriv->ai_scan_count == 0) {
+ todo = 0;
+ } else if ((devpriv->ai_scan_count > PCI230_ADC_FIFOLEVEL_HALFFULL)
+ || (scanlen > PCI230_ADC_FIFOLEVEL_HALFFULL)) {
+ todo = PCI230_ADC_FIFOLEVEL_HALFFULL;
+ } else {
+ todo = (devpriv->ai_scan_count * scanlen)
+ - devpriv->ai_scan_pos;
+ if (todo > PCI230_ADC_FIFOLEVEL_HALFFULL)
+ todo = PCI230_ADC_FIFOLEVEL_HALFFULL;
+ }
+ if (todo == 0)
+ return;
+ fifoamount = 0;
+ for (i = 0; i < todo; i++) {
+ if (fifoamount == 0) {
+ /* Read FIFO state. */
+ status_fifo = inw(dev->iobase + PCI230_ADCCON);
+ if ((status_fifo & PCI230_ADC_FIFO_FULL_LATCHED) != 0) {
+ /* Report error otherwise FIFO overruns will go
+ * unnoticed by the caller. */
+ comedi_error(dev, "AI FIFO overrun");
+ events |= COMEDI_CB_OVERFLOW | COMEDI_CB_ERROR;
+ break;
+ } else if ((status_fifo & PCI230_ADC_FIFO_EMPTY) != 0) {
+ /* FIFO empty. */
+ break;
+ } else if ((status_fifo & PCI230_ADC_FIFO_HALF) != 0) {
+ /* FIFO half full. */
+ fifoamount = PCI230_ADC_FIFOLEVEL_HALFFULL;
+ } else {
+ /* FIFO not empty. */
+ if (devpriv->hwver > 0) {
+ /* Read PCI230+/260+ ADC FIFO level. */
+ fifoamount = inw(dev->iobase
+ + PCI230P_ADCFFLEV);
+ if (fifoamount == 0) {
+ /* Shouldn't happen. */
+ break;
+ }
+ } else {
+ fifoamount = 1;
+ }
+ }
+ }
+ /* Read sample and store in Comedi's circular buffer. */
+ if (comedi_buf_put(async, pci230_ai_read(dev)) == 0) {
+ events |= COMEDI_CB_ERROR | COMEDI_CB_OVERFLOW;
+ comedi_error(dev, "AI buffer overflow");
+ break;
+ }
+ fifoamount--;
+ devpriv->ai_scan_pos++;
+ if (devpriv->ai_scan_pos == scanlen) {
+ /* End of scan. */
+ devpriv->ai_scan_pos = 0;
+ devpriv->ai_scan_count--;
+ async->events |= COMEDI_CB_EOS;
+ }
+ }
+ if (!devpriv->ai_continuous && (devpriv->ai_scan_count == 0)) {
+ /* End of acquisition. */
+ events |= COMEDI_CB_EOA;
+ } else {
+ /* More samples required, tell Comedi to block. */
+ events |= COMEDI_CB_BLOCK;
+ }
+ async->events |= events;
+ if ((async->events & (COMEDI_CB_EOA | COMEDI_CB_ERROR |
+ COMEDI_CB_OVERFLOW)) != 0) {
+ /* disable hardware conversions */
+ pci230_ai_stop(dev, s);
+ } else {
+ /* update FIFO interrupt trigger level */
+ pci230_ai_update_fifo_trigger_level(dev, s);
+ }
+}
+
static int pci230_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
{
+ struct pci230_private *devpriv = dev->private;
unsigned int i, chan, range, diff;
unsigned int res_mask;
unsigned short adccon, adcen;
@@ -2544,81 +2581,11 @@ static int pci230_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
return 0;
}
-static unsigned int divide_ns(uint64_t ns, unsigned int timebase,
- unsigned int round_mode)
-{
- uint64_t div;
- unsigned int rem;
-
- div = ns;
- rem = do_div(div, timebase);
- round_mode &= TRIG_ROUND_MASK;
- switch (round_mode) {
- default:
- case TRIG_ROUND_NEAREST:
- div += (rem + (timebase / 2)) / timebase;
- break;
- case TRIG_ROUND_DOWN:
- break;
- case TRIG_ROUND_UP:
- div += (rem + timebase - 1) / timebase;
- break;
- }
- return div > UINT_MAX ? UINT_MAX : (unsigned int)div;
-}
-
-/* Given desired period in ns, returns the required internal clock source
- * and gets the initial count. */
-static unsigned int pci230_choose_clk_count(uint64_t ns, unsigned int *count,
- unsigned int round_mode)
-{
- unsigned int clk_src, cnt;
-
- for (clk_src = CLK_10MHZ;; clk_src++) {
- cnt = divide_ns(ns, pci230_timebase[clk_src], round_mode);
- if ((cnt <= 65536) || (clk_src == CLK_1KHZ))
- break;
-
- }
- *count = cnt;
- return clk_src;
-}
-
-static void pci230_ns_to_single_timer(unsigned int *ns, unsigned int round)
-{
- unsigned int count;
- unsigned int clk_src;
-
- clk_src = pci230_choose_clk_count(*ns, &count, round);
- *ns = count * pci230_timebase[clk_src];
- return;
-}
-
-static void pci230_ct_setup_ns_mode(struct comedi_device *dev, unsigned int ct,
- unsigned int mode, uint64_t ns,
- unsigned int round)
-{
- unsigned int clk_src;
- unsigned int count;
-
- /* Set mode. */
- i8254_set_mode(devpriv->iobase1 + PCI230_Z2_CT_BASE, 0, ct, mode);
- /* Determine clock source and count. */
- clk_src = pci230_choose_clk_count(ns, &count, round);
- /* Program clock source. */
- outb(CLK_CONFIG(ct, clk_src), devpriv->iobase1 + PCI230_ZCLK_SCE);
- /* Set initial count. */
- if (count >= 65536)
- count = 0;
-
- i8254_write(devpriv->iobase1 + PCI230_Z2_CT_BASE, 0, ct, count);
-}
-
-static void pci230_cancel_ct(struct comedi_device *dev, unsigned int ct)
+static int pci230_ai_cancel(struct comedi_device *dev,
+ struct comedi_subdevice *s)
{
- i8254_set_mode(devpriv->iobase1 + PCI230_Z2_CT_BASE, 0, ct,
- I8254_MODE1);
- /* Counter ct, 8254 mode 1, initial count not written. */
+ pci230_ai_stop(dev, s);
+ return 0;
}
/* Interrupt handler */
@@ -2626,6 +2593,7 @@ static irqreturn_t pci230_interrupt(int irq, void *d)
{
unsigned char status_int, valid_status_int;
struct comedi_device *dev = (struct comedi_device *)d;
+ struct pci230_private *devpriv = dev->private;
struct comedi_subdevice *s;
unsigned long irqflags;
@@ -2685,369 +2653,334 @@ static irqreturn_t pci230_interrupt(int irq, void *d)
return IRQ_HANDLED;
}
-static void pci230_handle_ao_nofifo(struct comedi_device *dev,
- struct comedi_subdevice *s)
+/* Check if PCI device matches a specific board. */
+static bool pci230_match_pci_board(const struct pci230_board *board,
+ struct pci_dev *pci_dev)
{
- short data;
- int i, ret;
- struct comedi_async *async = s->async;
- struct comedi_cmd *cmd = &async->cmd;
-
- if (!devpriv->ao_continuous && (devpriv->ao_scan_count == 0))
- return;
-
+ /* assume pci_dev->device != PCI_DEVICE_ID_INVALID */
+ if (board->id != pci_dev->device)
+ return false;
+ if (board->min_hwver == 0)
+ return true;
+ /* Looking for a '+' model. First check length of registers. */
+ if (pci_resource_len(pci_dev, 3) < 32)
+ return false; /* Not a '+' model. */
+ /* TODO: temporarily enable PCI device and read the hardware version
+ * register. For now, assume it's okay. */
+ return true;
+}
- for (i = 0; i < cmd->chanlist_len; i++) {
- /* Read sample from Comedi's circular buffer. */
- ret = comedi_buf_get(s->async, &data);
- if (ret == 0) {
- s->async->events |= COMEDI_CB_OVERFLOW;
- pci230_ao_stop(dev, s);
- comedi_error(dev, "AO buffer underrun");
- return;
- }
- /* Write value to DAC. */
- pci230_ao_write_nofifo(dev, data, CR_CHAN(cmd->chanlist[i]));
- }
+/* Look for board matching PCI device. */
+static const struct pci230_board *pci230_find_pci_board(struct pci_dev *pci_dev)
+{
+ unsigned int i;
- async->events |= COMEDI_CB_BLOCK | COMEDI_CB_EOS;
- if (!devpriv->ao_continuous) {
- devpriv->ao_scan_count--;
- if (devpriv->ao_scan_count == 0) {
- /* End of acquisition. */
- async->events |= COMEDI_CB_EOA;
- pci230_ao_stop(dev, s);
- }
- }
+ for (i = 0; i < ARRAY_SIZE(pci230_boards); i++)
+ if (pci230_match_pci_board(&pci230_boards[i], pci_dev))
+ return &pci230_boards[i];
+ return NULL;
}
-/* Loads DAC FIFO (if using it) from buffer. */
-/* Returns 0 if AO finished due to completion or error, 1 if still going. */
-static int pci230_handle_ao_fifo(struct comedi_device *dev,
- struct comedi_subdevice *s)
+/* Look for PCI device matching requested board name, bus and slot. */
+static struct pci_dev *pci230_find_pci_dev(struct comedi_device *dev,
+ struct comedi_devconfig *it)
{
- struct comedi_async *async = s->async;
- struct comedi_cmd *cmd = &async->cmd;
- unsigned int num_scans;
- unsigned int room;
- unsigned short dacstat;
- unsigned int i, n;
- unsigned int bytes_per_scan;
- unsigned int events = 0;
- int running;
-
- /* Get DAC FIFO status. */
- dacstat = inw(dev->iobase + PCI230_DACCON);
+ const struct pci230_board *thisboard = comedi_board(dev);
+ struct pci_dev *pci_dev = NULL;
+ int bus = it->options[0];
+ int slot = it->options[1];
- /* Determine number of scans available in buffer. */
- bytes_per_scan = cmd->chanlist_len * sizeof(short);
- num_scans = comedi_buf_read_n_available(async) / bytes_per_scan;
- if (!devpriv->ao_continuous) {
- /* Fixed number of scans. */
- if (num_scans > devpriv->ao_scan_count)
- num_scans = devpriv->ao_scan_count;
+ for_each_pci_dev(pci_dev) {
+ /* Check vendor ID (same for all supported PCI boards). */
+ if (pci_dev->vendor != PCI_VENDOR_ID_AMPLICON)
+ continue;
+ /* If bus/slot specified, check them. */
+ if ((bus || slot) &&
+ (bus != pci_dev->bus->number ||
+ slot != PCI_SLOT(pci_dev->devfn)))
+ continue;
+ if (thisboard->id == PCI_DEVICE_ID_INVALID) {
+ /* Wildcard board matches any supported PCI board. */
+ const struct pci230_board *foundboard;
- if (devpriv->ao_scan_count == 0) {
- /* End of acquisition. */
- events |= COMEDI_CB_EOA;
- }
- }
- if (events == 0) {
- /* Check for FIFO underrun. */
- if ((dacstat & PCI230P2_DAC_FIFO_UNDERRUN_LATCHED) != 0) {
- comedi_error(dev, "AO FIFO underrun");
- events |= COMEDI_CB_OVERFLOW | COMEDI_CB_ERROR;
- }
- /* Check for buffer underrun if FIFO less than half full
- * (otherwise there will be loads of "DAC FIFO not half full"
- * interrupts). */
- if ((num_scans == 0)
- && ((dacstat & PCI230P2_DAC_FIFO_HALF) == 0)) {
- comedi_error(dev, "AO buffer underrun");
- events |= COMEDI_CB_OVERFLOW | COMEDI_CB_ERROR;
+ foundboard = pci230_find_pci_board(pci_dev);
+ if (foundboard == NULL)
+ continue;
+ /* Replace wildcard board_ptr. */
+ dev->board_ptr = foundboard;
+ } else {
+ /* Need to match a specific board. */
+ if (!pci230_match_pci_board(thisboard, pci_dev))
+ continue;
}
+ return pci_dev;
}
- if (events == 0) {
- /* Determine how much room is in the FIFO (in samples). */
- if ((dacstat & PCI230P2_DAC_FIFO_FULL) != 0)
- room = PCI230P2_DAC_FIFOROOM_FULL;
- else if ((dacstat & PCI230P2_DAC_FIFO_HALF) != 0)
- room = PCI230P2_DAC_FIFOROOM_HALFTOFULL;
- else if ((dacstat & PCI230P2_DAC_FIFO_EMPTY) != 0)
- room = PCI230P2_DAC_FIFOROOM_EMPTY;
- else
- room = PCI230P2_DAC_FIFOROOM_ONETOHALF;
-
- /* Convert room to number of scans that can be added. */
- room /= cmd->chanlist_len;
- /* Determine number of scans to process. */
- if (num_scans > room)
- num_scans = room;
+ dev_err(dev->class_dev,
+ "No supported board found! (req. bus %d, slot %d)\n",
+ bus, slot);
+ return NULL;
+}
- /* Process scans. */
- for (n = 0; n < num_scans; n++) {
- for (i = 0; i < cmd->chanlist_len; i++) {
- short datum;
+static int pci230_alloc_private(struct comedi_device *dev)
+{
+ struct pci230_private *devpriv;
+ int err;
- comedi_buf_get(async, &datum);
- pci230_ao_write_fifo(dev, datum,
- CR_CHAN(cmd->chanlist[i]));
- }
- }
- events |= COMEDI_CB_EOS | COMEDI_CB_BLOCK;
- if (!devpriv->ao_continuous) {
- devpriv->ao_scan_count -= num_scans;
- if (devpriv->ao_scan_count == 0) {
- /* All data for the command has been written
- * to FIFO. Set FIFO interrupt trigger level
- * to 'empty'. */
- devpriv->daccon = (devpriv->daccon
- &
- ~PCI230P2_DAC_INT_FIFO_MASK)
- | PCI230P2_DAC_INT_FIFO_EMPTY;
- outw(devpriv->daccon,
- dev->iobase + PCI230_DACCON);
- }
- }
- /* Check if FIFO underrun occurred while writing to FIFO. */
- dacstat = inw(dev->iobase + PCI230_DACCON);
- if ((dacstat & PCI230P2_DAC_FIFO_UNDERRUN_LATCHED) != 0) {
- comedi_error(dev, "AO FIFO underrun");
- events |= COMEDI_CB_OVERFLOW | COMEDI_CB_ERROR;
- }
+ /* sets dev->private to allocated memory */
+ err = alloc_private(dev, sizeof(struct pci230_private));
+ if (err) {
+ dev_err(dev->class_dev, "error! out of memory!\n");
+ return err;
}
- if ((events & (COMEDI_CB_EOA | COMEDI_CB_ERROR | COMEDI_CB_OVERFLOW))
- != 0) {
- /* Stopping AO due to completion or error. */
- pci230_ao_stop(dev, s);
- running = 0;
- } else {
- running = 1;
- }
- async->events |= events;
- return running;
+ devpriv = dev->private;
+ spin_lock_init(&devpriv->isr_spinlock);
+ spin_lock_init(&devpriv->res_spinlock);
+ spin_lock_init(&devpriv->ai_stop_spinlock);
+ spin_lock_init(&devpriv->ao_stop_spinlock);
+ return 0;
}
-static void pci230_handle_ai(struct comedi_device *dev,
- struct comedi_subdevice *s)
+/* Common part of attach and attach_pci. */
+static int pci230_attach_common(struct comedi_device *dev,
+ struct pci_dev *pci_dev)
{
- unsigned int events = 0;
- unsigned int status_fifo;
- unsigned int i;
- unsigned int todo;
- unsigned int fifoamount;
- struct comedi_async *async = s->async;
- unsigned int scanlen = async->cmd.scan_end_arg;
+ const struct pci230_board *thisboard = comedi_board(dev);
+ struct pci230_private *devpriv = dev->private;
+ struct comedi_subdevice *s;
+ unsigned long iobase1, iobase2;
+ /* PCI230's I/O spaces 1 and 2 respectively. */
+ int irq_hdl, rc;
- /* Determine number of samples to read. */
- if (devpriv->ai_continuous) {
- todo = PCI230_ADC_FIFOLEVEL_HALFFULL;
- } else if (devpriv->ai_scan_count == 0) {
- todo = 0;
- } else if ((devpriv->ai_scan_count > PCI230_ADC_FIFOLEVEL_HALFFULL)
- || (scanlen > PCI230_ADC_FIFOLEVEL_HALFFULL)) {
- todo = PCI230_ADC_FIFOLEVEL_HALFFULL;
- } else {
- todo = (devpriv->ai_scan_count * scanlen)
- - devpriv->ai_scan_pos;
- if (todo > PCI230_ADC_FIFOLEVEL_HALFFULL)
- todo = PCI230_ADC_FIFOLEVEL_HALFFULL;
+ comedi_set_hw_dev(dev, &pci_dev->dev);
+ dev->board_name = thisboard->name;
+ /* Enable PCI device and reserve I/O spaces. */
+ if (comedi_pci_enable(pci_dev, "amplc_pci230") < 0) {
+ dev_err(dev->class_dev,
+ "failed to enable PCI device and request regions\n");
+ return -EIO;
}
+ /* Read base addresses of the PCI230's two I/O regions from PCI
+ * configuration register. */
+ iobase1 = pci_resource_start(pci_dev, 2);
+ iobase2 = pci_resource_start(pci_dev, 3);
+ dev_dbg(dev->class_dev,
+ "%s I/O region 1 0x%04lx I/O region 2 0x%04lx\n",
+ dev->board_name, iobase1, iobase2);
+ devpriv->iobase1 = iobase1;
+ dev->iobase = iobase2;
+ /* Read bits of DACCON register - only the output range. */
+ devpriv->daccon = inw(dev->iobase + PCI230_DACCON) & PCI230_DAC_OR_MASK;
+ /* Read hardware version register and set extended function register
+ * if they exist. */
+ if (pci_resource_len(pci_dev, 3) >= 32) {
+ unsigned short extfunc = 0;
- if (todo == 0)
- return;
-
-
- fifoamount = 0;
- for (i = 0; i < todo; i++) {
- if (fifoamount == 0) {
- /* Read FIFO state. */
- status_fifo = inw(dev->iobase + PCI230_ADCCON);
-
- if ((status_fifo & PCI230_ADC_FIFO_FULL_LATCHED) != 0) {
- /* Report error otherwise FIFO overruns will go
- * unnoticed by the caller. */
- comedi_error(dev, "AI FIFO overrun");
- events |= COMEDI_CB_OVERFLOW | COMEDI_CB_ERROR;
- break;
- } else if ((status_fifo & PCI230_ADC_FIFO_EMPTY) != 0) {
- /* FIFO empty. */
- break;
- } else if ((status_fifo & PCI230_ADC_FIFO_HALF) != 0) {
- /* FIFO half full. */
- fifoamount = PCI230_ADC_FIFOLEVEL_HALFFULL;
- } else {
- /* FIFO not empty. */
- if (devpriv->hwver > 0) {
- /* Read PCI230+/260+ ADC FIFO level. */
- fifoamount = inw(dev->iobase
- + PCI230P_ADCFFLEV);
- if (fifoamount == 0) {
- /* Shouldn't happen. */
- break;
- }
- } else {
- fifoamount = 1;
- }
- }
+ devpriv->hwver = inw(dev->iobase + PCI230P_HWVER);
+ if (devpriv->hwver < thisboard->min_hwver) {
+ dev_err(dev->class_dev,
+ "%s - bad hardware version - got %u, need %u\n",
+ dev->board_name, devpriv->hwver,
+ thisboard->min_hwver);
+ return -EIO;
}
-
- /* Read sample and store in Comedi's circular buffer. */
- if (comedi_buf_put(async, pci230_ai_read(dev)) == 0) {
- events |= COMEDI_CB_ERROR | COMEDI_CB_OVERFLOW;
- comedi_error(dev, "AI buffer overflow");
- break;
+ if (devpriv->hwver > 0) {
+ if (!thisboard->have_dio) {
+ /* No DIO ports. Route counters' external gates
+ * to the EXTTRIG signal (PCI260+ pin 17).
+ * (Otherwise, they would be routed to DIO
+ * inputs PC0, PC1 and PC2 which don't exist
+ * on PCI260[+].) */
+ extfunc |= PCI230P_EXTFUNC_GAT_EXTTRIG;
+ }
+ if ((thisboard->ao_chans > 0)
+ && (devpriv->hwver >= 2)) {
+ /* Enable DAC FIFO functionality. */
+ extfunc |= PCI230P2_EXTFUNC_DACFIFO;
+ }
}
- fifoamount--;
- devpriv->ai_scan_pos++;
- if (devpriv->ai_scan_pos == scanlen) {
- /* End of scan. */
- devpriv->ai_scan_pos = 0;
- devpriv->ai_scan_count--;
- async->events |= COMEDI_CB_EOS;
+ outw(extfunc, dev->iobase + PCI230P_EXTFUNC);
+ if ((extfunc & PCI230P2_EXTFUNC_DACFIFO) != 0) {
+ /* Temporarily enable DAC FIFO, reset it and disable
+ * FIFO wraparound. */
+ outw(devpriv->daccon | PCI230P2_DAC_FIFO_EN
+ | PCI230P2_DAC_FIFO_RESET,
+ dev->iobase + PCI230_DACCON);
+ /* Clear DAC FIFO channel enable register. */
+ outw(0, dev->iobase + PCI230P2_DACEN);
+ /* Disable DAC FIFO. */
+ outw(devpriv->daccon, dev->iobase + PCI230_DACCON);
}
}
-
- if (!devpriv->ai_continuous && (devpriv->ai_scan_count == 0)) {
- /* End of acquisition. */
- events |= COMEDI_CB_EOA;
- } else {
- /* More samples required, tell Comedi to block. */
- events |= COMEDI_CB_BLOCK;
- }
- async->events |= events;
-
- if ((async->events & (COMEDI_CB_EOA | COMEDI_CB_ERROR |
- COMEDI_CB_OVERFLOW)) != 0) {
- /* disable hardware conversions */
- pci230_ai_stop(dev, s);
+ /* Disable board's interrupts. */
+ outb(0, devpriv->iobase1 + PCI230_INT_SCE);
+ /* Set ADC to a reasonable state. */
+ devpriv->adcg = 0;
+ devpriv->adccon = PCI230_ADC_TRIG_NONE | PCI230_ADC_IM_SE
+ | PCI230_ADC_IR_BIP;
+ outw(1 << 0, dev->iobase + PCI230_ADCEN);
+ outw(devpriv->adcg, dev->iobase + PCI230_ADCG);
+ outw(devpriv->adccon | PCI230_ADC_FIFO_RESET,
+ dev->iobase + PCI230_ADCCON);
+ /* Register the interrupt handler. */
+ irq_hdl = request_irq(pci_dev->irq, pci230_interrupt,
+ IRQF_SHARED, "amplc_pci230", dev);
+ if (irq_hdl < 0) {
+ dev_warn(dev->class_dev,
+ "unable to register irq %u, commands will not be available\n",
+ pci_dev->irq);
} else {
- /* update FIFO interrupt trigger level */
- pci230_ai_update_fifo_trigger_level(dev, s);
+ dev->irq = pci_dev->irq;
+ dev_dbg(dev->class_dev, "registered irq %u\n", pci_dev->irq);
}
-}
-
-static void pci230_ao_stop(struct comedi_device *dev,
- struct comedi_subdevice *s)
-{
- unsigned long irqflags;
- unsigned char intsrc;
- int started;
- struct comedi_cmd *cmd;
-
- spin_lock_irqsave(&devpriv->ao_stop_spinlock, irqflags);
- started = test_and_clear_bit(AO_CMD_STARTED, &devpriv->state);
- spin_unlock_irqrestore(&devpriv->ao_stop_spinlock, irqflags);
- if (!started)
- return;
+ rc = comedi_alloc_subdevices(dev, 3);
+ if (rc)
+ return rc;
- cmd = &s->async->cmd;
- if (cmd->scan_begin_src == TRIG_TIMER) {
- /* Stop scan rate generator. */
- pci230_cancel_ct(dev, 1);
+ s = dev->subdevices + 0;
+ /* analog input subdevice */
+ s->type = COMEDI_SUBD_AI;
+ s->subdev_flags = SDF_READABLE | SDF_DIFF | SDF_GROUND;
+ s->n_chan = thisboard->ai_chans;
+ s->maxdata = (1 << thisboard->ai_bits) - 1;
+ s->range_table = &pci230_ai_range;
+ s->insn_read = &pci230_ai_rinsn;
+ s->len_chanlist = 256; /* but there are restrictions. */
+ /* Only register commands if the interrupt handler is installed. */
+ if (irq_hdl == 0) {
+ dev->read_subdev = s;
+ s->subdev_flags |= SDF_CMD_READ;
+ s->do_cmd = &pci230_ai_cmd;
+ s->do_cmdtest = &pci230_ai_cmdtest;
+ s->cancel = pci230_ai_cancel;
}
-
- /* Determine interrupt source. */
- if (devpriv->hwver < 2) {
- /* Not using DAC FIFO. Using CT1 interrupt. */
- intsrc = PCI230_INT_ZCLK_CT1;
+ s = dev->subdevices + 1;
+ /* analog output subdevice */
+ if (thisboard->ao_chans > 0) {
+ s->type = COMEDI_SUBD_AO;
+ s->subdev_flags = SDF_WRITABLE | SDF_GROUND;
+ s->n_chan = thisboard->ao_chans;
+ s->maxdata = (1 << thisboard->ao_bits) - 1;
+ s->range_table = &pci230_ao_range;
+ s->insn_write = &pci230_ao_winsn;
+ s->insn_read = &pci230_ao_rinsn;
+ s->len_chanlist = thisboard->ao_chans;
+ /* Only register commands if the interrupt handler is
+ * installed. */
+ if (irq_hdl == 0) {
+ dev->write_subdev = s;
+ s->subdev_flags |= SDF_CMD_WRITE;
+ s->do_cmd = &pci230_ao_cmd;
+ s->do_cmdtest = &pci230_ao_cmdtest;
+ s->cancel = pci230_ao_cancel;
+ }
} else {
- /* Using DAC FIFO interrupt. */
- intsrc = PCI230P2_INT_DAC;
- }
- /* Disable interrupt and wait for interrupt routine to finish running
- * unless we are called from the interrupt routine. */
- spin_lock_irqsave(&devpriv->isr_spinlock, irqflags);
- devpriv->int_en &= ~intsrc;
- while (devpriv->intr_running && devpriv->intr_cpuid != THISCPU) {
- spin_unlock_irqrestore(&devpriv->isr_spinlock, irqflags);
- spin_lock_irqsave(&devpriv->isr_spinlock, irqflags);
- }
- if (devpriv->ier != devpriv->int_en) {
- devpriv->ier = devpriv->int_en;
- outb(devpriv->ier, devpriv->iobase1 + PCI230_INT_SCE);
+ s->type = COMEDI_SUBD_UNUSED;
}
- spin_unlock_irqrestore(&devpriv->isr_spinlock, irqflags);
-
- if (devpriv->hwver >= 2) {
- /* Using DAC FIFO. Reset FIFO, clear underrun error,
- * disable FIFO. */
- devpriv->daccon &= PCI230_DAC_OR_MASK;
- outw(devpriv->daccon | PCI230P2_DAC_FIFO_RESET
- | PCI230P2_DAC_FIFO_UNDERRUN_CLEAR,
- dev->iobase + PCI230_DACCON);
+ s = dev->subdevices + 2;
+ /* digital i/o subdevice */
+ if (thisboard->have_dio) {
+ rc = subdev_8255_init(dev, s, NULL,
+ (devpriv->iobase1 + PCI230_PPI_X_BASE));
+ if (rc < 0)
+ return rc;
+ } else {
+ s->type = COMEDI_SUBD_UNUSED;
}
-
- /* Release resources. */
- put_all_resources(dev, OWNER_AOCMD);
+ dev_info(dev->class_dev, "attached\n");
+ return 1;
}
-static int pci230_ao_cancel(struct comedi_device *dev,
- struct comedi_subdevice *s)
+static int pci230_attach(struct comedi_device *dev, struct comedi_devconfig *it)
{
- pci230_ao_stop(dev, s);
- return 0;
+ const struct pci230_board *thisboard = comedi_board(dev);
+ struct pci_dev *pci_dev;
+ int rc;
+
+ dev_info(dev->class_dev, "amplc_pci230: attach %s %d,%d\n",
+ thisboard->name, it->options[0], it->options[1]);
+ rc = pci230_alloc_private(dev); /* sets dev->private */
+ if (rc)
+ return rc;
+ pci_dev = pci230_find_pci_dev(dev, it);
+ if (!pci_dev)
+ return -EIO;
+ return pci230_attach_common(dev, pci_dev);
}
-static void pci230_ai_stop(struct comedi_device *dev,
- struct comedi_subdevice *s)
+static int __devinit pci230_attach_pci(struct comedi_device *dev,
+ struct pci_dev *pci_dev)
{
- unsigned long irqflags;
- struct comedi_cmd *cmd;
- int started;
-
- spin_lock_irqsave(&devpriv->ai_stop_spinlock, irqflags);
- started = test_and_clear_bit(AI_CMD_STARTED, &devpriv->state);
- spin_unlock_irqrestore(&devpriv->ai_stop_spinlock, irqflags);
- if (!started)
- return;
-
-
- cmd = &s->async->cmd;
- if (cmd->convert_src == TRIG_TIMER) {
- /* Stop conversion rate generator. */
- pci230_cancel_ct(dev, 2);
- }
- if (cmd->scan_begin_src != TRIG_FOLLOW) {
- /* Stop scan period monostable. */
- pci230_cancel_ct(dev, 0);
+ int rc;
+
+ dev_info(dev->class_dev, "amplc_pci230: attach pci %s\n",
+ pci_name(pci_dev));
+ rc = pci230_alloc_private(dev); /* sets dev->private */
+ if (rc)
+ return rc;
+ dev->board_ptr = pci230_find_pci_board(pci_dev);
+ if (dev->board_ptr == NULL) {
+ dev_err(dev->class_dev,
+ "amplc_pci230: BUG! cannot determine board type!\n");
+ return -EINVAL;
}
+ return pci230_attach_common(dev, pci_dev);
+}
- spin_lock_irqsave(&devpriv->isr_spinlock, irqflags);
- /* Disable ADC interrupt and wait for interrupt routine to finish
- * running unless we are called from the interrupt routine. */
- devpriv->int_en &= ~PCI230_INT_ADC;
- while (devpriv->intr_running && devpriv->intr_cpuid != THISCPU) {
- spin_unlock_irqrestore(&devpriv->isr_spinlock, irqflags);
- spin_lock_irqsave(&devpriv->isr_spinlock, irqflags);
- }
- if (devpriv->ier != devpriv->int_en) {
- devpriv->ier = devpriv->int_en;
- outb(devpriv->ier, devpriv->iobase1 + PCI230_INT_SCE);
+static void pci230_detach(struct comedi_device *dev)
+{
+ const struct pci230_board *thisboard = comedi_board(dev);
+ struct pci_dev *pcidev = comedi_to_pci_dev(dev);
+
+ if (dev->subdevices && thisboard->have_dio)
+ subdev_8255_cleanup(dev, dev->subdevices + 2);
+ if (dev->irq)
+ free_irq(dev->irq, dev);
+ if (pcidev) {
+ if (dev->iobase)
+ comedi_pci_disable(pcidev);
+ pci_dev_put(pcidev);
}
- spin_unlock_irqrestore(&devpriv->isr_spinlock, irqflags);
+}
- /* Reset FIFO, disable FIFO and set start conversion source to none.
- * Keep se/diff and bip/uni settings */
- devpriv->adccon = (devpriv->adccon & (PCI230_ADC_IR_MASK
- | PCI230_ADC_IM_MASK)) |
- PCI230_ADC_TRIG_NONE;
- outw(devpriv->adccon | PCI230_ADC_FIFO_RESET,
- dev->iobase + PCI230_ADCCON);
+static struct comedi_driver amplc_pci230_driver = {
+ .driver_name = "amplc_pci230",
+ .module = THIS_MODULE,
+ .attach = pci230_attach,
+ .attach_pci = pci230_attach_pci,
+ .detach = pci230_detach,
+ .board_name = &pci230_boards[0].name,
+ .offset = sizeof(pci230_boards[0]),
+ .num_names = ARRAY_SIZE(pci230_boards),
+};
- /* Release resources. */
- put_all_resources(dev, OWNER_AICMD);
+static int __devinit amplc_pci230_pci_probe(struct pci_dev *dev,
+ const struct pci_device_id *ent)
+{
+ return comedi_pci_auto_config(dev, &amplc_pci230_driver);
}
-static int pci230_ai_cancel(struct comedi_device *dev,
- struct comedi_subdevice *s)
+static void __devexit amplc_pci230_pci_remove(struct pci_dev *dev)
{
- pci230_ai_stop(dev, s);
- return 0;
+ comedi_pci_auto_unconfig(dev);
}
+static DEFINE_PCI_DEVICE_TABLE(amplc_pci230_pci_table) = {
+ { PCI_DEVICE(PCI_VENDOR_ID_AMPLICON, PCI_DEVICE_ID_PCI230) },
+ { PCI_DEVICE(PCI_VENDOR_ID_AMPLICON, PCI_DEVICE_ID_PCI260) },
+ { 0 }
+};
+MODULE_DEVICE_TABLE(pci, amplc_pci230_pci_table);
+
+static struct pci_driver amplc_pci230_pci_driver = {
+ .name = "amplc_pci230",
+ .id_table = amplc_pci230_pci_table,
+ .probe = amplc_pci230_pci_probe,
+ .remove = __devexit_p(amplc_pci230_pci_remove)
+};
+module_comedi_pci_driver(amplc_pci230_driver, amplc_pci230_pci_driver);
+
MODULE_AUTHOR("Comedi http://www.comedi.org");
MODULE_DESCRIPTION("Comedi low-level driver");
MODULE_LICENSE("GPL");
diff --git a/drivers/staging/comedi/drivers/c6xdigio.c b/drivers/staging/comedi/drivers/c6xdigio.c
index 11cdaf2a5aa5..41ed8576f301 100644
--- a/drivers/staging/comedi/drivers/c6xdigio.c
+++ b/drivers/staging/comedi/drivers/c6xdigio.c
@@ -97,16 +97,6 @@ union encvaluetype {
#define C6XDIGIO_TIME_OUT 20
-static int c6xdigio_attach(struct comedi_device *dev,
- struct comedi_devconfig *it);
-static int c6xdigio_detach(struct comedi_device *dev);
-struct comedi_driver driver_c6xdigio = {
- .driver_name = "c6xdigio",
- .module = THIS_MODULE,
- .attach = c6xdigio_attach,
- .detach = c6xdigio_detach,
-};
-
static void C6X_pwmInit(unsigned long baseAddr)
{
int timeout = 0;
@@ -407,10 +397,6 @@ static void board_init(struct comedi_device *dev)
}
-/* static void board_halt(struct comedi_device *dev) { */
-/* C6X_pwmInit(dev->iobase); */
-/* } */
-
/*
options[0] - I/O port
options[1] - irq
@@ -447,8 +433,8 @@ static int c6xdigio_attach(struct comedi_device *dev,
dev->iobase = iobase;
dev->board_name = "c6xdigio";
- result = alloc_subdevices(dev, 2); /* 3 with encoder_init write */
- if (result < 0)
+ result = comedi_alloc_subdevices(dev, 2);
+ if (result)
return result;
/* Make sure that PnP ports get activated */
@@ -500,36 +486,22 @@ static int c6xdigio_attach(struct comedi_device *dev,
return 0;
}
-static int c6xdigio_detach(struct comedi_device *dev)
+static void c6xdigio_detach(struct comedi_device *dev)
{
- /* board_halt(dev); may not need this */
-
- printk(KERN_DEBUG "comedi%d: c6xdigio: remove\n", dev->minor);
-
if (dev->iobase)
release_region(dev->iobase, C6XDIGIO_SIZE);
-
- /* Not using IRQ so I am not sure if I need this */
if (dev->irq)
free_irq(dev->irq, dev);
-
pnp_unregister_driver(&c6xdigio_pnp_driver);
-
- return 0;
-}
-
-static int __init driver_c6xdigio_init_module(void)
-{
- return comedi_driver_register(&driver_c6xdigio);
}
-static void __exit driver_c6xdigio_cleanup_module(void)
-{
- comedi_driver_unregister(&driver_c6xdigio);
-}
-
-module_init(driver_c6xdigio_init_module);
-module_exit(driver_c6xdigio_cleanup_module);
+static struct comedi_driver c6xdigio_driver = {
+ .driver_name = "c6xdigio",
+ .module = THIS_MODULE,
+ .attach = c6xdigio_attach,
+ .detach = c6xdigio_detach,
+};
+module_comedi_driver(c6xdigio_driver);
MODULE_AUTHOR("Comedi http://www.comedi.org");
MODULE_DESCRIPTION("Comedi low-level driver");
diff --git a/drivers/staging/comedi/drivers/cb_das16_cs.c b/drivers/staging/comedi/drivers/cb_das16_cs.c
index 49404f49f7b7..58d45299bf85 100644
--- a/drivers/staging/comedi/drivers/cb_das16_cs.c
+++ b/drivers/staging/comedi/drivers/cb_das16_cs.c
@@ -19,6 +19,13 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ PCMCIA support code for this driver is adapted from the dummy_cs.c
+ driver of the Linux PCMCIA Card Services package.
+
+ The initial developer of the original code is David A. Hinds
+ <dahinds@users.sourceforge.net>. Portions created by David A. Hinds
+ are Copyright (C) 1999 David A. Hinds. All Rights Reserved.
+
*/
/*
Driver: cb_das16_cs
@@ -35,7 +42,6 @@ Status: experimental
#include <linux/slab.h>
#include "../comedidev.h"
#include <linux/delay.h>
-#include <linux/pci.h>
#include <pcmcia/cistpl.h>
#include <pcmcia/ds.h>
@@ -59,212 +65,39 @@ struct das16cs_board {
int device_id;
int n_ao_chans;
};
+
static const struct das16cs_board das16cs_boards[] = {
{
- .device_id = 0x0000, /* unknown */
- .name = "PC-CARD DAS16/16",
- .n_ao_chans = 0,
- },
- {
- .device_id = 0x0039,
- .name = "PC-CARD DAS16/16-AO",
- .n_ao_chans = 2,
- },
- {
- .device_id = 0x4009,
- .name = "PCM-DAS16s/16",
- .n_ao_chans = 0,
- },
+ .name = "PC-CARD DAS16/16-AO",
+ .device_id = 0x0039,
+ .n_ao_chans = 2,
+ }, {
+ .name = "PCM-DAS16s/16",
+ .device_id = 0x4009,
+ .n_ao_chans = 0,
+ }, {
+ .name = "PC-CARD DAS16/16",
+ .device_id = 0x0000, /* unknown */
+ .n_ao_chans = 0,
+ },
};
-#define n_boards ARRAY_SIZE(das16cs_boards)
-#define thisboard ((const struct das16cs_board *)dev->board_ptr)
-
struct das16cs_private {
- struct pcmcia_device *link;
-
unsigned int ao_readback[2];
unsigned short status1;
unsigned short status2;
};
-#define devpriv ((struct das16cs_private *)dev->private)
-
-static int das16cs_attach(struct comedi_device *dev,
- struct comedi_devconfig *it);
-static int das16cs_detach(struct comedi_device *dev);
-static struct comedi_driver driver_das16cs = {
- .driver_name = "cb_das16_cs",
- .module = THIS_MODULE,
- .attach = das16cs_attach,
- .detach = das16cs_detach,
-};
static struct pcmcia_device *cur_dev;
-static const struct comedi_lrange das16cs_ai_range = { 4, {
- RANGE(-10, 10),
- RANGE(-5, 5),
- RANGE(-2.5, 2.5),
- RANGE(-1.25, 1.25),
- }
-};
-
-static irqreturn_t das16cs_interrupt(int irq, void *d);
-static int das16cs_ai_rinsn(struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data);
-static int das16cs_ai_cmd(struct comedi_device *dev,
- struct comedi_subdevice *s);
-static int das16cs_ai_cmdtest(struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_cmd *cmd);
-static int das16cs_ao_winsn(struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data);
-static int das16cs_ao_rinsn(struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data);
-static int das16cs_dio_insn_bits(struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data);
-static int das16cs_dio_insn_config(struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_insn *insn,
- unsigned int *data);
-static int das16cs_timer_insn_read(struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_insn *insn,
- unsigned int *data);
-static int das16cs_timer_insn_config(struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_insn *insn,
- unsigned int *data);
-
-static const struct das16cs_board *das16cs_probe(struct comedi_device *dev,
- struct pcmcia_device *link)
-{
- int i;
-
- for (i = 0; i < n_boards; i++) {
- if (das16cs_boards[i].device_id == link->card_id)
- return das16cs_boards + i;
+static const struct comedi_lrange das16cs_ai_range = {
+ 4, {
+ BIP_RANGE(10),
+ BIP_RANGE(5),
+ BIP_RANGE(2.5),
+ BIP_RANGE(1.25),
}
-
- dev_dbg(dev->hw_dev, "unknown board!\n");
-
- return NULL;
-}
-
-static int das16cs_attach(struct comedi_device *dev,
- struct comedi_devconfig *it)
-{
- struct pcmcia_device *link;
- struct comedi_subdevice *s;
- int ret;
- int i;
-
- dev_dbg(dev->hw_dev, "comedi%d: cb_das16_cs: attached\n", dev->minor);
-
- link = cur_dev; /* XXX hack */
- if (!link)
- return -EIO;
-
- dev->iobase = link->resource[0]->start;
- dev_dbg(dev->hw_dev, "I/O base=0x%04lx\n", dev->iobase);
-
- dev_dbg(dev->hw_dev, "fingerprint:\n");
- for (i = 0; i < 48; i += 2)
- dev_dbg(dev->hw_dev, "%04x\n", inw(dev->iobase + i));
-
-
- ret = request_irq(link->irq, das16cs_interrupt,
- IRQF_SHARED, "cb_das16_cs", dev);
- if (ret < 0)
- return ret;
-
- dev->irq = link->irq;
-
- dev_dbg(dev->hw_dev, "irq=%u\n", dev->irq);
-
- dev->board_ptr = das16cs_probe(dev, link);
- if (!dev->board_ptr)
- return -EIO;
-
- dev->board_name = thisboard->name;
-
- if (alloc_private(dev, sizeof(struct das16cs_private)) < 0)
- return -ENOMEM;
-
- if (alloc_subdevices(dev, 4) < 0)
- return -ENOMEM;
-
- s = dev->subdevices + 0;
- dev->read_subdev = s;
- /* analog input subdevice */
- s->type = COMEDI_SUBD_AI;
- s->subdev_flags = SDF_READABLE | SDF_GROUND | SDF_DIFF | SDF_CMD_READ;
- s->n_chan = 16;
- s->maxdata = 0xffff;
- s->range_table = &das16cs_ai_range;
- s->len_chanlist = 16;
- s->insn_read = das16cs_ai_rinsn;
- s->do_cmd = das16cs_ai_cmd;
- s->do_cmdtest = das16cs_ai_cmdtest;
-
- s = dev->subdevices + 1;
- /* analog output subdevice */
- if (thisboard->n_ao_chans) {
- s->type = COMEDI_SUBD_AO;
- s->subdev_flags = SDF_WRITABLE;
- s->n_chan = thisboard->n_ao_chans;
- s->maxdata = 0xffff;
- s->range_table = &range_bipolar10;
- s->insn_write = &das16cs_ao_winsn;
- s->insn_read = &das16cs_ao_rinsn;
- }
-
- s = dev->subdevices + 2;
- /* digital i/o subdevice */
- if (1) {
- s->type = COMEDI_SUBD_DIO;
- s->subdev_flags = SDF_READABLE | SDF_WRITABLE;
- s->n_chan = 8;
- s->maxdata = 1;
- s->range_table = &range_digital;
- s->insn_bits = das16cs_dio_insn_bits;
- s->insn_config = das16cs_dio_insn_config;
- } else {
- s->type = COMEDI_SUBD_UNUSED;
- }
-
- s = dev->subdevices + 3;
- /* timer subdevice */
- if (0) {
- s->type = COMEDI_SUBD_TIMER;
- s->subdev_flags = SDF_READABLE | SDF_WRITABLE;
- s->n_chan = 1;
- s->maxdata = 0xff;
- s->range_table = &range_unknown;
- s->insn_read = das16cs_timer_insn_read;
- s->insn_config = das16cs_timer_insn_config;
- } else {
- s->type = COMEDI_SUBD_UNUSED;
- }
-
-
- return 1;
-}
-
-static int das16cs_detach(struct comedi_device *dev)
-{
- dev_dbg(dev->hw_dev, "comedi%d: das16cs: remove\n", dev->minor);
-
- if (dev->irq)
- free_irq(dev->irq, dev);
-
-
- return 0;
-}
+};
static irqreturn_t das16cs_interrupt(int irq, void *d)
{
@@ -272,48 +105,53 @@ static irqreturn_t das16cs_interrupt(int irq, void *d)
return IRQ_HANDLED;
}
-/*
- * "instructions" read/write data in "one-shot" or "software-triggered"
- * mode.
- */
static int das16cs_ai_rinsn(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
+ struct das16cs_private *devpriv = dev->private;
+ int chan = CR_CHAN(insn->chanspec);
+ int range = CR_RANGE(insn->chanspec);
+ int aref = CR_AREF(insn->chanspec);
int i;
int to;
- int aref;
- int range;
- int chan;
- static int range_bits[] = { 0x800, 0x000, 0x100, 0x200 };
- chan = CR_CHAN(insn->chanspec);
- aref = CR_AREF(insn->chanspec);
- range = CR_RANGE(insn->chanspec);
-
- outw(chan, dev->iobase + 2);
+ outw(chan, dev->iobase + DAS16CS_DIO_MUX);
devpriv->status1 &= ~0xf320;
devpriv->status1 |= (aref == AREF_DIFF) ? 0 : 0x0020;
- outw(devpriv->status1, dev->iobase + 4);
+ outw(devpriv->status1, dev->iobase + DAS16CS_MISC1);
devpriv->status2 &= ~0xff00;
- devpriv->status2 |= range_bits[range];
- outw(devpriv->status2, dev->iobase + 6);
+ switch (range) {
+ case 0:
+ devpriv->status2 |= 0x800;
+ break;
+ case 1:
+ devpriv->status2 |= 0x000;
+ break;
+ case 2:
+ devpriv->status2 |= 0x100;
+ break;
+ case 3:
+ devpriv->status2 |= 0x200;
+ break;
+ }
+ outw(devpriv->status2, dev->iobase + DAS16CS_MISC2);
for (i = 0; i < insn->n; i++) {
- outw(0, dev->iobase);
+ outw(0, dev->iobase + DAS16CS_ADC_DATA);
#define TIMEOUT 1000
for (to = 0; to < TIMEOUT; to++) {
- if (inw(dev->iobase + 4) & 0x0080)
+ if (inw(dev->iobase + DAS16CS_MISC1) & 0x0080)
break;
}
if (to == TIMEOUT) {
- dev_dbg(dev->hw_dev, "cb_das16_cs: ai timeout\n");
+ dev_dbg(dev->class_dev, "cb_das16_cs: ai timeout\n");
return -ETIME;
}
- data[i] = (unsigned short)inw(dev->iobase + 0);
+ data[i] = inw(dev->iobase + DAS16CS_ADC_DATA);
}
return i;
@@ -331,13 +169,6 @@ static int das16cs_ai_cmdtest(struct comedi_device *dev,
int err = 0;
int tmp;
- /* cmdtest tests a particular command to see if it is valid.
- * Using the cmdtest ioctl, a user can create a valid cmd
- * and then have it executes by the cmd ioctl.
- *
- * cmdtest returns 1,2,3,4 or 0, depending on which tests
- * the command passes. */
-
/* step 1: make sure trigger sources are trivially valid */
tmp = cmd->start_src;
@@ -488,6 +319,7 @@ static int das16cs_ao_winsn(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
+ struct das16cs_private *devpriv = dev->private;
int i;
int chan = CR_CHAN(insn->chanspec);
unsigned short status1;
@@ -498,7 +330,7 @@ static int das16cs_ao_winsn(struct comedi_device *dev,
devpriv->ao_readback[chan] = data[i];
d = data[i];
- outw(devpriv->status1, dev->iobase + 4);
+ outw(devpriv->status1, dev->iobase + DAS16CS_MISC1);
udelay(1);
status1 = devpriv->status1 & ~0xf;
@@ -507,34 +339,32 @@ static int das16cs_ao_winsn(struct comedi_device *dev,
else
status1 |= 0x0008;
-/* printk("0x%04x\n",status1);*/
- outw(status1, dev->iobase + 4);
+ outw(status1, dev->iobase + DAS16CS_MISC1);
udelay(1);
for (bit = 15; bit >= 0; bit--) {
int b = (d >> bit) & 0x1;
b <<= 1;
-/* printk("0x%04x\n",status1 | b | 0x0000);*/
- outw(status1 | b | 0x0000, dev->iobase + 4);
+ outw(status1 | b | 0x0000, dev->iobase + DAS16CS_MISC1);
udelay(1);
-/* printk("0x%04x\n",status1 | b | 0x0004);*/
- outw(status1 | b | 0x0004, dev->iobase + 4);
+ outw(status1 | b | 0x0004, dev->iobase + DAS16CS_MISC1);
udelay(1);
}
-/* make high both DAC0CS and DAC1CS to load
- new data and update analog output*/
- outw(status1 | 0x9, dev->iobase + 4);
+ /*
+ * Make both DAC0CS and DAC1CS high to load
+ * the new data and update analog the output
+ */
+ outw(status1 | 0x9, dev->iobase + DAS16CS_MISC1);
}
return i;
}
-/* AO subdevices should have a read insn as well as a write insn.
- * Usually this means copying a value stored in devpriv. */
static int das16cs_ao_rinsn(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
+ struct das16cs_private *devpriv = dev->private;
int i;
int chan = CR_CHAN(insn->chanspec);
@@ -544,36 +374,27 @@ static int das16cs_ao_rinsn(struct comedi_device *dev,
return i;
}
-/* DIO devices are slightly special. Although it is possible to
- * implement the insn_read/insn_write interface, it is much more
- * useful to applications if you implement the insn_bits interface.
- * This allows packed reading/writing of the DIO channels. The
- * comedi core can convert between insn_bits and insn_read/write */
static int das16cs_dio_insn_bits(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
- if (insn->n != 2)
- return -EINVAL;
-
if (data[0]) {
s->state &= ~data[0];
s->state |= data[0] & data[1];
- outw(s->state, dev->iobase + 16);
+ outw(s->state, dev->iobase + DAS16CS_DIO);
}
- /* on return, data[1] contains the value of the digital
- * input and output lines. */
- data[1] = inw(dev->iobase + 16);
+ data[1] = inw(dev->iobase + DAS16CS_DIO);
- return 2;
+ return insn->n;
}
static int das16cs_dio_insn_config(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
+ struct das16cs_private *devpriv = dev->private;
int chan = CR_CHAN(insn->chanspec);
int bits;
@@ -603,110 +424,116 @@ static int das16cs_dio_insn_config(struct comedi_device *dev,
devpriv->status2 |= (s->io_bits & 0xf0) ? 0x0080 : 0;
devpriv->status2 |= (s->io_bits & 0x0f) ? 0x0040 : 0;
- outw(devpriv->status2, dev->iobase + 6);
+ outw(devpriv->status2, dev->iobase + DAS16CS_MISC2);
return insn->n;
}
-static int das16cs_timer_insn_read(struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data)
-{
- return -EINVAL;
-}
-
-static int das16cs_timer_insn_config(struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_insn *insn,
- unsigned int *data)
+static const struct das16cs_board *das16cs_probe(struct comedi_device *dev,
+ struct pcmcia_device *link)
{
- return -EINVAL;
-}
-
-/* PCMCIA stuff */
-
-/*======================================================================
-
- The following pcmcia code for the pcm-das08 is adapted from the
- dummy_cs.c driver of the Linux PCMCIA Card Services package.
-
- The initial developer of the original code is David A. Hinds
- <dahinds@users.sourceforge.net>. Portions created by David A. Hinds
- are Copyright (C) 1999 David A. Hinds. All Rights Reserved.
-
-======================================================================*/
-
-#if defined(CONFIG_PCMCIA) || defined(CONFIG_PCMCIA_MODULE)
-
-static void das16cs_pcmcia_config(struct pcmcia_device *link);
-static void das16cs_pcmcia_release(struct pcmcia_device *link);
-static int das16cs_pcmcia_suspend(struct pcmcia_device *p_dev);
-static int das16cs_pcmcia_resume(struct pcmcia_device *p_dev);
+ int i;
-/*
- The attach() and detach() entry points are used to create and destroy
- "instances" of the driver, where each instance represents everything
- needed to manage one actual PCMCIA card.
-*/
+ for (i = 0; i < ARRAY_SIZE(das16cs_boards); i++) {
+ if (das16cs_boards[i].device_id == link->card_id)
+ return das16cs_boards + i;
+ }
-static int das16cs_pcmcia_attach(struct pcmcia_device *);
-static void das16cs_pcmcia_detach(struct pcmcia_device *);
+ dev_dbg(dev->class_dev, "unknown board!\n");
-/*
- You'll also need to prototype all the functions that will actually
- be used to talk to your device. See 'memory_cs' for a good example
- of a fully self-sufficient driver; the other drivers rely more or
- less on other parts of the kernel.
-*/
+ return NULL;
+}
-struct local_info_t {
+static int das16cs_attach(struct comedi_device *dev,
+ struct comedi_devconfig *it)
+{
+ const struct das16cs_board *thisboard;
struct pcmcia_device *link;
- int stop;
- struct bus_operations *bus;
-};
-
-/*======================================================================
+ struct comedi_subdevice *s;
+ int ret;
- das16cs_pcmcia_attach() creates an "instance" of the driver, allocating
- local data structures for one device. The device is registered
- with Card Services.
+ link = cur_dev; /* XXX hack */
+ if (!link)
+ return -EIO;
- The dev_link structure is initialized, but we don't actually
- configure the card at this point -- we wait until we receive a
- card insertion event.
+ dev->board_ptr = das16cs_probe(dev, link);
+ if (!dev->board_ptr)
+ return -EIO;
+ thisboard = comedi_board(dev);
-======================================================================*/
+ dev->board_name = thisboard->name;
-static int das16cs_pcmcia_attach(struct pcmcia_device *link)
-{
- struct local_info_t *local;
+ dev->iobase = link->resource[0]->start;
- dev_dbg(&link->dev, "das16cs_pcmcia_attach()\n");
+ ret = request_irq(link->irq, das16cs_interrupt,
+ IRQF_SHARED, "cb_das16_cs", dev);
+ if (ret < 0)
+ return ret;
+ dev->irq = link->irq;
- /* Allocate space for private device-specific data */
- local = kzalloc(sizeof(struct local_info_t), GFP_KERNEL);
- if (!local)
+ if (alloc_private(dev, sizeof(struct das16cs_private)) < 0)
return -ENOMEM;
- local->link = link;
- link->priv = local;
- cur_dev = link;
+ ret = comedi_alloc_subdevices(dev, 3);
+ if (ret)
+ return ret;
+
+ s = dev->subdevices + 0;
+ dev->read_subdev = s;
+ /* analog input subdevice */
+ s->type = COMEDI_SUBD_AI;
+ s->subdev_flags = SDF_READABLE | SDF_GROUND | SDF_DIFF | SDF_CMD_READ;
+ s->n_chan = 16;
+ s->maxdata = 0xffff;
+ s->range_table = &das16cs_ai_range;
+ s->len_chanlist = 16;
+ s->insn_read = das16cs_ai_rinsn;
+ s->do_cmd = das16cs_ai_cmd;
+ s->do_cmdtest = das16cs_ai_cmdtest;
+
+ s = dev->subdevices + 1;
+ /* analog output subdevice */
+ if (thisboard->n_ao_chans) {
+ s->type = COMEDI_SUBD_AO;
+ s->subdev_flags = SDF_WRITABLE;
+ s->n_chan = thisboard->n_ao_chans;
+ s->maxdata = 0xffff;
+ s->range_table = &range_bipolar10;
+ s->insn_write = &das16cs_ao_winsn;
+ s->insn_read = &das16cs_ao_rinsn;
+ } else {
+ s->type = COMEDI_SUBD_UNUSED;
+ }
- das16cs_pcmcia_config(link);
+ s = dev->subdevices + 2;
+ /* digital i/o subdevice */
+ s->type = COMEDI_SUBD_DIO;
+ s->subdev_flags = SDF_READABLE | SDF_WRITABLE;
+ s->n_chan = 8;
+ s->maxdata = 1;
+ s->range_table = &range_digital;
+ s->insn_bits = das16cs_dio_insn_bits;
+ s->insn_config = das16cs_dio_insn_config;
+
+ dev_info(dev->class_dev, "%s: %s, I/O base=0x%04lx, irq=%u\n",
+ dev->driver->driver_name, dev->board_name,
+ dev->iobase, dev->irq);
return 0;
-} /* das16cs_pcmcia_attach */
+}
-static void das16cs_pcmcia_detach(struct pcmcia_device *link)
+static void das16cs_detach(struct comedi_device *dev)
{
- dev_dbg(&link->dev, "das16cs_pcmcia_detach\n");
-
- ((struct local_info_t *)link->priv)->stop = 1;
- das16cs_pcmcia_release(link);
- /* This points to the parent struct local_info_t struct */
- kfree(link->priv);
-} /* das16cs_pcmcia_detach */
+ if (dev->irq)
+ free_irq(dev->irq, dev);
+}
+static struct comedi_driver driver_das16cs = {
+ .driver_name = "cb_das16_cs",
+ .module = THIS_MODULE,
+ .attach = das16cs_attach,
+ .detach = das16cs_detach,
+};
static int das16cs_pcmcia_config_loop(struct pcmcia_device *p_dev,
void *priv_data)
@@ -717,20 +544,16 @@ static int das16cs_pcmcia_config_loop(struct pcmcia_device *p_dev,
return pcmcia_request_io(p_dev);
}
-static void das16cs_pcmcia_config(struct pcmcia_device *link)
+static int das16cs_pcmcia_attach(struct pcmcia_device *link)
{
int ret;
- dev_dbg(&link->dev, "das16cs_pcmcia_config\n");
-
/* Do we need to allocate an interrupt? */
link->config_flags |= CONF_ENABLE_IRQ | CONF_AUTO_SET_IO;
ret = pcmcia_loop_config(link, das16cs_pcmcia_config_loop, NULL);
- if (ret) {
- dev_warn(&link->dev, "no configuration found\n");
+ if (ret)
goto failed;
- }
if (!link->irq)
goto failed;
@@ -739,99 +562,60 @@ static void das16cs_pcmcia_config(struct pcmcia_device *link)
if (ret)
goto failed;
- return;
+ cur_dev = link;
+ return 0;
failed:
- das16cs_pcmcia_release(link);
-} /* das16cs_pcmcia_config */
-
-static void das16cs_pcmcia_release(struct pcmcia_device *link)
-{
- dev_dbg(&link->dev, "das16cs_pcmcia_release\n");
pcmcia_disable_device(link);
-} /* das16cs_pcmcia_release */
-
-static int das16cs_pcmcia_suspend(struct pcmcia_device *link)
-{
- struct local_info_t *local = link->priv;
-
- /* Mark the device as stopped, to block IO until later */
- local->stop = 1;
-
- return 0;
-} /* das16cs_pcmcia_suspend */
+ return ret;
+}
-static int das16cs_pcmcia_resume(struct pcmcia_device *link)
+static void das16cs_pcmcia_detach(struct pcmcia_device *link)
{
- struct local_info_t *local = link->priv;
-
- local->stop = 0;
- return 0;
-} /* das16cs_pcmcia_resume */
-
-/*====================================================================*/
+ pcmcia_disable_device(link);
+ cur_dev = NULL;
+}
static const struct pcmcia_device_id das16cs_id_table[] = {
PCMCIA_DEVICE_MANF_CARD(0x01c5, 0x0039),
PCMCIA_DEVICE_MANF_CARD(0x01c5, 0x4009),
PCMCIA_DEVICE_NULL
};
-
MODULE_DEVICE_TABLE(pcmcia, das16cs_id_table);
-MODULE_AUTHOR("David A. Schleef <ds@schleef.org>");
-MODULE_DESCRIPTION("Comedi driver for Computer Boards PC-CARD DAS16/16");
-MODULE_LICENSE("GPL");
-struct pcmcia_driver das16cs_driver = {
- .probe = das16cs_pcmcia_attach,
- .remove = das16cs_pcmcia_detach,
- .suspend = das16cs_pcmcia_suspend,
- .resume = das16cs_pcmcia_resume,
- .id_table = das16cs_id_table,
- .owner = THIS_MODULE,
- .name = "cb_das16_cs",
+static struct pcmcia_driver das16cs_driver = {
+ .name = "cb_das16_cs",
+ .owner = THIS_MODULE,
+ .probe = das16cs_pcmcia_attach,
+ .remove = das16cs_pcmcia_detach,
+ .id_table = das16cs_id_table,
};
-static int __init init_das16cs_pcmcia_cs(void)
-{
- pcmcia_register_driver(&das16cs_driver);
- return 0;
-}
-
-static void __exit exit_das16cs_pcmcia_cs(void)
-{
- pr_debug("das16cs_pcmcia_cs: unloading\n");
- pcmcia_unregister_driver(&das16cs_driver);
-}
-
-int __init init_module(void)
+static int __init das16cs_init(void)
{
int ret;
- ret = init_das16cs_pcmcia_cs();
+ ret = comedi_driver_register(&driver_das16cs);
if (ret < 0)
return ret;
- return comedi_driver_register(&driver_das16cs);
-}
-
-void __exit cleanup_module(void)
-{
- exit_das16cs_pcmcia_cs();
- comedi_driver_unregister(&driver_das16cs);
-}
+ ret = pcmcia_register_driver(&das16cs_driver);
+ if (ret < 0) {
+ comedi_driver_unregister(&driver_das16cs);
+ return ret;
+ }
-#else
-static int __init driver_das16cs_init_module(void)
-{
- return comedi_driver_register(&driver_das16cs);
+ return 0;
}
+module_init(das16cs_init);
-static void __exit driver_das16cs_cleanup_module(void)
+static void __exit das16cs_exit(void)
{
+ pcmcia_unregister_driver(&das16cs_driver);
comedi_driver_unregister(&driver_das16cs);
}
+module_exit(das16cs_exit);
-module_init(driver_das16cs_init_module);
-module_exit(driver_das16cs_cleanup_module);
-#endif /* CONFIG_PCMCIA */
+MODULE_AUTHOR("David A. Schleef <ds@schleef.org>");
+MODULE_DESCRIPTION("Comedi driver for Computer Boards PC-CARD DAS16/16");
+MODULE_LICENSE("GPL");
diff --git a/drivers/staging/comedi/drivers/cb_pcidas.c b/drivers/staging/comedi/drivers/cb_pcidas.c
index 7e4ffcfdac62..2b6a637c3499 100644
--- a/drivers/staging/comedi/drivers/cb_pcidas.c
+++ b/drivers/staging/comedi/drivers/cb_pcidas.c
@@ -28,7 +28,8 @@
*/
/*
Driver: cb_pcidas
-Description: MeasurementComputing PCI-DAS series with the AMCC S5933 PCI controller
+Description: MeasurementComputing PCI-DAS series
+ with the AMCC S5933 PCI controller
Author: Ivan Martinez <imr@oersted.dtu.dk>,
Frank Mori Hess <fmhess@users.sourceforge.net>
Updated: 2003-3-11
@@ -57,8 +58,8 @@ range and aref.
AI Triggering:
For start_src == TRIG_EXT, the A/D EXTERNAL TRIGGER IN (pin 45) is used.
For 1602 series, the start_arg is interpreted as follows:
- start_arg == 0 => gated triger (level high)
- start_arg == CR_INVERT => gated triger (level low)
+ start_arg == 0 => gated trigger (level high)
+ start_arg == CR_INVERT => gated trigger (level low)
start_arg == CR_EDGE => Rising edge
start_arg == CR_EDGE | CR_INVERT => Falling edge
For the other boards the trigger will be done on rising edge
@@ -77,92 +78,74 @@ analog triggering on 1602 series
#include "8253.h"
#include "8255.h"
#include "amcc_s5933.h"
-#include "comedi_pci.h"
#include "comedi_fc.h"
-#undef CB_PCIDAS_DEBUG /* disable debugging code */
-/* #define CB_PCIDAS_DEBUG enable debugging code */
-
/* PCI vendor number of ComputerBoards/MeasurementComputing */
#define PCI_VENDOR_ID_CB 0x1307
-#define TIMER_BASE 100 /* 10MHz master clock */
-#define AI_BUFFER_SIZE 1024 /* maximum fifo size of any supported board */
-#define AO_BUFFER_SIZE 1024 /* maximum fifo size of any supported board */
-#define NUM_CHANNELS_8800 8
-#define NUM_CHANNELS_7376 1
-#define NUM_CHANNELS_8402 2
-#define NUM_CHANNELS_DAC08 1
-
-/* PCI-DAS base addresses */
-
-/* indices of base address regions */
-#define S5933_BADRINDEX 0
-#define CONT_STAT_BADRINDEX 1
-#define ADC_FIFO_BADRINDEX 2
-#define PACER_BADRINDEX 3
-#define AO_BADRINDEX 4
-/* sizes of io regions */
-#define CONT_STAT_SIZE 10
-#define ADC_FIFO_SIZE 4
-#define PACER_SIZE 12
-#define AO_SIZE 4
+
+#define TIMER_BASE 100 /* 10MHz master clock */
+#define AI_BUFFER_SIZE 1024 /* max ai fifo size */
+#define AO_BUFFER_SIZE 1024 /* max ao fifo size */
+#define NUM_CHANNELS_8800 8
+#define NUM_CHANNELS_7376 1
+#define NUM_CHANNELS_8402 2
+#define NUM_CHANNELS_DAC08 1
/* Control/Status registers */
-#define INT_ADCFIFO 0 /* INTERRUPT / ADC FIFO register */
-#define INT_EOS 0x1 /* interrupt end of scan */
-#define INT_FHF 0x2 /* interrupt fifo half full */
-#define INT_FNE 0x3 /* interrupt fifo not empty */
-#define INT_MASK 0x3 /* mask of interrupt select bits */
-#define INTE 0x4 /* interrupt enable */
-#define DAHFIE 0x8 /* dac half full interrupt enable */
-#define EOAIE 0x10 /* end of acquisition interrupt enable */
-#define DAHFI 0x20 /* dac half full read status / write interrupt clear */
-#define EOAI 0x40 /* read end of acq. interrupt status / write clear */
-#define INT 0x80 /* read interrupt status / write clear */
-#define EOBI 0x200 /* read end of burst interrupt status */
-#define ADHFI 0x400 /* read half-full interrupt status */
-#define ADNEI 0x800 /* read fifo not empty interrupt latch status */
-#define ADNE 0x1000 /* read, fifo not empty (realtime, not latched) status */
-#define DAEMIE 0x1000 /* write, dac empty interrupt enable */
-#define LADFUL 0x2000 /* read fifo overflow / write clear */
-#define DAEMI 0x4000 /* dac fifo empty interrupt status / write clear */
-
-#define ADCMUX_CONT 2 /* ADC CHANNEL MUX AND CONTROL register */
-#define BEGIN_SCAN(x) ((x) & 0xf)
-#define END_SCAN(x) (((x) & 0xf) << 4)
-#define GAIN_BITS(x) (((x) & 0x3) << 8)
-#define UNIP 0x800 /* Analog front-end unipolar for range */
-#define SE 0x400 /* Inputs in single-ended mode */
-#define PACER_MASK 0x3000 /* pacer source bits */
-#define PACER_INT 0x1000 /* internal pacer */
-#define PACER_EXT_FALL 0x2000 /* external falling edge */
-#define PACER_EXT_RISE 0x3000 /* external rising edge */
-#define EOC 0x4000 /* adc not busy */
-
-#define TRIG_CONTSTAT 4 /* TRIGGER CONTROL/STATUS register */
-#define SW_TRIGGER 0x1 /* software start trigger */
-#define EXT_TRIGGER 0x2 /* external start trigger */
-#define ANALOG_TRIGGER 0x3 /* external analog trigger */
-#define TRIGGER_MASK 0x3 /* mask of bits that determine start trigger */
-#define TGPOL 0x04 /* invert the edge/level of the external trigger (1602 only) */
-#define TGSEL 0x08 /* if set edge triggered, otherwise level trigerred (1602 only) */
-#define TGEN 0x10 /* enable external start trigger */
-#define BURSTE 0x20 /* burst mode enable */
-#define XTRCL 0x80 /* clear external trigger */
-
-#define CALIBRATION_REG 6 /* CALIBRATION register */
-#define SELECT_8800_BIT 0x100 /* select 8800 caldac */
-#define SELECT_TRIMPOT_BIT 0x200 /* select ad7376 trim pot */
-#define SELECT_DAC08_BIT 0x400 /* select dac08 caldac */
+#define INT_ADCFIFO 0 /* INTERRUPT / ADC FIFO register */
+#define INT_EOS 0x1 /* int end of scan */
+#define INT_FHF 0x2 /* int fifo half full */
+#define INT_FNE 0x3 /* int fifo not empty */
+#define INT_MASK 0x3 /* mask of int select bits */
+#define INTE 0x4 /* int enable */
+#define DAHFIE 0x8 /* dac half full int enable */
+#define EOAIE 0x10 /* end of acq. int enable */
+#define DAHFI 0x20 /* dac half full status / clear */
+#define EOAI 0x40 /* end of acq. int status / clear */
+#define INT 0x80 /* int status / clear */
+#define EOBI 0x200 /* end of burst int status */
+#define ADHFI 0x400 /* half-full int status */
+#define ADNEI 0x800 /* fifo not empty int status (latch) */
+#define ADNE 0x1000 /* fifo not empty status (realtime) */
+#define DAEMIE 0x1000 /* dac empty int enable */
+#define LADFUL 0x2000 /* fifo overflow / clear */
+#define DAEMI 0x4000 /* dac fifo empty int status / clear */
+
+#define ADCMUX_CONT 2 /* ADC CHANNEL MUX AND CONTROL reg */
+#define BEGIN_SCAN(x) ((x) & 0xf)
+#define END_SCAN(x) (((x) & 0xf) << 4)
+#define GAIN_BITS(x) (((x) & 0x3) << 8)
+#define UNIP 0x800 /* Analog front-end unipolar mode */
+#define SE 0x400 /* Inputs in single-ended mode */
+#define PACER_MASK 0x3000 /* pacer source bits */
+#define PACER_INT 0x1000 /* int. pacer */
+#define PACER_EXT_FALL 0x2000 /* ext. falling edge */
+#define PACER_EXT_RISE 0x3000 /* ext. rising edge */
+#define EOC 0x4000 /* adc not busy */
+
+#define TRIG_CONTSTAT 4 /* TRIGGER CONTROL/STATUS register */
+#define SW_TRIGGER 0x1 /* software start trigger */
+#define EXT_TRIGGER 0x2 /* ext. start trigger */
+#define ANALOG_TRIGGER 0x3 /* ext. analog trigger */
+#define TRIGGER_MASK 0x3 /* start trigger mask */
+#define TGPOL 0x04 /* invert trigger (1602 only) */
+#define TGSEL 0x08 /* edge/level trigerred (1602 only) */
+#define TGEN 0x10 /* enable external start trigger */
+#define BURSTE 0x20 /* burst mode enable */
+#define XTRCL 0x80 /* clear external trigger */
+
+#define CALIBRATION_REG 6 /* CALIBRATION register */
+#define SELECT_8800_BIT 0x100 /* select 8800 caldac */
+#define SELECT_TRIMPOT_BIT 0x200 /* select ad7376 trim pot */
+#define SELECT_DAC08_BIT 0x400 /* select dac08 caldac */
#define CAL_SRC_BITS(x) (((x) & 0x7) << 11)
-#define CAL_EN_BIT 0x4000 /* read calibration source instead of analog input channel 0 */
-#define SERIAL_DATA_IN_BIT 0x8000 /* serial data stream going to 8800 and 7376 */
+#define CAL_EN_BIT 0x4000 /* calibration source enable */
+#define SERIAL_DATA_IN_BIT 0x8000 /* serial data bit going to caldac */
+
+#define DAC_CSR 0x8 /* dac control and status register */
+#define DACEN 0x02 /* dac enable */
+#define DAC_MODE_UPDATE_BOTH 0x80 /* update both dacs */
-#define DAC_CSR 0x8 /* dac control and status register */
-enum dac_csr_bits {
- DACEN = 0x2, /* dac enable */
- DAC_MODE_UPDATE_BOTH = 0x80, /* update both dacs when dac0 is written */
-};
static inline unsigned int DAC_RANGE(unsigned int channel, unsigned int range)
{
return (range & 0x3) << (8 + 2 * (channel & 0x1));
@@ -174,27 +157,26 @@ static inline unsigned int DAC_RANGE_MASK(unsigned int channel)
};
/* bits for 1602 series only */
-enum dac_csr_bits_1602 {
- DAC_EMPTY = 0x1, /* dac fifo empty, read, write clear */
- DAC_START = 0x4, /* start/arm dac fifo operations */
- DAC_PACER_MASK = 0x18, /* bits that set dac pacer source */
- DAC_PACER_INT = 0x8, /* dac internal pacing */
- DAC_PACER_EXT_FALL = 0x10, /* dac external pacing, falling edge */
- DAC_PACER_EXT_RISE = 0x18, /* dac external pacing, rising edge */
-};
+#define DAC_EMPTY 0x1 /* fifo empty, read, write clear */
+#define DAC_START 0x4 /* start/arm fifo operations */
+#define DAC_PACER_MASK 0x18 /* bits that set pacer source */
+#define DAC_PACER_INT 0x8 /* int. pacing */
+#define DAC_PACER_EXT_FALL 0x10 /* ext. pacing, falling edge */
+#define DAC_PACER_EXT_RISE 0x18 /* ext. pacing, rising edge */
+
static inline unsigned int DAC_CHAN_EN(unsigned int channel)
{
return 1 << (5 + (channel & 0x1)); /* enable channel 0 or 1 */
};
/* analog input fifo */
-#define ADCDATA 0 /* ADC DATA register */
-#define ADCFIFOCLR 2 /* ADC FIFO CLEAR */
+#define ADCDATA 0 /* ADC DATA register */
+#define ADCFIFOCLR 2 /* ADC FIFO CLEAR */
/* pacer, counter, dio registers */
-#define ADC8254 0
-#define DIO_8255 4
-#define DAC8254 8
+#define ADC8254 0
+#define DIO_8255 4
+#define DAC8254 8
/* analog output registers for 100x, 1200 series */
static inline unsigned int DAC_DATA_REG(unsigned int channel)
@@ -203,11 +185,11 @@ static inline unsigned int DAC_DATA_REG(unsigned int channel)
}
/* analog output registers for 1602 series*/
-#define DACDATA 0 /* DAC DATA register */
-#define DACFIFOCLR 2 /* DAC FIFO CLEAR */
+#define DACDATA 0 /* DAC DATA register */
+#define DACFIFOCLR 2 /* DAC FIFO CLEAR */
+
+#define IS_UNIPOLAR 0x4 /* unipolar range mask */
-/* bit in hexadecimal representation of range index that indicates unipolar input range */
-#define IS_UNIPOLAR 0x4
/* analog input ranges for most boards */
static const struct comedi_lrange cb_pcidas_ranges = {
8,
@@ -257,569 +239,175 @@ enum trimpot_model {
struct cb_pcidas_board {
const char *name;
unsigned short device_id;
- int ai_se_chans; /* Inputs in single-ended mode */
- int ai_diff_chans; /* Inputs in differential mode */
+ int ai_nchan; /* Inputs in single-ended mode */
int ai_bits; /* analog input resolution */
int ai_speed; /* fastest conversion period in ns */
int ao_nchan; /* number of analog out channels */
int has_ao_fifo; /* analog output has fifo */
- int ao_scan_speed; /* analog output speed for 1602 series (for a scan, not conversion) */
+ int ao_scan_speed; /* analog output scan speed for 1602 series */
int fifo_size; /* number of samples fifo can hold */
const struct comedi_lrange *ranges;
enum trimpot_model trimpot;
unsigned has_dac08:1;
- unsigned has_ai_trig_gated:1; /* Tells if the AI trigger can be gated */
- unsigned has_ai_trig_invert:1; /* Tells if the AI trigger can be inverted */
+ unsigned is_1602:1;
};
static const struct cb_pcidas_board cb_pcidas_boards[] = {
{
- .name = "pci-das1602/16",
- .device_id = 0x1,
- .ai_se_chans = 16,
- .ai_diff_chans = 8,
- .ai_bits = 16,
- .ai_speed = 5000,
- .ao_nchan = 2,
- .has_ao_fifo = 1,
- .ao_scan_speed = 10000,
- .fifo_size = 512,
- .ranges = &cb_pcidas_ranges,
- .trimpot = AD8402,
- .has_dac08 = 1,
- .has_ai_trig_gated = 1,
- .has_ai_trig_invert = 1,
- },
- {
- .name = "pci-das1200",
- .device_id = 0xF,
- .ai_se_chans = 16,
- .ai_diff_chans = 8,
- .ai_bits = 12,
- .ai_speed = 3200,
- .ao_nchan = 2,
- .has_ao_fifo = 0,
- .fifo_size = 1024,
- .ranges = &cb_pcidas_ranges,
- .trimpot = AD7376,
- .has_dac08 = 0,
- .has_ai_trig_gated = 0,
- .has_ai_trig_invert = 0,
- },
- {
- .name = "pci-das1602/12",
- .device_id = 0x10,
- .ai_se_chans = 16,
- .ai_diff_chans = 8,
- .ai_bits = 12,
- .ai_speed = 3200,
- .ao_nchan = 2,
- .has_ao_fifo = 1,
- .ao_scan_speed = 4000,
- .fifo_size = 1024,
- .ranges = &cb_pcidas_ranges,
- .trimpot = AD7376,
- .has_dac08 = 0,
- .has_ai_trig_gated = 1,
- .has_ai_trig_invert = 1,
- },
- {
- .name = "pci-das1200/jr",
- .device_id = 0x19,
- .ai_se_chans = 16,
- .ai_diff_chans = 8,
- .ai_bits = 12,
- .ai_speed = 3200,
- .ao_nchan = 0,
- .has_ao_fifo = 0,
- .fifo_size = 1024,
- .ranges = &cb_pcidas_ranges,
- .trimpot = AD7376,
- .has_dac08 = 0,
- .has_ai_trig_gated = 0,
- .has_ai_trig_invert = 0,
- },
- {
- .name = "pci-das1602/16/jr",
- .device_id = 0x1C,
- .ai_se_chans = 16,
- .ai_diff_chans = 8,
- .ai_bits = 16,
- .ai_speed = 5000,
- .ao_nchan = 0,
- .has_ao_fifo = 0,
- .fifo_size = 512,
- .ranges = &cb_pcidas_ranges,
- .trimpot = AD8402,
- .has_dac08 = 1,
- .has_ai_trig_gated = 1,
- .has_ai_trig_invert = 1,
- },
- {
- .name = "pci-das1000",
- .device_id = 0x4C,
- .ai_se_chans = 16,
- .ai_diff_chans = 8,
- .ai_bits = 12,
- .ai_speed = 4000,
- .ao_nchan = 0,
- .has_ao_fifo = 0,
- .fifo_size = 1024,
- .ranges = &cb_pcidas_ranges,
- .trimpot = AD7376,
- .has_dac08 = 0,
- .has_ai_trig_gated = 0,
- .has_ai_trig_invert = 0,
- },
- {
- .name = "pci-das1001",
- .device_id = 0x1a,
- .ai_se_chans = 16,
- .ai_diff_chans = 8,
- .ai_bits = 12,
- .ai_speed = 6800,
- .ao_nchan = 2,
- .has_ao_fifo = 0,
- .fifo_size = 1024,
- .ranges = &cb_pcidas_alt_ranges,
- .trimpot = AD7376,
- .has_dac08 = 0,
- .has_ai_trig_gated = 0,
- .has_ai_trig_invert = 0,
- },
- {
- .name = "pci-das1002",
- .device_id = 0x1b,
- .ai_se_chans = 16,
- .ai_diff_chans = 8,
- .ai_bits = 12,
- .ai_speed = 6800,
- .ao_nchan = 2,
- .has_ao_fifo = 0,
- .fifo_size = 1024,
- .ranges = &cb_pcidas_ranges,
- .trimpot = AD7376,
- .has_dac08 = 0,
- .has_ai_trig_gated = 0,
- .has_ai_trig_invert = 0,
- },
-};
-
-static DEFINE_PCI_DEVICE_TABLE(cb_pcidas_pci_table) = {
- { PCI_DEVICE(PCI_VENDOR_ID_CB, 0x0001) },
- { PCI_DEVICE(PCI_VENDOR_ID_CB, 0x000f) },
- { PCI_DEVICE(PCI_VENDOR_ID_CB, 0x0010) },
- { PCI_DEVICE(PCI_VENDOR_ID_CB, 0x0019) },
- { PCI_DEVICE(PCI_VENDOR_ID_CB, 0x001c) },
- { PCI_DEVICE(PCI_VENDOR_ID_CB, 0x004c) },
- { PCI_DEVICE(PCI_VENDOR_ID_CB, 0x001a) },
- { PCI_DEVICE(PCI_VENDOR_ID_CB, 0x001b) },
- { 0 }
+ .name = "pci-das1602/16",
+ .device_id = 0x1,
+ .ai_nchan = 16,
+ .ai_bits = 16,
+ .ai_speed = 5000,
+ .ao_nchan = 2,
+ .has_ao_fifo = 1,
+ .ao_scan_speed = 10000,
+ .fifo_size = 512,
+ .ranges = &cb_pcidas_ranges,
+ .trimpot = AD8402,
+ .has_dac08 = 1,
+ .is_1602 = 1,
+ }, {
+ .name = "pci-das1200",
+ .device_id = 0xF,
+ .ai_nchan = 16,
+ .ai_bits = 12,
+ .ai_speed = 3200,
+ .ao_nchan = 2,
+ .fifo_size = 1024,
+ .ranges = &cb_pcidas_ranges,
+ .trimpot = AD7376,
+ }, {
+ .name = "pci-das1602/12",
+ .device_id = 0x10,
+ .ai_nchan = 16,
+ .ai_bits = 12,
+ .ai_speed = 3200,
+ .ao_nchan = 2,
+ .has_ao_fifo = 1,
+ .ao_scan_speed = 4000,
+ .fifo_size = 1024,
+ .ranges = &cb_pcidas_ranges,
+ .trimpot = AD7376,
+ .is_1602 = 1,
+ }, {
+ .name = "pci-das1200/jr",
+ .device_id = 0x19,
+ .ai_nchan = 16,
+ .ai_bits = 12,
+ .ai_speed = 3200,
+ .fifo_size = 1024,
+ .ranges = &cb_pcidas_ranges,
+ .trimpot = AD7376,
+ }, {
+ .name = "pci-das1602/16/jr",
+ .device_id = 0x1C,
+ .ai_nchan = 16,
+ .ai_bits = 16,
+ .ai_speed = 5000,
+ .fifo_size = 512,
+ .ranges = &cb_pcidas_ranges,
+ .trimpot = AD8402,
+ .has_dac08 = 1,
+ .is_1602 = 1,
+ }, {
+ .name = "pci-das1000",
+ .device_id = 0x4C,
+ .ai_nchan = 16,
+ .ai_bits = 12,
+ .ai_speed = 4000,
+ .fifo_size = 1024,
+ .ranges = &cb_pcidas_ranges,
+ .trimpot = AD7376,
+ }, {
+ .name = "pci-das1001",
+ .device_id = 0x1a,
+ .ai_nchan = 16,
+ .ai_bits = 12,
+ .ai_speed = 6800,
+ .ao_nchan = 2,
+ .fifo_size = 1024,
+ .ranges = &cb_pcidas_alt_ranges,
+ .trimpot = AD7376,
+ }, {
+ .name = "pci-das1002",
+ .device_id = 0x1b,
+ .ai_nchan = 16,
+ .ai_bits = 12,
+ .ai_speed = 6800,
+ .ao_nchan = 2,
+ .fifo_size = 1024,
+ .ranges = &cb_pcidas_ranges,
+ .trimpot = AD7376,
+ },
};
-MODULE_DEVICE_TABLE(pci, cb_pcidas_pci_table);
-
-/*
- * Useful for shorthand access to the particular board structure
- */
-#define thisboard ((const struct cb_pcidas_board *)dev->board_ptr)
-
-/* this structure is for data unique to this hardware driver. If
- several hardware drivers keep similar information in this structure,
- feel free to suggest moving the variable to the struct comedi_device struct. */
struct cb_pcidas_private {
- /* would be useful for a PCI device */
- struct pci_dev *pci_dev;
- /* base addresses */
+ /* base addresses */
unsigned long s5933_config;
unsigned long control_status;
unsigned long adc_fifo;
unsigned long pacer_counter_dio;
unsigned long ao_registers;
- /* divisors of master clock for analog input pacing */
+ /* divisors of master clock for analog input pacing */
unsigned int divisor1;
unsigned int divisor2;
- volatile unsigned int count; /* number of analog input samples remaining */
- volatile unsigned int adc_fifo_bits; /* bits to write to interrupt/adcfifo register */
- volatile unsigned int s5933_intcsr_bits; /* bits to write to amcc s5933 interrupt control/status register */
- volatile unsigned int ao_control_bits; /* bits to write to ao control and status register */
+ /* number of analog input samples remaining */
+ unsigned int count;
+ /* bits to write to registers */
+ unsigned int adc_fifo_bits;
+ unsigned int s5933_intcsr_bits;
+ unsigned int ao_control_bits;
+ /* fifo buffers */
short ai_buffer[AI_BUFFER_SIZE];
short ao_buffer[AO_BUFFER_SIZE];
- /* divisors of master clock for analog output pacing */
+ /* divisors of master clock for analog output pacing */
unsigned int ao_divisor1;
unsigned int ao_divisor2;
- volatile unsigned int ao_count; /* number of analog output samples remaining */
- int ao_value[2]; /* remember what the analog outputs are set to, to allow readback */
- unsigned int caldac_value[NUM_CHANNELS_8800]; /* for readback of caldac */
- unsigned int trimpot_value[NUM_CHANNELS_8402]; /* for readback of trimpot */
+ /* number of analog output samples remaining */
+ unsigned int ao_count;
+ /* cached values for readback */
+ int ao_value[2];
+ unsigned int caldac_value[NUM_CHANNELS_8800];
+ unsigned int trimpot_value[NUM_CHANNELS_8402];
unsigned int dac08_value;
unsigned int calibration_source;
};
-/*
- * most drivers define the following macro to make it easy to
- * access the private structure.
- */
-#define devpriv ((struct cb_pcidas_private *)dev->private)
-
-/*
- * The struct comedi_driver structure tells the Comedi core module
- * which functions to call to configure/deconfigure (attach/detach)
- * the board, and also about the kernel module that contains
- * the device code.
- */
-static int cb_pcidas_attach(struct comedi_device *dev,
- struct comedi_devconfig *it);
-static int cb_pcidas_detach(struct comedi_device *dev);
-static struct comedi_driver driver_cb_pcidas = {
- .driver_name = "cb_pcidas",
- .module = THIS_MODULE,
- .attach = cb_pcidas_attach,
- .detach = cb_pcidas_detach,
-};
-
-static int cb_pcidas_ai_rinsn(struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data);
-static int ai_config_insn(struct comedi_device *dev, struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data);
-static int cb_pcidas_ao_nofifo_winsn(struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_insn *insn,
- unsigned int *data);
-static int cb_pcidas_ao_fifo_winsn(struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_insn *insn,
- unsigned int *data);
-static int cb_pcidas_ao_readback_insn(struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_insn *insn,
- unsigned int *data);
-static int cb_pcidas_ai_cmd(struct comedi_device *dev,
- struct comedi_subdevice *s);
-static int cb_pcidas_ai_cmdtest(struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_cmd *cmd);
-static int cb_pcidas_ao_cmd(struct comedi_device *dev,
- struct comedi_subdevice *s);
-static int cb_pcidas_ao_inttrig(struct comedi_device *dev,
- struct comedi_subdevice *subdev,
- unsigned int trig_num);
-static int cb_pcidas_ao_cmdtest(struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_cmd *cmd);
-static irqreturn_t cb_pcidas_interrupt(int irq, void *d);
-static void handle_ao_interrupt(struct comedi_device *dev, unsigned int status);
-static int cb_pcidas_cancel(struct comedi_device *dev,
- struct comedi_subdevice *s);
-static int cb_pcidas_ao_cancel(struct comedi_device *dev,
- struct comedi_subdevice *s);
-static void cb_pcidas_load_counters(struct comedi_device *dev, unsigned int *ns,
- int round_flags);
-static int eeprom_read_insn(struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data);
-static int caldac_read_insn(struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data);
-static int caldac_write_insn(struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data);
-static int trimpot_read_insn(struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data);
-static int cb_pcidas_trimpot_write(struct comedi_device *dev,
- unsigned int channel, unsigned int value);
-static int trimpot_write_insn(struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data);
-static int dac08_read_insn(struct comedi_device *dev,
- struct comedi_subdevice *s, struct comedi_insn *insn,
- unsigned int *data);
-static int dac08_write(struct comedi_device *dev, unsigned int value);
-static int dac08_write_insn(struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data);
-static int caldac_8800_write(struct comedi_device *dev, unsigned int address,
- uint8_t value);
-static int trimpot_7376_write(struct comedi_device *dev, uint8_t value);
-static int trimpot_8402_write(struct comedi_device *dev, unsigned int channel,
- uint8_t value);
-static int nvram_read(struct comedi_device *dev, unsigned int address,
- uint8_t *data);
-
static inline unsigned int cal_enable_bits(struct comedi_device *dev)
{
- return CAL_EN_BIT | CAL_SRC_BITS(devpriv->calibration_source);
-}
-
-/*
- * Attach is called by the Comedi core to configure the driver
- * for a particular board.
- */
-static int cb_pcidas_attach(struct comedi_device *dev,
- struct comedi_devconfig *it)
-{
- struct comedi_subdevice *s;
- struct pci_dev *pcidev = NULL;
- int index;
- int i;
-
-/*
- * Allocate the private structure area.
- */
- if (alloc_private(dev, sizeof(struct cb_pcidas_private)) < 0)
- return -ENOMEM;
-
-/*
- * Probe the device to determine what device in the series it is.
- */
-
- for_each_pci_dev(pcidev) {
- /* is it not a computer boards card? */
- if (pcidev->vendor != PCI_VENDOR_ID_CB)
- continue;
- /* loop through cards supported by this driver */
- for (index = 0; index < ARRAY_SIZE(cb_pcidas_boards); index++) {
- if (cb_pcidas_boards[index].device_id != pcidev->device)
- continue;
- /* was a particular bus/slot requested? */
- if (it->options[0] || it->options[1]) {
- /* are we on the wrong bus/slot? */
- if (pcidev->bus->number != it->options[0] ||
- PCI_SLOT(pcidev->devfn) != it->options[1]) {
- continue;
- }
- }
- devpriv->pci_dev = pcidev;
- dev->board_ptr = cb_pcidas_boards + index;
- goto found;
- }
- }
-
- dev_err(dev->hw_dev, "No supported ComputerBoards/MeasurementComputing card found on requested position\n");
- return -EIO;
-
-found:
-
- dev_dbg(dev->hw_dev, "Found %s on bus %i, slot %i\n",
- cb_pcidas_boards[index].name, pcidev->bus->number,
- PCI_SLOT(pcidev->devfn));
-
- /*
- * Enable PCI device and reserve I/O ports.
- */
- if (comedi_pci_enable(pcidev, "cb_pcidas")) {
- dev_err(dev->hw_dev, "Failed to enable PCI device and request regions\n");
- return -EIO;
- }
- /*
- * Initialize devpriv->control_status and devpriv->adc_fifo to point to
- * their base address.
- */
- devpriv->s5933_config =
- pci_resource_start(devpriv->pci_dev, S5933_BADRINDEX);
- devpriv->control_status =
- pci_resource_start(devpriv->pci_dev, CONT_STAT_BADRINDEX);
- devpriv->adc_fifo =
- pci_resource_start(devpriv->pci_dev, ADC_FIFO_BADRINDEX);
- devpriv->pacer_counter_dio =
- pci_resource_start(devpriv->pci_dev, PACER_BADRINDEX);
- if (thisboard->ao_nchan) {
- devpriv->ao_registers =
- pci_resource_start(devpriv->pci_dev, AO_BADRINDEX);
- }
- /* disable and clear interrupts on amcc s5933 */
- outl(INTCSR_INBOX_INTR_STATUS,
- devpriv->s5933_config + AMCC_OP_REG_INTCSR);
-
- /* get irq */
- if (request_irq(devpriv->pci_dev->irq, cb_pcidas_interrupt,
- IRQF_SHARED, "cb_pcidas", dev)) {
- dev_dbg(dev->hw_dev, "unable to allocate irq %d\n",
- devpriv->pci_dev->irq);
- return -EINVAL;
- }
- dev->irq = devpriv->pci_dev->irq;
-
- /* Initialize dev->board_name */
- dev->board_name = thisboard->name;
-
-/*
- * Allocate the subdevice structures.
- */
- if (alloc_subdevices(dev, 7) < 0)
- return -ENOMEM;
-
- s = dev->subdevices + 0;
- /* analog input subdevice */
- dev->read_subdev = s;
- s->type = COMEDI_SUBD_AI;
- s->subdev_flags = SDF_READABLE | SDF_GROUND | SDF_DIFF | SDF_CMD_READ;
- /* WARNING: Number of inputs in differential mode is ignored */
- s->n_chan = thisboard->ai_se_chans;
- s->len_chanlist = thisboard->ai_se_chans;
- s->maxdata = (1 << thisboard->ai_bits) - 1;
- s->range_table = thisboard->ranges;
- s->insn_read = cb_pcidas_ai_rinsn;
- s->insn_config = ai_config_insn;
- s->do_cmd = cb_pcidas_ai_cmd;
- s->do_cmdtest = cb_pcidas_ai_cmdtest;
- s->cancel = cb_pcidas_cancel;
-
- /* analog output subdevice */
- s = dev->subdevices + 1;
- if (thisboard->ao_nchan) {
- s->type = COMEDI_SUBD_AO;
- s->subdev_flags = SDF_READABLE | SDF_WRITABLE | SDF_GROUND;
- s->n_chan = thisboard->ao_nchan;
- /* analog out resolution is the same as analog input resolution, so use ai_bits */
- s->maxdata = (1 << thisboard->ai_bits) - 1;
- s->range_table = &cb_pcidas_ao_ranges;
- s->insn_read = cb_pcidas_ao_readback_insn;
- if (thisboard->has_ao_fifo) {
- dev->write_subdev = s;
- s->subdev_flags |= SDF_CMD_WRITE;
- s->insn_write = cb_pcidas_ao_fifo_winsn;
- s->do_cmdtest = cb_pcidas_ao_cmdtest;
- s->do_cmd = cb_pcidas_ao_cmd;
- s->cancel = cb_pcidas_ao_cancel;
- } else {
- s->insn_write = cb_pcidas_ao_nofifo_winsn;
- }
- } else {
- s->type = COMEDI_SUBD_UNUSED;
- }
-
- /* 8255 */
- s = dev->subdevices + 2;
- subdev_8255_init(dev, s, NULL, devpriv->pacer_counter_dio + DIO_8255);
-
- /* serial EEPROM, */
- s = dev->subdevices + 3;
- s->type = COMEDI_SUBD_MEMORY;
- s->subdev_flags = SDF_READABLE | SDF_INTERNAL;
- s->n_chan = 256;
- s->maxdata = 0xff;
- s->insn_read = eeprom_read_insn;
-
- /* 8800 caldac */
- s = dev->subdevices + 4;
- s->type = COMEDI_SUBD_CALIB;
- s->subdev_flags = SDF_READABLE | SDF_WRITABLE | SDF_INTERNAL;
- s->n_chan = NUM_CHANNELS_8800;
- s->maxdata = 0xff;
- s->insn_read = caldac_read_insn;
- s->insn_write = caldac_write_insn;
- for (i = 0; i < s->n_chan; i++)
- caldac_8800_write(dev, i, s->maxdata / 2);
-
- /* trim potentiometer */
- s = dev->subdevices + 5;
- s->type = COMEDI_SUBD_CALIB;
- s->subdev_flags = SDF_READABLE | SDF_WRITABLE | SDF_INTERNAL;
- if (thisboard->trimpot == AD7376) {
- s->n_chan = NUM_CHANNELS_7376;
- s->maxdata = 0x7f;
- } else {
- s->n_chan = NUM_CHANNELS_8402;
- s->maxdata = 0xff;
- }
- s->insn_read = trimpot_read_insn;
- s->insn_write = trimpot_write_insn;
- for (i = 0; i < s->n_chan; i++)
- cb_pcidas_trimpot_write(dev, i, s->maxdata / 2);
-
- /* dac08 caldac */
- s = dev->subdevices + 6;
- if (thisboard->has_dac08) {
- s->type = COMEDI_SUBD_CALIB;
- s->subdev_flags = SDF_READABLE | SDF_WRITABLE | SDF_INTERNAL;
- s->n_chan = NUM_CHANNELS_DAC08;
- s->insn_read = dac08_read_insn;
- s->insn_write = dac08_write_insn;
- s->maxdata = 0xff;
- dac08_write(dev, s->maxdata / 2);
- } else
- s->type = COMEDI_SUBD_UNUSED;
-
- /* make sure mailbox 4 is empty */
- inl(devpriv->s5933_config + AMCC_OP_REG_IMB4);
- /* Set bits to enable incoming mailbox interrupts on amcc s5933. */
- devpriv->s5933_intcsr_bits =
- INTCSR_INBOX_BYTE(3) | INTCSR_INBOX_SELECT(3) |
- INTCSR_INBOX_FULL_INT;
- /* clear and enable interrupt on amcc s5933 */
- outl(devpriv->s5933_intcsr_bits | INTCSR_INBOX_INTR_STATUS,
- devpriv->s5933_config + AMCC_OP_REG_INTCSR);
-
- return 1;
-}
-
-/*
- * cb_pcidas_detach is called to deconfigure a device. It should deallocate
- * resources.
- * This function is also called when _attach() fails, so it should be
- * careful not to release resources that were not necessarily
- * allocated by _attach(). dev->private and dev->subdevices are
- * deallocated automatically by the core.
- */
-static int cb_pcidas_detach(struct comedi_device *dev)
-{
-
- if (devpriv) {
- if (devpriv->s5933_config) {
- /* disable and clear interrupts on amcc s5933 */
- outl(INTCSR_INBOX_INTR_STATUS,
- devpriv->s5933_config + AMCC_OP_REG_INTCSR);
-#ifdef CB_PCIDAS_DEBUG
- dev_dbg(dev->hw_dev, "detaching, incsr is 0x%x\n",
- inl(devpriv->s5933_config + AMCC_OP_REG_INTCSR));
-#endif
- }
- }
- if (dev->irq)
- free_irq(dev->irq, dev);
- if (dev->subdevices)
- subdev_8255_cleanup(dev, dev->subdevices + 2);
- if (devpriv && devpriv->pci_dev) {
- if (devpriv->s5933_config)
- comedi_pci_disable(devpriv->pci_dev);
- pci_dev_put(devpriv->pci_dev);
- }
+ struct cb_pcidas_private *devpriv = dev->private;
- return 0;
+ return CAL_EN_BIT | CAL_SRC_BITS(devpriv->calibration_source);
}
-/*
- * "instructions" read/write data in "one-shot" or "software-triggered"
- * mode.
- */
static int cb_pcidas_ai_rinsn(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
- int n, i;
+ struct cb_pcidas_private *devpriv = dev->private;
+ unsigned int chan = CR_CHAN(insn->chanspec);
+ unsigned int range = CR_RANGE(insn->chanspec);
+ unsigned int aref = CR_AREF(insn->chanspec);
unsigned int bits;
- static const int timeout = 10000;
- int channel;
- /* enable calibration input if appropriate */
+ int n, i;
+
+ /* enable calibration input if appropriate */
if (insn->chanspec & CR_ALT_SOURCE) {
outw(cal_enable_bits(dev),
devpriv->control_status + CALIBRATION_REG);
- channel = 0;
+ chan = 0;
} else {
outw(0, devpriv->control_status + CALIBRATION_REG);
- channel = CR_CHAN(insn->chanspec);
}
- /* set mux limits and gain */
- bits = BEGIN_SCAN(channel) |
- END_SCAN(channel) | GAIN_BITS(CR_RANGE(insn->chanspec));
- /* set unipolar/bipolar */
- if (CR_RANGE(insn->chanspec) & IS_UNIPOLAR)
+
+ /* set mux limits and gain */
+ bits = BEGIN_SCAN(chan) | END_SCAN(chan) | GAIN_BITS(range);
+ /* set unipolar/bipolar */
+ if (range & IS_UNIPOLAR)
bits |= UNIP;
- /* set singleended/differential */
- if (CR_AREF(insn->chanspec) != AREF_DIFF)
+ /* set single-ended/differential */
+ if (aref != AREF_DIFF)
bits |= SE;
outw(bits, devpriv->control_status + ADCMUX_CONT);
@@ -833,11 +421,11 @@ static int cb_pcidas_ai_rinsn(struct comedi_device *dev,
/* wait for conversion to end */
/* return -ETIMEDOUT if there is a timeout */
- for (i = 0; i < timeout; i++) {
+ for (i = 0; i < 10000; i++) {
if (inw(devpriv->control_status + ADCMUX_CONT) & EOC)
break;
}
- if (i == timeout)
+ if (i == 10000)
return -ETIMEDOUT;
/* read data */
@@ -848,37 +436,28 @@ static int cb_pcidas_ai_rinsn(struct comedi_device *dev,
return n;
}
-static int ai_config_calibration_source(struct comedi_device *dev,
- unsigned int *data)
-{
- static const int num_calibration_sources = 8;
- unsigned int source = data[1];
-
- if (source >= num_calibration_sources) {
- dev_err(dev->hw_dev, "invalid calibration source: %i\n",
- source);
- return -EINVAL;
- }
-
- devpriv->calibration_source = source;
-
- return 2;
-}
-
static int ai_config_insn(struct comedi_device *dev, struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
+ struct cb_pcidas_private *devpriv = dev->private;
int id = data[0];
+ unsigned int source = data[1];
switch (id) {
case INSN_CONFIG_ALT_SOURCE:
- return ai_config_calibration_source(dev, data);
+ if (source >= 8) {
+ dev_err(dev->class_dev,
+ "invalid calibration source: %i\n",
+ source);
+ return -EINVAL;
+ }
+ devpriv->calibration_source = source;
break;
default:
return -EINVAL;
break;
}
- return -EINVAL;
+ return insn->n;
}
/* analog output insn for pcidas-1000 and 1200 series */
@@ -887,25 +466,26 @@ static int cb_pcidas_ao_nofifo_winsn(struct comedi_device *dev,
struct comedi_insn *insn,
unsigned int *data)
{
- int channel;
+ struct cb_pcidas_private *devpriv = dev->private;
+ unsigned int chan = CR_CHAN(insn->chanspec);
+ unsigned int range = CR_RANGE(insn->chanspec);
unsigned long flags;
- /* set channel and range */
- channel = CR_CHAN(insn->chanspec);
+ /* set channel and range */
spin_lock_irqsave(&dev->spinlock, flags);
- devpriv->ao_control_bits &=
- ~DAC_MODE_UPDATE_BOTH & ~DAC_RANGE_MASK(channel);
- devpriv->ao_control_bits |=
- DACEN | DAC_RANGE(channel, CR_RANGE(insn->chanspec));
+ devpriv->ao_control_bits &= (~DAC_MODE_UPDATE_BOTH &
+ ~DAC_RANGE_MASK(chan));
+ devpriv->ao_control_bits |= (DACEN | DAC_RANGE(chan, range));
outw(devpriv->ao_control_bits, devpriv->control_status + DAC_CSR);
spin_unlock_irqrestore(&dev->spinlock, flags);
- /* remember value for readback */
- devpriv->ao_value[channel] = data[0];
- /* send data */
- outw(data[0], devpriv->ao_registers + DAC_DATA_REG(channel));
+ /* remember value for readback */
+ devpriv->ao_value[chan] = data[0];
- return 1;
+ /* send data */
+ outw(data[0], devpriv->ao_registers + DAC_DATA_REG(chan));
+
+ return insn->n;
}
/* analog output insn for pcidas-1602 series */
@@ -913,46 +493,84 @@ static int cb_pcidas_ao_fifo_winsn(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
- int channel;
+ struct cb_pcidas_private *devpriv = dev->private;
+ unsigned int chan = CR_CHAN(insn->chanspec);
+ unsigned int range = CR_RANGE(insn->chanspec);
unsigned long flags;
- /* clear dac fifo */
+ /* clear dac fifo */
outw(0, devpriv->ao_registers + DACFIFOCLR);
- /* set channel and range */
- channel = CR_CHAN(insn->chanspec);
+ /* set channel and range */
spin_lock_irqsave(&dev->spinlock, flags);
- devpriv->ao_control_bits &=
- ~DAC_CHAN_EN(0) & ~DAC_CHAN_EN(1) & ~DAC_RANGE_MASK(channel) &
- ~DAC_PACER_MASK;
- devpriv->ao_control_bits |=
- DACEN | DAC_RANGE(channel,
- CR_RANGE(insn->
- chanspec)) | DAC_CHAN_EN(channel) |
- DAC_START;
+ devpriv->ao_control_bits &= (~DAC_CHAN_EN(0) & ~DAC_CHAN_EN(1) &
+ ~DAC_RANGE_MASK(chan) & ~DAC_PACER_MASK);
+ devpriv->ao_control_bits |= (DACEN | DAC_RANGE(chan, range) |
+ DAC_CHAN_EN(chan) | DAC_START);
outw(devpriv->ao_control_bits, devpriv->control_status + DAC_CSR);
spin_unlock_irqrestore(&dev->spinlock, flags);
- /* remember value for readback */
- devpriv->ao_value[channel] = data[0];
- /* send data */
+ /* remember value for readback */
+ devpriv->ao_value[chan] = data[0];
+
+ /* send data */
outw(data[0], devpriv->ao_registers + DACDATA);
- return 1;
+ return insn->n;
}
-/* analog output readback insn */
-/* XXX loses track of analog output value back after an analog ouput command is executed */
static int cb_pcidas_ao_readback_insn(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn,
unsigned int *data)
{
+ struct cb_pcidas_private *devpriv = dev->private;
+
data[0] = devpriv->ao_value[CR_CHAN(insn->chanspec)];
return 1;
}
+static int wait_for_nvram_ready(unsigned long s5933_base_addr)
+{
+ static const int timeout = 1000;
+ unsigned int i;
+
+ for (i = 0; i < timeout; i++) {
+ if ((inb(s5933_base_addr +
+ AMCC_OP_REG_MCSR_NVCMD) & MCSR_NV_BUSY)
+ == 0)
+ return 0;
+ udelay(1);
+ }
+ return -1;
+}
+
+static int nvram_read(struct comedi_device *dev, unsigned int address,
+ uint8_t *data)
+{
+ struct cb_pcidas_private *devpriv = dev->private;
+ unsigned long iobase = devpriv->s5933_config;
+
+ if (wait_for_nvram_ready(iobase) < 0)
+ return -ETIMEDOUT;
+
+ outb(MCSR_NV_ENABLE | MCSR_NV_LOAD_LOW_ADDR,
+ iobase + AMCC_OP_REG_MCSR_NVCMD);
+ outb(address & 0xff, iobase + AMCC_OP_REG_MCSR_NVDATA);
+ outb(MCSR_NV_ENABLE | MCSR_NV_LOAD_HIGH_ADDR,
+ iobase + AMCC_OP_REG_MCSR_NVCMD);
+ outb((address >> 8) & 0xff, iobase + AMCC_OP_REG_MCSR_NVDATA);
+ outb(MCSR_NV_ENABLE | MCSR_NV_READ, iobase + AMCC_OP_REG_MCSR_NVCMD);
+
+ if (wait_for_nvram_ready(iobase) < 0)
+ return -ETIMEDOUT;
+
+ *data = inb(iobase + AMCC_OP_REG_MCSR_NVDATA);
+
+ return 0;
+}
+
static int eeprom_read_insn(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
@@ -969,6 +587,56 @@ static int eeprom_read_insn(struct comedi_device *dev,
return 1;
}
+static void write_calibration_bitstream(struct comedi_device *dev,
+ unsigned int register_bits,
+ unsigned int bitstream,
+ unsigned int bitstream_length)
+{
+ struct cb_pcidas_private *devpriv = dev->private;
+ static const int write_delay = 1;
+ unsigned int bit;
+
+ for (bit = 1 << (bitstream_length - 1); bit; bit >>= 1) {
+ if (bitstream & bit)
+ register_bits |= SERIAL_DATA_IN_BIT;
+ else
+ register_bits &= ~SERIAL_DATA_IN_BIT;
+ udelay(write_delay);
+ outw(register_bits, devpriv->control_status + CALIBRATION_REG);
+ }
+}
+
+static int caldac_8800_write(struct comedi_device *dev, unsigned int address,
+ uint8_t value)
+{
+ struct cb_pcidas_private *devpriv = dev->private;
+ static const int num_caldac_channels = 8;
+ static const int bitstream_length = 11;
+ unsigned int bitstream = ((address & 0x7) << 8) | value;
+ static const int caldac_8800_udelay = 1;
+
+ if (address >= num_caldac_channels) {
+ comedi_error(dev, "illegal caldac channel");
+ return -1;
+ }
+
+ if (value == devpriv->caldac_value[address])
+ return 1;
+
+ devpriv->caldac_value[address] = value;
+
+ write_calibration_bitstream(dev, cal_enable_bits(dev), bitstream,
+ bitstream_length);
+
+ udelay(caldac_8800_udelay);
+ outw(cal_enable_bits(dev) | SELECT_8800_BIT,
+ devpriv->control_status + CALIBRATION_REG);
+ udelay(caldac_8800_udelay);
+ outw(cal_enable_bits(dev), devpriv->control_status + CALIBRATION_REG);
+
+ return 1;
+}
+
static int caldac_write_insn(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
@@ -982,51 +650,112 @@ static int caldac_read_insn(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
+ struct cb_pcidas_private *devpriv = dev->private;
+
data[0] = devpriv->caldac_value[CR_CHAN(insn->chanspec)];
return 1;
}
/* 1602/16 pregain offset */
-static int dac08_write(struct comedi_device *dev, unsigned int value)
+static void dac08_write(struct comedi_device *dev, unsigned int value)
{
- if (devpriv->dac08_value == value)
- return 1;
+ struct cb_pcidas_private *devpriv = dev->private;
+ unsigned long cal_reg;
- devpriv->dac08_value = value;
+ if (devpriv->dac08_value != value) {
+ devpriv->dac08_value = value;
- outw(cal_enable_bits(dev) | (value & 0xff),
- devpriv->control_status + CALIBRATION_REG);
- udelay(1);
- outw(cal_enable_bits(dev) | SELECT_DAC08_BIT | (value & 0xff),
- devpriv->control_status + CALIBRATION_REG);
- udelay(1);
- outw(cal_enable_bits(dev) | (value & 0xff),
- devpriv->control_status + CALIBRATION_REG);
- udelay(1);
+ cal_reg = devpriv->control_status + CALIBRATION_REG;
- return 1;
+ value &= 0xff;
+ value |= cal_enable_bits(dev);
+
+ /* latch the new value into the caldac */
+ outw(value, cal_reg);
+ udelay(1);
+ outw(value | SELECT_DAC08_BIT, cal_reg);
+ udelay(1);
+ outw(value, cal_reg);
+ udelay(1);
+ }
}
static int dac08_write_insn(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
- return dac08_write(dev, data[0]);
+ int i;
+
+ for (i = 0; i < insn->n; i++)
+ dac08_write(dev, data[i]);
+
+ return insn->n;
}
static int dac08_read_insn(struct comedi_device *dev,
struct comedi_subdevice *s, struct comedi_insn *insn,
unsigned int *data)
{
+ struct cb_pcidas_private *devpriv = dev->private;
+
data[0] = devpriv->dac08_value;
return 1;
}
+static int trimpot_7376_write(struct comedi_device *dev, uint8_t value)
+{
+ struct cb_pcidas_private *devpriv = dev->private;
+ static const int bitstream_length = 7;
+ unsigned int bitstream = value & 0x7f;
+ unsigned int register_bits;
+ static const int ad7376_udelay = 1;
+
+ register_bits = cal_enable_bits(dev) | SELECT_TRIMPOT_BIT;
+ udelay(ad7376_udelay);
+ outw(register_bits, devpriv->control_status + CALIBRATION_REG);
+
+ write_calibration_bitstream(dev, register_bits, bitstream,
+ bitstream_length);
+
+ udelay(ad7376_udelay);
+ outw(cal_enable_bits(dev), devpriv->control_status + CALIBRATION_REG);
+
+ return 0;
+}
+
+/* For 1602/16 only
+ * ch 0 : adc gain
+ * ch 1 : adc postgain offset */
+static int trimpot_8402_write(struct comedi_device *dev, unsigned int channel,
+ uint8_t value)
+{
+ struct cb_pcidas_private *devpriv = dev->private;
+ static const int bitstream_length = 10;
+ unsigned int bitstream = ((channel & 0x3) << 8) | (value & 0xff);
+ unsigned int register_bits;
+ static const int ad8402_udelay = 1;
+
+ register_bits = cal_enable_bits(dev) | SELECT_TRIMPOT_BIT;
+ udelay(ad8402_udelay);
+ outw(register_bits, devpriv->control_status + CALIBRATION_REG);
+
+ write_calibration_bitstream(dev, register_bits, bitstream,
+ bitstream_length);
+
+ udelay(ad8402_udelay);
+ outw(cal_enable_bits(dev), devpriv->control_status + CALIBRATION_REG);
+
+ return 0;
+}
+
static int cb_pcidas_trimpot_write(struct comedi_device *dev,
unsigned int channel, unsigned int value)
{
+ const struct cb_pcidas_board *thisboard = comedi_board(dev);
+ struct cb_pcidas_private *devpriv = dev->private;
+
if (devpriv->trimpot_value[channel] == value)
return 1;
@@ -1060,6 +789,7 @@ static int trimpot_read_insn(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
+ struct cb_pcidas_private *devpriv = dev->private;
unsigned int channel = CR_CHAN(insn->chanspec);
data[0] = devpriv->trimpot_value[channel];
@@ -1071,18 +801,13 @@ static int cb_pcidas_ai_cmdtest(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_cmd *cmd)
{
+ const struct cb_pcidas_board *thisboard = comedi_board(dev);
+ struct cb_pcidas_private *devpriv = dev->private;
int err = 0;
int tmp;
int i, gain, start_chan;
- /* cmdtest tests a particular command to see if it is valid.
- * Using the cmdtest ioctl, a user can create a valid cmd
- * and then have it executes by the cmd ioctl.
- *
- * cmdtest returns 1,2,3,4 or 0, depending on which tests
- * the command passes. */
-
- /* step 1: make sure trigger sources are trivially valid */
+ /* step 1: trigger sources are trivially valid */
tmp = cmd->start_src;
cmd->start_src &= TRIG_NOW | TRIG_EXT;
@@ -1112,7 +837,7 @@ static int cb_pcidas_ai_cmdtest(struct comedi_device *dev,
if (err)
return 1;
- /* step 2: make sure trigger sources are unique and mutually compatible */
+ /* step 2: trigger sources are unique and mutually compatible */
if (cmd->start_src != TRIG_NOW && cmd->start_src != TRIG_EXT)
err++;
@@ -1138,7 +863,7 @@ static int cb_pcidas_ai_cmdtest(struct comedi_device *dev,
if (err)
return 2;
- /* step 3: make sure arguments are trivially compatible */
+ /* step 3: arguments are trivially compatible */
switch (cmd->start_src) {
case TRIG_EXT:
@@ -1149,8 +874,7 @@ static int cb_pcidas_ai_cmdtest(struct comedi_device *dev,
~(CR_FLAGS_MASK & ~(CR_EDGE | CR_INVERT));
err++;
}
- if (!thisboard->has_ai_trig_invert &&
- (cmd->start_arg & CR_INVERT)) {
+ if (!thisboard->is_1602 && (cmd->start_arg & CR_INVERT)) {
cmd->start_arg &= (CR_FLAGS_MASK & ~CR_INVERT);
err++;
}
@@ -1244,9 +968,27 @@ static int cb_pcidas_ai_cmdtest(struct comedi_device *dev,
return 0;
}
+static void cb_pcidas_load_counters(struct comedi_device *dev, unsigned int *ns,
+ int rounding_flags)
+{
+ struct cb_pcidas_private *devpriv = dev->private;
+
+ i8253_cascade_ns_to_timer_2div(TIMER_BASE, &(devpriv->divisor1),
+ &(devpriv->divisor2), ns,
+ rounding_flags & TRIG_ROUND_MASK);
+
+ /* Write the values of ctr1 and ctr2 into counters 1 and 2 */
+ i8254_load(devpriv->pacer_counter_dio + ADC8254, 0, 1,
+ devpriv->divisor1, 2);
+ i8254_load(devpriv->pacer_counter_dio + ADC8254, 0, 2,
+ devpriv->divisor2, 2);
+}
+
static int cb_pcidas_ai_cmd(struct comedi_device *dev,
struct comedi_subdevice *s)
{
+ const struct cb_pcidas_board *thisboard = comedi_board(dev);
+ struct cb_pcidas_private *devpriv = dev->private;
struct comedi_async *async = s->async;
struct comedi_cmd *cmd = &async->cmd;
unsigned int bits;
@@ -1276,10 +1018,6 @@ static int cb_pcidas_ai_cmd(struct comedi_device *dev,
bits |= PACER_INT;
outw(bits, devpriv->control_status + ADCMUX_CONT);
-#ifdef CB_PCIDAS_DEBUG
- dev_dbg(dev->hw_dev, "comedi: sent 0x%x to adcmux control\n", bits);
-#endif
-
/* load counters */
if (cmd->convert_src == TRIG_TIMER)
cb_pcidas_load_counters(dev, &cmd->convert_arg,
@@ -1296,17 +1034,18 @@ static int cb_pcidas_ai_cmd(struct comedi_device *dev,
devpriv->adc_fifo_bits |= INTE;
devpriv->adc_fifo_bits &= ~INT_MASK;
if (cmd->flags & TRIG_WAKE_EOS) {
- if (cmd->convert_src == TRIG_NOW && cmd->chanlist_len > 1)
- devpriv->adc_fifo_bits |= INT_EOS; /* interrupt end of burst */
- else
- devpriv->adc_fifo_bits |= INT_FNE; /* interrupt fifo not empty */
+ if (cmd->convert_src == TRIG_NOW && cmd->chanlist_len > 1) {
+ /* interrupt end of burst */
+ devpriv->adc_fifo_bits |= INT_EOS;
+ } else {
+ /* interrupt fifo not empty */
+ devpriv->adc_fifo_bits |= INT_FNE;
+ }
} else {
- devpriv->adc_fifo_bits |= INT_FHF; /* interrupt fifo half full */
+ /* interrupt fifo half full */
+ devpriv->adc_fifo_bits |= INT_FHF;
}
-#ifdef CB_PCIDAS_DEBUG
- dev_dbg(dev->hw_dev, "comedi: adc_fifo_bits are 0x%x\n",
- devpriv->adc_fifo_bits);
-#endif
+
/* enable (and clear) interrupts */
outw(devpriv->adc_fifo_bits | EOAI | INT | LADFUL,
devpriv->control_status + INT_ADCFIFO);
@@ -1318,11 +1057,12 @@ static int cb_pcidas_ai_cmd(struct comedi_device *dev,
bits |= SW_TRIGGER;
else if (cmd->start_src == TRIG_EXT) {
bits |= EXT_TRIGGER | TGEN | XTRCL;
- if (thisboard->has_ai_trig_invert
- && (cmd->start_arg & CR_INVERT))
- bits |= TGPOL;
- if (thisboard->has_ai_trig_gated && (cmd->start_arg & CR_EDGE))
- bits |= TGSEL;
+ if (thisboard->is_1602) {
+ if (cmd->start_arg & CR_INVERT)
+ bits |= TGPOL;
+ if (cmd->start_arg & CR_EDGE)
+ bits |= TGSEL;
+ }
} else {
comedi_error(dev, "bug!");
return -1;
@@ -1330,9 +1070,6 @@ static int cb_pcidas_ai_cmd(struct comedi_device *dev,
if (cmd->convert_src == TRIG_NOW && cmd->chanlist_len > 1)
bits |= BURSTE;
outw(bits, devpriv->control_status + TRIG_CONTSTAT);
-#ifdef CB_PCIDAS_DEBUG
- dev_dbg(dev->hw_dev, "comedi: sent 0x%x to trig control\n", bits);
-#endif
return 0;
}
@@ -1341,17 +1078,12 @@ static int cb_pcidas_ao_cmdtest(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_cmd *cmd)
{
+ const struct cb_pcidas_board *thisboard = comedi_board(dev);
+ struct cb_pcidas_private *devpriv = dev->private;
int err = 0;
int tmp;
- /* cmdtest tests a particular command to see if it is valid.
- * Using the cmdtest ioctl, a user can create a valid cmd
- * and then have it executes by the cmd ioctl.
- *
- * cmdtest returns 1,2,3,4 or 0, depending on which tests
- * the command passes. */
-
- /* step 1: make sure trigger sources are trivially valid */
+ /* step 1: trigger sources are trivially valid */
tmp = cmd->start_src;
cmd->start_src &= TRIG_INT;
@@ -1381,7 +1113,7 @@ static int cb_pcidas_ao_cmdtest(struct comedi_device *dev,
if (err)
return 1;
- /* step 2: make sure trigger sources are unique and mutually compatible */
+ /* step 2: trigger sources are unique and mutually compatible */
if (cmd->scan_begin_src != TRIG_TIMER &&
cmd->scan_begin_src != TRIG_EXT)
@@ -1392,7 +1124,7 @@ static int cb_pcidas_ao_cmdtest(struct comedi_device *dev,
if (err)
return 2;
- /* step 3: make sure arguments are trivially compatible */
+ /* step 3: arguments are trivially compatible */
if (cmd->start_arg != 0) {
cmd->start_arg = 0;
@@ -1453,9 +1185,77 @@ static int cb_pcidas_ao_cmdtest(struct comedi_device *dev,
return 0;
}
+/* cancel analog input command */
+static int cb_pcidas_cancel(struct comedi_device *dev,
+ struct comedi_subdevice *s)
+{
+ struct cb_pcidas_private *devpriv = dev->private;
+ unsigned long flags;
+
+ spin_lock_irqsave(&dev->spinlock, flags);
+ /* disable interrupts */
+ devpriv->adc_fifo_bits &= ~INTE & ~EOAIE;
+ outw(devpriv->adc_fifo_bits, devpriv->control_status + INT_ADCFIFO);
+ spin_unlock_irqrestore(&dev->spinlock, flags);
+
+ /* disable start trigger source and burst mode */
+ outw(0, devpriv->control_status + TRIG_CONTSTAT);
+ /* software pacer source */
+ outw(0, devpriv->control_status + ADCMUX_CONT);
+
+ return 0;
+}
+
+static int cb_pcidas_ao_inttrig(struct comedi_device *dev,
+ struct comedi_subdevice *s,
+ unsigned int trig_num)
+{
+ const struct cb_pcidas_board *thisboard = comedi_board(dev);
+ struct cb_pcidas_private *devpriv = dev->private;
+ unsigned int num_bytes, num_points = thisboard->fifo_size;
+ struct comedi_async *async = s->async;
+ struct comedi_cmd *cmd = &s->async->cmd;
+ unsigned long flags;
+
+ if (trig_num != 0)
+ return -EINVAL;
+
+ /* load up fifo */
+ if (cmd->stop_src == TRIG_COUNT && devpriv->ao_count < num_points)
+ num_points = devpriv->ao_count;
+
+ num_bytes = cfc_read_array_from_buffer(s, devpriv->ao_buffer,
+ num_points * sizeof(short));
+ num_points = num_bytes / sizeof(short);
+
+ if (cmd->stop_src == TRIG_COUNT)
+ devpriv->ao_count -= num_points;
+ /* write data to board's fifo */
+ outsw(devpriv->ao_registers + DACDATA, devpriv->ao_buffer, num_bytes);
+
+ /* enable dac half-full and empty interrupts */
+ spin_lock_irqsave(&dev->spinlock, flags);
+ devpriv->adc_fifo_bits |= DAEMIE | DAHFIE;
+
+ /* enable and clear interrupts */
+ outw(devpriv->adc_fifo_bits | DAEMI | DAHFI,
+ devpriv->control_status + INT_ADCFIFO);
+
+ /* start dac */
+ devpriv->ao_control_bits |= DAC_START | DACEN | DAC_EMPTY;
+ outw(devpriv->ao_control_bits, devpriv->control_status + DAC_CSR);
+
+ spin_unlock_irqrestore(&dev->spinlock, flags);
+
+ async->inttrig = NULL;
+
+ return 0;
+}
+
static int cb_pcidas_ao_cmd(struct comedi_device *dev,
struct comedi_subdevice *s)
{
+ struct cb_pcidas_private *devpriv = dev->private;
struct comedi_async *async = s->async;
struct comedi_cmd *cmd = &async->cmd;
unsigned int i;
@@ -1519,59 +1319,88 @@ static int cb_pcidas_ao_cmd(struct comedi_device *dev,
return 0;
}
-static int cb_pcidas_ao_inttrig(struct comedi_device *dev,
- struct comedi_subdevice *s,
- unsigned int trig_num)
+/* cancel analog output command */
+static int cb_pcidas_ao_cancel(struct comedi_device *dev,
+ struct comedi_subdevice *s)
{
- unsigned int num_bytes, num_points = thisboard->fifo_size;
- struct comedi_async *async = s->async;
- struct comedi_cmd *cmd = &s->async->cmd;
+ struct cb_pcidas_private *devpriv = dev->private;
unsigned long flags;
- if (trig_num != 0)
- return -EINVAL;
+ spin_lock_irqsave(&dev->spinlock, flags);
+ /* disable interrupts */
+ devpriv->adc_fifo_bits &= ~DAHFIE & ~DAEMIE;
+ outw(devpriv->adc_fifo_bits, devpriv->control_status + INT_ADCFIFO);
- /* load up fifo */
- if (cmd->stop_src == TRIG_COUNT && devpriv->ao_count < num_points)
- num_points = devpriv->ao_count;
+ /* disable output */
+ devpriv->ao_control_bits &= ~DACEN & ~DAC_PACER_MASK;
+ outw(devpriv->ao_control_bits, devpriv->control_status + DAC_CSR);
+ spin_unlock_irqrestore(&dev->spinlock, flags);
- num_bytes = cfc_read_array_from_buffer(s, devpriv->ao_buffer,
- num_points * sizeof(short));
- num_points = num_bytes / sizeof(short);
+ return 0;
+}
- if (cmd->stop_src == TRIG_COUNT)
- devpriv->ao_count -= num_points;
- /* write data to board's fifo */
- outsw(devpriv->ao_registers + DACDATA, devpriv->ao_buffer, num_bytes);
+static void handle_ao_interrupt(struct comedi_device *dev, unsigned int status)
+{
+ const struct cb_pcidas_board *thisboard = comedi_board(dev);
+ struct cb_pcidas_private *devpriv = dev->private;
+ struct comedi_subdevice *s = dev->write_subdev;
+ struct comedi_async *async = s->async;
+ struct comedi_cmd *cmd = &async->cmd;
+ unsigned int half_fifo = thisboard->fifo_size / 2;
+ unsigned int num_points;
+ unsigned long flags;
- /* enable dac half-full and empty interrupts */
- spin_lock_irqsave(&dev->spinlock, flags);
- devpriv->adc_fifo_bits |= DAEMIE | DAHFIE;
-#ifdef CB_PCIDAS_DEBUG
- dev_dbg(dev->hw_dev, "comedi: adc_fifo_bits are 0x%x\n",
- devpriv->adc_fifo_bits);
-#endif
- /* enable and clear interrupts */
- outw(devpriv->adc_fifo_bits | DAEMI | DAHFI,
- devpriv->control_status + INT_ADCFIFO);
+ async->events = 0;
- /* start dac */
- devpriv->ao_control_bits |= DAC_START | DACEN | DAC_EMPTY;
- outw(devpriv->ao_control_bits, devpriv->control_status + DAC_CSR);
-#ifdef CB_PCIDAS_DEBUG
- dev_dbg(dev->hw_dev, "comedi: sent 0x%x to dac control\n",
- devpriv->ao_control_bits);
-#endif
- spin_unlock_irqrestore(&dev->spinlock, flags);
+ if (status & DAEMI) {
+ /* clear dac empty interrupt latch */
+ spin_lock_irqsave(&dev->spinlock, flags);
+ outw(devpriv->adc_fifo_bits | DAEMI,
+ devpriv->control_status + INT_ADCFIFO);
+ spin_unlock_irqrestore(&dev->spinlock, flags);
+ if (inw(devpriv->ao_registers + DAC_CSR) & DAC_EMPTY) {
+ if (cmd->stop_src == TRIG_NONE ||
+ (cmd->stop_src == TRIG_COUNT
+ && devpriv->ao_count)) {
+ comedi_error(dev, "dac fifo underflow");
+ cb_pcidas_ao_cancel(dev, s);
+ async->events |= COMEDI_CB_ERROR;
+ }
+ async->events |= COMEDI_CB_EOA;
+ }
+ } else if (status & DAHFI) {
+ unsigned int num_bytes;
- async->inttrig = NULL;
+ /* figure out how many points we are writing to fifo */
+ num_points = half_fifo;
+ if (cmd->stop_src == TRIG_COUNT &&
+ devpriv->ao_count < num_points)
+ num_points = devpriv->ao_count;
+ num_bytes =
+ cfc_read_array_from_buffer(s, devpriv->ao_buffer,
+ num_points * sizeof(short));
+ num_points = num_bytes / sizeof(short);
- return 0;
+ if (async->cmd.stop_src == TRIG_COUNT)
+ devpriv->ao_count -= num_points;
+ /* write data to board's fifo */
+ outsw(devpriv->ao_registers + DACDATA, devpriv->ao_buffer,
+ num_points);
+ /* clear half-full interrupt latch */
+ spin_lock_irqsave(&dev->spinlock, flags);
+ outw(devpriv->adc_fifo_bits | DAHFI,
+ devpriv->control_status + INT_ADCFIFO);
+ spin_unlock_irqrestore(&dev->spinlock, flags);
+ }
+
+ comedi_event(dev, s);
}
static irqreturn_t cb_pcidas_interrupt(int irq, void *d)
{
struct comedi_device *dev = (struct comedi_device *)d;
+ const struct cb_pcidas_board *thisboard = comedi_board(dev);
+ struct cb_pcidas_private *devpriv = dev->private;
struct comedi_subdevice *s = dev->read_subdev;
struct comedi_async *async;
int status, s5933_status;
@@ -1587,11 +1416,6 @@ static irqreturn_t cb_pcidas_interrupt(int irq, void *d)
async->events = 0;
s5933_status = inl(devpriv->s5933_config + AMCC_OP_REG_INTCSR);
-#ifdef CB_PCIDAS_DEBUG
- dev_dbg(dev->hw_dev, "intcsr 0x%x\n", s5933_status);
- dev_dbg(dev->hw_dev, "mbef 0x%x\n",
- inl(devpriv->s5933_config + AMCC_OP_REG_MBEF));
-#endif
if ((INTCSR_INTR_ASSERTED & s5933_status) == 0)
return IRQ_NONE;
@@ -1603,10 +1427,6 @@ static irqreturn_t cb_pcidas_interrupt(int irq, void *d)
devpriv->s5933_config + AMCC_OP_REG_INTCSR);
status = inw(devpriv->control_status + INT_ADCFIFO);
-#ifdef CB_PCIDAS_DEBUG
- if ((status & (INT | EOAI | LADFUL | DAHFI | DAEMI)) == 0)
- comedi_error(dev, "spurious interrupt");
-#endif
/* check for analog output interrupt */
if (status & (DAHFI | DAEMI))
@@ -1642,7 +1462,9 @@ static irqreturn_t cb_pcidas_interrupt(int irq, void *d)
INT_ADCFIFO)) == 0)
break;
cfc_write_to_buffer(s, inw(devpriv->adc_fifo));
- if (async->cmd.stop_src == TRIG_COUNT && --devpriv->count == 0) { /* end of acquisition */
+ if (async->cmd.stop_src == TRIG_COUNT &&
+ --devpriv->count == 0) {
+ /* end of acquisition */
cb_pcidas_cancel(dev, s);
async->events |= COMEDI_CB_EOA;
break;
@@ -1679,286 +1501,266 @@ static irqreturn_t cb_pcidas_interrupt(int irq, void *d)
return IRQ_HANDLED;
}
-static void handle_ao_interrupt(struct comedi_device *dev, unsigned int status)
+static struct pci_dev *cb_pcidas_find_pci_device(struct comedi_device *dev,
+ struct comedi_devconfig *it)
{
- struct comedi_subdevice *s = dev->write_subdev;
- struct comedi_async *async = s->async;
- struct comedi_cmd *cmd = &async->cmd;
- unsigned int half_fifo = thisboard->fifo_size / 2;
- unsigned int num_points;
- unsigned long flags;
-
- async->events = 0;
+ const struct cb_pcidas_board *thisboard;
+ struct pci_dev *pcidev = NULL;
+ int bus = it->options[0];
+ int slot = it->options[1];
+ int i;
- if (status & DAEMI) {
- /* clear dac empty interrupt latch */
- spin_lock_irqsave(&dev->spinlock, flags);
- outw(devpriv->adc_fifo_bits | DAEMI,
- devpriv->control_status + INT_ADCFIFO);
- spin_unlock_irqrestore(&dev->spinlock, flags);
- if (inw(devpriv->ao_registers + DAC_CSR) & DAC_EMPTY) {
- if (cmd->stop_src == TRIG_NONE ||
- (cmd->stop_src == TRIG_COUNT
- && devpriv->ao_count)) {
- comedi_error(dev, "dac fifo underflow");
- cb_pcidas_ao_cancel(dev, s);
- async->events |= COMEDI_CB_ERROR;
+ for_each_pci_dev(pcidev) {
+ /* is it not a computer boards card? */
+ if (pcidev->vendor != PCI_VENDOR_ID_CB)
+ continue;
+ /* loop through cards supported by this driver */
+ for (i = 0; i < ARRAY_SIZE(cb_pcidas_boards); i++) {
+ thisboard = &cb_pcidas_boards[i];
+ if (thisboard->device_id != pcidev->device)
+ continue;
+ /* was a particular bus/slot requested? */
+ if (bus || slot) {
+ /* are we on the wrong bus/slot? */
+ if (pcidev->bus->number != bus ||
+ PCI_SLOT(pcidev->devfn) != slot) {
+ continue;
+ }
}
- async->events |= COMEDI_CB_EOA;
+ dev_dbg(dev->class_dev,
+ "Found %s on bus %i, slot %i\n",
+ thisboard->name,
+ pcidev->bus->number, PCI_SLOT(pcidev->devfn));
+ dev->board_ptr = thisboard;
+ return pcidev;
}
- } else if (status & DAHFI) {
- unsigned int num_bytes;
-
- /* figure out how many points we are writing to fifo */
- num_points = half_fifo;
- if (cmd->stop_src == TRIG_COUNT &&
- devpriv->ao_count < num_points)
- num_points = devpriv->ao_count;
- num_bytes =
- cfc_read_array_from_buffer(s, devpriv->ao_buffer,
- num_points * sizeof(short));
- num_points = num_bytes / sizeof(short);
-
- if (async->cmd.stop_src == TRIG_COUNT)
- devpriv->ao_count -= num_points;
- /* write data to board's fifo */
- outsw(devpriv->ao_registers + DACDATA, devpriv->ao_buffer,
- num_points);
- /* clear half-full interrupt latch */
- spin_lock_irqsave(&dev->spinlock, flags);
- outw(devpriv->adc_fifo_bits | DAHFI,
- devpriv->control_status + INT_ADCFIFO);
- spin_unlock_irqrestore(&dev->spinlock, flags);
}
-
- comedi_event(dev, s);
+ dev_err(dev->class_dev, "No supported card found\n");
+ return NULL;
}
-/* cancel analog input command */
-static int cb_pcidas_cancel(struct comedi_device *dev,
- struct comedi_subdevice *s)
+static int cb_pcidas_attach(struct comedi_device *dev,
+ struct comedi_devconfig *it)
{
- unsigned long flags;
+ const struct cb_pcidas_board *thisboard;
+ struct cb_pcidas_private *devpriv;
+ struct pci_dev *pcidev;
+ struct comedi_subdevice *s;
+ int i;
+ int ret;
- spin_lock_irqsave(&dev->spinlock, flags);
- /* disable interrupts */
- devpriv->adc_fifo_bits &= ~INTE & ~EOAIE;
- outw(devpriv->adc_fifo_bits, devpriv->control_status + INT_ADCFIFO);
- spin_unlock_irqrestore(&dev->spinlock, flags);
+ if (alloc_private(dev, sizeof(struct cb_pcidas_private)) < 0)
+ return -ENOMEM;
+ devpriv = dev->private;
- /* disable start trigger source and burst mode */
- outw(0, devpriv->control_status + TRIG_CONTSTAT);
- /* software pacer source */
- outw(0, devpriv->control_status + ADCMUX_CONT);
+ pcidev = cb_pcidas_find_pci_device(dev, it);
+ if (!pcidev)
+ return -EIO;
+ comedi_set_hw_dev(dev, &pcidev->dev);
+ thisboard = comedi_board(dev);
- return 0;
-}
+ if (comedi_pci_enable(pcidev, dev->driver->driver_name)) {
+ dev_err(dev->class_dev,
+ "Failed to enable PCI device and request regions\n");
+ return -EIO;
+ }
-/* cancel analog output command */
-static int cb_pcidas_ao_cancel(struct comedi_device *dev,
- struct comedi_subdevice *s)
-{
- unsigned long flags;
+ devpriv->s5933_config = pci_resource_start(pcidev, 0);
+ devpriv->control_status = pci_resource_start(pcidev, 1);
+ devpriv->adc_fifo = pci_resource_start(pcidev, 2);
+ devpriv->pacer_counter_dio = pci_resource_start(pcidev, 3);
+ if (thisboard->ao_nchan)
+ devpriv->ao_registers = pci_resource_start(pcidev, 4);
- spin_lock_irqsave(&dev->spinlock, flags);
- /* disable interrupts */
- devpriv->adc_fifo_bits &= ~DAHFIE & ~DAEMIE;
- outw(devpriv->adc_fifo_bits, devpriv->control_status + INT_ADCFIFO);
-
- /* disable output */
- devpriv->ao_control_bits &= ~DACEN & ~DAC_PACER_MASK;
- outw(devpriv->ao_control_bits, devpriv->control_status + DAC_CSR);
- spin_unlock_irqrestore(&dev->spinlock, flags);
+ /* disable and clear interrupts on amcc s5933 */
+ outl(INTCSR_INBOX_INTR_STATUS,
+ devpriv->s5933_config + AMCC_OP_REG_INTCSR);
- return 0;
-}
+ if (request_irq(pcidev->irq, cb_pcidas_interrupt,
+ IRQF_SHARED, dev->driver->driver_name, dev)) {
+ dev_dbg(dev->class_dev, "unable to allocate irq %d\n",
+ pcidev->irq);
+ return -EINVAL;
+ }
+ dev->irq = pcidev->irq;
-static void cb_pcidas_load_counters(struct comedi_device *dev, unsigned int *ns,
- int rounding_flags)
-{
- i8253_cascade_ns_to_timer_2div(TIMER_BASE, &(devpriv->divisor1),
- &(devpriv->divisor2), ns,
- rounding_flags & TRIG_ROUND_MASK);
+ dev->board_name = thisboard->name;
- /* Write the values of ctr1 and ctr2 into counters 1 and 2 */
- i8254_load(devpriv->pacer_counter_dio + ADC8254, 0, 1,
- devpriv->divisor1, 2);
- i8254_load(devpriv->pacer_counter_dio + ADC8254, 0, 2,
- devpriv->divisor2, 2);
-}
+ ret = comedi_alloc_subdevices(dev, 7);
+ if (ret)
+ return ret;
-static void write_calibration_bitstream(struct comedi_device *dev,
- unsigned int register_bits,
- unsigned int bitstream,
- unsigned int bitstream_length)
-{
- static const int write_delay = 1;
- unsigned int bit;
+ s = dev->subdevices + 0;
+ /* analog input subdevice */
+ dev->read_subdev = s;
+ s->type = COMEDI_SUBD_AI;
+ s->subdev_flags = SDF_READABLE | SDF_GROUND | SDF_DIFF | SDF_CMD_READ;
+ /* WARNING: Number of inputs in differential mode is ignored */
+ s->n_chan = thisboard->ai_nchan;
+ s->len_chanlist = thisboard->ai_nchan;
+ s->maxdata = (1 << thisboard->ai_bits) - 1;
+ s->range_table = thisboard->ranges;
+ s->insn_read = cb_pcidas_ai_rinsn;
+ s->insn_config = ai_config_insn;
+ s->do_cmd = cb_pcidas_ai_cmd;
+ s->do_cmdtest = cb_pcidas_ai_cmdtest;
+ s->cancel = cb_pcidas_cancel;
- for (bit = 1 << (bitstream_length - 1); bit; bit >>= 1) {
- if (bitstream & bit)
- register_bits |= SERIAL_DATA_IN_BIT;
- else
- register_bits &= ~SERIAL_DATA_IN_BIT;
- udelay(write_delay);
- outw(register_bits, devpriv->control_status + CALIBRATION_REG);
+ /* analog output subdevice */
+ s = dev->subdevices + 1;
+ if (thisboard->ao_nchan) {
+ s->type = COMEDI_SUBD_AO;
+ s->subdev_flags = SDF_READABLE | SDF_WRITABLE | SDF_GROUND;
+ s->n_chan = thisboard->ao_nchan;
+ /*
+ * analog out resolution is the same as
+ * analog input resolution, so use ai_bits
+ */
+ s->maxdata = (1 << thisboard->ai_bits) - 1;
+ s->range_table = &cb_pcidas_ao_ranges;
+ s->insn_read = cb_pcidas_ao_readback_insn;
+ if (thisboard->has_ao_fifo) {
+ dev->write_subdev = s;
+ s->subdev_flags |= SDF_CMD_WRITE;
+ s->insn_write = cb_pcidas_ao_fifo_winsn;
+ s->do_cmdtest = cb_pcidas_ao_cmdtest;
+ s->do_cmd = cb_pcidas_ao_cmd;
+ s->cancel = cb_pcidas_ao_cancel;
+ } else {
+ s->insn_write = cb_pcidas_ao_nofifo_winsn;
+ }
+ } else {
+ s->type = COMEDI_SUBD_UNUSED;
}
-}
-static int caldac_8800_write(struct comedi_device *dev, unsigned int address,
- uint8_t value)
-{
- static const int num_caldac_channels = 8;
- static const int bitstream_length = 11;
- unsigned int bitstream = ((address & 0x7) << 8) | value;
- static const int caldac_8800_udelay = 1;
+ /* 8255 */
+ s = dev->subdevices + 2;
+ ret = subdev_8255_init(dev, s, NULL,
+ devpriv->pacer_counter_dio + DIO_8255);
+ if (ret)
+ return ret;
- if (address >= num_caldac_channels) {
- comedi_error(dev, "illegal caldac channel");
- return -1;
- }
+ /* serial EEPROM, */
+ s = dev->subdevices + 3;
+ s->type = COMEDI_SUBD_MEMORY;
+ s->subdev_flags = SDF_READABLE | SDF_INTERNAL;
+ s->n_chan = 256;
+ s->maxdata = 0xff;
+ s->insn_read = eeprom_read_insn;
- if (value == devpriv->caldac_value[address])
- return 1;
+ /* 8800 caldac */
+ s = dev->subdevices + 4;
+ s->type = COMEDI_SUBD_CALIB;
+ s->subdev_flags = SDF_READABLE | SDF_WRITABLE | SDF_INTERNAL;
+ s->n_chan = NUM_CHANNELS_8800;
+ s->maxdata = 0xff;
+ s->insn_read = caldac_read_insn;
+ s->insn_write = caldac_write_insn;
+ for (i = 0; i < s->n_chan; i++)
+ caldac_8800_write(dev, i, s->maxdata / 2);
- devpriv->caldac_value[address] = value;
+ /* trim potentiometer */
+ s = dev->subdevices + 5;
+ s->type = COMEDI_SUBD_CALIB;
+ s->subdev_flags = SDF_READABLE | SDF_WRITABLE | SDF_INTERNAL;
+ if (thisboard->trimpot == AD7376) {
+ s->n_chan = NUM_CHANNELS_7376;
+ s->maxdata = 0x7f;
+ } else {
+ s->n_chan = NUM_CHANNELS_8402;
+ s->maxdata = 0xff;
+ }
+ s->insn_read = trimpot_read_insn;
+ s->insn_write = trimpot_write_insn;
+ for (i = 0; i < s->n_chan; i++)
+ cb_pcidas_trimpot_write(dev, i, s->maxdata / 2);
- write_calibration_bitstream(dev, cal_enable_bits(dev), bitstream,
- bitstream_length);
+ /* dac08 caldac */
+ s = dev->subdevices + 6;
+ if (thisboard->has_dac08) {
+ s->type = COMEDI_SUBD_CALIB;
+ s->subdev_flags = SDF_READABLE | SDF_WRITABLE | SDF_INTERNAL;
+ s->n_chan = NUM_CHANNELS_DAC08;
+ s->insn_read = dac08_read_insn;
+ s->insn_write = dac08_write_insn;
+ s->maxdata = 0xff;
+ dac08_write(dev, s->maxdata / 2);
+ } else
+ s->type = COMEDI_SUBD_UNUSED;
- udelay(caldac_8800_udelay);
- outw(cal_enable_bits(dev) | SELECT_8800_BIT,
- devpriv->control_status + CALIBRATION_REG);
- udelay(caldac_8800_udelay);
- outw(cal_enable_bits(dev), devpriv->control_status + CALIBRATION_REG);
+ /* make sure mailbox 4 is empty */
+ inl(devpriv->s5933_config + AMCC_OP_REG_IMB4);
+ /* Set bits to enable incoming mailbox interrupts on amcc s5933. */
+ devpriv->s5933_intcsr_bits =
+ INTCSR_INBOX_BYTE(3) | INTCSR_INBOX_SELECT(3) |
+ INTCSR_INBOX_FULL_INT;
+ /* clear and enable interrupt on amcc s5933 */
+ outl(devpriv->s5933_intcsr_bits | INTCSR_INBOX_INTR_STATUS,
+ devpriv->s5933_config + AMCC_OP_REG_INTCSR);
return 1;
}
-static int trimpot_7376_write(struct comedi_device *dev, uint8_t value)
+static void cb_pcidas_detach(struct comedi_device *dev)
{
- static const int bitstream_length = 7;
- unsigned int bitstream = value & 0x7f;
- unsigned int register_bits;
- static const int ad7376_udelay = 1;
-
- register_bits = cal_enable_bits(dev) | SELECT_TRIMPOT_BIT;
- udelay(ad7376_udelay);
- outw(register_bits, devpriv->control_status + CALIBRATION_REG);
-
- write_calibration_bitstream(dev, register_bits, bitstream,
- bitstream_length);
-
- udelay(ad7376_udelay);
- outw(cal_enable_bits(dev), devpriv->control_status + CALIBRATION_REG);
-
- return 0;
-}
+ struct cb_pcidas_private *devpriv = dev->private;
+ struct pci_dev *pcidev = comedi_to_pci_dev(dev);
-/* For 1602/16 only
- * ch 0 : adc gain
- * ch 1 : adc postgain offset */
-static int trimpot_8402_write(struct comedi_device *dev, unsigned int channel,
- uint8_t value)
-{
- static const int bitstream_length = 10;
- unsigned int bitstream = ((channel & 0x3) << 8) | (value & 0xff);
- unsigned int register_bits;
- static const int ad8402_udelay = 1;
-
- register_bits = cal_enable_bits(dev) | SELECT_TRIMPOT_BIT;
- udelay(ad8402_udelay);
- outw(register_bits, devpriv->control_status + CALIBRATION_REG);
-
- write_calibration_bitstream(dev, register_bits, bitstream,
- bitstream_length);
-
- udelay(ad8402_udelay);
- outw(cal_enable_bits(dev), devpriv->control_status + CALIBRATION_REG);
-
- return 0;
-}
-
-static int wait_for_nvram_ready(unsigned long s5933_base_addr)
-{
- static const int timeout = 1000;
- unsigned int i;
-
- for (i = 0; i < timeout; i++) {
- if ((inb(s5933_base_addr +
- AMCC_OP_REG_MCSR_NVCMD) & MCSR_NV_BUSY)
- == 0)
- return 0;
- udelay(1);
+ if (devpriv) {
+ if (devpriv->s5933_config) {
+ outl(INTCSR_INBOX_INTR_STATUS,
+ devpriv->s5933_config + AMCC_OP_REG_INTCSR);
+ }
+ }
+ if (dev->irq)
+ free_irq(dev->irq, dev);
+ if (dev->subdevices)
+ subdev_8255_cleanup(dev, dev->subdevices + 2);
+ if (pcidev) {
+ if (devpriv->s5933_config)
+ comedi_pci_disable(pcidev);
+ pci_dev_put(pcidev);
}
- return -1;
}
-static int nvram_read(struct comedi_device *dev, unsigned int address,
- uint8_t *data)
-{
- unsigned long iobase = devpriv->s5933_config;
-
- if (wait_for_nvram_ready(iobase) < 0)
- return -ETIMEDOUT;
-
- outb(MCSR_NV_ENABLE | MCSR_NV_LOAD_LOW_ADDR,
- iobase + AMCC_OP_REG_MCSR_NVCMD);
- outb(address & 0xff, iobase + AMCC_OP_REG_MCSR_NVDATA);
- outb(MCSR_NV_ENABLE | MCSR_NV_LOAD_HIGH_ADDR,
- iobase + AMCC_OP_REG_MCSR_NVCMD);
- outb((address >> 8) & 0xff, iobase + AMCC_OP_REG_MCSR_NVDATA);
- outb(MCSR_NV_ENABLE | MCSR_NV_READ, iobase + AMCC_OP_REG_MCSR_NVCMD);
-
- if (wait_for_nvram_ready(iobase) < 0)
- return -ETIMEDOUT;
-
- *data = inb(iobase + AMCC_OP_REG_MCSR_NVDATA);
-
- return 0;
-}
+static struct comedi_driver cb_pcidas_driver = {
+ .driver_name = "cb_pcidas",
+ .module = THIS_MODULE,
+ .attach = cb_pcidas_attach,
+ .detach = cb_pcidas_detach,
+};
-/*
- * A convenient macro that defines init_module() and cleanup_module(),
- * as necessary.
- */
-static int __devinit driver_cb_pcidas_pci_probe(struct pci_dev *dev,
- const struct pci_device_id *ent)
+static int __devinit cb_pcidas_pci_probe(struct pci_dev *dev,
+ const struct pci_device_id *ent)
{
- return comedi_pci_auto_config(dev, driver_cb_pcidas.driver_name);
+ return comedi_pci_auto_config(dev, &cb_pcidas_driver);
}
-static void __devexit driver_cb_pcidas_pci_remove(struct pci_dev *dev)
+static void __devexit cb_pcidas_pci_remove(struct pci_dev *dev)
{
comedi_pci_auto_unconfig(dev);
}
-static struct pci_driver driver_cb_pcidas_pci_driver = {
- .id_table = cb_pcidas_pci_table,
- .probe = &driver_cb_pcidas_pci_probe,
- .remove = __devexit_p(&driver_cb_pcidas_pci_remove)
+static DEFINE_PCI_DEVICE_TABLE(cb_pcidas_pci_table) = {
+ { PCI_DEVICE(PCI_VENDOR_ID_CB, 0x0001) },
+ { PCI_DEVICE(PCI_VENDOR_ID_CB, 0x000f) },
+ { PCI_DEVICE(PCI_VENDOR_ID_CB, 0x0010) },
+ { PCI_DEVICE(PCI_VENDOR_ID_CB, 0x0019) },
+ { PCI_DEVICE(PCI_VENDOR_ID_CB, 0x001c) },
+ { PCI_DEVICE(PCI_VENDOR_ID_CB, 0x004c) },
+ { PCI_DEVICE(PCI_VENDOR_ID_CB, 0x001a) },
+ { PCI_DEVICE(PCI_VENDOR_ID_CB, 0x001b) },
+ { 0 }
};
+MODULE_DEVICE_TABLE(pci, cb_pcidas_pci_table);
-static int __init driver_cb_pcidas_init_module(void)
-{
- int retval;
-
- retval = comedi_driver_register(&driver_cb_pcidas);
- if (retval < 0)
- return retval;
-
- driver_cb_pcidas_pci_driver.name = (char *)driver_cb_pcidas.driver_name;
- return pci_register_driver(&driver_cb_pcidas_pci_driver);
-}
-
-static void __exit driver_cb_pcidas_cleanup_module(void)
-{
- pci_unregister_driver(&driver_cb_pcidas_pci_driver);
- comedi_driver_unregister(&driver_cb_pcidas);
-}
-
-module_init(driver_cb_pcidas_init_module);
-module_exit(driver_cb_pcidas_cleanup_module);
+static struct pci_driver cb_pcidas_pci_driver = {
+ .name = "cb_pcidas",
+ .id_table = cb_pcidas_pci_table,
+ .probe = cb_pcidas_pci_probe,
+ .remove = __devexit_p(cb_pcidas_pci_remove)
+};
+module_comedi_pci_driver(cb_pcidas_driver, cb_pcidas_pci_driver);
MODULE_AUTHOR("Comedi http://www.comedi.org");
MODULE_DESCRIPTION("Comedi low-level driver");
diff --git a/drivers/staging/comedi/drivers/cb_pcidas64.c b/drivers/staging/comedi/drivers/cb_pcidas64.c
index 915157d47805..65cbaabf6456 100644
--- a/drivers/staging/comedi/drivers/cb_pcidas64.c
+++ b/drivers/staging/comedi/drivers/cb_pcidas64.c
@@ -87,7 +87,6 @@ TODO:
#include <linux/delay.h>
#include <linux/interrupt.h>
-#include "comedi_pci.h"
#include "8253.h"
#include "8255.h"
#include "plx9080.h"
@@ -1026,31 +1025,6 @@ static const struct pcidas64_board pcidas64_boards[] = {
#endif
};
-static DEFINE_PCI_DEVICE_TABLE(pcidas64_pci_table) = {
- { PCI_DEVICE(PCI_VENDOR_ID_COMPUTERBOARDS, 0x001d) },
- { PCI_DEVICE(PCI_VENDOR_ID_COMPUTERBOARDS, 0x001e) },
- { PCI_DEVICE(PCI_VENDOR_ID_COMPUTERBOARDS, 0x0035) },
- { PCI_DEVICE(PCI_VENDOR_ID_COMPUTERBOARDS, 0x0036) },
- { PCI_DEVICE(PCI_VENDOR_ID_COMPUTERBOARDS, 0x0037) },
- { PCI_DEVICE(PCI_VENDOR_ID_COMPUTERBOARDS, 0x0052) },
- { PCI_DEVICE(PCI_VENDOR_ID_COMPUTERBOARDS, 0x005d) },
- { PCI_DEVICE(PCI_VENDOR_ID_COMPUTERBOARDS, 0x005e) },
- { PCI_DEVICE(PCI_VENDOR_ID_COMPUTERBOARDS, 0x005f) },
- { PCI_DEVICE(PCI_VENDOR_ID_COMPUTERBOARDS, 0x0061) },
- { PCI_DEVICE(PCI_VENDOR_ID_COMPUTERBOARDS, 0x0062) },
- { PCI_DEVICE(PCI_VENDOR_ID_COMPUTERBOARDS, 0x0063) },
- { PCI_DEVICE(PCI_VENDOR_ID_COMPUTERBOARDS, 0x0064) },
- { PCI_DEVICE(PCI_VENDOR_ID_COMPUTERBOARDS, 0x0066) },
- { PCI_DEVICE(PCI_VENDOR_ID_COMPUTERBOARDS, 0x0067) },
- { PCI_DEVICE(PCI_VENDOR_ID_COMPUTERBOARDS, 0x0068) },
- { PCI_DEVICE(PCI_VENDOR_ID_COMPUTERBOARDS, 0x006f) },
- { PCI_DEVICE(PCI_VENDOR_ID_COMPUTERBOARDS, 0x0078) },
- { PCI_DEVICE(PCI_VENDOR_ID_COMPUTERBOARDS, 0x0079) },
- { 0 }
-};
-
-MODULE_DEVICE_TABLE(pci, pcidas64_pci_table);
-
static inline struct pcidas64_board *board(const struct comedi_device *dev)
{
return (struct pcidas64_board *)dev->board_ptr;
@@ -1073,8 +1047,6 @@ struct ext_clock_info {
/* this structure is for data unique to this hardware driver. */
struct pcidas64_private {
-
- struct pci_dev *hw_dev; /* pointer to board's pci_dev struct */
/* base addresses (physical) */
resource_size_t plx9080_phys_iobase;
resource_size_t main_phys_iobase;
@@ -1127,21 +1099,6 @@ static inline struct pcidas64_private *priv(struct comedi_device *dev)
return dev->private;
}
-/*
- * The comedi_driver structure tells the Comedi core module
- * which functions to call to configure/deconfigure (attach/detach)
- * the board, and also about the kernel module that contains
- * the device code.
- */
-static int attach(struct comedi_device *dev, struct comedi_devconfig *it);
-static int detach(struct comedi_device *dev);
-static struct comedi_driver driver_cb_pcidas = {
- .driver_name = "cb_pcidas64",
- .module = THIS_MODULE,
- .attach = attach,
- .detach = detach,
-};
-
static int ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data);
static int ai_config_insn(struct comedi_device *dev, struct comedi_subdevice *s,
@@ -1193,7 +1150,7 @@ static int eeprom_read_insn(struct comedi_device *dev,
static void check_adc_timing(struct comedi_device *dev, struct comedi_cmd *cmd);
static unsigned int get_divisor(unsigned int ns, unsigned int flags);
static void i2c_write(struct comedi_device *dev, unsigned int address,
- const uint8_t * data, unsigned int length);
+ const uint8_t *data, unsigned int length);
static void caldac_write(struct comedi_device *dev, unsigned int channel,
unsigned int value);
static int caldac_8800_write(struct comedi_device *dev, unsigned int address,
@@ -1216,44 +1173,6 @@ static unsigned int get_ao_divisor(unsigned int ns, unsigned int flags);
static void load_ao_dma(struct comedi_device *dev,
const struct comedi_cmd *cmd);
-static int __devinit driver_cb_pcidas_pci_probe(struct pci_dev *dev,
- const struct pci_device_id *ent)
-{
- return comedi_pci_auto_config(dev, driver_cb_pcidas.driver_name);
-}
-
-static void __devexit driver_cb_pcidas_pci_remove(struct pci_dev *dev)
-{
- comedi_pci_auto_unconfig(dev);
-}
-
-static struct pci_driver driver_cb_pcidas_pci_driver = {
- .id_table = pcidas64_pci_table,
- .probe = &driver_cb_pcidas_pci_probe,
- .remove = __devexit_p(&driver_cb_pcidas_pci_remove)
-};
-
-static int __init driver_cb_pcidas_init_module(void)
-{
- int retval;
-
- retval = comedi_driver_register(&driver_cb_pcidas);
- if (retval < 0)
- return retval;
-
- driver_cb_pcidas_pci_driver.name = (char *)driver_cb_pcidas.driver_name;
- return pci_register_driver(&driver_cb_pcidas_pci_driver);
-}
-
-static void __exit driver_cb_pcidas_cleanup_module(void)
-{
- pci_unregister_driver(&driver_cb_pcidas_pci_driver);
- comedi_driver_unregister(&driver_cb_pcidas);
-}
-
-module_init(driver_cb_pcidas_init_module);
-module_exit(driver_cb_pcidas_cleanup_module);
-
static unsigned int ai_range_bits_6xxx(const struct comedi_device *dev,
unsigned int range_index)
{
@@ -1308,7 +1227,7 @@ static unsigned int hw_revision(const struct comedi_device *dev,
}
static void set_dac_range_bits(struct comedi_device *dev,
- volatile uint16_t * bits, unsigned int channel,
+ volatile uint16_t *bits, unsigned int channel,
unsigned int range)
{
unsigned int code = board(dev)->ao_range_code[range];
@@ -1423,9 +1342,11 @@ static int setup_subdevices(struct comedi_device *dev)
struct comedi_subdevice *s;
void __iomem *dio_8255_iobase;
int i;
+ int ret;
- if (alloc_subdevices(dev, 10) < 0)
- return -ENOMEM;
+ ret = comedi_alloc_subdevices(dev, 10);
+ if (ret)
+ return ret;
s = dev->subdevices + 0;
/* analog input subdevice */
@@ -1630,12 +1551,13 @@ static void init_stc_registers(struct comedi_device *dev)
static int alloc_and_init_dma_members(struct comedi_device *dev)
{
+ struct pci_dev *pcidev = comedi_to_pci_dev(dev);
int i;
/* alocate pci dma buffers */
for (i = 0; i < ai_dma_ring_count(board(dev)); i++) {
priv(dev)->ai_buffer[i] =
- pci_alloc_consistent(priv(dev)->hw_dev, DMA_BUFFER_SIZE,
+ pci_alloc_consistent(pcidev, DMA_BUFFER_SIZE,
&priv(dev)->ai_buffer_bus_addr[i]);
if (priv(dev)->ai_buffer[i] == NULL)
return -ENOMEM;
@@ -1644,7 +1566,7 @@ static int alloc_and_init_dma_members(struct comedi_device *dev)
for (i = 0; i < AO_DMA_RING_COUNT; i++) {
if (ao_cmd_is_supported(board(dev))) {
priv(dev)->ao_buffer[i] =
- pci_alloc_consistent(priv(dev)->hw_dev,
+ pci_alloc_consistent(pcidev,
DMA_BUFFER_SIZE,
&priv(dev)->
ao_buffer_bus_addr[i]);
@@ -1655,7 +1577,7 @@ static int alloc_and_init_dma_members(struct comedi_device *dev)
}
/* allocate dma descriptors */
priv(dev)->ai_dma_desc =
- pci_alloc_consistent(priv(dev)->hw_dev,
+ pci_alloc_consistent(pcidev,
sizeof(struct plx_dma_desc) *
ai_dma_ring_count(board(dev)),
&priv(dev)->ai_dma_desc_bus_addr);
@@ -1666,7 +1588,7 @@ static int alloc_and_init_dma_members(struct comedi_device *dev)
priv(dev)->ai_dma_desc_bus_addr);
if (ao_cmd_is_supported(board(dev))) {
priv(dev)->ao_dma_desc =
- pci_alloc_consistent(priv(dev)->hw_dev,
+ pci_alloc_consistent(pcidev,
sizeof(struct plx_dma_desc) *
AO_DMA_RING_COUNT,
&priv(dev)->ao_dma_desc_bus_addr);
@@ -1727,14 +1649,43 @@ static inline void warn_external_queue(struct comedi_device *dev)
"Use internal AI channel queue (channels must be consecutive and use same range/aref)");
}
+static struct pci_dev *cb_pcidas64_find_pci_dev(struct comedi_device *dev,
+ struct comedi_devconfig *it)
+{
+ struct pci_dev *pcidev = NULL;
+ int bus = it->options[0];
+ int slot = it->options[1];
+ int i;
+
+ for_each_pci_dev(pcidev) {
+ if (bus || slot) {
+ if (bus != pcidev->bus->number ||
+ slot != PCI_SLOT(pcidev->devfn))
+ continue;
+ }
+ if (pcidev->vendor != PCI_VENDOR_ID_COMPUTERBOARDS)
+ continue;
+
+ for (i = 0; i < ARRAY_SIZE(pcidas64_boards); i++) {
+ if (pcidas64_boards[i].device_id != pcidev->device)
+ continue;
+ dev->board_ptr = pcidas64_boards + i;
+ return pcidev;
+ }
+ }
+ dev_err(dev->class_dev,
+ "No supported board found! (req. bus %d, slot %d)\n",
+ bus, slot);
+ return NULL;
+}
+
/*
* Attach is called by the Comedi core to configure the driver
* for a particular board.
*/
static int attach(struct comedi_device *dev, struct comedi_devconfig *it)
{
- struct pci_dev *pcidev = NULL;
- int index;
+ struct pci_dev *pcidev;
uint32_t local_range, local_decode;
int retval;
@@ -1744,45 +1695,14 @@ static int attach(struct comedi_device *dev, struct comedi_devconfig *it)
if (alloc_private(dev, sizeof(struct pcidas64_private)) < 0)
return -ENOMEM;
-/*
- * Probe the device to determine what device in the series it is.
- */
-
- for_each_pci_dev(pcidev) {
- /* is it not a computer boards card? */
- if (pcidev->vendor != PCI_VENDOR_ID_COMPUTERBOARDS)
- continue;
- /* loop through cards supported by this driver */
- for (index = 0; index < ARRAY_SIZE(pcidas64_boards); index++) {
- if (pcidas64_boards[index].device_id != pcidev->device)
- continue;
- /* was a particular bus/slot requested? */
- if (it->options[0] || it->options[1]) {
- /* are we on the wrong bus/slot? */
- if (pcidev->bus->number != it->options[0] ||
- PCI_SLOT(pcidev->devfn) != it->options[1]) {
- continue;
- }
- }
- priv(dev)->hw_dev = pcidev;
- dev->board_ptr = pcidas64_boards + index;
- break;
- }
- if (dev->board_ptr)
- break;
- }
-
- if (dev->board_ptr == NULL) {
- printk
- ("No supported ComputerBoards/MeasurementComputing card found\n");
+ pcidev = cb_pcidas64_find_pci_dev(dev, it);
+ if (!pcidev)
return -EIO;
- }
-
- dev_dbg(dev->hw_dev, "Found %s on bus %i, slot %i\n", board(dev)->name,
- pcidev->bus->number, PCI_SLOT(pcidev->devfn));
+ comedi_set_hw_dev(dev, &pcidev->dev);
- if (comedi_pci_enable(pcidev, driver_cb_pcidas.driver_name)) {
- dev_warn(dev->hw_dev, "failed to enable PCI device and request regions\n");
+ if (comedi_pci_enable(pcidev, dev->driver->driver_name)) {
+ dev_warn(dev->class_dev,
+ "failed to enable PCI device and request regions\n");
return -EIO;
}
pci_set_master(pcidev);
@@ -1790,10 +1710,11 @@ static int attach(struct comedi_device *dev, struct comedi_devconfig *it)
/* Initialize dev->board_name */
dev->board_name = board(dev)->name;
+ dev->iobase = pci_resource_start(pcidev, MAIN_BADDRINDEX);
+
priv(dev)->plx9080_phys_iobase =
pci_resource_start(pcidev, PLX9080_BADDRINDEX);
- priv(dev)->main_phys_iobase =
- pci_resource_start(pcidev, MAIN_BADDRINDEX);
+ priv(dev)->main_phys_iobase = dev->iobase;
priv(dev)->dio_counter_phys_iobase =
pci_resource_start(pcidev, DIO_COUNTER_BADDRINDEX);
@@ -1810,7 +1731,7 @@ static int attach(struct comedi_device *dev, struct comedi_devconfig *it)
if (!priv(dev)->plx9080_iobase || !priv(dev)->main_iobase
|| !priv(dev)->dio_counter_iobase) {
- dev_warn(dev->hw_dev, "failed to remap io memory\n");
+ dev_warn(dev->class_dev, "failed to remap io memory\n");
return -ENOMEM;
}
@@ -1846,19 +1767,19 @@ static int attach(struct comedi_device *dev, struct comedi_devconfig *it)
priv(dev)->hw_revision =
hw_revision(dev, readw(priv(dev)->main_iobase + HW_STATUS_REG));
- dev_dbg(dev->hw_dev, "stc hardware revision %i\n",
+ dev_dbg(dev->class_dev, "stc hardware revision %i\n",
priv(dev)->hw_revision);
init_plx9080(dev);
init_stc_registers(dev);
/* get irq */
if (request_irq(pcidev->irq, handle_interrupt, IRQF_SHARED,
"cb_pcidas64", dev)) {
- dev_dbg(dev->hw_dev, "unable to allocate irq %u\n",
+ dev_dbg(dev->class_dev, "unable to allocate irq %u\n",
pcidev->irq);
return -EINVAL;
}
dev->irq = pcidev->irq;
- dev_dbg(dev->hw_dev, "irq %u\n", dev->irq);
+ dev_dbg(dev->class_dev, "irq %u\n", dev->irq);
retval = setup_subdevices(dev);
if (retval < 0)
@@ -1868,22 +1789,15 @@ static int attach(struct comedi_device *dev, struct comedi_devconfig *it)
return 0;
}
-/*
- * _detach is called to deconfigure a device. It should deallocate
- * resources.
- * This function is also called when _attach() fails, so it should be
- * careful not to release resources that were not necessarily
- * allocated by _attach(). dev->private and dev->subdevices are
- * deallocated automatically by the core.
- */
-static int detach(struct comedi_device *dev)
+static void detach(struct comedi_device *dev)
{
+ struct pci_dev *pcidev = comedi_to_pci_dev(dev);
unsigned int i;
if (dev->irq)
free_irq(dev->irq, dev);
if (priv(dev)) {
- if (priv(dev)->hw_dev) {
+ if (pcidev) {
if (priv(dev)->plx9080_iobase) {
disable_plx_interrupts(dev);
iounmap(priv(dev)->plx9080_iobase);
@@ -1895,7 +1809,7 @@ static int detach(struct comedi_device *dev)
/* free pci dma buffers */
for (i = 0; i < ai_dma_ring_count(board(dev)); i++) {
if (priv(dev)->ai_buffer[i])
- pci_free_consistent(priv(dev)->hw_dev,
+ pci_free_consistent(pcidev,
DMA_BUFFER_SIZE,
priv(dev)->
ai_buffer[i],
@@ -1905,7 +1819,7 @@ static int detach(struct comedi_device *dev)
}
for (i = 0; i < AO_DMA_RING_COUNT; i++) {
if (priv(dev)->ao_buffer[i])
- pci_free_consistent(priv(dev)->hw_dev,
+ pci_free_consistent(pcidev,
DMA_BUFFER_SIZE,
priv(dev)->
ao_buffer[i],
@@ -1915,7 +1829,7 @@ static int detach(struct comedi_device *dev)
}
/* free dma descriptors */
if (priv(dev)->ai_dma_desc)
- pci_free_consistent(priv(dev)->hw_dev,
+ pci_free_consistent(pcidev,
sizeof(struct plx_dma_desc)
*
ai_dma_ring_count(board
@@ -1924,22 +1838,22 @@ static int detach(struct comedi_device *dev)
priv(dev)->
ai_dma_desc_bus_addr);
if (priv(dev)->ao_dma_desc)
- pci_free_consistent(priv(dev)->hw_dev,
+ pci_free_consistent(pcidev,
sizeof(struct plx_dma_desc)
* AO_DMA_RING_COUNT,
priv(dev)->ao_dma_desc,
priv(dev)->
ao_dma_desc_bus_addr);
- if (priv(dev)->main_phys_iobase)
- comedi_pci_disable(priv(dev)->hw_dev);
-
- pci_dev_put(priv(dev)->hw_dev);
}
}
if (dev->subdevices)
subdev_8255_cleanup(dev, dev->subdevices + 4);
+ if (pcidev) {
+ if (dev->iobase)
+ comedi_pci_disable(pcidev);
- return 0;
+ pci_dev_put(pcidev);
+ }
}
static int ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
@@ -2089,7 +2003,7 @@ static int ai_config_calibration_source(struct comedi_device *dev,
else
num_calibration_sources = 8;
if (source >= num_calibration_sources) {
- dev_dbg(dev->hw_dev, "invalid calibration source: %i\n",
+ dev_dbg(dev->class_dev, "invalid calibration source: %i\n",
source);
return -EINVAL;
}
@@ -2921,7 +2835,8 @@ static void pio_drain_ai_fifo_16(struct comedi_device *dev)
}
if (num_samples < 0) {
- dev_err(dev->hw_dev, "cb_pcidas64: bug! num_samples < 0\n");
+ dev_err(dev->class_dev,
+ "cb_pcidas64: bug! num_samples < 0\n");
break;
}
@@ -3702,7 +3617,7 @@ static int di_rbits(struct comedi_device *dev, struct comedi_subdevice *s,
data[1] = bits;
data[0] = 0;
- return 2;
+ return insn->n;
}
static int do_wbits(struct comedi_device *dev, struct comedi_subdevice *s,
@@ -3718,7 +3633,7 @@ static int do_wbits(struct comedi_device *dev, struct comedi_subdevice *s,
data[1] = s->state;
- return 2;
+ return insn->n;
}
static int dio_60xx_config_insn(struct comedi_device *dev,
@@ -3761,7 +3676,7 @@ static int dio_60xx_wbits(struct comedi_device *dev, struct comedi_subdevice *s,
data[1] = readb(priv(dev)->dio_counter_iobase + DIO_DATA_60XX_REG);
- return 2;
+ return insn->n;
}
static void caldac_write(struct comedi_device *dev, unsigned int channel,
@@ -4279,7 +4194,7 @@ static void i2c_stop(struct comedi_device *dev)
}
static void i2c_write(struct comedi_device *dev, unsigned int address,
- const uint8_t * data, unsigned int length)
+ const uint8_t *data, unsigned int length)
{
unsigned int i;
uint8_t bitstream;
@@ -4315,6 +4230,56 @@ static void i2c_write(struct comedi_device *dev, unsigned int address,
i2c_stop(dev);
}
+static struct comedi_driver cb_pcidas64_driver = {
+ .driver_name = "cb_pcidas64",
+ .module = THIS_MODULE,
+ .attach = attach,
+ .detach = detach,
+};
+
+static int __devinit cb_pcidas64_pci_probe(struct pci_dev *dev,
+ const struct pci_device_id *ent)
+{
+ return comedi_pci_auto_config(dev, &cb_pcidas64_driver);
+}
+
+static void __devexit cb_pcidas64_pci_remove(struct pci_dev *dev)
+{
+ comedi_pci_auto_unconfig(dev);
+}
+
+static DEFINE_PCI_DEVICE_TABLE(cb_pcidas64_pci_table) = {
+ { PCI_DEVICE(PCI_VENDOR_ID_COMPUTERBOARDS, 0x001d) },
+ { PCI_DEVICE(PCI_VENDOR_ID_COMPUTERBOARDS, 0x001e) },
+ { PCI_DEVICE(PCI_VENDOR_ID_COMPUTERBOARDS, 0x0035) },
+ { PCI_DEVICE(PCI_VENDOR_ID_COMPUTERBOARDS, 0x0036) },
+ { PCI_DEVICE(PCI_VENDOR_ID_COMPUTERBOARDS, 0x0037) },
+ { PCI_DEVICE(PCI_VENDOR_ID_COMPUTERBOARDS, 0x0052) },
+ { PCI_DEVICE(PCI_VENDOR_ID_COMPUTERBOARDS, 0x005d) },
+ { PCI_DEVICE(PCI_VENDOR_ID_COMPUTERBOARDS, 0x005e) },
+ { PCI_DEVICE(PCI_VENDOR_ID_COMPUTERBOARDS, 0x005f) },
+ { PCI_DEVICE(PCI_VENDOR_ID_COMPUTERBOARDS, 0x0061) },
+ { PCI_DEVICE(PCI_VENDOR_ID_COMPUTERBOARDS, 0x0062) },
+ { PCI_DEVICE(PCI_VENDOR_ID_COMPUTERBOARDS, 0x0063) },
+ { PCI_DEVICE(PCI_VENDOR_ID_COMPUTERBOARDS, 0x0064) },
+ { PCI_DEVICE(PCI_VENDOR_ID_COMPUTERBOARDS, 0x0066) },
+ { PCI_DEVICE(PCI_VENDOR_ID_COMPUTERBOARDS, 0x0067) },
+ { PCI_DEVICE(PCI_VENDOR_ID_COMPUTERBOARDS, 0x0068) },
+ { PCI_DEVICE(PCI_VENDOR_ID_COMPUTERBOARDS, 0x006f) },
+ { PCI_DEVICE(PCI_VENDOR_ID_COMPUTERBOARDS, 0x0078) },
+ { PCI_DEVICE(PCI_VENDOR_ID_COMPUTERBOARDS, 0x0079) },
+ { 0 }
+};
+MODULE_DEVICE_TABLE(pci, cb_pcidas64_pci_table);
+
+static struct pci_driver cb_pcidas64_pci_driver = {
+ .name = "cb_pcidas64",
+ .id_table = cb_pcidas64_pci_table,
+ .probe = cb_pcidas64_pci_probe,
+ .remove = __devexit_p(cb_pcidas64_pci_remove),
+};
+module_comedi_pci_driver(cb_pcidas64_driver, cb_pcidas64_pci_driver);
+
MODULE_AUTHOR("Comedi http://www.comedi.org");
MODULE_DESCRIPTION("Comedi low-level driver");
MODULE_LICENSE("GPL");
diff --git a/drivers/staging/comedi/drivers/cb_pcidda.c b/drivers/staging/comedi/drivers/cb_pcidda.c
index abba220a767f..12660a384e59 100644
--- a/drivers/staging/comedi/drivers/cb_pcidda.c
+++ b/drivers/staging/comedi/drivers/cb_pcidda.c
@@ -48,12 +48,13 @@ Please report success/failure with other different cards to
#include "../comedidev.h"
-#include "comedi_pci.h"
#include "8255.h"
-#define PCI_VENDOR_ID_CB 0x1307 /* PCI vendor number of ComputerBoards */
+/* PCI vendor number of ComputerBoards */
+#define PCI_VENDOR_ID_CB 0x1307
#define EEPROM_SIZE 128 /* number of entries in eeprom */
-#define MAX_AO_CHANNELS 8 /* maximum number of ao channels for supported boards */
+/* maximum number of ao channels for supported boards */
+#define MAX_AO_CHANNELS 8
/* PCI-DDA base addresses */
#define DIGITALIO_BADRINDEX 2
@@ -94,20 +95,26 @@ Please report success/failure with other different cards to
#define DACALIBRATION1 4 /* D/A CALIBRATION REGISTER 1 */
/* write bits */
-#define SERIAL_IN_BIT 0x1 /* serial data input for eeprom, caldacs, reference dac */
+/* serial data input for eeprom, caldacs, reference dac */
+#define SERIAL_IN_BIT 0x1
#define CAL_CHANNEL_MASK (0x7 << 1)
#define CAL_CHANNEL_BITS(channel) (((channel) << 1) & CAL_CHANNEL_MASK)
/* read bits */
#define CAL_COUNTER_MASK 0x1f
-#define CAL_COUNTER_OVERFLOW_BIT 0x20 /* calibration counter overflow status bit */
-#define AO_BELOW_REF_BIT 0x40 /* analog output is less than reference dac voltage */
+/* calibration counter overflow status bit */
+#define CAL_COUNTER_OVERFLOW_BIT 0x20
+/* analog output is less than reference dac voltage */
+#define AO_BELOW_REF_BIT 0x40
#define SERIAL_OUT_BIT 0x80 /* serial data out, for reading from eeprom */
#define DACALIBRATION2 6 /* D/A CALIBRATION REGISTER 2 */
#define SELECT_EEPROM_BIT 0x1 /* send serial data in to eeprom */
-#define DESELECT_REF_DAC_BIT 0x2 /* don't send serial data to MAX542 reference dac */
-#define DESELECT_CALDAC_BIT(n) (0x4 << (n)) /* don't send serial data to caldac n */
-#define DUMMY_BIT 0x40 /* manual says to set this bit with no explanation */
+/* don't send serial data to MAX542 reference dac */
+#define DESELECT_REF_DAC_BIT 0x2
+/* don't send serial data to caldac n */
+#define DESELECT_CALDAC_BIT(n) (0x4 << (n))
+/* manual says to set this bit with no explanation */
+#define DUMMY_BIT 0x40
#define DADATA 8 /* FIRST D/A DATA REGISTER (0) */
@@ -195,40 +202,30 @@ static const struct cb_pcidda_board cb_pcidda_boards[] = {
},
};
-static DEFINE_PCI_DEVICE_TABLE(cb_pcidda_pci_table) = {
- { PCI_DEVICE(PCI_VENDOR_ID_CB, 0x0020) },
- { PCI_DEVICE(PCI_VENDOR_ID_CB, 0x0021) },
- { PCI_DEVICE(PCI_VENDOR_ID_CB, 0x0022) },
- { PCI_DEVICE(PCI_VENDOR_ID_CB, 0x0023) },
- { PCI_DEVICE(PCI_VENDOR_ID_CB, 0x0024) },
- { PCI_DEVICE(PCI_VENDOR_ID_CB, 0x0025) },
- { 0 }
-};
-
-MODULE_DEVICE_TABLE(pci, cb_pcidda_pci_table);
-
/*
* Useful for shorthand access to the particular board structure
*/
#define thisboard ((const struct cb_pcidda_board *)dev->board_ptr)
-/* this structure is for data unique to this hardware driver. If
- several hardware drivers keep similar information in this structure,
- feel free to suggest moving the variable to the struct comedi_device struct. */
+/*
+ * this structure is for data unique to this hardware driver. If
+ * several hardware drivers keep similar information in this structure,
+ * feel free to suggest moving the variable to the struct comedi_device
+ * struct.
+ */
struct cb_pcidda_private {
int data;
- /* would be useful for a PCI device */
- struct pci_dev *pci_dev;
-
unsigned long digitalio;
unsigned long dac;
/* unsigned long control_status; */
/* unsigned long adc_fifo; */
- unsigned int dac_cal1_bits; /* bits last written to da calibration register 1 */
- unsigned int ao_range[MAX_AO_CHANNELS]; /* current range settings for output channels */
+ /* bits last written to da calibration register 1 */
+ unsigned int dac_cal1_bits;
+ /* current range settings for output channels */
+ unsigned int ao_range[MAX_AO_CHANNELS];
u16 eeprom_data[EEPROM_SIZE]; /* software copy of board's eeprom */
};
@@ -238,9 +235,6 @@ struct cb_pcidda_private {
*/
#define devpriv ((struct cb_pcidda_private *)dev->private)
-static int cb_pcidda_attach(struct comedi_device *dev,
- struct comedi_devconfig *it);
-static int cb_pcidda_detach(struct comedi_device *dev);
/* static int cb_pcidda_ai_rinsn(struct comedi_device *dev,struct comedi_subdevice *s,struct comedi_insn *insn,unsigned int *data); */
static int cb_pcidda_ao_winsn(struct comedi_device *dev,
struct comedi_subdevice *s,
@@ -258,18 +252,35 @@ static unsigned int cb_pcidda_read_eeprom(struct comedi_device *dev,
static void cb_pcidda_calibrate(struct comedi_device *dev, unsigned int channel,
unsigned int range);
-/*
- * The struct comedi_driver structure tells the Comedi core module
- * which functions to call to configure/deconfigure (attach/detach)
- * the board, and also about the kernel module that contains
- * the device code.
- */
-static struct comedi_driver driver_cb_pcidda = {
- .driver_name = "cb_pcidda",
- .module = THIS_MODULE,
- .attach = cb_pcidda_attach,
- .detach = cb_pcidda_detach,
-};
+static struct pci_dev *cb_pcidda_find_pci_dev(struct comedi_device *dev,
+ struct comedi_devconfig *it)
+{
+ struct pci_dev *pcidev = NULL;
+ int bus = it->options[0];
+ int slot = it->options[1];
+ int i;
+
+ for_each_pci_dev(pcidev) {
+ if (bus || slot) {
+ if (bus != pcidev->bus->number ||
+ slot != PCI_SLOT(pcidev->devfn))
+ continue;
+ }
+ if (pcidev->vendor != PCI_VENDOR_ID_CB)
+ continue;
+
+ for (i = 0; i < ARRAY_SIZE(cb_pcidda_boards); i++) {
+ if (cb_pcidda_boards[i].device_id != pcidev->device)
+ continue;
+ dev->board_ptr = cb_pcidda_boards + i;
+ return pcidev;
+ }
+ }
+ dev_err(dev->class_dev,
+ "No supported board found! (req. bus %d, slot %d)\n",
+ bus, slot);
+ return NULL;
+}
/*
* Attach is called by the Comedi core to configure the driver
@@ -278,10 +289,10 @@ static struct comedi_driver driver_cb_pcidda = {
static int cb_pcidda_attach(struct comedi_device *dev,
struct comedi_devconfig *it)
{
+ struct pci_dev *pcidev;
struct comedi_subdevice *s;
- struct pci_dev *pcidev = NULL;
int index;
-
+ int ret;
/*
* Allocate the private structure area.
@@ -289,51 +300,26 @@ static int cb_pcidda_attach(struct comedi_device *dev,
if (alloc_private(dev, sizeof(struct cb_pcidda_private)) < 0)
return -ENOMEM;
-/*
- * Probe the device to determine what device in the series it is.
- */
-
- for_each_pci_dev(pcidev) {
- if (pcidev->vendor == PCI_VENDOR_ID_CB) {
- if (it->options[0] || it->options[1]) {
- if (pcidev->bus->number != it->options[0] ||
- PCI_SLOT(pcidev->devfn) != it->options[1]) {
- continue;
- }
- }
- for (index = 0; index < ARRAY_SIZE(cb_pcidda_boards); index++) {
- if (cb_pcidda_boards[index].device_id ==
- pcidev->device) {
- goto found;
- }
- }
- }
- }
- if (!pcidev) {
- dev_err(dev->hw_dev, "Not a ComputerBoards/MeasurementComputing card on requested position\n");
+ pcidev = cb_pcidda_find_pci_dev(dev, it);
+ if (!pcidev)
return -EIO;
- }
-found:
- devpriv->pci_dev = pcidev;
- dev->board_ptr = cb_pcidda_boards + index;
- /* "thisboard" macro can be used from here. */
- dev_dbg(dev->hw_dev, "Found %s at requested position\n",
- thisboard->name);
+ comedi_set_hw_dev(dev, &pcidev->dev);
/*
* Enable PCI device and request regions.
*/
if (comedi_pci_enable(pcidev, thisboard->name)) {
- dev_err(dev->hw_dev, "cb_pcidda: failed to enable PCI device and request regions\n");
+ dev_err(dev->class_dev,
+ "cb_pcidda: failed to enable PCI device and request regions\n");
return -EIO;
}
/*
* Allocate the I/O ports.
*/
- devpriv->digitalio =
- pci_resource_start(devpriv->pci_dev, DIGITALIO_BADRINDEX);
- devpriv->dac = pci_resource_start(devpriv->pci_dev, DAC_BADRINDEX);
+ devpriv->digitalio = pci_resource_start(pcidev, DIGITALIO_BADRINDEX);
+ devpriv->dac = pci_resource_start(pcidev, DAC_BADRINDEX);
+ dev->iobase = devpriv->dac;
/*
* Warn about the status of the driver.
@@ -349,11 +335,9 @@ found:
*/
dev->board_name = thisboard->name;
-/*
- * Allocate the subdevice structures.
- */
- if (alloc_subdevices(dev, 3) < 0)
- return -ENOMEM;
+ ret = comedi_alloc_subdevices(dev, 3);
+ if (ret)
+ return ret;
s = dev->subdevices + 0;
/* analog output subdevice */
@@ -374,10 +358,11 @@ found:
s = dev->subdevices + 2;
subdev_8255_init(dev, s, NULL, devpriv->digitalio + PORT2A);
- dev_dbg(dev->hw_dev, "eeprom:\n");
+ dev_dbg(dev->class_dev, "eeprom:\n");
for (index = 0; index < EEPROM_SIZE; index++) {
devpriv->eeprom_data[index] = cb_pcidda_read_eeprom(dev, index);
- dev_dbg(dev->hw_dev, "%i:0x%x\n", index, devpriv->eeprom_data[index]);
+ dev_dbg(dev->class_dev, "%i:0x%x\n", index,
+ devpriv->eeprom_data[index]);
}
/* set calibrations dacs */
@@ -387,33 +372,19 @@ found:
return 1;
}
-/*
- * _detach is called to deconfigure a device. It should deallocate
- * resources.
- * This function is also called when _attach() fails, so it should be
- * careful not to release resources that were not necessarily
- * allocated by _attach(). dev->private and dev->subdevices are
- * deallocated automatically by the core.
- */
-static int cb_pcidda_detach(struct comedi_device *dev)
+static void cb_pcidda_detach(struct comedi_device *dev)
{
-/*
- * Deallocate the I/O ports.
- */
- if (devpriv) {
- if (devpriv->pci_dev) {
- if (devpriv->dac)
- comedi_pci_disable(devpriv->pci_dev);
- pci_dev_put(devpriv->pci_dev);
- }
+ struct pci_dev *pcidev = comedi_to_pci_dev(dev);
+
+ if (pcidev) {
+ if (dev->iobase)
+ comedi_pci_disable(pcidev);
+ pci_dev_put(pcidev);
}
- /* cleanup 8255 */
if (dev->subdevices) {
subdev_8255_cleanup(dev, dev->subdevices + 1);
subdev_8255_cleanup(dev, dev->subdevices + 2);
}
-
- return 0;
}
/*
@@ -484,7 +455,10 @@ static int cb_pcidda_ai_cmdtest(struct comedi_device *dev,
if (err)
return 1;
- /* step 2: make sure trigger sources are unique and mutually compatible */
+ /*
+ * step 2: make sure trigger sources are unique and mutually
+ * compatible
+ */
/* note that mutual compatibility is not an issue here */
if (cmd->scan_begin_src != TRIG_TIMER
@@ -696,8 +670,10 @@ static unsigned int cb_pcidda_read_eeprom(struct comedi_device *dev,
unsigned int i;
unsigned int cal2_bits;
unsigned int value;
- const int max_num_caldacs = 4; /* one caldac for every two dac channels */
- const int read_instruction = 0x6; /* bits to send to tell eeprom we want to read */
+ /* one caldac for every two dac channels */
+ const int max_num_caldacs = 4;
+ /* bits to send to tell eeprom we want to read */
+ const int read_instruction = 0x6;
const int instruction_length = 3;
const int address_length = 8;
@@ -729,9 +705,11 @@ static void cb_pcidda_write_caldac(struct comedi_device *dev,
{
unsigned int cal2_bits;
unsigned int i;
- const int num_channel_bits = 3; /* caldacs use 3 bit channel specification */
+ /* caldacs use 3 bit channel specification */
+ const int num_channel_bits = 3;
const int num_caldac_bits = 8; /* 8 bit calibration dacs */
- const int max_num_caldacs = 4; /* one caldac for every two dac channels */
+ /* one caldac for every two dac channels */
+ const int max_num_caldacs = 4;
/* write 3 bit channel */
cb_pcidda_serial_out(dev, channel, num_channel_bits);
@@ -790,14 +768,20 @@ static unsigned int offset_eeprom_address(unsigned int ao_channel,
return 0x7 + 2 * range + 12 * ao_channel;
}
-/* returns eeprom address that provides gain calibration for given ao channel and range */
+/*
+ * returns eeprom address that provides gain calibration for given ao
+ * channel and range
+ */
static unsigned int gain_eeprom_address(unsigned int ao_channel,
unsigned int range)
{
return 0x8 + 2 * range + 12 * ao_channel;
}
-/* returns upper byte of eeprom entry, which gives the coarse adjustment values */
+/*
+ * returns upper byte of eeprom entry, which gives the coarse adjustment
+ * values
+ */
static unsigned int eeprom_coarse_byte(unsigned int word)
{
return (word >> 8) & 0xff;
@@ -815,7 +799,7 @@ static void cb_pcidda_calibrate(struct comedi_device *dev, unsigned int channel,
{
unsigned int coarse_offset, fine_offset, coarse_gain, fine_gain;
- /* remember range so we can tell when we need to readjust calibration */
+ /* remember range so we can tell when we need to readjust calibration */
devpriv->ao_range[channel] = range;
/* get values from eeprom data */
@@ -843,47 +827,42 @@ static void cb_pcidda_calibrate(struct comedi_device *dev, unsigned int channel,
fine_gain_channel(channel), fine_gain);
}
-/*
- * A convenient macro that defines init_module() and cleanup_module(),
- * as necessary.
- */
-static int __devinit driver_cb_pcidda_pci_probe(struct pci_dev *dev,
- const struct pci_device_id *ent)
+static struct comedi_driver cb_pcidda_driver = {
+ .driver_name = "cb_pcidda",
+ .module = THIS_MODULE,
+ .attach = cb_pcidda_attach,
+ .detach = cb_pcidda_detach,
+};
+
+static int __devinit cb_pcidda_pci_probe(struct pci_dev *dev,
+ const struct pci_device_id *ent)
{
- return comedi_pci_auto_config(dev, driver_cb_pcidda.driver_name);
+ return comedi_pci_auto_config(dev, &cb_pcidda_driver);
}
-static void __devexit driver_cb_pcidda_pci_remove(struct pci_dev *dev)
+static void __devexit cb_pcidda_pci_remove(struct pci_dev *dev)
{
comedi_pci_auto_unconfig(dev);
}
-static struct pci_driver driver_cb_pcidda_pci_driver = {
- .id_table = cb_pcidda_pci_table,
- .probe = &driver_cb_pcidda_pci_probe,
- .remove = __devexit_p(&driver_cb_pcidda_pci_remove)
+static DEFINE_PCI_DEVICE_TABLE(cb_pcidda_pci_table) = {
+ { PCI_DEVICE(PCI_VENDOR_ID_CB, 0x0020) },
+ { PCI_DEVICE(PCI_VENDOR_ID_CB, 0x0021) },
+ { PCI_DEVICE(PCI_VENDOR_ID_CB, 0x0022) },
+ { PCI_DEVICE(PCI_VENDOR_ID_CB, 0x0023) },
+ { PCI_DEVICE(PCI_VENDOR_ID_CB, 0x0024) },
+ { PCI_DEVICE(PCI_VENDOR_ID_CB, 0x0025) },
+ { 0 }
};
+MODULE_DEVICE_TABLE(pci, cb_pcidda_pci_table);
-static int __init driver_cb_pcidda_init_module(void)
-{
- int retval;
-
- retval = comedi_driver_register(&driver_cb_pcidda);
- if (retval < 0)
- return retval;
-
- driver_cb_pcidda_pci_driver.name = (char *)driver_cb_pcidda.driver_name;
- return pci_register_driver(&driver_cb_pcidda_pci_driver);
-}
-
-static void __exit driver_cb_pcidda_cleanup_module(void)
-{
- pci_unregister_driver(&driver_cb_pcidda_pci_driver);
- comedi_driver_unregister(&driver_cb_pcidda);
-}
-
-module_init(driver_cb_pcidda_init_module);
-module_exit(driver_cb_pcidda_cleanup_module);
+static struct pci_driver cb_pcidda_pci_driver = {
+ .name = "cb_pcidda",
+ .id_table = cb_pcidda_pci_table,
+ .probe = cb_pcidda_pci_probe,
+ .remove = __devexit_p(cb_pcidda_pci_remove),
+};
+module_comedi_pci_driver(cb_pcidda_driver, cb_pcidda_pci_driver);
MODULE_AUTHOR("Comedi http://www.comedi.org");
MODULE_DESCRIPTION("Comedi low-level driver");
diff --git a/drivers/staging/comedi/drivers/cb_pcidio.c b/drivers/staging/comedi/drivers/cb_pcidio.c
index 8f3215239a15..e370d0d81bbd 100644
--- a/drivers/staging/comedi/drivers/cb_pcidio.c
+++ b/drivers/staging/comedi/drivers/cb_pcidio.c
@@ -41,7 +41,6 @@ Passing a zero for an option is the same as leaving it unspecified.
/*------------------------------ HEADER FILES ---------------------------------*/
#include "../comedidev.h"
-#include "comedi_pci.h"
#include "8255.h"
/*-------------------------- MACROS and DATATYPES -----------------------------*/
@@ -86,145 +85,51 @@ static const struct pcidio_board pcidio_boards[] = {
},
};
-/* This is used by modprobe to translate PCI IDs to drivers. Should
- * only be used for PCI and ISA-PnP devices */
-/* Please add your PCI vendor ID to comedidev.h, and it will be forwarded
- * upstream. */
-static DEFINE_PCI_DEVICE_TABLE(pcidio_pci_table) = {
- { PCI_DEVICE(PCI_VENDOR_ID_CB, 0x0028) },
- { PCI_DEVICE(PCI_VENDOR_ID_CB, 0x0014) },
- { PCI_DEVICE(PCI_VENDOR_ID_CB, 0x000b) },
- { 0 }
-};
-
-MODULE_DEVICE_TABLE(pci, pcidio_pci_table);
-
/*
* Useful for shorthand access to the particular board structure
*/
#define thisboard ((const struct pcidio_board *)dev->board_ptr)
-/* this structure is for data unique to this hardware driver. If
- several hardware drivers keep similar information in this structure,
- feel free to suggest moving the variable to the struct comedi_device struct. */
-struct pcidio_private {
- int data; /* currently unused */
-
- /* would be useful for a PCI device */
- struct pci_dev *pci_dev;
-
- /* used for DO readback, currently unused */
- unsigned int do_readback[4]; /* up to 4 unsigned int suffice to hold 96 bits for PCI-DIO96 */
-
- unsigned long dio_reg_base; /* address of port A of the first 8255 chip on board */
-};
-
-/*
- * most drivers define the following macro to make it easy to
- * access the private structure.
- */
-#define devpriv ((struct pcidio_private *)dev->private)
-
-/*
- * The struct comedi_driver structure tells the Comedi core module
- * which functions to call to configure/deconfigure (attach/detach)
- * the board, and also about the kernel module that contains
- * the device code.
- */
-static int pcidio_attach(struct comedi_device *dev,
- struct comedi_devconfig *it);
-static int pcidio_detach(struct comedi_device *dev);
-static struct comedi_driver driver_cb_pcidio = {
- .driver_name = "cb_pcidio",
- .module = THIS_MODULE,
- .attach = pcidio_attach,
- .detach = pcidio_detach,
-
-/* It is not necessary to implement the following members if you are
- * writing a driver for a ISA PnP or PCI card */
-
- /* Most drivers will support multiple types of boards by
- * having an array of board structures. These were defined
- * in pcidio_boards[] above. Note that the element 'name'
- * was first in the structure -- Comedi uses this fact to
- * extract the name of the board without knowing any details
- * about the structure except for its length.
- * When a device is attached (by comedi_config), the name
- * of the device is given to Comedi, and Comedi tries to
- * match it by going through the list of board names. If
- * there is a match, the address of the pointer is put
- * into dev->board_ptr and driver->attach() is called.
- *
- * Note that these are not necessary if you can determine
- * the type of board in software. ISA PnP, PCI, and PCMCIA
- * devices are such boards.
- */
-
-/* The following fields should NOT be initialized if you are dealing
- * with PCI devices
- *
- * .board_name = pcidio_boards,
- * .offset = sizeof(struct pcidio_board),
- * .num_names = sizeof(pcidio_boards) / sizeof(structpcidio_board),
- */
-
-};
-
-/*------------------------------- FUNCTIONS -----------------------------------*/
-
-/*
- * Attach is called by the Comedi core to configure the driver
- * for a particular board. If you specified a board_name array
- * in the driver structure, dev->board_ptr contains that
- * address.
- */
-static int pcidio_attach(struct comedi_device *dev, struct comedi_devconfig *it)
+static struct pci_dev *pcidio_find_pci_dev(struct comedi_device *dev,
+ struct comedi_devconfig *it)
{
struct pci_dev *pcidev = NULL;
- int index;
+ int bus = it->options[0];
+ int slot = it->options[1];
int i;
-/*
- * Allocate the private structure area. alloc_private() is a
- * convenient macro defined in comedidev.h.
- */
- if (alloc_private(dev, sizeof(struct pcidio_private)) < 0)
- return -ENOMEM;
-/*
- * If you can probe the device to determine what device in a series
- * it is, this is the place to do it. Otherwise, dev->board_ptr
- * should already be initialized.
- */
-/*
- * Probe the device to determine what device in the series it is.
- */
-
for_each_pci_dev(pcidev) {
- /* is it not a computer boards card? */
+ if (bus || slot) {
+ if (bus != pcidev->bus->number ||
+ slot != PCI_SLOT(pcidev->devfn))
+ continue;
+ }
if (pcidev->vendor != PCI_VENDOR_ID_CB)
continue;
- /* loop through cards supported by this driver */
- for (index = 0; index < ARRAY_SIZE(pcidio_boards); index++) {
- if (pcidio_boards[index].dev_id != pcidev->device)
+ for (i = 0; i < ARRAY_SIZE(pcidio_boards); i++) {
+ if (pcidio_boards[i].dev_id != pcidev->device)
continue;
- /* was a particular bus/slot requested? */
- if (it->options[0] || it->options[1]) {
- /* are we on the wrong bus/slot? */
- if (pcidev->bus->number != it->options[0] ||
- PCI_SLOT(pcidev->devfn) != it->options[1]) {
- continue;
- }
- }
- dev->board_ptr = pcidio_boards + index;
- goto found;
+ dev->board_ptr = pcidio_boards + i;
+ return pcidev;
}
}
+ dev_err(dev->class_dev,
+ "No supported board found! (req. bus %d, slot %d)\n",
+ bus, slot);
+ return NULL;
+}
- dev_err(dev->hw_dev, "No supported ComputerBoards/MeasurementComputing card found on requested position\n");
- return -EIO;
+static int pcidio_attach(struct comedi_device *dev, struct comedi_devconfig *it)
+{
+ struct pci_dev *pcidev;
+ int i;
+ int ret;
-found:
+ pcidev = pcidio_find_pci_dev(dev, it);
+ if (!pcidev)
+ return -EIO;
+ comedi_set_hw_dev(dev, &pcidev->dev);
/*
* Initialize dev->board_name. Note that we can use the "thisboard"
@@ -232,101 +137,74 @@ found:
*/
dev->board_name = thisboard->name;
- devpriv->pci_dev = pcidev;
- dev_dbg(dev->hw_dev, "Found %s on bus %i, slot %i\n", thisboard->name,
- devpriv->pci_dev->bus->number,
- PCI_SLOT(devpriv->pci_dev->devfn));
if (comedi_pci_enable(pcidev, thisboard->name))
return -EIO;
- devpriv->dio_reg_base
- =
- pci_resource_start(devpriv->pci_dev,
- pcidio_boards[index].dioregs_badrindex);
+ dev->iobase = pci_resource_start(pcidev, thisboard->dioregs_badrindex);
-/*
- * Allocate the subdevice structures. alloc_subdevice() is a
- * convenient macro defined in comedidev.h.
- */
- if (alloc_subdevices(dev, thisboard->n_8255) < 0)
- return -ENOMEM;
+ ret = comedi_alloc_subdevices(dev, thisboard->n_8255);
+ if (ret)
+ return ret;
for (i = 0; i < thisboard->n_8255; i++) {
subdev_8255_init(dev, dev->subdevices + i,
- NULL, devpriv->dio_reg_base + i * 4);
- dev_dbg(dev->hw_dev, "subdev %d: base = 0x%lx\n", i,
- devpriv->dio_reg_base + i * 4);
+ NULL, dev->iobase + i * 4);
+ dev_dbg(dev->class_dev, "subdev %d: base = 0x%lx\n", i,
+ dev->iobase + i * 4);
}
return 1;
}
-/*
- * _detach is called to deconfigure a device. It should deallocate
- * resources.
- * This function is also called when _attach() fails, so it should be
- * careful not to release resources that were not necessarily
- * allocated by _attach(). dev->private and dev->subdevices are
- * deallocated automatically by the core.
- */
-static int pcidio_detach(struct comedi_device *dev)
+static void pcidio_detach(struct comedi_device *dev)
{
- if (devpriv) {
- if (devpriv->pci_dev) {
- if (devpriv->dio_reg_base)
- comedi_pci_disable(devpriv->pci_dev);
- pci_dev_put(devpriv->pci_dev);
- }
+ struct pci_dev *pcidev = comedi_to_pci_dev(dev);
+
+ if (pcidev) {
+ if (dev->iobase)
+ comedi_pci_disable(pcidev);
+ pci_dev_put(pcidev);
}
if (dev->subdevices) {
int i;
for (i = 0; i < thisboard->n_8255; i++)
subdev_8255_cleanup(dev, dev->subdevices + i);
}
- return 0;
}
-/*
- * A convenient macro that defines init_module() and cleanup_module(),
- * as necessary.
- */
-static int __devinit driver_cb_pcidio_pci_probe(struct pci_dev *dev,
+static struct comedi_driver cb_pcidio_driver = {
+ .driver_name = "cb_pcidio",
+ .module = THIS_MODULE,
+ .attach = pcidio_attach,
+ .detach = pcidio_detach,
+};
+
+static int __devinit cb_pcidio_pci_probe(struct pci_dev *dev,
const struct pci_device_id *ent)
{
- return comedi_pci_auto_config(dev, driver_cb_pcidio.driver_name);
+ return comedi_pci_auto_config(dev, &cb_pcidio_driver);
}
-static void __devexit driver_cb_pcidio_pci_remove(struct pci_dev *dev)
+static void __devexit cb_pcidio_pci_remove(struct pci_dev *dev)
{
comedi_pci_auto_unconfig(dev);
}
-static struct pci_driver driver_cb_pcidio_pci_driver = {
- .id_table = pcidio_pci_table,
- .probe = &driver_cb_pcidio_pci_probe,
- .remove = __devexit_p(&driver_cb_pcidio_pci_remove)
+static DEFINE_PCI_DEVICE_TABLE(cb_pcidio_pci_table) = {
+ { PCI_DEVICE(PCI_VENDOR_ID_CB, 0x0028) },
+ { PCI_DEVICE(PCI_VENDOR_ID_CB, 0x0014) },
+ { PCI_DEVICE(PCI_VENDOR_ID_CB, 0x000b) },
+ { 0 }
};
+MODULE_DEVICE_TABLE(pci, cb_pcidio_pci_table);
-static int __init driver_cb_pcidio_init_module(void)
-{
- int retval;
-
- retval = comedi_driver_register(&driver_cb_pcidio);
- if (retval < 0)
- return retval;
-
- driver_cb_pcidio_pci_driver.name = (char *)driver_cb_pcidio.driver_name;
- return pci_register_driver(&driver_cb_pcidio_pci_driver);
-}
-
-static void __exit driver_cb_pcidio_cleanup_module(void)
-{
- pci_unregister_driver(&driver_cb_pcidio_pci_driver);
- comedi_driver_unregister(&driver_cb_pcidio);
-}
-
-module_init(driver_cb_pcidio_init_module);
-module_exit(driver_cb_pcidio_cleanup_module);
+static struct pci_driver cb_pcidio_pci_driver = {
+ .name = "cb_pcidio",
+ .id_table = cb_pcidio_pci_table,
+ .probe = cb_pcidio_pci_probe,
+ .remove = __devexit_p(cb_pcidio_pci_remove),
+};
+module_comedi_pci_driver(cb_pcidio_driver, cb_pcidio_pci_driver);
MODULE_AUTHOR("Comedi http://www.comedi.org");
MODULE_DESCRIPTION("Comedi low-level driver");
diff --git a/drivers/staging/comedi/drivers/cb_pcimdas.c b/drivers/staging/comedi/drivers/cb_pcimdas.c
index 8ba694263bd3..c632a89f3ae9 100644
--- a/drivers/staging/comedi/drivers/cb_pcimdas.c
+++ b/drivers/staging/comedi/drivers/cb_pcimdas.c
@@ -45,7 +45,6 @@ See http://www.mccdaq.com/PDFs/Manuals/pcim-das1602-16.pdf for more details.
#include <linux/delay.h>
#include <linux/interrupt.h>
-#include "comedi_pci.h"
#include "plx9052.h"
#include "8255.h"
@@ -57,11 +56,7 @@ See http://www.mccdaq.com/PDFs/Manuals/pcim-das1602-16.pdf for more details.
/* Registers for the PCIM-DAS1602/16 */
/* sizes of io regions (bytes) */
-#define BADR0_SIZE 2 /* ?? */
-#define BADR1_SIZE 4
-#define BADR2_SIZE 6
#define BADR3_SIZE 16
-#define BADR4_SIZE 4
/* DAC Offsets */
#define ADC_TRIG 0
@@ -123,47 +118,23 @@ static const struct cb_pcimdas_board cb_pcimdas_boards[] = {
},
};
-/* This is used by modprobe to translate PCI IDs to drivers. Should
- * only be used for PCI and ISA-PnP devices */
-static DEFINE_PCI_DEVICE_TABLE(cb_pcimdas_pci_table) = {
- { PCI_DEVICE(PCI_VENDOR_ID_COMPUTERBOARDS, 0x0056) },
- { 0 }
-};
-
-MODULE_DEVICE_TABLE(pci, cb_pcimdas_pci_table);
-
-#define N_BOARDS 1 /* Max number of boards supported */
-
/*
* Useful for shorthand access to the particular board structure
*/
#define thisboard ((const struct cb_pcimdas_board *)dev->board_ptr)
-/* this structure is for data unique to this hardware driver. If
- several hardware drivers keep similar information in this structure,
- feel free to suggest moving the variable to the struct comedi_device struct. */
+/*
+ * this structure is for data unique to this hardware driver. If
+ * several hardware drivers keep similar information in this structure,
+ * feel free to suggest moving the variable to the struct comedi_device
+ * struct.
+ */
struct cb_pcimdas_private {
- int data;
-
- /* would be useful for a PCI device */
- struct pci_dev *pci_dev;
-
/* base addresses */
- unsigned long BADR0;
- unsigned long BADR1;
- unsigned long BADR2;
unsigned long BADR3;
- unsigned long BADR4;
/* Used for AO readback */
unsigned int ao_readback[2];
-
- /* Used for DIO */
- unsigned short int port_a; /* copy of BADR4+0 */
- unsigned short int port_b; /* copy of BADR4+1 */
- unsigned short int port_c; /* copy of BADR4+2 */
- unsigned short int dio_mode; /* copy of BADR4+3 */
-
};
/*
@@ -172,22 +143,6 @@ struct cb_pcimdas_private {
*/
#define devpriv ((struct cb_pcimdas_private *)dev->private)
-/*
- * The struct comedi_driver structure tells the Comedi core module
- * which functions to call to configure/deconfigure (attach/detach)
- * the board, and also about the kernel module that contains
- * the device code.
- */
-static int cb_pcimdas_attach(struct comedi_device *dev,
- struct comedi_devconfig *it);
-static int cb_pcimdas_detach(struct comedi_device *dev);
-static struct comedi_driver driver_cb_pcimdas = {
- .driver_name = "cb_pcimdas",
- .module = THIS_MODULE,
- .attach = cb_pcimdas_attach,
- .detach = cb_pcimdas_detach,
-};
-
static int cb_pcimdas_ai_rinsn(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data);
@@ -198,6 +153,37 @@ static int cb_pcimdas_ao_rinsn(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data);
+static struct pci_dev *cb_pcimdas_find_pci_dev(struct comedi_device *dev,
+ struct comedi_devconfig *it)
+{
+ struct pci_dev *pcidev = NULL;
+ int bus = it->options[0];
+ int slot = it->options[1];
+ int i;
+
+ for_each_pci_dev(pcidev) {
+ if (bus || slot) {
+ if (bus != pcidev->bus->number ||
+ slot != PCI_SLOT(pcidev->devfn))
+ continue;
+ }
+ if (pcidev->vendor != PCI_VENDOR_ID_COMPUTERBOARDS)
+ continue;
+
+ for (i = 0; i < ARRAY_SIZE(cb_pcimdas_boards); i++) {
+ if (cb_pcimdas_boards[i].device_id != pcidev->device)
+ continue;
+
+ dev->board_ptr = cb_pcimdas_boards + i;
+ return pcidev;
+ }
+ }
+ dev_err(dev->class_dev,
+ "No supported board found! (req. bus %d, slot %d)\n",
+ bus, slot);
+ return NULL;
+}
+
/*
* Attach is called by the Comedi core to configure the driver
* for a particular board. If you specified a board_name array
@@ -207,10 +193,10 @@ static int cb_pcimdas_ao_rinsn(struct comedi_device *dev,
static int cb_pcimdas_attach(struct comedi_device *dev,
struct comedi_devconfig *it)
{
+ struct pci_dev *pcidev;
struct comedi_subdevice *s;
- struct pci_dev *pcidev = NULL;
- int index;
- /* int i; */
+ unsigned long iobase_8255;
+ int ret;
/*
* Allocate the private structure area.
@@ -218,86 +204,46 @@ static int cb_pcimdas_attach(struct comedi_device *dev,
if (alloc_private(dev, sizeof(struct cb_pcimdas_private)) < 0)
return -ENOMEM;
-/*
- * Probe the device to determine what device in the series it is.
- */
-
- for_each_pci_dev(pcidev) {
- /* is it not a computer boards card? */
- if (pcidev->vendor != PCI_VENDOR_ID_COMPUTERBOARDS)
- continue;
- /* loop through cards supported by this driver */
- for (index = 0; index < N_BOARDS; index++) {
- if (cb_pcimdas_boards[index].device_id !=
- pcidev->device)
- continue;
- /* was a particular bus/slot requested? */
- if (it->options[0] || it->options[1]) {
- /* are we on the wrong bus/slot? */
- if (pcidev->bus->number != it->options[0] ||
- PCI_SLOT(pcidev->devfn) != it->options[1]) {
- continue;
- }
- }
- devpriv->pci_dev = pcidev;
- dev->board_ptr = cb_pcimdas_boards + index;
- goto found;
- }
- }
-
- dev_err(dev->hw_dev, "No supported ComputerBoards/MeasurementComputing card found on requested position\n");
- return -EIO;
-
-found:
-
- dev_dbg(dev->hw_dev, "Found %s on bus %i, slot %i\n",
- cb_pcimdas_boards[index].name, pcidev->bus->number,
- PCI_SLOT(pcidev->devfn));
+ pcidev = cb_pcimdas_find_pci_dev(dev, it);
+ if (!pcidev)
+ return -EIO;
+ comedi_set_hw_dev(dev, &pcidev->dev);
/* Warn about non-tested features */
switch (thisboard->device_id) {
case 0x56:
break;
default:
- dev_dbg(dev->hw_dev, "THIS CARD IS UNSUPPORTED.\n"
+ dev_dbg(dev->class_dev, "THIS CARD IS UNSUPPORTED.\n");
+ dev_dbg(dev->class_dev,
"PLEASE REPORT USAGE TO <mocelet@sucs.org>\n");
}
if (comedi_pci_enable(pcidev, "cb_pcimdas")) {
- dev_err(dev->hw_dev, "Failed to enable PCI device and request regions\n");
+ dev_err(dev->class_dev,
+ "Failed to enable PCI device and request regions\n");
return -EIO;
}
- devpriv->BADR0 = pci_resource_start(devpriv->pci_dev, 0);
- devpriv->BADR1 = pci_resource_start(devpriv->pci_dev, 1);
- devpriv->BADR2 = pci_resource_start(devpriv->pci_dev, 2);
- devpriv->BADR3 = pci_resource_start(devpriv->pci_dev, 3);
- devpriv->BADR4 = pci_resource_start(devpriv->pci_dev, 4);
-
- dev_dbg(dev->hw_dev, "devpriv->BADR0 = 0x%lx\n", devpriv->BADR0);
- dev_dbg(dev->hw_dev, "devpriv->BADR1 = 0x%lx\n", devpriv->BADR1);
- dev_dbg(dev->hw_dev, "devpriv->BADR2 = 0x%lx\n", devpriv->BADR2);
- dev_dbg(dev->hw_dev, "devpriv->BADR3 = 0x%lx\n", devpriv->BADR3);
- dev_dbg(dev->hw_dev, "devpriv->BADR4 = 0x%lx\n", devpriv->BADR4);
+ dev->iobase = pci_resource_start(pcidev, 2);
+ devpriv->BADR3 = pci_resource_start(pcidev, 3);
+ iobase_8255 = pci_resource_start(pcidev, 4);
/* Dont support IRQ yet */
/* get irq */
-/* if(request_irq(devpriv->pci_dev->irq, cb_pcimdas_interrupt, IRQF_SHARED, "cb_pcimdas", dev )) */
+/* if(request_irq(pcidev->irq, cb_pcimdas_interrupt, IRQF_SHARED, "cb_pcimdas", dev )) */
/* { */
-/* printk(" unable to allocate irq %u\n", devpriv->pci_dev->irq); */
+/* printk(" unable to allocate irq %u\n", pcidev->irq); */
/* return -EINVAL; */
/* } */
-/* dev->irq = devpriv->pci_dev->irq; */
+/* dev->irq = pcidev->irq; */
/* Initialize dev->board_name */
dev->board_name = thisboard->name;
-/*
- * Allocate the subdevice structures. alloc_subdevice() is a
- * convenient macro defined in comedidev.h.
- */
- if (alloc_subdevices(dev, 3) < 0)
- return -ENOMEM;
+ ret = comedi_alloc_subdevices(dev, 3);
+ if (ret)
+ return ret;
s = dev->subdevices + 0;
/* dev->read_subdev=s; */
@@ -317,54 +263,32 @@ found:
s->subdev_flags = SDF_WRITABLE;
s->n_chan = thisboard->ao_nchan;
s->maxdata = 1 << thisboard->ao_bits;
- s->range_table = &range_unknown; /* ranges are hardware settable, but not software readable. */
+ /* ranges are hardware settable, but not software readable. */
+ s->range_table = &range_unknown;
s->insn_write = &cb_pcimdas_ao_winsn;
s->insn_read = &cb_pcimdas_ao_rinsn;
s = dev->subdevices + 2;
/* digital i/o subdevice */
if (thisboard->has_dio)
- subdev_8255_init(dev, s, NULL, devpriv->BADR4);
+ subdev_8255_init(dev, s, NULL, iobase_8255);
else
s->type = COMEDI_SUBD_UNUSED;
return 1;
}
-/*
- * _detach is called to deconfigure a device. It should deallocate
- * resources.
- * This function is also called when _attach() fails, so it should be
- * careful not to release resources that were not necessarily
- * allocated by _attach(). dev->private and dev->subdevices are
- * deallocated automatically by the core.
- */
-static int cb_pcimdas_detach(struct comedi_device *dev)
+static void cb_pcimdas_detach(struct comedi_device *dev)
{
- if (devpriv) {
- dev_dbg(dev->hw_dev, "devpriv->BADR0 = 0x%lx\n",
- devpriv->BADR0);
- dev_dbg(dev->hw_dev, "devpriv->BADR1 = 0x%lx\n",
- devpriv->BADR1);
- dev_dbg(dev->hw_dev, "devpriv->BADR2 = 0x%lx\n",
- devpriv->BADR2);
- dev_dbg(dev->hw_dev, "devpriv->BADR3 = 0x%lx\n",
- devpriv->BADR3);
- dev_dbg(dev->hw_dev, "devpriv->BADR4 = 0x%lx\n",
- devpriv->BADR4);
- }
+ struct pci_dev *pcidev = comedi_to_pci_dev(dev);
if (dev->irq)
free_irq(dev->irq, dev);
- if (devpriv) {
- if (devpriv->pci_dev) {
- if (devpriv->BADR0)
- comedi_pci_disable(devpriv->pci_dev);
- pci_dev_put(devpriv->pci_dev);
- }
+ if (pcidev) {
+ if (dev->iobase)
+ comedi_pci_disable(pcidev);
+ pci_dev_put(pcidev);
}
-
- return 0;
}
/*
@@ -402,14 +326,17 @@ static int cb_pcimdas_ai_rinsn(struct comedi_device *dev,
outb(0x01, devpriv->BADR3 + 6); /* set bursting off, conversions on */
outb(0x00, devpriv->BADR3 + 7); /* set range to 10V. UP/BP is controlled by a switch on the board */
- /* write channel limits to multiplexer, set Low (bits 0-3) and High (bits 4-7) channels to chan. */
+ /*
+ * write channel limits to multiplexer, set Low (bits 0-3) and
+ * High (bits 4-7) channels to chan.
+ */
chanlims = chan | (chan << 4);
outb(chanlims, devpriv->BADR3 + 0);
/* convert n samples */
for (n = 0; n < insn->n; n++) {
/* trigger conversion */
- outw(0, devpriv->BADR2 + 0);
+ outw(0, dev->iobase + 0);
#define TIMEOUT 1000 /* typically takes 5 loops on a lightly loaded Pentium 100MHz, */
/* this is likely to be 100 loops on a 2GHz machine, so set 1000 as the limit. */
@@ -425,7 +352,7 @@ static int cb_pcimdas_ai_rinsn(struct comedi_device *dev,
return -ETIMEDOUT;
}
/* read data */
- d = inw(devpriv->BADR2 + 0);
+ d = inw(dev->iobase + 0);
/* mangle the data as necessary */
/* d ^= 1<<(thisboard->ai_bits-1); // 16 bit data from ADC, so no mangle needed. */
@@ -449,10 +376,10 @@ static int cb_pcimdas_ao_winsn(struct comedi_device *dev,
for (i = 0; i < insn->n; i++) {
switch (chan) {
case 0:
- outw(data[i] & 0x0FFF, devpriv->BADR2 + DAC0_OFFSET);
+ outw(data[i] & 0x0FFF, dev->iobase + DAC0_OFFSET);
break;
case 1:
- outw(data[i] & 0x0FFF, devpriv->BADR2 + DAC1_OFFSET);
+ outw(data[i] & 0x0FFF, dev->iobase + DAC1_OFFSET);
break;
default:
return -1;
@@ -479,49 +406,37 @@ static int cb_pcimdas_ao_rinsn(struct comedi_device *dev,
return i;
}
-/*
- * A convenient macro that defines init_module() and cleanup_module(),
- * as necessary.
- */
-static int __devinit driver_cb_pcimdas_pci_probe(struct pci_dev *dev,
- const struct pci_device_id
- *ent)
+static struct comedi_driver cb_pcimdas_driver = {
+ .driver_name = "cb_pcimdas",
+ .module = THIS_MODULE,
+ .attach = cb_pcimdas_attach,
+ .detach = cb_pcimdas_detach,
+};
+
+static int __devinit cb_pcimdas_pci_probe(struct pci_dev *dev,
+ const struct pci_device_id *ent)
{
- return comedi_pci_auto_config(dev, driver_cb_pcimdas.driver_name);
+ return comedi_pci_auto_config(dev, &cb_pcimdas_driver);
}
-static void __devexit driver_cb_pcimdas_pci_remove(struct pci_dev *dev)
+static void __devexit cb_pcimdas_pci_remove(struct pci_dev *dev)
{
comedi_pci_auto_unconfig(dev);
}
-static struct pci_driver driver_cb_pcimdas_pci_driver = {
- .id_table = cb_pcimdas_pci_table,
- .probe = &driver_cb_pcimdas_pci_probe,
- .remove = __devexit_p(&driver_cb_pcimdas_pci_remove)
+static DEFINE_PCI_DEVICE_TABLE(cb_pcimdas_pci_table) = {
+ { PCI_DEVICE(PCI_VENDOR_ID_COMPUTERBOARDS, 0x0056) },
+ { 0 }
};
+MODULE_DEVICE_TABLE(pci, cb_pcimdas_pci_table);
-static int __init driver_cb_pcimdas_init_module(void)
-{
- int retval;
-
- retval = comedi_driver_register(&driver_cb_pcimdas);
- if (retval < 0)
- return retval;
-
- driver_cb_pcimdas_pci_driver.name =
- (char *)driver_cb_pcimdas.driver_name;
- return pci_register_driver(&driver_cb_pcimdas_pci_driver);
-}
-
-static void __exit driver_cb_pcimdas_cleanup_module(void)
-{
- pci_unregister_driver(&driver_cb_pcimdas_pci_driver);
- comedi_driver_unregister(&driver_cb_pcimdas);
-}
-
-module_init(driver_cb_pcimdas_init_module);
-module_exit(driver_cb_pcimdas_cleanup_module);
+static struct pci_driver cb_pcimdas_pci_driver = {
+ .name = "cb_pcimdas",
+ .id_table = cb_pcimdas_pci_table,
+ .probe = cb_pcimdas_pci_probe,
+ .remove = __devexit_p(cb_pcimdas_pci_remove),
+};
+module_comedi_pci_driver(cb_pcimdas_driver, cb_pcimdas_pci_driver);
MODULE_AUTHOR("Comedi http://www.comedi.org");
MODULE_DESCRIPTION("Comedi low-level driver");
diff --git a/drivers/staging/comedi/drivers/cb_pcimdda.c b/drivers/staging/comedi/drivers/cb_pcimdda.c
index 40bddfa22220..a80146133c04 100644
--- a/drivers/staging/comedi/drivers/cb_pcimdda.c
+++ b/drivers/staging/comedi/drivers/cb_pcimdda.c
@@ -86,8 +86,6 @@ Configuration Options:
#include "../comedidev.h"
-#include "comedi_pci.h"
-
#include "8255.h"
/* device ids of the cards we support -- currently only 1 card supported */
@@ -140,17 +138,6 @@ static const struct board_struct boards[] = {
#define REG_SZ (thisboard->reg_sz)
#define REGS_BADRINDEX (thisboard->regs_badrindex)
-/* This is used by modprobe to translate PCI IDs to drivers. Should
- * only be used for PCI and ISA-PnP devices */
-/* Please add your PCI vendor ID to comedidev.h, and it will be forwarded
- * upstream. */
-static DEFINE_PCI_DEVICE_TABLE(pci_table) = {
- { PCI_DEVICE(PCI_VENDOR_ID_COMPUTERBOARDS, PCI_ID_PCIM_DDA06_16) },
- {0}
-};
-
-MODULE_DEVICE_TABLE(pci, pci_table);
-
/*
* this structure is for data unique to this hardware driver. If
* several hardware drivers keep similar information in this structure,
@@ -161,7 +148,6 @@ struct board_private_struct {
unsigned long registers; /* set by probe */
unsigned long dio_registers;
char attached_to_8255; /* boolean */
- char attached_successfully; /* boolean */
/* would be useful for a PCI device */
struct pci_dev *pci_dev;
@@ -177,66 +163,6 @@ struct board_private_struct {
*/
#define devpriv ((struct board_private_struct *)dev->private)
-/*
- * The struct comedi_driver structure tells the Comedi core module
- * which functions to call to configure/deconfigure (attach/detach)
- * the board, and also about the kernel module that contains
- * the device code.
- */
-static int attach(struct comedi_device *dev, struct comedi_devconfig *it);
-static int detach(struct comedi_device *dev);
-static struct comedi_driver cb_pcimdda_driver = {
- .driver_name = "cb_pcimdda",
- .module = THIS_MODULE,
- .attach = attach,
- .detach = detach,
-};
-
-MODULE_AUTHOR("Calin A. Culianu <calin@rtlab.org>");
-MODULE_DESCRIPTION("Comedi low-level driver for the Computerboards PCIM-DDA "
- "series. Currently only supports PCIM-DDA06-16 (which "
- "also happens to be the only board in this series. :) ) ");
-MODULE_LICENSE("GPL");
-static int __devinit cb_pcimdda_driver_pci_probe(struct pci_dev *dev,
- const struct pci_device_id
- *ent)
-{
- return comedi_pci_auto_config(dev, cb_pcimdda_driver.driver_name);
-}
-
-static void __devexit cb_pcimdda_driver_pci_remove(struct pci_dev *dev)
-{
- comedi_pci_auto_unconfig(dev);
-}
-
-static struct pci_driver cb_pcimdda_driver_pci_driver = {
- .id_table = pci_table,
- .probe = &cb_pcimdda_driver_pci_probe,
- .remove = __devexit_p(&cb_pcimdda_driver_pci_remove)
-};
-
-static int __init cb_pcimdda_driver_init_module(void)
-{
- int retval;
-
- retval = comedi_driver_register(&cb_pcimdda_driver);
- if (retval < 0)
- return retval;
-
- cb_pcimdda_driver_pci_driver.name =
- (char *)cb_pcimdda_driver.driver_name;
- return pci_register_driver(&cb_pcimdda_driver_pci_driver);
-}
-
-static void __exit cb_pcimdda_driver_cleanup_module(void)
-{
- pci_unregister_driver(&cb_pcimdda_driver_pci_driver);
- comedi_driver_unregister(&cb_pcimdda_driver);
-}
-
-module_init(cb_pcimdda_driver_init_module);
-module_exit(cb_pcimdda_driver_cleanup_module);
-
static int ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data);
static int ao_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
@@ -310,12 +236,9 @@ static int attach(struct comedi_device *dev, struct comedi_devconfig *it)
*/
dev->board_name = thisboard->name;
-/*
- * Allocate the subdevice structures. alloc_subdevice() is a
- * convenient macro defined in comedidev.h.
- */
- if (alloc_subdevices(dev, 2) < 0)
- return -ENOMEM;
+ err = comedi_alloc_subdevices(dev, 2);
+ if (err)
+ return err;
s = dev->subdevices + 0;
@@ -354,44 +277,24 @@ static int attach(struct comedi_device *dev, struct comedi_devconfig *it)
s->type = COMEDI_SUBD_UNUSED;
}
- devpriv->attached_successfully = 1;
-
printk("attached\n");
return 1;
}
-/*
- * _detach is called to deconfigure a device. It should deallocate
- * resources.
- * This function is also called when _attach() fails, so it should be
- * careful not to release resources that were not necessarily
- * allocated by _attach(). dev->private and dev->subdevices are
- * deallocated automatically by the core.
- */
-static int detach(struct comedi_device *dev)
+static void detach(struct comedi_device *dev)
{
if (devpriv) {
-
if (dev->subdevices && devpriv->attached_to_8255) {
- /* de-register us from the 8255 driver */
subdev_8255_cleanup(dev, dev->subdevices + 2);
devpriv->attached_to_8255 = 0;
}
-
if (devpriv->pci_dev) {
if (devpriv->registers)
comedi_pci_disable(devpriv->pci_dev);
pci_dev_put(devpriv->pci_dev);
}
-
- if (devpriv->attached_successfully && thisboard)
- printk("comedi%d: %s: detached\n", dev->minor,
- thisboard->name);
-
}
-
- return 0;
}
static int ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s,
@@ -515,3 +418,41 @@ static int probe(struct comedi_device *dev, const struct comedi_devconfig *it)
"card found at the requested position\n");
return -ENODEV;
}
+
+static struct comedi_driver cb_pcimdda_driver = {
+ .driver_name = "cb_pcimdda",
+ .module = THIS_MODULE,
+ .attach = attach,
+ .detach = detach,
+};
+
+static int __devinit cb_pcimdda_pci_probe(struct pci_dev *dev,
+ const struct pci_device_id *ent)
+{
+ return comedi_pci_auto_config(dev, &cb_pcimdda_driver);
+}
+
+static void __devexit cb_pcimdda_pci_remove(struct pci_dev *dev)
+{
+ comedi_pci_auto_unconfig(dev);
+}
+
+static DEFINE_PCI_DEVICE_TABLE(cb_pcimdda_pci_table) = {
+ { PCI_DEVICE(PCI_VENDOR_ID_COMPUTERBOARDS, PCI_ID_PCIM_DDA06_16) },
+ { 0 }
+};
+MODULE_DEVICE_TABLE(pci, cb_pcimdda_pci_table);
+
+static struct pci_driver cb_pcimdda_driver_pci_driver = {
+ .name = "cb_pcimdda",
+ .id_table = cb_pcimdda_pci_table,
+ .probe = cb_pcimdda_pci_probe,
+ .remove = __devexit_p(cb_pcimdda_pci_remove),
+};
+module_comedi_pci_driver(cb_pcimdda_driver, cb_pcimdda_driver_pci_driver);
+
+MODULE_AUTHOR("Calin A. Culianu <calin@rtlab.org>");
+MODULE_DESCRIPTION("Comedi low-level driver for the Computerboards PCIM-DDA "
+ "series. Currently only supports PCIM-DDA06-16 (which "
+ "also happens to be the only board in this series. :) ) ");
+MODULE_LICENSE("GPL");
diff --git a/drivers/staging/comedi/drivers/comedi_bond.c b/drivers/staging/comedi/drivers/comedi_bond.c
index d8aefb23d6b9..5ed324c4f620 100644
--- a/drivers/staging/comedi/drivers/comedi_bond.c
+++ b/drivers/staging/comedi/drivers/comedi_bond.c
@@ -60,7 +60,6 @@ Configuration Options:
#define MAX_CHANS 256
#define MODULE_NAME "comedi_bond"
-MODULE_LICENSE("GPL");
#ifndef STR
# define STR1(x) #x
# define STR(x) STR1(x)
@@ -79,10 +78,6 @@ MODULE_PARM_DESC(debug, "If true, print extra cryptic debugging output useful"
} while (0)
#define WARNING(x...) printk(KERN_WARNING MODULE_NAME ": WARNING: "x)
#define ERROR(x...) printk(KERN_ERR MODULE_NAME ": INTERNAL ERROR: "x)
-MODULE_AUTHOR("Calin A. Culianu");
-MODULE_DESCRIPTION(MODULE_NAME "A driver for COMEDI to bond multiple COMEDI "
- "devices together as one. In the words of John Lennon: "
- "'And the world will live as one...'");
/*
* Board descriptions for two imaginary boards. Describing the
@@ -93,12 +88,6 @@ struct BondingBoard {
const char *name;
};
-static const struct BondingBoard bondingBoards[] = {
- {
- .name = MODULE_NAME,
- },
-};
-
/*
* Useful for shorthand access to the particular board structure
*/
@@ -133,129 +122,6 @@ struct Private {
*/
#define devpriv ((struct Private *)dev->private)
-/*
- * The struct comedi_driver structure tells the Comedi core module
- * which functions to call to configure/deconfigure (attach/detach)
- * the board, and also about the kernel module that contains
- * the device code.
- */
-static int bonding_attach(struct comedi_device *dev,
- struct comedi_devconfig *it);
-static int bonding_detach(struct comedi_device *dev);
-/** Build Private array of all devices.. */
-static int doDevConfig(struct comedi_device *dev, struct comedi_devconfig *it);
-static void doDevUnconfig(struct comedi_device *dev);
-/* Ugly implementation of realloc that always copies memory around -- I'm lazy,
- * what can I say? I like to do wasteful memcopies.. :) */
-static void *Realloc(const void *ptr, size_t len, size_t old_len);
-
-static struct comedi_driver driver_bonding = {
- .driver_name = MODULE_NAME,
- .module = THIS_MODULE,
- .attach = bonding_attach,
- .detach = bonding_detach,
- /* It is not necessary to implement the following members if you are
- * writing a driver for a ISA PnP or PCI card */
- /* Most drivers will support multiple types of boards by
- * having an array of board structures. These were defined
- * in skel_boards[] above. Note that the element 'name'
- * was first in the structure -- Comedi uses this fact to
- * extract the name of the board without knowing any details
- * about the structure except for its length.
- * When a device is attached (by comedi_config), the name
- * of the device is given to Comedi, and Comedi tries to
- * match it by going through the list of board names. If
- * there is a match, the address of the pointer is put
- * into dev->board_ptr and driver->attach() is called.
- *
- * Note that these are not necessary if you can determine
- * the type of board in software. ISA PnP, PCI, and PCMCIA
- * devices are such boards.
- */
- .board_name = &bondingBoards[0].name,
- .offset = sizeof(struct BondingBoard),
- .num_names = ARRAY_SIZE(bondingBoards),
-};
-
-static int bonding_dio_insn_bits(struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data);
-static int bonding_dio_insn_config(struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_insn *insn,
- unsigned int *data);
-
-/*
- * Attach is called by the Comedi core to configure the driver
- * for a particular board. If you specified a board_name array
- * in the driver structure, dev->board_ptr contains that
- * address.
- */
-static int bonding_attach(struct comedi_device *dev,
- struct comedi_devconfig *it)
-{
- struct comedi_subdevice *s;
-
- LOG_MSG("comedi%d\n", dev->minor);
-
- /*
- * Allocate the private structure area. alloc_private() is a
- * convenient macro defined in comedidev.h.
- */
- if (alloc_private(dev, sizeof(struct Private)) < 0)
- return -ENOMEM;
-
- /*
- * Setup our bonding from config params.. sets up our Private struct..
- */
- if (!doDevConfig(dev, it))
- return -EINVAL;
-
- /*
- * Initialize dev->board_name. Note that we can use the "thisboard"
- * macro now, since we just initialized it in the last line.
- */
- dev->board_name = devpriv->name;
-
- /*
- * Allocate the subdevice structures. alloc_subdevice() is a
- * convenient macro defined in comedidev.h.
- */
- if (alloc_subdevices(dev, 1) < 0)
- return -ENOMEM;
-
- s = dev->subdevices + 0;
- s->type = COMEDI_SUBD_DIO;
- s->subdev_flags = SDF_READABLE | SDF_WRITABLE;
- s->n_chan = devpriv->nchans;
- s->maxdata = 1;
- s->range_table = &range_digital;
- s->insn_bits = bonding_dio_insn_bits;
- s->insn_config = bonding_dio_insn_config;
-
- LOG_MSG("attached with %u DIO channels coming from %u different "
- "subdevices all bonded together. "
- "John Lennon would be proud!\n",
- devpriv->nchans, devpriv->ndevs);
-
- return 1;
-}
-
-/*
- * _detach is called to deconfigure a device. It should deallocate
- * resources.
- * This function is also called when _attach() fails, so it should be
- * careful not to release resources that were not necessarily
- * allocated by _attach(). dev->private and dev->subdevices are
- * deallocated automatically by the core.
- */
-static int bonding_detach(struct comedi_device *dev)
-{
- LOG_MSG("comedi%d: remove\n", dev->minor);
- doDevUnconfig(dev);
- return 0;
-}
-
/* DIO devices are slightly special. Although it is possible to
* implement the insn_read/insn_write interface, it is much more
* useful to applications if you implement the insn_bits interface.
@@ -267,8 +133,6 @@ static int bonding_dio_insn_bits(struct comedi_device *dev,
{
#define LSAMPL_BITS (sizeof(unsigned int)*8)
unsigned nchans = LSAMPL_BITS, num_done = 0, i;
- if (insn->n != 2)
- return -EINVAL;
if (devpriv->nchans < nchans)
nchans = devpriv->nchans;
@@ -466,7 +330,55 @@ static int doDevConfig(struct comedi_device *dev, struct comedi_devconfig *it)
return 1;
}
-static void doDevUnconfig(struct comedi_device *dev)
+static int bonding_attach(struct comedi_device *dev,
+ struct comedi_devconfig *it)
+{
+ struct comedi_subdevice *s;
+ int ret;
+
+ LOG_MSG("comedi%d\n", dev->minor);
+
+ /*
+ * Allocate the private structure area. alloc_private() is a
+ * convenient macro defined in comedidev.h.
+ */
+ if (alloc_private(dev, sizeof(struct Private)) < 0)
+ return -ENOMEM;
+
+ /*
+ * Setup our bonding from config params.. sets up our Private struct..
+ */
+ if (!doDevConfig(dev, it))
+ return -EINVAL;
+
+ /*
+ * Initialize dev->board_name. Note that we can use the "thisboard"
+ * macro now, since we just initialized it in the last line.
+ */
+ dev->board_name = devpriv->name;
+
+ ret = comedi_alloc_subdevices(dev, 1);
+ if (ret)
+ return ret;
+
+ s = dev->subdevices + 0;
+ s->type = COMEDI_SUBD_DIO;
+ s->subdev_flags = SDF_READABLE | SDF_WRITABLE;
+ s->n_chan = devpriv->nchans;
+ s->maxdata = 1;
+ s->range_table = &range_digital;
+ s->insn_bits = bonding_dio_insn_bits;
+ s->insn_config = bonding_dio_insn_config;
+
+ LOG_MSG("attached with %u DIO channels coming from %u different "
+ "subdevices all bonded together. "
+ "John Lennon would be proud!\n",
+ devpriv->nchans, devpriv->ndevs);
+
+ return 1;
+}
+
+static void bonding_detach(struct comedi_device *dev)
{
unsigned long devs_closed = 0;
@@ -490,15 +402,25 @@ static void doDevUnconfig(struct comedi_device *dev)
}
}
-static int __init init(void)
-{
- return comedi_driver_register(&driver_bonding);
-}
+static const struct BondingBoard bondingBoards[] = {
+ {
+ .name = "comedi_bond",
+ },
+};
-static void __exit cleanup(void)
-{
- comedi_driver_unregister(&driver_bonding);
-}
+static struct comedi_driver bonding_driver = {
+ .driver_name = "comedi_bond",
+ .module = THIS_MODULE,
+ .attach = bonding_attach,
+ .detach = bonding_detach,
+ .board_name = &bondingBoards[0].name,
+ .offset = sizeof(struct BondingBoard),
+ .num_names = ARRAY_SIZE(bondingBoards),
+};
+module_comedi_driver(bonding_driver);
-module_init(init);
-module_exit(cleanup);
+MODULE_AUTHOR("Calin A. Culianu");
+MODULE_DESCRIPTION(MODULE_NAME "A driver for COMEDI to bond multiple COMEDI "
+ "devices together as one. In the words of John Lennon: "
+ "'And the world will live as one...'");
+MODULE_LICENSE("GPL");
diff --git a/drivers/staging/comedi/drivers/comedi_parport.c b/drivers/staging/comedi/drivers/comedi_parport.c
index 21d834dd92b6..9a63cac2434a 100644
--- a/drivers/staging/comedi/drivers/comedi_parport.c
+++ b/drivers/staging/comedi/drivers/comedi_parport.c
@@ -91,29 +91,6 @@ pin, which can be used to wake up tasks.
#define PARPORT_B 1
#define PARPORT_C 2
-static int parport_attach(struct comedi_device *dev,
- struct comedi_devconfig *it);
-static int parport_detach(struct comedi_device *dev);
-static struct comedi_driver driver_parport = {
- .driver_name = "comedi_parport",
- .module = THIS_MODULE,
- .attach = parport_attach,
- .detach = parport_detach,
-};
-
-static int __init driver_parport_init_module(void)
-{
- return comedi_driver_register(&driver_parport);
-}
-
-static void __exit driver_parport_cleanup_module(void)
-{
- comedi_driver_unregister(&driver_parport);
-}
-
-module_init(driver_parport_init_module);
-module_exit(driver_parport_cleanup_module);
-
struct parport_private {
unsigned int a_data;
unsigned int c_data;
@@ -133,7 +110,7 @@ static int parport_insn_a(struct comedi_device *dev, struct comedi_subdevice *s,
data[1] = inb(dev->iobase + PARPORT_A);
- return 2;
+ return insn->n;
}
static int parport_insn_config_a(struct comedi_device *dev,
@@ -162,7 +139,7 @@ static int parport_insn_b(struct comedi_device *dev, struct comedi_subdevice *s,
data[1] = (inb(dev->iobase + PARPORT_B) >> 3);
- return 2;
+ return insn->n;
}
static int parport_insn_c(struct comedi_device *dev, struct comedi_subdevice *s,
@@ -178,18 +155,15 @@ static int parport_insn_c(struct comedi_device *dev, struct comedi_subdevice *s,
data[1] = devpriv->c_data & 0xf;
- return 2;
+ return insn->n;
}
static int parport_intr_insn(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
- if (insn->n < 1)
- return -EINVAL;
-
data[1] = 0;
- return 2;
+ return insn->n;
}
static int parport_intr_cmdtest(struct comedi_device *dev,
@@ -338,9 +312,10 @@ static int parport_attach(struct comedi_device *dev,
}
dev->board_name = "parport";
- ret = alloc_subdevices(dev, 4);
- if (ret < 0)
+ ret = comedi_alloc_subdevices(dev, 4);
+ if (ret)
return ret;
+
ret = alloc_private(dev, sizeof(struct parport_private));
if (ret < 0)
return ret;
@@ -395,19 +370,22 @@ static int parport_attach(struct comedi_device *dev,
return 1;
}
-static int parport_detach(struct comedi_device *dev)
+static void parport_detach(struct comedi_device *dev)
{
- printk(KERN_INFO "comedi%d: parport: remove\n", dev->minor);
-
if (dev->iobase)
release_region(dev->iobase, PARPORT_SIZE);
-
if (dev->irq)
free_irq(dev->irq, dev);
-
- return 0;
}
+static struct comedi_driver parport_driver = {
+ .driver_name = "comedi_parport",
+ .module = THIS_MODULE,
+ .attach = parport_attach,
+ .detach = parport_detach,
+};
+module_comedi_driver(parport_driver);
+
MODULE_AUTHOR("Comedi http://www.comedi.org");
MODULE_DESCRIPTION("Comedi low-level driver");
MODULE_LICENSE("GPL");
diff --git a/drivers/staging/comedi/drivers/comedi_pci.h b/drivers/staging/comedi/drivers/comedi_pci.h
deleted file mode 100644
index c14a036a0536..000000000000
--- a/drivers/staging/comedi/drivers/comedi_pci.h
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- comedi/drivers/comedi_pci.h
- Various PCI functions for drivers.
-
- Copyright (C) 2007 MEV Ltd. <http://www.mev.co.uk/>
-
- COMEDI - Linux Control and Measurement Device Interface
- Copyright (C) 2000 David A. Schleef <ds@schleef.org>
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
-*/
-
-#ifndef _COMEDI_PCI_H_
-#define _COMEDI_PCI_H_
-
-#include <linux/pci.h>
-
-/*
- * Enable the PCI device and request the regions.
- */
-static inline int comedi_pci_enable(struct pci_dev *pdev, const char *res_name)
-{
- int rc;
-
- rc = pci_enable_device(pdev);
- if (rc < 0)
- return rc;
-
- rc = pci_request_regions(pdev, res_name);
- if (rc < 0)
- pci_disable_device(pdev);
-
- return rc;
-}
-
-/*
- * Release the regions and disable the PCI device.
- *
- * This must be matched with a previous successful call to comedi_pci_enable().
- */
-static inline void comedi_pci_disable(struct pci_dev *pdev)
-{
- pci_release_regions(pdev);
- pci_disable_device(pdev);
-}
-
-#endif
diff --git a/drivers/staging/comedi/drivers/comedi_test.c b/drivers/staging/comedi/drivers/comedi_test.c
index a804742b8022..523a809708b7 100644
--- a/drivers/staging/comedi/drivers/comedi_test.c
+++ b/drivers/staging/comedi/drivers/comedi_test.c
@@ -67,17 +67,6 @@ struct waveform_board {
#define N_CHANS 8
-static const struct waveform_board waveform_boards[] = {
- {
- .name = "comedi_test",
- .ai_chans = N_CHANS,
- .ai_bits = 16,
- .have_dio = 0,
- },
-};
-
-#define thisboard ((const struct waveform_board *)dev->board_ptr)
-
/* Data unique to this driver */
struct waveform_private {
struct timer_list timer;
@@ -94,54 +83,6 @@ struct waveform_private {
};
#define devpriv ((struct waveform_private *)dev->private)
-static int waveform_attach(struct comedi_device *dev,
- struct comedi_devconfig *it);
-static int waveform_detach(struct comedi_device *dev);
-static struct comedi_driver driver_waveform = {
- .driver_name = "comedi_test",
- .module = THIS_MODULE,
- .attach = waveform_attach,
- .detach = waveform_detach,
- .board_name = &waveform_boards[0].name,
- .offset = sizeof(struct waveform_board),
- .num_names = ARRAY_SIZE(waveform_boards),
-};
-
-static int __init driver_waveform_init_module(void)
-{
- return comedi_driver_register(&driver_waveform);
-}
-
-static void __exit driver_waveform_cleanup_module(void)
-{
- comedi_driver_unregister(&driver_waveform);
-}
-
-module_init(driver_waveform_init_module);
-module_exit(driver_waveform_cleanup_module);
-
-static int waveform_ai_cmdtest(struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_cmd *cmd);
-static int waveform_ai_cmd(struct comedi_device *dev,
- struct comedi_subdevice *s);
-static int waveform_ai_cancel(struct comedi_device *dev,
- struct comedi_subdevice *s);
-static int waveform_ai_insn_read(struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data);
-static int waveform_ao_insn_write(struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data);
-static short fake_sawtooth(struct comedi_device *dev, unsigned int range,
- unsigned long current_time);
-static short fake_squarewave(struct comedi_device *dev, unsigned int range,
- unsigned long current_time);
-static short fake_flatline(struct comedi_device *dev, unsigned int range,
- unsigned long current_time);
-static short fake_waveform(struct comedi_device *dev, unsigned int channel,
- unsigned int range, unsigned long current_time);
-
/* 1000 nanosec in a microsec */
static const int nano_per_micro = 1000;
@@ -154,6 +95,78 @@ static const struct comedi_lrange waveform_ai_ranges = {
}
};
+static short fake_sawtooth(struct comedi_device *dev, unsigned int range_index,
+ unsigned long current_time)
+{
+ struct comedi_subdevice *s = dev->read_subdev;
+ unsigned int offset = s->maxdata / 2;
+ u64 value;
+ const struct comedi_krange *krange =
+ &s->range_table->range[range_index];
+ u64 binary_amplitude;
+
+ binary_amplitude = s->maxdata;
+ binary_amplitude *= devpriv->uvolt_amplitude;
+ do_div(binary_amplitude, krange->max - krange->min);
+
+ current_time %= devpriv->usec_period;
+ value = current_time;
+ value *= binary_amplitude * 2;
+ do_div(value, devpriv->usec_period);
+ value -= binary_amplitude; /* get rid of sawtooth's dc offset */
+
+ return offset + value;
+}
+
+static short fake_squarewave(struct comedi_device *dev,
+ unsigned int range_index,
+ unsigned long current_time)
+{
+ struct comedi_subdevice *s = dev->read_subdev;
+ unsigned int offset = s->maxdata / 2;
+ u64 value;
+ const struct comedi_krange *krange =
+ &s->range_table->range[range_index];
+ current_time %= devpriv->usec_period;
+
+ value = s->maxdata;
+ value *= devpriv->uvolt_amplitude;
+ do_div(value, krange->max - krange->min);
+
+ if (current_time < devpriv->usec_period / 2)
+ value *= -1;
+
+ return offset + value;
+}
+
+static short fake_flatline(struct comedi_device *dev, unsigned int range_index,
+ unsigned long current_time)
+{
+ return dev->read_subdev->maxdata / 2;
+}
+
+/* generates a different waveform depending on what channel is read */
+static short fake_waveform(struct comedi_device *dev, unsigned int channel,
+ unsigned int range, unsigned long current_time)
+{
+ enum {
+ SAWTOOTH_CHAN,
+ SQUARE_CHAN,
+ };
+ switch (channel) {
+ case SAWTOOTH_CHAN:
+ return fake_sawtooth(dev, range, current_time);
+ break;
+ case SQUARE_CHAN:
+ return fake_squarewave(dev, range, current_time);
+ break;
+ default:
+ break;
+ }
+
+ return fake_flatline(dev, range, current_time);
+}
+
/*
This is the background routine used to generate arbitrary data.
It should run in the background; therefore it is scheduled by
@@ -217,84 +230,6 @@ static void waveform_ai_interrupt(unsigned long arg)
comedi_event(dev, dev->read_subdev);
}
-static int waveform_attach(struct comedi_device *dev,
- struct comedi_devconfig *it)
-{
- struct comedi_subdevice *s;
- int amplitude = it->options[0];
- int period = it->options[1];
- int i;
-
- dev->board_name = thisboard->name;
-
- if (alloc_private(dev, sizeof(struct waveform_private)) < 0)
- return -ENOMEM;
-
- /* set default amplitude and period */
- if (amplitude <= 0)
- amplitude = 1000000; /* 1 volt */
- if (period <= 0)
- period = 100000; /* 0.1 sec */
-
- devpriv->uvolt_amplitude = amplitude;
- devpriv->usec_period = period;
-
- dev->n_subdevices = 2;
- if (alloc_subdevices(dev, dev->n_subdevices) < 0)
- return -ENOMEM;
-
- s = dev->subdevices + 0;
- dev->read_subdev = s;
- /* analog input subdevice */
- s->type = COMEDI_SUBD_AI;
- s->subdev_flags = SDF_READABLE | SDF_GROUND | SDF_CMD_READ;
- s->n_chan = thisboard->ai_chans;
- s->maxdata = (1 << thisboard->ai_bits) - 1;
- s->range_table = &waveform_ai_ranges;
- s->len_chanlist = s->n_chan * 2;
- s->insn_read = waveform_ai_insn_read;
- s->do_cmd = waveform_ai_cmd;
- s->do_cmdtest = waveform_ai_cmdtest;
- s->cancel = waveform_ai_cancel;
-
- s = dev->subdevices + 1;
- dev->write_subdev = s;
- /* analog output subdevice (loopback) */
- s->type = COMEDI_SUBD_AO;
- s->subdev_flags = SDF_WRITEABLE | SDF_GROUND;
- s->n_chan = thisboard->ai_chans;
- s->maxdata = (1 << thisboard->ai_bits) - 1;
- s->range_table = &waveform_ai_ranges;
- s->len_chanlist = s->n_chan * 2;
- s->insn_write = waveform_ao_insn_write;
- s->do_cmd = NULL;
- s->do_cmdtest = NULL;
- s->cancel = NULL;
-
- /* Our default loopback value is just a 0V flatline */
- for (i = 0; i < s->n_chan; i++)
- devpriv->ao_loopbacks[i] = s->maxdata / 2;
-
- init_timer(&(devpriv->timer));
- devpriv->timer.function = waveform_ai_interrupt;
- devpriv->timer.data = (unsigned long)dev;
-
- printk(KERN_INFO "comedi%d: comedi_test: "
- "%i microvolt, %li microsecond waveform attached\n", dev->minor,
- devpriv->uvolt_amplitude, devpriv->usec_period);
- return 1;
-}
-
-static int waveform_detach(struct comedi_device *dev)
-{
- printk("comedi%d: comedi_test: remove\n", dev->minor);
-
- if (dev->private)
- waveform_ai_cancel(dev, dev->read_subdev);
-
- return 0;
-}
-
static int waveform_ai_cmdtest(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_cmd *cmd)
@@ -465,78 +400,6 @@ static int waveform_ai_cancel(struct comedi_device *dev,
return 0;
}
-static short fake_sawtooth(struct comedi_device *dev, unsigned int range_index,
- unsigned long current_time)
-{
- struct comedi_subdevice *s = dev->read_subdev;
- unsigned int offset = s->maxdata / 2;
- u64 value;
- const struct comedi_krange *krange =
- &s->range_table->range[range_index];
- u64 binary_amplitude;
-
- binary_amplitude = s->maxdata;
- binary_amplitude *= devpriv->uvolt_amplitude;
- do_div(binary_amplitude, krange->max - krange->min);
-
- current_time %= devpriv->usec_period;
- value = current_time;
- value *= binary_amplitude * 2;
- do_div(value, devpriv->usec_period);
- value -= binary_amplitude; /* get rid of sawtooth's dc offset */
-
- return offset + value;
-}
-
-static short fake_squarewave(struct comedi_device *dev,
- unsigned int range_index,
- unsigned long current_time)
-{
- struct comedi_subdevice *s = dev->read_subdev;
- unsigned int offset = s->maxdata / 2;
- u64 value;
- const struct comedi_krange *krange =
- &s->range_table->range[range_index];
- current_time %= devpriv->usec_period;
-
- value = s->maxdata;
- value *= devpriv->uvolt_amplitude;
- do_div(value, krange->max - krange->min);
-
- if (current_time < devpriv->usec_period / 2)
- value *= -1;
-
- return offset + value;
-}
-
-static short fake_flatline(struct comedi_device *dev, unsigned int range_index,
- unsigned long current_time)
-{
- return dev->read_subdev->maxdata / 2;
-}
-
-/* generates a different waveform depending on what channel is read */
-static short fake_waveform(struct comedi_device *dev, unsigned int channel,
- unsigned int range, unsigned long current_time)
-{
- enum {
- SAWTOOTH_CHAN,
- SQUARE_CHAN,
- };
- switch (channel) {
- case SAWTOOTH_CHAN:
- return fake_sawtooth(dev, range, current_time);
- break;
- case SQUARE_CHAN:
- return fake_squarewave(dev, range, current_time);
- break;
- default:
- break;
- }
-
- return fake_flatline(dev, range, current_time);
-}
-
static int waveform_ai_insn_read(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
@@ -561,6 +424,102 @@ static int waveform_ao_insn_write(struct comedi_device *dev,
return insn->n;
}
+static int waveform_attach(struct comedi_device *dev,
+ struct comedi_devconfig *it)
+{
+ const struct waveform_board *board = comedi_board(dev);
+ struct comedi_subdevice *s;
+ int amplitude = it->options[0];
+ int period = it->options[1];
+ int i;
+ int ret;
+
+ dev->board_name = board->name;
+
+ if (alloc_private(dev, sizeof(struct waveform_private)) < 0)
+ return -ENOMEM;
+
+ /* set default amplitude and period */
+ if (amplitude <= 0)
+ amplitude = 1000000; /* 1 volt */
+ if (period <= 0)
+ period = 100000; /* 0.1 sec */
+
+ devpriv->uvolt_amplitude = amplitude;
+ devpriv->usec_period = period;
+
+ ret = comedi_alloc_subdevices(dev, 2);
+ if (ret)
+ return ret;
+
+ s = dev->subdevices + 0;
+ dev->read_subdev = s;
+ /* analog input subdevice */
+ s->type = COMEDI_SUBD_AI;
+ s->subdev_flags = SDF_READABLE | SDF_GROUND | SDF_CMD_READ;
+ s->n_chan = board->ai_chans;
+ s->maxdata = (1 << board->ai_bits) - 1;
+ s->range_table = &waveform_ai_ranges;
+ s->len_chanlist = s->n_chan * 2;
+ s->insn_read = waveform_ai_insn_read;
+ s->do_cmd = waveform_ai_cmd;
+ s->do_cmdtest = waveform_ai_cmdtest;
+ s->cancel = waveform_ai_cancel;
+
+ s = dev->subdevices + 1;
+ dev->write_subdev = s;
+ /* analog output subdevice (loopback) */
+ s->type = COMEDI_SUBD_AO;
+ s->subdev_flags = SDF_WRITEABLE | SDF_GROUND;
+ s->n_chan = board->ai_chans;
+ s->maxdata = (1 << board->ai_bits) - 1;
+ s->range_table = &waveform_ai_ranges;
+ s->len_chanlist = s->n_chan * 2;
+ s->insn_write = waveform_ao_insn_write;
+ s->do_cmd = NULL;
+ s->do_cmdtest = NULL;
+ s->cancel = NULL;
+
+ /* Our default loopback value is just a 0V flatline */
+ for (i = 0; i < s->n_chan; i++)
+ devpriv->ao_loopbacks[i] = s->maxdata / 2;
+
+ init_timer(&(devpriv->timer));
+ devpriv->timer.function = waveform_ai_interrupt;
+ devpriv->timer.data = (unsigned long)dev;
+
+ printk(KERN_INFO "comedi%d: comedi_test: "
+ "%i microvolt, %li microsecond waveform attached\n", dev->minor,
+ devpriv->uvolt_amplitude, devpriv->usec_period);
+ return 1;
+}
+
+static void waveform_detach(struct comedi_device *dev)
+{
+ if (dev->private)
+ waveform_ai_cancel(dev, dev->read_subdev);
+}
+
+static const struct waveform_board waveform_boards[] = {
+ {
+ .name = "comedi_test",
+ .ai_chans = N_CHANS,
+ .ai_bits = 16,
+ .have_dio = 0,
+ },
+};
+
+static struct comedi_driver waveform_driver = {
+ .driver_name = "comedi_test",
+ .module = THIS_MODULE,
+ .attach = waveform_attach,
+ .detach = waveform_detach,
+ .board_name = &waveform_boards[0].name,
+ .offset = sizeof(struct waveform_board),
+ .num_names = ARRAY_SIZE(waveform_boards),
+};
+module_comedi_driver(waveform_driver);
+
MODULE_AUTHOR("Comedi http://www.comedi.org");
MODULE_DESCRIPTION("Comedi low-level driver");
MODULE_LICENSE("GPL");
diff --git a/drivers/staging/comedi/drivers/contec_pci_dio.c b/drivers/staging/comedi/drivers/contec_pci_dio.c
index e3659bd6e85e..944cfeeb2b2d 100644
--- a/drivers/staging/comedi/drivers/contec_pci_dio.c
+++ b/drivers/staging/comedi/drivers/contec_pci_dio.c
@@ -36,8 +36,6 @@ Configuration Options:
#include "../comedidev.h"
-#include "comedi_pci.h"
-
enum contec_model {
PIO1616L = 0,
};
@@ -56,215 +54,157 @@ static const struct contec_board contec_boards[] = {
};
#define PCI_DEVICE_ID_PIO1616L 0x8172
-static DEFINE_PCI_DEVICE_TABLE(contec_pci_table) = {
- { PCI_DEVICE(PCI_VENDOR_ID_CONTEC, PCI_DEVICE_ID_PIO1616L),
- .driver_data = PIO1616L },
- {0}
-};
-
-MODULE_DEVICE_TABLE(pci, contec_pci_table);
#define thisboard ((const struct contec_board *)dev->board_ptr)
-struct contec_private {
- int data;
-
- struct pci_dev *pci_dev;
-
-};
-
-#define devpriv ((struct contec_private *)dev->private)
-
-static int contec_attach(struct comedi_device *dev,
- struct comedi_devconfig *it);
-static int contec_detach(struct comedi_device *dev);
-static struct comedi_driver driver_contec = {
- .driver_name = "contec_pci_dio",
- .module = THIS_MODULE,
- .attach = contec_attach,
- .detach = contec_detach,
-};
-
-/* Classic digital IO */
-static int contec_di_insn_bits(struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data);
static int contec_do_insn_bits(struct comedi_device *dev,
struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data);
+ struct comedi_insn *insn, unsigned int *data)
+{
-#if 0
-static int contec_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
- struct comedi_cmd *cmd);
+ dev_dbg(dev->class_dev, "contec_do_insn_bits called\n");
+ dev_dbg(dev->class_dev, "data: %d %d\n", data[0], data[1]);
-static int contec_ns_to_timer(unsigned int *ns, int round);
-#endif
+ if (data[0]) {
+ s->state &= ~data[0];
+ s->state |= data[0] & data[1];
+ dev_dbg(dev->class_dev, "out: %d on %lx\n", s->state,
+ dev->iobase + thisboard->out_offs);
+ outw(s->state, dev->iobase + thisboard->out_offs);
+ }
+ return insn->n;
+}
-static int contec_attach(struct comedi_device *dev, struct comedi_devconfig *it)
+static int contec_di_insn_bits(struct comedi_device *dev,
+ struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
- struct pci_dev *pcidev = NULL;
- struct comedi_subdevice *s;
- printk("comedi%d: contec: ", dev->minor);
+ dev_dbg(dev->class_dev, "contec_di_insn_bits called\n");
+ dev_dbg(dev->class_dev, "data: %d %d\n", data[0], data[1]);
- dev->board_name = thisboard->name;
+ data[1] = inw(dev->iobase + thisboard->in_offs);
- if (alloc_private(dev, sizeof(struct contec_private)) < 0)
- return -ENOMEM;
+ return insn->n;
+}
- if (alloc_subdevices(dev, 2) < 0)
- return -ENOMEM;
+static struct pci_dev *contec_find_pci_dev(struct comedi_device *dev,
+ struct comedi_devconfig *it)
+{
+ struct pci_dev *pcidev = NULL;
+ int bus = it->options[0];
+ int slot = it->options[1];
for_each_pci_dev(pcidev) {
- if (pcidev->vendor == PCI_VENDOR_ID_CONTEC &&
- pcidev->device == PCI_DEVICE_ID_PIO1616L) {
- if (it->options[0] || it->options[1]) {
- /* Check bus and slot. */
- if (it->options[0] != pcidev->bus->number ||
- it->options[1] != PCI_SLOT(pcidev->devfn)) {
- continue;
- }
- }
- devpriv->pci_dev = pcidev;
- if (comedi_pci_enable(pcidev, "contec_pci_dio")) {
- printk
- ("error enabling PCI device and request regions!\n");
- return -EIO;
- }
- dev->iobase = pci_resource_start(pcidev, 0);
- printk(" base addr %lx ", dev->iobase);
-
- dev->board_ptr = contec_boards + 0;
-
- s = dev->subdevices + 0;
-
- s->type = COMEDI_SUBD_DI;
- s->subdev_flags = SDF_READABLE;
- s->n_chan = 16;
- s->maxdata = 1;
- s->range_table = &range_digital;
- s->insn_bits = contec_di_insn_bits;
-
- s = dev->subdevices + 1;
- s->type = COMEDI_SUBD_DO;
- s->subdev_flags = SDF_WRITABLE;
- s->n_chan = 16;
- s->maxdata = 1;
- s->range_table = &range_digital;
- s->insn_bits = contec_do_insn_bits;
-
- printk("attached\n");
-
- return 1;
+ if (bus || slot) {
+ if (bus != pcidev->bus->number ||
+ slot != PCI_SLOT(pcidev->devfn))
+ continue;
}
- }
-
- printk("card not present!\n");
-
- return -EIO;
-}
+ if (pcidev->vendor != PCI_VENDOR_ID_CONTEC ||
+ pcidev->device != PCI_DEVICE_ID_PIO1616L)
+ continue;
-static int contec_detach(struct comedi_device *dev)
-{
- printk("comedi%d: contec: remove\n", dev->minor);
-
- if (devpriv && devpriv->pci_dev) {
- if (dev->iobase)
- comedi_pci_disable(devpriv->pci_dev);
- pci_dev_put(devpriv->pci_dev);
+ dev->board_ptr = contec_boards + 0;
+ return pcidev;
}
-
- return 0;
+ dev_err(dev->class_dev,
+ "No supported board found! (req. bus %d, slot %d)\n",
+ bus, slot);
+ return NULL;
}
-#if 0
-static int contec_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
- struct comedi_cmd *cmd)
+static int contec_attach(struct comedi_device *dev, struct comedi_devconfig *it)
{
- printk("contec_cmdtest called\n");
- return 0;
-}
+ struct pci_dev *pcidev;
+ struct comedi_subdevice *s;
+ int ret;
-static int contec_ns_to_timer(unsigned int *ns, int round)
-{
- return *ns;
-}
-#endif
+ printk("comedi%d: contec: ", dev->minor);
-static int contec_do_insn_bits(struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data)
-{
+ dev->board_name = thisboard->name;
- dev_dbg(dev->hw_dev, "contec_do_insn_bits called\n");
- dev_dbg(dev->hw_dev, "data: %d %d\n", data[0], data[1]);
+ ret = comedi_alloc_subdevices(dev, 2);
+ if (ret)
+ return ret;
- if (insn->n != 2)
- return -EINVAL;
+ pcidev = contec_find_pci_dev(dev, it);
+ if (!pcidev)
+ return -EIO;
+ comedi_set_hw_dev(dev, &pcidev->dev);
- if (data[0]) {
- s->state &= ~data[0];
- s->state |= data[0] & data[1];
- dev_dbg(dev->hw_dev, "out: %d on %lx\n", s->state,
- dev->iobase + thisboard->out_offs);
- outw(s->state, dev->iobase + thisboard->out_offs);
+ if (comedi_pci_enable(pcidev, "contec_pci_dio")) {
+ printk("error enabling PCI device and request regions!\n");
+ return -EIO;
}
- return 2;
-}
+ dev->iobase = pci_resource_start(pcidev, 0);
+ printk(" base addr %lx ", dev->iobase);
-static int contec_di_insn_bits(struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data)
-{
+ s = dev->subdevices + 0;
- dev_dbg(dev->hw_dev, "contec_di_insn_bits called\n");
- dev_dbg(dev->hw_dev, "data: %d %d\n", data[0], data[1]);
+ s->type = COMEDI_SUBD_DI;
+ s->subdev_flags = SDF_READABLE;
+ s->n_chan = 16;
+ s->maxdata = 1;
+ s->range_table = &range_digital;
+ s->insn_bits = contec_di_insn_bits;
- if (insn->n != 2)
- return -EINVAL;
+ s = dev->subdevices + 1;
+ s->type = COMEDI_SUBD_DO;
+ s->subdev_flags = SDF_WRITABLE;
+ s->n_chan = 16;
+ s->maxdata = 1;
+ s->range_table = &range_digital;
+ s->insn_bits = contec_do_insn_bits;
- data[1] = inw(dev->iobase + thisboard->in_offs);
+ printk("attached\n");
- return 2;
+ return 1;
}
-static int __devinit driver_contec_pci_probe(struct pci_dev *dev,
- const struct pci_device_id *ent)
+static void contec_detach(struct comedi_device *dev)
{
- return comedi_pci_auto_config(dev, driver_contec.driver_name);
-}
+ struct pci_dev *pcidev = comedi_to_pci_dev(dev);
-static void __devexit driver_contec_pci_remove(struct pci_dev *dev)
-{
- comedi_pci_auto_unconfig(dev);
+ if (pcidev) {
+ if (dev->iobase)
+ comedi_pci_disable(pcidev);
+ pci_dev_put(pcidev);
+ }
}
-static struct pci_driver driver_contec_pci_driver = {
- .id_table = contec_pci_table,
- .probe = &driver_contec_pci_probe,
- .remove = __devexit_p(&driver_contec_pci_remove)
+static struct comedi_driver contec_pci_dio_driver = {
+ .driver_name = "contec_pci_dio",
+ .module = THIS_MODULE,
+ .attach = contec_attach,
+ .detach = contec_detach,
};
-static int __init driver_contec_init_module(void)
+static int __devinit contec_pci_dio_pci_probe(struct pci_dev *dev,
+ const struct pci_device_id *ent)
{
- int retval;
-
- retval = comedi_driver_register(&driver_contec);
- if (retval < 0)
- return retval;
-
- driver_contec_pci_driver.name = (char *)driver_contec.driver_name;
- return pci_register_driver(&driver_contec_pci_driver);
+ return comedi_pci_auto_config(dev, &contec_pci_dio_driver);
}
-static void __exit driver_contec_cleanup_module(void)
+static void __devexit contec_pci_dio_pci_remove(struct pci_dev *dev)
{
- pci_unregister_driver(&driver_contec_pci_driver);
- comedi_driver_unregister(&driver_contec);
+ comedi_pci_auto_unconfig(dev);
}
-module_init(driver_contec_init_module);
-module_exit(driver_contec_cleanup_module);
+static DEFINE_PCI_DEVICE_TABLE(contec_pci_dio_pci_table) = {
+ { PCI_DEVICE(PCI_VENDOR_ID_CONTEC, PCI_DEVICE_ID_PIO1616L),
+ .driver_data = PIO1616L },
+ { 0 }
+};
+MODULE_DEVICE_TABLE(pci, contec_pci_dio_pci_table);
+
+static struct pci_driver contec_pci_dio_pci_driver = {
+ .name = "contec_pci_dio",
+ .id_table = contec_pci_dio_pci_table,
+ .probe = contec_pci_dio_pci_probe,
+ .remove = __devexit_p(contec_pci_dio_pci_remove),
+};
+module_comedi_pci_driver(contec_pci_dio_driver, contec_pci_dio_pci_driver);
MODULE_AUTHOR("Comedi http://www.comedi.org");
MODULE_DESCRIPTION("Comedi low-level driver");
diff --git a/drivers/staging/comedi/drivers/daqboard2000.c b/drivers/staging/comedi/drivers/daqboard2000.c
index e61c6a8f2857..ef28385c1482 100644
--- a/drivers/staging/comedi/drivers/daqboard2000.c
+++ b/drivers/staging/comedi/drivers/daqboard2000.c
@@ -118,11 +118,12 @@ Configuration options:
#include <linux/delay.h>
#include <linux/interrupt.h>
-#include "comedi_pci.h"
#include "8255.h"
-#define DAQBOARD2000_SUBSYSTEM_IDS2 0x00021616 /* Daqboard/2000 - 2 Dacs */
-#define DAQBOARD2000_SUBSYSTEM_IDS4 0x00041616 /* Daqboard/2000 - 4 Dacs */
+#define PCI_VENDOR_ID_IOTECH 0x1616
+
+#define DAQBOARD2000_SUBSYSTEM_IDS2 0x0002 /* Daqboard/2000 - 2 Dacs */
+#define DAQBOARD2000_SUBSYSTEM_IDS4 0x0004 /* Daqboard/2000 - 4 Dacs */
#define DAQBOARD2000_DAQ_SIZE 0x1002
#define DAQBOARD2000_PLX_SIZE 0x100
@@ -301,17 +302,6 @@ struct daqboard2000_hw {
#define DAQBOARD2000_PosRefDacSelect 0x0100
#define DAQBOARD2000_NegRefDacSelect 0x0000
-static int daqboard2000_attach(struct comedi_device *dev,
- struct comedi_devconfig *it);
-static int daqboard2000_detach(struct comedi_device *dev);
-
-static struct comedi_driver driver_daqboard2000 = {
- .driver_name = "daqboard2000",
- .module = THIS_MODULE,
- .attach = daqboard2000_attach,
- .detach = daqboard2000_detach,
-};
-
struct daq200_boardtype {
const char *name;
int id;
@@ -321,24 +311,14 @@ static const struct daq200_boardtype boardtypes[] = {
{"ids4", DAQBOARD2000_SUBSYSTEM_IDS4},
};
-#define n_boardtypes (sizeof(boardtypes)/sizeof(struct daq200_boardtype))
#define this_board ((const struct daq200_boardtype *)dev->board_ptr)
-static DEFINE_PCI_DEVICE_TABLE(daqboard2000_pci_table) = {
- { PCI_DEVICE(0x1616, 0x0409) },
- {0}
-};
-
-MODULE_DEVICE_TABLE(pci, daqboard2000_pci_table);
-
struct daqboard2000_private {
enum {
card_daqboard_2000
} card;
- struct pci_dev *pci_dev;
void *daq;
- void *plx;
- int got_regions;
+ void __iomem *plx;
unsigned int ao_readback[2];
};
@@ -412,9 +392,12 @@ static int daqboard2000_ai_insn_read(struct comedi_device *dev,
DAQBOARD2000_AcqResetScanListFifo |
DAQBOARD2000_AcqResetResultsFifo | DAQBOARD2000_AcqResetConfigPipe;
- /* If pacer clock is not set to some high value (> 10 us), we
- risk multiple samples to be put into the result FIFO. */
- fpga->acqPacerClockDivLow = 1000000; /* 1 second, should be long enough */
+ /*
+ * If pacer clock is not set to some high value (> 10 us), we
+ * risk multiple samples to be put into the result FIFO.
+ */
+ /* 1 second, should be long enough */
+ fpga->acqPacerClockDivLow = 1000000;
fpga->acqPacerClockDivHigh = 0;
gain = CR_RANGE(insn->chanspec);
@@ -502,7 +485,7 @@ static int daqboard2000_ao_insn_write(struct comedi_device *dev,
static void daqboard2000_resetLocalBus(struct comedi_device *dev)
{
- dev_dbg(dev->hw_dev, "daqboard2000_resetLocalBus\n");
+ dev_dbg(dev->class_dev, "daqboard2000_resetLocalBus\n");
writel(DAQBOARD2000_SECRLocalBusHi, devpriv->plx + 0x6c);
udelay(10000);
writel(DAQBOARD2000_SECRLocalBusLo, devpriv->plx + 0x6c);
@@ -511,7 +494,7 @@ static void daqboard2000_resetLocalBus(struct comedi_device *dev)
static void daqboard2000_reloadPLX(struct comedi_device *dev)
{
- dev_dbg(dev->hw_dev, "daqboard2000_reloadPLX\n");
+ dev_dbg(dev->class_dev, "daqboard2000_reloadPLX\n");
writel(DAQBOARD2000_SECRReloadLo, devpriv->plx + 0x6c);
udelay(10000);
writel(DAQBOARD2000_SECRReloadHi, devpriv->plx + 0x6c);
@@ -522,7 +505,7 @@ static void daqboard2000_reloadPLX(struct comedi_device *dev)
static void daqboard2000_pulseProgPin(struct comedi_device *dev)
{
- dev_dbg(dev->hw_dev, "daqboard2000_pulseProgPin 1\n");
+ dev_dbg(dev->class_dev, "daqboard2000_pulseProgPin 1\n");
writel(DAQBOARD2000_SECRProgPinHi, devpriv->plx + 0x6c);
udelay(10000);
writel(DAQBOARD2000_SECRProgPinLo, devpriv->plx + 0x6c);
@@ -574,14 +557,14 @@ static int initialize_daqboard2000(struct comedi_device *dev,
secr = readl(devpriv->plx + 0x6c);
if (!(secr & DAQBOARD2000_EEPROM_PRESENT)) {
#ifdef DEBUG_EEPROM
- dev_dbg(dev->hw_dev, "no serial eeprom\n");
+ dev_dbg(dev->class_dev, "no serial eeprom\n");
#endif
return -EIO;
}
for (retry = 0; retry < 3; retry++) {
#ifdef DEBUG_EEPROM
- dev_dbg(dev->hw_dev, "Programming EEPROM try %x\n", retry);
+ dev_dbg(dev->class_dev, "Programming EEPROM try %x\n", retry);
#endif
daqboard2000_resetLocalBus(dev);
@@ -592,8 +575,8 @@ static int initialize_daqboard2000(struct comedi_device *dev,
if (cpld_array[i] == 0xff
&& cpld_array[i + 1] == 0x20) {
#ifdef DEBUG_EEPROM
- dev_dbg(dev->hw_dev, "Preamble found at %d\n",
- i);
+ dev_dbg(dev->class_dev,
+ "Preamble found at %d\n", i);
#endif
break;
}
@@ -606,7 +589,7 @@ static int initialize_daqboard2000(struct comedi_device *dev,
}
if (i >= len) {
#ifdef DEBUG_EEPROM
- dev_dbg(dev->hw_dev, "Programmed\n");
+ dev_dbg(dev->class_dev, "Programmed\n");
#endif
daqboard2000_resetLocalBus(dev);
daqboard2000_reloadPLX(dev);
@@ -720,85 +703,79 @@ static int daqboard2000_8255_cb(int dir, int port, int data,
return result;
}
+static struct pci_dev *daqboard2000_find_pci_dev(struct comedi_device *dev,
+ struct comedi_devconfig *it)
+{
+ struct pci_dev *pcidev = NULL;
+ int bus = it->options[0];
+ int slot = it->options[1];
+ int i;
+
+ for_each_pci_dev(pcidev) {
+ if (bus || slot) {
+ if (bus != pcidev->bus->number ||
+ slot != PCI_SLOT(pcidev->devfn))
+ continue;
+ }
+ if (pcidev->vendor != PCI_VENDOR_ID_IOTECH ||
+ pcidev->device != 0x0409)
+ continue;
+
+ for (i = 0; i < ARRAY_SIZE(boardtypes); i++) {
+ if (boardtypes[i].id != pcidev->subsystem_device)
+ continue;
+ dev->board_ptr = boardtypes + i;
+ return pcidev;
+ }
+ }
+ dev_err(dev->class_dev,
+ "No supported board found! (req. bus %d, slot %d)\n",
+ bus, slot);
+ return NULL;
+}
+
static int daqboard2000_attach(struct comedi_device *dev,
struct comedi_devconfig *it)
{
- int result = 0;
+ struct pci_dev *pcidev;
struct comedi_subdevice *s;
- struct pci_dev *card = NULL;
void *aux_data;
unsigned int aux_len;
- int bus, slot;
-
- bus = it->options[0];
- slot = it->options[1];
+ int result;
result = alloc_private(dev, sizeof(struct daqboard2000_private));
if (result < 0)
return -ENOMEM;
- for (card = pci_get_device(0x1616, 0x0409, NULL);
- card != NULL; card = pci_get_device(0x1616, 0x0409, card)) {
- if (bus || slot) {
- /* requested particular bus/slot */
- if (card->bus->number != bus ||
- PCI_SLOT(card->devfn) != slot) {
- continue;
- }
- }
- break; /* found one */
- }
- if (!card) {
- if (bus || slot)
- dev_err(dev->hw_dev, "no daqboard2000 found at bus/slot: %d/%d\n",
- bus, slot);
- else
- dev_err(dev->hw_dev, "no daqboard2000 found\n");
+ pcidev = daqboard2000_find_pci_dev(dev, it);
+ if (!pcidev)
return -EIO;
- } else {
- u32 id;
- int i;
- devpriv->pci_dev = card;
- id = ((u32) card->
- subsystem_device << 16) | card->subsystem_vendor;
- for (i = 0; i < n_boardtypes; i++) {
- if (boardtypes[i].id == id) {
- dev_dbg(dev->hw_dev, "%s\n",
- boardtypes[i].name);
- dev->board_ptr = boardtypes + i;
- }
- }
- if (!dev->board_ptr) {
- printk
- (" unknown subsystem id %08x (pretend it is an ids2)",
- id);
- dev->board_ptr = boardtypes;
- }
- }
+ comedi_set_hw_dev(dev, &pcidev->dev);
- result = comedi_pci_enable(card, "daqboard2000");
+ result = comedi_pci_enable(pcidev, "daqboard2000");
if (result < 0) {
- dev_err(dev->hw_dev, "failed to enable PCI device and request regions\n");
+ dev_err(dev->class_dev,
+ "failed to enable PCI device and request regions\n");
return -EIO;
}
- devpriv->got_regions = 1;
+ dev->iobase = pci_resource_start(pcidev, 2);
+
devpriv->plx =
- ioremap(pci_resource_start(card, 0), DAQBOARD2000_PLX_SIZE);
- devpriv->daq =
- ioremap(pci_resource_start(card, 2), DAQBOARD2000_DAQ_SIZE);
+ ioremap(pci_resource_start(pcidev, 0), DAQBOARD2000_PLX_SIZE);
+ devpriv->daq = ioremap(dev->iobase, DAQBOARD2000_DAQ_SIZE);
if (!devpriv->plx || !devpriv->daq)
return -ENOMEM;
- result = alloc_subdevices(dev, 3);
- if (result < 0)
- goto out;
+ result = comedi_alloc_subdevices(dev, 3);
+ if (result)
+ return result;
readl(devpriv->plx + 0x6c);
/*
u8 interrupt;
Windows code does restore interrupts, but since we don't use them...
- pci_read_config_byte(card, PCI_INTERRUPT_LINE, &interrupt);
+ pci_read_config_byte(pcidev, PCI_INTERRUPT_LINE, &interrupt);
printk("Interrupt before is: %x\n", interrupt);
*/
@@ -808,7 +785,8 @@ static int daqboard2000_attach(struct comedi_device *dev,
if (aux_data && aux_len) {
result = initialize_daqboard2000(dev, aux_data, aux_len);
} else {
- dev_dbg(dev->hw_dev, "no FPGA initialization code, aborting\n");
+ dev_dbg(dev->class_dev,
+ "no FPGA initialization code, aborting\n");
result = -EIO;
}
if (result < 0)
@@ -817,7 +795,7 @@ static int daqboard2000_attach(struct comedi_device *dev,
daqboard2000_initializeDac(dev);
/*
Windows code does restore interrupts, but since we don't use them...
- pci_read_config_byte(card, PCI_INTERRUPT_LINE, &interrupt);
+ pci_read_config_byte(pcidev, PCI_INTERRUPT_LINE, &interrupt);
printk("Interrupt after is: %x\n", interrupt);
*/
@@ -852,67 +830,58 @@ out:
return result;
}
-static int daqboard2000_detach(struct comedi_device *dev)
+static void daqboard2000_detach(struct comedi_device *dev)
{
+ struct pci_dev *pcidev = comedi_to_pci_dev(dev);
+
if (dev->subdevices)
subdev_8255_cleanup(dev, dev->subdevices + 2);
-
if (dev->irq)
free_irq(dev->irq, dev);
-
if (devpriv) {
if (devpriv->daq)
iounmap(devpriv->daq);
if (devpriv->plx)
iounmap(devpriv->plx);
- if (devpriv->pci_dev) {
- if (devpriv->got_regions)
- comedi_pci_disable(devpriv->pci_dev);
- pci_dev_put(devpriv->pci_dev);
- }
}
- return 0;
+ if (pcidev) {
+ if (dev->iobase)
+ comedi_pci_disable(pcidev);
+ pci_dev_put(pcidev);
+ }
}
-static int __devinit driver_daqboard2000_pci_probe(struct pci_dev *dev,
- const struct pci_device_id
- *ent)
+static struct comedi_driver daqboard2000_driver = {
+ .driver_name = "daqboard2000",
+ .module = THIS_MODULE,
+ .attach = daqboard2000_attach,
+ .detach = daqboard2000_detach,
+};
+
+static int __devinit daqboard2000_pci_probe(struct pci_dev *dev,
+ const struct pci_device_id *ent)
{
- return comedi_pci_auto_config(dev, driver_daqboard2000.driver_name);
+ return comedi_pci_auto_config(dev, &daqboard2000_driver);
}
-static void __devexit driver_daqboard2000_pci_remove(struct pci_dev *dev)
+static void __devexit daqboard2000_pci_remove(struct pci_dev *dev)
{
comedi_pci_auto_unconfig(dev);
}
-static struct pci_driver driver_daqboard2000_pci_driver = {
- .id_table = daqboard2000_pci_table,
- .probe = &driver_daqboard2000_pci_probe,
- .remove = __devexit_p(&driver_daqboard2000_pci_remove)
+static DEFINE_PCI_DEVICE_TABLE(daqboard2000_pci_table) = {
+ { PCI_DEVICE(PCI_VENDOR_ID_IOTECH, 0x0409) },
+ { 0 }
};
+MODULE_DEVICE_TABLE(pci, daqboard2000_pci_table);
-static int __init driver_daqboard2000_init_module(void)
-{
- int retval;
-
- retval = comedi_driver_register(&driver_daqboard2000);
- if (retval < 0)
- return retval;
-
- driver_daqboard2000_pci_driver.name =
- (char *)driver_daqboard2000.driver_name;
- return pci_register_driver(&driver_daqboard2000_pci_driver);
-}
-
-static void __exit driver_daqboard2000_cleanup_module(void)
-{
- pci_unregister_driver(&driver_daqboard2000_pci_driver);
- comedi_driver_unregister(&driver_daqboard2000);
-}
-
-module_init(driver_daqboard2000_init_module);
-module_exit(driver_daqboard2000_cleanup_module);
+static struct pci_driver daqboard2000_pci_driver = {
+ .name = "daqboard2000",
+ .id_table = daqboard2000_pci_table,
+ .probe = daqboard2000_pci_probe,
+ .remove = __devexit_p(daqboard2000_pci_remove),
+};
+module_comedi_pci_driver(daqboard2000_driver, daqboard2000_pci_driver);
MODULE_AUTHOR("Comedi http://www.comedi.org");
MODULE_DESCRIPTION("Comedi low-level driver");
diff --git a/drivers/staging/comedi/drivers/das08.c b/drivers/staging/comedi/drivers/das08.c
index c2dd0ed36a73..874e02e47668 100644
--- a/drivers/staging/comedi/drivers/das08.c
+++ b/drivers/staging/comedi/drivers/das08.c
@@ -32,7 +32,7 @@
* [ComputerBoards] DAS08 (isa-das08), DAS08-PGM (das08-pgm),
* DAS08-PGH (das08-pgh), DAS08-PGL (das08-pgl), DAS08-AOH (das08-aoh),
* DAS08-AOL (das08-aol), DAS08-AOM (das08-aom), DAS08/JR-AO (das08/jr-ao),
- * DAS08/JR-16-AO (das08jr-16-ao), PCI-DAS08 (das08),
+ * DAS08/JR-16-AO (das08jr-16-ao), PCI-DAS08 (pci-das08 or das08),
* PC104-DAS08 (pc104-das08), DAS08/JR/16 (das08jr/16)
* Status: works
*
@@ -55,12 +55,16 @@
#include <linux/delay.h>
-#include "comedi_pci.h"
#include "8255.h"
+#include "8253.h"
#include "das08.h"
#define DRV_NAME "das08"
+#define DO_COMEDI_DRIVER_REGISTER \
+ (IS_ENABLED(CONFIG_COMEDI_DAS08_ISA) || \
+ IS_ENABLED(CONFIG_COMEDI_DAS08_PCI))
+
#define PCI_VENDOR_ID_COMPUTERBOARDS 0x1307
#define PCI_DEVICE_ID_PCIDAS08 0x29
#define PCIDAS08_SIZE 0x54
@@ -154,27 +158,6 @@
/* gainlist same as _pgx_ below */
-static int das08_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data);
-static int das08_di_rbits(struct comedi_device *dev, struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data);
-static int das08_do_wbits(struct comedi_device *dev, struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data);
-static int das08jr_di_rbits(struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data);
-static int das08jr_do_wbits(struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data);
-static int das08jr_ao_winsn(struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data);
-static int das08ao_ao_winsn(struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data);
-static void i8254_set_mode_low(unsigned int base, int channel,
- unsigned int mode);
-
static const struct comedi_lrange range_das08_pgl = { 9, {
BIP_RANGE(10),
BIP_RANGE(5),
@@ -253,274 +236,13 @@ static const int *const das08_gainlists[] = {
das08_pgm_gainlist,
};
-static const struct das08_board_struct das08_boards[] = {
- {
- .name = "isa-das08", /* cio-das08.pdf */
- .bustype = isa,
- .ai = das08_ai_rinsn,
- .ai_nbits = 12,
- .ai_pg = das08_pg_none,
- .ai_encoding = das08_encode12,
- .ao = NULL,
- .ao_nbits = 12,
- .di = das08_di_rbits,
- .do_ = das08_do_wbits,
- .do_nchan = 4,
- .i8255_offset = 8,
- .i8254_offset = 4,
- .iosize = 16, /* unchecked */
- },
- {
- .name = "das08-pgm", /* cio-das08pgx.pdf */
- .bustype = isa,
- .ai = das08_ai_rinsn,
- .ai_nbits = 12,
- .ai_pg = das08_pgm,
- .ai_encoding = das08_encode12,
- .ao = NULL,
- .di = das08_di_rbits,
- .do_ = das08_do_wbits,
- .do_nchan = 4,
- .i8255_offset = 0,
- .i8254_offset = 0x04,
- .iosize = 16, /* unchecked */
- },
- {
- .name = "das08-pgh", /* cio-das08pgx.pdf */
- .bustype = isa,
- .ai = das08_ai_rinsn,
- .ai_nbits = 12,
- .ai_pg = das08_pgh,
- .ai_encoding = das08_encode12,
- .ao = NULL,
- .di = das08_di_rbits,
- .do_ = das08_do_wbits,
- .do_nchan = 4,
- .i8255_offset = 0,
- .i8254_offset = 0x04,
- .iosize = 16, /* unchecked */
- },
- {
- .name = "das08-pgl", /* cio-das08pgx.pdf */
- .bustype = isa,
- .ai = das08_ai_rinsn,
- .ai_nbits = 12,
- .ai_pg = das08_pgl,
- .ai_encoding = das08_encode12,
- .ao = NULL,
- .di = das08_di_rbits,
- .do_ = das08_do_wbits,
- .do_nchan = 4,
- .i8255_offset = 0,
- .i8254_offset = 0x04,
- .iosize = 16, /* unchecked */
- },
- {
- .name = "das08-aoh", /* cio-das08_aox.pdf */
- .bustype = isa,
- .ai = das08_ai_rinsn,
- .ai_nbits = 12,
- .ai_pg = das08_pgh,
- .ai_encoding = das08_encode12,
- .ao = das08ao_ao_winsn, /* 8 */
- .ao_nbits = 12,
- .di = das08_di_rbits,
- .do_ = das08_do_wbits,
- .do_nchan = 4,
- .i8255_offset = 0x0c,
- .i8254_offset = 0x04,
- .iosize = 16, /* unchecked */
- },
- {
- .name = "das08-aol", /* cio-das08_aox.pdf */
- .bustype = isa,
- .ai = das08_ai_rinsn,
- .ai_nbits = 12,
- .ai_pg = das08_pgl,
- .ai_encoding = das08_encode12,
- .ao = das08ao_ao_winsn, /* 8 */
- .ao_nbits = 12,
- .di = das08_di_rbits,
- .do_ = das08_do_wbits,
- .do_nchan = 4,
- .i8255_offset = 0x0c,
- .i8254_offset = 0x04,
- .iosize = 16, /* unchecked */
- },
- {
- .name = "das08-aom", /* cio-das08_aox.pdf */
- .bustype = isa,
- .ai = das08_ai_rinsn,
- .ai_nbits = 12,
- .ai_pg = das08_pgm,
- .ai_encoding = das08_encode12,
- .ao = das08ao_ao_winsn, /* 8 */
- .ao_nbits = 12,
- .di = das08_di_rbits,
- .do_ = das08_do_wbits,
- .do_nchan = 4,
- .i8255_offset = 0x0c,
- .i8254_offset = 0x04,
- .iosize = 16, /* unchecked */
- },
- {
- .name = "das08/jr-ao", /* cio-das08-jr-ao.pdf */
- .bustype = isa,
- .ai = das08_ai_rinsn,
- .ai_nbits = 12,
- .ai_pg = das08_pg_none,
- .ai_encoding = das08_encode12,
- .ao = das08jr_ao_winsn,
- .ao_nbits = 12,
- .di = das08jr_di_rbits,
- .do_ = das08jr_do_wbits,
- .do_nchan = 8,
- .i8255_offset = 0,
- .i8254_offset = 0,
- .iosize = 16, /* unchecked */
- },
- {
- .name = "das08jr-16-ao", /* cio-das08jr-16-ao.pdf */
- .bustype = isa,
- .ai = das08_ai_rinsn,
- .ai_nbits = 16,
- .ai_pg = das08_pg_none,
- .ai_encoding = das08_encode12,
- .ao = das08jr_ao_winsn,
- .ao_nbits = 16,
- .di = das08jr_di_rbits,
- .do_ = das08jr_do_wbits,
- .do_nchan = 8,
- .i8255_offset = 0,
- .i8254_offset = 0x04,
- .iosize = 16, /* unchecked */
- },
-#ifdef CONFIG_COMEDI_PCI
- {
- .name = "das08", /* pci-das08 */
- .id = PCI_DEVICE_ID_PCIDAS08,
- .bustype = pci,
- .ai = das08_ai_rinsn,
- .ai_nbits = 12,
- .ai_pg = das08_bipolar5,
- .ai_encoding = das08_encode12,
- .ao = NULL,
- .ao_nbits = 0,
- .di = das08_di_rbits,
- .do_ = das08_do_wbits,
- .do_nchan = 4,
- .i8255_offset = 0,
- .i8254_offset = 4,
- .iosize = 8,
- },
-#endif
- {
- .name = "pc104-das08",
- .bustype = pc104,
- .ai = das08_ai_rinsn,
- .ai_nbits = 12,
- .ai_pg = das08_pg_none,
- .ai_encoding = das08_encode12,
- .ao = NULL,
- .ao_nbits = 0,
- .di = das08_di_rbits,
- .do_ = das08_do_wbits,
- .do_nchan = 4,
- .i8255_offset = 0,
- .i8254_offset = 4,
- .iosize = 16, /* unchecked */
- },
-#if 0
- {
- .name = "das08/f",
- },
- {
- .name = "das08jr",
- },
-#endif
- {
- .name = "das08jr/16",
- .bustype = isa,
- .ai = das08_ai_rinsn,
- .ai_nbits = 16,
- .ai_pg = das08_pg_none,
- .ai_encoding = das08_encode16,
- .ao = NULL,
- .ao_nbits = 0,
- .di = das08jr_di_rbits,
- .do_ = das08jr_do_wbits,
- .do_nchan = 8,
- .i8255_offset = 0,
- .i8254_offset = 0,
- .iosize = 16, /* unchecked */
- },
-#if 0
- {
- .name = "das48-pga", /* cio-das48-pga.pdf */
- },
- {
- .name = "das08-pga-g2", /* a KM board */
- },
-#endif
-};
-
-#ifdef CONFIG_COMEDI_PCMCIA
-struct das08_board_struct das08_cs_boards[NUM_DAS08_CS_BOARDS] = {
- {
- .name = "pcm-das08",
- .id = 0x0, /* XXX */
- .bustype = pcmcia,
- .ai = das08_ai_rinsn,
- .ai_nbits = 12,
- .ai_pg = das08_bipolar5,
- .ai_encoding = das08_pcm_encode12,
- .ao = NULL,
- .ao_nbits = 0,
- .di = das08_di_rbits,
- .do_ = das08_do_wbits,
- .do_nchan = 3,
- .i8255_offset = 0,
- .i8254_offset = 0,
- .iosize = 16,
- },
- /* duplicate so driver name can be used also */
- {
- .name = "das08_cs",
- .id = 0x0, /* XXX */
- .bustype = pcmcia,
- .ai = das08_ai_rinsn,
- .ai_nbits = 12,
- .ai_pg = das08_bipolar5,
- .ai_encoding = das08_pcm_encode12,
- .ao = NULL,
- .ao_nbits = 0,
- .di = das08_di_rbits,
- .do_ = das08_do_wbits,
- .do_nchan = 3,
- .i8255_offset = 0,
- .i8254_offset = 0,
- .iosize = 16,
- },
-};
-#endif
-
-#ifdef CONFIG_COMEDI_PCI
-static DEFINE_PCI_DEVICE_TABLE(das08_pci_table) = {
- { PCI_DEVICE(PCI_VENDOR_ID_COMPUTERBOARDS, PCI_DEVICE_ID_PCIDAS08) },
- {0}
-};
-
-MODULE_DEVICE_TABLE(pci, das08_pci_table);
-#endif
-
-#define devpriv ((struct das08_private_struct *)dev->private)
-#define thisboard ((const struct das08_board_struct *)dev->board_ptr)
-
#define TIMEOUT 100000
static int das08_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
+ const struct das08_board_struct *thisboard = comedi_board(dev);
+ struct das08_private_struct *devpriv = dev->private;
int i, n;
int chan;
int range;
@@ -552,7 +274,7 @@ static int das08_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
/* clear over-range bits for 16-bit boards */
if (thisboard->ai_nbits == 16)
if (inb(dev->iobase + DAS08_MSB) & 0x80)
- printk(KERN_INFO "das08: over-range\n");
+ dev_info(dev->class_dev, "over-range\n");
/* trigger conversion */
outb_p(0, dev->iobase + DAS08_TRIG_12BIT);
@@ -562,7 +284,7 @@ static int das08_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
break;
}
if (i == TIMEOUT) {
- printk(KERN_ERR "das08: timeout\n");
+ dev_err(dev->class_dev, "timeout\n");
return -ETIME;
}
msb = inb(dev->iobase + DAS08_MSB);
@@ -592,12 +314,13 @@ static int das08_di_rbits(struct comedi_device *dev, struct comedi_subdevice *s,
data[0] = 0;
data[1] = DAS08_IP(inb(dev->iobase + DAS08_STATUS));
- return 2;
+ return insn->n;
}
static int das08_do_wbits(struct comedi_device *dev, struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
+ struct das08_private_struct *devpriv = dev->private;
int wbits;
/* get current settings of digital output lines */
@@ -616,23 +339,25 @@ static int das08_do_wbits(struct comedi_device *dev, struct comedi_subdevice *s,
data[1] = wbits;
- return 2;
+ return insn->n;
}
-static int das08jr_di_rbits(struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data)
+static int __maybe_unused
+das08jr_di_rbits(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
data[0] = 0;
data[1] = inb(dev->iobase + DAS08JR_DIO);
- return 2;
+ return insn->n;
}
-static int das08jr_do_wbits(struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data)
+static int __maybe_unused
+das08jr_do_wbits(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
+ struct das08_private_struct *devpriv = dev->private;
+
/* null bits we are going to set */
devpriv->do_bits &= ~data[0];
/* set new bit values */
@@ -641,12 +366,12 @@ static int das08jr_do_wbits(struct comedi_device *dev,
data[1] = devpriv->do_bits;
- return 2;
+ return insn->n;
}
-static int das08jr_ao_winsn(struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data)
+static int __maybe_unused
+das08jr_ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
int n;
int lsb, msb;
@@ -679,9 +404,9 @@ static int das08jr_ao_winsn(struct comedi_device *dev,
* a different method to force an update.
*
*/
-static int das08ao_ao_winsn(struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data)
+static int __maybe_unused
+das08ao_ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
{
int n;
int lsb, msb;
@@ -708,102 +433,24 @@ static int das08ao_ao_winsn(struct comedi_device *dev,
return n;
}
-static unsigned int i8254_read_channel_low(unsigned int base, int chan)
-{
- unsigned int msb, lsb;
-
- /* The following instructions must be in order.
- We must avoid other process reading the counter's value in the
- middle.
- The spin_lock isn't needed since ioctl calls grab the big kernel
- lock automatically */
- /*spin_lock(sp); */
- outb(chan << 6, base + I8254_CTRL);
- base += chan;
- lsb = inb(base);
- msb = inb(base);
- /*spin_unlock(sp); */
-
- return lsb | (msb << 8);
-}
-
-static void i8254_write_channel_low(unsigned int base, int chan,
- unsigned int value)
-{
- unsigned int msb, lsb;
-
- lsb = value & 0xFF;
- msb = value >> 8;
-
- /* write lsb, then msb */
- base += chan;
- /* See comments in i8254_read_channel_low */
- /*spin_lock(sp); */
- outb(lsb, base);
- outb(msb, base);
- /*spin_unlock(sp); */
-}
-
-static unsigned int i8254_read_channel(struct i8254_struct *st, int channel)
-{
- int chan = st->logic2phys[channel];
-
- return i8254_read_channel_low(st->iobase, chan);
-}
-
-static void i8254_write_channel(struct i8254_struct *st, int channel,
- unsigned int value)
-{
- int chan = st->logic2phys[channel];
-
- i8254_write_channel_low(st->iobase, chan, value);
-}
-
-static void i8254_initialize(struct i8254_struct *st)
+static void i8254_initialize(struct comedi_device *dev)
{
+ struct das08_private_struct *devpriv = dev->private;
+ unsigned int mode = I8254_MODE0 | I8254_BINARY;
int i;
- for (i = 0; i < 3; ++i)
- i8254_set_mode_low(st->iobase, i, st->mode[i]);
-}
-
-static void i8254_set_mode_low(unsigned int base, int channel,
- unsigned int mode)
-{
- outb((channel << 6) | 0x30 | (mode & 0x0F), base + I8254_CTRL);
-}
-
-static void i8254_set_mode(struct i8254_struct *st, int channel,
- unsigned int mode)
-{
- int chan = st->logic2phys[channel];
-
- st->mode[chan] = mode;
- return i8254_set_mode_low(st->iobase, chan, mode);
-}
-
-static unsigned int i8254_read_status_low(unsigned int base, int channel)
-{
- outb(0xE0 | (2 << channel), base + I8254_CTRL);
- return inb(base + channel);
-}
-
-static unsigned int i8254_read_status(struct i8254_struct *st, int channel)
-{
- int chan = st->logic2phys[channel];
- return i8254_read_status_low(st->iobase, chan);
+ for (i = 0; i < 3; ++i)
+ i8254_set_mode(devpriv->i8254_iobase, 0, i, mode);
}
static int das08_counter_read(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
+ struct das08_private_struct *devpriv = dev->private;
int chan = insn->chanspec;
- /* printk("Reading counter channel %d ",chan); */
- data[0] = i8254_read_channel(&devpriv->i8254, chan);
- /* printk("=> 0x%08X\n",data[0]); */
-
+ data[0] = i8254_read(devpriv->i8254_iobase, 0, chan);
return 1;
}
@@ -811,11 +458,10 @@ static int das08_counter_write(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
+ struct das08_private_struct *devpriv = dev->private;
int chan = insn->chanspec;
- /* printk("Writing counter channel %d with 0x%04X\n",chan,data[0]); */
- i8254_write_channel(&devpriv->i8254, chan, data[0]);
-
+ i8254_write(devpriv->i8254_iobase, 0, chan, data[0]);
return 1;
}
@@ -823,6 +469,7 @@ static int das08_counter_config(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
+ struct das08_private_struct *devpriv = dev->private;
int chan = insn->chanspec;
if (insn->n != 2)
@@ -830,10 +477,10 @@ static int das08_counter_config(struct comedi_device *dev,
switch (data[0]) {
case INSN_CONFIG_SET_COUNTER_MODE:
- i8254_set_mode(&devpriv->i8254, chan, data[1]);
+ i8254_set_mode(devpriv->i8254_iobase, 0, chan, data[1]);
break;
case INSN_CONFIG_8254_READ_STATUS:
- data[1] = i8254_read_status(&devpriv->i8254, chan);
+ data[1] = i8254_status(devpriv->i8254_iobase, 0, chan);
break;
default:
return -EINVAL;
@@ -842,37 +489,280 @@ static int das08_counter_config(struct comedi_device *dev,
return 2;
}
-static int das08_attach(struct comedi_device *dev, struct comedi_devconfig *it);
+#if DO_COMEDI_DRIVER_REGISTER
+static const struct das08_board_struct das08_boards[] = {
+#if IS_ENABLED(CONFIG_COMEDI_DAS08_ISA)
+ {
+ .name = "isa-das08", /* cio-das08.pdf */
+ .bustype = isa,
+ .ai = das08_ai_rinsn,
+ .ai_nbits = 12,
+ .ai_pg = das08_pg_none,
+ .ai_encoding = das08_encode12,
+ .ao = NULL,
+ .ao_nbits = 12,
+ .di = das08_di_rbits,
+ .do_ = das08_do_wbits,
+ .do_nchan = 4,
+ .i8255_offset = 8,
+ .i8254_offset = 4,
+ .iosize = 16, /* unchecked */
+ },
+ {
+ .name = "das08-pgm", /* cio-das08pgx.pdf */
+ .bustype = isa,
+ .ai = das08_ai_rinsn,
+ .ai_nbits = 12,
+ .ai_pg = das08_pgm,
+ .ai_encoding = das08_encode12,
+ .ao = NULL,
+ .di = das08_di_rbits,
+ .do_ = das08_do_wbits,
+ .do_nchan = 4,
+ .i8255_offset = 0,
+ .i8254_offset = 0x04,
+ .iosize = 16, /* unchecked */
+ },
+ {
+ .name = "das08-pgh", /* cio-das08pgx.pdf */
+ .bustype = isa,
+ .ai = das08_ai_rinsn,
+ .ai_nbits = 12,
+ .ai_pg = das08_pgh,
+ .ai_encoding = das08_encode12,
+ .ao = NULL,
+ .di = das08_di_rbits,
+ .do_ = das08_do_wbits,
+ .do_nchan = 4,
+ .i8255_offset = 0,
+ .i8254_offset = 0x04,
+ .iosize = 16, /* unchecked */
+ },
+ {
+ .name = "das08-pgl", /* cio-das08pgx.pdf */
+ .bustype = isa,
+ .ai = das08_ai_rinsn,
+ .ai_nbits = 12,
+ .ai_pg = das08_pgl,
+ .ai_encoding = das08_encode12,
+ .ao = NULL,
+ .di = das08_di_rbits,
+ .do_ = das08_do_wbits,
+ .do_nchan = 4,
+ .i8255_offset = 0,
+ .i8254_offset = 0x04,
+ .iosize = 16, /* unchecked */
+ },
+ {
+ .name = "das08-aoh", /* cio-das08_aox.pdf */
+ .bustype = isa,
+ .ai = das08_ai_rinsn,
+ .ai_nbits = 12,
+ .ai_pg = das08_pgh,
+ .ai_encoding = das08_encode12,
+ .ao = das08ao_ao_winsn, /* 8 */
+ .ao_nbits = 12,
+ .di = das08_di_rbits,
+ .do_ = das08_do_wbits,
+ .do_nchan = 4,
+ .i8255_offset = 0x0c,
+ .i8254_offset = 0x04,
+ .iosize = 16, /* unchecked */
+ },
+ {
+ .name = "das08-aol", /* cio-das08_aox.pdf */
+ .bustype = isa,
+ .ai = das08_ai_rinsn,
+ .ai_nbits = 12,
+ .ai_pg = das08_pgl,
+ .ai_encoding = das08_encode12,
+ .ao = das08ao_ao_winsn, /* 8 */
+ .ao_nbits = 12,
+ .di = das08_di_rbits,
+ .do_ = das08_do_wbits,
+ .do_nchan = 4,
+ .i8255_offset = 0x0c,
+ .i8254_offset = 0x04,
+ .iosize = 16, /* unchecked */
+ },
+ {
+ .name = "das08-aom", /* cio-das08_aox.pdf */
+ .bustype = isa,
+ .ai = das08_ai_rinsn,
+ .ai_nbits = 12,
+ .ai_pg = das08_pgm,
+ .ai_encoding = das08_encode12,
+ .ao = das08ao_ao_winsn, /* 8 */
+ .ao_nbits = 12,
+ .di = das08_di_rbits,
+ .do_ = das08_do_wbits,
+ .do_nchan = 4,
+ .i8255_offset = 0x0c,
+ .i8254_offset = 0x04,
+ .iosize = 16, /* unchecked */
+ },
+ {
+ .name = "das08/jr-ao", /* cio-das08-jr-ao.pdf */
+ .bustype = isa,
+ .ai = das08_ai_rinsn,
+ .ai_nbits = 12,
+ .ai_pg = das08_pg_none,
+ .ai_encoding = das08_encode12,
+ .ao = das08jr_ao_winsn,
+ .ao_nbits = 12,
+ .di = das08jr_di_rbits,
+ .do_ = das08jr_do_wbits,
+ .do_nchan = 8,
+ .i8255_offset = 0,
+ .i8254_offset = 0,
+ .iosize = 16, /* unchecked */
+ },
+ {
+ .name = "das08jr-16-ao", /* cio-das08jr-16-ao.pdf */
+ .bustype = isa,
+ .ai = das08_ai_rinsn,
+ .ai_nbits = 16,
+ .ai_pg = das08_pg_none,
+ .ai_encoding = das08_encode12,
+ .ao = das08jr_ao_winsn,
+ .ao_nbits = 16,
+ .di = das08jr_di_rbits,
+ .do_ = das08jr_do_wbits,
+ .do_nchan = 8,
+ .i8255_offset = 0,
+ .i8254_offset = 0x04,
+ .iosize = 16, /* unchecked */
+ },
+ {
+ .name = "pc104-das08",
+ .bustype = pc104,
+ .ai = das08_ai_rinsn,
+ .ai_nbits = 12,
+ .ai_pg = das08_pg_none,
+ .ai_encoding = das08_encode12,
+ .ao = NULL,
+ .ao_nbits = 0,
+ .di = das08_di_rbits,
+ .do_ = das08_do_wbits,
+ .do_nchan = 4,
+ .i8255_offset = 0,
+ .i8254_offset = 4,
+ .iosize = 16, /* unchecked */
+ },
+#if 0
+ {
+ .name = "das08/f",
+ },
+ {
+ .name = "das08jr",
+ },
+#endif
+ {
+ .name = "das08jr/16",
+ .bustype = isa,
+ .ai = das08_ai_rinsn,
+ .ai_nbits = 16,
+ .ai_pg = das08_pg_none,
+ .ai_encoding = das08_encode16,
+ .ao = NULL,
+ .ao_nbits = 0,
+ .di = das08jr_di_rbits,
+ .do_ = das08jr_do_wbits,
+ .do_nchan = 8,
+ .i8255_offset = 0,
+ .i8254_offset = 0,
+ .iosize = 16, /* unchecked */
+ },
+#if 0
+ {
+ .name = "das48-pga", /* cio-das48-pga.pdf */
+ },
+ {
+ .name = "das08-pga-g2", /* a KM board */
+ },
+#endif
+#endif /* IS_ENABLED(CONFIG_COMEDI_DAS08_ISA) */
+#if IS_ENABLED(CONFIG_COMEDI_DAS08_PCI)
+ {
+ .name = "pci-das08", /* pci-das08 */
+ .id = PCI_DEVICE_ID_PCIDAS08,
+ .bustype = pci,
+ .ai = das08_ai_rinsn,
+ .ai_nbits = 12,
+ .ai_pg = das08_bipolar5,
+ .ai_encoding = das08_encode12,
+ .ao = NULL,
+ .ao_nbits = 0,
+ .di = das08_di_rbits,
+ .do_ = das08_do_wbits,
+ .do_nchan = 4,
+ .i8255_offset = 0,
+ .i8254_offset = 4,
+ .iosize = 8,
+ },
+ { /* wildcard entry matches any supported PCI device */
+ .name = DRV_NAME,
+ .id = PCI_ANY_ID,
+ .bustype = pci,
+ },
+#endif /* IS_ENABLED(CONFIG_COMEDI_DAS08_PCI) */
+};
+#endif /* DO_COMEDI_DRIVER_REGISTER */
-static struct comedi_driver driver_das08 = {
- .driver_name = DRV_NAME,
- .module = THIS_MODULE,
- .attach = das08_attach,
- .detach = das08_common_detach,
- .board_name = &das08_boards[0].name,
- .num_names = sizeof(das08_boards) / sizeof(struct das08_board_struct),
- .offset = sizeof(struct das08_board_struct),
+#if IS_ENABLED(CONFIG_COMEDI_DAS08_CS)
+struct das08_board_struct das08_cs_boards[NUM_DAS08_CS_BOARDS] = {
+ {
+ .name = "pcm-das08",
+ .id = 0x0, /* XXX */
+ .bustype = pcmcia,
+ .ai = das08_ai_rinsn,
+ .ai_nbits = 12,
+ .ai_pg = das08_bipolar5,
+ .ai_encoding = das08_pcm_encode12,
+ .ao = NULL,
+ .ao_nbits = 0,
+ .di = das08_di_rbits,
+ .do_ = das08_do_wbits,
+ .do_nchan = 3,
+ .i8255_offset = 0,
+ .i8254_offset = 0,
+ .iosize = 16,
+ },
+ /* duplicate so driver name can be used also */
+ {
+ .name = "das08_cs",
+ .id = 0x0, /* XXX */
+ .bustype = pcmcia,
+ .ai = das08_ai_rinsn,
+ .ai_nbits = 12,
+ .ai_pg = das08_bipolar5,
+ .ai_encoding = das08_pcm_encode12,
+ .ao = NULL,
+ .ao_nbits = 0,
+ .di = das08_di_rbits,
+ .do_ = das08_do_wbits,
+ .do_nchan = 3,
+ .i8255_offset = 0,
+ .i8254_offset = 0,
+ .iosize = 16,
+ },
};
+EXPORT_SYMBOL_GPL(das08_cs_boards);
+#endif
int das08_common_attach(struct comedi_device *dev, unsigned long iobase)
{
+ const struct das08_board_struct *thisboard = comedi_board(dev);
+ struct das08_private_struct *devpriv = dev->private;
struct comedi_subdevice *s;
int ret;
- /* allocate ioports for non-pcmcia, non-pci boards */
- if ((thisboard->bustype != pcmcia) && (thisboard->bustype != pci)) {
- printk(KERN_INFO " iobase 0x%lx\n", iobase);
- if (!request_region(iobase, thisboard->iosize, DRV_NAME)) {
- printk(KERN_ERR " I/O port conflict\n");
- return -EIO;
- }
- }
dev->iobase = iobase;
dev->board_name = thisboard->name;
- ret = alloc_subdevices(dev, 6);
- if (ret < 0)
+ ret = comedi_alloc_subdevices(dev, 6);
+ if (ret)
return ret;
s = dev->subdevices + 0;
@@ -954,16 +844,9 @@ int das08_common_attach(struct comedi_device *dev, unsigned long iobase)
s->insn_read = das08_counter_read;
s->insn_write = das08_counter_write;
s->insn_config = das08_counter_config;
- /* Set-up the 8254 structure */
- devpriv->i8254.channels = 3;
- devpriv->i8254.logic2phys[0] = 0;
- devpriv->i8254.logic2phys[1] = 1;
- devpriv->i8254.logic2phys[2] = 2;
- devpriv->i8254.iobase = iobase + thisboard->i8254_offset;
- devpriv->i8254.mode[0] =
- devpriv->i8254.mode[1] =
- devpriv->i8254.mode[2] = I8254_MODE0 | I8254_BINARY;
- i8254_initialize(&devpriv->i8254);
+
+ devpriv->i8254_iobase = iobase + thisboard->i8254_offset;
+ i8254_initialize(dev);
} else {
s->type = COMEDI_SUBD_UNUSED;
}
@@ -972,167 +855,246 @@ int das08_common_attach(struct comedi_device *dev, unsigned long iobase)
}
EXPORT_SYMBOL_GPL(das08_common_attach);
-static int das08_attach(struct comedi_device *dev, struct comedi_devconfig *it)
+static int das08_pci_attach_common(struct comedi_device *dev,
+ struct pci_dev *pdev)
{
- int ret;
unsigned long iobase;
-#ifdef CONFIG_COMEDI_PCI
- unsigned long pci_iobase = 0;
- struct pci_dev *pdev = NULL;
+ unsigned long pci_iobase;
+ struct das08_private_struct *devpriv = dev->private;
+
+ if (!IS_ENABLED(CONFIG_COMEDI_DAS08_PCI))
+ return -EINVAL;
+
+ devpriv->pdev = pdev;
+ /* enable PCI device and reserve I/O spaces */
+ if (comedi_pci_enable(pdev, dev->driver->driver_name)) {
+ dev_err(dev->class_dev,
+ "Error enabling PCI device and requesting regions\n");
+ return -EIO;
+ }
+ /* read base addresses */
+ pci_iobase = pci_resource_start(pdev, 1);
+ iobase = pci_resource_start(pdev, 2);
+ dev_info(dev->class_dev, "pcibase 0x%lx iobase 0x%lx\n",
+ pci_iobase, iobase);
+ devpriv->pci_iobase = pci_iobase;
+#if 0
+ /* We could enable pci-das08's interrupt here to make it possible
+ * to do timed input in this driver, but there is little point since
+ * conversions would have to be started by the interrupt handler
+ * so you might as well use comedi_rt_timer to emulate commands
+ */
+ /* set source of interrupt trigger to counter2 output */
+ outb(CNTRL_INTR | CNTRL_DIR, pci_iobase + CNTRL);
+ /* Enable local interrupt 1 and pci interrupt */
+ outw(INTR1_ENABLE | PCI_INTR_ENABLE, pci_iobase + INTCSR);
+#endif
+ return das08_common_attach(dev, iobase);
+}
+
+static const struct das08_board_struct *
+das08_find_pci_board(struct pci_dev *pdev)
+{
+#if DO_COMEDI_DRIVER_REGISTER
+ unsigned int i;
+ for (i = 0; i < ARRAY_SIZE(das08_boards); i++)
+ if (das08_boards[i].bustype == pci &&
+ pdev->device == das08_boards[i].id)
+ return &das08_boards[i];
#endif
+ return NULL;
+}
+
+/* only called in the PCI probe path, via comedi_pci_auto_config() */
+static int __devinit __maybe_unused
+das08_attach_pci(struct comedi_device *dev, struct pci_dev *pdev)
+{
+ int ret;
+ if (!IS_ENABLED(CONFIG_COMEDI_DAS08_PCI))
+ return -EINVAL;
ret = alloc_private(dev, sizeof(struct das08_private_struct));
if (ret < 0)
return ret;
+ dev_info(dev->class_dev, "attach pci %s\n", pci_name(pdev));
+ dev->board_ptr = das08_find_pci_board(pdev);
+ if (dev->board_ptr == NULL) {
+ dev_err(dev->class_dev, "BUG! cannot determine board type!\n");
+ return -EINVAL;
+ }
+ return das08_pci_attach_common(dev, pdev);
+}
- printk(KERN_INFO "comedi%d: das08: ", dev->minor);
- /* deal with a pci board */
- if (thisboard->bustype == pci) {
-#ifdef CONFIG_COMEDI_PCI
- if (it->options[0] || it->options[1]) {
- printk("bus %i slot %i ",
- it->options[0], it->options[1]);
- }
- printk("\n");
- /* find card */
- for_each_pci_dev(pdev) {
- if (pdev->vendor == PCI_VENDOR_ID_COMPUTERBOARDS
- && pdev->device == PCI_DEVICE_ID_PCIDAS08) {
- if (it->options[0] || it->options[1]) {
- if (pdev->bus->number == it->options[0]
- && PCI_SLOT(pdev->devfn) ==
- it->options[1]) {
- break;
- }
- } else {
- break;
- }
- }
+static struct pci_dev *das08_find_pci(struct comedi_device *dev,
+ int bus, int slot)
+{
+ const struct das08_board_struct *thisboard = comedi_board(dev);
+ struct pci_dev *pdev;
+ unsigned int matchid;
+
+ if (bus || slot)
+ dev_dbg(dev->class_dev, "Looking for %s at PCI %02X:%02X\n",
+ thisboard->name, bus, slot);
+ else
+ dev_dbg(dev->class_dev, "Looking for %s on PCI buses\n",
+ thisboard->name);
+
+ matchid = thisboard->id;
+ pdev = NULL;
+ for_each_pci_dev(pdev) {
+ if ((bus || slot) &&
+ (bus != pdev->bus->number || slot != PCI_SLOT(pdev->devfn)))
+ continue;
+ if (pdev->vendor != PCI_VENDOR_ID_COMPUTERBOARDS)
+ continue;
+ if (matchid == PCI_ANY_ID) {
+ /* wildcard board matches any supported PCI board */
+ const struct das08_board_struct *foundboard;
+ foundboard = das08_find_pci_board(pdev);
+ if (foundboard == NULL)
+ continue;
+ /* replace wildcard board_ptr */
+ dev->board_ptr = thisboard = foundboard;
+ } else {
+ /* match specific PCI board */
+ if (pdev->device != matchid)
+ continue;
}
- if (!pdev) {
- printk(KERN_ERR "No pci das08 cards found\n");
+ /* found a match */
+ dev_info(dev->class_dev, "Found %s at PCI %s\n",
+ thisboard->name, pci_name(pdev));
+ return pdev;
+ }
+ /* no match found */
+ if (bus || slot)
+ dev_err(dev->class_dev,
+ "No %s cards found at PCI %02X:%02X\n",
+ thisboard->name, bus, slot);
+ else
+ dev_err(dev->class_dev, "No %s cards found on PCI buses\n",
+ thisboard->name);
+ return NULL;
+}
+
+static int __maybe_unused
+das08_attach(struct comedi_device *dev, struct comedi_devconfig *it)
+{
+ const struct das08_board_struct *thisboard = comedi_board(dev);
+ struct das08_private_struct *devpriv;
+ int ret;
+ unsigned long iobase;
+
+ ret = alloc_private(dev, sizeof(struct das08_private_struct));
+ if (ret < 0)
+ return ret;
+ devpriv = dev->private;
+
+ dev_info(dev->class_dev, "attach\n");
+ if (IS_ENABLED(CONFIG_COMEDI_DAS08_PCI) && thisboard->bustype == pci) {
+ struct pci_dev *pdev;
+ pdev = das08_find_pci(dev, it->options[0], it->options[1]);
+ if (pdev == NULL)
return -EIO;
- }
- devpriv->pdev = pdev;
- /* enable PCI device and reserve I/O spaces */
- if (comedi_pci_enable(pdev, DRV_NAME)) {
- printk(KERN_ERR " Error enabling PCI device and "
- "requesting regions\n");
+ return das08_pci_attach_common(dev, pdev);
+ } else if (IS_ENABLED(CONFIG_COMEDI_DAS08_ISA) &&
+ (thisboard->bustype == isa || thisboard->bustype == pc104)) {
+ iobase = it->options[0];
+ dev_info(dev->class_dev, "iobase 0x%lx\n", iobase);
+ if (!request_region(iobase, thisboard->iosize, DRV_NAME)) {
+ dev_err(dev->class_dev, "I/O port conflict\n");
return -EIO;
}
- /* read base addresses */
- pci_iobase = pci_resource_start(pdev, 1);
- iobase = pci_resource_start(pdev, 2);
- printk(KERN_INFO "pcibase 0x%lx iobase 0x%lx\n",
- pci_iobase, iobase);
- devpriv->pci_iobase = pci_iobase;
-#if 0
-/* We could enable to pci-das08's interrupt here to make it possible
- * to do timed input in this driver, but there is little point since
- * conversions would have to be started by the interrupt handler
- * so you might as well use comedi_rt_timer to emulate commands
- */
- /* set source of interrupt trigger to counter2 output */
- outb(CNTRL_INTR | CNTRL_DIR, pci_iobase + CNTRL);
- /* Enable local interrupt 1 and pci interrupt */
- outw(INTR1_ENABLE | PCI_INTR_ENABLE, pci_iobase + INTCSR);
-#endif
-#else /* CONFIG_COMEDI_PCI */
- printk(KERN_ERR "this driver has not been built with PCI support.\n");
- return -EINVAL;
-#endif /* CONFIG_COMEDI_PCI */
- } else {
- iobase = it->options[0];
- }
- printk(KERN_INFO "\n");
-
- return das08_common_attach(dev, iobase);
+ return das08_common_attach(dev, iobase);
+ } else
+ return -EIO;
}
-
-int das08_common_detach(struct comedi_device *dev)
+void das08_common_detach(struct comedi_device *dev)
{
- printk(KERN_INFO "comedi%d: das08: remove\n", dev->minor);
-
if (dev->subdevices)
subdev_8255_cleanup(dev, dev->subdevices + 4);
+}
+EXPORT_SYMBOL_GPL(das08_common_detach);
+
+static void __maybe_unused das08_detach(struct comedi_device *dev)
+{
+ const struct das08_board_struct *thisboard = comedi_board(dev);
+ struct das08_private_struct *devpriv = dev->private;
- /* deallocate ioports for non-pcmcia, non-pci boards */
- if ((thisboard->bustype != pcmcia) && (thisboard->bustype != pci)) {
+ das08_common_detach(dev);
+ if (IS_ENABLED(CONFIG_COMEDI_DAS08_ISA) &&
+ (thisboard->bustype == isa || thisboard->bustype == pc104)) {
if (dev->iobase)
release_region(dev->iobase, thisboard->iosize);
- }
-#ifdef CONFIG_COMEDI_PCI
- if (devpriv) {
- if (devpriv->pdev) {
+ } else if (IS_ENABLED(CONFIG_COMEDI_DAS08_PCI) &&
+ thisboard->bustype == pci) {
+ if (devpriv && devpriv->pdev) {
if (devpriv->pci_iobase)
comedi_pci_disable(devpriv->pdev);
-
pci_dev_put(devpriv->pdev);
}
}
+}
+
+#if DO_COMEDI_DRIVER_REGISTER
+static struct comedi_driver das08_driver = {
+ .driver_name = DRV_NAME,
+ .module = THIS_MODULE,
+ .attach = das08_attach,
+ .attach_pci = das08_attach_pci,
+ .detach = das08_detach,
+ .board_name = &das08_boards[0].name,
+ .num_names = sizeof(das08_boards) / sizeof(struct das08_board_struct),
+ .offset = sizeof(struct das08_board_struct),
+};
#endif
- return 0;
-}
-EXPORT_SYMBOL_GPL(das08_common_detach);
+#if IS_ENABLED(CONFIG_COMEDI_DAS08_PCI)
+static DEFINE_PCI_DEVICE_TABLE(das08_pci_table) = {
+ { PCI_DEVICE(PCI_VENDOR_ID_COMPUTERBOARDS, PCI_DEVICE_ID_PCIDAS08) },
+ {0}
+};
+
+MODULE_DEVICE_TABLE(pci, das08_pci_table);
-#ifdef CONFIG_COMEDI_PCI
-static int __devinit driver_das08_pci_probe(struct pci_dev *dev,
+static int __devinit das08_pci_probe(struct pci_dev *dev,
const struct pci_device_id *ent)
{
- return comedi_pci_auto_config(dev, driver_das08.driver_name);
+ return comedi_pci_auto_config(dev, &das08_driver);
}
-static void __devexit driver_das08_pci_remove(struct pci_dev *dev)
+static void __devexit das08_pci_remove(struct pci_dev *dev)
{
comedi_pci_auto_unconfig(dev);
}
-static struct pci_driver driver_das08_pci_driver = {
+static struct pci_driver das08_pci_driver = {
.id_table = das08_pci_table,
- .probe = &driver_das08_pci_probe,
- .remove = __devexit_p(&driver_das08_pci_remove)
+ .name = DRV_NAME,
+ .probe = &das08_pci_probe,
+ .remove = __devexit_p(&das08_pci_remove)
};
+#endif /* CONFIG_COMEDI_DAS08_PCI */
-static int __init driver_das08_init_module(void)
-{
- int retval;
-
- retval = comedi_driver_register(&driver_das08);
- if (retval < 0)
- return retval;
-
- driver_das08_pci_driver.name = (char *)driver_das08.driver_name;
- return pci_register_driver(&driver_das08_pci_driver);
-}
-
-static void __exit driver_das08_cleanup_module(void)
-{
- pci_unregister_driver(&driver_das08_pci_driver);
- comedi_driver_unregister(&driver_das08);
-}
-
-module_init(driver_das08_init_module);
-module_exit(driver_das08_cleanup_module);
+#if DO_COMEDI_DRIVER_REGISTER
+#if IS_ENABLED(CONFIG_COMEDI_DAS08_PCI)
+module_comedi_pci_driver(das08_driver, das08_pci_driver);
#else
-static int __init driver_das08_init_module(void)
+module_comedi_driver(das08_driver);
+#endif
+#else /* DO_COMEDI_DRIVER_REGISTER */
+static int __init das08_init(void)
{
- return comedi_driver_register(&driver_das08);
+ return 0;
}
-static void __exit driver_das08_cleanup_module(void)
+static void __exit das08_exit(void)
{
- comedi_driver_unregister(&driver_das08);
}
-module_init(driver_das08_init_module);
-module_exit(driver_das08_cleanup_module);
-#endif
-
-#ifdef CONFIG_COMEDI_PCMCIA
-EXPORT_SYMBOL_GPL(das08_cs_boards);
-#endif
+module_init(das08_init);
+module_exit(das08_exit);
+#endif /* DO_COMEDI_DRIVER_REGISTER */
MODULE_AUTHOR("Comedi http://www.comedi.org");
MODULE_DESCRIPTION("Comedi low-level driver");
diff --git a/drivers/staging/comedi/drivers/das08.h b/drivers/staging/comedi/drivers/das08.h
index 2a30d764ddfc..27b6d4ec9032 100644
--- a/drivers/staging/comedi/drivers/das08.h
+++ b/drivers/staging/comedi/drivers/das08.h
@@ -49,31 +49,19 @@ struct das08_board_struct {
unsigned int iosize; /* number of ioports used */
};
-struct i8254_struct {
- int channels; /* available channels. Some could be used internally. */
- int logic2phys[3]; /* to know which physical channel is. */
- int mode[3]; /* the index is the real counter. */
- unsigned int iobase;
-};
-
-#define I8254_CNT0 0
-#define I8254_CNT1 1
-#define I8254_CNT2 2
-#define I8254_CTRL 3
-
struct das08_private_struct {
unsigned int do_mux_bits; /* bits for do/mux register on boards without separate do register */
unsigned int do_bits; /* bits for do register on boards with register dedicated to digital out only */
const unsigned int *pg_gainlist;
struct pci_dev *pdev; /* struct for pci-das08 */
unsigned int pci_iobase; /* additional base address for pci-das08 */
- struct i8254_struct i8254;
+ unsigned int i8254_iobase;
};
#define NUM_DAS08_CS_BOARDS 2
extern struct das08_board_struct das08_cs_boards[NUM_DAS08_CS_BOARDS];
int das08_common_attach(struct comedi_device *dev, unsigned long iobase);
-int das08_common_detach(struct comedi_device *dev);
+void das08_common_detach(struct comedi_device *dev);
#endif /* _DAS08_H */
diff --git a/drivers/staging/comedi/drivers/das08_cs.c b/drivers/staging/comedi/drivers/das08_cs.c
index 4ad398aad72c..f5700de7b6c0 100644
--- a/drivers/staging/comedi/drivers/das08_cs.c
+++ b/drivers/staging/comedi/drivers/das08_cs.c
@@ -20,6 +20,13 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ PCMCIA support code for this driver is adapted from the dummy_cs.c
+ driver of the Linux PCMCIA Card Services package.
+
+ The initial developer of the original code is David A. Hinds
+ <dahinds@users.sourceforge.net>. Portions created by David A. Hinds
+ are Copyright (C) 1999 David A. Hinds. All Rights Reserved.
+
*****************************************************************
*/
@@ -53,24 +60,10 @@ Command support does not exist, but could be added for this board.
static struct pcmcia_device *cur_dev;
-#define thisboard ((const struct das08_board_struct *)dev->board_ptr)
-
-static int das08_cs_attach(struct comedi_device *dev,
- struct comedi_devconfig *it);
-
-static struct comedi_driver driver_das08_cs = {
- .driver_name = "das08_cs",
- .module = THIS_MODULE,
- .attach = das08_cs_attach,
- .detach = das08_common_detach,
- .board_name = &das08_cs_boards[0].name,
- .num_names = ARRAY_SIZE(das08_cs_boards),
- .offset = sizeof(struct das08_board_struct),
-};
-
static int das08_cs_attach(struct comedi_device *dev,
struct comedi_devconfig *it)
{
+ const struct das08_board_struct *thisboard = comedi_board(dev);
int ret;
unsigned long iobase;
struct pcmcia_device *link = cur_dev; /* XXX hack */
@@ -79,82 +72,34 @@ static int das08_cs_attach(struct comedi_device *dev,
if (ret < 0)
return ret;
- dev_info(dev->hw_dev, "comedi%d: das08_cs:\n", dev->minor);
+ dev_info(dev->class_dev, "das08_cs: attach\n");
/* deal with a pci board */
if (thisboard->bustype == pcmcia) {
if (link == NULL) {
- dev_err(dev->hw_dev, "no pcmcia cards found\n");
+ dev_err(dev->class_dev, "no pcmcia cards found\n");
return -EIO;
}
iobase = link->resource[0]->start;
} else {
- dev_err(dev->hw_dev, "bug! board does not have PCMCIA bustype\n");
+ dev_err(dev->class_dev,
+ "bug! board does not have PCMCIA bustype\n");
return -EINVAL;
}
return das08_common_attach(dev, iobase);
}
-/*======================================================================
-
- The following pcmcia code for the pcm-das08 is adapted from the
- dummy_cs.c driver of the Linux PCMCIA Card Services package.
-
- The initial developer of the original code is David A. Hinds
- <dahinds@users.sourceforge.net>. Portions created by David A. Hinds
- are Copyright (C) 1999 David A. Hinds. All Rights Reserved.
-
-======================================================================*/
-
-static void das08_pcmcia_config(struct pcmcia_device *link);
-static void das08_pcmcia_release(struct pcmcia_device *link);
-static int das08_pcmcia_suspend(struct pcmcia_device *p_dev);
-static int das08_pcmcia_resume(struct pcmcia_device *p_dev);
-
-static int das08_pcmcia_attach(struct pcmcia_device *);
-static void das08_pcmcia_detach(struct pcmcia_device *);
-
-struct local_info_t {
- struct pcmcia_device *link;
- int stop;
- struct bus_operations *bus;
+static struct comedi_driver driver_das08_cs = {
+ .driver_name = "das08_cs",
+ .module = THIS_MODULE,
+ .attach = das08_cs_attach,
+ .detach = das08_common_detach,
+ .board_name = &das08_cs_boards[0].name,
+ .num_names = ARRAY_SIZE(das08_cs_boards),
+ .offset = sizeof(struct das08_board_struct),
};
-static int das08_pcmcia_attach(struct pcmcia_device *link)
-{
- struct local_info_t *local;
-
- dev_dbg(&link->dev, "das08_pcmcia_attach()\n");
-
- /* Allocate space for private device-specific data */
- local = kzalloc(sizeof(struct local_info_t), GFP_KERNEL);
- if (!local)
- return -ENOMEM;
- local->link = link;
- link->priv = local;
-
- cur_dev = link;
-
- das08_pcmcia_config(link);
-
- return 0;
-} /* das08_pcmcia_attach */
-
-static void das08_pcmcia_detach(struct pcmcia_device *link)
-{
-
- dev_dbg(&link->dev, "das08_pcmcia_detach\n");
-
- ((struct local_info_t *)link->priv)->stop = 1;
- das08_pcmcia_release(link);
-
- /* This points to the parent struct local_info_t struct */
- kfree(link->priv);
-
-} /* das08_pcmcia_detach */
-
-
static int das08_pcmcia_config_loop(struct pcmcia_device *p_dev,
void *priv_data)
{
@@ -164,19 +109,15 @@ static int das08_pcmcia_config_loop(struct pcmcia_device *p_dev,
return pcmcia_request_io(p_dev);
}
-static void das08_pcmcia_config(struct pcmcia_device *link)
+static int das08_pcmcia_attach(struct pcmcia_device *link)
{
int ret;
- dev_dbg(&link->dev, "das08_pcmcia_config\n");
-
link->config_flags |= CONF_ENABLE_IRQ | CONF_AUTO_SET_IO;
ret = pcmcia_loop_config(link, das08_pcmcia_config_loop, NULL);
- if (ret) {
- dev_warn(&link->dev, "no configuration found\n");
+ if (ret)
goto failed;
- }
if (!link->irq)
goto failed;
@@ -185,87 +126,61 @@ static void das08_pcmcia_config(struct pcmcia_device *link)
if (ret)
goto failed;
- return;
+ cur_dev = link;
+ return 0;
failed:
- das08_pcmcia_release(link);
-
-} /* das08_pcmcia_config */
-
-static void das08_pcmcia_release(struct pcmcia_device *link)
-{
- dev_dbg(&link->dev, "das08_pcmcia_release\n");
pcmcia_disable_device(link);
-} /* das08_pcmcia_release */
-
-static int das08_pcmcia_suspend(struct pcmcia_device *link)
-{
- struct local_info_t *local = link->priv;
- /* Mark the device as stopped, to block IO until later */
- local->stop = 1;
-
- return 0;
-} /* das08_pcmcia_suspend */
+ return ret;
+}
-static int das08_pcmcia_resume(struct pcmcia_device *link)
+static void das08_pcmcia_detach(struct pcmcia_device *link)
{
- struct local_info_t *local = link->priv;
-
- local->stop = 0;
- return 0;
-} /* das08_pcmcia_resume */
-
-/*====================================================================*/
+ pcmcia_disable_device(link);
+ cur_dev = NULL;
+}
static const struct pcmcia_device_id das08_cs_id_table[] = {
PCMCIA_DEVICE_MANF_CARD(0x01c5, 0x4001),
PCMCIA_DEVICE_NULL
};
-
MODULE_DEVICE_TABLE(pcmcia, das08_cs_id_table);
-MODULE_AUTHOR("David A. Schleef <ds@schleef.org>, "
- "Frank Mori Hess <fmhess@users.sourceforge.net>");
-MODULE_DESCRIPTION("Comedi driver for ComputerBoards DAS-08 PCMCIA boards");
-MODULE_LICENSE("GPL");
-struct pcmcia_driver das08_cs_driver = {
- .probe = das08_pcmcia_attach,
- .remove = das08_pcmcia_detach,
- .suspend = das08_pcmcia_suspend,
- .resume = das08_pcmcia_resume,
- .id_table = das08_cs_id_table,
- .owner = THIS_MODULE,
- .name = "pcm-das08",
+static struct pcmcia_driver das08_cs_driver = {
+ .name = "pcm-das08",
+ .owner = THIS_MODULE,
+ .probe = das08_pcmcia_attach,
+ .remove = das08_pcmcia_detach,
+ .id_table = das08_cs_id_table,
};
-static int __init init_das08_pcmcia_cs(void)
-{
- pcmcia_register_driver(&das08_cs_driver);
- return 0;
-}
-
-static void __exit exit_das08_pcmcia_cs(void)
-{
- pr_debug("das08_pcmcia_cs: unloading\n");
- pcmcia_unregister_driver(&das08_cs_driver);
-}
-
static int __init das08_cs_init_module(void)
{
int ret;
- ret = init_das08_pcmcia_cs();
+ ret = comedi_driver_register(&driver_das08_cs);
if (ret < 0)
return ret;
- return comedi_driver_register(&driver_das08_cs);
+ ret = pcmcia_register_driver(&das08_cs_driver);
+ if (ret < 0) {
+ comedi_driver_unregister(&driver_das08_cs);
+ return ret;
+ }
+
+ return 0;
+
}
+module_init(das08_cs_init_module);
static void __exit das08_cs_exit_module(void)
{
- exit_das08_pcmcia_cs();
+ pcmcia_unregister_driver(&das08_cs_driver);
comedi_driver_unregister(&driver_das08_cs);
}
-
-module_init(das08_cs_init_module);
module_exit(das08_cs_exit_module);
+
+MODULE_AUTHOR("David A. Schleef <ds@schleef.org>, "
+ "Frank Mori Hess <fmhess@users.sourceforge.net>");
+MODULE_DESCRIPTION("Comedi driver for ComputerBoards DAS-08 PCMCIA boards");
+MODULE_LICENSE("GPL");
diff --git a/drivers/staging/comedi/drivers/das16.c b/drivers/staging/comedi/drivers/das16.c
index e7905bac92da..895cc7783c9c 100644
--- a/drivers/staging/comedi/drivers/das16.c
+++ b/drivers/staging/comedi/drivers/das16.c
@@ -339,38 +339,6 @@ struct munge_info {
unsigned have_byte:1;
};
-static int das16_ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data);
-static int das16_do_wbits(struct comedi_device *dev, struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data);
-static int das16_di_rbits(struct comedi_device *dev, struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data);
-static int das16_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data);
-
-static int das16_cmd_test(struct comedi_device *dev, struct comedi_subdevice *s,
- struct comedi_cmd *cmd);
-static int das16_cmd_exec(struct comedi_device *dev,
- struct comedi_subdevice *s);
-static int das16_cancel(struct comedi_device *dev, struct comedi_subdevice *s);
-static void das16_ai_munge(struct comedi_device *dev,
- struct comedi_subdevice *s, void *array,
- unsigned int num_bytes,
- unsigned int start_chan_index);
-
-static void das16_reset(struct comedi_device *dev);
-static irqreturn_t das16_dma_interrupt(int irq, void *d);
-static void das16_timer_interrupt(unsigned long arg);
-static void das16_interrupt(struct comedi_device *dev);
-
-static unsigned int das16_set_pacer(struct comedi_device *dev, unsigned int ns,
- int flags);
-static int das1600_mode_detect(struct comedi_device *dev);
-static unsigned int das16_suggest_transfer_size(struct comedi_device *dev,
- struct comedi_cmd cmd);
-
-static void reg_dump(struct comedi_device *dev);
-
struct das16_board {
const char *name;
void *ai;
@@ -389,344 +357,6 @@ struct das16_board {
unsigned int id;
};
-static const struct das16_board das16_boards[] = {
- {
- .name = "das-16",
- .ai = das16_ai_rinsn,
- .ai_nbits = 12,
- .ai_speed = 15000,
- .ai_pg = das16_pg_none,
- .ao = das16_ao_winsn,
- .ao_nbits = 12,
- .di = das16_di_rbits,
- .do_ = das16_do_wbits,
- .i8255_offset = 0x10,
- .i8254_offset = 0x0c,
- .size = 0x14,
- .id = 0x00,
- },
- {
- .name = "das-16g",
- .ai = das16_ai_rinsn,
- .ai_nbits = 12,
- .ai_speed = 15000,
- .ai_pg = das16_pg_none,
- .ao = das16_ao_winsn,
- .ao_nbits = 12,
- .di = das16_di_rbits,
- .do_ = das16_do_wbits,
- .i8255_offset = 0x10,
- .i8254_offset = 0x0c,
- .size = 0x14,
- .id = 0x00,
- },
- {
- .name = "das-16f",
- .ai = das16_ai_rinsn,
- .ai_nbits = 12,
- .ai_speed = 8500,
- .ai_pg = das16_pg_none,
- .ao = das16_ao_winsn,
- .ao_nbits = 12,
- .di = das16_di_rbits,
- .do_ = das16_do_wbits,
- .i8255_offset = 0x10,
- .i8254_offset = 0x0c,
- .size = 0x14,
- .id = 0x00,
- },
- {
- .name = "cio-das16", /* cio-das16.pdf */
- .ai = das16_ai_rinsn,
- .ai_nbits = 12,
- .ai_speed = 20000,
- .ai_pg = das16_pg_none,
- .ao = das16_ao_winsn,
- .ao_nbits = 12,
- .di = das16_di_rbits,
- .do_ = das16_do_wbits,
- .i8255_offset = 0x10,
- .i8254_offset = 0x0c,
- .size = 0x14,
- .id = 0x80,
- },
- {
- .name = "cio-das16/f", /* das16.pdf */
- .ai = das16_ai_rinsn,
- .ai_nbits = 12,
- .ai_speed = 10000,
- .ai_pg = das16_pg_none,
- .ao = das16_ao_winsn,
- .ao_nbits = 12,
- .di = das16_di_rbits,
- .do_ = das16_do_wbits,
- .i8255_offset = 0x10,
- .i8254_offset = 0x0c,
- .size = 0x14,
- .id = 0x80,
- },
- {
- .name = "cio-das16/jr", /* cio-das16jr.pdf */
- .ai = das16_ai_rinsn,
- .ai_nbits = 12,
- .ai_speed = 7692,
- .ai_pg = das16_pg_16jr,
- .ao = NULL,
- .di = das16_di_rbits,
- .do_ = das16_do_wbits,
- .i8255_offset = 0,
- .i8254_offset = 0x0c,
- .size = 0x10,
- .id = 0x00,
- },
- {
- .name = "pc104-das16jr", /* pc104-das16jr_xx.pdf */
- .ai = das16_ai_rinsn,
- .ai_nbits = 12,
- .ai_speed = 3300,
- .ai_pg = das16_pg_16jr,
- .ao = NULL,
- .di = das16_di_rbits,
- .do_ = das16_do_wbits,
- .i8255_offset = 0,
- .i8254_offset = 0x0c,
- .size = 0x10,
- .id = 0x00,
- },
- {
- .name = "cio-das16jr/16", /* cio-das16jr_16.pdf */
- .ai = das16_ai_rinsn,
- .ai_nbits = 16,
- .ai_speed = 10000,
- .ai_pg = das16_pg_16jr_16,
- .ao = NULL,
- .di = das16_di_rbits,
- .do_ = das16_do_wbits,
- .i8255_offset = 0,
- .i8254_offset = 0x0c,
- .size = 0x10,
- .id = 0x00,
- },
- {
- .name = "pc104-das16jr/16", /* pc104-das16jr_xx.pdf */
- .ai = das16_ai_rinsn,
- .ai_nbits = 16,
- .ai_speed = 10000,
- .ai_pg = das16_pg_16jr_16,
- .ao = NULL,
- .di = das16_di_rbits,
- .do_ = das16_do_wbits,
- .i8255_offset = 0,
- .i8254_offset = 0x0c,
- .size = 0x10,
- .id = 0x00,
- },
- {
- .name = "das-1201", /* 4924.pdf (keithley user's manual) */
- .ai = das16_ai_rinsn,
- .ai_nbits = 12,
- .ai_speed = 20000,
- .ai_pg = das16_pg_none,
- .ao = NULL,
- .di = das16_di_rbits,
- .do_ = das16_do_wbits,
- .i8255_offset = 0x400,
- .i8254_offset = 0x0c,
- .size = 0x408,
- .id = 0x20,
- },
- {
- .name = "das-1202", /* 4924.pdf (keithley user's manual) */
- .ai = das16_ai_rinsn,
- .ai_nbits = 12,
- .ai_speed = 10000,
- .ai_pg = das16_pg_none,
- .ao = NULL,
- .di = das16_di_rbits,
- .do_ = das16_do_wbits,
- .i8255_offset = 0x400,
- .i8254_offset = 0x0c,
- .size = 0x408,
- .id = 0x20,
- },
- {
- /* 4919.pdf and 4922.pdf (keithley user's manual) */
- .name = "das-1401",
- .ai = das16_ai_rinsn,
- .ai_nbits = 12,
- .ai_speed = 10000,
- .ai_pg = das16_pg_1601,
- .ao = NULL,
- .di = das16_di_rbits,
- .do_ = das16_do_wbits,
- .i8255_offset = 0x0,
- .i8254_offset = 0x0c,
- .size = 0x408,
- .id = 0xc0 /* 4919.pdf says id bits are 0xe0, 4922.pdf says 0xc0 */
- },
- {
- /* 4919.pdf and 4922.pdf (keithley user's manual) */
- .name = "das-1402",
- .ai = das16_ai_rinsn,
- .ai_nbits = 12,
- .ai_speed = 10000,
- .ai_pg = das16_pg_1602,
- .ao = NULL,
- .di = das16_di_rbits,
- .do_ = das16_do_wbits,
- .i8255_offset = 0x0,
- .i8254_offset = 0x0c,
- .size = 0x408,
- .id = 0xc0 /* 4919.pdf says id bits are 0xe0, 4922.pdf says 0xc0 */
- },
- {
- .name = "das-1601", /* 4919.pdf */
- .ai = das16_ai_rinsn,
- .ai_nbits = 12,
- .ai_speed = 10000,
- .ai_pg = das16_pg_1601,
- .ao = das16_ao_winsn,
- .ao_nbits = 12,
- .di = das16_di_rbits,
- .do_ = das16_do_wbits,
- .i8255_offset = 0x400,
- .i8254_offset = 0x0c,
- .size = 0x408,
- .id = 0xc0},
- {
- .name = "das-1602", /* 4919.pdf */
- .ai = das16_ai_rinsn,
- .ai_nbits = 12,
- .ai_speed = 10000,
- .ai_pg = das16_pg_1602,
- .ao = das16_ao_winsn,
- .ao_nbits = 12,
- .di = das16_di_rbits,
- .do_ = das16_do_wbits,
- .i8255_offset = 0x400,
- .i8254_offset = 0x0c,
- .size = 0x408,
- .id = 0xc0},
- {
- .name = "cio-das1401/12", /* cio-das1400_series.pdf */
- .ai = das16_ai_rinsn,
- .ai_nbits = 12,
- .ai_speed = 6250,
- .ai_pg = das16_pg_1601,
- .ao = NULL,
- .di = das16_di_rbits,
- .do_ = das16_do_wbits,
- .i8255_offset = 0,
- .i8254_offset = 0x0c,
- .size = 0x408,
- .id = 0xc0},
- {
- .name = "cio-das1402/12", /* cio-das1400_series.pdf */
- .ai = das16_ai_rinsn,
- .ai_nbits = 12,
- .ai_speed = 6250,
- .ai_pg = das16_pg_1602,
- .ao = NULL,
- .di = das16_di_rbits,
- .do_ = das16_do_wbits,
- .i8255_offset = 0,
- .i8254_offset = 0x0c,
- .size = 0x408,
- .id = 0xc0},
- {
- .name = "cio-das1402/16", /* cio-das1400_series.pdf */
- .ai = das16_ai_rinsn,
- .ai_nbits = 16,
- .ai_speed = 10000,
- .ai_pg = das16_pg_1602,
- .ao = NULL,
- .di = das16_di_rbits,
- .do_ = das16_do_wbits,
- .i8255_offset = 0,
- .i8254_offset = 0x0c,
- .size = 0x408,
- .id = 0xc0},
- {
- .name = "cio-das1601/12", /* cio-das160x-1x.pdf */
- .ai = das16_ai_rinsn,
- .ai_nbits = 12,
- .ai_speed = 6250,
- .ai_pg = das16_pg_1601,
- .ao = das16_ao_winsn,
- .ao_nbits = 12,
- .di = das16_di_rbits,
- .do_ = das16_do_wbits,
- .i8255_offset = 0x400,
- .i8254_offset = 0x0c,
- .size = 0x408,
- .id = 0xc0},
- {
- .name = "cio-das1602/12", /* cio-das160x-1x.pdf */
- .ai = das16_ai_rinsn,
- .ai_nbits = 12,
- .ai_speed = 10000,
- .ai_pg = das16_pg_1602,
- .ao = das16_ao_winsn,
- .ao_nbits = 12,
- .di = das16_di_rbits,
- .do_ = das16_do_wbits,
- .i8255_offset = 0x400,
- .i8254_offset = 0x0c,
- .size = 0x408,
- .id = 0xc0},
- {
- .name = "cio-das1602/16", /* cio-das160x-1x.pdf */
- .ai = das16_ai_rinsn,
- .ai_nbits = 16,
- .ai_speed = 10000,
- .ai_pg = das16_pg_1602,
- .ao = das16_ao_winsn,
- .ao_nbits = 12,
- .di = das16_di_rbits,
- .do_ = das16_do_wbits,
- .i8255_offset = 0x400,
- .i8254_offset = 0x0c,
- .size = 0x408,
- .id = 0xc0},
- {
- .name = "cio-das16/330", /* ? */
- .ai = das16_ai_rinsn,
- .ai_nbits = 12,
- .ai_speed = 3030,
- .ai_pg = das16_pg_16jr,
- .ao = NULL,
- .di = das16_di_rbits,
- .do_ = das16_do_wbits,
- .i8255_offset = 0,
- .i8254_offset = 0x0c,
- .size = 0x14,
- .id = 0xf0},
-#if 0
- {
- .name = "das16/330i", /* ? */
- },
- {
- .name = "das16/jr/ctr5", /* ? */
- },
- {
- /* cio-das16_m1_16.pdf, this board is a bit quirky, no dma */
- .name = "cio-das16/m1/16",
- },
-#endif
-};
-
-static int das16_attach(struct comedi_device *dev, struct comedi_devconfig *it);
-static int das16_detach(struct comedi_device *dev);
-static struct comedi_driver driver_das16 = {
- .driver_name = "das16",
- .module = THIS_MODULE,
- .attach = das16_attach,
- .detach = das16_detach,
- .board_name = &das16_boards[0].name,
- .num_names = ARRAY_SIZE(das16_boards),
- .offset = sizeof(das16_boards[0]),
-};
-
#define DAS16_TIMEOUT 1000
/* Period for timer interrupt in jiffies. It's a function
@@ -763,11 +393,11 @@ struct das16_private_struct {
volatile short timer_mode; /* true if using timer mode */
};
#define devpriv ((struct das16_private_struct *)(dev->private))
-#define thisboard ((struct das16_board *)(dev->board_ptr))
static int das16_cmd_test(struct comedi_device *dev, struct comedi_subdevice *s,
struct comedi_cmd *cmd)
{
+ const struct das16_board *board = comedi_board(dev);
int err = 0, tmp;
int gain, start_chan, i;
int mask;
@@ -781,7 +411,7 @@ static int das16_cmd_test(struct comedi_device *dev, struct comedi_subdevice *s,
tmp = cmd->scan_begin_src;
mask = TRIG_FOLLOW;
/* if board supports burst mode */
- if (thisboard->size > 0x400)
+ if (board->size > 0x400)
mask |= TRIG_TIMER | TRIG_EXT;
cmd->scan_begin_src &= mask;
if (!cmd->scan_begin_src || tmp != cmd->scan_begin_src)
@@ -790,7 +420,7 @@ static int das16_cmd_test(struct comedi_device *dev, struct comedi_subdevice *s,
tmp = cmd->convert_src;
mask = TRIG_TIMER | TRIG_EXT;
/* if board supports burst mode */
- if (thisboard->size > 0x400)
+ if (board->size > 0x400)
mask |= TRIG_NOW;
cmd->convert_src &= mask;
if (!cmd->convert_src || tmp != cmd->convert_src)
@@ -853,15 +483,15 @@ static int das16_cmd_test(struct comedi_device *dev, struct comedi_subdevice *s,
/* check against maximum frequency */
if (cmd->scan_begin_src == TRIG_TIMER) {
if (cmd->scan_begin_arg <
- thisboard->ai_speed * cmd->chanlist_len) {
+ board->ai_speed * cmd->chanlist_len) {
cmd->scan_begin_arg =
- thisboard->ai_speed * cmd->chanlist_len;
+ board->ai_speed * cmd->chanlist_len;
err++;
}
}
if (cmd->convert_src == TRIG_TIMER) {
- if (cmd->convert_arg < thisboard->ai_speed) {
- cmd->convert_arg = thisboard->ai_speed;
+ if (cmd->convert_arg < board->ai_speed) {
+ cmd->convert_arg = board->ai_speed;
err++;
}
}
@@ -926,8 +556,65 @@ static int das16_cmd_test(struct comedi_device *dev, struct comedi_subdevice *s,
return 0;
}
+/* utility function that suggests a dma transfer size in bytes */
+static unsigned int das16_suggest_transfer_size(struct comedi_device *dev,
+ struct comedi_cmd cmd)
+{
+ unsigned int size;
+ unsigned int freq;
+
+ /* if we are using timer interrupt, we don't care how long it
+ * will take to complete transfer since it will be interrupted
+ * by timer interrupt */
+ if (devpriv->timer_mode)
+ return DAS16_DMA_SIZE;
+
+ /* otherwise, we are relying on dma terminal count interrupt,
+ * so pick a reasonable size */
+ if (cmd.convert_src == TRIG_TIMER)
+ freq = 1000000000 / cmd.convert_arg;
+ else if (cmd.scan_begin_src == TRIG_TIMER)
+ freq = (1000000000 / cmd.scan_begin_arg) * cmd.chanlist_len;
+ /* return some default value */
+ else
+ freq = 0xffffffff;
+
+ if (cmd.flags & TRIG_WAKE_EOS) {
+ size = sample_size * cmd.chanlist_len;
+ } else {
+ /* make buffer fill in no more than 1/3 second */
+ size = (freq / 3) * sample_size;
+ }
+
+ /* set a minimum and maximum size allowed */
+ if (size > DAS16_DMA_SIZE)
+ size = DAS16_DMA_SIZE - DAS16_DMA_SIZE % sample_size;
+ else if (size < sample_size)
+ size = sample_size;
+
+ if (cmd.stop_src == TRIG_COUNT && size > devpriv->adc_byte_count)
+ size = devpriv->adc_byte_count;
+
+ return size;
+}
+
+static unsigned int das16_set_pacer(struct comedi_device *dev, unsigned int ns,
+ int rounding_flags)
+{
+ i8253_cascade_ns_to_timer_2div(devpriv->clockbase, &(devpriv->divisor1),
+ &(devpriv->divisor2), &ns,
+ rounding_flags & TRIG_ROUND_MASK);
+
+ /* Write the values of ctr1 and ctr2 into counters 1 and 2 */
+ i8254_load(dev->iobase + DAS16_CNTR0_DATA, 0, 1, devpriv->divisor1, 2);
+ i8254_load(dev->iobase + DAS16_CNTR0_DATA, 0, 2, devpriv->divisor2, 2);
+
+ return ns;
+}
+
static int das16_cmd_exec(struct comedi_device *dev, struct comedi_subdevice *s)
{
+ const struct das16_board *board = comedi_board(dev);
struct comedi_async *async = s->async;
struct comedi_cmd *cmd = &async->cmd;
unsigned int byte;
@@ -951,7 +638,7 @@ static int das16_cmd_exec(struct comedi_device *dev, struct comedi_subdevice *s)
cmd->stop_arg * cmd->chanlist_len * sizeof(uint16_t);
/* disable conversions for das1600 mode */
- if (thisboard->size > 0x400)
+ if (board->size > 0x400)
outb(DAS1600_CONV_DISABLE, dev->iobase + DAS1600_CONV);
/* set scan limits */
@@ -962,9 +649,9 @@ static int das16_cmd_exec(struct comedi_device *dev, struct comedi_subdevice *s)
/* set gain (this is also burst rate register but according to
* computer boards manual, burst rate does nothing, even on
* keithley cards) */
- if (thisboard->ai_pg != das16_pg_none) {
+ if (board->ai_pg != das16_pg_none) {
range = CR_RANGE(cmd->chanlist[0]);
- outb((das16_gainlists[thisboard->ai_pg])[range],
+ outb((das16_gainlists[board->ai_pg])[range],
dev->iobase + DAS16_GAIN);
}
@@ -977,7 +664,7 @@ static int das16_cmd_exec(struct comedi_device *dev, struct comedi_subdevice *s)
/* enable counters */
byte = 0;
/* Enable burst mode if appropriate. */
- if (thisboard->size > 0x400) {
+ if (board->size > 0x400) {
if (cmd->convert_src == TRIG_NOW) {
outb(DAS1600_BURST_VAL, dev->iobase + DAS1600_BURST);
/* set burst length */
@@ -1024,7 +711,7 @@ static int das16_cmd_exec(struct comedi_device *dev, struct comedi_subdevice *s)
outb(devpriv->control_state, dev->iobase + DAS16_CONTROL);
/* Enable conversions if using das1600 mode */
- if (thisboard->size > 0x400)
+ if (board->size > 0x400)
outb(0, dev->iobase + DAS1600_CONV);
@@ -1033,6 +720,7 @@ static int das16_cmd_exec(struct comedi_device *dev, struct comedi_subdevice *s)
static int das16_cancel(struct comedi_device *dev, struct comedi_subdevice *s)
{
+ const struct das16_board *board = comedi_board(dev);
unsigned long flags;
spin_lock_irqsave(&dev->spinlock, flags);
@@ -1049,7 +737,7 @@ static int das16_cancel(struct comedi_device *dev, struct comedi_subdevice *s)
}
/* disable burst mode */
- if (thisboard->size > 0x400)
+ if (board->size > 0x400)
outb(0, dev->iobase + DAS1600_BURST);
@@ -1069,6 +757,7 @@ static void das16_reset(struct comedi_device *dev)
static int das16_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
+ const struct das16_board *board = comedi_board(dev);
int i, n;
int range;
int chan;
@@ -1084,9 +773,9 @@ static int das16_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
outb(chan, dev->iobase + DAS16_MUX);
/* set gain */
- if (thisboard->ai_pg != das16_pg_none) {
+ if (board->ai_pg != das16_pg_none) {
range = CR_RANGE(insn->chanspec);
- outb((das16_gainlists[thisboard->ai_pg])[range],
+ outb((das16_gainlists[board->ai_pg])[range],
dev->iobase + DAS16_GAIN);
}
@@ -1104,7 +793,7 @@ static int das16_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
}
msb = inb(dev->iobase + DAS16_AI_MSB);
lsb = inb(dev->iobase + DAS16_AI_LSB);
- if (thisboard->ai_nbits == 12)
+ if (board->ai_nbits == 12)
data[n] = ((lsb >> 4) & 0xf) | (msb << 4);
else
data[n] = lsb | (msb << 8);
@@ -1123,7 +812,7 @@ static int das16_di_rbits(struct comedi_device *dev, struct comedi_subdevice *s,
data[1] = bits;
data[0] = 0;
- return 2;
+ return insn->n;
}
static int das16_do_wbits(struct comedi_device *dev, struct comedi_subdevice *s,
@@ -1143,12 +832,13 @@ static int das16_do_wbits(struct comedi_device *dev, struct comedi_subdevice *s,
outb(s->state, dev->iobase + DAS16_DIO);
- return 2;
+ return insn->n;
}
static int das16_ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
+ const struct das16_board *board = comedi_board(dev);
int i;
int lsb, msb;
int chan;
@@ -1156,7 +846,7 @@ static int das16_ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s,
chan = CR_CHAN(insn->chanspec);
for (i = 0; i < insn->n; i++) {
- if (thisboard->ao_nbits == 12) {
+ if (board->ao_nbits == 12) {
lsb = (data[i] << 4) & 0xff;
msb = (data[i] >> 4) & 0xff;
} else {
@@ -1170,34 +860,6 @@ static int das16_ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s,
return i;
}
-static irqreturn_t das16_dma_interrupt(int irq, void *d)
-{
- int status;
- struct comedi_device *dev = d;
-
- status = inb(dev->iobase + DAS16_STATUS);
-
- if ((status & DAS16_INT) == 0) {
- DEBUG_PRINT("spurious interrupt\n");
- return IRQ_NONE;
- }
-
- /* clear interrupt */
- outb(0x00, dev->iobase + DAS16_STATUS);
- das16_interrupt(dev);
- return IRQ_HANDLED;
-}
-
-static void das16_timer_interrupt(unsigned long arg)
-{
- struct comedi_device *dev = (struct comedi_device *)arg;
-
- das16_interrupt(dev);
-
- if (devpriv->timer_running)
- mod_timer(&devpriv->timer, jiffies + timer_period());
-}
-
/* the pc104-das16jr (at least) has problems if the dma
transfer is interrupted in the middle of transferring
a 16 bit sample, so this function takes care to get
@@ -1234,6 +896,7 @@ static int disable_dma_on_even(struct comedi_device *dev)
static void das16_interrupt(struct comedi_device *dev)
{
+ const struct das16_board *board = comedi_board(dev);
unsigned long dma_flags, spin_flags;
struct comedi_subdevice *s = dev->read_subdev;
struct comedi_async *async;
@@ -1295,7 +958,7 @@ static void das16_interrupt(struct comedi_device *dev)
set_dma_count(devpriv->dma_chan, devpriv->dma_transfer_size);
enable_dma(devpriv->dma_chan);
/* reenable conversions for das1600 mode, (stupid hardware) */
- if (thisboard->size > 0x400 && devpriv->timer_mode == 0)
+ if (board->size > 0x400 && devpriv->timer_mode == 0)
outb(0x00, dev->iobase + DAS1600_CONV);
}
@@ -1309,18 +972,32 @@ static void das16_interrupt(struct comedi_device *dev)
cfc_handle_events(dev, s);
}
-static unsigned int das16_set_pacer(struct comedi_device *dev, unsigned int ns,
- int rounding_flags)
+static irqreturn_t das16_dma_interrupt(int irq, void *d)
{
- i8253_cascade_ns_to_timer_2div(devpriv->clockbase, &(devpriv->divisor1),
- &(devpriv->divisor2), &ns,
- rounding_flags & TRIG_ROUND_MASK);
+ int status;
+ struct comedi_device *dev = d;
- /* Write the values of ctr1 and ctr2 into counters 1 and 2 */
- i8254_load(dev->iobase + DAS16_CNTR0_DATA, 0, 1, devpriv->divisor1, 2);
- i8254_load(dev->iobase + DAS16_CNTR0_DATA, 0, 2, devpriv->divisor2, 2);
+ status = inb(dev->iobase + DAS16_STATUS);
- return ns;
+ if ((status & DAS16_INT) == 0) {
+ DEBUG_PRINT("spurious interrupt\n");
+ return IRQ_NONE;
+ }
+
+ /* clear interrupt */
+ outb(0x00, dev->iobase + DAS16_STATUS);
+ das16_interrupt(dev);
+ return IRQ_HANDLED;
+}
+
+static void das16_timer_interrupt(unsigned long arg)
+{
+ struct comedi_device *dev = (struct comedi_device *)arg;
+
+ das16_interrupt(dev);
+
+ if (devpriv->timer_running)
+ mod_timer(&devpriv->timer, jiffies + timer_period());
}
static void reg_dump(struct comedi_device *dev)
@@ -1343,6 +1020,7 @@ static void reg_dump(struct comedi_device *dev)
static int das16_probe(struct comedi_device *dev, struct comedi_devconfig *it)
{
+ const struct das16_board *board = comedi_board(dev);
int status;
int diobits;
@@ -1367,9 +1045,9 @@ static int das16_probe(struct comedi_device *dev, struct comedi_devconfig *it)
diobits = inb(dev->iobase + DAS16_DIO) & 0xf0;
printk(KERN_INFO " id bits are 0x%02x\n", diobits);
- if (thisboard->id != diobits) {
+ if (board->id != diobits) {
printk(KERN_INFO " requested board's id bits are 0x%x (ignore)\n",
- thisboard->id);
+ board->id);
}
return 0;
@@ -1394,6 +1072,23 @@ static int das1600_mode_detect(struct comedi_device *dev)
return 0;
}
+static void das16_ai_munge(struct comedi_device *dev,
+ struct comedi_subdevice *s, void *array,
+ unsigned int num_bytes,
+ unsigned int start_chan_index)
+{
+ const struct das16_board *board = comedi_board(dev);
+ unsigned int i, num_samples = num_bytes / sizeof(short);
+ short *data = array;
+
+ for (i = 0; i < num_samples; i++) {
+ data[i] = le16_to_cpu(data[i]);
+ if (board->ai_nbits == 12)
+ data[i] = (data[i] >> 4) & 0xfff;
+
+ }
+}
+
/*
*
* Options list:
@@ -1402,9 +1097,9 @@ static int das1600_mode_detect(struct comedi_device *dev)
* 2 DMA
* 3 Clock speed (in MHz)
*/
-
static int das16_attach(struct comedi_device *dev, struct comedi_devconfig *it)
{
+ const struct das16_board *board = comedi_board(dev);
struct comedi_subdevice *s;
int ret;
unsigned int irq;
@@ -1443,9 +1138,9 @@ static int das16_attach(struct comedi_device *dev, struct comedi_devconfig *it)
if (ret < 0)
return ret;
- if (thisboard->size < 0x400) {
- printk(" 0x%04lx-0x%04lx\n", iobase, iobase + thisboard->size);
- if (!request_region(iobase, thisboard->size, "das16")) {
+ if (board->size < 0x400) {
+ printk(" 0x%04lx-0x%04lx\n", iobase, iobase + board->size);
+ if (!request_region(iobase, board->size, "das16")) {
printk(KERN_ERR " I/O port conflict\n");
return -EIO;
}
@@ -1453,18 +1148,18 @@ static int das16_attach(struct comedi_device *dev, struct comedi_devconfig *it)
printk(KERN_INFO " 0x%04lx-0x%04lx 0x%04lx-0x%04lx\n",
iobase, iobase + 0x0f,
iobase + 0x400,
- iobase + 0x400 + (thisboard->size & 0x3ff));
+ iobase + 0x400 + (board->size & 0x3ff));
if (!request_region(iobase, 0x10, "das16")) {
printk(KERN_ERR " I/O port conflict: 0x%04lx-0x%04lx\n",
iobase, iobase + 0x0f);
return -EIO;
}
- if (!request_region(iobase + 0x400, thisboard->size & 0x3ff,
+ if (!request_region(iobase + 0x400, board->size & 0x3ff,
"das16")) {
release_region(iobase, 0x10);
printk(KERN_ERR " I/O port conflict: 0x%04lx-0x%04lx\n",
iobase + 0x400,
- iobase + 0x400 + (thisboard->size & 0x3ff));
+ iobase + 0x400 + (board->size & 0x3ff));
return -EIO;
}
}
@@ -1476,10 +1171,10 @@ static int das16_attach(struct comedi_device *dev, struct comedi_devconfig *it)
printk(KERN_ERR " id bits do not match selected board, aborting\n");
return -EINVAL;
}
- dev->board_name = thisboard->name;
+ dev->board_name = board->name;
/* get master clock speed */
- if (thisboard->size < 0x400) {
+ if (board->size < 0x400) {
if (it->options[3])
devpriv->clockbase = 1000 / it->options[3];
else
@@ -1535,7 +1230,7 @@ static int das16_attach(struct comedi_device *dev, struct comedi_devconfig *it)
}
/* get any user-defined input range */
- if (thisboard->ai_pg == das16_pg_none &&
+ if (board->ai_pg == das16_pg_none &&
(it->options[4] || it->options[5])) {
/* allocate single-range range table */
devpriv->user_ai_range_table =
@@ -1569,14 +1264,14 @@ static int das16_attach(struct comedi_device *dev, struct comedi_devconfig *it)
}
devpriv->timer_mode = timer_mode ? 1 : 0;
- ret = alloc_subdevices(dev, 5);
- if (ret < 0)
+ ret = comedi_alloc_subdevices(dev, 5);
+ if (ret)
return ret;
s = dev->subdevices + 0;
dev->read_subdev = s;
/* ai */
- if (thisboard->ai) {
+ if (board->ai) {
s->type = COMEDI_SUBD_AI;
s->subdev_flags = SDF_READABLE | SDF_CMD_READ;
if (devpriv->ai_singleended) {
@@ -1588,15 +1283,15 @@ static int das16_attach(struct comedi_device *dev, struct comedi_devconfig *it)
s->len_chanlist = 8;
s->subdev_flags |= SDF_DIFF;
}
- s->maxdata = (1 << thisboard->ai_nbits) - 1;
+ s->maxdata = (1 << board->ai_nbits) - 1;
if (devpriv->user_ai_range_table) { /* user defined ai range */
s->range_table = devpriv->user_ai_range_table;
} else if (devpriv->ai_unipolar) {
- s->range_table = das16_ai_uni_lranges[thisboard->ai_pg];
+ s->range_table = das16_ai_uni_lranges[board->ai_pg];
} else {
- s->range_table = das16_ai_bip_lranges[thisboard->ai_pg];
+ s->range_table = das16_ai_bip_lranges[board->ai_pg];
}
- s->insn_read = thisboard->ai;
+ s->insn_read = board->ai;
s->do_cmdtest = das16_cmd_test;
s->do_cmd = das16_cmd_exec;
s->cancel = das16_cancel;
@@ -1607,44 +1302,44 @@ static int das16_attach(struct comedi_device *dev, struct comedi_devconfig *it)
s = dev->subdevices + 1;
/* ao */
- if (thisboard->ao) {
+ if (board->ao) {
s->type = COMEDI_SUBD_AO;
s->subdev_flags = SDF_WRITABLE;
s->n_chan = 2;
- s->maxdata = (1 << thisboard->ao_nbits) - 1;
+ s->maxdata = (1 << board->ao_nbits) - 1;
/* user defined ao range */
if (devpriv->user_ao_range_table)
s->range_table = devpriv->user_ao_range_table;
else
s->range_table = &range_unknown;
- s->insn_write = thisboard->ao;
+ s->insn_write = board->ao;
} else {
s->type = COMEDI_SUBD_UNUSED;
}
s = dev->subdevices + 2;
/* di */
- if (thisboard->di) {
+ if (board->di) {
s->type = COMEDI_SUBD_DI;
s->subdev_flags = SDF_READABLE;
s->n_chan = 4;
s->maxdata = 1;
s->range_table = &range_digital;
- s->insn_bits = thisboard->di;
+ s->insn_bits = board->di;
} else {
s->type = COMEDI_SUBD_UNUSED;
}
s = dev->subdevices + 3;
/* do */
- if (thisboard->do_) {
+ if (board->do_) {
s->type = COMEDI_SUBD_DO;
s->subdev_flags = SDF_WRITABLE | SDF_READABLE;
s->n_chan = 4;
s->maxdata = 1;
s->range_table = &range_digital;
- s->insn_bits = thisboard->do_;
+ s->insn_bits = board->do_;
/* initialize digital output lines */
outb(s->state, dev->iobase + DAS16_DIO);
} else {
@@ -1653,9 +1348,9 @@ static int das16_attach(struct comedi_device *dev, struct comedi_devconfig *it)
s = dev->subdevices + 4;
/* 8255 */
- if (thisboard->i8255_offset != 0) {
+ if (board->i8255_offset != 0) {
subdev_8255_init(dev, s, NULL, (dev->iobase +
- thisboard->i8255_offset));
+ board->i8255_offset));
} else {
s->type = COMEDI_SUBD_UNUSED;
}
@@ -1666,7 +1361,7 @@ static int das16_attach(struct comedi_device *dev, struct comedi_devconfig *it)
outb(devpriv->control_state, dev->iobase + DAS16_CONTROL);
/* turn on das1600 mode if available */
- if (thisboard->size > 0x400) {
+ if (board->size > 0x400) {
outb(DAS1600_ENABLE_VAL, dev->iobase + DAS1600_ENABLE);
outb(0, dev->iobase + DAS1600_CONV);
outb(0, dev->iobase + DAS1600_BURST);
@@ -1675,15 +1370,13 @@ static int das16_attach(struct comedi_device *dev, struct comedi_devconfig *it)
return 0;
}
-static int das16_detach(struct comedi_device *dev)
+static void das16_detach(struct comedi_device *dev)
{
- printk(KERN_INFO "comedi%d: das16: remove\n", dev->minor);
+ const struct das16_board *board = comedi_board(dev);
das16_reset(dev);
-
if (dev->subdevices)
subdev_8255_cleanup(dev, dev->subdevices + 4);
-
if (devpriv) {
int i;
for (i = 0; i < 2; i++) {
@@ -1698,93 +1391,329 @@ static int das16_detach(struct comedi_device *dev)
kfree(devpriv->user_ai_range_table);
kfree(devpriv->user_ao_range_table);
}
-
if (dev->irq)
free_irq(dev->irq, dev);
-
if (dev->iobase) {
- if (thisboard->size < 0x400) {
- release_region(dev->iobase, thisboard->size);
+ if (board->size < 0x400) {
+ release_region(dev->iobase, board->size);
} else {
release_region(dev->iobase, 0x10);
release_region(dev->iobase + 0x400,
- thisboard->size & 0x3ff);
+ board->size & 0x3ff);
}
}
-
- return 0;
-}
-
-static int __init driver_das16_init_module(void)
-{
- return comedi_driver_register(&driver_das16);
-}
-
-static void __exit driver_das16_cleanup_module(void)
-{
- comedi_driver_unregister(&driver_das16);
-}
-
-module_init(driver_das16_init_module);
-module_exit(driver_das16_cleanup_module);
-
-/* utility function that suggests a dma transfer size in bytes */
-static unsigned int das16_suggest_transfer_size(struct comedi_device *dev,
- struct comedi_cmd cmd)
-{
- unsigned int size;
- unsigned int freq;
-
- /* if we are using timer interrupt, we don't care how long it
- * will take to complete transfer since it will be interrupted
- * by timer interrupt */
- if (devpriv->timer_mode)
- return DAS16_DMA_SIZE;
-
- /* otherwise, we are relying on dma terminal count interrupt,
- * so pick a reasonable size */
- if (cmd.convert_src == TRIG_TIMER)
- freq = 1000000000 / cmd.convert_arg;
- else if (cmd.scan_begin_src == TRIG_TIMER)
- freq = (1000000000 / cmd.scan_begin_arg) * cmd.chanlist_len;
- /* return some default value */
- else
- freq = 0xffffffff;
-
- if (cmd.flags & TRIG_WAKE_EOS) {
- size = sample_size * cmd.chanlist_len;
- } else {
- /* make buffer fill in no more than 1/3 second */
- size = (freq / 3) * sample_size;
- }
-
- /* set a minimum and maximum size allowed */
- if (size > DAS16_DMA_SIZE)
- size = DAS16_DMA_SIZE - DAS16_DMA_SIZE % sample_size;
- else if (size < sample_size)
- size = sample_size;
-
- if (cmd.stop_src == TRIG_COUNT && size > devpriv->adc_byte_count)
- size = devpriv->adc_byte_count;
-
- return size;
}
-static void das16_ai_munge(struct comedi_device *dev,
- struct comedi_subdevice *s, void *array,
- unsigned int num_bytes,
- unsigned int start_chan_index)
-{
- unsigned int i, num_samples = num_bytes / sizeof(short);
- short *data = array;
-
- for (i = 0; i < num_samples; i++) {
- data[i] = le16_to_cpu(data[i]);
- if (thisboard->ai_nbits == 12)
- data[i] = (data[i] >> 4) & 0xfff;
+static const struct das16_board das16_boards[] = {
+ {
+ .name = "das-16",
+ .ai = das16_ai_rinsn,
+ .ai_nbits = 12,
+ .ai_speed = 15000,
+ .ai_pg = das16_pg_none,
+ .ao = das16_ao_winsn,
+ .ao_nbits = 12,
+ .di = das16_di_rbits,
+ .do_ = das16_do_wbits,
+ .i8255_offset = 0x10,
+ .i8254_offset = 0x0c,
+ .size = 0x14,
+ .id = 0x00,
+ }, {
+ .name = "das-16g",
+ .ai = das16_ai_rinsn,
+ .ai_nbits = 12,
+ .ai_speed = 15000,
+ .ai_pg = das16_pg_none,
+ .ao = das16_ao_winsn,
+ .ao_nbits = 12,
+ .di = das16_di_rbits,
+ .do_ = das16_do_wbits,
+ .i8255_offset = 0x10,
+ .i8254_offset = 0x0c,
+ .size = 0x14,
+ .id = 0x00,
+ }, {
+ .name = "das-16f",
+ .ai = das16_ai_rinsn,
+ .ai_nbits = 12,
+ .ai_speed = 8500,
+ .ai_pg = das16_pg_none,
+ .ao = das16_ao_winsn,
+ .ao_nbits = 12,
+ .di = das16_di_rbits,
+ .do_ = das16_do_wbits,
+ .i8255_offset = 0x10,
+ .i8254_offset = 0x0c,
+ .size = 0x14,
+ .id = 0x00,
+ }, {
+ .name = "cio-das16",
+ .ai = das16_ai_rinsn,
+ .ai_nbits = 12,
+ .ai_speed = 20000,
+ .ai_pg = das16_pg_none,
+ .ao = das16_ao_winsn,
+ .ao_nbits = 12,
+ .di = das16_di_rbits,
+ .do_ = das16_do_wbits,
+ .i8255_offset = 0x10,
+ .i8254_offset = 0x0c,
+ .size = 0x14,
+ .id = 0x80,
+ }, {
+ .name = "cio-das16/f",
+ .ai = das16_ai_rinsn,
+ .ai_nbits = 12,
+ .ai_speed = 10000,
+ .ai_pg = das16_pg_none,
+ .ao = das16_ao_winsn,
+ .ao_nbits = 12,
+ .di = das16_di_rbits,
+ .do_ = das16_do_wbits,
+ .i8255_offset = 0x10,
+ .i8254_offset = 0x0c,
+ .size = 0x14,
+ .id = 0x80,
+ }, {
+ .name = "cio-das16/jr",
+ .ai = das16_ai_rinsn,
+ .ai_nbits = 12,
+ .ai_speed = 7692,
+ .ai_pg = das16_pg_16jr,
+ .ao = NULL,
+ .di = das16_di_rbits,
+ .do_ = das16_do_wbits,
+ .i8255_offset = 0,
+ .i8254_offset = 0x0c,
+ .size = 0x10,
+ .id = 0x00,
+ }, {
+ .name = "pc104-das16jr",
+ .ai = das16_ai_rinsn,
+ .ai_nbits = 12,
+ .ai_speed = 3300,
+ .ai_pg = das16_pg_16jr,
+ .ao = NULL,
+ .di = das16_di_rbits,
+ .do_ = das16_do_wbits,
+ .i8255_offset = 0,
+ .i8254_offset = 0x0c,
+ .size = 0x10,
+ .id = 0x00,
+ }, {
+ .name = "cio-das16jr/16",
+ .ai = das16_ai_rinsn,
+ .ai_nbits = 16,
+ .ai_speed = 10000,
+ .ai_pg = das16_pg_16jr_16,
+ .ao = NULL,
+ .di = das16_di_rbits,
+ .do_ = das16_do_wbits,
+ .i8255_offset = 0,
+ .i8254_offset = 0x0c,
+ .size = 0x10,
+ .id = 0x00,
+ }, {
+ .name = "pc104-das16jr/16",
+ .ai = das16_ai_rinsn,
+ .ai_nbits = 16,
+ .ai_speed = 10000,
+ .ai_pg = das16_pg_16jr_16,
+ .ao = NULL,
+ .di = das16_di_rbits,
+ .do_ = das16_do_wbits,
+ .i8255_offset = 0,
+ .i8254_offset = 0x0c,
+ .size = 0x10,
+ .id = 0x00,
+ }, {
+ .name = "das-1201",
+ .ai = das16_ai_rinsn,
+ .ai_nbits = 12,
+ .ai_speed = 20000,
+ .ai_pg = das16_pg_none,
+ .ao = NULL,
+ .di = das16_di_rbits,
+ .do_ = das16_do_wbits,
+ .i8255_offset = 0x400,
+ .i8254_offset = 0x0c,
+ .size = 0x408,
+ .id = 0x20,
+ }, {
+ .name = "das-1202",
+ .ai = das16_ai_rinsn,
+ .ai_nbits = 12,
+ .ai_speed = 10000,
+ .ai_pg = das16_pg_none,
+ .ao = NULL,
+ .di = das16_di_rbits,
+ .do_ = das16_do_wbits,
+ .i8255_offset = 0x400,
+ .i8254_offset = 0x0c,
+ .size = 0x408,
+ .id = 0x20,
+ }, {
+ .name = "das-1401",
+ .ai = das16_ai_rinsn,
+ .ai_nbits = 12,
+ .ai_speed = 10000,
+ .ai_pg = das16_pg_1601,
+ .ao = NULL,
+ .di = das16_di_rbits,
+ .do_ = das16_do_wbits,
+ .i8255_offset = 0x0,
+ .i8254_offset = 0x0c,
+ .size = 0x408,
+ .id = 0xc0,
+ }, {
+ .name = "das-1402",
+ .ai = das16_ai_rinsn,
+ .ai_nbits = 12,
+ .ai_speed = 10000,
+ .ai_pg = das16_pg_1602,
+ .ao = NULL,
+ .di = das16_di_rbits,
+ .do_ = das16_do_wbits,
+ .i8255_offset = 0x0,
+ .i8254_offset = 0x0c,
+ .size = 0x408,
+ .id = 0xc0,
+ }, {
+ .name = "das-1601",
+ .ai = das16_ai_rinsn,
+ .ai_nbits = 12,
+ .ai_speed = 10000,
+ .ai_pg = das16_pg_1601,
+ .ao = das16_ao_winsn,
+ .ao_nbits = 12,
+ .di = das16_di_rbits,
+ .do_ = das16_do_wbits,
+ .i8255_offset = 0x400,
+ .i8254_offset = 0x0c,
+ .size = 0x408,
+ .id = 0xc0,
+ }, {
+ .name = "das-1602",
+ .ai = das16_ai_rinsn,
+ .ai_nbits = 12,
+ .ai_speed = 10000,
+ .ai_pg = das16_pg_1602,
+ .ao = das16_ao_winsn,
+ .ao_nbits = 12,
+ .di = das16_di_rbits,
+ .do_ = das16_do_wbits,
+ .i8255_offset = 0x400,
+ .i8254_offset = 0x0c,
+ .size = 0x408,
+ .id = 0xc0,
+ }, {
+ .name = "cio-das1401/12",
+ .ai = das16_ai_rinsn,
+ .ai_nbits = 12,
+ .ai_speed = 6250,
+ .ai_pg = das16_pg_1601,
+ .ao = NULL,
+ .di = das16_di_rbits,
+ .do_ = das16_do_wbits,
+ .i8255_offset = 0,
+ .i8254_offset = 0x0c,
+ .size = 0x408,
+ .id = 0xc0,
+ }, {
+ .name = "cio-das1402/12",
+ .ai = das16_ai_rinsn,
+ .ai_nbits = 12,
+ .ai_speed = 6250,
+ .ai_pg = das16_pg_1602,
+ .ao = NULL,
+ .di = das16_di_rbits,
+ .do_ = das16_do_wbits,
+ .i8255_offset = 0,
+ .i8254_offset = 0x0c,
+ .size = 0x408,
+ .id = 0xc0,
+ }, {
+ .name = "cio-das1402/16",
+ .ai = das16_ai_rinsn,
+ .ai_nbits = 16,
+ .ai_speed = 10000,
+ .ai_pg = das16_pg_1602,
+ .ao = NULL,
+ .di = das16_di_rbits,
+ .do_ = das16_do_wbits,
+ .i8255_offset = 0,
+ .i8254_offset = 0x0c,
+ .size = 0x408,
+ .id = 0xc0,
+ }, {
+ .name = "cio-das1601/12",
+ .ai = das16_ai_rinsn,
+ .ai_nbits = 12,
+ .ai_speed = 6250,
+ .ai_pg = das16_pg_1601,
+ .ao = das16_ao_winsn,
+ .ao_nbits = 12,
+ .di = das16_di_rbits,
+ .do_ = das16_do_wbits,
+ .i8255_offset = 0x400,
+ .i8254_offset = 0x0c,
+ .size = 0x408,
+ .id = 0xc0,
+ }, {
+ .name = "cio-das1602/12",
+ .ai = das16_ai_rinsn,
+ .ai_nbits = 12,
+ .ai_speed = 10000,
+ .ai_pg = das16_pg_1602,
+ .ao = das16_ao_winsn,
+ .ao_nbits = 12,
+ .di = das16_di_rbits,
+ .do_ = das16_do_wbits,
+ .i8255_offset = 0x400,
+ .i8254_offset = 0x0c,
+ .size = 0x408,
+ .id = 0xc0,
+ }, {
+ .name = "cio-das1602/16",
+ .ai = das16_ai_rinsn,
+ .ai_nbits = 16,
+ .ai_speed = 10000,
+ .ai_pg = das16_pg_1602,
+ .ao = das16_ao_winsn,
+ .ao_nbits = 12,
+ .di = das16_di_rbits,
+ .do_ = das16_do_wbits,
+ .i8255_offset = 0x400,
+ .i8254_offset = 0x0c,
+ .size = 0x408,
+ .id = 0xc0,
+ }, {
+ .name = "cio-das16/330",
+ .ai = das16_ai_rinsn,
+ .ai_nbits = 12,
+ .ai_speed = 3030,
+ .ai_pg = das16_pg_16jr,
+ .ao = NULL,
+ .di = das16_di_rbits,
+ .do_ = das16_do_wbits,
+ .i8255_offset = 0,
+ .i8254_offset = 0x0c,
+ .size = 0x14,
+ .id = 0xf0,
+ },
+};
- }
-}
+static struct comedi_driver das16_driver = {
+ .driver_name = "das16",
+ .module = THIS_MODULE,
+ .attach = das16_attach,
+ .detach = das16_detach,
+ .board_name = &das16_boards[0].name,
+ .num_names = ARRAY_SIZE(das16_boards),
+ .offset = sizeof(das16_boards[0]),
+};
+module_comedi_driver(das16_driver);
MODULE_AUTHOR("Comedi http://www.comedi.org");
MODULE_DESCRIPTION("Comedi low-level driver");
diff --git a/drivers/staging/comedi/drivers/das16m1.c b/drivers/staging/comedi/drivers/das16m1.c
index 5376e718e3d7..200926347861 100644
--- a/drivers/staging/comedi/drivers/das16m1.c
+++ b/drivers/staging/comedi/drivers/das16m1.c
@@ -132,57 +132,11 @@ static const struct comedi_lrange range_das16m1 = { 9,
}
};
-static int das16m1_do_wbits(struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data);
-static int das16m1_di_rbits(struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data);
-static int das16m1_ai_rinsn(struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data);
-
-static int das16m1_cmd_test(struct comedi_device *dev,
- struct comedi_subdevice *s, struct comedi_cmd *cmd);
-static int das16m1_cmd_exec(struct comedi_device *dev,
- struct comedi_subdevice *s);
-static int das16m1_cancel(struct comedi_device *dev,
- struct comedi_subdevice *s);
-
-static int das16m1_poll(struct comedi_device *dev, struct comedi_subdevice *s);
-static irqreturn_t das16m1_interrupt(int irq, void *d);
-static void das16m1_handler(struct comedi_device *dev, unsigned int status);
-
-static unsigned int das16m1_set_pacer(struct comedi_device *dev,
- unsigned int ns, int round_flag);
-
-static int das16m1_irq_bits(unsigned int irq);
-
struct das16m1_board {
const char *name;
unsigned int ai_speed;
};
-static const struct das16m1_board das16m1_boards[] = {
- {
- .name = "cio-das16/m1", /* CIO-DAS16_M1.pdf */
- .ai_speed = 1000, /* 1MHz max speed */
- },
-};
-
-static int das16m1_attach(struct comedi_device *dev,
- struct comedi_devconfig *it);
-static int das16m1_detach(struct comedi_device *dev);
-static struct comedi_driver driver_das16m1 = {
- .driver_name = "das16m1",
- .module = THIS_MODULE,
- .attach = das16m1_attach,
- .detach = das16m1_detach,
- .board_name = &das16m1_boards[0].name,
- .num_names = ARRAY_SIZE(das16m1_boards),
- .offset = sizeof(das16m1_boards[0]),
-};
-
struct das16m1_private_struct {
unsigned int control_state;
volatile unsigned int adc_count; /* number of samples completed */
@@ -196,29 +150,24 @@ struct das16m1_private_struct {
unsigned int divisor2; /* divides master clock to obtain conversion speed */
};
#define devpriv ((struct das16m1_private_struct *)(dev->private))
-#define thisboard ((const struct das16m1_board *)(dev->board_ptr))
-static int __init driver_das16m1_init_module(void)
+static inline short munge_sample(short data)
{
- return comedi_driver_register(&driver_das16m1);
+ return (data >> 4) & 0xfff;
}
-static void __exit driver_das16m1_cleanup_module(void)
+static void munge_sample_array(short *array, unsigned int num_elements)
{
- comedi_driver_unregister(&driver_das16m1);
-}
-
-module_init(driver_das16m1_init_module);
-module_exit(driver_das16m1_cleanup_module);
+ unsigned int i;
-static inline short munge_sample(short data)
-{
- return (data >> 4) & 0xfff;
+ for (i = 0; i < num_elements; i++)
+ array[i] = munge_sample(array[i]);
}
static int das16m1_cmd_test(struct comedi_device *dev,
struct comedi_subdevice *s, struct comedi_cmd *cmd)
{
+ const struct das16m1_board *board = comedi_board(dev);
unsigned int err = 0, tmp, i;
/* make sure triggers are valid */
@@ -276,8 +225,8 @@ static int das16m1_cmd_test(struct comedi_device *dev,
}
if (cmd->convert_src == TRIG_TIMER) {
- if (cmd->convert_arg < thisboard->ai_speed) {
- cmd->convert_arg = thisboard->ai_speed;
+ if (cmd->convert_arg < board->ai_speed) {
+ cmd->convert_arg = board->ai_speed;
err++;
}
}
@@ -340,6 +289,25 @@ static int das16m1_cmd_test(struct comedi_device *dev,
return 0;
}
+/* This function takes a time in nanoseconds and sets the *
+ * 2 pacer clocks to the closest frequency possible. It also *
+ * returns the actual sampling period. */
+static unsigned int das16m1_set_pacer(struct comedi_device *dev,
+ unsigned int ns, int rounding_flags)
+{
+ i8253_cascade_ns_to_timer_2div(DAS16M1_XTAL, &(devpriv->divisor1),
+ &(devpriv->divisor2), &ns,
+ rounding_flags & TRIG_ROUND_MASK);
+
+ /* Write the values of ctr1 and ctr2 into counters 1 and 2 */
+ i8254_load(dev->iobase + DAS16M1_8254_SECOND, 0, 1, devpriv->divisor1,
+ 2);
+ i8254_load(dev->iobase + DAS16M1_8254_SECOND, 0, 2, devpriv->divisor2,
+ 2);
+
+ return ns;
+}
+
static int das16m1_cmd_exec(struct comedi_device *dev,
struct comedi_subdevice *s)
{
@@ -460,7 +428,7 @@ static int das16m1_di_rbits(struct comedi_device *dev,
data[1] = bits;
data[0] = 0;
- return 2;
+ return insn->n;
}
static int das16m1_do_wbits(struct comedi_device *dev,
@@ -481,58 +449,7 @@ static int das16m1_do_wbits(struct comedi_device *dev,
outb(devpriv->do_bits, dev->iobase + DAS16M1_DIO);
- return 2;
-}
-
-static int das16m1_poll(struct comedi_device *dev, struct comedi_subdevice *s)
-{
- unsigned long flags;
- unsigned int status;
-
- /* prevent race with interrupt handler */
- spin_lock_irqsave(&dev->spinlock, flags);
- status = inb(dev->iobase + DAS16M1_CS);
- das16m1_handler(dev, status);
- spin_unlock_irqrestore(&dev->spinlock, flags);
-
- return s->async->buf_write_count - s->async->buf_read_count;
-}
-
-static irqreturn_t das16m1_interrupt(int irq, void *d)
-{
- int status;
- struct comedi_device *dev = d;
-
- if (dev->attached == 0) {
- comedi_error(dev, "premature interrupt");
- return IRQ_HANDLED;
- }
- /* prevent race with comedi_poll() */
- spin_lock(&dev->spinlock);
-
- status = inb(dev->iobase + DAS16M1_CS);
-
- if ((status & (IRQDATA | OVRUN)) == 0) {
- comedi_error(dev, "spurious interrupt");
- spin_unlock(&dev->spinlock);
- return IRQ_NONE;
- }
-
- das16m1_handler(dev, status);
-
- /* clear interrupt */
- outb(0, dev->iobase + DAS16M1_CLEAR_INTR);
-
- spin_unlock(&dev->spinlock);
- return IRQ_HANDLED;
-}
-
-static void munge_sample_array(short *array, unsigned int num_elements)
-{
- unsigned int i;
-
- for (i = 0; i < num_elements; i++)
- array[i] = munge_sample(array[i]);
+ return insn->n;
}
static void das16m1_handler(struct comedi_device *dev, unsigned int status)
@@ -596,23 +513,47 @@ static void das16m1_handler(struct comedi_device *dev, unsigned int status)
}
-/* This function takes a time in nanoseconds and sets the *
- * 2 pacer clocks to the closest frequency possible. It also *
- * returns the actual sampling period. */
-static unsigned int das16m1_set_pacer(struct comedi_device *dev,
- unsigned int ns, int rounding_flags)
+static int das16m1_poll(struct comedi_device *dev, struct comedi_subdevice *s)
{
- i8253_cascade_ns_to_timer_2div(DAS16M1_XTAL, &(devpriv->divisor1),
- &(devpriv->divisor2), &ns,
- rounding_flags & TRIG_ROUND_MASK);
+ unsigned long flags;
+ unsigned int status;
- /* Write the values of ctr1 and ctr2 into counters 1 and 2 */
- i8254_load(dev->iobase + DAS16M1_8254_SECOND, 0, 1, devpriv->divisor1,
- 2);
- i8254_load(dev->iobase + DAS16M1_8254_SECOND, 0, 2, devpriv->divisor2,
- 2);
+ /* prevent race with interrupt handler */
+ spin_lock_irqsave(&dev->spinlock, flags);
+ status = inb(dev->iobase + DAS16M1_CS);
+ das16m1_handler(dev, status);
+ spin_unlock_irqrestore(&dev->spinlock, flags);
- return ns;
+ return s->async->buf_write_count - s->async->buf_read_count;
+}
+
+static irqreturn_t das16m1_interrupt(int irq, void *d)
+{
+ int status;
+ struct comedi_device *dev = d;
+
+ if (dev->attached == 0) {
+ comedi_error(dev, "premature interrupt");
+ return IRQ_HANDLED;
+ }
+ /* prevent race with comedi_poll() */
+ spin_lock(&dev->spinlock);
+
+ status = inb(dev->iobase + DAS16M1_CS);
+
+ if ((status & (IRQDATA | OVRUN)) == 0) {
+ comedi_error(dev, "spurious interrupt");
+ spin_unlock(&dev->spinlock);
+ return IRQ_NONE;
+ }
+
+ das16m1_handler(dev, status);
+
+ /* clear interrupt */
+ outb(0, dev->iobase + DAS16M1_CLEAR_INTR);
+
+ spin_unlock(&dev->spinlock);
+ return IRQ_HANDLED;
}
static int das16m1_irq_bits(unsigned int irq)
@@ -656,10 +597,10 @@ static int das16m1_irq_bits(unsigned int irq)
* 0 I/O base
* 1 IRQ
*/
-
static int das16m1_attach(struct comedi_device *dev,
struct comedi_devconfig *it)
{
+ const struct das16m1_board *board = comedi_board(dev);
struct comedi_subdevice *s;
int ret;
unsigned int irq;
@@ -671,14 +612,14 @@ static int das16m1_attach(struct comedi_device *dev,
if (ret < 0)
return ret;
- dev->board_name = thisboard->name;
+ dev->board_name = board->name;
- if (!request_region(iobase, DAS16M1_SIZE, driver_das16m1.driver_name)) {
+ if (!request_region(iobase, DAS16M1_SIZE, dev->driver->driver_name)) {
comedi_error(dev, "I/O port conflict\n");
return -EIO;
}
if (!request_region(iobase + DAS16M1_82C55, DAS16M1_SIZE2,
- driver_das16m1.driver_name)) {
+ dev->driver->driver_name)) {
release_region(iobase, DAS16M1_SIZE);
comedi_error(dev, "I/O port conflict\n");
return -EIO;
@@ -690,7 +631,7 @@ static int das16m1_attach(struct comedi_device *dev,
/* make sure it is valid */
if (das16m1_irq_bits(irq) >= 0) {
ret = request_irq(irq, das16m1_interrupt, 0,
- driver_das16m1.driver_name, dev);
+ dev->driver->driver_name, dev);
if (ret < 0)
return ret;
dev->irq = irq;
@@ -705,8 +646,8 @@ static int das16m1_attach(struct comedi_device *dev,
return -EINVAL;
}
- ret = alloc_subdevices(dev, 4);
- if (ret < 0)
+ ret = comedi_alloc_subdevices(dev, 4);
+ if (ret)
return ret;
s = dev->subdevices + 0;
@@ -763,25 +704,36 @@ static int das16m1_attach(struct comedi_device *dev,
return 0;
}
-static int das16m1_detach(struct comedi_device *dev)
+static void das16m1_detach(struct comedi_device *dev)
{
-
-/* das16m1_reset(dev); */
-
if (dev->subdevices)
subdev_8255_cleanup(dev, dev->subdevices + 3);
-
if (dev->irq)
free_irq(dev->irq, dev);
-
if (dev->iobase) {
release_region(dev->iobase, DAS16M1_SIZE);
release_region(dev->iobase + DAS16M1_82C55, DAS16M1_SIZE2);
}
-
- return 0;
}
+static const struct das16m1_board das16m1_boards[] = {
+ {
+ .name = "cio-das16/m1", /* CIO-DAS16_M1.pdf */
+ .ai_speed = 1000, /* 1MHz max speed */
+ },
+};
+
+static struct comedi_driver das16m1_driver = {
+ .driver_name = "das16m1",
+ .module = THIS_MODULE,
+ .attach = das16m1_attach,
+ .detach = das16m1_detach,
+ .board_name = &das16m1_boards[0].name,
+ .num_names = ARRAY_SIZE(das16m1_boards),
+ .offset = sizeof(das16m1_boards[0]),
+};
+module_comedi_driver(das16m1_driver);
+
MODULE_AUTHOR("Comedi http://www.comedi.org");
MODULE_DESCRIPTION("Comedi low-level driver");
MODULE_LICENSE("GPL");
diff --git a/drivers/staging/comedi/drivers/das1800.c b/drivers/staging/comedi/drivers/das1800.c
index 99ada5a53b9e..25e7e56a376f 100644
--- a/drivers/staging/comedi/drivers/das1800.c
+++ b/drivers/staging/comedi/drivers/das1800.c
@@ -183,49 +183,6 @@ enum {
das1802hr, das1802hr_da, das1801hc, das1802hc, das1801ao, das1802ao
};
-static int das1800_attach(struct comedi_device *dev,
- struct comedi_devconfig *it);
-static int das1800_detach(struct comedi_device *dev);
-static int das1800_probe(struct comedi_device *dev);
-static int das1800_cancel(struct comedi_device *dev,
- struct comedi_subdevice *s);
-static irqreturn_t das1800_interrupt(int irq, void *d);
-static int das1800_ai_poll(struct comedi_device *dev,
- struct comedi_subdevice *s);
-static void das1800_ai_handler(struct comedi_device *dev);
-static void das1800_handle_dma(struct comedi_device *dev,
- struct comedi_subdevice *s, unsigned int status);
-static void das1800_flush_dma(struct comedi_device *dev,
- struct comedi_subdevice *s);
-static void das1800_flush_dma_channel(struct comedi_device *dev,
- struct comedi_subdevice *s,
- unsigned int channel, uint16_t *buffer);
-static void das1800_handle_fifo_half_full(struct comedi_device *dev,
- struct comedi_subdevice *s);
-static void das1800_handle_fifo_not_empty(struct comedi_device *dev,
- struct comedi_subdevice *s);
-static int das1800_ai_do_cmdtest(struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_cmd *cmd);
-static int das1800_ai_do_cmd(struct comedi_device *dev,
- struct comedi_subdevice *s);
-static int das1800_ai_rinsn(struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data);
-static int das1800_ao_winsn(struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data);
-static int das1800_di_rbits(struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data);
-static int das1800_do_wbits(struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data);
-
-static int das1800_set_frequency(struct comedi_device *dev);
-static unsigned int burst_convert_arg(unsigned int convert_arg, int round_mode);
-static unsigned int suggest_transfer_size(struct comedi_cmd *cmd);
-
/* analog input ranges */
static const struct comedi_lrange range_ai_das1801 = {
8,
@@ -518,433 +475,182 @@ static const struct comedi_lrange range_ao_2 = {
};
*/
-static struct comedi_driver driver_das1800 = {
- .driver_name = "das1800",
- .module = THIS_MODULE,
- .attach = das1800_attach,
- .detach = das1800_detach,
- .num_names = ARRAY_SIZE(das1800_boards),
- .board_name = &das1800_boards[0].name,
- .offset = sizeof(struct das1800_board),
-};
-
-/*
- * A convenient macro that defines init_module() and cleanup_module(),
- * as necessary.
- */
-static int __init driver_das1800_init_module(void)
+static inline uint16_t munge_bipolar_sample(const struct comedi_device *dev,
+ uint16_t sample)
{
- return comedi_driver_register(&driver_das1800);
+ sample += 1 << (thisboard->resolution - 1);
+ return sample;
}
-static void __exit driver_das1800_cleanup_module(void)
+static void munge_data(struct comedi_device *dev, uint16_t * array,
+ unsigned int num_elements)
{
- comedi_driver_unregister(&driver_das1800);
-}
-
-module_init(driver_das1800_init_module);
-module_exit(driver_das1800_cleanup_module);
+ unsigned int i;
+ int unipolar;
-static int das1800_init_dma(struct comedi_device *dev, unsigned int dma0,
- unsigned int dma1)
-{
- unsigned long flags;
+ /* see if card is using a unipolar or bipolar range so we can munge data correctly */
+ unipolar = inb(dev->iobase + DAS1800_CONTROL_C) & UB;
- /* need an irq to do dma */
- if (dev->irq && dma0) {
- /* encode dma0 and dma1 into 2 digit hexadecimal for switch */
- switch ((dma0 & 0x7) | (dma1 << 4)) {
- case 0x5: /* dma0 == 5 */
- devpriv->dma_bits |= DMA_CH5;
- break;
- case 0x6: /* dma0 == 6 */
- devpriv->dma_bits |= DMA_CH6;
- break;
- case 0x7: /* dma0 == 7 */
- devpriv->dma_bits |= DMA_CH7;
- break;
- case 0x65: /* dma0 == 5, dma1 == 6 */
- devpriv->dma_bits |= DMA_CH5_CH6;
- break;
- case 0x76: /* dma0 == 6, dma1 == 7 */
- devpriv->dma_bits |= DMA_CH6_CH7;
- break;
- case 0x57: /* dma0 == 7, dma1 == 5 */
- devpriv->dma_bits |= DMA_CH7_CH5;
- break;
- default:
- dev_err(dev->hw_dev, " only supports dma channels 5 through 7\n"
- " Dual dma only allows the following combinations:\n"
- " dma 5,6 / 6,7 / or 7,5\n");
- return -EINVAL;
- break;
- }
- if (request_dma(dma0, driver_das1800.driver_name)) {
- dev_err(dev->hw_dev, "failed to allocate dma channel %i\n",
- dma0);
- return -EINVAL;
- }
- devpriv->dma0 = dma0;
- devpriv->dma_current = dma0;
- if (dma1) {
- if (request_dma(dma1, driver_das1800.driver_name)) {
- dev_err(dev->hw_dev, "failed to allocate dma channel %i\n",
- dma1);
- return -EINVAL;
- }
- devpriv->dma1 = dma1;
- }
- devpriv->ai_buf0 = kmalloc(DMA_BUF_SIZE, GFP_KERNEL | GFP_DMA);
- if (devpriv->ai_buf0 == NULL)
- return -ENOMEM;
- devpriv->dma_current_buf = devpriv->ai_buf0;
- if (dma1) {
- devpriv->ai_buf1 =
- kmalloc(DMA_BUF_SIZE, GFP_KERNEL | GFP_DMA);
- if (devpriv->ai_buf1 == NULL)
- return -ENOMEM;
- }
- flags = claim_dma_lock();
- disable_dma(devpriv->dma0);
- set_dma_mode(devpriv->dma0, DMA_MODE_READ);
- if (dma1) {
- disable_dma(devpriv->dma1);
- set_dma_mode(devpriv->dma1, DMA_MODE_READ);
- }
- release_dma_lock(flags);
+ /* convert to unsigned type if we are in a bipolar mode */
+ if (!unipolar) {
+ for (i = 0; i < num_elements; i++)
+ array[i] = munge_bipolar_sample(dev, array[i]);
}
- return 0;
}
-static int das1800_attach(struct comedi_device *dev,
- struct comedi_devconfig *it)
+static void das1800_handle_fifo_half_full(struct comedi_device *dev,
+ struct comedi_subdevice *s)
{
- struct comedi_subdevice *s;
- unsigned long iobase = it->options[0];
- unsigned int irq = it->options[1];
- unsigned int dma0 = it->options[2];
- unsigned int dma1 = it->options[3];
- unsigned long iobase2;
- int board;
- int retval;
-
- /* allocate and initialize dev->private */
- if (alloc_private(dev, sizeof(struct das1800_private)) < 0)
- return -ENOMEM;
-
- printk(KERN_DEBUG "comedi%d: %s: io 0x%lx", dev->minor,
- driver_das1800.driver_name, iobase);
- if (irq) {
- printk(KERN_CONT ", irq %u", irq);
- if (dma0) {
- printk(KERN_CONT ", dma %u", dma0);
- if (dma1)
- printk(KERN_CONT " and %u", dma1);
- }
- }
- printk(KERN_CONT "\n");
-
- if (iobase == 0) {
- dev_err(dev->hw_dev, "io base address required\n");
- return -EINVAL;
- }
-
- /* check if io addresses are available */
- if (!request_region(iobase, DAS1800_SIZE, driver_das1800.driver_name)) {
- printk
- (" I/O port conflict: failed to allocate ports 0x%lx to 0x%lx\n",
- iobase, iobase + DAS1800_SIZE - 1);
- return -EIO;
- }
- dev->iobase = iobase;
+ int numPoints = 0; /* number of points to read */
+ struct comedi_cmd *cmd = &s->async->cmd;
- board = das1800_probe(dev);
- if (board < 0) {
- dev_err(dev->hw_dev, "unable to determine board type\n");
- return -ENODEV;
- }
+ numPoints = FIFO_SIZE / 2;
+ /* if we only need some of the points */
+ if (cmd->stop_src == TRIG_COUNT && devpriv->count < numPoints)
+ numPoints = devpriv->count;
+ insw(dev->iobase + DAS1800_FIFO, devpriv->ai_buf0, numPoints);
+ munge_data(dev, devpriv->ai_buf0, numPoints);
+ cfc_write_array_to_buffer(s, devpriv->ai_buf0,
+ numPoints * sizeof(devpriv->ai_buf0[0]));
+ if (cmd->stop_src == TRIG_COUNT)
+ devpriv->count -= numPoints;
+ return;
+}
- dev->board_ptr = das1800_boards + board;
- dev->board_name = thisboard->name;
+static void das1800_handle_fifo_not_empty(struct comedi_device *dev,
+ struct comedi_subdevice *s)
+{
+ short dpnt;
+ int unipolar;
+ struct comedi_cmd *cmd = &s->async->cmd;
- /* if it is an 'ao' board with fancy analog out then we need extra io ports */
- if (thisboard->ao_ability == 2) {
- iobase2 = iobase + IOBASE2;
- if (!request_region(iobase2, DAS1800_SIZE,
- driver_das1800.driver_name)) {
- printk
- (" I/O port conflict: failed to allocate ports 0x%lx to 0x%lx\n",
- iobase2, iobase2 + DAS1800_SIZE - 1);
- return -EIO;
- }
- devpriv->iobase2 = iobase2;
- }
+ unipolar = inb(dev->iobase + DAS1800_CONTROL_C) & UB;
- /* grab our IRQ */
- if (irq) {
- if (request_irq(irq, das1800_interrupt, 0,
- driver_das1800.driver_name, dev)) {
- dev_dbg(dev->hw_dev, "unable to allocate irq %u\n",
- irq);
- return -EINVAL;
- }
+ while (inb(dev->iobase + DAS1800_STATUS) & FNE) {
+ if (cmd->stop_src == TRIG_COUNT && devpriv->count == 0)
+ break;
+ dpnt = inw(dev->iobase + DAS1800_FIFO);
+ /* convert to unsigned type if we are in a bipolar mode */
+ if (!unipolar)
+ ;
+ dpnt = munge_bipolar_sample(dev, dpnt);
+ cfc_write_to_buffer(s, dpnt);
+ if (cmd->stop_src == TRIG_COUNT)
+ devpriv->count--;
}
- dev->irq = irq;
- /* set bits that tell card which irq to use */
- switch (irq) {
- case 0:
- break;
- case 3:
- devpriv->irq_dma_bits |= 0x8;
- break;
- case 5:
- devpriv->irq_dma_bits |= 0x10;
- break;
- case 7:
- devpriv->irq_dma_bits |= 0x18;
- break;
- case 10:
- devpriv->irq_dma_bits |= 0x28;
- break;
- case 11:
- devpriv->irq_dma_bits |= 0x30;
- break;
- case 15:
- devpriv->irq_dma_bits |= 0x38;
- break;
- default:
- dev_err(dev->hw_dev, "irq out of range\n");
- return -EINVAL;
- break;
- }
+ return;
+}
- retval = das1800_init_dma(dev, dma0, dma1);
- if (retval < 0)
- return retval;
+/* Utility function used by das1800_flush_dma() and das1800_handle_dma().
+ * Assumes dma lock is held */
+static void das1800_flush_dma_channel(struct comedi_device *dev,
+ struct comedi_subdevice *s,
+ unsigned int channel, uint16_t *buffer)
+{
+ unsigned int num_bytes, num_samples;
+ struct comedi_cmd *cmd = &s->async->cmd;
- if (devpriv->ai_buf0 == NULL) {
- devpriv->ai_buf0 =
- kmalloc(FIFO_SIZE * sizeof(uint16_t), GFP_KERNEL);
- if (devpriv->ai_buf0 == NULL)
- return -ENOMEM;
- }
+ disable_dma(channel);
- if (alloc_subdevices(dev, 4) < 0)
- return -ENOMEM;
+ /* clear flip-flop to make sure 2-byte registers
+ * get set correctly */
+ clear_dma_ff(channel);
- /* analog input subdevice */
- s = dev->subdevices + 0;
- dev->read_subdev = s;
- s->type = COMEDI_SUBD_AI;
- s->subdev_flags = SDF_READABLE | SDF_DIFF | SDF_GROUND | SDF_CMD_READ;
- if (thisboard->common)
- s->subdev_flags |= SDF_COMMON;
- s->n_chan = thisboard->qram_len;
- s->len_chanlist = thisboard->qram_len;
- s->maxdata = (1 << thisboard->resolution) - 1;
- s->range_table = thisboard->range_ai;
- s->do_cmd = das1800_ai_do_cmd;
- s->do_cmdtest = das1800_ai_do_cmdtest;
- s->insn_read = das1800_ai_rinsn;
- s->poll = das1800_ai_poll;
- s->cancel = das1800_cancel;
+ /* figure out how many points to read */
+ num_bytes = devpriv->dma_transfer_size - get_dma_residue(channel);
+ num_samples = num_bytes / sizeof(short);
- /* analog out */
- s = dev->subdevices + 1;
- if (thisboard->ao_ability == 1) {
- s->type = COMEDI_SUBD_AO;
- s->subdev_flags = SDF_WRITABLE;
- s->n_chan = thisboard->ao_n_chan;
- s->maxdata = (1 << thisboard->resolution) - 1;
- s->range_table = &range_ao_1;
- s->insn_write = das1800_ao_winsn;
- } else {
- s->type = COMEDI_SUBD_UNUSED;
- }
+ /* if we only need some of the points */
+ if (cmd->stop_src == TRIG_COUNT && devpriv->count < num_samples)
+ num_samples = devpriv->count;
- /* di */
- s = dev->subdevices + 2;
- s->type = COMEDI_SUBD_DI;
- s->subdev_flags = SDF_READABLE;
- s->n_chan = 4;
- s->maxdata = 1;
- s->range_table = &range_digital;
- s->insn_bits = das1800_di_rbits;
+ munge_data(dev, buffer, num_samples);
+ cfc_write_array_to_buffer(s, buffer, num_bytes);
+ if (s->async->cmd.stop_src == TRIG_COUNT)
+ devpriv->count -= num_samples;
- /* do */
- s = dev->subdevices + 3;
- s->type = COMEDI_SUBD_DO;
- s->subdev_flags = SDF_WRITABLE | SDF_READABLE;
- s->n_chan = thisboard->do_n_chan;
- s->maxdata = 1;
- s->range_table = &range_digital;
- s->insn_bits = das1800_do_wbits;
+ return;
+}
- das1800_cancel(dev, dev->read_subdev);
+/* flushes remaining data from board when external trigger has stopped acquisition
+ * and we are using dma transfers */
+static void das1800_flush_dma(struct comedi_device *dev,
+ struct comedi_subdevice *s)
+{
+ unsigned long flags;
+ const int dual_dma = devpriv->irq_dma_bits & DMA_DUAL;
- /* initialize digital out channels */
- outb(devpriv->do_bits, dev->iobase + DAS1800_DIGITAL);
+ flags = claim_dma_lock();
+ das1800_flush_dma_channel(dev, s, devpriv->dma_current,
+ devpriv->dma_current_buf);
- /* initialize analog out channels */
- if (thisboard->ao_ability == 1) {
- /* select 'update' dac channel for baseAddress + 0x0 */
- outb(DAC(thisboard->ao_n_chan - 1),
- dev->iobase + DAS1800_SELECT);
- outw(devpriv->ao_update_bits, dev->iobase + DAS1800_DAC);
+ if (dual_dma) {
+ /* switch to other channel and flush it */
+ if (devpriv->dma_current == devpriv->dma0) {
+ devpriv->dma_current = devpriv->dma1;
+ devpriv->dma_current_buf = devpriv->ai_buf1;
+ } else {
+ devpriv->dma_current = devpriv->dma0;
+ devpriv->dma_current_buf = devpriv->ai_buf0;
+ }
+ das1800_flush_dma_channel(dev, s, devpriv->dma_current,
+ devpriv->dma_current_buf);
}
- return 0;
-};
-
-static int das1800_detach(struct comedi_device *dev)
-{
- /* only free stuff if it has been allocated by _attach */
- if (dev->iobase)
- release_region(dev->iobase, DAS1800_SIZE);
- if (dev->irq)
- free_irq(dev->irq, dev);
- if (dev->private) {
- if (devpriv->iobase2)
- release_region(devpriv->iobase2, DAS1800_SIZE);
- if (devpriv->dma0)
- free_dma(devpriv->dma0);
- if (devpriv->dma1)
- free_dma(devpriv->dma1);
- kfree(devpriv->ai_buf0);
- kfree(devpriv->ai_buf1);
- }
+ release_dma_lock(flags);
- dev_dbg(dev->hw_dev, "comedi%d: %s: remove\n", dev->minor,
- driver_das1800.driver_name);
+ /* get any remaining samples in fifo */
+ das1800_handle_fifo_not_empty(dev, s);
- return 0;
-};
+ return;
+}
-/* probes and checks das-1800 series board type
- */
-static int das1800_probe(struct comedi_device *dev)
+static void das1800_handle_dma(struct comedi_device *dev,
+ struct comedi_subdevice *s, unsigned int status)
{
- int id;
- int board;
+ unsigned long flags;
+ const int dual_dma = devpriv->irq_dma_bits & DMA_DUAL;
- id = (inb(dev->iobase + DAS1800_DIGITAL) >> 4) & 0xf; /* get id bits */
- board = ((struct das1800_board *)dev->board_ptr) - das1800_boards;
+ flags = claim_dma_lock();
+ das1800_flush_dma_channel(dev, s, devpriv->dma_current,
+ devpriv->dma_current_buf);
+ /* re-enable dma channel */
+ set_dma_addr(devpriv->dma_current,
+ virt_to_bus(devpriv->dma_current_buf));
+ set_dma_count(devpriv->dma_current, devpriv->dma_transfer_size);
+ enable_dma(devpriv->dma_current);
+ release_dma_lock(flags);
- switch (id) {
- case 0x3:
- if (board == das1801st_da || board == das1802st_da ||
- board == das1701st_da || board == das1702st_da) {
- dev_dbg(dev->hw_dev, "Board model: %s\n",
- das1800_boards[board].name);
- return board;
- }
- printk
- (" Board model (probed, not recommended): das-1800st-da series\n");
- return das1801st;
- break;
- case 0x4:
- if (board == das1802hr_da || board == das1702hr_da) {
- dev_dbg(dev->hw_dev, "Board model: %s\n",
- das1800_boards[board].name);
- return board;
- }
- printk
- (" Board model (probed, not recommended): das-1802hr-da\n");
- return das1802hr;
- break;
- case 0x5:
- if (board == das1801ao || board == das1802ao ||
- board == das1701ao || board == das1702ao) {
- dev_dbg(dev->hw_dev, "Board model: %s\n",
- das1800_boards[board].name);
- return board;
- }
- printk
- (" Board model (probed, not recommended): das-1800ao series\n");
- return das1801ao;
- break;
- case 0x6:
- if (board == das1802hr || board == das1702hr) {
- dev_dbg(dev->hw_dev, "Board model: %s\n",
- das1800_boards[board].name);
- return board;
- }
- printk
- (" Board model (probed, not recommended): das-1802hr\n");
- return das1802hr;
- break;
- case 0x7:
- if (board == das1801st || board == das1802st ||
- board == das1701st || board == das1702st) {
- dev_dbg(dev->hw_dev, "Board model: %s\n",
- das1800_boards[board].name);
- return board;
- }
- printk
- (" Board model (probed, not recommended): das-1800st series\n");
- return das1801st;
- break;
- case 0x8:
- if (board == das1801hc || board == das1802hc) {
- dev_dbg(dev->hw_dev, "Board model: %s\n",
- das1800_boards[board].name);
- return board;
+ if (status & DMATC) {
+ /* clear DMATC interrupt bit */
+ outb(CLEAR_INTR_MASK & ~DMATC, dev->iobase + DAS1800_STATUS);
+ /* switch dma channels for next time, if appropriate */
+ if (dual_dma) {
+ /* read data from the other channel next time */
+ if (devpriv->dma_current == devpriv->dma0) {
+ devpriv->dma_current = devpriv->dma1;
+ devpriv->dma_current_buf = devpriv->ai_buf1;
+ } else {
+ devpriv->dma_current = devpriv->dma0;
+ devpriv->dma_current_buf = devpriv->ai_buf0;
+ }
}
- printk
- (" Board model (probed, not recommended): das-1800hc series\n");
- return das1801hc;
- break;
- default:
- printk
- (" Board model: probe returned 0x%x (unknown, please report)\n",
- id);
- return board;
- break;
}
- return -1;
-}
-static int das1800_ai_poll(struct comedi_device *dev,
- struct comedi_subdevice *s)
-{
- unsigned long flags;
-
- /* prevent race with interrupt handler */
- spin_lock_irqsave(&dev->spinlock, flags);
- das1800_ai_handler(dev);
- spin_unlock_irqrestore(&dev->spinlock, flags);
-
- return s->async->buf_write_count - s->async->buf_read_count;
+ return;
}
-static irqreturn_t das1800_interrupt(int irq, void *d)
+static int das1800_cancel(struct comedi_device *dev, struct comedi_subdevice *s)
{
- struct comedi_device *dev = d;
- unsigned int status;
-
- if (dev->attached == 0) {
- comedi_error(dev, "premature interrupt");
- return IRQ_HANDLED;
- }
-
- /* Prevent race with das1800_ai_poll() on multi processor systems.
- * Also protects indirect addressing in das1800_ai_handler */
- spin_lock(&dev->spinlock);
- status = inb(dev->iobase + DAS1800_STATUS);
-
- /* if interrupt was not caused by das-1800 */
- if (!(status & INT)) {
- spin_unlock(&dev->spinlock);
- return IRQ_NONE;
- }
- /* clear the interrupt status bit INT */
- outb(CLEAR_INTR_MASK & ~INT, dev->iobase + DAS1800_STATUS);
- /* handle interrupt */
- das1800_ai_handler(dev);
-
- spin_unlock(&dev->spinlock);
- return IRQ_HANDLED;
+ outb(0x0, dev->iobase + DAS1800_STATUS); /* disable conversions */
+ outb(0x0, dev->iobase + DAS1800_CONTROL_B); /* disable interrupts and dma */
+ outb(0x0, dev->iobase + DAS1800_CONTROL_A); /* disable and clear fifo and stop triggering */
+ if (devpriv->dma0)
+ disable_dma(devpriv->dma0);
+ if (devpriv->dma1)
+ disable_dma(devpriv->dma1);
+ return 0;
}
/* the guts of the interrupt handler, that is shared with das1800_ai_poll */
@@ -1001,182 +707,75 @@ static void das1800_ai_handler(struct comedi_device *dev)
return;
}
-static void das1800_handle_dma(struct comedi_device *dev,
- struct comedi_subdevice *s, unsigned int status)
+static int das1800_ai_poll(struct comedi_device *dev,
+ struct comedi_subdevice *s)
{
unsigned long flags;
- const int dual_dma = devpriv->irq_dma_bits & DMA_DUAL;
-
- flags = claim_dma_lock();
- das1800_flush_dma_channel(dev, s, devpriv->dma_current,
- devpriv->dma_current_buf);
- /* re-enable dma channel */
- set_dma_addr(devpriv->dma_current,
- virt_to_bus(devpriv->dma_current_buf));
- set_dma_count(devpriv->dma_current, devpriv->dma_transfer_size);
- enable_dma(devpriv->dma_current);
- release_dma_lock(flags);
-
- if (status & DMATC) {
- /* clear DMATC interrupt bit */
- outb(CLEAR_INTR_MASK & ~DMATC, dev->iobase + DAS1800_STATUS);
- /* switch dma channels for next time, if appropriate */
- if (dual_dma) {
- /* read data from the other channel next time */
- if (devpriv->dma_current == devpriv->dma0) {
- devpriv->dma_current = devpriv->dma1;
- devpriv->dma_current_buf = devpriv->ai_buf1;
- } else {
- devpriv->dma_current = devpriv->dma0;
- devpriv->dma_current_buf = devpriv->ai_buf0;
- }
- }
- }
- return;
-}
+ /* prevent race with interrupt handler */
+ spin_lock_irqsave(&dev->spinlock, flags);
+ das1800_ai_handler(dev);
+ spin_unlock_irqrestore(&dev->spinlock, flags);
-static inline uint16_t munge_bipolar_sample(const struct comedi_device *dev,
- uint16_t sample)
-{
- sample += 1 << (thisboard->resolution - 1);
- return sample;
+ return s->async->buf_write_count - s->async->buf_read_count;
}
-static void munge_data(struct comedi_device *dev, uint16_t * array,
- unsigned int num_elements)
+static irqreturn_t das1800_interrupt(int irq, void *d)
{
- unsigned int i;
- int unipolar;
-
- /* see if card is using a unipolar or bipolar range so we can munge data correctly */
- unipolar = inb(dev->iobase + DAS1800_CONTROL_C) & UB;
+ struct comedi_device *dev = d;
+ unsigned int status;
- /* convert to unsigned type if we are in a bipolar mode */
- if (!unipolar) {
- for (i = 0; i < num_elements; i++)
- array[i] = munge_bipolar_sample(dev, array[i]);
+ if (dev->attached == 0) {
+ comedi_error(dev, "premature interrupt");
+ return IRQ_HANDLED;
}
-}
-
-/* Utility function used by das1800_flush_dma() and das1800_handle_dma().
- * Assumes dma lock is held */
-static void das1800_flush_dma_channel(struct comedi_device *dev,
- struct comedi_subdevice *s,
- unsigned int channel, uint16_t *buffer)
-{
- unsigned int num_bytes, num_samples;
- struct comedi_cmd *cmd = &s->async->cmd;
-
- disable_dma(channel);
-
- /* clear flip-flop to make sure 2-byte registers
- * get set correctly */
- clear_dma_ff(channel);
-
- /* figure out how many points to read */
- num_bytes = devpriv->dma_transfer_size - get_dma_residue(channel);
- num_samples = num_bytes / sizeof(short);
-
- /* if we only need some of the points */
- if (cmd->stop_src == TRIG_COUNT && devpriv->count < num_samples)
- num_samples = devpriv->count;
-
- munge_data(dev, buffer, num_samples);
- cfc_write_array_to_buffer(s, buffer, num_bytes);
- if (s->async->cmd.stop_src == TRIG_COUNT)
- devpriv->count -= num_samples;
-
- return;
-}
-/* flushes remaining data from board when external trigger has stopped acquisition
- * and we are using dma transfers */
-static void das1800_flush_dma(struct comedi_device *dev,
- struct comedi_subdevice *s)
-{
- unsigned long flags;
- const int dual_dma = devpriv->irq_dma_bits & DMA_DUAL;
-
- flags = claim_dma_lock();
- das1800_flush_dma_channel(dev, s, devpriv->dma_current,
- devpriv->dma_current_buf);
+ /* Prevent race with das1800_ai_poll() on multi processor systems.
+ * Also protects indirect addressing in das1800_ai_handler */
+ spin_lock(&dev->spinlock);
+ status = inb(dev->iobase + DAS1800_STATUS);
- if (dual_dma) {
- /* switch to other channel and flush it */
- if (devpriv->dma_current == devpriv->dma0) {
- devpriv->dma_current = devpriv->dma1;
- devpriv->dma_current_buf = devpriv->ai_buf1;
- } else {
- devpriv->dma_current = devpriv->dma0;
- devpriv->dma_current_buf = devpriv->ai_buf0;
- }
- das1800_flush_dma_channel(dev, s, devpriv->dma_current,
- devpriv->dma_current_buf);
+ /* if interrupt was not caused by das-1800 */
+ if (!(status & INT)) {
+ spin_unlock(&dev->spinlock);
+ return IRQ_NONE;
}
+ /* clear the interrupt status bit INT */
+ outb(CLEAR_INTR_MASK & ~INT, dev->iobase + DAS1800_STATUS);
+ /* handle interrupt */
+ das1800_ai_handler(dev);
- release_dma_lock(flags);
-
- /* get any remaining samples in fifo */
- das1800_handle_fifo_not_empty(dev, s);
-
- return;
-}
-
-static void das1800_handle_fifo_half_full(struct comedi_device *dev,
- struct comedi_subdevice *s)
-{
- int numPoints = 0; /* number of points to read */
- struct comedi_cmd *cmd = &s->async->cmd;
-
- numPoints = FIFO_SIZE / 2;
- /* if we only need some of the points */
- if (cmd->stop_src == TRIG_COUNT && devpriv->count < numPoints)
- numPoints = devpriv->count;
- insw(dev->iobase + DAS1800_FIFO, devpriv->ai_buf0, numPoints);
- munge_data(dev, devpriv->ai_buf0, numPoints);
- cfc_write_array_to_buffer(s, devpriv->ai_buf0,
- numPoints * sizeof(devpriv->ai_buf0[0]));
- if (cmd->stop_src == TRIG_COUNT)
- devpriv->count -= numPoints;
- return;
+ spin_unlock(&dev->spinlock);
+ return IRQ_HANDLED;
}
-static void das1800_handle_fifo_not_empty(struct comedi_device *dev,
- struct comedi_subdevice *s)
+/* converts requested conversion timing to timing compatible with
+ * hardware, used only when card is in 'burst mode'
+ */
+static unsigned int burst_convert_arg(unsigned int convert_arg, int round_mode)
{
- short dpnt;
- int unipolar;
- struct comedi_cmd *cmd = &s->async->cmd;
+ unsigned int micro_sec;
- unipolar = inb(dev->iobase + DAS1800_CONTROL_C) & UB;
+ /* in burst mode, the maximum conversion time is 64 microseconds */
+ if (convert_arg > 64000)
+ convert_arg = 64000;
- while (inb(dev->iobase + DAS1800_STATUS) & FNE) {
- if (cmd->stop_src == TRIG_COUNT && devpriv->count == 0)
- break;
- dpnt = inw(dev->iobase + DAS1800_FIFO);
- /* convert to unsigned type if we are in a bipolar mode */
- if (!unipolar)
- ;
- dpnt = munge_bipolar_sample(dev, dpnt);
- cfc_write_to_buffer(s, dpnt);
- if (cmd->stop_src == TRIG_COUNT)
- devpriv->count--;
+ /* the conversion time must be an integral number of microseconds */
+ switch (round_mode) {
+ case TRIG_ROUND_NEAREST:
+ default:
+ micro_sec = (convert_arg + 500) / 1000;
+ break;
+ case TRIG_ROUND_DOWN:
+ micro_sec = convert_arg / 1000;
+ break;
+ case TRIG_ROUND_UP:
+ micro_sec = (convert_arg - 1) / 1000 + 1;
+ break;
}
- return;
-}
-
-static int das1800_cancel(struct comedi_device *dev, struct comedi_subdevice *s)
-{
- outb(0x0, dev->iobase + DAS1800_STATUS); /* disable conversions */
- outb(0x0, dev->iobase + DAS1800_CONTROL_B); /* disable interrupts and dma */
- outb(0x0, dev->iobase + DAS1800_CONTROL_A); /* disable and clear fifo and stop triggering */
- if (devpriv->dma0)
- disable_dma(devpriv->dma0);
- if (devpriv->dma1)
- disable_dma(devpriv->dma1);
- return 0;
+ /* return number of nanoseconds */
+ return micro_sec * 1000;
}
/* test analog input cmd */
@@ -1358,10 +957,6 @@ static int das1800_ai_do_cmdtest(struct comedi_device *dev,
return 0;
}
-/* analog input cmd interface */
-
-/* first, some utility functions used in the main ai_do_cmd() */
-
/* returns appropriate bits for control register a, depending on command */
static int control_a_bits(struct comedi_cmd cmd)
{
@@ -1432,6 +1027,25 @@ static int control_c_bits(struct comedi_cmd cmd)
return control_c;
}
+/* loads counters with divisor1, divisor2 from private structure */
+static int das1800_set_frequency(struct comedi_device *dev)
+{
+ int err = 0;
+
+ /* counter 1, mode 2 */
+ if (i8254_load(dev->iobase + DAS1800_COUNTER, 0, 1, devpriv->divisor1,
+ 2))
+ err++;
+ /* counter 2, mode 2 */
+ if (i8254_load(dev->iobase + DAS1800_COUNTER, 0, 2, devpriv->divisor2,
+ 2))
+ err++;
+ if (err)
+ return -1;
+
+ return 0;
+}
+
/* sets up counters */
static int setup_counters(struct comedi_device *dev, struct comedi_cmd cmd)
{
@@ -1472,6 +1086,44 @@ static int setup_counters(struct comedi_device *dev, struct comedi_cmd cmd)
return 0;
}
+/* utility function that suggests a dma transfer size based on the conversion period 'ns' */
+static unsigned int suggest_transfer_size(struct comedi_cmd *cmd)
+{
+ unsigned int size = DMA_BUF_SIZE;
+ static const int sample_size = 2; /* size in bytes of one sample from board */
+ unsigned int fill_time = 300000000; /* target time in nanoseconds for filling dma buffer */
+ unsigned int max_size; /* maximum size we will allow for a transfer */
+
+ /* make dma buffer fill in 0.3 seconds for timed modes */
+ switch (cmd->scan_begin_src) {
+ case TRIG_FOLLOW: /* not in burst mode */
+ if (cmd->convert_src == TRIG_TIMER)
+ size = (fill_time / cmd->convert_arg) * sample_size;
+ break;
+ case TRIG_TIMER:
+ size = (fill_time / (cmd->scan_begin_arg * cmd->chanlist_len)) *
+ sample_size;
+ break;
+ default:
+ size = DMA_BUF_SIZE;
+ break;
+ }
+
+ /* set a minimum and maximum size allowed */
+ max_size = DMA_BUF_SIZE;
+ /* if we are taking limited number of conversions, limit transfer size to that */
+ if (cmd->stop_src == TRIG_COUNT &&
+ cmd->stop_arg * cmd->chanlist_len * sample_size < max_size)
+ max_size = cmd->stop_arg * cmd->chanlist_len * sample_size;
+
+ if (size > max_size)
+ size = max_size;
+ if (size < sample_size)
+ size = sample_size;
+
+ return size;
+}
+
/* sets up dma */
static void setup_dma(struct comedi_device *dev, struct comedi_cmd cmd)
{
@@ -1701,7 +1353,7 @@ static int das1800_di_rbits(struct comedi_device *dev,
data[1] = inb(dev->iobase + DAS1800_DIGITAL) & 0xf;
data[0] = 0;
- return 2;
+ return insn->n;
}
/* writes to digital output channels */
@@ -1722,94 +1374,376 @@ static int das1800_do_wbits(struct comedi_device *dev,
data[1] = devpriv->do_bits;
- return 2;
+ return insn->n;
}
-/* loads counters with divisor1, divisor2 from private structure */
-static int das1800_set_frequency(struct comedi_device *dev)
+static int das1800_init_dma(struct comedi_device *dev, unsigned int dma0,
+ unsigned int dma1)
{
- int err = 0;
-
- /* counter 1, mode 2 */
- if (i8254_load(dev->iobase + DAS1800_COUNTER, 0, 1, devpriv->divisor1,
- 2))
- err++;
- /* counter 2, mode 2 */
- if (i8254_load(dev->iobase + DAS1800_COUNTER, 0, 2, devpriv->divisor2,
- 2))
- err++;
- if (err)
- return -1;
+ unsigned long flags;
+ /* need an irq to do dma */
+ if (dev->irq && dma0) {
+ /* encode dma0 and dma1 into 2 digit hexadecimal for switch */
+ switch ((dma0 & 0x7) | (dma1 << 4)) {
+ case 0x5: /* dma0 == 5 */
+ devpriv->dma_bits |= DMA_CH5;
+ break;
+ case 0x6: /* dma0 == 6 */
+ devpriv->dma_bits |= DMA_CH6;
+ break;
+ case 0x7: /* dma0 == 7 */
+ devpriv->dma_bits |= DMA_CH7;
+ break;
+ case 0x65: /* dma0 == 5, dma1 == 6 */
+ devpriv->dma_bits |= DMA_CH5_CH6;
+ break;
+ case 0x76: /* dma0 == 6, dma1 == 7 */
+ devpriv->dma_bits |= DMA_CH6_CH7;
+ break;
+ case 0x57: /* dma0 == 7, dma1 == 5 */
+ devpriv->dma_bits |= DMA_CH7_CH5;
+ break;
+ default:
+ dev_err(dev->class_dev,
+ "only supports dma channels 5 through 7\n");
+ dev_err(dev->class_dev,
+ "Dual dma only allows the following combinations:\n");
+ dev_err(dev->class_dev,
+ "dma 5,6 / 6,7 / or 7,5\n");
+ return -EINVAL;
+ break;
+ }
+ if (request_dma(dma0, dev->driver->driver_name)) {
+ dev_err(dev->class_dev,
+ "failed to allocate dma channel %i\n", dma0);
+ return -EINVAL;
+ }
+ devpriv->dma0 = dma0;
+ devpriv->dma_current = dma0;
+ if (dma1) {
+ if (request_dma(dma1, dev->driver->driver_name)) {
+ dev_err(dev->class_dev,
+ "failed to allocate dma channel %i\n",
+ dma1);
+ return -EINVAL;
+ }
+ devpriv->dma1 = dma1;
+ }
+ devpriv->ai_buf0 = kmalloc(DMA_BUF_SIZE, GFP_KERNEL | GFP_DMA);
+ if (devpriv->ai_buf0 == NULL)
+ return -ENOMEM;
+ devpriv->dma_current_buf = devpriv->ai_buf0;
+ if (dma1) {
+ devpriv->ai_buf1 =
+ kmalloc(DMA_BUF_SIZE, GFP_KERNEL | GFP_DMA);
+ if (devpriv->ai_buf1 == NULL)
+ return -ENOMEM;
+ }
+ flags = claim_dma_lock();
+ disable_dma(devpriv->dma0);
+ set_dma_mode(devpriv->dma0, DMA_MODE_READ);
+ if (dma1) {
+ disable_dma(devpriv->dma1);
+ set_dma_mode(devpriv->dma1, DMA_MODE_READ);
+ }
+ release_dma_lock(flags);
+ }
return 0;
}
-/* converts requested conversion timing to timing compatible with
- * hardware, used only when card is in 'burst mode'
- */
-static unsigned int burst_convert_arg(unsigned int convert_arg, int round_mode)
+static int das1800_probe(struct comedi_device *dev)
{
- unsigned int micro_sec;
+ int id;
+ int board;
- /* in burst mode, the maximum conversion time is 64 microseconds */
- if (convert_arg > 64000)
- convert_arg = 64000;
+ id = (inb(dev->iobase + DAS1800_DIGITAL) >> 4) & 0xf; /* get id bits */
+ board = ((struct das1800_board *)dev->board_ptr) - das1800_boards;
- /* the conversion time must be an integral number of microseconds */
- switch (round_mode) {
- case TRIG_ROUND_NEAREST:
- default:
- micro_sec = (convert_arg + 500) / 1000;
+ switch (id) {
+ case 0x3:
+ if (board == das1801st_da || board == das1802st_da ||
+ board == das1701st_da || board == das1702st_da) {
+ dev_dbg(dev->class_dev, "Board model: %s\n",
+ das1800_boards[board].name);
+ return board;
+ }
+ printk
+ (" Board model (probed, not recommended): das-1800st-da series\n");
+ return das1801st;
break;
- case TRIG_ROUND_DOWN:
- micro_sec = convert_arg / 1000;
+ case 0x4:
+ if (board == das1802hr_da || board == das1702hr_da) {
+ dev_dbg(dev->class_dev, "Board model: %s\n",
+ das1800_boards[board].name);
+ return board;
+ }
+ printk
+ (" Board model (probed, not recommended): das-1802hr-da\n");
+ return das1802hr;
break;
- case TRIG_ROUND_UP:
- micro_sec = (convert_arg - 1) / 1000 + 1;
+ case 0x5:
+ if (board == das1801ao || board == das1802ao ||
+ board == das1701ao || board == das1702ao) {
+ dev_dbg(dev->class_dev, "Board model: %s\n",
+ das1800_boards[board].name);
+ return board;
+ }
+ printk
+ (" Board model (probed, not recommended): das-1800ao series\n");
+ return das1801ao;
+ break;
+ case 0x6:
+ if (board == das1802hr || board == das1702hr) {
+ dev_dbg(dev->class_dev, "Board model: %s\n",
+ das1800_boards[board].name);
+ return board;
+ }
+ printk
+ (" Board model (probed, not recommended): das-1802hr\n");
+ return das1802hr;
+ break;
+ case 0x7:
+ if (board == das1801st || board == das1802st ||
+ board == das1701st || board == das1702st) {
+ dev_dbg(dev->class_dev, "Board model: %s\n",
+ das1800_boards[board].name);
+ return board;
+ }
+ printk
+ (" Board model (probed, not recommended): das-1800st series\n");
+ return das1801st;
+ break;
+ case 0x8:
+ if (board == das1801hc || board == das1802hc) {
+ dev_dbg(dev->class_dev, "Board model: %s\n",
+ das1800_boards[board].name);
+ return board;
+ }
+ printk
+ (" Board model (probed, not recommended): das-1800hc series\n");
+ return das1801hc;
+ break;
+ default:
+ printk
+ (" Board model: probe returned 0x%x (unknown, please report)\n",
+ id);
+ return board;
break;
}
-
- /* return number of nanoseconds */
- return micro_sec * 1000;
+ return -1;
}
-/* utility function that suggests a dma transfer size based on the conversion period 'ns' */
-static unsigned int suggest_transfer_size(struct comedi_cmd *cmd)
+static int das1800_attach(struct comedi_device *dev,
+ struct comedi_devconfig *it)
{
- unsigned int size = DMA_BUF_SIZE;
- static const int sample_size = 2; /* size in bytes of one sample from board */
- unsigned int fill_time = 300000000; /* target time in nanoseconds for filling dma buffer */
- unsigned int max_size; /* maximum size we will allow for a transfer */
+ struct comedi_subdevice *s;
+ unsigned long iobase = it->options[0];
+ unsigned int irq = it->options[1];
+ unsigned int dma0 = it->options[2];
+ unsigned int dma1 = it->options[3];
+ unsigned long iobase2;
+ int board;
+ int retval;
- /* make dma buffer fill in 0.3 seconds for timed modes */
- switch (cmd->scan_begin_src) {
- case TRIG_FOLLOW: /* not in burst mode */
- if (cmd->convert_src == TRIG_TIMER)
- size = (fill_time / cmd->convert_arg) * sample_size;
+ /* allocate and initialize dev->private */
+ if (alloc_private(dev, sizeof(struct das1800_private)) < 0)
+ return -ENOMEM;
+
+ printk(KERN_DEBUG "comedi%d: %s: io 0x%lx", dev->minor,
+ dev->driver->driver_name, iobase);
+ if (irq) {
+ printk(KERN_CONT ", irq %u", irq);
+ if (dma0) {
+ printk(KERN_CONT ", dma %u", dma0);
+ if (dma1)
+ printk(KERN_CONT " and %u", dma1);
+ }
+ }
+ printk(KERN_CONT "\n");
+
+ if (iobase == 0) {
+ dev_err(dev->class_dev, "io base address required\n");
+ return -EINVAL;
+ }
+
+ /* check if io addresses are available */
+ if (!request_region(iobase, DAS1800_SIZE, dev->driver->driver_name)) {
+ printk
+ (" I/O port conflict: failed to allocate ports 0x%lx to 0x%lx\n",
+ iobase, iobase + DAS1800_SIZE - 1);
+ return -EIO;
+ }
+ dev->iobase = iobase;
+
+ board = das1800_probe(dev);
+ if (board < 0) {
+ dev_err(dev->class_dev, "unable to determine board type\n");
+ return -ENODEV;
+ }
+
+ dev->board_ptr = das1800_boards + board;
+ dev->board_name = thisboard->name;
+
+ /* if it is an 'ao' board with fancy analog out then we need extra io ports */
+ if (thisboard->ao_ability == 2) {
+ iobase2 = iobase + IOBASE2;
+ if (!request_region(iobase2, DAS1800_SIZE,
+ dev->driver->driver_name)) {
+ printk
+ (" I/O port conflict: failed to allocate ports 0x%lx to 0x%lx\n",
+ iobase2, iobase2 + DAS1800_SIZE - 1);
+ return -EIO;
+ }
+ devpriv->iobase2 = iobase2;
+ }
+
+ /* grab our IRQ */
+ if (irq) {
+ if (request_irq(irq, das1800_interrupt, 0,
+ dev->driver->driver_name, dev)) {
+ dev_dbg(dev->class_dev, "unable to allocate irq %u\n",
+ irq);
+ return -EINVAL;
+ }
+ }
+ dev->irq = irq;
+
+ /* set bits that tell card which irq to use */
+ switch (irq) {
+ case 0:
break;
- case TRIG_TIMER:
- size = (fill_time / (cmd->scan_begin_arg * cmd->chanlist_len)) *
- sample_size;
+ case 3:
+ devpriv->irq_dma_bits |= 0x8;
+ break;
+ case 5:
+ devpriv->irq_dma_bits |= 0x10;
+ break;
+ case 7:
+ devpriv->irq_dma_bits |= 0x18;
+ break;
+ case 10:
+ devpriv->irq_dma_bits |= 0x28;
+ break;
+ case 11:
+ devpriv->irq_dma_bits |= 0x30;
+ break;
+ case 15:
+ devpriv->irq_dma_bits |= 0x38;
break;
default:
- size = DMA_BUF_SIZE;
+ dev_err(dev->class_dev, "irq out of range\n");
+ return -EINVAL;
break;
}
- /* set a minimum and maximum size allowed */
- max_size = DMA_BUF_SIZE;
- /* if we are taking limited number of conversions, limit transfer size to that */
- if (cmd->stop_src == TRIG_COUNT &&
- cmd->stop_arg * cmd->chanlist_len * sample_size < max_size)
- max_size = cmd->stop_arg * cmd->chanlist_len * sample_size;
+ retval = das1800_init_dma(dev, dma0, dma1);
+ if (retval < 0)
+ return retval;
- if (size > max_size)
- size = max_size;
- if (size < sample_size)
- size = sample_size;
+ if (devpriv->ai_buf0 == NULL) {
+ devpriv->ai_buf0 =
+ kmalloc(FIFO_SIZE * sizeof(uint16_t), GFP_KERNEL);
+ if (devpriv->ai_buf0 == NULL)
+ return -ENOMEM;
+ }
- return size;
-}
+ retval = comedi_alloc_subdevices(dev, 4);
+ if (retval)
+ return retval;
+
+ /* analog input subdevice */
+ s = dev->subdevices + 0;
+ dev->read_subdev = s;
+ s->type = COMEDI_SUBD_AI;
+ s->subdev_flags = SDF_READABLE | SDF_DIFF | SDF_GROUND | SDF_CMD_READ;
+ if (thisboard->common)
+ s->subdev_flags |= SDF_COMMON;
+ s->n_chan = thisboard->qram_len;
+ s->len_chanlist = thisboard->qram_len;
+ s->maxdata = (1 << thisboard->resolution) - 1;
+ s->range_table = thisboard->range_ai;
+ s->do_cmd = das1800_ai_do_cmd;
+ s->do_cmdtest = das1800_ai_do_cmdtest;
+ s->insn_read = das1800_ai_rinsn;
+ s->poll = das1800_ai_poll;
+ s->cancel = das1800_cancel;
+
+ /* analog out */
+ s = dev->subdevices + 1;
+ if (thisboard->ao_ability == 1) {
+ s->type = COMEDI_SUBD_AO;
+ s->subdev_flags = SDF_WRITABLE;
+ s->n_chan = thisboard->ao_n_chan;
+ s->maxdata = (1 << thisboard->resolution) - 1;
+ s->range_table = &range_ao_1;
+ s->insn_write = das1800_ao_winsn;
+ } else {
+ s->type = COMEDI_SUBD_UNUSED;
+ }
+
+ /* di */
+ s = dev->subdevices + 2;
+ s->type = COMEDI_SUBD_DI;
+ s->subdev_flags = SDF_READABLE;
+ s->n_chan = 4;
+ s->maxdata = 1;
+ s->range_table = &range_digital;
+ s->insn_bits = das1800_di_rbits;
+
+ /* do */
+ s = dev->subdevices + 3;
+ s->type = COMEDI_SUBD_DO;
+ s->subdev_flags = SDF_WRITABLE | SDF_READABLE;
+ s->n_chan = thisboard->do_n_chan;
+ s->maxdata = 1;
+ s->range_table = &range_digital;
+ s->insn_bits = das1800_do_wbits;
+
+ das1800_cancel(dev, dev->read_subdev);
+
+ /* initialize digital out channels */
+ outb(devpriv->do_bits, dev->iobase + DAS1800_DIGITAL);
+
+ /* initialize analog out channels */
+ if (thisboard->ao_ability == 1) {
+ /* select 'update' dac channel for baseAddress + 0x0 */
+ outb(DAC(thisboard->ao_n_chan - 1),
+ dev->iobase + DAS1800_SELECT);
+ outw(devpriv->ao_update_bits, dev->iobase + DAS1800_DAC);
+ }
+
+ return 0;
+};
+
+static void das1800_detach(struct comedi_device *dev)
+{
+ if (dev->iobase)
+ release_region(dev->iobase, DAS1800_SIZE);
+ if (dev->irq)
+ free_irq(dev->irq, dev);
+ if (dev->private) {
+ if (devpriv->iobase2)
+ release_region(devpriv->iobase2, DAS1800_SIZE);
+ if (devpriv->dma0)
+ free_dma(devpriv->dma0);
+ if (devpriv->dma1)
+ free_dma(devpriv->dma1);
+ kfree(devpriv->ai_buf0);
+ kfree(devpriv->ai_buf1);
+ }
+};
+
+static struct comedi_driver das1800_driver = {
+ .driver_name = "das1800",
+ .module = THIS_MODULE,
+ .attach = das1800_attach,
+ .detach = das1800_detach,
+ .num_names = ARRAY_SIZE(das1800_boards),
+ .board_name = &das1800_boards[0].name,
+ .offset = sizeof(struct das1800_board),
+};
+module_comedi_driver(das1800_driver);
MODULE_AUTHOR("Comedi http://www.comedi.org");
MODULE_DESCRIPTION("Comedi low-level driver");
diff --git a/drivers/staging/comedi/drivers/das6402.c b/drivers/staging/comedi/drivers/das6402.c
index f25684145e84..e3afcfa9efc8 100644
--- a/drivers/staging/comedi/drivers/das6402.c
+++ b/drivers/staging/comedi/drivers/das6402.c
@@ -99,29 +99,6 @@ This driver has suffered bitrot.
#define C2 0x80
#define RWLH 0x30
-static int das6402_attach(struct comedi_device *dev,
- struct comedi_devconfig *it);
-static int das6402_detach(struct comedi_device *dev);
-static struct comedi_driver driver_das6402 = {
- .driver_name = "das6402",
- .module = THIS_MODULE,
- .attach = das6402_attach,
- .detach = das6402_detach,
-};
-
-static int __init driver_das6402_init_module(void)
-{
- return comedi_driver_register(&driver_das6402);
-}
-
-static void __exit driver_das6402_cleanup_module(void)
-{
- comedi_driver_unregister(&driver_das6402);
-}
-
-module_init(driver_das6402_init_module);
-module_exit(driver_das6402_cleanup_module);
-
struct das6402_private {
int ai_bytes_to_read;
@@ -130,7 +107,14 @@ struct das6402_private {
#define devpriv ((struct das6402_private *)dev->private)
static void das6402_ai_fifo_dregs(struct comedi_device *dev,
- struct comedi_subdevice *s);
+ struct comedi_subdevice *s)
+{
+ while (1) {
+ if (!(inb(dev->iobase + 8) & 0x01))
+ return;
+ comedi_buf_put(s->async, inw(dev->iobase));
+ }
+}
static void das6402_setcounter(struct comedi_device *dev)
{
@@ -171,7 +155,7 @@ static irqreturn_t intr_handler(int irq, void *d)
struct comedi_subdevice *s = dev->subdevices;
if (!dev->attached || devpriv->das6402_ignoreirq) {
- dev_warn(dev->hw_dev, "BUG: spurious interrupt\n");
+ dev_warn(dev->class_dev, "BUG: spurious interrupt\n");
return IRQ_HANDLED;
}
#ifdef DEBUG
@@ -209,16 +193,6 @@ static void das6402_ai_fifo_read(struct comedi_device *dev, short *data, int n)
}
#endif
-static void das6402_ai_fifo_dregs(struct comedi_device *dev,
- struct comedi_subdevice *s)
-{
- while (1) {
- if (!(inb(dev->iobase + 8) & 0x01))
- return;
- comedi_buf_put(s->async, inw(dev->iobase));
- }
-}
-
static int das6402_ai_cancel(struct comedi_device *dev,
struct comedi_subdevice *s)
{
@@ -228,7 +202,7 @@ static int das6402_ai_cancel(struct comedi_device *dev,
*/
devpriv->das6402_ignoreirq = 1;
- dev_dbg(dev->hw_dev, "Stopping acquisition\n");
+ dev_dbg(dev->class_dev, "Stopping acquisition\n");
devpriv->das6402_ignoreirq = 1;
outb_p(0x02, dev->iobase + 10); /* disable external trigging */
outw_p(SCANL, dev->iobase + 2); /* resets the card fifo */
@@ -244,7 +218,7 @@ static int das6402_ai_mode2(struct comedi_device *dev,
struct comedi_subdevice *s, comedi_trig * it)
{
devpriv->das6402_ignoreirq = 1;
- dev_dbg(dev->hw_dev, "Starting acquisition\n");
+ dev_dbg(dev->class_dev, "Starting acquisition\n");
outb_p(0x03, dev->iobase + 10); /* enable external trigging */
outw_p(SCANL, dev->iobase + 2); /* resets the card fifo */
outb_p(IRQ | CONVSRC | BURSTEN | INTE, dev->iobase + 9);
@@ -300,16 +274,6 @@ static int board_init(struct comedi_device *dev)
return 0;
}
-static int das6402_detach(struct comedi_device *dev)
-{
- if (dev->irq)
- free_irq(dev->irq, dev);
- if (dev->iobase)
- release_region(dev->iobase, DAS6402_SIZE);
-
- return 0;
-}
-
static int das6402_attach(struct comedi_device *dev,
struct comedi_devconfig *it)
{
@@ -325,7 +289,7 @@ static int das6402_attach(struct comedi_device *dev,
iobase = 0x300;
if (!request_region(iobase, DAS6402_SIZE, "das6402")) {
- dev_err(dev->hw_dev, "I/O port conflict\n");
+ dev_err(dev->class_dev, "I/O port conflict\n");
return -EIO;
}
dev->iobase = iobase;
@@ -333,7 +297,7 @@ static int das6402_attach(struct comedi_device *dev,
/* should do a probe here */
irq = it->options[0];
- dev_dbg(dev->hw_dev, "( irq = %u )\n", irq);
+ dev_dbg(dev->class_dev, "( irq = %u )\n", irq);
ret = request_irq(irq, intr_handler, 0, "das6402", dev);
if (ret < 0)
return ret;
@@ -343,8 +307,8 @@ static int das6402_attach(struct comedi_device *dev,
if (ret < 0)
return ret;
- ret = alloc_subdevices(dev, 1);
- if (ret < 0)
+ ret = comedi_alloc_subdevices(dev, 1);
+ if (ret)
return ret;
/* ai subdevice */
@@ -363,6 +327,22 @@ static int das6402_attach(struct comedi_device *dev,
return 0;
}
+static void das6402_detach(struct comedi_device *dev)
+{
+ if (dev->irq)
+ free_irq(dev->irq, dev);
+ if (dev->iobase)
+ release_region(dev->iobase, DAS6402_SIZE);
+}
+
+static struct comedi_driver das6402_driver = {
+ .driver_name = "das6402",
+ .module = THIS_MODULE,
+ .attach = das6402_attach,
+ .detach = das6402_detach,
+};
+module_comedi_driver(das6402_driver)
+
MODULE_AUTHOR("Comedi http://www.comedi.org");
MODULE_DESCRIPTION("Comedi low-level driver");
MODULE_LICENSE("GPL");
diff --git a/drivers/staging/comedi/drivers/das800.c b/drivers/staging/comedi/drivers/das800.c
index 6e347b40fe61..a0959a5e8747 100644
--- a/drivers/staging/comedi/drivers/das800.c
+++ b/drivers/staging/comedi/drivers/das800.c
@@ -245,7 +245,7 @@ struct das800_private {
static int das800_attach(struct comedi_device *dev,
struct comedi_devconfig *it);
-static int das800_detach(struct comedi_device *dev);
+static void das800_detach(struct comedi_device *dev);
static int das800_cancel(struct comedi_device *dev, struct comedi_subdevice *s);
static struct comedi_driver driver_das800 = {
@@ -296,46 +296,47 @@ static int das800_probe(struct comedi_device *dev)
switch (id_bits) {
case 0x0:
if (board == das800) {
- dev_dbg(dev->hw_dev, "Board model: DAS-800\n");
+ dev_dbg(dev->class_dev, "Board model: DAS-800\n");
return board;
}
if (board == ciodas800) {
- dev_dbg(dev->hw_dev, "Board model: CIO-DAS800\n");
+ dev_dbg(dev->class_dev, "Board model: CIO-DAS800\n");
return board;
}
- dev_dbg(dev->hw_dev, "Board model (probed): DAS-800\n");
+ dev_dbg(dev->class_dev, "Board model (probed): DAS-800\n");
return das800;
break;
case 0x2:
if (board == das801) {
- dev_dbg(dev->hw_dev, "Board model: DAS-801\n");
+ dev_dbg(dev->class_dev, "Board model: DAS-801\n");
return board;
}
if (board == ciodas801) {
- dev_dbg(dev->hw_dev, "Board model: CIO-DAS801\n");
+ dev_dbg(dev->class_dev, "Board model: CIO-DAS801\n");
return board;
}
- dev_dbg(dev->hw_dev, "Board model (probed): DAS-801\n");
+ dev_dbg(dev->class_dev, "Board model (probed): DAS-801\n");
return das801;
break;
case 0x3:
if (board == das802) {
- dev_dbg(dev->hw_dev, "Board model: DAS-802\n");
+ dev_dbg(dev->class_dev, "Board model: DAS-802\n");
return board;
}
if (board == ciodas802) {
- dev_dbg(dev->hw_dev, "Board model: CIO-DAS802\n");
+ dev_dbg(dev->class_dev, "Board model: CIO-DAS802\n");
return board;
}
if (board == ciodas80216) {
- dev_dbg(dev->hw_dev, "Board model: CIO-DAS802/16\n");
+ dev_dbg(dev->class_dev, "Board model: CIO-DAS802/16\n");
return board;
}
- dev_dbg(dev->hw_dev, "Board model (probed): DAS-802\n");
+ dev_dbg(dev->class_dev, "Board model (probed): DAS-802\n");
return das802;
break;
default:
- dev_dbg(dev->hw_dev, "Board model: probe returned 0x%x (unknown)\n",
+ dev_dbg(dev->class_dev,
+ "Board model: probe returned 0x%x (unknown)\n",
id_bits);
return board;
break;
@@ -450,7 +451,7 @@ static irqreturn_t das800_interrupt(int irq, void *d)
/* otherwise, stop taking data */
} else {
spin_unlock_irqrestore(&dev->spinlock, irq_flags);
- disable_das800(dev); /* diable hardware triggered conversions */
+ disable_das800(dev); /* disable hardware triggered conversions */
async->events |= COMEDI_CB_EOA;
}
comedi_event(dev, s);
@@ -465,43 +466,44 @@ static int das800_attach(struct comedi_device *dev, struct comedi_devconfig *it)
unsigned int irq = it->options[1];
unsigned long irq_flags;
int board;
+ int ret;
- dev_info(dev->hw_dev, "comedi%d: das800: io 0x%lx\n", dev->minor,
- iobase);
+ dev_info(dev->class_dev, "das800: io 0x%lx\n", iobase);
if (irq)
- dev_dbg(dev->hw_dev, "irq %u\n", irq);
+ dev_dbg(dev->class_dev, "irq %u\n", irq);
/* allocate and initialize dev->private */
if (alloc_private(dev, sizeof(struct das800_private)) < 0)
return -ENOMEM;
if (iobase == 0) {
- dev_err(dev->hw_dev, "io base address required for das800\n");
+ dev_err(dev->class_dev,
+ "io base address required for das800\n");
return -EINVAL;
}
/* check if io addresses are available */
if (!request_region(iobase, DAS800_SIZE, "das800")) {
- dev_err(dev->hw_dev, "I/O port conflict\n");
+ dev_err(dev->class_dev, "I/O port conflict\n");
return -EIO;
}
dev->iobase = iobase;
board = das800_probe(dev);
if (board < 0) {
- dev_dbg(dev->hw_dev, "unable to determine board type\n");
+ dev_dbg(dev->class_dev, "unable to determine board type\n");
return -ENODEV;
}
dev->board_ptr = das800_boards + board;
/* grab our IRQ */
if (irq == 1 || irq > 7) {
- dev_err(dev->hw_dev, "irq out of range\n");
+ dev_err(dev->class_dev, "irq out of range\n");
return -EINVAL;
}
if (irq) {
if (request_irq(irq, das800_interrupt, 0, "das800", dev)) {
- dev_err(dev->hw_dev, "unable to allocate irq %u\n",
+ dev_err(dev->class_dev, "unable to allocate irq %u\n",
irq);
return -EINVAL;
}
@@ -510,8 +512,9 @@ static int das800_attach(struct comedi_device *dev, struct comedi_devconfig *it)
dev->board_name = thisboard->name;
- if (alloc_subdevices(dev, 3) < 0)
- return -ENOMEM;
+ ret = comedi_alloc_subdevices(dev, 3);
+ if (ret)
+ return ret;
/* analog input subdevice */
s = dev->subdevices + 0;
@@ -556,16 +559,12 @@ static int das800_attach(struct comedi_device *dev, struct comedi_devconfig *it)
return 0;
};
-static int das800_detach(struct comedi_device *dev)
+static void das800_detach(struct comedi_device *dev)
{
- dev_info(dev->hw_dev, "comedi%d: das800: remove\n", dev->minor);
-
- /* only free stuff if it has been allocated by _attach */
if (dev->iobase)
release_region(dev->iobase, DAS800_SIZE);
if (dev->irq)
free_irq(dev->irq, dev);
- return 0;
};
static int das800_cancel(struct comedi_device *dev, struct comedi_subdevice *s)
@@ -876,7 +875,7 @@ static int das800_di_rbits(struct comedi_device *dev,
data[1] = bits;
data[0] = 0;
- return 2;
+ return insn->n;
}
static int das800_do_wbits(struct comedi_device *dev,
@@ -900,7 +899,7 @@ static int das800_do_wbits(struct comedi_device *dev,
data[1] = wbits;
- return 2;
+ return insn->n;
}
/* loads counters with divisor1, divisor2 from private structure */
diff --git a/drivers/staging/comedi/drivers/dmm32at.c b/drivers/staging/comedi/drivers/dmm32at.c
index 2b4e6e6eb825..7107f590b1fe 100644
--- a/drivers/staging/comedi/drivers/dmm32at.c
+++ b/drivers/staging/comedi/drivers/dmm32at.c
@@ -78,9 +78,6 @@ Configuration Options:
#define DMM32AT_DIOC 0x0e
#define DMM32AT_DIOCONF 0x0f
-#define dmm_inb(cdev, reg) inb((cdev->iobase)+reg)
-#define dmm_outb(cdev, reg, valu) outb(valu, (cdev->iobase)+reg)
-
/* Board register values. */
/* DMM32AT_DACSTAT 0x04 */
@@ -159,45 +156,10 @@ static const struct comedi_lrange dmm32at_aoranges = {
}
};
-/*
- * Board descriptions for two imaginary boards. Describing the
- * boards in this way is optional, and completely driver-dependent.
- * Some drivers use arrays such as this, other do not.
- */
struct dmm32at_board {
const char *name;
- int ai_chans;
- int ai_bits;
- const struct comedi_lrange *ai_ranges;
- int ao_chans;
- int ao_bits;
- const struct comedi_lrange *ao_ranges;
- int have_dio;
- int dio_chans;
-};
-static const struct dmm32at_board dmm32at_boards[] = {
- {
- .name = "dmm32at",
- .ai_chans = 32,
- .ai_bits = 16,
- .ai_ranges = &dmm32at_airanges,
- .ao_chans = 4,
- .ao_bits = 12,
- .ao_ranges = &dmm32at_aoranges,
- .have_dio = 1,
- .dio_chans = 24,
- },
};
-/*
- * Useful for shorthand access to the particular board structure
- */
-#define thisboard ((const struct dmm32at_board *)dev->board_ptr)
-
-/* this structure is for data unique to this hardware driver. If
- * several hardware drivers keep similar information in this structure,
- * feel free to suggest moving the variable to the struct comedi_device struct.
- */
struct dmm32at_private {
int data;
@@ -210,270 +172,6 @@ struct dmm32at_private {
};
-/*
- * most drivers define the following macro to make it easy to
- * access the private structure.
- */
-#define devpriv ((struct dmm32at_private *)dev->private)
-
-/*
- * The struct comedi_driver structure tells the Comedi core module
- * which functions to call to configure/deconfigure (attach/detach)
- * the board, and also about the kernel module that contains
- * the device code.
- */
-static int dmm32at_attach(struct comedi_device *dev,
- struct comedi_devconfig *it);
-static int dmm32at_detach(struct comedi_device *dev);
-static struct comedi_driver driver_dmm32at = {
- .driver_name = "dmm32at",
- .module = THIS_MODULE,
- .attach = dmm32at_attach,
- .detach = dmm32at_detach,
-/* It is not necessary to implement the following members if you are
- * writing a driver for a ISA PnP or PCI card */
-/* Most drivers will support multiple types of boards by
- * having an array of board structures. These were defined
- * in dmm32at_boards[] above. Note that the element 'name'
- * was first in the structure -- Comedi uses this fact to
- * extract the name of the board without knowing any details
- * about the structure except for its length.
- * When a device is attached (by comedi_config), the name
- * of the device is given to Comedi, and Comedi tries to
- * match it by going through the list of board names. If
- * there is a match, the address of the pointer is put
- * into dev->board_ptr and driver->attach() is called.
- *
- * Note that these are not necessary if you can determine
- * the type of board in software. ISA PnP, PCI, and PCMCIA
- * devices are such boards.
- */
- .board_name = &dmm32at_boards[0].name,
- .offset = sizeof(struct dmm32at_board),
- .num_names = ARRAY_SIZE(dmm32at_boards),
-};
-
-/* prototypes for driver functions below */
-static int dmm32at_ai_rinsn(struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data);
-static int dmm32at_ao_winsn(struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data);
-static int dmm32at_ao_rinsn(struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data);
-static int dmm32at_dio_insn_bits(struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data);
-static int dmm32at_dio_insn_config(struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_insn *insn,
- unsigned int *data);
-static int dmm32at_ai_cmdtest(struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_cmd *cmd);
-static int dmm32at_ai_cmd(struct comedi_device *dev,
- struct comedi_subdevice *s);
-static int dmm32at_ai_cancel(struct comedi_device *dev,
- struct comedi_subdevice *s);
-static int dmm32at_ns_to_timer(unsigned int *ns, int round);
-static irqreturn_t dmm32at_isr(int irq, void *d);
-void dmm32at_setaitimer(struct comedi_device *dev, unsigned int nansec);
-
-/*
- * Attach is called by the Comedi core to configure the driver
- * for a particular board. If you specified a board_name array
- * in the driver structure, dev->board_ptr contains that
- * address.
- */
-static int dmm32at_attach(struct comedi_device *dev,
- struct comedi_devconfig *it)
-{
- int ret;
- struct comedi_subdevice *s;
- unsigned char aihi, ailo, fifostat, aistat, intstat, airback;
- unsigned long iobase;
- unsigned int irq;
-
- iobase = it->options[0];
- irq = it->options[1];
-
- printk(KERN_INFO "comedi%d: dmm32at: attaching\n", dev->minor);
- printk(KERN_DEBUG "dmm32at: probing at address 0x%04lx, irq %u\n",
- iobase, irq);
-
- /* register address space */
- if (!request_region(iobase, DMM32AT_MEMSIZE, thisboard->name)) {
- printk(KERN_ERR "comedi%d: dmm32at: I/O port conflict\n",
- dev->minor);
- return -EIO;
- }
- dev->iobase = iobase;
-
- /* the following just makes sure the board is there and gets
- it to a known state */
-
- /* reset the board */
- dmm_outb(dev, DMM32AT_CNTRL, DMM32AT_RESET);
-
- /* allow a millisecond to reset */
- udelay(1000);
-
- /* zero scan and fifo control */
- dmm_outb(dev, DMM32AT_FIFOCNTRL, 0x0);
-
- /* zero interrupt and clock control */
- dmm_outb(dev, DMM32AT_INTCLOCK, 0x0);
-
- /* write a test channel range, the high 3 bits should drop */
- dmm_outb(dev, DMM32AT_AILOW, 0x80);
- dmm_outb(dev, DMM32AT_AIHIGH, 0xff);
-
- /* set the range at 10v unipolar */
- dmm_outb(dev, DMM32AT_AICONF, DMM32AT_RANGE_U10);
-
- /* should take 10 us to settle, here's a hundred */
- udelay(100);
-
- /* read back the values */
- ailo = dmm_inb(dev, DMM32AT_AILOW);
- aihi = dmm_inb(dev, DMM32AT_AIHIGH);
- fifostat = dmm_inb(dev, DMM32AT_FIFOSTAT);
- aistat = dmm_inb(dev, DMM32AT_AISTAT);
- intstat = dmm_inb(dev, DMM32AT_INTCLOCK);
- airback = dmm_inb(dev, DMM32AT_AIRBACK);
-
- printk(KERN_DEBUG "dmm32at: lo=0x%02x hi=0x%02x fifostat=0x%02x\n",
- ailo, aihi, fifostat);
- printk(KERN_DEBUG
- "dmm32at: aistat=0x%02x intstat=0x%02x airback=0x%02x\n",
- aistat, intstat, airback);
-
- if ((ailo != 0x00) || (aihi != 0x1f) || (fifostat != 0x80) ||
- (aistat != 0x60 || (intstat != 0x00) || airback != 0x0c)) {
- printk(KERN_ERR "dmmat32: board detection failed\n");
- return -EIO;
- }
-
- /* board is there, register interrupt */
- if (irq) {
- ret = request_irq(irq, dmm32at_isr, 0, thisboard->name, dev);
- if (ret < 0) {
- printk(KERN_ERR "dmm32at: irq conflict\n");
- return ret;
- }
- dev->irq = irq;
- }
-
-/*
- * If you can probe the device to determine what device in a series
- * it is, this is the place to do it. Otherwise, dev->board_ptr
- * should already be initialized.
- */
- /* dev->board_ptr = dmm32at_probe(dev); */
-
-/*
- * Initialize dev->board_name. Note that we can use the "thisboard"
- * macro now, since we just initialized it in the last line.
- */
- dev->board_name = thisboard->name;
-
-/*
- * Allocate the private structure area. alloc_private() is a
- * convenient macro defined in comedidev.h.
- */
- if (alloc_private(dev, sizeof(struct dmm32at_private)) < 0)
- return -ENOMEM;
-
-/*
- * Allocate the subdevice structures. alloc_subdevice() is a
- * convenient macro defined in comedidev.h.
- */
- if (alloc_subdevices(dev, 3) < 0)
- return -ENOMEM;
-
- s = dev->subdevices + 0;
- dev->read_subdev = s;
- /* analog input subdevice */
- s->type = COMEDI_SUBD_AI;
- /* we support single-ended (ground) and differential */
- s->subdev_flags = SDF_READABLE | SDF_GROUND | SDF_DIFF | SDF_CMD_READ;
- s->n_chan = thisboard->ai_chans;
- s->maxdata = (1 << thisboard->ai_bits) - 1;
- s->range_table = thisboard->ai_ranges;
- s->len_chanlist = 32; /* This is the maximum chanlist length that
- the board can handle */
- s->insn_read = dmm32at_ai_rinsn;
- s->do_cmd = dmm32at_ai_cmd;
- s->do_cmdtest = dmm32at_ai_cmdtest;
- s->cancel = dmm32at_ai_cancel;
-
- s = dev->subdevices + 1;
- /* analog output subdevice */
- s->type = COMEDI_SUBD_AO;
- s->subdev_flags = SDF_WRITABLE;
- s->n_chan = thisboard->ao_chans;
- s->maxdata = (1 << thisboard->ao_bits) - 1;
- s->range_table = thisboard->ao_ranges;
- s->insn_write = dmm32at_ao_winsn;
- s->insn_read = dmm32at_ao_rinsn;
-
- s = dev->subdevices + 2;
- /* digital i/o subdevice */
- if (thisboard->have_dio) {
-
- /* get access to the DIO regs */
- dmm_outb(dev, DMM32AT_CNTRL, DMM32AT_DIOACC);
- /* set the DIO's to the defualt input setting */
- devpriv->dio_config = DMM32AT_DIRA | DMM32AT_DIRB |
- DMM32AT_DIRCL | DMM32AT_DIRCH | DMM32AT_DIENABLE;
- dmm_outb(dev, DMM32AT_DIOCONF, devpriv->dio_config);
-
- /* set up the subdevice */
- s->type = COMEDI_SUBD_DIO;
- s->subdev_flags = SDF_READABLE | SDF_WRITABLE;
- s->n_chan = thisboard->dio_chans;
- s->maxdata = 1;
- s->state = 0;
- s->range_table = &range_digital;
- s->insn_bits = dmm32at_dio_insn_bits;
- s->insn_config = dmm32at_dio_insn_config;
- } else {
- s->type = COMEDI_SUBD_UNUSED;
- }
-
- /* success */
- printk(KERN_INFO "comedi%d: dmm32at: attached\n", dev->minor);
-
- return 1;
-
-}
-
-/*
- * _detach is called to deconfigure a device. It should deallocate
- * resources.
- * This function is also called when _attach() fails, so it should be
- * careful not to release resources that were not necessarily
- * allocated by _attach(). dev->private and dev->subdevices are
- * deallocated automatically by the core.
- */
-static int dmm32at_detach(struct comedi_device *dev)
-{
- printk(KERN_INFO "comedi%d: dmm32at: remove\n", dev->minor);
- if (dev->irq)
- free_irq(dev->irq, dev);
- if (dev->iobase)
- release_region(dev->iobase, DMM32AT_MEMSIZE);
-
- return 0;
-}
-
-/*
- * "instructions" read/write data in "one-shot" or "software-triggered"
- * mode.
- */
-
static int dmm32at_ai_rinsn(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
@@ -493,17 +191,17 @@ static int dmm32at_ai_rinsn(struct comedi_device *dev,
/* printk("channel=0x%02x, range=%d\n",chan,range); */
/* zero scan and fifo control and reset fifo */
- dmm_outb(dev, DMM32AT_FIFOCNTRL, DMM32AT_FIFORESET);
+ outb(DMM32AT_FIFORESET, dev->iobase + DMM32AT_FIFOCNTRL);
/* write the ai channel range regs */
- dmm_outb(dev, DMM32AT_AILOW, chan);
- dmm_outb(dev, DMM32AT_AIHIGH, chan);
+ outb(chan, dev->iobase + DMM32AT_AILOW);
+ outb(chan, dev->iobase + DMM32AT_AIHIGH);
/* set the range bits */
- dmm_outb(dev, DMM32AT_AICONF, dmm32at_rangebits[range]);
+ outb(dmm32at_rangebits[range], dev->iobase + DMM32AT_AICONF);
/* wait for circuit to settle */
for (i = 0; i < 40000; i++) {
- status = dmm_inb(dev, DMM32AT_AIRBACK);
+ status = inb(dev->iobase + DMM32AT_AIRBACK);
if ((status & DMM32AT_STATUS) == 0)
break;
}
@@ -515,10 +213,10 @@ static int dmm32at_ai_rinsn(struct comedi_device *dev,
/* convert n samples */
for (n = 0; n < insn->n; n++) {
/* trigger conversion */
- dmm_outb(dev, DMM32AT_CONV, 0xff);
+ outb(0xff, dev->iobase + DMM32AT_CONV);
/* wait for conversion to end */
for (i = 0; i < 40000; i++) {
- status = dmm_inb(dev, DMM32AT_AISTAT);
+ status = inb(dev->iobase + DMM32AT_AISTAT);
if ((status & DMM32AT_STATUS) == 0)
break;
}
@@ -528,8 +226,8 @@ static int dmm32at_ai_rinsn(struct comedi_device *dev,
}
/* read data */
- lsb = dmm_inb(dev, DMM32AT_AILSB);
- msb = dmm_inb(dev, DMM32AT_AIMSB);
+ lsb = inb(dev->iobase + DMM32AT_AILSB);
+ msb = inb(dev->iobase + DMM32AT_AIMSB);
/* invert sign bit to make range unsigned, this is an
idiosyncrasy of the diamond board, it return
@@ -546,6 +244,12 @@ static int dmm32at_ai_rinsn(struct comedi_device *dev,
return n;
}
+static int dmm32at_ns_to_timer(unsigned int *ns, int round)
+{
+ /* trivial timer */
+ return *ns;
+}
+
static int dmm32at_ai_cmdtest(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_cmd *cmd)
@@ -554,15 +258,6 @@ static int dmm32at_ai_cmdtest(struct comedi_device *dev,
int tmp;
int start_chan, gain, i;
- /* printk("dmmat32 in command test\n"); */
-
- /* cmdtest tests a particular command to see if it is valid.
- * Using the cmdtest ioctl, a user can create a valid cmd
- * and then have it executes by the cmd ioctl.
- *
- * cmdtest returns 1,2,3,4 or 0, depending on which tests
- * the command passes. */
-
/* step 1: make sure trigger sources are trivially valid */
tmp = cmd->start_src;
@@ -732,8 +427,39 @@ static int dmm32at_ai_cmdtest(struct comedi_device *dev,
return 0;
}
+static void dmm32at_setaitimer(struct comedi_device *dev, unsigned int nansec)
+{
+ unsigned char lo1, lo2, hi2;
+ unsigned short both2;
+
+ /* based on 10mhz clock */
+ lo1 = 200;
+ both2 = nansec / 20000;
+ hi2 = (both2 & 0xff00) >> 8;
+ lo2 = both2 & 0x00ff;
+
+ /* set the counter frequency to 10mhz */
+ outb(0, dev->iobase + DMM32AT_CNTRDIO);
+
+ /* get access to the clock regs */
+ outb(DMM32AT_CLKACC, dev->iobase + DMM32AT_CNTRL);
+
+ /* write the counter 1 control word and low byte to counter */
+ outb(DMM32AT_CLKCT1, dev->iobase + DMM32AT_CLKCT);
+ outb(lo1, dev->iobase + DMM32AT_CLK1);
+
+ /* write the counter 2 control word and low byte then to counter */
+ outb(DMM32AT_CLKCT2, dev->iobase + DMM32AT_CLKCT);
+ outb(lo2, dev->iobase + DMM32AT_CLK2);
+ outb(hi2, dev->iobase + DMM32AT_CLK2);
+
+ /* enable the ai conversion interrupt and the clock to start scans */
+ outb(DMM32AT_ADINT | DMM32AT_CLKSEL, dev->iobase + DMM32AT_INTCLOCK);
+}
+
static int dmm32at_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
{
+ struct dmm32at_private *devpriv = dev->private;
struct comedi_cmd *cmd = &s->async->cmd;
int i, range;
unsigned char chanlo, chanhi, status;
@@ -749,20 +475,20 @@ static int dmm32at_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
range = CR_RANGE(cmd->chanlist[0]);
/* reset fifo */
- dmm_outb(dev, DMM32AT_FIFOCNTRL, DMM32AT_FIFORESET);
+ outb(DMM32AT_FIFORESET, dev->iobase + DMM32AT_FIFOCNTRL);
/* set scan enable */
- dmm_outb(dev, DMM32AT_FIFOCNTRL, DMM32AT_SCANENABLE);
+ outb(DMM32AT_SCANENABLE, dev->iobase + DMM32AT_FIFOCNTRL);
/* write the ai channel range regs */
- dmm_outb(dev, DMM32AT_AILOW, chanlo);
- dmm_outb(dev, DMM32AT_AIHIGH, chanhi);
+ outb(chanlo, dev->iobase + DMM32AT_AILOW);
+ outb(chanhi, dev->iobase + DMM32AT_AIHIGH);
/* set the range bits */
- dmm_outb(dev, DMM32AT_AICONF, dmm32at_rangebits[range]);
+ outb(dmm32at_rangebits[range], dev->iobase + DMM32AT_AICONF);
/* reset the interrupt just in case */
- dmm_outb(dev, DMM32AT_CNTRL, DMM32AT_INTRESET);
+ outb(DMM32AT_INTRESET, dev->iobase + DMM32AT_CNTRL);
if (cmd->stop_src == TRIG_COUNT)
devpriv->ai_scans_left = cmd->stop_arg;
@@ -773,7 +499,7 @@ static int dmm32at_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
/* wait for circuit to settle */
for (i = 0; i < 40000; i++) {
- status = dmm_inb(dev, DMM32AT_AIRBACK);
+ status = inb(dev->iobase + DMM32AT_AIRBACK);
if ((status & DMM32AT_STATUS) == 0)
break;
}
@@ -787,8 +513,8 @@ static int dmm32at_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
dmm32at_setaitimer(dev, cmd->scan_begin_arg);
} else {
/* start the interrups and initiate a single scan */
- dmm_outb(dev, DMM32AT_INTCLOCK, DMM32AT_ADINT);
- dmm_outb(dev, DMM32AT_CONV, 0xff);
+ outb(DMM32AT_ADINT, dev->iobase + DMM32AT_INTCLOCK);
+ outb(0xff, dev->iobase + DMM32AT_CONV);
}
/* printk("dmmat32 in command\n"); */
@@ -806,24 +532,27 @@ static int dmm32at_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
static int dmm32at_ai_cancel(struct comedi_device *dev,
struct comedi_subdevice *s)
{
+ struct dmm32at_private *devpriv = dev->private;
+
devpriv->ai_scans_left = 1;
return 0;
}
static irqreturn_t dmm32at_isr(int irq, void *d)
{
+ struct comedi_device *dev = d;
+ struct dmm32at_private *devpriv = dev->private;
unsigned char intstat;
unsigned int samp;
unsigned short msb, lsb;
int i;
- struct comedi_device *dev = d;
if (!dev->attached) {
comedi_error(dev, "spurious interrupt");
return IRQ_HANDLED;
}
- intstat = dmm_inb(dev, DMM32AT_INTCLOCK);
+ intstat = inb(dev->iobase + DMM32AT_INTCLOCK);
if (intstat & DMM32AT_ADINT) {
struct comedi_subdevice *s = dev->read_subdev;
@@ -831,8 +560,8 @@ static irqreturn_t dmm32at_isr(int irq, void *d)
for (i = 0; i < cmd->chanlist_len; i++) {
/* read data */
- lsb = dmm_inb(dev, DMM32AT_AILSB);
- msb = dmm_inb(dev, DMM32AT_AIMSB);
+ lsb = inb(dev->iobase + DMM32AT_AILSB);
+ msb = inb(dev->iobase + DMM32AT_AIMSB);
/* invert sign bit to make range unsigned */
samp = ((msb ^ 0x0080) << 8) + lsb;
@@ -843,7 +572,7 @@ static irqreturn_t dmm32at_isr(int irq, void *d)
devpriv->ai_scans_left--;
if (devpriv->ai_scans_left == 0) {
/* disable further interrupts and clocks */
- dmm_outb(dev, DMM32AT_INTCLOCK, 0x0);
+ outb(0x0, dev->iobase + DMM32AT_INTCLOCK);
/* set the buffer to be flushed with an EOF */
s->async->events |= COMEDI_CB_EOA;
}
@@ -854,31 +583,15 @@ static irqreturn_t dmm32at_isr(int irq, void *d)
}
/* reset the interrupt */
- dmm_outb(dev, DMM32AT_CNTRL, DMM32AT_INTRESET);
+ outb(DMM32AT_INTRESET, dev->iobase + DMM32AT_CNTRL);
return IRQ_HANDLED;
}
-/* This function doesn't require a particular form, this is just
- * what happens to be used in some of the drivers. It should
- * convert ns nanoseconds to a counter value suitable for programming
- * the device. Also, it should adjust ns so that it cooresponds to
- * the actual time that the device will use. */
-static int dmm32at_ns_to_timer(unsigned int *ns, int round)
-{
- /* trivial timer */
- /* if your timing is done through two cascaded timers, the
- * i8253_cascade_ns_to_timer() function in 8253.h can be
- * very helpful. There are also i8254_load() and i8254_mm_load()
- * which can be used to load values into the ubiquitous 8254 counters
- */
-
- return *ns;
-}
-
static int dmm32at_ao_winsn(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
+ struct dmm32at_private *devpriv = dev->private;
int i;
int chan = CR_CHAN(insn->chanspec);
unsigned char hi, lo, status;
@@ -895,12 +608,12 @@ static int dmm32at_ao_winsn(struct comedi_device *dev,
hi = (data[i] >> 8) + chan * (1 << 6);
/* printk("writing 0x%02x 0x%02x\n",hi,lo); */
/* write the low and high values to the board */
- dmm_outb(dev, DMM32AT_DACLSB, lo);
- dmm_outb(dev, DMM32AT_DACMSB, hi);
+ outb(lo, dev->iobase + DMM32AT_DACLSB);
+ outb(hi, dev->iobase + DMM32AT_DACMSB);
/* wait for circuit to settle */
for (i = 0; i < 40000; i++) {
- status = dmm_inb(dev, DMM32AT_DACSTAT);
+ status = inb(dev->iobase + DMM32AT_DACSTAT);
if ((status & DMM32AT_DACBUSY) == 0)
break;
}
@@ -909,7 +622,7 @@ static int dmm32at_ao_winsn(struct comedi_device *dev,
return -ETIMEDOUT;
}
/* dummy read to update trigger the output */
- status = dmm_inb(dev, DMM32AT_DACMSB);
+ status = inb(dev->iobase + DMM32AT_DACMSB);
}
@@ -917,12 +630,11 @@ static int dmm32at_ao_winsn(struct comedi_device *dev,
return i;
}
-/* AO subdevices should have a read insn as well as a write insn.
- * Usually this means copying a value stored in devpriv. */
static int dmm32at_ao_rinsn(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
+ struct dmm32at_private *devpriv = dev->private;
int i;
int chan = CR_CHAN(insn->chanspec);
@@ -932,20 +644,13 @@ static int dmm32at_ao_rinsn(struct comedi_device *dev,
return i;
}
-/* DIO devices are slightly special. Although it is possible to
- * implement the insn_read/insn_write interface, it is much more
- * useful to applications if you implement the insn_bits interface.
- * This allows packed reading/writing of the DIO channels. The
- * comedi core can convert between insn_bits and insn_read/write */
static int dmm32at_dio_insn_bits(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
+ struct dmm32at_private *devpriv = dev->private;
unsigned char diobits;
- if (insn->n != 2)
- return -EINVAL;
-
/* The insn data is a mask in data[0] and the new data
* in data[1], each channel cooresponding to a bit. */
if (data[0]) {
@@ -956,29 +661,29 @@ static int dmm32at_dio_insn_bits(struct comedi_device *dev,
}
/* get access to the DIO regs */
- dmm_outb(dev, DMM32AT_CNTRL, DMM32AT_DIOACC);
+ outb(DMM32AT_DIOACC, dev->iobase + DMM32AT_CNTRL);
/* if either part of dio is set for output */
if (((devpriv->dio_config & DMM32AT_DIRCL) == 0) ||
((devpriv->dio_config & DMM32AT_DIRCH) == 0)) {
diobits = (s->state & 0x00ff0000) >> 16;
- dmm_outb(dev, DMM32AT_DIOC, diobits);
+ outb(diobits, dev->iobase + DMM32AT_DIOC);
}
if ((devpriv->dio_config & DMM32AT_DIRB) == 0) {
diobits = (s->state & 0x0000ff00) >> 8;
- dmm_outb(dev, DMM32AT_DIOB, diobits);
+ outb(diobits, dev->iobase + DMM32AT_DIOB);
}
if ((devpriv->dio_config & DMM32AT_DIRA) == 0) {
diobits = (s->state & 0x000000ff);
- dmm_outb(dev, DMM32AT_DIOA, diobits);
+ outb(diobits, dev->iobase + DMM32AT_DIOA);
}
/* now read the state back in */
- s->state = dmm_inb(dev, DMM32AT_DIOC);
+ s->state = inb(dev->iobase + DMM32AT_DIOC);
s->state <<= 8;
- s->state |= dmm_inb(dev, DMM32AT_DIOB);
+ s->state |= inb(dev->iobase + DMM32AT_DIOB);
s->state <<= 8;
- s->state |= dmm_inb(dev, DMM32AT_DIOA);
+ s->state |= inb(dev->iobase + DMM32AT_DIOA);
data[1] = s->state;
/* on return, data[1] contains the value of the digital
@@ -988,13 +693,14 @@ static int dmm32at_dio_insn_bits(struct comedi_device *dev,
* it was a purely digital output subdevice */
/* data[1]=s->state; */
- return 2;
+ return insn->n;
}
static int dmm32at_dio_insn_config(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
+ struct dmm32at_private *devpriv = dev->private;
unsigned char chanbit;
int chan = CR_CHAN(insn->chanspec);
@@ -1021,60 +727,181 @@ static int dmm32at_dio_insn_config(struct comedi_device *dev,
else
devpriv->dio_config |= chanbit;
/* get access to the DIO regs */
- dmm_outb(dev, DMM32AT_CNTRL, DMM32AT_DIOACC);
+ outb(DMM32AT_DIOACC, dev->iobase + DMM32AT_CNTRL);
/* set the DIO's to the new configuration setting */
- dmm_outb(dev, DMM32AT_DIOCONF, devpriv->dio_config);
+ outb(devpriv->dio_config, dev->iobase + DMM32AT_DIOCONF);
return 1;
}
-void dmm32at_setaitimer(struct comedi_device *dev, unsigned int nansec)
+static int dmm32at_attach(struct comedi_device *dev,
+ struct comedi_devconfig *it)
{
- unsigned char lo1, lo2, hi2;
- unsigned short both2;
+ const struct dmm32at_board *board = comedi_board(dev);
+ struct dmm32at_private *devpriv;
+ int ret;
+ struct comedi_subdevice *s;
+ unsigned char aihi, ailo, fifostat, aistat, intstat, airback;
+ unsigned long iobase;
+ unsigned int irq;
- /* based on 10mhz clock */
- lo1 = 200;
- both2 = nansec / 20000;
- hi2 = (both2 & 0xff00) >> 8;
- lo2 = both2 & 0x00ff;
+ iobase = it->options[0];
+ irq = it->options[1];
- /* set the counter frequency to 10mhz */
- dmm_outb(dev, DMM32AT_CNTRDIO, 0);
+ printk(KERN_INFO "comedi%d: dmm32at: attaching\n", dev->minor);
+ printk(KERN_DEBUG "dmm32at: probing at address 0x%04lx, irq %u\n",
+ iobase, irq);
- /* get access to the clock regs */
- dmm_outb(dev, DMM32AT_CNTRL, DMM32AT_CLKACC);
+ /* register address space */
+ if (!request_region(iobase, DMM32AT_MEMSIZE, board->name)) {
+ printk(KERN_ERR "comedi%d: dmm32at: I/O port conflict\n",
+ dev->minor);
+ return -EIO;
+ }
+ dev->iobase = iobase;
- /* write the counter 1 control word and low byte to counter */
- dmm_outb(dev, DMM32AT_CLKCT, DMM32AT_CLKCT1);
- dmm_outb(dev, DMM32AT_CLK1, lo1);
+ /* the following just makes sure the board is there and gets
+ it to a known state */
- /* write the counter 2 control word and low byte then to counter */
- dmm_outb(dev, DMM32AT_CLKCT, DMM32AT_CLKCT2);
- dmm_outb(dev, DMM32AT_CLK2, lo2);
- dmm_outb(dev, DMM32AT_CLK2, hi2);
+ /* reset the board */
+ outb(DMM32AT_RESET, dev->iobase + DMM32AT_CNTRL);
- /* enable the ai conversion interrupt and the clock to start scans */
- dmm_outb(dev, DMM32AT_INTCLOCK, DMM32AT_ADINT | DMM32AT_CLKSEL);
+ /* allow a millisecond to reset */
+ udelay(1000);
-}
+ /* zero scan and fifo control */
+ outb(0x0, dev->iobase + DMM32AT_FIFOCNTRL);
+
+ /* zero interrupt and clock control */
+ outb(0x0, dev->iobase + DMM32AT_INTCLOCK);
+
+ /* write a test channel range, the high 3 bits should drop */
+ outb(0x80, dev->iobase + DMM32AT_AILOW);
+ outb(0xff, dev->iobase + DMM32AT_AIHIGH);
+
+ /* set the range at 10v unipolar */
+ outb(DMM32AT_RANGE_U10, dev->iobase + DMM32AT_AICONF);
+
+ /* should take 10 us to settle, here's a hundred */
+ udelay(100);
+
+ /* read back the values */
+ ailo = inb(dev->iobase + DMM32AT_AILOW);
+ aihi = inb(dev->iobase + DMM32AT_AIHIGH);
+ fifostat = inb(dev->iobase + DMM32AT_FIFOSTAT);
+ aistat = inb(dev->iobase + DMM32AT_AISTAT);
+ intstat = inb(dev->iobase + DMM32AT_INTCLOCK);
+ airback = inb(dev->iobase + DMM32AT_AIRBACK);
+
+ printk(KERN_DEBUG "dmm32at: lo=0x%02x hi=0x%02x fifostat=0x%02x\n",
+ ailo, aihi, fifostat);
+ printk(KERN_DEBUG
+ "dmm32at: aistat=0x%02x intstat=0x%02x airback=0x%02x\n",
+ aistat, intstat, airback);
+
+ if ((ailo != 0x00) || (aihi != 0x1f) || (fifostat != 0x80) ||
+ (aistat != 0x60 || (intstat != 0x00) || airback != 0x0c)) {
+ printk(KERN_ERR "dmmat32: board detection failed\n");
+ return -EIO;
+ }
+
+ /* board is there, register interrupt */
+ if (irq) {
+ ret = request_irq(irq, dmm32at_isr, 0, board->name, dev);
+ if (ret < 0) {
+ printk(KERN_ERR "dmm32at: irq conflict\n");
+ return ret;
+ }
+ dev->irq = irq;
+ }
+
+ dev->board_name = board->name;
+
+ if (alloc_private(dev, sizeof(*devpriv)) < 0)
+ return -ENOMEM;
+ devpriv = dev->private;
+
+ ret = comedi_alloc_subdevices(dev, 3);
+ if (ret)
+ return ret;
+
+ s = dev->subdevices + 0;
+ dev->read_subdev = s;
+ /* analog input subdevice */
+ s->type = COMEDI_SUBD_AI;
+ /* we support single-ended (ground) and differential */
+ s->subdev_flags = SDF_READABLE | SDF_GROUND | SDF_DIFF | SDF_CMD_READ;
+ s->n_chan = 32;
+ s->maxdata = 0xffff;
+ s->range_table = &dmm32at_airanges;
+ s->len_chanlist = 32; /* This is the maximum chanlist length that
+ the board can handle */
+ s->insn_read = dmm32at_ai_rinsn;
+ s->do_cmd = dmm32at_ai_cmd;
+ s->do_cmdtest = dmm32at_ai_cmdtest;
+ s->cancel = dmm32at_ai_cancel;
+
+ s = dev->subdevices + 1;
+ /* analog output subdevice */
+ s->type = COMEDI_SUBD_AO;
+ s->subdev_flags = SDF_WRITABLE;
+ s->n_chan = 4;
+ s->maxdata = 0x0fff;
+ s->range_table = &dmm32at_aoranges;
+ s->insn_write = dmm32at_ao_winsn;
+ s->insn_read = dmm32at_ao_rinsn;
+
+ s = dev->subdevices + 2;
+ /* digital i/o subdevice */
+
+ /* get access to the DIO regs */
+ outb(DMM32AT_DIOACC, dev->iobase + DMM32AT_CNTRL);
+ /* set the DIO's to the defualt input setting */
+ devpriv->dio_config = DMM32AT_DIRA | DMM32AT_DIRB |
+ DMM32AT_DIRCL | DMM32AT_DIRCH | DMM32AT_DIENABLE;
+ outb(devpriv->dio_config, dev->iobase + DMM32AT_DIOCONF);
+
+ /* set up the subdevice */
+ s->type = COMEDI_SUBD_DIO;
+ s->subdev_flags = SDF_READABLE | SDF_WRITABLE;
+ s->n_chan = 24;
+ s->maxdata = 1;
+ s->state = 0;
+ s->range_table = &range_digital;
+ s->insn_bits = dmm32at_dio_insn_bits;
+ s->insn_config = dmm32at_dio_insn_config;
+
+ /* success */
+ printk(KERN_INFO "comedi%d: dmm32at: attached\n", dev->minor);
+
+ return 1;
-/*
- * A convenient macro that defines init_module() and cleanup_module(),
- * as necessary.
- */
-static int __init driver_dmm32at_init_module(void)
-{
- return comedi_driver_register(&driver_dmm32at);
}
-static void __exit driver_dmm32at_cleanup_module(void)
+static void dmm32at_detach(struct comedi_device *dev)
{
- comedi_driver_unregister(&driver_dmm32at);
+ if (dev->irq)
+ free_irq(dev->irq, dev);
+ if (dev->iobase)
+ release_region(dev->iobase, DMM32AT_MEMSIZE);
}
-module_init(driver_dmm32at_init_module);
-module_exit(driver_dmm32at_cleanup_module);
+static const struct dmm32at_board dmm32at_boards[] = {
+ {
+ .name = "dmm32at",
+ },
+};
+
+static struct comedi_driver dmm32at_driver = {
+ .driver_name = "dmm32at",
+ .module = THIS_MODULE,
+ .attach = dmm32at_attach,
+ .detach = dmm32at_detach,
+ .board_name = &dmm32at_boards[0].name,
+ .offset = sizeof(struct dmm32at_board),
+ .num_names = ARRAY_SIZE(dmm32at_boards),
+};
+module_comedi_driver(dmm32at_driver);
MODULE_AUTHOR("Comedi http://www.comedi.org");
MODULE_DESCRIPTION("Comedi low-level driver");
diff --git a/drivers/staging/comedi/drivers/dt2801.c b/drivers/staging/comedi/drivers/dt2801.c
index b85c8366a396..d332269375ab 100644
--- a/drivers/staging/comedi/drivers/dt2801.c
+++ b/drivers/staging/comedi/drivers/dt2801.c
@@ -88,29 +88,6 @@ Configuration options:
#define DT2801_STATUS 1
#define DT2801_CMD 1
-static int dt2801_attach(struct comedi_device *dev,
- struct comedi_devconfig *it);
-static int dt2801_detach(struct comedi_device *dev);
-static struct comedi_driver driver_dt2801 = {
- .driver_name = "dt2801",
- .module = THIS_MODULE,
- .attach = dt2801_attach,
- .detach = dt2801_detach,
-};
-
-static int __init driver_dt2801_init_module(void)
-{
- return comedi_driver_register(&driver_dt2801);
-}
-
-static void __exit driver_dt2801_cleanup_module(void)
-{
- comedi_driver_unregister(&driver_dt2801);
-}
-
-module_init(driver_dt2801_init_module);
-module_exit(driver_dt2801_cleanup_module);
-
#if 0
/* ignore 'defined but not used' warning */
static const struct comedi_lrange range_dt2801_ai_pgh_bipolar = { 4, {
@@ -258,22 +235,6 @@ struct dt2801_private {
#define devpriv ((struct dt2801_private *)dev->private)
-static int dt2801_ai_insn_read(struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data);
-static int dt2801_ao_insn_read(struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data);
-static int dt2801_ao_insn_write(struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data);
-static int dt2801_dio_insn_bits(struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data);
-static int dt2801_dio_insn_config(struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data);
-
/* These are the low-level routines:
writecommand: write a command to the board
writedata: write data byte
@@ -503,126 +464,6 @@ static const struct comedi_lrange *ai_range_lkup(int type, int opt)
return &range_unknown;
}
-/*
- options:
- [0] - i/o base
- [1] - unused
- [2] - a/d 0=differential, 1=single-ended
- [3] - a/d range 0=[-10,10], 1=[0,10]
- [4] - dac0 range 0=[-10,10], 1=[-5,5], 2=[-2.5,2.5] 3=[0,10], 4=[0,5]
- [5] - dac1 range 0=[-10,10], 1=[-5,5], 2=[-2.5,2.5] 3=[0,10], 4=[0,5]
-*/
-static int dt2801_attach(struct comedi_device *dev, struct comedi_devconfig *it)
-{
- struct comedi_subdevice *s;
- unsigned long iobase;
- int board_code, type;
- int ret = 0;
- int n_ai_chans;
-
- iobase = it->options[0];
- if (!request_region(iobase, DT2801_IOSIZE, "dt2801")) {
- comedi_error(dev, "I/O port conflict");
- return -EIO;
- }
- dev->iobase = iobase;
-
- /* do some checking */
-
- board_code = dt2801_reset(dev);
-
- /* heh. if it didn't work, try it again. */
- if (!board_code)
- board_code = dt2801_reset(dev);
-
- for (type = 0; type < ARRAY_SIZE(boardtypes); type++) {
- if (boardtypes[type].boardcode == board_code)
- goto havetype;
- }
- printk("dt2801: unrecognized board code=0x%02x, contact author\n",
- board_code);
- type = 0;
-
-havetype:
- dev->board_ptr = boardtypes + type;
- printk("dt2801: %s at port 0x%lx", boardtype.name, iobase);
-
- n_ai_chans = probe_number_of_ai_chans(dev);
- printk(" (ai channels = %d)", n_ai_chans);
-
- ret = alloc_subdevices(dev, 4);
- if (ret < 0)
- goto out;
-
- ret = alloc_private(dev, sizeof(struct dt2801_private));
- if (ret < 0)
- goto out;
-
- dev->board_name = boardtype.name;
-
- s = dev->subdevices + 0;
- /* ai subdevice */
- s->type = COMEDI_SUBD_AI;
- s->subdev_flags = SDF_READABLE | SDF_GROUND;
-#if 1
- s->n_chan = n_ai_chans;
-#else
- if (it->options[2])
- s->n_chan = boardtype.ad_chan;
- else
- s->n_chan = boardtype.ad_chan / 2;
-#endif
- s->maxdata = (1 << boardtype.adbits) - 1;
- s->range_table = ai_range_lkup(boardtype.adrangetype, it->options[3]);
- s->insn_read = dt2801_ai_insn_read;
-
- s++;
- /* ao subdevice */
- s->type = COMEDI_SUBD_AO;
- s->subdev_flags = SDF_WRITABLE;
- s->n_chan = 2;
- s->maxdata = (1 << boardtype.dabits) - 1;
- s->range_table_list = devpriv->dac_range_types;
- devpriv->dac_range_types[0] = dac_range_lkup(it->options[4]);
- devpriv->dac_range_types[1] = dac_range_lkup(it->options[5]);
- s->insn_read = dt2801_ao_insn_read;
- s->insn_write = dt2801_ao_insn_write;
-
- s++;
- /* 1st digital subdevice */
- s->type = COMEDI_SUBD_DIO;
- s->subdev_flags = SDF_READABLE | SDF_WRITABLE;
- s->n_chan = 8;
- s->maxdata = 1;
- s->range_table = &range_digital;
- s->insn_bits = dt2801_dio_insn_bits;
- s->insn_config = dt2801_dio_insn_config;
-
- s++;
- /* 2nd digital subdevice */
- s->type = COMEDI_SUBD_DIO;
- s->subdev_flags = SDF_READABLE | SDF_WRITABLE;
- s->n_chan = 8;
- s->maxdata = 1;
- s->range_table = &range_digital;
- s->insn_bits = dt2801_dio_insn_bits;
- s->insn_config = dt2801_dio_insn_config;
-
- ret = 0;
-out:
- printk("\n");
-
- return ret;
-}
-
-static int dt2801_detach(struct comedi_device *dev)
-{
- if (dev->iobase)
- release_region(dev->iobase, DT2801_IOSIZE);
-
- return 0;
-}
-
static int dt2801_error(struct comedi_device *dev, int stat)
{
if (stat < 0) {
@@ -694,8 +535,6 @@ static int dt2801_dio_insn_bits(struct comedi_device *dev,
if (s == dev->subdevices + 4)
which = 1;
- if (insn->n != 2)
- return -EINVAL;
if (data[0]) {
s->state &= ~data[0];
s->state |= (data[0] & data[1]);
@@ -707,7 +546,7 @@ static int dt2801_dio_insn_bits(struct comedi_device *dev,
dt2801_writedata(dev, which);
dt2801_readdata(dev, data + 1);
- return 2;
+ return insn->n;
}
static int dt2801_dio_insn_config(struct comedi_device *dev,
@@ -740,6 +579,130 @@ static int dt2801_dio_insn_config(struct comedi_device *dev,
return 1;
}
+/*
+ options:
+ [0] - i/o base
+ [1] - unused
+ [2] - a/d 0=differential, 1=single-ended
+ [3] - a/d range 0=[-10,10], 1=[0,10]
+ [4] - dac0 range 0=[-10,10], 1=[-5,5], 2=[-2.5,2.5] 3=[0,10], 4=[0,5]
+ [5] - dac1 range 0=[-10,10], 1=[-5,5], 2=[-2.5,2.5] 3=[0,10], 4=[0,5]
+*/
+static int dt2801_attach(struct comedi_device *dev, struct comedi_devconfig *it)
+{
+ struct comedi_subdevice *s;
+ unsigned long iobase;
+ int board_code, type;
+ int ret = 0;
+ int n_ai_chans;
+
+ iobase = it->options[0];
+ if (!request_region(iobase, DT2801_IOSIZE, "dt2801")) {
+ comedi_error(dev, "I/O port conflict");
+ return -EIO;
+ }
+ dev->iobase = iobase;
+
+ /* do some checking */
+
+ board_code = dt2801_reset(dev);
+
+ /* heh. if it didn't work, try it again. */
+ if (!board_code)
+ board_code = dt2801_reset(dev);
+
+ for (type = 0; type < ARRAY_SIZE(boardtypes); type++) {
+ if (boardtypes[type].boardcode == board_code)
+ goto havetype;
+ }
+ printk("dt2801: unrecognized board code=0x%02x, contact author\n",
+ board_code);
+ type = 0;
+
+havetype:
+ dev->board_ptr = boardtypes + type;
+ printk("dt2801: %s at port 0x%lx", boardtype.name, iobase);
+
+ n_ai_chans = probe_number_of_ai_chans(dev);
+ printk(" (ai channels = %d)\n", n_ai_chans);
+
+ ret = comedi_alloc_subdevices(dev, 4);
+ if (ret)
+ goto out;
+
+ ret = alloc_private(dev, sizeof(struct dt2801_private));
+ if (ret < 0)
+ return ret;
+
+ dev->board_name = boardtype.name;
+
+ s = dev->subdevices + 0;
+ /* ai subdevice */
+ s->type = COMEDI_SUBD_AI;
+ s->subdev_flags = SDF_READABLE | SDF_GROUND;
+#if 1
+ s->n_chan = n_ai_chans;
+#else
+ if (it->options[2])
+ s->n_chan = boardtype.ad_chan;
+ else
+ s->n_chan = boardtype.ad_chan / 2;
+#endif
+ s->maxdata = (1 << boardtype.adbits) - 1;
+ s->range_table = ai_range_lkup(boardtype.adrangetype, it->options[3]);
+ s->insn_read = dt2801_ai_insn_read;
+
+ s++;
+ /* ao subdevice */
+ s->type = COMEDI_SUBD_AO;
+ s->subdev_flags = SDF_WRITABLE;
+ s->n_chan = 2;
+ s->maxdata = (1 << boardtype.dabits) - 1;
+ s->range_table_list = devpriv->dac_range_types;
+ devpriv->dac_range_types[0] = dac_range_lkup(it->options[4]);
+ devpriv->dac_range_types[1] = dac_range_lkup(it->options[5]);
+ s->insn_read = dt2801_ao_insn_read;
+ s->insn_write = dt2801_ao_insn_write;
+
+ s++;
+ /* 1st digital subdevice */
+ s->type = COMEDI_SUBD_DIO;
+ s->subdev_flags = SDF_READABLE | SDF_WRITABLE;
+ s->n_chan = 8;
+ s->maxdata = 1;
+ s->range_table = &range_digital;
+ s->insn_bits = dt2801_dio_insn_bits;
+ s->insn_config = dt2801_dio_insn_config;
+
+ s++;
+ /* 2nd digital subdevice */
+ s->type = COMEDI_SUBD_DIO;
+ s->subdev_flags = SDF_READABLE | SDF_WRITABLE;
+ s->n_chan = 8;
+ s->maxdata = 1;
+ s->range_table = &range_digital;
+ s->insn_bits = dt2801_dio_insn_bits;
+ s->insn_config = dt2801_dio_insn_config;
+
+ ret = 0;
+out:
+ return ret;
+}
+
+static void dt2801_detach(struct comedi_device *dev)
+{
+ if (dev->iobase)
+ release_region(dev->iobase, DT2801_IOSIZE);
+}
+
+static struct comedi_driver dt2801_driver = {
+ .driver_name = "dt2801",
+ .module = THIS_MODULE,
+ .attach = dt2801_attach,
+ .detach = dt2801_detach,
+};
+module_comedi_driver(dt2801_driver);
+
MODULE_AUTHOR("Comedi http://www.comedi.org");
MODULE_DESCRIPTION("Comedi low-level driver");
MODULE_LICENSE("GPL");
diff --git a/drivers/staging/comedi/drivers/dt2811.c b/drivers/staging/comedi/drivers/dt2811.c
index 0131d5225b52..290b933c5f96 100644
--- a/drivers/staging/comedi/drivers/dt2811.c
+++ b/drivers/staging/comedi/drivers/dt2811.c
@@ -211,61 +211,6 @@ struct dt2811_board {
const struct comedi_lrange *unip_5;
};
-static const struct dt2811_board boardtypes[] = {
- {"dt2811-pgh",
- &range_dt2811_pgh_ai_5_bipolar,
- &range_dt2811_pgh_ai_2_5_bipolar,
- &range_dt2811_pgh_ai_5_unipolar,
- },
- {"dt2811-pgl",
- &range_dt2811_pgl_ai_5_bipolar,
- &range_dt2811_pgl_ai_2_5_bipolar,
- &range_dt2811_pgl_ai_5_unipolar,
- },
-};
-
-#define this_board ((const struct dt2811_board *)dev->board_ptr)
-
-static int dt2811_attach(struct comedi_device *dev,
- struct comedi_devconfig *it);
-static int dt2811_detach(struct comedi_device *dev);
-static struct comedi_driver driver_dt2811 = {
- .driver_name = "dt2811",
- .module = THIS_MODULE,
- .attach = dt2811_attach,
- .detach = dt2811_detach,
- .board_name = &boardtypes[0].name,
- .num_names = ARRAY_SIZE(boardtypes),
- .offset = sizeof(struct dt2811_board),
-};
-
-static int __init driver_dt2811_init_module(void)
-{
- return comedi_driver_register(&driver_dt2811);
-}
-
-static void __exit driver_dt2811_cleanup_module(void)
-{
- comedi_driver_unregister(&driver_dt2811);
-}
-
-module_init(driver_dt2811_init_module);
-module_exit(driver_dt2811_cleanup_module);
-
-static int dt2811_ai_insn(struct comedi_device *dev, struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data);
-static int dt2811_ao_insn(struct comedi_device *dev, struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data);
-static int dt2811_ao_insn_read(struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data);
-static int dt2811_di_insn_bits(struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data);
-static int dt2811_do_insn_bits(struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data);
-
enum { card_2811_pgh, card_2811_pgl };
struct dt2811_private {
@@ -317,6 +262,114 @@ static irqreturn_t dt2811_interrupt(int irq, void *d)
}
#endif
+static int dt2811_ai_insn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
+{
+ int chan = CR_CHAN(insn->chanspec);
+ int timeout = DT2811_TIMEOUT;
+ int i;
+
+ for (i = 0; i < insn->n; i++) {
+ outb(chan, dev->iobase + DT2811_ADGCR);
+
+ while (timeout
+ && inb(dev->iobase + DT2811_ADCSR) & DT2811_ADBUSY)
+ timeout--;
+ if (!timeout)
+ return -ETIME;
+
+ data[i] = inb(dev->iobase + DT2811_ADDATLO);
+ data[i] |= inb(dev->iobase + DT2811_ADDATHI) << 8;
+ data[i] &= 0xfff;
+ }
+
+ return i;
+}
+
+#if 0
+/* Wow. This is code from the Comedi stone age. But it hasn't been
+ * replaced, so I'll let it stay. */
+int dt2811_adtrig(kdev_t minor, comedi_adtrig *adtrig)
+{
+ struct comedi_device *dev = comedi_devices + minor;
+
+ if (adtrig->n < 1)
+ return 0;
+ dev->curadchan = adtrig->chan;
+ switch (dev->i_admode) {
+ case COMEDI_MDEMAND:
+ dev->ntrig = adtrig->n - 1;
+ /* not necessary */
+ /*printk("dt2811: AD soft trigger\n"); */
+ /*outb(DT2811_CLRERROR|DT2811_INTENB,
+ dev->iobase+DT2811_ADCSR); */
+ outb(dev->curadchan, dev->iobase + DT2811_ADGCR);
+ do_gettimeofday(&trigtime);
+ break;
+ case COMEDI_MCONTS:
+ dev->ntrig = adtrig->n;
+ break;
+ }
+
+ return 0;
+}
+#endif
+
+static int dt2811_ao_insn(struct comedi_device *dev, struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
+{
+ int i;
+ int chan;
+
+ chan = CR_CHAN(insn->chanspec);
+
+ for (i = 0; i < insn->n; i++) {
+ outb(data[i] & 0xff, dev->iobase + DT2811_DADAT0LO + 2 * chan);
+ outb((data[i] >> 8) & 0xff,
+ dev->iobase + DT2811_DADAT0HI + 2 * chan);
+ devpriv->ao_readback[chan] = data[i];
+ }
+
+ return i;
+}
+
+static int dt2811_ao_insn_read(struct comedi_device *dev,
+ struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
+{
+ int i;
+ int chan;
+
+ chan = CR_CHAN(insn->chanspec);
+
+ for (i = 0; i < insn->n; i++)
+ data[i] = devpriv->ao_readback[chan];
+
+ return i;
+}
+
+static int dt2811_di_insn_bits(struct comedi_device *dev,
+ struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
+{
+ data[1] = inb(dev->iobase + DT2811_DIO);
+
+ return insn->n;
+}
+
+static int dt2811_do_insn_bits(struct comedi_device *dev,
+ struct comedi_subdevice *s,
+ struct comedi_insn *insn, unsigned int *data)
+{
+ s->state &= ~data[0];
+ s->state |= data[0] & data[1];
+ outb(s->state, dev->iobase + DT2811_DIO);
+
+ data[1] = s->state;
+
+ return insn->n;
+}
+
/*
options[0] Board base address
options[1] IRQ
@@ -337,13 +390,13 @@ static irqreturn_t dt2811_interrupt(int irq, void *d)
1 == bipolar 2.5V (-2.5V -- +2.5V)
2 == unipolar 5V (0V -- +5V)
*/
-
static int dt2811_attach(struct comedi_device *dev, struct comedi_devconfig *it)
{
/* int i, irq; */
/* unsigned long irqs; */
/* long flags; */
+ const struct dt2811_board *board = comedi_board(dev);
int ret;
struct comedi_subdevice *s;
unsigned long iobase;
@@ -358,7 +411,7 @@ static int dt2811_attach(struct comedi_device *dev, struct comedi_devconfig *it)
}
dev->iobase = iobase;
- dev->board_name = this_board->name;
+ dev->board_name = board->name;
#if 0
outb(0, dev->iobase + DT2811_ADCSR);
@@ -406,8 +459,8 @@ static int dt2811_attach(struct comedi_device *dev, struct comedi_devconfig *it)
}
#endif
- ret = alloc_subdevices(dev, 4);
- if (ret < 0)
+ ret = comedi_alloc_subdevices(dev, 4);
+ if (ret)
return ret;
ret = alloc_private(dev, sizeof(struct dt2811_private));
@@ -467,13 +520,13 @@ static int dt2811_attach(struct comedi_device *dev, struct comedi_devconfig *it)
switch (it->options[3]) {
case 0:
default:
- s->range_table = this_board->bip_5;
+ s->range_table = board->bip_5;
break;
case 1:
- s->range_table = this_board->bip_2_5;
+ s->range_table = board->bip_2_5;
break;
case 2:
- s->range_table = this_board->unip_5;
+ s->range_table = board->unip_5;
break;
}
@@ -511,131 +564,38 @@ static int dt2811_attach(struct comedi_device *dev, struct comedi_devconfig *it)
return 0;
}
-static int dt2811_detach(struct comedi_device *dev)
+static void dt2811_detach(struct comedi_device *dev)
{
- printk(KERN_INFO "comedi%d: dt2811: remove\n", dev->minor);
-
if (dev->irq)
free_irq(dev->irq, dev);
if (dev->iobase)
release_region(dev->iobase, DT2811_SIZE);
-
- return 0;
-}
-
-static int dt2811_ai_insn(struct comedi_device *dev, struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data)
-{
- int chan = CR_CHAN(insn->chanspec);
- int timeout = DT2811_TIMEOUT;
- int i;
-
- for (i = 0; i < insn->n; i++) {
- outb(chan, dev->iobase + DT2811_ADGCR);
-
- while (timeout
- && inb(dev->iobase + DT2811_ADCSR) & DT2811_ADBUSY)
- timeout--;
- if (!timeout)
- return -ETIME;
-
- data[i] = inb(dev->iobase + DT2811_ADDATLO);
- data[i] |= inb(dev->iobase + DT2811_ADDATHI) << 8;
- data[i] &= 0xfff;
- }
-
- return i;
-}
-
-#if 0
-/* Wow. This is code from the Comedi stone age. But it hasn't been
- * replaced, so I'll let it stay. */
-int dt2811_adtrig(kdev_t minor, comedi_adtrig *adtrig)
-{
- struct comedi_device *dev = comedi_devices + minor;
-
- if (adtrig->n < 1)
- return 0;
- dev->curadchan = adtrig->chan;
- switch (dev->i_admode) {
- case COMEDI_MDEMAND:
- dev->ntrig = adtrig->n - 1;
- /* not necessary */
- /*printk("dt2811: AD soft trigger\n"); */
- /*outb(DT2811_CLRERROR|DT2811_INTENB,
- dev->iobase+DT2811_ADCSR); */
- outb(dev->curadchan, dev->iobase + DT2811_ADGCR);
- do_gettimeofday(&trigtime);
- break;
- case COMEDI_MCONTS:
- dev->ntrig = adtrig->n;
- break;
- }
-
- return 0;
-}
-#endif
-
-static int dt2811_ao_insn(struct comedi_device *dev, struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data)
-{
- int i;
- int chan;
-
- chan = CR_CHAN(insn->chanspec);
-
- for (i = 0; i < insn->n; i++) {
- outb(data[i] & 0xff, dev->iobase + DT2811_DADAT0LO + 2 * chan);
- outb((data[i] >> 8) & 0xff,
- dev->iobase + DT2811_DADAT0HI + 2 * chan);
- devpriv->ao_readback[chan] = data[i];
- }
-
- return i;
-}
-
-static int dt2811_ao_insn_read(struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data)
-{
- int i;
- int chan;
-
- chan = CR_CHAN(insn->chanspec);
-
- for (i = 0; i < insn->n; i++)
- data[i] = devpriv->ao_readback[chan];
-
- return i;
-}
-
-static int dt2811_di_insn_bits(struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data)
-{
- if (insn->n != 2)
- return -EINVAL;
-
- data[1] = inb(dev->iobase + DT2811_DIO);
-
- return 2;
}
-static int dt2811_do_insn_bits(struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data)
-{
- if (insn->n != 2)
- return -EINVAL;
-
- s->state &= ~data[0];
- s->state |= data[0] & data[1];
- outb(s->state, dev->iobase + DT2811_DIO);
-
- data[1] = s->state;
+static const struct dt2811_board boardtypes[] = {
+ {
+ .name = "dt2811-pgh",
+ .bip_5 = &range_dt2811_pgh_ai_5_bipolar,
+ .bip_2_5 = &range_dt2811_pgh_ai_2_5_bipolar,
+ .unip_5 = &range_dt2811_pgh_ai_5_unipolar,
+ }, {
+ .name = "dt2811-pgl",
+ .bip_5 = &range_dt2811_pgl_ai_5_bipolar,
+ .bip_2_5 = &range_dt2811_pgl_ai_2_5_bipolar,
+ .unip_5 = &range_dt2811_pgl_ai_5_unipolar,
+ },
+};
- return 2;
-}
+static struct comedi_driver dt2811_driver = {
+ .driver_name = "dt2811",
+ .module = THIS_MODULE,
+ .attach = dt2811_attach,
+ .detach = dt2811_detach,
+ .board_name = &boardtypes[0].name,
+ .num_names = ARRAY_SIZE(boardtypes),
+ .offset = sizeof(struct dt2811_board),
+};
+module_comedi_driver(dt2811_driver);
MODULE_AUTHOR("Comedi http://www.comedi.org");
MODULE_DESCRIPTION("Comedi low-level driver");
diff --git a/drivers/staging/comedi/drivers/dt2814.c b/drivers/staging/comedi/drivers/dt2814.c
index 1c6248cf5928..2e39ebe36fb5 100644
--- a/drivers/staging/comedi/drivers/dt2814.c
+++ b/drivers/staging/comedi/drivers/dt2814.c
@@ -60,31 +60,6 @@ addition, the clock does not seem to be very accurate.
#define DT2814_ENB 0x10
#define DT2814_CHANMASK 0x0f
-static int dt2814_attach(struct comedi_device *dev,
- struct comedi_devconfig *it);
-static int dt2814_detach(struct comedi_device *dev);
-static struct comedi_driver driver_dt2814 = {
- .driver_name = "dt2814",
- .module = THIS_MODULE,
- .attach = dt2814_attach,
- .detach = dt2814_detach,
-};
-
-static int __init driver_dt2814_init_module(void)
-{
- return comedi_driver_register(&driver_dt2814);
-}
-
-static void __exit driver_dt2814_cleanup_module(void)
-{
- comedi_driver_unregister(&driver_dt2814);
-}
-
-module_init(driver_dt2814_init_module);
-module_exit(driver_dt2814_cleanup_module);
-
-static irqreturn_t dt2814_interrupt(int irq, void *dev);
-
struct dt2814_private {
int ntrig;
@@ -260,6 +235,45 @@ static int dt2814_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
}
+static irqreturn_t dt2814_interrupt(int irq, void *d)
+{
+ int lo, hi;
+ struct comedi_device *dev = d;
+ struct comedi_subdevice *s;
+ int data;
+
+ if (!dev->attached) {
+ comedi_error(dev, "spurious interrupt");
+ return IRQ_HANDLED;
+ }
+
+ s = dev->subdevices + 0;
+
+ hi = inb(dev->iobase + DT2814_DATA);
+ lo = inb(dev->iobase + DT2814_DATA);
+
+ data = (hi << 4) | (lo >> 4);
+
+ if (!(--devpriv->ntrig)) {
+ int i;
+
+ outb(0, dev->iobase + DT2814_CSR);
+ /* note: turning off timed mode triggers another
+ sample. */
+
+ for (i = 0; i < DT2814_TIMEOUT; i++) {
+ if (inb(dev->iobase + DT2814_CSR) & DT2814_FINISH)
+ break;
+ }
+ inb(dev->iobase + DT2814_DATA);
+ inb(dev->iobase + DT2814_DATA);
+
+ s->async->events |= COMEDI_CB_EOA;
+ }
+ comedi_event(dev, s);
+ return IRQ_HANDLED;
+}
+
static int dt2814_attach(struct comedi_device *dev, struct comedi_devconfig *it)
{
int i, irq;
@@ -324,8 +338,8 @@ static int dt2814_attach(struct comedi_device *dev, struct comedi_devconfig *it)
#endif
}
- ret = alloc_subdevices(dev, 1);
- if (ret < 0)
+ ret = comedi_alloc_subdevices(dev, 1);
+ if (ret)
return ret;
ret = alloc_private(dev, sizeof(struct dt2814_private));
@@ -347,57 +361,21 @@ static int dt2814_attach(struct comedi_device *dev, struct comedi_devconfig *it)
return 0;
}
-static int dt2814_detach(struct comedi_device *dev)
+static void dt2814_detach(struct comedi_device *dev)
{
- printk(KERN_INFO "comedi%d: dt2814: remove\n", dev->minor);
-
if (dev->irq)
free_irq(dev->irq, dev);
-
if (dev->iobase)
release_region(dev->iobase, DT2814_SIZE);
-
- return 0;
}
-static irqreturn_t dt2814_interrupt(int irq, void *d)
-{
- int lo, hi;
- struct comedi_device *dev = d;
- struct comedi_subdevice *s;
- int data;
-
- if (!dev->attached) {
- comedi_error(dev, "spurious interrupt");
- return IRQ_HANDLED;
- }
-
- s = dev->subdevices + 0;
-
- hi = inb(dev->iobase + DT2814_DATA);
- lo = inb(dev->iobase + DT2814_DATA);
-
- data = (hi << 4) | (lo >> 4);
-
- if (!(--devpriv->ntrig)) {
- int i;
-
- outb(0, dev->iobase + DT2814_CSR);
- /* note: turning off timed mode triggers another
- sample. */
-
- for (i = 0; i < DT2814_TIMEOUT; i++) {
- if (inb(dev->iobase + DT2814_CSR) & DT2814_FINISH)
- break;
- }
- inb(dev->iobase + DT2814_DATA);
- inb(dev->iobase + DT2814_DATA);
-
- s->async->events |= COMEDI_CB_EOA;
- }
- comedi_event(dev, s);
- return IRQ_HANDLED;
-}
+static struct comedi_driver dt2814_driver = {
+ .driver_name = "dt2814",
+ .module = THIS_MODULE,
+ .attach = dt2814_attach,
+ .detach = dt2814_detach,
+};
+module_comedi_driver(dt2814_driver);
MODULE_AUTHOR("Comedi http://www.comedi.org");
MODULE_DESCRIPTION("Comedi low-level driver");
diff --git a/drivers/staging/comedi/drivers/dt2815.c b/drivers/staging/comedi/drivers/dt2815.c
index 4155da43fd51..45b20bee4369 100644
--- a/drivers/staging/comedi/drivers/dt2815.c
+++ b/drivers/staging/comedi/drivers/dt2815.c
@@ -72,31 +72,6 @@ static const struct comedi_lrange
#define DT2815_DATA 0
#define DT2815_STATUS 1
-static int dt2815_attach(struct comedi_device *dev,
- struct comedi_devconfig *it);
-static int dt2815_detach(struct comedi_device *dev);
-static struct comedi_driver driver_dt2815 = {
- .driver_name = "dt2815",
- .module = THIS_MODULE,
- .attach = dt2815_attach,
- .detach = dt2815_detach,
-};
-
-static int __init driver_dt2815_init_module(void)
-{
- return comedi_driver_register(&driver_dt2815);
-}
-
-static void __exit driver_dt2815_cleanup_module(void)
-{
- comedi_driver_unregister(&driver_dt2815);
-}
-
-module_init(driver_dt2815_init_module);
-module_exit(driver_dt2815_cleanup_module);
-
-static void dt2815_free_resources(struct comedi_device *dev);
-
struct dt2815_private {
const struct comedi_lrange *range_type_list[8];
@@ -191,6 +166,7 @@ static int dt2815_attach(struct comedi_device *dev, struct comedi_devconfig *it)
int i;
const struct comedi_lrange *current_range_type, *voltage_range_type;
unsigned long iobase;
+ int ret;
iobase = it->options[0];
printk(KERN_INFO "comedi%d: dt2815: 0x%04lx ", dev->minor, iobase);
@@ -202,8 +178,10 @@ static int dt2815_attach(struct comedi_device *dev, struct comedi_devconfig *it)
dev->iobase = iobase;
dev->board_name = "dt2815";
- if (alloc_subdevices(dev, 1) < 0)
- return -ENOMEM;
+ ret = comedi_alloc_subdevices(dev, 1);
+ if (ret)
+ return ret;
+
if (alloc_private(dev, sizeof(struct dt2815_private)) < 0)
return -ENOMEM;
@@ -252,20 +230,19 @@ static int dt2815_attach(struct comedi_device *dev, struct comedi_devconfig *it)
return 0;
}
-static void dt2815_free_resources(struct comedi_device *dev)
+static void dt2815_detach(struct comedi_device *dev)
{
if (dev->iobase)
release_region(dev->iobase, DT2815_SIZE);
}
-static int dt2815_detach(struct comedi_device *dev)
-{
- printk(KERN_INFO "comedi%d: dt2815: remove\n", dev->minor);
-
- dt2815_free_resources(dev);
-
- return 0;
-}
+static struct comedi_driver dt2815_driver = {
+ .driver_name = "dt2815",
+ .module = THIS_MODULE,
+ .attach = dt2815_attach,
+ .detach = dt2815_detach,
+};
+module_comedi_driver(dt2815_driver);
MODULE_AUTHOR("Comedi http://www.comedi.org");
MODULE_DESCRIPTION("Comedi low-level driver");
diff --git a/drivers/staging/comedi/drivers/dt2817.c b/drivers/staging/comedi/drivers/dt2817.c
index 99c1584153d7..beba0447b3ee 100644
--- a/drivers/staging/comedi/drivers/dt2817.c
+++ b/drivers/staging/comedi/drivers/dt2817.c
@@ -47,29 +47,6 @@ Configuration options:
#define DT2817_CR 0
#define DT2817_DATA 1
-static int dt2817_attach(struct comedi_device *dev,
- struct comedi_devconfig *it);
-static int dt2817_detach(struct comedi_device *dev);
-static struct comedi_driver driver_dt2817 = {
- .driver_name = "dt2817",
- .module = THIS_MODULE,
- .attach = dt2817_attach,
- .detach = dt2817_detach,
-};
-
-static int __init driver_dt2817_init_module(void)
-{
- return comedi_driver_register(&driver_dt2817);
-}
-
-static void __exit driver_dt2817_cleanup_module(void)
-{
- comedi_driver_unregister(&driver_dt2817);
-}
-
-module_init(driver_dt2817_init_module);
-module_exit(driver_dt2817_cleanup_module);
-
static int dt2817_dio_insn_config(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
@@ -142,7 +119,7 @@ static int dt2817_dio_insn_bits(struct comedi_device *dev,
data[1] |= (inb(dev->iobase + DT2817_DATA + 2) << 16);
data[1] |= (inb(dev->iobase + DT2817_DATA + 3) << 24);
- return 2;
+ return insn->n;
}
static int dt2817_attach(struct comedi_device *dev, struct comedi_devconfig *it)
@@ -160,8 +137,8 @@ static int dt2817_attach(struct comedi_device *dev, struct comedi_devconfig *it)
dev->iobase = iobase;
dev->board_name = "dt2817";
- ret = alloc_subdevices(dev, 1);
- if (ret < 0)
+ ret = comedi_alloc_subdevices(dev, 1);
+ if (ret)
return ret;
s = dev->subdevices + 0;
@@ -182,16 +159,20 @@ static int dt2817_attach(struct comedi_device *dev, struct comedi_devconfig *it)
return 0;
}
-static int dt2817_detach(struct comedi_device *dev)
+static void dt2817_detach(struct comedi_device *dev)
{
- printk(KERN_INFO "comedi%d: dt2817: remove\n", dev->minor);
-
if (dev->iobase)
release_region(dev->iobase, DT2817_SIZE);
-
- return 0;
}
+static struct comedi_driver dt2817_driver = {
+ .driver_name = "dt2817",
+ .module = THIS_MODULE,
+ .attach = dt2817_attach,
+ .detach = dt2817_detach,
+};
+module_comedi_driver(dt2817_driver);
+
MODULE_AUTHOR("Comedi http://www.comedi.org");
MODULE_DESCRIPTION("Comedi low-level driver");
MODULE_LICENSE("GPL");
diff --git a/drivers/staging/comedi/drivers/dt282x.c b/drivers/staging/comedi/drivers/dt282x.c
index 95ebc267bb74..1f0b40e4bddd 100644
--- a/drivers/staging/comedi/drivers/dt282x.c
+++ b/drivers/staging/comedi/drivers/dt282x.c
@@ -221,138 +221,6 @@ struct dt282x_board {
int dabits;
};
-static const struct dt282x_board boardtypes[] = {
- {.name = "dt2821",
- .adbits = 12,
- .adchan_se = 16,
- .adchan_di = 8,
- .ai_speed = 20000,
- .ispgl = 0,
- .dachan = 2,
- .dabits = 12,
- },
- {.name = "dt2821-f",
- .adbits = 12,
- .adchan_se = 16,
- .adchan_di = 8,
- .ai_speed = 6500,
- .ispgl = 0,
- .dachan = 2,
- .dabits = 12,
- },
- {.name = "dt2821-g",
- .adbits = 12,
- .adchan_se = 16,
- .adchan_di = 8,
- .ai_speed = 4000,
- .ispgl = 0,
- .dachan = 2,
- .dabits = 12,
- },
- {.name = "dt2823",
- .adbits = 16,
- .adchan_se = 0,
- .adchan_di = 4,
- .ai_speed = 10000,
- .ispgl = 0,
- .dachan = 2,
- .dabits = 16,
- },
- {.name = "dt2824-pgh",
- .adbits = 12,
- .adchan_se = 16,
- .adchan_di = 8,
- .ai_speed = 20000,
- .ispgl = 0,
- .dachan = 0,
- .dabits = 0,
- },
- {.name = "dt2824-pgl",
- .adbits = 12,
- .adchan_se = 16,
- .adchan_di = 8,
- .ai_speed = 20000,
- .ispgl = 1,
- .dachan = 0,
- .dabits = 0,
- },
- {.name = "dt2825",
- .adbits = 12,
- .adchan_se = 16,
- .adchan_di = 8,
- .ai_speed = 20000,
- .ispgl = 1,
- .dachan = 2,
- .dabits = 12,
- },
- {.name = "dt2827",
- .adbits = 16,
- .adchan_se = 0,
- .adchan_di = 4,
- .ai_speed = 10000,
- .ispgl = 0,
- .dachan = 2,
- .dabits = 12,
- },
- {.name = "dt2828",
- .adbits = 12,
- .adchan_se = 4,
- .adchan_di = 0,
- .ai_speed = 10000,
- .ispgl = 0,
- .dachan = 2,
- .dabits = 12,
- },
- {.name = "dt2829",
- .adbits = 16,
- .adchan_se = 8,
- .adchan_di = 0,
- .ai_speed = 33250,
- .ispgl = 0,
- .dachan = 2,
- .dabits = 16,
- },
- {.name = "dt21-ez",
- .adbits = 12,
- .adchan_se = 16,
- .adchan_di = 8,
- .ai_speed = 10000,
- .ispgl = 0,
- .dachan = 2,
- .dabits = 12,
- },
- {.name = "dt23-ez",
- .adbits = 16,
- .adchan_se = 16,
- .adchan_di = 8,
- .ai_speed = 10000,
- .ispgl = 0,
- .dachan = 0,
- .dabits = 0,
- },
- {.name = "dt24-ez",
- .adbits = 12,
- .adchan_se = 16,
- .adchan_di = 8,
- .ai_speed = 10000,
- .ispgl = 0,
- .dachan = 0,
- .dabits = 0,
- },
- {.name = "dt24-ez-pgl",
- .adbits = 12,
- .adchan_se = 16,
- .adchan_di = 8,
- .ai_speed = 10000,
- .ispgl = 1,
- .dachan = 0,
- .dabits = 0,
- },
-};
-
-#define n_boardtypes (sizeof(boardtypes)/sizeof(struct dt282x_board))
-#define this_board ((const struct dt282x_board *)dev->board_ptr)
-
struct dt282x_private {
int ad_2scomp; /* we have 2's comp jumper set */
int da0_2scomp; /* same, for DAC0 */
@@ -387,11 +255,8 @@ struct dt282x_private {
* Some useless abstractions
*/
#define chan_to_DAC(a) ((a)&1)
-#define update_dacsr(a) outw(devpriv->dacsr|(a), dev->iobase+DT2821_DACSR)
-#define update_adcsr(a) outw(devpriv->adcsr|(a), dev->iobase+DT2821_ADCSR)
#define mux_busy() (inw(dev->iobase+DT2821_ADCSR)&DT2821_MUXBUSY)
#define ad_done() (inw(dev->iobase+DT2821_ADCSR)&DT2821_ADDONE)
-#define update_supcsr(a) outw(devpriv->supcsr|(a), dev->iobase+DT2821_SUPCSR)
/*
* danger! macro abuse... a is the expression to wait on, and b is
@@ -411,33 +276,6 @@ struct dt282x_private {
b \
} while (0)
-static int dt282x_attach(struct comedi_device *dev,
- struct comedi_devconfig *it);
-static int dt282x_detach(struct comedi_device *dev);
-static struct comedi_driver driver_dt282x = {
- .driver_name = "dt282x",
- .module = THIS_MODULE,
- .attach = dt282x_attach,
- .detach = dt282x_detach,
- .board_name = &boardtypes[0].name,
- .num_names = n_boardtypes,
- .offset = sizeof(struct dt282x_board),
-};
-
-static int __init driver_dt282x_init_module(void)
-{
- return comedi_driver_register(&driver_dt282x);
-}
-
-static void __exit driver_dt282x_cleanup_module(void)
-{
- comedi_driver_unregister(&driver_dt282x);
-}
-
-module_init(driver_dt282x_init_module);
-module_exit(driver_dt282x_cleanup_module);
-
-static void free_resources(struct comedi_device *dev);
static int prep_ai_dma(struct comedi_device *dev, int chan, int size);
static int prep_ao_dma(struct comedi_device *dev, int chan, int size);
static int dt282x_ai_cancel(struct comedi_device *dev,
@@ -476,7 +314,7 @@ static void dt282x_ao_dma_interrupt(struct comedi_device *dev)
int i;
struct comedi_subdevice *s = dev->subdevices + 1;
- update_supcsr(DT2821_CLRDMADNE);
+ outw(devpriv->supcsr | DT2821_CLRDMADNE, dev->iobase + DT2821_SUPCSR);
if (!s->async->prealloc_buf) {
printk(KERN_ERR "async->data disappeared. dang!\n");
@@ -509,7 +347,7 @@ static void dt282x_ai_dma_interrupt(struct comedi_device *dev)
int ret;
struct comedi_subdevice *s = dev->subdevices;
- update_supcsr(DT2821_CLRDMADNE);
+ outw(devpriv->supcsr | DT2821_CLRDMADNE, dev->iobase + DT2821_SUPCSR);
if (!s->async->prealloc_buf) {
printk(KERN_ERR "async->data disappeared. dang!\n");
@@ -546,7 +384,7 @@ static void dt282x_ai_dma_interrupt(struct comedi_device *dev)
/* XXX probably wrong */
if (!devpriv->ntrig) {
devpriv->supcsr &= ~(DT2821_DDMA);
- update_supcsr(0);
+ outw(devpriv->supcsr, dev->iobase + DT2821_SUPCSR);
}
#endif
/* restart the channel */
@@ -672,7 +510,8 @@ static irqreturn_t dt282x_interrupt(int irq, void *d)
s->async->events |= COMEDI_CB_EOA;
} else {
if (supcsr & DT2821_SCDN)
- update_supcsr(DT2821_STRIG);
+ outw(devpriv->supcsr | DT2821_STRIG,
+ dev->iobase + DT2821_SUPCSR);
}
handled = 1;
}
@@ -693,7 +532,8 @@ static void dt282x_load_changain(struct comedi_device *dev, int n,
for (i = 0; i < n; i++) {
chan = CR_CHAN(chanlist[i]);
range = CR_RANGE(chanlist[i]);
- update_adcsr((range << 4) | (chan));
+ outw(devpriv->adcsr | (range << 4) | chan,
+ dev->iobase + DT2821_ADCSR);
}
outw(n - 1, dev->iobase + DT2821_CHANCSR);
}
@@ -712,15 +552,16 @@ static int dt282x_ai_insn_read(struct comedi_device *dev,
/* XXX should we really be enabling the ad clock here? */
devpriv->adcsr = DT2821_ADCLK;
- update_adcsr(0);
+ outw(devpriv->adcsr, dev->iobase + DT2821_ADCSR);
dt282x_load_changain(dev, 1, &insn->chanspec);
- update_supcsr(DT2821_PRLD);
+ outw(devpriv->supcsr | DT2821_PRLD, dev->iobase + DT2821_SUPCSR);
wait_for(!mux_busy(), comedi_error(dev, "timeout\n"); return -ETIME;);
for (i = 0; i < insn->n; i++) {
- update_supcsr(DT2821_STRIG);
+ outw(devpriv->supcsr | DT2821_STRIG,
+ dev->iobase + DT2821_SUPCSR);
wait_for(ad_done(), comedi_error(dev, "timeout\n");
return -ETIME;);
@@ -737,6 +578,7 @@ static int dt282x_ai_insn_read(struct comedi_device *dev,
static int dt282x_ai_cmdtest(struct comedi_device *dev,
struct comedi_subdevice *s, struct comedi_cmd *cmd)
{
+ const struct dt282x_board *board = comedi_board(dev);
int err = 0;
int tmp;
@@ -815,8 +657,8 @@ static int dt282x_ai_cmdtest(struct comedi_device *dev,
cmd->convert_arg = SLOWEST_TIMER;
err++;
}
- if (cmd->convert_arg < this_board->ai_speed) {
- cmd->convert_arg = this_board->ai_speed;
+ if (cmd->convert_arg < board->ai_speed) {
+ cmd->convert_arg = board->ai_speed;
err++;
}
if (cmd->scan_end_arg != cmd->chanlist_len) {
@@ -851,6 +693,7 @@ static int dt282x_ai_cmdtest(struct comedi_device *dev,
static int dt282x_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
{
+ const struct dt282x_board *board = comedi_board(dev);
struct comedi_cmd *cmd = &s->async->cmd;
int timer;
@@ -863,8 +706,8 @@ static int dt282x_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
dt282x_disable_dma(dev);
- if (cmd->convert_arg < this_board->ai_speed)
- cmd->convert_arg = this_board->ai_speed;
+ if (cmd->convert_arg < board->ai_speed)
+ cmd->convert_arg = board->ai_speed;
timer = dt282x_ns_to_timer(&cmd->convert_arg, TRIG_ROUND_NEAREST);
outw(timer, dev->iobase + DT2821_TMRCTR);
@@ -875,7 +718,8 @@ static int dt282x_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
/* external trigger */
devpriv->supcsr = DT2821_ERRINTEN | DT2821_DS0 | DT2821_DS1;
}
- update_supcsr(DT2821_CLRDMADNE | DT2821_BUFFB | DT2821_ADCINIT);
+ outw(devpriv->supcsr | DT2821_CLRDMADNE | DT2821_BUFFB | DT2821_ADCINIT,
+ dev->iobase + DT2821_SUPCSR);
devpriv->ntrig = cmd->stop_arg * cmd->scan_end_arg;
devpriv->nread = devpriv->ntrig;
@@ -886,7 +730,7 @@ static int dt282x_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
if (devpriv->ntrig) {
prep_ai_dma(dev, 1, 0);
devpriv->supcsr |= DT2821_DDMA;
- update_supcsr(0);
+ outw(devpriv->supcsr, dev->iobase + DT2821_SUPCSR);
}
devpriv->adcsr = 0;
@@ -894,16 +738,17 @@ static int dt282x_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
dt282x_load_changain(dev, cmd->chanlist_len, cmd->chanlist);
devpriv->adcsr = DT2821_ADCLK | DT2821_IADDONE;
- update_adcsr(0);
+ outw(devpriv->adcsr, dev->iobase + DT2821_ADCSR);
- update_supcsr(DT2821_PRLD);
+ outw(devpriv->supcsr | DT2821_PRLD, dev->iobase + DT2821_SUPCSR);
wait_for(!mux_busy(), comedi_error(dev, "timeout\n"); return -ETIME;);
if (cmd->scan_begin_src == TRIG_FOLLOW) {
- update_supcsr(DT2821_STRIG);
+ outw(devpriv->supcsr | DT2821_STRIG,
+ dev->iobase + DT2821_SUPCSR);
} else {
devpriv->supcsr |= DT2821_XTRIG;
- update_supcsr(0);
+ outw(devpriv->supcsr, dev->iobase + DT2821_SUPCSR);
}
return 0;
@@ -923,10 +768,10 @@ static int dt282x_ai_cancel(struct comedi_device *dev,
dt282x_disable_dma(dev);
devpriv->adcsr = 0;
- update_adcsr(0);
+ outw(devpriv->adcsr, dev->iobase + DT2821_ADCSR);
devpriv->supcsr = 0;
- update_supcsr(DT2821_ADCINIT);
+ outw(devpriv->supcsr | DT2821_ADCINIT, dev->iobase + DT2821_SUPCSR);
return 0;
}
@@ -1002,11 +847,11 @@ static int dt282x_ao_insn_write(struct comedi_device *dev,
d ^= (1 << (boardtype.dabits - 1));
}
- update_dacsr(0);
+ outw(devpriv->dacsr, dev->iobase + DT2821_DACSR);
outw(d, dev->iobase + DT2821_DADAT);
- update_supcsr(DT2821_DACON);
+ outw(devpriv->supcsr | DT2821_DACON, dev->iobase + DT2821_SUPCSR);
return 1;
}
@@ -1129,7 +974,7 @@ static int dt282x_ao_inttrig(struct comedi_device *dev,
}
prep_ao_dma(dev, 1, size);
- update_supcsr(DT2821_STRIG);
+ outw(devpriv->supcsr | DT2821_STRIG, dev->iobase + DT2821_SUPCSR);
s->async->inttrig = NULL;
return 1;
@@ -1150,7 +995,8 @@ static int dt282x_ao_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
dt282x_disable_dma(dev);
devpriv->supcsr = DT2821_ERRINTEN | DT2821_DS1 | DT2821_DDMA;
- update_supcsr(DT2821_CLRDMADNE | DT2821_BUFFB | DT2821_DACINIT);
+ outw(devpriv->supcsr | DT2821_CLRDMADNE | DT2821_BUFFB | DT2821_DACINIT,
+ dev->iobase + DT2821_SUPCSR);
devpriv->ntrig = cmd->stop_arg * cmd->chanlist_len;
devpriv->nread = devpriv->ntrig;
@@ -1162,7 +1008,7 @@ static int dt282x_ao_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
outw(timer, dev->iobase + DT2821_TMRCTR);
devpriv->dacsr = DT2821_SSEL | DT2821_DACLK | DT2821_IDARDY;
- update_dacsr(0);
+ outw(devpriv->dacsr, dev->iobase + DT2821_DACSR);
s->async->inttrig = dt282x_ao_inttrig;
@@ -1175,10 +1021,10 @@ static int dt282x_ao_cancel(struct comedi_device *dev,
dt282x_disable_dma(dev);
devpriv->dacsr = 0;
- update_dacsr(0);
+ outw(devpriv->dacsr, dev->iobase + DT2821_DACSR);
devpriv->supcsr = 0;
- update_supcsr(DT2821_DACINIT);
+ outw(devpriv->supcsr | DT2821_DACINIT, dev->iobase + DT2821_SUPCSR);
return 0;
}
@@ -1195,7 +1041,7 @@ static int dt282x_dio_insn_bits(struct comedi_device *dev,
}
data[1] = inw(dev->iobase + DT2821_DIODAT);
- return 2;
+ return insn->n;
}
static int dt282x_dio_insn_config(struct comedi_device *dev,
@@ -1271,6 +1117,52 @@ enum { /* i/o base, irq, dma channels */
opt_ai_range, opt_ao0_range, opt_ao1_range, /* range */
};
+static int dt282x_grab_dma(struct comedi_device *dev, int dma1, int dma2)
+{
+ int ret;
+
+ devpriv->usedma = 0;
+
+ if (!dma1 && !dma2) {
+ printk(KERN_ERR " (no dma)");
+ return 0;
+ }
+
+ if (dma1 == dma2 || dma1 < 5 || dma2 < 5 || dma1 > 7 || dma2 > 7)
+ return -EINVAL;
+
+ if (dma2 < dma1) {
+ int i;
+ i = dma1;
+ dma1 = dma2;
+ dma2 = i;
+ }
+
+ ret = request_dma(dma1, "dt282x A");
+ if (ret)
+ return -EBUSY;
+ devpriv->dma[0].chan = dma1;
+
+ ret = request_dma(dma2, "dt282x B");
+ if (ret)
+ return -EBUSY;
+ devpriv->dma[1].chan = dma2;
+
+ devpriv->dma_maxsize = PAGE_SIZE;
+ devpriv->dma[0].buf = (void *)__get_free_page(GFP_KERNEL | GFP_DMA);
+ devpriv->dma[1].buf = (void *)__get_free_page(GFP_KERNEL | GFP_DMA);
+ if (!devpriv->dma[0].buf || !devpriv->dma[1].buf) {
+ printk(KERN_ERR " can't get DMA memory");
+ return -ENOMEM;
+ }
+
+ printk(KERN_INFO " (dma=%d,%d)", dma1, dma2);
+
+ devpriv->usedma = 1;
+
+ return 0;
+}
+
/*
options:
0 i/o base
@@ -1287,12 +1179,13 @@ enum { /* i/o base, irq, dma channels */
*/
static int dt282x_attach(struct comedi_device *dev, struct comedi_devconfig *it)
{
+ const struct dt282x_board *board = comedi_board(dev);
int i, irq;
int ret;
struct comedi_subdevice *s;
unsigned long iobase;
- dev->board_name = this_board->name;
+ dev->board_name = board->name;
iobase = it->options[opt_iobase];
if (!iobase)
@@ -1378,8 +1271,8 @@ static int dt282x_attach(struct comedi_device *dev, struct comedi_devconfig *it)
if (ret < 0)
return ret;
- ret = alloc_subdevices(dev, 3);
- if (ret < 0)
+ ret = comedi_alloc_subdevices(dev, 3);
+ if (ret)
return ret;
s = dev->subdevices + 0;
@@ -1442,7 +1335,7 @@ static int dt282x_attach(struct comedi_device *dev, struct comedi_devconfig *it)
return 0;
}
-static void free_resources(struct comedi_device *dev)
+static void dt282x_detach(struct comedi_device *dev)
{
if (dev->irq)
free_irq(dev->irq, dev);
@@ -1460,60 +1353,146 @@ static void free_resources(struct comedi_device *dev)
}
}
-static int dt282x_detach(struct comedi_device *dev)
-{
- printk(KERN_INFO "comedi%d: dt282x: remove\n", dev->minor);
-
- free_resources(dev);
-
- return 0;
-}
-
-static int dt282x_grab_dma(struct comedi_device *dev, int dma1, int dma2)
-{
- int ret;
-
- devpriv->usedma = 0;
-
- if (!dma1 && !dma2) {
- printk(KERN_ERR " (no dma)");
- return 0;
- }
-
- if (dma1 == dma2 || dma1 < 5 || dma2 < 5 || dma1 > 7 || dma2 > 7)
- return -EINVAL;
-
- if (dma2 < dma1) {
- int i;
- i = dma1;
- dma1 = dma2;
- dma2 = i;
- }
-
- ret = request_dma(dma1, "dt282x A");
- if (ret)
- return -EBUSY;
- devpriv->dma[0].chan = dma1;
-
- ret = request_dma(dma2, "dt282x B");
- if (ret)
- return -EBUSY;
- devpriv->dma[1].chan = dma2;
-
- devpriv->dma_maxsize = PAGE_SIZE;
- devpriv->dma[0].buf = (void *)__get_free_page(GFP_KERNEL | GFP_DMA);
- devpriv->dma[1].buf = (void *)__get_free_page(GFP_KERNEL | GFP_DMA);
- if (!devpriv->dma[0].buf || !devpriv->dma[1].buf) {
- printk(KERN_ERR " can't get DMA memory");
- return -ENOMEM;
- }
-
- printk(KERN_INFO " (dma=%d,%d)", dma1, dma2);
-
- devpriv->usedma = 1;
+static const struct dt282x_board boardtypes[] = {
+ {
+ .name = "dt2821",
+ .adbits = 12,
+ .adchan_se = 16,
+ .adchan_di = 8,
+ .ai_speed = 20000,
+ .ispgl = 0,
+ .dachan = 2,
+ .dabits = 12,
+ }, {
+ .name = "dt2821-f",
+ .adbits = 12,
+ .adchan_se = 16,
+ .adchan_di = 8,
+ .ai_speed = 6500,
+ .ispgl = 0,
+ .dachan = 2,
+ .dabits = 12,
+ }, {
+ .name = "dt2821-g",
+ .adbits = 12,
+ .adchan_se = 16,
+ .adchan_di = 8,
+ .ai_speed = 4000,
+ .ispgl = 0,
+ .dachan = 2,
+ .dabits = 12,
+ }, {
+ .name = "dt2823",
+ .adbits = 16,
+ .adchan_se = 0,
+ .adchan_di = 4,
+ .ai_speed = 10000,
+ .ispgl = 0,
+ .dachan = 2,
+ .dabits = 16,
+ }, {
+ .name = "dt2824-pgh",
+ .adbits = 12,
+ .adchan_se = 16,
+ .adchan_di = 8,
+ .ai_speed = 20000,
+ .ispgl = 0,
+ .dachan = 0,
+ .dabits = 0,
+ }, {
+ .name = "dt2824-pgl",
+ .adbits = 12,
+ .adchan_se = 16,
+ .adchan_di = 8,
+ .ai_speed = 20000,
+ .ispgl = 1,
+ .dachan = 0,
+ .dabits = 0,
+ }, {
+ .name = "dt2825",
+ .adbits = 12,
+ .adchan_se = 16,
+ .adchan_di = 8,
+ .ai_speed = 20000,
+ .ispgl = 1,
+ .dachan = 2,
+ .dabits = 12,
+ }, {
+ .name = "dt2827",
+ .adbits = 16,
+ .adchan_se = 0,
+ .adchan_di = 4,
+ .ai_speed = 10000,
+ .ispgl = 0,
+ .dachan = 2,
+ .dabits = 12,
+ }, {
+ .name = "dt2828",
+ .adbits = 12,
+ .adchan_se = 4,
+ .adchan_di = 0,
+ .ai_speed = 10000,
+ .ispgl = 0,
+ .dachan = 2,
+ .dabits = 12,
+ }, {
+ .name = "dt2829",
+ .adbits = 16,
+ .adchan_se = 8,
+ .adchan_di = 0,
+ .ai_speed = 33250,
+ .ispgl = 0,
+ .dachan = 2,
+ .dabits = 16,
+ }, {
+ .name = "dt21-ez",
+ .adbits = 12,
+ .adchan_se = 16,
+ .adchan_di = 8,
+ .ai_speed = 10000,
+ .ispgl = 0,
+ .dachan = 2,
+ .dabits = 12,
+ }, {
+ .name = "dt23-ez",
+ .adbits = 16,
+ .adchan_se = 16,
+ .adchan_di = 8,
+ .ai_speed = 10000,
+ .ispgl = 0,
+ .dachan = 0,
+ .dabits = 0,
+ }, {
+ .name = "dt24-ez",
+ .adbits = 12,
+ .adchan_se = 16,
+ .adchan_di = 8,
+ .ai_speed = 10000,
+ .ispgl = 0,
+ .dachan = 0,
+ .dabits = 0,
+ }, {
+ .name = "dt24-ez-pgl",
+ .adbits = 12,
+ .adchan_se = 16,
+ .adchan_di = 8,
+ .ai_speed = 10000,
+ .ispgl = 1,
+ .dachan = 0,
+ .dabits = 0,
+ },
+};
- return 0;
-}
+static struct comedi_driver dt282x_driver = {
+ .driver_name = "dt282x",
+ .module = THIS_MODULE,
+ .attach = dt282x_attach,
+ .detach = dt282x_detach,
+ .board_name = &boardtypes[0].name,
+ .num_names = ARRAY_SIZE(boardtypes),
+ .offset = sizeof(struct dt282x_board),
+};
+module_comedi_driver(dt282x_driver);
MODULE_AUTHOR("Comedi http://www.comedi.org");
MODULE_DESCRIPTION("Comedi low-level driver");
diff --git a/drivers/staging/comedi/drivers/dt3000.c b/drivers/staging/comedi/drivers/dt3000.c
index 0a7979e52999..a6fe6c9be87e 100644
--- a/drivers/staging/comedi/drivers/dt3000.c
+++ b/drivers/staging/comedi/drivers/dt3000.c
@@ -63,8 +63,6 @@ AO commands are not supported.
#include "../comedidev.h"
#include <linux/delay.h>
-#include "comedi_pci.h"
-
#define PCI_VENDOR_ID_DT 0x1116
static const struct comedi_lrange range_dt3000_ai = { 4, {
@@ -161,22 +159,8 @@ static const struct dt3k_boardtype dt3k_boardtypes[] = {
},
};
-#define n_dt3k_boards sizeof(dt3k_boardtypes)/sizeof(struct dt3k_boardtype)
#define this_board ((const struct dt3k_boardtype *)dev->board_ptr)
-static DEFINE_PCI_DEVICE_TABLE(dt3k_pci_table) = {
- { PCI_DEVICE(PCI_VENDOR_ID_DT, 0x0022) },
- { PCI_DEVICE(PCI_VENDOR_ID_DT, 0x0027) },
- { PCI_DEVICE(PCI_VENDOR_ID_DT, 0x0023) },
- { PCI_DEVICE(PCI_VENDOR_ID_DT, 0x0024) },
- { PCI_DEVICE(PCI_VENDOR_ID_DT, 0x0028) },
- { PCI_DEVICE(PCI_VENDOR_ID_DT, 0x0025) },
- { PCI_DEVICE(PCI_VENDOR_ID_DT, 0x0026) },
- { 0 }
-};
-
-MODULE_DEVICE_TABLE(pci, dt3k_pci_table);
-
#define DT3000_SIZE (4*0x1000)
/* dual-ported RAM location definitions */
@@ -264,10 +248,7 @@ MODULE_DEVICE_TABLE(pci, dt3k_pci_table);
#define DT3000_CHANNEL_MODE_DI 1
struct dt3k_private {
-
- struct pci_dev *pci_dev;
- resource_size_t phys_addr;
- void *io_addr;
+ void __iomem *io_addr;
unsigned int lock;
unsigned int ao_readback[2];
unsigned int ai_front;
@@ -276,54 +257,6 @@ struct dt3k_private {
#define devpriv ((struct dt3k_private *)dev->private)
-static int dt3000_attach(struct comedi_device *dev,
- struct comedi_devconfig *it);
-static int dt3000_detach(struct comedi_device *dev);
-static struct comedi_driver driver_dt3000 = {
- .driver_name = "dt3000",
- .module = THIS_MODULE,
- .attach = dt3000_attach,
- .detach = dt3000_detach,
-};
-
-static int __devinit driver_dt3000_pci_probe(struct pci_dev *dev,
- const struct pci_device_id *ent)
-{
- return comedi_pci_auto_config(dev, driver_dt3000.driver_name);
-}
-
-static void __devexit driver_dt3000_pci_remove(struct pci_dev *dev)
-{
- comedi_pci_auto_unconfig(dev);
-}
-
-static struct pci_driver driver_dt3000_pci_driver = {
- .id_table = dt3k_pci_table,
- .probe = &driver_dt3000_pci_probe,
- .remove = __devexit_p(&driver_dt3000_pci_remove)
-};
-
-static int __init driver_dt3000_init_module(void)
-{
- int retval;
-
- retval = comedi_driver_register(&driver_dt3000);
- if (retval < 0)
- return retval;
-
- driver_dt3000_pci_driver.name = (char *)driver_dt3000.driver_name;
- return pci_register_driver(&driver_dt3000_pci_driver);
-}
-
-static void __exit driver_dt3000_cleanup_module(void)
-{
- pci_unregister_driver(&driver_dt3000_pci_driver);
- comedi_driver_unregister(&driver_dt3000);
-}
-
-module_init(driver_dt3000_init_module);
-module_exit(driver_dt3000_cleanup_module);
-
static void dt3k_ai_empty_fifo(struct comedi_device *dev,
struct comedi_subdevice *s);
static int dt3k_ns_to_timer(unsigned int timer_base, unsigned int *arg,
@@ -352,7 +285,7 @@ static int dt3k_send_cmd(struct comedi_device *dev, unsigned int cmd)
if ((status & DT3000_COMPLETION_MASK) == DT3000_NOERROR)
return 0;
- dev_dbg(dev->hw_dev, "dt3k_send_cmd() timeout/error status=0x%04x\n",
+ dev_dbg(dev->class_dev, "dt3k_send_cmd() timeout/error status=0x%04x\n",
status);
return -ETIME;
@@ -453,7 +386,7 @@ static void dt3k_ai_empty_fifo(struct comedi_device *dev,
if (count < 0)
count += AI_FIFO_DEPTH;
- dev_dbg(dev->hw_dev, "reading %d samples\n", count);
+ dev_dbg(dev->class_dev, "reading %d samples\n", count);
rear = devpriv->ai_rear;
@@ -641,7 +574,7 @@ static int dt3k_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
int ret;
unsigned int mode;
- dev_dbg(dev->hw_dev, "dt3k_ai_cmd:\n");
+ dev_dbg(dev->class_dev, "dt3k_ai_cmd:\n");
for (i = 0; i < cmd->chanlist_len; i++) {
chan = CR_CHAN(cmd->chanlist[i]);
range = CR_RANGE(cmd->chanlist[i]);
@@ -652,15 +585,15 @@ static int dt3k_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
aref = CR_AREF(cmd->chanlist[0]);
writew(cmd->scan_end_arg, devpriv->io_addr + DPR_Params(0));
- dev_dbg(dev->hw_dev, "param[0]=0x%04x\n", cmd->scan_end_arg);
+ dev_dbg(dev->class_dev, "param[0]=0x%04x\n", cmd->scan_end_arg);
if (cmd->convert_src == TRIG_TIMER) {
divider = dt3k_ns_to_timer(50, &cmd->convert_arg,
cmd->flags & TRIG_ROUND_MASK);
writew((divider >> 16), devpriv->io_addr + DPR_Params(1));
- dev_dbg(dev->hw_dev, "param[1]=0x%04x\n", divider >> 16);
+ dev_dbg(dev->class_dev, "param[1]=0x%04x\n", divider >> 16);
writew((divider & 0xffff), devpriv->io_addr + DPR_Params(2));
- dev_dbg(dev->hw_dev, "param[2]=0x%04x\n", divider & 0xffff);
+ dev_dbg(dev->class_dev, "param[2]=0x%04x\n", divider & 0xffff);
} else {
/* not supported */
}
@@ -669,21 +602,21 @@ static int dt3k_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
tscandiv = dt3k_ns_to_timer(100, &cmd->scan_begin_arg,
cmd->flags & TRIG_ROUND_MASK);
writew((tscandiv >> 16), devpriv->io_addr + DPR_Params(3));
- dev_dbg(dev->hw_dev, "param[3]=0x%04x\n", tscandiv >> 16);
+ dev_dbg(dev->class_dev, "param[3]=0x%04x\n", tscandiv >> 16);
writew((tscandiv & 0xffff), devpriv->io_addr + DPR_Params(4));
- dev_dbg(dev->hw_dev, "param[4]=0x%04x\n", tscandiv & 0xffff);
+ dev_dbg(dev->class_dev, "param[4]=0x%04x\n", tscandiv & 0xffff);
} else {
/* not supported */
}
mode = DT3000_AD_RETRIG_INTERNAL | 0 | 0;
writew(mode, devpriv->io_addr + DPR_Params(5));
- dev_dbg(dev->hw_dev, "param[5]=0x%04x\n", mode);
+ dev_dbg(dev->class_dev, "param[5]=0x%04x\n", mode);
writew(aref == AREF_DIFF, devpriv->io_addr + DPR_Params(6));
- dev_dbg(dev->hw_dev, "param[6]=0x%04x\n", aref == AREF_DIFF);
+ dev_dbg(dev->class_dev, "param[6]=0x%04x\n", aref == AREF_DIFF);
writew(AI_FIFO_DEPTH / 2, devpriv->io_addr + DPR_Params(7));
- dev_dbg(dev->hw_dev, "param[7]=0x%04x\n", AI_FIFO_DEPTH / 2);
+ dev_dbg(dev->class_dev, "param[7]=0x%04x\n", AI_FIFO_DEPTH / 2);
writew(SUBS_AI, devpriv->io_addr + DPR_SubSys);
ret = dt3k_send_cmd(dev, CMD_CONFIG);
@@ -808,9 +741,6 @@ static int dt3k_dio_insn_bits(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
- if (insn->n != 2)
- return -EINVAL;
-
if (data[0]) {
s->state &= ~data[0];
s->state |= data[1] & data[0];
@@ -818,7 +748,7 @@ static int dt3k_dio_insn_bits(struct comedi_device *dev,
}
data[1] = dt3k_readsingle(dev, SUBS_DIN, 0, 0);
- return 2;
+ return insn->n;
}
static int dt3k_mem_insn_read(struct comedi_device *dev,
@@ -841,42 +771,73 @@ static int dt3k_mem_insn_read(struct comedi_device *dev,
return i;
}
-static int dt_pci_probe(struct comedi_device *dev, int bus, int slot);
+static struct pci_dev *dt3000_find_pci_dev(struct comedi_device *dev,
+ struct comedi_devconfig *it)
+{
+ struct pci_dev *pcidev = NULL;
+ int bus = it->options[0];
+ int slot = it->options[1];
+ int i;
+
+ for_each_pci_dev(pcidev) {
+ if (bus || slot) {
+ if (bus != pcidev->bus->number ||
+ slot != PCI_SLOT(pcidev->devfn))
+ continue;
+ }
+ if (pcidev->vendor != PCI_VENDOR_ID_DT)
+ continue;
+ for (i = 0; i < ARRAY_SIZE(dt3k_boardtypes); i++) {
+ if (dt3k_boardtypes[i].device_id != pcidev->device)
+ continue;
+ dev->board_ptr = dt3k_boardtypes + i;
+ return pcidev;
+ }
+ }
+ dev_err(dev->class_dev,
+ "No supported board found! (req. bus %d, slot %d)\n",
+ bus, slot);
+ return NULL;
+}
static int dt3000_attach(struct comedi_device *dev, struct comedi_devconfig *it)
{
+ struct pci_dev *pcidev;
struct comedi_subdevice *s;
- int bus, slot;
int ret = 0;
- dev_dbg(dev->hw_dev, "dt3000:\n");
- bus = it->options[0];
- slot = it->options[1];
+ dev_dbg(dev->class_dev, "dt3000:\n");
ret = alloc_private(dev, sizeof(struct dt3k_private));
if (ret < 0)
return ret;
- ret = dt_pci_probe(dev, bus, slot);
+ pcidev = dt3000_find_pci_dev(dev, it);
+ if (!pcidev)
+ return -EIO;
+ comedi_set_hw_dev(dev, &pcidev->dev);
+
+ ret = comedi_pci_enable(pcidev, "dt3000");
if (ret < 0)
return ret;
- if (ret == 0) {
- dev_warn(dev->hw_dev, "no DT board found\n");
- return -ENODEV;
- }
+
+ dev->iobase = pci_resource_start(pcidev, 0);
+ devpriv->io_addr = ioremap(dev->iobase, DT3000_SIZE);
+ if (!devpriv->io_addr)
+ return -ENOMEM;
dev->board_name = this_board->name;
- if (request_irq(devpriv->pci_dev->irq, dt3k_interrupt, IRQF_SHARED,
+ if (request_irq(pcidev->irq, dt3k_interrupt, IRQF_SHARED,
"dt3000", dev)) {
- dev_err(dev->hw_dev, "unable to allocate IRQ %u\n",
- devpriv->pci_dev->irq);
+ dev_err(dev->class_dev, "unable to allocate IRQ %u\n",
+ pcidev->irq);
return -EINVAL;
}
- dev->irq = devpriv->pci_dev->irq;
+ dev->irq = pcidev->irq;
- ret = alloc_subdevices(dev, 4);
- if (ret < 0)
+ ret = comedi_alloc_subdevices(dev, 4);
+ if (ret)
return ret;
s = dev->subdevices;
@@ -935,99 +896,60 @@ static int dt3000_attach(struct comedi_device *dev, struct comedi_devconfig *it)
return 0;
}
-static int dt3000_detach(struct comedi_device *dev)
+static void dt3000_detach(struct comedi_device *dev)
{
+ struct pci_dev *pcidev = comedi_to_pci_dev(dev);
+
if (dev->irq)
free_irq(dev->irq, dev);
-
if (devpriv) {
- if (devpriv->pci_dev) {
- if (devpriv->phys_addr)
- comedi_pci_disable(devpriv->pci_dev);
- pci_dev_put(devpriv->pci_dev);
- }
if (devpriv->io_addr)
iounmap(devpriv->io_addr);
}
- /* XXX */
-
- return 0;
+ if (pcidev) {
+ if (dev->iobase)
+ comedi_pci_disable(pcidev);
+ pci_dev_put(pcidev);
+ }
}
-static struct pci_dev *dt_pci_find_device(struct pci_dev *from, int *board);
-static int setup_pci(struct comedi_device *dev);
+static struct comedi_driver dt3000_driver = {
+ .driver_name = "dt3000",
+ .module = THIS_MODULE,
+ .attach = dt3000_attach,
+ .detach = dt3000_detach,
+};
-static int dt_pci_probe(struct comedi_device *dev, int bus, int slot)
+static int __devinit dt3000_pci_probe(struct pci_dev *dev,
+ const struct pci_device_id *ent)
{
- int board;
- int ret;
- struct pci_dev *pcidev;
-
- pcidev = NULL;
- while ((pcidev = dt_pci_find_device(pcidev, &board)) != NULL) {
- if ((bus == 0 && slot == 0) ||
- (pcidev->bus->number == bus &&
- PCI_SLOT(pcidev->devfn) == slot)) {
- break;
- }
- }
- devpriv->pci_dev = pcidev;
-
- if (board >= 0)
- dev->board_ptr = dt3k_boardtypes + board;
-
- if (!devpriv->pci_dev)
- return 0;
-
- ret = setup_pci(dev);
- if (ret < 0)
- return ret;
-
- return 1;
+ return comedi_pci_auto_config(dev, &dt3000_driver);
}
-static int setup_pci(struct comedi_device *dev)
+static void __devexit dt3000_pci_remove(struct pci_dev *dev)
{
- resource_size_t addr;
- int ret;
-
- ret = comedi_pci_enable(devpriv->pci_dev, "dt3000");
- if (ret < 0)
- return ret;
-
- addr = pci_resource_start(devpriv->pci_dev, 0);
- devpriv->phys_addr = addr;
- devpriv->io_addr = ioremap(devpriv->phys_addr, DT3000_SIZE);
- if (!devpriv->io_addr)
- return -ENOMEM;
-#if DEBUG
- printk("0x%08llx mapped to %p, ",
- (unsigned long long)devpriv->phys_addr, devpriv->io_addr);
-#endif
-
- return 0;
+ comedi_pci_auto_unconfig(dev);
}
-static struct pci_dev *dt_pci_find_device(struct pci_dev *from, int *board)
-{
- int i;
+static DEFINE_PCI_DEVICE_TABLE(dt3000_pci_table) = {
+ { PCI_DEVICE(PCI_VENDOR_ID_DT, 0x0022) },
+ { PCI_DEVICE(PCI_VENDOR_ID_DT, 0x0027) },
+ { PCI_DEVICE(PCI_VENDOR_ID_DT, 0x0023) },
+ { PCI_DEVICE(PCI_VENDOR_ID_DT, 0x0024) },
+ { PCI_DEVICE(PCI_VENDOR_ID_DT, 0x0028) },
+ { PCI_DEVICE(PCI_VENDOR_ID_DT, 0x0025) },
+ { PCI_DEVICE(PCI_VENDOR_ID_DT, 0x0026) },
+ { 0 }
+};
+MODULE_DEVICE_TABLE(pci, dt3000_pci_table);
- for (from = pci_get_device(PCI_VENDOR_ID_DT, PCI_ANY_ID, from);
- from != NULL;
- from = pci_get_device(PCI_VENDOR_ID_DT, PCI_ANY_ID, from)) {
- for (i = 0; i < n_dt3k_boards; i++) {
- if (from->device == dt3k_boardtypes[i].device_id) {
- *board = i;
- return from;
- }
- }
- printk
- ("unknown Data Translation PCI device found with device_id=0x%04x\n",
- from->device);
- }
- *board = -1;
- return from;
-}
+static struct pci_driver dt3000_pci_driver = {
+ .name = "dt3000",
+ .id_table = dt3000_pci_table,
+ .probe = dt3000_pci_probe,
+ .remove = __devexit_p(dt3000_pci_remove),
+};
+module_comedi_pci_driver(dt3000_driver, dt3000_pci_driver);
MODULE_AUTHOR("Comedi http://www.comedi.org");
MODULE_DESCRIPTION("Comedi low-level driver");
diff --git a/drivers/staging/comedi/drivers/dt9812.c b/drivers/staging/comedi/drivers/dt9812.c
index e86ab5862895..40821c7303ea 100644
--- a/drivers/staging/comedi/drivers/dt9812.c
+++ b/drivers/staging/comedi/drivers/dt9812.c
@@ -196,7 +196,7 @@ struct dt9812_flash_data {
};
#define DT9812_MAX_NUM_MULTI_BYTE_RDS \
- ((DT9812_MAX_WRITE_CMD_PIPE_SIZE - 4 - 1) / sizeof(u8))
+ ((DT9812_MAX_WRITE_CMD_PIPE_SIZE - 4 - 1) / sizeof(u8))
struct dt9812_read_multi {
u8 count;
@@ -209,8 +209,8 @@ struct dt9812_write_byte {
};
#define DT9812_MAX_NUM_MULTI_BYTE_WRTS \
- ((DT9812_MAX_WRITE_CMD_PIPE_SIZE - 4 - 1) / \
- sizeof(struct dt9812_write_byte))
+ ((DT9812_MAX_WRITE_CMD_PIPE_SIZE - 4 - 1) / \
+ sizeof(struct dt9812_write_byte))
struct dt9812_write_multi {
u8 count;
@@ -224,7 +224,8 @@ struct dt9812_rmw_byte {
};
#define DT9812_MAX_NUM_MULTI_BYTE_RMWS \
- ((DT9812_MAX_WRITE_CMD_PIPE_SIZE - 4 - 1) / sizeof(struct dt9812_rmw_byte))
+ ((DT9812_MAX_WRITE_CMD_PIPE_SIZE - 4 - 1) / \
+ sizeof(struct dt9812_rmw_byte))
struct dt9812_rmw_multi {
u8 count;
@@ -365,7 +366,7 @@ static int dt9812_read_info(struct usb_dt9812 *dev, int offset, void *buf,
}
static int dt9812_read_multiple_registers(struct usb_dt9812 *dev, int reg_count,
- u8 * address, u8 * value)
+ u8 *address, u8 *value)
{
struct dt9812_usb_cmd cmd;
int i, count, retval;
@@ -391,8 +392,8 @@ static int dt9812_read_multiple_registers(struct usb_dt9812 *dev, int reg_count,
}
static int dt9812_write_multiple_registers(struct usb_dt9812 *dev,
- int reg_count, u8 * address,
- u8 * value)
+ int reg_count, u8 *address,
+ u8 *value)
{
struct dt9812_usb_cmd cmd;
int i, count, retval;
@@ -430,7 +431,7 @@ static int dt9812_rmw_multiple_registers(struct usb_dt9812 *dev, int reg_count,
return retval;
}
-static int dt9812_digital_in(struct slot_dt9812 *slot, u8 * bits)
+static int dt9812_digital_in(struct slot_dt9812 *slot, u8 *bits)
{
int result = -ENODEV;
@@ -476,7 +477,7 @@ static int dt9812_digital_out(struct slot_dt9812 *slot, u8 bits)
return result;
}
-static int dt9812_digital_out_shadow(struct slot_dt9812 *slot, u8 * bits)
+static int dt9812_digital_out_shadow(struct slot_dt9812 *slot, u8 *bits)
{
int result = -ENODEV;
@@ -547,12 +548,12 @@ static void dt9812_configure_gain(struct usb_dt9812 *dev,
rmw->or_value = F020_MASK_ADC0CF_AMP0GN2;
break;
default:
- err("Illegal gain %d\n", gain);
+ dev_err(&dev->interface->dev, "Illegal gain %d\n", gain);
}
}
-static int dt9812_analog_in(struct slot_dt9812 *slot, int channel, u16 * value,
+static int dt9812_analog_in(struct slot_dt9812 *slot, int channel, u16 *value,
enum dt9812_gain gain)
{
struct dt9812_rmw_byte rmw[3];
@@ -619,7 +620,7 @@ exit:
}
static int dt9812_analog_out_shadow(struct slot_dt9812 *slot, int channel,
- u16 * value)
+ u16 *value)
{
int result = -ENODEV;
@@ -715,7 +716,7 @@ static int dt9812_probe(struct usb_interface *interface,
iface_desc = interface->cur_altsetting;
if (iface_desc->desc.bNumEndpoints != 5) {
- err("Wrong number of endpints.");
+ dev_err(&interface->dev, "Wrong number of endpoints.\n");
retval = -ENODEV;
goto error;
}
@@ -781,22 +782,22 @@ static int dt9812_probe(struct usb_interface *interface,
}
if (dt9812_read_info(dev, 1, &dev->vendor, sizeof(dev->vendor)) != 0) {
- err("Failed to read vendor.");
+ dev_err(&interface->dev, "Failed to read vendor.\n");
retval = -ENODEV;
goto error;
}
if (dt9812_read_info(dev, 3, &dev->product, sizeof(dev->product)) != 0) {
- err("Failed to read product.");
+ dev_err(&interface->dev, "Failed to read product.\n");
retval = -ENODEV;
goto error;
}
if (dt9812_read_info(dev, 5, &dev->device, sizeof(dev->device)) != 0) {
- err("Failed to read device.");
+ dev_err(&interface->dev, "Failed to read device.\n");
retval = -ENODEV;
goto error;
}
if (dt9812_read_info(dev, 7, &dev->serial, sizeof(dev->serial)) != 0) {
- err("Failed to read serial.");
+ dev_err(&interface->dev, "Failed to read serial.\n");
retval = -ENODEV;
goto error;
}
@@ -1020,6 +1021,7 @@ static int dt9812_attach(struct comedi_device *dev, struct comedi_devconfig *it)
{
int i;
struct comedi_subdevice *s;
+ int ret;
dev->board_name = "dt9812";
@@ -1034,9 +1036,9 @@ static int dt9812_attach(struct comedi_device *dev, struct comedi_devconfig *it)
devpriv->serial = it->options[0];
- /* Allocate subdevices */
- if (alloc_subdevices(dev, 4) < 0)
- return -ENOMEM;
+ ret = comedi_alloc_subdevices(dev, 4);
+ if (ret)
+ return ret;
/* digital input subdevice */
s = dev->subdevices + 0;
@@ -1110,9 +1112,9 @@ static int dt9812_attach(struct comedi_device *dev, struct comedi_devconfig *it)
return 0;
}
-static int dt9812_detach(struct comedi_device *dev)
+static void dt9812_detach(struct comedi_device *dev)
{
- return 0;
+ /* Nothing to cleanup */
}
static struct comedi_driver dt9812_comedi_driver = {
@@ -1146,7 +1148,9 @@ static int __init usb_dt9812_init(void)
result = comedi_driver_register(&dt9812_comedi_driver);
if (result) {
usb_deregister(&dt9812_usb_driver);
- err("comedi_driver_register failed. Error number %d", result);
+ printk(KERN_ERR KBUILD_MODNAME
+ ": comedi_driver_register failed. Error number %d\n",
+ result);
}
return result;
diff --git a/drivers/staging/comedi/drivers/dyna_pci10xx.c b/drivers/staging/comedi/drivers/dyna_pci10xx.c
index da8a2bf31657..064be9aae3aa 100644
--- a/drivers/staging/comedi/drivers/dyna_pci10xx.c
+++ b/drivers/staging/comedi/drivers/dyna_pci10xx.c
@@ -38,7 +38,6 @@
*/
#include "../comedidev.h"
-#include "comedi_pci.h"
#include <linux/mutex.h>
#define PCI_VENDOR_ID_DYNALOG 0x10b5
@@ -46,19 +45,6 @@
#define READ_TIMEOUT 50
-static DEFINE_MUTEX(start_stop_sem);
-
-static DEFINE_PCI_DEVICE_TABLE(dyna_pci10xx_pci_table) = {
- { PCI_DEVICE(PCI_VENDOR_ID_DYNALOG, 0x1050) },
- { 0 }
-};
-
-MODULE_DEVICE_TABLE(pci, dyna_pci10xx_pci_table);
-
-static int dyna_pci10xx_attach(struct comedi_device *dev,
- struct comedi_devconfig *it);
-static int dyna_pci10xx_detach(struct comedi_device *dev);
-
static const struct comedi_lrange range_pci1050_ai = { 3, {
BIP_RANGE(10),
BIP_RANGE(5),
@@ -113,23 +99,9 @@ static const struct boardtype boardtypes[] = {
{.name = DRV_NAME},
};
-static struct comedi_driver driver_dyna_pci10xx = {
- .driver_name = DRV_NAME,
- .module = THIS_MODULE,
- .attach = dyna_pci10xx_attach,
- .detach = dyna_pci10xx_detach,
- .board_name = &boardtypes[0].name,
- .offset = sizeof(struct boardtype),
- .num_names = ARRAY_SIZE(boardtypes),
-};
-
struct dyna_pci10xx_private {
- struct pci_dev *pci_dev; /* ptr to PCI device */
- char valid; /* card is usable */
struct mutex mutex;
-
- /* device base address registers */
- unsigned long BADR0, BADR1, BADR2, BADR3, BADR4, BADR5;
+ unsigned long BADR3;
};
#define thisboard ((const struct boardtype *)dev->board_ptr)
@@ -157,13 +129,13 @@ static int dyna_pci10xx_insn_read_ai(struct comedi_device *dev,
for (n = 0; n < insn->n; n++) {
/* trigger conversion */
smp_mb();
- outw_p(0x0000 + range + chan, devpriv->BADR2 + 2);
+ outw_p(0x0000 + range + chan, dev->iobase + 2);
udelay(10);
/* read data */
for (counter = 0; counter < READ_TIMEOUT; counter++) {
- d = inw_p(devpriv->BADR2);
+ d = inw_p(dev->iobase);
- /* check if read is successfull if the EOC bit is set */
+ /* check if read is successful if the EOC bit is set */
if (d & (1 << 15))
goto conv_finish;
}
@@ -197,7 +169,7 @@ static int dyna_pci10xx_insn_write_ao(struct comedi_device *dev,
for (n = 0; n < insn->n; n++) {
smp_mb();
/* trigger conversion and write data */
- outw_p(data[n], devpriv->BADR2);
+ outw_p(data[n], dev->iobase);
udelay(10);
}
mutex_unlock(&devpriv->mutex);
@@ -211,9 +183,6 @@ static int dyna_pci10xx_di_insn_bits(struct comedi_device *dev,
{
u16 d = 0;
- if (insn->n != 2)
- return -EINVAL;
-
mutex_lock(&devpriv->mutex);
smp_mb();
d = inw_p(devpriv->BADR3);
@@ -223,7 +192,7 @@ static int dyna_pci10xx_di_insn_bits(struct comedi_device *dev,
data[1] = d;
data[0] = s->state;
mutex_unlock(&devpriv->mutex);
- return 2;
+ return insn->n;
}
/* digital output bit interface */
@@ -231,9 +200,6 @@ static int dyna_pci10xx_do_insn_bits(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
- if (insn->n != 2)
- return -EINVAL;
-
/* The insn data is a mask in data[0] and the new data
* in data[1], each channel cooresponding to a bit.
* s->state contains the previous write data
@@ -254,109 +220,77 @@ static int dyna_pci10xx_do_insn_bits(struct comedi_device *dev,
*/
data[1] = s->state;
mutex_unlock(&devpriv->mutex);
- return 2;
+ return insn->n;
}
-/******************************************************************************/
-/*********************** INITIALIZATION FUNCTIONS *****************************/
-/******************************************************************************/
+static struct pci_dev *dyna_pci10xx_find_pci_dev(struct comedi_device *dev,
+ struct comedi_devconfig *it)
+{
+ struct pci_dev *pcidev = NULL;
+ int bus = it->options[0];
+ int slot = it->options[1];
+ int i;
+
+ for_each_pci_dev(pcidev) {
+ if (bus || slot) {
+ if (bus != pcidev->bus->number ||
+ slot != PCI_SLOT(pcidev->devfn))
+ continue;
+ }
+ if (pcidev->vendor != PCI_VENDOR_ID_DYNALOG)
+ continue;
+
+ for (i = 0; i < ARRAY_SIZE(boardtypes); ++i) {
+ if (pcidev->device != boardtypes[i].device_id)
+ continue;
+
+ dev->board_ptr = &boardtypes[i];
+ return pcidev;
+ }
+ }
+ dev_err(dev->class_dev,
+ "No supported board found! (req. bus %d, slot %d)\n",
+ bus, slot);
+ return NULL;
+}
static int dyna_pci10xx_attach(struct comedi_device *dev,
struct comedi_devconfig *it)
{
- struct comedi_subdevice *s;
struct pci_dev *pcidev;
- unsigned int opt_bus, opt_slot;
- int board_index, i;
-
- mutex_lock(&start_stop_sem);
+ struct comedi_subdevice *s;
+ int ret;
if (alloc_private(dev, sizeof(struct dyna_pci10xx_private)) < 0) {
printk(KERN_ERR "comedi: dyna_pci10xx: "
"failed to allocate memory!\n");
- mutex_unlock(&start_stop_sem);
return -ENOMEM;
}
- opt_bus = it->options[0];
- opt_slot = it->options[1];
+ pcidev = dyna_pci10xx_find_pci_dev(dev, it);
+ if (!pcidev)
+ return -EIO;
+ comedi_set_hw_dev(dev, &pcidev->dev);
+
dev->board_name = thisboard->name;
dev->irq = 0;
- /*
- * Probe the PCI bus and located the matching device
- */
- for (pcidev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, NULL);
- pcidev != NULL;
- pcidev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, pcidev)) {
-
- board_index = -1;
- for (i = 0; i < ARRAY_SIZE(boardtypes); ++i) {
- if ((pcidev->vendor == PCI_VENDOR_ID_DYNALOG) &&
- (pcidev->device == boardtypes[i].device_id)) {
- board_index = i;
- break;
- }
- }
- if (board_index < 0)
- continue;
-
- /* Found matching vendor/device. */
- if (opt_bus || opt_slot) {
- /* Check bus/slot. */
- if (opt_bus != pcidev->bus->number
- || opt_slot != PCI_SLOT(pcidev->devfn))
- continue; /* no match */
- }
-
- goto found;
- }
- printk(KERN_ERR "comedi: dyna_pci10xx: no supported device found!\n");
- mutex_unlock(&start_stop_sem);
- return -EIO;
-
-found:
-
- if (!pcidev) {
- if (opt_bus || opt_slot) {
- printk(KERN_ERR "comedi: dyna_pci10xx: "
- "invalid PCI device at b:s %d:%d\n",
- opt_bus, opt_slot);
- } else {
- printk(KERN_ERR "comedi: dyna_pci10xx: "
- "invalid PCI device\n");
- }
- mutex_unlock(&start_stop_sem);
- return -EIO;
- }
-
if (comedi_pci_enable(pcidev, DRV_NAME)) {
printk(KERN_ERR "comedi: dyna_pci10xx: "
"failed to enable PCI device and request regions!");
- mutex_unlock(&start_stop_sem);
return -EIO;
}
mutex_init(&devpriv->mutex);
- dev->board_ptr = &boardtypes[board_index];
- devpriv->pci_dev = pcidev;
printk(KERN_INFO "comedi: dyna_pci10xx: device found!\n");
- /* initialize device base address registers */
- devpriv->BADR0 = pci_resource_start(pcidev, 0);
- devpriv->BADR1 = pci_resource_start(pcidev, 1);
- devpriv->BADR2 = pci_resource_start(pcidev, 2);
+ dev->iobase = pci_resource_start(pcidev, 2);
devpriv->BADR3 = pci_resource_start(pcidev, 3);
- devpriv->BADR4 = pci_resource_start(pcidev, 4);
- devpriv->BADR5 = pci_resource_start(pcidev, 5);
- if (alloc_subdevices(dev, 4) < 0) {
- printk(KERN_ERR "comedi: dyna_pci10xx: "
- "failed allocating subdevices\n");
- mutex_unlock(&start_stop_sem);
- return -ENOMEM;
- }
+ ret = comedi_alloc_subdevices(dev, 4);
+ if (ret)
+ return ret;
/* analog input */
s = dev->subdevices + 0;
@@ -399,63 +333,59 @@ found:
s->state = 0;
s->insn_bits = dyna_pci10xx_do_insn_bits;
- devpriv->valid = 1;
- mutex_unlock(&start_stop_sem);
-
printk(KERN_INFO "comedi: dyna_pci10xx: %s - device setup completed!\n",
- boardtypes[board_index].name);
+ thisboard->name);
return 1;
}
-static int dyna_pci10xx_detach(struct comedi_device *dev)
+static void dyna_pci10xx_detach(struct comedi_device *dev)
{
- if (devpriv && devpriv->pci_dev) {
- comedi_pci_disable(devpriv->pci_dev);
+ struct pci_dev *pcidev = comedi_to_pci_dev(dev);
+
+ if (devpriv)
mutex_destroy(&devpriv->mutex);
+ if (pcidev) {
+ if (dev->iobase)
+ comedi_pci_disable(pcidev);
+ pci_dev_put(pcidev);
}
-
- return 0;
}
-static int __devinit driver_dyna_pci10xx_pci_probe(struct pci_dev *dev,
- const struct pci_device_id *ent)
+static struct comedi_driver dyna_pci10xx_driver = {
+ .driver_name = "dyna_pci10xx",
+ .module = THIS_MODULE,
+ .attach = dyna_pci10xx_attach,
+ .detach = dyna_pci10xx_detach,
+ .board_name = &boardtypes[0].name,
+ .offset = sizeof(struct boardtype),
+ .num_names = ARRAY_SIZE(boardtypes),
+};
+
+static int __devinit dyna_pci10xx_pci_probe(struct pci_dev *dev,
+ const struct pci_device_id *ent)
{
- return comedi_pci_auto_config(dev, driver_dyna_pci10xx.driver_name);
+ return comedi_pci_auto_config(dev, &dyna_pci10xx_driver);
}
-static void __devexit driver_dyna_pci10xx_pci_remove(struct pci_dev *dev)
+static void __devexit dyna_pci10xx_pci_remove(struct pci_dev *dev)
{
comedi_pci_auto_unconfig(dev);
}
-static struct pci_driver driver_dyna_pci10xx_pci_driver = {
- .id_table = dyna_pci10xx_pci_table,
- .probe = &driver_dyna_pci10xx_pci_probe,
- .remove = __devexit_p(&driver_dyna_pci10xx_pci_remove)
+static DEFINE_PCI_DEVICE_TABLE(dyna_pci10xx_pci_table) = {
+ { PCI_DEVICE(PCI_VENDOR_ID_DYNALOG, 0x1050) },
+ { 0 }
};
+MODULE_DEVICE_TABLE(pci, dyna_pci10xx_pci_table);
-static int __init driver_dyna_pci10xx_init_module(void)
-{
- int retval;
-
- retval = comedi_driver_register(&driver_dyna_pci10xx);
- if (retval < 0)
- return retval;
-
- driver_dyna_pci10xx_pci_driver.name =
- (char *)driver_dyna_pci10xx.driver_name;
- return pci_register_driver(&driver_dyna_pci10xx_pci_driver);
-}
-
-static void __exit driver_dyna_pci10xx_cleanup_module(void)
-{
- pci_unregister_driver(&driver_dyna_pci10xx_pci_driver);
- comedi_driver_unregister(&driver_dyna_pci10xx);
-}
-
-module_init(driver_dyna_pci10xx_init_module);
-module_exit(driver_dyna_pci10xx_cleanup_module);
+static struct pci_driver dyna_pci10xx_pci_driver = {
+ .name = "dyna_pci10xx",
+ .id_table = dyna_pci10xx_pci_table,
+ .probe = dyna_pci10xx_pci_probe,
+ .remove = __devexit_p(dyna_pci10xx_pci_remove),
+};
+module_comedi_pci_driver(dyna_pci10xx_driver, dyna_pci10xx_pci_driver);
MODULE_LICENSE("GPL");
MODULE_AUTHOR("Prashant Shah <pshah.mumbai@gmail.com>");
diff --git a/drivers/staging/comedi/drivers/fl512.c b/drivers/staging/comedi/drivers/fl512.c
index 7f49add60b21..d1da80976f84 100644
--- a/drivers/staging/comedi/drivers/fl512.c
+++ b/drivers/staging/comedi/drivers/fl512.c
@@ -42,38 +42,6 @@ static const struct comedi_lrange range_fl512 = { 4, {
}
};
-static int fl512_attach(struct comedi_device *dev, struct comedi_devconfig *it);
-static int fl512_detach(struct comedi_device *dev);
-
-static struct comedi_driver driver_fl512 = {
- .driver_name = "fl512",
- .module = THIS_MODULE,
- .attach = fl512_attach,
- .detach = fl512_detach,
-};
-
-static int __init driver_fl512_init_module(void)
-{
- return comedi_driver_register(&driver_fl512);
-}
-
-static void __exit driver_fl512_cleanup_module(void)
-{
- comedi_driver_unregister(&driver_fl512);
-}
-
-module_init(driver_fl512_init_module);
-module_exit(driver_fl512_cleanup_module);
-
-static int fl512_ai_insn(struct comedi_device *dev,
- struct comedi_subdevice *s, struct comedi_insn *insn,
- unsigned int *data);
-static int fl512_ao_insn(struct comedi_device *dev, struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data);
-static int fl512_ao_insn_readback(struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data);
-
/*
* fl512_ai_insn : this is the analog input function
*/
@@ -140,12 +108,10 @@ static int fl512_ao_insn_readback(struct comedi_device *dev,
return n;
}
-/*
- * start attach
- */
static int fl512_attach(struct comedi_device *dev, struct comedi_devconfig *it)
{
unsigned long iobase;
+ int ret;
/* pointer to the subdevice: Analog in, Analog out,
(not made ->and Digital IO) */
@@ -166,8 +132,9 @@ static int fl512_attach(struct comedi_device *dev, struct comedi_devconfig *it)
printk(KERN_DEBUG "malloc ok\n");
#endif
- if (alloc_subdevices(dev, 2) < 0)
- return -ENOMEM;
+ ret = comedi_alloc_subdevices(dev, 2);
+ if (ret)
+ return ret;
/*
* this if the definitions of the supdevices, 2 have been defined
@@ -209,14 +176,20 @@ static int fl512_attach(struct comedi_device *dev, struct comedi_devconfig *it)
return 1;
}
-static int fl512_detach(struct comedi_device *dev)
+static void fl512_detach(struct comedi_device *dev)
{
if (dev->iobase)
release_region(dev->iobase, FL512_SIZE);
- printk(KERN_INFO "comedi%d: fl512: dummy i detach\n", dev->minor);
- return 0;
}
+static struct comedi_driver fl512_driver = {
+ .driver_name = "fl512",
+ .module = THIS_MODULE,
+ .attach = fl512_attach,
+ .detach = fl512_detach,
+};
+module_comedi_driver(fl512_driver);
+
MODULE_AUTHOR("Comedi http://www.comedi.org");
MODULE_DESCRIPTION("Comedi low-level driver");
MODULE_LICENSE("GPL");
diff --git a/drivers/staging/comedi/drivers/gsc_hpdi.c b/drivers/staging/comedi/drivers/gsc_hpdi.c
index bc020dea141b..79f580841dee 100644
--- a/drivers/staging/comedi/drivers/gsc_hpdi.c
+++ b/drivers/staging/comedi/drivers/gsc_hpdi.c
@@ -49,12 +49,9 @@ support could be added to this driver.
#include "../comedidev.h"
#include <linux/delay.h>
-#include "comedi_pci.h"
#include "plx9080.h"
#include "comedi_fc.h"
-static int hpdi_attach(struct comedi_device *dev, struct comedi_devconfig *it);
-static int hpdi_detach(struct comedi_device *dev);
static void abort_dma(struct comedi_device *dev, unsigned int channel);
static int hpdi_cmd(struct comedi_device *dev, struct comedi_subdevice *s);
static int hpdi_cmd_test(struct comedi_device *dev, struct comedi_subdevice *s,
@@ -287,15 +284,6 @@ static const struct hpdi_board hpdi_boards[] = {
#endif
};
-static DEFINE_PCI_DEVICE_TABLE(hpdi_pci_table) = {
- {
- PCI_VENDOR_ID_PLX, PCI_DEVICE_ID_PLX_9080, PCI_VENDOR_ID_PLX,
- 0x2400, 0, 0, 0}, {
- 0}
-};
-
-MODULE_DEVICE_TABLE(pci, hpdi_pci_table);
-
static inline struct hpdi_board *board(const struct comedi_device *dev)
{
return (struct hpdi_board *)dev->board_ptr;
@@ -308,8 +296,8 @@ struct hpdi_private {
resource_size_t plx9080_phys_iobase;
resource_size_t hpdi_phys_iobase;
/* base addresses (ioremapped) */
- void *plx9080_iobase;
- void *hpdi_iobase;
+ void __iomem *plx9080_iobase;
+ void __iomem *hpdi_iobase;
uint32_t *dio_buffer[NUM_DMA_BUFFERS]; /* dma buffers */
/* physical addresses of dma buffers */
dma_addr_t dio_buffer_phys_addr[NUM_DMA_BUFFERS];
@@ -338,51 +326,6 @@ static inline struct hpdi_private *priv(struct comedi_device *dev)
return dev->private;
}
-static struct comedi_driver driver_hpdi = {
- .driver_name = "gsc_hpdi",
- .module = THIS_MODULE,
- .attach = hpdi_attach,
- .detach = hpdi_detach,
-};
-
-static int __devinit driver_hpdi_pci_probe(struct pci_dev *dev,
- const struct pci_device_id *ent)
-{
- return comedi_pci_auto_config(dev, driver_hpdi.driver_name);
-}
-
-static void __devexit driver_hpdi_pci_remove(struct pci_dev *dev)
-{
- comedi_pci_auto_unconfig(dev);
-}
-
-static struct pci_driver driver_hpdi_pci_driver = {
- .id_table = hpdi_pci_table,
- .probe = &driver_hpdi_pci_probe,
- .remove = __devexit_p(&driver_hpdi_pci_remove)
-};
-
-static int __init driver_hpdi_init_module(void)
-{
- int retval;
-
- retval = comedi_driver_register(&driver_hpdi);
- if (retval < 0)
- return retval;
-
- driver_hpdi_pci_driver.name = (char *)driver_hpdi.driver_name;
- return pci_register_driver(&driver_hpdi_pci_driver);
-}
-
-static void __exit driver_hpdi_cleanup_module(void)
-{
- pci_unregister_driver(&driver_hpdi_pci_driver);
- comedi_driver_unregister(&driver_hpdi);
-}
-
-module_init(driver_hpdi_init_module);
-module_exit(driver_hpdi_cleanup_module);
-
static int dio_config_insn(struct comedi_device *dev,
struct comedi_subdevice *s, struct comedi_insn *insn,
unsigned int *data)
@@ -420,7 +363,7 @@ static void disable_plx_interrupts(struct comedi_device *dev)
static void init_plx9080(struct comedi_device *dev)
{
uint32_t bits;
- void *plx_iobase = priv(dev)->plx9080_iobase;
+ void __iomem *plx_iobase = priv(dev)->plx9080_iobase;
/* plx9080 dump */
DEBUG_PRINT(" plx interrupt status 0x%x\n",
@@ -487,9 +430,11 @@ static void init_plx9080(struct comedi_device *dev)
static int setup_subdevices(struct comedi_device *dev)
{
struct comedi_subdevice *s;
+ int ret;
- if (alloc_subdevices(dev, 1) < 0)
- return -ENOMEM;
+ ret = comedi_alloc_subdevices(dev, 1);
+ if (ret)
+ return ret;
s = dev->subdevices + 0;
/* analog input subdevice */
@@ -645,7 +590,7 @@ static int hpdi_attach(struct comedi_device *dev, struct comedi_devconfig *it)
"gsc_hpdi: found %s on bus %i, slot %i\n", board(dev)->name,
pcidev->bus->number, PCI_SLOT(pcidev->devfn));
- if (comedi_pci_enable(pcidev, driver_hpdi.driver_name)) {
+ if (comedi_pci_enable(pcidev, dev->driver->driver_name)) {
printk(KERN_WARNING
" failed enable PCI device and request regions\n");
return -EIO;
@@ -679,7 +624,7 @@ static int hpdi_attach(struct comedi_device *dev, struct comedi_devconfig *it)
/* get irq */
if (request_irq(pcidev->irq, handle_interrupt, IRQF_SHARED,
- driver_hpdi.driver_name, dev)) {
+ dev->driver->driver_name, dev)) {
printk(KERN_WARNING
" unable to allocate irq %u\n", pcidev->irq);
return -EINVAL;
@@ -688,7 +633,7 @@ static int hpdi_attach(struct comedi_device *dev, struct comedi_devconfig *it)
printk(KERN_WARNING " irq %u\n", dev->irq);
- /* alocate pci dma buffers */
+ /* allocate pci dma buffers */
for (i = 0; i < NUM_DMA_BUFFERS; i++) {
priv(dev)->dio_buffer[i] =
pci_alloc_consistent(priv(dev)->hw_dev, DMA_BUFFER_SIZE,
@@ -720,21 +665,19 @@ static int hpdi_attach(struct comedi_device *dev, struct comedi_devconfig *it)
return init_hpdi(dev);
}
-static int hpdi_detach(struct comedi_device *dev)
+static void hpdi_detach(struct comedi_device *dev)
{
unsigned int i;
- printk(KERN_WARNING "comedi%d: gsc_hpdi: remove\n", dev->minor);
-
if (dev->irq)
free_irq(dev->irq, dev);
if ((priv(dev)) && (priv(dev)->hw_dev)) {
if (priv(dev)->plx9080_iobase) {
disable_plx_interrupts(dev);
- iounmap((void *)priv(dev)->plx9080_iobase);
+ iounmap(priv(dev)->plx9080_iobase);
}
if (priv(dev)->hpdi_iobase)
- iounmap((void *)priv(dev)->hpdi_iobase);
+ iounmap(priv(dev)->hpdi_iobase);
/* free pci dma buffers */
for (i = 0; i < NUM_DMA_BUFFERS; i++) {
if (priv(dev)->dio_buffer[i])
@@ -758,7 +701,6 @@ static int hpdi_detach(struct comedi_device *dev)
comedi_pci_disable(priv(dev)->hw_dev);
pci_dev_put(priv(dev)->hw_dev);
}
- return 0;
}
static int dio_config_block_size(struct comedi_device *dev, unsigned int *data)
@@ -962,7 +904,7 @@ static void drain_dma_buffers(struct comedi_device *dev, unsigned int channel)
uint32_t next_transfer_addr;
int j;
int num_samples = 0;
- void *pci_addr_reg;
+ void __iomem *pci_addr_reg;
if (channel)
pci_addr_reg =
@@ -1113,6 +1055,39 @@ static int hpdi_cancel(struct comedi_device *dev, struct comedi_subdevice *s)
return 0;
}
+static struct comedi_driver gsc_hpdi_driver = {
+ .driver_name = "gsc_hpdi",
+ .module = THIS_MODULE,
+ .attach = hpdi_attach,
+ .detach = hpdi_detach,
+};
+
+static int __devinit gsc_hpdi_pci_probe(struct pci_dev *dev,
+ const struct pci_device_id *ent)
+{
+ return comedi_pci_auto_config(dev, &gsc_hpdi_driver);
+}
+
+static void __devexit gsc_hpdi_pci_remove(struct pci_dev *dev)
+{
+ comedi_pci_auto_unconfig(dev);
+}
+
+static DEFINE_PCI_DEVICE_TABLE(gsc_hpdi_pci_table) = {
+ { PCI_VENDOR_ID_PLX, PCI_DEVICE_ID_PLX_9080, PCI_VENDOR_ID_PLX,
+ 0x2400, 0, 0, 0},
+ { 0 }
+};
+MODULE_DEVICE_TABLE(pci, gsc_hpdi_pci_table);
+
+static struct pci_driver gsc_hpdi_pci_driver = {
+ .name = "gsc_hpdi",
+ .id_table = gsc_hpdi_pci_table,
+ .probe = gsc_hpdi_pci_probe,
+ .remove = __devexit_p(gsc_hpdi_pci_remove)
+};
+module_comedi_pci_driver(gsc_hpdi_driver, gsc_hpdi_pci_driver);
+
MODULE_AUTHOR("Comedi http://www.comedi.org");
MODULE_DESCRIPTION("Comedi low-level driver");
MODULE_LICENSE("GPL");
diff --git a/drivers/staging/comedi/drivers/icp_multi.c b/drivers/staging/comedi/drivers/icp_multi.c
index 126550f3c02b..b10ebdbc1f7e 100644
--- a/drivers/staging/comedi/drivers/icp_multi.c
+++ b/drivers/staging/comedi/drivers/icp_multi.c
@@ -121,15 +121,6 @@ static const char range_codes_analog[] = { 0x00, 0x20, 0x10, 0x30 };
/*
==============================================================================
- Forward declarations
-==============================================================================
-*/
-static int icp_multi_attach(struct comedi_device *dev,
- struct comedi_devconfig *it);
-static int icp_multi_detach(struct comedi_device *dev);
-
-/*
-==============================================================================
Data & Structure declarations
==============================================================================
*/
@@ -154,54 +145,10 @@ struct boardtype {
const struct comedi_lrange *rangelist_ao; /* rangelist for D/A */
};
-static const struct boardtype boardtypes[] = {
- {"icp_multi", /* Driver name */
- DEVICE_ID, /* PCI device ID */
- IORANGE_ICP_MULTI, /* I/O range length */
- 1, /* 1=Card supports interrupts */
- TYPE_ICP_MULTI, /* Card type = ICP MULTI */
- 16, /* Num of A/D channels */
- 8, /* Num of A/D channels in diff mode */
- 4, /* Num of D/A channels */
- 16, /* Num of digital inputs */
- 8, /* Num of digital outputs */
- 4, /* Num of counters */
- 0x0fff, /* Resolution of A/D */
- 0x0fff, /* Resolution of D/A */
- &range_analog, /* Rangelist for A/D */
- range_codes_analog, /* Range codes for programming */
- &range_analog}, /* Rangelist for D/A */
-};
-
-#define n_boardtypes (sizeof(boardtypes)/sizeof(struct boardtype))
-
-static struct comedi_driver driver_icp_multi = {
- .driver_name = "icp_multi",
- .module = THIS_MODULE,
- .attach = icp_multi_attach,
- .detach = icp_multi_detach,
- .num_names = n_boardtypes,
- .board_name = &boardtypes[0].name,
- .offset = sizeof(struct boardtype),
-};
-
-static int __init driver_icp_multi_init_module(void)
-{
- return comedi_driver_register(&driver_icp_multi);
-}
-
-static void __exit driver_icp_multi_cleanup_module(void)
-{
- comedi_driver_unregister(&driver_icp_multi);
-}
-
-module_init(driver_icp_multi_init_module);
-module_exit(driver_icp_multi_cleanup_module);
-
struct icp_multi_private {
struct pcilst_struct *card; /* pointer to card */
char valid; /* card is usable */
- void *io_addr; /* Pointer to mapped io address */
+ void __iomem *io_addr; /* Pointer to mapped io address */
resource_size_t phys_iobase; /* Physical io address */
unsigned int AdcCmdStatus; /* ADC Command/Status register */
unsigned int DacCmdStatus; /* DAC Command/Status register */
@@ -222,25 +169,81 @@ struct icp_multi_private {
/*
==============================================================================
- More forward declarations
+
+Name: setup_channel_list
+
+Description:
+ This function sets the appropriate channel selection,
+ differential input mode and range bits in the ADC Command/
+ Status register.
+
+Parameters:
+ struct comedi_device *dev Pointer to current service structure
+ struct comedi_subdevice *s Pointer to current subdevice structure
+ unsigned int *chanlist Pointer to packed channel list
+ unsigned int n_chan Number of channels to scan
+
+Returns:Void
+
==============================================================================
*/
-
-#if 0
-static int check_channel_list(struct comedi_device *dev,
- struct comedi_subdevice *s,
- unsigned int *chanlist, unsigned int n_chan);
-#endif
static void setup_channel_list(struct comedi_device *dev,
struct comedi_subdevice *s,
- unsigned int *chanlist, unsigned int n_chan);
-static int icp_multi_reset(struct comedi_device *dev);
+ unsigned int *chanlist, unsigned int n_chan)
+{
+ unsigned int i, range, chanprog;
+ unsigned int diff;
-/*
-==============================================================================
- Functions
-==============================================================================
-*/
+#ifdef ICP_MULTI_EXTDEBUG
+ printk(KERN_DEBUG
+ "icp multi EDBG: setup_channel_list(...,%d)\n", n_chan);
+#endif
+ devpriv->act_chanlist_len = n_chan;
+ devpriv->act_chanlist_pos = 0;
+
+ for (i = 0; i < n_chan; i++) {
+ /* Get channel */
+ chanprog = CR_CHAN(chanlist[i]);
+
+ /* Determine if it is a differential channel (Bit 15 = 1) */
+ if (CR_AREF(chanlist[i]) == AREF_DIFF) {
+ diff = 1;
+ chanprog &= 0x0007;
+ } else {
+ diff = 0;
+ chanprog &= 0x000f;
+ }
+
+ /* Clear channel, range and input mode bits
+ * in A/D command/status register */
+ devpriv->AdcCmdStatus &= 0xf00f;
+
+ /* Set channel number and differential mode status bit */
+ if (diff) {
+ /* Set channel number, bits 9-11 & mode, bit 6 */
+ devpriv->AdcCmdStatus |= (chanprog << 9);
+ devpriv->AdcCmdStatus |= ADC_DI;
+ } else
+ /* Set channel number, bits 8-11 */
+ devpriv->AdcCmdStatus |= (chanprog << 8);
+
+ /* Get range for current channel */
+ range = this_board->rangecode[CR_RANGE(chanlist[i])];
+ /* Set range. bits 4-5 */
+ devpriv->AdcCmdStatus |= range;
+
+ /* Output channel, range, mode to ICP Multi */
+ writew(devpriv->AdcCmdStatus,
+ devpriv->io_addr + ICP_MULTI_ADC_CSR);
+
+#ifdef ICP_MULTI_EXTDEBUG
+ printk(KERN_DEBUG
+ "GS: %2d. [%4x]=%4x %4x\n", i, chanprog, range,
+ devpriv->act_chanlist[i]);
+#endif
+ }
+
+}
/*
==============================================================================
@@ -539,7 +542,7 @@ static int icp_multi_insn_bits_di(struct comedi_device *dev,
{
data[1] = readw(devpriv->io_addr + ICP_MULTI_DI);
- return 2;
+ return insn->n;
}
/*
@@ -582,7 +585,7 @@ static int icp_multi_insn_bits_do(struct comedi_device *dev,
#ifdef ICP_MULTI_EXTDEBUG
printk(KERN_DEBUG "icp multi EDBG: END: icp_multi_insn_bits_do(...)\n");
#endif
- return 2;
+ return insn->n;
}
/*
@@ -764,84 +767,6 @@ static int check_channel_list(struct comedi_device *dev,
/*
==============================================================================
-Name: setup_channel_list
-
-Description:
- This function sets the appropriate channel selection,
- differential input mode and range bits in the ADC Command/
- Status register.
-
-Parameters:
- struct comedi_device *dev Pointer to current service structure
- struct comedi_subdevice *s Pointer to current subdevice structure
- unsigned int *chanlist Pointer to packed channel list
- unsigned int n_chan Number of channels to scan
-
-Returns:Void
-
-==============================================================================
-*/
-static void setup_channel_list(struct comedi_device *dev,
- struct comedi_subdevice *s,
- unsigned int *chanlist, unsigned int n_chan)
-{
- unsigned int i, range, chanprog;
- unsigned int diff;
-
-#ifdef ICP_MULTI_EXTDEBUG
- printk(KERN_DEBUG
- "icp multi EDBG: setup_channel_list(...,%d)\n", n_chan);
-#endif
- devpriv->act_chanlist_len = n_chan;
- devpriv->act_chanlist_pos = 0;
-
- for (i = 0; i < n_chan; i++) {
- /* Get channel */
- chanprog = CR_CHAN(chanlist[i]);
-
- /* Determine if it is a differential channel (Bit 15 = 1) */
- if (CR_AREF(chanlist[i]) == AREF_DIFF) {
- diff = 1;
- chanprog &= 0x0007;
- } else {
- diff = 0;
- chanprog &= 0x000f;
- }
-
- /* Clear channel, range and input mode bits
- * in A/D command/status register */
- devpriv->AdcCmdStatus &= 0xf00f;
-
- /* Set channel number and differential mode status bit */
- if (diff) {
- /* Set channel number, bits 9-11 & mode, bit 6 */
- devpriv->AdcCmdStatus |= (chanprog << 9);
- devpriv->AdcCmdStatus |= ADC_DI;
- } else
- /* Set channel number, bits 8-11 */
- devpriv->AdcCmdStatus |= (chanprog << 8);
-
- /* Get range for current channel */
- range = this_board->rangecode[CR_RANGE(chanlist[i])];
- /* Set range. bits 4-5 */
- devpriv->AdcCmdStatus |= range;
-
- /* Output channel, range, mode to ICP Multi */
- writew(devpriv->AdcCmdStatus,
- devpriv->io_addr + ICP_MULTI_ADC_CSR);
-
-#ifdef ICP_MULTI_EXTDEBUG
- printk(KERN_DEBUG
- "GS: %2d. [%4x]=%4x %4x\n", i, chanprog, range,
- devpriv->act_chanlist[i]);
-#endif
- }
-
-}
-
-/*
-==============================================================================
-
Name: icp_multi_reset
Description:
@@ -897,23 +822,6 @@ static int icp_multi_reset(struct comedi_device *dev)
return 0;
}
-/*
-==============================================================================
-
-Name: icp_multi_attach
-
-Description:
- This function sets up all the appropriate data for the current
- device.
-
-Parameters:
- struct comedi_device *dev Pointer to current device structure
- struct comedi_devconfig *it Pointer to current device configuration
-
-Returns:int 0 = success
-
-==============================================================================
-*/
static int icp_multi_attach(struct comedi_device *dev,
struct comedi_devconfig *it)
{
@@ -927,7 +835,7 @@ static int icp_multi_attach(struct comedi_device *dev,
printk(KERN_WARNING
"icp_multi EDBG: BGN: icp_multi_attach(...)\n");
- /* Alocate private data storage space */
+ /* Allocate private data storage space */
ret = alloc_private(dev, sizeof(struct icp_multi_private));
if (ret < 0)
return ret;
@@ -995,8 +903,8 @@ static int icp_multi_attach(struct comedi_device *dev,
if (this_board->n_ctrs)
n_subdevices++;
- ret = alloc_subdevices(dev, n_subdevices);
- if (ret < 0)
+ ret = comedi_alloc_subdevices(dev, n_subdevices);
+ if (ret)
return ret;
icp_multi_reset(dev);
@@ -1099,44 +1007,53 @@ static int icp_multi_attach(struct comedi_device *dev,
return 0;
}
-/*
-==============================================================================
-
-Name: icp_multi_detach
-
-Description:
- This function releases all the resources used by the current
- device.
-
-Parameters:
- struct comedi_device *dev Pointer to current device structure
-
-Returns:int 0 = success
-
-==============================================================================
-*/
-static int icp_multi_detach(struct comedi_device *dev)
+static void icp_multi_detach(struct comedi_device *dev)
{
-
if (dev->private)
if (devpriv->valid)
icp_multi_reset(dev);
-
if (dev->irq)
free_irq(dev->irq, dev);
-
if (dev->private && devpriv->io_addr)
iounmap(devpriv->io_addr);
-
if (dev->private && devpriv->card)
pci_card_free(devpriv->card);
-
if (--pci_list_builded == 0)
pci_card_list_cleanup(PCI_VENDOR_ID_ICP);
-
- return 0;
}
+static const struct boardtype boardtypes[] = {
+ {
+ .name = "icp_multi",
+ .device_id = DEVICE_ID,
+ .iorange = IORANGE_ICP_MULTI,
+ .have_irq = 1,
+ .cardtype = TYPE_ICP_MULTI,
+ .n_aichan = 16,
+ .n_aichand = 8,
+ .n_aochan = 4,
+ .n_dichan = 16,
+ .n_dochan = 8,
+ .n_ctrs = 4,
+ .ai_maxdata = 0x0fff,
+ .ao_maxdata = 0x0fff,
+ .rangelist_ai = &range_analog,
+ .rangecode = range_codes_analog,
+ .rangelist_ao = &range_analog,
+ },
+};
+
+static struct comedi_driver icp_multi_driver = {
+ .driver_name = "icp_multi",
+ .module = THIS_MODULE,
+ .attach = icp_multi_attach,
+ .detach = icp_multi_detach,
+ .num_names = ARRAY_SIZE(boardtypes),
+ .board_name = &boardtypes[0].name,
+ .offset = sizeof(struct boardtype),
+};
+module_comedi_driver(icp_multi_driver);
+
MODULE_AUTHOR("Comedi http://www.comedi.org");
MODULE_DESCRIPTION("Comedi low-level driver");
MODULE_LICENSE("GPL");
diff --git a/drivers/staging/comedi/drivers/icp_multi.h b/drivers/staging/comedi/drivers/icp_multi.h
index 68acefe16888..dbf9908cfde6 100644
--- a/drivers/staging/comedi/drivers/icp_multi.h
+++ b/drivers/staging/comedi/drivers/icp_multi.h
@@ -11,7 +11,6 @@
#define _ICP_MULTI_H_
#include "../comedidev.h"
-#include "comedi_pci.h"
/****************************************************************************/
diff --git a/drivers/staging/comedi/drivers/ii_pci20kc.c b/drivers/staging/comedi/drivers/ii_pci20kc.c
index e4711ef54719..0f9cfe662b9a 100644
--- a/drivers/staging/comedi/drivers/ii_pci20kc.c
+++ b/drivers/staging/comedi/drivers/ii_pci20kc.c
@@ -135,15 +135,15 @@ options for PCI-20341M:
#define PCI20341_SCANLIST 0x80 /* Channel/Gain Scan List */
union pci20xxx_subdev_private {
- void *iobase;
+ void __iomem *iobase;
struct {
- void *iobase;
+ void __iomem *iobase;
const struct comedi_lrange *ao_range_list[2];
/* range of channels of ao module */
unsigned int last_data[2];
} pci20006;
struct {
- void *iobase;
+ void __iomem *iobase;
int timebase;
int settling_time;
int ai_gain;
@@ -152,24 +152,13 @@ union pci20xxx_subdev_private {
struct pci20xxx_private {
- void *ioaddr;
+ void __iomem *ioaddr;
union pci20xxx_subdev_private subdev_private[PCI20000_MODULES];
};
#define devpriv ((struct pci20xxx_private *)dev->private)
#define CHAN (CR_CHAN(it->chanlist[0]))
-static int pci20xxx_attach(struct comedi_device *dev,
- struct comedi_devconfig *it);
-static int pci20xxx_detach(struct comedi_device *dev);
-
-static struct comedi_driver driver_pci20xxx = {
- .driver_name = "ii_pci20kc",
- .module = THIS_MODULE,
- .attach = pci20xxx_attach,
- .detach = pci20xxx_detach,
-};
-
static int pci20006_init(struct comedi_device *dev, struct comedi_subdevice *s,
int opt0, int opt1);
static int pci20341_init(struct comedi_device *dev, struct comedi_subdevice *s,
@@ -213,15 +202,15 @@ static int pci20xxx_attach(struct comedi_device *dev,
struct comedi_subdevice *s;
union pci20xxx_subdev_private *sdp;
- ret = alloc_subdevices(dev, 1 + PCI20000_MODULES);
- if (ret < 0)
+ ret = comedi_alloc_subdevices(dev, 1 + PCI20000_MODULES);
+ if (ret)
return ret;
ret = alloc_private(dev, sizeof(struct pci20xxx_private));
if (ret < 0)
return ret;
- devpriv->ioaddr = (void *)(unsigned long)it->options[0];
+ devpriv->ioaddr = (void __iomem *)(unsigned long)it->options[0];
dev->board_name = "pci20kc";
/* Check PCI-20001 C-2A Carrier Board ID */
@@ -275,11 +264,9 @@ static int pci20xxx_attach(struct comedi_device *dev,
return 1;
}
-static int pci20xxx_detach(struct comedi_device *dev)
+static void pci20xxx_detach(struct comedi_device *dev)
{
- printk(KERN_INFO "comedi%d: pci20xxx: remove\n", dev->minor);
-
- return 0;
+ /* Nothing to cleanup */
}
/* pci20006m */
@@ -578,7 +565,7 @@ static int pci20xxx_dio_insn_bits(struct comedi_device *dev,
data[1] |= readb(devpriv->ioaddr + PCI20000_DIO_2) << 16;
data[1] |= readb(devpriv->ioaddr + PCI20000_DIO_3) << 24;
- return 2;
+ return insn->n;
}
static void pci20xxx_dio_config(struct comedi_device *dev,
@@ -666,18 +653,13 @@ static unsigned int pci20xxx_di(struct comedi_device *dev,
}
#endif
-static int __init driver_pci20xxx_init_module(void)
-{
- return comedi_driver_register(&driver_pci20xxx);
-}
-
-static void __exit driver_pci20xxx_cleanup_module(void)
-{
- comedi_driver_unregister(&driver_pci20xxx);
-}
-
-module_init(driver_pci20xxx_init_module);
-module_exit(driver_pci20xxx_cleanup_module);
+static struct comedi_driver pci20xxx_driver = {
+ .driver_name = "ii_pci20kc",
+ .module = THIS_MODULE,
+ .attach = pci20xxx_attach,
+ .detach = pci20xxx_detach,
+};
+module_comedi_driver(pci20xxx_driver);
MODULE_AUTHOR("Comedi http://www.comedi.org");
MODULE_DESCRIPTION("Comedi low-level driver");
diff --git a/drivers/staging/comedi/drivers/jr3_pci.c b/drivers/staging/comedi/drivers/jr3_pci.c
index 6a79ba10630d..93f94cd7bae2 100644
--- a/drivers/staging/comedi/drivers/jr3_pci.c
+++ b/drivers/staging/comedi/drivers/jr3_pci.c
@@ -49,7 +49,6 @@ Devices: [JR3] PCI force sensor board (jr3_pci)
#include <linux/slab.h>
#include <linux/timer.h>
#include <linux/kernel.h>
-#include "comedi_pci.h"
#include "jr3_pci.h"
#define PCI_VENDOR_ID_JR3 0x1762
@@ -59,28 +58,6 @@ Devices: [JR3] PCI force sensor board (jr3_pci)
#define PCI_DEVICE_ID_JR3_3_CHANNEL 0x3113
#define PCI_DEVICE_ID_JR3_4_CHANNEL 0x3114
-static int jr3_pci_attach(struct comedi_device *dev,
- struct comedi_devconfig *it);
-static int jr3_pci_detach(struct comedi_device *dev);
-
-static struct comedi_driver driver_jr3_pci = {
- .driver_name = "jr3_pci",
- .module = THIS_MODULE,
- .attach = jr3_pci_attach,
- .detach = jr3_pci_detach,
-};
-
-static DEFINE_PCI_DEVICE_TABLE(jr3_pci_pci_table) = {
- { PCI_DEVICE(PCI_VENDOR_ID_JR3, PCI_DEVICE_ID_JR3_1_CHANNEL) },
- { PCI_DEVICE(PCI_VENDOR_ID_JR3, PCI_DEVICE_ID_JR3_1_CHANNEL_NEW) },
- { PCI_DEVICE(PCI_VENDOR_ID_JR3, PCI_DEVICE_ID_JR3_2_CHANNEL) },
- { PCI_DEVICE(PCI_VENDOR_ID_JR3, PCI_DEVICE_ID_JR3_3_CHANNEL) },
- { PCI_DEVICE(PCI_VENDOR_ID_JR3, PCI_DEVICE_ID_JR3_4_CHANNEL) },
- {0}
-};
-
-MODULE_DEVICE_TABLE(pci, jr3_pci_pci_table);
-
struct jr3_pci_dev_private {
struct pci_dev *pci_dev;
@@ -372,13 +349,13 @@ static int jr3_pci_open(struct comedi_device *dev)
int i;
struct jr3_pci_dev_private *devpriv = dev->private;
- dev_dbg(dev->hw_dev, "jr3_pci_open\n");
+ dev_dbg(dev->class_dev, "jr3_pci_open\n");
for (i = 0; i < devpriv->n_channels; i++) {
struct jr3_pci_subdev_private *p;
p = dev->subdevices[i].private;
if (p) {
- dev_dbg(dev->hw_dev, "serial: %p %d (%d)\n", p,
+ dev_dbg(dev->class_dev, "serial: %p %d (%d)\n", p,
p->serial_no, p->channel_no);
}
}
@@ -457,7 +434,8 @@ static int jr3_download_firmware(struct comedi_device *dev, const u8 * data,
break;
more = more
&& read_idm_word(data, size, &pos, &addr);
- dev_dbg(dev->hw_dev, "Loading#%d %4.4x bytes at %4.4x\n",
+ dev_dbg(dev->class_dev,
+ "Loading#%d %4.4x bytes at %4.4x\n",
i, count, addr);
while (more && count > 0) {
if (addr & 0x4000) {
@@ -777,7 +755,8 @@ static int jr3_pci_attach(struct comedi_device *dev,
opt_slot = it->options[1];
if (sizeof(struct jr3_channel) != 0xc00) {
- dev_err(dev->hw_dev, "sizeof(struct jr3_channel) = %x [expected %x]\n",
+ dev_err(dev->class_dev,
+ "sizeof(struct jr3_channel) = %x [expected %x]\n",
(unsigned)sizeof(struct jr3_channel), 0xc00);
return -EINVAL;
}
@@ -832,7 +811,7 @@ static int jr3_pci_attach(struct comedi_device *dev,
}
}
if (!card) {
- dev_err(dev->hw_dev, "no jr3_pci found\n");
+ dev_err(dev->class_dev, "no jr3_pci found\n");
return -EIO;
} else {
devpriv->pci_dev = card;
@@ -849,9 +828,9 @@ static int jr3_pci_attach(struct comedi_device *dev,
if (!devpriv->iobase)
return -ENOMEM;
- result = alloc_subdevices(dev, devpriv->n_channels);
- if (result < 0)
- goto out;
+ result = comedi_alloc_subdevices(dev, devpriv->n_channels);
+ if (result)
+ return result;
dev->open = jr3_pci_open;
for (i = 0; i < devpriv->n_channels; i++) {
@@ -867,7 +846,7 @@ static int jr3_pci_attach(struct comedi_device *dev,
p = dev->subdevices[i].private;
p->channel = &devpriv->iobase->channel[i].data;
- dev_dbg(dev->hw_dev, "p->channel %p %p (%tx)\n",
+ dev_dbg(dev->class_dev, "p->channel %p %p (%tx)\n",
p->channel, devpriv->iobase,
((char *)(p->channel) -
(char *)(devpriv->iobase)));
@@ -908,7 +887,7 @@ static int jr3_pci_attach(struct comedi_device *dev,
devpriv->iobase->channel[0].reset = 0;
result = comedi_load_firmware(dev, "jr3pci.idm", jr3_download_firmware);
- dev_dbg(dev->hw_dev, "Firmare load %d\n", result);
+ dev_dbg(dev->class_dev, "Firmare load %d\n", result);
if (result < 0)
goto out;
@@ -926,7 +905,7 @@ static int jr3_pci_attach(struct comedi_device *dev,
*/
msleep_interruptible(25);
for (i = 0; i < 0x18; i++) {
- dev_dbg(dev->hw_dev, "%c\n",
+ dev_dbg(dev->class_dev, "%c\n",
get_u16(&devpriv->iobase->channel[0].
data.copyright[i]) >> 8);
}
@@ -948,9 +927,7 @@ out:
return result;
}
-MODULE_FIRMWARE("comedi/jr3pci.idm");
-
-static int jr3_pci_detach(struct comedi_device *dev)
+static void jr3_pci_detach(struct comedi_device *dev)
{
int i;
struct jr3_pci_dev_private *devpriv = dev->private;
@@ -962,56 +939,52 @@ static int jr3_pci_detach(struct comedi_device *dev)
for (i = 0; i < devpriv->n_channels; i++)
kfree(dev->subdevices[i].private);
}
-
if (devpriv->iobase)
iounmap((void *)devpriv->iobase);
if (devpriv->pci_enabled)
comedi_pci_disable(devpriv->pci_dev);
-
if (devpriv->pci_dev)
pci_dev_put(devpriv->pci_dev);
}
- return 0;
}
-static int __devinit driver_jr3_pci_pci_probe(struct pci_dev *dev,
- const struct pci_device_id *ent)
+static struct comedi_driver jr3_pci_driver = {
+ .driver_name = "jr3_pci",
+ .module = THIS_MODULE,
+ .attach = jr3_pci_attach,
+ .detach = jr3_pci_detach,
+};
+
+static int __devinit jr3_pci_pci_probe(struct pci_dev *dev,
+ const struct pci_device_id *ent)
{
- return comedi_pci_auto_config(dev, driver_jr3_pci.driver_name);
+ return comedi_pci_auto_config(dev, &jr3_pci_driver);
}
-static void __devexit driver_jr3_pci_pci_remove(struct pci_dev *dev)
+static void __devexit jr3_pci_pci_remove(struct pci_dev *dev)
{
comedi_pci_auto_unconfig(dev);
}
-static struct pci_driver driver_jr3_pci_pci_driver = {
- .id_table = jr3_pci_pci_table,
- .probe = &driver_jr3_pci_pci_probe,
- .remove = __devexit_p(&driver_jr3_pci_pci_remove)
+static DEFINE_PCI_DEVICE_TABLE(jr3_pci_pci_table) = {
+ { PCI_DEVICE(PCI_VENDOR_ID_JR3, PCI_DEVICE_ID_JR3_1_CHANNEL) },
+ { PCI_DEVICE(PCI_VENDOR_ID_JR3, PCI_DEVICE_ID_JR3_1_CHANNEL_NEW) },
+ { PCI_DEVICE(PCI_VENDOR_ID_JR3, PCI_DEVICE_ID_JR3_2_CHANNEL) },
+ { PCI_DEVICE(PCI_VENDOR_ID_JR3, PCI_DEVICE_ID_JR3_3_CHANNEL) },
+ { PCI_DEVICE(PCI_VENDOR_ID_JR3, PCI_DEVICE_ID_JR3_4_CHANNEL) },
+ { 0 }
};
+MODULE_DEVICE_TABLE(pci, jr3_pci_pci_table);
-static int __init driver_jr3_pci_init_module(void)
-{
- int retval;
-
- retval = comedi_driver_register(&driver_jr3_pci);
- if (retval < 0)
- return retval;
-
- driver_jr3_pci_pci_driver.name = (char *)driver_jr3_pci.driver_name;
- return pci_register_driver(&driver_jr3_pci_pci_driver);
-}
-
-static void __exit driver_jr3_pci_cleanup_module(void)
-{
- pci_unregister_driver(&driver_jr3_pci_pci_driver);
- comedi_driver_unregister(&driver_jr3_pci);
-}
-
-module_init(driver_jr3_pci_init_module);
-module_exit(driver_jr3_pci_cleanup_module);
+static struct pci_driver jr3_pci_pci_driver = {
+ .name = "jr3_pci",
+ .id_table = jr3_pci_pci_table,
+ .probe = jr3_pci_pci_probe,
+ .remove = __devexit_p(jr3_pci_pci_remove),
+};
+module_comedi_pci_driver(jr3_pci_driver, jr3_pci_pci_driver);
MODULE_AUTHOR("Comedi http://www.comedi.org");
MODULE_DESCRIPTION("Comedi low-level driver");
MODULE_LICENSE("GPL");
+MODULE_FIRMWARE("comedi/jr3pci.idm");
diff --git a/drivers/staging/comedi/drivers/ke_counter.c b/drivers/staging/comedi/drivers/ke_counter.c
index 4e9e9a078652..d4e9292483a0 100644
--- a/drivers/staging/comedi/drivers/ke_counter.c
+++ b/drivers/staging/comedi/drivers/ke_counter.c
@@ -40,24 +40,10 @@ Kolter Electronic PCI Counter Card.
#include "../comedidev.h"
-#include "comedi_pci.h"
-
#define CNT_DRIVER_NAME "ke_counter"
#define PCI_VENDOR_ID_KOLTER 0x1001
#define CNT_CARD_DEVICE_ID 0x0014
-/*-- function prototypes ----------------------------------------------------*/
-
-static int cnt_attach(struct comedi_device *dev, struct comedi_devconfig *it);
-static int cnt_detach(struct comedi_device *dev);
-
-static DEFINE_PCI_DEVICE_TABLE(cnt_pci_table) = {
- { PCI_DEVICE(PCI_VENDOR_ID_KOLTER, CNT_CARD_DEVICE_ID) },
- {0}
-};
-
-MODULE_DEVICE_TABLE(pci, cnt_pci_table);
-
/*-- board specification structure ------------------------------------------*/
struct cnt_board_struct {
@@ -76,62 +62,6 @@ static const struct cnt_board_struct cnt_boards[] = {
.cnt_bits = 24}
};
-#define cnt_board_nbr (sizeof(cnt_boards)/sizeof(struct cnt_board_struct))
-
-/*-- device private structure -----------------------------------------------*/
-
-struct cnt_device_private {
-
- struct pci_dev *pcidev;
-};
-
-#define devpriv ((struct cnt_device_private *)dev->private)
-
-static struct comedi_driver cnt_driver = {
- .driver_name = CNT_DRIVER_NAME,
- .module = THIS_MODULE,
- .attach = cnt_attach,
- .detach = cnt_detach,
-};
-
-static int __devinit cnt_driver_pci_probe(struct pci_dev *dev,
- const struct pci_device_id *ent)
-{
- return comedi_pci_auto_config(dev, cnt_driver.driver_name);
-}
-
-static void __devexit cnt_driver_pci_remove(struct pci_dev *dev)
-{
- comedi_pci_auto_unconfig(dev);
-}
-
-static struct pci_driver cnt_driver_pci_driver = {
- .id_table = cnt_pci_table,
- .probe = &cnt_driver_pci_probe,
- .remove = __devexit_p(&cnt_driver_pci_remove)
-};
-
-static int __init cnt_driver_init_module(void)
-{
- int retval;
-
- retval = comedi_driver_register(&cnt_driver);
- if (retval < 0)
- return retval;
-
- cnt_driver_pci_driver.name = (char *)cnt_driver.driver_name;
- return pci_register_driver(&cnt_driver_pci_driver);
-}
-
-static void __exit cnt_driver_cleanup_module(void)
-{
- pci_unregister_driver(&cnt_driver_pci_driver);
- comedi_driver_unregister(&cnt_driver);
-}
-
-module_init(cnt_driver_init_module);
-module_exit(cnt_driver_cleanup_module);
-
/*-- counter write ----------------------------------------------------------*/
/* This should be used only for resetting the counters; maybe it is better
@@ -181,64 +111,58 @@ static int cnt_rinsn(struct comedi_device *dev,
return 1;
}
-/*-- attach -----------------------------------------------------------------*/
+static struct pci_dev *cnt_find_pci_dev(struct comedi_device *dev,
+ struct comedi_devconfig *it)
+{
+ const struct cnt_board_struct *board;
+ struct pci_dev *pcidev = NULL;
+ int bus = it->options[0];
+ int slot = it->options[1];
+ int i;
+
+ /* Probe the device to determine what device in the series it is. */
+ for_each_pci_dev(pcidev) {
+ if (bus || slot) {
+ if (pcidev->bus->number != bus ||
+ PCI_SLOT(pcidev->devfn) != slot)
+ continue;
+ }
+ if (pcidev->vendor != PCI_VENDOR_ID_KOLTER)
+ continue;
+
+ for (i = 0; i < ARRAY_SIZE(cnt_boards); i++) {
+ board = &cnt_boards[i];
+ if (board->device_id != pcidev->device)
+ continue;
+
+ dev->board_ptr = board;
+ return pcidev;
+ }
+ }
+ dev_err(dev->class_dev,
+ "No supported board found! (req. bus %d, slot %d)\n",
+ bus, slot);
+ return NULL;
+}
static int cnt_attach(struct comedi_device *dev, struct comedi_devconfig *it)
{
+ const struct cnt_board_struct *board;
+ struct pci_dev *pcidev;
struct comedi_subdevice *subdevice;
- struct pci_dev *pci_device = NULL;
- struct cnt_board_struct *board;
unsigned long io_base;
- int error, i;
+ int error;
- /* allocate device private structure */
- error = alloc_private(dev, sizeof(struct cnt_device_private));
- if (error < 0)
- return error;
+ pcidev = cnt_find_pci_dev(dev, it);
+ if (!pcidev)
+ return -EIO;
+ comedi_set_hw_dev(dev, &pcidev->dev);
+ board = comedi_board(dev);
- /* Probe the device to determine what device in the series it is. */
- for_each_pci_dev(pci_device) {
- if (pci_device->vendor == PCI_VENDOR_ID_KOLTER) {
- for (i = 0; i < cnt_board_nbr; i++) {
- if (cnt_boards[i].device_id ==
- pci_device->device) {
- /* was a particular bus/slot requested? */
- if ((it->options[0] != 0)
- || (it->options[1] != 0)) {
- /* are we on the wrong bus/slot? */
- if (pci_device->bus->number !=
- it->options[0]
- ||
- PCI_SLOT(pci_device->devfn)
- != it->options[1]) {
- continue;
- }
- }
-
- dev->board_ptr = cnt_boards + i;
- board =
- (struct cnt_board_struct *)
- dev->board_ptr;
- goto found;
- }
- }
- }
- }
- printk(KERN_WARNING
- "comedi%d: no supported board found! (req. bus/slot: %d/%d)\n",
- dev->minor, it->options[0], it->options[1]);
- return -EIO;
-
-found:
- printk(KERN_INFO
- "comedi%d: found %s at PCI bus %d, slot %d\n", dev->minor,
- board->name, pci_device->bus->number,
- PCI_SLOT(pci_device->devfn));
- devpriv->pcidev = pci_device;
dev->board_name = board->name;
/* enable PCI device and request regions */
- error = comedi_pci_enable(pci_device, CNT_DRIVER_NAME);
+ error = comedi_pci_enable(pcidev, CNT_DRIVER_NAME);
if (error < 0) {
printk(KERN_WARNING "comedi%d: "
"failed to enable PCI device and request regions!\n",
@@ -247,12 +171,11 @@ found:
}
/* read register base address [PCI_BASE_ADDRESS #0] */
- io_base = pci_resource_start(pci_device, 0);
+ io_base = pci_resource_start(pcidev, 0);
dev->iobase = io_base;
- /* allocate the subdevice structures */
- error = alloc_subdevices(dev, 1);
- if (error < 0)
+ error = comedi_alloc_subdevices(dev, 1);
+ if (error)
return error;
subdevice = dev->subdevices + 0;
@@ -278,20 +201,49 @@ found:
return 0;
}
-/*-- detach -----------------------------------------------------------------*/
-
-static int cnt_detach(struct comedi_device *dev)
+static void cnt_detach(struct comedi_device *dev)
{
- if (devpriv && devpriv->pcidev) {
+ struct pci_dev *pcidev = comedi_to_pci_dev(dev);
+
+ if (pcidev) {
if (dev->iobase)
- comedi_pci_disable(devpriv->pcidev);
- pci_dev_put(devpriv->pcidev);
+ comedi_pci_disable(pcidev);
+ pci_dev_put(pcidev);
}
- printk(KERN_INFO "comedi%d: " CNT_DRIVER_NAME " remove\n",
- dev->minor);
- return 0;
}
+static struct comedi_driver ke_counter_driver = {
+ .driver_name = "ke_counter",
+ .module = THIS_MODULE,
+ .attach = cnt_attach,
+ .detach = cnt_detach,
+};
+
+static int __devinit ke_counter_pci_probe(struct pci_dev *dev,
+ const struct pci_device_id *ent)
+{
+ return comedi_pci_auto_config(dev, &ke_counter_driver);
+}
+
+static void __devexit ke_counter_pci_remove(struct pci_dev *dev)
+{
+ comedi_pci_auto_unconfig(dev);
+}
+
+static DEFINE_PCI_DEVICE_TABLE(ke_counter_pci_table) = {
+ { PCI_DEVICE(PCI_VENDOR_ID_KOLTER, CNT_CARD_DEVICE_ID) },
+ { 0 }
+};
+MODULE_DEVICE_TABLE(pci, ke_counter_pci_table);
+
+static struct pci_driver ke_counter_pci_driver = {
+ .name = "ke_counter",
+ .id_table = ke_counter_pci_table,
+ .probe = ke_counter_pci_probe,
+ .remove = __devexit_p(ke_counter_pci_remove),
+};
+module_comedi_pci_driver(ke_counter_driver, ke_counter_pci_driver);
+
MODULE_AUTHOR("Comedi http://www.comedi.org");
MODULE_DESCRIPTION("Comedi low-level driver");
MODULE_LICENSE("GPL");
diff --git a/drivers/staging/comedi/drivers/me4000.c b/drivers/staging/comedi/drivers/me4000.c
index b0bc6bb877ab..9a8258e6fa45 100644
--- a/drivers/staging/comedi/drivers/me4000.c
+++ b/drivers/staging/comedi/drivers/me4000.c
@@ -58,37 +58,12 @@ broken.
#include <linux/list.h>
#include <linux/spinlock.h>
-#include "comedi_pci.h"
#include "me4000.h"
#if 0
/* file removed due to GPL incompatibility */
#include "me4000_fw.h"
#endif
-/*=============================================================================
- PCI device table.
- This is used by modprobe to translate PCI IDs to drivers.
- ===========================================================================*/
-
-static DEFINE_PCI_DEVICE_TABLE(me4000_pci_table) = {
- { PCI_DEVICE(PCI_VENDOR_ID_MEILHAUS, 0x4650) },
- { PCI_DEVICE(PCI_VENDOR_ID_MEILHAUS, 0x4660) },
- { PCI_DEVICE(PCI_VENDOR_ID_MEILHAUS, 0x4661) },
- { PCI_DEVICE(PCI_VENDOR_ID_MEILHAUS, 0x4662) },
- { PCI_DEVICE(PCI_VENDOR_ID_MEILHAUS, 0x4663) },
- { PCI_DEVICE(PCI_VENDOR_ID_MEILHAUS, 0x4670) },
- { PCI_DEVICE(PCI_VENDOR_ID_MEILHAUS, 0x4671) },
- { PCI_DEVICE(PCI_VENDOR_ID_MEILHAUS, 0x4672) },
- { PCI_DEVICE(PCI_VENDOR_ID_MEILHAUS, 0x4673) },
- { PCI_DEVICE(PCI_VENDOR_ID_MEILHAUS, 0x4680) },
- { PCI_DEVICE(PCI_VENDOR_ID_MEILHAUS, 0x4681) },
- { PCI_DEVICE(PCI_VENDOR_ID_MEILHAUS, 0x4682) },
- { PCI_DEVICE(PCI_VENDOR_ID_MEILHAUS, 0x4683) },
- { 0 }
-};
-
-MODULE_DEVICE_TABLE(pci, me4000_pci_table);
-
static const struct me4000_board me4000_boards[] = {
{"ME-4650", 0x4650, {0, 0}, {16, 0, 0, 0}, {4}, {0} },
@@ -113,22 +88,8 @@ static const struct me4000_board me4000_boards[] = {
#define ME4000_BOARD_VERSIONS (ARRAY_SIZE(me4000_boards) - 1)
/*-----------------------------------------------------------------------------
- Comedi function prototypes
- ---------------------------------------------------------------------------*/
-static int me4000_attach(struct comedi_device *dev,
- struct comedi_devconfig *it);
-static int me4000_detach(struct comedi_device *dev);
-static struct comedi_driver driver_me4000 = {
- .driver_name = "me4000",
- .module = THIS_MODULE,
- .attach = me4000_attach,
- .detach = me4000_detach,
-};
-
-/*-----------------------------------------------------------------------------
Meilhaus function prototypes
---------------------------------------------------------------------------*/
-static int me4000_probe(struct comedi_device *dev, struct comedi_devconfig *it);
static int get_registers(struct comedi_device *dev, struct pci_dev *pci_dev_p);
static int init_board_info(struct comedi_device *dev,
struct pci_dev *pci_dev_p);
@@ -139,112 +100,10 @@ static int init_cnt_context(struct comedi_device *dev);
static int xilinx_download(struct comedi_device *dev);
static int reset_board(struct comedi_device *dev);
-static int me4000_dio_insn_bits(struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data);
-
-static int me4000_dio_insn_config(struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data);
-
-static int cnt_reset(struct comedi_device *dev, unsigned int channel);
-
-static int cnt_config(struct comedi_device *dev,
- unsigned int channel, unsigned int mode);
-
-static int me4000_cnt_insn_config(struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data);
-
-static int me4000_cnt_insn_write(struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data);
-
-static int me4000_cnt_insn_read(struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data);
-
-static int me4000_ai_insn_read(struct comedi_device *dev,
- struct comedi_subdevice *subdevice,
- struct comedi_insn *insn, unsigned int *data);
-
-static int me4000_ai_cancel(struct comedi_device *dev,
- struct comedi_subdevice *s);
-
-static int ai_check_chanlist(struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_cmd *cmd);
-
-static int ai_round_cmd_args(struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_cmd *cmd,
- unsigned int *init_ticks,
- unsigned int *scan_ticks,
- unsigned int *chan_ticks);
-
-static int ai_prepare(struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_cmd *cmd,
- unsigned int init_ticks,
- unsigned int scan_ticks, unsigned int chan_ticks);
-
static int ai_write_chanlist(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_cmd *cmd);
-static irqreturn_t me4000_ai_isr(int irq, void *dev_id);
-
-static int me4000_ai_do_cmd_test(struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_cmd *cmd);
-
-static int me4000_ai_do_cmd(struct comedi_device *dev,
- struct comedi_subdevice *s);
-
-static int me4000_ao_insn_write(struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data);
-
-static int me4000_ao_insn_read(struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data);
-
-/*-----------------------------------------------------------------------------
- Meilhaus inline functions
- ---------------------------------------------------------------------------*/
-
-static inline void me4000_outb(struct comedi_device *dev, unsigned char value,
- unsigned long port)
-{
- PORT_PDEBUG("--> 0x%02X port 0x%04lX\n", value, port);
- outb(value, port);
-}
-
-static inline void me4000_outl(struct comedi_device *dev, unsigned long value,
- unsigned long port)
-{
- PORT_PDEBUG("--> 0x%08lX port 0x%04lX\n", value, port);
- outl(value, port);
-}
-
-static inline unsigned long me4000_inl(struct comedi_device *dev,
- unsigned long port)
-{
- unsigned long value;
- value = inl(port);
- PORT_PDEBUG("<-- 0x%08lX port 0x%04lX\n", value, port);
- return value;
-}
-
-static inline unsigned char me4000_inb(struct comedi_device *dev,
- unsigned long port)
-{
- unsigned char value;
- value = inb(port);
- PORT_PDEBUG("<-- 0x%08X port 0x%04lX\n", value, port);
- return value;
-}
-
static const struct comedi_lrange me4000_ai_range = {
4,
{
@@ -262,138 +121,12 @@ static const struct comedi_lrange me4000_ao_range = {
}
};
-static int me4000_attach(struct comedi_device *dev, struct comedi_devconfig *it)
-{
- struct comedi_subdevice *s;
- int result;
-
- CALL_PDEBUG("In me4000_attach()\n");
-
- result = me4000_probe(dev, it);
- if (result)
- return result;
-
- /*
- * Allocate the subdevice structures. alloc_subdevice() is a
- * convenient macro defined in comedidev.h. It relies on
- * n_subdevices being set correctly.
- */
- if (alloc_subdevices(dev, 4) < 0)
- return -ENOMEM;
-
- /*=========================================================================
- Analog input subdevice
- ========================================================================*/
-
- s = dev->subdevices + 0;
-
- if (thisboard->ai.count) {
- s->type = COMEDI_SUBD_AI;
- s->subdev_flags =
- SDF_READABLE | SDF_COMMON | SDF_GROUND | SDF_DIFF;
- s->n_chan = thisboard->ai.count;
- s->maxdata = 0xFFFF; /* 16 bit ADC */
- s->len_chanlist = ME4000_AI_CHANNEL_LIST_COUNT;
- s->range_table = &me4000_ai_range;
- s->insn_read = me4000_ai_insn_read;
-
- if (info->irq > 0) {
- if (request_irq(info->irq, me4000_ai_isr,
- IRQF_SHARED, "ME-4000", dev)) {
- printk
- ("comedi%d: me4000: me4000_attach(): "
- "Unable to allocate irq\n", dev->minor);
- } else {
- dev->read_subdev = s;
- s->subdev_flags |= SDF_CMD_READ;
- s->cancel = me4000_ai_cancel;
- s->do_cmdtest = me4000_ai_do_cmd_test;
- s->do_cmd = me4000_ai_do_cmd;
- }
- } else {
- printk(KERN_WARNING
- "comedi%d: me4000: me4000_attach(): "
- "No interrupt available\n", dev->minor);
- }
- } else {
- s->type = COMEDI_SUBD_UNUSED;
- }
-
- /*=========================================================================
- Analog output subdevice
- ========================================================================*/
-
- s = dev->subdevices + 1;
-
- if (thisboard->ao.count) {
- s->type = COMEDI_SUBD_AO;
- s->subdev_flags = SDF_WRITEABLE | SDF_COMMON | SDF_GROUND;
- s->n_chan = thisboard->ao.count;
- s->maxdata = 0xFFFF; /* 16 bit DAC */
- s->range_table = &me4000_ao_range;
- s->insn_write = me4000_ao_insn_write;
- s->insn_read = me4000_ao_insn_read;
- } else {
- s->type = COMEDI_SUBD_UNUSED;
- }
-
- /*=========================================================================
- Digital I/O subdevice
- ========================================================================*/
-
- s = dev->subdevices + 2;
-
- if (thisboard->dio.count) {
- s->type = COMEDI_SUBD_DIO;
- s->subdev_flags = SDF_READABLE | SDF_WRITABLE;
- s->n_chan = thisboard->dio.count * 8;
- s->maxdata = 1;
- s->range_table = &range_digital;
- s->insn_bits = me4000_dio_insn_bits;
- s->insn_config = me4000_dio_insn_config;
- } else {
- s->type = COMEDI_SUBD_UNUSED;
- }
-
- /*
- * Check for optoisolated ME-4000 version. If one the first
- * port is a fixed output port and the second is a fixed input port.
- */
- if (!me4000_inl(dev, info->dio_context.dir_reg)) {
- s->io_bits |= 0xFF;
- me4000_outl(dev, ME4000_DIO_CTRL_BIT_MODE_0,
- info->dio_context.dir_reg);
- }
-
- /*=========================================================================
- Counter subdevice
- ========================================================================*/
-
- s = dev->subdevices + 3;
-
- if (thisboard->cnt.count) {
- s->type = COMEDI_SUBD_COUNTER;
- s->subdev_flags = SDF_READABLE | SDF_WRITABLE;
- s->n_chan = thisboard->cnt.count;
- s->maxdata = 0xFFFF; /* 16 bit counters */
- s->insn_read = me4000_cnt_insn_read;
- s->insn_write = me4000_cnt_insn_write;
- s->insn_config = me4000_cnt_insn_config;
- } else {
- s->type = COMEDI_SUBD_UNUSED;
- }
-
- return 0;
-}
-
static int me4000_probe(struct comedi_device *dev, struct comedi_devconfig *it)
{
struct pci_dev *pci_device = NULL;
int result, i;
struct me4000_board *board;
- CALL_PDEBUG("In me4000_probe()\n");
-
/* Allocate private memory */
if (alloc_private(dev, sizeof(struct me4000_info)) < 0)
return -ENOMEM;
@@ -537,9 +270,6 @@ found:
static int get_registers(struct comedi_device *dev, struct pci_dev *pci_dev_p)
{
-
- CALL_PDEBUG("In get_registers()\n");
-
/*--------------------------- plx regbase -------------------------------*/
info->plx_regbase = pci_resource_start(pci_dev_p, 1);
@@ -591,8 +321,6 @@ static int init_board_info(struct comedi_device *dev, struct pci_dev *pci_dev_p)
{
int result;
- CALL_PDEBUG("In init_board_info()\n");
-
/* Init spin locks */
/* spin_lock_init(&info->preload_lock); */
/* spin_lock_init(&info->ai_ctrl_lock); */
@@ -623,8 +351,6 @@ static int init_ao_context(struct comedi_device *dev)
{
int i;
- CALL_PDEBUG("In init_ao_context()\n");
-
for (i = 0; i < thisboard->ao.count; i++) {
/* spin_lock_init(&info->ao_context[i].use_lock); */
info->ao_context[i].irq = info->irq;
@@ -704,9 +430,6 @@ static int init_ao_context(struct comedi_device *dev)
static int init_ai_context(struct comedi_device *dev)
{
-
- CALL_PDEBUG("In init_ai_context()\n");
-
info->ai_context.irq = info->irq;
info->ai_context.ctrl_reg = info->me4000_regbase + ME4000_AI_CTRL_REG;
@@ -738,9 +461,6 @@ static int init_ai_context(struct comedi_device *dev)
static int init_dio_context(struct comedi_device *dev)
{
-
- CALL_PDEBUG("In init_dio_context()\n");
-
info->dio_context.dir_reg = info->me4000_regbase + ME4000_DIO_DIR_REG;
info->dio_context.ctrl_reg = info->me4000_regbase + ME4000_DIO_CTRL_REG;
info->dio_context.port_0_reg =
@@ -757,9 +477,6 @@ static int init_dio_context(struct comedi_device *dev)
static int init_cnt_context(struct comedi_device *dev)
{
-
- CALL_PDEBUG("In init_cnt_context()\n");
-
info->cnt_context.ctrl_reg = info->timer_regbase + ME4000_CNT_CTRL_REG;
info->cnt_context.counter_0_reg =
info->timer_regbase + ME4000_CNT_COUNTER_0_REG;
@@ -783,8 +500,6 @@ static int xilinx_download(struct comedi_device *dev)
int idx = 0;
int size = 0;
- CALL_PDEBUG("In xilinx_download()\n");
-
init_waitqueue_head(&queue);
/*
@@ -863,75 +578,46 @@ static int reset_board(struct comedi_device *dev)
{
unsigned long icr;
- CALL_PDEBUG("In reset_board()\n");
-
/* Make a hardware reset */
- icr = me4000_inl(dev, info->plx_regbase + PLX_ICR);
+ icr = inl(info->plx_regbase + PLX_ICR);
icr |= 0x40000000;
- me4000_outl(dev, icr, info->plx_regbase + PLX_ICR);
+ outl(icr, info->plx_regbase + PLX_ICR);
icr &= ~0x40000000;
- me4000_outl(dev, icr, info->plx_regbase + PLX_ICR);
+ outl(icr, info->plx_regbase + PLX_ICR);
/* 0x8000 to the DACs means an output voltage of 0V */
- me4000_outl(dev, 0x8000,
- info->me4000_regbase + ME4000_AO_00_SINGLE_REG);
- me4000_outl(dev, 0x8000,
- info->me4000_regbase + ME4000_AO_01_SINGLE_REG);
- me4000_outl(dev, 0x8000,
- info->me4000_regbase + ME4000_AO_02_SINGLE_REG);
- me4000_outl(dev, 0x8000,
- info->me4000_regbase + ME4000_AO_03_SINGLE_REG);
+ outl(0x8000, info->me4000_regbase + ME4000_AO_00_SINGLE_REG);
+ outl(0x8000, info->me4000_regbase + ME4000_AO_01_SINGLE_REG);
+ outl(0x8000, info->me4000_regbase + ME4000_AO_02_SINGLE_REG);
+ outl(0x8000, info->me4000_regbase + ME4000_AO_03_SINGLE_REG);
/* Set both stop bits in the analog input control register */
- me4000_outl(dev,
- ME4000_AI_CTRL_BIT_IMMEDIATE_STOP | ME4000_AI_CTRL_BIT_STOP,
- info->me4000_regbase + ME4000_AI_CTRL_REG);
+ outl(ME4000_AI_CTRL_BIT_IMMEDIATE_STOP | ME4000_AI_CTRL_BIT_STOP,
+ info->me4000_regbase + ME4000_AI_CTRL_REG);
/* Set both stop bits in the analog output control register */
- me4000_outl(dev,
- ME4000_AO_CTRL_BIT_IMMEDIATE_STOP | ME4000_AO_CTRL_BIT_STOP,
- info->me4000_regbase + ME4000_AO_00_CTRL_REG);
- me4000_outl(dev,
- ME4000_AO_CTRL_BIT_IMMEDIATE_STOP | ME4000_AO_CTRL_BIT_STOP,
- info->me4000_regbase + ME4000_AO_01_CTRL_REG);
- me4000_outl(dev,
- ME4000_AO_CTRL_BIT_IMMEDIATE_STOP | ME4000_AO_CTRL_BIT_STOP,
- info->me4000_regbase + ME4000_AO_02_CTRL_REG);
- me4000_outl(dev,
- ME4000_AO_CTRL_BIT_IMMEDIATE_STOP | ME4000_AO_CTRL_BIT_STOP,
- info->me4000_regbase + ME4000_AO_03_CTRL_REG);
+ outl(ME4000_AO_CTRL_BIT_IMMEDIATE_STOP | ME4000_AO_CTRL_BIT_STOP,
+ info->me4000_regbase + ME4000_AO_00_CTRL_REG);
+ outl(ME4000_AO_CTRL_BIT_IMMEDIATE_STOP | ME4000_AO_CTRL_BIT_STOP,
+ info->me4000_regbase + ME4000_AO_01_CTRL_REG);
+ outl(ME4000_AO_CTRL_BIT_IMMEDIATE_STOP | ME4000_AO_CTRL_BIT_STOP,
+ info->me4000_regbase + ME4000_AO_02_CTRL_REG);
+ outl(ME4000_AO_CTRL_BIT_IMMEDIATE_STOP | ME4000_AO_CTRL_BIT_STOP,
+ info->me4000_regbase + ME4000_AO_03_CTRL_REG);
/* Enable interrupts on the PLX */
- me4000_outl(dev, 0x43, info->plx_regbase + PLX_INTCSR);
+ outl(0x43, info->plx_regbase + PLX_INTCSR);
/* Set the adustment register for AO demux */
- me4000_outl(dev, ME4000_AO_DEMUX_ADJUST_VALUE,
+ outl(ME4000_AO_DEMUX_ADJUST_VALUE,
info->me4000_regbase + ME4000_AO_DEMUX_ADJUST_REG);
/*
* Set digital I/O direction for port 0
* to output on isolated versions
*/
- if (!(me4000_inl(dev, info->me4000_regbase + ME4000_DIO_DIR_REG) & 0x1)) {
- me4000_outl(dev, 0x1,
- info->me4000_regbase + ME4000_DIO_CTRL_REG);
- }
-
- return 0;
-}
-
-static int me4000_detach(struct comedi_device *dev)
-{
- CALL_PDEBUG("In me4000_detach()\n");
-
- if (info) {
- if (info->pci_dev_p) {
- reset_board(dev);
- if (info->plx_regbase)
- comedi_pci_disable(info->pci_dev_p);
- pci_dev_put(info->pci_dev_p);
- }
- }
+ if (!(inl(info->me4000_regbase + ME4000_DIO_DIR_REG) & 0x1))
+ outl(0x1, info->me4000_regbase + ME4000_DIO_CTRL_REG);
return 0;
}
@@ -953,8 +639,6 @@ static int me4000_ai_insn_read(struct comedi_device *dev,
unsigned long tmp;
long lval;
- CALL_PDEBUG("In me4000_ai_insn_read()\n");
-
if (insn->n == 0) {
return 0;
} else if (insn->n > 1) {
@@ -1023,36 +707,34 @@ static int me4000_ai_insn_read(struct comedi_device *dev,
entry |= ME4000_AI_LIST_LAST_ENTRY;
/* Clear channel list, data fifo and both stop bits */
- tmp = me4000_inl(dev, info->ai_context.ctrl_reg);
+ tmp = inl(info->ai_context.ctrl_reg);
tmp &= ~(ME4000_AI_CTRL_BIT_CHANNEL_FIFO |
ME4000_AI_CTRL_BIT_DATA_FIFO |
ME4000_AI_CTRL_BIT_STOP | ME4000_AI_CTRL_BIT_IMMEDIATE_STOP);
- me4000_outl(dev, tmp, info->ai_context.ctrl_reg);
+ outl(tmp, info->ai_context.ctrl_reg);
/* Set the acquisition mode to single */
tmp &= ~(ME4000_AI_CTRL_BIT_MODE_0 | ME4000_AI_CTRL_BIT_MODE_1 |
ME4000_AI_CTRL_BIT_MODE_2);
- me4000_outl(dev, tmp, info->ai_context.ctrl_reg);
+ outl(tmp, info->ai_context.ctrl_reg);
/* Enable channel list and data fifo */
tmp |= ME4000_AI_CTRL_BIT_CHANNEL_FIFO | ME4000_AI_CTRL_BIT_DATA_FIFO;
- me4000_outl(dev, tmp, info->ai_context.ctrl_reg);
+ outl(tmp, info->ai_context.ctrl_reg);
/* Generate channel list entry */
- me4000_outl(dev, entry, info->ai_context.channel_list_reg);
+ outl(entry, info->ai_context.channel_list_reg);
/* Set the timer to maximum sample rate */
- me4000_outl(dev, ME4000_AI_MIN_TICKS, info->ai_context.chan_timer_reg);
- me4000_outl(dev, ME4000_AI_MIN_TICKS,
- info->ai_context.chan_pre_timer_reg);
+ outl(ME4000_AI_MIN_TICKS, info->ai_context.chan_timer_reg);
+ outl(ME4000_AI_MIN_TICKS, info->ai_context.chan_pre_timer_reg);
/* Start conversion by dummy read */
- me4000_inl(dev, info->ai_context.start_reg);
+ inl(info->ai_context.start_reg);
/* Wait until ready */
udelay(10);
- if (!
- (me4000_inl(dev, info->ai_context.status_reg) &
+ if (!(inl(info->ai_context.status_reg) &
ME4000_AI_STATUS_BIT_EF_DATA)) {
printk(KERN_ERR
"comedi%d: me4000: me4000_ai_insn_read(): "
@@ -1061,7 +743,7 @@ static int me4000_ai_insn_read(struct comedi_device *dev,
}
/* Read value from data fifo */
- lval = me4000_inl(dev, info->ai_context.data_reg) & 0xFFFF;
+ lval = inl(info->ai_context.data_reg) & 0xFFFF;
data[0] = lval ^ 0x8000;
return 1;
@@ -1072,15 +754,13 @@ static int me4000_ai_cancel(struct comedi_device *dev,
{
unsigned long tmp;
- CALL_PDEBUG("In me4000_ai_cancel()\n");
-
/* Stop any running conversion */
- tmp = me4000_inl(dev, info->ai_context.ctrl_reg);
+ tmp = inl(info->ai_context.ctrl_reg);
tmp &= ~(ME4000_AI_CTRL_BIT_STOP | ME4000_AI_CTRL_BIT_IMMEDIATE_STOP);
- me4000_outl(dev, tmp, info->ai_context.ctrl_reg);
+ outl(tmp, info->ai_context.ctrl_reg);
/* Clear the control register */
- me4000_outl(dev, 0x0, info->ai_context.ctrl_reg);
+ outl(0x0, info->ai_context.ctrl_reg);
return 0;
}
@@ -1091,8 +771,6 @@ static int ai_check_chanlist(struct comedi_device *dev,
int aref;
int i;
- CALL_PDEBUG("In ai_check_chanlist()\n");
-
/* Check whether a channel list is available */
if (!cmd->chanlist_len) {
printk(KERN_ERR
@@ -1178,25 +856,18 @@ static int ai_round_cmd_args(struct comedi_device *dev,
int rest;
- CALL_PDEBUG("In ai_round_cmd_args()\n");
-
*init_ticks = 0;
*scan_ticks = 0;
*chan_ticks = 0;
- PDEBUG("ai_round_cmd_arg(): start_arg = %d\n", cmd->start_arg);
- PDEBUG("ai_round_cmd_arg(): scan_begin_arg = %d\n",
- cmd->scan_begin_arg);
- PDEBUG("ai_round_cmd_arg(): convert_arg = %d\n", cmd->convert_arg);
-
if (cmd->start_arg) {
*init_ticks = (cmd->start_arg * 33) / 1000;
rest = (cmd->start_arg * 33) % 1000;
- if (cmd->flags & TRIG_ROUND_NEAREST) {
+ if ((cmd->flags & TRIG_ROUND_MASK) == TRIG_ROUND_NEAREST) {
if (rest > 33)
(*init_ticks)++;
- } else if (cmd->flags & TRIG_ROUND_UP) {
+ } else if ((cmd->flags & TRIG_ROUND_MASK) == TRIG_ROUND_UP) {
if (rest)
(*init_ticks)++;
}
@@ -1206,10 +877,10 @@ static int ai_round_cmd_args(struct comedi_device *dev,
*scan_ticks = (cmd->scan_begin_arg * 33) / 1000;
rest = (cmd->scan_begin_arg * 33) % 1000;
- if (cmd->flags & TRIG_ROUND_NEAREST) {
+ if ((cmd->flags & TRIG_ROUND_MASK) == TRIG_ROUND_NEAREST) {
if (rest > 33)
(*scan_ticks)++;
- } else if (cmd->flags & TRIG_ROUND_UP) {
+ } else if ((cmd->flags & TRIG_ROUND_MASK) == TRIG_ROUND_UP) {
if (rest)
(*scan_ticks)++;
}
@@ -1219,19 +890,15 @@ static int ai_round_cmd_args(struct comedi_device *dev,
*chan_ticks = (cmd->convert_arg * 33) / 1000;
rest = (cmd->convert_arg * 33) % 1000;
- if (cmd->flags & TRIG_ROUND_NEAREST) {
+ if ((cmd->flags & TRIG_ROUND_MASK) == TRIG_ROUND_NEAREST) {
if (rest > 33)
(*chan_ticks)++;
- } else if (cmd->flags & TRIG_ROUND_UP) {
+ } else if ((cmd->flags & TRIG_ROUND_MASK) == TRIG_ROUND_UP) {
if (rest)
(*chan_ticks)++;
}
}
- PDEBUG("ai_round_cmd_args(): init_ticks = %d\n", *init_ticks);
- PDEBUG("ai_round_cmd_args(): scan_ticks = %d\n", *scan_ticks);
- PDEBUG("ai_round_cmd_args(): chan_ticks = %d\n", *chan_ticks);
-
return 0;
}
@@ -1239,21 +906,16 @@ static void ai_write_timer(struct comedi_device *dev,
unsigned int init_ticks,
unsigned int scan_ticks, unsigned int chan_ticks)
{
-
- CALL_PDEBUG("In ai_write_timer()\n");
-
- me4000_outl(dev, init_ticks - 1,
- info->ai_context.scan_pre_timer_low_reg);
- me4000_outl(dev, 0x0, info->ai_context.scan_pre_timer_high_reg);
+ outl(init_ticks - 1, info->ai_context.scan_pre_timer_low_reg);
+ outl(0x0, info->ai_context.scan_pre_timer_high_reg);
if (scan_ticks) {
- me4000_outl(dev, scan_ticks - 1,
- info->ai_context.scan_timer_low_reg);
- me4000_outl(dev, 0x0, info->ai_context.scan_timer_high_reg);
+ outl(scan_ticks - 1, info->ai_context.scan_timer_low_reg);
+ outl(0x0, info->ai_context.scan_timer_high_reg);
}
- me4000_outl(dev, chan_ticks - 1, info->ai_context.chan_pre_timer_reg);
- me4000_outl(dev, chan_ticks - 1, info->ai_context.chan_timer_reg);
+ outl(chan_ticks - 1, info->ai_context.chan_pre_timer_reg);
+ outl(chan_ticks - 1, info->ai_context.chan_timer_reg);
}
static int ai_prepare(struct comedi_device *dev,
@@ -1265,13 +927,11 @@ static int ai_prepare(struct comedi_device *dev,
unsigned long tmp = 0;
- CALL_PDEBUG("In ai_prepare()\n");
-
/* Write timer arguments */
ai_write_timer(dev, init_ticks, scan_ticks, chan_ticks);
/* Reset control register */
- me4000_outl(dev, tmp, info->ai_context.ctrl_reg);
+ outl(tmp, info->ai_context.ctrl_reg);
/* Start sources */
if ((cmd->start_src == TRIG_EXT &&
@@ -1304,12 +964,12 @@ static int ai_prepare(struct comedi_device *dev,
/* Stop triggers */
if (cmd->stop_src == TRIG_COUNT) {
- me4000_outl(dev, cmd->chanlist_len * cmd->stop_arg,
+ outl(cmd->chanlist_len * cmd->stop_arg,
info->ai_context.sample_counter_reg);
tmp |= ME4000_AI_CTRL_BIT_HF_IRQ | ME4000_AI_CTRL_BIT_SC_IRQ;
} else if (cmd->stop_src == TRIG_NONE &&
cmd->scan_end_src == TRIG_COUNT) {
- me4000_outl(dev, cmd->scan_end_arg,
+ outl(cmd->scan_end_arg,
info->ai_context.sample_counter_reg);
tmp |= ME4000_AI_CTRL_BIT_HF_IRQ | ME4000_AI_CTRL_BIT_SC_IRQ;
} else {
@@ -1317,7 +977,7 @@ static int ai_prepare(struct comedi_device *dev,
}
/* Write the setup to the control register */
- me4000_outl(dev, tmp, info->ai_context.ctrl_reg);
+ outl(tmp, info->ai_context.ctrl_reg);
/* Write the channel list */
ai_write_chanlist(dev, s, cmd);
@@ -1334,8 +994,6 @@ static int ai_write_chanlist(struct comedi_device *dev,
unsigned int aref;
int i;
- CALL_PDEBUG("In ai_write_chanlist()\n");
-
for (i = 0; i < cmd->chanlist_len; i++) {
chan = CR_CHAN(cmd->chanlist[i]);
rang = CR_RANGE(cmd->chanlist[i]);
@@ -1357,7 +1015,7 @@ static int ai_write_chanlist(struct comedi_device *dev,
else
entry |= ME4000_AI_LIST_INPUT_SINGLE_ENDED;
- me4000_outl(dev, entry, info->ai_context.channel_list_reg);
+ outl(entry, info->ai_context.channel_list_reg);
}
return 0;
@@ -1372,8 +1030,6 @@ static int me4000_ai_do_cmd(struct comedi_device *dev,
unsigned int chan_ticks = 0;
struct comedi_cmd *cmd = &s->async->cmd;
- CALL_PDEBUG("In me4000_ai_do_cmd()\n");
-
/* Reset the analog input */
err = me4000_ai_cancel(dev, s);
if (err)
@@ -1391,7 +1047,7 @@ static int me4000_ai_do_cmd(struct comedi_device *dev,
return err;
/* Start acquistion by dummy read */
- me4000_inl(dev, info->ai_context.start_reg);
+ inl(info->ai_context.start_reg);
return 0;
}
@@ -1418,34 +1074,6 @@ static int me4000_ai_do_cmd_test(struct comedi_device *dev,
unsigned int scan_ticks;
int err = 0;
- CALL_PDEBUG("In me4000_ai_do_cmd_test()\n");
-
- PDEBUG("me4000_ai_do_cmd_test(): subdev = %d\n", cmd->subdev);
- PDEBUG("me4000_ai_do_cmd_test(): flags = %08X\n", cmd->flags);
- PDEBUG("me4000_ai_do_cmd_test(): start_src = %08X\n",
- cmd->start_src);
- PDEBUG("me4000_ai_do_cmd_test(): start_arg = %d\n",
- cmd->start_arg);
- PDEBUG("me4000_ai_do_cmd_test(): scan_begin_src = %08X\n",
- cmd->scan_begin_src);
- PDEBUG("me4000_ai_do_cmd_test(): scan_begin_arg = %d\n",
- cmd->scan_begin_arg);
- PDEBUG("me4000_ai_do_cmd_test(): convert_src = %08X\n",
- cmd->convert_src);
- PDEBUG("me4000_ai_do_cmd_test(): convert_arg = %d\n",
- cmd->convert_arg);
- PDEBUG("me4000_ai_do_cmd_test(): scan_end_src = %08X\n",
- cmd->scan_end_src);
- PDEBUG("me4000_ai_do_cmd_test(): scan_end_arg = %d\n",
- cmd->scan_end_arg);
- PDEBUG("me4000_ai_do_cmd_test(): stop_src = %08X\n",
- cmd->stop_src);
- PDEBUG("me4000_ai_do_cmd_test(): stop_arg = %d\n", cmd->stop_arg);
- PDEBUG("me4000_ai_do_cmd_test(): chanlist = %d\n",
- (unsigned int)cmd->chanlist);
- PDEBUG("me4000_ai_do_cmd_test(): chanlist_len = %d\n",
- cmd->chanlist_len);
-
/* Only rounding flags are implemented */
cmd->flags &= TRIG_ROUND_NEAREST | TRIG_ROUND_UP | TRIG_ROUND_DOWN;
@@ -1788,12 +1416,8 @@ static irqreturn_t me4000_ai_isr(int irq, void *dev_id)
int c = 0;
long lval;
- ISR_PDEBUG("me4000_ai_isr() is executed\n");
-
- if (!dev->attached) {
- ISR_PDEBUG("me4000_ai_isr() premature interrupt\n");
+ if (!dev->attached)
return IRQ_NONE;
- }
/* Reset all events */
s->async->events = 0;
@@ -1806,19 +1430,14 @@ static irqreturn_t me4000_ai_isr(int irq, void *dev_id)
return IRQ_HANDLED;
}
- if (me4000_inl(dev,
- ai_context->irq_status_reg) &
+ if (inl(ai_context->irq_status_reg) &
ME4000_IRQ_STATUS_BIT_AI_HF) {
- ISR_PDEBUG
- ("me4000_ai_isr(): Fifo half full interrupt occurred\n");
-
/* Read status register to find out what happened */
- tmp = me4000_inl(dev, ai_context->ctrl_reg);
+ tmp = inl(ai_context->ctrl_reg);
if (!(tmp & ME4000_AI_STATUS_BIT_FF_DATA) &&
!(tmp & ME4000_AI_STATUS_BIT_HF_DATA) &&
(tmp & ME4000_AI_STATUS_BIT_EF_DATA)) {
- ISR_PDEBUG("me4000_ai_isr(): Fifo full\n");
c = ME4000_AI_FIFO_COUNT;
/*
@@ -1828,7 +1447,7 @@ static irqreturn_t me4000_ai_isr(int irq, void *dev_id)
tmp |= ME4000_AI_CTRL_BIT_IMMEDIATE_STOP;
tmp &= ~(ME4000_AI_CTRL_BIT_HF_IRQ |
ME4000_AI_CTRL_BIT_SC_IRQ);
- me4000_outl(dev, tmp, ai_context->ctrl_reg);
+ outl(tmp, ai_context->ctrl_reg);
s->async->events |= COMEDI_CB_ERROR | COMEDI_CB_EOA;
@@ -1838,8 +1457,6 @@ static irqreturn_t me4000_ai_isr(int irq, void *dev_id)
} else if ((tmp & ME4000_AI_STATUS_BIT_FF_DATA)
&& !(tmp & ME4000_AI_STATUS_BIT_HF_DATA)
&& (tmp & ME4000_AI_STATUS_BIT_EF_DATA)) {
- ISR_PDEBUG("me4000_ai_isr(): Fifo half full\n");
-
s->async->events |= COMEDI_CB_BLOCK;
c = ME4000_AI_FIFO_COUNT / 2;
@@ -1856,7 +1473,7 @@ static irqreturn_t me4000_ai_isr(int irq, void *dev_id)
tmp |= ME4000_AI_CTRL_BIT_IMMEDIATE_STOP;
tmp &= ~(ME4000_AI_CTRL_BIT_HF_IRQ |
ME4000_AI_CTRL_BIT_SC_IRQ);
- me4000_outl(dev, tmp, ai_context->ctrl_reg);
+ outl(tmp, ai_context->ctrl_reg);
s->async->events |= COMEDI_CB_ERROR | COMEDI_CB_EOA;
@@ -1865,8 +1482,6 @@ static irqreturn_t me4000_ai_isr(int irq, void *dev_id)
"Undefined FIFO state\n", dev->minor);
}
- ISR_PDEBUG("me4000_ai_isr(): Try to read %d values\n", c);
-
for (i = 0; i < c; i++) {
/* Read value from data fifo */
lval = inl(ai_context->data_reg) & 0xFFFF;
@@ -1880,7 +1495,7 @@ static irqreturn_t me4000_ai_isr(int irq, void *dev_id)
tmp |= ME4000_AI_CTRL_BIT_IMMEDIATE_STOP;
tmp &= ~(ME4000_AI_CTRL_BIT_HF_IRQ |
ME4000_AI_CTRL_BIT_SC_IRQ);
- me4000_outl(dev, tmp, ai_context->ctrl_reg);
+ outl(tmp, ai_context->ctrl_reg);
s->async->events |= COMEDI_CB_OVERFLOW;
@@ -1893,28 +1508,23 @@ static irqreturn_t me4000_ai_isr(int irq, void *dev_id)
}
/* Work is done, so reset the interrupt */
- ISR_PDEBUG("me4000_ai_isr(): Reset fifo half full interrupt\n");
tmp |= ME4000_AI_CTRL_BIT_HF_IRQ_RESET;
- me4000_outl(dev, tmp, ai_context->ctrl_reg);
+ outl(tmp, ai_context->ctrl_reg);
tmp &= ~ME4000_AI_CTRL_BIT_HF_IRQ_RESET;
- me4000_outl(dev, tmp, ai_context->ctrl_reg);
+ outl(tmp, ai_context->ctrl_reg);
}
- if (me4000_inl(dev,
- ai_context->irq_status_reg) & ME4000_IRQ_STATUS_BIT_SC) {
- ISR_PDEBUG
- ("me4000_ai_isr(): Sample counter interrupt occurred\n");
-
+ if (inl(ai_context->irq_status_reg) & ME4000_IRQ_STATUS_BIT_SC) {
s->async->events |= COMEDI_CB_BLOCK | COMEDI_CB_EOA;
/*
* Acquisition is complete, so stop
* conversion and disable all interrupts
*/
- tmp = me4000_inl(dev, ai_context->ctrl_reg);
+ tmp = inl(ai_context->ctrl_reg);
tmp |= ME4000_AI_CTRL_BIT_IMMEDIATE_STOP;
tmp &= ~(ME4000_AI_CTRL_BIT_HF_IRQ | ME4000_AI_CTRL_BIT_SC_IRQ);
- me4000_outl(dev, tmp, ai_context->ctrl_reg);
+ outl(tmp, ai_context->ctrl_reg);
/* Poll data until fifo empty */
while (inl(ai_context->ctrl_reg) & ME4000_AI_STATUS_BIT_EF_DATA) {
@@ -1932,16 +1542,12 @@ static irqreturn_t me4000_ai_isr(int irq, void *dev_id)
}
/* Work is done, so reset the interrupt */
- ISR_PDEBUG
- ("me4000_ai_isr(): Reset interrupt from sample counter\n");
tmp |= ME4000_AI_CTRL_BIT_SC_IRQ_RESET;
- me4000_outl(dev, tmp, ai_context->ctrl_reg);
+ outl(tmp, ai_context->ctrl_reg);
tmp &= ~ME4000_AI_CTRL_BIT_SC_IRQ_RESET;
- me4000_outl(dev, tmp, ai_context->ctrl_reg);
+ outl(tmp, ai_context->ctrl_reg);
}
- ISR_PDEBUG("me4000_ai_isr(): Events = 0x%X\n", s->async->events);
-
if (s->async->events)
comedi_event(dev, s);
@@ -1962,8 +1568,6 @@ static int me4000_ao_insn_write(struct comedi_device *dev,
int aref = CR_AREF(insn->chanspec);
unsigned long tmp;
- CALL_PDEBUG("In me4000_ao_insn_write()\n");
-
if (insn->n == 0) {
return 0;
} else if (insn->n > 1) {
@@ -1995,15 +1599,15 @@ static int me4000_ao_insn_write(struct comedi_device *dev,
}
/* Stop any running conversion */
- tmp = me4000_inl(dev, info->ao_context[chan].ctrl_reg);
+ tmp = inl(info->ao_context[chan].ctrl_reg);
tmp |= ME4000_AO_CTRL_BIT_IMMEDIATE_STOP;
- me4000_outl(dev, tmp, info->ao_context[chan].ctrl_reg);
+ outl(tmp, info->ao_context[chan].ctrl_reg);
/* Clear control register and set to single mode */
- me4000_outl(dev, 0x0, info->ao_context[chan].ctrl_reg);
+ outl(0x0, info->ao_context[chan].ctrl_reg);
/* Write data value */
- me4000_outl(dev, data[0], info->ao_context[chan].single_reg);
+ outl(data[0], info->ao_context[chan].single_reg);
/* Store in the mirror */
info->ao_context[chan].mirror = data[0];
@@ -2039,20 +1643,6 @@ static int me4000_dio_insn_bits(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
-
- CALL_PDEBUG("In me4000_dio_insn_bits()\n");
-
- /* Length of data must be 2 (mask and new data, see below) */
- if (insn->n == 0)
- return 0;
-
- if (insn->n != 2) {
- printk
- ("comedi%d: me4000: me4000_dio_insn_bits(): "
- "Invalid instruction length\n", dev->minor);
- return -EINVAL;
- }
-
/*
* The insn data consists of a mask in data[0] and the new data
* in data[1]. The mask defines which bits we are concerning about.
@@ -2068,25 +1658,24 @@ static int me4000_dio_insn_bits(struct comedi_device *dev,
s->state |= data[0] & data[1];
/* Write out the new digital output lines */
- me4000_outl(dev, (s->state >> 0) & 0xFF,
+ outl((s->state >> 0) & 0xFF,
info->dio_context.port_0_reg);
- me4000_outl(dev, (s->state >> 8) & 0xFF,
+ outl((s->state >> 8) & 0xFF,
info->dio_context.port_1_reg);
- me4000_outl(dev, (s->state >> 16) & 0xFF,
+ outl((s->state >> 16) & 0xFF,
info->dio_context.port_2_reg);
- me4000_outl(dev, (s->state >> 24) & 0xFF,
+ outl((s->state >> 24) & 0xFF,
info->dio_context.port_3_reg);
}
/* On return, data[1] contains the value of
the digital input and output lines. */
- data[1] =
- ((me4000_inl(dev, info->dio_context.port_0_reg) & 0xFF) << 0) |
- ((me4000_inl(dev, info->dio_context.port_1_reg) & 0xFF) << 8) |
- ((me4000_inl(dev, info->dio_context.port_2_reg) & 0xFF) << 16) |
- ((me4000_inl(dev, info->dio_context.port_3_reg) & 0xFF) << 24);
+ data[1] = ((inl(info->dio_context.port_0_reg) & 0xFF) << 0) |
+ ((inl(info->dio_context.port_1_reg) & 0xFF) << 8) |
+ ((inl(info->dio_context.port_2_reg) & 0xFF) << 16) |
+ ((inl(info->dio_context.port_3_reg) & 0xFF) << 24);
- return 2;
+ return insn->n;
}
static int me4000_dio_insn_config(struct comedi_device *dev,
@@ -2096,8 +1685,6 @@ static int me4000_dio_insn_config(struct comedi_device *dev,
unsigned long tmp;
int chan = CR_CHAN(insn->chanspec);
- CALL_PDEBUG("In me4000_dio_insn_config()\n");
-
switch (data[0]) {
default:
return -EINVAL;
@@ -2118,7 +1705,7 @@ static int me4000_dio_insn_config(struct comedi_device *dev,
* On the ME-4000 it is only possible to switch port wise (8 bit)
*/
- tmp = me4000_inl(dev, info->dio_context.ctrl_reg);
+ tmp = inl(info->dio_context.ctrl_reg);
if (data[0] == INSN_CONFIG_DIO_OUTPUT) {
if (chan < 8) {
@@ -2132,7 +1719,7 @@ static int me4000_dio_insn_config(struct comedi_device *dev,
* If one the first port is a fixed output
* port and the second is a fixed input port.
*/
- if (!me4000_inl(dev, info->dio_context.dir_reg))
+ if (!inl(info->dio_context.dir_reg))
return -ENODEV;
s->io_bits |= 0xFF00;
@@ -2159,7 +1746,7 @@ static int me4000_dio_insn_config(struct comedi_device *dev,
* If one the first port is a fixed output
* port and the second is a fixed input port.
*/
- if (!me4000_inl(dev, info->dio_context.dir_reg))
+ if (!inl(info->dio_context.dir_reg))
return -ENODEV;
s->io_bits &= ~0xFF;
@@ -2182,7 +1769,7 @@ static int me4000_dio_insn_config(struct comedi_device *dev,
}
}
- me4000_outl(dev, tmp, info->dio_context.ctrl_reg);
+ outl(tmp, info->dio_context.ctrl_reg);
return 1;
}
@@ -2193,24 +1780,21 @@ static int me4000_dio_insn_config(struct comedi_device *dev,
static int cnt_reset(struct comedi_device *dev, unsigned int channel)
{
-
- CALL_PDEBUG("In cnt_reset()\n");
-
switch (channel) {
case 0:
- me4000_outb(dev, 0x30, info->cnt_context.ctrl_reg);
- me4000_outb(dev, 0x00, info->cnt_context.counter_0_reg);
- me4000_outb(dev, 0x00, info->cnt_context.counter_0_reg);
+ outb(0x30, info->cnt_context.ctrl_reg);
+ outb(0x00, info->cnt_context.counter_0_reg);
+ outb(0x00, info->cnt_context.counter_0_reg);
break;
case 1:
- me4000_outb(dev, 0x70, info->cnt_context.ctrl_reg);
- me4000_outb(dev, 0x00, info->cnt_context.counter_1_reg);
- me4000_outb(dev, 0x00, info->cnt_context.counter_1_reg);
+ outb(0x70, info->cnt_context.ctrl_reg);
+ outb(0x00, info->cnt_context.counter_1_reg);
+ outb(0x00, info->cnt_context.counter_1_reg);
break;
case 2:
- me4000_outb(dev, 0xB0, info->cnt_context.ctrl_reg);
- me4000_outb(dev, 0x00, info->cnt_context.counter_2_reg);
- me4000_outb(dev, 0x00, info->cnt_context.counter_2_reg);
+ outb(0xB0, info->cnt_context.ctrl_reg);
+ outb(0x00, info->cnt_context.counter_2_reg);
+ outb(0x00, info->cnt_context.counter_2_reg);
break;
default:
printk(KERN_ERR
@@ -2227,8 +1811,6 @@ static int cnt_config(struct comedi_device *dev, unsigned int channel,
{
int tmp = 0;
- CALL_PDEBUG("In cnt_config()\n");
-
switch (channel) {
case 0:
tmp |= ME4000_CNT_COUNTER_0;
@@ -2274,7 +1856,7 @@ static int cnt_config(struct comedi_device *dev, unsigned int channel,
/* Write the control word */
tmp |= 0x30;
- me4000_outb(dev, tmp, info->cnt_context.ctrl_reg);
+ outb(tmp, info->cnt_context.ctrl_reg);
return 0;
}
@@ -2286,8 +1868,6 @@ static int me4000_cnt_insn_config(struct comedi_device *dev,
int err;
- CALL_PDEBUG("In me4000_cnt_insn_config()\n");
-
switch (data[0]) {
case GPCT_RESET:
if (insn->n != 1) {
@@ -2332,8 +1912,6 @@ static int me4000_cnt_insn_read(struct comedi_device *dev,
unsigned short tmp;
- CALL_PDEBUG("In me4000_cnt_insn_read()\n");
-
if (insn->n == 0)
return 0;
@@ -2347,21 +1925,21 @@ static int me4000_cnt_insn_read(struct comedi_device *dev,
switch (insn->chanspec) {
case 0:
- tmp = me4000_inb(dev, info->cnt_context.counter_0_reg);
+ tmp = inb(info->cnt_context.counter_0_reg);
data[0] = tmp;
- tmp = me4000_inb(dev, info->cnt_context.counter_0_reg);
+ tmp = inb(info->cnt_context.counter_0_reg);
data[0] |= tmp << 8;
break;
case 1:
- tmp = me4000_inb(dev, info->cnt_context.counter_1_reg);
+ tmp = inb(info->cnt_context.counter_1_reg);
data[0] = tmp;
- tmp = me4000_inb(dev, info->cnt_context.counter_1_reg);
+ tmp = inb(info->cnt_context.counter_1_reg);
data[0] |= tmp << 8;
break;
case 2:
- tmp = me4000_inb(dev, info->cnt_context.counter_2_reg);
+ tmp = inb(info->cnt_context.counter_2_reg);
data[0] = tmp;
- tmp = me4000_inb(dev, info->cnt_context.counter_2_reg);
+ tmp = inb(info->cnt_context.counter_2_reg);
data[0] |= tmp << 8;
break;
default:
@@ -2382,8 +1960,6 @@ static int me4000_cnt_insn_write(struct comedi_device *dev,
unsigned short tmp;
- CALL_PDEBUG("In me4000_cnt_insn_write()\n");
-
if (insn->n == 0) {
return 0;
} else if (insn->n > 1) {
@@ -2397,21 +1973,21 @@ static int me4000_cnt_insn_write(struct comedi_device *dev,
switch (insn->chanspec) {
case 0:
tmp = data[0] & 0xFF;
- me4000_outb(dev, tmp, info->cnt_context.counter_0_reg);
+ outb(tmp, info->cnt_context.counter_0_reg);
tmp = (data[0] >> 8) & 0xFF;
- me4000_outb(dev, tmp, info->cnt_context.counter_0_reg);
+ outb(tmp, info->cnt_context.counter_0_reg);
break;
case 1:
tmp = data[0] & 0xFF;
- me4000_outb(dev, tmp, info->cnt_context.counter_1_reg);
+ outb(tmp, info->cnt_context.counter_1_reg);
tmp = (data[0] >> 8) & 0xFF;
- me4000_outb(dev, tmp, info->cnt_context.counter_1_reg);
+ outb(tmp, info->cnt_context.counter_1_reg);
break;
case 2:
tmp = data[0] & 0xFF;
- me4000_outb(dev, tmp, info->cnt_context.counter_2_reg);
+ outb(tmp, info->cnt_context.counter_2_reg);
tmp = (data[0] >> 8) & 0xFF;
- me4000_outb(dev, tmp, info->cnt_context.counter_2_reg);
+ outb(tmp, info->cnt_context.counter_2_reg);
break;
default:
printk(KERN_ERR
@@ -2424,43 +2000,178 @@ static int me4000_cnt_insn_write(struct comedi_device *dev,
return 1;
}
-static int __devinit driver_me4000_pci_probe(struct pci_dev *dev,
- const struct pci_device_id *ent)
+static int me4000_attach(struct comedi_device *dev, struct comedi_devconfig *it)
{
- return comedi_pci_auto_config(dev, driver_me4000.driver_name);
+ struct comedi_subdevice *s;
+ int result;
+
+ result = me4000_probe(dev, it);
+ if (result)
+ return result;
+
+ result = comedi_alloc_subdevices(dev, 4);
+ if (result)
+ return result;
+
+ /*=========================================================================
+ Analog input subdevice
+ ========================================================================*/
+
+ s = dev->subdevices + 0;
+
+ if (thisboard->ai.count) {
+ s->type = COMEDI_SUBD_AI;
+ s->subdev_flags =
+ SDF_READABLE | SDF_COMMON | SDF_GROUND | SDF_DIFF;
+ s->n_chan = thisboard->ai.count;
+ s->maxdata = 0xFFFF; /* 16 bit ADC */
+ s->len_chanlist = ME4000_AI_CHANNEL_LIST_COUNT;
+ s->range_table = &me4000_ai_range;
+ s->insn_read = me4000_ai_insn_read;
+
+ if (info->irq > 0) {
+ if (request_irq(info->irq, me4000_ai_isr,
+ IRQF_SHARED, "ME-4000", dev)) {
+ printk
+ ("comedi%d: me4000: me4000_attach(): "
+ "Unable to allocate irq\n", dev->minor);
+ } else {
+ dev->read_subdev = s;
+ s->subdev_flags |= SDF_CMD_READ;
+ s->cancel = me4000_ai_cancel;
+ s->do_cmdtest = me4000_ai_do_cmd_test;
+ s->do_cmd = me4000_ai_do_cmd;
+ }
+ } else {
+ printk(KERN_WARNING
+ "comedi%d: me4000: me4000_attach(): "
+ "No interrupt available\n", dev->minor);
+ }
+ } else {
+ s->type = COMEDI_SUBD_UNUSED;
+ }
+
+ /*=========================================================================
+ Analog output subdevice
+ ========================================================================*/
+
+ s = dev->subdevices + 1;
+
+ if (thisboard->ao.count) {
+ s->type = COMEDI_SUBD_AO;
+ s->subdev_flags = SDF_WRITEABLE | SDF_COMMON | SDF_GROUND;
+ s->n_chan = thisboard->ao.count;
+ s->maxdata = 0xFFFF; /* 16 bit DAC */
+ s->range_table = &me4000_ao_range;
+ s->insn_write = me4000_ao_insn_write;
+ s->insn_read = me4000_ao_insn_read;
+ } else {
+ s->type = COMEDI_SUBD_UNUSED;
+ }
+
+ /*=========================================================================
+ Digital I/O subdevice
+ ========================================================================*/
+
+ s = dev->subdevices + 2;
+
+ if (thisboard->dio.count) {
+ s->type = COMEDI_SUBD_DIO;
+ s->subdev_flags = SDF_READABLE | SDF_WRITABLE;
+ s->n_chan = thisboard->dio.count * 8;
+ s->maxdata = 1;
+ s->range_table = &range_digital;
+ s->insn_bits = me4000_dio_insn_bits;
+ s->insn_config = me4000_dio_insn_config;
+ } else {
+ s->type = COMEDI_SUBD_UNUSED;
+ }
+
+ /*
+ * Check for optoisolated ME-4000 version. If one the first
+ * port is a fixed output port and the second is a fixed input port.
+ */
+ if (!inl(info->dio_context.dir_reg)) {
+ s->io_bits |= 0xFF;
+ outl(ME4000_DIO_CTRL_BIT_MODE_0, info->dio_context.dir_reg);
+ }
+
+ /*=========================================================================
+ Counter subdevice
+ ========================================================================*/
+
+ s = dev->subdevices + 3;
+
+ if (thisboard->cnt.count) {
+ s->type = COMEDI_SUBD_COUNTER;
+ s->subdev_flags = SDF_READABLE | SDF_WRITABLE;
+ s->n_chan = thisboard->cnt.count;
+ s->maxdata = 0xFFFF; /* 16 bit counters */
+ s->insn_read = me4000_cnt_insn_read;
+ s->insn_write = me4000_cnt_insn_write;
+ s->insn_config = me4000_cnt_insn_config;
+ } else {
+ s->type = COMEDI_SUBD_UNUSED;
+ }
+
+ return 0;
}
-static void __devexit driver_me4000_pci_remove(struct pci_dev *dev)
+static void me4000_detach(struct comedi_device *dev)
{
- comedi_pci_auto_unconfig(dev);
+ if (info) {
+ if (info->pci_dev_p) {
+ reset_board(dev);
+ if (info->plx_regbase)
+ comedi_pci_disable(info->pci_dev_p);
+ pci_dev_put(info->pci_dev_p);
+ }
+ }
}
-static struct pci_driver driver_me4000_pci_driver = {
- .id_table = me4000_pci_table,
- .probe = &driver_me4000_pci_probe,
- .remove = __devexit_p(&driver_me4000_pci_remove)
+static struct comedi_driver me4000_driver = {
+ .driver_name = "me4000",
+ .module = THIS_MODULE,
+ .attach = me4000_attach,
+ .detach = me4000_detach,
};
-static int __init driver_me4000_init_module(void)
+static int __devinit me4000_pci_probe(struct pci_dev *dev,
+ const struct pci_device_id *ent)
{
- int retval;
-
- retval = comedi_driver_register(&driver_me4000);
- if (retval < 0)
- return retval;
-
- driver_me4000_pci_driver.name = (char *)driver_me4000.driver_name;
- return pci_register_driver(&driver_me4000_pci_driver);
+ return comedi_pci_auto_config(dev, &me4000_driver);
}
-static void __exit driver_me4000_cleanup_module(void)
+static void __devexit me4000_pci_remove(struct pci_dev *dev)
{
- pci_unregister_driver(&driver_me4000_pci_driver);
- comedi_driver_unregister(&driver_me4000);
+ comedi_pci_auto_unconfig(dev);
}
-module_init(driver_me4000_init_module);
-module_exit(driver_me4000_cleanup_module);
+static DEFINE_PCI_DEVICE_TABLE(me4000_pci_table) = {
+ { PCI_DEVICE(PCI_VENDOR_ID_MEILHAUS, 0x4650) },
+ { PCI_DEVICE(PCI_VENDOR_ID_MEILHAUS, 0x4660) },
+ { PCI_DEVICE(PCI_VENDOR_ID_MEILHAUS, 0x4661) },
+ { PCI_DEVICE(PCI_VENDOR_ID_MEILHAUS, 0x4662) },
+ { PCI_DEVICE(PCI_VENDOR_ID_MEILHAUS, 0x4663) },
+ { PCI_DEVICE(PCI_VENDOR_ID_MEILHAUS, 0x4670) },
+ { PCI_DEVICE(PCI_VENDOR_ID_MEILHAUS, 0x4671) },
+ { PCI_DEVICE(PCI_VENDOR_ID_MEILHAUS, 0x4672) },
+ { PCI_DEVICE(PCI_VENDOR_ID_MEILHAUS, 0x4673) },
+ { PCI_DEVICE(PCI_VENDOR_ID_MEILHAUS, 0x4680) },
+ { PCI_DEVICE(PCI_VENDOR_ID_MEILHAUS, 0x4681) },
+ { PCI_DEVICE(PCI_VENDOR_ID_MEILHAUS, 0x4682) },
+ { PCI_DEVICE(PCI_VENDOR_ID_MEILHAUS, 0x4683) },
+ { 0 }
+};
+MODULE_DEVICE_TABLE(pci, me4000_pci_table);
+
+static struct pci_driver me4000_pci_driver = {
+ .name = "me4000",
+ .id_table = me4000_pci_table,
+ .probe = me4000_pci_probe,
+ .remove = __devexit_p(me4000_pci_remove),
+};
+module_comedi_pci_driver(me4000_driver, me4000_pci_driver);
MODULE_AUTHOR("Comedi http://www.comedi.org");
MODULE_DESCRIPTION("Comedi low-level driver");
diff --git a/drivers/staging/comedi/drivers/me4000.h b/drivers/staging/comedi/drivers/me4000.h
index 733b19243c75..5a4df4e4b236 100644
--- a/drivers/staging/comedi/drivers/me4000.h
+++ b/drivers/staging/comedi/drivers/me4000.h
@@ -25,43 +25,6 @@
#define _ME4000_H_
/*=============================================================================
- Debug section
- ===========================================================================*/
-
-#undef ME4000_CALL_DEBUG /* Debug function entry and exit */
-#undef ME4000_PORT_DEBUG /* Debug port access */
-#undef ME4000_ISR_DEBUG /* Debug the interrupt service routine */
-#undef ME4000_DEBUG /* General purpose debug masseges */
-
-#ifdef ME4000_CALL_DEBUG
-#undef CALL_PDEBUG
-#define CALL_PDEBUG(fmt, args...) printk(KERN_DEBUG"comedi%d: me4000: " fmt, dev->minor, ##args)
-#else
-# define CALL_PDEBUG(fmt, args...) /* no debugging, do nothing */
-#endif
-
-#ifdef ME4000_PORT_DEBUG
-#undef PORT_PDEBUG
-#define PORT_PDEBUG(fmt, args...) printk(KERN_DEBUG"comedi%d: me4000: " fmt, dev->minor, ##args)
-#else
-#define PORT_PDEBUG(fmt, args...) /* no debugging, do nothing */
-#endif
-
-#ifdef ME4000_ISR_DEBUG
-#undef ISR_PDEBUG
-#define ISR_PDEBUG(fmt, args...) printk(KERN_DEBUG"comedi%d: me4000: " fmt, dev->minor, ##args)
-#else
-#define ISR_PDEBUG(fmt, args...) /* no debugging, do nothing */
-#endif
-
-#ifdef ME4000_DEBUG
-#undef PDEBUG
-#define PDEBUG(fmt, args...) printk(KERN_DEBUG"comedi%d: me4000: " fmt, dev->minor, ##args)
-#else
-#define PDEBUG(fmt, args...) /* no debugging, do nothing */
-#endif
-
-/*=============================================================================
PCI vendor and device IDs
===========================================================================*/
diff --git a/drivers/staging/comedi/drivers/me_daq.c b/drivers/staging/comedi/drivers/me_daq.c
index 8b812e41c52b..8c6f8b93b277 100644
--- a/drivers/staging/comedi/drivers/me_daq.c
+++ b/drivers/staging/comedi/drivers/me_daq.c
@@ -54,8 +54,6 @@ from http://www.comedi.org
#include <linux/sched.h>
#include "../comedidev.h"
-#include "comedi_pci.h"
-
/*#include "me2600_fw.h" */
#define ME_DRIVER_NAME "me_daq"
@@ -146,10 +144,6 @@ from http://www.comedi.org
#define ME_COUNTER_STARTDATA_B 0x0022 /* - | W */
#define ME_COUNTER_VALUE_B 0x0022 /* R | - */
-/* Function prototypes */
-static int me_attach(struct comedi_device *dev, struct comedi_devconfig *it);
-static int me_detach(struct comedi_device *dev);
-
static const struct comedi_lrange me2000_ai_range = {
8,
{
@@ -187,14 +181,6 @@ static const struct comedi_lrange me2600_ao_range = {
}
};
-static DEFINE_PCI_DEVICE_TABLE(me_pci_table) = {
- { PCI_DEVICE(PCI_VENDOR_ID_MEILHAUS, ME2600_DEVICE_ID) },
- { PCI_DEVICE(PCI_VENDOR_ID_MEILHAUS, ME2000_DEVICE_ID) },
- {0}
-};
-
-MODULE_DEVICE_TABLE(pci, me_pci_table);
-
/* Board specification structure */
struct me_board {
const char *name; /* driver name */
@@ -245,56 +231,8 @@ static const struct me_board me_boards[] = {
}
};
-#define me_board_nbr (sizeof(me_boards)/sizeof(struct me_board))
-
-static struct comedi_driver me_driver = {
- .driver_name = ME_DRIVER_NAME,
- .module = THIS_MODULE,
- .attach = me_attach,
- .detach = me_detach,
-};
-
-static int __devinit me_driver_pci_probe(struct pci_dev *dev,
- const struct pci_device_id *ent)
-{
- return comedi_pci_auto_config(dev, me_driver.driver_name);
-}
-
-static void __devexit me_driver_pci_remove(struct pci_dev *dev)
-{
- comedi_pci_auto_unconfig(dev);
-}
-
-static struct pci_driver me_driver_pci_driver = {
- .id_table = me_pci_table,
- .probe = &me_driver_pci_probe,
- .remove = __devexit_p(&me_driver_pci_remove)
-};
-
-static int __init me_driver_init_module(void)
-{
- int retval;
-
- retval = comedi_driver_register(&me_driver);
- if (retval < 0)
- return retval;
-
- me_driver_pci_driver.name = (char *)me_driver.driver_name;
- return pci_register_driver(&me_driver_pci_driver);
-}
-
-static void __exit me_driver_cleanup_module(void)
-{
- pci_unregister_driver(&me_driver_pci_driver);
- comedi_driver_unregister(&me_driver);
-}
-
-module_init(me_driver_init_module);
-module_exit(me_driver_cleanup_module);
-
/* Private data structure */
struct me_private_data {
- struct pci_dev *pci_device;
void __iomem *plx_regbase; /* PLX configuration base address */
void __iomem *me_regbase; /* Base address of the Meilhaus card */
unsigned long plx_regbase_size; /* Size of PLX configuration space */
@@ -390,7 +328,7 @@ static int me_dio_insn_bits(struct comedi_device *dev,
data[1] |= readw(dev_private->me_regbase + ME_DIO_PORT_B) << 16;
}
- return 2;
+ return insn->n;
}
/*
@@ -669,15 +607,42 @@ static int me_reset(struct comedi_device *dev)
return 0;
}
-/*
- * Attach
- *
- * - Register PCI device
- * - Declare device driver capability
- */
+static struct pci_dev *me_find_pci_dev(struct comedi_device *dev,
+ struct comedi_devconfig *it)
+{
+ const struct me_board *board;
+ struct pci_dev *pcidev = NULL;
+ int bus = it->options[0];
+ int slot = it->options[1];
+ int i;
+
+ for_each_pci_dev(pcidev) {
+ if (bus || slot) {
+ if (pcidev->bus->number != bus ||
+ PCI_SLOT(pcidev->devfn) != slot)
+ continue;
+ }
+ if (pcidev->vendor != PCI_VENDOR_ID_MEILHAUS)
+ continue;
+
+ for (i = 0; i < ARRAY_SIZE(me_boards); i++) {
+ board = &me_boards[i];
+ if (board->device_id != pcidev->device)
+ continue;
+
+ dev->board_ptr = board;
+ return pcidev;
+ }
+ }
+ dev_err(dev->class_dev,
+ "No supported board found! (req. bus %d, slot %d)\n",
+ bus, slot);
+ return NULL;
+}
+
static int me_attach(struct comedi_device *dev, struct comedi_devconfig *it)
{
- struct pci_dev *pci_device = NULL;
+ struct pci_dev *pci_device;
struct comedi_subdevice *subdevice;
struct me_board *board;
resource_size_t plx_regbase_tmp;
@@ -687,54 +652,17 @@ static int me_attach(struct comedi_device *dev, struct comedi_devconfig *it)
resource_size_t swap_regbase_tmp;
unsigned long swap_regbase_size_tmp;
resource_size_t regbase_tmp;
- int result, error, i;
+ int result, error;
/* Allocate private memory */
if (alloc_private(dev, sizeof(struct me_private_data)) < 0)
return -ENOMEM;
- /* Probe the device to determine what device in the series it is. */
- for_each_pci_dev(pci_device) {
- if (pci_device->vendor == PCI_VENDOR_ID_MEILHAUS) {
- for (i = 0; i < me_board_nbr; i++) {
- if (me_boards[i].device_id ==
- pci_device->device) {
- /*
- * was a particular bus/slot requested?
- */
- if ((it->options[0] != 0)
- || (it->options[1] != 0)) {
- /*
- * are we on the wrong bus/slot?
- */
- if (pci_device->bus->number !=
- it->options[0]
- ||
- PCI_SLOT(pci_device->devfn)
- != it->options[1]) {
- continue;
- }
- }
-
- dev->board_ptr = me_boards + i;
- board =
- (struct me_board *)dev->board_ptr;
- dev_private->pci_device = pci_device;
- goto found;
- }
- }
- }
- }
-
- printk(KERN_ERR
- "comedi%d: no supported board found! (req. bus/slot : %d/%d)\n",
- dev->minor, it->options[0], it->options[1]);
- return -EIO;
-
-found:
- printk(KERN_INFO "comedi%d: found %s at PCI bus %d, slot %d\n",
- dev->minor, me_boards[i].name,
- pci_device->bus->number, PCI_SLOT(pci_device->devfn));
+ pci_device = me_find_pci_dev(dev, it);
+ if (!pci_device)
+ return -EIO;
+ comedi_set_hw_dev(dev, &pci_device->dev);
+ board = (struct me_board *)dev->board_ptr;
/* Enable PCI device and request PCI regions */
if (comedi_pci_enable(pci_device, ME_DRIVER_NAME) < 0) {
@@ -826,9 +754,8 @@ found:
me_reset(dev);
- /* device driver capabilities */
- error = alloc_subdevices(dev, 3);
- if (error < 0)
+ error = comedi_alloc_subdevices(dev, 3);
+ if (error)
return error;
subdevice = dev->subdevices + 0;
@@ -869,9 +796,10 @@ found:
return 0;
}
-/* Detach */
-static int me_detach(struct comedi_device *dev)
+static void me_detach(struct comedi_device *dev)
{
+ struct pci_dev *pcidev = comedi_to_pci_dev(dev);
+
if (dev_private) {
if (dev_private->me_regbase) {
me_reset(dev);
@@ -879,16 +807,47 @@ static int me_detach(struct comedi_device *dev)
}
if (dev_private->plx_regbase)
iounmap(dev_private->plx_regbase);
- if (dev_private->pci_device) {
- if (dev_private->plx_regbase_size)
- comedi_pci_disable(dev_private->pci_device);
-
- pci_dev_put(dev_private->pci_device);
- }
}
- return 0;
+ if (pcidev) {
+ if (dev_private->plx_regbase_size)
+ comedi_pci_disable(pcidev);
+ pci_dev_put(pcidev);
+ }
}
+static struct comedi_driver me_daq_driver = {
+ .driver_name = "me_daq",
+ .module = THIS_MODULE,
+ .attach = me_attach,
+ .detach = me_detach,
+};
+
+static int __devinit me_daq_pci_probe(struct pci_dev *dev,
+ const struct pci_device_id *ent)
+{
+ return comedi_pci_auto_config(dev, &me_daq_driver);
+}
+
+static void __devexit me_daq_pci_remove(struct pci_dev *dev)
+{
+ comedi_pci_auto_unconfig(dev);
+}
+
+static DEFINE_PCI_DEVICE_TABLE(me_daq_pci_table) = {
+ { PCI_DEVICE(PCI_VENDOR_ID_MEILHAUS, ME2600_DEVICE_ID) },
+ { PCI_DEVICE(PCI_VENDOR_ID_MEILHAUS, ME2000_DEVICE_ID) },
+ { 0 }
+};
+MODULE_DEVICE_TABLE(pci, me_daq_pci_table);
+
+static struct pci_driver me_daq_pci_driver = {
+ .name = "me_daq",
+ .id_table = me_daq_pci_table,
+ .probe = me_daq_pci_probe,
+ .remove = __devexit_p(me_daq_pci_remove),
+};
+module_comedi_pci_driver(me_daq_driver, me_daq_pci_driver);
+
MODULE_AUTHOR("Comedi http://www.comedi.org");
MODULE_DESCRIPTION("Comedi low-level driver");
MODULE_LICENSE("GPL");
diff --git a/drivers/staging/comedi/drivers/mite.c b/drivers/staging/comedi/drivers/mite.c
index 13e9c8071696..a93166d6a8f8 100644
--- a/drivers/staging/comedi/drivers/mite.c
+++ b/drivers/staging/comedi/drivers/mite.c
@@ -52,7 +52,6 @@
#include "mite.h"
#include "comedi_fc.h"
-#include "comedi_pci.h"
#include "../comedidev.h"
diff --git a/drivers/staging/comedi/drivers/mite.h b/drivers/staging/comedi/drivers/mite.h
index 999551f54c2a..83f1b27a4720 100644
--- a/drivers/staging/comedi/drivers/mite.h
+++ b/drivers/staging/comedi/drivers/mite.h
@@ -66,9 +66,9 @@ struct mite_struct {
struct pci_dev *pcidev;
resource_size_t mite_phys_addr;
- void *mite_io_addr;
+ void __iomem *mite_io_addr;
resource_size_t daq_phys_addr;
- void *daq_io_addr;
+ void __iomem *daq_io_addr;
struct mite_channel channels[MAX_MITE_DMA_CHANNELS];
short channel_allocated[MAX_MITE_DMA_CHANNELS];
diff --git a/drivers/staging/comedi/drivers/mpc624.c b/drivers/staging/comedi/drivers/mpc624.c
index dd09a6d46e5c..b928b6763cd5 100644
--- a/drivers/staging/comedi/drivers/mpc624.c
+++ b/drivers/staging/comedi/drivers/mpc624.c
@@ -148,131 +148,6 @@ static const struct comedi_lrange range_mpc624_bipolar10 = {
}
};
-/* -------------------------------------------------------------------------- */
-static int mpc624_attach(struct comedi_device *dev,
- struct comedi_devconfig *it);
-static int mpc624_detach(struct comedi_device *dev);
-/* -------------------------------------------------------------------------- */
-static struct comedi_driver driver_mpc624 = {
- .driver_name = "mpc624",
- .module = THIS_MODULE,
- .attach = mpc624_attach,
- .detach = mpc624_detach
-};
-
-/* -------------------------------------------------------------------------- */
-static int mpc624_ai_rinsn(struct comedi_device *dev,
- struct comedi_subdevice *s, struct comedi_insn *insn,
- unsigned int *data);
-/* -------------------------------------------------------------------------- */
-static int mpc624_attach(struct comedi_device *dev, struct comedi_devconfig *it)
-{
- struct comedi_subdevice *s;
- unsigned long iobase;
-
- iobase = it->options[0];
- printk(KERN_INFO "comedi%d: mpc624 [0x%04lx, ", dev->minor, iobase);
- if (request_region(iobase, MPC624_SIZE, "mpc624") == NULL) {
- printk(KERN_ERR "I/O port(s) in use\n");
- return -EIO;
- }
-
- dev->iobase = iobase;
- dev->board_name = "mpc624";
-
- /* Private structure initialization */
- if (alloc_private(dev, sizeof(struct skel_private)) < 0)
- return -ENOMEM;
-
- switch (it->options[1]) {
- case 0:
- devpriv->ulConvertionRate = MPC624_SPEED_3_52_kHz;
- printk(KERN_INFO "3.52 kHz, ");
- break;
- case 1:
- devpriv->ulConvertionRate = MPC624_SPEED_1_76_kHz;
- printk(KERN_INFO "1.76 kHz, ");
- break;
- case 2:
- devpriv->ulConvertionRate = MPC624_SPEED_880_Hz;
- printk(KERN_INFO "880 Hz, ");
- break;
- case 3:
- devpriv->ulConvertionRate = MPC624_SPEED_440_Hz;
- printk(KERN_INFO "440 Hz, ");
- break;
- case 4:
- devpriv->ulConvertionRate = MPC624_SPEED_220_Hz;
- printk(KERN_INFO "220 Hz, ");
- break;
- case 5:
- devpriv->ulConvertionRate = MPC624_SPEED_110_Hz;
- printk(KERN_INFO "110 Hz, ");
- break;
- case 6:
- devpriv->ulConvertionRate = MPC624_SPEED_55_Hz;
- printk(KERN_INFO "55 Hz, ");
- break;
- case 7:
- devpriv->ulConvertionRate = MPC624_SPEED_27_5_Hz;
- printk(KERN_INFO "27.5 Hz, ");
- break;
- case 8:
- devpriv->ulConvertionRate = MPC624_SPEED_13_75_Hz;
- printk(KERN_INFO "13.75 Hz, ");
- break;
- case 9:
- devpriv->ulConvertionRate = MPC624_SPEED_6_875_Hz;
- printk(KERN_INFO "6.875 Hz, ");
- break;
- default:
- printk
- (KERN_ERR "illegal conversion rate setting!"
- " Valid numbers are 0..9. Using 9 => 6.875 Hz, ");
- devpriv->ulConvertionRate = MPC624_SPEED_3_52_kHz;
- }
-
- /* Subdevices structures */
- if (alloc_subdevices(dev, 1) < 0)
- return -ENOMEM;
-
- s = dev->subdevices + 0;
- s->type = COMEDI_SUBD_AI;
- s->subdev_flags = SDF_READABLE | SDF_DIFF;
- s->n_chan = 8;
- switch (it->options[1]) {
- default:
- s->maxdata = 0x3FFFFFFF;
- printk(KERN_INFO "30 bit, ");
- }
-
- switch (it->options[1]) {
- case 0:
- s->range_table = &range_mpc624_bipolar1;
- printk(KERN_INFO "1.01V]: ");
- break;
- default:
- s->range_table = &range_mpc624_bipolar10;
- printk(KERN_INFO "10.1V]: ");
- }
- s->len_chanlist = 1;
- s->insn_read = mpc624_ai_rinsn;
-
- printk(KERN_INFO "attached\n");
-
- return 1;
-}
-
-static int mpc624_detach(struct comedi_device *dev)
-{
- printk(KERN_INFO "comedi%d: mpc624: remove\n", dev->minor);
-
- if (dev->iobase)
- release_region(dev->iobase, MPC624_SIZE);
-
- return 0;
-}
-
/* Timeout 200ms */
#define TIMEOUT 200
@@ -406,18 +281,118 @@ static int mpc624_ai_rinsn(struct comedi_device *dev,
return n;
}
-static int __init driver_mpc624_init_module(void)
+static int mpc624_attach(struct comedi_device *dev, struct comedi_devconfig *it)
{
- return comedi_driver_register(&driver_mpc624);
+ struct comedi_subdevice *s;
+ unsigned long iobase;
+ int ret;
+
+ iobase = it->options[0];
+ printk(KERN_INFO "comedi%d: mpc624 [0x%04lx, ", dev->minor, iobase);
+ if (request_region(iobase, MPC624_SIZE, "mpc624") == NULL) {
+ printk(KERN_ERR "I/O port(s) in use\n");
+ return -EIO;
+ }
+
+ dev->iobase = iobase;
+ dev->board_name = "mpc624";
+
+ /* Private structure initialization */
+ if (alloc_private(dev, sizeof(struct skel_private)) < 0)
+ return -ENOMEM;
+
+ switch (it->options[1]) {
+ case 0:
+ devpriv->ulConvertionRate = MPC624_SPEED_3_52_kHz;
+ printk(KERN_INFO "3.52 kHz, ");
+ break;
+ case 1:
+ devpriv->ulConvertionRate = MPC624_SPEED_1_76_kHz;
+ printk(KERN_INFO "1.76 kHz, ");
+ break;
+ case 2:
+ devpriv->ulConvertionRate = MPC624_SPEED_880_Hz;
+ printk(KERN_INFO "880 Hz, ");
+ break;
+ case 3:
+ devpriv->ulConvertionRate = MPC624_SPEED_440_Hz;
+ printk(KERN_INFO "440 Hz, ");
+ break;
+ case 4:
+ devpriv->ulConvertionRate = MPC624_SPEED_220_Hz;
+ printk(KERN_INFO "220 Hz, ");
+ break;
+ case 5:
+ devpriv->ulConvertionRate = MPC624_SPEED_110_Hz;
+ printk(KERN_INFO "110 Hz, ");
+ break;
+ case 6:
+ devpriv->ulConvertionRate = MPC624_SPEED_55_Hz;
+ printk(KERN_INFO "55 Hz, ");
+ break;
+ case 7:
+ devpriv->ulConvertionRate = MPC624_SPEED_27_5_Hz;
+ printk(KERN_INFO "27.5 Hz, ");
+ break;
+ case 8:
+ devpriv->ulConvertionRate = MPC624_SPEED_13_75_Hz;
+ printk(KERN_INFO "13.75 Hz, ");
+ break;
+ case 9:
+ devpriv->ulConvertionRate = MPC624_SPEED_6_875_Hz;
+ printk(KERN_INFO "6.875 Hz, ");
+ break;
+ default:
+ printk
+ (KERN_ERR "illegal conversion rate setting!"
+ " Valid numbers are 0..9. Using 9 => 6.875 Hz, ");
+ devpriv->ulConvertionRate = MPC624_SPEED_3_52_kHz;
+ }
+
+ ret = comedi_alloc_subdevices(dev, 1);
+ if (ret)
+ return ret;
+
+ s = dev->subdevices + 0;
+ s->type = COMEDI_SUBD_AI;
+ s->subdev_flags = SDF_READABLE | SDF_DIFF;
+ s->n_chan = 8;
+ switch (it->options[1]) {
+ default:
+ s->maxdata = 0x3FFFFFFF;
+ printk(KERN_INFO "30 bit, ");
+ }
+
+ switch (it->options[1]) {
+ case 0:
+ s->range_table = &range_mpc624_bipolar1;
+ printk(KERN_INFO "1.01V]: ");
+ break;
+ default:
+ s->range_table = &range_mpc624_bipolar10;
+ printk(KERN_INFO "10.1V]: ");
+ }
+ s->len_chanlist = 1;
+ s->insn_read = mpc624_ai_rinsn;
+
+ printk(KERN_INFO "attached\n");
+
+ return 1;
}
-static void __exit driver_mpc624_cleanup_module(void)
+static void mpc624_detach(struct comedi_device *dev)
{
- comedi_driver_unregister(&driver_mpc624);
+ if (dev->iobase)
+ release_region(dev->iobase, MPC624_SIZE);
}
-module_init(driver_mpc624_init_module);
-module_exit(driver_mpc624_cleanup_module);
+static struct comedi_driver mpc624_driver = {
+ .driver_name = "mpc624",
+ .module = THIS_MODULE,
+ .attach = mpc624_attach,
+ .detach = mpc624_detach
+};
+module_comedi_driver(mpc624_driver);
MODULE_AUTHOR("Comedi http://www.comedi.org");
MODULE_DESCRIPTION("Comedi low-level driver");
diff --git a/drivers/staging/comedi/drivers/mpc8260cpm.c b/drivers/staging/comedi/drivers/mpc8260cpm.c
index 5f6816a3fe8c..a7fda8f01e8c 100644
--- a/drivers/staging/comedi/drivers/mpc8260cpm.c
+++ b/drivers/staging/comedi/drivers/mpc8260cpm.c
@@ -46,75 +46,6 @@ struct mpc8260cpm_private {
#define devpriv ((struct mpc8260cpm_private *)dev->private)
-static int mpc8260cpm_attach(struct comedi_device *dev,
- struct comedi_devconfig *it);
-static int mpc8260cpm_detach(struct comedi_device *dev);
-static struct comedi_driver driver_mpc8260cpm = {
- .driver_name = "mpc8260cpm",
- .module = THIS_MODULE,
- .attach = mpc8260cpm_attach,
- .detach = mpc8260cpm_detach,
-};
-
-static int __init driver_mpc8260cpm_init_module(void)
-{
- return comedi_driver_register(&driver_mpc8260cpm);
-}
-
-static void __exit driver_mpc8260cpm_cleanup_module(void)
-{
- comedi_driver_unregister(&driver_mpc8260cpm);
-}
-
-module_init(driver_mpc8260cpm_init_module);
-module_exit(driver_mpc8260cpm_cleanup_module);
-
-static int mpc8260cpm_dio_config(struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data);
-static int mpc8260cpm_dio_bits(struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data);
-
-static int mpc8260cpm_attach(struct comedi_device *dev,
- struct comedi_devconfig *it)
-{
- struct comedi_subdevice *s;
- int i;
-
- printk("comedi%d: mpc8260cpm: ", dev->minor);
-
- dev->board_ptr = mpc8260cpm_boards + dev->board;
-
- dev->board_name = thisboard->name;
-
- if (alloc_private(dev, sizeof(struct mpc8260cpm_private)) < 0)
- return -ENOMEM;
-
- if (alloc_subdevices(dev, 4) < 0)
- return -ENOMEM;
-
- for (i = 0; i < 4; i++) {
- s = dev->subdevices + i;
- s->type = COMEDI_SUBD_DIO;
- s->subdev_flags = SDF_READABLE | SDF_WRITABLE;
- s->n_chan = 32;
- s->maxdata = 1;
- s->range_table = &range_digital;
- s->insn_config = mpc8260cpm_dio_config;
- s->insn_bits = mpc8260cpm_dio_bits;
- }
-
- return 1;
-}
-
-static int mpc8260cpm_detach(struct comedi_device *dev)
-{
- printk("comedi%d: mpc8260cpm: remove\n", dev->minor);
-
- return 0;
-}
-
static unsigned long *cpm_pdat(int port)
{
switch (port) {
@@ -182,5 +113,52 @@ static int mpc8260cpm_dio_bits(struct comedi_device *dev,
p = cpm_pdat((int)s->private);
- return 2;
+ return insn->n;
+}
+
+static int mpc8260cpm_attach(struct comedi_device *dev,
+ struct comedi_devconfig *it)
+{
+ struct comedi_subdevice *s;
+ int i;
+ int ret;
+
+ printk("comedi%d: mpc8260cpm: ", dev->minor);
+
+ dev->board_ptr = mpc8260cpm_boards + dev->board;
+
+ dev->board_name = thisboard->name;
+
+ if (alloc_private(dev, sizeof(struct mpc8260cpm_private)) < 0)
+ return -ENOMEM;
+
+ ret =comedi_alloc_subdevices(dev, 4);
+ if (ret)
+ return ret;
+
+ for (i = 0; i < 4; i++) {
+ s = dev->subdevices + i;
+ s->type = COMEDI_SUBD_DIO;
+ s->subdev_flags = SDF_READABLE | SDF_WRITABLE;
+ s->n_chan = 32;
+ s->maxdata = 1;
+ s->range_table = &range_digital;
+ s->insn_config = mpc8260cpm_dio_config;
+ s->insn_bits = mpc8260cpm_dio_bits;
+ }
+
+ return 1;
}
+
+static void mpc8260cpm_detach(struct comedi_device *dev)
+{
+ /* Nothing to cleanup */
+}
+
+static struct comedi_driver mpc8260cpm_driver = {
+ .driver_name = "mpc8260cpm",
+ .module = THIS_MODULE,
+ .attach = mpc8260cpm_attach,
+ .detach = mpc8260cpm_detach,
+};
+module_comedi_driver(mpc8260cpm_driver);
diff --git a/drivers/staging/comedi/drivers/multiq3.c b/drivers/staging/comedi/drivers/multiq3.c
index dace902d3bce..eccbe1fb4f2c 100644
--- a/drivers/staging/comedi/drivers/multiq3.c
+++ b/drivers/staging/comedi/drivers/multiq3.c
@@ -83,29 +83,6 @@ Devices: [Quanser Consulting] MultiQ-3 (multiq3)
#define MULTIQ3_TIMEOUT 30
-static int multiq3_attach(struct comedi_device *dev,
- struct comedi_devconfig *it);
-static int multiq3_detach(struct comedi_device *dev);
-static struct comedi_driver driver_multiq3 = {
- .driver_name = "multiq3",
- .module = THIS_MODULE,
- .attach = multiq3_attach,
- .detach = multiq3_detach,
-};
-
-static int __init driver_multiq3_init_module(void)
-{
- return comedi_driver_register(&driver_multiq3);
-}
-
-static void __exit driver_multiq3_cleanup_module(void)
-{
- comedi_driver_unregister(&driver_multiq3);
-}
-
-module_init(driver_multiq3_init_module);
-module_exit(driver_multiq3_cleanup_module);
-
struct multiq3_private {
unsigned int ao_readback[2];
};
@@ -184,28 +161,22 @@ static int multiq3_di_insn_bits(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
- if (insn->n != 2)
- return -EINVAL;
-
data[1] = inw(dev->iobase + MULTIQ3_DIGIN_PORT);
- return 2;
+ return insn->n;
}
static int multiq3_do_insn_bits(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
- if (insn->n != 2)
- return -EINVAL;
-
s->state &= ~data[0];
s->state |= (data[0] & data[1]);
outw(s->state, dev->iobase + MULTIQ3_DIGOUT_PORT);
data[1] = s->state;
- return 2;
+ return insn->n;
}
static int multiq3_encoder_insn_read(struct comedi_device *dev,
@@ -278,8 +249,9 @@ static int multiq3_attach(struct comedi_device *dev,
else
printk(KERN_WARNING "comedi%d: no irq\n", dev->minor);
dev->board_name = "multiq3";
- result = alloc_subdevices(dev, 5);
- if (result < 0)
+
+ result = comedi_alloc_subdevices(dev, 5);
+ if (result)
return result;
result = alloc_private(dev, sizeof(struct multiq3_private));
@@ -338,18 +310,22 @@ static int multiq3_attach(struct comedi_device *dev,
return 0;
}
-static int multiq3_detach(struct comedi_device *dev)
+static void multiq3_detach(struct comedi_device *dev)
{
- printk(KERN_INFO "comedi%d: multiq3: remove\n", dev->minor);
-
if (dev->iobase)
release_region(dev->iobase, MULTIQ3_SIZE);
if (dev->irq)
free_irq(dev->irq, dev);
-
- return 0;
}
+static struct comedi_driver multiq3_driver = {
+ .driver_name = "multiq3",
+ .module = THIS_MODULE,
+ .attach = multiq3_attach,
+ .detach = multiq3_detach,
+};
+module_comedi_driver(multiq3_driver);
+
MODULE_AUTHOR("Comedi http://www.comedi.org");
MODULE_DESCRIPTION("Comedi low-level driver");
MODULE_LICENSE("GPL");
diff --git a/drivers/staging/comedi/drivers/ni_6527.c b/drivers/staging/comedi/drivers/ni_6527.c
index 54741c9e1af5..a80c52fb2731 100644
--- a/drivers/staging/comedi/drivers/ni_6527.c
+++ b/drivers/staging/comedi/drivers/ni_6527.c
@@ -78,7 +78,7 @@ Updated: Sat, 25 Jan 2003 13:24:40 -0800
static int ni6527_attach(struct comedi_device *dev,
struct comedi_devconfig *it);
-static int ni6527_detach(struct comedi_device *dev);
+static void ni6527_detach(struct comedi_device *dev);
static struct comedi_driver driver_ni6527 = {
.driver_name = "ni6527",
.module = THIS_MODULE,
@@ -174,22 +174,17 @@ static int ni6527_di_insn_bits(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
- if (insn->n != 2)
- return -EINVAL;
-
data[1] = readb(devpriv->mite->daq_io_addr + Port_Register(0));
data[1] |= readb(devpriv->mite->daq_io_addr + Port_Register(1)) << 8;
data[1] |= readb(devpriv->mite->daq_io_addr + Port_Register(2)) << 16;
- return 2;
+ return insn->n;
}
static int ni6527_do_insn_bits(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
- if (insn->n != 2)
- return -EINVAL;
if (data[0]) {
s->state &= ~data[0];
s->state |= (data[0] & data[1]);
@@ -211,7 +206,7 @@ static int ni6527_do_insn_bits(struct comedi_device *dev,
}
data[1] = s->state;
- return 2;
+ return insn->n;
}
static irqreturn_t ni6527_interrupt(int irq, void *d)
@@ -339,11 +334,8 @@ static int ni6527_intr_insn_bits(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
- if (insn->n < 1)
- return -EINVAL;
-
data[1] = 0;
- return 2;
+ return insn->n;
}
static int ni6527_intr_insn_config(struct comedi_device *dev,
@@ -397,8 +389,8 @@ static int ni6527_attach(struct comedi_device *dev, struct comedi_devconfig *it)
printk(KERN_INFO "comedi board: %s, ID=0x%02x\n", dev->board_name,
readb(devpriv->mite->daq_io_addr + ID_Register));
- ret = alloc_subdevices(dev, 3);
- if (ret < 0)
+ ret = comedi_alloc_subdevices(dev, 3);
+ if (ret)
return ret;
s = dev->subdevices + 0;
@@ -449,19 +441,15 @@ static int ni6527_attach(struct comedi_device *dev, struct comedi_devconfig *it)
return 0;
}
-static int ni6527_detach(struct comedi_device *dev)
+static void ni6527_detach(struct comedi_device *dev)
{
if (devpriv && devpriv->mite && devpriv->mite->daq_io_addr)
writeb(0x00,
devpriv->mite->daq_io_addr + Master_Interrupt_Control);
-
if (dev->irq)
free_irq(dev->irq, dev);
-
if (devpriv && devpriv->mite)
mite_unsetup(devpriv->mite);
-
- return 0;
}
static int ni6527_find_device(struct comedi_device *dev, int bus, int slot)
@@ -493,7 +481,7 @@ static int ni6527_find_device(struct comedi_device *dev, int bus, int slot)
static int __devinit driver_ni6527_pci_probe(struct pci_dev *dev,
const struct pci_device_id *ent)
{
- return comedi_pci_auto_config(dev, driver_ni6527.driver_name);
+ return comedi_pci_auto_config(dev, &driver_ni6527);
}
static void __devexit driver_ni6527_pci_remove(struct pci_dev *dev)
diff --git a/drivers/staging/comedi/drivers/ni_65xx.c b/drivers/staging/comedi/drivers/ni_65xx.c
index 403fc0997d37..bce39f1ea36d 100644
--- a/drivers/staging/comedi/drivers/ni_65xx.c
+++ b/drivers/staging/comedi/drivers/ni_65xx.c
@@ -111,7 +111,7 @@ static inline unsigned Filter_Enable(unsigned port)
static int ni_65xx_attach(struct comedi_device *dev,
struct comedi_devconfig *it);
-static int ni_65xx_detach(struct comedi_device *dev);
+static void ni_65xx_detach(struct comedi_device *dev);
static struct comedi_driver driver_ni_65xx = {
.driver_name = "ni_65xx",
.module = THIS_MODULE,
@@ -415,8 +415,7 @@ static int ni_65xx_dio_insn_bits(struct comedi_device *dev,
const unsigned max_ports_per_bitfield = 5;
unsigned read_bits = 0;
unsigned j;
- if (insn->n != 2)
- return -EINVAL;
+
base_bitfield_channel = CR_CHAN(insn->chanspec);
for (j = 0; j < max_ports_per_bitfield; ++j) {
const unsigned port_offset =
@@ -602,11 +601,8 @@ static int ni_65xx_intr_insn_bits(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
- if (insn->n < 1)
- return -EINVAL;
-
data[1] = 0;
- return 2;
+ return insn->n;
}
static int ni_65xx_intr_insn_config(struct comedi_device *dev,
@@ -678,8 +674,8 @@ static int ni_65xx_attach(struct comedi_device *dev,
printk(KERN_INFO " ID=0x%02x",
readb(private(dev)->mite->daq_io_addr + ID_Register));
- ret = alloc_subdevices(dev, 4);
- if (ret < 0)
+ ret = comedi_alloc_subdevices(dev, 4);
+ if (ret)
return ret;
s = dev->subdevices + 0;
@@ -784,7 +780,7 @@ static int ni_65xx_attach(struct comedi_device *dev,
return 0;
}
-static int ni_65xx_detach(struct comedi_device *dev)
+static void ni_65xx_detach(struct comedi_device *dev)
{
if (private(dev) && private(dev)->mite
&& private(dev)->mite->daq_io_addr) {
@@ -792,10 +788,8 @@ static int ni_65xx_detach(struct comedi_device *dev)
private(dev)->mite->daq_io_addr +
Master_Interrupt_Control);
}
-
if (dev->irq)
free_irq(dev->irq, dev);
-
if (private(dev)) {
unsigned i;
for (i = 0; i < dev->n_subdevices; ++i) {
@@ -805,7 +799,6 @@ static int ni_65xx_detach(struct comedi_device *dev)
if (private(dev)->mite)
mite_unsetup(private(dev)->mite);
}
- return 0;
}
static int ni_65xx_find_device(struct comedi_device *dev, int bus, int slot)
@@ -837,7 +830,7 @@ static int ni_65xx_find_device(struct comedi_device *dev, int bus, int slot)
static int __devinit driver_ni_65xx_pci_probe(struct pci_dev *dev,
const struct pci_device_id *ent)
{
- return comedi_pci_auto_config(dev, driver_ni_65xx.driver_name);
+ return comedi_pci_auto_config(dev, &driver_ni_65xx);
}
static void __devexit driver_ni_65xx_pci_remove(struct pci_dev *dev)
diff --git a/drivers/staging/comedi/drivers/ni_660x.c b/drivers/staging/comedi/drivers/ni_660x.c
index 35f3a4749825..5e863ff343dd 100644
--- a/drivers/staging/comedi/drivers/ni_660x.c
+++ b/drivers/staging/comedi/drivers/ni_660x.c
@@ -458,7 +458,7 @@ static inline const struct ni_660x_board *board(struct comedi_device *dev)
static int ni_660x_attach(struct comedi_device *dev,
struct comedi_devconfig *it);
-static int ni_660x_detach(struct comedi_device *dev);
+static void ni_660x_detach(struct comedi_device *dev);
static void init_tio_chip(struct comedi_device *dev, int chipset);
static void ni_660x_select_pfi_output(struct comedi_device *dev,
unsigned pfi_channel,
@@ -474,7 +474,7 @@ static struct comedi_driver driver_ni_660x = {
static int __devinit driver_ni_660x_pci_probe(struct pci_dev *dev,
const struct pci_device_id *ent)
{
- return comedi_pci_auto_config(dev, driver_ni_660x.driver_name);
+ return comedi_pci_auto_config(dev, &driver_ni_660x);
}
static void __devexit driver_ni_660x_pci_remove(struct pci_dev *dev)
@@ -761,7 +761,7 @@ static inline void ni_660x_write_register(struct comedi_device *dev,
unsigned chip_index, unsigned bits,
enum NI_660x_Register reg)
{
- void *const write_address =
+ void __iomem *write_address =
private(dev)->mite->daq_io_addr + GPCT_OFFSET[chip_index] +
registerData[reg].offset;
@@ -784,7 +784,7 @@ static inline unsigned ni_660x_read_register(struct comedi_device *dev,
unsigned chip_index,
enum NI_660x_Register reg)
{
- void *const read_address =
+ void __iomem *read_address =
private(dev)->mite->daq_io_addr + GPCT_OFFSET[chip_index] +
registerData[reg].offset;
@@ -1093,10 +1093,9 @@ static int ni_660x_attach(struct comedi_device *dev,
printk(KERN_INFO " %s ", dev->board_name);
- dev->n_subdevices = 2 + NI_660X_MAX_NUM_COUNTERS;
-
- if (alloc_subdevices(dev, dev->n_subdevices) < 0)
- return -ENOMEM;
+ ret = comedi_alloc_subdevices(dev, 2 + NI_660X_MAX_NUM_COUNTERS);
+ if (ret)
+ return ret;
s = dev->subdevices + 0;
/* Old GENERAL-PURPOSE COUNTER/TIME (GPCT) subdevice, no longer used */
@@ -1188,14 +1187,10 @@ static int ni_660x_attach(struct comedi_device *dev,
return 0;
}
-static int ni_660x_detach(struct comedi_device *dev)
+static void ni_660x_detach(struct comedi_device *dev)
{
- printk(KERN_INFO "comedi%d: ni_660x: remove\n", dev->minor);
-
- /* Free irq */
if (dev->irq)
free_irq(dev->irq, dev);
-
if (dev->private) {
if (private(dev)->counter_dev)
ni_gpct_device_destroy(private(dev)->counter_dev);
@@ -1204,7 +1199,6 @@ static int ni_660x_detach(struct comedi_device *dev)
mite_unsetup(private(dev)->mite);
}
}
- return 0;
}
static int
@@ -1291,7 +1285,7 @@ static int ni_660x_dio_insn_bits(struct comedi_device *dev,
data[1] =
(ni_660x_read_register(dev, 0,
DIO32Input) >> base_bitfield_channel);
- return 2;
+ return insn->n;
}
static void ni_660x_select_pfi_output(struct comedi_device *dev,
diff --git a/drivers/staging/comedi/drivers/ni_670x.c b/drivers/staging/comedi/drivers/ni_670x.c
index d8d91f90060e..9c57618f2c5b 100644
--- a/drivers/staging/comedi/drivers/ni_670x.c
+++ b/drivers/staging/comedi/drivers/ni_670x.c
@@ -61,43 +61,27 @@ Commands are not supported.
/* Board description*/
struct ni_670x_board {
- unsigned short dev_id;
const char *name;
+ unsigned short dev_id;
unsigned short ao_chans;
- unsigned short ao_bits;
};
static const struct ni_670x_board ni_670x_boards[] = {
{
- .dev_id = 0x2c90,
- .name = "PCI-6703",
- .ao_chans = 16,
- .ao_bits = 16,
- },
- {
- .dev_id = 0x1920,
- .name = "PXI-6704",
- .ao_chans = 32,
- .ao_bits = 16,
- },
- {
- .dev_id = 0x1290,
- .name = "PCI-6704",
- .ao_chans = 32,
- .ao_bits = 16,
- },
-};
-
-static DEFINE_PCI_DEVICE_TABLE(ni_670x_pci_table) = {
- {PCI_DEVICE(PCI_VENDOR_ID_NI, 0x2c90)},
- {PCI_DEVICE(PCI_VENDOR_ID_NI, 0x1920)},
- {0}
+ .name = "PCI-6703",
+ .dev_id = 0x2c90,
+ .ao_chans = 16,
+ }, {
+ .name = "PXI-6704",
+ .dev_id = 0x1920,
+ .ao_chans = 32,
+ }, {
+ .name = "PCI-6704",
+ .dev_id = 0x1290,
+ .ao_chans = 32,
+ },
};
-MODULE_DEVICE_TABLE(pci, ni_670x_pci_table);
-
-#define thisboard ((struct ni_670x_board *)dev->board_ptr)
-
struct ni_670x_private {
struct mite_struct *mite;
@@ -106,168 +90,13 @@ struct ni_670x_private {
unsigned int ao_readback[32];
};
-#define devpriv ((struct ni_670x_private *)dev->private)
-#define n_ni_670x_boards ARRAY_SIZE(ni_670x_boards)
-
-static int ni_670x_attach(struct comedi_device *dev,
- struct comedi_devconfig *it);
-static int ni_670x_detach(struct comedi_device *dev);
-
-static struct comedi_driver driver_ni_670x = {
- .driver_name = "ni_670x",
- .module = THIS_MODULE,
- .attach = ni_670x_attach,
- .detach = ni_670x_detach,
-};
-
-static int __devinit driver_ni_670x_pci_probe(struct pci_dev *dev,
- const struct pci_device_id *ent)
-{
- return comedi_pci_auto_config(dev, driver_ni_670x.driver_name);
-}
-
-static void __devexit driver_ni_670x_pci_remove(struct pci_dev *dev)
-{
- comedi_pci_auto_unconfig(dev);
-}
-
-static struct pci_driver driver_ni_670x_pci_driver = {
- .id_table = ni_670x_pci_table,
- .probe = &driver_ni_670x_pci_probe,
- .remove = __devexit_p(&driver_ni_670x_pci_remove)
-};
-
-static int __init driver_ni_670x_init_module(void)
-{
- int retval;
-
- retval = comedi_driver_register(&driver_ni_670x);
- if (retval < 0)
- return retval;
-
- driver_ni_670x_pci_driver.name = (char *)driver_ni_670x.driver_name;
- return pci_register_driver(&driver_ni_670x_pci_driver);
-}
-
-static void __exit driver_ni_670x_cleanup_module(void)
-{
- pci_unregister_driver(&driver_ni_670x_pci_driver);
- comedi_driver_unregister(&driver_ni_670x);
-}
-
-module_init(driver_ni_670x_init_module);
-module_exit(driver_ni_670x_cleanup_module);
-
static struct comedi_lrange range_0_20mA = { 1, {RANGE_mA(0, 20)} };
-static int ni_670x_find_device(struct comedi_device *dev, int bus, int slot);
-
-static int ni_670x_ao_winsn(struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data);
-static int ni_670x_ao_rinsn(struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data);
-static int ni_670x_dio_insn_bits(struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data);
-static int ni_670x_dio_insn_config(struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_insn *insn,
- unsigned int *data);
-
-static int ni_670x_attach(struct comedi_device *dev,
- struct comedi_devconfig *it)
-{
- struct comedi_subdevice *s;
- int ret;
- int i;
-
- printk(KERN_INFO "comedi%d: ni_670x: ", dev->minor);
-
- ret = alloc_private(dev, sizeof(struct ni_670x_private));
- if (ret < 0)
- return ret;
-
- ret = ni_670x_find_device(dev, it->options[0], it->options[1]);
- if (ret < 0)
- return ret;
-
- ret = mite_setup(devpriv->mite);
- if (ret < 0) {
- printk(KERN_WARNING "error setting up mite\n");
- return ret;
- }
- dev->board_name = thisboard->name;
- dev->irq = mite_irq(devpriv->mite);
- printk(KERN_INFO " %s", dev->board_name);
-
- if (alloc_subdevices(dev, 2) < 0)
- return -ENOMEM;
-
- s = dev->subdevices + 0;
- /* analog output subdevice */
- s->type = COMEDI_SUBD_AO;
- s->subdev_flags = SDF_WRITABLE;
- s->n_chan = thisboard->ao_chans;
- s->maxdata = 0xffff;
- if (s->n_chan == 32) {
- const struct comedi_lrange **range_table_list;
-
- range_table_list = kmalloc(sizeof(struct comedi_lrange *) * 32,
- GFP_KERNEL);
- if (!range_table_list)
- return -ENOMEM;
- s->range_table_list = range_table_list;
- for (i = 0; i < 16; i++) {
- range_table_list[i] = &range_bipolar10;
- range_table_list[16 + i] = &range_0_20mA;
- }
- } else {
- s->range_table = &range_bipolar10;
- }
- s->insn_write = &ni_670x_ao_winsn;
- s->insn_read = &ni_670x_ao_rinsn;
-
- s = dev->subdevices + 1;
- /* digital i/o subdevice */
- s->type = COMEDI_SUBD_DIO;
- s->subdev_flags = SDF_READABLE | SDF_WRITABLE;
- s->n_chan = 8;
- s->maxdata = 1;
- s->range_table = &range_digital;
- s->insn_bits = ni_670x_dio_insn_bits;
- s->insn_config = ni_670x_dio_insn_config;
-
- /* Config of misc registers */
- writel(0x10, devpriv->mite->daq_io_addr + MISC_CONTROL_OFFSET);
- /* Config of ao registers */
- writel(0x00, devpriv->mite->daq_io_addr + AO_CONTROL_OFFSET);
-
- printk(KERN_INFO "attached\n");
-
- return 1;
-}
-
-static int ni_670x_detach(struct comedi_device *dev)
-{
- printk(KERN_INFO "comedi%d: ni_670x: remove\n", dev->minor);
-
- kfree(dev->subdevices[0].range_table_list);
-
- if (dev->private && devpriv->mite)
- mite_unsetup(devpriv->mite);
-
- if (dev->irq)
- free_irq(dev->irq, dev);
-
- return 0;
-}
-
static int ni_670x_ao_winsn(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
+ struct ni_670x_private *devpriv = dev->private;
int i;
int chan = CR_CHAN(insn->chanspec);
@@ -298,6 +127,7 @@ static int ni_670x_ao_rinsn(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
+ struct ni_670x_private *devpriv = dev->private;
int i;
int chan = CR_CHAN(insn->chanspec);
@@ -311,29 +141,29 @@ static int ni_670x_dio_insn_bits(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
- if (insn->n != 2)
- return -EINVAL;
+ struct ni_670x_private *devpriv = dev->private;
+ void __iomem *io_addr = devpriv->mite->daq_io_addr +
+ DIO_PORT0_DATA_OFFSET;
+ unsigned int mask = data[0];
+ unsigned int bits = data[1];
+
+ if (mask) {
+ s->state &= ~mask;
+ s->state |= (bits & mask);
- /* The insn data is a mask in data[0] and the new data
- * in data[1], each channel cooresponding to a bit. */
- if (data[0]) {
- s->state &= ~data[0];
- s->state |= data[0] & data[1];
- writel(s->state,
- devpriv->mite->daq_io_addr + DIO_PORT0_DATA_OFFSET);
+ writel(s->state, io_addr);
}
- /* on return, data[1] contains the value of the digital
- * input lines. */
- data[1] = readl(devpriv->mite->daq_io_addr + DIO_PORT0_DATA_OFFSET);
+ data[1] = readl(io_addr);
- return 2;
+ return insn->n;
}
static int ni_670x_dio_insn_config(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
+ struct ni_670x_private *devpriv = dev->private;
int chan = CR_CHAN(insn->chanspec);
switch (data[0]) {
@@ -359,6 +189,7 @@ static int ni_670x_dio_insn_config(struct comedi_device *dev,
static int ni_670x_find_device(struct comedi_device *dev, int bus, int slot)
{
+ struct ni_670x_private *devpriv = dev->private;
struct mite_struct *mite;
int i;
@@ -371,7 +202,7 @@ static int ni_670x_find_device(struct comedi_device *dev, int bus, int slot)
continue;
}
- for (i = 0; i < n_ni_670x_boards; i++) {
+ for (i = 0; i < ARRAY_SIZE(ni_670x_boards); i++) {
if (mite_device_id(mite) == ni_670x_boards[i].dev_id) {
dev->board_ptr = ni_670x_boards + i;
devpriv->mite = mite;
@@ -380,11 +211,136 @@ static int ni_670x_find_device(struct comedi_device *dev, int bus, int slot)
}
}
}
- printk(KERN_INFO "no device found\n");
+ dev_warn(dev->class_dev, "no device found\n");
mite_list_devices();
return -EIO;
}
+static int ni_670x_attach(struct comedi_device *dev,
+ struct comedi_devconfig *it)
+{
+ const struct ni_670x_board *thisboard;
+ struct ni_670x_private *devpriv;
+ struct comedi_subdevice *s;
+ int ret;
+ int i;
+
+ ret = alloc_private(dev, sizeof(*devpriv));
+ if (ret < 0)
+ return ret;
+ devpriv = dev->private;
+
+ ret = ni_670x_find_device(dev, it->options[0], it->options[1]);
+ if (ret < 0)
+ return ret;
+ thisboard = comedi_board(dev);
+
+ ret = mite_setup(devpriv->mite);
+ if (ret < 0) {
+ dev_warn(dev->class_dev, "error setting up mite\n");
+ return ret;
+ }
+ dev->board_name = thisboard->name;
+ dev->irq = mite_irq(devpriv->mite);
+
+ ret = comedi_alloc_subdevices(dev, 2);
+ if (ret)
+ return ret;
+
+ s = dev->subdevices + 0;
+ /* analog output subdevice */
+ s->type = COMEDI_SUBD_AO;
+ s->subdev_flags = SDF_WRITABLE;
+ s->n_chan = thisboard->ao_chans;
+ s->maxdata = 0xffff;
+ if (s->n_chan == 32) {
+ const struct comedi_lrange **range_table_list;
+
+ range_table_list = kmalloc(sizeof(struct comedi_lrange *) * 32,
+ GFP_KERNEL);
+ if (!range_table_list)
+ return -ENOMEM;
+ s->range_table_list = range_table_list;
+ for (i = 0; i < 16; i++) {
+ range_table_list[i] = &range_bipolar10;
+ range_table_list[16 + i] = &range_0_20mA;
+ }
+ } else {
+ s->range_table = &range_bipolar10;
+ }
+ s->insn_write = &ni_670x_ao_winsn;
+ s->insn_read = &ni_670x_ao_rinsn;
+
+ s = dev->subdevices + 1;
+ /* digital i/o subdevice */
+ s->type = COMEDI_SUBD_DIO;
+ s->subdev_flags = SDF_READABLE | SDF_WRITABLE;
+ s->n_chan = 8;
+ s->maxdata = 1;
+ s->range_table = &range_digital;
+ s->insn_bits = ni_670x_dio_insn_bits;
+ s->insn_config = ni_670x_dio_insn_config;
+
+ /* Config of misc registers */
+ writel(0x10, devpriv->mite->daq_io_addr + MISC_CONTROL_OFFSET);
+ /* Config of ao registers */
+ writel(0x00, devpriv->mite->daq_io_addr + AO_CONTROL_OFFSET);
+
+ dev_info(dev->class_dev, "%s: %s attached\n",
+ dev->driver->driver_name, dev->board_name);
+
+ return 0;
+}
+
+static void ni_670x_detach(struct comedi_device *dev)
+{
+ struct ni_670x_private *devpriv = dev->private;
+ struct comedi_subdevice *s;
+
+ if (dev->n_subdevices) {
+ s = dev->subdevices + 0;
+ if (s)
+ kfree(s->range_table_list);
+ }
+ if (devpriv && devpriv->mite)
+ mite_unsetup(devpriv->mite);
+ if (dev->irq)
+ free_irq(dev->irq, dev);
+}
+
+static struct comedi_driver ni_670x_driver = {
+ .driver_name = "ni_670x",
+ .module = THIS_MODULE,
+ .attach = ni_670x_attach,
+ .detach = ni_670x_detach,
+};
+
+static int __devinit ni_670x_pci_probe(struct pci_dev *dev,
+ const struct pci_device_id *ent)
+{
+ return comedi_pci_auto_config(dev, &ni_670x_driver);
+}
+
+static void __devexit ni_670x_pci_remove(struct pci_dev *dev)
+{
+ comedi_pci_auto_unconfig(dev);
+}
+
+static DEFINE_PCI_DEVICE_TABLE(ni_670x_pci_table) = {
+ { PCI_DEVICE(PCI_VENDOR_ID_NI, 0x2c90) },
+ { PCI_DEVICE(PCI_VENDOR_ID_NI, 0x1920) },
+ { 0 }
+};
+MODULE_DEVICE_TABLE(pci, ni_670x_pci_table);
+
+static struct pci_driver ni_670x_pci_driver = {
+ .name ="ni_670x",
+ .id_table = ni_670x_pci_table,
+ .probe = ni_670x_pci_probe,
+ .remove = __devexit_p(ni_670x_pci_remove),
+};
+module_comedi_pci_driver(ni_670x_driver, ni_670x_pci_driver);
+
MODULE_AUTHOR("Comedi http://www.comedi.org");
MODULE_DESCRIPTION("Comedi low-level driver");
MODULE_LICENSE("GPL");
diff --git a/drivers/staging/comedi/drivers/ni_at_a2150.c b/drivers/staging/comedi/drivers/ni_at_a2150.c
index c25e44c1905e..b53a4286f8cb 100644
--- a/drivers/staging/comedi/drivers/ni_at_a2150.c
+++ b/drivers/staging/comedi/drivers/ni_at_a2150.c
@@ -171,46 +171,13 @@ struct a2150_private {
#define devpriv ((struct a2150_private *)dev->private)
-static int a2150_attach(struct comedi_device *dev, struct comedi_devconfig *it);
-static int a2150_detach(struct comedi_device *dev);
static int a2150_cancel(struct comedi_device *dev, struct comedi_subdevice *s);
-static struct comedi_driver driver_a2150 = {
- .driver_name = "ni_at_a2150",
- .module = THIS_MODULE,
- .attach = a2150_attach,
- .detach = a2150_detach,
-};
-
-static irqreturn_t a2150_interrupt(int irq, void *d);
-static int a2150_ai_cmdtest(struct comedi_device *dev,
- struct comedi_subdevice *s, struct comedi_cmd *cmd);
-static int a2150_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s);
-static int a2150_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data);
static int a2150_get_timing(struct comedi_device *dev, unsigned int *period,
int flags);
-static int a2150_probe(struct comedi_device *dev);
static int a2150_set_chanlist(struct comedi_device *dev,
unsigned int start_channel,
unsigned int num_channels);
-/*
- * A convenient macro that defines init_module() and cleanup_module(),
- * as necessary.
- */
-static int __init driver_a2150_init_module(void)
-{
- return comedi_driver_register(&driver_a2150);
-}
-
-static void __exit driver_a2150_cleanup_module(void)
-{
- comedi_driver_unregister(&driver_a2150);
-}
-
-module_init(driver_a2150_init_module);
-module_exit(driver_a2150_cleanup_module);
-
#ifdef A2150_DEBUG
static void ni_dump_regs(struct comedi_device *dev)
@@ -331,161 +298,6 @@ static irqreturn_t a2150_interrupt(int irq, void *d)
return IRQ_HANDLED;
}
-/* probes board type, returns offset */
-static int a2150_probe(struct comedi_device *dev)
-{
- int status = inw(dev->iobase + STATUS_REG);
- return ID_BITS(status);
-}
-
-static int a2150_attach(struct comedi_device *dev, struct comedi_devconfig *it)
-{
- struct comedi_subdevice *s;
- unsigned long iobase = it->options[0];
- unsigned int irq = it->options[1];
- unsigned int dma = it->options[2];
- static const int timeout = 2000;
- int i;
-
- printk("comedi%d: %s: io 0x%lx", dev->minor, driver_a2150.driver_name,
- iobase);
- if (irq) {
- printk(", irq %u", irq);
- } else {
- printk(", no irq");
- }
- if (dma) {
- printk(", dma %u", dma);
- } else {
- printk(", no dma");
- }
- printk("\n");
-
- /* allocate and initialize dev->private */
- if (alloc_private(dev, sizeof(struct a2150_private)) < 0)
- return -ENOMEM;
-
- if (iobase == 0) {
- printk(" io base address required\n");
- return -EINVAL;
- }
-
- /* check if io addresses are available */
- if (!request_region(iobase, A2150_SIZE, driver_a2150.driver_name)) {
- printk(" I/O port conflict\n");
- return -EIO;
- }
- dev->iobase = iobase;
-
- /* grab our IRQ */
- if (irq) {
- /* check that irq is supported */
- if (irq < 3 || irq == 8 || irq == 13 || irq > 15) {
- printk(" invalid irq line %u\n", irq);
- return -EINVAL;
- }
- if (request_irq(irq, a2150_interrupt, 0,
- driver_a2150.driver_name, dev)) {
- printk("unable to allocate irq %u\n", irq);
- return -EINVAL;
- }
- devpriv->irq_dma_bits |= IRQ_LVL_BITS(irq);
- dev->irq = irq;
- }
- /* initialize dma */
- if (dma) {
- if (dma == 4 || dma > 7) {
- printk(" invalid dma channel %u\n", dma);
- return -EINVAL;
- }
- if (request_dma(dma, driver_a2150.driver_name)) {
- printk(" failed to allocate dma channel %u\n", dma);
- return -EINVAL;
- }
- devpriv->dma = dma;
- devpriv->dma_buffer =
- kmalloc(A2150_DMA_BUFFER_SIZE, GFP_KERNEL | GFP_DMA);
- if (devpriv->dma_buffer == NULL)
- return -ENOMEM;
-
- disable_dma(dma);
- set_dma_mode(dma, DMA_MODE_READ);
-
- devpriv->irq_dma_bits |= DMA_CHAN_BITS(dma);
- }
-
- dev->board_ptr = a2150_boards + a2150_probe(dev);
- dev->board_name = thisboard->name;
-
- if (alloc_subdevices(dev, 1) < 0)
- return -ENOMEM;
-
- /* analog input subdevice */
- s = dev->subdevices + 0;
- dev->read_subdev = s;
- s->type = COMEDI_SUBD_AI;
- s->subdev_flags = SDF_READABLE | SDF_GROUND | SDF_OTHER | SDF_CMD_READ;
- s->n_chan = 4;
- s->len_chanlist = 4;
- s->maxdata = 0xffff;
- s->range_table = &range_a2150;
- s->do_cmd = a2150_ai_cmd;
- s->do_cmdtest = a2150_ai_cmdtest;
- s->insn_read = a2150_ai_rinsn;
- s->cancel = a2150_cancel;
-
- /* need to do this for software counting of completed conversions, to
- * prevent hardware count from stopping acquisition */
- outw(HW_COUNT_DISABLE, dev->iobase + I8253_MODE_REG);
-
- /* set card's irq and dma levels */
- outw(devpriv->irq_dma_bits, dev->iobase + IRQ_DMA_CNTRL_REG);
-
- /* reset and sync adc clock circuitry */
- outw_p(DPD_BIT | APD_BIT, dev->iobase + CONFIG_REG);
- outw_p(DPD_BIT, dev->iobase + CONFIG_REG);
- /* initialize configuration register */
- devpriv->config_bits = 0;
- outw(devpriv->config_bits, dev->iobase + CONFIG_REG);
- /* wait until offset calibration is done, then enable analog inputs */
- for (i = 0; i < timeout; i++) {
- if ((DCAL_BIT & inw(dev->iobase + STATUS_REG)) == 0)
- break;
- udelay(1000);
- }
- if (i == timeout) {
- printk
- (" timed out waiting for offset calibration to complete\n");
- return -ETIME;
- }
- devpriv->config_bits |= ENABLE0_BIT | ENABLE1_BIT;
- outw(devpriv->config_bits, dev->iobase + CONFIG_REG);
-
- return 0;
-};
-
-static int a2150_detach(struct comedi_device *dev)
-{
- printk("comedi%d: %s: remove\n", dev->minor, driver_a2150.driver_name);
-
- /* only free stuff if it has been allocated by _attach */
- if (dev->iobase) {
- /* put board in power-down mode */
- outw(APD_BIT | DPD_BIT, dev->iobase + CONFIG_REG);
- release_region(dev->iobase, A2150_SIZE);
- }
-
- if (dev->irq)
- free_irq(dev->irq, dev);
- if (devpriv) {
- if (devpriv->dma)
- free_dma(devpriv->dma);
- kfree(devpriv->dma_buffer);
- }
-
- return 0;
-};
-
static int a2150_cancel(struct comedi_device *dev, struct comedi_subdevice *s)
{
/* disable dma on card */
@@ -539,7 +351,10 @@ static int a2150_ai_cmdtest(struct comedi_device *dev,
if (err)
return 1;
- /* step 2: make sure trigger sources are unique and mutually compatible */
+ /*
+ * step 2: make sure trigger sources are unique and mutually
+ * compatible
+ */
if (cmd->start_src != TRIG_NOW && cmd->start_src != TRIG_EXT)
err++;
@@ -771,7 +586,10 @@ static int a2150_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
/* start acquisition for soft trigger */
outw(0, dev->iobase + FIFO_START_REG);
- /* there is a 35.6 sample delay for data to get through the antialias filter */
+ /*
+ * there is a 35.6 sample delay for data to get through the
+ * antialias filter
+ */
for (n = 0; n < filter_delay; n++) {
for (i = 0; i < timeout; i++) {
if (inw(dev->iobase + STATUS_REG) & FNE_BIT)
@@ -812,8 +630,10 @@ static int a2150_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
return n;
}
-/* sets bits in devpriv->clock_bits to nearest approximation of requested period,
- * adjusts requested period to actual timing. */
+/*
+ * sets bits in devpriv->clock_bits to nearest approximation of requested
+ * period, adjusts requested period to actual timing.
+ */
static int a2150_get_timing(struct comedi_device *dev, unsigned int *period,
int flags)
{
@@ -920,6 +740,164 @@ static int a2150_set_chanlist(struct comedi_device *dev,
return 0;
}
+/* probes board type, returns offset */
+static int a2150_probe(struct comedi_device *dev)
+{
+ int status = inw(dev->iobase + STATUS_REG);
+ return ID_BITS(status);
+}
+
+static int a2150_attach(struct comedi_device *dev, struct comedi_devconfig *it)
+{
+ struct comedi_subdevice *s;
+ unsigned long iobase = it->options[0];
+ unsigned int irq = it->options[1];
+ unsigned int dma = it->options[2];
+ static const int timeout = 2000;
+ int i;
+ int ret;
+
+ printk("comedi%d: %s: io 0x%lx", dev->minor, dev->driver->driver_name,
+ iobase);
+ if (irq) {
+ printk(", irq %u", irq);
+ } else {
+ printk(", no irq");
+ }
+ if (dma) {
+ printk(", dma %u", dma);
+ } else {
+ printk(", no dma");
+ }
+ printk("\n");
+
+ /* allocate and initialize dev->private */
+ if (alloc_private(dev, sizeof(struct a2150_private)) < 0)
+ return -ENOMEM;
+
+ if (iobase == 0) {
+ printk(" io base address required\n");
+ return -EINVAL;
+ }
+
+ /* check if io addresses are available */
+ if (!request_region(iobase, A2150_SIZE, dev->driver->driver_name)) {
+ printk(" I/O port conflict\n");
+ return -EIO;
+ }
+ dev->iobase = iobase;
+
+ /* grab our IRQ */
+ if (irq) {
+ /* check that irq is supported */
+ if (irq < 3 || irq == 8 || irq == 13 || irq > 15) {
+ printk(" invalid irq line %u\n", irq);
+ return -EINVAL;
+ }
+ if (request_irq(irq, a2150_interrupt, 0,
+ dev->driver->driver_name, dev)) {
+ printk("unable to allocate irq %u\n", irq);
+ return -EINVAL;
+ }
+ devpriv->irq_dma_bits |= IRQ_LVL_BITS(irq);
+ dev->irq = irq;
+ }
+ /* initialize dma */
+ if (dma) {
+ if (dma == 4 || dma > 7) {
+ printk(" invalid dma channel %u\n", dma);
+ return -EINVAL;
+ }
+ if (request_dma(dma, dev->driver->driver_name)) {
+ printk(" failed to allocate dma channel %u\n", dma);
+ return -EINVAL;
+ }
+ devpriv->dma = dma;
+ devpriv->dma_buffer =
+ kmalloc(A2150_DMA_BUFFER_SIZE, GFP_KERNEL | GFP_DMA);
+ if (devpriv->dma_buffer == NULL)
+ return -ENOMEM;
+
+ disable_dma(dma);
+ set_dma_mode(dma, DMA_MODE_READ);
+
+ devpriv->irq_dma_bits |= DMA_CHAN_BITS(dma);
+ }
+
+ dev->board_ptr = a2150_boards + a2150_probe(dev);
+ dev->board_name = thisboard->name;
+
+ ret = comedi_alloc_subdevices(dev, 1);
+ if (ret)
+ return ret;
+
+ /* analog input subdevice */
+ s = dev->subdevices + 0;
+ dev->read_subdev = s;
+ s->type = COMEDI_SUBD_AI;
+ s->subdev_flags = SDF_READABLE | SDF_GROUND | SDF_OTHER | SDF_CMD_READ;
+ s->n_chan = 4;
+ s->len_chanlist = 4;
+ s->maxdata = 0xffff;
+ s->range_table = &range_a2150;
+ s->do_cmd = a2150_ai_cmd;
+ s->do_cmdtest = a2150_ai_cmdtest;
+ s->insn_read = a2150_ai_rinsn;
+ s->cancel = a2150_cancel;
+
+ /* need to do this for software counting of completed conversions, to
+ * prevent hardware count from stopping acquisition */
+ outw(HW_COUNT_DISABLE, dev->iobase + I8253_MODE_REG);
+
+ /* set card's irq and dma levels */
+ outw(devpriv->irq_dma_bits, dev->iobase + IRQ_DMA_CNTRL_REG);
+
+ /* reset and sync adc clock circuitry */
+ outw_p(DPD_BIT | APD_BIT, dev->iobase + CONFIG_REG);
+ outw_p(DPD_BIT, dev->iobase + CONFIG_REG);
+ /* initialize configuration register */
+ devpriv->config_bits = 0;
+ outw(devpriv->config_bits, dev->iobase + CONFIG_REG);
+ /* wait until offset calibration is done, then enable analog inputs */
+ for (i = 0; i < timeout; i++) {
+ if ((DCAL_BIT & inw(dev->iobase + STATUS_REG)) == 0)
+ break;
+ udelay(1000);
+ }
+ if (i == timeout) {
+ printk
+ (" timed out waiting for offset calibration to complete\n");
+ return -ETIME;
+ }
+ devpriv->config_bits |= ENABLE0_BIT | ENABLE1_BIT;
+ outw(devpriv->config_bits, dev->iobase + CONFIG_REG);
+
+ return 0;
+};
+
+static void a2150_detach(struct comedi_device *dev)
+{
+ if (dev->iobase) {
+ outw(APD_BIT | DPD_BIT, dev->iobase + CONFIG_REG);
+ release_region(dev->iobase, A2150_SIZE);
+ }
+ if (dev->irq)
+ free_irq(dev->irq, dev);
+ if (devpriv) {
+ if (devpriv->dma)
+ free_dma(devpriv->dma);
+ kfree(devpriv->dma_buffer);
+ }
+};
+
+static struct comedi_driver ni_at_a2150_driver = {
+ .driver_name = "ni_at_a2150",
+ .module = THIS_MODULE,
+ .attach = a2150_attach,
+ .detach = a2150_detach,
+};
+module_comedi_driver(ni_at_a2150_driver);
+
MODULE_AUTHOR("Comedi http://www.comedi.org");
MODULE_DESCRIPTION("Comedi low-level driver");
MODULE_LICENSE("GPL");
diff --git a/drivers/staging/comedi/drivers/ni_at_ao.c b/drivers/staging/comedi/drivers/ni_at_ao.c
index 138dcc2275ab..62c8c44a8d28 100644
--- a/drivers/staging/comedi/drivers/ni_at_ao.c
+++ b/drivers/staging/comedi/drivers/ni_at_ao.c
@@ -157,19 +157,6 @@ struct atao_board {
int n_ao_chans;
};
-static const struct atao_board atao_boards[] = {
- {
- .name = "ai-ao-6",
- .n_ao_chans = 6,
- },
- {
- .name = "ai-ao-10",
- .n_ao_chans = 10,
- },
-};
-
-#define thisboard ((struct atao_board *)dev->board_ptr)
-
struct atao_private {
unsigned short cfg1;
@@ -182,133 +169,6 @@ struct atao_private {
#define devpriv ((struct atao_private *)dev->private)
-static int atao_attach(struct comedi_device *dev, struct comedi_devconfig *it);
-static int atao_detach(struct comedi_device *dev);
-static struct comedi_driver driver_atao = {
- .driver_name = "ni_at_ao",
- .module = THIS_MODULE,
- .attach = atao_attach,
- .detach = atao_detach,
- .board_name = &atao_boards[0].name,
- .offset = sizeof(struct atao_board),
- .num_names = ARRAY_SIZE(atao_boards),
-};
-
-static int __init driver_atao_init_module(void)
-{
- return comedi_driver_register(&driver_atao);
-}
-
-static void __exit driver_atao_cleanup_module(void)
-{
- comedi_driver_unregister(&driver_atao);
-}
-
-module_init(driver_atao_init_module);
-module_exit(driver_atao_cleanup_module);
-
-static void atao_reset(struct comedi_device *dev);
-
-static int atao_ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data);
-static int atao_ao_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data);
-static int atao_dio_insn_bits(struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data);
-static int atao_dio_insn_config(struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data);
-static int atao_calib_insn_read(struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data);
-static int atao_calib_insn_write(struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data);
-
-static int atao_attach(struct comedi_device *dev, struct comedi_devconfig *it)
-{
- struct comedi_subdevice *s;
- unsigned long iobase;
- int ao_unipolar;
-
- iobase = it->options[0];
- if (iobase == 0)
- iobase = 0x1c0;
- ao_unipolar = it->options[3];
-
- printk(KERN_INFO "comedi%d: ni_at_ao: 0x%04lx", dev->minor, iobase);
-
- if (!request_region(iobase, ATAO_SIZE, "ni_at_ao")) {
- printk(" I/O port conflict\n");
- return -EIO;
- }
- dev->iobase = iobase;
-
- /* dev->board_ptr = atao_probe(dev); */
-
- dev->board_name = thisboard->name;
-
- if (alloc_private(dev, sizeof(struct atao_private)) < 0)
- return -ENOMEM;
-
- if (alloc_subdevices(dev, 4) < 0)
- return -ENOMEM;
-
- s = dev->subdevices + 0;
- /* analog output subdevice */
- s->type = COMEDI_SUBD_AO;
- s->subdev_flags = SDF_WRITABLE;
- s->n_chan = thisboard->n_ao_chans;
- s->maxdata = (1 << 12) - 1;
- if (ao_unipolar)
- s->range_table = &range_unipolar10;
- else
- s->range_table = &range_bipolar10;
- s->insn_write = &atao_ao_winsn;
- s->insn_read = &atao_ao_rinsn;
-
- s = dev->subdevices + 1;
- /* digital i/o subdevice */
- s->type = COMEDI_SUBD_DIO;
- s->subdev_flags = SDF_READABLE | SDF_WRITABLE;
- s->n_chan = 8;
- s->maxdata = 1;
- s->range_table = &range_digital;
- s->insn_bits = atao_dio_insn_bits;
- s->insn_config = atao_dio_insn_config;
-
- s = dev->subdevices + 2;
- /* caldac subdevice */
- s->type = COMEDI_SUBD_CALIB;
- s->subdev_flags = SDF_WRITABLE | SDF_INTERNAL;
- s->n_chan = 21;
- s->maxdata = 0xff;
- s->insn_read = atao_calib_insn_read;
- s->insn_write = atao_calib_insn_write;
-
- s = dev->subdevices + 3;
- /* eeprom subdevice */
- /* s->type=COMEDI_SUBD_EEPROM; */
- s->type = COMEDI_SUBD_UNUSED;
-
- atao_reset(dev);
-
- printk(KERN_INFO "\n");
-
- return 0;
-}
-
-static int atao_detach(struct comedi_device *dev)
-{
- printk(KERN_INFO "comedi%d: atao: remove\n", dev->minor);
-
- if (dev->iobase)
- release_region(dev->iobase, ATAO_SIZE);
-
- return 0;
-}
-
static void atao_reset(struct comedi_device *dev)
{
/* This is the reset sequence described in the manual */
@@ -379,9 +239,6 @@ static int atao_dio_insn_bits(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
- if (insn->n != 2)
- return -EINVAL;
-
if (data[0]) {
s->state &= ~data[0];
s->state |= data[0] & data[1];
@@ -390,7 +247,7 @@ static int atao_dio_insn_bits(struct comedi_device *dev,
data[1] = inw(dev->iobase + ATAO_DIN);
- return 2;
+ return insn->n;
}
static int atao_dio_insn_config(struct comedi_device *dev,
@@ -471,6 +328,107 @@ static int atao_calib_insn_write(struct comedi_device *dev,
return insn->n;
}
+static int atao_attach(struct comedi_device *dev, struct comedi_devconfig *it)
+{
+ const struct atao_board *board = comedi_board(dev);
+ struct comedi_subdevice *s;
+ unsigned long iobase;
+ int ao_unipolar;
+ int ret;
+
+ iobase = it->options[0];
+ if (iobase == 0)
+ iobase = 0x1c0;
+ ao_unipolar = it->options[3];
+
+ printk(KERN_INFO "comedi%d: ni_at_ao: 0x%04lx", dev->minor, iobase);
+
+ if (!request_region(iobase, ATAO_SIZE, "ni_at_ao")) {
+ printk(" I/O port conflict\n");
+ return -EIO;
+ }
+ dev->iobase = iobase;
+
+ dev->board_name = board->name;
+
+ if (alloc_private(dev, sizeof(struct atao_private)) < 0)
+ return -ENOMEM;
+
+ ret = comedi_alloc_subdevices(dev, 4);
+ if (ret)
+ return ret;
+
+ s = dev->subdevices + 0;
+ /* analog output subdevice */
+ s->type = COMEDI_SUBD_AO;
+ s->subdev_flags = SDF_WRITABLE;
+ s->n_chan = board->n_ao_chans;
+ s->maxdata = (1 << 12) - 1;
+ if (ao_unipolar)
+ s->range_table = &range_unipolar10;
+ else
+ s->range_table = &range_bipolar10;
+ s->insn_write = &atao_ao_winsn;
+ s->insn_read = &atao_ao_rinsn;
+
+ s = dev->subdevices + 1;
+ /* digital i/o subdevice */
+ s->type = COMEDI_SUBD_DIO;
+ s->subdev_flags = SDF_READABLE | SDF_WRITABLE;
+ s->n_chan = 8;
+ s->maxdata = 1;
+ s->range_table = &range_digital;
+ s->insn_bits = atao_dio_insn_bits;
+ s->insn_config = atao_dio_insn_config;
+
+ s = dev->subdevices + 2;
+ /* caldac subdevice */
+ s->type = COMEDI_SUBD_CALIB;
+ s->subdev_flags = SDF_WRITABLE | SDF_INTERNAL;
+ s->n_chan = 21;
+ s->maxdata = 0xff;
+ s->insn_read = atao_calib_insn_read;
+ s->insn_write = atao_calib_insn_write;
+
+ s = dev->subdevices + 3;
+ /* eeprom subdevice */
+ /* s->type=COMEDI_SUBD_EEPROM; */
+ s->type = COMEDI_SUBD_UNUSED;
+
+ atao_reset(dev);
+
+ printk(KERN_INFO "\n");
+
+ return 0;
+}
+
+static void atao_detach(struct comedi_device *dev)
+{
+ if (dev->iobase)
+ release_region(dev->iobase, ATAO_SIZE);
+}
+
+static const struct atao_board atao_boards[] = {
+ {
+ .name = "ai-ao-6",
+ .n_ao_chans = 6,
+ }, {
+ .name = "ai-ao-10",
+ .n_ao_chans = 10,
+ },
+};
+
+static struct comedi_driver ni_at_ao_driver = {
+ .driver_name = "ni_at_ao",
+ .module = THIS_MODULE,
+ .attach = atao_attach,
+ .detach = atao_detach,
+ .board_name = &atao_boards[0].name,
+ .offset = sizeof(struct atao_board),
+ .num_names = ARRAY_SIZE(atao_boards),
+};
+module_comedi_driver(ni_at_ao_driver);
+
MODULE_AUTHOR("Comedi http://www.comedi.org");
MODULE_DESCRIPTION("Comedi low-level driver");
MODULE_LICENSE("GPL");
diff --git a/drivers/staging/comedi/drivers/ni_atmio.c b/drivers/staging/comedi/drivers/ni_atmio.c
index 647c228abfbf..6448373878ed 100644
--- a/drivers/staging/comedi/drivers/ni_atmio.c
+++ b/drivers/staging/comedi/drivers/ni_atmio.c
@@ -343,49 +343,8 @@ static struct pnp_device_id device_ids[] = {
MODULE_DEVICE_TABLE(pnp, device_ids);
-static int ni_atmio_attach(struct comedi_device *dev,
- struct comedi_devconfig *it);
-static int ni_atmio_detach(struct comedi_device *dev);
-static struct comedi_driver driver_atmio = {
- .driver_name = "ni_atmio",
- .module = THIS_MODULE,
- .attach = ni_atmio_attach,
- .detach = ni_atmio_detach,
-};
-
-static int __init driver_atmio_init_module(void)
-{
- return comedi_driver_register(&driver_atmio);
-}
-
-static void __exit driver_atmio_cleanup_module(void)
-{
- comedi_driver_unregister(&driver_atmio);
-}
-
-module_init(driver_atmio_init_module);
-module_exit(driver_atmio_cleanup_module);
-
#include "ni_mio_common.c"
-static int ni_getboardtype(struct comedi_device *dev);
-
-/* clean up allocated resources */
-static int ni_atmio_detach(struct comedi_device *dev)
-{
- mio_common_detach(dev);
-
- if (dev->iobase)
- release_region(dev->iobase, NI_SIZE);
- if (dev->irq)
- free_irq(dev->irq, dev);
-
- if (devpriv->isapnp_dev)
- pnp_device_detach(devpriv->isapnp_dev);
-
- return 0;
-}
-
static int ni_isapnp_find_board(struct pnp_dev **dev)
{
struct pnp_dev *isapnp_dev = NULL;
@@ -424,6 +383,26 @@ static int ni_isapnp_find_board(struct pnp_dev **dev)
return 0;
}
+static int ni_getboardtype(struct comedi_device *dev)
+{
+ int device_id = ni_read_eeprom(dev, 511);
+ int i;
+
+ for (i = 0; i < n_ni_boards; i++) {
+ if (ni_boards[i].device_id == device_id)
+ return i;
+
+ }
+ if (device_id == 255)
+ printk(" can't find board\n");
+ else if (device_id == 0)
+ printk(" EEPROM read error (?) or device not found\n");
+ else
+ printk(" unknown device ID %d -- contact author\n", device_id);
+
+ return -1;
+}
+
static int ni_atmio_attach(struct comedi_device *dev,
struct comedi_devconfig *it)
{
@@ -518,22 +497,21 @@ static int ni_atmio_attach(struct comedi_device *dev,
return 0;
}
-static int ni_getboardtype(struct comedi_device *dev)
+static void ni_atmio_detach(struct comedi_device *dev)
{
- int device_id = ni_read_eeprom(dev, 511);
- int i;
-
- for (i = 0; i < n_ni_boards; i++) {
- if (ni_boards[i].device_id == device_id)
- return i;
-
- }
- if (device_id == 255)
- printk(" can't find board\n");
- else if (device_id == 0)
- printk(" EEPROM read error (?) or device not found\n");
- else
- printk(" unknown device ID %d -- contact author\n", device_id);
-
- return -1;
+ mio_common_detach(dev);
+ if (dev->iobase)
+ release_region(dev->iobase, NI_SIZE);
+ if (dev->irq)
+ free_irq(dev->irq, dev);
+ if (devpriv->isapnp_dev)
+ pnp_device_detach(devpriv->isapnp_dev);
}
+
+static struct comedi_driver ni_atmio_driver = {
+ .driver_name = "ni_atmio",
+ .module = THIS_MODULE,
+ .attach = ni_atmio_attach,
+ .detach = ni_atmio_detach,
+};
+module_comedi_driver(ni_atmio_driver);
diff --git a/drivers/staging/comedi/drivers/ni_atmio16d.c b/drivers/staging/comedi/drivers/ni_atmio16d.c
index 285b933551ab..2c78d3dd242a 100644
--- a/drivers/staging/comedi/drivers/ni_atmio16d.c
+++ b/drivers/staging/comedi/drivers/ni_atmio16d.c
@@ -110,60 +110,6 @@ struct atmio16_board_t {
int has_8255;
};
-static const struct atmio16_board_t atmio16_boards[] = {
- {
- .name = "atmio16",
- .has_8255 = 0,
- },
- {
- .name = "atmio16d",
- .has_8255 = 1,
- },
-};
-
-#define n_atmio16_boards ARRAY_SIZE(atmio16_boards)
-
-#define boardtype ((const struct atmio16_board_t *)dev->board_ptr)
-
-/* function prototypes */
-static int atmio16d_attach(struct comedi_device *dev,
- struct comedi_devconfig *it);
-static int atmio16d_detach(struct comedi_device *dev);
-static irqreturn_t atmio16d_interrupt(int irq, void *d);
-static int atmio16d_ai_cmdtest(struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_cmd *cmd);
-static int atmio16d_ai_cmd(struct comedi_device *dev,
- struct comedi_subdevice *s);
-static int atmio16d_ai_cancel(struct comedi_device *dev,
- struct comedi_subdevice *s);
-static void reset_counters(struct comedi_device *dev);
-static void reset_atmio16d(struct comedi_device *dev);
-
-/* main driver struct */
-static struct comedi_driver driver_atmio16d = {
- .driver_name = "atmio16",
- .module = THIS_MODULE,
- .attach = atmio16d_attach,
- .detach = atmio16d_detach,
- .board_name = &atmio16_boards[0].name,
- .num_names = n_atmio16_boards,
- .offset = sizeof(struct atmio16_board_t),
-};
-
-static int __init driver_atmio16d_init_module(void)
-{
- return comedi_driver_register(&driver_atmio16d);
-}
-
-static void __exit driver_atmio16d_cleanup_module(void)
-{
- comedi_driver_unregister(&driver_atmio16d);
-}
-
-module_init(driver_atmio16d_init_module);
-module_exit(driver_atmio16d_cleanup_module);
-
/* range structs */
static const struct comedi_lrange range_atmio16d_ai_10_bipolar = { 4, {
BIP_RANGE
@@ -290,10 +236,6 @@ static irqreturn_t atmio16d_interrupt(int irq, void *d)
struct comedi_device *dev = d;
struct comedi_subdevice *s = dev->subdevices + 0;
-#ifdef DEBUG1
- printk(KERN_DEBUG "atmio16d_interrupt!\n");
-#endif
-
comedi_buf_put(s->async, inw(dev->iobase + AD_FIFO_REG));
comedi_event(dev, s);
@@ -305,9 +247,7 @@ static int atmio16d_ai_cmdtest(struct comedi_device *dev,
struct comedi_cmd *cmd)
{
int err = 0, tmp;
-#ifdef DEBUG1
- printk(KERN_DEBUG "atmio16d_ai_cmdtest\n");
-#endif
+
/* make sure triggers are valid */
tmp = cmd->start_src;
cmd->start_src &= TRIG_NOW;
@@ -409,9 +349,7 @@ static int atmio16d_ai_cmd(struct comedi_device *dev,
unsigned int timer, base_clock;
unsigned int sample_count, tmp, chan, gain;
int i;
-#ifdef DEBUG1
- printk(KERN_DEBUG "atmio16d_ai_cmd\n");
-#endif
+
/* This is slowly becoming a working command interface. *
* It is still uber-experimental */
@@ -571,9 +509,6 @@ static int atmio16d_ai_insn_read(struct comedi_device *dev,
int gain;
int status;
-#ifdef DEBUG1
- printk(KERN_DEBUG "atmio16d_ai_insn_read\n");
-#endif
chan = CR_CHAN(insn->chanspec);
gain = CR_RANGE(insn->chanspec);
@@ -592,9 +527,6 @@ static int atmio16d_ai_insn_read(struct comedi_device *dev,
for (t = 0; t < ATMIO16D_TIMEOUT; t++) {
/* check conversion status */
status = inw(dev->iobase + STAT_REG);
-#ifdef DEBUG1
- printk(KERN_DEBUG "status=%x\n", status);
-#endif
if (status & STAT_AD_CONVAVAIL) {
/* read the data now */
data[i] = inw(dev->iobase + AD_FIFO_REG);
@@ -626,9 +558,6 @@ static int atmio16d_ao_insn_read(struct comedi_device *dev,
struct comedi_insn *insn, unsigned int *data)
{
int i;
-#ifdef DEBUG1
- printk(KERN_DEBUG "atmio16d_ao_insn_read\n");
-#endif
for (i = 0; i < insn->n; i++)
data[i] = devpriv->ao_readback[CR_CHAN(insn->chanspec)];
@@ -642,9 +571,6 @@ static int atmio16d_ao_insn_write(struct comedi_device *dev,
int i;
int chan;
int d;
-#ifdef DEBUG1
- printk(KERN_DEBUG "atmio16d_ao_insn_write\n");
-#endif
chan = CR_CHAN(insn->chanspec);
@@ -673,9 +599,6 @@ static int atmio16d_dio_insn_bits(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
- if (insn->n != 2)
- return -EINVAL;
-
if (data[0]) {
s->state &= ~data[0];
s->state |= (data[0] | data[1]);
@@ -683,7 +606,7 @@ static int atmio16d_dio_insn_bits(struct comedi_device *dev,
}
data[1] = inw(dev->iobase + MIO_16_DIG_IN_REG);
- return 2;
+ return insn->n;
}
static int atmio16d_dio_insn_config(struct comedi_device *dev,
@@ -745,6 +668,7 @@ static int atmio16d_dio_insn_config(struct comedi_device *dev,
static int atmio16d_attach(struct comedi_device *dev,
struct comedi_devconfig *it)
{
+ const struct atmio16_board_t *board = comedi_board(dev);
unsigned int irq;
unsigned long iobase;
int ret;
@@ -760,11 +684,10 @@ static int atmio16d_attach(struct comedi_device *dev,
}
dev->iobase = iobase;
- /* board name */
- dev->board_name = boardtype->name;
+ dev->board_name = board->name;
- ret = alloc_subdevices(dev, 4);
- if (ret < 0)
+ ret = comedi_alloc_subdevices(dev, 4);
+ if (ret)
return ret;
ret = alloc_private(dev, sizeof(struct atmio16d_private));
@@ -863,7 +786,7 @@ static int atmio16d_attach(struct comedi_device *dev,
/* 8255 subdevice */
s++;
- if (boardtype->has_8255)
+ if (board->has_8255)
subdev_8255_init(dev, s, NULL, dev->iobase);
else
s->type = COMEDI_SUBD_UNUSED;
@@ -881,24 +804,40 @@ static int atmio16d_attach(struct comedi_device *dev,
return 0;
}
-static int atmio16d_detach(struct comedi_device *dev)
+static void atmio16d_detach(struct comedi_device *dev)
{
- printk(KERN_INFO "comedi%d: atmio16d: remove\n", dev->minor);
+ const struct atmio16_board_t *board = comedi_board(dev);
- if (dev->subdevices && boardtype->has_8255)
+ if (dev->subdevices && board->has_8255)
subdev_8255_cleanup(dev, dev->subdevices + 3);
-
if (dev->irq)
free_irq(dev->irq, dev);
-
reset_atmio16d(dev);
-
if (dev->iobase)
release_region(dev->iobase, ATMIO16D_SIZE);
-
- return 0;
}
+static const struct atmio16_board_t atmio16_boards[] = {
+ {
+ .name = "atmio16",
+ .has_8255 = 0,
+ }, {
+ .name = "atmio16d",
+ .has_8255 = 1,
+ },
+};
+
+static struct comedi_driver atmio16d_driver = {
+ .driver_name = "atmio16",
+ .module = THIS_MODULE,
+ .attach = atmio16d_attach,
+ .detach = atmio16d_detach,
+ .board_name = &atmio16_boards[0].name,
+ .num_names = ARRAY_SIZE(atmio16_boards),
+ .offset = sizeof(struct atmio16_board_t),
+};
+module_comedi_driver(atmio16d_driver);
+
MODULE_AUTHOR("Comedi http://www.comedi.org");
MODULE_DESCRIPTION("Comedi low-level driver");
MODULE_LICENSE("GPL");
diff --git a/drivers/staging/comedi/drivers/ni_daq_700.c b/drivers/staging/comedi/drivers/ni_daq_700.c
index e2420123db87..83016b411851 100644
--- a/drivers/staging/comedi/drivers/ni_daq_700.c
+++ b/drivers/staging/comedi/drivers/ni_daq_700.c
@@ -37,8 +37,6 @@ port, bit 0; channel 8 corresponds to the input port, bit 0.
Direction configuration: channels 0-7 output, 8-15 input (8225 device
emu as port A output, port B input, port C N/A).
-
-IRQ is assigned but not used.
*/
#include <linux/interrupt.h>
@@ -53,111 +51,13 @@ IRQ is assigned but not used.
static struct pcmcia_device *pcmcia_cur_dev;
-#define DIO700_SIZE 8 /* size of io region used by board */
-
-static int dio700_attach(struct comedi_device *dev,
- struct comedi_devconfig *it);
-static int dio700_detach(struct comedi_device *dev);
-
-enum dio700_bustype { pcmcia_bustype };
-
struct dio700_board {
const char *name;
- int device_id; /* device id for pcmcia board */
- enum dio700_bustype bustype; /* PCMCIA */
- int have_dio; /* have daqcard-700 dio */
- /* function pointers so we can use inb/outb or readb/writeb */
- /* as appropriate */
- unsigned int (*read_byte) (unsigned int address);
- void (*write_byte) (unsigned int byte, unsigned int address);
-};
-
-static const struct dio700_board dio700_boards[] = {
- {
- .name = "daqcard-700",
- /* 0x10b is manufacturer id, 0x4743 is device id */
- .device_id = 0x4743,
- .bustype = pcmcia_bustype,
- .have_dio = 1,
- },
- {
- .name = "ni_daq_700",
- /* 0x10b is manufacturer id, 0x4743 is device id */
- .device_id = 0x4743,
- .bustype = pcmcia_bustype,
- .have_dio = 1,
- },
};
-/*
- * Useful for shorthand access to the particular board structure
- */
-#define thisboard ((const struct dio700_board *)dev->board_ptr)
-
-struct dio700_private {
-
- int data; /* number of data points left to be taken */
-};
-
-#define devpriv ((struct dio700_private *)dev->private)
-
-static struct comedi_driver driver_dio700 = {
- .driver_name = "ni_daq_700",
- .module = THIS_MODULE,
- .attach = dio700_attach,
- .detach = dio700_detach,
- .num_names = ARRAY_SIZE(dio700_boards),
- .board_name = &dio700_boards[0].name,
- .offset = sizeof(struct dio700_board),
-};
-
-/* the real driver routines */
-
-#define _700_SIZE 8
-
-#define _700_DATA 0
-
#define DIO_W 0x04
#define DIO_R 0x05
-struct subdev_700_struct {
- unsigned long cb_arg;
- int (*cb_func) (int, int, int, unsigned long);
- int have_irq;
-};
-
-#define CALLBACK_ARG (((struct subdev_700_struct *)s->private)->cb_arg)
-#define CALLBACK_FUNC (((struct subdev_700_struct *)s->private)->cb_func)
-#define subdevpriv ((struct subdev_700_struct *)s->private)
-
-static void do_config(struct comedi_device *dev, struct comedi_subdevice *s);
-
-void subdev_700_interrupt(struct comedi_device *dev, struct comedi_subdevice *s)
-{
- short d;
-
- d = CALLBACK_FUNC(0, _700_DATA, 0, CALLBACK_ARG);
-
- comedi_buf_put(s->async, d);
- s->async->events |= COMEDI_CB_EOS;
-
- comedi_event(dev, s);
-}
-EXPORT_SYMBOL(subdev_700_interrupt);
-
-static int subdev_700_cb(int dir, int port, int data, unsigned long arg)
-{
- /* port is always A for output and B for input (8255 emu) */
- unsigned long iobase = arg;
-
- if (dir) {
- outb(data, iobase + DIO_W);
- return 0;
- } else {
- return inb(iobase + DIO_R);
- }
-}
-
static int subdev_700_insn(struct comedi_device *dev,
struct comedi_subdevice *s, struct comedi_insn *insn,
unsigned int *data)
@@ -167,20 +67,20 @@ static int subdev_700_insn(struct comedi_device *dev,
s->state |= (data[0] & data[1]);
if (data[0] & 0xff)
- CALLBACK_FUNC(1, _700_DATA, s->state & 0xff,
- CALLBACK_ARG);
+ outb(s->state & 0xff, dev->iobase + DIO_W);
}
data[1] = s->state & 0xff;
- data[1] |= CALLBACK_FUNC(0, _700_DATA, 0, CALLBACK_ARG) << 8;
+ data[1] |= inb(dev->iobase + DIO_R);
- return 2;
+ return insn->n;
}
static int subdev_700_insn_config(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
+ unsigned int chan = 1 << CR_CHAN(insn->chanspec);
switch (data[0]) {
case INSN_CONFIG_DIO_INPUT:
@@ -188,303 +88,82 @@ static int subdev_700_insn_config(struct comedi_device *dev,
case INSN_CONFIG_DIO_OUTPUT:
break;
case INSN_CONFIG_DIO_QUERY:
- data[1] =
- (s->
- io_bits & (1 << CR_CHAN(insn->chanspec))) ? COMEDI_OUTPUT :
- COMEDI_INPUT;
- return insn->n;
+ data[1] = (s->io_bits & chan) ? COMEDI_OUTPUT : COMEDI_INPUT;
break;
default:
return -EINVAL;
}
- return 1;
-}
-
-static void do_config(struct comedi_device *dev, struct comedi_subdevice *s)
-{ /* use powerup defaults */
- return;
-}
-
-static int subdev_700_cmdtest(struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_cmd *cmd)
-{
- int err = 0;
- unsigned int tmp;
-
- /* step 1 */
-
- tmp = cmd->start_src;
- cmd->start_src &= TRIG_NOW;
- if (!cmd->start_src || tmp != cmd->start_src)
- err++;
-
- tmp = cmd->scan_begin_src;
- cmd->scan_begin_src &= TRIG_EXT;
- if (!cmd->scan_begin_src || tmp != cmd->scan_begin_src)
- err++;
-
- tmp = cmd->convert_src;
- cmd->convert_src &= TRIG_FOLLOW;
- if (!cmd->convert_src || tmp != cmd->convert_src)
- err++;
-
- tmp = cmd->scan_end_src;
- cmd->scan_end_src &= TRIG_COUNT;
- if (!cmd->scan_end_src || tmp != cmd->scan_end_src)
- err++;
-
- tmp = cmd->stop_src;
- cmd->stop_src &= TRIG_NONE;
- if (!cmd->stop_src || tmp != cmd->stop_src)
- err++;
-
- if (err)
- return 1;
-
- /* step 2 */
-
- if (err)
- return 2;
-
- /* step 3 */
-
- if (cmd->start_arg != 0) {
- cmd->start_arg = 0;
- err++;
- }
- if (cmd->scan_begin_arg != 0) {
- cmd->scan_begin_arg = 0;
- err++;
- }
- if (cmd->convert_arg != 0) {
- cmd->convert_arg = 0;
- err++;
- }
- if (cmd->scan_end_arg != 1) {
- cmd->scan_end_arg = 1;
- err++;
- }
- if (cmd->stop_arg != 0) {
- cmd->stop_arg = 0;
- err++;
- }
-
- if (err)
- return 3;
-
- /* step 4 */
-
- if (err)
- return 4;
-
- return 0;
+ return insn->n;
}
-static int subdev_700_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
-{
- /* FIXME */
-
- return 0;
-}
-
-static int subdev_700_cancel(struct comedi_device *dev,
- struct comedi_subdevice *s)
-{
- /* FIXME */
-
- return 0;
-}
-
-int subdev_700_init(struct comedi_device *dev, struct comedi_subdevice *s,
- int (*cb) (int, int, int, unsigned long), unsigned long arg)
-{
- s->type = COMEDI_SUBD_DIO;
- s->subdev_flags = SDF_READABLE | SDF_WRITABLE;
- s->n_chan = 16;
- s->range_table = &range_digital;
- s->maxdata = 1;
-
- s->private = kmalloc(sizeof(struct subdev_700_struct), GFP_KERNEL);
- if (!s->private)
- return -ENOMEM;
-
- CALLBACK_ARG = arg;
- if (cb == NULL)
- CALLBACK_FUNC = subdev_700_cb;
- else
- CALLBACK_FUNC = cb;
-
- s->insn_bits = subdev_700_insn;
- s->insn_config = subdev_700_insn_config;
-
- s->state = 0;
- s->io_bits = 0x00ff;
- do_config(dev, s);
-
- return 0;
-}
-EXPORT_SYMBOL(subdev_700_init);
-
-int subdev_700_init_irq(struct comedi_device *dev, struct comedi_subdevice *s,
- int (*cb) (int, int, int, unsigned long),
- unsigned long arg)
-{
- int ret;
-
- ret = subdev_700_init(dev, s, cb, arg);
- if (ret < 0)
- return ret;
-
- s->do_cmdtest = subdev_700_cmdtest;
- s->do_cmd = subdev_700_cmd;
- s->cancel = subdev_700_cancel;
-
- subdevpriv->have_irq = 1;
-
- return 0;
-}
-EXPORT_SYMBOL(subdev_700_init_irq);
-
-void subdev_700_cleanup(struct comedi_device *dev, struct comedi_subdevice *s)
-{
- if (s->private)
- if (subdevpriv->have_irq)
-
- kfree(s->private);
-}
-EXPORT_SYMBOL(subdev_700_cleanup);
-
static int dio700_attach(struct comedi_device *dev, struct comedi_devconfig *it)
{
+ const struct dio700_board *thisboard = comedi_board(dev);
struct comedi_subdevice *s;
- unsigned long iobase = 0;
-#ifdef incomplete
- unsigned int irq = 0;
-#endif
struct pcmcia_device *link;
+ int ret;
- /* allocate and initialize dev->private */
- if (alloc_private(dev, sizeof(struct dio700_private)) < 0)
- return -ENOMEM;
-
- /* get base address, irq etc. based on bustype */
- switch (thisboard->bustype) {
- case pcmcia_bustype:
- link = pcmcia_cur_dev; /* XXX hack */
- if (!link)
- return -EIO;
- iobase = link->resource[0]->start;
-#ifdef incomplete
- irq = link->irq;
-#endif
- break;
- default:
- printk(KERN_ERR "bug! couldn't determine board type\n");
- return -EINVAL;
- break;
- }
- printk(KERN_ERR "comedi%d: ni_daq_700: %s, io 0x%lx", dev->minor,
- thisboard->name, iobase);
-#ifdef incomplete
- if (irq)
- printk(", irq %u", irq);
-
-#endif
-
- printk("\n");
+ link = pcmcia_cur_dev; /* XXX hack */
+ if (!link)
+ return -EIO;
- if (iobase == 0) {
- printk(KERN_ERR "io base address is zero!\n");
+ dev->iobase = link->resource[0]->start;
+ if (!dev->iobase) {
+ dev_err(dev->class_dev, "io base address is zero!\n");
return -EINVAL;
}
- dev->iobase = iobase;
-
-#ifdef incomplete
- /* grab our IRQ */
- dev->irq = irq;
-#endif
-
dev->board_name = thisboard->name;
- if (alloc_subdevices(dev, 1) < 0)
- return -ENOMEM;
+ ret = comedi_alloc_subdevices(dev, 1);
+ if (ret)
+ return ret;
/* DAQCard-700 dio */
s = dev->subdevices + 0;
- subdev_700_init(dev, s, NULL, dev->iobase);
+ s->type = COMEDI_SUBD_DIO;
+ s->subdev_flags = SDF_READABLE | SDF_WRITABLE;
+ s->n_chan = 16;
+ s->range_table = &range_digital;
+ s->maxdata = 1;
+ s->insn_bits = subdev_700_insn;
+ s->insn_config = subdev_700_insn_config;
+
+ s->state = 0;
+ s->io_bits = 0x00ff;
+
+ dev_info(dev->class_dev, "%s: %s, io 0x%lx\n",
+ dev->driver->driver_name,
+ dev->board_name,
+ dev->iobase);
return 0;
-};
+}
-static int dio700_detach(struct comedi_device *dev)
+static void dio700_detach(struct comedi_device *dev)
{
- printk(KERN_ERR "comedi%d: ni_daq_700: cs-remove\n", dev->minor);
-
- if (dev->subdevices)
- subdev_700_cleanup(dev, dev->subdevices + 0);
-
- if (thisboard->bustype != pcmcia_bustype && dev->iobase)
- release_region(dev->iobase, DIO700_SIZE);
- if (dev->irq)
- free_irq(dev->irq, dev);
+ /* nothing to cleanup */
+}
- return 0;
+static const struct dio700_board dio700_boards[] = {
+ {
+ .name = "daqcard-700",
+ }, {
+ .name = "ni_daq_700",
+ },
};
-static void dio700_config(struct pcmcia_device *link);
-static void dio700_release(struct pcmcia_device *link);
-static int dio700_cs_suspend(struct pcmcia_device *p_dev);
-static int dio700_cs_resume(struct pcmcia_device *p_dev);
-
-static int dio700_cs_attach(struct pcmcia_device *);
-static void dio700_cs_detach(struct pcmcia_device *);
-
-struct local_info_t {
- struct pcmcia_device *link;
- int stop;
- struct bus_operations *bus;
+static struct comedi_driver driver_dio700 = {
+ .driver_name = "ni_daq_700",
+ .module = THIS_MODULE,
+ .attach = dio700_attach,
+ .detach = dio700_detach,
+ .board_name = &dio700_boards[0].name,
+ .num_names = ARRAY_SIZE(dio700_boards),
+ .offset = sizeof(struct dio700_board),
};
-static int dio700_cs_attach(struct pcmcia_device *link)
-{
- struct local_info_t *local;
-
- printk(KERN_INFO "ni_daq_700: cs-attach\n");
-
- dev_dbg(&link->dev, "dio700_cs_attach()\n");
-
- /* Allocate space for private device-specific data */
- local = kzalloc(sizeof(struct local_info_t), GFP_KERNEL);
- if (!local)
- return -ENOMEM;
- local->link = link;
- link->priv = local;
-
- pcmcia_cur_dev = link;
-
- dio700_config(link);
-
- return 0;
-} /* dio700_cs_attach */
-
-static void dio700_cs_detach(struct pcmcia_device *link)
-{
-
- printk(KERN_INFO "ni_daq_700: cs-detach!\n");
-
- dev_dbg(&link->dev, "dio700_cs_detach\n");
-
- ((struct local_info_t *)link->priv)->stop = 1;
- dio700_release(link);
-
- /* This points to the parent struct local_info_t struct */
- kfree(link->priv);
-
-} /* dio700_cs_detach */
-
static int dio700_pcmcia_config_loop(struct pcmcia_device *p_dev,
void *priv_data)
{
@@ -494,112 +173,78 @@ static int dio700_pcmcia_config_loop(struct pcmcia_device *p_dev,
return pcmcia_request_io(p_dev);
}
-static void dio700_config(struct pcmcia_device *link)
+static int dio700_cs_attach(struct pcmcia_device *link)
{
int ret;
- printk(KERN_INFO "ni_daq_700: cs-config\n");
-
- dev_dbg(&link->dev, "dio700_config\n");
-
link->config_flags |= CONF_ENABLE_IRQ | CONF_AUTO_AUDIO |
CONF_AUTO_SET_IO;
ret = pcmcia_loop_config(link, dio700_pcmcia_config_loop, NULL);
- if (ret) {
- dev_warn(&link->dev, "no configuration found\n");
+ if (ret)
goto failed;
- }
if (!link->irq)
goto failed;
ret = pcmcia_enable_device(link);
- if (ret != 0)
+ if (ret)
goto failed;
- return;
+ pcmcia_cur_dev = link;
+ return 0;
failed:
- printk(KERN_INFO "ni_daq_700 cs failed");
- dio700_release(link);
-
-} /* dio700_config */
-
-static void dio700_release(struct pcmcia_device *link)
-{
- dev_dbg(&link->dev, "dio700_release\n");
-
pcmcia_disable_device(link);
-} /* dio700_release */
-
-static int dio700_cs_suspend(struct pcmcia_device *link)
-{
- struct local_info_t *local = link->priv;
-
- /* Mark the device as stopped, to block IO until later */
- local->stop = 1;
- return 0;
-} /* dio700_cs_suspend */
+ return ret;
+}
-static int dio700_cs_resume(struct pcmcia_device *link)
+static void dio700_cs_detach(struct pcmcia_device *link)
{
- struct local_info_t *local = link->priv;
-
- local->stop = 0;
- return 0;
-} /* dio700_cs_resume */
-
-/*====================================================================*/
+ pcmcia_disable_device(link);
+ pcmcia_cur_dev = NULL;
+}
static const struct pcmcia_device_id dio700_cs_ids[] = {
- /* N.B. These IDs should match those in dio700_boards */
- PCMCIA_DEVICE_MANF_CARD(0x010b, 0x4743), /* daqcard-700 */
+ PCMCIA_DEVICE_MANF_CARD(0x010b, 0x4743),
PCMCIA_DEVICE_NULL
};
-
-
MODULE_DEVICE_TABLE(pcmcia, dio700_cs_ids);
-MODULE_AUTHOR("Fred Brooks <nsaspook@nsaspook.com>");
-MODULE_DESCRIPTION("Comedi driver for National Instruments "
- "PCMCIA DAQCard-700 DIO");
-MODULE_LICENSE("GPL");
-struct pcmcia_driver dio700_cs_driver = {
- .probe = dio700_cs_attach,
- .remove = dio700_cs_detach,
- .suspend = dio700_cs_suspend,
- .resume = dio700_cs_resume,
- .id_table = dio700_cs_ids,
- .owner = THIS_MODULE,
- .name = "ni_daq_700",
+static struct pcmcia_driver dio700_cs_driver = {
+ .name = "ni_daq_700",
+ .owner = THIS_MODULE,
+ .probe = dio700_cs_attach,
+ .remove = dio700_cs_detach,
+ .id_table = dio700_cs_ids,
};
-static int __init init_dio700_cs(void)
-{
- pcmcia_register_driver(&dio700_cs_driver);
- return 0;
-}
-
-static void __exit exit_dio700_cs(void)
-{
- pr_debug("ni_daq_700: unloading\n");
- pcmcia_unregister_driver(&dio700_cs_driver);
-}
-
-int __init init_module(void)
+static int __init dio700_cs_init(void)
{
int ret;
- ret = init_dio700_cs();
+ ret = comedi_driver_register(&driver_dio700);
if (ret < 0)
return ret;
- return comedi_driver_register(&driver_dio700);
+ ret = pcmcia_register_driver(&dio700_cs_driver);
+ if (ret < 0) {
+ comedi_driver_unregister(&driver_dio700);
+ return ret;
+ }
+
+ return 0;
}
+module_init(dio700_cs_init);
-void __exit cleanup_module(void)
+static void __exit dio700_cs_exit(void)
{
- exit_dio700_cs();
+ pcmcia_unregister_driver(&dio700_cs_driver);
comedi_driver_unregister(&driver_dio700);
}
+module_exit(dio700_cs_exit);
+
+MODULE_AUTHOR("Fred Brooks <nsaspook@nsaspook.com>");
+MODULE_DESCRIPTION(
+ "Comedi driver for National Instruments PCMCIA DAQCard-700 DIO");
+MODULE_LICENSE("GPL");
diff --git a/drivers/staging/comedi/drivers/ni_daq_dio24.c b/drivers/staging/comedi/drivers/ni_daq_dio24.c
index c0423a8c3e36..e27cae0eb8a2 100644
--- a/drivers/staging/comedi/drivers/ni_daq_dio24.c
+++ b/drivers/staging/comedi/drivers/ni_daq_dio24.c
@@ -57,7 +57,7 @@ static struct pcmcia_device *pcmcia_cur_dev;
#define DIO24_SIZE 4 /* size of io region used by board */
static int dio24_attach(struct comedi_device *dev, struct comedi_devconfig *it);
-static int dio24_detach(struct comedi_device *dev);
+static void dio24_detach(struct comedi_device *dev);
enum dio24_bustype { pcmcia_bustype };
@@ -116,6 +116,7 @@ static int dio24_attach(struct comedi_device *dev, struct comedi_devconfig *it)
unsigned int irq = 0;
#endif
struct pcmcia_device *link;
+ int ret;
/* allocate and initialize dev->private */
if (alloc_private(dev, sizeof(struct dio24_private)) < 0)
@@ -158,8 +159,9 @@ static int dio24_attach(struct comedi_device *dev, struct comedi_devconfig *it)
dev->board_name = thisboard->name;
- if (alloc_subdevices(dev, 1) < 0)
- return -ENOMEM;
+ ret = comedi_alloc_subdevices(dev, 1);
+ if (ret)
+ return ret;
/* 8255 dio */
s = dev->subdevices + 0;
@@ -168,19 +170,14 @@ static int dio24_attach(struct comedi_device *dev, struct comedi_devconfig *it)
return 0;
};
-static int dio24_detach(struct comedi_device *dev)
+static void dio24_detach(struct comedi_device *dev)
{
- dev_info(dev->hw_dev, "comedi%d: ni_daq_dio24: remove\n", dev->minor);
-
if (dev->subdevices)
subdev_8255_cleanup(dev, dev->subdevices + 0);
-
if (thisboard->bustype != pcmcia_bustype && dev->iobase)
release_region(dev->iobase, DIO24_SIZE);
if (dev->irq)
free_irq(dev->irq, dev);
-
- return 0;
};
static void dio24_config(struct pcmcia_device *link);
@@ -221,18 +218,12 @@ static int dio24_cs_attach(struct pcmcia_device *link)
static void dio24_cs_detach(struct pcmcia_device *link)
{
-
- printk(KERN_INFO "ni_daq_dio24: HOLA SOY YO - cs-detach!\n");
-
- dev_dbg(&link->dev, "dio24_cs_detach\n");
-
((struct local_info_t *)link->priv)->stop = 1;
dio24_release(link);
/* This points to the parent local_info_t struct */
kfree(link->priv);
-
-} /* dio24_cs_detach */
+}
static int dio24_pcmcia_config_loop(struct pcmcia_device *p_dev,
void *priv_data)
diff --git a/drivers/staging/comedi/drivers/ni_labpc.c b/drivers/staging/comedi/drivers/ni_labpc.c
index 721b2be22500..ab8b787c78bb 100644
--- a/drivers/staging/comedi/drivers/ni_labpc.c
+++ b/drivers/staging/comedi/drivers/ni_labpc.c
@@ -536,6 +536,7 @@ int labpc_common_attach(struct comedi_device *dev, unsigned long iobase,
unsigned long dma_flags;
#endif
short lsb, msb;
+ int ret;
printk(KERN_ERR "comedi%d: ni_labpc: %s, io 0x%lx", dev->minor,
thisboard->name,
@@ -622,8 +623,9 @@ int labpc_common_attach(struct comedi_device *dev, unsigned long iobase,
dev->board_name = thisboard->name;
- if (alloc_subdevices(dev, 5) < 0)
- return -ENOMEM;
+ ret = comedi_alloc_subdevices(dev, 5);
+ if (ret)
+ return ret;
/* analog input subdevice */
s = dev->subdevices + 0;
@@ -805,13 +807,10 @@ static int labpc_find_device(struct comedi_device *dev, int bus, int slot)
}
#endif
-int labpc_common_detach(struct comedi_device *dev)
+void labpc_common_detach(struct comedi_device *dev)
{
- printk(KERN_ERR "comedi%d: ni_labpc: detach\n", dev->minor);
-
if (dev->subdevices)
subdev_8255_cleanup(dev, dev->subdevices + 2);
-
#ifdef CONFIG_ISA_DMA_API
/* only free stuff if it has been allocated by _attach */
kfree(devpriv->dma_buffer);
@@ -826,8 +825,6 @@ int labpc_common_detach(struct comedi_device *dev)
if (devpriv->mite)
mite_unsetup(devpriv->mite);
#endif
-
- return 0;
};
EXPORT_SYMBOL_GPL(labpc_common_detach);
@@ -1391,6 +1388,7 @@ static int labpc_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
break;
default:
comedi_error(dev, "bug with start_src");
+ spin_unlock_irqrestore(&dev->spinlock, flags);
return -1;
break;
}
@@ -1403,6 +1401,7 @@ static int labpc_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
break;
default:
comedi_error(dev, "bug with stop_src");
+ spin_unlock_irqrestore(&dev->spinlock, flags);
return -1;
}
devpriv->write_byte(devpriv->command2_bits, dev->iobase + COMMAND2_REG);
@@ -2141,7 +2140,7 @@ static void write_caldac(struct comedi_device *dev, unsigned int channel,
static int __devinit driver_labpc_pci_probe(struct pci_dev *dev,
const struct pci_device_id *ent)
{
- return comedi_pci_auto_config(dev, driver_labpc.driver_name);
+ return comedi_pci_auto_config(dev, &driver_labpc);
}
static void __devexit driver_labpc_pci_remove(struct pci_dev *dev)
diff --git a/drivers/staging/comedi/drivers/ni_labpc.h b/drivers/staging/comedi/drivers/ni_labpc.h
index 422cee58a967..e052ed3ba544 100644
--- a/drivers/staging/comedi/drivers/ni_labpc.h
+++ b/drivers/staging/comedi/drivers/ni_labpc.h
@@ -103,7 +103,7 @@ struct labpc_private {
int labpc_common_attach(struct comedi_device *dev, unsigned long iobase,
unsigned int irq, unsigned int dma);
-int labpc_common_detach(struct comedi_device *dev);
+void labpc_common_detach(struct comedi_device *dev);
extern const int labpc_1200_is_unipolar[];
extern const int labpc_1200_ai_gain_bits[];
diff --git a/drivers/staging/comedi/drivers/ni_labpc_cs.c b/drivers/staging/comedi/drivers/ni_labpc_cs.c
index ff3840544dd4..dbb61b6b3ed1 100644
--- a/drivers/staging/comedi/drivers/ni_labpc_cs.c
+++ b/drivers/staging/comedi/drivers/ni_labpc_cs.c
@@ -188,21 +188,13 @@ static int labpc_cs_attach(struct pcmcia_device *link)
static void labpc_cs_detach(struct pcmcia_device *link)
{
- dev_dbg(&link->dev, "labpc_cs_detach\n");
-
- /*
- If the device is currently configured and active, we won't
- actually delete it yet. Instead, it is marked so that when
- the release() function is called, that will trigger a proper
- detach().
- */
((struct local_info_t *)link->priv)->stop = 1;
labpc_release(link);
/* This points to the parent local_info_t struct (may be null) */
kfree(link->priv);
-} /* labpc_cs_detach */
+}
static int labpc_pcmcia_config_loop(struct pcmcia_device *p_dev,
void *priv_data)
diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c b/drivers/staging/comedi/drivers/ni_mio_common.c
index fd232bc5f873..cf0e0d147f8c 100644
--- a/drivers/staging/comedi/drivers/ni_mio_common.c
+++ b/drivers/staging/comedi/drivers/ni_mio_common.c
@@ -3567,8 +3567,7 @@ static int ni_dio_insn_bits(struct comedi_device *dev,
#ifdef DEBUG_DIO
printk("ni_dio_insn_bits() mask=0x%x bits=0x%x\n", data[0], data[1]);
#endif
- if (insn->n != 2)
- return -EINVAL;
+
if (data[0]) {
/* Perform check to make sure we're not using the
serial part of the dio */
@@ -3585,7 +3584,7 @@ static int ni_dio_insn_bits(struct comedi_device *dev,
}
data[1] = devpriv->stc_readw(dev, DIO_Parallel_Input_Register);
- return 2;
+ return insn->n;
}
static int ni_m_series_dio_insn_config(struct comedi_device *dev,
@@ -3629,8 +3628,7 @@ static int ni_m_series_dio_insn_bits(struct comedi_device *dev,
printk("ni_m_series_dio_insn_bits() mask=0x%x bits=0x%x\n", data[0],
data[1]);
#endif
- if (insn->n != 2)
- return -EINVAL;
+
if (data[0]) {
s->state &= ~data[0];
s->state |= (data[0] & data[1]);
@@ -3638,7 +3636,7 @@ static int ni_m_series_dio_insn_bits(struct comedi_device *dev,
}
data[1] = ni_readl(M_Offset_Static_Digital_Input);
- return 2;
+ return insn->n;
}
static int ni_cdio_cmdtest(struct comedi_device *dev,
@@ -4406,14 +4404,16 @@ static int ni_E_init(struct comedi_device *dev, struct comedi_devconfig *it)
struct comedi_subdevice *s;
unsigned j;
enum ni_gpct_variant counter_variant;
+ int ret;
if (boardtype.n_aochan > MAX_N_AO_CHAN) {
printk("bug! boardtype.n_aochan > MAX_N_AO_CHAN\n");
return -EINVAL;
}
- if (alloc_subdevices(dev, NI_NUM_SUBDEVICES) < 0)
- return -ENOMEM;
+ ret = comedi_alloc_subdevices(dev, NI_NUM_SUBDEVICES);
+ if (ret)
+ return ret;
/* analog input subdevice */
@@ -5394,7 +5394,7 @@ static int ni_pfi_insn_bits(struct comedi_device *dev,
ni_writew(s->state, M_Offset_PFI_DO);
}
data[1] = ni_readw(M_Offset_PFI_DI);
- return 2;
+ return insn->n;
}
static int ni_pfi_insn_config(struct comedi_device *dev,
@@ -5483,12 +5483,9 @@ static int ni_rtsi_insn_bits(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
- if (insn->n != 2)
- return -EINVAL;
-
data[1] = 0;
- return 2;
+ return insn->n;
}
/* Find best multiplier/divider to try and get the PLL running at 80 MHz
diff --git a/drivers/staging/comedi/drivers/ni_mio_cs.c b/drivers/staging/comedi/drivers/ni_mio_cs.c
index 53ec24bb6dce..b85765d266c2 100644
--- a/drivers/staging/comedi/drivers/ni_mio_cs.c
+++ b/drivers/staging/comedi/drivers/ni_mio_cs.c
@@ -227,7 +227,7 @@ static uint16_t mio_cs_win_in(struct comedi_device *dev, int addr)
static int mio_cs_attach(struct comedi_device *dev,
struct comedi_devconfig *it);
-static int mio_cs_detach(struct comedi_device *dev);
+static void mio_cs_detach(struct comedi_device *dev);
static struct comedi_driver driver_ni_mio_cs = {
.driver_name = "ni_mio_cs",
.module = THIS_MODULE,
@@ -240,18 +240,11 @@ static struct comedi_driver driver_ni_mio_cs = {
static int ni_getboardtype(struct comedi_device *dev,
struct pcmcia_device *link);
-/* clean up allocated resources */
-/* called when driver is removed */
-static int mio_cs_detach(struct comedi_device *dev)
+static void mio_cs_detach(struct comedi_device *dev)
{
mio_common_detach(dev);
-
- /* PCMCIA layer frees the IO region */
-
if (dev->irq)
free_irq(dev->irq, dev);
-
- return 0;
}
static void mio_cs_config(struct pcmcia_device *link);
@@ -276,8 +269,6 @@ static void cs_release(struct pcmcia_device *link)
static void cs_detach(struct pcmcia_device *link)
{
- DPRINTK("cs_detach(link=%p)\n", link);
-
cs_release(link);
}
diff --git a/drivers/staging/comedi/drivers/ni_pcidio.c b/drivers/staging/comedi/drivers/ni_pcidio.c
index 1df8fcbcd108..0a55de968039 100644
--- a/drivers/staging/comedi/drivers/ni_pcidio.c
+++ b/drivers/staging/comedi/drivers/ni_pcidio.c
@@ -293,18 +293,9 @@ enum FPGA_Control_Bits {
#define IntEn (TransferReady|CountExpired|Waited|PrimaryTC|SecondaryTC)
#endif
-static int nidio_attach(struct comedi_device *dev, struct comedi_devconfig *it);
-static int nidio_detach(struct comedi_device *dev);
static int ni_pcidio_cancel(struct comedi_device *dev,
struct comedi_subdevice *s);
-static struct comedi_driver driver_pcidio = {
- .driver_name = "ni_pcidio",
- .module = THIS_MODULE,
- .attach = nidio_attach,
- .detach = nidio_detach,
-};
-
struct nidio_board {
int dev_id;
@@ -381,22 +372,6 @@ static const struct nidio_board nidio_boards[] = {
#define n_nidio_boards ARRAY_SIZE(nidio_boards)
#define this_board ((const struct nidio_board *)dev->board_ptr)
-static DEFINE_PCI_DEVICE_TABLE(ni_pcidio_pci_table) = {
- {PCI_DEVICE(PCI_VENDOR_ID_NI, 0x1150)},
- {PCI_DEVICE(PCI_VENDOR_ID_NI, 0x1320)},
- {PCI_DEVICE(PCI_VENDOR_ID_NI, 0x12b0)},
- {PCI_DEVICE(PCI_VENDOR_ID_NI, 0x0160)},
- {PCI_DEVICE(PCI_VENDOR_ID_NI, 0x1630)},
- {PCI_DEVICE(PCI_VENDOR_ID_NI, 0x13c0)},
- {PCI_DEVICE(PCI_VENDOR_ID_NI, 0x0400)},
- {PCI_DEVICE(PCI_VENDOR_ID_NI, 0x1250)},
- {PCI_DEVICE(PCI_VENDOR_ID_NI, 0x17d0)},
- {PCI_DEVICE(PCI_VENDOR_ID_NI, 0x1800)},
- {0}
-};
-
-MODULE_DEVICE_TABLE(pci, ni_pcidio_pci_table);
-
struct nidio96_private {
struct mite_struct *mite;
int boardtype;
@@ -414,7 +389,6 @@ static int ni_pcidio_cmdtest(struct comedi_device *dev,
static int ni_pcidio_cmd(struct comedi_device *dev, struct comedi_subdevice *s);
static int ni_pcidio_inttrig(struct comedi_device *dev,
struct comedi_subdevice *s, unsigned int trignum);
-static int nidio_find_device(struct comedi_device *dev, int bus, int slot);
static int ni_pcidio_ns_to_timer(int *nanosec, int round_mode);
static int setup_mite_dma(struct comedi_device *dev,
struct comedi_subdevice *s);
@@ -771,8 +745,6 @@ static int ni_pcidio_insn_bits(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
- if (insn->n != 2)
- return -EINVAL;
if (data[0]) {
s->state &= ~data[0];
s->state |= (data[0] & data[1]);
@@ -780,7 +752,7 @@ static int ni_pcidio_insn_bits(struct comedi_device *dev,
}
data[1] = readl(devpriv->mite->daq_io_addr + Port_IO(0));
- return 2;
+ return insn->n;
}
static int ni_pcidio_cmdtest(struct comedi_device *dev,
@@ -1205,6 +1177,33 @@ static int pci_6534_upload_firmware(struct comedi_device *dev, int options[])
return 0;
}
+static int nidio_find_device(struct comedi_device *dev, int bus, int slot)
+{
+ struct mite_struct *mite;
+ int i;
+
+ for (mite = mite_devices; mite; mite = mite->next) {
+ if (mite->used)
+ continue;
+ if (bus || slot) {
+ if (bus != mite->pcidev->bus->number ||
+ slot != PCI_SLOT(mite->pcidev->devfn))
+ continue;
+ }
+ for (i = 0; i < n_nidio_boards; i++) {
+ if (mite_device_id(mite) == nidio_boards[i].dev_id) {
+ dev->board_ptr = nidio_boards + i;
+ devpriv->mite = mite;
+
+ return 0;
+ }
+ }
+ }
+ printk(KERN_WARNING "no device found\n");
+ mite_list_devices();
+ return -EIO;
+}
+
static int nidio_attach(struct comedi_device *dev, struct comedi_devconfig *it)
{
struct comedi_subdevice *s;
@@ -1247,8 +1246,8 @@ static int nidio_attach(struct comedi_device *dev, struct comedi_devconfig *it)
else
n_subdevices = 1;
- ret = alloc_subdevices(dev, n_subdevices);
- if (ret < 0)
+ ret = comedi_alloc_subdevices(dev, n_subdevices);
+ if (ret)
return ret;
if (!this_board->is_diodaq) {
@@ -1306,7 +1305,7 @@ static int nidio_attach(struct comedi_device *dev, struct comedi_devconfig *it)
return 0;
}
-static int nidio_detach(struct comedi_device *dev)
+static void nidio_detach(struct comedi_device *dev)
{
int i;
@@ -1314,10 +1313,8 @@ static int nidio_detach(struct comedi_device *dev)
for (i = 0; i < this_board->n_8255; i++)
subdev_8255_cleanup(dev, dev->subdevices + i);
}
-
if (dev->irq)
free_irq(dev->irq, dev);
-
if (devpriv) {
if (devpriv->di_mite_ring) {
mite_free_ring(devpriv->di_mite_ring);
@@ -1326,73 +1323,48 @@ static int nidio_detach(struct comedi_device *dev)
if (devpriv->mite)
mite_unsetup(devpriv->mite);
}
- return 0;
}
-static int nidio_find_device(struct comedi_device *dev, int bus, int slot)
-{
- struct mite_struct *mite;
- int i;
-
- for (mite = mite_devices; mite; mite = mite->next) {
- if (mite->used)
- continue;
- if (bus || slot) {
- if (bus != mite->pcidev->bus->number ||
- slot != PCI_SLOT(mite->pcidev->devfn))
- continue;
- }
- for (i = 0; i < n_nidio_boards; i++) {
- if (mite_device_id(mite) == nidio_boards[i].dev_id) {
- dev->board_ptr = nidio_boards + i;
- devpriv->mite = mite;
-
- return 0;
- }
- }
- }
- printk(KERN_WARNING "no device found\n");
- mite_list_devices();
- return -EIO;
-}
+static struct comedi_driver ni_pcidio_driver = {
+ .driver_name = "ni_pcidio",
+ .module = THIS_MODULE,
+ .attach = nidio_attach,
+ .detach = nidio_detach,
+};
-static int __devinit driver_pcidio_pci_probe(struct pci_dev *dev,
- const struct pci_device_id *ent)
+static int __devinit ni_pcidio_pci_probe(struct pci_dev *dev,
+ const struct pci_device_id *ent)
{
- return comedi_pci_auto_config(dev, driver_pcidio.driver_name);
+ return comedi_pci_auto_config(dev, &ni_pcidio_driver);
}
-static void __devexit driver_pcidio_pci_remove(struct pci_dev *dev)
+static void __devexit ni_pcidio_pci_remove(struct pci_dev *dev)
{
comedi_pci_auto_unconfig(dev);
}
-static struct pci_driver driver_pcidio_pci_driver = {
- .id_table = ni_pcidio_pci_table,
- .probe = &driver_pcidio_pci_probe,
- .remove = __devexit_p(&driver_pcidio_pci_remove)
+static DEFINE_PCI_DEVICE_TABLE(ni_pcidio_pci_table) = {
+ { PCI_DEVICE(PCI_VENDOR_ID_NI, 0x1150) },
+ { PCI_DEVICE(PCI_VENDOR_ID_NI, 0x1320) },
+ { PCI_DEVICE(PCI_VENDOR_ID_NI, 0x12b0) },
+ { PCI_DEVICE(PCI_VENDOR_ID_NI, 0x0160) },
+ { PCI_DEVICE(PCI_VENDOR_ID_NI, 0x1630) },
+ { PCI_DEVICE(PCI_VENDOR_ID_NI, 0x13c0) },
+ { PCI_DEVICE(PCI_VENDOR_ID_NI, 0x0400) },
+ { PCI_DEVICE(PCI_VENDOR_ID_NI, 0x1250) },
+ { PCI_DEVICE(PCI_VENDOR_ID_NI, 0x17d0) },
+ { PCI_DEVICE(PCI_VENDOR_ID_NI, 0x1800) },
+ { 0 }
};
+MODULE_DEVICE_TABLE(pci, ni_pcidio_pci_table);
-static int __init driver_pcidio_init_module(void)
-{
- int retval;
-
- retval = comedi_driver_register(&driver_pcidio);
- if (retval < 0)
- return retval;
-
- driver_pcidio_pci_driver.name = (char *)driver_pcidio.driver_name;
- return pci_register_driver(&driver_pcidio_pci_driver);
-}
-
-static void __exit driver_pcidio_cleanup_module(void)
-{
- pci_unregister_driver(&driver_pcidio_pci_driver);
- comedi_driver_unregister(&driver_pcidio);
-}
-
-module_init(driver_pcidio_init_module);
-module_exit(driver_pcidio_cleanup_module);
+static struct pci_driver ni_pcidio_pci_driver = {
+ .name = "ni_pcidio",
+ .id_table = ni_pcidio_pci_table,
+ .probe = ni_pcidio_pci_probe,
+ .remove = __devexit_p(ni_pcidio_pci_remove),
+};
+module_comedi_pci_driver(ni_pcidio_driver, ni_pcidio_pci_driver);
MODULE_AUTHOR("Comedi http://www.comedi.org");
MODULE_DESCRIPTION("Comedi low-level driver");
diff --git a/drivers/staging/comedi/drivers/ni_pcimio.c b/drivers/staging/comedi/drivers/ni_pcimio.c
index 27baefa32b17..89f4d43c6d08 100644
--- a/drivers/staging/comedi/drivers/ni_pcimio.c
+++ b/drivers/staging/comedi/drivers/ni_pcimio.c
@@ -129,66 +129,6 @@ Bugs:
#define DRV_NAME "ni_pcimio"
-/* The following two tables must be in the same order */
-static DEFINE_PCI_DEVICE_TABLE(ni_pci_table) = {
- {PCI_DEVICE(PCI_VENDOR_ID_NI, 0x0162)},
- {PCI_DEVICE(PCI_VENDOR_ID_NI, 0x1170)},
- {PCI_DEVICE(PCI_VENDOR_ID_NI, 0x1180)},
- {PCI_DEVICE(PCI_VENDOR_ID_NI, 0x1190)},
- {PCI_DEVICE(PCI_VENDOR_ID_NI, 0x11b0)},
- {PCI_DEVICE(PCI_VENDOR_ID_NI, 0x11c0)},
- {PCI_DEVICE(PCI_VENDOR_ID_NI, 0x11d0)},
- {PCI_DEVICE(PCI_VENDOR_ID_NI, 0x1270)},
- {PCI_DEVICE(PCI_VENDOR_ID_NI, 0x1330)},
- {PCI_DEVICE(PCI_VENDOR_ID_NI, 0x1340)},
- {PCI_DEVICE(PCI_VENDOR_ID_NI, 0x1350)},
- {PCI_DEVICE(PCI_VENDOR_ID_NI, 0x14e0)},
- {PCI_DEVICE(PCI_VENDOR_ID_NI, 0x14f0)},
- {PCI_DEVICE(PCI_VENDOR_ID_NI, 0x1580)},
- {PCI_DEVICE(PCI_VENDOR_ID_NI, 0x15b0)},
- {PCI_DEVICE(PCI_VENDOR_ID_NI, 0x1880)},
- {PCI_DEVICE(PCI_VENDOR_ID_NI, 0x1870)},
- {PCI_DEVICE(PCI_VENDOR_ID_NI, 0x18b0)},
- {PCI_DEVICE(PCI_VENDOR_ID_NI, 0x18c0)},
- {PCI_DEVICE(PCI_VENDOR_ID_NI, 0x2410)},
- {PCI_DEVICE(PCI_VENDOR_ID_NI, 0x2420)},
- {PCI_DEVICE(PCI_VENDOR_ID_NI, 0x2430)},
- {PCI_DEVICE(PCI_VENDOR_ID_NI, 0x2890)},
- {PCI_DEVICE(PCI_VENDOR_ID_NI, 0x28c0)},
- {PCI_DEVICE(PCI_VENDOR_ID_NI, 0x2a60)},
- {PCI_DEVICE(PCI_VENDOR_ID_NI, 0x2a70)},
- {PCI_DEVICE(PCI_VENDOR_ID_NI, 0x2a80)},
- {PCI_DEVICE(PCI_VENDOR_ID_NI, 0x2ab0)},
- {PCI_DEVICE(PCI_VENDOR_ID_NI, 0x2b80)},
- {PCI_DEVICE(PCI_VENDOR_ID_NI, 0x2b90)},
- {PCI_DEVICE(PCI_VENDOR_ID_NI, 0x2c80)},
- {PCI_DEVICE(PCI_VENDOR_ID_NI, 0x2ca0)},
- {PCI_DEVICE(PCI_VENDOR_ID_NI, 0x70aa)},
- {PCI_DEVICE(PCI_VENDOR_ID_NI, 0x70ab)},
- {PCI_DEVICE(PCI_VENDOR_ID_NI, 0x70ac)},
- {PCI_DEVICE(PCI_VENDOR_ID_NI, 0x70af)},
- {PCI_DEVICE(PCI_VENDOR_ID_NI, 0x70b0)},
- {PCI_DEVICE(PCI_VENDOR_ID_NI, 0x70b4)},
- {PCI_DEVICE(PCI_VENDOR_ID_NI, 0x70b6)},
- {PCI_DEVICE(PCI_VENDOR_ID_NI, 0x70b7)},
- {PCI_DEVICE(PCI_VENDOR_ID_NI, 0x70b8)},
- {PCI_DEVICE(PCI_VENDOR_ID_NI, 0x70bc)},
- {PCI_DEVICE(PCI_VENDOR_ID_NI, 0x70bd)},
- {PCI_DEVICE(PCI_VENDOR_ID_NI, 0x70bf)},
- {PCI_DEVICE(PCI_VENDOR_ID_NI, 0x70c0)},
- {PCI_DEVICE(PCI_VENDOR_ID_NI, 0x70f2)},
- {PCI_DEVICE(PCI_VENDOR_ID_NI, 0x710d)},
- {PCI_DEVICE(PCI_VENDOR_ID_NI, 0x716c)},
- {PCI_DEVICE(PCI_VENDOR_ID_NI, 0x716d)},
- {PCI_DEVICE(PCI_VENDOR_ID_NI, 0x717f)},
- {PCI_DEVICE(PCI_VENDOR_ID_NI, 0x71bc)},
- {PCI_DEVICE(PCI_VENDOR_ID_NI, 0x717d)},
- {PCI_DEVICE(PCI_VENDOR_ID_NI, 0x72e8)},
- {0}
-};
-
-MODULE_DEVICE_TABLE(pci, ni_pci_table);
-
/* These are not all the possible ao ranges for 628x boards.
They can do OFFSET +- REFERENCE where OFFSET can be
0V, 5V, APFI<0,1>, or AO<0...3> and RANGE can
@@ -1250,54 +1190,6 @@ static const struct ni_board_struct ni_boards[] = {
#define n_pcimio_boards ARRAY_SIZE(ni_boards)
-static int pcimio_attach(struct comedi_device *dev,
- struct comedi_devconfig *it);
-static int pcimio_detach(struct comedi_device *dev);
-static struct comedi_driver driver_pcimio = {
- .driver_name = DRV_NAME,
- .module = THIS_MODULE,
- .attach = pcimio_attach,
- .detach = pcimio_detach,
-};
-
-static int __devinit driver_pcimio_pci_probe(struct pci_dev *dev,
- const struct pci_device_id *ent)
-{
- return comedi_pci_auto_config(dev, driver_pcimio.driver_name);
-}
-
-static void __devexit driver_pcimio_pci_remove(struct pci_dev *dev)
-{
- comedi_pci_auto_unconfig(dev);
-}
-
-static struct pci_driver driver_pcimio_pci_driver = {
- .id_table = ni_pci_table,
- .probe = &driver_pcimio_pci_probe,
- .remove = __devexit_p(&driver_pcimio_pci_remove)
-};
-
-static int __init driver_pcimio_init_module(void)
-{
- int retval;
-
- retval = comedi_driver_register(&driver_pcimio);
- if (retval < 0)
- return retval;
-
- driver_pcimio_pci_driver.name = (char *)driver_pcimio.driver_name;
- return pci_register_driver(&driver_pcimio_pci_driver);
-}
-
-static void __exit driver_pcimio_cleanup_module(void)
-{
- pci_unregister_driver(&driver_pcimio_pci_driver);
- comedi_driver_unregister(&driver_pcimio);
-}
-
-module_init(driver_pcimio_init_module);
-module_exit(driver_pcimio_cleanup_module);
-
struct ni_private {
NI_PRIVATE_COMMON};
#define devpriv ((struct ni_private *)dev->private)
@@ -1681,13 +1573,11 @@ static void init_6143(struct comedi_device *dev)
ni_writew(devpriv->ai_calib_source, Calibration_Channel_6143);
}
-/* cleans up allocated resources */
-static int pcimio_detach(struct comedi_device *dev)
+static void pcimio_detach(struct comedi_device *dev)
{
mio_common_detach(dev);
if (dev->irq)
free_irq(dev->irq, dev);
-
if (dev->private) {
mite_free_ring(devpriv->ai_mite_ring);
mite_free_ring(devpriv->ao_mite_ring);
@@ -1697,15 +1587,13 @@ static int pcimio_detach(struct comedi_device *dev)
if (devpriv->mite)
mite_unsetup(devpriv->mite);
}
-
- return 0;
}
static int pcimio_attach(struct comedi_device *dev, struct comedi_devconfig *it)
{
int ret;
- dev_info(dev->hw_dev, "comedi%d: ni_pcimio:\n", dev->minor);
+ dev_info(dev->class_dev, "ni_pcimio: attach\n");
ret = ni_alloc_private(dev);
if (ret < 0)
@@ -1715,7 +1603,7 @@ static int pcimio_attach(struct comedi_device *dev, struct comedi_devconfig *it)
if (ret < 0)
return ret;
- dev_dbg(dev->hw_dev, "%s\n", boardtype.name);
+ dev_dbg(dev->class_dev, "%s\n", boardtype.name);
dev->board_name = boardtype.name;
if (boardtype.reg_type & ni_reg_m_series_mask) {
@@ -1874,6 +1762,90 @@ static int pcimio_dio_change(struct comedi_device *dev,
return 0;
}
+static struct comedi_driver ni_pcimio_driver = {
+ .driver_name = "ni_pcimio",
+ .module = THIS_MODULE,
+ .attach = pcimio_attach,
+ .detach = pcimio_detach,
+};
+
+static int __devinit ni_pcimio_pci_probe(struct pci_dev *dev,
+ const struct pci_device_id *ent)
+{
+ return comedi_pci_auto_config(dev, &ni_pcimio_driver);
+}
+
+static void __devexit ni_pcimio_pci_remove(struct pci_dev *dev)
+{
+ comedi_pci_auto_unconfig(dev);
+}
+
+static DEFINE_PCI_DEVICE_TABLE(ni_pcimio_pci_table) = {
+ { PCI_DEVICE(PCI_VENDOR_ID_NI, 0x0162) },
+ { PCI_DEVICE(PCI_VENDOR_ID_NI, 0x1170) },
+ { PCI_DEVICE(PCI_VENDOR_ID_NI, 0x1180) },
+ { PCI_DEVICE(PCI_VENDOR_ID_NI, 0x1190) },
+ { PCI_DEVICE(PCI_VENDOR_ID_NI, 0x11b0) },
+ { PCI_DEVICE(PCI_VENDOR_ID_NI, 0x11c0) },
+ { PCI_DEVICE(PCI_VENDOR_ID_NI, 0x11d0) },
+ { PCI_DEVICE(PCI_VENDOR_ID_NI, 0x1270) },
+ { PCI_DEVICE(PCI_VENDOR_ID_NI, 0x1330) },
+ { PCI_DEVICE(PCI_VENDOR_ID_NI, 0x1340) },
+ { PCI_DEVICE(PCI_VENDOR_ID_NI, 0x1350) },
+ { PCI_DEVICE(PCI_VENDOR_ID_NI, 0x14e0) },
+ { PCI_DEVICE(PCI_VENDOR_ID_NI, 0x14f0) },
+ { PCI_DEVICE(PCI_VENDOR_ID_NI, 0x1580) },
+ { PCI_DEVICE(PCI_VENDOR_ID_NI, 0x15b0) },
+ { PCI_DEVICE(PCI_VENDOR_ID_NI, 0x1880) },
+ { PCI_DEVICE(PCI_VENDOR_ID_NI, 0x1870) },
+ { PCI_DEVICE(PCI_VENDOR_ID_NI, 0x18b0) },
+ { PCI_DEVICE(PCI_VENDOR_ID_NI, 0x18c0) },
+ { PCI_DEVICE(PCI_VENDOR_ID_NI, 0x2410) },
+ { PCI_DEVICE(PCI_VENDOR_ID_NI, 0x2420) },
+ { PCI_DEVICE(PCI_VENDOR_ID_NI, 0x2430) },
+ { PCI_DEVICE(PCI_VENDOR_ID_NI, 0x2890) },
+ { PCI_DEVICE(PCI_VENDOR_ID_NI, 0x28c0) },
+ { PCI_DEVICE(PCI_VENDOR_ID_NI, 0x2a60) },
+ { PCI_DEVICE(PCI_VENDOR_ID_NI, 0x2a70) },
+ { PCI_DEVICE(PCI_VENDOR_ID_NI, 0x2a80) },
+ { PCI_DEVICE(PCI_VENDOR_ID_NI, 0x2ab0) },
+ { PCI_DEVICE(PCI_VENDOR_ID_NI, 0x2b80) },
+ { PCI_DEVICE(PCI_VENDOR_ID_NI, 0x2b90) },
+ { PCI_DEVICE(PCI_VENDOR_ID_NI, 0x2c80) },
+ { PCI_DEVICE(PCI_VENDOR_ID_NI, 0x2ca0) },
+ { PCI_DEVICE(PCI_VENDOR_ID_NI, 0x70aa) },
+ { PCI_DEVICE(PCI_VENDOR_ID_NI, 0x70ab) },
+ { PCI_DEVICE(PCI_VENDOR_ID_NI, 0x70ac) },
+ { PCI_DEVICE(PCI_VENDOR_ID_NI, 0x70af) },
+ { PCI_DEVICE(PCI_VENDOR_ID_NI, 0x70b0) },
+ { PCI_DEVICE(PCI_VENDOR_ID_NI, 0x70b4) },
+ { PCI_DEVICE(PCI_VENDOR_ID_NI, 0x70b6) },
+ { PCI_DEVICE(PCI_VENDOR_ID_NI, 0x70b7) },
+ { PCI_DEVICE(PCI_VENDOR_ID_NI, 0x70b8) },
+ { PCI_DEVICE(PCI_VENDOR_ID_NI, 0x70bc) },
+ { PCI_DEVICE(PCI_VENDOR_ID_NI, 0x70bd) },
+ { PCI_DEVICE(PCI_VENDOR_ID_NI, 0x70bf) },
+ { PCI_DEVICE(PCI_VENDOR_ID_NI, 0x70c0) },
+ { PCI_DEVICE(PCI_VENDOR_ID_NI, 0x70f2) },
+ { PCI_DEVICE(PCI_VENDOR_ID_NI, 0x710d) },
+ { PCI_DEVICE(PCI_VENDOR_ID_NI, 0x716c) },
+ { PCI_DEVICE(PCI_VENDOR_ID_NI, 0x716d) },
+ { PCI_DEVICE(PCI_VENDOR_ID_NI, 0x717f) },
+ { PCI_DEVICE(PCI_VENDOR_ID_NI, 0x71bc) },
+ { PCI_DEVICE(PCI_VENDOR_ID_NI, 0x717d) },
+ { PCI_DEVICE(PCI_VENDOR_ID_NI, 0x72e8) },
+ { 0 }
+};
+MODULE_DEVICE_TABLE(pci, ni_pcimio_pci_table);
+
+static struct pci_driver ni_pcimio_pci_driver = {
+ .name = "ni_pcimio",
+ .id_table = ni_pcimio_pci_table,
+ .probe = ni_pcimio_pci_probe,
+ .remove = __devexit_p(ni_pcimio_pci_remove)
+};
+module_comedi_pci_driver(ni_pcimio_driver, ni_pcimio_pci_driver)
+
MODULE_AUTHOR("Comedi http://www.comedi.org");
MODULE_DESCRIPTION("Comedi low-level driver");
MODULE_LICENSE("GPL");
diff --git a/drivers/staging/comedi/drivers/ni_tio_internal.h b/drivers/staging/comedi/drivers/ni_tio_internal.h
index c4ca53785832..5e00212aa022 100644
--- a/drivers/staging/comedi/drivers/ni_tio_internal.h
+++ b/drivers/staging/comedi/drivers/ni_tio_internal.h
@@ -362,8 +362,8 @@ static inline enum ni_gpct_register NITIO_Gi_ABZ_Reg(int counter_index)
return 0;
}
-static inline enum ni_gpct_register NITIO_Gi_Interrupt_Acknowledge_Reg(int
- counter_index)
+static inline enum ni_gpct_register NITIO_Gi_Interrupt_Acknowledge_Reg(
+ int counter_index)
{
switch (counter_index) {
case 0:
@@ -407,8 +407,8 @@ static inline enum ni_gpct_register NITIO_Gi_Status_Reg(int counter_index)
return 0;
}
-static inline enum ni_gpct_register NITIO_Gi_Interrupt_Enable_Reg(int
- counter_index)
+static inline enum ni_gpct_register NITIO_Gi_Interrupt_Enable_Reg(
+ int counter_index)
{
switch (counter_index) {
case 0:
@@ -472,15 +472,22 @@ enum Gi_Counting_Mode_Reg_Bits {
Gi_Index_Phase_LowA_HighB = 0x1 << Gi_Index_Phase_Bitshift,
Gi_Index_Phase_HighA_LowB = 0x2 << Gi_Index_Phase_Bitshift,
Gi_Index_Phase_HighA_HighB = 0x3 << Gi_Index_Phase_Bitshift,
- Gi_HW_Arm_Enable_Bit = 0x80, /* from m-series example code, not documented in 660x register level manual */
- Gi_660x_HW_Arm_Select_Mask = 0x7 << Gi_HW_Arm_Select_Shift, /* from m-series example code, not documented in 660x register level manual */
+ /* from m-series example code, not documented in 660x register level
+ * manual */
+ Gi_HW_Arm_Enable_Bit = 0x80,
+ /* from m-series example code, not documented in 660x register level
+ * manual */
+ Gi_660x_HW_Arm_Select_Mask = 0x7 << Gi_HW_Arm_Select_Shift,
Gi_660x_Prescale_X8_Bit = 0x1000,
Gi_M_Series_Prescale_X8_Bit = 0x2000,
Gi_M_Series_HW_Arm_Select_Mask = 0x1f << Gi_HW_Arm_Select_Shift,
- /* must be set for clocks over 40MHz, which includes synchronous counting and quadrature modes */
+ /* must be set for clocks over 40MHz, which includes synchronous
+ * counting and quadrature modes */
Gi_660x_Alternate_Sync_Bit = 0x2000,
Gi_M_Series_Alternate_Sync_Bit = 0x4000,
- Gi_660x_Prescale_X2_Bit = 0x4000, /* from m-series example code, not documented in 660x register level manual */
+ /* from m-series example code, not documented in 660x register level
+ * manual */
+ Gi_660x_Prescale_X2_Bit = 0x4000,
Gi_M_Series_Prescale_X2_Bit = 0x8000,
};
@@ -503,7 +510,8 @@ enum Gi_Mode_Bits {
Gi_Level_Gating_Bits = 0x1,
Gi_Rising_Edge_Gating_Bits = 0x2,
Gi_Falling_Edge_Gating_Bits = 0x3,
- Gi_Gate_On_Both_Edges_Bit = 0x4, /* used in conjunction with rising edge gating mode */
+ Gi_Gate_On_Both_Edges_Bit = 0x4, /* used in conjunction with
+ * rising edge gating mode */
Gi_Trigger_Mode_for_Edge_Gate_Mask = 0x18,
Gi_Edge_Gate_Starts_Stops_Bits = 0x0,
Gi_Edge_Gate_Stops_Starts_Bits = 0x8,
@@ -686,11 +694,10 @@ static inline unsigned Gi_Gate_Interrupt_Enable_Bit(unsigned counter_index)
{
unsigned bit;
- if (counter_index % 2) {
+ if (counter_index % 2)
bit = G1_Gate_Interrupt_Enable_Bit;
- } else {
+ else
bit = G0_Gate_Interrupt_Enable_Bit;
- }
return bit;
}
@@ -748,8 +755,9 @@ static inline void ni_tio_set_bits_transient(struct ni_gpct *counter,
}
/* ni_tio_set_bits( ) is for safely writing to registers whose bits may be
-twiddled in interrupt context, or whose software copy may be read in interrupt context.
-*/
+ * twiddled in interrupt context, or whose software copy may be read in
+ * interrupt context.
+ */
static inline void ni_tio_set_bits(struct ni_gpct *counter,
enum ni_gpct_register register_index,
unsigned bit_mask, unsigned bit_values)
diff --git a/drivers/staging/comedi/drivers/pcl711.c b/drivers/staging/comedi/drivers/pcl711.c
index b44386a6b636..bb72d0bc2975 100644
--- a/drivers/staging/comedi/drivers/pcl711.c
+++ b/drivers/staging/comedi/drivers/pcl711.c
@@ -148,42 +148,6 @@ struct pcl711_board {
const struct comedi_lrange *ai_range_type;
};
-static const struct pcl711_board boardtypes[] = {
- {"pcl711", 0, 0, 0, 5, 8, 1, 0, &range_bipolar5},
- {"pcl711b", 1, 0, 0, 5, 8, 1, 7, &range_pcl711b_ai},
- {"acl8112hg", 0, 1, 0, 12, 16, 2, 15, &range_acl8112hg_ai},
- {"acl8112dg", 0, 1, 1, 9, 16, 2, 15, &range_acl8112dg_ai},
-};
-
-#define n_boardtypes (sizeof(boardtypes)/sizeof(struct pcl711_board))
-#define this_board ((const struct pcl711_board *)dev->board_ptr)
-
-static int pcl711_attach(struct comedi_device *dev,
- struct comedi_devconfig *it);
-static int pcl711_detach(struct comedi_device *dev);
-static struct comedi_driver driver_pcl711 = {
- .driver_name = "pcl711",
- .module = THIS_MODULE,
- .attach = pcl711_attach,
- .detach = pcl711_detach,
- .board_name = &boardtypes[0].name,
- .num_names = n_boardtypes,
- .offset = sizeof(struct pcl711_board),
-};
-
-static int __init driver_pcl711_init_module(void)
-{
- return comedi_driver_register(&driver_pcl711);
-}
-
-static void __exit driver_pcl711_cleanup_module(void)
-{
- comedi_driver_unregister(&driver_pcl711);
-}
-
-module_init(driver_pcl711_init_module);
-module_exit(driver_pcl711_cleanup_module);
-
struct pcl711_private {
int board;
@@ -203,6 +167,7 @@ static irqreturn_t pcl711_interrupt(int irq, void *d)
int lo, hi;
int data;
struct comedi_device *dev = d;
+ const struct pcl711_board *board = comedi_board(dev);
struct comedi_subdevice *s = dev->subdevices + 0;
if (!dev->attached) {
@@ -218,7 +183,7 @@ static irqreturn_t pcl711_interrupt(int irq, void *d)
/* FIXME! Nothing else sets ntrig! */
if (!(--devpriv->ntrig)) {
- if (this_board->is_8112)
+ if (board->is_8112)
outb(1, dev->iobase + PCL711_MODE);
else
outb(0, dev->iobase + PCL711_MODE);
@@ -231,13 +196,14 @@ static irqreturn_t pcl711_interrupt(int irq, void *d)
static void pcl711_set_changain(struct comedi_device *dev, int chan)
{
+ const struct pcl711_board *board = comedi_board(dev);
int chan_register;
outb(CR_RANGE(chan), dev->iobase + PCL711_GAIN);
chan_register = CR_CHAN(chan);
- if (this_board->is_8112) {
+ if (board->is_8112) {
/*
* Set the correct channel. The two channel banks are switched
@@ -259,6 +225,7 @@ static void pcl711_set_changain(struct comedi_device *dev, int chan)
static int pcl711_ai_insn(struct comedi_device *dev, struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
+ const struct pcl711_board *board = comedi_board(dev);
int i, n;
int hi, lo;
@@ -271,7 +238,7 @@ static int pcl711_ai_insn(struct comedi_device *dev, struct comedi_subdevice *s,
*/
outb(1, dev->iobase + PCL711_MODE);
- if (!this_board->is_8112)
+ if (!board->is_8112)
outb(0, dev->iobase + PCL711_SOFTTRIG);
i = PCL711_TIMEOUT;
@@ -482,13 +449,10 @@ static int pcl711_di_insn_bits(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
- if (insn->n != 2)
- return -EINVAL;
-
data[1] = inb(dev->iobase + PCL711_DI_LO) |
(inb(dev->iobase + PCL711_DI_HI) << 8);
- return 2;
+ return insn->n;
}
/* Digital port write - Untested on 8112 */
@@ -496,9 +460,6 @@ static int pcl711_do_insn_bits(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
- if (insn->n != 2)
- return -EINVAL;
-
if (data[0]) {
s->state &= ~data[0];
s->state |= data[0] & data[1];
@@ -510,26 +471,12 @@ static int pcl711_do_insn_bits(struct comedi_device *dev,
data[1] = s->state;
- return 2;
-}
-
-/* Free any resources that we have claimed */
-static int pcl711_detach(struct comedi_device *dev)
-{
- printk(KERN_INFO "comedi%d: pcl711: remove\n", dev->minor);
-
- if (dev->irq)
- free_irq(dev->irq, dev);
-
- if (dev->iobase)
- release_region(dev->iobase, PCL711_SIZE);
-
- return 0;
+ return insn->n;
}
-/* Initialization */
static int pcl711_attach(struct comedi_device *dev, struct comedi_devconfig *it)
{
+ const struct pcl711_board *board = comedi_board(dev);
int ret;
unsigned long iobase;
unsigned int irq;
@@ -547,12 +494,11 @@ static int pcl711_attach(struct comedi_device *dev, struct comedi_devconfig *it)
/* there should be a sanity check here */
- /* set up some name stuff */
- dev->board_name = this_board->name;
+ dev->board_name = board->name;
/* grab our IRQ */
irq = it->options[1];
- if (irq > this_board->maxirq) {
+ if (irq > board->maxirq) {
printk(KERN_ERR "irq out of range\n");
return -EINVAL;
}
@@ -566,8 +512,8 @@ static int pcl711_attach(struct comedi_device *dev, struct comedi_devconfig *it)
}
dev->irq = irq;
- ret = alloc_subdevices(dev, 4);
- if (ret < 0)
+ ret = comedi_alloc_subdevices(dev, 4);
+ if (ret)
return ret;
ret = alloc_private(dev, sizeof(struct pcl711_private));
@@ -578,10 +524,10 @@ static int pcl711_attach(struct comedi_device *dev, struct comedi_devconfig *it)
/* AI subdevice */
s->type = COMEDI_SUBD_AI;
s->subdev_flags = SDF_READABLE | SDF_GROUND;
- s->n_chan = this_board->n_aichan;
+ s->n_chan = board->n_aichan;
s->maxdata = 0xfff;
s->len_chanlist = 1;
- s->range_table = this_board->ai_range_type;
+ s->range_table = board->ai_range_type;
s->insn_read = pcl711_ai_insn;
if (irq) {
dev->read_subdev = s;
@@ -594,7 +540,7 @@ static int pcl711_attach(struct comedi_device *dev, struct comedi_devconfig *it)
/* AO subdevice */
s->type = COMEDI_SUBD_AO;
s->subdev_flags = SDF_WRITABLE;
- s->n_chan = this_board->n_aochan;
+ s->n_chan = board->n_aochan;
s->maxdata = 0xfff;
s->len_chanlist = 1;
s->range_table = &range_bipolar5;
@@ -626,7 +572,7 @@ static int pcl711_attach(struct comedi_device *dev, struct comedi_devconfig *it)
this is the "base value" for the mode register, which is
used for the irq on the PCL711
*/
- if (this_board->is_pcl711b)
+ if (board->is_pcl711b)
devpriv->mode = (dev->irq << 4);
/* clear DAC */
@@ -640,6 +586,32 @@ static int pcl711_attach(struct comedi_device *dev, struct comedi_devconfig *it)
return 0;
}
+static void pcl711_detach(struct comedi_device *dev)
+{
+ if (dev->irq)
+ free_irq(dev->irq, dev);
+ if (dev->iobase)
+ release_region(dev->iobase, PCL711_SIZE);
+}
+
+static const struct pcl711_board boardtypes[] = {
+ { "pcl711", 0, 0, 0, 5, 8, 1, 0, &range_bipolar5 },
+ { "pcl711b", 1, 0, 0, 5, 8, 1, 7, &range_pcl711b_ai },
+ { "acl8112hg", 0, 1, 0, 12, 16, 2, 15, &range_acl8112hg_ai },
+ { "acl8112dg", 0, 1, 1, 9, 16, 2, 15, &range_acl8112dg_ai },
+};
+
+static struct comedi_driver pcl711_driver = {
+ .driver_name = "pcl711",
+ .module = THIS_MODULE,
+ .attach = pcl711_attach,
+ .detach = pcl711_detach,
+ .board_name = &boardtypes[0].name,
+ .num_names = ARRAY_SIZE(boardtypes),
+ .offset = sizeof(struct pcl711_board),
+};
+module_comedi_driver(pcl711_driver);
+
MODULE_AUTHOR("Comedi http://www.comedi.org");
MODULE_DESCRIPTION("Comedi low-level driver");
MODULE_LICENSE("GPL");
diff --git a/drivers/staging/comedi/drivers/pcl724.c b/drivers/staging/comedi/drivers/pcl724.c
index 61b075db66ef..c8fe23ca899d 100644
--- a/drivers/staging/comedi/drivers/pcl724.c
+++ b/drivers/staging/comedi/drivers/pcl724.c
@@ -56,10 +56,6 @@ See the source for configuration details.
/* #define PCL724_IRQ 1 no IRQ support now */
-static int pcl724_attach(struct comedi_device *dev,
- struct comedi_devconfig *it);
-static int pcl724_detach(struct comedi_device *dev);
-
struct pcl724_board {
const char *name; /* board name */
@@ -71,41 +67,6 @@ struct pcl724_board {
char is_pet48;
};
-static const struct pcl724_board boardtypes[] = {
- {"pcl724", 24, 1, 0x00fc, PCL724_SIZE, 0, 0,},
- {"pcl722", 144, 6, 0x00fc, PCL722_SIZE, 1, 0,},
- {"pcl731", 48, 2, 0x9cfc, PCL731_SIZE, 0, 0,},
- {"acl7122", 144, 6, 0x9ee8, PCL722_SIZE, 1, 0,},
- {"acl7124", 24, 1, 0x00fc, PCL724_SIZE, 0, 0,},
- {"pet48dio", 48, 2, 0x9eb8, PET48_SIZE, 0, 1,},
-};
-
-#define n_boardtypes (sizeof(boardtypes)/sizeof(struct pcl724_board))
-#define this_board ((const struct pcl724_board *)dev->board_ptr)
-
-static struct comedi_driver driver_pcl724 = {
- .driver_name = "pcl724",
- .module = THIS_MODULE,
- .attach = pcl724_attach,
- .detach = pcl724_detach,
- .board_name = &boardtypes[0].name,
- .num_names = n_boardtypes,
- .offset = sizeof(struct pcl724_board),
-};
-
-static int __init driver_pcl724_init_module(void)
-{
- return comedi_driver_register(&driver_pcl724);
-}
-
-static void __exit driver_pcl724_cleanup_module(void)
-{
- comedi_driver_unregister(&driver_pcl724);
-}
-
-module_init(driver_pcl724_init_module);
-module_exit(driver_pcl724_cleanup_module);
-
static int subdev_8255_cb(int dir, int port, int data, unsigned long arg)
{
unsigned long iobase = arg;
@@ -137,6 +98,7 @@ static int subdev_8255mapped_cb(int dir, int port, int data,
static int pcl724_attach(struct comedi_device *dev, struct comedi_devconfig *it)
{
+ const struct pcl724_board *board = comedi_board(dev);
unsigned long iobase;
unsigned int iorange;
int ret, i, n_subdevices;
@@ -145,12 +107,12 @@ static int pcl724_attach(struct comedi_device *dev, struct comedi_devconfig *it)
#endif
iobase = it->options[0];
- iorange = this_board->io_range;
- if ((this_board->can_have96) && ((it->options[1] == 1)
+ iorange = board->io_range;
+ if ((board->can_have96) && ((it->options[1] == 1)
|| (it->options[1] == 96)))
iorange = PCL722_96_SIZE; /* PCL-724 in 96 DIO configuration */
printk(KERN_INFO "comedi%d: pcl724: board=%s, 0x%03lx ", dev->minor,
- this_board->name, iobase);
+ board->name, iobase);
if (!request_region(iobase, iorange, "pcl724")) {
printk("I/O port conflict\n");
return -EIO;
@@ -158,14 +120,14 @@ static int pcl724_attach(struct comedi_device *dev, struct comedi_devconfig *it)
dev->iobase = iobase;
- dev->board_name = this_board->name;
+ dev->board_name = board->name;
#ifdef PCL724_IRQ
irq = 0;
- if (this_board->IRQbits != 0) { /* board support IRQ */
+ if (board->IRQbits != 0) { /* board support IRQ */
irq = it->options[1];
if (irq) { /* we want to use IRQ */
- if (((1 << irq) & this_board->IRQbits) == 0) {
+ if (((1 << irq) & board->IRQbits) == 0) {
printk(KERN_WARNING
", IRQ %u is out of allowed range, "
"DISABLING IT", irq);
@@ -189,17 +151,17 @@ static int pcl724_attach(struct comedi_device *dev, struct comedi_devconfig *it)
printk("\n");
- n_subdevices = this_board->numofports;
- if ((this_board->can_have96) && ((it->options[1] == 1)
+ n_subdevices = board->numofports;
+ if ((board->can_have96) && ((it->options[1] == 1)
|| (it->options[1] == 96)))
n_subdevices = 4; /* PCL-724 in 96 DIO configuration */
- ret = alloc_subdevices(dev, n_subdevices);
- if (ret < 0)
+ ret = comedi_alloc_subdevices(dev, n_subdevices);
+ if (ret)
return ret;
for (i = 0; i < dev->n_subdevices; i++) {
- if (this_board->is_pet48) {
+ if (board->is_pet48) {
subdev_8255_init(dev, dev->subdevices + i,
subdev_8255mapped_cb,
(unsigned long)(dev->iobase +
@@ -214,24 +176,39 @@ static int pcl724_attach(struct comedi_device *dev, struct comedi_devconfig *it)
return 0;
}
-static int pcl724_detach(struct comedi_device *dev)
+static void pcl724_detach(struct comedi_device *dev)
{
+ const struct pcl724_board *board = comedi_board(dev);
int i;
- /* printk("comedi%d: pcl724: remove\n",dev->minor); */
-
for (i = 0; i < dev->n_subdevices; i++)
subdev_8255_cleanup(dev, dev->subdevices + i);
-
#ifdef PCL724_IRQ
if (dev->irq)
free_irq(dev->irq, dev);
#endif
+ release_region(dev->iobase, board->io_range);
+}
- release_region(dev->iobase, this_board->io_range);
+static const struct pcl724_board boardtypes[] = {
+ { "pcl724", 24, 1, 0x00fc, PCL724_SIZE, 0, 0, },
+ { "pcl722", 144, 6, 0x00fc, PCL722_SIZE, 1, 0, },
+ { "pcl731", 48, 2, 0x9cfc, PCL731_SIZE, 0, 0, },
+ { "acl7122", 144, 6, 0x9ee8, PCL722_SIZE, 1, 0, },
+ { "acl7124", 24, 1, 0x00fc, PCL724_SIZE, 0, 0, },
+ { "pet48dio", 48, 2, 0x9eb8, PET48_SIZE, 0, 1, },
+};
- return 0;
-}
+static struct comedi_driver pcl724_driver = {
+ .driver_name = "pcl724",
+ .module = THIS_MODULE,
+ .attach = pcl724_attach,
+ .detach = pcl724_detach,
+ .board_name = &boardtypes[0].name,
+ .num_names = ARRAY_SIZE(boardtypes),
+ .offset = sizeof(struct pcl724_board),
+};
+module_comedi_driver(pcl724_driver);
MODULE_AUTHOR("Comedi http://www.comedi.org");
MODULE_DESCRIPTION("Comedi low-level driver");
diff --git a/drivers/staging/comedi/drivers/pcl725.c b/drivers/staging/comedi/drivers/pcl725.c
index 24b223ca4399..d5b60cf7c93f 100644
--- a/drivers/staging/comedi/drivers/pcl725.c
+++ b/drivers/staging/comedi/drivers/pcl725.c
@@ -20,35 +20,9 @@ Devices: [Advantech] PCL-725 (pcl725)
#define PCL725_DO 0
#define PCL725_DI 1
-static int pcl725_attach(struct comedi_device *dev,
- struct comedi_devconfig *it);
-static int pcl725_detach(struct comedi_device *dev);
-static struct comedi_driver driver_pcl725 = {
- .driver_name = "pcl725",
- .module = THIS_MODULE,
- .attach = pcl725_attach,
- .detach = pcl725_detach,
-};
-
-static int __init driver_pcl725_init_module(void)
-{
- return comedi_driver_register(&driver_pcl725);
-}
-
-static void __exit driver_pcl725_cleanup_module(void)
-{
- comedi_driver_unregister(&driver_pcl725);
-}
-
-module_init(driver_pcl725_init_module);
-module_exit(driver_pcl725_cleanup_module);
-
static int pcl725_do_insn(struct comedi_device *dev, struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
- if (insn->n != 2)
- return -EINVAL;
-
if (data[0]) {
s->state &= ~data[0];
s->state |= (data[0] & data[1]);
@@ -57,24 +31,22 @@ static int pcl725_do_insn(struct comedi_device *dev, struct comedi_subdevice *s,
data[1] = s->state;
- return 2;
+ return insn->n;
}
static int pcl725_di_insn(struct comedi_device *dev, struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
- if (insn->n != 2)
- return -EINVAL;
-
data[1] = inb(dev->iobase + PCL725_DI);
- return 2;
+ return insn->n;
}
static int pcl725_attach(struct comedi_device *dev, struct comedi_devconfig *it)
{
struct comedi_subdevice *s;
unsigned long iobase;
+ int ret;
iobase = it->options[0];
printk(KERN_INFO "comedi%d: pcl725: 0x%04lx ", dev->minor, iobase);
@@ -86,8 +58,9 @@ static int pcl725_attach(struct comedi_device *dev, struct comedi_devconfig *it)
dev->iobase = iobase;
dev->irq = 0;
- if (alloc_subdevices(dev, 2) < 0)
- return -ENOMEM;
+ ret = comedi_alloc_subdevices(dev, 2);
+ if (ret)
+ return ret;
s = dev->subdevices + 0;
/* do */
@@ -112,16 +85,20 @@ static int pcl725_attach(struct comedi_device *dev, struct comedi_devconfig *it)
return 0;
}
-static int pcl725_detach(struct comedi_device *dev)
+static void pcl725_detach(struct comedi_device *dev)
{
- printk(KERN_INFO "comedi%d: pcl725: remove\n", dev->minor);
-
if (dev->iobase)
release_region(dev->iobase, PCL725_SIZE);
-
- return 0;
}
+static struct comedi_driver pcl725_driver = {
+ .driver_name = "pcl725",
+ .module = THIS_MODULE,
+ .attach = pcl725_attach,
+ .detach = pcl725_detach,
+};
+module_comedi_driver(pcl725_driver);
+
MODULE_AUTHOR("Comedi http://www.comedi.org");
MODULE_DESCRIPTION("Comedi low-level driver");
MODULE_LICENSE("GPL");
diff --git a/drivers/staging/comedi/drivers/pcl726.c b/drivers/staging/comedi/drivers/pcl726.c
index 897cd808eeb7..2b10f1d83085 100644
--- a/drivers/staging/comedi/drivers/pcl726.c
+++ b/drivers/staging/comedi/drivers/pcl726.c
@@ -111,10 +111,6 @@ static const struct comedi_lrange *const rangelist_728[] = {
&range_4_20mA, &range_0_20mA
};
-static int pcl726_attach(struct comedi_device *dev,
- struct comedi_devconfig *it);
-static int pcl726_detach(struct comedi_device *dev);
-
struct pcl726_board {
const char *name; /* driver name */
@@ -149,32 +145,6 @@ static const struct pcl726_board boardtypes[] = {
&rangelist_728[0],},
};
-#define n_boardtypes (sizeof(boardtypes)/sizeof(struct pcl726_board))
-#define this_board ((const struct pcl726_board *)dev->board_ptr)
-
-static struct comedi_driver driver_pcl726 = {
- .driver_name = "pcl726",
- .module = THIS_MODULE,
- .attach = pcl726_attach,
- .detach = pcl726_detach,
- .board_name = &boardtypes[0].name,
- .num_names = n_boardtypes,
- .offset = sizeof(struct pcl726_board),
-};
-
-static int __init driver_pcl726_init_module(void)
-{
- return comedi_driver_register(&driver_pcl726);
-}
-
-static void __exit driver_pcl726_cleanup_module(void)
-{
- comedi_driver_unregister(&driver_pcl726);
-}
-
-module_init(driver_pcl726_init_module);
-module_exit(driver_pcl726_cleanup_module);
-
struct pcl726_private {
int bipolar[12];
@@ -225,38 +195,37 @@ static int pcl726_di_insn_bits(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
- if (insn->n != 2)
- return -EINVAL;
+ const struct pcl726_board *board = comedi_board(dev);
- data[1] = inb(dev->iobase + this_board->di_lo) |
- (inb(dev->iobase + this_board->di_hi) << 8);
+ data[1] = inb(dev->iobase + board->di_lo) |
+ (inb(dev->iobase + board->di_hi) << 8);
- return 2;
+ return insn->n;
}
static int pcl726_do_insn_bits(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
- if (insn->n != 2)
- return -EINVAL;
+ const struct pcl726_board *board = comedi_board(dev);
if (data[0]) {
s->state &= ~data[0];
s->state |= data[0] & data[1];
}
if (data[1] & 0x00ff)
- outb(s->state & 0xff, dev->iobase + this_board->do_lo);
+ outb(s->state & 0xff, dev->iobase + board->do_lo);
if (data[1] & 0xff00)
- outb((s->state >> 8), dev->iobase + this_board->do_hi);
+ outb((s->state >> 8), dev->iobase + board->do_hi);
data[1] = s->state;
- return 2;
+ return insn->n;
}
static int pcl726_attach(struct comedi_device *dev, struct comedi_devconfig *it)
{
+ const struct pcl726_board *board = comedi_board(dev);
struct comedi_subdevice *s;
unsigned long iobase;
unsigned int iorange;
@@ -266,9 +235,9 @@ static int pcl726_attach(struct comedi_device *dev, struct comedi_devconfig *it)
#endif
iobase = it->options[0];
- iorange = this_board->io_range;
+ iorange = board->io_range;
printk(KERN_WARNING "comedi%d: pcl726: board=%s, 0x%03lx ", dev->minor,
- this_board->name, iobase);
+ board->name, iobase);
if (!request_region(iobase, iorange, "pcl726")) {
printk(KERN_WARNING "I/O port conflict\n");
return -EIO;
@@ -276,7 +245,7 @@ static int pcl726_attach(struct comedi_device *dev, struct comedi_devconfig *it)
dev->iobase = iobase;
- dev->board_name = this_board->name;
+ dev->board_name = board->name;
ret = alloc_private(dev, sizeof(struct pcl726_private));
if (ret < 0)
@@ -317,31 +286,31 @@ static int pcl726_attach(struct comedi_device *dev, struct comedi_devconfig *it)
printk("\n");
- ret = alloc_subdevices(dev, 3);
- if (ret < 0)
+ ret = comedi_alloc_subdevices(dev, 3);
+ if (ret)
return ret;
s = dev->subdevices + 0;
/* ao */
s->type = COMEDI_SUBD_AO;
s->subdev_flags = SDF_WRITABLE | SDF_GROUND;
- s->n_chan = this_board->n_aochan;
+ s->n_chan = board->n_aochan;
s->maxdata = 0xfff;
s->len_chanlist = 1;
s->insn_write = pcl726_ao_insn;
s->insn_read = pcl726_ao_insn_read;
s->range_table_list = devpriv->rangelist;
- for (i = 0; i < this_board->n_aochan; i++) {
+ for (i = 0; i < board->n_aochan; i++) {
int j;
j = it->options[2 + 1];
- if ((j < 0) || (j >= this_board->num_of_ranges)) {
+ if ((j < 0) || (j >= board->num_of_ranges)) {
printk
("Invalid range for channel %d! Must be 0<=%d<%d\n",
- i, j, this_board->num_of_ranges - 1);
+ i, j, board->num_of_ranges - 1);
j = 0;
}
- devpriv->rangelist[i] = this_board->range_type_list[j];
+ devpriv->rangelist[i] = board->range_type_list[j];
if (devpriv->rangelist[i]->range[0].min ==
-devpriv->rangelist[i]->range[0].max)
devpriv->bipolar[i] = 1; /* bipolar range */
@@ -349,7 +318,7 @@ static int pcl726_attach(struct comedi_device *dev, struct comedi_devconfig *it)
s = dev->subdevices + 1;
/* di */
- if (!this_board->have_dio) {
+ if (!board->have_dio) {
s->type = COMEDI_SUBD_UNUSED;
} else {
s->type = COMEDI_SUBD_DI;
@@ -363,7 +332,7 @@ static int pcl726_attach(struct comedi_device *dev, struct comedi_devconfig *it)
s = dev->subdevices + 2;
/* do */
- if (!this_board->have_dio) {
+ if (!board->have_dio) {
s->type = COMEDI_SUBD_UNUSED;
} else {
s->type = COMEDI_SUBD_DO;
@@ -378,21 +347,29 @@ static int pcl726_attach(struct comedi_device *dev, struct comedi_devconfig *it)
return 0;
}
-static int pcl726_detach(struct comedi_device *dev)
+static void pcl726_detach(struct comedi_device *dev)
{
-/* printk("comedi%d: pcl726: remove\n",dev->minor); */
+ const struct pcl726_board *board = comedi_board(dev);
#ifdef ACL6126_IRQ
if (dev->irq)
free_irq(dev->irq, dev);
#endif
-
if (dev->iobase)
- release_region(dev->iobase, this_board->io_range);
-
- return 0;
+ release_region(dev->iobase, board->io_range);
}
+static struct comedi_driver pcl726_driver = {
+ .driver_name = "pcl726",
+ .module = THIS_MODULE,
+ .attach = pcl726_attach,
+ .detach = pcl726_detach,
+ .board_name = &boardtypes[0].name,
+ .num_names = ARRAY_SIZE(boardtypes),
+ .offset = sizeof(struct pcl726_board),
+};
+module_comedi_driver(pcl726_driver);
+
MODULE_AUTHOR("Comedi http://www.comedi.org");
MODULE_DESCRIPTION("Comedi low-level driver");
MODULE_LICENSE("GPL");
diff --git a/drivers/staging/comedi/drivers/pcl730.c b/drivers/staging/comedi/drivers/pcl730.c
index c9682d614e0e..4675ec57082e 100644
--- a/drivers/staging/comedi/drivers/pcl730.c
+++ b/drivers/staging/comedi/drivers/pcl730.c
@@ -26,54 +26,15 @@ The ACL-7130 card have an 8254 timer/counter not supported by this driver.
#define PCL730_DIO_LO 2 /* TTL Digital I/O low byte (D0-D7) */
#define PCL730_DIO_HI 3 /* TTL Digital I/O high byte (D8-D15) */
-static int pcl730_attach(struct comedi_device *dev,
- struct comedi_devconfig *it);
-static int pcl730_detach(struct comedi_device *dev);
-
struct pcl730_board {
const char *name; /* board name */
unsigned int io_range; /* len of I/O space */
};
-static const struct pcl730_board boardtypes[] = {
- {"pcl730", PCL730_SIZE,},
- {"iso730", PCL730_SIZE,},
- {"acl7130", ACL7130_SIZE,},
-};
-
-#define n_boardtypes (sizeof(boardtypes)/sizeof(struct pcl730_board))
-#define this_board ((const struct pcl730_board *)dev->board_ptr)
-
-static struct comedi_driver driver_pcl730 = {
- .driver_name = "pcl730",
- .module = THIS_MODULE,
- .attach = pcl730_attach,
- .detach = pcl730_detach,
- .board_name = &boardtypes[0].name,
- .num_names = n_boardtypes,
- .offset = sizeof(struct pcl730_board),
-};
-
-static int __init driver_pcl730_init_module(void)
-{
- return comedi_driver_register(&driver_pcl730);
-}
-
-static void __exit driver_pcl730_cleanup_module(void)
-{
- comedi_driver_unregister(&driver_pcl730);
-}
-
-module_init(driver_pcl730_init_module);
-module_exit(driver_pcl730_cleanup_module);
-
static int pcl730_do_insn(struct comedi_device *dev, struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
- if (insn->n != 2)
- return -EINVAL;
-
if (data[0]) {
s->state &= ~data[0];
s->state |= (data[0] & data[1]);
@@ -87,41 +48,41 @@ static int pcl730_do_insn(struct comedi_device *dev, struct comedi_subdevice *s,
data[1] = s->state;
- return 2;
+ return insn->n;
}
static int pcl730_di_insn(struct comedi_device *dev, struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
- if (insn->n != 2)
- return -EINVAL;
-
data[1] = inb(dev->iobase + ((unsigned long)s->private)) |
(inb(dev->iobase + ((unsigned long)s->private) + 1) << 8);
- return 2;
+ return insn->n;
}
static int pcl730_attach(struct comedi_device *dev, struct comedi_devconfig *it)
{
+ const struct pcl730_board *board = comedi_board(dev);
struct comedi_subdevice *s;
unsigned long iobase;
unsigned int iorange;
+ int ret;
iobase = it->options[0];
- iorange = this_board->io_range;
+ iorange = board->io_range;
printk(KERN_INFO "comedi%d: pcl730: board=%s 0x%04lx ", dev->minor,
- this_board->name, iobase);
+ board->name, iobase);
if (!request_region(iobase, iorange, "pcl730")) {
printk("I/O port conflict\n");
return -EIO;
}
- dev->board_name = this_board->name;
+ dev->board_name = board->name;
dev->iobase = iobase;
dev->irq = 0;
- if (alloc_subdevices(dev, 4) < 0)
- return -ENOMEM;
+ ret = comedi_alloc_subdevices(dev, 4);
+ if (ret)
+ return ret;
s = dev->subdevices + 0;
/* Isolated do */
@@ -168,16 +129,31 @@ static int pcl730_attach(struct comedi_device *dev, struct comedi_devconfig *it)
return 0;
}
-static int pcl730_detach(struct comedi_device *dev)
+static void pcl730_detach(struct comedi_device *dev)
{
- printk(KERN_INFO "comedi%d: pcl730: remove\n", dev->minor);
+ const struct pcl730_board *board = comedi_board(dev);
if (dev->iobase)
- release_region(dev->iobase, this_board->io_range);
-
- return 0;
+ release_region(dev->iobase, board->io_range);
}
+static const struct pcl730_board boardtypes[] = {
+ { "pcl730", PCL730_SIZE, },
+ { "iso730", PCL730_SIZE, },
+ { "acl7130", ACL7130_SIZE, },
+};
+
+static struct comedi_driver pcl730_driver = {
+ .driver_name = "pcl730",
+ .module = THIS_MODULE,
+ .attach = pcl730_attach,
+ .detach = pcl730_detach,
+ .board_name = &boardtypes[0].name,
+ .num_names = ARRAY_SIZE(boardtypes),
+ .offset = sizeof(struct pcl730_board),
+};
+module_comedi_driver(pcl730_driver);
+
MODULE_AUTHOR("Comedi http://www.comedi.org");
MODULE_DESCRIPTION("Comedi low-level driver");
MODULE_LICENSE("GPL");
diff --git a/drivers/staging/comedi/drivers/pcl812.c b/drivers/staging/comedi/drivers/pcl812.c
index 6fc74645af2c..578fd8920be1 100644
--- a/drivers/staging/comedi/drivers/pcl812.c
+++ b/drivers/staging/comedi/drivers/pcl812.c
@@ -119,9 +119,6 @@
#include "8253.h"
-/* if this is defined then a lot of messages is printed */
-#undef PCL812_EXTDEBUG
-
/* hardware types of the cards */
#define boardPCL812PG 0 /* and ACL-8112PG */
#define boardPCL813B 1
@@ -316,10 +313,6 @@ static const struct comedi_lrange range_a821pgh_ai = { 4, {
}
};
-static int pcl812_attach(struct comedi_device *dev,
- struct comedi_devconfig *it);
-static int pcl812_detach(struct comedi_device *dev);
-
struct pcl812_board {
const char *name; /* board name */
@@ -340,89 +333,6 @@ struct pcl812_board {
unsigned char haveMPC508; /* 1=board use MPC508A multiplexor */
};
-static const struct pcl812_board boardtypes[] = {
- {"pcl812", boardPCL812, 16, 0, 2, 16, 16, 0x0fff,
- 33000, 500, &range_bipolar10, &range_unipolar5,
- 0xdcfc, 0x0a, PCLx1x_IORANGE, 0},
- {"pcl812pg", boardPCL812PG, 16, 0, 2, 16, 16, 0x0fff,
- 33000, 500, &range_pcl812pg_ai, &range_unipolar5,
- 0xdcfc, 0x0a, PCLx1x_IORANGE, 0},
- {"acl8112pg", boardPCL812PG, 16, 0, 2, 16, 16, 0x0fff,
- 10000, 500, &range_pcl812pg_ai, &range_unipolar5,
- 0xdcfc, 0x0a, PCLx1x_IORANGE, 0},
- {"acl8112dg", boardACL8112, 16, 8, 2, 16, 16, 0x0fff,
- 10000, 500, &range_acl8112dg_ai, &range_unipolar5,
- 0xdcfc, 0x0a, PCLx1x_IORANGE, 1},
- {"acl8112hg", boardACL8112, 16, 8, 2, 16, 16, 0x0fff,
- 10000, 500, &range_acl8112hg_ai, &range_unipolar5,
- 0xdcfc, 0x0a, PCLx1x_IORANGE, 1},
- {"a821pgl", boardA821, 16, 8, 1, 16, 16, 0x0fff,
- 10000, 500, &range_pcl813b_ai, &range_unipolar5,
- 0x000c, 0x00, PCLx1x_IORANGE, 0},
- {"a821pglnda", boardA821, 16, 8, 0, 0, 0, 0x0fff,
- 10000, 500, &range_pcl813b_ai, NULL,
- 0x000c, 0x00, PCLx1x_IORANGE, 0},
- {"a821pgh", boardA821, 16, 8, 1, 16, 16, 0x0fff,
- 10000, 500, &range_a821pgh_ai, &range_unipolar5,
- 0x000c, 0x00, PCLx1x_IORANGE, 0},
- {"a822pgl", boardACL8112, 16, 8, 2, 16, 16, 0x0fff,
- 10000, 500, &range_acl8112dg_ai, &range_unipolar5,
- 0xdcfc, 0x0a, PCLx1x_IORANGE, 0},
- {"a822pgh", boardACL8112, 16, 8, 2, 16, 16, 0x0fff,
- 10000, 500, &range_acl8112hg_ai, &range_unipolar5,
- 0xdcfc, 0x0a, PCLx1x_IORANGE, 0},
- {"a823pgl", boardACL8112, 16, 8, 2, 16, 16, 0x0fff,
- 8000, 500, &range_acl8112dg_ai, &range_unipolar5,
- 0xdcfc, 0x0a, PCLx1x_IORANGE, 0},
- {"a823pgh", boardACL8112, 16, 8, 2, 16, 16, 0x0fff,
- 8000, 500, &range_acl8112hg_ai, &range_unipolar5,
- 0xdcfc, 0x0a, PCLx1x_IORANGE, 0},
- {"pcl813", boardPCL813, 32, 0, 0, 0, 0, 0x0fff,
- 0, 0, &range_pcl813b_ai, NULL,
- 0x0000, 0x00, PCLx1x_IORANGE, 0},
- {"pcl813b", boardPCL813B, 32, 0, 0, 0, 0, 0x0fff,
- 0, 0, &range_pcl813b_ai, NULL,
- 0x0000, 0x00, PCLx1x_IORANGE, 0},
- {"acl8113", boardACL8113, 32, 0, 0, 0, 0, 0x0fff,
- 0, 0, &range_acl8113_1_ai, NULL,
- 0x0000, 0x00, PCLx1x_IORANGE, 0},
- {"iso813", boardISO813, 32, 0, 0, 0, 0, 0x0fff,
- 0, 0, &range_iso813_1_ai, NULL,
- 0x0000, 0x00, PCLx1x_IORANGE, 0},
- {"acl8216", boardACL8216, 16, 8, 2, 16, 16, 0xffff,
- 10000, 500, &range_pcl813b2_ai, &range_unipolar5,
- 0xdcfc, 0x0a, PCLx1x_IORANGE, 1},
- {"a826pg", boardACL8216, 16, 8, 2, 16, 16, 0xffff,
- 10000, 500, &range_pcl813b2_ai, &range_unipolar5,
- 0xdcfc, 0x0a, PCLx1x_IORANGE, 0},
-};
-
-#define n_boardtypes (sizeof(boardtypes)/sizeof(struct pcl812_board))
-#define this_board ((const struct pcl812_board *)dev->board_ptr)
-
-static struct comedi_driver driver_pcl812 = {
- .driver_name = "pcl812",
- .module = THIS_MODULE,
- .attach = pcl812_attach,
- .detach = pcl812_detach,
- .board_name = &boardtypes[0].name,
- .num_names = n_boardtypes,
- .offset = sizeof(struct pcl812_board),
-};
-
-static int __init driver_pcl812_init_module(void)
-{
- return comedi_driver_register(&driver_pcl812);
-}
-
-static void __exit driver_pcl812_cleanup_module(void)
-{
- comedi_driver_unregister(&driver_pcl812);
-}
-
-module_init(driver_pcl812_init_module);
-module_exit(driver_pcl812_cleanup_module);
-
struct pcl812_private {
unsigned char valid; /* =1 device is OK */
@@ -591,13 +501,10 @@ static int pcl812_di_insn_bits(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
- if (insn->n != 2)
- return -EINVAL;
-
data[1] = inb(dev->iobase + PCL812_DI_LO);
data[1] |= inb(dev->iobase + PCL812_DI_HI) << 8;
- return 2;
+ return insn->n;
}
/*
@@ -607,9 +514,6 @@ static int pcl812_do_insn_bits(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
- if (insn->n != 2)
- return -EINVAL;
-
if (data[0]) {
s->state &= ~data[0];
s->state |= data[0] & data[1];
@@ -618,40 +522,19 @@ static int pcl812_do_insn_bits(struct comedi_device *dev,
}
data[1] = s->state;
- return 2;
+ return insn->n;
}
-#ifdef PCL812_EXTDEBUG
-/*
-==============================================================================
-*/
-static void pcl812_cmdtest_out(int e, struct comedi_cmd *cmd)
-{
- printk(KERN_INFO "pcl812 e=%d startsrc=%x scansrc=%x convsrc=%x\n", e,
- cmd->start_src, cmd->scan_begin_src, cmd->convert_src);
- printk(KERN_INFO "pcl812 e=%d startarg=%d scanarg=%d convarg=%d\n", e,
- cmd->start_arg, cmd->scan_begin_arg, cmd->convert_arg);
- printk(KERN_INFO "pcl812 e=%d stopsrc=%x scanend=%x\n", e,
- cmd->stop_src, cmd->scan_end_src);
- printk(KERN_INFO "pcl812 e=%d stoparg=%d scanendarg=%d "
- "chanlistlen=%d\n", e, cmd->stop_arg, cmd->scan_end_arg,
- cmd->chanlist_len);
-}
-#endif
-
/*
==============================================================================
*/
static int pcl812_ai_cmdtest(struct comedi_device *dev,
struct comedi_subdevice *s, struct comedi_cmd *cmd)
{
+ const struct pcl812_board *board = comedi_board(dev);
int err = 0;
int tmp, divisor1, divisor2;
-#ifdef PCL812_EXTDEBUG
- printk("pcl812 EDBG: BGN: pcl812_ai_cmdtest(...)\n");
- pcl812_cmdtest_out(-1, cmd);
-#endif
/* step 1: make sure trigger sources are trivially valid */
tmp = cmd->start_src;
@@ -683,60 +566,19 @@ static int pcl812_ai_cmdtest(struct comedi_device *dev,
if (!cmd->stop_src || tmp != cmd->stop_src)
err++;
- if (err) {
-#ifdef PCL812_EXTDEBUG
- pcl812_cmdtest_out(1, cmd);
- printk
- ("pcl812 EDBG: BGN: pcl812_ai_cmdtest(...) err=%d ret=1\n",
- err);
-#endif
+ if (err)
return 1;
- }
/*
* step 2: make sure trigger sources are
* unique and mutually compatible
*/
- if (cmd->start_src != TRIG_NOW) {
- cmd->start_src = TRIG_NOW;
- err++;
- }
-
- if (cmd->scan_begin_src != TRIG_FOLLOW) {
- cmd->scan_begin_src = TRIG_FOLLOW;
- err++;
- }
-
- if (devpriv->use_ext_trg) {
- if (cmd->convert_src != TRIG_EXT) {
- cmd->convert_src = TRIG_EXT;
- err++;
- }
- } else {
- if (cmd->convert_src != TRIG_TIMER) {
- cmd->convert_src = TRIG_TIMER;
- err++;
- }
- }
-
- if (cmd->scan_end_src != TRIG_COUNT) {
- cmd->scan_end_src = TRIG_COUNT;
- err++;
- }
-
if (cmd->stop_src != TRIG_NONE && cmd->stop_src != TRIG_COUNT)
err++;
- if (err) {
-#ifdef PCL812_EXTDEBUG
- pcl812_cmdtest_out(2, cmd);
- printk
- ("pcl812 EDBG: BGN: pcl812_ai_cmdtest(...) err=%d ret=2\n",
- err);
-#endif
+ if (err)
return 2;
- }
/* step 3: make sure arguments are trivially compatible */
@@ -751,8 +593,8 @@ static int pcl812_ai_cmdtest(struct comedi_device *dev,
}
if (cmd->convert_src == TRIG_TIMER) {
- if (cmd->convert_arg < this_board->ai_ns_min) {
- cmd->convert_arg = this_board->ai_ns_min;
+ if (cmd->convert_arg < board->ai_ns_min) {
+ cmd->convert_arg = board->ai_ns_min;
err++;
}
} else { /* TRIG_EXT */
@@ -767,7 +609,7 @@ static int pcl812_ai_cmdtest(struct comedi_device *dev,
err++;
}
if (cmd->chanlist_len > MAX_CHANLIST_LEN) {
- cmd->chanlist_len = this_board->n_aichan;
+ cmd->chanlist_len = board->n_aichan;
err++;
}
if (cmd->scan_end_arg != cmd->chanlist_len) {
@@ -786,37 +628,24 @@ static int pcl812_ai_cmdtest(struct comedi_device *dev,
}
}
- if (err) {
-#ifdef PCL812_EXTDEBUG
- pcl812_cmdtest_out(3, cmd);
- printk
- ("pcl812 EDBG: BGN: pcl812_ai_cmdtest(...) err=%d ret=3\n",
- err);
-#endif
+ if (err)
return 3;
- }
/* step 4: fix up any arguments */
if (cmd->convert_src == TRIG_TIMER) {
tmp = cmd->convert_arg;
- i8253_cascade_ns_to_timer(this_board->i8254_osc_base, &divisor1,
+ i8253_cascade_ns_to_timer(board->i8254_osc_base, &divisor1,
&divisor2, &cmd->convert_arg,
cmd->flags & TRIG_ROUND_MASK);
- if (cmd->convert_arg < this_board->ai_ns_min)
- cmd->convert_arg = this_board->ai_ns_min;
+ if (cmd->convert_arg < board->ai_ns_min)
+ cmd->convert_arg = board->ai_ns_min;
if (tmp != cmd->convert_arg)
err++;
}
- if (err) {
-#ifdef PCL812_EXTDEBUG
- printk
- ("pcl812 EDBG: BGN: pcl812_ai_cmdtest(...) err=%d ret=4\n",
- err);
-#endif
+ if (err)
return 4;
- }
return 0;
}
@@ -826,13 +655,10 @@ static int pcl812_ai_cmdtest(struct comedi_device *dev,
*/
static int pcl812_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
{
+ const struct pcl812_board *board = comedi_board(dev);
unsigned int divisor1 = 0, divisor2 = 0, i, dma_flags, bytes;
struct comedi_cmd *cmd = &s->async->cmd;
-#ifdef PCL812_EXTDEBUG
- printk(KERN_DEBUG "pcl812 EDBG: BGN: pcl812_ai_cmd(...)\n");
-#endif
-
if (cmd->start_src != TRIG_NOW)
return -EINVAL;
if (cmd->scan_begin_src != TRIG_FOLLOW)
@@ -852,9 +678,9 @@ static int pcl812_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
return -EINVAL;
if (cmd->convert_src == TRIG_TIMER) {
- if (cmd->convert_arg < this_board->ai_ns_min)
- cmd->convert_arg = this_board->ai_ns_min;
- i8253_cascade_ns_to_timer(this_board->i8254_osc_base,
+ if (cmd->convert_arg < board->ai_ns_min)
+ cmd->convert_arg = board->ai_ns_min;
+ i8253_cascade_ns_to_timer(board->i8254_osc_base,
&divisor1, &divisor2,
&cmd->convert_arg,
cmd->flags & TRIG_ROUND_MASK);
@@ -956,13 +782,6 @@ static int pcl812_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
set_dma_count(devpriv->dma, devpriv->dmabytestomove[0]);
release_dma_lock(dma_flags);
enable_dma(devpriv->dma);
-#ifdef PCL812_EXTDEBUG
- printk
- ("pcl812 EDBG: DMA %d PTR 0x%0x/0x%0x LEN %u/%u EOS %d\n",
- devpriv->dma, devpriv->hwdmaptr[0],
- devpriv->hwdmaptr[1], devpriv->dmabytestomove[0],
- devpriv->dmabytestomove[1], devpriv->ai_eos);
-#endif
}
switch (cmd->convert_src) {
@@ -976,10 +795,6 @@ static int pcl812_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
else /* let's go! */
outb(devpriv->mode_reg_int | 6, dev->iobase + PCL812_MODE);
-#ifdef PCL812_EXTDEBUG
- printk(KERN_DEBUG "pcl812 EDBG: END: pcl812_ai_cmd(...)\n");
-#endif
-
return 0;
}
@@ -1099,9 +914,6 @@ static irqreturn_t interrupt_pcl812_ai_dma(int irq, void *d)
int len, bufptr;
short *ptr;
-#ifdef PCL812_EXTDEBUG
- printk(KERN_DEBUG "pcl812 EDBG: BGN: interrupt_pcl812_ai_dma(...)\n");
-#endif
ptr = (short *)devpriv->dmabuf[devpriv->next_dma_buf];
len = (devpriv->dmabytestomove[devpriv->next_dma_buf] >> 1) -
devpriv->ai_poll_ptr;
@@ -1134,9 +946,6 @@ static irqreturn_t interrupt_pcl812_ai_dma(int irq, void *d)
transfer_from_dma_buf(dev, s, ptr, bufptr, len);
-#ifdef PCL812_EXTDEBUG
- printk(KERN_DEBUG "pcl812 EDBG: END: interrupt_pcl812_ai_dma(...)\n");
-#endif
return IRQ_HANDLED;
}
@@ -1253,10 +1062,6 @@ static void setup_range_channel(struct comedi_device *dev,
static void start_pacer(struct comedi_device *dev, int mode,
unsigned int divisor1, unsigned int divisor2)
{
-#ifdef PCL812_EXTDEBUG
- printk(KERN_DEBUG "pcl812 EDBG: BGN: start_pacer(%d,%u,%u)\n", mode,
- divisor1, divisor2);
-#endif
outb(0xb4, dev->iobase + PCL812_CTRCTL);
outb(0x74, dev->iobase + PCL812_CTRCTL);
udelay(1);
@@ -1267,9 +1072,6 @@ static void start_pacer(struct comedi_device *dev, int mode,
outb(divisor1 & 0xff, dev->iobase + PCL812_CTR1);
outb((divisor1 >> 8) & 0xff, dev->iobase + PCL812_CTR1);
}
-#ifdef PCL812_EXTDEBUG
- printk(KERN_DEBUG "pcl812 EDBG: END: start_pacer(...)\n");
-#endif
}
/*
@@ -1277,6 +1079,7 @@ static void start_pacer(struct comedi_device *dev, int mode,
*/
static void free_resources(struct comedi_device *dev)
{
+ const struct pcl812_board *board = comedi_board(dev);
if (dev->private) {
if (devpriv->dmabuf[0])
@@ -1289,7 +1092,7 @@ static void free_resources(struct comedi_device *dev)
if (dev->irq)
free_irq(dev->irq, dev);
if (dev->iobase)
- release_region(dev->iobase, this_board->io_range);
+ release_region(dev->iobase, board->io_range);
}
/*
@@ -1298,9 +1101,6 @@ static void free_resources(struct comedi_device *dev)
static int pcl812_ai_cancel(struct comedi_device *dev,
struct comedi_subdevice *s)
{
-#ifdef PCL812_EXTDEBUG
- printk(KERN_DEBUG "pcl812 EDBG: BGN: pcl812_ai_cancel(...)\n");
-#endif
if (devpriv->ai_dma)
disable_dma(devpriv->dma);
outb(0, dev->iobase + PCL812_CLRINT); /* clear INT request */
@@ -1308,9 +1108,6 @@ static int pcl812_ai_cancel(struct comedi_device *dev,
outb(devpriv->mode_reg_int | 0, dev->iobase + PCL812_MODE);
start_pacer(dev, -1, 0, 0); /* stop 8254 */
outb(0, dev->iobase + PCL812_CLRINT); /* clear INT request */
-#ifdef PCL812_EXTDEBUG
- printk(KERN_DEBUG "pcl812 EDBG: END: pcl812_ai_cancel(...)\n");
-#endif
return 0;
}
@@ -1319,15 +1116,14 @@ static int pcl812_ai_cancel(struct comedi_device *dev,
*/
static void pcl812_reset(struct comedi_device *dev)
{
-#ifdef PCL812_EXTDEBUG
- printk(KERN_DEBUG "pcl812 EDBG: BGN: pcl812_reset(...)\n");
-#endif
+ const struct pcl812_board *board = comedi_board(dev);
+
outb(0, dev->iobase + PCL812_MUX);
outb(0 + devpriv->range_correction, dev->iobase + PCL812_GAIN);
devpriv->old_chan_reg = -1; /* invalidate chain/gain memory */
devpriv->old_gain_reg = -1;
- switch (this_board->board_type) {
+ switch (board->board_type) {
case boardPCL812PG:
case boardPCL812:
case boardACL8112:
@@ -1351,16 +1147,11 @@ static void pcl812_reset(struct comedi_device *dev)
break;
}
udelay(5);
-#ifdef PCL812_EXTDEBUG
- printk(KERN_DEBUG "pcl812 EDBG: END: pcl812_reset(...)\n");
-#endif
}
-/*
-==============================================================================
-*/
static int pcl812_attach(struct comedi_device *dev, struct comedi_devconfig *it)
{
+ const struct pcl812_board *board = comedi_board(dev);
int ret, subdev;
unsigned long iobase;
unsigned int irq;
@@ -1371,9 +1162,9 @@ static int pcl812_attach(struct comedi_device *dev, struct comedi_devconfig *it)
iobase = it->options[0];
printk(KERN_INFO "comedi%d: pcl812: board=%s, ioport=0x%03lx",
- dev->minor, this_board->name, iobase);
+ dev->minor, board->name, iobase);
- if (!request_region(iobase, this_board->io_range, "pcl812")) {
+ if (!request_region(iobase, board->io_range, "pcl812")) {
printk("I/O port conflict\n");
return -EIO;
}
@@ -1385,13 +1176,13 @@ static int pcl812_attach(struct comedi_device *dev, struct comedi_devconfig *it)
return ret; /* Can't alloc mem */
}
- dev->board_name = this_board->name;
+ dev->board_name = board->name;
irq = 0;
- if (this_board->IRQbits != 0) { /* board support IRQ */
+ if (board->IRQbits != 0) { /* board support IRQ */
irq = it->options[1];
if (irq) { /* we want to use IRQ */
- if (((1 << irq) & this_board->IRQbits) == 0) {
+ if (((1 << irq) & board->IRQbits) == 0) {
printk
(", IRQ %u is out of allowed range, "
"DISABLING IT", irq);
@@ -1416,9 +1207,9 @@ static int pcl812_attach(struct comedi_device *dev, struct comedi_devconfig *it)
devpriv->dma = dma;
if (!dev->irq)
goto no_dma; /* if we haven't IRQ, we can't use DMA */
- if (this_board->DMAbits != 0) { /* board support DMA */
+ if (board->DMAbits != 0) { /* board support DMA */
dma = it->options[2];
- if (((1 << dma) & this_board->DMAbits) == 0) {
+ if (((1 << dma) & board->DMAbits) == 0) {
printk(", DMA is out of allowed range, FAIL!\n");
return -EINVAL; /* Bad DMA */
}
@@ -1457,17 +1248,17 @@ static int pcl812_attach(struct comedi_device *dev, struct comedi_devconfig *it)
no_dma:
n_subdevices = 0;
- if (this_board->n_aichan > 0)
+ if (board->n_aichan > 0)
n_subdevices++;
- if (this_board->n_aochan > 0)
+ if (board->n_aochan > 0)
n_subdevices++;
- if (this_board->n_dichan > 0)
+ if (board->n_dichan > 0)
n_subdevices++;
- if (this_board->n_dochan > 0)
+ if (board->n_dochan > 0)
n_subdevices++;
- ret = alloc_subdevices(dev, n_subdevices);
- if (ret < 0) {
+ ret = comedi_alloc_subdevices(dev, n_subdevices);
+ if (ret) {
free_resources(dev);
return ret;
}
@@ -1475,46 +1266,46 @@ no_dma:
subdev = 0;
/* analog input */
- if (this_board->n_aichan > 0) {
+ if (board->n_aichan > 0) {
s = dev->subdevices + subdev;
s->type = COMEDI_SUBD_AI;
s->subdev_flags = SDF_READABLE;
- switch (this_board->board_type) {
+ switch (board->board_type) {
case boardA821:
if (it->options[2] == 1) {
- s->n_chan = this_board->n_aichan_diff;
+ s->n_chan = board->n_aichan_diff;
s->subdev_flags |= SDF_DIFF;
devpriv->use_diff = 1;
} else {
- s->n_chan = this_board->n_aichan;
+ s->n_chan = board->n_aichan;
s->subdev_flags |= SDF_GROUND;
}
break;
case boardACL8112:
case boardACL8216:
if (it->options[4] == 1) {
- s->n_chan = this_board->n_aichan_diff;
+ s->n_chan = board->n_aichan_diff;
s->subdev_flags |= SDF_DIFF;
devpriv->use_diff = 1;
} else {
- s->n_chan = this_board->n_aichan;
+ s->n_chan = board->n_aichan;
s->subdev_flags |= SDF_GROUND;
}
break;
default:
- s->n_chan = this_board->n_aichan;
+ s->n_chan = board->n_aichan;
s->subdev_flags |= SDF_GROUND;
break;
}
- s->maxdata = this_board->ai_maxdata;
+ s->maxdata = board->ai_maxdata;
s->len_chanlist = MAX_CHANLIST_LEN;
- s->range_table = this_board->rangelist_ai;
- if (this_board->board_type == boardACL8216)
+ s->range_table = board->rangelist_ai;
+ if (board->board_type == boardACL8216)
s->insn_read = acl8216_ai_insn_read;
else
s->insn_read = pcl812_ai_insn_read;
- devpriv->use_MPC = this_board->haveMPC508;
+ devpriv->use_MPC = board->haveMPC508;
s->cancel = pcl812_ai_cancel;
if (dev->irq) {
dev->read_subdev = s;
@@ -1523,7 +1314,7 @@ no_dma:
s->do_cmd = pcl812_ai_cmd;
s->poll = pcl812_ai_poll;
}
- switch (this_board->board_type) {
+ switch (board->board_type) {
case boardPCL812PG:
if (it->options[4] == 1)
s->range_table = &range_pcl812pg2_ai;
@@ -1617,17 +1408,17 @@ no_dma:
}
/* analog output */
- if (this_board->n_aochan > 0) {
+ if (board->n_aochan > 0) {
s = dev->subdevices + subdev;
s->type = COMEDI_SUBD_AO;
s->subdev_flags = SDF_WRITABLE | SDF_GROUND;
- s->n_chan = this_board->n_aochan;
+ s->n_chan = board->n_aochan;
s->maxdata = 0xfff;
s->len_chanlist = 1;
- s->range_table = this_board->rangelist_ao;
+ s->range_table = board->rangelist_ao;
s->insn_read = pcl812_ao_insn_read;
s->insn_write = pcl812_ao_insn_write;
- switch (this_board->board_type) {
+ switch (board->board_type) {
case boardA821:
if (it->options[3] == 1)
s->range_table = &range_unipolar10;
@@ -1646,32 +1437,32 @@ no_dma:
}
/* digital input */
- if (this_board->n_dichan > 0) {
+ if (board->n_dichan > 0) {
s = dev->subdevices + subdev;
s->type = COMEDI_SUBD_DI;
s->subdev_flags = SDF_READABLE;
- s->n_chan = this_board->n_dichan;
+ s->n_chan = board->n_dichan;
s->maxdata = 1;
- s->len_chanlist = this_board->n_dichan;
+ s->len_chanlist = board->n_dichan;
s->range_table = &range_digital;
s->insn_bits = pcl812_di_insn_bits;
subdev++;
}
/* digital output */
- if (this_board->n_dochan > 0) {
+ if (board->n_dochan > 0) {
s = dev->subdevices + subdev;
s->type = COMEDI_SUBD_DO;
s->subdev_flags = SDF_WRITABLE;
- s->n_chan = this_board->n_dochan;
+ s->n_chan = board->n_dochan;
s->maxdata = 1;
- s->len_chanlist = this_board->n_dochan;
+ s->len_chanlist = board->n_dochan;
s->range_table = &range_digital;
s->insn_bits = pcl812_do_insn_bits;
subdev++;
}
- switch (this_board->board_type) {
+ switch (board->board_type) {
case boardACL8216:
devpriv->ai_is16b = 1;
case boardPCL812PG:
@@ -1702,19 +1493,79 @@ no_dma:
return 0;
}
-/*
-==============================================================================
- */
-static int pcl812_detach(struct comedi_device *dev)
+static void pcl812_detach(struct comedi_device *dev)
{
-
-#ifdef PCL812_EXTDEBUG
- printk(KERN_DEBUG "comedi%d: pcl812: remove\n", dev->minor);
-#endif
free_resources(dev);
- return 0;
}
+static const struct pcl812_board boardtypes[] = {
+ {"pcl812", boardPCL812, 16, 0, 2, 16, 16, 0x0fff,
+ 33000, 500, &range_bipolar10, &range_unipolar5,
+ 0xdcfc, 0x0a, PCLx1x_IORANGE, 0},
+ {"pcl812pg", boardPCL812PG, 16, 0, 2, 16, 16, 0x0fff,
+ 33000, 500, &range_pcl812pg_ai, &range_unipolar5,
+ 0xdcfc, 0x0a, PCLx1x_IORANGE, 0},
+ {"acl8112pg", boardPCL812PG, 16, 0, 2, 16, 16, 0x0fff,
+ 10000, 500, &range_pcl812pg_ai, &range_unipolar5,
+ 0xdcfc, 0x0a, PCLx1x_IORANGE, 0},
+ {"acl8112dg", boardACL8112, 16, 8, 2, 16, 16, 0x0fff,
+ 10000, 500, &range_acl8112dg_ai, &range_unipolar5,
+ 0xdcfc, 0x0a, PCLx1x_IORANGE, 1},
+ {"acl8112hg", boardACL8112, 16, 8, 2, 16, 16, 0x0fff,
+ 10000, 500, &range_acl8112hg_ai, &range_unipolar5,
+ 0xdcfc, 0x0a, PCLx1x_IORANGE, 1},
+ {"a821pgl", boardA821, 16, 8, 1, 16, 16, 0x0fff,
+ 10000, 500, &range_pcl813b_ai, &range_unipolar5,
+ 0x000c, 0x00, PCLx1x_IORANGE, 0},
+ {"a821pglnda", boardA821, 16, 8, 0, 0, 0, 0x0fff,
+ 10000, 500, &range_pcl813b_ai, NULL,
+ 0x000c, 0x00, PCLx1x_IORANGE, 0},
+ {"a821pgh", boardA821, 16, 8, 1, 16, 16, 0x0fff,
+ 10000, 500, &range_a821pgh_ai, &range_unipolar5,
+ 0x000c, 0x00, PCLx1x_IORANGE, 0},
+ {"a822pgl", boardACL8112, 16, 8, 2, 16, 16, 0x0fff,
+ 10000, 500, &range_acl8112dg_ai, &range_unipolar5,
+ 0xdcfc, 0x0a, PCLx1x_IORANGE, 0},
+ {"a822pgh", boardACL8112, 16, 8, 2, 16, 16, 0x0fff,
+ 10000, 500, &range_acl8112hg_ai, &range_unipolar5,
+ 0xdcfc, 0x0a, PCLx1x_IORANGE, 0},
+ {"a823pgl", boardACL8112, 16, 8, 2, 16, 16, 0x0fff,
+ 8000, 500, &range_acl8112dg_ai, &range_unipolar5,
+ 0xdcfc, 0x0a, PCLx1x_IORANGE, 0},
+ {"a823pgh", boardACL8112, 16, 8, 2, 16, 16, 0x0fff,
+ 8000, 500, &range_acl8112hg_ai, &range_unipolar5,
+ 0xdcfc, 0x0a, PCLx1x_IORANGE, 0},
+ {"pcl813", boardPCL813, 32, 0, 0, 0, 0, 0x0fff,
+ 0, 0, &range_pcl813b_ai, NULL,
+ 0x0000, 0x00, PCLx1x_IORANGE, 0},
+ {"pcl813b", boardPCL813B, 32, 0, 0, 0, 0, 0x0fff,
+ 0, 0, &range_pcl813b_ai, NULL,
+ 0x0000, 0x00, PCLx1x_IORANGE, 0},
+ {"acl8113", boardACL8113, 32, 0, 0, 0, 0, 0x0fff,
+ 0, 0, &range_acl8113_1_ai, NULL,
+ 0x0000, 0x00, PCLx1x_IORANGE, 0},
+ {"iso813", boardISO813, 32, 0, 0, 0, 0, 0x0fff,
+ 0, 0, &range_iso813_1_ai, NULL,
+ 0x0000, 0x00, PCLx1x_IORANGE, 0},
+ {"acl8216", boardACL8216, 16, 8, 2, 16, 16, 0xffff,
+ 10000, 500, &range_pcl813b2_ai, &range_unipolar5,
+ 0xdcfc, 0x0a, PCLx1x_IORANGE, 1},
+ {"a826pg", boardACL8216, 16, 8, 2, 16, 16, 0xffff,
+ 10000, 500, &range_pcl813b2_ai, &range_unipolar5,
+ 0xdcfc, 0x0a, PCLx1x_IORANGE, 0},
+};
+
+static struct comedi_driver pcl812_driver = {
+ .driver_name = "pcl812",
+ .module = THIS_MODULE,
+ .attach = pcl812_attach,
+ .detach = pcl812_detach,
+ .board_name = &boardtypes[0].name,
+ .num_names = ARRAY_SIZE(boardtypes),
+ .offset = sizeof(struct pcl812_board),
+};
+module_comedi_driver(pcl812_driver);
+
MODULE_AUTHOR("Comedi http://www.comedi.org");
MODULE_DESCRIPTION("Comedi low-level driver");
MODULE_LICENSE("GPL");
diff --git a/drivers/staging/comedi/drivers/pcl816.c b/drivers/staging/comedi/drivers/pcl816.c
index 96cd7ec2ad53..ba6911f063cb 100644
--- a/drivers/staging/comedi/drivers/pcl816.c
+++ b/drivers/staging/comedi/drivers/pcl816.c
@@ -125,63 +125,13 @@ struct pcl816_board {
int i8254_osc_base; /* 1/frequency of on board oscilator in ns */
};
-static const struct pcl816_board boardtypes[] = {
- {"pcl816", 8, 16, 10000, 1, 16, 16, &range_pcl816,
- &range_pcl816, PCLx1x_RANGE,
- 0x00fc, /* IRQ mask */
- 0x0a, /* DMA mask */
- 0xffff, /* 16-bit card */
- 0xffff, /* D/A maxdata */
- 1024,
- 1, /* ao chan list */
- 100},
- {"pcl814b", 8, 16, 10000, 1, 16, 16, &range_pcl816,
- &range_pcl816, PCLx1x_RANGE,
- 0x00fc,
- 0x0a,
- 0x3fff, /* 14 bit card */
- 0x3fff,
- 1024,
- 1,
- 100},
-};
-
-#define n_boardtypes (sizeof(boardtypes)/sizeof(struct pcl816_board))
#define devpriv ((struct pcl816_private *)dev->private)
-#define this_board ((const struct pcl816_board *)dev->board_ptr)
-
-static int pcl816_attach(struct comedi_device *dev,
- struct comedi_devconfig *it);
-static int pcl816_detach(struct comedi_device *dev);
#ifdef unused
static int RTC_lock; /* RTC lock */
static int RTC_timer_lock; /* RTC int lock */
#endif
-static struct comedi_driver driver_pcl816 = {
- .driver_name = "pcl816",
- .module = THIS_MODULE,
- .attach = pcl816_attach,
- .detach = pcl816_detach,
- .board_name = &boardtypes[0].name,
- .num_names = n_boardtypes,
- .offset = sizeof(struct pcl816_board),
-};
-
-static int __init driver_pcl816_init_module(void)
-{
- return comedi_driver_register(&driver_pcl816);
-}
-
-static void __exit driver_pcl816_cleanup_module(void)
-{
- comedi_driver_unregister(&driver_pcl816);
-}
-
-module_init(driver_pcl816_init_module);
-module_exit(driver_pcl816_cleanup_module);
-
struct pcl816_private {
unsigned int dma; /* used DMA, 0=don't use DMA */
@@ -464,8 +414,8 @@ static irqreturn_t interrupt_pcl816(int irq, void *d)
}
outb(0, dev->iobase + PCL816_CLRINT); /* clear INT request */
- if ((!dev->irq) | (!devpriv->irq_free) | (!devpriv->irq_blocked) |
- (!devpriv->int816_mode)) {
+ if (!dev->irq || !devpriv->irq_free || !devpriv->irq_blocked ||
+ !devpriv->int816_mode) {
if (devpriv->irq_was_now_closed) {
devpriv->irq_was_now_closed = 0;
/* comedi_error(dev,"last IRQ.."); */
@@ -500,6 +450,7 @@ static void pcl816_cmdtest_out(int e, struct comedi_cmd *cmd)
static int pcl816_ai_cmdtest(struct comedi_device *dev,
struct comedi_subdevice *s, struct comedi_cmd *cmd)
{
+ const struct pcl816_board *board = comedi_board(dev);
int err = 0;
int tmp, divisor1 = 0, divisor2 = 0;
@@ -542,26 +493,11 @@ static int pcl816_ai_cmdtest(struct comedi_device *dev,
* are unique and mutually compatible
*/
- if (cmd->start_src != TRIG_NOW) {
- cmd->start_src = TRIG_NOW;
- err++;
- }
-
- if (cmd->scan_begin_src != TRIG_FOLLOW) {
- cmd->scan_begin_src = TRIG_FOLLOW;
- err++;
- }
-
if (cmd->convert_src != TRIG_EXT && cmd->convert_src != TRIG_TIMER) {
cmd->convert_src = TRIG_TIMER;
err++;
}
- if (cmd->scan_end_src != TRIG_COUNT) {
- cmd->scan_end_src = TRIG_COUNT;
- err++;
- }
-
if (cmd->stop_src != TRIG_NONE && cmd->stop_src != TRIG_COUNT)
err++;
@@ -580,8 +516,8 @@ static int pcl816_ai_cmdtest(struct comedi_device *dev,
err++;
}
if (cmd->convert_src == TRIG_TIMER) {
- if (cmd->convert_arg < this_board->ai_ns_min) {
- cmd->convert_arg = this_board->ai_ns_min;
+ if (cmd->convert_arg < board->ai_ns_min) {
+ cmd->convert_arg = board->ai_ns_min;
err++;
}
} else { /* TRIG_EXT */
@@ -614,12 +550,12 @@ static int pcl816_ai_cmdtest(struct comedi_device *dev,
/* step 4: fix up any arguments */
if (cmd->convert_src == TRIG_TIMER) {
tmp = cmd->convert_arg;
- i8253_cascade_ns_to_timer(this_board->i8254_osc_base,
+ i8253_cascade_ns_to_timer(board->i8254_osc_base,
&divisor1, &divisor2,
&cmd->convert_arg,
cmd->flags & TRIG_ROUND_MASK);
- if (cmd->convert_arg < this_board->ai_ns_min)
- cmd->convert_arg = this_board->ai_ns_min;
+ if (cmd->convert_arg < board->ai_ns_min)
+ cmd->convert_arg = board->ai_ns_min;
if (tmp != cmd->convert_arg)
err++;
}
@@ -641,6 +577,7 @@ static int pcl816_ai_cmdtest(struct comedi_device *dev,
static int pcl816_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
{
+ const struct pcl816_board *board = comedi_board(dev);
unsigned int divisor1 = 0, divisor2 = 0, dma_flags, bytes, dmairq;
struct comedi_cmd *cmd = &s->async->cmd;
unsigned int seglen;
@@ -658,10 +595,10 @@ static int pcl816_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
return -EBUSY;
if (cmd->convert_src == TRIG_TIMER) {
- if (cmd->convert_arg < this_board->ai_ns_min)
- cmd->convert_arg = this_board->ai_ns_min;
+ if (cmd->convert_arg < board->ai_ns_min)
+ cmd->convert_arg = board->ai_ns_min;
- i8253_cascade_ns_to_timer(this_board->i8254_osc_base, &divisor1,
+ i8253_cascade_ns_to_timer(board->i8254_osc_base, &divisor1,
&divisor2, &cmd->convert_arg,
cmd->flags & TRIG_ROUND_MASK);
@@ -1075,48 +1012,9 @@ static int set_rtc_irq_bit(unsigned char bit)
}
#endif
-/*
-==============================================================================
- Free any resources that we have claimed
-*/
-static void free_resources(struct comedi_device *dev)
-{
- /* printk("free_resource()\n"); */
- if (dev->private) {
- pcl816_ai_cancel(dev, devpriv->sub_ai);
- pcl816_reset(dev);
- if (devpriv->dma)
- free_dma(devpriv->dma);
- if (devpriv->dmabuf[0])
- free_pages(devpriv->dmabuf[0], devpriv->dmapages[0]);
- if (devpriv->dmabuf[1])
- free_pages(devpriv->dmabuf[1], devpriv->dmapages[1]);
-#ifdef unused
- if (devpriv->rtc_irq)
- free_irq(devpriv->rtc_irq, dev);
- if ((devpriv->dma_rtc) && (RTC_lock == 1)) {
- if (devpriv->rtc_iobase)
- release_region(devpriv->rtc_iobase,
- devpriv->rtc_iosize);
- }
-#endif
- }
-
- if (dev->irq)
- free_irq(dev->irq, dev);
- if (dev->iobase)
- release_region(dev->iobase, this_board->io_range);
- /* printk("free_resource() end\n"); */
-}
-
-/*
-==============================================================================
-
- Initialization
-
-*/
static int pcl816_attach(struct comedi_device *dev, struct comedi_devconfig *it)
{
+ const struct pcl816_board *board = comedi_board(dev);
int ret;
unsigned long iobase;
unsigned int irq, dma;
@@ -1127,9 +1025,9 @@ static int pcl816_attach(struct comedi_device *dev, struct comedi_devconfig *it)
/* claim our I/O space */
iobase = it->options[0];
printk("comedi%d: pcl816: board=%s, ioport=0x%03lx", dev->minor,
- this_board->name, iobase);
+ board->name, iobase);
- if (!request_region(iobase, this_board->io_range, "pcl816")) {
+ if (!request_region(iobase, board->io_range, "pcl816")) {
printk("I/O port conflict\n");
return -EIO;
}
@@ -1145,15 +1043,14 @@ static int pcl816_attach(struct comedi_device *dev, struct comedi_devconfig *it)
if (ret < 0)
return ret; /* Can't alloc mem */
- /* set up some name stuff */
- dev->board_name = this_board->name;
+ dev->board_name = board->name;
/* grab our IRQ */
irq = 0;
- if (this_board->IRQbits != 0) { /* board support IRQ */
+ if (board->IRQbits != 0) { /* board support IRQ */
irq = it->options[1];
if (irq) { /* we want to use IRQ */
- if (((1 << irq) & this_board->IRQbits) == 0) {
+ if (((1 << irq) & board->IRQbits) == 0) {
printk
(", IRQ %u is out of allowed range, "
"DISABLING IT", irq);
@@ -1223,12 +1120,12 @@ no_rtc:
if ((devpriv->irq_free == 0) && (devpriv->dma_rtc == 0))
goto no_dma; /* if we haven't IRQ, we can't use DMA */
- if (this_board->DMAbits != 0) { /* board support DMA */
+ if (board->DMAbits != 0) { /* board support DMA */
dma = it->options[2];
if (dma < 1)
goto no_dma; /* DMA disabled */
- if (((1 << dma) & this_board->DMAbits) == 0) {
+ if (((1 << dma) & board->DMAbits) == 0) {
printk(", DMA is out of allowed range, FAIL!\n");
return -EINVAL; /* Bad DMA */
}
@@ -1274,30 +1171,30 @@ no_rtc:
no_dma:
-/* if (this_board->n_aochan > 0)
+/* if (board->n_aochan > 0)
subdevs[1] = COMEDI_SUBD_AO;
- if (this_board->n_dichan > 0)
+ if (board->n_dichan > 0)
subdevs[2] = COMEDI_SUBD_DI;
- if (this_board->n_dochan > 0)
+ if (board->n_dochan > 0)
subdevs[3] = COMEDI_SUBD_DO;
*/
- ret = alloc_subdevices(dev, 1);
- if (ret < 0)
+ ret = comedi_alloc_subdevices(dev, 1);
+ if (ret)
return ret;
s = dev->subdevices + 0;
- if (this_board->n_aichan > 0) {
+ if (board->n_aichan > 0) {
s->type = COMEDI_SUBD_AI;
devpriv->sub_ai = s;
dev->read_subdev = s;
s->subdev_flags = SDF_READABLE | SDF_CMD_READ;
- s->n_chan = this_board->n_aichan;
+ s->n_chan = board->n_aichan;
s->subdev_flags |= SDF_DIFF;
/* printk (", %dchans DIFF DAC - %d", s->n_chan, i); */
- s->maxdata = this_board->ai_maxdata;
- s->len_chanlist = this_board->ai_chanlist;
- s->range_table = this_board->ai_range_type;
+ s->maxdata = board->ai_maxdata;
+ s->len_chanlist = board->ai_chanlist;
+ s->range_table = board->ai_range_type;
s->cancel = pcl816_ai_cancel;
s->do_cmdtest = pcl816_ai_cmdtest;
s->do_cmd = pcl816_ai_cmd;
@@ -1310,25 +1207,25 @@ no_dma:
#if 0
case COMEDI_SUBD_AO:
s->subdev_flags = SDF_WRITABLE | SDF_GROUND;
- s->n_chan = this_board->n_aochan;
- s->maxdata = this_board->ao_maxdata;
- s->len_chanlist = this_board->ao_chanlist;
- s->range_table = this_board->ao_range_type;
+ s->n_chan = board->n_aochan;
+ s->maxdata = board->ao_maxdata;
+ s->len_chanlist = board->ao_chanlist;
+ s->range_table = board->ao_range_type;
break;
case COMEDI_SUBD_DI:
s->subdev_flags = SDF_READABLE;
- s->n_chan = this_board->n_dichan;
+ s->n_chan = board->n_dichan;
s->maxdata = 1;
- s->len_chanlist = this_board->n_dichan;
+ s->len_chanlist = board->n_dichan;
s->range_table = &range_digital;
break;
case COMEDI_SUBD_DO:
s->subdev_flags = SDF_WRITABLE;
- s->n_chan = this_board->n_dochan;
+ s->n_chan = board->n_dochan;
s->maxdata = 1;
- s->len_chanlist = this_board->n_dochan;
+ s->len_chanlist = board->n_dochan;
s->range_table = &range_digital;
break;
#endif
@@ -1340,21 +1237,71 @@ case COMEDI_SUBD_DO:
return 0;
}
-/*
-==============================================================================
- Removes device
- */
-static int pcl816_detach(struct comedi_device *dev)
+static void pcl816_detach(struct comedi_device *dev)
{
- DEBUG(printk(KERN_INFO "comedi%d: pcl816: remove\n", dev->minor);)
- free_resources(dev);
+ const struct pcl816_board *board = comedi_board(dev);
+
+ if (dev->private) {
+ pcl816_ai_cancel(dev, devpriv->sub_ai);
+ pcl816_reset(dev);
+ if (devpriv->dma)
+ free_dma(devpriv->dma);
+ if (devpriv->dmabuf[0])
+ free_pages(devpriv->dmabuf[0], devpriv->dmapages[0]);
+ if (devpriv->dmabuf[1])
+ free_pages(devpriv->dmabuf[1], devpriv->dmapages[1]);
+#ifdef unused
+ if (devpriv->rtc_irq)
+ free_irq(devpriv->rtc_irq, dev);
+ if ((devpriv->dma_rtc) && (RTC_lock == 1)) {
+ if (devpriv->rtc_iobase)
+ release_region(devpriv->rtc_iobase,
+ devpriv->rtc_iosize);
+ }
+#endif
+ }
+ if (dev->irq)
+ free_irq(dev->irq, dev);
+ if (dev->iobase)
+ release_region(dev->iobase, board->io_range);
#ifdef unused
if (devpriv->dma_rtc)
RTC_lock--;
#endif
- return 0;
}
+static const struct pcl816_board boardtypes[] = {
+ {"pcl816", 8, 16, 10000, 1, 16, 16, &range_pcl816,
+ &range_pcl816, PCLx1x_RANGE,
+ 0x00fc, /* IRQ mask */
+ 0x0a, /* DMA mask */
+ 0xffff, /* 16-bit card */
+ 0xffff, /* D/A maxdata */
+ 1024,
+ 1, /* ao chan list */
+ 100},
+ {"pcl814b", 8, 16, 10000, 1, 16, 16, &range_pcl816,
+ &range_pcl816, PCLx1x_RANGE,
+ 0x00fc,
+ 0x0a,
+ 0x3fff, /* 14 bit card */
+ 0x3fff,
+ 1024,
+ 1,
+ 100},
+};
+
+static struct comedi_driver pcl816_driver = {
+ .driver_name = "pcl816",
+ .module = THIS_MODULE,
+ .attach = pcl816_attach,
+ .detach = pcl816_detach,
+ .board_name = &boardtypes[0].name,
+ .num_names = ARRAY_SIZE(boardtypes),
+ .offset = sizeof(struct pcl816_board),
+};
+module_comedi_driver(pcl816_driver);
+
MODULE_AUTHOR("Comedi http://www.comedi.org");
MODULE_DESCRIPTION("Comedi low-level driver");
MODULE_LICENSE("GPL");
diff --git a/drivers/staging/comedi/drivers/pcl818.c b/drivers/staging/comedi/drivers/pcl818.c
index 7344a53a81c4..34169c16fb92 100644
--- a/drivers/staging/comedi/drivers/pcl818.c
+++ b/drivers/staging/comedi/drivers/pcl818.c
@@ -247,10 +247,6 @@ static const struct comedi_lrange range718_bipolar0_5 =
static const struct comedi_lrange range718_unipolar2 = { 1, {UNI_RANGE(2),} };
static const struct comedi_lrange range718_unipolar1 = { 1, {BIP_RANGE(1),} };
-static int pcl818_attach(struct comedi_device *dev,
- struct comedi_devconfig *it);
-static int pcl818_detach(struct comedi_device *dev);
-
#ifdef unused
static int RTC_lock; /* RTC lock */
static int RTC_timer_lock; /* RTC int lock */
@@ -277,56 +273,6 @@ struct pcl818_board {
int is_818;
};
-static const struct pcl818_board boardtypes[] = {
- {"pcl818l", 4, 16, 8, 25000, 1, 16, 16, &range_pcl818l_l_ai,
- &range_unipolar5, PCLx1x_RANGE, 0x00fc,
- 0x0a, 0xfff, 0xfff, 0, 1},
- {"pcl818h", 9, 16, 8, 10000, 1, 16, 16, &range_pcl818h_ai,
- &range_unipolar5, PCLx1x_RANGE, 0x00fc,
- 0x0a, 0xfff, 0xfff, 0, 1},
- {"pcl818hd", 9, 16, 8, 10000, 1, 16, 16, &range_pcl818h_ai,
- &range_unipolar5, PCLx1x_RANGE, 0x00fc,
- 0x0a, 0xfff, 0xfff, 1, 1},
- {"pcl818hg", 12, 16, 8, 10000, 1, 16, 16, &range_pcl818hg_ai,
- &range_unipolar5, PCLx1x_RANGE, 0x00fc,
- 0x0a, 0xfff, 0xfff, 1, 1},
- {"pcl818", 9, 16, 8, 10000, 2, 16, 16, &range_pcl818h_ai,
- &range_unipolar5, PCLx1x_RANGE, 0x00fc,
- 0x0a, 0xfff, 0xfff, 0, 1},
- {"pcl718", 1, 16, 8, 16000, 2, 16, 16, &range_unipolar5,
- &range_unipolar5, PCLx1x_RANGE, 0x00fc,
- 0x0a, 0xfff, 0xfff, 0, 0},
- /* pcm3718 */
- {"pcm3718", 9, 16, 8, 10000, 0, 16, 16, &range_pcl818h_ai,
- &range_unipolar5, PCLx1x_RANGE, 0x00fc,
- 0x0a, 0xfff, 0xfff, 0, 1 /* XXX ? */ },
-};
-
-#define n_boardtypes (sizeof(boardtypes)/sizeof(struct pcl818_board))
-
-static struct comedi_driver driver_pcl818 = {
- .driver_name = "pcl818",
- .module = THIS_MODULE,
- .attach = pcl818_attach,
- .detach = pcl818_detach,
- .board_name = &boardtypes[0].name,
- .num_names = n_boardtypes,
- .offset = sizeof(struct pcl818_board),
-};
-
-static int __init driver_pcl818_init_module(void)
-{
- return comedi_driver_register(&driver_pcl818);
-}
-
-static void __exit driver_pcl818_cleanup_module(void)
-{
- comedi_driver_unregister(&driver_pcl818);
-}
-
-module_init(driver_pcl818_init_module);
-module_exit(driver_pcl818_cleanup_module);
-
struct pcl818_private {
unsigned int dma; /* used DMA, 0=don't use DMA */
@@ -380,7 +326,6 @@ static const unsigned int muxonechan[] = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0
};
#define devpriv ((struct pcl818_private *)dev->private)
-#define this_board ((const struct pcl818_board *)dev->board_ptr)
/*
==============================================================================
@@ -497,13 +442,10 @@ static int pcl818_di_insn_bits(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
- if (insn->n != 2)
- return -EINVAL;
-
data[1] = inb(dev->iobase + PCL818_DI_LO) |
(inb(dev->iobase + PCL818_DI_HI) << 8);
- return 2;
+ return insn->n;
}
/*
@@ -516,9 +458,6 @@ static int pcl818_do_insn_bits(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
- if (insn->n != 2)
- return -EINVAL;
-
s->state &= ~data[0];
s->state |= (data[0] & data[1]);
@@ -527,7 +466,7 @@ static int pcl818_do_insn_bits(struct comedi_device *dev,
data[1] = s->state;
- return 2;
+ return insn->n;
}
/*
@@ -1007,7 +946,7 @@ static int pcl818_ai_cmd_mode(int mode, struct comedi_device *dev,
int divisor1 = 0, divisor2 = 0;
unsigned int seglen;
- dev_dbg(dev->hw_dev, "pcl818_ai_cmd_mode()\n");
+ dev_dbg(dev->class_dev, "pcl818_ai_cmd_mode()\n");
if ((!dev->irq) && (!devpriv->dma_rtc)) {
comedi_error(dev, "IRQ not defined!");
return -EINVAL;
@@ -1110,7 +1049,7 @@ static int pcl818_ai_cmd_mode(int mode, struct comedi_device *dev,
break;
}
#endif
- dev_dbg(dev->hw_dev, "pcl818_ai_cmd_mode() end\n");
+ dev_dbg(dev->class_dev, "pcl818_ai_cmd_mode() end\n");
return 0;
}
@@ -1318,6 +1257,7 @@ static int check_single_ended(unsigned int port)
static int ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
struct comedi_cmd *cmd)
{
+ const struct pcl818_board *board = comedi_board(dev);
int err = 0;
int tmp, divisor1 = 0, divisor2 = 0;
@@ -1353,22 +1293,9 @@ static int ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
/* step 2: make sure trigger sources are unique and mutually compatible */
- if (cmd->start_src != TRIG_NOW) {
- cmd->start_src = TRIG_NOW;
- err++;
- }
- if (cmd->scan_begin_src != TRIG_FOLLOW) {
- cmd->scan_begin_src = TRIG_FOLLOW;
- err++;
- }
if (cmd->convert_src != TRIG_TIMER && cmd->convert_src != TRIG_EXT)
err++;
- if (cmd->scan_end_src != TRIG_COUNT) {
- cmd->scan_end_src = TRIG_COUNT;
- err++;
- }
-
if (cmd->stop_src != TRIG_NONE && cmd->stop_src != TRIG_COUNT)
err++;
@@ -1388,8 +1315,8 @@ static int ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
}
if (cmd->convert_src == TRIG_TIMER) {
- if (cmd->convert_arg < this_board->ns_min) {
- cmd->convert_arg = this_board->ns_min;
+ if (cmd->convert_arg < board->ns_min) {
+ cmd->convert_arg = board->ns_min;
err++;
}
} else { /* TRIG_EXT */
@@ -1425,8 +1352,8 @@ static int ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
i8253_cascade_ns_to_timer(devpriv->i8253_osc_base, &divisor1,
&divisor2, &cmd->convert_arg,
cmd->flags & TRIG_ROUND_MASK);
- if (cmd->convert_arg < this_board->ns_min)
- cmd->convert_arg = this_board->ns_min;
+ if (cmd->convert_arg < board->ns_min)
+ cmd->convert_arg = board->ns_min;
if (tmp != cmd->convert_arg)
err++;
}
@@ -1453,7 +1380,7 @@ static int ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
struct comedi_cmd *cmd = &s->async->cmd;
int retval;
- dev_dbg(dev->hw_dev, "pcl818_ai_cmd()\n");
+ dev_dbg(dev->class_dev, "pcl818_ai_cmd()\n");
devpriv->ai_n_chan = cmd->chanlist_len;
devpriv->ai_chanlist = cmd->chanlist;
devpriv->ai_flags = cmd->flags;
@@ -1471,7 +1398,7 @@ static int ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
if (cmd->convert_src == TRIG_TIMER) { /* mode 1 */
devpriv->ai_timer1 = cmd->convert_arg;
retval = pcl818_ai_cmd_mode(1, dev, s);
- dev_dbg(dev->hw_dev, "pcl818_ai_cmd() end\n");
+ dev_dbg(dev->class_dev, "pcl818_ai_cmd() end\n");
return retval;
}
if (cmd->convert_src == TRIG_EXT) { /* mode 3 */
@@ -1490,7 +1417,7 @@ static int pcl818_ai_cancel(struct comedi_device *dev,
struct comedi_subdevice *s)
{
if (devpriv->irq_blocked > 0) {
- dev_dbg(dev->hw_dev, "pcl818_ai_cancel()\n");
+ dev_dbg(dev->class_dev, "pcl818_ai_cancel()\n");
devpriv->irq_was_now_closed = 1;
switch (devpriv->ai_mode) {
@@ -1540,7 +1467,7 @@ static int pcl818_ai_cancel(struct comedi_device *dev,
}
end:
- dev_dbg(dev->hw_dev, "pcl818_ai_cancel() end\n");
+ dev_dbg(dev->class_dev, "pcl818_ai_cancel() end\n");
return 0;
}
@@ -1573,6 +1500,8 @@ static int pcl818_check(unsigned long iobase)
*/
static void pcl818_reset(struct comedi_device *dev)
{
+ const struct pcl818_board *board = comedi_board(dev);
+
if (devpriv->usefifo) { /* FIFO shutdown */
outb(0, dev->iobase + PCL818_FI_INTCLR);
outb(0, dev->iobase + PCL818_FI_FLUSH);
@@ -1591,7 +1520,7 @@ static void pcl818_reset(struct comedi_device *dev)
outb(0xb0, dev->iobase + PCL818_CTRCTL); /* Stop pacer */
outb(0x70, dev->iobase + PCL818_CTRCTL);
outb(0x30, dev->iobase + PCL818_CTRCTL);
- if (this_board->is_818) {
+ if (board->is_818) {
outb(0, dev->iobase + PCL818_RANGE);
} else {
outb(0, dev->iobase + PCL718_DA2_LO);
@@ -1688,50 +1617,9 @@ static int rtc_setfreq_irq(int freq)
}
#endif
-/*
-==============================================================================
- Free any resources that we have claimed
-*/
-static void free_resources(struct comedi_device *dev)
-{
- /* printk("free_resource()\n"); */
- if (dev->private) {
- pcl818_ai_cancel(dev, devpriv->sub_ai);
- pcl818_reset(dev);
- if (devpriv->dma)
- free_dma(devpriv->dma);
- if (devpriv->dmabuf[0])
- free_pages(devpriv->dmabuf[0], devpriv->dmapages[0]);
- if (devpriv->dmabuf[1])
- free_pages(devpriv->dmabuf[1], devpriv->dmapages[1]);
-#ifdef unused
- if (devpriv->rtc_irq)
- free_irq(devpriv->rtc_irq, dev);
- if ((devpriv->dma_rtc) && (RTC_lock == 1)) {
- if (devpriv->rtc_iobase)
- release_region(devpriv->rtc_iobase,
- devpriv->rtc_iosize);
- }
- if (devpriv->dma_rtc)
- RTC_lock--;
-#endif
- }
-
- if (dev->irq)
- free_irq(dev->irq, dev);
- if (dev->iobase)
- release_region(dev->iobase, devpriv->io_range);
- /* printk("free_resource() end\n"); */
-}
-
-/*
-==============================================================================
-
- Initialization
-
-*/
static int pcl818_attach(struct comedi_device *dev, struct comedi_devconfig *it)
{
+ const struct pcl818_board *board = comedi_board(dev);
int ret;
unsigned long iobase;
unsigned int irq;
@@ -1747,9 +1635,10 @@ static int pcl818_attach(struct comedi_device *dev, struct comedi_devconfig *it)
iobase = it->options[0];
printk
("comedi%d: pcl818: board=%s, ioport=0x%03lx",
- dev->minor, this_board->name, iobase);
- devpriv->io_range = this_board->io_range;
- if ((this_board->fifo) && (it->options[2] == -1)) { /* we've board with FIFO and we want to use FIFO */
+ dev->minor, board->name, iobase);
+ devpriv->io_range = board->io_range;
+ if ((board->fifo) && (it->options[2] == -1)) {
+ /* we've board with FIFO and we want to use FIFO */
devpriv->io_range = PCLx1xFIFO_RANGE;
devpriv->usefifo = 1;
}
@@ -1765,14 +1654,14 @@ static int pcl818_attach(struct comedi_device *dev, struct comedi_devconfig *it)
return -EIO;
}
- /* set up some name stuff */
- dev->board_name = this_board->name;
+ dev->board_name = board->name;
+
/* grab our IRQ */
irq = 0;
- if (this_board->IRQbits != 0) { /* board support IRQ */
+ if (board->IRQbits != 0) { /* board support IRQ */
irq = it->options[1];
if (irq) { /* we want to use IRQ */
- if (((1 << irq) & this_board->IRQbits) == 0) {
+ if (((1 << irq) & board->IRQbits) == 0) {
printk
(", IRQ %u is out of allowed range, DISABLING IT",
irq);
@@ -1836,11 +1725,11 @@ no_rtc:
devpriv->dma = dma;
if ((devpriv->irq_free == 0) && (devpriv->dma_rtc == 0))
goto no_dma; /* if we haven't IRQ, we can't use DMA */
- if (this_board->DMAbits != 0) { /* board support DMA */
+ if (board->DMAbits != 0) { /* board support DMA */
dma = it->options[2];
if (dma < 1)
goto no_dma; /* DMA disabled */
- if (((1 << dma) & this_board->DMAbits) == 0) {
+ if (((1 << dma) & board->DMAbits) == 0) {
printk(KERN_ERR "DMA is out of allowed range, FAIL!\n");
return -EINVAL; /* Bad DMA */
}
@@ -1870,29 +1759,29 @@ no_rtc:
no_dma:
- ret = alloc_subdevices(dev, 4);
- if (ret < 0)
+ ret = comedi_alloc_subdevices(dev, 4);
+ if (ret)
return ret;
s = dev->subdevices + 0;
- if (!this_board->n_aichan_se) {
+ if (!board->n_aichan_se) {
s->type = COMEDI_SUBD_UNUSED;
} else {
s->type = COMEDI_SUBD_AI;
devpriv->sub_ai = s;
s->subdev_flags = SDF_READABLE;
if (check_single_ended(dev->iobase)) {
- s->n_chan = this_board->n_aichan_se;
+ s->n_chan = board->n_aichan_se;
s->subdev_flags |= SDF_COMMON | SDF_GROUND;
printk(", %dchans S.E. DAC", s->n_chan);
} else {
- s->n_chan = this_board->n_aichan_diff;
+ s->n_chan = board->n_aichan_diff;
s->subdev_flags |= SDF_DIFF;
printk(", %dchans DIFF DAC", s->n_chan);
}
- s->maxdata = this_board->ai_maxdata;
+ s->maxdata = board->ai_maxdata;
s->len_chanlist = s->n_chan;
- s->range_table = this_board->ai_range_type;
+ s->range_table = board->ai_range_type;
s->cancel = pcl818_ai_cancel;
s->insn_read = pcl818_ai_insn_read;
if ((irq) || (devpriv->dma_rtc)) {
@@ -1901,7 +1790,7 @@ no_dma:
s->do_cmdtest = ai_cmdtest;
s->do_cmd = ai_cmd;
}
- if (this_board->is_818) {
+ if (board->is_818) {
if ((it->options[4] == 1) || (it->options[4] == 10))
s->range_table = &range_pcl818l_h_ai; /* secondary range list jumper selectable */
} else {
@@ -1941,15 +1830,15 @@ no_dma:
}
s = dev->subdevices + 1;
- if (!this_board->n_aochan) {
+ if (!board->n_aochan) {
s->type = COMEDI_SUBD_UNUSED;
} else {
s->type = COMEDI_SUBD_AO;
s->subdev_flags = SDF_WRITABLE | SDF_GROUND;
- s->n_chan = this_board->n_aochan;
- s->maxdata = this_board->ao_maxdata;
- s->len_chanlist = this_board->n_aochan;
- s->range_table = this_board->ao_range_type;
+ s->n_chan = board->n_aochan;
+ s->maxdata = board->ao_maxdata;
+ s->len_chanlist = board->n_aochan;
+ s->range_table = board->ao_range_type;
s->insn_read = pcl818_ao_insn_read;
s->insn_write = pcl818_ao_insn_write;
#ifdef unused
@@ -1960,7 +1849,7 @@ no_dma:
}
#endif
#endif
- if (this_board->is_818) {
+ if (board->is_818) {
if ((it->options[4] == 1) || (it->options[4] == 10))
s->range_table = &range_unipolar10;
if (it->options[4] == 2)
@@ -1974,27 +1863,27 @@ no_dma:
}
s = dev->subdevices + 2;
- if (!this_board->n_dichan) {
+ if (!board->n_dichan) {
s->type = COMEDI_SUBD_UNUSED;
} else {
s->type = COMEDI_SUBD_DI;
s->subdev_flags = SDF_READABLE;
- s->n_chan = this_board->n_dichan;
+ s->n_chan = board->n_dichan;
s->maxdata = 1;
- s->len_chanlist = this_board->n_dichan;
+ s->len_chanlist = board->n_dichan;
s->range_table = &range_digital;
s->insn_bits = pcl818_di_insn_bits;
}
s = dev->subdevices + 3;
- if (!this_board->n_dochan) {
+ if (!board->n_dochan) {
s->type = COMEDI_SUBD_UNUSED;
} else {
s->type = COMEDI_SUBD_DO;
s->subdev_flags = SDF_WRITABLE;
- s->n_chan = this_board->n_dochan;
+ s->n_chan = board->n_dochan;
s->maxdata = 1;
- s->len_chanlist = this_board->n_dochan;
+ s->len_chanlist = board->n_dochan;
s->range_table = &range_digital;
s->insn_bits = pcl818_do_insn_bits;
}
@@ -2006,9 +1895,9 @@ no_dma:
devpriv->i8253_osc_base = 1000;
/* max sampling speed */
- devpriv->ns_min = this_board->ns_min;
+ devpriv->ns_min = board->ns_min;
- if (!this_board->is_818) {
+ if (!board->is_818) {
if ((it->options[6] == 1) || (it->options[6] == 100))
devpriv->ns_min = 10000; /* extended PCL718 to 100kHz DAC */
}
@@ -2020,17 +1909,71 @@ no_dma:
return 0;
}
-/*
-==============================================================================
- Removes device
- */
-static int pcl818_detach(struct comedi_device *dev)
+static void pcl818_detach(struct comedi_device *dev)
{
- /* printk("comedi%d: pcl818: remove\n", dev->minor); */
- free_resources(dev);
- return 0;
+ if (dev->private) {
+ pcl818_ai_cancel(dev, devpriv->sub_ai);
+ pcl818_reset(dev);
+ if (devpriv->dma)
+ free_dma(devpriv->dma);
+ if (devpriv->dmabuf[0])
+ free_pages(devpriv->dmabuf[0], devpriv->dmapages[0]);
+ if (devpriv->dmabuf[1])
+ free_pages(devpriv->dmabuf[1], devpriv->dmapages[1]);
+#ifdef unused
+ if (devpriv->rtc_irq)
+ free_irq(devpriv->rtc_irq, dev);
+ if ((devpriv->dma_rtc) && (RTC_lock == 1)) {
+ if (devpriv->rtc_iobase)
+ release_region(devpriv->rtc_iobase,
+ devpriv->rtc_iosize);
+ }
+ if (devpriv->dma_rtc)
+ RTC_lock--;
+#endif
+ }
+ if (dev->irq)
+ free_irq(dev->irq, dev);
+ if (dev->iobase)
+ release_region(dev->iobase, devpriv->io_range);
}
+static const struct pcl818_board boardtypes[] = {
+ {"pcl818l", 4, 16, 8, 25000, 1, 16, 16, &range_pcl818l_l_ai,
+ &range_unipolar5, PCLx1x_RANGE, 0x00fc,
+ 0x0a, 0xfff, 0xfff, 0, 1},
+ {"pcl818h", 9, 16, 8, 10000, 1, 16, 16, &range_pcl818h_ai,
+ &range_unipolar5, PCLx1x_RANGE, 0x00fc,
+ 0x0a, 0xfff, 0xfff, 0, 1},
+ {"pcl818hd", 9, 16, 8, 10000, 1, 16, 16, &range_pcl818h_ai,
+ &range_unipolar5, PCLx1x_RANGE, 0x00fc,
+ 0x0a, 0xfff, 0xfff, 1, 1},
+ {"pcl818hg", 12, 16, 8, 10000, 1, 16, 16, &range_pcl818hg_ai,
+ &range_unipolar5, PCLx1x_RANGE, 0x00fc,
+ 0x0a, 0xfff, 0xfff, 1, 1},
+ {"pcl818", 9, 16, 8, 10000, 2, 16, 16, &range_pcl818h_ai,
+ &range_unipolar5, PCLx1x_RANGE, 0x00fc,
+ 0x0a, 0xfff, 0xfff, 0, 1},
+ {"pcl718", 1, 16, 8, 16000, 2, 16, 16, &range_unipolar5,
+ &range_unipolar5, PCLx1x_RANGE, 0x00fc,
+ 0x0a, 0xfff, 0xfff, 0, 0},
+ /* pcm3718 */
+ {"pcm3718", 9, 16, 8, 10000, 0, 16, 16, &range_pcl818h_ai,
+ &range_unipolar5, PCLx1x_RANGE, 0x00fc,
+ 0x0a, 0xfff, 0xfff, 0, 1 /* XXX ? */ },
+};
+
+static struct comedi_driver pcl818_driver = {
+ .driver_name = "pcl818",
+ .module = THIS_MODULE,
+ .attach = pcl818_attach,
+ .detach = pcl818_detach,
+ .board_name = &boardtypes[0].name,
+ .num_names = ARRAY_SIZE(boardtypes),
+ .offset = sizeof(struct pcl818_board),
+};
+module_comedi_driver(pcl818_driver);
+
MODULE_AUTHOR("Comedi http://www.comedi.org");
MODULE_DESCRIPTION("Comedi low-level driver");
MODULE_LICENSE("GPL");
diff --git a/drivers/staging/comedi/drivers/pcm3724.c b/drivers/staging/comedi/drivers/pcm3724.c
index f5c0bd17684c..62c22ccfb780 100644
--- a/drivers/staging/comedi/drivers/pcm3724.c
+++ b/drivers/staging/comedi/drivers/pcm3724.c
@@ -62,10 +62,6 @@ Copy/pasted/hacked from pcm724.c
#define CR_A_MODE(a) ((a)<<5)
#define CR_CW 0x80
-static int pcm3724_attach(struct comedi_device *dev,
- struct comedi_devconfig *it);
-static int pcm3724_detach(struct comedi_device *dev);
-
struct pcm3724_board {
const char *name; /* driver name */
int dio; /* num of DIO */
@@ -80,38 +76,6 @@ struct priv_pcm3724 {
int dio_2;
};
-static const struct pcm3724_board boardtypes[] = {
- {"pcm3724", 48, 2, 0x00fc, PCM3724_SIZE,},
-};
-
-#define n_boardtypes (sizeof(boardtypes)/sizeof(struct pcm3724_board))
-#define this_board ((const struct pcm3724_board *)dev->board_ptr)
-
-static struct comedi_driver driver_pcm3724 = {
- .driver_name = "pcm3724",
- .module = THIS_MODULE,
- .attach = pcm3724_attach,
- .detach = pcm3724_detach,
- .board_name = &boardtypes[0].name,
- .num_names = n_boardtypes,
- .offset = sizeof(struct pcm3724_board),
-};
-
-static int __init driver_pcm3724_init_module(void)
-{
- return comedi_driver_register(&driver_pcm3724);
-}
-
-static void __exit driver_pcm3724_cleanup_module(void)
-{
- comedi_driver_unregister(&driver_pcm3724);
-}
-
-module_init(driver_pcm3724_init_module);
-module_exit(driver_pcm3724_cleanup_module);
-
-/* (setq c-basic-offset 8) */
-
static int subdev_8255_cb(int dir, int port, int data, unsigned long arg)
{
unsigned long iobase = arg;
@@ -266,12 +230,13 @@ static int subdev_3724_insn_config(struct comedi_device *dev,
static int pcm3724_attach(struct comedi_device *dev,
struct comedi_devconfig *it)
{
+ const struct pcm3724_board *board = comedi_board(dev);
unsigned long iobase;
unsigned int iorange;
int ret, i, n_subdevices;
iobase = it->options[0];
- iorange = this_board->io_range;
+ iorange = board->io_range;
ret = alloc_private(dev, sizeof(struct priv_pcm3724));
if (ret < 0)
@@ -281,20 +246,20 @@ static int pcm3724_attach(struct comedi_device *dev,
((struct priv_pcm3724 *)(dev->private))->dio_2 = 0;
printk(KERN_INFO "comedi%d: pcm3724: board=%s, 0x%03lx ", dev->minor,
- this_board->name, iobase);
+ board->name, iobase);
if (!iobase || !request_region(iobase, iorange, "pcm3724")) {
printk("I/O port conflict\n");
return -EIO;
}
dev->iobase = iobase;
- dev->board_name = this_board->name;
+ dev->board_name = board->name;
printk(KERN_INFO "\n");
- n_subdevices = this_board->numofports;
+ n_subdevices = board->numofports;
- ret = alloc_subdevices(dev, n_subdevices);
- if (ret < 0)
+ ret = comedi_alloc_subdevices(dev, n_subdevices);
+ if (ret)
return ret;
for (i = 0; i < dev->n_subdevices; i++) {
@@ -305,8 +270,9 @@ static int pcm3724_attach(struct comedi_device *dev,
return 0;
}
-static int pcm3724_detach(struct comedi_device *dev)
+static void pcm3724_detach(struct comedi_device *dev)
{
+ const struct pcm3724_board *board = comedi_board(dev);
int i;
if (dev->subdevices) {
@@ -314,11 +280,24 @@ static int pcm3724_detach(struct comedi_device *dev)
subdev_8255_cleanup(dev, dev->subdevices + i);
}
if (dev->iobase)
- release_region(dev->iobase, this_board->io_range);
-
- return 0;
+ release_region(dev->iobase, board->io_range);
}
+static const struct pcm3724_board boardtypes[] = {
+ { "pcm3724", 48, 2, 0x00fc, PCM3724_SIZE, },
+};
+
+static struct comedi_driver pcm3724_driver = {
+ .driver_name = "pcm3724",
+ .module = THIS_MODULE,
+ .attach = pcm3724_attach,
+ .detach = pcm3724_detach,
+ .board_name = &boardtypes[0].name,
+ .num_names = ARRAY_SIZE(boardtypes),
+ .offset = sizeof(struct pcm3724_board),
+};
+module_comedi_driver(pcm3724_driver);
+
MODULE_AUTHOR("Comedi http://www.comedi.org");
MODULE_DESCRIPTION("Comedi low-level driver");
MODULE_LICENSE("GPL");
diff --git a/drivers/staging/comedi/drivers/pcm3730.c b/drivers/staging/comedi/drivers/pcm3730.c
index bada6b236ff1..d65e0bda2c44 100644
--- a/drivers/staging/comedi/drivers/pcm3730.c
+++ b/drivers/staging/comedi/drivers/pcm3730.c
@@ -28,35 +28,10 @@ Configuration options:
#define PCM3730_DIB 2
#define PCM3730_DIC 3
-static int pcm3730_attach(struct comedi_device *dev,
- struct comedi_devconfig *it);
-static int pcm3730_detach(struct comedi_device *dev);
-static struct comedi_driver driver_pcm3730 = {
- .driver_name = "pcm3730",
- .module = THIS_MODULE,
- .attach = pcm3730_attach,
- .detach = pcm3730_detach,
-};
-
-static int __init driver_pcm3730_init_module(void)
-{
- return comedi_driver_register(&driver_pcm3730);
-}
-
-static void __exit driver_pcm3730_cleanup_module(void)
-{
- comedi_driver_unregister(&driver_pcm3730);
-}
-
-module_init(driver_pcm3730_init_module);
-module_exit(driver_pcm3730_cleanup_module);
-
static int pcm3730_do_insn_bits(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
- if (insn->n != 2)
- return -EINVAL;
if (data[0]) {
s->state &= ~data[0];
s->state |= (data[0] & data[1]);
@@ -64,17 +39,15 @@ static int pcm3730_do_insn_bits(struct comedi_device *dev,
}
data[1] = s->state;
- return 2;
+ return insn->n;
}
static int pcm3730_di_insn_bits(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
- if (insn->n != 2)
- return -EINVAL;
data[1] = inb(dev->iobase + (unsigned long)(s->private));
- return 2;
+ return insn->n;
}
static int pcm3730_attach(struct comedi_device *dev,
@@ -82,6 +55,7 @@ static int pcm3730_attach(struct comedi_device *dev,
{
struct comedi_subdevice *s;
unsigned long iobase;
+ int ret;
iobase = it->options[0];
printk(KERN_INFO "comedi%d: pcm3730: 0x%04lx ", dev->minor, iobase);
@@ -94,8 +68,9 @@ static int pcm3730_attach(struct comedi_device *dev,
dev->iobase = dev->iobase;
dev->irq = 0;
- if (alloc_subdevices(dev, 6) < 0)
- return -ENOMEM;
+ ret = comedi_alloc_subdevices(dev, 6);
+ if (ret)
+ return ret;
s = dev->subdevices + 0;
s->type = COMEDI_SUBD_DO;
@@ -156,16 +131,20 @@ static int pcm3730_attach(struct comedi_device *dev,
return 0;
}
-static int pcm3730_detach(struct comedi_device *dev)
+static void pcm3730_detach(struct comedi_device *dev)
{
- printk(KERN_INFO "comedi%d: pcm3730: remove\n", dev->minor);
-
if (dev->iobase)
release_region(dev->iobase, PCM3730_SIZE);
-
- return 0;
}
+static struct comedi_driver pcm3730_driver = {
+ .driver_name = "pcm3730",
+ .module = THIS_MODULE,
+ .attach = pcm3730_attach,
+ .detach = pcm3730_detach,
+};
+module_comedi_driver(pcm3730_driver);
+
MODULE_AUTHOR("Comedi http://www.comedi.org");
MODULE_DESCRIPTION("Comedi low-level driver");
MODULE_LICENSE("GPL");
diff --git a/drivers/staging/comedi/drivers/pcmad.c b/drivers/staging/comedi/drivers/pcmad.c
index 23b3d777340c..54d19c943967 100644
--- a/drivers/staging/comedi/drivers/pcmad.c
+++ b/drivers/staging/comedi/drivers/pcmad.c
@@ -57,19 +57,6 @@ struct pcmad_board_struct {
const char *name;
int n_ai_bits;
};
-static const struct pcmad_board_struct pcmad_boards[] = {
- {
- .name = "pcmad12",
- .n_ai_bits = 12,
- },
- {
- .name = "pcmad16",
- .n_ai_bits = 16,
- },
-};
-
-#define this_board ((const struct pcmad_board_struct *)(dev->board_ptr))
-#define n_pcmad_boards ARRAY_SIZE(pcmad_boards)
struct pcmad_priv_struct {
int differential;
@@ -77,37 +64,13 @@ struct pcmad_priv_struct {
};
#define devpriv ((struct pcmad_priv_struct *)dev->private)
-static int pcmad_attach(struct comedi_device *dev, struct comedi_devconfig *it);
-static int pcmad_detach(struct comedi_device *dev);
-static struct comedi_driver driver_pcmad = {
- .driver_name = "pcmad",
- .module = THIS_MODULE,
- .attach = pcmad_attach,
- .detach = pcmad_detach,
- .board_name = &pcmad_boards[0].name,
- .num_names = n_pcmad_boards,
- .offset = sizeof(pcmad_boards[0]),
-};
-
-static int __init driver_pcmad_init_module(void)
-{
- return comedi_driver_register(&driver_pcmad);
-}
-
-static void __exit driver_pcmad_cleanup_module(void)
-{
- comedi_driver_unregister(&driver_pcmad);
-}
-
-module_init(driver_pcmad_init_module);
-module_exit(driver_pcmad_cleanup_module);
-
#define TIMEOUT 100
static int pcmad_ai_insn_read(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
+ const struct pcmad_board_struct *board = comedi_board(dev);
int i;
int chan;
int n;
@@ -125,7 +88,7 @@ static int pcmad_ai_insn_read(struct comedi_device *dev,
data[n] |= (inb(dev->iobase + PCMAD_MSB) << 8);
if (devpriv->twos_comp)
- data[n] ^= (1 << (this_board->n_ai_bits - 1));
+ data[n] ^= (1 << (board->n_ai_bits - 1));
}
return n;
@@ -140,6 +103,7 @@ static int pcmad_ai_insn_read(struct comedi_device *dev,
*/
static int pcmad_attach(struct comedi_device *dev, struct comedi_devconfig *it)
{
+ const struct pcmad_board_struct *board = comedi_board(dev);
int ret;
struct comedi_subdevice *s;
unsigned long iobase;
@@ -153,15 +117,15 @@ static int pcmad_attach(struct comedi_device *dev, struct comedi_devconfig *it)
printk(KERN_CONT "\n");
dev->iobase = iobase;
- ret = alloc_subdevices(dev, 1);
- if (ret < 0)
+ ret = comedi_alloc_subdevices(dev, 1);
+ if (ret)
return ret;
ret = alloc_private(dev, sizeof(struct pcmad_priv_struct));
if (ret < 0)
return ret;
- dev->board_name = this_board->name;
+ dev->board_name = board->name;
s = dev->subdevices + 0;
s->type = COMEDI_SUBD_AI;
@@ -169,25 +133,40 @@ static int pcmad_attach(struct comedi_device *dev, struct comedi_devconfig *it)
s->n_chan = 16; /* XXX */
s->len_chanlist = 1;
s->insn_read = pcmad_ai_insn_read;
- s->maxdata = (1 << this_board->n_ai_bits) - 1;
+ s->maxdata = (1 << board->n_ai_bits) - 1;
s->range_table = &range_unknown;
return 0;
}
-static int pcmad_detach(struct comedi_device *dev)
+static void pcmad_detach(struct comedi_device *dev)
{
- printk(KERN_INFO "comedi%d: pcmad: remove\n", dev->minor);
-
if (dev->irq)
free_irq(dev->irq, dev);
-
if (dev->iobase)
release_region(dev->iobase, PCMAD_SIZE);
-
- return 0;
}
+static const struct pcmad_board_struct pcmad_boards[] = {
+ {
+ .name = "pcmad12",
+ .n_ai_bits = 12,
+ }, {
+ .name = "pcmad16",
+ .n_ai_bits = 16,
+ },
+};
+static struct comedi_driver pcmad_driver = {
+ .driver_name = "pcmad",
+ .module = THIS_MODULE,
+ .attach = pcmad_attach,
+ .detach = pcmad_detach,
+ .board_name = &pcmad_boards[0].name,
+ .num_names = ARRAY_SIZE(pcmad_boards),
+ .offset = sizeof(pcmad_boards[0]),
+};
+module_comedi_driver(pcmad_driver);
+
MODULE_AUTHOR("Comedi http://www.comedi.org");
MODULE_DESCRIPTION("Comedi low-level driver");
MODULE_LICENSE("GPL");
diff --git a/drivers/staging/comedi/drivers/pcmda12.c b/drivers/staging/comedi/drivers/pcmda12.c
index 0e9ffa28d745..291ce7c1bdb1 100644
--- a/drivers/staging/comedi/drivers/pcmda12.c
+++ b/drivers/staging/comedi/drivers/pcmda12.c
@@ -80,17 +80,6 @@ static const struct comedi_lrange pcmda12_ranges = {
}
};
-static const struct pcmda12_board pcmda12_boards[] = {
- {
- .name = "pcmda12",
- },
-};
-
-/*
- * Useful for shorthand access to the particular board structure
- */
-#define thisboard ((const struct pcmda12_board *)dev->board_ptr)
-
struct pcmda12_private {
unsigned int ao_readback[CHANS];
@@ -99,137 +88,6 @@ struct pcmda12_private {
#define devpriv ((struct pcmda12_private *)(dev->private))
-/*
- * The struct comedi_driver structure tells the Comedi core module
- * which functions to call to configure/deconfigure (attach/detach)
- * the board, and also about the kernel module that contains
- * the device code.
- */
-static int pcmda12_attach(struct comedi_device *dev,
- struct comedi_devconfig *it);
-static int pcmda12_detach(struct comedi_device *dev);
-
-static void zero_chans(struct comedi_device *dev);
-
-static struct comedi_driver driver = {
- .driver_name = "pcmda12",
- .module = THIS_MODULE,
- .attach = pcmda12_attach,
- .detach = pcmda12_detach,
-/* It is not necessary to implement the following members if you are
- * writing a driver for a ISA PnP or PCI card */
- /* Most drivers will support multiple types of boards by
- * having an array of board structures. These were defined
- * in pcmda12_boards[] above. Note that the element 'name'
- * was first in the structure -- Comedi uses this fact to
- * extract the name of the board without knowing any details
- * about the structure except for its length.
- * When a device is attached (by comedi_config), the name
- * of the device is given to Comedi, and Comedi tries to
- * match it by going through the list of board names. If
- * there is a match, the address of the pointer is put
- * into dev->board_ptr and driver->attach() is called.
- *
- * Note that these are not necessary if you can determine
- * the type of board in software. ISA PnP, PCI, and PCMCIA
- * devices are such boards.
- */
- .board_name = &pcmda12_boards[0].name,
- .offset = sizeof(struct pcmda12_board),
- .num_names = ARRAY_SIZE(pcmda12_boards),
-};
-
-static int ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data);
-static int ao_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data);
-
-/*
- * Attach is called by the Comedi core to configure the driver
- * for a particular board. If you specified a board_name array
- * in the driver structure, dev->board_ptr contains that
- * address.
- */
-static int pcmda12_attach(struct comedi_device *dev,
- struct comedi_devconfig *it)
-{
- struct comedi_subdevice *s;
- unsigned long iobase;
-
- iobase = it->options[0];
- printk(KERN_INFO
- "comedi%d: %s: io: %lx %s ", dev->minor, driver.driver_name,
- iobase, it->options[1] ? "simultaneous xfer mode enabled" : "");
-
- if (!request_region(iobase, IOSIZE, driver.driver_name)) {
- printk("I/O port conflict\n");
- return -EIO;
- }
- dev->iobase = iobase;
-
-/*
- * Initialize dev->board_name. Note that we can use the "thisboard"
- * macro now, since we just initialized it in the last line.
- */
- dev->board_name = thisboard->name;
-
-/*
- * Allocate the private structure area. alloc_private() is a
- * convenient macro defined in comedidev.h.
- */
- if (alloc_private(dev, sizeof(struct pcmda12_private)) < 0) {
- printk(KERN_ERR "cannot allocate private data structure\n");
- return -ENOMEM;
- }
-
- devpriv->simultaneous_xfer_mode = it->options[1];
-
- /*
- * Allocate the subdevice structures. alloc_subdevice() is a
- * convenient macro defined in comedidev.h.
- *
- * Allocate 2 subdevs (32 + 16 DIO lines) or 3 32 DIO subdevs for the
- * 96-channel version of the board.
- */
- if (alloc_subdevices(dev, 1) < 0) {
- printk(KERN_ERR "cannot allocate subdevice data structures\n");
- return -ENOMEM;
- }
-
- s = dev->subdevices;
- s->private = NULL;
- s->maxdata = (0x1 << BITS) - 1;
- s->range_table = &pcmda12_ranges;
- s->type = COMEDI_SUBD_AO;
- s->subdev_flags = SDF_READABLE | SDF_WRITABLE;
- s->n_chan = CHANS;
- s->insn_write = &ao_winsn;
- s->insn_read = &ao_rinsn;
-
- zero_chans(dev); /* clear out all the registers, basically */
-
- printk(KERN_INFO "attached\n");
-
- return 1;
-}
-
-/*
- * _detach is called to deconfigure a device. It should deallocate
- * resources.
- * This function is also called when _attach() fails, so it should be
- * careful not to release resources that were not necessarily
- * allocated by _attach(). dev->private and dev->subdevices are
- * deallocated automatically by the core.
- */
-static int pcmda12_detach(struct comedi_device *dev)
-{
- printk(KERN_INFO
- "comedi%d: %s: remove\n", dev->minor, driver.driver_name);
- if (dev->iobase)
- release_region(dev->iobase, IOSIZE);
- return 0;
-}
-
static void zero_chans(struct comedi_device *dev)
{ /* sets up an
ASIC chip to defaults */
@@ -301,22 +159,81 @@ static int ao_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
return i;
}
+static int pcmda12_attach(struct comedi_device *dev,
+ struct comedi_devconfig *it)
+{
+ const struct pcmda12_board *board = comedi_board(dev);
+ struct comedi_subdevice *s;
+ unsigned long iobase;
+ int ret;
+
+ iobase = it->options[0];
+ printk(KERN_INFO
+ "comedi%d: %s: io: %lx %s ", dev->minor, dev->driver->driver_name,
+ iobase, it->options[1] ? "simultaneous xfer mode enabled" : "");
+
+ if (!request_region(iobase, IOSIZE, dev->driver->driver_name)) {
+ printk("I/O port conflict\n");
+ return -EIO;
+ }
+ dev->iobase = iobase;
+
+ dev->board_name = board->name;
+
/*
- * A convenient macro that defines init_module() and cleanup_module(),
- * as necessary.
+ * Allocate the private structure area. alloc_private() is a
+ * convenient macro defined in comedidev.h.
*/
-static int __init driver_init_module(void)
-{
- return comedi_driver_register(&driver);
+ if (alloc_private(dev, sizeof(struct pcmda12_private)) < 0) {
+ printk(KERN_ERR "cannot allocate private data structure\n");
+ return -ENOMEM;
+ }
+
+ devpriv->simultaneous_xfer_mode = it->options[1];
+
+ ret = comedi_alloc_subdevices(dev, 1);
+ if (ret)
+ return ret;
+
+ s = dev->subdevices;
+ s->private = NULL;
+ s->maxdata = (0x1 << BITS) - 1;
+ s->range_table = &pcmda12_ranges;
+ s->type = COMEDI_SUBD_AO;
+ s->subdev_flags = SDF_READABLE | SDF_WRITABLE;
+ s->n_chan = CHANS;
+ s->insn_write = &ao_winsn;
+ s->insn_read = &ao_rinsn;
+
+ zero_chans(dev); /* clear out all the registers, basically */
+
+ printk(KERN_INFO "attached\n");
+
+ return 1;
}
-static void __exit driver_cleanup_module(void)
+static void pcmda12_detach(struct comedi_device *dev)
{
- comedi_driver_unregister(&driver);
+ if (dev->iobase)
+ release_region(dev->iobase, IOSIZE);
}
-module_init(driver_init_module);
-module_exit(driver_cleanup_module);
+static const struct pcmda12_board pcmda12_boards[] = {
+ {
+ .name = "pcmda12",
+ },
+};
+
+static struct comedi_driver pcmda12_driver = {
+ .driver_name = "pcmda12",
+ .module = THIS_MODULE,
+ .attach = pcmda12_attach,
+ .detach = pcmda12_detach,
+ .board_name = &pcmda12_boards[0].name,
+ .offset = sizeof(struct pcmda12_board),
+ .num_names = ARRAY_SIZE(pcmda12_boards),
+};
+module_comedi_driver(pcmda12_driver);
MODULE_AUTHOR("Comedi http://www.comedi.org");
MODULE_DESCRIPTION("Comedi low-level driver");
diff --git a/drivers/staging/comedi/drivers/pcmmio.c b/drivers/staging/comedi/drivers/pcmmio.c
index eddac00e4e29..3d2e6f01c4b7 100644
--- a/drivers/staging/comedi/drivers/pcmmio.c
+++ b/drivers/staging/comedi/drivers/pcmmio.c
@@ -145,13 +145,6 @@ Configuration Options:
#define PAGE_ENAB 2
#define PAGE_INT_ID 3
-static int ai_rinsn(struct comedi_device *, struct comedi_subdevice *,
- struct comedi_insn *, unsigned int *);
-static int ao_rinsn(struct comedi_device *, struct comedi_subdevice *,
- struct comedi_insn *, unsigned int *);
-static int ao_winsn(struct comedi_device *, struct comedi_subdevice *,
- struct comedi_insn *, unsigned int *);
-
/*
* Board descriptions for two imaginary boards. Describing the
* boards in this way is optional, and completely driver-dependent.
@@ -190,28 +183,6 @@ static const struct comedi_lrange ranges_ao = {
RANGE(-2.5, 2.5), RANGE(-2.5, 7.5)}
};
-static const struct pcmmio_board pcmmio_boards[] = {
- {
- .name = "pcmmio",
- .dio_num_asics = 1,
- .dio_num_ports = 6,
- .total_iosize = 32,
- .ai_bits = 16,
- .ao_bits = 16,
- .n_ai_chans = 16,
- .n_ao_chans = 8,
- .ai_range_table = &ranges_ai,
- .ao_range_table = &ranges_ao,
- .ai_rinsn = ai_rinsn,
- .ao_rinsn = ao_rinsn,
- .ao_winsn = ao_winsn},
-};
-
-/*
- * Useful for shorthand access to the particular board structure
- */
-#define thisboard ((const struct pcmmio_board *)dev->board_ptr)
-
/* this structure is for data unique to this subdevice. */
struct pcmmio_subdev_private {
@@ -293,312 +264,6 @@ struct pcmmio_private {
*/
#define devpriv ((struct pcmmio_private *)dev->private)
#define subpriv ((struct pcmmio_subdev_private *)s->private)
-/*
- * The struct comedi_driver structure tells the Comedi core module
- * which functions to call to configure/deconfigure (attach/detach)
- * the board, and also about the kernel module that contains
- * the device code.
- */
-static int pcmmio_attach(struct comedi_device *dev,
- struct comedi_devconfig *it);
-static int pcmmio_detach(struct comedi_device *dev);
-
-static struct comedi_driver driver = {
- .driver_name = "pcmmio",
- .module = THIS_MODULE,
- .attach = pcmmio_attach,
- .detach = pcmmio_detach,
-/* It is not necessary to implement the following members if you are
- * writing a driver for a ISA PnP or PCI card */
- /* Most drivers will support multiple types of boards by
- * having an array of board structures. These were defined
- * in pcmmio_boards[] above. Note that the element 'name'
- * was first in the structure -- Comedi uses this fact to
- * extract the name of the board without knowing any details
- * about the structure except for its length.
- * When a device is attached (by comedi_config), the name
- * of the device is given to Comedi, and Comedi tries to
- * match it by going through the list of board names. If
- * there is a match, the address of the pointer is put
- * into dev->board_ptr and driver->attach() is called.
- *
- * Note that these are not necessary if you can determine
- * the type of board in software. ISA PnP, PCI, and PCMCIA
- * devices are such boards.
- */
- .board_name = &pcmmio_boards[0].name,
- .offset = sizeof(struct pcmmio_board),
- .num_names = ARRAY_SIZE(pcmmio_boards),
-};
-
-static int pcmmio_dio_insn_bits(struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data);
-static int pcmmio_dio_insn_config(struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data);
-
-static irqreturn_t interrupt_pcmmio(int irq, void *d);
-static void pcmmio_stop_intr(struct comedi_device *, struct comedi_subdevice *);
-static int pcmmio_cancel(struct comedi_device *dev, struct comedi_subdevice *s);
-static int pcmmio_cmd(struct comedi_device *dev, struct comedi_subdevice *s);
-static int pcmmio_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
- struct comedi_cmd *cmd);
-
-/* some helper functions to deal with specifics of this device's registers */
-/* sets up/clears ASIC chips to defaults */
-static void init_asics(struct comedi_device *dev);
-static void switch_page(struct comedi_device *dev, int asic, int page);
-#ifdef notused
-static void lock_port(struct comedi_device *dev, int asic, int port);
-static void unlock_port(struct comedi_device *dev, int asic, int port);
-#endif
-
-/*
- * Attach is called by the Comedi core to configure the driver
- * for a particular board. If you specified a board_name array
- * in the driver structure, dev->board_ptr contains that
- * address.
- */
-static int pcmmio_attach(struct comedi_device *dev, struct comedi_devconfig *it)
-{
- struct comedi_subdevice *s;
- int sdev_no, chans_left, n_dio_subdevs, n_subdevs, port, asic,
- thisasic_chanct = 0;
- unsigned long iobase;
- unsigned int irq[MAX_ASICS];
-
- iobase = it->options[0];
- irq[0] = it->options[1];
-
- printk(KERN_INFO "comedi%d: %s: io: %lx attaching...\n", dev->minor,
- driver.driver_name, iobase);
-
- dev->iobase = iobase;
-
- if (!iobase || !request_region(iobase,
- thisboard->total_iosize,
- driver.driver_name)) {
- printk(KERN_ERR "comedi%d: I/O port conflict\n", dev->minor);
- return -EIO;
- }
-
-/*
- * Initialize dev->board_name. Note that we can use the "thisboard"
- * macro now, since we just initialized it in the last line.
- */
- dev->board_name = thisboard->name;
-
-/*
- * Allocate the private structure area. alloc_private() is a
- * convenient macro defined in comedidev.h.
- */
- if (alloc_private(dev, sizeof(struct pcmmio_private)) < 0) {
- printk(KERN_ERR "comedi%d: cannot allocate private data structure\n",
- dev->minor);
- return -ENOMEM;
- }
-
- for (asic = 0; asic < MAX_ASICS; ++asic) {
- devpriv->asics[asic].num = asic;
- devpriv->asics[asic].iobase =
- dev->iobase + 16 + asic * ASIC_IOSIZE;
- /*
- * this gets actually set at the end of this function when we
- * request_irqs
- */
- devpriv->asics[asic].irq = 0;
- spin_lock_init(&devpriv->asics[asic].spinlock);
- }
-
- chans_left = CHANS_PER_ASIC * thisboard->dio_num_asics;
- n_dio_subdevs = CALC_N_DIO_SUBDEVS(chans_left);
- n_subdevs = n_dio_subdevs + 2;
- devpriv->sprivs =
- kcalloc(n_subdevs, sizeof(struct pcmmio_subdev_private),
- GFP_KERNEL);
- if (!devpriv->sprivs) {
- printk(KERN_ERR "comedi%d: cannot allocate subdevice private data structures\n",
- dev->minor);
- return -ENOMEM;
- }
- /*
- * Allocate the subdevice structures. alloc_subdevice() is a
- * convenient macro defined in comedidev.h.
- *
- * Allocate 1 AI + 1 AO + 2 DIO subdevs (24 lines per DIO)
- */
- if (alloc_subdevices(dev, n_subdevs) < 0) {
- printk(KERN_ERR "comedi%d: cannot allocate subdevice data structures\n",
- dev->minor);
- return -ENOMEM;
- }
-
- /* First, AI */
- sdev_no = 0;
- s = dev->subdevices + sdev_no;
- s->private = devpriv->sprivs + sdev_no;
- s->maxdata = (1 << thisboard->ai_bits) - 1;
- s->range_table = thisboard->ai_range_table;
- s->subdev_flags = SDF_READABLE | SDF_GROUND | SDF_DIFF;
- s->type = COMEDI_SUBD_AI;
- s->n_chan = thisboard->n_ai_chans;
- s->len_chanlist = s->n_chan;
- s->insn_read = thisboard->ai_rinsn;
- subpriv->iobase = dev->iobase + 0;
- /* initialize the resource enable register by clearing it */
- outb(0, subpriv->iobase + 3);
- outb(0, subpriv->iobase + 4 + 3);
-
- /* Next, AO */
- ++sdev_no;
- s = dev->subdevices + sdev_no;
- s->private = devpriv->sprivs + sdev_no;
- s->maxdata = (1 << thisboard->ao_bits) - 1;
- s->range_table = thisboard->ao_range_table;
- s->subdev_flags = SDF_READABLE;
- s->type = COMEDI_SUBD_AO;
- s->n_chan = thisboard->n_ao_chans;
- s->len_chanlist = s->n_chan;
- s->insn_read = thisboard->ao_rinsn;
- s->insn_write = thisboard->ao_winsn;
- subpriv->iobase = dev->iobase + 8;
- /* initialize the resource enable register by clearing it */
- outb(0, subpriv->iobase + 3);
- outb(0, subpriv->iobase + 4 + 3);
-
- ++sdev_no;
- port = 0;
- asic = 0;
- for (; sdev_no < (int)dev->n_subdevices; ++sdev_no) {
- int byte_no;
-
- s = dev->subdevices + sdev_no;
- s->private = devpriv->sprivs + sdev_no;
- s->maxdata = 1;
- s->range_table = &range_digital;
- s->subdev_flags = SDF_READABLE | SDF_WRITABLE;
- s->type = COMEDI_SUBD_DIO;
- s->insn_bits = pcmmio_dio_insn_bits;
- s->insn_config = pcmmio_dio_insn_config;
- s->n_chan = min(chans_left, MAX_CHANS_PER_SUBDEV);
- subpriv->dio.intr.asic = -1;
- subpriv->dio.intr.first_chan = -1;
- subpriv->dio.intr.asic_chan = -1;
- subpriv->dio.intr.num_asic_chans = -1;
- subpriv->dio.intr.active = 0;
- s->len_chanlist = 1;
-
- /* save the ioport address for each 'port' of 8 channels in the
- subdevice */
- for (byte_no = 0; byte_no < PORTS_PER_SUBDEV; ++byte_no, ++port) {
- if (port >= PORTS_PER_ASIC) {
- port = 0;
- ++asic;
- thisasic_chanct = 0;
- }
- subpriv->iobases[byte_no] =
- devpriv->asics[asic].iobase + port;
-
- if (thisasic_chanct <
- CHANS_PER_PORT * INTR_PORTS_PER_ASIC
- && subpriv->dio.intr.asic < 0) {
- /*
- * this is an interrupt subdevice,
- * so setup the struct
- */
- subpriv->dio.intr.asic = asic;
- subpriv->dio.intr.active = 0;
- subpriv->dio.intr.stop_count = 0;
- subpriv->dio.intr.first_chan = byte_no * 8;
- subpriv->dio.intr.asic_chan = thisasic_chanct;
- subpriv->dio.intr.num_asic_chans =
- s->n_chan - subpriv->dio.intr.first_chan;
- s->cancel = pcmmio_cancel;
- s->do_cmd = pcmmio_cmd;
- s->do_cmdtest = pcmmio_cmdtest;
- s->len_chanlist =
- subpriv->dio.intr.num_asic_chans;
- }
- thisasic_chanct += CHANS_PER_PORT;
- }
- spin_lock_init(&subpriv->dio.intr.spinlock);
-
- chans_left -= s->n_chan;
-
- if (!chans_left) {
- /*
- * reset the asic to our first asic,
- * to do intr subdevs
- */
- asic = 0;
- port = 0;
- }
-
- }
-
- init_asics(dev); /* clear out all the registers, basically */
-
- for (asic = 0; irq[0] && asic < MAX_ASICS; ++asic) {
- if (irq[asic]
- && request_irq(irq[asic], interrupt_pcmmio,
- IRQF_SHARED, thisboard->name, dev)) {
- int i;
- /* unroll the allocated irqs.. */
- for (i = asic - 1; i >= 0; --i) {
- free_irq(irq[i], dev);
- devpriv->asics[i].irq = irq[i] = 0;
- }
- irq[asic] = 0;
- }
- devpriv->asics[asic].irq = irq[asic];
- }
-
- dev->irq = irq[0]; /*
- * grr.. wish comedi dev struct supported
- * multiple irqs..
- */
-
- if (irq[0]) {
- printk(KERN_DEBUG "comedi%d: irq: %u\n", dev->minor, irq[0]);
- if (thisboard->dio_num_asics == 2 && irq[1])
- printk(KERN_DEBUG "comedi%d: second ASIC irq: %u\n",
- dev->minor, irq[1]);
- } else {
- printk(KERN_INFO "comedi%d: (IRQ mode disabled)\n", dev->minor);
- }
-
- printk(KERN_INFO "comedi%d: attached\n", dev->minor);
-
- return 1;
-}
-
-/*
- * _detach is called to deconfigure a device. It should deallocate
- * resources.
- * This function is also called when _attach() fails, so it should be
- * careful not to release resources that were not necessarily
- * allocated by _attach(). dev->private and dev->subdevices are
- * deallocated automatically by the core.
- */
-static int pcmmio_detach(struct comedi_device *dev)
-{
- int i;
-
- printk(KERN_INFO "comedi%d: %s: remove\n", dev->minor, driver.driver_name);
- if (dev->iobase)
- release_region(dev->iobase, thisboard->total_iosize);
-
- for (i = 0; i < MAX_ASICS; ++i) {
- if (devpriv && devpriv->asics[i].irq)
- free_irq(devpriv->asics[i].irq, dev);
- }
-
- if (devpriv && devpriv->sprivs)
- kfree(devpriv->sprivs);
-
- return 0;
-}
/* DIO devices are slightly special. Although it is possible to
* implement the insn_read/insn_write interface, it is much more
@@ -610,8 +275,6 @@ static int pcmmio_dio_insn_bits(struct comedi_device *dev,
struct comedi_insn *insn, unsigned int *data)
{
int byte_no;
- if (insn->n != 2)
- return -EINVAL;
/* NOTE:
reading a 0 means this channel was high
@@ -667,7 +330,7 @@ static int pcmmio_dio_insn_bits(struct comedi_device *dev,
}
#ifdef DAMMIT_ITS_BROKEN
/* DEBUG */
- printk("data_out_byte %02x\n", (unsigned)byte);
+ printk(KERN_DEBUG "data_out_byte %02x\n", (unsigned)byte);
#endif
/* save the digital input lines for this byte.. */
s->state |= ((unsigned int)byte) << offset;
@@ -681,7 +344,7 @@ static int pcmmio_dio_insn_bits(struct comedi_device *dev,
printk(KERN_DEBUG "s->state %08x data_out %08x\n", s->state, data[1]);
#endif
- return 2;
+ return insn->n;
}
/* The input or output configuration of each digital line is
@@ -751,12 +414,30 @@ static int pcmmio_dio_insn_config(struct comedi_device *dev,
return insn->n;
}
+static void switch_page(struct comedi_device *dev, int asic, int page)
+{
+ const struct pcmmio_board *board = comedi_board(dev);
+
+ if (asic < 0 || asic >= board->dio_num_asics)
+ return; /* paranoia */
+ if (page < 0 || page >= NUM_PAGES)
+ return; /* more paranoia */
+
+ devpriv->asics[asic].pagelock &= ~REG_PAGE_MASK;
+ devpriv->asics[asic].pagelock |= page << REG_PAGE_BITOFFSET;
+
+ /* now write out the shadow register */
+ outb(devpriv->asics[asic].pagelock,
+ devpriv->asics[asic].iobase + REG_PAGELOCK);
+}
+
static void init_asics(struct comedi_device *dev)
{ /* sets up an
ASIC chip to defaults */
+ const struct pcmmio_board *board = comedi_board(dev);
int asic;
- for (asic = 0; asic < thisboard->dio_num_asics; ++asic) {
+ for (asic = 0; asic < board->dio_num_asics; ++asic) {
int port, page;
unsigned long baseaddr = devpriv->asics[asic].iobase;
@@ -788,25 +469,12 @@ static void init_asics(struct comedi_device *dev)
}
}
-static void switch_page(struct comedi_device *dev, int asic, int page)
-{
- if (asic < 0 || asic >= thisboard->dio_num_asics)
- return; /* paranoia */
- if (page < 0 || page >= NUM_PAGES)
- return; /* more paranoia */
-
- devpriv->asics[asic].pagelock &= ~REG_PAGE_MASK;
- devpriv->asics[asic].pagelock |= page << REG_PAGE_BITOFFSET;
-
- /* now write out the shadow register */
- outb(devpriv->asics[asic].pagelock,
- devpriv->asics[asic].iobase + REG_PAGELOCK);
-}
-
#ifdef notused
static void lock_port(struct comedi_device *dev, int asic, int port)
{
- if (asic < 0 || asic >= thisboard->dio_num_asics)
+ const struct pcmmio_board *board = comedi_board(dev);
+
+ if (asic < 0 || asic >= board->dio_num_asics)
return; /* paranoia */
if (port < 0 || port >= PORTS_PER_ASIC)
return; /* more paranoia */
@@ -820,7 +488,9 @@ static void lock_port(struct comedi_device *dev, int asic, int port)
static void unlock_port(struct comedi_device *dev, int asic, int port)
{
- if (asic < 0 || asic >= thisboard->dio_num_asics)
+ const struct pcmmio_board *board = comedi_board(dev);
+
+ if (asic < 0 || asic >= board->dio_num_asics)
return; /* paranoia */
if (port < 0 || port >= PORTS_PER_ASIC)
return; /* more paranoia */
@@ -831,6 +501,27 @@ static void unlock_port(struct comedi_device *dev, int asic, int port)
}
#endif /* notused */
+static void pcmmio_stop_intr(struct comedi_device *dev,
+ struct comedi_subdevice *s)
+{
+ int nports, firstport, asic, port;
+
+ asic = subpriv->dio.intr.asic;
+ if (asic < 0)
+ return; /* not an interrupt subdev */
+
+ subpriv->dio.intr.enabled_mask = 0;
+ subpriv->dio.intr.active = 0;
+ s->async->inttrig = NULL;
+ nports = subpriv->dio.intr.num_asic_chans / CHANS_PER_PORT;
+ firstport = subpriv->dio.intr.asic_chan / CHANS_PER_PORT;
+ switch_page(dev, asic, PAGE_ENAB);
+ for (port = firstport; port < firstport + nports; ++port) {
+ /* disable all intrs for this subdev.. */
+ outb(0, devpriv->asics[asic].iobase + REG_ENAB0 + port);
+ }
+}
+
static irqreturn_t interrupt_pcmmio(int irq, void *d)
{
int asic, got1 = 0;
@@ -991,27 +682,6 @@ static irqreturn_t interrupt_pcmmio(int irq, void *d)
return IRQ_HANDLED;
}
-static void pcmmio_stop_intr(struct comedi_device *dev,
- struct comedi_subdevice *s)
-{
- int nports, firstport, asic, port;
-
- asic = subpriv->dio.intr.asic;
- if (asic < 0)
- return; /* not an interrupt subdev */
-
- subpriv->dio.intr.enabled_mask = 0;
- subpriv->dio.intr.active = 0;
- s->async->inttrig = 0;
- nports = subpriv->dio.intr.num_asic_chans / CHANS_PER_PORT;
- firstport = subpriv->dio.intr.asic_chan / CHANS_PER_PORT;
- switch_page(dev, asic, PAGE_ENAB);
- for (port = firstport; port < firstport + nports; ++port) {
- /* disable all intrs for this subdev.. */
- outb(0, devpriv->asics[asic].iobase + REG_ENAB0 + port);
- }
-}
-
static int pcmmio_start_intr(struct comedi_device *dev,
struct comedi_subdevice *s)
{
@@ -1108,7 +778,7 @@ pcmmio_inttrig_start_intr(struct comedi_device *dev, struct comedi_subdevice *s,
return -EINVAL;
spin_lock_irqsave(&subpriv->dio.intr.spinlock, flags);
- s->async->inttrig = 0;
+ s->async->inttrig = NULL;
if (subpriv->dio.intr.active)
event = pcmmio_start_intr(dev, s);
spin_unlock_irqrestore(&subpriv->dio.intr.spinlock, flags);
@@ -1340,22 +1010,253 @@ static int ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s,
return n;
}
+static int pcmmio_attach(struct comedi_device *dev, struct comedi_devconfig *it)
+{
+ const struct pcmmio_board *board = comedi_board(dev);
+ struct comedi_subdevice *s;
+ int sdev_no, chans_left, n_dio_subdevs, n_subdevs, port, asic,
+ thisasic_chanct = 0;
+ unsigned long iobase;
+ unsigned int irq[MAX_ASICS];
+ int ret;
+
+ iobase = it->options[0];
+ irq[0] = it->options[1];
+
+ printk(KERN_INFO "comedi%d: %s: io: %lx attaching...\n", dev->minor,
+ dev->driver->driver_name, iobase);
+
+ dev->iobase = iobase;
+
+ if (!iobase || !request_region(iobase,
+ board->total_iosize,
+ dev->driver->driver_name)) {
+ printk(KERN_ERR "comedi%d: I/O port conflict\n", dev->minor);
+ return -EIO;
+ }
+
+ dev->board_name = board->name;
+
/*
- * A convenient macro that defines init_module() and cleanup_module(),
- * as necessary.
+ * Allocate the private structure area. alloc_private() is a
+ * convenient macro defined in comedidev.h.
*/
-static int __init driver_init_module(void)
-{
- return comedi_driver_register(&driver);
+ if (alloc_private(dev, sizeof(struct pcmmio_private)) < 0) {
+ printk(KERN_ERR "comedi%d: cannot allocate private data structure\n",
+ dev->minor);
+ return -ENOMEM;
+ }
+
+ for (asic = 0; asic < MAX_ASICS; ++asic) {
+ devpriv->asics[asic].num = asic;
+ devpriv->asics[asic].iobase =
+ dev->iobase + 16 + asic * ASIC_IOSIZE;
+ /*
+ * this gets actually set at the end of this function when we
+ * request_irqs
+ */
+ devpriv->asics[asic].irq = 0;
+ spin_lock_init(&devpriv->asics[asic].spinlock);
+ }
+
+ chans_left = CHANS_PER_ASIC * board->dio_num_asics;
+ n_dio_subdevs = CALC_N_DIO_SUBDEVS(chans_left);
+ n_subdevs = n_dio_subdevs + 2;
+ devpriv->sprivs =
+ kcalloc(n_subdevs, sizeof(struct pcmmio_subdev_private),
+ GFP_KERNEL);
+ if (!devpriv->sprivs) {
+ printk(KERN_ERR "comedi%d: cannot allocate subdevice private data structures\n",
+ dev->minor);
+ return -ENOMEM;
+ }
+
+ ret = comedi_alloc_subdevices(dev, n_subdevs);
+ if (ret)
+ return ret;
+
+ /* First, AI */
+ sdev_no = 0;
+ s = dev->subdevices + sdev_no;
+ s->private = devpriv->sprivs + sdev_no;
+ s->maxdata = (1 << board->ai_bits) - 1;
+ s->range_table = board->ai_range_table;
+ s->subdev_flags = SDF_READABLE | SDF_GROUND | SDF_DIFF;
+ s->type = COMEDI_SUBD_AI;
+ s->n_chan = board->n_ai_chans;
+ s->len_chanlist = s->n_chan;
+ s->insn_read = board->ai_rinsn;
+ subpriv->iobase = dev->iobase + 0;
+ /* initialize the resource enable register by clearing it */
+ outb(0, subpriv->iobase + 3);
+ outb(0, subpriv->iobase + 4 + 3);
+
+ /* Next, AO */
+ ++sdev_no;
+ s = dev->subdevices + sdev_no;
+ s->private = devpriv->sprivs + sdev_no;
+ s->maxdata = (1 << board->ao_bits) - 1;
+ s->range_table = board->ao_range_table;
+ s->subdev_flags = SDF_READABLE;
+ s->type = COMEDI_SUBD_AO;
+ s->n_chan = board->n_ao_chans;
+ s->len_chanlist = s->n_chan;
+ s->insn_read = board->ao_rinsn;
+ s->insn_write = board->ao_winsn;
+ subpriv->iobase = dev->iobase + 8;
+ /* initialize the resource enable register by clearing it */
+ outb(0, subpriv->iobase + 3);
+ outb(0, subpriv->iobase + 4 + 3);
+
+ ++sdev_no;
+ port = 0;
+ asic = 0;
+ for (; sdev_no < (int)dev->n_subdevices; ++sdev_no) {
+ int byte_no;
+
+ s = dev->subdevices + sdev_no;
+ s->private = devpriv->sprivs + sdev_no;
+ s->maxdata = 1;
+ s->range_table = &range_digital;
+ s->subdev_flags = SDF_READABLE | SDF_WRITABLE;
+ s->type = COMEDI_SUBD_DIO;
+ s->insn_bits = pcmmio_dio_insn_bits;
+ s->insn_config = pcmmio_dio_insn_config;
+ s->n_chan = min(chans_left, MAX_CHANS_PER_SUBDEV);
+ subpriv->dio.intr.asic = -1;
+ subpriv->dio.intr.first_chan = -1;
+ subpriv->dio.intr.asic_chan = -1;
+ subpriv->dio.intr.num_asic_chans = -1;
+ subpriv->dio.intr.active = 0;
+ s->len_chanlist = 1;
+
+ /* save the ioport address for each 'port' of 8 channels in the
+ subdevice */
+ for (byte_no = 0; byte_no < PORTS_PER_SUBDEV; ++byte_no, ++port) {
+ if (port >= PORTS_PER_ASIC) {
+ port = 0;
+ ++asic;
+ thisasic_chanct = 0;
+ }
+ subpriv->iobases[byte_no] =
+ devpriv->asics[asic].iobase + port;
+
+ if (thisasic_chanct <
+ CHANS_PER_PORT * INTR_PORTS_PER_ASIC
+ && subpriv->dio.intr.asic < 0) {
+ /*
+ * this is an interrupt subdevice,
+ * so setup the struct
+ */
+ subpriv->dio.intr.asic = asic;
+ subpriv->dio.intr.active = 0;
+ subpriv->dio.intr.stop_count = 0;
+ subpriv->dio.intr.first_chan = byte_no * 8;
+ subpriv->dio.intr.asic_chan = thisasic_chanct;
+ subpriv->dio.intr.num_asic_chans =
+ s->n_chan - subpriv->dio.intr.first_chan;
+ s->cancel = pcmmio_cancel;
+ s->do_cmd = pcmmio_cmd;
+ s->do_cmdtest = pcmmio_cmdtest;
+ s->len_chanlist =
+ subpriv->dio.intr.num_asic_chans;
+ }
+ thisasic_chanct += CHANS_PER_PORT;
+ }
+ spin_lock_init(&subpriv->dio.intr.spinlock);
+
+ chans_left -= s->n_chan;
+
+ if (!chans_left) {
+ /*
+ * reset the asic to our first asic,
+ * to do intr subdevs
+ */
+ asic = 0;
+ port = 0;
+ }
+
+ }
+
+ init_asics(dev); /* clear out all the registers, basically */
+
+ for (asic = 0; irq[0] && asic < MAX_ASICS; ++asic) {
+ if (irq[asic]
+ && request_irq(irq[asic], interrupt_pcmmio,
+ IRQF_SHARED, board->name, dev)) {
+ int i;
+ /* unroll the allocated irqs.. */
+ for (i = asic - 1; i >= 0; --i) {
+ free_irq(irq[i], dev);
+ devpriv->asics[i].irq = irq[i] = 0;
+ }
+ irq[asic] = 0;
+ }
+ devpriv->asics[asic].irq = irq[asic];
+ }
+
+ dev->irq = irq[0]; /*
+ * grr.. wish comedi dev struct supported
+ * multiple irqs..
+ */
+
+ if (irq[0]) {
+ printk(KERN_DEBUG "comedi%d: irq: %u\n", dev->minor, irq[0]);
+ if (board->dio_num_asics == 2 && irq[1])
+ printk(KERN_DEBUG "comedi%d: second ASIC irq: %u\n",
+ dev->minor, irq[1]);
+ } else {
+ printk(KERN_INFO "comedi%d: (IRQ mode disabled)\n", dev->minor);
+ }
+
+ printk(KERN_INFO "comedi%d: attached\n", dev->minor);
+
+ return 1;
}
-static void __exit driver_cleanup_module(void)
+static void pcmmio_detach(struct comedi_device *dev)
{
- comedi_driver_unregister(&driver);
+ const struct pcmmio_board *board = comedi_board(dev);
+ int i;
+
+ if (dev->iobase)
+ release_region(dev->iobase, board->total_iosize);
+ for (i = 0; i < MAX_ASICS; ++i) {
+ if (devpriv && devpriv->asics[i].irq)
+ free_irq(devpriv->asics[i].irq, dev);
+ }
+ if (devpriv && devpriv->sprivs)
+ kfree(devpriv->sprivs);
}
-module_init(driver_init_module);
-module_exit(driver_cleanup_module);
+static const struct pcmmio_board pcmmio_boards[] = {
+ {
+ .name = "pcmmio",
+ .dio_num_asics = 1,
+ .dio_num_ports = 6,
+ .total_iosize = 32,
+ .ai_bits = 16,
+ .ao_bits = 16,
+ .n_ai_chans = 16,
+ .n_ao_chans = 8,
+ .ai_range_table = &ranges_ai,
+ .ao_range_table = &ranges_ao,
+ .ai_rinsn = ai_rinsn,
+ .ao_rinsn = ao_rinsn,
+ .ao_winsn = ao_winsn
+ },
+};
+
+static struct comedi_driver pcmmio_driver = {
+ .driver_name = "pcmmio",
+ .module = THIS_MODULE,
+ .attach = pcmmio_attach,
+ .detach = pcmmio_detach,
+ .board_name = &pcmmio_boards[0].name,
+ .offset = sizeof(struct pcmmio_board),
+ .num_names = ARRAY_SIZE(pcmmio_boards),
+};
+module_comedi_driver(pcmmio_driver);
MODULE_AUTHOR("Comedi http://www.comedi.org");
MODULE_DESCRIPTION("Comedi low-level driver");
diff --git a/drivers/staging/comedi/drivers/pcmuio.c b/drivers/staging/comedi/drivers/pcmuio.c
index 661ba2e03892..feef3d02f35a 100644
--- a/drivers/staging/comedi/drivers/pcmuio.c
+++ b/drivers/staging/comedi/drivers/pcmuio.c
@@ -155,24 +155,6 @@ struct pcmuio_board {
const int num_ports;
};
-static const struct pcmuio_board pcmuio_boards[] = {
- {
- .name = "pcmuio48",
- .num_asics = 1,
- .num_ports = 6,
- },
- {
- .name = "pcmuio96",
- .num_asics = 2,
- .num_ports = 12,
- },
-};
-
-/*
- * Useful for shorthand access to the particular board structure
- */
-#define thisboard ((const struct pcmuio_board *)dev->board_ptr)
-
/* this structure is for data unique to this subdevice. */
struct pcmuio_subdev_private {
/* mapping of halfwords (bytes) in port/chanarray to iobase */
@@ -218,262 +200,6 @@ struct pcmuio_private {
*/
#define devpriv ((struct pcmuio_private *)dev->private)
#define subpriv ((struct pcmuio_subdev_private *)s->private)
-/*
- * The struct comedi_driver structure tells the Comedi core module
- * which functions to call to configure/deconfigure (attach/detach)
- * the board, and also about the kernel module that contains
- * the device code.
- */
-static int pcmuio_attach(struct comedi_device *dev,
- struct comedi_devconfig *it);
-static int pcmuio_detach(struct comedi_device *dev);
-
-static struct comedi_driver driver = {
- .driver_name = "pcmuio",
- .module = THIS_MODULE,
- .attach = pcmuio_attach,
- .detach = pcmuio_detach,
-/* It is not necessary to implement the following members if you are
- * writing a driver for a ISA PnP or PCI card */
- /* Most drivers will support multiple types of boards by
- * having an array of board structures. These were defined
- * in pcmuio_boards[] above. Note that the element 'name'
- * was first in the structure -- Comedi uses this fact to
- * extract the name of the board without knowing any details
- * about the structure except for its length.
- * When a device is attached (by comedi_config), the name
- * of the device is given to Comedi, and Comedi tries to
- * match it by going through the list of board names. If
- * there is a match, the address of the pointer is put
- * into dev->board_ptr and driver->attach() is called.
- *
- * Note that these are not necessary if you can determine
- * the type of board in software. ISA PnP, PCI, and PCMCIA
- * devices are such boards.
- */
- .board_name = &pcmuio_boards[0].name,
- .offset = sizeof(struct pcmuio_board),
- .num_names = ARRAY_SIZE(pcmuio_boards),
-};
-
-static int pcmuio_dio_insn_bits(struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data);
-static int pcmuio_dio_insn_config(struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data);
-
-static irqreturn_t interrupt_pcmuio(int irq, void *d);
-static void pcmuio_stop_intr(struct comedi_device *, struct comedi_subdevice *);
-static int pcmuio_cancel(struct comedi_device *dev, struct comedi_subdevice *s);
-static int pcmuio_cmd(struct comedi_device *dev, struct comedi_subdevice *s);
-static int pcmuio_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
- struct comedi_cmd *cmd);
-
-/* some helper functions to deal with specifics of this device's registers */
-static void init_asics(struct comedi_device *dev); /* sets up/clears ASIC chips to defaults */
-static void switch_page(struct comedi_device *dev, int asic, int page);
-#ifdef notused
-static void lock_port(struct comedi_device *dev, int asic, int port);
-static void unlock_port(struct comedi_device *dev, int asic, int port);
-#endif
-
-/*
- * Attach is called by the Comedi core to configure the driver
- * for a particular board. If you specified a board_name array
- * in the driver structure, dev->board_ptr contains that
- * address.
- */
-static int pcmuio_attach(struct comedi_device *dev, struct comedi_devconfig *it)
-{
- struct comedi_subdevice *s;
- int sdev_no, chans_left, n_subdevs, port, asic, thisasic_chanct = 0;
- unsigned long iobase;
- unsigned int irq[MAX_ASICS];
-
- iobase = it->options[0];
- irq[0] = it->options[1];
- irq[1] = it->options[2];
-
- dev_dbg(dev->hw_dev, "comedi%d: %s: io: %lx attached\n", dev->minor,
- driver.driver_name, iobase);
-
- dev->iobase = iobase;
-
- if (!iobase || !request_region(iobase,
- thisboard->num_asics * ASIC_IOSIZE,
- driver.driver_name)) {
- dev_err(dev->hw_dev, "I/O port conflict\n");
- return -EIO;
- }
-
-/*
- * Initialize dev->board_name. Note that we can use the "thisboard"
- * macro now, since we just initialized it in the last line.
- */
- dev->board_name = thisboard->name;
-
-/*
- * Allocate the private structure area. alloc_private() is a
- * convenient macro defined in comedidev.h.
- */
- if (alloc_private(dev, sizeof(struct pcmuio_private)) < 0) {
- dev_warn(dev->hw_dev, "cannot allocate private data structure\n");
- return -ENOMEM;
- }
-
- for (asic = 0; asic < MAX_ASICS; ++asic) {
- devpriv->asics[asic].num = asic;
- devpriv->asics[asic].iobase = dev->iobase + asic * ASIC_IOSIZE;
- devpriv->asics[asic].irq = 0; /* this gets actually set at the end of
- this function when we
- request_irqs */
- spin_lock_init(&devpriv->asics[asic].spinlock);
- }
-
- chans_left = CHANS_PER_ASIC * thisboard->num_asics;
- n_subdevs = CALC_N_SUBDEVS(chans_left);
- devpriv->sprivs =
- kcalloc(n_subdevs, sizeof(struct pcmuio_subdev_private),
- GFP_KERNEL);
- if (!devpriv->sprivs) {
- dev_warn(dev->hw_dev, "cannot allocate subdevice private data structures\n");
- return -ENOMEM;
- }
- /*
- * Allocate the subdevice structures. alloc_subdevice() is a
- * convenient macro defined in comedidev.h.
- *
- * Allocate 2 subdevs (32 + 16 DIO lines) or 3 32 DIO subdevs for the
- * 96-channel version of the board.
- */
- if (alloc_subdevices(dev, n_subdevs) < 0) {
- dev_dbg(dev->hw_dev, "cannot allocate subdevice data structures\n");
- return -ENOMEM;
- }
-
- port = 0;
- asic = 0;
- for (sdev_no = 0; sdev_no < (int)dev->n_subdevices; ++sdev_no) {
- int byte_no;
-
- s = dev->subdevices + sdev_no;
- s->private = devpriv->sprivs + sdev_no;
- s->maxdata = 1;
- s->range_table = &range_digital;
- s->subdev_flags = SDF_READABLE | SDF_WRITABLE;
- s->type = COMEDI_SUBD_DIO;
- s->insn_bits = pcmuio_dio_insn_bits;
- s->insn_config = pcmuio_dio_insn_config;
- s->n_chan = min(chans_left, MAX_CHANS_PER_SUBDEV);
- subpriv->intr.asic = -1;
- subpriv->intr.first_chan = -1;
- subpriv->intr.asic_chan = -1;
- subpriv->intr.num_asic_chans = -1;
- subpriv->intr.active = 0;
- s->len_chanlist = 1;
-
- /* save the ioport address for each 'port' of 8 channels in the
- subdevice */
- for (byte_no = 0; byte_no < PORTS_PER_SUBDEV; ++byte_no, ++port) {
- if (port >= PORTS_PER_ASIC) {
- port = 0;
- ++asic;
- thisasic_chanct = 0;
- }
- subpriv->iobases[byte_no] =
- devpriv->asics[asic].iobase + port;
-
- if (thisasic_chanct <
- CHANS_PER_PORT * INTR_PORTS_PER_ASIC
- && subpriv->intr.asic < 0) {
- /* this is an interrupt subdevice, so setup the struct */
- subpriv->intr.asic = asic;
- subpriv->intr.active = 0;
- subpriv->intr.stop_count = 0;
- subpriv->intr.first_chan = byte_no * 8;
- subpriv->intr.asic_chan = thisasic_chanct;
- subpriv->intr.num_asic_chans =
- s->n_chan - subpriv->intr.first_chan;
- dev->read_subdev = s;
- s->subdev_flags |= SDF_CMD_READ;
- s->cancel = pcmuio_cancel;
- s->do_cmd = pcmuio_cmd;
- s->do_cmdtest = pcmuio_cmdtest;
- s->len_chanlist = subpriv->intr.num_asic_chans;
- }
- thisasic_chanct += CHANS_PER_PORT;
- }
- spin_lock_init(&subpriv->intr.spinlock);
-
- chans_left -= s->n_chan;
-
- if (!chans_left) {
- asic = 0; /* reset the asic to our first asic, to do intr subdevs */
- port = 0;
- }
-
- }
-
- init_asics(dev); /* clear out all the registers, basically */
-
- for (asic = 0; irq[0] && asic < MAX_ASICS; ++asic) {
- if (irq[asic]
- && request_irq(irq[asic], interrupt_pcmuio,
- IRQF_SHARED, thisboard->name, dev)) {
- int i;
- /* unroll the allocated irqs.. */
- for (i = asic - 1; i >= 0; --i) {
- free_irq(irq[i], dev);
- devpriv->asics[i].irq = irq[i] = 0;
- }
- irq[asic] = 0;
- }
- devpriv->asics[asic].irq = irq[asic];
- }
-
- dev->irq = irq[0]; /* grr.. wish comedi dev struct supported multiple
- irqs.. */
-
- if (irq[0]) {
- dev_dbg(dev->hw_dev, "irq: %u\n", irq[0]);
- if (irq[1] && thisboard->num_asics == 2)
- dev_dbg(dev->hw_dev, "second ASIC irq: %u\n", irq[1]);
- } else {
- dev_dbg(dev->hw_dev, "(IRQ mode disabled)\n");
- }
-
-
- return 1;
-}
-
-/*
- * _detach is called to deconfigure a device. It should deallocate
- * resources.
- * This function is also called when _attach() fails, so it should be
- * careful not to release resources that were not necessarily
- * allocated by _attach(). dev->private and dev->subdevices are
- * deallocated automatically by the core.
- */
-static int pcmuio_detach(struct comedi_device *dev)
-{
- int i;
-
- dev_dbg(dev->hw_dev, "comedi%d: %s: remove\n", dev->minor,
- driver.driver_name);
- if (dev->iobase)
- release_region(dev->iobase, ASIC_IOSIZE * thisboard->num_asics);
-
- for (i = 0; i < MAX_ASICS; ++i) {
- if (devpriv->asics[i].irq)
- free_irq(devpriv->asics[i].irq, dev);
- }
-
- if (devpriv && devpriv->sprivs)
- kfree(devpriv->sprivs);
-
- return 0;
-}
/* DIO devices are slightly special. Although it is possible to
* implement the insn_read/insn_write interface, it is much more
@@ -485,8 +211,6 @@ static int pcmuio_dio_insn_bits(struct comedi_device *dev,
struct comedi_insn *insn, unsigned int *data)
{
int byte_no;
- if (insn->n != 2)
- return -EINVAL;
/* NOTE:
reading a 0 means this channel was high
@@ -501,7 +225,7 @@ static int pcmuio_dio_insn_bits(struct comedi_device *dev,
#ifdef DAMMIT_ITS_BROKEN
/* DEBUG */
- dev_dbg(dev->hw_dev, "write mask: %08x data: %08x\n", data[0],
+ dev_dbg(dev->class_dev, "write mask: %08x data: %08x\n", data[0],
data[1]);
#endif
@@ -538,7 +262,7 @@ static int pcmuio_dio_insn_bits(struct comedi_device *dev,
}
#ifdef DAMMIT_ITS_BROKEN
/* DEBUG */
- dev_dbg(dev->hw_dev, "data_out_byte %02x\n", (unsigned)byte);
+ dev_dbg(dev->class_dev, "data_out_byte %02x\n", (unsigned)byte);
#endif
/* save the digital input lines for this byte.. */
s->state |= ((unsigned int)byte) << offset;
@@ -549,11 +273,11 @@ static int pcmuio_dio_insn_bits(struct comedi_device *dev,
#ifdef DAMMIT_ITS_BROKEN
/* DEBUG */
- dev_dbg(dev->hw_dev, "s->state %08x data_out %08x\n", s->state,
+ dev_dbg(dev->class_dev, "s->state %08x data_out %08x\n", s->state,
data[1]);
#endif
- return 2;
+ return insn->n;
}
/* The input or output configuration of each digital line is
@@ -621,12 +345,30 @@ static int pcmuio_dio_insn_config(struct comedi_device *dev,
return insn->n;
}
+static void switch_page(struct comedi_device *dev, int asic, int page)
+{
+ const struct pcmuio_board *board = comedi_board(dev);
+
+ if (asic < 0 || asic >= board->num_asics)
+ return; /* paranoia */
+ if (page < 0 || page >= NUM_PAGES)
+ return; /* more paranoia */
+
+ devpriv->asics[asic].pagelock &= ~REG_PAGE_MASK;
+ devpriv->asics[asic].pagelock |= page << REG_PAGE_BITOFFSET;
+
+ /* now write out the shadow register */
+ outb(devpriv->asics[asic].pagelock,
+ dev->iobase + ASIC_IOSIZE * asic + REG_PAGELOCK);
+}
+
static void init_asics(struct comedi_device *dev)
{ /* sets up an
ASIC chip to defaults */
+ const struct pcmuio_board *board = comedi_board(dev);
int asic;
- for (asic = 0; asic < thisboard->num_asics; ++asic) {
+ for (asic = 0; asic < board->num_asics; ++asic) {
int port, page;
unsigned long baseaddr = dev->iobase + asic * ASIC_IOSIZE;
@@ -658,25 +400,12 @@ static void init_asics(struct comedi_device *dev)
}
}
-static void switch_page(struct comedi_device *dev, int asic, int page)
-{
- if (asic < 0 || asic >= thisboard->num_asics)
- return; /* paranoia */
- if (page < 0 || page >= NUM_PAGES)
- return; /* more paranoia */
-
- devpriv->asics[asic].pagelock &= ~REG_PAGE_MASK;
- devpriv->asics[asic].pagelock |= page << REG_PAGE_BITOFFSET;
-
- /* now write out the shadow register */
- outb(devpriv->asics[asic].pagelock,
- dev->iobase + ASIC_IOSIZE * asic + REG_PAGELOCK);
-}
-
#ifdef notused
static void lock_port(struct comedi_device *dev, int asic, int port)
{
- if (asic < 0 || asic >= thisboard->num_asics)
+ const struct pcmuio_board *board = comedi_board(dev);
+
+ if (asic < 0 || asic >= board->num_asics)
return; /* paranoia */
if (port < 0 || port >= PORTS_PER_ASIC)
return; /* more paranoia */
@@ -689,7 +418,9 @@ static void lock_port(struct comedi_device *dev, int asic, int port)
static void unlock_port(struct comedi_device *dev, int asic, int port)
{
- if (asic < 0 || asic >= thisboard->num_asics)
+ const struct pcmuio_board *board = comedi_board(dev);
+
+ if (asic < 0 || asic >= board->num_asics)
return; /* paranoia */
if (port < 0 || port >= PORTS_PER_ASIC)
return; /* more paranoia */
@@ -700,6 +431,27 @@ static void unlock_port(struct comedi_device *dev, int asic, int port)
}
#endif /* notused */
+static void pcmuio_stop_intr(struct comedi_device *dev,
+ struct comedi_subdevice *s)
+{
+ int nports, firstport, asic, port;
+
+ asic = subpriv->intr.asic;
+ if (asic < 0)
+ return; /* not an interrupt subdev */
+
+ subpriv->intr.enabled_mask = 0;
+ subpriv->intr.active = 0;
+ s->async->inttrig = 0;
+ nports = subpriv->intr.num_asic_chans / CHANS_PER_PORT;
+ firstport = subpriv->intr.asic_chan / CHANS_PER_PORT;
+ switch_page(dev, asic, PAGE_ENAB);
+ for (port = firstport; port < firstport + nports; ++port) {
+ /* disable all intrs for this subdev.. */
+ outb(0, devpriv->asics[asic].iobase + REG_ENAB0 + port);
+ }
+}
+
static irqreturn_t interrupt_pcmuio(int irq, void *d)
{
int asic, got1 = 0;
@@ -852,27 +604,6 @@ static irqreturn_t interrupt_pcmuio(int irq, void *d)
return IRQ_HANDLED;
}
-static void pcmuio_stop_intr(struct comedi_device *dev,
- struct comedi_subdevice *s)
-{
- int nports, firstport, asic, port;
-
- asic = subpriv->intr.asic;
- if (asic < 0)
- return; /* not an interrupt subdev */
-
- subpriv->intr.enabled_mask = 0;
- subpriv->intr.active = 0;
- s->async->inttrig = 0;
- nports = subpriv->intr.num_asic_chans / CHANS_PER_PORT;
- firstport = subpriv->intr.asic_chan / CHANS_PER_PORT;
- switch_page(dev, asic, PAGE_ENAB);
- for (port = firstport; port < firstport + nports; ++port) {
- /* disable all intrs for this subdev.. */
- outb(0, devpriv->asics[asic].iobase + REG_ENAB0 + port);
- }
-}
-
static int pcmuio_start_intr(struct comedi_device *dev,
struct comedi_subdevice *s)
{
@@ -1014,22 +745,200 @@ pcmuio_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
return comedi_pcm_cmdtest(dev, s, cmd);
}
+static int pcmuio_attach(struct comedi_device *dev, struct comedi_devconfig *it)
+{
+ const struct pcmuio_board *board = comedi_board(dev);
+ struct comedi_subdevice *s;
+ int sdev_no, chans_left, n_subdevs, port, asic, thisasic_chanct = 0;
+ unsigned long iobase;
+ unsigned int irq[MAX_ASICS];
+ int ret;
+
+ iobase = it->options[0];
+ irq[0] = it->options[1];
+ irq[1] = it->options[2];
+
+ dev_dbg(dev->class_dev, "%s: io: %lx attach\n",
+ dev->driver->driver_name, iobase);
+
+ dev->iobase = iobase;
+
+ if (!iobase || !request_region(iobase,
+ board->num_asics * ASIC_IOSIZE,
+ dev->driver->driver_name)) {
+ dev_err(dev->class_dev, "I/O port conflict\n");
+ return -EIO;
+ }
+
+ dev->board_name = board->name;
+
/*
- * A convenient macro that defines init_module() and cleanup_module(),
- * as necessary.
+ * Allocate the private structure area. alloc_private() is a
+ * convenient macro defined in comedidev.h.
*/
-static int __init driver_init_module(void)
-{
- return comedi_driver_register(&driver);
+ if (alloc_private(dev, sizeof(struct pcmuio_private)) < 0) {
+ dev_warn(dev->class_dev,
+ "cannot allocate private data structure\n");
+ return -ENOMEM;
+ }
+
+ for (asic = 0; asic < MAX_ASICS; ++asic) {
+ devpriv->asics[asic].num = asic;
+ devpriv->asics[asic].iobase = dev->iobase + asic * ASIC_IOSIZE;
+ devpriv->asics[asic].irq = 0; /* this gets actually set at the end of
+ this function when we
+ request_irqs */
+ spin_lock_init(&devpriv->asics[asic].spinlock);
+ }
+
+ chans_left = CHANS_PER_ASIC * board->num_asics;
+ n_subdevs = CALC_N_SUBDEVS(chans_left);
+ devpriv->sprivs =
+ kcalloc(n_subdevs, sizeof(struct pcmuio_subdev_private),
+ GFP_KERNEL);
+ if (!devpriv->sprivs) {
+ dev_warn(dev->class_dev,
+ "cannot allocate subdevice private data structures\n");
+ return -ENOMEM;
+ }
+
+ ret = comedi_alloc_subdevices(dev, n_subdevs);
+ if (ret)
+ return ret;
+
+ port = 0;
+ asic = 0;
+ for (sdev_no = 0; sdev_no < (int)dev->n_subdevices; ++sdev_no) {
+ int byte_no;
+
+ s = dev->subdevices + sdev_no;
+ s->private = devpriv->sprivs + sdev_no;
+ s->maxdata = 1;
+ s->range_table = &range_digital;
+ s->subdev_flags = SDF_READABLE | SDF_WRITABLE;
+ s->type = COMEDI_SUBD_DIO;
+ s->insn_bits = pcmuio_dio_insn_bits;
+ s->insn_config = pcmuio_dio_insn_config;
+ s->n_chan = min(chans_left, MAX_CHANS_PER_SUBDEV);
+ subpriv->intr.asic = -1;
+ subpriv->intr.first_chan = -1;
+ subpriv->intr.asic_chan = -1;
+ subpriv->intr.num_asic_chans = -1;
+ subpriv->intr.active = 0;
+ s->len_chanlist = 1;
+
+ /* save the ioport address for each 'port' of 8 channels in the
+ subdevice */
+ for (byte_no = 0; byte_no < PORTS_PER_SUBDEV; ++byte_no, ++port) {
+ if (port >= PORTS_PER_ASIC) {
+ port = 0;
+ ++asic;
+ thisasic_chanct = 0;
+ }
+ subpriv->iobases[byte_no] =
+ devpriv->asics[asic].iobase + port;
+
+ if (thisasic_chanct <
+ CHANS_PER_PORT * INTR_PORTS_PER_ASIC
+ && subpriv->intr.asic < 0) {
+ /* this is an interrupt subdevice, so setup the struct */
+ subpriv->intr.asic = asic;
+ subpriv->intr.active = 0;
+ subpriv->intr.stop_count = 0;
+ subpriv->intr.first_chan = byte_no * 8;
+ subpriv->intr.asic_chan = thisasic_chanct;
+ subpriv->intr.num_asic_chans =
+ s->n_chan - subpriv->intr.first_chan;
+ dev->read_subdev = s;
+ s->subdev_flags |= SDF_CMD_READ;
+ s->cancel = pcmuio_cancel;
+ s->do_cmd = pcmuio_cmd;
+ s->do_cmdtest = pcmuio_cmdtest;
+ s->len_chanlist = subpriv->intr.num_asic_chans;
+ }
+ thisasic_chanct += CHANS_PER_PORT;
+ }
+ spin_lock_init(&subpriv->intr.spinlock);
+
+ chans_left -= s->n_chan;
+
+ if (!chans_left) {
+ asic = 0; /* reset the asic to our first asic, to do intr subdevs */
+ port = 0;
+ }
+
+ }
+
+ init_asics(dev); /* clear out all the registers, basically */
+
+ for (asic = 0; irq[0] && asic < MAX_ASICS; ++asic) {
+ if (irq[asic]
+ && request_irq(irq[asic], interrupt_pcmuio,
+ IRQF_SHARED, board->name, dev)) {
+ int i;
+ /* unroll the allocated irqs.. */
+ for (i = asic - 1; i >= 0; --i) {
+ free_irq(irq[i], dev);
+ devpriv->asics[i].irq = irq[i] = 0;
+ }
+ irq[asic] = 0;
+ }
+ devpriv->asics[asic].irq = irq[asic];
+ }
+
+ dev->irq = irq[0]; /* grr.. wish comedi dev struct supported multiple
+ irqs.. */
+
+ if (irq[0]) {
+ dev_dbg(dev->class_dev, "irq: %u\n", irq[0]);
+ if (irq[1] && board->num_asics == 2)
+ dev_dbg(dev->class_dev, "second ASIC irq: %u\n",
+ irq[1]);
+ } else {
+ dev_dbg(dev->class_dev, "(IRQ mode disabled)\n");
+ }
+
+
+ return 1;
}
-static void __exit driver_cleanup_module(void)
+static void pcmuio_detach(struct comedi_device *dev)
{
- comedi_driver_unregister(&driver);
+ const struct pcmuio_board *board = comedi_board(dev);
+ int i;
+
+ if (dev->iobase)
+ release_region(dev->iobase, ASIC_IOSIZE * board->num_asics);
+ for (i = 0; i < MAX_ASICS; ++i) {
+ if (devpriv->asics[i].irq)
+ free_irq(devpriv->asics[i].irq, dev);
+ }
+ if (devpriv && devpriv->sprivs)
+ kfree(devpriv->sprivs);
}
-module_init(driver_init_module);
-module_exit(driver_cleanup_module);
+static const struct pcmuio_board pcmuio_boards[] = {
+ {
+ .name = "pcmuio48",
+ .num_asics = 1,
+ .num_ports = 6,
+ }, {
+ .name = "pcmuio96",
+ .num_asics = 2,
+ .num_ports = 12,
+ },
+};
+
+static struct comedi_driver pcmuio_driver = {
+ .driver_name = "pcmuio",
+ .module = THIS_MODULE,
+ .attach = pcmuio_attach,
+ .detach = pcmuio_detach,
+ .board_name = &pcmuio_boards[0].name,
+ .offset = sizeof(struct pcmuio_board),
+ .num_names = ARRAY_SIZE(pcmuio_boards),
+};
+module_comedi_driver(pcmuio_driver);
MODULE_AUTHOR("Comedi http://www.comedi.org");
MODULE_DESCRIPTION("Comedi low-level driver");
diff --git a/drivers/staging/comedi/drivers/poc.c b/drivers/staging/comedi/drivers/poc.c
index 831a576c24aa..c253bb9ef335 100644
--- a/drivers/staging/comedi/drivers/poc.c
+++ b/drivers/staging/comedi/drivers/poc.c
@@ -41,20 +41,6 @@ Configuration options:
#include <linux/ioport.h>
-static int poc_attach(struct comedi_device *dev, struct comedi_devconfig *it);
-static int poc_detach(struct comedi_device *dev);
-static int readback_insn(struct comedi_device *dev, struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data);
-
-static int dac02_ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data);
-static int pcl733_insn_bits(struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data);
-static int pcl734_insn_bits(struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data);
-
struct boarddef_struct {
const char *name;
unsigned int iosize;
@@ -70,107 +56,6 @@ struct boarddef_struct {
struct comedi_insn *, unsigned int *);
const struct comedi_lrange *range;
};
-static const struct boarddef_struct boards[] = {
- {
- .name = "dac02",
- .iosize = 8,
- /* .setup = dac02_setup, */
- .type = COMEDI_SUBD_AO,
- .n_chan = 2,
- .n_bits = 12,
- .winsn = dac02_ao_winsn,
- .rinsn = readback_insn,
- .range = &range_unknown,
- },
- {
- .name = "pcl733",
- .iosize = 4,
- .type = COMEDI_SUBD_DI,
- .n_chan = 32,
- .n_bits = 1,
- .insnbits = pcl733_insn_bits,
- .range = &range_digital,
- },
- {
- .name = "pcl734",
- .iosize = 4,
- .type = COMEDI_SUBD_DO,
- .n_chan = 32,
- .n_bits = 1,
- .insnbits = pcl734_insn_bits,
- .range = &range_digital,
- },
-};
-
-#define n_boards ARRAY_SIZE(boards)
-#define this_board ((const struct boarddef_struct *)dev->board_ptr)
-
-static struct comedi_driver driver_poc = {
- .driver_name = "poc",
- .module = THIS_MODULE,
- .attach = poc_attach,
- .detach = poc_detach,
- .board_name = &boards[0].name,
- .num_names = n_boards,
- .offset = sizeof(boards[0]),
-};
-
-static int poc_attach(struct comedi_device *dev, struct comedi_devconfig *it)
-{
- struct comedi_subdevice *s;
- unsigned long iobase;
- unsigned int iosize;
-
- iobase = it->options[0];
- printk(KERN_INFO "comedi%d: poc: using %s iobase 0x%lx\n", dev->minor,
- this_board->name, iobase);
-
- dev->board_name = this_board->name;
-
- if (iobase == 0) {
- printk(KERN_ERR "io base address required\n");
- return -EINVAL;
- }
-
- iosize = this_board->iosize;
- /* check if io addresses are available */
- if (!request_region(iobase, iosize, "dac02")) {
- printk(KERN_ERR "I/O port conflict: failed to allocate ports "
- "0x%lx to 0x%lx\n", iobase, iobase + iosize - 1);
- return -EIO;
- }
- dev->iobase = iobase;
-
- if (alloc_subdevices(dev, 1) < 0)
- return -ENOMEM;
- if (alloc_private(dev, sizeof(unsigned int) * this_board->n_chan) < 0)
- return -ENOMEM;
-
- /* analog output subdevice */
- s = dev->subdevices + 0;
- s->type = this_board->type;
- s->n_chan = this_board->n_chan;
- s->maxdata = (1 << this_board->n_bits) - 1;
- s->range_table = this_board->range;
- s->insn_write = this_board->winsn;
- s->insn_read = this_board->rinsn;
- s->insn_bits = this_board->insnbits;
- if (s->type == COMEDI_SUBD_AO || s->type == COMEDI_SUBD_DO)
- s->subdev_flags = SDF_WRITABLE;
-
- return 0;
-}
-
-static int poc_detach(struct comedi_device *dev)
-{
- /* only free stuff if it has been allocated by _attach */
- if (dev->iobase)
- release_region(dev->iobase, this_board->iosize);
-
- printk(KERN_INFO "comedi%d: dac02: remove\n", dev->minor);
-
- return 0;
-}
static int readback_insn(struct comedi_device *dev, struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
@@ -214,23 +99,18 @@ static int pcl733_insn_bits(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
- if (insn->n != 2)
- return -EINVAL;
-
data[1] = inb(dev->iobase + 0);
data[1] |= (inb(dev->iobase + 1) << 8);
data[1] |= (inb(dev->iobase + 2) << 16);
data[1] |= (inb(dev->iobase + 3) << 24);
- return 2;
+ return insn->n;
}
static int pcl734_insn_bits(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
- if (insn->n != 2)
- return -EINVAL;
if (data[0]) {
s->state &= ~data[0];
s->state |= (data[0] & data[1]);
@@ -245,21 +125,107 @@ static int pcl734_insn_bits(struct comedi_device *dev,
}
data[1] = s->state;
- return 2;
+ return insn->n;
}
-static int __init driver_poc_init_module(void)
+static int poc_attach(struct comedi_device *dev, struct comedi_devconfig *it)
{
- return comedi_driver_register(&driver_poc);
+ const struct boarddef_struct *board = comedi_board(dev);
+ struct comedi_subdevice *s;
+ unsigned long iobase;
+ unsigned int iosize;
+ int ret;
+
+ iobase = it->options[0];
+ printk(KERN_INFO "comedi%d: poc: using %s iobase 0x%lx\n", dev->minor,
+ board->name, iobase);
+
+ dev->board_name = board->name;
+
+ if (iobase == 0) {
+ printk(KERN_ERR "io base address required\n");
+ return -EINVAL;
+ }
+
+ iosize = board->iosize;
+ /* check if io addresses are available */
+ if (!request_region(iobase, iosize, "dac02")) {
+ printk(KERN_ERR "I/O port conflict: failed to allocate ports "
+ "0x%lx to 0x%lx\n", iobase, iobase + iosize - 1);
+ return -EIO;
+ }
+ dev->iobase = iobase;
+
+ ret = comedi_alloc_subdevices(dev, 1);
+ if (ret)
+ return ret;
+
+ if (alloc_private(dev, sizeof(unsigned int) * board->n_chan) < 0)
+ return -ENOMEM;
+
+ /* analog output subdevice */
+ s = dev->subdevices + 0;
+ s->type = board->type;
+ s->n_chan = board->n_chan;
+ s->maxdata = (1 << board->n_bits) - 1;
+ s->range_table = board->range;
+ s->insn_write = board->winsn;
+ s->insn_read = board->rinsn;
+ s->insn_bits = board->insnbits;
+ if (s->type == COMEDI_SUBD_AO || s->type == COMEDI_SUBD_DO)
+ s->subdev_flags = SDF_WRITABLE;
+
+ return 0;
}
-static void __exit driver_poc_cleanup_module(void)
+static void poc_detach(struct comedi_device *dev)
{
- comedi_driver_unregister(&driver_poc);
+ const struct boarddef_struct *board = comedi_board(dev);
+
+ if (dev->iobase)
+ release_region(dev->iobase, board->iosize);
}
-module_init(driver_poc_init_module);
-module_exit(driver_poc_cleanup_module);
+static const struct boarddef_struct boards[] = {
+ {
+ .name = "dac02",
+ .iosize = 8,
+ /* .setup = dac02_setup, */
+ .type = COMEDI_SUBD_AO,
+ .n_chan = 2,
+ .n_bits = 12,
+ .winsn = dac02_ao_winsn,
+ .rinsn = readback_insn,
+ .range = &range_unknown,
+ }, {
+ .name = "pcl733",
+ .iosize = 4,
+ .type = COMEDI_SUBD_DI,
+ .n_chan = 32,
+ .n_bits = 1,
+ .insnbits = pcl733_insn_bits,
+ .range = &range_digital,
+ }, {
+ .name = "pcl734",
+ .iosize = 4,
+ .type = COMEDI_SUBD_DO,
+ .n_chan = 32,
+ .n_bits = 1,
+ .insnbits = pcl734_insn_bits,
+ .range = &range_digital,
+ },
+};
+
+static struct comedi_driver poc_driver = {
+ .driver_name = "poc",
+ .module = THIS_MODULE,
+ .attach = poc_attach,
+ .detach = poc_detach,
+ .board_name = &boards[0].name,
+ .num_names = ARRAY_SIZE(boards),
+ .offset = sizeof(boards[0]),
+};
+module_comedi_driver(poc_driver);
MODULE_AUTHOR("Comedi http://www.comedi.org");
MODULE_DESCRIPTION("Comedi low-level driver");
diff --git a/drivers/staging/comedi/drivers/quatech_daqp_cs.c b/drivers/staging/comedi/drivers/quatech_daqp_cs.c
index e0bb73445dd8..a029147c9b69 100644
--- a/drivers/staging/comedi/drivers/quatech_daqp_cs.c
+++ b/drivers/staging/comedi/drivers/quatech_daqp_cs.c
@@ -181,7 +181,7 @@ static const struct comedi_lrange range_daqp_ao = { 1, {BIP_RANGE(5)} };
/* comedi interface code */
static int daqp_attach(struct comedi_device *dev, struct comedi_devconfig *it);
-static int daqp_detach(struct comedi_device *dev);
+static void daqp_detach(struct comedi_device *dev);
static struct comedi_driver driver_daqp = {
.driver_name = "quatech_daqp_cs",
.module = THIS_MODULE,
@@ -871,8 +871,8 @@ static int daqp_attach(struct comedi_device *dev, struct comedi_devconfig *it)
dev->iobase = local->link->resource[0]->start;
- ret = alloc_subdevices(dev, 4);
- if (ret < 0)
+ ret = comedi_alloc_subdevices(dev, 4);
+ if (ret)
return ret;
printk(KERN_INFO "comedi%d: attaching daqp%d (io 0x%04lx)\n",
@@ -922,15 +922,9 @@ static int daqp_attach(struct comedi_device *dev, struct comedi_devconfig *it)
return 1;
}
-/* daqp_detach (called from comedi_comdig) does nothing. If the PCMCIA
- * card is removed, daqp_cs_detach() is called by the pcmcia subsystem.
- */
-
-static int daqp_detach(struct comedi_device *dev)
+static void daqp_detach(struct comedi_device *dev)
{
- printk(KERN_INFO "comedi%d: detaching daqp\n", dev->minor);
-
- return 0;
+ /* Nothing to cleanup */
}
/*====================================================================
@@ -1010,8 +1004,6 @@ static void daqp_cs_detach(struct pcmcia_device *link)
{
struct local_info_t *dev = link->priv;
- dev_dbg(&link->dev, "daqp_cs_detach\n");
-
dev->stop = 1;
daqp_cs_release(link);
@@ -1019,7 +1011,7 @@ static void daqp_cs_detach(struct pcmcia_device *link)
dev_table[dev->table_index] = NULL;
kfree(dev);
-} /* daqp_cs_detach */
+}
static int daqp_pcmcia_config_loop(struct pcmcia_device *p_dev, void *priv_data)
{
diff --git a/drivers/staging/comedi/drivers/rtd520.c b/drivers/staging/comedi/drivers/rtd520.c
index 138441960506..112fdc3e9c69 100644
--- a/drivers/staging/comedi/drivers/rtd520.c
+++ b/drivers/staging/comedi/drivers/rtd520.c
@@ -105,7 +105,6 @@ Configuration options:
#include <linux/delay.h>
#include "../comedidev.h"
-#include "comedi_pci.h"
#define DRV_NAME "rtd520"
@@ -195,110 +194,79 @@ Configuration options:
======================================================================*/
/*
- The board has 3 input modes and the gains of 1,2,4,...32 (, 64, 128)
-*/
-static const struct comedi_lrange rtd_ai_7520_range = { 18, {
- /* +-5V input range gain steps */
- BIP_RANGE(5.0),
- BIP_RANGE(5.0 / 2),
- BIP_RANGE(5.0 / 4),
- BIP_RANGE(5.0 / 8),
- BIP_RANGE(5.0 /
- 16),
- BIP_RANGE(5.0 /
- 32),
- /* +-10V input range gain steps */
- BIP_RANGE(10.0),
- BIP_RANGE(10.0 /
- 2),
- BIP_RANGE(10.0 /
- 4),
- BIP_RANGE(10.0 /
- 8),
- BIP_RANGE(10.0 /
- 16),
- BIP_RANGE(10.0 /
- 32),
- /* +10V input range gain steps */
- UNI_RANGE(10.0),
- UNI_RANGE(10.0 /
- 2),
- UNI_RANGE(10.0 /
- 4),
- UNI_RANGE(10.0 /
- 8),
- UNI_RANGE(10.0 /
- 16),
- UNI_RANGE(10.0 /
- 32),
-
- }
+ * The board has 3 input modes and the gains of 1,2,4,...32 (, 64, 128)
+ */
+static const struct comedi_lrange rtd_ai_7520_range = {
+ 18, {
+ /* +-5V input range gain steps */
+ BIP_RANGE(5.0),
+ BIP_RANGE(5.0 / 2),
+ BIP_RANGE(5.0 / 4),
+ BIP_RANGE(5.0 / 8),
+ BIP_RANGE(5.0 / 16),
+ BIP_RANGE(5.0 / 32),
+ /* +-10V input range gain steps */
+ BIP_RANGE(10.0),
+ BIP_RANGE(10.0 / 2),
+ BIP_RANGE(10.0 / 4),
+ BIP_RANGE(10.0 / 8),
+ BIP_RANGE(10.0 / 16),
+ BIP_RANGE(10.0 / 32),
+ /* +10V input range gain steps */
+ UNI_RANGE(10.0),
+ UNI_RANGE(10.0 / 2),
+ UNI_RANGE(10.0 / 4),
+ UNI_RANGE(10.0 / 8),
+ UNI_RANGE(10.0 / 16),
+ UNI_RANGE(10.0 / 32),
+ }
};
/* PCI4520 has two more gains (6 more entries) */
-static const struct comedi_lrange rtd_ai_4520_range = { 24, {
- /* +-5V input range gain steps */
- BIP_RANGE(5.0),
- BIP_RANGE(5.0 / 2),
- BIP_RANGE(5.0 / 4),
- BIP_RANGE(5.0 / 8),
- BIP_RANGE(5.0 /
- 16),
- BIP_RANGE(5.0 /
- 32),
- BIP_RANGE(5.0 /
- 64),
- BIP_RANGE(5.0 /
- 128),
- /* +-10V input range gain steps */
- BIP_RANGE(10.0),
- BIP_RANGE(10.0 /
- 2),
- BIP_RANGE(10.0 /
- 4),
- BIP_RANGE(10.0 /
- 8),
- BIP_RANGE(10.0 /
- 16),
- BIP_RANGE(10.0 /
- 32),
- BIP_RANGE(10.0 /
- 64),
- BIP_RANGE(10.0 /
- 128),
- /* +10V input range gain steps */
- UNI_RANGE(10.0),
- UNI_RANGE(10.0 /
- 2),
- UNI_RANGE(10.0 /
- 4),
- UNI_RANGE(10.0 /
- 8),
- UNI_RANGE(10.0 /
- 16),
- UNI_RANGE(10.0 /
- 32),
- UNI_RANGE(10.0 /
- 64),
- UNI_RANGE(10.0 /
- 128),
- }
+static const struct comedi_lrange rtd_ai_4520_range = {
+ 24, {
+ /* +-5V input range gain steps */
+ BIP_RANGE(5.0),
+ BIP_RANGE(5.0 / 2),
+ BIP_RANGE(5.0 / 4),
+ BIP_RANGE(5.0 / 8),
+ BIP_RANGE(5.0 / 16),
+ BIP_RANGE(5.0 / 32),
+ BIP_RANGE(5.0 / 64),
+ BIP_RANGE(5.0 / 128),
+ /* +-10V input range gain steps */
+ BIP_RANGE(10.0),
+ BIP_RANGE(10.0 / 2),
+ BIP_RANGE(10.0 / 4),
+ BIP_RANGE(10.0 / 8),
+ BIP_RANGE(10.0 / 16),
+ BIP_RANGE(10.0 / 32),
+ BIP_RANGE(10.0 / 64),
+ BIP_RANGE(10.0 / 128),
+ /* +10V input range gain steps */
+ UNI_RANGE(10.0),
+ UNI_RANGE(10.0 / 2),
+ UNI_RANGE(10.0 / 4),
+ UNI_RANGE(10.0 / 8),
+ UNI_RANGE(10.0 / 16),
+ UNI_RANGE(10.0 / 32),
+ UNI_RANGE(10.0 / 64),
+ UNI_RANGE(10.0 / 128),
+ }
};
/* Table order matches range values */
-static const struct comedi_lrange rtd_ao_range = { 4, {
- RANGE(0, 5),
- RANGE(0, 10),
- RANGE(-5, 5),
- RANGE(-10, 10),
- }
+static const struct comedi_lrange rtd_ao_range = {
+ 4, {
+ UNI_RANGE(5),
+ UNI_RANGE(10),
+ BIP_RANGE(5),
+ BIP_RANGE(10),
+ }
};
-/*
- Board descriptions
- */
struct rtdBoard {
- const char *name; /* must be first */
+ const char *name;
int device_id;
int aiChans;
int aiBits;
@@ -309,57 +277,39 @@ struct rtdBoard {
static const struct rtdBoard rtd520Boards[] = {
{
- .name = "DM7520",
- .device_id = 0x7520,
- .aiChans = 16,
- .aiBits = 12,
- .aiMaxGain = 32,
- .range10Start = 6,
- .rangeUniStart = 12,
- },
- {
- .name = "PCI4520",
- .device_id = 0x4520,
- .aiChans = 16,
- .aiBits = 12,
- .aiMaxGain = 128,
- .range10Start = 8,
- .rangeUniStart = 16,
- },
-};
-
-static DEFINE_PCI_DEVICE_TABLE(rtd520_pci_table) = {
- { PCI_DEVICE(PCI_VENDOR_ID_RTD, 0x7520) },
- { PCI_DEVICE(PCI_VENDOR_ID_RTD, 0x4520) },
- { 0 }
+ .name = "DM7520",
+ .device_id = 0x7520,
+ .aiChans = 16,
+ .aiBits = 12,
+ .aiMaxGain = 32,
+ .range10Start = 6,
+ .rangeUniStart = 12,
+ }, {
+ .name = "PCI4520",
+ .device_id = 0x4520,
+ .aiChans = 16,
+ .aiBits = 12,
+ .aiMaxGain = 128,
+ .range10Start = 8,
+ .rangeUniStart = 16,
+ },
};
-MODULE_DEVICE_TABLE(pci, rtd520_pci_table);
-
-/*
- * Useful for shorthand access to the particular board structure
- */
-#define thisboard ((const struct rtdBoard *)dev->board_ptr)
-
/*
This structure is for data unique to this hardware driver.
This is also unique for each board in the system.
*/
struct rtdPrivate {
/* memory mapped board structures */
- void *las0;
- void *las1;
- void *lcfg;
+ void __iomem *las0;
+ void __iomem *las1;
+ void __iomem *lcfg;
unsigned long intCount; /* interrupt count */
long aiCount; /* total transfer size (samples) */
- int transCount; /* # to tranfer data. 0->1/2FIFO */
+ int transCount; /* # to transfer data. 0->1/2FIFO */
int flags; /* flag event modes */
- /* PCI device info */
- struct pci_dev *pci_dev;
- int got_regions; /* non-zero if PCI regions owned */
-
/* channel list info */
/* chanBipolar tracks whether a channel is bipolar (and needs +2048) */
unsigned char chanBipolar[RTD_MAX_CHANLIST / 8]; /* bit array */
@@ -377,8 +327,11 @@ struct rtdPrivate {
u8 utcCtrl[4]; /* crtl mode for 3 utc + read back */
u8 dioStatus; /* could be read back (dio0Ctrl) */
#ifdef USE_DMA
- /* Always DMA 1/2 FIFO. Buffer (dmaBuff?) is (at least) twice that size.
- After transferring, interrupt processes 1/2 FIFO and passes to comedi */
+ /*
+ * Always DMA 1/2 FIFO. Buffer (dmaBuff?) is (at least) twice that
+ * size. After transferring, interrupt processes 1/2 FIFO and
+ * passes to comedi
+ */
s16 dma0Offset; /* current processing offset (0, 1/2) */
uint16_t *dma0Buff[DMA_CHAIN_COUNT]; /* DMA buffers (for ADC) */
dma_addr_t dma0BuffPhysAddr[DMA_CHAIN_COUNT]; /* physical addresses */
@@ -405,780 +358,46 @@ struct rtdPrivate {
(((array)[(index)/8] &= ~(1 << ((index) & 0x7))))
/*
- * most drivers define the following macro to make it easy to
- * access the private structure.
- */
-#define devpriv ((struct rtdPrivate *)dev->private)
-
-/* Macros to access registers */
-
-/* Reset board */
-#define RtdResetBoard(dev) \
- writel(0, devpriv->las0+LAS0_BOARD_RESET)
-
-/* Reset channel gain table read pointer */
-#define RtdResetCGT(dev) \
- writel(0, devpriv->las0+LAS0_CGT_RESET)
-
-/* Reset channel gain table read and write pointers */
-#define RtdClearCGT(dev) \
- writel(0, devpriv->las0+LAS0_CGT_CLEAR)
-
-/* Reset channel gain table read and write pointers */
-#define RtdEnableCGT(dev, v) \
- writel((v > 0) ? 1 : 0, devpriv->las0+LAS0_CGT_ENABLE)
-
-/* Write channel gain table entry */
-#define RtdWriteCGTable(dev, v) \
- writel(v, devpriv->las0+LAS0_CGT_WRITE)
-
-/* Write Channel Gain Latch */
-#define RtdWriteCGLatch(dev, v) \
- writel(v, devpriv->las0+LAS0_CGL_WRITE)
-
-/* Reset ADC FIFO */
-#define RtdAdcClearFifo(dev) \
- writel(0, devpriv->las0+LAS0_ADC_FIFO_CLEAR)
-
-/* Set ADC start conversion source select (write only) */
-#define RtdAdcConversionSource(dev, v) \
- writel(v, devpriv->las0+LAS0_ADC_CONVERSION)
-
-/* Set burst start source select (write only) */
-#define RtdBurstStartSource(dev, v) \
- writel(v, devpriv->las0+LAS0_BURST_START)
-
-/* Set Pacer start source select (write only) */
-#define RtdPacerStartSource(dev, v) \
- writel(v, devpriv->las0+LAS0_PACER_START)
-
-/* Set Pacer stop source select (write only) */
-#define RtdPacerStopSource(dev, v) \
- writel(v, devpriv->las0+LAS0_PACER_STOP)
-
-/* Set Pacer clock source select (write only) 0=external 1=internal */
-#define RtdPacerClockSource(dev, v) \
- writel((v > 0) ? 1 : 0, devpriv->las0+LAS0_PACER_SELECT)
-
-/* Set sample counter source select (write only) */
-#define RtdAdcSampleCounterSource(dev, v) \
- writel(v, devpriv->las0+LAS0_ADC_SCNT_SRC)
-
-/* Set Pacer trigger mode select (write only) 0=single cycle, 1=repeat */
-#define RtdPacerTriggerMode(dev, v) \
- writel((v > 0) ? 1 : 0, devpriv->las0+LAS0_PACER_REPEAT)
-
-/* Set About counter stop enable (write only) */
-#define RtdAboutStopEnable(dev, v) \
- writel((v > 0) ? 1 : 0, devpriv->las0+LAS0_ACNT_STOP_ENABLE)
-
-/* Set external trigger polarity (write only) 0=positive edge, 1=negative */
-#define RtdTriggerPolarity(dev, v) \
- writel((v > 0) ? 1 : 0, devpriv->las0+LAS0_ETRG_POLARITY)
-
-/* Start single ADC conversion */
-#define RtdAdcStart(dev) \
- writew(0, devpriv->las0+LAS0_ADC)
-
-/* Read one ADC data value (12bit (with sign extend) as 16bit) */
-/* Note: matches what DMA would get. Actual value >> 3 */
-#define RtdAdcFifoGet(dev) \
- readw(devpriv->las1+LAS1_ADC_FIFO)
-
-/* Read two ADC data values (DOESN'T WORK) */
-#define RtdAdcFifoGet2(dev) \
- readl(devpriv->las1+LAS1_ADC_FIFO)
-
-/* FIFO status */
-#define RtdFifoStatus(dev) \
- readl(devpriv->las0+LAS0_ADC)
-
-/* pacer start/stop read=start, write=stop*/
-#define RtdPacerStart(dev) \
- readl(devpriv->las0+LAS0_PACER)
-#define RtdPacerStop(dev) \
- writel(0, devpriv->las0+LAS0_PACER)
-
-/* Interrupt status */
-#define RtdInterruptStatus(dev) \
- readw(devpriv->las0+LAS0_IT)
-
-/* Interrupt mask */
-#define RtdInterruptMask(dev, v) \
- writew((devpriv->intMask = (v)), devpriv->las0+LAS0_IT)
-
-/* Interrupt status clear (only bits set in mask) */
-#define RtdInterruptClear(dev) \
- readw(devpriv->las0+LAS0_CLEAR)
-
-/* Interrupt clear mask */
-#define RtdInterruptClearMask(dev, v) \
- writew((devpriv->intClearMask = (v)), devpriv->las0+LAS0_CLEAR)
-
-/* Interrupt overrun status */
-#define RtdInterruptOverrunStatus(dev) \
- readl(devpriv->las0+LAS0_OVERRUN)
-
-/* Interrupt overrun clear */
-#define RtdInterruptOverrunClear(dev) \
- writel(0, devpriv->las0+LAS0_OVERRUN)
-
-/* Pacer counter, 24bit */
-#define RtdPacerCount(dev) \
- readl(devpriv->las0+LAS0_PCLK)
-#define RtdPacerCounter(dev, v) \
- writel((v) & 0xffffff, devpriv->las0+LAS0_PCLK)
-
-/* Burst counter, 10bit */
-#define RtdBurstCount(dev) \
- readl(devpriv->las0+LAS0_BCLK)
-#define RtdBurstCounter(dev, v) \
- writel((v) & 0x3ff, devpriv->las0+LAS0_BCLK)
-
-/* Delay counter, 16bit */
-#define RtdDelayCount(dev) \
- readl(devpriv->las0+LAS0_DCLK)
-#define RtdDelayCounter(dev, v) \
- writel((v) & 0xffff, devpriv->las0+LAS0_DCLK)
-
-/* About counter, 16bit */
-#define RtdAboutCount(dev) \
- readl(devpriv->las0+LAS0_ACNT)
-#define RtdAboutCounter(dev, v) \
- writel((v) & 0xffff, devpriv->las0+LAS0_ACNT)
-
-/* ADC sample counter, 10bit */
-#define RtdAdcSampleCount(dev) \
- readl(devpriv->las0+LAS0_ADC_SCNT)
-#define RtdAdcSampleCounter(dev, v) \
- writel((v) & 0x3ff, devpriv->las0+LAS0_ADC_SCNT)
-
-/* User Timer/Counter (8254) */
-#define RtdUtcCounterGet(dev, n) \
- readb(devpriv->las0 \
- + ((n <= 0) ? LAS0_UTC0 : ((1 == n) ? LAS0_UTC1 : LAS0_UTC2)))
-
-#define RtdUtcCounterPut(dev, n, v) \
- writeb((v) & 0xff, devpriv->las0 \
- + ((n <= 0) ? LAS0_UTC0 : ((1 == n) ? LAS0_UTC1 : LAS0_UTC2)))
-
-/* Set UTC (8254) control byte */
-#define RtdUtcCtrlPut(dev, n, v) \
- writeb(devpriv->utcCtrl[(n) & 3] = (((n) & 3) << 6) | ((v) & 0x3f), \
- devpriv->las0 + LAS0_UTC_CTRL)
-
-/* Set UTCn clock source (write only) */
-#define RtdUtcClockSource(dev, n, v) \
- writew(v, devpriv->las0 \
- + ((n <= 0) ? LAS0_UTC0_CLOCK : \
- ((1 == n) ? LAS0_UTC1_CLOCK : LAS0_UTC2_CLOCK)))
-
-/* Set UTCn gate source (write only) */
-#define RtdUtcGateSource(dev, n, v) \
- writew(v, devpriv->las0 \
- + ((n <= 0) ? LAS0_UTC0_GATE : \
- ((1 == n) ? LAS0_UTC1_GATE : LAS0_UTC2_GATE)))
-
-/* User output N source select (write only) */
-#define RtdUsrOutSource(dev, n, v) \
- writel(v, devpriv->las0+((n <= 0) ? LAS0_UOUT0_SELECT : LAS0_UOUT1_SELECT))
-
-/* Digital IO */
-#define RtdDio0Read(dev) \
- (readw(devpriv->las0+LAS0_DIO0) & 0xff)
-#define RtdDio0Write(dev, v) \
- writew((v) & 0xff, devpriv->las0+LAS0_DIO0)
-
-#define RtdDio1Read(dev) \
- (readw(devpriv->las0+LAS0_DIO1) & 0xff)
-#define RtdDio1Write(dev, v) \
- writew((v) & 0xff, devpriv->las0+LAS0_DIO1)
-
-#define RtdDioStatusRead(dev) \
- (readw(devpriv->las0+LAS0_DIO_STATUS) & 0xff)
-#define RtdDioStatusWrite(dev, v) \
- writew((devpriv->dioStatus = (v)), devpriv->las0+LAS0_DIO_STATUS)
-
-#define RtdDio0CtrlRead(dev) \
- (readw(devpriv->las0+LAS0_DIO0_CTRL) & 0xff)
-#define RtdDio0CtrlWrite(dev, v) \
- writew((v) & 0xff, devpriv->las0+LAS0_DIO0_CTRL)
-
-/* Digital to Analog converter */
-/* Write one data value (sign + 12bit + marker bits) */
-/* Note: matches what DMA would put. Actual value << 3 */
-#define RtdDacFifoPut(dev, n, v) \
- writew((v), devpriv->las1 + (((n) == 0) ? LAS1_DAC1_FIFO : LAS1_DAC2_FIFO))
-
-/* Start single DAC conversion */
-#define RtdDacUpdate(dev, n) \
- writew(0, devpriv->las0 + (((n) == 0) ? LAS0_DAC1 : LAS0_DAC2))
-
-/* Start single DAC conversion on both DACs */
-#define RtdDacBothUpdate(dev) \
- writew(0, devpriv->las0+LAS0_DAC)
-
-/* Set DAC output type and range */
-#define RtdDacRange(dev, n, v) \
- writew((v) & 7, devpriv->las0 \
- +(((n) == 0) ? LAS0_DAC1_CTRL : LAS0_DAC2_CTRL))
-
-/* Reset DAC FIFO */
-#define RtdDacClearFifo(dev, n) \
- writel(0, devpriv->las0+(((n) == 0) ? LAS0_DAC1_RESET : LAS0_DAC2_RESET))
-
-/* Set source for DMA 0 (write only, shadow?) */
-#define RtdDma0Source(dev, n) \
- writel((n) & 0xf, devpriv->las0+LAS0_DMA0_SRC)
-
-/* Set source for DMA 1 (write only, shadow?) */
-#define RtdDma1Source(dev, n) \
- writel((n) & 0xf, devpriv->las0+LAS0_DMA1_SRC)
-
-/* Reset board state for DMA 0 */
-#define RtdDma0Reset(dev) \
- writel(0, devpriv->las0+LAS0_DMA0_RESET)
-
-/* Reset board state for DMA 1 */
-#define RtdDma1Reset(dev) \
- writel(0, devpriv->las0+LAS0_DMA1_SRC)
-
-/* PLX9080 interrupt mask and status */
-#define RtdPlxInterruptRead(dev) \
- readl(devpriv->lcfg+LCFG_ITCSR)
-#define RtdPlxInterruptWrite(dev, v) \
- writel(v, devpriv->lcfg+LCFG_ITCSR)
-
-/* Set mode for DMA 0 */
-#define RtdDma0Mode(dev, m) \
- writel((m), devpriv->lcfg+LCFG_DMAMODE0)
-
-/* Set PCI address for DMA 0 */
-#define RtdDma0PciAddr(dev, a) \
- writel((a), devpriv->lcfg+LCFG_DMAPADR0)
-
-/* Set local address for DMA 0 */
-#define RtdDma0LocalAddr(dev, a) \
- writel((a), devpriv->lcfg+LCFG_DMALADR0)
-
-/* Set byte count for DMA 0 */
-#define RtdDma0Count(dev, c) \
- writel((c), devpriv->lcfg+LCFG_DMASIZ0)
-
-/* Set next descriptor for DMA 0 */
-#define RtdDma0Next(dev, a) \
- writel((a), devpriv->lcfg+LCFG_DMADPR0)
-
-/* Set mode for DMA 1 */
-#define RtdDma1Mode(dev, m) \
- writel((m), devpriv->lcfg+LCFG_DMAMODE1)
-
-/* Set PCI address for DMA 1 */
-#define RtdDma1PciAddr(dev, a) \
- writel((a), devpriv->lcfg+LCFG_DMAADR1)
-
-/* Set local address for DMA 1 */
-#define RtdDma1LocalAddr(dev, a) \
- writel((a), devpriv->lcfg+LCFG_DMALADR1)
-
-/* Set byte count for DMA 1 */
-#define RtdDma1Count(dev, c) \
- writel((c), devpriv->lcfg+LCFG_DMASIZ1)
-
-/* Set next descriptor for DMA 1 */
-#define RtdDma1Next(dev, a) \
- writel((a), devpriv->lcfg+LCFG_DMADPR1)
-
-/* Set control for DMA 0 (write only, shadow?) */
-#define RtdDma0Control(dev, n) \
- writeb(devpriv->dma0Control = (n), devpriv->lcfg+LCFG_DMACSR0)
-
-/* Get status for DMA 0 */
-#define RtdDma0Status(dev) \
- readb(devpriv->lcfg+LCFG_DMACSR0)
-
-/* Set control for DMA 1 (write only, shadow?) */
-#define RtdDma1Control(dev, n) \
- writeb(devpriv->dma1Control = (n), devpriv->lcfg+LCFG_DMACSR1)
-
-/* Get status for DMA 1 */
-#define RtdDma1Status(dev) \
- readb(devpriv->lcfg+LCFG_DMACSR1)
-
-/*
- * The struct comedi_driver structure tells the Comedi core module
- * which functions to call to configure/deconfigure (attac/detach)
- * the board, and also about the kernel module that contains
- * the device code.
- */
-static int rtd_attach(struct comedi_device *dev, struct comedi_devconfig *it);
-static int rtd_detach(struct comedi_device *dev);
-
-static struct comedi_driver rtd520Driver = {
- .driver_name = DRV_NAME,
- .module = THIS_MODULE,
- .attach = rtd_attach,
- .detach = rtd_detach,
-};
-
-static int rtd_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data);
-static int rtd_ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data);
-static int rtd_ao_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data);
-static int rtd_dio_insn_bits(struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data);
-static int rtd_dio_insn_config(struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data);
-static int rtd_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
- struct comedi_cmd *cmd);
-static int rtd_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s);
-static int rtd_ai_cancel(struct comedi_device *dev, struct comedi_subdevice *s);
-/* static int rtd_ai_poll (struct comedi_device *dev,struct comedi_subdevice *s); */
-static int rtd_ns_to_timer(unsigned int *ns, int roundMode);
-static irqreturn_t rtd_interrupt(int irq, void *d);
-static int rtd520_probe_fifo_depth(struct comedi_device *dev);
-
-/*
- * Attach is called by the Comedi core to configure the driver
- * for a particular board. If you specified a board_name array
- * in the driver structure, dev->board_ptr contains that
- * address.
- */
-static int rtd_attach(struct comedi_device *dev, struct comedi_devconfig *it)
-{ /* board name and options flags */
- struct comedi_subdevice *s;
- struct pci_dev *pcidev;
- int ret;
- resource_size_t physLas0; /* configuration */
- resource_size_t physLas1; /* data area */
- resource_size_t physLcfg; /* PLX9080 */
-#ifdef USE_DMA
- int index;
-#endif
-
- printk(KERN_INFO "comedi%d: rtd520 attaching.\n", dev->minor);
-
-#if defined(CONFIG_COMEDI_DEBUG) && defined(USE_DMA)
- /* You can set this a load time: modprobe comedi comedi_debug=1 */
- if (0 == comedi_debug) /* force DMA debug printks */
- comedi_debug = 1;
-#endif
-
- /*
- * Allocate the private structure area. alloc_private() is a
- * convenient macro defined in comedidev.h.
- */
- if (alloc_private(dev, sizeof(struct rtdPrivate)) < 0)
- return -ENOMEM;
-
- /*
- * Probe the device to determine what device in the series it is.
- */
- for (pcidev = pci_get_device(PCI_VENDOR_ID_RTD, PCI_ANY_ID, NULL);
- pcidev != NULL;
- pcidev = pci_get_device(PCI_VENDOR_ID_RTD, PCI_ANY_ID, pcidev)) {
- int i;
-
- if (it->options[0] || it->options[1]) {
- if (pcidev->bus->number != it->options[0]
- || PCI_SLOT(pcidev->devfn) != it->options[1]) {
- continue;
- }
- }
- for (i = 0; i < ARRAY_SIZE(rtd520Boards); ++i) {
- if (pcidev->device == rtd520Boards[i].device_id) {
- dev->board_ptr = &rtd520Boards[i];
- break;
- }
- }
- if (dev->board_ptr)
- break; /* found one */
- }
- if (!pcidev) {
- if (it->options[0] && it->options[1]) {
- printk(KERN_INFO "No RTD card at bus=%d slot=%d.\n",
- it->options[0], it->options[1]);
- } else {
- printk(KERN_INFO "No RTD card found.\n");
- }
- return -EIO;
- }
- devpriv->pci_dev = pcidev;
- dev->board_name = thisboard->name;
-
- ret = comedi_pci_enable(pcidev, DRV_NAME);
- if (ret < 0) {
- printk(KERN_INFO "Failed to enable PCI device and request regions.\n");
- return ret;
- }
- devpriv->got_regions = 1;
-
- /*
- * Initialize base addresses
- */
- /* Get the physical address from PCI config */
- physLas0 = pci_resource_start(devpriv->pci_dev, LAS0_PCIINDEX);
- physLas1 = pci_resource_start(devpriv->pci_dev, LAS1_PCIINDEX);
- physLcfg = pci_resource_start(devpriv->pci_dev, LCFG_PCIINDEX);
- /* Now have the kernel map this into memory */
- /* ASSUME page aligned */
- devpriv->las0 = ioremap_nocache(physLas0, LAS0_PCISIZE);
- devpriv->las1 = ioremap_nocache(physLas1, LAS1_PCISIZE);
- devpriv->lcfg = ioremap_nocache(physLcfg, LCFG_PCISIZE);
-
- if (!devpriv->las0 || !devpriv->las1 || !devpriv->lcfg)
- return -ENOMEM;
-
-
- DPRINTK("%s: LAS0=%llx, LAS1=%llx, CFG=%llx.\n", dev->board_name,
- (unsigned long long)physLas0, (unsigned long long)physLas1,
- (unsigned long long)physLcfg);
- { /* The RTD driver does this */
- unsigned char pci_latency;
- u16 revision;
- /*uint32_t epld_version; */
-
- pci_read_config_word(devpriv->pci_dev, PCI_REVISION_ID,
- &revision);
- DPRINTK("%s: PCI revision %d.\n", dev->board_name, revision);
-
- pci_read_config_byte(devpriv->pci_dev,
- PCI_LATENCY_TIMER, &pci_latency);
- if (pci_latency < 32) {
- printk(KERN_INFO "%s: PCI latency changed from %d to %d\n",
- dev->board_name, pci_latency, 32);
- pci_write_config_byte(devpriv->pci_dev,
- PCI_LATENCY_TIMER, 32);
- } else {
- DPRINTK("rtd520: PCI latency = %d\n", pci_latency);
- }
-
- /* Undocumented EPLD version (doesn't match RTD driver results) */
- /*DPRINTK ("rtd520: Reading epld from %p\n",
- devpriv->las0+0);
- epld_version = readl (devpriv->las0+0);
- if ((epld_version & 0xF0) >> 4 == 0x0F) {
- DPRINTK("rtd520: pre-v8 EPLD. (%x)\n", epld_version);
- } else {
- DPRINTK("rtd520: EPLD version %x.\n", epld_version >> 4);
- } */
- }
-
- /* Show board configuration */
- printk(KERN_INFO "%s:", dev->board_name);
-
- /*
- * Allocate the subdevice structures. alloc_subdevice() is a
- * convenient macro defined in comedidev.h.
- */
- if (alloc_subdevices(dev, 4) < 0)
- return -ENOMEM;
-
-
- s = dev->subdevices + 0;
- dev->read_subdev = s;
- /* analog input subdevice */
- s->type = COMEDI_SUBD_AI;
- s->subdev_flags =
- SDF_READABLE | SDF_GROUND | SDF_COMMON | SDF_DIFF | SDF_CMD_READ;
- s->n_chan = thisboard->aiChans;
- s->maxdata = (1 << thisboard->aiBits) - 1;
- if (thisboard->aiMaxGain <= 32)
- s->range_table = &rtd_ai_7520_range;
- else
- s->range_table = &rtd_ai_4520_range;
-
- s->len_chanlist = RTD_MAX_CHANLIST; /* devpriv->fifoLen */
- s->insn_read = rtd_ai_rinsn;
- s->do_cmd = rtd_ai_cmd;
- s->do_cmdtest = rtd_ai_cmdtest;
- s->cancel = rtd_ai_cancel;
- /* s->poll = rtd_ai_poll; *//* not ready yet */
-
- s = dev->subdevices + 1;
- /* analog output subdevice */
- s->type = COMEDI_SUBD_AO;
- s->subdev_flags = SDF_WRITABLE;
- s->n_chan = 2;
- s->maxdata = (1 << thisboard->aiBits) - 1;
- s->range_table = &rtd_ao_range;
- s->insn_write = rtd_ao_winsn;
- s->insn_read = rtd_ao_rinsn;
-
- s = dev->subdevices + 2;
- /* digital i/o subdevice */
- s->type = COMEDI_SUBD_DIO;
- s->subdev_flags = SDF_READABLE | SDF_WRITABLE;
- /* we only support port 0 right now. Ignoring port 1 and user IO */
- s->n_chan = 8;
- s->maxdata = 1;
- s->range_table = &range_digital;
- s->insn_bits = rtd_dio_insn_bits;
- s->insn_config = rtd_dio_insn_config;
-
- /* timer/counter subdevices (not currently supported) */
- s = dev->subdevices + 3;
- s->type = COMEDI_SUBD_COUNTER;
- s->subdev_flags = SDF_READABLE | SDF_WRITABLE;
- s->n_chan = 3;
- s->maxdata = 0xffff;
-
- /* initialize board, per RTD spec */
- /* also, initialize shadow registers */
- RtdResetBoard(dev);
- udelay(100); /* needed? */
- RtdPlxInterruptWrite(dev, 0);
- RtdInterruptMask(dev, 0); /* and sets shadow */
- RtdInterruptClearMask(dev, ~0); /* and sets shadow */
- RtdInterruptClear(dev); /* clears bits set by mask */
- RtdInterruptOverrunClear(dev);
- RtdClearCGT(dev);
- RtdAdcClearFifo(dev);
- RtdDacClearFifo(dev, 0);
- RtdDacClearFifo(dev, 1);
- /* clear digital IO fifo */
- RtdDioStatusWrite(dev, 0); /* safe state, set shadow */
- RtdUtcCtrlPut(dev, 0, 0x30); /* safe state, set shadow */
- RtdUtcCtrlPut(dev, 1, 0x30); /* safe state, set shadow */
- RtdUtcCtrlPut(dev, 2, 0x30); /* safe state, set shadow */
- RtdUtcCtrlPut(dev, 3, 0); /* safe state, set shadow */
- /* TODO: set user out source ??? */
-
- /* check if our interrupt is available and get it */
- ret = request_irq(devpriv->pci_dev->irq, rtd_interrupt,
- IRQF_SHARED, DRV_NAME, dev);
-
- if (ret < 0) {
- printk("Could not get interrupt! (%u)\n",
- devpriv->pci_dev->irq);
- return ret;
- }
- dev->irq = devpriv->pci_dev->irq;
- printk(KERN_INFO "( irq=%u )", dev->irq);
-
- ret = rtd520_probe_fifo_depth(dev);
- if (ret < 0)
- return ret;
-
- devpriv->fifoLen = ret;
- printk("( fifoLen=%d )", devpriv->fifoLen);
-
-#ifdef USE_DMA
- if (dev->irq > 0) {
- printk("( DMA buff=%d )\n", DMA_CHAIN_COUNT);
- /* The PLX9080 has 2 DMA controllers, but there could be 4 sources:
- ADC, digital, DAC1, and DAC2. Since only the ADC supports cmd mode
- right now, this isn't an issue (yet) */
- devpriv->dma0Offset = 0;
-
- for (index = 0; index < DMA_CHAIN_COUNT; index++) {
- devpriv->dma0Buff[index] =
- pci_alloc_consistent(devpriv->pci_dev,
- sizeof(u16) *
- devpriv->fifoLen / 2,
- &devpriv->
- dma0BuffPhysAddr[index]);
- if (devpriv->dma0Buff[index] == NULL) {
- ret = -ENOMEM;
- goto rtd_attach_die_error;
- }
- /*DPRINTK ("buff[%d] @ %p virtual, %x PCI\n",
- index,
- devpriv->dma0Buff[index], devpriv->dma0BuffPhysAddr[index]); */
- }
-
- /* setup DMA descriptor ring (use cpu_to_le32 for byte ordering?) */
- devpriv->dma0Chain =
- pci_alloc_consistent(devpriv->pci_dev,
- sizeof(struct plx_dma_desc) *
- DMA_CHAIN_COUNT,
- &devpriv->dma0ChainPhysAddr);
- for (index = 0; index < DMA_CHAIN_COUNT; index++) {
- devpriv->dma0Chain[index].pci_start_addr =
- devpriv->dma0BuffPhysAddr[index];
- devpriv->dma0Chain[index].local_start_addr =
- DMALADDR_ADC;
- devpriv->dma0Chain[index].transfer_size =
- sizeof(u16) * devpriv->fifoLen / 2;
- devpriv->dma0Chain[index].next =
- (devpriv->dma0ChainPhysAddr + ((index +
- 1) %
- (DMA_CHAIN_COUNT))
- * sizeof(devpriv->dma0Chain[0]))
- | DMA_TRANSFER_BITS;
- /*DPRINTK ("ring[%d] @%lx PCI: %x, local: %x, N: 0x%x, next: %x\n",
- index,
- ((long)devpriv->dma0ChainPhysAddr
- + (index * sizeof(devpriv->dma0Chain[0]))),
- devpriv->dma0Chain[index].pci_start_addr,
- devpriv->dma0Chain[index].local_start_addr,
- devpriv->dma0Chain[index].transfer_size,
- devpriv->dma0Chain[index].next); */
- }
-
- if (devpriv->dma0Chain == NULL) {
- ret = -ENOMEM;
- goto rtd_attach_die_error;
- }
-
- RtdDma0Mode(dev, DMA_MODE_BITS);
- /* set DMA trigger source */
- RtdDma0Source(dev, DMAS_ADFIFO_HALF_FULL);
- } else {
- printk(KERN_INFO "( no IRQ->no DMA )");
- }
-#endif /* USE_DMA */
-
- if (dev->irq) { /* enable plx9080 interrupts */
- RtdPlxInterruptWrite(dev, ICS_PIE | ICS_PLIE);
- }
-
- printk("\ncomedi%d: rtd520 driver attached.\n", dev->minor);
-
- return 1;
+ Given a desired period and the clock period (both in ns),
+ return the proper counter value (divider-1).
+ Sets the original period to be the true value.
+ Note: you have to check if the value is larger than the counter range!
+*/
+static int rtd_ns_to_timer_base(unsigned int *nanosec, /* desired period (in ns) */
+ int round_mode, int base)
+{ /* clock period (in ns) */
+ int divider;
-#if 0
- /* hit an error, clean up memory and return ret */
-/* rtd_attach_die_error: */
-#ifdef USE_DMA
- for (index = 0; index < DMA_CHAIN_COUNT; index++) {
- if (NULL != devpriv->dma0Buff[index]) { /* free buffer memory */
- pci_free_consistent(devpriv->pci_dev,
- sizeof(u16) * devpriv->fifoLen / 2,
- devpriv->dma0Buff[index],
- devpriv->dma0BuffPhysAddr[index]);
- devpriv->dma0Buff[index] = NULL;
- }
- }
- if (NULL != devpriv->dma0Chain) {
- pci_free_consistent(devpriv->pci_dev,
- sizeof(struct plx_dma_desc)
- * DMA_CHAIN_COUNT,
- devpriv->dma0Chain,
- devpriv->dma0ChainPhysAddr);
- devpriv->dma0Chain = NULL;
- }
-#endif /* USE_DMA */
- /* subdevices and priv are freed by the core */
- if (dev->irq) {
- /* disable interrupt controller */
- RtdPlxInterruptWrite(dev, RtdPlxInterruptRead(dev)
- & ~(ICS_PLIE | ICS_DMA0_E | ICS_DMA1_E));
- free_irq(dev->irq, dev);
+ switch (round_mode) {
+ case TRIG_ROUND_NEAREST:
+ default:
+ divider = (*nanosec + base / 2) / base;
+ break;
+ case TRIG_ROUND_DOWN:
+ divider = (*nanosec) / base;
+ break;
+ case TRIG_ROUND_UP:
+ divider = (*nanosec + base - 1) / base;
+ break;
}
+ if (divider < 2)
+ divider = 2; /* min is divide by 2 */
- /* release all regions that were allocated */
- if (devpriv->las0)
- iounmap(devpriv->las0);
-
- if (devpriv->las1)
- iounmap(devpriv->las1);
-
- if (devpriv->lcfg)
- iounmap(devpriv->lcfg);
-
- if (devpriv->pci_dev)
- pci_dev_put(devpriv->pci_dev);
+ /* Note: we don't check for max, because different timers
+ have different ranges */
- return ret;
-#endif
+ *nanosec = base * divider;
+ return divider - 1; /* countdown is divisor+1 */
}
/*
- * _detach is called to deconfigure a device. It should deallocate
- * resources.
- * This function is also called when _attach() fails, so it should be
- * careful not to release resources that were not necessarily
- * allocated by _attach(). dev->private and dev->subdevices are
- * deallocated automatically by the core.
- */
-static int rtd_detach(struct comedi_device *dev)
+ Given a desired period (in ns),
+ return the proper counter value (divider-1) for the internal clock.
+ Sets the original period to be the true value.
+*/
+static int rtd_ns_to_timer(unsigned int *ns, int round_mode)
{
-#ifdef USE_DMA
- int index;
-#endif
-
- DPRINTK("comedi%d: rtd520: removing (%ld ints)\n",
- dev->minor, (devpriv ? devpriv->intCount : 0L));
- if (devpriv && devpriv->lcfg) {
- DPRINTK
- ("(int status 0x%x, overrun status 0x%x, fifo status 0x%x)...\n",
- 0xffff & RtdInterruptStatus(dev),
- 0xffff & RtdInterruptOverrunStatus(dev),
- (0xffff & RtdFifoStatus(dev)) ^ 0x6666);
- }
-
- if (devpriv) {
- /* Shut down any board ops by resetting it */
-#ifdef USE_DMA
- if (devpriv->lcfg) {
- RtdDma0Control(dev, 0); /* disable DMA */
- RtdDma1Control(dev, 0); /* disable DMA */
- RtdPlxInterruptWrite(dev, ICS_PIE | ICS_PLIE);
- }
-#endif /* USE_DMA */
- if (devpriv->las0) {
- RtdResetBoard(dev);
- RtdInterruptMask(dev, 0);
- RtdInterruptClearMask(dev, ~0);
- RtdInterruptClear(dev); /* clears bits set by mask */
- }
-#ifdef USE_DMA
- /* release DMA */
- for (index = 0; index < DMA_CHAIN_COUNT; index++) {
- if (NULL != devpriv->dma0Buff[index]) {
- pci_free_consistent(devpriv->pci_dev,
- sizeof(u16) *
- devpriv->fifoLen / 2,
- devpriv->dma0Buff[index],
- devpriv->
- dma0BuffPhysAddr[index]);
- devpriv->dma0Buff[index] = NULL;
- }
- }
- if (NULL != devpriv->dma0Chain) {
- pci_free_consistent(devpriv->pci_dev,
- sizeof(struct plx_dma_desc) *
- DMA_CHAIN_COUNT, devpriv->dma0Chain,
- devpriv->dma0ChainPhysAddr);
- devpriv->dma0Chain = NULL;
- }
-#endif /* USE_DMA */
-
- /* release IRQ */
- if (dev->irq) {
- /* disable interrupt controller */
- RtdPlxInterruptWrite(dev, RtdPlxInterruptRead(dev)
- & ~(ICS_PLIE | ICS_DMA0_E |
- ICS_DMA1_E));
- free_irq(dev->irq, dev);
- }
-
- /* release all regions that were allocated */
- if (devpriv->las0)
- iounmap(devpriv->las0);
-
- if (devpriv->las1)
- iounmap(devpriv->las1);
-
- if (devpriv->lcfg)
- iounmap(devpriv->lcfg);
-
- if (devpriv->pci_dev) {
- if (devpriv->got_regions)
- comedi_pci_disable(devpriv->pci_dev);
-
- pci_dev_put(devpriv->pci_dev);
- }
- }
-
- printk(KERN_INFO "comedi%d: rtd520: removed.\n", dev->minor);
-
- return 0;
+ return rtd_ns_to_timer_base(ns, round_mode, RTD_CLOCK_BASE);
}
/*
@@ -1187,6 +406,8 @@ static int rtd_detach(struct comedi_device *dev)
static unsigned short rtdConvertChanGain(struct comedi_device *dev,
unsigned int comediChan, int chanIndex)
{ /* index in channel list */
+ const struct rtdBoard *thisboard = comedi_board(dev);
+ struct rtdPrivate *devpriv = dev->private;
unsigned int chan, range, aref;
unsigned short r = 0;
@@ -1239,17 +460,21 @@ static unsigned short rtdConvertChanGain(struct comedi_device *dev,
static void rtd_load_channelgain_list(struct comedi_device *dev,
unsigned int n_chan, unsigned int *list)
{
+ struct rtdPrivate *devpriv = dev->private;
+
if (n_chan > 1) { /* setup channel gain table */
int ii;
- RtdClearCGT(dev);
- RtdEnableCGT(dev, 1); /* enable table */
+
+ writel(0, devpriv->las0 + LAS0_CGT_CLEAR);
+ writel(1, devpriv->las0 + LAS0_CGT_ENABLE);
for (ii = 0; ii < n_chan; ii++) {
- RtdWriteCGTable(dev, rtdConvertChanGain(dev, list[ii],
- ii));
+ writel(rtdConvertChanGain(dev, list[ii], ii),
+ devpriv->las0 + LAS0_CGT_WRITE);
}
} else { /* just use the channel gain latch */
- RtdEnableCGT(dev, 0); /* disable table, enable latch */
- RtdWriteCGLatch(dev, rtdConvertChanGain(dev, list[0], 0));
+ writel(0, devpriv->las0 + LAS0_CGT_ENABLE);
+ writel(rtdConvertChanGain(dev, list[0], 0),
+ devpriv->las0 + LAS0_CGL_WRITE);
}
}
@@ -1257,31 +482,34 @@ static void rtd_load_channelgain_list(struct comedi_device *dev,
empty status flag clears */
static int rtd520_probe_fifo_depth(struct comedi_device *dev)
{
+ struct rtdPrivate *devpriv = dev->private;
unsigned int chanspec = CR_PACK(0, 0, AREF_GROUND);
unsigned i;
static const unsigned limit = 0x2000;
unsigned fifo_size = 0;
- RtdAdcClearFifo(dev);
+ writel(0, devpriv->las0 + LAS0_ADC_FIFO_CLEAR);
rtd_load_channelgain_list(dev, 1, &chanspec);
- RtdAdcConversionSource(dev, 0); /* software */
+ /* ADC conversion trigger source: SOFTWARE */
+ writel(0, devpriv->las0 + LAS0_ADC_CONVERSION);
/* convert samples */
for (i = 0; i < limit; ++i) {
unsigned fifo_status;
/* trigger conversion */
- RtdAdcStart(dev);
+ writew(0, devpriv->las0 + LAS0_ADC);
udelay(1);
- fifo_status = RtdFifoStatus(dev);
+ fifo_status = readl(devpriv->las0 + LAS0_ADC);
if ((fifo_status & FS_ADC_HEMPTY) == 0) {
fifo_size = 2 * i;
break;
}
}
if (i == limit) {
- printk(KERN_INFO "\ncomedi: %s: failed to probe fifo size.\n", DRV_NAME);
+ printk(KERN_INFO "\ncomedi: %s: failed to probe fifo size.\n",
+ DRV_NAME);
return -EIO;
}
- RtdAdcClearFifo(dev);
+ writel(0, devpriv->las0 + LAS0_ADC_FIFO_CLEAR);
if (fifo_size != 0x400 && fifo_size != 0x2000) {
printk
(KERN_INFO "\ncomedi: %s: unexpected fifo size of %i, expected 1024 or 8192.\n",
@@ -1303,26 +531,27 @@ static int rtd_ai_rinsn(struct comedi_device *dev,
struct comedi_subdevice *s, struct comedi_insn *insn,
unsigned int *data)
{
+ struct rtdPrivate *devpriv = dev->private;
int n, ii;
int stat;
/* clear any old fifo data */
- RtdAdcClearFifo(dev);
+ writel(0, devpriv->las0 + LAS0_ADC_FIFO_CLEAR);
/* write channel to multiplexer and clear channel gain table */
rtd_load_channelgain_list(dev, 1, &insn->chanspec);
- /* set conversion source */
- RtdAdcConversionSource(dev, 0); /* software */
+ /* ADC conversion trigger source: SOFTWARE */
+ writel(0, devpriv->las0 + LAS0_ADC_CONVERSION);
/* convert n samples */
for (n = 0; n < insn->n; n++) {
s16 d;
/* trigger conversion */
- RtdAdcStart(dev);
+ writew(0, devpriv->las0 + LAS0_ADC);
for (ii = 0; ii < RTD_ADC_TIMEOUT; ++ii) {
- stat = RtdFifoStatus(dev);
+ stat = readl(devpriv->las0 + LAS0_ADC);
if (stat & FS_ADC_NOT_EMPTY) /* 1 -> not empty */
break;
WAIT_QUIETLY;
@@ -1335,7 +564,7 @@ static int rtd_ai_rinsn(struct comedi_device *dev,
}
/* read data */
- d = RtdAdcFifoGet(dev); /* get 2s comp value */
+ d = readw(devpriv->las1 + LAS1_ADC_FIFO);
/*printk ("rtd520: Got 0x%x after %d usec\n", d, ii+1); */
d = d >> 3; /* low 3 bits are marker lines */
if (CHAN_ARRAY_TEST(devpriv->chanBipolar, 0))
@@ -1358,6 +587,7 @@ static int rtd_ai_rinsn(struct comedi_device *dev,
static int ai_read_n(struct comedi_device *dev, struct comedi_subdevice *s,
int count)
{
+ struct rtdPrivate *devpriv = dev->private;
int ii;
for (ii = 0; ii < count; ii++) {
@@ -1365,22 +595,23 @@ static int ai_read_n(struct comedi_device *dev, struct comedi_subdevice *s,
s16 d;
if (0 == devpriv->aiCount) { /* done */
- d = RtdAdcFifoGet(dev); /* Read N and discard */
+ d = readw(devpriv->las1 + LAS1_ADC_FIFO);
continue;
}
#if 0
- if (0 == (RtdFifoStatus(dev) & FS_ADC_NOT_EMPTY)) { /* DEBUG */
+ if (!(readl(devpriv->las0 + LAS0_ADC) & FS_ADC_NOT_EMPTY)) {
DPRINTK("comedi: READ OOPS on %d of %d\n", ii + 1,
count);
break;
}
#endif
- d = RtdAdcFifoGet(dev); /* get 2s comp value */
+ d = readw(devpriv->las1 + LAS1_ADC_FIFO);
d = d >> 3; /* low 3 bits are marker lines */
- if (CHAN_ARRAY_TEST(devpriv->chanBipolar, s->async->cur_chan))
- sample = d + 2048; /* convert to comedi unsigned data */
- else
+ if (CHAN_ARRAY_TEST(devpriv->chanBipolar, s->async->cur_chan)) {
+ /* convert to comedi unsigned data */
+ sample = d + 2048;
+ } else
sample = d;
if (!comedi_buf_put(s->async, sample))
@@ -1397,18 +628,21 @@ static int ai_read_n(struct comedi_device *dev, struct comedi_subdevice *s,
*/
static int ai_read_dregs(struct comedi_device *dev, struct comedi_subdevice *s)
{
- while (RtdFifoStatus(dev) & FS_ADC_NOT_EMPTY) { /* 1 -> not empty */
+ struct rtdPrivate *devpriv = dev->private;
+
+ while (readl(devpriv->las0 + LAS0_ADC) & FS_ADC_NOT_EMPTY) {
short sample;
- s16 d = RtdAdcFifoGet(dev); /* get 2s comp value */
+ s16 d = readw(devpriv->las1 + LAS1_ADC_FIFO);
if (0 == devpriv->aiCount) { /* done */
continue; /* read rest */
}
d = d >> 3; /* low 3 bits are marker lines */
- if (CHAN_ARRAY_TEST(devpriv->chanBipolar, s->async->cur_chan))
- sample = d + 2048; /* convert to comedi unsigned data */
- else
+ if (CHAN_ARRAY_TEST(devpriv->chanBipolar, s->async->cur_chan)) {
+ /* convert to comedi unsigned data */
+ sample = d + 2048;
+ } else
sample = d;
if (!comedi_buf_put(s->async, sample))
@@ -1426,6 +660,7 @@ static int ai_read_dregs(struct comedi_device *dev, struct comedi_subdevice *s)
*/
void abort_dma(struct comedi_device *dev, unsigned int channel)
{ /* DMA channel 0, 1 */
+ struct rtdPrivate *devpriv = dev->private;
unsigned long dma_cs_addr; /* the control/status register */
uint8_t status;
unsigned int ii;
@@ -1484,6 +719,7 @@ abortDmaExit:
*/
static int ai_process_dma(struct comedi_device *dev, struct comedi_subdevice *s)
{
+ struct rtdPrivate *devpriv = dev->private;
int ii, n;
s16 *dp;
@@ -1525,7 +761,9 @@ static int ai_process_dma(struct comedi_device *dev, struct comedi_subdevice *s)
comedi_buf_memcpy_to(s->async, 0, dp, n);
comedi_buf_write_free(s->async, n);
- /* always at least 1 scan -- 1/2 FIFO is larger than our max scan list */
+ /*
+ * always at least 1 scan -- 1/2 FIFO is larger than our max scan list
+ */
s->async->events |= COMEDI_CB_BLOCK | COMEDI_CB_EOS;
if (++devpriv->dma0Offset >= DMA_CHAIN_COUNT) { /* next buffer */
@@ -1544,17 +782,19 @@ static int ai_process_dma(struct comedi_device *dev, struct comedi_subdevice *s)
static irqreturn_t rtd_interrupt(int irq, /* interrupt number (ignored) */
void *d)
{ /* our data *//* cpu context (ignored) */
- struct comedi_device *dev = d; /* must be called "dev" for devpriv */
+ struct comedi_device *dev = d;
+ struct comedi_subdevice *s = dev->subdevices + 0; /* analog in subdevice */
+ struct rtdPrivate *devpriv = dev->private;
+ u32 overrun;
u16 status;
u16 fifoStatus;
- struct comedi_subdevice *s = dev->subdevices + 0; /* analog in subdevice */
if (!dev->attached)
return IRQ_NONE;
devpriv->intCount++; /* DEBUG statistics */
- fifoStatus = RtdFifoStatus(dev);
+ fifoStatus = readl(devpriv->las0 + LAS0_ADC);
/* check for FIFO full, this automatically halts the ADC! */
if (!(fifoStatus & FS_ADC_NOT_FULL)) { /* 0 -> full */
DPRINTK("rtd520: FIFO full! fifo_status=0x%x\n", (fifoStatus ^ 0x6666) & 0x7777); /* should be all 0s */
@@ -1562,26 +802,26 @@ static irqreturn_t rtd_interrupt(int irq, /* interrupt number (ignored) */
}
#ifdef USE_DMA
if (devpriv->flags & DMA0_ACTIVE) { /* Check DMA */
- u32 istatus = RtdPlxInterruptRead(dev);
+ u32 istatus = readl(devpriv->lcfg + LCFG_ITCSR);
if (istatus & ICS_DMA0_A) {
if (ai_process_dma(dev, s) < 0) {
DPRINTK
("rtd520: comedi read buffer overflow (DMA) with %ld to go!\n",
devpriv->aiCount);
- RtdDma0Control(dev,
- (devpriv->dma0Control &
- ~PLX_DMA_START_BIT)
- | PLX_CLEAR_DMA_INTR_BIT);
+ devpriv->dma0Control &= ~PLX_DMA_START_BIT;
+ devpriv->dma0Control |= PLX_CLEAR_DMA_INTR_BIT;
+ writeb(devpriv->dma0Control,
+ devpriv->lcfg + LCFG_DMACSR0);
goto abortTransfer;
}
/*DPRINTK ("rtd520: DMA transfer: %ld to go, istatus %x\n",
devpriv->aiCount, istatus); */
- RtdDma0Control(dev,
- (devpriv->
- dma0Control & ~PLX_DMA_START_BIT)
- | PLX_CLEAR_DMA_INTR_BIT);
+ devpriv->dma0Control &= ~PLX_DMA_START_BIT;
+ devpriv->dma0Control |= PLX_CLEAR_DMA_INTR_BIT;
+ writeb(devpriv->dma0Control,
+ devpriv->lcfg + LCFG_DMACSR0);
if (0 == devpriv->aiCount) { /* counted down */
DPRINTK("rtd520: Samples Done (DMA).\n");
goto transferDone;
@@ -1594,7 +834,7 @@ static irqreturn_t rtd_interrupt(int irq, /* interrupt number (ignored) */
/* Fall through and check for other interrupt sources */
#endif /* USE_DMA */
- status = RtdInterruptStatus(dev);
+ status = readw(devpriv->las0 + LAS0_IT);
/* if interrupt was not caused by our board, or handled above */
if (0 == status)
return IRQ_HANDLED;
@@ -1644,33 +884,37 @@ static irqreturn_t rtd_interrupt(int irq, /* interrupt number (ignored) */
DPRINTK("rtd520: unknown interrupt source!\n");
}
- if (0xffff & RtdInterruptOverrunStatus(dev)) { /* interrupt overrun */
+ overrun = readl(devpriv->las0 + LAS0_OVERRUN) & 0xffff;
+ if (overrun) {
DPRINTK
("rtd520: Interrupt overrun with %ld to go! over_status=0x%x\n",
- devpriv->aiCount, 0xffff & RtdInterruptOverrunStatus(dev));
+ devpriv->aiCount, overrun);
goto abortTransfer;
}
/* clear the interrupt */
- RtdInterruptClearMask(dev, status);
- RtdInterruptClear(dev);
+ devpriv->intClearMask = status;
+ writew(devpriv->intClearMask, devpriv->las0 + LAS0_CLEAR);
+ readw(devpriv->las0 + LAS0_CLEAR);
return IRQ_HANDLED;
abortTransfer:
- RtdAdcClearFifo(dev); /* clears full flag */
+ writel(0, devpriv->las0 + LAS0_ADC_FIFO_CLEAR);
s->async->events |= COMEDI_CB_ERROR;
devpriv->aiCount = 0; /* stop and don't transfer any more */
/* fall into transferDone */
transferDone:
- RtdPacerStopSource(dev, 0); /* stop on SOFTWARE stop */
- RtdPacerStop(dev); /* Stop PACER */
- RtdAdcConversionSource(dev, 0); /* software trigger only */
- RtdInterruptMask(dev, 0); /* mask out SAMPLE */
+ /* pacer stop source: SOFTWARE */
+ writel(0, devpriv->las0 + LAS0_PACER_STOP);
+ writel(0, devpriv->las0 + LAS0_PACER); /* stop pacer */
+ writel(0, devpriv->las0 + LAS0_ADC_CONVERSION);
+ devpriv->intMask = 0;
+ writew(devpriv->intMask, devpriv->las0 + LAS0_IT);
#ifdef USE_DMA
if (devpriv->flags & DMA0_ACTIVE) {
- RtdPlxInterruptWrite(dev, /* disable any more interrupts */
- RtdPlxInterruptRead(dev) & ~ICS_DMA0_E);
+ writel(readl(devpriv->lcfg + LCFG_ITCSR) & ~ICS_DMA0_E,
+ devpriv->lcfg + LCFG_ITCSR);
abort_dma(dev, 0);
devpriv->flags &= ~DMA0_ACTIVE;
/* if Using DMA, then we should have read everything by now */
@@ -1682,7 +926,7 @@ transferDone:
#endif /* USE_DMA */
if (devpriv->aiCount > 0) { /* there shouldn't be anything left */
- fifoStatus = RtdFifoStatus(dev);
+ fifoStatus = readl(devpriv->las0 + LAS0_ADC);
DPRINTK("rtd520: Finishing up. %ld remain, fifoStat=%x\n", devpriv->aiCount, (fifoStatus ^ 0x6666) & 0x7777); /* should read all 0s */
ai_read_dregs(dev, s); /* read anything left in FIFO */
}
@@ -1691,15 +935,16 @@ transferDone:
comedi_event(dev, s);
/* clear the interrupt */
- status = RtdInterruptStatus(dev);
- RtdInterruptClearMask(dev, status);
- RtdInterruptClear(dev);
+ status = readw(devpriv->las0 + LAS0_IT);
+ devpriv->intClearMask = status;
+ writew(devpriv->intClearMask, devpriv->las0 + LAS0_CLEAR);
+ readw(devpriv->las0 + LAS0_CLEAR);
- fifoStatus = RtdFifoStatus(dev); /* DEBUG */
+ fifoStatus = readl(devpriv->las0 + LAS0_ADC);
+ overrun = readl(devpriv->las0 + LAS0_OVERRUN) & 0xffff;
DPRINTK
("rtd520: Acquisition complete. %ld ints, intStat=%x, overStat=%x\n",
- devpriv->intCount, status,
- 0xffff & RtdInterruptOverrunStatus(dev));
+ devpriv->intCount, status, overrun);
return IRQ_HANDLED;
}
@@ -1928,28 +1173,33 @@ static int rtd_ai_cmdtest(struct comedi_device *dev,
*/
static int rtd_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
{
+ struct rtdPrivate *devpriv = dev->private;
struct comedi_cmd *cmd = &s->async->cmd;
int timer;
/* stop anything currently running */
- RtdPacerStopSource(dev, 0); /* stop on SOFTWARE stop */
- RtdPacerStop(dev); /* make sure PACER is stopped */
- RtdAdcConversionSource(dev, 0); /* software trigger only */
- RtdInterruptMask(dev, 0);
+ /* pacer stop source: SOFTWARE */
+ writel(0, devpriv->las0 + LAS0_PACER_STOP);
+ writel(0, devpriv->las0 + LAS0_PACER); /* stop pacer */
+ writel(0, devpriv->las0 + LAS0_ADC_CONVERSION);
+ devpriv->intMask = 0;
+ writew(devpriv->intMask, devpriv->las0 + LAS0_IT);
#ifdef USE_DMA
if (devpriv->flags & DMA0_ACTIVE) { /* cancel anything running */
- RtdPlxInterruptWrite(dev, /* disable any more interrupts */
- RtdPlxInterruptRead(dev) & ~ICS_DMA0_E);
+ writel(readl(devpriv->lcfg + LCFG_ITCSR) & ~ICS_DMA0_E,
+ devpriv->lcfg + LCFG_ITCSR);
abort_dma(dev, 0);
devpriv->flags &= ~DMA0_ACTIVE;
- if (RtdPlxInterruptRead(dev) & ICS_DMA0_A) { /*clear pending int */
- RtdDma0Control(dev, PLX_CLEAR_DMA_INTR_BIT);
+ if (readl(devpriv->lcfg + LCFG_ITCSR) & ICS_DMA0_A) {
+ devpriv->dma0Control = PLX_CLEAR_DMA_INTR_BIT;
+ writeb(devpriv->dma0Control,
+ devpriv->lcfg + LCFG_DMACSR0);
}
}
- RtdDma0Reset(dev); /* reset onboard state */
+ writel(0, devpriv->las0 + LAS0_DMA0_RESET);
#endif /* USE_DMA */
- RtdAdcClearFifo(dev); /* clear any old data */
- RtdInterruptOverrunClear(dev);
+ writel(0, devpriv->las0 + LAS0_ADC_FIFO_CLEAR);
+ writel(0, devpriv->las0 + LAS0_OVERRUN);
devpriv->intCount = 0;
if (!dev->irq) { /* we need interrupts for this */
@@ -1964,15 +1214,20 @@ static int rtd_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
/* setup the common case and override if needed */
if (cmd->chanlist_len > 1) {
/*DPRINTK ("rtd520: Multi channel setup\n"); */
- RtdPacerStartSource(dev, 0); /* software triggers pacer */
- RtdBurstStartSource(dev, 1); /* PACER triggers burst */
- RtdAdcConversionSource(dev, 2); /* BURST triggers ADC */
+ /* pacer start source: SOFTWARE */
+ writel(0, devpriv->las0 + LAS0_PACER_START);
+ /* burst trigger source: PACER */
+ writel(1, devpriv->las0 + LAS0_BURST_START);
+ /* ADC conversion trigger source: BURST */
+ writel(2, devpriv->las0 + LAS0_ADC_CONVERSION);
} else { /* single channel */
/*DPRINTK ("rtd520: single channel setup\n"); */
- RtdPacerStartSource(dev, 0); /* software triggers pacer */
- RtdAdcConversionSource(dev, 1); /* PACER triggers ADC */
+ /* pacer start source: SOFTWARE */
+ writel(0, devpriv->las0 + LAS0_PACER_START);
+ /* ADC conversion trigger source: PACER */
+ writel(1, devpriv->las0 + LAS0_ADC_CONVERSION);
}
- RtdAboutCounter(dev, devpriv->fifoLen / 2 - 1); /* 1/2 FIFO */
+ writel((devpriv->fifoLen / 2 - 1) & 0xffff, devpriv->las0 + LAS0_ACNT);
if (TRIG_TIMER == cmd->scan_begin_src) {
/* scan_begin_arg is in nanoseconds */
@@ -1989,7 +1244,7 @@ static int rtd_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
(TRANS_TARGET_PERIOD * cmd->chanlist_len) /
cmd->scan_begin_arg;
if (devpriv->transCount < cmd->chanlist_len) {
- /* tranfer after each scan (and avoid 0) */
+ /* transfer after each scan (and avoid 0) */
devpriv->transCount = cmd->chanlist_len;
} else { /* make a multiple of scan length */
devpriv->transCount =
@@ -2005,20 +1260,23 @@ static int rtd_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
devpriv->transCount = 0;
devpriv->flags &= ~SEND_EOS;
} else {
- /* interrupt for each tranfer */
- RtdAboutCounter(dev, devpriv->transCount - 1);
+ /* interrupt for each transfer */
+ writel((devpriv->transCount - 1) & 0xffff,
+ devpriv->las0 + LAS0_ACNT);
}
DPRINTK
- ("rtd520: scanLen=%d tranferCount=%d fifoLen=%d\n scanTime(ns)=%d flags=0x%x\n",
+ ("rtd520: scanLen=%d transferCount=%d fifoLen=%d\n scanTime(ns)=%d flags=0x%x\n",
cmd->chanlist_len, devpriv->transCount, devpriv->fifoLen,
cmd->scan_begin_arg, devpriv->flags);
} else { /* unknown timing, just use 1/2 FIFO */
devpriv->transCount = 0;
devpriv->flags &= ~SEND_EOS;
}
- RtdPacerClockSource(dev, 1); /* use INTERNAL 8Mhz clock source */
- RtdAboutStopEnable(dev, 1); /* just interrupt, dont stop */
+ /* pacer clock source: INTERNAL 8MHz */
+ writel(1, devpriv->las0 + LAS0_PACER_SELECT);
+ /* just interrupt, don't stop */
+ writel(1, devpriv->las0 + LAS0_ACNT_STOP_ENABLE);
/* BUG??? these look like enumerated values, but they are bit fields */
@@ -2048,12 +1306,13 @@ static int rtd_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
TRIG_ROUND_NEAREST);
/* set PACER clock */
/*DPRINTK ("rtd520: loading %d into pacer\n", timer); */
- RtdPacerCounter(dev, timer);
+ writel(timer & 0xffffff, devpriv->las0 + LAS0_PCLK);
break;
case TRIG_EXT:
- RtdPacerStartSource(dev, 1); /* EXTERNALy trigger pacer */
+ /* pacer start source: EXTERNAL */
+ writel(1, devpriv->las0 + LAS0_PACER_START);
break;
default:
@@ -2069,13 +1328,14 @@ static int rtd_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
TRIG_ROUND_NEAREST);
/* setup BURST clock */
/*DPRINTK ("rtd520: loading %d into burst\n", timer); */
- RtdBurstCounter(dev, timer);
+ writel(timer & 0x3ff, devpriv->las0 + LAS0_BCLK);
}
break;
case TRIG_EXT: /* external */
- RtdBurstStartSource(dev, 2); /* EXTERNALy trigger burst */
+ /* burst trigger source: EXTERNAL */
+ writel(2, devpriv->las0 + LAS0_BURST_START);
break;
default:
@@ -2086,12 +1346,14 @@ static int rtd_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
/* This doesn't seem to work. There is no way to clear an interrupt
that the priority controller has queued! */
- RtdInterruptClearMask(dev, ~0); /* clear any existing flags */
- RtdInterruptClear(dev);
+ devpriv->intClearMask = ~0;
+ writew(devpriv->intClearMask, devpriv->las0 + LAS0_CLEAR);
+ readw(devpriv->las0 + LAS0_CLEAR);
/* TODO: allow multiple interrupt sources */
if (devpriv->transCount > 0) { /* transfer every N samples */
- RtdInterruptMask(dev, IRQM_ADC_ABOUT_CNT);
+ devpriv->intMask = IRQM_ADC_ABOUT_CNT;
+ writew(devpriv->intMask, devpriv->las0 + LAS0_IT);
DPRINTK("rtd520: Transferring every %d\n", devpriv->transCount);
} else { /* 1/2 FIFO transfers */
#ifdef USE_DMA
@@ -2099,27 +1361,32 @@ static int rtd_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
/* point to first transfer in ring */
devpriv->dma0Offset = 0;
- RtdDma0Mode(dev, DMA_MODE_BITS);
- RtdDma0Next(dev, /* point to first block */
- devpriv->dma0Chain[DMA_CHAIN_COUNT - 1].next);
- RtdDma0Source(dev, DMAS_ADFIFO_HALF_FULL); /* set DMA trigger source */
-
- RtdPlxInterruptWrite(dev, /* enable interrupt */
- RtdPlxInterruptRead(dev) | ICS_DMA0_E);
+ writel(DMA_MODE_BITS, devpriv->lcfg + LCFG_DMAMODE0);
+ /* point to first block */
+ writel(devpriv->dma0Chain[DMA_CHAIN_COUNT - 1].next,
+ devpriv->lcfg + LCFG_DMADPR0);
+ writel(DMAS_ADFIFO_HALF_FULL, devpriv->las0 + LAS0_DMA0_SRC);
+ writel(readl(devpriv->lcfg + LCFG_ITCSR) | ICS_DMA0_E,
+ devpriv->lcfg + LCFG_ITCSR);
/* Must be 2 steps. See PLX app note about "Starting a DMA transfer" */
- RtdDma0Control(dev, PLX_DMA_EN_BIT); /* enable DMA (clear INTR?) */
- RtdDma0Control(dev, PLX_DMA_EN_BIT | PLX_DMA_START_BIT); /*start DMA */
+ devpriv->dma0Control = PLX_DMA_EN_BIT;
+ writeb(devpriv->dma0Control,
+ devpriv->lcfg + LCFG_DMACSR0);
+ devpriv->dma0Control |= PLX_DMA_START_BIT;
+ writeb(devpriv->dma0Control,
+ devpriv->lcfg + LCFG_DMACSR0);
DPRINTK("rtd520: Using DMA0 transfers. plxInt %x RtdInt %x\n",
- RtdPlxInterruptRead(dev), devpriv->intMask);
+ readl(devpriv->lcfg + LCFG_ITCSR), devpriv->intMask);
#else /* USE_DMA */
- RtdInterruptMask(dev, IRQM_ADC_ABOUT_CNT);
+ devpriv->intMask = IRQM_ADC_ABOUT_CNT;
+ writew(devpriv->intMask, devpriv->las0 + LAS0_IT);
DPRINTK("rtd520: Transferring every 1/2 FIFO\n");
#endif /* USE_DMA */
}
/* BUG: start_src is ASSUMED to be TRIG_NOW */
/* BUG? it seems like things are running before the "start" */
- RtdPacerStart(dev); /* Start PACER */
+ readl(devpriv->las0 + LAS0_PACER); /* start pacer */
return 0;
}
@@ -2128,85 +1395,48 @@ static int rtd_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
*/
static int rtd_ai_cancel(struct comedi_device *dev, struct comedi_subdevice *s)
{
+ struct rtdPrivate *devpriv = dev->private;
+ u32 overrun;
u16 status;
- RtdPacerStopSource(dev, 0); /* stop on SOFTWARE stop */
- RtdPacerStop(dev); /* Stop PACER */
- RtdAdcConversionSource(dev, 0); /* software trigger only */
- RtdInterruptMask(dev, 0);
+ /* pacer stop source: SOFTWARE */
+ writel(0, devpriv->las0 + LAS0_PACER_STOP);
+ writel(0, devpriv->las0 + LAS0_PACER); /* stop pacer */
+ writel(0, devpriv->las0 + LAS0_ADC_CONVERSION);
+ devpriv->intMask = 0;
+ writew(devpriv->intMask, devpriv->las0 + LAS0_IT);
devpriv->aiCount = 0; /* stop and don't transfer any more */
#ifdef USE_DMA
if (devpriv->flags & DMA0_ACTIVE) {
- RtdPlxInterruptWrite(dev, /* disable any more interrupts */
- RtdPlxInterruptRead(dev) & ~ICS_DMA0_E);
+ writel(readl(devpriv->lcfg + LCFG_ITCSR) & ~ICS_DMA0_E,
+ devpriv->lcfg + LCFG_ITCSR);
abort_dma(dev, 0);
devpriv->flags &= ~DMA0_ACTIVE;
}
#endif /* USE_DMA */
- status = RtdInterruptStatus(dev);
+ status = readw(devpriv->las0 + LAS0_IT);
+ overrun = readl(devpriv->las0 + LAS0_OVERRUN) & 0xffff;
DPRINTK
("rtd520: Acquisition canceled. %ld ints, intStat=%x, overStat=%x\n",
- devpriv->intCount, status,
- 0xffff & RtdInterruptOverrunStatus(dev));
+ devpriv->intCount, status, overrun);
return 0;
}
/*
- Given a desired period and the clock period (both in ns),
- return the proper counter value (divider-1).
- Sets the original period to be the true value.
- Note: you have to check if the value is larger than the counter range!
-*/
-static int rtd_ns_to_timer_base(unsigned int *nanosec, /* desired period (in ns) */
- int round_mode, int base)
-{ /* clock period (in ns) */
- int divider;
-
- switch (round_mode) {
- case TRIG_ROUND_NEAREST:
- default:
- divider = (*nanosec + base / 2) / base;
- break;
- case TRIG_ROUND_DOWN:
- divider = (*nanosec) / base;
- break;
- case TRIG_ROUND_UP:
- divider = (*nanosec + base - 1) / base;
- break;
- }
- if (divider < 2)
- divider = 2; /* min is divide by 2 */
-
- /* Note: we don't check for max, because different timers
- have different ranges */
-
- *nanosec = base * divider;
- return divider - 1; /* countdown is divisor+1 */
-}
-
-/*
- Given a desired period (in ns),
- return the proper counter value (divider-1) for the internal clock.
- Sets the original period to be the true value.
-*/
-static int rtd_ns_to_timer(unsigned int *ns, int round_mode)
-{
- return rtd_ns_to_timer_base(ns, round_mode, RTD_CLOCK_BASE);
-}
-
-/*
Output one (or more) analog values to a single port as fast as possible.
*/
static int rtd_ao_winsn(struct comedi_device *dev,
struct comedi_subdevice *s, struct comedi_insn *insn,
unsigned int *data)
{
+ struct rtdPrivate *devpriv = dev->private;
int i;
int chan = CR_CHAN(insn->chanspec);
int range = CR_RANGE(insn->chanspec);
/* Configure the output range (table index matches the range values) */
- RtdDacRange(dev, chan, range);
+ writew(range & 7, devpriv->las0 +
+ ((chan == 0) ? LAS0_DAC1_CTRL : LAS0_DAC2_CTRL));
/* Writing a list of values to an AO channel is probably not
* very useful, but that's how the interface is defined. */
@@ -2230,13 +1460,14 @@ static int rtd_ao_winsn(struct comedi_device *dev,
chan, range, data[i], val);
/* a typical programming sequence */
- RtdDacFifoPut(dev, chan, val); /* put the value in */
- RtdDacUpdate(dev, chan); /* trigger the conversion */
+ writew(val, devpriv->las1 +
+ ((chan == 0) ? LAS1_DAC1_FIFO : LAS1_DAC2_FIFO));
+ writew(0, devpriv->las0 + ((chan == 0) ? LAS0_DAC1 : LAS0_DAC2));
devpriv->aoValue[chan] = data[i]; /* save for read back */
for (ii = 0; ii < RTD_DAC_TIMEOUT; ++ii) {
- stat = RtdFifoStatus(dev);
+ stat = readl(devpriv->las0 + LAS0_ADC);
/* 1 -> not empty */
if (stat & ((0 == chan) ? FS_DAC1_NOT_EMPTY :
FS_DAC2_NOT_EMPTY))
@@ -2261,6 +1492,7 @@ static int rtd_ao_rinsn(struct comedi_device *dev,
struct comedi_subdevice *s, struct comedi_insn *insn,
unsigned int *data)
{
+ struct rtdPrivate *devpriv = dev->private;
int i;
int chan = CR_CHAN(insn->chanspec);
@@ -2285,8 +1517,7 @@ static int rtd_dio_insn_bits(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
- if (insn->n != 2)
- return -EINVAL;
+ struct rtdPrivate *devpriv = dev->private;
/* The insn data is a mask in data[0] and the new data
* in data[1], each channel cooresponding to a bit. */
@@ -2295,15 +1526,15 @@ static int rtd_dio_insn_bits(struct comedi_device *dev,
s->state |= data[0] & data[1];
/* Write out the new digital output lines */
- RtdDio0Write(dev, s->state);
+ writew(s->state & 0xff, devpriv->las0 + LAS0_DIO0);
}
/* on return, data[1] contains the value of the digital
* input lines. */
- data[1] = RtdDio0Read(dev);
+ data[1] = readw(devpriv->las0 + LAS0_DIO0) & 0xff;
/*DPRINTK("rtd520:port_0 wrote: 0x%x read: 0x%x\n", s->state, data[1]); */
- return 2;
+ return insn->n;
}
/*
@@ -2313,6 +1544,7 @@ static int rtd_dio_insn_config(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
+ struct rtdPrivate *devpriv = dev->private;
int chan = CR_CHAN(insn->chanspec);
/* The input or output configuration of each digital line is
@@ -2337,9 +1569,11 @@ static int rtd_dio_insn_config(struct comedi_device *dev,
DPRINTK("rtd520: port_0_direction=0x%x (1 means out)\n", s->io_bits);
/* TODO support digital match interrupts and strobes */
- RtdDioStatusWrite(dev, 0x01); /* make Dio0Ctrl point to direction */
- RtdDio0CtrlWrite(dev, s->io_bits); /* set direction 1 means Out */
- RtdDioStatusWrite(dev, 0); /* make Dio0Ctrl clear interrupts */
+ devpriv->dioStatus = 0x01; /* set direction */
+ writew(devpriv->dioStatus, devpriv->las0 + LAS0_DIO_STATUS);
+ writew(s->io_bits & 0xff, devpriv->las0 + LAS0_DIO0_CTRL);
+ devpriv->dioStatus = 0x00; /* clear interrupts */
+ writew(devpriv->dioStatus, devpriv->las0 + LAS0_DIO_STATUS);
/* port1 can only be all input or all output */
@@ -2348,47 +1582,414 @@ static int rtd_dio_insn_config(struct comedi_device *dev,
return 1;
}
-/*
- * A convenient macro that defines init_module() and cleanup_module(),
- * as necessary.
- */
-static int __devinit rtd520Driver_pci_probe(struct pci_dev *dev,
- const struct pci_device_id *ent)
+static struct pci_dev *rtd_find_pci(struct comedi_device *dev,
+ struct comedi_devconfig *it)
{
- return comedi_pci_auto_config(dev, rtd520Driver.driver_name);
+ const struct rtdBoard *thisboard;
+ struct pci_dev *pcidev = NULL;
+ int bus = it->options[0];
+ int slot = it->options[1];
+ int i;
+
+ for_each_pci_dev(pcidev) {
+ if (pcidev->vendor != PCI_VENDOR_ID_RTD)
+ continue;
+ if (bus || slot) {
+ if (pcidev->bus->number != bus ||
+ PCI_SLOT(pcidev->devfn) != slot)
+ continue;
+ }
+ for (i = 0; i < ARRAY_SIZE(rtd520Boards); i++) {
+ thisboard = &rtd520Boards[i];
+ if (pcidev->device == thisboard->device_id) {
+ dev->board_ptr = thisboard;
+ return pcidev;
+ }
+ }
+ }
+ dev_warn(dev->class_dev,
+ "no supported board found! (req. bus/slot: %d/%d)\n",
+ bus, slot);
+ return NULL;
+}
+
+static int rtd_attach(struct comedi_device *dev, struct comedi_devconfig *it)
+{ /* board name and options flags */
+ const struct rtdBoard *thisboard;
+ struct rtdPrivate *devpriv;
+ struct pci_dev *pcidev;
+ struct comedi_subdevice *s;
+ int ret;
+ resource_size_t physLas1; /* data area */
+ resource_size_t physLcfg; /* PLX9080 */
+#ifdef USE_DMA
+ int index;
+#endif
+
+ printk(KERN_INFO "comedi%d: rtd520 attaching.\n", dev->minor);
+
+#if defined(CONFIG_COMEDI_DEBUG) && defined(USE_DMA)
+ /* You can set this a load time: modprobe comedi comedi_debug=1 */
+ if (0 == comedi_debug) /* force DMA debug printks */
+ comedi_debug = 1;
+#endif
+
+ /*
+ * Allocate the private structure area. alloc_private() is a
+ * convenient macro defined in comedidev.h.
+ */
+ if (alloc_private(dev, sizeof(struct rtdPrivate)) < 0)
+ return -ENOMEM;
+ devpriv = dev->private;
+
+ pcidev = rtd_find_pci(dev, it);
+ if (!pcidev)
+ return -EIO;
+ comedi_set_hw_dev(dev, &pcidev->dev);
+ thisboard = comedi_board(dev);
+
+ dev->board_name = thisboard->name;
+
+ ret = comedi_pci_enable(pcidev, DRV_NAME);
+ if (ret < 0) {
+ printk(KERN_INFO "Failed to enable PCI device and request regions.\n");
+ return ret;
+ }
+
+ /*
+ * Initialize base addresses
+ */
+ /* Get the physical address from PCI config */
+ dev->iobase = pci_resource_start(pcidev, LAS0_PCIINDEX);
+ physLas1 = pci_resource_start(pcidev, LAS1_PCIINDEX);
+ physLcfg = pci_resource_start(pcidev, LCFG_PCIINDEX);
+ /* Now have the kernel map this into memory */
+ /* ASSUME page aligned */
+ devpriv->las0 = ioremap_nocache(dev->iobase, LAS0_PCISIZE);
+ devpriv->las1 = ioremap_nocache(physLas1, LAS1_PCISIZE);
+ devpriv->lcfg = ioremap_nocache(physLcfg, LCFG_PCISIZE);
+
+ if (!devpriv->las0 || !devpriv->las1 || !devpriv->lcfg)
+ return -ENOMEM;
+
+ { /* The RTD driver does this */
+ unsigned char pci_latency;
+ u16 revision;
+ /*uint32_t epld_version; */
+
+ pci_read_config_word(pcidev, PCI_REVISION_ID,
+ &revision);
+ DPRINTK("%s: PCI revision %d.\n", dev->board_name, revision);
+
+ pci_read_config_byte(pcidev,
+ PCI_LATENCY_TIMER, &pci_latency);
+ if (pci_latency < 32) {
+ printk(KERN_INFO "%s: PCI latency changed from %d to %d\n",
+ dev->board_name, pci_latency, 32);
+ pci_write_config_byte(pcidev,
+ PCI_LATENCY_TIMER, 32);
+ } else {
+ DPRINTK("rtd520: PCI latency = %d\n", pci_latency);
+ }
+
+ /*
+ * Undocumented EPLD version (doesn't match RTD driver results)
+ */
+ /*DPRINTK ("rtd520: Reading epld from %p\n",
+ devpriv->las0+0);
+ epld_version = readl (devpriv->las0+0);
+ if ((epld_version & 0xF0) >> 4 == 0x0F) {
+ DPRINTK("rtd520: pre-v8 EPLD. (%x)\n", epld_version);
+ } else {
+ DPRINTK("rtd520: EPLD version %x.\n", epld_version >> 4);
+ } */
+ }
+
+ /* Show board configuration */
+ printk(KERN_INFO "%s:", dev->board_name);
+
+ ret = comedi_alloc_subdevices(dev, 4);
+ if (ret)
+ return ret;
+
+ s = dev->subdevices + 0;
+ dev->read_subdev = s;
+ /* analog input subdevice */
+ s->type = COMEDI_SUBD_AI;
+ s->subdev_flags =
+ SDF_READABLE | SDF_GROUND | SDF_COMMON | SDF_DIFF | SDF_CMD_READ;
+ s->n_chan = thisboard->aiChans;
+ s->maxdata = (1 << thisboard->aiBits) - 1;
+ if (thisboard->aiMaxGain <= 32)
+ s->range_table = &rtd_ai_7520_range;
+ else
+ s->range_table = &rtd_ai_4520_range;
+
+ s->len_chanlist = RTD_MAX_CHANLIST; /* devpriv->fifoLen */
+ s->insn_read = rtd_ai_rinsn;
+ s->do_cmd = rtd_ai_cmd;
+ s->do_cmdtest = rtd_ai_cmdtest;
+ s->cancel = rtd_ai_cancel;
+ /* s->poll = rtd_ai_poll; *//* not ready yet */
+
+ s = dev->subdevices + 1;
+ /* analog output subdevice */
+ s->type = COMEDI_SUBD_AO;
+ s->subdev_flags = SDF_WRITABLE;
+ s->n_chan = 2;
+ s->maxdata = (1 << thisboard->aiBits) - 1;
+ s->range_table = &rtd_ao_range;
+ s->insn_write = rtd_ao_winsn;
+ s->insn_read = rtd_ao_rinsn;
+
+ s = dev->subdevices + 2;
+ /* digital i/o subdevice */
+ s->type = COMEDI_SUBD_DIO;
+ s->subdev_flags = SDF_READABLE | SDF_WRITABLE;
+ /* we only support port 0 right now. Ignoring port 1 and user IO */
+ s->n_chan = 8;
+ s->maxdata = 1;
+ s->range_table = &range_digital;
+ s->insn_bits = rtd_dio_insn_bits;
+ s->insn_config = rtd_dio_insn_config;
+
+ /* timer/counter subdevices (not currently supported) */
+ s = dev->subdevices + 3;
+ s->type = COMEDI_SUBD_COUNTER;
+ s->subdev_flags = SDF_READABLE | SDF_WRITABLE;
+ s->n_chan = 3;
+ s->maxdata = 0xffff;
+
+ /* initialize board, per RTD spec */
+ /* also, initialize shadow registers */
+ writel(0, devpriv->las0 + LAS0_BOARD_RESET);
+ udelay(100); /* needed? */
+ writel(0, devpriv->lcfg + LCFG_ITCSR);
+ devpriv->intMask = 0;
+ writew(devpriv->intMask, devpriv->las0 + LAS0_IT);
+ devpriv->intClearMask = ~0;
+ writew(devpriv->intClearMask, devpriv->las0 + LAS0_CLEAR);
+ readw(devpriv->las0 + LAS0_CLEAR);
+ writel(0, devpriv->las0 + LAS0_OVERRUN);
+ writel(0, devpriv->las0 + LAS0_CGT_CLEAR);
+ writel(0, devpriv->las0 + LAS0_ADC_FIFO_CLEAR);
+ writel(0, devpriv->las0 + LAS0_DAC1_RESET);
+ writel(0, devpriv->las0 + LAS0_DAC2_RESET);
+ /* clear digital IO fifo */
+ devpriv->dioStatus = 0;
+ writew(devpriv->dioStatus, devpriv->las0 + LAS0_DIO_STATUS);
+ devpriv->utcCtrl[0] = (0 << 6) | 0x30;
+ devpriv->utcCtrl[1] = (1 << 6) | 0x30;
+ devpriv->utcCtrl[2] = (2 << 6) | 0x30;
+ devpriv->utcCtrl[3] = (3 << 6) | 0x00;
+ writeb(devpriv->utcCtrl[0], devpriv->las0 + LAS0_UTC_CTRL);
+ writeb(devpriv->utcCtrl[1], devpriv->las0 + LAS0_UTC_CTRL);
+ writeb(devpriv->utcCtrl[2], devpriv->las0 + LAS0_UTC_CTRL);
+ writeb(devpriv->utcCtrl[3], devpriv->las0 + LAS0_UTC_CTRL);
+ /* TODO: set user out source ??? */
+
+ /* check if our interrupt is available and get it */
+ ret = request_irq(pcidev->irq, rtd_interrupt,
+ IRQF_SHARED, DRV_NAME, dev);
+
+ if (ret < 0) {
+ printk("Could not get interrupt! (%u)\n",
+ pcidev->irq);
+ return ret;
+ }
+ dev->irq = pcidev->irq;
+ printk(KERN_INFO "( irq=%u )", dev->irq);
+
+ ret = rtd520_probe_fifo_depth(dev);
+ if (ret < 0)
+ return ret;
+
+ devpriv->fifoLen = ret;
+ printk("( fifoLen=%d )", devpriv->fifoLen);
+
+#ifdef USE_DMA
+ if (dev->irq > 0) {
+ printk("( DMA buff=%d )\n", DMA_CHAIN_COUNT);
+ /*
+ * The PLX9080 has 2 DMA controllers, but there could be
+ * 4 sources: ADC, digital, DAC1, and DAC2. Since only the
+ * ADC supports cmd mode right now, this isn't an issue (yet)
+ */
+ devpriv->dma0Offset = 0;
+
+ for (index = 0; index < DMA_CHAIN_COUNT; index++) {
+ devpriv->dma0Buff[index] =
+ pci_alloc_consistent(pcidev,
+ sizeof(u16) *
+ devpriv->fifoLen / 2,
+ &devpriv->
+ dma0BuffPhysAddr[index]);
+ if (devpriv->dma0Buff[index] == NULL) {
+ ret = -ENOMEM;
+ goto rtd_attach_die_error;
+ }
+ /*DPRINTK ("buff[%d] @ %p virtual, %x PCI\n",
+ index,
+ devpriv->dma0Buff[index],
+ devpriv->dma0BuffPhysAddr[index]); */
+ }
+
+ /*
+ * setup DMA descriptor ring (use cpu_to_le32 for byte
+ * ordering?)
+ */
+ devpriv->dma0Chain =
+ pci_alloc_consistent(pcidev,
+ sizeof(struct plx_dma_desc) *
+ DMA_CHAIN_COUNT,
+ &devpriv->dma0ChainPhysAddr);
+ for (index = 0; index < DMA_CHAIN_COUNT; index++) {
+ devpriv->dma0Chain[index].pci_start_addr =
+ devpriv->dma0BuffPhysAddr[index];
+ devpriv->dma0Chain[index].local_start_addr =
+ DMALADDR_ADC;
+ devpriv->dma0Chain[index].transfer_size =
+ sizeof(u16) * devpriv->fifoLen / 2;
+ devpriv->dma0Chain[index].next =
+ (devpriv->dma0ChainPhysAddr + ((index +
+ 1) %
+ (DMA_CHAIN_COUNT))
+ * sizeof(devpriv->dma0Chain[0]))
+ | DMA_TRANSFER_BITS;
+ /*DPRINTK ("ring[%d] @%lx PCI: %x, local: %x, N: 0x%x, next: %x\n",
+ index,
+ ((long)devpriv->dma0ChainPhysAddr
+ + (index * sizeof(devpriv->dma0Chain[0]))),
+ devpriv->dma0Chain[index].pci_start_addr,
+ devpriv->dma0Chain[index].local_start_addr,
+ devpriv->dma0Chain[index].transfer_size,
+ devpriv->dma0Chain[index].next); */
+ }
+
+ if (devpriv->dma0Chain == NULL) {
+ ret = -ENOMEM;
+ goto rtd_attach_die_error;
+ }
+
+ writel(DMA_MODE_BITS, devpriv->lcfg + LCFG_DMAMODE0);
+ /* set DMA trigger source */
+ writel(DMAS_ADFIFO_HALF_FULL, devpriv->las0 + LAS0_DMA0_SRC);
+ } else {
+ printk(KERN_INFO "( no IRQ->no DMA )");
+ }
+#endif /* USE_DMA */
+
+ if (dev->irq)
+ writel(ICS_PIE | ICS_PLIE, devpriv->lcfg + LCFG_ITCSR);
+
+ printk("\ncomedi%d: rtd520 driver attached.\n", dev->minor);
+
+ return 1;
}
-static void __devexit rtd520Driver_pci_remove(struct pci_dev *dev)
+static void rtd_detach(struct comedi_device *dev)
{
- comedi_pci_auto_unconfig(dev);
+ struct rtdPrivate *devpriv = dev->private;
+ struct pci_dev *pcidev = comedi_to_pci_dev(dev);
+#ifdef USE_DMA
+ int index;
+#endif
+
+ if (devpriv) {
+ /* Shut down any board ops by resetting it */
+#ifdef USE_DMA
+ if (devpriv->lcfg) {
+ devpriv->dma0Control = 0;
+ devpriv->dma1Control = 0;
+ writeb(devpriv->dma0Control,
+ devpriv->lcfg + LCFG_DMACSR0);
+ writeb(devpriv->dma1Control,
+ devpriv->lcfg + LCFG_DMACSR1);
+ writel(ICS_PIE | ICS_PLIE, devpriv->lcfg + LCFG_ITCSR);
+ }
+#endif /* USE_DMA */
+ if (devpriv->las0) {
+ writel(0, devpriv->las0 + LAS0_BOARD_RESET);
+ devpriv->intMask = 0;
+ writew(devpriv->intMask, devpriv->las0 + LAS0_IT);
+ devpriv->intClearMask = ~0;
+ writew(devpriv->intClearMask,
+ devpriv->las0 + LAS0_CLEAR);
+ readw(devpriv->las0 + LAS0_CLEAR);
+ }
+#ifdef USE_DMA
+ /* release DMA */
+ for (index = 0; index < DMA_CHAIN_COUNT; index++) {
+ if (NULL != devpriv->dma0Buff[index]) {
+ pci_free_consistent(pcidev,
+ sizeof(u16) *
+ devpriv->fifoLen / 2,
+ devpriv->dma0Buff[index],
+ devpriv->
+ dma0BuffPhysAddr[index]);
+ devpriv->dma0Buff[index] = NULL;
+ }
+ }
+ if (NULL != devpriv->dma0Chain) {
+ pci_free_consistent(pcidev,
+ sizeof(struct plx_dma_desc) *
+ DMA_CHAIN_COUNT, devpriv->dma0Chain,
+ devpriv->dma0ChainPhysAddr);
+ devpriv->dma0Chain = NULL;
+ }
+#endif /* USE_DMA */
+ if (dev->irq) {
+ writel(readl(devpriv->lcfg + LCFG_ITCSR) &
+ ~(ICS_PLIE | ICS_DMA0_E | ICS_DMA1_E),
+ devpriv->lcfg + LCFG_ITCSR);
+ free_irq(dev->irq, dev);
+ }
+ if (devpriv->las0)
+ iounmap(devpriv->las0);
+ if (devpriv->las1)
+ iounmap(devpriv->las1);
+ if (devpriv->lcfg)
+ iounmap(devpriv->lcfg);
+ }
+ if (pcidev) {
+ if (dev->iobase)
+ comedi_pci_disable(pcidev);
+ pci_dev_put(pcidev);
+ }
}
-static struct pci_driver rtd520Driver_pci_driver = {
- .id_table = rtd520_pci_table,
- .probe = &rtd520Driver_pci_probe,
- .remove = __devexit_p(&rtd520Driver_pci_remove)
+static struct comedi_driver rtd520_driver = {
+ .driver_name = "rtd520",
+ .module = THIS_MODULE,
+ .attach = rtd_attach,
+ .detach = rtd_detach,
};
-static int __init rtd520Driver_init_module(void)
+static int __devinit rtd520_pci_probe(struct pci_dev *dev,
+ const struct pci_device_id *ent)
{
- int retval;
-
- retval = comedi_driver_register(&rtd520Driver);
- if (retval < 0)
- return retval;
-
- rtd520Driver_pci_driver.name = (char *)rtd520Driver.driver_name;
- return pci_register_driver(&rtd520Driver_pci_driver);
+ return comedi_pci_auto_config(dev, &rtd520_driver);
}
-static void __exit rtd520Driver_cleanup_module(void)
+static void __devexit rtd520_pci_remove(struct pci_dev *dev)
{
- pci_unregister_driver(&rtd520Driver_pci_driver);
- comedi_driver_unregister(&rtd520Driver);
+ comedi_pci_auto_unconfig(dev);
}
-module_init(rtd520Driver_init_module);
-module_exit(rtd520Driver_cleanup_module);
+static DEFINE_PCI_DEVICE_TABLE(rtd520_pci_table) = {
+ { PCI_DEVICE(PCI_VENDOR_ID_RTD, 0x7520) },
+ { PCI_DEVICE(PCI_VENDOR_ID_RTD, 0x4520) },
+ { 0 }
+};
+MODULE_DEVICE_TABLE(pci, rtd520_pci_table);
+
+static struct pci_driver rtd520_pci_driver = {
+ .name = "rtd520",
+ .id_table = rtd520_pci_table,
+ .probe = rtd520_pci_probe,
+ .remove = __devexit_p(rtd520_pci_remove),
+};
+module_comedi_pci_driver(rtd520_driver, rtd520_pci_driver);
MODULE_AUTHOR("Comedi http://www.comedi.org");
MODULE_DESCRIPTION("Comedi low-level driver");
diff --git a/drivers/staging/comedi/drivers/rti800.c b/drivers/staging/comedi/drivers/rti800.c
index 72042b818310..f7fa940d9783 100644
--- a/drivers/staging/comedi/drivers/rti800.c
+++ b/drivers/staging/comedi/drivers/rti800.c
@@ -138,39 +138,6 @@ struct rti800_board {
int has_ao;
};
-static const struct rti800_board boardtypes[] = {
- {"rti800", 0},
- {"rti815", 1},
-};
-
-#define this_board ((const struct rti800_board *)dev->board_ptr)
-
-static int rti800_attach(struct comedi_device *dev,
- struct comedi_devconfig *it);
-static int rti800_detach(struct comedi_device *dev);
-static struct comedi_driver driver_rti800 = {
- .driver_name = "rti800",
- .module = THIS_MODULE,
- .attach = rti800_attach,
- .detach = rti800_detach,
- .num_names = ARRAY_SIZE(boardtypes),
- .board_name = &boardtypes[0].name,
- .offset = sizeof(struct rti800_board),
-};
-
-static int __init driver_rti800_init_module(void)
-{
- return comedi_driver_register(&driver_rti800);
-}
-
-static void __exit driver_rti800_cleanup_module(void)
-{
- comedi_driver_unregister(&driver_rti800);
-}
-
-module_init(driver_rti800_init_module);
-module_exit(driver_rti800_cleanup_module);
-
static irqreturn_t rti800_interrupt(int irq, void *dev);
struct rti800_private {
@@ -296,19 +263,14 @@ static int rti800_di_insn_bits(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
- if (insn->n != 2)
- return -EINVAL;
data[1] = inb(dev->iobase + RTI800_DI);
- return 2;
+ return insn->n;
}
static int rti800_do_insn_bits(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
- if (insn->n != 2)
- return -EINVAL;
-
if (data[0]) {
s->state &= ~data[0];
s->state |= data[0] & data[1];
@@ -318,7 +280,7 @@ static int rti800_do_insn_bits(struct comedi_device *dev,
data[1] = s->state;
- return 2;
+ return insn->n;
}
/*
@@ -340,6 +302,7 @@ static int rti800_do_insn_bits(struct comedi_device *dev,
static int rti800_attach(struct comedi_device *dev, struct comedi_devconfig *it)
{
+ const struct rti800_board *board = comedi_board(dev);
unsigned int irq;
unsigned long iobase;
int ret;
@@ -378,10 +341,10 @@ static int rti800_attach(struct comedi_device *dev, struct comedi_devconfig *it)
printk(KERN_INFO "( no irq )\n");
}
- dev->board_name = this_board->name;
+ dev->board_name = board->name;
- ret = alloc_subdevices(dev, 4);
- if (ret < 0)
+ ret = comedi_alloc_subdevices(dev, 4);
+ if (ret)
return ret;
ret = alloc_private(dev, sizeof(struct rti800_private));
@@ -417,7 +380,7 @@ static int rti800_attach(struct comedi_device *dev, struct comedi_devconfig *it)
}
s++;
- if (this_board->has_ao) {
+ if (board->has_ao) {
/* ao subdevice (only on rti815) */
s->type = COMEDI_SUBD_AO;
s->subdev_flags = SDF_WRITABLE;
@@ -474,19 +437,30 @@ static int rti800_attach(struct comedi_device *dev, struct comedi_devconfig *it)
return 0;
}
-static int rti800_detach(struct comedi_device *dev)
+static void rti800_detach(struct comedi_device *dev)
{
- printk(KERN_INFO "comedi%d: rti800: remove\n", dev->minor);
-
if (dev->iobase)
release_region(dev->iobase, RTI800_SIZE);
-
if (dev->irq)
free_irq(dev->irq, dev);
-
- return 0;
}
+static const struct rti800_board boardtypes[] = {
+ { "rti800", 0 },
+ { "rti815", 1 },
+};
+
+static struct comedi_driver rti800_driver = {
+ .driver_name = "rti800",
+ .module = THIS_MODULE,
+ .attach = rti800_attach,
+ .detach = rti800_detach,
+ .num_names = ARRAY_SIZE(boardtypes),
+ .board_name = &boardtypes[0].name,
+ .offset = sizeof(struct rti800_board),
+};
+module_comedi_driver(rti800_driver);
+
MODULE_AUTHOR("Comedi http://www.comedi.org");
MODULE_DESCRIPTION("Comedi low-level driver");
MODULE_LICENSE("GPL");
diff --git a/drivers/staging/comedi/drivers/rti802.c b/drivers/staging/comedi/drivers/rti802.c
index f59cb11590f6..fc16508181d4 100644
--- a/drivers/staging/comedi/drivers/rti802.c
+++ b/drivers/staging/comedi/drivers/rti802.c
@@ -47,29 +47,6 @@ Configuration Options:
#define RTI802_DATALOW 1
#define RTI802_DATAHIGH 2
-static int rti802_attach(struct comedi_device *dev,
- struct comedi_devconfig *it);
-static int rti802_detach(struct comedi_device *dev);
-static struct comedi_driver driver_rti802 = {
- .driver_name = "rti802",
- .module = THIS_MODULE,
- .attach = rti802_attach,
- .detach = rti802_detach,
-};
-
-static int __init driver_rti802_init_module(void)
-{
- return comedi_driver_register(&driver_rti802);
-}
-
-static void __exit driver_rti802_cleanup_module(void)
-{
- comedi_driver_unregister(&driver_rti802);
-}
-
-module_init(driver_rti802_init_module);
-module_exit(driver_rti802_cleanup_module);
-
struct rti802_private {
enum {
dac_2comp, dac_straight
@@ -115,6 +92,7 @@ static int rti802_attach(struct comedi_device *dev, struct comedi_devconfig *it)
struct comedi_subdevice *s;
int i;
unsigned long iobase;
+ int ret;
iobase = it->options[0];
printk(KERN_INFO "comedi%d: rti802: 0x%04lx ", dev->minor, iobase);
@@ -126,10 +104,12 @@ static int rti802_attach(struct comedi_device *dev, struct comedi_devconfig *it)
dev->board_name = "rti802";
- if (alloc_subdevices(dev, 1) < 0
- || alloc_private(dev, sizeof(struct rti802_private))) {
+ if (alloc_private(dev, sizeof(struct rti802_private)))
return -ENOMEM;
- }
+
+ ret = comedi_alloc_subdevices(dev, 1);
+ if (ret)
+ return ret;
s = dev->subdevices;
/* ao subdevice */
@@ -152,16 +132,20 @@ static int rti802_attach(struct comedi_device *dev, struct comedi_devconfig *it)
return 0;
}
-static int rti802_detach(struct comedi_device *dev)
+static void rti802_detach(struct comedi_device *dev)
{
- printk(KERN_INFO "comedi%d: rti802: remove\n", dev->minor);
-
if (dev->iobase)
release_region(dev->iobase, RTI802_SIZE);
-
- return 0;
}
+static struct comedi_driver rti802_driver = {
+ .driver_name = "rti802",
+ .module = THIS_MODULE,
+ .attach = rti802_attach,
+ .detach = rti802_detach,
+};
+module_comedi_driver(rti802_driver);
+
MODULE_AUTHOR("Comedi http://www.comedi.org");
MODULE_DESCRIPTION("Comedi low-level driver");
MODULE_LICENSE("GPL");
diff --git a/drivers/staging/comedi/drivers/s526.c b/drivers/staging/comedi/drivers/s526.c
index 2b34daedc3d7..737a194dfce3 100644
--- a/drivers/staging/comedi/drivers/s526.c
+++ b/drivers/staging/comedi/drivers/s526.c
@@ -200,26 +200,13 @@ static const struct s526_board s526_boards[] = {
#define ADDR_REG(reg) (dev->iobase + (reg))
#define ADDR_CHAN_REG(reg, chan) (dev->iobase + (reg) + (chan) * 8)
-/*
- * Useful for shorthand access to the particular board structure
- */
-#define thisboard ((const struct s526_board *)dev->board_ptr)
-
/* this structure is for data unique to this hardware driver. If
several hardware drivers keep similar information in this structure,
feel free to suggest moving the variable to the struct comedi_device
struct.
*/
struct s526_private {
-
- int data;
-
- /* would be useful for a PCI device */
- struct pci_dev *pci_dev;
-
- /* Used for AO readback */
unsigned int ao_readback[2];
-
struct s526GPCTConfig s526_gpct_config[4];
unsigned short s526_ai_config;
};
@@ -230,287 +217,6 @@ struct s526_private {
*/
#define devpriv ((struct s526_private *)dev->private)
-/*
- * The struct comedi_driver structure tells the Comedi core module
- * which functions to call to configure/deconfigure (attach/detach)
- * the board, and also about the kernel module that contains
- * the device code.
- */
-static int s526_attach(struct comedi_device *dev, struct comedi_devconfig *it);
-static int s526_detach(struct comedi_device *dev);
-static struct comedi_driver driver_s526 = {
- .driver_name = "s526",
- .module = THIS_MODULE,
- .attach = s526_attach,
- .detach = s526_detach,
-/* It is not necessary to implement the following members if you are
- * writing a driver for a ISA PnP or PCI card */
- /* Most drivers will support multiple types of boards by
- * having an array of board structures. These were defined
- * in s526_boards[] above. Note that the element 'name'
- * was first in the structure -- Comedi uses this fact to
- * extract the name of the board without knowing any details
- * about the structure except for its length.
- * When a device is attached (by comedi_config), the name
- * of the device is given to Comedi, and Comedi tries to
- * match it by going through the list of board names. If
- * there is a match, the address of the pointer is put
- * into dev->board_ptr and driver->attach() is called.
- *
- * Note that these are not necessary if you can determine
- * the type of board in software. ISA PnP, PCI, and PCMCIA
- * devices are such boards.
- */
- .board_name = &s526_boards[0].name,
- .offset = sizeof(struct s526_board),
- .num_names = ARRAY_SIZE(s526_boards),
-};
-
-static int s526_gpct_rinsn(struct comedi_device *dev,
- struct comedi_subdevice *s, struct comedi_insn *insn,
- unsigned int *data);
-static int s526_gpct_insn_config(struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data);
-static int s526_gpct_winsn(struct comedi_device *dev,
- struct comedi_subdevice *s, struct comedi_insn *insn,
- unsigned int *data);
-static int s526_ai_insn_config(struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data);
-static int s526_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data);
-static int s526_ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data);
-static int s526_ao_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data);
-static int s526_dio_insn_bits(struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data);
-static int s526_dio_insn_config(struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data);
-
-/*
- * Attach is called by the Comedi core to configure the driver
- * for a particular board. If you specified a board_name array
- * in the driver structure, dev->board_ptr contains that
- * address.
- */
-static int s526_attach(struct comedi_device *dev, struct comedi_devconfig *it)
-{
- struct comedi_subdevice *s;
- int iobase;
- int i, n;
-/* short value; */
-/* int subdev_channel = 0; */
- union cmReg cmReg;
-
- printk(KERN_INFO "comedi%d: s526: ", dev->minor);
-
- iobase = it->options[0];
- if (!iobase || !request_region(iobase, S526_IOSIZE, thisboard->name)) {
- comedi_error(dev, "I/O port conflict");
- return -EIO;
- }
- dev->iobase = iobase;
-
- printk("iobase=0x%lx\n", dev->iobase);
-
- /*** make it a little quieter, exw, 8/29/06
- for (i = 0; i < S526_NUM_PORTS; i++) {
- printk("0x%02x: 0x%04x\n", ADDR_REG(s526_ports[i]),
- inw(ADDR_REG(s526_ports[i])));
- }
- ***/
-
-/*
- * Initialize dev->board_name. Note that we can use the "thisboard"
- * macro now, since we just initialized it in the last line.
- */
- dev->board_ptr = &s526_boards[0];
-
- dev->board_name = thisboard->name;
-
-/*
- * Allocate the private structure area. alloc_private() is a
- * convenient macro defined in comedidev.h.
- */
- if (alloc_private(dev, sizeof(struct s526_private)) < 0)
- return -ENOMEM;
-
-/*
- * Allocate the subdevice structures. alloc_subdevice() is a
- * convenient macro defined in comedidev.h.
- */
- dev->n_subdevices = 4;
- if (alloc_subdevices(dev, dev->n_subdevices) < 0)
- return -ENOMEM;
-
- s = dev->subdevices + 0;
- /* GENERAL-PURPOSE COUNTER/TIME (GPCT) */
- s->type = COMEDI_SUBD_COUNTER;
- s->subdev_flags = SDF_READABLE | SDF_WRITABLE | SDF_LSAMPL;
- /* KG: What does SDF_LSAMPL (see multiq3.c) mean? */
- s->n_chan = thisboard->gpct_chans;
- s->maxdata = 0x00ffffff; /* 24 bit counter */
- s->insn_read = s526_gpct_rinsn;
- s->insn_config = s526_gpct_insn_config;
- s->insn_write = s526_gpct_winsn;
-
- /* Command are not implemented yet, however they are necessary to
- allocate the necessary memory for the comedi_async struct (used
- to trigger the GPCT in case of pulsegenerator function */
- /* s->do_cmd = s526_gpct_cmd; */
- /* s->do_cmdtest = s526_gpct_cmdtest; */
- /* s->cancel = s526_gpct_cancel; */
-
- s = dev->subdevices + 1;
- /* dev->read_subdev=s; */
- /* analog input subdevice */
- s->type = COMEDI_SUBD_AI;
- /* we support differential */
- s->subdev_flags = SDF_READABLE | SDF_DIFF;
- /* channels 0 to 7 are the regular differential inputs */
- /* channel 8 is "reference 0" (+10V), channel 9 is "reference 1" (0V) */
- s->n_chan = 10;
- s->maxdata = 0xffff;
- s->range_table = &range_bipolar10;
- s->len_chanlist = 16; /* This is the maximum chanlist length that
- the board can handle */
- s->insn_read = s526_ai_rinsn;
- s->insn_config = s526_ai_insn_config;
-
- s = dev->subdevices + 2;
- /* analog output subdevice */
- s->type = COMEDI_SUBD_AO;
- s->subdev_flags = SDF_WRITABLE;
- s->n_chan = 4;
- s->maxdata = 0xffff;
- s->range_table = &range_bipolar10;
- s->insn_write = s526_ao_winsn;
- s->insn_read = s526_ao_rinsn;
-
- s = dev->subdevices + 3;
- /* digital i/o subdevice */
- if (thisboard->have_dio) {
- s->type = COMEDI_SUBD_DIO;
- s->subdev_flags = SDF_READABLE | SDF_WRITABLE;
- s->n_chan = 8;
- s->maxdata = 1;
- s->range_table = &range_digital;
- s->insn_bits = s526_dio_insn_bits;
- s->insn_config = s526_dio_insn_config;
- } else {
- s->type = COMEDI_SUBD_UNUSED;
- }
-
- printk(KERN_INFO "attached\n");
-
- return 1;
-
-#if 0
- /* Example of Counter Application */
- /* One-shot (software trigger) */
- cmReg.reg.coutSource = 0; /* out RCAP */
- cmReg.reg.coutPolarity = 1; /* Polarity inverted */
- cmReg.reg.autoLoadResetRcap = 1;/* Auto load 0:disabled, 1:enabled */
- cmReg.reg.hwCtEnableSource = 3; /* NOT RCAP */
- cmReg.reg.ctEnableCtrl = 2; /* Hardware */
- cmReg.reg.clockSource = 2; /* Internal */
- cmReg.reg.countDir = 1; /* Down */
- cmReg.reg.countDirCtrl = 1; /* Software */
- cmReg.reg.outputRegLatchCtrl = 0; /* latch on read */
- cmReg.reg.preloadRegSel = 0; /* PR0 */
- cmReg.reg.reserved = 0;
-
- outw(cmReg.value, ADDR_CHAN_REG(REG_C0M, subdev_channel));
-
- outw(0x0001, ADDR_CHAN_REG(REG_C0H, subdev_channel));
- outw(0x3C68, ADDR_CHAN_REG(REG_C0L, subdev_channel));
-
- /* Reset the counter */
- outw(0x8000, ADDR_CHAN_REG(REG_C0C, subdev_channel));
- /* Load the counter from PR0 */
- outw(0x4000, ADDR_CHAN_REG(REG_C0C, subdev_channel));
- /* Reset RCAP (fires one-shot) */
- outw(0x0008, ADDR_CHAN_REG(REG_C0C, subdev_channel));
-
-#else
-
- /* Set Counter Mode Register */
- cmReg.reg.coutSource = 0; /* out RCAP */
- cmReg.reg.coutPolarity = 0; /* Polarity inverted */
- cmReg.reg.autoLoadResetRcap = 0; /* Auto load disabled */
- cmReg.reg.hwCtEnableSource = 2; /* NOT RCAP */
- cmReg.reg.ctEnableCtrl = 1; /* 1: Software, >1 : Hardware */
- cmReg.reg.clockSource = 3; /* x4 */
- cmReg.reg.countDir = 0; /* up */
- cmReg.reg.countDirCtrl = 0; /* quadrature */
- cmReg.reg.outputRegLatchCtrl = 0; /* latch on read */
- cmReg.reg.preloadRegSel = 0; /* PR0 */
- cmReg.reg.reserved = 0;
-
- n = 0;
- printk(KERN_INFO "Mode reg=0x%04x, 0x%04lx\n",
- cmReg.value, ADDR_CHAN_REG(REG_C0M, n));
- outw(cmReg.value, ADDR_CHAN_REG(REG_C0M, n));
- udelay(1000);
- printk(KERN_INFO "Read back mode reg=0x%04x\n",
- inw(ADDR_CHAN_REG(REG_C0M, n)));
-
- /* Load the pre-load register high word */
-/* value = (short) (0x55); */
-/* outw(value, ADDR_CHAN_REG(REG_C0H, n)); */
-
- /* Load the pre-load register low word */
-/* value = (short)(0xaa55); */
-/* outw(value, ADDR_CHAN_REG(REG_C0L, n)); */
-
- /* Write the Counter Control Register */
-/* outw(value, ADDR_CHAN_REG(REG_C0C, 0)); */
-
- /* Reset the counter if it is software preload */
- if (cmReg.reg.autoLoadResetRcap == 0) {
- /* Reset the counter */
- outw(0x8000, ADDR_CHAN_REG(REG_C0C, n));
- /* Load the counter from PR0 */
- outw(0x4000, ADDR_CHAN_REG(REG_C0C, n));
- }
-
- outw(cmReg.value, ADDR_CHAN_REG(REG_C0M, n));
- udelay(1000);
- printk(KERN_INFO "Read back mode reg=0x%04x\n",
- inw(ADDR_CHAN_REG(REG_C0M, n)));
-
-#endif
- printk(KERN_INFO "Current registres:\n");
-
- for (i = 0; i < S526_NUM_PORTS; i++) {
- printk(KERN_INFO "0x%02lx: 0x%04x\n",
- ADDR_REG(s526_ports[i]), inw(ADDR_REG(s526_ports[i])));
- }
- return 1;
-}
-
-/*
- * _detach is called to deconfigure a device. It should deallocate
- * resources.
- * This function is also called when _attach() fails, so it should be
- * careful not to release resources that were not necessarily
- * allocated by _attach(). dev->private and dev->subdevices are
- * deallocated automatically by the core.
- */
-static int s526_detach(struct comedi_device *dev)
-{
- printk(KERN_INFO "comedi%d: s526: remove\n", dev->minor);
-
- if (dev->iobase > 0)
- release_region(dev->iobase, S526_IOSIZE);
-
- return 0;
-}
-
static int s526_gpct_rinsn(struct comedi_device *dev,
struct comedi_subdevice *s, struct comedi_insn *insn,
unsigned int *data)
@@ -964,9 +670,6 @@ static int s526_dio_insn_bits(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
- if (insn->n != 2)
- return -EINVAL;
-
/* The insn data is a mask in data[0] and the new data
* in data[1], each channel cooresponding to a bit. */
if (data[0]) {
@@ -983,7 +686,7 @@ static int s526_dio_insn_bits(struct comedi_device *dev,
* it was a purely digital output subdevice */
/* data[1]=s->state & 0xFF; */
- return 2;
+ return insn->n;
}
static int s526_dio_insn_config(struct comedi_device *dev,
@@ -1023,22 +726,210 @@ static int s526_dio_insn_config(struct comedi_device *dev,
return 1;
}
+static int s526_attach(struct comedi_device *dev, struct comedi_devconfig *it)
+{
+ const struct s526_board *board = comedi_board(dev);
+ struct comedi_subdevice *s;
+ int iobase;
+ int i, n;
+ int ret;
+/* short value; */
+/* int subdev_channel = 0; */
+ union cmReg cmReg;
+
+ printk(KERN_INFO "comedi%d: s526: ", dev->minor);
+
+ iobase = it->options[0];
+ if (!iobase || !request_region(iobase, S526_IOSIZE, board->name)) {
+ comedi_error(dev, "I/O port conflict");
+ return -EIO;
+ }
+ dev->iobase = iobase;
+
+ printk("iobase=0x%lx\n", dev->iobase);
+
+ /*** make it a little quieter, exw, 8/29/06
+ for (i = 0; i < S526_NUM_PORTS; i++) {
+ printk("0x%02x: 0x%04x\n", ADDR_REG(s526_ports[i]),
+ inw(ADDR_REG(s526_ports[i])));
+ }
+ ***/
+
+ dev->board_name = board->name;
+
/*
- * A convenient macro that defines init_module() and cleanup_module(),
- * as necessary.
+ * Allocate the private structure area. alloc_private() is a
+ * convenient macro defined in comedidev.h.
*/
-static int __init driver_s526_init_module(void)
-{
- return comedi_driver_register(&driver_s526);
+ if (alloc_private(dev, sizeof(struct s526_private)) < 0)
+ return -ENOMEM;
+
+ ret = comedi_alloc_subdevices(dev, 4);
+ if (ret)
+ return ret;
+
+ s = dev->subdevices + 0;
+ /* GENERAL-PURPOSE COUNTER/TIME (GPCT) */
+ s->type = COMEDI_SUBD_COUNTER;
+ s->subdev_flags = SDF_READABLE | SDF_WRITABLE | SDF_LSAMPL;
+ /* KG: What does SDF_LSAMPL (see multiq3.c) mean? */
+ s->n_chan = board->gpct_chans;
+ s->maxdata = 0x00ffffff; /* 24 bit counter */
+ s->insn_read = s526_gpct_rinsn;
+ s->insn_config = s526_gpct_insn_config;
+ s->insn_write = s526_gpct_winsn;
+
+ /* Command are not implemented yet, however they are necessary to
+ allocate the necessary memory for the comedi_async struct (used
+ to trigger the GPCT in case of pulsegenerator function */
+ /* s->do_cmd = s526_gpct_cmd; */
+ /* s->do_cmdtest = s526_gpct_cmdtest; */
+ /* s->cancel = s526_gpct_cancel; */
+
+ s = dev->subdevices + 1;
+ /* dev->read_subdev=s; */
+ /* analog input subdevice */
+ s->type = COMEDI_SUBD_AI;
+ /* we support differential */
+ s->subdev_flags = SDF_READABLE | SDF_DIFF;
+ /* channels 0 to 7 are the regular differential inputs */
+ /* channel 8 is "reference 0" (+10V), channel 9 is "reference 1" (0V) */
+ s->n_chan = 10;
+ s->maxdata = 0xffff;
+ s->range_table = &range_bipolar10;
+ s->len_chanlist = 16; /* This is the maximum chanlist length that
+ the board can handle */
+ s->insn_read = s526_ai_rinsn;
+ s->insn_config = s526_ai_insn_config;
+
+ s = dev->subdevices + 2;
+ /* analog output subdevice */
+ s->type = COMEDI_SUBD_AO;
+ s->subdev_flags = SDF_WRITABLE;
+ s->n_chan = 4;
+ s->maxdata = 0xffff;
+ s->range_table = &range_bipolar10;
+ s->insn_write = s526_ao_winsn;
+ s->insn_read = s526_ao_rinsn;
+
+ s = dev->subdevices + 3;
+ /* digital i/o subdevice */
+ if (board->have_dio) {
+ s->type = COMEDI_SUBD_DIO;
+ s->subdev_flags = SDF_READABLE | SDF_WRITABLE;
+ s->n_chan = 8;
+ s->maxdata = 1;
+ s->range_table = &range_digital;
+ s->insn_bits = s526_dio_insn_bits;
+ s->insn_config = s526_dio_insn_config;
+ } else {
+ s->type = COMEDI_SUBD_UNUSED;
+ }
+
+ printk(KERN_INFO "attached\n");
+
+ return 1;
+
+#if 0
+ /* Example of Counter Application */
+ /* One-shot (software trigger) */
+ cmReg.reg.coutSource = 0; /* out RCAP */
+ cmReg.reg.coutPolarity = 1; /* Polarity inverted */
+ cmReg.reg.autoLoadResetRcap = 1;/* Auto load 0:disabled, 1:enabled */
+ cmReg.reg.hwCtEnableSource = 3; /* NOT RCAP */
+ cmReg.reg.ctEnableCtrl = 2; /* Hardware */
+ cmReg.reg.clockSource = 2; /* Internal */
+ cmReg.reg.countDir = 1; /* Down */
+ cmReg.reg.countDirCtrl = 1; /* Software */
+ cmReg.reg.outputRegLatchCtrl = 0; /* latch on read */
+ cmReg.reg.preloadRegSel = 0; /* PR0 */
+ cmReg.reg.reserved = 0;
+
+ outw(cmReg.value, ADDR_CHAN_REG(REG_C0M, subdev_channel));
+
+ outw(0x0001, ADDR_CHAN_REG(REG_C0H, subdev_channel));
+ outw(0x3C68, ADDR_CHAN_REG(REG_C0L, subdev_channel));
+
+ /* Reset the counter */
+ outw(0x8000, ADDR_CHAN_REG(REG_C0C, subdev_channel));
+ /* Load the counter from PR0 */
+ outw(0x4000, ADDR_CHAN_REG(REG_C0C, subdev_channel));
+ /* Reset RCAP (fires one-shot) */
+ outw(0x0008, ADDR_CHAN_REG(REG_C0C, subdev_channel));
+
+#else
+
+ /* Set Counter Mode Register */
+ cmReg.reg.coutSource = 0; /* out RCAP */
+ cmReg.reg.coutPolarity = 0; /* Polarity inverted */
+ cmReg.reg.autoLoadResetRcap = 0; /* Auto load disabled */
+ cmReg.reg.hwCtEnableSource = 2; /* NOT RCAP */
+ cmReg.reg.ctEnableCtrl = 1; /* 1: Software, >1 : Hardware */
+ cmReg.reg.clockSource = 3; /* x4 */
+ cmReg.reg.countDir = 0; /* up */
+ cmReg.reg.countDirCtrl = 0; /* quadrature */
+ cmReg.reg.outputRegLatchCtrl = 0; /* latch on read */
+ cmReg.reg.preloadRegSel = 0; /* PR0 */
+ cmReg.reg.reserved = 0;
+
+ n = 0;
+ printk(KERN_INFO "Mode reg=0x%04x, 0x%04lx\n",
+ cmReg.value, ADDR_CHAN_REG(REG_C0M, n));
+ outw(cmReg.value, ADDR_CHAN_REG(REG_C0M, n));
+ udelay(1000);
+ printk(KERN_INFO "Read back mode reg=0x%04x\n",
+ inw(ADDR_CHAN_REG(REG_C0M, n)));
+
+ /* Load the pre-load register high word */
+/* value = (short) (0x55); */
+/* outw(value, ADDR_CHAN_REG(REG_C0H, n)); */
+
+ /* Load the pre-load register low word */
+/* value = (short)(0xaa55); */
+/* outw(value, ADDR_CHAN_REG(REG_C0L, n)); */
+
+ /* Write the Counter Control Register */
+/* outw(value, ADDR_CHAN_REG(REG_C0C, 0)); */
+
+ /* Reset the counter if it is software preload */
+ if (cmReg.reg.autoLoadResetRcap == 0) {
+ /* Reset the counter */
+ outw(0x8000, ADDR_CHAN_REG(REG_C0C, n));
+ /* Load the counter from PR0 */
+ outw(0x4000, ADDR_CHAN_REG(REG_C0C, n));
+ }
+
+ outw(cmReg.value, ADDR_CHAN_REG(REG_C0M, n));
+ udelay(1000);
+ printk(KERN_INFO "Read back mode reg=0x%04x\n",
+ inw(ADDR_CHAN_REG(REG_C0M, n)));
+
+#endif
+ printk(KERN_INFO "Current registres:\n");
+
+ for (i = 0; i < S526_NUM_PORTS; i++) {
+ printk(KERN_INFO "0x%02lx: 0x%04x\n",
+ ADDR_REG(s526_ports[i]), inw(ADDR_REG(s526_ports[i])));
+ }
+ return 1;
}
-static void __exit driver_s526_cleanup_module(void)
+static void s526_detach(struct comedi_device *dev)
{
- comedi_driver_unregister(&driver_s526);
+ if (dev->iobase > 0)
+ release_region(dev->iobase, S526_IOSIZE);
}
-module_init(driver_s526_init_module);
-module_exit(driver_s526_cleanup_module);
+static struct comedi_driver s526_driver = {
+ .driver_name = "s526",
+ .module = THIS_MODULE,
+ .attach = s526_attach,
+ .detach = s526_detach,
+ .board_name = &s526_boards[0].name,
+ .offset = sizeof(struct s526_board),
+ .num_names = ARRAY_SIZE(s526_boards),
+};
+module_comedi_driver(s526_driver);
MODULE_AUTHOR("Comedi http://www.comedi.org");
MODULE_DESCRIPTION("Comedi low-level driver");
diff --git a/drivers/staging/comedi/drivers/s626.c b/drivers/staging/comedi/drivers/s626.c
index 23fc64b9988e..f90578e5e727 100644
--- a/drivers/staging/comedi/drivers/s626.c
+++ b/drivers/staging/comedi/drivers/s626.c
@@ -74,17 +74,20 @@ INSN_CONFIG instructions:
#include "../comedidev.h"
-#include "comedi_pci.h"
-
#include "comedi_fc.h"
#include "s626.h"
-MODULE_AUTHOR("Gianluca Palli <gpalli@deis.unibo.it>");
-MODULE_DESCRIPTION("Sensoray 626 Comedi driver module");
-MODULE_LICENSE("GPL");
+#define PCI_VENDOR_ID_S626 0x1131
+#define PCI_DEVICE_ID_S626 0x7146
+#define PCI_SUBVENDOR_ID_S626 0x6000
+#define PCI_SUBDEVICE_ID_S626 0x0272
struct s626_board {
const char *name;
+ int vendor_id;
+ int device_id;
+ int subvendor_id;
+ int subdevice_id;
int ai_chans;
int ai_bits;
int ao_chans;
@@ -97,6 +100,10 @@ struct s626_board {
static const struct s626_board s626_boards[] = {
{
.name = "s626",
+ .vendor_id = PCI_VENDOR_ID_S626,
+ .device_id = PCI_DEVICE_ID_S626,
+ .subvendor_id = PCI_SUBVENDOR_ID_S626,
+ .subdevice_id = PCI_SUBDEVICE_ID_S626,
.ai_chans = S626_ADC_CHANNELS,
.ai_bits = 14,
.ao_chans = S626_DAC_CHANNELS,
@@ -108,34 +115,10 @@ static const struct s626_board s626_boards[] = {
};
#define thisboard ((const struct s626_board *)dev->board_ptr)
-#define PCI_VENDOR_ID_S626 0x1131
-#define PCI_DEVICE_ID_S626 0x7146
-
-/*
- * For devices with vendor:device id == 0x1131:0x7146 you must specify
- * also subvendor:subdevice ids, because otherwise it will conflict with
- * Philips SAA7146 media/dvb based cards.
- */
-static DEFINE_PCI_DEVICE_TABLE(s626_pci_table) = {
- {PCI_VENDOR_ID_S626, PCI_DEVICE_ID_S626, 0x6000, 0x0272, 0, 0, 0},
- {0}
-};
-
-MODULE_DEVICE_TABLE(pci, s626_pci_table);
-
-static int s626_attach(struct comedi_device *dev, struct comedi_devconfig *it);
-static int s626_detach(struct comedi_device *dev);
-
-static struct comedi_driver driver_s626 = {
- .driver_name = "s626",
- .module = THIS_MODULE,
- .attach = s626_attach,
- .detach = s626_detach,
-};
struct s626_private {
struct pci_dev *pdev;
- void *base_addr;
+ void __iomem *base_addr;
int got_regions;
short allocatedBuf;
uint8_t ai_cmd_running; /* ai_cmd is running */
@@ -224,109 +207,6 @@ static struct dio_private *dio_private_word[]={
#define devpriv ((struct s626_private *)dev->private)
#define diopriv ((struct dio_private *)s->private)
-static int __devinit driver_s626_pci_probe(struct pci_dev *dev,
- const struct pci_device_id *ent)
-{
- return comedi_pci_auto_config(dev, driver_s626.driver_name);
-}
-
-static void __devexit driver_s626_pci_remove(struct pci_dev *dev)
-{
- comedi_pci_auto_unconfig(dev);
-}
-
-static struct pci_driver driver_s626_pci_driver = {
- .id_table = s626_pci_table,
- .probe = &driver_s626_pci_probe,
- .remove = __devexit_p(&driver_s626_pci_remove)
-};
-
-static int __init driver_s626_init_module(void)
-{
- int retval;
-
- retval = comedi_driver_register(&driver_s626);
- if (retval < 0)
- return retval;
-
- driver_s626_pci_driver.name = (char *)driver_s626.driver_name;
- return pci_register_driver(&driver_s626_pci_driver);
-}
-
-static void __exit driver_s626_cleanup_module(void)
-{
- pci_unregister_driver(&driver_s626_pci_driver);
- comedi_driver_unregister(&driver_s626);
-}
-
-module_init(driver_s626_init_module);
-module_exit(driver_s626_cleanup_module);
-
-/* ioctl routines */
-static int s626_ai_insn_config(struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data);
-/* static int s626_ai_rinsn(struct comedi_device *dev,struct comedi_subdevice *s,struct comedi_insn *insn,unsigned int *data); */
-static int s626_ai_insn_read(struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data);
-static int s626_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s);
-static int s626_ai_cmdtest(struct comedi_device *dev,
- struct comedi_subdevice *s, struct comedi_cmd *cmd);
-static int s626_ai_cancel(struct comedi_device *dev,
- struct comedi_subdevice *s);
-static int s626_ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data);
-static int s626_ao_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data);
-static int s626_dio_insn_bits(struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data);
-static int s626_dio_insn_config(struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data);
-static int s626_dio_set_irq(struct comedi_device *dev, unsigned int chan);
-static int s626_dio_reset_irq(struct comedi_device *dev, unsigned int gruop,
- unsigned int mask);
-static int s626_dio_clear_irq(struct comedi_device *dev);
-static int s626_enc_insn_config(struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data);
-static int s626_enc_insn_read(struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data);
-static int s626_enc_insn_write(struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data);
-static int s626_ns_to_timer(int *nanosec, int round_mode);
-static int s626_ai_load_polllist(uint8_t *ppl, struct comedi_cmd *cmd);
-static int s626_ai_inttrig(struct comedi_device *dev,
- struct comedi_subdevice *s, unsigned int trignum);
-static irqreturn_t s626_irq_handler(int irq, void *d);
-static unsigned int s626_ai_reg_to_uint(int data);
-/* static unsigned int s626_uint_to_reg(struct comedi_subdevice *s, int data); */
-
-/* end ioctl routines */
-
-/* internal routines */
-static void s626_dio_init(struct comedi_device *dev);
-static void ResetADC(struct comedi_device *dev, uint8_t * ppl);
-static void LoadTrimDACs(struct comedi_device *dev);
-static void WriteTrimDAC(struct comedi_device *dev, uint8_t LogicalChan,
- uint8_t DacData);
-static uint8_t I2Cread(struct comedi_device *dev, uint8_t addr);
-static uint32_t I2Chandshake(struct comedi_device *dev, uint32_t val);
-static void SetDAC(struct comedi_device *dev, uint16_t chan, short dacdata);
-static void SendDAC(struct comedi_device *dev, uint32_t val);
-static void WriteMISC2(struct comedi_device *dev, uint16_t NewImage);
-static void DEBItransfer(struct comedi_device *dev);
-static uint16_t DEBIread(struct comedi_device *dev, uint16_t addr);
-static void DEBIwrite(struct comedi_device *dev, uint16_t addr, uint16_t wdata);
-static void DEBIreplace(struct comedi_device *dev, uint16_t addr, uint16_t mask,
- uint16_t wdata);
-static void CloseDMAB(struct comedi_device *dev, struct bufferDMA *pdma,
- size_t bsize);
-
/* COUNTER OBJECT ------------------------------------------------ */
struct enc_private {
/* Pointers to functions that differ for A and B counters: */
@@ -350,56 +230,6 @@ struct enc_private {
#define encpriv ((struct enc_private *)(dev->subdevices+5)->private)
-/* counters routines */
-static void s626_timer_load(struct comedi_device *dev, struct enc_private *k,
- int tick);
-static uint32_t ReadLatch(struct comedi_device *dev, struct enc_private *k);
-static void ResetCapFlags_A(struct comedi_device *dev, struct enc_private *k);
-static void ResetCapFlags_B(struct comedi_device *dev, struct enc_private *k);
-static uint16_t GetMode_A(struct comedi_device *dev, struct enc_private *k);
-static uint16_t GetMode_B(struct comedi_device *dev, struct enc_private *k);
-static void SetMode_A(struct comedi_device *dev, struct enc_private *k,
- uint16_t Setup, uint16_t DisableIntSrc);
-static void SetMode_B(struct comedi_device *dev, struct enc_private *k,
- uint16_t Setup, uint16_t DisableIntSrc);
-static void SetEnable_A(struct comedi_device *dev, struct enc_private *k,
- uint16_t enab);
-static void SetEnable_B(struct comedi_device *dev, struct enc_private *k,
- uint16_t enab);
-static uint16_t GetEnable_A(struct comedi_device *dev, struct enc_private *k);
-static uint16_t GetEnable_B(struct comedi_device *dev, struct enc_private *k);
-static void SetLatchSource(struct comedi_device *dev, struct enc_private *k,
- uint16_t value);
-/* static uint16_t GetLatchSource(struct comedi_device *dev, struct enc_private *k ); */
-static void SetLoadTrig_A(struct comedi_device *dev, struct enc_private *k,
- uint16_t Trig);
-static void SetLoadTrig_B(struct comedi_device *dev, struct enc_private *k,
- uint16_t Trig);
-static uint16_t GetLoadTrig_A(struct comedi_device *dev, struct enc_private *k);
-static uint16_t GetLoadTrig_B(struct comedi_device *dev, struct enc_private *k);
-static void SetIntSrc_B(struct comedi_device *dev, struct enc_private *k,
- uint16_t IntSource);
-static void SetIntSrc_A(struct comedi_device *dev, struct enc_private *k,
- uint16_t IntSource);
-static uint16_t GetIntSrc_A(struct comedi_device *dev, struct enc_private *k);
-static uint16_t GetIntSrc_B(struct comedi_device *dev, struct enc_private *k);
-/* static void SetClkMult(struct comedi_device *dev, struct enc_private *k, uint16_t value ) ; */
-/* static uint16_t GetClkMult(struct comedi_device *dev, struct enc_private *k ) ; */
-/* static void SetIndexPol(struct comedi_device *dev, struct enc_private *k, uint16_t value ); */
-/* static uint16_t GetClkPol(struct comedi_device *dev, struct enc_private *k ) ; */
-/* static void SetIndexSrc( struct comedi_device *dev,struct enc_private *k, uint16_t value ); */
-/* static uint16_t GetClkSrc( struct comedi_device *dev,struct enc_private *k ); */
-/* static void SetIndexSrc( struct comedi_device *dev,struct enc_private *k, uint16_t value ); */
-/* static uint16_t GetIndexSrc( struct comedi_device *dev,struct enc_private *k ); */
-static void PulseIndex_A(struct comedi_device *dev, struct enc_private *k);
-static void PulseIndex_B(struct comedi_device *dev, struct enc_private *k);
-static void Preload(struct comedi_device *dev, struct enc_private *k,
- uint32_t value);
-static void CountersInit(struct comedi_device *dev);
-/* end internal routines */
-
-/* Counter objects constructor. */
-
/* Counter overflow/index event flag masks for RDMISC2. */
#define INDXMASK(C) (1 << (((C) > 2) ? ((C) * 2 - 1) : ((C) * 2 + 4)))
#define OVERMASK(C) (1 << (((C) > 2) ? ((C) * 2 + 5) : ((C) * 2 + 10)))
@@ -408,106 +238,6 @@ static void CountersInit(struct comedi_device *dev);
/* Translation table to map IntSrc into equivalent RDMISC2 event flag bits. */
/* static const uint16_t EventBits[][4] = { EVBITS(0), EVBITS(1), EVBITS(2), EVBITS(3), EVBITS(4), EVBITS(5) }; */
-/* struct enc_private; */
-static struct enc_private enc_private_data[] = {
- {
- .GetEnable = GetEnable_A,
- .GetIntSrc = GetIntSrc_A,
- .GetLoadTrig = GetLoadTrig_A,
- .GetMode = GetMode_A,
- .PulseIndex = PulseIndex_A,
- .SetEnable = SetEnable_A,
- .SetIntSrc = SetIntSrc_A,
- .SetLoadTrig = SetLoadTrig_A,
- .SetMode = SetMode_A,
- .ResetCapFlags = ResetCapFlags_A,
- .MyCRA = LP_CR0A,
- .MyCRB = LP_CR0B,
- .MyLatchLsw = LP_CNTR0ALSW,
- .MyEventBits = EVBITS(0),
- },
- {
- .GetEnable = GetEnable_A,
- .GetIntSrc = GetIntSrc_A,
- .GetLoadTrig = GetLoadTrig_A,
- .GetMode = GetMode_A,
- .PulseIndex = PulseIndex_A,
- .SetEnable = SetEnable_A,
- .SetIntSrc = SetIntSrc_A,
- .SetLoadTrig = SetLoadTrig_A,
- .SetMode = SetMode_A,
- .ResetCapFlags = ResetCapFlags_A,
- .MyCRA = LP_CR1A,
- .MyCRB = LP_CR1B,
- .MyLatchLsw = LP_CNTR1ALSW,
- .MyEventBits = EVBITS(1),
- },
- {
- .GetEnable = GetEnable_A,
- .GetIntSrc = GetIntSrc_A,
- .GetLoadTrig = GetLoadTrig_A,
- .GetMode = GetMode_A,
- .PulseIndex = PulseIndex_A,
- .SetEnable = SetEnable_A,
- .SetIntSrc = SetIntSrc_A,
- .SetLoadTrig = SetLoadTrig_A,
- .SetMode = SetMode_A,
- .ResetCapFlags = ResetCapFlags_A,
- .MyCRA = LP_CR2A,
- .MyCRB = LP_CR2B,
- .MyLatchLsw = LP_CNTR2ALSW,
- .MyEventBits = EVBITS(2),
- },
- {
- .GetEnable = GetEnable_B,
- .GetIntSrc = GetIntSrc_B,
- .GetLoadTrig = GetLoadTrig_B,
- .GetMode = GetMode_B,
- .PulseIndex = PulseIndex_B,
- .SetEnable = SetEnable_B,
- .SetIntSrc = SetIntSrc_B,
- .SetLoadTrig = SetLoadTrig_B,
- .SetMode = SetMode_B,
- .ResetCapFlags = ResetCapFlags_B,
- .MyCRA = LP_CR0A,
- .MyCRB = LP_CR0B,
- .MyLatchLsw = LP_CNTR0BLSW,
- .MyEventBits = EVBITS(3),
- },
- {
- .GetEnable = GetEnable_B,
- .GetIntSrc = GetIntSrc_B,
- .GetLoadTrig = GetLoadTrig_B,
- .GetMode = GetMode_B,
- .PulseIndex = PulseIndex_B,
- .SetEnable = SetEnable_B,
- .SetIntSrc = SetIntSrc_B,
- .SetLoadTrig = SetLoadTrig_B,
- .SetMode = SetMode_B,
- .ResetCapFlags = ResetCapFlags_B,
- .MyCRA = LP_CR1A,
- .MyCRB = LP_CR1B,
- .MyLatchLsw = LP_CNTR1BLSW,
- .MyEventBits = EVBITS(4),
- },
- {
- .GetEnable = GetEnable_B,
- .GetIntSrc = GetIntSrc_B,
- .GetLoadTrig = GetLoadTrig_B,
- .GetMode = GetMode_B,
- .PulseIndex = PulseIndex_B,
- .SetEnable = SetEnable_B,
- .SetIntSrc = SetIntSrc_B,
- .SetLoadTrig = SetLoadTrig_B,
- .SetMode = SetMode_B,
- .ResetCapFlags = ResetCapFlags_B,
- .MyCRA = LP_CR2A,
- .MyCRB = LP_CR2B,
- .MyLatchLsw = LP_CNTR2BLSW,
- .MyEventBits = EVBITS(5),
- },
-};
-
/* enab/disable a function or test status bit(s) that are accessed */
/* through Main Control Registers 1 or 2. */
#define MC_ENABLE(REGADRS, CTRLWORD) writel(((uint32_t)(CTRLWORD) << 16) | (uint32_t)(CTRLWORD), devpriv->base_addr+(REGADRS))
@@ -541,498 +271,509 @@ static const struct comedi_lrange s626_range_table = { 2, {
}
};
-static int s626_attach(struct comedi_device *dev, struct comedi_devconfig *it)
+/* Execute a DEBI transfer. This must be called from within a */
+/* critical section. */
+static void DEBItransfer(struct comedi_device *dev)
{
-/* uint8_t PollList; */
-/* uint16_t AdcData; */
-/* uint16_t StartVal; */
-/* uint16_t index; */
-/* unsigned int data[16]; */
- int result;
- int i;
- int ret;
- resource_size_t resourceStart;
- dma_addr_t appdma;
- struct comedi_subdevice *s;
- const struct pci_device_id *ids;
- struct pci_dev *pdev = NULL;
+ /* Initiate upload of shadow RAM to DEBI control register. */
+ MC_ENABLE(P_MC2, MC2_UPLD_DEBI);
- if (alloc_private(dev, sizeof(struct s626_private)) < 0)
- return -ENOMEM;
+ /* Wait for completion of upload from shadow RAM to DEBI control */
+ /* register. */
+ while (!MC_TEST(P_MC2, MC2_UPLD_DEBI))
+ ;
- for (i = 0; i < (ARRAY_SIZE(s626_pci_table) - 1) && !pdev; i++) {
- ids = &s626_pci_table[i];
- do {
- pdev = pci_get_subsys(ids->vendor, ids->device,
- ids->subvendor, ids->subdevice,
- pdev);
+ /* Wait until DEBI transfer is done. */
+ while (RR7146(P_PSR) & PSR_DEBI_S)
+ ;
+}
- if ((it->options[0] || it->options[1]) && pdev) {
- /* matches requested bus/slot */
- if (pdev->bus->number == it->options[0] &&
- PCI_SLOT(pdev->devfn) == it->options[1])
- break;
- } else
- break;
- } while (1);
- }
- devpriv->pdev = pdev;
+/* Initialize the DEBI interface for all transfers. */
- if (pdev == NULL) {
- printk(KERN_ERR "s626_attach: Board not present!!!\n");
- return -ENODEV;
- }
+static uint16_t DEBIread(struct comedi_device *dev, uint16_t addr)
+{
+ uint16_t retval;
- result = comedi_pci_enable(pdev, "s626");
- if (result < 0) {
- printk(KERN_ERR "s626_attach: comedi_pci_enable fails\n");
- return -ENODEV;
- }
- devpriv->got_regions = 1;
+ /* Set up DEBI control register value in shadow RAM. */
+ WR7146(P_DEBICMD, DEBI_CMD_RDWORD | addr);
- resourceStart = pci_resource_start(devpriv->pdev, 0);
+ /* Execute the DEBI transfer. */
+ DEBItransfer(dev);
- devpriv->base_addr = ioremap(resourceStart, SIZEOF_ADDRESS_SPACE);
- if (devpriv->base_addr == NULL) {
- printk(KERN_ERR "s626_attach: IOREMAP failed\n");
- return -ENODEV;
- }
+ /* Fetch target register value. */
+ retval = (uint16_t) RR7146(P_DEBIAD);
- if (devpriv->base_addr) {
- /* disable master interrupt */
- writel(0, devpriv->base_addr + P_IER);
+ /* Return register value. */
+ return retval;
+}
- /* soft reset */
- writel(MC1_SOFT_RESET, devpriv->base_addr + P_MC1);
+/* Write a value to a gate array register. */
+static void DEBIwrite(struct comedi_device *dev, uint16_t addr, uint16_t wdata)
+{
- /* DMA FIXME DMA// */
- DEBUG("s626_attach: DMA ALLOCATION\n");
+ /* Set up DEBI control register value in shadow RAM. */
+ WR7146(P_DEBICMD, DEBI_CMD_WRWORD | addr);
+ WR7146(P_DEBIAD, wdata);
- /* adc buffer allocation */
- devpriv->allocatedBuf = 0;
+ /* Execute the DEBI transfer. */
+ DEBItransfer(dev);
+}
- devpriv->ANABuf.LogicalBase =
- pci_alloc_consistent(devpriv->pdev, DMABUF_SIZE, &appdma);
+/* Replace the specified bits in a gate array register. Imports: mask
+ * specifies bits that are to be preserved, wdata is new value to be
+ * or'd with the masked original.
+ */
+static void DEBIreplace(struct comedi_device *dev, uint16_t addr, uint16_t mask,
+ uint16_t wdata)
+{
- if (devpriv->ANABuf.LogicalBase == NULL) {
- printk(KERN_ERR "s626_attach: DMA Memory mapping error\n");
- return -ENOMEM;
- }
+ /* Copy target gate array register into P_DEBIAD register. */
+ WR7146(P_DEBICMD, DEBI_CMD_RDWORD | addr);
+ /* Set up DEBI control reg value in shadow RAM. */
+ DEBItransfer(dev); /* Execute the DEBI Read transfer. */
- devpriv->ANABuf.PhysicalBase = appdma;
+ /* Write back the modified image. */
+ WR7146(P_DEBICMD, DEBI_CMD_WRWORD | addr);
+ /* Set up DEBI control reg value in shadow RAM. */
- DEBUG
- ("s626_attach: AllocDMAB ADC Logical=%p, bsize=%d, Physical=0x%x\n",
- devpriv->ANABuf.LogicalBase, DMABUF_SIZE,
- (uint32_t) devpriv->ANABuf.PhysicalBase);
+ WR7146(P_DEBIAD, wdata | ((uint16_t) RR7146(P_DEBIAD) & mask));
+ /* Modify the register image. */
+ DEBItransfer(dev); /* Execute the DEBI Write transfer. */
+}
- devpriv->allocatedBuf++;
+/* ************** EEPROM ACCESS FUNCTIONS ************** */
- devpriv->RPSBuf.LogicalBase =
- pci_alloc_consistent(devpriv->pdev, DMABUF_SIZE, &appdma);
+static uint32_t I2Chandshake(struct comedi_device *dev, uint32_t val)
+{
+ /* Write I2C command to I2C Transfer Control shadow register. */
+ WR7146(P_I2CCTRL, val);
- if (devpriv->RPSBuf.LogicalBase == NULL) {
- printk(KERN_ERR "s626_attach: DMA Memory mapping error\n");
- return -ENOMEM;
- }
+ /* Upload I2C shadow registers into working registers and wait for */
+ /* upload confirmation. */
- devpriv->RPSBuf.PhysicalBase = appdma;
+ MC_ENABLE(P_MC2, MC2_UPLD_IIC);
+ while (!MC_TEST(P_MC2, MC2_UPLD_IIC))
+ ;
- DEBUG
- ("s626_attach: AllocDMAB RPS Logical=%p, bsize=%d, Physical=0x%x\n",
- devpriv->RPSBuf.LogicalBase, DMABUF_SIZE,
- (uint32_t) devpriv->RPSBuf.PhysicalBase);
+ /* Wait until I2C bus transfer is finished or an error occurs. */
+ while ((RR7146(P_I2CCTRL) & (I2C_BUSY | I2C_ERR)) == I2C_BUSY)
+ ;
- devpriv->allocatedBuf++;
+ /* Return non-zero if I2C error occurred. */
+ return RR7146(P_I2CCTRL) & I2C_ERR;
- }
+}
- dev->board_ptr = s626_boards;
- dev->board_name = thisboard->name;
+/* Read uint8_t from EEPROM. */
+static uint8_t I2Cread(struct comedi_device *dev, uint8_t addr)
+{
+ uint8_t rtnval;
- if (alloc_subdevices(dev, 6) < 0)
- return -ENOMEM;
+ /* Send EEPROM target address. */
+ if (I2Chandshake(dev, I2C_B2(I2C_ATTRSTART, I2CW)
+ /* Byte2 = I2C command: write to I2C EEPROM device. */
+ | I2C_B1(I2C_ATTRSTOP, addr)
+ /* Byte1 = EEPROM internal target address. */
+ | I2C_B0(I2C_ATTRNOP, 0))) { /* Byte0 = Not sent. */
+ /* Abort function and declare error if handshake failed. */
+ return 0;
+ }
+ /* Execute EEPROM read. */
+ if (I2Chandshake(dev, I2C_B2(I2C_ATTRSTART, I2CR)
- dev->iobase = (unsigned long)devpriv->base_addr;
- dev->irq = devpriv->pdev->irq;
+ /* Byte2 = I2C */
+ /* command: read */
+ /* from I2C EEPROM */
+ /* device. */
+ |I2C_B1(I2C_ATTRSTOP, 0)
- /* set up interrupt handler */
- if (dev->irq == 0) {
- printk(KERN_ERR " unknown irq (bad)\n");
- } else {
- ret = request_irq(dev->irq, s626_irq_handler, IRQF_SHARED,
- "s626", dev);
+ /* Byte1 receives */
+ /* uint8_t from */
+ /* EEPROM. */
+ |I2C_B0(I2C_ATTRNOP, 0))) { /* Byte0 = Not sent. */
- if (ret < 0) {
- printk(KERN_ERR " irq not available\n");
- dev->irq = 0;
- }
+ /* Abort function and declare error if handshake failed. */
+ return 0;
}
+ /* Return copy of EEPROM value. */
+ rtnval = (uint8_t) (RR7146(P_I2CCTRL) >> 16);
+ return rtnval;
+}
- DEBUG("s626_attach: -- it opts %d,%d --\n",
- it->options[0], it->options[1]);
+/* *********** DAC FUNCTIONS *********** */
- s = dev->subdevices + 0;
- /* analog input subdevice */
- dev->read_subdev = s;
- /* we support single-ended (ground) and differential */
- s->type = COMEDI_SUBD_AI;
- s->subdev_flags = SDF_READABLE | SDF_DIFF | SDF_CMD_READ;
- s->n_chan = thisboard->ai_chans;
- s->maxdata = (0xffff >> 2);
- s->range_table = &s626_range_table;
- s->len_chanlist = thisboard->ai_chans; /* This is the maximum chanlist
- length that the board can
- handle */
- s->insn_config = s626_ai_insn_config;
- s->insn_read = s626_ai_insn_read;
- s->do_cmd = s626_ai_cmd;
- s->do_cmdtest = s626_ai_cmdtest;
- s->cancel = s626_ai_cancel;
+/* Slot 0 base settings. */
+#define VECT0 (XSD2 | RSD3 | SIB_A2)
+/* Slot 0 always shifts in 0xFF and store it to FB_BUFFER2. */
- s = dev->subdevices + 1;
- /* analog output subdevice */
- s->type = COMEDI_SUBD_AO;
- s->subdev_flags = SDF_WRITABLE | SDF_READABLE;
- s->n_chan = thisboard->ao_chans;
- s->maxdata = (0x3fff);
- s->range_table = &range_bipolar10;
- s->insn_write = s626_ao_winsn;
- s->insn_read = s626_ao_rinsn;
+/* TrimDac LogicalChan-to-PhysicalChan mapping table. */
+static uint8_t trimchan[] = { 10, 9, 8, 3, 2, 7, 6, 1, 0, 5, 4 };
- s = dev->subdevices + 2;
- /* digital I/O subdevice */
- s->type = COMEDI_SUBD_DIO;
- s->subdev_flags = SDF_WRITABLE | SDF_READABLE;
- s->n_chan = S626_DIO_CHANNELS;
- s->maxdata = 1;
- s->io_bits = 0xffff;
- s->private = &dio_private_A;
- s->range_table = &range_digital;
- s->insn_config = s626_dio_insn_config;
- s->insn_bits = s626_dio_insn_bits;
+/* TrimDac LogicalChan-to-EepromAdrs mapping table. */
+static uint8_t trimadrs[] = { 0x40, 0x41, 0x42, 0x50, 0x51, 0x52, 0x53, 0x60, 0x61, 0x62, 0x63 };
- s = dev->subdevices + 3;
- /* digital I/O subdevice */
- s->type = COMEDI_SUBD_DIO;
- s->subdev_flags = SDF_WRITABLE | SDF_READABLE;
- s->n_chan = 16;
- s->maxdata = 1;
- s->io_bits = 0xffff;
- s->private = &dio_private_B;
- s->range_table = &range_digital;
- s->insn_config = s626_dio_insn_config;
- s->insn_bits = s626_dio_insn_bits;
+/* Private helper function: Transmit serial data to DAC via Audio
+ * channel 2. Assumes: (1) TSL2 slot records initialized, and (2)
+ * Dacpol contains valid target image.
+ */
+static void SendDAC(struct comedi_device *dev, uint32_t val)
+{
- s = dev->subdevices + 4;
- /* digital I/O subdevice */
- s->type = COMEDI_SUBD_DIO;
- s->subdev_flags = SDF_WRITABLE | SDF_READABLE;
- s->n_chan = 16;
- s->maxdata = 1;
- s->io_bits = 0xffff;
- s->private = &dio_private_C;
- s->range_table = &range_digital;
- s->insn_config = s626_dio_insn_config;
- s->insn_bits = s626_dio_insn_bits;
+ /* START THE SERIAL CLOCK RUNNING ------------- */
- s = dev->subdevices + 5;
- /* encoder (counter) subdevice */
- s->type = COMEDI_SUBD_COUNTER;
- s->subdev_flags = SDF_WRITABLE | SDF_READABLE | SDF_LSAMPL;
- s->n_chan = thisboard->enc_chans;
- s->private = enc_private_data;
- s->insn_config = s626_enc_insn_config;
- s->insn_read = s626_enc_insn_read;
- s->insn_write = s626_enc_insn_write;
- s->maxdata = 0xffffff;
- s->range_table = &range_unknown;
+ /* Assert DAC polarity control and enable gating of DAC serial clock
+ * and audio bit stream signals. At this point in time we must be
+ * assured of being in time slot 0. If we are not in slot 0, the
+ * serial clock and audio stream signals will be disabled; this is
+ * because the following DEBIwrite statement (which enables signals
+ * to be passed through the gate array) would execute before the
+ * trailing edge of WS1/WS3 (which turns off the signals), thus
+ * causing the signals to be inactive during the DAC write.
+ */
+ DEBIwrite(dev, LP_DACPOL, devpriv->Dacpol);
- /* stop ai_command */
- devpriv->ai_cmd_running = 0;
+ /* TRANSFER OUTPUT DWORD VALUE INTO A2'S OUTPUT FIFO ---------------- */
- if (devpriv->base_addr && (devpriv->allocatedBuf == 2)) {
- dma_addr_t pPhysBuf;
- uint16_t chan;
+ /* Copy DAC setpoint value to DAC's output DMA buffer. */
- /* enab DEBI and audio pins, enable I2C interface. */
- MC_ENABLE(P_MC1, MC1_DEBI | MC1_AUDIO | MC1_I2C);
- /* Configure DEBI operating mode. */
- WR7146(P_DEBICFG, DEBI_CFG_SLAVE16 /* Local bus is 16 */
- /* bits wide. */
- | (DEBI_TOUT << DEBI_CFG_TOUT_BIT)
+ /* WR7146( (uint32_t)devpriv->pDacWBuf, val ); */
+ *devpriv->pDacWBuf = val;
- /* Declare DEBI */
- /* transfer timeout */
- /* interval. */
- |DEBI_SWAP /* Set up byte lane */
- /* steering. */
- | DEBI_CFG_INTEL); /* Intel-compatible */
- /* local bus (DEBI */
- /* never times out). */
- DEBUG("s626_attach: %d debi init -- %d\n",
- DEBI_CFG_SLAVE16 | (DEBI_TOUT << DEBI_CFG_TOUT_BIT) |
- DEBI_SWAP | DEBI_CFG_INTEL,
- DEBI_CFG_INTEL | DEBI_CFG_TOQ | DEBI_CFG_INCQ |
- DEBI_CFG_16Q);
+ /* enab the output DMA transfer. This will cause the DMAC to copy
+ * the DAC's data value to A2's output FIFO. The DMA transfer will
+ * then immediately terminate because the protection address is
+ * reached upon transfer of the first DWORD value.
+ */
+ MC_ENABLE(P_MC1, MC1_A2OUT);
- /* DEBI INIT S626 WR7146( P_DEBICFG, DEBI_CFG_INTEL | DEBI_CFG_TOQ */
- /* | DEBI_CFG_INCQ| DEBI_CFG_16Q); //end */
+ /* While the DMA transfer is executing ... */
- /* Paging is disabled. */
- WR7146(P_DEBIPAGE, DEBI_PAGE_DISABLE); /* Disable MMU paging. */
+ /* Reset Audio2 output FIFO's underflow flag (along with any other
+ * FIFO underflow/overflow flags). When set, this flag will
+ * indicate that we have emerged from slot 0.
+ */
+ WR7146(P_ISR, ISR_AFOU);
- /* Init GPIO so that ADC Start* is negated. */
- WR7146(P_GPIO, GPIO_BASE | GPIO1_HI);
+ /* Wait for the DMA transfer to finish so that there will be data
+ * available in the FIFO when time slot 1 tries to transfer a DWORD
+ * from the FIFO to the output buffer register. We test for DMA
+ * Done by polling the DMAC enable flag; this flag is automatically
+ * cleared when the transfer has finished.
+ */
+ while ((RR7146(P_MC1) & MC1_A2OUT) != 0)
+ ;
- /* IsBoardRevA is a boolean that indicates whether the board is RevA.
- *
- * VERSION 2.01 CHANGE: REV A & B BOARDS NOW SUPPORTED BY DYNAMIC
- * EEPROM ADDRESS SELECTION. Initialize the I2C interface, which
- * is used to access the onboard serial EEPROM. The EEPROM's I2C
- * DeviceAddress is hardwired to a value that is dependent on the
- * 626 board revision. On all board revisions, the EEPROM stores
- * TrimDAC calibration constants for analog I/O. On RevB and
- * higher boards, the DeviceAddress is hardwired to 0 to enable
- * the EEPROM to also store the PCI SubVendorID and SubDeviceID;
- * this is the address at which the SAA7146 expects a
- * configuration EEPROM to reside. On RevA boards, the EEPROM
- * device address, which is hardwired to 4, prevents the SAA7146
- * from retrieving PCI sub-IDs, so the SAA7146 uses its built-in
- * default values, instead.
- */
+ /* START THE OUTPUT STREAM TO THE TARGET DAC -------------------- */
- /* devpriv->I2Cards= IsBoardRevA ? 0xA8 : 0xA0; // Set I2C EEPROM */
- /* DeviceType (0xA0) */
- /* and DeviceAddress<<1. */
+ /* FIFO data is now available, so we enable execution of time slots
+ * 1 and higher by clearing the EOS flag in slot 0. Note that SD3
+ * will be shifted in and stored in FB_BUFFER2 for end-of-slot-list
+ * detection.
+ */
+ SETVECT(0, XSD2 | RSD3 | SIB_A2);
- devpriv->I2CAdrs = 0xA0; /* I2C device address for onboard */
- /* eeprom(revb) */
+ /* Wait for slot 1 to execute to ensure that the Packet will be
+ * transmitted. This is detected by polling the Audio2 output FIFO
+ * underflow flag, which will be set when slot 1 execution has
+ * finished transferring the DAC's data DWORD from the output FIFO
+ * to the output buffer register.
+ */
+ while ((RR7146(P_SSR) & SSR_AF2_OUT) == 0)
+ ;
- /* Issue an I2C ABORT command to halt any I2C operation in */
- /* progress and reset BUSY flag. */
- WR7146(P_I2CSTAT, I2C_CLKSEL | I2C_ABORT);
- /* Write I2C control: abort any I2C activity. */
- MC_ENABLE(P_MC2, MC2_UPLD_IIC);
- /* Invoke command upload */
- while ((RR7146(P_MC2) & MC2_UPLD_IIC) == 0)
- ;
- /* and wait for upload to complete. */
+ /* Set up to trap execution at slot 0 when the TSL sequencer cycles
+ * back to slot 0 after executing the EOS in slot 5. Also,
+ * simultaneously shift out and in the 0x00 that is ALWAYS the value
+ * stored in the last byte to be shifted out of the FIFO's DWORD
+ * buffer register.
+ */
+ SETVECT(0, XSD2 | XFIFO_2 | RSD2 | SIB_A2 | EOS);
- /* Per SAA7146 data sheet, write to STATUS reg twice to
- * reset all I2C error flags. */
- for (i = 0; i < 2; i++) {
- WR7146(P_I2CSTAT, I2C_CLKSEL);
- /* Write I2C control: reset error flags. */
- MC_ENABLE(P_MC2, MC2_UPLD_IIC); /* Invoke command upload */
- while (!MC_TEST(P_MC2, MC2_UPLD_IIC))
- ;
- /* and wait for upload to complete. */
- }
+ /* WAIT FOR THE TRANSACTION TO FINISH ----------------------- */
- /* Init audio interface functional attributes: set DAC/ADC
- * serial clock rates, invert DAC serial clock so that
- * DAC data setup times are satisfied, enable DAC serial
- * clock out.
+ /* Wait for the TSL to finish executing all time slots before
+ * exiting this function. We must do this so that the next DAC
+ * write doesn't start, thereby enabling clock/chip select signals:
+ *
+ * 1. Before the TSL sequence cycles back to slot 0, which disables
+ * the clock/cs signal gating and traps slot // list execution.
+ * we have not yet finished slot 5 then the clock/cs signals are
+ * still gated and we have not finished transmitting the stream.
+ *
+ * 2. While slots 2-5 are executing due to a late slot 0 trap. In
+ * this case, the slot sequence is currently repeating, but with
+ * clock/cs signals disabled. We must wait for slot 0 to trap
+ * execution before setting up the next DAC setpoint DMA transfer
+ * and enabling the clock/cs signals. To detect the end of slot 5,
+ * we test for the FB_BUFFER2 MSB contents to be equal to 0xFF. If
+ * the TSL has not yet finished executing slot 5 ...
+ */
+ if ((RR7146(P_FB_BUFFER2) & 0xFF000000) != 0) {
+ /* The trap was set on time and we are still executing somewhere
+ * in slots 2-5, so we now wait for slot 0 to execute and trap
+ * TSL execution. This is detected when FB_BUFFER2 MSB changes
+ * from 0xFF to 0x00, which slot 0 causes to happen by shifting
+ * out/in on SD2 the 0x00 that is always referenced by slot 5.
*/
+ while ((RR7146(P_FB_BUFFER2) & 0xFF000000) != 0)
+ ;
+ }
+ /* Either (1) we were too late setting the slot 0 trap; the TSL
+ * sequencer restarted slot 0 before we could set the EOS trap flag,
+ * or (2) we were not late and execution is now trapped at slot 0.
+ * In either case, we must now change slot 0 so that it will store
+ * value 0xFF (instead of 0x00) to FB_BUFFER2 next time it executes.
+ * In order to do this, we reprogram slot 0 so that it will shift in
+ * SD3, which is driven only by a pull-up resistor.
+ */
+ SETVECT(0, RSD3 | SIB_A2 | EOS);
- WR7146(P_ACON2, ACON2_INIT);
-
- /* Set up TSL1 slot list, which is used to control the
- * accumulation of ADC data: RSD1 = shift data in on SD1.
- * SIB_A1 = store data uint8_t at next available location in
- * FB BUFFER1 register. */
- WR7146(P_TSL1, RSD1 | SIB_A1);
- /* Fetch ADC high data uint8_t. */
- WR7146(P_TSL1 + 4, RSD1 | SIB_A1 | EOS);
- /* Fetch ADC low data uint8_t; end of TSL1. */
+ /* Wait for slot 0 to execute, at which time the TSL is setup for
+ * the next DAC write. This is detected when FB_BUFFER2 MSB changes
+ * from 0x00 to 0xFF.
+ */
+ while ((RR7146(P_FB_BUFFER2) & 0xFF000000) == 0)
+ ;
+}
- /* enab TSL1 slot list so that it executes all the time. */
- WR7146(P_ACON1, ACON1_ADCSTART);
+/* Private helper function: Write setpoint to an application DAC channel. */
+static void SetDAC(struct comedi_device *dev, uint16_t chan, short dacdata)
+{
+ register uint16_t signmask;
+ register uint32_t WSImage;
- /* Initialize RPS registers used for ADC. */
+ /* Adjust DAC data polarity and set up Polarity Control Register */
+ /* image. */
+ signmask = 1 << chan;
+ if (dacdata < 0) {
+ dacdata = -dacdata;
+ devpriv->Dacpol |= signmask;
+ } else
+ devpriv->Dacpol &= ~signmask;
- /* Physical start of RPS program. */
- WR7146(P_RPSADDR1, (uint32_t) devpriv->RPSBuf.PhysicalBase);
+ /* Limit DAC setpoint value to valid range. */
+ if ((uint16_t) dacdata > 0x1FFF)
+ dacdata = 0x1FFF;
- WR7146(P_RPSPAGE1, 0);
- /* RPS program performs no explicit mem writes. */
- WR7146(P_RPS1_TOUT, 0); /* Disable RPS timeouts. */
+ /* Set up TSL2 records (aka "vectors") for DAC update. Vectors V2
+ * and V3 transmit the setpoint to the target DAC. V4 and V5 send
+ * data to a non-existent TrimDac channel just to keep the clock
+ * running after sending data to the target DAC. This is necessary
+ * to eliminate the clock glitch that would otherwise occur at the
+ * end of the target DAC's serial data stream. When the sequence
+ * restarts at V0 (after executing V5), the gate array automatically
+ * disables gating for the DAC clock and all DAC chip selects.
+ */
- /* SAA7146 BUG WORKAROUND. Initialize SAA7146 ADC interface
- * to a known state by invoking ADCs until FB BUFFER 1
- * register shows that it is correctly receiving ADC data.
- * This is necessary because the SAA7146 ADC interface does
- * not start up in a defined state after a PCI reset.
- */
+ WSImage = (chan & 2) ? WS1 : WS2;
+ /* Choose DAC chip select to be asserted. */
+ SETVECT(2, XSD2 | XFIFO_1 | WSImage);
+ /* Slot 2: Transmit high data byte to target DAC. */
+ SETVECT(3, XSD2 | XFIFO_0 | WSImage);
+ /* Slot 3: Transmit low data byte to target DAC. */
+ SETVECT(4, XSD2 | XFIFO_3 | WS3);
+ /* Slot 4: Transmit to non-existent TrimDac channel to keep clock */
+ SETVECT(5, XSD2 | XFIFO_2 | WS3 | EOS);
+ /* Slot 5: running after writing target DAC's low data byte. */
-/* PollList = EOPL; // Create a simple polling */
-/* // list for analog input */
-/* // channel 0. */
-/* ResetADC( dev, &PollList ); */
+ /* Construct and transmit target DAC's serial packet:
+ * ( A10D DDDD ),( DDDD DDDD ),( 0x0F ),( 0x00 ) where A is chan<0>,
+ * and D<12:0> is the DAC setpoint. Append a WORD value (that writes
+ * to a non-existent TrimDac channel) that serves to keep the clock
+ * running after the packet has been sent to the target DAC.
+ */
+ SendDAC(dev, 0x0F000000
+ /* Continue clock after target DAC data (write to non-existent trimdac). */
+ | 0x00004000
+ /* Address the two main dual-DAC devices (TSL's chip select enables
+ * target device). */
+ | ((uint32_t) (chan & 1) << 15)
+ /* Address the DAC channel within the device. */
+ | (uint32_t) dacdata); /* Include DAC setpoint data. */
-/* s626_ai_rinsn(dev,dev->subdevices,NULL,data); //( &AdcData ); // */
-/* //Get initial ADC */
-/* //value. */
+}
-/* StartVal = data[0]; */
+static void WriteTrimDAC(struct comedi_device *dev, uint8_t LogicalChan,
+ uint8_t DacData)
+{
+ uint32_t chan;
-/* // VERSION 2.01 CHANGE: TIMEOUT ADDED TO PREVENT HANGED EXECUTION. */
-/* // Invoke ADCs until the new ADC value differs from the initial */
-/* // value or a timeout occurs. The timeout protects against the */
-/* // possibility that the driver is restarting and the ADC data is a */
-/* // fixed value resulting from the applied ADC analog input being */
-/* // unusually quiet or at the rail. */
+ /* Save the new setpoint in case the application needs to read it back later. */
+ devpriv->TrimSetpoint[LogicalChan] = (uint8_t) DacData;
-/* for ( index = 0; index < 500; index++ ) */
-/* { */
-/* s626_ai_rinsn(dev,dev->subdevices,NULL,data); */
-/* AdcData = data[0]; //ReadADC( &AdcData ); */
-/* if ( AdcData != StartVal ) */
-/* break; */
-/* } */
+ /* Map logical channel number to physical channel number. */
+ chan = (uint32_t) trimchan[LogicalChan];
- /* end initADC */
+ /* Set up TSL2 records for TrimDac write operation. All slots shift
+ * 0xFF in from pulled-up SD3 so that the end of the slot sequence
+ * can be detected.
+ */
- /* init the DAC interface */
+ SETVECT(2, XSD2 | XFIFO_1 | WS3);
+ /* Slot 2: Send high uint8_t to target TrimDac. */
+ SETVECT(3, XSD2 | XFIFO_0 | WS3);
+ /* Slot 3: Send low uint8_t to target TrimDac. */
+ SETVECT(4, XSD2 | XFIFO_3 | WS1);
+ /* Slot 4: Send NOP high uint8_t to DAC0 to keep clock running. */
+ SETVECT(5, XSD2 | XFIFO_2 | WS1 | EOS);
+ /* Slot 5: Send NOP low uint8_t to DAC0. */
- /* Init Audio2's output DMAC attributes: burst length = 1
- * DWORD, threshold = 1 DWORD.
- */
- WR7146(P_PCI_BT_A, 0);
+ /* Construct and transmit target DAC's serial packet:
+ * ( 0000 AAAA ), ( DDDD DDDD ),( 0x00 ),( 0x00 ) where A<3:0> is the
+ * DAC channel's address, and D<7:0> is the DAC setpoint. Append a
+ * WORD value (that writes a channel 0 NOP command to a non-existent
+ * main DAC channel) that serves to keep the clock running after the
+ * packet has been sent to the target DAC.
+ */
- /* Init Audio2's output DMA physical addresses. The protection
- * address is set to 1 DWORD past the base address so that a
- * single DWORD will be transferred each time a DMA transfer is
- * enabled. */
+ /* Address the DAC channel within the trimdac device. */
+ SendDAC(dev, ((uint32_t) chan << 8)
+ | (uint32_t) DacData); /* Include DAC setpoint data. */
+}
- pPhysBuf =
- devpriv->ANABuf.PhysicalBase +
- (DAC_WDMABUF_OS * sizeof(uint32_t));
+static void LoadTrimDACs(struct comedi_device *dev)
+{
+ register uint8_t i;
- WR7146(P_BASEA2_OUT, (uint32_t) pPhysBuf); /* Buffer base adrs. */
- WR7146(P_PROTA2_OUT, (uint32_t) (pPhysBuf + sizeof(uint32_t))); /* Protection address. */
+ /* Copy TrimDac setpoint values from EEPROM to TrimDacs. */
+ for (i = 0; i < ARRAY_SIZE(trimchan); i++)
+ WriteTrimDAC(dev, i, I2Cread(dev, trimadrs[i]));
+}
- /* Cache Audio2's output DMA buffer logical address. This is
- * where DAC data is buffered for A2 output DMA transfers. */
- devpriv->pDacWBuf =
- (uint32_t *) devpriv->ANABuf.LogicalBase + DAC_WDMABUF_OS;
+/* ****** COUNTER FUNCTIONS ******* */
+/* All counter functions address a specific counter by means of the
+ * "Counter" argument, which is a logical counter number. The Counter
+ * argument may have any of the following legal values: 0=0A, 1=1A,
+ * 2=2A, 3=0B, 4=1B, 5=2B.
+ */
- /* Audio2's output channels does not use paging. The protection
- * violation handling bit is set so that the DMAC will
- * automatically halt and its PCI address pointer will be reset
- * when the protection address is reached. */
+/* Read a counter's output latch. */
+static uint32_t ReadLatch(struct comedi_device *dev, struct enc_private *k)
+{
+ register uint32_t value;
- WR7146(P_PAGEA2_OUT, 8);
+ /* Latch counts and fetch LSW of latched counts value. */
+ value = (uint32_t) DEBIread(dev, k->MyLatchLsw);
- /* Initialize time slot list 2 (TSL2), which is used to control
- * the clock generation for and serialization of data to be sent
- * to the DAC devices. Slot 0 is a NOP that is used to trap TSL
- * execution; this permits other slots to be safely modified
- * without first turning off the TSL sequencer (which is
- * apparently impossible to do). Also, SD3 (which is driven by a
- * pull-up resistor) is shifted in and stored to the MSB of
- * FB_BUFFER2 to be used as evidence that the slot sequence has
- * not yet finished executing.
- */
+ /* Fetch MSW of latched counts and combine with LSW. */
+ value |= ((uint32_t) DEBIread(dev, k->MyLatchLsw + 2) << 16);
- SETVECT(0, XSD2 | RSD3 | SIB_A2 | EOS);
- /* Slot 0: Trap TSL execution, shift 0xFF into FB_BUFFER2. */
+ /* Return latched counts. */
+ return value;
+}
- /* Initialize slot 1, which is constant. Slot 1 causes a
- * DWORD to be transferred from audio channel 2's output FIFO
- * to the FIFO's output buffer so that it can be serialized
- * and sent to the DAC during subsequent slots. All remaining
- * slots are dynamically populated as required by the target
- * DAC device.
- */
- SETVECT(1, LF_A2);
- /* Slot 1: Fetch DWORD from Audio2's output FIFO. */
+/* Return/set a counter pair's latch trigger source. 0: On read
+ * access, 1: A index latches A, 2: B index latches B, 3: A overflow
+ * latches B.
+ */
+static void SetLatchSource(struct comedi_device *dev, struct enc_private *k,
+ uint16_t value)
+{
+ DEBIreplace(dev, k->MyCRB,
+ (uint16_t) (~(CRBMSK_INTCTRL | CRBMSK_LATCHSRC)),
+ (uint16_t) (value << CRBBIT_LATCHSRC));
+}
- /* Start DAC's audio interface (TSL2) running. */
- WR7146(P_ACON1, ACON1_DACSTART);
+/* Write value into counter preload register. */
+static void Preload(struct comedi_device *dev, struct enc_private *k,
+ uint32_t value)
+{
+ DEBIwrite(dev, (uint16_t) (k->MyLatchLsw), (uint16_t) value);
+ DEBIwrite(dev, (uint16_t) (k->MyLatchLsw + 2),
+ (uint16_t) (value >> 16));
+}
- /* end init DAC interface */
+static unsigned int s626_ai_reg_to_uint(int data)
+{
+ unsigned int tempdata;
- /* Init Trim DACs to calibrated values. Do it twice because the
- * SAA7146 audio channel does not always reset properly and
- * sometimes causes the first few TrimDAC writes to malfunction.
- */
+ tempdata = (data >> 18);
+ if (tempdata & 0x2000)
+ tempdata &= 0x1fff;
+ else
+ tempdata += (1 << 13);
- LoadTrimDACs(dev);
- LoadTrimDACs(dev); /* Insurance. */
+ return tempdata;
+}
- /* Manually init all gate array hardware in case this is a soft
- * reset (we have no way of determining whether this is a warm
- * or cold start). This is necessary because the gate array will
- * reset only in response to a PCI hard reset; there is no soft
- * reset function. */
+/* static unsigned int s626_uint_to_reg(struct comedi_subdevice *s, int data){ */
+/* return 0; */
+/* } */
- /* Init all DAC outputs to 0V and init all DAC setpoint and
- * polarity images.
- */
- for (chan = 0; chan < S626_DAC_CHANNELS; chan++)
- SetDAC(dev, chan, 0);
+static int s626_dio_set_irq(struct comedi_device *dev, unsigned int chan)
+{
+ unsigned int group;
+ unsigned int bitmask;
+ unsigned int status;
- /* Init image of WRMISC2 Battery Charger Enabled control bit.
- * This image is used when the state of the charger control bit,
- * which has no direct hardware readback mechanism, is queried.
- */
- devpriv->ChargeEnabled = 0;
+ /* select dio bank */
+ group = chan / 16;
+ bitmask = 1 << (chan - (16 * group));
- /* Init image of watchdog timer interval in WRMISC2. This image
- * maintains the value of the control bits of MISC2 are
- * continuously reset to zero as long as the WD timer is disabled.
- */
- devpriv->WDInterval = 0;
+ /* set channel to capture positive edge */
+ status = DEBIread(dev,
+ ((struct dio_private *)(dev->subdevices + 2 +
+ group)->private)->RDEdgSel);
+ DEBIwrite(dev,
+ ((struct dio_private *)(dev->subdevices + 2 +
+ group)->private)->WREdgSel,
+ bitmask | status);
- /* Init Counter Interrupt enab mask for RDMISC2. This mask is
- * applied against MISC2 when testing to determine which timer
- * events are requesting interrupt service.
- */
- devpriv->CounterIntEnabs = 0;
+ /* enable interrupt on selected channel */
+ status = DEBIread(dev,
+ ((struct dio_private *)(dev->subdevices + 2 +
+ group)->private)->RDIntSel);
+ DEBIwrite(dev,
+ ((struct dio_private *)(dev->subdevices + 2 +
+ group)->private)->WRIntSel,
+ bitmask | status);
- /* Init counters. */
- CountersInit(dev);
+ /* enable edge capture write command */
+ DEBIwrite(dev, LP_MISC1, MISC1_EDCAP);
- /* Without modifying the state of the Battery Backup enab, disable
- * the watchdog timer, set DIO channels 0-5 to operate in the
- * standard DIO (vs. counter overflow) mode, disable the battery
- * charger, and reset the watchdog interval selector to zero.
- */
- WriteMISC2(dev, (uint16_t) (DEBIread(dev,
- LP_RDMISC2) &
- MISC2_BATT_ENABLE));
+ /* enable edge capture on selected channel */
+ status = DEBIread(dev,
+ ((struct dio_private *)(dev->subdevices + 2 +
+ group)->private)->RDCapSel);
+ DEBIwrite(dev,
+ ((struct dio_private *)(dev->subdevices + 2 +
+ group)->private)->WRCapSel,
+ bitmask | status);
- /* Initialize the digital I/O subsystem. */
- s626_dio_init(dev);
+ return 0;
+}
- /* enable interrupt test */
- /* writel(IRQ_GPIO3 | IRQ_RPS1,devpriv->base_addr+P_IER); */
- }
+static int s626_dio_reset_irq(struct comedi_device *dev, unsigned int group,
+ unsigned int mask)
+{
+ /* disable edge capture write command */
+ DEBIwrite(dev, LP_MISC1, MISC1_NOEDCAP);
- DEBUG("s626_attach: comedi%d s626 attached %04x\n", dev->minor,
- (uint32_t) devpriv->base_addr);
+ /* enable edge capture on selected channel */
+ DEBIwrite(dev,
+ ((struct dio_private *)(dev->subdevices + 2 +
+ group)->private)->WRCapSel, mask);
- return 1;
+ return 0;
}
-static unsigned int s626_ai_reg_to_uint(int data)
+static int s626_dio_clear_irq(struct comedi_device *dev)
{
- unsigned int tempdata;
+ unsigned int group;
- tempdata = (data >> 18);
- if (tempdata & 0x2000)
- tempdata &= 0x1fff;
- else
- tempdata += (1 << 13);
+ /* disable edge capture write command */
+ DEBIwrite(dev, LP_MISC1, MISC1_NOEDCAP);
- return tempdata;
-}
+ for (group = 0; group < S626_DIO_BANKS; group++) {
+ /* clear pending events and interrupt */
+ DEBIwrite(dev,
+ ((struct dio_private *)(dev->subdevices + 2 +
+ group)->private)->WRCapSel,
+ 0xffff);
+ }
-/* static unsigned int s626_uint_to_reg(struct comedi_subdevice *s, int data){ */
-/* return 0; */
-/* } */
+ return 0;
+}
static irqreturn_t s626_irq_handler(int irq, void *d)
{
@@ -1048,8 +789,6 @@ static irqreturn_t s626_irq_handler(int irq, void *d)
uint8_t group;
uint16_t irqbit;
- DEBUG("s626_irq_handler: interrupt request received!!!\n");
-
if (dev->attached == 0)
return IRQ_NONE;
/* lock to avoid race with comedi_poll */
@@ -1067,14 +806,8 @@ static irqreturn_t s626_irq_handler(int irq, void *d)
/* clear interrupt */
writel(irqtype, devpriv->base_addr + P_ISR);
- /* do somethings */
- DEBUG("s626_irq_handler: interrupt type %d\n", irqtype);
-
switch (irqtype) {
case IRQ_RPS1: /* end_of_scan occurs */
-
- DEBUG("s626_irq_handler: RPS1 irq detected\n");
-
/* manage ai subdevice */
s = dev->subdevices;
cmd = &(s->async->cmd);
@@ -1097,9 +830,6 @@ static irqreturn_t s626_irq_handler(int irq, void *d)
if (cfc_write_to_buffer(s, tempdata) == 0)
printk
("s626_irq_handler: cfc_write_to_buffer error!\n");
-
- DEBUG("s626_irq_handler: ai channel %d acquired: %d\n",
- i, tempdata);
}
/* end of scan occurs */
@@ -1120,23 +850,12 @@ static irqreturn_t s626_irq_handler(int irq, void *d)
irqstatus = 0;
}
- if (devpriv->ai_cmd_running && cmd->scan_begin_src == TRIG_EXT) {
- DEBUG
- ("s626_irq_handler: enable interrupt on dio channel %d\n",
- cmd->scan_begin_arg);
-
+ if (devpriv->ai_cmd_running && cmd->scan_begin_src == TRIG_EXT)
s626_dio_set_irq(dev, cmd->scan_begin_arg);
-
- DEBUG("s626_irq_handler: External trigger is set!!!\n");
- }
/* tell comedi that data is there */
- DEBUG("s626_irq_handler: events %d\n", s->async->events);
comedi_event(dev, s);
break;
case IRQ_GPIO3: /* check dio and conter interrupt */
-
- DEBUG("s626_irq_handler: GPIO3 irq detected\n");
-
/* manage ai subdevice */
s = dev->subdevices;
cmd = &(s->async->cmd);
@@ -1156,36 +875,18 @@ static irqreturn_t s626_irq_handler(int irq, void *d)
/* check if interrupt is generated from dio channels */
if (irqbit) {
s626_dio_reset_irq(dev, group, irqbit);
- DEBUG
- ("s626_irq_handler: check interrupt on dio group %d %d\n",
- group, i);
if (devpriv->ai_cmd_running) {
/* check if interrupt is an ai acquisition start trigger */
if ((irqbit >> (cmd->start_arg -
(16 * group)))
== 1 && cmd->start_src == TRIG_EXT) {
- DEBUG
- ("s626_irq_handler: Edge capture interrupt received from channel %d\n",
- cmd->start_arg);
-
/* Start executing the RPS program. */
MC_ENABLE(P_MC1, MC1_ERPS1);
- DEBUG
- ("s626_irq_handler: acquisition start triggered!!!\n");
-
if (cmd->scan_begin_src ==
TRIG_EXT) {
- DEBUG
- ("s626_ai_cmd: enable interrupt on dio channel %d\n",
- cmd->
- scan_begin_arg);
-
s626_dio_set_irq(dev,
cmd->scan_begin_arg);
-
- DEBUG
- ("s626_irq_handler: External scan trigger is set!!!\n");
}
}
if ((irqbit >> (cmd->scan_begin_arg -
@@ -1193,33 +894,16 @@ static irqreturn_t s626_irq_handler(int irq, void *d)
== 1
&& cmd->scan_begin_src ==
TRIG_EXT) {
- DEBUG
- ("s626_irq_handler: Edge capture interrupt received from channel %d\n",
- cmd->scan_begin_arg);
-
/* Trigger ADC scan loop start by setting RPS Signal 0. */
MC_ENABLE(P_MC2, MC2_ADC_RPS);
- DEBUG
- ("s626_irq_handler: scan triggered!!! %d\n",
- devpriv->ai_sample_count);
if (cmd->convert_src ==
TRIG_EXT) {
-
- DEBUG
- ("s626_ai_cmd: enable interrupt on dio channel %d group %d\n",
- cmd->convert_arg -
- (16 * group),
- group);
-
devpriv->ai_convert_count
= cmd->chanlist_len;
s626_dio_set_irq(dev,
cmd->convert_arg);
-
- DEBUG
- ("s626_irq_handler: External convert trigger is set!!!\n");
}
if (cmd->convert_src ==
@@ -1235,32 +919,15 @@ static irqreturn_t s626_irq_handler(int irq, void *d)
(16 * group)))
== 1
&& cmd->convert_src == TRIG_EXT) {
- DEBUG
- ("s626_irq_handler: Edge capture interrupt received from channel %d\n",
- cmd->convert_arg);
-
/* Trigger ADC scan loop start by setting RPS Signal 0. */
MC_ENABLE(P_MC2, MC2_ADC_RPS);
- DEBUG
- ("s626_irq_handler: adc convert triggered!!!\n");
-
devpriv->ai_convert_count--;
if (devpriv->ai_convert_count >
0) {
-
- DEBUG
- ("s626_ai_cmd: enable interrupt on dio channel %d group %d\n",
- cmd->convert_arg -
- (16 * group),
- group);
-
s626_dio_set_irq(dev,
cmd->convert_arg);
-
- DEBUG
- ("s626_irq_handler: External trigger is set!!!\n");
}
}
}
@@ -1272,44 +939,31 @@ static irqreturn_t s626_irq_handler(int irq, void *d)
irqbit = DEBIread(dev, LP_RDMISC2);
/* check interrupt on counters */
- DEBUG("s626_irq_handler: check counters interrupt %d\n",
- irqbit);
-
if (irqbit & IRQ_COINT1A) {
- DEBUG
- ("s626_irq_handler: interrupt on counter 1A overflow\n");
k = &encpriv[0];
/* clear interrupt capture flag */
k->ResetCapFlags(dev, k);
}
if (irqbit & IRQ_COINT2A) {
- DEBUG
- ("s626_irq_handler: interrupt on counter 2A overflow\n");
k = &encpriv[1];
/* clear interrupt capture flag */
k->ResetCapFlags(dev, k);
}
if (irqbit & IRQ_COINT3A) {
- DEBUG
- ("s626_irq_handler: interrupt on counter 3A overflow\n");
k = &encpriv[2];
/* clear interrupt capture flag */
k->ResetCapFlags(dev, k);
}
if (irqbit & IRQ_COINT1B) {
- DEBUG
- ("s626_irq_handler: interrupt on counter 1B overflow\n");
k = &encpriv[3];
/* clear interrupt capture flag */
k->ResetCapFlags(dev, k);
}
if (irqbit & IRQ_COINT2B) {
- DEBUG
- ("s626_irq_handler: interrupt on counter 2B overflow\n");
k = &encpriv[4];
/* clear interrupt capture flag */
@@ -1321,34 +975,23 @@ static irqreturn_t s626_irq_handler(int irq, void *d)
k->SetEnable(dev, k, CLKENAB_INDEX);
if (cmd->convert_src == TRIG_TIMER) {
- DEBUG
- ("s626_irq_handler: conver timer trigger!!! %d\n",
- devpriv->ai_convert_count);
-
/* Trigger ADC scan loop start by setting RPS Signal 0. */
MC_ENABLE(P_MC2, MC2_ADC_RPS);
}
}
}
if (irqbit & IRQ_COINT3B) {
- DEBUG
- ("s626_irq_handler: interrupt on counter 3B overflow\n");
k = &encpriv[5];
/* clear interrupt capture flag */
k->ResetCapFlags(dev, k);
if (cmd->scan_begin_src == TRIG_TIMER) {
- DEBUG
- ("s626_irq_handler: scan timer trigger!!!\n");
-
/* Trigger ADC scan loop start by setting RPS Signal 0. */
MC_ENABLE(P_MC2, MC2_ADC_RPS);
}
if (cmd->convert_src == TRIG_TIMER) {
- DEBUG
- ("s626_irq_handler: convert timer trigger is set\n");
k = &encpriv[4];
devpriv->ai_convert_count = cmd->chanlist_len;
k->SetEnable(dev, k, CLKENAB_ALWAYS);
@@ -1359,56 +1002,14 @@ static irqreturn_t s626_irq_handler(int irq, void *d)
/* enable interrupt */
writel(irqstatus, devpriv->base_addr + P_IER);
- DEBUG("s626_irq_handler: exit interrupt service routine.\n");
-
spin_unlock_irqrestore(&dev->spinlock, flags);
return IRQ_HANDLED;
}
-static int s626_detach(struct comedi_device *dev)
-{
- if (devpriv) {
- /* stop ai_command */
- devpriv->ai_cmd_running = 0;
-
- if (devpriv->base_addr) {
- /* interrupt mask */
- WR7146(P_IER, 0); /* Disable master interrupt. */
- WR7146(P_ISR, IRQ_GPIO3 | IRQ_RPS1); /* Clear board's IRQ status flag. */
-
- /* Disable the watchdog timer and battery charger. */
- WriteMISC2(dev, 0);
-
- /* Close all interfaces on 7146 device. */
- WR7146(P_MC1, MC1_SHUTDOWN);
- WR7146(P_ACON1, ACON1_BASE);
-
- CloseDMAB(dev, &devpriv->RPSBuf, DMABUF_SIZE);
- CloseDMAB(dev, &devpriv->ANABuf, DMABUF_SIZE);
- }
-
- if (dev->irq)
- free_irq(dev->irq, dev);
-
- if (devpriv->base_addr)
- iounmap(devpriv->base_addr);
-
- if (devpriv->pdev) {
- if (devpriv->got_regions)
- comedi_pci_disable(devpriv->pdev);
- pci_dev_put(devpriv->pdev);
- }
- }
-
- DEBUG("s626_detach: S626 detached!\n");
-
- return 0;
-}
-
/*
* this functions build the RPS program for hardware driven acquistion
*/
-void ResetADC(struct comedi_device *dev, uint8_t * ppl)
+static void ResetADC(struct comedi_device *dev, uint8_t *ppl)
{
register uint32_t *pRPS;
uint32_t JmpAdrs;
@@ -1429,7 +1030,6 @@ void ResetADC(struct comedi_device *dev, uint8_t * ppl)
/* Construct RPS program in RPSBuf DMA buffer */
if (cmd != NULL && cmd->scan_begin_src != TRIG_FOLLOW) {
- DEBUG("ResetADC: scan_begin pause inserted\n");
/* Wait for Start trigger. */
*pRPS++ = RPS_PAUSE | RPS_SIGADC;
*pRPS++ = RPS_CLRSIGNAL | RPS_SIGADC;
@@ -1519,7 +1119,6 @@ void ResetADC(struct comedi_device *dev, uint8_t * ppl)
}
if (cmd != NULL && cmd->convert_src != TRIG_NOW) {
- DEBUG("ResetADC: convert pause inserted\n");
/* Wait for Start trigger. */
*pRPS++ = RPS_PAUSE | RPS_SIGADC;
*pRPS++ = RPS_CLRSIGNAL | RPS_SIGADC;
@@ -1551,7 +1150,6 @@ void ResetADC(struct comedi_device *dev, uint8_t * ppl)
break; /* Exit poll list processing loop. */
}
}
- DEBUG("ResetADC: ADC items %d\n", devpriv->AdcItems);
/* VERSION 2.01 CHANGE: DELAY CHANGED FROM 250NS to 2US. Allow the
* ADC to stabilize for 2 microseconds before starting the final
@@ -1588,7 +1186,6 @@ void ResetADC(struct comedi_device *dev, uint8_t * ppl)
/* invoke interrupt */
if (devpriv->ai_cmd_running == 1) {
- DEBUG("ResetADC: insert irq in ADC RPS task\n");
*pRPS++ = RPS_IRQ;
}
/* Restart RPS program at its beginning. */
@@ -1612,8 +1209,6 @@ static int s626_ai_insn_config(struct comedi_device *dev,
/* register uint8_t i; */
/* register int32_t *readaddr; */
-/* DEBUG("as626_ai_rinsn: ai_rinsn enter\n"); */
-
/* Trigger ADC scan loop start by setting RPS Signal 0. */
/* MC_ENABLE( P_MC2, MC2_ADC_RPS ); */
@@ -1629,11 +1224,9 @@ static int s626_ai_insn_config(struct comedi_device *dev,
/* Convert ADC data to 16-bit integer values and copy to application buffer. */
/* for ( i = 0; i < devpriv->AdcItems; i++ ) { */
/* *data = s626_ai_reg_to_uint( *readaddr++ ); */
-/* DEBUG("s626_ai_rinsn: data %d\n",*data); */
/* data++; */
/* } */
-/* DEBUG("s626_ai_rinsn: ai_rinsn escape\n"); */
/* return i; */
/* } */
@@ -1653,8 +1246,6 @@ static int s626_ai_insn_read(struct comedi_device *dev,
* corresponding interrupt to be generated if enabled
*/
- DEBUG("s626_ai_insn_read: entering\n");
-
/* Convert application's ADC specification into form
* appropriate for register programming.
*/
@@ -1731,8 +1322,6 @@ static int s626_ai_insn_read(struct comedi_device *dev,
if (n != 0)
data[n - 1] = s626_ai_reg_to_uint(RR7146(P_FB_BUFFER1));
- DEBUG("s626_ai_insn_read: samples %d, data %d\n", n, data[n - 1]);
-
return n;
}
@@ -1759,18 +1348,76 @@ static int s626_ai_inttrig(struct comedi_device *dev,
if (trignum != 0)
return -EINVAL;
- DEBUG("s626_ai_inttrig: trigger adc start...");
-
/* Start executing the RPS program. */
MC_ENABLE(P_MC1, MC1_ERPS1);
s->async->inttrig = NULL;
- DEBUG(" done\n");
-
return 1;
}
+/* This function doesn't require a particular form, this is just what
+ * happens to be used in some of the drivers. It should convert ns
+ * nanoseconds to a counter value suitable for programming the device.
+ * Also, it should adjust ns so that it cooresponds to the actual time
+ * that the device will use. */
+static int s626_ns_to_timer(int *nanosec, int round_mode)
+{
+ int divider, base;
+
+ base = 500; /* 2MHz internal clock */
+
+ switch (round_mode) {
+ case TRIG_ROUND_NEAREST:
+ default:
+ divider = (*nanosec + base / 2) / base;
+ break;
+ case TRIG_ROUND_DOWN:
+ divider = (*nanosec) / base;
+ break;
+ case TRIG_ROUND_UP:
+ divider = (*nanosec + base - 1) / base;
+ break;
+ }
+
+ *nanosec = base * divider;
+ return divider - 1;
+}
+
+static void s626_timer_load(struct comedi_device *dev, struct enc_private *k,
+ int tick)
+{
+ uint16_t Setup = (LOADSRC_INDX << BF_LOADSRC) | /* Preload upon */
+ /* index. */
+ (INDXSRC_SOFT << BF_INDXSRC) | /* Disable hardware index. */
+ (CLKSRC_TIMER << BF_CLKSRC) | /* Operating mode is Timer. */
+ (CLKPOL_POS << BF_CLKPOL) | /* Active high clock. */
+ (CNTDIR_DOWN << BF_CLKPOL) | /* Count direction is Down. */
+ (CLKMULT_1X << BF_CLKMULT) | /* Clock multiplier is 1x. */
+ (CLKENAB_INDEX << BF_CLKENAB);
+ uint16_t valueSrclatch = LATCHSRC_A_INDXA;
+ /* uint16_t enab=CLKENAB_ALWAYS; */
+
+ k->SetMode(dev, k, Setup, FALSE);
+
+ /* Set the preload register */
+ Preload(dev, k, tick);
+
+ /* Software index pulse forces the preload register to load */
+ /* into the counter */
+ k->SetLoadTrig(dev, k, 0);
+ k->PulseIndex(dev, k);
+
+ /* set reload on counter overflow */
+ k->SetLoadTrig(dev, k, 1);
+
+ /* set interrupt on overflow */
+ k->SetIntSrc(dev, k, INTSRC_OVER);
+
+ SetLatchSource(dev, k, valueSrclatch);
+ /* k->SetEnable(dev,k,(uint16_t)(enab != 0)); */
+}
+
/* TO COMPLETE */
static int s626_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
{
@@ -1780,8 +1427,6 @@ static int s626_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
struct enc_private *k;
int tick;
- DEBUG("s626_ai_cmd: entering command function\n");
-
if (devpriv->ai_cmd_running) {
printk(KERN_ERR "s626_ai_cmd: Another ai_cmd is running %d\n",
dev->minor);
@@ -1801,12 +1446,8 @@ static int s626_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
devpriv->ai_cmd_running = 0;
/* test if cmd is valid */
- if (cmd == NULL) {
- DEBUG("s626_ai_cmd: NULL command\n");
+ if (cmd == NULL)
return -EINVAL;
- } else {
- DEBUG("s626_ai_cmd: command received!!!\n");
- }
if (dev->irq == 0) {
comedi_error(dev,
@@ -1830,18 +1471,11 @@ static int s626_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
/* load timer value and enable interrupt */
s626_timer_load(dev, k, tick);
k->SetEnable(dev, k, CLKENAB_ALWAYS);
-
- DEBUG("s626_ai_cmd: scan trigger timer is set with value %d\n",
- tick);
-
break;
case TRIG_EXT:
/* set the digital line and interrupt for scan trigger */
if (cmd->start_src != TRIG_EXT)
s626_dio_set_irq(dev, cmd->scan_begin_arg);
-
- DEBUG("s626_ai_cmd: External scan trigger is set!!!\n");
-
break;
}
@@ -1857,19 +1491,12 @@ static int s626_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
/* load timer value and enable interrupt */
s626_timer_load(dev, k, tick);
k->SetEnable(dev, k, CLKENAB_INDEX);
-
- DEBUG
- ("s626_ai_cmd: convert trigger timer is set with value %d\n",
- tick);
break;
case TRIG_EXT:
/* set the digital line and interrupt for convert trigger */
if (cmd->scan_begin_src != TRIG_EXT
&& cmd->start_src == TRIG_EXT)
s626_dio_set_irq(dev, cmd->convert_arg);
-
- DEBUG("s626_ai_cmd: External convert trigger is set!!!\n");
-
break;
}
@@ -1896,15 +1523,12 @@ static int s626_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
/* Start executing the RPS program. */
MC_ENABLE(P_MC1, MC1_ERPS1);
- DEBUG("s626_ai_cmd: ADC triggered\n");
s->async->inttrig = NULL;
break;
case TRIG_EXT:
/* configure DIO channel for acquisition trigger */
s626_dio_set_irq(dev, cmd->start_arg);
- DEBUG("s626_ai_cmd: External start trigger is set!!!\n");
-
s->async->inttrig = NULL;
break;
case TRIG_INT:
@@ -1915,8 +1539,6 @@ static int s626_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
/* enable interrupt */
writel(IRQ_GPIO3 | IRQ_RPS1, devpriv->base_addr + P_IER);
- DEBUG("s626_ai_cmd: command function terminated\n");
-
return 0;
}
@@ -2103,34 +1725,6 @@ static int s626_ai_cancel(struct comedi_device *dev, struct comedi_subdevice *s)
return 0;
}
-/* This function doesn't require a particular form, this is just what
- * happens to be used in some of the drivers. It should convert ns
- * nanoseconds to a counter value suitable for programming the device.
- * Also, it should adjust ns so that it cooresponds to the actual time
- * that the device will use. */
-static int s626_ns_to_timer(int *nanosec, int round_mode)
-{
- int divider, base;
-
- base = 500; /* 2MHz internal clock */
-
- switch (round_mode) {
- case TRIG_ROUND_NEAREST:
- default:
- divider = (*nanosec + base / 2) / base;
- break;
- case TRIG_ROUND_DOWN:
- divider = (*nanosec) / base;
- break;
- case TRIG_ROUND_UP:
- divider = (*nanosec + base - 1) / base;
- break;
- }
-
- *nanosec = base * divider;
- return divider - 1;
-}
-
static int s626_ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
@@ -2187,7 +1781,6 @@ static void s626_dio_init(struct comedi_device *dev)
DEBIwrite(dev, diopriv->WRDOut, 0); /* Program all outputs */
/* to inactive state. */
}
- DEBUG("s626_dio_init: DIO initialized\n");
}
/* DIO devices are slightly special. Although it is possible to
@@ -2200,18 +1793,6 @@ static int s626_dio_insn_bits(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
-
- /* Length of data must be 2 (mask and new data, see below) */
- if (insn->n == 0)
- return 0;
-
- if (insn->n != 2) {
- printk
- ("comedi%d: s626: s626_dio_insn_bits(): Invalid instruction length\n",
- dev->minor);
- return -EINVAL;
- }
-
/*
* The insn data consists of a mask in data[0] and the new data in
* data[1]. The mask defines which bits we are concerning about.
@@ -2232,7 +1813,7 @@ static int s626_dio_insn_bits(struct comedi_device *dev,
}
data[1] = DEBIread(dev, diopriv->RDDIn);
- return 2;
+ return insn->n;
}
static int s626_dio_insn_config(struct comedi_device *dev,
@@ -2263,87 +1844,6 @@ static int s626_dio_insn_config(struct comedi_device *dev,
return 1;
}
-static int s626_dio_set_irq(struct comedi_device *dev, unsigned int chan)
-{
- unsigned int group;
- unsigned int bitmask;
- unsigned int status;
-
- /* select dio bank */
- group = chan / 16;
- bitmask = 1 << (chan - (16 * group));
- DEBUG("s626_dio_set_irq: enable interrupt on dio channel %d group %d\n",
- chan - (16 * group), group);
-
- /* set channel to capture positive edge */
- status = DEBIread(dev,
- ((struct dio_private *)(dev->subdevices + 2 +
- group)->private)->RDEdgSel);
- DEBIwrite(dev,
- ((struct dio_private *)(dev->subdevices + 2 +
- group)->private)->WREdgSel,
- bitmask | status);
-
- /* enable interrupt on selected channel */
- status = DEBIread(dev,
- ((struct dio_private *)(dev->subdevices + 2 +
- group)->private)->RDIntSel);
- DEBIwrite(dev,
- ((struct dio_private *)(dev->subdevices + 2 +
- group)->private)->WRIntSel,
- bitmask | status);
-
- /* enable edge capture write command */
- DEBIwrite(dev, LP_MISC1, MISC1_EDCAP);
-
- /* enable edge capture on selected channel */
- status = DEBIread(dev,
- ((struct dio_private *)(dev->subdevices + 2 +
- group)->private)->RDCapSel);
- DEBIwrite(dev,
- ((struct dio_private *)(dev->subdevices + 2 +
- group)->private)->WRCapSel,
- bitmask | status);
-
- return 0;
-}
-
-static int s626_dio_reset_irq(struct comedi_device *dev, unsigned int group,
- unsigned int mask)
-{
- DEBUG
- ("s626_dio_reset_irq: disable interrupt on dio channel %d group %d\n",
- mask, group);
-
- /* disable edge capture write command */
- DEBIwrite(dev, LP_MISC1, MISC1_NOEDCAP);
-
- /* enable edge capture on selected channel */
- DEBIwrite(dev,
- ((struct dio_private *)(dev->subdevices + 2 +
- group)->private)->WRCapSel, mask);
-
- return 0;
-}
-
-static int s626_dio_clear_irq(struct comedi_device *dev)
-{
- unsigned int group;
-
- /* disable edge capture write command */
- DEBIwrite(dev, LP_MISC1, MISC1_NOEDCAP);
-
- for (group = 0; group < S626_DIO_BANKS; group++) {
- /* clear pending events and interrupt */
- DEBIwrite(dev,
- ((struct dio_private *)(dev->subdevices + 2 +
- group)->private)->WRCapSel,
- 0xffff);
- }
-
- return 0;
-}
-
/* Now this function initializes the value of the counter (data[0])
and set the subdevice. To complete with trigger and interrupt
configuration */
@@ -2365,8 +1865,6 @@ static int s626_enc_insn_config(struct comedi_device *dev,
uint16_t enab = CLKENAB_ALWAYS;
struct enc_private *k = &encpriv[CR_CHAN(insn->chanspec)];
- DEBUG("s626_enc_insn_config: encoder config\n");
-
/* (data==NULL) ? (Preloadvalue=0) : (Preloadvalue=data[0]); */
k->SetMode(dev, k, Setup, TRUE);
@@ -2386,14 +1884,9 @@ static int s626_enc_insn_read(struct comedi_device *dev,
int n;
struct enc_private *k = &encpriv[CR_CHAN(insn->chanspec)];
- DEBUG("s626_enc_insn_read: encoder read channel %d\n",
- CR_CHAN(insn->chanspec));
-
for (n = 0; n < insn->n; n++)
data[n] = ReadLatch(dev, k);
- DEBUG("s626_enc_insn_read: encoder sample %d\n", data[n]);
-
return n;
}
@@ -2404,9 +1897,6 @@ static int s626_enc_insn_write(struct comedi_device *dev,
struct enc_private *k = &encpriv[CR_CHAN(insn->chanspec)];
- DEBUG("s626_enc_insn_write: encoder write channel %d\n",
- CR_CHAN(insn->chanspec));
-
/* Set the preload register */
Preload(dev, k, data[0]);
@@ -2416,348 +1906,9 @@ static int s626_enc_insn_write(struct comedi_device *dev,
k->PulseIndex(dev, k);
k->SetLoadTrig(dev, k, 2);
- DEBUG("s626_enc_insn_write: End encoder write\n");
-
return 1;
}
-static void s626_timer_load(struct comedi_device *dev, struct enc_private *k,
- int tick)
-{
- uint16_t Setup = (LOADSRC_INDX << BF_LOADSRC) | /* Preload upon */
- /* index. */
- (INDXSRC_SOFT << BF_INDXSRC) | /* Disable hardware index. */
- (CLKSRC_TIMER << BF_CLKSRC) | /* Operating mode is Timer. */
- (CLKPOL_POS << BF_CLKPOL) | /* Active high clock. */
- (CNTDIR_DOWN << BF_CLKPOL) | /* Count direction is Down. */
- (CLKMULT_1X << BF_CLKMULT) | /* Clock multiplier is 1x. */
- (CLKENAB_INDEX << BF_CLKENAB);
- uint16_t valueSrclatch = LATCHSRC_A_INDXA;
- /* uint16_t enab=CLKENAB_ALWAYS; */
-
- k->SetMode(dev, k, Setup, FALSE);
-
- /* Set the preload register */
- Preload(dev, k, tick);
-
- /* Software index pulse forces the preload register to load */
- /* into the counter */
- k->SetLoadTrig(dev, k, 0);
- k->PulseIndex(dev, k);
-
- /* set reload on counter overflow */
- k->SetLoadTrig(dev, k, 1);
-
- /* set interrupt on overflow */
- k->SetIntSrc(dev, k, INTSRC_OVER);
-
- SetLatchSource(dev, k, valueSrclatch);
- /* k->SetEnable(dev,k,(uint16_t)(enab != 0)); */
-}
-
-/* *********** DAC FUNCTIONS *********** */
-
-/* Slot 0 base settings. */
-#define VECT0 (XSD2 | RSD3 | SIB_A2)
-/* Slot 0 always shifts in 0xFF and store it to FB_BUFFER2. */
-
-/* TrimDac LogicalChan-to-PhysicalChan mapping table. */
-static uint8_t trimchan[] = { 10, 9, 8, 3, 2, 7, 6, 1, 0, 5, 4 };
-
-/* TrimDac LogicalChan-to-EepromAdrs mapping table. */
-static uint8_t trimadrs[] = { 0x40, 0x41, 0x42, 0x50, 0x51, 0x52, 0x53, 0x60, 0x61, 0x62, 0x63 };
-
-static void LoadTrimDACs(struct comedi_device *dev)
-{
- register uint8_t i;
-
- /* Copy TrimDac setpoint values from EEPROM to TrimDacs. */
- for (i = 0; i < ARRAY_SIZE(trimchan); i++)
- WriteTrimDAC(dev, i, I2Cread(dev, trimadrs[i]));
-}
-
-static void WriteTrimDAC(struct comedi_device *dev, uint8_t LogicalChan,
- uint8_t DacData)
-{
- uint32_t chan;
-
- /* Save the new setpoint in case the application needs to read it back later. */
- devpriv->TrimSetpoint[LogicalChan] = (uint8_t) DacData;
-
- /* Map logical channel number to physical channel number. */
- chan = (uint32_t) trimchan[LogicalChan];
-
- /* Set up TSL2 records for TrimDac write operation. All slots shift
- * 0xFF in from pulled-up SD3 so that the end of the slot sequence
- * can be detected.
- */
-
- SETVECT(2, XSD2 | XFIFO_1 | WS3);
- /* Slot 2: Send high uint8_t to target TrimDac. */
- SETVECT(3, XSD2 | XFIFO_0 | WS3);
- /* Slot 3: Send low uint8_t to target TrimDac. */
- SETVECT(4, XSD2 | XFIFO_3 | WS1);
- /* Slot 4: Send NOP high uint8_t to DAC0 to keep clock running. */
- SETVECT(5, XSD2 | XFIFO_2 | WS1 | EOS);
- /* Slot 5: Send NOP low uint8_t to DAC0. */
-
- /* Construct and transmit target DAC's serial packet:
- * ( 0000 AAAA ), ( DDDD DDDD ),( 0x00 ),( 0x00 ) where A<3:0> is the
- * DAC channel's address, and D<7:0> is the DAC setpoint. Append a
- * WORD value (that writes a channel 0 NOP command to a non-existent
- * main DAC channel) that serves to keep the clock running after the
- * packet has been sent to the target DAC.
- */
-
- /* Address the DAC channel within the trimdac device. */
- SendDAC(dev, ((uint32_t) chan << 8)
- | (uint32_t) DacData); /* Include DAC setpoint data. */
-}
-
-/* ************** EEPROM ACCESS FUNCTIONS ************** */
-/* Read uint8_t from EEPROM. */
-
-static uint8_t I2Cread(struct comedi_device *dev, uint8_t addr)
-{
- uint8_t rtnval;
-
- /* Send EEPROM target address. */
- if (I2Chandshake(dev, I2C_B2(I2C_ATTRSTART, I2CW)
- /* Byte2 = I2C command: write to I2C EEPROM device. */
- | I2C_B1(I2C_ATTRSTOP, addr)
- /* Byte1 = EEPROM internal target address. */
- | I2C_B0(I2C_ATTRNOP, 0))) { /* Byte0 = Not sent. */
- /* Abort function and declare error if handshake failed. */
- DEBUG("I2Cread: error handshake I2Cread a\n");
- return 0;
- }
- /* Execute EEPROM read. */
- if (I2Chandshake(dev, I2C_B2(I2C_ATTRSTART, I2CR)
-
- /* Byte2 = I2C */
- /* command: read */
- /* from I2C EEPROM */
- /* device. */
- |I2C_B1(I2C_ATTRSTOP, 0)
-
- /* Byte1 receives */
- /* uint8_t from */
- /* EEPROM. */
- |I2C_B0(I2C_ATTRNOP, 0))) { /* Byte0 = Not sent. */
-
- /* Abort function and declare error if handshake failed. */
- DEBUG("I2Cread: error handshake I2Cread b\n");
- return 0;
- }
- /* Return copy of EEPROM value. */
- rtnval = (uint8_t) (RR7146(P_I2CCTRL) >> 16);
- return rtnval;
-}
-
-static uint32_t I2Chandshake(struct comedi_device *dev, uint32_t val)
-{
- /* Write I2C command to I2C Transfer Control shadow register. */
- WR7146(P_I2CCTRL, val);
-
- /* Upload I2C shadow registers into working registers and wait for */
- /* upload confirmation. */
-
- MC_ENABLE(P_MC2, MC2_UPLD_IIC);
- while (!MC_TEST(P_MC2, MC2_UPLD_IIC))
- ;
-
- /* Wait until I2C bus transfer is finished or an error occurs. */
- while ((RR7146(P_I2CCTRL) & (I2C_BUSY | I2C_ERR)) == I2C_BUSY)
- ;
-
- /* Return non-zero if I2C error occurred. */
- return RR7146(P_I2CCTRL) & I2C_ERR;
-
-}
-
-/* Private helper function: Write setpoint to an application DAC channel. */
-
-static void SetDAC(struct comedi_device *dev, uint16_t chan, short dacdata)
-{
- register uint16_t signmask;
- register uint32_t WSImage;
-
- /* Adjust DAC data polarity and set up Polarity Control Register */
- /* image. */
- signmask = 1 << chan;
- if (dacdata < 0) {
- dacdata = -dacdata;
- devpriv->Dacpol |= signmask;
- } else
- devpriv->Dacpol &= ~signmask;
-
- /* Limit DAC setpoint value to valid range. */
- if ((uint16_t) dacdata > 0x1FFF)
- dacdata = 0x1FFF;
-
- /* Set up TSL2 records (aka "vectors") for DAC update. Vectors V2
- * and V3 transmit the setpoint to the target DAC. V4 and V5 send
- * data to a non-existent TrimDac channel just to keep the clock
- * running after sending data to the target DAC. This is necessary
- * to eliminate the clock glitch that would otherwise occur at the
- * end of the target DAC's serial data stream. When the sequence
- * restarts at V0 (after executing V5), the gate array automatically
- * disables gating for the DAC clock and all DAC chip selects.
- */
-
- WSImage = (chan & 2) ? WS1 : WS2;
- /* Choose DAC chip select to be asserted. */
- SETVECT(2, XSD2 | XFIFO_1 | WSImage);
- /* Slot 2: Transmit high data byte to target DAC. */
- SETVECT(3, XSD2 | XFIFO_0 | WSImage);
- /* Slot 3: Transmit low data byte to target DAC. */
- SETVECT(4, XSD2 | XFIFO_3 | WS3);
- /* Slot 4: Transmit to non-existent TrimDac channel to keep clock */
- SETVECT(5, XSD2 | XFIFO_2 | WS3 | EOS);
- /* Slot 5: running after writing target DAC's low data byte. */
-
- /* Construct and transmit target DAC's serial packet:
- * ( A10D DDDD ),( DDDD DDDD ),( 0x0F ),( 0x00 ) where A is chan<0>,
- * and D<12:0> is the DAC setpoint. Append a WORD value (that writes
- * to a non-existent TrimDac channel) that serves to keep the clock
- * running after the packet has been sent to the target DAC.
- */
- SendDAC(dev, 0x0F000000
- /* Continue clock after target DAC data (write to non-existent trimdac). */
- | 0x00004000
- /* Address the two main dual-DAC devices (TSL's chip select enables
- * target device). */
- | ((uint32_t) (chan & 1) << 15)
- /* Address the DAC channel within the device. */
- | (uint32_t) dacdata); /* Include DAC setpoint data. */
-
-}
-
-/* Private helper function: Transmit serial data to DAC via Audio
- * channel 2. Assumes: (1) TSL2 slot records initialized, and (2)
- * Dacpol contains valid target image.
- */
-
-static void SendDAC(struct comedi_device *dev, uint32_t val)
-{
-
- /* START THE SERIAL CLOCK RUNNING ------------- */
-
- /* Assert DAC polarity control and enable gating of DAC serial clock
- * and audio bit stream signals. At this point in time we must be
- * assured of being in time slot 0. If we are not in slot 0, the
- * serial clock and audio stream signals will be disabled; this is
- * because the following DEBIwrite statement (which enables signals
- * to be passed through the gate array) would execute before the
- * trailing edge of WS1/WS3 (which turns off the signals), thus
- * causing the signals to be inactive during the DAC write.
- */
- DEBIwrite(dev, LP_DACPOL, devpriv->Dacpol);
-
- /* TRANSFER OUTPUT DWORD VALUE INTO A2'S OUTPUT FIFO ---------------- */
-
- /* Copy DAC setpoint value to DAC's output DMA buffer. */
-
- /* WR7146( (uint32_t)devpriv->pDacWBuf, val ); */
- *devpriv->pDacWBuf = val;
-
- /* enab the output DMA transfer. This will cause the DMAC to copy
- * the DAC's data value to A2's output FIFO. The DMA transfer will
- * then immediately terminate because the protection address is
- * reached upon transfer of the first DWORD value.
- */
- MC_ENABLE(P_MC1, MC1_A2OUT);
-
- /* While the DMA transfer is executing ... */
-
- /* Reset Audio2 output FIFO's underflow flag (along with any other
- * FIFO underflow/overflow flags). When set, this flag will
- * indicate that we have emerged from slot 0.
- */
- WR7146(P_ISR, ISR_AFOU);
-
- /* Wait for the DMA transfer to finish so that there will be data
- * available in the FIFO when time slot 1 tries to transfer a DWORD
- * from the FIFO to the output buffer register. We test for DMA
- * Done by polling the DMAC enable flag; this flag is automatically
- * cleared when the transfer has finished.
- */
- while ((RR7146(P_MC1) & MC1_A2OUT) != 0)
- ;
-
- /* START THE OUTPUT STREAM TO THE TARGET DAC -------------------- */
-
- /* FIFO data is now available, so we enable execution of time slots
- * 1 and higher by clearing the EOS flag in slot 0. Note that SD3
- * will be shifted in and stored in FB_BUFFER2 for end-of-slot-list
- * detection.
- */
- SETVECT(0, XSD2 | RSD3 | SIB_A2);
-
- /* Wait for slot 1 to execute to ensure that the Packet will be
- * transmitted. This is detected by polling the Audio2 output FIFO
- * underflow flag, which will be set when slot 1 execution has
- * finished transferring the DAC's data DWORD from the output FIFO
- * to the output buffer register.
- */
- while ((RR7146(P_SSR) & SSR_AF2_OUT) == 0)
- ;
-
- /* Set up to trap execution at slot 0 when the TSL sequencer cycles
- * back to slot 0 after executing the EOS in slot 5. Also,
- * simultaneously shift out and in the 0x00 that is ALWAYS the value
- * stored in the last byte to be shifted out of the FIFO's DWORD
- * buffer register.
- */
- SETVECT(0, XSD2 | XFIFO_2 | RSD2 | SIB_A2 | EOS);
-
- /* WAIT FOR THE TRANSACTION TO FINISH ----------------------- */
-
- /* Wait for the TSL to finish executing all time slots before
- * exiting this function. We must do this so that the next DAC
- * write doesn't start, thereby enabling clock/chip select signals:
- *
- * 1. Before the TSL sequence cycles back to slot 0, which disables
- * the clock/cs signal gating and traps slot // list execution.
- * we have not yet finished slot 5 then the clock/cs signals are
- * still gated and we have not finished transmitting the stream.
- *
- * 2. While slots 2-5 are executing due to a late slot 0 trap. In
- * this case, the slot sequence is currently repeating, but with
- * clock/cs signals disabled. We must wait for slot 0 to trap
- * execution before setting up the next DAC setpoint DMA transfer
- * and enabling the clock/cs signals. To detect the end of slot 5,
- * we test for the FB_BUFFER2 MSB contents to be equal to 0xFF. If
- * the TSL has not yet finished executing slot 5 ...
- */
- if ((RR7146(P_FB_BUFFER2) & 0xFF000000) != 0) {
- /* The trap was set on time and we are still executing somewhere
- * in slots 2-5, so we now wait for slot 0 to execute and trap
- * TSL execution. This is detected when FB_BUFFER2 MSB changes
- * from 0xFF to 0x00, which slot 0 causes to happen by shifting
- * out/in on SD2 the 0x00 that is always referenced by slot 5.
- */
- while ((RR7146(P_FB_BUFFER2) & 0xFF000000) != 0)
- ;
- }
- /* Either (1) we were too late setting the slot 0 trap; the TSL
- * sequencer restarted slot 0 before we could set the EOS trap flag,
- * or (2) we were not late and execution is now trapped at slot 0.
- * In either case, we must now change slot 0 so that it will store
- * value 0xFF (instead of 0x00) to FB_BUFFER2 next time it executes.
- * In order to do this, we reprogram slot 0 so that it will shift in
- * SD3, which is driven only by a pull-up resistor.
- */
- SETVECT(0, RSD3 | SIB_A2 | EOS);
-
- /* Wait for slot 0 to execute, at which time the TSL is setup for
- * the next DAC write. This is detected when FB_BUFFER2 MSB changes
- * from 0x00 to 0xFF.
- */
- while ((RR7146(P_FB_BUFFER2) & 0xFF000000) == 0)
- ;
-}
-
static void WriteMISC2(struct comedi_device *dev, uint16_t NewImage)
{
DEBIwrite(dev, LP_MISC1, MISC1_WENABLE); /* enab writes to */
@@ -2766,83 +1917,12 @@ static void WriteMISC2(struct comedi_device *dev, uint16_t NewImage)
DEBIwrite(dev, LP_MISC1, MISC1_WDISABLE); /* Disable writes to MISC2. */
}
-/* Initialize the DEBI interface for all transfers. */
-
-static uint16_t DEBIread(struct comedi_device *dev, uint16_t addr)
-{
- uint16_t retval;
-
- /* Set up DEBI control register value in shadow RAM. */
- WR7146(P_DEBICMD, DEBI_CMD_RDWORD | addr);
-
- /* Execute the DEBI transfer. */
- DEBItransfer(dev);
-
- /* Fetch target register value. */
- retval = (uint16_t) RR7146(P_DEBIAD);
-
- /* Return register value. */
- return retval;
-}
-
-/* Execute a DEBI transfer. This must be called from within a */
-/* critical section. */
-static void DEBItransfer(struct comedi_device *dev)
-{
- /* Initiate upload of shadow RAM to DEBI control register. */
- MC_ENABLE(P_MC2, MC2_UPLD_DEBI);
-
- /* Wait for completion of upload from shadow RAM to DEBI control */
- /* register. */
- while (!MC_TEST(P_MC2, MC2_UPLD_DEBI))
- ;
-
- /* Wait until DEBI transfer is done. */
- while (RR7146(P_PSR) & PSR_DEBI_S)
- ;
-}
-
-/* Write a value to a gate array register. */
-static void DEBIwrite(struct comedi_device *dev, uint16_t addr, uint16_t wdata)
-{
-
- /* Set up DEBI control register value in shadow RAM. */
- WR7146(P_DEBICMD, DEBI_CMD_WRWORD | addr);
- WR7146(P_DEBIAD, wdata);
-
- /* Execute the DEBI transfer. */
- DEBItransfer(dev);
-}
-
-/* Replace the specified bits in a gate array register. Imports: mask
- * specifies bits that are to be preserved, wdata is new value to be
- * or'd with the masked original.
- */
-static void DEBIreplace(struct comedi_device *dev, uint16_t addr, uint16_t mask,
- uint16_t wdata)
-{
-
- /* Copy target gate array register into P_DEBIAD register. */
- WR7146(P_DEBICMD, DEBI_CMD_RDWORD | addr);
- /* Set up DEBI control reg value in shadow RAM. */
- DEBItransfer(dev); /* Execute the DEBI Read transfer. */
-
- /* Write back the modified image. */
- WR7146(P_DEBICMD, DEBI_CMD_WRWORD | addr);
- /* Set up DEBI control reg value in shadow RAM. */
-
- WR7146(P_DEBIAD, wdata | ((uint16_t) RR7146(P_DEBIAD) & mask));
- /* Modify the register image. */
- DEBItransfer(dev); /* Execute the DEBI Write transfer. */
-}
-
static void CloseDMAB(struct comedi_device *dev, struct bufferDMA *pdma,
size_t bsize)
{
void *vbptr;
dma_addr_t vpptr;
- DEBUG("CloseDMAB: Entering S626DRV_CloseDMAB():\n");
if (pdma == NULL)
return;
/* find the matching allocation from the board struct */
@@ -2851,44 +1931,13 @@ static void CloseDMAB(struct comedi_device *dev, struct bufferDMA *pdma,
vpptr = pdma->PhysicalBase;
if (vbptr) {
pci_free_consistent(devpriv->pdev, bsize, vbptr, vpptr);
- pdma->LogicalBase = 0;
+ pdma->LogicalBase = NULL;
pdma->PhysicalBase = 0;
-
- DEBUG("CloseDMAB(): Logical=%p, bsize=%d, Physical=0x%x\n",
- vbptr, bsize, (uint32_t) vpptr);
}
}
-/* ****** COUNTER FUNCTIONS ******* */
-/* All counter functions address a specific counter by means of the
- * "Counter" argument, which is a logical counter number. The Counter
- * argument may have any of the following legal values: 0=0A, 1=1A,
- * 2=2A, 3=0B, 4=1B, 5=2B.
- */
-
-/* Forward declarations for functions that are common to both A and B counters: */
-
/* ****** PRIVATE COUNTER FUNCTIONS ****** */
-/* Read a counter's output latch. */
-
-static uint32_t ReadLatch(struct comedi_device *dev, struct enc_private *k)
-{
- register uint32_t value;
- /* DEBUG FIXME DEBUG("ReadLatch: Read Latch enter\n"); */
-
- /* Latch counts and fetch LSW of latched counts value. */
- value = (uint32_t) DEBIread(dev, k->MyLatchLsw);
-
- /* Fetch MSW of latched counts and combine with LSW. */
- value |= ((uint32_t) DEBIread(dev, k->MyLatchLsw + 2) << 16);
-
- /* DEBUG FIXME DEBUG("ReadLatch: Read Latch exit\n"); */
-
- /* Return latched counts. */
- return value;
-}
-
/* Reset a counter's index and overflow event capture flags. */
static void ResetCapFlags_A(struct comedi_device *dev, struct enc_private *k)
@@ -3114,7 +2163,6 @@ static void SetMode_B(struct comedi_device *dev, struct enc_private *k,
static void SetEnable_A(struct comedi_device *dev, struct enc_private *k,
uint16_t enab)
{
- DEBUG("SetEnable_A: SetEnable_A enter 3541\n");
DEBIreplace(dev, k->MyCRB,
(uint16_t) (~(CRBMSK_INTCTRL | CRBMSK_CLKENAB_A)),
(uint16_t) (enab << CRBBIT_CLKENAB_A));
@@ -3138,22 +2186,6 @@ static uint16_t GetEnable_B(struct comedi_device *dev, struct enc_private *k)
return (DEBIread(dev, k->MyCRB) >> CRBBIT_CLKENAB_B) & 1;
}
-/* Return/set a counter pair's latch trigger source. 0: On read
- * access, 1: A index latches A, 2: B index latches B, 3: A overflow
- * latches B.
- */
-
-static void SetLatchSource(struct comedi_device *dev, struct enc_private *k,
- uint16_t value)
-{
- DEBUG("SetLatchSource: SetLatchSource enter 3550\n");
- DEBIreplace(dev, k->MyCRB,
- (uint16_t) (~(CRBMSK_INTCTRL | CRBMSK_LATCHSRC)),
- (uint16_t) (value << CRBBIT_LATCHSRC));
-
- DEBUG("SetLatchSource: SetLatchSource exit\n");
-}
-
/*
* static uint16_t GetLatchSource(struct comedi_device *dev, struct enc_private *k )
* {
@@ -3299,7 +2331,6 @@ static uint16_t GetIntSrc_B(struct comedi_device *dev, struct enc_private *k)
/* static void SetIndexSrc(struct comedi_device *dev, struct enc_private *k, uint16_t value ) */
/* { */
-/* DEBUG("SetIndexSrc: set index src enter 3700\n"); */
/* k->SetMode(dev, k, (uint16_t)( ( k->GetMode(dev, k ) & ~STDMSK_INDXSRC ) | ( (value != 0) << STDBIT_INDXSRC ) ), FALSE ); */
/* } */
@@ -3314,11 +2345,8 @@ static void PulseIndex_A(struct comedi_device *dev, struct enc_private *k)
{
register uint16_t cra;
- DEBUG("PulseIndex_A: pulse index enter\n");
-
cra = DEBIread(dev, k->MyCRA); /* Pulse index. */
DEBIwrite(dev, k->MyCRA, (uint16_t) (cra ^ CRAMSK_INDXPOL_A));
- DEBUG("PulseIndex_A: pulse index step1\n");
DEBIwrite(dev, k->MyCRA, cra);
}
@@ -3331,17 +2359,99 @@ static void PulseIndex_B(struct comedi_device *dev, struct enc_private *k)
DEBIwrite(dev, k->MyCRB, crb);
}
-/* Write value into counter preload register. */
-
-static void Preload(struct comedi_device *dev, struct enc_private *k,
- uint32_t value)
-{
- DEBUG("Preload: preload enter\n");
- DEBIwrite(dev, (uint16_t) (k->MyLatchLsw), (uint16_t) value); /* Write value to preload register. */
- DEBUG("Preload: preload step 1\n");
- DEBIwrite(dev, (uint16_t) (k->MyLatchLsw + 2),
- (uint16_t) (value >> 16));
-}
+static struct enc_private enc_private_data[] = {
+ {
+ .GetEnable = GetEnable_A,
+ .GetIntSrc = GetIntSrc_A,
+ .GetLoadTrig = GetLoadTrig_A,
+ .GetMode = GetMode_A,
+ .PulseIndex = PulseIndex_A,
+ .SetEnable = SetEnable_A,
+ .SetIntSrc = SetIntSrc_A,
+ .SetLoadTrig = SetLoadTrig_A,
+ .SetMode = SetMode_A,
+ .ResetCapFlags = ResetCapFlags_A,
+ .MyCRA = LP_CR0A,
+ .MyCRB = LP_CR0B,
+ .MyLatchLsw = LP_CNTR0ALSW,
+ .MyEventBits = EVBITS(0),
+ }, {
+ .GetEnable = GetEnable_A,
+ .GetIntSrc = GetIntSrc_A,
+ .GetLoadTrig = GetLoadTrig_A,
+ .GetMode = GetMode_A,
+ .PulseIndex = PulseIndex_A,
+ .SetEnable = SetEnable_A,
+ .SetIntSrc = SetIntSrc_A,
+ .SetLoadTrig = SetLoadTrig_A,
+ .SetMode = SetMode_A,
+ .ResetCapFlags = ResetCapFlags_A,
+ .MyCRA = LP_CR1A,
+ .MyCRB = LP_CR1B,
+ .MyLatchLsw = LP_CNTR1ALSW,
+ .MyEventBits = EVBITS(1),
+ }, {
+ .GetEnable = GetEnable_A,
+ .GetIntSrc = GetIntSrc_A,
+ .GetLoadTrig = GetLoadTrig_A,
+ .GetMode = GetMode_A,
+ .PulseIndex = PulseIndex_A,
+ .SetEnable = SetEnable_A,
+ .SetIntSrc = SetIntSrc_A,
+ .SetLoadTrig = SetLoadTrig_A,
+ .SetMode = SetMode_A,
+ .ResetCapFlags = ResetCapFlags_A,
+ .MyCRA = LP_CR2A,
+ .MyCRB = LP_CR2B,
+ .MyLatchLsw = LP_CNTR2ALSW,
+ .MyEventBits = EVBITS(2),
+ }, {
+ .GetEnable = GetEnable_B,
+ .GetIntSrc = GetIntSrc_B,
+ .GetLoadTrig = GetLoadTrig_B,
+ .GetMode = GetMode_B,
+ .PulseIndex = PulseIndex_B,
+ .SetEnable = SetEnable_B,
+ .SetIntSrc = SetIntSrc_B,
+ .SetLoadTrig = SetLoadTrig_B,
+ .SetMode = SetMode_B,
+ .ResetCapFlags = ResetCapFlags_B,
+ .MyCRA = LP_CR0A,
+ .MyCRB = LP_CR0B,
+ .MyLatchLsw = LP_CNTR0BLSW,
+ .MyEventBits = EVBITS(3),
+ }, {
+ .GetEnable = GetEnable_B,
+ .GetIntSrc = GetIntSrc_B,
+ .GetLoadTrig = GetLoadTrig_B,
+ .GetMode = GetMode_B,
+ .PulseIndex = PulseIndex_B,
+ .SetEnable = SetEnable_B,
+ .SetIntSrc = SetIntSrc_B,
+ .SetLoadTrig = SetLoadTrig_B,
+ .SetMode = SetMode_B,
+ .ResetCapFlags = ResetCapFlags_B,
+ .MyCRA = LP_CR1A,
+ .MyCRB = LP_CR1B,
+ .MyLatchLsw = LP_CNTR1BLSW,
+ .MyEventBits = EVBITS(4),
+ }, {
+ .GetEnable = GetEnable_B,
+ .GetIntSrc = GetIntSrc_B,
+ .GetLoadTrig = GetLoadTrig_B,
+ .GetMode = GetMode_B,
+ .PulseIndex = PulseIndex_B,
+ .SetEnable = SetEnable_B,
+ .SetIntSrc = SetIntSrc_B,
+ .SetLoadTrig = SetLoadTrig_B,
+ .SetMode = SetMode_B,
+ .ResetCapFlags = ResetCapFlags_B,
+ .MyCRA = LP_CR2A,
+ .MyCRB = LP_CR2B,
+ .MyLatchLsw = LP_CNTR2BLSW,
+ .MyEventBits = EVBITS(5),
+ },
+};
static void CountersInit(struct comedi_device *dev)
{
@@ -3364,6 +2474,545 @@ static void CountersInit(struct comedi_device *dev)
k->ResetCapFlags(dev, k);
k->SetEnable(dev, k, CLKENAB_ALWAYS);
}
- DEBUG("CountersInit: counters initialized\n");
+}
+
+static struct pci_dev *s626_find_pci(struct comedi_device *dev,
+ struct comedi_devconfig *it)
+{
+ struct pci_dev *pcidev = NULL;
+ int bus = it->options[0];
+ int slot = it->options[1];
+ int i;
+
+ for (i = 0; i < ARRAY_SIZE(s626_boards) && !pcidev; i++) {
+ do {
+ pcidev = pci_get_subsys(s626_boards[i].vendor_id,
+ s626_boards[i].device_id,
+ s626_boards[i].subvendor_id,
+ s626_boards[i].subdevice_id,
+ pcidev);
+
+ if ((bus || slot) && pcidev) {
+ /* matches requested bus/slot */
+ if (pcidev->bus->number == bus &&
+ PCI_SLOT(pcidev->devfn) == slot)
+ break;
+ } else {
+ break;
+ }
+ } while (1);
+ }
+ return pcidev;
+}
+
+static int s626_attach(struct comedi_device *dev, struct comedi_devconfig *it)
+{
+/* uint8_t PollList; */
+/* uint16_t AdcData; */
+/* uint16_t StartVal; */
+/* uint16_t index; */
+/* unsigned int data[16]; */
+ int result;
+ int i;
+ int ret;
+ resource_size_t resourceStart;
+ dma_addr_t appdma;
+ struct comedi_subdevice *s;
+
+ if (alloc_private(dev, sizeof(struct s626_private)) < 0)
+ return -ENOMEM;
+
+ devpriv->pdev = s626_find_pci(dev, it);
+ if (!devpriv->pdev) {
+ printk(KERN_ERR "s626_attach: Board not present!!!\n");
+ return -ENODEV;
+ }
+
+ result = comedi_pci_enable(devpriv->pdev, "s626");
+ if (result < 0) {
+ printk(KERN_ERR "s626_attach: comedi_pci_enable fails\n");
+ return -ENODEV;
+ }
+ devpriv->got_regions = 1;
+
+ resourceStart = pci_resource_start(devpriv->pdev, 0);
+
+ devpriv->base_addr = ioremap(resourceStart, SIZEOF_ADDRESS_SPACE);
+ if (devpriv->base_addr == NULL) {
+ printk(KERN_ERR "s626_attach: IOREMAP failed\n");
+ return -ENODEV;
+ }
+
+ if (devpriv->base_addr) {
+ /* disable master interrupt */
+ writel(0, devpriv->base_addr + P_IER);
+
+ /* soft reset */
+ writel(MC1_SOFT_RESET, devpriv->base_addr + P_MC1);
+
+ /* DMA FIXME DMA// */
+
+ /* adc buffer allocation */
+ devpriv->allocatedBuf = 0;
+
+ devpriv->ANABuf.LogicalBase =
+ pci_alloc_consistent(devpriv->pdev, DMABUF_SIZE, &appdma);
+
+ if (devpriv->ANABuf.LogicalBase == NULL) {
+ printk(KERN_ERR "s626_attach: DMA Memory mapping error\n");
+ return -ENOMEM;
+ }
+
+ devpriv->ANABuf.PhysicalBase = appdma;
+
+ devpriv->allocatedBuf++;
+
+ devpriv->RPSBuf.LogicalBase =
+ pci_alloc_consistent(devpriv->pdev, DMABUF_SIZE, &appdma);
+
+ if (devpriv->RPSBuf.LogicalBase == NULL) {
+ printk(KERN_ERR "s626_attach: DMA Memory mapping error\n");
+ return -ENOMEM;
+ }
+
+ devpriv->RPSBuf.PhysicalBase = appdma;
+
+ devpriv->allocatedBuf++;
+
+ }
+
+ dev->board_ptr = s626_boards;
+ dev->board_name = thisboard->name;
+
+ ret = comedi_alloc_subdevices(dev, 6);
+ if (ret)
+ return ret;
+
+ dev->iobase = (unsigned long)devpriv->base_addr;
+ dev->irq = devpriv->pdev->irq;
+
+ /* set up interrupt handler */
+ if (dev->irq == 0) {
+ printk(KERN_ERR " unknown irq (bad)\n");
+ } else {
+ ret = request_irq(dev->irq, s626_irq_handler, IRQF_SHARED,
+ "s626", dev);
+
+ if (ret < 0) {
+ printk(KERN_ERR " irq not available\n");
+ dev->irq = 0;
+ }
+ }
+
+ s = dev->subdevices + 0;
+ /* analog input subdevice */
+ dev->read_subdev = s;
+ /* we support single-ended (ground) and differential */
+ s->type = COMEDI_SUBD_AI;
+ s->subdev_flags = SDF_READABLE | SDF_DIFF | SDF_CMD_READ;
+ s->n_chan = thisboard->ai_chans;
+ s->maxdata = (0xffff >> 2);
+ s->range_table = &s626_range_table;
+ s->len_chanlist = thisboard->ai_chans; /* This is the maximum chanlist
+ length that the board can
+ handle */
+ s->insn_config = s626_ai_insn_config;
+ s->insn_read = s626_ai_insn_read;
+ s->do_cmd = s626_ai_cmd;
+ s->do_cmdtest = s626_ai_cmdtest;
+ s->cancel = s626_ai_cancel;
+
+ s = dev->subdevices + 1;
+ /* analog output subdevice */
+ s->type = COMEDI_SUBD_AO;
+ s->subdev_flags = SDF_WRITABLE | SDF_READABLE;
+ s->n_chan = thisboard->ao_chans;
+ s->maxdata = (0x3fff);
+ s->range_table = &range_bipolar10;
+ s->insn_write = s626_ao_winsn;
+ s->insn_read = s626_ao_rinsn;
+
+ s = dev->subdevices + 2;
+ /* digital I/O subdevice */
+ s->type = COMEDI_SUBD_DIO;
+ s->subdev_flags = SDF_WRITABLE | SDF_READABLE;
+ s->n_chan = 16;
+ s->maxdata = 1;
+ s->io_bits = 0xffff;
+ s->private = &dio_private_A;
+ s->range_table = &range_digital;
+ s->insn_config = s626_dio_insn_config;
+ s->insn_bits = s626_dio_insn_bits;
+
+ s = dev->subdevices + 3;
+ /* digital I/O subdevice */
+ s->type = COMEDI_SUBD_DIO;
+ s->subdev_flags = SDF_WRITABLE | SDF_READABLE;
+ s->n_chan = 16;
+ s->maxdata = 1;
+ s->io_bits = 0xffff;
+ s->private = &dio_private_B;
+ s->range_table = &range_digital;
+ s->insn_config = s626_dio_insn_config;
+ s->insn_bits = s626_dio_insn_bits;
+
+ s = dev->subdevices + 4;
+ /* digital I/O subdevice */
+ s->type = COMEDI_SUBD_DIO;
+ s->subdev_flags = SDF_WRITABLE | SDF_READABLE;
+ s->n_chan = 16;
+ s->maxdata = 1;
+ s->io_bits = 0xffff;
+ s->private = &dio_private_C;
+ s->range_table = &range_digital;
+ s->insn_config = s626_dio_insn_config;
+ s->insn_bits = s626_dio_insn_bits;
+
+ s = dev->subdevices + 5;
+ /* encoder (counter) subdevice */
+ s->type = COMEDI_SUBD_COUNTER;
+ s->subdev_flags = SDF_WRITABLE | SDF_READABLE | SDF_LSAMPL;
+ s->n_chan = thisboard->enc_chans;
+ s->private = enc_private_data;
+ s->insn_config = s626_enc_insn_config;
+ s->insn_read = s626_enc_insn_read;
+ s->insn_write = s626_enc_insn_write;
+ s->maxdata = 0xffffff;
+ s->range_table = &range_unknown;
+
+ /* stop ai_command */
+ devpriv->ai_cmd_running = 0;
+
+ if (devpriv->base_addr && (devpriv->allocatedBuf == 2)) {
+ dma_addr_t pPhysBuf;
+ uint16_t chan;
+
+ /* enab DEBI and audio pins, enable I2C interface. */
+ MC_ENABLE(P_MC1, MC1_DEBI | MC1_AUDIO | MC1_I2C);
+ /* Configure DEBI operating mode. */
+ WR7146(P_DEBICFG, DEBI_CFG_SLAVE16 /* Local bus is 16 */
+ /* bits wide. */
+ | (DEBI_TOUT << DEBI_CFG_TOUT_BIT)
+
+ /* Declare DEBI */
+ /* transfer timeout */
+ /* interval. */
+ |DEBI_SWAP /* Set up byte lane */
+ /* steering. */
+ | DEBI_CFG_INTEL); /* Intel-compatible */
+ /* local bus (DEBI */
+ /* never times out). */
+
+ /* DEBI INIT S626 WR7146( P_DEBICFG, DEBI_CFG_INTEL | DEBI_CFG_TOQ */
+ /* | DEBI_CFG_INCQ| DEBI_CFG_16Q); //end */
+
+ /* Paging is disabled. */
+ WR7146(P_DEBIPAGE, DEBI_PAGE_DISABLE); /* Disable MMU paging. */
+
+ /* Init GPIO so that ADC Start* is negated. */
+ WR7146(P_GPIO, GPIO_BASE | GPIO1_HI);
+
+ /* IsBoardRevA is a boolean that indicates whether the board is RevA.
+ *
+ * VERSION 2.01 CHANGE: REV A & B BOARDS NOW SUPPORTED BY DYNAMIC
+ * EEPROM ADDRESS SELECTION. Initialize the I2C interface, which
+ * is used to access the onboard serial EEPROM. The EEPROM's I2C
+ * DeviceAddress is hardwired to a value that is dependent on the
+ * 626 board revision. On all board revisions, the EEPROM stores
+ * TrimDAC calibration constants for analog I/O. On RevB and
+ * higher boards, the DeviceAddress is hardwired to 0 to enable
+ * the EEPROM to also store the PCI SubVendorID and SubDeviceID;
+ * this is the address at which the SAA7146 expects a
+ * configuration EEPROM to reside. On RevA boards, the EEPROM
+ * device address, which is hardwired to 4, prevents the SAA7146
+ * from retrieving PCI sub-IDs, so the SAA7146 uses its built-in
+ * default values, instead.
+ */
+
+ /* devpriv->I2Cards= IsBoardRevA ? 0xA8 : 0xA0; // Set I2C EEPROM */
+ /* DeviceType (0xA0) */
+ /* and DeviceAddress<<1. */
+
+ devpriv->I2CAdrs = 0xA0; /* I2C device address for onboard */
+ /* eeprom(revb) */
+
+ /* Issue an I2C ABORT command to halt any I2C operation in */
+ /* progress and reset BUSY flag. */
+ WR7146(P_I2CSTAT, I2C_CLKSEL | I2C_ABORT);
+ /* Write I2C control: abort any I2C activity. */
+ MC_ENABLE(P_MC2, MC2_UPLD_IIC);
+ /* Invoke command upload */
+ while ((RR7146(P_MC2) & MC2_UPLD_IIC) == 0)
+ ;
+ /* and wait for upload to complete. */
+
+ /* Per SAA7146 data sheet, write to STATUS reg twice to
+ * reset all I2C error flags. */
+ for (i = 0; i < 2; i++) {
+ WR7146(P_I2CSTAT, I2C_CLKSEL);
+ /* Write I2C control: reset error flags. */
+ MC_ENABLE(P_MC2, MC2_UPLD_IIC); /* Invoke command upload */
+ while (!MC_TEST(P_MC2, MC2_UPLD_IIC))
+ ;
+ /* and wait for upload to complete. */
+ }
+
+ /* Init audio interface functional attributes: set DAC/ADC
+ * serial clock rates, invert DAC serial clock so that
+ * DAC data setup times are satisfied, enable DAC serial
+ * clock out.
+ */
+
+ WR7146(P_ACON2, ACON2_INIT);
+
+ /* Set up TSL1 slot list, which is used to control the
+ * accumulation of ADC data: RSD1 = shift data in on SD1.
+ * SIB_A1 = store data uint8_t at next available location in
+ * FB BUFFER1 register. */
+ WR7146(P_TSL1, RSD1 | SIB_A1);
+ /* Fetch ADC high data uint8_t. */
+ WR7146(P_TSL1 + 4, RSD1 | SIB_A1 | EOS);
+ /* Fetch ADC low data uint8_t; end of TSL1. */
+
+ /* enab TSL1 slot list so that it executes all the time. */
+ WR7146(P_ACON1, ACON1_ADCSTART);
+
+ /* Initialize RPS registers used for ADC. */
+
+ /* Physical start of RPS program. */
+ WR7146(P_RPSADDR1, (uint32_t) devpriv->RPSBuf.PhysicalBase);
+
+ WR7146(P_RPSPAGE1, 0);
+ /* RPS program performs no explicit mem writes. */
+ WR7146(P_RPS1_TOUT, 0); /* Disable RPS timeouts. */
+
+ /* SAA7146 BUG WORKAROUND. Initialize SAA7146 ADC interface
+ * to a known state by invoking ADCs until FB BUFFER 1
+ * register shows that it is correctly receiving ADC data.
+ * This is necessary because the SAA7146 ADC interface does
+ * not start up in a defined state after a PCI reset.
+ */
+
+/* PollList = EOPL; // Create a simple polling */
+/* // list for analog input */
+/* // channel 0. */
+/* ResetADC( dev, &PollList ); */
+
+/* s626_ai_rinsn(dev,dev->subdevices,NULL,data); //( &AdcData ); // */
+/* //Get initial ADC */
+/* //value. */
+
+/* StartVal = data[0]; */
+
+/* // VERSION 2.01 CHANGE: TIMEOUT ADDED TO PREVENT HANGED EXECUTION. */
+/* // Invoke ADCs until the new ADC value differs from the initial */
+/* // value or a timeout occurs. The timeout protects against the */
+/* // possibility that the driver is restarting and the ADC data is a */
+/* // fixed value resulting from the applied ADC analog input being */
+/* // unusually quiet or at the rail. */
+
+/* for ( index = 0; index < 500; index++ ) */
+/* { */
+/* s626_ai_rinsn(dev,dev->subdevices,NULL,data); */
+/* AdcData = data[0]; //ReadADC( &AdcData ); */
+/* if ( AdcData != StartVal ) */
+/* break; */
+/* } */
+
+ /* end initADC */
+
+ /* init the DAC interface */
+
+ /* Init Audio2's output DMAC attributes: burst length = 1
+ * DWORD, threshold = 1 DWORD.
+ */
+ WR7146(P_PCI_BT_A, 0);
+
+ /* Init Audio2's output DMA physical addresses. The protection
+ * address is set to 1 DWORD past the base address so that a
+ * single DWORD will be transferred each time a DMA transfer is
+ * enabled. */
+
+ pPhysBuf =
+ devpriv->ANABuf.PhysicalBase +
+ (DAC_WDMABUF_OS * sizeof(uint32_t));
+
+ WR7146(P_BASEA2_OUT, (uint32_t) pPhysBuf); /* Buffer base adrs. */
+ WR7146(P_PROTA2_OUT, (uint32_t) (pPhysBuf + sizeof(uint32_t))); /* Protection address. */
+
+ /* Cache Audio2's output DMA buffer logical address. This is
+ * where DAC data is buffered for A2 output DMA transfers. */
+ devpriv->pDacWBuf =
+ (uint32_t *) devpriv->ANABuf.LogicalBase + DAC_WDMABUF_OS;
+
+ /* Audio2's output channels does not use paging. The protection
+ * violation handling bit is set so that the DMAC will
+ * automatically halt and its PCI address pointer will be reset
+ * when the protection address is reached. */
+
+ WR7146(P_PAGEA2_OUT, 8);
+
+ /* Initialize time slot list 2 (TSL2), which is used to control
+ * the clock generation for and serialization of data to be sent
+ * to the DAC devices. Slot 0 is a NOP that is used to trap TSL
+ * execution; this permits other slots to be safely modified
+ * without first turning off the TSL sequencer (which is
+ * apparently impossible to do). Also, SD3 (which is driven by a
+ * pull-up resistor) is shifted in and stored to the MSB of
+ * FB_BUFFER2 to be used as evidence that the slot sequence has
+ * not yet finished executing.
+ */
+
+ SETVECT(0, XSD2 | RSD3 | SIB_A2 | EOS);
+ /* Slot 0: Trap TSL execution, shift 0xFF into FB_BUFFER2. */
+
+ /* Initialize slot 1, which is constant. Slot 1 causes a
+ * DWORD to be transferred from audio channel 2's output FIFO
+ * to the FIFO's output buffer so that it can be serialized
+ * and sent to the DAC during subsequent slots. All remaining
+ * slots are dynamically populated as required by the target
+ * DAC device.
+ */
+ SETVECT(1, LF_A2);
+ /* Slot 1: Fetch DWORD from Audio2's output FIFO. */
+
+ /* Start DAC's audio interface (TSL2) running. */
+ WR7146(P_ACON1, ACON1_DACSTART);
+
+ /* end init DAC interface */
+
+ /* Init Trim DACs to calibrated values. Do it twice because the
+ * SAA7146 audio channel does not always reset properly and
+ * sometimes causes the first few TrimDAC writes to malfunction.
+ */
+
+ LoadTrimDACs(dev);
+ LoadTrimDACs(dev); /* Insurance. */
+
+ /* Manually init all gate array hardware in case this is a soft
+ * reset (we have no way of determining whether this is a warm
+ * or cold start). This is necessary because the gate array will
+ * reset only in response to a PCI hard reset; there is no soft
+ * reset function. */
+
+ /* Init all DAC outputs to 0V and init all DAC setpoint and
+ * polarity images.
+ */
+ for (chan = 0; chan < S626_DAC_CHANNELS; chan++)
+ SetDAC(dev, chan, 0);
+
+ /* Init image of WRMISC2 Battery Charger Enabled control bit.
+ * This image is used when the state of the charger control bit,
+ * which has no direct hardware readback mechanism, is queried.
+ */
+ devpriv->ChargeEnabled = 0;
+
+ /* Init image of watchdog timer interval in WRMISC2. This image
+ * maintains the value of the control bits of MISC2 are
+ * continuously reset to zero as long as the WD timer is disabled.
+ */
+ devpriv->WDInterval = 0;
+
+ /* Init Counter Interrupt enab mask for RDMISC2. This mask is
+ * applied against MISC2 when testing to determine which timer
+ * events are requesting interrupt service.
+ */
+ devpriv->CounterIntEnabs = 0;
+
+ /* Init counters. */
+ CountersInit(dev);
+
+ /* Without modifying the state of the Battery Backup enab, disable
+ * the watchdog timer, set DIO channels 0-5 to operate in the
+ * standard DIO (vs. counter overflow) mode, disable the battery
+ * charger, and reset the watchdog interval selector to zero.
+ */
+ WriteMISC2(dev, (uint16_t) (DEBIread(dev,
+ LP_RDMISC2) &
+ MISC2_BATT_ENABLE));
+
+ /* Initialize the digital I/O subsystem. */
+ s626_dio_init(dev);
+
+ /* enable interrupt test */
+ /* writel(IRQ_GPIO3 | IRQ_RPS1,devpriv->base_addr+P_IER); */
+ }
+
+ return 1;
+}
+
+static void s626_detach(struct comedi_device *dev)
+{
+ if (devpriv) {
+ /* stop ai_command */
+ devpriv->ai_cmd_running = 0;
+
+ if (devpriv->base_addr) {
+ /* interrupt mask */
+ WR7146(P_IER, 0); /* Disable master interrupt. */
+ WR7146(P_ISR, IRQ_GPIO3 | IRQ_RPS1); /* Clear board's IRQ status flag. */
+
+ /* Disable the watchdog timer and battery charger. */
+ WriteMISC2(dev, 0);
+
+ /* Close all interfaces on 7146 device. */
+ WR7146(P_MC1, MC1_SHUTDOWN);
+ WR7146(P_ACON1, ACON1_BASE);
+
+ CloseDMAB(dev, &devpriv->RPSBuf, DMABUF_SIZE);
+ CloseDMAB(dev, &devpriv->ANABuf, DMABUF_SIZE);
+ }
+
+ if (dev->irq)
+ free_irq(dev->irq, dev);
+ if (devpriv->base_addr)
+ iounmap(devpriv->base_addr);
+ if (devpriv->pdev) {
+ if (devpriv->got_regions)
+ comedi_pci_disable(devpriv->pdev);
+ pci_dev_put(devpriv->pdev);
+ }
+ }
+}
+
+static struct comedi_driver s626_driver = {
+ .driver_name = "s626",
+ .module = THIS_MODULE,
+ .attach = s626_attach,
+ .detach = s626_detach,
+};
+static int __devinit s626_pci_probe(struct pci_dev *dev,
+ const struct pci_device_id *ent)
+{
+ return comedi_pci_auto_config(dev, &s626_driver);
+}
+
+static void __devexit s626_pci_remove(struct pci_dev *dev)
+{
+ comedi_pci_auto_unconfig(dev);
}
+
+/*
+ * For devices with vendor:device id == 0x1131:0x7146 you must specify
+ * also subvendor:subdevice ids, because otherwise it will conflict with
+ * Philips SAA7146 media/dvb based cards.
+ */
+static DEFINE_PCI_DEVICE_TABLE(s626_pci_table) = {
+ { PCI_VENDOR_ID_S626, PCI_DEVICE_ID_S626,
+ PCI_SUBVENDOR_ID_S626, PCI_SUBDEVICE_ID_S626, 0, 0, 0 },
+ { 0 }
+};
+MODULE_DEVICE_TABLE(pci, s626_pci_table);
+
+static struct pci_driver s626_pci_driver = {
+ .name = "s626",
+ .id_table = s626_pci_table,
+ .probe = s626_pci_probe,
+ .remove = __devexit_p(s626_pci_remove),
+};
+module_comedi_pci_driver(s626_driver, s626_pci_driver);
+
+MODULE_AUTHOR("Gianluca Palli <gpalli@deis.unibo.it>");
+MODULE_DESCRIPTION("Sensoray 626 Comedi driver module");
+MODULE_LICENSE("GPL");
diff --git a/drivers/staging/comedi/drivers/s626.h b/drivers/staging/comedi/drivers/s626.h
index 2d1afecbbb60..8a8f196cf153 100644
--- a/drivers/staging/comedi/drivers/s626.h
+++ b/drivers/staging/comedi/drivers/s626.h
@@ -62,12 +62,6 @@
comedi_do_insn(cf,&insn); // executing configuration
*/
-#ifdef _DEBUG_
-#define DEBUG(...); printk(__VA_ARGS__);
-#else
-#define DEBUG(...)
-#endif
-
#if !defined(TRUE)
#define TRUE (1)
#endif
@@ -76,11 +70,7 @@
#define FALSE (0)
#endif
-#if !defined(INLINE)
-#define INLINE static __inline
-#endif
-
-#include<linux/slab.h>
+#include <linux/slab.h>
#define S626_SIZE 0x0200
#define SIZEOF_ADDRESS_SPACE 0x0200
diff --git a/drivers/staging/comedi/drivers/serial2002.c b/drivers/staging/comedi/drivers/serial2002.c
index d880c2f6fbc1..c18314be8c82 100644
--- a/drivers/staging/comedi/drivers/serial2002.c
+++ b/drivers/staging/comedi/drivers/serial2002.c
@@ -43,25 +43,10 @@ Status: in development
#include <linux/serial.h>
#include <linux/poll.h>
-/*
- * Board descriptions for two imaginary boards. Describing the
- * boards in this way is optional, and completely driver-dependent.
- * Some drivers use arrays such as this, other do not.
- */
struct serial2002_board {
const char *name;
};
-static const struct serial2002_board serial2002_boards[] = {
- {
- .name = "serial2002"}
-};
-
-/*
- * Useful for shorthand access to the particular board structure
- */
-#define thisboard ((const struct serial2002_board *)dev->board_ptr)
-
struct serial2002_range_table_t {
/* HACK... */
@@ -89,35 +74,6 @@ struct serial2002_private {
*/
#define devpriv ((struct serial2002_private *)dev->private)
-static int serial2002_attach(struct comedi_device *dev,
- struct comedi_devconfig *it);
-static int serial2002_detach(struct comedi_device *dev);
-struct comedi_driver driver_serial2002 = {
- .driver_name = "serial2002",
- .module = THIS_MODULE,
- .attach = serial2002_attach,
- .detach = serial2002_detach,
- .board_name = &serial2002_boards[0].name,
- .offset = sizeof(struct serial2002_board),
- .num_names = ARRAY_SIZE(serial2002_boards),
-};
-
-static int serial2002_di_rinsn(struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data);
-static int serial2002_do_winsn(struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data);
-static int serial2002_ai_rinsn(struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data);
-static int serial2002_ao_winsn(struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data);
-static int serial2002_ao_rinsn(struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data);
-
struct serial_data {
enum { is_invalid, is_digital, is_channel } kind;
int index;
@@ -687,7 +643,7 @@ err_alloc_configs:
if (result) {
if (devpriv->tty) {
- filp_close(devpriv->tty, 0);
+ filp_close(devpriv->tty, NULL);
devpriv->tty = NULL;
}
}
@@ -697,8 +653,8 @@ err_alloc_configs:
static void serial_2002_close(struct comedi_device *dev)
{
- if (!IS_ERR(devpriv->tty) && (devpriv->tty != 0))
- filp_close(devpriv->tty, 0);
+ if (!IS_ERR(devpriv->tty) && devpriv->tty)
+ filp_close(devpriv->tty, NULL);
}
static int serial2002_di_rinsn(struct comedi_device *dev,
@@ -822,21 +778,24 @@ static int serial2002_ei_rinsn(struct comedi_device *dev,
static int serial2002_attach(struct comedi_device *dev,
struct comedi_devconfig *it)
{
+ const struct serial2002_board *board = comedi_board(dev);
struct comedi_subdevice *s;
+ int ret;
- dev_dbg(dev->hw_dev, "comedi%d: attached\n", dev->minor);
- dev->board_name = thisboard->name;
+ dev_dbg(dev->class_dev, "serial2002: attach\n");
+ dev->board_name = board->name;
if (alloc_private(dev, sizeof(struct serial2002_private)) < 0)
return -ENOMEM;
dev->open = serial_2002_open;
dev->close = serial_2002_close;
devpriv->port = it->options[0];
devpriv->speed = it->options[1];
- dev_dbg(dev->hw_dev, "/dev/ttyS%d @ %d\n", devpriv->port,
+ dev_dbg(dev->class_dev, "/dev/ttyS%d @ %d\n", devpriv->port,
devpriv->speed);
- if (alloc_subdevices(dev, 5) < 0)
- return -ENOMEM;
+ ret = comedi_alloc_subdevices(dev, 5);
+ if (ret)
+ return ret;
/* digital input subdevice */
s = dev->subdevices + 0;
@@ -862,7 +821,7 @@ static int serial2002_attach(struct comedi_device *dev,
s->subdev_flags = SDF_READABLE | SDF_GROUND;
s->n_chan = 0;
s->maxdata = 1;
- s->range_table = 0;
+ s->range_table = NULL;
s->insn_read = &serial2002_ai_rinsn;
/* analog output subdevice */
@@ -871,7 +830,7 @@ static int serial2002_attach(struct comedi_device *dev,
s->subdev_flags = SDF_WRITEABLE;
s->n_chan = 0;
s->maxdata = 1;
- s->range_table = 0;
+ s->range_table = NULL;
s->insn_write = &serial2002_ao_winsn;
s->insn_read = &serial2002_ao_rinsn;
@@ -881,38 +840,40 @@ static int serial2002_attach(struct comedi_device *dev,
s->subdev_flags = SDF_READABLE | SDF_LSAMPL;
s->n_chan = 0;
s->maxdata = 1;
- s->range_table = 0;
+ s->range_table = NULL;
s->insn_read = &serial2002_ei_rinsn;
return 1;
}
-static int serial2002_detach(struct comedi_device *dev)
+static void serial2002_detach(struct comedi_device *dev)
{
struct comedi_subdevice *s;
int i;
- dev_dbg(dev->hw_dev, "comedi%d: remove\n", dev->minor);
for (i = 0; i < 5; i++) {
s = &dev->subdevices[i];
kfree(s->maxdata_list);
kfree(s->range_table_list);
}
- return 0;
-}
-
-static int __init driver_serial2002_init_module(void)
-{
- return comedi_driver_register(&driver_serial2002);
}
-static void __exit driver_serial2002_cleanup_module(void)
-{
- comedi_driver_unregister(&driver_serial2002);
-}
+static const struct serial2002_board serial2002_boards[] = {
+ {
+ .name = "serial2002"
+ },
+};
-module_init(driver_serial2002_init_module);
-module_exit(driver_serial2002_cleanup_module);
+static struct comedi_driver serial2002_driver = {
+ .driver_name = "serial2002",
+ .module = THIS_MODULE,
+ .attach = serial2002_attach,
+ .detach = serial2002_detach,
+ .board_name = &serial2002_boards[0].name,
+ .offset = sizeof(struct serial2002_board),
+ .num_names = ARRAY_SIZE(serial2002_boards),
+};
+module_comedi_driver(serial2002_driver);
MODULE_AUTHOR("Comedi http://www.comedi.org");
MODULE_DESCRIPTION("Comedi low-level driver");
diff --git a/drivers/staging/comedi/drivers/skel.c b/drivers/staging/comedi/drivers/skel.c
index ed69008f0d39..9a68eebefca0 100644
--- a/drivers/staging/comedi/drivers/skel.c
+++ b/drivers/staging/comedi/drivers/skel.c
@@ -156,7 +156,7 @@ struct skel_private {
* the device code.
*/
static int skel_attach(struct comedi_device *dev, struct comedi_devconfig *it);
-static int skel_detach(struct comedi_device *dev);
+static void skel_detach(struct comedi_device *dev);
static struct comedi_driver driver_skel = {
.driver_name = "dummy",
.module = THIS_MODULE,
@@ -210,6 +210,7 @@ static int skel_ns_to_timer(unsigned int *ns, int round);
static int skel_attach(struct comedi_device *dev, struct comedi_devconfig *it)
{
struct comedi_subdevice *s;
+ int ret;
pr_info("comedi%d: skel: ", dev->minor);
@@ -233,12 +234,9 @@ static int skel_attach(struct comedi_device *dev, struct comedi_devconfig *it)
if (alloc_private(dev, sizeof(struct skel_private)) < 0)
return -ENOMEM;
-/*
- * Allocate the subdevice structures. alloc_subdevice() is a
- * convenient macro defined in comedidev.h.
- */
- if (alloc_subdevices(dev, 3) < 0)
- return -ENOMEM;
+ ret = comedi_alloc_subdevices(dev, 3);
+ if (ret)
+ return ret;
s = dev->subdevices + 0;
/* dev->read_subdev=s; */
@@ -295,11 +293,8 @@ static int skel_attach(struct comedi_device *dev, struct comedi_devconfig *it)
* allocated by _attach(). dev->private and dev->subdevices are
* deallocated automatically by the core.
*/
-static int skel_detach(struct comedi_device *dev)
+static void skel_detach(struct comedi_device *dev)
{
- pr_info("comedi%d: skel: remove\n", dev->minor);
-
- return 0;
}
/*
@@ -566,9 +561,6 @@ static int skel_dio_insn_bits(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
- if (insn->n != 2)
- return -EINVAL;
-
/* The insn data is a mask in data[0] and the new data
* in data[1], each channel cooresponding to a bit. */
if (data[0]) {
@@ -585,7 +577,7 @@ static int skel_dio_insn_bits(struct comedi_device *dev,
* it was a purely digital output subdevice */
/* data[1]=s->state; */
- return 2;
+ return insn->n;
}
static int skel_dio_insn_config(struct comedi_device *dev,
@@ -619,11 +611,11 @@ static int skel_dio_insn_config(struct comedi_device *dev,
return insn->n;
}
-#ifdef CONFIG_COMEDI_PCI
+#ifdef CONFIG_COMEDI_PCI_DRIVERS
static int __devinit driver_skel_pci_probe(struct pci_dev *dev,
const struct pci_device_id *ent)
{
- return comedi_pci_auto_config(dev, driver_skel.driver_name);
+ return comedi_pci_auto_config(dev, &driver_skel);
}
static void __devexit driver_skel_pci_remove(struct pci_dev *dev)
diff --git a/drivers/staging/comedi/drivers/ssv_dnp.c b/drivers/staging/comedi/drivers/ssv_dnp.c
index 526de2efa125..84b9f2a4280b 100644
--- a/drivers/staging/comedi/drivers/ssv_dnp.c
+++ b/drivers/staging/comedi/drivers/ssv_dnp.c
@@ -59,157 +59,6 @@ struct dnp_board {
int have_dio;
};
-/* We only support one DNP 'board' variant at the moment */
-static const struct dnp_board dnp_boards[] = {
-{
- .name = "dnp-1486",
- .ai_chans = 16,
- .ai_bits = 12,
- .have_dio = 1,
- },
-};
-
-/* Useful for shorthand access to the particular board structure ----------- */
-#define thisboard ((const struct dnp_board *)dev->board_ptr)
-
-/* This structure is for data unique to the DNP driver --------------------- */
-struct dnp_private_data {
-
-};
-
-/* Shorthand macro for faster access to the private data ------------------- */
-#define devpriv ((dnp_private *)dev->private)
-
-/* ------------------------------------------------------------------------- */
-/* The struct comedi_driver structure tells the Comedi core module which */
-/* functions to call to configure/deconfigure (attach/detach) the board, and */
-/* also about the kernel module that contains the device code. */
-/* */
-/* In the following section we define the API of this driver. */
-/* ------------------------------------------------------------------------- */
-
-static int dnp_attach(struct comedi_device *dev, struct comedi_devconfig *it);
-static int dnp_detach(struct comedi_device *dev);
-
-static struct comedi_driver driver_dnp = {
- .driver_name = "ssv_dnp",
- .module = THIS_MODULE,
- .attach = dnp_attach,
- .detach = dnp_detach,
- .board_name = &dnp_boards[0].name,
- /* only necessary for non-PnP devs */
- .offset = sizeof(struct dnp_board), /* like ISA-PnP, PCI or PCMCIA */
- .num_names = ARRAY_SIZE(dnp_boards),
-};
-
-static int __init driver_dnp_init_module(void)
-{
- return comedi_driver_register(&driver_dnp);
-}
-
-static void __exit driver_dnp_cleanup_module(void)
-{
- comedi_driver_unregister(&driver_dnp);
-}
-
-module_init(driver_dnp_init_module);
-module_exit(driver_dnp_cleanup_module);
-
-static int dnp_dio_insn_bits(struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data);
-
-static int dnp_dio_insn_config(struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_insn *insn, unsigned int *data);
-
-/* ------------------------------------------------------------------------- */
-/* Attach is called by comedi core to configure the driver for a particular */
-/* board. If you specified a board_name array in the driver structure, */
-/* dev->board_ptr contains that address. */
-/* ------------------------------------------------------------------------- */
-
-static int dnp_attach(struct comedi_device *dev, struct comedi_devconfig *it)
-{
-
- struct comedi_subdevice *s;
-
- printk(KERN_INFO "comedi%d: dnp: ", dev->minor);
-
- /* Autoprobing: this should find out which board we have. Currently */
- /* only the 1486 board is supported and autoprobing is not */
- /* implemented :-) */
- /* dev->board_ptr = dnp_probe(dev); */
-
- /* Initialize the name of the board. */
- /* We can use the "thisboard" macro now. */
- dev->board_name = thisboard->name;
-
- /* Allocate the private structure area. alloc_private() is a */
- /* convenient macro defined in comedidev.h. */
- if (alloc_private(dev, sizeof(struct dnp_private_data)) < 0)
- return -ENOMEM;
-
- /* Allocate the subdevice structures. alloc_subdevice() is a */
- /* convenient macro defined in comedidev.h. */
-
- if (alloc_subdevices(dev, 1) < 0)
- return -ENOMEM;
-
- s = dev->subdevices + 0;
- /* digital i/o subdevice */
- s->type = COMEDI_SUBD_DIO;
- s->subdev_flags = SDF_READABLE | SDF_WRITABLE;
- s->n_chan = 20;
- s->maxdata = 1;
- s->range_table = &range_digital;
- s->insn_bits = dnp_dio_insn_bits;
- s->insn_config = dnp_dio_insn_config;
-
- printk("attached\n");
-
- /* We use the I/O ports 0x22,0x23 and 0xa3-0xa9, which are always
- * allocated for the primary 8259, so we don't need to allocate them
- * ourselves. */
-
- /* configure all ports as input (default) */
- outb(PAMR, CSCIR);
- outb(0x00, CSCDR);
- outb(PBMR, CSCIR);
- outb(0x00, CSCDR);
- outb(PCMR, CSCIR);
- outb((inb(CSCDR) & 0xAA), CSCDR);
-
- return 1;
-
-}
-
-/* ------------------------------------------------------------------------- */
-/* detach is called to deconfigure a device. It should deallocate the */
-/* resources. This function is also called when _attach() fails, so it */
-/* should be careful not to release resources that were not necessarily */
-/* allocated by _attach(). dev->private and dev->subdevices are */
-/* deallocated automatically by the core. */
-/* ------------------------------------------------------------------------- */
-
-static int dnp_detach(struct comedi_device *dev)
-{
-
- /* configure all ports as input (default) */
- outb(PAMR, CSCIR);
- outb(0x00, CSCDR);
- outb(PBMR, CSCIR);
- outb(0x00, CSCDR);
- outb(PCMR, CSCIR);
- outb((inb(CSCDR) & 0xAA), CSCDR);
-
- /* announce that we are finished */
- printk(KERN_INFO "comedi%d: dnp: remove\n", dev->minor);
-
- return 0;
-
-}
-
/* ------------------------------------------------------------------------- */
/* The insn_bits interface allows packed reading/writing of DIO channels. */
/* The comedi core can convert between insn_bits and insn_read/write, so you */
@@ -220,10 +69,6 @@ static int dnp_dio_insn_bits(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
-
- if (insn->n != 2)
- return -EINVAL; /* insn uses data[0] and data[1] */
-
/* The insn data is a mask in data[0] and the new data in data[1], */
/* each channel cooresponding to a bit. */
@@ -257,7 +102,7 @@ static int dnp_dio_insn_bits(struct comedi_device *dev,
outb(PCDR, CSCIR);
data[0] += ((inb(CSCDR) & 0xF0) << 12);
- return 2;
+ return insn->n;
}
@@ -326,6 +171,77 @@ static int dnp_dio_insn_config(struct comedi_device *dev,
}
+static int dnp_attach(struct comedi_device *dev, struct comedi_devconfig *it)
+{
+ const struct dnp_board *board = comedi_board(dev);
+ struct comedi_subdevice *s;
+ int ret;
+
+ printk(KERN_INFO "comedi%d: dnp: ", dev->minor);
+
+ dev->board_name = board->name;
+
+ ret = comedi_alloc_subdevices(dev, 1);
+ if (ret)
+ return ret;
+
+ s = dev->subdevices + 0;
+ /* digital i/o subdevice */
+ s->type = COMEDI_SUBD_DIO;
+ s->subdev_flags = SDF_READABLE | SDF_WRITABLE;
+ s->n_chan = 20;
+ s->maxdata = 1;
+ s->range_table = &range_digital;
+ s->insn_bits = dnp_dio_insn_bits;
+ s->insn_config = dnp_dio_insn_config;
+
+ printk("attached\n");
+
+ /* We use the I/O ports 0x22,0x23 and 0xa3-0xa9, which are always
+ * allocated for the primary 8259, so we don't need to allocate them
+ * ourselves. */
+
+ /* configure all ports as input (default) */
+ outb(PAMR, CSCIR);
+ outb(0x00, CSCDR);
+ outb(PBMR, CSCIR);
+ outb(0x00, CSCDR);
+ outb(PCMR, CSCIR);
+ outb((inb(CSCDR) & 0xAA), CSCDR);
+
+ return 1;
+}
+
+static void dnp_detach(struct comedi_device *dev)
+{
+ outb(PAMR, CSCIR);
+ outb(0x00, CSCDR);
+ outb(PBMR, CSCIR);
+ outb(0x00, CSCDR);
+ outb(PCMR, CSCIR);
+ outb((inb(CSCDR) & 0xAA), CSCDR);
+}
+
+static const struct dnp_board dnp_boards[] = {
+ {
+ .name = "dnp-1486",
+ .ai_chans = 16,
+ .ai_bits = 12,
+ .have_dio = 1,
+ },
+};
+
+static struct comedi_driver dnp_driver = {
+ .driver_name = "ssv_dnp",
+ .module = THIS_MODULE,
+ .attach = dnp_attach,
+ .detach = dnp_detach,
+ .board_name = &dnp_boards[0].name,
+ .offset = sizeof(struct dnp_board),
+ .num_names = ARRAY_SIZE(dnp_boards),
+};
+module_comedi_driver(dnp_driver);
+
MODULE_AUTHOR("Comedi http://www.comedi.org");
MODULE_DESCRIPTION("Comedi low-level driver");
MODULE_LICENSE("GPL");
diff --git a/drivers/staging/comedi/drivers/unioxx5.c b/drivers/staging/comedi/drivers/unioxx5.c
index f45824f0d86b..9f1fdec62dcb 100644
--- a/drivers/staging/comedi/drivers/unioxx5.c
+++ b/drivers/staging/comedi/drivers/unioxx5.c
@@ -83,96 +83,188 @@ struct unioxx5_subd_priv {
unsigned char usp_prev_cn_val[3]; /* previous channel value */
};
-static int unioxx5_attach(struct comedi_device *dev,
- struct comedi_devconfig *it);
-static int unioxx5_subdev_write(struct comedi_device *dev,
- struct comedi_subdevice *subdev,
- struct comedi_insn *insn, unsigned int *data);
-static int unioxx5_subdev_read(struct comedi_device *dev,
- struct comedi_subdevice *subdev,
- struct comedi_insn *insn, unsigned int *data);
-static int unioxx5_insn_config(struct comedi_device *dev,
- struct comedi_subdevice *subdev,
- struct comedi_insn *insn, unsigned int *data);
-static int unioxx5_detach(struct comedi_device *dev);
-static int __unioxx5_subdev_init(struct comedi_subdevice *subdev,
- int subdev_iobase, int minor);
-static int __unioxx5_digital_write(struct unioxx5_subd_priv *usp,
- unsigned int *data, int channel, int minor);
-static int __unioxx5_digital_read(struct unioxx5_subd_priv *usp,
- unsigned int *data, int channel, int minor);
-/* static void __unioxx5_digital_config(struct unioxx5_subd_priv* usp, int mode); */
-static int __unioxx5_analog_write(struct unioxx5_subd_priv *usp,
- unsigned int *data, int channel, int minor);
-static int __unioxx5_analog_read(struct unioxx5_subd_priv *usp,
- unsigned int *data, int channel, int minor);
-static int __unioxx5_define_chan_offset(int chan_num);
-static void __unioxx5_analog_config(struct unioxx5_subd_priv *usp, int channel);
+static int __unioxx5_define_chan_offset(int chan_num)
+{
-static struct comedi_driver unioxx5_driver = {
- .driver_name = DRIVER_NAME,
- .module = THIS_MODULE,
- .attach = unioxx5_attach,
- .detach = unioxx5_detach
-};
+ if (chan_num < 0 || chan_num > 23)
+ return -1;
-static int __init unioxx5_driver_init_module(void)
+ return (chan_num >> 3) + 1;
+}
+
+#if 0 /* not used? */
+static void __unioxx5_digital_config(struct unioxx5_subd_priv *usp, int mode)
{
- return comedi_driver_register(&unioxx5_driver);
+ int i, mask;
+
+ mask = (mode == ALL_2_OUTPUT) ? 0xFF : 0x00;
+ printk("COMEDI: mode = %d\n", mask);
+
+ outb(1, usp->usp_iobase + 0);
+
+ for (i = 0; i < 3; i++)
+ outb(mask, usp->usp_iobase + i);
+
+ outb(0, usp->usp_iobase + 0);
}
+#endif
-static void __exit unioxx5_driver_cleanup_module(void)
+/* configure channels for analog i/o (even to output, odd to input) */
+static void __unioxx5_analog_config(struct unioxx5_subd_priv *usp, int channel)
{
- comedi_driver_unregister(&unioxx5_driver);
+ int chan_a, chan_b, conf, channel_offset;
+
+ channel_offset = __unioxx5_define_chan_offset(channel);
+ conf = usp->usp_prev_cn_val[channel_offset - 1];
+ chan_a = chan_b = 1;
+
+ /* setting channel A and channel B mask */
+ if (channel % 2 == 0) {
+ chan_a <<= channel & 0x07;
+ chan_b <<= (channel + 1) & 0x07;
+ } else {
+ chan_a <<= (channel - 1) & 0x07;
+ chan_b <<= channel & 0x07;
+ }
+
+ conf |= chan_a; /* even channel ot output */
+ conf &= ~chan_b; /* odd channel to input */
+
+ outb(1, usp->usp_iobase + 0);
+ outb(conf, usp->usp_iobase + channel_offset);
+ outb(0, usp->usp_iobase + 0);
+
+ usp->usp_prev_cn_val[channel_offset - 1] = conf;
}
-module_init(unioxx5_driver_init_module);
-module_exit(unioxx5_driver_cleanup_module);
+static int __unioxx5_digital_read(struct unioxx5_subd_priv *usp,
+ unsigned int *data, int channel, int minor)
+{
+ int channel_offset, mask = 1 << (channel & 0x07);
+
+ channel_offset = __unioxx5_define_chan_offset(channel);
+ if (channel_offset < 0) {
+ printk(KERN_ERR
+ "comedi%d: undefined channel %d. channel range is 0 .. 23\n",
+ minor, channel);
+ return 0;
+ }
-static int unioxx5_attach(struct comedi_device *dev,
- struct comedi_devconfig *it)
+ *data = inb(usp->usp_iobase + channel_offset);
+ *data &= mask;
+
+ /* correct the read value to 0 or 1 */
+ if (channel_offset > 1)
+ channel -= 2 << channel_offset;
+ *data >>= channel;
+ return 1;
+}
+
+static int __unioxx5_analog_read(struct unioxx5_subd_priv *usp,
+ unsigned int *data, int channel, int minor)
{
- int iobase, i, n_subd;
- int id, num, ba;
+ int module_no, read_ch;
+ char control;
- iobase = it->options[0];
+ module_no = channel / 2;
+ read_ch = channel % 2; /* depend on type of channel (A or B) */
- dev->board_name = DRIVER_NAME;
- dev->iobase = iobase;
- iobase += UNIOXX5_SUBDEV_BASE;
+ /* defining if given module can work on input */
+ if (usp->usp_module_type[module_no] & MODULE_OUTPUT_MASK) {
+ printk(KERN_ERR
+ "comedi%d: module in position %d with id 0x%02x is for output only",
+ minor, module_no, usp->usp_module_type[module_no]);
+ return 0;
+ }
- /* defining number of subdevices and getting they types (it must be 'g01') */
- for (i = n_subd = 0, ba = iobase; i < 4; i++, ba += UNIOXX5_SUBDEV_ODDS) {
- id = inb(ba + 0xE);
- num = inb(ba + 0xF);
+ __unioxx5_analog_config(usp, channel);
+ /* sends module number to card(1 .. 12) */
+ outb(module_no + 1, usp->usp_iobase + 5);
+ outb('V', usp->usp_iobase + 6); /* sends to module (V)erify command */
+ control = inb(usp->usp_iobase); /* get control register byte */
- if (id != 'g' || num != 1)
- continue;
+ /* waits while reading four bytes will be allowed */
+ while (!((control = inb(usp->usp_iobase + 0)) & Rx4CA))
+ ;
- n_subd++;
+ /* if four bytes readding error occurs - return 0(false) */
+ if ((control & Rx4CA_ERR_MASK)) {
+ printk("COMEDI: 4 bytes error\n");
+ return 0;
}
- /* unioxx5 can has from two to four subdevices */
- if (n_subd < 2) {
+ if (read_ch)
+ *data = inw(usp->usp_iobase + 6); /* channel B */
+ else
+ *data = inw(usp->usp_iobase + 4); /* channel A */
+
+ return 1;
+}
+
+static int __unioxx5_digital_write(struct unioxx5_subd_priv *usp,
+ unsigned int *data, int channel, int minor)
+{
+ int channel_offset, val;
+ int mask = 1 << (channel & 0x07);
+
+ channel_offset = __unioxx5_define_chan_offset(channel);
+ if (channel_offset < 0) {
printk(KERN_ERR
- "your card must has at least 2 'g01' subdevices\n");
- return -1;
+ "comedi%d: undefined channel %d. channel range is 0 .. 23\n",
+ minor, channel);
+ return 0;
}
- if (alloc_subdevices(dev, n_subd) < 0) {
- printk(KERN_ERR "out of memory\n");
- return -ENOMEM;
+ /* getting previous written value */
+ val = usp->usp_prev_wr_val[channel_offset - 1];
+
+ if (*data)
+ val |= mask;
+ else
+ val &= ~mask;
+
+ outb(val, usp->usp_iobase + channel_offset);
+ /* saving new written value */
+ usp->usp_prev_wr_val[channel_offset - 1] = val;
+
+ return 1;
+}
+
+static int __unioxx5_analog_write(struct unioxx5_subd_priv *usp,
+ unsigned int *data, int channel, int minor)
+{
+ int module, i;
+
+ module = channel / 2; /* definig module number(0 .. 11) */
+ i = (channel % 2) << 1; /* depends on type of channel (A or B) */
+
+ /* defining if given module can work on output */
+ if (!(usp->usp_module_type[module] & MODULE_OUTPUT_MASK)) {
+ printk(KERN_ERR
+ "comedi%d: module in position %d with id 0x%0x is for input only!\n",
+ minor, module, usp->usp_module_type[module]);
+ return 0;
}
- /* initializing each of for same subdevices */
- for (i = 0; i < n_subd; i++, iobase += UNIOXX5_SUBDEV_ODDS) {
- if (__unioxx5_subdev_init(&dev->subdevices[i], iobase,
- dev->minor) < 0)
- return -1;
+ __unioxx5_analog_config(usp, channel);
+ /* saving minor byte */
+ usp->usp_extra_data[module][i++] = (unsigned char)(*data & 0x00FF);
+ /* saving major byte */
+ usp->usp_extra_data[module][i] = (unsigned char)((*data & 0xFF00) >> 8);
+
+ /* while(!((inb(usp->usp_iobase + 0)) & TxBE)); */
+ /* sending module number to card(1 .. 12) */
+ outb(module + 1, usp->usp_iobase + 5);
+ outb('W', usp->usp_iobase + 6); /* sends (W)rite command to module */
+
+ /* sending for bytes to module(one byte per cycle iteration) */
+ for (i = 0; i < 4; i++) {
+ while (!((inb(usp->usp_iobase + 0)) & TxBE))
+ ; /* waits while writting will be allowed */
+ outb(usp->usp_extra_data[module][i], usp->usp_iobase + 6);
}
- printk(KERN_INFO "attached\n");
- return 0;
+ return 1;
}
static int unioxx5_subdev_read(struct comedi_device *dev,
@@ -275,22 +367,6 @@ static int unioxx5_insn_config(struct comedi_device *dev,
return 0;
}
-static int unioxx5_detach(struct comedi_device *dev)
-{
- int i;
- struct comedi_subdevice *subdev;
- struct unioxx5_subd_priv *usp;
-
- for (i = 0; i < dev->n_subdevices; i++) {
- subdev = &dev->subdevices[i];
- usp = subdev->private;
- release_region(usp->usp_iobase, UNIOXX5_SIZE);
- kfree(subdev->private);
- }
-
- return 0;
-}
-
/* initializing subdevice with given address */
static int __unioxx5_subdev_init(struct comedi_subdevice *subdev,
int subdev_iobase, int minor)
@@ -362,196 +438,73 @@ static int __unioxx5_subdev_init(struct comedi_subdevice *subdev,
return 0;
}
-static int __unioxx5_digital_write(struct unioxx5_subd_priv *usp,
- unsigned int *data, int channel, int minor)
-{
- int channel_offset, val;
- int mask = 1 << (channel & 0x07);
-
- channel_offset = __unioxx5_define_chan_offset(channel);
- if (channel_offset < 0) {
- printk(KERN_ERR
- "comedi%d: undefined channel %d. channel range is 0 .. 23\n",
- minor, channel);
- return 0;
- }
-
- /* getting previous written value */
- val = usp->usp_prev_wr_val[channel_offset - 1];
-
- if (*data)
- val |= mask;
- else
- val &= ~mask;
-
- outb(val, usp->usp_iobase + channel_offset);
- /* saving new written value */
- usp->usp_prev_wr_val[channel_offset - 1] = val;
-
- return 1;
-}
-
-/* function for digital reading */
-static int __unioxx5_digital_read(struct unioxx5_subd_priv *usp,
- unsigned int *data, int channel, int minor)
-{
- int channel_offset, mask = 1 << (channel & 0x07);
-
- channel_offset = __unioxx5_define_chan_offset(channel);
- if (channel_offset < 0) {
- printk(KERN_ERR
- "comedi%d: undefined channel %d. channel range is 0 .. 23\n",
- minor, channel);
- return 0;
- }
-
- *data = inb(usp->usp_iobase + channel_offset);
- *data &= mask;
-
- if (channel_offset > 1)
- channel -= 2 << channel_offset; /* this operation is created for correct readed value to 0 or 1 */
- *data >>= channel;
- return 1;
-}
-
-#if 0 /* not used? */
-static void __unioxx5_digital_config(struct unioxx5_subd_priv *usp, int mode)
-{
- int i, mask;
-
- mask = (mode == ALL_2_OUTPUT) ? 0xFF : 0x00;
- printk("COMEDI: mode = %d\n", mask);
-
- outb(1, usp->usp_iobase + 0);
-
- for (i = 0; i < 3; i++)
- outb(mask, usp->usp_iobase + i);
-
- outb(0, usp->usp_iobase + 0);
-}
-#endif
-
-static int __unioxx5_analog_write(struct unioxx5_subd_priv *usp,
- unsigned int *data, int channel, int minor)
+static int unioxx5_attach(struct comedi_device *dev,
+ struct comedi_devconfig *it)
{
- int module, i;
+ int iobase, i, n_subd;
+ int id, num, ba;
+ int ret;
- module = channel / 2; /* definig module number(0 .. 11) */
- i = (channel % 2) << 1; /* depends on type of channel (A or B) */
+ iobase = it->options[0];
- /* defining if given module can work on output */
- if (!(usp->usp_module_type[module] & MODULE_OUTPUT_MASK)) {
- printk(KERN_ERR
- "comedi%d: module in position %d with id 0x%0x is for input only!\n",
- minor, module, usp->usp_module_type[module]);
- return 0;
- }
+ dev->board_name = DRIVER_NAME;
+ dev->iobase = iobase;
+ iobase += UNIOXX5_SUBDEV_BASE;
- __unioxx5_analog_config(usp, channel);
- /* saving minor byte */
- usp->usp_extra_data[module][i++] = (unsigned char)(*data & 0x00FF);
- /* saving major byte */
- usp->usp_extra_data[module][i] = (unsigned char)((*data & 0xFF00) >> 8);
+ /* defining number of subdevices and getting they types (it must be 'g01') */
+ for (i = n_subd = 0, ba = iobase; i < 4; i++, ba += UNIOXX5_SUBDEV_ODDS) {
+ id = inb(ba + 0xE);
+ num = inb(ba + 0xF);
- /* while(!((inb(usp->usp_iobase + 0)) & TxBE)); */
- /* sending module number to card(1 .. 12) */
- outb(module + 1, usp->usp_iobase + 5);
- outb('W', usp->usp_iobase + 6); /* sends (W)rite command to module */
+ if (id != 'g' || num != 1)
+ continue;
- /* sending for bytes to module(one byte per cycle iteration) */
- for (i = 0; i < 4; i++) {
- while (!((inb(usp->usp_iobase + 0)) & TxBE))
- ; /* waits while writting will be allowed */
- outb(usp->usp_extra_data[module][i], usp->usp_iobase + 6);
+ n_subd++;
}
- return 1;
-}
-
-static int __unioxx5_analog_read(struct unioxx5_subd_priv *usp,
- unsigned int *data, int channel, int minor)
-{
- int module_no, read_ch;
- char control;
-
- module_no = channel / 2;
- read_ch = channel % 2; /* depend on type of channel (A or B) */
-
- /* defining if given module can work on input */
- if (usp->usp_module_type[module_no] & MODULE_OUTPUT_MASK) {
+ /* unioxx5 can has from two to four subdevices */
+ if (n_subd < 2) {
printk(KERN_ERR
- "comedi%d: module in position %d with id 0x%02x is for output only",
- minor, module_no, usp->usp_module_type[module_no]);
- return 0;
+ "your card must has at least 2 'g01' subdevices\n");
+ return -1;
}
- __unioxx5_analog_config(usp, channel);
- /* sends module number to card(1 .. 12) */
- outb(module_no + 1, usp->usp_iobase + 5);
- outb('V', usp->usp_iobase + 6); /* sends to module (V)erify command */
- control = inb(usp->usp_iobase); /* get control register byte */
+ ret = comedi_alloc_subdevices(dev, n_subd);
+ if (ret)
+ return ret;
- /* waits while reading four bytes will be allowed */
- while (!((control = inb(usp->usp_iobase + 0)) & Rx4CA))
- ;
-
- /* if four bytes readding error occurs - return 0(false) */
- if ((control & Rx4CA_ERR_MASK)) {
- printk("COMEDI: 4 bytes error\n");
- return 0;
+ /* initializing each of for same subdevices */
+ for (i = 0; i < n_subd; i++, iobase += UNIOXX5_SUBDEV_ODDS) {
+ if (__unioxx5_subdev_init(&dev->subdevices[i], iobase,
+ dev->minor) < 0)
+ return -1;
}
- if (read_ch)
- *data = inw(usp->usp_iobase + 6); /* channel B */
- else
- *data = inw(usp->usp_iobase + 4); /* channel A */
-
- return 1;
+ printk(KERN_INFO "attached\n");
+ return 0;
}
-/* configure channels for analog i/o (even to output, odd to input) */
-static void __unioxx5_analog_config(struct unioxx5_subd_priv *usp, int channel)
+static void unioxx5_detach(struct comedi_device *dev)
{
- int chan_a, chan_b, conf, channel_offset;
-
- channel_offset = __unioxx5_define_chan_offset(channel);
- conf = usp->usp_prev_cn_val[channel_offset - 1];
- chan_a = chan_b = 1;
+ int i;
+ struct comedi_subdevice *subdev;
+ struct unioxx5_subd_priv *usp;
- /* setting channel A and channel B mask */
- if (channel % 2 == 0) {
- chan_a <<= channel & 0x07;
- chan_b <<= (channel + 1) & 0x07;
- } else {
- chan_a <<= (channel - 1) & 0x07;
- chan_b <<= channel & 0x07;
+ for (i = 0; i < dev->n_subdevices; i++) {
+ subdev = &dev->subdevices[i];
+ usp = subdev->private;
+ release_region(usp->usp_iobase, UNIOXX5_SIZE);
+ kfree(subdev->private);
}
-
- conf |= chan_a; /* even channel ot output */
- conf &= ~chan_b; /* odd channel to input */
-
- outb(1, usp->usp_iobase + 0);
- outb(conf, usp->usp_iobase + channel_offset);
- outb(0, usp->usp_iobase + 0);
-
- usp->usp_prev_cn_val[channel_offset - 1] = conf;
}
-/* *\
- * this function defines if the given channel number *
- * enters in default numeric interspace(from 0 to 23) *
- * and it returns address offset for usage needed *
- * channel. *
-\* */
-
-static int __unioxx5_define_chan_offset(int chan_num)
-{
-
- if (chan_num < 0 || chan_num > 23)
- return -1;
-
- return (chan_num >> 3) + 1;
-}
+static struct comedi_driver unioxx5_driver = {
+ .driver_name = DRIVER_NAME,
+ .module = THIS_MODULE,
+ .attach = unioxx5_attach,
+ .detach = unioxx5_detach,
+};
+module_comedi_driver(unioxx5_driver);
MODULE_AUTHOR("Comedi http://www.comedi.org");
MODULE_DESCRIPTION("Comedi low-level driver");
diff --git a/drivers/staging/comedi/drivers/usbdux.c b/drivers/staging/comedi/drivers/usbdux.c
index bf62e0dd6f69..848c7ec06976 100644
--- a/drivers/staging/comedi/drivers/usbdux.c
+++ b/drivers/staging/comedi/drivers/usbdux.c
@@ -1,6 +1,3 @@
-#define DRIVER_VERSION "v2.4"
-#define DRIVER_AUTHOR "Bernd Porr, BerndPorr@f2s.com"
-#define DRIVER_DESC "Stirling/ITL USB-DUX -- Bernd.Porr@f2s.com"
/*
comedi/drivers/usbdux.c
Copyright (C) 2003-2007 Bernd Porr, Bernd.Porr@f2s.com
@@ -101,8 +98,6 @@ sampling rate. If you sample two channels you get 4kHz and so on.
#include "../comedidev.h"
-#define BOARDNAME "usbdux"
-
/* timeout for the USB-transfer in ms*/
#define BULK_TIMEOUT 1000
@@ -1778,9 +1773,6 @@ static int usbdux_dio_insn_bits(struct comedi_device *dev,
if (!this_usbduxsub)
return -EFAULT;
- if (insn->n != 2)
- return -EINVAL;
-
down(&this_usbduxsub->sem);
if (!(this_usbduxsub->probed)) {
@@ -1810,7 +1802,7 @@ static int usbdux_dio_insn_bits(struct comedi_device *dev,
data[1] = le16_to_cpu(this_usbduxsub->insnBuffer[1]);
up(&this_usbduxsub->sem);
- return 2;
+ return insn->n;
}
/* reads the 4 counters, only two are used just now */
@@ -2300,15 +2292,240 @@ static void tidy_up(struct usbduxsub *usbduxsub_tmp)
usbduxsub_tmp->pwm_cmd_running = 0;
}
+/* common part of attach and attach_usb */
+static int usbdux_attach_common(struct comedi_device *dev,
+ struct usbduxsub *udev,
+ void *aux_data, int aux_len)
+{
+ int ret;
+ struct comedi_subdevice *s = NULL;
+ int n_subdevs;
+
+ down(&udev->sem);
+ /* pointer back to the corresponding comedi device */
+ udev->comedidev = dev;
+
+ /* trying to upload the firmware into the chip */
+ if (aux_data)
+ firmwareUpload(udev, aux_data, aux_len);
+
+ dev->board_name = "usbdux";
+
+ /* set number of subdevices */
+ if (udev->high_speed) {
+ /* with pwm */
+ n_subdevs = 5;
+ } else {
+ /* without pwm */
+ n_subdevs = 4;
+ }
+
+ ret = comedi_alloc_subdevices(dev, n_subdevs);
+ if (ret) {
+ up(&udev->sem);
+ return ret;
+ }
+
+ /* private structure is also simply the usb-structure */
+ dev->private = udev;
+
+ /* the first subdevice is the A/D converter */
+ s = dev->subdevices + SUBDEV_AD;
+ /* the URBs get the comedi subdevice */
+ /* which is responsible for reading */
+ /* this is the subdevice which reads data */
+ dev->read_subdev = s;
+ /* the subdevice receives as private structure the */
+ /* usb-structure */
+ s->private = NULL;
+ /* analog input */
+ s->type = COMEDI_SUBD_AI;
+ /* readable and ref is to ground */
+ s->subdev_flags = SDF_READABLE | SDF_GROUND | SDF_CMD_READ;
+ /* 8 channels */
+ s->n_chan = 8;
+ /* length of the channellist */
+ s->len_chanlist = 8;
+ /* callback functions */
+ s->insn_read = usbdux_ai_insn_read;
+ s->do_cmdtest = usbdux_ai_cmdtest;
+ s->do_cmd = usbdux_ai_cmd;
+ s->cancel = usbdux_ai_cancel;
+ /* max value from the A/D converter (12bit) */
+ s->maxdata = 0xfff;
+ /* range table to convert to physical units */
+ s->range_table = (&range_usbdux_ai_range);
+
+ /* analog out */
+ s = dev->subdevices + SUBDEV_DA;
+ /* analog out */
+ s->type = COMEDI_SUBD_AO;
+ /* backward pointer */
+ dev->write_subdev = s;
+ /* the subdevice receives as private structure the */
+ /* usb-structure */
+ s->private = NULL;
+ /* are writable */
+ s->subdev_flags = SDF_WRITABLE | SDF_GROUND | SDF_CMD_WRITE;
+ /* 4 channels */
+ s->n_chan = 4;
+ /* length of the channellist */
+ s->len_chanlist = 4;
+ /* 12 bit resolution */
+ s->maxdata = 0x0fff;
+ /* bipolar range */
+ s->range_table = (&range_usbdux_ao_range);
+ /* callback */
+ s->do_cmdtest = usbdux_ao_cmdtest;
+ s->do_cmd = usbdux_ao_cmd;
+ s->cancel = usbdux_ao_cancel;
+ s->insn_read = usbdux_ao_insn_read;
+ s->insn_write = usbdux_ao_insn_write;
+
+ /* digital I/O */
+ s = dev->subdevices + SUBDEV_DIO;
+ s->type = COMEDI_SUBD_DIO;
+ s->subdev_flags = SDF_READABLE | SDF_WRITABLE;
+ s->n_chan = 8;
+ s->maxdata = 1;
+ s->range_table = (&range_digital);
+ s->insn_bits = usbdux_dio_insn_bits;
+ s->insn_config = usbdux_dio_insn_config;
+ /* we don't use it */
+ s->private = NULL;
+
+ /* counter */
+ s = dev->subdevices + SUBDEV_COUNTER;
+ s->type = COMEDI_SUBD_COUNTER;
+ s->subdev_flags = SDF_WRITABLE | SDF_READABLE;
+ s->n_chan = 4;
+ s->maxdata = 0xFFFF;
+ s->insn_read = usbdux_counter_read;
+ s->insn_write = usbdux_counter_write;
+ s->insn_config = usbdux_counter_config;
+
+ if (udev->high_speed) {
+ /* timer / pwm */
+ s = dev->subdevices + SUBDEV_PWM;
+ s->type = COMEDI_SUBD_PWM;
+ s->subdev_flags = SDF_WRITABLE | SDF_PWM_HBRIDGE;
+ s->n_chan = 8;
+ /* this defines the max duty cycle resolution */
+ s->maxdata = udev->sizePwmBuf;
+ s->insn_write = usbdux_pwm_write;
+ s->insn_read = usbdux_pwm_read;
+ s->insn_config = usbdux_pwm_config;
+ usbdux_pwm_period(dev, s, PWM_DEFAULT_PERIOD);
+ }
+ /* finally decide that it's attached */
+ udev->attached = 1;
+
+ up(&udev->sem);
+
+ dev_info(&udev->interface->dev, "comedi%d: attached to usbdux.\n",
+ dev->minor);
+
+ return 0;
+}
+
+/* is called when comedi-config is called */
+static int usbdux_attach(struct comedi_device *dev, struct comedi_devconfig *it)
+{
+ int ret;
+ int index;
+ int i;
+ void *aux_data;
+ int aux_len;
+
+ dev->private = NULL;
+
+ aux_data = comedi_aux_data(it->options, 0);
+ aux_len = it->options[COMEDI_DEVCONF_AUX_DATA_LENGTH];
+ if (aux_data == NULL)
+ aux_len = 0;
+ else if (aux_len == 0)
+ aux_data = NULL;
+
+ down(&start_stop_sem);
+ /* find a valid device which has been detected by the probe function of
+ * the usb */
+ index = -1;
+ for (i = 0; i < NUMUSBDUX; i++) {
+ if ((usbduxsub[i].probed) && (!usbduxsub[i].attached)) {
+ index = i;
+ break;
+ }
+ }
+
+ if (index < 0) {
+ printk(KERN_ERR
+ "comedi%d: usbdux: error: attach failed, no usbdux devs connected to the usb bus.\n",
+ dev->minor);
+ ret = -ENODEV;
+ } else
+ ret = usbdux_attach_common(dev, &usbduxsub[index],
+ aux_data, aux_len);
+ up(&start_stop_sem);
+ return ret;
+}
+
+/* is called from comedi_usb_auto_config() */
+static int usbdux_attach_usb(struct comedi_device *dev,
+ struct usb_interface *uinterf)
+{
+ int ret;
+ struct usbduxsub *this_usbduxsub;
+
+ dev->private = NULL;
+
+ down(&start_stop_sem);
+ this_usbduxsub = usb_get_intfdata(uinterf);
+ if (!this_usbduxsub || !this_usbduxsub->probed) {
+ printk(KERN_ERR
+ "comedi%d: usbdux: error: attach_usb failed, not connected\n",
+ dev->minor);
+ ret = -ENODEV;
+ } else if (this_usbduxsub->attached) {
+ printk(KERN_ERR
+ "comedi%d: usbdux: error: attach_usb failed, already attached\n",
+ dev->minor);
+ ret = -ENODEV;
+ } else
+ ret = usbdux_attach_common(dev, this_usbduxsub, NULL, 0);
+ up(&start_stop_sem);
+ return ret;
+}
+
+static void usbdux_detach(struct comedi_device *dev)
+{
+ struct usbduxsub *usb = dev->private;
+
+ if (usb) {
+ down(&usb->sem);
+ dev->private = NULL;
+ usb->attached = 0;
+ usb->comedidev = NULL;
+ up(&usb->sem);
+ }
+}
+
+static struct comedi_driver usbdux_driver = {
+ .driver_name = "usbdux",
+ .module = THIS_MODULE,
+ .attach = usbdux_attach,
+ .detach = usbdux_detach,
+ .attach_usb = usbdux_attach_usb,
+};
+
static void usbdux_firmware_request_complete_handler(const struct firmware *fw,
void *context)
{
struct usbduxsub *usbduxsub_tmp = context;
- struct usb_device *usbdev = usbduxsub_tmp->usbdev;
+ struct usb_interface *uinterf = usbduxsub_tmp->interface;
int ret;
if (fw == NULL) {
- dev_err(&usbdev->dev,
+ dev_err(&uinterf->dev,
"Firmware complete handler without firmware!\n");
return;
}
@@ -2320,18 +2537,17 @@ static void usbdux_firmware_request_complete_handler(const struct firmware *fw,
ret = firmwareUpload(usbduxsub_tmp, fw->data, fw->size);
if (ret) {
- dev_err(&usbdev->dev,
+ dev_err(&uinterf->dev,
"Could not upload firmware (err=%d)\n", ret);
goto out;
}
- comedi_usb_auto_config(usbdev, BOARDNAME);
+ comedi_usb_auto_config(uinterf, &usbdux_driver);
out:
release_firmware(fw);
}
-/* allocate memory for the urbs and initialise them */
-static int usbduxsub_probe(struct usb_interface *uinterf,
- const struct usb_device_id *id)
+static int usbdux_usb_probe(struct usb_interface *uinterf,
+ const struct usb_device_id *id)
{
struct usb_device *udev = interface_to_usbdev(uinterf);
struct device *dev = &uinterf->dev;
@@ -2592,7 +2808,7 @@ static int usbduxsub_probe(struct usb_interface *uinterf,
return 0;
}
-static void usbduxsub_disconnect(struct usb_interface *intf)
+static void usbdux_usb_disconnect(struct usb_interface *intf)
{
struct usbduxsub *usbduxsub_tmp = usb_get_intfdata(intf);
struct usb_device *udev = interface_to_usbdev(intf);
@@ -2606,7 +2822,7 @@ static void usbduxsub_disconnect(struct usb_interface *intf)
dev_err(&intf->dev, "comedi_: BUG! called with wrong ptr!!!\n");
return;
}
- comedi_usb_auto_unconfig(udev);
+ comedi_usb_auto_unconfig(intf);
down(&start_stop_sem);
down(&usbduxsub_tmp->sem);
tidy_up(usbduxsub_tmp);
@@ -2615,254 +2831,22 @@ static void usbduxsub_disconnect(struct usb_interface *intf)
dev_dbg(&intf->dev, "comedi_: disconnected from the usb\n");
}
-/* is called when comedi-config is called */
-static int usbdux_attach(struct comedi_device *dev, struct comedi_devconfig *it)
-{
- int ret;
- int index;
- int i;
- struct usbduxsub *udev;
-
- struct comedi_subdevice *s = NULL;
- dev->private = NULL;
-
- down(&start_stop_sem);
- /* find a valid device which has been detected by the probe function of
- * the usb */
- index = -1;
- for (i = 0; i < NUMUSBDUX; i++) {
- if ((usbduxsub[i].probed) && (!usbduxsub[i].attached)) {
- index = i;
- break;
- }
- }
-
- if (index < 0) {
- printk(KERN_ERR "comedi%d: usbdux: error: attach failed, no "
- "usbdux devs connected to the usb bus.\n", dev->minor);
- up(&start_stop_sem);
- return -ENODEV;
- }
-
- udev = &usbduxsub[index];
- down(&udev->sem);
- /* pointer back to the corresponding comedi device */
- udev->comedidev = dev;
-
- /* trying to upload the firmware into the chip */
- if (comedi_aux_data(it->options, 0) &&
- it->options[COMEDI_DEVCONF_AUX_DATA_LENGTH]) {
- firmwareUpload(udev, comedi_aux_data(it->options, 0),
- it->options[COMEDI_DEVCONF_AUX_DATA_LENGTH]);
- }
-
- dev->board_name = BOARDNAME;
-
- /* set number of subdevices */
- if (udev->high_speed) {
- /* with pwm */
- dev->n_subdevices = 5;
- } else {
- /* without pwm */
- dev->n_subdevices = 4;
- }
-
- /* allocate space for the subdevices */
- ret = alloc_subdevices(dev, dev->n_subdevices);
- if (ret < 0) {
- dev_err(&udev->interface->dev,
- "comedi%d: error alloc space for subdev\n", dev->minor);
- up(&udev->sem);
- up(&start_stop_sem);
- return ret;
- }
-
- dev_info(&udev->interface->dev,
- "comedi%d: usb-device %d is attached to comedi.\n",
- dev->minor, index);
- /* private structure is also simply the usb-structure */
- dev->private = udev;
-
- /* the first subdevice is the A/D converter */
- s = dev->subdevices + SUBDEV_AD;
- /* the URBs get the comedi subdevice */
- /* which is responsible for reading */
- /* this is the subdevice which reads data */
- dev->read_subdev = s;
- /* the subdevice receives as private structure the */
- /* usb-structure */
- s->private = NULL;
- /* analog input */
- s->type = COMEDI_SUBD_AI;
- /* readable and ref is to ground */
- s->subdev_flags = SDF_READABLE | SDF_GROUND | SDF_CMD_READ;
- /* 8 channels */
- s->n_chan = 8;
- /* length of the channellist */
- s->len_chanlist = 8;
- /* callback functions */
- s->insn_read = usbdux_ai_insn_read;
- s->do_cmdtest = usbdux_ai_cmdtest;
- s->do_cmd = usbdux_ai_cmd;
- s->cancel = usbdux_ai_cancel;
- /* max value from the A/D converter (12bit) */
- s->maxdata = 0xfff;
- /* range table to convert to physical units */
- s->range_table = (&range_usbdux_ai_range);
-
- /* analog out */
- s = dev->subdevices + SUBDEV_DA;
- /* analog out */
- s->type = COMEDI_SUBD_AO;
- /* backward pointer */
- dev->write_subdev = s;
- /* the subdevice receives as private structure the */
- /* usb-structure */
- s->private = NULL;
- /* are writable */
- s->subdev_flags = SDF_WRITABLE | SDF_GROUND | SDF_CMD_WRITE;
- /* 4 channels */
- s->n_chan = 4;
- /* length of the channellist */
- s->len_chanlist = 4;
- /* 12 bit resolution */
- s->maxdata = 0x0fff;
- /* bipolar range */
- s->range_table = (&range_usbdux_ao_range);
- /* callback */
- s->do_cmdtest = usbdux_ao_cmdtest;
- s->do_cmd = usbdux_ao_cmd;
- s->cancel = usbdux_ao_cancel;
- s->insn_read = usbdux_ao_insn_read;
- s->insn_write = usbdux_ao_insn_write;
-
- /* digital I/O */
- s = dev->subdevices + SUBDEV_DIO;
- s->type = COMEDI_SUBD_DIO;
- s->subdev_flags = SDF_READABLE | SDF_WRITABLE;
- s->n_chan = 8;
- s->maxdata = 1;
- s->range_table = (&range_digital);
- s->insn_bits = usbdux_dio_insn_bits;
- s->insn_config = usbdux_dio_insn_config;
- /* we don't use it */
- s->private = NULL;
-
- /* counter */
- s = dev->subdevices + SUBDEV_COUNTER;
- s->type = COMEDI_SUBD_COUNTER;
- s->subdev_flags = SDF_WRITABLE | SDF_READABLE;
- s->n_chan = 4;
- s->maxdata = 0xFFFF;
- s->insn_read = usbdux_counter_read;
- s->insn_write = usbdux_counter_write;
- s->insn_config = usbdux_counter_config;
-
- if (udev->high_speed) {
- /* timer / pwm */
- s = dev->subdevices + SUBDEV_PWM;
- s->type = COMEDI_SUBD_PWM;
- s->subdev_flags = SDF_WRITABLE | SDF_PWM_HBRIDGE;
- s->n_chan = 8;
- /* this defines the max duty cycle resolution */
- s->maxdata = udev->sizePwmBuf;
- s->insn_write = usbdux_pwm_write;
- s->insn_read = usbdux_pwm_read;
- s->insn_config = usbdux_pwm_config;
- usbdux_pwm_period(dev, s, PWM_DEFAULT_PERIOD);
- }
- /* finally decide that it's attached */
- udev->attached = 1;
-
- up(&udev->sem);
-
- up(&start_stop_sem);
-
- dev_info(&udev->interface->dev, "comedi%d: attached to usbdux.\n",
- dev->minor);
-
- return 0;
-}
-
-static int usbdux_detach(struct comedi_device *dev)
-{
- struct usbduxsub *usbduxsub_tmp;
-
- if (!dev) {
- printk(KERN_ERR
- "comedi?: usbdux: detach without dev variable...\n");
- return -EFAULT;
- }
-
- usbduxsub_tmp = dev->private;
- if (!usbduxsub_tmp) {
- printk(KERN_ERR
- "comedi?: usbdux: detach without ptr to usbduxsub[]\n");
- return -EFAULT;
- }
-
- dev_dbg(&usbduxsub_tmp->interface->dev, "comedi%d: detach usb device\n",
- dev->minor);
-
- down(&usbduxsub_tmp->sem);
- /* Don't allow detach to free the private structure */
- /* It's one entry of of usbduxsub[] */
- dev->private = NULL;
- usbduxsub_tmp->attached = 0;
- usbduxsub_tmp->comedidev = NULL;
- dev_dbg(&usbduxsub_tmp->interface->dev,
- "comedi%d: detach: successfully removed\n", dev->minor);
- up(&usbduxsub_tmp->sem);
- return 0;
-}
-
-/* main driver struct */
-static struct comedi_driver driver_usbdux = {
- .driver_name = "usbdux",
- .module = THIS_MODULE,
- .attach = usbdux_attach,
- .detach = usbdux_detach,
-};
-
-/* Table with the USB-devices: just now only testing IDs */
-static const struct usb_device_id usbduxsub_table[] = {
- {USB_DEVICE(0x13d8, 0x0001)},
- {USB_DEVICE(0x13d8, 0x0002)},
- {} /* Terminating entry */
+static const struct usb_device_id usbdux_usb_table[] = {
+ { USB_DEVICE(0x13d8, 0x0001) },
+ { USB_DEVICE(0x13d8, 0x0002) },
+ { }
};
-MODULE_DEVICE_TABLE(usb, usbduxsub_table);
+MODULE_DEVICE_TABLE(usb, usbdux_usb_table);
-/* The usbduxsub-driver */
-static struct usb_driver usbduxsub_driver = {
- .name = BOARDNAME,
- .probe = usbduxsub_probe,
- .disconnect = usbduxsub_disconnect,
- .id_table = usbduxsub_table,
+static struct usb_driver usbdux_usb_driver = {
+ .name = "usbdux",
+ .probe = usbdux_usb_probe,
+ .disconnect = usbdux_usb_disconnect,
+ .id_table = usbdux_usb_table,
};
+module_comedi_usb_driver(usbdux_driver, usbdux_usb_driver);
-/* Can't use the nice macro as I have also to initialise the USB */
-/* subsystem: */
-/* registering the usb-system _and_ the comedi-driver */
-static int __init init_usbdux(void)
-{
- printk(KERN_INFO KBUILD_MODNAME ": "
- DRIVER_VERSION ":" DRIVER_DESC "\n");
- usb_register(&usbduxsub_driver);
- comedi_driver_register(&driver_usbdux);
- return 0;
-}
-
-/* deregistering the comedi driver and the usb-subsystem */
-static void __exit exit_usbdux(void)
-{
- comedi_driver_unregister(&driver_usbdux);
- usb_deregister(&usbduxsub_driver);
-}
-
-module_init(init_usbdux);
-module_exit(exit_usbdux);
-
-MODULE_AUTHOR(DRIVER_AUTHOR);
-MODULE_DESCRIPTION(DRIVER_DESC);
+MODULE_AUTHOR("Bernd Porr, BerndPorr@f2s.com");
+MODULE_DESCRIPTION("Stirling/ITL USB-DUX -- Bernd.Porr@f2s.com");
MODULE_LICENSE("GPL");
diff --git a/drivers/staging/comedi/drivers/usbduxfast.c b/drivers/staging/comedi/drivers/usbduxfast.c
index 2a8e725b7859..d9911588c10a 100644
--- a/drivers/staging/comedi/drivers/usbduxfast.c
+++ b/drivers/staging/comedi/drivers/usbduxfast.c
@@ -49,11 +49,6 @@
#include "comedi_fc.h"
#include "../comedidev.h"
-#define DRIVER_VERSION "v1.0"
-#define DRIVER_AUTHOR "Bernd Porr, BerndPorr@f2s.com"
-#define DRIVER_DESC "USB-DUXfast, BerndPorr@f2s.com"
-#define BOARDNAME "usbduxfast"
-
/*
* timeout for the USB-transfer
*/
@@ -127,11 +122,6 @@
#define NUMUSBDUXFAST 16
/*
- * number of subdevices
- */
-#define N_SUBDEVICES 1
-
-/*
* analogue in subdevice
*/
#define SUBDEV_AD 0
@@ -453,14 +443,15 @@ static int usbduxfastsub_start(struct usbduxfastsub_s *udfs)
/* 7f92 to zero */
local_transfer_buffer[0] = 0;
/* bRequest, "Firmware" */
- ret = usb_control_msg(udfs->usbdev, usb_sndctrlpipe(udfs->usbdev, 0), USBDUXFASTSUB_FIRMWARE,
- VENDOR_DIR_OUT, /* bmRequestType */
- USBDUXFASTSUB_CPUCS, /* Value */
- 0x0000, /* Index */
- /* address of the transfer buffer */
- local_transfer_buffer,
- 1, /* Length */
- EZTIMEOUT); /* Timeout */
+ ret = usb_control_msg(udfs->usbdev, usb_sndctrlpipe(udfs->usbdev, 0),
+ USBDUXFASTSUB_FIRMWARE,
+ VENDOR_DIR_OUT, /* bmRequestType */
+ USBDUXFASTSUB_CPUCS, /* Value */
+ 0x0000, /* Index */
+ /* address of the transfer buffer */
+ local_transfer_buffer,
+ 1, /* Length */
+ EZTIMEOUT); /* Timeout */
if (ret < 0) {
printk("comedi_: usbduxfast_: control msg failed (start)\n");
return ret;
@@ -477,7 +468,8 @@ static int usbduxfastsub_stop(struct usbduxfastsub_s *udfs)
/* 7f92 to one */
local_transfer_buffer[0] = 1;
/* bRequest, "Firmware" */
- ret = usb_control_msg(udfs->usbdev, usb_sndctrlpipe(udfs->usbdev, 0), USBDUXFASTSUB_FIRMWARE,
+ ret = usb_control_msg(udfs->usbdev, usb_sndctrlpipe(udfs->usbdev, 0),
+ USBDUXFASTSUB_FIRMWARE,
VENDOR_DIR_OUT, /* bmRequestType */
USBDUXFASTSUB_CPUCS, /* Value */
0x0000, /* Index */
@@ -504,14 +496,15 @@ static int usbduxfastsub_upload(struct usbduxfastsub_s *udfs,
startAddr, local_transfer_buffer[0]);
#endif
/* brequest, firmware */
- ret = usb_control_msg(udfs->usbdev, usb_sndctrlpipe(udfs->usbdev, 0), USBDUXFASTSUB_FIRMWARE,
- VENDOR_DIR_OUT, /* bmRequestType */
- startAddr, /* value */
- 0x0000, /* index */
- /* our local safe buffer */
- local_transfer_buffer,
- len, /* length */
- EZTIMEOUT); /* timeout */
+ ret = usb_control_msg(udfs->usbdev, usb_sndctrlpipe(udfs->usbdev, 0),
+ USBDUXFASTSUB_FIRMWARE,
+ VENDOR_DIR_OUT, /* bmRequestType */
+ startAddr, /* value */
+ 0x0000, /* index */
+ /* our local safe buffer */
+ local_transfer_buffer,
+ len, /* length */
+ EZTIMEOUT); /* timeout */
#ifdef CONFIG_COMEDI_DEBUG
printk(KERN_DEBUG "comedi_: usbduxfast: result=%d\n", ret);
@@ -1436,11 +1429,154 @@ static void tidy_up(struct usbduxfastsub_s *udfs)
udfs->ai_cmd_running = 0;
}
+/* common part of attach and attach_usb */
+static int usbduxfast_attach_common(struct comedi_device *dev,
+ struct usbduxfastsub_s *udfs,
+ void *aux_data, int aux_len)
+{
+ int ret;
+ struct comedi_subdevice *s;
+
+ down(&udfs->sem);
+ /* pointer back to the corresponding comedi device */
+ udfs->comedidev = dev;
+ /* trying to upload the firmware into the chip */
+ if (aux_data)
+ firmwareUpload(udfs, aux_data, aux_len);
+ dev->board_name = "usbduxfast";
+ ret = comedi_alloc_subdevices(dev, 1);
+ if (ret) {
+ up(&udfs->sem);
+ return ret;
+ }
+ /* private structure is also simply the usb-structure */
+ dev->private = udfs;
+ /* the first subdevice is the A/D converter */
+ s = dev->subdevices + SUBDEV_AD;
+ /*
+ * the URBs get the comedi subdevice which is responsible for reading
+ * this is the subdevice which reads data
+ */
+ dev->read_subdev = s;
+ /* the subdevice receives as private structure the usb-structure */
+ s->private = NULL;
+ /* analog input */
+ s->type = COMEDI_SUBD_AI;
+ /* readable and ref is to ground */
+ s->subdev_flags = SDF_READABLE | SDF_GROUND | SDF_CMD_READ;
+ /* 16 channels */
+ s->n_chan = 16;
+ /* length of the channellist */
+ s->len_chanlist = 16;
+ /* callback functions */
+ s->insn_read = usbduxfast_ai_insn_read;
+ s->do_cmdtest = usbduxfast_ai_cmdtest;
+ s->do_cmd = usbduxfast_ai_cmd;
+ s->cancel = usbduxfast_ai_cancel;
+ /* max value from the A/D converter (12bit+1 bit for overflow) */
+ s->maxdata = 0x1000;
+ /* range table to convert to physical units */
+ s->range_table = &range_usbduxfast_ai_range;
+ /* finally decide that it's attached */
+ udfs->attached = 1;
+ up(&udfs->sem);
+ dev_info(dev->class_dev, "successfully attached to usbduxfast.\n");
+ return 0;
+}
+
+/* is called for COMEDI_DEVCONFIG ioctl (when comedi_config is run) */
+static int usbduxfast_attach(struct comedi_device *dev,
+ struct comedi_devconfig *it)
+{
+ int ret;
+ int index;
+ int i;
+ void *aux_data;
+ int aux_len;
+
+ dev->private = NULL;
+
+ aux_data = comedi_aux_data(it->options, 0);
+ aux_len = it->options[COMEDI_DEVCONF_AUX_DATA_LENGTH];
+ if (aux_data == NULL)
+ aux_len = 0;
+ else if (aux_len == 0)
+ aux_data = NULL;
+ down(&start_stop_sem);
+ /*
+ * find a valid device which has been detected by the
+ * probe function of the usb
+ */
+ index = -1;
+ for (i = 0; i < NUMUSBDUXFAST; i++) {
+ if (usbduxfastsub[i].probed && !usbduxfastsub[i].attached) {
+ index = i;
+ break;
+ }
+ }
+ if (index < 0) {
+ dev_err(dev->class_dev,
+ "usbduxfast: error: attach failed, no usbduxfast devs connected to the usb bus.\n");
+ ret = -ENODEV;
+ } else
+ ret = usbduxfast_attach_common(dev, &usbduxfastsub[index],
+ aux_data, aux_len);
+ up(&start_stop_sem);
+ return ret;
+}
+
+/* is called from comedi_usb_auto_config() */
+static int usbduxfast_attach_usb(struct comedi_device *dev,
+ struct usb_interface *uinterf)
+{
+ int ret;
+ struct usbduxfastsub_s *udfs;
+
+ dev->private = NULL;
+ down(&start_stop_sem);
+ udfs = usb_get_intfdata(uinterf);
+ if (!udfs || !udfs->probed) {
+ dev_err(dev->class_dev,
+ "usbduxfast: error: attach_usb failed, not connected\n");
+ ret = -ENODEV;
+ } else if (udfs->attached) {
+ dev_err(dev->class_dev,
+ "usbduxfast: error: attach_usb failed, already attached\n");
+ ret = -ENODEV;
+ } else
+ ret = usbduxfast_attach_common(dev, udfs, NULL, 0);
+ up(&start_stop_sem);
+ return ret;
+}
+
+static void usbduxfast_detach(struct comedi_device *dev)
+{
+ struct usbduxfastsub_s *usb = dev->private;
+
+ if (usb) {
+ down(&usb->sem);
+ down(&start_stop_sem);
+ dev->private = NULL;
+ usb->attached = 0;
+ usb->comedidev = NULL;
+ up(&start_stop_sem);
+ up(&usb->sem);
+ }
+}
+
+static struct comedi_driver usbduxfast_driver = {
+ .driver_name = "usbduxfast",
+ .module = THIS_MODULE,
+ .attach = usbduxfast_attach,
+ .detach = usbduxfast_detach,
+ .attach_usb = usbduxfast_attach_usb,
+};
+
static void usbduxfast_firmware_request_complete_handler(const struct firmware
*fw, void *context)
{
struct usbduxfastsub_s *usbduxfastsub_tmp = context;
- struct usb_device *usbdev = usbduxfastsub_tmp->usbdev;
+ struct usb_interface *uinterf = usbduxfastsub_tmp->interface;
int ret;
if (fw == NULL)
@@ -1453,21 +1589,18 @@ static void usbduxfast_firmware_request_complete_handler(const struct firmware
ret = firmwareUpload(usbduxfastsub_tmp, fw->data, fw->size);
if (ret) {
- dev_err(&usbdev->dev,
+ dev_err(&uinterf->dev,
"Could not upload firmware (err=%d)\n", ret);
goto out;
}
- comedi_usb_auto_config(usbdev, BOARDNAME);
+ comedi_usb_auto_config(uinterf, &usbduxfast_driver);
out:
release_firmware(fw);
}
-/*
- * allocate memory for the urbs and initialise them
- */
-static int usbduxfastsub_probe(struct usb_interface *uinterf,
- const struct usb_device_id *id)
+static int usbduxfast_usb_probe(struct usb_interface *uinterf,
+ const struct usb_device_id *id)
{
struct usb_device *udev = interface_to_usbdev(uinterf);
int i;
@@ -1590,7 +1723,7 @@ static int usbduxfastsub_probe(struct usb_interface *uinterf,
return 0;
}
-static void usbduxfastsub_disconnect(struct usb_interface *intf)
+static void usbduxfast_usb_disconnect(struct usb_interface *intf)
{
struct usbduxfastsub_s *udfs = usb_get_intfdata(intf);
struct usb_device *udev = interface_to_usbdev(intf);
@@ -1606,7 +1739,7 @@ static void usbduxfastsub_disconnect(struct usb_interface *intf)
return;
}
- comedi_usb_auto_unconfig(udev);
+ comedi_usb_auto_unconfig(intf);
down(&start_stop_sem);
down(&udfs->sem);
@@ -1619,207 +1752,25 @@ static void usbduxfastsub_disconnect(struct usb_interface *intf)
#endif
}
-/*
- * is called when comedi-config is called
- */
-static int usbduxfast_attach(struct comedi_device *dev,
- struct comedi_devconfig *it)
-{
- int ret;
- int index;
- int i;
- struct comedi_subdevice *s = NULL;
- dev->private = NULL;
-
- down(&start_stop_sem);
- /*
- * find a valid device which has been detected by the
- * probe function of the usb
- */
- index = -1;
- for (i = 0; i < NUMUSBDUXFAST; i++) {
- if (usbduxfastsub[i].probed && !usbduxfastsub[i].attached) {
- index = i;
- break;
- }
- }
-
- if (index < 0) {
- printk(KERN_ERR "comedi%d: usbduxfast: error: attach failed, "
- "no usbduxfast devs connected to the usb bus.\n",
- dev->minor);
- up(&start_stop_sem);
- return -ENODEV;
- }
-
- down(&(usbduxfastsub[index].sem));
- /* pointer back to the corresponding comedi device */
- usbduxfastsub[index].comedidev = dev;
-
- /* trying to upload the firmware into the chip */
- if (comedi_aux_data(it->options, 0) &&
- it->options[COMEDI_DEVCONF_AUX_DATA_LENGTH]) {
- firmwareUpload(&usbduxfastsub[index],
- comedi_aux_data(it->options, 0),
- it->options[COMEDI_DEVCONF_AUX_DATA_LENGTH]);
- }
-
- dev->board_name = BOARDNAME;
-
- /* set number of subdevices */
- dev->n_subdevices = N_SUBDEVICES;
-
- /* allocate space for the subdevices */
- ret = alloc_subdevices(dev, N_SUBDEVICES);
- if (ret < 0) {
- printk(KERN_ERR "comedi%d: usbduxfast: error alloc space for "
- "subdev\n", dev->minor);
- up(&(usbduxfastsub[index].sem));
- up(&start_stop_sem);
- return ret;
- }
-
- printk(KERN_INFO "comedi%d: usbduxfast: usb-device %d is attached to "
- "comedi.\n", dev->minor, index);
- /* private structure is also simply the usb-structure */
- dev->private = usbduxfastsub + index;
- /* the first subdevice is the A/D converter */
- s = dev->subdevices + SUBDEV_AD;
- /*
- * the URBs get the comedi subdevice which is responsible for reading
- * this is the subdevice which reads data
- */
- dev->read_subdev = s;
- /* the subdevice receives as private structure the usb-structure */
- s->private = NULL;
- /* analog input */
- s->type = COMEDI_SUBD_AI;
- /* readable and ref is to ground */
- s->subdev_flags = SDF_READABLE | SDF_GROUND | SDF_CMD_READ;
- /* 16 channels */
- s->n_chan = 16;
- /* length of the channellist */
- s->len_chanlist = 16;
- /* callback functions */
- s->insn_read = usbduxfast_ai_insn_read;
- s->do_cmdtest = usbduxfast_ai_cmdtest;
- s->do_cmd = usbduxfast_ai_cmd;
- s->cancel = usbduxfast_ai_cancel;
- /* max value from the A/D converter (12bit+1 bit for overflow) */
- s->maxdata = 0x1000;
- /* range table to convert to physical units */
- s->range_table = &range_usbduxfast_ai_range;
-
- /* finally decide that it's attached */
- usbduxfastsub[index].attached = 1;
-
- up(&(usbduxfastsub[index].sem));
- up(&start_stop_sem);
- printk(KERN_INFO "comedi%d: successfully attached to usbduxfast.\n",
- dev->minor);
-
- return 0;
-}
-
-static int usbduxfast_detach(struct comedi_device *dev)
-{
- struct usbduxfastsub_s *udfs;
-
- if (!dev) {
- printk(KERN_ERR "comedi?: usbduxfast: detach without dev "
- "variable...\n");
- return -EFAULT;
- }
-#ifdef CONFIG_COMEDI_DEBUG
- printk(KERN_DEBUG "comedi%d: usbduxfast: detach usb device\n",
- dev->minor);
-#endif
-
- udfs = dev->private;
- if (!udfs) {
- printk(KERN_ERR "comedi?: usbduxfast: detach without ptr to "
- "usbduxfastsub[]\n");
- return -EFAULT;
- }
-
- down(&udfs->sem);
- down(&start_stop_sem);
- /*
- * Don't allow detach to free the private structure
- * It's one entry of of usbduxfastsub[]
- */
- dev->private = NULL;
- udfs->attached = 0;
- udfs->comedidev = NULL;
-#ifdef CONFIG_COMEDI_DEBUG
- printk(KERN_DEBUG "comedi%d: usbduxfast: detach: successfully "
- "removed\n", dev->minor);
-#endif
- up(&start_stop_sem);
- up(&udfs->sem);
- return 0;
-}
-
-/*
- * main driver struct
- */
-static struct comedi_driver driver_usbduxfast = {
- .driver_name = "usbduxfast",
- .module = THIS_MODULE,
- .attach = usbduxfast_attach,
- .detach = usbduxfast_detach
-};
-
-/*
- * Table with the USB-devices: just now only testing IDs
- */
-static const struct usb_device_id usbduxfastsub_table[] = {
+static const struct usb_device_id usbduxfast_usb_table[] = {
/* { USB_DEVICE(0x4b4, 0x8613) }, testing */
- {USB_DEVICE(0x13d8, 0x0010)}, /* real ID */
- {USB_DEVICE(0x13d8, 0x0011)}, /* real ID */
- {} /* Terminating entry */
+ { USB_DEVICE(0x13d8, 0x0010) }, /* real ID */
+ { USB_DEVICE(0x13d8, 0x0011) }, /* real ID */
+ { }
};
+MODULE_DEVICE_TABLE(usb, usbduxfast_usb_table);
-MODULE_DEVICE_TABLE(usb, usbduxfastsub_table);
-
-/*
- * The usbduxfastsub-driver
- */
-static struct usb_driver usbduxfastsub_driver = {
+static struct usb_driver usbduxfast_usb_driver = {
#ifdef COMEDI_HAVE_USB_DRIVER_OWNER
- .owner = THIS_MODULE,
+ .owner = THIS_MODULE,
#endif
- .name = BOARDNAME,
- .probe = usbduxfastsub_probe,
- .disconnect = usbduxfastsub_disconnect,
- .id_table = usbduxfastsub_table
+ .name = "usbduxfast",
+ .probe = usbduxfast_usb_probe,
+ .disconnect = usbduxfast_usb_disconnect,
+ .id_table = usbduxfast_usb_table,
};
+module_comedi_usb_driver(usbduxfast_driver, usbduxfast_usb_driver);
-/*
- * Can't use the nice macro as I have also to initialise the USB subsystem:
- * registering the usb-system _and_ the comedi-driver
- */
-static int __init init_usbduxfast(void)
-{
- printk(KERN_INFO
- KBUILD_MODNAME ": " DRIVER_VERSION ":" DRIVER_DESC "\n");
- usb_register(&usbduxfastsub_driver);
- comedi_driver_register(&driver_usbduxfast);
- return 0;
-}
-
-/*
- * deregistering the comedi driver and the usb-subsystem
- */
-static void __exit exit_usbduxfast(void)
-{
- comedi_driver_unregister(&driver_usbduxfast);
- usb_deregister(&usbduxfastsub_driver);
-}
-
-module_init(init_usbduxfast);
-module_exit(exit_usbduxfast);
-
-MODULE_AUTHOR(DRIVER_AUTHOR);
-MODULE_DESCRIPTION(DRIVER_DESC);
+MODULE_AUTHOR("Bernd Porr, BerndPorr@f2s.com");
+MODULE_DESCRIPTION("USB-DUXfast, BerndPorr@f2s.com");
MODULE_LICENSE("GPL");
diff --git a/drivers/staging/comedi/drivers/usbduxsigma.c b/drivers/staging/comedi/drivers/usbduxsigma.c
index 63c9b6dbc317..543e604791e2 100644
--- a/drivers/staging/comedi/drivers/usbduxsigma.c
+++ b/drivers/staging/comedi/drivers/usbduxsigma.c
@@ -1,6 +1,3 @@
-#define DRIVER_VERSION "v0.6"
-#define DRIVER_AUTHOR "Bernd Porr, BerndPorr@f2s.com"
-#define DRIVER_DESC "Stirling/ITL USB-DUX SIGMA -- Bernd.Porr@f2s.com"
/*
comedi/drivers/usbdux.c
Copyright (C) 2011 Bernd Porr, Bernd.Porr@f2s.com
@@ -62,8 +59,6 @@ Status: testing
#include "comedi_fc.h"
#include "../comedidev.h"
-#define BOARDNAME "usbduxsigma"
-
/* timeout for the USB-transfer in ms*/
#define BULK_TIMEOUT 1000
@@ -1356,7 +1351,7 @@ static int usbdux_ai_insn_read(struct comedi_device *dev,
/* 32 bits big endian from the A/D converter */
one = be32_to_cpu(*((int32_t *)
((this_usbduxsub->insnBuffer)+1)));
- /* mask out the staus byte */
+ /* mask out the status byte */
one = one & 0x00ffffff;
/* turn it into an unsigned integer */
one = one ^ 0x00800000;
@@ -1843,9 +1838,6 @@ static int usbdux_dio_insn_bits(struct comedi_device *dev,
if (!this_usbduxsub)
return -EFAULT;
- if (insn->n != 2)
- return -EINVAL;
-
down(&this_usbduxsub->sem);
if (!(this_usbduxsub->probed)) {
@@ -1885,7 +1877,7 @@ static int usbdux_dio_insn_bits(struct comedi_device *dev,
s->state = data[1];
up(&this_usbduxsub->sem);
- return 2;
+ return insn->n;
}
/***********************************/
@@ -2308,15 +2300,218 @@ static void tidy_up(struct usbduxsub *usbduxsub_tmp)
usbduxsub_tmp->pwm_cmd_running = 0;
}
+/* common part of attach and attach_usb */
+static int usbduxsigma_attach_common(struct comedi_device *dev,
+ struct usbduxsub *uds,
+ void *aux_data, int aux_len)
+{
+ int ret;
+ struct comedi_subdevice *s;
+ int n_subdevs;
+ int offset;
+
+ down(&uds->sem);
+ /* pointer back to the corresponding comedi device */
+ uds->comedidev = dev;
+ /* trying to upload the firmware into the FX2 */
+ if (aux_data)
+ firmwareUpload(uds, aux_data, aux_len);
+ dev->board_name = "usbduxsigma";
+ /* set number of subdevices */
+ if (uds->high_speed)
+ n_subdevs = 4; /* with pwm */
+ else
+ n_subdevs = 3; /* without pwm */
+ ret = comedi_alloc_subdevices(dev, n_subdevs);
+ if (ret) {
+ up(&uds->sem);
+ return ret;
+ }
+ /* private structure is also simply the usb-structure */
+ dev->private = uds;
+ /* the first subdevice is the A/D converter */
+ s = dev->subdevices + SUBDEV_AD;
+ /* the URBs get the comedi subdevice */
+ /* which is responsible for reading */
+ /* this is the subdevice which reads data */
+ dev->read_subdev = s;
+ /* the subdevice receives as private structure the */
+ /* usb-structure */
+ s->private = NULL;
+ /* analog input */
+ s->type = COMEDI_SUBD_AI;
+ /* readable and ref is to ground, 32 bit wide data! */
+ s->subdev_flags = SDF_READABLE | SDF_GROUND |
+ SDF_CMD_READ | SDF_LSAMPL;
+ /* 16 A/D channels */
+ s->n_chan = NUMCHANNELS;
+ /* length of the channellist */
+ s->len_chanlist = NUMCHANNELS;
+ /* callback functions */
+ s->insn_read = usbdux_ai_insn_read;
+ s->do_cmdtest = usbdux_ai_cmdtest;
+ s->do_cmd = usbdux_ai_cmd;
+ s->cancel = usbdux_ai_cancel;
+ /* max value from the A/D converter (24bit) */
+ s->maxdata = 0x00FFFFFF;
+ /* range table to convert to physical units */
+ s->range_table = (&range_usbdux_ai_range);
+ /* analog output subdevice */
+ s = dev->subdevices + SUBDEV_DA;
+ /* analog out */
+ s->type = COMEDI_SUBD_AO;
+ /* backward pointer */
+ dev->write_subdev = s;
+ /* the subdevice receives as private structure the */
+ /* usb-structure */
+ s->private = NULL;
+ /* are writable */
+ s->subdev_flags = SDF_WRITABLE | SDF_GROUND | SDF_CMD_WRITE;
+ /* 4 channels */
+ s->n_chan = 4;
+ /* length of the channellist */
+ s->len_chanlist = 4;
+ /* 8 bit resolution */
+ s->maxdata = 0x00ff;
+ /* unipolar range */
+ s->range_table = (&range_usbdux_ao_range);
+ /* callback */
+ s->do_cmdtest = usbdux_ao_cmdtest;
+ s->do_cmd = usbdux_ao_cmd;
+ s->cancel = usbdux_ao_cancel;
+ s->insn_read = usbdux_ao_insn_read;
+ s->insn_write = usbdux_ao_insn_write;
+ /* digital I/O subdevice */
+ s = dev->subdevices + SUBDEV_DIO;
+ s->type = COMEDI_SUBD_DIO;
+ s->subdev_flags = SDF_READABLE | SDF_WRITABLE;
+ /* 8 external and 16 internal channels */
+ s->n_chan = 24;
+ s->maxdata = 1;
+ s->range_table = (&range_digital);
+ s->insn_bits = usbdux_dio_insn_bits;
+ s->insn_config = usbdux_dio_insn_config;
+ /* we don't use it */
+ s->private = NULL;
+ if (uds->high_speed) {
+ /* timer / pwm subdevice */
+ s = dev->subdevices + SUBDEV_PWM;
+ s->type = COMEDI_SUBD_PWM;
+ s->subdev_flags = SDF_WRITABLE | SDF_PWM_HBRIDGE;
+ s->n_chan = 8;
+ /* this defines the max duty cycle resolution */
+ s->maxdata = uds->sizePwmBuf;
+ s->insn_write = usbdux_pwm_write;
+ s->insn_read = usbdux_pwm_read;
+ s->insn_config = usbdux_pwm_config;
+ usbdux_pwm_period(dev, s, PWM_DEFAULT_PERIOD);
+ }
+ /* finally decide that it's attached */
+ uds->attached = 1;
+ up(&uds->sem);
+ offset = usbdux_getstatusinfo(dev, 0);
+ if (offset < 0)
+ dev_err(&uds->interface->dev,
+ "Communication to USBDUXSIGMA failed! Check firmware and cabling.");
+ dev_info(&uds->interface->dev,
+ "comedi%d: attached, ADC_zero = %x\n", dev->minor, offset);
+ return 0;
+}
+
+/* is called for COMEDI_DEVCONFIG ioctl (when comedi_config is run) */
+static int usbduxsigma_attach(struct comedi_device *dev,
+ struct comedi_devconfig *it)
+{
+ int ret;
+ int index;
+ int i;
+ void *aux_data;
+ int aux_len;
+
+ dev->private = NULL;
+
+ aux_data = comedi_aux_data(it->options, 0);
+ aux_len = it->options[COMEDI_DEVCONF_AUX_DATA_LENGTH];
+ if (aux_data == NULL)
+ aux_len = 0;
+ else if (aux_len == 0)
+ aux_data = NULL;
+
+ down(&start_stop_sem);
+ /* find a valid device which has been detected by the probe function of
+ * the usb */
+ index = -1;
+ for (i = 0; i < NUMUSBDUX; i++) {
+ if ((usbduxsub[i].probed) && (!usbduxsub[i].attached)) {
+ index = i;
+ break;
+ }
+ }
+ if (index < 0) {
+ dev_err(dev->class_dev,
+ "usbduxsigma: error: attach failed, dev not connected to the usb bus.\n");
+ ret = -ENODEV;
+ } else
+ ret = usbduxsigma_attach_common(dev, &usbduxsub[index],
+ aux_data, aux_len);
+ up(&start_stop_sem);
+ return ret;
+}
+
+/* is called from comedi_usb_auto_config() */
+static int usbduxsigma_attach_usb(struct comedi_device *dev,
+ struct usb_interface *uinterf)
+{
+ int ret;
+ struct usbduxsub *uds;
+
+ dev->private = NULL;
+ down(&start_stop_sem);
+ uds = usb_get_intfdata(uinterf);
+ if (!uds || !uds->probed) {
+ dev_err(dev->class_dev,
+ "usbduxsigma: error: attach_usb failed, not connected\n");
+ ret = -ENODEV;
+ } else if (uds->attached) {
+ dev_err(dev->class_dev,
+ "usbduxsigma: error: attach_usb failed, already attached\n");
+ ret = -ENODEV;
+ } else
+ ret = usbduxsigma_attach_common(dev, uds, NULL, 0);
+ up(&start_stop_sem);
+ return ret;
+}
+
+static void usbduxsigma_detach(struct comedi_device *dev)
+{
+ struct usbduxsub *usb = dev->private;
+
+ if (usb) {
+ down(&usb->sem);
+ dev->private = NULL;
+ usb->attached = 0;
+ usb->comedidev = NULL;
+ up(&usb->sem);
+ }
+}
+
+static struct comedi_driver usbduxsigma_driver = {
+ .driver_name = "usbduxsigma",
+ .module = THIS_MODULE,
+ .attach = usbduxsigma_attach,
+ .detach = usbduxsigma_detach,
+ .attach_usb = usbduxsigma_attach_usb,
+};
+
static void usbdux_firmware_request_complete_handler(const struct firmware *fw,
void *context)
{
struct usbduxsub *usbduxsub_tmp = context;
- struct usb_device *usbdev = usbduxsub_tmp->usbdev;
+ struct usb_interface *uinterf = usbduxsub_tmp->interface;
int ret;
if (fw == NULL) {
- dev_err(&usbdev->dev,
+ dev_err(&uinterf->dev,
"Firmware complete handler without firmware!\n");
return;
}
@@ -2328,18 +2523,17 @@ static void usbdux_firmware_request_complete_handler(const struct firmware *fw,
ret = firmwareUpload(usbduxsub_tmp, fw->data, fw->size);
if (ret) {
- dev_err(&usbdev->dev,
+ dev_err(&uinterf->dev,
"Could not upload firmware (err=%d)\n", ret);
goto out;
}
- comedi_usb_auto_config(usbdev, BOARDNAME);
+ comedi_usb_auto_config(uinterf, &usbduxsigma_driver);
out:
release_firmware(fw);
}
-/* allocate memory for the urbs and initialise them */
-static int usbduxsigma_probe(struct usb_interface *uinterf,
- const struct usb_device_id *id)
+static int usbduxsigma_usb_probe(struct usb_interface *uinterf,
+ const struct usb_device_id *id)
{
struct usb_device *udev = interface_to_usbdev(uinterf);
struct device *dev = &uinterf->dev;
@@ -2603,7 +2797,7 @@ static int usbduxsigma_probe(struct usb_interface *uinterf,
return 0;
}
-static void usbduxsigma_disconnect(struct usb_interface *intf)
+static void usbduxsigma_usb_disconnect(struct usb_interface *intf)
{
struct usbduxsub *usbduxsub_tmp = usb_get_intfdata(intf);
struct usb_device *udev = interface_to_usbdev(intf);
@@ -2623,7 +2817,7 @@ static void usbduxsigma_disconnect(struct usb_interface *intf)
if (usbduxsub_tmp->ao_cmd_running)
/* we are still running a command */
usbdux_ao_stop(usbduxsub_tmp, 1);
- comedi_usb_auto_unconfig(udev);
+ comedi_usb_auto_unconfig(intf);
down(&start_stop_sem);
down(&usbduxsub_tmp->sem);
tidy_up(usbduxsub_tmp);
@@ -2632,254 +2826,22 @@ static void usbduxsigma_disconnect(struct usb_interface *intf)
dev_info(&intf->dev, "comedi_: disconnected from the usb\n");
}
-/* is called when comedi-config is called */
-static int usbduxsigma_attach(struct comedi_device *dev,
- struct comedi_devconfig *it)
-{
- int ret;
- int index;
- int i;
- struct usbduxsub *udev;
-
- int offset;
-
- struct comedi_subdevice *s = NULL;
- dev->private = NULL;
-
- down(&start_stop_sem);
- /* find a valid device which has been detected by the probe function of
- * the usb */
- index = -1;
- for (i = 0; i < NUMUSBDUX; i++) {
- if ((usbduxsub[i].probed) && (!usbduxsub[i].attached)) {
- index = i;
- break;
- }
- }
-
- if (index < 0) {
- printk(KERN_ERR "comedi%d: usbduxsigma: error: attach failed,"
- "dev not connected to the usb bus.\n", dev->minor);
- up(&start_stop_sem);
- return -ENODEV;
- }
-
- udev = &usbduxsub[index];
- down(&udev->sem);
- /* pointer back to the corresponding comedi device */
- udev->comedidev = dev;
-
- /* trying to upload the firmware into the FX2 */
- if (comedi_aux_data(it->options, 0) &&
- it->options[COMEDI_DEVCONF_AUX_DATA_LENGTH]) {
- firmwareUpload(udev, comedi_aux_data(it->options, 0),
- it->options[COMEDI_DEVCONF_AUX_DATA_LENGTH]);
- }
-
- dev->board_name = BOARDNAME;
-
- /* set number of subdevices */
- if (udev->high_speed) {
- /* with pwm */
- dev->n_subdevices = 4;
- } else {
- /* without pwm */
- dev->n_subdevices = 3;
- }
-
- /* allocate space for the subdevices */
- ret = alloc_subdevices(dev, dev->n_subdevices);
- if (ret < 0) {
- dev_err(&udev->interface->dev,
- "comedi%d: no space for subdev\n", dev->minor);
- up(&udev->sem);
- up(&start_stop_sem);
- return ret;
- }
-
- /* private structure is also simply the usb-structure */
- dev->private = udev;
-
- /* the first subdevice is the A/D converter */
- s = dev->subdevices + SUBDEV_AD;
- /* the URBs get the comedi subdevice */
- /* which is responsible for reading */
- /* this is the subdevice which reads data */
- dev->read_subdev = s;
- /* the subdevice receives as private structure the */
- /* usb-structure */
- s->private = NULL;
- /* analog input */
- s->type = COMEDI_SUBD_AI;
- /* readable and ref is to ground, 32 bit wide data! */
- s->subdev_flags = SDF_READABLE | SDF_GROUND |
- SDF_CMD_READ | SDF_LSAMPL;
- /* 16 A/D channels */
- s->n_chan = NUMCHANNELS;
- /* length of the channellist */
- s->len_chanlist = NUMCHANNELS;
- /* callback functions */
- s->insn_read = usbdux_ai_insn_read;
- s->do_cmdtest = usbdux_ai_cmdtest;
- s->do_cmd = usbdux_ai_cmd;
- s->cancel = usbdux_ai_cancel;
- /* max value from the A/D converter (24bit) */
- s->maxdata = 0x00FFFFFF;
- /* range table to convert to physical units */
- s->range_table = (&range_usbdux_ai_range);
-
- /* analog out */
- s = dev->subdevices + SUBDEV_DA;
- /* analog out */
- s->type = COMEDI_SUBD_AO;
- /* backward pointer */
- dev->write_subdev = s;
- /* the subdevice receives as private structure the */
- /* usb-structure */
- s->private = NULL;
- /* are writable */
- s->subdev_flags = SDF_WRITABLE | SDF_GROUND | SDF_CMD_WRITE;
- /* 4 channels */
- s->n_chan = 4;
- /* length of the channellist */
- s->len_chanlist = 4;
- /* 8 bit resolution */
- s->maxdata = 0x00ff;
- /* unipolar range */
- s->range_table = (&range_usbdux_ao_range);
- /* callback */
- s->do_cmdtest = usbdux_ao_cmdtest;
- s->do_cmd = usbdux_ao_cmd;
- s->cancel = usbdux_ao_cancel;
- s->insn_read = usbdux_ao_insn_read;
- s->insn_write = usbdux_ao_insn_write;
-
- /* digital I/O */
- s = dev->subdevices + SUBDEV_DIO;
- s->type = COMEDI_SUBD_DIO;
- s->subdev_flags = SDF_READABLE | SDF_WRITABLE;
- /* 8 external and 16 internal channels */
- s->n_chan = 24;
- s->maxdata = 1;
- s->range_table = (&range_digital);
- s->insn_bits = usbdux_dio_insn_bits;
- s->insn_config = usbdux_dio_insn_config;
- /* we don't use it */
- s->private = NULL;
-
- if (udev->high_speed) {
- /* timer / pwm */
- s = dev->subdevices + SUBDEV_PWM;
- s->type = COMEDI_SUBD_PWM;
- s->subdev_flags = SDF_WRITABLE | SDF_PWM_HBRIDGE;
- s->n_chan = 8;
- /* this defines the max duty cycle resolution */
- s->maxdata = udev->sizePwmBuf;
- s->insn_write = usbdux_pwm_write;
- s->insn_read = usbdux_pwm_read;
- s->insn_config = usbdux_pwm_config;
- usbdux_pwm_period(dev, s, PWM_DEFAULT_PERIOD);
- }
- /* finally decide that it's attached */
- udev->attached = 1;
-
- up(&udev->sem);
-
- up(&start_stop_sem);
-
- offset = usbdux_getstatusinfo(dev, 0);
- if (offset < 0)
- dev_err(&udev->interface->dev,
- "Communication to USBDUXSIGMA failed!"
- "Check firmware and cabling.");
-
- dev_info(&udev->interface->dev,
- "comedi%d: attached, ADC_zero = %x", dev->minor, offset);
-
- return 0;
-}
-
-static int usbduxsigma_detach(struct comedi_device *dev)
-{
- struct usbduxsub *usbduxsub_tmp;
-
- if (!dev) {
- printk(KERN_ERR
- "comedi? usbduxsigma detach: dev=NULL\n");
- return -EFAULT;
- }
-
- usbduxsub_tmp = dev->private;
- if (!usbduxsub_tmp) {
- printk(KERN_ERR
- "comedi?: usbduxsigma detach: private=NULL\n");
- return -EFAULT;
- }
-
- dev_dbg(&usbduxsub_tmp->interface->dev,
- "comedi%d: detach usb device\n",
- dev->minor);
-
- down(&usbduxsub_tmp->sem);
- /* Don't allow detach to free the private structure */
- /* It's one entry of of usbduxsub[] */
- dev->private = NULL;
- usbduxsub_tmp->attached = 0;
- usbduxsub_tmp->comedidev = NULL;
- dev_info(&usbduxsub_tmp->interface->dev,
- "comedi%d: successfully detached.\n", dev->minor);
- up(&usbduxsub_tmp->sem);
- return 0;
-}
-
-/* main driver struct */
-static struct comedi_driver driver_usbduxsigma = {
- .driver_name = "usbduxsigma",
- .module = THIS_MODULE,
- .attach = usbduxsigma_attach,
- .detach = usbduxsigma_detach,
-};
-
-/* Table with the USB-devices */
-static const struct usb_device_id usbduxsigma_table[] = {
- {USB_DEVICE(0x13d8, 0x0020)},
- {USB_DEVICE(0x13d8, 0x0021)},
- {USB_DEVICE(0x13d8, 0x0022)},
- {} /* Terminating entry */
+static const struct usb_device_id usbduxsigma_usb_table[] = {
+ { USB_DEVICE(0x13d8, 0x0020) },
+ { USB_DEVICE(0x13d8, 0x0021) },
+ { USB_DEVICE(0x13d8, 0x0022) },
+ { }
};
+MODULE_DEVICE_TABLE(usb, usbduxsigma_usb_table);
-MODULE_DEVICE_TABLE(usb, usbduxsigma_table);
-
-/* The usbduxsub-driver */
-static struct usb_driver usbduxsigma_driver = {
- .name = BOARDNAME,
- .probe = usbduxsigma_probe,
- .disconnect = usbduxsigma_disconnect,
- .id_table = usbduxsigma_table,
+static struct usb_driver usbduxsigma_usb_driver = {
+ .name = "usbduxsigma",
+ .probe = usbduxsigma_usb_probe,
+ .disconnect = usbduxsigma_usb_disconnect,
+ .id_table = usbduxsigma_usb_table,
};
+module_comedi_usb_driver(usbduxsigma_driver, usbduxsigma_usb_driver);
-/* Can't use the nice macro as I have also to initialise the USB */
-/* subsystem: */
-/* registering the usb-system _and_ the comedi-driver */
-static int __init init_usbduxsigma(void)
-{
- printk(KERN_INFO KBUILD_MODNAME ": "
- DRIVER_VERSION ":" DRIVER_DESC "\n");
- usb_register(&usbduxsigma_driver);
- comedi_driver_register(&driver_usbduxsigma);
- return 0;
-}
-
-/* deregistering the comedi driver and the usb-subsystem */
-static void __exit exit_usbduxsigma(void)
-{
- comedi_driver_unregister(&driver_usbduxsigma);
- usb_deregister(&usbduxsigma_driver);
-}
-
-module_init(init_usbduxsigma);
-module_exit(exit_usbduxsigma);
-
-MODULE_AUTHOR(DRIVER_AUTHOR);
-MODULE_DESCRIPTION(DRIVER_DESC);
+MODULE_AUTHOR("Bernd Porr, BerndPorr@f2s.com");
+MODULE_DESCRIPTION("Stirling/ITL USB-DUX SIGMA -- Bernd.Porr@f2s.com");
MODULE_LICENSE("GPL");
diff --git a/drivers/staging/comedi/drivers/vmk80xx.c b/drivers/staging/comedi/drivers/vmk80xx.c
index 3d13ca6e1670..94010fc05905 100644
--- a/drivers/staging/comedi/drivers/vmk80xx.c
+++ b/drivers/staging/comedi/drivers/vmk80xx.c
@@ -64,37 +64,11 @@ Changelog:
#include "../comedidev.h"
-#define BOARDNAME "vmk80xx"
-
-MODULE_AUTHOR("Manuel Gebele <forensixs@gmx.de>");
-MODULE_DESCRIPTION("Velleman USB Board Low-Level Driver");
-MODULE_SUPPORTED_DEVICE("K8055/K8061 aka VM110/VM140");
-MODULE_VERSION("0.8.01");
-MODULE_LICENSE("GPL");
-
enum {
DEVICE_VMK8055,
DEVICE_VMK8061
};
-static const struct usb_device_id vmk80xx_id_table[] = {
- {USB_DEVICE(0x10cf, 0x5500), .driver_info = DEVICE_VMK8055},
- {USB_DEVICE(0x10cf, 0x5501), .driver_info = DEVICE_VMK8055},
- {USB_DEVICE(0x10cf, 0x5502), .driver_info = DEVICE_VMK8055},
- {USB_DEVICE(0x10cf, 0x5503), .driver_info = DEVICE_VMK8055},
- {USB_DEVICE(0x10cf, 0x8061), .driver_info = DEVICE_VMK8061},
- {USB_DEVICE(0x10cf, 0x8062), .driver_info = DEVICE_VMK8061},
- {USB_DEVICE(0x10cf, 0x8063), .driver_info = DEVICE_VMK8061},
- {USB_DEVICE(0x10cf, 0x8064), .driver_info = DEVICE_VMK8061},
- {USB_DEVICE(0x10cf, 0x8065), .driver_info = DEVICE_VMK8061},
- {USB_DEVICE(0x10cf, 0x8066), .driver_info = DEVICE_VMK8061},
- {USB_DEVICE(0x10cf, 0x8067), .driver_info = DEVICE_VMK8061},
- {USB_DEVICE(0x10cf, 0x8068), .driver_info = DEVICE_VMK8061},
- {} /* terminating entry */
-};
-
-MODULE_DEVICE_TABLE(usb, vmk80xx_id_table);
-
#define VMK8055_DI_REG 0x00
#define VMK8055_DO_REG 0x01
#define VMK8055_AO1_REG 0x02
@@ -151,27 +125,12 @@ MODULE_DEVICE_TABLE(usb, vmk80xx_id_table);
#define URB_RCV_FLAG (1 << 0)
#define URB_SND_FLAG (1 << 1)
-#define CONFIG_VMK80XX_DEBUG
-#undef CONFIG_VMK80XX_DEBUG
-
-#ifdef CONFIG_VMK80XX_DEBUG
-static int dbgvm = 1;
-#else
-static int dbgvm;
-#endif
-
#ifdef CONFIG_COMEDI_DEBUG
static int dbgcm = 1;
#else
static int dbgcm;
#endif
-#define dbgvm(fmt, arg...) \
-do { \
- if (dbgvm) \
- printk(KERN_DEBUG fmt, ##arg); \
-} while (0)
-
#define dbgcm(fmt, arg...) \
do { \
if (dbgcm) \
@@ -252,8 +211,6 @@ static void vmk80xx_tx_callback(struct urb *urb)
struct vmk80xx_usb *dev = urb->context;
int stat = urb->status;
- dbgvm("vmk80xx: %s\n", __func__);
-
if (stat && !(stat == -ENOENT
|| stat == -ECONNRESET || stat == -ESHUTDOWN))
dbgcm("comedi#: vmk80xx: %s - nonzero urb status (%d)\n",
@@ -272,8 +229,6 @@ static void vmk80xx_rx_callback(struct urb *urb)
struct vmk80xx_usb *dev = urb->context;
int stat = urb->status;
- dbgvm("vmk80xx: %s\n", __func__);
-
switch (stat) {
case 0:
break;
@@ -295,7 +250,9 @@ resubmit:
if (!usb_submit_urb(urb, GFP_KERNEL))
goto exit;
- err("comedi#: vmk80xx: %s - submit urb failed\n", __func__);
+ dev_err(&urb->dev->dev,
+ "comedi#: vmk80xx: %s - submit urb failed\n",
+ __func__);
usb_unanchor_urb(urb);
}
@@ -312,8 +269,6 @@ static int vmk80xx_check_data_link(struct vmk80xx_usb *dev)
unsigned char tx[1];
unsigned char rx[2];
- dbgvm("vmk80xx: %s\n", __func__);
-
tx_pipe = usb_sndbulkpipe(dev->udev, 0x01);
rx_pipe = usb_rcvbulkpipe(dev->udev, 0x81);
@@ -338,8 +293,6 @@ static void vmk80xx_read_eeprom(struct vmk80xx_usb *dev, int flag)
unsigned char rx[64];
int cnt;
- dbgvm("vmk80xx: %s\n", __func__);
-
tx_pipe = usb_sndbulkpipe(dev->udev, 0x01);
rx_pipe = usb_rcvbulkpipe(dev->udev, 0x81);
@@ -367,8 +320,6 @@ static int vmk80xx_reset_device(struct vmk80xx_usb *dev)
int ival;
size_t size;
- dbgvm("vmk80xx: %s\n", __func__);
-
urb = usb_alloc_urb(0, GFP_KERNEL);
if (!urb)
return -ENOMEM;
@@ -406,8 +357,6 @@ static void vmk80xx_build_int_urb(struct urb *urb, int flag)
void (*callback) (struct urb *);
int ival;
- dbgvm("vmk80xx: %s\n", __func__);
-
if (flag & URB_RCV_FLAG) {
rx_addr = dev->ep_rx->bEndpointAddress;
pipe = usb_rcvintpipe(dev->udev, rx_addr);
@@ -435,8 +384,6 @@ static void vmk80xx_do_bulk_msg(struct vmk80xx_usb *dev)
unsigned int rx_pipe;
size_t size;
- dbgvm("vmk80xx: %s\n", __func__);
-
set_bit(TRANS_IN_BUSY, &dev->flags);
set_bit(TRANS_OUT_BUSY, &dev->flags);
@@ -464,8 +411,6 @@ static int vmk80xx_read_packet(struct vmk80xx_usb *dev)
struct urb *urb;
int retval;
- dbgvm("vmk80xx: %s\n", __func__);
-
if (!dev->intf)
return -ENODEV;
@@ -512,8 +457,6 @@ static int vmk80xx_write_packet(struct vmk80xx_usb *dev, int cmd)
struct urb *urb;
int retval;
- dbgvm("vmk80xx: %s\n", __func__);
-
if (!dev->intf)
return -ENODEV;
@@ -588,8 +531,6 @@ static int vmk80xx_ai_rinsn(struct comedi_device *cdev,
int reg[2];
int n;
- dbgvm("vmk80xx: %s\n", __func__);
-
n = rudimentary_check(dev, DIR_IN);
if (n)
return n;
@@ -641,8 +582,6 @@ static int vmk80xx_ao_winsn(struct comedi_device *cdev,
int reg;
int n;
- dbgvm("vmk80xx: %s\n", __func__);
-
n = rudimentary_check(dev, DIR_OUT);
if (n)
return n;
@@ -686,8 +625,6 @@ static int vmk80xx_ao_rinsn(struct comedi_device *cdev,
int reg;
int n;
- dbgvm("vmk80xx: %s\n", __func__);
-
n = rudimentary_check(dev, DIR_IN);
if (n)
return n;
@@ -720,8 +657,6 @@ static int vmk80xx_di_bits(struct comedi_device *cdev,
int reg;
int retval;
- dbgvm("vmk80xx: %s\n", __func__);
-
retval = rudimentary_check(dev, DIR_IN);
if (retval)
return retval;
@@ -766,8 +701,6 @@ static int vmk80xx_di_rinsn(struct comedi_device *cdev,
int inp;
int n;
- dbgvm("vmk80xx: %s\n", __func__);
-
n = rudimentary_check(dev, DIR_IN);
if (n)
return n;
@@ -813,8 +746,6 @@ static int vmk80xx_do_winsn(struct comedi_device *cdev,
int cmd;
int n;
- dbgvm("vmk80xx: %s\n", __func__);
-
n = rudimentary_check(dev, DIR_OUT);
if (n)
return n;
@@ -861,8 +792,6 @@ static int vmk80xx_do_rinsn(struct comedi_device *cdev,
int reg;
int n;
- dbgvm("vmk80xx: %s\n", __func__);
-
n = rudimentary_check(dev, DIR_IN);
if (n)
return n;
@@ -895,8 +824,6 @@ static int vmk80xx_do_bits(struct comedi_device *cdev,
int dir, reg, cmd;
int retval;
- dbgvm("vmk80xx: %s\n", __func__);
-
dir = 0;
if (data[0])
@@ -962,8 +889,6 @@ static int vmk80xx_cnt_rinsn(struct comedi_device *cdev,
int reg[2];
int n;
- dbgvm("vmk80xx: %s\n", __func__);
-
n = rudimentary_check(dev, DIR_IN);
if (n)
return n;
@@ -1012,18 +937,16 @@ static int vmk80xx_cnt_cinsn(struct comedi_device *cdev,
int reg;
int n;
- dbgvm("vmk80xx: %s\n", __func__);
-
n = rudimentary_check(dev, DIR_OUT);
if (n)
return n;
- down(&dev->limit_sem);
-
insn_cmd = data[0];
if (insn_cmd != INSN_CONFIG_RESET && insn_cmd != GPCT_RESET)
return -EINVAL;
+ down(&dev->limit_sem);
+
chan = CR_CHAN(insn->chanspec);
if (dev->board.model == VMK8055_MODEL) {
@@ -1060,8 +983,6 @@ static int vmk80xx_cnt_winsn(struct comedi_device *cdev,
int cmd;
int n;
- dbgvm("vmk80xx: %s\n", __func__);
-
n = rudimentary_check(dev, DIR_OUT);
if (n)
return n;
@@ -1106,8 +1027,6 @@ static int vmk80xx_pwm_rinsn(struct comedi_device *cdev,
int reg[2];
int n;
- dbgvm("vmk80xx: %s\n", __func__);
-
n = rudimentary_check(dev, DIR_IN);
if (n)
return n;
@@ -1141,8 +1060,6 @@ static int vmk80xx_pwm_winsn(struct comedi_device *cdev,
int cmd;
int n;
- dbgvm("vmk80xx: %s\n", __func__);
-
n = rudimentary_check(dev, DIR_OUT);
if (n)
return n;
@@ -1182,46 +1099,25 @@ static int vmk80xx_pwm_winsn(struct comedi_device *cdev,
return n;
}
-static int vmk80xx_attach(struct comedi_device *cdev,
- struct comedi_devconfig *it)
+static int vmk80xx_attach_common(struct comedi_device *cdev,
+ struct vmk80xx_usb *dev)
{
- int i;
- struct vmk80xx_usb *dev;
int n_subd;
struct comedi_subdevice *s;
- int minor;
-
- dbgvm("vmk80xx: %s\n", __func__);
-
- mutex_lock(&glb_mutex);
-
- for (i = 0; i < VMK80XX_MAX_BOARDS; i++)
- if (vmb[i].probed && !vmb[i].attached)
- break;
-
- if (i == VMK80XX_MAX_BOARDS) {
- mutex_unlock(&glb_mutex);
- return -ENODEV;
- }
-
- dev = &vmb[i];
+ int ret;
down(&dev->limit_sem);
-
cdev->board_name = dev->board.name;
cdev->private = dev;
-
if (dev->board.model == VMK8055_MODEL)
n_subd = 5;
else
n_subd = 6;
-
- if (alloc_subdevices(cdev, n_subd) < 0) {
+ ret = comedi_alloc_subdevices(cdev, n_subd);
+ if (ret) {
up(&dev->limit_sem);
- mutex_unlock(&glb_mutex);
- return -ENOMEM;
+ return ret;
}
-
/* Analog input subdevice */
s = cdev->subdevices + VMK80XX_SUBD_AI;
s->type = COMEDI_SUBD_AI;
@@ -1230,7 +1126,6 @@ static int vmk80xx_attach(struct comedi_device *cdev,
s->maxdata = (1 << dev->board.ai_bits) - 1;
s->range_table = dev->board.range;
s->insn_read = vmk80xx_ai_rinsn;
-
/* Analog output subdevice */
s = cdev->subdevices + VMK80XX_SUBD_AO;
s->type = COMEDI_SUBD_AO;
@@ -1239,12 +1134,10 @@ static int vmk80xx_attach(struct comedi_device *cdev,
s->maxdata = (1 << dev->board.ao_bits) - 1;
s->range_table = dev->board.range;
s->insn_write = vmk80xx_ao_winsn;
-
if (dev->board.model == VMK8061_MODEL) {
s->subdev_flags |= SDF_READABLE;
s->insn_read = vmk80xx_ao_rinsn;
}
-
/* Digital input subdevice */
s = cdev->subdevices + VMK80XX_SUBD_DI;
s->type = COMEDI_SUBD_DI;
@@ -1253,7 +1146,6 @@ static int vmk80xx_attach(struct comedi_device *cdev,
s->maxdata = 1;
s->insn_read = vmk80xx_di_rinsn;
s->insn_bits = vmk80xx_di_bits;
-
/* Digital output subdevice */
s = cdev->subdevices + VMK80XX_SUBD_DO;
s->type = COMEDI_SUBD_DO;
@@ -1262,12 +1154,10 @@ static int vmk80xx_attach(struct comedi_device *cdev,
s->maxdata = 1;
s->insn_write = vmk80xx_do_winsn;
s->insn_bits = vmk80xx_do_bits;
-
if (dev->board.model == VMK8061_MODEL) {
s->subdev_flags |= SDF_READABLE;
s->insn_read = vmk80xx_do_rinsn;
}
-
/* Counter subdevice */
s = cdev->subdevices + VMK80XX_SUBD_CNT;
s->type = COMEDI_SUBD_COUNTER;
@@ -1275,13 +1165,11 @@ static int vmk80xx_attach(struct comedi_device *cdev,
s->n_chan = dev->board.cnt_chans;
s->insn_read = vmk80xx_cnt_rinsn;
s->insn_config = vmk80xx_cnt_cinsn;
-
if (dev->board.model == VMK8055_MODEL) {
s->subdev_flags |= SDF_WRITEABLE;
s->maxdata = (1 << dev->board.cnt_bits) - 1;
s->insn_write = vmk80xx_cnt_winsn;
}
-
/* PWM subdevice */
if (dev->board.model == VMK8061_MODEL) {
s = cdev->subdevices + VMK80XX_SUBD_PWM;
@@ -1292,53 +1180,75 @@ static int vmk80xx_attach(struct comedi_device *cdev,
s->insn_read = vmk80xx_pwm_rinsn;
s->insn_write = vmk80xx_pwm_winsn;
}
-
dev->attached = 1;
-
- minor = cdev->minor;
-
- printk(KERN_INFO
- "comedi%d: vmk80xx: board #%d [%s] attached to comedi\n",
- minor, dev->count, dev->board.name);
-
+ dev_info(cdev->class_dev, "vmk80xx: board #%d [%s] attached\n",
+ dev->count, dev->board.name);
up(&dev->limit_sem);
- mutex_unlock(&glb_mutex);
-
return 0;
}
-static int vmk80xx_detach(struct comedi_device *cdev)
+/* called for COMEDI_DEVCONFIG ioctl for board_name "vmk80xx" */
+static int vmk80xx_attach(struct comedi_device *cdev,
+ struct comedi_devconfig *it)
{
- struct vmk80xx_usb *dev;
- int minor;
-
- dbgvm("vmk80xx: %s\n", __func__);
-
- if (!cdev)
- return -EFAULT;
-
- dev = cdev->private;
- if (!dev)
- return -EFAULT;
-
- down(&dev->limit_sem);
+ int i;
+ int ret;
- cdev->private = NULL;
- dev->attached = 0;
+ mutex_lock(&glb_mutex);
+ for (i = 0; i < VMK80XX_MAX_BOARDS; i++)
+ if (vmb[i].probed && !vmb[i].attached)
+ break;
+ if (i == VMK80XX_MAX_BOARDS)
+ ret = -ENODEV;
+ else
+ ret = vmk80xx_attach_common(cdev, &vmb[i]);
+ mutex_unlock(&glb_mutex);
+ return ret;
+}
- minor = cdev->minor;
+/* called via comedi_usb_auto_config() */
+static int vmk80xx_attach_usb(struct comedi_device *cdev,
+ struct usb_interface *intf)
+{
+ int i;
+ int ret;
- printk(KERN_INFO
- "comedi%d: vmk80xx: board #%d [%s] detached from comedi\n",
- minor, dev->count, dev->board.name);
+ mutex_lock(&glb_mutex);
+ for (i = 0; i < VMK80XX_MAX_BOARDS; i++)
+ if (vmb[i].probed && vmb[i].intf == intf)
+ break;
+ if (i == VMK80XX_MAX_BOARDS)
+ ret = -ENODEV;
+ else if (vmb[i].attached)
+ ret = -EBUSY;
+ else
+ ret = vmk80xx_attach_common(cdev, &vmb[i]);
+ mutex_unlock(&glb_mutex);
+ return ret;
+}
- up(&dev->limit_sem);
+static void vmk80xx_detach(struct comedi_device *dev)
+{
+ struct vmk80xx_usb *usb = dev->private;
- return 0;
+ if (usb) {
+ down(&usb->limit_sem);
+ dev->private = NULL;
+ usb->attached = 0;
+ up(&usb->limit_sem);
+ }
}
-static int vmk80xx_probe(struct usb_interface *intf,
- const struct usb_device_id *id)
+static struct comedi_driver vmk80xx_driver = {
+ .module = THIS_MODULE,
+ .driver_name = "vmk80xx",
+ .attach = vmk80xx_attach,
+ .detach = vmk80xx_detach,
+ .attach_usb = vmk80xx_attach_usb,
+};
+
+static int vmk80xx_usb_probe(struct usb_interface *intf,
+ const struct usb_device_id *id)
{
int i;
struct vmk80xx_usb *dev;
@@ -1346,8 +1256,6 @@ static int vmk80xx_probe(struct usb_interface *intf,
struct usb_endpoint_descriptor *ep_desc;
size_t size;
- dbgvm("vmk80xx: %s\n", __func__);
-
mutex_lock(&glb_mutex);
for (i = 0; i < VMK80XX_MAX_BOARDS; i++)
@@ -1482,7 +1390,7 @@ static int vmk80xx_probe(struct usb_interface *intf,
mutex_unlock(&glb_mutex);
- comedi_usb_auto_config(dev->udev, BOARDNAME);
+ comedi_usb_auto_config(intf, &vmk80xx_driver);
return 0;
error:
@@ -1491,16 +1399,14 @@ error:
return -ENODEV;
}
-static void vmk80xx_disconnect(struct usb_interface *intf)
+static void vmk80xx_usb_disconnect(struct usb_interface *intf)
{
struct vmk80xx_usb *dev = usb_get_intfdata(intf);
- dbgvm("vmk80xx: %s\n", __func__);
-
if (!dev)
return;
- comedi_usb_auto_unconfig(dev->udev);
+ comedi_usb_auto_unconfig(intf);
mutex_lock(&glb_mutex);
down(&dev->limit_sem);
@@ -1521,41 +1427,35 @@ static void vmk80xx_disconnect(struct usb_interface *intf)
mutex_unlock(&glb_mutex);
}
-/* TODO: Add support for suspend, resume, pre_reset,
- * post_reset and flush */
-static struct usb_driver vmk80xx_driver = {
- .name = "vmk80xx",
- .probe = vmk80xx_probe,
- .disconnect = vmk80xx_disconnect,
- .id_table = vmk80xx_id_table
+static const struct usb_device_id vmk80xx_usb_id_table[] = {
+ { USB_DEVICE(0x10cf, 0x5500), .driver_info = DEVICE_VMK8055 },
+ { USB_DEVICE(0x10cf, 0x5501), .driver_info = DEVICE_VMK8055 },
+ { USB_DEVICE(0x10cf, 0x5502), .driver_info = DEVICE_VMK8055 },
+ { USB_DEVICE(0x10cf, 0x5503), .driver_info = DEVICE_VMK8055 },
+ { USB_DEVICE(0x10cf, 0x8061), .driver_info = DEVICE_VMK8061 },
+ { USB_DEVICE(0x10cf, 0x8062), .driver_info = DEVICE_VMK8061 },
+ { USB_DEVICE(0x10cf, 0x8063), .driver_info = DEVICE_VMK8061 },
+ { USB_DEVICE(0x10cf, 0x8064), .driver_info = DEVICE_VMK8061 },
+ { USB_DEVICE(0x10cf, 0x8065), .driver_info = DEVICE_VMK8061 },
+ { USB_DEVICE(0x10cf, 0x8066), .driver_info = DEVICE_VMK8061 },
+ { USB_DEVICE(0x10cf, 0x8067), .driver_info = DEVICE_VMK8061 },
+ { USB_DEVICE(0x10cf, 0x8068), .driver_info = DEVICE_VMK8061 },
+ { }
};
+MODULE_DEVICE_TABLE(usb, vmk80xx_usb_id_table);
-static struct comedi_driver driver_vmk80xx = {
- .module = THIS_MODULE,
- .driver_name = "vmk80xx",
- .attach = vmk80xx_attach,
- .detach = vmk80xx_detach
+/* TODO: Add support for suspend, resume, pre_reset,
+ * post_reset and flush */
+static struct usb_driver vmk80xx_usb_driver = {
+ .name = "vmk80xx",
+ .probe = vmk80xx_usb_probe,
+ .disconnect = vmk80xx_usb_disconnect,
+ .id_table = vmk80xx_usb_id_table,
};
+module_comedi_usb_driver(vmk80xx_driver, vmk80xx_usb_driver);
-static int __init vmk80xx_init(void)
-{
- int retval;
-
- printk(KERN_INFO "vmk80xx: version 0.8.01 "
- "Manuel Gebele <forensixs@gmx.de>\n");
-
- retval = comedi_driver_register(&driver_vmk80xx);
- if (retval < 0)
- return retval;
-
- return usb_register(&vmk80xx_driver);
-}
-
-static void __exit vmk80xx_exit(void)
-{
- comedi_driver_unregister(&driver_vmk80xx);
- usb_deregister(&vmk80xx_driver);
-}
-
-module_init(vmk80xx_init);
-module_exit(vmk80xx_exit);
+MODULE_AUTHOR("Manuel Gebele <forensixs@gmx.de>");
+MODULE_DESCRIPTION("Velleman USB Board Low-Level Driver");
+MODULE_SUPPORTED_DEVICE("K8055/K8061 aka VM110/VM140");
+MODULE_VERSION("0.8.01");
+MODULE_LICENSE("GPL");
diff --git a/drivers/staging/comedi/proc.c b/drivers/staging/comedi/proc.c
index 2aa487b60187..bb7e70e3e94a 100644
--- a/drivers/staging/comedi/proc.c
+++ b/drivers/staging/comedi/proc.c
@@ -30,7 +30,7 @@
#define __NO_VERSION__
#include "comedidev.h"
-#include "comedi_fops.h"
+#include "comedi_internal.h"
#include <linux/proc_fs.h>
#include <linux/string.h>
diff --git a/drivers/staging/comedi/range.c b/drivers/staging/comedi/range.c
index 148ec6fd6fdd..41f95237789d 100644
--- a/drivers/staging/comedi/range.c
+++ b/drivers/staging/comedi/range.c
@@ -23,7 +23,7 @@
#include <linux/uaccess.h>
#include "comedidev.h"
-#include "internal.h"
+#include "comedi_internal.h"
const struct comedi_lrange range_bipolar10 = { 1, {BIP_RANGE(10)} };
EXPORT_SYMBOL(range_bipolar10);
diff --git a/drivers/staging/cptm1217/clearpad_tm1217.c b/drivers/staging/cptm1217/clearpad_tm1217.c
index 5456f82c3066..0d924d3a2ab1 100644
--- a/drivers/staging/cptm1217/clearpad_tm1217.c
+++ b/drivers/staging/cptm1217/clearpad_tm1217.c
@@ -396,8 +396,8 @@ static int cp_tm1217_setup_gpio_irq(struct cp_tm1217_device *ts)
retval = gpio_to_irq(ts->gpio);
if (retval < 0) {
- dev_err(ts->dev, "cp_tm1217: GPIO to IRQ failedi,"
- " error %d\n", retval);
+ dev_err(ts->dev,
+ "cp_tm1217: GPIO to IRQ failed, error %d\n", retval);
gpio_free(ts->gpio);
}
dev_dbg(ts->dev,
diff --git a/drivers/staging/cptm1217/cp_tm1217.h b/drivers/staging/cptm1217/cp_tm1217.h
index a0ce31db53f8..30bad357a055 100644
--- a/drivers/staging/cptm1217/cp_tm1217.h
+++ b/drivers/staging/cptm1217/cp_tm1217.h
@@ -1,8 +1,7 @@
#ifndef __LINUX_I2C_CP_TM1217_H
#define __LINUX_I2C_CP_TM1217_H
-struct cp_tm1217_platform_data
-{
+struct cp_tm1217_platform_data {
int gpio; /* If not set uses the IRQ resource 0 */
};
diff --git a/drivers/staging/csr/Kconfig b/drivers/staging/csr/Kconfig
new file mode 100644
index 000000000000..cee8d48d2af9
--- /dev/null
+++ b/drivers/staging/csr/Kconfig
@@ -0,0 +1,9 @@
+config CSR_WIFI
+ tristate "CSR wireless driver"
+ depends on MMC && CFG80211_WEXT
+ select WIRELESS_EXT
+ select WEXT_PRIV
+ help
+ Driver for the CSR wireless SDIO device.
+
+ If unsure, select N.
diff --git a/drivers/staging/csr/LICENSE.txt b/drivers/staging/csr/LICENSE.txt
new file mode 100644
index 000000000000..364853e5fedc
--- /dev/null
+++ b/drivers/staging/csr/LICENSE.txt
@@ -0,0 +1,39 @@
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+Except as contained in this notice, the names of above-listed
+copyright holders and the names of any contributors shall not be used
+in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
+CONTRIBUTORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT
+OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
+
+Alternatively, this software may be distributed under the terms of the
+GNU General Public License ("GPL") version 2 as published
+by the Free Software Foundation.
+
+As a special exception, if other files instantiate templates or use
+macros or inline functions from this file, or you compile this file
+and link it with other works to produce a work based on this file,
+this file does not by itself cause the resulting work to be covered by
+the GNU General Public License. However the source code for this file
+must still be made available in accordance with section (3) of the GNU
+General Public License.
+
+This exception does not invalidate any other reasons why a work based
+on this file might be covered by the GNU General Public License.
diff --git a/drivers/staging/csr/Makefile b/drivers/staging/csr/Makefile
new file mode 100644
index 000000000000..afda44b0a925
--- /dev/null
+++ b/drivers/staging/csr/Makefile
@@ -0,0 +1,75 @@
+ccflags-y := -DCSR_SME_USERSPACE -DCSR_SUPPORT_SME -DREMOTE_SYS_SAP -DCSR_WIFI_SECURITY_WAPI_ENABLE -DENABLE_SHUTDOWN -DUNIFI_DEBUG
+ccflags-y += -DSDIO_EXPORTS_STRUCT_DEVICE -DCSR_WIFI_SUPPORT_MMC_DRIVER -DCSR_WIFI_SINGLE_FUNCTION -DCSR_WIFI_SPLIT_PATCH
+ccflags-y += -DCSR_SUPPORT_WEXT -DREMOTE_SYS_SAP -DREMOTE_MGT_SAP -DCSR_WIFI_SECURITY_WAPI_ENABLE -DCSR_WIFI_SECURITY_WAPI_QOSCTRL_MIC_WORKAROUND -DENABLE_SHUTDOWN -DCSR_WIFI_NME_ENABLE -DCSR_WIFI_AP_ENABLE -DCSR_SUPPORT_WEXT_AP -DCSR_WIFI_REQUEUE_PACKET_TO_HAL
+
+obj-$(CONFIG_CSR_WIFI) += csr_wifi.o
+obj-$(CONFIG_CSR_WIFI) += csr_helper.o
+
+csr_wifi-y := bh.o \
+ data_tx.o \
+ drv.o \
+ firmware.o \
+ inet.o \
+ init_hw.o \
+ io.o \
+ monitor.o \
+ netdev.o \
+ os.o \
+ putest.o \
+ sdio_events.o \
+ sdio_mmc.o \
+ sdio_stubs.o \
+ sme_blocking.o \
+ ul_int.o \
+ unifi_dbg.o \
+ unifi_event.o \
+ unifi_pdu_processing.o \
+ unifi_sme.o \
+ csr_formatted_io.o \
+ csr_wifi_hip_card_sdio.o \
+ csr_wifi_hip_card_sdio_intr.o \
+ csr_wifi_hip_card_sdio_mem.o \
+ csr_wifi_hip_chiphelper.o \
+ csr_wifi_hip_download.o \
+ csr_wifi_hip_dump.o \
+ csr_wifi_hip_packing.o \
+ csr_wifi_hip_send.o \
+ csr_wifi_hip_signals.o \
+ csr_wifi_hip_ta_sampling.o \
+ csr_wifi_hip_udi.o \
+ csr_wifi_hip_unifi_signal_names.o \
+ csr_wifi_hip_xbv.o \
+ csr_wifi_nme_ap_converter_init.o \
+ csr_wifi_nme_ap_free_downstream_contents.o \
+ csr_wifi_nme_ap_free_upstream_contents.o \
+ csr_wifi_nme_ap_serialize.o \
+ csr_wifi_nme_ap_sef.o \
+ csr_wifi_router_ctrl_sef.o \
+ csr_wifi_router_sef.o \
+ csr_wifi_router_transport.o \
+ csr_wifi_sme_sef.o \
+ csr_wifi_sme_converter_init.o \
+ csr_wifi_sme_free_downstream_contents.o \
+ csr_wifi_sme_free_upstream_contents.o \
+ csr_wifi_sme_serialize.o \
+ csr_wifi_router_ctrl_converter_init.o \
+ csr_wifi_router_ctrl_free_downstream_contents.o \
+ csr_wifi_router_ctrl_free_upstream_contents.o \
+ csr_wifi_router_ctrl_serialize.o \
+ csr_wifi_router_converter_init.o \
+ csr_wifi_router_free_downstream_contents.o \
+ csr_wifi_router_free_upstream_contents.o \
+ csr_wifi_router_serialize.o \
+ sme_mgt.o \
+ sme_sys.o \
+ sme_userspace.o \
+ sme_wext.o \
+ wext_events.o
+
+csr_helper-y := csr_time.o \
+ csr_util.o \
+ csr_framework_ext.o \
+ csr_wifi_serialize_primitive_types.o \
+ csr_serialize_primitive_types.o \
+ csr_msgconv.o \
+ csr_panic.o
diff --git a/drivers/staging/csr/bh.c b/drivers/staging/csr/bh.c
new file mode 100644
index 000000000000..b089c28d5610
--- /dev/null
+++ b/drivers/staging/csr/bh.c
@@ -0,0 +1,391 @@
+/*
+ * ---------------------------------------------------------------------------
+ * FILE: bh.c
+ *
+ * PURPOSE:
+ * Provides an implementation for the driver bottom-half.
+ * It is part of the porting exercise in Linux.
+ *
+ * Copyright (C) 2005-2009 by Cambridge Silicon Radio Ltd.
+ *
+ * Refer to LICENSE.txt included with this source code for details on
+ * the license terms.
+ *
+ * ---------------------------------------------------------------------------
+ */
+#include "csr_wifi_hip_unifi.h"
+#include "unifi_priv.h"
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * uf_start_thread
+ *
+ * Helper function to start a new thread.
+ *
+ * Arguments:
+ * priv Pointer to OS driver structure for the device.
+ * thread Pointer to the thread object
+ * func The thread function
+ *
+ * Returns:
+ * 0 on success or else a Linux error code.
+ * ---------------------------------------------------------------------------
+ */
+int
+uf_start_thread(unifi_priv_t *priv, struct uf_thread *thread, int (*func)(void *))
+{
+ if (thread->thread_task != NULL) {
+ unifi_error(priv, "%s thread already started\n", thread->name);
+ return 0;
+ }
+
+ /* Start the kernel thread that handles all h/w accesses. */
+ thread->thread_task = kthread_run(func, priv, "%s", thread->name);
+ if (IS_ERR(thread->thread_task)) {
+ return PTR_ERR(thread->thread_task);
+ }
+
+ /* Module parameter overides the thread priority */
+ if (bh_priority != -1) {
+ if (bh_priority >= 0 && bh_priority <= MAX_RT_PRIO) {
+ struct sched_param param;
+ priv->bh_thread.prio = bh_priority;
+ unifi_trace(priv, UDBG1, "%s thread (RT) priority = %d\n",
+ thread->name, bh_priority);
+ param.sched_priority = bh_priority;
+ sched_setscheduler(thread->thread_task, SCHED_FIFO, &param);
+ } else if (bh_priority > MAX_RT_PRIO && bh_priority <= MAX_PRIO) {
+ priv->bh_thread.prio = bh_priority;
+ unifi_trace(priv, UDBG1, "%s thread priority = %d\n",
+ thread->name, PRIO_TO_NICE(bh_priority));
+ set_user_nice(thread->thread_task, PRIO_TO_NICE(bh_priority));
+ } else {
+ priv->bh_thread.prio = DEFAULT_PRIO;
+ unifi_warning(priv, "%s thread unsupported (%d) priority\n",
+ thread->name, bh_priority);
+ }
+ } else {
+ priv->bh_thread.prio = DEFAULT_PRIO;
+ }
+ unifi_trace(priv, UDBG2, "Started %s thread\n", thread->name);
+
+ return 0;
+} /* uf_start_thread() */
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * uf_stop_thread
+ *
+ * Helper function to stop a thread.
+ *
+ * Arguments:
+ * priv Pointer to OS driver structure for the device.
+ * thread Pointer to the thread object
+ *
+ * Returns:
+ *
+ * ---------------------------------------------------------------------------
+ */
+ void
+uf_stop_thread(unifi_priv_t *priv, struct uf_thread *thread)
+{
+ if (!thread->thread_task) {
+ unifi_notice(priv, "%s thread is already stopped\n", thread->name);
+ return;
+ }
+
+ unifi_trace(priv, UDBG2, "Stopping %s thread\n", thread->name);
+
+ kthread_stop(thread->thread_task);
+ thread->thread_task = NULL;
+
+} /* uf_stop_thread() */
+
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * uf_wait_for_thread_to_stop
+ *
+ * Helper function to wait until a thread is stopped.
+ *
+ * Arguments:
+ * priv Pointer to OS driver structure for the device.
+ *
+ * Returns:
+ *
+ * ---------------------------------------------------------------------------
+ */
+ void
+uf_wait_for_thread_to_stop(unifi_priv_t *priv, struct uf_thread *thread)
+{
+ /*
+ * kthread_stop() cannot handle the thread exiting while
+ * kthread_should_stop() is false, so sleep until kthread_stop()
+ * wakes us up.
+ */
+ unifi_trace(priv, UDBG2, "%s waiting for the stop signal.\n", thread->name);
+ set_current_state(TASK_INTERRUPTIBLE);
+ if (!kthread_should_stop()) {
+ unifi_trace(priv, UDBG2, "%s schedule....\n", thread->name);
+ schedule();
+ }
+
+ thread->thread_task = NULL;
+ unifi_trace(priv, UDBG2, "%s exiting....\n", thread->name);
+} /* uf_wait_for_thread_to_stop() */
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * handle_bh_error
+ *
+ * This function reports an error returned from the HIP core bottom-half.
+ * Normally, implemented during the porting exercise, passing the error
+ * to the SME using unifi_sys_wifi_off_ind().
+ * The SME will try to reset the device and go through
+ * the initialisation of the UniFi.
+ *
+ * Arguments:
+ * priv Pointer to OS driver structure for the device.
+ *
+ * Returns:
+ * None.
+ * ---------------------------------------------------------------------------
+ */
+ static void
+handle_bh_error(unifi_priv_t *priv)
+{
+ u8 conf_param = CONFIG_IND_ERROR;
+ u8 interfaceTag = 0; /* used as a loop counter */
+
+
+ /* Block unifi_run_bh() until the error has been handled. */
+ priv->bh_thread.block_thread = 1;
+
+ /* Consider UniFi to be uninitialised */
+ priv->init_progress = UNIFI_INIT_NONE;
+
+ /* Stop the network traffic */
+ for( interfaceTag =0; interfaceTag <CSR_WIFI_NUM_INTERFACES;interfaceTag ++) {
+ netInterface_priv_t *interfacePriv = priv->interfacePriv[interfaceTag];
+ if (interfacePriv->netdev_registered == 1) {
+ netif_carrier_off(priv->netdev[interfaceTag]);
+ }
+ }
+
+#ifdef CSR_NATIVE_LINUX
+ /* Force any client waiting on an mlme_wait_for_reply() to abort. */
+ uf_abort_mlme(priv);
+
+ /* Cancel any pending workqueue tasks */
+ flush_workqueue(priv->unifi_workqueue);
+
+#endif /* CSR_NATIVE_LINUX */
+
+ unifi_error(priv, "handle_bh_error: fatal error is reported to the SME.\n");
+ /* Notify the clients (SME or unifi_manager) for the error. */
+ ul_log_config_ind(priv, &conf_param, sizeof(u8));
+
+} /* handle_bh_error() */
+
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * bh_thread_function
+ *
+ * All hardware access happens in this thread.
+ * This means there is no need for locks on the hardware and we don't need
+ * to worry about reentrancy with the SDIO library.
+ * Provides and example implementation on how to call unifi_bh(), which
+ * is part of the HIP core API.
+ *
+ * It processes the events generated by unifi_run_bh() to serialise calls
+ * to unifi_bh(). It also demonstrates how the timeout parameter passed in
+ * and returned from unifi_bh() needs to be handled.
+ *
+ * Arguments:
+ * arg Pointer to OS driver structure for the device.
+ *
+ * Returns:
+ * None.
+ *
+ * Notes:
+ * When the bottom half of the driver needs to process signals, events,
+ * or simply the host status (i.e sleep mode), it invokes unifi_run_bh().
+ * Since we need all SDIO transaction to be in a single thread, the
+ * unifi_run_bh() will wake up this thread to process it.
+ *
+ * ---------------------------------------------------------------------------
+ */
+static int
+bh_thread_function(void *arg)
+{
+ unifi_priv_t *priv = (unifi_priv_t*)arg;
+ CsrResult csrResult;
+ long ret;
+ u32 timeout, t;
+ struct uf_thread *this_thread;
+
+ unifi_trace(priv, UDBG2, "bh_thread_function starting\n");
+
+ this_thread = &priv->bh_thread;
+
+ t = timeout = 0;
+ while (!kthread_should_stop()) {
+ /* wait until an error occurs, or we need to process something. */
+ unifi_trace(priv, UDBG3, "bh_thread goes to sleep.\n");
+
+ if (timeout > 0) {
+ /* Convert t in ms to jiffies */
+ t = msecs_to_jiffies(timeout);
+ ret = wait_event_interruptible_timeout(this_thread->wakeup_q,
+ (this_thread->wakeup_flag && !this_thread->block_thread) ||
+ kthread_should_stop(),
+ t);
+ timeout = (ret > 0) ? jiffies_to_msecs(ret) : 0;
+ } else {
+ ret = wait_event_interruptible(this_thread->wakeup_q,
+ (this_thread->wakeup_flag && !this_thread->block_thread) ||
+ kthread_should_stop());
+ }
+
+ if (kthread_should_stop()) {
+ unifi_trace(priv, UDBG2, "bh_thread: signalled to exit\n");
+ break;
+ }
+
+ if (ret < 0) {
+ unifi_notice(priv,
+ "bh_thread: wait_event returned %d, thread will exit\n",
+ ret);
+ uf_wait_for_thread_to_stop(priv, this_thread);
+ break;
+ }
+
+ this_thread->wakeup_flag = 0;
+
+ unifi_trace(priv, UDBG3, "bh_thread calls unifi_bh().\n");
+
+ CsrSdioClaim(priv->sdio);
+ csrResult = unifi_bh(priv->card, &timeout);
+ if(csrResult != CSR_RESULT_SUCCESS) {
+ if (csrResult == CSR_WIFI_HIP_RESULT_NO_DEVICE) {
+ CsrSdioRelease(priv->sdio);
+ uf_wait_for_thread_to_stop(priv, this_thread);
+ break;
+ }
+ /* Errors must be delivered to the error task */
+ handle_bh_error(priv);
+ }
+ CsrSdioRelease(priv->sdio);
+ }
+
+ /*
+ * I would normally try to call csr_sdio_remove_irq() here to make sure
+ * that we do not get any interrupts while this thread is not running.
+ * However, the MMC/SDIO driver tries to kill its' interrupt thread.
+ * The kernel threads implementation does not allow to kill threads
+ * from a signalled to stop thread.
+ * So, instead call csr_sdio_linux_remove_irq() always after calling
+ * uf_stop_thread() to kill this thread.
+ */
+
+ unifi_trace(priv, UDBG2, "bh_thread exiting....\n");
+ return 0;
+} /* bh_thread_function() */
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * uf_init_bh
+ *
+ * Helper function to start the bottom half of the driver.
+ * All we need to do here is start the I/O bh thread.
+ *
+ * Arguments:
+ * priv Pointer to OS driver structure for the device.
+ *
+ * Returns:
+ * 0 on success or else a Linux error code.
+ * ---------------------------------------------------------------------------
+ */
+ int
+uf_init_bh(unifi_priv_t *priv)
+{
+ int r;
+
+ /* Enable mlme interface. */
+ priv->io_aborted = 0;
+
+
+ /* Start the BH thread */
+ r = uf_start_thread(priv, &priv->bh_thread, bh_thread_function);
+ if (r) {
+ unifi_error(priv,
+ "uf_init_bh: failed to start the BH thread.\n");
+ return r;
+ }
+
+ /* Allow interrupts */
+ r = csr_sdio_linux_install_irq(priv->sdio);
+ if (r) {
+ unifi_error(priv,
+ "uf_init_bh: failed to install the IRQ.\n");
+
+ uf_stop_thread(priv, &priv->bh_thread);
+ }
+
+ return r;
+} /* uf_init_bh() */
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * unifi_run_bh
+ *
+ * Part of the HIP core lib API, implemented in the porting exercise.
+ * The bottom half of the driver calls this function when
+ * it wants to process anything that requires access to unifi.
+ * We need to call unifi_bh() which in this implementation is done
+ * by waking up the I/O thread.
+ *
+ * Arguments:
+ * ospriv Pointer to OS driver structure for the device.
+ *
+ * Returns:
+ * 0 on success or else a Linux error code.
+ *
+ * Notes:
+ * ---------------------------------------------------------------------------
+ */
+CsrResult unifi_run_bh(void *ospriv)
+{
+ unifi_priv_t *priv = ospriv;
+
+ /*
+ * If an error has occured, we discard silently all messages from the bh
+ * until the error has been processed and the unifi has been reinitialised.
+ */
+ if (priv->bh_thread.block_thread == 1) {
+ unifi_trace(priv, UDBG3, "unifi_run_bh: discard message.\n");
+ /*
+ * Do not try to acknowledge a pending interrupt here.
+ * This function is called by unifi_send_signal() which in turn can be
+ * running in an atomic or 'disabled irq' level if a signal is sent
+ * from a workqueue task (i.e multicass addresses set).
+ * We can not hold the SDIO lock because it might sleep.
+ */
+ return CSR_RESULT_FAILURE;
+ }
+
+ priv->bh_thread.wakeup_flag = 1;
+ /* wake up I/O thread */
+ wake_up_interruptible(&priv->bh_thread.wakeup_q);
+
+ return CSR_RESULT_SUCCESS;
+} /* unifi_run_bh() */
+
diff --git a/drivers/staging/csr/csr_formatted_io.c b/drivers/staging/csr/csr_formatted_io.c
new file mode 100644
index 000000000000..7213cc8fb577
--- /dev/null
+++ b/drivers/staging/csr/csr_formatted_io.c
@@ -0,0 +1,27 @@
+/*****************************************************************************
+
+ (c) Cambridge Silicon Radio Limited 2010
+ All rights reserved and confidential information of CSR
+
+ Refer to LICENSE.txt included with this source for details
+ on the license terms.
+
+*****************************************************************************/
+#include <linux/kernel.h>
+#include "csr_formatted_io.h"
+
+s32 CsrSnprintf(char *dest, size_t n, const char *fmt, ...)
+{
+ s32 r;
+ va_list args;
+ va_start(args, fmt);
+ r = vsnprintf(dest, n, fmt, args);
+ va_end(args);
+
+ if (dest && (n > 0))
+ {
+ dest[n - 1] = '\0';
+ }
+
+ return r;
+}
diff --git a/drivers/staging/csr/csr_formatted_io.h b/drivers/staging/csr/csr_formatted_io.h
new file mode 100644
index 000000000000..2e238cb98d51
--- /dev/null
+++ b/drivers/staging/csr/csr_formatted_io.h
@@ -0,0 +1,25 @@
+#ifndef CSR_FORMATTED_IO_H__
+#define CSR_FORMATTED_IO_H__
+/*****************************************************************************
+
+ (c) Cambridge Silicon Radio Limited 2010
+ All rights reserved and confidential information of CSR
+
+ Refer to LICENSE.txt included with this source for details
+ on the license terms.
+
+*****************************************************************************/
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <linux/types.h>
+
+s32 CsrSnprintf(char *dest, size_t n, const char *fmt, ...);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/drivers/staging/csr/csr_framework_ext.c b/drivers/staging/csr/csr_framework_ext.c
new file mode 100644
index 000000000000..12e7ddf3220a
--- /dev/null
+++ b/drivers/staging/csr/csr_framework_ext.c
@@ -0,0 +1,148 @@
+/*****************************************************************************
+
+ (c) Cambridge Silicon Radio Limited 2010
+ All rights reserved and confidential information of CSR
+
+ Refer to LICENSE.txt included with this source for details
+ on the license terms.
+
+*****************************************************************************/
+
+#include <linux/kernel.h>
+#include <linux/version.h>
+#include <linux/kthread.h>
+#include <linux/module.h>
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 34)
+#include <linux/slab.h>
+#endif
+
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 19)
+#include <linux/freezer.h>
+#endif
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 27)
+#include <asm/semaphore.h>
+#else
+#include <linux/semaphore.h>
+#endif
+
+#include <linux/bitops.h>
+
+#include "csr_framework_ext.h"
+#include "csr_panic.h"
+
+/*----------------------------------------------------------------------------*
+ * NAME
+ * CsrMutexCreate
+ *
+ * DESCRIPTION
+ * Create a mutex and return a handle to the created mutex.
+ *
+ * RETURNS
+ * Possible values:
+ * CSR_RESULT_SUCCESS in case of success
+ * CSR_FE_RESULT_NO_MORE_MUTEXES in case of out of mutex resources
+ * CSR_FE_RESULT_INVALID_POINTER in case the mutexHandle pointer is invalid
+ *
+ *----------------------------------------------------------------------------*/
+CsrResult CsrMutexCreate(CsrMutexHandle *mutexHandle)
+{
+ if (mutexHandle == NULL)
+ {
+ return CSR_FE_RESULT_INVALID_POINTER;
+ }
+
+ sema_init(mutexHandle, 1);
+
+ return CSR_RESULT_SUCCESS;
+}
+
+/*----------------------------------------------------------------------------*
+ * NAME
+ * CsrMutexDestroy
+ *
+ * DESCRIPTION
+ * Destroy the previously created mutex.
+ *
+ * RETURNS
+ * void
+ *
+ *----------------------------------------------------------------------------*/
+void CsrMutexDestroy(CsrMutexHandle *mutexHandle)
+{
+}
+
+/*----------------------------------------------------------------------------*
+ * NAME
+ * CsrMutexLock
+ *
+ * DESCRIPTION
+ * Lock the mutex refered to by the provided handle.
+ *
+ * RETURNS
+ * Possible values:
+ * CSR_RESULT_SUCCESS in case of success
+ * CSR_FE_RESULT_INVALID_HANDLE in case the mutexHandle is invalid
+ *
+ *----------------------------------------------------------------------------*/
+CsrResult CsrMutexLock(CsrMutexHandle *mutexHandle)
+{
+ if (mutexHandle == NULL)
+ {
+ return CSR_FE_RESULT_INVALID_POINTER;
+ }
+
+ if (down_interruptible(mutexHandle))
+ {
+ CsrPanic(CSR_TECH_FW, CSR_PANIC_FW_UNEXPECTED_VALUE, "CsrMutexLock Failed");
+ return CSR_FE_RESULT_INVALID_POINTER;
+ }
+
+ return CSR_RESULT_SUCCESS;
+}
+
+/*----------------------------------------------------------------------------*
+ * NAME
+ * CsrMutexUnlock
+ *
+ * DESCRIPTION
+ * Unlock the mutex refered to by the provided handle.
+ *
+ * RETURNS
+ * Possible values:
+ * CSR_RESULT_SUCCESS in case of success
+ * CSR_FE_RESULT_INVALID_HANDLE in case the mutexHandle is invalid
+ *
+ *----------------------------------------------------------------------------*/
+CsrResult CsrMutexUnlock(CsrMutexHandle *mutexHandle)
+{
+ if (mutexHandle == NULL)
+ {
+ return CSR_FE_RESULT_INVALID_POINTER;
+ }
+
+ up(mutexHandle);
+
+ return CSR_RESULT_SUCCESS;
+}
+
+/*----------------------------------------------------------------------------*
+ * NAME
+ * CsrThreadSleep
+ *
+ * DESCRIPTION
+ * Sleep for a given period.
+ *
+ * RETURNS
+ * void
+ *
+ *----------------------------------------------------------------------------*/
+void CsrThreadSleep(u16 sleepTimeInMs)
+{
+ unsigned long t;
+
+ /* Convert t in ms to jiffies and round up */
+ t = ((sleepTimeInMs * HZ) + 999) / 1000;
+ schedule_timeout_uninterruptible(t);
+}
+EXPORT_SYMBOL_GPL(CsrThreadSleep);
diff --git a/drivers/staging/csr/csr_framework_ext.h b/drivers/staging/csr/csr_framework_ext.h
new file mode 100644
index 000000000000..66973e93a6bc
--- /dev/null
+++ b/drivers/staging/csr/csr_framework_ext.h
@@ -0,0 +1,248 @@
+#ifndef CSR_FRAMEWORK_EXT_H__
+#define CSR_FRAMEWORK_EXT_H__
+/*****************************************************************************
+
+ (c) Cambridge Silicon Radio Limited 2010
+ All rights reserved and confidential information of CSR
+
+ Refer to LICENSE.txt included with this source for details
+ on the license terms.
+
+*****************************************************************************/
+
+#include "csr_result.h"
+#include "csr_framework_ext_types.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Result codes */
+#define CSR_FE_RESULT_NO_MORE_EVENTS ((CsrResult) 0x0001)
+#define CSR_FE_RESULT_INVALID_POINTER ((CsrResult) 0x0002)
+#define CSR_FE_RESULT_INVALID_HANDLE ((CsrResult) 0x0003)
+#define CSR_FE_RESULT_NO_MORE_MUTEXES ((CsrResult) 0x0004)
+#define CSR_FE_RESULT_TIMEOUT ((CsrResult) 0x0005)
+#define CSR_FE_RESULT_NO_MORE_THREADS ((CsrResult) 0x0006)
+
+/* Thread priorities */
+#define CSR_THREAD_PRIORITY_HIGHEST ((u16) 0)
+#define CSR_THREAD_PRIORITY_HIGH ((u16) 1)
+#define CSR_THREAD_PRIORITY_NORMAL ((u16) 2)
+#define CSR_THREAD_PRIORITY_LOW ((u16) 3)
+#define CSR_THREAD_PRIORITY_LOWEST ((u16) 4)
+
+#define CSR_EVENT_WAIT_INFINITE ((u16) 0xFFFF)
+
+/*----------------------------------------------------------------------------*
+ * NAME
+ * CsrEventCreate
+ *
+ * DESCRIPTION
+ * Creates an event and returns a handle to the created event.
+ *
+ * RETURNS
+ * Possible values:
+ * CSR_RESULT_SUCCESS in case of success
+ * CSR_FE_RESULT_NO_MORE_EVENTS in case of out of event resources
+ * CSR_FE_RESULT_INVALID_POINTER in case the eventHandle pointer is invalid
+ *
+ *----------------------------------------------------------------------------*/
+CsrResult CsrEventCreate(CsrEventHandle *eventHandle);
+
+/*----------------------------------------------------------------------------*
+ * NAME
+ * CsrEventWait
+ *
+ * DESCRIPTION
+ * Wait fore one or more of the event bits to be set.
+ *
+ * RETURNS
+ * Possible values:
+ * CSR_RESULT_SUCCESS in case of success
+ * CSR_FE_RESULT_TIMEOUT in case of timeout
+ * CSR_FE_RESULT_INVALID_HANDLE in case the eventHandle is invalid
+ * CSR_FE_RESULT_INVALID_POINTER in case the eventBits pointer is invalid
+ *
+ *----------------------------------------------------------------------------*/
+CsrResult CsrEventWait(CsrEventHandle *eventHandle, u16 timeoutInMs, u32 *eventBits);
+
+/*----------------------------------------------------------------------------*
+ * NAME
+ * CsrEventSet
+ *
+ * DESCRIPTION
+ * Set an event.
+ *
+ * RETURNS
+ * Possible values:
+ * CSR_RESULT_SUCCESS in case of success
+ * CSR_FE_RESULT_INVALID_HANDLE in case the eventHandle is invalid
+ *
+ *----------------------------------------------------------------------------*/
+CsrResult CsrEventSet(CsrEventHandle *eventHandle, u32 eventBits);
+
+/*----------------------------------------------------------------------------*
+ * NAME
+ * CsrEventDestroy
+ *
+ * DESCRIPTION
+ * Destroy the event associated.
+ *
+ * RETURNS
+ * void
+ *
+ *----------------------------------------------------------------------------*/
+void CsrEventDestroy(CsrEventHandle *eventHandle);
+
+/*----------------------------------------------------------------------------*
+ * NAME
+ * CsrMutexCreate
+ *
+ * DESCRIPTION
+ * Create a mutex and return a handle to the created mutex.
+ *
+ * RETURNS
+ * Possible values:
+ * CSR_RESULT_SUCCESS in case of success
+ * CSR_FE_RESULT_NO_MORE_MUTEXES in case of out of mutex resources
+ * CSR_FE_RESULT_INVALID_POINTER in case the mutexHandle pointer is invalid
+ *
+ *----------------------------------------------------------------------------*/
+CsrResult CsrMutexCreate(CsrMutexHandle *mutexHandle);
+
+/*----------------------------------------------------------------------------*
+ * NAME
+ * CsrMutexLock
+ *
+ * DESCRIPTION
+ * Lock the mutex refered to by the provided handle.
+ *
+ * RETURNS
+ * Possible values:
+ * CSR_RESULT_SUCCESS in case of success
+ * CSR_FE_RESULT_INVALID_HANDLE in case the mutexHandle is invalid
+ *
+ *----------------------------------------------------------------------------*/
+CsrResult CsrMutexLock(CsrMutexHandle *mutexHandle);
+
+/*----------------------------------------------------------------------------*
+ * NAME
+ * CsrMutexUnlock
+ *
+ * DESCRIPTION
+ * Unlock the mutex refered to by the provided handle.
+ *
+ * RETURNS
+ * Possible values:
+ * CSR_RESULT_SUCCESS in case of success
+ * CSR_FE_RESULT_INVALID_HANDLE in case the mutexHandle is invalid
+ *
+ *----------------------------------------------------------------------------*/
+CsrResult CsrMutexUnlock(CsrMutexHandle *mutexHandle);
+
+/*----------------------------------------------------------------------------*
+ * NAME
+ * CsrMutexDestroy
+ *
+ * DESCRIPTION
+ * Destroy the previously created mutex.
+ *
+ * RETURNS
+ * void
+ *
+ *----------------------------------------------------------------------------*/
+void CsrMutexDestroy(CsrMutexHandle *mutexHandle);
+
+/*----------------------------------------------------------------------------*
+ * NAME
+ * CsrGlobalMutexLock
+ *
+ * DESCRIPTION
+ * Lock the global mutex. The global mutex is a single pre-initialised
+ * shared mutex, spinlock or similar that does not need to be created prior
+ * to use. The limitation is that there is only one single lock shared
+ * between all code. Consequently, it must only be used very briefly to
+ * either protect simple one-time initialisation or to protect the creation
+ * of a dedicated mutex by calling CsrMutexCreate.
+ *
+ *----------------------------------------------------------------------------*/
+void CsrGlobalMutexLock(void);
+
+/*----------------------------------------------------------------------------*
+ * NAME
+ * CsrGlobalMutexUnlock
+ *
+ * DESCRIPTION
+ * Unlock the global mutex.
+ *
+ *----------------------------------------------------------------------------*/
+void CsrGlobalMutexUnlock(void);
+
+/*----------------------------------------------------------------------------*
+ * NAME
+ * CsrThreadCreate
+ *
+ * DESCRIPTION
+ * Create thread function and return a handle to the created thread.
+ *
+ * RETURNS
+ * Possible values:
+ * CSR_RESULT_SUCCESS in case of success
+ * CSR_FE_RESULT_NO_MORE_THREADS in case of out of thread resources
+ * CSR_FE_RESULT_INVALID_POINTER in case one of the supplied pointers is invalid
+ *
+ *----------------------------------------------------------------------------*/
+CsrResult CsrThreadCreate(void (*threadFunction)(void *pointer), void *pointer,
+ u32 stackSize, u16 priority,
+ const char *threadName, CsrThreadHandle *threadHandle);
+
+/*----------------------------------------------------------------------------*
+ * NAME
+ * CsrThreadGetHandle
+ *
+ * DESCRIPTION
+ * Return thread handle of calling thread.
+ *
+ * RETURNS
+ * Possible values:
+ * CSR_RESULT_SUCCESS in case of success
+ * CSR_FE_RESULT_INVALID_POINTER in case the threadHandle pointer is invalid
+ *
+ *----------------------------------------------------------------------------*/
+CsrResult CsrThreadGetHandle(CsrThreadHandle *threadHandle);
+
+/*----------------------------------------------------------------------------*
+ * NAME
+ * CsrThreadEqual
+ *
+ * DESCRIPTION
+ * Compare thread handles
+ *
+ * RETURNS
+ * Possible values:
+ * CSR_RESULT_SUCCESS in case thread handles are identical
+ * CSR_FE_RESULT_INVALID_POINTER in case either threadHandle pointer is invalid
+ * CSR_RESULT_FAILURE otherwise
+ *
+ *----------------------------------------------------------------------------*/
+CsrResult CsrThreadEqual(CsrThreadHandle *threadHandle1, CsrThreadHandle *threadHandle2);
+
+/*----------------------------------------------------------------------------*
+ * NAME
+ * CsrThreadSleep
+ *
+ * DESCRIPTION
+ * Sleep for a given period.
+ *
+ * RETURNS
+ * void
+ *
+ *----------------------------------------------------------------------------*/
+void CsrThreadSleep(u16 sleepTimeInMs);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/drivers/staging/csr/csr_framework_ext_types.h b/drivers/staging/csr/csr_framework_ext_types.h
new file mode 100644
index 000000000000..57194ee911ea
--- /dev/null
+++ b/drivers/staging/csr/csr_framework_ext_types.h
@@ -0,0 +1,63 @@
+#ifndef CSR_FRAMEWORK_EXT_TYPES_H__
+#define CSR_FRAMEWORK_EXT_TYPES_H__
+/*****************************************************************************
+
+ (c) Cambridge Silicon Radio Limited 2010
+ All rights reserved and confidential information of CSR
+
+ Refer to LICENSE.txt included with this source for details
+ on the license terms.
+
+*****************************************************************************/
+
+#ifdef __KERNEL__
+#include <linux/kthread.h>
+#include <linux/semaphore.h>
+#else
+#include <pthread.h>
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+#ifdef __KERNEL__
+
+struct CsrThread
+{
+ struct task_struct *thread_task;
+ char name[16];
+};
+
+struct CsrEvent
+{
+ /* wait_queue for waking the kernel thread */
+ wait_queue_head_t wakeup_q;
+ unsigned int wakeup_flag;
+};
+
+typedef struct CsrEvent CsrEventHandle;
+typedef struct semaphore CsrMutexHandle;
+typedef struct CsrThread CsrThreadHandle;
+
+#else /* __KERNEL __ */
+
+struct CsrEvent
+{
+ pthread_cond_t event;
+ pthread_mutex_t mutex;
+ u32 eventBits;
+};
+
+typedef struct CsrEvent CsrEventHandle;
+typedef pthread_mutex_t CsrMutexHandle;
+typedef pthread_t CsrThreadHandle;
+
+#endif /* __KERNEL__ */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/drivers/staging/csr/csr_lib.h b/drivers/staging/csr/csr_lib.h
new file mode 100644
index 000000000000..b1a57d5d06f9
--- /dev/null
+++ b/drivers/staging/csr/csr_lib.h
@@ -0,0 +1,188 @@
+#ifndef CSR_LIB_H__
+#define CSR_LIB_H__
+/*****************************************************************************
+
+ (c) Cambridge Silicon Radio Limited 2010
+ All rights reserved and confidential information of CSR
+
+ Refer to LICENSE.txt included with this source for details
+ on the license terms.
+
+*****************************************************************************/
+
+#include "csr_prim_defs.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct
+{
+ CsrPrim type;
+} CsrEvent;
+
+/*----------------------------------------------------------------------------*
+ * CsrEvent_struct
+ *
+ * DESCRIPTION
+ * Generic message creator.
+ * Allocates and fills in a message with the signature CsrEvent
+ *
+ *----------------------------------------------------------------------------*/
+CsrEvent *CsrEvent_struct(u16 primtype, u16 msgtype);
+
+typedef struct
+{
+ CsrPrim type;
+ u8 value;
+} CsrEventCsrUint8;
+
+/*----------------------------------------------------------------------------*
+ * CsrEventCsrUint8_struct
+ *
+ * DESCRIPTION
+ * Generic message creator.
+ * Allocates and fills in a message with the signature CsrEventCsrUint8
+ *
+ *----------------------------------------------------------------------------*/
+CsrEventCsrUint8 *CsrEventCsrUint8_struct(u16 primtype, u16 msgtype, u8 value);
+
+typedef struct
+{
+ CsrPrim type;
+ u16 value;
+} CsrEventCsrUint16;
+
+/*----------------------------------------------------------------------------*
+ * CsrEventCsrUint16_struct
+ *
+ * DESCRIPTION
+ * Generic message creator.
+ * Allocates and fills in a message with the signature CsrEventCsrUint16
+ *
+ *----------------------------------------------------------------------------*/
+CsrEventCsrUint16 *CsrEventCsrUint16_struct(u16 primtype, u16 msgtype, u16 value);
+
+typedef struct
+{
+ CsrPrim type;
+ u16 value1;
+ u8 value2;
+} CsrEventCsrUint16CsrUint8;
+
+/*----------------------------------------------------------------------------*
+ * CsrEventCsrUint16CsrUint8_struct
+ *
+ * DESCRIPTION
+ * Generic message creator.
+ * Allocates and fills in a message with the signature CsrEventCsrUint16CsrUint8
+ *
+ *----------------------------------------------------------------------------*/
+CsrEventCsrUint16CsrUint8 *CsrEventCsrUint16CsrUint8_struct(u16 primtype, u16 msgtype, u16 value1, u8 value2);
+
+typedef struct
+{
+ CsrPrim type;
+ u16 value1;
+ u16 value2;
+} CsrEventCsrUint16CsrUint16;
+
+/*----------------------------------------------------------------------------*
+ * CsrEventCsrUint16CsrUint16_struct
+ *
+ * DESCRIPTION
+ * Generic message creator.
+ * Allocates and fills in a message with the signature CsrEventCsrUint16CsrUint16
+ *
+ *----------------------------------------------------------------------------*/
+CsrEventCsrUint16CsrUint16 *CsrEventCsrUint16CsrUint16_struct(u16 primtype, u16 msgtype, u16 value1, u16 value2);
+
+typedef struct
+{
+ CsrPrim type;
+ u16 value1;
+ u32 value2;
+} CsrEventCsrUint16CsrUint32;
+
+/*----------------------------------------------------------------------------*
+ * CsrEventCsrUint16_struct
+ *
+ * DESCRIPTION
+ * Generic message creator.
+ * Allocates and fills in a message with the signature CsrEventCsrUint16
+ *
+ *----------------------------------------------------------------------------*/
+CsrEventCsrUint16CsrUint32 *CsrEventCsrUint16CsrUint32_struct(u16 primtype, u16 msgtype, u16 value1, u32 value2);
+
+typedef struct
+{
+ CsrPrim type;
+ u16 value1;
+ char *value2;
+} CsrEventCsrUint16CsrCharString;
+
+/*----------------------------------------------------------------------------*
+ * CsrEventCsrUint16CsrCharString_struct
+ *
+ * DESCRIPTION
+ * Generic message creator.
+ * Allocates and fills in a message with the signature CsrEventCsrUint16CsrCharString
+ *
+ *----------------------------------------------------------------------------*/
+CsrEventCsrUint16CsrCharString *CsrEventCsrUint16CsrCharString_struct(u16 primtype, u16 msgtype, u16 value1, char *value2);
+
+typedef struct
+{
+ CsrPrim type;
+ u32 value;
+} CsrEventCsrUint32;
+
+/*----------------------------------------------------------------------------*
+ * CsrEventCsrUint32_struct
+ *
+ * DESCRIPTION
+ * Generic message creator.
+ * Allocates and fills in a message with the signature CsrEventCsrUint32
+ *
+ *----------------------------------------------------------------------------*/
+CsrEventCsrUint32 *CsrEventCsrUint32_struct(u16 primtype, u16 msgtype, u32 value);
+
+typedef struct
+{
+ CsrPrim type;
+ u32 value1;
+ u16 value2;
+} CsrEventCsrUint32CsrUint16;
+
+/*----------------------------------------------------------------------------*
+ * CsrEventCsrUint32CsrUint16_struct
+ *
+ * DESCRIPTION
+ * Generic message creator.
+ * Allocates and fills in a message with the signature CsrEventCsrUint32CsrUint16
+ *
+ *----------------------------------------------------------------------------*/
+CsrEventCsrUint32CsrUint16 *CsrEventCsrUint32CsrUint16_struct(u16 primtype, u16 msgtype, u32 value1, u32 value2);
+
+typedef struct
+{
+ CsrPrim type;
+ u32 value1;
+ char *value2;
+} CsrEventCsrUint32CsrCharString;
+
+/*----------------------------------------------------------------------------*
+ * CsrEventCsrUint32CsrCharString_struct
+ *
+ * DESCRIPTION
+ * Generic message creator.
+ * Allocates and fills in a message with the signature CsrEventCsrUint32CsrCharString
+ *
+ *----------------------------------------------------------------------------*/
+CsrEventCsrUint32CsrCharString *CsrEventCsrUint32CsrCharString_struct(u16 primtype, u16 msgtype, u32 value1, char *value2);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* CSR_LIB_H__ */
diff --git a/drivers/staging/csr/csr_log.h b/drivers/staging/csr/csr_log.h
new file mode 100644
index 000000000000..b2808569f8de
--- /dev/null
+++ b/drivers/staging/csr/csr_log.h
@@ -0,0 +1,249 @@
+#ifndef CSR_LOG_H__
+#define CSR_LOG_H__
+/*****************************************************************************
+
+ (c) Cambridge Silicon Radio Limited 2010
+ All rights reserved and confidential information of CSR
+
+ Refer to LICENSE.txt included with this source for details
+ on the license terms.
+
+*****************************************************************************/
+
+#include "csr_sched.h"
+#include "csr_panic.h"
+#include "csr_prim_defs.h"
+#include "csr_msgconv.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ * Log filtering
+ */
+
+/*----------------------------------------------------*/
+/* Filtering on environment specific log levels */
+/*----------------------------------------------------*/
+typedef u32 CsrLogLevelEnvironment;
+#define CSR_LOG_LEVEL_ENVIRONMENT_OFF ((CsrLogLevelEnvironment) 0x00000000) /* No environment data/events are logged */
+#define CSR_LOG_LEVEL_ENVIRONMENT_BCI_ACL ((CsrLogLevelEnvironment) 0x00000001) /* BlueCore Channel Interface HCI Acl data are logged */
+#define CSR_LOG_LEVEL_ENVIRONMENT_BCI_HCI ((CsrLogLevelEnvironment) 0x00000002) /* BlueCore Channel Interface HCI Cmd/Evt data are logged */
+#define CSR_LOG_LEVEL_ENVIRONMENT_BCI_SCO ((CsrLogLevelEnvironment) 0x00000004) /* BlueCore Channel Interface HCI Sco data are logged */
+#define CSR_LOG_LEVEL_ENVIRONMENT_BCI_VENDOR ((CsrLogLevelEnvironment) 0x00000008) /* BlueCore Channel Interface HCI Vendor specific data are logged (This includes BCCMD, HQ, VM etc) */
+#define CSR_LOG_LEVEL_ENVIRONMENT_TRANSPORTS ((CsrLogLevelEnvironment) 0x00000010) /* Transport protocol data is logged (This includes transport protocols like BCSP, H4 etc.) */
+#define CSR_LOG_LEVEL_ENVIRONMENT_BGINT_REG ((CsrLogLevelEnvironment) 0x00000020) /* Background Interrupt registration events are logged */
+#define CSR_LOG_LEVEL_ENVIRONMENT_BGINT_UNREG ((CsrLogLevelEnvironment) 0x00000040) /* Background Interrupt unregistration events are logged */
+#define CSR_LOG_LEVEL_ENVIRONMENT_BGINT_SET ((CsrLogLevelEnvironment) 0x00000080) /* Background Interrupt set events are logged */
+#define CSR_LOG_LEVEL_ENVIRONMENT_BGINT_START ((CsrLogLevelEnvironment) 0x00000100) /* Background Interrupt start events are logged */
+#define CSR_LOG_LEVEL_ENVIRONMENT_BGINT_DONE ((CsrLogLevelEnvironment) 0x00000200) /* Background Interrupt done events are logged */
+#define CSR_LOG_LEVEL_ENVIRONMENT_PROTO ((CsrLogLevelEnvironment) 0x00000400) /* Transport protocol events are logged */
+#define CSR_LOG_LEVEL_ENVIRONMENT_PROTO_LOC ((CsrLogLevelEnvironment) 0x00000800) /* The Location where the transport protocol event occured are logged NB: This is a supplement to CSR_LOG_LEVEL_ENVIRONMENT_PROTO, it has no effect without it */
+/* The bit masks between here are reserved for future usage */
+#define CSR_LOG_LEVEL_ENVIRONMENT_ALL ((CsrLogLevelEnvironment) 0xFFFFFFFF) /* All possible environment data/events are logged WARNING: By using this define the application also accepts future possible environment data/events in the logs */
+
+/*----------------------------------------------------*/
+/* Filtering on task specific log levels */
+/*----------------------------------------------------*/
+typedef u32 CsrLogLevelTask;
+#define CSR_LOG_LEVEL_TASK_OFF ((CsrLogLevelTask) 0x00000000) /* No events are logged for this task */
+#define CSR_LOG_LEVEL_TASK_TEXT ((CsrLogLevelTask) 0x00000001) /* Text strings printed by a task are logged NB: This bit does not affect the CSR_LOG_TEXT_LEVEL interface. This has to be configured separately */
+#define CSR_LOG_LEVEL_TASK_TEXT_LOC ((CsrLogLevelTask) 0x00000002) /* The locaction where the text string call occured are logged. NB: This is a supplement to CSR_LOG_LEVEL_TASK_TEXT, it has no effect without it */
+#define CSR_LOG_LEVEL_TASK_STATE ((CsrLogLevelTask) 0x00000004) /* FSM state transitions in a task are logged */
+#define CSR_LOG_LEVEL_TASK_STATE_NAME ((CsrLogLevelTask) 0x00000008) /* The name of each state in a FSM state transition are logged. NB: This is a supplement to CSR_LOG_LEVEL_TASK_STATE, it has no effect without it */
+#define CSR_LOG_LEVEL_TASK_STATE_LOC ((CsrLogLevelTask) 0x00000010) /* The location where the FSM state transition occured are logged. NB: This is a supplement to CSR_LOG_LEVEL_TASK_STATE, it has no effect without it */
+#define CSR_LOG_LEVEL_TASK_TASK_SWITCH ((CsrLogLevelTask) 0x00000020) /* Activation and deactiation of a task are logged */
+#define CSR_LOG_LEVEL_TASK_MESSAGE_PUT ((CsrLogLevelTask) 0x00000080) /* Message put operations are logged */
+#define CSR_LOG_LEVEL_TASK_MESSAGE_PUT_LOC ((CsrLogLevelTask) 0x00000100) /* The location where a message was sent are logged. NB: This is a supplement to CSR_LOG_LEVEL_TASK_MESSAGE_PUT, it has no effect without it */
+#define CSR_LOG_LEVEL_TASK_MESSAGE_GET ((CsrLogLevelTask) 0x00000200) /* Message get operations are logged */
+#define CSR_LOG_LEVEL_TASK_MESSAGE_QUEUE_PUSH ((CsrLogLevelTask) 0x00000400) /* Message push operations are logged */
+#define CSR_LOG_LEVEL_TASK_MESSAGE_QUEUE_POP ((CsrLogLevelTask) 0x00000800) /* Message pop operations are logged */
+#define CSR_LOG_LEVEL_TASK_PRIM_ONLY_TYPE ((CsrLogLevelTask) 0x00001000) /* Only the type of primitives in messages are logged. By default the entire primitive is serialized and logged */
+#define CSR_LOG_LEVEL_TASK_PRIM_APPLY_LIMIT ((CsrLogLevelTask) 0x00002000) /* An upper limit (defined by CSR_LOG_PRIM_SIZE_UPPER_LIMIT) is applied to how much of a primitive in a message are logged. NB: This limit is only applied if CSR_LOG_LEVEL_TASK_PRIM_ONLY_TYPE is _not_ defined */
+#define CSR_LOG_LEVEL_TASK_TIMER_IN ((CsrLogLevelTask) 0x00004000) /* TimedEventIn events are logged */
+#define CSR_LOG_LEVEL_TASK_TIMER_IN_LOC ((CsrLogLevelTask) 0x00008000) /* The location where a timer was started are logged. NB: This is a supplement to CSR_LOG_LEVEL_TASK_TIMER_IN, it has no effect without it */
+#define CSR_LOG_LEVEL_TASK_TIMER_CANCEL ((CsrLogLevelTask) 0x00010000) /* TimedEventCancel events are logged */
+#define CSR_LOG_LEVEL_TASK_TIMER_CANCEL_LOC ((CsrLogLevelTask) 0x00020000) /* The location where a timer was cancelled are logged. NB: This is a supplement to CSR_LOG_LEVEL_TASK_TIMER_CANCEL, it has no effect without it */
+#define CSR_LOG_LEVEL_TASK_TIMER_FIRE ((CsrLogLevelTask) 0x00040000) /* TimedEventFire events are logged */
+#define CSR_LOG_LEVEL_TASK_TIMER_DONE ((CsrLogLevelTask) 0x00080000) /* TimedEventDone events are logged */
+/* The bit masks between here are reserved for future usage */
+#define CSR_LOG_LEVEL_TASK_ALL ((CsrLogLevelTask) 0xFFFFFFFF & ~(CSR_LOG_LEVEL_TASK_PRIM_ONLY_TYPE | CSR_LOG_LEVEL_TASK_PRIM_APPLY_LIMIT)) /* All info possible to log for a task are logged. WARNING: By using this define the application also accepts future possible task data/events in the logs */
+
+u8 CsrLogEnvironmentIsFiltered(CsrLogLevelEnvironment level);
+CsrLogLevelTask CsrLogTaskFilterGet(CsrSchedQid taskId);
+u8 CsrLogTaskIsFiltered(CsrSchedQid taskId, CsrLogLevelTask level);
+
+/*
+ * Logging stuff
+ */
+#define CSR_LOG_STRINGIFY_REAL(a) #a
+#define CSR_LOG_STRINGIFY(a) CSR_LOG_STRINGIFY_REAL(a)
+
+#ifdef CSR_LOG_ASSERT_ENABLE
+#define CSR_LOG_ASSERT(cond) \
+ do { \
+ if (!(cond)) \
+ { \
+ char *panic_arg = "[" __FILE__ ":" CSR_LOG_STRINGIFY(__LINE__) "] - " CSR_LOG_STRINGIFY(cond); \
+ CsrPanic(CSR_TECH_FW, CSR_PANIC_FW_ASSERTION_FAIL, panic_arg); \
+ } \
+ } while (0)
+#else
+#define CSR_LOG_ASSERT(cond)
+#endif
+
+typedef struct
+{
+ u16 primitiveType;
+ const char *primitiveName;
+ CsrMsgConvMsgEntry *messageConv; /* Private - do not use */
+} CsrLogPrimitiveInformation;
+
+typedef struct
+{
+ const char *techVer;
+ u32 primitiveInfoCount;
+ CsrLogPrimitiveInformation *primitiveInfo;
+} CsrLogTechInformation;
+
+/*---------------------------------*/
+/* Tech logging */
+/*---------------------------------*/
+typedef u8 bitmask8_t;
+typedef u16 bitmask16_t;
+typedef u32 bitmask32_t;
+
+#ifdef CSR_LOG_ENABLE
+#ifdef CSR_LOG_INCLUDE_FILE_NAME_AND_LINE_NUMBER
+/* DEPRECATED - replaced by csr_log_text.h */
+#define CSR_LOG_TEXT(text) \
+ do { \
+ if (!CsrLogTaskIsFiltered(CsrSchedTaskQueueGet(), CSR_LOG_LEVEL_TASK_TEXT)) \
+ { \
+ CsrLogTaskText(text, __LINE__, __FILE__); \
+ } \
+ } while (0)
+#else
+/* DEPRECATED - replaced by csr_log_text.h */
+#define CSR_LOG_TEXT(text) \
+ do { \
+ if (!CsrLogTaskIsFiltered(CsrSchedTaskQueueGet(), CSR_LOG_LEVEL_TASK_TEXT)) \
+ { \
+ CsrLogTaskText(text, 0, NULL); \
+ } \
+ } while (0)
+#endif
+#else
+#define CSR_LOG_TEXT(text)
+#endif
+
+/* DEPRECATED - replaced by csr_log_text.h */
+void CsrLogTaskText(const char *text,
+ u32 line,
+ const char *file);
+
+#define CSR_LOG_STATE_TRANSITION_MASK_FSM_NAME (0x001)
+#define CSR_LOG_STATE_TRANSITION_MASK_NEXT_STATE (0x002)
+#define CSR_LOG_STATE_TRANSITION_MASK_NEXT_STATE_STR (0x004)
+#define CSR_LOG_STATE_TRANSITION_MASK_PREV_STATE (0x008)
+#define CSR_LOG_STATE_TRANSITION_MASK_PREV_STATE_STR (0x010)
+#define CSR_LOG_STATE_TRANSITION_MASK_EVENT (0x020)
+#define CSR_LOG_STATE_TRANSITION_MASK_EVENT_STR (0x040)
+
+/* DEPRECATED - replaced by csr_log_text.h */
+void CsrLogStateTransition(bitmask16_t mask,
+ u32 identifier,
+ const char *fsm_name,
+ u32 prev_state,
+ const char *prev_state_str,
+ u32 in_event,
+ const char *in_event_str,
+ u32 next_state,
+ const char *next_state_str,
+ u32 line,
+ const char *file);
+
+/*---------------------------------*/
+/* BSP logging */
+/*---------------------------------*/
+void CsrLogSchedInit(u8 thread_id);
+void CsrLogSchedDeinit(u8 thread_id);
+
+void CsrLogSchedStart(u8 thread_id);
+void CsrLogSchedStop(u8 thread_id);
+
+void CsrLogInitTask(u8 thread_id, CsrSchedQid tskid, const char *tskName);
+void CsrLogDeinitTask(u16 task_id);
+
+void CsrLogActivate(CsrSchedQid tskid);
+void CsrLogDeactivate(CsrSchedQid tskid);
+
+#define SYNERGY_SERIALIZER_TYPE_DUMP (0x000)
+#define SYNERGY_SERIALIZER_TYPE_SER (0x001)
+
+void CsrLogMessagePut(u32 line,
+ const char *file,
+ CsrSchedQid src_task_id,
+ CsrSchedQid dst_taskid,
+ CsrSchedMsgId msg_id,
+ u16 prim_type,
+ const void *msg);
+
+void CsrLogMessageGet(CsrSchedQid src_task_id,
+ CsrSchedQid dst_taskid,
+ u8 get_res,
+ CsrSchedMsgId msg_id,
+ u16 prim_type,
+ const void *msg);
+
+void CsrLogTimedEventIn(u32 line,
+ const char *file,
+ CsrSchedQid task_id,
+ CsrSchedTid tid,
+ CsrTime requested_delay,
+ u16 fniarg,
+ const void *fnvarg);
+
+void CsrLogTimedEventFire(CsrSchedQid task_id,
+ CsrSchedTid tid);
+
+void CsrLogTimedEventDone(CsrSchedQid task_id,
+ CsrSchedTid tid);
+
+void CsrLogTimedEventCancel(u32 line,
+ const char *file,
+ CsrSchedQid task_id,
+ CsrSchedTid tid,
+ u8 cancel_res);
+
+void CsrLogBgintRegister(u8 thread_id,
+ CsrSchedBgint irq,
+ const char *callback,
+ const void *ptr);
+void CsrLogBgintUnregister(CsrSchedBgint irq);
+void CsrLogBgintSet(CsrSchedBgint irq);
+void CsrLogBgintServiceStart(CsrSchedBgint irq);
+void CsrLogBgintServiceDone(CsrSchedBgint irq);
+
+void CsrLogExceptionStateEvent(u16 prim_type,
+ CsrPrim msg_type,
+ u16 state,
+ u32 line,
+ const char *file);
+void CsrLogExceptionGeneral(u16 prim_type,
+ u16 state,
+ const char *text,
+ u32 line,
+ const char *file);
+void CsrLogExceptionWarning(u16 prim_type,
+ u16 state,
+ const char *text,
+ u32 line,
+ const char *file);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/drivers/staging/csr/csr_log_configure.h b/drivers/staging/csr/csr_log_configure.h
new file mode 100644
index 000000000000..8842e4bf4611
--- /dev/null
+++ b/drivers/staging/csr/csr_log_configure.h
@@ -0,0 +1,134 @@
+#ifndef CSR_LOG_CONFIGURE_H__
+#define CSR_LOG_CONFIGURE_H__
+/*****************************************************************************
+
+ (c) Cambridge Silicon Radio Limited 2010
+ All rights reserved and confidential information of CSR
+
+ Refer to LICENSE.txt included with this source for details
+ on the license terms.
+
+*****************************************************************************/
+
+#include "csr_log.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*---------------------------------*/
+/* Log init/deinit */
+/*---------------------------------*/
+void CsrLogInit(u8 size);
+void CsrLogDeinit(void);
+
+/*---------------------------------*/
+/* Log Framework Tech info */
+/*---------------------------------*/
+void CsrLogTechInfoRegister(void);
+
+/* Set the logging level for the environment outside the scheduler context */
+void CsrLogLevelEnvironmentSet(CsrLogLevelEnvironment environmentLogLevel);
+
+
+/* Set the logging level for all scheduler tasks */
+/* This function call takes precedence over all previous calls to CsrLogLevelTaskSetSpecific() */
+void CsrLogLevelTaskSetAll(CsrLogLevelTask tasksLogLevelMask);
+
+/* Set the logging level for a given Task */
+/* This function can be used as a complement to CsrLogLevelTaskSetAll() to add more _or_ less log from a given task than what is set
+generally with CsrLogLevelTaskSetAll(). */
+void CsrLogLevelTaskSetSpecific(CsrSchedQid taskId, CsrLogLevelTask taskLogLevelMask);
+
+
+/*--------------------------------------------*/
+/* Filtering on log text warning levels */
+/*--------------------------------------------*/
+typedef u32 CsrLogLevelText;
+#define CSR_LOG_LEVEL_TEXT_OFF ((CsrLogLevelText) 0x0000)
+
+#define CSR_LOG_LEVEL_TEXT_CRITICAL ((CsrLogLevelText) 0x0001)
+#define CSR_LOG_LEVEL_TEXT_ERROR ((CsrLogLevelText) 0x0002)
+#define CSR_LOG_LEVEL_TEXT_WARNING ((CsrLogLevelText) 0x0004)
+#define CSR_LOG_LEVEL_TEXT_INFO ((CsrLogLevelText) 0x0008)
+#define CSR_LOG_LEVEL_TEXT_DEBUG ((CsrLogLevelText) 0x0010)
+
+#define CSR_LOG_LEVEL_TEXT_ALL ((CsrLogLevelText) 0xFFFF)
+
+/* The log text interface is used by both scheduler tasks and components outside the scheduler context.
+ * Therefore a CsrLogTextTaskId is introduced. It is effectively considered as two u16's. The lower
+ * 16 bits corresponds one2one with the scheduler queueId's (CsrSchedQid) and as such these bits can not be used
+ * by components outside scheduler tasks. The upper 16 bits are allocated for use of components outside the
+ * scheduler like drivers etc. Components in this range is defined independently by each technology. To avoid
+ * clashes the technologies are only allowed to assign values within the same restrictive range as allies to
+ * primitive identifiers. eg. for the framework components outside the scheduler is only allowed to assign
+ * taskId's in the range 0x0600xxxx to 0x06FFxxxx. And so on for other technologies. */
+typedef u32 CsrLogTextTaskId;
+
+/* Set the text logging level for all Tasks */
+/* This function call takes precedence over all previous calls to CsrLogLevelTextSetTask() and CsrLogLevelTextSetTaskSubOrigin() */
+void CsrLogLevelTextSetAll(CsrLogLevelText warningLevelMask);
+
+/* Set the text logging level for a given Task */
+/* This function call takes precedence over all previous calls to CsrLogLevelTextSetTaskSubOrigin(), but it can be used as a complement to
+ * CsrLogLevelTextSetAll() to add more _or_ less log from a given task than what is set generally with CsrLogLevelTextSetAll(). */
+void CsrLogLevelTextSetTask(CsrLogTextTaskId taskId, CsrLogLevelText warningLevelMask);
+
+/* Set the text logging level for a given tasks subOrigin */
+/* This function can be used as a complement to CsrLogLevelTextSetAll() and CsrLogLevelTextSetTask() to add more _or_ less log from a given
+ * subOrigin within a task than what is set generally with CsrLogLevelTextSetAll() _or_ CsrLogLevelTextSetTask(). */
+void CsrLogLevelTextSetTaskSubOrigin(CsrLogTextTaskId taskId, u16 subOrigin, CsrLogLevelText warningLevelMask);
+
+/*******************************************************************************
+
+ NAME
+ CsrLogLevelTextSet
+
+ DESCRIPTION
+ Set the text logging level for a given origin and optionally sub origin
+ by name. If either string is NULL or zero length, it is interpreted as
+ all origins and/or all sub origins respectively. If originName is NULL
+ or zero length, subOriginName is ignored.
+
+ Passing NULL or zero length strings in both originName and subOriginName
+ is equivalent to calling CsrLogLevelTextSetAll, and overrides all
+ previous filter configurations for all origins and sub origins.
+
+ Passing NULL or a zero length string in subOriginName overrides all
+ previous filter configurations for all sub origins of the specified
+ origin.
+
+ Note: the supplied strings may be accessed after the function returns
+ and must remain valid and constant until CsrLogDeinit is called.
+
+ Note: when specifying an origin (originName is not NULL and not zero
+ length), this function can only be used for origins that use the
+ csr_log_text_2.h interface for registration and logging. Filtering for
+ origins that use the legacy csr_log_text.h interface must be be
+ configured using the legacy filter configuration functions that accept
+ a CsrLogTextTaskId as origin specifier. However, when not specifying an
+ origin this function also affects origins that have been registered with
+ the legacy csr_log_text.h interface. Furthermore, using this function
+ and the legacy filter configuration functions on the same origin is not
+ allowed.
+
+ PARAMETERS
+ originName - a string containing the name of the origin. Can be NULL or
+ zero length to set the log level for all origins. In this case, the
+ subOriginName parameter will be ignored.
+ subOriginName - a string containing the name of the sub origin. Can be
+ NULL or zero length to set the log level for all sub origins of the
+ specified origin.
+ warningLevelMask - The desired log level for the specified origin(s) and
+ sub origin(s).
+
+*******************************************************************************/
+void CsrLogLevelTextSet(const char *originName,
+ const char *subOriginName,
+ CsrLogLevelText warningLevelMask);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/drivers/staging/csr/csr_log_text.h b/drivers/staging/csr/csr_log_text.h
new file mode 100644
index 000000000000..9fe6c90244c4
--- /dev/null
+++ b/drivers/staging/csr/csr_log_text.h
@@ -0,0 +1,132 @@
+#ifndef CSR_LOG_TEXT_H__
+#define CSR_LOG_TEXT_H__
+/*****************************************************************************
+
+ (c) Cambridge Silicon Radio Limited 2010
+ All rights reserved and confidential information of CSR
+
+ Refer to LICENSE.txt included with this source for details
+ on the license terms.
+
+*****************************************************************************/
+
+#include "csr_log_configure.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct CsrLogSubOrigin
+{
+ u16 subOriginNumber; /* Id of the given SubOrigin */
+ const char *subOriginName; /* Prefix Text for this SubOrigin */
+} CsrLogSubOrigin;
+
+/* Register a task which is going to use the CSR_LOG_TEXT_XXX interface */
+#ifdef CSR_LOG_ENABLE
+void CsrLogTextRegister(CsrLogTextTaskId taskId, const char *taskName, u16 subOriginsLength, const CsrLogSubOrigin *subOrigins);
+#else
+#define CsrLogTextRegister(taskId, taskName, subOriginsLength, subOrigins)
+#endif
+
+/* CRITICAL: Conditions that are threatening to the integrity/stability of the
+ system as a whole. */
+#if defined(CSR_LOG_ENABLE) && !defined(CSR_LOG_LEVEL_TEXT_CRITICAL_DISABLE)
+void CsrLogTextCritical(CsrLogTextTaskId taskId, u16 subOrigin, const char *formatString, ...);
+void CsrLogTextBufferCritical(CsrLogTextTaskId taskId, u16 subOrigin, size_t bufferLength, const void *buffer, const char *formatString, ...);
+#define CSR_LOG_TEXT_CRITICAL(taskId_subOrigin_formatString_varargs) CsrLogTextCritical taskId_subOrigin_formatString_varargs
+#define CSR_LOG_TEXT_CONDITIONAL_CRITICAL(condition, logtextargs) {if (condition) {CSR_LOG_TEXT_CRITICAL(logtextargs);}}
+#define CSR_LOG_TEXT_BUFFER_CRITICAL(taskId_subOrigin_length_buffer_formatString_varargs) CsrLogTextBufferCritical taskId_subOrigin_length_buffer_formatString_varargs
+#define CSR_LOG_TEXT_BUFFER_CONDITIONAL_CRITICAL(condition, logtextbufferargs) {if (condition) {CSR_LOG_TEXT_BUFFER_CRITICAL(logtextbufferargs);}}
+#else
+#define CSR_LOG_TEXT_CRITICAL(taskId_subOrigin_formatString_varargs)
+#define CSR_LOG_TEXT_CONDITIONAL_CRITICAL(condition, logtextargs)
+#define CSR_LOG_TEXT_BUFFER_CRITICAL(taskId_subOrigin_length_buffer_formatString_varargs)
+#define CSR_LOG_TEXT_BUFFER_CONDITIONAL_CRITICAL(condition, logtextbufferargs)
+#endif
+
+/* ERROR: Malfunction of a component rendering it unable to operate correctly,
+ causing lack of functionality but not loss of system integrity/stability. */
+#if defined(CSR_LOG_ENABLE) && !defined(CSR_LOG_LEVEL_TEXT_ERROR_DISABLE)
+void CsrLogTextError(CsrLogTextTaskId taskId, u16 subOrigin, const char *formatString, ...);
+void CsrLogTextBufferError(CsrLogTextTaskId taskId, u16 subOrigin, size_t bufferLength, const void *buffer, const char *formatString, ...);
+#define CSR_LOG_TEXT_ERROR(taskId_subOrigin_formatString_varargs) CsrLogTextError taskId_subOrigin_formatString_varargs
+#define CSR_LOG_TEXT_CONDITIONAL_ERROR(condition, logtextargs) {if (condition) {CSR_LOG_TEXT_ERROR(logtextargs);}}
+#define CSR_LOG_TEXT_BUFFER_ERROR(taskId_subOrigin_length_buffer_formatString_varargs) CsrLogTextBufferError taskId_subOrigin_length_buffer_formatString_varargs
+#define CSR_LOG_TEXT_BUFFER_CONDITIONAL_ERROR(condition, logtextbufferargs) {if (condition) {CSR_LOG_TEXT_BUFFER_ERROR(logtextbufferargs);}}
+#else
+#define CSR_LOG_TEXT_ERROR(taskId_subOrigin_formatString_varargs)
+#define CSR_LOG_TEXT_CONDITIONAL_ERROR(condition, logtextargs)
+#define CSR_LOG_TEXT_BUFFER_ERROR(taskId_subOrigin_length_buffer_formatString_varargs)
+#define CSR_LOG_TEXT_BUFFER_CONDITIONAL_ERROR(condition, logtextbufferargs)
+#endif
+
+/* WARNING: Conditions that are unexpected and indicative of possible problems
+ or violations of specifications, where the result of such deviations does not
+ lead to malfunction of the component. */
+#if defined(CSR_LOG_ENABLE) && !defined(CSR_LOG_LEVEL_TEXT_WARNING_DISABLE)
+void CsrLogTextWarning(CsrLogTextTaskId taskId, u16 subOrigin, const char *formatString, ...);
+void CsrLogTextBufferWarning(CsrLogTextTaskId taskId, u16 subOrigin, size_t bufferLength, const void *buffer, const char *formatString, ...);
+#define CSR_LOG_TEXT_WARNING(taskId_subOrigin_formatString_varargs) CsrLogTextWarning taskId_subOrigin_formatString_varargs
+#define CSR_LOG_TEXT_CONDITIONAL_WARNING(condition, logtextargs) {if (condition) {CSR_LOG_TEXT_WARNING(logtextargs);}}
+#define CSR_LOG_TEXT_BUFFER_WARNING(taskId_subOrigin_length_buffer_formatString_varargs) CsrLogTextBufferWarning taskId_subOrigin_length_buffer_formatString_varargs
+#define CSR_LOG_TEXT_BUFFER_CONDITIONAL_WARNING(condition, logtextbufferargs) {if (condition) {CSR_LOG_TEXT_BUFFER_WARNING(logtextbufferargs);}}
+#else
+#define CSR_LOG_TEXT_WARNING(taskId_subOrigin_formatString_varargs)
+#define CSR_LOG_TEXT_CONDITIONAL_WARNING(condition, logtextargs)
+#define CSR_LOG_TEXT_BUFFER_WARNING(taskId_subOrigin_length_buffer_formatString_varargs)
+#define CSR_LOG_TEXT_BUFFER_CONDITIONAL_WARNING(condition, logtextbufferargs)
+#endif
+
+/* INFO: Important events that may aid in determining the conditions under which
+ the more severe conditions are encountered. */
+#if defined(CSR_LOG_ENABLE) && !defined(CSR_LOG_LEVEL_TEXT_INFO_DISABLE)
+void CsrLogTextInfo(CsrLogTextTaskId taskId, u16 subOrigin, const char *formatString, ...);
+void CsrLogTextBufferInfo(CsrLogTextTaskId taskId, u16 subOrigin, size_t bufferLength, const void *buffer, const char *formatString, ...);
+#define CSR_LOG_TEXT_INFO(taskId_subOrigin_formatString_varargs) CsrLogTextInfo taskId_subOrigin_formatString_varargs
+#define CSR_LOG_TEXT_CONDITIONAL_INFO(condition, logtextargs) {if (condition) {CSR_LOG_TEXT_INFO(logtextargs);}}
+#define CSR_LOG_TEXT_BUFFER_INFO(taskId_subOrigin_length_buffer_formatString_varargs) CsrLogTextBufferInfo taskId_subOrigin_length_buffer_formatString_varargs
+#define CSR_LOG_TEXT_BUFFER_CONDITIONAL_INFO(condition, logtextbufferargs) {if (condition) {CSR_LOG_TEXT_BUFFER_INFO(logtextbufferargs);}}
+#else
+#define CSR_LOG_TEXT_INFO(taskId_subOrigin_formatString_varargs)
+#define CSR_LOG_TEXT_CONDITIONAL_INFO(condition, logtextargs)
+#define CSR_LOG_TEXT_BUFFER_INFO(taskId_subOrigin_length_buffer_formatString_varargs)
+#define CSR_LOG_TEXT_BUFFER_CONDITIONAL_INFO(condition, logtextbufferargs)
+#endif
+
+/* DEBUG: Similar to INFO, but dedicated to events that occur more frequently. */
+#if defined(CSR_LOG_ENABLE) && !defined(CSR_LOG_LEVEL_TEXT_DEBUG_DISABLE)
+void CsrLogTextDebug(CsrLogTextTaskId taskId, u16 subOrigin, const char *formatString, ...);
+void CsrLogTextBufferDebug(CsrLogTextTaskId taskId, u16 subOrigin, size_t bufferLength, const void *buffer, const char *formatString, ...);
+#define CSR_LOG_TEXT_DEBUG(taskId_subOrigin_formatString_varargs) CsrLogTextDebug taskId_subOrigin_formatString_varargs
+#define CSR_LOG_TEXT_CONDITIONAL_DEBUG(condition, logtextargs) {if (condition) {CSR_LOG_TEXT_DEBUG(logtextargs);}}
+#define CSR_LOG_TEXT_BUFFER_DEBUG(taskId_subOrigin_length_buffer_formatString_varargs) CsrLogTextBufferDebug taskId_subOrigin_length_buffer_formatString_varargs
+#define CSR_LOG_TEXT_BUFFER_CONDITIONAL_DEBUG(condition, logtextbufferargs) {if (condition) {CSR_LOG_TEXT_BUFFER_DEBUG(logtextbufferargs);}}
+#else
+#define CSR_LOG_TEXT_DEBUG(taskId_subOrigin_formatString_varargs)
+#define CSR_LOG_TEXT_CONDITIONAL_DEBUG(condition, logtextargs)
+#define CSR_LOG_TEXT_BUFFER_DEBUG(taskId_subOrigin_length_buffer_formatString_varargs)
+#define CSR_LOG_TEXT_BUFFER_CONDITIONAL_DEBUG(condition, logtextbufferargs)
+#endif
+
+/* CSR_LOG_TEXT_ASSERT (CRITICAL) */
+#ifdef CSR_LOG_ENABLE
+#define CSR_LOG_TEXT_ASSERT(origin, suborigin, condition) \
+ {if (!(condition)) {CSR_LOG_TEXT_CRITICAL((origin, suborigin, "Assertion \"%s\" failed at %s:%u", #condition, __FILE__, __LINE__));}}
+#else
+#define CSR_LOG_TEXT_ASSERT(origin, suborigin, condition)
+#endif
+
+/* CSR_LOG_TEXT_UNHANDLED_PRIM (CRITICAL) */
+#ifdef CSR_LOG_ENABLE
+#define CSR_LOG_TEXT_UNHANDLED_PRIMITIVE(origin, suborigin, primClass, primType) \
+ CSR_LOG_TEXT_CRITICAL((origin, suborigin, "Unhandled primitive 0x%04X:0x%04X at %s:%u", primClass, primType, __FILE__, __LINE__))
+#else
+#define CSR_LOG_TEXT_UNHANDLED_PRIMITIVE(origin, suborigin, primClass, primType)
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/drivers/staging/csr/csr_macro.h b/drivers/staging/csr/csr_macro.h
new file mode 100644
index 000000000000..57cbfcb0619b
--- /dev/null
+++ b/drivers/staging/csr/csr_macro.h
@@ -0,0 +1,114 @@
+#ifndef CSR_MACRO_H__
+#define CSR_MACRO_H__
+/*****************************************************************************
+
+ (c) Cambridge Silicon Radio Limited 2010
+ All rights reserved and confidential information of CSR
+
+ Refer to LICENSE.txt included with this source for details
+ on the license terms.
+
+*****************************************************************************/
+
+#include <linux/types.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define FALSE (0)
+#define TRUE (1)
+
+/*------------------------------------------------------------------*/
+/* Bits - intended to operate on u32 values */
+/*------------------------------------------------------------------*/
+#define CSR_MASK_IS_SET(val, mask) (((val) & (mask)) == (mask))
+#define CSR_MASK_IS_UNSET(val, mask) ((((val) & (mask)) ^ mask) == (mask))
+#define CSR_MASK_SET(val, mask) ((val) |= (mask))
+#define CSR_MASK_UNSET(val, mask) ((val) = ((val) ^ (mask)) & (val)) /* Unsets the bits in val that are set in mask */
+#define CSR_BIT_IS_SET(val, bit) ((u8) ((((val) & (1UL << (bit))) != 0)))
+#define CSR_BIT_SET(val, bit) ((val) |= (1UL << (bit)))
+#define CSR_BIT_UNSET(val, bit) ((val) &= ~(1UL << (bit)))
+#define CSR_BIT_TOGGLE(val, bit) ((val) ^= (1UL << (bit)))
+
+/*------------------------------------------------------------------*/
+/* Endian conversion */
+/*------------------------------------------------------------------*/
+#define CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr) (((u16) ((u8 *) (ptr))[0]) | ((u16) ((u8 *) (ptr))[1]) << 8)
+#define CSR_GET_UINT32_FROM_LITTLE_ENDIAN(ptr) (((u32) ((u8 *) (ptr))[0]) | ((u32) ((u8 *) (ptr))[1]) << 8 | \
+ ((u32) ((u8 *) (ptr))[2]) << 16 | ((u32) ((u8 *) (ptr))[3]) << 24)
+#define CSR_COPY_UINT16_TO_LITTLE_ENDIAN(uint, ptr) ((u8 *) (ptr))[0] = ((u8) ((uint) & 0x00FF)); \
+ ((u8 *) (ptr))[1] = ((u8) ((uint) >> 8))
+#define CSR_COPY_UINT32_TO_LITTLE_ENDIAN(uint, ptr) ((u8 *) (ptr))[0] = ((u8) ((uint) & 0x000000FF)); \
+ ((u8 *) (ptr))[1] = ((u8) (((uint) >> 8) & 0x000000FF)); \
+ ((u8 *) (ptr))[2] = ((u8) (((uint) >> 16) & 0x000000FF)); \
+ ((u8 *) (ptr))[3] = ((u8) (((uint) >> 24) & 0x000000FF))
+#define CSR_GET_UINT16_FROM_BIG_ENDIAN(ptr) (((u16) ((u8 *) (ptr))[1]) | ((u16) ((u8 *) (ptr))[0]) << 8)
+#define CSR_GET_UINT24_FROM_BIG_ENDIAN(ptr) (((u32) ((u8 *) (ptr))[2]) | \
+ ((u32) ((u8 *) (ptr))[1]) << 8 | ((u32) ((u8 *) (ptr))[0]) << 16)
+#define CSR_GET_UINT32_FROM_BIG_ENDIAN(ptr) (((u32) ((u8 *) (ptr))[3]) | ((u32) ((u8 *) (ptr))[2]) << 8 | \
+ ((u32) ((u8 *) (ptr))[1]) << 16 | ((u32) ((u8 *) (ptr))[0]) << 24)
+#define CSR_COPY_UINT16_TO_BIG_ENDIAN(uint, ptr) ((u8 *) (ptr))[1] = ((u8) ((uint) & 0x00FF)); \
+ ((u8 *) (ptr))[0] = ((u8) ((uint) >> 8))
+#define CSR_COPY_UINT24_TO_BIG_ENDIAN(uint, ptr) ((u8 *) (ptr))[2] = ((u8) ((uint) & 0x000000FF)); \
+ ((u8 *) (ptr))[1] = ((u8) (((uint) >> 8) & 0x000000FF)); \
+ ((u8 *) (ptr))[0] = ((u8) (((uint) >> 16) & 0x000000FF))
+#define CSR_COPY_UINT32_TO_BIG_ENDIAN(uint, ptr) ((u8 *) (ptr))[3] = ((u8) ((uint) & 0x000000FF)); \
+ ((u8 *) (ptr))[2] = ((u8) (((uint) >> 8) & 0x000000FF)); \
+ ((u8 *) (ptr))[1] = ((u8) (((uint) >> 16) & 0x000000FF)); \
+ ((u8 *) (ptr))[0] = ((u8) (((uint) >> 24) & 0x000000FF))
+
+/*------------------------------------------------------------------*/
+/* XAP conversion macros */
+/*------------------------------------------------------------------*/
+
+#define CSR_LSB16(a) ((u8) ((a) & 0x00ff))
+#define CSR_MSB16(b) ((u8) ((b) >> 8))
+
+#define CSR_CONVERT_8_FROM_XAP(output, input) \
+ (output) = ((u8) (input));(input) += 2
+
+#define CSR_CONVERT_16_FROM_XAP(output, input) \
+ (output) = (u16) ((((u16) (input)[1]) << 8) | \
+ ((u16) (input)[0]));(input) += 2
+
+#define CSR_CONVERT_32_FROM_XAP(output, input) \
+ (output) = (((u32) (input)[1]) << 24) | \
+ (((u32) (input)[0]) << 16) | \
+ (((u32) (input)[3]) << 8) | \
+ ((u32) (input)[2]);input += 4
+
+#define CSR_ADD_UINT8_TO_XAP(output, input) \
+ (output)[0] = (input); \
+ (output)[1] = 0;(output) += 2
+
+#define CSR_ADD_UINT16_TO_XAP(output, input) \
+ (output)[0] = ((u8) ((input) & 0x00FF)); \
+ (output)[1] = ((u8) ((input) >> 8));(output) += 2
+
+#define CSR_ADD_UINT32_TO_XAP(output, input) \
+ (output)[0] = ((u8) (((input) >> 16) & 0x00FF)); \
+ (output)[1] = ((u8) ((input) >> 24)); \
+ (output)[2] = ((u8) ((input) & 0x00FF)); \
+ (output)[3] = ((u8) (((input) >> 8) & 0x00FF));(output) += 4
+
+/*------------------------------------------------------------------*/
+/* Misc */
+/*------------------------------------------------------------------*/
+#define CSRMAX(a, b) (((a) > (b)) ? (a) : (b))
+#define CSRMIN(a, b) (((a) < (b)) ? (a) : (b))
+
+/* Use this macro on unused local variables that cannot be removed (such as
+ unused function parameters). This will quell warnings from certain compilers
+ and static code analysis tools like Lint and Valgrind. */
+#define CSR_UNUSED(x) ((void) (x))
+
+#define CSR_TOUPPER(character) (((character) >= 'a') && ((character) <= 'z') ? ((character) - 0x20) : (character))
+#define CSR_TOLOWER(character) (((character) >= 'A') && ((character) <= 'Z') ? ((character) + 0x20) : (character))
+#define CSR_ARRAY_SIZE(x) (sizeof(x) / sizeof(*(x)))
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/drivers/staging/csr/csr_msg_transport.h b/drivers/staging/csr/csr_msg_transport.h
new file mode 100644
index 000000000000..b0095b023817
--- /dev/null
+++ b/drivers/staging/csr/csr_msg_transport.h
@@ -0,0 +1,25 @@
+#ifndef CSR_MSG_TRANSPORT_H__
+#define CSR_MSG_TRANSPORT_H__
+/*****************************************************************************
+
+ (c) Cambridge Silicon Radio Limited 2010
+ All rights reserved and confidential information of CSR
+
+ Refer to LICENSE.txt included with this source for details
+ on the license terms.
+
+*****************************************************************************/
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef CsrMsgTransport
+#define CsrMsgTransport CsrSchedMessagePut
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* CSR_MSG_TRANSPORT */
diff --git a/drivers/staging/csr/csr_msgconv.c b/drivers/staging/csr/csr_msgconv.c
new file mode 100644
index 000000000000..0081a255e91c
--- /dev/null
+++ b/drivers/staging/csr/csr_msgconv.c
@@ -0,0 +1,292 @@
+/*****************************************************************************
+
+ (c) Cambridge Silicon Radio Limited 2010
+ All rights reserved and confidential information of CSR
+
+ Refer to LICENSE.txt included with this source for details
+ on the license terms.
+
+*****************************************************************************/
+
+#include <linux/module.h>
+#include <linux/types.h>
+#include <linux/slab.h>
+#include "csr_panic.h"
+#include "csr_sched.h"
+#include "csr_msgconv.h"
+#include "csr_macro.h"
+
+static CsrMsgConvEntry *converter;
+
+CsrMsgConvPrimEntry *CsrMsgConvFind(u16 primType)
+{
+ CsrMsgConvPrimEntry *ptr = NULL;
+
+ if (converter)
+ {
+ ptr = converter->profile_converters;
+ while (ptr)
+ {
+ if (ptr->primType == primType)
+ {
+ break;
+ }
+ else
+ {
+ ptr = ptr->next;
+ }
+ }
+ }
+
+ return ptr;
+}
+
+static const CsrMsgConvMsgEntry *find_msg_converter(CsrMsgConvPrimEntry *ptr, u16 msgType)
+{
+ const CsrMsgConvMsgEntry *cv = ptr->conv;
+ if (ptr->lookupFunc)
+ {
+ return (const CsrMsgConvMsgEntry *) ptr->lookupFunc((CsrMsgConvMsgEntry *) cv, msgType);
+ }
+
+ while (cv)
+ {
+ if (cv->serFunc == NULL)
+ {
+ /* We've reached the end of the chain */
+ cv = NULL;
+ break;
+ }
+
+ if (cv->msgType == msgType)
+ {
+ break;
+ }
+ else
+ {
+ cv++;
+ }
+ }
+
+ return cv;
+}
+
+static void *deserialize_data(u16 primType,
+ size_t length,
+ u8 *data)
+{
+ CsrMsgConvPrimEntry *ptr;
+ u8 *ret;
+
+ ptr = CsrMsgConvFind(primType);
+
+ if (ptr)
+ {
+ const CsrMsgConvMsgEntry *cv;
+ u16 msgId = 0;
+ size_t offset = 0;
+ CsrUint16Des(&msgId, data, &offset);
+
+ cv = find_msg_converter(ptr, msgId);
+ if (cv)
+ {
+ ret = cv->deserFunc(data, length);
+ }
+ else
+ {
+ ret = NULL;
+ }
+ }
+ else
+ {
+ ret = NULL;
+ }
+
+ return ret;
+}
+
+static size_t sizeof_message(u16 primType, void *msg)
+{
+ CsrMsgConvPrimEntry *ptr = CsrMsgConvFind(primType);
+ size_t ret;
+
+ if (ptr)
+ {
+ const CsrMsgConvMsgEntry *cv;
+ u16 msgId = *(u16 *) msg;
+
+ cv = find_msg_converter(ptr, msgId);
+ if (cv)
+ {
+ ret = cv->sizeofFunc(msg);
+ }
+ else
+ {
+ ret = 0;
+ }
+ }
+ else
+ {
+ ret = 0;
+ }
+
+ return ret;
+}
+
+static u8 free_message(u16 primType, u8 *data)
+{
+ CsrMsgConvPrimEntry *ptr;
+ u8 ret;
+
+ ptr = CsrMsgConvFind(primType);
+
+ if (ptr)
+ {
+ const CsrMsgConvMsgEntry *cv;
+ u16 msgId = *(u16 *) data;
+
+ cv = find_msg_converter(ptr, msgId);
+ if (cv)
+ {
+ cv->freeFunc(data);
+ ret = TRUE;
+ }
+ else
+ {
+ ret = FALSE;
+ }
+ }
+ else
+ {
+ ret = FALSE;
+ }
+
+ return ret;
+}
+
+static u8 *serialize_message(u16 primType,
+ void *msg,
+ size_t *length,
+ u8 *buffer)
+{
+ CsrMsgConvPrimEntry *ptr;
+ u8 *ret;
+
+ ptr = CsrMsgConvFind(primType);
+
+ *length = 0;
+
+ if (ptr)
+ {
+ const CsrMsgConvMsgEntry *cv;
+
+ cv = find_msg_converter(ptr, *(u16 *) msg);
+ if (cv)
+ {
+ ret = cv->serFunc(buffer, length, msg);
+ }
+ else
+ {
+ ret = NULL;
+ }
+ }
+ else
+ {
+ ret = NULL;
+ }
+
+ return ret;
+}
+
+size_t CsrMsgConvSizeof(u16 primType, void *msg)
+{
+ return sizeof_message(primType, msg);
+}
+
+u8 *CsrMsgConvSerialize(u8 *buffer, size_t maxBufferOffset, size_t *offset, u16 primType, void *msg)
+{
+ if (converter)
+ {
+ size_t serializedLength;
+ u8 *bufSerialized;
+ u8 *bufOffset = &buffer[*offset];
+ bufSerialized = converter->serialize_message(primType, msg, &serializedLength, bufOffset);
+ *offset += serializedLength;
+ return bufSerialized;
+ }
+ else
+ {
+ return NULL;
+ }
+}
+
+/* Insert profile converter at head of converter list. */
+void CsrMsgConvInsert(u16 primType, const CsrMsgConvMsgEntry *ce)
+{
+ CsrMsgConvPrimEntry *pc;
+ pc = CsrMsgConvFind(primType);
+
+ if (pc)
+ {
+ /* Already registered. Do nothing */
+ }
+ else
+ {
+ pc = kmalloc(sizeof(*pc), GFP_KERNEL);
+ pc->primType = primType;
+ pc->conv = ce;
+ pc->lookupFunc = NULL;
+ pc->next = converter->profile_converters;
+ converter->profile_converters = pc;
+ }
+}
+EXPORT_SYMBOL_GPL(CsrMsgConvInsert);
+
+CsrMsgConvMsgEntry *CsrMsgConvFindEntry(u16 primType, u16 msgType)
+{
+ CsrMsgConvPrimEntry *ptr = CsrMsgConvFind(primType);
+ if (ptr)
+ {
+ return (CsrMsgConvMsgEntry *) find_msg_converter(ptr, msgType);
+ }
+ return NULL;
+}
+EXPORT_SYMBOL_GPL(CsrMsgConvFindEntry);
+
+CsrMsgConvMsgEntry *CsrMsgConvFindEntryByMsg(u16 primType, const void *msg)
+{
+ CsrMsgConvPrimEntry *ptr = CsrMsgConvFind(primType);
+ if (ptr && msg)
+ {
+ u16 msgType = *((u16 *) msg);
+ return (CsrMsgConvMsgEntry *) find_msg_converter(ptr, msgType);
+ }
+ return NULL;
+}
+
+void CsrMsgConvCustomLookupRegister(u16 primType, CsrMsgCustomLookupFunc *lookupFunc)
+{
+ CsrMsgConvPrimEntry *ptr = CsrMsgConvFind(primType);
+ if (ptr)
+ {
+ ptr->lookupFunc = lookupFunc;
+ }
+}
+EXPORT_SYMBOL_GPL(CsrMsgConvCustomLookupRegister);
+
+CsrMsgConvEntry *CsrMsgConvInit(void)
+{
+ if (!converter)
+ {
+ converter = kmalloc(sizeof(CsrMsgConvEntry), GFP_KERNEL);
+
+ converter->profile_converters = NULL;
+ converter->free_message = free_message;
+ converter->sizeof_message = sizeof_message;
+ converter->serialize_message = serialize_message;
+ converter->deserialize_data = deserialize_data;
+ }
+
+ return converter;
+}
+EXPORT_SYMBOL_GPL(CsrMsgConvInit);
diff --git a/drivers/staging/csr/csr_msgconv.h b/drivers/staging/csr/csr_msgconv.h
new file mode 100644
index 000000000000..09489f38e52d
--- /dev/null
+++ b/drivers/staging/csr/csr_msgconv.h
@@ -0,0 +1,87 @@
+#ifndef CSR_MSGCONV_H__
+#define CSR_MSGCONV_H__
+
+/*****************************************************************************
+
+ (c) Cambridge Silicon Radio Limited 2010
+ All rights reserved and confidential information of CSR
+
+ Refer to LICENSE.txt included with this source for details
+ on the license terms.
+
+*****************************************************************************/
+
+#include <linux/types.h>
+#include "csr_prim_defs.h"
+#include "csr_sched.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef size_t (CsrMsgSizeofFunc)(void *msg);
+typedef u8 *(CsrMsgSerializeFunc)(u8 *buffer, size_t *length, void *msg);
+typedef void (CsrMsgFreeFunc)(void *msg);
+typedef void *(CsrMsgDeserializeFunc)(u8 *buffer, size_t length);
+
+/* Converter entry for one message type */
+typedef struct CsrMsgConvMsgEntry
+{
+ u16 msgType;
+ CsrMsgSizeofFunc *sizeofFunc;
+ CsrMsgSerializeFunc *serFunc;
+ CsrMsgDeserializeFunc *deserFunc;
+ CsrMsgFreeFunc *freeFunc;
+} CsrMsgConvMsgEntry;
+
+/* Optional lookup function */
+typedef CsrMsgConvMsgEntry *(CsrMsgCustomLookupFunc)(CsrMsgConvMsgEntry *ce, u16 msgType);
+
+/* All converter entries for one specific primitive */
+typedef struct CsrMsgConvPrimEntry
+{
+ u16 primType;
+ const CsrMsgConvMsgEntry *conv;
+ CsrMsgCustomLookupFunc *lookupFunc;
+ struct CsrMsgConvPrimEntry *next;
+} CsrMsgConvPrimEntry;
+
+typedef struct
+{
+ CsrMsgConvPrimEntry *profile_converters;
+ void *(*deserialize_data)(u16 primType, size_t length, u8 * data);
+ u8 (*free_message)(u16 primType, u8 *data);
+ size_t (*sizeof_message)(u16 primType, void *msg);
+ u8 *(*serialize_message)(u16 primType, void *msg,
+ size_t * length,
+ u8 * buffer);
+} CsrMsgConvEntry;
+
+size_t CsrMsgConvSizeof(u16 primType, void *msg);
+u8 *CsrMsgConvSerialize(u8 *buffer, size_t maxBufferOffset, size_t *offset, u16 primType, void *msg);
+void CsrMsgConvCustomLookupRegister(u16 primType, CsrMsgCustomLookupFunc *lookupFunc);
+void CsrMsgConvInsert(u16 primType, const CsrMsgConvMsgEntry *ce);
+CsrMsgConvPrimEntry *CsrMsgConvFind(u16 primType);
+CsrMsgConvMsgEntry *CsrMsgConvFindEntry(u16 primType, u16 msgType);
+CsrMsgConvMsgEntry *CsrMsgConvFindEntryByMsg(u16 primType, const void *msg);
+CsrMsgConvEntry *CsrMsgConvInit(void);
+
+/* Prototypes for primitive type serializers */
+void CsrUint8Ser(u8 *buffer, size_t *offset, u8 value);
+void CsrUint16Ser(u8 *buffer, size_t *offset, u16 value);
+void CsrUint32Ser(u8 *buffer, size_t *offset, u32 value);
+void CsrMemCpySer(u8 *buffer, size_t *offset, const void *value, size_t length);
+void CsrCharStringSer(u8 *buffer, size_t *offset, const char *value);
+
+void CsrUint8Des(u8 *value, u8 *buffer, size_t *offset);
+void CsrUint16Des(u16 *value, u8 *buffer, size_t *offset);
+void CsrUint32Des(u32 *value, u8 *buffer, size_t *offset);
+void CsrMemCpyDes(void *value, u8 *buffer, size_t *offset, size_t length);
+void CsrCharStringDes(char **value, u8 *buffer, size_t *offset);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/drivers/staging/csr/csr_panic.c b/drivers/staging/csr/csr_panic.c
new file mode 100644
index 000000000000..353a829bb74c
--- /dev/null
+++ b/drivers/staging/csr/csr_panic.c
@@ -0,0 +1,21 @@
+/*****************************************************************************
+
+ (c) Cambridge Silicon Radio Limited 2010
+ All rights reserved and confidential information of CSR
+
+ Refer to LICENSE.txt included with this source for details
+ on the license terms.
+
+*****************************************************************************/
+
+#include <linux/kernel.h>
+#include <linux/version.h>
+#include <linux/module.h>
+
+#include "csr_panic.h"
+
+void CsrPanic(u8 tech, u16 reason, const char *p)
+{
+ BUG_ON(1);
+}
+EXPORT_SYMBOL_GPL(CsrPanic);
diff --git a/drivers/staging/csr/csr_panic.h b/drivers/staging/csr/csr_panic.h
new file mode 100644
index 000000000000..37989fc15bbe
--- /dev/null
+++ b/drivers/staging/csr/csr_panic.h
@@ -0,0 +1,53 @@
+#ifndef CSR_PANIC_H__
+#define CSR_PANIC_H__
+/*****************************************************************************
+
+ (c) Cambridge Silicon Radio Limited 2010
+ All rights reserved and confidential information of CSR
+
+ Refer to LICENSE.txt included with this source for details
+ on the license terms.
+
+*****************************************************************************/
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Synergy techonology ID definitions */
+#define CSR_TECH_FW 0
+#define CSR_TECH_BT 1
+#define CSR_TECH_WIFI 2
+#define CSR_TECH_GPS 3
+#define CSR_TECH_NFC 4
+
+/* Panic type ID definitions for technology type CSR_TECH_FW */
+#define CSR_PANIC_FW_UNEXPECTED_VALUE 0
+#define CSR_PANIC_FW_HEAP_EXHAUSTION 1
+#define CSR_PANIC_FW_INVALID_PFREE_POINTER 2
+#define CSR_PANIC_FW_EXCEPTION 3
+#define CSR_PANIC_FW_ASSERTION_FAIL 4
+#define CSR_PANIC_FW_NULL_TASK_HANDLER 5
+#define CSR_PANIC_FW_UNKNOWN_TASK 6
+#define CSR_PANIC_FW_QUEUE_ACCESS_VIOLATION 7
+#define CSR_PANIC_FW_TOO_MANY_MESSAGES 8
+#define CSR_PANIC_FW_TOO_MANY_TIMED_EVENTS 9
+#define CSR_PANIC_FW_ABCSP_SYNC_LOST 10
+#define CSR_PANIC_FW_OVERSIZE_ABCSP_PRIM 11
+#define CSR_PANIC_FW_H4_CORRUPTION 12
+#define CSR_PANIC_FW_H4_SYNC_LOST 13
+#define CSR_PANIC_FW_H4_RX_OVERRUN 14
+#define CSR_PANIC_FW_H4_TX_OVERRUN 15
+#define CSR_PANIC_FW_TM_BC_RESTART_FAIL 16
+#define CSR_PANIC_FW_TM_BC_START_FAIL 17
+#define CSR_PANIC_FW_TM_BC_BAD_STATE 18
+#define CSR_PANIC_FW_TM_BC_TRANSPORT_LOST 19
+
+/* Panic interface used by technologies */
+/* DEPRECATED - replaced by csr_log_text.h */
+void CsrPanic(u8 tech, u16 reason, const char *p);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* CSR_PANIC_H__ */
diff --git a/drivers/staging/csr/csr_prim_defs.h b/drivers/staging/csr/csr_prim_defs.h
new file mode 100644
index 000000000000..6a7f73dbb706
--- /dev/null
+++ b/drivers/staging/csr/csr_prim_defs.h
@@ -0,0 +1,62 @@
+#ifndef CSR_PRIM_DEFS_H__
+#define CSR_PRIM_DEFS_H__
+/*****************************************************************************
+
+ (c) Cambridge Silicon Radio Limited 2010
+ All rights reserved and confidential information of CSR
+
+ Refer to LICENSE.txt included with this source for details
+ on the license terms.
+
+*****************************************************************************/
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/************************************************************************************
+ * Segmentation of primitives in upstream and downstream segment
+ ************************************************************************************/
+typedef u16 CsrPrim;
+#define CSR_PRIM_UPSTREAM ((CsrPrim) (0x8000))
+
+/************************************************************************************
+ * Primitive definitions for Synergy framework
+ ************************************************************************************/
+#define CSR_SYNERGY_EVENT_CLASS_BASE ((u16) (0x0600))
+
+#define CSR_HCI_PRIM ((u16) (0x0000 | CSR_SYNERGY_EVENT_CLASS_BASE))
+#define CSR_BCCMD_PRIM ((u16) (0x0001 | CSR_SYNERGY_EVENT_CLASS_BASE))
+#define CSR_HQ_PRIM ((u16) (0x0002 | CSR_SYNERGY_EVENT_CLASS_BASE))
+#define CSR_VM_PRIM ((u16) (0x0003 | CSR_SYNERGY_EVENT_CLASS_BASE))
+#define CSR_TM_BLUECORE_PRIM ((u16) (0x0004 | CSR_SYNERGY_EVENT_CLASS_BASE))
+#define CSR_FP_PRIM ((u16) (0x0005 | CSR_SYNERGY_EVENT_CLASS_BASE))
+#define CSR_IP_SOCKET_PRIM ((u16) (0x0006 | CSR_SYNERGY_EVENT_CLASS_BASE))
+#define CSR_IP_ETHER_PRIM ((u16) (0x0007 | CSR_SYNERGY_EVENT_CLASS_BASE))
+#define CSR_IP_IFCONFIG_PRIM ((u16) (0x0008 | CSR_SYNERGY_EVENT_CLASS_BASE))
+#define CSR_IP_INTERNAL_PRIM ((u16) (0x0009 | CSR_SYNERGY_EVENT_CLASS_BASE))
+#define CSR_FSAL_PRIM ((u16) (0x000A | CSR_SYNERGY_EVENT_CLASS_BASE))
+#define CSR_DATA_STORE_PRIM ((u16) (0x000B | CSR_SYNERGY_EVENT_CLASS_BASE))
+#define CSR_AM_PRIM ((u16) (0x000C | CSR_SYNERGY_EVENT_CLASS_BASE))
+#define CSR_TLS_PRIM ((u16) (0x000D | CSR_SYNERGY_EVENT_CLASS_BASE))
+#define CSR_DHCP_SERVER_PRIM ((u16) (0x000E | CSR_SYNERGY_EVENT_CLASS_BASE))
+#define CSR_TFTP_PRIM ((u16) (0x000F | CSR_SYNERGY_EVENT_CLASS_BASE))
+#define CSR_DSPM_PRIM ((u16) (0x0010 | CSR_SYNERGY_EVENT_CLASS_BASE))
+#define CSR_TLS_INTERNAL_PRIM ((u16) (0x0011 | CSR_SYNERGY_EVENT_CLASS_BASE))
+
+#define NUMBER_OF_CSR_FW_EVENTS (CSR_DSPM_PRIM - CSR_SYNERGY_EVENT_CLASS_BASE + 1)
+
+#define CSR_SYNERGY_EVENT_CLASS_MISC_BASE ((u16) (0x06A0))
+
+#define CSR_UI_PRIM ((u16) (0x0000 | CSR_SYNERGY_EVENT_CLASS_MISC_BASE))
+#define CSR_APP_PRIM ((u16) (0x0001 | CSR_SYNERGY_EVENT_CLASS_MISC_BASE))
+#define CSR_SDIO_PROBE_PRIM ((u16) (0x0002 | CSR_SYNERGY_EVENT_CLASS_MISC_BASE))
+
+#define NUMBER_OF_CSR_FW_MISC_EVENTS (CSR_SDIO_PROBE_PRIM - CSR_SYNERGY_EVENT_CLASS_MISC_BASE + 1)
+
+#define CSR_ENV_PRIM ((u16) (0x00FF | CSR_SYNERGY_EVENT_CLASS_MISC_BASE))
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* CSR_PRIM_DEFS_H__ */
diff --git a/drivers/staging/csr/csr_result.h b/drivers/staging/csr/csr_result.h
new file mode 100644
index 000000000000..c7c36d6b59ef
--- /dev/null
+++ b/drivers/staging/csr/csr_result.h
@@ -0,0 +1,25 @@
+#ifndef CSR_RESULT_H__
+#define CSR_RESULT_H__
+/*****************************************************************************
+
+ (c) Cambridge Silicon Radio Limited 2010
+ All rights reserved and confidential information of CSR
+
+ Refer to LICENSE.txt included with this source for details
+ on the license terms.
+
+*****************************************************************************/
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef u16 CsrResult;
+#define CSR_RESULT_SUCCESS ((CsrResult) 0x0000)
+#define CSR_RESULT_FAILURE ((CsrResult) 0xFFFF)
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/drivers/staging/csr/csr_sched.h b/drivers/staging/csr/csr_sched.h
new file mode 100644
index 000000000000..cc1b8bf66079
--- /dev/null
+++ b/drivers/staging/csr/csr_sched.h
@@ -0,0 +1,292 @@
+#ifndef CSR_SCHED_H__
+#define CSR_SCHED_H__
+/*****************************************************************************
+
+ (c) Cambridge Silicon Radio Limited 2010
+ All rights reserved and confidential information of CSR
+
+ Refer to LICENSE.txt included with this source for details
+ on the license terms.
+
+*****************************************************************************/
+#include <linux/types.h>
+#include "csr_time.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* An identifier issued by the scheduler. */
+typedef u32 CsrSchedIdentifier;
+
+/* A task identifier */
+typedef u16 CsrSchedTaskId;
+
+/* A queue identifier */
+typedef u16 CsrSchedQid;
+#define CSR_SCHED_QID_INVALID ((CsrSchedQid) 0xFFFF)
+
+/* A message identifier */
+typedef CsrSchedIdentifier CsrSchedMsgId;
+
+/* A timer event identifier */
+typedef CsrSchedIdentifier CsrSchedTid;
+#define CSR_SCHED_TID_INVALID ((CsrSchedTid) 0)
+
+/* Scheduler entry functions share this structure */
+typedef void (*schedEntryFunction_t)(void **inst);
+
+/* Time constants. */
+#define CSR_SCHED_TIME_MAX ((CsrTime) 0xFFFFFFFF)
+#define CSR_SCHED_MILLISECOND ((CsrTime) (1000))
+#define CSR_SCHED_SECOND ((CsrTime) (1000 * CSR_SCHED_MILLISECOND))
+#define CSR_SCHED_MINUTE ((CsrTime) (60 * CSR_SCHED_SECOND))
+
+/* Queue and primitive that identifies the environment */
+#define CSR_SCHED_TASK_ID 0xFFFF
+#define CSR_SCHED_PRIM (CSR_SCHED_TASK_ID)
+#define CSR_SCHED_EXCLUDED_MODULE_QUEUE 0xFFFF
+
+/*
+ * Background interrupt definitions
+ */
+typedef u16 CsrSchedBgint;
+#define CSR_SCHED_BGINT_INVALID ((CsrSchedBgint) 0xFFFF)
+
+typedef void (*CsrSchedBgintHandler)(void *);
+
+/*----------------------------------------------------------------------------*
+ * NAME
+ * CsrSchedBgintReg
+ *
+ * DESCRIPTION
+ * Register a background interrupt handler function with the scheduler.
+ * When CsrSchedBgint() is called from the foreground (e.g. an interrupt
+ * routine) the registered function is called.
+ *
+ * If "cb" is null then the interrupt is effectively disabled. If a
+ * no bgints are available, CSR_SCHED_BGINT_INVALID is returned, otherwise
+ * a CsrSchedBgint value is returned to be used in subsequent calls to
+ * CsrSchedBgint(). id is a possibly NULL identifier used for logging
+ * purposes only.
+ *
+ * RETURNS
+ * CsrSchedBgint -- CSR_SCHED_BGINT_INVALID denotes failure to obtain a CsrSchedBgintSet.
+ *
+ *----------------------------------------------------------------------------*/
+CsrSchedBgint CsrSchedBgintReg(CsrSchedBgintHandler cb,
+ void *context,
+ const char *id);
+
+/*----------------------------------------------------------------------------*
+ * NAME
+ * CsrSchedBgintUnreg
+ *
+ * DESCRIPTION
+ * Unregister a background interrupt handler function.
+ *
+ * ``irq'' is a background interrupt handle previously obtained
+ * from a call to CsrSchedBgintReg().
+ *
+ * RETURNS
+ * void.
+ *
+ *----------------------------------------------------------------------------*/
+void CsrSchedBgintUnreg(CsrSchedBgint bgint);
+
+/*----------------------------------------------------------------------------*
+ * NAME
+ * CsrSchedBgintSet
+ *
+ * DESCRIPTION
+ * Set background interrupt.
+ *
+ * RETURNS
+ * void.
+ *
+ *----------------------------------------------------------------------------*/
+void CsrSchedBgintSet(CsrSchedBgint bgint);
+
+/*----------------------------------------------------------------------------*
+ * NAME
+ * CsrSchedMessagePut
+ *
+ * DESCRIPTION
+ * Sends a message consisting of the integer "mi" and the void * pointer
+ * "mv" to the message queue "q".
+ *
+ * "mi" and "mv" are neither inspected nor changed by the scheduler - the
+ * task that owns "q" is expected to make sense of the values. "mv" may
+ * be null.
+ *
+ * NOTE
+ * If "mv" is not null then it will typically be a chunk of kmalloc()ed
+ * memory, though there is no need for it to be so. Tasks should normally
+ * obey the convention that when a message built with kmalloc()ed memory
+ * is given to CsrSchedMessagePut() then ownership of the memory is ceded to the
+ * scheduler - and eventually to the recipient task. I.e., the receiver of
+ * the message will be expected to kfree() the message storage.
+ *
+ * RETURNS
+ * void.
+ *
+ *----------------------------------------------------------------------------*/
+#if defined(CSR_LOG_ENABLE) && defined(CSR_LOG_INCLUDE_FILE_NAME_AND_LINE_NUMBER)
+void CsrSchedMessagePutStringLog(CsrSchedQid q,
+ u16 mi,
+ void *mv,
+ u32 line,
+ const char *file);
+#define CsrSchedMessagePut(q, mi, mv) CsrSchedMessagePutStringLog((q), (mi), (mv), __LINE__, __FILE__)
+#else
+void CsrSchedMessagePut(CsrSchedQid q,
+ u16 mi,
+ void *mv);
+#endif
+
+/*----------------------------------------------------------------------------*
+ * NAME
+ * CsrSchedMessageBroadcast
+ *
+ * DESCRIPTION
+ * Sends a message to all tasks.
+ *
+ * The user must supply a "factory function" that is called once
+ * for every task that exists. The "factory function", msg_build_func,
+ * must allocate and initialise the message and set the msg_build_ptr
+ * to point to the message when done.
+ *
+ * NOTE
+ * N/A
+ *
+ * RETURNS
+ * void
+ *
+ *----------------------------------------------------------------------------*/
+#if defined(CSR_LOG_ENABLE) && defined(CSR_LOG_INCLUDE_FILE_NAME_AND_LINE_NUMBER)
+void CsrSchedMessageBroadcastStringLog(u16 mi,
+ void *(*msg_build_func)(void *),
+ void *msg_build_ptr,
+ u32 line,
+ const char *file);
+#define CsrSchedMessageBroadcast(mi, fn, ptr) CsrSchedMessageBroadcastStringLog((mi), (fn), (ptr), __LINE__, __FILE__)
+#else
+void CsrSchedMessageBroadcast(u16 mi,
+ void *(*msg_build_func)(void *),
+ void *msg_build_ptr);
+#endif
+
+/*----------------------------------------------------------------------------*
+ * NAME
+ * CsrSchedMessageGet
+ *
+ * DESCRIPTION
+ * Obtains a message from the message queue belonging to the calling task.
+ * The message consists of one or both of a u16 and a void *.
+ *
+ * RETURNS
+ * u8 - TRUE if a message has been obtained from the queue, else FALSE.
+ * If a message is taken from the queue, then "*pmi" and "*pmv" are set to
+ * the "mi" and "mv" passed to CsrSchedMessagePut() respectively.
+ *
+ * "pmi" and "pmv" can be null, in which case the corresponding value from
+ * them message is discarded.
+ *
+ *----------------------------------------------------------------------------*/
+u8 CsrSchedMessageGet(u16 *pmi, void **pmv);
+
+/*----------------------------------------------------------------------------*
+ * NAME
+ * CsrSchedTimerSet
+ *
+ * DESCRIPTION
+ * Causes the void function "fn" to be called with the arguments
+ * "fniarg" and "fnvarg" after "delay" has elapsed.
+ *
+ * "delay" must be less than half the range of a CsrTime.
+ *
+ * CsrSchedTimerSet() does nothing with "fniarg" and "fnvarg" except
+ * deliver them via a call to "fn()". (Unless CsrSchedTimerCancel()
+ * is used to prevent delivery.)
+ *
+ * NOTE
+ * The function will be called at or after "delay"; the actual delay will
+ * depend on the timing behaviour of the scheduler's tasks.
+ *
+ * RETURNS
+ * CsrSchedTid - A timed event identifier, can be used in CsrSchedTimerCancel().
+ *
+ *----------------------------------------------------------------------------*/
+#if defined(CSR_LOG_ENABLE) && defined(CSR_LOG_INCLUDE_FILE_NAME_AND_LINE_NUMBER)
+CsrSchedTid CsrSchedTimerSetStringLog(CsrTime delay,
+ void (*fn)(u16 mi, void *mv),
+ u16 fniarg,
+ void *fnvarg,
+ u32 line,
+ const char *file);
+#define CsrSchedTimerSet(d, fn, fni, fnv) CsrSchedTimerSetStringLog((d), (fn), (fni), (fnv), __LINE__, __FILE__)
+#else
+CsrSchedTid CsrSchedTimerSet(CsrTime delay,
+ void (*fn)(u16 mi, void *mv),
+ u16 fniarg,
+ void *fnvarg);
+#endif
+
+/*----------------------------------------------------------------------------*
+ * NAME
+ * CsrSchedTimerCancel
+ *
+ * DESCRIPTION
+ * Attempts to prevent the timed event with identifier "eventid" from
+ * occurring.
+ *
+ * RETURNS
+ * u8 - TRUE if cancelled, FALSE if the event has already occurred.
+ *
+ *----------------------------------------------------------------------------*/
+#if defined(CSR_LOG_ENABLE) && defined(CSR_LOG_INCLUDE_FILE_NAME_AND_LINE_NUMBER)
+u8 CsrSchedTimerCancelStringLog(CsrSchedTid eventid,
+ u16 *pmi,
+ void **pmv,
+ u32 line,
+ const char *file);
+#define CsrSchedTimerCancel(e, pmi, pmv) CsrSchedTimerCancelStringLog((e), (pmi), (pmv), __LINE__, __FILE__)
+#else
+u8 CsrSchedTimerCancel(CsrSchedTid eventid,
+ u16 *pmi,
+ void **pmv);
+#endif
+
+/*----------------------------------------------------------------------------*
+ * NAME
+ * CsrSchedTaskQueueGet
+ *
+ * DESCRIPTION
+ * Return the queue identifier for the currently running queue
+ *
+ * RETURNS
+ * CsrSchedQid - The current task queue identifier, or 0xFFFF if not available.
+ *
+ *----------------------------------------------------------------------------*/
+CsrSchedQid CsrSchedTaskQueueGet(void);
+
+
+/*----------------------------------------------------------------------------*
+ * NAME
+ * CsrSchedTaskQueueGet
+ *
+ * DESCRIPTION
+ * Return the queue identifier for the currently running queue
+ *
+ * RETURNS
+ * char - The current task queue identifier, or 0xFFFF if not available.
+ *
+ *----------------------------------------------------------------------------*/
+char* CsrSchedTaskNameGet(CsrSchedQid );
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/drivers/staging/csr/csr_sdio.h b/drivers/staging/csr/csr_sdio.h
new file mode 100644
index 000000000000..f0cda84f6a00
--- /dev/null
+++ b/drivers/staging/csr/csr_sdio.h
@@ -0,0 +1,731 @@
+#ifndef CSR_SDIO_H__
+#define CSR_SDIO_H__
+/*****************************************************************************
+
+ (c) Cambridge Silicon Radio Limited 2010
+ All rights reserved and confidential information of CSR
+
+ Refer to LICENSE.txt included with this source for details
+ on the license terms.
+
+*****************************************************************************/
+
+#include "csr_result.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Result Codes */
+#define CSR_SDIO_RESULT_INVALID_VALUE ((CsrResult) 1) /* Invalid argument value */
+#define CSR_SDIO_RESULT_NO_DEVICE ((CsrResult) 2) /* The specified device is no longer present */
+#define CSR_SDIO_RESULT_CRC_ERROR ((CsrResult) 3) /* The transmitted/received data or command response contained a CRC error */
+#define CSR_SDIO_RESULT_TIMEOUT ((CsrResult) 4) /* No command response or data received from device, or function enable/disable did not succeed within timeout period */
+#define CSR_SDIO_RESULT_NOT_RESET ((CsrResult) 5) /* The device was not reset */
+
+/* Features (for use in features member of CsrSdioFunction) */
+#define CSR_SDIO_FEATURE_BYTE_MODE 0x00000001 /* Transfer sizes do not have to be a multiple of block size */
+#define CSR_SDIO_FEATURE_DMA_CAPABLE_MEM_REQUIRED 0x00000002 /* Bulk operations require DMA friendly memory */
+
+/* CsrSdioFunctionId wildcards (for use in CsrSdioFunctionId members) */
+#define CSR_SDIO_ANY_MANF_ID 0xFFFF
+#define CSR_SDIO_ANY_CARD_ID 0xFFFF
+#define CSR_SDIO_ANY_SDIO_FUNCTION 0xFF
+#define CSR_SDIO_ANY_SDIO_INTERFACE 0xFF
+
+/*----------------------------------------------------------------------------*
+ * NAME
+ * CsrSdioFunctionId
+ *
+ * DESCRIPTION
+ * This structure describes one or more functions of a device, based on
+ * four qualitative measures. The CsrSdioFunctionId wildcard defines can be
+ * used for making the CsrSdioFunctionId match more than one function.
+ *
+ * MEMBERS
+ * manfId - Vendor ID (or CSR_SDIO_ANY_MANF_ID).
+ * cardId - Device ID (or CSR_SDIO_ANY_CARD_ID).
+ * sdioFunction - SDIO Function number (or CSR_SDIO_ANY_SDIO_FUNCTION).
+ * sdioInterface - SDIO Standard Interface Code (or CSR_SDIO_ANY_SDIO_INTERFACE)
+ *
+ *----------------------------------------------------------------------------*/
+typedef struct
+{
+ u16 manfId; /* Vendor ID to match or CSR_SDIO_ANY_MANF_ID */
+ u16 cardId; /* Device ID to match or CSR_SDIO_ANY_CARD_ID */
+ u8 sdioFunction; /* SDIO Function number to match or CSR_SDIO_ANY_SDIO_FUNCTION */
+ u8 sdioInterface; /* SDIO Standard Interface Code to match or CSR_SDIO_ANY_SDIO_INTERFACE */
+} CsrSdioFunctionId;
+
+/*----------------------------------------------------------------------------*
+ * NAME
+ * CsrSdioFunction
+ *
+ * DESCRIPTION
+ * This structure represents a single function on a device.
+ *
+ * MEMBERS
+ * sdioId - A CsrSdioFunctionId describing this particular function. The
+ * subfield shall not contain any CsrSdioFunctionId wildcards. The
+ * subfields shall describe the specific single function
+ * represented by this structure.
+ * blockSize - Actual configured block size, or 0 if unconfigured.
+ * features - Bit mask with any of CSR_SDIO_FEATURE_* set.
+ * device - Handle of device containing the function. If two functions have
+ * the same device handle, they reside on the same device.
+ * driverData - For use by the Function Driver. The SDIO Driver shall not
+ * attempt to dereference the pointer.
+ * priv - For use by the SDIO Driver. The Function Driver shall not attempt
+ * to dereference the pointer.
+ *
+ *
+ *----------------------------------------------------------------------------*/
+typedef struct
+{
+ CsrSdioFunctionId sdioId;
+ u16 blockSize; /* Actual configured block size, or 0 if unconfigured */
+ u32 features; /* Bit mask with any of CSR_SDIO_FEATURE_* set */
+ void *device; /* Handle of device containing the function */
+ void *driverData; /* For use by the Function Driver */
+ void *priv; /* For use by the SDIO Driver */
+} CsrSdioFunction;
+
+/*----------------------------------------------------------------------------*
+ * NAME
+ * CsrSdioInsertedCallback, CsrSdioRemovedCallback
+ *
+ * DESCRIPTION
+ * CsrSdioInsertedCallback is called when a function becomes available to
+ * a registered Function Driver that supports the function.
+ * CsrSdioRemovedCallback is called when a function is no longer available
+ * to a Function Driver, either because the device has been removed, or the
+ * Function Driver has been unregistered.
+ *
+ * NOTE: These functions are implemented by the Function Driver, and are
+ * passed as function pointers in the CsrSdioFunctionDriver struct.
+ *
+ * PARAMETERS
+ * function - Pointer to struct representing the function.
+ *
+ *----------------------------------------------------------------------------*/
+typedef void (*CsrSdioInsertedCallback)(CsrSdioFunction *function);
+typedef void (*CsrSdioRemovedCallback)(CsrSdioFunction *function);
+
+/*----------------------------------------------------------------------------*
+ * NAME
+ * CsrSdioInterruptDsrCallback, CsrSdioInterruptCallback
+ *
+ * DESCRIPTION
+ * CsrSdioInterruptCallback is called when an interrupt occurs on the
+ * the device associated with the specified function.
+ *
+ * NOTE: These functions are implemented by the Function Driver, and are
+ * passed as function pointers in the CsrSdioFunctionDriver struct.
+ *
+ * PARAMETERS
+ * function - Pointer to struct representing the function.
+ *
+ * RETURNS (only CsrSdioInterruptCallback)
+ * A pointer to a CsrSdioInterruptDsrCallback function.
+ *
+ *----------------------------------------------------------------------------*/
+typedef void (*CsrSdioInterruptDsrCallback)(CsrSdioFunction *function);
+typedef CsrSdioInterruptDsrCallback (*CsrSdioInterruptCallback)(CsrSdioFunction *function);
+
+/*----------------------------------------------------------------------------*
+ * NAME
+ * CsrSdioSuspendCallback, CsrSdioResumeCallback
+ *
+ * DESCRIPTION
+ * CsrSdioSuspendCallback is called when the system is preparing to go
+ * into a suspended state. CsrSdioResumeCallback is called when the system
+ * has entered an active state again.
+ *
+ * NOTE: These functions are implemented by the Function Driver, and are
+ * passed as function pointers in the CsrSdioFunctionDriver struct.
+ *
+ * PARAMETERS
+ * function - Pointer to struct representing the function.
+ *
+ *----------------------------------------------------------------------------*/
+typedef void (*CsrSdioSuspendCallback)(CsrSdioFunction *function);
+typedef void (*CsrSdioResumeCallback)(CsrSdioFunction *function);
+
+/*----------------------------------------------------------------------------*
+ * NAME
+ * CsrSdioAsyncCallback, CsrSdioAsyncDsrCallback
+ *
+ * DESCRIPTION
+ * CsrSdioAsyncCallback is called when an asynchronous operation completes.
+ *
+ * NOTE: These functions are implemented by the Function Driver, and are
+ * passed as function pointers in the function calls that initiate
+ * the operation.
+ *
+ * PARAMETERS
+ * function - Pointer to struct representing the function.
+ * result - The result of the operation that completed. See the description
+ * of the initiating function for possible result values.
+ *
+ * RETURNS (only CsrSdioAsyncCallback)
+ * A pointer to a CsrSdioAsyncDsrCallback function.
+ *
+ *----------------------------------------------------------------------------*/
+typedef void (*CsrSdioAsyncDsrCallback)(CsrSdioFunction *function, CsrResult result);
+typedef CsrSdioAsyncDsrCallback (*CsrSdioAsyncCallback)(CsrSdioFunction *function, CsrResult result);
+
+/*----------------------------------------------------------------------------*
+ * NAME
+ * CsrSdioFunctionDriver
+ *
+ * DESCRIPTION
+ * Structure representing a Function Driver.
+ *
+ * MEMBERS
+ * inserted - Callback, see description of CsrSdioInsertedCallback.
+ * removed - Callback, see description of CsrSdioRemovedCallback.
+ * intr - Callback, see description of CsrSdioInterruptCallback.
+ * suspend - Callback, see description of CsrSdioSuspendCallback.
+ * resume - Callback, see description of CsrSdioResumeCallback.
+ * ids - Array of CsrSdioFunctionId describing one or more functions that
+ * are supported by the Function Driver.
+ * idsCount - Length of the ids array.
+ * priv - For use by the SDIO Driver. The Function Driver may initialise
+ * it to NULL, but shall otherwise not access the pointer or attempt
+ * to dereference it.
+ *
+ *----------------------------------------------------------------------------*/
+typedef struct
+{
+ CsrSdioInsertedCallback inserted;
+ CsrSdioRemovedCallback removed;
+ CsrSdioInterruptCallback intr;
+ CsrSdioSuspendCallback suspend;
+ CsrSdioResumeCallback resume;
+ CsrSdioFunctionId *ids;
+ u8 idsCount;
+ void *priv; /* For use by the SDIO Driver */
+} CsrSdioFunctionDriver;
+
+/*----------------------------------------------------------------------------*
+ * NAME
+ * CsrSdioFunctionDriverRegister
+ *
+ * DESCRIPTION
+ * Register a Function Driver.
+ *
+ * PARAMETERS
+ * functionDriver - Pointer to struct describing the Function Driver.
+ *
+ * RETURNS
+ * CSR_RESULT_SUCCESS - The Function Driver was successfully
+ * registered.
+ * CSR_RESULT_FAILURE - Unable to register the function driver,
+ * because of an unspecified/unknown error. The
+ * Function Driver has not been registered.
+ * CSR_SDIO_RESULT_INVALID_VALUE - The specified Function Driver pointer
+ * does not point at a valid Function
+ * Driver structure, or some of the members
+ * contain invalid entries.
+ *
+ *----------------------------------------------------------------------------*/
+CsrResult CsrSdioFunctionDriverRegister(CsrSdioFunctionDriver *functionDriver);
+
+/*----------------------------------------------------------------------------*
+ * NAME
+ * CsrSdioFunctionDriverUnregister
+ *
+ * DESCRIPTION
+ * Unregister a previously registered Function Driver.
+ *
+ * PARAMETERS
+ * functionDriver - pointer to struct describing the Function Driver.
+ *
+ *----------------------------------------------------------------------------*/
+void CsrSdioFunctionDriverUnregister(CsrSdioFunctionDriver *functionDriver);
+
+/*----------------------------------------------------------------------------*
+ * NAME
+ * CsrSdioFunctionEnable, CsrSdioFunctionDisable
+ *
+ * DESCRIPTION
+ * Enable/disable the specified function by setting/clearing the
+ * corresponding bit in the I/O Enable register in function 0, and then
+ * periodically reading the related bit in the I/O Ready register until it
+ * is set/clear, limited by an implementation defined timeout.
+ *
+ * PARAMETERS
+ * function - Pointer to struct representing the function.
+ *
+ * RETURNS
+ * CSR_RESULT_SUCCESS - The specified function was enabled/disabled.
+ * CSR_RESULT_FAILURE - Unspecified/unknown error.
+ * CSR_SDIO_RESULT_NO_DEVICE - The device does not exist anymore.
+ * CSR_SDIO_RESULT_CRC_ERROR - A CRC error occured. The state of the
+ * related bit in the I/O Enable register is
+ * undefined.
+ * CSR_SDIO_RESULT_TIMEOUT - No response from the device, or the related
+ * bit in the I/O ready register was not
+ * set/cleared within the timeout period.
+ *
+ * NOTE: If the SDIO R5 response is available, and either of the
+ * FUNCTION_NUMBER or OUT_OF_RANGE bits are set,
+ * CSR_SDIO_RESULT_INVALID_VALUE shall be returned. If the ERROR bit
+ * is set (but none of FUNCTION_NUMBER or OUT_OF_RANGE),
+ * CSR_RESULT_FAILURE shall be returned. The ILLEGAL_COMMAND and
+ * COM_CRC_ERROR bits shall be ignored.
+ *
+ * If the CSPI response is available, and any of the
+ * FUNCTION_DISABLED or CLOCK_DISABLED bits are set,
+ * CSR_SDIO_RESULT_INVALID_VALUE will be returned.
+ *
+ *----------------------------------------------------------------------------*/
+CsrResult CsrSdioFunctionEnable(CsrSdioFunction *function);
+CsrResult CsrSdioFunctionDisable(CsrSdioFunction *function);
+
+/*----------------------------------------------------------------------------*
+ * NAME
+ * CsrSdioInterruptEnable, CsrSdioInterruptDisable
+ *
+ * DESCRIPTION
+ * Enable/disable the interrupt for the specified function by
+ * setting/clearing the corresponding bit in the INT Enable register in
+ * function 0.
+ *
+ * PARAMETERS
+ * function - Pointer to struct representing the function.
+ *
+ * RETURNS
+ * CSR_RESULT_SUCCESS - The specified function was enabled/disabled.
+ * CSR_RESULT_FAILURE - Unspecified/unknown error.
+ * CSR_SDIO_RESULT_NO_DEVICE - The device does not exist anymore.
+ * CSR_SDIO_RESULT_CRC_ERROR - A CRC error occured. The state of the
+ * related bit in the INT Enable register is
+ * unchanged.
+ * CSR_SDIO_RESULT_INVALID_VALUE - The specified function cannot be
+ * enabled/disabled, because it either
+ * does not exist or it is not possible to
+ * individually enable/disable functions.
+ * CSR_SDIO_RESULT_TIMEOUT - No response from the device.
+ *
+ * NOTE: If the SDIO R5 response is available, and either of the
+ * FUNCTION_NUMBER or OUT_OF_RANGE bits are set,
+ * CSR_SDIO_RESULT_INVALID_VALUE shall be returned. If the ERROR bit
+ * is set (but none of FUNCTION_NUMBER or OUT_OF_RANGE),
+ * CSR_RESULT_FAILURE shall be returned. The ILLEGAL_COMMAND and
+ * COM_CRC_ERROR bits shall be ignored.
+ *
+ * If the CSPI response is available, and any of the
+ * FUNCTION_DISABLED or CLOCK_DISABLED bits are set,
+ * CSR_SDIO_RESULT_INVALID_VALUE will be returned.
+ *
+ *----------------------------------------------------------------------------*/
+CsrResult CsrSdioInterruptEnable(CsrSdioFunction *function);
+CsrResult CsrSdioInterruptDisable(CsrSdioFunction *function);
+
+/*----------------------------------------------------------------------------*
+ * NAME
+ * CsrSdioInterruptAcknowledge
+ *
+ * DESCRIPTION
+ * Acknowledge that a signalled interrupt has been handled. Shall only
+ * be called once, and exactly once for each signalled interrupt to the
+ * corresponding function.
+ *
+ * PARAMETERS
+ * function - Pointer to struct representing the function to which the
+ * event was signalled.
+ *
+ *----------------------------------------------------------------------------*/
+void CsrSdioInterruptAcknowledge(CsrSdioFunction *function);
+
+/*----------------------------------------------------------------------------*
+ * NAME
+ * CsrSdioInsertedAcknowledge, CsrSdioRemovedAcknowledge
+ *
+ * DESCRIPTION
+ * Acknowledge that a signalled inserted/removed event has been handled.
+ * Shall only be called once, and exactly once for each signalled event to
+ * the corresponding function.
+ *
+ * PARAMETERS
+ * function - Pointer to struct representing the function to which the
+ * inserted was signalled.
+ * result (CsrSdioInsertedAcknowledge only)
+ * CSR_RESULT_SUCCESS - The Function Driver has accepted the
+ * function, and the function is attached to
+ * the Function Driver until the
+ * CsrSdioRemovedCallback is called and
+ * acknowledged.
+ * CSR_RESULT_FAILURE - Unable to accept the function. The
+ * function is not attached to the Function
+ * Driver, and it may be passed to another
+ * Function Driver which supports the
+ * function.
+ *
+ *----------------------------------------------------------------------------*/
+void CsrSdioInsertedAcknowledge(CsrSdioFunction *function, CsrResult result);
+void CsrSdioRemovedAcknowledge(CsrSdioFunction *function);
+
+/*----------------------------------------------------------------------------*
+ * NAME
+ * CsrSdioSuspendAcknowledge, CsrSdioResumeAcknowledge
+ *
+ * DESCRIPTION
+ * Acknowledge that a signalled suspend event has been handled. Shall only
+ * be called once, and exactly once for each signalled event to the
+ * corresponding function.
+ *
+ * PARAMETERS
+ * function - Pointer to struct representing the function to which the
+ * event was signalled.
+ * result
+ * CSR_RESULT_SUCCESS - Successfully suspended/resumed.
+ * CSR_RESULT_FAILURE - Unspecified/unknown error.
+ *
+ *----------------------------------------------------------------------------*/
+void CsrSdioSuspendAcknowledge(CsrSdioFunction *function, CsrResult result);
+void CsrSdioResumeAcknowledge(CsrSdioFunction *function, CsrResult result);
+
+/*----------------------------------------------------------------------------*
+ * NAME
+ * CsrSdioBlockSizeSet
+ *
+ * DESCRIPTION
+ * Set the block size to use for the function. The actual configured block
+ * size shall be the minimum of:
+ * 1) Maximum block size supported by the function.
+ * 2) Maximum block size supported by the host controller.
+ * 3) The block size specified by the blockSize argument.
+ *
+ * When this function returns, the actual configured block size is
+ * available in the blockSize member of the function struct.
+ *
+ * PARAMETERS
+ * function - Pointer to struct representing the function.
+ * blockSize - Block size to use for the function. Valid range is 1 to
+ * 2048.
+ *
+ * RETURNS
+ * CSR_RESULT_SUCCESS - The block size register on the chip
+ * was updated.
+ * CSR_RESULT_FAILURE - Unspecified/unknown error.
+ * CSR_SDIO_RESULT_INVALID_VALUE - One or more arguments were invalid.
+ * CSR_SDIO_RESULT_NO_DEVICE - The device does not exist anymore.
+ * CSR_SDIO_RESULT_CRC_ERROR - A CRC error occured. The configured block
+ * size is undefined.
+ * CSR_SDIO_RESULT_TIMEOUT - No response from the device.
+ *
+ * NOTE: If the SDIO R5 response is available, and the FUNCTION_NUMBER
+ * bits is set, CSR_SDIO_RESULT_INVALID_VALUE shall be returned.
+ * If the ERROR bit is set (but not FUNCTION_NUMBER),
+ * CSR_RESULT_FAILURE shall be returned. The ILLEGAL_COMMAND and
+ * COM_CRC_ERROR bits shall be ignored.
+ *
+ * If the CSPI response is available, and any of the
+ * FUNCTION_DISABLED or CLOCK_DISABLED bits are set,
+ * CSR_SDIO_RESULT_INVALID_VALUE will be returned.
+ *
+ * NOTE: Setting the block size requires two individual operations. The
+ * implementation shall ignore the OUT_OF_RANGE bit of the SDIO R5
+ * response for the first operation, as the partially configured
+ * block size may be out of range, even if the final block size
+ * (after the second operation) is in the valid range.
+ *
+ *----------------------------------------------------------------------------*/
+CsrResult CsrSdioBlockSizeSet(CsrSdioFunction *function, u16 blockSize);
+
+/*----------------------------------------------------------------------------*
+ * NAME
+ * CsrSdioMaxBusClockFrequencySet
+ *
+ * DESCRIPTION
+ * Set the maximum clock frequency to use for the device associated with
+ * the specified function. The actual configured clock frequency for the
+ * device shall be the minimum of:
+ * 1) Maximum clock frequency supported by the device.
+ * 2) Maximum clock frequency supported by the host controller.
+ * 3) Maximum clock frequency specified for any function on the same
+ * device.
+ *
+ * If the clock frequency exceeds 25MHz, it is the responsibility of the
+ * SDIO driver to enable high speed mode on the device, using the standard
+ * defined procedure, before increasing the frequency beyond the limit.
+ *
+ * Note that the clock frequency configured affects all functions on the
+ * same device.
+ *
+ * PARAMETERS
+ * function - Pointer to struct representing the function.
+ * maxFrequency - The maximum clock frequency for the function in Hertz.
+ *
+ * RETURNS
+ * CSR_RESULT_SUCCESS - The maximum clock frequency was succesfully
+ * set for the function.
+ * CSR_RESULT_FAILURE - Unspecified/unknown error.
+ * CSR_SDIO_RESULT_INVALID_VALUE - One or more arguments were invalid.
+ * CSR_SDIO_RESULT_NO_DEVICE - The device does not exist anymore.
+ *
+ * NOTE: If the SDIO R5 response is available, and the FUNCTION_NUMBER
+ * bits is set, CSR_SDIO_RESULT_INVALID_VALUE shall be returned.
+ * If the ERROR bit is set (but not FUNCTION_NUMBER),
+ * CSR_RESULT_FAILURE shall be returned. The ILLEGAL_COMMAND and
+ * COM_CRC_ERROR bits shall be ignored.
+ *
+ * If the CSPI response is available, and any of the
+ * FUNCTION_DISABLED or CLOCK_DISABLED bits are set,
+ * CSR_SDIO_RESULT_INVALID_VALUE will be returned.
+ *
+ *
+ *----------------------------------------------------------------------------*/
+CsrResult CsrSdioMaxBusClockFrequencySet(CsrSdioFunction *function, u32 maxFrequency);
+
+/*----------------------------------------------------------------------------*
+ * NAME
+ * CsrSdioRead8, CsrSdioWrite8, CsrSdioRead8Async, CsrSdioWrite8Async
+ *
+ * DESCRIPTION
+ * Read/write an 8bit value from/to the specified register address.
+ *
+ * PARAMETERS
+ * function - Pointer to struct representing the function.
+ * address - Register address within the function.
+ * data - The data to read/write.
+ * callback - The function to call on operation completion.
+ *
+ * RETURNS
+ * CSR_RESULT_SUCCESS - The data was successfully read/written.
+ * CSR_RESULT_FAILURE - Unspecified/unknown error.
+ * CSR_SDIO_RESULT_INVALID_VALUE - One or more arguments were invalid.
+ * CSR_SDIO_RESULT_NO_DEVICE - The device does not exist anymore.
+ * CSR_SDIO_RESULT_CRC_ERROR - A CRC error occured. No data read/written.
+ * CSR_SDIO_RESULT_TIMEOUT - No response from the device.
+ *
+ * NOTE: If the SDIO R5 response is available, and either of the
+ * FUNCTION_NUMBER or OUT_OF_RANGE bits are set,
+ * CSR_SDIO_RESULT_INVALID_VALUE shall be returned. If the ERROR bit
+ * is set (but none of FUNCTION_NUMBER or OUT_OF_RANGE),
+ * CSR_RESULT_FAILURE shall be returned. The ILLEGAL_COMMAND and
+ * COM_CRC_ERROR bits shall be ignored.
+ *
+ * If the CSPI response is available, and any of the
+ * FUNCTION_DISABLED or CLOCK_DISABLED bits are set,
+ * CSR_SDIO_RESULT_INVALID_VALUE will be returned.
+ *
+ * NOTE: The CsrSdioRead8Async and CsrSdioWrite8Async functions return
+ * immediately, and the supplied callback function is called when the
+ * operation is complete. The result value is given as an argument to
+ * the callback function.
+ *
+ *----------------------------------------------------------------------------*/
+CsrResult CsrSdioRead8(CsrSdioFunction *function, u32 address, u8 *data);
+CsrResult CsrSdioWrite8(CsrSdioFunction *function, u32 address, u8 data);
+void CsrSdioRead8Async(CsrSdioFunction *function, u32 address, u8 *data, CsrSdioAsyncCallback callback);
+void CsrSdioWrite8Async(CsrSdioFunction *function, u32 address, u8 data, CsrSdioAsyncCallback callback);
+
+/*----------------------------------------------------------------------------*
+ * NAME
+ * CsrSdioRead16, CsrSdioWrite16, CsrSdioRead16Async, CsrSdioWrite16Async
+ *
+ * DESCRIPTION
+ * Read/write a 16bit value from/to the specified register address.
+ *
+ * PARAMETERS
+ * function - Pointer to struct representing the function.
+ * address - Register address within the function.
+ * data - The data to read/write.
+ * callback - The function to call on operation completion.
+ *
+ * RETURNS
+ * CSR_RESULT_SUCCESS - The data was successfully read/written.
+ * CSR_RESULT_FAILURE - Unspecified/unknown error.
+ * CSR_SDIO_RESULT_INVALID_VALUE - One or more arguments were invalid.
+ * CSR_SDIO_RESULT_NO_DEVICE - The device does not exist anymore.
+ * CSR_SDIO_RESULT_CRC_ERROR - A CRC error occured. Data may have been
+ * partially read/written.
+ * CSR_SDIO_RESULT_TIMEOUT - No response from the device.
+ *
+ * NOTE: If the SDIO R5 response is available, and either of the
+ * FUNCTION_NUMBER or OUT_OF_RANGE bits are set,
+ * CSR_SDIO_RESULT_INVALID_VALUE shall be returned. If the ERROR bit
+ * is set (but none of FUNCTION_NUMBER or OUT_OF_RANGE),
+ * CSR_RESULT_FAILURE shall be returned. The ILLEGAL_COMMAND and
+ * COM_CRC_ERROR bits shall be ignored.
+ *
+ * If the CSPI response is available, and any of the
+ * FUNCTION_DISABLED or CLOCK_DISABLED bits are set,
+ * CSR_SDIO_RESULT_INVALID_VALUE will be returned.
+ *
+ * NOTE: The CsrSdioRead16Async and CsrSdioWrite16Async functions return
+ * immediately, and the supplied callback function is called when the
+ * operation is complete. The result value is given as an argument to
+ * the callback function.
+ *
+ *----------------------------------------------------------------------------*/
+CsrResult CsrSdioRead16(CsrSdioFunction *function, u32 address, u16 *data);
+CsrResult CsrSdioWrite16(CsrSdioFunction *function, u32 address, u16 data);
+void CsrSdioRead16Async(CsrSdioFunction *function, u32 address, u16 *data, CsrSdioAsyncCallback callback);
+void CsrSdioWrite16Async(CsrSdioFunction *function, u32 address, u16 data, CsrSdioAsyncCallback callback);
+
+/*----------------------------------------------------------------------------*
+ * NAME
+ * CsrSdioF0Read8, CsrSdioF0Write8, CsrSdioF0Read8Async,
+ * CsrSdioF0Write8Async
+ *
+ * DESCRIPTION
+ * Read/write an 8bit value from/to the specified register address in
+ * function 0.
+ *
+ * PARAMETERS
+ * function - Pointer to struct representing the function.
+ * address - Register address within the function.
+ * data - The data to read/write.
+ * callback - The function to call on operation completion.
+ *
+ * RETURNS
+ * CSR_RESULT_SUCCESS - The data was successfully read/written.
+ * CSR_RESULT_FAILURE - Unspecified/unknown error.
+ * CSR_SDIO_RESULT_INVALID_VALUE - One or more arguments were invalid.
+ * CSR_SDIO_RESULT_NO_DEVICE - The device does not exist anymore.
+ * CSR_SDIO_RESULT_CRC_ERROR - A CRC error occured. No data read/written.
+ * CSR_SDIO_RESULT_TIMEOUT - No response from the device.
+ *
+ * NOTE: If the SDIO R5 response is available, and either of the
+ * FUNCTION_NUMBER or OUT_OF_RANGE bits are set,
+ * CSR_SDIO_RESULT_INVALID_VALUE shall be returned. If the ERROR bit
+ * is set (but none of FUNCTION_NUMBER or OUT_OF_RANGE),
+ * CSR_RESULT_FAILURE shall be returned. The ILLEGAL_COMMAND and
+ * COM_CRC_ERROR bits shall be ignored.
+ *
+ * If the CSPI response is available, and any of the
+ * FUNCTION_DISABLED or CLOCK_DISABLED bits are set,
+ * CSR_SDIO_RESULT_INVALID_VALUE will be returned.
+ *
+ * NOTE: The CsrSdioF0Read8Async and CsrSdioF0Write8Async functions return
+ * immediately, and the supplied callback function is called when the
+ * operation is complete. The result value is given as an argument to
+ * the callback function.
+ *
+ *----------------------------------------------------------------------------*/
+CsrResult CsrSdioF0Read8(CsrSdioFunction *function, u32 address, u8 *data);
+CsrResult CsrSdioF0Write8(CsrSdioFunction *function, u32 address, u8 data);
+void CsrSdioF0Read8Async(CsrSdioFunction *function, u32 address, u8 *data, CsrSdioAsyncCallback callback);
+void CsrSdioF0Write8Async(CsrSdioFunction *function, u32 address, u8 data, CsrSdioAsyncCallback callback);
+
+/*----------------------------------------------------------------------------*
+ * NAME
+ * CsrSdioRead, CsrSdioWrite, CsrSdioReadAsync, CsrSdioWriteAsync
+ *
+ * DESCRIPTION
+ * Read/write a specified number of bytes from/to the specified register
+ * address.
+ *
+ * PARAMETERS
+ * function - Pointer to struct representing the function.
+ * address - Register address within the function.
+ * data - The data to read/write.
+ * length - Number of byte to read/write.
+ * callback - The function to call on operation completion.
+ *
+ * RETURNS
+ * CSR_RESULT_SUCCESS - The data was successfully read/written.
+ * CSR_RESULT_FAILURE - Unspecified/unknown error.
+ * CSR_SDIO_RESULT_INVALID_VALUE - One or more arguments were invalid.
+ * CSR_SDIO_RESULT_NO_DEVICE - The device does not exist anymore.
+ * CSR_SDIO_RESULT_CRC_ERROR - A CRC error occured. Data may have been
+ * partially read/written.
+ * CSR_SDIO_RESULT_TIMEOUT - No response from the device.
+ *
+ * NOTE: If the SDIO R5 response is available, and either of the
+ * FUNCTION_NUMBER or OUT_OF_RANGE bits are set,
+ * CSR_SDIO_RESULT_INVALID_VALUE shall be returned. If the ERROR bit
+ * is set (but none of FUNCTION_NUMBER or OUT_OF_RANGE),
+ * CSR_RESULT_FAILURE shall be returned. The ILLEGAL_COMMAND and
+ * COM_CRC_ERROR bits shall be ignored.
+ *
+ * If the CSPI response is available, and any of the
+ * FUNCTION_DISABLED or CLOCK_DISABLED bits are set,
+ * CSR_SDIO_RESULT_INVALID_VALUE will be returned.
+ *
+ * NOTE: The CsrSdioF0Read8Async and CsrSdioF0Write8Async functions return
+ * immediately, and the supplied callback function is called when the
+ * operation is complete. The result value is given as an argument to
+ * the callback function.
+ *
+ *----------------------------------------------------------------------------*/
+CsrResult CsrSdioRead(CsrSdioFunction *function, u32 address, void *data, u32 length);
+CsrResult CsrSdioWrite(CsrSdioFunction *function, u32 address, const void *data, u32 length);
+void CsrSdioReadAsync(CsrSdioFunction *function, u32 address, void *data, u32 length, CsrSdioAsyncCallback callback);
+void CsrSdioWriteAsync(CsrSdioFunction *function, u32 address, const void *data, u32 length, CsrSdioAsyncCallback callback);
+
+/*----------------------------------------------------------------------------*
+ * NAME
+ * CsrSdioPowerOn, CsrSdioPowerOff
+ *
+ * DESCRIPTION
+ * Power on/off the device.
+ *
+ * PARAMETERS
+ * function - Pointer to struct representing the function that resides on
+ * the device to power on/off.
+ *
+ * RETURNS (only CsrSdioPowerOn)
+ * CSR_RESULT_SUCCESS - Power was succesfully reapplied and the device
+ * has been reinitialised.
+ * CSR_RESULT_FAILURE - Unspecified/unknown error.
+ * CSR_SDIO_RESULT_NO_DEVICE - The device does not exist anymore.
+ * CSR_SDIO_RESULT_CRC_ERROR - A CRC error occured during reinitialisation.
+ * CSR_SDIO_RESULT_TIMEOUT - No response from the device during
+ * reinitialisation.
+ * CSR_SDIO_RESULT_NOT_RESET - The power was not removed by the
+ * CsrSdioPowerOff call. The state of the
+ * device is unchanged.
+ *
+ *----------------------------------------------------------------------------*/
+CsrResult CsrSdioPowerOn(CsrSdioFunction *function);
+void CsrSdioPowerOff(CsrSdioFunction *function);
+
+/*----------------------------------------------------------------------------*
+ * NAME
+ * CsrSdioHardReset
+ *
+ * DESCRIPTION
+ * Perform a hardware reset of the device.
+ *
+ * PARAMETERS
+ * function - Pointer to struct representing the function that resides on
+ * the device to hard reset.
+ *
+ * RETURNS
+ * CSR_RESULT_SUCCESS - Reset was succesfully performed and the device
+ * has been reinitialised.
+ * CSR_RESULT_FAILURE - Unspecified/unknown error.
+ * CSR_SDIO_RESULT_NO_DEVICE - The device does not exist anymore.
+ * CSR_SDIO_RESULT_CRC_ERROR - A CRC error occured during reinitialisation.
+ * CSR_SDIO_RESULT_TIMEOUT - No response from the device during
+ * reinitialisation.
+ * CSR_SDIO_RESULT_NOT_RESET - The reset was not applied because it is not
+ * supported. The state of the device is
+ * unchanged.
+ *
+ *----------------------------------------------------------------------------*/
+CsrResult CsrSdioHardReset(CsrSdioFunction *function);
+
+/*----------------------------------------------------------------------------*
+ * NAME
+ * CsrSdioFunctionActive, CsrSdioFunctionIdle
+ *
+ * DESCRIPTION
+ *
+ * PARAMETERS
+ * function - Pointer to struct representing the function.
+ *
+ *----------------------------------------------------------------------------*/
+void CsrSdioFunctionActive(CsrSdioFunction *function);
+void CsrSdioFunctionIdle(CsrSdioFunction *function);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/drivers/staging/csr/csr_serialize_primitive_types.c b/drivers/staging/csr/csr_serialize_primitive_types.c
new file mode 100644
index 000000000000..bf5e4ab9f959
--- /dev/null
+++ b/drivers/staging/csr/csr_serialize_primitive_types.c
@@ -0,0 +1,101 @@
+/*****************************************************************************
+
+ (c) Cambridge Silicon Radio Limited 2010
+ All rights reserved and confidential information of CSR
+
+ Refer to LICENSE.txt included with this source for details
+ on the license terms.
+
+*****************************************************************************/
+
+#include <linux/module.h>
+#include <linux/slab.h>
+#include "csr_prim_defs.h"
+#include "csr_msgconv.h"
+#include "csr_macro.h"
+#include "csr_lib.h"
+
+void CsrUint8Des(u8 *value, u8 *buffer, size_t *offset)
+{
+ *value = buffer[*offset];
+ *offset += sizeof(*value);
+}
+EXPORT_SYMBOL_GPL(CsrUint8Des);
+
+void CsrUint16Des(u16 *value, u8 *buffer, size_t *offset)
+{
+ *value = (buffer[*offset + 0] << 0) |
+ (buffer[*offset + 1] << 8);
+ *offset += sizeof(*value);
+}
+EXPORT_SYMBOL_GPL(CsrUint16Des);
+
+void CsrUint32Des(u32 *value, u8 *buffer, size_t *offset)
+{
+ *value = (buffer[*offset + 0] << 0) |
+ (buffer[*offset + 1] << 8) |
+ (buffer[*offset + 2] << 16) |
+ (buffer[*offset + 3] << 24);
+ *offset += sizeof(*value);
+}
+EXPORT_SYMBOL_GPL(CsrUint32Des);
+
+void CsrMemCpyDes(void *value, u8 *buffer, size_t *offset, size_t length)
+{
+ memcpy(value, &buffer[*offset], length);
+ *offset += length;
+}
+EXPORT_SYMBOL_GPL(CsrMemCpyDes);
+
+void CsrCharStringDes(char **value, u8 *buffer, size_t *offset)
+{
+ *value = kstrdup((char *) &buffer[*offset], GFP_KERNEL);
+ *offset += strlen(*value) + 1;
+}
+EXPORT_SYMBOL_GPL(CsrCharStringDes);
+
+void CsrUint8Ser(u8 *buffer, size_t *offset, u8 value)
+{
+ buffer[*offset] = value;
+ *offset += sizeof(value);
+}
+EXPORT_SYMBOL_GPL(CsrUint8Ser);
+
+void CsrUint16Ser(u8 *buffer, size_t *offset, u16 value)
+{
+ buffer[*offset + 0] = (u8) ((value >> 0) & 0xFF);
+ buffer[*offset + 1] = (u8) ((value >> 8) & 0xFF);
+ *offset += sizeof(value);
+}
+EXPORT_SYMBOL_GPL(CsrUint16Ser);
+
+void CsrUint32Ser(u8 *buffer, size_t *offset, u32 value)
+{
+ buffer[*offset + 0] = (u8) ((value >> 0) & 0xFF);
+ buffer[*offset + 1] = (u8) ((value >> 8) & 0xFF);
+ buffer[*offset + 2] = (u8) ((value >> 16) & 0xFF);
+ buffer[*offset + 3] = (u8) ((value >> 24) & 0xFF);
+ *offset += sizeof(value);
+}
+EXPORT_SYMBOL_GPL(CsrUint32Ser);
+
+void CsrMemCpySer(u8 *buffer, size_t *offset, const void *value, size_t length)
+{
+ memcpy(&buffer[*offset], value, length);
+ *offset += length;
+}
+EXPORT_SYMBOL_GPL(CsrMemCpySer);
+
+void CsrCharStringSer(u8 *buffer, size_t *offset, const char *value)
+{
+ if (value)
+ {
+ strcpy(((char *) &buffer[*offset]), value);
+ *offset += strlen(value) + 1;
+ }
+ else
+ {
+ CsrUint8Ser(buffer, offset, 0);
+ }
+}
+EXPORT_SYMBOL_GPL(CsrCharStringSer);
diff --git a/drivers/staging/csr/csr_time.c b/drivers/staging/csr/csr_time.c
new file mode 100644
index 000000000000..83586ca34e8c
--- /dev/null
+++ b/drivers/staging/csr/csr_time.c
@@ -0,0 +1,43 @@
+/*****************************************************************************
+
+ (c) Cambridge Silicon Radio Limited 2010
+ All rights reserved and confidential information of CSR
+
+ Refer to LICENSE.txt included with this source for details
+ on the license terms.
+
+*****************************************************************************/
+
+#include <linux/kernel.h>
+#include <linux/version.h>
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 33)
+#elif LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 16)
+#include <linux/autoconf.h>
+#include <linux/config.h>
+#endif
+
+#include <linux/time.h>
+#include <linux/module.h>
+
+#include "csr_time.h"
+
+CsrTime CsrTimeGet(CsrTime *high)
+{
+ struct timespec ts;
+ u64 time;
+ CsrTime low;
+
+ ts = current_kernel_time();
+ time = (u64) ts.tv_sec * 1000000 + ts.tv_nsec / 1000;
+
+ if (high != NULL)
+ {
+ *high = (CsrTime) ((time >> 32) & 0xFFFFFFFF);
+ }
+
+ low = (CsrTime) (time & 0xFFFFFFFF);
+
+ return low;
+}
+EXPORT_SYMBOL_GPL(CsrTimeGet);
diff --git a/drivers/staging/csr/csr_time.h b/drivers/staging/csr/csr_time.h
new file mode 100644
index 000000000000..2a45f3e4024d
--- /dev/null
+++ b/drivers/staging/csr/csr_time.h
@@ -0,0 +1,114 @@
+#ifndef CSR_TIME_H__
+#define CSR_TIME_H__
+/*****************************************************************************
+
+ (c) Cambridge Silicon Radio Limited 2010
+ All rights reserved and confidential information of CSR
+
+ Refer to LICENSE.txt included with this source for details
+ on the license terms.
+
+*****************************************************************************/
+
+#include <linux/types.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*******************************************************************************
+
+ NAME
+ CsrTime
+
+ DESCRIPTION
+ Type to hold a value describing the current system time, which is a
+ measure of time elapsed since some arbitrarily defined fixed time
+ reference, usually associated with system startup.
+
+*******************************************************************************/
+typedef u32 CsrTime;
+
+
+/*******************************************************************************
+
+ NAME
+ CsrTimeUtc
+
+ DESCRIPTION
+ Type to hold a value describing a UTC wallclock time expressed in
+ seconds and milliseconds elapsed since midnight January 1st 1970.
+
+*******************************************************************************/
+typedef struct
+{
+ u32 sec;
+ u16 msec;
+} CsrTimeUtc;
+
+
+/*******************************************************************************
+
+ NAME
+ CsrTimeGet
+
+ DESCRIPTION
+ Returns the current system time in a low and a high part. The low part
+ is expressed in microseconds. The high part is incremented when the low
+ part wraps to provide an extended range.
+
+ The caller may provide a NULL pointer as the high parameter. In this case
+ the function just returns the low part and ignores the high parameter.
+
+ Although the time is expressed in microseconds the actual resolution is
+ platform dependent and can be less. It is recommended that the
+ resolution is at least 10 milliseconds.
+
+ PARAMETERS
+ high - Pointer to variable that will receive the high part of the
+ current system time. Passing NULL is valid.
+
+ RETURNS
+ Low part of current system time in microseconds.
+
+*******************************************************************************/
+CsrTime CsrTimeGet(CsrTime *high);
+
+
+/*------------------------------------------------------------------*/
+/* CsrTime Macros */
+/*------------------------------------------------------------------*/
+
+/*----------------------------------------------------------------------------*
+ * NAME
+ * CsrTimeAdd
+ *
+ * DESCRIPTION
+ * Add two time values. Adding the numbers can overflow the range of a
+ * CsrTime, so the user must be cautious.
+ *
+ * RETURNS
+ * CsrTime - the sum of "t1" and "t2".
+ *
+ *----------------------------------------------------------------------------*/
+#define CsrTimeAdd(t1, t2) ((t1) + (t2))
+
+/*----------------------------------------------------------------------------*
+ * NAME
+ * CsrTimeSub
+ *
+ * DESCRIPTION
+ * Subtract two time values. Subtracting the numbers can provoke an
+ * underflow, so the user must be cautious.
+ *
+ * RETURNS
+ * CsrTime - "t1" - "t2".
+ *
+ *----------------------------------------------------------------------------*/
+#define CsrTimeSub(t1, t2) ((s32) (t1) - (s32) (t2))
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/drivers/staging/csr/csr_util.c b/drivers/staging/csr/csr_util.c
new file mode 100644
index 000000000000..c3aa9d509e5c
--- /dev/null
+++ b/drivers/staging/csr/csr_util.c
@@ -0,0 +1,15 @@
+/*****************************************************************************
+
+ (c) Cambridge Silicon Radio Limited 2010
+ All rights reserved and confidential information of CSR
+
+ Refer to LICENSE.txt included with this source for details
+ on the license terms.
+
+*****************************************************************************/
+
+#include <linux/module.h>
+
+MODULE_DESCRIPTION("CSR Operating System Kernel Abstraction");
+MODULE_AUTHOR("Cambridge Silicon Radio Ltd.");
+MODULE_LICENSE("GPL and additional rights");
diff --git a/drivers/staging/csr/csr_wifi_common.h b/drivers/staging/csr/csr_wifi_common.h
new file mode 100644
index 000000000000..cc41a94b8f25
--- /dev/null
+++ b/drivers/staging/csr/csr_wifi_common.h
@@ -0,0 +1,109 @@
+/*****************************************************************************
+
+ (c) Cambridge Silicon Radio Limited 2011
+ All rights reserved and confidential information of CSR
+
+ Refer to LICENSE.txt included with this source for details
+ on the license terms.
+
+*****************************************************************************/
+
+#ifndef CSR_WIFI_COMMON_H__
+#define CSR_WIFI_COMMON_H__
+
+#include <linux/types.h>
+#include "csr_result.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* MAC address */
+typedef struct
+{
+ u8 a[6];
+} CsrWifiMacAddress;
+
+/* IPv4 address */
+typedef struct
+{
+ u8 a[4];
+} CsrWifiIp4Address;
+
+/* IPv6 address */
+typedef struct
+{
+ u8 a[16];
+} CsrWifiIp6Address;
+
+typedef struct
+{
+ u8 ssid[32];
+ u8 length;
+} CsrWifiSsid;
+
+/*******************************************************************************
+
+ DESCRIPTION
+ Result values used on the Wifi Interfaces
+
+ VALUES
+ CSR_RESULT_SUCCESS
+ - The request/procedure succeeded
+ CSR_RESULT_FAILURE
+ - The request/procedure did not succeed because of an error
+ CSR_WIFI_RESULT_NOT_FOUND
+ - The request did not succeed because some resource was not
+ found.
+ CSR_WIFI_RESULT_TIMED_OUT
+ - The request/procedure did not succeed because of a time out
+ CSR_WIFI_RESULT_CANCELLED
+ - The request was canceled due to another conflicting
+ request that was issued before this one was completed
+ CSR_WIFI_RESULT_INVALID_PARAMETER
+ - The request/procedure did not succeed because it had an
+ invalid parameter
+ CSR_WIFI_RESULT_NO_ROOM
+ - The request did not succeed due to a lack of resources,
+ e.g. out of memory problem.
+ CSR_WIFI_RESULT_UNSUPPORTED
+ - The request/procedure did not succeed because the feature
+ is not supported yet
+ CSR_WIFI_RESULT_UNAVAILABLE
+ - The request cannot be processed at this time
+ CSR_WIFI_RESULT_WIFI_OFF
+ - The requested action is not available because Wi-Fi is
+ currently off
+ CSR_WIFI_RESULT_SECURITY_ERROR
+ - The request/procedure did not succeed because of a security
+ error
+ CSR_WIFI_RESULT_MIB_SET_FAILURE
+ - MIB Set Failure: either the MIB OID to be written to does
+ not exist or the MIB Value is invalid.
+ CSR_WIFI_RESULT_INVALID_INTERFACE_TAG
+ - The supplied Interface Tag is not valid.
+ CSR_WIFI_RESULT_P2P_NOA_CONFIG_CONFLICT
+ - The new NOA configuration conflicts with the existing NOA configuration
+ hence not accepted"
+*******************************************************************************/
+#define CSR_WIFI_RESULT_NOT_FOUND ((CsrResult) 0x0001)
+#define CSR_WIFI_RESULT_TIMED_OUT ((CsrResult) 0x0002)
+#define CSR_WIFI_RESULT_CANCELLED ((CsrResult) 0x0003)
+#define CSR_WIFI_RESULT_INVALID_PARAMETER ((CsrResult) 0x0004)
+#define CSR_WIFI_RESULT_NO_ROOM ((CsrResult) 0x0005)
+#define CSR_WIFI_RESULT_UNSUPPORTED ((CsrResult) 0x0006)
+#define CSR_WIFI_RESULT_UNAVAILABLE ((CsrResult) 0x0007)
+#define CSR_WIFI_RESULT_WIFI_OFF ((CsrResult) 0x0008)
+#define CSR_WIFI_RESULT_SECURITY_ERROR ((CsrResult) 0x0009)
+#define CSR_WIFI_RESULT_MIB_SET_FAILURE ((CsrResult) 0x000A)
+#define CSR_WIFI_RESULT_INVALID_INTERFACE_TAG ((CsrResult) 0x000B)
+#define CSR_WIFI_RESULT_P2P_NOA_CONFIG_CONFLICT ((CsrResult) 0x000C)
+
+#define CSR_WIFI_VERSION "5.1.0.0"
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+
diff --git a/drivers/staging/csr/csr_wifi_fsm.h b/drivers/staging/csr/csr_wifi_fsm.h
new file mode 100644
index 000000000000..073e2f8b5532
--- /dev/null
+++ b/drivers/staging/csr/csr_wifi_fsm.h
@@ -0,0 +1,248 @@
+/*****************************************************************************
+
+ (c) Cambridge Silicon Radio Limited 2011
+ All rights reserved and confidential information of CSR
+
+ Refer to LICENSE.txt included with this source for details
+ on the license terms.
+
+*****************************************************************************/
+
+#ifndef CSR_WIFI_FSM_H
+#define CSR_WIFI_FSM_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include "csr_prim_defs.h"
+#include "csr_log_text.h"
+#include "csr_wifi_fsm_event.h"
+
+/* including this file for CsrWifiInterfaceMode*/
+#include "csr_wifi_common.h"
+
+#define CSR_WIFI_FSM_ENV (0xFFFF)
+
+/**
+ * @brief
+ * Toplevel FSM context data
+ *
+ * @par Description
+ * Holds ALL FSM static and dynamic data for a FSM
+ */
+typedef struct CsrWifiFsmContext CsrWifiFsmContext;
+
+/**
+ * @brief
+ * FSM External Wakeup CallbackFunction Pointer
+ *
+ * @par Description
+ * Defines the external wakeup function for the FSM
+ * to call when an external event is injected into the systen
+ *
+ * @param[in] context : External context
+ *
+ * @return
+ * void
+ */
+typedef void (*CsrWifiFsmExternalWakupCallbackPtr)(void *context);
+
+/**
+ * @brief
+ * Initialises a top level FSM context
+ *
+ * @par Description
+ * Initialises the FSM Context to an initial state and allocates
+ * space for "maxProcesses" number of instances
+ *
+ * @param[in] osaContext : OSA context
+ * @param[in] applicationContext : Internal fsm application context
+ * @param[in] externalContext : External context
+ * @param[in] maxProcesses : Max processes to allocate room for
+ *
+ * @return
+ * CsrWifiFsmContext* fsm context
+ */
+extern CsrWifiFsmContext* CsrWifiFsmInit(void *applicationContext, void *externalContext, u16 maxProcesses, CsrLogTextTaskId loggingTaskId);
+
+/**
+ * @brief
+ * Resets the FSM's back to first conditions
+ *
+ * @par Description
+ * This function is used to free any dynamic resources allocated for the
+ * given context by CsrWifiFsmInit().
+ * The FSM's reset function is called to cleanup any fsm specific memory
+ * The reset funtion does NOT need to free the fsm data pointer as
+ * CsrWifiFsmShutdown() will do it.
+ * the FSM's init function is call again to reinitialise the FSM context.
+ * CsrWifiFsmReset() should NEVER be called when CsrWifiFsmExecute() is running.
+ *
+ * @param[in] context : FSM context
+ *
+ * @return
+ * void
+ */
+extern void CsrWifiFsmReset(CsrWifiFsmContext *context);
+
+/**
+ * @brief
+ * Frees resources allocated by CsrWifiFsmInit
+ *
+ * @par Description
+ * This function is used to free any dynamic resources allocated for the
+ * given context by CsrWifiFsmInit(), prior to complete termination of
+ * the program.
+ * The FSM's reset function is called to cleanup any fsm specific memory.
+ * The reset funtion does NOT need to free the fsm data pointer as
+ * CsrWifiFsmShutdown() will do it.
+ * CsrWifiFsmShutdown() should NEVER be called when CsrWifiFsmExecute() is running.
+ *
+ * @param[in] context : FSM context
+ *
+ * @return
+ * void
+ */
+extern void CsrWifiFsmShutdown(CsrWifiFsmContext *context);
+
+/**
+ * @brief
+ * Executes the fsm context
+ *
+ * @par Description
+ * Executes the FSM context and runs until ALL events in the context are processed.
+ * When no more events are left to process then CsrWifiFsmExecute() returns to a time
+ * specifying when to next call the CsrWifiFsmExecute()
+ * Scheduling, threading, blocking and external event notification are outside
+ * the scope of the FSM and CsrWifiFsmExecute().
+ *
+ * @param[in] context : FSM context
+ *
+ * @return
+ * u32 Time in ms until next timeout or 0xFFFFFFFF for no timer set
+ */
+extern u32 CsrWifiFsmExecute(CsrWifiFsmContext *context);
+
+/**
+ * @brief
+ * Adds an event to the FSM context's external event queue for processing
+ *
+ * @par Description
+ * Adds an event to the contexts external queue
+ * This is thread safe and adds an event to the fsm's external event queue.
+ *
+ * @param[in] context : FSM context
+ * @param[in] event : event to add to the event queue
+ * @param[in] source : source of the event (this can be a synergy task queue or an fsm instance id)
+ * @param[in] destination : destination of the event (This can be a fsm instance id or CSR_WIFI_FSM_ENV)
+ * @param[in] id : event id
+ *
+ * @return
+ * void
+ */
+extern void CsrWifiFsmSendEventExternal(CsrWifiFsmContext *context, CsrWifiFsmEvent *event, u16 source, u16 destination, CsrPrim primtype, u16 id);
+
+/**
+ * @brief
+ * Adds an Alien event to the FSM context's external event queue for processing
+ *
+ * @par Description
+ * Adds an event to the contexts external queue
+ * This is thread safe and adds an event to the fsm's external event queue.
+ *
+ * @param[in] context : FSM context
+ * @param[in] event : event to add to the event queue
+ * @param[in] source : source of the event (this can be a synergy task queue or an fsm instance id)
+ * @param[in] destination : destination of the event (This can be a fsm instance id or CSR_WIFI_FSM_ENV)
+ * @param[in] id : event id
+ */
+#define CsrWifiFsmSendAlienEventExternal(_context, _alienEvent, _source, _destination, _primtype, _id) \
+ { \
+ CsrWifiFsmAlienEvent *_evt = kmalloc(sizeof(CsrWifiFsmAlienEvent), GFP_KERNEL); \
+ _evt->alienEvent = _alienEvent; \
+ CsrWifiFsmSendEventExternal(_context, (CsrWifiFsmEvent *)_evt, _source, _destination, _primtype, _id); \
+ }
+
+
+/**
+ * @brief
+ * Current time of day in ms
+ *
+ * @param[in] context : FSM context
+ *
+ * @return
+ * u32 32 bit ms tick
+ */
+extern u32 CsrWifiFsmGetTimeOfDayMs(CsrWifiFsmContext *context);
+
+/**
+ * @brief
+ * Gets the time until the next FSM timer expiry
+ *
+ * @par Description
+ * Returns the next timeout time or 0 if no timers are set.
+ *
+ * @param[in] context : FSM context
+ *
+ * @return
+ * u32 Time in ms until next timeout or 0xFFFFFFFF for no timer set
+ */
+extern u32 CsrWifiFsmGetNextTimeout(CsrWifiFsmContext *context);
+
+/**
+ * @brief
+ * Fast forwards the fsm timers by ms Milliseconds
+ *
+ * @param[in] context : FSM context
+ * @param[in] ms : Milliseconds to fast forward by
+ *
+ * @return
+ * void
+ */
+extern void CsrWifiFsmFastForward(CsrWifiFsmContext *context, u16 ms);
+
+/**
+ * @brief
+ * shift the current time of day by ms amount
+ *
+ * @par Description
+ * usefull to speed up tests where time needs to pass
+ *
+ * @param[in] context : FSM context
+ * @param[in] ms : ms to adjust time by
+ *
+ * @return
+ * void
+ */
+extern void CsrWifiFsmTestAdvanceTime(CsrWifiFsmContext *context, u32 ms);
+
+/**
+ * @brief
+ * Check if the fsm has events to process
+ *
+ * @param[in] context : FSM context
+ *
+ * @return
+ * u8 returns TRUE if there are events for the FSM to process
+ */
+extern u8 CsrWifiFsmHasEvents(CsrWifiFsmContext *context);
+
+/**
+ * @brief
+ * function that installs the contexts wakeup function
+ *
+ * @param[in] context : FSM context
+ * @param[in] callback : Callback function pointer
+ *
+ * @return
+ * void
+ */
+extern void CsrWifiFsmInstallWakeupCallback(CsrWifiFsmContext *context, CsrWifiFsmExternalWakupCallbackPtr callback);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* CSR_WIFI_FSM_H */
+
diff --git a/drivers/staging/csr/csr_wifi_fsm_event.h b/drivers/staging/csr/csr_wifi_fsm_event.h
new file mode 100644
index 000000000000..57a5cafd40bd
--- /dev/null
+++ b/drivers/staging/csr/csr_wifi_fsm_event.h
@@ -0,0 +1,50 @@
+/*****************************************************************************
+
+ (c) Cambridge Silicon Radio Limited 2011
+ All rights reserved and confidential information of CSR
+
+ Refer to LICENSE.txt included with this source for details
+ on the license terms.
+
+*****************************************************************************/
+
+#ifndef CSR_WIFI_FSM_EVENT_H
+#define CSR_WIFI_FSM_EVENT_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include "csr_prim_defs.h"
+#include "csr_sched.h"
+
+/**
+ * @brief
+ * FSM event header.
+ *
+ * @par Description
+ * All events MUST have this struct as the FIRST member.
+ * The next member is used internally for linked lists
+ */
+typedef struct CsrWifiFsmEvent
+{
+ CsrPrim type;
+ u16 primtype;
+ CsrSchedQid destination;
+ CsrSchedQid source;
+
+ /* Private pointer to allow an optimal Event list */
+ /* NOTE: Ignore this pointer.
+ * Do not waste code initializing OR freeing it.
+ * The pointer is used internally in the CsrWifiFsm code
+ * to avoid a second malloc when queuing events.
+ */
+ struct CsrWifiFsmEvent *next;
+} CsrWifiFsmEvent;
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* CSR_WIFI_FSM_EVENT_H */
+
diff --git a/drivers/staging/csr/csr_wifi_fsm_types.h b/drivers/staging/csr/csr_wifi_fsm_types.h
new file mode 100644
index 000000000000..26752bf316e0
--- /dev/null
+++ b/drivers/staging/csr/csr_wifi_fsm_types.h
@@ -0,0 +1,440 @@
+/*****************************************************************************
+
+ (c) Cambridge Silicon Radio Limited 2011
+ All rights reserved and confidential information of CSR
+
+ Refer to LICENSE.txt included with this source for details
+ on the license terms.
+
+*****************************************************************************/
+
+#ifndef CSR_WIFI_FSM_TYPES_H
+#define CSR_WIFI_FSM_TYPES_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <linux/types.h>
+#include "csr_macro.h"
+#include "csr_panic.h"
+#include "csr_sched.h"
+
+#ifdef CSR_WIFI_FSM_MUTEX_ENABLE
+#include "csr_framework_ext.h"
+#endif
+
+#include "csr_wifi_fsm.h"
+
+#define CSR_WIFI_FSM_MAX_TRANSITION_HISTORY 10
+
+/**
+ * @brief
+ * FSM event list header.
+ *
+ * @par Description
+ * Singly linked list of events.
+ */
+typedef struct CsrWifiFsmEventList
+{
+ CsrWifiFsmEvent *first;
+ CsrWifiFsmEvent *last;
+} CsrWifiFsmEventList;
+
+
+/**
+ * @brief
+ * FSM timer id.
+ *
+ * @par Description
+ * Composite Id made up of the type, dest and a unique id so
+ * CsrWifiFsmRemoveTimer knows where to look when removing the timer
+ */
+typedef struct CsrWifiFsmTimerId
+{
+ CsrPrim type;
+ u16 primtype;
+ CsrSchedQid destination;
+ u16 uniqueid;
+} CsrWifiFsmTimerId;
+
+/**
+ * @brief
+ * FSM timer header.
+ *
+ * @par Description
+ * All timer MUST have this struct as the FIRST member.
+ * The first members of the structure MUST remain compatable
+ * with the CsrWifiFsmEvent so that timers are just specialised events
+ */
+typedef struct CsrWifiFsmTimer
+{
+ CsrPrim type;
+ u16 primtype;
+ CsrSchedQid destination;
+ CsrSchedQid source;
+
+ /* Private pointer to allow an optimal Event list */
+ struct CsrWifiFsmTimer *next;
+
+ CsrWifiFsmTimerId timerid;
+ u32 timeoutTimeMs;
+} CsrWifiFsmTimer;
+
+
+/**
+ * @brief
+ * Fsm Alien Event
+ *
+ * @par Description
+ * Allows the wrapping of alien events that do not use CsrWifiFsmEvent
+ * as the first member of the Event struct
+ */
+typedef struct
+{
+ CsrWifiFsmEvent event;
+ void *alienEvent;
+} CsrWifiFsmAlienEvent;
+
+
+/**
+ * @brief
+ * FSM timer list header.
+ *
+ * @par Description
+ * Singly linked list of timers.
+ */
+typedef struct CsrWifiFsmTimerList
+{
+ CsrWifiFsmTimer *first;
+ CsrWifiFsmTimer *last;
+ u16 nexttimerid;
+} CsrWifiFsmTimerList;
+
+/**
+ * @brief
+ * Process Entry Function Pointer
+ *
+ * @par Description
+ * Defines the entry function for a processes.
+ * Called at process initialisation.
+ *
+ * @param[in] context : FSM context
+ *
+ * @return
+ * void
+ */
+typedef void (*CsrWifiFsmProcEntryFnPtr)(CsrWifiFsmContext *context);
+
+/**
+ * @brief
+ * Process Transition Function Pointer
+ *
+ * @par Description
+ * Defines a transition function for a processes.
+ * Called when an event causes a transition on a process
+ *
+ * @param[in] CsrWifiFsmContext* : FSM context
+ * @param[in] void* : FSM data (can be NULL)
+ * @param[in] const CsrWifiFsmEvent* : event to process
+ *
+ * @return
+ * void
+ */
+typedef void (*CsrWifiFsmTransitionFnPtr)(CsrWifiFsmContext *context, void *fsmData, const CsrWifiFsmEvent *event);
+
+/**
+ * @brief
+ * Process reset/shutdown Function Pointer
+ *
+ * @par Description
+ * Defines the reset/shutdown function for a processes.
+ * Called to reset or shutdown an fsm.
+ *
+ * @param[in] context : FSM context
+ *
+ * @return
+ * void
+ */
+typedef void (*CsrWifiFsmProcResetFnPtr)(CsrWifiFsmContext *context);
+
+/**
+ * @brief
+ * FSM Default Destination CallbackFunction Pointer
+ *
+ * @par Description
+ * Defines the default destination function for the FSM
+ * to call when an event does not have a valid destination.
+ * This
+ *
+ * @param[in] context : External context
+ *
+ * @return
+ * u16 a valid destination OR CSR_WIFI_FSM_ENV
+ */
+typedef u16 (*CsrWifiFsmDestLookupCallbackPtr)(void *context, const CsrWifiFsmEvent *event);
+
+
+#ifdef CSR_WIFI_FSM_DUMP_ENABLE
+/**
+ * @brief
+ * Trace Dump Function Pointer
+ *
+ * @par Description
+ * Called when we want to trace the FSM
+ *
+ * @param[in] context : FSM context
+ * @param[in] id : fsm id
+ *
+ * @return
+ * void
+ */
+typedef void (*CsrWifiFsmDumpFnPtr)(CsrWifiFsmContext *context, void *fsmData);
+#endif
+
+/**
+ * @brief
+ * Event ID to transition function entry
+ *
+ * @par Description
+ * Event ID to Transition Entry in a state table.
+ */
+typedef struct
+{
+ u32 eventid;
+ CsrWifiFsmTransitionFnPtr transition;
+#ifdef CSR_LOG_ENABLE
+ const char *transitionName;
+#endif
+} CsrWifiFsmEventEntry;
+
+/**
+ * @brief
+ * Single State's Transition Table
+ *
+ * @par Description
+ * Stores Data for a single State's event to
+ * transition functions mapping
+ */
+typedef struct
+{
+ const u8 numEntries;
+ const u8 saveAll;
+ const CsrWifiFsmEventEntry *eventEntryArray; /* array of transition function pointers for state */
+#ifdef CSR_LOG_ENABLE
+ u16 stateNumber;
+ const char *stateName;
+#endif
+} CsrWifiFsmTableEntry;
+
+/**
+ * @brief
+ * Process State Transtion table
+ *
+ * @par Description
+ * Stores Data for a processes State to transition table
+ */
+typedef struct
+{
+ u16 numStates; /* number of states */
+ const CsrWifiFsmTableEntry *aStateEventMatrix; /* state event matrix */
+} CsrWifiFsmTransitionFunctionTable;
+
+/**
+ * @brief
+ * Const Process definition
+ *
+ * @par Description
+ * Constant process specification.
+ * This is ALL the non dynamic data that defines
+ * a process.
+ */
+typedef struct
+{
+ const char *processName;
+ const u32 processId;
+ const CsrWifiFsmTransitionFunctionTable transitionTable;
+ const CsrWifiFsmTableEntry unhandledTransitions;
+ const CsrWifiFsmTableEntry ignoreFunctions;
+ const CsrWifiFsmProcEntryFnPtr entryFn;
+ const CsrWifiFsmProcResetFnPtr resetFn;
+#ifdef CSR_WIFI_FSM_DUMP_ENABLE
+ const CsrWifiFsmDumpFnPtr dumpFn; /* Called to dump fsm specific trace if not NULL */
+#endif
+} CsrWifiFsmProcessStateMachine;
+
+#ifdef CSR_WIFI_FSM_DUMP_ENABLE
+/**
+ * @brief
+ * Storage for state transition info
+ */
+typedef struct
+{
+ u16 transitionNumber;
+ CsrWifiFsmEvent event;
+ u16 fromState;
+ u16 toState;
+ CsrWifiFsmTransitionFnPtr transitionFn;
+ u16 transitionCount; /* number consecutive of times this transition was seen */
+#ifdef CSR_LOG_ENABLE
+ const char *transitionName;
+#endif
+} CsrWifiFsmTransitionRecord;
+
+/**
+ * @brief
+ * Storage for the last state X transitions
+ */
+typedef struct
+{
+ u16 numTransitions;
+ CsrWifiFsmTransitionRecord records[CSR_WIFI_FSM_MAX_TRANSITION_HISTORY];
+} CsrWifiFsmTransitionRecords;
+#endif
+
+/**
+ * @brief
+ * Dynamic Process data
+ *
+ * @par Description
+ * Dynamic process data that is used to keep track of the
+ * state and data for a process instance
+ */
+typedef struct
+{
+ const CsrWifiFsmProcessStateMachine *fsmInfo; /* state machine info that is constant regardless of context */
+ u16 instanceId; /* Runtime process id */
+ u16 state; /* Current state */
+ void *params; /* Instance user data */
+ CsrWifiFsmEventList savedEventQueue; /* The saved event queue */
+ struct CsrWifiFsmInstanceEntry *subFsm; /* Sub Fsm instance data */
+ struct CsrWifiFsmInstanceEntry *subFsmCaller; /* The Fsm instance that created the SubFsm and should be used for callbacks*/
+#ifdef CSR_WIFI_FSM_DUMP_ENABLE
+ CsrWifiFsmTransitionRecords transitionRecords; /* Last X transitions in the FSM */
+#endif
+} CsrWifiFsmInstanceEntry;
+
+/**
+ * @brief
+ * OnCreate Callback Function Pointer
+ *
+ * @par Description
+ * Called when an fsm is created.
+ *
+ * @param[in] extContext : External context
+ * @param[in] instance : FSM instance
+ *
+ * @return
+ * void
+ */
+typedef void (*CsrWifiFsmOnCreateFnPtr)(void *extContext, const CsrWifiFsmInstanceEntry *instance);
+
+/**
+ * @brief
+ * OnTransition Callback Function Pointer
+ *
+ * @par Description
+ * Called when an event is processed by a fsm
+ *
+ * @param[in] extContext : External context
+ * @param[in] eventEntryArray : Entry data
+ * @param[in] event : Event
+ *
+ * @return
+ * void
+ */
+typedef void (*CsrWifiFsmOnTransitionFnPtr)(void *extContext, const CsrWifiFsmEventEntry *eventEntryArray, const CsrWifiFsmEvent *event);
+
+/**
+ * @brief
+ * OnStateChange Callback Function Pointer
+ *
+ * @par Description
+ * Called when CsrWifiFsmNextState is called
+ *
+ * @param[in] extContext : External context
+ *
+ * @return
+ * void
+ */
+typedef void (*CsrWifiFsmOnStateChangeFnPtr)(void *extContext, u16 nextstate);
+
+/**
+ * @brief
+ * OnIgnore,OnError or OnInvalid Callback Function Pointer
+ *
+ * @par Description
+ * Called when an event is processed by a fsm
+ *
+ * @param[in] extContext : External context
+ * @param[in] event : Event
+ *
+ * @return
+ * void
+ */
+typedef void (*CsrWifiFsmOnEventFnPtr)(void *extContext, const CsrWifiFsmEvent *event);
+
+/**
+ * @brief
+ * Toplevel FSM context data
+ *
+ * @par Description
+ * Holds ALL FSM static and dynamic data for a FSM
+ */
+struct CsrWifiFsmContext
+{
+ CsrWifiFsmEventList eventQueue; /* The internal event queue */
+ CsrWifiFsmEventList externalEventQueue; /* The external event queue */
+#ifdef CSR_WIFI_FSM_MUTEX_ENABLE
+ CsrMutexHandle externalEventQueueLock; /* The external event queue mutex */
+#endif
+ u32 timeOffset; /* Amount to adjust the TimeOfDayMs by */
+ CsrWifiFsmTimerList timerQueue; /* The internal timer queue */
+ u8 useTempSaveList; /* Should the temp save list be used */
+ CsrWifiFsmEventList tempSaveList; /* The temp save event queue */
+ CsrWifiFsmEvent *eventForwardedOrSaved; /* The event that was forwarded or Saved */
+ u16 maxProcesses; /* Size of instanceArray */
+ u16 numProcesses; /* Current number allocated in instanceArray */
+ CsrWifiFsmInstanceEntry *instanceArray; /* Array of processes for this component */
+ CsrWifiFsmInstanceEntry *ownerInstance; /* The Process that owns currentInstance (SubFsm support) */
+ CsrWifiFsmInstanceEntry *currentInstance; /* Current Process that is executing */
+ CsrWifiFsmExternalWakupCallbackPtr externalEventFn; /* External event Callback */
+ CsrWifiFsmOnEventFnPtr appIgnoreCallback; /* Application Ignore event Callback */
+ CsrWifiFsmDestLookupCallbackPtr appEvtDstCallback; /* Application Lookup event Destination Function*/
+
+ void *applicationContext; /* Internal fsm application context */
+ void *externalContext; /* External context (set by the user of the fsm)*/
+ CsrLogTextTaskId loggingTaskId; /* Task Id to use in any logging output */
+
+#ifndef CSR_WIFI_FSM_SCHEDULER_DISABLED
+ CsrSchedTid schedTimerId; /* Scheduler TimerId for use in Scheduler Tasks */
+ u32 schedTimerNexttimeoutMs; /* Next timeout time for the current timer */
+#endif
+
+#ifdef CSR_WIFI_FSM_MUTEX_ENABLE
+#ifdef CSR_WIFI_FSM_TRANSITION_LOCK
+ CsrMutexHandle transitionLock; /* Lock when calling transition functions */
+#endif
+#endif
+
+#ifdef CSR_LOG_ENABLE
+ CsrWifiFsmOnCreateFnPtr onCreate; /* Debug Transition Callback */
+ CsrWifiFsmOnTransitionFnPtr onTransition; /* Debug Transition Callback */
+ CsrWifiFsmOnTransitionFnPtr onUnhandedCallback; /* Unhanded event Callback */
+ CsrWifiFsmOnStateChangeFnPtr onStateChange; /* Debug State Change Callback */
+ CsrWifiFsmOnEventFnPtr onIgnoreCallback; /* Ignore event Callback */
+ CsrWifiFsmOnEventFnPtr onSaveCallback; /* Save event Callback */
+ CsrWifiFsmOnEventFnPtr onErrorCallback; /* Error event Callback */
+ CsrWifiFsmOnEventFnPtr onInvalidCallback; /* Invalid event Callback */
+#endif
+#ifdef CSR_WIFI_FSM_DUMP_ENABLE
+ u16 masterTransitionNumber; /* Increments on every transition */
+#endif
+};
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* CSR_WIFI_FSM_TYPES_H */
diff --git a/drivers/staging/csr/csr_wifi_hip_card.h b/drivers/staging/csr/csr_wifi_hip_card.h
new file mode 100644
index 000000000000..9caf88c7887d
--- /dev/null
+++ b/drivers/staging/csr/csr_wifi_hip_card.h
@@ -0,0 +1,123 @@
+/*****************************************************************************
+
+ (c) Cambridge Silicon Radio Limited 2012
+ All rights reserved and confidential information of CSR
+
+ Refer to LICENSE.txt included with this source for details
+ on the license terms.
+
+*****************************************************************************/
+
+/*
+ ******************************************************************************
+ * FILE : csr_wifi_hip_card.h
+ *
+ * PURPOSE : Defines abstract interface for hardware specific functions.
+ * Note, this is a different file from one of the same name in the
+ * Windows driver.
+ *
+ *****************************************************************************
+ */
+#ifndef __CARD_H__
+#define __CARD_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include "csr_wifi_hip_card_sdio.h"
+#include "csr_wifi_hip_signals.h"
+#include "csr_wifi_hip_unifi_udi.h"
+
+
+/*****************************************************************************
+ * CardEnableInt -
+ */
+CsrResult CardEnableInt(card_t *card);
+
+/*****************************************************************************
+ * CardGenInt -
+ */
+CsrResult CardGenInt(card_t *card);
+
+/*****************************************************************************
+ * CardPendingInt -
+ */
+CsrResult CardPendingInt(card_t *card, u8 *pintr);
+
+/*****************************************************************************
+ * CardDisableInt -
+ */
+CsrResult CardDisableInt(card_t *card);
+
+/*****************************************************************************
+ * CardClearInt -
+ */
+CsrResult CardClearInt(card_t *card);
+
+/*****************************************************************************
+ * CardDisable -
+ */
+void CardDisable(card_t *card);
+
+/*****************************************************************************
+ * CardIntEnabled -
+ */
+CsrResult CardIntEnabled(card_t *card, u8 *enabled);
+
+/*****************************************************************************
+ * CardGetDataSlotSize
+ */
+u16 CardGetDataSlotSize(card_t *card);
+
+/*****************************************************************************
+ * CardWriteBulkData -
+ */
+CsrResult CardWriteBulkData(card_t *card, card_signal_t *csptr, unifi_TrafficQueue queue);
+
+
+/*****************************************************************************
+ * CardClearFromHostDataSlot -
+ */
+void CardClearFromHostDataSlot(card_t *card, const s16 aSlotNum);
+
+#ifdef CSR_WIFI_REQUEUE_PACKET_TO_HAL
+/*****************************************************************************
+ * CardClearFromHostDataSlotWithoutFreeingBulkData - Clear the data stot
+ * without freeing the bulk data
+ */
+
+void CardClearFromHostDataSlotWithoutFreeingBulkData(card_t *card, const s16 aSlotNum);
+#endif
+
+/*****************************************************************************
+ * CardGetFreeFromHostDataSlots -
+ */
+u16 CardGetFreeFromHostDataSlots(card_t *card);
+
+u16 CardAreAllFromHostDataSlotsEmpty(card_t *card);
+
+CsrResult card_start_processor(card_t *card, enum unifi_dbg_processors_select which);
+
+CsrResult card_wait_for_firmware_to_start(card_t *card, u32 *paddr);
+
+CsrResult unifi_dl_firmware(card_t *card, void *arg);
+CsrResult unifi_dl_patch(card_t *card, void *arg, u32 boot_ctrl);
+CsrResult unifi_do_loader_op(card_t *card, u32 op_addr, u8 opcode);
+void* unifi_dl_fw_read_start(card_t *card, s8 is_fw);
+
+CsrResult unifi_coredump_handle_request(card_t *card);
+
+CsrResult ConvertCsrSdioToCsrHipResult(card_t *card, CsrResult csrResult);
+#ifdef CSR_WIFI_HIP_DEBUG_OFFLINE
+void unifi_debug_log_to_buf(const char *fmt, ...);
+void unifi_debug_string_to_buf(const char *str);
+void unifi_debug_hex_to_buf(const char *buff, u16 length);
+#endif
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __CARD_H__ */
diff --git a/drivers/staging/csr/csr_wifi_hip_card_sdio.c b/drivers/staging/csr/csr_wifi_hip_card_sdio.c
new file mode 100644
index 000000000000..44ab00c53fec
--- /dev/null
+++ b/drivers/staging/csr/csr_wifi_hip_card_sdio.c
@@ -0,0 +1,4163 @@
+/*****************************************************************************
+
+ (c) Cambridge Silicon Radio Limited 2012
+ All rights reserved and confidential information of CSR
+
+ Refer to LICENSE.txt included with this source for details
+ on the license terms.
+
+*****************************************************************************/
+
+/*
+ * ---------------------------------------------------------------------------
+ * FILE: csr_wifi_hip_card_sdio.c
+ *
+ * PURPOSE: Implementation of the Card API for SDIO.
+ *
+ * NOTES:
+ * CardInit() is called from the SDIO probe callback when a card is
+ * inserted. This performs the basic SDIO initialisation, enabling i/o
+ * etc.
+ *
+ * ---------------------------------------------------------------------------
+ */
+#include <linux/slab.h>
+#include "csr_wifi_hip_unifi.h"
+#include "csr_wifi_hip_conversions.h"
+#include "csr_wifi_hip_unifiversion.h"
+#include "csr_wifi_hip_card.h"
+#include "csr_wifi_hip_card_sdio.h"
+#include "csr_wifi_hip_chiphelper.h"
+
+
+/* Time to wait between attempts to read MAILBOX0 */
+#define MAILBOX1_TIMEOUT 10 /* in millisecs */
+#define MAILBOX1_ATTEMPTS 200 /* 2 seconds */
+
+#define MAILBOX2_TIMEOUT 5 /* in millisecs */
+#define MAILBOX2_ATTEMPTS 10 /* 50ms */
+
+#define RESET_SETTLE_DELAY 25 /* in millisecs */
+
+static CsrResult card_init_slots(card_t *card);
+static CsrResult card_hw_init(card_t *card);
+static CsrResult firmware_present_in_flash(card_t *card);
+static void bootstrap_chip_hw(card_t *card);
+static CsrResult unifi_reset_hardware(card_t *card);
+static CsrResult unifi_hip_init(card_t *card);
+static CsrResult card_access_panic(card_t *card);
+static CsrResult unifi_read_chip_version(card_t *card);
+
+/*
+ * ---------------------------------------------------------------------------
+ * unifi_alloc_card
+ *
+ * Allocate and initialise the card context structure.
+ *
+ * Arguments:
+ * sdio Pointer to SDIO context pointer to pass to low
+ * level i/o functions.
+ * ospriv Pointer to O/S private struct to pass when calling
+ * callbacks to the higher level system.
+ *
+ * Returns:
+ * Pointer to card struct, which represents the driver context or
+ * NULL if the allocation failed.
+ * ---------------------------------------------------------------------------
+ */
+card_t* unifi_alloc_card(CsrSdioFunction *sdio, void *ospriv)
+{
+ card_t *card;
+ u32 i;
+
+ func_enter();
+
+
+ card = kzalloc(sizeof(card_t), GFP_KERNEL);
+ if (card == NULL)
+ {
+ return NULL;
+ }
+
+ card->sdio_if = sdio;
+ card->ospriv = ospriv;
+
+ card->unifi_interrupt_seq = 1;
+
+ /* Make these invalid. */
+ card->proc_select = (u32)(-1);
+ card->dmem_page = (u32)(-1);
+ card->pmem_page = (u32)(-1);
+
+ card->bh_reason_host = 0;
+ card->bh_reason_unifi = 0;
+
+ for (i = 0; i < sizeof(card->tx_q_paused_flag) / sizeof(card->tx_q_paused_flag[0]); i++)
+ {
+ card->tx_q_paused_flag[i] = 0;
+ }
+ card->memory_resources_allocated = 0;
+
+ card->low_power_mode = UNIFI_LOW_POWER_DISABLED;
+ card->periodic_wake_mode = UNIFI_PERIODIC_WAKE_HOST_DISABLED;
+
+ card->host_state = UNIFI_HOST_STATE_AWAKE;
+ card->intmode = CSR_WIFI_INTMODE_DEFAULT;
+
+ /*
+ * Memory resources for buffers are allocated when the chip is initialised
+ * because we need configuration information from the firmware.
+ */
+
+ /*
+ * Initialise wait queues and lists
+ */
+ card->fh_command_queue.q_body = card->fh_command_q_body;
+ card->fh_command_queue.q_length = UNIFI_SOFT_COMMAND_Q_LENGTH;
+
+ for (i = 0; i < UNIFI_NO_OF_TX_QS; i++)
+ {
+ card->fh_traffic_queue[i].q_body = card->fh_traffic_q_body[i];
+ card->fh_traffic_queue[i].q_length = UNIFI_SOFT_TRAFFIC_Q_LENGTH;
+ }
+
+
+ /* Initialise mini-coredump pointers in case no coredump buffers
+ * are requested by the OS layer.
+ */
+ card->request_coredump_on_reset = 0;
+ card->dump_next_write = NULL;
+ card->dump_cur_read = NULL;
+ card->dump_buf = NULL;
+
+#ifdef UNIFI_DEBUG
+ /* Determine offset of LSB in pointer for later alignment sanity check.
+ * Synergy integer types have specific widths, which cause compiler
+ * warnings when casting pointer types, e.g. on 64-bit systems.
+ */
+ {
+ u32 val = 0x01234567;
+
+ if (*((u8 *)&val) == 0x01)
+ {
+ card->lsb = sizeof(void *) - 1; /* BE */
+ }
+ else
+ {
+ card->lsb = 0; /* LE */
+ }
+ }
+#endif
+ func_exit();
+ return card;
+} /* unifi_alloc_card() */
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * unifi_init_card
+ *
+ * Reset the hardware and perform HIP initialization
+ *
+ * Arguments:
+ * card Pointer to card struct
+ *
+ * Returns:
+ * CsrResult code
+ * CSR_RESULT_SUCCESS if successful
+ * ---------------------------------------------------------------------------
+ */
+CsrResult unifi_init_card(card_t *card, s32 led_mask)
+{
+ CsrResult r;
+
+ func_enter();
+
+ if (card == NULL)
+ {
+ func_exit_r(CSR_WIFI_HIP_RESULT_INVALID_VALUE);
+ return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
+ }
+
+ r = unifi_init(card);
+ if (r != CSR_RESULT_SUCCESS)
+ {
+ func_exit_r(r);
+ return r;
+ }
+
+ r = unifi_hip_init(card);
+ if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
+ {
+ func_exit_r(r);
+ return r;
+ }
+ if (r != CSR_RESULT_SUCCESS)
+ {
+ unifi_error(card->ospriv, "Failed to start host protocol.\n");
+ func_exit_r(r);
+ return r;
+ }
+
+ func_exit();
+ return CSR_RESULT_SUCCESS;
+}
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * unifi_init
+ *
+ * Init the hardware.
+ *
+ * Arguments:
+ * card Pointer to card struct
+ *
+ * Returns:
+ * CsrResult code
+ * CSR_RESULT_SUCCESS if successful
+ * ---------------------------------------------------------------------------
+ */
+CsrResult unifi_init(card_t *card)
+{
+ CsrResult r;
+ CsrResult csrResult;
+
+ func_enter();
+
+ if (card == NULL)
+ {
+ func_exit_r(CSR_WIFI_HIP_RESULT_INVALID_VALUE);
+ return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
+ }
+
+ /*
+ * Disable the SDIO interrupts while initialising UniFi.
+ * Re-enable them when f/w is running.
+ */
+ csrResult = CsrSdioInterruptDisable(card->sdio_if);
+ if (csrResult == CSR_SDIO_RESULT_NO_DEVICE)
+ {
+ return CSR_WIFI_HIP_RESULT_NO_DEVICE;
+ }
+
+ /*
+ * UniFi's PLL may start with a slow clock (~ 1 MHz) so initially
+ * set the SDIO bus clock to a similar value or SDIO accesses may
+ * fail.
+ */
+ csrResult = CsrSdioMaxBusClockFrequencySet(card->sdio_if, UNIFI_SDIO_CLOCK_SAFE_HZ);
+ if (csrResult != CSR_RESULT_SUCCESS)
+ {
+ r = ConvertCsrSdioToCsrHipResult(card, csrResult);
+ func_exit_r(r);
+ return r;
+ }
+ card->sdio_clock_speed = UNIFI_SDIO_CLOCK_SAFE_HZ;
+
+ /*
+ * Reset UniFi. Note, this only resets the WLAN function part of the chip,
+ * the SDIO interface is not reset.
+ */
+ unifi_trace(card->ospriv, UDBG1, "Resetting UniFi\n");
+ r = unifi_reset_hardware(card);
+ if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
+ {
+ return r;
+ }
+ if (r != CSR_RESULT_SUCCESS)
+ {
+ unifi_error(card->ospriv, "Failed to reset UniFi\n");
+ func_exit_r(r);
+ return r;
+ }
+
+ /* Reset the power save mode, to be active until the MLME-reset is complete */
+ r = unifi_configure_low_power_mode(card,
+ UNIFI_LOW_POWER_DISABLED, UNIFI_PERIODIC_WAKE_HOST_DISABLED);
+ if (r != CSR_RESULT_SUCCESS)
+ {
+ unifi_error(card->ospriv, "Failed to set power save mode\n");
+ func_exit_r(r);
+ return r;
+ }
+
+ /*
+ * Set initial value of page registers.
+ * The page registers will be maintained by unifi_read...() and
+ * unifi_write...().
+ */
+ card->proc_select = (u32)(-1);
+ card->dmem_page = (u32)(-1);
+ card->pmem_page = (u32)(-1);
+ r = unifi_write_direct16(card, ChipHelper_HOST_WINDOW3_PAGE(card->helper) * 2, 0);
+ if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
+ {
+ return r;
+ }
+ if (r != CSR_RESULT_SUCCESS)
+ {
+ unifi_error(card->ospriv, "Failed to write SHARED_DMEM_PAGE\n");
+ func_exit_r(r);
+ return r;
+ }
+ r = unifi_write_direct16(card, ChipHelper_HOST_WINDOW2_PAGE(card->helper) * 2, 0);
+ if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
+ {
+ return r;
+ }
+ if (r != CSR_RESULT_SUCCESS)
+ {
+ unifi_error(card->ospriv, "Failed to write PROG_MEM2_PAGE\n");
+ func_exit_r(r);
+ return r;
+ }
+
+ /*
+ * If the driver has reset UniFi due to previous SDIO failure, this may
+ * have been due to a chip watchdog reset. In this case, the driver may
+ * have requested a mini-coredump which needs to be captured now the
+ * SDIO interface is alive.
+ */
+ (void)unifi_coredump_handle_request(card);
+
+ /*
+ * Probe to see if the UniFi has ROM/flash to boot from. CSR6xxx should do.
+ */
+ r = firmware_present_in_flash(card);
+ if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
+ {
+ return r;
+ }
+ if (r == CSR_WIFI_HIP_RESULT_NOT_FOUND)
+ {
+ unifi_error(card->ospriv, "No firmware found\n");
+ }
+ else if (r != CSR_RESULT_SUCCESS)
+ {
+ unifi_error(card->ospriv, "Probe for Flash failed\n");
+ }
+
+ func_exit_r(r);
+ return r;
+} /* unifi_init() */
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * unifi_download
+ *
+ * Load the firmware.
+ *
+ * Arguments:
+ * card Pointer to card struct
+ * led_mask Loader LED mask
+ *
+ * Returns:
+ * CSR_RESULT_SUCCESS on success
+ * CsrResult error code on failure.
+ * ---------------------------------------------------------------------------
+ */
+CsrResult unifi_download(card_t *card, s32 led_mask)
+{
+ CsrResult r;
+ void *dlpriv;
+
+ func_enter();
+
+ if (card == NULL)
+ {
+ func_exit_r(CSR_WIFI_HIP_RESULT_INVALID_VALUE);
+ return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
+ }
+
+ /* Set the loader led mask */
+ card->loader_led_mask = led_mask;
+
+ /* Get the firmware file information */
+ unifi_trace(card->ospriv, UDBG1, "downloading firmware...\n");
+
+ dlpriv = unifi_dl_fw_read_start(card, UNIFI_FW_STA);
+ if (dlpriv == NULL)
+ {
+ func_exit_r(CSR_WIFI_HIP_RESULT_NOT_FOUND);
+ return CSR_WIFI_HIP_RESULT_NOT_FOUND;
+ }
+
+ /* Download the firmware. */
+ r = unifi_dl_firmware(card, dlpriv);
+ if (r != CSR_RESULT_SUCCESS)
+ {
+ unifi_error(card->ospriv, "Failed to download firmware\n");
+ func_exit_r(r);
+ return r;
+ }
+
+ /* Free the firmware file information. */
+ unifi_fw_read_stop(card->ospriv, dlpriv);
+
+ func_exit();
+
+ return CSR_RESULT_SUCCESS;
+} /* unifi_download() */
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * unifi_hip_init
+ *
+ * This function performs the f/w initialisation sequence as described
+ * in the Unifi Host Interface Protocol Specification.
+ * It allocates memory for host-side slot data and signal queues.
+ *
+ * Arguments:
+ * card Pointer to card struct
+ *
+ * Returns:
+ * CSR_RESULT_SUCCESS on success or else a CSR error code
+ *
+ * Notes:
+ * The firmware must have been downloaded.
+ * ---------------------------------------------------------------------------
+ */
+static CsrResult unifi_hip_init(card_t *card)
+{
+ CsrResult r;
+ CsrResult csrResult;
+
+ func_enter();
+
+ r = card_hw_init(card);
+ if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
+ {
+ return r;
+ }
+ if (r != CSR_RESULT_SUCCESS)
+ {
+ unifi_error(card->ospriv, "Failed to establish communication with UniFi\n");
+ func_exit_r(r);
+ return r;
+ }
+#ifdef CSR_PRE_ALLOC_NET_DATA
+ /* if there is any preallocated netdata left from the prev session free it now */
+ prealloc_netdata_free(card);
+#endif
+ /*
+ * Allocate memory for host-side slot data and signal queues.
+ * We need the config info read from the firmware to know how much
+ * memory to allocate.
+ */
+ r = card_init_slots(card);
+ if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
+ {
+ return r;
+ }
+ if (r != CSR_RESULT_SUCCESS)
+ {
+ unifi_error(card->ospriv, "Init slots failed: %d\n", r);
+ func_exit_r(r);
+ return r;
+ }
+
+ unifi_trace(card->ospriv, UDBG2, "Sending first UniFi interrupt\n");
+
+ r = unifi_set_host_state(card, UNIFI_HOST_STATE_AWAKE);
+ if (r != CSR_RESULT_SUCCESS)
+ {
+ func_exit_r(r);
+ return r;
+ }
+
+ /* Enable the SDIO interrupts now that the f/w is running. */
+ csrResult = CsrSdioInterruptEnable(card->sdio_if);
+ if (csrResult == CSR_SDIO_RESULT_NO_DEVICE)
+ {
+ return CSR_WIFI_HIP_RESULT_NO_DEVICE;
+ }
+
+ /* Signal the UniFi to start handling messages */
+ r = CardGenInt(card);
+ if (r != CSR_RESULT_SUCCESS)
+ {
+ func_exit_r(r);
+ return r;
+ }
+
+ func_exit();
+
+ return CSR_RESULT_SUCCESS;
+} /* unifi_hip_init() */
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * _build_sdio_config_data
+ *
+ * Unpack the SDIO configuration information from a buffer read from
+ * UniFi into a host structure.
+ * The data is byte-swapped for a big-endian host if necessary by the
+ * UNPACK... macros.
+ *
+ * Arguments:
+ * card Pointer to card struct
+ * cfg_data Destination structure to unpack into.
+ * cfg_data_buf Source buffer to read from. This should be the raw
+ * data read from UniFi.
+ *
+ * Returns:
+ * None.
+ * ---------------------------------------------------------------------------
+ */
+static void _build_sdio_config_data(sdio_config_data_t *cfg_data,
+ const u8 *cfg_data_buf)
+{
+ s16 offset = 0;
+
+ cfg_data->version = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(cfg_data_buf + offset);
+ offset += SIZEOF_UINT16;
+
+ cfg_data->sdio_ctrl_offset = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(cfg_data_buf + offset);
+ offset += SIZEOF_UINT16;
+
+ cfg_data->fromhost_sigbuf_handle = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(cfg_data_buf + offset);
+ offset += SIZEOF_UINT16;
+
+ cfg_data->tohost_sigbuf_handle = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(cfg_data_buf + offset);
+ offset += SIZEOF_UINT16;
+
+ cfg_data->num_fromhost_sig_frags = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(cfg_data_buf + offset);
+ offset += SIZEOF_UINT16;
+
+ cfg_data->num_tohost_sig_frags = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(cfg_data_buf + offset);
+ offset += SIZEOF_UINT16;
+
+ cfg_data->num_fromhost_data_slots = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(cfg_data_buf + offset);
+ offset += SIZEOF_UINT16;
+
+ cfg_data->num_tohost_data_slots = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(cfg_data_buf + offset);
+ offset += SIZEOF_UINT16;
+
+ cfg_data->data_slot_size = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(cfg_data_buf + offset);
+ offset += SIZEOF_UINT16;
+
+ cfg_data->initialised = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(cfg_data_buf + offset);
+ offset += SIZEOF_UINT16;
+
+ cfg_data->overlay_size = CSR_GET_UINT32_FROM_LITTLE_ENDIAN(cfg_data_buf + offset);
+ offset += SIZEOF_UINT32;
+
+ cfg_data->data_slot_round = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(cfg_data_buf + offset);
+ offset += SIZEOF_UINT16;
+
+ cfg_data->sig_frag_size = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(cfg_data_buf + offset);
+ offset += SIZEOF_UINT16;
+
+ cfg_data->tohost_signal_padding = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(cfg_data_buf + offset);
+} /* _build_sdio_config_data() */
+
+
+/*
+ * - Function ----------------------------------------------------------------
+ * card_hw_init()
+ *
+ * Perform the initialisation procedure described in the UniFi Host
+ * Interface Protocol document (section 3.3.8) and read the run-time
+ * configuration information from the UniFi. This is stuff like number
+ * of bulk data slots etc.
+ *
+ * The card enumeration and SD initialisation has already been done by
+ * the SDIO library, see card_sdio_init().
+ *
+ * The initialisation is done when firmware is ready, i.e. this may need
+ * to be called after a f/w download operation.
+ *
+ * The initialisation procedure goes like this:
+ * - Wait for UniFi to start-up by polling SHARED_MAILBOX1
+ * - Find the symbol table and look up SLT_SDIO_SLOT_CONFIG
+ * - Read the config structure
+ * - Check the "SDIO initialised" flag, if not zero do a h/w reset and
+ * start again
+ * - Decide the number of bulk data slots to allocate, allocate them and
+ * set "SDIO initialised" flag (and generate an interrupt) to say so.
+ *
+ * Arguments:
+ * card Pointer to card struct
+ *
+ * Returns:
+ * CSR_RESULT_SUCEESS on success,
+ * a CSR error code on failure
+ *
+ * Notes:
+ * All data in the f/w is stored in a little endian format, without any
+ * padding bytes. Every read from this memory has to be transformed in
+ * host (cpu specific) format, before it is stored in driver's parameters
+ * or/and structures. Athough unifi_card_read16() and unifi_read32() do perform
+ * the convertion internally, unifi_readn() does not.
+ * ---------------------------------------------------------------------------
+ */
+static CsrResult card_hw_init(card_t *card)
+{
+ u32 slut_address;
+ u16 initialised;
+ u16 finger_print;
+ symbol_t slut;
+ sdio_config_data_t *cfg_data;
+ u8 cfg_data_buf[SDIO_CONFIG_DATA_SIZE];
+ CsrResult r;
+ void *dlpriv;
+ s16 major, minor;
+ s16 search_4slut_again;
+ CsrResult csrResult;
+
+ func_enter();
+
+ /*
+ * The device revision from the TPLMID_MANF and TPLMID_CARD fields
+ * of the CIS are available as
+ * card->sdio_if->pDevice->ManfID
+ * card->sdio_if->pDevice->AppID
+ */
+
+ /*
+ * Run in a loop so we can patch.
+ */
+ do
+ {
+ /* Reset these each time around the loop. */
+ search_4slut_again = 0;
+ cfg_data = NULL;
+
+ r = card_wait_for_firmware_to_start(card, &slut_address);
+ if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
+ {
+ return r;
+ }
+ if (r != CSR_RESULT_SUCCESS)
+ {
+ unifi_error(card->ospriv, "Firmware hasn't started\n");
+ func_exit_r(r);
+ return r;
+ }
+ unifi_trace(card->ospriv, UDBG4, "SLUT addr 0x%lX\n", slut_address);
+
+ /*
+ * Firmware has started, but doesn't know full clock configuration yet
+ * as some of the information may be in the MIB. Therefore we set an
+ * initial SDIO clock speed, faster than UNIFI_SDIO_CLOCK_SAFE_HZ, for
+ * the patch download and subsequent firmware initialisation, and
+ * full speed UNIFI_SDIO_CLOCK_MAX_HZ will be set once the f/w tells us
+ * that it is ready.
+ */
+ csrResult = CsrSdioMaxBusClockFrequencySet(card->sdio_if, UNIFI_SDIO_CLOCK_INIT_HZ);
+ if (csrResult != CSR_RESULT_SUCCESS)
+ {
+ r = ConvertCsrSdioToCsrHipResult(card, csrResult);
+ func_exit_r(r);
+ return r;
+ }
+ card->sdio_clock_speed = UNIFI_SDIO_CLOCK_INIT_HZ;
+
+ /*
+ * Check the SLUT fingerprint.
+ * The slut_address is a generic pointer so we must use unifi_card_read16().
+ */
+ unifi_trace(card->ospriv, UDBG4, "Looking for SLUT finger print\n");
+ finger_print = 0;
+ r = unifi_card_read16(card, slut_address, &finger_print);
+ if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
+ {
+ return r;
+ }
+ if (r != CSR_RESULT_SUCCESS)
+ {
+ unifi_error(card->ospriv, "Failed to read SLUT finger print\n");
+ func_exit_r(r);
+ return r;
+ }
+
+ if (finger_print != SLUT_FINGERPRINT)
+ {
+ unifi_error(card->ospriv, "Failed to find Symbol lookup table fingerprint\n");
+ func_exit_r(CSR_RESULT_FAILURE);
+ return CSR_RESULT_FAILURE;
+ }
+
+ /* Symbol table starts imedately after the fingerprint */
+ slut_address += 2;
+
+ /* Search the table until either the end marker is found, or the
+ * loading of patch firmware invalidates the current table.
+ */
+ while (!search_4slut_again)
+ {
+ u16 s;
+ u32 l;
+
+ r = unifi_card_read16(card, slut_address, &s);
+ if (r != CSR_RESULT_SUCCESS)
+ {
+ func_exit_r(r);
+ return r;
+ }
+ slut_address += 2;
+
+ if (s == CSR_SLT_END)
+ {
+ unifi_trace(card->ospriv, UDBG3, " found CSR_SLT_END\n");
+ break;
+ }
+
+ r = unifi_read32(card, slut_address, &l);
+ if (r != CSR_RESULT_SUCCESS)
+ {
+ func_exit_r(r);
+ return r;
+ }
+ slut_address += 4;
+
+ slut.id = s;
+ slut.obj = l;
+
+ unifi_trace(card->ospriv, UDBG3, " found SLUT id %02d.%08lx\n", slut.id, slut.obj);
+ switch (slut.id)
+ {
+ case CSR_SLT_SDIO_SLOT_CONFIG:
+ cfg_data = &card->config_data;
+ /*
+ * unifi_card_readn reads n bytes from the card, where data is stored
+ * in a little endian format, without any padding bytes. So, we
+ * can not just pass the cfg_data pointer or use the
+ * sizeof(sdio_config_data_t) since the structure in the host can
+ * be big endian formatted or have padding bytes for alignment.
+ * We use a char buffer to read the data from the card.
+ */
+ r = unifi_card_readn(card, slut.obj, cfg_data_buf, SDIO_CONFIG_DATA_SIZE);
+ if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
+ {
+ return r;
+ }
+ if (r != CSR_RESULT_SUCCESS)
+ {
+ unifi_error(card->ospriv, "Failed to read config data\n");
+ func_exit_r(r);
+ return r;
+ }
+ /* .. and then we copy the data to the host structure */
+ _build_sdio_config_data(cfg_data, cfg_data_buf);
+
+ /* Make sure the from host data slots are what we expect
+ we reserve 2 for commands and there should be at least
+ 1 left for each access category */
+ if ((cfg_data->num_fromhost_data_slots < UNIFI_RESERVED_COMMAND_SLOTS)
+ || (cfg_data->num_fromhost_data_slots - UNIFI_RESERVED_COMMAND_SLOTS) / UNIFI_NO_OF_TX_QS == 0)
+ {
+ unifi_error(card->ospriv, "From host data slots %d\n", cfg_data->num_fromhost_data_slots);
+ unifi_error(card->ospriv, "need to be (queues * x + 2) (UNIFI_RESERVED_COMMAND_SLOTS for commands)\n");
+ func_exit_r(CSR_RESULT_FAILURE);
+ return CSR_RESULT_FAILURE;
+ }
+
+ /* Configure SDIO to-block-size padding */
+ if (card->sdio_io_block_pad)
+ {
+ /*
+ * Firmware limits the maximum padding size via data_slot_round.
+ * Therefore when padding to whole block sizes, the block size
+ * must be configured correctly by adjusting CSR_WIFI_HIP_SDIO_BLOCK_SIZE.
+ */
+ if (cfg_data->data_slot_round < card->sdio_io_block_size)
+ {
+ unifi_error(card->ospriv,
+ "Configuration error: Block size of %d exceeds f/w data_slot_round of %d\n",
+ card->sdio_io_block_size, cfg_data->data_slot_round);
+ return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
+ }
+
+ /*
+ * To force the To-Host signals to be rounded up to the SDIO block
+ * size, we need to write the To-Host Signal Padding Fragments
+ * field of the SDIO configuration in UniFi.
+ */
+ if ((card->sdio_io_block_size % cfg_data->sig_frag_size) != 0)
+ {
+ unifi_error(card->ospriv, "Configuration error: Can not pad to-host signals.\n");
+ func_exit_r(CSR_WIFI_HIP_RESULT_INVALID_VALUE);
+ return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
+ }
+ cfg_data->tohost_signal_padding = (u16) (card->sdio_io_block_size / cfg_data->sig_frag_size);
+ unifi_info(card->ospriv, "SDIO block size %d requires %d padding chunks\n",
+ card->sdio_io_block_size, cfg_data->tohost_signal_padding);
+ r = unifi_card_write16(card, slut.obj + SDIO_TO_HOST_SIG_PADDING_OFFSET, cfg_data->tohost_signal_padding);
+ if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
+ {
+ return r;
+ }
+ if (r != CSR_RESULT_SUCCESS)
+ {
+ unifi_error(card->ospriv, "Failed to write To-Host Signal Padding Fragments\n");
+ func_exit_r(r);
+ return r;
+ }
+ }
+
+ /* Reconstruct the Generic Pointer address of the
+ * SDIO Control Data Struct.
+ */
+ card->sdio_ctrl_addr = cfg_data->sdio_ctrl_offset | (UNIFI_SH_DMEM << 24);
+ card->init_flag_addr = slut.obj + SDIO_INIT_FLAG_OFFSET;
+ break;
+
+ case CSR_SLT_BUILD_ID_NUMBER:
+ {
+ u32 n;
+ r = unifi_read32(card, slut.obj, &n);
+ if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
+ {
+ return r;
+ }
+ if (r != CSR_RESULT_SUCCESS)
+ {
+ unifi_error(card->ospriv, "Failed to read build id\n");
+ func_exit_r(r);
+ return r;
+ }
+ card->build_id = n;
+ }
+ break;
+
+ case CSR_SLT_BUILD_ID_STRING:
+ r = unifi_readnz(card, slut.obj, card->build_id_string,
+ sizeof(card->build_id_string));
+ if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
+ {
+ return r;
+ }
+ if (r != CSR_RESULT_SUCCESS)
+ {
+ unifi_error(card->ospriv, "Failed to read build string\n");
+ func_exit_r(r);
+ return r;
+ }
+ break;
+
+ case CSR_SLT_PERSISTENT_STORE_DB:
+ break;
+
+ case CSR_SLT_BOOT_LOADER_CONTROL:
+
+ /* This command copies most of the station firmware
+ * image from ROM into program RAM. It also clears
+ * out the zerod data and sets up the initialised
+ * data. */
+ r = unifi_do_loader_op(card, slut.obj + 6, UNIFI_BOOT_LOADER_LOAD_STA);
+ if (r != CSR_RESULT_SUCCESS)
+ {
+ unifi_error(card->ospriv, "Failed to write loader load image command\n");
+ func_exit_r(r);
+ return r;
+ }
+
+ dlpriv = unifi_dl_fw_read_start(card, UNIFI_FW_STA);
+
+ /* dlpriv might be NULL, we still need to do the do_loader_op step. */
+ if (dlpriv != NULL)
+ {
+ /* Download the firmware. */
+ r = unifi_dl_patch(card, dlpriv, slut.obj);
+
+ /* Free the firmware file information. */
+ unifi_fw_read_stop(card->ospriv, dlpriv);
+
+ if (r != CSR_RESULT_SUCCESS)
+ {
+ unifi_error(card->ospriv, "Failed to patch firmware\n");
+ func_exit_r(r);
+ return r;
+ }
+ }
+
+ /* This command starts the firmware image that we want (the
+ * station by default) with any patches required applied. */
+ r = unifi_do_loader_op(card, slut.obj + 6, UNIFI_BOOT_LOADER_RESTART);
+ if (r != CSR_RESULT_SUCCESS)
+ {
+ unifi_error(card->ospriv, "Failed to write loader restart command\n");
+ func_exit_r(r);
+ return r;
+ }
+
+ /* The now running patch f/w defines a new SLUT data structure -
+ * the current one is no longer valid. We must drop out of the
+ * processing loop and enumerate the new SLUT (which may appear
+ * at a different offset).
+ */
+ search_4slut_again = 1;
+ break;
+
+ case CSR_SLT_PANIC_DATA_PHY:
+ card->panic_data_phy_addr = slut.obj;
+ break;
+
+ case CSR_SLT_PANIC_DATA_MAC:
+ card->panic_data_mac_addr = slut.obj;
+ break;
+
+ default:
+ /* do nothing */
+ break;
+ }
+ } /* while */
+ } while (search_4slut_again);
+
+ /* Did we find the Config Data ? */
+ if (cfg_data == NULL)
+ {
+ unifi_error(card->ospriv, "Failed to find SDIO_SLOT_CONFIG Symbol\n");
+ func_exit_r(CSR_RESULT_FAILURE);
+ return CSR_RESULT_FAILURE;
+ }
+
+ /*
+ * Has ths card already been initialised?
+ * If so, return an error so we do a h/w reset and start again.
+ */
+ r = unifi_card_read16(card, card->init_flag_addr, &initialised);
+ if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
+ {
+ return r;
+ }
+ if (r != CSR_RESULT_SUCCESS)
+ {
+ unifi_error(card->ospriv, "Failed to read init flag at %08lx\n",
+ card->init_flag_addr);
+ func_exit_r(r);
+ return r;
+ }
+ if (initialised != 0)
+ {
+ func_exit_r(CSR_RESULT_FAILURE);
+ return CSR_RESULT_FAILURE;
+ }
+
+
+ /*
+ * Now check the UniFi firmware version
+ */
+ major = (cfg_data->version >> 8) & 0xFF;
+ minor = cfg_data->version & 0xFF;
+ unifi_info(card->ospriv, "UniFi f/w protocol version %d.%d (driver %d.%d)\n",
+ major, minor,
+ UNIFI_HIP_MAJOR_VERSION, UNIFI_HIP_MINOR_VERSION);
+
+ unifi_info(card->ospriv, "Firmware build %u: %s\n",
+ card->build_id, card->build_id_string);
+
+ if (major != UNIFI_HIP_MAJOR_VERSION)
+ {
+ unifi_error(card->ospriv, "UniFi f/w protocol major version (%d) is different from driver (v%d.%d)\n",
+ major, UNIFI_HIP_MAJOR_VERSION, UNIFI_HIP_MINOR_VERSION);
+#ifndef CSR_WIFI_DISABLE_HIP_VERSION_CHECK
+ func_exit_r(CSR_RESULT_FAILURE);
+ return CSR_RESULT_FAILURE;
+#endif
+ }
+ if (minor < UNIFI_HIP_MINOR_VERSION)
+ {
+ unifi_error(card->ospriv, "UniFi f/w protocol version (v%d.%d) is older than minimum required by driver (v%d.%d).\n",
+ major, minor,
+ UNIFI_HIP_MAJOR_VERSION, UNIFI_HIP_MINOR_VERSION);
+#ifndef CSR_WIFI_DISABLE_HIP_VERSION_CHECK
+ func_exit_r(CSR_RESULT_FAILURE);
+ return CSR_RESULT_FAILURE;
+#endif
+ }
+
+ /* Read panic codes from a previous firmware panic. If the firmware has
+ * not panicked since power was applied (e.g. power-off hard reset)
+ * the stored panic codes will not be updated.
+ */
+ unifi_read_panic(card);
+
+ func_exit();
+ return CSR_RESULT_SUCCESS;
+} /* card_hw_init() */
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * card_wait_for_unifi_to_reset
+ *
+ * Waits for a reset to complete by polling the WLAN function enable
+ * bit (which is cleared on reset).
+ *
+ * Arguments:
+ * card Pointer to card struct
+ *
+ * Returns:
+ * CSR_RESULT_SUCCESS on success, CSR error code on failure.
+ * ---------------------------------------------------------------------------
+ */
+static CsrResult card_wait_for_unifi_to_reset(card_t *card)
+{
+ s16 i;
+ CsrResult r;
+ u8 io_enable;
+ CsrResult csrResult;
+
+ func_enter();
+
+ r = CSR_RESULT_SUCCESS;
+ for (i = 0; i < MAILBOX2_ATTEMPTS; i++)
+ {
+ unifi_trace(card->ospriv, UDBG1, "waiting for reset to complete, attempt %d\n", i);
+ if (card->chip_id > SDIO_CARD_ID_UNIFI_2)
+ {
+ /* It's quite likely that this read will timeout for the
+ * first few tries - especially if we have reset via
+ * DBG_RESET.
+ */
+#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_SDIO_TRACE)
+ unifi_debug_log_to_buf("m0@%02X=", SDIO_IO_READY);
+#endif
+ csrResult = CsrSdioF0Read8(card->sdio_if, SDIO_IO_READY, &io_enable);
+#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_SDIO_TRACE)
+ if (csrResult != CSR_RESULT_SUCCESS)
+ {
+ unifi_debug_log_to_buf("error=%X\n", csrResult);
+ }
+ else
+ {
+ unifi_debug_log_to_buf("%X\n", io_enable);
+ }
+#endif
+ if (csrResult == CSR_SDIO_RESULT_NO_DEVICE)
+ {
+ return CSR_WIFI_HIP_RESULT_NO_DEVICE;
+ }
+ r = CSR_RESULT_SUCCESS;
+ if (csrResult != CSR_RESULT_SUCCESS)
+ {
+ r = ConvertCsrSdioToCsrHipResult(card, csrResult);
+ }
+ }
+ else
+ {
+ r = sdio_read_f0(card, SDIO_IO_ENABLE, &io_enable);
+ }
+ if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
+ {
+ return r;
+ }
+ if (r == CSR_RESULT_SUCCESS)
+ {
+ u16 mbox2;
+ s16 enabled = io_enable & (1 << card->function);
+
+ if (!enabled)
+ {
+ unifi_trace(card->ospriv, UDBG1,
+ "Reset complete (function %d is disabled) in ~ %u msecs\n",
+ card->function, i * MAILBOX2_TIMEOUT);
+
+ /* Enable WLAN function and verify MAILBOX2 is zero'd */
+ csrResult = CsrSdioFunctionEnable(card->sdio_if);
+ if (csrResult != CSR_RESULT_SUCCESS)
+ {
+ r = ConvertCsrSdioToCsrHipResult(card, csrResult);
+ unifi_error(card->ospriv, "CsrSdioFunctionEnable failed %d\n", r);
+ break;
+ }
+ }
+
+ r = unifi_read_direct16(card, ChipHelper_SDIO_HIP_HANDSHAKE(card->helper) * 2, &mbox2);
+ if (r != CSR_RESULT_SUCCESS)
+ {
+ unifi_error(card->ospriv, "read HIP_HANDSHAKE failed %d\n", r);
+ break;
+ }
+ if (mbox2 != 0)
+ {
+ unifi_error(card->ospriv, "MAILBOX2 non-zero after reset (mbox2 = %04x)\n", mbox2);
+ r = CSR_RESULT_FAILURE;
+ }
+ break;
+ }
+ else
+ {
+ if (card->chip_id > SDIO_CARD_ID_UNIFI_2)
+ {
+ /* We ignore read failures for the first few reads,
+ * they are probably benign. */
+ if (i > MAILBOX2_ATTEMPTS / 4)
+ {
+ unifi_trace(card->ospriv, UDBG1, "Failed to read CCCR IO Ready register while polling for reset\n");
+ }
+ }
+ else
+ {
+ unifi_trace(card->ospriv, UDBG1, "Failed to read CCCR IO Enable register while polling for reset\n");
+ }
+ }
+ CsrThreadSleep(MAILBOX2_TIMEOUT);
+ }
+
+ if (r == CSR_RESULT_SUCCESS && i == MAILBOX2_ATTEMPTS)
+ {
+ unifi_trace(card->ospriv, UDBG1, "Timeout waiting for UniFi to complete reset\n");
+ r = CSR_RESULT_FAILURE;
+ }
+
+ func_exit();
+ return r;
+} /* card_wait_for_unifi_to_reset() */
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * card_wait_for_unifi_to_disable
+ *
+ * Waits for the function to become disabled by polling the
+ * IO_READY bit.
+ *
+ * Arguments:
+ * card Pointer to card struct
+ *
+ * Returns:
+ * CSR_RESULT_SUCCESS on success, CSR error code on failure.
+ *
+ * Notes: This function can only be used with
+ * card->chip_id > SDIO_CARD_ID_UNIFI_2
+ * ---------------------------------------------------------------------------
+ */
+static CsrResult card_wait_for_unifi_to_disable(card_t *card)
+{
+ s16 i;
+ CsrResult r;
+ u8 io_enable;
+ CsrResult csrResult;
+
+ func_enter();
+
+ if (card->chip_id <= SDIO_CARD_ID_UNIFI_2)
+ {
+ unifi_error(card->ospriv,
+ "Function reset method not supported for chip_id=%d\n",
+ card->chip_id);
+ func_exit();
+ return CSR_RESULT_FAILURE;
+ }
+
+ r = CSR_RESULT_SUCCESS;
+ for (i = 0; i < MAILBOX2_ATTEMPTS; i++)
+ {
+ unifi_trace(card->ospriv, UDBG1, "waiting for disable to complete, attempt %d\n", i);
+
+ /*
+ * It's quite likely that this read will timeout for the
+ * first few tries - especially if we have reset via
+ * DBG_RESET.
+ */
+#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_SDIO_TRACE)
+ unifi_debug_log_to_buf("r0@%02X=", SDIO_IO_READY);
+#endif
+ csrResult = CsrSdioF0Read8(card->sdio_if, SDIO_IO_READY, &io_enable);
+#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_SDIO_TRACE)
+ if (csrResult != CSR_RESULT_SUCCESS)
+ {
+ unifi_debug_log_to_buf("error=%X\n", csrResult);
+ }
+ else
+ {
+ unifi_debug_log_to_buf("%X\n", io_enable);
+ }
+#endif
+ if (csrResult == CSR_SDIO_RESULT_NO_DEVICE)
+ {
+ return CSR_WIFI_HIP_RESULT_NO_DEVICE;
+ }
+ if (csrResult == CSR_RESULT_SUCCESS)
+ {
+ s16 enabled = io_enable & (1 << card->function);
+ r = CSR_RESULT_SUCCESS;
+ if (!enabled)
+ {
+ unifi_trace(card->ospriv, UDBG1,
+ "Disable complete (function %d is disabled) in ~ %u msecs\n",
+ card->function, i * MAILBOX2_TIMEOUT);
+
+ break;
+ }
+ }
+ else
+ {
+ /*
+ * We ignore read failures for the first few reads,
+ * they are probably benign.
+ */
+ r = ConvertCsrSdioToCsrHipResult(card, csrResult);
+ if (i > (MAILBOX2_ATTEMPTS / 4))
+ {
+ unifi_trace(card->ospriv, UDBG1,
+ "Failed to read CCCR IO Ready register while polling for disable\n");
+ }
+ }
+ CsrThreadSleep(MAILBOX2_TIMEOUT);
+ }
+
+ if ((r == CSR_RESULT_SUCCESS) && (i == MAILBOX2_ATTEMPTS))
+ {
+ unifi_trace(card->ospriv, UDBG1, "Timeout waiting for UniFi to complete disable\n");
+ r = CSR_RESULT_FAILURE;
+ }
+
+ func_exit();
+ return r;
+} /* card_wait_for_unifi_to_reset() */
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * card_wait_for_firmware_to_start
+ *
+ * Polls the MAILBOX1 register for a non-zero value.
+ * Then reads MAILBOX0 and forms the two values into a 32-bit address
+ * which is returned to the caller.
+ *
+ * Arguments:
+ * card Pointer to card struct
+ * paddr Pointer to receive the UniFi address formed
+ * by concatenating MAILBOX1 and MAILBOX0.
+ *
+ * Returns:
+ * CSR_RESULT_SUCCESS on success, CSR error code on failure.
+ * ---------------------------------------------------------------------------
+ */
+CsrResult card_wait_for_firmware_to_start(card_t *card, u32 *paddr)
+{
+ s32 i;
+ u16 mbox0, mbox1;
+ CsrResult r;
+
+ func_enter();
+
+ /*
+ * Wait for UniFi to initialise its data structures by polling
+ * the SHARED_MAILBOX1 register.
+ * Experience shows this is typically 120ms.
+ */
+ CsrThreadSleep(MAILBOX1_TIMEOUT);
+
+ mbox1 = 0;
+ unifi_trace(card->ospriv, UDBG1, "waiting for MAILBOX1 to be non-zero...\n");
+ for (i = 0; i < MAILBOX1_ATTEMPTS; i++)
+ {
+ r = unifi_read_direct16(card, ChipHelper_MAILBOX1(card->helper) * 2, &mbox1);
+ if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
+ {
+ return r;
+ }
+ if (r != CSR_RESULT_SUCCESS)
+ {
+ /* These reads can fail if UniFi isn't up yet, so try again */
+ unifi_warning(card->ospriv, "Failed to read UniFi Mailbox1 register\n");
+ }
+
+ if ((r == CSR_RESULT_SUCCESS) && (mbox1 != 0))
+ {
+ unifi_trace(card->ospriv, UDBG1, "MAILBOX1 ready (0x%04X) in %u millisecs\n",
+ mbox1, i * MAILBOX1_TIMEOUT);
+
+ /* Read the MAILBOX1 again in case we caught the value as it
+ * changed. */
+ r = unifi_read_direct16(card, ChipHelper_MAILBOX1(card->helper) * 2, &mbox1);
+ if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
+ {
+ return r;
+ }
+ if (r != CSR_RESULT_SUCCESS)
+ {
+ unifi_error(card->ospriv, "Failed to read UniFi Mailbox1 register for second time\n");
+ func_exit_r(r);
+ return r;
+ }
+ unifi_trace(card->ospriv, UDBG1, "MAILBOX1 value=0x%04X\n", mbox1);
+
+ break;
+ }
+
+ CsrThreadSleep(MAILBOX1_TIMEOUT);
+ if ((i % 100) == 99)
+ {
+ unifi_trace(card->ospriv, UDBG2, "MAILBOX1 not ready (0x%X), still trying...\n", mbox1);
+ }
+ }
+
+ if ((r == CSR_RESULT_SUCCESS) && (mbox1 == 0))
+ {
+ unifi_trace(card->ospriv, UDBG1, "Timeout waiting for firmware to start, Mailbox1 still 0 after %d ms\n",
+ MAILBOX1_ATTEMPTS * MAILBOX1_TIMEOUT);
+ func_exit_r(CSR_RESULT_FAILURE);
+ return CSR_RESULT_FAILURE;
+ }
+
+
+ /*
+ * Complete the reset handshake by setting MAILBOX2 to 0xFFFF
+ */
+ r = unifi_write_direct16(card, ChipHelper_SDIO_HIP_HANDSHAKE(card->helper) * 2, 0xFFFF);
+ if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
+ {
+ return r;
+ }
+ if (r != CSR_RESULT_SUCCESS)
+ {
+ unifi_error(card->ospriv, "Failed to write f/w startup handshake to MAILBOX2\n");
+ func_exit_r(r);
+ return r;
+ }
+
+
+ /*
+ * Read the Symbol Look Up Table (SLUT) offset.
+ * Top 16 bits are in mbox1, read the lower 16 bits from mbox0.
+ */
+ mbox0 = 0;
+ r = unifi_read_direct16(card, ChipHelper_MAILBOX0(card->helper) * 2, &mbox0);
+ if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
+ {
+ return r;
+ }
+ if (r != CSR_RESULT_SUCCESS)
+ {
+ unifi_error(card->ospriv, "Failed to read UniFi Mailbox0 register\n");
+ func_exit_r(r);
+ return r;
+ }
+
+ *paddr = (((u32)mbox1 << 16) | mbox0);
+
+ func_exit();
+ return CSR_RESULT_SUCCESS;
+} /* card_wait_for_firmware_to_start() */
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * unifi_capture_panic
+ *
+ * Attempt to capture panic codes from the firmware. This may involve
+ * warm reset of the chip to regain access following a watchdog reset.
+ *
+ * Arguments:
+ * card Pointer to card struct
+ *
+ * Returns:
+ * CSR_RESULT_SUCCESS if panic codes were captured, or none available
+ * CSR_RESULT_FAILURE if the driver could not access function 1
+ * ---------------------------------------------------------------------------
+ */
+CsrResult unifi_capture_panic(card_t *card)
+{
+ func_enter();
+
+ /* The firmware must have previously initialised to read the panic addresses
+ * from the SLUT
+ */
+ if (!card->panic_data_phy_addr || !card->panic_data_mac_addr)
+ {
+ func_exit();
+ return CSR_RESULT_SUCCESS;
+ }
+
+ /* Ensure we can access function 1 following a panic/watchdog reset */
+ if (card_access_panic(card) == CSR_RESULT_SUCCESS)
+ {
+ /* Read the panic codes */
+ unifi_read_panic(card);
+ }
+ else
+ {
+ unifi_info(card->ospriv, "Unable to read panic codes");
+ }
+
+ func_exit();
+ return CSR_RESULT_SUCCESS;
+}
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * card_access_panic
+ * Attempt to read the WLAN SDIO function in order to read panic codes
+ * and perform various reset steps to regain access if the read fails.
+ *
+ * Arguments:
+ * card Pointer to card struct
+ *
+ * Returns:
+ * CSR_RESULT_SUCCESS if panic codes can be read
+ * CSR error code if panic codes can not be read
+ * ---------------------------------------------------------------------------
+ */
+static CsrResult card_access_panic(card_t *card)
+{
+ u16 data_u16 = 0;
+ s32 i;
+ CsrResult r, sr;
+
+ func_enter();
+
+ /* A chip version of zero means that the version never got succesfully read
+ * during reset. In this case give up because it will not be possible to
+ * verify the chip version.
+ */
+ if (!card->chip_version)
+ {
+ unifi_info(card->ospriv, "Unknown chip version\n");
+ return CSR_RESULT_FAILURE;
+ }
+
+ /* Ensure chip is awake or access to function 1 will fail */
+ r = unifi_set_host_state(card, UNIFI_HOST_STATE_AWAKE);
+ if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
+ {
+ return r;
+ }
+ if (r != CSR_RESULT_SUCCESS)
+ {
+ unifi_error(card->ospriv, "unifi_set_host_state() failed %d\n", r);
+ return CSR_RESULT_FAILURE; /* Card is probably unpowered */
+ }
+ CsrThreadSleep(20);
+
+ for (i = 0; i < 3; i++)
+ {
+ sr = CsrSdioRead16(card->sdio_if, CHIP_HELPER_UNIFI_GBL_CHIP_VERSION * 2, &data_u16);
+ if (sr != CSR_RESULT_SUCCESS || data_u16 != card->chip_version)
+ {
+ unifi_info(card->ospriv, "Failed to read valid chip version sr=%d (0x%04x want 0x%04x) try %d\n",
+ sr, data_u16, card->chip_version, i);
+
+ /* Set clock speed low */
+ sr = CsrSdioMaxBusClockFrequencySet(card->sdio_if, UNIFI_SDIO_CLOCK_SAFE_HZ);
+ if (sr != CSR_RESULT_SUCCESS)
+ {
+ unifi_error(card->ospriv, "CsrSdioMaxBusClockFrequencySet() failed1 %d\n", sr);
+ r = ConvertCsrSdioToCsrHipResult(card, sr);
+ }
+ card->sdio_clock_speed = UNIFI_SDIO_CLOCK_SAFE_HZ;
+
+ /* First try re-enabling function in case a f/w watchdog reset disabled it */
+ if (i == 0)
+ {
+ unifi_info(card->ospriv, "Try function enable\n");
+ sr = CsrSdioFunctionEnable(card->sdio_if);
+ if (sr != CSR_RESULT_SUCCESS)
+ {
+ r = ConvertCsrSdioToCsrHipResult(card, sr);
+ unifi_error(card->ospriv, "CsrSdioFunctionEnable failed %d (HIP %d)\n", sr, r);
+ }
+ continue;
+ }
+
+ /* Second try, set awake */
+ unifi_info(card->ospriv, "Try set awake\n");
+
+ /* Ensure chip is awake */
+ r = unifi_set_host_state(card, UNIFI_HOST_STATE_AWAKE);
+ if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
+ {
+ return r;
+ }
+ if (r != CSR_RESULT_SUCCESS)
+ {
+ unifi_error(card->ospriv, "unifi_set_host_state() failed2 %d\n", r);
+ }
+
+ /* Set clock speed low in case setting the host state raised it, which
+ * would only happen if host state was previously TORPID
+ */
+ sr = CsrSdioMaxBusClockFrequencySet(card->sdio_if, UNIFI_SDIO_CLOCK_SAFE_HZ);
+ if (sr != CSR_RESULT_SUCCESS)
+ {
+ unifi_error(card->ospriv, "CsrSdioMaxBusClockFrequencySet() failed2 %d\n", sr);
+ }
+ card->sdio_clock_speed = UNIFI_SDIO_CLOCK_SAFE_HZ;
+
+ if (i == 1)
+ {
+ continue;
+ }
+
+ /* Perform a s/w reset to preserve as much as the card state as possible,
+ * (mainly the preserve RAM). The context will be lost for coredump - but as we
+ * were unable to access the WLAN function for panic, the coredump would have
+ * also failed without a reset.
+ */
+ unifi_info(card->ospriv, "Try s/w reset\n");
+
+ r = unifi_card_hard_reset(card);
+ if (r != CSR_RESULT_SUCCESS)
+ {
+ unifi_error(card->ospriv, "unifi_card_hard_reset() failed %d\n", r);
+ }
+ }
+ else
+ {
+ if (i > 0)
+ {
+ unifi_info(card->ospriv, "Read chip version 0x%x after %d retries\n", data_u16, i);
+ }
+ break;
+ }
+ }
+
+ r = ConvertCsrSdioToCsrHipResult(card, sr);
+ func_exit_r(r);
+ return r;
+}
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * unifi_read_panic
+ * Reads, saves and prints panic codes stored by the firmware in UniFi's
+ * preserve RAM by the last panic that occurred since chip was powered.
+ * Nothing is saved if the panic codes are read as zero.
+ *
+ * Arguments:
+ * card Pointer to card struct
+ *
+ * Returns:
+ * ---------------------------------------------------------------------------
+ */
+void unifi_read_panic(card_t *card)
+{
+ CsrResult r;
+ u16 p_code, p_arg;
+
+ func_enter();
+
+ /* The firmware must have previously initialised to read the panic addresses
+ * from the SLUT
+ */
+ if (!card->panic_data_phy_addr || !card->panic_data_mac_addr)
+ {
+ return;
+ }
+
+ /* Get the panic data from PHY */
+ r = unifi_card_read16(card, card->panic_data_phy_addr, &p_code);
+ if (r != CSR_RESULT_SUCCESS)
+ {
+ unifi_error(card->ospriv, "capture_panic: unifi_read16 %08x failed %d\n", card->panic_data_phy_addr, r);
+ p_code = 0;
+ }
+ if (p_code)
+ {
+ r = unifi_card_read16(card, card->panic_data_phy_addr + 2, &p_arg);
+ if (r != CSR_RESULT_SUCCESS)
+ {
+ unifi_error(card->ospriv, "capture_panic: unifi_read16 %08x failed %d\n", card->panic_data_phy_addr + 2, r);
+ }
+ unifi_error(card->ospriv, "Last UniFi PHY PANIC %04x arg %04x\n", p_code, p_arg);
+ card->last_phy_panic_code = p_code;
+ card->last_phy_panic_arg = p_arg;
+ }
+
+ /* Get the panic data from MAC */
+ r = unifi_card_read16(card, card->panic_data_mac_addr, &p_code);
+ if (r != CSR_RESULT_SUCCESS)
+ {
+ unifi_error(card->ospriv, "capture_panic: unifi_read16 %08x failed %d\n", card->panic_data_mac_addr, r);
+ p_code = 0;
+ }
+ if (p_code)
+ {
+ r = unifi_card_read16(card, card->panic_data_mac_addr + 2, &p_arg);
+ if (r != CSR_RESULT_SUCCESS)
+ {
+ unifi_error(card->ospriv, "capture_panic: unifi_read16 %08x failed %d\n", card->panic_data_mac_addr + 2, r);
+ }
+ unifi_error(card->ospriv, "Last UniFi MAC PANIC %04x arg %04x\n", p_code, p_arg);
+ card->last_mac_panic_code = p_code;
+ card->last_mac_panic_arg = p_arg;
+ }
+
+ func_exit();
+}
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * card_allocate_memory_resources
+ *
+ * Allocates memory for the from-host, to-host bulk data slots,
+ * soft queue buffers and bulk data buffers.
+ *
+ * Arguments:
+ * card Pointer to card struct
+ *
+ * Returns:
+ * CSR_RESULT_SUCCESS on success, CSR error code on failure.
+ * ---------------------------------------------------------------------------
+ */
+static CsrResult card_allocate_memory_resources(card_t *card)
+{
+ s16 n, i, k, r;
+ sdio_config_data_t *cfg_data;
+
+ func_enter();
+
+ /* Reset any state carried forward from a previous life */
+ card->fh_command_queue.q_rd_ptr = 0;
+ card->fh_command_queue.q_wr_ptr = 0;
+ (void)CsrSnprintf(card->fh_command_queue.name, UNIFI_QUEUE_NAME_MAX_LENGTH,
+ "fh_cmd_q");
+ for (i = 0; i < UNIFI_NO_OF_TX_QS; i++)
+ {
+ card->fh_traffic_queue[i].q_rd_ptr = 0;
+ card->fh_traffic_queue[i].q_wr_ptr = 0;
+ (void)CsrSnprintf(card->fh_traffic_queue[i].name,
+ UNIFI_QUEUE_NAME_MAX_LENGTH, "fh_data_q%d", i);
+ }
+#ifndef CSR_WIFI_HIP_TA_DISABLE
+ unifi_ta_sampling_init(card);
+#endif
+ /* Convenience short-cut */
+ cfg_data = &card->config_data;
+
+ /*
+ * Allocate memory for the from-host and to-host signal buffers.
+ */
+ card->fh_buffer.buf = kmalloc(UNIFI_FH_BUF_SIZE, GFP_KERNEL);
+ if (card->fh_buffer.buf == NULL)
+ {
+ unifi_error(card->ospriv, "Failed to allocate memory for F-H signals\n");
+ func_exit_r(CSR_WIFI_HIP_RESULT_NO_MEMORY);
+ return CSR_WIFI_HIP_RESULT_NO_MEMORY;
+ }
+ card->fh_buffer.bufsize = UNIFI_FH_BUF_SIZE;
+ card->fh_buffer.ptr = card->fh_buffer.buf;
+ card->fh_buffer.count = 0;
+
+ card->th_buffer.buf = kmalloc(UNIFI_FH_BUF_SIZE, GFP_KERNEL);
+ if (card->th_buffer.buf == NULL)
+ {
+ unifi_error(card->ospriv, "Failed to allocate memory for T-H signals\n");
+ func_exit_r(CSR_WIFI_HIP_RESULT_NO_MEMORY);
+ return CSR_WIFI_HIP_RESULT_NO_MEMORY;
+ }
+ card->th_buffer.bufsize = UNIFI_FH_BUF_SIZE;
+ card->th_buffer.ptr = card->th_buffer.buf;
+ card->th_buffer.count = 0;
+
+
+ /*
+ * Allocate memory for the from-host and to-host bulk data slots.
+ * This is done as separate kmallocs because lots of smaller
+ * allocations are more likely to succeed than one huge one.
+ */
+
+ /* Allocate memory for the array of pointers */
+ n = cfg_data->num_fromhost_data_slots;
+
+ unifi_trace(card->ospriv, UDBG3, "Alloc from-host resources, %d slots.\n", n);
+ card->from_host_data = kmalloc(n * sizeof(slot_desc_t), GFP_KERNEL);
+ if (card->from_host_data == NULL)
+ {
+ unifi_error(card->ospriv, "Failed to allocate memory for F-H bulk data array\n");
+ func_exit_r(CSR_WIFI_HIP_RESULT_NO_MEMORY);
+ return CSR_WIFI_HIP_RESULT_NO_MEMORY;
+ }
+
+ /* Initialise from-host bulk data slots */
+ for (i = 0; i < n; i++)
+ {
+ UNIFI_INIT_BULK_DATA(&card->from_host_data[i].bd);
+ }
+
+ /* Allocate memory for the array used for slot host tag mapping */
+ card->fh_slot_host_tag_record = kmalloc(n * sizeof(u32), GFP_KERNEL);
+
+ if (card->fh_slot_host_tag_record == NULL)
+ {
+ unifi_error(card->ospriv, "Failed to allocate memory for F-H slot host tag mapping array\n");
+ func_exit_r(CSR_WIFI_HIP_RESULT_NO_MEMORY);
+ return CSR_WIFI_HIP_RESULT_NO_MEMORY;
+ }
+
+ /* Initialise host tag entries for from-host bulk data slots */
+ for (i = 0; i < n; i++)
+ {
+ card->fh_slot_host_tag_record[i] = CSR_WIFI_HIP_RESERVED_HOST_TAG;
+ }
+
+
+ /* Allocate memory for the array of pointers */
+ n = cfg_data->num_tohost_data_slots;
+
+ unifi_trace(card->ospriv, UDBG3, "Alloc to-host resources, %d slots.\n", n);
+ card->to_host_data = kmalloc(n * sizeof(bulk_data_desc_t), GFP_KERNEL);
+ if (card->to_host_data == NULL)
+ {
+ unifi_error(card->ospriv, "Failed to allocate memory for T-H bulk data array\n");
+ func_exit_r(CSR_WIFI_HIP_RESULT_NO_MEMORY);
+ return CSR_WIFI_HIP_RESULT_NO_MEMORY;
+ }
+
+ /* Initialise to-host bulk data slots */
+ for (i = 0; i < n; i++)
+ {
+ UNIFI_INIT_BULK_DATA(&card->to_host_data[i]);
+ }
+
+ /*
+ * Initialise buffers for soft Q
+ */
+ for (i = 0; i < UNIFI_SOFT_COMMAND_Q_LENGTH; i++)
+ {
+ for (r = 0; r < UNIFI_MAX_DATA_REFERENCES; r++)
+ {
+ UNIFI_INIT_BULK_DATA(&card->fh_command_q_body[i].bulkdata[r]);
+ }
+ }
+
+ for (k = 0; k < UNIFI_NO_OF_TX_QS; k++)
+ {
+ for (i = 0; i < UNIFI_SOFT_TRAFFIC_Q_LENGTH; i++)
+ {
+ for (r = 0; r < UNIFI_MAX_DATA_REFERENCES; r++)
+ {
+ UNIFI_INIT_BULK_DATA(&card->fh_traffic_q_body[k][i].bulkdata[r]);
+ }
+ }
+ }
+
+ card->memory_resources_allocated = 1;
+
+ func_exit();
+ return CSR_RESULT_SUCCESS;
+} /* card_allocate_memory_resources() */
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * unifi_free_bulk_data
+ *
+ * Free the data associated to a bulk data structure.
+ *
+ * Arguments:
+ * card Pointer to card struct
+ * bulk_data_slot Pointer to bulk data structure
+ *
+ * Returns:
+ * None.
+ *
+ * ---------------------------------------------------------------------------
+ */
+static void unifi_free_bulk_data(card_t *card, bulk_data_desc_t *bulk_data_slot)
+{
+ if (bulk_data_slot->data_length != 0)
+ {
+ unifi_net_data_free(card->ospriv, bulk_data_slot);
+ }
+} /* unifi_free_bulk_data() */
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * card_free_memory_resources
+ *
+ * Frees memory allocated for the from-host, to-host bulk data slots,
+ * soft queue buffers and bulk data buffers.
+ *
+ * Arguments:
+ * card Pointer to card struct
+ *
+ * Returns:
+ * None.
+ * ---------------------------------------------------------------------------
+ */
+static void card_free_memory_resources(card_t *card)
+{
+ func_enter();
+
+ unifi_trace(card->ospriv, UDBG1, "Freeing card memory resources.\n");
+
+ /* Clear our internal queues */
+ unifi_cancel_pending_signals(card);
+
+
+ kfree(card->to_host_data);
+ card->to_host_data = NULL;
+
+ kfree(card->from_host_data);
+ card->from_host_data = NULL;
+
+ /* free the memory for slot host tag mapping array */
+ kfree(card->fh_slot_host_tag_record);
+ card->fh_slot_host_tag_record = NULL;
+
+ kfree(card->fh_buffer.buf);
+ card->fh_buffer.ptr = card->fh_buffer.buf = NULL;
+ card->fh_buffer.bufsize = 0;
+ card->fh_buffer.count = 0;
+
+ kfree(card->th_buffer.buf);
+ card->th_buffer.ptr = card->th_buffer.buf = NULL;
+ card->th_buffer.bufsize = 0;
+ card->th_buffer.count = 0;
+
+
+ card->memory_resources_allocated = 0;
+
+ func_exit();
+} /* card_free_memory_resources() */
+
+
+static void card_init_soft_queues(card_t *card)
+{
+ s16 i;
+
+ func_enter();
+
+ unifi_trace(card->ospriv, UDBG1, "Initialising internal signal queues.\n");
+ /* Reset any state carried forward from a previous life */
+ card->fh_command_queue.q_rd_ptr = 0;
+ card->fh_command_queue.q_wr_ptr = 0;
+ (void)CsrSnprintf(card->fh_command_queue.name, UNIFI_QUEUE_NAME_MAX_LENGTH,
+ "fh_cmd_q");
+ for (i = 0; i < UNIFI_NO_OF_TX_QS; i++)
+ {
+ card->fh_traffic_queue[i].q_rd_ptr = 0;
+ card->fh_traffic_queue[i].q_wr_ptr = 0;
+ (void)CsrSnprintf(card->fh_traffic_queue[i].name,
+ UNIFI_QUEUE_NAME_MAX_LENGTH, "fh_data_q%d", i);
+ }
+#ifndef CSR_WIFI_HIP_TA_DISABLE
+ unifi_ta_sampling_init(card);
+#endif
+ func_exit();
+}
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * unifi_cancel_pending_signals
+ *
+ * Free the signals and associated bulk data, pending in the core.
+ *
+ * Arguments:
+ * card Pointer to card struct
+ *
+ * Returns:
+ * None.
+ * ---------------------------------------------------------------------------
+ */
+void unifi_cancel_pending_signals(card_t *card)
+{
+ s16 i, n, r;
+ func_enter();
+
+ unifi_trace(card->ospriv, UDBG1, "Canceling pending signals.\n");
+
+ if (card->to_host_data)
+ {
+ /*
+ * Free any bulk data buffers allocated for the t-h slots
+ * This will clear all buffers that did not make it to
+ * unifi_receive_event() before cancel was request.
+ */
+ n = card->config_data.num_tohost_data_slots;
+ unifi_trace(card->ospriv, UDBG3, "Freeing to-host resources, %d slots.\n", n);
+ for (i = 0; i < n; i++)
+ {
+ unifi_free_bulk_data(card, &card->to_host_data[i]);
+ }
+ }
+
+ /*
+ * If any of the from-host bulk data has reached the card->from_host_data
+ * but not UniFi, we need to free the buffers here.
+ */
+ if (card->from_host_data)
+ {
+ /* Free any bulk data buffers allocated for the f-h slots */
+ n = card->config_data.num_fromhost_data_slots;
+ unifi_trace(card->ospriv, UDBG3, "Freeing from-host resources, %d slots.\n", n);
+ for (i = 0; i < n; i++)
+ {
+ unifi_free_bulk_data(card, &card->from_host_data[i].bd);
+ }
+
+ for (i = 0; i < UNIFI_NO_OF_TX_QS; i++)
+ {
+ card->dynamic_slot_data.from_host_used_slots[i] = 0;
+ card->dynamic_slot_data.from_host_max_slots[i] = 0;
+ card->dynamic_slot_data.from_host_reserved_slots[i] = 0;
+ }
+ }
+
+ /*
+ * Free any bulk data buffers allocated in the soft queues.
+ * This covers the case where a bulk data pointer has reached the soft queue
+ * but not the card->from_host_data.
+ */
+ unifi_trace(card->ospriv, UDBG3, "Freeing cmd q resources.\n");
+ for (i = 0; i < UNIFI_SOFT_COMMAND_Q_LENGTH; i++)
+ {
+ for (r = 0; r < UNIFI_MAX_DATA_REFERENCES; r++)
+ {
+ unifi_free_bulk_data(card, &card->fh_command_q_body[i].bulkdata[r]);
+ }
+ }
+
+ unifi_trace(card->ospriv, UDBG3, "Freeing traffic q resources.\n");
+ for (n = 0; n < UNIFI_NO_OF_TX_QS; n++)
+ {
+ for (i = 0; i < UNIFI_SOFT_TRAFFIC_Q_LENGTH; i++)
+ {
+ for (r = 0; r < UNIFI_MAX_DATA_REFERENCES; r++)
+ {
+ unifi_free_bulk_data(card, &card->fh_traffic_q_body[n][i].bulkdata[r]);
+ }
+ }
+ }
+
+ card_init_soft_queues(card);
+
+ func_exit();
+} /* unifi_cancel_pending_signals() */
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * unifi_free_card
+ *
+ * Free the memory allocated for the card structure and buffers.
+ *
+ * Notes:
+ * The porting layer is responsible for freeing any mini-coredump buffers
+ * allocated when it called unifi_coredump_init(), by calling
+ * unifi_coredump_free() before calling this function.
+ *
+ * Arguments:
+ * card Pointer to card struct
+ *
+ * Returns:
+ * None.
+ * ---------------------------------------------------------------------------
+ */
+void unifi_free_card(card_t *card)
+{
+ func_enter();
+#ifdef CSR_PRE_ALLOC_NET_DATA
+ prealloc_netdata_free(card);
+#endif
+ /* Free any memory allocated. */
+ card_free_memory_resources(card);
+
+ /* Warn if caller didn't free coredump buffers */
+ if (card->dump_buf)
+ {
+ unifi_error(card->ospriv, "Caller should call unifi_coredump_free()\n");
+ unifi_coredump_free(card); /* free anyway to prevent memory leak */
+ }
+
+ kfree(card);
+
+ func_exit();
+} /* unifi_free_card() */
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * card_init_slots
+ *
+ * Allocate memory for host-side slot data and signal queues.
+ *
+ * Arguments:
+ * card Pointer to card object
+ *
+ * Returns:
+ * CSR error code.
+ * ---------------------------------------------------------------------------
+ */
+static CsrResult card_init_slots(card_t *card)
+{
+ CsrResult r;
+ u8 i;
+
+ func_enter();
+
+ /* Allocate the buffers we need, only once. */
+ if (card->memory_resources_allocated == 1)
+ {
+ card_free_memory_resources(card);
+ }
+ else
+ {
+ /* Initialise our internal command and traffic queues */
+ card_init_soft_queues(card);
+ }
+
+ r = card_allocate_memory_resources(card);
+ if (r != CSR_RESULT_SUCCESS)
+ {
+ unifi_error(card->ospriv, "Failed to allocate card memory resources.\n");
+ card_free_memory_resources(card);
+ func_exit_r(r);
+ return r;
+ }
+
+ if (card->sdio_ctrl_addr == 0)
+ {
+ unifi_error(card->ospriv, "Failed to find config struct!\n");
+ func_exit_r(CSR_WIFI_HIP_RESULT_INVALID_VALUE);
+ return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
+ }
+
+ /*
+ * Set initial counts.
+ */
+
+ card->from_host_data_head = 0;
+
+ /* Get initial signal counts from UniFi, in case it has not been reset. */
+ {
+ u16 s;
+
+ /* Get the from-host-signals-written count */
+ r = unifi_card_read16(card, card->sdio_ctrl_addr + 0, &s);
+ if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
+ {
+ return r;
+ }
+ if (r != CSR_RESULT_SUCCESS)
+ {
+ unifi_error(card->ospriv, "Failed to read from-host sig written count\n");
+ func_exit_r(r);
+ return r;
+ }
+ card->from_host_signals_w = (s16)s;
+
+ /* Get the to-host-signals-written count */
+ r = unifi_card_read16(card, card->sdio_ctrl_addr + 6, &s);
+ if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
+ {
+ return r;
+ }
+ if (r != CSR_RESULT_SUCCESS)
+ {
+ unifi_error(card->ospriv, "Failed to read to-host sig read count\n");
+ func_exit_r(r);
+ return r;
+ }
+ card->to_host_signals_r = (s16)s;
+ }
+
+ /* Set Initialised flag. */
+ r = unifi_card_write16(card, card->init_flag_addr, 0x0001);
+ if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
+ {
+ return r;
+ }
+ if (r != CSR_RESULT_SUCCESS)
+ {
+ unifi_error(card->ospriv, "Failed to write initialised flag\n");
+ func_exit_r(r);
+ return r;
+ }
+
+ /* Dynamic queue reservation */
+ memset(&card->dynamic_slot_data, 0, sizeof(card_dynamic_slot_t));
+
+ for (i = 0; i < UNIFI_NO_OF_TX_QS; i++)
+ {
+ card->dynamic_slot_data.from_host_max_slots[i] = card->config_data.num_fromhost_data_slots -
+ UNIFI_RESERVED_COMMAND_SLOTS;
+ card->dynamic_slot_data.queue_stable[i] = FALSE;
+ }
+
+ card->dynamic_slot_data.packets_interval = UNIFI_PACKETS_INTERVAL;
+
+ func_exit();
+ return CSR_RESULT_SUCCESS;
+} /* card_init_slots() */
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * unifi_set_udi_hook
+ *
+ * Registers the udi hook that reports the sent signals to the core.
+ *
+ * Arguments:
+ * card Pointer to the card context struct
+ * udi_fn Pointer to the callback function.
+ *
+ * Returns:
+ * CSR_WIFI_HIP_RESULT_INVALID_VALUE if the card pointer is invalid,
+ * CSR_RESULT_SUCCESS on success.
+ * ---------------------------------------------------------------------------
+ */
+CsrResult unifi_set_udi_hook(card_t *card, udi_func_t udi_fn)
+{
+ if (card == NULL)
+ {
+ return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
+ }
+
+ if (card->udi_hook == NULL)
+ {
+ card->udi_hook = udi_fn;
+ }
+
+ return CSR_RESULT_SUCCESS;
+} /* unifi_set_udi_hook() */
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * unifi_remove_udi_hook
+ *
+ * Removes the udi hook that reports the sent signals from the core.
+ *
+ * Arguments:
+ * card Pointer to the card context struct
+ * udi_fn Pointer to the callback function.
+ *
+ * Returns:
+ * CSR_WIFI_HIP_RESULT_INVALID_VALUE if the card pointer is invalid,
+ * CSR_RESULT_SUCCESS on success.
+ * ---------------------------------------------------------------------------
+ */
+CsrResult unifi_remove_udi_hook(card_t *card, udi_func_t udi_fn)
+{
+ if (card == NULL)
+ {
+ return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
+ }
+
+ if (card->udi_hook == udi_fn)
+ {
+ card->udi_hook = NULL;
+ }
+
+ return CSR_RESULT_SUCCESS;
+} /* unifi_remove_udi_hook() */
+
+
+static void CardReassignDynamicReservation(card_t *card)
+{
+ u8 i;
+
+ func_enter();
+
+ unifi_trace(card->ospriv, UDBG5, "Packets Txed %d %d %d %d\n",
+ card->dynamic_slot_data.packets_txed[0],
+ card->dynamic_slot_data.packets_txed[1],
+ card->dynamic_slot_data.packets_txed[2],
+ card->dynamic_slot_data.packets_txed[3]);
+
+ /* Clear reservation and recalculate max slots */
+ for (i = 0; i < UNIFI_NO_OF_TX_QS; i++)
+ {
+ card->dynamic_slot_data.queue_stable[i] = FALSE;
+ card->dynamic_slot_data.from_host_reserved_slots[i] = 0;
+ card->dynamic_slot_data.from_host_max_slots[i] = card->config_data.num_fromhost_data_slots -
+ UNIFI_RESERVED_COMMAND_SLOTS;
+ card->dynamic_slot_data.packets_txed[i] = 0;
+
+ unifi_trace(card->ospriv, UDBG5, "CardReassignDynamicReservation: queue %d reserved %d Max %d\n", i,
+ card->dynamic_slot_data.from_host_reserved_slots[i],
+ card->dynamic_slot_data.from_host_max_slots[i]);
+ }
+
+ card->dynamic_slot_data.total_packets_txed = 0;
+ func_exit();
+}
+
+
+/* Algorithm to dynamically reserve slots. The logic is based mainly on the outstanding queue
+ * length. Slots are reserved for particular queues during an interval and cleared after the interval.
+ * Each queue has three associated variables.. a) used slots - the number of slots currently occupied
+ * by the queue b) reserved slots - number of slots reserved specifically for the queue c) max slots - total
+ * slots that this queue can actually use (may be higher than reserved slots and is dependent on reserved slots
+ * for other queues).
+ * This function is called when there are no slots available for a queue. It checks to see if there are enough
+ * unreserved slots sufficient for this request. If available these slots are reserved for the queue.
+ * If there are not enough unreserved slots, a fair share for each queue is calculated based on the total slots
+ * and the number of active queues (any queue with existing reservation is considered active). Queues needing
+ * less than their fair share are allowed to have the previously reserved slots. The remaining slots are
+ * distributed evenly among queues that need more than the fair share
+ *
+ * A better scheme would take current bandwidth per AC into consideration when reserving slots. An
+ * implementation scheme could consider the relative time/service period for slots in an AC. If the firmware
+ * services other ACs faster than a particular AC (packets wait in the slots longer) then it is fair to reserve
+ * less slots for the AC
+ */
+static void CardCheckDynamicReservation(card_t *card, unifi_TrafficQueue queue)
+{
+ u16 q_len, active_queues = 0, excess_queue_slots, div_extra_slots,
+ queue_fair_share, reserved_slots = 0, q, excess_need_queues = 0, unmovable_slots = 0;
+ s32 i;
+ q_t *sigq;
+ u16 num_data_slots = card->config_data.num_fromhost_data_slots - UNIFI_RESERVED_COMMAND_SLOTS;
+
+ func_enter();
+
+ /* Calculate the pending queue length */
+ sigq = &card->fh_traffic_queue[queue];
+ q_len = CSR_WIFI_HIP_Q_SLOTS_USED(sigq);
+
+ if (q_len <= card->dynamic_slot_data.from_host_reserved_slots[queue])
+ {
+ unifi_trace(card->ospriv, UDBG5, "queue %d q_len %d already has that many reserved slots, exiting\n", queue, q_len);
+ func_exit();
+ return;
+ }
+
+ /* Upper limit */
+ if (q_len > num_data_slots)
+ {
+ q_len = num_data_slots;
+ }
+
+ for (i = 0; i < UNIFI_NO_OF_TX_QS; i++)
+ {
+ if (i != (s32)queue)
+ {
+ reserved_slots += card->dynamic_slot_data.from_host_reserved_slots[i];
+ }
+ if ((i == (s32)queue) || (card->dynamic_slot_data.from_host_reserved_slots[i] > 0))
+ {
+ active_queues++;
+ }
+ }
+
+ unifi_trace(card->ospriv, UDBG5, "CardCheckDynamicReservation: queue %d q_len %d\n", queue, q_len);
+ unifi_trace(card->ospriv, UDBG5, "Active queues %d reserved slots on other queues %d\n",
+ active_queues, reserved_slots);
+
+ if (reserved_slots + q_len <= num_data_slots)
+ {
+ card->dynamic_slot_data.from_host_reserved_slots[queue] = q_len;
+ if (q_len == num_data_slots)
+ {
+ /* This is the common case when just 1 stream is going */
+ card->dynamic_slot_data.queue_stable[queue] = TRUE;
+ }
+ }
+ else
+ {
+ queue_fair_share = num_data_slots / active_queues;
+ unifi_trace(card->ospriv, UDBG5, "queue fair share %d\n", queue_fair_share);
+
+ /* Evenly distribute slots among active queues */
+ /* Find out the queues that need excess of fair share. Also find slots allocated
+ * to queues less than their fair share, these slots cannot be reallocated (unmovable slots) */
+
+ card->dynamic_slot_data.from_host_reserved_slots[queue] = q_len;
+
+ for (i = 0; i < UNIFI_NO_OF_TX_QS; i++)
+ {
+ if (card->dynamic_slot_data.from_host_reserved_slots[i] > queue_fair_share)
+ {
+ excess_need_queues++;
+ }
+ else
+ {
+ unmovable_slots += card->dynamic_slot_data.from_host_reserved_slots[i];
+ }
+ }
+
+ unifi_trace(card->ospriv, UDBG5, "Excess need queues %d\n", excess_need_queues);
+
+ /* Now find the slots per excess demand queue */
+ excess_queue_slots = (num_data_slots - unmovable_slots) / excess_need_queues;
+ div_extra_slots = (num_data_slots - unmovable_slots) - excess_queue_slots * excess_need_queues;
+ for (i = UNIFI_NO_OF_TX_QS - 1; i >= 0; i--)
+ {
+ if (card->dynamic_slot_data.from_host_reserved_slots[i] > excess_queue_slots)
+ {
+ card->dynamic_slot_data.from_host_reserved_slots[i] = excess_queue_slots;
+ if (div_extra_slots > 0)
+ {
+ card->dynamic_slot_data.from_host_reserved_slots[i]++;
+ div_extra_slots--;
+ }
+ /* No more slots will be allocated to this queue during the current interval */
+ card->dynamic_slot_data.queue_stable[i] = TRUE;
+ unifi_trace(card->ospriv, UDBG5, "queue stable %d\n", i);
+ }
+ }
+ }
+
+ /* Redistribute max slots */
+ for (i = 0; i < UNIFI_NO_OF_TX_QS; i++)
+ {
+ reserved_slots = 0;
+ for (q = 0; q < UNIFI_NO_OF_TX_QS; q++)
+ {
+ if (i != q)
+ {
+ reserved_slots += card->dynamic_slot_data.from_host_reserved_slots[q];
+ }
+ }
+
+ card->dynamic_slot_data.from_host_max_slots[i] = num_data_slots - reserved_slots;
+ unifi_trace(card->ospriv, UDBG5, "queue %d reserved %d Max %d\n", i,
+ card->dynamic_slot_data.from_host_reserved_slots[i],
+ card->dynamic_slot_data.from_host_max_slots[i]);
+ }
+
+ func_exit();
+}
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * CardClearFromHostDataSlot
+ *
+ * Clear a the given data slot, making it available again.
+ *
+ * Arguments:
+ * card Pointer to Card object
+ * slot Index of the signal slot to clear.
+ *
+ * Returns:
+ * None.
+ * ---------------------------------------------------------------------------
+ */
+void CardClearFromHostDataSlot(card_t *card, const s16 slot)
+{
+ u8 queue = card->from_host_data[slot].queue;
+ const void *os_data_ptr = card->from_host_data[slot].bd.os_data_ptr;
+
+ func_enter();
+
+ if (card->from_host_data[slot].bd.data_length == 0)
+ {
+ unifi_warning(card->ospriv,
+ "Surprise: request to clear an already free FH data slot: %d\n",
+ slot);
+ func_exit();
+ return;
+ }
+
+ if (os_data_ptr == NULL)
+ {
+ unifi_warning(card->ospriv,
+ "Clearing FH data slot %d: has null payload, len=%d\n",
+ slot, card->from_host_data[slot].bd.data_length);
+ }
+
+ /* Free card->from_host_data[slot].bd.os_net_ptr here. */
+ /* Mark slot as free by setting length to 0. */
+ unifi_free_bulk_data(card, &card->from_host_data[slot].bd);
+ if (queue < UNIFI_NO_OF_TX_QS)
+ {
+ if (card->dynamic_slot_data.from_host_used_slots[queue] == 0)
+ {
+ unifi_error(card->ospriv, "Goofed up used slots q = %d used slots = %d\n",
+ queue,
+ card->dynamic_slot_data.from_host_used_slots[queue]);
+ }
+ else
+ {
+ card->dynamic_slot_data.from_host_used_slots[queue]--;
+ }
+ card->dynamic_slot_data.packets_txed[queue]++;
+ card->dynamic_slot_data.total_packets_txed++;
+ if (card->dynamic_slot_data.total_packets_txed >= card->dynamic_slot_data.packets_interval)
+ {
+ CardReassignDynamicReservation(card);
+ }
+ }
+
+ unifi_trace(card->ospriv, UDBG4, "CardClearFromHostDataSlot: slot %d recycled %p\n", slot, os_data_ptr);
+
+ func_exit();
+} /* CardClearFromHostDataSlot() */
+
+
+#ifdef CSR_WIFI_REQUEUE_PACKET_TO_HAL
+/*
+ * ---------------------------------------------------------------------------
+ * CardClearFromHostDataSlotWithoutFreeingBulkData
+ *
+ * Clear the given data slot with out freeing the bulk data.
+ *
+ * Arguments:
+ * card Pointer to Card object
+ * slot Index of the signal slot to clear.
+ *
+ * Returns:
+ * None.
+ * ---------------------------------------------------------------------------
+ */
+void CardClearFromHostDataSlotWithoutFreeingBulkData(card_t *card, const s16 slot)
+{
+ u8 queue = card->from_host_data[slot].queue;
+
+ /* Initialise the from_host data slot so it can be re-used,
+ * Set length field in from_host_data array to 0.
+ */
+ UNIFI_INIT_BULK_DATA(&card->from_host_data[slot].bd);
+
+ queue = card->from_host_data[slot].queue;
+
+ if (queue < UNIFI_NO_OF_TX_QS)
+ {
+ if (card->dynamic_slot_data.from_host_used_slots[queue] == 0)
+ {
+ unifi_error(card->ospriv, "Goofed up used slots q = %d used slots = %d\n",
+ queue,
+ card->dynamic_slot_data.from_host_used_slots[queue]);
+ }
+ else
+ {
+ card->dynamic_slot_data.from_host_used_slots[queue]--;
+ }
+ card->dynamic_slot_data.packets_txed[queue]++;
+ card->dynamic_slot_data.total_packets_txed++;
+ if (card->dynamic_slot_data.total_packets_txed >=
+ card->dynamic_slot_data.packets_interval)
+ {
+ CardReassignDynamicReservation(card);
+ }
+ }
+} /* CardClearFromHostDataSlotWithoutFreeingBulkData() */
+
+
+#endif
+
+u16 CardGetDataSlotSize(card_t *card)
+{
+ return card->config_data.data_slot_size;
+} /* CardGetDataSlotSize() */
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * CardGetFreeFromHostDataSlots
+ *
+ * Retrieve the number of from-host bulk data slots available.
+ *
+ * Arguments:
+ * card Pointer to the card context struct
+ *
+ * Returns:
+ * Number of free from-host bulk data slots.
+ * ---------------------------------------------------------------------------
+ */
+u16 CardGetFreeFromHostDataSlots(card_t *card)
+{
+ u16 i, n = 0;
+
+ func_enter();
+
+ /* First two slots reserved for MLME */
+ for (i = 0; i < card->config_data.num_fromhost_data_slots; i++)
+ {
+ if (card->from_host_data[i].bd.data_length == 0)
+ {
+ /* Free slot */
+ n++;
+ }
+ }
+
+ func_exit();
+ return n;
+} /* CardGetFreeFromHostDataSlots() */
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * CardAreAllFromHostDataSlotsEmpty
+ *
+ * Returns the state of from-host bulk data slots.
+ *
+ * Arguments:
+ * card Pointer to the card context struct
+ *
+ * Returns:
+ * 1 The from-host bulk data slots are all empty (available).
+ * 0 Some or all the from-host bulk data slots are in use.
+ * ---------------------------------------------------------------------------
+ */
+u16 CardAreAllFromHostDataSlotsEmpty(card_t *card)
+{
+ u16 i;
+
+ for (i = 0; i < card->config_data.num_fromhost_data_slots; i++)
+ {
+ if (card->from_host_data[i].bd.data_length != 0)
+ {
+ return 0;
+ }
+ }
+
+ return 1;
+} /* CardGetFreeFromHostDataSlots() */
+
+
+static CsrResult unifi_identify_hw(card_t *card)
+{
+ func_enter();
+
+ card->chip_id = card->sdio_if->sdioId.cardId;
+ card->function = card->sdio_if->sdioId.sdioFunction;
+ card->sdio_io_block_size = card->sdio_if->blockSize;
+
+ /* If SDIO controller doesn't support byte mode CMD53, pad transfers to block sizes */
+ card->sdio_io_block_pad = (card->sdio_if->features & CSR_SDIO_FEATURE_BYTE_MODE)?FALSE : TRUE;
+
+ /*
+ * Setup the chip helper so that we can access the registers (and
+ * also tell what sub-type of HIP we should use).
+ */
+ card->helper = ChipHelper_GetVersionSdio((u8)card->chip_id);
+ if (!card->helper)
+ {
+ unifi_error(card->ospriv, "Null ChipHelper\n");
+ }
+
+ unifi_info(card->ospriv, "Chip ID 0x%02X Function %u Block Size %u Name %s(%s)\n",
+ card->chip_id, card->function, card->sdio_io_block_size,
+ ChipHelper_MarketingName(card->helper),
+ ChipHelper_FriendlyName(card->helper));
+
+ func_exit();
+ return CSR_RESULT_SUCCESS;
+} /* unifi_identify_hw() */
+
+
+static CsrResult unifi_prepare_hw(card_t *card)
+{
+ CsrResult r;
+ CsrResult csrResult;
+ enum unifi_host_state old_state = card->host_state;
+
+ func_enter();
+
+ r = unifi_identify_hw(card);
+ if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
+ {
+ return r;
+ }
+ if (r != CSR_RESULT_SUCCESS)
+ {
+ unifi_error(card->ospriv, "Failed to identify hw\n");
+ func_exit_r(r);
+ return r;
+ }
+
+ unifi_trace(card->ospriv, UDBG1,
+ "%s mode SDIO\n", card->sdio_io_block_pad?"Block" : "Byte");
+ /*
+ * Chip must be a awake or blocks that are asleep may not get
+ * reset. We can only do this after we have read the chip_id.
+ */
+ r = unifi_set_host_state(card, UNIFI_HOST_STATE_AWAKE);
+ if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
+ {
+ return r;
+ }
+
+ if (old_state == UNIFI_HOST_STATE_TORPID)
+ {
+ /* Ensure the initial clock rate is set; if a reset occured when the chip was
+ * TORPID, unifi_set_host_state() may have raised it to MAX.
+ */
+ csrResult = CsrSdioMaxBusClockFrequencySet(card->sdio_if, UNIFI_SDIO_CLOCK_INIT_HZ);
+ if (csrResult != CSR_RESULT_SUCCESS)
+ {
+ r = ConvertCsrSdioToCsrHipResult(card, csrResult);
+ func_exit_r(r);
+ return r;
+ }
+ card->sdio_clock_speed = UNIFI_SDIO_CLOCK_INIT_HZ;
+ }
+
+ /*
+ * The WLAN function must be enabled to access MAILBOX2 and DEBUG_RST
+ * registers.
+ */
+ csrResult = CsrSdioFunctionEnable(card->sdio_if);
+ if (csrResult == CSR_SDIO_RESULT_NO_DEVICE)
+ {
+ return CSR_WIFI_HIP_RESULT_NO_DEVICE;
+ }
+ if (csrResult != CSR_RESULT_SUCCESS)
+ {
+ r = ConvertCsrSdioToCsrHipResult(card, csrResult);
+ /* Can't enable WLAN function. Try resetting the SDIO block. */
+ unifi_error(card->ospriv, "Failed to re-enable function %d.\n", card->function);
+ func_exit_r(r);
+ return r;
+ }
+
+ /*
+ * Poke some registers to make sure the PLL has started,
+ * otherwise memory accesses are likely to fail.
+ */
+ bootstrap_chip_hw(card);
+
+ /* Try to read the chip version from register. */
+ r = unifi_read_chip_version(card);
+ if (r != CSR_RESULT_SUCCESS)
+ {
+ func_exit_r(r);
+ return r;
+ }
+
+ func_exit();
+ return CSR_RESULT_SUCCESS;
+} /* unifi_prepare_hw() */
+
+
+static CsrResult unifi_read_chip_version(card_t *card)
+{
+ u32 gbl_chip_version;
+ CsrResult r;
+ u16 ver;
+
+ func_enter();
+
+ gbl_chip_version = ChipHelper_GBL_CHIP_VERSION(card->helper);
+
+ /* Try to read the chip version from register. */
+ if (gbl_chip_version != 0)
+ {
+ r = unifi_read_direct16(card, gbl_chip_version * 2, &ver);
+ if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
+ {
+ return r;
+ }
+ if (r != CSR_RESULT_SUCCESS)
+ {
+ unifi_error(card->ospriv, "Failed to read GBL_CHIP_VERSION\n");
+ func_exit_r(r);
+ return r;
+ }
+ card->chip_version = ver;
+ }
+ else
+ {
+ unifi_info(card->ospriv, "Unknown Chip ID, cannot locate GBL_CHIP_VERSION\n");
+ r = CSR_RESULT_FAILURE;
+ }
+
+ unifi_info(card->ospriv, "Chip Version 0x%04X\n", card->chip_version);
+
+ func_exit_r(r);
+ return r;
+} /* unifi_read_chip_version() */
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * unifi_reset_hardware
+ *
+ * Execute the UniFi reset sequence.
+ *
+ * Note: This may fail if the chip is going TORPID so retry at
+ * least once.
+ *
+ * Arguments:
+ * card - pointer to card context structure
+ *
+ * Returns:
+ * CSR_RESULT_SUCCESS on success, CSR error otherwise.
+ *
+ * Notes:
+ * Some platforms (e.g. Windows Vista) do not allow access to registers
+ * that are necessary for a software soft reset.
+ * ---------------------------------------------------------------------------
+ */
+static CsrResult unifi_reset_hardware(card_t *card)
+{
+ CsrResult r;
+ u16 new_block_size = UNIFI_IO_BLOCK_SIZE;
+ CsrResult csrResult;
+
+ func_enter();
+
+ /* Errors returned by unifi_prepare_hw() are not critical at this point */
+ r = unifi_prepare_hw(card);
+ if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
+ {
+ return r;
+ }
+
+ /* First try SDIO controller reset, which may power cycle the UniFi, assert
+ * its reset line, or not be implemented depending on the platform.
+ */
+ unifi_info(card->ospriv, "Calling CsrSdioHardReset\n");
+ csrResult = CsrSdioHardReset(card->sdio_if);
+ if (csrResult == CSR_RESULT_SUCCESS)
+ {
+ unifi_info(card->ospriv, "CsrSdioHardReset succeeded on reseting UniFi\n");
+ r = unifi_prepare_hw(card);
+ if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
+ {
+ return r;
+ }
+ if (r != CSR_RESULT_SUCCESS)
+ {
+ unifi_error(card->ospriv, "unifi_prepare_hw failed after hard reset\n");
+ func_exit_r(r);
+ return r;
+ }
+ }
+ else if (csrResult == CSR_SDIO_RESULT_NO_DEVICE)
+ {
+ return CSR_WIFI_HIP_RESULT_NO_DEVICE;
+ }
+ else
+ {
+ /* Falling back to software hard reset methods */
+ unifi_info(card->ospriv, "Falling back to software hard reset\n");
+ r = unifi_card_hard_reset(card);
+ if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
+ {
+ return r;
+ }
+ if (r != CSR_RESULT_SUCCESS)
+ {
+ unifi_error(card->ospriv, "software hard reset failed\n");
+ func_exit_r(r);
+ return r;
+ }
+
+ /* If we fell back to unifi_card_hard_reset() methods, chip version may
+ * not have been read. (Note in the unlikely event that it is zero,
+ * it will be harmlessly read again)
+ */
+ if (card->chip_version == 0)
+ {
+ r = unifi_read_chip_version(card);
+ if (r != CSR_RESULT_SUCCESS)
+ {
+ func_exit_r(r);
+ return r;
+ }
+ }
+ }
+
+#ifdef CSR_WIFI_HIP_SDIO_BLOCK_SIZE
+ new_block_size = CSR_WIFI_HIP_SDIO_BLOCK_SIZE;
+#endif
+
+ /* After hard reset, we need to restore the SDIO block size */
+ csrResult = CsrSdioBlockSizeSet(card->sdio_if, new_block_size);
+ r = ConvertCsrSdioToCsrHipResult(card, csrResult);
+
+ /* Warn if a different block size was achieved by the transport */
+ if (card->sdio_if->blockSize != new_block_size)
+ {
+ unifi_info(card->ospriv,
+ "Actually got block size %d\n", card->sdio_if->blockSize);
+ }
+
+ /* sdio_io_block_size always needs be updated from the achieved block size,
+ * as it is used by the OS layer to allocate memory in unifi_net_malloc().
+ * Controllers which don't support block mode (e.g. CSPI) will report a
+ * block size of zero.
+ */
+ if (card->sdio_if->blockSize == 0)
+ {
+ unifi_info(card->ospriv, "Block size 0, block mode not available\n");
+
+ /* Set sdio_io_block_size to 1 so that unifi_net_data_malloc() has a
+ * sensible rounding value. Elsewhere padding will already be
+ * disabled because the controller supports byte mode.
+ */
+ card->sdio_io_block_size = 1;
+
+ /* Controller features must declare support for byte mode */
+ if (!(card->sdio_if->features & CSR_SDIO_FEATURE_BYTE_MODE))
+ {
+ unifi_error(card->ospriv, "Requires byte mode\n");
+ r = CSR_WIFI_HIP_RESULT_INVALID_VALUE;
+ }
+ }
+ else
+ {
+ /* Padding will be enabled if CSR_SDIO_FEATURE_BYTE_MODE isn't set */
+ card->sdio_io_block_size = card->sdio_if->blockSize;
+ }
+
+
+ func_exit_r(r);
+ return r;
+} /* unifi_reset_hardware() */
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * card_reset_method_io_enable
+ *
+ * Issue a hard reset to the hw writing the IO_ENABLE.
+ *
+ * Arguments:
+ * card Pointer to Card object
+ *
+ * Returns:
+ * 0 on success,
+ * CSR_WIFI_HIP_RESULT_NO_DEVICE if the card was ejected
+ * CSR_RESULT_FAILURE if an SDIO error occurred or if a response
+ * was not seen in the expected time
+ * ---------------------------------------------------------------------------
+ */
+static CsrResult card_reset_method_io_enable(card_t *card)
+{
+ CsrResult r;
+ CsrResult csrResult;
+
+ func_enter();
+
+ /*
+ * This resets only function 1, so should be used in
+ * preference to the method below (CSR_FUNC_EN)
+ */
+ unifi_trace(card->ospriv, UDBG1, "Hard reset (IO_ENABLE)\n");
+
+ csrResult = CsrSdioFunctionDisable(card->sdio_if);
+ if (csrResult == CSR_SDIO_RESULT_NO_DEVICE)
+ {
+ return CSR_WIFI_HIP_RESULT_NO_DEVICE;
+ }
+ if (csrResult != CSR_RESULT_SUCCESS)
+ {
+ r = ConvertCsrSdioToCsrHipResult(card, csrResult);
+ unifi_warning(card->ospriv, "SDIO error writing IO_ENABLE: %d\n", r);
+ }
+ else
+ {
+ /* Delay here to let the reset take affect. */
+ CsrThreadSleep(RESET_SETTLE_DELAY);
+
+ r = card_wait_for_unifi_to_disable(card);
+ if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
+ {
+ return r;
+ }
+
+ if (r == CSR_RESULT_SUCCESS)
+ {
+ r = card_wait_for_unifi_to_reset(card);
+ if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
+ {
+ return r;
+ }
+ }
+ }
+
+ if (r != CSR_RESULT_SUCCESS)
+ {
+ unifi_trace(card->ospriv, UDBG1, "Hard reset (CSR_FUNC_EN)\n");
+
+ r = sdio_write_f0(card, SDIO_CSR_FUNC_EN, 0);
+ if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
+ {
+ return r;
+ }
+ if (r != CSR_RESULT_SUCCESS)
+ {
+ unifi_warning(card->ospriv, "SDIO error writing SDIO_CSR_FUNC_EN: %d\n", r);
+ func_exit_r(r);
+ return r;
+ }
+ else
+ {
+ /* Delay here to let the reset take affect. */
+ CsrThreadSleep(RESET_SETTLE_DELAY);
+
+ r = card_wait_for_unifi_to_reset(card);
+ if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
+ {
+ return r;
+ }
+ }
+ }
+
+ if (r != CSR_RESULT_SUCCESS)
+ {
+ unifi_warning(card->ospriv, "card_reset_method_io_enable failed to reset UniFi\n");
+ }
+
+ func_exit();
+ return r;
+} /* card_reset_method_io_enable() */
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * card_reset_method_dbg_reset
+ *
+ * Issue a hard reset to the hw writing the DBG_RESET.
+ *
+ * Arguments:
+ * card Pointer to Card object
+ *
+ * Returns:
+ * CSR_RESULT_SUCCESS on success,
+ * CSR_WIFI_HIP_RESULT_NO_DEVICE if the card was ejected
+ * CSR_RESULT_FAILURE if an SDIO error occurred or if a response
+ * was not seen in the expected time
+ * ---------------------------------------------------------------------------
+ */
+static CsrResult card_reset_method_dbg_reset(card_t *card)
+{
+ CsrResult r;
+
+ func_enter();
+
+ /*
+ * Prepare UniFi for h/w reset
+ */
+ if (card->host_state == UNIFI_HOST_STATE_TORPID)
+ {
+ r = unifi_set_host_state(card, UNIFI_HOST_STATE_DROWSY);
+ if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
+ {
+ return r;
+ }
+ if (r != CSR_RESULT_SUCCESS)
+ {
+ unifi_error(card->ospriv, "Failed to set UNIFI_HOST_STATE_DROWSY\n");
+ func_exit_r(r);
+ return r;
+ }
+ CsrThreadSleep(5);
+ }
+
+ r = unifi_card_stop_processor(card, UNIFI_PROC_BOTH);
+ if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
+ {
+ return r;
+ }
+ if (r != CSR_RESULT_SUCCESS)
+ {
+ unifi_error(card->ospriv, "Can't stop processors\n");
+ func_exit();
+ return r;
+ }
+
+ unifi_trace(card->ospriv, UDBG1, "Hard reset (DBG_RESET)\n");
+
+ /*
+ * This register write may fail. The debug reset resets
+ * parts of the Function 0 sections of the chip, and
+ * therefore the response cannot be sent back to the host.
+ */
+ r = unifi_write_direct_8_or_16(card, ChipHelper_DBG_RESET(card->helper) * 2, 1);
+ if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
+ {
+ return r;
+ }
+ if (r != CSR_RESULT_SUCCESS)
+ {
+ unifi_warning(card->ospriv, "SDIO error writing DBG_RESET: %d\n", r);
+ func_exit_r(r);
+ return r;
+ }
+
+ /* Delay here to let the reset take affect. */
+ CsrThreadSleep(RESET_SETTLE_DELAY);
+
+ r = card_wait_for_unifi_to_reset(card);
+ if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
+ {
+ return r;
+ }
+ if (r != CSR_RESULT_SUCCESS)
+ {
+ unifi_warning(card->ospriv, "card_reset_method_dbg_reset failed to reset UniFi\n");
+ }
+
+ func_exit();
+ return r;
+} /* card_reset_method_dbg_reset() */
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * unifi_card_hard_reset
+ *
+ * Issue reset to hardware, by writing to registers on the card.
+ * Power to the card is preserved.
+ *
+ * Arguments:
+ * card Pointer to Card object
+ *
+ * Returns:
+ * CSR_RESULT_SUCCESS on success,
+ * CSR_WIFI_HIP_RESULT_NO_DEVICE if the card was ejected
+ * CSR_RESULT_FAILURE if an SDIO error occurred or if a response
+ * was not seen in the expected time
+ * ---------------------------------------------------------------------------
+ */
+CsrResult unifi_card_hard_reset(card_t *card)
+{
+ CsrResult r;
+ const struct chip_helper_reset_values *init_data;
+ u32 chunks;
+
+ func_enter();
+
+ /* Clear cache of page registers */
+ card->proc_select = (u32)(-1);
+ card->dmem_page = (u32)(-1);
+ card->pmem_page = (u32)(-1);
+
+ /*
+ * We need to have a valid card->helper before we use software hard reset.
+ * If unifi_identify_hw() fails to get the card ID, it probably means
+ * that there is no way to talk to the h/w.
+ */
+ r = unifi_identify_hw(card);
+ if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
+ {
+ return r;
+ }
+ if (r != CSR_RESULT_SUCCESS)
+ {
+ unifi_error(card->ospriv, "unifi_card_hard_reset failed to identify h/w\n");
+ func_exit();
+ return r;
+ }
+
+ /* Search for some reset code. */
+ chunks = ChipHelper_HostResetSequence(card->helper, &init_data);
+ if (chunks != 0)
+ {
+ unifi_error(card->ospriv,
+ "Hard reset (Code download) is unsupported\n");
+
+ func_exit_r(CSR_RESULT_FAILURE);
+ return CSR_RESULT_FAILURE;
+ }
+
+ if (card->chip_id > SDIO_CARD_ID_UNIFI_2)
+ {
+ /* The HIP spec considers this a bus-specific reset.
+ * This resets only function 1, so should be used in
+ * preference to the method below (CSR_FUNC_EN)
+ * If this method fails, it means that the f/w is probably
+ * not running. In this case, try the DBG_RESET method.
+ */
+ r = card_reset_method_io_enable(card);
+ if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
+ {
+ return r;
+ }
+ if (r == CSR_RESULT_SUCCESS)
+ {
+ func_exit();
+ return r;
+ }
+ }
+
+ /* Software hard reset */
+ r = card_reset_method_dbg_reset(card);
+
+ func_exit_r(r);
+ return r;
+} /* unifi_card_hard_reset() */
+
+
+/*
+ * ---------------------------------------------------------------------------
+ *
+ * CardGenInt
+ *
+ * Prod the card.
+ * This function causes an internal interrupt to be raised in the
+ * UniFi chip. It is used to signal the firmware that some action has
+ * been completed.
+ * The UniFi Host Interface asks that the value used increments for
+ * debugging purposes.
+ *
+ * Arguments:
+ * card Pointer to Card object
+ *
+ * Returns:
+ * CSR_RESULT_SUCCESS on success,
+ * CSR_WIFI_HIP_RESULT_NO_DEVICE if the card was ejected
+ * CSR_RESULT_FAILURE if an SDIO error occurred or if a response
+ * was not seen in the expected time
+ * ---------------------------------------------------------------------------
+ */
+CsrResult CardGenInt(card_t *card)
+{
+ CsrResult r;
+
+ func_enter();
+
+ if (card->chip_id > SDIO_CARD_ID_UNIFI_2)
+ {
+ r = sdio_write_f0(card, SDIO_CSR_FROM_HOST_SCRATCH0,
+ (u8)card->unifi_interrupt_seq);
+ }
+ else
+ {
+ r = unifi_write_direct_8_or_16(card,
+ ChipHelper_SHARED_IO_INTERRUPT(card->helper) * 2,
+ (u8)card->unifi_interrupt_seq);
+ }
+ if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
+ {
+ return r;
+ }
+ if (r != CSR_RESULT_SUCCESS)
+ {
+ unifi_error(card->ospriv, "SDIO error writing UNIFI_SHARED_IO_INTERRUPT: %d\n", r);
+ func_exit_r(r);
+ return r;
+ }
+
+ card->unifi_interrupt_seq++;
+
+ func_exit();
+ return CSR_RESULT_SUCCESS;
+} /* CardGenInt() */
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * CardEnableInt
+ *
+ * Enable the outgoing SDIO interrupt from UniFi to the host.
+ *
+ * Arguments:
+ * card Pointer to Card object
+ *
+ * Returns:
+ * CSR_RESULT_SUCCESS on success,
+ * CSR_WIFI_HIP_RESULT_NO_DEVICE if the card was ejected
+ * CSR_RESULT_FAILURE if an SDIO error occurred,
+ * ---------------------------------------------------------------------------
+ */
+CsrResult CardEnableInt(card_t *card)
+{
+ CsrResult r;
+ u8 int_enable;
+
+ r = sdio_read_f0(card, SDIO_INT_ENABLE, &int_enable);
+ if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
+ {
+ return r;
+ }
+ if (r != CSR_RESULT_SUCCESS)
+ {
+ unifi_error(card->ospriv, "SDIO error reading SDIO_INT_ENABLE\n");
+ return r;
+ }
+
+ int_enable |= (1 << card->function) | UNIFI_SD_INT_ENABLE_IENM;
+
+ r = sdio_write_f0(card, SDIO_INT_ENABLE, int_enable);
+ if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
+ {
+ return r;
+ }
+ if (r != CSR_RESULT_SUCCESS)
+ {
+ unifi_error(card->ospriv, "SDIO error writing SDIO_INT_ENABLE\n");
+ return r;
+ }
+
+ return CSR_RESULT_SUCCESS;
+} /* CardEnableInt() */
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * CardDisableInt
+ *
+ * Disable the outgoing SDIO interrupt from UniFi to the host.
+ *
+ * Arguments:
+ * card Pointer to Card object
+ *
+ * Returns:
+ * CSR_RESULT_SUCCESS on success,
+ * CSR_WIFI_HIP_RESULT_NO_DEVICE if the card was ejected
+ * CSR_RESULT_FAILURE if an SDIO error occurred,
+ * ---------------------------------------------------------------------------
+ */
+CsrResult CardDisableInt(card_t *card)
+{
+ CsrResult r;
+ u8 int_enable;
+
+ r = sdio_read_f0(card, SDIO_INT_ENABLE, &int_enable);
+ if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
+ {
+ return r;
+ }
+ if (r != CSR_RESULT_SUCCESS)
+ {
+ unifi_error(card->ospriv, "SDIO error reading SDIO_INT_ENABLE\n");
+ return r;
+ }
+
+ int_enable &= ~(1 << card->function);
+
+ r = sdio_write_f0(card, SDIO_INT_ENABLE, int_enable);
+ if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
+ {
+ return r;
+ }
+ if (r != CSR_RESULT_SUCCESS)
+ {
+ unifi_error(card->ospriv, "SDIO error writing SDIO_INT_ENABLE\n");
+ return r;
+ }
+
+ return CSR_RESULT_SUCCESS;
+} /* CardDisableInt() */
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * CardPendingInt
+ *
+ * Determine whether UniFi is currently asserting the SDIO interrupt
+ * request.
+ *
+ * Arguments:
+ * card Pointer to Card object
+ * pintr Pointer to location to write interrupt status,
+ * TRUE if interrupt pending,
+ * FALSE if no interrupt pending.
+ * Returns:
+ * CSR_RESULT_SUCCESS interrupt status read successfully
+ * CSR_WIFI_HIP_RESULT_NO_DEVICE if the card was ejected
+ * CSR_RESULT_FAILURE if an SDIO error occurred,
+ * ---------------------------------------------------------------------------
+ */
+CsrResult CardPendingInt(card_t *card, u8 *pintr)
+{
+ CsrResult r;
+ u8 pending;
+
+ *pintr = FALSE;
+
+ r = sdio_read_f0(card, SDIO_INT_PENDING, &pending);
+ if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
+ {
+ return r;
+ }
+ if (r != CSR_RESULT_SUCCESS)
+ {
+ unifi_error(card->ospriv, "SDIO error reading SDIO_INT_PENDING\n");
+ return r;
+ }
+
+ *pintr = (pending & (1 << card->function))?TRUE : FALSE;
+
+ return CSR_RESULT_SUCCESS;
+} /* CardPendingInt() */
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * CardClearInt
+ *
+ * Clear the UniFi SDIO interrupt request.
+ *
+ * Arguments:
+ * card Pointer to Card object
+ *
+ * Returns:
+ * CSR_RESULT_SUCCESS if pending interrupt was cleared, or no pending interrupt.
+ * CSR_WIFI_HIP_RESULT_NO_DEVICE if the card was ejected
+ * CSR_RESULT_FAILURE if an SDIO error occurred,
+ * ---------------------------------------------------------------------------
+ */
+CsrResult CardClearInt(card_t *card)
+{
+ CsrResult r;
+ u8 intr;
+
+ if (card->chip_id > SDIO_CARD_ID_UNIFI_2)
+ {
+ /* CardPendingInt() sets intr, if there is a pending interrupt */
+ r = CardPendingInt(card, &intr);
+ if (intr == FALSE)
+ {
+ return r;
+ }
+
+ r = sdio_write_f0(card, SDIO_CSR_HOST_INT_CLEAR, 1);
+ if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
+ {
+ return r;
+ }
+ if (r != CSR_RESULT_SUCCESS)
+ {
+ unifi_error(card->ospriv, "SDIO error writing SDIO_CSR_HOST_INT_CLEAR\n");
+ }
+ }
+ else
+ {
+ r = unifi_write_direct_8_or_16(card,
+ ChipHelper_SDIO_HOST_INT(card->helper) * 2,
+ 0);
+ if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
+ {
+ return r;
+ }
+ if (r != CSR_RESULT_SUCCESS)
+ {
+ unifi_error(card->ospriv, "SDIO error writing UNIFI_SDIO_HOST_INT\n");
+ }
+ }
+
+ return r;
+} /* CardClearInt() */
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * CardIntEnabled
+ *
+ * Determine whether UniFi is currently asserting the SDIO interrupt
+ * request.
+ *
+ * Arguments:
+ * card Pointer to Card object
+ * enabled Pointer to location to write interrupt enable status,
+ * TRUE if interrupts enabled,
+ * FALSE if interupts disabled.
+ *
+ * Returns:
+ * CSR_WIFI_HIP_RESULT_NO_DEVICE if the card was ejected
+ * CSR_RESULT_FAILURE if an SDIO error occurred,
+ * ---------------------------------------------------------------------------
+ */
+CsrResult CardIntEnabled(card_t *card, u8 *enabled)
+{
+ CsrResult r;
+ u8 int_enable;
+
+ r = sdio_read_f0(card, SDIO_INT_ENABLE, &int_enable);
+ if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
+ {
+ return r;
+ }
+ if (r != CSR_RESULT_SUCCESS)
+ {
+ unifi_error(card->ospriv, "SDIO error reading SDIO_INT_ENABLE\n");
+ return r;
+ }
+
+ *enabled = (int_enable & (1 << card->function))?TRUE : FALSE;
+
+ return CSR_RESULT_SUCCESS;
+} /* CardIntEnabled() */
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * CardWriteBulkData
+ * Allocate slot in the pending bulkdata arrays and assign it to a signal's
+ * bulkdata reference. The slot is then ready for UniFi's bulkdata commands
+ * to transfer the data to/from the host.
+ *
+ * Arguments:
+ * card Pointer to Card object
+ * csptr Pending signal pointer, including bulkdata ref
+ * queue Traffic queue that this signal is using
+ *
+ * Returns:
+ * CSR_RESULT_SUCCESS if a free slot was assigned
+ * CSR_RESULT_FAILURE if no slot was available
+ * ---------------------------------------------------------------------------
+ */
+CsrResult CardWriteBulkData(card_t *card, card_signal_t *csptr, unifi_TrafficQueue queue)
+{
+ u16 i, slots[UNIFI_MAX_DATA_REFERENCES], j = 0;
+ u8 *packed_sigptr, num_slots_required = 0;
+ bulk_data_desc_t *bulkdata = csptr->bulkdata;
+ s16 h, nslots;
+
+ func_enter();
+
+ /* Count the number of slots required */
+ for (i = 0; i < UNIFI_MAX_DATA_REFERENCES; i++)
+ {
+ if (bulkdata[i].data_length != 0)
+ {
+ num_slots_required++;
+ }
+ }
+
+ /* Get the slot numbers */
+ if (num_slots_required != 0)
+ {
+ /* Last 2 slots for MLME */
+ if (queue == UNIFI_TRAFFIC_Q_MLME)
+ {
+ h = card->config_data.num_fromhost_data_slots - UNIFI_RESERVED_COMMAND_SLOTS;
+ for (i = 0; i < card->config_data.num_fromhost_data_slots; i++)
+ {
+ if (card->from_host_data[h].bd.data_length == 0)
+ {
+ /* Free data slot, claim it */
+ slots[j++] = h;
+ if (j == num_slots_required)
+ {
+ break;
+ }
+ }
+
+ if (++h >= card->config_data.num_fromhost_data_slots)
+ {
+ h = 0;
+ }
+ }
+ }
+ else
+ {
+ if (card->dynamic_slot_data.from_host_used_slots[queue]
+ < card->dynamic_slot_data.from_host_max_slots[queue])
+ {
+ /* Data commands get a free slot only after a few checks */
+ nslots = card->config_data.num_fromhost_data_slots - UNIFI_RESERVED_COMMAND_SLOTS;
+
+ h = card->from_host_data_head;
+
+ for (i = 0; i < nslots; i++)
+ {
+ if (card->from_host_data[h].bd.data_length == 0)
+ {
+ /* Free data slot, claim it */
+ slots[j++] = h;
+ if (j == num_slots_required)
+ {
+ break;
+ }
+ }
+
+ if (++h >= nslots)
+ {
+ h = 0;
+ }
+ }
+ card->from_host_data_head = h;
+ }
+ }
+
+ /* Required number of slots are not available, bail out */
+ if (j != num_slots_required)
+ {
+ unifi_trace(card->ospriv, UDBG5, "CardWriteBulkData: didn't find free slot/s\n");
+
+ /* If we haven't already reached the stable state we can ask for reservation */
+ if ((queue != UNIFI_TRAFFIC_Q_MLME) && (card->dynamic_slot_data.queue_stable[queue] == FALSE))
+ {
+ CardCheckDynamicReservation(card, queue);
+ }
+
+ for (i = 0; i < card->config_data.num_fromhost_data_slots; i++)
+ {
+ unifi_trace(card->ospriv, UDBG5, "fh data slot %d: %d\n", i, card->from_host_data[i].bd.data_length);
+ }
+ func_exit();
+ return CSR_RESULT_FAILURE;
+ }
+ }
+
+ packed_sigptr = csptr->sigbuf;
+
+ /* Fill in the slots with data */
+ j = 0;
+ for (i = 0; i < UNIFI_MAX_DATA_REFERENCES; i++)
+ {
+ if (bulkdata[i].data_length == 0)
+ {
+ /* Zero-out the DATAREF in the signal */
+ SET_PACKED_DATAREF_SLOT(packed_sigptr, i, 0);
+ SET_PACKED_DATAREF_LEN(packed_sigptr, i, 0);
+ }
+ else
+ {
+ /*
+ * Fill in the slot number in the SIGNAL structure but
+ * preserve the offset already in there
+ */
+ SET_PACKED_DATAREF_SLOT(packed_sigptr, i, slots[j] | (((u16)packed_sigptr[SIZEOF_SIGNAL_HEADER + (i * SIZEOF_DATAREF) + 1]) << 8));
+ SET_PACKED_DATAREF_LEN(packed_sigptr, i, bulkdata[i].data_length);
+
+ /* Do not copy the data, just store the information to them */
+ card->from_host_data[slots[j]].bd.os_data_ptr = bulkdata[i].os_data_ptr;
+ card->from_host_data[slots[j]].bd.os_net_buf_ptr = bulkdata[i].os_net_buf_ptr;
+ card->from_host_data[slots[j]].bd.data_length = bulkdata[i].data_length;
+ card->from_host_data[slots[j]].bd.net_buf_length = bulkdata[i].net_buf_length;
+ card->from_host_data[slots[j]].queue = queue;
+
+ unifi_trace(card->ospriv, UDBG4, "CardWriteBulkData sig=0x%x, fh slot %d = %p\n",
+ GET_SIGNAL_ID(packed_sigptr), i, bulkdata[i].os_data_ptr);
+
+ /* Sanity-check that the bulk data desc being assigned to the slot
+ * actually has a payload.
+ */
+ if (!bulkdata[i].os_data_ptr)
+ {
+ unifi_error(card->ospriv, "Assign null os_data_ptr (len=%d) fh slot %d, i=%d, q=%d, sig=0x%x",
+ bulkdata[i].data_length, slots[j], i, queue, GET_SIGNAL_ID(packed_sigptr));
+ }
+
+ j++;
+ if (queue < UNIFI_NO_OF_TX_QS)
+ {
+ card->dynamic_slot_data.from_host_used_slots[queue]++;
+ }
+ }
+ }
+
+ func_exit();
+
+ return CSR_RESULT_SUCCESS;
+} /* CardWriteBulkData() */
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * card_find_data_slot
+ *
+ * Dereference references to bulk data slots into pointers to real data.
+ *
+ * Arguments:
+ * card Pointer to the card struct.
+ * slot Slot number from a signal structure
+ *
+ * Returns:
+ * Pointer to entry in bulk_data_slot array.
+ * ---------------------------------------------------------------------------
+ */
+bulk_data_desc_t* card_find_data_slot(card_t *card, s16 slot)
+{
+ s16 sn;
+ bulk_data_desc_t *bd;
+
+ sn = slot & 0x7FFF;
+
+ /* ?? check sanity of slot number ?? */
+
+ if (slot & SLOT_DIR_TO_HOST)
+ {
+ bd = &card->to_host_data[sn];
+ }
+ else
+ {
+ bd = &card->from_host_data[sn].bd;
+ }
+
+ return bd;
+} /* card_find_data_slot() */
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * firmware_present_in_flash
+ *
+ * Probe for external Flash that looks like it might contain firmware.
+ *
+ * If Flash is not present, reads always return 0x0008.
+ * If Flash is present, but empty, reads return 0xFFFF.
+ * Anything else is considered to be firmware.
+ *
+ * Arguments:
+ * card Pointer to card struct
+ *
+ * Returns:
+ * CSR_RESULT_SUCCESS firmware is present in ROM or flash
+ * CSR_WIFI_HIP_RESULT_NOT_FOUND firmware is not present in ROM or flash
+ * CSR_WIFI_HIP_RESULT_NO_DEVICE if the card was ejected
+ * CSR_RESULT_FAILURE if an SDIO error occurred
+ * ---------------------------------------------------------------------------
+ */
+static CsrResult firmware_present_in_flash(card_t *card)
+{
+ CsrResult r;
+ u16 m1, m5;
+
+ if (ChipHelper_HasRom(card->helper))
+ {
+ return CSR_RESULT_SUCCESS;
+ }
+ if (!ChipHelper_HasFlash(card->helper))
+ {
+ return CSR_WIFI_HIP_RESULT_NOT_FOUND;
+ }
+
+ /*
+ * Examine the Flash locations that are the power-on default reset
+ * vectors of the XAP processors.
+ * These are words 1 and 5 in Flash.
+ */
+ r = unifi_card_read16(card, UNIFI_MAKE_GP(EXT_FLASH, 2), &m1);
+ if (r != CSR_RESULT_SUCCESS)
+ {
+ return r;
+ }
+
+ r = unifi_card_read16(card, UNIFI_MAKE_GP(EXT_FLASH, 10), &m5);
+ if (r != CSR_RESULT_SUCCESS)
+ {
+ return r;
+ }
+
+ /* Check for uninitialised/missing flash */
+ if ((m1 == 0x0008) || (m1 == 0xFFFF) ||
+ (m1 == 0x0004) || (m5 == 0x0004) ||
+ (m5 == 0x0008) || (m5 == 0xFFFF))
+ {
+ return CSR_WIFI_HIP_RESULT_NOT_FOUND;
+ }
+
+ return CSR_RESULT_SUCCESS;
+} /* firmware_present_in_flash() */
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * bootstrap_chip_hw
+ *
+ * Perform chip specific magic to "Get It Working" TM. This will
+ * increase speed of PLLs in analogue and maybe enable some
+ * on-chip regulators.
+ *
+ * Arguments:
+ * card Pointer to card struct
+ *
+ * Returns:
+ * None.
+ * ---------------------------------------------------------------------------
+ */
+static void bootstrap_chip_hw(card_t *card)
+{
+ const struct chip_helper_init_values *vals;
+ u32 i, len;
+ void *sdio = card->sdio_if;
+ CsrResult csrResult;
+
+ len = ChipHelper_ClockStartupSequence(card->helper, &vals);
+ if (len != 0)
+ {
+ for (i = 0; i < len; i++)
+ {
+ csrResult = CsrSdioWrite16(sdio, vals[i].addr * 2, vals[i].value);
+ if (csrResult != CSR_RESULT_SUCCESS)
+ {
+ unifi_warning(card->ospriv, "Failed to write bootstrap value %d\n", i);
+ /* Might not be fatal */
+ }
+
+ CsrThreadSleep(1);
+ }
+ }
+} /* bootstrap_chip_hw() */
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * unifi_card_stop_processor
+ *
+ * Stop the UniFi XAP processors.
+ *
+ * Arguments:
+ * card Pointer to card struct
+ * which One of UNIFI_PROC_MAC, UNIFI_PROC_PHY, UNIFI_PROC_BOTH
+ *
+ * Returns:
+ * CSR_RESULT_SUCCESS if successful, or CSR error code
+ * ---------------------------------------------------------------------------
+ */
+CsrResult unifi_card_stop_processor(card_t *card, enum unifi_dbg_processors_select which)
+{
+ CsrResult r = CSR_RESULT_SUCCESS;
+ u8 status;
+ s16 retry = 100;
+
+ while (retry--)
+ {
+ /* Select both XAPs */
+ r = unifi_set_proc_select(card, which);
+ if (r != CSR_RESULT_SUCCESS)
+ {
+ break;
+ }
+
+ /* Stop processors */
+ r = unifi_write_direct16(card, ChipHelper_DBG_EMU_CMD(card->helper) * 2, 2);
+ if (r != CSR_RESULT_SUCCESS)
+ {
+ break;
+ }
+
+ /* Read status */
+ r = unifi_read_direct_8_or_16(card,
+ ChipHelper_DBG_HOST_STOP_STATUS(card->helper) * 2,
+ &status);
+ if (r != CSR_RESULT_SUCCESS)
+ {
+ break;
+ }
+
+ if ((status & 1) == 1)
+ {
+ /* Success! */
+ return CSR_RESULT_SUCCESS;
+ }
+
+ /* Processors didn't stop, try again */
+ }
+
+ if (r != CSR_RESULT_SUCCESS)
+ {
+ /* An SDIO error occurred */
+ unifi_error(card->ospriv, "Failed to stop processors: SDIO error\n");
+ }
+ else
+ {
+ /* If we reach here, we didn't the status in time. */
+ unifi_error(card->ospriv, "Failed to stop processors: timeout waiting for stopped status\n");
+ r = CSR_RESULT_FAILURE;
+ }
+
+ return r;
+} /* unifi_card_stop_processor() */
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * card_start_processor
+ *
+ * Start the UniFi XAP processors.
+ *
+ * Arguments:
+ * card Pointer to card struct
+ * which One of UNIFI_PROC_MAC, UNIFI_PROC_PHY, UNIFI_PROC_BOTH
+ *
+ * Returns:
+ * CSR_RESULT_SUCCESS or CSR error code
+ * ---------------------------------------------------------------------------
+ */
+CsrResult card_start_processor(card_t *card, enum unifi_dbg_processors_select which)
+{
+ CsrResult r;
+
+ /* Select both XAPs */
+ r = unifi_set_proc_select(card, which);
+ if (r != CSR_RESULT_SUCCESS)
+ {
+ unifi_error(card->ospriv, "unifi_set_proc_select failed: %d.\n", r);
+ return r;
+ }
+
+
+ r = unifi_write_direct_8_or_16(card,
+ ChipHelper_DBG_EMU_CMD(card->helper) * 2, 8);
+ if (r != CSR_RESULT_SUCCESS)
+ {
+ return r;
+ }
+
+ r = unifi_write_direct_8_or_16(card,
+ ChipHelper_DBG_EMU_CMD(card->helper) * 2, 0);
+ if (r != CSR_RESULT_SUCCESS)
+ {
+ return r;
+ }
+
+ return CSR_RESULT_SUCCESS;
+} /* card_start_processor() */
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * unifi_set_interrupt_mode
+ *
+ * Configure the interrupt processing mode used by the HIP
+ *
+ * Arguments:
+ * card Pointer to card struct
+ * mode Interrupt mode to apply
+ *
+ * Returns:
+ * None
+ * ---------------------------------------------------------------------------
+ */
+void unifi_set_interrupt_mode(card_t *card, u32 mode)
+{
+ if (mode == CSR_WIFI_INTMODE_RUN_BH_ONCE)
+ {
+ unifi_info(card->ospriv, "Scheduled interrupt mode");
+ }
+ card->intmode = mode;
+} /* unifi_set_interrupt_mode() */
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * unifi_start_processors
+ *
+ * Start all UniFi XAP processors.
+ *
+ * Arguments:
+ * card Pointer to card struct
+ *
+ * Returns:
+ * CSR_RESULT_SUCCESS on success, CSR error code on error
+ * ---------------------------------------------------------------------------
+ */
+CsrResult unifi_start_processors(card_t *card)
+{
+ return card_start_processor(card, UNIFI_PROC_BOTH);
+} /* unifi_start_processors() */
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * unifi_request_max_sdio_clock
+ *
+ * Requests that the maximum SDIO clock rate is set at the next suitable
+ * opportunity (e.g. when the BH next runs, so as not to interfere with
+ * any current operation).
+ *
+ * Arguments:
+ * card Pointer to card struct
+ *
+ * Returns:
+ * None
+ * ---------------------------------------------------------------------------
+ */
+void unifi_request_max_sdio_clock(card_t *card)
+{
+ card->request_max_clock = 1;
+} /* unifi_request_max_sdio_clock() */
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * unifi_set_host_state
+ *
+ * Set the host deep-sleep state.
+ *
+ * If transitioning to TORPID, the SDIO driver will be notified
+ * that the SD bus will be unused (idle) and conversely, when
+ * transitioning from TORPID that the bus will be used (active).
+ *
+ * Arguments:
+ * card Pointer to card struct
+ * state New deep-sleep state.
+ *
+ * Returns:
+ * CSR_RESULT_SUCCESS on success
+ * CSR_WIFI_HIP_RESULT_NO_DEVICE if the card was ejected
+ * CSR_RESULT_FAILURE if an SDIO error occurred
+ *
+ * Notes:
+ * We need to reduce the SDIO clock speed before trying to wake up the
+ * chip. Actually, in the implementation below we reduce the clock speed
+ * not just before we try to wake up the chip, but when we put the chip to
+ * deep sleep. This means that if the f/w wakes up on its' own, we waste
+ * a reduce/increace cycle. However, trying to eliminate this overhead is
+ * proved difficult, as the current state machine in the HIP lib does at
+ * least a CMD52 to disable the interrupts before we configure the host
+ * state.
+ * ---------------------------------------------------------------------------
+ */
+CsrResult unifi_set_host_state(card_t *card, enum unifi_host_state state)
+{
+ CsrResult r = CSR_RESULT_SUCCESS;
+ CsrResult csrResult;
+ static const char *const states[] = {
+ "AWAKE", "DROWSY", "TORPID"
+ };
+ static const u8 state_csr_host_wakeup[] = {
+ 1, 3, 0
+ };
+ static const u8 state_io_abort[] = {
+ 0, 2, 3
+ };
+
+ unifi_trace(card->ospriv, UDBG4, "State %s to %s\n",
+ states[card->host_state], states[state]);
+
+ if (card->host_state == UNIFI_HOST_STATE_TORPID)
+ {
+ CsrSdioFunctionActive(card->sdio_if);
+ }
+
+ /* Write the new state to UniFi. */
+ if (card->chip_id > SDIO_CARD_ID_UNIFI_2)
+ {
+ r = sdio_write_f0(card, SDIO_CSR_HOST_WAKEUP,
+ (u8)((card->function << 4) | state_csr_host_wakeup[state]));
+ }
+ else
+ {
+ r = sdio_write_f0(card, SDIO_IO_ABORT, state_io_abort[state]);
+ }
+
+ if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
+ {
+ return r;
+ }
+ if (r != CSR_RESULT_SUCCESS)
+ {
+ unifi_error(card->ospriv, "Failed to write UniFi deep sleep state\n");
+ }
+ else
+ {
+ /*
+ * If the chip was in state TORPID then we can now increase
+ * the maximum bus clock speed.
+ */
+ if (card->host_state == UNIFI_HOST_STATE_TORPID)
+ {
+ csrResult = CsrSdioMaxBusClockFrequencySet(card->sdio_if,
+ UNIFI_SDIO_CLOCK_MAX_HZ);
+ r = ConvertCsrSdioToCsrHipResult(card, csrResult);
+ /* Non-fatal error */
+ if (r != CSR_RESULT_SUCCESS && r != CSR_WIFI_HIP_RESULT_NO_DEVICE)
+ {
+ unifi_warning(card->ospriv,
+ "Failed to increase the SDIO clock speed\n");
+ }
+ else
+ {
+ card->sdio_clock_speed = UNIFI_SDIO_CLOCK_MAX_HZ;
+ }
+ }
+
+ /*
+ * Cache the current state in the card structure to avoid
+ * unnecessary SDIO reads.
+ */
+ card->host_state = state;
+
+ if (state == UNIFI_HOST_STATE_TORPID)
+ {
+ /*
+ * If the chip is now in state TORPID then we must now decrease
+ * the maximum bus clock speed.
+ */
+ csrResult = CsrSdioMaxBusClockFrequencySet(card->sdio_if,
+ UNIFI_SDIO_CLOCK_SAFE_HZ);
+ r = ConvertCsrSdioToCsrHipResult(card, csrResult);
+ if (r != CSR_RESULT_SUCCESS && r != CSR_WIFI_HIP_RESULT_NO_DEVICE)
+ {
+ unifi_warning(card->ospriv,
+ "Failed to decrease the SDIO clock speed\n");
+ }
+ else
+ {
+ card->sdio_clock_speed = UNIFI_SDIO_CLOCK_SAFE_HZ;
+ }
+ CsrSdioFunctionIdle(card->sdio_if);
+ }
+ }
+
+ return r;
+} /* unifi_set_host_state() */
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * unifi_card_info
+ *
+ * Update the card information data structure
+ *
+ * Arguments:
+ * card Pointer to card struct
+ * card_info Pointer to info structure to update
+ *
+ * Returns:
+ * None
+ * ---------------------------------------------------------------------------
+ */
+void unifi_card_info(card_t *card, card_info_t *card_info)
+{
+ card_info->chip_id = card->chip_id;
+ card_info->chip_version = card->chip_version;
+ card_info->fw_build = card->build_id;
+ card_info->fw_hip_version = card->config_data.version;
+ card_info->sdio_block_size = card->sdio_io_block_size;
+} /* unifi_card_info() */
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * unifi_check_io_status
+ *
+ * Check UniFi for spontaneous reset and pending interrupt.
+ *
+ * Arguments:
+ * card Pointer to card struct
+ * status Pointer to location to write chip status:
+ * 0 if UniFi is running, and no interrupt pending
+ * 1 if UniFi has spontaneously reset
+ * 2 if there is a pending interrupt
+ * Returns:
+ * CSR_RESULT_SUCCESS if OK, or CSR error
+ * ---------------------------------------------------------------------------
+ */
+CsrResult unifi_check_io_status(card_t *card, s32 *status)
+{
+ u8 io_en;
+ CsrResult r;
+ u8 pending;
+
+ *status = 0;
+
+ r = sdio_read_f0(card, SDIO_IO_ENABLE, &io_en);
+ if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
+ {
+ return r;
+ }
+ if (r != CSR_RESULT_SUCCESS)
+ {
+ unifi_error(card->ospriv, "Failed to read SDIO_IO_ENABLE to check for spontaneous reset\n");
+ return r;
+ }
+
+ if ((io_en & (1 << card->function)) == 0)
+ {
+ s32 fw_count;
+ *status = 1;
+ unifi_error(card->ospriv, "UniFi has spontaneously reset.\n");
+
+ /*
+ * These reads are very likely to fail. We want to know if the function is really
+ * disabled or the SDIO driver just returns rubbish.
+ */
+ fw_count = unifi_read_shared_count(card, card->sdio_ctrl_addr + 4);
+ if (fw_count < 0)
+ {
+ unifi_error(card->ospriv, "Failed to read to-host sig written count\n");
+ }
+ else
+ {
+ unifi_error(card->ospriv, "thsw: %u (driver thinks is %u)\n",
+ fw_count, card->to_host_signals_w);
+ }
+ fw_count = unifi_read_shared_count(card, card->sdio_ctrl_addr + 2);
+ if (fw_count < 0)
+ {
+ unifi_error(card->ospriv, "Failed to read from-host sig read count\n");
+ }
+ else
+ {
+ unifi_error(card->ospriv, "fhsr: %u (driver thinks is %u)\n",
+ fw_count, card->from_host_signals_r);
+ }
+
+ return r;
+ }
+
+ unifi_info(card->ospriv, "UniFi function %d is enabled.\n", card->function);
+
+ /* See if we missed an SDIO interrupt */
+ r = CardPendingInt(card, &pending);
+ if (pending)
+ {
+ unifi_error(card->ospriv, "There is an unhandled pending interrupt.\n");
+ *status = 2;
+ return r;
+ }
+
+ return r;
+} /* unifi_check_io_status() */
+
+
+void unifi_get_hip_qos_info(card_t *card, unifi_HipQosInfo *hipqosinfo)
+{
+ s32 count_fhr;
+ s16 t;
+ u32 occupied_fh;
+
+ q_t *sigq;
+ u16 nslots, i;
+
+ memset(hipqosinfo, 0, sizeof(unifi_HipQosInfo));
+
+ nslots = card->config_data.num_fromhost_data_slots;
+
+ for (i = 0; i < nslots; i++)
+ {
+ if (card->from_host_data[i].bd.data_length == 0)
+ {
+ hipqosinfo->free_fh_bulkdata_slots++;
+ }
+ }
+
+ for (i = 0; i < UNIFI_NO_OF_TX_QS; i++)
+ {
+ sigq = &card->fh_traffic_queue[i];
+ t = sigq->q_wr_ptr - sigq->q_rd_ptr;
+ if (t < 0)
+ {
+ t += sigq->q_length;
+ }
+ hipqosinfo->free_fh_sig_queue_slots[i] = (sigq->q_length - t) - 1;
+ }
+
+ count_fhr = unifi_read_shared_count(card, card->sdio_ctrl_addr + 2);
+ if (count_fhr < 0)
+ {
+ unifi_error(card->ospriv, "Failed to read from-host sig read count - %d\n", count_fhr);
+ hipqosinfo->free_fh_fw_slots = 0xfa;
+ return;
+ }
+
+ occupied_fh = (card->from_host_signals_w - count_fhr) % 128;
+
+ hipqosinfo->free_fh_fw_slots = (u16)(card->config_data.num_fromhost_sig_frags - occupied_fh);
+}
+
+
+
+CsrResult ConvertCsrSdioToCsrHipResult(card_t *card, CsrResult csrResult)
+{
+ CsrResult r = CSR_RESULT_FAILURE;
+
+ switch (csrResult)
+ {
+ case CSR_RESULT_SUCCESS:
+ r = CSR_RESULT_SUCCESS;
+ break;
+ /* Timeout errors */
+ case CSR_SDIO_RESULT_TIMEOUT:
+ /* Integrity errors */
+ case CSR_SDIO_RESULT_CRC_ERROR:
+ r = CSR_RESULT_FAILURE;
+ break;
+ case CSR_SDIO_RESULT_NO_DEVICE:
+ r = CSR_WIFI_HIP_RESULT_NO_DEVICE;
+ break;
+ case CSR_SDIO_RESULT_INVALID_VALUE:
+ r = CSR_WIFI_HIP_RESULT_INVALID_VALUE;
+ break;
+ case CSR_RESULT_FAILURE:
+ r = CSR_RESULT_FAILURE;
+ break;
+ default:
+ unifi_warning(card->ospriv, "Unrecognised csrResult error code: %d\n", csrResult);
+ break;
+ }
+
+ return r;
+} /* ConvertCsrSdioToCsrHipResult() */
+
+
diff --git a/drivers/staging/csr/csr_wifi_hip_card_sdio.h b/drivers/staging/csr/csr_wifi_hip_card_sdio.h
new file mode 100644
index 000000000000..dc2ed70f7edd
--- /dev/null
+++ b/drivers/staging/csr/csr_wifi_hip_card_sdio.h
@@ -0,0 +1,702 @@
+/*****************************************************************************
+
+ (c) Cambridge Silicon Radio Limited 2011
+ All rights reserved and confidential information of CSR
+
+ Refer to LICENSE.txt included with this source for details
+ on the license terms.
+
+*****************************************************************************/
+
+/*
+ * ---------------------------------------------------------------------------
+ *
+ * FILE: csr_wifi_hip_card_sdio.h
+ *
+ * PURPOSE:
+ * Internal header for Card API for SDIO.
+ * ---------------------------------------------------------------------------
+ */
+#ifndef __CARD_SDIO_H__
+#define __CARD_SDIO_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include "csr_wifi_hip_unifi.h"
+#include "csr_wifi_hip_unifi_udi.h"
+#include "csr_wifi_hip_unifihw.h"
+#include "csr_wifi_hip_unifiversion.h"
+#ifndef CSR_WIFI_HIP_TA_DISABLE
+#include "csr_wifi_hip_ta_sampling.h"
+#endif
+#include "csr_wifi_hip_xbv.h"
+#include "csr_wifi_hip_chiphelper.h"
+
+
+/*
+ *
+ * Configuration items.
+ * Which of these should go in a platform unifi_config.h file?
+ *
+ */
+
+/*
+ * When the traffic queues contain more signals than there is space for on
+ * UniFi, a limiting algorithm comes into play.
+ * If a traffic queue has enough slots free to buffer more traffic from the
+ * network stack, then the following check is applied. The number of free
+ * slots is RESUME_XMIT_THRESHOLD.
+ */
+#define RESUME_XMIT_THRESHOLD 4
+
+
+/*
+ * When reading signals from UniFi, the host processes pending all signals
+ * and then acknowledges them together in a single write to update the
+ * to-host-chunks-read location.
+ * When there is more than one bulk data transfer (e.g. one received data
+ * packet and a request for the payload data of a transmitted packet), the
+ * update can be delayed significantly. This ties up resources on chip.
+ *
+ * To remedy this problem, to-host-chunks-read is updated after processing
+ * a signal if TO_HOST_FLUSH_THRESHOLD bytes of bulk data have been
+ * transferred since the last update.
+ */
+#define TO_HOST_FLUSH_THRESHOLD (500 * 5)
+
+
+/* SDIO Card Common Control Registers */
+#define SDIO_CCCR_SDIO_REVISION (0x00)
+#define SDIO_SD_SPEC_REVISION (0x01)
+#define SDIO_IO_ENABLE (0x02)
+#define SDIO_IO_READY (0x03)
+#define SDIO_INT_ENABLE (0x04)
+#define SDIO_INT_PENDING (0x05)
+#define SDIO_IO_ABORT (0x06)
+#define SDIO_BUS_IFACE_CONTROL (0x07)
+#define SDIO_CARD_CAPABILOTY (0x08)
+#define SDIO_COMMON_CIS_POINTER (0x09)
+#define SDIO_BUS_SUSPEND (0x0C)
+#define SDIO_FUNCTION_SELECT (0x0D)
+#define SDIO_EXEC_FLAGS (0x0E)
+#define SDIO_READY_FLAGS (0x0F)
+#define SDIO_FN0_BLOCK_SIZE (0x10)
+#define SDIO_POWER_CONTROL (0x12)
+#define SDIO_VENDOR_START (0xF0)
+
+#define SDIO_CSR_HOST_WAKEUP (0xf0)
+#define SDIO_CSR_HOST_INT_CLEAR (0xf1)
+#define SDIO_CSR_FROM_HOST_SCRATCH0 (0xf2)
+#define SDIO_CSR_FROM_HOST_SCRATCH1 (0xf3)
+#define SDIO_CSR_TO_HOST_SCRATCH0 (0xf4)
+#define SDIO_CSR_TO_HOST_SCRATCH1 (0xf5)
+#define SDIO_CSR_FUNC_EN (0xf6)
+#define SDIO_CSR_CSPI_MODE (0xf7)
+#define SDIO_CSR_CSPI_STATUS (0xf8)
+#define SDIO_CSR_CSPI_PADDING (0xf9)
+
+
+#define UNIFI_SD_INT_ENABLE_IENM 0x0001 /* Master INT Enable */
+
+#ifdef CSR_PRE_ALLOC_NET_DATA
+#define BULK_DATA_PRE_ALLOC_NUM 16
+#endif
+
+/*
+ * Structure to hold configuration information read from UniFi.
+ */
+typedef struct
+{
+ /*
+ * The version of the SDIO signal queues and bulk data pools
+ * configuration structure. The MSB is the major version number, used to
+ * indicate incompatible changes. The LSB gives the minor revision number,
+ * used to indicate changes that maintain backwards compatibility.
+ */
+ u16 version;
+
+ /*
+ * offset from the start of the shared data memory to the SD IO
+ * control structure.
+ */
+ u16 sdio_ctrl_offset;
+
+ /* Buffer handle of the from-host signal queue */
+ u16 fromhost_sigbuf_handle;
+
+ /* Buffer handle of the to-host signal queue */
+ u16 tohost_sigbuf_handle;
+
+ /*
+ * Maximum number of signal primitive or bulk data command fragments that may be
+ * pending in the to-hw signal queue.
+ */
+ u16 num_fromhost_sig_frags;
+
+ /*
+ * Number of signal primitive or bulk data command fragments that must be pending
+ * in the to-host signal queue before the host will generate an interrupt
+ * to indicate that it has read a signal. This will usually be the total
+ * capacity of the to-host signal buffer less the size of the largest signal
+ * primitive divided by the signal primitive fragment size, but may be set
+ * to 1 to request interrupts every time that the host read a signal.
+ * Note that the hw may place more signals in the to-host signal queue
+ * than indicated by this field.
+ */
+ u16 num_tohost_sig_frags;
+
+ /*
+ * Number of to-hw bulk data slots. Slots are numbered from 0 (zero) to
+ * one less than the value in this field
+ */
+ u16 num_fromhost_data_slots;
+
+ /*
+ * Number of frm-hw bulk data slots. Slots are numbered from 0 (zero) to
+ * one less than the value in this field
+ */
+ u16 num_tohost_data_slots;
+
+ /*
+ * Size of the bulk data slots (2 octets)
+ * The size of the bulk data slots in octets. This will usually be
+ * the size of the largest MSDU. The value should always be even.
+ */
+ u16 data_slot_size;
+
+ /*
+ * Indicates that the host has finished the initialisation sequence.
+ * Initialised to 0x0000 by the firmware, and set to 0x0001 by us.
+ */
+ u16 initialised;
+
+ /* Added by protocol version 0x0001 */
+ u32 overlay_size;
+
+ /* Added by protocol version 0x0300 */
+ u16 data_slot_round;
+ u16 sig_frag_size;
+
+ /* Added by protocol version 0x0500 */
+ u16 tohost_signal_padding;
+} sdio_config_data_t;
+
+/*
+ * These values may change with versions of the Host Interface Protocol.
+ */
+/*
+ * Size of config info block pointed to by the CSR_SLT_SDIO_SLOT_CONFIG
+ * entry in the f/w symbol table
+ */
+#define SDIO_CONFIG_DATA_SIZE 30
+
+/* Offset of the INIT flag in the config info block. */
+#define SDIO_INIT_FLAG_OFFSET 0x12
+#define SDIO_TO_HOST_SIG_PADDING_OFFSET 0x1C
+
+
+/* Structure for a bulk data transfer command */
+typedef struct
+{
+ u16 cmd_and_len; /* bits 12-15 cmd, bits 0-11 len */
+ u16 data_slot; /* slot number, perhaps OR'd with SLOT_DIR_TO_HOST */
+ u16 offset;
+ u16 buffer_handle;
+} bulk_data_cmd_t;
+
+
+/* Bulk Data signal command values */
+#define SDIO_CMD_SIGNAL 0x00
+#define SDIO_CMD_TO_HOST_TRANSFER 0x01
+#define SDIO_CMD_TO_HOST_TRANSFER_ACK 0x02 /*deprecated*/
+#define SDIO_CMD_FROM_HOST_TRANSFER 0x03
+#define SDIO_CMD_FROM_HOST_TRANSFER_ACK 0x04 /*deprecated*/
+#define SDIO_CMD_CLEAR_SLOT 0x05
+#define SDIO_CMD_OVERLAY_TRANSFER 0x06
+#define SDIO_CMD_OVERLAY_TRANSFER_ACK 0x07 /*deprecated*/
+#define SDIO_CMD_FROM_HOST_AND_CLEAR 0x08
+#define SDIO_CMD_PADDING 0x0f
+
+#define SLOT_DIR_TO_HOST 0x8000
+
+
+/* Initialise bulkdata slot
+ * params:
+ * bulk_data_desc_t *bulk_data_slot
+ */
+#define UNIFI_INIT_BULK_DATA(bulk_data_slot) \
+ { \
+ (bulk_data_slot)->os_data_ptr = NULL; \
+ (bulk_data_slot)->data_length = 0; \
+ (bulk_data_slot)->os_net_buf_ptr = NULL; \
+ (bulk_data_slot)->net_buf_length = 0; \
+ }
+
+/*
+ * Structure to contain a SIGNAL datagram.
+ * This is used to build signal queues between the main driver and the
+ * i/o thread.
+ * The fields are:
+ * sigbuf Contains the HIP signal is wire-format (i.e. packed,
+ * little-endian)
+ * bulkdata Contains a copy of any associated bulk data
+ * signal_length The size of the signal in the sigbuf
+ */
+typedef struct card_signal
+{
+ u8 sigbuf[UNIFI_PACKED_SIGBUF_SIZE];
+
+ /* Length of the SIGNAL inside sigbuf */
+ u16 signal_length;
+
+ bulk_data_desc_t bulkdata[UNIFI_MAX_DATA_REFERENCES];
+} card_signal_t;
+
+
+/*
+ * Control structure for a generic ring buffer.
+ */
+#define UNIFI_QUEUE_NAME_MAX_LENGTH 16
+typedef struct
+{
+ card_signal_t *q_body;
+
+ /* Num elements in queue (capacity is one less than this!) */
+ u16 q_length;
+
+ u16 q_wr_ptr;
+ u16 q_rd_ptr;
+
+ char name[UNIFI_QUEUE_NAME_MAX_LENGTH];
+} q_t;
+
+
+#define UNIFI_RESERVED_COMMAND_SLOTS 2
+
+/* Considering approx 500 us per packet giving 0.5 secs */
+#define UNIFI_PACKETS_INTERVAL 1000
+
+/*
+ * Dynamic slot reservation for QoS
+ */
+typedef struct
+{
+ u16 from_host_used_slots[UNIFI_NO_OF_TX_QS];
+ u16 from_host_max_slots[UNIFI_NO_OF_TX_QS];
+ u16 from_host_reserved_slots[UNIFI_NO_OF_TX_QS];
+
+ /* Parameters to determine if a queue was active.
+ If number of packets sent is greater than the threshold
+ for the queue, the queue is considered active and no
+ re reservation is done, it is important not to keep this
+ value too low */
+ /* Packets sent during this interval */
+ u16 packets_txed[UNIFI_NO_OF_TX_QS];
+ u16 total_packets_txed;
+
+ /* Number of packets to see if slots need to be reassigned */
+ u16 packets_interval;
+
+ /* Once a queue reaches a stable state, avoid processing */
+ u8 queue_stable[UNIFI_NO_OF_TX_QS];
+} card_dynamic_slot_t;
+
+
+/* These are type-safe and don't write incorrect values to the
+ * structure. */
+
+/* Return queue slots used count
+ * params:
+ * const q_t *q
+ * returns:
+ * u16
+ */
+#define CSR_WIFI_HIP_Q_SLOTS_USED(q) \
+ (((q)->q_wr_ptr - (q)->q_rd_ptr < 0)? \
+ ((q)->q_wr_ptr - (q)->q_rd_ptr + (q)->q_length) : ((q)->q_wr_ptr - (q)->q_rd_ptr))
+
+/* Return queue slots free count
+ * params:
+ * const q_t *q
+ * returns:
+ * u16
+ */
+#define CSR_WIFI_HIP_Q_SLOTS_FREE(q) \
+ ((q)->q_length - CSR_WIFI_HIP_Q_SLOTS_USED((q)) - 1)
+
+/* Return slot signal data pointer
+ * params:
+ * const q_t *q
+ * u16 slot
+ * returns:
+ * card_signal_t *
+ */
+#define CSR_WIFI_HIP_Q_SLOT_DATA(q, slot) \
+ ((q)->q_body + slot)
+
+/* Return queue next read slot
+ * params:
+ * const q_t *q
+ * returns:
+ * u16 slot offset
+ */
+#define CSR_WIFI_HIP_Q_NEXT_R_SLOT(q) \
+ ((q)->q_rd_ptr)
+
+/* Return queue next write slot
+ * params:
+ * const q_t *q
+ * returns:
+ * u16 slot offset
+ */
+#define CSR_WIFI_HIP_Q_NEXT_W_SLOT(q) \
+ ((q)->q_wr_ptr)
+
+/* Return updated queue pointer wrapped around its length
+ * params:
+ * const q_t *q
+ * u16 x amount to add to queue pointer
+ * returns:
+ * u16 wrapped queue pointer
+ */
+#define CSR_WIFI_HIP_Q_WRAP(q, x) \
+ ((((x) >= (q)->q_length)?((x) % (q)->q_length) : (x)))
+
+/* Advance queue read pointer
+ * params:
+ * const q_t *q
+ */
+#define CSR_WIFI_HIP_Q_INC_R(q) \
+ ((q)->q_rd_ptr = CSR_WIFI_HIP_Q_WRAP((q), (q)->q_rd_ptr + 1))
+
+/* Advance queue write pointer
+ * params:
+ * const q_t *q
+ */
+#define CSR_WIFI_HIP_Q_INC_W(q) \
+ ((q)->q_wr_ptr = CSR_WIFI_HIP_Q_WRAP((q), (q)->q_wr_ptr + 1))
+
+enum unifi_host_state
+{
+ UNIFI_HOST_STATE_AWAKE = 0,
+ UNIFI_HOST_STATE_DROWSY = 1,
+ UNIFI_HOST_STATE_TORPID = 2
+};
+
+typedef struct
+{
+ bulk_data_desc_t bd;
+ unifi_TrafficQueue queue; /* Used for dynamic slot reservation */
+} slot_desc_t;
+
+/*
+ * Structure describing a UniFi SDIO card.
+ */
+struct card
+{
+ /*
+ * Back pointer for the higher level OS code. This is passed as
+ * an argument to callbacks (e.g. for received data and indications).
+ */
+ void *ospriv;
+
+ /*
+ * mapping of HIP slot to MA-PACKET.req host tag, the
+ * array is indexed by slot numbers and each index stores
+ * information of the last host tag it was used for
+ */
+ u32 *fh_slot_host_tag_record;
+
+
+ /* Info read from Symbol Table during probe */
+ u32 build_id;
+ char build_id_string[128];
+
+ /* Retrieve from SDIO driver. */
+ u16 chip_id;
+
+ /* Read from GBL_CHIP_VERSION. */
+ u16 chip_version;
+
+ /* From the SDIO driver (probably 1) */
+ u8 function;
+
+ /* This is sused to get the register addresses and things. */
+ ChipDescript *helper;
+
+ /*
+ * Bit mask of PIOs for the loader to waggle during download.
+ * We assume these are connected to LEDs. The main firmware gets
+ * the mask from a MIB entry.
+ */
+ s32 loader_led_mask;
+
+ /*
+ * Support for flow control. When the from-host queue of signals
+ * is full, we ask the host upper layer to stop sending packets. When
+ * the queue drains we tell it that it can send packets again.
+ * We use this flag to remember the current state.
+ */
+#define card_is_tx_q_paused(card, q) (card->tx_q_paused_flag[q])
+#define card_tx_q_unpause(card, q) (card->tx_q_paused_flag[q] = 0)
+#define card_tx_q_pause(card, q) (card->tx_q_paused_flag[q] = 1)
+
+ u16 tx_q_paused_flag[UNIFI_TRAFFIC_Q_MAX + 1 + UNIFI_NO_OF_TX_QS]; /* defensive more than big enough */
+
+ /* UDI callback for logging UniFi interactions */
+ udi_func_t udi_hook;
+
+ u8 bh_reason_host;
+ u8 bh_reason_unifi;
+
+ /* SDIO clock speed request from OS layer */
+ u8 request_max_clock;
+
+ /* Last SDIO clock frequency set */
+ u32 sdio_clock_speed;
+
+ /*
+ * Current host state (copy of value in IOABORT register and
+ * spinlock to protect it.
+ */
+ enum unifi_host_state host_state;
+
+ enum unifi_low_power_mode low_power_mode;
+ enum unifi_periodic_wake_mode periodic_wake_mode;
+
+ /*
+ * Ring buffer of signal structs for a queue of data packets from
+ * the host.
+ * The queue is empty when fh_data_q_num_rd == fh_data_q_num_wr.
+ * To add a packet to the queue, copy it to index given by
+ * (fh_data_q_num_wr%UNIFI_SOFT_Q_LENGTH) and advance fh_data_q_num_wr.
+ * To take a packet from the queue, copy data from index given by
+ * (fh_data_q_num_rd%UNIFI_SOFT_Q_LENGTH) and advance fh_data_q_num_rd.
+ * fh_data_q_num_rd and fh_data_q_num_rd are both modulo 256.
+ */
+ card_signal_t fh_command_q_body[UNIFI_SOFT_COMMAND_Q_LENGTH];
+ q_t fh_command_queue;
+
+ card_signal_t fh_traffic_q_body[UNIFI_NO_OF_TX_QS][UNIFI_SOFT_TRAFFIC_Q_LENGTH];
+ q_t fh_traffic_queue[UNIFI_NO_OF_TX_QS];
+
+ /*
+ * Signal counts from UniFi SDIO Control Data Structure.
+ * These are cached and synchronised with the UniFi before and after
+ * a batch of operations.
+ *
+ * These are the modulo-256 count of signals written to or read from UniFi
+ * The value is incremented for every signal.
+ */
+ s32 from_host_signals_w;
+ s32 from_host_signals_r;
+ s32 to_host_signals_r;
+ s32 to_host_signals_w;
+
+
+ /* Should specify buffer size as a number of signals */
+ /*
+ * Enough for 10 th and 10 fh data slots:
+ * 1 * 10 * 8 = 80
+ * 2 * 10 * 8 = 160
+ */
+#define UNIFI_FH_BUF_SIZE 1024
+ struct sigbuf
+ {
+ u8 *buf; /* buffer area */
+ u8 *ptr; /* current pos */
+ u16 count; /* signal count */
+ u16 bufsize;
+ } fh_buffer;
+ struct sigbuf th_buffer;
+
+
+ /*
+ * Field to use for the incrementing value to write to the UniFi
+ * SHARED_IO_INTERRUPT register.
+ * Flag to say we need to generate an interrupt at end of processing.
+ */
+ u32 unifi_interrupt_seq;
+ u8 generate_interrupt;
+
+
+ /* Pointers to the bulk data slots */
+ slot_desc_t *from_host_data;
+ bulk_data_desc_t *to_host_data;
+
+
+ /*
+ * Index of the next (hopefully) free data slot.
+ * This is an optimisation that starts searching at a more likely point
+ * than the beginning.
+ */
+ s16 from_host_data_head;
+
+ /* Dynamic slot allocation for queues */
+ card_dynamic_slot_t dynamic_slot_data;
+
+ /*
+ * SDIO specific fields
+ */
+
+ /* Interface pointer for the SDIO library */
+ CsrSdioFunction *sdio_if;
+
+ /* Copy of config_data struct from the card */
+ sdio_config_data_t config_data;
+
+ /* SDIO address of the Initialised flag and Control Data struct */
+ u32 init_flag_addr;
+ u32 sdio_ctrl_addr;
+
+ /* The last value written to the Shared Data Memory Page register */
+ u32 proc_select;
+ u32 dmem_page;
+ u32 pmem_page;
+
+ /* SDIO traffic counters limited to 32 bits for Synergy compatibility */
+ u32 sdio_bytes_read;
+ u32 sdio_bytes_written;
+
+ u8 memory_resources_allocated;
+
+ /* UniFi SDIO I/O Block size. */
+ u16 sdio_io_block_size;
+
+ /* Pad transfer sizes to SDIO block boundaries */
+ u8 sdio_io_block_pad;
+
+ /* Read from the XBV */
+ struct FWOV fwov;
+
+#ifndef CSR_WIFI_HIP_TA_DISABLE
+ /* TA sampling */
+ ta_data_t ta_sampling;
+#endif
+
+ /* Auto-coredump */
+ s16 request_coredump_on_reset; /* request coredump on next reset */
+ struct coredump_buf *dump_buf; /* root node */
+ struct coredump_buf *dump_next_write; /* node to fill at next dump */
+ struct coredump_buf *dump_cur_read; /* valid node to read, or NULL */
+
+#ifdef CSR_WIFI_HIP_DATA_PLANE_PROFILE
+ struct cmd_profile
+ {
+ u32 cmd52_count;
+ u32 cmd53_count;
+ u32 tx_count;
+ u32 tx_cfm_count;
+ u32 rx_count;
+ u32 bh_count;
+ u32 process_count;
+ u32 protocol_count;
+
+ u32 cmd52_f0_r_count;
+ u32 cmd52_f0_w_count;
+ u32 cmd52_r8or16_count;
+ u32 cmd52_w8or16_count;
+ u32 cmd52_r16_count;
+ u32 cmd52_w16_count;
+ u32 cmd52_r32_count;
+
+ u32 sdio_cmd_signal;
+ u32 sdio_cmd_clear_slot;
+ u32 sdio_cmd_to_host;
+ u32 sdio_cmd_from_host;
+ u32 sdio_cmd_from_host_and_clear;
+ } hip_prof;
+ struct cmd_profile cmd_prof;
+#endif
+
+ /* Interrupt processing mode flags */
+ u32 intmode;
+
+#ifdef UNIFI_DEBUG
+ u8 lsb;
+#endif
+
+ /* Historic firmware panic codes */
+ u32 panic_data_phy_addr;
+ u32 panic_data_mac_addr;
+ u16 last_phy_panic_code;
+ u16 last_phy_panic_arg;
+ u16 last_mac_panic_code;
+ u16 last_mac_panic_arg;
+#ifdef CSR_PRE_ALLOC_NET_DATA
+ bulk_data_desc_t bulk_data_desc_list[BULK_DATA_PRE_ALLOC_NUM];
+ u16 prealloc_netdata_r;
+ u16 prealloc_netdata_w;
+#endif
+}; /* struct card */
+
+
+/* Reset types */
+enum unifi_reset_type
+{
+ UNIFI_COLD_RESET = 1,
+ UNIFI_WARM_RESET = 2
+};
+
+/*
+ * unifi_set_host_state() implements signalling for waking UniFi from
+ * deep sleep. The host indicates to UniFi that it is in one of three states:
+ * Torpid - host has nothing to send, UniFi can go to sleep.
+ * Drowsy - host has data to send to UniFi. UniFi will respond with an
+ * SDIO interrupt. When hosts responds it moves to Awake.
+ * Awake - host has data to transfer, UniFi must stay awake.
+ * When host has finished, it moves to Torpid.
+ */
+CsrResult unifi_set_host_state(card_t *card, enum unifi_host_state state);
+
+
+CsrResult unifi_set_proc_select(card_t *card, enum unifi_dbg_processors_select select);
+s32 card_read_signal_counts(card_t *card);
+bulk_data_desc_t* card_find_data_slot(card_t *card, s16 slot);
+
+
+CsrResult unifi_read32(card_t *card, u32 unifi_addr, u32 *pdata);
+CsrResult unifi_readnz(card_t *card, u32 unifi_addr,
+ void *pdata, u16 len);
+s32 unifi_read_shared_count(card_t *card, u32 addr);
+
+CsrResult unifi_writen(card_t *card, u32 unifi_addr, void *pdata, u16 len);
+
+CsrResult unifi_bulk_rw(card_t *card, u32 handle,
+ void *pdata, u32 len, s16 direction);
+CsrResult unifi_bulk_rw_noretry(card_t *card, u32 handle,
+ void *pdata, u32 len, s16 direction);
+#define UNIFI_SDIO_READ 0
+#define UNIFI_SDIO_WRITE 1
+
+CsrResult unifi_read_8_or_16(card_t *card, u32 unifi_addr, u8 *pdata);
+CsrResult unifi_write_8_or_16(card_t *card, u32 unifi_addr, u8 data);
+CsrResult unifi_read_direct_8_or_16(card_t *card, u32 addr, u8 *pdata);
+CsrResult unifi_write_direct_8_or_16(card_t *card, u32 addr, u8 data);
+
+CsrResult unifi_read_direct16(card_t *card, u32 addr, u16 *pdata);
+CsrResult unifi_read_direct32(card_t *card, u32 addr, u32 *pdata);
+CsrResult unifi_read_directn(card_t *card, u32 addr, void *pdata, u16 len);
+
+CsrResult unifi_write_direct16(card_t *card, u32 addr, u16 data);
+CsrResult unifi_write_directn(card_t *card, u32 addr, void *pdata, u16 len);
+
+CsrResult sdio_read_f0(card_t *card, u32 addr, u8 *pdata);
+CsrResult sdio_write_f0(card_t *card, u32 addr, u8 data);
+
+void unifi_read_panic(card_t *card);
+#ifdef CSR_PRE_ALLOC_NET_DATA
+void prealloc_netdata_free(card_t *card);
+CsrResult prealloc_netdata_alloc(card_t *card);
+#endif
+/* For diagnostic use */
+void dump(void *mem, u16 len);
+void dump16(void *mem, u16 len);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __CARD_SDIO_H__ */
diff --git a/drivers/staging/csr/csr_wifi_hip_card_sdio_intr.c b/drivers/staging/csr/csr_wifi_hip_card_sdio_intr.c
new file mode 100644
index 000000000000..97f645c06818
--- /dev/null
+++ b/drivers/staging/csr/csr_wifi_hip_card_sdio_intr.c
@@ -0,0 +1,2595 @@
+/*****************************************************************************
+
+ (c) Cambridge Silicon Radio Limited 2012
+ All rights reserved and confidential information of CSR
+
+ Refer to LICENSE.txt included with this source for details
+ on the license terms.
+
+*****************************************************************************/
+
+/*
+ * ---------------------------------------------------------------------------
+ * FILE: csr_wifi_hip_card_sdio_intr.c
+ *
+ * PURPOSE:
+ * Interrupt processing for the UniFi SDIO driver.
+ *
+ * We may need another signal queue of responses to UniFi to hold
+ * bulk data commands generated by read_to_host_signals().
+ *
+ * ---------------------------------------------------------------------------
+ */
+#undef CSR_WIFI_HIP_NOISY
+
+#include "csr_wifi_hip_unifi.h"
+#include "csr_wifi_hip_conversions.h"
+#include "csr_wifi_hip_card.h"
+#include "csr_wifi_hip_xbv.h"
+
+
+/*
+ * If the SDIO link is idle for this time (in milliseconds),
+ * signal UniFi to go into Deep Sleep.
+ * Valid return value of unifi_bh().
+ */
+#define UNIFI_DEFAULT_HOST_IDLE_TIMEOUT 5
+/*
+ * If the UniFi has not woken up for this time (in milliseconds),
+ * signal the bottom half to take action.
+ * Valid return value of unifi_bh().
+ */
+#define UNIFI_DEFAULT_WAKE_TIMEOUT 1000
+
+
+static CsrResult process_bh(card_t *card);
+static CsrResult handle_host_protocol(card_t *card, u8 *processed_something);
+
+static CsrResult flush_fh_buffer(card_t *card);
+
+static CsrResult check_fh_sig_slots(card_t *card, u16 needed, s32 *space);
+
+static CsrResult read_to_host_signals(card_t *card, s32 *processed);
+static CsrResult process_to_host_signals(card_t *card, s32 *processed);
+
+static CsrResult process_bulk_data_command(card_t *card,
+ const u8 *cmdptr,
+ s16 cmd, u16 len);
+static CsrResult process_clear_slot_command(card_t *card,
+ const u8 *cmdptr);
+static CsrResult process_fh_cmd_queue(card_t *card, s32 *processed);
+static CsrResult process_fh_traffic_queue(card_t *card, s32 *processed);
+static void restart_packet_flow(card_t *card);
+static CsrResult process_clock_request(card_t *card);
+
+#ifdef CSR_WIFI_HIP_NOISY
+s16 dump_fh_buf = 0;
+#endif /* CSR_WIFI_HIP_NOISY */
+
+#ifdef CSR_WIFI_HIP_DEBUG_OFFLINE
+
+/*
+ * The unifi_debug_output buffer can be used to debug the HIP behaviour offline
+ * i.e. without using the tracing functions that change the timing.
+ *
+ * Call unifi_debug_log_to_buf() with printf arguments to store a string into
+ * unifi_debug_output. When unifi_debug_buf_dump() is called, the contents of the
+ * buffer are dumped with dump_str() which has to be implemented in the
+ * OS layer, during the porting exercise. The offset printed, holds the
+ * offset where the last character is (always a zero).
+ *
+ */
+
+#define UNIFI_DEBUG_GBUFFER_SIZE 8192
+static char unifi_debug_output[UNIFI_DEBUG_GBUFFER_SIZE];
+static char *unifi_dbgbuf_ptr = unifi_debug_output;
+static char *unifi_dbgbuf_start = unifi_debug_output;
+
+static void append_char(char c)
+{
+ /* write char and advance pointer */
+ *unifi_dbgbuf_ptr++ = c;
+ /* wrap pointer at end of buffer */
+ if ((unifi_dbgbuf_ptr - unifi_debug_output) >= UNIFI_DEBUG_GBUFFER_SIZE)
+ {
+ unifi_dbgbuf_ptr = unifi_debug_output;
+ }
+} /* append_char() */
+
+
+void unifi_debug_string_to_buf(const char *str)
+{
+ const char *p = str;
+ while (*p)
+ {
+ append_char(*p);
+ p++;
+ }
+ /* Update start-of-buffer pointer */
+ unifi_dbgbuf_start = unifi_dbgbuf_ptr + 1;
+ if ((unifi_dbgbuf_start - unifi_debug_output) >= UNIFI_DEBUG_GBUFFER_SIZE)
+ {
+ unifi_dbgbuf_start = unifi_debug_output;
+ }
+}
+
+
+void unifi_debug_log_to_buf(const char *fmt, ...)
+{
+#define DEBUG_BUFFER_SIZE 80
+ static char s[DEBUG_BUFFER_SIZE];
+ va_list args;
+
+ va_start(args, fmt);
+ vsnprintf(s, DEBUG_BUFFER_SIZE, fmt, args);
+ va_end(args);
+
+ unifi_debug_string_to_buf(s);
+} /* unifi_debug_log_to_buf() */
+
+
+/* Convert signed 32 bit (or less) integer to string */
+static void CsrUInt16ToHex(u16 number, char *str)
+{
+ u16 index;
+ u16 currentValue;
+
+ for (index = 0; index < 4; index++)
+ {
+ currentValue = (u16) (number & 0x000F);
+ number >>= 4;
+ str[3 - index] = (char) (currentValue > 9 ? currentValue + 55 : currentValue + '0');
+ }
+ str[4] = '\0';
+}
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * unifi_debug_hex_to_buf
+ *
+ * puts the contents of the passed buffer into the debug buffer as a hex string
+ *
+ * Arguments:
+ * buff buffer to print as hex
+ * length number of chars to print
+ *
+ * Returns:
+ * None.
+ *
+ * ---------------------------------------------------------------------------
+ */
+void unifi_debug_hex_to_buf(const char *buff, u16 length)
+{
+ char s[5];
+ u16 i;
+
+ for (i = 0; i < length; i = i + 2)
+ {
+ CsrUInt16ToHex(*((u16 *)(buff + i)), s);
+ unifi_debug_string_to_buf(s);
+ }
+}
+
+
+void unifi_debug_buf_dump(void)
+{
+ s32 offset = unifi_dbgbuf_ptr - unifi_debug_output;
+
+ unifi_error(NULL, "HIP debug buffer offset=%d\n", offset);
+ dump_str(unifi_debug_output + offset, UNIFI_DEBUG_GBUFFER_SIZE - offset);
+ dump_str(unifi_debug_output, offset);
+} /* unifi_debug_buf_dump() */
+
+
+#endif /* CSR_WIFI_HIP_DEBUG_OFFLINE */
+
+#ifdef CSR_PRE_ALLOC_NET_DATA
+#define NETDATA_PRE_ALLOC_BUF_SIZE 8000
+
+void prealloc_netdata_free(card_t *card)
+{
+ unifi_warning(card->ospriv, "prealloc_netdata_free: IN: w=%d r=%d\n", card->prealloc_netdata_w, card->prealloc_netdata_r);
+
+ while (card->bulk_data_desc_list[card->prealloc_netdata_r].data_length != 0)
+ {
+ unifi_warning(card->ospriv, "prealloc_netdata_free: r=%d\n", card->prealloc_netdata_r);
+
+ unifi_net_data_free(card->ospriv, &card->bulk_data_desc_list[card->prealloc_netdata_r]);
+ card->prealloc_netdata_r++;
+ card->prealloc_netdata_r %= BULK_DATA_PRE_ALLOC_NUM;
+ }
+ card->prealloc_netdata_r = card->prealloc_netdata_w = 0;
+
+ unifi_warning(card->ospriv, "prealloc_netdata_free: OUT: w=%d r=%d\n", card->prealloc_netdata_w, card->prealloc_netdata_r);
+}
+
+
+CsrResult prealloc_netdata_alloc(card_t *card)
+{
+ CsrResult r;
+
+ unifi_trace(card->ospriv, UDBG5, "prealloc_netdata_alloc: IN: w=%d r=%d\n", card->prealloc_netdata_w, card->prealloc_netdata_r);
+
+ while (card->bulk_data_desc_list[card->prealloc_netdata_w].data_length == 0)
+ {
+ r = unifi_net_data_malloc(card->ospriv, &card->bulk_data_desc_list[card->prealloc_netdata_w], NETDATA_PRE_ALLOC_BUF_SIZE);
+ if (r != CSR_RESULT_SUCCESS)
+ {
+ unifi_error(card->ospriv, "prealloc_netdata_alloc: Failed to allocate t-h bulk data\n");
+ return CSR_RESULT_FAILURE;
+ }
+ card->prealloc_netdata_w++;
+ card->prealloc_netdata_w %= BULK_DATA_PRE_ALLOC_NUM;
+ }
+ unifi_trace(card->ospriv, UDBG5, "prealloc_netdata_alloc: OUT: w=%d r=%d\n", card->prealloc_netdata_w, card->prealloc_netdata_r);
+
+ return CSR_RESULT_SUCCESS;
+}
+
+
+static CsrResult prealloc_netdata_get(card_t *card, bulk_data_desc_t *bulk_data_slot, u32 size)
+{
+ CsrResult r;
+
+ unifi_trace(card->ospriv, UDBG5, "prealloc_netdata_get: IN: w=%d r=%d\n", card->prealloc_netdata_w, card->prealloc_netdata_r);
+
+ if (card->bulk_data_desc_list[card->prealloc_netdata_r].data_length == 0)
+ {
+ unifi_error(card->ospriv, "prealloc_netdata_get: data_length = 0\n");
+ }
+
+ if ((size > NETDATA_PRE_ALLOC_BUF_SIZE) || (card->bulk_data_desc_list[card->prealloc_netdata_r].data_length == 0))
+ {
+ unifi_warning(card->ospriv, "prealloc_netdata_get: Calling net_data_malloc\n");
+
+ r = unifi_net_data_malloc(card->ospriv, bulk_data_slot, size);
+ if (r != CSR_RESULT_SUCCESS)
+ {
+ unifi_error(card->ospriv, "prealloc_netdata_get: Failed to allocate t-h bulk data\n");
+ return CSR_RESULT_FAILURE;
+ }
+ return CSR_RESULT_SUCCESS;
+ }
+
+ *bulk_data_slot = card->bulk_data_desc_list[card->prealloc_netdata_r];
+ card->bulk_data_desc_list[card->prealloc_netdata_r].os_data_ptr = NULL;
+ card->bulk_data_desc_list[card->prealloc_netdata_r].os_net_buf_ptr = NULL;
+ card->bulk_data_desc_list[card->prealloc_netdata_r].net_buf_length = 0;
+ card->bulk_data_desc_list[card->prealloc_netdata_r].data_length = 0;
+
+ card->prealloc_netdata_r++;
+ card->prealloc_netdata_r %= BULK_DATA_PRE_ALLOC_NUM;
+
+ unifi_trace(card->ospriv, UDBG5, "prealloc_netdata_get: OUT: w=%d r=%d\n", card->prealloc_netdata_w, card->prealloc_netdata_r);
+
+ return CSR_RESULT_SUCCESS;
+}
+
+
+#endif
+
+/*
+ * ---------------------------------------------------------------------------
+ * unifi_sdio_interrupt_handler
+ *
+ * This function should be called by the OS-dependent code to handle
+ * an SDIO interrupt from the UniFi.
+ *
+ * Arguments:
+ * card Pointer to card context structure.
+ *
+ * Returns:
+ * None.
+ *
+ * Notes: This function may be called in DRS context. In this case,
+ * tracing with the unifi_trace(), etc, is not allowed.
+ * ---------------------------------------------------------------------------
+ */
+void unifi_sdio_interrupt_handler(card_t *card)
+{
+ /*
+ * Set the flag to say reason for waking was SDIO interrupt.
+ * Then ask the OS layer to run the unifi_bh to give attention to the UniFi.
+ */
+ card->bh_reason_unifi = 1;
+ (void)unifi_run_bh(card->ospriv);
+} /* sdio_interrupt_handler() */
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * unifi_configure_low_power_mode
+ *
+ * This function should be called by the OS-dependent when
+ * the deep sleep signaling needs to be enabled or disabled.
+ *
+ * Arguments:
+ * card Pointer to card context structure.
+ * low_power_mode Disable/Enable the deep sleep signaling
+ * periodic_wake_mode UniFi wakes host periodically.
+ *
+ * Returns:
+ * CSR_RESULT_SUCCESS on success or a CSR error code.
+ * ---------------------------------------------------------------------------
+ */
+CsrResult unifi_configure_low_power_mode(card_t *card,
+ enum unifi_low_power_mode low_power_mode,
+ enum unifi_periodic_wake_mode periodic_wake_mode)
+{
+ card->low_power_mode = low_power_mode;
+ card->periodic_wake_mode = periodic_wake_mode;
+
+ unifi_trace(card->ospriv, UDBG1,
+ "unifi_configure_low_power_mode: new mode = %s, wake_host = %s\n",
+ (low_power_mode == UNIFI_LOW_POWER_DISABLED)?"disabled" : "enabled",
+ (periodic_wake_mode == UNIFI_PERIODIC_WAKE_HOST_DISABLED)?"FALSE" : "TRUE");
+
+ (void)unifi_run_bh(card->ospriv);
+ return CSR_RESULT_SUCCESS;
+} /* unifi_configure_low_power_mode() */
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * unifi_force_low_power_mode
+ *
+ * This function should be called by the OS-dependent when
+ * UniFi needs to be set to the low power mode (e.g. on suspend)
+ *
+ * Arguments:
+ * card Pointer to card context structure.
+ *
+ * Returns:
+ * CSR_RESULT_SUCCESS on success or a CSR error code.
+ * ---------------------------------------------------------------------------
+ */
+CsrResult unifi_force_low_power_mode(card_t *card)
+{
+ if (card->low_power_mode == UNIFI_LOW_POWER_DISABLED)
+ {
+ unifi_error(card->ospriv, "Attempt to set mode to TORPID when lower power mode is disabled\n");
+ return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
+ }
+
+ return unifi_set_host_state(card, UNIFI_HOST_STATE_TORPID);
+} /* unifi_force_low_power_mode() */
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * unifi_bh
+ *
+ * This function should be called by the OS-dependent code when
+ * host and/or UniFi has requested an exchange of messages.
+ *
+ * Arguments:
+ * card Pointer to card context structure.
+ *
+ * Returns:
+ * CSR_RESULT_SUCCESS on success or a CSR error code.
+ * ---------------------------------------------------------------------------
+ */
+CsrResult unifi_bh(card_t *card, u32 *remaining)
+{
+ CsrResult r;
+ CsrResult csrResult;
+ u8 pending;
+ s32 iostate, j;
+ const enum unifi_low_power_mode low_power_mode = card->low_power_mode;
+ u16 data_slots_used = 0;
+
+
+ /* Process request to raise the maximum SDIO clock */
+ r = process_clock_request(card);
+ if (r != CSR_RESULT_SUCCESS)
+ {
+ unifi_error(card->ospriv, "Error setting maximum SDIO clock\n");
+ goto exit;
+ }
+
+ /*
+ * Why was the BH thread woken?
+ * If it was an SDIO interrupt, UniFi is awake and we need to process it.
+ * If it was a host process queueing data, then we need to awaken UniFi.
+ *
+ * Priority of flags is top down.
+ *
+ * ----------------------------------------------------------+
+ * \state| AWAKE | DROWSY | TORPID |
+ * flag\ | | | |
+ * ---------+--------------+----------------+----------------|
+ * | do the host | go to AWAKE and| go to AWAKE and|
+ * unifi | protocol | do the host | do the host |
+ * | | protocol | protocol |
+ * ---------+--------------+----------------+----------------|
+ * | do the host | | |
+ * host | protocol | do nothing | go to DROWSY |
+ * | | | |
+ * ---------+--------------+----------------+----------------|
+ * | | | should not |
+ * timeout | go to TORPID | error, unifi | occur |
+ * | | didn't wake up | do nothing |
+ * ----------------------------------------------------------+
+ *
+ * Note that if we end up in the AWAKE state we always do the host protocol.
+ */
+
+ do
+ {
+ /*
+ * When the host state is set to DROWSY, then we can not disable the
+ * interrupts as UniFi can generate an interrupt even when the INT_ENABLE
+ * register has the interrupts disabled. This interrupt will be lost.
+ */
+ if (card->host_state == UNIFI_HOST_STATE_DROWSY || card->host_state == UNIFI_HOST_STATE_TORPID)
+ {
+ u8 reason_unifi;
+
+ /*
+ * An interrupt may occur while or after we cache the reason.
+ * This interrupt will cause the unifi_bh() to be scheduled again.
+ * Any interrupt that has happened before the register is read
+ * and is considered spurious has to acknowledged.
+ */
+ reason_unifi = card->bh_reason_unifi;
+
+ /*
+ * If an interrupt is received, check if it was a real one,
+ * set the host state to AWAKE and run the BH.
+ */
+ r = CardPendingInt(card, &pending);
+ if (r != CSR_RESULT_SUCCESS)
+ {
+ goto exit;
+ }
+
+ if (pending)
+ {
+ unifi_trace(card->ospriv, UDBG5,
+ "UNIFI_HOST_STATE_%s: Set state to AWAKE.\n",
+ (card->host_state == UNIFI_HOST_STATE_TORPID)?"TORPID" : "DROWSY");
+
+ r = unifi_set_host_state(card, UNIFI_HOST_STATE_AWAKE);
+ if (r == CSR_RESULT_SUCCESS)
+ {
+ (*remaining) = 0;
+ break;
+ }
+ }
+ else if (reason_unifi)
+ {
+ CsrSdioInterruptAcknowledge(card->sdio_if);
+ }
+
+ /*
+ * If an chip is in TORPID, and the host wants to wake it up,
+ * set the host state to DROWSY and wait for the wake-up interrupt.
+ */
+ if ((card->host_state == UNIFI_HOST_STATE_TORPID) && card->bh_reason_host)
+ {
+ r = unifi_set_host_state(card, UNIFI_HOST_STATE_DROWSY);
+ if (r == CSR_RESULT_SUCCESS)
+ {
+ /*
+ * set the timeout value to UNIFI_DEFAULT_WAKE_TIMEOUT
+ * to capture a wake error.
+ */
+ card->bh_reason_host = 0;
+ (*remaining) = UNIFI_DEFAULT_WAKE_TIMEOUT;
+ return CSR_RESULT_SUCCESS;
+ }
+
+ goto exit;
+ }
+
+ /*
+ * If the chip is in DROWSY, and the timeout expires,
+ * we need to reset the chip. This should never occur.
+ * (If it does, check that the calling thread set "remaining"
+ * according to the time remaining when unifi_bh() was called).
+ */
+ if ((card->host_state == UNIFI_HOST_STATE_DROWSY) && ((*remaining) == 0))
+ {
+ unifi_error(card->ospriv, "UniFi did not wake up on time...\n");
+
+ /*
+ * Check if Function1 has gone away or
+ * if we missed an SDIO interrupt.
+ */
+ r = unifi_check_io_status(card, &iostate);
+ if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
+ {
+ goto exit;
+ }
+ /* Need to reset and reboot */
+ return CSR_RESULT_FAILURE;
+ }
+ }
+ else
+ {
+ if (card->bh_reason_unifi || card->bh_reason_host)
+ {
+ break;
+ }
+
+ if (((*remaining) == 0) && (low_power_mode == UNIFI_LOW_POWER_ENABLED))
+ {
+ r = unifi_set_host_state(card, UNIFI_HOST_STATE_TORPID);
+ if (r == CSR_RESULT_SUCCESS)
+ {
+ (*remaining) = 0;
+ return CSR_RESULT_SUCCESS;
+ }
+
+ goto exit;
+ }
+ }
+
+ /* No need to run the host protocol */
+ return CSR_RESULT_SUCCESS;
+ } while (0);
+
+
+ /* Disable the SDIO interrupts while doing SDIO ops */
+ csrResult = CsrSdioInterruptDisable(card->sdio_if);
+ if (csrResult == CSR_SDIO_RESULT_NO_DEVICE)
+ {
+ r = CSR_WIFI_HIP_RESULT_NO_DEVICE;
+ goto exit;
+ }
+ if (csrResult != CSR_RESULT_SUCCESS)
+ {
+ r = ConvertCsrSdioToCsrHipResult(card, csrResult);
+ unifi_error(card->ospriv, "Failed to disable SDIO interrupts. unifi_bh queues error.\n");
+ goto exit;
+ }
+
+ /* Now that the interrupts are disabled, ack the interrupt */
+ CsrSdioInterruptAcknowledge(card->sdio_if);
+
+ /* Run the HIP */
+ r = process_bh(card);
+ if (r != CSR_RESULT_SUCCESS)
+ {
+ goto exit;
+ }
+
+ /*
+ * If host is now idle, schedule a timer for the delay before we
+ * let UniFi go into deep sleep.
+ * If the timer goes off, we will move to TORPID state.
+ * If UniFi raises an interrupt in the meantime, we will cancel
+ * the timer and start a new one when we become idle.
+ */
+ for (j = 0; j < UNIFI_NO_OF_TX_QS; j++)
+ {
+ data_slots_used += CSR_WIFI_HIP_Q_SLOTS_USED(&card->fh_traffic_queue[j]);
+ }
+
+ if ((low_power_mode == UNIFI_LOW_POWER_ENABLED) && (data_slots_used == 0))
+ {
+#ifndef CSR_WIFI_HIP_TA_DISABLE
+ if (card->ta_sampling.traffic_type != CSR_WIFI_ROUTER_CTRL_TRAFFIC_TYPE_PERIODIC)
+ {
+#endif
+ /* return the UNIFI_DEFAULT_HOST_IDLE_TIMEOUT, so we can go to sleep. */
+ unifi_trace(card->ospriv, UDBG5,
+ "Traffic is not periodic, set timer for TORPID.\n");
+ (*remaining) = UNIFI_DEFAULT_HOST_IDLE_TIMEOUT;
+#ifndef CSR_WIFI_HIP_TA_DISABLE
+ }
+ else
+ {
+ unifi_trace(card->ospriv, UDBG5,
+ "Traffic is periodic, set unifi to TORPID immediately.\n");
+ if (CardAreAllFromHostDataSlotsEmpty(card) == 1)
+ {
+ r = unifi_set_host_state(card, UNIFI_HOST_STATE_TORPID);
+ if (r != CSR_RESULT_SUCCESS)
+ {
+ goto exit;
+ }
+ }
+ }
+#endif
+ }
+
+ csrResult = CsrSdioInterruptEnable(card->sdio_if);
+ if (csrResult == CSR_SDIO_RESULT_NO_DEVICE)
+ {
+ r = CSR_WIFI_HIP_RESULT_NO_DEVICE;
+ }
+ if (csrResult != CSR_RESULT_SUCCESS)
+ {
+ r = ConvertCsrSdioToCsrHipResult(card, csrResult);
+ unifi_error(card->ospriv, "Failed to enable SDIO interrupt\n");
+ }
+
+exit:
+
+ unifi_trace(card->ospriv, UDBG4, "New state=%d\n", card->host_state);
+
+ if (r != CSR_RESULT_SUCCESS)
+ {
+#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_SDIO_TRACE)
+ unifi_debug_buf_dump();
+#endif
+ /* If an interrupt has been raised, ack it here */
+ if (card->bh_reason_unifi)
+ {
+ CsrSdioInterruptAcknowledge(card->sdio_if);
+ }
+
+ unifi_error(card->ospriv,
+ "unifi_bh: state=%d %c, clock=%dkHz, interrupt=%d host=%d, power_save=%s\n",
+ card->host_state,
+ (card->host_state == UNIFI_HOST_STATE_AWAKE)?'A' : (card->host_state == UNIFI_HOST_STATE_DROWSY)?'D' : 'T',
+ card->sdio_clock_speed / 1000,
+ card->bh_reason_unifi, card->bh_reason_host,
+ (low_power_mode == UNIFI_LOW_POWER_DISABLED)?"disabled" : "enabled");
+
+ /* Try to capture firmware panic codes */
+ (void)unifi_capture_panic(card);
+
+ /* Ask for a mini-coredump when the driver has reset UniFi */
+ (void)unifi_coredump_request_at_next_reset(card, 1);
+ }
+
+ return r;
+} /* unifi_bh() */
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * process_clock_request
+ *
+ * Handle request from the OS layer to increase the SDIO clock speed.
+ * The fast clock is limited until the firmware has indicated that it has
+ * completed initialisation to the OS layer.
+ *
+ * Arguments:
+ * card Pointer to card context structure.
+ *
+ * Returns:
+ * CSR_RESULT_SUCCESS on success or CSR error code.
+ * ---------------------------------------------------------------------------
+ */
+static CsrResult process_clock_request(card_t *card)
+{
+ CsrResult r = CSR_RESULT_SUCCESS;
+ CsrResult csrResult;
+
+ if (!card->request_max_clock)
+ {
+ return CSR_RESULT_SUCCESS; /* No pending request */
+ }
+
+ /*
+ * The SDIO clock speed request from the OS layer is only acted upon if
+ * the UniFi is awake. If it was in any other state, the clock speed will
+ * transition through SAFE to MAX while the host wakes it up, and the
+ * final speed reached will be UNIFI_SDIO_CLOCK_MAX_HZ.
+ * This assumes that the SME never requests low power mode while the f/w
+ * initialisation takes place.
+ */
+ if (card->host_state == UNIFI_HOST_STATE_AWAKE)
+ {
+ unifi_trace(card->ospriv, UDBG1, "Set SDIO max clock\n");
+ csrResult = CsrSdioMaxBusClockFrequencySet(card->sdio_if, UNIFI_SDIO_CLOCK_MAX_HZ);
+ if (csrResult != CSR_RESULT_SUCCESS)
+ {
+ r = ConvertCsrSdioToCsrHipResult(card, csrResult);
+ }
+ else
+ {
+ card->sdio_clock_speed = UNIFI_SDIO_CLOCK_MAX_HZ; /* log the new freq */
+ }
+ }
+ else
+ {
+ unifi_trace(card->ospriv, UDBG1, "Will set SDIO max clock after wakeup\n");
+ }
+
+ /* Cancel the request now that it has been acted upon, or is about to be
+ * by the wakeup mechanism
+ */
+ card->request_max_clock = 0;
+
+ return r;
+}
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * process_bh
+ *
+ * Exchange messages with UniFi
+ *
+ * Arguments:
+ * card Pointer to card context structure.
+ *
+ * Returns:
+ * CSR_RESULT_SUCCESS on success or CSR error code.
+ * ---------------------------------------------------------------------------
+ */
+static CsrResult process_bh(card_t *card)
+{
+ CsrResult r;
+ u8 more;
+ more = FALSE;
+
+ /* Process the reasons (interrupt, signals) */
+ do
+ {
+ /*
+ * Run in a while loop, to save clearing the interrupts
+ * every time around the outside loop.
+ */
+ do
+ {
+ /* If configured to run the HIP just once, skip first loop */
+ if (card->intmode & CSR_WIFI_INTMODE_RUN_BH_ONCE)
+ {
+ break;
+ }
+
+ r = handle_host_protocol(card, &more);
+ if (r != CSR_RESULT_SUCCESS)
+ {
+ return r;
+ }
+
+#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_DATA_PLANE_PROFILE)
+ unifi_debug_log_to_buf("c52=%d c53=%d tx=%d txc=%d rx=%d s=%d t=%d fc=%d\n",
+ card->cmd_prof.cmd52_count,
+ card->cmd_prof.cmd53_count,
+ card->cmd_prof.tx_count,
+ card->cmd_prof.tx_cfm_count,
+ card->cmd_prof.rx_count,
+ card->cmd_prof.sdio_cmd_signal,
+ card->cmd_prof.sdio_cmd_to_host,
+ card->cmd_prof.sdio_cmd_from_host_and_clear
+ );
+
+ card->cmd_prof.cmd52_count = card->cmd_prof.cmd53_count = 0;
+ card->cmd_prof.tx_count = card->cmd_prof.tx_cfm_count = card->cmd_prof.rx_count = 0;
+
+ card->cmd_prof.cmd52_f0_r_count = 0;
+ card->cmd_prof.cmd52_f0_w_count = 0;
+ card->cmd_prof.cmd52_r8or16_count = 0;
+ card->cmd_prof.cmd52_w8or16_count = 0;
+ card->cmd_prof.cmd52_r16_count = 0;
+ card->cmd_prof.cmd52_w16_count = 0;
+ card->cmd_prof.cmd52_r32_count = 0;
+
+ card->cmd_prof.sdio_cmd_signal = 0;
+ card->cmd_prof.sdio_cmd_clear_slot = 0;
+ card->cmd_prof.sdio_cmd_to_host = 0;
+ card->cmd_prof.sdio_cmd_from_host = 0;
+ card->cmd_prof.sdio_cmd_from_host_and_clear = 0;
+#endif
+
+
+ } while (more || card->bh_reason_unifi || card->bh_reason_host);
+
+ /* Acknowledge the h/w interrupt */
+ r = CardClearInt(card);
+ if (r != CSR_RESULT_SUCCESS)
+ {
+ unifi_error(card->ospriv, "Failed to acknowledge interrupt.\n");
+ return r;
+ }
+
+ /*
+ * UniFi may have tried to generate an interrupt during the
+ * CardClearInt() was running. So, we need to run the host
+ * protocol again, to check if there are any pending requests.
+ */
+ r = handle_host_protocol(card, &more);
+ if (r != CSR_RESULT_SUCCESS)
+ {
+ return r;
+ }
+
+#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_DATA_PLANE_PROFILE)
+ unifi_debug_log_to_buf("c52=%d c53=%d tx=%d txc=%d rx=%d s=%d t=%d fc=%d\n",
+ card->cmd_prof.cmd52_count,
+ card->cmd_prof.cmd53_count,
+ card->cmd_prof.tx_count,
+ card->cmd_prof.tx_cfm_count,
+ card->cmd_prof.rx_count,
+ card->cmd_prof.sdio_cmd_signal,
+ card->cmd_prof.sdio_cmd_to_host,
+ card->cmd_prof.sdio_cmd_from_host_and_clear
+ );
+
+ card->cmd_prof.cmd52_count = card->cmd_prof.cmd53_count = 0;
+ card->cmd_prof.tx_count = card->cmd_prof.tx_cfm_count = card->cmd_prof.rx_count = 0;
+
+ card->cmd_prof.cmd52_f0_r_count = 0;
+ card->cmd_prof.cmd52_f0_w_count = 0;
+ card->cmd_prof.cmd52_r8or16_count = 0;
+ card->cmd_prof.cmd52_w8or16_count = 0;
+ card->cmd_prof.cmd52_r16_count = 0;
+ card->cmd_prof.cmd52_w16_count = 0;
+ card->cmd_prof.cmd52_r32_count = 0;
+
+ card->cmd_prof.sdio_cmd_signal = 0;
+ card->cmd_prof.sdio_cmd_clear_slot = 0;
+ card->cmd_prof.sdio_cmd_to_host = 0;
+ card->cmd_prof.sdio_cmd_from_host = 0;
+ card->cmd_prof.sdio_cmd_from_host_and_clear = 0;
+#endif
+ /* If configured to run the HIP just once, work is now done */
+ if (card->intmode & CSR_WIFI_INTMODE_RUN_BH_ONCE)
+ {
+ break;
+ }
+
+ } while (more || card->bh_reason_unifi || card->bh_reason_host);
+
+#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_DATA_PLANE_PROFILE)
+ if ((card->intmode & CSR_WIFI_INTMODE_RUN_BH_ONCE) == 0)
+ {
+ unifi_debug_log_to_buf("proc=%d\n",
+ card->cmd_prof.process_count);
+ }
+#endif
+
+ return CSR_RESULT_SUCCESS;
+} /* process_bh() */
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * handle_host_protocol
+ *
+ * This function implements the Host Interface Protocol (HIP) as
+ * described in the Host Interface Protocol Specification.
+ *
+ * Arguments:
+ * card Pointer to card context structure.
+ * processed_something Pointer to location to update processing status:
+ * TRUE when data was transferred
+ * FALSE when no data was transferred (queues empty)
+ *
+ * Returns:
+ * CSR_RESULT_SUCCESS on success or CSR error code.
+ * ---------------------------------------------------------------------------
+ */
+static CsrResult handle_host_protocol(card_t *card, u8 *processed_something)
+{
+ CsrResult r;
+ s32 done;
+
+ *processed_something = FALSE;
+
+#ifdef CSR_WIFI_HIP_NOISY
+ unifi_error(card->ospriv, " ======================== \n");
+#endif /* CSR_WIFI_HIP_NOISY */
+
+#ifdef CSR_WIFI_HIP_DATA_PLANE_PROFILE
+ card->cmd_prof.process_count++;
+#endif
+
+ card->bh_reason_unifi = card->bh_reason_host = 0;
+ card->generate_interrupt = 0;
+
+
+ /*
+ * (Re)fill the T-H signal buffer
+ */
+ r = read_to_host_signals(card, &done);
+ if (r != CSR_RESULT_SUCCESS)
+ {
+ unifi_error(card->ospriv, "Error occured reading to-host signals\n");
+ return r;
+ }
+ if (done > 0)
+ {
+ *processed_something = TRUE;
+ }
+
+ /*
+ * Process any to-host signals.
+ * Perform any requested CMD53 transfers here, but just queue any
+ * bulk data command responses.
+ */
+ r = process_to_host_signals(card, &done);
+ if (r != CSR_RESULT_SUCCESS)
+ {
+ unifi_error(card->ospriv, "Error occured processing to-host signals\n");
+ return r;
+ }
+
+ /* Now send any signals in the F-H queues */
+ /* Give precedence to the command queue */
+ r = process_fh_cmd_queue(card, &done);
+ if (r != CSR_RESULT_SUCCESS)
+ {
+ unifi_error(card->ospriv, "Error occured processing from-host signals\n");
+ return r;
+ }
+ if (done > 0)
+ {
+ *processed_something = TRUE;
+ }
+
+ r = process_fh_traffic_queue(card, &done);
+ if (r != CSR_RESULT_SUCCESS)
+ {
+ unifi_error(card->ospriv, "Error occured processing from-host data signals\n");
+ return r;
+ }
+ if (done > 0)
+ {
+ *processed_something = TRUE;
+ }
+
+ /* Flush out the batch of signals to the UniFi. */
+ r = flush_fh_buffer(card);
+ if (r != CSR_RESULT_SUCCESS)
+ {
+ unifi_error(card->ospriv, "Failed to copy from-host signals to UniFi\n");
+ return r;
+ }
+
+
+ /*
+ * Send the host interrupt to say the queues have been modified.
+ */
+ if (card->generate_interrupt)
+ {
+ r = CardGenInt(card);
+ if (r != CSR_RESULT_SUCCESS)
+ {
+ unifi_error(card->ospriv, "Failed to notify UniFi that queues have been modified.\n");
+ return r;
+ }
+ }
+
+#ifdef CSR_WIFI_RX_PATH_SPLIT
+#ifdef CSR_WIFI_RX_PATH_SPLIT_DONT_USE_WQ
+ unifi_rx_queue_flush(card->ospriv);
+#endif
+#endif
+
+ /* See if we can re-enable transmission now */
+ restart_packet_flow(card);
+
+#ifdef CSR_PRE_ALLOC_NET_DATA
+ r = prealloc_netdata_alloc(card);
+ if (r != CSR_RESULT_SUCCESS)
+ {
+ unifi_error(card->ospriv, "prealloc_netdata failed\n");
+ return r;
+ }
+#endif
+
+ /*
+ * Don't put the thread sleep if we just interacted with the chip,
+ * there might be more to do if we look again.
+ */
+ return r;
+} /* handle_host_protocol() */
+
+
+/*
+ * Rounds the given signal length in bytes to a whole number
+ * of sig_frag_size.
+ */
+#define GET_CHUNKS_FOR(SIG_FRAG_SIZE, LENGTH) (((LENGTH) + ((SIG_FRAG_SIZE)-1)) / (SIG_FRAG_SIZE))
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * read_to_host_signals
+ *
+ * Read everything pending in the UniFi TH signal buffer.
+ * Only do it if the local buffer is empty.
+ *
+ * Arguments:
+ * card Pointer to card context struct
+ * processed Number of signals read:
+ * 0 if there were no signals pending,
+ * 1 if we read at least one signal
+ * Returns:
+ * CSR error code if an error occurred.
+ * ---------------------------------------------------------------------------
+ */
+static CsrResult read_to_host_signals(card_t *card, s32 *processed)
+{
+ s32 count_thw, count_thr;
+ s32 unread_chunks, unread_bytes;
+ CsrResult r;
+
+ *processed = 0;
+
+ /* Read any pending signals or bulk data commands */
+ count_thw = unifi_read_shared_count(card, card->sdio_ctrl_addr + 4);
+ if (count_thw < 0)
+ {
+ unifi_error(card->ospriv, "Failed to read to-host sig written count\n");
+ return CSR_RESULT_FAILURE;
+ }
+ card->to_host_signals_w = count_thw; /* diag */
+
+ count_thr = card->to_host_signals_r;
+
+ if (count_thw == count_thr)
+ {
+ return CSR_RESULT_SUCCESS;
+ }
+
+ unread_chunks =
+ (((count_thw - count_thr) + 128) % 128) - card->th_buffer.count;
+
+ if (unread_chunks == 0)
+ {
+ return CSR_RESULT_SUCCESS;
+ }
+
+ unread_bytes = card->config_data.sig_frag_size * unread_chunks;
+
+
+ r = unifi_bulk_rw(card,
+ card->config_data.tohost_sigbuf_handle,
+ card->th_buffer.ptr,
+ unread_bytes,
+ UNIFI_SDIO_READ);
+ if (r != CSR_RESULT_SUCCESS)
+ {
+ unifi_error(card->ospriv, "Failed to read ToHost signal\n");
+ return r;
+ }
+
+ card->th_buffer.ptr += unread_bytes;
+ card->th_buffer.count += (u16)unread_chunks;
+
+ *processed = 1;
+
+ return CSR_RESULT_SUCCESS;
+} /* read_to_host_signals() */
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * update_to_host_signals_r
+ *
+ * Advance the shared-memory count of chunks read from the to-host
+ * signal buffer.
+ * Raise a UniFi internal interrupt to tell the firmware that the
+ * count has changed.
+ *
+ * Arguments:
+ * card Pointer to card context struct
+ * pending Number of chunks remaining
+ *
+ * Returns:
+ * CSR_RESULT_SUCCESS on success or CSR error code
+ * ---------------------------------------------------------------------------
+ */
+static CsrResult update_to_host_signals_r(card_t *card, s16 pending)
+{
+ CsrResult r;
+
+ card->to_host_signals_r =
+ (card->to_host_signals_r + (card->th_buffer.count - pending)) % 128;
+ card->th_buffer.count = pending;
+
+ /* Update the count of signals read */
+ r = unifi_write_8_or_16(card, card->sdio_ctrl_addr + 6,
+ (u8)card->to_host_signals_r);
+ if (r != CSR_RESULT_SUCCESS)
+ {
+ unifi_error(card->ospriv, "Failed to update to-host signals read\n");
+ return r;
+ }
+
+ r = CardGenInt(card);
+ if (r != CSR_RESULT_SUCCESS)
+ {
+ unifi_error(card->ospriv, "Failed to notify UniFi that we processed to-host signals.\n");
+ return r;
+ }
+
+ card->generate_interrupt = 0;
+
+ return CSR_RESULT_SUCCESS;
+} /* update_to_host_signals_r() */
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * read_unpack_cmd
+ *
+ * Converts a wire-formatted command to the host bulk_data_cmd_t structure.
+ *
+ * Arguments:
+ * ptr Pointer to the command
+ * bulk_data_cmd Pointer to the host structure
+ *
+ * Returns:
+ * None.
+ * ---------------------------------------------------------------------------
+ */
+static void read_unpack_cmd(const u8 *ptr, bulk_data_cmd_t *bulk_data_cmd)
+{
+ s16 index = 0;
+ bulk_data_cmd->cmd_and_len = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ bulk_data_cmd->data_slot = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ bulk_data_cmd->offset = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ bulk_data_cmd->buffer_handle = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+} /* read_unpack_cmd */
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * process_to_host_signals
+ *
+ * Read and dispatch signals from the UniFi
+ *
+ * Arguments:
+ * card Pointer to card context struct
+ * processed Pointer to location to write processing result:
+ * 0 if there were no signals pending,
+ * 1 if we read at least one signal
+ *
+ * Returns:
+ * CSR error code if there was an error
+ *
+ * Notes:
+ * Since bulk data transfers can take a long time, if we wait until
+ * all are done before we acknowledge the signals, the UniFi runs out
+ * of buffer space. Therefore we keep a count of the bytes transferred
+ * in bulk data commands, and update the to-host-signals-read count
+ * if we've done a large transfer.
+ *
+ * All data in the f/w is stored in a little endian format, without any
+ * padding bytes. Every read from the memory has to be transformed in
+ * host (cpu specific) format, before we can process it. Therefore we
+ * use read_unpack_cmd() and read_unpack_signal() to convert the raw data
+ * contained in the card->th_buffer.buf to host structures.
+ * Important: UDI clients use wire-formatted structures, so we need to
+ * indicate all data, as we have read it from the device.
+ * ---------------------------------------------------------------------------
+ */
+static CsrResult process_to_host_signals(card_t *card, s32 *processed)
+{
+ s16 pending;
+ s16 remaining;
+ u8 *bufptr;
+ bulk_data_param_t data_ptrs;
+ s16 cmd;
+ u16 sig_len;
+ s16 i;
+ u16 chunks_in_buf;
+ u16 bytes_transferred = 0;
+ CsrResult r = CSR_RESULT_SUCCESS;
+
+ *processed = 0;
+
+ pending = card->th_buffer.count;
+
+ /* Are there new to-host signals? */
+ unifi_trace(card->ospriv, UDBG4, "handling %d to-host chunks\n", pending);
+
+ if (!pending)
+ {
+ return CSR_RESULT_SUCCESS;
+ }
+
+ /*
+ * This is a pointer to the raw data we have read from the f/w.
+ * Can be a signal or a command. Note that we need to convert
+ * it to a host structure before we process it.
+ */
+ bufptr = card->th_buffer.buf;
+
+ while (pending > 0)
+ {
+ s16 f_flush_count = 0;
+
+ /*
+ * Command and length are common to signal and bulk data msgs.
+ * If command == 0 (i.e. a signal), len is number of bytes
+ * *following* the 2-byte header.
+ */
+ cmd = bufptr[1] >> 4;
+ sig_len = bufptr[0] + ((bufptr[1] & 0x0F) << 8);
+
+#ifdef CSR_WIFI_HIP_NOISY
+ unifi_error(card->ospriv, "Received UniFi msg cmd=%d, len=%d\n",
+ cmd, sig_len);
+#endif /* CSR_WIFI_HIP_NOISY */
+
+ if ((sig_len == 0) &&
+ ((cmd != SDIO_CMD_CLEAR_SLOT) && (cmd != SDIO_CMD_PADDING)))
+ {
+ unifi_error(card->ospriv, "incomplete signal or command: has size zero\n");
+ return CSR_RESULT_FAILURE;
+ }
+ /*
+ * Make sure the buffer contains a complete message.
+ * Signals may occupy multiple chunks, bulk-data commands occupy
+ * one chunk.
+ */
+ if (cmd == SDIO_CMD_SIGNAL)
+ {
+ chunks_in_buf = GET_CHUNKS_FOR(card->config_data.sig_frag_size, (u16)(sig_len + 2));
+ }
+ else
+ {
+ chunks_in_buf = 1;
+ }
+
+ if (chunks_in_buf > (u16)pending)
+ {
+ unifi_error(card->ospriv, "incomplete signal (0x%x?): need %d chunks, got %d\n",
+ GET_SIGNAL_ID(bufptr + 2),
+ chunks_in_buf, pending);
+ unifi_error(card->ospriv, " thsw=%d, thsr=%d\n",
+ card->to_host_signals_w,
+ card->to_host_signals_r);
+ return CSR_RESULT_FAILURE;
+ }
+
+
+ switch (cmd)
+ {
+ case SDIO_CMD_SIGNAL:
+ /* This is a signal. Read the rest of it and then handle it. */
+#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_DATA_PLANE_PROFILE)
+ card->cmd_prof.sdio_cmd_signal++;
+#endif
+
+ for (i = 0; i < UNIFI_MAX_DATA_REFERENCES; i++)
+ {
+ /* Retrieve dataRefs[i].DataLength */
+ u16 data_len = GET_PACKED_DATAREF_LEN(bufptr + 2, i);
+
+ /*
+ * The bulk data length in the signal can not be greater than
+ * the maximun length allowed by the SDIO config structure.
+ */
+ if (data_len > card->config_data.data_slot_size)
+ {
+ unifi_error(card->ospriv,
+ "Bulk Data length (%d) exceeds Maximum Bulk Data length (%d)\n",
+ data_len, card->config_data.data_slot_size);
+ return CSR_RESULT_FAILURE;
+ }
+
+ /*
+ * Len here might not be the same as the length in the
+ * bulk data slot. The slot length will always be even,
+ * but len could be odd.
+ */
+ if (data_len != 0)
+ {
+ /* Retrieve dataRefs[i].SlotNumber */
+ s16 slot = GET_PACKED_DATAREF_SLOT(bufptr + 2, i);
+
+ if (slot >= card->config_data.num_tohost_data_slots)
+ {
+ unifi_error(card->ospriv, "!!!bad slot number in to-host signal: %d, sig 0x%X\n",
+ slot, cmd);
+ return CSR_RESULT_FAILURE;
+ }
+
+ data_ptrs.d[i].os_data_ptr = card->to_host_data[slot].os_data_ptr;
+ data_ptrs.d[i].os_net_buf_ptr = card->to_host_data[slot].os_net_buf_ptr;
+ data_ptrs.d[i].net_buf_length = card->to_host_data[slot].net_buf_length;
+ data_ptrs.d[i].data_length = data_len;
+ }
+ else
+ {
+ UNIFI_INIT_BULK_DATA(&data_ptrs.d[i]);
+ }
+ }
+
+ /*
+ * Log the signal to the UDI, before call unifi_receive_event() as
+ * it can modify the bulk data.
+ */
+ if (card->udi_hook)
+ {
+ (*card->udi_hook)(card->ospriv, bufptr + 2, sig_len,
+ &data_ptrs, UDI_LOG_TO_HOST);
+ }
+
+#ifdef CSR_WIFI_HIP_DATA_PLANE_PROFILE
+ if (GET_SIGNAL_ID(bufptr + 2) == CSR_MA_PACKET_CONFIRM_ID)
+ {
+ card->cmd_prof.tx_cfm_count++;
+ }
+ else if (GET_SIGNAL_ID(bufptr + 2) == CSR_MA_PACKET_INDICATION_ID)
+ {
+ if (data_ptrs.d[0].os_data_ptr)
+ {
+ if ((*data_ptrs.d[0].os_data_ptr) & 0x08)
+ {
+ card->cmd_prof.rx_count++;
+ }
+ }
+ }
+#endif
+ /*
+ * Check if the signal is MA-PACKET.cfm and if so check the status.
+ * If the status is failure, search through the slot records to find
+ * if any slots are occupied for this host tag. This can happen if
+ * f/w has not downloaded the bulkdata and before that itself it has
+ * signalled the confirm with failure. If it finds a slot with that
+ * host tag then, it clears the corresponding slot
+ */
+
+ if (GET_SIGNAL_ID(bufptr + 2) == CSR_MA_PACKET_CONFIRM_ID)
+ {
+ /* Get host tag and transmission status */
+ u32 host_tag = GET_PACKED_MA_PACKET_CONFIRM_HOST_TAG(bufptr + 2);
+ u16 status = GET_PACKED_MA_PACKET_CONFIRM_TRANSMISSION_STATUS(bufptr + 2);
+
+ unifi_trace(card->ospriv, UDBG4, "process_to_host_signals signal ID=%x host Tag=%x status=%x\n",
+ GET_SIGNAL_ID(bufptr + 2), host_tag, status);
+
+ /* If transmission status is failure then search through the slot records
+ * and if for any slot records the clear slot is not done then do it now
+ */
+
+ if (status && (card->fh_slot_host_tag_record))
+ {
+ u16 num_fh_slots = card->config_data.num_fromhost_data_slots;
+
+ /* search through the list of slot records and match with host tag
+ * If a slot is not yet cleared then clear the slot from here
+ */
+ for (i = 0; i < num_fh_slots; i++)
+ {
+ if (card->fh_slot_host_tag_record[i] == host_tag)
+ {
+#ifdef CSR_WIFI_REQUEUE_PACKET_TO_HAL
+ /* Invoke the HAL module function to requeue it back to HAL Queues */
+ r = unifi_reque_ma_packet_request(card->ospriv, host_tag, status, &card->from_host_data[i].bd);
+ card->fh_slot_host_tag_record[i] = CSR_WIFI_HIP_RESERVED_HOST_TAG;
+ if (CSR_RESULT_SUCCESS != r)
+ {
+ unifi_trace(card->ospriv, UDBG5, "process_to_host_signals: Failed to requeue Packet(hTag:%x) back to HAL \n", host_tag);
+ CardClearFromHostDataSlot(card, i);
+ }
+ else
+ {
+ CardClearFromHostDataSlotWithoutFreeingBulkData(card, i);
+ }
+
+#else
+ unifi_trace(card->ospriv, UDBG4, "process_to_host_signals Clear slot=%x host tag=%x\n", i, host_tag);
+ card->fh_slot_host_tag_record[i] = CSR_WIFI_HIP_RESERVED_HOST_TAG;
+
+ /* Set length field in from_host_data array to 0 */
+ CardClearFromHostDataSlot(card, i);
+#endif
+ break;
+ }
+ }
+ }
+ }
+
+ /* Pass event to OS layer */
+ unifi_receive_event(card->ospriv, bufptr + 2, sig_len, &data_ptrs);
+
+ /* Initialise the to_host data, so it can be re-used. */
+ for (i = 0; i < UNIFI_MAX_DATA_REFERENCES; i++)
+ {
+ /* The slot is only valid if the length is non-zero. */
+ if (GET_PACKED_DATAREF_LEN(bufptr + 2, i) != 0)
+ {
+ s16 slot = GET_PACKED_DATAREF_SLOT(bufptr + 2, i);
+ if (slot < card->config_data.num_tohost_data_slots)
+ {
+ UNIFI_INIT_BULK_DATA(&card->to_host_data[slot]);
+ }
+ }
+ }
+
+#ifndef CSR_WIFI_DEFER_TH_FLUSH
+ /*
+ * If we have previously transferred a lot of data, ack
+ * the signals read so far, so f/w can reclaim the buffer
+ * memory sooner.
+ */
+ if (bytes_transferred >= TO_HOST_FLUSH_THRESHOLD)
+ {
+ f_flush_count = 1;
+ }
+#endif
+ break;
+
+
+ case SDIO_CMD_CLEAR_SLOT:
+#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_DATA_PLANE_PROFILE)
+ card->cmd_prof.sdio_cmd_clear_slot++;
+#endif
+ /* This is a clear slot command. */
+ if (sig_len != 0)
+ {
+ unifi_error(card->ospriv, "process_to_host_signals: clear slot, bad data len: 0x%X at offset %d\n",
+ sig_len, bufptr - card->th_buffer.buf);
+ return CSR_RESULT_FAILURE;
+ }
+
+ r = process_clear_slot_command(card, bufptr);
+ if (r != CSR_RESULT_SUCCESS)
+ {
+ unifi_error(card->ospriv, "Failed to process clear slot\n");
+ return r;
+ }
+ break;
+
+ case SDIO_CMD_TO_HOST_TRANSFER:
+ case SDIO_CMD_FROM_HOST_TRANSFER:
+ case SDIO_CMD_FROM_HOST_AND_CLEAR:
+ case SDIO_CMD_OVERLAY_TRANSFER:
+ /* This is a bulk data command. */
+ if (sig_len & 1)
+ {
+ unifi_error(card->ospriv, "process_to_host_signals: bulk data, bad data len: 0x%X at offset %d\n",
+ sig_len, bufptr - card->th_buffer.buf);
+ return CSR_RESULT_FAILURE;
+ }
+
+ r = process_bulk_data_command(card, bufptr, cmd, sig_len);
+ if (r != CSR_RESULT_SUCCESS)
+ {
+ unifi_error(card->ospriv, "Failed to process bulk cmd\n");
+ return r;
+ }
+ /* Count the bytes transferred */
+ bytes_transferred += sig_len;
+
+ if (cmd == SDIO_CMD_FROM_HOST_AND_CLEAR)
+ {
+#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_DATA_PLANE_PROFILE)
+ card->cmd_prof.sdio_cmd_from_host_and_clear++;
+#endif
+#ifndef CSR_WIFI_DEFER_TH_FLUSH
+ f_flush_count = 1;
+#endif
+ }
+#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_DATA_PLANE_PROFILE)
+ else if (cmd == SDIO_CMD_FROM_HOST_TRANSFER)
+ {
+ card->cmd_prof.sdio_cmd_from_host++;
+ }
+ else if (cmd == SDIO_CMD_TO_HOST_TRANSFER)
+ {
+ card->cmd_prof.sdio_cmd_to_host++;
+ }
+#endif
+ break;
+
+ case SDIO_CMD_PADDING:
+ break;
+
+ default:
+ unifi_error(card->ospriv, "Unrecognised to-host command: %d\n", cmd);
+ break;
+ }
+
+ bufptr += chunks_in_buf * card->config_data.sig_frag_size;
+ pending -= chunks_in_buf;
+
+ /*
+ * Write out the host signal count when a significant
+ * number of bytes of bulk data have been transferred or
+ * when we have performed a CopyFromHostAndClear.
+ */
+ if (f_flush_count)
+ {
+ r = update_to_host_signals_r(card, pending);
+ if (r != CSR_RESULT_SUCCESS)
+ {
+ return r;
+ }
+ bytes_transferred = 0;
+ }
+ }
+
+ if (pending)
+ {
+ unifi_warning(card->ospriv, "proc_th_sigs: %d unprocessed\n", pending);
+ }
+
+ /* If we processed any signals, write the updated count to UniFi */
+ if (card->th_buffer.count != pending)
+ {
+ r = update_to_host_signals_r(card, pending);
+ if (r != CSR_RESULT_SUCCESS)
+ {
+ return r;
+ }
+ }
+
+ /*
+ * Reset the buffer pointer, copying down any un-processed signals.
+ * This can happen if we enable the optimisation in read_to_host_signals()
+ * that limits the length to whole blocks.
+ */
+ remaining = card->th_buffer.ptr - bufptr;
+ if (remaining < 0)
+ {
+ unifi_error(card->ospriv, "Processing TH signals overran the buffer\n");
+ return CSR_RESULT_FAILURE;
+ }
+ if (remaining > 0)
+ {
+ /* Use a safe copy because source and destination may overlap */
+ u8 *d = card->th_buffer.buf;
+ u8 *s = bufptr;
+ s32 n = remaining;
+ while (n--)
+ {
+ *d++ = *s++;
+ }
+ }
+ card->th_buffer.ptr = card->th_buffer.buf + remaining;
+
+
+ /* If we reach here then we processed something */
+ *processed = 1;
+ return CSR_RESULT_SUCCESS;
+} /* process_to_host_signals() */
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * process_clear_slot_command
+ *
+ * Process a clear slot command fom the UniFi.
+ *
+ * Arguments:
+ * card Pointer to card context struct
+ * bdcmd Pointer to bulk-data command msg from UniFi
+ *
+ * Returns:
+ * 0 on success, CSR error code on error
+ * ---------------------------------------------------------------------------
+ */
+static CsrResult process_clear_slot_command(card_t *card, const u8 *cmdptr)
+{
+ u16 data_slot;
+ s16 slot;
+
+ data_slot = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(cmdptr + SIZEOF_UINT16);
+
+ unifi_trace(card->ospriv, UDBG4, "Processing clear slot cmd, slot=0x%X\n",
+ data_slot);
+
+ slot = data_slot & 0x7FFF;
+
+#ifdef CSR_WIFI_HIP_NOISY
+ unifi_error(card->ospriv, "CMD clear data slot 0x%04x\n", data_slot);
+#endif /* CSR_WIFI_HIP_NOISY */
+
+ if (data_slot & SLOT_DIR_TO_HOST)
+ {
+ if (slot >= card->config_data.num_tohost_data_slots)
+ {
+ unifi_error(card->ospriv,
+ "Invalid to-host data slot in SDIO_CMD_CLEAR_SLOT: %d\n",
+ slot);
+ return CSR_RESULT_FAILURE;
+ }
+ /* clear to-host data slot */
+ unifi_warning(card->ospriv, "Unexpected clear to-host data slot cmd: 0x%04x\n",
+ data_slot);
+ }
+ else
+ {
+ if (slot >= card->config_data.num_fromhost_data_slots)
+ {
+ unifi_error(card->ospriv,
+ "Invalid from-host data slot in SDIO_CMD_CLEAR_SLOT: %d\n",
+ slot);
+ return CSR_RESULT_FAILURE;
+ }
+
+ /*
+ * The driver is the owner to clear all slots now
+ * Ref - comment in process_fh_traffic_queue
+ * so it will just ignore the clear slot command from firmware
+ * and return success
+ */
+ return CSR_RESULT_SUCCESS;
+
+ /* Set length field in from_host_data array to 0 */
+ /* CardClearFromHostDataSlot(card, slot); */
+ }
+
+ return CSR_RESULT_SUCCESS;
+} /* process_clear_slot_command() */
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * process_bulk_data_command
+ *
+ * Process a bulk data request from the UniFi.
+ *
+ * Arguments:
+ * card Pointer to card context struct
+ * bdcmd Pointer to bulk-data command msg from UniFi
+ * cmd, len Decoded values of command and length from the msg header
+ * Cmd will only be one of:
+ * SDIO_CMD_TO_HOST_TRANSFER
+ * SDIO_CMD_FROM_HOST_TRANSFER
+ * SDIO_CMD_FROM_HOST_AND_CLEAR
+ * SDIO_CMD_OVERLAY_TRANSFER
+ *
+ * Returns:
+ * CSR_RESULT_SUCCESS on success, CSR error code on error
+ * ---------------------------------------------------------------------------
+ */
+static CsrResult process_bulk_data_command(card_t *card, const u8 *cmdptr,
+ s16 cmd, u16 len)
+{
+ bulk_data_desc_t *bdslot;
+#ifdef CSR_WIFI_ALIGNMENT_WORKAROUND
+ u8 *host_bulk_data_slot;
+#endif
+ bulk_data_cmd_t bdcmd;
+ s16 offset;
+ s16 slot;
+ s16 dir;
+ CsrResult r;
+
+ read_unpack_cmd(cmdptr, &bdcmd);
+
+ unifi_trace(card->ospriv, UDBG4, "Processing bulk data cmd %d %s, len=%d, slot=0x%X\n",
+ cmd, lookup_bulkcmd_name(cmd), len, bdcmd.data_slot);
+
+ /*
+ * Round up the transfer length if required.
+ * This is useful to force all transfers to be a multiple of the SDIO block
+ * size, so the SDIO driver won't try to use a byte-mode CMD53. These are
+ * broken on some hardware platforms.
+ */
+ if (card->sdio_io_block_pad)
+ {
+ len = (len + card->sdio_io_block_size - 1) & ~(card->sdio_io_block_size - 1);
+ unifi_trace(card->ospriv, UDBG4, "Rounded bulk data length up to %d\n", len);
+ }
+
+ slot = bdcmd.data_slot & 0x7FFF;
+
+ if (cmd == SDIO_CMD_OVERLAY_TRANSFER)
+ {
+ return CSR_WIFI_HIP_RESULT_INVALID_VALUE; /* Not used on CSR6xxx */
+ }
+ else
+ {
+ if (bdcmd.data_slot & SLOT_DIR_TO_HOST)
+ {
+ /* Request is for to-host bulk data */
+
+ /* Check sanity of slot number */
+ if (slot >= card->config_data.num_tohost_data_slots)
+ {
+ unifi_error(card->ospriv,
+ "Invalid to-host data slot in SDIO bulk xfr req: %d\n",
+ slot);
+ return CSR_RESULT_FAILURE;
+ }
+
+ /* Allocate memory for card->to_host_data[slot] bulk data here. */
+#ifdef CSR_PRE_ALLOC_NET_DATA
+ r = prealloc_netdata_get(card, &card->to_host_data[slot], len);
+#else
+ r = unifi_net_data_malloc(card->ospriv, &card->to_host_data[slot], len);
+#endif
+ if (r != CSR_RESULT_SUCCESS)
+ {
+ unifi_error(card->ospriv, "Failed to allocate t-h bulk data\n");
+ return CSR_RESULT_FAILURE;
+ }
+
+ bdslot = &card->to_host_data[slot];
+
+ /* Make sure that the buffer is 4-bytes aligned */
+ r = unifi_net_dma_align(card->ospriv, bdslot);
+ if (r != CSR_RESULT_SUCCESS)
+ {
+ unifi_error(card->ospriv, "Failed to align t-h bulk data buffer for DMA\n");
+ return CSR_RESULT_FAILURE;
+ }
+ }
+ else
+ {
+ /* Request is for from-host bulk data */
+
+ if (slot >= card->config_data.num_fromhost_data_slots)
+ {
+ unifi_error(card->ospriv,
+ "Invalid from-host data slot in SDIO bulk xfr req: %d\n",
+ slot);
+ return CSR_RESULT_FAILURE;
+ }
+ bdslot = &card->from_host_data[slot].bd;
+ }
+ offset = bdcmd.offset;
+ }
+ /* Do the transfer */
+ dir = (cmd == SDIO_CMD_TO_HOST_TRANSFER)?
+ UNIFI_SDIO_READ : UNIFI_SDIO_WRITE;
+
+ unifi_trace(card->ospriv, UDBG4,
+ "Bulk %c %s len=%d, handle %d - slot=%d %p+(%d)\n",
+ (dir == UNIFI_SDIO_READ)?'R' : 'W',
+ lookup_bulkcmd_name(cmd),
+ len,
+ bdcmd.buffer_handle,
+ slot, bdslot->os_data_ptr, offset);
+#ifdef CSR_WIFI_HIP_NOISY
+ unifi_error(card->ospriv, "Bulk %s len=%d, handle %d - slot=%d %p+(%d)\n",
+ lookup_bulkcmd_name(cmd),
+ len,
+ bdcmd.buffer_handle,
+ slot, bdslot->os_data_ptr, offset);
+#endif /* CSR_WIFI_HIP_NOISY */
+
+
+ if (bdslot->os_data_ptr == NULL)
+ {
+ unifi_error(card->ospriv, "Null os_data_ptr - Bulk %s handle %d - slot=%d o=(%d)\n",
+ lookup_bulkcmd_name(cmd),
+ bdcmd.buffer_handle,
+ slot,
+ offset);
+ return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
+ }
+
+#ifdef CSR_WIFI_ALIGNMENT_WORKAROUND
+ /* if os_data_ptr is not 4-byte aligned, then allocate a new buffer and copy data
+ to new buffer to ensure the address passed to unifi_bulk_rw is 4-byte aligned */
+
+ if (len != 0 && (dir == UNIFI_SDIO_WRITE) && (((ptrdiff_t)bdslot->os_data_ptr + offset) & 3))
+ {
+ host_bulk_data_slot = kmalloc(len, GFP_KERNEL);
+
+ if (!host_bulk_data_slot)
+ {
+ unifi_error(card->ospriv, " failed to allocate request_data before unifi_bulk_rw\n");
+ return -1;
+ }
+
+ memcpy((void *)host_bulk_data_slot,
+ (void *)(bdslot->os_data_ptr + offset), len);
+
+ r = unifi_bulk_rw(card,
+ bdcmd.buffer_handle,
+ (void *)host_bulk_data_slot,
+ len,
+ dir);
+ }
+ else
+#endif
+ {
+ r = unifi_bulk_rw(card,
+ bdcmd.buffer_handle,
+ (void *)(bdslot->os_data_ptr + offset),
+ len,
+ dir);
+ }
+
+ if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
+ {
+ return r;
+ }
+ if (r != CSR_RESULT_SUCCESS)
+ {
+ unifi_error(card->ospriv,
+ "Failed: %s hlen=%d, slen=%d, handle %d - slot=%d %p+0x%X\n",
+ lookup_bulkcmd_name(cmd),
+ len, /* Header length */
+ bdslot->data_length, /* Length stored in slot */
+ bdcmd.buffer_handle,
+ slot, bdslot->os_data_ptr, offset);
+ return r;
+ }
+
+ bdslot->data_length = len;
+
+ if (cmd == SDIO_CMD_FROM_HOST_AND_CLEAR)
+ {
+ if (slot >= card->config_data.num_fromhost_data_slots)
+ {
+ unifi_error(card->ospriv,
+ "Invalid from-host data slot in SDIO_CMD_FROM_HOST_AND_CLEAR: %d\n",
+ slot);
+ return CSR_RESULT_FAILURE;
+ }
+
+#ifdef CSR_WIFI_ALIGNMENT_WORKAROUND
+ /* moving this check before we clear host data slot */
+ if ((len != 0) && (dir == UNIFI_SDIO_WRITE) && (((ptrdiff_t)bdslot->os_data_ptr + offset) & 3))
+ {
+ kfree(host_bulk_data_slot);
+ }
+#endif
+
+ if (card->fh_slot_host_tag_record)
+ {
+ unifi_trace(card->ospriv, UDBG5, "CopyFromHostAndClearSlot Reset entry for slot=%d\n", slot);
+
+ /* reset the host tag entry for the corresponding slot */
+ card->fh_slot_host_tag_record[slot] = CSR_WIFI_HIP_RESERVED_HOST_TAG;
+ }
+
+
+ /* Set length field in from_host_data array to 0 */
+ CardClearFromHostDataSlot(card, slot);
+ }
+
+ return CSR_RESULT_SUCCESS;
+} /* process_bulk_data_command() */
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * check_fh_sig_slots
+ *
+ * Check whether there are <n> free signal slots available on UniFi.
+ * This takes into account the signals already batched since the
+ * from_host_signal counts were last read.
+ * If the from_host_signal counts indicate not enough space, we read
+ * the latest count from UniFi to see if some more have been freed.
+ *
+ * Arguments:
+ * None.
+ *
+ * Returns:
+ * CSR_RESULT_SUCCESS, otherwise CSR error code on error.
+ * ---------------------------------------------------------------------------
+ */
+static CsrResult check_fh_sig_slots(card_t *card, u16 needed, s32 *space_fh)
+{
+ u32 count_fhw;
+ u32 occupied_fh, slots_fh;
+ s32 count_fhr;
+
+ count_fhw = card->from_host_signals_w;
+ count_fhr = card->from_host_signals_r;
+ slots_fh = card->config_data.num_fromhost_sig_frags;
+
+ /* Only read the space in from-host queue if necessary */
+ occupied_fh = (count_fhw - count_fhr) % 128;
+
+ if (slots_fh < occupied_fh)
+ {
+ *space_fh = 0;
+ }
+ else
+ {
+ *space_fh = slots_fh - occupied_fh;
+ }
+
+ if ((occupied_fh != 0) && (*space_fh < needed))
+ {
+ count_fhr = unifi_read_shared_count(card, card->sdio_ctrl_addr + 2);
+ if (count_fhr < 0)
+ {
+ unifi_error(card->ospriv, "Failed to read from-host sig read count\n");
+ return CSR_RESULT_FAILURE;
+ }
+ card->from_host_signals_r = count_fhr; /* diag */
+
+ occupied_fh = (count_fhw - count_fhr) % 128;
+ *space_fh = slots_fh - occupied_fh;
+ }
+
+ return CSR_RESULT_SUCCESS;
+} /* check_fh_sig_slots() */
+
+
+/*
+* If we are padding the From-Host signals to the SDIO block size,
+* we need to round up the needed_chunks to the SDIO block size.
+*/
+#define ROUND_UP_NEEDED_CHUNKS(_card, _needed_chunks) \
+ { \
+ u16 _chunks_per_block; \
+ u16 _chunks_in_last_block; \
+ \
+ if (_card->sdio_io_block_pad) \
+ { \
+ _chunks_per_block = _card->sdio_io_block_size / _card->config_data.sig_frag_size; \
+ _chunks_in_last_block = _needed_chunks % _chunks_per_block; \
+ if (_chunks_in_last_block != 0) \
+ { \
+ _needed_chunks = _needed_chunks + (_chunks_per_block - _chunks_in_last_block); \
+ } \
+ } \
+ }
+
+
+#define ROUND_UP_SPACE_CHUNKS(_card, _space_chunks) \
+ { \
+ u16 _chunks_per_block; \
+ \
+ if (_card->sdio_io_block_pad) \
+ { \
+ _chunks_per_block = _card->sdio_io_block_size / _card->config_data.sig_frag_size; \
+ _space_chunks = ((_space_chunks / _chunks_per_block) * _chunks_per_block); \
+ } \
+ }
+
+
+
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * process_fh_cmd_queue
+ *
+ * Take one signal off the from-host queue and copy it to the UniFi.
+ * Does nothing if the UniFi has no slots free.
+ *
+ * Arguments:
+ * card Pointer to card context struct
+ * processed Location to write:
+ * 0 if there is nothing on the queue to process
+ * 1 if a signal was successfully processed
+ *
+ * Returns:
+ * CSR error code if an error occurred.
+ *
+ * Notes:
+ * The from-host queue contains signal requests from the network driver
+ * and any UDI clients interspersed. UDI clients' requests have been stored
+ * in the from-host queue using the wire-format structures, as they arrive.
+ * All other requests are stored in the from-host queue using the host
+ * (cpu specific) structures. We use the is_packed member of the card_signal_t
+ * structure that describes the queue to make the distiction.
+ * ---------------------------------------------------------------------------
+ */
+static CsrResult process_fh_cmd_queue(card_t *card, s32 *processed)
+{
+ q_t *sigq = &card->fh_command_queue;
+
+ CsrResult r;
+ u16 pending_sigs;
+ u16 pending_chunks;
+ u16 needed_chunks;
+ s32 space_chunks;
+ u16 q_index;
+
+ *processed = 0;
+
+ /* Get the number of pending signals. */
+ pending_sigs = CSR_WIFI_HIP_Q_SLOTS_USED(sigq);
+ unifi_trace(card->ospriv, UDBG5, "proc_fh: %d pending\n", pending_sigs);
+ if (pending_sigs == 0)
+ {
+ /* Nothing to do */
+ return CSR_RESULT_SUCCESS;
+ }
+
+ /* Work out how many chunks we have waiting to send */
+ for (pending_chunks = 0, q_index = CSR_WIFI_HIP_Q_NEXT_R_SLOT(sigq);
+ q_index != CSR_WIFI_HIP_Q_NEXT_W_SLOT(sigq);
+ q_index = CSR_WIFI_HIP_Q_WRAP(sigq, q_index + 1))
+ {
+ card_signal_t *csptr = CSR_WIFI_HIP_Q_SLOT_DATA(sigq, q_index);
+
+ /*
+ * Note that GET_CHUNKS_FOR() needs the size of the packed
+ * (wire-formatted) structure
+ */
+ pending_chunks += GET_CHUNKS_FOR(card->config_data.sig_frag_size, (u16)(csptr->signal_length + 2));
+ }
+
+ /*
+ * Check whether UniFi has space for all the buffered bulk-data
+ * commands and signals as well.
+ */
+ needed_chunks = pending_chunks + card->fh_buffer.count;
+
+ /* Round up to the block size if necessary */
+ ROUND_UP_NEEDED_CHUNKS(card, needed_chunks);
+
+ r = check_fh_sig_slots(card, needed_chunks, &space_chunks);
+ if (r != CSR_RESULT_SUCCESS)
+ {
+ /* Error */
+ unifi_error(card->ospriv, "Failed to read fh sig count\n");
+ return r;
+ }
+
+#ifdef CSR_WIFI_HIP_NOISY
+ unifi_error(card->ospriv, "proc_fh: %d chunks free, need %d\n",
+ space_chunks, needed_chunks);
+#endif /* CSR_WIFI_HIP_NOISY */
+
+
+ /*
+ * Coalesce as many from-host signals as possible
+ * into a single block and write using a single CMD53
+ */
+ if (needed_chunks > (u16)space_chunks)
+ {
+ /* Round up to the block size if necessary */
+ ROUND_UP_SPACE_CHUNKS(card, space_chunks);
+
+ /*
+ * If the f/w has less free chunks than those already pending
+ * return immediately.
+ */
+ if ((u16)space_chunks <= card->fh_buffer.count)
+ {
+ /*
+ * No room in UniFi for any signals after the buffered bulk
+ * data commands have been sent.
+ */
+ unifi_error(card->ospriv, "not enough room to send signals, need %d chunks, %d free\n",
+ card->fh_buffer.count, space_chunks);
+ card->generate_interrupt = 1;
+ return CSR_RESULT_SUCCESS;
+ }
+ pending_chunks = (u16)(space_chunks - card->fh_buffer.count);
+ }
+
+ while (pending_sigs-- && pending_chunks > 0)
+ {
+ card_signal_t *csptr;
+ s16 i;
+ u16 sig_chunks, total_length, free_chunks_in_fh_buffer;
+ bulk_data_param_t bulkdata;
+ u8 *packed_sigptr;
+ u16 signal_length = 0;
+
+ /* Retrieve the entry at the head of the queue */
+ q_index = CSR_WIFI_HIP_Q_NEXT_R_SLOT(sigq);
+
+ /* Get a pointer to the containing card_signal_t struct */
+ csptr = CSR_WIFI_HIP_Q_SLOT_DATA(sigq, q_index);
+
+ /* Get the new length of the packed signal */
+ signal_length = csptr->signal_length;
+
+ if ((signal_length & 1) || (signal_length > UNIFI_PACKED_SIGBUF_SIZE))
+ {
+ unifi_error(card->ospriv, "process_fh_queue: Bad len: %d\n", signal_length);
+ return CSR_RESULT_FAILURE;
+ }
+
+ /* Need space for 2-byte SDIO protocol header + signal */
+ sig_chunks = GET_CHUNKS_FOR(card->config_data.sig_frag_size, (u16)(signal_length + 2));
+
+ free_chunks_in_fh_buffer = GET_CHUNKS_FOR(card->config_data.sig_frag_size,
+ (u16)((card->fh_buffer.buf + UNIFI_FH_BUF_SIZE) - card->fh_buffer.ptr));
+ if (free_chunks_in_fh_buffer < sig_chunks)
+ {
+ /* No more room */
+ unifi_notice(card->ospriv, "proc_fh_cmd_q: no room in fh buffer for 0x%.4X, deferring\n",
+ (u16)(GET_SIGNAL_ID(csptr->sigbuf)));
+ break;
+ }
+
+ packed_sigptr = csptr->sigbuf;
+
+ /* Claim and set up a from-host data slot */
+ if (CSR_RESULT_FAILURE == CardWriteBulkData(card, csptr, UNIFI_TRAFFIC_Q_MLME))
+ {
+ unifi_notice(card->ospriv, "proc_fh_cmd_q: no fh data slots for 0x%.4X, deferring\n",
+ (u16)(GET_SIGNAL_ID(csptr->sigbuf)));
+ break;
+ }
+
+ for (i = 0; i < UNIFI_MAX_DATA_REFERENCES; i++)
+ {
+ if (csptr->bulkdata[i].data_length == 0)
+ {
+ UNIFI_INIT_BULK_DATA(&bulkdata.d[i]);
+ }
+ else
+ {
+ bulkdata.d[i].os_data_ptr = csptr->bulkdata[i].os_data_ptr;
+ bulkdata.d[i].data_length = csptr->bulkdata[i].data_length;
+ }
+
+ /* Pass the free responsibility to the lower layer. */
+ UNIFI_INIT_BULK_DATA(&csptr->bulkdata[i]);
+ }
+
+ unifi_trace(card->ospriv, UDBG2, "Sending signal 0x%.4X\n",
+ GET_SIGNAL_ID(packed_sigptr));
+#ifdef CSR_WIFI_HIP_NOISY
+ unifi_error(card->ospriv, "Sending signal 0x%.4X\n",
+ GET_SIGNAL_ID(packed_sigptr));
+#endif /* CSR_WIFI_HIP_NOISY */
+
+
+ /* Append packed signal to F-H buffer */
+ total_length = sig_chunks * card->config_data.sig_frag_size;
+
+ card->fh_buffer.ptr[0] = (u8)(signal_length & 0xff);
+ card->fh_buffer.ptr[1] =
+ (u8)(((signal_length >> 8) & 0xf) | (SDIO_CMD_SIGNAL << 4));
+
+ memcpy(card->fh_buffer.ptr + 2, packed_sigptr, signal_length);
+ memset(card->fh_buffer.ptr + 2 + signal_length, 0,
+ total_length - (2 + signal_length));
+
+#ifdef CSR_WIFI_HIP_NOISY
+ unifi_error(card->ospriv, "proc_fh: fh_buffer %d bytes \n",
+ signal_length + 2);
+ dump(card->fh_buffer.ptr, signal_length + 2);
+ unifi_trace(card->ospriv, UDBG1, " \n");
+#endif /* CSR_WIFI_HIP_NOISY */
+
+ card->fh_buffer.ptr += total_length;
+ card->fh_buffer.count += sig_chunks;
+
+#ifdef CSR_WIFI_HIP_NOISY
+ unifi_error(card->ospriv, "Added %d to fh buf, len now %d, count %d\n",
+ signal_length,
+ card->fh_buffer.ptr - card->fh_buffer.buf,
+ card->fh_buffer.count);
+#endif /* CSR_WIFI_HIP_NOISY */
+
+ (*processed)++;
+ pending_chunks -= sig_chunks;
+
+ /* Log the signal to the UDI. */
+ /* UDI will get the packed structure */
+ /* Can not log the unpacked signal, unless we reconstruct it! */
+ if (card->udi_hook)
+ {
+ (*card->udi_hook)(card->ospriv, packed_sigptr, signal_length,
+ &bulkdata, UDI_LOG_FROM_HOST);
+ }
+
+ /* Remove entry from q */
+ csptr->signal_length = 0;
+ CSR_WIFI_HIP_Q_INC_R(sigq);
+ }
+
+ return CSR_RESULT_SUCCESS;
+} /* process_fh_cmd_queue() */
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * process_fh_traffic_queue
+ *
+ * Take signals off the from-host queue and copy them to the UniFi.
+ * Does nothing if the UniFi has no slots free.
+ *
+ * Arguments:
+ * card Pointer to card context struct
+ * sigq Pointer to the traffic queue
+ * processed Pointer to location to write:
+ * 0 if there is nothing on the queue to process
+ * 1 if a signal was successfully processed
+ *
+ * Returns:
+ * CSR error code if an error occurred.
+ *
+ * Notes:
+ * The from-host queue contains signal requests from the network driver
+ * and any UDI clients interspersed.
+ * ---------------------------------------------------------------------------
+ */
+static CsrResult process_fh_traffic_queue(card_t *card, s32 *processed)
+{
+ q_t *sigq = card->fh_traffic_queue;
+
+ CsrResult r;
+ s16 n = 0;
+ s32 q_no;
+ u16 pending_sigs = 0;
+ u16 pending_chunks = 0;
+ u16 needed_chunks;
+ s32 space_chunks;
+ u16 q_index;
+ u32 host_tag = 0;
+ u16 slot_num = 0;
+
+ *processed = 0;
+
+ /* calculate how many signals are in queues and how many chunks are needed. */
+ for (n = UNIFI_NO_OF_TX_QS - 1; n >= 0; n--)
+ {
+ /* Get the number of pending signals. */
+ pending_sigs += CSR_WIFI_HIP_Q_SLOTS_USED(&sigq[n]);
+ unifi_trace(card->ospriv, UDBG5, "proc_fh%d: %d pending\n", n, pending_sigs);
+
+ /* Work out how many chunks we have waiting to send */
+ for (q_index = CSR_WIFI_HIP_Q_NEXT_R_SLOT(&sigq[n]);
+ q_index != CSR_WIFI_HIP_Q_NEXT_W_SLOT(&sigq[n]);
+ q_index = CSR_WIFI_HIP_Q_WRAP(&sigq[n], q_index + 1))
+ {
+ card_signal_t *csptr = CSR_WIFI_HIP_Q_SLOT_DATA(&sigq[n], q_index);
+
+ /*
+ * Note that GET_CHUNKS_FOR() needs the size of the packed
+ * (wire-formatted) structure
+ */
+ pending_chunks += GET_CHUNKS_FOR(card->config_data.sig_frag_size, (u16)(csptr->signal_length + 2));
+ }
+ }
+
+ /* If there are no pending signals, just return */
+ if (pending_sigs == 0)
+ {
+ /* Nothing to do */
+ return CSR_RESULT_SUCCESS;
+ }
+
+ /*
+ * Check whether UniFi has space for all the buffered bulk-data
+ * commands and signals as well.
+ */
+ needed_chunks = pending_chunks + card->fh_buffer.count;
+
+ /* Round up to the block size if necessary */
+ ROUND_UP_NEEDED_CHUNKS(card, needed_chunks);
+
+ r = check_fh_sig_slots(card, needed_chunks, &space_chunks);
+ if (r != CSR_RESULT_SUCCESS)
+ {
+ /* Error */
+ unifi_error(card->ospriv, "Failed to read fh sig count\n");
+ return r;
+ }
+
+#ifdef CSR_WIFI_HIP_NOISY
+ unifi_error(card->ospriv,
+ "process_fh_traffic_queue: %d chunks free, need %d\n",
+ space_chunks, needed_chunks);
+ read_fhsr(card); /* debugging only */
+#endif /* CSR_WIFI_HIP_NOISY */
+
+ /* Coalesce as many from-host signals as possible
+ into a single block and write using a single CMD53 */
+ if (needed_chunks > (u16)space_chunks)
+ {
+ /* Round up to the block size if necessary */
+ ROUND_UP_SPACE_CHUNKS(card, space_chunks);
+
+ if ((u16)space_chunks <= card->fh_buffer.count)
+ {
+ /*
+ * No room in UniFi for any signals after the buffered bulk
+ * data commands have been sent.
+ */
+ unifi_error(card->ospriv, "not enough room to send signals, need %d chunks, %d free\n",
+ card->fh_buffer.count, space_chunks);
+ card->generate_interrupt = 1;
+ return 0;
+ }
+
+ pending_chunks = (u16)space_chunks - card->fh_buffer.count;
+ }
+
+ q_no = UNIFI_NO_OF_TX_QS - 1;
+
+ /*
+ * pending_sigs will be exhausted if there are is no restriction to the pending
+ * signals per queue. pending_chunks may be exhausted if there is a restriction.
+ * q_no check will be exhausted if there is a restriction and our round-robin
+ * algorith fails to fill all chunks.
+ */
+ do
+ {
+ card_signal_t *csptr;
+ u16 sig_chunks, total_length, free_chunks_in_fh_buffer;
+ bulk_data_param_t bulkdata;
+ u8 *packed_sigptr;
+ u16 signal_length = 0;
+
+ /* if this queue is empty go to next one. */
+ if (CSR_WIFI_HIP_Q_SLOTS_USED(&sigq[q_no]) == 0)
+ {
+ q_no--;
+ continue;
+ }
+
+ /* Retrieve the entry at the head of the queue */
+ q_index = CSR_WIFI_HIP_Q_NEXT_R_SLOT(&sigq[q_no]);
+
+ /* Get a pointer to the containing card_signal_t struct */
+ csptr = CSR_WIFI_HIP_Q_SLOT_DATA(&sigq[q_no], q_index);
+
+ /* Get the new length of the packed signal */
+ signal_length = csptr->signal_length;
+
+ if ((signal_length & 1) || (signal_length > UNIFI_PACKED_SIGBUF_SIZE))
+ {
+ unifi_error(card->ospriv, "process_fh_traffic_queue: Bad len: %d\n", signal_length);
+ return CSR_RESULT_FAILURE;
+ }
+
+ /* Need space for 2-byte SDIO protocol header + signal */
+ sig_chunks = GET_CHUNKS_FOR(card->config_data.sig_frag_size, (u16)(signal_length + 2));
+ free_chunks_in_fh_buffer = GET_CHUNKS_FOR(card->config_data.sig_frag_size,
+ (u16)((card->fh_buffer.buf + UNIFI_FH_BUF_SIZE) - card->fh_buffer.ptr));
+ if (free_chunks_in_fh_buffer < sig_chunks)
+ {
+ /* No more room */
+ unifi_notice(card->ospriv, "process_fh_traffic_queue: no more chunks.\n");
+ break;
+ }
+
+ packed_sigptr = csptr->sigbuf;
+ /* Claim and set up a from-host data slot */
+ if (CSR_RESULT_FAILURE == CardWriteBulkData(card, csptr, (unifi_TrafficQueue)q_no))
+ {
+ q_no--;
+ continue;
+ }
+
+ /* Sanity check: MA-PACKET.req must have a valid bulk data */
+ if ((csptr->bulkdata[0].data_length == 0) || (csptr->bulkdata[0].os_data_ptr == NULL))
+ {
+ unifi_error(card->ospriv, "MA-PACKET.req with empty bulk data (%d bytes in %p)\n",
+ csptr->bulkdata[0].data_length, csptr->bulkdata[0].os_data_ptr);
+ dump(packed_sigptr, signal_length);
+ return CSR_RESULT_FAILURE;
+ }
+
+ bulkdata.d[0].os_data_ptr = csptr->bulkdata[0].os_data_ptr;
+ bulkdata.d[0].data_length = csptr->bulkdata[0].data_length;
+ bulkdata.d[0].os_net_buf_ptr = csptr->bulkdata[0].os_net_buf_ptr;
+ bulkdata.d[0].net_buf_length = csptr->bulkdata[0].net_buf_length;
+
+ /* The driver owns clearing of HIP slots for following scenario
+ * - driver has requested a MA-PACKET.req signal
+ * - The f/w after receiving the signal decides it can't send it out due to various reasons
+ * - So the f/w without downloading the bulk data decides to just send a confirmation with fail
+ * - and then sends a clear slot signal to HIP
+ *
+ * But in some cases the clear slot signal never comes and the slot remains --NOT-- freed for ever
+ *
+ * To handle this, HIP will keep the record of host tag for each occupied slot
+ * and then based on status of that Host tag and slot the driver will decide if the slot is
+ * cleared by f/w signal or the slot has to be freed by driver
+ */
+
+ if (card->fh_slot_host_tag_record)
+ {
+ /* Update the f-h slot record for the corresponding host tag */
+ host_tag = GET_PACKED_MA_PACKET_REQUEST_HOST_TAG(packed_sigptr);
+ slot_num = GET_PACKED_DATAREF_SLOT(packed_sigptr, 0) & 0x00FF;
+
+ unifi_trace(card->ospriv, UDBG5,
+ "process_fh_traffic_queue signal ID =%x fh slot=%x Host tag =%x\n",
+ GET_SIGNAL_ID(packed_sigptr), slot_num, host_tag);
+ card->fh_slot_host_tag_record[slot_num] = host_tag;
+ }
+ UNIFI_INIT_BULK_DATA(&bulkdata.d[1]);
+ UNIFI_INIT_BULK_DATA(&csptr->bulkdata[0]);
+ UNIFI_INIT_BULK_DATA(&csptr->bulkdata[1]);
+
+#ifdef CSR_WIFI_HIP_DATA_PLANE_PROFILE
+ if (bulkdata.d[0].os_data_ptr)
+ {
+ if ((*bulkdata.d[0].os_data_ptr) & 0x08)
+ {
+ card->cmd_prof.tx_count++;
+ }
+ }
+#endif
+ unifi_trace(card->ospriv, UDBG3, "Sending signal 0x%.4X\n",
+ GET_SIGNAL_ID(packed_sigptr));
+#ifdef CSR_WIFI_HIP_NOISY
+ unifi_error(card->ospriv, "Sending signal 0x%.4X\n",
+ GET_SIGNAL_ID(packed_sigptr));
+#endif /* CSR_WIFI_HIP_NOISY */
+
+ /* Append packed signal to F-H buffer */
+ total_length = sig_chunks * card->config_data.sig_frag_size;
+
+ card->fh_buffer.ptr[0] = (u8)(signal_length & 0xff);
+ card->fh_buffer.ptr[1] =
+ (u8)(((signal_length >> 8) & 0xf) | (SDIO_CMD_SIGNAL << 4));
+
+ memcpy(card->fh_buffer.ptr + 2, packed_sigptr, signal_length);
+ memset(card->fh_buffer.ptr + 2 + signal_length, 0,
+ total_length - (2 + signal_length));
+
+#ifdef CSR_WIFI_HIP_NOISY
+ unifi_error(card->ospriv, "proc_fh: fh_buffer %d bytes \n",
+ signal_length + 2);
+ dump(card->fh_buffer.ptr, signal_length + 2);
+ unifi_trace(card->ospriv, UDBG1, " \n");
+#endif /* CSR_WIFI_HIP_NOISY */
+
+ card->fh_buffer.ptr += total_length;
+ card->fh_buffer.count += sig_chunks;
+
+#ifdef CSR_WIFI_HIP_NOISY
+ unifi_error(card->ospriv, "Added %d to fh buf, len now %d, count %d\n",
+ signal_length,
+ card->fh_buffer.ptr - card->fh_buffer.buf,
+ card->fh_buffer.count);
+#endif /* CSR_WIFI_HIP_NOISY */
+
+ (*processed)++;
+ pending_sigs--;
+ pending_chunks -= sig_chunks;
+
+ /* Log the signal to the UDI. */
+ /* UDI will get the packed structure */
+ /* Can not log the unpacked signal, unless we reconstruct it! */
+ if (card->udi_hook)
+ {
+ (*card->udi_hook)(card->ospriv, packed_sigptr, signal_length,
+ &bulkdata, UDI_LOG_FROM_HOST);
+ }
+
+ /* Remove entry from q */
+ csptr->signal_length = 0;
+ /* Note that the traffic queue has only one valid bulk data buffer. */
+ csptr->bulkdata[0].data_length = 0;
+
+ CSR_WIFI_HIP_Q_INC_R(&sigq[q_no]);
+ } while ((pending_sigs > 0) && (pending_chunks > 0) && (q_no >= 0));
+
+ return CSR_RESULT_SUCCESS;
+} /* process_fh_traffic_queue() */
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * flush_fh_buffer
+ *
+ * Write out the cache from-hosts signals to the UniFi.
+ *
+ * Arguments:
+ * card Pointer to card context struct
+ *
+ * Returns:
+ * CSR error code if an SDIO error occurred.
+ * ---------------------------------------------------------------------------
+ */
+static CsrResult flush_fh_buffer(card_t *card)
+{
+ CsrResult r;
+ u16 len;
+ u16 sig_units;
+ u16 data_round;
+ u16 chunks_in_last_block;
+ u16 padding_chunks;
+ u16 i;
+
+ len = card->fh_buffer.ptr - card->fh_buffer.buf;
+
+#ifdef CSR_WIFI_HIP_NOISY
+ unifi_error(card->ospriv, "fh_buffer is at %p, ptr= %p\n",
+ card->fh_buffer.buf, card->fh_buffer.ptr);
+#endif /* CSR_WIFI_HIP_NOISY */
+
+ if (len == 0)
+ {
+ return CSR_RESULT_SUCCESS;
+ }
+
+#ifdef CSR_WIFI_HIP_NOISY
+ if (dump_fh_buf)
+ {
+ dump(card->fh_buffer.buf, len);
+ dump_fh_buf = 0;
+ }
+#endif /* CSR_WIFI_HIP_NOISY */
+
+ if (card->sdio_io_block_pad)
+ {
+ /* Both of these are powers of 2 */
+ sig_units = card->config_data.sig_frag_size;
+ data_round = card->sdio_io_block_size;
+
+ if (data_round > sig_units)
+ {
+ chunks_in_last_block = (len % data_round) / sig_units;
+
+ if (chunks_in_last_block != 0)
+ {
+ padding_chunks = (data_round / sig_units) - chunks_in_last_block;
+
+ memset(card->fh_buffer.ptr, 0, padding_chunks * sig_units);
+ for (i = 0; i < padding_chunks; i++)
+ {
+ card->fh_buffer.ptr[1] = SDIO_CMD_PADDING << 4;
+ card->fh_buffer.ptr += sig_units;
+ }
+
+ card->fh_buffer.count += padding_chunks;
+ len += padding_chunks * sig_units;
+ }
+ }
+ }
+
+ r = unifi_bulk_rw(card,
+ card->config_data.fromhost_sigbuf_handle,
+ card->fh_buffer.buf,
+ len, UNIFI_SDIO_WRITE);
+ if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
+ {
+ return r;
+ }
+ if (r != CSR_RESULT_SUCCESS)
+ {
+ unifi_error(card->ospriv, "Failed to write fh signals: %u bytes, error %d\n", len, r);
+ return r;
+ }
+
+ /* Update from-host-signals-written signal count */
+ card->from_host_signals_w =
+ (card->from_host_signals_w + card->fh_buffer.count) % 128u;
+ r = unifi_write_8_or_16(card, card->sdio_ctrl_addr + 0,
+ (u8)card->from_host_signals_w);
+ if (r != CSR_RESULT_SUCCESS)
+ {
+ unifi_error(card->ospriv, "Failed to write fh signal count %u with error %d\n",
+ card->from_host_signals_w, r);
+ return r;
+ }
+ card->generate_interrupt = 1;
+
+ /* Reset the fh buffer pointer */
+ card->fh_buffer.ptr = card->fh_buffer.buf;
+ card->fh_buffer.count = 0;
+
+#ifdef CSR_WIFI_HIP_NOISY
+ unifi_error(card->ospriv, "END flush: fh len %d, count %d\n",
+ card->fh_buffer.ptr - card->fh_buffer.buf,
+ card->fh_buffer.count);
+#endif /* CSR_WIFI_HIP_NOISY */
+
+ return CSR_RESULT_SUCCESS;
+} /* flush_fh_buffer() */
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * restart_packet_flow
+ *
+ * This function is called before the bottom-half thread sleeps.
+ * It checks whether both data and signal resources are available and
+ * then calls the OS-layer function to re-enable packet transmission.
+ *
+ * Arguments:
+ * card Pointer to card context struct
+ *
+ * Returns:
+ * None.
+ * ---------------------------------------------------------------------------
+ */
+static void restart_packet_flow(card_t *card)
+{
+ u8 q;
+
+ /*
+ * We only look at the fh_traffic_queue, because that is where packets from
+ * the network stack are placed.
+ */
+ for (q = 0; q <= UNIFI_TRAFFIC_Q_VO; q++)
+ {
+ if (card_is_tx_q_paused(card, q) &&
+ CSR_WIFI_HIP_Q_SLOTS_FREE(&card->fh_traffic_queue[q]) >= RESUME_XMIT_THRESHOLD)
+ {
+#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_DATA_PLANE_PROFILE)
+ unifi_debug_log_to_buf("U");
+#endif
+ card_tx_q_unpause(card, q);
+ unifi_restart_xmit(card->ospriv, (unifi_TrafficQueue)q);
+ }
+ }
+} /* restart_packet_flow() */
+
+
diff --git a/drivers/staging/csr/csr_wifi_hip_card_sdio_mem.c b/drivers/staging/csr/csr_wifi_hip_card_sdio_mem.c
new file mode 100644
index 000000000000..17867f60df16
--- /dev/null
+++ b/drivers/staging/csr/csr_wifi_hip_card_sdio_mem.c
@@ -0,0 +1,1713 @@
+/*****************************************************************************
+
+ (c) Cambridge Silicon Radio Limited 2012
+ All rights reserved and confidential information of CSR
+
+ Refer to LICENSE.txt included with this source for details
+ on the license terms.
+
+*****************************************************************************/
+
+/*
+ * ---------------------------------------------------------------------------
+ * FILE: csr_wifi_hip_card_sdio_mem.c
+ *
+ * PURPOSE: Implementation of the Card API for SDIO.
+ *
+ * ---------------------------------------------------------------------------
+ */
+#include "csr_wifi_hip_unifi.h"
+#include "csr_wifi_hip_card.h"
+
+#define SDIO_RETRIES 3
+#define CSR_WIFI_HIP_SDIO_TRACE_DATA_LENGTH 16
+
+
+#define retryable_sdio_error(_csrResult) (((_csrResult) == CSR_SDIO_RESULT_CRC_ERROR) || ((_csrResult) == CSR_SDIO_RESULT_TIMEOUT))
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * retrying_read8
+ * retrying_write8
+ *
+ * These functions provide the first level of retry for SDIO operations.
+ * If an SDIO command fails for reason of a response timeout or CRC
+ * error, it is retried immediately. If three attempts fail we report a
+ * failure.
+ * If the command failed for any other reason, the failure is reported
+ * immediately.
+ *
+ * Arguments:
+ * card Pointer to card structure.
+ * funcnum The SDIO function to access.
+ * Function 0 is the Card Configuration Register space,
+ * function 1/2 is the UniFi register space.
+ * addr Address to access
+ * pdata Pointer in which to return the value read.
+ * data Value to write.
+ *
+ * Returns:
+ * CSR_RESULT_SUCCESS on success, non-zero error code on error:
+ * CSR_WIFI_HIP_RESULT_NO_DEVICE card was ejected
+ * CSR_RESULT_FAILURE an SDIO error occurred
+ * ---------------------------------------------------------------------------
+ */
+static CsrResult retrying_read8(card_t *card, s16 funcnum, u32 addr, u8 *pdata)
+{
+ CsrSdioFunction *sdio = card->sdio_if;
+ CsrResult r = CSR_RESULT_SUCCESS;
+ s16 retries;
+ CsrResult csrResult = CSR_RESULT_SUCCESS;
+
+ retries = 0;
+ while (retries++ < SDIO_RETRIES)
+ {
+ if (funcnum == 0)
+ {
+#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_SDIO_TRACE)
+ unifi_debug_log_to_buf("r0@%02X", addr);
+#endif
+ csrResult = CsrSdioF0Read8(sdio, addr, pdata);
+ }
+ else
+ {
+#ifdef CSR_WIFI_TRANSPORT_CSPI
+ unifi_error(card->ospriv,
+ "retrying_read_f0_8: F1 8-bit reads are not allowed.\n");
+ return CSR_RESULT_FAILURE;
+#else
+#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_SDIO_TRACE)
+ unifi_debug_log_to_buf("r@%02X", addr);
+#endif
+ csrResult = CsrSdioRead8(sdio, addr, pdata);
+#endif
+ }
+#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_SDIO_TRACE)
+ if (csrResult != CSR_RESULT_SUCCESS)
+ {
+ unifi_debug_log_to_buf("error=%X\n", csrResult);
+ }
+ else
+ {
+ unifi_debug_log_to_buf("=%X\n", *pdata);
+ }
+#endif
+ if (csrResult == CSR_SDIO_RESULT_NO_DEVICE)
+ {
+ return CSR_WIFI_HIP_RESULT_NO_DEVICE;
+ }
+ /*
+ * Try again for retryable (CRC or TIMEOUT) errors,
+ * break on success or fatal error
+ */
+ if (!retryable_sdio_error(csrResult))
+ {
+#ifdef CSR_WIFI_HIP_DATA_PLANE_PROFILE
+ card->cmd_prof.cmd52_count++;
+#endif
+ break;
+ }
+ unifi_trace(card->ospriv, UDBG2, "retryable SDIO error reading F%d 0x%lX\n", funcnum, addr);
+ }
+
+ if ((csrResult == CSR_RESULT_SUCCESS) && (retries > 1))
+ {
+ unifi_warning(card->ospriv, "Read succeeded after %d attempts\n", retries);
+ }
+
+ if (csrResult != CSR_RESULT_SUCCESS)
+ {
+ unifi_error(card->ospriv, "Failed to read from UniFi (addr 0x%lX) after %d tries\n",
+ addr, retries - 1);
+ /* Report any SDIO error as a general i/o error */
+ r = CSR_RESULT_FAILURE;
+ }
+
+ return r;
+} /* retrying_read8() */
+
+
+static CsrResult retrying_write8(card_t *card, s16 funcnum, u32 addr, u8 data)
+{
+ CsrSdioFunction *sdio = card->sdio_if;
+ CsrResult r = CSR_RESULT_SUCCESS;
+ s16 retries;
+ CsrResult csrResult = CSR_RESULT_SUCCESS;
+
+ retries = 0;
+ while (retries++ < SDIO_RETRIES)
+ {
+ if (funcnum == 0)
+ {
+#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_SDIO_TRACE)
+ unifi_debug_log_to_buf("w0@%02X=%X", addr, data);
+#endif
+ csrResult = CsrSdioF0Write8(sdio, addr, data);
+ }
+ else
+ {
+#ifdef CSR_WIFI_TRANSPORT_CSPI
+ unifi_error(card->ospriv,
+ "retrying_write_f0_8: F1 8-bit writes are not allowed.\n");
+ return CSR_RESULT_FAILURE;
+#else
+#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_SDIO_TRACE)
+ unifi_debug_log_to_buf("w@%02X=%X", addr, data);
+#endif
+ csrResult = CsrSdioWrite8(sdio, addr, data);
+#endif
+ }
+#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_SDIO_TRACE)
+ if (csrResult != CSR_RESULT_SUCCESS)
+ {
+ unifi_debug_log_to_buf(",error=%X", csrResult);
+ }
+ unifi_debug_string_to_buf("\n");
+#endif
+ if (csrResult == CSR_SDIO_RESULT_NO_DEVICE)
+ {
+ return CSR_WIFI_HIP_RESULT_NO_DEVICE;
+ }
+ /*
+ * Try again for retryable (CRC or TIMEOUT) errors,
+ * break on success or fatal error
+ */
+ if (!retryable_sdio_error(csrResult))
+ {
+#ifdef CSR_WIFI_HIP_DATA_PLANE_PROFILE
+ card->cmd_prof.cmd52_count++;
+#endif
+ break;
+ }
+ unifi_trace(card->ospriv, UDBG2, "retryable SDIO error writing %02X to F%d 0x%lX\n",
+ data, funcnum, addr);
+ }
+
+ if ((csrResult == CSR_RESULT_SUCCESS) && (retries > 1))
+ {
+ unifi_warning(card->ospriv, "Write succeeded after %d attempts\n", retries);
+ }
+
+ if (csrResult != CSR_RESULT_SUCCESS)
+ {
+ unifi_error(card->ospriv, "Failed to write to UniFi (addr 0x%lX) after %d tries\n",
+ addr, retries - 1);
+ /* Report any SDIO error as a general i/o error */
+ r = CSR_RESULT_FAILURE;
+ }
+
+ return r;
+} /* retrying_write8() */
+
+
+static CsrResult retrying_read16(card_t *card, s16 funcnum,
+ u32 addr, u16 *pdata)
+{
+ CsrSdioFunction *sdio = card->sdio_if;
+ CsrResult r = CSR_RESULT_SUCCESS;
+ s16 retries;
+ CsrResult csrResult = CSR_RESULT_SUCCESS;
+
+ retries = 0;
+ while (retries++ < SDIO_RETRIES)
+ {
+#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_SDIO_TRACE)
+ unifi_debug_log_to_buf("r@%02X", addr);
+#endif
+ csrResult = CsrSdioRead16(sdio, addr, pdata);
+#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_SDIO_TRACE)
+ if (csrResult != CSR_RESULT_SUCCESS)
+ {
+ unifi_debug_log_to_buf("error=%X\n", csrResult);
+ }
+ else
+ {
+ unifi_debug_log_to_buf("=%X\n", *pdata);
+ }
+#endif
+ if (csrResult == CSR_SDIO_RESULT_NO_DEVICE)
+ {
+ return CSR_WIFI_HIP_RESULT_NO_DEVICE;
+ }
+
+ /*
+ * Try again for retryable (CRC or TIMEOUT) errors,
+ * break on success or fatal error
+ */
+ if (!retryable_sdio_error(csrResult))
+ {
+#ifdef CSR_WIFI_HIP_DATA_PLANE_PROFILE
+ card->cmd_prof.cmd52_count++;
+#endif
+ break;
+ }
+ unifi_trace(card->ospriv, UDBG2, "retryable SDIO error reading F%d 0x%lX\n", funcnum, addr);
+ }
+
+ if ((csrResult == CSR_RESULT_SUCCESS) && (retries > 1))
+ {
+ unifi_warning(card->ospriv, "Read succeeded after %d attempts\n", retries);
+ }
+
+ if (csrResult != CSR_RESULT_SUCCESS)
+ {
+ unifi_error(card->ospriv, "Failed to read from UniFi (addr 0x%lX) after %d tries\n",
+ addr, retries - 1);
+ /* Report any SDIO error as a general i/o error */
+ r = CSR_RESULT_FAILURE;
+ }
+
+ return r;
+} /* retrying_read16() */
+
+
+static CsrResult retrying_write16(card_t *card, s16 funcnum,
+ u32 addr, u16 data)
+{
+ CsrSdioFunction *sdio = card->sdio_if;
+ CsrResult r = CSR_RESULT_SUCCESS;
+ s16 retries;
+ CsrResult csrResult = CSR_RESULT_SUCCESS;
+
+ retries = 0;
+ while (retries++ < SDIO_RETRIES)
+ {
+#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_SDIO_TRACE)
+ unifi_debug_log_to_buf("w@%02X=%X", addr, data);
+#endif
+ csrResult = CsrSdioWrite16(sdio, addr, data);
+#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_SDIO_TRACE)
+ if (csrResult != CSR_RESULT_SUCCESS)
+ {
+ unifi_debug_log_to_buf(",error=%X", csrResult);
+ }
+ unifi_debug_string_to_buf("\n");
+#endif
+ if (csrResult == CSR_SDIO_RESULT_NO_DEVICE)
+ {
+ return CSR_WIFI_HIP_RESULT_NO_DEVICE;
+ }
+
+ /*
+ * Try again for retryable (CRC or TIMEOUT) errors,
+ * break on success or fatal error
+ */
+ if (!retryable_sdio_error(csrResult))
+ {
+#ifdef CSR_WIFI_HIP_DATA_PLANE_PROFILE
+ card->cmd_prof.cmd52_count++;
+#endif
+ break;
+ }
+ unifi_trace(card->ospriv, UDBG2, "retryable SDIO error writing %02X to F%d 0x%lX\n",
+ data, funcnum, addr);
+ }
+
+ if ((csrResult == CSR_RESULT_SUCCESS) && (retries > 1))
+ {
+ unifi_warning(card->ospriv, "Write succeeded after %d attempts\n", retries);
+ }
+
+ if (csrResult != CSR_RESULT_SUCCESS)
+ {
+ unifi_error(card->ospriv, "Failed to write to UniFi (addr 0x%lX) after %d tries\n",
+ addr, retries - 1);
+ /* Report any SDIO error as a general i/o error */
+ r = CSR_RESULT_FAILURE;
+ }
+
+ return r;
+} /* retrying_write16() */
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * sdio_read_f0
+ *
+ * Reads a byte value from the CCCR (func 0) area of UniFi.
+ *
+ * Arguments:
+ * card Pointer to card structure.
+ * addr Address to read from
+ * pdata Pointer in which to store the read value.
+ *
+ * Returns:
+ * CSR_RESULT_SUCCESS on success, non-zero error code on error:
+ * CSR_WIFI_HIP_RESULT_NO_DEVICE card was ejected
+ * CSR_RESULT_FAILURE an SDIO error occurred
+ * ---------------------------------------------------------------------------
+ */
+CsrResult sdio_read_f0(card_t *card, u32 addr, u8 *pdata)
+{
+#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_DATA_PLANE_PROFILE)
+ card->cmd_prof.cmd52_f0_r_count++;
+#endif
+ return retrying_read8(card, 0, addr, pdata);
+} /* sdio_read_f0() */
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * sdio_write_f0
+ *
+ * Writes a byte value to the CCCR (func 0) area of UniFi.
+ *
+ * Arguments:
+ * card Pointer to card structure.
+ * addr Address to read from
+ * data Data value to write.
+ *
+ * Returns:
+ * CSR_RESULT_SUCCESS on success, non-zero error code on error:
+ * CSR_WIFI_HIP_RESULT_NO_DEVICE card was ejected
+ * CSR_RESULT_FAILURE an SDIO error occurred
+ * ---------------------------------------------------------------------------
+ */
+CsrResult sdio_write_f0(card_t *card, u32 addr, u8 data)
+{
+#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_DATA_PLANE_PROFILE)
+ card->cmd_prof.cmd52_f0_w_count++;
+#endif
+ return retrying_write8(card, 0, addr, data);
+} /* sdio_write_f0() */
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * unifi_read_direct_8_or_16
+ *
+ * Read a 8-bit value from the UniFi SDIO interface.
+ *
+ * Arguments:
+ * card Pointer to card structure.
+ * addr Address to read from
+ * pdata Pointer in which to return data.
+ *
+ * Returns:
+ * CSR_RESULT_SUCCESS on success, non-zero error code on error:
+ * ---------------------------------------------------------------------------
+ */
+CsrResult unifi_read_direct_8_or_16(card_t *card, u32 addr, u8 *pdata)
+{
+#ifdef CSR_WIFI_TRANSPORT_CSPI
+ u16 w;
+ CsrResult r;
+
+ r = retrying_read16(card, card->function, addr, &w);
+ *pdata = (u8)(w & 0xFF);
+ return r;
+#else
+ return retrying_read8(card, card->function, addr, pdata);
+#endif
+} /* unifi_read_direct_8_or_16() */
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * unifi_write_direct_8_or_16
+ *
+ * Write a byte value to the UniFi SDIO interface.
+ *
+ * Arguments:
+ * card Pointer to card structure.
+ * addr Address to write to
+ * data Value to write.
+ *
+ * Returns:
+ * CSR_RESULT_SUCCESS on success, non-zero error code on error
+ *
+ * Notes:
+ * If 8-bit write is used, the even address *must* be written second.
+ * This is because writes to odd bytes are cached and not committed
+ * to memory until the preceding even address is written.
+ * ---------------------------------------------------------------------------
+ */
+CsrResult unifi_write_direct_8_or_16(card_t *card, u32 addr, u8 data)
+{
+ if (addr & 1)
+ {
+ unifi_warning(card->ospriv,
+ "Warning: Byte write to an odd address (0x%lX) is dangerous\n",
+ addr);
+ }
+
+#ifdef CSR_WIFI_TRANSPORT_CSPI
+ return retrying_write16(card, card->function, addr, (u16)data);
+#else
+ return retrying_write8(card, card->function, addr, data);
+#endif
+} /* unifi_write_direct_8_or_16() */
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * unifi_read_direct16
+ *
+ * Read a 16-bit value from the UniFi SDIO interface.
+ *
+ * Arguments:
+ * card Pointer to card structure.
+ * addr Address to read from
+ * pdata Pointer in which to return data.
+ *
+ * Returns:
+ * CSR_RESULT_SUCCESS on success, non-zero error code on error:
+ * CSR_WIFI_HIP_RESULT_NO_DEVICE card was ejected
+ * CSR_RESULT_FAILURE an SDIO error occurred
+ *
+ * Notes:
+ * The even address *must* be read first. This is because reads from
+ * odd bytes are cached and read from memory when the preceding
+ * even address is read.
+ * ---------------------------------------------------------------------------
+ */
+CsrResult unifi_read_direct16(card_t *card, u32 addr, u16 *pdata)
+{
+ return retrying_read16(card, card->function, addr, pdata);
+} /* unifi_read_direct16() */
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * unifi_write_direct16
+ *
+ * Write a 16-bit value to the UniFi SDIO interface.
+ *
+ * Arguments:
+ * card Pointer to card structure.
+ * addr Address to write to
+ * data Value to write.
+ *
+ * Returns:
+ * CSR_RESULT_SUCCESS on success, non-zero error code on error:
+ * CSR_WIFI_HIP_RESULT_NO_DEVICE card was ejected
+ * CSR_RESULT_FAILURE an SDIO error occurred
+ *
+ * Notes:
+ * The even address *must* be written second. This is because writes to
+ * odd bytes are cached and not committed to memory until the preceding
+ * even address is written.
+ * ---------------------------------------------------------------------------
+ */
+CsrResult unifi_write_direct16(card_t *card, u32 addr, u16 data)
+{
+ return retrying_write16(card, card->function, addr, data);
+} /* unifi_write_direct16() */
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * unifi_read_direct32
+ *
+ * Read a 32-bit value from the UniFi SDIO interface.
+ *
+ * Arguments:
+ * card Pointer to card structure.
+ * addr Address to read from
+ * pdata Pointer in which to return data.
+ *
+ * Returns:
+ * CSR_RESULT_SUCCESS on success, non-zero error code on error:
+ * CSR_WIFI_HIP_RESULT_NO_DEVICE card was ejected
+ * CSR_RESULT_FAILURE an SDIO error occurred
+ * ---------------------------------------------------------------------------
+ */
+CsrResult unifi_read_direct32(card_t *card, u32 addr, u32 *pdata)
+{
+ CsrResult r;
+ u16 w0, w1;
+
+ r = retrying_read16(card, card->function, addr, &w0);
+ if (r != CSR_RESULT_SUCCESS)
+ {
+ return r;
+ }
+
+ r = retrying_read16(card, card->function, addr + 2, &w1);
+ if (r != CSR_RESULT_SUCCESS)
+ {
+ return r;
+ }
+
+ *pdata = ((u32)w1 << 16) | (u32)w0;
+
+ return CSR_RESULT_SUCCESS;
+} /* unifi_read_direct32() */
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * unifi_read_directn_match
+ *
+ * Read multiple 8-bit values from the UniFi SDIO interface,
+ * stopping when either we have read 'len' bytes or we have read
+ * a octet equal to 'match'. If 'match' is not a valid octet
+ * then this function is the same as 'unifi_read_directn'.
+ *
+ * Arguments:
+ * card Pointer to card structure.
+ * addr Start address to read from.
+ * pdata Pointer to which to write data.
+ * len Maximum umber of bytes to read
+ * match The value to stop reading at.
+ * num Pointer to buffer to write number of bytes read
+ *
+ * Returns:
+ * number of octets read on success, negative error code on error:
+ * CSR_WIFI_HIP_RESULT_NO_DEVICE card was ejected
+ * CSR_RESULT_FAILURE an SDIO error occurred
+ *
+ * Notes:
+ * The even address *must* be read first. This is because reads from
+ * odd bytes are cached and read from memory when the preceding
+ * even address is read.
+ * ---------------------------------------------------------------------------
+ */
+static CsrResult unifi_read_directn_match(card_t *card, u32 addr, void *pdata, u16 len, s8 m, u32 *num)
+{
+ CsrResult r;
+ u32 i;
+ u8 *cptr;
+ u16 w;
+
+ *num = 0;
+
+ cptr = (u8 *)pdata;
+ for (i = 0; i < len; i += 2)
+ {
+ r = retrying_read16(card, card->function, addr, &w);
+ if (r != CSR_RESULT_SUCCESS)
+ {
+ return r;
+ }
+
+ *cptr++ = ((u8)w & 0xFF);
+ if ((m >= 0) && (((s8)w & 0xFF) == m))
+ {
+ break;
+ }
+
+ if (i + 1 == len)
+ {
+ /* The len is odd. Ignore the last high byte */
+ break;
+ }
+
+ *cptr++ = ((u8)(w >> 8) & 0xFF);
+ if ((m >= 0) && (((s8)(w >> 8) & 0xFF) == m))
+ {
+ break;
+ }
+
+ addr += 2;
+ }
+
+ *num = (s32)(cptr - (u8 *)pdata);
+ return CSR_RESULT_SUCCESS;
+}
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * unifi_read_directn
+ *
+ * Read multiple 8-bit values from the UniFi SDIO interface.
+ *
+ * Arguments:
+ * card Pointer to card structure.
+ * addr Start address to read from.
+ * pdata Pointer to which to write data.
+ * len Number of bytes to read
+ *
+ * Returns:
+ * 0 on success, non-zero error code on error:
+ * CSR_WIFI_HIP_RESULT_NO_DEVICE card was ejected
+ * CSR_RESULT_FAILURE an SDIO error occurred
+ *
+ * Notes:
+ * The even address *must* be read first. This is because reads from
+ * odd bytes are cached and read from memory when the preceding
+ * even address is read.
+ * ---------------------------------------------------------------------------
+ */
+CsrResult unifi_read_directn(card_t *card, u32 addr, void *pdata, u16 len)
+{
+ u32 num;
+
+ return unifi_read_directn_match(card, addr, pdata, len, -1, &num);
+} /* unifi_read_directn() */
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * unifi_write_directn
+ *
+ * Write multiple 8-bit values to the UniFi SDIO interface.
+ *
+ * Arguments:
+ * card Pointer to card structure.
+ * addr Start address to write to.
+ * pdata Source data pointer.
+ * len Number of bytes to write, must be even.
+ *
+ * Returns:
+ * 0 on success, non-zero error code on error:
+ * CSR_WIFI_HIP_RESULT_NO_DEVICE card was ejected
+ * CSR_RESULT_FAILURE an SDIO error occurred
+ *
+ * Notes:
+ * The UniFi has a peculiar 16-bit bus architecture. Writes are only
+ * committed to memory when an even address is accessed. Writes to
+ * odd addresses are cached and only committed if the next write is
+ * to the preceding address.
+ * This means we must write data as pairs of bytes in reverse order.
+ * ---------------------------------------------------------------------------
+ */
+CsrResult unifi_write_directn(card_t *card, u32 addr, void *pdata, u16 len)
+{
+ CsrResult r;
+ u8 *cptr;
+ s16 signed_len;
+
+ cptr = (u8 *)pdata;
+ signed_len = (s16)len;
+ while (signed_len > 0)
+ {
+ /* This is UniFi-1 specific code. CSPI not supported so 8-bit write allowed */
+ r = retrying_write16(card, card->function, addr, *cptr);
+ if (r != CSR_RESULT_SUCCESS)
+ {
+ return r;
+ }
+
+ cptr += 2;
+ addr += 2;
+ signed_len -= 2;
+ }
+
+ return CSR_RESULT_SUCCESS;
+} /* unifi_write_directn() */
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * set_dmem_page
+ * set_pmem_page
+ *
+ * Set up the page register for the shared data memory window or program
+ * memory window.
+ *
+ * Arguments:
+ * card Pointer to card structure.
+ * dmem_addr UniFi shared-data-memory address to access.
+ * pmem_addr UniFi program memory address to access. This includes
+ * External FLASH memory at 0x000000
+ * Processor program memory at 0x200000
+ * External SRAM at memory 0x400000
+ * paddr Location to write an SDIO address (24-bit) for
+ * use in a unifi_read_direct or unifi_write_direct call.
+ *
+ * Returns:
+ * CSR_RESULT_SUCCESS on success
+ * CSR_WIFI_HIP_RESULT_NO_DEVICE card was ejected
+ * CSR_RESULT_FAILURE an SDIO error occurred
+ * ---------------------------------------------------------------------------
+ */
+static CsrResult set_dmem_page(card_t *card, u32 dmem_addr, u32 *paddr)
+{
+ u16 page, addr;
+ u32 len;
+ CsrResult r;
+
+ *paddr = 0;
+
+ if (!ChipHelper_DecodeWindow(card->helper,
+ CHIP_HELPER_WINDOW_3,
+ CHIP_HELPER_WT_SHARED,
+ dmem_addr / 2,
+ &page, &addr, &len))
+ {
+ unifi_error(card->ospriv, "Failed to decode SHARED_DMEM_PAGE %08lx\n", dmem_addr);
+ return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
+ }
+
+ if (page != card->dmem_page)
+ {
+ unifi_trace(card->ospriv, UDBG6, "setting dmem page=0x%X, addr=0x%lX\n", page, addr);
+
+ /* change page register */
+ r = unifi_write_direct16(card, ChipHelper_HOST_WINDOW3_PAGE(card->helper) * 2, page);
+ if (r != CSR_RESULT_SUCCESS)
+ {
+ unifi_error(card->ospriv, "Failed to write SHARED_DMEM_PAGE\n");
+ return r;
+ }
+
+ card->dmem_page = page;
+ }
+
+ *paddr = ((s32)addr * 2) + (dmem_addr & 1);
+
+ return CSR_RESULT_SUCCESS;
+} /* set_dmem_page() */
+
+
+static CsrResult set_pmem_page(card_t *card, u32 pmem_addr,
+ enum chip_helper_window_type mem_type, u32 *paddr)
+{
+ u16 page, addr;
+ u32 len;
+ CsrResult r;
+
+ *paddr = 0;
+
+ if (!ChipHelper_DecodeWindow(card->helper,
+ CHIP_HELPER_WINDOW_2,
+ mem_type,
+ pmem_addr / 2,
+ &page, &addr, &len))
+ {
+ unifi_error(card->ospriv, "Failed to decode PROG MEM PAGE %08lx %d\n", pmem_addr, mem_type);
+ return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
+ }
+
+ if (page != card->pmem_page)
+ {
+ unifi_trace(card->ospriv, UDBG6, "setting pmem page=0x%X, addr=0x%lX\n", page, addr);
+
+ /* change page register */
+ r = unifi_write_direct16(card, ChipHelper_HOST_WINDOW2_PAGE(card->helper) * 2, page);
+ if (r != CSR_RESULT_SUCCESS)
+ {
+ unifi_error(card->ospriv, "Failed to write PROG MEM PAGE\n");
+ return r;
+ }
+
+ card->pmem_page = page;
+ }
+
+ *paddr = ((s32)addr * 2) + (pmem_addr & 1);
+
+ return CSR_RESULT_SUCCESS;
+} /* set_pmem_page() */
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * set_page
+ *
+ * Sets up the appropriate page register to access the given address.
+ * Returns the sdio address at which the unifi address can be accessed.
+ *
+ * Arguments:
+ * card Pointer to card structure.
+ * generic_addr UniFi internal address to access, in Generic Pointer
+ * format, i.e. top byte is space indicator.
+ * paddr Location to write page address
+ * SDIO address (24-bit) for use in a unifi_read_direct or
+ * unifi_write_direct call
+ *
+ * Returns:
+ * CSR_WIFI_HIP_RESULT_NO_DEVICE card was ejected
+ * CSR_RESULT_FAILURE an SDIO error occurred
+ * CSR_WIFI_HIP_RESULT_INVALID_VALUE the address is invalid
+ * ---------------------------------------------------------------------------
+ */
+static CsrResult set_page(card_t *card, u32 generic_addr, u32 *paddr)
+{
+ s32 space;
+ u32 addr;
+ CsrResult r = CSR_RESULT_SUCCESS;
+
+ if (!paddr)
+ {
+ return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
+ }
+ *paddr = 0;
+ space = UNIFI_GP_SPACE(generic_addr);
+ addr = UNIFI_GP_OFFSET(generic_addr);
+ switch (space)
+ {
+ case UNIFI_SH_DMEM:
+ /* Shared Data Memory is accessed via the Shared Data Memory window */
+ r = set_dmem_page(card, addr, paddr);
+ if (r != CSR_RESULT_SUCCESS)
+ {
+ return r;
+ }
+ break;
+
+ case UNIFI_EXT_FLASH:
+ if (!ChipHelper_HasFlash(card->helper))
+ {
+ unifi_error(card->ospriv, "Bad address space for chip in generic pointer 0x%08lX (helper=0x%x)\n",
+ generic_addr, card->helper);
+ return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
+ }
+ /* External FLASH is accessed via the Program Memory window */
+ r = set_pmem_page(card, addr, CHIP_HELPER_WT_FLASH, paddr);
+ break;
+
+ case UNIFI_EXT_SRAM:
+ if (!ChipHelper_HasExtSram(card->helper))
+ {
+ unifi_error(card->ospriv, "Bad address space for chip in generic pointer 0x%08l (helper=0x%x)\n",
+ generic_addr, card->helper);
+ return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
+ }
+ /* External SRAM is accessed via the Program Memory window */
+ r = set_pmem_page(card, addr, CHIP_HELPER_WT_EXT_SRAM, paddr);
+ break;
+
+ case UNIFI_REGISTERS:
+ /* Registers are accessed directly */
+ *paddr = addr;
+ break;
+
+ case UNIFI_PHY_DMEM:
+ r = unifi_set_proc_select(card, UNIFI_PROC_PHY);
+ if (r != CSR_RESULT_SUCCESS)
+ {
+ return r;
+ }
+ *paddr = ChipHelper_DATA_MEMORY_RAM_OFFSET(card->helper) * 2 + addr;
+ break;
+
+ case UNIFI_MAC_DMEM:
+ r = unifi_set_proc_select(card, UNIFI_PROC_MAC);
+ if (r != CSR_RESULT_SUCCESS)
+ {
+ return r;
+ }
+ *paddr = ChipHelper_DATA_MEMORY_RAM_OFFSET(card->helper) * 2 + addr;
+ break;
+
+ case UNIFI_BT_DMEM:
+ if (!ChipHelper_HasBt(card->helper))
+ {
+ unifi_error(card->ospriv, "Bad address space for chip in generic pointer 0x%08lX (helper=0x%x)\n",
+ generic_addr, card->helper);
+ return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
+ }
+ r = unifi_set_proc_select(card, UNIFI_PROC_BT);
+ if (r != CSR_RESULT_SUCCESS)
+ {
+ return r;
+ }
+ *paddr = ChipHelper_DATA_MEMORY_RAM_OFFSET(card->helper) * 2 + addr;
+ break;
+
+ case UNIFI_PHY_PMEM:
+ r = unifi_set_proc_select(card, UNIFI_PROC_PHY);
+ if (r != CSR_RESULT_SUCCESS)
+ {
+ return r;
+ }
+ r = set_pmem_page(card, addr, CHIP_HELPER_WT_CODE_RAM, paddr);
+ break;
+
+ case UNIFI_MAC_PMEM:
+ r = unifi_set_proc_select(card, UNIFI_PROC_MAC);
+ if (r != CSR_RESULT_SUCCESS)
+ {
+ return r;
+ }
+ r = set_pmem_page(card, addr, CHIP_HELPER_WT_CODE_RAM, paddr);
+ break;
+
+ case UNIFI_BT_PMEM:
+ if (!ChipHelper_HasBt(card->helper))
+ {
+ unifi_error(card->ospriv, "Bad address space for chip in generic pointer 0x%08lX (helper=0x%x)\n",
+ generic_addr, card->helper);
+ return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
+ }
+ r = unifi_set_proc_select(card, UNIFI_PROC_BT);
+ if (r != CSR_RESULT_SUCCESS)
+ {
+ return r;
+ }
+ r = set_pmem_page(card, addr, CHIP_HELPER_WT_CODE_RAM, paddr);
+ break;
+
+ case UNIFI_PHY_ROM:
+ if (!ChipHelper_HasRom(card->helper))
+ {
+ unifi_error(card->ospriv, "Bad address space for chip in generic pointer 0x%08lX (helper=0x%x)\n",
+ generic_addr, card->helper);
+ return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
+ }
+ r = unifi_set_proc_select(card, UNIFI_PROC_PHY);
+ if (r != CSR_RESULT_SUCCESS)
+ {
+ return r;
+ }
+ r = set_pmem_page(card, addr, CHIP_HELPER_WT_ROM, paddr);
+ break;
+
+ case UNIFI_MAC_ROM:
+ if (!ChipHelper_HasRom(card->helper))
+ {
+ unifi_error(card->ospriv, "Bad address space for chip in generic pointer 0x%08lX (helper=0x%x)\n",
+ generic_addr, card->helper);
+ return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
+ }
+ r = unifi_set_proc_select(card, UNIFI_PROC_MAC);
+ if (r != CSR_RESULT_SUCCESS)
+ {
+ return r;
+ }
+ r = set_pmem_page(card, addr, CHIP_HELPER_WT_ROM, paddr);
+ break;
+
+ case UNIFI_BT_ROM:
+ if (!ChipHelper_HasRom(card->helper) || !ChipHelper_HasBt(card->helper))
+ {
+ unifi_error(card->ospriv, "Bad address space for chip in generic pointer 0x%08lX (helper=0x%x)\n",
+ generic_addr, card->helper);
+ return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
+ }
+ r = unifi_set_proc_select(card, UNIFI_PROC_BT);
+ if (r != CSR_RESULT_SUCCESS)
+ {
+ return r;
+ }
+ r = set_pmem_page(card, addr, CHIP_HELPER_WT_ROM, paddr);
+ break;
+
+ default:
+ unifi_error(card->ospriv, "Bad address space %d in generic pointer 0x%08lX (helper=0x%x)\n",
+ space, generic_addr, card->helper);
+ return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
+ }
+
+ return r;
+} /* set_page() */
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * unifi_set_proc_select
+ *
+ *
+ * Arguments:
+ * card Pointer to card structure.
+ * select Which XAP core to select
+ *
+ * Returns:
+ * 0 on success, non-zero error code on error:
+ * CSR_WIFI_HIP_RESULT_NO_DEVICE card was ejected
+ * CSR_RESULT_FAILURE an SDIO error occurred
+ * ---------------------------------------------------------------------------
+ */
+CsrResult unifi_set_proc_select(card_t *card, enum unifi_dbg_processors_select select)
+{
+ CsrResult r;
+
+ /* Verify the the select value is allowed. */
+ switch (select)
+ {
+ case UNIFI_PROC_MAC:
+ case UNIFI_PROC_PHY:
+ case UNIFI_PROC_BOTH:
+ break;
+
+
+ default:
+ return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
+ }
+
+ if (card->proc_select != (u32)select)
+ {
+ r = unifi_write_direct16(card,
+ ChipHelper_DBG_HOST_PROC_SELECT(card->helper) * 2,
+ (u8)select);
+ if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
+ {
+ return r;
+ }
+ if (r != CSR_RESULT_SUCCESS)
+ {
+ unifi_error(card->ospriv, "Failed to write to Proc Select register\n");
+ return r;
+ }
+
+ card->proc_select = (u32)select;
+ }
+
+ return CSR_RESULT_SUCCESS;
+}
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * unifi_read_8_or_16
+ *
+ * Performs a byte read of the given address in shared data memory.
+ * Set up the shared data memory page register as required.
+ *
+ * Arguments:
+ * card Pointer to card structure.
+ * unifi_addr UniFi shared-data-memory address to access.
+ * pdata Pointer to a byte variable for the value read.
+ *
+ * Returns:
+ * CSR_RESULT_SUCCESS on success, non-zero error code on error:
+ * CSR_WIFI_HIP_RESULT_NO_DEVICE card was ejected
+ * CSR_RESULT_FAILURE an SDIO error occurred
+ * CSR_WIFI_HIP_RESULT_INVALID_VALUE a bad generic pointer was specified
+ * ---------------------------------------------------------------------------
+ */
+CsrResult unifi_read_8_or_16(card_t *card, u32 unifi_addr, u8 *pdata)
+{
+ u32 sdio_addr;
+ CsrResult r;
+#ifdef CSR_WIFI_TRANSPORT_CSPI
+ u16 w;
+#endif
+
+ r = set_page(card, unifi_addr, &sdio_addr);
+ if (r != CSR_RESULT_SUCCESS)
+ {
+ return r;
+ }
+
+#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_DATA_PLANE_PROFILE)
+ card->cmd_prof.cmd52_r8or16_count++;
+#endif
+#ifdef CSR_WIFI_TRANSPORT_CSPI
+ r = retrying_read16(card, card->function, sdio_addr, &w);
+ *pdata = (u8)(w & 0xFF);
+ return r;
+#else
+ return retrying_read8(card, card->function, sdio_addr, pdata);
+#endif
+} /* unifi_read_8_or_16() */
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * unifi_write_8_or_16
+ *
+ * Performs a byte write of the given address in shared data memory.
+ * Set up the shared data memory page register as required.
+ *
+ * Arguments:
+ * card Pointer to card context struct.
+ * unifi_addr UniFi shared-data-memory address to access.
+ * data Value to write.
+ *
+ * Returns:
+ * CSR_RESULT_SUCCESS on success, non-zero error code on error:
+ * CSR_WIFI_HIP_RESULT_NO_DEVICE card was ejected
+ * CSR_RESULT_FAILURE an SDIO error occurred
+ * CSR_WIFI_HIP_RESULT_INVALID_VALUE a bad generic pointer was specified
+ *
+ * Notes:
+ * Beware using unifi_write8() because byte writes are not safe on UniFi.
+ * Writes to odd bytes are cached, writes to even bytes perform a 16-bit
+ * write with the previously cached odd byte.
+ * ---------------------------------------------------------------------------
+ */
+CsrResult unifi_write_8_or_16(card_t *card, u32 unifi_addr, u8 data)
+{
+ u32 sdio_addr;
+ CsrResult r;
+#ifdef CSR_WIFI_TRANSPORT_CSPI
+ u16 w;
+#endif
+
+ r = set_page(card, unifi_addr, &sdio_addr);
+ if (r != CSR_RESULT_SUCCESS)
+ {
+ return r;
+ }
+
+ if (sdio_addr & 1)
+ {
+ unifi_warning(card->ospriv,
+ "Warning: Byte write to an odd address (0x%lX) is dangerous\n",
+ sdio_addr);
+ }
+
+#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_DATA_PLANE_PROFILE)
+ card->cmd_prof.cmd52_w8or16_count++;
+#endif
+#ifdef CSR_WIFI_TRANSPORT_CSPI
+ w = data;
+ return retrying_write16(card, card->function, sdio_addr, w);
+#else
+ return retrying_write8(card, card->function, sdio_addr, data);
+#endif
+} /* unifi_write_8_or_16() */
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * unifi_card_read16
+ *
+ * Performs a 16-bit read of the given address in shared data memory.
+ * Set up the shared data memory page register as required.
+ *
+ * Arguments:
+ * card Pointer to card structure.
+ * unifi_addr UniFi shared-data-memory address to access.
+ * pdata Pointer to a 16-bit int variable for the value read.
+ *
+ * Returns:
+ * CSR_RESULT_SUCCESS on success, non-zero error code on error:
+ * CSR_WIFI_HIP_RESULT_NO_DEVICE card was ejected
+ * CSR_RESULT_FAILURE an SDIO error occurred
+ * CSR_WIFI_HIP_RESULT_INVALID_VALUE a bad generic pointer was specified
+ * ---------------------------------------------------------------------------
+ */
+CsrResult unifi_card_read16(card_t *card, u32 unifi_addr, u16 *pdata)
+{
+ u32 sdio_addr;
+ CsrResult r;
+
+ r = set_page(card, unifi_addr, &sdio_addr);
+ if (r != CSR_RESULT_SUCCESS)
+ {
+ return r;
+ }
+
+#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_DATA_PLANE_PROFILE)
+ card->cmd_prof.cmd52_r16_count++;
+#endif
+ return unifi_read_direct16(card, sdio_addr, pdata);
+} /* unifi_card_read16() */
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * unifi_card_write16
+ *
+ * Performs a 16-bit write of the given address in shared data memory.
+ * Set up the shared data memory page register as required.
+ *
+ * Arguments:
+ * card Pointer to card structure.
+ * unifi_addr UniFi shared-data-memory address to access.
+ * pdata Pointer to a byte variable for the value write.
+ *
+ * Returns:
+ * CSR_RESULT_SUCCESS on success, non-zero error code on error:
+ * CSR_WIFI_HIP_RESULT_NO_DEVICE card was ejected
+ * CSR_RESULT_FAILURE an SDIO error occurred
+ * CSR_WIFI_HIP_RESULT_INVALID_VALUE a bad generic pointer was specified
+ * ---------------------------------------------------------------------------
+ */
+CsrResult unifi_card_write16(card_t *card, u32 unifi_addr, u16 data)
+{
+ u32 sdio_addr;
+ CsrResult r;
+
+ r = set_page(card, unifi_addr, &sdio_addr);
+ if (r != CSR_RESULT_SUCCESS)
+ {
+ return r;
+ }
+
+#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_DATA_PLANE_PROFILE)
+ card->cmd_prof.cmd52_w16_count++;
+#endif
+ return unifi_write_direct16(card, sdio_addr, data);
+} /* unifi_card_write16() */
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * unifi_read32
+ *
+ * Performs a 32-bit read of the given address in shared data memory.
+ * Set up the shared data memory page register as required.
+ *
+ * Arguments:
+ * card Pointer to card structure.
+ * unifi_addr UniFi shared-data-memory address to access.
+ * pdata Pointer to a int variable for the value read.
+ *
+ * Returns:
+ * CSR_RESULT_SUCCESS on success, non-zero error code on error:
+ * CSR_WIFI_HIP_RESULT_NO_DEVICE card was ejected
+ * CSR_RESULT_FAILURE an SDIO error occurred
+ * CSR_WIFI_HIP_RESULT_INVALID_VALUE a bad generic pointer was specified
+ * ---------------------------------------------------------------------------
+ */
+CsrResult unifi_read32(card_t *card, u32 unifi_addr, u32 *pdata)
+{
+ u32 sdio_addr;
+ CsrResult r;
+
+ r = set_page(card, unifi_addr, &sdio_addr);
+ if (r != CSR_RESULT_SUCCESS)
+ {
+ return r;
+ }
+
+#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_DATA_PLANE_PROFILE)
+ card->cmd_prof.cmd52_r32_count++;
+#endif
+ return unifi_read_direct32(card, sdio_addr, pdata);
+} /* unifi_read32() */
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * unifi_card_readn
+ * unifi_readnz
+ *
+ * Read multiple 8-bit values from the UniFi SDIO interface.
+ * This function interprets the address as a GenericPointer as
+ * defined in the UniFi Host Interface Protocol Specification.
+ * The readnz version of this function will stop when it reads a
+ * zero octet.
+ *
+ * Arguments:
+ * card Pointer to card structure.
+ * unifi_addr UniFi shared-data-memory address to access.
+ * pdata Pointer to which to write data.
+ * len Number of bytes to read
+ *
+ * Returns:
+ * CSR_RESULT_SUCCESS on success, non-zero error code on error:
+ * CSR_WIFI_HIP_RESULT_NO_DEVICE card was ejected
+ * CSR_RESULT_FAILURE an SDIO error occurred
+ * CSR_WIFI_HIP_RESULT_INVALID_VALUE a bad generic pointer was specified
+ * ---------------------------------------------------------------------------
+ */
+CsrResult unifi_readn_match(card_t *card, u32 unifi_addr, void *pdata, u16 len, s8 match)
+{
+ u32 sdio_addr;
+ CsrResult r;
+ u32 num;
+
+ r = set_page(card, unifi_addr, &sdio_addr);
+ if (r != CSR_RESULT_SUCCESS)
+ {
+ return r;
+ }
+
+ r = unifi_read_directn_match(card, sdio_addr, pdata, len, match, &num);
+ return r;
+} /* unifi_readn_match() */
+
+
+CsrResult unifi_card_readn(card_t *card, u32 unifi_addr, void *pdata, u16 len)
+{
+ return unifi_readn_match(card, unifi_addr, pdata, len, -1);
+} /* unifi_card_readn() */
+
+
+CsrResult unifi_readnz(card_t *card, u32 unifi_addr, void *pdata, u16 len)
+{
+ return unifi_readn_match(card, unifi_addr, pdata, len, 0);
+} /* unifi_readnz() */
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * unifi_read_shared_count
+ *
+ * Read signal count locations, checking for an SDIO error. The
+ * signal count locations only contain a valid number if the
+ * highest bit isn't set.
+ *
+ * Arguments:
+ * card Pointer to card context structure.
+ * addr Shared-memory address to read.
+ *
+ * Returns:
+ * Value read from memory (0-127) or -1 on error
+ * ---------------------------------------------------------------------------
+ */
+s32 unifi_read_shared_count(card_t *card, u32 addr)
+{
+ u8 b;
+ /* I've increased this count, because I have seen cases where
+ * there were three reads in a row with the top bit set. I'm not
+ * sure why this might have happened, but I can't see a problem
+ * with increasing this limit. It's better to take a while to
+ * recover than to fail. */
+#define SHARED_READ_RETRY_LIMIT 10
+ s32 i;
+
+ /*
+ * Get the to-host-signals-written count.
+ * The top-bit will be set if the firmware was in the process of
+ * changing the value, in which case we read again.
+ */
+ /* Limit the number of repeats so we don't freeze */
+ for (i = 0; i < SHARED_READ_RETRY_LIMIT; i++)
+ {
+ CsrResult r;
+ r = unifi_read_8_or_16(card, addr, &b);
+ if (r != CSR_RESULT_SUCCESS)
+ {
+ return -1;
+ }
+ if (!(b & 0x80))
+ {
+ /* There is a chance that the MSB may have contained invalid data
+ * (overflow) at the time it was read. Therefore mask off the MSB.
+ * This avoids a race between driver read and firmware write of the
+ * word, the value we need is in the lower 8 bits anway.
+ */
+ return (s32)(b & 0xff);
+ }
+ }
+
+ return -1; /* this function has changed in WMM mods */
+} /* unifi_read_shared_count() */
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * unifi_writen
+ *
+ * Write multiple 8-bit values to the UniFi SDIO interface using CMD52
+ * This function interprets the address as a GenericPointer as
+ * defined in the UniFi Host Interface Protocol Specification.
+ *
+ * Arguments:
+ * card Pointer to card structure.
+ * unifi_addr UniFi shared-data-memory address to access.
+ * pdata Pointer to which to write data.
+ * len Number of bytes to write
+ *
+ * Returns:
+ * 0 on success, non-zero error code on error:
+ * CSR_WIFI_HIP_RESULT_NO_DEVICE card was ejected
+ * CSR_RESULT_FAILURE an SDIO error occurred
+ * CSR_WIFI_HIP_RESULT_INVALID_VALUE an odd length or length too big.
+ * ---------------------------------------------------------------------------
+ */
+CsrResult unifi_writen(card_t *card, u32 unifi_addr, void *pdata, u16 len)
+{
+ u32 sdio_addr;
+ CsrResult r;
+
+ r = set_page(card, unifi_addr, &sdio_addr);
+ if (r != CSR_RESULT_SUCCESS)
+ {
+ return r;
+ }
+
+ return unifi_write_directn(card, sdio_addr, pdata, len);
+} /* unifi_writen() */
+
+
+static CsrResult csr_sdio_block_rw(card_t *card, s16 funcnum,
+ u32 addr, u8 *pdata,
+ u16 count, s16 dir_is_write)
+{
+ CsrResult csrResult;
+
+ if (dir_is_write == UNIFI_SDIO_READ)
+ {
+#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_SDIO_TRACE)
+ unifi_debug_log_to_buf("r@%02X#%X=", addr, count);
+#endif
+#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_DATA_PLANE_PROFILE)
+ unifi_debug_log_to_buf("R");
+#endif
+ csrResult = CsrSdioRead(card->sdio_if, addr, pdata, count);
+#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_DATA_PLANE_PROFILE)
+ unifi_debug_log_to_buf("<");
+#endif
+ }
+ else
+ {
+#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_SDIO_TRACE)
+ unifi_debug_log_to_buf("w@%02X#%X=", addr, count);
+ unifi_debug_hex_to_buf(pdata, count > CSR_WIFI_HIP_SDIO_TRACE_DATA_LENGTH?CSR_WIFI_HIP_SDIO_TRACE_DATA_LENGTH : count);
+#endif
+#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_DATA_PLANE_PROFILE)
+ unifi_debug_log_to_buf("W");
+#endif
+ csrResult = CsrSdioWrite(card->sdio_if, addr, pdata, count);
+#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_DATA_PLANE_PROFILE)
+ unifi_debug_log_to_buf(">");
+#endif
+ }
+#ifdef CSR_WIFI_HIP_DATA_PLANE_PROFILE
+ card->cmd_prof.cmd53_count++;
+#endif
+#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_SDIO_TRACE)
+ if (csrResult != CSR_RESULT_SUCCESS)
+ {
+ unifi_debug_log_to_buf("error=%X", csrResult);
+ }
+ else if (dir_is_write == UNIFI_SDIO_READ)
+ {
+ unifi_debug_hex_to_buf(pdata, count > CSR_WIFI_HIP_SDIO_TRACE_DATA_LENGTH?CSR_WIFI_HIP_SDIO_TRACE_DATA_LENGTH : count);
+ }
+ unifi_debug_string_to_buf("\n");
+#endif
+ return csrResult; /* CSR SDIO (not HIP) error code */
+}
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * unifi_bulk_rw
+ *
+ * Transfer bulk data to or from the UniFi SDIO interface.
+ * This function is used to read or write signals and bulk data.
+ *
+ * Arguments:
+ * card Pointer to card structure.
+ * handle Value to put in the Register Address field of the CMD53 req.
+ * data Pointer to data to write.
+ * direction One of UNIFI_SDIO_READ or UNIFI_SDIO_WRITE
+ *
+ * Returns:
+ * CSR_RESULT_SUCCESS on success, non-zero error code on error:
+ * CSR_WIFI_HIP_RESULT_NO_DEVICE card was ejected
+ * CSR_RESULT_FAILURE an SDIO error occurred
+ *
+ * Notes:
+ * This function uses SDIO CMD53, which is the block transfer mode.
+ * ---------------------------------------------------------------------------
+ */
+CsrResult unifi_bulk_rw(card_t *card, u32 handle, void *pdata,
+ u32 len, s16 direction)
+{
+#define CMD53_RETRIES 3
+ /*
+ * Ideally instead of sleeping, we want to busy wait.
+ * Currently there is no framework API to do this. When it becomes available,
+ * we can use it to busy wait using usecs
+ */
+#define REWIND_RETRIES 15 /* when REWIND_DELAY==1msec, or 250 when REWIND_DELAY==50usecs */
+#define REWIND_POLLING_RETRIES 5
+#define REWIND_DELAY 1 /* msec or 50usecs */
+ CsrResult csrResult; /* SDIO error code */
+ CsrResult r = CSR_RESULT_SUCCESS; /* HIP error code */
+ s16 retries = CMD53_RETRIES;
+ s16 stat_retries;
+ u8 stat;
+ s16 dump_read;
+#ifdef UNIFI_DEBUG
+ u8 *pdata_lsb = ((u8 *)&pdata) + card->lsb;
+#endif
+#ifdef CSR_WIFI_MAKE_FAKE_CMD53_ERRORS
+ static s16 fake_error;
+#endif
+
+ dump_read = 0;
+#ifdef UNIFI_DEBUG
+ if (*pdata_lsb & 1)
+ {
+ unifi_notice(card->ospriv, "CD53 request on a unaligned buffer (addr: 0x%X) dir %s-Host\n",
+ pdata, (direction == UNIFI_SDIO_READ)?"To" : "From");
+ if (direction == UNIFI_SDIO_WRITE)
+ {
+ dump(pdata, (u16)len);
+ }
+ else
+ {
+ dump_read = 1;
+ }
+ }
+#endif
+
+ /* Defensive checks */
+ if (!pdata)
+ {
+ unifi_error(card->ospriv, "Null pdata for unifi_bulk_rw() len: %d\n", len);
+ return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
+ }
+ if ((len & 1) || (len > 0xffff))
+ {
+ unifi_error(card->ospriv, "Impossible CMD53 length requested: %d\n", len);
+ return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
+ }
+
+ while (1)
+ {
+ csrResult = csr_sdio_block_rw(card, card->function, handle,
+ (u8 *)pdata, (u16)len,
+ direction);
+ if (csrResult == CSR_SDIO_RESULT_NO_DEVICE)
+ {
+ return CSR_WIFI_HIP_RESULT_NO_DEVICE;
+ }
+#ifdef CSR_WIFI_MAKE_FAKE_CMD53_ERRORS
+ if (++fake_error > 100)
+ {
+ fake_error = 90;
+ unifi_warning(card->ospriv, "Faking a CMD53 error,\n");
+ if (csrResult == CSR_RESULT_SUCCESS)
+ {
+ csrResult = CSR_RESULT_FAILURE;
+ }
+ }
+#endif
+ if (csrResult == CSR_RESULT_SUCCESS)
+ {
+ if (dump_read)
+ {
+ dump(pdata, (u16)len);
+ }
+ break;
+ }
+
+ /*
+ * At this point the SDIO driver should have written the I/O Abort
+ * register to notify UniFi that the command has failed.
+ * UniFi-1 and UniFi-2 (not UF6xxx) use the same register to store the
+ * Deep Sleep State. This means we have to restore the Deep Sleep
+ * State (AWAKE in any case since we can not perform a CD53 in any other
+ * state) by rewriting the I/O Abort register to its previous value.
+ */
+ if (card->chip_id <= SDIO_CARD_ID_UNIFI_2)
+ {
+ (void)unifi_set_host_state(card, UNIFI_HOST_STATE_AWAKE);
+ }
+
+ /* If csr_sdio_block_rw() failed in a non-retryable way, or retries exhausted
+ * then stop retrying
+ */
+ if (!retryable_sdio_error(csrResult))
+ {
+ unifi_error(card->ospriv, "Fatal error in a CMD53 transfer\n");
+ break;
+ }
+
+ /*
+ * These happen from time to time, try again
+ */
+ if (--retries == 0)
+ {
+ break;
+ }
+
+ unifi_trace(card->ospriv, UDBG4,
+ "Error in a CMD53 transfer, retrying (h:%d,l:%u)...\n",
+ (s16)handle & 0xff, len);
+
+ /* The transfer failed, rewind and try again */
+ r = unifi_write_8_or_16(card, card->sdio_ctrl_addr + 8,
+ (u8)(handle & 0xff));
+ if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
+ {
+ return r;
+ }
+ if (r != CSR_RESULT_SUCCESS)
+ {
+ /*
+ * If we can't even do CMD52 (register read/write) then
+ * stop here.
+ */
+ unifi_error(card->ospriv, "Failed to write REWIND cmd\n");
+ return r;
+ }
+
+ /* Signal the UniFi to look for the rewind request. */
+ r = CardGenInt(card);
+ if (r != CSR_RESULT_SUCCESS)
+ {
+ return r;
+ }
+
+ /* Wait for UniFi to acknowledge the rewind */
+ stat_retries = REWIND_RETRIES;
+ while (1)
+ {
+ r = unifi_read_8_or_16(card, card->sdio_ctrl_addr + 8, &stat);
+ if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
+ {
+ return r;
+ }
+ if (r != CSR_RESULT_SUCCESS)
+ {
+ unifi_error(card->ospriv, "Failed to read REWIND status\n");
+ return CSR_RESULT_FAILURE;
+ }
+
+ if (stat == 0)
+ {
+ break;
+ }
+ if (--stat_retries == 0)
+ {
+ unifi_error(card->ospriv, "Timeout waiting for REWIND ready\n");
+ return CSR_RESULT_FAILURE;
+ }
+
+ /* Poll for the ack a few times */
+ if (stat_retries < REWIND_RETRIES - REWIND_POLLING_RETRIES)
+ {
+ CsrThreadSleep(REWIND_DELAY);
+ }
+ }
+ }
+
+ /* The call to csr_sdio_block_rw() still failed after retrying */
+ if (csrResult != CSR_RESULT_SUCCESS)
+ {
+ unifi_error(card->ospriv, "Block %s failed after %d retries\n",
+ (direction == UNIFI_SDIO_READ)?"read" : "write",
+ CMD53_RETRIES - retries);
+ /* Report any SDIO error as a general i/o error */
+ return CSR_RESULT_FAILURE;
+ }
+
+ /* Collect some stats */
+ if (direction == UNIFI_SDIO_READ)
+ {
+ card->sdio_bytes_read += len;
+ }
+ else
+ {
+ card->sdio_bytes_written += len;
+ }
+
+ return CSR_RESULT_SUCCESS;
+} /* unifi_bulk_rw() */
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * unifi_bulk_rw_noretry
+ *
+ * Transfer bulk data to or from the UniFi SDIO interface.
+ * This function is used to read or write signals and bulk data.
+ *
+ * Arguments:
+ * card Pointer to card structure.
+ * handle Value to put in the Register Address field of
+ * the CMD53 req.
+ * data Pointer to data to write.
+ * direction One of UNIFI_SDIO_READ or UNIFI_SDIO_WRITE
+ *
+ * Returns:
+ * 0 on success, non-zero error code on error:
+ * CSR_WIFI_HIP_RESULT_NO_DEVICE card was ejected
+ * CSR_RESULT_FAILURE an SDIO error occurred
+ *
+ * Notes:
+ * This function uses SDIO CMD53, which is the block transfer mode.
+ * ---------------------------------------------------------------------------
+ */
+CsrResult unifi_bulk_rw_noretry(card_t *card, u32 handle, void *pdata,
+ u32 len, s16 direction)
+{
+ CsrResult csrResult;
+
+ csrResult = csr_sdio_block_rw(card, card->function, handle,
+ (u8 *)pdata, (u16)len, direction);
+ if (csrResult != CSR_RESULT_SUCCESS)
+ {
+ unifi_error(card->ospriv, "Block %s failed\n",
+ (direction == UNIFI_SDIO_READ)?"read" : "write");
+ return csrResult;
+ }
+
+ return CSR_RESULT_SUCCESS;
+} /* unifi_bulk_rw_noretry() */
+
+
diff --git a/drivers/staging/csr/csr_wifi_hip_chiphelper.c b/drivers/staging/csr/csr_wifi_hip_chiphelper.c
new file mode 100644
index 000000000000..5cf5b8a5a1e1
--- /dev/null
+++ b/drivers/staging/csr/csr_wifi_hip_chiphelper.c
@@ -0,0 +1,793 @@
+/*****************************************************************************
+
+ (c) Cambridge Silicon Radio Limited 2011
+ All rights reserved and confidential information of CSR
+
+ Refer to LICENSE.txt included with this source for details
+ on the license terms.
+
+*****************************************************************************/
+
+#include "csr_macro.h"
+#include "csr_wifi_hip_chiphelper_private.h"
+
+#ifndef nelem
+#define nelem(a) (sizeof(a) / sizeof(a[0]))
+#endif
+
+#define counted(foo) { nelem(foo), foo }
+#define null_counted() { 0, NULL }
+
+/* The init values are a set of register writes that we must
+ perform when we first connect to the chip to get it working.
+ They swicth on the correct clocks and possibly set the host
+ interface as a wkaeup source. They should not be used if
+ proper HIP opperation is required, but are useful before we
+ do a code download. */
+static const struct chip_helper_init_values init_vals_v1[] = {
+ { 0xFDBB, 0xFFFF },
+ { 0xFDB6, 0x03FF },
+ { 0xFDB1, 0x01E3 },
+ { 0xFDB3, 0x0FFF },
+ { 0xFEE3, 0x08F0 },
+ { 0xFEE7, 0x3C3F },
+ { 0xFEE6, 0x0050 },
+ { 0xFDBA, 0x0000 }
+};
+
+static const struct chip_helper_init_values init_vals_v2[] = {
+ { 0xFDB6, 0x0FFF },
+ { 0xF023, 0x3F3F },
+ { 0xFDB1, 0x01E3 },
+ { 0xFDB3, 0x0FFF },
+ { 0xF003, 0x08F0 },
+ { 0xF007, 0x3C3F },
+ { 0xF006, 0x0050 }
+};
+
+
+static const struct chip_helper_init_values init_vals_v22_v23[] = {
+ { 0xF81C, 0x00FF },
+ /*{ 0x????, 0x???? }, */
+ { 0xF80C, 0x1FFF },
+ { 0xFA25, 0x001F },
+ { 0xF804, 0x00FF },
+ { 0xF802, 0x0FFF },
+ /*{ 0x????, 0x???? },
+ { 0x????, 0x???? },
+ { 0x????, 0x???? }*/
+};
+
+static const u16 reset_program_a_v1_or_v2[] = {
+ 0x0000
+};
+static const u16 reset_program_b_v1_or_v2[] = {
+ 0x0010, 0xFE00, 0xA021, 0xFF00, 0x8111, 0x0009, 0x0CA4, 0x0114,
+ 0x0280, 0x04F8, 0xFE00, 0x6F25, 0x06E0, 0x0010, 0xFC00, 0x0121,
+ 0xFC00, 0x0225, 0xFE00, 0x7125, 0xFE00, 0x6D11, 0x03F0, 0xFE00,
+ 0x6E25, 0x0008, 0x00E0
+};
+
+static const struct chip_helper_reset_values reset_program_v1_or_v2[] =
+{
+ {
+ MAKE_GP(REGISTERS, 0x000C),
+ nelem(reset_program_a_v1_or_v2),
+ reset_program_a_v1_or_v2
+ },
+ {
+ MAKE_GP(MAC_PMEM, 0x000000),
+ nelem(reset_program_b_v1_or_v2),
+ reset_program_b_v1_or_v2
+ }
+};
+
+static const struct chip_map_address_t unifi_map_address_v1_v2[] =
+{
+ { 0xFE9F, 0xFE7B }, /* PM1_BANK_SELECT */
+ { 0xFE9E, 0xFE78 }, /* PM2_BANK_SELECT */
+ { 0xFE9D, 0xFE7E }, /* SHARED_DMEM_PAGE */
+ { 0xFE91, 0xFE90 }, /* PROC_SELECT */
+ { 0xFE8D, 0xFE8C }, /* STOP_STATUS */
+};
+
+static const struct chip_map_address_t unifi_map_address_v22_v23[] =
+{
+ { 0xF8F9, 0xF8AC }, /* GW1_CONFIG */
+ { 0xF8FA, 0xF8AD }, /* GW2_CONFIG */
+ { 0xF8FB, 0xF8AE }, /* GW3_CONFIG */
+ { 0xF830, 0xF81E }, /* PROC_SELECT */
+ { 0xF831, 0xF81F }, /* STOP_STATUS */
+ { 0xF8FC, 0xF8AF }, /* IO_LOG_ADDRESS */
+};
+
+static const struct chip_device_regs_t unifi_device_regs_null =
+{
+ 0xFE81, /* GBL_CHIP_VERSION */
+ 0x0000, /* GBL_MISC_ENABLES */
+ 0x0000, /* DBG_EMU_CMD */
+ {
+ 0x0000, /* HOST.DBG_PROC_SELECT */
+ 0x0000, /* HOST.DBG_STOP_STATUS */
+ 0x0000, /* HOST.WINDOW1_PAGE */
+ 0x0000, /* HOST.WINDOW2_PAGE */
+ 0x0000, /* HOST.WINDOW3_PAGE */
+ 0x0000 /* HOST.IO_LOG_ADDR */
+ },
+ {
+ 0x0000, /* SPI.DBG_PROC_SELECT */
+ 0x0000, /* SPI.DBG_STOP_STATUS */
+ 0x0000, /* SPI.WINDOW1_PAGE */
+ 0x0000, /* SPI.WINDOW2_PAGE */
+ 0x0000, /* SPI.WINDOW3_PAGE */
+ 0x0000 /* SPI.IO_LOG_ADDR */
+ },
+ 0x0000, /* DBG_RESET */
+ 0x0000, /* > DBG_RESET_VALUE */
+ 0x0000, /* DBG_RESET_WARN */
+ 0x0000, /* DBG_RESET_WARN_VALUE */
+ 0x0000, /* DBG_RESET_RESULT */
+ 0xFFE9, /* XAP_PCH */
+ 0xFFEA, /* XAP_PCL */
+ 0x0000, /* PROC_PC_SNOOP */
+ 0x0000, /* WATCHDOG_DISABLE */
+ 0x0000, /* MAILBOX0 */
+ 0x0000, /* MAILBOX1 */
+ 0x0000, /* MAILBOX2 */
+ 0x0000, /* MAILBOX3 */
+ 0x0000, /* SDIO_HOST_INT */
+ 0x0000, /* SHARED_IO_INTERRUPT */
+ 0x0000, /* SDIO HIP HANDSHAKE */
+ 0x0000 /* COEX_STATUS */
+};
+
+/* UF105x */
+static const struct chip_device_regs_t unifi_device_regs_v1 =
+{
+ 0xFE81, /* GBL_CHIP_VERSION */
+ 0xFE87, /* GBL_MISC_ENABLES */
+ 0xFE9C, /* DBG_EMU_CMD */
+ {
+ 0xFE90, /* HOST.DBG_PROC_SELECT */
+ 0xFE8C, /* HOST.DBG_STOP_STATUS */
+ 0xFE7B, /* HOST.WINDOW1_PAGE */
+ 0xFE78, /* HOST.WINDOW2_PAGE */
+ 0xFE7E, /* HOST.WINDOW3_PAGE */
+ 0x0000 /* HOST.IO_LOG_ADDR */
+ },
+ {
+ 0xFE91, /* SPI.DBG_PROC_SELECT */
+ 0xFE8D, /* SPI.DBG_STOP_STATUS */
+ 0xFE9F, /* SPI.WINDOW1_PAGE */
+ 0xFE9E, /* SPI.WINDOW2_PAGE */
+ 0xFE9D, /* SPI.WINDOW3_PAGE */
+ 0x0000 /* SPI.IO_LOG_ADDR */
+ },
+ 0xFE92, /* DBG_RESET */
+ 0x0001, /* > DBG_RESET_VALUE */
+ 0xFDA0, /* DBG_RESET_WARN (HOST_SELECT) */
+ 0x0000, /* DBG_RESET_WARN_VALUE */
+ 0xFE92, /* DBG_RESET_RESULT */
+ 0xFFE9, /* XAP_PCH */
+ 0xFFEA, /* XAP_PCL */
+ 0x0051, /* PROC_PC_SNOOP */
+ 0xFE70, /* WATCHDOG_DISABLE */
+ 0xFE6B, /* MAILBOX0 */
+ 0xFE6A, /* MAILBOX1 */
+ 0xFE69, /* MAILBOX2 */
+ 0xFE68, /* MAILBOX3 */
+ 0xFE67, /* SDIO_HOST_INT */
+ 0xFE65, /* SHARED_IO_INTERRUPT */
+ 0xFDE9, /* SDIO HIP HANDSHAKE */
+ 0x0000 /* COEX_STATUS */
+};
+
+/* UF2... */
+static const struct chip_device_regs_t unifi_device_regs_v2 =
+{
+ 0xFE81, /* GBL_CHIP_VERSION */
+ 0xFE87, /* GBL_MISC_ENABLES */
+ 0xFE9C, /* DBG_EMU_CMD */
+ {
+ 0xFE90, /* HOST.DBG_PROC_SELECT */
+ 0xFE8C, /* HOST.DBG_STOP_STATUS */
+ 0xFE7B, /* HOST.WINDOW1_PAGE */
+ 0xFE78, /* HOST.WINDOW2_PAGE */
+ 0xFE7E, /* HOST.WINDOW3_PAGE */
+ 0x0000 /* HOST.IO_LOG_ADDR */
+ },
+ {
+ 0xFE91, /* SPI.DBG_PROC_SELECT */
+ 0xFE8D, /* SPI.DBG_STOP_STATUS */
+ 0xFE9F, /* SPI.WINDOW1_PAGE */
+ 0xFE9E, /* SPI.WINDOW2_PAGE */
+ 0xFE9D, /* SPI.WINDOW3_PAGE */
+ 0x0000 /* SPI.IO_LOG_ADDR */
+ },
+ 0xFE92, /* DBG_RESET */
+ 0x0000, /* > DBG_RESET_VALUE */
+ 0xFDE9, /* DBG_RESET_WARN (TEST_FLASH_DATA - SHARED_MAILBOX2B) */
+ 0xFFFF, /* DBG_RESET_WARN_VALUE */
+ 0xFDE9, /* DBG_RESET_RESULT (TEST_FLASH_DATA) */
+ 0xFFE9, /* XAP_PCH */
+ 0xFFEA, /* XAP_PCL */
+ 0x0051, /* PROC_PC_SNOOP */
+ 0xFE70, /* WATCHDOG_DISABLE */
+ 0xFE6B, /* MAILBOX0 */
+ 0xFE6A, /* MAILBOX1 */
+ 0xFE69, /* MAILBOX2 */
+ 0xFE68, /* MAILBOX3 */
+ 0xFE67, /* SDIO_HOST_INT */
+ 0xFE65, /* SHARED_IO_INTERRUPT */
+ 0xFE69, /* SDIO HIP HANDSHAKE */
+ 0x0000 /* COEX_STATUS */
+};
+
+/* UF60xx */
+static const struct chip_device_regs_t unifi_device_regs_v22_v23 =
+{
+ 0xFE81, /* GBL_CHIP_VERSION */
+ 0xF84F, /* GBL_MISC_ENABLES */
+ 0xF81D, /* DBG_EMU_CMD */
+ {
+ 0xF81E, /* HOST.DBG_PROC_SELECT */
+ 0xF81F, /* HOST.DBG_STOP_STATUS */
+ 0xF8AC, /* HOST.WINDOW1_PAGE */
+ 0xF8AD, /* HOST.WINDOW2_PAGE */
+ 0xF8AE, /* HOST.WINDOW3_PAGE */
+ 0xF8AF /* HOST.IO_LOG_ADDR */
+ },
+ {
+ 0xF830, /* SPI.DBG_PROC_SELECT */
+ 0xF831, /* SPI.DBG_STOP_STATUS */
+ 0xF8F9, /* SPI.WINDOW1_PAGE */
+ 0xF8FA, /* SPI.WINDOW2_PAGE */
+ 0xF8FB, /* SPI.WINDOW3_PAGE */
+ 0xF8FC /* SPI.IO_LOG_ADDR */
+ },
+ 0xF82F, /* DBG_RESET */
+ 0x0001, /* > DBG_RESET_VALUE */
+ 0x0000, /* DBG_RESET_WARN */
+ 0x0000, /* DBG_RESET_WARN_VALUE */
+ 0xF82F, /* DBG_RESET_RESULT */
+ 0xFFE9, /* XAP_PCH */
+ 0xFFEA, /* XAP_PCL */
+ 0x001B, /* PROC_PC_SNOOP */
+ 0x0055, /* WATCHDOG_DISABLE */
+ 0xF84B, /* MAILBOX0 */
+ 0xF84C, /* MAILBOX1 */
+ 0xF84D, /* MAILBOX2 */
+ 0xF84E, /* MAILBOX3 */
+ 0xF92F, /* SDIO_HOST_INT */
+ 0xF92B, /* SDIO_FROMHOST_SCRTACH0 / SHARED_IO_INTERRUPT */
+ 0xF84D, /* SDIO HIP HANDSHAKE (MAILBOX2) */
+ 0xF9FB /* COEX_STATUS */
+};
+
+/* Program memory window on UF105x. */
+static const struct window_shift_info_t prog_window_array_unifi_v1_v2[CHIP_HELPER_WT_COUNT] =
+{
+ { TRUE, 11, 0x0200 }, /* CODE RAM */
+ { TRUE, 11, 0x0000 }, /* FLASH */
+ { TRUE, 11, 0x0400 }, /* External SRAM */
+ { FALSE, 0, 0 }, /* ROM */
+ { FALSE, 0, 0 } /* SHARED */
+};
+
+/* Shared memory window on UF105x. */
+static const struct window_shift_info_t shared_window_array_unifi_v1_v2[CHIP_HELPER_WT_COUNT] =
+{
+ { FALSE, 0, 0 }, /* CODE RAM */
+ { FALSE, 0, 0 }, /* FLASH */
+ { FALSE, 0, 0 }, /* External SRAM */
+ { FALSE, 0, 0 }, /* ROM */
+ { TRUE, 11, 0x0000 } /* SHARED */
+};
+
+/* One of the Generic Windows on UF60xx and later. */
+static const struct window_shift_info_t generic_window_array_unifi_v22_v23[CHIP_HELPER_WT_COUNT] =
+{
+ { TRUE, 11, 0x3800 }, /* CODE RAM */
+ { FALSE, 0, 0 }, /* FLASH */
+ { FALSE, 0, 0 }, /* External SRAM */
+ { TRUE, 11, 0x2000 }, /* ROM */
+ { TRUE, 11, 0x0000 } /* SHARED */
+};
+
+/* The three windows on UF105x. */
+static const struct window_info_t prog1_window_unifi_v1_v2 = { 0x0000, 0x2000, 0x0080, prog_window_array_unifi_v1_v2 };
+static const struct window_info_t prog2_window_unifi_v1_v2 = { 0x2000, 0x2000, 0x0000, prog_window_array_unifi_v1_v2 };
+static const struct window_info_t shared_window_unifi_v1_v2 = { 0x4000, 0x2000, 0x0000, shared_window_array_unifi_v1_v2 };
+
+/* The three windows on UF60xx and later. */
+static const struct window_info_t generic1_window_unifi_v22_v23 = { 0x0000, 0x2000, 0x0080, generic_window_array_unifi_v22_v23 };
+static const struct window_info_t generic2_window_unifi_v22_v23 = { 0x2000, 0x2000, 0x0000, generic_window_array_unifi_v22_v23 };
+static const struct window_info_t generic3_window_unifi_v22_v23 = { 0x4000, 0x2000, 0x0000, generic_window_array_unifi_v22_v23 };
+
+static const struct chip_device_desc_t chip_device_desc_null =
+{
+ { FALSE, 0x0000, 0x0000, 0x00 },
+ "",
+ "",
+ null_counted(), /* init */
+ null_counted(), /* reset_prog */
+ &unifi_device_regs_null, /* regs */
+ {
+ FALSE, /* has_flash */
+ FALSE, /* has_ext_sram */
+ FALSE, /* has_rom */
+ FALSE, /* has_bt */
+ FALSE, /* has_wlan */
+ },
+ null_counted(),
+ /* prog_offset */
+ {
+ 0x00000000,
+ 0x00000000,
+ 0x00000000,
+ 0x00000000
+ },
+ /* data_offset */
+ {
+ 0x0000 /* ram */
+ },
+ /* windows */
+ {
+ NULL,
+ NULL,
+ NULL
+ }
+};
+
+static const struct chip_device_desc_t unifi_device_desc_v1 =
+{
+ { FALSE, 0xf0ff, 0x1001, 0x01 }, /* UF105x R01 */
+ "UF105x",
+ "UniFi-1",
+ counted(init_vals_v1), /* init */
+ counted(reset_program_v1_or_v2), /* reset_prog */
+ &unifi_device_regs_v1, /* regs */
+ {
+ TRUE, /* has_flash */
+ TRUE, /* has_ext_sram */
+ FALSE, /* has_rom */
+ FALSE, /* has_bt */
+ TRUE, /* has_wlan */
+ },
+ counted(unifi_map_address_v1_v2), /* map */
+ /* prog_offset */
+ {
+ 0x00100000, /* ram */
+ 0x00000000, /* rom (invalid) */
+ 0x00000000, /* flash */
+ 0x00200000, /* ext_ram */
+ },
+ /* data_offset */
+ {
+ 0x8000 /* ram */
+ },
+ /* windows */
+ {
+ &prog1_window_unifi_v1_v2,
+ &prog2_window_unifi_v1_v2,
+ &shared_window_unifi_v1_v2
+ }
+};
+
+static const struct chip_device_desc_t unifi_device_desc_v2 =
+{
+ { FALSE, 0xf0ff, 0x2001, 0x02 }, /* UF2... R02 */
+ "UF2...",
+ "UniFi-2",
+ counted(init_vals_v2), /* init */
+ counted(reset_program_v1_or_v2), /* reset_prog */
+ &unifi_device_regs_v2, /* regs */
+ {
+ TRUE, /* has_flash */
+ TRUE, /* has_ext_sram */
+ FALSE, /* has_rom */
+ FALSE, /* has_bt */
+ TRUE, /* has_wlan */
+ },
+ counted(unifi_map_address_v1_v2), /* map */
+ /* prog_offset */
+ {
+ 0x00100000, /* ram */
+ 0x00000000, /* rom (invalid) */
+ 0x00000000, /* flash */
+ 0x00200000, /* ext_ram */
+ },
+ /* data_offset */
+ {
+ 0x8000 /* ram */
+ },
+ /* windows */
+ {
+ &prog1_window_unifi_v1_v2,
+ &prog2_window_unifi_v1_v2,
+ &shared_window_unifi_v1_v2
+ }
+};
+
+static const struct chip_device_desc_t unifi_device_desc_v3 =
+{
+ { FALSE, 0xf0ff, 0x3001, 0x02 }, /* UF2... R03 */
+ "UF2...",
+ "UniFi-3",
+ counted(init_vals_v2), /* init */
+ counted(reset_program_v1_or_v2), /* reset_prog */
+ &unifi_device_regs_v2, /* regs */
+ {
+ TRUE, /* has_flash */
+ TRUE, /* has_ext_sram */
+ FALSE, /* has_rom */
+ FALSE, /* has_bt */
+ TRUE, /* has_wlan */
+ },
+ counted(unifi_map_address_v1_v2), /* map */
+ /* prog_offset */
+ {
+ 0x00100000, /* ram */
+ 0x00000000, /* rom (invalid) */
+ 0x00000000, /* flash */
+ 0x00200000, /* ext_ram */
+ },
+ /* data_offset */
+ {
+ 0x8000 /* ram */
+ },
+ /* windows */
+ {
+ &prog1_window_unifi_v1_v2,
+ &prog2_window_unifi_v1_v2,
+ &shared_window_unifi_v1_v2
+ }
+};
+
+static const struct chip_device_desc_t unifi_device_desc_v22 =
+{
+ { FALSE, 0x00ff, 0x0022, 0x07 }, /* UF60xx */
+ "UF60xx",
+ "UniFi-4",
+ counted(init_vals_v22_v23), /* init */
+ null_counted(), /* reset_prog */
+ &unifi_device_regs_v22_v23, /* regs */
+ {
+ FALSE, /* has_flash */
+ FALSE, /* has_ext_sram */
+ TRUE, /* has_rom */
+ FALSE, /* has_bt */
+ TRUE, /* has_wlan */
+ },
+ counted(unifi_map_address_v22_v23), /* map */
+ /* prog_offset */
+ {
+ 0x00C00000, /* ram */
+ 0x00000000, /* rom */
+ 0x00000000, /* flash (invalid) */
+ 0x00000000, /* ext_ram (invalid) */
+ },
+ /* data_offset */
+ {
+ 0x8000 /* ram */
+ },
+ /* windows */
+ {
+ &generic1_window_unifi_v22_v23,
+ &generic2_window_unifi_v22_v23,
+ &generic3_window_unifi_v22_v23
+ }
+};
+
+static const struct chip_device_desc_t unifi_device_desc_v23 =
+{
+ { FALSE, 0x00ff, 0x0023, 0x08 }, /* UF.... */
+ "UF....",
+ "UF.... (5)",
+ counted(init_vals_v22_v23), /* init */
+ null_counted(), /* reset_prog */
+ &unifi_device_regs_v22_v23, /* regs */
+ {
+ FALSE, /* has_flash */
+ FALSE, /* has_ext_sram */
+ TRUE, /* has_rom */
+ TRUE, /* has_bt */
+ TRUE, /* has_wlan */
+ },
+ counted(unifi_map_address_v22_v23),
+ /* prog_offset */
+ {
+ 0x00C00000, /* ram */
+ 0x00000000, /* rom */
+ 0x00000000, /* flash (invalid) */
+ 0x00000000, /* ext_sram (invalid) */
+ },
+ /* data_offset */
+ {
+ 0x8000 /* ram */
+ },
+ /* windows */
+ {
+ &generic1_window_unifi_v22_v23,
+ &generic2_window_unifi_v22_v23,
+ &generic3_window_unifi_v22_v23
+ }
+};
+
+static const struct chip_device_desc_t hyd_wlan_subsys_desc_v1 =
+{
+ { FALSE, 0x00ff, 0x0044, 0x00 }, /* UF.... */
+ "HYD...",
+ "HYD... ",
+ counted(init_vals_v22_v23), /* init */
+ null_counted(), /* reset_prog */
+ &unifi_device_regs_v22_v23, /* regs */
+ {
+ FALSE, /* has_flash */
+ FALSE, /* has_ext_sram */
+ TRUE, /* has_rom */
+ FALSE, /* has_bt */
+ TRUE, /* has_wlan */
+ },
+ counted(unifi_map_address_v22_v23),
+ /* prog_offset */
+ {
+ 0x00C00000, /* ram */
+ 0x00000000, /* rom */
+ 0x00000000, /* flash (invalid) */
+ 0x00000000, /* ext_sram (invalid) */
+ },
+ /* data_offset */
+ {
+ 0x8000 /* ram */
+ },
+ /* windows */
+ {
+ &generic1_window_unifi_v22_v23,
+ &generic2_window_unifi_v22_v23,
+ &generic3_window_unifi_v22_v23
+ }
+};
+
+
+/* This is the list of all chips that we know about. I'm
+ assuming that the order here will be important - we
+ might have multiple entries witrh the same SDIO id for
+ instance. The first one in this list will be the one
+ that is returned if a search is done on only that id.
+ The client will then have to call GetVersionXXX again
+ but with more detailed info.
+
+ I don't know if we need to signal this up to the client
+ in some way?
+
+ (We get the SDIO id before we know anything else about
+ the chip. We might not be able to read any of the other
+ registers at first, but we still need to know about the
+ chip). */
+static const struct chip_device_desc_t *chip_ver_to_desc[] =
+{
+ &unifi_device_desc_v1, /* UF105x R01 */
+ &unifi_device_desc_v2, /* UF2... R02 */
+ &unifi_device_desc_v3, /* UF2... R03 */
+ &unifi_device_desc_v22, /* UF60xx */
+ &unifi_device_desc_v23, /* UF.... */
+ &hyd_wlan_subsys_desc_v1
+};
+
+ChipDescript* ChipHelper_GetVersionSdio(u8 sdio_ver)
+{
+ u32 i;
+
+ for (i = 0; i < nelem(chip_ver_to_desc); i++)
+ {
+ if (chip_ver_to_desc[i]->chip_version.sdio == sdio_ver)
+ {
+ return chip_ver_to_desc[i];
+ }
+ }
+
+ return &chip_device_desc_null;
+}
+
+
+ChipDescript* ChipHelper_GetVersionAny(u16 from_FF9A, u16 from_FE81)
+{
+ u32 i;
+
+ if ((from_FF9A & 0xFF00) != 0)
+ {
+ for (i = 0; i < nelem(chip_ver_to_desc); i++)
+ {
+ if (chip_ver_to_desc[i]->chip_version.pre_bc7 &&
+ ((from_FF9A & chip_ver_to_desc[i]->chip_version.mask) ==
+ chip_ver_to_desc[i]->chip_version.result))
+ {
+ return chip_ver_to_desc[i];
+ }
+ }
+ }
+ else
+ {
+ for (i = 0; i < nelem(chip_ver_to_desc); i++)
+ {
+ if (!chip_ver_to_desc[i]->chip_version.pre_bc7 &&
+ ((from_FE81 & chip_ver_to_desc[i]->chip_version.mask) ==
+ chip_ver_to_desc[i]->chip_version.result))
+ {
+ return chip_ver_to_desc[i];
+ }
+ }
+ }
+
+ return &chip_device_desc_null;
+}
+
+
+ChipDescript* ChipHelper_GetVersionUniFi(u16 ver)
+{
+ return ChipHelper_GetVersionAny(0x0000, ver);
+}
+
+
+ChipDescript *ChipHelper_Null(void)
+{
+ return &chip_device_desc_null;
+}
+
+
+ChipDescript* ChipHelper_GetVersionBlueCore(enum chip_helper_bluecore_age bc_age, u16 version)
+{
+ if (bc_age == chip_helper_bluecore_pre_bc7)
+ {
+ return ChipHelper_GetVersionAny(version, 0x0000);
+ }
+ else
+ {
+ return ChipHelper_GetVersionAny(0x0000, version);
+ }
+}
+
+
+/* Expand the DEF0 functions into simple code to return the
+ correct thing. The DEF1 functions expand to nothing in
+ this X macro expansion. */
+#define CHIP_HELPER_DEF0_C_DEF(ret_type, name, info) \
+ ret_type ChipHelper_ ## name(ChipDescript * chip_help) \
+ { \
+ return chip_help->info; \
+ }
+#define CHIP_HELPER_DEF1_C_DEF(ret_type, name, type1, name1)
+
+CHIP_HELPER_LIST(C_DEF)
+
+/*
+ * Map register addresses between HOST and SPI access.
+ */
+u16 ChipHelper_MapAddress_SPI2HOST(ChipDescript *chip_help, u16 addr)
+{
+ u32 i;
+ for (i = 0; i < chip_help->map.len; i++)
+ {
+ if (chip_help->map.vals[i].spi == addr)
+ {
+ return chip_help->map.vals[i].host;
+ }
+ }
+ return addr;
+}
+
+
+u16 ChipHelper_MapAddress_HOST2SPI(ChipDescript *chip_help, u16 addr)
+{
+ u32 i;
+ for (i = 0; i < chip_help->map.len; i++)
+ {
+ if (chip_help->map.vals[i].host == addr)
+ {
+ return chip_help->map.vals[i].spi;
+ }
+ }
+ return addr;
+}
+
+
+/* The address returned by this function is the start of the
+ window in the address space, that is where we can start
+ accessing data from. If a section of the window at the
+ start is unusable because something else is cluttering up
+ the address map then that is taken into account and this
+ function returns that address justt past that. */
+u16 ChipHelper_WINDOW_ADDRESS(ChipDescript *chip_help,
+ enum chip_helper_window_index window)
+{
+ if (window < CHIP_HELPER_WINDOW_COUNT &&
+ chip_help->windows[window] != NULL)
+ {
+ return chip_help->windows[window]->address + chip_help->windows[window]->blocked;
+ }
+ return 0;
+}
+
+
+/* This returns the size of the window minus any blocked section */
+u16 ChipHelper_WINDOW_SIZE(ChipDescript *chip_help,
+ enum chip_helper_window_index window)
+{
+ if (window < CHIP_HELPER_WINDOW_COUNT &&
+ chip_help->windows[window] != NULL)
+ {
+ return chip_help->windows[window]->size - chip_help->windows[window]->blocked;
+ }
+ return 0;
+}
+
+
+/* Get the register writes we should do to make sure that
+ the chip is running with most clocks on. */
+u32 ChipHelper_ClockStartupSequence(ChipDescript *chip_help,
+ const struct chip_helper_init_values **val)
+{
+ *val = chip_help->init.vals;
+ return chip_help->init.len;
+}
+
+
+/* Get the set of values tat we should write to the chip to perform a reset. */
+u32 ChipHelper_HostResetSequence(ChipDescript *chip_help,
+ const struct chip_helper_reset_values **val)
+{
+ *val = chip_help->reset_prog.vals;
+ return chip_help->reset_prog.len;
+}
+
+
+/* Decode a windowed access to the chip. */
+s32 ChipHelper_DecodeWindow(ChipDescript *chip_help,
+ enum chip_helper_window_index window,
+ enum chip_helper_window_type type,
+ u32 offset,
+ u16 *page, u16 *addr, u32 *len)
+{
+ const struct window_info_t *win;
+ const struct window_shift_info_t *mode;
+ u16 of, pg;
+
+ if (window >= CHIP_HELPER_WINDOW_COUNT)
+ {
+ return FALSE;
+ }
+ if ((win = chip_help->windows[window]) == NULL)
+ {
+ return FALSE;
+ }
+ if (type >= CHIP_HELPER_WT_COUNT)
+ {
+ return FALSE;
+ }
+ if ((mode = &win->mode[type]) == NULL)
+ {
+ return FALSE;
+ }
+ if (!mode->allowed)
+ {
+ return FALSE;
+ }
+
+ pg = (u16)(offset >> mode->page_shift) + mode->page_offset;
+ of = (u16)(offset & ((1 << mode->page_shift) - 1));
+ /* If 'blocked' is zero this does nothing, else decrease
+ the page register and increase the offset until we aren't
+ in the blocked region of the window. */
+ while (of < win->blocked)
+ {
+ of += 1 << mode->page_shift;
+ pg--;
+ }
+ *page = pg;
+ *addr = win->address + of;
+ *len = win->size - of;
+ return TRUE;
+}
+
+
diff --git a/drivers/staging/csr/csr_wifi_hip_chiphelper.h b/drivers/staging/csr/csr_wifi_hip_chiphelper.h
new file mode 100644
index 000000000000..24737ae8a2de
--- /dev/null
+++ b/drivers/staging/csr/csr_wifi_hip_chiphelper.h
@@ -0,0 +1,471 @@
+/*****************************************************************************
+
+ (c) Cambridge Silicon Radio Limited 2011
+ All rights reserved and confidential information of CSR
+
+ Refer to LICENSE.txt included with this source for details
+ on the license terms.
+
+*****************************************************************************/
+
+#ifndef CSR_WIFI_HIP_CHIPHELPER_H__
+#define CSR_WIFI_HIP_CHIPHELPER_H__
+
+
+#include <linux/types.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* The age of the BlueCore chip. This is probably not useful, if
+ you know the age then you can probably work out the version directly. */
+enum chip_helper_bluecore_age
+{
+ chip_helper_bluecore_pre_bc7,
+ chip_helper_bluecore_bc7_or_later
+};
+
+/* We support up to three windowed regions at the moment.
+ Don't reorder these - they're used to index into an array. */
+enum chip_helper_window_index
+{
+ CHIP_HELPER_WINDOW_1 = 0,
+ CHIP_HELPER_WINDOW_2 = 1,
+ CHIP_HELPER_WINDOW_3 = 2,
+ CHIP_HELPER_WINDOW_COUNT = 3
+};
+
+/* These are the things that we can access through a window.
+ Don't reorder these - they're used to index into an array. */
+enum chip_helper_window_type
+{
+ CHIP_HELPER_WT_CODE_RAM = 0,
+ CHIP_HELPER_WT_FLASH = 1,
+ CHIP_HELPER_WT_EXT_SRAM = 2,
+ CHIP_HELPER_WT_ROM = 3,
+ CHIP_HELPER_WT_SHARED = 4,
+ CHIP_HELPER_WT_COUNT = 5
+};
+
+/* Commands to stop and start the XAP */
+enum chip_helper_dbg_emu_cmd_enum
+{
+ CHIP_HELPER_DBG_EMU_CMD_XAP_STEP_MASK = 0x0001,
+ CHIP_HELPER_DBG_EMU_CMD_XAP_RUN_B_MASK = 0x0002,
+ CHIP_HELPER_DBG_EMU_CMD_XAP_BRK_MASK = 0x0004,
+ CHIP_HELPER_DBG_EMU_CMD_XAP_WAKEUP_MASK = 0x0008
+};
+
+/* Bitmasks for Stop and sleep status: DBG_SPI_STOP_STATUS & DBG_HOST_STOP_STATUS */
+enum chip_helper_dbg_stop_status_enum
+{
+ CHIP_HELPER_DBG_STOP_STATUS_NONE_MASK = 0x0000,
+ CHIP_HELPER_DBG_STOP_STATUS_P0_MASK = 0x0001,
+ CHIP_HELPER_DBG_STOP_STATUS_P1_MASK = 0x0002,
+ CHIP_HELPER_DBG_STOP_STATUS_P2_MASK = 0x0004,
+ CHIP_HELPER_DBG_STOP_STATUS_SLEEP_STATUS_P0_MASK = 0x0008,
+ CHIP_HELPER_DBG_STOP_STATUS_SLEEP_STATUS_P1_MASK = 0x0010,
+ CHIP_HELPER_DBG_STOP_STATUS_SLEEP_STATUS_P2_MASK = 0x0020,
+ /* Legacy names/alias */
+ CHIP_HELPER_DBG_STOP_STATUS_MAC_MASK = 0x0001,
+ CHIP_HELPER_DBG_STOP_STATUS_PHY_MASK = 0x0002,
+ CHIP_HELPER_DBG_STOP_STATUS_BT_MASK = 0x0004,
+ CHIP_HELPER_DBG_STOP_STATUS_SLEEP_STATUS_MAC_MASK = 0x0008,
+ CHIP_HELPER_DBG_STOP_STATUS_SLEEP_STATUS_PHY_MASK = 0x0010,
+ CHIP_HELPER_DBG_STOP_STATUS_SLEEP_STATUS_BT_MASK = 0x0020
+};
+
+/* Codes to disable the watchdog */
+enum chip_helper_watchdog_disable_enum
+{
+ CHIP_HELPER_WATCHDOG_DISABLE_CODE1 = 0x6734,
+ CHIP_HELPER_WATCHDOG_DISABLE_CODE2 = 0xD6BF,
+ CHIP_HELPER_WATCHDOG_DISABLE_CODE3 = 0xC31E
+};
+
+/* Other bits have changed between versions */
+enum chip_helper_gbl_misc_enum
+{
+ CHIP_HELPER_GBL_MISC_SPI_STOP_OUT_EN_MASK = 0x0001,
+ CHIP_HELPER_GBL_MISC_MMU_INIT_DONE_MASK = 0x0004
+};
+
+/* Coex status register, contains interrupt status and reset pullup status.
+ * CHIP_HELPER_COEX_STATUS_RST_PULLS_MSB_MASK can be used to check
+ * for WAPI on R03 chips and later. */
+enum chip_helper_coex_status_mask_enum
+{
+ CHIP_HELPER_COEX_STATUS_RST_PULLS_LSB_MASK = 0x0001,
+ CHIP_HELPER_COEX_STATUS_RST_PULLS_MSB_MASK = 0x0008,
+ CHIP_HELPER_COEX_STATUS_WL_FEC_PINS_LSB_MASK = 0x0010,
+ CHIP_HELPER_COEX_STATUS_WL_FEC_PINS_MSB_MASK = 0x0080,
+ CHIP_HELPER_COEX_STATUS_INT_UART_MASK = 0x0100,
+ CHIP_HELPER_COEX_STATUS_INT_BT_LEG_MASK = 0x0200
+};
+
+/* How to select the different CPUs */
+enum chip_helper_dbg_proc_sel_enum
+{
+ CHIP_HELPER_DBG_PROC_SEL_MAC = 0,
+ CHIP_HELPER_DBG_PROC_SEL_PHY = 1,
+ CHIP_HELPER_DBG_PROC_SEL_BT = 2,
+ CHIP_HELPER_DBG_PROC_SEL_NONE = 2,
+ CHIP_HELPER_DBG_PROC_SEL_BOTH = 3
+};
+
+/* These are the only registers that we have to know the
+ address of before we know the chip version. */
+enum chip_helper_fixed_registers
+{
+ /* This is the address of GBL_CHIP_VERISON on BC7,
+ UF105x, UF60xx and
+ anything later than that. */
+ CHIP_HELPER_UNIFI_GBL_CHIP_VERSION = 0xFE81,
+
+ CHIP_HELPER_OLD_BLUECORE_GBL_CHIP_VERSION = 0xFF9A
+
+ /* This isn't used at the moment (but might be needed
+ to distinguish the BlueCore sub version?) */
+ /* CHIP_HELPER_OLD_BLUECORE_ANA_VERSION_ID = 0xFF7D */
+};
+
+/* Address-value pairs for defining initialisation values */
+struct chip_helper_init_values
+{
+ u16 addr;
+ u16 value;
+};
+
+/* A block of data that should be written to the device */
+struct chip_helper_reset_values
+{
+ u32 gp_address;
+ u32 len;
+ const u16 *data;
+};
+
+/*
+ * This is the C API.
+ */
+
+/* opaque type */
+typedef const struct chip_device_desc_t ChipDescript;
+
+/* Return a NULL descriptor */
+ChipDescript* ChipHelper_Null(void);
+
+/* This should get the correct version for any CSR chip.
+ The two parameters are what is read from addresses
+ 0xFF9A and 0xFE81 (OLD_BLUECORE_GBL_CHIP_VERSION and
+ UNIFI_GBL_CHIP_VERSION). These should give a unique identity
+ for most (all?) chips.
+
+ FF9A is the old GBL_CHIP_VERSION register. If the high
+ eight bits are zero then the chip is a new (BC7 +) one
+ and FE81 is the _new_ GBL_CHIP_VERSION register. */
+ChipDescript* ChipHelper_GetVersionAny(u16 from_FF9A, u16 from_FE81);
+
+/* The chip is a UniFi, but we don't know which type
+ The parameter is the value of UNIFI_GBL_CHIP_VERSION (0xFE81) */
+ChipDescript* ChipHelper_GetVersionUniFi(u16 version);
+
+/* This gets the version from the SDIO device id. This only
+ gives quite a coarse grained version, so we should update once
+ we hav access to the function N registers. */
+ChipDescript* ChipHelper_GetVersionSdio(u8 sdio_version);
+
+/* The chip is some sort of BlueCore. If "age" is "pre_bc7" then
+ "version" is what was read from FF9A. If "age" is bc7_or_later
+ then "version" is read from FE81. If we don't know if we're pre
+ or post BC7 then we should use "GetVersionAny". */
+ChipDescript* ChipHelper_GetVersionBlueCore(enum chip_helper_bluecore_age age,
+ u16 version);
+
+/* The main functions of this class are built with an X macro. This
+ means we can generate the C and C++ versions from the same source
+ without the two diverging.
+
+ The DEF0 functions are simple and take no parameters. The first
+ parameter to the macro is the return type. The second parameter
+ is the function name and the third parameter is where to get the
+ info from (this is hidden from the user).
+
+ The DEF1 functions take one parameter. This time the third macro
+ parameter is the type of this parameter, and the fourth macro
+ parameter is the name of the parameter. The bodies of these
+ functions are hand written. */
+#define CHIP_HELPER_LIST(m) \
+ CHIP_HELPER_DEF0(m, (const char *, FriendlyName, friendly_name)) \
+ CHIP_HELPER_DEF0(m, (const char *, MarketingName, marketing_name)) \
+ CHIP_HELPER_DEF0(m, (u16, DBG_EMU_CMD, regs->dbg_emu_cmd)) \
+ CHIP_HELPER_DEF0(m, (u16, DBG_HOST_PROC_SELECT, regs->host.dbg_proc_select)) \
+ CHIP_HELPER_DEF0(m, (u16, DBG_HOST_STOP_STATUS, regs->host.dbg_stop_status)) \
+ CHIP_HELPER_DEF0(m, (u16, HOST_WINDOW1_PAGE, regs->host.window1_page)) \
+ CHIP_HELPER_DEF0(m, (u16, HOST_WINDOW2_PAGE, regs->host.window2_page)) \
+ CHIP_HELPER_DEF0(m, (u16, HOST_WINDOW3_PAGE, regs->host.window3_page)) \
+ CHIP_HELPER_DEF0(m, (u16, HOST_IO_LOG_ADDR, regs->host.io_log_addr)) \
+ CHIP_HELPER_DEF0(m, (u16, DBG_SPI_PROC_SELECT, regs->spi.dbg_proc_select)) \
+ CHIP_HELPER_DEF0(m, (u16, DBG_SPI_STOP_STATUS, regs->spi.dbg_stop_status)) \
+ CHIP_HELPER_DEF0(m, (u16, SPI_WINDOW1_PAGE, regs->spi.window1_page)) \
+ CHIP_HELPER_DEF0(m, (u16, SPI_WINDOW2_PAGE, regs->spi.window2_page)) \
+ CHIP_HELPER_DEF0(m, (u16, SPI_WINDOW3_PAGE, regs->spi.window3_page)) \
+ CHIP_HELPER_DEF0(m, (u16, SPI_IO_LOG_ADDR, regs->spi.io_log_addr)) \
+ CHIP_HELPER_DEF0(m, (u16, DBG_RESET, regs->dbg_reset)) \
+ CHIP_HELPER_DEF0(m, (u16, DBG_RESET_VALUE, regs->dbg_reset_value)) \
+ CHIP_HELPER_DEF0(m, (u16, DBG_RESET_WARN, regs->dbg_reset_warn)) \
+ CHIP_HELPER_DEF0(m, (u16, DBG_RESET_WARN_VALUE, regs->dbg_reset_warn_value)) \
+ CHIP_HELPER_DEF0(m, (u16, DBG_RESET_RESULT, regs->dbg_reset_result)) \
+ CHIP_HELPER_DEF0(m, (u16, WATCHDOG_DISABLE, regs->watchdog_disable)) \
+ CHIP_HELPER_DEF0(m, (u16, PROC_PC_SNOOP, regs->proc_pc_snoop)) \
+ CHIP_HELPER_DEF0(m, (u16, GBL_CHIP_VERSION, regs->gbl_chip_version)) \
+ CHIP_HELPER_DEF0(m, (u16, GBL_MISC_ENABLES, regs->gbl_misc_enables)) \
+ CHIP_HELPER_DEF0(m, (u16, XAP_PCH, regs->xap_pch)) \
+ CHIP_HELPER_DEF0(m, (u16, XAP_PCL, regs->xap_pcl)) \
+ CHIP_HELPER_DEF0(m, (u16, MAILBOX0, regs->mailbox0)) \
+ CHIP_HELPER_DEF0(m, (u16, MAILBOX1, regs->mailbox1)) \
+ CHIP_HELPER_DEF0(m, (u16, MAILBOX2, regs->mailbox2)) \
+ CHIP_HELPER_DEF0(m, (u16, MAILBOX3, regs->mailbox3)) \
+ CHIP_HELPER_DEF0(m, (u16, SDIO_HIP_HANDSHAKE, regs->sdio_hip_handshake)) \
+ CHIP_HELPER_DEF0(m, (u16, SDIO_HOST_INT, regs->sdio_host_int)) \
+ CHIP_HELPER_DEF0(m, (u16, COEX_STATUS, regs->coex_status)) \
+ CHIP_HELPER_DEF0(m, (u16, SHARED_IO_INTERRUPT, regs->shared_io_interrupt)) \
+ CHIP_HELPER_DEF0(m, (u32, PROGRAM_MEMORY_RAM_OFFSET, prog_offset.ram)) \
+ CHIP_HELPER_DEF0(m, (u32, PROGRAM_MEMORY_ROM_OFFSET, prog_offset.rom)) \
+ CHIP_HELPER_DEF0(m, (u32, PROGRAM_MEMORY_FLASH_OFFSET, prog_offset.flash)) \
+ CHIP_HELPER_DEF0(m, (u32, PROGRAM_MEMORY_EXT_SRAM_OFFSET, prog_offset.ext_sram)) \
+ CHIP_HELPER_DEF0(m, (u16, DATA_MEMORY_RAM_OFFSET, data_offset.ram)) \
+ CHIP_HELPER_DEF0(m, (s32, HasFlash, bools.has_flash)) \
+ CHIP_HELPER_DEF0(m, (s32, HasExtSram, bools.has_ext_sram)) \
+ CHIP_HELPER_DEF0(m, (s32, HasRom, bools.has_rom)) \
+ CHIP_HELPER_DEF0(m, (s32, HasBt, bools.has_bt)) \
+ CHIP_HELPER_DEF0(m, (s32, HasWLan, bools.has_wlan)) \
+ CHIP_HELPER_DEF1(m, (u16, WINDOW_ADDRESS, enum chip_helper_window_index, window)) \
+ CHIP_HELPER_DEF1(m, (u16, WINDOW_SIZE, enum chip_helper_window_index, window)) \
+ CHIP_HELPER_DEF1(m, (u16, MapAddress_SPI2HOST, u16, addr)) \
+ CHIP_HELPER_DEF1(m, (u16, MapAddress_HOST2SPI, u16, addr)) \
+ CHIP_HELPER_DEF1(m, (u32, ClockStartupSequence, const struct chip_helper_init_values **, val)) \
+ CHIP_HELPER_DEF1(m, (u32, HostResetSequence, const struct chip_helper_reset_values **, val))
+
+/* Some magic to help the expansion */
+#define CHIP_HELPER_DEF0(a, b) \
+ CHIP_HELPER_DEF0_ ## a b
+#define CHIP_HELPER_DEF1(a, b) \
+ CHIP_HELPER_DEF1_ ## a b
+
+/* Macros so that when we expand the list we get "C" function prototypes. */
+#define CHIP_HELPER_DEF0_C_DEC(ret_type, name, info) \
+ ret_type ChipHelper_ ## name(ChipDescript * chip_help);
+#define CHIP_HELPER_DEF1_C_DEC(ret_type, name, type1, name1) \
+ ret_type ChipHelper_ ## name(ChipDescript * chip_help, type1 name1);
+
+CHIP_HELPER_LIST(C_DEC)
+
+/* FriendlyName
+ MarketingName
+
+ These two functions return human readable strings that describe
+ the chip. FriendlyName returns something that a software engineer
+ at CSR might understand. MarketingName returns something more like
+ an external name for a CSR chip.
+*/
+/* DBG_EMU_CMD
+ WATCHDOG_DISABLE
+ PROC_PC_SNOOP
+ GBL_CHIP_VERSION
+ XAP_PCH
+ XAP_PCL
+
+ These registers are used to control the XAPs.
+*/
+/* DBG_HOST_PROC_SELECT DBG_HOST_STOP_STATUS
+ HOST_WINDOW1_PAGE HOST_WINDOW2_PAGE HOST_WINDOW3_PAGE
+ HOST_IO_LOG_ADDR
+ DBG_SPI_PROC_SELECT DBG_SPI_STOP_STATUS
+ SPI_WINDOW1_PAGE SPI_WINDOW2_PAGE SPI_WINDOW3_PAGE
+ SPI_IO_LOG_ADDR
+
+ These register are used to control the XAPs and the memory
+ windows, normally while debugging the code on chip. There
+ are two versons of these registers, one for access via SPI
+ and another for access via the host interface.
+*/
+/* DBG_RESET
+ DBG_RESET_VALUE
+ DBG_RESET_WARN
+ DBG_RESET_WARN_VALUE
+ DBG_RESET_RESULT
+
+ These registers are used to reset the XAP. This can be
+ quite complex for some chips. If DBG_RESET_WARN is non
+ zero the DBG_RESET_WARN_VALUE should be written to address
+ DBG_RESET_WARN before the reset is perfeormed. DBG_RESET_VALUE
+ should then be written to DBG_RESET to make the reset happen.
+ The DBG_RESET_RESULT register should contain 0 if the reset
+ was successful.
+*/
+/* GBL_MISC_ENABLES
+
+ This register controls some special chip features. It
+ should be used with care is it changes quite a lot between
+ chip versions.
+*/
+/* MAILBOX0
+ MAILBOX1
+ MAILBOX2
+ MAILBOX3
+
+ The mailbox registers are for communication between the host
+ and the firmware. There use is described in part by the host
+ interface protcol specifcation.
+*/
+/* SDIO_HIP_HANDSHAKE
+
+ This is one of the more important SDIO HIP registers. On some
+ chips it has the same value as one of the mailbox registers
+ and on other chips it is different.
+*/
+/* SDIO_HOST_INT
+ SHARED_IO_INTERRUPT
+
+ These registers are used by some versions of the host interface
+ protocol specification. Their names should probably be changed
+ to hide the registers and to expose the functions more.
+*/
+/* COEX_STATUS
+
+ Coex status register, contains interrupt status and reset
+ pullup status. The latter is used to detect WAPI.
+*/
+/* PROGRAM_MEMORY_RAM_OFFSET
+ PROGRAM_MEMORY_ROM_OFFSET
+ PROGRAM_MEMORY_FLASH_OFFSET
+ PROGRAM_MEMORY_EXT_SRAM_OFFSET
+ DATA_MEMORY_RAM_OFFSET
+
+ These are constants that describe the offset of the different
+ memory types in the two different address spaces.
+*/
+/* HasFlash HasExtSram HasRom
+ HasBt HasWLan
+
+ These are a set of bools describing the chip.
+*/
+/* WINDOW_ADDRESS WINDOW_SIZE
+
+ These two functions return the size and address of the windows.
+ The address is the address of the lowest value in the address
+ map that is part of the window and the size is the number of
+ visible words.
+
+ Some of the windows have thier lowest portion covered by
+ registers. For these windows address is the first address
+ after the registers and size is the siave excluding the part
+ covered by registers.
+*/
+/* MapAddress_SPI2HOST
+ MapAddress_HOST2SPI
+
+ The debugging interface is duplicated on UniFi and later chips
+ so that there are two versions - one over the SPI interaface and
+ the other over the SDIO interface. These functions map the
+ registers between these two interfaces.
+*/
+/* ClockStartupSequence
+
+ This function returns the list of register value pairs that
+ should be forced into UniFi to enable SPI communication. This
+ set of registers is not needed if the firmware is running, but
+ will be needed if the device is being booted from cold. These
+ register writes enable the clocks and setup the PLL to a basic
+ working state. SPI access might be unreliable until these writes
+ have occured (And they may take mulitple goes).
+*/
+/* HostResetSequence
+
+ This returns a number of chunks of data and generic pointers.
+ All of the XAPs should be stopped. The data should be written
+ to the generic pointers. The instruction pointer for the MAC
+ should then be set to the start of program memory and then the
+ MAC should be "go"d. This will reset the chip in a reliable
+ and orderly manner without resetting the SDIO interface. It
+ is therefore not needed if the chip is being accessed by the
+ SPI interface (the DBG_RESET_ mechanism can be used instead).
+*/
+
+/* The Decode Window function is more complex. For the window
+ 'window' it tries to return the address and page register
+ value needed to see offset 'offset' of memory type 'type'.
+
+ It return 1 on success and 0 on failure. 'page' is what
+ should be written to the page register. 'addr' is the
+ address in the XAPs 16 address map to read from. 'len'
+ is the length that we can read without having to change
+ the page registers. */
+s32 ChipHelper_DecodeWindow(ChipDescript *chip_help,
+ enum chip_helper_window_index window,
+ enum chip_helper_window_type type,
+ u32 offset,
+ u16 *page, u16 *addr, u32 *len);
+
+#ifdef __cplusplus
+/* Close the extern "C" */
+}
+
+/*
+ * This is the C++ API.
+ */
+
+class ChipHelper
+{
+public:
+ /* If this constructor is used then a GetVersionXXX function
+ should be called next. */
+ ChipHelper();
+
+ /* copy constructor */
+ ChipHelper(ChipDescript * desc);
+
+ /* The default constructor assume a BC7 / UF105x series chip
+ and that the number given is the value of UNIFI_GBL_CHIP_VERSION
+ (0xFE81) */
+ ChipHelper(u16 version);
+
+ /* This returns the C interface magic token from a C++ instance. */
+ ChipDescript* GetDescript() const
+ {
+ return m_desc;
+ }
+
+
+ /* Clear out theis class (set it to the null token). */
+ void ClearVersion();
+
+ /* Load this class with data for a specific chip. */
+ void GetVersionAny(u16 from_FF9A, u16 from_FE81);
+ void GetVersionUniFi(u16 version);
+ void GetVersionBlueCore(chip_helper_bluecore_age age, u16 version);
+ void GetVersionSdio(u8 sdio_version);
+
+ /* Helpers to build the definitions of the member functions. */
+#define CHIP_HELPER_DEF0_CPP_DEC(ret_type, name, info) \
+ ret_type name() const;
+#define CHIP_HELPER_DEF1_CPP_DEC(ret_type, name, type1, name1) \
+ ret_type name(type1 name1) const;
+
+ CHIP_HELPER_LIST(CPP_DEC)
+
+
+ /* The DecodeWindow function, see the description of the C version. */
+ s32 DecodeWindow(chip_helper_window_index window,
+ chip_helper_window_type type,
+ u32 offset,
+ u16 &page, u16 &addr, u32 &len) const;
+
+private:
+ ChipDescript *m_desc;
+};
+
+#endif /* __cplusplus */
+
+#endif
diff --git a/drivers/staging/csr/csr_wifi_hip_chiphelper_private.h b/drivers/staging/csr/csr_wifi_hip_chiphelper_private.h
new file mode 100644
index 000000000000..cb0ea4b63e65
--- /dev/null
+++ b/drivers/staging/csr/csr_wifi_hip_chiphelper_private.h
@@ -0,0 +1,208 @@
+/*****************************************************************************
+
+ (c) Cambridge Silicon Radio Limited 2011
+ All rights reserved and confidential information of CSR
+
+ Refer to LICENSE.txt included with this source for details
+ on the license terms.
+
+*****************************************************************************/
+
+#ifndef CSR_WIFI_HIP_CHIPHELPER_PRIVATE_H__
+#define CSR_WIFI_HIP_CHIPHELPER_PRIVATE_H__
+
+
+#include "csr_wifi_hip_chiphelper.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+/* This GP stuff should be somewhere else? */
+
+/* Memory spaces encoded in top byte of Generic Pointer type */
+#define UNIFI_SH_DMEM 0x01 /* Shared Data Memory */
+#define UNIFI_EXT_FLASH 0x02 /* External FLASH */
+#define UNIFI_EXT_SRAM 0x03 /* External SRAM */
+#define UNIFI_REGISTERS 0x04 /* Registers */
+#define UNIFI_PHY_DMEM 0x10 /* PHY Data Memory */
+#define UNIFI_PHY_PMEM 0x11 /* PHY Program Memory */
+#define UNIFI_PHY_ROM 0x12 /* PHY ROM */
+#define UNIFI_MAC_DMEM 0x20 /* MAC Data Memory */
+#define UNIFI_MAC_PMEM 0x21 /* MAC Program Memory */
+#define UNIFI_MAC_ROM 0x22 /* MAC ROM */
+#define UNIFI_BT_DMEM 0x30 /* BT Data Memory */
+#define UNIFI_BT_PMEM 0x31 /* BT Program Memory */
+#define UNIFI_BT_ROM 0x32 /* BT ROM */
+
+#define MAKE_GP(R, O) (((UNIFI_ ## R) << 24) | (O))
+#define GP_OFFSET(GP) ((GP) & 0xFFFFFF)
+#define GP_SPACE(GP) (((GP) >> 24) & 0xFF)
+
+
+/* Address value pairs */
+struct val_array_t
+{
+ u32 len;
+ const struct chip_helper_init_values *vals;
+};
+
+/* Just a (counted) u16 array */
+struct data_array_t
+{
+ u32 len;
+ const u16 *vals;
+};
+
+struct reset_prog_t
+{
+ u32 len;
+ const struct chip_helper_reset_values *vals;
+};
+
+/* The addresses of registers that are equivalent but on
+ different host transports. */
+struct chip_map_address_t
+{
+ u16 spi, host;
+};
+
+struct map_array_t
+{
+ u32 len;
+ const struct chip_map_address_t *vals;
+};
+
+struct chip_device_regs_per_transport_t
+{
+ u16 dbg_proc_select;
+ u16 dbg_stop_status;
+ u16 window1_page; /* PROG_PMEM1 or GW1 */
+ u16 window2_page; /* PROG_PMEM2 or GW2 */
+ u16 window3_page; /* SHARED or GW3 */
+ u16 io_log_addr;
+};
+
+struct chip_device_regs_t
+{
+ u16 gbl_chip_version;
+ u16 gbl_misc_enables;
+ u16 dbg_emu_cmd;
+ struct chip_device_regs_per_transport_t host;
+ struct chip_device_regs_per_transport_t spi;
+ u16 dbg_reset;
+ u16 dbg_reset_value;
+ u16 dbg_reset_warn;
+ u16 dbg_reset_warn_value;
+ u16 dbg_reset_result;
+ u16 xap_pch;
+ u16 xap_pcl;
+ u16 proc_pc_snoop;
+ u16 watchdog_disable;
+ u16 mailbox0;
+ u16 mailbox1;
+ u16 mailbox2;
+ u16 mailbox3;
+ u16 sdio_host_int;
+ u16 shared_io_interrupt;
+ u16 sdio_hip_handshake;
+ u16 coex_status; /* Allows WAPI detection */
+};
+
+/* If allowed is false then this window does not provide this
+ type of access.
+ This describes how addresses should be shifted to make the
+ "page" address. The address is shifted left by 'page_shift'
+ and then has 'page_offset' added. This value should then be
+ written to the page register. */
+struct window_shift_info_t
+{
+ s32 allowed;
+ u32 page_shift;
+ u16 page_offset;
+};
+
+/* Each window has an address and size. These are obvious. It then
+ has a description for each type of memory that might be accessed
+ through it. There might also be a start to the offset of the window.
+ This means that that number of addresses at the start of the window
+ are unusable. */
+struct window_info_t
+{
+ u16 address;
+ u16 size;
+ u16 blocked;
+ const struct window_shift_info_t *mode;
+};
+
+/* If GBL_CHIP_VERSION and'ed with 'mask' and is equal to 'result'
+ then this is the correct set of info. If pre_bc7 is true then the
+ address of GBL_CHIP_VERSION is FF9A, else its FE81. */
+struct chip_version_t
+{
+ s32 pre_bc7;
+ u16 mask;
+ u16 result;
+ u8 sdio;
+};
+
+struct chip_device_desc_t
+{
+ struct chip_version_t chip_version;
+
+ /* This is a text string that a human might find useful (BC02, UF105x) */
+ const char *friendly_name;
+ /* This is what we show to customers */
+ const char *marketing_name;
+
+ /* Initialisation values to write following a reset */
+ struct val_array_t init;
+
+ /* Binary sequence for hard reset */
+ struct reset_prog_t reset_prog;
+
+ /* The register map */
+ const struct chip_device_regs_t *regs;
+
+ /* Some misc. info on the chip */
+ struct
+ {
+ u32 has_flash : 1;
+ u32 has_ext_sram : 1;
+ u32 has_rom : 1;
+ u32 has_bt : 1;
+ u32 has_wlan : 1;
+ } bools;
+
+ /* This table is used to remap register addresses depending on what
+ host interface is used. On the BC7 and later chips there are
+ multiple sets of memory window registers, on for each host
+ interafce (SDIO / SPI). The correct one is needed. */
+ struct map_array_t map;
+
+ /* The offsets into the program address space of the different types of memory.
+ The RAM offset is probably the most useful. */
+ struct
+ {
+ u32 ram;
+ u32 rom;
+ u32 flash;
+ u32 ext_sram;
+ } prog_offset;
+
+ /* The offsets into the data address space of interesting things. */
+ struct
+ {
+ u16 ram;
+ /* maybe add shared / page tables? */
+ } data_offset;
+
+ /* Information on the different windows */
+ const struct window_info_t *windows[CHIP_HELPER_WINDOW_COUNT];
+};
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* CSR_WIFI_HIP_CHIPHELPER_PRIVATE_H__ */
diff --git a/drivers/staging/csr/csr_wifi_hip_conversions.h b/drivers/staging/csr/csr_wifi_hip_conversions.h
new file mode 100644
index 000000000000..7d045c069362
--- /dev/null
+++ b/drivers/staging/csr/csr_wifi_hip_conversions.h
@@ -0,0 +1,81 @@
+/*****************************************************************************
+
+ (c) Cambridge Silicon Radio Limited 2011
+ All rights reserved and confidential information of CSR
+
+ Refer to LICENSE.txt included with this source for details
+ on the license terms.
+
+*****************************************************************************/
+
+/*
+ * ---------------------------------------------------------------------------
+ *
+ * FILE: csr_wifi_hip_conversions.h
+ *
+ * PURPOSE:
+ * This header file provides the macros for converting to and from
+ * wire format.
+ * These macros *MUST* work for little-endian AND big-endian hosts.
+ *
+ * ---------------------------------------------------------------------------
+ */
+#ifndef __CSR_WIFI_HIP_CONVERSIONS_H__
+#define __CSR_WIFI_HIP_CONVERSIONS_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define SIZEOF_UINT16 2
+#define SIZEOF_UINT32 4
+#define SIZEOF_UINT64 8
+
+#define SIZEOF_SIGNAL_HEADER 6
+#define SIZEOF_DATAREF 4
+
+
+/*
+ * Macro to retrieve the signal ID from a wire-format signal.
+ */
+#define GET_SIGNAL_ID(_buf) CSR_GET_UINT16_FROM_LITTLE_ENDIAN((_buf))
+
+/*
+ * Macros to retrieve and set the DATAREF fields in a packed (i.e. wire-format)
+ * HIP signal.
+ */
+#define GET_PACKED_DATAREF_SLOT(_buf, _ref) \
+ CSR_GET_UINT16_FROM_LITTLE_ENDIAN(((_buf) + SIZEOF_SIGNAL_HEADER + ((_ref) * SIZEOF_DATAREF) + 0))
+
+#define GET_PACKED_DATAREF_LEN(_buf, _ref) \
+ CSR_GET_UINT16_FROM_LITTLE_ENDIAN(((_buf) + SIZEOF_SIGNAL_HEADER + ((_ref) * SIZEOF_DATAREF) + 2))
+
+#define SET_PACKED_DATAREF_SLOT(_buf, _ref, _slot) \
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN((_slot), ((_buf) + SIZEOF_SIGNAL_HEADER + ((_ref) * SIZEOF_DATAREF) + 0))
+
+#define SET_PACKED_DATAREF_LEN(_buf, _ref, _len) \
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN((_len), ((_buf) + SIZEOF_SIGNAL_HEADER + ((_ref) * SIZEOF_DATAREF) + 2))
+
+#define GET_PACKED_MA_PACKET_REQUEST_FRAME_PRIORITY(_buf) \
+ CSR_GET_UINT16_FROM_LITTLE_ENDIAN(((_buf) + SIZEOF_SIGNAL_HEADER + UNIFI_MAX_DATA_REFERENCES * SIZEOF_DATAREF + 8))
+
+#define GET_PACKED_MA_PACKET_REQUEST_HOST_TAG(_buf) \
+ CSR_GET_UINT32_FROM_LITTLE_ENDIAN(((_buf) + SIZEOF_SIGNAL_HEADER + UNIFI_MAX_DATA_REFERENCES * SIZEOF_DATAREF + 4))
+
+#define GET_PACKED_MA_PACKET_CONFIRM_HOST_TAG(_buf) \
+ CSR_GET_UINT32_FROM_LITTLE_ENDIAN(((_buf) + SIZEOF_SIGNAL_HEADER + UNIFI_MAX_DATA_REFERENCES * SIZEOF_DATAREF + 8))
+
+#define GET_PACKED_MA_PACKET_CONFIRM_TRANSMISSION_STATUS(_buf) \
+ CSR_GET_UINT16_FROM_LITTLE_ENDIAN(((_buf) + SIZEOF_SIGNAL_HEADER + UNIFI_MAX_DATA_REFERENCES * SIZEOF_DATAREF + 2))
+
+
+s32 get_packed_struct_size(const u8 *buf);
+CsrResult read_unpack_signal(const u8 *ptr, CSR_SIGNAL *sig);
+CsrResult write_pack(const CSR_SIGNAL *sig, u8 *ptr, u16 *sig_len);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __CSR_WIFI_HIP_CONVERSIONS_H__ */
+
diff --git a/drivers/staging/csr/csr_wifi_hip_download.c b/drivers/staging/csr/csr_wifi_hip_download.c
new file mode 100644
index 000000000000..8e4a4608ba5c
--- /dev/null
+++ b/drivers/staging/csr/csr_wifi_hip_download.c
@@ -0,0 +1,835 @@
+/*****************************************************************************
+
+ (c) Cambridge Silicon Radio Limited 2012
+ All rights reserved and confidential information of CSR
+
+ Refer to LICENSE.txt included with this source for details
+ on the license terms.
+
+*****************************************************************************/
+
+/*
+ * ---------------------------------------------------------------------------
+ * FILE: csr_wifi_hip_download.c
+ *
+ * PURPOSE:
+ * Routines for downloading firmware to UniFi.
+ *
+ * ---------------------------------------------------------------------------
+ */
+#include <linux/slab.h>
+#include "csr_wifi_hip_unifi.h"
+#include "csr_wifi_hip_unifiversion.h"
+#include "csr_wifi_hip_card.h"
+#include "csr_wifi_hip_xbv.h"
+
+#undef CSR_WIFI_IGNORE_PATCH_VERSION_MISMATCH
+
+static CsrResult do_patch_download(card_t *card, void *dlpriv,
+ xbv1_t *pfwinfo, u32 boot_ctrl_addr);
+
+static CsrResult do_patch_convert_download(card_t *card,
+ void *dlpriv, xbv1_t *pfwinfo);
+
+/*
+ * ---------------------------------------------------------------------------
+ * _find_in_slut
+ *
+ * Find the offset of the appropriate object in the SLUT of a card
+ *
+ * Arguments:
+ * card Pointer to card struct
+ * psym Pointer to symbol object.
+ * id set up by caller
+ * obj will be set up by this function
+ * pslut Pointer to SLUT address, if 0xffffffff then it must be
+ * read from the chip.
+ * Returns:
+ * CSR_RESULT_SUCCESS on success
+ * Non-zero on error,
+ * CSR_WIFI_HIP_RESULT_NOT_FOUND if not found
+ * ---------------------------------------------------------------------------
+ */
+static CsrResult _find_in_slut(card_t *card, symbol_t *psym, u32 *pslut)
+{
+ u32 slut_address;
+ u16 finger_print;
+ CsrResult r;
+ CsrResult csrResult;
+
+ /* Get SLUT address */
+ if (*pslut == 0xffffffff)
+ {
+ r = card_wait_for_firmware_to_start(card, &slut_address);
+ if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
+ {
+ return r;
+ }
+ if (r != CSR_RESULT_SUCCESS)
+ {
+ unifi_error(card->ospriv, "Firmware hasn't started\n");
+ func_exit_r(r);
+ return r;
+ }
+ *pslut = slut_address;
+
+ /*
+ * Firmware has started so set the SDIO bus clock to the initial speed,
+ * faster than UNIFI_SDIO_CLOCK_SAFE_HZ, to speed up the f/w download.
+ */
+ csrResult = CsrSdioMaxBusClockFrequencySet(card->sdio_if, UNIFI_SDIO_CLOCK_INIT_HZ);
+ if (csrResult != CSR_RESULT_SUCCESS)
+ {
+ r = ConvertCsrSdioToCsrHipResult(card, csrResult);
+ func_exit_r(r);
+ return r;
+ }
+ card->sdio_clock_speed = UNIFI_SDIO_CLOCK_INIT_HZ;
+ }
+ else
+ {
+ slut_address = *pslut; /* Use previously discovered address */
+ }
+ unifi_trace(card->ospriv, UDBG4, "SLUT addr: 0x%lX\n", slut_address);
+
+ /*
+ * Check the SLUT fingerprint.
+ * The slut_address is a generic pointer so we must use unifi_card_read16().
+ */
+ unifi_trace(card->ospriv, UDBG4, "Looking for SLUT finger print\n");
+ finger_print = 0;
+ r = unifi_card_read16(card, slut_address, &finger_print);
+ if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
+ {
+ return r;
+ }
+ if (r != CSR_RESULT_SUCCESS)
+ {
+ unifi_error(card->ospriv, "Failed to read SLUT finger print\n");
+ func_exit_r(r);
+ return r;
+ }
+
+ if (finger_print != SLUT_FINGERPRINT)
+ {
+ unifi_error(card->ospriv, "Failed to find SLUT fingerprint\n");
+ func_exit_r(CSR_RESULT_FAILURE);
+ return CSR_RESULT_FAILURE;
+ }
+
+ /* Symbol table starts imedately after the fingerprint */
+ slut_address += 2;
+
+ while (1)
+ {
+ u16 id;
+ u32 obj;
+
+ r = unifi_card_read16(card, slut_address, &id);
+ if (r != CSR_RESULT_SUCCESS)
+ {
+ func_exit_r(r);
+ return r;
+ }
+ slut_address += 2;
+
+ if (id == CSR_SLT_END)
+ {
+ /* End of table reached: not found */
+ r = CSR_WIFI_HIP_RESULT_RANGE;
+ break;
+ }
+
+ r = unifi_read32(card, slut_address, &obj);
+ if (r != CSR_RESULT_SUCCESS)
+ {
+ func_exit_r(r);
+ return r;
+ }
+ slut_address += 4;
+
+ unifi_trace(card->ospriv, UDBG3, " found SLUT id %02d.%08lx\n", id, obj);
+
+ r = CSR_WIFI_HIP_RESULT_NOT_FOUND;
+ /* Found search term? */
+ if (id == psym->id)
+ {
+ unifi_trace(card->ospriv, UDBG1, " matched SLUT id %02d.%08lx\n", id, obj);
+ psym->obj = obj;
+ r = CSR_RESULT_SUCCESS;
+ break;
+ }
+ }
+
+ func_exit_r(r);
+ return r;
+}
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * do_patch_convert_download
+ *
+ * Download the given firmware image to the UniFi, converting from FWDL
+ * to PTDL XBV format.
+ *
+ * Arguments:
+ * card Pointer to card struct
+ * dlpriv Pointer to source firmware image
+ * fwinfo Pointer to source firmware info struct
+ *
+ * Returns:
+ * CSR_RESULT_SUCCESS on success, CSR error code on error
+ *
+ * Notes:
+ * ---------------------------------------------------------------------------
+ */
+static CsrResult do_patch_convert_download(card_t *card, void *dlpriv, xbv1_t *pfwinfo)
+{
+ CsrResult r;
+ u32 slut_base = 0xffffffff;
+ void *pfw;
+ u32 psize;
+ symbol_t sym;
+
+ /* Reset the chip to guarantee that the ROM loader is running */
+ r = unifi_init(card);
+ if (r != CSR_RESULT_SUCCESS)
+ {
+ unifi_error(card->ospriv,
+ "do_patch_convert_download: failed to re-init UniFi\n");
+ return r;
+ }
+
+ /* If no unifi_helper is running, the firmware version must be read */
+ if (card->build_id == 0)
+ {
+ u32 ver = 0;
+ sym.id = CSR_SLT_BUILD_ID_NUMBER;
+ sym.obj = 0; /* To be updated by _find_in_slut() */
+
+ unifi_trace(card->ospriv, UDBG1, "Need f/w version\n");
+
+ /* Find chip build id entry in SLUT */
+ r = _find_in_slut(card, &sym, &slut_base);
+ if (r != CSR_RESULT_SUCCESS)
+ {
+ unifi_error(card->ospriv, "Failed to find CSR_SLT_BUILD_ID_NUMBER\n");
+ return CSR_RESULT_FAILURE;
+ }
+
+ /* Read running f/w version */
+ r = unifi_read32(card, sym.obj, &ver);
+ if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
+ {
+ return r;
+ }
+ if (r != CSR_RESULT_SUCCESS)
+ {
+ unifi_error(card->ospriv, "Failed to read f/w id\n");
+ return CSR_RESULT_FAILURE;
+ }
+ card->build_id = ver;
+ }
+
+ /* Convert the ptest firmware to a patch against the running firmware */
+ pfw = xbv_to_patch(card, unifi_fw_read, dlpriv, pfwinfo, &psize);
+ if (!pfw)
+ {
+ unifi_error(card->ospriv, "Failed to convert f/w to patch");
+ return CSR_WIFI_HIP_RESULT_NO_MEMORY;
+ }
+ else
+ {
+ void *desc;
+ sym.id = CSR_SLT_BOOT_LOADER_CONTROL;
+ sym.obj = 0; /* To be updated by _find_in_slut() */
+
+ /* Find boot loader control entry in SLUT */
+ r = _find_in_slut(card, &sym, &slut_base);
+ if (r != CSR_RESULT_SUCCESS)
+ {
+ unifi_error(card->ospriv, "Failed to find BOOT_LOADER_CONTROL\n");
+ return CSR_RESULT_FAILURE;
+ }
+
+ r = unifi_set_host_state(card, UNIFI_HOST_STATE_AWAKE);
+ if (r != CSR_RESULT_SUCCESS)
+ {
+ unifi_error(card->ospriv, "Failed to wake UniFi\n");
+ }
+
+ /* Get a dlpriv for the patch buffer so that unifi_fw_read() can
+ * access it.
+ */
+ desc = unifi_fw_open_buffer(card->ospriv, pfw, psize);
+ if (!desc)
+ {
+ return CSR_WIFI_HIP_RESULT_NO_MEMORY;
+ }
+
+ /* Download the patch */
+ unifi_info(card->ospriv, "Downloading converted f/w as patch\n");
+ r = unifi_dl_patch(card, desc, sym.obj);
+ kfree(pfw);
+ unifi_fw_close_buffer(card->ospriv, desc);
+
+ if (r != CSR_RESULT_SUCCESS)
+ {
+ unifi_error(card->ospriv, "Converted patch download failed\n");
+ func_exit_r(r);
+ return r;
+ }
+ else
+ {
+ unifi_trace(card->ospriv, UDBG1, "Converted patch downloaded\n");
+ }
+
+ /* This command starts the firmware */
+ r = unifi_do_loader_op(card, sym.obj + 6, UNIFI_BOOT_LOADER_RESTART);
+ if (r != CSR_RESULT_SUCCESS)
+ {
+ unifi_error(card->ospriv, "Failed to write loader restart cmd\n");
+ }
+
+ func_exit_r(r);
+ return r;
+ }
+}
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * unifi_dl_firmware
+ *
+ * Download the given firmware image to the UniFi.
+ *
+ * Arguments:
+ * card Pointer to card struct
+ * dlpriv A context pointer from the calling function to be
+ * passed when calling unifi_fw_read().
+ *
+ * Returns:
+ * CSR_RESULT_SUCCESS on success,
+ * CSR_WIFI_HIP_RESULT_NO_MEMORY memory allocation failed
+ * CSR_WIFI_HIP_RESULT_INVALID_VALUE error in XBV file
+ * CSR_RESULT_FAILURE SDIO error
+ *
+ * Notes:
+ * Stops and resets the chip, does the download and runs the new
+ * firmware.
+ * ---------------------------------------------------------------------------
+ */
+CsrResult unifi_dl_firmware(card_t *card, void *dlpriv)
+{
+ xbv1_t *fwinfo;
+ CsrResult r;
+
+ func_enter();
+
+ fwinfo = kmalloc(sizeof(xbv1_t), GFP_KERNEL);
+ if (fwinfo == NULL)
+ {
+ unifi_error(card->ospriv, "Failed to allocate memory for firmware\n");
+ return CSR_WIFI_HIP_RESULT_NO_MEMORY;
+ }
+
+ /*
+ * Scan the firmware file to find the TLVs we are interested in.
+ * These are:
+ * - check we support the file format version in VERF
+ * - SLTP Symbol Lookup Table Pointer
+ * - FWDL firmware download segments
+ * - FWOV firmware overlay segment
+ * - VMEQ Register probe tests to verify matching h/w
+ */
+ r = xbv1_parse(card, unifi_fw_read, dlpriv, fwinfo);
+ if (r != CSR_RESULT_SUCCESS || fwinfo->mode != xbv_firmware)
+ {
+ unifi_error(card->ospriv, "File type is %s, expected firmware.\n",
+ fwinfo->mode == xbv_patch?"patch" : "unknown");
+ kfree(fwinfo);
+ return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
+ }
+
+ /* UF6xxx doesn't accept firmware, only patches. Therefore we convert
+ * the file to patch format with version numbers matching the current
+ * running firmware, and then download via the patch mechanism.
+ * The sole purpose of this is to support production test firmware across
+ * different ROM releases, the test firmware being provided in non-patch
+ * format.
+ */
+ if (card->chip_id > SDIO_CARD_ID_UNIFI_2)
+ {
+ unifi_info(card->ospriv, "Must convert f/w to patch format\n");
+ r = do_patch_convert_download(card, dlpriv, fwinfo);
+ }
+ else
+ {
+ /* Older UniFi chips allowed firmware to be directly loaded onto the
+ * chip, which is no longer supported.
+ */
+ unifi_error(card->ospriv, "Only patch downloading supported\n");
+ r = CSR_WIFI_HIP_RESULT_INVALID_VALUE;
+ }
+
+ kfree(fwinfo);
+ func_exit_r(r);
+ return r;
+} /* unifi_dl_firmware() */
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * unifi_dl_patch
+ *
+ * Load the given patch set into UniFi.
+ *
+ * Arguments:
+ * card Pointer to card struct
+ * dlpriv The os specific handle to the firmware file.
+ * boot_ctrl The address of the boot loader control structure.
+ *
+ * Returns:
+ * CSR_RESULT_SUCCESS on success,
+ * CSR_WIFI_HIP_RESULT_NO_MEMORY memory allocation failed
+ * CSR_WIFI_HIP_RESULT_INVALID_VALUE error in XBV file
+ * CSR_RESULT_FAILURE SDIO error
+ *
+ * Notes:
+ * This ends up telling UniFi to restart.
+ * ---------------------------------------------------------------------------
+ */
+CsrResult unifi_dl_patch(card_t *card, void *dlpriv, u32 boot_ctrl)
+{
+ xbv1_t *fwinfo;
+ CsrResult r;
+
+ func_enter();
+
+ unifi_info(card->ospriv, "unifi_dl_patch %p %08x\n", dlpriv, boot_ctrl);
+
+ fwinfo = kmalloc(sizeof(xbv1_t), GFP_KERNEL);
+ if (fwinfo == NULL)
+ {
+ unifi_error(card->ospriv, "Failed to allocate memory for patches\n");
+ func_exit();
+ return CSR_WIFI_HIP_RESULT_NO_MEMORY;
+ }
+
+ /*
+ * Scan the firmware file to find the TLVs we are interested in.
+ * These are:
+ * - check we support the file format version in VERF
+ * - FWID The build ID of the ROM that we can patch
+ * - PTDL patch download segments
+ */
+ r = xbv1_parse(card, unifi_fw_read, dlpriv, fwinfo);
+ if (r != CSR_RESULT_SUCCESS || fwinfo->mode != xbv_patch)
+ {
+ kfree(fwinfo);
+ unifi_error(card->ospriv, "Failed to read in patch file\n");
+ func_exit();
+ return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
+ }
+
+ /*
+ * We have to check the build id read from the SLUT against that
+ * for the patch file. They have to match exactly.
+ * "card->build_id" == XBV1.PTCH.FWID
+ */
+ if (card->build_id != fwinfo->build_id)
+ {
+ unifi_error(card->ospriv, "Wrong patch file for chip (chip = %lu, file = %lu)\n",
+ card->build_id, fwinfo->build_id);
+ kfree(fwinfo);
+#ifndef CSR_WIFI_IGNORE_PATCH_VERSION_MISMATCH
+ func_exit();
+ return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
+#else
+ fwinfo = NULL;
+ dlpriv = NULL;
+ return CSR_RESULT_SUCCESS;
+#endif
+ }
+
+ r = do_patch_download(card, dlpriv, fwinfo, boot_ctrl);
+ if (r != CSR_RESULT_SUCCESS)
+ {
+ unifi_error(card->ospriv, "Failed to patch image\n");
+ }
+
+ kfree(fwinfo);
+
+ func_exit_r(r);
+ return r;
+} /* unifi_dl_patch() */
+
+
+void* unifi_dl_fw_read_start(card_t *card, s8 is_fw)
+{
+ card_info_t card_info;
+
+ unifi_card_info(card, &card_info);
+ unifi_trace(card->ospriv, UDBG5,
+ "id=%d, ver=0x%x, fw_build=%u, fw_hip=0x%x, block_size=%d\n",
+ card_info.chip_id, card_info.chip_version,
+ card_info.fw_build, card_info.fw_hip_version,
+ card_info.sdio_block_size);
+
+ return unifi_fw_read_start(card->ospriv, is_fw, &card_info);
+}
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * safe_read_shared_location
+ *
+ * Read a shared memory location repeatedly until we get two readings
+ * the same.
+ *
+ * Arguments:
+ * card Pointer to card context struct.
+ * unifi_addr UniFi shared-data-memory address to access.
+ * pdata Pointer to a byte variable for the value read.
+ *
+ *
+ * Returns:
+ * CSR_RESULT_SUCCESS on success, CSR error code on failure
+ * ---------------------------------------------------------------------------
+ */
+static CsrResult safe_read_shared_location(card_t *card, u32 address, u8 *pdata)
+{
+ CsrResult r;
+ u16 limit = 1000;
+ u8 b, b2;
+
+ *pdata = 0;
+
+ r = unifi_read_8_or_16(card, address, &b);
+ if (r != CSR_RESULT_SUCCESS)
+ {
+ return r;
+ }
+
+ while (limit--)
+ {
+ r = unifi_read_8_or_16(card, address, &b2);
+ if (r != CSR_RESULT_SUCCESS)
+ {
+ return r;
+ }
+
+ /* When we have a stable value, return it */
+ if (b == b2)
+ {
+ *pdata = b;
+ return CSR_RESULT_SUCCESS;
+ }
+
+ b = b2;
+ }
+
+ return CSR_RESULT_FAILURE;
+} /* safe_read_shared_location() */
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * unifi_do_loader_op
+ *
+ * Send a loader / boot_loader command to the UniFi and wait for
+ * it to complete.
+ *
+ * Arguments:
+ * card Pointer to card context struct.
+ * op_addr The address of the loader operation control word.
+ * opcode The operation to perform.
+ *
+ * Returns:
+ * CSR_RESULT_SUCCESS on success
+ * CSR_RESULT_FAILURE SDIO error or SDIO/XAP timeout
+ * ---------------------------------------------------------------------------
+ */
+
+/*
+ * Ideally instead of sleeping, we want to busy wait.
+ * Currently there is no framework API to do this. When it becomes available,
+ * we can use it to busy wait using usecs
+ */
+#define OPERATION_TIMEOUT_LOOPS (100) /* when OPERATION_TIMEOUT_DELAY==1, (500) otherwise */
+#define OPERATION_TIMEOUT_DELAY 1 /* msec, or 200usecs */
+
+CsrResult unifi_do_loader_op(card_t *card, u32 op_addr, u8 opcode)
+{
+ CsrResult r;
+ s16 op_retries;
+
+ unifi_trace(card->ospriv, UDBG4, "Loader cmd 0x%0x -> 0x%08x\n", opcode, op_addr);
+
+ /* Set the Operation command byte to the opcode */
+ r = unifi_write_8_or_16(card, op_addr, opcode);
+ if (r != CSR_RESULT_SUCCESS)
+ {
+ unifi_error(card->ospriv, "Failed to write loader copy command\n");
+ return r;
+ }
+
+ /* Wait for Operation command byte to be Idle */
+ /* Typically takes ~100us */
+ op_retries = 0;
+ r = CSR_RESULT_SUCCESS;
+ while (1)
+ {
+ u8 op;
+
+ /*
+ * Read the memory location until two successive reads give
+ * the same value.
+ * Then handle it.
+ */
+ r = safe_read_shared_location(card, op_addr, &op);
+ if (r != CSR_RESULT_SUCCESS)
+ {
+ unifi_error(card->ospriv, "Failed to read loader status\n");
+ break;
+ }
+
+ if (op == UNIFI_LOADER_IDLE)
+ {
+ /* Success */
+ break;
+ }
+
+ if (op != opcode)
+ {
+ unifi_error(card->ospriv, "Error reported by loader: 0x%X\n", op);
+ r = CSR_RESULT_FAILURE;
+ break;
+ }
+
+ /* Allow 500us timeout */
+ if (++op_retries >= OPERATION_TIMEOUT_LOOPS)
+ {
+ unifi_error(card->ospriv, "Timeout waiting for loader to ack transfer\n");
+ /* Stop XAPs to aid post-mortem */
+ r = unifi_card_stop_processor(card, UNIFI_PROC_BOTH);
+ if (r != CSR_RESULT_SUCCESS)
+ {
+ unifi_error(card->ospriv, "Failed to stop UniFi processors\n");
+ }
+ else
+ {
+ r = CSR_RESULT_FAILURE;
+ }
+ break;
+ }
+ CsrThreadSleep(OPERATION_TIMEOUT_DELAY);
+ } /* Loop exits with r != CSR_RESULT_SUCCESS on error */
+
+ return r;
+} /* unifi_do_loader_op() */
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * send_ptdl_to_unifi
+ *
+ * Copy a patch block from userland to the UniFi.
+ * This function reads data, 2K at a time, from userland and writes
+ * it to the UniFi.
+ *
+ * Arguments:
+ * card A pointer to the card structure
+ * dlpriv The os specific handle for the firmware file
+ * ptdl A pointer ot the PTDL block
+ * handle The buffer handle to use for the xfer
+ * op_addr The address of the loader operation control word
+ *
+ * Returns:
+ * Number of bytes sent (Positive) or negative value indicating
+ * error code:
+ * CSR_WIFI_HIP_RESULT_NO_MEMORY memory allocation failed
+ * CSR_WIFI_HIP_RESULT_INVALID_VALUE error in XBV file
+ * CSR_RESULT_FAILURE SDIO error
+ * ---------------------------------------------------------------------------
+ */
+static CsrResult send_ptdl_to_unifi(card_t *card, void *dlpriv,
+ const struct PTDL *ptdl, u32 handle,
+ u32 op_addr)
+{
+ u32 offset;
+ u8 *buf;
+ s32 data_len;
+ u32 write_len;
+ CsrResult r;
+ const u16 buf_size = 2 * 1024;
+
+ offset = ptdl->dl_offset;
+ data_len = ptdl->dl_size;
+
+ if (data_len > buf_size)
+ {
+ unifi_error(card->ospriv, "PTDL block is too large (%u)\n",
+ ptdl->dl_size);
+ return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
+ }
+
+ buf = kmalloc(buf_size, GFP_KERNEL);
+ if (buf == NULL)
+ {
+ unifi_error(card->ospriv, "Failed to allocate transfer buffer for firmware download\n");
+ return CSR_WIFI_HIP_RESULT_NO_MEMORY;
+ }
+
+ r = CSR_RESULT_SUCCESS;
+
+ if (unifi_fw_read(card->ospriv, dlpriv, offset, buf, data_len) != data_len)
+ {
+ unifi_error(card->ospriv, "Failed to read from file\n");
+ }
+ else
+ {
+ /* We can always round these if the host wants to */
+ if (card->sdio_io_block_pad)
+ {
+ write_len = (data_len + (card->sdio_io_block_size - 1)) &
+ ~(card->sdio_io_block_size - 1);
+
+ /* Zero out the rest of the buffer (This isn't needed, but it
+ * makes debugging things later much easier). */
+ memset(buf + data_len, 0, write_len - data_len);
+ }
+ else
+ {
+ write_len = data_len;
+ }
+
+ r = unifi_bulk_rw_noretry(card, handle, buf, write_len, UNIFI_SDIO_WRITE);
+ if (r != CSR_RESULT_SUCCESS)
+ {
+ unifi_error(card->ospriv, "CMD53 failed writing %d bytes to handle %ld\n",
+ data_len, handle);
+ }
+ else
+ {
+ /*
+ * Can change the order of things to overlap read from file
+ * with copy to unifi
+ */
+ r = unifi_do_loader_op(card, op_addr, UNIFI_BOOT_LOADER_PATCH);
+ }
+ }
+
+ kfree(buf);
+
+ if (r != CSR_RESULT_SUCCESS && r != CSR_WIFI_HIP_RESULT_NO_DEVICE)
+ {
+ unifi_error(card->ospriv, "Failed to copy block of %u bytes to UniFi\n",
+ ptdl->dl_size);
+ }
+
+ return r;
+} /* send_ptdl_to_unifi() */
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * do_patch_download
+ *
+ * This function downloads a set of patches to UniFi and then
+ * causes it to restart.
+ *
+ * Arguments:
+ * card Pointer to card struct.
+ * dlpriv A context pointer from the calling function to be
+ * used when reading the XBV file. This can be NULL
+ * in which case not patches are applied.
+ * pfwinfo Pointer to a fwinfo struct describing the f/w
+ * XBV file.
+ * boot_ctrl_addr The address of the boot loader control structure.
+ *
+ * Returns:
+ * 0 on success, or an error code
+ * CSR_WIFI_HIP_RESULT_INVALID_VALUE for a bad laoader version number
+ * ---------------------------------------------------------------------------
+ */
+static CsrResult do_patch_download(card_t *card, void *dlpriv, xbv1_t *pfwinfo, u32 boot_ctrl_addr)
+{
+ CsrResult r;
+ s32 i;
+ u16 loader_version;
+ u16 handle;
+ u32 total_bytes;
+
+ /*
+ * Read info from the SDIO Loader Control Data Structure
+ */
+ /* Check the loader version */
+ r = unifi_card_read16(card, boot_ctrl_addr, &loader_version);
+ if (r != CSR_RESULT_SUCCESS)
+ {
+ unifi_error(card->ospriv, "Patch download: Failed to read loader version\n");
+ return r;
+ }
+ unifi_trace(card->ospriv, UDBG2, "Patch download: boot loader version 0x%04X\n", loader_version);
+ switch (loader_version)
+ {
+ case 0x0000:
+ break;
+
+ default:
+ unifi_error(card->ospriv, "Patch loader version (0x%04X) is not supported by this driver\n",
+ loader_version);
+ return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
+ }
+
+ /* Retrieve the handle to use with CMD53 */
+ r = unifi_card_read16(card, boot_ctrl_addr + 4, &handle);
+ if (r != CSR_RESULT_SUCCESS)
+ {
+ unifi_error(card->ospriv, "Patch download: Failed to read loader handle\n");
+ return r;
+ }
+
+ /* Set the mask of LEDs to flash */
+ if (card->loader_led_mask)
+ {
+ r = unifi_card_write16(card, boot_ctrl_addr + 2,
+ (u16)card->loader_led_mask);
+ if (r != CSR_RESULT_SUCCESS)
+ {
+ unifi_error(card->ospriv, "Patch download: Failed to write LED mask\n");
+ return r;
+ }
+ }
+
+ total_bytes = 0;
+
+ /* Copy download data to UniFi memory */
+ for (i = 0; i < pfwinfo->num_ptdl; i++)
+ {
+ unifi_trace(card->ospriv, UDBG3, "Patch download: %d Downloading for %d from offset %d\n",
+ i,
+ pfwinfo->ptdl[i].dl_size,
+ pfwinfo->ptdl[i].dl_offset);
+
+ r = send_ptdl_to_unifi(card, dlpriv, &pfwinfo->ptdl[i],
+ handle, boot_ctrl_addr + 6);
+ if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
+ {
+ return r;
+ }
+ if (r != CSR_RESULT_SUCCESS)
+ {
+ unifi_error(card->ospriv, "Patch failed after %u bytes\n",
+ total_bytes);
+ return r;
+ }
+ total_bytes += pfwinfo->ptdl[i].dl_size;
+ }
+
+ return CSR_RESULT_SUCCESS;
+} /* do_patch_download() */
+
+
diff --git a/drivers/staging/csr/csr_wifi_hip_dump.c b/drivers/staging/csr/csr_wifi_hip_dump.c
new file mode 100644
index 000000000000..d67b460e7a85
--- /dev/null
+++ b/drivers/staging/csr/csr_wifi_hip_dump.c
@@ -0,0 +1,865 @@
+/*****************************************************************************
+
+ (c) Cambridge Silicon Radio Limited 2012
+ All rights reserved and confidential information of CSR
+
+ Refer to LICENSE.txt included with this source for details
+ on the license terms.
+
+*****************************************************************************/
+
+/*
+ * ---------------------------------------------------------------------------
+ * FILE: csr_wifi_hip_dump.c
+ *
+ * PURPOSE:
+ * Routines for retrieving and buffering core status from the UniFi
+ *
+ * ---------------------------------------------------------------------------
+ */
+#include <linux/slab.h>
+#include "csr_wifi_hip_unifi.h"
+#include "csr_wifi_hip_unifiversion.h"
+#include "csr_wifi_hip_card.h"
+
+/* Locations to capture in dump (XAP words) */
+#define HIP_CDUMP_FIRST_CPUREG (0xFFE0) /* First CPU register */
+#define HIP_CDUMP_FIRST_LO (0) /* Start of low address range */
+#define HIP_CDUMP_FIRST_HI_MAC (0x3C00) /* Start of MAC high area */
+#define HIP_CDUMP_FIRST_HI_PHY (0x1C00) /* Start of PHY high area */
+#define HIP_CDUMP_FIRST_SH (0) /* Start of shared memory area */
+
+#define HIP_CDUMP_NCPUREGS (10) /* No. of 16-bit XAP registers */
+#define HIP_CDUMP_NWORDS_LO (0x0100) /* Low area size in 16-bit words */
+#define HIP_CDUMP_NWORDS_HI (0x0400) /* High area size in 16-bit words */
+#define HIP_CDUMP_NWORDS_SH (0x0500) /* Shared memory area size, 16-bit words */
+
+#define HIP_CDUMP_NUM_ZONES 7 /* Number of UniFi memory areas to capture */
+
+/* Mini-coredump state */
+typedef struct coredump_buf
+{
+ u16 count; /* serial number of dump */
+ CsrTime timestamp; /* host's system time at capture */
+ s16 requestor; /* request: 0=auto dump, 1=manual */
+ u16 chip_ver;
+ u32 fw_ver;
+ u16 *zone[HIP_CDUMP_NUM_ZONES];
+
+ struct coredump_buf *next; /* circular list */
+ struct coredump_buf *prev; /* circular list */
+} coredump_buffer;
+
+/* Structure used to describe a zone of chip memory captured by mini-coredump */
+struct coredump_zone
+{
+ unifi_coredump_space_t space; /* XAP memory space this zone covers */
+ enum unifi_dbg_processors_select cpu; /* XAP CPU core selector */
+ u32 gp; /* Generic Pointer to memory zone on XAP */
+ u16 offset; /* 16-bit XAP word offset of zone in memory space */
+ u16 length; /* Length of zone in XAP words */
+};
+
+static CsrResult unifi_coredump_from_sdio(card_t *card, coredump_buffer *dump_buf);
+static CsrResult unifi_coredump_read_zones(card_t *card, coredump_buffer *dump_buf);
+static CsrResult unifi_coredump_read_zone(card_t *card, u16 *zone,
+ const struct coredump_zone *def);
+static s32 get_value_from_coredump(const coredump_buffer *dump,
+ const unifi_coredump_space_t space, const u16 offset);
+
+/* Table of chip memory zones we capture on mini-coredump */
+static const struct coredump_zone zonedef_table[HIP_CDUMP_NUM_ZONES] = {
+ { UNIFI_COREDUMP_MAC_REG, UNIFI_PROC_MAC, UNIFI_MAKE_GP(REGISTERS, HIP_CDUMP_FIRST_CPUREG * 2), HIP_CDUMP_FIRST_CPUREG, HIP_CDUMP_NCPUREGS },
+ { UNIFI_COREDUMP_PHY_REG, UNIFI_PROC_PHY, UNIFI_MAKE_GP(REGISTERS, HIP_CDUMP_FIRST_CPUREG * 2), HIP_CDUMP_FIRST_CPUREG, HIP_CDUMP_NCPUREGS },
+ { UNIFI_COREDUMP_SH_DMEM, UNIFI_PROC_INVALID, UNIFI_MAKE_GP(SH_DMEM, HIP_CDUMP_FIRST_SH * 2), HIP_CDUMP_FIRST_SH, HIP_CDUMP_NWORDS_SH },
+ { UNIFI_COREDUMP_MAC_DMEM, UNIFI_PROC_MAC, UNIFI_MAKE_GP(MAC_DMEM, HIP_CDUMP_FIRST_LO * 2), HIP_CDUMP_FIRST_LO, HIP_CDUMP_NWORDS_LO },
+ { UNIFI_COREDUMP_MAC_DMEM, UNIFI_PROC_MAC, UNIFI_MAKE_GP(MAC_DMEM, HIP_CDUMP_FIRST_HI_MAC * 2), HIP_CDUMP_FIRST_HI_MAC, HIP_CDUMP_NWORDS_HI },
+ { UNIFI_COREDUMP_PHY_DMEM, UNIFI_PROC_PHY, UNIFI_MAKE_GP(PHY_DMEM, HIP_CDUMP_FIRST_LO * 2), HIP_CDUMP_FIRST_LO, HIP_CDUMP_NWORDS_LO },
+ { UNIFI_COREDUMP_PHY_DMEM, UNIFI_PROC_PHY, UNIFI_MAKE_GP(PHY_DMEM, HIP_CDUMP_FIRST_HI_PHY * 2), HIP_CDUMP_FIRST_HI_PHY, HIP_CDUMP_NWORDS_HI },
+};
+
+/*
+ * ---------------------------------------------------------------------------
+ * unifi_coredump_request_at_next_reset
+ *
+ * Request that a mini-coredump is performed when the driver has
+ * completed resetting the UniFi device.
+ *
+ * Arguments:
+ * card Pointer to card struct
+ * enable If non-zero, sets the request.
+ * If zero, cancels any pending request.
+ *
+ * Returns:
+ * CSR_RESULT_SUCCESS or CSR HIP error code
+ *
+ * Notes:
+ * This function is typically called once the driver has detected that
+ * the UniFi device has become unresponsive due to crash, or internal
+ * watchdog reset. The driver must reset it to regain communication and,
+ * immediately after that, the mini-coredump can be captured.
+ * ---------------------------------------------------------------------------
+ */
+CsrResult unifi_coredump_request_at_next_reset(card_t *card, s8 enable)
+{
+ CsrResult r;
+
+ func_enter();
+
+ if (enable)
+ {
+ unifi_trace(card->ospriv, UDBG2, "Mini-coredump requested after reset\n");
+ }
+
+ if (card == NULL)
+ {
+ r = CSR_WIFI_HIP_RESULT_INVALID_VALUE;
+ }
+ else
+ {
+ card->request_coredump_on_reset = enable?1 : 0;
+ r = CSR_RESULT_SUCCESS;
+ }
+
+ func_exit_r(r);
+ return r;
+}
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * unifi_coredump_handle_request
+ *
+ * Performs a coredump now, if one was requested, and clears the request.
+ *
+ * Arguments:
+ * card Pointer to card struct
+ *
+ * Returns:
+ * CSR_RESULT_SUCCESS or CSR HIP error code
+ *
+ * Notes:
+ * ---------------------------------------------------------------------------
+ */
+CsrResult unifi_coredump_handle_request(card_t *card)
+{
+ CsrResult r = CSR_RESULT_SUCCESS;
+
+ func_enter();
+
+ if (card == NULL)
+ {
+ r = CSR_WIFI_HIP_RESULT_INVALID_VALUE;
+ }
+ else
+ {
+ if (card->request_coredump_on_reset == 1)
+ {
+ card->request_coredump_on_reset = 0;
+ r = unifi_coredump_capture(card, NULL);
+ }
+ }
+
+ func_exit_r(r);
+ return r;
+}
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * unifi_coredump_capture
+ *
+ * Capture the current status of the UniFi device.
+ * Various registers are buffered for future offline inspection.
+ *
+ * Arguments:
+ * card Pointer to card struct
+ * req Pointer to request struct, or NULL:
+ * A coredump requested manually by the user app
+ * will have a request struct pointer, an automatic
+ * coredump will have a NULL pointer.
+ * Returns:
+ * CSR_RESULT_SUCCESS on success,
+ * CSR_RESULT_FAILURE SDIO error
+ * CSR_WIFI_HIP_RESULT_INVALID_VALUE Initialisation not complete
+ *
+ * Notes:
+ * The result is a filled entry in the circular buffer of core dumps,
+ * values from which can be extracted to userland via an ioctl.
+ * ---------------------------------------------------------------------------
+ */
+CsrResult unifi_coredump_capture(card_t *card, struct unifi_coredump_req *req)
+{
+ CsrResult r = CSR_RESULT_SUCCESS;
+ static u16 dump_seq_no = 1;
+ CsrTime time_of_capture;
+
+ func_enter();
+
+ if (card->dump_next_write == NULL)
+ {
+ r = CSR_RESULT_SUCCESS;
+ goto done;
+ }
+
+ /* Reject forced capture before initialisation has happened */
+ if (card->helper == NULL)
+ {
+ r = CSR_WIFI_HIP_RESULT_INVALID_VALUE;
+ goto done;
+ }
+
+
+ /*
+ * Force a mini-coredump capture right now
+ */
+ time_of_capture = CsrTimeGet(NULL);
+ unifi_info(card->ospriv, "Mini-coredump capture at t=%u\n", time_of_capture);
+
+ /* Wake up the processors so we can talk to them */
+ r = unifi_set_host_state(card, UNIFI_HOST_STATE_AWAKE);
+ if (r != CSR_RESULT_SUCCESS)
+ {
+ unifi_error(card->ospriv, "Failed to wake UniFi\n");
+ goto done;
+ }
+ CsrThreadSleep(20);
+
+ /* Stop both XAPs */
+ unifi_trace(card->ospriv, UDBG4, "Stopping XAPs for coredump capture\n");
+ r = unifi_card_stop_processor(card, UNIFI_PROC_BOTH);
+ if (r != CSR_RESULT_SUCCESS)
+ {
+ unifi_error(card->ospriv, "Failed to stop UniFi XAPs\n");
+ goto done;
+ }
+
+ /* Dump core into the next available slot in the circular list */
+ r = unifi_coredump_from_sdio(card, card->dump_next_write);
+ if (r == CSR_RESULT_SUCCESS)
+ {
+ /* Record whether the dump was manual or automatic */
+ card->dump_next_write->requestor = (req?1 : 0);
+ card->dump_next_write->timestamp = time_of_capture;
+ /* Advance to the next buffer */
+ card->dump_next_write->count = dump_seq_no++;
+ card->dump_cur_read = card->dump_next_write;
+ card->dump_next_write = card->dump_next_write->next;
+
+ /* Sequence no. of zero indicates slot not in use, so handle wrap */
+ if (dump_seq_no == 0)
+ {
+ dump_seq_no = 1;
+ }
+
+ unifi_trace(card->ospriv, UDBG3,
+ "Coredump (%p), SeqNo=%d, cur_read=%p, next_write=%p\n",
+ req,
+ card->dump_cur_read->count,
+ card->dump_cur_read, card->dump_next_write);
+ }
+
+ /* Start both XAPs */
+ unifi_trace(card->ospriv, UDBG4, "Restart XAPs after coredump\n");
+ r = card_start_processor(card, UNIFI_PROC_BOTH);
+ if (r != CSR_RESULT_SUCCESS)
+ {
+ unifi_error(card->ospriv, "Failed to start UniFi XAPs\n");
+ goto done;
+ }
+
+done:
+ func_exit_r(r);
+ return r;
+} /* unifi_coredump_capture() */
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * get_value_from_coredump
+ *
+ *
+ *
+ * Arguments:
+ * dump Pointer to buffered coredump data
+ * offset_in_space XAP memory space to retrieve from the buffer (there
+ * may be more than one zone covering the same memory
+ * space, but starting from different offsets).
+ * offset Offset within the XAP memory space to be retrieved
+ *
+ * Returns:
+ * >=0 Register value on success
+ * <0 Register out of range of any captured zones
+ *
+ * Notes:
+ * ---------------------------------------------------------------------------
+ */
+static s32 get_value_from_coredump(const coredump_buffer *coreDump,
+ const unifi_coredump_space_t space,
+ const u16 offset_in_space)
+{
+ s32 r = -1;
+ u16 offset_in_zone;
+ u32 zone_end_offset;
+ s32 i;
+ const struct coredump_zone *def = &zonedef_table[0];
+
+ /* Search zone def table for a match with the requested memory space */
+ for (i = 0; i < HIP_CDUMP_NUM_ZONES; i++, def++)
+ {
+ if (space == def->space)
+ {
+ zone_end_offset = def->offset + def->length;
+
+ /* Is the space offset contained in this zone? */
+ if (offset_in_space < zone_end_offset &&
+ offset_in_space >= def->offset)
+ {
+ /* Calculate the offset of data within the zone buffer */
+ offset_in_zone = offset_in_space - def->offset;
+ r = (s32) * (coreDump->zone[i] + offset_in_zone);
+
+ unifi_trace(NULL, UDBG6,
+ "sp %d, offs 0x%04x = 0x%04x (in z%d 0x%04x->0x%04x)\n",
+ space, offset_in_space, r,
+ i, def->offset, zone_end_offset - 1);
+ break;
+ }
+ }
+ }
+ return r;
+}
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * unifi_coredump_get_value
+ *
+ * Retrieve the value of a register buffered from a previous core dump,
+ * so that it may be reported back to application code.
+ *
+ * Arguments:
+ * card Pointer to card struct
+ * req_reg Pointer to request parameter partially filled. This
+ * function puts in the values retrieved from the dump.
+ *
+ * Returns:
+ * CSR_RESULT_SUCCESS on success, or:
+ * CSR_WIFI_HIP_RESULT_INVALID_VALUE Null parameter error
+ * CSR_WIFI_HIP_RESULT_RANGE Register out of range
+ * CSR_WIFI_HIP_RESULT_NOT_FOUND Dump index not (yet) captured
+ *
+ * Notes:
+ * ---------------------------------------------------------------------------
+ */
+CsrResult unifi_coredump_get_value(card_t *card, struct unifi_coredump_req *req)
+{
+ CsrResult r;
+ s32 i = 0;
+ coredump_buffer *find_dump = NULL;
+
+ func_enter();
+
+ if (req == NULL || card == NULL)
+ {
+ r = CSR_WIFI_HIP_RESULT_INVALID_VALUE;
+ goto done;
+ }
+ req->value = -1;
+ if (card->dump_buf == NULL)
+ {
+ unifi_trace(card->ospriv, UDBG2, "No coredump buffers\n");
+ r = CSR_WIFI_HIP_RESULT_NOT_FOUND; /* Coredumping disabled */
+ goto done;
+ }
+ if (card->dump_cur_read == NULL)
+ {
+ unifi_trace(card->ospriv, UDBG4, "No coredumps captured\n");
+ r = CSR_WIFI_HIP_RESULT_NOT_FOUND; /* No coredump yet captured */
+ goto done;
+ }
+
+ /* Find the requested dump buffer */
+ switch (req->index)
+ {
+ case 0: /* Newest */
+ find_dump = card->dump_cur_read;
+ break;
+ case -1: /* Oldest: The next used slot forward */
+ for (find_dump = card->dump_cur_read->next;
+ (find_dump->count == 0) && (find_dump != card->dump_cur_read);
+ find_dump = card->dump_cur_read->next)
+ {
+ }
+ break;
+ default: /* Number of steps back from current read position */
+ for (i = 0, find_dump = card->dump_cur_read;
+ i < req->index;
+ i++, find_dump = find_dump->prev)
+ {
+ /* Walk the list for the index'th entry, but
+ * stop when about to wrap. */
+ unifi_trace(card->ospriv, UDBG6,
+ "%d: %d, @%p, p=%p, n=%p, cr=%p, h=%p\n",
+ i, find_dump->count, find_dump, find_dump->prev,
+ find_dump->next, card->dump_cur_read, card->dump_buf);
+ if (find_dump->prev == card->dump_cur_read)
+ {
+ /* Wrapped but still not found, index out of range */
+ if (i != req->index)
+ {
+ unifi_trace(card->ospriv, UDBG6,
+ "Dump index %d not found %d\n", req->index, i);
+ r = CSR_WIFI_HIP_RESULT_NOT_FOUND;
+ goto done;
+ }
+ break;
+ }
+ }
+ break;
+ }
+
+ /* Check if the slot is actually filled with a core dump */
+ if (find_dump->count == 0)
+ {
+ unifi_trace(card->ospriv, UDBG4, "Not captured %d\n", req->index);
+ r = CSR_WIFI_HIP_RESULT_NOT_FOUND;
+ goto done;
+ }
+
+ unifi_trace(card->ospriv, UDBG6, "Req index %d, found seq %d at step %d\n",
+ req->index, find_dump->count, i);
+
+ /* Find the appropriate entry in the buffer */
+ req->value = get_value_from_coredump(find_dump, req->space, (u16)req->offset);
+ if (req->value < 0)
+ {
+ r = CSR_WIFI_HIP_RESULT_RANGE; /* Un-captured register */
+ unifi_trace(card->ospriv, UDBG4,
+ "Can't read space %d, reg 0x%x from coredump buffer %d\n",
+ req->space, req->offset, req->index);
+ }
+ else
+ {
+ r = CSR_RESULT_SUCCESS;
+ }
+
+ /* Update the private request structure with the found values */
+ req->chip_ver = find_dump->chip_ver;
+ req->fw_ver = find_dump->fw_ver;
+ req->timestamp = find_dump->timestamp;
+ req->requestor = find_dump->requestor;
+ req->serial = find_dump->count;
+
+done:
+ func_exit_r(r);
+ return r;
+} /* unifi_coredump_get_value() */
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * unifi_coredump_read_zone
+ *
+ * Captures a UniFi memory zone into a buffer on the host
+ *
+ * Arguments:
+ * card Pointer to card struct
+ * zonebuf Pointer to on-host buffer to dump the memory zone into
+ * def Pointer to description of the memory zone to read from UniFi.
+ *
+ * Returns:
+ * CSR_RESULT_SUCCESS on success, or:
+ * CSR_RESULT_FAILURE SDIO error
+ * CSR_WIFI_HIP_RESULT_INVALID_VALUE Parameter error
+ *
+ * Notes:
+ * It is assumed that the caller has already stopped the XAPs
+ * ---------------------------------------------------------------------------
+ */
+static CsrResult unifi_coredump_read_zone(card_t *card, u16 *zonebuf, const struct coredump_zone *def)
+{
+ CsrResult r;
+
+ func_enter();
+
+ if (zonebuf == NULL || def == NULL)
+ {
+ r = CSR_WIFI_HIP_RESULT_INVALID_VALUE;
+ goto done;
+ }
+
+ /* Select XAP CPU if necessary */
+ if (def->cpu != UNIFI_PROC_INVALID)
+ {
+ if (def->cpu != UNIFI_PROC_MAC && def->cpu != UNIFI_PROC_PHY)
+ {
+ r = CSR_WIFI_HIP_RESULT_INVALID_VALUE;
+ goto done;
+ }
+ r = unifi_set_proc_select(card, def->cpu);
+ if (r != CSR_RESULT_SUCCESS)
+ {
+ goto done;
+ }
+ }
+
+ unifi_trace(card->ospriv, UDBG4,
+ "Dump sp %d, offs 0x%04x, 0x%04x words @GP=%08x CPU %d\n",
+ def->space, def->offset, def->length, def->gp, def->cpu);
+
+ /* Read on-chip RAM (byte-wise) */
+ r = unifi_card_readn(card, def->gp, zonebuf, (u16)(def->length * 2));
+ if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
+ {
+ goto done;
+ }
+ if (r != CSR_RESULT_SUCCESS)
+ {
+ unifi_error(card->ospriv, "Can't read UniFi shared data area\n");
+ goto done;
+ }
+
+done:
+ func_exit_r(r);
+ return r;
+}
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * unifi_coredump_read_zones
+ *
+ * Walks through the table of on-chip memory zones defined in zonedef_table,
+ * and reads each of them from the UniFi chip
+ *
+ * Arguments:
+ * card Pointer to card struct
+ * dump_buf Buffer into which register values will be dumped
+ *
+ * Returns:
+ * CSR_RESULT_SUCCESS on success, or:
+ * CSR_RESULT_FAILURE SDIO error
+ * CSR_WIFI_HIP_RESULT_INVALID_VALUE Parameter error
+ *
+ * Notes:
+ * It is assumed that the caller has already stopped the XAPs
+ * ---------------------------------------------------------------------------
+ */
+static CsrResult unifi_coredump_read_zones(card_t *card, coredump_buffer *dump_buf)
+{
+ CsrResult r = CSR_RESULT_SUCCESS;
+ s32 i;
+
+ func_enter();
+
+ /* Walk the table of coredump zone definitions and read them from the chip */
+ for (i = 0;
+ (i < HIP_CDUMP_NUM_ZONES) && (r == 0);
+ i++)
+ {
+ r = unifi_coredump_read_zone(card, dump_buf->zone[i], &zonedef_table[i]);
+ }
+
+ func_exit_r(r);
+ return r;
+}
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * unifi_coredump_from_sdio
+ *
+ * Capture the status of the UniFi processors, over SDIO
+ *
+ * Arguments:
+ * card Pointer to card struct
+ * reg_buffer Buffer into which register values will be dumped
+ *
+ * Returns:
+ * CSR_RESULT_SUCCESS on success, or:
+ * CSR_RESULT_FAILURE SDIO error
+ * CSR_WIFI_HIP_RESULT_INVALID_VALUE Parameter error
+ *
+ * Notes:
+ * ---------------------------------------------------------------------------
+ */
+static CsrResult unifi_coredump_from_sdio(card_t *card, coredump_buffer *dump_buf)
+{
+ u16 val;
+ CsrResult r;
+ u32 sdio_addr;
+
+ func_enter();
+
+ if (dump_buf == NULL)
+ {
+ r = CSR_WIFI_HIP_RESULT_INVALID_VALUE;
+ goto done;
+ }
+
+
+ /* Chip and firmware version */
+ unifi_trace(card->ospriv, UDBG4, "Get chip version\n");
+ sdio_addr = 2 * ChipHelper_GBL_CHIP_VERSION(card->helper);
+ if (sdio_addr != 0)
+ {
+ r = unifi_read_direct16(card, sdio_addr, &val);
+ if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
+ {
+ goto done;
+ }
+ if (r != CSR_RESULT_SUCCESS)
+ {
+ unifi_error(card->ospriv, "Can't read GBL_CHIP_VERSION\n");
+ goto done;
+ }
+ }
+ dump_buf->chip_ver = val;
+ dump_buf->fw_ver = card->build_id;
+
+ unifi_trace(card->ospriv, UDBG4, "chip_ver 0x%04x, fw_ver %u\n",
+ dump_buf->chip_ver, dump_buf->fw_ver);
+
+ /* Capture the memory zones required from UniFi */
+ r = unifi_coredump_read_zones(card, dump_buf);
+ if (r == CSR_WIFI_HIP_RESULT_NO_DEVICE)
+ {
+ goto done;
+ }
+ if (r != CSR_RESULT_SUCCESS)
+ {
+ unifi_error(card->ospriv, "Can't read UniFi memory areas\n");
+ goto done;
+ }
+
+done:
+ func_exit_r(r);
+ return r;
+} /* unifi_coredump_from_sdio() */
+
+
+#ifndef UNIFI_DISABLE_COREDUMP
+/*
+ * ---------------------------------------------------------------------------
+ * new_coredump_node
+ *
+ * Allocates a coredump linked-list node, and links it to the previous.
+ *
+ * Arguments:
+ * ospriv OS context
+ * prevnode Previous node to link into
+ *
+ * Returns:
+ * Pointer to valid coredump_buffer on success
+ * NULL on memory allocation failure
+ *
+ * Notes:
+ * Allocates "all or nothing"
+ * ---------------------------------------------------------------------------
+ */
+static
+coredump_buffer* new_coredump_node(void *ospriv, coredump_buffer *prevnode)
+{
+ coredump_buffer *newnode = NULL;
+ u16 *newzone = NULL;
+ s32 i;
+ u32 zone_size;
+
+ /* Allocate node header */
+ newnode = kzalloc(sizeof(coredump_buffer), GFP_KERNEL);
+ if (newnode == NULL)
+ {
+ return NULL;
+ }
+
+ /* Allocate chip memory zone capture buffers */
+ for (i = 0; i < HIP_CDUMP_NUM_ZONES; i++)
+ {
+ zone_size = sizeof(u16) * zonedef_table[i].length;
+ newzone = kzalloc(zone_size, GFP_KERNEL);
+ newnode->zone[i] = newzone;
+ if (newzone == NULL)
+ {
+ unifi_error(ospriv, "Out of memory on coredump zone %d (%d words)\n",
+ i, zonedef_table[i].length);
+ break;
+ }
+ }
+
+ /* Clean up if any zone alloc failed */
+ if (newzone == NULL)
+ {
+ for (i = 0; newnode->zone[i] != NULL; i++)
+ {
+ kfree(newnode->zone[i]);
+ newnode->zone[i] = NULL;
+ }
+ }
+
+ /* Link to previous node */
+ newnode->prev = prevnode;
+ if (prevnode)
+ {
+ prevnode->next = newnode;
+ }
+ newnode->next = NULL;
+
+ return newnode;
+}
+
+
+#endif /* UNIFI_DISABLE_COREDUMP */
+
+/*
+ * ---------------------------------------------------------------------------
+ * unifi_coredump_init
+ *
+ * Allocates buffers for the automatic SDIO core dump
+ *
+ * Arguments:
+ * card Pointer to card struct
+ * num_dump_buffers Number of buffers to reserve for coredumps
+ *
+ * Returns:
+ * CSR_RESULT_SUCCESS on success, or:
+ * CSR_WIFI_HIP_RESULT_NO_MEMORY memory allocation failed
+ *
+ * Notes:
+ * Allocates space in advance, to be used for the last n coredump buffers
+ * the intention being that the size is sufficient for at least one dump,
+ * probably several.
+ * It's probably advisable to have at least 2 coredump buffers to allow
+ * one to be enquired with the unifi_coredump tool, while leaving another
+ * free for capturing.
+ * ---------------------------------------------------------------------------
+ */
+CsrResult unifi_coredump_init(card_t *card, u16 num_dump_buffers)
+{
+#ifndef UNIFI_DISABLE_COREDUMP
+ void *ospriv = card->ospriv;
+ coredump_buffer *prev = NULL;
+ coredump_buffer *newnode = NULL;
+ u32 i = 0;
+#endif
+
+ func_enter();
+
+ card->request_coredump_on_reset = 0;
+ card->dump_next_write = NULL;
+ card->dump_cur_read = NULL;
+ card->dump_buf = NULL;
+
+#ifndef UNIFI_DISABLE_COREDUMP
+ unifi_trace(ospriv, UDBG1,
+ "Allocate buffers for %d core dumps\n", num_dump_buffers);
+ if (num_dump_buffers == 0)
+ {
+ goto done;
+ }
+
+ /* Root node */
+ card->dump_buf = new_coredump_node(ospriv, NULL);
+ if (card->dump_buf == NULL)
+ {
+ goto fail;
+ }
+ prev = card->dump_buf;
+ newnode = card->dump_buf;
+
+ /* Add each subsequent node at tail */
+ for (i = 1; i < num_dump_buffers; i++)
+ {
+ newnode = new_coredump_node(ospriv, prev);
+ if (newnode == NULL)
+ {
+ goto fail;
+ }
+ prev = newnode;
+ }
+
+ /* Link the first and last nodes to make the list circular */
+ card->dump_buf->prev = newnode;
+ newnode->next = card->dump_buf;
+
+ /* Set initial r/w access pointers */
+ card->dump_next_write = card->dump_buf;
+ card->dump_cur_read = NULL;
+
+ unifi_trace(ospriv, UDBG2, "Core dump configured (%d dumps max)\n", i);
+
+done:
+#endif
+ func_exit();
+ return CSR_RESULT_SUCCESS;
+
+#ifndef UNIFI_DISABLE_COREDUMP
+fail:
+ /* Unwind what we allocated so far */
+ unifi_error(ospriv, "Out of memory allocating core dump node %d\n", i);
+ unifi_coredump_free(card);
+ func_exit();
+ return CSR_WIFI_HIP_RESULT_NO_MEMORY;
+#endif
+} /* unifi_coreump_init() */
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * unifi_coredump_free
+ *
+ * Free all memory dynamically allocated for core dump
+ *
+ * Arguments:
+ * card Pointer to card struct
+ *
+ * Returns:
+ * None
+ *
+ * Notes:
+ * ---------------------------------------------------------------------------
+ */
+void unifi_coredump_free(card_t *card)
+{
+ void *ospriv = card->ospriv;
+ coredump_buffer *node, *del_node;
+ s16 i = 0;
+ s16 j;
+
+ func_enter();
+ unifi_trace(ospriv, UDBG2, "Core dump de-configured\n");
+
+ if (card->dump_buf == NULL)
+ {
+ return;
+ }
+
+ node = card->dump_buf;
+ do
+ {
+ /* Free payload zones */
+ for (j = 0; j < HIP_CDUMP_NUM_ZONES; j++)
+ {
+ kfree(node->zone[j]);
+ node->zone[j] = NULL;
+ }
+
+ /* Detach */
+ del_node = node;
+ node = node->next;
+
+ /* Free header */
+ kfree(del_node);
+ i++;
+ } while ((node != NULL) && (node != card->dump_buf));
+
+ unifi_trace(ospriv, UDBG3, "Freed %d coredump buffers\n", i);
+
+ card->dump_buf = NULL;
+ card->dump_next_write = NULL;
+ card->dump_cur_read = NULL;
+
+ func_exit();
+} /* unifi_coredump_free() */
+
+
diff --git a/drivers/staging/csr/csr_wifi_hip_packing.c b/drivers/staging/csr/csr_wifi_hip_packing.c
new file mode 100644
index 000000000000..0768aefc6d1f
--- /dev/null
+++ b/drivers/staging/csr/csr_wifi_hip_packing.c
@@ -0,0 +1,4804 @@
+/*****************************************************************************
+
+ (c) Cambridge Silicon Radio Limited 2011
+ All rights reserved and confidential information of CSR
+
+ Refer to LICENSE.txt included with this source for details
+ on the license terms.
+
+*****************************************************************************/
+
+/* Note: this is an auto-generated file. */
+
+#include "csr_wifi_hip_signals.h"
+#include "csr_wifi_hip_unifi.h"
+#include "csr_wifi_hip_conversions.h"
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * get_packed_struct_size
+ *
+ * Examine a buffer containing a UniFi signal in wire-format.
+ * The first two bytes contain the signal ID, decode the signal ID and
+ * return the size, in bytes, of the signal, not including any bulk
+ * data.
+ *
+ * WARNING: This function is auto-generated, DO NOT EDIT!
+ *
+ * Arguments:
+ * buf Pointer to buffer to decode.
+ *
+ * Returns:
+ * 0 if the signal ID is not recognised (i.e. zero length),
+ * otherwise the number of bytes occupied by the signal in the buffer.
+ * This is useful for stepping past the signal to the object in the buffer.
+ * ---------------------------------------------------------------------------
+ */
+s32 get_packed_struct_size(const u8 *buf)
+{
+ s32 size = 0;
+ u16 sig_id;
+
+ sig_id = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(buf);
+
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ switch (sig_id)
+ {
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_SET_PACKET_FILTER_CONFIRM_ID:
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_SETKEYS_CONFIRM_ID:
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_CONFIG_QUEUE_CONFIRM_ID:
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_ADD_AUTONOMOUS_SCAN_CONFIRM_ID:
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_ADD_BLACKOUT_CONFIRM_ID:
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_DEL_BLACKOUT_REQUEST_ID:
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_GET_KEY_SEQUENCE_CONFIRM_ID:
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_SM_START_CONFIRM_ID:
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_STOP_AGGREGATION_CONFIRM_ID:
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += 48 / 8;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_DEL_TSPEC_REQUEST_ID:
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ break;
+#endif
+ case CSR_DEBUG_WORD16_INDICATION_ID:
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ break;
+ case CSR_DEBUG_GENERIC_CONFIRM_ID:
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ break;
+ case CSR_MA_PACKET_INDICATION_ID:
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT64;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ break;
+ case CSR_MLME_SET_TIM_REQUEST_ID:
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ break;
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_CONNECTED_INDICATION_ID:
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += 48 / 8;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_DEL_RX_TRIGGER_REQUEST_ID:
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_TRIGGERED_GET_INDICATION_ID:
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_SCAN_REQUEST_ID:
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT32;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_DELETEKEYS_CONFIRM_ID:
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_GET_NEXT_REQUEST_ID:
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_SET_CHANNEL_CONFIRM_ID:
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_START_AGGREGATION_REQUEST_ID:
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += 48 / 8;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_HL_SYNC_REQUEST_ID:
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += 48 / 8;
+ break;
+#endif
+ case CSR_DEBUG_GENERIC_REQUEST_ID:
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ break;
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_LEAVE_CONFIRM_ID:
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_DEL_TRIGGERED_GET_REQUEST_ID:
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_ADD_MULTICAST_ADDRESS_REQUEST_ID:
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_RESET_REQUEST_ID:
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += 48 / 8;
+ size += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_SCAN_CANCEL_REQUEST_ID:
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_ADD_TRIGGERED_GET_CONFIRM_ID:
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_SET_PACKET_FILTER_REQUEST_ID:
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT32;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_DEL_RX_TRIGGER_CONFIRM_ID:
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_CONNECT_STATUS_REQUEST_ID:
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += 48 / 8;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_LEAVE_REQUEST_ID:
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_CONFIG_QUEUE_REQUEST_ID:
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_DEL_TSPEC_CONFIRM_ID:
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ break;
+#endif
+ case CSR_MLME_SET_TIM_CONFIRM_ID:
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ break;
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_MEASURE_INDICATION_ID:
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_DEL_BLACKOUT_CONFIRM_ID:
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_DEL_TRIGGERED_GET_CONFIRM_ID:
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ break;
+#endif
+ case CSR_DEBUG_GENERIC_INDICATION_ID:
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ break;
+ case CSR_MA_PACKET_CANCEL_REQUEST_ID:
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT32;
+ break;
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_MODIFY_BSS_PARAMETER_CONFIRM_ID:
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_PAUSE_AUTONOMOUS_SCAN_CONFIRM_ID:
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ break;
+#endif
+ case CSR_MA_PACKET_REQUEST_ID:
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT32;
+ size += SIZEOF_UINT16;
+ size += 48 / 8;
+ size += SIZEOF_UINT16;
+ break;
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_MODIFY_BSS_PARAMETER_REQUEST_ID:
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += 48 / 8;
+ size += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_ADD_RX_TRIGGER_REQUEST_ID:
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ break;
+#endif
+ case CSR_MA_VIF_AVAILABILITY_INDICATION_ID:
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ break;
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_HL_SYNC_CANCEL_REQUEST_ID:
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += 48 / 8;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_DEL_AUTONOMOUS_SCAN_REQUEST_ID:
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_BLACKOUT_ENDED_INDICATION_ID:
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_AUTONOMOUS_SCAN_DONE_INDICATION_ID:
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_GET_KEY_SEQUENCE_REQUEST_ID:
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += 48 / 8;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_SET_CHANNEL_REQUEST_ID:
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += 48 / 8;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_MEASURE_CONFIRM_ID:
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_ADD_TRIGGERED_GET_REQUEST_ID:
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_AUTONOMOUS_SCAN_LOSS_INDICATION_ID:
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += 48 / 8;
+ break;
+#endif
+ case CSR_MA_VIF_AVAILABILITY_RESPONSE_ID:
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ break;
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_ADD_TEMPLATE_REQUEST_ID:
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_POWERMGT_CONFIRM_ID:
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_ADD_PERIODIC_CONFIRM_ID:
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_GET_CONFIRM_ID:
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_GET_NEXT_CONFIRM_ID:
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_STOP_AGGREGATION_REQUEST_ID:
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += 48 / 8;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_ADD_RX_TRIGGER_CONFIRM_ID:
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_ADD_BLACKOUT_REQUEST_ID:
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT32;
+ size += SIZEOF_UINT32;
+ size += SIZEOF_UINT32;
+ size += 48 / 8;
+ size += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_DELETEKEYS_REQUEST_ID:
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += 48 / 8;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_RESET_CONFIRM_ID:
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_HL_SYNC_CONFIRM_ID:
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += 48 / 8;
+ size += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_ADD_AUTONOMOUS_SCAN_REQUEST_ID:
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT32;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_SET_REQUEST_ID:
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_SM_START_REQUEST_ID:
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += 48 / 8;
+ size += 48 / 8;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_CONNECT_STATUS_CONFIRM_ID:
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_DEL_AUTONOMOUS_SCAN_CONFIRM_ID:
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_DEL_PERIODIC_REQUEST_ID:
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_SETKEYS_REQUEST_ID:
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += 48 / 8;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += 32 / 8;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_PAUSE_AUTONOMOUS_SCAN_REQUEST_ID:
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_GET_REQUEST_ID:
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_POWERMGT_REQUEST_ID:
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ break;
+#endif
+ case CSR_MA_PACKET_ERROR_INDICATION_ID:
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += 48 / 8;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ break;
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_ADD_PERIODIC_REQUEST_ID:
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT32;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_ADD_TSPEC_REQUEST_ID:
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT32;
+ size += SIZEOF_UINT32;
+ size += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_ADD_MULTICAST_ADDRESS_CONFIRM_ID:
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_ADD_TSPEC_CONFIRM_ID:
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_HL_SYNC_CANCEL_CONFIRM_ID:
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_SCAN_CONFIRM_ID:
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ break;
+#endif
+ case CSR_DEBUG_STRING_INDICATION_ID:
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ break;
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_ADD_TEMPLATE_CONFIRM_ID:
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_BLOCKACK_ERROR_INDICATION_ID:
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += 48 / 8;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_SET_CONFIRM_ID:
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_MEASURE_REQUEST_ID:
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_START_AGGREGATION_CONFIRM_ID:
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += 48 / 8;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_STOP_MEASURE_CONFIRM_ID:
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ break;
+#endif
+ case CSR_MA_PACKET_CONFIRM_ID:
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT32;
+ break;
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_DEL_PERIODIC_CONFIRM_ID:
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_STOP_MEASURE_REQUEST_ID:
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ size += SIZEOF_UINT16;
+ break;
+#endif
+ default:
+ size = 0;
+ }
+ return size;
+} /* get_packed_struct_size() */
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * read_unpack_signal
+ *
+ * Unpack a wire-format signal into a host-native structure.
+ * This function handles any necessary conversions for endianness and
+ * places no restrictions on packing or alignment for the structure
+ * definition.
+ *
+ * WARNING: This function is auto-generated, DO NOT EDIT!
+ *
+ * Arguments:
+ * ptr Signal buffer to unpack.
+ * sig Pointer to destination structure to populate.
+ *
+ * Returns:
+ * CSR_RESULT_SUCCESS on success,
+ * CSR_WIFI_HIP_RESULT_INVALID_VALUE if the ID of signal was not recognised.
+ * ---------------------------------------------------------------------------
+ */
+CsrResult read_unpack_signal(const u8 *ptr, CSR_SIGNAL *sig)
+{
+ s32 index = 0;
+
+ sig->SignalPrimitiveHeader.SignalId = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+
+ sig->SignalPrimitiveHeader.ReceiverProcessId = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+
+ sig->SignalPrimitiveHeader.SenderProcessId = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+
+ switch (sig->SignalPrimitiveHeader.SignalId)
+ {
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_SET_PACKET_FILTER_CONFIRM_ID:
+ sig->u.MlmeSetPacketFilterConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeSetPacketFilterConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeSetPacketFilterConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeSetPacketFilterConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeSetPacketFilterConfirm.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeSetPacketFilterConfirm.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_SETKEYS_CONFIRM_ID:
+ sig->u.MlmeSetkeysConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeSetkeysConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeSetkeysConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeSetkeysConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeSetkeysConfirm.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeSetkeysConfirm.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_CONFIG_QUEUE_CONFIRM_ID:
+ sig->u.MlmeConfigQueueConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeConfigQueueConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeConfigQueueConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeConfigQueueConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeConfigQueueConfirm.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_ADD_AUTONOMOUS_SCAN_CONFIRM_ID:
+ sig->u.MlmeAddAutonomousScanConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeAddAutonomousScanConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeAddAutonomousScanConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeAddAutonomousScanConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeAddAutonomousScanConfirm.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeAddAutonomousScanConfirm.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeAddAutonomousScanConfirm.AutonomousScanId = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_ADD_BLACKOUT_CONFIRM_ID:
+ sig->u.MlmeAddBlackoutConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeAddBlackoutConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeAddBlackoutConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeAddBlackoutConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeAddBlackoutConfirm.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeAddBlackoutConfirm.BlackoutId = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeAddBlackoutConfirm.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_DEL_BLACKOUT_REQUEST_ID:
+ sig->u.MlmeDelBlackoutRequest.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeDelBlackoutRequest.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeDelBlackoutRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeDelBlackoutRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeDelBlackoutRequest.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeDelBlackoutRequest.BlackoutId = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_GET_KEY_SEQUENCE_CONFIRM_ID:
+ sig->u.MlmeGetKeySequenceConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeGetKeySequenceConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeGetKeySequenceConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeGetKeySequenceConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeGetKeySequenceConfirm.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeGetKeySequenceConfirm.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeGetKeySequenceConfirm.SequenceNumber[0] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeGetKeySequenceConfirm.SequenceNumber[1] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeGetKeySequenceConfirm.SequenceNumber[2] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeGetKeySequenceConfirm.SequenceNumber[3] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeGetKeySequenceConfirm.SequenceNumber[4] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeGetKeySequenceConfirm.SequenceNumber[5] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeGetKeySequenceConfirm.SequenceNumber[6] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeGetKeySequenceConfirm.SequenceNumber[7] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_SM_START_CONFIRM_ID:
+ sig->u.MlmeSmStartConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeSmStartConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeSmStartConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeSmStartConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeSmStartConfirm.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeSmStartConfirm.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_STOP_AGGREGATION_CONFIRM_ID:
+ sig->u.MlmeStopAggregationConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeStopAggregationConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeStopAggregationConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeStopAggregationConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeStopAggregationConfirm.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ memcpy(sig->u.MlmeStopAggregationConfirm.PeerQstaAddress.x, &ptr[index], 48 / 8);
+ index += 48 / 8;
+ sig->u.MlmeStopAggregationConfirm.UserPriority = (CSR_PRIORITY) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeStopAggregationConfirm.Direction = (CSR_DIRECTION) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeStopAggregationConfirm.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_DEL_TSPEC_REQUEST_ID:
+ sig->u.MlmeDelTspecRequest.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeDelTspecRequest.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeDelTspecRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeDelTspecRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeDelTspecRequest.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeDelTspecRequest.UserPriority = (CSR_PRIORITY) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeDelTspecRequest.Direction = (CSR_DIRECTION) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ break;
+#endif
+ case CSR_DEBUG_WORD16_INDICATION_ID:
+ sig->u.DebugWord16Indication.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.DebugWord16Indication.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.DebugWord16Indication.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.DebugWord16Indication.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.DebugWord16Indication.DebugWords[0] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.DebugWord16Indication.DebugWords[1] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.DebugWord16Indication.DebugWords[2] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.DebugWord16Indication.DebugWords[3] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.DebugWord16Indication.DebugWords[4] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.DebugWord16Indication.DebugWords[5] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.DebugWord16Indication.DebugWords[6] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.DebugWord16Indication.DebugWords[7] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.DebugWord16Indication.DebugWords[8] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.DebugWord16Indication.DebugWords[9] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.DebugWord16Indication.DebugWords[10] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.DebugWord16Indication.DebugWords[11] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.DebugWord16Indication.DebugWords[12] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.DebugWord16Indication.DebugWords[13] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.DebugWord16Indication.DebugWords[14] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.DebugWord16Indication.DebugWords[15] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ break;
+ case CSR_DEBUG_GENERIC_CONFIRM_ID:
+ sig->u.DebugGenericConfirm.DebugVariable.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.DebugGenericConfirm.DebugVariable.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.DebugGenericConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.DebugGenericConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.DebugGenericConfirm.DebugWords[0] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.DebugGenericConfirm.DebugWords[1] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.DebugGenericConfirm.DebugWords[2] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.DebugGenericConfirm.DebugWords[3] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.DebugGenericConfirm.DebugWords[4] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.DebugGenericConfirm.DebugWords[5] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.DebugGenericConfirm.DebugWords[6] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.DebugGenericConfirm.DebugWords[7] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ break;
+ case CSR_MA_PACKET_INDICATION_ID:
+ sig->u.MaPacketIndication.Data.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MaPacketIndication.Data.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MaPacketIndication.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MaPacketIndication.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MaPacketIndication.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ memcpy(sig->u.MaPacketIndication.LocalTime.x, &ptr[index], 64 / 8);
+ index += 64 / 8;
+ sig->u.MaPacketIndication.Ifindex = (CSR_IFINTERFACE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MaPacketIndication.Channel = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MaPacketIndication.ReceptionStatus = (CSR_RECEPTION_STATUS) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MaPacketIndication.Rssi = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MaPacketIndication.Snr = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MaPacketIndication.ReceivedRate = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ break;
+ case CSR_MLME_SET_TIM_REQUEST_ID:
+ sig->u.MlmeSetTimRequest.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeSetTimRequest.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeSetTimRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeSetTimRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeSetTimRequest.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeSetTimRequest.AssociationId = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeSetTimRequest.TimValue = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ break;
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_CONNECTED_INDICATION_ID:
+ sig->u.MlmeConnectedIndication.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeConnectedIndication.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeConnectedIndication.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeConnectedIndication.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeConnectedIndication.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeConnectedIndication.ConnectionStatus = (CSR_CONNECTION_STATUS) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ memcpy(sig->u.MlmeConnectedIndication.PeerMacAddress.x, &ptr[index], 48 / 8);
+ index += 48 / 8;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_DEL_RX_TRIGGER_REQUEST_ID:
+ sig->u.MlmeDelRxTriggerRequest.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeDelRxTriggerRequest.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeDelRxTriggerRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeDelRxTriggerRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeDelRxTriggerRequest.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeDelRxTriggerRequest.TriggerId = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_TRIGGERED_GET_INDICATION_ID:
+ sig->u.MlmeTriggeredGetIndication.MibAttributeValue.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeTriggeredGetIndication.MibAttributeValue.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeTriggeredGetIndication.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeTriggeredGetIndication.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeTriggeredGetIndication.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeTriggeredGetIndication.Status = (CSR_MIB_STATUS) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeTriggeredGetIndication.ErrorIndex = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeTriggeredGetIndication.TriggeredId = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_SCAN_REQUEST_ID:
+ sig->u.MlmeScanRequest.ChannelList.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeScanRequest.ChannelList.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeScanRequest.InformationElements.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeScanRequest.InformationElements.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeScanRequest.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeScanRequest.Ifindex = (CSR_IFINTERFACE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeScanRequest.ScanType = (CSR_SCAN_TYPE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeScanRequest.ProbeDelay = CSR_GET_UINT32_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT32;
+ sig->u.MlmeScanRequest.MinChannelTime = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeScanRequest.MaxChannelTime = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_DELETEKEYS_CONFIRM_ID:
+ sig->u.MlmeDeletekeysConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeDeletekeysConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeDeletekeysConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeDeletekeysConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeDeletekeysConfirm.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeDeletekeysConfirm.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_GET_NEXT_REQUEST_ID:
+ sig->u.MlmeGetNextRequest.MibAttribute.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeGetNextRequest.MibAttribute.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeGetNextRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeGetNextRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_SET_CHANNEL_CONFIRM_ID:
+ sig->u.MlmeSetChannelConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeSetChannelConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeSetChannelConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeSetChannelConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeSetChannelConfirm.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeSetChannelConfirm.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_START_AGGREGATION_REQUEST_ID:
+ sig->u.MlmeStartAggregationRequest.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeStartAggregationRequest.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeStartAggregationRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeStartAggregationRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeStartAggregationRequest.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ memcpy(sig->u.MlmeStartAggregationRequest.PeerQstaAddress.x, &ptr[index], 48 / 8);
+ index += 48 / 8;
+ sig->u.MlmeStartAggregationRequest.UserPriority = (CSR_PRIORITY) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeStartAggregationRequest.Direction = (CSR_DIRECTION) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeStartAggregationRequest.StartingSequenceNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeStartAggregationRequest.BufferSize = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeStartAggregationRequest.BlockAckTimeout = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_HL_SYNC_REQUEST_ID:
+ sig->u.MlmeHlSyncRequest.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeHlSyncRequest.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeHlSyncRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeHlSyncRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ memcpy(sig->u.MlmeHlSyncRequest.GroupAddress.x, &ptr[index], 48 / 8);
+ index += 48 / 8;
+ break;
+#endif
+ case CSR_DEBUG_GENERIC_REQUEST_ID:
+ sig->u.DebugGenericRequest.DebugVariable.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.DebugGenericRequest.DebugVariable.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.DebugGenericRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.DebugGenericRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.DebugGenericRequest.DebugWords[0] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.DebugGenericRequest.DebugWords[1] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.DebugGenericRequest.DebugWords[2] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.DebugGenericRequest.DebugWords[3] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.DebugGenericRequest.DebugWords[4] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.DebugGenericRequest.DebugWords[5] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.DebugGenericRequest.DebugWords[6] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.DebugGenericRequest.DebugWords[7] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ break;
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_LEAVE_CONFIRM_ID:
+ sig->u.MlmeLeaveConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeLeaveConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeLeaveConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeLeaveConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeLeaveConfirm.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeLeaveConfirm.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_DEL_TRIGGERED_GET_REQUEST_ID:
+ sig->u.MlmeDelTriggeredGetRequest.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeDelTriggeredGetRequest.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeDelTriggeredGetRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeDelTriggeredGetRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeDelTriggeredGetRequest.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeDelTriggeredGetRequest.TriggeredId = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_ADD_MULTICAST_ADDRESS_REQUEST_ID:
+ sig->u.MlmeAddMulticastAddressRequest.Data.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeAddMulticastAddressRequest.Data.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeAddMulticastAddressRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeAddMulticastAddressRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeAddMulticastAddressRequest.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeAddMulticastAddressRequest.NumberOfMulticastGroupAddresses = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_RESET_REQUEST_ID:
+ sig->u.MlmeResetRequest.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeResetRequest.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeResetRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeResetRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ memcpy(sig->u.MlmeResetRequest.StaAddress.x, &ptr[index], 48 / 8);
+ index += 48 / 8;
+ sig->u.MlmeResetRequest.SetDefaultMib = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_SCAN_CANCEL_REQUEST_ID:
+ sig->u.MlmeScanCancelRequest.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeScanCancelRequest.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeScanCancelRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeScanCancelRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeScanCancelRequest.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_ADD_TRIGGERED_GET_CONFIRM_ID:
+ sig->u.MlmeAddTriggeredGetConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeAddTriggeredGetConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeAddTriggeredGetConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeAddTriggeredGetConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeAddTriggeredGetConfirm.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeAddTriggeredGetConfirm.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeAddTriggeredGetConfirm.TriggeredId = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_SET_PACKET_FILTER_REQUEST_ID:
+ sig->u.MlmeSetPacketFilterRequest.InformationElements.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeSetPacketFilterRequest.InformationElements.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeSetPacketFilterRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeSetPacketFilterRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeSetPacketFilterRequest.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeSetPacketFilterRequest.PacketFilterMode = (CSR_PACKET_FILTER_MODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeSetPacketFilterRequest.ArpFilterAddress = CSR_GET_UINT32_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT32;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_DEL_RX_TRIGGER_CONFIRM_ID:
+ sig->u.MlmeDelRxTriggerConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeDelRxTriggerConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeDelRxTriggerConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeDelRxTriggerConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeDelRxTriggerConfirm.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeDelRxTriggerConfirm.TriggerId = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeDelRxTriggerConfirm.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_CONNECT_STATUS_REQUEST_ID:
+ sig->u.MlmeConnectStatusRequest.InformationElements.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeConnectStatusRequest.InformationElements.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeConnectStatusRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeConnectStatusRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeConnectStatusRequest.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeConnectStatusRequest.ConnectionStatus = (CSR_CONNECTION_STATUS) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ memcpy(sig->u.MlmeConnectStatusRequest.StaAddress.x, &ptr[index], 48 / 8);
+ index += 48 / 8;
+ sig->u.MlmeConnectStatusRequest.AssociationId = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeConnectStatusRequest.AssociationCapabilityInformation = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_LEAVE_REQUEST_ID:
+ sig->u.MlmeLeaveRequest.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeLeaveRequest.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeLeaveRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeLeaveRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeLeaveRequest.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_CONFIG_QUEUE_REQUEST_ID:
+ sig->u.MlmeConfigQueueRequest.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeConfigQueueRequest.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeConfigQueueRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeConfigQueueRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeConfigQueueRequest.QueueIndex = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeConfigQueueRequest.Aifs = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeConfigQueueRequest.Cwmin = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeConfigQueueRequest.Cwmax = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeConfigQueueRequest.TxopLimit = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_DEL_TSPEC_CONFIRM_ID:
+ sig->u.MlmeDelTspecConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeDelTspecConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeDelTspecConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeDelTspecConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeDelTspecConfirm.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeDelTspecConfirm.UserPriority = (CSR_PRIORITY) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeDelTspecConfirm.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ break;
+#endif
+ case CSR_MLME_SET_TIM_CONFIRM_ID:
+ sig->u.MlmeSetTimConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeSetTimConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeSetTimConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeSetTimConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeSetTimConfirm.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeSetTimConfirm.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ break;
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_MEASURE_INDICATION_ID:
+ sig->u.MlmeMeasureIndication.MeasurementReportSet.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeMeasureIndication.MeasurementReportSet.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeMeasureIndication.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeMeasureIndication.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeMeasureIndication.DialogToken = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_DEL_BLACKOUT_CONFIRM_ID:
+ sig->u.MlmeDelBlackoutConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeDelBlackoutConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeDelBlackoutConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeDelBlackoutConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeDelBlackoutConfirm.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeDelBlackoutConfirm.BlackoutId = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeDelBlackoutConfirm.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_DEL_TRIGGERED_GET_CONFIRM_ID:
+ sig->u.MlmeDelTriggeredGetConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeDelTriggeredGetConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeDelTriggeredGetConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeDelTriggeredGetConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeDelTriggeredGetConfirm.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeDelTriggeredGetConfirm.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeDelTriggeredGetConfirm.TriggeredId = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ break;
+#endif
+ case CSR_DEBUG_GENERIC_INDICATION_ID:
+ sig->u.DebugGenericIndication.DebugVariable.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.DebugGenericIndication.DebugVariable.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.DebugGenericIndication.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.DebugGenericIndication.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.DebugGenericIndication.DebugWords[0] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.DebugGenericIndication.DebugWords[1] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.DebugGenericIndication.DebugWords[2] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.DebugGenericIndication.DebugWords[3] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.DebugGenericIndication.DebugWords[4] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.DebugGenericIndication.DebugWords[5] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.DebugGenericIndication.DebugWords[6] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.DebugGenericIndication.DebugWords[7] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ break;
+ case CSR_MA_PACKET_CANCEL_REQUEST_ID:
+ sig->u.MaPacketCancelRequest.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MaPacketCancelRequest.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MaPacketCancelRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MaPacketCancelRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MaPacketCancelRequest.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MaPacketCancelRequest.HostTag = CSR_GET_UINT32_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT32;
+ break;
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_MODIFY_BSS_PARAMETER_CONFIRM_ID:
+ sig->u.MlmeModifyBssParameterConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeModifyBssParameterConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeModifyBssParameterConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeModifyBssParameterConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeModifyBssParameterConfirm.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeModifyBssParameterConfirm.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_PAUSE_AUTONOMOUS_SCAN_CONFIRM_ID:
+ sig->u.MlmePauseAutonomousScanConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmePauseAutonomousScanConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmePauseAutonomousScanConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmePauseAutonomousScanConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmePauseAutonomousScanConfirm.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmePauseAutonomousScanConfirm.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmePauseAutonomousScanConfirm.AutonomousScanId = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ break;
+#endif
+ case CSR_MA_PACKET_REQUEST_ID:
+ sig->u.MaPacketRequest.Data.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MaPacketRequest.Data.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MaPacketRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MaPacketRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MaPacketRequest.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MaPacketRequest.TransmitRate = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MaPacketRequest.HostTag = CSR_GET_UINT32_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT32;
+ sig->u.MaPacketRequest.Priority = (CSR_PRIORITY) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ memcpy(sig->u.MaPacketRequest.Ra.x, &ptr[index], 48 / 8);
+ index += 48 / 8;
+ sig->u.MaPacketRequest.TransmissionControl = (CSR_TRANSMISSION_CONTROL) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ break;
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_MODIFY_BSS_PARAMETER_REQUEST_ID:
+ sig->u.MlmeModifyBssParameterRequest.Data.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeModifyBssParameterRequest.Data.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeModifyBssParameterRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeModifyBssParameterRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeModifyBssParameterRequest.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeModifyBssParameterRequest.BeaconPeriod = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeModifyBssParameterRequest.DtimPeriod = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeModifyBssParameterRequest.CapabilityInformation = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ memcpy(sig->u.MlmeModifyBssParameterRequest.Bssid.x, &ptr[index], 48 / 8);
+ index += 48 / 8;
+ sig->u.MlmeModifyBssParameterRequest.RtsThreshold = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_ADD_RX_TRIGGER_REQUEST_ID:
+ sig->u.MlmeAddRxTriggerRequest.InformationElements.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeAddRxTriggerRequest.InformationElements.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeAddRxTriggerRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeAddRxTriggerRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeAddRxTriggerRequest.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeAddRxTriggerRequest.TriggerId = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeAddRxTriggerRequest.Priority = (CSR_PRIORITY) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ break;
+#endif
+ case CSR_MA_VIF_AVAILABILITY_INDICATION_ID:
+ sig->u.MaVifAvailabilityIndication.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MaVifAvailabilityIndication.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MaVifAvailabilityIndication.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MaVifAvailabilityIndication.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MaVifAvailabilityIndication.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MaVifAvailabilityIndication.Multicast = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ break;
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_HL_SYNC_CANCEL_REQUEST_ID:
+ sig->u.MlmeHlSyncCancelRequest.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeHlSyncCancelRequest.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeHlSyncCancelRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeHlSyncCancelRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ memcpy(sig->u.MlmeHlSyncCancelRequest.GroupAddress.x, &ptr[index], 48 / 8);
+ index += 48 / 8;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_DEL_AUTONOMOUS_SCAN_REQUEST_ID:
+ sig->u.MlmeDelAutonomousScanRequest.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeDelAutonomousScanRequest.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeDelAutonomousScanRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeDelAutonomousScanRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeDelAutonomousScanRequest.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeDelAutonomousScanRequest.AutonomousScanId = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_BLACKOUT_ENDED_INDICATION_ID:
+ sig->u.MlmeBlackoutEndedIndication.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeBlackoutEndedIndication.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeBlackoutEndedIndication.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeBlackoutEndedIndication.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeBlackoutEndedIndication.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeBlackoutEndedIndication.BlackoutId = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_AUTONOMOUS_SCAN_DONE_INDICATION_ID:
+ sig->u.MlmeAutonomousScanDoneIndication.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeAutonomousScanDoneIndication.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeAutonomousScanDoneIndication.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeAutonomousScanDoneIndication.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeAutonomousScanDoneIndication.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeAutonomousScanDoneIndication.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeAutonomousScanDoneIndication.AutonomousScanId = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_GET_KEY_SEQUENCE_REQUEST_ID:
+ sig->u.MlmeGetKeySequenceRequest.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeGetKeySequenceRequest.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeGetKeySequenceRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeGetKeySequenceRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeGetKeySequenceRequest.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeGetKeySequenceRequest.KeyId = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeGetKeySequenceRequest.KeyType = (CSR_KEY_TYPE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ memcpy(sig->u.MlmeGetKeySequenceRequest.Address.x, &ptr[index], 48 / 8);
+ index += 48 / 8;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_SET_CHANNEL_REQUEST_ID:
+ sig->u.MlmeSetChannelRequest.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeSetChannelRequest.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeSetChannelRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeSetChannelRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeSetChannelRequest.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeSetChannelRequest.Ifindex = (CSR_IFINTERFACE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeSetChannelRequest.Channel = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ memcpy(sig->u.MlmeSetChannelRequest.Address.x, &ptr[index], 48 / 8);
+ index += 48 / 8;
+ sig->u.MlmeSetChannelRequest.AvailabilityDuration = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeSetChannelRequest.AvailabilityInterval = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_MEASURE_CONFIRM_ID:
+ sig->u.MlmeMeasureConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeMeasureConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeMeasureConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeMeasureConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeMeasureConfirm.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeMeasureConfirm.DialogToken = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_ADD_TRIGGERED_GET_REQUEST_ID:
+ sig->u.MlmeAddTriggeredGetRequest.MibAttribute.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeAddTriggeredGetRequest.MibAttribute.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeAddTriggeredGetRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeAddTriggeredGetRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeAddTriggeredGetRequest.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeAddTriggeredGetRequest.TriggeredId = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_AUTONOMOUS_SCAN_LOSS_INDICATION_ID:
+ sig->u.MlmeAutonomousScanLossIndication.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeAutonomousScanLossIndication.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeAutonomousScanLossIndication.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeAutonomousScanLossIndication.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeAutonomousScanLossIndication.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ memcpy(sig->u.MlmeAutonomousScanLossIndication.Bssid.x, &ptr[index], 48 / 8);
+ index += 48 / 8;
+ break;
+#endif
+ case CSR_MA_VIF_AVAILABILITY_RESPONSE_ID:
+ sig->u.MaVifAvailabilityResponse.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MaVifAvailabilityResponse.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MaVifAvailabilityResponse.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MaVifAvailabilityResponse.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MaVifAvailabilityResponse.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MaVifAvailabilityResponse.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ break;
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_ADD_TEMPLATE_REQUEST_ID:
+ sig->u.MlmeAddTemplateRequest.Data1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeAddTemplateRequest.Data1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeAddTemplateRequest.Data2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeAddTemplateRequest.Data2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeAddTemplateRequest.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeAddTemplateRequest.FrameType = (CSR_FRAME_TYPE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeAddTemplateRequest.MinTransmitRate = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_POWERMGT_CONFIRM_ID:
+ sig->u.MlmePowermgtConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmePowermgtConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmePowermgtConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmePowermgtConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmePowermgtConfirm.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmePowermgtConfirm.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_ADD_PERIODIC_CONFIRM_ID:
+ sig->u.MlmeAddPeriodicConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeAddPeriodicConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeAddPeriodicConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeAddPeriodicConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeAddPeriodicConfirm.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeAddPeriodicConfirm.PeriodicId = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeAddPeriodicConfirm.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_GET_CONFIRM_ID:
+ sig->u.MlmeGetConfirm.MibAttributeValue.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeGetConfirm.MibAttributeValue.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeGetConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeGetConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeGetConfirm.Status = (CSR_MIB_STATUS) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeGetConfirm.ErrorIndex = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_GET_NEXT_CONFIRM_ID:
+ sig->u.MlmeGetNextConfirm.MibAttributeValue.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeGetNextConfirm.MibAttributeValue.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeGetNextConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeGetNextConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeGetNextConfirm.Status = (CSR_MIB_STATUS) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeGetNextConfirm.ErrorIndex = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_STOP_AGGREGATION_REQUEST_ID:
+ sig->u.MlmeStopAggregationRequest.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeStopAggregationRequest.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeStopAggregationRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeStopAggregationRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeStopAggregationRequest.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ memcpy(sig->u.MlmeStopAggregationRequest.PeerQstaAddress.x, &ptr[index], 48 / 8);
+ index += 48 / 8;
+ sig->u.MlmeStopAggregationRequest.UserPriority = (CSR_PRIORITY) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeStopAggregationRequest.Direction = (CSR_DIRECTION) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_ADD_RX_TRIGGER_CONFIRM_ID:
+ sig->u.MlmeAddRxTriggerConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeAddRxTriggerConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeAddRxTriggerConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeAddRxTriggerConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeAddRxTriggerConfirm.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeAddRxTriggerConfirm.TriggerId = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeAddRxTriggerConfirm.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_ADD_BLACKOUT_REQUEST_ID:
+ sig->u.MlmeAddBlackoutRequest.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeAddBlackoutRequest.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeAddBlackoutRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeAddBlackoutRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeAddBlackoutRequest.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeAddBlackoutRequest.BlackoutId = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeAddBlackoutRequest.BlackoutType = (CSR_BLACKOUT_TYPE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeAddBlackoutRequest.BlackoutSource = (CSR_BLACKOUT_SOURCE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeAddBlackoutRequest.BlackoutStartReference = CSR_GET_UINT32_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT32;
+ sig->u.MlmeAddBlackoutRequest.BlackoutPeriod = CSR_GET_UINT32_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT32;
+ sig->u.MlmeAddBlackoutRequest.BlackoutDuration = CSR_GET_UINT32_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT32;
+ memcpy(sig->u.MlmeAddBlackoutRequest.PeerStaAddress.x, &ptr[index], 48 / 8);
+ index += 48 / 8;
+ sig->u.MlmeAddBlackoutRequest.BlackoutCount = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_DELETEKEYS_REQUEST_ID:
+ sig->u.MlmeDeletekeysRequest.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeDeletekeysRequest.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeDeletekeysRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeDeletekeysRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeDeletekeysRequest.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeDeletekeysRequest.KeyId = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeDeletekeysRequest.KeyType = (CSR_KEY_TYPE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ memcpy(sig->u.MlmeDeletekeysRequest.Address.x, &ptr[index], 48 / 8);
+ index += 48 / 8;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_RESET_CONFIRM_ID:
+ sig->u.MlmeResetConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeResetConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeResetConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeResetConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeResetConfirm.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_HL_SYNC_CONFIRM_ID:
+ sig->u.MlmeHlSyncConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeHlSyncConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeHlSyncConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeHlSyncConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ memcpy(sig->u.MlmeHlSyncConfirm.GroupAddress.x, &ptr[index], 48 / 8);
+ index += 48 / 8;
+ sig->u.MlmeHlSyncConfirm.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_ADD_AUTONOMOUS_SCAN_REQUEST_ID:
+ sig->u.MlmeAddAutonomousScanRequest.ChannelList.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeAddAutonomousScanRequest.ChannelList.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeAddAutonomousScanRequest.InformationElements.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeAddAutonomousScanRequest.InformationElements.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeAddAutonomousScanRequest.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeAddAutonomousScanRequest.AutonomousScanId = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeAddAutonomousScanRequest.Ifindex = (CSR_IFINTERFACE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeAddAutonomousScanRequest.ChannelStartingFactor = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeAddAutonomousScanRequest.ScanType = (CSR_SCAN_TYPE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeAddAutonomousScanRequest.ProbeDelay = CSR_GET_UINT32_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT32;
+ sig->u.MlmeAddAutonomousScanRequest.MinChannelTime = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeAddAutonomousScanRequest.MaxChannelTime = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_SET_REQUEST_ID:
+ sig->u.MlmeSetRequest.MibAttributeValue.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeSetRequest.MibAttributeValue.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeSetRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeSetRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_SM_START_REQUEST_ID:
+ sig->u.MlmeSmStartRequest.Beacon.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeSmStartRequest.Beacon.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeSmStartRequest.BssParameters.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeSmStartRequest.BssParameters.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeSmStartRequest.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeSmStartRequest.Ifindex = (CSR_IFINTERFACE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeSmStartRequest.Channel = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ memcpy(sig->u.MlmeSmStartRequest.InterfaceAddress.x, &ptr[index], 48 / 8);
+ index += 48 / 8;
+ memcpy(sig->u.MlmeSmStartRequest.Bssid.x, &ptr[index], 48 / 8);
+ index += 48 / 8;
+ sig->u.MlmeSmStartRequest.BeaconPeriod = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeSmStartRequest.DtimPeriod = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeSmStartRequest.CapabilityInformation = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_CONNECT_STATUS_CONFIRM_ID:
+ sig->u.MlmeConnectStatusConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeConnectStatusConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeConnectStatusConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeConnectStatusConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeConnectStatusConfirm.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeConnectStatusConfirm.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_DEL_AUTONOMOUS_SCAN_CONFIRM_ID:
+ sig->u.MlmeDelAutonomousScanConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeDelAutonomousScanConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeDelAutonomousScanConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeDelAutonomousScanConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeDelAutonomousScanConfirm.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeDelAutonomousScanConfirm.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeDelAutonomousScanConfirm.AutonomousScanId = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_DEL_PERIODIC_REQUEST_ID:
+ sig->u.MlmeDelPeriodicRequest.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeDelPeriodicRequest.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeDelPeriodicRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeDelPeriodicRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeDelPeriodicRequest.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeDelPeriodicRequest.PeriodicId = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_SETKEYS_REQUEST_ID:
+ sig->u.MlmeSetkeysRequest.Key.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeSetkeysRequest.Key.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeSetkeysRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeSetkeysRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeSetkeysRequest.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeSetkeysRequest.Length = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeSetkeysRequest.KeyId = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeSetkeysRequest.KeyType = (CSR_KEY_TYPE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ memcpy(sig->u.MlmeSetkeysRequest.Address.x, &ptr[index], 48 / 8);
+ index += 48 / 8;
+ sig->u.MlmeSetkeysRequest.SequenceNumber[0] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeSetkeysRequest.SequenceNumber[1] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeSetkeysRequest.SequenceNumber[2] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeSetkeysRequest.SequenceNumber[3] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeSetkeysRequest.SequenceNumber[4] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeSetkeysRequest.SequenceNumber[5] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeSetkeysRequest.SequenceNumber[6] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeSetkeysRequest.SequenceNumber[7] = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ memcpy(&sig->u.MlmeSetkeysRequest.CipherSuiteSelector, &ptr[index], 32 / 8);
+ index += 32 / 8;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_PAUSE_AUTONOMOUS_SCAN_REQUEST_ID:
+ sig->u.MlmePauseAutonomousScanRequest.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmePauseAutonomousScanRequest.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmePauseAutonomousScanRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmePauseAutonomousScanRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmePauseAutonomousScanRequest.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmePauseAutonomousScanRequest.AutonomousScanId = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmePauseAutonomousScanRequest.Pause = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_GET_REQUEST_ID:
+ sig->u.MlmeGetRequest.MibAttribute.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeGetRequest.MibAttribute.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeGetRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeGetRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_POWERMGT_REQUEST_ID:
+ sig->u.MlmePowermgtRequest.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmePowermgtRequest.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmePowermgtRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmePowermgtRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmePowermgtRequest.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmePowermgtRequest.PowerManagementMode = (CSR_POWER_MANAGEMENT_MODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmePowermgtRequest.ReceiveDtims = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmePowermgtRequest.ListenInterval = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmePowermgtRequest.TrafficWindow = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ break;
+#endif
+ case CSR_MA_PACKET_ERROR_INDICATION_ID:
+ sig->u.MaPacketErrorIndication.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MaPacketErrorIndication.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MaPacketErrorIndication.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MaPacketErrorIndication.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MaPacketErrorIndication.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ memcpy(sig->u.MaPacketErrorIndication.PeerQstaAddress.x, &ptr[index], 48 / 8);
+ index += 48 / 8;
+ sig->u.MaPacketErrorIndication.UserPriority = (CSR_PRIORITY) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MaPacketErrorIndication.SequenceNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ break;
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_ADD_PERIODIC_REQUEST_ID:
+ sig->u.MlmeAddPeriodicRequest.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeAddPeriodicRequest.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeAddPeriodicRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeAddPeriodicRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeAddPeriodicRequest.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeAddPeriodicRequest.PeriodicId = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeAddPeriodicRequest.MaximumLatency = CSR_GET_UINT32_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT32;
+ sig->u.MlmeAddPeriodicRequest.PeriodicSchedulingMode = (CSR_PERIODIC_SCHEDULING_MODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeAddPeriodicRequest.WakeHost = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeAddPeriodicRequest.UserPriority = (CSR_PRIORITY) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_ADD_TSPEC_REQUEST_ID:
+ sig->u.MlmeAddTspecRequest.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeAddTspecRequest.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeAddTspecRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeAddTspecRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeAddTspecRequest.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeAddTspecRequest.UserPriority = (CSR_PRIORITY) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeAddTspecRequest.Direction = (CSR_DIRECTION) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeAddTspecRequest.PsScheme = (CSR_PS_SCHEME) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeAddTspecRequest.MediumTime = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeAddTspecRequest.ServiceStartTime = CSR_GET_UINT32_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT32;
+ sig->u.MlmeAddTspecRequest.ServiceInterval = CSR_GET_UINT32_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT32;
+ sig->u.MlmeAddTspecRequest.MinimumDataRate = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_ADD_MULTICAST_ADDRESS_CONFIRM_ID:
+ sig->u.MlmeAddMulticastAddressConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeAddMulticastAddressConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeAddMulticastAddressConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeAddMulticastAddressConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeAddMulticastAddressConfirm.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeAddMulticastAddressConfirm.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_ADD_TSPEC_CONFIRM_ID:
+ sig->u.MlmeAddTspecConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeAddTspecConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeAddTspecConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeAddTspecConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeAddTspecConfirm.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeAddTspecConfirm.UserPriority = (CSR_PRIORITY) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeAddTspecConfirm.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_HL_SYNC_CANCEL_CONFIRM_ID:
+ sig->u.MlmeHlSyncCancelConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeHlSyncCancelConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeHlSyncCancelConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeHlSyncCancelConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeHlSyncCancelConfirm.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_SCAN_CONFIRM_ID:
+ sig->u.MlmeScanConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeScanConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeScanConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeScanConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeScanConfirm.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeScanConfirm.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ break;
+#endif
+ case CSR_DEBUG_STRING_INDICATION_ID:
+ sig->u.DebugStringIndication.DebugMessage.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.DebugStringIndication.DebugMessage.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.DebugStringIndication.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.DebugStringIndication.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ break;
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_ADD_TEMPLATE_CONFIRM_ID:
+ sig->u.MlmeAddTemplateConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeAddTemplateConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeAddTemplateConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeAddTemplateConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeAddTemplateConfirm.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeAddTemplateConfirm.FrameType = (CSR_FRAME_TYPE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeAddTemplateConfirm.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_BLOCKACK_ERROR_INDICATION_ID:
+ sig->u.MlmeBlockackErrorIndication.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeBlockackErrorIndication.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeBlockackErrorIndication.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeBlockackErrorIndication.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeBlockackErrorIndication.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeBlockackErrorIndication.ResultCode = (CSR_REASON_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ memcpy(sig->u.MlmeBlockackErrorIndication.PeerQstaAddress.x, &ptr[index], 48 / 8);
+ index += 48 / 8;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_SET_CONFIRM_ID:
+ sig->u.MlmeSetConfirm.MibAttributeValue.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeSetConfirm.MibAttributeValue.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeSetConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeSetConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeSetConfirm.Status = (CSR_MIB_STATUS) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeSetConfirm.ErrorIndex = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_MEASURE_REQUEST_ID:
+ sig->u.MlmeMeasureRequest.MeasurementRequestSet.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeMeasureRequest.MeasurementRequestSet.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeMeasureRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeMeasureRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeMeasureRequest.DialogToken = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_START_AGGREGATION_CONFIRM_ID:
+ sig->u.MlmeStartAggregationConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeStartAggregationConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeStartAggregationConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeStartAggregationConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeStartAggregationConfirm.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ memcpy(sig->u.MlmeStartAggregationConfirm.PeerQstaAddress.x, &ptr[index], 48 / 8);
+ index += 48 / 8;
+ sig->u.MlmeStartAggregationConfirm.UserPriority = (CSR_PRIORITY) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeStartAggregationConfirm.Direction = (CSR_DIRECTION) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeStartAggregationConfirm.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeStartAggregationConfirm.SequenceNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_STOP_MEASURE_CONFIRM_ID:
+ sig->u.MlmeStopMeasureConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeStopMeasureConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeStopMeasureConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeStopMeasureConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeStopMeasureConfirm.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeStopMeasureConfirm.DialogToken = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ break;
+#endif
+ case CSR_MA_PACKET_CONFIRM_ID:
+ sig->u.MaPacketConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MaPacketConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MaPacketConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MaPacketConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MaPacketConfirm.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MaPacketConfirm.TransmissionStatus = (CSR_TRANSMISSION_STATUS) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MaPacketConfirm.RetryCount = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MaPacketConfirm.Rate = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MaPacketConfirm.HostTag = CSR_GET_UINT32_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT32;
+ break;
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_DEL_PERIODIC_CONFIRM_ID:
+ sig->u.MlmeDelPeriodicConfirm.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeDelPeriodicConfirm.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeDelPeriodicConfirm.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeDelPeriodicConfirm.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeDelPeriodicConfirm.VirtualInterfaceIdentifier = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeDelPeriodicConfirm.PeriodicId = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeDelPeriodicConfirm.ResultCode = (CSR_RESULT_CODE) CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_STOP_MEASURE_REQUEST_ID:
+ sig->u.MlmeStopMeasureRequest.Dummydataref1.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeStopMeasureRequest.Dummydataref1.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeStopMeasureRequest.Dummydataref2.SlotNumber = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeStopMeasureRequest.Dummydataref2.DataLength = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ sig->u.MlmeStopMeasureRequest.DialogToken = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(ptr + index);
+ index += SIZEOF_UINT16;
+ break;
+#endif
+
+ default:
+ return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
+ }
+ return CSR_RESULT_SUCCESS;
+} /* read_unpack_signal() */
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * write_pack
+ *
+ * Convert a signal structure, in host-native format, to the
+ * little-endian wire format specified in the UniFi Host Interface
+ * Protocol Specification.
+ *
+ * WARNING: This function is auto-generated, DO NOT EDIT!
+ *
+ * Arguments:
+ * sig Pointer to signal structure to pack.
+ * ptr Destination buffer to pack into.
+ * sig_len Returns the length of the packed signal, i.e. the
+ * number of bytes written to ptr.
+ *
+ * Returns:
+ * CSR_RESULT_SUCCESS on success,
+ * CSR_WIFI_HIP_RESULT_INVALID_VALUE if the ID of signal was not recognised.
+ * ---------------------------------------------------------------------------
+ */
+CsrResult write_pack(const CSR_SIGNAL *sig, u8 *ptr, u16 *sig_len)
+{
+ s16 index = 0;
+
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->SignalPrimitiveHeader.SignalId, ptr + index);
+ index += SIZEOF_UINT16;
+
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->SignalPrimitiveHeader.ReceiverProcessId, ptr + index);
+ index += SIZEOF_UINT16;
+
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->SignalPrimitiveHeader.SenderProcessId, ptr + index);
+ index += SIZEOF_UINT16;
+
+ switch (sig->SignalPrimitiveHeader.SignalId)
+ {
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_SET_PACKET_FILTER_CONFIRM_ID:
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetPacketFilterConfirm.Dummydataref1.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetPacketFilterConfirm.Dummydataref1.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetPacketFilterConfirm.Dummydataref2.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetPacketFilterConfirm.Dummydataref2.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetPacketFilterConfirm.VirtualInterfaceIdentifier, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetPacketFilterConfirm.ResultCode, ptr + index);
+ index += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_SETKEYS_CONFIRM_ID:
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetkeysConfirm.Dummydataref1.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetkeysConfirm.Dummydataref1.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetkeysConfirm.Dummydataref2.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetkeysConfirm.Dummydataref2.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetkeysConfirm.VirtualInterfaceIdentifier, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetkeysConfirm.ResultCode, ptr + index);
+ index += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_CONFIG_QUEUE_CONFIRM_ID:
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeConfigQueueConfirm.Dummydataref1.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeConfigQueueConfirm.Dummydataref1.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeConfigQueueConfirm.Dummydataref2.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeConfigQueueConfirm.Dummydataref2.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeConfigQueueConfirm.ResultCode, ptr + index);
+ index += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_ADD_AUTONOMOUS_SCAN_CONFIRM_ID:
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddAutonomousScanConfirm.Dummydataref1.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddAutonomousScanConfirm.Dummydataref1.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddAutonomousScanConfirm.Dummydataref2.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddAutonomousScanConfirm.Dummydataref2.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddAutonomousScanConfirm.VirtualInterfaceIdentifier, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddAutonomousScanConfirm.ResultCode, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddAutonomousScanConfirm.AutonomousScanId, ptr + index);
+ index += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_ADD_BLACKOUT_CONFIRM_ID:
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddBlackoutConfirm.Dummydataref1.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddBlackoutConfirm.Dummydataref1.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddBlackoutConfirm.Dummydataref2.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddBlackoutConfirm.Dummydataref2.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddBlackoutConfirm.VirtualInterfaceIdentifier, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddBlackoutConfirm.BlackoutId, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddBlackoutConfirm.ResultCode, ptr + index);
+ index += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_DEL_BLACKOUT_REQUEST_ID:
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelBlackoutRequest.Dummydataref1.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelBlackoutRequest.Dummydataref1.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelBlackoutRequest.Dummydataref2.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelBlackoutRequest.Dummydataref2.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelBlackoutRequest.VirtualInterfaceIdentifier, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelBlackoutRequest.BlackoutId, ptr + index);
+ index += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_GET_KEY_SEQUENCE_CONFIRM_ID:
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetKeySequenceConfirm.Dummydataref1.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetKeySequenceConfirm.Dummydataref1.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetKeySequenceConfirm.Dummydataref2.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetKeySequenceConfirm.Dummydataref2.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetKeySequenceConfirm.VirtualInterfaceIdentifier, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetKeySequenceConfirm.ResultCode, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetKeySequenceConfirm.SequenceNumber[0], ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetKeySequenceConfirm.SequenceNumber[1], ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetKeySequenceConfirm.SequenceNumber[2], ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetKeySequenceConfirm.SequenceNumber[3], ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetKeySequenceConfirm.SequenceNumber[4], ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetKeySequenceConfirm.SequenceNumber[5], ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetKeySequenceConfirm.SequenceNumber[6], ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetKeySequenceConfirm.SequenceNumber[7], ptr + index);
+ index += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_SM_START_CONFIRM_ID:
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSmStartConfirm.Dummydataref1.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSmStartConfirm.Dummydataref1.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSmStartConfirm.Dummydataref2.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSmStartConfirm.Dummydataref2.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSmStartConfirm.VirtualInterfaceIdentifier, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSmStartConfirm.ResultCode, ptr + index);
+ index += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_STOP_AGGREGATION_CONFIRM_ID:
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStopAggregationConfirm.Dummydataref1.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStopAggregationConfirm.Dummydataref1.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStopAggregationConfirm.Dummydataref2.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStopAggregationConfirm.Dummydataref2.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStopAggregationConfirm.VirtualInterfaceIdentifier, ptr + index);
+ index += SIZEOF_UINT16;
+ memcpy(ptr + index, sig->u.MlmeStopAggregationConfirm.PeerQstaAddress.x, 48 / 8);
+ index += 48 / 8;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStopAggregationConfirm.UserPriority, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStopAggregationConfirm.Direction, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStopAggregationConfirm.ResultCode, ptr + index);
+ index += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_DEL_TSPEC_REQUEST_ID:
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelTspecRequest.Dummydataref1.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelTspecRequest.Dummydataref1.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelTspecRequest.Dummydataref2.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelTspecRequest.Dummydataref2.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelTspecRequest.VirtualInterfaceIdentifier, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelTspecRequest.UserPriority, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelTspecRequest.Direction, ptr + index);
+ index += SIZEOF_UINT16;
+ break;
+#endif
+ case CSR_DEBUG_WORD16_INDICATION_ID:
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugWord16Indication.Dummydataref1.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugWord16Indication.Dummydataref1.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugWord16Indication.Dummydataref2.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugWord16Indication.Dummydataref2.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugWord16Indication.DebugWords[0], ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugWord16Indication.DebugWords[1], ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugWord16Indication.DebugWords[2], ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugWord16Indication.DebugWords[3], ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugWord16Indication.DebugWords[4], ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugWord16Indication.DebugWords[5], ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugWord16Indication.DebugWords[6], ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugWord16Indication.DebugWords[7], ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugWord16Indication.DebugWords[8], ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugWord16Indication.DebugWords[9], ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugWord16Indication.DebugWords[10], ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugWord16Indication.DebugWords[11], ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugWord16Indication.DebugWords[12], ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugWord16Indication.DebugWords[13], ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugWord16Indication.DebugWords[14], ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugWord16Indication.DebugWords[15], ptr + index);
+ index += SIZEOF_UINT16;
+ break;
+ case CSR_DEBUG_GENERIC_CONFIRM_ID:
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericConfirm.DebugVariable.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericConfirm.DebugVariable.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericConfirm.Dummydataref2.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericConfirm.Dummydataref2.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericConfirm.DebugWords[0], ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericConfirm.DebugWords[1], ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericConfirm.DebugWords[2], ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericConfirm.DebugWords[3], ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericConfirm.DebugWords[4], ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericConfirm.DebugWords[5], ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericConfirm.DebugWords[6], ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericConfirm.DebugWords[7], ptr + index);
+ index += SIZEOF_UINT16;
+ break;
+ case CSR_MA_PACKET_INDICATION_ID:
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketIndication.Data.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketIndication.Data.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketIndication.Dummydataref2.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketIndication.Dummydataref2.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketIndication.VirtualInterfaceIdentifier, ptr + index);
+ index += SIZEOF_UINT16;
+ memcpy(ptr + index, sig->u.MaPacketIndication.LocalTime.x, 64 / 8);
+ index += 64 / 8;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketIndication.Ifindex, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketIndication.Channel, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketIndication.ReceptionStatus, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketIndication.Rssi, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketIndication.Snr, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketIndication.ReceivedRate, ptr + index);
+ index += SIZEOF_UINT16;
+ break;
+ case CSR_MLME_SET_TIM_REQUEST_ID:
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetTimRequest.Dummydataref1.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetTimRequest.Dummydataref1.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetTimRequest.Dummydataref2.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetTimRequest.Dummydataref2.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetTimRequest.VirtualInterfaceIdentifier, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetTimRequest.AssociationId, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetTimRequest.TimValue, ptr + index);
+ index += SIZEOF_UINT16;
+ break;
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_CONNECTED_INDICATION_ID:
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeConnectedIndication.Dummydataref1.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeConnectedIndication.Dummydataref1.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeConnectedIndication.Dummydataref2.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeConnectedIndication.Dummydataref2.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeConnectedIndication.VirtualInterfaceIdentifier, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeConnectedIndication.ConnectionStatus, ptr + index);
+ index += SIZEOF_UINT16;
+ memcpy(ptr + index, sig->u.MlmeConnectedIndication.PeerMacAddress.x, 48 / 8);
+ index += 48 / 8;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_DEL_RX_TRIGGER_REQUEST_ID:
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelRxTriggerRequest.Dummydataref1.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelRxTriggerRequest.Dummydataref1.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelRxTriggerRequest.Dummydataref2.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelRxTriggerRequest.Dummydataref2.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelRxTriggerRequest.VirtualInterfaceIdentifier, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelRxTriggerRequest.TriggerId, ptr + index);
+ index += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_TRIGGERED_GET_INDICATION_ID:
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeTriggeredGetIndication.MibAttributeValue.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeTriggeredGetIndication.MibAttributeValue.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeTriggeredGetIndication.Dummydataref2.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeTriggeredGetIndication.Dummydataref2.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeTriggeredGetIndication.VirtualInterfaceIdentifier, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeTriggeredGetIndication.Status, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeTriggeredGetIndication.ErrorIndex, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeTriggeredGetIndication.TriggeredId, ptr + index);
+ index += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_SCAN_REQUEST_ID:
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeScanRequest.ChannelList.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeScanRequest.ChannelList.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeScanRequest.InformationElements.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeScanRequest.InformationElements.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeScanRequest.VirtualInterfaceIdentifier, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeScanRequest.Ifindex, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeScanRequest.ScanType, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT32_TO_LITTLE_ENDIAN(sig->u.MlmeScanRequest.ProbeDelay, ptr + index);
+ index += SIZEOF_UINT32;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeScanRequest.MinChannelTime, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeScanRequest.MaxChannelTime, ptr + index);
+ index += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_DELETEKEYS_CONFIRM_ID:
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDeletekeysConfirm.Dummydataref1.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDeletekeysConfirm.Dummydataref1.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDeletekeysConfirm.Dummydataref2.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDeletekeysConfirm.Dummydataref2.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDeletekeysConfirm.VirtualInterfaceIdentifier, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDeletekeysConfirm.ResultCode, ptr + index);
+ index += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_GET_NEXT_REQUEST_ID:
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetNextRequest.MibAttribute.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetNextRequest.MibAttribute.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetNextRequest.Dummydataref2.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetNextRequest.Dummydataref2.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_SET_CHANNEL_CONFIRM_ID:
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetChannelConfirm.Dummydataref1.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetChannelConfirm.Dummydataref1.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetChannelConfirm.Dummydataref2.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetChannelConfirm.Dummydataref2.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetChannelConfirm.VirtualInterfaceIdentifier, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetChannelConfirm.ResultCode, ptr + index);
+ index += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_START_AGGREGATION_REQUEST_ID:
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStartAggregationRequest.Dummydataref1.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStartAggregationRequest.Dummydataref1.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStartAggregationRequest.Dummydataref2.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStartAggregationRequest.Dummydataref2.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStartAggregationRequest.VirtualInterfaceIdentifier, ptr + index);
+ index += SIZEOF_UINT16;
+ memcpy(ptr + index, sig->u.MlmeStartAggregationRequest.PeerQstaAddress.x, 48 / 8);
+ index += 48 / 8;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStartAggregationRequest.UserPriority, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStartAggregationRequest.Direction, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStartAggregationRequest.StartingSequenceNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStartAggregationRequest.BufferSize, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStartAggregationRequest.BlockAckTimeout, ptr + index);
+ index += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_HL_SYNC_REQUEST_ID:
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeHlSyncRequest.Dummydataref1.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeHlSyncRequest.Dummydataref1.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeHlSyncRequest.Dummydataref2.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeHlSyncRequest.Dummydataref2.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ memcpy(ptr + index, sig->u.MlmeHlSyncRequest.GroupAddress.x, 48 / 8);
+ index += 48 / 8;
+ break;
+#endif
+ case CSR_DEBUG_GENERIC_REQUEST_ID:
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericRequest.DebugVariable.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericRequest.DebugVariable.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericRequest.Dummydataref2.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericRequest.Dummydataref2.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericRequest.DebugWords[0], ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericRequest.DebugWords[1], ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericRequest.DebugWords[2], ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericRequest.DebugWords[3], ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericRequest.DebugWords[4], ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericRequest.DebugWords[5], ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericRequest.DebugWords[6], ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericRequest.DebugWords[7], ptr + index);
+ index += SIZEOF_UINT16;
+ break;
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_LEAVE_CONFIRM_ID:
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeLeaveConfirm.Dummydataref1.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeLeaveConfirm.Dummydataref1.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeLeaveConfirm.Dummydataref2.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeLeaveConfirm.Dummydataref2.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeLeaveConfirm.VirtualInterfaceIdentifier, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeLeaveConfirm.ResultCode, ptr + index);
+ index += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_DEL_TRIGGERED_GET_REQUEST_ID:
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelTriggeredGetRequest.Dummydataref1.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelTriggeredGetRequest.Dummydataref1.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelTriggeredGetRequest.Dummydataref2.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelTriggeredGetRequest.Dummydataref2.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelTriggeredGetRequest.VirtualInterfaceIdentifier, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelTriggeredGetRequest.TriggeredId, ptr + index);
+ index += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_ADD_MULTICAST_ADDRESS_REQUEST_ID:
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddMulticastAddressRequest.Data.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddMulticastAddressRequest.Data.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddMulticastAddressRequest.Dummydataref2.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddMulticastAddressRequest.Dummydataref2.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddMulticastAddressRequest.VirtualInterfaceIdentifier, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddMulticastAddressRequest.NumberOfMulticastGroupAddresses, ptr + index);
+ index += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_RESET_REQUEST_ID:
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeResetRequest.Dummydataref1.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeResetRequest.Dummydataref1.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeResetRequest.Dummydataref2.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeResetRequest.Dummydataref2.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ memcpy(ptr + index, sig->u.MlmeResetRequest.StaAddress.x, 48 / 8);
+ index += 48 / 8;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeResetRequest.SetDefaultMib, ptr + index);
+ index += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_SCAN_CANCEL_REQUEST_ID:
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeScanCancelRequest.Dummydataref1.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeScanCancelRequest.Dummydataref1.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeScanCancelRequest.Dummydataref2.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeScanCancelRequest.Dummydataref2.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeScanCancelRequest.VirtualInterfaceIdentifier, ptr + index);
+ index += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_ADD_TRIGGERED_GET_CONFIRM_ID:
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTriggeredGetConfirm.Dummydataref1.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTriggeredGetConfirm.Dummydataref1.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTriggeredGetConfirm.Dummydataref2.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTriggeredGetConfirm.Dummydataref2.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTriggeredGetConfirm.VirtualInterfaceIdentifier, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTriggeredGetConfirm.ResultCode, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTriggeredGetConfirm.TriggeredId, ptr + index);
+ index += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_SET_PACKET_FILTER_REQUEST_ID:
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetPacketFilterRequest.InformationElements.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetPacketFilterRequest.InformationElements.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetPacketFilterRequest.Dummydataref2.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetPacketFilterRequest.Dummydataref2.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetPacketFilterRequest.VirtualInterfaceIdentifier, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetPacketFilterRequest.PacketFilterMode, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT32_TO_LITTLE_ENDIAN(sig->u.MlmeSetPacketFilterRequest.ArpFilterAddress, ptr + index);
+ index += SIZEOF_UINT32;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_DEL_RX_TRIGGER_CONFIRM_ID:
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelRxTriggerConfirm.Dummydataref1.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelRxTriggerConfirm.Dummydataref1.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelRxTriggerConfirm.Dummydataref2.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelRxTriggerConfirm.Dummydataref2.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelRxTriggerConfirm.VirtualInterfaceIdentifier, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelRxTriggerConfirm.TriggerId, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelRxTriggerConfirm.ResultCode, ptr + index);
+ index += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_CONNECT_STATUS_REQUEST_ID:
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeConnectStatusRequest.InformationElements.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeConnectStatusRequest.InformationElements.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeConnectStatusRequest.Dummydataref2.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeConnectStatusRequest.Dummydataref2.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeConnectStatusRequest.VirtualInterfaceIdentifier, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeConnectStatusRequest.ConnectionStatus, ptr + index);
+ index += SIZEOF_UINT16;
+ memcpy(ptr + index, sig->u.MlmeConnectStatusRequest.StaAddress.x, 48 / 8);
+ index += 48 / 8;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeConnectStatusRequest.AssociationId, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeConnectStatusRequest.AssociationCapabilityInformation, ptr + index);
+ index += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_LEAVE_REQUEST_ID:
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeLeaveRequest.Dummydataref1.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeLeaveRequest.Dummydataref1.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeLeaveRequest.Dummydataref2.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeLeaveRequest.Dummydataref2.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeLeaveRequest.VirtualInterfaceIdentifier, ptr + index);
+ index += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_CONFIG_QUEUE_REQUEST_ID:
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeConfigQueueRequest.Dummydataref1.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeConfigQueueRequest.Dummydataref1.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeConfigQueueRequest.Dummydataref2.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeConfigQueueRequest.Dummydataref2.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeConfigQueueRequest.QueueIndex, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeConfigQueueRequest.Aifs, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeConfigQueueRequest.Cwmin, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeConfigQueueRequest.Cwmax, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeConfigQueueRequest.TxopLimit, ptr + index);
+ index += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_DEL_TSPEC_CONFIRM_ID:
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelTspecConfirm.Dummydataref1.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelTspecConfirm.Dummydataref1.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelTspecConfirm.Dummydataref2.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelTspecConfirm.Dummydataref2.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelTspecConfirm.VirtualInterfaceIdentifier, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelTspecConfirm.UserPriority, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelTspecConfirm.ResultCode, ptr + index);
+ index += SIZEOF_UINT16;
+ break;
+#endif
+ case CSR_MLME_SET_TIM_CONFIRM_ID:
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetTimConfirm.Dummydataref1.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetTimConfirm.Dummydataref1.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetTimConfirm.Dummydataref2.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetTimConfirm.Dummydataref2.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetTimConfirm.VirtualInterfaceIdentifier, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetTimConfirm.ResultCode, ptr + index);
+ index += SIZEOF_UINT16;
+ break;
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_MEASURE_INDICATION_ID:
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeMeasureIndication.MeasurementReportSet.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeMeasureIndication.MeasurementReportSet.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeMeasureIndication.Dummydataref2.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeMeasureIndication.Dummydataref2.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeMeasureIndication.DialogToken, ptr + index);
+ index += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_DEL_BLACKOUT_CONFIRM_ID:
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelBlackoutConfirm.Dummydataref1.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelBlackoutConfirm.Dummydataref1.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelBlackoutConfirm.Dummydataref2.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelBlackoutConfirm.Dummydataref2.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelBlackoutConfirm.VirtualInterfaceIdentifier, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelBlackoutConfirm.BlackoutId, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelBlackoutConfirm.ResultCode, ptr + index);
+ index += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_DEL_TRIGGERED_GET_CONFIRM_ID:
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelTriggeredGetConfirm.Dummydataref1.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelTriggeredGetConfirm.Dummydataref1.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelTriggeredGetConfirm.Dummydataref2.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelTriggeredGetConfirm.Dummydataref2.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelTriggeredGetConfirm.VirtualInterfaceIdentifier, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelTriggeredGetConfirm.ResultCode, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelTriggeredGetConfirm.TriggeredId, ptr + index);
+ index += SIZEOF_UINT16;
+ break;
+#endif
+ case CSR_DEBUG_GENERIC_INDICATION_ID:
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericIndication.DebugVariable.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericIndication.DebugVariable.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericIndication.Dummydataref2.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericIndication.Dummydataref2.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericIndication.DebugWords[0], ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericIndication.DebugWords[1], ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericIndication.DebugWords[2], ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericIndication.DebugWords[3], ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericIndication.DebugWords[4], ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericIndication.DebugWords[5], ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericIndication.DebugWords[6], ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugGenericIndication.DebugWords[7], ptr + index);
+ index += SIZEOF_UINT16;
+ break;
+ case CSR_MA_PACKET_CANCEL_REQUEST_ID:
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketCancelRequest.Dummydataref1.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketCancelRequest.Dummydataref1.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketCancelRequest.Dummydataref2.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketCancelRequest.Dummydataref2.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketCancelRequest.VirtualInterfaceIdentifier, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT32_TO_LITTLE_ENDIAN(sig->u.MaPacketCancelRequest.HostTag, ptr + index);
+ index += SIZEOF_UINT32;
+ break;
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_MODIFY_BSS_PARAMETER_CONFIRM_ID:
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeModifyBssParameterConfirm.Dummydataref1.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeModifyBssParameterConfirm.Dummydataref1.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeModifyBssParameterConfirm.Dummydataref2.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeModifyBssParameterConfirm.Dummydataref2.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeModifyBssParameterConfirm.VirtualInterfaceIdentifier, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeModifyBssParameterConfirm.ResultCode, ptr + index);
+ index += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_PAUSE_AUTONOMOUS_SCAN_CONFIRM_ID:
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmePauseAutonomousScanConfirm.Dummydataref1.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmePauseAutonomousScanConfirm.Dummydataref1.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmePauseAutonomousScanConfirm.Dummydataref2.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmePauseAutonomousScanConfirm.Dummydataref2.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmePauseAutonomousScanConfirm.VirtualInterfaceIdentifier, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmePauseAutonomousScanConfirm.ResultCode, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmePauseAutonomousScanConfirm.AutonomousScanId, ptr + index);
+ index += SIZEOF_UINT16;
+ break;
+#endif
+ case CSR_MA_PACKET_REQUEST_ID:
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketRequest.Data.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketRequest.Data.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketRequest.Dummydataref2.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketRequest.Dummydataref2.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketRequest.VirtualInterfaceIdentifier, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketRequest.TransmitRate, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT32_TO_LITTLE_ENDIAN(sig->u.MaPacketRequest.HostTag, ptr + index);
+ index += SIZEOF_UINT32;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketRequest.Priority, ptr + index);
+ index += SIZEOF_UINT16;
+ memcpy(ptr + index, sig->u.MaPacketRequest.Ra.x, 48 / 8);
+ index += 48 / 8;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketRequest.TransmissionControl, ptr + index);
+ index += SIZEOF_UINT16;
+ break;
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_MODIFY_BSS_PARAMETER_REQUEST_ID:
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeModifyBssParameterRequest.Data.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeModifyBssParameterRequest.Data.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeModifyBssParameterRequest.Dummydataref2.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeModifyBssParameterRequest.Dummydataref2.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeModifyBssParameterRequest.VirtualInterfaceIdentifier, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeModifyBssParameterRequest.BeaconPeriod, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeModifyBssParameterRequest.DtimPeriod, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeModifyBssParameterRequest.CapabilityInformation, ptr + index);
+ index += SIZEOF_UINT16;
+ memcpy(ptr + index, sig->u.MlmeModifyBssParameterRequest.Bssid.x, 48 / 8);
+ index += 48 / 8;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeModifyBssParameterRequest.RtsThreshold, ptr + index);
+ index += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_ADD_RX_TRIGGER_REQUEST_ID:
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddRxTriggerRequest.InformationElements.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddRxTriggerRequest.InformationElements.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddRxTriggerRequest.Dummydataref2.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddRxTriggerRequest.Dummydataref2.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddRxTriggerRequest.VirtualInterfaceIdentifier, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddRxTriggerRequest.TriggerId, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddRxTriggerRequest.Priority, ptr + index);
+ index += SIZEOF_UINT16;
+ break;
+#endif
+ case CSR_MA_VIF_AVAILABILITY_INDICATION_ID:
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaVifAvailabilityIndication.Dummydataref1.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaVifAvailabilityIndication.Dummydataref1.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaVifAvailabilityIndication.Dummydataref2.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaVifAvailabilityIndication.Dummydataref2.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaVifAvailabilityIndication.VirtualInterfaceIdentifier, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaVifAvailabilityIndication.Multicast, ptr + index);
+ index += SIZEOF_UINT16;
+ break;
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_HL_SYNC_CANCEL_REQUEST_ID:
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeHlSyncCancelRequest.Dummydataref1.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeHlSyncCancelRequest.Dummydataref1.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeHlSyncCancelRequest.Dummydataref2.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeHlSyncCancelRequest.Dummydataref2.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ memcpy(ptr + index, sig->u.MlmeHlSyncCancelRequest.GroupAddress.x, 48 / 8);
+ index += 48 / 8;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_DEL_AUTONOMOUS_SCAN_REQUEST_ID:
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelAutonomousScanRequest.Dummydataref1.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelAutonomousScanRequest.Dummydataref1.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelAutonomousScanRequest.Dummydataref2.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelAutonomousScanRequest.Dummydataref2.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelAutonomousScanRequest.VirtualInterfaceIdentifier, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelAutonomousScanRequest.AutonomousScanId, ptr + index);
+ index += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_BLACKOUT_ENDED_INDICATION_ID:
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeBlackoutEndedIndication.Dummydataref1.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeBlackoutEndedIndication.Dummydataref1.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeBlackoutEndedIndication.Dummydataref2.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeBlackoutEndedIndication.Dummydataref2.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeBlackoutEndedIndication.VirtualInterfaceIdentifier, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeBlackoutEndedIndication.BlackoutId, ptr + index);
+ index += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_AUTONOMOUS_SCAN_DONE_INDICATION_ID:
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAutonomousScanDoneIndication.Dummydataref1.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAutonomousScanDoneIndication.Dummydataref1.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAutonomousScanDoneIndication.Dummydataref2.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAutonomousScanDoneIndication.Dummydataref2.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAutonomousScanDoneIndication.VirtualInterfaceIdentifier, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAutonomousScanDoneIndication.ResultCode, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAutonomousScanDoneIndication.AutonomousScanId, ptr + index);
+ index += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_GET_KEY_SEQUENCE_REQUEST_ID:
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetKeySequenceRequest.Dummydataref1.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetKeySequenceRequest.Dummydataref1.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetKeySequenceRequest.Dummydataref2.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetKeySequenceRequest.Dummydataref2.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetKeySequenceRequest.VirtualInterfaceIdentifier, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetKeySequenceRequest.KeyId, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetKeySequenceRequest.KeyType, ptr + index);
+ index += SIZEOF_UINT16;
+ memcpy(ptr + index, sig->u.MlmeGetKeySequenceRequest.Address.x, 48 / 8);
+ index += 48 / 8;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_SET_CHANNEL_REQUEST_ID:
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetChannelRequest.Dummydataref1.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetChannelRequest.Dummydataref1.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetChannelRequest.Dummydataref2.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetChannelRequest.Dummydataref2.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetChannelRequest.VirtualInterfaceIdentifier, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetChannelRequest.Ifindex, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetChannelRequest.Channel, ptr + index);
+ index += SIZEOF_UINT16;
+ memcpy(ptr + index, sig->u.MlmeSetChannelRequest.Address.x, 48 / 8);
+ index += 48 / 8;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetChannelRequest.AvailabilityDuration, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetChannelRequest.AvailabilityInterval, ptr + index);
+ index += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_MEASURE_CONFIRM_ID:
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeMeasureConfirm.Dummydataref1.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeMeasureConfirm.Dummydataref1.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeMeasureConfirm.Dummydataref2.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeMeasureConfirm.Dummydataref2.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeMeasureConfirm.ResultCode, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeMeasureConfirm.DialogToken, ptr + index);
+ index += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_ADD_TRIGGERED_GET_REQUEST_ID:
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTriggeredGetRequest.MibAttribute.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTriggeredGetRequest.MibAttribute.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTriggeredGetRequest.Dummydataref2.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTriggeredGetRequest.Dummydataref2.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTriggeredGetRequest.VirtualInterfaceIdentifier, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTriggeredGetRequest.TriggeredId, ptr + index);
+ index += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_AUTONOMOUS_SCAN_LOSS_INDICATION_ID:
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAutonomousScanLossIndication.Dummydataref1.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAutonomousScanLossIndication.Dummydataref1.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAutonomousScanLossIndication.Dummydataref2.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAutonomousScanLossIndication.Dummydataref2.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAutonomousScanLossIndication.VirtualInterfaceIdentifier, ptr + index);
+ index += SIZEOF_UINT16;
+ memcpy(ptr + index, sig->u.MlmeAutonomousScanLossIndication.Bssid.x, 48 / 8);
+ index += 48 / 8;
+ break;
+#endif
+ case CSR_MA_VIF_AVAILABILITY_RESPONSE_ID:
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaVifAvailabilityResponse.Dummydataref1.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaVifAvailabilityResponse.Dummydataref1.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaVifAvailabilityResponse.Dummydataref2.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaVifAvailabilityResponse.Dummydataref2.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaVifAvailabilityResponse.VirtualInterfaceIdentifier, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaVifAvailabilityResponse.ResultCode, ptr + index);
+ index += SIZEOF_UINT16;
+ break;
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_ADD_TEMPLATE_REQUEST_ID:
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTemplateRequest.Data1.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTemplateRequest.Data1.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTemplateRequest.Data2.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTemplateRequest.Data2.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTemplateRequest.VirtualInterfaceIdentifier, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTemplateRequest.FrameType, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTemplateRequest.MinTransmitRate, ptr + index);
+ index += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_POWERMGT_CONFIRM_ID:
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmePowermgtConfirm.Dummydataref1.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmePowermgtConfirm.Dummydataref1.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmePowermgtConfirm.Dummydataref2.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmePowermgtConfirm.Dummydataref2.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmePowermgtConfirm.VirtualInterfaceIdentifier, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmePowermgtConfirm.ResultCode, ptr + index);
+ index += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_ADD_PERIODIC_CONFIRM_ID:
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddPeriodicConfirm.Dummydataref1.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddPeriodicConfirm.Dummydataref1.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddPeriodicConfirm.Dummydataref2.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddPeriodicConfirm.Dummydataref2.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddPeriodicConfirm.VirtualInterfaceIdentifier, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddPeriodicConfirm.PeriodicId, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddPeriodicConfirm.ResultCode, ptr + index);
+ index += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_GET_CONFIRM_ID:
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetConfirm.MibAttributeValue.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetConfirm.MibAttributeValue.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetConfirm.Dummydataref2.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetConfirm.Dummydataref2.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetConfirm.Status, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetConfirm.ErrorIndex, ptr + index);
+ index += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_GET_NEXT_CONFIRM_ID:
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetNextConfirm.MibAttributeValue.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetNextConfirm.MibAttributeValue.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetNextConfirm.Dummydataref2.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetNextConfirm.Dummydataref2.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetNextConfirm.Status, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetNextConfirm.ErrorIndex, ptr + index);
+ index += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_STOP_AGGREGATION_REQUEST_ID:
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStopAggregationRequest.Dummydataref1.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStopAggregationRequest.Dummydataref1.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStopAggregationRequest.Dummydataref2.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStopAggregationRequest.Dummydataref2.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStopAggregationRequest.VirtualInterfaceIdentifier, ptr + index);
+ index += SIZEOF_UINT16;
+ memcpy(ptr + index, sig->u.MlmeStopAggregationRequest.PeerQstaAddress.x, 48 / 8);
+ index += 48 / 8;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStopAggregationRequest.UserPriority, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStopAggregationRequest.Direction, ptr + index);
+ index += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_ADD_RX_TRIGGER_CONFIRM_ID:
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddRxTriggerConfirm.Dummydataref1.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddRxTriggerConfirm.Dummydataref1.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddRxTriggerConfirm.Dummydataref2.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddRxTriggerConfirm.Dummydataref2.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddRxTriggerConfirm.VirtualInterfaceIdentifier, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddRxTriggerConfirm.TriggerId, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddRxTriggerConfirm.ResultCode, ptr + index);
+ index += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_ADD_BLACKOUT_REQUEST_ID:
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddBlackoutRequest.Dummydataref1.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddBlackoutRequest.Dummydataref1.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddBlackoutRequest.Dummydataref2.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddBlackoutRequest.Dummydataref2.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddBlackoutRequest.VirtualInterfaceIdentifier, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddBlackoutRequest.BlackoutId, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddBlackoutRequest.BlackoutType, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddBlackoutRequest.BlackoutSource, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT32_TO_LITTLE_ENDIAN(sig->u.MlmeAddBlackoutRequest.BlackoutStartReference, ptr + index);
+ index += SIZEOF_UINT32;
+ CSR_COPY_UINT32_TO_LITTLE_ENDIAN(sig->u.MlmeAddBlackoutRequest.BlackoutPeriod, ptr + index);
+ index += SIZEOF_UINT32;
+ CSR_COPY_UINT32_TO_LITTLE_ENDIAN(sig->u.MlmeAddBlackoutRequest.BlackoutDuration, ptr + index);
+ index += SIZEOF_UINT32;
+ memcpy(ptr + index, sig->u.MlmeAddBlackoutRequest.PeerStaAddress.x, 48 / 8);
+ index += 48 / 8;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddBlackoutRequest.BlackoutCount, ptr + index);
+ index += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_DELETEKEYS_REQUEST_ID:
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDeletekeysRequest.Dummydataref1.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDeletekeysRequest.Dummydataref1.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDeletekeysRequest.Dummydataref2.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDeletekeysRequest.Dummydataref2.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDeletekeysRequest.VirtualInterfaceIdentifier, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDeletekeysRequest.KeyId, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDeletekeysRequest.KeyType, ptr + index);
+ index += SIZEOF_UINT16;
+ memcpy(ptr + index, sig->u.MlmeDeletekeysRequest.Address.x, 48 / 8);
+ index += 48 / 8;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_RESET_CONFIRM_ID:
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeResetConfirm.Dummydataref1.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeResetConfirm.Dummydataref1.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeResetConfirm.Dummydataref2.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeResetConfirm.Dummydataref2.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeResetConfirm.ResultCode, ptr + index);
+ index += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_HL_SYNC_CONFIRM_ID:
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeHlSyncConfirm.Dummydataref1.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeHlSyncConfirm.Dummydataref1.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeHlSyncConfirm.Dummydataref2.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeHlSyncConfirm.Dummydataref2.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ memcpy(ptr + index, sig->u.MlmeHlSyncConfirm.GroupAddress.x, 48 / 8);
+ index += 48 / 8;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeHlSyncConfirm.ResultCode, ptr + index);
+ index += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_ADD_AUTONOMOUS_SCAN_REQUEST_ID:
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddAutonomousScanRequest.ChannelList.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddAutonomousScanRequest.ChannelList.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddAutonomousScanRequest.InformationElements.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddAutonomousScanRequest.InformationElements.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddAutonomousScanRequest.VirtualInterfaceIdentifier, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddAutonomousScanRequest.AutonomousScanId, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddAutonomousScanRequest.Ifindex, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddAutonomousScanRequest.ChannelStartingFactor, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddAutonomousScanRequest.ScanType, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT32_TO_LITTLE_ENDIAN(sig->u.MlmeAddAutonomousScanRequest.ProbeDelay, ptr + index);
+ index += SIZEOF_UINT32;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddAutonomousScanRequest.MinChannelTime, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddAutonomousScanRequest.MaxChannelTime, ptr + index);
+ index += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_SET_REQUEST_ID:
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetRequest.MibAttributeValue.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetRequest.MibAttributeValue.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetRequest.Dummydataref2.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetRequest.Dummydataref2.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_SM_START_REQUEST_ID:
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSmStartRequest.Beacon.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSmStartRequest.Beacon.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSmStartRequest.BssParameters.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSmStartRequest.BssParameters.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSmStartRequest.VirtualInterfaceIdentifier, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSmStartRequest.Ifindex, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSmStartRequest.Channel, ptr + index);
+ index += SIZEOF_UINT16;
+ memcpy(ptr + index, sig->u.MlmeSmStartRequest.InterfaceAddress.x, 48 / 8);
+ index += 48 / 8;
+ memcpy(ptr + index, sig->u.MlmeSmStartRequest.Bssid.x, 48 / 8);
+ index += 48 / 8;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSmStartRequest.BeaconPeriod, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSmStartRequest.DtimPeriod, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSmStartRequest.CapabilityInformation, ptr + index);
+ index += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_CONNECT_STATUS_CONFIRM_ID:
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeConnectStatusConfirm.Dummydataref1.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeConnectStatusConfirm.Dummydataref1.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeConnectStatusConfirm.Dummydataref2.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeConnectStatusConfirm.Dummydataref2.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeConnectStatusConfirm.VirtualInterfaceIdentifier, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeConnectStatusConfirm.ResultCode, ptr + index);
+ index += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_DEL_AUTONOMOUS_SCAN_CONFIRM_ID:
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelAutonomousScanConfirm.Dummydataref1.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelAutonomousScanConfirm.Dummydataref1.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelAutonomousScanConfirm.Dummydataref2.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelAutonomousScanConfirm.Dummydataref2.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelAutonomousScanConfirm.VirtualInterfaceIdentifier, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelAutonomousScanConfirm.ResultCode, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelAutonomousScanConfirm.AutonomousScanId, ptr + index);
+ index += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_DEL_PERIODIC_REQUEST_ID:
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelPeriodicRequest.Dummydataref1.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelPeriodicRequest.Dummydataref1.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelPeriodicRequest.Dummydataref2.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelPeriodicRequest.Dummydataref2.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelPeriodicRequest.VirtualInterfaceIdentifier, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelPeriodicRequest.PeriodicId, ptr + index);
+ index += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_SETKEYS_REQUEST_ID:
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetkeysRequest.Key.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetkeysRequest.Key.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetkeysRequest.Dummydataref2.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetkeysRequest.Dummydataref2.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetkeysRequest.VirtualInterfaceIdentifier, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetkeysRequest.Length, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetkeysRequest.KeyId, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetkeysRequest.KeyType, ptr + index);
+ index += SIZEOF_UINT16;
+ memcpy(ptr + index, sig->u.MlmeSetkeysRequest.Address.x, 48 / 8);
+ index += 48 / 8;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetkeysRequest.SequenceNumber[0], ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetkeysRequest.SequenceNumber[1], ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetkeysRequest.SequenceNumber[2], ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetkeysRequest.SequenceNumber[3], ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetkeysRequest.SequenceNumber[4], ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetkeysRequest.SequenceNumber[5], ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetkeysRequest.SequenceNumber[6], ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetkeysRequest.SequenceNumber[7], ptr + index);
+ index += SIZEOF_UINT16;
+ memcpy(ptr + index, &sig->u.MlmeSetkeysRequest.CipherSuiteSelector, 32 / 8);
+ index += 32 / 8;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_PAUSE_AUTONOMOUS_SCAN_REQUEST_ID:
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmePauseAutonomousScanRequest.Dummydataref1.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmePauseAutonomousScanRequest.Dummydataref1.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmePauseAutonomousScanRequest.Dummydataref2.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmePauseAutonomousScanRequest.Dummydataref2.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmePauseAutonomousScanRequest.VirtualInterfaceIdentifier, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmePauseAutonomousScanRequest.AutonomousScanId, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmePauseAutonomousScanRequest.Pause, ptr + index);
+ index += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_GET_REQUEST_ID:
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetRequest.MibAttribute.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetRequest.MibAttribute.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetRequest.Dummydataref2.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeGetRequest.Dummydataref2.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_POWERMGT_REQUEST_ID:
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmePowermgtRequest.Dummydataref1.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmePowermgtRequest.Dummydataref1.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmePowermgtRequest.Dummydataref2.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmePowermgtRequest.Dummydataref2.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmePowermgtRequest.VirtualInterfaceIdentifier, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmePowermgtRequest.PowerManagementMode, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmePowermgtRequest.ReceiveDtims, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmePowermgtRequest.ListenInterval, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmePowermgtRequest.TrafficWindow, ptr + index);
+ index += SIZEOF_UINT16;
+ break;
+#endif
+ case CSR_MA_PACKET_ERROR_INDICATION_ID:
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketErrorIndication.Dummydataref1.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketErrorIndication.Dummydataref1.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketErrorIndication.Dummydataref2.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketErrorIndication.Dummydataref2.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketErrorIndication.VirtualInterfaceIdentifier, ptr + index);
+ index += SIZEOF_UINT16;
+ memcpy(ptr + index, sig->u.MaPacketErrorIndication.PeerQstaAddress.x, 48 / 8);
+ index += 48 / 8;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketErrorIndication.UserPriority, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketErrorIndication.SequenceNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ break;
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_ADD_PERIODIC_REQUEST_ID:
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddPeriodicRequest.Dummydataref1.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddPeriodicRequest.Dummydataref1.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddPeriodicRequest.Dummydataref2.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddPeriodicRequest.Dummydataref2.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddPeriodicRequest.VirtualInterfaceIdentifier, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddPeriodicRequest.PeriodicId, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT32_TO_LITTLE_ENDIAN(sig->u.MlmeAddPeriodicRequest.MaximumLatency, ptr + index);
+ index += SIZEOF_UINT32;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddPeriodicRequest.PeriodicSchedulingMode, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddPeriodicRequest.WakeHost, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddPeriodicRequest.UserPriority, ptr + index);
+ index += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_ADD_TSPEC_REQUEST_ID:
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTspecRequest.Dummydataref1.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTspecRequest.Dummydataref1.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTspecRequest.Dummydataref2.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTspecRequest.Dummydataref2.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTspecRequest.VirtualInterfaceIdentifier, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTspecRequest.UserPriority, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTspecRequest.Direction, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTspecRequest.PsScheme, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTspecRequest.MediumTime, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT32_TO_LITTLE_ENDIAN(sig->u.MlmeAddTspecRequest.ServiceStartTime, ptr + index);
+ index += SIZEOF_UINT32;
+ CSR_COPY_UINT32_TO_LITTLE_ENDIAN(sig->u.MlmeAddTspecRequest.ServiceInterval, ptr + index);
+ index += SIZEOF_UINT32;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTspecRequest.MinimumDataRate, ptr + index);
+ index += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_ADD_MULTICAST_ADDRESS_CONFIRM_ID:
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddMulticastAddressConfirm.Dummydataref1.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddMulticastAddressConfirm.Dummydataref1.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddMulticastAddressConfirm.Dummydataref2.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddMulticastAddressConfirm.Dummydataref2.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddMulticastAddressConfirm.VirtualInterfaceIdentifier, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddMulticastAddressConfirm.ResultCode, ptr + index);
+ index += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_ADD_TSPEC_CONFIRM_ID:
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTspecConfirm.Dummydataref1.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTspecConfirm.Dummydataref1.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTspecConfirm.Dummydataref2.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTspecConfirm.Dummydataref2.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTspecConfirm.VirtualInterfaceIdentifier, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTspecConfirm.UserPriority, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTspecConfirm.ResultCode, ptr + index);
+ index += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_HL_SYNC_CANCEL_CONFIRM_ID:
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeHlSyncCancelConfirm.Dummydataref1.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeHlSyncCancelConfirm.Dummydataref1.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeHlSyncCancelConfirm.Dummydataref2.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeHlSyncCancelConfirm.Dummydataref2.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeHlSyncCancelConfirm.ResultCode, ptr + index);
+ index += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_SCAN_CONFIRM_ID:
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeScanConfirm.Dummydataref1.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeScanConfirm.Dummydataref1.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeScanConfirm.Dummydataref2.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeScanConfirm.Dummydataref2.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeScanConfirm.VirtualInterfaceIdentifier, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeScanConfirm.ResultCode, ptr + index);
+ index += SIZEOF_UINT16;
+ break;
+#endif
+ case CSR_DEBUG_STRING_INDICATION_ID:
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugStringIndication.DebugMessage.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugStringIndication.DebugMessage.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugStringIndication.Dummydataref2.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.DebugStringIndication.Dummydataref2.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ break;
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_ADD_TEMPLATE_CONFIRM_ID:
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTemplateConfirm.Dummydataref1.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTemplateConfirm.Dummydataref1.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTemplateConfirm.Dummydataref2.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTemplateConfirm.Dummydataref2.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTemplateConfirm.VirtualInterfaceIdentifier, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTemplateConfirm.FrameType, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeAddTemplateConfirm.ResultCode, ptr + index);
+ index += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_BLOCKACK_ERROR_INDICATION_ID:
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeBlockackErrorIndication.Dummydataref1.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeBlockackErrorIndication.Dummydataref1.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeBlockackErrorIndication.Dummydataref2.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeBlockackErrorIndication.Dummydataref2.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeBlockackErrorIndication.VirtualInterfaceIdentifier, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeBlockackErrorIndication.ResultCode, ptr + index);
+ index += SIZEOF_UINT16;
+ memcpy(ptr + index, sig->u.MlmeBlockackErrorIndication.PeerQstaAddress.x, 48 / 8);
+ index += 48 / 8;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_SET_CONFIRM_ID:
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetConfirm.MibAttributeValue.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetConfirm.MibAttributeValue.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetConfirm.Dummydataref2.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetConfirm.Dummydataref2.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetConfirm.Status, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeSetConfirm.ErrorIndex, ptr + index);
+ index += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_MEASURE_REQUEST_ID:
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeMeasureRequest.MeasurementRequestSet.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeMeasureRequest.MeasurementRequestSet.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeMeasureRequest.Dummydataref2.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeMeasureRequest.Dummydataref2.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeMeasureRequest.DialogToken, ptr + index);
+ index += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_START_AGGREGATION_CONFIRM_ID:
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStartAggregationConfirm.Dummydataref1.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStartAggregationConfirm.Dummydataref1.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStartAggregationConfirm.Dummydataref2.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStartAggregationConfirm.Dummydataref2.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStartAggregationConfirm.VirtualInterfaceIdentifier, ptr + index);
+ index += SIZEOF_UINT16;
+ memcpy(ptr + index, sig->u.MlmeStartAggregationConfirm.PeerQstaAddress.x, 48 / 8);
+ index += 48 / 8;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStartAggregationConfirm.UserPriority, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStartAggregationConfirm.Direction, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStartAggregationConfirm.ResultCode, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStartAggregationConfirm.SequenceNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_STOP_MEASURE_CONFIRM_ID:
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStopMeasureConfirm.Dummydataref1.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStopMeasureConfirm.Dummydataref1.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStopMeasureConfirm.Dummydataref2.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStopMeasureConfirm.Dummydataref2.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStopMeasureConfirm.ResultCode, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStopMeasureConfirm.DialogToken, ptr + index);
+ index += SIZEOF_UINT16;
+ break;
+#endif
+ case CSR_MA_PACKET_CONFIRM_ID:
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketConfirm.Dummydataref1.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketConfirm.Dummydataref1.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketConfirm.Dummydataref2.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketConfirm.Dummydataref2.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketConfirm.VirtualInterfaceIdentifier, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketConfirm.TransmissionStatus, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketConfirm.RetryCount, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MaPacketConfirm.Rate, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT32_TO_LITTLE_ENDIAN(sig->u.MaPacketConfirm.HostTag, ptr + index);
+ index += SIZEOF_UINT32;
+ break;
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_DEL_PERIODIC_CONFIRM_ID:
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelPeriodicConfirm.Dummydataref1.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelPeriodicConfirm.Dummydataref1.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelPeriodicConfirm.Dummydataref2.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelPeriodicConfirm.Dummydataref2.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelPeriodicConfirm.VirtualInterfaceIdentifier, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelPeriodicConfirm.PeriodicId, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeDelPeriodicConfirm.ResultCode, ptr + index);
+ index += SIZEOF_UINT16;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_STOP_MEASURE_REQUEST_ID:
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStopMeasureRequest.Dummydataref1.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStopMeasureRequest.Dummydataref1.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStopMeasureRequest.Dummydataref2.SlotNumber, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStopMeasureRequest.Dummydataref2.DataLength, ptr + index);
+ index += SIZEOF_UINT16;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(sig->u.MlmeStopMeasureRequest.DialogToken, ptr + index);
+ index += SIZEOF_UINT16;
+ break;
+#endif
+
+ default:
+ return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
+ }
+
+ *sig_len = index;
+
+ return CSR_RESULT_SUCCESS;
+} /* write_pack() */
+
+
diff --git a/drivers/staging/csr/csr_wifi_hip_send.c b/drivers/staging/csr/csr_wifi_hip_send.c
new file mode 100644
index 000000000000..684d30459d75
--- /dev/null
+++ b/drivers/staging/csr/csr_wifi_hip_send.c
@@ -0,0 +1,422 @@
+/*****************************************************************************
+
+ (c) Cambridge Silicon Radio Limited 2011
+ All rights reserved and confidential information of CSR
+
+ Refer to LICENSE.txt included with this source for details
+ on the license terms.
+
+*****************************************************************************/
+
+/*
+ * ***************************************************************************
+ *
+ * FILE: csr_wifi_hip_send.c
+ *
+ * PURPOSE:
+ * Code for adding a signal request to the from-host queue.
+ * When the driver bottom-half is run, it will take requests from the
+ * queue and pass them to the UniFi.
+ *
+ * ***************************************************************************
+ */
+#include "csr_wifi_hip_unifi.h"
+#include "csr_wifi_hip_conversions.h"
+#include "csr_wifi_hip_sigs.h"
+#include "csr_wifi_hip_card.h"
+
+unifi_TrafficQueue unifi_frame_priority_to_queue(CSR_PRIORITY priority)
+{
+ switch (priority)
+ {
+ case CSR_QOS_UP0:
+ case CSR_QOS_UP3:
+ return UNIFI_TRAFFIC_Q_BE;
+ case CSR_QOS_UP1:
+ case CSR_QOS_UP2:
+ return UNIFI_TRAFFIC_Q_BK;
+ case CSR_QOS_UP4:
+ case CSR_QOS_UP5:
+ return UNIFI_TRAFFIC_Q_VI;
+ case CSR_QOS_UP6:
+ case CSR_QOS_UP7:
+ case CSR_MANAGEMENT:
+ return UNIFI_TRAFFIC_Q_VO;
+ default:
+ return UNIFI_TRAFFIC_Q_BE;
+ }
+}
+
+
+CSR_PRIORITY unifi_get_default_downgrade_priority(unifi_TrafficQueue queue)
+{
+ switch (queue)
+ {
+ case UNIFI_TRAFFIC_Q_BE:
+ return CSR_QOS_UP0;
+ case UNIFI_TRAFFIC_Q_BK:
+ return CSR_QOS_UP1;
+ case UNIFI_TRAFFIC_Q_VI:
+ return CSR_QOS_UP5;
+ case UNIFI_TRAFFIC_Q_VO:
+ return CSR_QOS_UP6;
+ default:
+ return CSR_QOS_UP0;
+ }
+}
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * send_signal
+ *
+ * This function queues a signal for sending to UniFi. It first checks
+ * that there is space on the fh_signal_queue for another entry, then
+ * claims any bulk data slots required and copies data into them. Then
+ * increments the fh_signal_queue write count.
+ *
+ * The fh_signal_queue is later processed by the driver bottom half
+ * (in unifi_bh()).
+ *
+ * This function call unifi_pause_xmit() to pause the flow of data plane
+ * packets when:
+ * - the fh_signal_queue ring buffer is full
+ * - there are less than UNIFI_MAX_DATA_REFERENCES (2) bulk data
+ * slots available.
+ *
+ * Arguments:
+ * card Pointer to card context structure
+ * sigptr Pointer to the signal to write to UniFi.
+ * siglen Number of bytes pointer to by sigptr.
+ * bulkdata Array of pointers to an associated bulk data.
+ * sigq To which from-host queue to add the signal.
+ *
+ * Returns:
+ * CSR_RESULT_SUCCESS on success
+ * CSR_WIFI_HIP_RESULT_NO_SPACE if there were insufficient data slots or
+ * no free signal queue entry
+ *
+ * Notes:
+ * Calls unifi_pause_xmit() when the last slots are used.
+ * ---------------------------------------------------------------------------
+ */
+static CsrResult send_signal(card_t *card, const u8 *sigptr, u32 siglen,
+ const bulk_data_param_t *bulkdata,
+ q_t *sigq, u32 priority_q, u32 run_bh)
+{
+ u16 i, data_slot_size;
+ card_signal_t *csptr;
+ s16 qe;
+ CsrResult r;
+ s16 debug_print = 0;
+
+ data_slot_size = CardGetDataSlotSize(card);
+
+ /* Check that the fh_data_queue has a free slot */
+ if (!CSR_WIFI_HIP_Q_SLOTS_FREE(sigq))
+ {
+ unifi_trace(card->ospriv, UDBG3, "send_signal: %s full\n", sigq->name);
+
+ return CSR_WIFI_HIP_RESULT_NO_SPACE;
+ }
+
+ /*
+ * Now add the signal to the From Host signal queue
+ */
+ /* Get next slot on queue */
+ qe = CSR_WIFI_HIP_Q_NEXT_W_SLOT(sigq);
+ csptr = CSR_WIFI_HIP_Q_SLOT_DATA(sigq, qe);
+
+ /* Make up the card_signal struct */
+ csptr->signal_length = (u16)siglen;
+ memcpy((void *)csptr->sigbuf, (void *)sigptr, siglen);
+
+ for (i = 0; i < UNIFI_MAX_DATA_REFERENCES; ++i)
+ {
+ if ((bulkdata != NULL) && (bulkdata->d[i].data_length != 0))
+ {
+ u32 datalen = bulkdata->d[i].data_length;
+
+ /* Make sure data will fit in a bulk data slot */
+ if (bulkdata->d[i].os_data_ptr == NULL)
+ {
+ unifi_error(card->ospriv, "send_signal - NULL bulkdata[%d]\n", i);
+ debug_print++;
+ csptr->bulkdata[i].data_length = 0;
+ }
+ else
+ {
+ if (datalen > data_slot_size)
+ {
+ unifi_error(card->ospriv,
+ "send_signal - Invalid data length %u (@%p), "
+ "truncating\n",
+ datalen, bulkdata->d[i].os_data_ptr);
+ datalen = data_slot_size;
+ debug_print++;
+ }
+ /* Store the bulk data info in the soft queue. */
+ csptr->bulkdata[i].os_data_ptr = (u8 *)bulkdata->d[i].os_data_ptr;
+ csptr->bulkdata[i].os_net_buf_ptr = (u8 *)bulkdata->d[i].os_net_buf_ptr;
+ csptr->bulkdata[i].net_buf_length = bulkdata->d[i].net_buf_length;
+ csptr->bulkdata[i].data_length = datalen;
+ }
+ }
+ else
+ {
+ UNIFI_INIT_BULK_DATA(&csptr->bulkdata[i]);
+ }
+ }
+
+ if (debug_print)
+ {
+ const u8 *sig = sigptr;
+
+ unifi_error(card->ospriv, "Signal(%d): %02x %02x %02x %02x %02x %02x %02x %02x"
+ " %02x %02x %02x %02x %02x %02x %02x %02x\n",
+ siglen,
+ sig[0], sig[1], sig[2], sig[3],
+ sig[4], sig[5], sig[6], sig[7],
+ sig[8], sig[9], sig[10], sig[11],
+ sig[12], sig[13], sig[14], sig[15]);
+ unifi_error(card->ospriv, "Bulkdata pointer %p(%d), %p(%d)\n",
+ bulkdata != NULL?bulkdata->d[0].os_data_ptr : NULL,
+ bulkdata != NULL?bulkdata->d[0].data_length : 0,
+ bulkdata != NULL?bulkdata->d[1].os_data_ptr : NULL,
+ bulkdata != NULL?bulkdata->d[1].data_length : 0);
+ }
+
+ /* Advance the written count to say there is a new entry */
+ CSR_WIFI_HIP_Q_INC_W(sigq);
+
+ /*
+ * Set the flag to say reason for waking was a host request.
+ * Then ask the OS layer to run the unifi_bh.
+ */
+ if (run_bh == 1)
+ {
+ card->bh_reason_host = 1;
+ r = unifi_run_bh(card->ospriv);
+ if (r != CSR_RESULT_SUCCESS)
+ {
+ unifi_error(card->ospriv, "failed to run bh.\n");
+ card->bh_reason_host = 0;
+
+ /*
+ * The bulk data buffer will be freed by the caller.
+ * We need to invalidate the description of the bulk data in our
+ * soft queue, to prevent the core freeing the bulk data again later.
+ */
+ for (i = 0; i < UNIFI_MAX_DATA_REFERENCES; ++i)
+ {
+ if (csptr->bulkdata[i].data_length != 0)
+ {
+ csptr->bulkdata[i].os_data_ptr = csptr->bulkdata[i].os_net_buf_ptr = NULL;
+ csptr->bulkdata[i].net_buf_length = csptr->bulkdata[i].data_length = 0;
+ }
+ }
+ return r;
+ }
+ }
+ else
+ {
+ unifi_error(card->ospriv, "run_bh=%d, bh not called.\n", run_bh);
+ }
+
+ /*
+ * Have we used up all the fh signal list entries?
+ */
+ if (CSR_WIFI_HIP_Q_SLOTS_FREE(sigq) == 0)
+ {
+ /* We have filled the queue, so stop the upper layer. The command queue
+ * is an exception, as suspending due to that being full could delay
+ * resume/retry until new commands or data are received.
+ */
+ if (sigq != &card->fh_command_queue)
+ {
+ /*
+ * Must call unifi_pause_xmit() *before* setting the paused flag.
+ * (the unifi_pause_xmit call should not be after setting the flag because of the possibility of being interrupted
+ * by the bh thread between our setting the flag and the call to unifi_pause_xmit()
+ * If bh thread then cleared the flag, we would end up paused, but without the flag set)
+ * Instead, setting it afterwards means that if this thread is interrupted by the bh thread
+ * the pause flag is still guaranteed to end up set
+ * However the potential deadlock now is that if bh thread emptied the queue and cleared the flag before this thread's
+ * call to unifi_pause_xmit(), then bh thread may not run again because it will be waiting for
+ * a packet to appear in the queue but nothing ever will because xmit is paused.
+ * So we will end up with the queue paused, and the flag set to say it is paused, but bh never runs to unpause it.
+ * (Note even this bad situation would not persist long in practice, because something else (eg rx, or tx in different queue)
+ * is likely to wake bh thread quite soon)
+ * But to avoid this deadlock completely, after setting the flag we check that there is something left in the queue.
+ * If there is, we know that bh thread has not emptied the queue yet.
+ * Since bh thread checks to unpause the queue *after* taking packets from the queue, we know that it is still going to make at
+ * least one more check to see whether it needs to unpause the queue. So all is well.
+ * If there are no packets in the queue, then the deadlock described above might happen. To make sure it does not, we
+ * unpause the queue here. A possible side effect is that unifi_restart_xmit() may (rarely) be called for second time
+ * unnecessarily, which is harmless
+ */
+
+#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_DATA_PLANE_PROFILE)
+ unifi_debug_log_to_buf("P");
+#endif
+ unifi_pause_xmit(card->ospriv, (unifi_TrafficQueue)priority_q);
+ card_tx_q_pause(card, priority_q);
+ if (CSR_WIFI_HIP_Q_SLOTS_USED(sigq) == 0)
+ {
+ card_tx_q_unpause(card, priority_q);
+ unifi_restart_xmit(card->ospriv, (unifi_TrafficQueue) priority_q);
+ }
+ }
+ else
+ {
+ unifi_warning(card->ospriv,
+ "send_signal: fh_cmd_q full, not pausing (run_bh=%d)\n",
+ run_bh);
+ }
+ }
+
+ func_exit();
+
+ return CSR_RESULT_SUCCESS;
+} /* send_signal() */
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * unifi_send_signal
+ *
+ * Invokes send_signal() to queue a signal in the command or traffic queue
+ * If sigptr pointer is NULL, it pokes the bh to check if UniFi is responsive.
+ *
+ * Arguments:
+ * card Pointer to card context struct
+ * sigptr Pointer to signal from card.
+ * siglen Size of the signal
+ * bulkdata Pointer to the bulk data of the signal
+ *
+ * Returns:
+ * CSR_RESULT_SUCCESS on success
+ * CSR_WIFI_HIP_RESULT_NO_SPACE if there were insufficient data slots or no free signal queue entry
+ *
+ * Notes:
+ * unifi_send_signal() is used to queue signals, created by the driver,
+ * to the device. Signals are constructed using the UniFi packed structures.
+ * ---------------------------------------------------------------------------
+ */
+CsrResult unifi_send_signal(card_t *card, const u8 *sigptr, u32 siglen,
+ const bulk_data_param_t *bulkdata)
+{
+ q_t *sig_soft_q;
+ u16 signal_id;
+ CsrResult r;
+ u32 run_bh;
+ u32 priority_q;
+
+ /* A NULL signal pointer is a request to check if UniFi is responsive */
+ if (sigptr == NULL)
+ {
+ card->bh_reason_host = 1;
+ return unifi_run_bh(card->ospriv);
+ }
+
+ priority_q = 0;
+ run_bh = 1;
+ signal_id = GET_SIGNAL_ID(sigptr);
+ /*
+ * If the signal is a CSR_MA_PACKET_REQUEST ,
+ * we send it using the traffic soft queue. Else we use the command soft queue.
+ */
+ if (signal_id == CSR_MA_PACKET_REQUEST_ID)
+ {
+ u16 frame_priority;
+
+ if (card->periodic_wake_mode == UNIFI_PERIODIC_WAKE_HOST_ENABLED)
+ {
+ run_bh = 0;
+ }
+
+#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_DATA_PLANE_PROFILE)
+ unifi_debug_log_to_buf("D");
+#endif
+ /* Sanity check: MA-PACKET.req must have a valid bulk data */
+ if ((bulkdata->d[0].data_length == 0) || (bulkdata->d[0].os_data_ptr == NULL))
+ {
+ unifi_error(card->ospriv, "MA-PACKET.req with empty bulk data (%d bytes in %p)\n",
+ bulkdata->d[0].data_length, bulkdata->d[0].os_data_ptr);
+ dump((void *)sigptr, siglen);
+ return CSR_RESULT_FAILURE;
+ }
+
+ /* Map the frame priority to a traffic queue index. */
+ frame_priority = GET_PACKED_MA_PACKET_REQUEST_FRAME_PRIORITY(sigptr);
+ priority_q = unifi_frame_priority_to_queue((CSR_PRIORITY)frame_priority);
+
+ sig_soft_q = &card->fh_traffic_queue[priority_q];
+ }
+ else
+ {
+ sig_soft_q = &card->fh_command_queue;
+ }
+
+ r = send_signal(card, sigptr, siglen, bulkdata, sig_soft_q, priority_q, run_bh);
+ /* On error, the caller must free or requeue bulkdata buffers */
+
+ return r;
+} /* unifi_send_signal() */
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * unifi_send_resources_available
+ *
+ * Examines whether there is available space to queue
+ * a signal in the command or traffic queue
+ *
+ * Arguments:
+ * card Pointer to card context struct
+ * sigptr Pointer to signal.
+ *
+ * Returns:
+ * CSR_RESULT_SUCCESS if resources available
+ * CSR_WIFI_HIP_RESULT_NO_SPACE if there was no free signal queue entry
+ *
+ * Notes:
+ * ---------------------------------------------------------------------------
+ */
+CsrResult unifi_send_resources_available(card_t *card, const u8 *sigptr)
+{
+ q_t *sig_soft_q;
+ u16 signal_id = GET_SIGNAL_ID(sigptr);
+
+ /*
+ * If the signal is a CSR_MA_PACKET_REQUEST ,
+ * we send it using the traffic soft queue. Else we use the command soft queue.
+ */
+ if (signal_id == CSR_MA_PACKET_REQUEST_ID)
+ {
+ u16 frame_priority;
+ u32 priority_q;
+
+ /* Map the frame priority to a traffic queue index. */
+ frame_priority = GET_PACKED_MA_PACKET_REQUEST_FRAME_PRIORITY(sigptr);
+ priority_q = unifi_frame_priority_to_queue((CSR_PRIORITY)frame_priority);
+
+ sig_soft_q = &card->fh_traffic_queue[priority_q];
+ }
+ else
+ {
+ sig_soft_q = &card->fh_command_queue;
+ }
+
+ /* Check that the fh_data_queue has a free slot */
+ if (!CSR_WIFI_HIP_Q_SLOTS_FREE(sig_soft_q))
+ {
+ unifi_notice(card->ospriv, "unifi_send_resources_available: %s full\n",
+ sig_soft_q->name);
+ return CSR_WIFI_HIP_RESULT_NO_SPACE;
+ }
+
+ return CSR_RESULT_SUCCESS;
+} /* unifi_send_resources_available() */
+
+
diff --git a/drivers/staging/csr/csr_wifi_hip_signals.c b/drivers/staging/csr/csr_wifi_hip_signals.c
new file mode 100644
index 000000000000..3c821320df00
--- /dev/null
+++ b/drivers/staging/csr/csr_wifi_hip_signals.c
@@ -0,0 +1,1313 @@
+/*****************************************************************************
+
+ (c) Cambridge Silicon Radio Limited 2011
+ All rights reserved and confidential information of CSR
+
+ Refer to LICENSE.txt included with this source for details
+ on the license terms.
+
+*****************************************************************************/
+
+/* Note: this is an auto-generated file. */
+
+
+/* Generated by hip_dd_l_c_gen.pl */
+
+#include "csr_wifi_hip_signals.h"
+
+#include "csr_wifi_hip_unifi.h"
+
+s32 SigGetSize(const CSR_SIGNAL *aSignal)
+{
+ switch (aSignal->SignalPrimitiveHeader.SignalId)
+ {
+ case CSR_MA_PACKET_REQUEST_ID:
+ return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MA_PACKET_REQUEST);
+ case CSR_MA_PACKET_CONFIRM_ID:
+ return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MA_PACKET_CONFIRM);
+ case CSR_MA_PACKET_INDICATION_ID:
+ return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MA_PACKET_INDICATION);
+ case CSR_MA_PACKET_CANCEL_REQUEST_ID:
+ return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MA_PACKET_CANCEL_REQUEST);
+ case CSR_MA_VIF_AVAILABILITY_RESPONSE_ID:
+ return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MA_VIF_AVAILABILITY_RESPONSE);
+ case CSR_MA_VIF_AVAILABILITY_INDICATION_ID:
+ return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MA_VIF_AVAILABILITY_INDICATION);
+ case CSR_MA_PACKET_ERROR_INDICATION_ID:
+ return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MA_PACKET_ERROR_INDICATION);
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_RESET_REQUEST_ID:
+ return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_RESET_REQUEST);
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_RESET_CONFIRM_ID:
+ return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_RESET_CONFIRM);
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_GET_REQUEST_ID:
+ return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_GET_REQUEST);
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_GET_CONFIRM_ID:
+ return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_GET_CONFIRM);
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_SET_REQUEST_ID:
+ return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_SET_REQUEST);
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_SET_CONFIRM_ID:
+ return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_SET_CONFIRM);
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_GET_NEXT_REQUEST_ID:
+ return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_GET_NEXT_REQUEST);
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_GET_NEXT_CONFIRM_ID:
+ return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_GET_NEXT_CONFIRM);
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_POWERMGT_REQUEST_ID:
+ return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_POWERMGT_REQUEST);
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_POWERMGT_CONFIRM_ID:
+ return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_POWERMGT_CONFIRM);
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_SCAN_REQUEST_ID:
+ return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_SCAN_REQUEST);
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_SCAN_CONFIRM_ID:
+ return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_SCAN_CONFIRM);
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_HL_SYNC_REQUEST_ID:
+ return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_HL_SYNC_REQUEST);
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_HL_SYNC_CONFIRM_ID:
+ return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_HL_SYNC_CONFIRM);
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_MEASURE_REQUEST_ID:
+ return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_MEASURE_REQUEST);
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_MEASURE_CONFIRM_ID:
+ return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_MEASURE_CONFIRM);
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_MEASURE_INDICATION_ID:
+ return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_MEASURE_INDICATION);
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_SETKEYS_REQUEST_ID:
+ return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_SETKEYS_REQUEST);
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_SETKEYS_CONFIRM_ID:
+ return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_SETKEYS_CONFIRM);
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_DELETEKEYS_REQUEST_ID:
+ return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_DELETEKEYS_REQUEST);
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_DELETEKEYS_CONFIRM_ID:
+ return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_DELETEKEYS_CONFIRM);
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_AUTONOMOUS_SCAN_LOSS_INDICATION_ID:
+ return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_AUTONOMOUS_SCAN_LOSS_INDICATION);
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_CONNECTED_INDICATION_ID:
+ return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_CONNECTED_INDICATION);
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_SCAN_CANCEL_REQUEST_ID:
+ return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_SCAN_CANCEL_REQUEST);
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_HL_SYNC_CANCEL_REQUEST_ID:
+ return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_HL_SYNC_CANCEL_REQUEST);
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_HL_SYNC_CANCEL_CONFIRM_ID:
+ return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_HL_SYNC_CANCEL_CONFIRM);
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_ADD_PERIODIC_REQUEST_ID:
+ return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_ADD_PERIODIC_REQUEST);
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_ADD_PERIODIC_CONFIRM_ID:
+ return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_ADD_PERIODIC_CONFIRM);
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_DEL_PERIODIC_REQUEST_ID:
+ return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_DEL_PERIODIC_REQUEST);
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_DEL_PERIODIC_CONFIRM_ID:
+ return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_DEL_PERIODIC_CONFIRM);
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_ADD_AUTONOMOUS_SCAN_REQUEST_ID:
+ return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_ADD_AUTONOMOUS_SCAN_REQUEST);
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_ADD_AUTONOMOUS_SCAN_CONFIRM_ID:
+ return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_ADD_AUTONOMOUS_SCAN_CONFIRM);
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_DEL_AUTONOMOUS_SCAN_REQUEST_ID:
+ return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_DEL_AUTONOMOUS_SCAN_REQUEST);
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_DEL_AUTONOMOUS_SCAN_CONFIRM_ID:
+ return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_DEL_AUTONOMOUS_SCAN_CONFIRM);
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_SET_PACKET_FILTER_REQUEST_ID:
+ return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_SET_PACKET_FILTER_REQUEST);
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_SET_PACKET_FILTER_CONFIRM_ID:
+ return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_SET_PACKET_FILTER_CONFIRM);
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_STOP_MEASURE_REQUEST_ID:
+ return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_STOP_MEASURE_REQUEST);
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_STOP_MEASURE_CONFIRM_ID:
+ return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_STOP_MEASURE_CONFIRM);
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_PAUSE_AUTONOMOUS_SCAN_REQUEST_ID:
+ return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_PAUSE_AUTONOMOUS_SCAN_REQUEST);
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_PAUSE_AUTONOMOUS_SCAN_CONFIRM_ID:
+ return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_PAUSE_AUTONOMOUS_SCAN_CONFIRM);
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_AUTONOMOUS_SCAN_DONE_INDICATION_ID:
+ return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_AUTONOMOUS_SCAN_DONE_INDICATION);
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_ADD_TRIGGERED_GET_REQUEST_ID:
+ return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_ADD_TRIGGERED_GET_REQUEST);
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_ADD_TRIGGERED_GET_CONFIRM_ID:
+ return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_ADD_TRIGGERED_GET_CONFIRM);
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_DEL_TRIGGERED_GET_REQUEST_ID:
+ return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_DEL_TRIGGERED_GET_REQUEST);
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_DEL_TRIGGERED_GET_CONFIRM_ID:
+ return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_DEL_TRIGGERED_GET_CONFIRM);
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_TRIGGERED_GET_INDICATION_ID:
+ return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_TRIGGERED_GET_INDICATION);
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_ADD_BLACKOUT_REQUEST_ID:
+ return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_ADD_BLACKOUT_REQUEST);
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_ADD_BLACKOUT_CONFIRM_ID:
+ return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_ADD_BLACKOUT_CONFIRM);
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_BLACKOUT_ENDED_INDICATION_ID:
+ return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_BLACKOUT_ENDED_INDICATION);
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_DEL_BLACKOUT_REQUEST_ID:
+ return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_DEL_BLACKOUT_REQUEST);
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_DEL_BLACKOUT_CONFIRM_ID:
+ return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_DEL_BLACKOUT_CONFIRM);
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_ADD_RX_TRIGGER_REQUEST_ID:
+ return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_ADD_RX_TRIGGER_REQUEST);
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_ADD_RX_TRIGGER_CONFIRM_ID:
+ return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_ADD_RX_TRIGGER_CONFIRM);
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_DEL_RX_TRIGGER_REQUEST_ID:
+ return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_DEL_RX_TRIGGER_REQUEST);
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_DEL_RX_TRIGGER_CONFIRM_ID:
+ return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_DEL_RX_TRIGGER_CONFIRM);
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_CONNECT_STATUS_REQUEST_ID:
+ return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_CONNECT_STATUS_REQUEST);
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_CONNECT_STATUS_CONFIRM_ID:
+ return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_CONNECT_STATUS_CONFIRM);
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_MODIFY_BSS_PARAMETER_REQUEST_ID:
+ return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_MODIFY_BSS_PARAMETER_REQUEST);
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_MODIFY_BSS_PARAMETER_CONFIRM_ID:
+ return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_MODIFY_BSS_PARAMETER_CONFIRM);
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_ADD_TEMPLATE_REQUEST_ID:
+ return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_ADD_TEMPLATE_REQUEST);
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_ADD_TEMPLATE_CONFIRM_ID:
+ return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_ADD_TEMPLATE_CONFIRM);
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_CONFIG_QUEUE_REQUEST_ID:
+ return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_CONFIG_QUEUE_REQUEST);
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_CONFIG_QUEUE_CONFIRM_ID:
+ return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_CONFIG_QUEUE_CONFIRM);
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_ADD_TSPEC_REQUEST_ID:
+ return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_ADD_TSPEC_REQUEST);
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_ADD_TSPEC_CONFIRM_ID:
+ return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_ADD_TSPEC_CONFIRM);
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_DEL_TSPEC_REQUEST_ID:
+ return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_DEL_TSPEC_REQUEST);
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_DEL_TSPEC_CONFIRM_ID:
+ return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_DEL_TSPEC_CONFIRM);
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_START_AGGREGATION_REQUEST_ID:
+ return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_START_AGGREGATION_REQUEST);
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_START_AGGREGATION_CONFIRM_ID:
+ return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_START_AGGREGATION_CONFIRM);
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_BLOCKACK_ERROR_INDICATION_ID:
+ return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_BLOCKACK_ERROR_INDICATION);
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_STOP_AGGREGATION_REQUEST_ID:
+ return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_STOP_AGGREGATION_REQUEST);
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_STOP_AGGREGATION_CONFIRM_ID:
+ return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_STOP_AGGREGATION_CONFIRM);
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_SM_START_REQUEST_ID:
+ return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_SM_START_REQUEST);
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_SM_START_CONFIRM_ID:
+ return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_SM_START_CONFIRM);
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_LEAVE_REQUEST_ID:
+ return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_LEAVE_REQUEST);
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_LEAVE_CONFIRM_ID:
+ return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_LEAVE_CONFIRM);
+#endif
+ case CSR_MLME_SET_TIM_REQUEST_ID:
+ return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_SET_TIM_REQUEST);
+ case CSR_MLME_SET_TIM_CONFIRM_ID:
+ return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_SET_TIM_CONFIRM);
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_GET_KEY_SEQUENCE_REQUEST_ID:
+ return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_GET_KEY_SEQUENCE_REQUEST);
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_GET_KEY_SEQUENCE_CONFIRM_ID:
+ return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_GET_KEY_SEQUENCE_CONFIRM);
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_SET_CHANNEL_REQUEST_ID:
+ return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_SET_CHANNEL_REQUEST);
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_SET_CHANNEL_CONFIRM_ID:
+ return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_SET_CHANNEL_CONFIRM);
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_ADD_MULTICAST_ADDRESS_REQUEST_ID:
+ return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_ADD_MULTICAST_ADDRESS_REQUEST);
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_ADD_MULTICAST_ADDRESS_CONFIRM_ID:
+ return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_MLME_ADD_MULTICAST_ADDRESS_CONFIRM);
+#endif
+ case CSR_DEBUG_STRING_INDICATION_ID:
+ return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_DEBUG_STRING_INDICATION);
+ case CSR_DEBUG_WORD16_INDICATION_ID:
+ return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_DEBUG_WORD16_INDICATION);
+ case CSR_DEBUG_GENERIC_REQUEST_ID:
+ return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_DEBUG_GENERIC_REQUEST);
+ case CSR_DEBUG_GENERIC_CONFIRM_ID:
+ return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_DEBUG_GENERIC_CONFIRM);
+ case CSR_DEBUG_GENERIC_INDICATION_ID:
+ return offsetof(struct CSR_SIGNAL_PRIMITIVE, u) + sizeof(CSR_DEBUG_GENERIC_INDICATION);
+ default:
+ return 0;
+ }
+}
+
+
+s32 SigGetDataRefs(CSR_SIGNAL *aSignal, CSR_DATAREF **aDataRef)
+{
+ s32 numRefs = 0;
+
+ switch (aSignal->SignalPrimitiveHeader.SignalId)
+ {
+ case CSR_MA_PACKET_REQUEST_ID:
+ aDataRef[numRefs++] = &aSignal->u.MaPacketRequest.Data;
+ aDataRef[numRefs++] = &aSignal->u.MaPacketRequest.Dummydataref2;
+ break;
+ case CSR_MA_PACKET_CONFIRM_ID:
+ aDataRef[numRefs++] = &aSignal->u.MaPacketConfirm.Dummydataref1;
+ aDataRef[numRefs++] = &aSignal->u.MaPacketConfirm.Dummydataref2;
+ break;
+ case CSR_MA_PACKET_INDICATION_ID:
+ aDataRef[numRefs++] = &aSignal->u.MaPacketIndication.Data;
+ aDataRef[numRefs++] = &aSignal->u.MaPacketIndication.Dummydataref2;
+ break;
+ case CSR_MA_PACKET_CANCEL_REQUEST_ID:
+ aDataRef[numRefs++] = &aSignal->u.MaPacketCancelRequest.Dummydataref1;
+ aDataRef[numRefs++] = &aSignal->u.MaPacketCancelRequest.Dummydataref2;
+ break;
+ case CSR_MA_VIF_AVAILABILITY_RESPONSE_ID:
+ aDataRef[numRefs++] = &aSignal->u.MaVifAvailabilityResponse.Dummydataref1;
+ aDataRef[numRefs++] = &aSignal->u.MaVifAvailabilityResponse.Dummydataref2;
+ break;
+ case CSR_MA_VIF_AVAILABILITY_INDICATION_ID:
+ aDataRef[numRefs++] = &aSignal->u.MaVifAvailabilityIndication.Dummydataref1;
+ aDataRef[numRefs++] = &aSignal->u.MaVifAvailabilityIndication.Dummydataref2;
+ break;
+ case CSR_MA_PACKET_ERROR_INDICATION_ID:
+ aDataRef[numRefs++] = &aSignal->u.MaPacketErrorIndication.Dummydataref1;
+ aDataRef[numRefs++] = &aSignal->u.MaPacketErrorIndication.Dummydataref2;
+ break;
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_RESET_REQUEST_ID:
+ aDataRef[numRefs++] = &aSignal->u.MlmeResetRequest.Dummydataref1;
+ aDataRef[numRefs++] = &aSignal->u.MlmeResetRequest.Dummydataref2;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_RESET_CONFIRM_ID:
+ aDataRef[numRefs++] = &aSignal->u.MlmeResetConfirm.Dummydataref1;
+ aDataRef[numRefs++] = &aSignal->u.MlmeResetConfirm.Dummydataref2;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_GET_REQUEST_ID:
+ aDataRef[numRefs++] = &aSignal->u.MlmeGetRequest.MibAttribute;
+ aDataRef[numRefs++] = &aSignal->u.MlmeGetRequest.Dummydataref2;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_GET_CONFIRM_ID:
+ aDataRef[numRefs++] = &aSignal->u.MlmeGetConfirm.MibAttributeValue;
+ aDataRef[numRefs++] = &aSignal->u.MlmeGetConfirm.Dummydataref2;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_SET_REQUEST_ID:
+ aDataRef[numRefs++] = &aSignal->u.MlmeSetRequest.MibAttributeValue;
+ aDataRef[numRefs++] = &aSignal->u.MlmeSetRequest.Dummydataref2;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_SET_CONFIRM_ID:
+ aDataRef[numRefs++] = &aSignal->u.MlmeSetConfirm.MibAttributeValue;
+ aDataRef[numRefs++] = &aSignal->u.MlmeSetConfirm.Dummydataref2;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_GET_NEXT_REQUEST_ID:
+ aDataRef[numRefs++] = &aSignal->u.MlmeGetNextRequest.MibAttribute;
+ aDataRef[numRefs++] = &aSignal->u.MlmeGetNextRequest.Dummydataref2;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_GET_NEXT_CONFIRM_ID:
+ aDataRef[numRefs++] = &aSignal->u.MlmeGetNextConfirm.MibAttributeValue;
+ aDataRef[numRefs++] = &aSignal->u.MlmeGetNextConfirm.Dummydataref2;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_POWERMGT_REQUEST_ID:
+ aDataRef[numRefs++] = &aSignal->u.MlmePowermgtRequest.Dummydataref1;
+ aDataRef[numRefs++] = &aSignal->u.MlmePowermgtRequest.Dummydataref2;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_POWERMGT_CONFIRM_ID:
+ aDataRef[numRefs++] = &aSignal->u.MlmePowermgtConfirm.Dummydataref1;
+ aDataRef[numRefs++] = &aSignal->u.MlmePowermgtConfirm.Dummydataref2;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_SCAN_REQUEST_ID:
+ aDataRef[numRefs++] = &aSignal->u.MlmeScanRequest.ChannelList;
+ aDataRef[numRefs++] = &aSignal->u.MlmeScanRequest.InformationElements;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_SCAN_CONFIRM_ID:
+ aDataRef[numRefs++] = &aSignal->u.MlmeScanConfirm.Dummydataref1;
+ aDataRef[numRefs++] = &aSignal->u.MlmeScanConfirm.Dummydataref2;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_HL_SYNC_REQUEST_ID:
+ aDataRef[numRefs++] = &aSignal->u.MlmeHlSyncRequest.Dummydataref1;
+ aDataRef[numRefs++] = &aSignal->u.MlmeHlSyncRequest.Dummydataref2;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_HL_SYNC_CONFIRM_ID:
+ aDataRef[numRefs++] = &aSignal->u.MlmeHlSyncConfirm.Dummydataref1;
+ aDataRef[numRefs++] = &aSignal->u.MlmeHlSyncConfirm.Dummydataref2;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_MEASURE_REQUEST_ID:
+ aDataRef[numRefs++] = &aSignal->u.MlmeMeasureRequest.MeasurementRequestSet;
+ aDataRef[numRefs++] = &aSignal->u.MlmeMeasureRequest.Dummydataref2;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_MEASURE_CONFIRM_ID:
+ aDataRef[numRefs++] = &aSignal->u.MlmeMeasureConfirm.Dummydataref1;
+ aDataRef[numRefs++] = &aSignal->u.MlmeMeasureConfirm.Dummydataref2;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_MEASURE_INDICATION_ID:
+ aDataRef[numRefs++] = &aSignal->u.MlmeMeasureIndication.MeasurementReportSet;
+ aDataRef[numRefs++] = &aSignal->u.MlmeMeasureIndication.Dummydataref2;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_SETKEYS_REQUEST_ID:
+ aDataRef[numRefs++] = &aSignal->u.MlmeSetkeysRequest.Key;
+ aDataRef[numRefs++] = &aSignal->u.MlmeSetkeysRequest.Dummydataref2;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_SETKEYS_CONFIRM_ID:
+ aDataRef[numRefs++] = &aSignal->u.MlmeSetkeysConfirm.Dummydataref1;
+ aDataRef[numRefs++] = &aSignal->u.MlmeSetkeysConfirm.Dummydataref2;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_DELETEKEYS_REQUEST_ID:
+ aDataRef[numRefs++] = &aSignal->u.MlmeDeletekeysRequest.Dummydataref1;
+ aDataRef[numRefs++] = &aSignal->u.MlmeDeletekeysRequest.Dummydataref2;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_DELETEKEYS_CONFIRM_ID:
+ aDataRef[numRefs++] = &aSignal->u.MlmeDeletekeysConfirm.Dummydataref1;
+ aDataRef[numRefs++] = &aSignal->u.MlmeDeletekeysConfirm.Dummydataref2;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_AUTONOMOUS_SCAN_LOSS_INDICATION_ID:
+ aDataRef[numRefs++] = &aSignal->u.MlmeAutonomousScanLossIndication.Dummydataref1;
+ aDataRef[numRefs++] = &aSignal->u.MlmeAutonomousScanLossIndication.Dummydataref2;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_CONNECTED_INDICATION_ID:
+ aDataRef[numRefs++] = &aSignal->u.MlmeConnectedIndication.Dummydataref1;
+ aDataRef[numRefs++] = &aSignal->u.MlmeConnectedIndication.Dummydataref2;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_SCAN_CANCEL_REQUEST_ID:
+ aDataRef[numRefs++] = &aSignal->u.MlmeScanCancelRequest.Dummydataref1;
+ aDataRef[numRefs++] = &aSignal->u.MlmeScanCancelRequest.Dummydataref2;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_HL_SYNC_CANCEL_REQUEST_ID:
+ aDataRef[numRefs++] = &aSignal->u.MlmeHlSyncCancelRequest.Dummydataref1;
+ aDataRef[numRefs++] = &aSignal->u.MlmeHlSyncCancelRequest.Dummydataref2;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_HL_SYNC_CANCEL_CONFIRM_ID:
+ aDataRef[numRefs++] = &aSignal->u.MlmeHlSyncCancelConfirm.Dummydataref1;
+ aDataRef[numRefs++] = &aSignal->u.MlmeHlSyncCancelConfirm.Dummydataref2;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_ADD_PERIODIC_REQUEST_ID:
+ aDataRef[numRefs++] = &aSignal->u.MlmeAddPeriodicRequest.Dummydataref1;
+ aDataRef[numRefs++] = &aSignal->u.MlmeAddPeriodicRequest.Dummydataref2;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_ADD_PERIODIC_CONFIRM_ID:
+ aDataRef[numRefs++] = &aSignal->u.MlmeAddPeriodicConfirm.Dummydataref1;
+ aDataRef[numRefs++] = &aSignal->u.MlmeAddPeriodicConfirm.Dummydataref2;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_DEL_PERIODIC_REQUEST_ID:
+ aDataRef[numRefs++] = &aSignal->u.MlmeDelPeriodicRequest.Dummydataref1;
+ aDataRef[numRefs++] = &aSignal->u.MlmeDelPeriodicRequest.Dummydataref2;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_DEL_PERIODIC_CONFIRM_ID:
+ aDataRef[numRefs++] = &aSignal->u.MlmeDelPeriodicConfirm.Dummydataref1;
+ aDataRef[numRefs++] = &aSignal->u.MlmeDelPeriodicConfirm.Dummydataref2;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_ADD_AUTONOMOUS_SCAN_REQUEST_ID:
+ aDataRef[numRefs++] = &aSignal->u.MlmeAddAutonomousScanRequest.ChannelList;
+ aDataRef[numRefs++] = &aSignal->u.MlmeAddAutonomousScanRequest.InformationElements;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_ADD_AUTONOMOUS_SCAN_CONFIRM_ID:
+ aDataRef[numRefs++] = &aSignal->u.MlmeAddAutonomousScanConfirm.Dummydataref1;
+ aDataRef[numRefs++] = &aSignal->u.MlmeAddAutonomousScanConfirm.Dummydataref2;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_DEL_AUTONOMOUS_SCAN_REQUEST_ID:
+ aDataRef[numRefs++] = &aSignal->u.MlmeDelAutonomousScanRequest.Dummydataref1;
+ aDataRef[numRefs++] = &aSignal->u.MlmeDelAutonomousScanRequest.Dummydataref2;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_DEL_AUTONOMOUS_SCAN_CONFIRM_ID:
+ aDataRef[numRefs++] = &aSignal->u.MlmeDelAutonomousScanConfirm.Dummydataref1;
+ aDataRef[numRefs++] = &aSignal->u.MlmeDelAutonomousScanConfirm.Dummydataref2;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_SET_PACKET_FILTER_REQUEST_ID:
+ aDataRef[numRefs++] = &aSignal->u.MlmeSetPacketFilterRequest.InformationElements;
+ aDataRef[numRefs++] = &aSignal->u.MlmeSetPacketFilterRequest.Dummydataref2;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_SET_PACKET_FILTER_CONFIRM_ID:
+ aDataRef[numRefs++] = &aSignal->u.MlmeSetPacketFilterConfirm.Dummydataref1;
+ aDataRef[numRefs++] = &aSignal->u.MlmeSetPacketFilterConfirm.Dummydataref2;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_STOP_MEASURE_REQUEST_ID:
+ aDataRef[numRefs++] = &aSignal->u.MlmeStopMeasureRequest.Dummydataref1;
+ aDataRef[numRefs++] = &aSignal->u.MlmeStopMeasureRequest.Dummydataref2;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_STOP_MEASURE_CONFIRM_ID:
+ aDataRef[numRefs++] = &aSignal->u.MlmeStopMeasureConfirm.Dummydataref1;
+ aDataRef[numRefs++] = &aSignal->u.MlmeStopMeasureConfirm.Dummydataref2;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_PAUSE_AUTONOMOUS_SCAN_REQUEST_ID:
+ aDataRef[numRefs++] = &aSignal->u.MlmePauseAutonomousScanRequest.Dummydataref1;
+ aDataRef[numRefs++] = &aSignal->u.MlmePauseAutonomousScanRequest.Dummydataref2;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_PAUSE_AUTONOMOUS_SCAN_CONFIRM_ID:
+ aDataRef[numRefs++] = &aSignal->u.MlmePauseAutonomousScanConfirm.Dummydataref1;
+ aDataRef[numRefs++] = &aSignal->u.MlmePauseAutonomousScanConfirm.Dummydataref2;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_AUTONOMOUS_SCAN_DONE_INDICATION_ID:
+ aDataRef[numRefs++] = &aSignal->u.MlmeAutonomousScanDoneIndication.Dummydataref1;
+ aDataRef[numRefs++] = &aSignal->u.MlmeAutonomousScanDoneIndication.Dummydataref2;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_ADD_TRIGGERED_GET_REQUEST_ID:
+ aDataRef[numRefs++] = &aSignal->u.MlmeAddTriggeredGetRequest.MibAttribute;
+ aDataRef[numRefs++] = &aSignal->u.MlmeAddTriggeredGetRequest.Dummydataref2;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_ADD_TRIGGERED_GET_CONFIRM_ID:
+ aDataRef[numRefs++] = &aSignal->u.MlmeAddTriggeredGetConfirm.Dummydataref1;
+ aDataRef[numRefs++] = &aSignal->u.MlmeAddTriggeredGetConfirm.Dummydataref2;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_DEL_TRIGGERED_GET_REQUEST_ID:
+ aDataRef[numRefs++] = &aSignal->u.MlmeDelTriggeredGetRequest.Dummydataref1;
+ aDataRef[numRefs++] = &aSignal->u.MlmeDelTriggeredGetRequest.Dummydataref2;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_DEL_TRIGGERED_GET_CONFIRM_ID:
+ aDataRef[numRefs++] = &aSignal->u.MlmeDelTriggeredGetConfirm.Dummydataref1;
+ aDataRef[numRefs++] = &aSignal->u.MlmeDelTriggeredGetConfirm.Dummydataref2;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_TRIGGERED_GET_INDICATION_ID:
+ aDataRef[numRefs++] = &aSignal->u.MlmeTriggeredGetIndication.MibAttributeValue;
+ aDataRef[numRefs++] = &aSignal->u.MlmeTriggeredGetIndication.Dummydataref2;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_ADD_BLACKOUT_REQUEST_ID:
+ aDataRef[numRefs++] = &aSignal->u.MlmeAddBlackoutRequest.Dummydataref1;
+ aDataRef[numRefs++] = &aSignal->u.MlmeAddBlackoutRequest.Dummydataref2;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_ADD_BLACKOUT_CONFIRM_ID:
+ aDataRef[numRefs++] = &aSignal->u.MlmeAddBlackoutConfirm.Dummydataref1;
+ aDataRef[numRefs++] = &aSignal->u.MlmeAddBlackoutConfirm.Dummydataref2;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_BLACKOUT_ENDED_INDICATION_ID:
+ aDataRef[numRefs++] = &aSignal->u.MlmeBlackoutEndedIndication.Dummydataref1;
+ aDataRef[numRefs++] = &aSignal->u.MlmeBlackoutEndedIndication.Dummydataref2;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_DEL_BLACKOUT_REQUEST_ID:
+ aDataRef[numRefs++] = &aSignal->u.MlmeDelBlackoutRequest.Dummydataref1;
+ aDataRef[numRefs++] = &aSignal->u.MlmeDelBlackoutRequest.Dummydataref2;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_DEL_BLACKOUT_CONFIRM_ID:
+ aDataRef[numRefs++] = &aSignal->u.MlmeDelBlackoutConfirm.Dummydataref1;
+ aDataRef[numRefs++] = &aSignal->u.MlmeDelBlackoutConfirm.Dummydataref2;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_ADD_RX_TRIGGER_REQUEST_ID:
+ aDataRef[numRefs++] = &aSignal->u.MlmeAddRxTriggerRequest.InformationElements;
+ aDataRef[numRefs++] = &aSignal->u.MlmeAddRxTriggerRequest.Dummydataref2;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_ADD_RX_TRIGGER_CONFIRM_ID:
+ aDataRef[numRefs++] = &aSignal->u.MlmeAddRxTriggerConfirm.Dummydataref1;
+ aDataRef[numRefs++] = &aSignal->u.MlmeAddRxTriggerConfirm.Dummydataref2;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_DEL_RX_TRIGGER_REQUEST_ID:
+ aDataRef[numRefs++] = &aSignal->u.MlmeDelRxTriggerRequest.Dummydataref1;
+ aDataRef[numRefs++] = &aSignal->u.MlmeDelRxTriggerRequest.Dummydataref2;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_DEL_RX_TRIGGER_CONFIRM_ID:
+ aDataRef[numRefs++] = &aSignal->u.MlmeDelRxTriggerConfirm.Dummydataref1;
+ aDataRef[numRefs++] = &aSignal->u.MlmeDelRxTriggerConfirm.Dummydataref2;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_CONNECT_STATUS_REQUEST_ID:
+ aDataRef[numRefs++] = &aSignal->u.MlmeConnectStatusRequest.InformationElements;
+ aDataRef[numRefs++] = &aSignal->u.MlmeConnectStatusRequest.Dummydataref2;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_CONNECT_STATUS_CONFIRM_ID:
+ aDataRef[numRefs++] = &aSignal->u.MlmeConnectStatusConfirm.Dummydataref1;
+ aDataRef[numRefs++] = &aSignal->u.MlmeConnectStatusConfirm.Dummydataref2;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_MODIFY_BSS_PARAMETER_REQUEST_ID:
+ aDataRef[numRefs++] = &aSignal->u.MlmeModifyBssParameterRequest.Data;
+ aDataRef[numRefs++] = &aSignal->u.MlmeModifyBssParameterRequest.Dummydataref2;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_MODIFY_BSS_PARAMETER_CONFIRM_ID:
+ aDataRef[numRefs++] = &aSignal->u.MlmeModifyBssParameterConfirm.Dummydataref1;
+ aDataRef[numRefs++] = &aSignal->u.MlmeModifyBssParameterConfirm.Dummydataref2;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_ADD_TEMPLATE_REQUEST_ID:
+ aDataRef[numRefs++] = &aSignal->u.MlmeAddTemplateRequest.Data1;
+ aDataRef[numRefs++] = &aSignal->u.MlmeAddTemplateRequest.Data2;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_ADD_TEMPLATE_CONFIRM_ID:
+ aDataRef[numRefs++] = &aSignal->u.MlmeAddTemplateConfirm.Dummydataref1;
+ aDataRef[numRefs++] = &aSignal->u.MlmeAddTemplateConfirm.Dummydataref2;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_CONFIG_QUEUE_REQUEST_ID:
+ aDataRef[numRefs++] = &aSignal->u.MlmeConfigQueueRequest.Dummydataref1;
+ aDataRef[numRefs++] = &aSignal->u.MlmeConfigQueueRequest.Dummydataref2;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_CONFIG_QUEUE_CONFIRM_ID:
+ aDataRef[numRefs++] = &aSignal->u.MlmeConfigQueueConfirm.Dummydataref1;
+ aDataRef[numRefs++] = &aSignal->u.MlmeConfigQueueConfirm.Dummydataref2;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_ADD_TSPEC_REQUEST_ID:
+ aDataRef[numRefs++] = &aSignal->u.MlmeAddTspecRequest.Dummydataref1;
+ aDataRef[numRefs++] = &aSignal->u.MlmeAddTspecRequest.Dummydataref2;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_ADD_TSPEC_CONFIRM_ID:
+ aDataRef[numRefs++] = &aSignal->u.MlmeAddTspecConfirm.Dummydataref1;
+ aDataRef[numRefs++] = &aSignal->u.MlmeAddTspecConfirm.Dummydataref2;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_DEL_TSPEC_REQUEST_ID:
+ aDataRef[numRefs++] = &aSignal->u.MlmeDelTspecRequest.Dummydataref1;
+ aDataRef[numRefs++] = &aSignal->u.MlmeDelTspecRequest.Dummydataref2;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_DEL_TSPEC_CONFIRM_ID:
+ aDataRef[numRefs++] = &aSignal->u.MlmeDelTspecConfirm.Dummydataref1;
+ aDataRef[numRefs++] = &aSignal->u.MlmeDelTspecConfirm.Dummydataref2;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_START_AGGREGATION_REQUEST_ID:
+ aDataRef[numRefs++] = &aSignal->u.MlmeStartAggregationRequest.Dummydataref1;
+ aDataRef[numRefs++] = &aSignal->u.MlmeStartAggregationRequest.Dummydataref2;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_START_AGGREGATION_CONFIRM_ID:
+ aDataRef[numRefs++] = &aSignal->u.MlmeStartAggregationConfirm.Dummydataref1;
+ aDataRef[numRefs++] = &aSignal->u.MlmeStartAggregationConfirm.Dummydataref2;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_BLOCKACK_ERROR_INDICATION_ID:
+ aDataRef[numRefs++] = &aSignal->u.MlmeBlockackErrorIndication.Dummydataref1;
+ aDataRef[numRefs++] = &aSignal->u.MlmeBlockackErrorIndication.Dummydataref2;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_STOP_AGGREGATION_REQUEST_ID:
+ aDataRef[numRefs++] = &aSignal->u.MlmeStopAggregationRequest.Dummydataref1;
+ aDataRef[numRefs++] = &aSignal->u.MlmeStopAggregationRequest.Dummydataref2;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_STOP_AGGREGATION_CONFIRM_ID:
+ aDataRef[numRefs++] = &aSignal->u.MlmeStopAggregationConfirm.Dummydataref1;
+ aDataRef[numRefs++] = &aSignal->u.MlmeStopAggregationConfirm.Dummydataref2;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_SM_START_REQUEST_ID:
+ aDataRef[numRefs++] = &aSignal->u.MlmeSmStartRequest.Beacon;
+ aDataRef[numRefs++] = &aSignal->u.MlmeSmStartRequest.BssParameters;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_SM_START_CONFIRM_ID:
+ aDataRef[numRefs++] = &aSignal->u.MlmeSmStartConfirm.Dummydataref1;
+ aDataRef[numRefs++] = &aSignal->u.MlmeSmStartConfirm.Dummydataref2;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_LEAVE_REQUEST_ID:
+ aDataRef[numRefs++] = &aSignal->u.MlmeLeaveRequest.Dummydataref1;
+ aDataRef[numRefs++] = &aSignal->u.MlmeLeaveRequest.Dummydataref2;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_LEAVE_CONFIRM_ID:
+ aDataRef[numRefs++] = &aSignal->u.MlmeLeaveConfirm.Dummydataref1;
+ aDataRef[numRefs++] = &aSignal->u.MlmeLeaveConfirm.Dummydataref2;
+ break;
+#endif
+ case CSR_MLME_SET_TIM_REQUEST_ID:
+ aDataRef[numRefs++] = &aSignal->u.MlmeSetTimRequest.Dummydataref1;
+ aDataRef[numRefs++] = &aSignal->u.MlmeSetTimRequest.Dummydataref2;
+ break;
+ case CSR_MLME_SET_TIM_CONFIRM_ID:
+ aDataRef[numRefs++] = &aSignal->u.MlmeSetTimConfirm.Dummydataref1;
+ aDataRef[numRefs++] = &aSignal->u.MlmeSetTimConfirm.Dummydataref2;
+ break;
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_GET_KEY_SEQUENCE_REQUEST_ID:
+ aDataRef[numRefs++] = &aSignal->u.MlmeGetKeySequenceRequest.Dummydataref1;
+ aDataRef[numRefs++] = &aSignal->u.MlmeGetKeySequenceRequest.Dummydataref2;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_GET_KEY_SEQUENCE_CONFIRM_ID:
+ aDataRef[numRefs++] = &aSignal->u.MlmeGetKeySequenceConfirm.Dummydataref1;
+ aDataRef[numRefs++] = &aSignal->u.MlmeGetKeySequenceConfirm.Dummydataref2;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_SET_CHANNEL_REQUEST_ID:
+ aDataRef[numRefs++] = &aSignal->u.MlmeSetChannelRequest.Dummydataref1;
+ aDataRef[numRefs++] = &aSignal->u.MlmeSetChannelRequest.Dummydataref2;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_SET_CHANNEL_CONFIRM_ID:
+ aDataRef[numRefs++] = &aSignal->u.MlmeSetChannelConfirm.Dummydataref1;
+ aDataRef[numRefs++] = &aSignal->u.MlmeSetChannelConfirm.Dummydataref2;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_ADD_MULTICAST_ADDRESS_REQUEST_ID:
+ aDataRef[numRefs++] = &aSignal->u.MlmeAddMulticastAddressRequest.Data;
+ aDataRef[numRefs++] = &aSignal->u.MlmeAddMulticastAddressRequest.Dummydataref2;
+ break;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_ADD_MULTICAST_ADDRESS_CONFIRM_ID:
+ aDataRef[numRefs++] = &aSignal->u.MlmeAddMulticastAddressConfirm.Dummydataref1;
+ aDataRef[numRefs++] = &aSignal->u.MlmeAddMulticastAddressConfirm.Dummydataref2;
+ break;
+#endif
+ case CSR_DEBUG_STRING_INDICATION_ID:
+ aDataRef[numRefs++] = &aSignal->u.DebugStringIndication.DebugMessage;
+ aDataRef[numRefs++] = &aSignal->u.DebugStringIndication.Dummydataref2;
+ break;
+ case CSR_DEBUG_WORD16_INDICATION_ID:
+ aDataRef[numRefs++] = &aSignal->u.DebugWord16Indication.Dummydataref1;
+ aDataRef[numRefs++] = &aSignal->u.DebugWord16Indication.Dummydataref2;
+ break;
+ case CSR_DEBUG_GENERIC_REQUEST_ID:
+ aDataRef[numRefs++] = &aSignal->u.DebugGenericRequest.DebugVariable;
+ aDataRef[numRefs++] = &aSignal->u.DebugGenericRequest.Dummydataref2;
+ break;
+ case CSR_DEBUG_GENERIC_CONFIRM_ID:
+ aDataRef[numRefs++] = &aSignal->u.DebugGenericConfirm.DebugVariable;
+ aDataRef[numRefs++] = &aSignal->u.DebugGenericConfirm.Dummydataref2;
+ break;
+ case CSR_DEBUG_GENERIC_INDICATION_ID:
+ aDataRef[numRefs++] = &aSignal->u.DebugGenericIndication.DebugVariable;
+ aDataRef[numRefs++] = &aSignal->u.DebugGenericIndication.Dummydataref2;
+ break;
+ default:
+ return 0;
+ }
+ return numRefs;
+}
+
+
+u32 SigGetFilterPos(u16 aSigID)
+{
+ switch (aSigID)
+ {
+ case CSR_MA_PACKET_REQUEST_ID:
+ return 0x00000001;
+ case CSR_MA_PACKET_CONFIRM_ID:
+ return 0x00000002;
+ case CSR_MA_PACKET_INDICATION_ID:
+ return 0x00000004;
+ case CSR_MA_PACKET_CANCEL_REQUEST_ID:
+ return 0x00000008;
+ case CSR_MA_VIF_AVAILABILITY_RESPONSE_ID:
+ return 0x00000010;
+ case CSR_MA_VIF_AVAILABILITY_INDICATION_ID:
+ return 0x00000020;
+ case CSR_MA_PACKET_ERROR_INDICATION_ID:
+ return 0x00000040;
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_RESET_REQUEST_ID:
+ return 0x00000080;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_RESET_CONFIRM_ID:
+ return 0x00000100;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_GET_REQUEST_ID:
+ return 0x00000200;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_GET_CONFIRM_ID:
+ return 0x00000400;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_SET_REQUEST_ID:
+ return 0x00000800;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_SET_CONFIRM_ID:
+ return 0x00001000;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_GET_NEXT_REQUEST_ID:
+ return 0x00002000;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_GET_NEXT_CONFIRM_ID:
+ return 0x00004000;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_POWERMGT_REQUEST_ID:
+ return 0x00008000;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_POWERMGT_CONFIRM_ID:
+ return 0x00010001;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_SCAN_REQUEST_ID:
+ return 0x00010002;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_SCAN_CONFIRM_ID:
+ return 0x00010004;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_HL_SYNC_REQUEST_ID:
+ return 0x00010008;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_HL_SYNC_CONFIRM_ID:
+ return 0x00010010;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_MEASURE_REQUEST_ID:
+ return 0x00010020;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_MEASURE_CONFIRM_ID:
+ return 0x00010040;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_MEASURE_INDICATION_ID:
+ return 0x00010080;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_SETKEYS_REQUEST_ID:
+ return 0x00010100;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_SETKEYS_CONFIRM_ID:
+ return 0x00010200;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_DELETEKEYS_REQUEST_ID:
+ return 0x00010400;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_DELETEKEYS_CONFIRM_ID:
+ return 0x00010800;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_AUTONOMOUS_SCAN_LOSS_INDICATION_ID:
+ return 0x00011000;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_CONNECTED_INDICATION_ID:
+ return 0x00012000;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_SCAN_CANCEL_REQUEST_ID:
+ return 0x00014000;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_HL_SYNC_CANCEL_REQUEST_ID:
+ return 0x00018000;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_HL_SYNC_CANCEL_CONFIRM_ID:
+ return 0x00020001;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_ADD_PERIODIC_REQUEST_ID:
+ return 0x00020002;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_ADD_PERIODIC_CONFIRM_ID:
+ return 0x00020004;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_DEL_PERIODIC_REQUEST_ID:
+ return 0x00020008;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_DEL_PERIODIC_CONFIRM_ID:
+ return 0x00020010;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_ADD_AUTONOMOUS_SCAN_REQUEST_ID:
+ return 0x00020020;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_ADD_AUTONOMOUS_SCAN_CONFIRM_ID:
+ return 0x00020040;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_DEL_AUTONOMOUS_SCAN_REQUEST_ID:
+ return 0x00020080;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_DEL_AUTONOMOUS_SCAN_CONFIRM_ID:
+ return 0x00020100;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_SET_PACKET_FILTER_REQUEST_ID:
+ return 0x00020200;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_SET_PACKET_FILTER_CONFIRM_ID:
+ return 0x00020400;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_STOP_MEASURE_REQUEST_ID:
+ return 0x00020800;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_STOP_MEASURE_CONFIRM_ID:
+ return 0x00021000;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_PAUSE_AUTONOMOUS_SCAN_REQUEST_ID:
+ return 0x00022000;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_PAUSE_AUTONOMOUS_SCAN_CONFIRM_ID:
+ return 0x00024000;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_AUTONOMOUS_SCAN_DONE_INDICATION_ID:
+ return 0x00028000;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_ADD_TRIGGERED_GET_REQUEST_ID:
+ return 0x00030001;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_ADD_TRIGGERED_GET_CONFIRM_ID:
+ return 0x00030002;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_DEL_TRIGGERED_GET_REQUEST_ID:
+ return 0x00030004;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_DEL_TRIGGERED_GET_CONFIRM_ID:
+ return 0x00030008;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_TRIGGERED_GET_INDICATION_ID:
+ return 0x00030010;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_ADD_BLACKOUT_REQUEST_ID:
+ return 0x00030020;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_ADD_BLACKOUT_CONFIRM_ID:
+ return 0x00030040;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_BLACKOUT_ENDED_INDICATION_ID:
+ return 0x00030080;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_DEL_BLACKOUT_REQUEST_ID:
+ return 0x00030100;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_DEL_BLACKOUT_CONFIRM_ID:
+ return 0x00030200;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_ADD_RX_TRIGGER_REQUEST_ID:
+ return 0x00030400;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_ADD_RX_TRIGGER_CONFIRM_ID:
+ return 0x00030800;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_DEL_RX_TRIGGER_REQUEST_ID:
+ return 0x00031000;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_DEL_RX_TRIGGER_CONFIRM_ID:
+ return 0x00032000;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_CONNECT_STATUS_REQUEST_ID:
+ return 0x00034000;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_CONNECT_STATUS_CONFIRM_ID:
+ return 0x00038000;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_MODIFY_BSS_PARAMETER_REQUEST_ID:
+ return 0x00040001;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_MODIFY_BSS_PARAMETER_CONFIRM_ID:
+ return 0x00040002;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_ADD_TEMPLATE_REQUEST_ID:
+ return 0x00040004;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_ADD_TEMPLATE_CONFIRM_ID:
+ return 0x00040008;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_CONFIG_QUEUE_REQUEST_ID:
+ return 0x00040010;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_CONFIG_QUEUE_CONFIRM_ID:
+ return 0x00040020;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_ADD_TSPEC_REQUEST_ID:
+ return 0x00040040;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_ADD_TSPEC_CONFIRM_ID:
+ return 0x00040080;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_DEL_TSPEC_REQUEST_ID:
+ return 0x00040100;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_DEL_TSPEC_CONFIRM_ID:
+ return 0x00040200;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_START_AGGREGATION_REQUEST_ID:
+ return 0x00040400;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_START_AGGREGATION_CONFIRM_ID:
+ return 0x00040800;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_BLOCKACK_ERROR_INDICATION_ID:
+ return 0x00041000;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_STOP_AGGREGATION_REQUEST_ID:
+ return 0x00042000;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_STOP_AGGREGATION_CONFIRM_ID:
+ return 0x00044000;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_SM_START_REQUEST_ID:
+ return 0x00048000;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_SM_START_CONFIRM_ID:
+ return 0x00050001;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_LEAVE_REQUEST_ID:
+ return 0x00050002;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_LEAVE_CONFIRM_ID:
+ return 0x00050004;
+#endif
+ case CSR_MLME_SET_TIM_REQUEST_ID:
+ return 0x00050008;
+ case CSR_MLME_SET_TIM_CONFIRM_ID:
+ return 0x00050010;
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_GET_KEY_SEQUENCE_REQUEST_ID:
+ return 0x00050020;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_GET_KEY_SEQUENCE_CONFIRM_ID:
+ return 0x00050040;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_SET_CHANNEL_REQUEST_ID:
+ return 0x00050080;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_SET_CHANNEL_CONFIRM_ID:
+ return 0x00050100;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_ADD_MULTICAST_ADDRESS_REQUEST_ID:
+ return 0x00050200;
+#endif
+#ifdef CSR_WIFI_HIP_FULL_SIGNAL_SET
+ case CSR_MLME_ADD_MULTICAST_ADDRESS_CONFIRM_ID:
+ return 0x00050400;
+#endif
+ case CSR_DEBUG_STRING_INDICATION_ID:
+ return 0x00050800;
+ case CSR_DEBUG_WORD16_INDICATION_ID:
+ return 0x00051000;
+ case CSR_DEBUG_GENERIC_REQUEST_ID:
+ return 0x00052000;
+ case CSR_DEBUG_GENERIC_CONFIRM_ID:
+ return 0x00054000;
+ case CSR_DEBUG_GENERIC_INDICATION_ID:
+ return 0x00058000;
+ default:
+ break;
+ }
+ return 0xffffffff;
+}
+
+
diff --git a/drivers/staging/csr/csr_wifi_hip_signals.h b/drivers/staging/csr/csr_wifi_hip_signals.h
new file mode 100644
index 000000000000..5f841556bbef
--- /dev/null
+++ b/drivers/staging/csr/csr_wifi_hip_signals.h
@@ -0,0 +1,137 @@
+/*****************************************************************************
+
+ (c) Cambridge Silicon Radio Limited 2011
+ All rights reserved and confidential information of CSR
+
+ Refer to LICENSE.txt included with this source for details
+ on the license terms.
+
+*****************************************************************************/
+
+/*
+ *****************************************************************************
+ *
+ * FILE: csr_wifi_hip_signals.h
+ *
+ * PURPOSE:
+ * Header file wrapping the auto-generated code in csr_wifi_hip_sigs.h
+ * and csr_wifi_hip_signals.c -
+ * csr_wifi_hip_sigs.h provides structures defining UniFi signals and
+ * csr_wifi_hip_signals.c provides SigGetSize() and SigGetDataRefs().
+ *
+ *****************************************************************************
+ */
+#ifndef __CSR_WIFI_HIP_SIGNALS_H__
+#define __CSR_WIFI_HIP_SIGNALS_H__
+
+#include <linux/types.h>
+#include "csr_wifi_hip_sigs.h"
+
+
+/****************************************************************************/
+/* INFORMATION ELEMENTS */
+/****************************************************************************/
+
+/* Information Element ID's - shouldn't be in here, but nowhere better yet */
+#define IE_SSID_ID 0
+#define IE_SUPPORTED_RATES_ID 1
+#define IE_FH_PARAM_SET_ID 2
+#define IE_DS_PARAM_SET_ID 3
+#define IE_CF_PARAM_SET_ID 4
+#define IE_TIM_ID 5
+#define IE_IBSS_PARAM_SET_ID 6
+#define IE_COUNTRY_ID 7
+#define IE_HOPPING_PATTERN_PARAMS_ID 8
+#define IE_HOPPING_PATTERN_TABLE_ID 9
+#define IE_REQUEST_ID 10
+#define IE_QBSS_LOAD_ID 11
+#define IE_EDCA_PARAM_SET_ID 12
+#define IE_TRAFFIC_SPEC_ID 13
+#define IE_TRAFFIC_CLASS_ID 14
+#define IE_SCHEDULE_ID 15
+#define IE_CHALLENGE_TEXT_ID 16
+#define IE_POWER_CONSTRAINT_ID 32
+#define IE_POWER_CAPABILITY_ID 33
+#define IE_TPC_REQUEST_ID 34
+#define IE_TPC_REPORT_ID 35
+#define IE_SUPPORTED_CHANNELS_ID 36
+#define IE_CHANNEL_SWITCH_ANNOUNCE_ID 37
+#define IE_MEASUREMENT_REQUEST_ID 38
+#define IE_MEASUREMENT_REPORT_ID 39
+#define IE_QUIET_ID 40
+#define IE_IBSS_DFS_ID 41
+#define IE_ERP_INFO_ID 42
+#define IE_TS_DELAY_ID 43
+#define IE_TCLAS_PROCESSING_ID 44
+#define IE_QOS_CAPABILITY_ID 46
+#define IE_RSN_ID 48
+#define IE_EXTENDED_SUPPORTED_RATES_ID 50
+#define IE_AP_CHANNEL_REPORT_ID 52
+#define IE_RCPI_ID 53
+#define IE_WPA_ID 221
+
+
+/* The maximum number of data references in a signal structure */
+#define UNIFI_MAX_DATA_REFERENCES 2
+
+/* The space to allow for a wire-format signal structure */
+#define UNIFI_PACKED_SIGBUF_SIZE 64
+
+
+/******************************************************************************/
+/* SIGNAL PARAMETER VALUES */
+/******************************************************************************/
+
+/* ifIndex */
+#define UNIFI_IF_2G4 1
+#define UNIFI_IF_5G 2
+
+/* SendProcessId */
+#define HOST_PROC_ID 0xc000
+
+#define SIG_CAP_ESS 0x0001
+#define SIG_CAP_IBSS 0x0002
+#define SIG_CAP_CF_POLLABLE 0x0004
+#define SIG_CAP_CF_POLL_REQUEST 0x0008
+#define SIG_CAP_PRIVACY 0x0010
+#define SIG_CAP_SHORT_PREAMBLE 0x0020
+#define SIG_CAP_DSSSOFDM 0x2000
+
+/******************************************************************************/
+/* FUNCTION DECLARATIONS */
+/******************************************************************************/
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+/******************************************************************************
+ * SigGetNumDataRefs - Retrieve pointers to data-refs from a signal.
+ *
+ * PARAMETERS:
+ * aSignal - Pointer to signal to retrieve the data refs of.
+ * aDataRef - Address of a pointer to the structure that the data refs
+ * pointers will be stored.
+ *
+ * RETURNS:
+ * The number of data-refs in the signal.
+ */
+s32 SigGetDataRefs(CSR_SIGNAL *aSignal, CSR_DATAREF **aDataRef);
+
+/******************************************************************************
+ * SigGetSize - Retrieve the size (in bytes) of a given signal.
+ *
+ * PARAMETERS:
+ * aSignal - Pointer to signal to retrieve size of.
+ *
+ * RETURNS:
+ * The size (in bytes) of the given signal.
+ */
+s32 SigGetSize(const CSR_SIGNAL *aSignal);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+
+#endif /* __CSR_WIFI_HIP_SIGNALS_H__ */
diff --git a/drivers/staging/csr/csr_wifi_hip_sigs.h b/drivers/staging/csr/csr_wifi_hip_sigs.h
new file mode 100644
index 000000000000..2b9f51d7f296
--- /dev/null
+++ b/drivers/staging/csr/csr_wifi_hip_sigs.h
@@ -0,0 +1,1425 @@
+/*****************************************************************************
+
+ (c) Cambridge Silicon Radio Limited 2011
+ All rights reserved and confidential information of CSR
+
+ Refer to LICENSE.txt included with this source for details
+ on the license terms.
+
+*****************************************************************************/
+
+/* Note: this is an auto-generated file. */
+
+
+/* Generated by hip_dd_l_h_gen.pl */
+
+#ifndef CSR_WIFI_HIP_SIGS_H
+#define CSR_WIFI_HIP_SIGS_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef s16 csr_place_holding_type;
+
+typedef u16 CSR_ASSOCIATION_ID;
+
+typedef u16 CSR_AUTONOMOUS_SCAN_ID;
+
+typedef u16 CSR_BEACON_PERIODS;
+
+typedef u16 CSR_BLACKOUT_ID;
+
+typedef enum CSR_BLACKOUT_SOURCE
+{
+ CSR_DOT11_LOCAL = 0x0000,
+ CSR_DOT11_REMOTE = 0x0001,
+ CSR_OTHER_RADIO = 0x0002,
+ CSR_NOT_LINKED = 0x0004
+} CSR_BLACKOUT_SOURCE;
+
+typedef enum CSR_BLACKOUT_TYPE
+{
+ CSR_LOCAL_DEVICE_ONLY = 0x0001,
+ CSR_SPECIFIED_PEER = 0x0002,
+ CSR_CURRENT_CHANNEL = 0x0004,
+ CSR_P2P = 0x0008
+} CSR_BLACKOUT_TYPE;
+
+typedef enum CSR_BOOT_LOADER_OPERATION
+{
+ CSR_BOOT_LOADER_IDLE = 0x00,
+ CSR_BOOT_LOADER_RESTART = 0x01,
+ CSR_BOOT_LOADER_PATCH = 0x02,
+ CSR_BOOT_LOADER_IMAGE_0 = 0x10,
+ CSR_BOOT_LOADER_IMAGE_1 = 0x11,
+ CSR_BOOT_LOADER_IMAGE_2 = 0x12,
+ CSR_BOOT_LOADER_IMAGE_3 = 0x13
+} CSR_BOOT_LOADER_OPERATION;
+
+typedef u16 CSR_CAPABILITY_INFORMATION;
+
+typedef u16 CSR_CHANNEL_STARTING_FACTOR;
+
+typedef u32 CSR_CIPHER_SUITE_SELECTOR;
+
+typedef u32 CSR_CLIENT_TAG;
+
+typedef enum CSR_CONNECTION_STATUS
+{
+ CSR_DISCONNECTED = 0x0000,
+ CSR_CONNECTED_AWAKE = 0x0001
+} CSR_CONNECTION_STATUS;
+
+typedef s16 CSR_DECIBELS;
+
+typedef enum CSR_DIRECTION
+{
+ CSR_TRANSMIT = 0x0000,
+ CSR_RECEIVE = 0x0001,
+ CSR_BIDIRECTIONAL = 0x0003
+} CSR_DIRECTION;
+
+typedef enum CSR_FRAME_TYPE
+{
+ CSR_RESERVED = 0x0000,
+ CSR_BEACON = 0x0001,
+ CSR_PROBE_RESPONSE = 0x0002,
+ CSR_BEACON_AND_PROBE_RESPONSE = 0x0003,
+ CSR_PROBE_REQUEST = 0x0004
+} CSR_FRAME_TYPE;
+
+typedef u32 CSR_IPV4_ADDRESS;
+
+typedef enum CSR_IFINTERFACE
+{
+ CSR_INDEX_2G4 = 0x0001,
+ CSR_INDEX_5G = 0x0002
+} CSR_IFINTERFACE;
+
+typedef enum CSR_KEY_TYPE
+{
+ CSR_GROUP = 0x0000,
+ CSR_PAIRWISE = 0x0001,
+ CSR_PEER_KEY = 0x0002,
+ CSR_IGTK = 0x0003
+} CSR_KEY_TYPE;
+
+typedef enum CSR_LOADER_OPERATION
+{
+ CSR_LOADER_IDLE = 0x0000,
+ CSR_LOADER_COPY = 0x0001
+} CSR_LOADER_OPERATION;
+
+typedef struct CSR_MAC_ADDRESS
+{
+ u8 x[6];
+} CSR_MACADDRESS;
+
+typedef enum CSR_MIB_STATUS
+{
+ CSR_MIB_SUCCESSFUL = 0x0000,
+ CSR_MIB_INVALID_PARAMETERS = 0x0001,
+ CSR_MIB_WRITE_ONLY = 0x0002,
+ CSR_MIB_READ_ONLY = 0x0003
+} CSR_MIB_STATUS;
+
+typedef enum CSR_MEMORY_SPACE
+{
+ CSR_NONE = 0x00,
+ CSR_SHARED_DATA_MEMORY = 0x01,
+ CSR_EXTERNAL_FLASH_MEMORY = 0x02,
+ CSR_EXTERNAL_SRAM = 0x03,
+ CSR_REGISTERS = 0x04,
+ CSR_PHY_PROCESSOR_DATA_MEMORY = 0x10,
+ CSR_PHY_PROCESSOR_PROGRAM_MEMORY = 0x11,
+ CSR_PHY_PROCESSOR_ROM = 0x12,
+ CSR_MAC_PROCESSOR_DATA_MEMORY = 0x20,
+ CSR_MAC_PROCESSOR_PROGRAM_MEMORY = 0x21,
+ CSR_MAC_PROCESSOR_ROM = 0x22,
+ CSR_BT_PROCESSOR_DATA_MEMORY = 0x30,
+ CSR_BT_PROCESSOR_PROGRAM_MEMORY = 0x31,
+ CSR_BT_PROCESSOR_ROM = 0x32
+} CSR_MEMORY_SPACE;
+
+typedef u16 CSR_MICROSECONDS16;
+
+typedef u32 CSR_MICROSECONDS32;
+
+typedef u16 CSR_NATURAL16;
+
+typedef enum CSR_PS_SCHEME
+{
+ CSR_LEGACY_PS = 0x0001,
+ CSR_U_APSD = 0x0002,
+ CSR_S_APSD = 0x0004
+} CSR_PS_SCHEME;
+
+typedef enum CSR_PACKET_FILTER_MODE
+{
+ CSR_PFM_OPT_OUT = 0x0000,
+ CSR_PFM_OPT_IN = 0x0003
+} CSR_PACKET_FILTER_MODE;
+
+typedef u16 CSR_PERIODIC_ID;
+
+typedef enum CSR_PERIODIC_SCHEDULING_MODE
+{
+ CSR_PSM_PERIODIC_SCHEDULE_PS_POLL = 0x0001,
+ CSR_PSM_PERIODIC_SCHEDULE_PM_BIT = 0x0002,
+ CSR_PSM_PERIODIC_SCHEDULE_UAPSD = 0x0004,
+ CSR_PSM_PERIODIC_SCHEDULE_SAPSD = 0x0008
+} CSR_PERIODIC_SCHEDULING_MODE;
+
+typedef enum CSR_POWER_MANAGEMENT_MODE
+{
+ CSR_PMM_ACTIVE_MODE = 0x0000,
+ CSR_PMM_POWER_SAVE = 0x0001,
+ CSR_PMM_FAST_POWER_SAVE = 0x0002
+} CSR_POWER_MANAGEMENT_MODE;
+
+typedef enum CSR_PRIORITY
+{
+ CSR_QOS_UP0 = 0x0000,
+ CSR_QOS_UP1 = 0x0001,
+ CSR_QOS_UP2 = 0x0002,
+ CSR_QOS_UP3 = 0x0003,
+ CSR_QOS_UP4 = 0x0004,
+ CSR_QOS_UP5 = 0x0005,
+ CSR_QOS_UP6 = 0x0006,
+ CSR_QOS_UP7 = 0x0007,
+ CSR_CONTENTION = 0x8000,
+ CSR_MANAGEMENT = 0x8010
+} CSR_PRIORITY;
+
+typedef enum CSR_REASON_CODE
+{
+ CSR_UNSPECIFIED_REASON = 0x0001,
+ CSR_INVALID_INFORMATION_ELEMENT = 0x000d,
+ CSR_QOS_UNSPECIFIED_REASON = 0x0020,
+ CSR_QOS_EXCESSIVE_NOT_ACK = 0x0022,
+ CSR_QOS_TXOP_LIMIT_EXCEEDED = 0x0023,
+ CSR_QSTA_LEAVING = 0x0024,
+ CSR_UNKNOWN_BA = 0x0026,
+ CSR_UNKNOWN_TS = 0x0026,
+ CSR_TIMEOUT = 0x0027
+} CSR_REASON_CODE;
+
+typedef enum CSR_RECEPTION_STATUS
+{
+ CSR_RX_SUCCESS = 0x0000,
+ CSR_RX_FAILURE_UNSPECIFIED = 0x0001,
+ CSR_MICHAEL_MIC_ERROR = 0x0002,
+ CSR_DECRYPTION_ERROR = 0x0003,
+ CSR_NO_TEMPORAL_KEY_AVAILABLE = 0x0004,
+ CSR_UNSUPPORTED_MODULATION = 0x0011,
+ CSR_BAD_FCS = 0x0012,
+ CSR_BAD_SIGNAL = 0x0013
+} CSR_RECEPTION_STATUS;
+
+typedef enum CSR_RESULT_CODE
+{
+ CSR_RC_SUCCESS = 0x0000,
+ CSR_RC_UNSPECIFIED_FAILURE = 0x0001,
+ CSR_RC_REFUSED = 0x0003,
+ CSR_RC_INVALID_PARAMETERS = 0x0026,
+ CSR_RC_REJECTED_INVALID_IE = 0x0028,
+ CSR_RC_REJECTED_INVALID_GROUP_CIPHER = 0x0029,
+ CSR_RC_REJECTED_INVALID_PAIRWISE_CIPHER = 0x002a,
+ CSR_RC_TIMEOUT = 0x8000,
+ CSR_RC_TOO_MANY_SIMULTANEOUS_REQUESTS = 0x8001,
+ CSR_RC_BSS_ALREADY_STARTED_OR_JOINED = 0x8002,
+ CSR_RC_NOT_SUPPORTED = 0x8003,
+ CSR_RC_TRANSMISSION_FAILURE = 0x8004,
+ CSR_RC_RESET_REQUIRED_BEFORE_START = 0x8006,
+ CSR_RC_INSUFFICIENT_RESOURCE = 0x8007,
+ CSR_RC_NO_BUFFERED_BROADCAST_MULTICAST_FRAMES = 0x8008,
+ CSR_RC_INVALID_UNICAST_CIPHER = 0xf02f,
+ CSR_RC_INVALID_MULTICAST_CIPHER = 0xf030
+} CSR_RESULT_CODE;
+
+typedef enum CSR_SCAN_TYPE
+{
+ CSR_SC_ACTIVE_SCAN = 0x0000,
+ CSR_SC_PASSIVE_SCAN = 0x0001
+} CSR_SCAN_TYPE;
+
+typedef enum CSR_SIGNAL_ID
+{
+ CSR_MA_PACKET_REQUEST_ID = 0x0110,
+ CSR_MA_PACKET_CONFIRM_ID = 0x0111,
+ CSR_MA_PACKET_INDICATION_ID = 0x0113,
+ CSR_MA_PACKET_CANCEL_REQUEST_ID = 0x0114,
+ CSR_MA_VIF_AVAILABILITY_RESPONSE_ID = 0x0116,
+ CSR_MA_VIF_AVAILABILITY_INDICATION_ID = 0x0117,
+ CSR_MA_PACKET_ERROR_INDICATION_ID = 0x011b,
+ CSR_MLME_RESET_REQUEST_ID = 0x0200,
+ CSR_MLME_RESET_CONFIRM_ID = 0x0201,
+ CSR_MLME_GET_REQUEST_ID = 0x0204,
+ CSR_MLME_GET_CONFIRM_ID = 0x0205,
+ CSR_MLME_SET_REQUEST_ID = 0x0208,
+ CSR_MLME_SET_CONFIRM_ID = 0x0209,
+ CSR_MLME_GET_NEXT_REQUEST_ID = 0x020c,
+ CSR_MLME_GET_NEXT_CONFIRM_ID = 0x020d,
+ CSR_MLME_POWERMGT_REQUEST_ID = 0x0210,
+ CSR_MLME_POWERMGT_CONFIRM_ID = 0x0211,
+ CSR_MLME_SCAN_REQUEST_ID = 0x0214,
+ CSR_MLME_SCAN_CONFIRM_ID = 0x0215,
+ CSR_MLME_HL_SYNC_REQUEST_ID = 0x0244,
+ CSR_MLME_HL_SYNC_CONFIRM_ID = 0x0245,
+ CSR_MLME_MEASURE_REQUEST_ID = 0x0258,
+ CSR_MLME_MEASURE_CONFIRM_ID = 0x0259,
+ CSR_MLME_MEASURE_INDICATION_ID = 0x025b,
+ CSR_MLME_SETKEYS_REQUEST_ID = 0x0268,
+ CSR_MLME_SETKEYS_CONFIRM_ID = 0x0269,
+ CSR_MLME_DELETEKEYS_REQUEST_ID = 0x026c,
+ CSR_MLME_DELETEKEYS_CONFIRM_ID = 0x026d,
+ CSR_MLME_AUTONOMOUS_SCAN_LOSS_INDICATION_ID = 0x0287,
+ CSR_MLME_CONNECTED_INDICATION_ID = 0x028b,
+ CSR_MLME_SCAN_CANCEL_REQUEST_ID = 0x028c,
+ CSR_MLME_HL_SYNC_CANCEL_REQUEST_ID = 0x0298,
+ CSR_MLME_HL_SYNC_CANCEL_CONFIRM_ID = 0x0299,
+ CSR_MLME_ADD_PERIODIC_REQUEST_ID = 0x02a0,
+ CSR_MLME_ADD_PERIODIC_CONFIRM_ID = 0x02a1,
+ CSR_MLME_DEL_PERIODIC_REQUEST_ID = 0x02a4,
+ CSR_MLME_DEL_PERIODIC_CONFIRM_ID = 0x02a5,
+ CSR_MLME_ADD_AUTONOMOUS_SCAN_REQUEST_ID = 0x02a8,
+ CSR_MLME_ADD_AUTONOMOUS_SCAN_CONFIRM_ID = 0x02a9,
+ CSR_MLME_DEL_AUTONOMOUS_SCAN_REQUEST_ID = 0x02ac,
+ CSR_MLME_DEL_AUTONOMOUS_SCAN_CONFIRM_ID = 0x02ad,
+ CSR_MLME_SET_PACKET_FILTER_REQUEST_ID = 0x02b8,
+ CSR_MLME_SET_PACKET_FILTER_CONFIRM_ID = 0x02b9,
+ CSR_MLME_STOP_MEASURE_REQUEST_ID = 0x02bc,
+ CSR_MLME_STOP_MEASURE_CONFIRM_ID = 0x02bd,
+ CSR_MLME_PAUSE_AUTONOMOUS_SCAN_REQUEST_ID = 0x02cc,
+ CSR_MLME_PAUSE_AUTONOMOUS_SCAN_CONFIRM_ID = 0x02cd,
+ CSR_MLME_AUTONOMOUS_SCAN_DONE_INDICATION_ID = 0x02db,
+ CSR_MLME_ADD_TRIGGERED_GET_REQUEST_ID = 0x02dc,
+ CSR_MLME_ADD_TRIGGERED_GET_CONFIRM_ID = 0x02dd,
+ CSR_MLME_DEL_TRIGGERED_GET_REQUEST_ID = 0x02e0,
+ CSR_MLME_DEL_TRIGGERED_GET_CONFIRM_ID = 0x02e1,
+ CSR_MLME_TRIGGERED_GET_INDICATION_ID = 0x02e7,
+ CSR_MLME_ADD_BLACKOUT_REQUEST_ID = 0x02f8,
+ CSR_MLME_ADD_BLACKOUT_CONFIRM_ID = 0x02f9,
+ CSR_MLME_BLACKOUT_ENDED_INDICATION_ID = 0x02fb,
+ CSR_MLME_DEL_BLACKOUT_REQUEST_ID = 0x02fc,
+ CSR_MLME_DEL_BLACKOUT_CONFIRM_ID = 0x02fd,
+ CSR_MLME_ADD_RX_TRIGGER_REQUEST_ID = 0x0304,
+ CSR_MLME_ADD_RX_TRIGGER_CONFIRM_ID = 0x0305,
+ CSR_MLME_DEL_RX_TRIGGER_REQUEST_ID = 0x0308,
+ CSR_MLME_DEL_RX_TRIGGER_CONFIRM_ID = 0x0309,
+ CSR_MLME_CONNECT_STATUS_REQUEST_ID = 0x0310,
+ CSR_MLME_CONNECT_STATUS_CONFIRM_ID = 0x0311,
+ CSR_MLME_MODIFY_BSS_PARAMETER_REQUEST_ID = 0x0314,
+ CSR_MLME_MODIFY_BSS_PARAMETER_CONFIRM_ID = 0x0315,
+ CSR_MLME_ADD_TEMPLATE_REQUEST_ID = 0x0318,
+ CSR_MLME_ADD_TEMPLATE_CONFIRM_ID = 0x0319,
+ CSR_MLME_CONFIG_QUEUE_REQUEST_ID = 0x031c,
+ CSR_MLME_CONFIG_QUEUE_CONFIRM_ID = 0x031d,
+ CSR_MLME_ADD_TSPEC_REQUEST_ID = 0x0320,
+ CSR_MLME_ADD_TSPEC_CONFIRM_ID = 0x0321,
+ CSR_MLME_DEL_TSPEC_REQUEST_ID = 0x0324,
+ CSR_MLME_DEL_TSPEC_CONFIRM_ID = 0x0325,
+ CSR_MLME_START_AGGREGATION_REQUEST_ID = 0x0328,
+ CSR_MLME_START_AGGREGATION_CONFIRM_ID = 0x0329,
+ CSR_MLME_BLOCKACK_ERROR_INDICATION_ID = 0x032b,
+ CSR_MLME_STOP_AGGREGATION_REQUEST_ID = 0x032c,
+ CSR_MLME_STOP_AGGREGATION_CONFIRM_ID = 0x032d,
+ CSR_MLME_SM_START_REQUEST_ID = 0x0334,
+ CSR_MLME_SM_START_CONFIRM_ID = 0x0335,
+ CSR_MLME_LEAVE_REQUEST_ID = 0x0338,
+ CSR_MLME_LEAVE_CONFIRM_ID = 0x0339,
+ CSR_MLME_SET_TIM_REQUEST_ID = 0x033c,
+ CSR_MLME_SET_TIM_CONFIRM_ID = 0x033d,
+ CSR_MLME_GET_KEY_SEQUENCE_REQUEST_ID = 0x0340,
+ CSR_MLME_GET_KEY_SEQUENCE_CONFIRM_ID = 0x0341,
+ CSR_MLME_SET_CHANNEL_REQUEST_ID = 0x034c,
+ CSR_MLME_SET_CHANNEL_CONFIRM_ID = 0x034d,
+ CSR_MLME_ADD_MULTICAST_ADDRESS_REQUEST_ID = 0x040c,
+ CSR_MLME_ADD_MULTICAST_ADDRESS_CONFIRM_ID = 0x040d,
+ CSR_DEBUG_STRING_INDICATION_ID = 0x0803,
+ CSR_DEBUG_WORD16_INDICATION_ID = 0x0807,
+ CSR_DEBUG_GENERIC_REQUEST_ID = 0x0808,
+ CSR_DEBUG_GENERIC_CONFIRM_ID = 0x0809,
+ CSR_DEBUG_GENERIC_INDICATION_ID = 0x080b
+} CSR_SIGNAL_ID;
+
+typedef u16 CSR_SIMPLE_POINTER;
+
+typedef u16 CSR_STARTING_SEQUENCE_NUMBER;
+
+typedef enum CSR_SYMBOL_ID
+{
+ CSR_SLT_END = 0x0000,
+ CSR_SLT_PCI_SLOT_CONFIG = 0x0001,
+ CSR_SLT_SDIO_SLOT_CONFIG = 0x0002,
+ CSR_SLT_BUILD_ID_NUMBER = 0x0003,
+ CSR_SLT_BUILD_ID_STRING = 0x0004,
+ CSR_SLT_PERSISTENT_STORE_DB = 0x0005,
+ CSR_SLT_RESET_VECTOR_PHY = 0x0006,
+ CSR_SLT_RESET_VECTOR_MAC = 0x0007,
+ CSR_SLT_SDIO_LOADER_CONTROL = 0x0008,
+ CSR_SLT_TEST_CMD = 0x0009,
+ CSR_SLT_TEST_ALIVE_COUNTER = 0x000a,
+ CSR_SLT_TEST_PARAMETERS = 0x000b,
+ CSR_SLT_TEST_RESULTS = 0x000c,
+ CSR_SLT_TEST_VERSION = 0x000d,
+ CSR_SLT_MIB_PSID_RANGES = 0x000e,
+ CSR_SLT_KIP_TABLE = 0x000f,
+ CSR_SLT_PANIC_DATA_PHY = 0x0010,
+ CSR_SLT_PANIC_DATA_MAC = 0x0011,
+ CSR_SLT_BOOT_LOADER_CONTROL = 0x0012,
+ CSR_SLT_SOFT_MAC = 0x0013
+} CSR_SYMBOL_ID;
+
+typedef struct CSR_TSF_TIME
+{
+ u8 x[8];
+} CSR_TSF_TIME;
+
+typedef u16 CSR_TIME_UNITS;
+
+typedef enum CSR_TRANSMISSION_CONTROL
+{
+ CSR_TRIGGERED = 0x0001,
+ CSR_END_OF_SERVICE = 0x0002,
+ CSR_NO_CONFIRM_REQUIRED = 0x0004,
+ CSR_ALLOW_BA = 0x0008
+} CSR_TRANSMISSION_CONTROL;
+
+typedef enum CSR_TRANSMISSION_STATUS
+{
+ CSR_TX_SUCCESSFUL = 0x0000,
+ CSR_TX_RETRY_LIMIT = 0x0001,
+ CSR_TX_LIFETIME = 0x0002,
+ CSR_TX_NO_BSS = 0x0003,
+ CSR_TX_EXCESSIVE_DATA_LENGTH = 0x0004,
+ CSR_TX_UNSUPPORTED_PRIORITY = 0x0006,
+ CSR_TX_UNAVAILABLE_PRIORITY = 0x0007,
+ CSR_TX_UNAVAILABLE_KEY_MAPPING = 0x000a,
+ CSR_TX_EDCA_TIMEOUT = 0x000b,
+ CSR_TX_BLOCK_ACK_TIMEOUT = 0x000c,
+ CSR_TX_FAIL_TRANSMISSION_VIF_INTERRUPTED = 0x000d,
+ CSR_TX_REJECTED_PEER_STATION_SLEEPING = 0x000e,
+ CSR_TX_REJECTED_DTIM_ENDED = 0x000f,
+ CSR_TX_REJECTED_DTIM_STARTED = 0x0010
+} CSR_TRANSMISSION_STATUS;
+
+typedef u16 CSR_TRIGGER_ID;
+
+typedef u16 CSR_TRIGGERED_ID;
+
+typedef enum CSR_HIP_VERSIONS
+{
+ CSR_HIP_ENG_VERSION = 0x0001,
+ CSR_HIP_VERSION = 0x0900
+} CSR_HIP_VERSIONS;
+
+typedef u16 CSR_BUFFER_HANDLE;
+
+typedef u16 CSR_CHANNEL_NUMBER;
+
+typedef struct CSR_DATA_REFERENCE
+{
+ u16 SlotNumber;
+ u16 DataLength;
+} CSR_DATAREF;
+
+typedef u16 CSR_DIALOG_TOKEN;
+
+typedef struct CSR_GENERIC_POINTER
+{
+ u32 MemoryOffset;
+ CSR_MEMORY_SPACE MemorySpace;
+} CSR_GENERIC_POINTER;
+
+typedef struct CSR_MLME_CONFIG_QUEUE_CONFIRM
+{
+ CSR_DATAREF Dummydataref1;
+ CSR_DATAREF Dummydataref2;
+ CSR_RESULT_CODE ResultCode;
+} CSR_MLME_CONFIG_QUEUE_CONFIRM;
+
+typedef struct CSR_MLME_CONFIG_QUEUE_REQUEST
+{
+ CSR_DATAREF Dummydataref1;
+ CSR_DATAREF Dummydataref2;
+ CSR_NATURAL16 QueueIndex;
+ CSR_NATURAL16 Aifs;
+ CSR_NATURAL16 Cwmin;
+ CSR_NATURAL16 Cwmax;
+ CSR_NATURAL16 TxopLimit;
+} CSR_MLME_CONFIG_QUEUE_REQUEST;
+
+typedef struct CSR_MLME_GET_CONFIRM
+{
+ CSR_DATAREF MibAttributeValue;
+ CSR_DATAREF Dummydataref2;
+ CSR_MIB_STATUS Status;
+ CSR_NATURAL16 ErrorIndex;
+} CSR_MLME_GET_CONFIRM;
+
+typedef struct CSR_MLME_GET_REQUEST
+{
+ CSR_DATAREF MibAttribute;
+ CSR_DATAREF Dummydataref2;
+} CSR_MLME_GET_REQUEST;
+
+typedef struct CSR_MLME_GET_NEXT_CONFIRM
+{
+ CSR_DATAREF MibAttributeValue;
+ CSR_DATAREF Dummydataref2;
+ CSR_MIB_STATUS Status;
+ CSR_NATURAL16 ErrorIndex;
+} CSR_MLME_GET_NEXT_CONFIRM;
+
+typedef struct CSR_MLME_GET_NEXT_REQUEST
+{
+ CSR_DATAREF MibAttribute;
+ CSR_DATAREF Dummydataref2;
+} CSR_MLME_GET_NEXT_REQUEST;
+
+typedef struct CSR_MLME_HL_SYNC_CONFIRM
+{
+ CSR_DATAREF Dummydataref1;
+ CSR_DATAREF Dummydataref2;
+ CSR_MACADDRESS GroupAddress;
+ CSR_RESULT_CODE ResultCode;
+} CSR_MLME_HL_SYNC_CONFIRM;
+
+typedef struct CSR_MLME_HL_SYNC_REQUEST
+{
+ CSR_DATAREF Dummydataref1;
+ CSR_DATAREF Dummydataref2;
+ CSR_MACADDRESS GroupAddress;
+} CSR_MLME_HL_SYNC_REQUEST;
+
+typedef struct CSR_MLME_HL_SYNC_CANCEL_CONFIRM
+{
+ CSR_DATAREF Dummydataref1;
+ CSR_DATAREF Dummydataref2;
+ CSR_RESULT_CODE ResultCode;
+} CSR_MLME_HL_SYNC_CANCEL_CONFIRM;
+
+typedef struct CSR_MLME_HL_SYNC_CANCEL_REQUEST
+{
+ CSR_DATAREF Dummydataref1;
+ CSR_DATAREF Dummydataref2;
+ CSR_MACADDRESS GroupAddress;
+} CSR_MLME_HL_SYNC_CANCEL_REQUEST;
+
+typedef struct CSR_MLME_MEASURE_CONFIRM
+{
+ CSR_DATAREF Dummydataref1;
+ CSR_DATAREF Dummydataref2;
+ CSR_RESULT_CODE ResultCode;
+ CSR_DIALOG_TOKEN DialogToken;
+} CSR_MLME_MEASURE_CONFIRM;
+
+typedef struct CSR_MLME_MEASURE_INDICATION
+{
+ CSR_DATAREF MeasurementReportSet;
+ CSR_DATAREF Dummydataref2;
+ CSR_DIALOG_TOKEN DialogToken;
+} CSR_MLME_MEASURE_INDICATION;
+
+typedef struct CSR_MLME_MEASURE_REQUEST
+{
+ CSR_DATAREF MeasurementRequestSet;
+ CSR_DATAREF Dummydataref2;
+ CSR_DIALOG_TOKEN DialogToken;
+} CSR_MLME_MEASURE_REQUEST;
+
+typedef struct CSR_MLME_RESET_CONFIRM
+{
+ CSR_DATAREF Dummydataref1;
+ CSR_DATAREF Dummydataref2;
+ CSR_RESULT_CODE ResultCode;
+} CSR_MLME_RESET_CONFIRM;
+
+typedef struct CSR_MLME_RESET_REQUEST
+{
+ CSR_DATAREF Dummydataref1;
+ CSR_DATAREF Dummydataref2;
+ CSR_MACADDRESS StaAddress;
+ s16 SetDefaultMib;
+} CSR_MLME_RESET_REQUEST;
+
+typedef struct CSR_MLME_SET_CONFIRM
+{
+ CSR_DATAREF MibAttributeValue;
+ CSR_DATAREF Dummydataref2;
+ CSR_MIB_STATUS Status;
+ CSR_NATURAL16 ErrorIndex;
+} CSR_MLME_SET_CONFIRM;
+
+typedef struct CSR_MLME_SET_REQUEST
+{
+ CSR_DATAREF MibAttributeValue;
+ CSR_DATAREF Dummydataref2;
+} CSR_MLME_SET_REQUEST;
+
+typedef struct CSR_MLME_STOP_MEASURE_CONFIRM
+{
+ CSR_DATAREF Dummydataref1;
+ CSR_DATAREF Dummydataref2;
+ CSR_RESULT_CODE ResultCode;
+ CSR_DIALOG_TOKEN DialogToken;
+} CSR_MLME_STOP_MEASURE_CONFIRM;
+
+typedef struct CSR_MLME_STOP_MEASURE_REQUEST
+{
+ CSR_DATAREF Dummydataref1;
+ CSR_DATAREF Dummydataref2;
+ CSR_DIALOG_TOKEN DialogToken;
+} CSR_MLME_STOP_MEASURE_REQUEST;
+
+typedef u16 CSR_PROCESS_ID;
+
+typedef u16 CSR_RATE;
+
+typedef u16 CSR_SEQUENCE_NUMBER;
+
+typedef struct CSR_SIGNAL_PRIMITIVE_HEADER
+{
+ s16 SignalId;
+ CSR_PROCESS_ID ReceiverProcessId;
+ CSR_PROCESS_ID SenderProcessId;
+} CSR_SIGNAL_PRIMITIVE_HEADER;
+
+typedef u16 CSR_TRAFFIC_WINDOW;
+
+typedef u16 CSR_VIF_IDENTIFIER;
+
+typedef struct CSR_DEBUG_GENERIC_CONFIRM
+{
+ CSR_DATAREF DebugVariable;
+ CSR_DATAREF Dummydataref2;
+ CSR_NATURAL16 DebugWords[8];
+} CSR_DEBUG_GENERIC_CONFIRM;
+
+typedef struct CSR_DEBUG_GENERIC_INDICATION
+{
+ CSR_DATAREF DebugVariable;
+ CSR_DATAREF Dummydataref2;
+ CSR_NATURAL16 DebugWords[8];
+} CSR_DEBUG_GENERIC_INDICATION;
+
+typedef struct CSR_DEBUG_GENERIC_REQUEST
+{
+ CSR_DATAREF DebugVariable;
+ CSR_DATAREF Dummydataref2;
+ CSR_NATURAL16 DebugWords[8];
+} CSR_DEBUG_GENERIC_REQUEST;
+
+typedef struct CSR_DEBUG_STRING_INDICATION
+{
+ CSR_DATAREF DebugMessage;
+ CSR_DATAREF Dummydataref2;
+} CSR_DEBUG_STRING_INDICATION;
+
+typedef struct CSR_DEBUG_WORD16_INDICATION
+{
+ CSR_DATAREF Dummydataref1;
+ CSR_DATAREF Dummydataref2;
+ CSR_NATURAL16 DebugWords[16];
+} CSR_DEBUG_WORD16_INDICATION;
+
+typedef struct CSR_MA_PACKET_CONFIRM
+{
+ CSR_DATAREF Dummydataref1;
+ CSR_DATAREF Dummydataref2;
+ CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
+ CSR_TRANSMISSION_STATUS TransmissionStatus;
+ CSR_NATURAL16 RetryCount;
+ CSR_RATE Rate;
+ CSR_CLIENT_TAG HostTag;
+} CSR_MA_PACKET_CONFIRM;
+
+typedef struct CSR_MA_PACKET_INDICATION
+{
+ CSR_DATAREF Data;
+ CSR_DATAREF Dummydataref2;
+ CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
+ CSR_TSF_TIME LocalTime;
+ CSR_IFINTERFACE Ifindex;
+ CSR_CHANNEL_NUMBER Channel;
+ CSR_RECEPTION_STATUS ReceptionStatus;
+ CSR_DECIBELS Rssi;
+ CSR_DECIBELS Snr;
+ CSR_RATE ReceivedRate;
+} CSR_MA_PACKET_INDICATION;
+
+typedef struct CSR_MA_PACKET_REQUEST
+{
+ CSR_DATAREF Data;
+ CSR_DATAREF Dummydataref2;
+ CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
+ CSR_RATE TransmitRate;
+ CSR_CLIENT_TAG HostTag;
+ CSR_PRIORITY Priority;
+ CSR_MACADDRESS Ra;
+ CSR_TRANSMISSION_CONTROL TransmissionControl;
+} CSR_MA_PACKET_REQUEST;
+
+typedef struct CSR_MA_PACKET_CANCEL_REQUEST
+{
+ CSR_DATAREF Dummydataref1;
+ CSR_DATAREF Dummydataref2;
+ CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
+ CSR_CLIENT_TAG HostTag;
+} CSR_MA_PACKET_CANCEL_REQUEST;
+
+typedef struct CSR_MA_PACKET_ERROR_INDICATION
+{
+ CSR_DATAREF Dummydataref1;
+ CSR_DATAREF Dummydataref2;
+ CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
+ CSR_MACADDRESS PeerQstaAddress;
+ CSR_PRIORITY UserPriority;
+ CSR_SEQUENCE_NUMBER SequenceNumber;
+} CSR_MA_PACKET_ERROR_INDICATION;
+
+typedef struct CSR_MA_VIF_AVAILABILITY_INDICATION
+{
+ CSR_DATAREF Dummydataref1;
+ CSR_DATAREF Dummydataref2;
+ CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
+ s16 Multicast;
+} CSR_MA_VIF_AVAILABILITY_INDICATION;
+
+typedef struct CSR_MA_VIF_AVAILABILITY_RESPONSE
+{
+ CSR_DATAREF Dummydataref1;
+ CSR_DATAREF Dummydataref2;
+ CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
+ CSR_RESULT_CODE ResultCode;
+} CSR_MA_VIF_AVAILABILITY_RESPONSE;
+
+typedef struct CSR_MLME_ADD_AUTONOMOUS_SCAN_CONFIRM
+{
+ CSR_DATAREF Dummydataref1;
+ CSR_DATAREF Dummydataref2;
+ CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
+ CSR_RESULT_CODE ResultCode;
+ CSR_AUTONOMOUS_SCAN_ID AutonomousScanId;
+} CSR_MLME_ADD_AUTONOMOUS_SCAN_CONFIRM;
+
+typedef struct CSR_MLME_ADD_AUTONOMOUS_SCAN_REQUEST
+{
+ CSR_DATAREF ChannelList;
+ CSR_DATAREF InformationElements;
+ CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
+ CSR_AUTONOMOUS_SCAN_ID AutonomousScanId;
+ CSR_IFINTERFACE Ifindex;
+ CSR_CHANNEL_STARTING_FACTOR ChannelStartingFactor;
+ CSR_SCAN_TYPE ScanType;
+ CSR_MICROSECONDS32 ProbeDelay;
+ CSR_TIME_UNITS MinChannelTime;
+ CSR_TIME_UNITS MaxChannelTime;
+} CSR_MLME_ADD_AUTONOMOUS_SCAN_REQUEST;
+
+typedef struct CSR_MLME_ADD_BLACKOUT_CONFIRM
+{
+ CSR_DATAREF Dummydataref1;
+ CSR_DATAREF Dummydataref2;
+ CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
+ CSR_BLACKOUT_ID BlackoutId;
+ CSR_RESULT_CODE ResultCode;
+} CSR_MLME_ADD_BLACKOUT_CONFIRM;
+
+typedef struct CSR_MLME_ADD_BLACKOUT_REQUEST
+{
+ CSR_DATAREF Dummydataref1;
+ CSR_DATAREF Dummydataref2;
+ CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
+ CSR_BLACKOUT_ID BlackoutId;
+ CSR_BLACKOUT_TYPE BlackoutType;
+ CSR_BLACKOUT_SOURCE BlackoutSource;
+ CSR_MICROSECONDS32 BlackoutStartReference;
+ CSR_MICROSECONDS32 BlackoutPeriod;
+ CSR_MICROSECONDS32 BlackoutDuration;
+ CSR_MACADDRESS PeerStaAddress;
+ CSR_NATURAL16 BlackoutCount;
+} CSR_MLME_ADD_BLACKOUT_REQUEST;
+
+typedef struct CSR_MLME_ADD_MULTICAST_ADDRESS_CONFIRM
+{
+ CSR_DATAREF Dummydataref1;
+ CSR_DATAREF Dummydataref2;
+ CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
+ CSR_RESULT_CODE ResultCode;
+} CSR_MLME_ADD_MULTICAST_ADDRESS_CONFIRM;
+
+typedef struct CSR_MLME_ADD_MULTICAST_ADDRESS_REQUEST
+{
+ CSR_DATAREF Data;
+ CSR_DATAREF Dummydataref2;
+ CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
+ CSR_NATURAL16 NumberOfMulticastGroupAddresses;
+} CSR_MLME_ADD_MULTICAST_ADDRESS_REQUEST;
+
+typedef struct CSR_MLME_ADD_PERIODIC_CONFIRM
+{
+ CSR_DATAREF Dummydataref1;
+ CSR_DATAREF Dummydataref2;
+ CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
+ CSR_PERIODIC_ID PeriodicId;
+ CSR_RESULT_CODE ResultCode;
+} CSR_MLME_ADD_PERIODIC_CONFIRM;
+
+typedef struct CSR_MLME_ADD_PERIODIC_REQUEST
+{
+ CSR_DATAREF Dummydataref1;
+ CSR_DATAREF Dummydataref2;
+ CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
+ CSR_PERIODIC_ID PeriodicId;
+ CSR_MICROSECONDS32 MaximumLatency;
+ CSR_PERIODIC_SCHEDULING_MODE PeriodicSchedulingMode;
+ s16 WakeHost;
+ CSR_PRIORITY UserPriority;
+} CSR_MLME_ADD_PERIODIC_REQUEST;
+
+typedef struct CSR_MLME_ADD_RX_TRIGGER_CONFIRM
+{
+ CSR_DATAREF Dummydataref1;
+ CSR_DATAREF Dummydataref2;
+ CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
+ CSR_TRIGGER_ID TriggerId;
+ CSR_RESULT_CODE ResultCode;
+} CSR_MLME_ADD_RX_TRIGGER_CONFIRM;
+
+typedef struct CSR_MLME_ADD_RX_TRIGGER_REQUEST
+{
+ CSR_DATAREF InformationElements;
+ CSR_DATAREF Dummydataref2;
+ CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
+ CSR_TRIGGER_ID TriggerId;
+ CSR_PRIORITY Priority;
+} CSR_MLME_ADD_RX_TRIGGER_REQUEST;
+
+typedef struct CSR_MLME_ADD_TEMPLATE_CONFIRM
+{
+ CSR_DATAREF Dummydataref1;
+ CSR_DATAREF Dummydataref2;
+ CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
+ CSR_FRAME_TYPE FrameType;
+ CSR_RESULT_CODE ResultCode;
+} CSR_MLME_ADD_TEMPLATE_CONFIRM;
+
+typedef struct CSR_MLME_ADD_TEMPLATE_REQUEST
+{
+ CSR_DATAREF Data1;
+ CSR_DATAREF Data2;
+ CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
+ CSR_FRAME_TYPE FrameType;
+ CSR_RATE MinTransmitRate;
+} CSR_MLME_ADD_TEMPLATE_REQUEST;
+
+typedef struct CSR_MLME_ADD_TRIGGERED_GET_CONFIRM
+{
+ CSR_DATAREF Dummydataref1;
+ CSR_DATAREF Dummydataref2;
+ CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
+ CSR_RESULT_CODE ResultCode;
+ CSR_TRIGGERED_ID TriggeredId;
+} CSR_MLME_ADD_TRIGGERED_GET_CONFIRM;
+
+typedef struct CSR_MLME_ADD_TRIGGERED_GET_REQUEST
+{
+ CSR_DATAREF MibAttribute;
+ CSR_DATAREF Dummydataref2;
+ CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
+ CSR_TRIGGERED_ID TriggeredId;
+} CSR_MLME_ADD_TRIGGERED_GET_REQUEST;
+
+typedef struct CSR_MLME_ADD_TSPEC_CONFIRM
+{
+ CSR_DATAREF Dummydataref1;
+ CSR_DATAREF Dummydataref2;
+ CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
+ CSR_PRIORITY UserPriority;
+ CSR_RESULT_CODE ResultCode;
+} CSR_MLME_ADD_TSPEC_CONFIRM;
+
+typedef struct CSR_MLME_ADD_TSPEC_REQUEST
+{
+ CSR_DATAREF Dummydataref1;
+ CSR_DATAREF Dummydataref2;
+ CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
+ CSR_PRIORITY UserPriority;
+ CSR_DIRECTION Direction;
+ CSR_PS_SCHEME PsScheme;
+ CSR_NATURAL16 MediumTime;
+ CSR_MICROSECONDS32 ServiceStartTime;
+ CSR_MICROSECONDS32 ServiceInterval;
+ CSR_RATE MinimumDataRate;
+} CSR_MLME_ADD_TSPEC_REQUEST;
+
+typedef struct CSR_MLME_AUTONOMOUS_SCAN_DONE_INDICATION
+{
+ CSR_DATAREF Dummydataref1;
+ CSR_DATAREF Dummydataref2;
+ CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
+ CSR_RESULT_CODE ResultCode;
+ CSR_AUTONOMOUS_SCAN_ID AutonomousScanId;
+} CSR_MLME_AUTONOMOUS_SCAN_DONE_INDICATION;
+
+typedef struct CSR_MLME_AUTONOMOUS_SCAN_LOSS_INDICATION
+{
+ CSR_DATAREF Dummydataref1;
+ CSR_DATAREF Dummydataref2;
+ CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
+ CSR_MACADDRESS Bssid;
+} CSR_MLME_AUTONOMOUS_SCAN_LOSS_INDICATION;
+
+typedef struct CSR_MLME_BLACKOUT_ENDED_INDICATION
+{
+ CSR_DATAREF Dummydataref1;
+ CSR_DATAREF Dummydataref2;
+ CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
+ CSR_BLACKOUT_ID BlackoutId;
+} CSR_MLME_BLACKOUT_ENDED_INDICATION;
+
+typedef struct CSR_MLME_BLOCKACK_ERROR_INDICATION
+{
+ CSR_DATAREF Dummydataref1;
+ CSR_DATAREF Dummydataref2;
+ CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
+ CSR_REASON_CODE ResultCode;
+ CSR_MACADDRESS PeerQstaAddress;
+} CSR_MLME_BLOCKACK_ERROR_INDICATION;
+
+typedef struct CSR_MLME_CONNECTED_INDICATION
+{
+ CSR_DATAREF Dummydataref1;
+ CSR_DATAREF Dummydataref2;
+ CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
+ CSR_CONNECTION_STATUS ConnectionStatus;
+ CSR_MACADDRESS PeerMacAddress;
+} CSR_MLME_CONNECTED_INDICATION;
+
+typedef struct CSR_MLME_CONNECT_STATUS_CONFIRM
+{
+ CSR_DATAREF Dummydataref1;
+ CSR_DATAREF Dummydataref2;
+ CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
+ CSR_RESULT_CODE ResultCode;
+} CSR_MLME_CONNECT_STATUS_CONFIRM;
+
+typedef struct CSR_MLME_CONNECT_STATUS_REQUEST
+{
+ CSR_DATAREF InformationElements;
+ CSR_DATAREF Dummydataref2;
+ CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
+ CSR_CONNECTION_STATUS ConnectionStatus;
+ CSR_MACADDRESS StaAddress;
+ CSR_ASSOCIATION_ID AssociationId;
+ CSR_CAPABILITY_INFORMATION AssociationCapabilityInformation;
+} CSR_MLME_CONNECT_STATUS_REQUEST;
+
+typedef struct CSR_MLME_DELETEKEYS_CONFIRM
+{
+ CSR_DATAREF Dummydataref1;
+ CSR_DATAREF Dummydataref2;
+ CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
+ CSR_RESULT_CODE ResultCode;
+} CSR_MLME_DELETEKEYS_CONFIRM;
+
+typedef struct CSR_MLME_DELETEKEYS_REQUEST
+{
+ CSR_DATAREF Dummydataref1;
+ CSR_DATAREF Dummydataref2;
+ CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
+ CSR_NATURAL16 KeyId;
+ CSR_KEY_TYPE KeyType;
+ CSR_MACADDRESS Address;
+} CSR_MLME_DELETEKEYS_REQUEST;
+
+typedef struct CSR_MLME_DEL_AUTONOMOUS_SCAN_CONFIRM
+{
+ CSR_DATAREF Dummydataref1;
+ CSR_DATAREF Dummydataref2;
+ CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
+ CSR_RESULT_CODE ResultCode;
+ CSR_AUTONOMOUS_SCAN_ID AutonomousScanId;
+} CSR_MLME_DEL_AUTONOMOUS_SCAN_CONFIRM;
+
+typedef struct CSR_MLME_DEL_AUTONOMOUS_SCAN_REQUEST
+{
+ CSR_DATAREF Dummydataref1;
+ CSR_DATAREF Dummydataref2;
+ CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
+ CSR_AUTONOMOUS_SCAN_ID AutonomousScanId;
+} CSR_MLME_DEL_AUTONOMOUS_SCAN_REQUEST;
+
+typedef struct CSR_MLME_DEL_BLACKOUT_CONFIRM
+{
+ CSR_DATAREF Dummydataref1;
+ CSR_DATAREF Dummydataref2;
+ CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
+ CSR_BLACKOUT_ID BlackoutId;
+ CSR_RESULT_CODE ResultCode;
+} CSR_MLME_DEL_BLACKOUT_CONFIRM;
+
+typedef struct CSR_MLME_DEL_BLACKOUT_REQUEST
+{
+ CSR_DATAREF Dummydataref1;
+ CSR_DATAREF Dummydataref2;
+ CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
+ CSR_BLACKOUT_ID BlackoutId;
+} CSR_MLME_DEL_BLACKOUT_REQUEST;
+
+typedef struct CSR_MLME_DEL_PERIODIC_CONFIRM
+{
+ CSR_DATAREF Dummydataref1;
+ CSR_DATAREF Dummydataref2;
+ CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
+ CSR_PERIODIC_ID PeriodicId;
+ CSR_RESULT_CODE ResultCode;
+} CSR_MLME_DEL_PERIODIC_CONFIRM;
+
+typedef struct CSR_MLME_DEL_PERIODIC_REQUEST
+{
+ CSR_DATAREF Dummydataref1;
+ CSR_DATAREF Dummydataref2;
+ CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
+ CSR_PERIODIC_ID PeriodicId;
+} CSR_MLME_DEL_PERIODIC_REQUEST;
+
+typedef struct CSR_MLME_DEL_RX_TRIGGER_CONFIRM
+{
+ CSR_DATAREF Dummydataref1;
+ CSR_DATAREF Dummydataref2;
+ CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
+ CSR_TRIGGER_ID TriggerId;
+ CSR_RESULT_CODE ResultCode;
+} CSR_MLME_DEL_RX_TRIGGER_CONFIRM;
+
+typedef struct CSR_MLME_DEL_RX_TRIGGER_REQUEST
+{
+ CSR_DATAREF Dummydataref1;
+ CSR_DATAREF Dummydataref2;
+ CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
+ CSR_TRIGGER_ID TriggerId;
+} CSR_MLME_DEL_RX_TRIGGER_REQUEST;
+
+typedef struct CSR_MLME_DEL_TRIGGERED_GET_CONFIRM
+{
+ CSR_DATAREF Dummydataref1;
+ CSR_DATAREF Dummydataref2;
+ CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
+ CSR_RESULT_CODE ResultCode;
+ CSR_TRIGGERED_ID TriggeredId;
+} CSR_MLME_DEL_TRIGGERED_GET_CONFIRM;
+
+typedef struct CSR_MLME_DEL_TRIGGERED_GET_REQUEST
+{
+ CSR_DATAREF Dummydataref1;
+ CSR_DATAREF Dummydataref2;
+ CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
+ CSR_TRIGGERED_ID TriggeredId;
+} CSR_MLME_DEL_TRIGGERED_GET_REQUEST;
+
+typedef struct CSR_MLME_DEL_TSPEC_CONFIRM
+{
+ CSR_DATAREF Dummydataref1;
+ CSR_DATAREF Dummydataref2;
+ CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
+ CSR_PRIORITY UserPriority;
+ CSR_RESULT_CODE ResultCode;
+} CSR_MLME_DEL_TSPEC_CONFIRM;
+
+typedef struct CSR_MLME_DEL_TSPEC_REQUEST
+{
+ CSR_DATAREF Dummydataref1;
+ CSR_DATAREF Dummydataref2;
+ CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
+ CSR_PRIORITY UserPriority;
+ CSR_DIRECTION Direction;
+} CSR_MLME_DEL_TSPEC_REQUEST;
+
+typedef struct CSR_MLME_GET_KEY_SEQUENCE_CONFIRM
+{
+ CSR_DATAREF Dummydataref1;
+ CSR_DATAREF Dummydataref2;
+ CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
+ CSR_RESULT_CODE ResultCode;
+ CSR_NATURAL16 SequenceNumber[8];
+} CSR_MLME_GET_KEY_SEQUENCE_CONFIRM;
+
+typedef struct CSR_MLME_GET_KEY_SEQUENCE_REQUEST
+{
+ CSR_DATAREF Dummydataref1;
+ CSR_DATAREF Dummydataref2;
+ CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
+ CSR_NATURAL16 KeyId;
+ CSR_KEY_TYPE KeyType;
+ CSR_MACADDRESS Address;
+} CSR_MLME_GET_KEY_SEQUENCE_REQUEST;
+
+typedef struct CSR_MLME_LEAVE_CONFIRM
+{
+ CSR_DATAREF Dummydataref1;
+ CSR_DATAREF Dummydataref2;
+ CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
+ CSR_RESULT_CODE ResultCode;
+} CSR_MLME_LEAVE_CONFIRM;
+
+typedef struct CSR_MLME_LEAVE_REQUEST
+{
+ CSR_DATAREF Dummydataref1;
+ CSR_DATAREF Dummydataref2;
+ CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
+} CSR_MLME_LEAVE_REQUEST;
+
+typedef struct CSR_MLME_MODIFY_BSS_PARAMETER_CONFIRM
+{
+ CSR_DATAREF Dummydataref1;
+ CSR_DATAREF Dummydataref2;
+ CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
+ CSR_RESULT_CODE ResultCode;
+} CSR_MLME_MODIFY_BSS_PARAMETER_CONFIRM;
+
+typedef struct CSR_MLME_MODIFY_BSS_PARAMETER_REQUEST
+{
+ CSR_DATAREF Data;
+ CSR_DATAREF Dummydataref2;
+ CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
+ CSR_TIME_UNITS BeaconPeriod;
+ CSR_BEACON_PERIODS DtimPeriod;
+ CSR_CAPABILITY_INFORMATION CapabilityInformation;
+ CSR_MACADDRESS Bssid;
+ CSR_NATURAL16 RtsThreshold;
+} CSR_MLME_MODIFY_BSS_PARAMETER_REQUEST;
+
+typedef struct CSR_MLME_PAUSE_AUTONOMOUS_SCAN_CONFIRM
+{
+ CSR_DATAREF Dummydataref1;
+ CSR_DATAREF Dummydataref2;
+ CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
+ CSR_RESULT_CODE ResultCode;
+ CSR_AUTONOMOUS_SCAN_ID AutonomousScanId;
+} CSR_MLME_PAUSE_AUTONOMOUS_SCAN_CONFIRM;
+
+typedef struct CSR_MLME_PAUSE_AUTONOMOUS_SCAN_REQUEST
+{
+ CSR_DATAREF Dummydataref1;
+ CSR_DATAREF Dummydataref2;
+ CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
+ CSR_AUTONOMOUS_SCAN_ID AutonomousScanId;
+ s16 Pause;
+} CSR_MLME_PAUSE_AUTONOMOUS_SCAN_REQUEST;
+
+typedef struct CSR_MLME_POWERMGT_CONFIRM
+{
+ CSR_DATAREF Dummydataref1;
+ CSR_DATAREF Dummydataref2;
+ CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
+ CSR_RESULT_CODE ResultCode;
+} CSR_MLME_POWERMGT_CONFIRM;
+
+typedef struct CSR_MLME_POWERMGT_REQUEST
+{
+ CSR_DATAREF Dummydataref1;
+ CSR_DATAREF Dummydataref2;
+ CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
+ CSR_POWER_MANAGEMENT_MODE PowerManagementMode;
+ s16 ReceiveDtims;
+ CSR_BEACON_PERIODS ListenInterval;
+ CSR_TRAFFIC_WINDOW TrafficWindow;
+} CSR_MLME_POWERMGT_REQUEST;
+
+typedef struct CSR_MLME_SCAN_CONFIRM
+{
+ CSR_DATAREF Dummydataref1;
+ CSR_DATAREF Dummydataref2;
+ CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
+ CSR_RESULT_CODE ResultCode;
+} CSR_MLME_SCAN_CONFIRM;
+
+typedef struct CSR_MLME_SCAN_REQUEST
+{
+ CSR_DATAREF ChannelList;
+ CSR_DATAREF InformationElements;
+ CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
+ CSR_IFINTERFACE Ifindex;
+ CSR_SCAN_TYPE ScanType;
+ CSR_MICROSECONDS32 ProbeDelay;
+ CSR_TIME_UNITS MinChannelTime;
+ CSR_TIME_UNITS MaxChannelTime;
+} CSR_MLME_SCAN_REQUEST;
+
+typedef struct CSR_MLME_SCAN_CANCEL_REQUEST
+{
+ CSR_DATAREF Dummydataref1;
+ CSR_DATAREF Dummydataref2;
+ CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
+} CSR_MLME_SCAN_CANCEL_REQUEST;
+
+typedef struct CSR_MLME_SETKEYS_CONFIRM
+{
+ CSR_DATAREF Dummydataref1;
+ CSR_DATAREF Dummydataref2;
+ CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
+ CSR_RESULT_CODE ResultCode;
+} CSR_MLME_SETKEYS_CONFIRM;
+
+typedef struct CSR_MLME_SETKEYS_REQUEST
+{
+ CSR_DATAREF Key;
+ CSR_DATAREF Dummydataref2;
+ CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
+ CSR_NATURAL16 Length;
+ CSR_NATURAL16 KeyId;
+ CSR_KEY_TYPE KeyType;
+ CSR_MACADDRESS Address;
+ CSR_NATURAL16 SequenceNumber[8];
+ CSR_CIPHER_SUITE_SELECTOR CipherSuiteSelector;
+} CSR_MLME_SETKEYS_REQUEST;
+
+typedef struct CSR_MLME_SET_CHANNEL_CONFIRM
+{
+ CSR_DATAREF Dummydataref1;
+ CSR_DATAREF Dummydataref2;
+ CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
+ CSR_RESULT_CODE ResultCode;
+} CSR_MLME_SET_CHANNEL_CONFIRM;
+
+typedef struct CSR_MLME_SET_CHANNEL_REQUEST
+{
+ CSR_DATAREF Dummydataref1;
+ CSR_DATAREF Dummydataref2;
+ CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
+ CSR_IFINTERFACE Ifindex;
+ CSR_CHANNEL_NUMBER Channel;
+ CSR_MACADDRESS Address;
+ CSR_TIME_UNITS AvailabilityDuration;
+ CSR_TIME_UNITS AvailabilityInterval;
+} CSR_MLME_SET_CHANNEL_REQUEST;
+
+typedef struct CSR_MLME_SET_PACKET_FILTER_CONFIRM
+{
+ CSR_DATAREF Dummydataref1;
+ CSR_DATAREF Dummydataref2;
+ CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
+ CSR_RESULT_CODE ResultCode;
+} CSR_MLME_SET_PACKET_FILTER_CONFIRM;
+
+typedef struct CSR_MLME_SET_PACKET_FILTER_REQUEST
+{
+ CSR_DATAREF InformationElements;
+ CSR_DATAREF Dummydataref2;
+ CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
+ CSR_PACKET_FILTER_MODE PacketFilterMode;
+ CSR_IPV4_ADDRESS ArpFilterAddress;
+} CSR_MLME_SET_PACKET_FILTER_REQUEST;
+
+typedef struct CSR_MLME_SET_TIM_CONFIRM
+{
+ CSR_DATAREF Dummydataref1;
+ CSR_DATAREF Dummydataref2;
+ CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
+ CSR_RESULT_CODE ResultCode;
+} CSR_MLME_SET_TIM_CONFIRM;
+
+typedef struct CSR_MLME_SET_TIM_REQUEST
+{
+ CSR_DATAREF Dummydataref1;
+ CSR_DATAREF Dummydataref2;
+ CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
+ CSR_ASSOCIATION_ID AssociationId;
+ s16 TimValue;
+} CSR_MLME_SET_TIM_REQUEST;
+
+typedef struct CSR_MLME_SM_START_CONFIRM
+{
+ CSR_DATAREF Dummydataref1;
+ CSR_DATAREF Dummydataref2;
+ CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
+ CSR_RESULT_CODE ResultCode;
+} CSR_MLME_SM_START_CONFIRM;
+
+typedef struct CSR_MLME_SM_START_REQUEST
+{
+ CSR_DATAREF Beacon;
+ CSR_DATAREF BssParameters;
+ CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
+ CSR_IFINTERFACE Ifindex;
+ CSR_CHANNEL_NUMBER Channel;
+ CSR_MACADDRESS InterfaceAddress;
+ CSR_MACADDRESS Bssid;
+ CSR_TIME_UNITS BeaconPeriod;
+ CSR_BEACON_PERIODS DtimPeriod;
+ CSR_CAPABILITY_INFORMATION CapabilityInformation;
+} CSR_MLME_SM_START_REQUEST;
+
+typedef struct CSR_MLME_START_AGGREGATION_CONFIRM
+{
+ CSR_DATAREF Dummydataref1;
+ CSR_DATAREF Dummydataref2;
+ CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
+ CSR_MACADDRESS PeerQstaAddress;
+ CSR_PRIORITY UserPriority;
+ CSR_DIRECTION Direction;
+ CSR_RESULT_CODE ResultCode;
+ CSR_SEQUENCE_NUMBER SequenceNumber;
+} CSR_MLME_START_AGGREGATION_CONFIRM;
+
+typedef struct CSR_MLME_START_AGGREGATION_REQUEST
+{
+ CSR_DATAREF Dummydataref1;
+ CSR_DATAREF Dummydataref2;
+ CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
+ CSR_MACADDRESS PeerQstaAddress;
+ CSR_PRIORITY UserPriority;
+ CSR_DIRECTION Direction;
+ CSR_STARTING_SEQUENCE_NUMBER StartingSequenceNumber;
+ CSR_NATURAL16 BufferSize;
+ CSR_TIME_UNITS BlockAckTimeout;
+} CSR_MLME_START_AGGREGATION_REQUEST;
+
+typedef struct CSR_MLME_STOP_AGGREGATION_CONFIRM
+{
+ CSR_DATAREF Dummydataref1;
+ CSR_DATAREF Dummydataref2;
+ CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
+ CSR_MACADDRESS PeerQstaAddress;
+ CSR_PRIORITY UserPriority;
+ CSR_DIRECTION Direction;
+ CSR_RESULT_CODE ResultCode;
+} CSR_MLME_STOP_AGGREGATION_CONFIRM;
+
+typedef struct CSR_MLME_STOP_AGGREGATION_REQUEST
+{
+ CSR_DATAREF Dummydataref1;
+ CSR_DATAREF Dummydataref2;
+ CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
+ CSR_MACADDRESS PeerQstaAddress;
+ CSR_PRIORITY UserPriority;
+ CSR_DIRECTION Direction;
+} CSR_MLME_STOP_AGGREGATION_REQUEST;
+
+typedef struct CSR_MLME_TRIGGERED_GET_INDICATION
+{
+ CSR_DATAREF MibAttributeValue;
+ CSR_DATAREF Dummydataref2;
+ CSR_VIF_IDENTIFIER VirtualInterfaceIdentifier;
+ CSR_MIB_STATUS Status;
+ CSR_NATURAL16 ErrorIndex;
+ CSR_TRIGGERED_ID TriggeredId;
+} CSR_MLME_TRIGGERED_GET_INDICATION;
+
+typedef struct CSR_SIGNAL_PRIMITIVE
+{
+ CSR_SIGNAL_PRIMITIVE_HEADER SignalPrimitiveHeader;
+ union
+ {
+ CSR_MA_PACKET_REQUEST MaPacketRequest;
+ CSR_MA_PACKET_CONFIRM MaPacketConfirm;
+ CSR_MA_PACKET_INDICATION MaPacketIndication;
+ CSR_MA_PACKET_CANCEL_REQUEST MaPacketCancelRequest;
+ CSR_MA_VIF_AVAILABILITY_RESPONSE MaVifAvailabilityResponse;
+ CSR_MA_VIF_AVAILABILITY_INDICATION MaVifAvailabilityIndication;
+ CSR_MA_PACKET_ERROR_INDICATION MaPacketErrorIndication;
+ CSR_MLME_RESET_REQUEST MlmeResetRequest;
+ CSR_MLME_RESET_CONFIRM MlmeResetConfirm;
+ CSR_MLME_GET_REQUEST MlmeGetRequest;
+ CSR_MLME_GET_CONFIRM MlmeGetConfirm;
+ CSR_MLME_SET_REQUEST MlmeSetRequest;
+ CSR_MLME_SET_CONFIRM MlmeSetConfirm;
+ CSR_MLME_GET_NEXT_REQUEST MlmeGetNextRequest;
+ CSR_MLME_GET_NEXT_CONFIRM MlmeGetNextConfirm;
+ CSR_MLME_POWERMGT_REQUEST MlmePowermgtRequest;
+ CSR_MLME_POWERMGT_CONFIRM MlmePowermgtConfirm;
+ CSR_MLME_SCAN_REQUEST MlmeScanRequest;
+ CSR_MLME_SCAN_CONFIRM MlmeScanConfirm;
+ CSR_MLME_HL_SYNC_REQUEST MlmeHlSyncRequest;
+ CSR_MLME_HL_SYNC_CONFIRM MlmeHlSyncConfirm;
+ CSR_MLME_MEASURE_REQUEST MlmeMeasureRequest;
+ CSR_MLME_MEASURE_CONFIRM MlmeMeasureConfirm;
+ CSR_MLME_MEASURE_INDICATION MlmeMeasureIndication;
+ CSR_MLME_SETKEYS_REQUEST MlmeSetkeysRequest;
+ CSR_MLME_SETKEYS_CONFIRM MlmeSetkeysConfirm;
+ CSR_MLME_DELETEKEYS_REQUEST MlmeDeletekeysRequest;
+ CSR_MLME_DELETEKEYS_CONFIRM MlmeDeletekeysConfirm;
+ CSR_MLME_AUTONOMOUS_SCAN_LOSS_INDICATION MlmeAutonomousScanLossIndication;
+ CSR_MLME_CONNECTED_INDICATION MlmeConnectedIndication;
+ CSR_MLME_SCAN_CANCEL_REQUEST MlmeScanCancelRequest;
+ CSR_MLME_HL_SYNC_CANCEL_REQUEST MlmeHlSyncCancelRequest;
+ CSR_MLME_HL_SYNC_CANCEL_CONFIRM MlmeHlSyncCancelConfirm;
+ CSR_MLME_ADD_PERIODIC_REQUEST MlmeAddPeriodicRequest;
+ CSR_MLME_ADD_PERIODIC_CONFIRM MlmeAddPeriodicConfirm;
+ CSR_MLME_DEL_PERIODIC_REQUEST MlmeDelPeriodicRequest;
+ CSR_MLME_DEL_PERIODIC_CONFIRM MlmeDelPeriodicConfirm;
+ CSR_MLME_ADD_AUTONOMOUS_SCAN_REQUEST MlmeAddAutonomousScanRequest;
+ CSR_MLME_ADD_AUTONOMOUS_SCAN_CONFIRM MlmeAddAutonomousScanConfirm;
+ CSR_MLME_DEL_AUTONOMOUS_SCAN_REQUEST MlmeDelAutonomousScanRequest;
+ CSR_MLME_DEL_AUTONOMOUS_SCAN_CONFIRM MlmeDelAutonomousScanConfirm;
+ CSR_MLME_SET_PACKET_FILTER_REQUEST MlmeSetPacketFilterRequest;
+ CSR_MLME_SET_PACKET_FILTER_CONFIRM MlmeSetPacketFilterConfirm;
+ CSR_MLME_STOP_MEASURE_REQUEST MlmeStopMeasureRequest;
+ CSR_MLME_STOP_MEASURE_CONFIRM MlmeStopMeasureConfirm;
+ CSR_MLME_PAUSE_AUTONOMOUS_SCAN_REQUEST MlmePauseAutonomousScanRequest;
+ CSR_MLME_PAUSE_AUTONOMOUS_SCAN_CONFIRM MlmePauseAutonomousScanConfirm;
+ CSR_MLME_AUTONOMOUS_SCAN_DONE_INDICATION MlmeAutonomousScanDoneIndication;
+ CSR_MLME_ADD_TRIGGERED_GET_REQUEST MlmeAddTriggeredGetRequest;
+ CSR_MLME_ADD_TRIGGERED_GET_CONFIRM MlmeAddTriggeredGetConfirm;
+ CSR_MLME_DEL_TRIGGERED_GET_REQUEST MlmeDelTriggeredGetRequest;
+ CSR_MLME_DEL_TRIGGERED_GET_CONFIRM MlmeDelTriggeredGetConfirm;
+ CSR_MLME_TRIGGERED_GET_INDICATION MlmeTriggeredGetIndication;
+ CSR_MLME_ADD_BLACKOUT_REQUEST MlmeAddBlackoutRequest;
+ CSR_MLME_ADD_BLACKOUT_CONFIRM MlmeAddBlackoutConfirm;
+ CSR_MLME_BLACKOUT_ENDED_INDICATION MlmeBlackoutEndedIndication;
+ CSR_MLME_DEL_BLACKOUT_REQUEST MlmeDelBlackoutRequest;
+ CSR_MLME_DEL_BLACKOUT_CONFIRM MlmeDelBlackoutConfirm;
+ CSR_MLME_ADD_RX_TRIGGER_REQUEST MlmeAddRxTriggerRequest;
+ CSR_MLME_ADD_RX_TRIGGER_CONFIRM MlmeAddRxTriggerConfirm;
+ CSR_MLME_DEL_RX_TRIGGER_REQUEST MlmeDelRxTriggerRequest;
+ CSR_MLME_DEL_RX_TRIGGER_CONFIRM MlmeDelRxTriggerConfirm;
+ CSR_MLME_CONNECT_STATUS_REQUEST MlmeConnectStatusRequest;
+ CSR_MLME_CONNECT_STATUS_CONFIRM MlmeConnectStatusConfirm;
+ CSR_MLME_MODIFY_BSS_PARAMETER_REQUEST MlmeModifyBssParameterRequest;
+ CSR_MLME_MODIFY_BSS_PARAMETER_CONFIRM MlmeModifyBssParameterConfirm;
+ CSR_MLME_ADD_TEMPLATE_REQUEST MlmeAddTemplateRequest;
+ CSR_MLME_ADD_TEMPLATE_CONFIRM MlmeAddTemplateConfirm;
+ CSR_MLME_CONFIG_QUEUE_REQUEST MlmeConfigQueueRequest;
+ CSR_MLME_CONFIG_QUEUE_CONFIRM MlmeConfigQueueConfirm;
+ CSR_MLME_ADD_TSPEC_REQUEST MlmeAddTspecRequest;
+ CSR_MLME_ADD_TSPEC_CONFIRM MlmeAddTspecConfirm;
+ CSR_MLME_DEL_TSPEC_REQUEST MlmeDelTspecRequest;
+ CSR_MLME_DEL_TSPEC_CONFIRM MlmeDelTspecConfirm;
+ CSR_MLME_START_AGGREGATION_REQUEST MlmeStartAggregationRequest;
+ CSR_MLME_START_AGGREGATION_CONFIRM MlmeStartAggregationConfirm;
+ CSR_MLME_BLOCKACK_ERROR_INDICATION MlmeBlockackErrorIndication;
+ CSR_MLME_STOP_AGGREGATION_REQUEST MlmeStopAggregationRequest;
+ CSR_MLME_STOP_AGGREGATION_CONFIRM MlmeStopAggregationConfirm;
+ CSR_MLME_SM_START_REQUEST MlmeSmStartRequest;
+ CSR_MLME_SM_START_CONFIRM MlmeSmStartConfirm;
+ CSR_MLME_LEAVE_REQUEST MlmeLeaveRequest;
+ CSR_MLME_LEAVE_CONFIRM MlmeLeaveConfirm;
+ CSR_MLME_SET_TIM_REQUEST MlmeSetTimRequest;
+ CSR_MLME_SET_TIM_CONFIRM MlmeSetTimConfirm;
+ CSR_MLME_GET_KEY_SEQUENCE_REQUEST MlmeGetKeySequenceRequest;
+ CSR_MLME_GET_KEY_SEQUENCE_CONFIRM MlmeGetKeySequenceConfirm;
+ CSR_MLME_SET_CHANNEL_REQUEST MlmeSetChannelRequest;
+ CSR_MLME_SET_CHANNEL_CONFIRM MlmeSetChannelConfirm;
+ CSR_MLME_ADD_MULTICAST_ADDRESS_REQUEST MlmeAddMulticastAddressRequest;
+ CSR_MLME_ADD_MULTICAST_ADDRESS_CONFIRM MlmeAddMulticastAddressConfirm;
+ CSR_DEBUG_STRING_INDICATION DebugStringIndication;
+ CSR_DEBUG_WORD16_INDICATION DebugWord16Indication;
+ CSR_DEBUG_GENERIC_REQUEST DebugGenericRequest;
+ CSR_DEBUG_GENERIC_CONFIRM DebugGenericConfirm;
+ CSR_DEBUG_GENERIC_INDICATION DebugGenericIndication;
+ } u;
+} CSR_SIGNAL;
+
+#define SIG_FILTER_SIZE 6
+
+u32 SigGetFilterPos(u16 aSigID);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/drivers/staging/csr/csr_wifi_hip_ta_sampling.c b/drivers/staging/csr/csr_wifi_hip_ta_sampling.c
new file mode 100644
index 000000000000..f1df36aa87e7
--- /dev/null
+++ b/drivers/staging/csr/csr_wifi_hip_ta_sampling.c
@@ -0,0 +1,541 @@
+/*****************************************************************************
+
+ (c) Cambridge Silicon Radio Limited 2012
+ All rights reserved and confidential information of CSR
+
+ Refer to LICENSE.txt included with this source for details
+ on the license terms.
+
+*****************************************************************************/
+
+/*
+ * ---------------------------------------------------------------------------
+ * FILE: csr_wifi_hip_ta_sampling.c
+ *
+ * PURPOSE:
+ * The traffic analysis sampling module.
+ * This gathers data which is sent to the SME and used to analyse
+ * the traffic behaviour.
+ *
+ * Provides:
+ * unifi_ta_sampling_init - Initialise the internal state
+ * unifi_ta_sample - Sampling function, call this for every data packet
+ *
+ * Calls these external functions which must be provided:
+ * unifi_ta_indicate_sampling - Pass sample data to the SME.
+ * unifi_ta_indicate_protocol - Report certain data packet types to the SME.
+ * ---------------------------------------------------------------------------
+ */
+
+#include "csr_wifi_hip_card_sdio.h"
+
+/* Maximum number of Tx frames we store each CYCLE_1, for detecting period */
+#define TA_MAX_INTERVALS_IN_C1 100
+
+/* Number of intervals in CYCLE_1 (one second), for detecting periodic */
+/* Must match size of unifi_TrafficStats.intervals - 1 */
+#define TA_INTERVALS_NUM 10
+
+/* Step (in msecs) between intervals, for detecting periodic */
+/* We are only interested in periods up to 100ms, i.e. between beacons */
+/* This is correct for TA_INTERVALS_NUM=10 */
+#define TA_INTERVALS_STEP 10
+
+
+enum ta_frame_identity
+{
+ TA_FRAME_UNKNOWN,
+ TA_FRAME_ETHERNET_UNINTERESTING,
+ TA_FRAME_ETHERNET_INTERESTING
+};
+
+
+#define TA_ETHERNET_TYPE_OFFSET 6
+#define TA_LLC_HEADER_SIZE 8
+#define TA_IP_TYPE_OFFSET 17
+#define TA_UDP_SOURCE_PORT_OFFSET 28
+#define TA_UDP_DEST_PORT_OFFSET (TA_UDP_SOURCE_PORT_OFFSET + 2)
+#define TA_BOOTP_CLIENT_MAC_ADDR_OFFSET 64
+#define TA_DHCP_MESSAGE_TYPE_OFFSET 278
+#define TA_DHCP_MESSAGE_TYPE_ACK 0x05
+#define TA_PROTO_TYPE_IP 0x0800
+#define TA_PROTO_TYPE_EAP 0x888E
+#define TA_PROTO_TYPE_WAI 0x8864
+#define TA_PROTO_TYPE_ARP 0x0806
+#define TA_IP_TYPE_TCP 0x06
+#define TA_IP_TYPE_UDP 0x11
+#define TA_UDP_PORT_BOOTPC 0x0044
+#define TA_UDP_PORT_BOOTPS 0x0043
+#define TA_EAPOL_TYPE_OFFSET 9
+#define TA_EAPOL_TYPE_START 0x01
+
+#define snap_802_2 0xAAAA0300
+#define oui_rfc1042 0x00000000
+#define oui_8021h 0x0000f800
+static const u8 aironet_snap[5] = { 0x00, 0x40, 0x96, 0x00, 0x00 };
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * ta_detect_protocol
+ *
+ * Internal only.
+ * Detects a specific protocol in a frame and indicates a TA event.
+ *
+ * Arguments:
+ * ta The pointer to the TA module.
+ * direction The direction of the frame (tx or rx).
+ * data Pointer to the structure that contains the data.
+ *
+ * Returns:
+ * None
+ * ---------------------------------------------------------------------------
+ */
+static enum ta_frame_identity ta_detect_protocol(card_t *card, CsrWifiRouterCtrlProtocolDirection direction,
+ const bulk_data_desc_t *data,
+ const u8 *saddr,
+ const u8 *sta_macaddr)
+{
+ ta_data_t *tad = &card->ta_sampling;
+ u16 proto;
+ u16 source_port, dest_port;
+ CsrWifiMacAddress srcAddress;
+ u32 snap_hdr, oui_hdr;
+
+ if (data->data_length < TA_LLC_HEADER_SIZE)
+ {
+ return TA_FRAME_UNKNOWN;
+ }
+
+ snap_hdr = (((u32)data->os_data_ptr[0]) << 24) |
+ (((u32)data->os_data_ptr[1]) << 16) |
+ (((u32)data->os_data_ptr[2]) << 8);
+ if (snap_hdr != snap_802_2)
+ {
+ return TA_FRAME_UNKNOWN;
+ }
+
+ if (tad->packet_filter & CSR_WIFI_ROUTER_CTRL_TRAFFIC_PACKET_TYPE_CUSTOM)
+ {
+ /*
+ * Here we would use the custom filter to detect interesting frames.
+ */
+ }
+
+ oui_hdr = (((u32)data->os_data_ptr[3]) << 24) |
+ (((u32)data->os_data_ptr[4]) << 16) |
+ (((u32)data->os_data_ptr[5]) << 8);
+ if ((oui_hdr == oui_rfc1042) || (oui_hdr == oui_8021h))
+ {
+ proto = (data->os_data_ptr[TA_ETHERNET_TYPE_OFFSET] * 256) +
+ data->os_data_ptr[TA_ETHERNET_TYPE_OFFSET + 1];
+
+ /* The only interesting IP frames are the DHCP */
+ if (proto == TA_PROTO_TYPE_IP)
+ {
+ if (data->data_length > TA_IP_TYPE_OFFSET)
+ {
+ if (tad->packet_filter & CSR_WIFI_ROUTER_CTRL_TRAFFIC_PACKET_TYPE_CUSTOM)
+ {
+ ta_l4stats_t *ta_l4stats = &tad->ta_l4stats;
+ u8 l4proto = data->os_data_ptr[TA_IP_TYPE_OFFSET];
+
+ if (l4proto == TA_IP_TYPE_TCP)
+ {
+ if (direction == CSR_WIFI_ROUTER_CTRL_PROTOCOL_DIRECTION_TX)
+ {
+ ta_l4stats->txTcpBytesCount += data->data_length;
+ }
+ else
+ {
+ ta_l4stats->rxTcpBytesCount += data->data_length;
+ }
+ }
+ else if (l4proto == TA_IP_TYPE_UDP)
+ {
+ if (direction == CSR_WIFI_ROUTER_CTRL_PROTOCOL_DIRECTION_TX)
+ {
+ ta_l4stats->txUdpBytesCount += data->data_length;
+ }
+ else
+ {
+ ta_l4stats->rxUdpBytesCount += data->data_length;
+ }
+ }
+ }
+
+ /* detect DHCP frames */
+ if (tad->packet_filter & CSR_WIFI_ROUTER_CTRL_TRAFFIC_PACKET_TYPE_DHCP)
+ {
+ /* DHCP frames are UDP frames with BOOTP ports */
+ if (data->os_data_ptr[TA_IP_TYPE_OFFSET] == TA_IP_TYPE_UDP)
+ {
+ if (data->data_length > TA_UDP_DEST_PORT_OFFSET)
+ {
+ source_port = (data->os_data_ptr[TA_UDP_SOURCE_PORT_OFFSET] * 256) +
+ data->os_data_ptr[TA_UDP_SOURCE_PORT_OFFSET + 1];
+ dest_port = (data->os_data_ptr[TA_UDP_DEST_PORT_OFFSET] * 256) +
+ data->os_data_ptr[TA_UDP_DEST_PORT_OFFSET + 1];
+
+ if (((source_port == TA_UDP_PORT_BOOTPC) && (dest_port == TA_UDP_PORT_BOOTPS)) ||
+ ((source_port == TA_UDP_PORT_BOOTPS) && (dest_port == TA_UDP_PORT_BOOTPC)))
+ {
+ /* The DHCP should have at least a message type (request, ack, nack, etc) */
+ if (data->data_length > TA_DHCP_MESSAGE_TYPE_OFFSET + 6)
+ {
+ UNIFI_MAC_ADDRESS_COPY(srcAddress.a, saddr);
+
+ if (direction == CSR_WIFI_ROUTER_CTRL_PROTOCOL_DIRECTION_TX)
+ {
+ unifi_ta_indicate_protocol(card->ospriv,
+ CSR_WIFI_ROUTER_CTRL_TRAFFIC_PACKET_TYPE_DHCP,
+ direction,
+ &srcAddress);
+ return TA_FRAME_ETHERNET_UNINTERESTING;
+ }
+
+ /* DHCPACK is a special indication */
+ if (UNIFI_MAC_ADDRESS_CMP(data->os_data_ptr + TA_BOOTP_CLIENT_MAC_ADDR_OFFSET, sta_macaddr) == TRUE)
+ {
+ if (data->os_data_ptr[TA_DHCP_MESSAGE_TYPE_OFFSET] == TA_DHCP_MESSAGE_TYPE_ACK)
+ {
+ unifi_ta_indicate_protocol(card->ospriv,
+ CSR_WIFI_ROUTER_CTRL_TRAFFIC_PACKET_TYPE_DHCP_ACK,
+ direction,
+ &srcAddress);
+ }
+ else
+ {
+ unifi_ta_indicate_protocol(card->ospriv,
+ CSR_WIFI_ROUTER_CTRL_TRAFFIC_PACKET_TYPE_DHCP,
+ direction,
+ &srcAddress);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ return TA_FRAME_ETHERNET_INTERESTING;
+ }
+
+ /* detect protocol type EAPOL or WAI (treated as equivalent here) */
+ if (tad->packet_filter & CSR_WIFI_ROUTER_CTRL_TRAFFIC_PACKET_TYPE_EAPOL)
+ {
+ if (TA_PROTO_TYPE_EAP == proto || TA_PROTO_TYPE_WAI == proto)
+ {
+ if ((TA_PROTO_TYPE_WAI == proto) || (direction != CSR_WIFI_ROUTER_CTRL_PROTOCOL_DIRECTION_TX) ||
+ (data->os_data_ptr[TA_EAPOL_TYPE_OFFSET] == TA_EAPOL_TYPE_START))
+ {
+ UNIFI_MAC_ADDRESS_COPY(srcAddress.a, saddr);
+ unifi_ta_indicate_protocol(card->ospriv,
+ CSR_WIFI_ROUTER_CTRL_TRAFFIC_PACKET_TYPE_EAPOL,
+ direction, &srcAddress);
+ }
+ return TA_FRAME_ETHERNET_UNINTERESTING;
+ }
+ }
+
+ /* detect protocol type 0x0806 (ARP) */
+ if (tad->packet_filter & CSR_WIFI_ROUTER_CTRL_TRAFFIC_PACKET_TYPE_ARP)
+ {
+ if (proto == TA_PROTO_TYPE_ARP)
+ {
+ UNIFI_MAC_ADDRESS_COPY(srcAddress.a, saddr);
+ unifi_ta_indicate_protocol(card->ospriv,
+ CSR_WIFI_ROUTER_CTRL_TRAFFIC_PACKET_TYPE_ARP,
+ direction, &srcAddress);
+ return TA_FRAME_ETHERNET_UNINTERESTING;
+ }
+ }
+
+ return TA_FRAME_ETHERNET_INTERESTING;
+ }
+ else if (tad->packet_filter & CSR_WIFI_ROUTER_CTRL_TRAFFIC_PACKET_TYPE_AIRONET)
+ {
+ /* detect Aironet frames */
+ if (!memcmp(data->os_data_ptr + 3, aironet_snap, 5))
+ {
+ UNIFI_MAC_ADDRESS_COPY(srcAddress.a, saddr);
+ unifi_ta_indicate_protocol(card->ospriv, CSR_WIFI_ROUTER_CTRL_TRAFFIC_PACKET_TYPE_AIRONET,
+ direction, &srcAddress);
+ }
+ }
+
+ return TA_FRAME_ETHERNET_UNINTERESTING;
+} /* ta_detect_protocol() */
+
+
+static void tas_reset_data(ta_data_t *tad)
+{
+ s16 i;
+
+ for (i = 0; i < (TA_INTERVALS_NUM + 1); i++)
+ {
+ tad->stats.intervals[i] = 0;
+ }
+
+ tad->stats.rxFramesNum = 0;
+ tad->stats.txFramesNum = 0;
+ tad->stats.rxBytesCount = 0;
+ tad->stats.txBytesCount = 0;
+ tad->stats.rxMeanRate = 0;
+
+ tad->rx_sum_rate = 0;
+
+ tad->ta_l4stats.rxTcpBytesCount = 0;
+ tad->ta_l4stats.txTcpBytesCount = 0;
+ tad->ta_l4stats.rxUdpBytesCount = 0;
+ tad->ta_l4stats.txUdpBytesCount = 0;
+} /* tas_reset_data() */
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * API.
+ * unifi_ta_sampling_init
+ *
+ * (Re)Initialise the Traffic Analysis sampling module.
+ * Resets the counters and timestamps.
+ *
+ * Arguments:
+ * tad Pointer to a ta_data_t structure containing the
+ * context for this device instance.
+ * drv_priv An opaque pointer that the TA sampling module will
+ * pass in call-outs.
+ *
+ * Returns:
+ * None.
+ * ---------------------------------------------------------------------------
+ */
+void unifi_ta_sampling_init(card_t *card)
+{
+ (void)unifi_ta_configure(card, CSR_WIFI_ROUTER_CTRL_TRAFFIC_CONFIG_TYPE_RESET, NULL);
+
+ card->ta_sampling.packet_filter = CSR_WIFI_ROUTER_CTRL_TRAFFIC_PACKET_TYPE_NONE;
+ card->ta_sampling.traffic_type = CSR_WIFI_ROUTER_CTRL_TRAFFIC_TYPE_OCCASIONAL;
+} /* unifi_ta_sampling_init() */
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * API.
+ * unifi_ta_sample
+ *
+ * Sample a data frame for the TA module.
+ * This function stores all the useful information it can extract from
+ * the frame and detects any specific protocols.
+ *
+ * Arguments:
+ * tad The pointer to the TA sampling context struct.
+ * direction The direction of the frame (rx, tx)
+ * data Pointer to the frame data
+ * saddr Source MAC address of frame.
+ * timestamp Time (in msecs) that the frame was received.
+ * rate Reported data rate for the rx frame (0 for tx frames)
+ *
+ * Returns:
+ * None
+ * ---------------------------------------------------------------------------
+ */
+void unifi_ta_sample(card_t *card,
+ CsrWifiRouterCtrlProtocolDirection direction,
+ const bulk_data_desc_t *data,
+ const u8 *saddr,
+ const u8 *sta_macaddr,
+ u32 timestamp,
+ u16 rate)
+{
+ ta_data_t *tad = &card->ta_sampling;
+ enum ta_frame_identity identity;
+ u32 time_delta;
+
+
+
+ /* Step1: Check for specific frames */
+ if (tad->packet_filter != CSR_WIFI_ROUTER_CTRL_TRAFFIC_PACKET_TYPE_NONE)
+ {
+ identity = ta_detect_protocol(card, direction, data, saddr, sta_macaddr);
+ }
+ else
+ {
+ identity = TA_FRAME_ETHERNET_INTERESTING;
+ }
+
+
+ /* Step2: Update the information in the current record */
+ if (direction == CSR_WIFI_ROUTER_CTRL_PROTOCOL_DIRECTION_RX)
+ {
+ /* Update the Rx packet count and the throughput count */
+ tad->stats.rxFramesNum++;
+ tad->stats.rxBytesCount += data->data_length;
+
+ /* Accumulate packet Rx rates for later averaging */
+ tad->rx_sum_rate += rate;
+ }
+ else
+ {
+ if (identity == TA_FRAME_ETHERNET_INTERESTING)
+ {
+ /*
+ * Store the period between the last and the current frame.
+ * There is not point storing more than TA_MAX_INTERVALS_IN_C1 periods,
+ * the traffic will be bursty or continuous.
+ */
+ if (tad->stats.txFramesNum < TA_MAX_INTERVALS_IN_C1)
+ {
+ u32 interval;
+ u32 index_in_intervals;
+
+ interval = timestamp - tad->tx_last_ts;
+ tad->tx_last_ts = timestamp;
+ index_in_intervals = (interval + TA_INTERVALS_STEP / 2 - 1) / TA_INTERVALS_STEP;
+
+ /* If the interval is interesting, update the t1_intervals count */
+ if (index_in_intervals <= TA_INTERVALS_NUM)
+ {
+ unifi_trace(card->ospriv, UDBG5,
+ "unifi_ta_sample: TX interval=%d index=%d\n",
+ interval, index_in_intervals);
+ tad->stats.intervals[index_in_intervals]++;
+ }
+ }
+ }
+
+ /* Update the Tx packet count... */
+ tad->stats.txFramesNum++;
+ /* ... and the number of bytes for throughput. */
+ tad->stats.txBytesCount += data->data_length;
+ }
+
+ /*
+ * If more than one second has elapsed since the last report, send
+ * another one.
+ */
+ /* Unsigned subtraction handles wrap-around from 0xFFFFFFFF to 0 */
+ time_delta = timestamp - tad->last_indication_time;
+ if (time_delta >= 1000)
+ {
+ /*
+ * rxFramesNum can be flashed in tas_reset_data() by another thread.
+ * Use a temp to avoid division by zero.
+ */
+ u32 temp_rxFramesNum;
+ temp_rxFramesNum = tad->stats.rxFramesNum;
+
+ /* Calculate this interval's mean frame Rx rate from the sum */
+ if (temp_rxFramesNum)
+ {
+ tad->stats.rxMeanRate = tad->rx_sum_rate / temp_rxFramesNum;
+ }
+ unifi_trace(card->ospriv, UDBG5,
+ "unifi_ta_sample: RX fr=%lu, r=%u, sum=%lu, av=%lu\n",
+ tad->stats.rxFramesNum, rate,
+ tad->rx_sum_rate, tad->stats.rxMeanRate);
+
+ /*
+ * Send the information collected in the stats struct
+ * to the SME and reset the counters.
+ */
+ if (tad->packet_filter & CSR_WIFI_ROUTER_CTRL_TRAFFIC_PACKET_TYPE_CUSTOM)
+ {
+ u32 rxTcpThroughput = tad->ta_l4stats.rxTcpBytesCount / time_delta;
+ u32 txTcpThroughput = tad->ta_l4stats.txTcpBytesCount / time_delta;
+ u32 rxUdpThroughput = tad->ta_l4stats.rxUdpBytesCount / time_delta;
+ u32 txUdpThroughput = tad->ta_l4stats.txUdpBytesCount / time_delta;
+
+ unifi_ta_indicate_l4stats(card->ospriv,
+ rxTcpThroughput,
+ txTcpThroughput,
+ rxUdpThroughput,
+ txUdpThroughput
+ );
+ }
+ unifi_ta_indicate_sampling(card->ospriv, &tad->stats);
+ tas_reset_data(tad);
+ tad->last_indication_time = timestamp;
+ }
+} /* unifi_ta_sample() */
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * External API.
+ * unifi_ta_configure
+ *
+ * Configures the TA module parameters.
+ *
+ * Arguments:
+ * ta The pointer to the TA module.
+ * config_type The type of the configuration request
+ * config Pointer to the configuration parameters.
+ *
+ * Returns:
+ * CSR_RESULT_SUCCESS on success, CSR error code otherwise
+ * ---------------------------------------------------------------------------
+ */
+CsrResult unifi_ta_configure(card_t *card,
+ CsrWifiRouterCtrlTrafficConfigType config_type,
+ const CsrWifiRouterCtrlTrafficConfig *config)
+{
+ ta_data_t *tad = &card->ta_sampling;
+
+ /* Reinitialise our data when we are reset */
+ if (config_type == CSR_WIFI_ROUTER_CTRL_TRAFFIC_CONFIG_TYPE_RESET)
+ {
+ /* Reset the stats to zero */
+ tas_reset_data(tad);
+
+ /* Reset the timer variables */
+ tad->tx_last_ts = 0;
+ tad->last_indication_time = 0;
+
+ return CSR_RESULT_SUCCESS;
+ }
+
+ if (config_type == CSR_WIFI_ROUTER_CTRL_TRAFFIC_CONFIG_TYPE_FILTER)
+ {
+ tad->packet_filter = config->packetFilter;
+
+ if (tad->packet_filter & CSR_WIFI_ROUTER_CTRL_TRAFFIC_PACKET_TYPE_CUSTOM)
+ {
+ tad->custom_filter = config->customFilter;
+ }
+
+ return CSR_RESULT_SUCCESS;
+ }
+
+ return CSR_RESULT_SUCCESS;
+} /* unifi_ta_configure() */
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * External API.
+ * unifi_ta_classification
+ *
+ * Configures the current TA classification.
+ *
+ * Arguments:
+ * ta The pointer to the TA module.
+ * traffic_type The classification type
+ * period The traffic period if the type is periodic
+ *
+ * Returns:
+ * None
+ * ---------------------------------------------------------------------------
+ */
+void unifi_ta_classification(card_t *card,
+ CsrWifiRouterCtrlTrafficType traffic_type,
+ u16 period)
+{
+ unifi_trace(card->ospriv, UDBG3,
+ "Changed current ta classification to: %d\n", traffic_type);
+
+ card->ta_sampling.traffic_type = traffic_type;
+}
+
+
diff --git a/drivers/staging/csr/csr_wifi_hip_ta_sampling.h b/drivers/staging/csr/csr_wifi_hip_ta_sampling.h
new file mode 100644
index 000000000000..46c630b4beea
--- /dev/null
+++ b/drivers/staging/csr/csr_wifi_hip_ta_sampling.h
@@ -0,0 +1,75 @@
+/*****************************************************************************
+
+ (c) Cambridge Silicon Radio Limited 2011
+ All rights reserved and confidential information of CSR
+
+ Refer to LICENSE.txt included with this source for details
+ on the license terms.
+
+*****************************************************************************/
+
+/*
+ * ---------------------------------------------------------------------------
+ * FILE: csr_wifi_hip_ta_sampling.h
+ *
+ * PURPOSE:
+ * This file contains Traffic Analysis definitions common to the
+ * sampling and analysis modules.
+ *
+ * ---------------------------------------------------------------------------
+ */
+#ifndef __TA_SAMPLING_H__
+#define __TA_SAMPLING_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include "csr_wifi_hip_unifi.h"
+
+typedef struct ta_l4stats
+{
+ u32 rxTcpBytesCount;
+ u32 txTcpBytesCount;
+ u32 rxUdpBytesCount;
+ u32 txUdpBytesCount;
+} ta_l4stats_t;
+
+/*
+ * Context structure to preserve state between calls.
+ */
+
+typedef struct ta_data
+{
+ /* Current packet filter configuration */
+ u16 packet_filter;
+
+ /* Current packet custom filter configuration */
+ CsrWifiRouterCtrlTrafficFilter custom_filter;
+
+ /* The timestamp of the last tx packet processed. */
+ u32 tx_last_ts;
+
+ /* The timestamp of the last packet processed. */
+ u32 last_indication_time;
+
+ /* Statistics */
+ CsrWifiRouterCtrlTrafficStats stats;
+
+ /* Current traffic classification */
+ CsrWifiRouterCtrlTrafficType traffic_type;
+
+ /* Sum of packet rx rates for this interval used to calculate mean */
+ u32 rx_sum_rate;
+ ta_l4stats_t ta_l4stats;
+} ta_data_t;
+
+
+void unifi_ta_sampling_init(card_t *card);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __TA_SAMPLING_H__ */
diff --git a/drivers/staging/csr/csr_wifi_hip_udi.c b/drivers/staging/csr/csr_wifi_hip_udi.c
new file mode 100644
index 000000000000..07cfd36c4971
--- /dev/null
+++ b/drivers/staging/csr/csr_wifi_hip_udi.c
@@ -0,0 +1,268 @@
+/*****************************************************************************
+
+ (c) Cambridge Silicon Radio Limited 2011
+ All rights reserved and confidential information of CSR
+
+ Refer to LICENSE.txt included with this source for details
+ on the license terms.
+
+*****************************************************************************/
+
+/*
+ * ---------------------------------------------------------------------------
+ * FILE: csr_wifi_hip_card_udi.c
+ *
+ * PURPOSE:
+ * Maintain a list of callbacks to log UniFi exchanges to one or more
+ * debug/monitoring client applications.
+ *
+ * NOTES:
+ * Just call the UDI driver log fn directly for now.
+ * When done properly, each open() on the UDI device will install
+ * a log function. We will call all log fns whenever a signal is written
+ * to or read form the UniFi.
+ *
+ * ---------------------------------------------------------------------------
+ */
+#include "csr_wifi_hip_unifi.h"
+#include "csr_wifi_hip_card.h"
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * unifi_print_status
+ *
+ * Print status info to given character buffer.
+ *
+ * Arguments:
+ * None.
+ *
+ * Returns:
+ * None.
+ * ---------------------------------------------------------------------------
+ */
+s32 unifi_print_status(card_t *card, char *str, s32 *remain)
+{
+ char *p = str;
+ sdio_config_data_t *cfg;
+ u16 i, n;
+ s32 remaining = *remain;
+ s32 written;
+#ifdef CSR_UNSAFE_SDIO_ACCESS
+ s32 iostate;
+ CsrResult r;
+ static const char *const states[] = {
+ "AWAKE", "DROWSY", "TORPID"
+ };
+ #define SHARED_READ_RETRY_LIMIT 10
+ u8 b;
+#endif
+
+ if (remaining <= 0)
+ {
+ return 0;
+ }
+
+ i = n = 0;
+ written = CsrSnprintf(p, remaining, "Chip ID %u\n",
+ (u16)card->chip_id);
+ UNIFI_SNPRINTF_RET(p, remaining, written);
+ written = CsrSnprintf(p, remaining, "Chip Version %04X\n",
+ card->chip_version);
+ UNIFI_SNPRINTF_RET(p, remaining, written);
+ written = CsrSnprintf(p, remaining, "HIP v%u.%u\n",
+ (card->config_data.version >> 8) & 0xFF,
+ card->config_data.version & 0xFF);
+ UNIFI_SNPRINTF_RET(p, remaining, written);
+ written = CsrSnprintf(p, remaining, "Build %lu: %s\n",
+ card->build_id, card->build_id_string);
+ UNIFI_SNPRINTF_RET(p, remaining, written);
+
+ cfg = &card->config_data;
+
+ written = CsrSnprintf(p, remaining, "sdio ctrl offset %u\n",
+ cfg->sdio_ctrl_offset);
+ UNIFI_SNPRINTF_RET(p, remaining, written);
+ written = CsrSnprintf(p, remaining, "fromhost sigbuf handle %u\n",
+ cfg->fromhost_sigbuf_handle);
+ UNIFI_SNPRINTF_RET(p, remaining, written);
+ written = CsrSnprintf(p, remaining, "tohost_sigbuf_handle %u\n",
+ cfg->tohost_sigbuf_handle);
+ UNIFI_SNPRINTF_RET(p, remaining, written);
+ written = CsrSnprintf(p, remaining, "num_fromhost_sig_frags %u\n",
+ cfg->num_fromhost_sig_frags);
+ UNIFI_SNPRINTF_RET(p, remaining, written);
+ written = CsrSnprintf(p, remaining, "num_tohost_sig_frags %u\n",
+ cfg->num_tohost_sig_frags);
+ UNIFI_SNPRINTF_RET(p, remaining, written);
+ written = CsrSnprintf(p, remaining, "num_fromhost_data_slots %u\n",
+ cfg->num_fromhost_data_slots);
+ UNIFI_SNPRINTF_RET(p, remaining, written);
+ written = CsrSnprintf(p, remaining, "num_tohost_data_slots %u\n",
+ cfg->num_tohost_data_slots);
+ UNIFI_SNPRINTF_RET(p, remaining, written);
+ written = CsrSnprintf(p, remaining, "data_slot_size %u\n",
+ cfg->data_slot_size);
+ UNIFI_SNPRINTF_RET(p, remaining, written);
+
+ /* Added by protocol version 0x0001 */
+ written = CsrSnprintf(p, remaining, "overlay_size %u\n",
+ (u16)cfg->overlay_size);
+ UNIFI_SNPRINTF_RET(p, remaining, written);
+
+ /* Added by protocol version 0x0300 */
+ written = CsrSnprintf(p, remaining, "data_slot_round %u\n",
+ cfg->data_slot_round);
+ UNIFI_SNPRINTF_RET(p, remaining, written);
+ written = CsrSnprintf(p, remaining, "sig_frag_size %u\n",
+ cfg->sig_frag_size);
+ UNIFI_SNPRINTF_RET(p, remaining, written);
+
+ /* Added by protocol version 0x0300 */
+ written = CsrSnprintf(p, remaining, "tohost_sig_pad %u\n",
+ cfg->tohost_signal_padding);
+ UNIFI_SNPRINTF_RET(p, remaining, written);
+
+ written = CsrSnprintf(p, remaining, "\nInternal state:\n");
+ UNIFI_SNPRINTF_RET(p, remaining, written);
+
+ written = CsrSnprintf(p, remaining, "Last PHY PANIC: %04x:%04x\n",
+ card->last_phy_panic_code, card->last_phy_panic_arg);
+ UNIFI_SNPRINTF_RET(p, remaining, written);
+ written = CsrSnprintf(p, remaining, "Last MAC PANIC: %04x:%04x\n",
+ card->last_mac_panic_code, card->last_mac_panic_arg);
+ UNIFI_SNPRINTF_RET(p, remaining, written);
+
+ written = CsrSnprintf(p, remaining, "fhsr: %u\n",
+ (u16)card->from_host_signals_r);
+ UNIFI_SNPRINTF_RET(p, remaining, written);
+ written = CsrSnprintf(p, remaining, "fhsw: %u\n",
+ (u16)card->from_host_signals_w);
+ UNIFI_SNPRINTF_RET(p, remaining, written);
+ written = CsrSnprintf(p, remaining, "thsr: %u\n",
+ (u16)card->to_host_signals_r);
+ UNIFI_SNPRINTF_RET(p, remaining, written);
+ written = CsrSnprintf(p, remaining, "thsw: %u\n",
+ (u16)card->to_host_signals_w);
+ UNIFI_SNPRINTF_RET(p, remaining, written);
+ written = CsrSnprintf(p, remaining,
+ "fh buffer contains: %u signals, %u bytes\n",
+ card->fh_buffer.count,
+ card->fh_buffer.ptr - card->fh_buffer.buf);
+ UNIFI_SNPRINTF_RET(p, remaining, written);
+
+ written = CsrSnprintf(p, remaining, "paused: ");
+ UNIFI_SNPRINTF_RET(p, remaining, written);
+ for (i = 0; i < sizeof(card->tx_q_paused_flag) / sizeof(card->tx_q_paused_flag[0]); i++)
+ {
+ written = CsrSnprintf(p, remaining, card->tx_q_paused_flag[i]?"1" : "0");
+ UNIFI_SNPRINTF_RET(p, remaining, written);
+ }
+ written = CsrSnprintf(p, remaining, "\n");
+ UNIFI_SNPRINTF_RET(p, remaining, written);
+
+ written = CsrSnprintf(p, remaining,
+ "fh command q: %u waiting, %u free of %u:\n",
+ CSR_WIFI_HIP_Q_SLOTS_USED(&card->fh_command_queue),
+ CSR_WIFI_HIP_Q_SLOTS_FREE(&card->fh_command_queue),
+ UNIFI_SOFT_COMMAND_Q_LENGTH);
+ UNIFI_SNPRINTF_RET(p, remaining, written);
+ for (i = 0; i < UNIFI_NO_OF_TX_QS; i++)
+ {
+ written = CsrSnprintf(p, remaining,
+ "fh traffic q[%u]: %u waiting, %u free of %u:\n",
+ i,
+ CSR_WIFI_HIP_Q_SLOTS_USED(&card->fh_traffic_queue[i]),
+ CSR_WIFI_HIP_Q_SLOTS_FREE(&card->fh_traffic_queue[i]),
+ UNIFI_SOFT_TRAFFIC_Q_LENGTH);
+ UNIFI_SNPRINTF_RET(p, remaining, written);
+ }
+
+ written = CsrSnprintf(p, remaining, "fh data slots free: %u\n",
+ card->from_host_data?CardGetFreeFromHostDataSlots(card) : 0);
+ UNIFI_SNPRINTF_RET(p, remaining, written);
+
+
+ written = CsrSnprintf(p, remaining, "From host data slots:");
+ UNIFI_SNPRINTF_RET(p, remaining, written);
+ n = card->config_data.num_fromhost_data_slots;
+ for (i = 0; i < n && card->from_host_data; i++)
+ {
+ written = CsrSnprintf(p, remaining, " %u",
+ (u16)card->from_host_data[i].bd.data_length);
+ UNIFI_SNPRINTF_RET(p, remaining, written);
+ }
+ written = CsrSnprintf(p, remaining, "\n");
+ UNIFI_SNPRINTF_RET(p, remaining, written);
+
+ written = CsrSnprintf(p, remaining, "To host data slots:");
+ UNIFI_SNPRINTF_RET(p, remaining, written);
+ n = card->config_data.num_tohost_data_slots;
+ for (i = 0; i < n && card->to_host_data; i++)
+ {
+ written = CsrSnprintf(p, remaining, " %u",
+ (u16)card->to_host_data[i].data_length);
+ UNIFI_SNPRINTF_RET(p, remaining, written);
+ }
+
+ written = CsrSnprintf(p, remaining, "\n");
+ UNIFI_SNPRINTF_RET(p, remaining, written);
+
+#ifdef CSR_UNSAFE_SDIO_ACCESS
+ written = CsrSnprintf(p, remaining, "Host State: %s\n", states[card->host_state]);
+ UNIFI_SNPRINTF_RET(p, remaining, written);
+
+ r = unifi_check_io_status(card, &iostate);
+ if (iostate == 1)
+ {
+ written = CsrSnprintf(p, remaining, "I/O Check: F1 disabled\n");
+ UNIFI_SNPRINTF_RET(p, remaining, written);
+ }
+ else
+ {
+ if (iostate == 1)
+ {
+ written = CsrSnprintf(p, remaining, "I/O Check: pending interrupt\n");
+ UNIFI_SNPRINTF_RET(p, remaining, written);
+ }
+
+ written = CsrSnprintf(p, remaining, "BH reason interrupt = %d\n",
+ card->bh_reason_unifi);
+ UNIFI_SNPRINTF_RET(p, remaining, written);
+ written = CsrSnprintf(p, remaining, "BH reason host = %d\n",
+ card->bh_reason_host);
+ UNIFI_SNPRINTF_RET(p, remaining, written);
+
+ for (i = 0; i < SHARED_READ_RETRY_LIMIT; i++)
+ {
+ r = unifi_read_8_or_16(card, card->sdio_ctrl_addr + 2, &b);
+ if ((r == CSR_RESULT_SUCCESS) && (!(b & 0x80)))
+ {
+ written = CsrSnprintf(p, remaining, "fhsr: %u (driver thinks is %u)\n",
+ b, card->from_host_signals_r);
+ UNIFI_SNPRINTF_RET(p, remaining, written);
+ break;
+ }
+ }
+ iostate = unifi_read_shared_count(card, card->sdio_ctrl_addr + 4);
+ written = CsrSnprintf(p, remaining, "thsw: %u (driver thinks is %u)\n",
+ iostate, card->to_host_signals_w);
+ UNIFI_SNPRINTF_RET(p, remaining, written);
+ }
+#endif
+
+ written = CsrSnprintf(p, remaining, "\nStats:\n");
+ UNIFI_SNPRINTF_RET(p, remaining, written);
+ written = CsrSnprintf(p, remaining, "Total SDIO bytes: R=%lu W=%lu\n",
+ card->sdio_bytes_read, card->sdio_bytes_written);
+
+ UNIFI_SNPRINTF_RET(p, remaining, written);
+ written = CsrSnprintf(p, remaining, "Interrupts generated on card: %lu\n",
+ card->unifi_interrupt_seq);
+ UNIFI_SNPRINTF_RET(p, remaining, written);
+
+ *remain = remaining;
+ return (p - str);
+} /* unifi_print_status() */
+
+
diff --git a/drivers/staging/csr/csr_wifi_hip_unifi.h b/drivers/staging/csr/csr_wifi_hip_unifi.h
new file mode 100644
index 000000000000..dc3c60b49702
--- /dev/null
+++ b/drivers/staging/csr/csr_wifi_hip_unifi.h
@@ -0,0 +1,880 @@
+/*****************************************************************************
+
+ (c) Cambridge Silicon Radio Limited 2012
+ All rights reserved and confidential information of CSR
+
+ Refer to LICENSE.txt included with this source for details
+ on the license terms.
+
+*****************************************************************************/
+
+/*
+ * ---------------------------------------------------------------------------
+ *
+ * FILE : csr_wifi_hip_unifi.h
+ *
+ * PURPOSE : Public API for the UniFi HIP core library.
+ *
+ * ---------------------------------------------------------------------------
+ */
+#ifndef __CSR_WIFI_HIP_UNIFI_H__
+#define __CSR_WIFI_HIP_UNIFI_H__ 1
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef CSR_WIFI_HIP_TA_DISABLE
+#include "csr_wifi_router_ctrl_prim.h"
+#include "csr_wifi_router_prim.h"
+#else
+#include "csr_time.h"
+#endif
+
+/* SDIO chip ID numbers */
+
+/* Manufacturer id */
+#define SDIO_MANF_ID_CSR 0x032a
+
+/* Device id */
+#define SDIO_CARD_ID_UNIFI_1 0x0001
+#define SDIO_CARD_ID_UNIFI_2 0x0002
+#define SDIO_CARD_ID_UNIFI_3 0x0007
+#define SDIO_CARD_ID_UNIFI_4 0x0008
+
+/* Function number for WLAN */
+#define SDIO_WLAN_FUNC_ID_UNIFI_1 0x0001
+#define SDIO_WLAN_FUNC_ID_UNIFI_2 0x0001
+#define SDIO_WLAN_FUNC_ID_UNIFI_3 0x0001
+#define SDIO_WLAN_FUNC_ID_UNIFI_4 0x0002
+
+/* Maximum SDIO bus clock supported. */
+#define UNIFI_SDIO_CLOCK_MAX_HZ 50000000 /* Hz */
+
+/*
+ * Initialisation SDIO bus clock.
+ *
+ * The initialisation clock speed should be used from when the chip has been
+ * reset until the first MLME-reset has been received (i.e. during firmware
+ * initialisation), unless UNIFI_SDIO_CLOCK_SAFE_HZ applies.
+ */
+#define UNIFI_SDIO_CLOCK_INIT_HZ 12500000 /* Hz */
+
+/*
+ * Safe SDIO bus clock.
+ *
+ * The safe speed should be used when the chip is in deep sleep or
+ * it's state is unknown (just after reset / power on).
+ */
+#define UNIFI_SDIO_CLOCK_SAFE_HZ 1000000 /* Hz */
+
+/* I/O default block size to use for UniFi. */
+#define UNIFI_IO_BLOCK_SIZE 64
+
+#define UNIFI_WOL_OFF 0
+#define UNIFI_WOL_SDIO 1
+#define UNIFI_WOL_PIO 2
+
+/* The number of Tx traffic queues */
+#define UNIFI_NO_OF_TX_QS 4
+
+#define CSR_WIFI_HIP_RESERVED_HOST_TAG 0xFFFFFFFF
+
+/*
+ * The number of slots in the from-host queues.
+ *
+ * UNIFI_SOFT_TRAFFIC_Q_LENGTH is the number of slots in the traffic queues
+ * and there will be UNIFI_NO_OF_TX_QS of them.
+ * Traffic queues are used for data packets.
+ *
+ * UNIFI_SOFT_COMMAND_Q_LENGTH is the number of slots in the command queue.
+ * The command queue is used for MLME management requests.
+ *
+ * Queues are ring buffers and so must always have 1 unused slot.
+ */
+#define UNIFI_SOFT_TRAFFIC_Q_LENGTH (20 + 1)
+#define UNIFI_SOFT_COMMAND_Q_LENGTH (16 + 1)
+
+#include "csr_framework_ext.h" /* from the synergy porting folder */
+#include "csr_sdio.h" /* from the synergy porting folder */
+#include "csr_macro.h" /* from the synergy porting folder */
+#include "csr_formatted_io.h" /* from the synergy gsp folder */
+#include "csr_wifi_result.h"
+
+/* Utility MACROS. Note that UNIFI_MAC_ADDRESS_CMP returns TRUE on success */
+#define UNIFI_MAC_ADDRESS_COPY(dst, src) \
+ do { (dst)[0] = (src)[0]; (dst)[1] = (src)[1]; \
+ (dst)[2] = (src)[2]; (dst)[3] = (src)[3]; \
+ (dst)[4] = (src)[4]; (dst)[5] = (src)[5]; \
+ } while (0)
+
+#define UNIFI_MAC_ADDRESS_CMP(addr1, addr2) \
+ (((addr1)[0] == (addr2)[0]) && ((addr1)[1] == (addr2)[1]) && \
+ ((addr1)[2] == (addr2)[2]) && ((addr1)[3] == (addr2)[3]) && \
+ ((addr1)[4] == (addr2)[4]) && ((addr1)[5] == (addr2)[5]))
+
+/* Traffic queue ordered according to priority
+ * EAPOL/Uncontrolled port Queue should be the last
+ */
+typedef enum
+{
+ UNIFI_TRAFFIC_Q_BK = 0,
+ UNIFI_TRAFFIC_Q_BE,
+ UNIFI_TRAFFIC_Q_VI,
+ UNIFI_TRAFFIC_Q_VO,
+ UNIFI_TRAFFIC_Q_EAPOL, /* Non existant in HIP */
+ UNIFI_TRAFFIC_Q_MAX, /* Non existant */
+ UNIFI_TRAFFIC_Q_MLME /* Non existant */
+} unifi_TrafficQueue;
+
+/*
+ * Structure describing a bulk data slot.
+ * This structure is shared between the HIP core library and the OS
+ * layer. See the definition of unifi_net_data_malloc() for more details.
+ *
+ * The data_length field is used to indicate empty/occupied state.
+ * Needs to be defined before #include "unifi_os.h".
+ */
+typedef struct _bulk_data_desc
+{
+ const u8 *os_data_ptr;
+ u32 data_length;
+ const void *os_net_buf_ptr;
+ u32 net_buf_length;
+} bulk_data_desc_t;
+
+/* Structure of an entry in the Symbol Look Up Table (SLUT). */
+typedef struct _symbol
+{
+ u16 id;
+ u32 obj;
+} symbol_t;
+
+/*
+ * Header files need to be included from the current directory,
+ * the SME library, the synergy framework and the OS layer.
+ * A thin OS layer needs to be implemented in the porting exercise.
+ *
+ * Note that unifi_os.h should be included only in unifi.h
+ */
+
+#include "unifi_os.h"
+
+/*
+ * Contains the HIP core definitions selected in the porting exercise, such as
+ * UNIFI_PAD_BULK_DATA_TO_BLOCK_SIZE and UNIFI_PAD_SIGNALS_TO_BLOCK_SIZE.
+ * Implemented in the OS layer, as part of the porting exersice.
+ */
+#include "unifi_config.h"
+
+#include "csr_wifi_hip_signals.h" /* from this dir */
+
+/*
+ * The card structure is an opaque pointer that is used to pass context
+ * to the upper-edge API functions.
+ */
+typedef struct card card_t;
+
+
+/*
+ * This structure describes all of the bulk data that 'might' be
+ * associated with a signal.
+ */
+typedef struct _bulk_data_param
+{
+ bulk_data_desc_t d[UNIFI_MAX_DATA_REFERENCES];
+} bulk_data_param_t;
+
+
+/*
+ * This structure describes the chip and HIP core lib
+ * information that exposed to the OS layer.
+ */
+typedef struct _card_info
+{
+ u16 chip_id;
+ u16 chip_version;
+ u32 fw_build;
+ u16 fw_hip_version;
+ u32 sdio_block_size;
+} card_info_t;
+
+
+/*
+ * Mini-coredump definitions
+ */
+/* Definition of XAP memory ranges used by the mini-coredump system.
+ * Note that, these values are NOT the same as UNIFI_REGISTERS, etc
+ * in unifihw.h which don't allow selection of register areas for each XAP.
+ */
+typedef enum unifi_coredump_space
+{
+ UNIFI_COREDUMP_MAC_REG,
+ UNIFI_COREDUMP_PHY_REG,
+ UNIFI_COREDUMP_SH_DMEM,
+ UNIFI_COREDUMP_MAC_DMEM,
+ UNIFI_COREDUMP_PHY_DMEM,
+ UNIFI_COREDUMP_TRIGGER_MAGIC = 0xFEED
+} unifi_coredump_space_t;
+
+/* Structure used to request a register value from a mini-coredump buffer */
+typedef struct unifi_coredump_req
+{
+ /* From user */
+ s32 index; /* 0=newest, -1=oldest */
+ unifi_coredump_space_t space; /* memory space */
+ u32 offset; /* register offset in space */
+ /* From driver */
+ u32 drv_build; /* Driver build id */
+ u32 chip_ver; /* Chip version */
+ u32 fw_ver; /* Firmware version */
+ s32 requestor; /* Requestor: 0=auto dump, 1=manual */
+ CsrTime timestamp; /* time of capture by driver */
+ u32 serial; /* capture serial number */
+ s32 value; /* register value */
+} unifi_coredump_req_t; /* mini-coredumped reg value request */
+
+
+/**
+ * @defgroup upperedge Upper edge API
+ *
+ * The following functions are implemented in the HIP core lib.
+ */
+
+/**
+ *
+ * Initialise the HIP core lib.
+ * Note that the OS layer must initialise the SDIO glue layer and obtain
+ * an SDIO function context, prior to this call.
+ *
+ * @param sdiopriv the SDIO function context.
+ *
+ * @param ospriv the OS layer context.
+ *
+ * @return \p card_t the HIP core lib API context.
+ *
+ * @ingroup upperedge
+ */
+card_t* unifi_alloc_card(CsrSdioFunction *sdiopriv, void *ospriv);
+
+
+/**
+ *
+ * Initialise the UniFi chip.
+ *
+ * @param card the HIP core lib API context.
+ *
+ * @param led_mask the led mask to apply to UniFi.
+ *
+ * @return \b 0 if UniFi is initialized.
+ *
+ * @return \b -CSR_EIO if an I/O error occured while initializing UniFi
+ *
+ * @return \b -CSR_ENODEV if the card is no longer present.
+ *
+ * @ingroup upperedge
+ */
+CsrResult unifi_init_card(card_t *card, s32 led_mask);
+
+/**
+ *
+ * De-Initialise the HIP core lib.
+ *
+ * @param card the HIP core lib API context.
+ *
+ * @ingroup upperedge
+ */
+void unifi_free_card(card_t *card);
+
+/**
+ *
+ * Cancel all the signals pending in the HIP core lib.
+ * Normally used during a system suspend when the power is retained on UniFi.
+ *
+ * @param card the HIP core lib API context.
+ *
+ * @ingroup upperedge
+ */
+void unifi_cancel_pending_signals(card_t *card);
+
+/**
+ *
+ * Send a signal to UniFi.
+ * Normally it is called from unifi_sys_hip_req() and the OS layer
+ * Tx data plane.
+ *
+ * Note that the bulkdata buffers ownership is passed to the HIP core lib.
+ * These buffers must be allocated using unifi_net_data_malloc().
+ *
+ * @param card the HIP core lib API context.
+ *
+ * @param sigptr pointer to the signal.
+ *
+ * @param siglen size of the signal.
+ *
+ * @param bulkdata pointer to the bulk data associated with the signal.
+ *
+ * @return \b 0 signal is sent.
+ *
+ * @return \b -CSR_EIO if an error occured while sending the signal
+ *
+ * @return \b -CSR_ENODEV if the card is no longer present.
+ *
+ * @ingroup upperedge
+ */
+CsrResult unifi_send_signal(card_t *card, const u8 *sigptr,
+ u32 siglen,
+ const bulk_data_param_t *bulkdata);
+
+/**
+ *
+ * Check if the HIP core lib has resources to send a signal.
+ * Normally there no need to use this function.
+ *
+ * @param card the HIP core lib API context.
+ *
+ * @param sigptr pointer to the signal.
+ *
+ * @return \b 0 if there are resources for the signal.
+ *
+ * @return \b -CSR_ENOSPC if there are not enough resources
+ *
+ * @ingroup upperedge
+ */
+CsrResult unifi_send_resources_available(card_t *card, const u8 *sigptr);
+
+/**
+ *
+ * Read the UniFi chip and the HIP core lib information.
+ *
+ * @param card the HIP core lib API context.
+ *
+ * @param card_info pointer to save the information.
+ *
+ * @ingroup upperedge
+ */
+void unifi_card_info(card_t *card, card_info_t *card_info);
+
+/**
+ *
+ * Print the UniFi I/O and Interrupt status.
+ * Normally it is used for debug purposes only.
+ *
+ * @param card the HIP core lib API context.
+
+ * @param status buffer for the chip status
+ *
+ * @return \b 0 if the check was performed.
+ *
+ * @return \b -CSR_EIO if an error occured while checking the status.
+ *
+ * @return \b -CSR_ENODEV if the card is no longer present.
+ *
+ * @ingroup upperedge
+ */
+CsrResult unifi_check_io_status(card_t *card, s32 *status);
+
+
+/**
+ *
+ * Run the HIP core lib Botton-Half.
+ * Whenever the HIP core lib want this function to be called
+ * by the OS layer, it calls unifi_run_bh().
+ *
+ * @param card the HIP core lib API context.
+ *
+ * @param remaining pointer to return the time (in msecs) that this function
+ * should be re-scheduled. A return value of 0 means that no re-scheduling
+ * is required. If unifi_bh() is called before the timeout expires,
+ * the caller must pass in the remaining time.
+ *
+ * @return \b 0 if no error occured.
+ *
+ * @return \b -CSR_ENODEV if the card is no longer present.
+ *
+ * @return \b -CSR_E* if an error occured while running the bottom half.
+ *
+ * @ingroup upperedge
+ */
+CsrResult unifi_bh(card_t *card, u32 *remaining);
+
+
+/**
+ * UniFi Low Power Mode (Deep Sleep Signaling)
+ *
+ * unifi_low_power_mode defines the UniFi Deep Sleep Signaling status.
+ * Use with unifi_configure_low_power_mode() to enable/disable
+ * the Deep Sleep Signaling.
+ */
+enum unifi_low_power_mode
+{
+ UNIFI_LOW_POWER_DISABLED,
+ UNIFI_LOW_POWER_ENABLED
+};
+
+/**
+ * Periodic Wake Host Mode
+ *
+ * unifi_periodic_wake_mode defines the Periodic Wake Host Mode.
+ * It can only be set to UNIFI_PERIODIC_WAKE_HOST_ENABLED if
+ * low_power_mode == UNIFI_LOW_POWER_ENABLED.
+ */
+enum unifi_periodic_wake_mode
+{
+ UNIFI_PERIODIC_WAKE_HOST_DISABLED,
+ UNIFI_PERIODIC_WAKE_HOST_ENABLED
+};
+
+/**
+ *
+ * Run the HIP core lib Botton-Half.
+ * Whenever the HIP core lib want this function to be called
+ * by the OS layer, it calls unifi_run_bh().
+ *
+ * Typically, the SME is responsible for configuring these parameters,
+ * so unifi_sys_configure_power_mode_req() is usually implemented
+ * as a direct call to unifi_configure_low_power_mode().
+ *
+ * Note: When polling mode is used instead of interrupts,
+ * low_power_mode must never be set to UNIFI_LOW_POWER_ENABLED.
+ *
+ * @param card the HIP core lib API context.
+ *
+ * @param low_power_mode the Low Power Mode.
+ *
+ * @param periodic_wake_mode the Periodic Wake Mode.
+ *
+ * @return \b 0 if no error occured.
+ *
+ * @return \b -CSR_E* if the request failed.
+ *
+ * @ingroup upperedge
+ */
+CsrResult unifi_configure_low_power_mode(card_t *card,
+ enum unifi_low_power_mode low_power_mode,
+ enum unifi_periodic_wake_mode periodic_wake_mode);
+
+/**
+ *
+ * Forces the UniFi chip to enter a Deep Sleep state.
+ * This is normally called by the OS layer when the platform suspends.
+ *
+ * Note that if the UniFi Low Power Mode is disabled this call fails.
+ *
+ * @param card the HIP core lib API context.
+ *
+ * @return \b 0 if no error occured.
+ *
+ * @return \b -CSR_ENODEV if the card is no longer present.
+ *
+ * @return \b -CSR_E* if the request failed.
+ *
+ * @ingroup upperedge
+ */
+CsrResult unifi_force_low_power_mode(card_t *card);
+
+#ifndef CSR_WIFI_HIP_TA_DISABLE
+/**
+ * Configure the Traffic Analysis sampling
+ *
+ * Enable or disable statistics gathering.
+ * Enable or disable particular packet detection.
+ *
+ * @param card the HIP core context
+ * @param config_type the item to configure
+ * @param config pointer to struct containing config info
+ *
+ * @return \b 0 if configuration was successful
+ *
+ * @return \b -CSR_EINVAL if a parameter had an invalid value
+ *
+ * @ingroup upperedge
+ */
+CsrResult unifi_ta_configure(card_t *card,
+ CsrWifiRouterCtrlTrafficConfigType config_type,
+ const CsrWifiRouterCtrlTrafficConfig *config);
+
+/**
+ * Pass a packet for Traffic Analysis sampling
+ *
+ * @param card the HIP core context
+ * @param direction the direction (Rx or Tx) of the frame.
+ * @param data pointer to bulkdata struct containing the packet
+ * @param saddr the source address of the packet
+ * @param sta_macaddr the MAC address of the UniFi chip
+ * @param timestamp the current time in msecs
+ *
+ * @ingroup upperedge
+ */
+void unifi_ta_sample(card_t *card,
+ CsrWifiRouterCtrlProtocolDirection direction,
+ const bulk_data_desc_t *data,
+ const u8 *saddr,
+ const u8 *sta_macaddr,
+ u32 timestamp,
+ u16 rate);
+
+/**
+ * Notify the HIP core lib for a detected Traffic Classification.
+ * Typically, the SME is responsible for configuring these parameters,
+ * so unifi_sys_traffic_classification_req() is usually implemented
+ * as a direct call to unifi_ta_classification().
+ *
+ * @param card the HIP core context.
+ * @param traffic_type the detected traffic type.
+ * @param period The detected period of the traffic.
+ *
+ * @ingroup upperedge
+ */
+void unifi_ta_classification(card_t *card,
+ CsrWifiRouterCtrlTrafficType traffic_type,
+ u16 period);
+
+#endif
+/**
+ * Use software to hard reset the chip.
+ * This is a subset of the unifi_init_card() functionality and should
+ * only be used only to reset a paniced chip before a coredump is taken.
+ *
+ * @param card the HIP core context.
+ *
+ * @ingroup upperedge
+ */
+CsrResult unifi_card_hard_reset(card_t *card);
+
+
+CsrResult unifi_card_readn(card_t *card, u32 unifi_addr, void *pdata, u16 len);
+CsrResult unifi_card_read16(card_t *card, u32 unifi_addr, u16 *pdata);
+CsrResult unifi_card_write16(card_t *card, u32 unifi_addr, u16 data);
+
+
+enum unifi_dbg_processors_select
+{
+ UNIFI_PROC_MAC,
+ UNIFI_PROC_PHY,
+ UNIFI_PROC_BT,
+ UNIFI_PROC_BOTH,
+ UNIFI_PROC_INVALID
+};
+
+CsrResult unifi_card_stop_processor(card_t *card, enum unifi_dbg_processors_select which);
+
+/**
+ * Call-outs from the HIP core lib to the OS layer.
+ * The following functions need to be implemented during the porting exercise.
+ */
+
+/**
+ * Selects appropriate queue according to priority
+ * Helps maintain uniformity in queue selection between the HIP
+ * and the OS layers.
+ *
+ * @param priority priority of the packet
+ *
+ * @return \b Traffic queue to which a packet of this priority belongs
+ *
+ * @ingroup upperedge
+ */
+unifi_TrafficQueue
+unifi_frame_priority_to_queue(CSR_PRIORITY priority);
+
+/**
+ * Returns the priority corresponding to a particular Queue when that is used
+ * when downgrading a packet to a lower AC.
+ * Helps maintain uniformity in queue - priority mapping between the HIP
+ * and the OS layers.
+ *
+ * @param queue
+ *
+ * @return \b Highest priority corresponding to this queue
+ *
+ * @ingroup upperedge
+ */
+CSR_PRIORITY unifi_get_default_downgrade_priority(unifi_TrafficQueue queue);
+
+/**
+ *
+ * Flow control callbacks.
+ * unifi_pause_xmit() is called when the HIP core lib does not have any
+ * resources to store data packets. The OS layer needs to pause
+ * the Tx data plane until unifi_restart_xmit() is called.
+ *
+ * @param ospriv the OS layer context.
+ *
+ * @ingroup upperedge
+ */
+void unifi_pause_xmit(void *ospriv, unifi_TrafficQueue queue);
+void unifi_restart_xmit(void *ospriv, unifi_TrafficQueue queue);
+
+/**
+ *
+ * Request to run the Bottom-Half.
+ * The HIP core lib calls this function to request that unifi_bh()
+ * needs to be run by the OS layer. It can be called anytime, i.e.
+ * when the unifi_bh() is running.
+ * Since unifi_bh() is not re-entrant, usually unifi_run_bh() sets
+ * an event to a thread that schedules a call to unifi_bh().
+ *
+ * @param ospriv the OS layer context.
+ *
+ * @ingroup upperedge
+ */
+CsrResult unifi_run_bh(void *ospriv);
+
+/**
+ *
+ * Delivers a signal received from UniFi to the OS layer.
+ * Normally, the data signals should be delivered to the data plane
+ * and all the rest to the SME (unifi_sys_hip_ind()).
+ *
+ * Note that the OS layer is responsible for freeing the bulkdata
+ * buffers, using unifi_net_data_free().
+ *
+ * @param ospriv the OS layer context.
+ *
+ * @param sigptr pointer to the signal.
+ *
+ * @param siglen size of the signal.
+ *
+ * @param bulkdata pointer to the bulk data associated with the signal.
+ *
+ * @ingroup upperedge
+ */
+void unifi_receive_event(void *ospriv,
+ u8 *sigdata, u32 siglen,
+ const bulk_data_param_t *bulkdata);
+
+#ifdef CSR_WIFI_REQUEUE_PACKET_TO_HAL
+/**
+ *
+ * Used to reque the failed ma packet request back to hal queues
+ *
+ * @param ospriv the OS layer context.
+ *
+ * @param host_tag host tag for the packet to requeue.
+ *
+ * @param bulkDataDesc pointer to the bulk data.
+ *
+ * @ingroup upperedge
+ */
+CsrResult unifi_reque_ma_packet_request(void *ospriv, u32 host_tag,
+ u16 status,
+ bulk_data_desc_t *bulkDataDesc);
+
+#endif
+typedef struct
+{
+ u16 free_fh_sig_queue_slots[UNIFI_NO_OF_TX_QS];
+ u16 free_fh_bulkdata_slots;
+ u16 free_fh_fw_slots;
+} unifi_HipQosInfo;
+
+void unifi_get_hip_qos_info(card_t *card, unifi_HipQosInfo *hipqosinfo);
+
+
+/**
+ * Functions that read a portion of a firmware file.
+ *
+ * Note: If the UniFi chip runs the f/w from ROM, the HIP core may never
+ * call these functions. Also, the HIP core may call these functions even if
+ * a f/w file is not available. In this case, it is safe to fail the request.
+ */
+#define UNIFI_FW_STA 1 /* Identify STA firmware file */
+
+/**
+ *
+ * Ask the OS layer to initialise a read from a f/w file.
+ *
+ * @param ospriv the OS layer context.
+ *
+ * @param is_fw if 0 the request if for the loader file, if 1 the request
+ * is for a f/w file.
+ *
+ * @param info a card_info_t structure containing versions information.
+ * Note that some members of the structure may not be initialised.
+ *
+ * @return \p NULL if the file is not available, or a pointer which contains
+ * OS specific information for the file (typically the contents of the file)
+ * that the HIP core uses when calling unifi_fw_read() and unifi_fw_read_stop()
+ *
+ * @ingroup upperedge
+ */
+void* unifi_fw_read_start(void *ospriv, s8 is_fw, const card_info_t *info);
+
+/**
+ *
+ * Ask the OS layer to return a portion from a f/w file.
+ *
+ * @param ospriv the OS layer context.
+ *
+ * @param arg the OS pointer returned by unifi_fw_read_start().
+ *
+ * @param offset the offset in the f/w file to read the read from.
+ *
+ * @param buf the buffer to store the returned data.
+ *
+ * @param len the size in bytes of the requested read.
+ *
+ * @ingroup upperedge
+ */
+s32 unifi_fw_read(void *ospriv, void *arg, u32 offset, void *buf, u32 len);
+
+/**
+ *
+ * Ask the OS layer to finish reading from a f/w file.
+ *
+ * @param ospriv the OS layer context.
+ *
+ * @param dlpriv the OS pointer returned by unifi_fw_read_start().
+ *
+ * @ingroup upperedge
+ */
+void unifi_fw_read_stop(void *ospriv, void *dlpriv);
+
+/**
+ *
+ * Ask OS layer for a handle to a dynamically allocated firmware buffer
+ * (primarily intended for production test images which may need conversion)
+ *
+ * @param ospriv the OS layer context.
+ *
+ * @param fwbuf pointer to dynamically allocated buffer
+ *
+ * @param len length of provided buffer in bytes
+ *
+ * @ingroup upperedge
+ */
+void* unifi_fw_open_buffer(void *ospriv, void *fwbuf, u32 len);
+
+/**
+ *
+ * Release a handle to a dynamically allocated firmware buffer
+ * (primarily intended for production test images which may need conversion)
+ *
+ * @param ospriv the OS layer context.
+ *
+ * @param fwbuf pointer to dynamically allocated buffer
+ *
+ * @ingroup upperedge
+ */
+void unifi_fw_close_buffer(void *ospriv, void *fwbuf);
+
+#ifndef CSR_WIFI_HIP_TA_DISABLE
+/*
+ * Driver must provide these.
+ *
+ * A simple implementation will just call
+ * unifi_sys_traffic_protocol_ind() or unifi_sys_traffic_classification_ind()
+ * respectively. See sme_csr_userspace/sme_userspace.c.
+ */
+/**
+ *
+ * Indicates a detected packet of type packet_type.
+ * Typically, this information is processed by the SME so
+ * unifi_ta_indicate_protocol() needs to schedule a call to
+ * unifi_sys_traffic_protocol_ind().
+ *
+ * @param ospriv the OS layer context.
+ *
+ * @param packet_type the detected packet type.
+ *
+ * @param direction the direction of the packet (Rx, Tx).
+ *
+ * @param src_addr the source address of the packet.
+ *
+ * @ingroup upperedge
+ */
+void unifi_ta_indicate_protocol(void *ospriv,
+ CsrWifiRouterCtrlTrafficPacketType packet_type,
+ CsrWifiRouterCtrlProtocolDirection direction,
+ const CsrWifiMacAddress *src_addr);
+
+/**
+ *
+ * Indicates statistics for the sample data over a period.
+ * Typically, this information is processed by the SME so
+ * unifi_ta_indicate_sampling() needs to schedule a call to
+ * unifi_sys_traffic_sample_ind().
+ *
+ * @param ospriv the OS layer context.
+ *
+ * @param stats the pointer to the structure that contains the statistics.
+ *
+ * @ingroup upperedge
+ */
+void unifi_ta_indicate_sampling(void *ospriv, CsrWifiRouterCtrlTrafficStats *stats);
+void unifi_ta_indicate_l4stats(void *ospriv,
+ u32 rxTcpThroughput,
+ u32 txTcpThroughput,
+ u32 rxUdpThroughput,
+ u32 txUdpThroughput);
+#endif
+
+void unifi_rx_queue_flush(void *ospriv);
+
+/**
+ * Call-out from the SDIO glue layer.
+ *
+ * The glue layer needs to call unifi_sdio_interrupt_handler() every time
+ * an interrupts occurs.
+ *
+ * @param card the HIP core context.
+ *
+ * @ingroup bottomedge
+ */
+void unifi_sdio_interrupt_handler(card_t *card);
+
+
+/* HELPER FUNCTIONS */
+
+/*
+ * unifi_init() and unifi_download() implement a subset of unifi_init_card functionality
+ * that excludes HIP initialization.
+ */
+CsrResult unifi_init(card_t *card);
+CsrResult unifi_download(card_t *card, s32 led_mask);
+
+/*
+ * unifi_start_processors() ensures both on-chip processors are running
+ */
+CsrResult unifi_start_processors(card_t *card);
+
+CsrResult unifi_capture_panic(card_t *card);
+
+/*
+ * Configure HIP interrupt processing mode
+ */
+#define CSR_WIFI_INTMODE_DEFAULT 0
+#define CSR_WIFI_INTMODE_RUN_BH_ONCE 1 /* Run BH once per interrupt */
+
+void unifi_set_interrupt_mode(card_t *card, u32 mode);
+
+/*
+ * unifi_request_max_clock() requests that max SDIO clock speed is set at the
+ * next suitable opportunity.
+ */
+void unifi_request_max_sdio_clock(card_t *card);
+
+
+/* Functions to lookup bulk data command names. */
+const char* lookup_bulkcmd_name(u16 id);
+
+/* Function to log HIP's global debug buffer */
+#ifdef CSR_WIFI_HIP_DEBUG_OFFLINE
+void unifi_debug_buf_dump(void);
+void unifi_debug_log_to_buf(const char *fmt, ...);
+void unifi_debug_hex_to_buf(const char *buff, u16 length);
+#endif
+
+/* Mini-coredump utility functions */
+CsrResult unifi_coredump_get_value(card_t *card, struct unifi_coredump_req *req);
+CsrResult unifi_coredump_capture(card_t *card, struct unifi_coredump_req *req);
+CsrResult unifi_coredump_request_at_next_reset(card_t *card, s8 enable);
+CsrResult unifi_coredump_init(card_t *card, u16 num_dump_buffers);
+void unifi_coredump_free(card_t *card);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __CSR_WIFI_HIP_UNIFI_H__ */
diff --git a/drivers/staging/csr/csr_wifi_hip_unifi_signal_names.c b/drivers/staging/csr/csr_wifi_hip_unifi_signal_names.c
new file mode 100644
index 000000000000..7c13df295c11
--- /dev/null
+++ b/drivers/staging/csr/csr_wifi_hip_unifi_signal_names.c
@@ -0,0 +1,46 @@
+/*****************************************************************************
+
+ (c) Cambridge Silicon Radio Limited 2011
+ All rights reserved and confidential information of CSR
+
+ Refer to LICENSE.txt included with this source for details
+ on the license terms.
+
+*****************************************************************************/
+
+#include "csr_wifi_hip_unifi.h"
+
+struct sig_name
+{
+ s16 id;
+ const char *name;
+};
+
+static const struct sig_name Unifi_bulkcmd_names[] = {
+ { 0, "SignalCmd" },
+ { 1, "CopyToHost" },
+ { 2, "CopyToHostAck" },
+ { 3, "CopyFromHost" },
+ { 4, "CopyFromHostAck" },
+ { 5, "ClearSlot" },
+ { 6, "CopyOverlay" },
+ { 7, "CopyOverlayAck" },
+ { 8, "CopyFromHostAndClearSlot" },
+ { 15, "Padding" }
+};
+
+const char* lookup_bulkcmd_name(u16 id)
+{
+ if (id < 9)
+ {
+ return Unifi_bulkcmd_names[id].name;
+ }
+ if (id == 15)
+ {
+ return "Padding";
+ }
+
+ return "UNKNOWN";
+}
+
+
diff --git a/drivers/staging/csr/csr_wifi_hip_unifi_udi.h b/drivers/staging/csr/csr_wifi_hip_unifi_udi.h
new file mode 100644
index 000000000000..83032d0b4ec9
--- /dev/null
+++ b/drivers/staging/csr/csr_wifi_hip_unifi_udi.h
@@ -0,0 +1,76 @@
+/*****************************************************************************
+
+ (c) Cambridge Silicon Radio Limited 2011
+ All rights reserved and confidential information of CSR
+
+ Refer to LICENSE.txt included with this source for details
+ on the license terms.
+
+*****************************************************************************/
+
+/*
+ * ---------------------------------------------------------------------------
+ * FILE: csr_wifi_hip_unifi_udi.h
+ *
+ * PURPOSE:
+ * Declarations and definitions for the UniFi Debug Interface.
+ *
+ * ---------------------------------------------------------------------------
+ */
+#ifndef __CSR_WIFI_HIP_UNIFI_UDI_H__
+#define __CSR_WIFI_HIP_UNIFI_UDI_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include "csr_wifi_hip_unifi.h"
+#include "csr_wifi_hip_signals.h"
+
+
+/*
+ * Support for tracing the wire protocol.
+ */
+enum udi_log_direction
+{
+ UDI_LOG_FROM_HOST = 0x0000,
+ UDI_LOG_TO_HOST = 0x0001
+};
+
+typedef void (*udi_func_t)(void *ospriv, u8 *sigdata,
+ u32 signal_len,
+ const bulk_data_param_t *bulkdata,
+ enum udi_log_direction dir);
+
+CsrResult unifi_set_udi_hook(card_t *card, udi_func_t udi_fn);
+CsrResult unifi_remove_udi_hook(card_t *card, udi_func_t udi_fn);
+
+
+/*
+ * Function to print current status info to a string.
+ * This is used in the linux /proc interface and might be useful
+ * in other systems.
+ */
+s32 unifi_print_status(card_t *card, char *str, s32 *remain);
+
+#define UNIFI_SNPRINTF_RET(buf_p, remain, written) \
+ do { \
+ if (written >= remain) { \
+ if (remain >= 2) { \
+ buf_p[remain - 2] = '\n'; \
+ buf_p[remain - 1] = 0; \
+ } \
+ buf_p += remain; \
+ remain = 0; \
+ } else if (written > 0) { \
+ buf_p += written; \
+ remain -= written; \
+ } \
+ } while (0)
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __CSR_WIFI_HIP_UNIFI_UDI_H__ */
diff --git a/drivers/staging/csr/csr_wifi_hip_unifihw.h b/drivers/staging/csr/csr_wifi_hip_unifihw.h
new file mode 100644
index 000000000000..5ffd6ba38d3b
--- /dev/null
+++ b/drivers/staging/csr/csr_wifi_hip_unifihw.h
@@ -0,0 +1,67 @@
+/*****************************************************************************
+
+ (c) Cambridge Silicon Radio Limited 2011
+ All rights reserved and confidential information of CSR
+
+ Refer to LICENSE.txt included with this source for details
+ on the license terms.
+
+*****************************************************************************/
+
+/*
+ * ---------------------------------------------------------------------------
+ *
+ * File: csr_wifi_hip_unifihw.h
+ *
+ * Definitions of various chip registers, addresses, values etc.
+ *
+ * ---------------------------------------------------------------------------
+ */
+#ifndef __UNIFIHW_H__
+#define __UNIFIHW_H__ 1
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Symbol Look Up Table fingerprint. IDs are in sigs.h */
+#define SLUT_FINGERPRINT 0xD397
+
+
+/* Values of LoaderOperation */
+#define UNIFI_LOADER_IDLE 0x00
+#define UNIFI_LOADER_COPY 0x01
+#define UNIFI_LOADER_ERROR_MASK 0xF0
+
+/* Values of BootLoaderOperation */
+#define UNIFI_BOOT_LOADER_IDLE 0x00
+#define UNIFI_BOOT_LOADER_RESTART 0x01
+#define UNIFI_BOOT_LOADER_PATCH 0x02
+#define UNIFI_BOOT_LOADER_LOAD_STA 0x10
+#define UNIFI_BOOT_LOADER_LOAD_PTEST 0x11
+
+
+/* Memory spaces encoded in top byte of Generic Pointer type */
+#define UNIFI_SH_DMEM 0x01 /* Shared Data Memory */
+#define UNIFI_EXT_FLASH 0x02 /* External FLASH */
+#define UNIFI_EXT_SRAM 0x03 /* External SRAM */
+#define UNIFI_REGISTERS 0x04 /* Registers */
+#define UNIFI_PHY_DMEM 0x10 /* PHY Data Memory */
+#define UNIFI_PHY_PMEM 0x11 /* PHY Program Memory */
+#define UNIFI_PHY_ROM 0x12 /* PHY ROM */
+#define UNIFI_MAC_DMEM 0x20 /* MAC Data Memory */
+#define UNIFI_MAC_PMEM 0x21 /* MAC Program Memory */
+#define UNIFI_MAC_ROM 0x22 /* MAC ROM */
+#define UNIFI_BT_DMEM 0x30 /* BT Data Memory */
+#define UNIFI_BT_PMEM 0x31 /* BT Program Memory */
+#define UNIFI_BT_ROM 0x32 /* BT ROM */
+
+#define UNIFI_MAKE_GP(R, O) (((UNIFI_ ## R) << 24) | (O))
+#define UNIFI_GP_OFFSET(GP) ((GP) & 0xFFFFFF)
+#define UNIFI_GP_SPACE(GP) (((GP) >> 24) & 0xFF)
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __UNIFIHW_H__ */
diff --git a/drivers/staging/csr/csr_wifi_hip_unifiversion.h b/drivers/staging/csr/csr_wifi_hip_unifiversion.h
new file mode 100644
index 000000000000..e1fdbb27a463
--- /dev/null
+++ b/drivers/staging/csr/csr_wifi_hip_unifiversion.h
@@ -0,0 +1,38 @@
+/*****************************************************************************
+
+ (c) Cambridge Silicon Radio Limited 2011
+ All rights reserved and confidential information of CSR
+
+ Refer to LICENSE.txt included with this source for details
+ on the license terms.
+
+*****************************************************************************/
+
+/*
+ * ---------------------------------------------------------------------------
+ * FILE: unifiversion.h
+ *
+ * PURPOSE:
+ * Version information for the portable UniFi driver.
+ *
+ * ---------------------------------------------------------------------------
+ */
+
+#ifndef __UNIFIVERSION_H__
+#define __UNIFIVERSION_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ * The minimum version of Host Interface Protocol required by the driver.
+ */
+#define UNIFI_HIP_MAJOR_VERSION 9
+#define UNIFI_HIP_MINOR_VERSION 1
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __UNIFIVERSION_H__ */
diff --git a/drivers/staging/csr/csr_wifi_hip_xbv.c b/drivers/staging/csr/csr_wifi_hip_xbv.c
new file mode 100644
index 000000000000..071f80a49f19
--- /dev/null
+++ b/drivers/staging/csr/csr_wifi_hip_xbv.c
@@ -0,0 +1,1076 @@
+/*****************************************************************************
+
+ (c) Cambridge Silicon Radio Limited 2012
+ All rights reserved and confidential information of CSR
+
+ Refer to LICENSE.txt included with this source for details
+ on the license terms.
+
+*****************************************************************************/
+
+/*
+ * ---------------------------------------------------------------------------
+ * FILE: csr_wifi_hip_xbv.c
+ *
+ * PURPOSE:
+ * Routines for downloading firmware to UniFi.
+ *
+ * UniFi firmware files use a nested TLV (Tag-Length-Value) format.
+ *
+ * ---------------------------------------------------------------------------
+ */
+#include <linux/slab.h>
+
+#ifdef CSR_WIFI_XBV_TEST
+/* Standalone test harness */
+#include "unifi_xbv.h"
+#include "csr_wifi_hip_unifihw.h"
+#else
+/* Normal driver build */
+#include "csr_wifi_hip_unifiversion.h"
+#include "csr_wifi_hip_card.h"
+#define DBG_TAG(t)
+#endif
+
+#include "csr_wifi_hip_xbv.h"
+
+#define STREAM_CHECKSUM 0x6d34 /* Sum of uint16s in each patch stream */
+
+/* XBV sizes used in patch conversion
+ */
+#define PTDL_MAX_SIZE 2048 /* Max bytes allowed per PTDL */
+#define PTDL_HDR_SIZE (4 + 2 + 6 + 2) /* sizeof(fw_id, sec_len, patch_cmd, csum) */
+
+/* Struct to represent a buffer for reading firmware file */
+
+typedef struct
+{
+ void *dlpriv;
+ s32 ioffset;
+ fwreadfn_t iread;
+} ct_t;
+
+/* Struct to represent a TLV field */
+typedef struct
+{
+ char t_name[4];
+ u32 t_len;
+} tag_t;
+
+
+#define TAG_EQ(i, v) (((i)[0] == (v)[0]) && \
+ ((i)[1] == (v)[1]) && \
+ ((i)[2] == (v)[2]) && \
+ ((i)[3] == (v)[3]))
+
+/* We create a small stack on the stack that contains an enum
+ * indicating the containing list segments, and the offset at which
+ * those lists end. This enables a lot more error checking. */
+typedef enum
+{
+ xbv_xbv1,
+ /*xbv_info,*/
+ xbv_fw,
+ xbv_vers,
+ xbv_vand,
+ xbv_ptch,
+ xbv_other
+} xbv_container;
+
+#define XBV_STACK_SIZE 6
+#define XBV_MAX_OFFS 0x7fffffff
+
+typedef struct
+{
+ struct
+ {
+ xbv_container container;
+ s32 ioffset_end;
+ } s[XBV_STACK_SIZE];
+ u32 ptr;
+} xbv_stack_t;
+
+static s32 read_tag(card_t *card, ct_t *ct, tag_t *tag);
+static s32 read_bytes(card_t *card, ct_t *ct, void *buf, u32 len);
+static s32 read_uint(card_t *card, ct_t *ct, u32 *u, u32 len);
+static s32 xbv_check(xbv1_t *fwinfo, const xbv_stack_t *stack,
+ xbv_mode new_mode, xbv_container old_cont);
+static s32 xbv_push(xbv1_t *fwinfo, xbv_stack_t *stack,
+ xbv_mode new_mode, xbv_container old_cont,
+ xbv_container new_cont, u32 ioff);
+
+static u32 write_uint16(void *buf, const u32 offset,
+ const u16 val);
+static u32 write_uint32(void *buf, const u32 offset,
+ const u32 val);
+static u32 write_bytes(void *buf, const u32 offset,
+ const u8 *data, const u32 len);
+static u32 write_tag(void *buf, const u32 offset,
+ const char *tag_str);
+static u32 write_chunk(void *buf, const u32 offset,
+ const char *tag_str,
+ const u32 payload_len);
+static u16 calc_checksum(void *buf, const u32 offset,
+ const u32 bytes_len);
+static u32 calc_patch_size(const xbv1_t *fwinfo);
+
+static u32 write_xbv_header(void *buf, const u32 offset,
+ const u32 file_payload_length);
+static u32 write_ptch_header(void *buf, const u32 offset,
+ const u32 fw_id);
+static u32 write_patchcmd(void *buf, const u32 offset,
+ const u32 dst_genaddr, const u16 len);
+static u32 write_reset_ptdl(void *buf, const u32 offset,
+ const xbv1_t *fwinfo, u32 fw_id);
+static u32 write_fwdl_to_ptdl(void *buf, const u32 offset,
+ fwreadfn_t readfn, const struct FWDL *fwdl,
+ const void *fw_buf, const u32 fw_id,
+ void *rdbuf);
+
+/*
+ * ---------------------------------------------------------------------------
+ * parse_xbv1
+ *
+ * Scan the firmware file to find the TLVs we are interested in.
+ * Actions performed:
+ * - check we support the file format version in VERF
+ * Store these TLVs if we have a firmware image:
+ * - SLTP Symbol Lookup Table Pointer
+ * - FWDL firmware download segments
+ * - FWOL firmware overlay segment
+ * - VMEQ Register probe tests to verify matching h/w
+ * Store these TLVs if we have a patch file:
+ * - FWID the firmware build ID that this file patches
+ * - PTDL The actual patches
+ *
+ * The structure pointed to by fwinfo is cleared and
+ * 'fwinfo->mode' is set to 'unknown'. The 'fwinfo->mode'
+ * variable is set to 'firmware' or 'patch' once we know which
+ * sort of XBV file we have.
+ *
+ * Arguments:
+ * readfn Pointer to function to call to read from the file.
+ * dlpriv Opaque pointer arg to pass to readfn.
+ * fwinfo Pointer to fwinfo struct to fill in.
+ *
+ * Returns:
+ * CSR_RESULT_SUCCESS on success, CSR error code on failure
+ * ---------------------------------------------------------------------------
+ */
+CsrResult xbv1_parse(card_t *card, fwreadfn_t readfn, void *dlpriv, xbv1_t *fwinfo)
+{
+ ct_t ct;
+ tag_t tag;
+ xbv_stack_t stack;
+
+ ct.dlpriv = dlpriv;
+ ct.ioffset = 0;
+ ct.iread = readfn;
+
+ memset(fwinfo, 0, sizeof(xbv1_t));
+ fwinfo->mode = xbv_unknown;
+
+ /* File must start with XBV1 triplet */
+ if (read_tag(card, &ct, &tag) <= 0)
+ {
+ unifi_error(NULL, "File is not UniFi firmware\n");
+ return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
+ }
+
+ DBG_TAG(tag.t_name);
+
+ if (!TAG_EQ(tag.t_name, "XBV1"))
+ {
+ unifi_error(NULL, "File is not UniFi firmware (%s)\n", tag.t_name);
+ return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
+ }
+
+ stack.ptr = 0;
+ stack.s[stack.ptr].container = xbv_xbv1;
+ stack.s[stack.ptr].ioffset_end = XBV_MAX_OFFS;
+
+ /* Now scan the file */
+ while (1)
+ {
+ s32 n;
+
+ n = read_tag(card, &ct, &tag);
+ if (n < 0)
+ {
+ unifi_error(NULL, "No tag\n");
+ return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
+ }
+ if (n == 0)
+ {
+ /* End of file */
+ break;
+ }
+
+ DBG_TAG(tag.t_name);
+
+ /* File format version */
+ if (TAG_EQ(tag.t_name, "VERF"))
+ {
+ u32 version;
+
+ if (xbv_check(fwinfo, &stack, xbv_unknown, xbv_xbv1) ||
+ (tag.t_len != 2) ||
+ read_uint(card, &ct, &version, 2))
+ {
+ return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
+ }
+ if (version != 0)
+ {
+ unifi_error(NULL, "Unsupported firmware file version: %d.%d\n",
+ version >> 8, version & 0xFF);
+ return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
+ }
+ }
+ else if (TAG_EQ(tag.t_name, "LIST"))
+ {
+ char name[4];
+ u32 list_end;
+
+ list_end = ct.ioffset + tag.t_len;
+
+ if (read_bytes(card, &ct, name, 4))
+ {
+ return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
+ }
+
+ DBG_TAG(name);
+ if (TAG_EQ(name, "FW "))
+ {
+ if (xbv_push(fwinfo, &stack, xbv_firmware, xbv_xbv1, xbv_fw, list_end))
+ {
+ return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
+ }
+ }
+ else if (TAG_EQ(name, "VERS"))
+ {
+ if (xbv_push(fwinfo, &stack, xbv_firmware, xbv_fw, xbv_vers, list_end) ||
+ (fwinfo->vers.num_vand != 0))
+ {
+ return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
+ }
+ }
+ else if (TAG_EQ(name, "VAND"))
+ {
+ struct VAND *vand;
+
+ if (xbv_push(fwinfo, &stack, xbv_firmware, xbv_vers, xbv_vand, list_end) ||
+ (fwinfo->vers.num_vand >= MAX_VAND))
+ {
+ return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
+ }
+
+ /* Get a new VAND */
+ vand = fwinfo->vand + fwinfo->vers.num_vand++;
+
+ /* Fill it in */
+ vand->first = fwinfo->num_vmeq;
+ vand->count = 0;
+ }
+ else if (TAG_EQ(name, "PTCH"))
+ {
+ if (xbv_push(fwinfo, &stack, xbv_patch, xbv_xbv1, xbv_ptch, list_end))
+ {
+ return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
+ }
+ }
+ else
+ {
+ /* Skip over any other lists. We dont bother to push
+ * the new list type now as we would only pop it at
+ * the end of the outer loop. */
+ ct.ioffset += tag.t_len - 4;
+ }
+ }
+ else if (TAG_EQ(tag.t_name, "SLTP"))
+ {
+ u32 addr;
+
+ if (xbv_check(fwinfo, &stack, xbv_firmware, xbv_fw) ||
+ (tag.t_len != 4) ||
+ (fwinfo->slut_addr != 0) ||
+ read_uint(card, &ct, &addr, 4))
+ {
+ return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
+ }
+
+ fwinfo->slut_addr = addr;
+ }
+ else if (TAG_EQ(tag.t_name, "FWDL"))
+ {
+ u32 addr;
+ struct FWDL *fwdl;
+
+ if (xbv_check(fwinfo, &stack, xbv_firmware, xbv_fw) ||
+ (fwinfo->num_fwdl >= MAX_FWDL) ||
+ (read_uint(card, &ct, &addr, 4)))
+ {
+ return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
+ }
+
+ fwdl = fwinfo->fwdl + fwinfo->num_fwdl++;
+
+ fwdl->dl_size = tag.t_len - 4;
+ fwdl->dl_addr = addr;
+ fwdl->dl_offset = ct.ioffset;
+
+ ct.ioffset += tag.t_len - 4;
+ }
+ else if (TAG_EQ(tag.t_name, "FWOV"))
+ {
+ if (xbv_check(fwinfo, &stack, xbv_firmware, xbv_fw) ||
+ (fwinfo->fwov.dl_size != 0) ||
+ (fwinfo->fwov.dl_offset != 0))
+ {
+ return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
+ }
+
+ fwinfo->fwov.dl_size = tag.t_len;
+ fwinfo->fwov.dl_offset = ct.ioffset;
+
+ ct.ioffset += tag.t_len;
+ }
+ else if (TAG_EQ(tag.t_name, "VMEQ"))
+ {
+ u32 temp[3];
+ struct VAND *vand;
+ struct VMEQ *vmeq;
+
+ if (xbv_check(fwinfo, &stack, xbv_firmware, xbv_vand) ||
+ (fwinfo->num_vmeq >= MAX_VMEQ) ||
+ (fwinfo->vers.num_vand == 0) ||
+ (tag.t_len != 8) ||
+ read_uint(card, &ct, &temp[0], 4) ||
+ read_uint(card, &ct, &temp[1], 2) ||
+ read_uint(card, &ct, &temp[2], 2))
+ {
+ return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
+ }
+
+ /* Get the last VAND */
+ vand = fwinfo->vand + (fwinfo->vers.num_vand - 1);
+
+ /* Get a new VMEQ */
+ vmeq = fwinfo->vmeq + fwinfo->num_vmeq++;
+
+ /* Note that this VAND contains another VMEQ */
+ vand->count++;
+
+ /* Fill in the VMEQ */
+ vmeq->addr = temp[0];
+ vmeq->mask = (u16)temp[1];
+ vmeq->value = (u16)temp[2];
+ }
+ else if (TAG_EQ(tag.t_name, "FWID"))
+ {
+ u32 build_id;
+
+ if (xbv_check(fwinfo, &stack, xbv_patch, xbv_ptch) ||
+ (tag.t_len != 4) ||
+ (fwinfo->build_id != 0) ||
+ read_uint(card, &ct, &build_id, 4))
+ {
+ return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
+ }
+
+ fwinfo->build_id = build_id;
+ }
+ else if (TAG_EQ(tag.t_name, "PTDL"))
+ {
+ struct PTDL *ptdl;
+
+ if (xbv_check(fwinfo, &stack, xbv_patch, xbv_ptch) ||
+ (fwinfo->num_ptdl >= MAX_PTDL))
+ {
+ return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
+ }
+
+ /* Allocate a new PTDL */
+ ptdl = fwinfo->ptdl + fwinfo->num_ptdl++;
+
+ ptdl->dl_size = tag.t_len;
+ ptdl->dl_offset = ct.ioffset;
+
+ ct.ioffset += tag.t_len;
+ }
+ else
+ {
+ /*
+ * If we get here it is a tag we are not interested in,
+ * just skip over it.
+ */
+ ct.ioffset += tag.t_len;
+ }
+
+ /* Check to see if we are at the end of the currently stacked
+ * segment. We could finish more than one list at a time. */
+ while (ct.ioffset >= stack.s[stack.ptr].ioffset_end)
+ {
+ if (ct.ioffset > stack.s[stack.ptr].ioffset_end)
+ {
+ unifi_error(NULL,
+ "XBV file has overrun stack'd segment %d (%d > %d)\n",
+ stack.ptr, ct.ioffset, stack.s[stack.ptr].ioffset_end);
+ return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
+ }
+ if (stack.ptr <= 0)
+ {
+ unifi_error(NULL, "XBV file has underrun stack pointer\n");
+ return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
+ }
+ stack.ptr--;
+ }
+ }
+
+ if (stack.ptr != 0)
+ {
+ unifi_error(NULL, "Last list of XBV is not complete.\n");
+ return CSR_WIFI_HIP_RESULT_INVALID_VALUE;
+ }
+
+ return CSR_RESULT_SUCCESS;
+} /* xbv1_parse() */
+
+
+/* Check the the XBV file is of a consistant sort (either firmware or
+ * patch) and that we are in the correct containing list type. */
+static s32 xbv_check(xbv1_t *fwinfo, const xbv_stack_t *stack,
+ xbv_mode new_mode, xbv_container old_cont)
+{
+ /* If the new file mode is unknown the current packet could be in
+ * either (any) type of XBV file, and we cant make a decission at
+ * this time. */
+ if (new_mode != xbv_unknown)
+ {
+ if (fwinfo->mode == xbv_unknown)
+ {
+ fwinfo->mode = new_mode;
+ }
+ else if (fwinfo->mode != new_mode)
+ {
+ return -1;
+ }
+ }
+ /* If the current stack top doesn't match what we expect then the
+ * file is corrupt. */
+ if (stack->s[stack->ptr].container != old_cont)
+ {
+ return -1;
+ }
+ return 0;
+}
+
+
+/* Make checks as above and then enter a new list */
+static s32 xbv_push(xbv1_t *fwinfo, xbv_stack_t *stack,
+ xbv_mode new_mode, xbv_container old_cont,
+ xbv_container new_cont, u32 new_ioff)
+{
+ if (xbv_check(fwinfo, stack, new_mode, old_cont))
+ {
+ return -1;
+ }
+
+ /* Check that our stack won't overflow. */
+ if (stack->ptr >= (XBV_STACK_SIZE - 1))
+ {
+ return -1;
+ }
+
+ /* Add the new list element to the top of the stack. */
+ stack->ptr++;
+ stack->s[stack->ptr].container = new_cont;
+ stack->s[stack->ptr].ioffset_end = new_ioff;
+
+ return 0;
+}
+
+
+static u32 xbv2uint(u8 *ptr, s32 len)
+{
+ u32 u = 0;
+ s16 i;
+
+ for (i = 0; i < len; i++)
+ {
+ u32 b;
+ b = ptr[i];
+ u += b << (i * 8);
+ }
+ return u;
+}
+
+
+static s32 read_tag(card_t *card, ct_t *ct, tag_t *tag)
+{
+ u8 buf[8];
+ s32 n;
+
+ n = (*ct->iread)(card->ospriv, ct->dlpriv, ct->ioffset, buf, 8);
+ if (n <= 0)
+ {
+ return n;
+ }
+
+ /* read the tag and length */
+ if (n != 8)
+ {
+ return -1;
+ }
+
+ /* get section tag */
+ memcpy(tag->t_name, buf, 4);
+
+ /* get section length */
+ tag->t_len = xbv2uint(buf + 4, 4);
+
+ ct->ioffset += 8;
+
+ return 8;
+} /* read_tag() */
+
+
+static s32 read_bytes(card_t *card, ct_t *ct, void *buf, u32 len)
+{
+ /* read the tag value */
+ if ((*ct->iread)(card->ospriv, ct->dlpriv, ct->ioffset, buf, len) != (s32)len)
+ {
+ return -1;
+ }
+
+ ct->ioffset += len;
+
+ return 0;
+} /* read_bytes() */
+
+
+static s32 read_uint(card_t *card, ct_t *ct, u32 *u, u32 len)
+{
+ u8 buf[4];
+
+ /* Integer cannot be more than 4 bytes */
+ if (len > 4)
+ {
+ return -1;
+ }
+
+ if (read_bytes(card, ct, buf, len))
+ {
+ return -1;
+ }
+
+ *u = xbv2uint(buf, len);
+
+ return 0;
+} /* read_uint() */
+
+
+static u32 write_uint16(void *buf, const u32 offset, const u16 val)
+{
+ u8 *dst = (u8 *)buf + offset;
+ *dst++ = (u8)(val & 0xff); /* LSB first */
+ *dst = (u8)(val >> 8);
+ return sizeof(u16);
+}
+
+
+static u32 write_uint32(void *buf, const u32 offset, const u32 val)
+{
+ (void)write_uint16(buf, offset + 0, (u16)(val & 0xffff));
+ (void)write_uint16(buf, offset + 2, (u16)(val >> 16));
+ return sizeof(u32);
+}
+
+
+static u32 write_bytes(void *buf, const u32 offset, const u8 *data, const u32 len)
+{
+ u32 i;
+ u8 *dst = (u8 *)buf + offset;
+
+ for (i = 0; i < len; i++)
+ {
+ *dst++ = *((u8 *)data + i);
+ }
+ return len;
+}
+
+
+static u32 write_tag(void *buf, const u32 offset, const char *tag_str)
+{
+ u8 *dst = (u8 *)buf + offset;
+ memcpy(dst, tag_str, 4);
+ return 4;
+}
+
+
+static u32 write_chunk(void *buf, const u32 offset, const char *tag_str, const u32 payload_len)
+{
+ u32 written = 0;
+ written += write_tag(buf, offset, tag_str);
+ written += write_uint32(buf, written + offset, (u32)payload_len);
+
+ return written;
+}
+
+
+static u16 calc_checksum(void *buf, const u32 offset, const u32 bytes_len)
+{
+ u32 i;
+ u8 *src = (u8 *)buf + offset;
+ u16 sum = 0;
+ u16 val;
+
+ for (i = 0; i < bytes_len / 2; i++)
+ {
+ /* Contents copied to file is LE, host might not be */
+ val = (u16) * src++; /* LSB */
+ val += (u16)(*src++) << 8; /* MSB */
+ sum += val;
+ }
+
+ /* Total of uint16s in the stream plus the stored check value
+ * should equal STREAM_CHECKSUM when decoded.
+ */
+ return (STREAM_CHECKSUM - sum);
+}
+
+
+#define PTDL_RESET_DATA_SIZE 20 /* Size of reset vectors PTDL */
+
+static u32 calc_patch_size(const xbv1_t *fwinfo)
+{
+ s16 i;
+ u32 size = 0;
+
+ /*
+ * Work out how big an equivalent patch format file must be for this image.
+ * This only needs to be approximate, so long as it's large enough.
+ */
+ if (fwinfo->mode != xbv_firmware)
+ {
+ return 0;
+ }
+
+ /* Payload (which will get put into a series of PTDLs) */
+ for (i = 0; i < fwinfo->num_fwdl; i++)
+ {
+ size += fwinfo->fwdl[i].dl_size;
+ }
+
+ /* Another PTDL at the end containing reset vectors */
+ size += PTDL_RESET_DATA_SIZE;
+
+ /* PTDL headers. Add one for remainder, one for reset vectors */
+ size += ((fwinfo->num_fwdl / PTDL_MAX_SIZE) + 2) * PTDL_HDR_SIZE;
+
+ /* Another 1K sufficient to cover miscellaneous headers */
+ size += 1024;
+
+ return size;
+}
+
+
+static u32 write_xbv_header(void *buf, const u32 offset, const u32 file_payload_length)
+{
+ u32 written = 0;
+
+ /* The length value given to the XBV chunk is the length of all subsequent
+ * contents of the file, excluding the 8 byte size of the XBV1 header itself
+ * (The added 6 bytes thus accounts for the size of the VERF)
+ */
+ written += write_chunk(buf, offset + written, (char *)"XBV1", file_payload_length + 6);
+
+ written += write_chunk(buf, offset + written, (char *)"VERF", 2);
+ written += write_uint16(buf, offset + written, 0); /* File version */
+
+ return written;
+}
+
+
+static u32 write_ptch_header(void *buf, const u32 offset, const u32 fw_id)
+{
+ u32 written = 0;
+
+ /* LIST is written with a zero length, to be updated later */
+ written += write_chunk(buf, offset + written, (char *)"LIST", 0);
+ written += write_tag(buf, offset + written, (char *)"PTCH"); /* List type */
+
+ written += write_chunk(buf, offset + written, (char *)"FWID", 4);
+ written += write_uint32(buf, offset + written, fw_id);
+
+
+ return written;
+}
+
+
+#define UF_REGION_PHY 1
+#define UF_REGION_MAC 2
+#define UF_MEMPUT_MAC 0x0000
+#define UF_MEMPUT_PHY 0x1000
+
+static u32 write_patchcmd(void *buf, const u32 offset, const u32 dst_genaddr, const u16 len)
+{
+ u32 written = 0;
+ u32 region = (dst_genaddr >> 28);
+ u16 cmd_and_len = UF_MEMPUT_MAC;
+
+ if (region == UF_REGION_PHY)
+ {
+ cmd_and_len = UF_MEMPUT_PHY;
+ }
+ else if (region != UF_REGION_MAC)
+ {
+ return 0; /* invalid */
+ }
+
+ /* Write the command and data length */
+ cmd_and_len |= len;
+ written += write_uint16(buf, offset + written, cmd_and_len);
+
+ /* Write the destination generic address */
+ written += write_uint16(buf, offset + written, (u16)(dst_genaddr >> 16));
+ written += write_uint16(buf, offset + written, (u16)(dst_genaddr & 0xffff));
+
+ /* The data payload should be appended to the command */
+ return written;
+}
+
+
+static u32 write_fwdl_to_ptdl(void *buf, const u32 offset, fwreadfn_t readfn,
+ const struct FWDL *fwdl, const void *dlpriv,
+ const u32 fw_id, void *fw_buf)
+{
+ u32 written = 0;
+ s16 chunks = 0;
+ u32 left = fwdl->dl_size; /* Bytes left in this fwdl */
+ u32 dl_addr = fwdl->dl_addr; /* Target address of fwdl image on XAP */
+ u32 dl_offs = fwdl->dl_offset; /* Offset of fwdl image data in source */
+ u16 csum;
+ u32 csum_start_offs; /* first offset to include in checksum */
+ u32 sec_data_len; /* section data byte count */
+ u32 sec_len; /* section data + header byte count */
+
+ /* FWDL maps to one or more PTDLs, as max size for a PTDL is 1K words */
+ while (left)
+ {
+ /* Calculate amount to be transferred */
+ sec_data_len = CSRMIN(left, PTDL_MAX_SIZE - PTDL_HDR_SIZE);
+ sec_len = sec_data_len + PTDL_HDR_SIZE;
+
+ /* Write PTDL header + entire PTDL size */
+ written += write_chunk(buf, offset + written, (char *)"PTDL", sec_len);
+ /* bug digest implies 4 bytes of padding here, but that seems wrong */
+
+ /* Checksum starts here */
+ csum_start_offs = offset + written;
+
+ /* Patch-chunk header: fw_id. Note that this is in XAP word order */
+ written += write_uint16(buf, offset + written, (u16)(fw_id >> 16));
+ written += write_uint16(buf, offset + written, (u16)(fw_id & 0xffff));
+
+ /* Patch-chunk header: section length in uint16s */
+ written += write_uint16(buf, offset + written, (u16)(sec_len / 2));
+
+
+ /* Write the appropriate patch command for the data's destination ptr */
+ written += write_patchcmd(buf, offset + written, dl_addr, (u16)(sec_data_len / 2));
+
+ /* Write the data itself (limited to the max chunk length) */
+ if (readfn(NULL, (void *)dlpriv, dl_offs, fw_buf, sec_data_len) < 0)
+ {
+ return 0;
+ }
+
+ written += write_bytes(buf,
+ offset + written,
+ fw_buf,
+ sec_data_len);
+
+ /* u16 checksum calculated over data written */
+ csum = calc_checksum(buf, csum_start_offs, written - (csum_start_offs - offset));
+ written += write_uint16(buf, offset + written, csum);
+
+ left -= sec_data_len;
+ dl_addr += sec_data_len;
+ dl_offs += sec_data_len;
+ chunks++;
+ }
+
+ return written;
+}
+
+
+#define SEC_CMD_LEN ((4 + 2) * 2) /* sizeof(cmd, vector) per XAP */
+#define PTDL_VEC_HDR_SIZE (4 + 2 + 2) /* sizeof(fw_id, sec_len, csum) */
+#define UF_MAC_START_VEC 0x00c00000 /* Start address of image on MAC */
+#define UF_PHY_START_VEC 0x00c00000 /* Start address of image on PHY */
+#define UF_MAC_START_CMD 0x6000 /* MAC "Set start address" command */
+#define UF_PHY_START_CMD 0x7000 /* PHY "Set start address" command */
+
+static u32 write_reset_ptdl(void *buf, const u32 offset, const xbv1_t *fwinfo, u32 fw_id)
+{
+ u32 written = 0;
+ u16 csum;
+ u32 csum_start_offs; /* first offset to include in checksum */
+ u32 sec_len; /* section data + header byte count */
+
+ sec_len = SEC_CMD_LEN + PTDL_VEC_HDR_SIZE; /* Total section byte length */
+
+ /* Write PTDL header + entire PTDL size */
+ written += write_chunk(buf, offset + written, (char *)"PTDL", sec_len);
+
+ /* Checksum starts here */
+ csum_start_offs = offset + written;
+
+ /* Patch-chunk header: fw_id. Note that this is in XAP word order */
+ written += write_uint16(buf, offset + written, (u16)(fw_id >> 16));
+ written += write_uint16(buf, offset + written, (u16)(fw_id & 0xffff));
+
+ /* Patch-chunk header: section length in uint16s */
+ written += write_uint16(buf, offset + written, (u16)(sec_len / 2));
+
+ /*
+ * Restart addresses to be executed on subsequent loader restart command.
+ */
+
+ /* Setup the MAC start address, note word ordering */
+ written += write_uint16(buf, offset + written, UF_MAC_START_CMD);
+ written += write_uint16(buf, offset + written, (UF_MAC_START_VEC >> 16));
+ written += write_uint16(buf, offset + written, (UF_MAC_START_VEC & 0xffff));
+
+ /* Setup the PHY start address, note word ordering */
+ written += write_uint16(buf, offset + written, UF_PHY_START_CMD);
+ written += write_uint16(buf, offset + written, (UF_PHY_START_VEC >> 16));
+ written += write_uint16(buf, offset + written, (UF_PHY_START_VEC & 0xffff));
+
+ /* u16 checksum calculated over data written */
+ csum = calc_checksum(buf, csum_start_offs, written - (csum_start_offs - offset));
+ written += write_uint16(buf, offset + written, csum);
+
+ return written;
+}
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * read_slut
+ *
+ * desc
+ *
+ * Arguments:
+ * readfn Pointer to function to call to read from the file.
+ * dlpriv Opaque pointer arg to pass to readfn.
+ * addr Offset into firmware image of SLUT.
+ * fwinfo Pointer to fwinfo struct to fill in.
+ *
+ * Returns:
+ * Number of SLUT entries in the f/w, or -1 if the image was corrupt.
+ * ---------------------------------------------------------------------------
+ */
+s32 xbv1_read_slut(card_t *card, fwreadfn_t readfn, void *dlpriv, xbv1_t *fwinfo,
+ symbol_t *slut, u32 slut_len)
+{
+ s16 i;
+ s32 offset;
+ u32 magic;
+ u32 count = 0;
+ ct_t ct;
+
+ if (fwinfo->mode != xbv_firmware)
+ {
+ return -1;
+ }
+
+ /* Find the d/l segment containing the SLUT */
+ /* This relies on the SLUT being entirely contained in one segment */
+ offset = -1;
+ for (i = 0; i < fwinfo->num_fwdl; i++)
+ {
+ if ((fwinfo->slut_addr >= fwinfo->fwdl[i].dl_addr) &&
+ (fwinfo->slut_addr < (fwinfo->fwdl[i].dl_addr + fwinfo->fwdl[i].dl_size)))
+ {
+ offset = fwinfo->fwdl[i].dl_offset +
+ (fwinfo->slut_addr - fwinfo->fwdl[i].dl_addr);
+ }
+ }
+ if (offset < 0)
+ {
+ return -1;
+ }
+
+ ct.dlpriv = dlpriv;
+ ct.ioffset = offset;
+ ct.iread = readfn;
+
+ if (read_uint(card, &ct, &magic, 2))
+ {
+ return -1;
+ }
+ if (magic != SLUT_FINGERPRINT)
+ {
+ return -1;
+ }
+
+ while (count < slut_len)
+ {
+ u32 id, obj;
+
+ /* Read Symbol Id */
+ if (read_uint(card, &ct, &id, 2))
+ {
+ return -1;
+ }
+
+ /* Check for end of table marker */
+ if (id == CSR_SLT_END)
+ {
+ break;
+ }
+
+ /* Read Symbol Value */
+ if (read_uint(card, &ct, &obj, 4))
+ {
+ return -1;
+ }
+
+ slut[count].id = (u16)id;
+ slut[count].obj = obj;
+ count++;
+ }
+
+ return count;
+} /* read_slut() */
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * xbv_to_patch
+ *
+ * Convert (the relevant parts of) a firmware xbv file into a patch xbv
+ *
+ * Arguments:
+ * card
+ * fw_buf - pointer to xbv firmware image
+ * fwinfo - structure describing the firmware image
+ * size - pointer to location into which size of f/w is written.
+ *
+ * Returns:
+ * Pointer to firmware image, or NULL on error. Caller must free this
+ * buffer via kfree() once it's finished with.
+ *
+ * Notes:
+ * The input fw_buf should have been checked via xbv1_parse prior to
+ * calling this function, so the input image is assumed valid.
+ * ---------------------------------------------------------------------------
+ */
+#define PTCH_LIST_SIZE 16 /* sizeof PTCH+FWID chunk in LIST header */
+
+void* xbv_to_patch(card_t *card, fwreadfn_t readfn,
+ const void *fw_buf, const xbv1_t *fwinfo, u32 *size)
+{
+ void *patch_buf = NULL;
+ u32 patch_buf_size;
+ u32 payload_offs = 0; /* Start of XBV payload */
+ s16 i;
+ u32 patch_offs = 0;
+ u32 list_len_offs = 0; /* Offset of PTDL LIST length parameter */
+ u32 ptdl_start_offs = 0; /* Offset of first PTDL chunk */
+ u32 fw_id;
+ void *rdbuf;
+
+ if (!fw_buf || !fwinfo || !card)
+ {
+ return NULL;
+ }
+
+ if (fwinfo->mode != xbv_firmware)
+ {
+ unifi_error(NULL, "Not a firmware file\n");
+ return NULL;
+ }
+
+ /* Pre-allocate read buffer for chunk conversion */
+ rdbuf = kmalloc(PTDL_MAX_SIZE, GFP_KERNEL);
+ if (!rdbuf)
+ {
+ unifi_error(card, "Couldn't alloc conversion buffer\n");
+ return NULL;
+ }
+
+ /* Loader requires patch file's build ID to match the running firmware's */
+ fw_id = card->build_id;
+
+ /* Firmware XBV1 contains VERF, optional INFO, SLUT(s), FWDL(s) */
+ /* Other chunks should get skipped. */
+ /* VERF should be sanity-checked against chip version */
+
+ /* Patch XBV1 contains VERF, optional INFO, PTCH */
+ /* PTCH contains FWID, optional INFO, PTDL(s), PTDL(start_vec) */
+ /* Each FWDL is split into PTDLs (each is 1024 XAP words max) */
+ /* Each PTDL contains running ROM f/w version, and checksum */
+ /* MAC/PHY reset addresses (known) are added into a final PTDL */
+
+ /* The input image has already been parsed, and loaded into fwinfo, so we
+ * can use that to build the output image
+ */
+ patch_buf_size = calc_patch_size(fwinfo);
+
+ patch_buf = kmalloc(patch_buf_size, GFP_KERNEL);
+ if (!patch_buf)
+ {
+ kfree(rdbuf);
+ unifi_error(NULL, "Can't malloc buffer for patch conversion\n");
+ return NULL;
+ }
+
+ memset(patch_buf, 0xdd, patch_buf_size);
+
+ /* Write XBV + VERF headers */
+ patch_offs += write_xbv_header(patch_buf, patch_offs, 0);
+ payload_offs = patch_offs;
+
+ /* Write patch (LIST) header */
+ list_len_offs = patch_offs + 4; /* Save LIST.length offset for later update */
+ patch_offs += write_ptch_header(patch_buf, patch_offs, fw_id);
+
+ /* Save start offset of the PTDL chunks */
+ ptdl_start_offs = patch_offs;
+
+ /* Write LIST of firmware PTDL blocks */
+ for (i = 0; i < fwinfo->num_fwdl; i++)
+ {
+ patch_offs += write_fwdl_to_ptdl(patch_buf,
+ patch_offs,
+ readfn,
+ &fwinfo->fwdl[i],
+ fw_buf,
+ fw_id,
+ rdbuf);
+ }
+
+ /* Write restart-vector PTDL last */
+ patch_offs += write_reset_ptdl(patch_buf, patch_offs, fwinfo, fw_id);
+
+ /* Now the length is known, update the LIST.length */
+ (void)write_uint32(patch_buf, list_len_offs,
+ (patch_offs - ptdl_start_offs) + PTCH_LIST_SIZE);
+
+ /* Re write XBV headers just to fill in the correct file size */
+ (void)write_xbv_header(patch_buf, 0, (patch_offs - payload_offs));
+
+ unifi_trace(card->ospriv, UDBG1, "XBV:PTCH size %u, fw_id %u\n",
+ patch_offs, fw_id);
+ if (size)
+ {
+ *size = patch_offs;
+ }
+ kfree(rdbuf);
+
+ return patch_buf;
+}
+
+
diff --git a/drivers/staging/csr/csr_wifi_hip_xbv.h b/drivers/staging/csr/csr_wifi_hip_xbv.h
new file mode 100644
index 000000000000..9b60a7e2dc78
--- /dev/null
+++ b/drivers/staging/csr/csr_wifi_hip_xbv.h
@@ -0,0 +1,127 @@
+/*****************************************************************************
+
+ (c) Cambridge Silicon Radio Limited 2011
+ All rights reserved and confidential information of CSR
+
+ Refer to LICENSE.txt included with this source for details
+ on the license terms.
+
+*****************************************************************************/
+
+/*
+ * ---------------------------------------------------------------------------
+ * FILE: csr_wifi_hip_xbv.h
+ *
+ * PURPOSE:
+ * Definitions and declarations for code to read XBV files - the UniFi
+ * firmware download file format.
+ *
+ * ---------------------------------------------------------------------------
+ */
+#ifndef __XBV_H__
+#define __XBV_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef CSR_WIFI_XBV_TEST
+/* Driver includes */
+#include "csr_wifi_hip_unifi.h"
+#endif
+
+
+struct VMEQ
+{
+ u32 addr;
+ u16 mask;
+ u16 value;
+};
+
+struct VAND
+{
+ u32 first;
+ u32 count;
+};
+
+struct VERS
+{
+ u32 num_vand;
+};
+
+struct FWDL
+{
+ u32 dl_addr;
+ u32 dl_size;
+ u32 dl_offset;
+};
+
+struct FWOV
+{
+ u32 dl_size;
+ u32 dl_offset;
+};
+
+struct PTDL
+{
+ u32 dl_size;
+ u32 dl_offset;
+};
+
+#define MAX_VMEQ 64
+#define MAX_VAND 64
+#define MAX_FWDL 256
+#define MAX_PTDL 256
+
+/* An XBV1 file can either contain firmware or patches (at the
+ * moment). The 'mode' member of the xbv1_t structure tells us which
+ * one is the case. */
+typedef enum
+{
+ xbv_unknown,
+ xbv_firmware,
+ xbv_patch
+} xbv_mode;
+
+typedef struct
+{
+ xbv_mode mode;
+
+ /* Parts of a Firmware XBV1 */
+
+ struct VMEQ vmeq[MAX_VMEQ];
+ u32 num_vmeq;
+ struct VAND vand[MAX_VAND];
+ struct VERS vers;
+
+ u32 slut_addr;
+
+ /* F/W download image, possibly more than one part */
+ struct FWDL fwdl[MAX_FWDL];
+ s16 num_fwdl;
+
+ /* F/W overlay image, add r not used */
+ struct FWOV fwov;
+
+ /* Parts of a Patch XBV1 */
+
+ u32 build_id;
+
+ struct PTDL ptdl[MAX_PTDL];
+ s16 num_ptdl;
+} xbv1_t;
+
+
+typedef s32 (*fwreadfn_t)(void *ospriv, void *dlpriv, u32 offset, void *buf, u32 len);
+
+CsrResult xbv1_parse(card_t *card, fwreadfn_t readfn, void *dlpriv, xbv1_t *fwinfo);
+s32 xbv1_read_slut(card_t *card, fwreadfn_t readfn, void *dlpriv, xbv1_t *fwinfo,
+ symbol_t *slut, u32 slut_len);
+void* xbv_to_patch(card_t *card, fwreadfn_t readfn, const void *fw_buf, const xbv1_t *fwinfo,
+ u32 *size);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __XBV_H__ */
diff --git a/drivers/staging/csr/csr_wifi_hostio_prim.h b/drivers/staging/csr/csr_wifi_hostio_prim.h
new file mode 100644
index 000000000000..bf7c55c6e84b
--- /dev/null
+++ b/drivers/staging/csr/csr_wifi_hostio_prim.h
@@ -0,0 +1,27 @@
+/*****************************************************************************
+
+ (c) Cambridge Silicon Radio Limited 2011
+ All rights reserved and confidential information of CSR
+
+ Refer to LICENSE.txt included with this source for details
+ on the license terms.
+
+*****************************************************************************/
+
+
+#ifndef CSR_WIFI_HOSTIO_H
+#define CSR_WIFI_HOSTIO_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+#define CSR_WIFI_HOSTIO_PRIM 0x0453
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* CSR_WIFI_HOSTIO_H */
+
diff --git a/drivers/staging/csr/csr_wifi_lib.h b/drivers/staging/csr/csr_wifi_lib.h
new file mode 100644
index 000000000000..eb56f6208871
--- /dev/null
+++ b/drivers/staging/csr/csr_wifi_lib.h
@@ -0,0 +1,112 @@
+/*****************************************************************************
+
+ (c) Cambridge Silicon Radio Limited 2011
+ All rights reserved and confidential information of CSR
+
+ Refer to LICENSE.txt included with this source for details
+ on the license terms.
+
+*****************************************************************************/
+#ifndef CSR_WIFI_LIB_H__
+#define CSR_WIFI_LIB_H__
+
+#include "csr_wifi_fsm_event.h"
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*----------------------------------------------------------------------------*
+ * CsrWifiFsmEventInit
+ *
+ * DESCRIPTION
+ * Macro to initialise the members of a CsrWifiFsmEvent.
+ *----------------------------------------------------------------------------*/
+#define CsrWifiFsmEventInit(evt, p_primtype, p_msgtype, p_dst, p_src) \
+ (evt)->primtype = p_primtype; \
+ (evt)->type = p_msgtype; \
+ (evt)->destination = p_dst; \
+ (evt)->source = p_src
+
+
+/*----------------------------------------------------------------------------*
+ * CsrWifiEvent_struct
+ *
+ * DESCRIPTION
+ * Generic message creator.
+ * Allocates and fills in a message with the signature CsrWifiEvent
+ *
+ *----------------------------------------------------------------------------*/
+CsrWifiFsmEvent* CsrWifiEvent_struct(u16 primtype, u16 msgtype, CsrSchedQid dst, CsrSchedQid src);
+
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ u8 value;
+} CsrWifiEventCsrUint8;
+
+/*----------------------------------------------------------------------------*
+ * CsrWifiEventCsrUint8_struct
+ *
+ * DESCRIPTION
+ * Generic message creator.
+ * Allocates and fills in a message with the signature CsrWifiEventCsrUint8
+ *
+ *----------------------------------------------------------------------------*/
+CsrWifiEventCsrUint8* CsrWifiEventCsrUint8_struct(u16 primtype, u16 msgtype, CsrSchedQid dst, CsrSchedQid src, u8 value);
+
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ u16 value;
+} CsrWifiEventCsrUint16;
+
+/*----------------------------------------------------------------------------*
+ * CsrWifiEventCsrUint16_struct
+ *
+ * DESCRIPTION
+ * Generic message creator.
+ * Allocates and fills in a message with the signature CsrWifiEventCsrUint16
+ *
+ *----------------------------------------------------------------------------*/
+CsrWifiEventCsrUint16* CsrWifiEventCsrUint16_struct(u16 primtype, u16 msgtype, CsrSchedQid dst, CsrSchedQid src, u16 value);
+
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ u32 value;
+} CsrWifiEventCsrUint32;
+
+/*----------------------------------------------------------------------------*
+ * CsrWifiEventCsrUint32_struct
+ *
+ * DESCRIPTION
+ * Generic message creator.
+ * Allocates and fills in a message with the signature CsrWifiEventCsrUint32
+ *
+ *----------------------------------------------------------------------------*/
+CsrWifiEventCsrUint32* CsrWifiEventCsrUint32_struct(u16 primtype, u16 msgtype, CsrSchedQid dst, CsrSchedQid src, u32 value);
+
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ u16 value16;
+ u8 value8;
+} CsrWifiEventCsrUint16CsrUint8;
+
+/*----------------------------------------------------------------------------*
+ * CsrWifiEventCsrUint16CsrUint8_struct
+ *
+ * DESCRIPTION
+ * Generic message creator.
+ * Allocates and fills in a message with the signature CsrWifiEventCsrUint16CsrUint8
+ *
+ *----------------------------------------------------------------------------*/
+CsrWifiEventCsrUint16CsrUint8* CsrWifiEventCsrUint16CsrUint8_struct(u16 primtype, u16 msgtype, CsrSchedQid dst, CsrSchedQid src, u16 value16, u8 value8);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* CSR_WIFI_LIB_H__ */
diff --git a/drivers/staging/csr/csr_wifi_msgconv.h b/drivers/staging/csr/csr_wifi_msgconv.h
new file mode 100644
index 000000000000..7ec35d70e14a
--- /dev/null
+++ b/drivers/staging/csr/csr_wifi_msgconv.h
@@ -0,0 +1,58 @@
+/*****************************************************************************
+
+ (c) Cambridge Silicon Radio Limited 2011
+ All rights reserved and confidential information of CSR
+
+ Refer to LICENSE.txt included with this source for details
+ on the license terms.
+
+*****************************************************************************/
+
+#ifndef CSR_WIFI_MSGCONV_H__
+#define CSR_WIFI_MSGCONV_H__
+
+#include "csr_prim_defs.h"
+#include "csr_sched.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+void CsrUint16SerBigEndian(u8 *ptr, size_t *len, u16 v);
+void CsrUint24SerBigEndian(u8 *ptr, size_t *len, u32 v);
+void CsrUint32SerBigEndian(u8 *ptr, size_t *len, u32 v);
+
+void CsrUint16DesBigEndian(u16 *v, u8 *buffer, size_t *offset);
+void CsrUint24DesBigEndian(u32 *v, u8 *buffer, size_t *offset);
+void CsrUint32DesBigEndian(u32 *v, u8 *buffer, size_t *offset);
+
+void CsrUint24Ser(u8 *ptr, size_t *len, u32 v);
+void CsrUint24Des(u32 *v, u8 *buffer, size_t *offset);
+
+
+size_t CsrWifiEventSizeof(void *msg);
+u8* CsrWifiEventSer(u8 *ptr, size_t *len, void *msg);
+void* CsrWifiEventDes(u8 *buffer, size_t length);
+
+size_t CsrWifiEventCsrUint8Sizeof(void *msg);
+u8* CsrWifiEventCsrUint8Ser(u8 *ptr, size_t *len, void *msg);
+void* CsrWifiEventCsrUint8Des(u8 *buffer, size_t length);
+
+size_t CsrWifiEventCsrUint16Sizeof(void *msg);
+u8* CsrWifiEventCsrUint16Ser(u8 *ptr, size_t *len, void *msg);
+void* CsrWifiEventCsrUint16Des(u8 *buffer, size_t length);
+
+size_t CsrWifiEventCsrUint32Sizeof(void *msg);
+u8* CsrWifiEventCsrUint32Ser(u8 *ptr, size_t *len, void *msg);
+void* CsrWifiEventCsrUint32Des(u8 *buffer, size_t length);
+
+size_t CsrWifiEventCsrUint16CsrUint8Sizeof(void *msg);
+u8* CsrWifiEventCsrUint16CsrUint8Ser(u8 *ptr, size_t *len, void *msg);
+void* CsrWifiEventCsrUint16CsrUint8Des(u8 *buffer, size_t length);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* CSR_WIFI_MSGCONV_H__ */
diff --git a/drivers/staging/csr/csr_wifi_nme_ap_converter_init.c b/drivers/staging/csr/csr_wifi_nme_ap_converter_init.c
new file mode 100644
index 000000000000..0689d6f1cab1
--- /dev/null
+++ b/drivers/staging/csr/csr_wifi_nme_ap_converter_init.c
@@ -0,0 +1,90 @@
+/*****************************************************************************
+
+ (c) Cambridge Silicon Radio Limited 2012
+ All rights reserved and confidential information of CSR
+
+ Refer to LICENSE.txt included with this source for details
+ on the license terms.
+
+*****************************************************************************/
+
+/* Note: this is an auto-generated file. */
+
+#include "csr_msgconv.h"
+#include "csr_macro.h"
+
+#ifdef CSR_WIFI_NME_ENABLE
+#ifdef CSR_WIFI_AP_ENABLE
+
+#ifdef CSR_LOG_ENABLE
+#include "csr_log.h"
+#endif
+
+#ifndef EXCLUDE_CSR_WIFI_NME_AP_MODULE
+#include "csr_wifi_nme_ap_serialize.h"
+#include "csr_wifi_nme_ap_prim.h"
+
+static CsrMsgConvMsgEntry csrwifinmeap_conv_lut[] = {
+ { CSR_WIFI_NME_AP_CONFIG_SET_REQ, CsrWifiNmeApConfigSetReqSizeof, CsrWifiNmeApConfigSetReqSer, CsrWifiNmeApConfigSetReqDes, CsrWifiNmeApConfigSetReqSerFree },
+ { CSR_WIFI_NME_AP_WPS_REGISTER_REQ, CsrWifiNmeApWpsRegisterReqSizeof, CsrWifiNmeApWpsRegisterReqSer, CsrWifiNmeApWpsRegisterReqDes, CsrWifiNmeApWpsRegisterReqSerFree },
+ { CSR_WIFI_NME_AP_START_REQ, CsrWifiNmeApStartReqSizeof, CsrWifiNmeApStartReqSer, CsrWifiNmeApStartReqDes, CsrWifiNmeApStartReqSerFree },
+ { CSR_WIFI_NME_AP_STOP_REQ, CsrWifiNmeApStopReqSizeof, CsrWifiNmeApStopReqSer, CsrWifiNmeApStopReqDes, CsrWifiNmeApStopReqSerFree },
+ { CSR_WIFI_NME_AP_WMM_PARAM_UPDATE_REQ, CsrWifiNmeApWmmParamUpdateReqSizeof, CsrWifiNmeApWmmParamUpdateReqSer, CsrWifiNmeApWmmParamUpdateReqDes, CsrWifiNmeApWmmParamUpdateReqSerFree },
+ { CSR_WIFI_NME_AP_STA_REMOVE_REQ, CsrWifiNmeApStaRemoveReqSizeof, CsrWifiNmeApStaRemoveReqSer, CsrWifiNmeApStaRemoveReqDes, CsrWifiNmeApStaRemoveReqSerFree },
+ { CSR_WIFI_NME_AP_CONFIG_SET_CFM, CsrWifiNmeApConfigSetCfmSizeof, CsrWifiNmeApConfigSetCfmSer, CsrWifiNmeApConfigSetCfmDes, CsrWifiNmeApConfigSetCfmSerFree },
+ { CSR_WIFI_NME_AP_WPS_REGISTER_CFM, CsrWifiNmeApWpsRegisterCfmSizeof, CsrWifiNmeApWpsRegisterCfmSer, CsrWifiNmeApWpsRegisterCfmDes, CsrWifiNmeApWpsRegisterCfmSerFree },
+ { CSR_WIFI_NME_AP_START_CFM, CsrWifiNmeApStartCfmSizeof, CsrWifiNmeApStartCfmSer, CsrWifiNmeApStartCfmDes, CsrWifiNmeApStartCfmSerFree },
+ { CSR_WIFI_NME_AP_STOP_CFM, CsrWifiNmeApStopCfmSizeof, CsrWifiNmeApStopCfmSer, CsrWifiNmeApStopCfmDes, CsrWifiNmeApStopCfmSerFree },
+ { CSR_WIFI_NME_AP_STOP_IND, CsrWifiNmeApStopIndSizeof, CsrWifiNmeApStopIndSer, CsrWifiNmeApStopIndDes, CsrWifiNmeApStopIndSerFree },
+ { CSR_WIFI_NME_AP_WMM_PARAM_UPDATE_CFM, CsrWifiNmeApWmmParamUpdateCfmSizeof, CsrWifiNmeApWmmParamUpdateCfmSer, CsrWifiNmeApWmmParamUpdateCfmDes, CsrWifiNmeApWmmParamUpdateCfmSerFree },
+ { CSR_WIFI_NME_AP_STATION_IND, CsrWifiNmeApStationIndSizeof, CsrWifiNmeApStationIndSer, CsrWifiNmeApStationIndDes, CsrWifiNmeApStationIndSerFree },
+
+ { 0, NULL, NULL, NULL, NULL },
+};
+
+CsrMsgConvMsgEntry* CsrWifiNmeApConverterLookup(CsrMsgConvMsgEntry *ce, u16 msgType)
+{
+ if (msgType & CSR_PRIM_UPSTREAM)
+ {
+ u16 idx = (msgType & ~CSR_PRIM_UPSTREAM) + CSR_WIFI_NME_AP_PRIM_DOWNSTREAM_COUNT;
+ if (idx < (CSR_WIFI_NME_AP_PRIM_UPSTREAM_COUNT + CSR_WIFI_NME_AP_PRIM_DOWNSTREAM_COUNT) &&
+ csrwifinmeap_conv_lut[idx].msgType == msgType)
+ {
+ return &csrwifinmeap_conv_lut[idx];
+ }
+ }
+ else
+ {
+ if (msgType < CSR_WIFI_NME_AP_PRIM_DOWNSTREAM_COUNT &&
+ csrwifinmeap_conv_lut[msgType].msgType == msgType)
+ {
+ return &csrwifinmeap_conv_lut[msgType];
+ }
+ }
+ return NULL;
+}
+
+
+void CsrWifiNmeApConverterInit(void)
+{
+ CsrMsgConvInsert(CSR_WIFI_NME_AP_PRIM, csrwifinmeap_conv_lut);
+ CsrMsgConvCustomLookupRegister(CSR_WIFI_NME_AP_PRIM, CsrWifiNmeApConverterLookup);
+}
+
+
+#ifdef CSR_LOG_ENABLE
+static const CsrLogPrimitiveInformation csrwifinmeap_conv_info = {
+ CSR_WIFI_NME_AP_PRIM,
+ (char *)"CSR_WIFI_NME_AP_PRIM",
+ csrwifinmeap_conv_lut
+};
+const CsrLogPrimitiveInformation* CsrWifiNmeApTechInfoGet(void)
+{
+ return &csrwifinmeap_conv_info;
+}
+
+
+#endif /* CSR_LOG_ENABLE */
+#endif /* EXCLUDE_CSR_WIFI_NME_AP_MODULE */
+#endif /* CSR_WIFI_NME_ENABLE */
+#endif /* CSR_WIFI_AP_ENABLE */
diff --git a/drivers/staging/csr/csr_wifi_nme_ap_converter_init.h b/drivers/staging/csr/csr_wifi_nme_ap_converter_init.h
new file mode 100644
index 000000000000..4072c06a152d
--- /dev/null
+++ b/drivers/staging/csr/csr_wifi_nme_ap_converter_init.h
@@ -0,0 +1,49 @@
+/*****************************************************************************
+
+ (c) Cambridge Silicon Radio Limited 2011
+ All rights reserved and confidential information of CSR
+
+ Refer to LICENSE.txt included with this source for details
+ on the license terms.
+
+*****************************************************************************/
+
+/* Note: this is an auto-generated file. */
+
+#ifndef CSR_WIFI_NME_AP_CONVERTER_INIT_H__
+#define CSR_WIFI_NME_AP_CONVERTER_INIT_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef CSR_WIFI_NME_ENABLE
+#error CSR_WIFI_NME_ENABLE MUST be defined inorder to use csr_wifi_nme_ap_converter_init.h
+#endif
+#ifndef CSR_WIFI_AP_ENABLE
+#error CSR_WIFI_AP_ENABLE MUST be defined inorder to use csr_wifi_nme_ap_converter_init.h
+#endif
+
+#ifndef EXCLUDE_CSR_WIFI_NME_AP_MODULE
+
+#include "csr_msgconv.h"
+
+#ifdef CSR_LOG_ENABLE
+#include "csr_log.h"
+
+extern const CsrLogPrimitiveInformation* CsrWifiNmeApTechInfoGet(void);
+#endif /* CSR_LOG_ENABLE */
+
+extern void CsrWifiNmeApConverterInit(void);
+
+#else /* EXCLUDE_CSR_WIFI_NME_AP_MODULE */
+
+#define CsrWifiNmeApConverterInit()
+
+#endif /* EXCLUDE_CSR_WIFI_NME_AP_MODULE */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* CSR_WIFI_NME_AP_CONVERTER_INIT_H__ */
diff --git a/drivers/staging/csr/csr_wifi_nme_ap_free_downstream_contents.c b/drivers/staging/csr/csr_wifi_nme_ap_free_downstream_contents.c
new file mode 100644
index 000000000000..ab9358873ec3
--- /dev/null
+++ b/drivers/staging/csr/csr_wifi_nme_ap_free_downstream_contents.c
@@ -0,0 +1,84 @@
+/*****************************************************************************
+
+ (c) Cambridge Silicon Radio Limited 2012
+ All rights reserved and confidential information of CSR
+
+ Refer to LICENSE.txt included with this source for details
+ on the license terms.
+
+*****************************************************************************/
+
+/* Note: this is an auto-generated file. */
+#include <linux/slab.h>
+#include "csr_wifi_nme_ap_prim.h"
+#include "csr_wifi_nme_ap_lib.h"
+
+/*----------------------------------------------------------------------------*
+ * NAME
+ * CsrWifiNmeApFreeDownstreamMessageContents
+ *
+ * DESCRIPTION
+ *
+ *
+ * PARAMETERS
+ * eventClass: only the value CSR_WIFI_NME_AP_PRIM will be handled
+ * message: the message to free
+ *----------------------------------------------------------------------------*/
+void CsrWifiNmeApFreeDownstreamMessageContents(u16 eventClass, void *message)
+{
+ if (eventClass != CSR_WIFI_NME_AP_PRIM)
+ {
+ return;
+ }
+ if (NULL == message)
+ {
+ return;
+ }
+
+ switch (*((CsrWifiNmeApPrim *) message))
+ {
+ case CSR_WIFI_NME_AP_CONFIG_SET_REQ:
+ {
+ CsrWifiNmeApConfigSetReq *p = (CsrWifiNmeApConfigSetReq *)message;
+ kfree(p->apMacConfig.macAddressList);
+ p->apMacConfig.macAddressList = NULL;
+ break;
+ }
+ case CSR_WIFI_NME_AP_START_REQ:
+ {
+ CsrWifiNmeApStartReq *p = (CsrWifiNmeApStartReq *)message;
+ switch (p->apCredentials.authType)
+ {
+ case CSR_WIFI_SME_AP_AUTH_TYPE_PERSONAL:
+ switch (p->apCredentials.nmeAuthType.authTypePersonal.pskOrPassphrase)
+ {
+ case CSR_WIFI_NME_AP_CREDENTIAL_TYPE_PASSPHRASE:
+ kfree(p->apCredentials.nmeAuthType.authTypePersonal.authPers_credentials.passphrase.passphrase);
+ p->apCredentials.nmeAuthType.authTypePersonal.authPers_credentials.passphrase.passphrase = NULL;
+ break;
+ default:
+ break;
+ }
+ break;
+ default:
+ break;
+ }
+ {
+ u16 i3;
+ for (i3 = 0; i3 < p->p2pGoParam.operatingChanList.channelEntryListCount; i3++)
+ {
+ kfree(p->p2pGoParam.operatingChanList.channelEntryList[i3].operatingChannel);
+ p->p2pGoParam.operatingChanList.channelEntryList[i3].operatingChannel = NULL;
+ }
+ }
+ kfree(p->p2pGoParam.operatingChanList.channelEntryList);
+ p->p2pGoParam.operatingChanList.channelEntryList = NULL;
+ break;
+ }
+
+ default:
+ break;
+ }
+}
+
+
diff --git a/drivers/staging/csr/csr_wifi_nme_ap_free_upstream_contents.c b/drivers/staging/csr/csr_wifi_nme_ap_free_upstream_contents.c
new file mode 100644
index 000000000000..2786a6bbff97
--- /dev/null
+++ b/drivers/staging/csr/csr_wifi_nme_ap_free_upstream_contents.c
@@ -0,0 +1,39 @@
+/*****************************************************************************
+
+ (c) Cambridge Silicon Radio Limited 2012
+ All rights reserved and confidential information of CSR
+
+ Refer to LICENSE.txt included with this source for details
+ on the license terms.
+
+*****************************************************************************/
+
+/* Note: this is an auto-generated file. */
+
+#include "csr_wifi_nme_ap_prim.h"
+#include "csr_wifi_nme_ap_lib.h"
+
+/*----------------------------------------------------------------------------*
+ * NAME
+ * CsrWifiNmeApFreeUpstreamMessageContents
+ *
+ * DESCRIPTION
+ *
+ *
+ * PARAMETERS
+ * eventClass: only the value CSR_WIFI_NME_AP_PRIM will be handled
+ * message: the message to free
+ *----------------------------------------------------------------------------*/
+void CsrWifiNmeApFreeUpstreamMessageContents(u16 eventClass, void *message)
+{
+ if (eventClass != CSR_WIFI_NME_AP_PRIM)
+ {
+ return;
+ }
+ if (NULL == message)
+ {
+ return;
+ }
+}
+
+
diff --git a/drivers/staging/csr/csr_wifi_nme_ap_lib.h b/drivers/staging/csr/csr_wifi_nme_ap_lib.h
new file mode 100644
index 000000000000..d4014709112b
--- /dev/null
+++ b/drivers/staging/csr/csr_wifi_nme_ap_lib.h
@@ -0,0 +1,523 @@
+/*****************************************************************************
+
+ (c) Cambridge Silicon Radio Limited 2012
+ All rights reserved and confidential information of CSR
+
+ Refer to LICENSE.txt included with this source for details
+ on the license terms.
+
+*****************************************************************************/
+
+/* Note: this is an auto-generated file. */
+
+#ifndef CSR_WIFI_NME_AP_LIB_H__
+#define CSR_WIFI_NME_AP_LIB_H__
+
+#include "csr_sched.h"
+#include "csr_macro.h"
+#include "csr_msg_transport.h"
+
+#include "csr_wifi_lib.h"
+
+#include "csr_wifi_nme_ap_prim.h"
+#include "csr_wifi_nme_task.h"
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef CSR_WIFI_NME_ENABLE
+#error CSR_WIFI_NME_ENABLE MUST be defined inorder to use csr_wifi_nme_ap_lib.h
+#endif
+#ifndef CSR_WIFI_AP_ENABLE
+#error CSR_WIFI_AP_ENABLE MUST be defined inorder to use csr_wifi_nme_ap_lib.h
+#endif
+
+/*----------------------------------------------------------------------------*
+ * CsrWifiNmeApFreeUpstreamMessageContents
+ *
+ * DESCRIPTION
+ * Free the allocated memory in a CSR_WIFI_NME_AP upstream message. Does not
+ * free the message itself, and can only be used for upstream messages.
+ *
+ * PARAMETERS
+ * Deallocates the resources in a CSR_WIFI_NME_AP upstream message
+ *----------------------------------------------------------------------------*/
+void CsrWifiNmeApFreeUpstreamMessageContents(u16 eventClass, void *message);
+
+/*----------------------------------------------------------------------------*
+ * CsrWifiNmeApFreeDownstreamMessageContents
+ *
+ * DESCRIPTION
+ * Free the allocated memory in a CSR_WIFI_NME_AP downstream message. Does not
+ * free the message itself, and can only be used for downstream messages.
+ *
+ * PARAMETERS
+ * Deallocates the resources in a CSR_WIFI_NME_AP downstream message
+ *----------------------------------------------------------------------------*/
+void CsrWifiNmeApFreeDownstreamMessageContents(u16 eventClass, void *message);
+
+/*----------------------------------------------------------------------------*
+ * Enum to string functions
+ *----------------------------------------------------------------------------*/
+const char* CsrWifiNmeApPersCredentialTypeToString(CsrWifiNmeApPersCredentialType value);
+
+
+/*----------------------------------------------------------------------------*
+ * CsrPrim Type toString function.
+ * Converts a message type to the String name of the Message
+ *----------------------------------------------------------------------------*/
+const char* CsrWifiNmeApPrimTypeToString(CsrPrim msgType);
+
+/*----------------------------------------------------------------------------*
+ * Lookup arrays for PrimType name Strings
+ *----------------------------------------------------------------------------*/
+extern const char *CsrWifiNmeApUpstreamPrimNames[CSR_WIFI_NME_AP_PRIM_UPSTREAM_COUNT];
+extern const char *CsrWifiNmeApDownstreamPrimNames[CSR_WIFI_NME_AP_PRIM_DOWNSTREAM_COUNT];
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiNmeApConfigSetReqSend
+
+ DESCRIPTION
+ This primitive passes AP configuration info for NME. This can be sent at
+ any time but will be acted upon when the AP is started again. This
+ information is common to both P2P GO and AP
+
+ PARAMETERS
+ queue - Message Source Task Queue (Cfm's will be sent to this Queue)
+ apConfig - AP configuration for the NME.
+ apMacConfig - MAC configuration to be acted on when
+ CSR_WIFI_NME_AP_START.request is sent.
+
+*******************************************************************************/
+#define CsrWifiNmeApConfigSetReqCreate(msg__, dst__, src__, apConfig__, apMacConfig__) \
+ msg__ = kmalloc(sizeof(CsrWifiNmeApConfigSetReq), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_NME_AP_PRIM, CSR_WIFI_NME_AP_CONFIG_SET_REQ, dst__, src__); \
+ msg__->apConfig = (apConfig__); \
+ msg__->apMacConfig = (apMacConfig__);
+
+#define CsrWifiNmeApConfigSetReqSendTo(dst__, src__, apConfig__, apMacConfig__) \
+ { \
+ CsrWifiNmeApConfigSetReq *msg__; \
+ CsrWifiNmeApConfigSetReqCreate(msg__, dst__, src__, apConfig__, apMacConfig__); \
+ CsrMsgTransport(dst__, CSR_WIFI_NME_AP_PRIM, msg__); \
+ }
+
+#define CsrWifiNmeApConfigSetReqSend(src__, apConfig__, apMacConfig__) \
+ CsrWifiNmeApConfigSetReqSendTo(CSR_WIFI_NME_IFACEQUEUE, src__, apConfig__, apMacConfig__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiNmeApConfigSetCfmSend
+
+ DESCRIPTION
+ This primitive reports the result of the request.
+
+ PARAMETERS
+ queue - Destination Task Queue
+ status - Status of the request.
+
+*******************************************************************************/
+#define CsrWifiNmeApConfigSetCfmCreate(msg__, dst__, src__, status__) \
+ msg__ = kmalloc(sizeof(CsrWifiNmeApConfigSetCfm), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_NME_AP_PRIM, CSR_WIFI_NME_AP_CONFIG_SET_CFM, dst__, src__); \
+ msg__->status = (status__);
+
+#define CsrWifiNmeApConfigSetCfmSendTo(dst__, src__, status__) \
+ { \
+ CsrWifiNmeApConfigSetCfm *msg__; \
+ CsrWifiNmeApConfigSetCfmCreate(msg__, dst__, src__, status__); \
+ CsrSchedMessagePut(dst__, CSR_WIFI_NME_AP_PRIM, msg__); \
+ }
+
+#define CsrWifiNmeApConfigSetCfmSend(dst__, status__) \
+ CsrWifiNmeApConfigSetCfmSendTo(dst__, CSR_WIFI_NME_IFACEQUEUE, status__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiNmeApStaRemoveReqSend
+
+ DESCRIPTION
+ This primitive disconnects a connected station. If keepBlocking is set to
+ TRUE, the station with the specified MAC address is not allowed to
+ connect. If the requested station is not already connected,it may be
+ blocked based on keepBlocking parameter.
+
+ PARAMETERS
+ queue - Message Source Task Queue (Cfm's will be sent to this Queue)
+ interfaceTag - Interface Identifier; unique identifier of an interface
+ staMacAddress - Mac Address of the station to be disconnected or blocked
+ keepBlocking - If TRUE, the station is blocked. If FALSE and the station is
+ connected, disconnect the station. If FALSE and the station
+ is not connected, no action is taken.
+
+*******************************************************************************/
+#define CsrWifiNmeApStaRemoveReqCreate(msg__, dst__, src__, interfaceTag__, staMacAddress__, keepBlocking__) \
+ msg__ = kmalloc(sizeof(CsrWifiNmeApStaRemoveReq), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_NME_AP_PRIM, CSR_WIFI_NME_AP_STA_REMOVE_REQ, dst__, src__); \
+ msg__->interfaceTag = (interfaceTag__); \
+ msg__->staMacAddress = (staMacAddress__); \
+ msg__->keepBlocking = (keepBlocking__);
+
+#define CsrWifiNmeApStaRemoveReqSendTo(dst__, src__, interfaceTag__, staMacAddress__, keepBlocking__) \
+ { \
+ CsrWifiNmeApStaRemoveReq *msg__; \
+ CsrWifiNmeApStaRemoveReqCreate(msg__, dst__, src__, interfaceTag__, staMacAddress__, keepBlocking__); \
+ CsrMsgTransport(dst__, CSR_WIFI_NME_AP_PRIM, msg__); \
+ }
+
+#define CsrWifiNmeApStaRemoveReqSend(src__, interfaceTag__, staMacAddress__, keepBlocking__) \
+ CsrWifiNmeApStaRemoveReqSendTo(CSR_WIFI_NME_IFACEQUEUE, src__, interfaceTag__, staMacAddress__, keepBlocking__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiNmeApStartReqSend
+
+ DESCRIPTION
+ This primitive requests NME to started the AP operation.
+
+ PARAMETERS
+ queue - Message Source Task Queue (Cfm's will be sent to this Queue)
+ interfaceTag - Interface identifier; unique identifier of an interface
+ apType - AP Type specifies the Legacy AP or P2P GO operation
+ cloakSsid - Indicates whether the SSID should be cloaked (hidden and
+ not broadcast in beacon) or not
+ ssid - Service Set Identifier
+ ifIndex - Radio interface
+ channel - Channel number of the channel to use
+ apCredentials - Security credential configuration.
+ maxConnections - Maximum number of stations/P2P clients allowed
+ p2pGoParam - P2P specific GO parameters.
+ wpsEnabled - Indicates whether WPS should be enabled or not
+
+*******************************************************************************/
+#define CsrWifiNmeApStartReqCreate(msg__, dst__, src__, interfaceTag__, apType__, cloakSsid__, ssid__, ifIndex__, channel__, apCredentials__, maxConnections__, p2pGoParam__, wpsEnabled__) \
+ msg__ = kmalloc(sizeof(CsrWifiNmeApStartReq), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_NME_AP_PRIM, CSR_WIFI_NME_AP_START_REQ, dst__, src__); \
+ msg__->interfaceTag = (interfaceTag__); \
+ msg__->apType = (apType__); \
+ msg__->cloakSsid = (cloakSsid__); \
+ msg__->ssid = (ssid__); \
+ msg__->ifIndex = (ifIndex__); \
+ msg__->channel = (channel__); \
+ msg__->apCredentials = (apCredentials__); \
+ msg__->maxConnections = (maxConnections__); \
+ msg__->p2pGoParam = (p2pGoParam__); \
+ msg__->wpsEnabled = (wpsEnabled__);
+
+#define CsrWifiNmeApStartReqSendTo(dst__, src__, interfaceTag__, apType__, cloakSsid__, ssid__, ifIndex__, channel__, apCredentials__, maxConnections__, p2pGoParam__, wpsEnabled__) \
+ { \
+ CsrWifiNmeApStartReq *msg__; \
+ CsrWifiNmeApStartReqCreate(msg__, dst__, src__, interfaceTag__, apType__, cloakSsid__, ssid__, ifIndex__, channel__, apCredentials__, maxConnections__, p2pGoParam__, wpsEnabled__); \
+ CsrMsgTransport(dst__, CSR_WIFI_NME_AP_PRIM, msg__); \
+ }
+
+#define CsrWifiNmeApStartReqSend(src__, interfaceTag__, apType__, cloakSsid__, ssid__, ifIndex__, channel__, apCredentials__, maxConnections__, p2pGoParam__, wpsEnabled__) \
+ CsrWifiNmeApStartReqSendTo(CSR_WIFI_NME_IFACEQUEUE, src__, interfaceTag__, apType__, cloakSsid__, ssid__, ifIndex__, channel__, apCredentials__, maxConnections__, p2pGoParam__, wpsEnabled__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiNmeApStartCfmSend
+
+ DESCRIPTION
+ This primitive reports the result of CSR_WIFI_NME_AP_START.request.
+
+ PARAMETERS
+ queue - Destination Task Queue
+ interfaceTag - Interface identifier; unique identifier of an interface
+ status - Status of the request.
+ ssid - Service Set Identifier
+
+*******************************************************************************/
+#define CsrWifiNmeApStartCfmCreate(msg__, dst__, src__, interfaceTag__, status__, ssid__) \
+ msg__ = kmalloc(sizeof(CsrWifiNmeApStartCfm), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_NME_AP_PRIM, CSR_WIFI_NME_AP_START_CFM, dst__, src__); \
+ msg__->interfaceTag = (interfaceTag__); \
+ msg__->status = (status__); \
+ msg__->ssid = (ssid__);
+
+#define CsrWifiNmeApStartCfmSendTo(dst__, src__, interfaceTag__, status__, ssid__) \
+ { \
+ CsrWifiNmeApStartCfm *msg__; \
+ CsrWifiNmeApStartCfmCreate(msg__, dst__, src__, interfaceTag__, status__, ssid__); \
+ CsrSchedMessagePut(dst__, CSR_WIFI_NME_AP_PRIM, msg__); \
+ }
+
+#define CsrWifiNmeApStartCfmSend(dst__, interfaceTag__, status__, ssid__) \
+ CsrWifiNmeApStartCfmSendTo(dst__, CSR_WIFI_NME_IFACEQUEUE, interfaceTag__, status__, ssid__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiNmeApStationIndSend
+
+ DESCRIPTION
+ This primitive indicates that a station has joined or a previously joined
+ station has left the BSS/group
+
+ PARAMETERS
+ queue - Destination Task Queue
+ interfaceTag - Interface Identifier; unique identifier of an interface
+ mediaStatus - Indicates whether the station is connected or
+ disconnected
+ peerMacAddress - MAC address of the station
+ peerDeviceAddress - P2P Device Address
+
+*******************************************************************************/
+#define CsrWifiNmeApStationIndCreate(msg__, dst__, src__, interfaceTag__, mediaStatus__, peerMacAddress__, peerDeviceAddress__) \
+ msg__ = kmalloc(sizeof(CsrWifiNmeApStationInd), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_NME_AP_PRIM, CSR_WIFI_NME_AP_STATION_IND, dst__, src__); \
+ msg__->interfaceTag = (interfaceTag__); \
+ msg__->mediaStatus = (mediaStatus__); \
+ msg__->peerMacAddress = (peerMacAddress__); \
+ msg__->peerDeviceAddress = (peerDeviceAddress__);
+
+#define CsrWifiNmeApStationIndSendTo(dst__, src__, interfaceTag__, mediaStatus__, peerMacAddress__, peerDeviceAddress__) \
+ { \
+ CsrWifiNmeApStationInd *msg__; \
+ CsrWifiNmeApStationIndCreate(msg__, dst__, src__, interfaceTag__, mediaStatus__, peerMacAddress__, peerDeviceAddress__); \
+ CsrSchedMessagePut(dst__, CSR_WIFI_NME_AP_PRIM, msg__); \
+ }
+
+#define CsrWifiNmeApStationIndSend(dst__, interfaceTag__, mediaStatus__, peerMacAddress__, peerDeviceAddress__) \
+ CsrWifiNmeApStationIndSendTo(dst__, CSR_WIFI_NME_IFACEQUEUE, interfaceTag__, mediaStatus__, peerMacAddress__, peerDeviceAddress__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiNmeApStopReqSend
+
+ DESCRIPTION
+ This primitive requests NME to stop the AP operation.
+
+ PARAMETERS
+ queue - Message Source Task Queue (Cfm's will be sent to this Queue)
+ interfaceTag - Interface identifier; unique identifier of an interface
+
+*******************************************************************************/
+#define CsrWifiNmeApStopReqCreate(msg__, dst__, src__, interfaceTag__) \
+ msg__ = kmalloc(sizeof(CsrWifiNmeApStopReq), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_NME_AP_PRIM, CSR_WIFI_NME_AP_STOP_REQ, dst__, src__); \
+ msg__->interfaceTag = (interfaceTag__);
+
+#define CsrWifiNmeApStopReqSendTo(dst__, src__, interfaceTag__) \
+ { \
+ CsrWifiNmeApStopReq *msg__; \
+ CsrWifiNmeApStopReqCreate(msg__, dst__, src__, interfaceTag__); \
+ CsrMsgTransport(dst__, CSR_WIFI_NME_AP_PRIM, msg__); \
+ }
+
+#define CsrWifiNmeApStopReqSend(src__, interfaceTag__) \
+ CsrWifiNmeApStopReqSendTo(CSR_WIFI_NME_IFACEQUEUE, src__, interfaceTag__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiNmeApStopIndSend
+
+ DESCRIPTION
+ Indicates that AP operation had stopped because of some unrecoverable
+ error after AP operation was started successfully. NME sends this signal
+ after failing to restart the AP operation internally following an error
+
+ PARAMETERS
+ queue - Destination Task Queue
+ interfaceTag - Interface Identifier; unique identifier of an interface
+ apType - Reports AP Type (P2PGO or AP)
+ status - Error Status
+
+*******************************************************************************/
+#define CsrWifiNmeApStopIndCreate(msg__, dst__, src__, interfaceTag__, apType__, status__) \
+ msg__ = kmalloc(sizeof(CsrWifiNmeApStopInd), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_NME_AP_PRIM, CSR_WIFI_NME_AP_STOP_IND, dst__, src__); \
+ msg__->interfaceTag = (interfaceTag__); \
+ msg__->apType = (apType__); \
+ msg__->status = (status__);
+
+#define CsrWifiNmeApStopIndSendTo(dst__, src__, interfaceTag__, apType__, status__) \
+ { \
+ CsrWifiNmeApStopInd *msg__; \
+ CsrWifiNmeApStopIndCreate(msg__, dst__, src__, interfaceTag__, apType__, status__); \
+ CsrSchedMessagePut(dst__, CSR_WIFI_NME_AP_PRIM, msg__); \
+ }
+
+#define CsrWifiNmeApStopIndSend(dst__, interfaceTag__, apType__, status__) \
+ CsrWifiNmeApStopIndSendTo(dst__, CSR_WIFI_NME_IFACEQUEUE, interfaceTag__, apType__, status__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiNmeApStopCfmSend
+
+ DESCRIPTION
+ This primitive confirms that the AP operation is stopped. NME shall send
+ this primitive in response to the request even if AP operation has
+ already been stopped
+
+ PARAMETERS
+ queue - Destination Task Queue
+ interfaceTag - Interface identifier; unique identifier of an interface
+ status - Status of the request.
+
+*******************************************************************************/
+#define CsrWifiNmeApStopCfmCreate(msg__, dst__, src__, interfaceTag__, status__) \
+ msg__ = kmalloc(sizeof(CsrWifiNmeApStopCfm), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_NME_AP_PRIM, CSR_WIFI_NME_AP_STOP_CFM, dst__, src__); \
+ msg__->interfaceTag = (interfaceTag__); \
+ msg__->status = (status__);
+
+#define CsrWifiNmeApStopCfmSendTo(dst__, src__, interfaceTag__, status__) \
+ { \
+ CsrWifiNmeApStopCfm *msg__; \
+ CsrWifiNmeApStopCfmCreate(msg__, dst__, src__, interfaceTag__, status__); \
+ CsrSchedMessagePut(dst__, CSR_WIFI_NME_AP_PRIM, msg__); \
+ }
+
+#define CsrWifiNmeApStopCfmSend(dst__, interfaceTag__, status__) \
+ CsrWifiNmeApStopCfmSendTo(dst__, CSR_WIFI_NME_IFACEQUEUE, interfaceTag__, status__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiNmeApWmmParamUpdateReqSend
+
+ DESCRIPTION
+ Application uses this primitive to update the WMM parameters
+
+ PARAMETERS
+ queue - Message Source Task Queue (Cfm's will be sent to this Queue)
+ wmmApParams - WMM Access point parameters per access category. The array
+ index corresponds to the ACI
+ wmmApBcParams - WMM station parameters per access category to be advertised
+ in the beacons and probe response The array index
+ corresponds to the ACI
+
+*******************************************************************************/
+#define CsrWifiNmeApWmmParamUpdateReqCreate(msg__, dst__, src__, wmmApParams__, wmmApBcParams__) \
+ msg__ = kmalloc(sizeof(CsrWifiNmeApWmmParamUpdateReq), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_NME_AP_PRIM, CSR_WIFI_NME_AP_WMM_PARAM_UPDATE_REQ, dst__, src__); \
+ memcpy(msg__->wmmApParams, (wmmApParams__), sizeof(CsrWifiSmeWmmAcParams) * 4); \
+ memcpy(msg__->wmmApBcParams, (wmmApBcParams__), sizeof(CsrWifiSmeWmmAcParams) * 4);
+
+#define CsrWifiNmeApWmmParamUpdateReqSendTo(dst__, src__, wmmApParams__, wmmApBcParams__) \
+ { \
+ CsrWifiNmeApWmmParamUpdateReq *msg__; \
+ CsrWifiNmeApWmmParamUpdateReqCreate(msg__, dst__, src__, wmmApParams__, wmmApBcParams__); \
+ CsrMsgTransport(dst__, CSR_WIFI_NME_AP_PRIM, msg__); \
+ }
+
+#define CsrWifiNmeApWmmParamUpdateReqSend(src__, wmmApParams__, wmmApBcParams__) \
+ CsrWifiNmeApWmmParamUpdateReqSendTo(CSR_WIFI_NME_IFACEQUEUE, src__, wmmApParams__, wmmApBcParams__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiNmeApWmmParamUpdateCfmSend
+
+ DESCRIPTION
+ A confirm for for the WMM parameters update
+
+ PARAMETERS
+ queue - Destination Task Queue
+ status - Status of the request.
+
+*******************************************************************************/
+#define CsrWifiNmeApWmmParamUpdateCfmCreate(msg__, dst__, src__, status__) \
+ msg__ = kmalloc(sizeof(CsrWifiNmeApWmmParamUpdateCfm), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_NME_AP_PRIM, CSR_WIFI_NME_AP_WMM_PARAM_UPDATE_CFM, dst__, src__); \
+ msg__->status = (status__);
+
+#define CsrWifiNmeApWmmParamUpdateCfmSendTo(dst__, src__, status__) \
+ { \
+ CsrWifiNmeApWmmParamUpdateCfm *msg__; \
+ CsrWifiNmeApWmmParamUpdateCfmCreate(msg__, dst__, src__, status__); \
+ CsrSchedMessagePut(dst__, CSR_WIFI_NME_AP_PRIM, msg__); \
+ }
+
+#define CsrWifiNmeApWmmParamUpdateCfmSend(dst__, status__) \
+ CsrWifiNmeApWmmParamUpdateCfmSendTo(dst__, CSR_WIFI_NME_IFACEQUEUE, status__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiNmeApWpsRegisterReqSend
+
+ DESCRIPTION
+ This primitive allows the NME to accept the WPS registration from an
+ enrollee. Such registration procedure can be cancelled by sending
+ CSR_WIFI_NME_WPS_CANCEL.request.
+
+ PARAMETERS
+ queue - Message Source Task Queue (Cfm's will be sent to this Queue)
+ interfaceTag - Interface Identifier; unique identifier of an
+ interface
+ selectedDevicePasswordId - Selected password type
+ selectedConfigMethod - Selected WPS configuration method type
+ pin - PIN value.
+ Relevant if selected device password ID is PIN.4
+ digit pin is passed by sending the pin digits in
+ pin[0]..pin[3] and rest of the contents filled
+ with '-'.
+
+*******************************************************************************/
+#define CsrWifiNmeApWpsRegisterReqCreate(msg__, dst__, src__, interfaceTag__, selectedDevicePasswordId__, selectedConfigMethod__, pin__) \
+ msg__ = kmalloc(sizeof(CsrWifiNmeApWpsRegisterReq), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_NME_AP_PRIM, CSR_WIFI_NME_AP_WPS_REGISTER_REQ, dst__, src__); \
+ msg__->interfaceTag = (interfaceTag__); \
+ msg__->selectedDevicePasswordId = (selectedDevicePasswordId__); \
+ msg__->selectedConfigMethod = (selectedConfigMethod__); \
+ memcpy(msg__->pin, (pin__), sizeof(u8) * 8);
+
+#define CsrWifiNmeApWpsRegisterReqSendTo(dst__, src__, interfaceTag__, selectedDevicePasswordId__, selectedConfigMethod__, pin__) \
+ { \
+ CsrWifiNmeApWpsRegisterReq *msg__; \
+ CsrWifiNmeApWpsRegisterReqCreate(msg__, dst__, src__, interfaceTag__, selectedDevicePasswordId__, selectedConfigMethod__, pin__); \
+ CsrMsgTransport(dst__, CSR_WIFI_NME_AP_PRIM, msg__); \
+ }
+
+#define CsrWifiNmeApWpsRegisterReqSend(src__, interfaceTag__, selectedDevicePasswordId__, selectedConfigMethod__, pin__) \
+ CsrWifiNmeApWpsRegisterReqSendTo(CSR_WIFI_NME_IFACEQUEUE, src__, interfaceTag__, selectedDevicePasswordId__, selectedConfigMethod__, pin__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiNmeApWpsRegisterCfmSend
+
+ DESCRIPTION
+ This primitive reports the result of WPS procedure.
+
+ PARAMETERS
+ queue - Destination Task Queue
+ interfaceTag - Interface identifier; unique identifier of an interface
+ status - Status of the request.
+
+*******************************************************************************/
+#define CsrWifiNmeApWpsRegisterCfmCreate(msg__, dst__, src__, interfaceTag__, status__) \
+ msg__ = kmalloc(sizeof(CsrWifiNmeApWpsRegisterCfm), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_NME_AP_PRIM, CSR_WIFI_NME_AP_WPS_REGISTER_CFM, dst__, src__); \
+ msg__->interfaceTag = (interfaceTag__); \
+ msg__->status = (status__);
+
+#define CsrWifiNmeApWpsRegisterCfmSendTo(dst__, src__, interfaceTag__, status__) \
+ { \
+ CsrWifiNmeApWpsRegisterCfm *msg__; \
+ CsrWifiNmeApWpsRegisterCfmCreate(msg__, dst__, src__, interfaceTag__, status__); \
+ CsrSchedMessagePut(dst__, CSR_WIFI_NME_AP_PRIM, msg__); \
+ }
+
+#define CsrWifiNmeApWpsRegisterCfmSend(dst__, interfaceTag__, status__) \
+ CsrWifiNmeApWpsRegisterCfmSendTo(dst__, CSR_WIFI_NME_IFACEQUEUE, interfaceTag__, status__)
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* CSR_WIFI_NME_AP_LIB_H__ */
diff --git a/drivers/staging/csr/csr_wifi_nme_ap_prim.h b/drivers/staging/csr/csr_wifi_nme_ap_prim.h
new file mode 100644
index 000000000000..fc44560b28b8
--- /dev/null
+++ b/drivers/staging/csr/csr_wifi_nme_ap_prim.h
@@ -0,0 +1,503 @@
+/*****************************************************************************
+
+ (c) Cambridge Silicon Radio Limited 2012
+ All rights reserved and confidential information of CSR
+
+ Refer to LICENSE.txt included with this source for details
+ on the license terms.
+
+*****************************************************************************/
+
+/* Note: this is an auto-generated file. */
+
+#ifndef CSR_WIFI_NME_AP_PRIM_H__
+#define CSR_WIFI_NME_AP_PRIM_H__
+
+#include <linux/types.h>
+#include "csr_prim_defs.h"
+#include "csr_sched.h"
+#include "csr_wifi_common.h"
+#include "csr_result.h"
+#include "csr_wifi_fsm_event.h"
+#include "csr_wifi_sme_ap_prim.h"
+#include "csr_wifi_nme_prim.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef CSR_WIFI_NME_ENABLE
+#error CSR_WIFI_NME_ENABLE MUST be defined inorder to use csr_wifi_nme_ap_prim.h
+#endif
+#ifndef CSR_WIFI_AP_ENABLE
+#error CSR_WIFI_AP_ENABLE MUST be defined inorder to use csr_wifi_nme_ap_prim.h
+#endif
+
+#define CSR_WIFI_NME_AP_PRIM (0x0426)
+
+typedef CsrPrim CsrWifiNmeApPrim;
+
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiNmeApPersCredentialType
+
+ DESCRIPTION
+ NME Credential Types
+
+ VALUES
+ CSR_WIFI_NME_AP_CREDENTIAL_TYPE_PSK
+ - Use PSK as credential.
+ CSR_WIFI_NME_AP_CREDENTIAL_TYPE_PASSPHRASE
+ - Use the specified passphrase as credential
+
+*******************************************************************************/
+typedef u8 CsrWifiNmeApPersCredentialType;
+#define CSR_WIFI_NME_AP_CREDENTIAL_TYPE_PSK ((CsrWifiNmeApPersCredentialType) 0x00)
+#define CSR_WIFI_NME_AP_CREDENTIAL_TYPE_PASSPHRASE ((CsrWifiNmeApPersCredentialType) 0x01)
+
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiNmeApConfig
+
+ DESCRIPTION
+ Structure holding AP config data.
+
+ MEMBERS
+ apGroupkeyTimeout - Access point group key timeout.
+ apStrictGtkRekey - Access point strict GTK rekey flag. If set TRUE, the AP
+ shall rekey GTK every time a connected STA leaves BSS.
+ apGmkTimeout - Access point GMK timeout
+ apResponseTimeout - Response timeout
+ apRetransLimit - Max allowed retransmissions
+
+*******************************************************************************/
+typedef struct
+{
+ u16 apGroupkeyTimeout;
+ u8 apStrictGtkRekey;
+ u16 apGmkTimeout;
+ u16 apResponseTimeout;
+ u8 apRetransLimit;
+} CsrWifiNmeApConfig;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiNmeApAuthPers
+
+ DESCRIPTION
+
+ MEMBERS
+ authSupport - Credential type value (as defined in the
+ enumeration type).
+ rsnCapabilities - RSN capabilities mask
+ wapiCapabilities - WAPI capabilities mask
+ pskOrPassphrase - Credential type value (as defined in the
+ enumeration type).
+ authPers_credentials - Union containing credentials which depends
+ on credentialType parameter.
+ authPers_credentialspsk -
+ authPers_credentialspassphrase -
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiSmeApAuthSupportMask authSupport;
+ CsrWifiSmeApRsnCapabilitiesMask rsnCapabilities;
+ CsrWifiSmeApWapiCapabilitiesMask wapiCapabilities;
+ CsrWifiNmeApPersCredentialType pskOrPassphrase;
+ union {
+ CsrWifiNmePsk psk;
+ CsrWifiNmePassphrase passphrase;
+ } authPers_credentials;
+} CsrWifiNmeApAuthPers;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiNmeApCredentials
+
+ DESCRIPTION
+ Structure containing the Credentials data.
+
+ MEMBERS
+ authType - Authentication type
+ nmeAuthType - Authentication parameters
+ nmeAuthTypeopenSystemEmpty -
+ nmeAuthTypeauthwep -
+ nmeAuthTypeauthTypePersonal -
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiSmeApAuthType authType;
+ union {
+ CsrWifiSmeEmpty openSystemEmpty;
+ CsrWifiSmeWepAuth authwep;
+ CsrWifiNmeApAuthPers authTypePersonal;
+ } nmeAuthType;
+} CsrWifiNmeApCredentials;
+
+
+/* Downstream */
+#define CSR_WIFI_NME_AP_PRIM_DOWNSTREAM_LOWEST (0x0000)
+
+#define CSR_WIFI_NME_AP_CONFIG_SET_REQ ((CsrWifiNmeApPrim) (0x0000 + CSR_WIFI_NME_AP_PRIM_DOWNSTREAM_LOWEST))
+#define CSR_WIFI_NME_AP_WPS_REGISTER_REQ ((CsrWifiNmeApPrim) (0x0001 + CSR_WIFI_NME_AP_PRIM_DOWNSTREAM_LOWEST))
+#define CSR_WIFI_NME_AP_START_REQ ((CsrWifiNmeApPrim) (0x0002 + CSR_WIFI_NME_AP_PRIM_DOWNSTREAM_LOWEST))
+#define CSR_WIFI_NME_AP_STOP_REQ ((CsrWifiNmeApPrim) (0x0003 + CSR_WIFI_NME_AP_PRIM_DOWNSTREAM_LOWEST))
+#define CSR_WIFI_NME_AP_WMM_PARAM_UPDATE_REQ ((CsrWifiNmeApPrim) (0x0004 + CSR_WIFI_NME_AP_PRIM_DOWNSTREAM_LOWEST))
+#define CSR_WIFI_NME_AP_STA_REMOVE_REQ ((CsrWifiNmeApPrim) (0x0005 + CSR_WIFI_NME_AP_PRIM_DOWNSTREAM_LOWEST))
+
+
+#define CSR_WIFI_NME_AP_PRIM_DOWNSTREAM_HIGHEST (0x0005 + CSR_WIFI_NME_AP_PRIM_DOWNSTREAM_LOWEST)
+
+/* Upstream */
+#define CSR_WIFI_NME_AP_PRIM_UPSTREAM_LOWEST (0x0000 + CSR_PRIM_UPSTREAM)
+
+#define CSR_WIFI_NME_AP_CONFIG_SET_CFM ((CsrWifiNmeApPrim)(0x0000 + CSR_WIFI_NME_AP_PRIM_UPSTREAM_LOWEST))
+#define CSR_WIFI_NME_AP_WPS_REGISTER_CFM ((CsrWifiNmeApPrim)(0x0001 + CSR_WIFI_NME_AP_PRIM_UPSTREAM_LOWEST))
+#define CSR_WIFI_NME_AP_START_CFM ((CsrWifiNmeApPrim)(0x0002 + CSR_WIFI_NME_AP_PRIM_UPSTREAM_LOWEST))
+#define CSR_WIFI_NME_AP_STOP_CFM ((CsrWifiNmeApPrim)(0x0003 + CSR_WIFI_NME_AP_PRIM_UPSTREAM_LOWEST))
+#define CSR_WIFI_NME_AP_STOP_IND ((CsrWifiNmeApPrim)(0x0004 + CSR_WIFI_NME_AP_PRIM_UPSTREAM_LOWEST))
+#define CSR_WIFI_NME_AP_WMM_PARAM_UPDATE_CFM ((CsrWifiNmeApPrim)(0x0005 + CSR_WIFI_NME_AP_PRIM_UPSTREAM_LOWEST))
+#define CSR_WIFI_NME_AP_STATION_IND ((CsrWifiNmeApPrim)(0x0006 + CSR_WIFI_NME_AP_PRIM_UPSTREAM_LOWEST))
+
+#define CSR_WIFI_NME_AP_PRIM_UPSTREAM_HIGHEST (0x0006 + CSR_WIFI_NME_AP_PRIM_UPSTREAM_LOWEST)
+
+#define CSR_WIFI_NME_AP_PRIM_DOWNSTREAM_COUNT (CSR_WIFI_NME_AP_PRIM_DOWNSTREAM_HIGHEST + 1 - CSR_WIFI_NME_AP_PRIM_DOWNSTREAM_LOWEST)
+#define CSR_WIFI_NME_AP_PRIM_UPSTREAM_COUNT (CSR_WIFI_NME_AP_PRIM_UPSTREAM_HIGHEST + 1 - CSR_WIFI_NME_AP_PRIM_UPSTREAM_LOWEST)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiNmeApConfigSetReq
+
+ DESCRIPTION
+ This primitive passes AP configuration info for NME. This can be sent at
+ any time but will be acted upon when the AP is started again. This
+ information is common to both P2P GO and AP
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ apConfig - AP configuration for the NME.
+ apMacConfig - MAC configuration to be acted on when
+ CSR_WIFI_NME_AP_START.request is sent.
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ CsrWifiNmeApConfig apConfig;
+ CsrWifiSmeApMacConfig apMacConfig;
+} CsrWifiNmeApConfigSetReq;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiNmeApWpsRegisterReq
+
+ DESCRIPTION
+ This primitive allows the NME to accept the WPS registration from an
+ enrollee. Such registration procedure can be cancelled by sending
+ CSR_WIFI_NME_WPS_CANCEL.request.
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ interfaceTag - Interface Identifier; unique identifier of an
+ interface
+ selectedDevicePasswordId - Selected password type
+ selectedConfigMethod - Selected WPS configuration method type
+ pin - PIN value.
+ Relevant if selected device password ID is PIN.4
+ digit pin is passed by sending the pin digits in
+ pin[0]..pin[3] and rest of the contents filled
+ with '-'.
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ u16 interfaceTag;
+ CsrWifiSmeWpsDpid selectedDevicePasswordId;
+ CsrWifiSmeWpsConfigType selectedConfigMethod;
+ u8 pin[8];
+} CsrWifiNmeApWpsRegisterReq;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiNmeApStartReq
+
+ DESCRIPTION
+ This primitive requests NME to started the AP operation.
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ interfaceTag - Interface identifier; unique identifier of an interface
+ apType - AP Type specifies the Legacy AP or P2P GO operation
+ cloakSsid - Indicates whether the SSID should be cloaked (hidden and
+ not broadcast in beacon) or not
+ ssid - Service Set Identifier
+ ifIndex - Radio interface
+ channel - Channel number of the channel to use
+ apCredentials - Security credential configuration.
+ maxConnections - Maximum number of stations/P2P clients allowed
+ p2pGoParam - P2P specific GO parameters.
+ wpsEnabled - Indicates whether WPS should be enabled or not
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ u16 interfaceTag;
+ CsrWifiSmeApType apType;
+ u8 cloakSsid;
+ CsrWifiSsid ssid;
+ CsrWifiSmeRadioIF ifIndex;
+ u8 channel;
+ CsrWifiNmeApCredentials apCredentials;
+ u8 maxConnections;
+ CsrWifiSmeApP2pGoConfig p2pGoParam;
+ u8 wpsEnabled;
+} CsrWifiNmeApStartReq;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiNmeApStopReq
+
+ DESCRIPTION
+ This primitive requests NME to stop the AP operation.
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ interfaceTag - Interface identifier; unique identifier of an interface
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ u16 interfaceTag;
+} CsrWifiNmeApStopReq;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiNmeApWmmParamUpdateReq
+
+ DESCRIPTION
+ Application uses this primitive to update the WMM parameters
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ wmmApParams - WMM Access point parameters per access category. The array
+ index corresponds to the ACI
+ wmmApBcParams - WMM station parameters per access category to be advertised
+ in the beacons and probe response The array index
+ corresponds to the ACI
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ CsrWifiSmeWmmAcParams wmmApParams[4];
+ CsrWifiSmeWmmAcParams wmmApBcParams[4];
+} CsrWifiNmeApWmmParamUpdateReq;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiNmeApStaRemoveReq
+
+ DESCRIPTION
+ This primitive disconnects a connected station. If keepBlocking is set to
+ TRUE, the station with the specified MAC address is not allowed to
+ connect. If the requested station is not already connected,it may be
+ blocked based on keepBlocking parameter.
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ interfaceTag - Interface Identifier; unique identifier of an interface
+ staMacAddress - Mac Address of the station to be disconnected or blocked
+ keepBlocking - If TRUE, the station is blocked. If FALSE and the station is
+ connected, disconnect the station. If FALSE and the station
+ is not connected, no action is taken.
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ u16 interfaceTag;
+ CsrWifiMacAddress staMacAddress;
+ u8 keepBlocking;
+} CsrWifiNmeApStaRemoveReq;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiNmeApConfigSetCfm
+
+ DESCRIPTION
+ This primitive reports the result of the request.
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ status - Status of the request.
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ CsrResult status;
+} CsrWifiNmeApConfigSetCfm;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiNmeApWpsRegisterCfm
+
+ DESCRIPTION
+ This primitive reports the result of WPS procedure.
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ interfaceTag - Interface identifier; unique identifier of an interface
+ status - Status of the request.
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ u16 interfaceTag;
+ CsrResult status;
+} CsrWifiNmeApWpsRegisterCfm;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiNmeApStartCfm
+
+ DESCRIPTION
+ This primitive reports the result of CSR_WIFI_NME_AP_START.request.
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ interfaceTag - Interface identifier; unique identifier of an interface
+ status - Status of the request.
+ ssid - Service Set Identifier
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ u16 interfaceTag;
+ CsrResult status;
+ CsrWifiSsid ssid;
+} CsrWifiNmeApStartCfm;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiNmeApStopCfm
+
+ DESCRIPTION
+ This primitive confirms that the AP operation is stopped. NME shall send
+ this primitive in response to the request even if AP operation has
+ already been stopped
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ interfaceTag - Interface identifier; unique identifier of an interface
+ status - Status of the request.
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ u16 interfaceTag;
+ CsrResult status;
+} CsrWifiNmeApStopCfm;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiNmeApStopInd
+
+ DESCRIPTION
+ Indicates that AP operation had stopped because of some unrecoverable
+ error after AP operation was started successfully. NME sends this signal
+ after failing to restart the AP operation internally following an error
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ interfaceTag - Interface Identifier; unique identifier of an interface
+ apType - Reports AP Type (P2PGO or AP)
+ status - Error Status
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ u16 interfaceTag;
+ CsrWifiSmeApType apType;
+ CsrResult status;
+} CsrWifiNmeApStopInd;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiNmeApWmmParamUpdateCfm
+
+ DESCRIPTION
+ A confirm for for the WMM parameters update
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ status - Status of the request.
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ CsrResult status;
+} CsrWifiNmeApWmmParamUpdateCfm;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiNmeApStationInd
+
+ DESCRIPTION
+ This primitive indicates that a station has joined or a previously joined
+ station has left the BSS/group
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ interfaceTag - Interface Identifier; unique identifier of an interface
+ mediaStatus - Indicates whether the station is connected or
+ disconnected
+ peerMacAddress - MAC address of the station
+ peerDeviceAddress - P2P Device Address
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ u16 interfaceTag;
+ CsrWifiSmeMediaStatus mediaStatus;
+ CsrWifiMacAddress peerMacAddress;
+ CsrWifiMacAddress peerDeviceAddress;
+} CsrWifiNmeApStationInd;
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* CSR_WIFI_NME_AP_PRIM_H__ */
+
diff --git a/drivers/staging/csr/csr_wifi_nme_ap_sef.c b/drivers/staging/csr/csr_wifi_nme_ap_sef.c
new file mode 100644
index 000000000000..e048848883d5
--- /dev/null
+++ b/drivers/staging/csr/csr_wifi_nme_ap_sef.c
@@ -0,0 +1,30 @@
+/*****************************************************************************
+
+ FILE: csr_wifi_nme_sef.c
+
+ (c) Cambridge Silicon Radio Limited 2010
+
+ Refer to LICENSE.txt included with this source for details
+ on the license terms.
+
+ *****************************************************************************/
+#include "csr_wifi_nme_ap_sef.h"
+#include "unifi_priv.h"
+
+void CsrWifiNmeApUpstreamStateHandlers(void* drvpriv, CsrWifiFsmEvent* msg)
+{
+ switch(msg->type) {
+ case CSR_WIFI_NME_AP_START_CFM:
+ CsrWifiNmeApStartCfmHandler(drvpriv, msg);
+ break;
+ case CSR_WIFI_NME_AP_STOP_CFM:
+ CsrWifiNmeApStopCfmHandler(drvpriv, msg);
+ break;
+ case CSR_WIFI_NME_AP_CONFIG_SET_CFM:
+ CsrWifiNmeApConfigSetCfmHandler(drvpriv,msg);
+ break;
+ default:
+ unifi_error(drvpriv, "CsrWifiNmeApUpstreamStateHandlers: unhandled NME_AP message type 0x%.4X\n",msg->type);
+ break;
+ }
+}
diff --git a/drivers/staging/csr/csr_wifi_nme_ap_sef.h b/drivers/staging/csr/csr_wifi_nme_ap_sef.h
new file mode 100644
index 000000000000..3f353633fa5e
--- /dev/null
+++ b/drivers/staging/csr/csr_wifi_nme_ap_sef.h
@@ -0,0 +1,31 @@
+/*****************************************************************************
+ FILE: csr_wifi_nme_sef.h
+ (c) Cambridge Silicon Radio Limited 2010
+
+ Refer to LICENSE.txt included with this source for details
+ on the license terms.
+
+*****************************************************************************/
+#ifndef CSR_WIFI_ROUTER_SEF_CSR_WIFI_NME_H__
+#define CSR_WIFI_ROUTER_SEF_CSR_WIFI_NME_H__
+
+#include "csr_wifi_nme_prim.h"
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void CsrWifiNmeApUpstreamStateHandlers(void* drvpriv, CsrWifiFsmEvent* msg);
+
+
+extern void CsrWifiNmeApConfigSetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg);
+extern void CsrWifiNmeApStartCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg);
+extern void CsrWifiNmeApStopCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* CSR_WIFI_ROUTER_SEF_CSR_WIFI_NME_H__ */
diff --git a/drivers/staging/csr/csr_wifi_nme_ap_serialize.c b/drivers/staging/csr/csr_wifi_nme_ap_serialize.c
new file mode 100644
index 000000000000..1a901a70d195
--- /dev/null
+++ b/drivers/staging/csr/csr_wifi_nme_ap_serialize.c
@@ -0,0 +1,909 @@
+/*****************************************************************************
+
+ (c) Cambridge Silicon Radio Limited 2012
+ All rights reserved and confidential information of CSR
+
+ Refer to LICENSE.txt included with this source for details
+ on the license terms.
+
+*****************************************************************************/
+
+/* Note: this is an auto-generated file. */
+#include <linux/string.h>
+#include <linux/slab.h>
+#include "csr_msgconv.h"
+
+#ifdef CSR_WIFI_NME_ENABLE
+#ifdef CSR_WIFI_AP_ENABLE
+
+#include "csr_wifi_nme_ap_prim.h"
+#include "csr_wifi_nme_ap_serialize.h"
+
+void CsrWifiNmeApPfree(void *ptr)
+{
+ kfree(ptr);
+}
+
+
+size_t CsrWifiNmeApConfigSetReqSizeof(void *msg)
+{
+ CsrWifiNmeApConfigSetReq *primitive = (CsrWifiNmeApConfigSetReq *) msg;
+ size_t bufferSize = 2;
+
+ /* Calculate the Size of the Serialised Data. Could be more efficient (Try 104) */
+ bufferSize += 2; /* u16 primitive->apConfig.apGroupkeyTimeout */
+ bufferSize += 1; /* u8 primitive->apConfig.apStrictGtkRekey */
+ bufferSize += 2; /* u16 primitive->apConfig.apGmkTimeout */
+ bufferSize += 2; /* u16 primitive->apConfig.apResponseTimeout */
+ bufferSize += 1; /* u8 primitive->apConfig.apRetransLimit */
+ bufferSize += 1; /* CsrWifiSmeApPhySupportMask primitive->apMacConfig.phySupportedBitmap */
+ bufferSize += 2; /* u16 primitive->apMacConfig.beaconInterval */
+ bufferSize += 1; /* u8 primitive->apMacConfig.dtimPeriod */
+ bufferSize += 2; /* u16 primitive->apMacConfig.maxListenInterval */
+ bufferSize += 1; /* u8 primitive->apMacConfig.supportedRatesCount */
+ bufferSize += 20; /* u8 primitive->apMacConfig.supportedRates[20] */
+ bufferSize += 1; /* CsrWifiSmePreambleType primitive->apMacConfig.preamble */
+ bufferSize += 1; /* u8 primitive->apMacConfig.shortSlotTimeEnabled */
+ bufferSize += 1; /* CsrWifiSmeCtsProtectionType primitive->apMacConfig.ctsProtectionType */
+ bufferSize += 1; /* u8 primitive->apMacConfig.wmmEnabled */
+ {
+ u16 i2;
+ for (i2 = 0; i2 < 4; i2++)
+ {
+ bufferSize += 1; /* u8 primitive->apMacConfig.wmmApParams[i2].cwMin */
+ bufferSize += 1; /* u8 primitive->apMacConfig.wmmApParams[i2].cwMax */
+ bufferSize += 1; /* u8 primitive->apMacConfig.wmmApParams[i2].aifs */
+ bufferSize += 2; /* u16 primitive->apMacConfig.wmmApParams[i2].txopLimit */
+ bufferSize += 1; /* u8 primitive->apMacConfig.wmmApParams[i2].admissionControlMandatory */
+ }
+ }
+ {
+ u16 i2;
+ for (i2 = 0; i2 < 4; i2++)
+ {
+ bufferSize += 1; /* u8 primitive->apMacConfig.wmmApBcParams[i2].cwMin */
+ bufferSize += 1; /* u8 primitive->apMacConfig.wmmApBcParams[i2].cwMax */
+ bufferSize += 1; /* u8 primitive->apMacConfig.wmmApBcParams[i2].aifs */
+ bufferSize += 2; /* u16 primitive->apMacConfig.wmmApBcParams[i2].txopLimit */
+ bufferSize += 1; /* u8 primitive->apMacConfig.wmmApBcParams[i2].admissionControlMandatory */
+ }
+ }
+ bufferSize += 1; /* CsrWifiSmeApAccessType primitive->apMacConfig.accessType */
+ bufferSize += 1; /* u8 primitive->apMacConfig.macAddressListCount */
+ {
+ u16 i2;
+ for (i2 = 0; i2 < primitive->apMacConfig.macAddressListCount; i2++)
+ {
+ bufferSize += 6; /* u8 primitive->apMacConfig.macAddressList[i2].a[6] */
+ }
+ }
+ bufferSize += 1; /* u8 primitive->apMacConfig.apHtParams.greenfieldSupported */
+ bufferSize += 1; /* u8 primitive->apMacConfig.apHtParams.shortGi20MHz */
+ bufferSize += 1; /* u8 primitive->apMacConfig.apHtParams.rxStbc */
+ bufferSize += 1; /* u8 primitive->apMacConfig.apHtParams.rifsModeAllowed */
+ bufferSize += 1; /* u8 primitive->apMacConfig.apHtParams.htProtection */
+ bufferSize += 1; /* u8 primitive->apMacConfig.apHtParams.dualCtsProtection */
+ return bufferSize;
+}
+
+
+u8* CsrWifiNmeApConfigSetReqSer(u8 *ptr, size_t *len, void *msg)
+{
+ CsrWifiNmeApConfigSetReq *primitive = (CsrWifiNmeApConfigSetReq *)msg;
+ *len = 0;
+ CsrUint16Ser(ptr, len, primitive->common.type);
+ CsrUint16Ser(ptr, len, (u16) primitive->apConfig.apGroupkeyTimeout);
+ CsrUint8Ser(ptr, len, (u8) primitive->apConfig.apStrictGtkRekey);
+ CsrUint16Ser(ptr, len, (u16) primitive->apConfig.apGmkTimeout);
+ CsrUint16Ser(ptr, len, (u16) primitive->apConfig.apResponseTimeout);
+ CsrUint8Ser(ptr, len, (u8) primitive->apConfig.apRetransLimit);
+ CsrUint8Ser(ptr, len, (u8) primitive->apMacConfig.phySupportedBitmap);
+ CsrUint16Ser(ptr, len, (u16) primitive->apMacConfig.beaconInterval);
+ CsrUint8Ser(ptr, len, (u8) primitive->apMacConfig.dtimPeriod);
+ CsrUint16Ser(ptr, len, (u16) primitive->apMacConfig.maxListenInterval);
+ CsrUint8Ser(ptr, len, (u8) primitive->apMacConfig.supportedRatesCount);
+ CsrMemCpySer(ptr, len, (const void *) primitive->apMacConfig.supportedRates, ((u16) (20)));
+ CsrUint8Ser(ptr, len, (u8) primitive->apMacConfig.preamble);
+ CsrUint8Ser(ptr, len, (u8) primitive->apMacConfig.shortSlotTimeEnabled);
+ CsrUint8Ser(ptr, len, (u8) primitive->apMacConfig.ctsProtectionType);
+ CsrUint8Ser(ptr, len, (u8) primitive->apMacConfig.wmmEnabled);
+ {
+ u16 i2;
+ for (i2 = 0; i2 < 4; i2++)
+ {
+ CsrUint8Ser(ptr, len, (u8) primitive->apMacConfig.wmmApParams[i2].cwMin);
+ CsrUint8Ser(ptr, len, (u8) primitive->apMacConfig.wmmApParams[i2].cwMax);
+ CsrUint8Ser(ptr, len, (u8) primitive->apMacConfig.wmmApParams[i2].aifs);
+ CsrUint16Ser(ptr, len, (u16) primitive->apMacConfig.wmmApParams[i2].txopLimit);
+ CsrUint8Ser(ptr, len, (u8) primitive->apMacConfig.wmmApParams[i2].admissionControlMandatory);
+ }
+ }
+ {
+ u16 i2;
+ for (i2 = 0; i2 < 4; i2++)
+ {
+ CsrUint8Ser(ptr, len, (u8) primitive->apMacConfig.wmmApBcParams[i2].cwMin);
+ CsrUint8Ser(ptr, len, (u8) primitive->apMacConfig.wmmApBcParams[i2].cwMax);
+ CsrUint8Ser(ptr, len, (u8) primitive->apMacConfig.wmmApBcParams[i2].aifs);
+ CsrUint16Ser(ptr, len, (u16) primitive->apMacConfig.wmmApBcParams[i2].txopLimit);
+ CsrUint8Ser(ptr, len, (u8) primitive->apMacConfig.wmmApBcParams[i2].admissionControlMandatory);
+ }
+ }
+ CsrUint8Ser(ptr, len, (u8) primitive->apMacConfig.accessType);
+ CsrUint8Ser(ptr, len, (u8) primitive->apMacConfig.macAddressListCount);
+ {
+ u16 i2;
+ for (i2 = 0; i2 < primitive->apMacConfig.macAddressListCount; i2++)
+ {
+ CsrMemCpySer(ptr, len, (const void *) primitive->apMacConfig.macAddressList[i2].a, ((u16) (6)));
+ }
+ }
+ CsrUint8Ser(ptr, len, (u8) primitive->apMacConfig.apHtParams.greenfieldSupported);
+ CsrUint8Ser(ptr, len, (u8) primitive->apMacConfig.apHtParams.shortGi20MHz);
+ CsrUint8Ser(ptr, len, (u8) primitive->apMacConfig.apHtParams.rxStbc);
+ CsrUint8Ser(ptr, len, (u8) primitive->apMacConfig.apHtParams.rifsModeAllowed);
+ CsrUint8Ser(ptr, len, (u8) primitive->apMacConfig.apHtParams.htProtection);
+ CsrUint8Ser(ptr, len, (u8) primitive->apMacConfig.apHtParams.dualCtsProtection);
+ return(ptr);
+}
+
+
+void* CsrWifiNmeApConfigSetReqDes(u8 *buffer, size_t length)
+{
+ CsrWifiNmeApConfigSetReq *primitive = kmalloc(sizeof(CsrWifiNmeApConfigSetReq), GFP_KERNEL);
+ size_t offset;
+ offset = 0;
+
+ CsrUint16Des(&primitive->common.type, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->apConfig.apGroupkeyTimeout, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->apConfig.apStrictGtkRekey, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->apConfig.apGmkTimeout, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->apConfig.apResponseTimeout, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->apConfig.apRetransLimit, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->apMacConfig.phySupportedBitmap, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->apMacConfig.beaconInterval, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->apMacConfig.dtimPeriod, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->apMacConfig.maxListenInterval, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->apMacConfig.supportedRatesCount, buffer, &offset);
+ CsrMemCpyDes(primitive->apMacConfig.supportedRates, buffer, &offset, ((u16) (20)));
+ CsrUint8Des((u8 *) &primitive->apMacConfig.preamble, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->apMacConfig.shortSlotTimeEnabled, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->apMacConfig.ctsProtectionType, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->apMacConfig.wmmEnabled, buffer, &offset);
+ {
+ u16 i2;
+ for (i2 = 0; i2 < 4; i2++)
+ {
+ CsrUint8Des((u8 *) &primitive->apMacConfig.wmmApParams[i2].cwMin, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->apMacConfig.wmmApParams[i2].cwMax, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->apMacConfig.wmmApParams[i2].aifs, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->apMacConfig.wmmApParams[i2].txopLimit, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->apMacConfig.wmmApParams[i2].admissionControlMandatory, buffer, &offset);
+ }
+ }
+ {
+ u16 i2;
+ for (i2 = 0; i2 < 4; i2++)
+ {
+ CsrUint8Des((u8 *) &primitive->apMacConfig.wmmApBcParams[i2].cwMin, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->apMacConfig.wmmApBcParams[i2].cwMax, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->apMacConfig.wmmApBcParams[i2].aifs, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->apMacConfig.wmmApBcParams[i2].txopLimit, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->apMacConfig.wmmApBcParams[i2].admissionControlMandatory, buffer, &offset);
+ }
+ }
+ CsrUint8Des((u8 *) &primitive->apMacConfig.accessType, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->apMacConfig.macAddressListCount, buffer, &offset);
+ primitive->apMacConfig.macAddressList = NULL;
+ if (primitive->apMacConfig.macAddressListCount)
+ {
+ primitive->apMacConfig.macAddressList = kmalloc(sizeof(CsrWifiMacAddress) * primitive->apMacConfig.macAddressListCount, GFP_KERNEL);
+ }
+ {
+ u16 i2;
+ for (i2 = 0; i2 < primitive->apMacConfig.macAddressListCount; i2++)
+ {
+ CsrMemCpyDes(primitive->apMacConfig.macAddressList[i2].a, buffer, &offset, ((u16) (6)));
+ }
+ }
+ CsrUint8Des((u8 *) &primitive->apMacConfig.apHtParams.greenfieldSupported, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->apMacConfig.apHtParams.shortGi20MHz, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->apMacConfig.apHtParams.rxStbc, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->apMacConfig.apHtParams.rifsModeAllowed, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->apMacConfig.apHtParams.htProtection, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->apMacConfig.apHtParams.dualCtsProtection, buffer, &offset);
+
+ return primitive;
+}
+
+
+void CsrWifiNmeApConfigSetReqSerFree(void *voidPrimitivePointer)
+{
+ CsrWifiNmeApConfigSetReq *primitive = (CsrWifiNmeApConfigSetReq *) voidPrimitivePointer;
+ kfree(primitive->apMacConfig.macAddressList);
+ kfree(primitive);
+}
+
+
+size_t CsrWifiNmeApWpsRegisterReqSizeof(void *msg)
+{
+ size_t bufferSize = 2;
+
+ /* Calculate the Size of the Serialised Data. Could be more efficient (Try 17) */
+ bufferSize += 2; /* u16 primitive->interfaceTag */
+ bufferSize += 2; /* CsrWifiSmeWpsDpid primitive->selectedDevicePasswordId */
+ bufferSize += 2; /* CsrWifiSmeWpsConfigType primitive->selectedConfigMethod */
+ bufferSize += 8; /* u8 primitive->pin[8] */
+ return bufferSize;
+}
+
+
+u8* CsrWifiNmeApWpsRegisterReqSer(u8 *ptr, size_t *len, void *msg)
+{
+ CsrWifiNmeApWpsRegisterReq *primitive = (CsrWifiNmeApWpsRegisterReq *)msg;
+ *len = 0;
+ CsrUint16Ser(ptr, len, primitive->common.type);
+ CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
+ CsrUint16Ser(ptr, len, (u16) primitive->selectedDevicePasswordId);
+ CsrUint16Ser(ptr, len, (u16) primitive->selectedConfigMethod);
+ CsrMemCpySer(ptr, len, (const void *) primitive->pin, ((u16) (8)));
+ return(ptr);
+}
+
+
+void* CsrWifiNmeApWpsRegisterReqDes(u8 *buffer, size_t length)
+{
+ CsrWifiNmeApWpsRegisterReq *primitive = kmalloc(sizeof(CsrWifiNmeApWpsRegisterReq), GFP_KERNEL);
+ size_t offset;
+ offset = 0;
+
+ CsrUint16Des(&primitive->common.type, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->selectedDevicePasswordId, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->selectedConfigMethod, buffer, &offset);
+ CsrMemCpyDes(primitive->pin, buffer, &offset, ((u16) (8)));
+
+ return primitive;
+}
+
+
+size_t CsrWifiNmeApStartReqSizeof(void *msg)
+{
+ CsrWifiNmeApStartReq *primitive = (CsrWifiNmeApStartReq *) msg;
+ size_t bufferSize = 2;
+
+ /* Calculate the Size of the Serialised Data. Could be more efficient (Try 112) */
+ bufferSize += 2; /* u16 primitive->interfaceTag */
+ bufferSize += 1; /* CsrWifiSmeApType primitive->apType */
+ bufferSize += 1; /* u8 primitive->cloakSsid */
+ bufferSize += 32; /* u8 primitive->ssid.ssid[32] */
+ bufferSize += 1; /* u8 primitive->ssid.length */
+ bufferSize += 1; /* CsrWifiSmeRadioIF primitive->ifIndex */
+ bufferSize += 1; /* u8 primitive->channel */
+ bufferSize += 1; /* CsrWifiSmeApAuthType primitive->apCredentials.authType */
+ switch (primitive->apCredentials.authType)
+ {
+ case CSR_WIFI_SME_AP_AUTH_TYPE_OPEN_SYSTEM:
+ bufferSize += 1; /* u8 primitive->apCredentials.nmeAuthType.openSystemEmpty.empty */
+ break;
+ case CSR_WIFI_SME_AP_AUTH_TYPE_WEP:
+ bufferSize += 1; /* CsrWifiSmeWepCredentialType primitive->apCredentials.nmeAuthType.authwep.wepKeyType */
+ switch (primitive->apCredentials.nmeAuthType.authwep.wepKeyType)
+ {
+ case CSR_WIFI_SME_CREDENTIAL_TYPE_WEP128:
+ bufferSize += 1; /* CsrWifiSmeWepAuthMode primitive->apCredentials.nmeAuthType.authwep.wepCredentials.wep128Key.wepAuthType */
+ bufferSize += 1; /* u8 primitive->apCredentials.nmeAuthType.authwep.wepCredentials.wep128Key.selectedWepKey */
+ bufferSize += 13; /* u8 primitive->apCredentials.nmeAuthType.authwep.wepCredentials.wep128Key.key1[13] */
+ bufferSize += 13; /* u8 primitive->apCredentials.nmeAuthType.authwep.wepCredentials.wep128Key.key2[13] */
+ bufferSize += 13; /* u8 primitive->apCredentials.nmeAuthType.authwep.wepCredentials.wep128Key.key3[13] */
+ bufferSize += 13; /* u8 primitive->apCredentials.nmeAuthType.authwep.wepCredentials.wep128Key.key4[13] */
+ break;
+ case CSR_WIFI_SME_CREDENTIAL_TYPE_WEP64:
+ bufferSize += 1; /* CsrWifiSmeWepAuthMode primitive->apCredentials.nmeAuthType.authwep.wepCredentials.wep64Key.wepAuthType */
+ bufferSize += 1; /* u8 primitive->apCredentials.nmeAuthType.authwep.wepCredentials.wep64Key.selectedWepKey */
+ bufferSize += 5; /* u8 primitive->apCredentials.nmeAuthType.authwep.wepCredentials.wep64Key.key1[5] */
+ bufferSize += 5; /* u8 primitive->apCredentials.nmeAuthType.authwep.wepCredentials.wep64Key.key2[5] */
+ bufferSize += 5; /* u8 primitive->apCredentials.nmeAuthType.authwep.wepCredentials.wep64Key.key3[5] */
+ bufferSize += 5; /* u8 primitive->apCredentials.nmeAuthType.authwep.wepCredentials.wep64Key.key4[5] */
+ break;
+ default:
+ break;
+ }
+ break;
+ case CSR_WIFI_SME_AP_AUTH_TYPE_PERSONAL:
+ bufferSize += 1; /* CsrWifiSmeApAuthSupportMask primitive->apCredentials.nmeAuthType.authTypePersonal.authSupport */
+ bufferSize += 2; /* CsrWifiSmeApRsnCapabilitiesMask primitive->apCredentials.nmeAuthType.authTypePersonal.rsnCapabilities */
+ bufferSize += 2; /* CsrWifiSmeApWapiCapabilitiesMask primitive->apCredentials.nmeAuthType.authTypePersonal.wapiCapabilities */
+ bufferSize += 1; /* CsrWifiNmeApPersCredentialType primitive->apCredentials.nmeAuthType.authTypePersonal.pskOrPassphrase */
+ switch (primitive->apCredentials.nmeAuthType.authTypePersonal.pskOrPassphrase)
+ {
+ case CSR_WIFI_NME_AP_CREDENTIAL_TYPE_PSK:
+ bufferSize += 2; /* u16 primitive->apCredentials.nmeAuthType.authTypePersonal.authPers_credentials.psk.encryptionMode */
+ bufferSize += 32; /* u8 primitive->apCredentials.nmeAuthType.authTypePersonal.authPers_credentials.psk.psk[32] */
+ break;
+ case CSR_WIFI_NME_AP_CREDENTIAL_TYPE_PASSPHRASE:
+ bufferSize += 2; /* u16 primitive->apCredentials.nmeAuthType.authTypePersonal.authPers_credentials.passphrase.encryptionMode */
+ bufferSize += (primitive->apCredentials.nmeAuthType.authTypePersonal.authPers_credentials.passphrase.passphrase ? strlen(primitive->apCredentials.nmeAuthType.authTypePersonal.authPers_credentials.passphrase.passphrase) : 0) + 1; /* char* primitive->apCredentials.nmeAuthType.authTypePersonal.authPers_credentials.passphrase.passphrase (0 byte len + 1 for NULL Term) */
+ break;
+ default:
+ break;
+ }
+ break;
+ default:
+ break;
+ }
+ bufferSize += 1; /* u8 primitive->maxConnections */
+ bufferSize += 1; /* CsrWifiSmeP2pGroupCapabilityMask primitive->p2pGoParam.groupCapability */
+ bufferSize += 3; /* u8 primitive->p2pGoParam.operatingChanList.country[3] */
+ bufferSize += 1; /* u8 primitive->p2pGoParam.operatingChanList.channelEntryListCount */
+ {
+ u16 i3;
+ for (i3 = 0; i3 < primitive->p2pGoParam.operatingChanList.channelEntryListCount; i3++)
+ {
+ bufferSize += 1; /* u8 primitive->p2pGoParam.operatingChanList.channelEntryList[i3].operatingClass */
+ bufferSize += 1; /* u8 primitive->p2pGoParam.operatingChanList.channelEntryList[i3].operatingChannelCount */
+ bufferSize += primitive->p2pGoParam.operatingChanList.channelEntryList[i3].operatingChannelCount; /* u8 primitive->p2pGoParam.operatingChanList.channelEntryList[i3].operatingChannel */
+ }
+ }
+ bufferSize += 1; /* u8 primitive->p2pGoParam.opPsEnabled */
+ bufferSize += 1; /* u8 primitive->p2pGoParam.ctWindow */
+ bufferSize += 1; /* CsrWifiSmeP2pNoaConfigMethod primitive->p2pGoParam.noaConfigMethod */
+ bufferSize += 1; /* u8 primitive->p2pGoParam.allowNoaWithNonP2pDevices */
+ bufferSize += 1; /* u8 primitive->wpsEnabled */
+ return bufferSize;
+}
+
+
+u8* CsrWifiNmeApStartReqSer(u8 *ptr, size_t *len, void *msg)
+{
+ CsrWifiNmeApStartReq *primitive = (CsrWifiNmeApStartReq *)msg;
+ *len = 0;
+ CsrUint16Ser(ptr, len, primitive->common.type);
+ CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
+ CsrUint8Ser(ptr, len, (u8) primitive->apType);
+ CsrUint8Ser(ptr, len, (u8) primitive->cloakSsid);
+ CsrMemCpySer(ptr, len, (const void *) primitive->ssid.ssid, ((u16) (32)));
+ CsrUint8Ser(ptr, len, (u8) primitive->ssid.length);
+ CsrUint8Ser(ptr, len, (u8) primitive->ifIndex);
+ CsrUint8Ser(ptr, len, (u8) primitive->channel);
+ CsrUint8Ser(ptr, len, (u8) primitive->apCredentials.authType);
+ switch (primitive->apCredentials.authType)
+ {
+ case CSR_WIFI_SME_AP_AUTH_TYPE_OPEN_SYSTEM:
+ CsrUint8Ser(ptr, len, (u8) primitive->apCredentials.nmeAuthType.openSystemEmpty.empty);
+ break;
+ case CSR_WIFI_SME_AP_AUTH_TYPE_WEP:
+ CsrUint8Ser(ptr, len, (u8) primitive->apCredentials.nmeAuthType.authwep.wepKeyType);
+ switch (primitive->apCredentials.nmeAuthType.authwep.wepKeyType)
+ {
+ case CSR_WIFI_SME_CREDENTIAL_TYPE_WEP128:
+ CsrUint8Ser(ptr, len, (u8) primitive->apCredentials.nmeAuthType.authwep.wepCredentials.wep128Key.wepAuthType);
+ CsrUint8Ser(ptr, len, (u8) primitive->apCredentials.nmeAuthType.authwep.wepCredentials.wep128Key.selectedWepKey);
+ CsrMemCpySer(ptr, len, (const void *) primitive->apCredentials.nmeAuthType.authwep.wepCredentials.wep128Key.key1, ((u16) (13)));
+ CsrMemCpySer(ptr, len, (const void *) primitive->apCredentials.nmeAuthType.authwep.wepCredentials.wep128Key.key2, ((u16) (13)));
+ CsrMemCpySer(ptr, len, (const void *) primitive->apCredentials.nmeAuthType.authwep.wepCredentials.wep128Key.key3, ((u16) (13)));
+ CsrMemCpySer(ptr, len, (const void *) primitive->apCredentials.nmeAuthType.authwep.wepCredentials.wep128Key.key4, ((u16) (13)));
+ break;
+ case CSR_WIFI_SME_CREDENTIAL_TYPE_WEP64:
+ CsrUint8Ser(ptr, len, (u8) primitive->apCredentials.nmeAuthType.authwep.wepCredentials.wep64Key.wepAuthType);
+ CsrUint8Ser(ptr, len, (u8) primitive->apCredentials.nmeAuthType.authwep.wepCredentials.wep64Key.selectedWepKey);
+ CsrMemCpySer(ptr, len, (const void *) primitive->apCredentials.nmeAuthType.authwep.wepCredentials.wep64Key.key1, ((u16) (5)));
+ CsrMemCpySer(ptr, len, (const void *) primitive->apCredentials.nmeAuthType.authwep.wepCredentials.wep64Key.key2, ((u16) (5)));
+ CsrMemCpySer(ptr, len, (const void *) primitive->apCredentials.nmeAuthType.authwep.wepCredentials.wep64Key.key3, ((u16) (5)));
+ CsrMemCpySer(ptr, len, (const void *) primitive->apCredentials.nmeAuthType.authwep.wepCredentials.wep64Key.key4, ((u16) (5)));
+ break;
+ default:
+ break;
+ }
+ break;
+ case CSR_WIFI_SME_AP_AUTH_TYPE_PERSONAL:
+ CsrUint8Ser(ptr, len, (u8) primitive->apCredentials.nmeAuthType.authTypePersonal.authSupport);
+ CsrUint16Ser(ptr, len, (u16) primitive->apCredentials.nmeAuthType.authTypePersonal.rsnCapabilities);
+ CsrUint16Ser(ptr, len, (u16) primitive->apCredentials.nmeAuthType.authTypePersonal.wapiCapabilities);
+ CsrUint8Ser(ptr, len, (u8) primitive->apCredentials.nmeAuthType.authTypePersonal.pskOrPassphrase);
+ switch (primitive->apCredentials.nmeAuthType.authTypePersonal.pskOrPassphrase)
+ {
+ case CSR_WIFI_NME_AP_CREDENTIAL_TYPE_PSK:
+ CsrUint16Ser(ptr, len, (u16) primitive->apCredentials.nmeAuthType.authTypePersonal.authPers_credentials.psk.encryptionMode);
+ CsrMemCpySer(ptr, len, (const void *) primitive->apCredentials.nmeAuthType.authTypePersonal.authPers_credentials.psk.psk, ((u16) (32)));
+ break;
+ case CSR_WIFI_NME_AP_CREDENTIAL_TYPE_PASSPHRASE:
+ CsrUint16Ser(ptr, len, (u16) primitive->apCredentials.nmeAuthType.authTypePersonal.authPers_credentials.passphrase.encryptionMode);
+ CsrCharStringSer(ptr, len, primitive->apCredentials.nmeAuthType.authTypePersonal.authPers_credentials.passphrase.passphrase);
+ break;
+ default:
+ break;
+ }
+ break;
+ default:
+ break;
+ }
+ CsrUint8Ser(ptr, len, (u8) primitive->maxConnections);
+ CsrUint8Ser(ptr, len, (u8) primitive->p2pGoParam.groupCapability);
+ CsrMemCpySer(ptr, len, (const void *) primitive->p2pGoParam.operatingChanList.country, ((u16) (3)));
+ CsrUint8Ser(ptr, len, (u8) primitive->p2pGoParam.operatingChanList.channelEntryListCount);
+ {
+ u16 i3;
+ for (i3 = 0; i3 < primitive->p2pGoParam.operatingChanList.channelEntryListCount; i3++)
+ {
+ CsrUint8Ser(ptr, len, (u8) primitive->p2pGoParam.operatingChanList.channelEntryList[i3].operatingClass);
+ CsrUint8Ser(ptr, len, (u8) primitive->p2pGoParam.operatingChanList.channelEntryList[i3].operatingChannelCount);
+ if (primitive->p2pGoParam.operatingChanList.channelEntryList[i3].operatingChannelCount)
+ {
+ CsrMemCpySer(ptr, len, (const void *) primitive->p2pGoParam.operatingChanList.channelEntryList[i3].operatingChannel, ((u16) (primitive->p2pGoParam.operatingChanList.channelEntryList[i3].operatingChannelCount)));
+ }
+ }
+ }
+ CsrUint8Ser(ptr, len, (u8) primitive->p2pGoParam.opPsEnabled);
+ CsrUint8Ser(ptr, len, (u8) primitive->p2pGoParam.ctWindow);
+ CsrUint8Ser(ptr, len, (u8) primitive->p2pGoParam.noaConfigMethod);
+ CsrUint8Ser(ptr, len, (u8) primitive->p2pGoParam.allowNoaWithNonP2pDevices);
+ CsrUint8Ser(ptr, len, (u8) primitive->wpsEnabled);
+ return(ptr);
+}
+
+
+void* CsrWifiNmeApStartReqDes(u8 *buffer, size_t length)
+{
+ CsrWifiNmeApStartReq *primitive = kmalloc(sizeof(CsrWifiNmeApStartReq), GFP_KERNEL);
+ size_t offset;
+ offset = 0;
+
+ CsrUint16Des(&primitive->common.type, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->apType, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->cloakSsid, buffer, &offset);
+ CsrMemCpyDes(primitive->ssid.ssid, buffer, &offset, ((u16) (32)));
+ CsrUint8Des((u8 *) &primitive->ssid.length, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->ifIndex, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->channel, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->apCredentials.authType, buffer, &offset);
+ switch (primitive->apCredentials.authType)
+ {
+ case CSR_WIFI_SME_AP_AUTH_TYPE_OPEN_SYSTEM:
+ CsrUint8Des((u8 *) &primitive->apCredentials.nmeAuthType.openSystemEmpty.empty, buffer, &offset);
+ break;
+ case CSR_WIFI_SME_AP_AUTH_TYPE_WEP:
+ CsrUint8Des((u8 *) &primitive->apCredentials.nmeAuthType.authwep.wepKeyType, buffer, &offset);
+ switch (primitive->apCredentials.nmeAuthType.authwep.wepKeyType)
+ {
+ case CSR_WIFI_SME_CREDENTIAL_TYPE_WEP128:
+ CsrUint8Des((u8 *) &primitive->apCredentials.nmeAuthType.authwep.wepCredentials.wep128Key.wepAuthType, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->apCredentials.nmeAuthType.authwep.wepCredentials.wep128Key.selectedWepKey, buffer, &offset);
+ CsrMemCpyDes(primitive->apCredentials.nmeAuthType.authwep.wepCredentials.wep128Key.key1, buffer, &offset, ((u16) (13)));
+ CsrMemCpyDes(primitive->apCredentials.nmeAuthType.authwep.wepCredentials.wep128Key.key2, buffer, &offset, ((u16) (13)));
+ CsrMemCpyDes(primitive->apCredentials.nmeAuthType.authwep.wepCredentials.wep128Key.key3, buffer, &offset, ((u16) (13)));
+ CsrMemCpyDes(primitive->apCredentials.nmeAuthType.authwep.wepCredentials.wep128Key.key4, buffer, &offset, ((u16) (13)));
+ break;
+ case CSR_WIFI_SME_CREDENTIAL_TYPE_WEP64:
+ CsrUint8Des((u8 *) &primitive->apCredentials.nmeAuthType.authwep.wepCredentials.wep64Key.wepAuthType, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->apCredentials.nmeAuthType.authwep.wepCredentials.wep64Key.selectedWepKey, buffer, &offset);
+ CsrMemCpyDes(primitive->apCredentials.nmeAuthType.authwep.wepCredentials.wep64Key.key1, buffer, &offset, ((u16) (5)));
+ CsrMemCpyDes(primitive->apCredentials.nmeAuthType.authwep.wepCredentials.wep64Key.key2, buffer, &offset, ((u16) (5)));
+ CsrMemCpyDes(primitive->apCredentials.nmeAuthType.authwep.wepCredentials.wep64Key.key3, buffer, &offset, ((u16) (5)));
+ CsrMemCpyDes(primitive->apCredentials.nmeAuthType.authwep.wepCredentials.wep64Key.key4, buffer, &offset, ((u16) (5)));
+ break;
+ default:
+ break;
+ }
+ break;
+ case CSR_WIFI_SME_AP_AUTH_TYPE_PERSONAL:
+ CsrUint8Des((u8 *) &primitive->apCredentials.nmeAuthType.authTypePersonal.authSupport, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->apCredentials.nmeAuthType.authTypePersonal.rsnCapabilities, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->apCredentials.nmeAuthType.authTypePersonal.wapiCapabilities, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->apCredentials.nmeAuthType.authTypePersonal.pskOrPassphrase, buffer, &offset);
+ switch (primitive->apCredentials.nmeAuthType.authTypePersonal.pskOrPassphrase)
+ {
+ case CSR_WIFI_NME_AP_CREDENTIAL_TYPE_PSK:
+ CsrUint16Des((u16 *) &primitive->apCredentials.nmeAuthType.authTypePersonal.authPers_credentials.psk.encryptionMode, buffer, &offset);
+ CsrMemCpyDes(primitive->apCredentials.nmeAuthType.authTypePersonal.authPers_credentials.psk.psk, buffer, &offset, ((u16) (32)));
+ break;
+ case CSR_WIFI_NME_AP_CREDENTIAL_TYPE_PASSPHRASE:
+ CsrUint16Des((u16 *) &primitive->apCredentials.nmeAuthType.authTypePersonal.authPers_credentials.passphrase.encryptionMode, buffer, &offset);
+ CsrCharStringDes(&primitive->apCredentials.nmeAuthType.authTypePersonal.authPers_credentials.passphrase.passphrase, buffer, &offset);
+ break;
+ default:
+ break;
+ }
+ break;
+ default:
+ break;
+ }
+ CsrUint8Des((u8 *) &primitive->maxConnections, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->p2pGoParam.groupCapability, buffer, &offset);
+ CsrMemCpyDes(primitive->p2pGoParam.operatingChanList.country, buffer, &offset, ((u16) (3)));
+ CsrUint8Des((u8 *) &primitive->p2pGoParam.operatingChanList.channelEntryListCount, buffer, &offset);
+ primitive->p2pGoParam.operatingChanList.channelEntryList = NULL;
+ if (primitive->p2pGoParam.operatingChanList.channelEntryListCount)
+ {
+ primitive->p2pGoParam.operatingChanList.channelEntryList = kmalloc(sizeof(CsrWifiSmeApP2pOperatingChanEntry) * primitive->p2pGoParam.operatingChanList.channelEntryListCount, GFP_KERNEL);
+ }
+ {
+ u16 i3;
+ for (i3 = 0; i3 < primitive->p2pGoParam.operatingChanList.channelEntryListCount; i3++)
+ {
+ CsrUint8Des((u8 *) &primitive->p2pGoParam.operatingChanList.channelEntryList[i3].operatingClass, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->p2pGoParam.operatingChanList.channelEntryList[i3].operatingChannelCount, buffer, &offset);
+ if (primitive->p2pGoParam.operatingChanList.channelEntryList[i3].operatingChannelCount)
+ {
+ primitive->p2pGoParam.operatingChanList.channelEntryList[i3].operatingChannel = kmalloc(primitive->p2pGoParam.operatingChanList.channelEntryList[i3].operatingChannelCount, GFP_KERNEL);
+ CsrMemCpyDes(primitive->p2pGoParam.operatingChanList.channelEntryList[i3].operatingChannel, buffer, &offset, ((u16) (primitive->p2pGoParam.operatingChanList.channelEntryList[i3].operatingChannelCount)));
+ }
+ else
+ {
+ primitive->p2pGoParam.operatingChanList.channelEntryList[i3].operatingChannel = NULL;
+ }
+ }
+ }
+ CsrUint8Des((u8 *) &primitive->p2pGoParam.opPsEnabled, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->p2pGoParam.ctWindow, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->p2pGoParam.noaConfigMethod, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->p2pGoParam.allowNoaWithNonP2pDevices, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->wpsEnabled, buffer, &offset);
+
+ return primitive;
+}
+
+
+void CsrWifiNmeApStartReqSerFree(void *voidPrimitivePointer)
+{
+ CsrWifiNmeApStartReq *primitive = (CsrWifiNmeApStartReq *) voidPrimitivePointer;
+ switch (primitive->apCredentials.authType)
+ {
+ case CSR_WIFI_SME_AP_AUTH_TYPE_PERSONAL:
+ switch (primitive->apCredentials.nmeAuthType.authTypePersonal.pskOrPassphrase)
+ {
+ case CSR_WIFI_NME_AP_CREDENTIAL_TYPE_PASSPHRASE:
+ kfree(primitive->apCredentials.nmeAuthType.authTypePersonal.authPers_credentials.passphrase.passphrase);
+ break;
+ default:
+ break;
+ }
+ break;
+ default:
+ break;
+ }
+ {
+ u16 i3;
+ for (i3 = 0; i3 < primitive->p2pGoParam.operatingChanList.channelEntryListCount; i3++)
+ {
+ kfree(primitive->p2pGoParam.operatingChanList.channelEntryList[i3].operatingChannel);
+ }
+ }
+ kfree(primitive->p2pGoParam.operatingChanList.channelEntryList);
+ kfree(primitive);
+}
+
+
+size_t CsrWifiNmeApWmmParamUpdateReqSizeof(void *msg)
+{
+ size_t bufferSize = 2;
+
+ /* Calculate the Size of the Serialised Data. Could be more efficient (Try 51) */
+ {
+ u16 i1;
+ for (i1 = 0; i1 < 4; i1++)
+ {
+ bufferSize += 1; /* u8 primitive->wmmApParams[i1].cwMin */
+ bufferSize += 1; /* u8 primitive->wmmApParams[i1].cwMax */
+ bufferSize += 1; /* u8 primitive->wmmApParams[i1].aifs */
+ bufferSize += 2; /* u16 primitive->wmmApParams[i1].txopLimit */
+ bufferSize += 1; /* u8 primitive->wmmApParams[i1].admissionControlMandatory */
+ }
+ }
+ {
+ u16 i1;
+ for (i1 = 0; i1 < 4; i1++)
+ {
+ bufferSize += 1; /* u8 primitive->wmmApBcParams[i1].cwMin */
+ bufferSize += 1; /* u8 primitive->wmmApBcParams[i1].cwMax */
+ bufferSize += 1; /* u8 primitive->wmmApBcParams[i1].aifs */
+ bufferSize += 2; /* u16 primitive->wmmApBcParams[i1].txopLimit */
+ bufferSize += 1; /* u8 primitive->wmmApBcParams[i1].admissionControlMandatory */
+ }
+ }
+ return bufferSize;
+}
+
+
+u8* CsrWifiNmeApWmmParamUpdateReqSer(u8 *ptr, size_t *len, void *msg)
+{
+ CsrWifiNmeApWmmParamUpdateReq *primitive = (CsrWifiNmeApWmmParamUpdateReq *)msg;
+ *len = 0;
+ CsrUint16Ser(ptr, len, primitive->common.type);
+ {
+ u16 i1;
+ for (i1 = 0; i1 < 4; i1++)
+ {
+ CsrUint8Ser(ptr, len, (u8) primitive->wmmApParams[i1].cwMin);
+ CsrUint8Ser(ptr, len, (u8) primitive->wmmApParams[i1].cwMax);
+ CsrUint8Ser(ptr, len, (u8) primitive->wmmApParams[i1].aifs);
+ CsrUint16Ser(ptr, len, (u16) primitive->wmmApParams[i1].txopLimit);
+ CsrUint8Ser(ptr, len, (u8) primitive->wmmApParams[i1].admissionControlMandatory);
+ }
+ }
+ {
+ u16 i1;
+ for (i1 = 0; i1 < 4; i1++)
+ {
+ CsrUint8Ser(ptr, len, (u8) primitive->wmmApBcParams[i1].cwMin);
+ CsrUint8Ser(ptr, len, (u8) primitive->wmmApBcParams[i1].cwMax);
+ CsrUint8Ser(ptr, len, (u8) primitive->wmmApBcParams[i1].aifs);
+ CsrUint16Ser(ptr, len, (u16) primitive->wmmApBcParams[i1].txopLimit);
+ CsrUint8Ser(ptr, len, (u8) primitive->wmmApBcParams[i1].admissionControlMandatory);
+ }
+ }
+ return(ptr);
+}
+
+
+void* CsrWifiNmeApWmmParamUpdateReqDes(u8 *buffer, size_t length)
+{
+ CsrWifiNmeApWmmParamUpdateReq *primitive = kmalloc(sizeof(CsrWifiNmeApWmmParamUpdateReq), GFP_KERNEL);
+ size_t offset;
+ offset = 0;
+
+ CsrUint16Des(&primitive->common.type, buffer, &offset);
+ {
+ u16 i1;
+ for (i1 = 0; i1 < 4; i1++)
+ {
+ CsrUint8Des((u8 *) &primitive->wmmApParams[i1].cwMin, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->wmmApParams[i1].cwMax, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->wmmApParams[i1].aifs, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->wmmApParams[i1].txopLimit, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->wmmApParams[i1].admissionControlMandatory, buffer, &offset);
+ }
+ }
+ {
+ u16 i1;
+ for (i1 = 0; i1 < 4; i1++)
+ {
+ CsrUint8Des((u8 *) &primitive->wmmApBcParams[i1].cwMin, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->wmmApBcParams[i1].cwMax, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->wmmApBcParams[i1].aifs, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->wmmApBcParams[i1].txopLimit, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->wmmApBcParams[i1].admissionControlMandatory, buffer, &offset);
+ }
+ }
+
+ return primitive;
+}
+
+
+size_t CsrWifiNmeApStaRemoveReqSizeof(void *msg)
+{
+ size_t bufferSize = 2;
+
+ /* Calculate the Size of the Serialised Data. Could be more efficient (Try 12) */
+ bufferSize += 2; /* u16 primitive->interfaceTag */
+ bufferSize += 6; /* u8 primitive->staMacAddress.a[6] */
+ bufferSize += 1; /* u8 primitive->keepBlocking */
+ return bufferSize;
+}
+
+
+u8* CsrWifiNmeApStaRemoveReqSer(u8 *ptr, size_t *len, void *msg)
+{
+ CsrWifiNmeApStaRemoveReq *primitive = (CsrWifiNmeApStaRemoveReq *)msg;
+ *len = 0;
+ CsrUint16Ser(ptr, len, primitive->common.type);
+ CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
+ CsrMemCpySer(ptr, len, (const void *) primitive->staMacAddress.a, ((u16) (6)));
+ CsrUint8Ser(ptr, len, (u8) primitive->keepBlocking);
+ return(ptr);
+}
+
+
+void* CsrWifiNmeApStaRemoveReqDes(u8 *buffer, size_t length)
+{
+ CsrWifiNmeApStaRemoveReq *primitive = kmalloc(sizeof(CsrWifiNmeApStaRemoveReq), GFP_KERNEL);
+ size_t offset;
+ offset = 0;
+
+ CsrUint16Des(&primitive->common.type, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
+ CsrMemCpyDes(primitive->staMacAddress.a, buffer, &offset, ((u16) (6)));
+ CsrUint8Des((u8 *) &primitive->keepBlocking, buffer, &offset);
+
+ return primitive;
+}
+
+
+size_t CsrWifiNmeApWpsRegisterCfmSizeof(void *msg)
+{
+ size_t bufferSize = 2;
+
+ /* Calculate the Size of the Serialised Data. Could be more efficient (Try 7) */
+ bufferSize += 2; /* u16 primitive->interfaceTag */
+ bufferSize += 2; /* CsrResult primitive->status */
+ return bufferSize;
+}
+
+
+u8* CsrWifiNmeApWpsRegisterCfmSer(u8 *ptr, size_t *len, void *msg)
+{
+ CsrWifiNmeApWpsRegisterCfm *primitive = (CsrWifiNmeApWpsRegisterCfm *)msg;
+ *len = 0;
+ CsrUint16Ser(ptr, len, primitive->common.type);
+ CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
+ CsrUint16Ser(ptr, len, (u16) primitive->status);
+ return(ptr);
+}
+
+
+void* CsrWifiNmeApWpsRegisterCfmDes(u8 *buffer, size_t length)
+{
+ CsrWifiNmeApWpsRegisterCfm *primitive = kmalloc(sizeof(CsrWifiNmeApWpsRegisterCfm), GFP_KERNEL);
+ size_t offset;
+ offset = 0;
+
+ CsrUint16Des(&primitive->common.type, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
+
+ return primitive;
+}
+
+
+size_t CsrWifiNmeApStartCfmSizeof(void *msg)
+{
+ size_t bufferSize = 2;
+
+ /* Calculate the Size of the Serialised Data. Could be more efficient (Try 40) */
+ bufferSize += 2; /* u16 primitive->interfaceTag */
+ bufferSize += 2; /* CsrResult primitive->status */
+ bufferSize += 32; /* u8 primitive->ssid.ssid[32] */
+ bufferSize += 1; /* u8 primitive->ssid.length */
+ return bufferSize;
+}
+
+
+u8* CsrWifiNmeApStartCfmSer(u8 *ptr, size_t *len, void *msg)
+{
+ CsrWifiNmeApStartCfm *primitive = (CsrWifiNmeApStartCfm *)msg;
+ *len = 0;
+ CsrUint16Ser(ptr, len, primitive->common.type);
+ CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
+ CsrUint16Ser(ptr, len, (u16) primitive->status);
+ CsrMemCpySer(ptr, len, (const void *) primitive->ssid.ssid, ((u16) (32)));
+ CsrUint8Ser(ptr, len, (u8) primitive->ssid.length);
+ return(ptr);
+}
+
+
+void* CsrWifiNmeApStartCfmDes(u8 *buffer, size_t length)
+{
+ CsrWifiNmeApStartCfm *primitive = kmalloc(sizeof(CsrWifiNmeApStartCfm), GFP_KERNEL);
+ size_t offset;
+ offset = 0;
+
+ CsrUint16Des(&primitive->common.type, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
+ CsrMemCpyDes(primitive->ssid.ssid, buffer, &offset, ((u16) (32)));
+ CsrUint8Des((u8 *) &primitive->ssid.length, buffer, &offset);
+
+ return primitive;
+}
+
+
+size_t CsrWifiNmeApStopCfmSizeof(void *msg)
+{
+ size_t bufferSize = 2;
+
+ /* Calculate the Size of the Serialised Data. Could be more efficient (Try 7) */
+ bufferSize += 2; /* u16 primitive->interfaceTag */
+ bufferSize += 2; /* CsrResult primitive->status */
+ return bufferSize;
+}
+
+
+u8* CsrWifiNmeApStopCfmSer(u8 *ptr, size_t *len, void *msg)
+{
+ CsrWifiNmeApStopCfm *primitive = (CsrWifiNmeApStopCfm *)msg;
+ *len = 0;
+ CsrUint16Ser(ptr, len, primitive->common.type);
+ CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
+ CsrUint16Ser(ptr, len, (u16) primitive->status);
+ return(ptr);
+}
+
+
+void* CsrWifiNmeApStopCfmDes(u8 *buffer, size_t length)
+{
+ CsrWifiNmeApStopCfm *primitive = kmalloc(sizeof(CsrWifiNmeApStopCfm), GFP_KERNEL);
+ size_t offset;
+ offset = 0;
+
+ CsrUint16Des(&primitive->common.type, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
+
+ return primitive;
+}
+
+
+size_t CsrWifiNmeApStopIndSizeof(void *msg)
+{
+ size_t bufferSize = 2;
+
+ /* Calculate the Size of the Serialised Data. Could be more efficient (Try 8) */
+ bufferSize += 2; /* u16 primitive->interfaceTag */
+ bufferSize += 1; /* CsrWifiSmeApType primitive->apType */
+ bufferSize += 2; /* CsrResult primitive->status */
+ return bufferSize;
+}
+
+
+u8* CsrWifiNmeApStopIndSer(u8 *ptr, size_t *len, void *msg)
+{
+ CsrWifiNmeApStopInd *primitive = (CsrWifiNmeApStopInd *)msg;
+ *len = 0;
+ CsrUint16Ser(ptr, len, primitive->common.type);
+ CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
+ CsrUint8Ser(ptr, len, (u8) primitive->apType);
+ CsrUint16Ser(ptr, len, (u16) primitive->status);
+ return(ptr);
+}
+
+
+void* CsrWifiNmeApStopIndDes(u8 *buffer, size_t length)
+{
+ CsrWifiNmeApStopInd *primitive = kmalloc(sizeof(CsrWifiNmeApStopInd), GFP_KERNEL);
+ size_t offset;
+ offset = 0;
+
+ CsrUint16Des(&primitive->common.type, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->apType, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
+
+ return primitive;
+}
+
+
+size_t CsrWifiNmeApStationIndSizeof(void *msg)
+{
+ size_t bufferSize = 2;
+
+ /* Calculate the Size of the Serialised Data. Could be more efficient (Try 18) */
+ bufferSize += 2; /* u16 primitive->interfaceTag */
+ bufferSize += 1; /* CsrWifiSmeMediaStatus primitive->mediaStatus */
+ bufferSize += 6; /* u8 primitive->peerMacAddress.a[6] */
+ bufferSize += 6; /* u8 primitive->peerDeviceAddress.a[6] */
+ return bufferSize;
+}
+
+
+u8* CsrWifiNmeApStationIndSer(u8 *ptr, size_t *len, void *msg)
+{
+ CsrWifiNmeApStationInd *primitive = (CsrWifiNmeApStationInd *)msg;
+ *len = 0;
+ CsrUint16Ser(ptr, len, primitive->common.type);
+ CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
+ CsrUint8Ser(ptr, len, (u8) primitive->mediaStatus);
+ CsrMemCpySer(ptr, len, (const void *) primitive->peerMacAddress.a, ((u16) (6)));
+ CsrMemCpySer(ptr, len, (const void *) primitive->peerDeviceAddress.a, ((u16) (6)));
+ return(ptr);
+}
+
+
+void* CsrWifiNmeApStationIndDes(u8 *buffer, size_t length)
+{
+ CsrWifiNmeApStationInd *primitive = kmalloc(sizeof(CsrWifiNmeApStationInd), GFP_KERNEL);
+ size_t offset;
+ offset = 0;
+
+ CsrUint16Des(&primitive->common.type, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->mediaStatus, buffer, &offset);
+ CsrMemCpyDes(primitive->peerMacAddress.a, buffer, &offset, ((u16) (6)));
+ CsrMemCpyDes(primitive->peerDeviceAddress.a, buffer, &offset, ((u16) (6)));
+
+ return primitive;
+}
+
+
+#endif /* CSR_WIFI_NME_ENABLE */
+#endif /* CSR_WIFI_AP_ENABLE */
diff --git a/drivers/staging/csr/csr_wifi_nme_ap_serialize.h b/drivers/staging/csr/csr_wifi_nme_ap_serialize.h
new file mode 100644
index 000000000000..0f5782947223
--- /dev/null
+++ b/drivers/staging/csr/csr_wifi_nme_ap_serialize.h
@@ -0,0 +1,103 @@
+/*****************************************************************************
+
+ (c) Cambridge Silicon Radio Limited 2011
+ All rights reserved and confidential information of CSR
+
+ Refer to LICENSE.txt included with this source for details
+ on the license terms.
+
+*****************************************************************************/
+
+/* Note: this is an auto-generated file. */
+
+#ifndef CSR_WIFI_NME_AP_SERIALIZE_H__
+#define CSR_WIFI_NME_AP_SERIALIZE_H__
+
+#include "csr_wifi_msgconv.h"
+
+#include "csr_wifi_nme_ap_prim.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef CSR_WIFI_NME_ENABLE
+#error CSR_WIFI_NME_ENABLE MUST be defined inorder to use csr_wifi_nme_ap_serialize.h
+#endif
+#ifndef CSR_WIFI_AP_ENABLE
+#error CSR_WIFI_AP_ENABLE MUST be defined inorder to use csr_wifi_nme_ap_serialize.h
+#endif
+
+extern void CsrWifiNmeApPfree(void *ptr);
+
+extern u8* CsrWifiNmeApConfigSetReqSer(u8 *ptr, size_t *len, void *msg);
+extern void* CsrWifiNmeApConfigSetReqDes(u8 *buffer, size_t len);
+extern size_t CsrWifiNmeApConfigSetReqSizeof(void *msg);
+extern void CsrWifiNmeApConfigSetReqSerFree(void *msg);
+
+extern u8* CsrWifiNmeApWpsRegisterReqSer(u8 *ptr, size_t *len, void *msg);
+extern void* CsrWifiNmeApWpsRegisterReqDes(u8 *buffer, size_t len);
+extern size_t CsrWifiNmeApWpsRegisterReqSizeof(void *msg);
+#define CsrWifiNmeApWpsRegisterReqSerFree CsrWifiNmeApPfree
+
+extern u8* CsrWifiNmeApStartReqSer(u8 *ptr, size_t *len, void *msg);
+extern void* CsrWifiNmeApStartReqDes(u8 *buffer, size_t len);
+extern size_t CsrWifiNmeApStartReqSizeof(void *msg);
+extern void CsrWifiNmeApStartReqSerFree(void *msg);
+
+#define CsrWifiNmeApStopReqSer CsrWifiEventCsrUint16Ser
+#define CsrWifiNmeApStopReqDes CsrWifiEventCsrUint16Des
+#define CsrWifiNmeApStopReqSizeof CsrWifiEventCsrUint16Sizeof
+#define CsrWifiNmeApStopReqSerFree CsrWifiNmeApPfree
+
+extern u8* CsrWifiNmeApWmmParamUpdateReqSer(u8 *ptr, size_t *len, void *msg);
+extern void* CsrWifiNmeApWmmParamUpdateReqDes(u8 *buffer, size_t len);
+extern size_t CsrWifiNmeApWmmParamUpdateReqSizeof(void *msg);
+#define CsrWifiNmeApWmmParamUpdateReqSerFree CsrWifiNmeApPfree
+
+extern u8* CsrWifiNmeApStaRemoveReqSer(u8 *ptr, size_t *len, void *msg);
+extern void* CsrWifiNmeApStaRemoveReqDes(u8 *buffer, size_t len);
+extern size_t CsrWifiNmeApStaRemoveReqSizeof(void *msg);
+#define CsrWifiNmeApStaRemoveReqSerFree CsrWifiNmeApPfree
+
+#define CsrWifiNmeApConfigSetCfmSer CsrWifiEventCsrUint16Ser
+#define CsrWifiNmeApConfigSetCfmDes CsrWifiEventCsrUint16Des
+#define CsrWifiNmeApConfigSetCfmSizeof CsrWifiEventCsrUint16Sizeof
+#define CsrWifiNmeApConfigSetCfmSerFree CsrWifiNmeApPfree
+
+extern u8* CsrWifiNmeApWpsRegisterCfmSer(u8 *ptr, size_t *len, void *msg);
+extern void* CsrWifiNmeApWpsRegisterCfmDes(u8 *buffer, size_t len);
+extern size_t CsrWifiNmeApWpsRegisterCfmSizeof(void *msg);
+#define CsrWifiNmeApWpsRegisterCfmSerFree CsrWifiNmeApPfree
+
+extern u8* CsrWifiNmeApStartCfmSer(u8 *ptr, size_t *len, void *msg);
+extern void* CsrWifiNmeApStartCfmDes(u8 *buffer, size_t len);
+extern size_t CsrWifiNmeApStartCfmSizeof(void *msg);
+#define CsrWifiNmeApStartCfmSerFree CsrWifiNmeApPfree
+
+extern u8* CsrWifiNmeApStopCfmSer(u8 *ptr, size_t *len, void *msg);
+extern void* CsrWifiNmeApStopCfmDes(u8 *buffer, size_t len);
+extern size_t CsrWifiNmeApStopCfmSizeof(void *msg);
+#define CsrWifiNmeApStopCfmSerFree CsrWifiNmeApPfree
+
+extern u8* CsrWifiNmeApStopIndSer(u8 *ptr, size_t *len, void *msg);
+extern void* CsrWifiNmeApStopIndDes(u8 *buffer, size_t len);
+extern size_t CsrWifiNmeApStopIndSizeof(void *msg);
+#define CsrWifiNmeApStopIndSerFree CsrWifiNmeApPfree
+
+#define CsrWifiNmeApWmmParamUpdateCfmSer CsrWifiEventCsrUint16Ser
+#define CsrWifiNmeApWmmParamUpdateCfmDes CsrWifiEventCsrUint16Des
+#define CsrWifiNmeApWmmParamUpdateCfmSizeof CsrWifiEventCsrUint16Sizeof
+#define CsrWifiNmeApWmmParamUpdateCfmSerFree CsrWifiNmeApPfree
+
+extern u8* CsrWifiNmeApStationIndSer(u8 *ptr, size_t *len, void *msg);
+extern void* CsrWifiNmeApStationIndDes(u8 *buffer, size_t len);
+extern size_t CsrWifiNmeApStationIndSizeof(void *msg);
+#define CsrWifiNmeApStationIndSerFree CsrWifiNmeApPfree
+
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* CSR_WIFI_NME_AP_SERIALIZE_H__ */
+
diff --git a/drivers/staging/csr/csr_wifi_nme_converter_init.h b/drivers/staging/csr/csr_wifi_nme_converter_init.h
new file mode 100644
index 000000000000..6661914fb403
--- /dev/null
+++ b/drivers/staging/csr/csr_wifi_nme_converter_init.h
@@ -0,0 +1,46 @@
+/*****************************************************************************
+
+ (c) Cambridge Silicon Radio Limited 2011
+ All rights reserved and confidential information of CSR
+
+ Refer to LICENSE.txt included with this source for details
+ on the license terms.
+
+*****************************************************************************/
+
+/* Note: this is an auto-generated file. */
+
+#ifndef CSR_WIFI_NME_CONVERTER_INIT_H__
+#define CSR_WIFI_NME_CONVERTER_INIT_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef CSR_WIFI_NME_ENABLE
+#error CSR_WIFI_NME_ENABLE MUST be defined inorder to use csr_wifi_nme_converter_init.h
+#endif
+
+#ifndef EXCLUDE_CSR_WIFI_NME_MODULE
+
+#include "csr_msgconv.h"
+
+#ifdef CSR_LOG_ENABLE
+#include "csr_log.h"
+
+extern const CsrLogPrimitiveInformation* CsrWifiNmeTechInfoGet(void);
+#endif /* CSR_LOG_ENABLE */
+
+extern void CsrWifiNmeConverterInit(void);
+
+#else /* EXCLUDE_CSR_WIFI_NME_MODULE */
+
+#define CsrWifiNmeConverterInit()
+
+#endif /* EXCLUDE_CSR_WIFI_NME_MODULE */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* CSR_WIFI_NME_CONVERTER_INIT_H__ */
diff --git a/drivers/staging/csr/csr_wifi_nme_lib.h b/drivers/staging/csr/csr_wifi_nme_lib.h
new file mode 100644
index 000000000000..709ece464977
--- /dev/null
+++ b/drivers/staging/csr/csr_wifi_nme_lib.h
@@ -0,0 +1,1054 @@
+/*****************************************************************************
+
+ (c) Cambridge Silicon Radio Limited 2011
+ All rights reserved and confidential information of CSR
+
+ Refer to LICENSE.txt included with this source for details
+ on the license terms.
+
+*****************************************************************************/
+
+/* Note: this is an auto-generated file. */
+
+#ifndef CSR_WIFI_NME_LIB_H__
+#define CSR_WIFI_NME_LIB_H__
+
+#include "csr_sched.h"
+#include "csr_macro.h"
+#include "csr_msg_transport.h"
+
+#include "csr_wifi_lib.h"
+
+#include "csr_wifi_nme_prim.h"
+#include "csr_wifi_nme_task.h"
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef CSR_WIFI_NME_ENABLE
+#error CSR_WIFI_NME_ENABLE MUST be defined inorder to use csr_wifi_nme_lib.h
+#endif
+
+/*----------------------------------------------------------------------------*
+ * CsrWifiNmeFreeUpstreamMessageContents
+ *
+ * DESCRIPTION
+ * Free the allocated memory in a CSR_WIFI_NME upstream message. Does not
+ * free the message itself, and can only be used for upstream messages.
+ *
+ * PARAMETERS
+ * Deallocates the resources in a CSR_WIFI_NME upstream message
+ *----------------------------------------------------------------------------*/
+void CsrWifiNmeFreeUpstreamMessageContents(u16 eventClass, void *message);
+
+/*----------------------------------------------------------------------------*
+ * CsrWifiNmeFreeDownstreamMessageContents
+ *
+ * DESCRIPTION
+ * Free the allocated memory in a CSR_WIFI_NME downstream message. Does not
+ * free the message itself, and can only be used for downstream messages.
+ *
+ * PARAMETERS
+ * Deallocates the resources in a CSR_WIFI_NME downstream message
+ *----------------------------------------------------------------------------*/
+void CsrWifiNmeFreeDownstreamMessageContents(u16 eventClass, void *message);
+
+/*----------------------------------------------------------------------------*
+ * Enum to string functions
+ *----------------------------------------------------------------------------*/
+const char* CsrWifiNmeAuthModeToString(CsrWifiNmeAuthMode value);
+const char* CsrWifiNmeBssTypeToString(CsrWifiNmeBssType value);
+const char* CsrWifiNmeCcxOptionsMaskToString(CsrWifiNmeCcxOptionsMask value);
+const char* CsrWifiNmeConfigActionToString(CsrWifiNmeConfigAction value);
+const char* CsrWifiNmeConnectionStatusToString(CsrWifiNmeConnectionStatus value);
+const char* CsrWifiNmeCredentialTypeToString(CsrWifiNmeCredentialType value);
+const char* CsrWifiNmeEapMethodToString(CsrWifiNmeEapMethod value);
+const char* CsrWifiNmeEncryptionToString(CsrWifiNmeEncryption value);
+const char* CsrWifiNmeIndicationsToString(CsrWifiNmeIndications value);
+const char* CsrWifiNmeSecErrorToString(CsrWifiNmeSecError value);
+const char* CsrWifiNmeSimCardTypeToString(CsrWifiNmeSimCardType value);
+const char* CsrWifiNmeUmtsAuthResultToString(CsrWifiNmeUmtsAuthResult value);
+const char* CsrWifiNmeWmmQosInfoToString(CsrWifiNmeWmmQosInfo value);
+
+
+/*----------------------------------------------------------------------------*
+ * CsrPrim Type toString function.
+ * Converts a message type to the String name of the Message
+ *----------------------------------------------------------------------------*/
+const char* CsrWifiNmePrimTypeToString(CsrPrim msgType);
+
+/*----------------------------------------------------------------------------*
+ * Lookup arrays for PrimType name Strings
+ *----------------------------------------------------------------------------*/
+extern const char *CsrWifiNmeUpstreamPrimNames[CSR_WIFI_NME_PRIM_UPSTREAM_COUNT];
+extern const char *CsrWifiNmeDownstreamPrimNames[CSR_WIFI_NME_PRIM_DOWNSTREAM_COUNT];
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiNmeConnectionStatusGetReqSend
+
+ DESCRIPTION
+ Requests the current connection status of the NME.
+
+ PARAMETERS
+ queue - Message Source Task Queue (Cfm's will be sent to this Queue)
+ interfaceTag - Interface Identifier; unique identifier of an interface
+
+*******************************************************************************/
+#define CsrWifiNmeConnectionStatusGetReqCreate(msg__, dst__, src__, interfaceTag__) \
+ msg__ = kmalloc(sizeof(CsrWifiNmeConnectionStatusGetReq), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_NME_PRIM, CSR_WIFI_NME_CONNECTION_STATUS_GET_REQ, dst__, src__); \
+ msg__->interfaceTag = (interfaceTag__);
+
+#define CsrWifiNmeConnectionStatusGetReqSendTo(dst__, src__, interfaceTag__) \
+ { \
+ CsrWifiNmeConnectionStatusGetReq *msg__; \
+ CsrWifiNmeConnectionStatusGetReqCreate(msg__, dst__, src__, interfaceTag__); \
+ CsrMsgTransport(dst__, CSR_WIFI_NME_PRIM, msg__); \
+ }
+
+#define CsrWifiNmeConnectionStatusGetReqSend(src__, interfaceTag__) \
+ CsrWifiNmeConnectionStatusGetReqSendTo(CSR_WIFI_NME_IFACEQUEUE, src__, interfaceTag__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiNmeConnectionStatusGetCfmSend
+
+ DESCRIPTION
+ Reports the connection status of the NME.
+
+ PARAMETERS
+ queue - Destination Task Queue
+ interfaceTag - Interface Identifier; unique identifier of an interface
+ status - Indicates the success or otherwise of the requested
+ operation.
+ connectionStatus - NME current connection status
+
+*******************************************************************************/
+#define CsrWifiNmeConnectionStatusGetCfmCreate(msg__, dst__, src__, interfaceTag__, status__, connectionStatus__) \
+ msg__ = kmalloc(sizeof(CsrWifiNmeConnectionStatusGetCfm), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_NME_PRIM, CSR_WIFI_NME_CONNECTION_STATUS_GET_CFM, dst__, src__); \
+ msg__->interfaceTag = (interfaceTag__); \
+ msg__->status = (status__); \
+ msg__->connectionStatus = (connectionStatus__);
+
+#define CsrWifiNmeConnectionStatusGetCfmSendTo(dst__, src__, interfaceTag__, status__, connectionStatus__) \
+ { \
+ CsrWifiNmeConnectionStatusGetCfm *msg__; \
+ CsrWifiNmeConnectionStatusGetCfmCreate(msg__, dst__, src__, interfaceTag__, status__, connectionStatus__); \
+ CsrSchedMessagePut(dst__, CSR_WIFI_NME_PRIM, msg__); \
+ }
+
+#define CsrWifiNmeConnectionStatusGetCfmSend(dst__, interfaceTag__, status__, connectionStatus__) \
+ CsrWifiNmeConnectionStatusGetCfmSendTo(dst__, CSR_WIFI_NME_IFACEQUEUE, interfaceTag__, status__, connectionStatus__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiNmeEventMaskSetReqSend
+
+ DESCRIPTION
+ The wireless manager application may register with the NME to receive
+ notification of interesting events. Indications will be sent only if the
+ wireless manager explicitly registers to be notified of that event.
+ indMask is a bit mask of values defined in CsrWifiNmeIndicationsMask.
+
+ PARAMETERS
+ queue - Message Source Task Queue (Cfm's will be sent to this Queue)
+ indMask - Set mask with values from CsrWifiNmeIndications
+
+*******************************************************************************/
+#define CsrWifiNmeEventMaskSetReqCreate(msg__, dst__, src__, indMask__) \
+ msg__ = kmalloc(sizeof(CsrWifiNmeEventMaskSetReq), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_NME_PRIM, CSR_WIFI_NME_EVENT_MASK_SET_REQ, dst__, src__); \
+ msg__->indMask = (indMask__);
+
+#define CsrWifiNmeEventMaskSetReqSendTo(dst__, src__, indMask__) \
+ { \
+ CsrWifiNmeEventMaskSetReq *msg__; \
+ CsrWifiNmeEventMaskSetReqCreate(msg__, dst__, src__, indMask__); \
+ CsrMsgTransport(dst__, CSR_WIFI_NME_PRIM, msg__); \
+ }
+
+#define CsrWifiNmeEventMaskSetReqSend(src__, indMask__) \
+ CsrWifiNmeEventMaskSetReqSendTo(CSR_WIFI_NME_IFACEQUEUE, src__, indMask__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiNmeEventMaskSetCfmSend
+
+ DESCRIPTION
+ The NME calls the primitive to report the result of the request
+ primitive.
+
+ PARAMETERS
+ queue - Destination Task Queue
+ status - Reports the result of the request
+
+*******************************************************************************/
+#define CsrWifiNmeEventMaskSetCfmCreate(msg__, dst__, src__, status__) \
+ msg__ = kmalloc(sizeof(CsrWifiNmeEventMaskSetCfm), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_NME_PRIM, CSR_WIFI_NME_EVENT_MASK_SET_CFM, dst__, src__); \
+ msg__->status = (status__);
+
+#define CsrWifiNmeEventMaskSetCfmSendTo(dst__, src__, status__) \
+ { \
+ CsrWifiNmeEventMaskSetCfm *msg__; \
+ CsrWifiNmeEventMaskSetCfmCreate(msg__, dst__, src__, status__); \
+ CsrSchedMessagePut(dst__, CSR_WIFI_NME_PRIM, msg__); \
+ }
+
+#define CsrWifiNmeEventMaskSetCfmSend(dst__, status__) \
+ CsrWifiNmeEventMaskSetCfmSendTo(dst__, CSR_WIFI_NME_IFACEQUEUE, status__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiNmeProfileConnectReqSend
+
+ DESCRIPTION
+ Requests the NME to attempt to connect to the specified profile.
+ Overrides any current connection attempt.
+
+ PARAMETERS
+ queue - Message Source Task Queue (Cfm's will be sent to this Queue)
+ interfaceTag - Interface Identifier; unique identifier of an interface
+ profileIdentity - Identity (BSSID, SSID) of profile to be connected to.
+ It must match an existing profile in the NME.
+
+*******************************************************************************/
+#define CsrWifiNmeProfileConnectReqCreate(msg__, dst__, src__, interfaceTag__, profileIdentity__) \
+ msg__ = kmalloc(sizeof(CsrWifiNmeProfileConnectReq), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_NME_PRIM, CSR_WIFI_NME_PROFILE_CONNECT_REQ, dst__, src__); \
+ msg__->interfaceTag = (interfaceTag__); \
+ msg__->profileIdentity = (profileIdentity__);
+
+#define CsrWifiNmeProfileConnectReqSendTo(dst__, src__, interfaceTag__, profileIdentity__) \
+ { \
+ CsrWifiNmeProfileConnectReq *msg__; \
+ CsrWifiNmeProfileConnectReqCreate(msg__, dst__, src__, interfaceTag__, profileIdentity__); \
+ CsrMsgTransport(dst__, CSR_WIFI_NME_PRIM, msg__); \
+ }
+
+#define CsrWifiNmeProfileConnectReqSend(src__, interfaceTag__, profileIdentity__) \
+ CsrWifiNmeProfileConnectReqSendTo(CSR_WIFI_NME_IFACEQUEUE, src__, interfaceTag__, profileIdentity__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiNmeProfileConnectCfmSend
+
+ DESCRIPTION
+ Reports the status of the NME PROFILE CONNECT REQ. If unsuccessful the
+ connectAttempt parameters contain details of the APs that the NME
+ attempted to connect to before reporting the failure of the request.
+
+ PARAMETERS
+ queue - Destination Task Queue
+ interfaceTag - Interface Identifier; unique identifier of an
+ interface
+ status - Indicates the success or otherwise of the requested
+ operation.
+ connectAttemptsCount - This parameter is relevant only if
+ status!=CSR_WIFI_NME_STATUS_SUCCESS.
+ Number of connection attempt elements provided with
+ this primitive
+ connectAttempts - This parameter is relevant only if
+ status!=CSR_WIFI_NME_STATUS_SUCCESS.
+ Points to the list of connection attempt elements
+ provided with this primitive
+ Each element of the list provides information about
+ an AP on which the connection attempt was made and
+ the error that occurred during the attempt.
+
+*******************************************************************************/
+#define CsrWifiNmeProfileConnectCfmCreate(msg__, dst__, src__, interfaceTag__, status__, connectAttemptsCount__, connectAttempts__) \
+ msg__ = kmalloc(sizeof(CsrWifiNmeProfileConnectCfm), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_NME_PRIM, CSR_WIFI_NME_PROFILE_CONNECT_CFM, dst__, src__); \
+ msg__->interfaceTag = (interfaceTag__); \
+ msg__->status = (status__); \
+ msg__->connectAttemptsCount = (connectAttemptsCount__); \
+ msg__->connectAttempts = (connectAttempts__);
+
+#define CsrWifiNmeProfileConnectCfmSendTo(dst__, src__, interfaceTag__, status__, connectAttemptsCount__, connectAttempts__) \
+ { \
+ CsrWifiNmeProfileConnectCfm *msg__; \
+ CsrWifiNmeProfileConnectCfmCreate(msg__, dst__, src__, interfaceTag__, status__, connectAttemptsCount__, connectAttempts__); \
+ CsrSchedMessagePut(dst__, CSR_WIFI_NME_PRIM, msg__); \
+ }
+
+#define CsrWifiNmeProfileConnectCfmSend(dst__, interfaceTag__, status__, connectAttemptsCount__, connectAttempts__) \
+ CsrWifiNmeProfileConnectCfmSendTo(dst__, CSR_WIFI_NME_IFACEQUEUE, interfaceTag__, status__, connectAttemptsCount__, connectAttempts__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiNmeProfileDeleteAllReqSend
+
+ DESCRIPTION
+ Deletes all profiles present in the NME, but does NOT modify the
+ preferred profile list.
+
+ PARAMETERS
+ queue - Message Source Task Queue (Cfm's will be sent to this Queue)
+
+*******************************************************************************/
+#define CsrWifiNmeProfileDeleteAllReqCreate(msg__, dst__, src__) \
+ msg__ = kmalloc(sizeof(CsrWifiNmeProfileDeleteAllReq), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_NME_PRIM, CSR_WIFI_NME_PROFILE_DELETE_ALL_REQ, dst__, src__);
+
+#define CsrWifiNmeProfileDeleteAllReqSendTo(dst__, src__) \
+ { \
+ CsrWifiNmeProfileDeleteAllReq *msg__; \
+ CsrWifiNmeProfileDeleteAllReqCreate(msg__, dst__, src__); \
+ CsrMsgTransport(dst__, CSR_WIFI_NME_PRIM, msg__); \
+ }
+
+#define CsrWifiNmeProfileDeleteAllReqSend(src__) \
+ CsrWifiNmeProfileDeleteAllReqSendTo(CSR_WIFI_NME_IFACEQUEUE, src__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiNmeProfileDeleteAllCfmSend
+
+ DESCRIPTION
+ Reports the status of the CSR_WIFI_NME_PROFILE_DELETE_ALL_REQ.
+ Returns always CSR_WIFI_NME_STATUS_SUCCESS.
+
+ PARAMETERS
+ queue - Destination Task Queue
+ status - Indicates the success or otherwise of the requested operation, but
+ in this case it always set to success.
+
+*******************************************************************************/
+#define CsrWifiNmeProfileDeleteAllCfmCreate(msg__, dst__, src__, status__) \
+ msg__ = kmalloc(sizeof(CsrWifiNmeProfileDeleteAllCfm), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_NME_PRIM, CSR_WIFI_NME_PROFILE_DELETE_ALL_CFM, dst__, src__); \
+ msg__->status = (status__);
+
+#define CsrWifiNmeProfileDeleteAllCfmSendTo(dst__, src__, status__) \
+ { \
+ CsrWifiNmeProfileDeleteAllCfm *msg__; \
+ CsrWifiNmeProfileDeleteAllCfmCreate(msg__, dst__, src__, status__); \
+ CsrSchedMessagePut(dst__, CSR_WIFI_NME_PRIM, msg__); \
+ }
+
+#define CsrWifiNmeProfileDeleteAllCfmSend(dst__, status__) \
+ CsrWifiNmeProfileDeleteAllCfmSendTo(dst__, CSR_WIFI_NME_IFACEQUEUE, status__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiNmeProfileDeleteReqSend
+
+ DESCRIPTION
+ Will delete the profile with a matching identity, but does NOT modify the
+ preferred profile list.
+
+ PARAMETERS
+ queue - Message Source Task Queue (Cfm's will be sent to this Queue)
+ profileIdentity - Identity (BSSID, SSID) of profile to be deleted.
+
+*******************************************************************************/
+#define CsrWifiNmeProfileDeleteReqCreate(msg__, dst__, src__, profileIdentity__) \
+ msg__ = kmalloc(sizeof(CsrWifiNmeProfileDeleteReq), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_NME_PRIM, CSR_WIFI_NME_PROFILE_DELETE_REQ, dst__, src__); \
+ msg__->profileIdentity = (profileIdentity__);
+
+#define CsrWifiNmeProfileDeleteReqSendTo(dst__, src__, profileIdentity__) \
+ { \
+ CsrWifiNmeProfileDeleteReq *msg__; \
+ CsrWifiNmeProfileDeleteReqCreate(msg__, dst__, src__, profileIdentity__); \
+ CsrMsgTransport(dst__, CSR_WIFI_NME_PRIM, msg__); \
+ }
+
+#define CsrWifiNmeProfileDeleteReqSend(src__, profileIdentity__) \
+ CsrWifiNmeProfileDeleteReqSendTo(CSR_WIFI_NME_IFACEQUEUE, src__, profileIdentity__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiNmeProfileDeleteCfmSend
+
+ DESCRIPTION
+ Reports the status of the CSR_WIFI_NME_PROFILE_DELETE_REQ.
+ Returns CSR_WIFI_NME_STATUS_NOT_FOUND if there is no matching profile.
+
+ PARAMETERS
+ queue - Destination Task Queue
+ status - Indicates the success or otherwise of the requested operation.
+
+*******************************************************************************/
+#define CsrWifiNmeProfileDeleteCfmCreate(msg__, dst__, src__, status__) \
+ msg__ = kmalloc(sizeof(CsrWifiNmeProfileDeleteCfm), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_NME_PRIM, CSR_WIFI_NME_PROFILE_DELETE_CFM, dst__, src__); \
+ msg__->status = (status__);
+
+#define CsrWifiNmeProfileDeleteCfmSendTo(dst__, src__, status__) \
+ { \
+ CsrWifiNmeProfileDeleteCfm *msg__; \
+ CsrWifiNmeProfileDeleteCfmCreate(msg__, dst__, src__, status__); \
+ CsrSchedMessagePut(dst__, CSR_WIFI_NME_PRIM, msg__); \
+ }
+
+#define CsrWifiNmeProfileDeleteCfmSend(dst__, status__) \
+ CsrWifiNmeProfileDeleteCfmSendTo(dst__, CSR_WIFI_NME_IFACEQUEUE, status__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiNmeProfileDisconnectIndSend
+
+ DESCRIPTION
+ Indication generated from the NME (if an application subscribes to
+ receive it) that informs that application that the current profile
+ connection has disconnected. The indication will contain information
+ about APs that it attempted to maintain the connection via i.e. in the
+ case of failed roaming.
+
+ PARAMETERS
+ queue - Destination Task Queue
+ interfaceTag - Interface Identifier; unique identifier of an
+ interface
+ connectAttemptsCount - Number of connection attempt elements provided with
+ this primitive
+ connectAttempts - Points to the list of connection attempt elements
+ provided with this primitive
+ Each element of the list provides information about
+ an AP on which the connection attempt was made and
+ the error occurred during the attempt.
+
+*******************************************************************************/
+#define CsrWifiNmeProfileDisconnectIndCreate(msg__, dst__, src__, interfaceTag__, connectAttemptsCount__, connectAttempts__) \
+ msg__ = kmalloc(sizeof(CsrWifiNmeProfileDisconnectInd), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_NME_PRIM, CSR_WIFI_NME_PROFILE_DISCONNECT_IND, dst__, src__); \
+ msg__->interfaceTag = (interfaceTag__); \
+ msg__->connectAttemptsCount = (connectAttemptsCount__); \
+ msg__->connectAttempts = (connectAttempts__);
+
+#define CsrWifiNmeProfileDisconnectIndSendTo(dst__, src__, interfaceTag__, connectAttemptsCount__, connectAttempts__) \
+ { \
+ CsrWifiNmeProfileDisconnectInd *msg__; \
+ CsrWifiNmeProfileDisconnectIndCreate(msg__, dst__, src__, interfaceTag__, connectAttemptsCount__, connectAttempts__); \
+ CsrSchedMessagePut(dst__, CSR_WIFI_NME_PRIM, msg__); \
+ }
+
+#define CsrWifiNmeProfileDisconnectIndSend(dst__, interfaceTag__, connectAttemptsCount__, connectAttempts__) \
+ CsrWifiNmeProfileDisconnectIndSendTo(dst__, CSR_WIFI_NME_IFACEQUEUE, interfaceTag__, connectAttemptsCount__, connectAttempts__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiNmeProfileOrderSetReqSend
+
+ DESCRIPTION
+ Defines the preferred order that profiles present in the NME should be
+ used during the NME auto-connect behaviour.
+ If profileIdentitysCount == 0, it removes any existing preferred profile
+ list already present in the NME, effectively disabling the auto-connect
+ behaviour.
+ NOTE: Profile identities that do not match any profile stored in the NME
+ are ignored during the auto-connect procedure.
+ NOTE: during auto-connect the NME will only attempt to join an existing
+ adhoc network and it will never attempt to host an adhoc network; for
+ hosting and adhoc network, use CSR_WIFI_NME_PROFILE_CONNECT_REQ
+
+ PARAMETERS
+ queue - Message Source Task Queue (Cfm's will be sent to this Queue)
+ interfaceTag - Interface Identifier; unique identifier of an
+ interface
+ profileIdentitysCount - The number of profiles identities in the list.
+ profileIdentitys - Points to the list of profile identities.
+
+*******************************************************************************/
+#define CsrWifiNmeProfileOrderSetReqCreate(msg__, dst__, src__, interfaceTag__, profileIdentitysCount__, profileIdentitys__) \
+ msg__ = kmalloc(sizeof(CsrWifiNmeProfileOrderSetReq), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_NME_PRIM, CSR_WIFI_NME_PROFILE_ORDER_SET_REQ, dst__, src__); \
+ msg__->interfaceTag = (interfaceTag__); \
+ msg__->profileIdentitysCount = (profileIdentitysCount__); \
+ msg__->profileIdentitys = (profileIdentitys__);
+
+#define CsrWifiNmeProfileOrderSetReqSendTo(dst__, src__, interfaceTag__, profileIdentitysCount__, profileIdentitys__) \
+ { \
+ CsrWifiNmeProfileOrderSetReq *msg__; \
+ CsrWifiNmeProfileOrderSetReqCreate(msg__, dst__, src__, interfaceTag__, profileIdentitysCount__, profileIdentitys__); \
+ CsrMsgTransport(dst__, CSR_WIFI_NME_PRIM, msg__); \
+ }
+
+#define CsrWifiNmeProfileOrderSetReqSend(src__, interfaceTag__, profileIdentitysCount__, profileIdentitys__) \
+ CsrWifiNmeProfileOrderSetReqSendTo(CSR_WIFI_NME_IFACEQUEUE, src__, interfaceTag__, profileIdentitysCount__, profileIdentitys__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiNmeProfileOrderSetCfmSend
+
+ DESCRIPTION
+ Confirmation to UNIFI_NME_PROFILE_ORDER_SET.request.
+
+ PARAMETERS
+ queue - Destination Task Queue
+ interfaceTag - Interface Identifier; unique identifier of an interface
+ status - Indicates the success or otherwise of the requested
+ operation.
+
+*******************************************************************************/
+#define CsrWifiNmeProfileOrderSetCfmCreate(msg__, dst__, src__, interfaceTag__, status__) \
+ msg__ = kmalloc(sizeof(CsrWifiNmeProfileOrderSetCfm), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_NME_PRIM, CSR_WIFI_NME_PROFILE_ORDER_SET_CFM, dst__, src__); \
+ msg__->interfaceTag = (interfaceTag__); \
+ msg__->status = (status__);
+
+#define CsrWifiNmeProfileOrderSetCfmSendTo(dst__, src__, interfaceTag__, status__) \
+ { \
+ CsrWifiNmeProfileOrderSetCfm *msg__; \
+ CsrWifiNmeProfileOrderSetCfmCreate(msg__, dst__, src__, interfaceTag__, status__); \
+ CsrSchedMessagePut(dst__, CSR_WIFI_NME_PRIM, msg__); \
+ }
+
+#define CsrWifiNmeProfileOrderSetCfmSend(dst__, interfaceTag__, status__) \
+ CsrWifiNmeProfileOrderSetCfmSendTo(dst__, CSR_WIFI_NME_IFACEQUEUE, interfaceTag__, status__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiNmeProfileSetReqSend
+
+ DESCRIPTION
+ Creates or updates an existing profile in the NME that matches the unique
+ identity of the profile. Each profile is identified by the combination of
+ BSSID and SSID. The profile contains all the required credentials for
+ attempting to connect to the network. Creating or updating a profile via
+ the NME PROFILE SET REQ does NOT add the profile to the preferred profile
+ list within the NME used for the NME auto-connect behaviour.
+
+ PARAMETERS
+ queue - Message Source Task Queue (Cfm's will be sent to this Queue)
+ profile - Specifies the identity and credentials of the network.
+
+*******************************************************************************/
+#define CsrWifiNmeProfileSetReqCreate(msg__, dst__, src__, profile__) \
+ msg__ = kmalloc(sizeof(CsrWifiNmeProfileSetReq), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_NME_PRIM, CSR_WIFI_NME_PROFILE_SET_REQ, dst__, src__); \
+ msg__->profile = (profile__);
+
+#define CsrWifiNmeProfileSetReqSendTo(dst__, src__, profile__) \
+ { \
+ CsrWifiNmeProfileSetReq *msg__; \
+ CsrWifiNmeProfileSetReqCreate(msg__, dst__, src__, profile__); \
+ CsrMsgTransport(dst__, CSR_WIFI_NME_PRIM, msg__); \
+ }
+
+#define CsrWifiNmeProfileSetReqSend(src__, profile__) \
+ CsrWifiNmeProfileSetReqSendTo(CSR_WIFI_NME_IFACEQUEUE, src__, profile__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiNmeProfileSetCfmSend
+
+ DESCRIPTION
+ Reports the status of the NME PROFILE SET REQ; the request will only fail
+ if the details specified in the profile contains an invalid combination
+ of parameters for example specifying the profile as cloaked but not
+ specifying the SSID. The NME doesn't limit the number of profiles that
+ may be created. The NME assumes that the entity configuring it is aware
+ of the appropriate limits.
+
+ PARAMETERS
+ queue - Destination Task Queue
+ status - Indicates the success or otherwise of the requested operation.
+
+*******************************************************************************/
+#define CsrWifiNmeProfileSetCfmCreate(msg__, dst__, src__, status__) \
+ msg__ = kmalloc(sizeof(CsrWifiNmeProfileSetCfm), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_NME_PRIM, CSR_WIFI_NME_PROFILE_SET_CFM, dst__, src__); \
+ msg__->status = (status__);
+
+#define CsrWifiNmeProfileSetCfmSendTo(dst__, src__, status__) \
+ { \
+ CsrWifiNmeProfileSetCfm *msg__; \
+ CsrWifiNmeProfileSetCfmCreate(msg__, dst__, src__, status__); \
+ CsrSchedMessagePut(dst__, CSR_WIFI_NME_PRIM, msg__); \
+ }
+
+#define CsrWifiNmeProfileSetCfmSend(dst__, status__) \
+ CsrWifiNmeProfileSetCfmSendTo(dst__, CSR_WIFI_NME_IFACEQUEUE, status__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiNmeProfileUpdateIndSend
+
+ DESCRIPTION
+ Indication generated from the NME (if an application subscribes to
+ receive it) that informs that application that the contained profile has
+ changed.
+ For example, either the credentials EAP-FAST PAC file or the session data
+ within the profile has changed.
+ It is up to the application whether it stores this updated profile or
+ not.
+
+ PARAMETERS
+ queue - Destination Task Queue
+ interfaceTag - Interface Identifier; unique identifier of an interface
+ profile - The identity and credentials of the network.
+
+*******************************************************************************/
+#define CsrWifiNmeProfileUpdateIndCreate(msg__, dst__, src__, interfaceTag__, profile__) \
+ msg__ = kmalloc(sizeof(CsrWifiNmeProfileUpdateInd), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_NME_PRIM, CSR_WIFI_NME_PROFILE_UPDATE_IND, dst__, src__); \
+ msg__->interfaceTag = (interfaceTag__); \
+ msg__->profile = (profile__);
+
+#define CsrWifiNmeProfileUpdateIndSendTo(dst__, src__, interfaceTag__, profile__) \
+ { \
+ CsrWifiNmeProfileUpdateInd *msg__; \
+ CsrWifiNmeProfileUpdateIndCreate(msg__, dst__, src__, interfaceTag__, profile__); \
+ CsrSchedMessagePut(dst__, CSR_WIFI_NME_PRIM, msg__); \
+ }
+
+#define CsrWifiNmeProfileUpdateIndSend(dst__, interfaceTag__, profile__) \
+ CsrWifiNmeProfileUpdateIndSendTo(dst__, CSR_WIFI_NME_IFACEQUEUE, interfaceTag__, profile__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiNmeSimGsmAuthIndSend
+
+ DESCRIPTION
+ Indication generated from the NME (if an application subscribes to
+ receive it) that requests the UICC Manager to perform a GSM
+ authentication on behalf of the NME. This indication is generated when
+ the NME is attempting to connect to a profile configured for EAP-SIM. An
+ application MUST register to receive this indication for the NME to
+ support the EAP-SIM credential types. Otherwise the NME has no route to
+ obtain the information from the UICC. EAP-SIM authentication requires 2
+ or 3 GSM authentication rounds and therefore 2 or 3 RANDS (GSM Random
+ Challenges) are included.
+
+ PARAMETERS
+ queue - Destination Task Queue
+ randsLength - GSM RAND is 16 bytes long hence valid values are 32 (2 RANDS)
+ or 48 (3 RANDs).
+ rands - 2 or 3 RANDs values.
+
+*******************************************************************************/
+#define CsrWifiNmeSimGsmAuthIndCreate(msg__, dst__, src__, randsLength__, rands__) \
+ msg__ = kmalloc(sizeof(CsrWifiNmeSimGsmAuthInd), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_NME_PRIM, CSR_WIFI_NME_SIM_GSM_AUTH_IND, dst__, src__); \
+ msg__->randsLength = (randsLength__); \
+ msg__->rands = (rands__);
+
+#define CsrWifiNmeSimGsmAuthIndSendTo(dst__, src__, randsLength__, rands__) \
+ { \
+ CsrWifiNmeSimGsmAuthInd *msg__; \
+ CsrWifiNmeSimGsmAuthIndCreate(msg__, dst__, src__, randsLength__, rands__); \
+ CsrSchedMessagePut(dst__, CSR_WIFI_NME_PRIM, msg__); \
+ }
+
+#define CsrWifiNmeSimGsmAuthIndSend(dst__, randsLength__, rands__) \
+ CsrWifiNmeSimGsmAuthIndSendTo(dst__, CSR_WIFI_NME_IFACEQUEUE, randsLength__, rands__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiNmeSimGsmAuthResSend
+
+ DESCRIPTION
+ Response from the application that received the NME SIM GSM AUTH IND. For
+ each GSM authentication round a GSM Ciphering key (Kc) and a signed
+ response (SRES) are produced. Since 2 or 3 GSM authentication rounds are
+ used the 2 or 3 Kc's obtained respectively are combined into one buffer
+ and similarly the 2 or 3 SRES's obtained are combined into another
+ buffer. The order of Kc values (SRES values respectively) in their buffer
+ is the same as that of their corresponding RAND values in the incoming
+ indication.
+
+ PARAMETERS
+ status - Indicates the outcome of the requested operation:
+ STATUS_SUCCESS or STATUS_ERROR
+ kcsLength - Length in Bytes of Kc buffer. Legal values are: 16 or 24.
+ kcs - Kc buffer holding 2 or 3 Kc values.
+ sresLength - Length in Bytes of SRES buffer. Legal values are: 8 or 12.
+ sres - SRES buffer holding 2 or 3 SRES values.
+
+*******************************************************************************/
+#define CsrWifiNmeSimGsmAuthResCreate(msg__, dst__, src__, status__, kcsLength__, kcs__, sresLength__, sres__) \
+ msg__ = kmalloc(sizeof(CsrWifiNmeSimGsmAuthRes), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_NME_PRIM, CSR_WIFI_NME_SIM_GSM_AUTH_RES, dst__, src__); \
+ msg__->status = (status__); \
+ msg__->kcsLength = (kcsLength__); \
+ msg__->kcs = (kcs__); \
+ msg__->sresLength = (sresLength__); \
+ msg__->sres = (sres__);
+
+#define CsrWifiNmeSimGsmAuthResSendTo(dst__, src__, status__, kcsLength__, kcs__, sresLength__, sres__) \
+ { \
+ CsrWifiNmeSimGsmAuthRes *msg__; \
+ CsrWifiNmeSimGsmAuthResCreate(msg__, dst__, src__, status__, kcsLength__, kcs__, sresLength__, sres__); \
+ CsrMsgTransport(dst__, CSR_WIFI_NME_PRIM, msg__); \
+ }
+
+#define CsrWifiNmeSimGsmAuthResSend(src__, status__, kcsLength__, kcs__, sresLength__, sres__) \
+ CsrWifiNmeSimGsmAuthResSendTo(CSR_WIFI_NME_IFACEQUEUE, src__, status__, kcsLength__, kcs__, sresLength__, sres__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiNmeSimImsiGetIndSend
+
+ DESCRIPTION
+ Indication generated from the NME (if an application subscribes to
+ receive it) that requests the IMSI and UICC type from the UICC Manager.
+ This indication is generated when the NME is attempting to connect to a
+ profile configured for EAP-SIM/AKA. An application MUST register to
+ receive this indication for the NME to support the EAP-SIM/AKA credential
+ types. Otherwise the NME has no route to obtain the information from the
+ UICC.
+
+ PARAMETERS
+ queue - Destination Task Queue
+
+*******************************************************************************/
+#define CsrWifiNmeSimImsiGetIndCreate(msg__, dst__, src__) \
+ msg__ = kmalloc(sizeof(CsrWifiNmeSimImsiGetInd), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_NME_PRIM, CSR_WIFI_NME_SIM_IMSI_GET_IND, dst__, src__);
+
+#define CsrWifiNmeSimImsiGetIndSendTo(dst__, src__) \
+ { \
+ CsrWifiNmeSimImsiGetInd *msg__; \
+ CsrWifiNmeSimImsiGetIndCreate(msg__, dst__, src__); \
+ CsrSchedMessagePut(dst__, CSR_WIFI_NME_PRIM, msg__); \
+ }
+
+#define CsrWifiNmeSimImsiGetIndSend(dst__) \
+ CsrWifiNmeSimImsiGetIndSendTo(dst__, CSR_WIFI_NME_IFACEQUEUE)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiNmeSimImsiGetResSend
+
+ DESCRIPTION
+ Response from the application that received the NME SIM IMSI GET IND.
+
+ PARAMETERS
+ status - Indicates the outcome of the requested operation: STATUS_SUCCESS
+ or STATUS_ERROR.
+ imsi - The value of the IMSI obtained from the UICC.
+ cardType - The UICC type (GSM only (SIM), UMTS only (USIM), Both).
+
+*******************************************************************************/
+#define CsrWifiNmeSimImsiGetResCreate(msg__, dst__, src__, status__, imsi__, cardType__) \
+ msg__ = kmalloc(sizeof(CsrWifiNmeSimImsiGetRes), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_NME_PRIM, CSR_WIFI_NME_SIM_IMSI_GET_RES, dst__, src__); \
+ msg__->status = (status__); \
+ msg__->imsi = (imsi__); \
+ msg__->cardType = (cardType__);
+
+#define CsrWifiNmeSimImsiGetResSendTo(dst__, src__, status__, imsi__, cardType__) \
+ { \
+ CsrWifiNmeSimImsiGetRes *msg__; \
+ CsrWifiNmeSimImsiGetResCreate(msg__, dst__, src__, status__, imsi__, cardType__); \
+ CsrMsgTransport(dst__, CSR_WIFI_NME_PRIM, msg__); \
+ }
+
+#define CsrWifiNmeSimImsiGetResSend(src__, status__, imsi__, cardType__) \
+ CsrWifiNmeSimImsiGetResSendTo(CSR_WIFI_NME_IFACEQUEUE, src__, status__, imsi__, cardType__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiNmeSimUmtsAuthIndSend
+
+ DESCRIPTION
+ Indication generated from the NME (if an application subscribes to
+ receive it) that requests the UICC Manager to perform a UMTS
+ authentication on behalf of the NME. This indication is generated when
+ the NME is attempting to connect to a profile configured for EAP-AKA. An
+ application MUST register to receive this indication for the NME to
+ support the EAP-AKA credential types. Otherwise the NME has no route to
+ obtain the information from the USIM. EAP-AKA requires one UMTS
+ authentication round and therefore only one RAND and one AUTN values are
+ included.
+
+ PARAMETERS
+ queue - Destination Task Queue
+ rand - UMTS RAND value.
+ autn - UMTS AUTN value.
+
+*******************************************************************************/
+#define CsrWifiNmeSimUmtsAuthIndCreate(msg__, dst__, src__, rand__, autn__) \
+ msg__ = kmalloc(sizeof(CsrWifiNmeSimUmtsAuthInd), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_NME_PRIM, CSR_WIFI_NME_SIM_UMTS_AUTH_IND, dst__, src__); \
+ memcpy(msg__->rand, (rand__), sizeof(u8) * 16); \
+ memcpy(msg__->autn, (autn__), sizeof(u8) * 16);
+
+#define CsrWifiNmeSimUmtsAuthIndSendTo(dst__, src__, rand__, autn__) \
+ { \
+ CsrWifiNmeSimUmtsAuthInd *msg__; \
+ CsrWifiNmeSimUmtsAuthIndCreate(msg__, dst__, src__, rand__, autn__); \
+ CsrSchedMessagePut(dst__, CSR_WIFI_NME_PRIM, msg__); \
+ }
+
+#define CsrWifiNmeSimUmtsAuthIndSend(dst__, rand__, autn__) \
+ CsrWifiNmeSimUmtsAuthIndSendTo(dst__, CSR_WIFI_NME_IFACEQUEUE, rand__, autn__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiNmeSimUmtsAuthResSend
+
+ DESCRIPTION
+ Response from the application that received the NME SIM UMTS AUTH IND.
+ The values of umtsCipherKey, umtsIntegrityKey, resParameterLength and
+ resParameter are only meanigful when result = UMTS_AUTH_RESULT_SUCCESS.
+ The value of auts is only meaningful when
+ result=UMTS_AUTH_RESULT_SYNC_FAIL.
+
+ PARAMETERS
+ status - Indicates the outcome of the requested operation:
+ STATUS_SUCCESS or STATUS_ERROR.
+ result - The result of UMTS authentication as performed by the
+ UICC which could be: Success, Authentication Reject or
+ Synchronisation Failure. For all these 3 outcomes the
+ value of status is success.
+ umtsCipherKey - The UMTS Cipher Key as calculated and returned by the
+ UICC.
+ umtsIntegrityKey - The UMTS Integrity Key as calculated and returned by
+ the UICC.
+ resParameterLength - The length (in bytes) of the RES parameter (min=4; max
+ = 16).
+ resParameter - The RES parameter as calculated and returned by the
+ UICC.
+ auts - The AUTS parameter as calculated and returned by the
+ UICC.
+
+*******************************************************************************/
+#define CsrWifiNmeSimUmtsAuthResCreate(msg__, dst__, src__, status__, result__, umtsCipherKey__, umtsIntegrityKey__, resParameterLength__, resParameter__, auts__) \
+ msg__ = kmalloc(sizeof(CsrWifiNmeSimUmtsAuthRes), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_NME_PRIM, CSR_WIFI_NME_SIM_UMTS_AUTH_RES, dst__, src__); \
+ msg__->status = (status__); \
+ msg__->result = (result__); \
+ memcpy(msg__->umtsCipherKey, (umtsCipherKey__), sizeof(u8) * 16); \
+ memcpy(msg__->umtsIntegrityKey, (umtsIntegrityKey__), sizeof(u8) * 16); \
+ msg__->resParameterLength = (resParameterLength__); \
+ msg__->resParameter = (resParameter__); \
+ memcpy(msg__->auts, (auts__), sizeof(u8) * 14);
+
+#define CsrWifiNmeSimUmtsAuthResSendTo(dst__, src__, status__, result__, umtsCipherKey__, umtsIntegrityKey__, resParameterLength__, resParameter__, auts__) \
+ { \
+ CsrWifiNmeSimUmtsAuthRes *msg__; \
+ CsrWifiNmeSimUmtsAuthResCreate(msg__, dst__, src__, status__, result__, umtsCipherKey__, umtsIntegrityKey__, resParameterLength__, resParameter__, auts__); \
+ CsrMsgTransport(dst__, CSR_WIFI_NME_PRIM, msg__); \
+ }
+
+#define CsrWifiNmeSimUmtsAuthResSend(src__, status__, result__, umtsCipherKey__, umtsIntegrityKey__, resParameterLength__, resParameter__, auts__) \
+ CsrWifiNmeSimUmtsAuthResSendTo(CSR_WIFI_NME_IFACEQUEUE, src__, status__, result__, umtsCipherKey__, umtsIntegrityKey__, resParameterLength__, resParameter__, auts__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiNmeWpsCancelReqSend
+
+ DESCRIPTION
+ Requests the NME to cancel any WPS procedure that it is currently
+ performing. This includes WPS registrar activities started because of
+ CSR_WIFI_NME_AP_REGISTER.request
+
+ PARAMETERS
+ queue - Message Source Task Queue (Cfm's will be sent to this Queue)
+ interfaceTag - Interface Identifier; unique identifier of an interface
+
+*******************************************************************************/
+#define CsrWifiNmeWpsCancelReqCreate(msg__, dst__, src__, interfaceTag__) \
+ msg__ = kmalloc(sizeof(CsrWifiNmeWpsCancelReq), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_NME_PRIM, CSR_WIFI_NME_WPS_CANCEL_REQ, dst__, src__); \
+ msg__->interfaceTag = (interfaceTag__);
+
+#define CsrWifiNmeWpsCancelReqSendTo(dst__, src__, interfaceTag__) \
+ { \
+ CsrWifiNmeWpsCancelReq *msg__; \
+ CsrWifiNmeWpsCancelReqCreate(msg__, dst__, src__, interfaceTag__); \
+ CsrMsgTransport(dst__, CSR_WIFI_NME_PRIM, msg__); \
+ }
+
+#define CsrWifiNmeWpsCancelReqSend(src__, interfaceTag__) \
+ CsrWifiNmeWpsCancelReqSendTo(CSR_WIFI_NME_IFACEQUEUE, src__, interfaceTag__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiNmeWpsCancelCfmSend
+
+ DESCRIPTION
+ Reports the status of the NME WPS REQ, the request is always SUCCESSFUL.
+
+ PARAMETERS
+ queue - Destination Task Queue
+ interfaceTag - Interface Identifier; unique identifier of an interface
+ status - Only returns CSR_WIFI_NME_STATUS_SUCCESS
+
+*******************************************************************************/
+#define CsrWifiNmeWpsCancelCfmCreate(msg__, dst__, src__, interfaceTag__, status__) \
+ msg__ = kmalloc(sizeof(CsrWifiNmeWpsCancelCfm), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_NME_PRIM, CSR_WIFI_NME_WPS_CANCEL_CFM, dst__, src__); \
+ msg__->interfaceTag = (interfaceTag__); \
+ msg__->status = (status__);
+
+#define CsrWifiNmeWpsCancelCfmSendTo(dst__, src__, interfaceTag__, status__) \
+ { \
+ CsrWifiNmeWpsCancelCfm *msg__; \
+ CsrWifiNmeWpsCancelCfmCreate(msg__, dst__, src__, interfaceTag__, status__); \
+ CsrSchedMessagePut(dst__, CSR_WIFI_NME_PRIM, msg__); \
+ }
+
+#define CsrWifiNmeWpsCancelCfmSend(dst__, interfaceTag__, status__) \
+ CsrWifiNmeWpsCancelCfmSendTo(dst__, CSR_WIFI_NME_IFACEQUEUE, interfaceTag__, status__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiNmeWpsCfmSend
+
+ DESCRIPTION
+ Reports the status of the NME WPS REQ.
+ If CSR_WIFI_NME_STATUS_SUCCESS, the profile parameter contains the
+ identity and credentials of the AP.
+
+ PARAMETERS
+ queue - Destination Task Queue
+ interfaceTag - Interface Identifier; unique identifier of an interface
+ status - Indicates the success or otherwise of the requested
+ operation.
+ profile - This parameter is relevant only if
+ status==CSR_WIFI_NME_STATUS_SUCCESS.
+ The identity and credentials of the network.
+
+*******************************************************************************/
+#define CsrWifiNmeWpsCfmCreate(msg__, dst__, src__, interfaceTag__, status__, profile__) \
+ msg__ = kmalloc(sizeof(CsrWifiNmeWpsCfm), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_NME_PRIM, CSR_WIFI_NME_WPS_CFM, dst__, src__); \
+ msg__->interfaceTag = (interfaceTag__); \
+ msg__->status = (status__); \
+ msg__->profile = (profile__);
+
+#define CsrWifiNmeWpsCfmSendTo(dst__, src__, interfaceTag__, status__, profile__) \
+ { \
+ CsrWifiNmeWpsCfm *msg__; \
+ CsrWifiNmeWpsCfmCreate(msg__, dst__, src__, interfaceTag__, status__, profile__); \
+ CsrSchedMessagePut(dst__, CSR_WIFI_NME_PRIM, msg__); \
+ }
+
+#define CsrWifiNmeWpsCfmSend(dst__, interfaceTag__, status__, profile__) \
+ CsrWifiNmeWpsCfmSendTo(dst__, CSR_WIFI_NME_IFACEQUEUE, interfaceTag__, status__, profile__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiNmeWpsConfigSetReqSend
+
+ DESCRIPTION
+ This primitive passes the WPS information for the device to NME. This may
+ be accepted only if no interface is active.
+
+ PARAMETERS
+ queue - Message Source Task Queue (Cfm's will be sent to this Queue)
+ wpsConfig - WPS config.
+
+*******************************************************************************/
+#define CsrWifiNmeWpsConfigSetReqCreate(msg__, dst__, src__, wpsConfig__) \
+ msg__ = kmalloc(sizeof(CsrWifiNmeWpsConfigSetReq), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_NME_PRIM, CSR_WIFI_NME_WPS_CONFIG_SET_REQ, dst__, src__); \
+ msg__->wpsConfig = (wpsConfig__);
+
+#define CsrWifiNmeWpsConfigSetReqSendTo(dst__, src__, wpsConfig__) \
+ { \
+ CsrWifiNmeWpsConfigSetReq *msg__; \
+ CsrWifiNmeWpsConfigSetReqCreate(msg__, dst__, src__, wpsConfig__); \
+ CsrMsgTransport(dst__, CSR_WIFI_NME_PRIM, msg__); \
+ }
+
+#define CsrWifiNmeWpsConfigSetReqSend(src__, wpsConfig__) \
+ CsrWifiNmeWpsConfigSetReqSendTo(CSR_WIFI_NME_IFACEQUEUE, src__, wpsConfig__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiNmeWpsConfigSetCfmSend
+
+ DESCRIPTION
+ Confirm.
+
+ PARAMETERS
+ queue - Destination Task Queue
+ status - Status of the request.
+
+*******************************************************************************/
+#define CsrWifiNmeWpsConfigSetCfmCreate(msg__, dst__, src__, status__) \
+ msg__ = kmalloc(sizeof(CsrWifiNmeWpsConfigSetCfm), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_NME_PRIM, CSR_WIFI_NME_WPS_CONFIG_SET_CFM, dst__, src__); \
+ msg__->status = (status__);
+
+#define CsrWifiNmeWpsConfigSetCfmSendTo(dst__, src__, status__) \
+ { \
+ CsrWifiNmeWpsConfigSetCfm *msg__; \
+ CsrWifiNmeWpsConfigSetCfmCreate(msg__, dst__, src__, status__); \
+ CsrSchedMessagePut(dst__, CSR_WIFI_NME_PRIM, msg__); \
+ }
+
+#define CsrWifiNmeWpsConfigSetCfmSend(dst__, status__) \
+ CsrWifiNmeWpsConfigSetCfmSendTo(dst__, CSR_WIFI_NME_IFACEQUEUE, status__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiNmeWpsReqSend
+
+ DESCRIPTION
+ Requests the NME to look for WPS enabled APs and attempt to perform WPS
+ to determine the appropriate security credentials to connect to the AP.
+ If the PIN == '00000000' then 'push button mode' is indicated, otherwise
+ the PIN has to match that of the AP. 4 digit pin is passed by sending the
+ pin digits in pin[0]..pin[3] and rest of the contents filled with '-'.
+
+ PARAMETERS
+ queue - Message Source Task Queue (Cfm's will be sent to this Queue)
+ interfaceTag - Interface Identifier; unique identifier of an interface
+ pin - PIN value.
+ ssid - Service Set identifier
+ bssid - ID of Basic Service Set for which a WPS connection attempt is
+ being made.
+
+*******************************************************************************/
+#define CsrWifiNmeWpsReqCreate(msg__, dst__, src__, interfaceTag__, pin__, ssid__, bssid__) \
+ msg__ = kmalloc(sizeof(CsrWifiNmeWpsReq), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_NME_PRIM, CSR_WIFI_NME_WPS_REQ, dst__, src__); \
+ msg__->interfaceTag = (interfaceTag__); \
+ memcpy(msg__->pin, (pin__), sizeof(u8) * 8); \
+ msg__->ssid = (ssid__); \
+ msg__->bssid = (bssid__);
+
+#define CsrWifiNmeWpsReqSendTo(dst__, src__, interfaceTag__, pin__, ssid__, bssid__) \
+ { \
+ CsrWifiNmeWpsReq *msg__; \
+ CsrWifiNmeWpsReqCreate(msg__, dst__, src__, interfaceTag__, pin__, ssid__, bssid__); \
+ CsrMsgTransport(dst__, CSR_WIFI_NME_PRIM, msg__); \
+ }
+
+#define CsrWifiNmeWpsReqSend(src__, interfaceTag__, pin__, ssid__, bssid__) \
+ CsrWifiNmeWpsReqSendTo(CSR_WIFI_NME_IFACEQUEUE, src__, interfaceTag__, pin__, ssid__, bssid__)
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* CSR_WIFI_NME_LIB_H__ */
diff --git a/drivers/staging/csr/csr_wifi_nme_prim.h b/drivers/staging/csr/csr_wifi_nme_prim.h
new file mode 100644
index 000000000000..20dc77971f94
--- /dev/null
+++ b/drivers/staging/csr/csr_wifi_nme_prim.h
@@ -0,0 +1,1666 @@
+/*****************************************************************************
+
+ (c) Cambridge Silicon Radio Limited 2011
+ All rights reserved and confidential information of CSR
+
+ Refer to LICENSE.txt included with this source for details
+ on the license terms.
+
+*****************************************************************************/
+
+/* Note: this is an auto-generated file. */
+
+#ifndef CSR_WIFI_NME_PRIM_H__
+#define CSR_WIFI_NME_PRIM_H__
+
+#include <linux/types.h>
+#include "csr_prim_defs.h"
+#include "csr_sched.h"
+#include "csr_wifi_common.h"
+#include "csr_result.h"
+#include "csr_wifi_fsm_event.h"
+#include "csr_wifi_sme_prim.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef CSR_WIFI_NME_ENABLE
+#error CSR_WIFI_NME_ENABLE MUST be defined inorder to use csr_wifi_nme_prim.h
+#endif
+
+#define CSR_WIFI_NME_PRIM (0x0424)
+
+typedef CsrPrim CsrWifiNmePrim;
+
+typedef void (*CsrWifiNmeFrameFreeFunction)(void *frame);
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiNmeAuthMode
+
+ DESCRIPTION
+ WiFi Authentication Mode
+
+ VALUES
+ CSR_WIFI_NME_AUTH_MODE_80211_OPEN
+ - Connects to an open system network (i.e. no authentication,
+ no encryption) or to a WEP enabled network.
+ CSR_WIFI_NME_AUTH_MODE_80211_SHARED
+ - Connect to a WEP enabled network.
+ CSR_WIFI_NME_AUTH_MODE_8021X_WPA
+ - Connects to a WPA Enterprise enabled network.
+ CSR_WIFI_NME_AUTH_MODE_8021X_WPAPSK
+ - Connects to a WPA with Pre-Shared Key enabled network.
+ CSR_WIFI_NME_AUTH_MODE_8021X_WPA2
+ - Connects to a WPA2 Enterprise enabled network.
+ CSR_WIFI_NME_AUTH_MODE_8021X_WPA2PSK
+ - Connects to a WPA2 with Pre-Shared Key enabled network.
+ CSR_WIFI_NME_AUTH_MODE_8021X_CCKM
+ - Connects to a CCKM enabled network.
+ CSR_WIFI_NME_AUTH_MODE_WAPI_WAI
+ - Connects to a WAPI Enterprise enabled network.
+ CSR_WIFI_NME_AUTH_MODE_WAPI_WAIPSK
+ - Connects to a WAPI with Pre-Shared Key enabled network.
+ CSR_WIFI_NME_AUTH_MODE_8021X_OTHER1X
+ - For future use.
+
+*******************************************************************************/
+typedef u16 CsrWifiNmeAuthMode;
+#define CSR_WIFI_NME_AUTH_MODE_80211_OPEN ((CsrWifiNmeAuthMode) 0x0001)
+#define CSR_WIFI_NME_AUTH_MODE_80211_SHARED ((CsrWifiNmeAuthMode) 0x0002)
+#define CSR_WIFI_NME_AUTH_MODE_8021X_WPA ((CsrWifiNmeAuthMode) 0x0004)
+#define CSR_WIFI_NME_AUTH_MODE_8021X_WPAPSK ((CsrWifiNmeAuthMode) 0x0008)
+#define CSR_WIFI_NME_AUTH_MODE_8021X_WPA2 ((CsrWifiNmeAuthMode) 0x0010)
+#define CSR_WIFI_NME_AUTH_MODE_8021X_WPA2PSK ((CsrWifiNmeAuthMode) 0x0020)
+#define CSR_WIFI_NME_AUTH_MODE_8021X_CCKM ((CsrWifiNmeAuthMode) 0x0040)
+#define CSR_WIFI_NME_AUTH_MODE_WAPI_WAI ((CsrWifiNmeAuthMode) 0x0080)
+#define CSR_WIFI_NME_AUTH_MODE_WAPI_WAIPSK ((CsrWifiNmeAuthMode) 0x0100)
+#define CSR_WIFI_NME_AUTH_MODE_8021X_OTHER1X ((CsrWifiNmeAuthMode) 0x0200)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiNmeBssType
+
+ DESCRIPTION
+ Type of BSS
+
+ VALUES
+ CSR_WIFI_NME_BSS_TYPE_INFRASTRUCTURE
+ - Infrastructure BSS type where access to the network is via
+ one or several Access Points.
+ CSR_WIFI_NME_BSS_TYPE_ADHOC
+ - Adhoc or Independent BSS Type where one Station acts as a
+ host and future stations can join the adhoc network without
+ needing an access point.
+ CSR_WIFI_NME_BSS_TYPE_RESERVED
+ - To be in sync with SME.This is not used.
+ CSR_WIFI_NME_BSS_TYPE_P2P
+ - P2P mode of operation.
+
+*******************************************************************************/
+typedef u8 CsrWifiNmeBssType;
+#define CSR_WIFI_NME_BSS_TYPE_INFRASTRUCTURE ((CsrWifiNmeBssType) 0x00)
+#define CSR_WIFI_NME_BSS_TYPE_ADHOC ((CsrWifiNmeBssType) 0x01)
+#define CSR_WIFI_NME_BSS_TYPE_RESERVED ((CsrWifiNmeBssType) 0x02)
+#define CSR_WIFI_NME_BSS_TYPE_P2P ((CsrWifiNmeBssType) 0x03)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiNmeCcxOptionsMask
+
+ DESCRIPTION
+ Enumeration type defining possible mask values for setting CCX options.
+
+ VALUES
+ CSR_WIFI_NME_CCX_OPTION_NONE - No CCX option is set.
+ CSR_WIFI_NME_CCX_OPTION_CCKM - CCX option cckm is set.
+
+*******************************************************************************/
+typedef u8 CsrWifiNmeCcxOptionsMask;
+#define CSR_WIFI_NME_CCX_OPTION_NONE ((CsrWifiNmeCcxOptionsMask) 0x00)
+#define CSR_WIFI_NME_CCX_OPTION_CCKM ((CsrWifiNmeCcxOptionsMask) 0x01)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiNmeConfigAction
+
+ DESCRIPTION
+
+ VALUES
+ CSR_WIFI_PIN_ENTRY_PUSH_BUTTON -
+ CSR_WIFI_PIN_ENTRY_DISPLAY_PIN -
+ CSR_WIFI_PIN_ENTRY_ENTER_PIN -
+
+*******************************************************************************/
+typedef u8 CsrWifiNmeConfigAction;
+#define CSR_WIFI_PIN_ENTRY_PUSH_BUTTON ((CsrWifiNmeConfigAction) 0x00)
+#define CSR_WIFI_PIN_ENTRY_DISPLAY_PIN ((CsrWifiNmeConfigAction) 0x01)
+#define CSR_WIFI_PIN_ENTRY_ENTER_PIN ((CsrWifiNmeConfigAction) 0x02)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiNmeConnectionStatus
+
+ DESCRIPTION
+ Indicate the NME Connection Status when connecting or when disconnecting
+
+ VALUES
+ CSR_WIFI_NME_CONNECTION_STATUS_CONNECTION_STATUS_DISCONNECTED
+ - NME is disconnected.
+ CSR_WIFI_NME_CONNECTION_STATUS_CONNECTION_STATUS_CONNECTING
+ - NME is in the process of connecting.
+ CSR_WIFI_NME_CONNECTION_STATUS_CONNECTION_STATUS_AUTHENTICATING
+ - NME is in the authentication stage of a connection attempt.
+ CSR_WIFI_NME_CONNECTION_STATUS_CONNECTION_STATUS_CONNECTED
+ - NME is connected.
+ CSR_WIFI_NME_CONNECTION_STATUS_CONNECTION_STATUS_DISCONNECTING
+ - NME is in the process of disconnecting.
+
+*******************************************************************************/
+typedef u8 CsrWifiNmeConnectionStatus;
+#define CSR_WIFI_NME_CONNECTION_STATUS_CONNECTION_STATUS_DISCONNECTED ((CsrWifiNmeConnectionStatus) 0x00)
+#define CSR_WIFI_NME_CONNECTION_STATUS_CONNECTION_STATUS_CONNECTING ((CsrWifiNmeConnectionStatus) 0x01)
+#define CSR_WIFI_NME_CONNECTION_STATUS_CONNECTION_STATUS_AUTHENTICATING ((CsrWifiNmeConnectionStatus) 0x02)
+#define CSR_WIFI_NME_CONNECTION_STATUS_CONNECTION_STATUS_CONNECTED ((CsrWifiNmeConnectionStatus) 0x03)
+#define CSR_WIFI_NME_CONNECTION_STATUS_CONNECTION_STATUS_DISCONNECTING ((CsrWifiNmeConnectionStatus) 0x04)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiNmeCredentialType
+
+ DESCRIPTION
+ NME Credential Types
+
+ VALUES
+ CSR_WIFI_NME_CREDENTIAL_TYPE_OPEN_SYSTEM
+ - Credential Type Open System.
+ CSR_WIFI_NME_CREDENTIAL_TYPE_WEP64
+ - Credential Type WEP-64
+ CSR_WIFI_NME_CREDENTIAL_TYPE_WEP128
+ - Credential Type WEP-128
+ CSR_WIFI_NME_CREDENTIAL_TYPE_WPA_PSK
+ - Credential Type WPA Pre-Shared Key
+ CSR_WIFI_NME_CREDENTIAL_TYPE_WPA_PASSPHRASE
+ - Credential Type WPA pass phrase
+ CSR_WIFI_NME_CREDENTIAL_TYPE_WPA2_PSK
+ - Credential Type WPA2 Pre-Shared Key.
+ CSR_WIFI_NME_CREDENTIAL_TYPE_WPA2_PASSPHRASE
+ - Credential Type WPA2 pass phrase
+ CSR_WIFI_NME_CREDENTIAL_TYPE_WAPI_PSK
+ - Credential Type WAPI Pre-Shared Key.
+ CSR_WIFI_NME_CREDENTIAL_TYPE_WAPI_PASSPHRASE
+ - Credential Type WAPI pass phrase
+ CSR_WIFI_NME_CREDENTIAL_TYPE_WAPI
+ - Credential Type WAPI certificates
+ CSR_WIFI_NME_CREDENTIAL_TYPE_8021X
+ - Credential Type 802.1X: the associated type supports
+ FAST/LEAP/TLS/TTLS/PEAP/etc.
+
+*******************************************************************************/
+typedef u16 CsrWifiNmeCredentialType;
+#define CSR_WIFI_NME_CREDENTIAL_TYPE_OPEN_SYSTEM ((CsrWifiNmeCredentialType) 0x0000)
+#define CSR_WIFI_NME_CREDENTIAL_TYPE_WEP64 ((CsrWifiNmeCredentialType) 0x0001)
+#define CSR_WIFI_NME_CREDENTIAL_TYPE_WEP128 ((CsrWifiNmeCredentialType) 0x0002)
+#define CSR_WIFI_NME_CREDENTIAL_TYPE_WPA_PSK ((CsrWifiNmeCredentialType) 0x0003)
+#define CSR_WIFI_NME_CREDENTIAL_TYPE_WPA_PASSPHRASE ((CsrWifiNmeCredentialType) 0x0004)
+#define CSR_WIFI_NME_CREDENTIAL_TYPE_WPA2_PSK ((CsrWifiNmeCredentialType) 0x0005)
+#define CSR_WIFI_NME_CREDENTIAL_TYPE_WPA2_PASSPHRASE ((CsrWifiNmeCredentialType) 0x0006)
+#define CSR_WIFI_NME_CREDENTIAL_TYPE_WAPI_PSK ((CsrWifiNmeCredentialType) 0x0007)
+#define CSR_WIFI_NME_CREDENTIAL_TYPE_WAPI_PASSPHRASE ((CsrWifiNmeCredentialType) 0x0008)
+#define CSR_WIFI_NME_CREDENTIAL_TYPE_WAPI ((CsrWifiNmeCredentialType) 0x0009)
+#define CSR_WIFI_NME_CREDENTIAL_TYPE_8021X ((CsrWifiNmeCredentialType) 0x000A)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiNmeEapMethod
+
+ DESCRIPTION
+ Outer EAP method with possibly inner method.
+
+ VALUES
+ CSR_WIFI_NME_EAP_METHOD_TLS
+ - EAP-TLS Method.
+ CSR_WIFI_NME_EAP_METHOD_TTLS_MSCHAPV2
+ - EAP-TTLS Method with MSCHAPV2.
+ CSR_WIFI_NME_EAP_METHOD_PEAP_GTC
+ - EAP-PEAP Method with GTC.
+ CSR_WIFI_NME_EAP_METHOD_PEAP_MSCHAPV2
+ - EAP-PEAP Method with MSCHAPV2.
+ CSR_WIFI_NME_EAP_METHOD_SIM
+ - EAP-SIM Method.
+ CSR_WIFI_NME_EAP_METHOD_AKA
+ - EAP-AKA Method.
+ CSR_WIFI_NME_EAP_METHOD_FAST_GTC
+ - EAP-FAST Method with GTC.
+ CSR_WIFI_NME_EAP_METHOD_FAST_MSCHAPV2
+ - EAP-FAST Method with MSCHAPV2.
+ CSR_WIFI_NME_EAP_METHOD_LEAP
+ - EAP-LEAP Method.
+
+*******************************************************************************/
+typedef u16 CsrWifiNmeEapMethod;
+#define CSR_WIFI_NME_EAP_METHOD_TLS ((CsrWifiNmeEapMethod) 0x0001)
+#define CSR_WIFI_NME_EAP_METHOD_TTLS_MSCHAPV2 ((CsrWifiNmeEapMethod) 0x0002)
+#define CSR_WIFI_NME_EAP_METHOD_PEAP_GTC ((CsrWifiNmeEapMethod) 0x0004)
+#define CSR_WIFI_NME_EAP_METHOD_PEAP_MSCHAPV2 ((CsrWifiNmeEapMethod) 0x0008)
+#define CSR_WIFI_NME_EAP_METHOD_SIM ((CsrWifiNmeEapMethod) 0x0010)
+#define CSR_WIFI_NME_EAP_METHOD_AKA ((CsrWifiNmeEapMethod) 0x0020)
+#define CSR_WIFI_NME_EAP_METHOD_FAST_GTC ((CsrWifiNmeEapMethod) 0x0040)
+#define CSR_WIFI_NME_EAP_METHOD_FAST_MSCHAPV2 ((CsrWifiNmeEapMethod) 0x0080)
+#define CSR_WIFI_NME_EAP_METHOD_LEAP ((CsrWifiNmeEapMethod) 0x0100)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiNmeEncryption
+
+ DESCRIPTION
+ WiFi Encryption method
+
+ VALUES
+ CSR_WIFI_NME_ENCRYPTION_CIPHER_NONE
+ - No encryprion set.
+ CSR_WIFI_NME_ENCRYPTION_CIPHER_PAIRWISE_WEP40
+ - 40 bytes WEP key for peer to peer communication.
+ CSR_WIFI_NME_ENCRYPTION_CIPHER_PAIRWISE_WEP104
+ - 104 bytes WEP key for peer to peer communication.
+ CSR_WIFI_NME_ENCRYPTION_CIPHER_PAIRWISE_TKIP
+ - TKIP key for peer to peer communication.
+ CSR_WIFI_NME_ENCRYPTION_CIPHER_PAIRWISE_CCMP
+ - CCMP key for peer to peer communication.
+ CSR_WIFI_NME_ENCRYPTION_CIPHER_PAIRWISE_SMS4
+ - SMS4 key for peer to peer communication.
+ CSR_WIFI_NME_ENCRYPTION_CIPHER_GROUP_WEP40
+ - 40 bytes WEP key for broadcast messages.
+ CSR_WIFI_NME_ENCRYPTION_CIPHER_GROUP_WEP104
+ - 104 bytes WEP key for broadcast messages.
+ CSR_WIFI_NME_ENCRYPTION_CIPHER_GROUP_TKIP
+ - TKIP key for broadcast messages.
+ CSR_WIFI_NME_ENCRYPTION_CIPHER_GROUP_CCMP
+ - CCMP key for broadcast messages
+ CSR_WIFI_NME_ENCRYPTION_CIPHER_GROUP_SMS4
+ - SMS4 key for broadcast messages.
+
+*******************************************************************************/
+typedef u16 CsrWifiNmeEncryption;
+#define CSR_WIFI_NME_ENCRYPTION_CIPHER_NONE ((CsrWifiNmeEncryption) 0x0000)
+#define CSR_WIFI_NME_ENCRYPTION_CIPHER_PAIRWISE_WEP40 ((CsrWifiNmeEncryption) 0x0001)
+#define CSR_WIFI_NME_ENCRYPTION_CIPHER_PAIRWISE_WEP104 ((CsrWifiNmeEncryption) 0x0002)
+#define CSR_WIFI_NME_ENCRYPTION_CIPHER_PAIRWISE_TKIP ((CsrWifiNmeEncryption) 0x0004)
+#define CSR_WIFI_NME_ENCRYPTION_CIPHER_PAIRWISE_CCMP ((CsrWifiNmeEncryption) 0x0008)
+#define CSR_WIFI_NME_ENCRYPTION_CIPHER_PAIRWISE_SMS4 ((CsrWifiNmeEncryption) 0x0010)
+#define CSR_WIFI_NME_ENCRYPTION_CIPHER_GROUP_WEP40 ((CsrWifiNmeEncryption) 0x0020)
+#define CSR_WIFI_NME_ENCRYPTION_CIPHER_GROUP_WEP104 ((CsrWifiNmeEncryption) 0x0040)
+#define CSR_WIFI_NME_ENCRYPTION_CIPHER_GROUP_TKIP ((CsrWifiNmeEncryption) 0x0080)
+#define CSR_WIFI_NME_ENCRYPTION_CIPHER_GROUP_CCMP ((CsrWifiNmeEncryption) 0x0100)
+#define CSR_WIFI_NME_ENCRYPTION_CIPHER_GROUP_SMS4 ((CsrWifiNmeEncryption) 0x0200)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiNmeIndications
+
+ DESCRIPTION
+ NME indications
+
+ VALUES
+ CSR_WIFI_NME_INDICATIONS_IND_AP_STATION
+ - NME AP Station Indication.
+ CSR_WIFI_NME_INDICATIONS_IND_AP_STOP
+ - NME AP Stop Indication.
+ CSR_WIFI_NME_INDICATIONS_IND_SIM_UMTS_AUTH
+ - NME UMTS Authentication Indication.
+ CSR_WIFI_NME_INDICATIONS_IND_P2P_GROUP_START
+ - NME P2P Group Start Indication.
+ CSR_WIFI_NME_INDICATIONS_IND_P2P_GROUP_STATUS
+ - NME P2P Group Status Indication.
+ CSR_WIFI_NME_INDICATIONS_IND_P2P_GROUP_ROLE
+ - NME P2P Group Role Indication.
+ CSR_WIFI_NME_INDICATIONS_IND_PROFILE_DISCONNECT
+ - NME Profile Disconnect Indication.
+ CSR_WIFI_NME_INDICATIONS_IND_PROFILE_UPDATE
+ - NME Profile Update Indication.
+ CSR_WIFI_NME_INDICATIONS_IND_SIM_IMSI_GET
+ - NME GET IMSI Indication.
+ CSR_WIFI_NME_INDICATIONS_IND_SIM_GSM_AUTH
+ - NME GSM Authentication Indication.
+ CSR_WIFI_NME_INDICATIONS_ALL
+ - Used to register for all available indications
+
+*******************************************************************************/
+typedef u32 CsrWifiNmeIndications;
+#define CSR_WIFI_NME_INDICATIONS_IND_AP_STATION ((CsrWifiNmeIndications) 0x00100000)
+#define CSR_WIFI_NME_INDICATIONS_IND_AP_STOP ((CsrWifiNmeIndications) 0x00200000)
+#define CSR_WIFI_NME_INDICATIONS_IND_SIM_UMTS_AUTH ((CsrWifiNmeIndications) 0x01000000)
+#define CSR_WIFI_NME_INDICATIONS_IND_P2P_GROUP_START ((CsrWifiNmeIndications) 0x02000000)
+#define CSR_WIFI_NME_INDICATIONS_IND_P2P_GROUP_STATUS ((CsrWifiNmeIndications) 0x04000000)
+#define CSR_WIFI_NME_INDICATIONS_IND_P2P_GROUP_ROLE ((CsrWifiNmeIndications) 0x08000000)
+#define CSR_WIFI_NME_INDICATIONS_IND_PROFILE_DISCONNECT ((CsrWifiNmeIndications) 0x10000000)
+#define CSR_WIFI_NME_INDICATIONS_IND_PROFILE_UPDATE ((CsrWifiNmeIndications) 0x20000000)
+#define CSR_WIFI_NME_INDICATIONS_IND_SIM_IMSI_GET ((CsrWifiNmeIndications) 0x40000000)
+#define CSR_WIFI_NME_INDICATIONS_IND_SIM_GSM_AUTH ((CsrWifiNmeIndications) 0x80000000)
+#define CSR_WIFI_NME_INDICATIONS_ALL ((CsrWifiNmeIndications) 0xFFFFFFFF)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiNmeSecError
+
+ DESCRIPTION
+ NME Security Errors
+ place holder for the security library abort reason
+
+ VALUES
+ CSR_WIFI_NME_SEC_ERROR_SEC_ERROR_UNKNOWN
+ - Unknown Security Error.
+
+*******************************************************************************/
+typedef u8 CsrWifiNmeSecError;
+#define CSR_WIFI_NME_SEC_ERROR_SEC_ERROR_UNKNOWN ((CsrWifiNmeSecError) 0x00)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiNmeSimCardType
+
+ DESCRIPTION
+ (U)SIM Card (or UICC) types
+
+ VALUES
+ CSR_WIFI_NME_SIM_CARD_TYPE_2G - 2G SIM card, capable of performing GSM
+ authentication only.
+ CSR_WIFI_NME_SIM_CARD_TYPE_3G - UICC supporting USIM application, capable
+ of performing UMTS authentication only.
+ CSR_WIFI_NME_SIM_CARD_TYPE_2G3G - UICC supporting both USIM and SIM
+ applications, capable of performing both
+ UMTS and GSM authentications.
+
+*******************************************************************************/
+typedef u8 CsrWifiNmeSimCardType;
+#define CSR_WIFI_NME_SIM_CARD_TYPE_2G ((CsrWifiNmeSimCardType) 0x01)
+#define CSR_WIFI_NME_SIM_CARD_TYPE_3G ((CsrWifiNmeSimCardType) 0x02)
+#define CSR_WIFI_NME_SIM_CARD_TYPE_2G3G ((CsrWifiNmeSimCardType) 0x03)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiNmeUmtsAuthResult
+
+ DESCRIPTION
+ Only relevant for UMTS Authentication. It indicates if the UICC has
+ successfully authenticated the network or otherwise.
+
+ VALUES
+ CSR_WIFI_NME_UMTS_AUTH_RESULT_SUCCESS
+ - Successful outcome from USIM indicating that the card has
+ successfully authenticated the network.
+ CSR_WIFI_NME_UMTS_AUTH_RESULT_SYNC_FAIL
+ - Unsuccessful outcome from USIM indicating that the card is
+ requesting the network to synchronise and re-try again. If
+ no further request is received an NME timer will expire and
+ the authentication is aborted.
+ CSR_WIFI_NME_UMTS_AUTH_RESULT_REJECT
+ - Unsuccessful outcome from USIM indicating that the card has
+ rejected the network and that the authentication is
+ aborted.
+
+*******************************************************************************/
+typedef u8 CsrWifiNmeUmtsAuthResult;
+#define CSR_WIFI_NME_UMTS_AUTH_RESULT_SUCCESS ((CsrWifiNmeUmtsAuthResult) 0x00)
+#define CSR_WIFI_NME_UMTS_AUTH_RESULT_SYNC_FAIL ((CsrWifiNmeUmtsAuthResult) 0x01)
+#define CSR_WIFI_NME_UMTS_AUTH_RESULT_REJECT ((CsrWifiNmeUmtsAuthResult) 0x02)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiNmeWmmQosInfo
+
+ DESCRIPTION
+ Defines bits for the QoS Info octect as defined in the WMM specification.
+ The values of this type are used across the NME/SME/Router API's and they
+ must be kept consistent with the corresponding types in the .xml of the
+ other interfaces
+
+ VALUES
+ CSR_WIFI_NME_WMM_QOS_INFO_AC_MAX_SP_ALL
+ - WMM AP may deliver all buffered frames.
+ CSR_WIFI_NME_WMM_QOS_INFO_AC_VO
+ - To enable the triggering and delivery of QoS Voice.
+ CSR_WIFI_NME_WMM_QOS_INFO_AC_VI
+ - To enable the triggering and delivery of QoS Video.
+ CSR_WIFI_NME_WMM_QOS_INFO_AC_BK
+ - To enable the triggering and delivery of QoS Background.
+ CSR_WIFI_NME_WMM_QOS_INFO_AC_BE
+ - To enable the triggering and delivery of QoS Best Effort.
+ CSR_WIFI_NME_WMM_QOS_INFO_AC_MAX_SP_TWO
+ - WMM AP may deliver a maximum of 2 buffered frames per
+ Unscheduled Service Period (USP).
+ CSR_WIFI_NME_WMM_QOS_INFO_AC_MAX_SP_FOUR
+ - WMM AP may deliver a maximum of 4 buffered frames per USP.
+ CSR_WIFI_NME_WMM_QOS_INFO_AC_MAX_SP_SIX
+ - WMM AP may deliver a maximum of 6 buffered frames per USP.
+
+*******************************************************************************/
+typedef u8 CsrWifiNmeWmmQosInfo;
+#define CSR_WIFI_NME_WMM_QOS_INFO_AC_MAX_SP_ALL ((CsrWifiNmeWmmQosInfo) 0x00)
+#define CSR_WIFI_NME_WMM_QOS_INFO_AC_VO ((CsrWifiNmeWmmQosInfo) 0x01)
+#define CSR_WIFI_NME_WMM_QOS_INFO_AC_VI ((CsrWifiNmeWmmQosInfo) 0x02)
+#define CSR_WIFI_NME_WMM_QOS_INFO_AC_BK ((CsrWifiNmeWmmQosInfo) 0x04)
+#define CSR_WIFI_NME_WMM_QOS_INFO_AC_BE ((CsrWifiNmeWmmQosInfo) 0x08)
+#define CSR_WIFI_NME_WMM_QOS_INFO_AC_MAX_SP_TWO ((CsrWifiNmeWmmQosInfo) 0x20)
+#define CSR_WIFI_NME_WMM_QOS_INFO_AC_MAX_SP_FOUR ((CsrWifiNmeWmmQosInfo) 0x40)
+#define CSR_WIFI_NME_WMM_QOS_INFO_AC_MAX_SP_SIX ((CsrWifiNmeWmmQosInfo) 0x60)
+
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiNmeEapMethodMask
+
+ DESCRIPTION
+ Mask type for use with the values defined by CsrWifiNmeEapMethod.
+
+*******************************************************************************/
+typedef u16 CsrWifiNmeEapMethodMask;
+/*******************************************************************************
+
+ NAME
+ CsrWifiNmeEncryptionMask
+
+ DESCRIPTION
+ Mask type for use with the values defined by CsrWifiNmeEncryption
+
+*******************************************************************************/
+typedef u16 CsrWifiNmeEncryptionMask;
+/*******************************************************************************
+
+ NAME
+ CsrWifiNmeIndicationsMask
+
+ DESCRIPTION
+ Mask type for use with the values defined by CsrWifiNmeIndications
+
+*******************************************************************************/
+typedef u32 CsrWifiNmeIndicationsMask;
+/*******************************************************************************
+
+ NAME
+ CsrWifiNmeNmeIndicationsMask
+
+ DESCRIPTION
+ Mask type for use with the values defined by CsrWifiNmeNmeIndications.
+ Used to overlap the unused portion of the unifi_IndicationsMask For NME
+ specific indications
+
+*******************************************************************************/
+typedef u32 CsrWifiNmeNmeIndicationsMask;
+/*******************************************************************************
+
+ NAME
+ CsrWifiNmeWmmQosInfoMask
+
+ DESCRIPTION
+ Mask type for use with the values defined by CsrWifiNmeWmmQosInfo
+
+*******************************************************************************/
+typedef u8 CsrWifiNmeWmmQosInfoMask;
+
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiNmeEmpty
+
+ DESCRIPTION
+ Empty Structure to indicate that no credentials are available.
+
+ MEMBERS
+ empty - Only element of the empty structure (always set to 0).
+
+*******************************************************************************/
+typedef struct
+{
+ u8 empty;
+} CsrWifiNmeEmpty;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiNmePassphrase
+
+ DESCRIPTION
+ Structure holding the ASCII Pass Phrase data.
+
+ MEMBERS
+ encryptionMode - Encryption type as defined in CsrWifiSmeEncryption.
+ passphrase - Pass phrase ASCII value.
+
+*******************************************************************************/
+typedef struct
+{
+ u16 encryptionMode;
+ char *passphrase;
+} CsrWifiNmePassphrase;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiNmePsk
+
+ DESCRIPTION
+ Structure holding the Pre-Shared Key data.
+
+ MEMBERS
+ encryptionMode - Encryption type as defined in CsrWifiSmeEncryption.
+ psk - Pre-Shared Key value.
+
+*******************************************************************************/
+typedef struct
+{
+ u16 encryptionMode;
+ u8 psk[32];
+} CsrWifiNmePsk;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiNmeWapiCredentials
+
+ DESCRIPTION
+ Structure holding WAPI credentials data.
+
+ MEMBERS
+ certificateLength - Length in bytes of the following client certificate.
+ certificate - The actual client certificate data (if present).
+ DER/PEM format supported.
+ privateKeyLength - Length in bytes of the following private key.
+ privateKey - The actual private key. DER/PEM format.
+ caCertificateLength - Length in bytes of the following certificate authority
+ certificate.
+ caCertificate - The actual certificate authority certificate data. If
+ not supplied the received certificate authority
+ certificate is assumed to be validate, if present the
+ received certificate is validated against it. DER/PEM
+ format supported.
+
+*******************************************************************************/
+typedef struct
+{
+ u32 certificateLength;
+ u8 *certificate;
+ u16 privateKeyLength;
+ u8 *privateKey;
+ u32 caCertificateLength;
+ u8 *caCertificate;
+} CsrWifiNmeWapiCredentials;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiNmeConnectAttempt
+
+ DESCRIPTION
+ Structure holding Connection attempt data.
+
+ MEMBERS
+ bssid - Id of Basic Service Set connections attempt have been made
+ to.
+ status - Status returned to indicate the success or otherwise of the
+ connection attempt.
+ securityError - Security error status indicating the nature of the failure
+ to connect.
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiMacAddress bssid;
+ CsrResult status;
+ CsrWifiNmeSecError securityError;
+} CsrWifiNmeConnectAttempt;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiNmeEapCredentials
+
+ DESCRIPTION
+ Supports the use of multiple EAP methods via a single structure. The
+ methods required are indicated by the value set in the eapMethodMask
+
+ MEMBERS
+ eapMethodMask
+ - Bit mask of supported EAP methods
+ Currently only supports the setting of one bit.
+ Required for all the EAP methods.
+ authMode
+ - Bit mask representing the authentication types that may be
+ supported by a suitable AP. An AP must support at least one
+ of the authentication types specified to be considered for
+ connection. Required for all EAP methods.
+ encryptionMode
+ - Bit mask representing the encryption types that may be
+ supported by a suitable AP. An AP must support a suitable
+ mix of the pairwise and group encryption types requested to
+ be considered for connection. Required for all EAP methods.
+ userName
+ - User name. Required for all EAP methods except: SIM or AKA.
+ userPassword
+ - User Password. Required for all EAP methods except: TLS,
+ SIM or AKA.
+ authServerUserIdentity
+ - Authentication server user Identity. Required for all EAP
+ methods except: TLS, SIM, AKA or FAST.
+ clientCertificateLength
+ - Length in bytes of the following client certificate (if
+ present). Only required for TLS.
+ clientCertificate
+ - The actual client certificate data (if present). Only
+ required for TLS. DER/PEM format supported.
+ certificateAuthorityCertificateLength
+ - Length in bytes of the following certificate authority
+ certificate (if present). Optional for TLS, TTLS, PEAP.
+ certificateAuthorityCertificate
+ - The actual certificate authority certificate data (if
+ present). If not supplied the received certificate
+ authority certificate is assumed to be valid, if present
+ the received certificate is validated against it. Optional
+ for TLS, TTLS, PEAP. DER/PEM format supported.
+ privateKeyLength
+ - Length in bytes of the following private key (if present).
+ Only required for TLS.
+ privateKey
+ - The actual private key (if present). Only required for TLS.
+ DER/PEM format, maybe password protected.
+ privateKeyPassword
+ - Optional password to protect the private key.
+ sessionLength
+ - Length in bytes of the following session field Supported
+ for all EAP methods except: SIM or AKA.
+ session
+ - Session information to support faster re-authentication.
+ Supported for all EAP methods except: SIM or AKA.
+ allowPacProvisioning
+ - If TRUE: PAC provisioning is allowed 'over-the_air';
+ If FALSE: a PAC must be supplied.
+ Only required for FAST.
+ pacLength
+ - Length the following PAC field. If allowPacProvisioning is
+ FALSE then the PAC MUST be supplied (i.e. non-zero). Only
+ required for FAST.
+ pac
+ - The actual PAC data. If allowPacProvisioning is FALSE then
+ the PAC MUST be supplied. Only required for FAST.
+ pacPassword
+ - Optional password to protect the PAC. Only required for
+ FAST.
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiNmeEapMethodMask eapMethodMask;
+ CsrWifiSmeAuthModeMask authMode;
+ CsrWifiNmeEncryptionMask encryptionMode;
+ char *userName;
+ char *userPassword;
+ char *authServerUserIdentity;
+ u32 clientCertificateLength;
+ u8 *clientCertificate;
+ u32 certificateAuthorityCertificateLength;
+ u8 *certificateAuthorityCertificate;
+ u16 privateKeyLength;
+ u8 *privateKey;
+ char *privateKeyPassword;
+ u32 sessionLength;
+ u8 *session;
+ u8 allowPacProvisioning;
+ u32 pacLength;
+ u8 *pac;
+ char *pacPassword;
+} CsrWifiNmeEapCredentials;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiNmePeerConfig
+
+ DESCRIPTION
+ Structure holding Peer Config data.
+
+ MEMBERS
+ p2pDeviceId -
+ groupCapabilityMask -
+ groupOwnerIntent -
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiMacAddress p2pDeviceId;
+ CsrWifiSmeP2pGroupCapabilityMask groupCapabilityMask;
+ u8 groupOwnerIntent;
+} CsrWifiNmePeerConfig;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiNmeProfileIdentity
+
+ DESCRIPTION
+ The identity of a profile is defined as the unique combination the BSSID
+ and SSID.
+
+ MEMBERS
+ bssid - ID of Basic Service Set for or the P2pDevice address of the GO for
+ which a connection attempt was made.
+ ssid - Service Set Id.
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiMacAddress bssid;
+ CsrWifiSsid ssid;
+} CsrWifiNmeProfileIdentity;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiNmeWep128Keys
+
+ DESCRIPTION
+ Structure holding WEP Authentication Type and WEP keys that can be used
+ when using WEP128.
+
+ MEMBERS
+ wepAuthType - Mask to select the WEP authentication type (Open or Shared)
+ selectedWepKey - Index to one of the four keys below indicating the
+ currently used WEP key.
+ key1 - Value for key number 1.
+ key2 - Value for key number 2.
+ key3 - Value for key number 3.
+ key4 - Value for key number 4.
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiSmeAuthModeMask wepAuthType;
+ u8 selectedWepKey;
+ u8 key1[13];
+ u8 key2[13];
+ u8 key3[13];
+ u8 key4[13];
+} CsrWifiNmeWep128Keys;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiNmeWep64Keys
+
+ DESCRIPTION
+ Structure for holding WEP Authentication Type and WEP keys that can be
+ used when using WEP64.
+
+ MEMBERS
+ wepAuthType - Mask to select the WEP authentication type (Open or Shared)
+ selectedWepKey - Index to one of the four keys below indicating the
+ currently used WEP key.
+ key1 - Value for key number 1.
+ key2 - Value for key number 2.
+ key3 - Value for key number 3.
+ key4 - Value for key number 4.
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiSmeAuthModeMask wepAuthType;
+ u8 selectedWepKey;
+ u8 key1[5];
+ u8 key2[5];
+ u8 key3[5];
+ u8 key4[5];
+} CsrWifiNmeWep64Keys;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiNmeCredentials
+
+ DESCRIPTION
+ Structure containing the Credentials data.
+
+ MEMBERS
+ credentialType - Credential type value (as defined in the
+ enumeration type).
+ credential - Union containing credentials which depends on
+ credentialType parameter.
+ credentialeap -
+ credentialwapiPassphrase -
+ credentialwpa2Passphrase -
+ credentialwpa2Psk -
+ credentialwapiPsk -
+ credentialwpaPassphrase -
+ credentialwapi -
+ credentialwep128Key -
+ credentialwpaPsk -
+ credentialopenSystem -
+ credentialwep64Key -
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiNmeCredentialType credentialType;
+ union {
+ CsrWifiNmeEapCredentials eap;
+ CsrWifiNmePassphrase wapiPassphrase;
+ CsrWifiNmePassphrase wpa2Passphrase;
+ CsrWifiNmePsk wpa2Psk;
+ CsrWifiNmePsk wapiPsk;
+ CsrWifiNmePassphrase wpaPassphrase;
+ CsrWifiNmeWapiCredentials wapi;
+ CsrWifiNmeWep128Keys wep128Key;
+ CsrWifiNmePsk wpaPsk;
+ CsrWifiNmeEmpty openSystem;
+ CsrWifiNmeWep64Keys wep64Key;
+ } credential;
+} CsrWifiNmeCredentials;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiNmeProfile
+
+ DESCRIPTION
+ Structure containing the Profile data.
+
+ MEMBERS
+ profileIdentity - Profile Identity.
+ wmmQosInfoMask - Mask for WMM QoS information.
+ bssType - Type of BSS (Infrastructure or Adhoc).
+ channelNo - Channel Number.
+ ccxOptionsMask - Options mask for Cisco Compatible Extentions.
+ cloakedSsid - Flag to decide whether the SSID is cloaked (not
+ transmitted) or not.
+ credentials - Credentials data.
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiNmeProfileIdentity profileIdentity;
+ CsrWifiNmeWmmQosInfoMask wmmQosInfoMask;
+ CsrWifiNmeBssType bssType;
+ u8 channelNo;
+ u8 ccxOptionsMask;
+ u8 cloakedSsid;
+ CsrWifiNmeCredentials credentials;
+} CsrWifiNmeProfile;
+
+
+/* Downstream */
+#define CSR_WIFI_NME_PRIM_DOWNSTREAM_LOWEST (0x0000)
+
+#define CSR_WIFI_NME_PROFILE_SET_REQ ((CsrWifiNmePrim) (0x0000 + CSR_WIFI_NME_PRIM_DOWNSTREAM_LOWEST))
+#define CSR_WIFI_NME_PROFILE_DELETE_REQ ((CsrWifiNmePrim) (0x0001 + CSR_WIFI_NME_PRIM_DOWNSTREAM_LOWEST))
+#define CSR_WIFI_NME_PROFILE_DELETE_ALL_REQ ((CsrWifiNmePrim) (0x0002 + CSR_WIFI_NME_PRIM_DOWNSTREAM_LOWEST))
+#define CSR_WIFI_NME_PROFILE_ORDER_SET_REQ ((CsrWifiNmePrim) (0x0003 + CSR_WIFI_NME_PRIM_DOWNSTREAM_LOWEST))
+#define CSR_WIFI_NME_PROFILE_CONNECT_REQ ((CsrWifiNmePrim) (0x0004 + CSR_WIFI_NME_PRIM_DOWNSTREAM_LOWEST))
+#define CSR_WIFI_NME_WPS_REQ ((CsrWifiNmePrim) (0x0005 + CSR_WIFI_NME_PRIM_DOWNSTREAM_LOWEST))
+#define CSR_WIFI_NME_WPS_CANCEL_REQ ((CsrWifiNmePrim) (0x0006 + CSR_WIFI_NME_PRIM_DOWNSTREAM_LOWEST))
+#define CSR_WIFI_NME_CONNECTION_STATUS_GET_REQ ((CsrWifiNmePrim) (0x0007 + CSR_WIFI_NME_PRIM_DOWNSTREAM_LOWEST))
+#define CSR_WIFI_NME_SIM_IMSI_GET_RES ((CsrWifiNmePrim) (0x0008 + CSR_WIFI_NME_PRIM_DOWNSTREAM_LOWEST))
+#define CSR_WIFI_NME_SIM_GSM_AUTH_RES ((CsrWifiNmePrim) (0x0009 + CSR_WIFI_NME_PRIM_DOWNSTREAM_LOWEST))
+#define CSR_WIFI_NME_SIM_UMTS_AUTH_RES ((CsrWifiNmePrim) (0x000A + CSR_WIFI_NME_PRIM_DOWNSTREAM_LOWEST))
+#define CSR_WIFI_NME_WPS_CONFIG_SET_REQ ((CsrWifiNmePrim) (0x000B + CSR_WIFI_NME_PRIM_DOWNSTREAM_LOWEST))
+#define CSR_WIFI_NME_EVENT_MASK_SET_REQ ((CsrWifiNmePrim) (0x000C + CSR_WIFI_NME_PRIM_DOWNSTREAM_LOWEST))
+
+
+#define CSR_WIFI_NME_PRIM_DOWNSTREAM_HIGHEST (0x000C + CSR_WIFI_NME_PRIM_DOWNSTREAM_LOWEST)
+
+/* Upstream */
+#define CSR_WIFI_NME_PRIM_UPSTREAM_LOWEST (0x0000 + CSR_PRIM_UPSTREAM)
+
+#define CSR_WIFI_NME_PROFILE_SET_CFM ((CsrWifiNmePrim)(0x0000 + CSR_WIFI_NME_PRIM_UPSTREAM_LOWEST))
+#define CSR_WIFI_NME_PROFILE_DELETE_CFM ((CsrWifiNmePrim)(0x0001 + CSR_WIFI_NME_PRIM_UPSTREAM_LOWEST))
+#define CSR_WIFI_NME_PROFILE_DELETE_ALL_CFM ((CsrWifiNmePrim)(0x0002 + CSR_WIFI_NME_PRIM_UPSTREAM_LOWEST))
+#define CSR_WIFI_NME_PROFILE_ORDER_SET_CFM ((CsrWifiNmePrim)(0x0003 + CSR_WIFI_NME_PRIM_UPSTREAM_LOWEST))
+#define CSR_WIFI_NME_PROFILE_CONNECT_CFM ((CsrWifiNmePrim)(0x0004 + CSR_WIFI_NME_PRIM_UPSTREAM_LOWEST))
+#define CSR_WIFI_NME_WPS_CFM ((CsrWifiNmePrim)(0x0005 + CSR_WIFI_NME_PRIM_UPSTREAM_LOWEST))
+#define CSR_WIFI_NME_WPS_CANCEL_CFM ((CsrWifiNmePrim)(0x0006 + CSR_WIFI_NME_PRIM_UPSTREAM_LOWEST))
+#define CSR_WIFI_NME_CONNECTION_STATUS_GET_CFM ((CsrWifiNmePrim)(0x0007 + CSR_WIFI_NME_PRIM_UPSTREAM_LOWEST))
+#define CSR_WIFI_NME_PROFILE_UPDATE_IND ((CsrWifiNmePrim)(0x0008 + CSR_WIFI_NME_PRIM_UPSTREAM_LOWEST))
+#define CSR_WIFI_NME_PROFILE_DISCONNECT_IND ((CsrWifiNmePrim)(0x0009 + CSR_WIFI_NME_PRIM_UPSTREAM_LOWEST))
+#define CSR_WIFI_NME_SIM_IMSI_GET_IND ((CsrWifiNmePrim)(0x000A + CSR_WIFI_NME_PRIM_UPSTREAM_LOWEST))
+#define CSR_WIFI_NME_SIM_GSM_AUTH_IND ((CsrWifiNmePrim)(0x000B + CSR_WIFI_NME_PRIM_UPSTREAM_LOWEST))
+#define CSR_WIFI_NME_SIM_UMTS_AUTH_IND ((CsrWifiNmePrim)(0x000C + CSR_WIFI_NME_PRIM_UPSTREAM_LOWEST))
+#define CSR_WIFI_NME_WPS_CONFIG_SET_CFM ((CsrWifiNmePrim)(0x000D + CSR_WIFI_NME_PRIM_UPSTREAM_LOWEST))
+#define CSR_WIFI_NME_EVENT_MASK_SET_CFM ((CsrWifiNmePrim)(0x000E + CSR_WIFI_NME_PRIM_UPSTREAM_LOWEST))
+
+#define CSR_WIFI_NME_PRIM_UPSTREAM_HIGHEST (0x000E + CSR_WIFI_NME_PRIM_UPSTREAM_LOWEST)
+
+#define CSR_WIFI_NME_PRIM_DOWNSTREAM_COUNT (CSR_WIFI_NME_PRIM_DOWNSTREAM_HIGHEST + 1 - CSR_WIFI_NME_PRIM_DOWNSTREAM_LOWEST)
+#define CSR_WIFI_NME_PRIM_UPSTREAM_COUNT (CSR_WIFI_NME_PRIM_UPSTREAM_HIGHEST + 1 - CSR_WIFI_NME_PRIM_UPSTREAM_LOWEST)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiNmeProfileSetReq
+
+ DESCRIPTION
+ Creates or updates an existing profile in the NME that matches the unique
+ identity of the profile. Each profile is identified by the combination of
+ BSSID and SSID. The profile contains all the required credentials for
+ attempting to connect to the network. Creating or updating a profile via
+ the NME PROFILE SET REQ does NOT add the profile to the preferred profile
+ list within the NME used for the NME auto-connect behaviour.
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ profile - Specifies the identity and credentials of the network.
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ CsrWifiNmeProfile profile;
+} CsrWifiNmeProfileSetReq;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiNmeProfileDeleteReq
+
+ DESCRIPTION
+ Will delete the profile with a matching identity, but does NOT modify the
+ preferred profile list.
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ profileIdentity - Identity (BSSID, SSID) of profile to be deleted.
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ CsrWifiNmeProfileIdentity profileIdentity;
+} CsrWifiNmeProfileDeleteReq;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiNmeProfileDeleteAllReq
+
+ DESCRIPTION
+ Deletes all profiles present in the NME, but does NOT modify the
+ preferred profile list.
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+} CsrWifiNmeProfileDeleteAllReq;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiNmeProfileOrderSetReq
+
+ DESCRIPTION
+ Defines the preferred order that profiles present in the NME should be
+ used during the NME auto-connect behaviour.
+ If profileIdentitysCount == 0, it removes any existing preferred profile
+ list already present in the NME, effectively disabling the auto-connect
+ behaviour.
+ NOTE: Profile identities that do not match any profile stored in the NME
+ are ignored during the auto-connect procedure.
+ NOTE: during auto-connect the NME will only attempt to join an existing
+ adhoc network and it will never attempt to host an adhoc network; for
+ hosting and adhoc network, use CSR_WIFI_NME_PROFILE_CONNECT_REQ
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ interfaceTag - Interface Identifier; unique identifier of an
+ interface
+ profileIdentitysCount - The number of profiles identities in the list.
+ profileIdentitys - Points to the list of profile identities.
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ u16 interfaceTag;
+ u8 profileIdentitysCount;
+ CsrWifiNmeProfileIdentity *profileIdentitys;
+} CsrWifiNmeProfileOrderSetReq;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiNmeProfileConnectReq
+
+ DESCRIPTION
+ Requests the NME to attempt to connect to the specified profile.
+ Overrides any current connection attempt.
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ interfaceTag - Interface Identifier; unique identifier of an interface
+ profileIdentity - Identity (BSSID, SSID) of profile to be connected to.
+ It must match an existing profile in the NME.
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ u16 interfaceTag;
+ CsrWifiNmeProfileIdentity profileIdentity;
+} CsrWifiNmeProfileConnectReq;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiNmeWpsReq
+
+ DESCRIPTION
+ Requests the NME to look for WPS enabled APs and attempt to perform WPS
+ to determine the appropriate security credentials to connect to the AP.
+ If the PIN == '00000000' then 'push button mode' is indicated, otherwise
+ the PIN has to match that of the AP. 4 digit pin is passed by sending the
+ pin digits in pin[0]..pin[3] and rest of the contents filled with '-'.
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ interfaceTag - Interface Identifier; unique identifier of an interface
+ pin - PIN value.
+ ssid - Service Set identifier
+ bssid - ID of Basic Service Set for which a WPS connection attempt is
+ being made.
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ u16 interfaceTag;
+ u8 pin[8];
+ CsrWifiSsid ssid;
+ CsrWifiMacAddress bssid;
+} CsrWifiNmeWpsReq;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiNmeWpsCancelReq
+
+ DESCRIPTION
+ Requests the NME to cancel any WPS procedure that it is currently
+ performing. This includes WPS registrar activities started because of
+ CSR_WIFI_NME_AP_REGISTER.request
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ interfaceTag - Interface Identifier; unique identifier of an interface
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ u16 interfaceTag;
+} CsrWifiNmeWpsCancelReq;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiNmeConnectionStatusGetReq
+
+ DESCRIPTION
+ Requests the current connection status of the NME.
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ interfaceTag - Interface Identifier; unique identifier of an interface
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ u16 interfaceTag;
+} CsrWifiNmeConnectionStatusGetReq;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiNmeSimImsiGetRes
+
+ DESCRIPTION
+ Response from the application that received the NME SIM IMSI GET IND.
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ status - Indicates the outcome of the requested operation: STATUS_SUCCESS
+ or STATUS_ERROR.
+ imsi - The value of the IMSI obtained from the UICC.
+ cardType - The UICC type (GSM only (SIM), UMTS only (USIM), Both).
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ CsrResult status;
+ char *imsi;
+ CsrWifiNmeSimCardType cardType;
+} CsrWifiNmeSimImsiGetRes;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiNmeSimGsmAuthRes
+
+ DESCRIPTION
+ Response from the application that received the NME SIM GSM AUTH IND. For
+ each GSM authentication round a GSM Ciphering key (Kc) and a signed
+ response (SRES) are produced. Since 2 or 3 GSM authentication rounds are
+ used the 2 or 3 Kc's obtained respectively are combined into one buffer
+ and similarly the 2 or 3 SRES's obtained are combined into another
+ buffer. The order of Kc values (SRES values respectively) in their buffer
+ is the same as that of their corresponding RAND values in the incoming
+ indication.
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ status - Indicates the outcome of the requested operation:
+ STATUS_SUCCESS or STATUS_ERROR
+ kcsLength - Length in Bytes of Kc buffer. Legal values are: 16 or 24.
+ kcs - Kc buffer holding 2 or 3 Kc values.
+ sresLength - Length in Bytes of SRES buffer. Legal values are: 8 or 12.
+ sres - SRES buffer holding 2 or 3 SRES values.
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ CsrResult status;
+ u8 kcsLength;
+ u8 *kcs;
+ u8 sresLength;
+ u8 *sres;
+} CsrWifiNmeSimGsmAuthRes;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiNmeSimUmtsAuthRes
+
+ DESCRIPTION
+ Response from the application that received the NME SIM UMTS AUTH IND.
+ The values of umtsCipherKey, umtsIntegrityKey, resParameterLength and
+ resParameter are only meanigful when result = UMTS_AUTH_RESULT_SUCCESS.
+ The value of auts is only meaningful when
+ result=UMTS_AUTH_RESULT_SYNC_FAIL.
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ status - Indicates the outcome of the requested operation:
+ STATUS_SUCCESS or STATUS_ERROR.
+ result - The result of UMTS authentication as performed by the
+ UICC which could be: Success, Authentication Reject or
+ Synchronisation Failure. For all these 3 outcomes the
+ value of status is success.
+ umtsCipherKey - The UMTS Cipher Key as calculated and returned by the
+ UICC.
+ umtsIntegrityKey - The UMTS Integrity Key as calculated and returned by
+ the UICC.
+ resParameterLength - The length (in bytes) of the RES parameter (min=4; max
+ = 16).
+ resParameter - The RES parameter as calculated and returned by the
+ UICC.
+ auts - The AUTS parameter as calculated and returned by the
+ UICC.
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ CsrResult status;
+ CsrWifiNmeUmtsAuthResult result;
+ u8 umtsCipherKey[16];
+ u8 umtsIntegrityKey[16];
+ u8 resParameterLength;
+ u8 *resParameter;
+ u8 auts[14];
+} CsrWifiNmeSimUmtsAuthRes;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiNmeWpsConfigSetReq
+
+ DESCRIPTION
+ This primitive passes the WPS information for the device to NME. This may
+ be accepted only if no interface is active.
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ wpsConfig - WPS config.
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ CsrWifiSmeWpsConfig wpsConfig;
+} CsrWifiNmeWpsConfigSetReq;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiNmeEventMaskSetReq
+
+ DESCRIPTION
+ The wireless manager application may register with the NME to receive
+ notification of interesting events. Indications will be sent only if the
+ wireless manager explicitly registers to be notified of that event.
+ indMask is a bit mask of values defined in CsrWifiNmeIndicationsMask.
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ indMask - Set mask with values from CsrWifiNmeIndications
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ CsrWifiNmeIndicationsMask indMask;
+} CsrWifiNmeEventMaskSetReq;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiNmeProfileSetCfm
+
+ DESCRIPTION
+ Reports the status of the NME PROFILE SET REQ; the request will only fail
+ if the details specified in the profile contains an invalid combination
+ of parameters for example specifying the profile as cloaked but not
+ specifying the SSID. The NME doesn't limit the number of profiles that
+ may be created. The NME assumes that the entity configuring it is aware
+ of the appropriate limits.
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ status - Indicates the success or otherwise of the requested operation.
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ CsrResult status;
+} CsrWifiNmeProfileSetCfm;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiNmeProfileDeleteCfm
+
+ DESCRIPTION
+ Reports the status of the CSR_WIFI_NME_PROFILE_DELETE_REQ.
+ Returns CSR_WIFI_NME_STATUS_NOT_FOUND if there is no matching profile.
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ status - Indicates the success or otherwise of the requested operation.
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ CsrResult status;
+} CsrWifiNmeProfileDeleteCfm;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiNmeProfileDeleteAllCfm
+
+ DESCRIPTION
+ Reports the status of the CSR_WIFI_NME_PROFILE_DELETE_ALL_REQ.
+ Returns always CSR_WIFI_NME_STATUS_SUCCESS.
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ status - Indicates the success or otherwise of the requested operation, but
+ in this case it always set to success.
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ CsrResult status;
+} CsrWifiNmeProfileDeleteAllCfm;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiNmeProfileOrderSetCfm
+
+ DESCRIPTION
+ Confirmation to UNIFI_NME_PROFILE_ORDER_SET.request.
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ interfaceTag - Interface Identifier; unique identifier of an interface
+ status - Indicates the success or otherwise of the requested
+ operation.
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ u16 interfaceTag;
+ CsrResult status;
+} CsrWifiNmeProfileOrderSetCfm;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiNmeProfileConnectCfm
+
+ DESCRIPTION
+ Reports the status of the NME PROFILE CONNECT REQ. If unsuccessful the
+ connectAttempt parameters contain details of the APs that the NME
+ attempted to connect to before reporting the failure of the request.
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ interfaceTag - Interface Identifier; unique identifier of an
+ interface
+ status - Indicates the success or otherwise of the requested
+ operation.
+ connectAttemptsCount - This parameter is relevant only if
+ status!=CSR_WIFI_NME_STATUS_SUCCESS.
+ Number of connection attempt elements provided with
+ this primitive
+ connectAttempts - This parameter is relevant only if
+ status!=CSR_WIFI_NME_STATUS_SUCCESS.
+ Points to the list of connection attempt elements
+ provided with this primitive
+ Each element of the list provides information about
+ an AP on which the connection attempt was made and
+ the error that occurred during the attempt.
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ u16 interfaceTag;
+ CsrResult status;
+ u8 connectAttemptsCount;
+ CsrWifiNmeConnectAttempt *connectAttempts;
+} CsrWifiNmeProfileConnectCfm;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiNmeWpsCfm
+
+ DESCRIPTION
+ Reports the status of the NME WPS REQ.
+ If CSR_WIFI_NME_STATUS_SUCCESS, the profile parameter contains the
+ identity and credentials of the AP.
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ interfaceTag - Interface Identifier; unique identifier of an interface
+ status - Indicates the success or otherwise of the requested
+ operation.
+ profile - This parameter is relevant only if
+ status==CSR_WIFI_NME_STATUS_SUCCESS.
+ The identity and credentials of the network.
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ u16 interfaceTag;
+ CsrResult status;
+ CsrWifiNmeProfile profile;
+} CsrWifiNmeWpsCfm;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiNmeWpsCancelCfm
+
+ DESCRIPTION
+ Reports the status of the NME WPS REQ, the request is always SUCCESSFUL.
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ interfaceTag - Interface Identifier; unique identifier of an interface
+ status - Only returns CSR_WIFI_NME_STATUS_SUCCESS
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ u16 interfaceTag;
+ CsrResult status;
+} CsrWifiNmeWpsCancelCfm;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiNmeConnectionStatusGetCfm
+
+ DESCRIPTION
+ Reports the connection status of the NME.
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ interfaceTag - Interface Identifier; unique identifier of an interface
+ status - Indicates the success or otherwise of the requested
+ operation.
+ connectionStatus - NME current connection status
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ u16 interfaceTag;
+ CsrResult status;
+ CsrWifiNmeConnectionStatus connectionStatus;
+} CsrWifiNmeConnectionStatusGetCfm;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiNmeProfileUpdateInd
+
+ DESCRIPTION
+ Indication generated from the NME (if an application subscribes to
+ receive it) that informs that application that the contained profile has
+ changed.
+ For example, either the credentials EAP-FAST PAC file or the session data
+ within the profile has changed.
+ It is up to the application whether it stores this updated profile or
+ not.
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ interfaceTag - Interface Identifier; unique identifier of an interface
+ profile - The identity and credentials of the network.
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ u16 interfaceTag;
+ CsrWifiNmeProfile profile;
+} CsrWifiNmeProfileUpdateInd;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiNmeProfileDisconnectInd
+
+ DESCRIPTION
+ Indication generated from the NME (if an application subscribes to
+ receive it) that informs that application that the current profile
+ connection has disconnected. The indication will contain information
+ about APs that it attempted to maintain the connection via i.e. in the
+ case of failed roaming.
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ interfaceTag - Interface Identifier; unique identifier of an
+ interface
+ connectAttemptsCount - Number of connection attempt elements provided with
+ this primitive
+ connectAttempts - Points to the list of connection attempt elements
+ provided with this primitive
+ Each element of the list provides information about
+ an AP on which the connection attempt was made and
+ the error occurred during the attempt.
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ u16 interfaceTag;
+ u8 connectAttemptsCount;
+ CsrWifiNmeConnectAttempt *connectAttempts;
+} CsrWifiNmeProfileDisconnectInd;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiNmeSimImsiGetInd
+
+ DESCRIPTION
+ Indication generated from the NME (if an application subscribes to
+ receive it) that requests the IMSI and UICC type from the UICC Manager.
+ This indication is generated when the NME is attempting to connect to a
+ profile configured for EAP-SIM/AKA. An application MUST register to
+ receive this indication for the NME to support the EAP-SIM/AKA credential
+ types. Otherwise the NME has no route to obtain the information from the
+ UICC.
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+} CsrWifiNmeSimImsiGetInd;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiNmeSimGsmAuthInd
+
+ DESCRIPTION
+ Indication generated from the NME (if an application subscribes to
+ receive it) that requests the UICC Manager to perform a GSM
+ authentication on behalf of the NME. This indication is generated when
+ the NME is attempting to connect to a profile configured for EAP-SIM. An
+ application MUST register to receive this indication for the NME to
+ support the EAP-SIM credential types. Otherwise the NME has no route to
+ obtain the information from the UICC. EAP-SIM authentication requires 2
+ or 3 GSM authentication rounds and therefore 2 or 3 RANDS (GSM Random
+ Challenges) are included.
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ randsLength - GSM RAND is 16 bytes long hence valid values are 32 (2 RANDS)
+ or 48 (3 RANDs).
+ rands - 2 or 3 RANDs values.
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ u8 randsLength;
+ u8 *rands;
+} CsrWifiNmeSimGsmAuthInd;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiNmeSimUmtsAuthInd
+
+ DESCRIPTION
+ Indication generated from the NME (if an application subscribes to
+ receive it) that requests the UICC Manager to perform a UMTS
+ authentication on behalf of the NME. This indication is generated when
+ the NME is attempting to connect to a profile configured for EAP-AKA. An
+ application MUST register to receive this indication for the NME to
+ support the EAP-AKA credential types. Otherwise the NME has no route to
+ obtain the information from the USIM. EAP-AKA requires one UMTS
+ authentication round and therefore only one RAND and one AUTN values are
+ included.
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ rand - UMTS RAND value.
+ autn - UMTS AUTN value.
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ u8 rand[16];
+ u8 autn[16];
+} CsrWifiNmeSimUmtsAuthInd;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiNmeWpsConfigSetCfm
+
+ DESCRIPTION
+ Confirm.
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ status - Status of the request.
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ CsrResult status;
+} CsrWifiNmeWpsConfigSetCfm;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiNmeEventMaskSetCfm
+
+ DESCRIPTION
+ The NME calls the primitive to report the result of the request
+ primitive.
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ status - Reports the result of the request
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ CsrResult status;
+} CsrWifiNmeEventMaskSetCfm;
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* CSR_WIFI_NME_PRIM_H__ */
+
diff --git a/drivers/staging/csr/csr_wifi_nme_serialize.h b/drivers/staging/csr/csr_wifi_nme_serialize.h
new file mode 100644
index 000000000000..c6b163660a3e
--- /dev/null
+++ b/drivers/staging/csr/csr_wifi_nme_serialize.h
@@ -0,0 +1,174 @@
+/*****************************************************************************
+
+ (c) Cambridge Silicon Radio Limited 2011
+ All rights reserved and confidential information of CSR
+
+ Refer to LICENSE.txt included with this source for details
+ on the license terms.
+
+*****************************************************************************/
+
+/* Note: this is an auto-generated file. */
+
+#ifndef CSR_WIFI_NME_SERIALIZE_H__
+#define CSR_WIFI_NME_SERIALIZE_H__
+
+#include "csr_wifi_msgconv.h"
+#include "csr_wifi_nme_prim.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef CSR_WIFI_NME_ENABLE
+#error CSR_WIFI_NME_ENABLE MUST be defined inorder to use csr_wifi_nme_serialize.h
+#endif
+
+extern void CsrWifiNmePfree(void *ptr);
+
+extern u8* CsrWifiNmeProfileSetReqSer(u8 *ptr, size_t *len, void *msg);
+extern void* CsrWifiNmeProfileSetReqDes(u8 *buffer, size_t len);
+extern size_t CsrWifiNmeProfileSetReqSizeof(void *msg);
+extern void CsrWifiNmeProfileSetReqSerFree(void *msg);
+
+extern u8* CsrWifiNmeProfileDeleteReqSer(u8 *ptr, size_t *len, void *msg);
+extern void* CsrWifiNmeProfileDeleteReqDes(u8 *buffer, size_t len);
+extern size_t CsrWifiNmeProfileDeleteReqSizeof(void *msg);
+#define CsrWifiNmeProfileDeleteReqSerFree CsrWifiNmePfree
+
+#define CsrWifiNmeProfileDeleteAllReqSer CsrWifiEventSer
+#define CsrWifiNmeProfileDeleteAllReqDes CsrWifiEventDes
+#define CsrWifiNmeProfileDeleteAllReqSizeof CsrWifiEventSizeof
+#define CsrWifiNmeProfileDeleteAllReqSerFree CsrWifiNmePfree
+
+extern u8* CsrWifiNmeProfileOrderSetReqSer(u8 *ptr, size_t *len, void *msg);
+extern void* CsrWifiNmeProfileOrderSetReqDes(u8 *buffer, size_t len);
+extern size_t CsrWifiNmeProfileOrderSetReqSizeof(void *msg);
+extern void CsrWifiNmeProfileOrderSetReqSerFree(void *msg);
+
+extern u8* CsrWifiNmeProfileConnectReqSer(u8 *ptr, size_t *len, void *msg);
+extern void* CsrWifiNmeProfileConnectReqDes(u8 *buffer, size_t len);
+extern size_t CsrWifiNmeProfileConnectReqSizeof(void *msg);
+#define CsrWifiNmeProfileConnectReqSerFree CsrWifiNmePfree
+
+extern u8* CsrWifiNmeWpsReqSer(u8 *ptr, size_t *len, void *msg);
+extern void* CsrWifiNmeWpsReqDes(u8 *buffer, size_t len);
+extern size_t CsrWifiNmeWpsReqSizeof(void *msg);
+#define CsrWifiNmeWpsReqSerFree CsrWifiNmePfree
+
+#define CsrWifiNmeWpsCancelReqSer CsrWifiEventCsrUint16Ser
+#define CsrWifiNmeWpsCancelReqDes CsrWifiEventCsrUint16Des
+#define CsrWifiNmeWpsCancelReqSizeof CsrWifiEventCsrUint16Sizeof
+#define CsrWifiNmeWpsCancelReqSerFree CsrWifiNmePfree
+
+#define CsrWifiNmeConnectionStatusGetReqSer CsrWifiEventCsrUint16Ser
+#define CsrWifiNmeConnectionStatusGetReqDes CsrWifiEventCsrUint16Des
+#define CsrWifiNmeConnectionStatusGetReqSizeof CsrWifiEventCsrUint16Sizeof
+#define CsrWifiNmeConnectionStatusGetReqSerFree CsrWifiNmePfree
+
+extern u8* CsrWifiNmeSimImsiGetResSer(u8 *ptr, size_t *len, void *msg);
+extern void* CsrWifiNmeSimImsiGetResDes(u8 *buffer, size_t len);
+extern size_t CsrWifiNmeSimImsiGetResSizeof(void *msg);
+extern void CsrWifiNmeSimImsiGetResSerFree(void *msg);
+
+extern u8* CsrWifiNmeSimGsmAuthResSer(u8 *ptr, size_t *len, void *msg);
+extern void* CsrWifiNmeSimGsmAuthResDes(u8 *buffer, size_t len);
+extern size_t CsrWifiNmeSimGsmAuthResSizeof(void *msg);
+extern void CsrWifiNmeSimGsmAuthResSerFree(void *msg);
+
+extern u8* CsrWifiNmeSimUmtsAuthResSer(u8 *ptr, size_t *len, void *msg);
+extern void* CsrWifiNmeSimUmtsAuthResDes(u8 *buffer, size_t len);
+extern size_t CsrWifiNmeSimUmtsAuthResSizeof(void *msg);
+extern void CsrWifiNmeSimUmtsAuthResSerFree(void *msg);
+
+extern u8* CsrWifiNmeWpsConfigSetReqSer(u8 *ptr, size_t *len, void *msg);
+extern void* CsrWifiNmeWpsConfigSetReqDes(u8 *buffer, size_t len);
+extern size_t CsrWifiNmeWpsConfigSetReqSizeof(void *msg);
+extern void CsrWifiNmeWpsConfigSetReqSerFree(void *msg);
+
+#define CsrWifiNmeEventMaskSetReqSer CsrWifiEventCsrUint32Ser
+#define CsrWifiNmeEventMaskSetReqDes CsrWifiEventCsrUint32Des
+#define CsrWifiNmeEventMaskSetReqSizeof CsrWifiEventCsrUint32Sizeof
+#define CsrWifiNmeEventMaskSetReqSerFree CsrWifiNmePfree
+
+#define CsrWifiNmeProfileSetCfmSer CsrWifiEventCsrUint16Ser
+#define CsrWifiNmeProfileSetCfmDes CsrWifiEventCsrUint16Des
+#define CsrWifiNmeProfileSetCfmSizeof CsrWifiEventCsrUint16Sizeof
+#define CsrWifiNmeProfileSetCfmSerFree CsrWifiNmePfree
+
+#define CsrWifiNmeProfileDeleteCfmSer CsrWifiEventCsrUint16Ser
+#define CsrWifiNmeProfileDeleteCfmDes CsrWifiEventCsrUint16Des
+#define CsrWifiNmeProfileDeleteCfmSizeof CsrWifiEventCsrUint16Sizeof
+#define CsrWifiNmeProfileDeleteCfmSerFree CsrWifiNmePfree
+
+#define CsrWifiNmeProfileDeleteAllCfmSer CsrWifiEventCsrUint16Ser
+#define CsrWifiNmeProfileDeleteAllCfmDes CsrWifiEventCsrUint16Des
+#define CsrWifiNmeProfileDeleteAllCfmSizeof CsrWifiEventCsrUint16Sizeof
+#define CsrWifiNmeProfileDeleteAllCfmSerFree CsrWifiNmePfree
+
+extern u8* CsrWifiNmeProfileOrderSetCfmSer(u8 *ptr, size_t *len, void *msg);
+extern void* CsrWifiNmeProfileOrderSetCfmDes(u8 *buffer, size_t len);
+extern size_t CsrWifiNmeProfileOrderSetCfmSizeof(void *msg);
+#define CsrWifiNmeProfileOrderSetCfmSerFree CsrWifiNmePfree
+
+extern u8* CsrWifiNmeProfileConnectCfmSer(u8 *ptr, size_t *len, void *msg);
+extern void* CsrWifiNmeProfileConnectCfmDes(u8 *buffer, size_t len);
+extern size_t CsrWifiNmeProfileConnectCfmSizeof(void *msg);
+extern void CsrWifiNmeProfileConnectCfmSerFree(void *msg);
+
+extern u8* CsrWifiNmeWpsCfmSer(u8 *ptr, size_t *len, void *msg);
+extern void* CsrWifiNmeWpsCfmDes(u8 *buffer, size_t len);
+extern size_t CsrWifiNmeWpsCfmSizeof(void *msg);
+extern void CsrWifiNmeWpsCfmSerFree(void *msg);
+
+extern u8* CsrWifiNmeWpsCancelCfmSer(u8 *ptr, size_t *len, void *msg);
+extern void* CsrWifiNmeWpsCancelCfmDes(u8 *buffer, size_t len);
+extern size_t CsrWifiNmeWpsCancelCfmSizeof(void *msg);
+#define CsrWifiNmeWpsCancelCfmSerFree CsrWifiNmePfree
+
+extern u8* CsrWifiNmeConnectionStatusGetCfmSer(u8 *ptr, size_t *len, void *msg);
+extern void* CsrWifiNmeConnectionStatusGetCfmDes(u8 *buffer, size_t len);
+extern size_t CsrWifiNmeConnectionStatusGetCfmSizeof(void *msg);
+#define CsrWifiNmeConnectionStatusGetCfmSerFree CsrWifiNmePfree
+
+extern u8* CsrWifiNmeProfileUpdateIndSer(u8 *ptr, size_t *len, void *msg);
+extern void* CsrWifiNmeProfileUpdateIndDes(u8 *buffer, size_t len);
+extern size_t CsrWifiNmeProfileUpdateIndSizeof(void *msg);
+extern void CsrWifiNmeProfileUpdateIndSerFree(void *msg);
+
+extern u8* CsrWifiNmeProfileDisconnectIndSer(u8 *ptr, size_t *len, void *msg);
+extern void* CsrWifiNmeProfileDisconnectIndDes(u8 *buffer, size_t len);
+extern size_t CsrWifiNmeProfileDisconnectIndSizeof(void *msg);
+extern void CsrWifiNmeProfileDisconnectIndSerFree(void *msg);
+
+#define CsrWifiNmeSimImsiGetIndSer CsrWifiEventSer
+#define CsrWifiNmeSimImsiGetIndDes CsrWifiEventDes
+#define CsrWifiNmeSimImsiGetIndSizeof CsrWifiEventSizeof
+#define CsrWifiNmeSimImsiGetIndSerFree CsrWifiNmePfree
+
+extern u8* CsrWifiNmeSimGsmAuthIndSer(u8 *ptr, size_t *len, void *msg);
+extern void* CsrWifiNmeSimGsmAuthIndDes(u8 *buffer, size_t len);
+extern size_t CsrWifiNmeSimGsmAuthIndSizeof(void *msg);
+extern void CsrWifiNmeSimGsmAuthIndSerFree(void *msg);
+
+extern u8* CsrWifiNmeSimUmtsAuthIndSer(u8 *ptr, size_t *len, void *msg);
+extern void* CsrWifiNmeSimUmtsAuthIndDes(u8 *buffer, size_t len);
+extern size_t CsrWifiNmeSimUmtsAuthIndSizeof(void *msg);
+#define CsrWifiNmeSimUmtsAuthIndSerFree CsrWifiNmePfree
+
+#define CsrWifiNmeWpsConfigSetCfmSer CsrWifiEventCsrUint16Ser
+#define CsrWifiNmeWpsConfigSetCfmDes CsrWifiEventCsrUint16Des
+#define CsrWifiNmeWpsConfigSetCfmSizeof CsrWifiEventCsrUint16Sizeof
+#define CsrWifiNmeWpsConfigSetCfmSerFree CsrWifiNmePfree
+
+#define CsrWifiNmeEventMaskSetCfmSer CsrWifiEventCsrUint16Ser
+#define CsrWifiNmeEventMaskSetCfmDes CsrWifiEventCsrUint16Des
+#define CsrWifiNmeEventMaskSetCfmSizeof CsrWifiEventCsrUint16Sizeof
+#define CsrWifiNmeEventMaskSetCfmSerFree CsrWifiNmePfree
+
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* CSR_WIFI_NME_SERIALIZE_H__ */
+
diff --git a/drivers/staging/csr/csr_wifi_nme_task.h b/drivers/staging/csr/csr_wifi_nme_task.h
new file mode 100644
index 000000000000..76f44dbe26a9
--- /dev/null
+++ b/drivers/staging/csr/csr_wifi_nme_task.h
@@ -0,0 +1,38 @@
+/*****************************************************************************
+
+ (c) Cambridge Silicon Radio Limited 2011
+ All rights reserved and confidential information of CSR
+
+ Refer to LICENSE.txt included with this source for details
+ on the license terms.
+
+*****************************************************************************/
+
+/* Note: this is an auto-generated file. */
+
+#ifndef CSR_WIFI_NME_TASK_H__
+#define CSR_WIFI_NME_TASK_H__
+
+#include <linux/types.h>
+#include "csr_sched.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef CSR_WIFI_NME_ENABLE
+#error CSR_WIFI_NME_ENABLE MUST be defined inorder to use csr_wifi_nme_task.h
+#endif
+
+#define CSR_WIFI_NME_LOG_ID 0x1203FFFF
+extern CsrSchedQid CSR_WIFI_NME_IFACEQUEUE;
+void CsrWifiNmeInit(void **gash);
+void CsrWifiNmeDeinit(void **gash);
+void CsrWifiNmeHandler(void **gash);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* CSR_WIFI_NME_TASK_H__ */
+
diff --git a/drivers/staging/csr/csr_wifi_private_common.h b/drivers/staging/csr/csr_wifi_private_common.h
new file mode 100644
index 000000000000..47309984e2a7
--- /dev/null
+++ b/drivers/staging/csr/csr_wifi_private_common.h
@@ -0,0 +1,89 @@
+/*****************************************************************************
+
+ (c) Cambridge Silicon Radio Limited 2011
+ All rights reserved and confidential information of CSR
+
+ Refer to LICENSE.txt included with this source for details
+ on the license terms.
+
+*****************************************************************************/
+
+#ifndef CSR_WIFI_PRIVATE_COMMON_H__
+#define CSR_WIFI_PRIVATE_COMMON_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @brief maximum number of STAs allowed to be connected
+ *
+ * @par Description
+ * min & max Beacon Interval
+ */
+#define CSR_WIFI_AP_MAX_ASSOC_STA 8
+
+/** Number of only b rates */
+#define CSR_WIFI_SME_AP_MAX_ONLY_B_RATES 4
+
+
+/** Number of mandatory b rates */
+#define CSR_WIFI_SME_AP_MAX_MANDATORY_B_RATES 2
+
+
+/** Number of mandatory bg rates */
+#define CSR_WIFI_SME_AP_MAX_MANDATORY_BG_RATES 4
+
+
+/** Number of bg rates */
+#define CSR_WIFI_SME_AP_MAX_BG_RATES 12
+
+
+/** Number of no b only g rates */
+#define CSR_WIFI_SME_AP_MAX_NO_B_ONLY_G_RATES 8
+
+
+/** Number of mandatory g rates */
+#define CSR_WIFI_SME_AP_MAX_MANDATORY_G_RATES 7
+
+
+/* Number of g mandatory rates */
+#define CSR_WIFI_SME_AP_G_MANDATORY_RATES_NUM 7
+
+
+/* Number of b mandatory rates */
+#define CSR_WIFI_SME_AP_B_MANDATORY_RATES_NUM 2
+
+
+/* Number of b/g mandatory rates */
+#define CSR_WIFI_SME_AP_BG_MANDATORY_RATES_NUM 4
+
+
+/* The maximum allowed length of SSID */
+#define CSR_WIFI_SME_AP_SSID_MAX_LENGTH 32
+
+/* Refer 8.4.2.27 RSN element - we support TKIP, WPA2, WAPI and PSK only, no pmkid, group cipher suite */
+#define CSR_WIFI_SME_RSN_PACKED_SIZE (1 + 1 + 2 + 4 + 2 + 4 * 2 + 2 + 4 * 1 + 2 + 24)
+
+/* Refer 7.3.2.9 (ISO/IEC 8802-11:2006) WAPI element - we support WAPI PSK only, no bkid, group cipher suite */
+#define CSR_WIFI_SME_WAPI_PACKED_SIZE (1 + 1 + 2 + 2 + 4 * 1 + 2 + 4 * 1 + 4 + 2 + 24)
+
+
+/* Common structure for NME and SME to maintain Interface mode*/
+typedef u8 CsrWifiInterfaceMode;
+#define CSR_WIFI_MODE_NONE ((CsrWifiInterfaceMode) 0xFF)
+#define CSR_WIFI_MODE_STA ((CsrWifiInterfaceMode) 0x00)
+#define CSR_WIFI_MODE_AP ((CsrWifiInterfaceMode) 0x01)
+#define CSR_WIFI_MODE_P2P_DEVICE ((CsrWifiInterfaceMode) 0x02)
+#define CSR_WIFI_MODE_P2P_CLI ((CsrWifiInterfaceMode) 0x03)
+#define CSR_WIFI_MODE_P2P_GO ((CsrWifiInterfaceMode) 0x04)
+#define CSR_WIFI_MODE_AMP ((CsrWifiInterfaceMode) 0x05)
+#define CSR_WIFI_MODE_WPS_ENROLLEE ((CsrWifiInterfaceMode) 0x06)
+#define CSR_WIFI_MODE_IBSS ((CsrWifiInterfaceMode) 0x07)
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+
diff --git a/drivers/staging/csr/csr_wifi_result.h b/drivers/staging/csr/csr_wifi_result.h
new file mode 100644
index 000000000000..2f87cda9003e
--- /dev/null
+++ b/drivers/staging/csr/csr_wifi_result.h
@@ -0,0 +1,35 @@
+/*****************************************************************************
+
+ (c) Cambridge Silicon Radio Limited 2011
+ All rights reserved and confidential information of CSR
+
+ Refer to LICENSE.txt included with this source for details
+ on the license terms.
+
+*****************************************************************************/
+
+#ifndef CSR_WIFI_RESULT_H__
+#define CSR_WIFI_RESULT_H__
+
+#include "csr_result.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* THIS FILE SHOULD CONTAIN ONLY RESULT CODES */
+
+/* Result Codes */
+#define CSR_WIFI_HIP_RESULT_INVALID_VALUE ((CsrResult) 1) /* Invalid argument value */
+#define CSR_WIFI_HIP_RESULT_NO_DEVICE ((CsrResult) 2) /* The specified device is no longer present */
+#define CSR_WIFI_HIP_RESULT_NO_SPACE ((CsrResult) 3) /* A queue or buffer is full */
+#define CSR_WIFI_HIP_RESULT_NO_MEMORY ((CsrResult) 4) /* Fatal error, no memory */
+#define CSR_WIFI_HIP_RESULT_RANGE ((CsrResult) 5) /* Request exceeds the range of a file or a buffer */
+#define CSR_WIFI_HIP_RESULT_NOT_FOUND ((CsrResult) 6) /* A file (typically a f/w patch) is not found */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* CSR_WIFI_RESULT_H__ */
+
diff --git a/drivers/staging/csr/csr_wifi_router_converter_init.c b/drivers/staging/csr/csr_wifi_router_converter_init.c
new file mode 100644
index 000000000000..775c013d0514
--- /dev/null
+++ b/drivers/staging/csr/csr_wifi_router_converter_init.c
@@ -0,0 +1,82 @@
+/*****************************************************************************
+
+ (c) Cambridge Silicon Radio Limited 2012
+ All rights reserved and confidential information of CSR
+
+ Refer to LICENSE.txt included with this source for details
+ on the license terms.
+
+*****************************************************************************/
+
+/* Note: this is an auto-generated file. */
+
+#include "csr_msgconv.h"
+#include "csr_macro.h"
+
+
+#ifdef CSR_LOG_ENABLE
+#include "csr_log.h"
+#endif
+
+#ifndef EXCLUDE_CSR_WIFI_ROUTER_MODULE
+#include "csr_wifi_router_serialize.h"
+#include "csr_wifi_router_prim.h"
+
+static CsrMsgConvMsgEntry csrwifirouter_conv_lut[] = {
+ { CSR_WIFI_ROUTER_MA_PACKET_SUBSCRIBE_REQ, CsrWifiRouterMaPacketSubscribeReqSizeof, CsrWifiRouterMaPacketSubscribeReqSer, CsrWifiRouterMaPacketSubscribeReqDes, CsrWifiRouterMaPacketSubscribeReqSerFree },
+ { CSR_WIFI_ROUTER_MA_PACKET_UNSUBSCRIBE_REQ, CsrWifiRouterMaPacketUnsubscribeReqSizeof, CsrWifiRouterMaPacketUnsubscribeReqSer, CsrWifiRouterMaPacketUnsubscribeReqDes, CsrWifiRouterMaPacketUnsubscribeReqSerFree },
+ { CSR_WIFI_ROUTER_MA_PACKET_REQ, CsrWifiRouterMaPacketReqSizeof, CsrWifiRouterMaPacketReqSer, CsrWifiRouterMaPacketReqDes, CsrWifiRouterMaPacketReqSerFree },
+ { CSR_WIFI_ROUTER_MA_PACKET_RES, CsrWifiRouterMaPacketResSizeof, CsrWifiRouterMaPacketResSer, CsrWifiRouterMaPacketResDes, CsrWifiRouterMaPacketResSerFree },
+ { CSR_WIFI_ROUTER_MA_PACKET_CANCEL_REQ, CsrWifiRouterMaPacketCancelReqSizeof, CsrWifiRouterMaPacketCancelReqSer, CsrWifiRouterMaPacketCancelReqDes, CsrWifiRouterMaPacketCancelReqSerFree },
+ { CSR_WIFI_ROUTER_MA_PACKET_SUBSCRIBE_CFM, CsrWifiRouterMaPacketSubscribeCfmSizeof, CsrWifiRouterMaPacketSubscribeCfmSer, CsrWifiRouterMaPacketSubscribeCfmDes, CsrWifiRouterMaPacketSubscribeCfmSerFree },
+ { CSR_WIFI_ROUTER_MA_PACKET_UNSUBSCRIBE_CFM, CsrWifiRouterMaPacketUnsubscribeCfmSizeof, CsrWifiRouterMaPacketUnsubscribeCfmSer, CsrWifiRouterMaPacketUnsubscribeCfmDes, CsrWifiRouterMaPacketUnsubscribeCfmSerFree },
+ { CSR_WIFI_ROUTER_MA_PACKET_CFM, CsrWifiRouterMaPacketCfmSizeof, CsrWifiRouterMaPacketCfmSer, CsrWifiRouterMaPacketCfmDes, CsrWifiRouterMaPacketCfmSerFree },
+ { CSR_WIFI_ROUTER_MA_PACKET_IND, CsrWifiRouterMaPacketIndSizeof, CsrWifiRouterMaPacketIndSer, CsrWifiRouterMaPacketIndDes, CsrWifiRouterMaPacketIndSerFree },
+
+ { 0, NULL, NULL, NULL, NULL },
+};
+
+CsrMsgConvMsgEntry* CsrWifiRouterConverterLookup(CsrMsgConvMsgEntry *ce, u16 msgType)
+{
+ if (msgType & CSR_PRIM_UPSTREAM)
+ {
+ u16 idx = (msgType & ~CSR_PRIM_UPSTREAM) + CSR_WIFI_ROUTER_PRIM_DOWNSTREAM_COUNT;
+ if (idx < (CSR_WIFI_ROUTER_PRIM_UPSTREAM_COUNT + CSR_WIFI_ROUTER_PRIM_DOWNSTREAM_COUNT) &&
+ csrwifirouter_conv_lut[idx].msgType == msgType)
+ {
+ return &csrwifirouter_conv_lut[idx];
+ }
+ }
+ else
+ {
+ if (msgType < CSR_WIFI_ROUTER_PRIM_DOWNSTREAM_COUNT &&
+ csrwifirouter_conv_lut[msgType].msgType == msgType)
+ {
+ return &csrwifirouter_conv_lut[msgType];
+ }
+ }
+ return NULL;
+}
+
+
+void CsrWifiRouterConverterInit(void)
+{
+ CsrMsgConvInsert(CSR_WIFI_ROUTER_PRIM, csrwifirouter_conv_lut);
+ CsrMsgConvCustomLookupRegister(CSR_WIFI_ROUTER_PRIM, CsrWifiRouterConverterLookup);
+}
+
+
+#ifdef CSR_LOG_ENABLE
+static const CsrLogPrimitiveInformation csrwifirouter_conv_info = {
+ CSR_WIFI_ROUTER_PRIM,
+ (char *)"CSR_WIFI_ROUTER_PRIM",
+ csrwifirouter_conv_lut
+};
+const CsrLogPrimitiveInformation* CsrWifiRouterTechInfoGet(void)
+{
+ return &csrwifirouter_conv_info;
+}
+
+
+#endif /* CSR_LOG_ENABLE */
+#endif /* EXCLUDE_CSR_WIFI_ROUTER_MODULE */
diff --git a/drivers/staging/csr/csr_wifi_router_converter_init.h b/drivers/staging/csr/csr_wifi_router_converter_init.h
new file mode 100644
index 000000000000..2a293e457ffb
--- /dev/null
+++ b/drivers/staging/csr/csr_wifi_router_converter_init.h
@@ -0,0 +1,42 @@
+/*****************************************************************************
+
+ (c) Cambridge Silicon Radio Limited 2011
+ All rights reserved and confidential information of CSR
+
+ Refer to LICENSE.txt included with this source for details
+ on the license terms.
+
+*****************************************************************************/
+
+/* Note: this is an auto-generated file. */
+
+#ifndef CSR_WIFI_ROUTER_CONVERTER_INIT_H__
+#define CSR_WIFI_ROUTER_CONVERTER_INIT_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef EXCLUDE_CSR_WIFI_ROUTER_MODULE
+
+#include "csr_msgconv.h"
+
+#ifdef CSR_LOG_ENABLE
+#include "csr_log.h"
+
+extern const CsrLogPrimitiveInformation* CsrWifiRouterTechInfoGet(void);
+#endif /* CSR_LOG_ENABLE */
+
+extern void CsrWifiRouterConverterInit(void);
+
+#else /* EXCLUDE_CSR_WIFI_ROUTER_MODULE */
+
+#define CsrWifiRouterConverterInit()
+
+#endif /* EXCLUDE_CSR_WIFI_ROUTER_MODULE */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* CSR_WIFI_ROUTER_CONVERTER_INIT_H__ */
diff --git a/drivers/staging/csr/csr_wifi_router_ctrl_converter_init.c b/drivers/staging/csr/csr_wifi_router_ctrl_converter_init.c
new file mode 100644
index 000000000000..a02e307e5a88
--- /dev/null
+++ b/drivers/staging/csr/csr_wifi_router_ctrl_converter_init.c
@@ -0,0 +1,134 @@
+/*****************************************************************************
+
+ (c) Cambridge Silicon Radio Limited 2012
+ All rights reserved and confidential information of CSR
+
+ Refer to LICENSE.txt included with this source for details
+ on the license terms.
+
+*****************************************************************************/
+
+/* Note: this is an auto-generated file. */
+
+#include "csr_msgconv.h"
+#include "csr_macro.h"
+
+#ifdef CSR_LOG_ENABLE
+#include "csr_log.h"
+#endif
+
+#ifndef EXCLUDE_CSR_WIFI_ROUTER_CTRL_MODULE
+#include "csr_wifi_router_ctrl_serialize.h"
+#include "csr_wifi_router_ctrl_prim.h"
+
+static CsrMsgConvMsgEntry csrwifirouterctrl_conv_lut[] = {
+ { CSR_WIFI_ROUTER_CTRL_CONFIGURE_POWER_MODE_REQ, CsrWifiRouterCtrlConfigurePowerModeReqSizeof, CsrWifiRouterCtrlConfigurePowerModeReqSer, CsrWifiRouterCtrlConfigurePowerModeReqDes, CsrWifiRouterCtrlConfigurePowerModeReqSerFree },
+ { CSR_WIFI_ROUTER_CTRL_HIP_REQ, CsrWifiRouterCtrlHipReqSizeof, CsrWifiRouterCtrlHipReqSer, CsrWifiRouterCtrlHipReqDes, CsrWifiRouterCtrlHipReqSerFree },
+ { CSR_WIFI_ROUTER_CTRL_MEDIA_STATUS_REQ, CsrWifiRouterCtrlMediaStatusReqSizeof, CsrWifiRouterCtrlMediaStatusReqSer, CsrWifiRouterCtrlMediaStatusReqDes, CsrWifiRouterCtrlMediaStatusReqSerFree },
+ { CSR_WIFI_ROUTER_CTRL_MULTICAST_ADDRESS_RES, CsrWifiRouterCtrlMulticastAddressResSizeof, CsrWifiRouterCtrlMulticastAddressResSer, CsrWifiRouterCtrlMulticastAddressResDes, CsrWifiRouterCtrlMulticastAddressResSerFree },
+ { CSR_WIFI_ROUTER_CTRL_PORT_CONFIGURE_REQ, CsrWifiRouterCtrlPortConfigureReqSizeof, CsrWifiRouterCtrlPortConfigureReqSer, CsrWifiRouterCtrlPortConfigureReqDes, CsrWifiRouterCtrlPortConfigureReqSerFree },
+ { CSR_WIFI_ROUTER_CTRL_QOS_CONTROL_REQ, CsrWifiRouterCtrlQosControlReqSizeof, CsrWifiRouterCtrlQosControlReqSer, CsrWifiRouterCtrlQosControlReqDes, CsrWifiRouterCtrlQosControlReqSerFree },
+ { CSR_WIFI_ROUTER_CTRL_SUSPEND_RES, CsrWifiRouterCtrlSuspendResSizeof, CsrWifiRouterCtrlSuspendResSer, CsrWifiRouterCtrlSuspendResDes, CsrWifiRouterCtrlSuspendResSerFree },
+ { CSR_WIFI_ROUTER_CTRL_TCLAS_ADD_REQ, CsrWifiRouterCtrlTclasAddReqSizeof, CsrWifiRouterCtrlTclasAddReqSer, CsrWifiRouterCtrlTclasAddReqDes, CsrWifiRouterCtrlTclasAddReqSerFree },
+ { CSR_WIFI_ROUTER_CTRL_RESUME_RES, CsrWifiRouterCtrlResumeResSizeof, CsrWifiRouterCtrlResumeResSer, CsrWifiRouterCtrlResumeResDes, CsrWifiRouterCtrlResumeResSerFree },
+ { CSR_WIFI_ROUTER_CTRL_RAW_SDIO_DEINITIALISE_REQ, CsrWifiRouterCtrlRawSdioDeinitialiseReqSizeof, CsrWifiRouterCtrlRawSdioDeinitialiseReqSer, CsrWifiRouterCtrlRawSdioDeinitialiseReqDes, CsrWifiRouterCtrlRawSdioDeinitialiseReqSerFree },
+ { CSR_WIFI_ROUTER_CTRL_RAW_SDIO_INITIALISE_REQ, CsrWifiRouterCtrlRawSdioInitialiseReqSizeof, CsrWifiRouterCtrlRawSdioInitialiseReqSer, CsrWifiRouterCtrlRawSdioInitialiseReqDes, CsrWifiRouterCtrlRawSdioInitialiseReqSerFree },
+ { CSR_WIFI_ROUTER_CTRL_TCLAS_DEL_REQ, CsrWifiRouterCtrlTclasDelReqSizeof, CsrWifiRouterCtrlTclasDelReqSer, CsrWifiRouterCtrlTclasDelReqDes, CsrWifiRouterCtrlTclasDelReqSerFree },
+ { CSR_WIFI_ROUTER_CTRL_TRAFFIC_CLASSIFICATION_REQ, CsrWifiRouterCtrlTrafficClassificationReqSizeof, CsrWifiRouterCtrlTrafficClassificationReqSer, CsrWifiRouterCtrlTrafficClassificationReqDes, CsrWifiRouterCtrlTrafficClassificationReqSerFree },
+ { CSR_WIFI_ROUTER_CTRL_TRAFFIC_CONFIG_REQ, CsrWifiRouterCtrlTrafficConfigReqSizeof, CsrWifiRouterCtrlTrafficConfigReqSer, CsrWifiRouterCtrlTrafficConfigReqDes, CsrWifiRouterCtrlTrafficConfigReqSerFree },
+ { CSR_WIFI_ROUTER_CTRL_WIFI_OFF_REQ, CsrWifiRouterCtrlWifiOffReqSizeof, CsrWifiRouterCtrlWifiOffReqSer, CsrWifiRouterCtrlWifiOffReqDes, CsrWifiRouterCtrlWifiOffReqSerFree },
+ { CSR_WIFI_ROUTER_CTRL_WIFI_OFF_RES, CsrWifiRouterCtrlWifiOffResSizeof, CsrWifiRouterCtrlWifiOffResSer, CsrWifiRouterCtrlWifiOffResDes, CsrWifiRouterCtrlWifiOffResSerFree },
+ { CSR_WIFI_ROUTER_CTRL_WIFI_ON_REQ, CsrWifiRouterCtrlWifiOnReqSizeof, CsrWifiRouterCtrlWifiOnReqSer, CsrWifiRouterCtrlWifiOnReqDes, CsrWifiRouterCtrlWifiOnReqSerFree },
+ { CSR_WIFI_ROUTER_CTRL_WIFI_ON_RES, CsrWifiRouterCtrlWifiOnResSizeof, CsrWifiRouterCtrlWifiOnResSer, CsrWifiRouterCtrlWifiOnResDes, CsrWifiRouterCtrlWifiOnResSerFree },
+ { CSR_WIFI_ROUTER_CTRL_M4_TRANSMIT_REQ, CsrWifiRouterCtrlM4TransmitReqSizeof, CsrWifiRouterCtrlM4TransmitReqSer, CsrWifiRouterCtrlM4TransmitReqDes, CsrWifiRouterCtrlM4TransmitReqSerFree },
+ { CSR_WIFI_ROUTER_CTRL_MODE_SET_REQ, CsrWifiRouterCtrlModeSetReqSizeof, CsrWifiRouterCtrlModeSetReqSer, CsrWifiRouterCtrlModeSetReqDes, CsrWifiRouterCtrlModeSetReqSerFree },
+ { CSR_WIFI_ROUTER_CTRL_PEER_ADD_REQ, CsrWifiRouterCtrlPeerAddReqSizeof, CsrWifiRouterCtrlPeerAddReqSer, CsrWifiRouterCtrlPeerAddReqDes, CsrWifiRouterCtrlPeerAddReqSerFree },
+ { CSR_WIFI_ROUTER_CTRL_PEER_DEL_REQ, CsrWifiRouterCtrlPeerDelReqSizeof, CsrWifiRouterCtrlPeerDelReqSer, CsrWifiRouterCtrlPeerDelReqDes, CsrWifiRouterCtrlPeerDelReqSerFree },
+ { CSR_WIFI_ROUTER_CTRL_PEER_UPDATE_REQ, CsrWifiRouterCtrlPeerUpdateReqSizeof, CsrWifiRouterCtrlPeerUpdateReqSer, CsrWifiRouterCtrlPeerUpdateReqDes, CsrWifiRouterCtrlPeerUpdateReqSerFree },
+ { CSR_WIFI_ROUTER_CTRL_CAPABILITIES_REQ, CsrWifiRouterCtrlCapabilitiesReqSizeof, CsrWifiRouterCtrlCapabilitiesReqSer, CsrWifiRouterCtrlCapabilitiesReqDes, CsrWifiRouterCtrlCapabilitiesReqSerFree },
+ { CSR_WIFI_ROUTER_CTRL_BLOCK_ACK_ENABLE_REQ, CsrWifiRouterCtrlBlockAckEnableReqSizeof, CsrWifiRouterCtrlBlockAckEnableReqSer, CsrWifiRouterCtrlBlockAckEnableReqDes, CsrWifiRouterCtrlBlockAckEnableReqSerFree },
+ { CSR_WIFI_ROUTER_CTRL_BLOCK_ACK_DISABLE_REQ, CsrWifiRouterCtrlBlockAckDisableReqSizeof, CsrWifiRouterCtrlBlockAckDisableReqSer, CsrWifiRouterCtrlBlockAckDisableReqDes, CsrWifiRouterCtrlBlockAckDisableReqSerFree },
+ { CSR_WIFI_ROUTER_CTRL_WAPI_RX_PKT_REQ, CsrWifiRouterCtrlWapiRxPktReqSizeof, CsrWifiRouterCtrlWapiRxPktReqSer, CsrWifiRouterCtrlWapiRxPktReqDes, CsrWifiRouterCtrlWapiRxPktReqSerFree },
+ { CSR_WIFI_ROUTER_CTRL_WAPI_MULTICAST_FILTER_REQ, CsrWifiRouterCtrlWapiMulticastFilterReqSizeof, CsrWifiRouterCtrlWapiMulticastFilterReqSer, CsrWifiRouterCtrlWapiMulticastFilterReqDes, CsrWifiRouterCtrlWapiMulticastFilterReqSerFree },
+ { CSR_WIFI_ROUTER_CTRL_WAPI_UNICAST_FILTER_REQ, CsrWifiRouterCtrlWapiUnicastFilterReqSizeof, CsrWifiRouterCtrlWapiUnicastFilterReqSer, CsrWifiRouterCtrlWapiUnicastFilterReqDes, CsrWifiRouterCtrlWapiUnicastFilterReqSerFree },
+ { CSR_WIFI_ROUTER_CTRL_WAPI_UNICAST_TX_PKT_REQ, CsrWifiRouterCtrlWapiUnicastTxPktReqSizeof, CsrWifiRouterCtrlWapiUnicastTxPktReqSer, CsrWifiRouterCtrlWapiUnicastTxPktReqDes, CsrWifiRouterCtrlWapiUnicastTxPktReqSerFree },
+ { CSR_WIFI_ROUTER_CTRL_WAPI_FILTER_REQ, CsrWifiRouterCtrlWapiFilterReqSizeof, CsrWifiRouterCtrlWapiFilterReqSer, CsrWifiRouterCtrlWapiFilterReqDes, CsrWifiRouterCtrlWapiFilterReqSerFree },
+ { CSR_WIFI_ROUTER_CTRL_HIP_IND, CsrWifiRouterCtrlHipIndSizeof, CsrWifiRouterCtrlHipIndSer, CsrWifiRouterCtrlHipIndDes, CsrWifiRouterCtrlHipIndSerFree },
+ { CSR_WIFI_ROUTER_CTRL_MULTICAST_ADDRESS_IND, CsrWifiRouterCtrlMulticastAddressIndSizeof, CsrWifiRouterCtrlMulticastAddressIndSer, CsrWifiRouterCtrlMulticastAddressIndDes, CsrWifiRouterCtrlMulticastAddressIndSerFree },
+ { CSR_WIFI_ROUTER_CTRL_PORT_CONFIGURE_CFM, CsrWifiRouterCtrlPortConfigureCfmSizeof, CsrWifiRouterCtrlPortConfigureCfmSer, CsrWifiRouterCtrlPortConfigureCfmDes, CsrWifiRouterCtrlPortConfigureCfmSerFree },
+ { CSR_WIFI_ROUTER_CTRL_RESUME_IND, CsrWifiRouterCtrlResumeIndSizeof, CsrWifiRouterCtrlResumeIndSer, CsrWifiRouterCtrlResumeIndDes, CsrWifiRouterCtrlResumeIndSerFree },
+ { CSR_WIFI_ROUTER_CTRL_SUSPEND_IND, CsrWifiRouterCtrlSuspendIndSizeof, CsrWifiRouterCtrlSuspendIndSer, CsrWifiRouterCtrlSuspendIndDes, CsrWifiRouterCtrlSuspendIndSerFree },
+ { CSR_WIFI_ROUTER_CTRL_TCLAS_ADD_CFM, CsrWifiRouterCtrlTclasAddCfmSizeof, CsrWifiRouterCtrlTclasAddCfmSer, CsrWifiRouterCtrlTclasAddCfmDes, CsrWifiRouterCtrlTclasAddCfmSerFree },
+ { CSR_WIFI_ROUTER_CTRL_RAW_SDIO_DEINITIALISE_CFM, CsrWifiRouterCtrlRawSdioDeinitialiseCfmSizeof, CsrWifiRouterCtrlRawSdioDeinitialiseCfmSer, CsrWifiRouterCtrlRawSdioDeinitialiseCfmDes, CsrWifiRouterCtrlRawSdioDeinitialiseCfmSerFree },
+ { CSR_WIFI_ROUTER_CTRL_RAW_SDIO_INITIALISE_CFM, CsrWifiRouterCtrlRawSdioInitialiseCfmSizeof, CsrWifiRouterCtrlRawSdioInitialiseCfmSer, CsrWifiRouterCtrlRawSdioInitialiseCfmDes, CsrWifiRouterCtrlRawSdioInitialiseCfmSerFree },
+ { CSR_WIFI_ROUTER_CTRL_TCLAS_DEL_CFM, CsrWifiRouterCtrlTclasDelCfmSizeof, CsrWifiRouterCtrlTclasDelCfmSer, CsrWifiRouterCtrlTclasDelCfmDes, CsrWifiRouterCtrlTclasDelCfmSerFree },
+ { CSR_WIFI_ROUTER_CTRL_TRAFFIC_PROTOCOL_IND, CsrWifiRouterCtrlTrafficProtocolIndSizeof, CsrWifiRouterCtrlTrafficProtocolIndSer, CsrWifiRouterCtrlTrafficProtocolIndDes, CsrWifiRouterCtrlTrafficProtocolIndSerFree },
+ { CSR_WIFI_ROUTER_CTRL_TRAFFIC_SAMPLE_IND, CsrWifiRouterCtrlTrafficSampleIndSizeof, CsrWifiRouterCtrlTrafficSampleIndSer, CsrWifiRouterCtrlTrafficSampleIndDes, CsrWifiRouterCtrlTrafficSampleIndSerFree },
+ { CSR_WIFI_ROUTER_CTRL_WIFI_OFF_IND, CsrWifiRouterCtrlWifiOffIndSizeof, CsrWifiRouterCtrlWifiOffIndSer, CsrWifiRouterCtrlWifiOffIndDes, CsrWifiRouterCtrlWifiOffIndSerFree },
+ { CSR_WIFI_ROUTER_CTRL_WIFI_OFF_CFM, CsrWifiRouterCtrlWifiOffCfmSizeof, CsrWifiRouterCtrlWifiOffCfmSer, CsrWifiRouterCtrlWifiOffCfmDes, CsrWifiRouterCtrlWifiOffCfmSerFree },
+ { CSR_WIFI_ROUTER_CTRL_WIFI_ON_IND, CsrWifiRouterCtrlWifiOnIndSizeof, CsrWifiRouterCtrlWifiOnIndSer, CsrWifiRouterCtrlWifiOnIndDes, CsrWifiRouterCtrlWifiOnIndSerFree },
+ { CSR_WIFI_ROUTER_CTRL_WIFI_ON_CFM, CsrWifiRouterCtrlWifiOnCfmSizeof, CsrWifiRouterCtrlWifiOnCfmSer, CsrWifiRouterCtrlWifiOnCfmDes, CsrWifiRouterCtrlWifiOnCfmSerFree },
+ { CSR_WIFI_ROUTER_CTRL_M4_READY_TO_SEND_IND, CsrWifiRouterCtrlM4ReadyToSendIndSizeof, CsrWifiRouterCtrlM4ReadyToSendIndSer, CsrWifiRouterCtrlM4ReadyToSendIndDes, CsrWifiRouterCtrlM4ReadyToSendIndSerFree },
+ { CSR_WIFI_ROUTER_CTRL_M4_TRANSMITTED_IND, CsrWifiRouterCtrlM4TransmittedIndSizeof, CsrWifiRouterCtrlM4TransmittedIndSer, CsrWifiRouterCtrlM4TransmittedIndDes, CsrWifiRouterCtrlM4TransmittedIndSerFree },
+ { CSR_WIFI_ROUTER_CTRL_MIC_FAILURE_IND, CsrWifiRouterCtrlMicFailureIndSizeof, CsrWifiRouterCtrlMicFailureIndSer, CsrWifiRouterCtrlMicFailureIndDes, CsrWifiRouterCtrlMicFailureIndSerFree },
+ { CSR_WIFI_ROUTER_CTRL_CONNECTED_IND, CsrWifiRouterCtrlConnectedIndSizeof, CsrWifiRouterCtrlConnectedIndSer, CsrWifiRouterCtrlConnectedIndDes, CsrWifiRouterCtrlConnectedIndSerFree },
+ { CSR_WIFI_ROUTER_CTRL_PEER_ADD_CFM, CsrWifiRouterCtrlPeerAddCfmSizeof, CsrWifiRouterCtrlPeerAddCfmSer, CsrWifiRouterCtrlPeerAddCfmDes, CsrWifiRouterCtrlPeerAddCfmSerFree },
+ { CSR_WIFI_ROUTER_CTRL_PEER_DEL_CFM, CsrWifiRouterCtrlPeerDelCfmSizeof, CsrWifiRouterCtrlPeerDelCfmSer, CsrWifiRouterCtrlPeerDelCfmDes, CsrWifiRouterCtrlPeerDelCfmSerFree },
+ { CSR_WIFI_ROUTER_CTRL_UNEXPECTED_FRAME_IND, CsrWifiRouterCtrlUnexpectedFrameIndSizeof, CsrWifiRouterCtrlUnexpectedFrameIndSer, CsrWifiRouterCtrlUnexpectedFrameIndDes, CsrWifiRouterCtrlUnexpectedFrameIndSerFree },
+ { CSR_WIFI_ROUTER_CTRL_PEER_UPDATE_CFM, CsrWifiRouterCtrlPeerUpdateCfmSizeof, CsrWifiRouterCtrlPeerUpdateCfmSer, CsrWifiRouterCtrlPeerUpdateCfmDes, CsrWifiRouterCtrlPeerUpdateCfmSerFree },
+ { CSR_WIFI_ROUTER_CTRL_CAPABILITIES_CFM, CsrWifiRouterCtrlCapabilitiesCfmSizeof, CsrWifiRouterCtrlCapabilitiesCfmSer, CsrWifiRouterCtrlCapabilitiesCfmDes, CsrWifiRouterCtrlCapabilitiesCfmSerFree },
+ { CSR_WIFI_ROUTER_CTRL_BLOCK_ACK_ENABLE_CFM, CsrWifiRouterCtrlBlockAckEnableCfmSizeof, CsrWifiRouterCtrlBlockAckEnableCfmSer, CsrWifiRouterCtrlBlockAckEnableCfmDes, CsrWifiRouterCtrlBlockAckEnableCfmSerFree },
+ { CSR_WIFI_ROUTER_CTRL_BLOCK_ACK_DISABLE_CFM, CsrWifiRouterCtrlBlockAckDisableCfmSizeof, CsrWifiRouterCtrlBlockAckDisableCfmSer, CsrWifiRouterCtrlBlockAckDisableCfmDes, CsrWifiRouterCtrlBlockAckDisableCfmSerFree },
+ { CSR_WIFI_ROUTER_CTRL_BLOCK_ACK_ERROR_IND, CsrWifiRouterCtrlBlockAckErrorIndSizeof, CsrWifiRouterCtrlBlockAckErrorIndSer, CsrWifiRouterCtrlBlockAckErrorIndDes, CsrWifiRouterCtrlBlockAckErrorIndSerFree },
+ { CSR_WIFI_ROUTER_CTRL_STA_INACTIVE_IND, CsrWifiRouterCtrlStaInactiveIndSizeof, CsrWifiRouterCtrlStaInactiveIndSer, CsrWifiRouterCtrlStaInactiveIndDes, CsrWifiRouterCtrlStaInactiveIndSerFree },
+ { CSR_WIFI_ROUTER_CTRL_WAPI_RX_MIC_CHECK_IND, CsrWifiRouterCtrlWapiRxMicCheckIndSizeof, CsrWifiRouterCtrlWapiRxMicCheckIndSer, CsrWifiRouterCtrlWapiRxMicCheckIndDes, CsrWifiRouterCtrlWapiRxMicCheckIndSerFree },
+ { CSR_WIFI_ROUTER_CTRL_MODE_SET_CFM, CsrWifiRouterCtrlModeSetCfmSizeof, CsrWifiRouterCtrlModeSetCfmSer, CsrWifiRouterCtrlModeSetCfmDes, CsrWifiRouterCtrlModeSetCfmSerFree },
+ { CSR_WIFI_ROUTER_CTRL_WAPI_UNICAST_TX_ENCRYPT_IND, CsrWifiRouterCtrlWapiUnicastTxEncryptIndSizeof, CsrWifiRouterCtrlWapiUnicastTxEncryptIndSer, CsrWifiRouterCtrlWapiUnicastTxEncryptIndDes, CsrWifiRouterCtrlWapiUnicastTxEncryptIndSerFree },
+
+ { 0, NULL, NULL, NULL, NULL },
+};
+
+CsrMsgConvMsgEntry* CsrWifiRouterCtrlConverterLookup(CsrMsgConvMsgEntry *ce, u16 msgType)
+{
+ if (msgType & CSR_PRIM_UPSTREAM)
+ {
+ u16 idx = (msgType & ~CSR_PRIM_UPSTREAM) + CSR_WIFI_ROUTER_CTRL_PRIM_DOWNSTREAM_COUNT;
+ if (idx < (CSR_WIFI_ROUTER_CTRL_PRIM_UPSTREAM_COUNT + CSR_WIFI_ROUTER_CTRL_PRIM_DOWNSTREAM_COUNT) &&
+ csrwifirouterctrl_conv_lut[idx].msgType == msgType)
+ {
+ return &csrwifirouterctrl_conv_lut[idx];
+ }
+ }
+ else
+ {
+ if (msgType < CSR_WIFI_ROUTER_CTRL_PRIM_DOWNSTREAM_COUNT &&
+ csrwifirouterctrl_conv_lut[msgType].msgType == msgType)
+ {
+ return &csrwifirouterctrl_conv_lut[msgType];
+ }
+ }
+ return NULL;
+}
+
+
+void CsrWifiRouterCtrlConverterInit(void)
+{
+ CsrMsgConvInsert(CSR_WIFI_ROUTER_CTRL_PRIM, csrwifirouterctrl_conv_lut);
+ CsrMsgConvCustomLookupRegister(CSR_WIFI_ROUTER_CTRL_PRIM, CsrWifiRouterCtrlConverterLookup);
+}
+
+
+#ifdef CSR_LOG_ENABLE
+static const CsrLogPrimitiveInformation csrwifirouterctrl_conv_info = {
+ CSR_WIFI_ROUTER_CTRL_PRIM,
+ (char *)"CSR_WIFI_ROUTER_CTRL_PRIM",
+ csrwifirouterctrl_conv_lut
+};
+const CsrLogPrimitiveInformation* CsrWifiRouterCtrlTechInfoGet(void)
+{
+ return &csrwifirouterctrl_conv_info;
+}
+
+
+#endif /* CSR_LOG_ENABLE */
+#endif /* EXCLUDE_CSR_WIFI_ROUTER_CTRL_MODULE */
diff --git a/drivers/staging/csr/csr_wifi_router_ctrl_converter_init.h b/drivers/staging/csr/csr_wifi_router_ctrl_converter_init.h
new file mode 100644
index 000000000000..0c9d26b7a0b4
--- /dev/null
+++ b/drivers/staging/csr/csr_wifi_router_ctrl_converter_init.h
@@ -0,0 +1,42 @@
+/*****************************************************************************
+
+ (c) Cambridge Silicon Radio Limited 2011
+ All rights reserved and confidential information of CSR
+
+ Refer to LICENSE.txt included with this source for details
+ on the license terms.
+
+*****************************************************************************/
+
+/* Note: this is an auto-generated file. */
+
+#ifndef CSR_WIFI_ROUTER_CTRL_CONVERTER_INIT_H__
+#define CSR_WIFI_ROUTER_CTRL_CONVERTER_INIT_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef EXCLUDE_CSR_WIFI_ROUTER_CTRL_MODULE
+
+#include "csr_msgconv.h"
+
+#ifdef CSR_LOG_ENABLE
+#include "csr_log.h"
+
+extern const CsrLogPrimitiveInformation* CsrWifiRouterCtrlTechInfoGet(void);
+#endif /* CSR_LOG_ENABLE */
+
+extern void CsrWifiRouterCtrlConverterInit(void);
+
+#else /* EXCLUDE_CSR_WIFI_ROUTER_CTRL_MODULE */
+
+#define CsrWifiRouterCtrlConverterInit()
+
+#endif /* EXCLUDE_CSR_WIFI_ROUTER_CTRL_MODULE */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* CSR_WIFI_ROUTER_CTRL_CONVERTER_INIT_H__ */
diff --git a/drivers/staging/csr/csr_wifi_router_ctrl_free_downstream_contents.c b/drivers/staging/csr/csr_wifi_router_ctrl_free_downstream_contents.c
new file mode 100644
index 000000000000..7fa85fb4d6c0
--- /dev/null
+++ b/drivers/staging/csr/csr_wifi_router_ctrl_free_downstream_contents.c
@@ -0,0 +1,108 @@
+/*****************************************************************************
+
+ (c) Cambridge Silicon Radio Limited 2012
+ All rights reserved and confidential information of CSR
+
+ Refer to LICENSE.txt included with this source for details
+ on the license terms.
+
+*****************************************************************************/
+
+/* Note: this is an auto-generated file. */
+#include <linux/slab.h>
+#include "csr_wifi_router_ctrl_prim.h"
+#include "csr_wifi_router_ctrl_lib.h"
+
+/*----------------------------------------------------------------------------*
+ * NAME
+ * CsrWifiRouterCtrlFreeDownstreamMessageContents
+ *
+ * DESCRIPTION
+ *
+ *
+ * PARAMETERS
+ * eventClass: only the value CSR_WIFI_ROUTER_CTRL_PRIM will be handled
+ * message: the message to free
+ *----------------------------------------------------------------------------*/
+void CsrWifiRouterCtrlFreeDownstreamMessageContents(u16 eventClass, void *message)
+{
+ if (eventClass != CSR_WIFI_ROUTER_CTRL_PRIM)
+ {
+ return;
+ }
+ if (NULL == message)
+ {
+ return;
+ }
+
+ switch (*((CsrWifiRouterCtrlPrim *) message))
+ {
+ case CSR_WIFI_ROUTER_CTRL_HIP_REQ:
+ {
+ CsrWifiRouterCtrlHipReq *p = (CsrWifiRouterCtrlHipReq *)message;
+ kfree(p->mlmeCommand);
+ p->mlmeCommand = NULL;
+ kfree(p->dataRef1);
+ p->dataRef1 = NULL;
+ kfree(p->dataRef2);
+ p->dataRef2 = NULL;
+ break;
+ }
+ case CSR_WIFI_ROUTER_CTRL_MULTICAST_ADDRESS_RES:
+ {
+ CsrWifiRouterCtrlMulticastAddressRes *p = (CsrWifiRouterCtrlMulticastAddressRes *)message;
+ kfree(p->getAddresses);
+ p->getAddresses = NULL;
+ break;
+ }
+ case CSR_WIFI_ROUTER_CTRL_TCLAS_ADD_REQ:
+ {
+ CsrWifiRouterCtrlTclasAddReq *p = (CsrWifiRouterCtrlTclasAddReq *)message;
+ kfree(p->tclas);
+ p->tclas = NULL;
+ break;
+ }
+ case CSR_WIFI_ROUTER_CTRL_TCLAS_DEL_REQ:
+ {
+ CsrWifiRouterCtrlTclasDelReq *p = (CsrWifiRouterCtrlTclasDelReq *)message;
+ kfree(p->tclas);
+ p->tclas = NULL;
+ break;
+ }
+ case CSR_WIFI_ROUTER_CTRL_WIFI_ON_REQ:
+ {
+ CsrWifiRouterCtrlWifiOnReq *p = (CsrWifiRouterCtrlWifiOnReq *)message;
+ kfree(p->data);
+ p->data = NULL;
+ break;
+ }
+ case CSR_WIFI_ROUTER_CTRL_WIFI_ON_RES:
+ {
+ CsrWifiRouterCtrlWifiOnRes *p = (CsrWifiRouterCtrlWifiOnRes *)message;
+ kfree(p->smeVersions.smeBuild);
+ p->smeVersions.smeBuild = NULL;
+ break;
+ }
+ case CSR_WIFI_ROUTER_CTRL_WAPI_RX_PKT_REQ:
+ {
+ CsrWifiRouterCtrlWapiRxPktReq *p = (CsrWifiRouterCtrlWapiRxPktReq *)message;
+ kfree(p->signal);
+ p->signal = NULL;
+ kfree(p->data);
+ p->data = NULL;
+ break;
+ }
+ case CSR_WIFI_ROUTER_CTRL_WAPI_UNICAST_TX_PKT_REQ:
+ {
+ CsrWifiRouterCtrlWapiUnicastTxPktReq *p = (CsrWifiRouterCtrlWapiUnicastTxPktReq *)message;
+ kfree(p->data);
+ p->data = NULL;
+ break;
+ }
+
+ default:
+ break;
+ }
+}
+
+
diff --git a/drivers/staging/csr/csr_wifi_router_ctrl_free_upstream_contents.c b/drivers/staging/csr/csr_wifi_router_ctrl_free_upstream_contents.c
new file mode 100644
index 000000000000..954b3defc49c
--- /dev/null
+++ b/drivers/staging/csr/csr_wifi_router_ctrl_free_upstream_contents.c
@@ -0,0 +1,87 @@
+/*****************************************************************************
+
+ (c) Cambridge Silicon Radio Limited 2012
+ All rights reserved and confidential information of CSR
+
+ Refer to LICENSE.txt included with this source for details
+ on the license terms.
+
+*****************************************************************************/
+
+/* Note: this is an auto-generated file. */
+#include <linux/slab.h>
+#include "csr_wifi_router_ctrl_prim.h"
+#include "csr_wifi_router_ctrl_lib.h"
+
+/*----------------------------------------------------------------------------*
+ * NAME
+ * CsrWifiRouterCtrlFreeUpstreamMessageContents
+ *
+ * DESCRIPTION
+ *
+ *
+ * PARAMETERS
+ * eventClass: only the value CSR_WIFI_ROUTER_CTRL_PRIM will be handled
+ * message: the message to free
+ *----------------------------------------------------------------------------*/
+void CsrWifiRouterCtrlFreeUpstreamMessageContents(u16 eventClass, void *message)
+{
+ if (eventClass != CSR_WIFI_ROUTER_CTRL_PRIM)
+ {
+ return;
+ }
+ if (NULL == message)
+ {
+ return;
+ }
+
+ switch (*((CsrWifiRouterCtrlPrim *) message))
+ {
+ case CSR_WIFI_ROUTER_CTRL_HIP_IND:
+ {
+ CsrWifiRouterCtrlHipInd *p = (CsrWifiRouterCtrlHipInd *)message;
+ kfree(p->mlmeCommand);
+ p->mlmeCommand = NULL;
+ kfree(p->dataRef1);
+ p->dataRef1 = NULL;
+ kfree(p->dataRef2);
+ p->dataRef2 = NULL;
+ break;
+ }
+ case CSR_WIFI_ROUTER_CTRL_MULTICAST_ADDRESS_IND:
+ {
+ CsrWifiRouterCtrlMulticastAddressInd *p = (CsrWifiRouterCtrlMulticastAddressInd *)message;
+ kfree(p->setAddresses);
+ p->setAddresses = NULL;
+ break;
+ }
+ case CSR_WIFI_ROUTER_CTRL_WIFI_ON_IND:
+ {
+ CsrWifiRouterCtrlWifiOnInd *p = (CsrWifiRouterCtrlWifiOnInd *)message;
+ kfree(p->versions.routerBuild);
+ p->versions.routerBuild = NULL;
+ break;
+ }
+ case CSR_WIFI_ROUTER_CTRL_WAPI_RX_MIC_CHECK_IND:
+ {
+ CsrWifiRouterCtrlWapiRxMicCheckInd *p = (CsrWifiRouterCtrlWapiRxMicCheckInd *)message;
+ kfree(p->signal);
+ p->signal = NULL;
+ kfree(p->data);
+ p->data = NULL;
+ break;
+ }
+ case CSR_WIFI_ROUTER_CTRL_WAPI_UNICAST_TX_ENCRYPT_IND:
+ {
+ CsrWifiRouterCtrlWapiUnicastTxEncryptInd *p = (CsrWifiRouterCtrlWapiUnicastTxEncryptInd *)message;
+ kfree(p->data);
+ p->data = NULL;
+ break;
+ }
+
+ default:
+ break;
+ }
+}
+
+
diff --git a/drivers/staging/csr/csr_wifi_router_ctrl_lib.h b/drivers/staging/csr/csr_wifi_router_ctrl_lib.h
new file mode 100644
index 000000000000..93d0fadf5e6f
--- /dev/null
+++ b/drivers/staging/csr/csr_wifi_router_ctrl_lib.h
@@ -0,0 +1,2092 @@
+/*****************************************************************************
+
+ (c) Cambridge Silicon Radio Limited 2012
+ All rights reserved and confidential information of CSR
+
+ Refer to LICENSE.txt included with this source for details
+ on the license terms.
+
+*****************************************************************************/
+
+/* Note: this is an auto-generated file. */
+
+#ifndef CSR_WIFI_ROUTER_CTRL_LIB_H__
+#define CSR_WIFI_ROUTER_CTRL_LIB_H__
+
+#include "csr_sched.h"
+#include "csr_macro.h"
+#include "csr_msg_transport.h"
+
+#include "csr_wifi_lib.h"
+
+#include "csr_wifi_router_ctrl_prim.h"
+#include "csr_wifi_router_task.h"
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*----------------------------------------------------------------------------*
+ * CsrWifiRouterCtrlFreeUpstreamMessageContents
+ *
+ * DESCRIPTION
+ * Free the allocated memory in a CSR_WIFI_ROUTER_CTRL upstream message. Does not
+ * free the message itself, and can only be used for upstream messages.
+ *
+ * PARAMETERS
+ * Deallocates the resources in a CSR_WIFI_ROUTER_CTRL upstream message
+ *----------------------------------------------------------------------------*/
+void CsrWifiRouterCtrlFreeUpstreamMessageContents(u16 eventClass, void *message);
+
+/*----------------------------------------------------------------------------*
+ * CsrWifiRouterCtrlFreeDownstreamMessageContents
+ *
+ * DESCRIPTION
+ * Free the allocated memory in a CSR_WIFI_ROUTER_CTRL downstream message. Does not
+ * free the message itself, and can only be used for downstream messages.
+ *
+ * PARAMETERS
+ * Deallocates the resources in a CSR_WIFI_ROUTER_CTRL downstream message
+ *----------------------------------------------------------------------------*/
+void CsrWifiRouterCtrlFreeDownstreamMessageContents(u16 eventClass, void *message);
+
+/*----------------------------------------------------------------------------*
+ * Enum to string functions
+ *----------------------------------------------------------------------------*/
+const char* CsrWifiRouterCtrlBlockAckRoleToString(CsrWifiRouterCtrlBlockAckRole value);
+const char* CsrWifiRouterCtrlControlIndicationToString(CsrWifiRouterCtrlControlIndication value);
+const char* CsrWifiRouterCtrlListActionToString(CsrWifiRouterCtrlListAction value);
+const char* CsrWifiRouterCtrlLowPowerModeToString(CsrWifiRouterCtrlLowPowerMode value);
+const char* CsrWifiRouterCtrlMediaStatusToString(CsrWifiRouterCtrlMediaStatus value);
+const char* CsrWifiRouterCtrlModeToString(CsrWifiRouterCtrlMode value);
+const char* CsrWifiRouterCtrlPeerStatusToString(CsrWifiRouterCtrlPeerStatus value);
+const char* CsrWifiRouterCtrlPortActionToString(CsrWifiRouterCtrlPortAction value);
+const char* CsrWifiRouterCtrlPowersaveTypeToString(CsrWifiRouterCtrlPowersaveType value);
+const char* CsrWifiRouterCtrlProtocolDirectionToString(CsrWifiRouterCtrlProtocolDirection value);
+const char* CsrWifiRouterCtrlQoSControlToString(CsrWifiRouterCtrlQoSControl value);
+const char* CsrWifiRouterCtrlQueueConfigToString(CsrWifiRouterCtrlQueueConfig value);
+const char* CsrWifiRouterCtrlTrafficConfigTypeToString(CsrWifiRouterCtrlTrafficConfigType value);
+const char* CsrWifiRouterCtrlTrafficPacketTypeToString(CsrWifiRouterCtrlTrafficPacketType value);
+const char* CsrWifiRouterCtrlTrafficTypeToString(CsrWifiRouterCtrlTrafficType value);
+
+
+/*----------------------------------------------------------------------------*
+ * CsrPrim Type toString function.
+ * Converts a message type to the String name of the Message
+ *----------------------------------------------------------------------------*/
+const char* CsrWifiRouterCtrlPrimTypeToString(CsrPrim msgType);
+
+/*----------------------------------------------------------------------------*
+ * Lookup arrays for PrimType name Strings
+ *----------------------------------------------------------------------------*/
+extern const char *CsrWifiRouterCtrlUpstreamPrimNames[CSR_WIFI_ROUTER_CTRL_PRIM_UPSTREAM_COUNT];
+extern const char *CsrWifiRouterCtrlDownstreamPrimNames[CSR_WIFI_ROUTER_CTRL_PRIM_DOWNSTREAM_COUNT];
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiRouterCtrlBlockAckDisableReqSend
+
+ DESCRIPTION
+
+ PARAMETERS
+ queue - Message Source Task Queue (Cfm's will be sent to this Queue)
+ interfaceTag -
+ clientData -
+ macAddress -
+ trafficStreamID -
+ role -
+
+*******************************************************************************/
+#define CsrWifiRouterCtrlBlockAckDisableReqCreate(msg__, dst__, src__, interfaceTag__, clientData__, macAddress__, trafficStreamID__, role__) \
+ msg__ = kmalloc(sizeof(CsrWifiRouterCtrlBlockAckDisableReq), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_BLOCK_ACK_DISABLE_REQ, dst__, src__); \
+ msg__->interfaceTag = (interfaceTag__); \
+ msg__->clientData = (clientData__); \
+ msg__->macAddress = (macAddress__); \
+ msg__->trafficStreamID = (trafficStreamID__); \
+ msg__->role = (role__);
+
+#define CsrWifiRouterCtrlBlockAckDisableReqSendTo(dst__, src__, interfaceTag__, clientData__, macAddress__, trafficStreamID__, role__) \
+ { \
+ CsrWifiRouterCtrlBlockAckDisableReq *msg__; \
+ CsrWifiRouterCtrlBlockAckDisableReqCreate(msg__, dst__, src__, interfaceTag__, clientData__, macAddress__, trafficStreamID__, role__); \
+ CsrMsgTransport(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
+ }
+
+#define CsrWifiRouterCtrlBlockAckDisableReqSend(src__, interfaceTag__, clientData__, macAddress__, trafficStreamID__, role__) \
+ CsrWifiRouterCtrlBlockAckDisableReqSendTo(CSR_WIFI_ROUTER_IFACEQUEUE, src__, interfaceTag__, clientData__, macAddress__, trafficStreamID__, role__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiRouterCtrlBlockAckDisableCfmSend
+
+ DESCRIPTION
+
+ PARAMETERS
+ queue - Destination Task Queue
+ clientData -
+ interfaceTag -
+ status -
+
+*******************************************************************************/
+#define CsrWifiRouterCtrlBlockAckDisableCfmCreate(msg__, dst__, src__, clientData__, interfaceTag__, status__) \
+ msg__ = kmalloc(sizeof(CsrWifiRouterCtrlBlockAckDisableCfm), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_BLOCK_ACK_DISABLE_CFM, dst__, src__); \
+ msg__->clientData = (clientData__); \
+ msg__->interfaceTag = (interfaceTag__); \
+ msg__->status = (status__);
+
+#define CsrWifiRouterCtrlBlockAckDisableCfmSendTo(dst__, src__, clientData__, interfaceTag__, status__) \
+ { \
+ CsrWifiRouterCtrlBlockAckDisableCfm *msg__; \
+ CsrWifiRouterCtrlBlockAckDisableCfmCreate(msg__, dst__, src__, clientData__, interfaceTag__, status__); \
+ CsrSchedMessagePut(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
+ }
+
+#define CsrWifiRouterCtrlBlockAckDisableCfmSend(dst__, clientData__, interfaceTag__, status__) \
+ CsrWifiRouterCtrlBlockAckDisableCfmSendTo(dst__, CSR_WIFI_ROUTER_IFACEQUEUE, clientData__, interfaceTag__, status__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiRouterCtrlBlockAckEnableReqSend
+
+ DESCRIPTION
+
+ PARAMETERS
+ queue - Message Source Task Queue (Cfm's will be sent to this Queue)
+ interfaceTag -
+ clientData -
+ macAddress -
+ trafficStreamID -
+ role -
+ bufferSize -
+ timeout -
+ ssn -
+
+*******************************************************************************/
+#define CsrWifiRouterCtrlBlockAckEnableReqCreate(msg__, dst__, src__, interfaceTag__, clientData__, macAddress__, trafficStreamID__, role__, bufferSize__, timeout__, ssn__) \
+ msg__ = kmalloc(sizeof(CsrWifiRouterCtrlBlockAckEnableReq), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_BLOCK_ACK_ENABLE_REQ, dst__, src__); \
+ msg__->interfaceTag = (interfaceTag__); \
+ msg__->clientData = (clientData__); \
+ msg__->macAddress = (macAddress__); \
+ msg__->trafficStreamID = (trafficStreamID__); \
+ msg__->role = (role__); \
+ msg__->bufferSize = (bufferSize__); \
+ msg__->timeout = (timeout__); \
+ msg__->ssn = (ssn__);
+
+#define CsrWifiRouterCtrlBlockAckEnableReqSendTo(dst__, src__, interfaceTag__, clientData__, macAddress__, trafficStreamID__, role__, bufferSize__, timeout__, ssn__) \
+ { \
+ CsrWifiRouterCtrlBlockAckEnableReq *msg__; \
+ CsrWifiRouterCtrlBlockAckEnableReqCreate(msg__, dst__, src__, interfaceTag__, clientData__, macAddress__, trafficStreamID__, role__, bufferSize__, timeout__, ssn__); \
+ CsrMsgTransport(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
+ }
+
+#define CsrWifiRouterCtrlBlockAckEnableReqSend(src__, interfaceTag__, clientData__, macAddress__, trafficStreamID__, role__, bufferSize__, timeout__, ssn__) \
+ CsrWifiRouterCtrlBlockAckEnableReqSendTo(CSR_WIFI_ROUTER_IFACEQUEUE, src__, interfaceTag__, clientData__, macAddress__, trafficStreamID__, role__, bufferSize__, timeout__, ssn__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiRouterCtrlBlockAckEnableCfmSend
+
+ DESCRIPTION
+
+ PARAMETERS
+ queue - Destination Task Queue
+ clientData -
+ interfaceTag -
+ status -
+
+*******************************************************************************/
+#define CsrWifiRouterCtrlBlockAckEnableCfmCreate(msg__, dst__, src__, clientData__, interfaceTag__, status__) \
+ msg__ = kmalloc(sizeof(CsrWifiRouterCtrlBlockAckEnableCfm), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_BLOCK_ACK_ENABLE_CFM, dst__, src__); \
+ msg__->clientData = (clientData__); \
+ msg__->interfaceTag = (interfaceTag__); \
+ msg__->status = (status__);
+
+#define CsrWifiRouterCtrlBlockAckEnableCfmSendTo(dst__, src__, clientData__, interfaceTag__, status__) \
+ { \
+ CsrWifiRouterCtrlBlockAckEnableCfm *msg__; \
+ CsrWifiRouterCtrlBlockAckEnableCfmCreate(msg__, dst__, src__, clientData__, interfaceTag__, status__); \
+ CsrSchedMessagePut(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
+ }
+
+#define CsrWifiRouterCtrlBlockAckEnableCfmSend(dst__, clientData__, interfaceTag__, status__) \
+ CsrWifiRouterCtrlBlockAckEnableCfmSendTo(dst__, CSR_WIFI_ROUTER_IFACEQUEUE, clientData__, interfaceTag__, status__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiRouterCtrlBlockAckErrorIndSend
+
+ DESCRIPTION
+
+ PARAMETERS
+ queue - Destination Task Queue
+ clientData -
+ interfaceTag -
+ trafficStreamID -
+ peerMacAddress -
+ status -
+
+*******************************************************************************/
+#define CsrWifiRouterCtrlBlockAckErrorIndCreate(msg__, dst__, src__, clientData__, interfaceTag__, trafficStreamID__, peerMacAddress__, status__) \
+ msg__ = kmalloc(sizeof(CsrWifiRouterCtrlBlockAckErrorInd), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_BLOCK_ACK_ERROR_IND, dst__, src__); \
+ msg__->clientData = (clientData__); \
+ msg__->interfaceTag = (interfaceTag__); \
+ msg__->trafficStreamID = (trafficStreamID__); \
+ msg__->peerMacAddress = (peerMacAddress__); \
+ msg__->status = (status__);
+
+#define CsrWifiRouterCtrlBlockAckErrorIndSendTo(dst__, src__, clientData__, interfaceTag__, trafficStreamID__, peerMacAddress__, status__) \
+ { \
+ CsrWifiRouterCtrlBlockAckErrorInd *msg__; \
+ CsrWifiRouterCtrlBlockAckErrorIndCreate(msg__, dst__, src__, clientData__, interfaceTag__, trafficStreamID__, peerMacAddress__, status__); \
+ CsrSchedMessagePut(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
+ }
+
+#define CsrWifiRouterCtrlBlockAckErrorIndSend(dst__, clientData__, interfaceTag__, trafficStreamID__, peerMacAddress__, status__) \
+ CsrWifiRouterCtrlBlockAckErrorIndSendTo(dst__, CSR_WIFI_ROUTER_IFACEQUEUE, clientData__, interfaceTag__, trafficStreamID__, peerMacAddress__, status__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiRouterCtrlCapabilitiesReqSend
+
+ DESCRIPTION
+
+ PARAMETERS
+ queue - Message Source Task Queue (Cfm's will be sent to this Queue)
+ clientData -
+
+*******************************************************************************/
+#define CsrWifiRouterCtrlCapabilitiesReqCreate(msg__, dst__, src__, clientData__) \
+ msg__ = kmalloc(sizeof(CsrWifiRouterCtrlCapabilitiesReq), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_CAPABILITIES_REQ, dst__, src__); \
+ msg__->clientData = (clientData__);
+
+#define CsrWifiRouterCtrlCapabilitiesReqSendTo(dst__, src__, clientData__) \
+ { \
+ CsrWifiRouterCtrlCapabilitiesReq *msg__; \
+ CsrWifiRouterCtrlCapabilitiesReqCreate(msg__, dst__, src__, clientData__); \
+ CsrMsgTransport(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
+ }
+
+#define CsrWifiRouterCtrlCapabilitiesReqSend(src__, clientData__) \
+ CsrWifiRouterCtrlCapabilitiesReqSendTo(CSR_WIFI_ROUTER_IFACEQUEUE, src__, clientData__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiRouterCtrlCapabilitiesCfmSend
+
+ DESCRIPTION
+ The router sends this primitive to confirm the size of the queues of the
+ HIP.
+
+ PARAMETERS
+ queue - Destination Task Queue
+ clientData -
+ commandQueueSize - Size of command queue
+ trafficQueueSize - Size of traffic queue (per AC)
+
+*******************************************************************************/
+#define CsrWifiRouterCtrlCapabilitiesCfmCreate(msg__, dst__, src__, clientData__, commandQueueSize__, trafficQueueSize__) \
+ msg__ = kmalloc(sizeof(CsrWifiRouterCtrlCapabilitiesCfm), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_CAPABILITIES_CFM, dst__, src__); \
+ msg__->clientData = (clientData__); \
+ msg__->commandQueueSize = (commandQueueSize__); \
+ msg__->trafficQueueSize = (trafficQueueSize__);
+
+#define CsrWifiRouterCtrlCapabilitiesCfmSendTo(dst__, src__, clientData__, commandQueueSize__, trafficQueueSize__) \
+ { \
+ CsrWifiRouterCtrlCapabilitiesCfm *msg__; \
+ CsrWifiRouterCtrlCapabilitiesCfmCreate(msg__, dst__, src__, clientData__, commandQueueSize__, trafficQueueSize__); \
+ CsrSchedMessagePut(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
+ }
+
+#define CsrWifiRouterCtrlCapabilitiesCfmSend(dst__, clientData__, commandQueueSize__, trafficQueueSize__) \
+ CsrWifiRouterCtrlCapabilitiesCfmSendTo(dst__, CSR_WIFI_ROUTER_IFACEQUEUE, clientData__, commandQueueSize__, trafficQueueSize__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiRouterCtrlConfigurePowerModeReqSend
+
+ DESCRIPTION
+
+ PARAMETERS
+ queue - Message Source Task Queue (Cfm's will be sent to this Queue)
+ clientData -
+ mode -
+ wakeHost -
+
+*******************************************************************************/
+#define CsrWifiRouterCtrlConfigurePowerModeReqCreate(msg__, dst__, src__, clientData__, mode__, wakeHost__) \
+ msg__ = kmalloc(sizeof(CsrWifiRouterCtrlConfigurePowerModeReq), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_CONFIGURE_POWER_MODE_REQ, dst__, src__); \
+ msg__->clientData = (clientData__); \
+ msg__->mode = (mode__); \
+ msg__->wakeHost = (wakeHost__);
+
+#define CsrWifiRouterCtrlConfigurePowerModeReqSendTo(dst__, src__, clientData__, mode__, wakeHost__) \
+ { \
+ CsrWifiRouterCtrlConfigurePowerModeReq *msg__; \
+ CsrWifiRouterCtrlConfigurePowerModeReqCreate(msg__, dst__, src__, clientData__, mode__, wakeHost__); \
+ CsrMsgTransport(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
+ }
+
+#define CsrWifiRouterCtrlConfigurePowerModeReqSend(src__, clientData__, mode__, wakeHost__) \
+ CsrWifiRouterCtrlConfigurePowerModeReqSendTo(CSR_WIFI_ROUTER_IFACEQUEUE, src__, clientData__, mode__, wakeHost__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiRouterCtrlConnectedIndSend
+
+ DESCRIPTION
+
+ PARAMETERS
+ queue - Destination Task Queue
+ clientData -
+ interfaceTag -
+ peerMacAddress -
+ peerStatus -
+
+*******************************************************************************/
+#define CsrWifiRouterCtrlConnectedIndCreate(msg__, dst__, src__, clientData__, interfaceTag__, peerMacAddress__, peerStatus__) \
+ msg__ = kmalloc(sizeof(CsrWifiRouterCtrlConnectedInd), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_CONNECTED_IND, dst__, src__); \
+ msg__->clientData = (clientData__); \
+ msg__->interfaceTag = (interfaceTag__); \
+ msg__->peerMacAddress = (peerMacAddress__); \
+ msg__->peerStatus = (peerStatus__);
+
+#define CsrWifiRouterCtrlConnectedIndSendTo(dst__, src__, clientData__, interfaceTag__, peerMacAddress__, peerStatus__) \
+ { \
+ CsrWifiRouterCtrlConnectedInd *msg__; \
+ CsrWifiRouterCtrlConnectedIndCreate(msg__, dst__, src__, clientData__, interfaceTag__, peerMacAddress__, peerStatus__); \
+ CsrSchedMessagePut(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
+ }
+
+#define CsrWifiRouterCtrlConnectedIndSend(dst__, clientData__, interfaceTag__, peerMacAddress__, peerStatus__) \
+ CsrWifiRouterCtrlConnectedIndSendTo(dst__, CSR_WIFI_ROUTER_IFACEQUEUE, clientData__, interfaceTag__, peerMacAddress__, peerStatus__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiRouterCtrlHipReqSend
+
+ DESCRIPTION
+ This primitive is used for transferring MLME messages to the HIP.
+
+ PARAMETERS
+ queue - Message Source Task Queue (Cfm's will be sent to this Queue)
+ mlmeCommandLength - Length of the MLME signal
+ mlmeCommand - Pointer to the MLME signal
+ dataRef1Length - Length of the dataRef1 bulk data
+ dataRef1 - Pointer to the bulk data 1
+ dataRef2Length - Length of the dataRef2 bulk data
+ dataRef2 - Pointer to the bulk data 2
+
+*******************************************************************************/
+#define CsrWifiRouterCtrlHipReqCreate(msg__, dst__, src__, mlmeCommandLength__, mlmeCommand__, dataRef1Length__, dataRef1__, dataRef2Length__, dataRef2__) \
+ msg__ = kmalloc(sizeof(CsrWifiRouterCtrlHipReq), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_HIP_REQ, dst__, src__); \
+ msg__->mlmeCommandLength = (mlmeCommandLength__); \
+ msg__->mlmeCommand = (mlmeCommand__); \
+ msg__->dataRef1Length = (dataRef1Length__); \
+ msg__->dataRef1 = (dataRef1__); \
+ msg__->dataRef2Length = (dataRef2Length__); \
+ msg__->dataRef2 = (dataRef2__);
+
+#define CsrWifiRouterCtrlHipReqSendTo(dst__, src__, mlmeCommandLength__, mlmeCommand__, dataRef1Length__, dataRef1__, dataRef2Length__, dataRef2__) \
+ { \
+ CsrWifiRouterCtrlHipReq *msg__; \
+ CsrWifiRouterCtrlHipReqCreate(msg__, dst__, src__, mlmeCommandLength__, mlmeCommand__, dataRef1Length__, dataRef1__, dataRef2Length__, dataRef2__); \
+ CsrMsgTransport(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
+ }
+
+#define CsrWifiRouterCtrlHipReqSend(src__, mlmeCommandLength__, mlmeCommand__, dataRef1Length__, dataRef1__, dataRef2Length__, dataRef2__) \
+ CsrWifiRouterCtrlHipReqSendTo(CSR_WIFI_ROUTER_IFACEQUEUE, src__, mlmeCommandLength__, mlmeCommand__, dataRef1Length__, dataRef1__, dataRef2Length__, dataRef2__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiRouterCtrlHipIndSend
+
+ DESCRIPTION
+ This primitive is used for transferring MLME messages from the HIP.
+
+ PARAMETERS
+ queue - Destination Task Queue
+ mlmeCommandLength - Length of the MLME signal
+ mlmeCommand - Pointer to the MLME signal
+ dataRef1Length - Length of the dataRef1 bulk data
+ dataRef1 - Pointer to the bulk data 1
+ dataRef2Length - Length of the dataRef2 bulk data
+ dataRef2 - Pointer to the bulk data 2
+
+*******************************************************************************/
+#define CsrWifiRouterCtrlHipIndCreate(msg__, dst__, src__, mlmeCommandLength__, mlmeCommand__, dataRef1Length__, dataRef1__, dataRef2Length__, dataRef2__) \
+ msg__ = kmalloc(sizeof(CsrWifiRouterCtrlHipInd), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_HIP_IND, dst__, src__); \
+ msg__->mlmeCommandLength = (mlmeCommandLength__); \
+ msg__->mlmeCommand = (mlmeCommand__); \
+ msg__->dataRef1Length = (dataRef1Length__); \
+ msg__->dataRef1 = (dataRef1__); \
+ msg__->dataRef2Length = (dataRef2Length__); \
+ msg__->dataRef2 = (dataRef2__);
+
+#define CsrWifiRouterCtrlHipIndSendTo(dst__, src__, mlmeCommandLength__, mlmeCommand__, dataRef1Length__, dataRef1__, dataRef2Length__, dataRef2__) \
+ { \
+ CsrWifiRouterCtrlHipInd *msg__; \
+ CsrWifiRouterCtrlHipIndCreate(msg__, dst__, src__, mlmeCommandLength__, mlmeCommand__, dataRef1Length__, dataRef1__, dataRef2Length__, dataRef2__); \
+ CsrSchedMessagePut(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
+ }
+
+#define CsrWifiRouterCtrlHipIndSend(dst__, mlmeCommandLength__, mlmeCommand__, dataRef1Length__, dataRef1__, dataRef2Length__, dataRef2__) \
+ CsrWifiRouterCtrlHipIndSendTo(dst__, CSR_WIFI_ROUTER_IFACEQUEUE, mlmeCommandLength__, mlmeCommand__, dataRef1Length__, dataRef1__, dataRef2Length__, dataRef2__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiRouterCtrlM4ReadyToSendIndSend
+
+ DESCRIPTION
+
+ PARAMETERS
+ queue - Destination Task Queue
+ clientData -
+ interfaceTag -
+ peerMacAddress -
+
+*******************************************************************************/
+#define CsrWifiRouterCtrlM4ReadyToSendIndCreate(msg__, dst__, src__, clientData__, interfaceTag__, peerMacAddress__) \
+ msg__ = kmalloc(sizeof(CsrWifiRouterCtrlM4ReadyToSendInd), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_M4_READY_TO_SEND_IND, dst__, src__); \
+ msg__->clientData = (clientData__); \
+ msg__->interfaceTag = (interfaceTag__); \
+ msg__->peerMacAddress = (peerMacAddress__);
+
+#define CsrWifiRouterCtrlM4ReadyToSendIndSendTo(dst__, src__, clientData__, interfaceTag__, peerMacAddress__) \
+ { \
+ CsrWifiRouterCtrlM4ReadyToSendInd *msg__; \
+ CsrWifiRouterCtrlM4ReadyToSendIndCreate(msg__, dst__, src__, clientData__, interfaceTag__, peerMacAddress__); \
+ CsrSchedMessagePut(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
+ }
+
+#define CsrWifiRouterCtrlM4ReadyToSendIndSend(dst__, clientData__, interfaceTag__, peerMacAddress__) \
+ CsrWifiRouterCtrlM4ReadyToSendIndSendTo(dst__, CSR_WIFI_ROUTER_IFACEQUEUE, clientData__, interfaceTag__, peerMacAddress__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiRouterCtrlM4TransmitReqSend
+
+ DESCRIPTION
+
+ PARAMETERS
+ queue - Message Source Task Queue (Cfm's will be sent to this Queue)
+ interfaceTag -
+ clientData -
+
+*******************************************************************************/
+#define CsrWifiRouterCtrlM4TransmitReqCreate(msg__, dst__, src__, interfaceTag__, clientData__) \
+ msg__ = kmalloc(sizeof(CsrWifiRouterCtrlM4TransmitReq), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_M4_TRANSMIT_REQ, dst__, src__); \
+ msg__->interfaceTag = (interfaceTag__); \
+ msg__->clientData = (clientData__);
+
+#define CsrWifiRouterCtrlM4TransmitReqSendTo(dst__, src__, interfaceTag__, clientData__) \
+ { \
+ CsrWifiRouterCtrlM4TransmitReq *msg__; \
+ CsrWifiRouterCtrlM4TransmitReqCreate(msg__, dst__, src__, interfaceTag__, clientData__); \
+ CsrMsgTransport(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
+ }
+
+#define CsrWifiRouterCtrlM4TransmitReqSend(src__, interfaceTag__, clientData__) \
+ CsrWifiRouterCtrlM4TransmitReqSendTo(CSR_WIFI_ROUTER_IFACEQUEUE, src__, interfaceTag__, clientData__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiRouterCtrlM4TransmittedIndSend
+
+ DESCRIPTION
+
+ PARAMETERS
+ queue - Destination Task Queue
+ clientData -
+ interfaceTag -
+ peerMacAddress -
+ status -
+
+*******************************************************************************/
+#define CsrWifiRouterCtrlM4TransmittedIndCreate(msg__, dst__, src__, clientData__, interfaceTag__, peerMacAddress__, status__) \
+ msg__ = kmalloc(sizeof(CsrWifiRouterCtrlM4TransmittedInd), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_M4_TRANSMITTED_IND, dst__, src__); \
+ msg__->clientData = (clientData__); \
+ msg__->interfaceTag = (interfaceTag__); \
+ msg__->peerMacAddress = (peerMacAddress__); \
+ msg__->status = (status__);
+
+#define CsrWifiRouterCtrlM4TransmittedIndSendTo(dst__, src__, clientData__, interfaceTag__, peerMacAddress__, status__) \
+ { \
+ CsrWifiRouterCtrlM4TransmittedInd *msg__; \
+ CsrWifiRouterCtrlM4TransmittedIndCreate(msg__, dst__, src__, clientData__, interfaceTag__, peerMacAddress__, status__); \
+ CsrSchedMessagePut(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
+ }
+
+#define CsrWifiRouterCtrlM4TransmittedIndSend(dst__, clientData__, interfaceTag__, peerMacAddress__, status__) \
+ CsrWifiRouterCtrlM4TransmittedIndSendTo(dst__, CSR_WIFI_ROUTER_IFACEQUEUE, clientData__, interfaceTag__, peerMacAddress__, status__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiRouterCtrlMediaStatusReqSend
+
+ DESCRIPTION
+
+ PARAMETERS
+ queue - Message Source Task Queue (Cfm's will be sent to this Queue)
+ interfaceTag -
+ clientData -
+ mediaStatus -
+
+*******************************************************************************/
+#define CsrWifiRouterCtrlMediaStatusReqCreate(msg__, dst__, src__, interfaceTag__, clientData__, mediaStatus__) \
+ msg__ = kmalloc(sizeof(CsrWifiRouterCtrlMediaStatusReq), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_MEDIA_STATUS_REQ, dst__, src__); \
+ msg__->interfaceTag = (interfaceTag__); \
+ msg__->clientData = (clientData__); \
+ msg__->mediaStatus = (mediaStatus__);
+
+#define CsrWifiRouterCtrlMediaStatusReqSendTo(dst__, src__, interfaceTag__, clientData__, mediaStatus__) \
+ { \
+ CsrWifiRouterCtrlMediaStatusReq *msg__; \
+ CsrWifiRouterCtrlMediaStatusReqCreate(msg__, dst__, src__, interfaceTag__, clientData__, mediaStatus__); \
+ CsrMsgTransport(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
+ }
+
+#define CsrWifiRouterCtrlMediaStatusReqSend(src__, interfaceTag__, clientData__, mediaStatus__) \
+ CsrWifiRouterCtrlMediaStatusReqSendTo(CSR_WIFI_ROUTER_IFACEQUEUE, src__, interfaceTag__, clientData__, mediaStatus__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiRouterCtrlMicFailureIndSend
+
+ DESCRIPTION
+
+ PARAMETERS
+ queue - Destination Task Queue
+ clientData -
+ interfaceTag -
+ peerMacAddress -
+ unicastPdu -
+
+*******************************************************************************/
+#define CsrWifiRouterCtrlMicFailureIndCreate(msg__, dst__, src__, clientData__, interfaceTag__, peerMacAddress__, unicastPdu__) \
+ msg__ = kmalloc(sizeof(CsrWifiRouterCtrlMicFailureInd), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_MIC_FAILURE_IND, dst__, src__); \
+ msg__->clientData = (clientData__); \
+ msg__->interfaceTag = (interfaceTag__); \
+ msg__->peerMacAddress = (peerMacAddress__); \
+ msg__->unicastPdu = (unicastPdu__);
+
+#define CsrWifiRouterCtrlMicFailureIndSendTo(dst__, src__, clientData__, interfaceTag__, peerMacAddress__, unicastPdu__) \
+ { \
+ CsrWifiRouterCtrlMicFailureInd *msg__; \
+ CsrWifiRouterCtrlMicFailureIndCreate(msg__, dst__, src__, clientData__, interfaceTag__, peerMacAddress__, unicastPdu__); \
+ CsrSchedMessagePut(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
+ }
+
+#define CsrWifiRouterCtrlMicFailureIndSend(dst__, clientData__, interfaceTag__, peerMacAddress__, unicastPdu__) \
+ CsrWifiRouterCtrlMicFailureIndSendTo(dst__, CSR_WIFI_ROUTER_IFACEQUEUE, clientData__, interfaceTag__, peerMacAddress__, unicastPdu__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiRouterCtrlModeSetReqSend
+
+ DESCRIPTION
+
+ PARAMETERS
+ queue - Message Source Task Queue (Cfm's will be sent to this Queue)
+ interfaceTag -
+ clientData -
+ mode -
+ bssid - BSSID of the network the device is going to be a part
+ of
+ protection - Set to TRUE if encryption is enabled for the
+ connection/broadcast frames
+ intraBssDistEnabled - If set to TRUE, intra BSS destribution will be
+ enabled. If set to FALSE, any unicast PDU which does
+ not have the RA as the the local MAC address, shall be
+ ignored. This field is interpreted by the receive if
+ mode is set to CSR_WIFI_ROUTER_CTRL_MODE_P2PGO
+
+*******************************************************************************/
+#define CsrWifiRouterCtrlModeSetReqCreate(msg__, dst__, src__, interfaceTag__, clientData__, mode__, bssid__, protection__, intraBssDistEnabled__) \
+ msg__ = kmalloc(sizeof(CsrWifiRouterCtrlModeSetReq), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_MODE_SET_REQ, dst__, src__); \
+ msg__->interfaceTag = (interfaceTag__); \
+ msg__->clientData = (clientData__); \
+ msg__->mode = (mode__); \
+ msg__->bssid = (bssid__); \
+ msg__->protection = (protection__); \
+ msg__->intraBssDistEnabled = (intraBssDistEnabled__);
+
+#define CsrWifiRouterCtrlModeSetReqSendTo(dst__, src__, interfaceTag__, clientData__, mode__, bssid__, protection__, intraBssDistEnabled__) \
+ { \
+ CsrWifiRouterCtrlModeSetReq *msg__; \
+ CsrWifiRouterCtrlModeSetReqCreate(msg__, dst__, src__, interfaceTag__, clientData__, mode__, bssid__, protection__, intraBssDistEnabled__); \
+ CsrMsgTransport(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
+ }
+
+#define CsrWifiRouterCtrlModeSetReqSend(src__, interfaceTag__, clientData__, mode__, bssid__, protection__, intraBssDistEnabled__) \
+ CsrWifiRouterCtrlModeSetReqSendTo(CSR_WIFI_ROUTER_IFACEQUEUE, src__, interfaceTag__, clientData__, mode__, bssid__, protection__, intraBssDistEnabled__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiRouterCtrlModeSetCfmSend
+
+ DESCRIPTION
+
+ PARAMETERS
+ queue - Destination Task Queue
+ clientData -
+ interfaceTag -
+ mode -
+ status -
+
+*******************************************************************************/
+#define CsrWifiRouterCtrlModeSetCfmCreate(msg__, dst__, src__, clientData__, interfaceTag__, mode__, status__) \
+ msg__ = kmalloc(sizeof(CsrWifiRouterCtrlModeSetCfm), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_MODE_SET_CFM, dst__, src__); \
+ msg__->clientData = (clientData__); \
+ msg__->interfaceTag = (interfaceTag__); \
+ msg__->mode = (mode__); \
+ msg__->status = (status__);
+
+#define CsrWifiRouterCtrlModeSetCfmSendTo(dst__, src__, clientData__, interfaceTag__, mode__, status__) \
+ { \
+ CsrWifiRouterCtrlModeSetCfm *msg__; \
+ CsrWifiRouterCtrlModeSetCfmCreate(msg__, dst__, src__, clientData__, interfaceTag__, mode__, status__); \
+ CsrSchedMessagePut(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
+ }
+
+#define CsrWifiRouterCtrlModeSetCfmSend(dst__, clientData__, interfaceTag__, mode__, status__) \
+ CsrWifiRouterCtrlModeSetCfmSendTo(dst__, CSR_WIFI_ROUTER_IFACEQUEUE, clientData__, interfaceTag__, mode__, status__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiRouterCtrlMulticastAddressIndSend
+
+ DESCRIPTION
+
+ PARAMETERS
+ queue - Destination Task Queue
+ clientData -
+ interfaceTag -
+ action -
+ setAddressesCount -
+ setAddresses -
+
+*******************************************************************************/
+#define CsrWifiRouterCtrlMulticastAddressIndCreate(msg__, dst__, src__, clientData__, interfaceTag__, action__, setAddressesCount__, setAddresses__) \
+ msg__ = kmalloc(sizeof(CsrWifiRouterCtrlMulticastAddressInd), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_MULTICAST_ADDRESS_IND, dst__, src__); \
+ msg__->clientData = (clientData__); \
+ msg__->interfaceTag = (interfaceTag__); \
+ msg__->action = (action__); \
+ msg__->setAddressesCount = (setAddressesCount__); \
+ msg__->setAddresses = (setAddresses__);
+
+#define CsrWifiRouterCtrlMulticastAddressIndSendTo(dst__, src__, clientData__, interfaceTag__, action__, setAddressesCount__, setAddresses__) \
+ { \
+ CsrWifiRouterCtrlMulticastAddressInd *msg__; \
+ CsrWifiRouterCtrlMulticastAddressIndCreate(msg__, dst__, src__, clientData__, interfaceTag__, action__, setAddressesCount__, setAddresses__); \
+ CsrSchedMessagePut(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
+ }
+
+#define CsrWifiRouterCtrlMulticastAddressIndSend(dst__, clientData__, interfaceTag__, action__, setAddressesCount__, setAddresses__) \
+ CsrWifiRouterCtrlMulticastAddressIndSendTo(dst__, CSR_WIFI_ROUTER_IFACEQUEUE, clientData__, interfaceTag__, action__, setAddressesCount__, setAddresses__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiRouterCtrlMulticastAddressResSend
+
+ DESCRIPTION
+
+ PARAMETERS
+ interfaceTag -
+ clientData -
+ status -
+ action -
+ getAddressesCount -
+ getAddresses -
+
+*******************************************************************************/
+#define CsrWifiRouterCtrlMulticastAddressResCreate(msg__, dst__, src__, interfaceTag__, clientData__, status__, action__, getAddressesCount__, getAddresses__) \
+ msg__ = kmalloc(sizeof(CsrWifiRouterCtrlMulticastAddressRes), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_MULTICAST_ADDRESS_RES, dst__, src__); \
+ msg__->interfaceTag = (interfaceTag__); \
+ msg__->clientData = (clientData__); \
+ msg__->status = (status__); \
+ msg__->action = (action__); \
+ msg__->getAddressesCount = (getAddressesCount__); \
+ msg__->getAddresses = (getAddresses__);
+
+#define CsrWifiRouterCtrlMulticastAddressResSendTo(dst__, src__, interfaceTag__, clientData__, status__, action__, getAddressesCount__, getAddresses__) \
+ { \
+ CsrWifiRouterCtrlMulticastAddressRes *msg__; \
+ CsrWifiRouterCtrlMulticastAddressResCreate(msg__, dst__, src__, interfaceTag__, clientData__, status__, action__, getAddressesCount__, getAddresses__); \
+ CsrMsgTransport(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
+ }
+
+#define CsrWifiRouterCtrlMulticastAddressResSend(src__, interfaceTag__, clientData__, status__, action__, getAddressesCount__, getAddresses__) \
+ CsrWifiRouterCtrlMulticastAddressResSendTo(CSR_WIFI_ROUTER_IFACEQUEUE, src__, interfaceTag__, clientData__, status__, action__, getAddressesCount__, getAddresses__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiRouterCtrlPeerAddReqSend
+
+ DESCRIPTION
+
+ PARAMETERS
+ queue - Message Source Task Queue (Cfm's will be sent to this Queue)
+ interfaceTag -
+ clientData -
+ peerMacAddress -
+ associationId -
+ staInfo -
+
+*******************************************************************************/
+#define CsrWifiRouterCtrlPeerAddReqCreate(msg__, dst__, src__, interfaceTag__, clientData__, peerMacAddress__, associationId__, staInfo__) \
+ msg__ = kmalloc(sizeof(CsrWifiRouterCtrlPeerAddReq), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_PEER_ADD_REQ, dst__, src__); \
+ msg__->interfaceTag = (interfaceTag__); \
+ msg__->clientData = (clientData__); \
+ msg__->peerMacAddress = (peerMacAddress__); \
+ msg__->associationId = (associationId__); \
+ msg__->staInfo = (staInfo__);
+
+#define CsrWifiRouterCtrlPeerAddReqSendTo(dst__, src__, interfaceTag__, clientData__, peerMacAddress__, associationId__, staInfo__) \
+ { \
+ CsrWifiRouterCtrlPeerAddReq *msg__; \
+ CsrWifiRouterCtrlPeerAddReqCreate(msg__, dst__, src__, interfaceTag__, clientData__, peerMacAddress__, associationId__, staInfo__); \
+ CsrMsgTransport(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
+ }
+
+#define CsrWifiRouterCtrlPeerAddReqSend(src__, interfaceTag__, clientData__, peerMacAddress__, associationId__, staInfo__) \
+ CsrWifiRouterCtrlPeerAddReqSendTo(CSR_WIFI_ROUTER_IFACEQUEUE, src__, interfaceTag__, clientData__, peerMacAddress__, associationId__, staInfo__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiRouterCtrlPeerAddCfmSend
+
+ DESCRIPTION
+
+ PARAMETERS
+ queue - Destination Task Queue
+ clientData -
+ interfaceTag -
+ peerMacAddress -
+ peerRecordHandle -
+ status -
+
+*******************************************************************************/
+#define CsrWifiRouterCtrlPeerAddCfmCreate(msg__, dst__, src__, clientData__, interfaceTag__, peerMacAddress__, peerRecordHandle__, status__) \
+ msg__ = kmalloc(sizeof(CsrWifiRouterCtrlPeerAddCfm), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_PEER_ADD_CFM, dst__, src__); \
+ msg__->clientData = (clientData__); \
+ msg__->interfaceTag = (interfaceTag__); \
+ msg__->peerMacAddress = (peerMacAddress__); \
+ msg__->peerRecordHandle = (peerRecordHandle__); \
+ msg__->status = (status__);
+
+#define CsrWifiRouterCtrlPeerAddCfmSendTo(dst__, src__, clientData__, interfaceTag__, peerMacAddress__, peerRecordHandle__, status__) \
+ { \
+ CsrWifiRouterCtrlPeerAddCfm *msg__; \
+ CsrWifiRouterCtrlPeerAddCfmCreate(msg__, dst__, src__, clientData__, interfaceTag__, peerMacAddress__, peerRecordHandle__, status__); \
+ CsrSchedMessagePut(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
+ }
+
+#define CsrWifiRouterCtrlPeerAddCfmSend(dst__, clientData__, interfaceTag__, peerMacAddress__, peerRecordHandle__, status__) \
+ CsrWifiRouterCtrlPeerAddCfmSendTo(dst__, CSR_WIFI_ROUTER_IFACEQUEUE, clientData__, interfaceTag__, peerMacAddress__, peerRecordHandle__, status__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiRouterCtrlPeerDelReqSend
+
+ DESCRIPTION
+
+ PARAMETERS
+ queue - Message Source Task Queue (Cfm's will be sent to this Queue)
+ interfaceTag -
+ clientData -
+ peerRecordHandle -
+
+*******************************************************************************/
+#define CsrWifiRouterCtrlPeerDelReqCreate(msg__, dst__, src__, interfaceTag__, clientData__, peerRecordHandle__) \
+ msg__ = kmalloc(sizeof(CsrWifiRouterCtrlPeerDelReq), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_PEER_DEL_REQ, dst__, src__); \
+ msg__->interfaceTag = (interfaceTag__); \
+ msg__->clientData = (clientData__); \
+ msg__->peerRecordHandle = (peerRecordHandle__);
+
+#define CsrWifiRouterCtrlPeerDelReqSendTo(dst__, src__, interfaceTag__, clientData__, peerRecordHandle__) \
+ { \
+ CsrWifiRouterCtrlPeerDelReq *msg__; \
+ CsrWifiRouterCtrlPeerDelReqCreate(msg__, dst__, src__, interfaceTag__, clientData__, peerRecordHandle__); \
+ CsrMsgTransport(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
+ }
+
+#define CsrWifiRouterCtrlPeerDelReqSend(src__, interfaceTag__, clientData__, peerRecordHandle__) \
+ CsrWifiRouterCtrlPeerDelReqSendTo(CSR_WIFI_ROUTER_IFACEQUEUE, src__, interfaceTag__, clientData__, peerRecordHandle__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiRouterCtrlPeerDelCfmSend
+
+ DESCRIPTION
+
+ PARAMETERS
+ queue - Destination Task Queue
+ clientData -
+ interfaceTag -
+ status -
+
+*******************************************************************************/
+#define CsrWifiRouterCtrlPeerDelCfmCreate(msg__, dst__, src__, clientData__, interfaceTag__, status__) \
+ msg__ = kmalloc(sizeof(CsrWifiRouterCtrlPeerDelCfm), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_PEER_DEL_CFM, dst__, src__); \
+ msg__->clientData = (clientData__); \
+ msg__->interfaceTag = (interfaceTag__); \
+ msg__->status = (status__);
+
+#define CsrWifiRouterCtrlPeerDelCfmSendTo(dst__, src__, clientData__, interfaceTag__, status__) \
+ { \
+ CsrWifiRouterCtrlPeerDelCfm *msg__; \
+ CsrWifiRouterCtrlPeerDelCfmCreate(msg__, dst__, src__, clientData__, interfaceTag__, status__); \
+ CsrSchedMessagePut(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
+ }
+
+#define CsrWifiRouterCtrlPeerDelCfmSend(dst__, clientData__, interfaceTag__, status__) \
+ CsrWifiRouterCtrlPeerDelCfmSendTo(dst__, CSR_WIFI_ROUTER_IFACEQUEUE, clientData__, interfaceTag__, status__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiRouterCtrlPeerUpdateReqSend
+
+ DESCRIPTION
+
+ PARAMETERS
+ queue - Message Source Task Queue (Cfm's will be sent to this Queue)
+ interfaceTag -
+ clientData -
+ peerRecordHandle -
+ powersaveMode -
+
+*******************************************************************************/
+#define CsrWifiRouterCtrlPeerUpdateReqCreate(msg__, dst__, src__, interfaceTag__, clientData__, peerRecordHandle__, powersaveMode__) \
+ msg__ = kmalloc(sizeof(CsrWifiRouterCtrlPeerUpdateReq), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_PEER_UPDATE_REQ, dst__, src__); \
+ msg__->interfaceTag = (interfaceTag__); \
+ msg__->clientData = (clientData__); \
+ msg__->peerRecordHandle = (peerRecordHandle__); \
+ msg__->powersaveMode = (powersaveMode__);
+
+#define CsrWifiRouterCtrlPeerUpdateReqSendTo(dst__, src__, interfaceTag__, clientData__, peerRecordHandle__, powersaveMode__) \
+ { \
+ CsrWifiRouterCtrlPeerUpdateReq *msg__; \
+ CsrWifiRouterCtrlPeerUpdateReqCreate(msg__, dst__, src__, interfaceTag__, clientData__, peerRecordHandle__, powersaveMode__); \
+ CsrMsgTransport(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
+ }
+
+#define CsrWifiRouterCtrlPeerUpdateReqSend(src__, interfaceTag__, clientData__, peerRecordHandle__, powersaveMode__) \
+ CsrWifiRouterCtrlPeerUpdateReqSendTo(CSR_WIFI_ROUTER_IFACEQUEUE, src__, interfaceTag__, clientData__, peerRecordHandle__, powersaveMode__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiRouterCtrlPeerUpdateCfmSend
+
+ DESCRIPTION
+
+ PARAMETERS
+ queue - Destination Task Queue
+ clientData -
+ interfaceTag -
+ status -
+
+*******************************************************************************/
+#define CsrWifiRouterCtrlPeerUpdateCfmCreate(msg__, dst__, src__, clientData__, interfaceTag__, status__) \
+ msg__ = kmalloc(sizeof(CsrWifiRouterCtrlPeerUpdateCfm), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_PEER_UPDATE_CFM, dst__, src__); \
+ msg__->clientData = (clientData__); \
+ msg__->interfaceTag = (interfaceTag__); \
+ msg__->status = (status__);
+
+#define CsrWifiRouterCtrlPeerUpdateCfmSendTo(dst__, src__, clientData__, interfaceTag__, status__) \
+ { \
+ CsrWifiRouterCtrlPeerUpdateCfm *msg__; \
+ CsrWifiRouterCtrlPeerUpdateCfmCreate(msg__, dst__, src__, clientData__, interfaceTag__, status__); \
+ CsrSchedMessagePut(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
+ }
+
+#define CsrWifiRouterCtrlPeerUpdateCfmSend(dst__, clientData__, interfaceTag__, status__) \
+ CsrWifiRouterCtrlPeerUpdateCfmSendTo(dst__, CSR_WIFI_ROUTER_IFACEQUEUE, clientData__, interfaceTag__, status__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiRouterCtrlPortConfigureReqSend
+
+ DESCRIPTION
+
+ PARAMETERS
+ queue - Message Source Task Queue (Cfm's will be sent to this Queue)
+ interfaceTag -
+ clientData -
+ uncontrolledPortAction -
+ controlledPortAction -
+ macAddress -
+ setProtection -
+
+*******************************************************************************/
+#define CsrWifiRouterCtrlPortConfigureReqCreate(msg__, dst__, src__, interfaceTag__, clientData__, uncontrolledPortAction__, controlledPortAction__, macAddress__, setProtection__) \
+ msg__ = kmalloc(sizeof(CsrWifiRouterCtrlPortConfigureReq), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_PORT_CONFIGURE_REQ, dst__, src__); \
+ msg__->interfaceTag = (interfaceTag__); \
+ msg__->clientData = (clientData__); \
+ msg__->uncontrolledPortAction = (uncontrolledPortAction__); \
+ msg__->controlledPortAction = (controlledPortAction__); \
+ msg__->macAddress = (macAddress__); \
+ msg__->setProtection = (setProtection__);
+
+#define CsrWifiRouterCtrlPortConfigureReqSendTo(dst__, src__, interfaceTag__, clientData__, uncontrolledPortAction__, controlledPortAction__, macAddress__, setProtection__) \
+ { \
+ CsrWifiRouterCtrlPortConfigureReq *msg__; \
+ CsrWifiRouterCtrlPortConfigureReqCreate(msg__, dst__, src__, interfaceTag__, clientData__, uncontrolledPortAction__, controlledPortAction__, macAddress__, setProtection__); \
+ CsrMsgTransport(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
+ }
+
+#define CsrWifiRouterCtrlPortConfigureReqSend(src__, interfaceTag__, clientData__, uncontrolledPortAction__, controlledPortAction__, macAddress__, setProtection__) \
+ CsrWifiRouterCtrlPortConfigureReqSendTo(CSR_WIFI_ROUTER_IFACEQUEUE, src__, interfaceTag__, clientData__, uncontrolledPortAction__, controlledPortAction__, macAddress__, setProtection__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiRouterCtrlPortConfigureCfmSend
+
+ DESCRIPTION
+
+ PARAMETERS
+ queue - Destination Task Queue
+ clientData -
+ interfaceTag -
+ status -
+ macAddress -
+
+*******************************************************************************/
+#define CsrWifiRouterCtrlPortConfigureCfmCreate(msg__, dst__, src__, clientData__, interfaceTag__, status__, macAddress__) \
+ msg__ = kmalloc(sizeof(CsrWifiRouterCtrlPortConfigureCfm), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_PORT_CONFIGURE_CFM, dst__, src__); \
+ msg__->clientData = (clientData__); \
+ msg__->interfaceTag = (interfaceTag__); \
+ msg__->status = (status__); \
+ msg__->macAddress = (macAddress__);
+
+#define CsrWifiRouterCtrlPortConfigureCfmSendTo(dst__, src__, clientData__, interfaceTag__, status__, macAddress__) \
+ { \
+ CsrWifiRouterCtrlPortConfigureCfm *msg__; \
+ CsrWifiRouterCtrlPortConfigureCfmCreate(msg__, dst__, src__, clientData__, interfaceTag__, status__, macAddress__); \
+ CsrSchedMessagePut(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
+ }
+
+#define CsrWifiRouterCtrlPortConfigureCfmSend(dst__, clientData__, interfaceTag__, status__, macAddress__) \
+ CsrWifiRouterCtrlPortConfigureCfmSendTo(dst__, CSR_WIFI_ROUTER_IFACEQUEUE, clientData__, interfaceTag__, status__, macAddress__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiRouterCtrlQosControlReqSend
+
+ DESCRIPTION
+
+ PARAMETERS
+ queue - Message Source Task Queue (Cfm's will be sent to this Queue)
+ interfaceTag -
+ clientData -
+ control -
+ queueConfig -
+
+*******************************************************************************/
+#define CsrWifiRouterCtrlQosControlReqCreate(msg__, dst__, src__, interfaceTag__, clientData__, control__, queueConfig__) \
+ msg__ = kmalloc(sizeof(CsrWifiRouterCtrlQosControlReq), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_QOS_CONTROL_REQ, dst__, src__); \
+ msg__->interfaceTag = (interfaceTag__); \
+ msg__->clientData = (clientData__); \
+ msg__->control = (control__); \
+ msg__->queueConfig = (queueConfig__);
+
+#define CsrWifiRouterCtrlQosControlReqSendTo(dst__, src__, interfaceTag__, clientData__, control__, queueConfig__) \
+ { \
+ CsrWifiRouterCtrlQosControlReq *msg__; \
+ CsrWifiRouterCtrlQosControlReqCreate(msg__, dst__, src__, interfaceTag__, clientData__, control__, queueConfig__); \
+ CsrMsgTransport(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
+ }
+
+#define CsrWifiRouterCtrlQosControlReqSend(src__, interfaceTag__, clientData__, control__, queueConfig__) \
+ CsrWifiRouterCtrlQosControlReqSendTo(CSR_WIFI_ROUTER_IFACEQUEUE, src__, interfaceTag__, clientData__, control__, queueConfig__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiRouterCtrlRawSdioDeinitialiseReqSend
+
+ DESCRIPTION
+
+ PARAMETERS
+ queue - Message Source Task Queue (Cfm's will be sent to this Queue)
+ clientData -
+
+*******************************************************************************/
+#define CsrWifiRouterCtrlRawSdioDeinitialiseReqCreate(msg__, dst__, src__, clientData__) \
+ msg__ = kmalloc(sizeof(CsrWifiRouterCtrlRawSdioDeinitialiseReq), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_RAW_SDIO_DEINITIALISE_REQ, dst__, src__); \
+ msg__->clientData = (clientData__);
+
+#define CsrWifiRouterCtrlRawSdioDeinitialiseReqSendTo(dst__, src__, clientData__) \
+ { \
+ CsrWifiRouterCtrlRawSdioDeinitialiseReq *msg__; \
+ CsrWifiRouterCtrlRawSdioDeinitialiseReqCreate(msg__, dst__, src__, clientData__); \
+ CsrMsgTransport(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
+ }
+
+#define CsrWifiRouterCtrlRawSdioDeinitialiseReqSend(src__, clientData__) \
+ CsrWifiRouterCtrlRawSdioDeinitialiseReqSendTo(CSR_WIFI_ROUTER_IFACEQUEUE, src__, clientData__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiRouterCtrlRawSdioDeinitialiseCfmSend
+
+ DESCRIPTION
+
+ PARAMETERS
+ queue - Destination Task Queue
+ clientData -
+ result -
+
+*******************************************************************************/
+#define CsrWifiRouterCtrlRawSdioDeinitialiseCfmCreate(msg__, dst__, src__, clientData__, result__) \
+ msg__ = kmalloc(sizeof(CsrWifiRouterCtrlRawSdioDeinitialiseCfm), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_RAW_SDIO_DEINITIALISE_CFM, dst__, src__); \
+ msg__->clientData = (clientData__); \
+ msg__->result = (result__);
+
+#define CsrWifiRouterCtrlRawSdioDeinitialiseCfmSendTo(dst__, src__, clientData__, result__) \
+ { \
+ CsrWifiRouterCtrlRawSdioDeinitialiseCfm *msg__; \
+ CsrWifiRouterCtrlRawSdioDeinitialiseCfmCreate(msg__, dst__, src__, clientData__, result__); \
+ CsrSchedMessagePut(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
+ }
+
+#define CsrWifiRouterCtrlRawSdioDeinitialiseCfmSend(dst__, clientData__, result__) \
+ CsrWifiRouterCtrlRawSdioDeinitialiseCfmSendTo(dst__, CSR_WIFI_ROUTER_IFACEQUEUE, clientData__, result__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiRouterCtrlRawSdioInitialiseReqSend
+
+ DESCRIPTION
+
+ PARAMETERS
+ queue - Message Source Task Queue (Cfm's will be sent to this Queue)
+ clientData -
+
+*******************************************************************************/
+#define CsrWifiRouterCtrlRawSdioInitialiseReqCreate(msg__, dst__, src__, clientData__) \
+ msg__ = kmalloc(sizeof(CsrWifiRouterCtrlRawSdioInitialiseReq), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_RAW_SDIO_INITIALISE_REQ, dst__, src__); \
+ msg__->clientData = (clientData__);
+
+#define CsrWifiRouterCtrlRawSdioInitialiseReqSendTo(dst__, src__, clientData__) \
+ { \
+ CsrWifiRouterCtrlRawSdioInitialiseReq *msg__; \
+ CsrWifiRouterCtrlRawSdioInitialiseReqCreate(msg__, dst__, src__, clientData__); \
+ CsrMsgTransport(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
+ }
+
+#define CsrWifiRouterCtrlRawSdioInitialiseReqSend(src__, clientData__) \
+ CsrWifiRouterCtrlRawSdioInitialiseReqSendTo(CSR_WIFI_ROUTER_IFACEQUEUE, src__, clientData__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiRouterCtrlRawSdioInitialiseCfmSend
+
+ DESCRIPTION
+
+ PARAMETERS
+ queue - Destination Task Queue
+ clientData -
+ result -
+ byteRead -
+ byteWrite -
+ firmwareDownload -
+ reset -
+ coreDumpPrepare -
+ byteBlockRead -
+ gpRead16 -
+ gpWrite16 -
+
+*******************************************************************************/
+#define CsrWifiRouterCtrlRawSdioInitialiseCfmCreate(msg__, dst__, src__, clientData__, result__, byteRead__, byteWrite__, firmwareDownload__, reset__, coreDumpPrepare__, byteBlockRead__, gpRead16__, gpWrite16__) \
+ msg__ = kmalloc(sizeof(CsrWifiRouterCtrlRawSdioInitialiseCfm), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_RAW_SDIO_INITIALISE_CFM, dst__, src__); \
+ msg__->clientData = (clientData__); \
+ msg__->result = (result__); \
+ msg__->byteRead = (byteRead__); \
+ msg__->byteWrite = (byteWrite__); \
+ msg__->firmwareDownload = (firmwareDownload__); \
+ msg__->reset = (reset__); \
+ msg__->coreDumpPrepare = (coreDumpPrepare__); \
+ msg__->byteBlockRead = (byteBlockRead__); \
+ msg__->gpRead16 = (gpRead16__); \
+ msg__->gpWrite16 = (gpWrite16__);
+
+#define CsrWifiRouterCtrlRawSdioInitialiseCfmSendTo(dst__, src__, clientData__, result__, byteRead__, byteWrite__, firmwareDownload__, reset__, coreDumpPrepare__, byteBlockRead__, gpRead16__, gpWrite16__) \
+ { \
+ CsrWifiRouterCtrlRawSdioInitialiseCfm *msg__; \
+ CsrWifiRouterCtrlRawSdioInitialiseCfmCreate(msg__, dst__, src__, clientData__, result__, byteRead__, byteWrite__, firmwareDownload__, reset__, coreDumpPrepare__, byteBlockRead__, gpRead16__, gpWrite16__); \
+ CsrSchedMessagePut(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
+ }
+
+#define CsrWifiRouterCtrlRawSdioInitialiseCfmSend(dst__, clientData__, result__, byteRead__, byteWrite__, firmwareDownload__, reset__, coreDumpPrepare__, byteBlockRead__, gpRead16__, gpWrite16__) \
+ CsrWifiRouterCtrlRawSdioInitialiseCfmSendTo(dst__, CSR_WIFI_ROUTER_IFACEQUEUE, clientData__, result__, byteRead__, byteWrite__, firmwareDownload__, reset__, coreDumpPrepare__, byteBlockRead__, gpRead16__, gpWrite16__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiRouterCtrlResumeIndSend
+
+ DESCRIPTION
+
+ PARAMETERS
+ queue - Destination Task Queue
+ clientData -
+ powerMaintained -
+
+*******************************************************************************/
+#define CsrWifiRouterCtrlResumeIndCreate(msg__, dst__, src__, clientData__, powerMaintained__) \
+ msg__ = kmalloc(sizeof(CsrWifiRouterCtrlResumeInd), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_RESUME_IND, dst__, src__); \
+ msg__->clientData = (clientData__); \
+ msg__->powerMaintained = (powerMaintained__);
+
+#define CsrWifiRouterCtrlResumeIndSendTo(dst__, src__, clientData__, powerMaintained__) \
+ { \
+ CsrWifiRouterCtrlResumeInd *msg__; \
+ CsrWifiRouterCtrlResumeIndCreate(msg__, dst__, src__, clientData__, powerMaintained__); \
+ CsrSchedMessagePut(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
+ }
+
+#define CsrWifiRouterCtrlResumeIndSend(dst__, clientData__, powerMaintained__) \
+ CsrWifiRouterCtrlResumeIndSendTo(dst__, CSR_WIFI_ROUTER_IFACEQUEUE, clientData__, powerMaintained__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiRouterCtrlResumeResSend
+
+ DESCRIPTION
+
+ PARAMETERS
+ clientData -
+ status -
+
+*******************************************************************************/
+#define CsrWifiRouterCtrlResumeResCreate(msg__, dst__, src__, clientData__, status__) \
+ msg__ = kmalloc(sizeof(CsrWifiRouterCtrlResumeRes), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_RESUME_RES, dst__, src__); \
+ msg__->clientData = (clientData__); \
+ msg__->status = (status__);
+
+#define CsrWifiRouterCtrlResumeResSendTo(dst__, src__, clientData__, status__) \
+ { \
+ CsrWifiRouterCtrlResumeRes *msg__; \
+ CsrWifiRouterCtrlResumeResCreate(msg__, dst__, src__, clientData__, status__); \
+ CsrMsgTransport(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
+ }
+
+#define CsrWifiRouterCtrlResumeResSend(src__, clientData__, status__) \
+ CsrWifiRouterCtrlResumeResSendTo(CSR_WIFI_ROUTER_IFACEQUEUE, src__, clientData__, status__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiRouterCtrlStaInactiveIndSend
+
+ DESCRIPTION
+
+ PARAMETERS
+ queue - Destination Task Queue
+ clientData -
+ interfaceTag -
+ staAddress -
+
+*******************************************************************************/
+#define CsrWifiRouterCtrlStaInactiveIndCreate(msg__, dst__, src__, clientData__, interfaceTag__, staAddress__) \
+ msg__ = kmalloc(sizeof(CsrWifiRouterCtrlStaInactiveInd), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_STA_INACTIVE_IND, dst__, src__); \
+ msg__->clientData = (clientData__); \
+ msg__->interfaceTag = (interfaceTag__); \
+ msg__->staAddress = (staAddress__);
+
+#define CsrWifiRouterCtrlStaInactiveIndSendTo(dst__, src__, clientData__, interfaceTag__, staAddress__) \
+ { \
+ CsrWifiRouterCtrlStaInactiveInd *msg__; \
+ CsrWifiRouterCtrlStaInactiveIndCreate(msg__, dst__, src__, clientData__, interfaceTag__, staAddress__); \
+ CsrSchedMessagePut(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
+ }
+
+#define CsrWifiRouterCtrlStaInactiveIndSend(dst__, clientData__, interfaceTag__, staAddress__) \
+ CsrWifiRouterCtrlStaInactiveIndSendTo(dst__, CSR_WIFI_ROUTER_IFACEQUEUE, clientData__, interfaceTag__, staAddress__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiRouterCtrlSuspendIndSend
+
+ DESCRIPTION
+
+ PARAMETERS
+ queue - Destination Task Queue
+ clientData -
+ hardSuspend -
+ d3Suspend -
+
+*******************************************************************************/
+#define CsrWifiRouterCtrlSuspendIndCreate(msg__, dst__, src__, clientData__, hardSuspend__, d3Suspend__) \
+ msg__ = kmalloc(sizeof(CsrWifiRouterCtrlSuspendInd), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_SUSPEND_IND, dst__, src__); \
+ msg__->clientData = (clientData__); \
+ msg__->hardSuspend = (hardSuspend__); \
+ msg__->d3Suspend = (d3Suspend__);
+
+#define CsrWifiRouterCtrlSuspendIndSendTo(dst__, src__, clientData__, hardSuspend__, d3Suspend__) \
+ { \
+ CsrWifiRouterCtrlSuspendInd *msg__; \
+ CsrWifiRouterCtrlSuspendIndCreate(msg__, dst__, src__, clientData__, hardSuspend__, d3Suspend__); \
+ CsrSchedMessagePut(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
+ }
+
+#define CsrWifiRouterCtrlSuspendIndSend(dst__, clientData__, hardSuspend__, d3Suspend__) \
+ CsrWifiRouterCtrlSuspendIndSendTo(dst__, CSR_WIFI_ROUTER_IFACEQUEUE, clientData__, hardSuspend__, d3Suspend__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiRouterCtrlSuspendResSend
+
+ DESCRIPTION
+
+ PARAMETERS
+ clientData -
+ status -
+
+*******************************************************************************/
+#define CsrWifiRouterCtrlSuspendResCreate(msg__, dst__, src__, clientData__, status__) \
+ msg__ = kmalloc(sizeof(CsrWifiRouterCtrlSuspendRes), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_SUSPEND_RES, dst__, src__); \
+ msg__->clientData = (clientData__); \
+ msg__->status = (status__);
+
+#define CsrWifiRouterCtrlSuspendResSendTo(dst__, src__, clientData__, status__) \
+ { \
+ CsrWifiRouterCtrlSuspendRes *msg__; \
+ CsrWifiRouterCtrlSuspendResCreate(msg__, dst__, src__, clientData__, status__); \
+ CsrMsgTransport(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
+ }
+
+#define CsrWifiRouterCtrlSuspendResSend(src__, clientData__, status__) \
+ CsrWifiRouterCtrlSuspendResSendTo(CSR_WIFI_ROUTER_IFACEQUEUE, src__, clientData__, status__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiRouterCtrlTclasAddReqSend
+
+ DESCRIPTION
+
+ PARAMETERS
+ queue - Message Source Task Queue (Cfm's will be sent to this Queue)
+ interfaceTag -
+ clientData -
+ tclasLength -
+ tclas -
+
+*******************************************************************************/
+#define CsrWifiRouterCtrlTclasAddReqCreate(msg__, dst__, src__, interfaceTag__, clientData__, tclasLength__, tclas__) \
+ msg__ = kmalloc(sizeof(CsrWifiRouterCtrlTclasAddReq), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_TCLAS_ADD_REQ, dst__, src__); \
+ msg__->interfaceTag = (interfaceTag__); \
+ msg__->clientData = (clientData__); \
+ msg__->tclasLength = (tclasLength__); \
+ msg__->tclas = (tclas__);
+
+#define CsrWifiRouterCtrlTclasAddReqSendTo(dst__, src__, interfaceTag__, clientData__, tclasLength__, tclas__) \
+ { \
+ CsrWifiRouterCtrlTclasAddReq *msg__; \
+ CsrWifiRouterCtrlTclasAddReqCreate(msg__, dst__, src__, interfaceTag__, clientData__, tclasLength__, tclas__); \
+ CsrMsgTransport(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
+ }
+
+#define CsrWifiRouterCtrlTclasAddReqSend(src__, interfaceTag__, clientData__, tclasLength__, tclas__) \
+ CsrWifiRouterCtrlTclasAddReqSendTo(CSR_WIFI_ROUTER_IFACEQUEUE, src__, interfaceTag__, clientData__, tclasLength__, tclas__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiRouterCtrlTclasAddCfmSend
+
+ DESCRIPTION
+
+ PARAMETERS
+ queue - Destination Task Queue
+ clientData -
+ interfaceTag -
+ status -
+
+*******************************************************************************/
+#define CsrWifiRouterCtrlTclasAddCfmCreate(msg__, dst__, src__, clientData__, interfaceTag__, status__) \
+ msg__ = kmalloc(sizeof(CsrWifiRouterCtrlTclasAddCfm), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_TCLAS_ADD_CFM, dst__, src__); \
+ msg__->clientData = (clientData__); \
+ msg__->interfaceTag = (interfaceTag__); \
+ msg__->status = (status__);
+
+#define CsrWifiRouterCtrlTclasAddCfmSendTo(dst__, src__, clientData__, interfaceTag__, status__) \
+ { \
+ CsrWifiRouterCtrlTclasAddCfm *msg__; \
+ CsrWifiRouterCtrlTclasAddCfmCreate(msg__, dst__, src__, clientData__, interfaceTag__, status__); \
+ CsrSchedMessagePut(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
+ }
+
+#define CsrWifiRouterCtrlTclasAddCfmSend(dst__, clientData__, interfaceTag__, status__) \
+ CsrWifiRouterCtrlTclasAddCfmSendTo(dst__, CSR_WIFI_ROUTER_IFACEQUEUE, clientData__, interfaceTag__, status__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiRouterCtrlTclasDelReqSend
+
+ DESCRIPTION
+
+ PARAMETERS
+ queue - Message Source Task Queue (Cfm's will be sent to this Queue)
+ interfaceTag -
+ clientData -
+ tclasLength -
+ tclas -
+
+*******************************************************************************/
+#define CsrWifiRouterCtrlTclasDelReqCreate(msg__, dst__, src__, interfaceTag__, clientData__, tclasLength__, tclas__) \
+ msg__ = kmalloc(sizeof(CsrWifiRouterCtrlTclasDelReq), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_TCLAS_DEL_REQ, dst__, src__); \
+ msg__->interfaceTag = (interfaceTag__); \
+ msg__->clientData = (clientData__); \
+ msg__->tclasLength = (tclasLength__); \
+ msg__->tclas = (tclas__);
+
+#define CsrWifiRouterCtrlTclasDelReqSendTo(dst__, src__, interfaceTag__, clientData__, tclasLength__, tclas__) \
+ { \
+ CsrWifiRouterCtrlTclasDelReq *msg__; \
+ CsrWifiRouterCtrlTclasDelReqCreate(msg__, dst__, src__, interfaceTag__, clientData__, tclasLength__, tclas__); \
+ CsrMsgTransport(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
+ }
+
+#define CsrWifiRouterCtrlTclasDelReqSend(src__, interfaceTag__, clientData__, tclasLength__, tclas__) \
+ CsrWifiRouterCtrlTclasDelReqSendTo(CSR_WIFI_ROUTER_IFACEQUEUE, src__, interfaceTag__, clientData__, tclasLength__, tclas__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiRouterCtrlTclasDelCfmSend
+
+ DESCRIPTION
+
+ PARAMETERS
+ queue - Destination Task Queue
+ clientData -
+ interfaceTag -
+ status -
+
+*******************************************************************************/
+#define CsrWifiRouterCtrlTclasDelCfmCreate(msg__, dst__, src__, clientData__, interfaceTag__, status__) \
+ msg__ = kmalloc(sizeof(CsrWifiRouterCtrlTclasDelCfm), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_TCLAS_DEL_CFM, dst__, src__); \
+ msg__->clientData = (clientData__); \
+ msg__->interfaceTag = (interfaceTag__); \
+ msg__->status = (status__);
+
+#define CsrWifiRouterCtrlTclasDelCfmSendTo(dst__, src__, clientData__, interfaceTag__, status__) \
+ { \
+ CsrWifiRouterCtrlTclasDelCfm *msg__; \
+ CsrWifiRouterCtrlTclasDelCfmCreate(msg__, dst__, src__, clientData__, interfaceTag__, status__); \
+ CsrSchedMessagePut(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
+ }
+
+#define CsrWifiRouterCtrlTclasDelCfmSend(dst__, clientData__, interfaceTag__, status__) \
+ CsrWifiRouterCtrlTclasDelCfmSendTo(dst__, CSR_WIFI_ROUTER_IFACEQUEUE, clientData__, interfaceTag__, status__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiRouterCtrlTrafficClassificationReqSend
+
+ DESCRIPTION
+
+ PARAMETERS
+ queue - Message Source Task Queue (Cfm's will be sent to this Queue)
+ interfaceTag -
+ clientData -
+ trafficType -
+ period -
+
+*******************************************************************************/
+#define CsrWifiRouterCtrlTrafficClassificationReqCreate(msg__, dst__, src__, interfaceTag__, clientData__, trafficType__, period__) \
+ msg__ = kmalloc(sizeof(CsrWifiRouterCtrlTrafficClassificationReq), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_TRAFFIC_CLASSIFICATION_REQ, dst__, src__); \
+ msg__->interfaceTag = (interfaceTag__); \
+ msg__->clientData = (clientData__); \
+ msg__->trafficType = (trafficType__); \
+ msg__->period = (period__);
+
+#define CsrWifiRouterCtrlTrafficClassificationReqSendTo(dst__, src__, interfaceTag__, clientData__, trafficType__, period__) \
+ { \
+ CsrWifiRouterCtrlTrafficClassificationReq *msg__; \
+ CsrWifiRouterCtrlTrafficClassificationReqCreate(msg__, dst__, src__, interfaceTag__, clientData__, trafficType__, period__); \
+ CsrMsgTransport(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
+ }
+
+#define CsrWifiRouterCtrlTrafficClassificationReqSend(src__, interfaceTag__, clientData__, trafficType__, period__) \
+ CsrWifiRouterCtrlTrafficClassificationReqSendTo(CSR_WIFI_ROUTER_IFACEQUEUE, src__, interfaceTag__, clientData__, trafficType__, period__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiRouterCtrlTrafficConfigReqSend
+
+ DESCRIPTION
+
+ PARAMETERS
+ queue - Message Source Task Queue (Cfm's will be sent to this Queue)
+ interfaceTag -
+ clientData -
+ trafficConfigType -
+ config -
+
+*******************************************************************************/
+#define CsrWifiRouterCtrlTrafficConfigReqCreate(msg__, dst__, src__, interfaceTag__, clientData__, trafficConfigType__, config__) \
+ msg__ = kmalloc(sizeof(CsrWifiRouterCtrlTrafficConfigReq), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_TRAFFIC_CONFIG_REQ, dst__, src__); \
+ msg__->interfaceTag = (interfaceTag__); \
+ msg__->clientData = (clientData__); \
+ msg__->trafficConfigType = (trafficConfigType__); \
+ msg__->config = (config__);
+
+#define CsrWifiRouterCtrlTrafficConfigReqSendTo(dst__, src__, interfaceTag__, clientData__, trafficConfigType__, config__) \
+ { \
+ CsrWifiRouterCtrlTrafficConfigReq *msg__; \
+ CsrWifiRouterCtrlTrafficConfigReqCreate(msg__, dst__, src__, interfaceTag__, clientData__, trafficConfigType__, config__); \
+ CsrMsgTransport(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
+ }
+
+#define CsrWifiRouterCtrlTrafficConfigReqSend(src__, interfaceTag__, clientData__, trafficConfigType__, config__) \
+ CsrWifiRouterCtrlTrafficConfigReqSendTo(CSR_WIFI_ROUTER_IFACEQUEUE, src__, interfaceTag__, clientData__, trafficConfigType__, config__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiRouterCtrlTrafficProtocolIndSend
+
+ DESCRIPTION
+
+ PARAMETERS
+ queue - Destination Task Queue
+ clientData -
+ interfaceTag -
+ packetType -
+ direction -
+ srcAddress -
+
+*******************************************************************************/
+#define CsrWifiRouterCtrlTrafficProtocolIndCreate(msg__, dst__, src__, clientData__, interfaceTag__, packetType__, direction__, srcAddress__) \
+ msg__ = kmalloc(sizeof(CsrWifiRouterCtrlTrafficProtocolInd), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_TRAFFIC_PROTOCOL_IND, dst__, src__); \
+ msg__->clientData = (clientData__); \
+ msg__->interfaceTag = (interfaceTag__); \
+ msg__->packetType = (packetType__); \
+ msg__->direction = (direction__); \
+ msg__->srcAddress = (srcAddress__);
+
+#define CsrWifiRouterCtrlTrafficProtocolIndSendTo(dst__, src__, clientData__, interfaceTag__, packetType__, direction__, srcAddress__) \
+ { \
+ CsrWifiRouterCtrlTrafficProtocolInd *msg__; \
+ CsrWifiRouterCtrlTrafficProtocolIndCreate(msg__, dst__, src__, clientData__, interfaceTag__, packetType__, direction__, srcAddress__); \
+ CsrSchedMessagePut(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
+ }
+
+#define CsrWifiRouterCtrlTrafficProtocolIndSend(dst__, clientData__, interfaceTag__, packetType__, direction__, srcAddress__) \
+ CsrWifiRouterCtrlTrafficProtocolIndSendTo(dst__, CSR_WIFI_ROUTER_IFACEQUEUE, clientData__, interfaceTag__, packetType__, direction__, srcAddress__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiRouterCtrlTrafficSampleIndSend
+
+ DESCRIPTION
+
+ PARAMETERS
+ queue - Destination Task Queue
+ clientData -
+ interfaceTag -
+ stats -
+
+*******************************************************************************/
+#define CsrWifiRouterCtrlTrafficSampleIndCreate(msg__, dst__, src__, clientData__, interfaceTag__, stats__) \
+ msg__ = kmalloc(sizeof(CsrWifiRouterCtrlTrafficSampleInd), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_TRAFFIC_SAMPLE_IND, dst__, src__); \
+ msg__->clientData = (clientData__); \
+ msg__->interfaceTag = (interfaceTag__); \
+ msg__->stats = (stats__);
+
+#define CsrWifiRouterCtrlTrafficSampleIndSendTo(dst__, src__, clientData__, interfaceTag__, stats__) \
+ { \
+ CsrWifiRouterCtrlTrafficSampleInd *msg__; \
+ CsrWifiRouterCtrlTrafficSampleIndCreate(msg__, dst__, src__, clientData__, interfaceTag__, stats__); \
+ CsrSchedMessagePut(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
+ }
+
+#define CsrWifiRouterCtrlTrafficSampleIndSend(dst__, clientData__, interfaceTag__, stats__) \
+ CsrWifiRouterCtrlTrafficSampleIndSendTo(dst__, CSR_WIFI_ROUTER_IFACEQUEUE, clientData__, interfaceTag__, stats__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiRouterCtrlUnexpectedFrameIndSend
+
+ DESCRIPTION
+
+ PARAMETERS
+ queue - Destination Task Queue
+ clientData -
+ interfaceTag -
+ peerMacAddress -
+
+*******************************************************************************/
+#define CsrWifiRouterCtrlUnexpectedFrameIndCreate(msg__, dst__, src__, clientData__, interfaceTag__, peerMacAddress__) \
+ msg__ = kmalloc(sizeof(CsrWifiRouterCtrlUnexpectedFrameInd), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_UNEXPECTED_FRAME_IND, dst__, src__); \
+ msg__->clientData = (clientData__); \
+ msg__->interfaceTag = (interfaceTag__); \
+ msg__->peerMacAddress = (peerMacAddress__);
+
+#define CsrWifiRouterCtrlUnexpectedFrameIndSendTo(dst__, src__, clientData__, interfaceTag__, peerMacAddress__) \
+ { \
+ CsrWifiRouterCtrlUnexpectedFrameInd *msg__; \
+ CsrWifiRouterCtrlUnexpectedFrameIndCreate(msg__, dst__, src__, clientData__, interfaceTag__, peerMacAddress__); \
+ CsrSchedMessagePut(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
+ }
+
+#define CsrWifiRouterCtrlUnexpectedFrameIndSend(dst__, clientData__, interfaceTag__, peerMacAddress__) \
+ CsrWifiRouterCtrlUnexpectedFrameIndSendTo(dst__, CSR_WIFI_ROUTER_IFACEQUEUE, clientData__, interfaceTag__, peerMacAddress__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiRouterCtrlWapiFilterReqSend
+
+ DESCRIPTION
+
+ PARAMETERS
+ queue - Message Source Task Queue (Cfm's will be sent to this Queue)
+ interfaceTag -
+ isWapiConnected -
+
+*******************************************************************************/
+#define CsrWifiRouterCtrlWapiFilterReqCreate(msg__, dst__, src__, interfaceTag__, isWapiConnected__) \
+ msg__ = kmalloc(sizeof(CsrWifiRouterCtrlWapiFilterReq), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_WAPI_FILTER_REQ, dst__, src__); \
+ msg__->interfaceTag = (interfaceTag__); \
+ msg__->isWapiConnected = (isWapiConnected__);
+
+#define CsrWifiRouterCtrlWapiFilterReqSendTo(dst__, src__, interfaceTag__, isWapiConnected__) \
+ { \
+ CsrWifiRouterCtrlWapiFilterReq *msg__; \
+ CsrWifiRouterCtrlWapiFilterReqCreate(msg__, dst__, src__, interfaceTag__, isWapiConnected__); \
+ CsrMsgTransport(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
+ }
+
+#define CsrWifiRouterCtrlWapiFilterReqSend(src__, interfaceTag__, isWapiConnected__) \
+ CsrWifiRouterCtrlWapiFilterReqSendTo(CSR_WIFI_ROUTER_IFACEQUEUE, src__, interfaceTag__, isWapiConnected__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiRouterCtrlWapiMulticastFilterReqSend
+
+ DESCRIPTION
+
+ PARAMETERS
+ queue - Message Source Task Queue (Cfm's will be sent to this Queue)
+ interfaceTag -
+ status -
+
+*******************************************************************************/
+#define CsrWifiRouterCtrlWapiMulticastFilterReqCreate(msg__, dst__, src__, interfaceTag__, status__) \
+ msg__ = kmalloc(sizeof(CsrWifiRouterCtrlWapiMulticastFilterReq), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_WAPI_MULTICAST_FILTER_REQ, dst__, src__); \
+ msg__->interfaceTag = (interfaceTag__); \
+ msg__->status = (status__);
+
+#define CsrWifiRouterCtrlWapiMulticastFilterReqSendTo(dst__, src__, interfaceTag__, status__) \
+ { \
+ CsrWifiRouterCtrlWapiMulticastFilterReq *msg__; \
+ CsrWifiRouterCtrlWapiMulticastFilterReqCreate(msg__, dst__, src__, interfaceTag__, status__); \
+ CsrMsgTransport(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
+ }
+
+#define CsrWifiRouterCtrlWapiMulticastFilterReqSend(src__, interfaceTag__, status__) \
+ CsrWifiRouterCtrlWapiMulticastFilterReqSendTo(CSR_WIFI_ROUTER_IFACEQUEUE, src__, interfaceTag__, status__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiRouterCtrlWapiRxMicCheckIndSend
+
+ DESCRIPTION
+
+ PARAMETERS
+ queue - Destination Task Queue
+ clientData -
+ interfaceTag -
+ signalLength -
+ signal -
+ dataLength -
+ data -
+
+*******************************************************************************/
+#define CsrWifiRouterCtrlWapiRxMicCheckIndCreate(msg__, dst__, src__, clientData__, interfaceTag__, signalLength__, signal__, dataLength__, data__) \
+ msg__ = kmalloc(sizeof(CsrWifiRouterCtrlWapiRxMicCheckInd), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_WAPI_RX_MIC_CHECK_IND, dst__, src__); \
+ msg__->clientData = (clientData__); \
+ msg__->interfaceTag = (interfaceTag__); \
+ msg__->signalLength = (signalLength__); \
+ msg__->signal = (signal__); \
+ msg__->dataLength = (dataLength__); \
+ msg__->data = (data__);
+
+#define CsrWifiRouterCtrlWapiRxMicCheckIndSendTo(dst__, src__, clientData__, interfaceTag__, signalLength__, signal__, dataLength__, data__) \
+ { \
+ CsrWifiRouterCtrlWapiRxMicCheckInd *msg__; \
+ CsrWifiRouterCtrlWapiRxMicCheckIndCreate(msg__, dst__, src__, clientData__, interfaceTag__, signalLength__, signal__, dataLength__, data__); \
+ CsrSchedMessagePut(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
+ }
+
+#define CsrWifiRouterCtrlWapiRxMicCheckIndSend(dst__, clientData__, interfaceTag__, signalLength__, signal__, dataLength__, data__) \
+ CsrWifiRouterCtrlWapiRxMicCheckIndSendTo(dst__, CSR_WIFI_ROUTER_IFACEQUEUE, clientData__, interfaceTag__, signalLength__, signal__, dataLength__, data__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiRouterCtrlWapiRxPktReqSend
+
+ DESCRIPTION
+
+ PARAMETERS
+ queue - Message Source Task Queue (Cfm's will be sent to this Queue)
+ interfaceTag -
+ signalLength -
+ signal -
+ dataLength -
+ data -
+
+*******************************************************************************/
+#define CsrWifiRouterCtrlWapiRxPktReqCreate(msg__, dst__, src__, interfaceTag__, signalLength__, signal__, dataLength__, data__) \
+ msg__ = kmalloc(sizeof(CsrWifiRouterCtrlWapiRxPktReq), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_WAPI_RX_PKT_REQ, dst__, src__); \
+ msg__->interfaceTag = (interfaceTag__); \
+ msg__->signalLength = (signalLength__); \
+ msg__->signal = (signal__); \
+ msg__->dataLength = (dataLength__); \
+ msg__->data = (data__);
+
+#define CsrWifiRouterCtrlWapiRxPktReqSendTo(dst__, src__, interfaceTag__, signalLength__, signal__, dataLength__, data__) \
+ { \
+ CsrWifiRouterCtrlWapiRxPktReq *msg__; \
+ CsrWifiRouterCtrlWapiRxPktReqCreate(msg__, dst__, src__, interfaceTag__, signalLength__, signal__, dataLength__, data__); \
+ CsrMsgTransport(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
+ }
+
+#define CsrWifiRouterCtrlWapiRxPktReqSend(src__, interfaceTag__, signalLength__, signal__, dataLength__, data__) \
+ CsrWifiRouterCtrlWapiRxPktReqSendTo(CSR_WIFI_ROUTER_IFACEQUEUE, src__, interfaceTag__, signalLength__, signal__, dataLength__, data__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiRouterCtrlWapiUnicastFilterReqSend
+
+ DESCRIPTION
+
+ PARAMETERS
+ queue - Message Source Task Queue (Cfm's will be sent to this Queue)
+ interfaceTag -
+ status -
+
+*******************************************************************************/
+#define CsrWifiRouterCtrlWapiUnicastFilterReqCreate(msg__, dst__, src__, interfaceTag__, status__) \
+ msg__ = kmalloc(sizeof(CsrWifiRouterCtrlWapiUnicastFilterReq), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_WAPI_UNICAST_FILTER_REQ, dst__, src__); \
+ msg__->interfaceTag = (interfaceTag__); \
+ msg__->status = (status__);
+
+#define CsrWifiRouterCtrlWapiUnicastFilterReqSendTo(dst__, src__, interfaceTag__, status__) \
+ { \
+ CsrWifiRouterCtrlWapiUnicastFilterReq *msg__; \
+ CsrWifiRouterCtrlWapiUnicastFilterReqCreate(msg__, dst__, src__, interfaceTag__, status__); \
+ CsrMsgTransport(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
+ }
+
+#define CsrWifiRouterCtrlWapiUnicastFilterReqSend(src__, interfaceTag__, status__) \
+ CsrWifiRouterCtrlWapiUnicastFilterReqSendTo(CSR_WIFI_ROUTER_IFACEQUEUE, src__, interfaceTag__, status__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiRouterCtrlWapiUnicastTxEncryptIndSend
+
+ DESCRIPTION
+
+ PARAMETERS
+ queue - Destination Task Queue
+ clientData -
+ interfaceTag -
+ dataLength -
+ data -
+
+*******************************************************************************/
+#define CsrWifiRouterCtrlWapiUnicastTxEncryptIndCreate(msg__, dst__, src__, clientData__, interfaceTag__, dataLength__, data__) \
+ msg__ = kmalloc(sizeof(CsrWifiRouterCtrlWapiUnicastTxEncryptInd), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_WAPI_UNICAST_TX_ENCRYPT_IND, dst__, src__); \
+ msg__->clientData = (clientData__); \
+ msg__->interfaceTag = (interfaceTag__); \
+ msg__->dataLength = (dataLength__); \
+ msg__->data = (data__);
+
+#define CsrWifiRouterCtrlWapiUnicastTxEncryptIndSendTo(dst__, src__, clientData__, interfaceTag__, dataLength__, data__) \
+ { \
+ CsrWifiRouterCtrlWapiUnicastTxEncryptInd *msg__; \
+ CsrWifiRouterCtrlWapiUnicastTxEncryptIndCreate(msg__, dst__, src__, clientData__, interfaceTag__, dataLength__, data__); \
+ CsrSchedMessagePut(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
+ }
+
+#define CsrWifiRouterCtrlWapiUnicastTxEncryptIndSend(dst__, clientData__, interfaceTag__, dataLength__, data__) \
+ CsrWifiRouterCtrlWapiUnicastTxEncryptIndSendTo(dst__, CSR_WIFI_ROUTER_IFACEQUEUE, clientData__, interfaceTag__, dataLength__, data__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiRouterCtrlWapiUnicastTxPktReqSend
+
+ DESCRIPTION
+
+ PARAMETERS
+ queue - Message Source Task Queue (Cfm's will be sent to this Queue)
+ interfaceTag -
+ dataLength -
+ data -
+
+*******************************************************************************/
+#define CsrWifiRouterCtrlWapiUnicastTxPktReqCreate(msg__, dst__, src__, interfaceTag__, dataLength__, data__) \
+ msg__ = kmalloc(sizeof(CsrWifiRouterCtrlWapiUnicastTxPktReq), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_WAPI_UNICAST_TX_PKT_REQ, dst__, src__); \
+ msg__->interfaceTag = (interfaceTag__); \
+ msg__->dataLength = (dataLength__); \
+ msg__->data = (data__);
+
+#define CsrWifiRouterCtrlWapiUnicastTxPktReqSendTo(dst__, src__, interfaceTag__, dataLength__, data__) \
+ { \
+ CsrWifiRouterCtrlWapiUnicastTxPktReq *msg__; \
+ CsrWifiRouterCtrlWapiUnicastTxPktReqCreate(msg__, dst__, src__, interfaceTag__, dataLength__, data__); \
+ CsrMsgTransport(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
+ }
+
+#define CsrWifiRouterCtrlWapiUnicastTxPktReqSend(src__, interfaceTag__, dataLength__, data__) \
+ CsrWifiRouterCtrlWapiUnicastTxPktReqSendTo(CSR_WIFI_ROUTER_IFACEQUEUE, src__, interfaceTag__, dataLength__, data__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiRouterCtrlWifiOffReqSend
+
+ DESCRIPTION
+
+ PARAMETERS
+ queue - Message Source Task Queue (Cfm's will be sent to this Queue)
+ clientData -
+
+*******************************************************************************/
+#define CsrWifiRouterCtrlWifiOffReqCreate(msg__, dst__, src__, clientData__) \
+ msg__ = kmalloc(sizeof(CsrWifiRouterCtrlWifiOffReq), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_WIFI_OFF_REQ, dst__, src__); \
+ msg__->clientData = (clientData__);
+
+#define CsrWifiRouterCtrlWifiOffReqSendTo(dst__, src__, clientData__) \
+ { \
+ CsrWifiRouterCtrlWifiOffReq *msg__; \
+ CsrWifiRouterCtrlWifiOffReqCreate(msg__, dst__, src__, clientData__); \
+ CsrMsgTransport(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
+ }
+
+#define CsrWifiRouterCtrlWifiOffReqSend(src__, clientData__) \
+ CsrWifiRouterCtrlWifiOffReqSendTo(CSR_WIFI_ROUTER_IFACEQUEUE, src__, clientData__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiRouterCtrlWifiOffIndSend
+
+ DESCRIPTION
+
+ PARAMETERS
+ queue - Destination Task Queue
+ clientData -
+ controlIndication -
+
+*******************************************************************************/
+#define CsrWifiRouterCtrlWifiOffIndCreate(msg__, dst__, src__, clientData__, controlIndication__) \
+ msg__ = kmalloc(sizeof(CsrWifiRouterCtrlWifiOffInd), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_WIFI_OFF_IND, dst__, src__); \
+ msg__->clientData = (clientData__); \
+ msg__->controlIndication = (controlIndication__);
+
+#define CsrWifiRouterCtrlWifiOffIndSendTo(dst__, src__, clientData__, controlIndication__) \
+ { \
+ CsrWifiRouterCtrlWifiOffInd *msg__; \
+ CsrWifiRouterCtrlWifiOffIndCreate(msg__, dst__, src__, clientData__, controlIndication__); \
+ CsrSchedMessagePut(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
+ }
+
+#define CsrWifiRouterCtrlWifiOffIndSend(dst__, clientData__, controlIndication__) \
+ CsrWifiRouterCtrlWifiOffIndSendTo(dst__, CSR_WIFI_ROUTER_IFACEQUEUE, clientData__, controlIndication__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiRouterCtrlWifiOffResSend
+
+ DESCRIPTION
+
+ PARAMETERS
+ clientData -
+
+*******************************************************************************/
+#define CsrWifiRouterCtrlWifiOffResCreate(msg__, dst__, src__, clientData__) \
+ msg__ = kmalloc(sizeof(CsrWifiRouterCtrlWifiOffRes), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_WIFI_OFF_RES, dst__, src__); \
+ msg__->clientData = (clientData__);
+
+#define CsrWifiRouterCtrlWifiOffResSendTo(dst__, src__, clientData__) \
+ { \
+ CsrWifiRouterCtrlWifiOffRes *msg__; \
+ CsrWifiRouterCtrlWifiOffResCreate(msg__, dst__, src__, clientData__); \
+ CsrMsgTransport(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
+ }
+
+#define CsrWifiRouterCtrlWifiOffResSend(src__, clientData__) \
+ CsrWifiRouterCtrlWifiOffResSendTo(CSR_WIFI_ROUTER_IFACEQUEUE, src__, clientData__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiRouterCtrlWifiOffCfmSend
+
+ DESCRIPTION
+
+ PARAMETERS
+ queue - Destination Task Queue
+ clientData -
+
+*******************************************************************************/
+#define CsrWifiRouterCtrlWifiOffCfmCreate(msg__, dst__, src__, clientData__) \
+ msg__ = kmalloc(sizeof(CsrWifiRouterCtrlWifiOffCfm), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_WIFI_OFF_CFM, dst__, src__); \
+ msg__->clientData = (clientData__);
+
+#define CsrWifiRouterCtrlWifiOffCfmSendTo(dst__, src__, clientData__) \
+ { \
+ CsrWifiRouterCtrlWifiOffCfm *msg__; \
+ CsrWifiRouterCtrlWifiOffCfmCreate(msg__, dst__, src__, clientData__); \
+ CsrSchedMessagePut(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
+ }
+
+#define CsrWifiRouterCtrlWifiOffCfmSend(dst__, clientData__) \
+ CsrWifiRouterCtrlWifiOffCfmSendTo(dst__, CSR_WIFI_ROUTER_IFACEQUEUE, clientData__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiRouterCtrlWifiOnReqSend
+
+ DESCRIPTION
+
+ PARAMETERS
+ queue - Message Source Task Queue (Cfm's will be sent to this Queue)
+ clientData -
+ dataLength - Number of bytes in the buffer pointed to by 'data'
+ data - Pointer to the buffer containing 'dataLength' bytes
+
+*******************************************************************************/
+#define CsrWifiRouterCtrlWifiOnReqCreate(msg__, dst__, src__, clientData__, dataLength__, data__) \
+ msg__ = kmalloc(sizeof(CsrWifiRouterCtrlWifiOnReq), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_WIFI_ON_REQ, dst__, src__); \
+ msg__->clientData = (clientData__); \
+ msg__->dataLength = (dataLength__); \
+ msg__->data = (data__);
+
+#define CsrWifiRouterCtrlWifiOnReqSendTo(dst__, src__, clientData__, dataLength__, data__) \
+ { \
+ CsrWifiRouterCtrlWifiOnReq *msg__; \
+ CsrWifiRouterCtrlWifiOnReqCreate(msg__, dst__, src__, clientData__, dataLength__, data__); \
+ CsrMsgTransport(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
+ }
+
+#define CsrWifiRouterCtrlWifiOnReqSend(src__, clientData__, dataLength__, data__) \
+ CsrWifiRouterCtrlWifiOnReqSendTo(CSR_WIFI_ROUTER_IFACEQUEUE, src__, clientData__, dataLength__, data__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiRouterCtrlWifiOnIndSend
+
+ DESCRIPTION
+
+ PARAMETERS
+ queue - Destination Task Queue
+ clientData -
+ status -
+ versions -
+
+*******************************************************************************/
+#define CsrWifiRouterCtrlWifiOnIndCreate(msg__, dst__, src__, clientData__, status__, versions__) \
+ msg__ = kmalloc(sizeof(CsrWifiRouterCtrlWifiOnInd), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_WIFI_ON_IND, dst__, src__); \
+ msg__->clientData = (clientData__); \
+ msg__->status = (status__); \
+ msg__->versions = (versions__);
+
+#define CsrWifiRouterCtrlWifiOnIndSendTo(dst__, src__, clientData__, status__, versions__) \
+ { \
+ CsrWifiRouterCtrlWifiOnInd *msg__; \
+ CsrWifiRouterCtrlWifiOnIndCreate(msg__, dst__, src__, clientData__, status__, versions__); \
+ CsrSchedMessagePut(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
+ }
+
+#define CsrWifiRouterCtrlWifiOnIndSend(dst__, clientData__, status__, versions__) \
+ CsrWifiRouterCtrlWifiOnIndSendTo(dst__, CSR_WIFI_ROUTER_IFACEQUEUE, clientData__, status__, versions__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiRouterCtrlWifiOnResSend
+
+ DESCRIPTION
+
+ PARAMETERS
+ clientData -
+ status -
+ numInterfaceAddress -
+ stationMacAddress - array size 1 MUST match CSR_WIFI_NUM_INTERFACES
+ smeVersions -
+ scheduledInterrupt -
+
+*******************************************************************************/
+#define CsrWifiRouterCtrlWifiOnResCreate(msg__, dst__, src__, clientData__, status__, numInterfaceAddress__, stationMacAddress__, smeVersions__, scheduledInterrupt__) \
+ msg__ = kmalloc(sizeof(CsrWifiRouterCtrlWifiOnRes), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_WIFI_ON_RES, dst__, src__); \
+ msg__->clientData = (clientData__); \
+ msg__->status = (status__); \
+ msg__->numInterfaceAddress = (numInterfaceAddress__); \
+ memcpy(msg__->stationMacAddress, (stationMacAddress__), sizeof(CsrWifiMacAddress) * 2); \
+ msg__->smeVersions = (smeVersions__); \
+ msg__->scheduledInterrupt = (scheduledInterrupt__);
+
+#define CsrWifiRouterCtrlWifiOnResSendTo(dst__, src__, clientData__, status__, numInterfaceAddress__, stationMacAddress__, smeVersions__, scheduledInterrupt__) \
+ { \
+ CsrWifiRouterCtrlWifiOnRes *msg__; \
+ CsrWifiRouterCtrlWifiOnResCreate(msg__, dst__, src__, clientData__, status__, numInterfaceAddress__, stationMacAddress__, smeVersions__, scheduledInterrupt__); \
+ CsrMsgTransport(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
+ }
+
+#define CsrWifiRouterCtrlWifiOnResSend(src__, clientData__, status__, numInterfaceAddress__, stationMacAddress__, smeVersions__, scheduledInterrupt__) \
+ CsrWifiRouterCtrlWifiOnResSendTo(CSR_WIFI_ROUTER_IFACEQUEUE, src__, clientData__, status__, numInterfaceAddress__, stationMacAddress__, smeVersions__, scheduledInterrupt__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiRouterCtrlWifiOnCfmSend
+
+ DESCRIPTION
+
+ PARAMETERS
+ queue - Destination Task Queue
+ clientData -
+ status -
+
+*******************************************************************************/
+#define CsrWifiRouterCtrlWifiOnCfmCreate(msg__, dst__, src__, clientData__, status__) \
+ msg__ = kmalloc(sizeof(CsrWifiRouterCtrlWifiOnCfm), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_CTRL_PRIM, CSR_WIFI_ROUTER_CTRL_WIFI_ON_CFM, dst__, src__); \
+ msg__->clientData = (clientData__); \
+ msg__->status = (status__);
+
+#define CsrWifiRouterCtrlWifiOnCfmSendTo(dst__, src__, clientData__, status__) \
+ { \
+ CsrWifiRouterCtrlWifiOnCfm *msg__; \
+ CsrWifiRouterCtrlWifiOnCfmCreate(msg__, dst__, src__, clientData__, status__); \
+ CsrSchedMessagePut(dst__, CSR_WIFI_ROUTER_CTRL_PRIM, msg__); \
+ }
+
+#define CsrWifiRouterCtrlWifiOnCfmSend(dst__, clientData__, status__) \
+ CsrWifiRouterCtrlWifiOnCfmSendTo(dst__, CSR_WIFI_ROUTER_IFACEQUEUE, clientData__, status__)
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* CSR_WIFI_ROUTER_CTRL_LIB_H__ */
diff --git a/drivers/staging/csr/csr_wifi_router_ctrl_prim.h b/drivers/staging/csr/csr_wifi_router_ctrl_prim.h
new file mode 100644
index 000000000000..ec972ac0b5aa
--- /dev/null
+++ b/drivers/staging/csr/csr_wifi_router_ctrl_prim.h
@@ -0,0 +1,2122 @@
+/*****************************************************************************
+
+ (c) Cambridge Silicon Radio Limited 2012
+ All rights reserved and confidential information of CSR
+
+ Refer to LICENSE.txt included with this source for details
+ on the license terms.
+
+*****************************************************************************/
+
+/* Note: this is an auto-generated file. */
+
+#ifndef CSR_WIFI_ROUTER_CTRL_PRIM_H__
+#define CSR_WIFI_ROUTER_CTRL_PRIM_H__
+
+#include <linux/types.h>
+#include "csr_prim_defs.h"
+#include "csr_sched.h"
+#include "csr_wifi_common.h"
+#include "csr_result.h"
+#include "csr_wifi_fsm_event.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define CSR_WIFI_ROUTER_CTRL_PRIM (0x0401)
+
+typedef CsrPrim CsrWifiRouterCtrlPrim;
+
+typedef CsrResult (*CsrWifiRouterCtrlRawSdioByteWrite)(u8 func, u32 address, u8 data);
+typedef CsrResult (*CsrWifiRouterCtrlRawSdioByteRead)(u8 func, u32 address, u8 *pdata);
+typedef CsrResult (*CsrWifiRouterCtrlRawSdioFirmwareDownload)(u32 length, const u8 *pdata);
+typedef CsrResult (*CsrWifiRouterCtrlRawSdioReset)(void);
+typedef CsrResult (*CsrWifiRouterCtrlRawSdioCoreDumpPrepare)(u8 suspendSme);
+typedef CsrResult (*CsrWifiRouterCtrlRawSdioByteBlockRead)(u8 func, u32 address, u8 *pdata, u32 length);
+typedef CsrResult (*CsrWifiRouterCtrlRawSdioGpRead16)(u8 func, u32 address, u16 *pdata);
+typedef CsrResult (*CsrWifiRouterCtrlRawSdioGpWrite16)(u8 func, u32 address, u16 data);
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiRouterCtrlBlockAckRole
+
+ DESCRIPTION
+
+ VALUES
+ CSR_WIFI_ROUTER_CTRL_BLOCK_ACK_ORIGINATOR
+ -
+ CSR_WIFI_ROUTER_CTRL_BLOCK_ACK_RECIPIENT
+ -
+
+*******************************************************************************/
+typedef u8 CsrWifiRouterCtrlBlockAckRole;
+#define CSR_WIFI_ROUTER_CTRL_BLOCK_ACK_ORIGINATOR ((CsrWifiRouterCtrlBlockAckRole) 0x00)
+#define CSR_WIFI_ROUTER_CTRL_BLOCK_ACK_RECIPIENT ((CsrWifiRouterCtrlBlockAckRole) 0x01)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiRouterCtrlControlIndication
+
+ DESCRIPTION
+
+ VALUES
+ CSR_WIFI_ROUTER_CTRL_CONTROL_INDICATION_ERROR
+ -
+ CSR_WIFI_ROUTER_CTRL_CONTROL_INDICATION_EXIT
+ -
+ CSR_WIFI_ROUTER_CTRL_CONTROL_INDICATION_USER_REQUESTED
+ -
+
+*******************************************************************************/
+typedef u8 CsrWifiRouterCtrlControlIndication;
+#define CSR_WIFI_ROUTER_CTRL_CONTROL_INDICATION_ERROR ((CsrWifiRouterCtrlControlIndication) 0x01)
+#define CSR_WIFI_ROUTER_CTRL_CONTROL_INDICATION_EXIT ((CsrWifiRouterCtrlControlIndication) 0x02)
+#define CSR_WIFI_ROUTER_CTRL_CONTROL_INDICATION_USER_REQUESTED ((CsrWifiRouterCtrlControlIndication) 0x03)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiRouterCtrlListAction
+
+ DESCRIPTION
+
+ VALUES
+ CSR_WIFI_ROUTER_CTRL_LIST_ACTION_GET
+ -
+ CSR_WIFI_ROUTER_CTRL_LIST_ACTION_ADD
+ -
+ CSR_WIFI_ROUTER_CTRL_LIST_ACTION_REMOVE
+ -
+ CSR_WIFI_ROUTER_CTRL_LIST_ACTION_FLUSH
+ -
+
+*******************************************************************************/
+typedef u8 CsrWifiRouterCtrlListAction;
+#define CSR_WIFI_ROUTER_CTRL_LIST_ACTION_GET ((CsrWifiRouterCtrlListAction) 0x00)
+#define CSR_WIFI_ROUTER_CTRL_LIST_ACTION_ADD ((CsrWifiRouterCtrlListAction) 0x01)
+#define CSR_WIFI_ROUTER_CTRL_LIST_ACTION_REMOVE ((CsrWifiRouterCtrlListAction) 0x02)
+#define CSR_WIFI_ROUTER_CTRL_LIST_ACTION_FLUSH ((CsrWifiRouterCtrlListAction) 0x03)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiRouterCtrlLowPowerMode
+
+ DESCRIPTION
+
+ VALUES
+ CSR_WIFI_ROUTER_CTRL_LOW_POWER_MODE_DISABLED
+ -
+ CSR_WIFI_ROUTER_CTRL_LOW_POWER_MODE_ENABLED
+ -
+
+*******************************************************************************/
+typedef u16 CsrWifiRouterCtrlLowPowerMode;
+#define CSR_WIFI_ROUTER_CTRL_LOW_POWER_MODE_DISABLED ((CsrWifiRouterCtrlLowPowerMode) 0x0000)
+#define CSR_WIFI_ROUTER_CTRL_LOW_POWER_MODE_ENABLED ((CsrWifiRouterCtrlLowPowerMode) 0x0001)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiRouterCtrlMediaStatus
+
+ DESCRIPTION
+
+ VALUES
+ CSR_WIFI_ROUTER_CTRL_MEDIA_STATUS_CONNECTED
+ -
+ CSR_WIFI_ROUTER_CTRL_MEDIA_STATUS_DISCONNECTED
+ -
+
+*******************************************************************************/
+typedef u8 CsrWifiRouterCtrlMediaStatus;
+#define CSR_WIFI_ROUTER_CTRL_MEDIA_STATUS_CONNECTED ((CsrWifiRouterCtrlMediaStatus) 0x00)
+#define CSR_WIFI_ROUTER_CTRL_MEDIA_STATUS_DISCONNECTED ((CsrWifiRouterCtrlMediaStatus) 0x01)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiRouterCtrlMode
+
+ DESCRIPTION
+
+ VALUES
+ CSR_WIFI_ROUTER_CTRL_MODE_NONE -
+ CSR_WIFI_ROUTER_CTRL_MODE_IBSS -
+ CSR_WIFI_ROUTER_CTRL_MODE_STA -
+ CSR_WIFI_ROUTER_CTRL_MODE_AP -
+ CSR_WIFI_ROUTER_CTRL_MODE_MONITOR -
+ CSR_WIFI_ROUTER_CTRL_MODE_AMP -
+ CSR_WIFI_ROUTER_CTRL_MODE_P2P -
+ CSR_WIFI_ROUTER_CTRL_MODE_P2PGO -
+ CSR_WIFI_ROUTER_CTRL_MODE_P2PCLI -
+
+*******************************************************************************/
+typedef u8 CsrWifiRouterCtrlMode;
+#define CSR_WIFI_ROUTER_CTRL_MODE_NONE ((CsrWifiRouterCtrlMode) 0x00)
+#define CSR_WIFI_ROUTER_CTRL_MODE_IBSS ((CsrWifiRouterCtrlMode) 0x01)
+#define CSR_WIFI_ROUTER_CTRL_MODE_STA ((CsrWifiRouterCtrlMode) 0x02)
+#define CSR_WIFI_ROUTER_CTRL_MODE_AP ((CsrWifiRouterCtrlMode) 0x03)
+#define CSR_WIFI_ROUTER_CTRL_MODE_MONITOR ((CsrWifiRouterCtrlMode) 0x04)
+#define CSR_WIFI_ROUTER_CTRL_MODE_AMP ((CsrWifiRouterCtrlMode) 0x05)
+#define CSR_WIFI_ROUTER_CTRL_MODE_P2P ((CsrWifiRouterCtrlMode) 0x06)
+#define CSR_WIFI_ROUTER_CTRL_MODE_P2PGO ((CsrWifiRouterCtrlMode) 0x07)
+#define CSR_WIFI_ROUTER_CTRL_MODE_P2PCLI ((CsrWifiRouterCtrlMode) 0x08)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiRouterCtrlPeerStatus
+
+ DESCRIPTION
+
+ VALUES
+ CSR_WIFI_ROUTER_CTRL_PEER_CONNECTED_ACTIVE
+ -
+ CSR_WIFI_ROUTER_CTRL_PEER_CONNECTED_POWER_SAVE
+ -
+ CSR_WIFI_ROUTER_CTRL_PEER_DISCONNECTED
+ -
+
+*******************************************************************************/
+typedef u8 CsrWifiRouterCtrlPeerStatus;
+#define CSR_WIFI_ROUTER_CTRL_PEER_CONNECTED_ACTIVE ((CsrWifiRouterCtrlPeerStatus) 0x00)
+#define CSR_WIFI_ROUTER_CTRL_PEER_CONNECTED_POWER_SAVE ((CsrWifiRouterCtrlPeerStatus) 0x01)
+#define CSR_WIFI_ROUTER_CTRL_PEER_DISCONNECTED ((CsrWifiRouterCtrlPeerStatus) 0x02)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiRouterCtrlPortAction
+
+ DESCRIPTION
+
+ VALUES
+ CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_OPEN
+ -
+ CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_CLOSED_DISCARD
+ -
+ CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_CLOSED_BLOCK
+ -
+
+*******************************************************************************/
+typedef u16 CsrWifiRouterCtrlPortAction;
+#define CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_OPEN ((CsrWifiRouterCtrlPortAction) 0x0000)
+#define CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_CLOSED_DISCARD ((CsrWifiRouterCtrlPortAction) 0x0001)
+#define CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_CLOSED_BLOCK ((CsrWifiRouterCtrlPortAction) 0x0002)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiRouterCtrlPowersaveType
+
+ DESCRIPTION
+
+ VALUES
+ CSR_WIFI_ROUTER_CTRL_AC_BK_PS_INFO_PRESENT
+ - If set, AC BK PS info is present in b4 and b5
+ CSR_WIFI_ROUTER_CTRL_AC_BE_PS_INFO_PRESENT
+ - If set, AC BE PS info is present in b6 and b7
+ CSR_WIFI_ROUTER_CTRL_AC_VI_PS_INFO_PRESENT
+ - If set, AC VI PS info is present in b8 and b9
+ CSR_WIFI_ROUTER_CTRL_AC_VO_PS_INFO_PRESENT
+ - If set, AC VO PS info is present in b10 and b11
+ CSR_WIFI_ROUTER_CTRL_AC_BK_TRIGGER_ENABLED
+ -
+ CSR_WIFI_ROUTER_CTRL_AC_BK_DELIVERY_ENABLED
+ -
+ CSR_WIFI_ROUTER_CTRL_AC_BE_TRIGGER_ENABLED
+ -
+ CSR_WIFI_ROUTER_CTRL_AC_BE_DELIVERY_ENABLED
+ -
+ CSR_WIFI_ROUTER_CTRL_AC_VI_TRIGGER_ENABLED
+ -
+ CSR_WIFI_ROUTER_CTRL_AC_VI_DELIVERY_ENABLED
+ -
+ CSR_WIFI_ROUTER_CTRL_AC_VO_TRIGGER_ENABLED
+ -
+ CSR_WIFI_ROUTER_CTRL_AC_VO_DELIVERY_ENABLED
+ -
+
+*******************************************************************************/
+typedef u16 CsrWifiRouterCtrlPowersaveType;
+#define CSR_WIFI_ROUTER_CTRL_AC_BK_PS_INFO_PRESENT ((CsrWifiRouterCtrlPowersaveType) 0x0001)
+#define CSR_WIFI_ROUTER_CTRL_AC_BE_PS_INFO_PRESENT ((CsrWifiRouterCtrlPowersaveType) 0x0002)
+#define CSR_WIFI_ROUTER_CTRL_AC_VI_PS_INFO_PRESENT ((CsrWifiRouterCtrlPowersaveType) 0x0004)
+#define CSR_WIFI_ROUTER_CTRL_AC_VO_PS_INFO_PRESENT ((CsrWifiRouterCtrlPowersaveType) 0x0008)
+#define CSR_WIFI_ROUTER_CTRL_AC_BK_TRIGGER_ENABLED ((CsrWifiRouterCtrlPowersaveType) 0x0010)
+#define CSR_WIFI_ROUTER_CTRL_AC_BK_DELIVERY_ENABLED ((CsrWifiRouterCtrlPowersaveType) 0x0020)
+#define CSR_WIFI_ROUTER_CTRL_AC_BE_TRIGGER_ENABLED ((CsrWifiRouterCtrlPowersaveType) 0x0040)
+#define CSR_WIFI_ROUTER_CTRL_AC_BE_DELIVERY_ENABLED ((CsrWifiRouterCtrlPowersaveType) 0x0080)
+#define CSR_WIFI_ROUTER_CTRL_AC_VI_TRIGGER_ENABLED ((CsrWifiRouterCtrlPowersaveType) 0x0100)
+#define CSR_WIFI_ROUTER_CTRL_AC_VI_DELIVERY_ENABLED ((CsrWifiRouterCtrlPowersaveType) 0x0200)
+#define CSR_WIFI_ROUTER_CTRL_AC_VO_TRIGGER_ENABLED ((CsrWifiRouterCtrlPowersaveType) 0x0400)
+#define CSR_WIFI_ROUTER_CTRL_AC_VO_DELIVERY_ENABLED ((CsrWifiRouterCtrlPowersaveType) 0x0800)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiRouterCtrlProtocolDirection
+
+ DESCRIPTION
+
+ VALUES
+ CSR_WIFI_ROUTER_CTRL_PROTOCOL_DIRECTION_RX
+ -
+ CSR_WIFI_ROUTER_CTRL_PROTOCOL_DIRECTION_TX
+ -
+
+*******************************************************************************/
+typedef u16 CsrWifiRouterCtrlProtocolDirection;
+#define CSR_WIFI_ROUTER_CTRL_PROTOCOL_DIRECTION_RX ((CsrWifiRouterCtrlProtocolDirection) 0x0000)
+#define CSR_WIFI_ROUTER_CTRL_PROTOCOL_DIRECTION_TX ((CsrWifiRouterCtrlProtocolDirection) 0x0001)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiRouterCtrlQoSControl
+
+ DESCRIPTION
+
+ VALUES
+ CSR_WIFI_ROUTER_CTRL_QOS_CONTROL_OFF
+ -
+ CSR_WIFI_ROUTER_CTRL_QOS_CONTROL_WMM_ON
+ -
+ CSR_WIFI_ROUTER_CTRL_QOS_CONTROL_80211_ON
+ -
+
+*******************************************************************************/
+typedef u16 CsrWifiRouterCtrlQoSControl;
+#define CSR_WIFI_ROUTER_CTRL_QOS_CONTROL_OFF ((CsrWifiRouterCtrlQoSControl) 0x0000)
+#define CSR_WIFI_ROUTER_CTRL_QOS_CONTROL_WMM_ON ((CsrWifiRouterCtrlQoSControl) 0x0001)
+#define CSR_WIFI_ROUTER_CTRL_QOS_CONTROL_80211_ON ((CsrWifiRouterCtrlQoSControl) 0x0002)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiRouterCtrlQueueConfig
+
+ DESCRIPTION
+ Defines which Queues are enabled for use.
+
+ VALUES
+ CSR_WIFI_ROUTER_CTRL_QUEUE_BE_ENABLE
+ -
+ CSR_WIFI_ROUTER_CTRL_QUEUE_BK_ENABLE
+ -
+ CSR_WIFI_ROUTER_CTRL_QUEUE_VI_ENABLE
+ -
+ CSR_WIFI_ROUTER_CTRL_QUEUE_VO_ENABLE
+ -
+
+*******************************************************************************/
+typedef u8 CsrWifiRouterCtrlQueueConfig;
+#define CSR_WIFI_ROUTER_CTRL_QUEUE_BE_ENABLE ((CsrWifiRouterCtrlQueueConfig) 0x01)
+#define CSR_WIFI_ROUTER_CTRL_QUEUE_BK_ENABLE ((CsrWifiRouterCtrlQueueConfig) 0x02)
+#define CSR_WIFI_ROUTER_CTRL_QUEUE_VI_ENABLE ((CsrWifiRouterCtrlQueueConfig) 0x04)
+#define CSR_WIFI_ROUTER_CTRL_QUEUE_VO_ENABLE ((CsrWifiRouterCtrlQueueConfig) 0x08)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiRouterCtrlTrafficConfigType
+
+ DESCRIPTION
+
+ VALUES
+ CSR_WIFI_ROUTER_CTRL_TRAFFIC_CONFIG_TYPE_RESET
+ -
+ CSR_WIFI_ROUTER_CTRL_TRAFFIC_CONFIG_TYPE_FILTER
+ -
+ CSR_WIFI_ROUTER_CTRL_TRAFFIC_CONFIG_TYPE_CLS
+ -
+
+*******************************************************************************/
+typedef u16 CsrWifiRouterCtrlTrafficConfigType;
+#define CSR_WIFI_ROUTER_CTRL_TRAFFIC_CONFIG_TYPE_RESET ((CsrWifiRouterCtrlTrafficConfigType) 0x0000)
+#define CSR_WIFI_ROUTER_CTRL_TRAFFIC_CONFIG_TYPE_FILTER ((CsrWifiRouterCtrlTrafficConfigType) 0x0001)
+#define CSR_WIFI_ROUTER_CTRL_TRAFFIC_CONFIG_TYPE_CLS ((CsrWifiRouterCtrlTrafficConfigType) 0x0002)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiRouterCtrlTrafficPacketType
+
+ DESCRIPTION
+
+ VALUES
+ CSR_WIFI_ROUTER_CTRL_TRAFFIC_PACKET_TYPE_NONE
+ -
+ CSR_WIFI_ROUTER_CTRL_TRAFFIC_PACKET_TYPE_EAPOL
+ -
+ CSR_WIFI_ROUTER_CTRL_TRAFFIC_PACKET_TYPE_DHCP
+ -
+ CSR_WIFI_ROUTER_CTRL_TRAFFIC_PACKET_TYPE_DHCP_ACK
+ -
+ CSR_WIFI_ROUTER_CTRL_TRAFFIC_PACKET_TYPE_ARP
+ -
+ CSR_WIFI_ROUTER_CTRL_TRAFFIC_PACKET_TYPE_AIRONET
+ -
+ CSR_WIFI_ROUTER_CTRL_TRAFFIC_PACKET_TYPE_CUSTOM
+ -
+ CSR_WIFI_ROUTER_CTRL_TRAFFIC_PACKET_TYPE_ALL
+ -
+
+*******************************************************************************/
+typedef u16 CsrWifiRouterCtrlTrafficPacketType;
+#define CSR_WIFI_ROUTER_CTRL_TRAFFIC_PACKET_TYPE_NONE ((CsrWifiRouterCtrlTrafficPacketType) 0x0000)
+#define CSR_WIFI_ROUTER_CTRL_TRAFFIC_PACKET_TYPE_EAPOL ((CsrWifiRouterCtrlTrafficPacketType) 0x0001)
+#define CSR_WIFI_ROUTER_CTRL_TRAFFIC_PACKET_TYPE_DHCP ((CsrWifiRouterCtrlTrafficPacketType) 0x0002)
+#define CSR_WIFI_ROUTER_CTRL_TRAFFIC_PACKET_TYPE_DHCP_ACK ((CsrWifiRouterCtrlTrafficPacketType) 0x0004)
+#define CSR_WIFI_ROUTER_CTRL_TRAFFIC_PACKET_TYPE_ARP ((CsrWifiRouterCtrlTrafficPacketType) 0x0008)
+#define CSR_WIFI_ROUTER_CTRL_TRAFFIC_PACKET_TYPE_AIRONET ((CsrWifiRouterCtrlTrafficPacketType) 0x0010)
+#define CSR_WIFI_ROUTER_CTRL_TRAFFIC_PACKET_TYPE_CUSTOM ((CsrWifiRouterCtrlTrafficPacketType) 0x0020)
+#define CSR_WIFI_ROUTER_CTRL_TRAFFIC_PACKET_TYPE_ALL ((CsrWifiRouterCtrlTrafficPacketType) 0x00FF)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiRouterCtrlTrafficType
+
+ DESCRIPTION
+
+ VALUES
+ CSR_WIFI_ROUTER_CTRL_TRAFFIC_TYPE_OCCASIONAL
+ -
+ CSR_WIFI_ROUTER_CTRL_TRAFFIC_TYPE_BURSTY
+ -
+ CSR_WIFI_ROUTER_CTRL_TRAFFIC_TYPE_PERIODIC
+ -
+ CSR_WIFI_ROUTER_CTRL_TRAFFIC_TYPE_CONTINUOUS
+ -
+
+*******************************************************************************/
+typedef u8 CsrWifiRouterCtrlTrafficType;
+#define CSR_WIFI_ROUTER_CTRL_TRAFFIC_TYPE_OCCASIONAL ((CsrWifiRouterCtrlTrafficType) 0x00)
+#define CSR_WIFI_ROUTER_CTRL_TRAFFIC_TYPE_BURSTY ((CsrWifiRouterCtrlTrafficType) 0x01)
+#define CSR_WIFI_ROUTER_CTRL_TRAFFIC_TYPE_PERIODIC ((CsrWifiRouterCtrlTrafficType) 0x02)
+#define CSR_WIFI_ROUTER_CTRL_TRAFFIC_TYPE_CONTINUOUS ((CsrWifiRouterCtrlTrafficType) 0x03)
+
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiRouterCtrlPeerRecordHandle
+
+ DESCRIPTION
+
+*******************************************************************************/
+typedef u32 CsrWifiRouterCtrlPeerRecordHandle;
+/*******************************************************************************
+
+ NAME
+ CsrWifiRouterCtrlPowersaveTypeMask
+
+ DESCRIPTION
+ Mask type for use with the values defined by
+ CsrWifiRouterCtrlPowersaveType
+
+*******************************************************************************/
+typedef u16 CsrWifiRouterCtrlPowersaveTypeMask;
+/*******************************************************************************
+
+ NAME
+ CsrWifiRouterCtrlQueueConfigMask
+
+ DESCRIPTION
+ Mask type for use with the values defined by CsrWifiRouterCtrlQueueConfig
+
+*******************************************************************************/
+typedef u8 CsrWifiRouterCtrlQueueConfigMask;
+/*******************************************************************************
+
+ NAME
+ CsrWifiRouterCtrlRequestorInfo
+
+ DESCRIPTION
+
+*******************************************************************************/
+typedef u16 CsrWifiRouterCtrlRequestorInfo;
+/*******************************************************************************
+
+ NAME
+ CsrWifiRouterCtrlTrafficStreamId
+
+ DESCRIPTION
+
+*******************************************************************************/
+typedef u8 CsrWifiRouterCtrlTrafficStreamId;
+
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiRouterCtrlSmeVersions
+
+ DESCRIPTION
+
+ MEMBERS
+ firmwarePatch -
+ smeBuild -
+ smeHip -
+
+*******************************************************************************/
+typedef struct
+{
+ u32 firmwarePatch;
+ char *smeBuild;
+ u32 smeHip;
+} CsrWifiRouterCtrlSmeVersions;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiRouterCtrlStaInfo
+
+ DESCRIPTION
+
+ MEMBERS
+ wmmOrQosEnabled -
+ powersaveMode -
+ maxSpLength -
+ listenIntervalInTus -
+
+*******************************************************************************/
+typedef struct
+{
+ u8 wmmOrQosEnabled;
+ CsrWifiRouterCtrlPowersaveTypeMask powersaveMode;
+ u8 maxSpLength;
+ u16 listenIntervalInTus;
+} CsrWifiRouterCtrlStaInfo;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiRouterCtrlTrafficFilter
+
+ DESCRIPTION
+
+ MEMBERS
+ etherType -
+ ipType -
+ udpSourcePort -
+ udpDestPort -
+
+*******************************************************************************/
+typedef struct
+{
+ u32 etherType;
+ u8 ipType;
+ u32 udpSourcePort;
+ u32 udpDestPort;
+} CsrWifiRouterCtrlTrafficFilter;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiRouterCtrlTrafficStats
+
+ DESCRIPTION
+
+ MEMBERS
+ rxMeanRate - Mean rx data rate over the interval
+ rxFramesNum - Keep number of Rx frames per second, for CYCLE_3.
+ txFramesNum - Keep number of Tx frames per second, for CYCLE_3.
+ rxBytesCount - Keep calculated Rx throughput per second, for CYCLE_2.
+ txBytesCount - Keep calculated Tx throughput per second, for CYCLE_2.
+ intervals - array size 11 MUST match TA_INTERVALS_NUM
+
+*******************************************************************************/
+typedef struct
+{
+ u32 rxMeanRate;
+ u32 rxFramesNum;
+ u32 txFramesNum;
+ u32 rxBytesCount;
+ u32 txBytesCount;
+ u8 intervals[11];
+} CsrWifiRouterCtrlTrafficStats;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiRouterCtrlVersions
+
+ DESCRIPTION
+
+ MEMBERS
+ chipId -
+ chipVersion -
+ firmwareBuild -
+ firmwareHip -
+ routerBuild -
+ routerHip -
+
+*******************************************************************************/
+typedef struct
+{
+ u32 chipId;
+ u32 chipVersion;
+ u32 firmwareBuild;
+ u32 firmwareHip;
+ char *routerBuild;
+ u32 routerHip;
+} CsrWifiRouterCtrlVersions;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiRouterCtrlTrafficConfig
+
+ DESCRIPTION
+
+ MEMBERS
+ packetFilter -
+ customFilter -
+
+*******************************************************************************/
+typedef struct
+{
+ u16 packetFilter;
+ CsrWifiRouterCtrlTrafficFilter customFilter;
+} CsrWifiRouterCtrlTrafficConfig;
+
+
+/* Downstream */
+#define CSR_WIFI_ROUTER_CTRL_PRIM_DOWNSTREAM_LOWEST (0x0000)
+
+#define CSR_WIFI_ROUTER_CTRL_CONFIGURE_POWER_MODE_REQ ((CsrWifiRouterCtrlPrim) (0x0000 + CSR_WIFI_ROUTER_CTRL_PRIM_DOWNSTREAM_LOWEST))
+#define CSR_WIFI_ROUTER_CTRL_HIP_REQ ((CsrWifiRouterCtrlPrim) (0x0001 + CSR_WIFI_ROUTER_CTRL_PRIM_DOWNSTREAM_LOWEST))
+#define CSR_WIFI_ROUTER_CTRL_MEDIA_STATUS_REQ ((CsrWifiRouterCtrlPrim) (0x0002 + CSR_WIFI_ROUTER_CTRL_PRIM_DOWNSTREAM_LOWEST))
+#define CSR_WIFI_ROUTER_CTRL_MULTICAST_ADDRESS_RES ((CsrWifiRouterCtrlPrim) (0x0003 + CSR_WIFI_ROUTER_CTRL_PRIM_DOWNSTREAM_LOWEST))
+#define CSR_WIFI_ROUTER_CTRL_PORT_CONFIGURE_REQ ((CsrWifiRouterCtrlPrim) (0x0004 + CSR_WIFI_ROUTER_CTRL_PRIM_DOWNSTREAM_LOWEST))
+#define CSR_WIFI_ROUTER_CTRL_QOS_CONTROL_REQ ((CsrWifiRouterCtrlPrim) (0x0005 + CSR_WIFI_ROUTER_CTRL_PRIM_DOWNSTREAM_LOWEST))
+#define CSR_WIFI_ROUTER_CTRL_SUSPEND_RES ((CsrWifiRouterCtrlPrim) (0x0006 + CSR_WIFI_ROUTER_CTRL_PRIM_DOWNSTREAM_LOWEST))
+#define CSR_WIFI_ROUTER_CTRL_TCLAS_ADD_REQ ((CsrWifiRouterCtrlPrim) (0x0007 + CSR_WIFI_ROUTER_CTRL_PRIM_DOWNSTREAM_LOWEST))
+#define CSR_WIFI_ROUTER_CTRL_RESUME_RES ((CsrWifiRouterCtrlPrim) (0x0008 + CSR_WIFI_ROUTER_CTRL_PRIM_DOWNSTREAM_LOWEST))
+#define CSR_WIFI_ROUTER_CTRL_RAW_SDIO_DEINITIALISE_REQ ((CsrWifiRouterCtrlPrim) (0x0009 + CSR_WIFI_ROUTER_CTRL_PRIM_DOWNSTREAM_LOWEST))
+#define CSR_WIFI_ROUTER_CTRL_RAW_SDIO_INITIALISE_REQ ((CsrWifiRouterCtrlPrim) (0x000A + CSR_WIFI_ROUTER_CTRL_PRIM_DOWNSTREAM_LOWEST))
+#define CSR_WIFI_ROUTER_CTRL_TCLAS_DEL_REQ ((CsrWifiRouterCtrlPrim) (0x000B + CSR_WIFI_ROUTER_CTRL_PRIM_DOWNSTREAM_LOWEST))
+#define CSR_WIFI_ROUTER_CTRL_TRAFFIC_CLASSIFICATION_REQ ((CsrWifiRouterCtrlPrim) (0x000C + CSR_WIFI_ROUTER_CTRL_PRIM_DOWNSTREAM_LOWEST))
+#define CSR_WIFI_ROUTER_CTRL_TRAFFIC_CONFIG_REQ ((CsrWifiRouterCtrlPrim) (0x000D + CSR_WIFI_ROUTER_CTRL_PRIM_DOWNSTREAM_LOWEST))
+#define CSR_WIFI_ROUTER_CTRL_WIFI_OFF_REQ ((CsrWifiRouterCtrlPrim) (0x000E + CSR_WIFI_ROUTER_CTRL_PRIM_DOWNSTREAM_LOWEST))
+#define CSR_WIFI_ROUTER_CTRL_WIFI_OFF_RES ((CsrWifiRouterCtrlPrim) (0x000F + CSR_WIFI_ROUTER_CTRL_PRIM_DOWNSTREAM_LOWEST))
+#define CSR_WIFI_ROUTER_CTRL_WIFI_ON_REQ ((CsrWifiRouterCtrlPrim) (0x0010 + CSR_WIFI_ROUTER_CTRL_PRIM_DOWNSTREAM_LOWEST))
+#define CSR_WIFI_ROUTER_CTRL_WIFI_ON_RES ((CsrWifiRouterCtrlPrim) (0x0011 + CSR_WIFI_ROUTER_CTRL_PRIM_DOWNSTREAM_LOWEST))
+#define CSR_WIFI_ROUTER_CTRL_M4_TRANSMIT_REQ ((CsrWifiRouterCtrlPrim) (0x0012 + CSR_WIFI_ROUTER_CTRL_PRIM_DOWNSTREAM_LOWEST))
+#define CSR_WIFI_ROUTER_CTRL_MODE_SET_REQ ((CsrWifiRouterCtrlPrim) (0x0013 + CSR_WIFI_ROUTER_CTRL_PRIM_DOWNSTREAM_LOWEST))
+#define CSR_WIFI_ROUTER_CTRL_PEER_ADD_REQ ((CsrWifiRouterCtrlPrim) (0x0014 + CSR_WIFI_ROUTER_CTRL_PRIM_DOWNSTREAM_LOWEST))
+#define CSR_WIFI_ROUTER_CTRL_PEER_DEL_REQ ((CsrWifiRouterCtrlPrim) (0x0015 + CSR_WIFI_ROUTER_CTRL_PRIM_DOWNSTREAM_LOWEST))
+#define CSR_WIFI_ROUTER_CTRL_PEER_UPDATE_REQ ((CsrWifiRouterCtrlPrim) (0x0016 + CSR_WIFI_ROUTER_CTRL_PRIM_DOWNSTREAM_LOWEST))
+#define CSR_WIFI_ROUTER_CTRL_CAPABILITIES_REQ ((CsrWifiRouterCtrlPrim) (0x0017 + CSR_WIFI_ROUTER_CTRL_PRIM_DOWNSTREAM_LOWEST))
+#define CSR_WIFI_ROUTER_CTRL_BLOCK_ACK_ENABLE_REQ ((CsrWifiRouterCtrlPrim) (0x0018 + CSR_WIFI_ROUTER_CTRL_PRIM_DOWNSTREAM_LOWEST))
+#define CSR_WIFI_ROUTER_CTRL_BLOCK_ACK_DISABLE_REQ ((CsrWifiRouterCtrlPrim) (0x0019 + CSR_WIFI_ROUTER_CTRL_PRIM_DOWNSTREAM_LOWEST))
+#define CSR_WIFI_ROUTER_CTRL_WAPI_RX_PKT_REQ ((CsrWifiRouterCtrlPrim) (0x001A + CSR_WIFI_ROUTER_CTRL_PRIM_DOWNSTREAM_LOWEST))
+#define CSR_WIFI_ROUTER_CTRL_WAPI_MULTICAST_FILTER_REQ ((CsrWifiRouterCtrlPrim) (0x001B + CSR_WIFI_ROUTER_CTRL_PRIM_DOWNSTREAM_LOWEST))
+#define CSR_WIFI_ROUTER_CTRL_WAPI_UNICAST_FILTER_REQ ((CsrWifiRouterCtrlPrim) (0x001C + CSR_WIFI_ROUTER_CTRL_PRIM_DOWNSTREAM_LOWEST))
+#define CSR_WIFI_ROUTER_CTRL_WAPI_UNICAST_TX_PKT_REQ ((CsrWifiRouterCtrlPrim) (0x001D + CSR_WIFI_ROUTER_CTRL_PRIM_DOWNSTREAM_LOWEST))
+#define CSR_WIFI_ROUTER_CTRL_WAPI_FILTER_REQ ((CsrWifiRouterCtrlPrim) (0x001E + CSR_WIFI_ROUTER_CTRL_PRIM_DOWNSTREAM_LOWEST))
+
+
+#define CSR_WIFI_ROUTER_CTRL_PRIM_DOWNSTREAM_HIGHEST (0x001E + CSR_WIFI_ROUTER_CTRL_PRIM_DOWNSTREAM_LOWEST)
+
+/* Upstream */
+#define CSR_WIFI_ROUTER_CTRL_PRIM_UPSTREAM_LOWEST (0x0000 + CSR_PRIM_UPSTREAM)
+
+#define CSR_WIFI_ROUTER_CTRL_HIP_IND ((CsrWifiRouterCtrlPrim)(0x0000 + CSR_WIFI_ROUTER_CTRL_PRIM_UPSTREAM_LOWEST))
+#define CSR_WIFI_ROUTER_CTRL_MULTICAST_ADDRESS_IND ((CsrWifiRouterCtrlPrim)(0x0001 + CSR_WIFI_ROUTER_CTRL_PRIM_UPSTREAM_LOWEST))
+#define CSR_WIFI_ROUTER_CTRL_PORT_CONFIGURE_CFM ((CsrWifiRouterCtrlPrim)(0x0002 + CSR_WIFI_ROUTER_CTRL_PRIM_UPSTREAM_LOWEST))
+#define CSR_WIFI_ROUTER_CTRL_RESUME_IND ((CsrWifiRouterCtrlPrim)(0x0003 + CSR_WIFI_ROUTER_CTRL_PRIM_UPSTREAM_LOWEST))
+#define CSR_WIFI_ROUTER_CTRL_SUSPEND_IND ((CsrWifiRouterCtrlPrim)(0x0004 + CSR_WIFI_ROUTER_CTRL_PRIM_UPSTREAM_LOWEST))
+#define CSR_WIFI_ROUTER_CTRL_TCLAS_ADD_CFM ((CsrWifiRouterCtrlPrim)(0x0005 + CSR_WIFI_ROUTER_CTRL_PRIM_UPSTREAM_LOWEST))
+#define CSR_WIFI_ROUTER_CTRL_RAW_SDIO_DEINITIALISE_CFM ((CsrWifiRouterCtrlPrim)(0x0006 + CSR_WIFI_ROUTER_CTRL_PRIM_UPSTREAM_LOWEST))
+#define CSR_WIFI_ROUTER_CTRL_RAW_SDIO_INITIALISE_CFM ((CsrWifiRouterCtrlPrim)(0x0007 + CSR_WIFI_ROUTER_CTRL_PRIM_UPSTREAM_LOWEST))
+#define CSR_WIFI_ROUTER_CTRL_TCLAS_DEL_CFM ((CsrWifiRouterCtrlPrim)(0x0008 + CSR_WIFI_ROUTER_CTRL_PRIM_UPSTREAM_LOWEST))
+#define CSR_WIFI_ROUTER_CTRL_TRAFFIC_PROTOCOL_IND ((CsrWifiRouterCtrlPrim)(0x0009 + CSR_WIFI_ROUTER_CTRL_PRIM_UPSTREAM_LOWEST))
+#define CSR_WIFI_ROUTER_CTRL_TRAFFIC_SAMPLE_IND ((CsrWifiRouterCtrlPrim)(0x000A + CSR_WIFI_ROUTER_CTRL_PRIM_UPSTREAM_LOWEST))
+#define CSR_WIFI_ROUTER_CTRL_WIFI_OFF_IND ((CsrWifiRouterCtrlPrim)(0x000B + CSR_WIFI_ROUTER_CTRL_PRIM_UPSTREAM_LOWEST))
+#define CSR_WIFI_ROUTER_CTRL_WIFI_OFF_CFM ((CsrWifiRouterCtrlPrim)(0x000C + CSR_WIFI_ROUTER_CTRL_PRIM_UPSTREAM_LOWEST))
+#define CSR_WIFI_ROUTER_CTRL_WIFI_ON_IND ((CsrWifiRouterCtrlPrim)(0x000D + CSR_WIFI_ROUTER_CTRL_PRIM_UPSTREAM_LOWEST))
+#define CSR_WIFI_ROUTER_CTRL_WIFI_ON_CFM ((CsrWifiRouterCtrlPrim)(0x000E + CSR_WIFI_ROUTER_CTRL_PRIM_UPSTREAM_LOWEST))
+#define CSR_WIFI_ROUTER_CTRL_M4_READY_TO_SEND_IND ((CsrWifiRouterCtrlPrim)(0x000F + CSR_WIFI_ROUTER_CTRL_PRIM_UPSTREAM_LOWEST))
+#define CSR_WIFI_ROUTER_CTRL_M4_TRANSMITTED_IND ((CsrWifiRouterCtrlPrim)(0x0010 + CSR_WIFI_ROUTER_CTRL_PRIM_UPSTREAM_LOWEST))
+#define CSR_WIFI_ROUTER_CTRL_MIC_FAILURE_IND ((CsrWifiRouterCtrlPrim)(0x0011 + CSR_WIFI_ROUTER_CTRL_PRIM_UPSTREAM_LOWEST))
+#define CSR_WIFI_ROUTER_CTRL_CONNECTED_IND ((CsrWifiRouterCtrlPrim)(0x0012 + CSR_WIFI_ROUTER_CTRL_PRIM_UPSTREAM_LOWEST))
+#define CSR_WIFI_ROUTER_CTRL_PEER_ADD_CFM ((CsrWifiRouterCtrlPrim)(0x0013 + CSR_WIFI_ROUTER_CTRL_PRIM_UPSTREAM_LOWEST))
+#define CSR_WIFI_ROUTER_CTRL_PEER_DEL_CFM ((CsrWifiRouterCtrlPrim)(0x0014 + CSR_WIFI_ROUTER_CTRL_PRIM_UPSTREAM_LOWEST))
+#define CSR_WIFI_ROUTER_CTRL_UNEXPECTED_FRAME_IND ((CsrWifiRouterCtrlPrim)(0x0015 + CSR_WIFI_ROUTER_CTRL_PRIM_UPSTREAM_LOWEST))
+#define CSR_WIFI_ROUTER_CTRL_PEER_UPDATE_CFM ((CsrWifiRouterCtrlPrim)(0x0016 + CSR_WIFI_ROUTER_CTRL_PRIM_UPSTREAM_LOWEST))
+#define CSR_WIFI_ROUTER_CTRL_CAPABILITIES_CFM ((CsrWifiRouterCtrlPrim)(0x0017 + CSR_WIFI_ROUTER_CTRL_PRIM_UPSTREAM_LOWEST))
+#define CSR_WIFI_ROUTER_CTRL_BLOCK_ACK_ENABLE_CFM ((CsrWifiRouterCtrlPrim)(0x0018 + CSR_WIFI_ROUTER_CTRL_PRIM_UPSTREAM_LOWEST))
+#define CSR_WIFI_ROUTER_CTRL_BLOCK_ACK_DISABLE_CFM ((CsrWifiRouterCtrlPrim)(0x0019 + CSR_WIFI_ROUTER_CTRL_PRIM_UPSTREAM_LOWEST))
+#define CSR_WIFI_ROUTER_CTRL_BLOCK_ACK_ERROR_IND ((CsrWifiRouterCtrlPrim)(0x001A + CSR_WIFI_ROUTER_CTRL_PRIM_UPSTREAM_LOWEST))
+#define CSR_WIFI_ROUTER_CTRL_STA_INACTIVE_IND ((CsrWifiRouterCtrlPrim)(0x001B + CSR_WIFI_ROUTER_CTRL_PRIM_UPSTREAM_LOWEST))
+#define CSR_WIFI_ROUTER_CTRL_WAPI_RX_MIC_CHECK_IND ((CsrWifiRouterCtrlPrim)(0x001C + CSR_WIFI_ROUTER_CTRL_PRIM_UPSTREAM_LOWEST))
+#define CSR_WIFI_ROUTER_CTRL_MODE_SET_CFM ((CsrWifiRouterCtrlPrim)(0x001D + CSR_WIFI_ROUTER_CTRL_PRIM_UPSTREAM_LOWEST))
+#define CSR_WIFI_ROUTER_CTRL_WAPI_UNICAST_TX_ENCRYPT_IND ((CsrWifiRouterCtrlPrim)(0x001E + CSR_WIFI_ROUTER_CTRL_PRIM_UPSTREAM_LOWEST))
+
+#define CSR_WIFI_ROUTER_CTRL_PRIM_UPSTREAM_HIGHEST (0x001E + CSR_WIFI_ROUTER_CTRL_PRIM_UPSTREAM_LOWEST)
+
+#define CSR_WIFI_ROUTER_CTRL_PRIM_DOWNSTREAM_COUNT (CSR_WIFI_ROUTER_CTRL_PRIM_DOWNSTREAM_HIGHEST + 1 - CSR_WIFI_ROUTER_CTRL_PRIM_DOWNSTREAM_LOWEST)
+#define CSR_WIFI_ROUTER_CTRL_PRIM_UPSTREAM_COUNT (CSR_WIFI_ROUTER_CTRL_PRIM_UPSTREAM_HIGHEST + 1 - CSR_WIFI_ROUTER_CTRL_PRIM_UPSTREAM_LOWEST)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiRouterCtrlConfigurePowerModeReq
+
+ DESCRIPTION
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ clientData -
+ mode -
+ wakeHost -
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ CsrWifiRouterCtrlRequestorInfo clientData;
+ CsrWifiRouterCtrlLowPowerMode mode;
+ u8 wakeHost;
+} CsrWifiRouterCtrlConfigurePowerModeReq;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiRouterCtrlHipReq
+
+ DESCRIPTION
+ This primitive is used for transferring MLME messages to the HIP.
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ mlmeCommandLength - Length of the MLME signal
+ mlmeCommand - Pointer to the MLME signal
+ dataRef1Length - Length of the dataRef1 bulk data
+ dataRef1 - Pointer to the bulk data 1
+ dataRef2Length - Length of the dataRef2 bulk data
+ dataRef2 - Pointer to the bulk data 2
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ u16 mlmeCommandLength;
+ u8 *mlmeCommand;
+ u16 dataRef1Length;
+ u8 *dataRef1;
+ u16 dataRef2Length;
+ u8 *dataRef2;
+} CsrWifiRouterCtrlHipReq;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiRouterCtrlMediaStatusReq
+
+ DESCRIPTION
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ interfaceTag -
+ clientData -
+ mediaStatus -
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ u16 interfaceTag;
+ CsrWifiRouterCtrlRequestorInfo clientData;
+ CsrWifiRouterCtrlMediaStatus mediaStatus;
+} CsrWifiRouterCtrlMediaStatusReq;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiRouterCtrlMulticastAddressRes
+
+ DESCRIPTION
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ interfaceTag -
+ clientData -
+ status -
+ action -
+ getAddressesCount -
+ getAddresses -
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ u16 interfaceTag;
+ CsrWifiRouterCtrlRequestorInfo clientData;
+ CsrResult status;
+ CsrWifiRouterCtrlListAction action;
+ u8 getAddressesCount;
+ CsrWifiMacAddress *getAddresses;
+} CsrWifiRouterCtrlMulticastAddressRes;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiRouterCtrlPortConfigureReq
+
+ DESCRIPTION
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ interfaceTag -
+ clientData -
+ uncontrolledPortAction -
+ controlledPortAction -
+ macAddress -
+ setProtection -
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ u16 interfaceTag;
+ CsrWifiRouterCtrlRequestorInfo clientData;
+ CsrWifiRouterCtrlPortAction uncontrolledPortAction;
+ CsrWifiRouterCtrlPortAction controlledPortAction;
+ CsrWifiMacAddress macAddress;
+ u8 setProtection;
+} CsrWifiRouterCtrlPortConfigureReq;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiRouterCtrlQosControlReq
+
+ DESCRIPTION
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ interfaceTag -
+ clientData -
+ control -
+ queueConfig -
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ u16 interfaceTag;
+ CsrWifiRouterCtrlRequestorInfo clientData;
+ CsrWifiRouterCtrlQoSControl control;
+ CsrWifiRouterCtrlQueueConfigMask queueConfig;
+} CsrWifiRouterCtrlQosControlReq;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiRouterCtrlSuspendRes
+
+ DESCRIPTION
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ clientData -
+ status -
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ CsrWifiRouterCtrlRequestorInfo clientData;
+ CsrResult status;
+} CsrWifiRouterCtrlSuspendRes;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiRouterCtrlTclasAddReq
+
+ DESCRIPTION
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ interfaceTag -
+ clientData -
+ tclasLength -
+ tclas -
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ u16 interfaceTag;
+ CsrWifiRouterCtrlRequestorInfo clientData;
+ u16 tclasLength;
+ u8 *tclas;
+} CsrWifiRouterCtrlTclasAddReq;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiRouterCtrlResumeRes
+
+ DESCRIPTION
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ clientData -
+ status -
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ CsrWifiRouterCtrlRequestorInfo clientData;
+ CsrResult status;
+} CsrWifiRouterCtrlResumeRes;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiRouterCtrlRawSdioDeinitialiseReq
+
+ DESCRIPTION
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ clientData -
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ CsrWifiRouterCtrlRequestorInfo clientData;
+} CsrWifiRouterCtrlRawSdioDeinitialiseReq;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiRouterCtrlRawSdioInitialiseReq
+
+ DESCRIPTION
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ clientData -
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ CsrWifiRouterCtrlRequestorInfo clientData;
+} CsrWifiRouterCtrlRawSdioInitialiseReq;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiRouterCtrlTclasDelReq
+
+ DESCRIPTION
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ interfaceTag -
+ clientData -
+ tclasLength -
+ tclas -
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ u16 interfaceTag;
+ CsrWifiRouterCtrlRequestorInfo clientData;
+ u16 tclasLength;
+ u8 *tclas;
+} CsrWifiRouterCtrlTclasDelReq;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiRouterCtrlTrafficClassificationReq
+
+ DESCRIPTION
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ interfaceTag -
+ clientData -
+ trafficType -
+ period -
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ u16 interfaceTag;
+ CsrWifiRouterCtrlRequestorInfo clientData;
+ CsrWifiRouterCtrlTrafficType trafficType;
+ u16 period;
+} CsrWifiRouterCtrlTrafficClassificationReq;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiRouterCtrlTrafficConfigReq
+
+ DESCRIPTION
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ interfaceTag -
+ clientData -
+ trafficConfigType -
+ config -
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ u16 interfaceTag;
+ CsrWifiRouterCtrlRequestorInfo clientData;
+ CsrWifiRouterCtrlTrafficConfigType trafficConfigType;
+ CsrWifiRouterCtrlTrafficConfig config;
+} CsrWifiRouterCtrlTrafficConfigReq;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiRouterCtrlWifiOffReq
+
+ DESCRIPTION
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ clientData -
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ CsrWifiRouterCtrlRequestorInfo clientData;
+} CsrWifiRouterCtrlWifiOffReq;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiRouterCtrlWifiOffRes
+
+ DESCRIPTION
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ clientData -
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ CsrWifiRouterCtrlRequestorInfo clientData;
+} CsrWifiRouterCtrlWifiOffRes;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiRouterCtrlWifiOnReq
+
+ DESCRIPTION
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ clientData -
+ dataLength - Number of bytes in the buffer pointed to by 'data'
+ data - Pointer to the buffer containing 'dataLength' bytes
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ CsrWifiRouterCtrlRequestorInfo clientData;
+ u32 dataLength;
+ u8 *data;
+} CsrWifiRouterCtrlWifiOnReq;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiRouterCtrlWifiOnRes
+
+ DESCRIPTION
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ clientData -
+ status -
+ numInterfaceAddress -
+ stationMacAddress - array size 1 MUST match CSR_WIFI_NUM_INTERFACES
+ smeVersions -
+ scheduledInterrupt -
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ CsrWifiRouterCtrlRequestorInfo clientData;
+ CsrResult status;
+ u16 numInterfaceAddress;
+ CsrWifiMacAddress stationMacAddress[2];
+ CsrWifiRouterCtrlSmeVersions smeVersions;
+ u8 scheduledInterrupt;
+} CsrWifiRouterCtrlWifiOnRes;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiRouterCtrlM4TransmitReq
+
+ DESCRIPTION
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ interfaceTag -
+ clientData -
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ u16 interfaceTag;
+ CsrWifiRouterCtrlRequestorInfo clientData;
+} CsrWifiRouterCtrlM4TransmitReq;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiRouterCtrlModeSetReq
+
+ DESCRIPTION
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ interfaceTag -
+ clientData -
+ mode -
+ bssid - BSSID of the network the device is going to be a part
+ of
+ protection - Set to TRUE if encryption is enabled for the
+ connection/broadcast frames
+ intraBssDistEnabled - If set to TRUE, intra BSS destribution will be
+ enabled. If set to FALSE, any unicast PDU which does
+ not have the RA as the the local MAC address, shall be
+ ignored. This field is interpreted by the receive if
+ mode is set to CSR_WIFI_ROUTER_CTRL_MODE_P2PGO
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ u16 interfaceTag;
+ CsrWifiRouterCtrlRequestorInfo clientData;
+ CsrWifiRouterCtrlMode mode;
+ CsrWifiMacAddress bssid;
+ u8 protection;
+ u8 intraBssDistEnabled;
+} CsrWifiRouterCtrlModeSetReq;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiRouterCtrlPeerAddReq
+
+ DESCRIPTION
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ interfaceTag -
+ clientData -
+ peerMacAddress -
+ associationId -
+ staInfo -
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ u16 interfaceTag;
+ CsrWifiRouterCtrlRequestorInfo clientData;
+ CsrWifiMacAddress peerMacAddress;
+ u16 associationId;
+ CsrWifiRouterCtrlStaInfo staInfo;
+} CsrWifiRouterCtrlPeerAddReq;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiRouterCtrlPeerDelReq
+
+ DESCRIPTION
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ interfaceTag -
+ clientData -
+ peerRecordHandle -
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ u16 interfaceTag;
+ CsrWifiRouterCtrlRequestorInfo clientData;
+ CsrWifiRouterCtrlPeerRecordHandle peerRecordHandle;
+} CsrWifiRouterCtrlPeerDelReq;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiRouterCtrlPeerUpdateReq
+
+ DESCRIPTION
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ interfaceTag -
+ clientData -
+ peerRecordHandle -
+ powersaveMode -
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ u16 interfaceTag;
+ CsrWifiRouterCtrlRequestorInfo clientData;
+ CsrWifiRouterCtrlPeerRecordHandle peerRecordHandle;
+ CsrWifiRouterCtrlPowersaveTypeMask powersaveMode;
+} CsrWifiRouterCtrlPeerUpdateReq;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiRouterCtrlCapabilitiesReq
+
+ DESCRIPTION
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ clientData -
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ CsrWifiRouterCtrlRequestorInfo clientData;
+} CsrWifiRouterCtrlCapabilitiesReq;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiRouterCtrlBlockAckEnableReq
+
+ DESCRIPTION
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ interfaceTag -
+ clientData -
+ macAddress -
+ trafficStreamID -
+ role -
+ bufferSize -
+ timeout -
+ ssn -
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ u16 interfaceTag;
+ CsrWifiRouterCtrlRequestorInfo clientData;
+ CsrWifiMacAddress macAddress;
+ CsrWifiRouterCtrlTrafficStreamId trafficStreamID;
+ CsrWifiRouterCtrlBlockAckRole role;
+ u16 bufferSize;
+ u16 timeout;
+ u16 ssn;
+} CsrWifiRouterCtrlBlockAckEnableReq;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiRouterCtrlBlockAckDisableReq
+
+ DESCRIPTION
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ interfaceTag -
+ clientData -
+ macAddress -
+ trafficStreamID -
+ role -
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ u16 interfaceTag;
+ CsrWifiRouterCtrlRequestorInfo clientData;
+ CsrWifiMacAddress macAddress;
+ CsrWifiRouterCtrlTrafficStreamId trafficStreamID;
+ CsrWifiRouterCtrlBlockAckRole role;
+} CsrWifiRouterCtrlBlockAckDisableReq;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiRouterCtrlWapiRxPktReq
+
+ DESCRIPTION
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ interfaceTag -
+ signalLength -
+ signal -
+ dataLength -
+ data -
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ u16 interfaceTag;
+ u16 signalLength;
+ u8 *signal;
+ u16 dataLength;
+ u8 *data;
+} CsrWifiRouterCtrlWapiRxPktReq;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiRouterCtrlWapiMulticastFilterReq
+
+ DESCRIPTION
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ interfaceTag -
+ status -
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ u16 interfaceTag;
+ u8 status;
+} CsrWifiRouterCtrlWapiMulticastFilterReq;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiRouterCtrlWapiUnicastFilterReq
+
+ DESCRIPTION
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ interfaceTag -
+ status -
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ u16 interfaceTag;
+ u8 status;
+} CsrWifiRouterCtrlWapiUnicastFilterReq;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiRouterCtrlWapiUnicastTxPktReq
+
+ DESCRIPTION
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ interfaceTag -
+ dataLength -
+ data -
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ u16 interfaceTag;
+ u16 dataLength;
+ u8 *data;
+} CsrWifiRouterCtrlWapiUnicastTxPktReq;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiRouterCtrlWapiFilterReq
+
+ DESCRIPTION
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ interfaceTag -
+ isWapiConnected -
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ u16 interfaceTag;
+ u8 isWapiConnected;
+} CsrWifiRouterCtrlWapiFilterReq;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiRouterCtrlHipInd
+
+ DESCRIPTION
+ This primitive is used for transferring MLME messages from the HIP.
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ mlmeCommandLength - Length of the MLME signal
+ mlmeCommand - Pointer to the MLME signal
+ dataRef1Length - Length of the dataRef1 bulk data
+ dataRef1 - Pointer to the bulk data 1
+ dataRef2Length - Length of the dataRef2 bulk data
+ dataRef2 - Pointer to the bulk data 2
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ u16 mlmeCommandLength;
+ u8 *mlmeCommand;
+ u16 dataRef1Length;
+ u8 *dataRef1;
+ u16 dataRef2Length;
+ u8 *dataRef2;
+} CsrWifiRouterCtrlHipInd;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiRouterCtrlMulticastAddressInd
+
+ DESCRIPTION
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ clientData -
+ interfaceTag -
+ action -
+ setAddressesCount -
+ setAddresses -
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ CsrWifiRouterCtrlRequestorInfo clientData;
+ u16 interfaceTag;
+ CsrWifiRouterCtrlListAction action;
+ u8 setAddressesCount;
+ CsrWifiMacAddress *setAddresses;
+} CsrWifiRouterCtrlMulticastAddressInd;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiRouterCtrlPortConfigureCfm
+
+ DESCRIPTION
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ clientData -
+ interfaceTag -
+ status -
+ macAddress -
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ CsrWifiRouterCtrlRequestorInfo clientData;
+ u16 interfaceTag;
+ CsrResult status;
+ CsrWifiMacAddress macAddress;
+} CsrWifiRouterCtrlPortConfigureCfm;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiRouterCtrlResumeInd
+
+ DESCRIPTION
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ clientData -
+ powerMaintained -
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ CsrWifiRouterCtrlRequestorInfo clientData;
+ u8 powerMaintained;
+} CsrWifiRouterCtrlResumeInd;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiRouterCtrlSuspendInd
+
+ DESCRIPTION
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ clientData -
+ hardSuspend -
+ d3Suspend -
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ CsrWifiRouterCtrlRequestorInfo clientData;
+ u8 hardSuspend;
+ u8 d3Suspend;
+} CsrWifiRouterCtrlSuspendInd;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiRouterCtrlTclasAddCfm
+
+ DESCRIPTION
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ clientData -
+ interfaceTag -
+ status -
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ CsrWifiRouterCtrlRequestorInfo clientData;
+ u16 interfaceTag;
+ CsrResult status;
+} CsrWifiRouterCtrlTclasAddCfm;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiRouterCtrlRawSdioDeinitialiseCfm
+
+ DESCRIPTION
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ clientData -
+ result -
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ CsrWifiRouterCtrlRequestorInfo clientData;
+ CsrResult result;
+} CsrWifiRouterCtrlRawSdioDeinitialiseCfm;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiRouterCtrlRawSdioInitialiseCfm
+
+ DESCRIPTION
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ clientData -
+ result -
+ byteRead -
+ byteWrite -
+ firmwareDownload -
+ reset -
+ coreDumpPrepare -
+ byteBlockRead -
+ gpRead16 -
+ gpWrite16 -
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ CsrWifiRouterCtrlRequestorInfo clientData;
+ CsrResult result;
+ CsrWifiRouterCtrlRawSdioByteRead byteRead;
+ CsrWifiRouterCtrlRawSdioByteWrite byteWrite;
+ CsrWifiRouterCtrlRawSdioFirmwareDownload firmwareDownload;
+ CsrWifiRouterCtrlRawSdioReset reset;
+ CsrWifiRouterCtrlRawSdioCoreDumpPrepare coreDumpPrepare;
+ CsrWifiRouterCtrlRawSdioByteBlockRead byteBlockRead;
+ CsrWifiRouterCtrlRawSdioGpRead16 gpRead16;
+ CsrWifiRouterCtrlRawSdioGpWrite16 gpWrite16;
+} CsrWifiRouterCtrlRawSdioInitialiseCfm;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiRouterCtrlTclasDelCfm
+
+ DESCRIPTION
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ clientData -
+ interfaceTag -
+ status -
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ CsrWifiRouterCtrlRequestorInfo clientData;
+ u16 interfaceTag;
+ CsrResult status;
+} CsrWifiRouterCtrlTclasDelCfm;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiRouterCtrlTrafficProtocolInd
+
+ DESCRIPTION
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ clientData -
+ interfaceTag -
+ packetType -
+ direction -
+ srcAddress -
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ CsrWifiRouterCtrlRequestorInfo clientData;
+ u16 interfaceTag;
+ CsrWifiRouterCtrlTrafficPacketType packetType;
+ CsrWifiRouterCtrlProtocolDirection direction;
+ CsrWifiMacAddress srcAddress;
+} CsrWifiRouterCtrlTrafficProtocolInd;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiRouterCtrlTrafficSampleInd
+
+ DESCRIPTION
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ clientData -
+ interfaceTag -
+ stats -
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ CsrWifiRouterCtrlRequestorInfo clientData;
+ u16 interfaceTag;
+ CsrWifiRouterCtrlTrafficStats stats;
+} CsrWifiRouterCtrlTrafficSampleInd;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiRouterCtrlWifiOffInd
+
+ DESCRIPTION
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ clientData -
+ controlIndication -
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ CsrWifiRouterCtrlRequestorInfo clientData;
+ CsrWifiRouterCtrlControlIndication controlIndication;
+} CsrWifiRouterCtrlWifiOffInd;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiRouterCtrlWifiOffCfm
+
+ DESCRIPTION
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ clientData -
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ CsrWifiRouterCtrlRequestorInfo clientData;
+} CsrWifiRouterCtrlWifiOffCfm;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiRouterCtrlWifiOnInd
+
+ DESCRIPTION
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ clientData -
+ status -
+ versions -
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ CsrWifiRouterCtrlRequestorInfo clientData;
+ CsrResult status;
+ CsrWifiRouterCtrlVersions versions;
+} CsrWifiRouterCtrlWifiOnInd;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiRouterCtrlWifiOnCfm
+
+ DESCRIPTION
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ clientData -
+ status -
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ CsrWifiRouterCtrlRequestorInfo clientData;
+ CsrResult status;
+} CsrWifiRouterCtrlWifiOnCfm;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiRouterCtrlM4ReadyToSendInd
+
+ DESCRIPTION
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ clientData -
+ interfaceTag -
+ peerMacAddress -
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ CsrWifiRouterCtrlRequestorInfo clientData;
+ u16 interfaceTag;
+ CsrWifiMacAddress peerMacAddress;
+} CsrWifiRouterCtrlM4ReadyToSendInd;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiRouterCtrlM4TransmittedInd
+
+ DESCRIPTION
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ clientData -
+ interfaceTag -
+ peerMacAddress -
+ status -
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ CsrWifiRouterCtrlRequestorInfo clientData;
+ u16 interfaceTag;
+ CsrWifiMacAddress peerMacAddress;
+ CsrResult status;
+} CsrWifiRouterCtrlM4TransmittedInd;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiRouterCtrlMicFailureInd
+
+ DESCRIPTION
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ clientData -
+ interfaceTag -
+ peerMacAddress -
+ unicastPdu -
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ CsrWifiRouterCtrlRequestorInfo clientData;
+ u16 interfaceTag;
+ CsrWifiMacAddress peerMacAddress;
+ u8 unicastPdu;
+} CsrWifiRouterCtrlMicFailureInd;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiRouterCtrlConnectedInd
+
+ DESCRIPTION
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ clientData -
+ interfaceTag -
+ peerMacAddress -
+ peerStatus -
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ CsrWifiRouterCtrlRequestorInfo clientData;
+ u16 interfaceTag;
+ CsrWifiMacAddress peerMacAddress;
+ CsrWifiRouterCtrlPeerStatus peerStatus;
+} CsrWifiRouterCtrlConnectedInd;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiRouterCtrlPeerAddCfm
+
+ DESCRIPTION
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ clientData -
+ interfaceTag -
+ peerMacAddress -
+ peerRecordHandle -
+ status -
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ CsrWifiRouterCtrlRequestorInfo clientData;
+ u16 interfaceTag;
+ CsrWifiMacAddress peerMacAddress;
+ CsrWifiRouterCtrlPeerRecordHandle peerRecordHandle;
+ CsrResult status;
+} CsrWifiRouterCtrlPeerAddCfm;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiRouterCtrlPeerDelCfm
+
+ DESCRIPTION
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ clientData -
+ interfaceTag -
+ status -
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ CsrWifiRouterCtrlRequestorInfo clientData;
+ u16 interfaceTag;
+ CsrResult status;
+} CsrWifiRouterCtrlPeerDelCfm;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiRouterCtrlUnexpectedFrameInd
+
+ DESCRIPTION
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ clientData -
+ interfaceTag -
+ peerMacAddress -
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ CsrWifiRouterCtrlRequestorInfo clientData;
+ u16 interfaceTag;
+ CsrWifiMacAddress peerMacAddress;
+} CsrWifiRouterCtrlUnexpectedFrameInd;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiRouterCtrlPeerUpdateCfm
+
+ DESCRIPTION
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ clientData -
+ interfaceTag -
+ status -
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ CsrWifiRouterCtrlRequestorInfo clientData;
+ u16 interfaceTag;
+ CsrResult status;
+} CsrWifiRouterCtrlPeerUpdateCfm;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiRouterCtrlCapabilitiesCfm
+
+ DESCRIPTION
+ The router sends this primitive to confirm the size of the queues of the
+ HIP.
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ clientData -
+ commandQueueSize - Size of command queue
+ trafficQueueSize - Size of traffic queue (per AC)
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ CsrWifiRouterCtrlRequestorInfo clientData;
+ u16 commandQueueSize;
+ u16 trafficQueueSize;
+} CsrWifiRouterCtrlCapabilitiesCfm;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiRouterCtrlBlockAckEnableCfm
+
+ DESCRIPTION
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ clientData -
+ interfaceTag -
+ status -
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ CsrWifiRouterCtrlRequestorInfo clientData;
+ u16 interfaceTag;
+ CsrResult status;
+} CsrWifiRouterCtrlBlockAckEnableCfm;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiRouterCtrlBlockAckDisableCfm
+
+ DESCRIPTION
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ clientData -
+ interfaceTag -
+ status -
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ CsrWifiRouterCtrlRequestorInfo clientData;
+ u16 interfaceTag;
+ CsrResult status;
+} CsrWifiRouterCtrlBlockAckDisableCfm;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiRouterCtrlBlockAckErrorInd
+
+ DESCRIPTION
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ clientData -
+ interfaceTag -
+ trafficStreamID -
+ peerMacAddress -
+ status -
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ CsrWifiRouterCtrlRequestorInfo clientData;
+ u16 interfaceTag;
+ CsrWifiRouterCtrlTrafficStreamId trafficStreamID;
+ CsrWifiMacAddress peerMacAddress;
+ CsrResult status;
+} CsrWifiRouterCtrlBlockAckErrorInd;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiRouterCtrlStaInactiveInd
+
+ DESCRIPTION
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ clientData -
+ interfaceTag -
+ staAddress -
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ CsrWifiRouterCtrlRequestorInfo clientData;
+ u16 interfaceTag;
+ CsrWifiMacAddress staAddress;
+} CsrWifiRouterCtrlStaInactiveInd;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiRouterCtrlWapiRxMicCheckInd
+
+ DESCRIPTION
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ clientData -
+ interfaceTag -
+ signalLength -
+ signal -
+ dataLength -
+ data -
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ CsrWifiRouterCtrlRequestorInfo clientData;
+ u16 interfaceTag;
+ u16 signalLength;
+ u8 *signal;
+ u16 dataLength;
+ u8 *data;
+} CsrWifiRouterCtrlWapiRxMicCheckInd;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiRouterCtrlModeSetCfm
+
+ DESCRIPTION
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ clientData -
+ interfaceTag -
+ mode -
+ status -
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ CsrWifiRouterCtrlRequestorInfo clientData;
+ u16 interfaceTag;
+ CsrWifiRouterCtrlMode mode;
+ CsrResult status;
+} CsrWifiRouterCtrlModeSetCfm;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiRouterCtrlWapiUnicastTxEncryptInd
+
+ DESCRIPTION
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ clientData -
+ interfaceTag -
+ dataLength -
+ data -
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ CsrWifiRouterCtrlRequestorInfo clientData;
+ u16 interfaceTag;
+ u16 dataLength;
+ u8 *data;
+} CsrWifiRouterCtrlWapiUnicastTxEncryptInd;
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* CSR_WIFI_ROUTER_CTRL_PRIM_H__ */
+
diff --git a/drivers/staging/csr/csr_wifi_router_ctrl_sef.c b/drivers/staging/csr/csr_wifi_router_ctrl_sef.c
new file mode 100644
index 000000000000..33d92b698c59
--- /dev/null
+++ b/drivers/staging/csr/csr_wifi_router_ctrl_sef.c
@@ -0,0 +1,45 @@
+/*****************************************************************************
+
+ (c) Cambridge Silicon Radio Limited 2010
+ Confidential information of CSR
+
+ Refer to LICENSE.txt included with this source for details
+ on the license terms.
+
+ *****************************************************************************/
+#include "csr_wifi_router_ctrl_sef.h"
+
+const CsrWifiRouterCtrlStateHandlerType CsrWifiRouterCtrlDownstreamStateHandlers[CSR_WIFI_ROUTER_CTRL_PRIM_DOWNSTREAM_COUNT] =
+{
+ /* 0x0000 */ CsrWifiRouterCtrlConfigurePowerModeReqHandler,
+ /* 0x0001 */ CsrWifiRouterCtrlHipReqHandler,
+ /* 0x0002 */ CsrWifiRouterCtrlMediaStatusReqHandler,
+ /* 0x0003 */ CsrWifiRouterCtrlMulticastAddressResHandler,
+ /* 0x0004 */ CsrWifiRouterCtrlPortConfigureReqHandler,
+ /* 0x0005 */ CsrWifiRouterCtrlQosControlReqHandler,
+ /* 0x0006 */ CsrWifiRouterCtrlSuspendResHandler,
+ /* 0x0007 */ CsrWifiRouterCtrlTclasAddReqHandler,
+ /* 0x0008 */ CsrWifiRouterCtrlResumeResHandler,
+ /* 0x0009 */ CsrWifiRouterCtrlRawSdioDeinitialiseReqHandler,
+ /* 0x000A */ CsrWifiRouterCtrlRawSdioInitialiseReqHandler,
+ /* 0x000B */ CsrWifiRouterCtrlTclasDelReqHandler,
+ /* 0x000C */ CsrWifiRouterCtrlTrafficClassificationReqHandler,
+ /* 0x000D */ CsrWifiRouterCtrlTrafficConfigReqHandler,
+ /* 0x000E */ CsrWifiRouterCtrlWifiOffReqHandler,
+ /* 0x000F */ CsrWifiRouterCtrlWifiOffResHandler,
+ /* 0x0010 */ CsrWifiRouterCtrlWifiOnReqHandler,
+ /* 0x0011 */ CsrWifiRouterCtrlWifiOnResHandler,
+ /* 0x0012 */ CsrWifiRouterCtrlM4TransmitReqHandler,
+ /* 0x0013 */ CsrWifiRouterCtrlModeSetReqHandler,
+ /* 0x0014 */ CsrWifiRouterCtrlPeerAddReqHandler,
+ /* 0x0015 */ CsrWifiRouterCtrlPeerDelReqHandler,
+ /* 0x0016 */ CsrWifiRouterCtrlPeerUpdateReqHandler,
+ /* 0x0017 */ CsrWifiRouterCtrlCapabilitiesReqHandler,
+ /* 0x0018 */ CsrWifiRouterCtrlBlockAckEnableReqHandler,
+ /* 0x0019 */ CsrWifiRouterCtrlBlockAckDisableReqHandler,
+ /* 0x001A */ CsrWifiRouterCtrlWapiRxPktReqHandler,
+ /* 0x001B */ CsrWifiRouterCtrlWapiMulticastFilterReqHandler,
+ /* 0x001C */ CsrWifiRouterCtrlWapiUnicastFilterReqHandler,
+ /* 0x001D */ CsrWifiRouterCtrlWapiUnicastTxPktReqHandler,
+ /* 0x001E */ CsrWifiRouterCtrlWapiFilterReqHandler,
+};
diff --git a/drivers/staging/csr/csr_wifi_router_ctrl_sef.h b/drivers/staging/csr/csr_wifi_router_ctrl_sef.h
new file mode 100644
index 000000000000..e0ee5cf45f9e
--- /dev/null
+++ b/drivers/staging/csr/csr_wifi_router_ctrl_sef.h
@@ -0,0 +1,58 @@
+/*****************************************************************************
+
+ (c) Cambridge Silicon Radio Limited 2010
+ Confidential information of CSR
+
+ Refer to LICENSE.txt included with this source for details
+ on the license terms.
+
+ *****************************************************************************/
+#ifndef CSR_WIFI_ROUTER_SEF_CSR_WIFI_ROUTER_CTRL_H__
+#define CSR_WIFI_ROUTER_SEF_CSR_WIFI_ROUTER_CTRL_H__
+
+#include "csr_wifi_router_ctrl_prim.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+ typedef void (*CsrWifiRouterCtrlStateHandlerType)(void* drvpriv, CsrWifiFsmEvent* msg);
+
+ extern const CsrWifiRouterCtrlStateHandlerType CsrWifiRouterCtrlDownstreamStateHandlers[CSR_WIFI_ROUTER_CTRL_PRIM_DOWNSTREAM_COUNT];
+
+ extern void CsrWifiRouterCtrlConfigurePowerModeReqHandler(void* drvpriv, CsrWifiFsmEvent* msg);
+ extern void CsrWifiRouterCtrlHipReqHandler(void* drvpriv, CsrWifiFsmEvent* msg);
+ extern void CsrWifiRouterCtrlMediaStatusReqHandler(void* drvpriv, CsrWifiFsmEvent* msg);
+ extern void CsrWifiRouterCtrlMulticastAddressResHandler(void* drvpriv, CsrWifiFsmEvent* msg);
+ extern void CsrWifiRouterCtrlPortConfigureReqHandler(void* drvpriv, CsrWifiFsmEvent* msg);
+ extern void CsrWifiRouterCtrlQosControlReqHandler(void* drvpriv, CsrWifiFsmEvent* msg);
+ extern void CsrWifiRouterCtrlSuspendResHandler(void* drvpriv, CsrWifiFsmEvent* msg);
+ extern void CsrWifiRouterCtrlTclasAddReqHandler(void* drvpriv, CsrWifiFsmEvent* msg);
+ extern void CsrWifiRouterCtrlResumeResHandler(void* drvpriv, CsrWifiFsmEvent* msg);
+ extern void CsrWifiRouterCtrlRawSdioDeinitialiseReqHandler(void* drvpriv, CsrWifiFsmEvent* msg);
+ extern void CsrWifiRouterCtrlRawSdioInitialiseReqHandler(void* drvpriv, CsrWifiFsmEvent* msg);
+ extern void CsrWifiRouterCtrlTclasDelReqHandler(void* drvpriv, CsrWifiFsmEvent* msg);
+ extern void CsrWifiRouterCtrlTrafficClassificationReqHandler(void* drvpriv, CsrWifiFsmEvent* msg);
+ extern void CsrWifiRouterCtrlTrafficConfigReqHandler(void* drvpriv, CsrWifiFsmEvent* msg);
+ extern void CsrWifiRouterCtrlWifiOffReqHandler(void* drvpriv, CsrWifiFsmEvent* msg);
+ extern void CsrWifiRouterCtrlWifiOffResHandler(void* drvpriv, CsrWifiFsmEvent* msg);
+ extern void CsrWifiRouterCtrlWifiOnReqHandler(void* drvpriv, CsrWifiFsmEvent* msg);
+ extern void CsrWifiRouterCtrlWifiOnResHandler(void* drvpriv, CsrWifiFsmEvent* msg);
+ extern void CsrWifiRouterCtrlM4TransmitReqHandler(void* drvpriv, CsrWifiFsmEvent* msg);
+ extern void CsrWifiRouterCtrlModeSetReqHandler(void* drvpriv, CsrWifiFsmEvent* msg);
+ extern void CsrWifiRouterCtrlPeerAddReqHandler(void* drvpriv, CsrWifiFsmEvent* msg);
+ extern void CsrWifiRouterCtrlPeerDelReqHandler(void* drvpriv, CsrWifiFsmEvent* msg);
+ extern void CsrWifiRouterCtrlPeerUpdateReqHandler(void* drvpriv, CsrWifiFsmEvent* msg);
+ extern void CsrWifiRouterCtrlCapabilitiesReqHandler(void* drvpriv, CsrWifiFsmEvent* msg);
+ extern void CsrWifiRouterCtrlBlockAckEnableReqHandler(void* drvpriv, CsrWifiFsmEvent* msg);
+ extern void CsrWifiRouterCtrlBlockAckDisableReqHandler(void* drvpriv, CsrWifiFsmEvent* msg);
+ extern void CsrWifiRouterCtrlWapiMulticastFilterReqHandler(void* drvpriv, CsrWifiFsmEvent* msg);
+ extern void CsrWifiRouterCtrlWapiRxPktReqHandler(void* drvpriv, CsrWifiFsmEvent* msg);
+ extern void CsrWifiRouterCtrlWapiUnicastTxPktReqHandler(void* drvpriv, CsrWifiFsmEvent* msg);
+ extern void CsrWifiRouterCtrlWapiUnicastFilterReqHandler(void* drvpriv, CsrWifiFsmEvent* msg);
+ extern void CsrWifiRouterCtrlWapiFilterReqHandler(void* drvpriv, CsrWifiFsmEvent* msg);
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* CSR_WIFI_ROUTER_SEF_CSR_WIFI_ROUTER_CTRL_H__ */
diff --git a/drivers/staging/csr/csr_wifi_router_ctrl_serialize.c b/drivers/staging/csr/csr_wifi_router_ctrl_serialize.c
new file mode 100644
index 000000000000..3eda1b66b336
--- /dev/null
+++ b/drivers/staging/csr/csr_wifi_router_ctrl_serialize.c
@@ -0,0 +1,2591 @@
+/*****************************************************************************
+
+ (c) Cambridge Silicon Radio Limited 2012
+ All rights reserved and confidential information of CSR
+
+ Refer to LICENSE.txt included with this source for details
+ on the license terms.
+
+*****************************************************************************/
+
+/* Note: this is an auto-generated file. */
+#include <linux/string.h>
+#include <linux/slab.h>
+#include "csr_msgconv.h"
+#include "csr_wifi_router_ctrl_prim.h"
+#include "csr_wifi_router_ctrl_serialize.h"
+
+void CsrWifiRouterCtrlPfree(void *ptr)
+{
+ kfree(ptr);
+}
+
+
+size_t CsrWifiRouterCtrlConfigurePowerModeReqSizeof(void *msg)
+{
+ size_t bufferSize = 2;
+
+ /* Calculate the Size of the Serialised Data. Could be more efficient (Try 8) */
+ bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */
+ bufferSize += 2; /* CsrWifiRouterCtrlLowPowerMode primitive->mode */
+ bufferSize += 1; /* u8 primitive->wakeHost */
+ return bufferSize;
+}
+
+
+u8* CsrWifiRouterCtrlConfigurePowerModeReqSer(u8 *ptr, size_t *len, void *msg)
+{
+ CsrWifiRouterCtrlConfigurePowerModeReq *primitive = (CsrWifiRouterCtrlConfigurePowerModeReq *)msg;
+ *len = 0;
+ CsrUint16Ser(ptr, len, primitive->common.type);
+ CsrUint16Ser(ptr, len, (u16) primitive->clientData);
+ CsrUint16Ser(ptr, len, (u16) primitive->mode);
+ CsrUint8Ser(ptr, len, (u8) primitive->wakeHost);
+ return(ptr);
+}
+
+
+void* CsrWifiRouterCtrlConfigurePowerModeReqDes(u8 *buffer, size_t length)
+{
+ CsrWifiRouterCtrlConfigurePowerModeReq *primitive = kmalloc(sizeof(CsrWifiRouterCtrlConfigurePowerModeReq), GFP_KERNEL);
+ size_t offset;
+ offset = 0;
+
+ CsrUint16Des(&primitive->common.type, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->mode, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->wakeHost, buffer, &offset);
+
+ return primitive;
+}
+
+
+size_t CsrWifiRouterCtrlHipReqSizeof(void *msg)
+{
+ CsrWifiRouterCtrlHipReq *primitive = (CsrWifiRouterCtrlHipReq *) msg;
+ size_t bufferSize = 2;
+
+ /* Calculate the Size of the Serialised Data. Could be more efficient (Try 12) */
+ bufferSize += 2; /* u16 primitive->mlmeCommandLength */
+ bufferSize += primitive->mlmeCommandLength; /* u8 primitive->mlmeCommand */
+ bufferSize += 2; /* u16 primitive->dataRef1Length */
+ bufferSize += primitive->dataRef1Length; /* u8 primitive->dataRef1 */
+ bufferSize += 2; /* u16 primitive->dataRef2Length */
+ bufferSize += primitive->dataRef2Length; /* u8 primitive->dataRef2 */
+ return bufferSize;
+}
+
+
+u8* CsrWifiRouterCtrlHipReqSer(u8 *ptr, size_t *len, void *msg)
+{
+ CsrWifiRouterCtrlHipReq *primitive = (CsrWifiRouterCtrlHipReq *)msg;
+ *len = 0;
+ CsrUint16Ser(ptr, len, primitive->common.type);
+ CsrUint16Ser(ptr, len, (u16) primitive->mlmeCommandLength);
+ if (primitive->mlmeCommandLength)
+ {
+ CsrMemCpySer(ptr, len, (const void *) primitive->mlmeCommand, ((u16) (primitive->mlmeCommandLength)));
+ }
+ CsrUint16Ser(ptr, len, (u16) primitive->dataRef1Length);
+ if (primitive->dataRef1Length)
+ {
+ CsrMemCpySer(ptr, len, (const void *) primitive->dataRef1, ((u16) (primitive->dataRef1Length)));
+ }
+ CsrUint16Ser(ptr, len, (u16) primitive->dataRef2Length);
+ if (primitive->dataRef2Length)
+ {
+ CsrMemCpySer(ptr, len, (const void *) primitive->dataRef2, ((u16) (primitive->dataRef2Length)));
+ }
+ return(ptr);
+}
+
+
+void* CsrWifiRouterCtrlHipReqDes(u8 *buffer, size_t length)
+{
+ CsrWifiRouterCtrlHipReq *primitive = kmalloc(sizeof(CsrWifiRouterCtrlHipReq), GFP_KERNEL);
+ size_t offset;
+ offset = 0;
+
+ CsrUint16Des(&primitive->common.type, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->mlmeCommandLength, buffer, &offset);
+ if (primitive->mlmeCommandLength)
+ {
+ primitive->mlmeCommand = kmalloc(primitive->mlmeCommandLength, GFP_KERNEL);
+ CsrMemCpyDes(primitive->mlmeCommand, buffer, &offset, ((u16) (primitive->mlmeCommandLength)));
+ }
+ else
+ {
+ primitive->mlmeCommand = NULL;
+ }
+ CsrUint16Des((u16 *) &primitive->dataRef1Length, buffer, &offset);
+ if (primitive->dataRef1Length)
+ {
+ primitive->dataRef1 = kmalloc(primitive->dataRef1Length, GFP_KERNEL);
+ CsrMemCpyDes(primitive->dataRef1, buffer, &offset, ((u16) (primitive->dataRef1Length)));
+ }
+ else
+ {
+ primitive->dataRef1 = NULL;
+ }
+ CsrUint16Des((u16 *) &primitive->dataRef2Length, buffer, &offset);
+ if (primitive->dataRef2Length)
+ {
+ primitive->dataRef2 = kmalloc(primitive->dataRef2Length, GFP_KERNEL);
+ CsrMemCpyDes(primitive->dataRef2, buffer, &offset, ((u16) (primitive->dataRef2Length)));
+ }
+ else
+ {
+ primitive->dataRef2 = NULL;
+ }
+
+ return primitive;
+}
+
+
+void CsrWifiRouterCtrlHipReqSerFree(void *voidPrimitivePointer)
+{
+ CsrWifiRouterCtrlHipReq *primitive = (CsrWifiRouterCtrlHipReq *) voidPrimitivePointer;
+ kfree(primitive->mlmeCommand);
+ kfree(primitive->dataRef1);
+ kfree(primitive->dataRef2);
+ kfree(primitive);
+}
+
+
+size_t CsrWifiRouterCtrlMediaStatusReqSizeof(void *msg)
+{
+ size_t bufferSize = 2;
+
+ /* Calculate the Size of the Serialised Data. Could be more efficient (Try 8) */
+ bufferSize += 2; /* u16 primitive->interfaceTag */
+ bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */
+ bufferSize += 1; /* CsrWifiRouterCtrlMediaStatus primitive->mediaStatus */
+ return bufferSize;
+}
+
+
+u8* CsrWifiRouterCtrlMediaStatusReqSer(u8 *ptr, size_t *len, void *msg)
+{
+ CsrWifiRouterCtrlMediaStatusReq *primitive = (CsrWifiRouterCtrlMediaStatusReq *)msg;
+ *len = 0;
+ CsrUint16Ser(ptr, len, primitive->common.type);
+ CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
+ CsrUint16Ser(ptr, len, (u16) primitive->clientData);
+ CsrUint8Ser(ptr, len, (u8) primitive->mediaStatus);
+ return(ptr);
+}
+
+
+void* CsrWifiRouterCtrlMediaStatusReqDes(u8 *buffer, size_t length)
+{
+ CsrWifiRouterCtrlMediaStatusReq *primitive = kmalloc(sizeof(CsrWifiRouterCtrlMediaStatusReq), GFP_KERNEL);
+ size_t offset;
+ offset = 0;
+
+ CsrUint16Des(&primitive->common.type, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->mediaStatus, buffer, &offset);
+
+ return primitive;
+}
+
+
+size_t CsrWifiRouterCtrlMulticastAddressResSizeof(void *msg)
+{
+ CsrWifiRouterCtrlMulticastAddressRes *primitive = (CsrWifiRouterCtrlMulticastAddressRes *) msg;
+ size_t bufferSize = 2;
+
+ /* Calculate the Size of the Serialised Data. Could be more efficient (Try 17) */
+ bufferSize += 2; /* u16 primitive->interfaceTag */
+ bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */
+ bufferSize += 2; /* CsrResult primitive->status */
+ bufferSize += 1; /* CsrWifiRouterCtrlListAction primitive->action */
+ bufferSize += 1; /* u8 primitive->getAddressesCount */
+ {
+ u16 i1;
+ for (i1 = 0; i1 < primitive->getAddressesCount; i1++)
+ {
+ bufferSize += 6; /* u8 primitive->getAddresses[i1].a[6] */
+ }
+ }
+ return bufferSize;
+}
+
+
+u8* CsrWifiRouterCtrlMulticastAddressResSer(u8 *ptr, size_t *len, void *msg)
+{
+ CsrWifiRouterCtrlMulticastAddressRes *primitive = (CsrWifiRouterCtrlMulticastAddressRes *)msg;
+ *len = 0;
+ CsrUint16Ser(ptr, len, primitive->common.type);
+ CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
+ CsrUint16Ser(ptr, len, (u16) primitive->clientData);
+ CsrUint16Ser(ptr, len, (u16) primitive->status);
+ CsrUint8Ser(ptr, len, (u8) primitive->action);
+ CsrUint8Ser(ptr, len, (u8) primitive->getAddressesCount);
+ {
+ u16 i1;
+ for (i1 = 0; i1 < primitive->getAddressesCount; i1++)
+ {
+ CsrMemCpySer(ptr, len, (const void *) primitive->getAddresses[i1].a, ((u16) (6)));
+ }
+ }
+ return(ptr);
+}
+
+
+void* CsrWifiRouterCtrlMulticastAddressResDes(u8 *buffer, size_t length)
+{
+ CsrWifiRouterCtrlMulticastAddressRes *primitive = kmalloc(sizeof(CsrWifiRouterCtrlMulticastAddressRes), GFP_KERNEL);
+ size_t offset;
+ offset = 0;
+
+ CsrUint16Des(&primitive->common.type, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->action, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->getAddressesCount, buffer, &offset);
+ primitive->getAddresses = NULL;
+ if (primitive->getAddressesCount)
+ {
+ primitive->getAddresses = kmalloc(sizeof(CsrWifiMacAddress) * primitive->getAddressesCount, GFP_KERNEL);
+ }
+ {
+ u16 i1;
+ for (i1 = 0; i1 < primitive->getAddressesCount; i1++)
+ {
+ CsrMemCpyDes(primitive->getAddresses[i1].a, buffer, &offset, ((u16) (6)));
+ }
+ }
+
+ return primitive;
+}
+
+
+void CsrWifiRouterCtrlMulticastAddressResSerFree(void *voidPrimitivePointer)
+{
+ CsrWifiRouterCtrlMulticastAddressRes *primitive = (CsrWifiRouterCtrlMulticastAddressRes *) voidPrimitivePointer;
+ kfree(primitive->getAddresses);
+ kfree(primitive);
+}
+
+
+size_t CsrWifiRouterCtrlPortConfigureReqSizeof(void *msg)
+{
+ size_t bufferSize = 2;
+
+ /* Calculate the Size of the Serialised Data. Could be more efficient (Try 18) */
+ bufferSize += 2; /* u16 primitive->interfaceTag */
+ bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */
+ bufferSize += 2; /* CsrWifiRouterCtrlPortAction primitive->uncontrolledPortAction */
+ bufferSize += 2; /* CsrWifiRouterCtrlPortAction primitive->controlledPortAction */
+ bufferSize += 6; /* u8 primitive->macAddress.a[6] */
+ bufferSize += 1; /* u8 primitive->setProtection */
+ return bufferSize;
+}
+
+
+u8* CsrWifiRouterCtrlPortConfigureReqSer(u8 *ptr, size_t *len, void *msg)
+{
+ CsrWifiRouterCtrlPortConfigureReq *primitive = (CsrWifiRouterCtrlPortConfigureReq *)msg;
+ *len = 0;
+ CsrUint16Ser(ptr, len, primitive->common.type);
+ CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
+ CsrUint16Ser(ptr, len, (u16) primitive->clientData);
+ CsrUint16Ser(ptr, len, (u16) primitive->uncontrolledPortAction);
+ CsrUint16Ser(ptr, len, (u16) primitive->controlledPortAction);
+ CsrMemCpySer(ptr, len, (const void *) primitive->macAddress.a, ((u16) (6)));
+ CsrUint8Ser(ptr, len, (u8) primitive->setProtection);
+ return(ptr);
+}
+
+
+void* CsrWifiRouterCtrlPortConfigureReqDes(u8 *buffer, size_t length)
+{
+ CsrWifiRouterCtrlPortConfigureReq *primitive = kmalloc(sizeof(CsrWifiRouterCtrlPortConfigureReq), GFP_KERNEL);
+ size_t offset;
+ offset = 0;
+
+ CsrUint16Des(&primitive->common.type, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->uncontrolledPortAction, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->controlledPortAction, buffer, &offset);
+ CsrMemCpyDes(primitive->macAddress.a, buffer, &offset, ((u16) (6)));
+ CsrUint8Des((u8 *) &primitive->setProtection, buffer, &offset);
+
+ return primitive;
+}
+
+
+size_t CsrWifiRouterCtrlQosControlReqSizeof(void *msg)
+{
+ size_t bufferSize = 2;
+
+ /* Calculate the Size of the Serialised Data. Could be more efficient (Try 10) */
+ bufferSize += 2; /* u16 primitive->interfaceTag */
+ bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */
+ bufferSize += 2; /* CsrWifiRouterCtrlQoSControl primitive->control */
+ bufferSize += 1; /* CsrWifiRouterCtrlQueueConfigMask primitive->queueConfig */
+ return bufferSize;
+}
+
+
+u8* CsrWifiRouterCtrlQosControlReqSer(u8 *ptr, size_t *len, void *msg)
+{
+ CsrWifiRouterCtrlQosControlReq *primitive = (CsrWifiRouterCtrlQosControlReq *)msg;
+ *len = 0;
+ CsrUint16Ser(ptr, len, primitive->common.type);
+ CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
+ CsrUint16Ser(ptr, len, (u16) primitive->clientData);
+ CsrUint16Ser(ptr, len, (u16) primitive->control);
+ CsrUint8Ser(ptr, len, (u8) primitive->queueConfig);
+ return(ptr);
+}
+
+
+void* CsrWifiRouterCtrlQosControlReqDes(u8 *buffer, size_t length)
+{
+ CsrWifiRouterCtrlQosControlReq *primitive = kmalloc(sizeof(CsrWifiRouterCtrlQosControlReq), GFP_KERNEL);
+ size_t offset;
+ offset = 0;
+
+ CsrUint16Des(&primitive->common.type, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->control, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->queueConfig, buffer, &offset);
+
+ return primitive;
+}
+
+
+size_t CsrWifiRouterCtrlSuspendResSizeof(void *msg)
+{
+ size_t bufferSize = 2;
+
+ /* Calculate the Size of the Serialised Data. Could be more efficient (Try 7) */
+ bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */
+ bufferSize += 2; /* CsrResult primitive->status */
+ return bufferSize;
+}
+
+
+u8* CsrWifiRouterCtrlSuspendResSer(u8 *ptr, size_t *len, void *msg)
+{
+ CsrWifiRouterCtrlSuspendRes *primitive = (CsrWifiRouterCtrlSuspendRes *)msg;
+ *len = 0;
+ CsrUint16Ser(ptr, len, primitive->common.type);
+ CsrUint16Ser(ptr, len, (u16) primitive->clientData);
+ CsrUint16Ser(ptr, len, (u16) primitive->status);
+ return(ptr);
+}
+
+
+void* CsrWifiRouterCtrlSuspendResDes(u8 *buffer, size_t length)
+{
+ CsrWifiRouterCtrlSuspendRes *primitive = kmalloc(sizeof(CsrWifiRouterCtrlSuspendRes), GFP_KERNEL);
+ size_t offset;
+ offset = 0;
+
+ CsrUint16Des(&primitive->common.type, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
+
+ return primitive;
+}
+
+
+size_t CsrWifiRouterCtrlTclasAddReqSizeof(void *msg)
+{
+ CsrWifiRouterCtrlTclasAddReq *primitive = (CsrWifiRouterCtrlTclasAddReq *) msg;
+ size_t bufferSize = 2;
+
+ /* Calculate the Size of the Serialised Data. Could be more efficient (Try 10) */
+ bufferSize += 2; /* u16 primitive->interfaceTag */
+ bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */
+ bufferSize += 2; /* u16 primitive->tclasLength */
+ bufferSize += primitive->tclasLength; /* u8 primitive->tclas */
+ return bufferSize;
+}
+
+
+u8* CsrWifiRouterCtrlTclasAddReqSer(u8 *ptr, size_t *len, void *msg)
+{
+ CsrWifiRouterCtrlTclasAddReq *primitive = (CsrWifiRouterCtrlTclasAddReq *)msg;
+ *len = 0;
+ CsrUint16Ser(ptr, len, primitive->common.type);
+ CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
+ CsrUint16Ser(ptr, len, (u16) primitive->clientData);
+ CsrUint16Ser(ptr, len, (u16) primitive->tclasLength);
+ if (primitive->tclasLength)
+ {
+ CsrMemCpySer(ptr, len, (const void *) primitive->tclas, ((u16) (primitive->tclasLength)));
+ }
+ return(ptr);
+}
+
+
+void* CsrWifiRouterCtrlTclasAddReqDes(u8 *buffer, size_t length)
+{
+ CsrWifiRouterCtrlTclasAddReq *primitive = kmalloc(sizeof(CsrWifiRouterCtrlTclasAddReq), GFP_KERNEL);
+ size_t offset;
+ offset = 0;
+
+ CsrUint16Des(&primitive->common.type, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->tclasLength, buffer, &offset);
+ if (primitive->tclasLength)
+ {
+ primitive->tclas = kmalloc(primitive->tclasLength, GFP_KERNEL);
+ CsrMemCpyDes(primitive->tclas, buffer, &offset, ((u16) (primitive->tclasLength)));
+ }
+ else
+ {
+ primitive->tclas = NULL;
+ }
+
+ return primitive;
+}
+
+
+void CsrWifiRouterCtrlTclasAddReqSerFree(void *voidPrimitivePointer)
+{
+ CsrWifiRouterCtrlTclasAddReq *primitive = (CsrWifiRouterCtrlTclasAddReq *) voidPrimitivePointer;
+ kfree(primitive->tclas);
+ kfree(primitive);
+}
+
+
+size_t CsrWifiRouterCtrlResumeResSizeof(void *msg)
+{
+ size_t bufferSize = 2;
+
+ /* Calculate the Size of the Serialised Data. Could be more efficient (Try 7) */
+ bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */
+ bufferSize += 2; /* CsrResult primitive->status */
+ return bufferSize;
+}
+
+
+u8* CsrWifiRouterCtrlResumeResSer(u8 *ptr, size_t *len, void *msg)
+{
+ CsrWifiRouterCtrlResumeRes *primitive = (CsrWifiRouterCtrlResumeRes *)msg;
+ *len = 0;
+ CsrUint16Ser(ptr, len, primitive->common.type);
+ CsrUint16Ser(ptr, len, (u16) primitive->clientData);
+ CsrUint16Ser(ptr, len, (u16) primitive->status);
+ return(ptr);
+}
+
+
+void* CsrWifiRouterCtrlResumeResDes(u8 *buffer, size_t length)
+{
+ CsrWifiRouterCtrlResumeRes *primitive = kmalloc(sizeof(CsrWifiRouterCtrlResumeRes), GFP_KERNEL);
+ size_t offset;
+ offset = 0;
+
+ CsrUint16Des(&primitive->common.type, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
+
+ return primitive;
+}
+
+
+size_t CsrWifiRouterCtrlTclasDelReqSizeof(void *msg)
+{
+ CsrWifiRouterCtrlTclasDelReq *primitive = (CsrWifiRouterCtrlTclasDelReq *) msg;
+ size_t bufferSize = 2;
+
+ /* Calculate the Size of the Serialised Data. Could be more efficient (Try 10) */
+ bufferSize += 2; /* u16 primitive->interfaceTag */
+ bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */
+ bufferSize += 2; /* u16 primitive->tclasLength */
+ bufferSize += primitive->tclasLength; /* u8 primitive->tclas */
+ return bufferSize;
+}
+
+
+u8* CsrWifiRouterCtrlTclasDelReqSer(u8 *ptr, size_t *len, void *msg)
+{
+ CsrWifiRouterCtrlTclasDelReq *primitive = (CsrWifiRouterCtrlTclasDelReq *)msg;
+ *len = 0;
+ CsrUint16Ser(ptr, len, primitive->common.type);
+ CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
+ CsrUint16Ser(ptr, len, (u16) primitive->clientData);
+ CsrUint16Ser(ptr, len, (u16) primitive->tclasLength);
+ if (primitive->tclasLength)
+ {
+ CsrMemCpySer(ptr, len, (const void *) primitive->tclas, ((u16) (primitive->tclasLength)));
+ }
+ return(ptr);
+}
+
+
+void* CsrWifiRouterCtrlTclasDelReqDes(u8 *buffer, size_t length)
+{
+ CsrWifiRouterCtrlTclasDelReq *primitive = kmalloc(sizeof(CsrWifiRouterCtrlTclasDelReq), GFP_KERNEL);
+ size_t offset;
+ offset = 0;
+
+ CsrUint16Des(&primitive->common.type, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->tclasLength, buffer, &offset);
+ if (primitive->tclasLength)
+ {
+ primitive->tclas = kmalloc(primitive->tclasLength, GFP_KERNEL);
+ CsrMemCpyDes(primitive->tclas, buffer, &offset, ((u16) (primitive->tclasLength)));
+ }
+ else
+ {
+ primitive->tclas = NULL;
+ }
+
+ return primitive;
+}
+
+
+void CsrWifiRouterCtrlTclasDelReqSerFree(void *voidPrimitivePointer)
+{
+ CsrWifiRouterCtrlTclasDelReq *primitive = (CsrWifiRouterCtrlTclasDelReq *) voidPrimitivePointer;
+ kfree(primitive->tclas);
+ kfree(primitive);
+}
+
+
+size_t CsrWifiRouterCtrlTrafficClassificationReqSizeof(void *msg)
+{
+ size_t bufferSize = 2;
+
+ /* Calculate the Size of the Serialised Data. Could be more efficient (Try 10) */
+ bufferSize += 2; /* u16 primitive->interfaceTag */
+ bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */
+ bufferSize += 1; /* CsrWifiRouterCtrlTrafficType primitive->trafficType */
+ bufferSize += 2; /* u16 primitive->period */
+ return bufferSize;
+}
+
+
+u8* CsrWifiRouterCtrlTrafficClassificationReqSer(u8 *ptr, size_t *len, void *msg)
+{
+ CsrWifiRouterCtrlTrafficClassificationReq *primitive = (CsrWifiRouterCtrlTrafficClassificationReq *)msg;
+ *len = 0;
+ CsrUint16Ser(ptr, len, primitive->common.type);
+ CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
+ CsrUint16Ser(ptr, len, (u16) primitive->clientData);
+ CsrUint8Ser(ptr, len, (u8) primitive->trafficType);
+ CsrUint16Ser(ptr, len, (u16) primitive->period);
+ return(ptr);
+}
+
+
+void* CsrWifiRouterCtrlTrafficClassificationReqDes(u8 *buffer, size_t length)
+{
+ CsrWifiRouterCtrlTrafficClassificationReq *primitive = kmalloc(sizeof(CsrWifiRouterCtrlTrafficClassificationReq), GFP_KERNEL);
+ size_t offset;
+ offset = 0;
+
+ CsrUint16Des(&primitive->common.type, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->trafficType, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->period, buffer, &offset);
+
+ return primitive;
+}
+
+
+size_t CsrWifiRouterCtrlTrafficConfigReqSizeof(void *msg)
+{
+ size_t bufferSize = 2;
+
+ /* Calculate the Size of the Serialised Data. Could be more efficient (Try 24) */
+ bufferSize += 2; /* u16 primitive->interfaceTag */
+ bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */
+ bufferSize += 2; /* CsrWifiRouterCtrlTrafficConfigType primitive->trafficConfigType */
+ bufferSize += 2; /* u16 primitive->config.packetFilter */
+ bufferSize += 4; /* u32 primitive->config.customFilter.etherType */
+ bufferSize += 1; /* u8 primitive->config.customFilter.ipType */
+ bufferSize += 4; /* u32 primitive->config.customFilter.udpSourcePort */
+ bufferSize += 4; /* u32 primitive->config.customFilter.udpDestPort */
+ return bufferSize;
+}
+
+
+u8* CsrWifiRouterCtrlTrafficConfigReqSer(u8 *ptr, size_t *len, void *msg)
+{
+ CsrWifiRouterCtrlTrafficConfigReq *primitive = (CsrWifiRouterCtrlTrafficConfigReq *)msg;
+ *len = 0;
+ CsrUint16Ser(ptr, len, primitive->common.type);
+ CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
+ CsrUint16Ser(ptr, len, (u16) primitive->clientData);
+ CsrUint16Ser(ptr, len, (u16) primitive->trafficConfigType);
+ CsrUint16Ser(ptr, len, (u16) primitive->config.packetFilter);
+ CsrUint32Ser(ptr, len, (u32) primitive->config.customFilter.etherType);
+ CsrUint8Ser(ptr, len, (u8) primitive->config.customFilter.ipType);
+ CsrUint32Ser(ptr, len, (u32) primitive->config.customFilter.udpSourcePort);
+ CsrUint32Ser(ptr, len, (u32) primitive->config.customFilter.udpDestPort);
+ return(ptr);
+}
+
+
+void* CsrWifiRouterCtrlTrafficConfigReqDes(u8 *buffer, size_t length)
+{
+ CsrWifiRouterCtrlTrafficConfigReq *primitive = kmalloc(sizeof(CsrWifiRouterCtrlTrafficConfigReq), GFP_KERNEL);
+ size_t offset;
+ offset = 0;
+
+ CsrUint16Des(&primitive->common.type, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->trafficConfigType, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->config.packetFilter, buffer, &offset);
+ CsrUint32Des((u32 *) &primitive->config.customFilter.etherType, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->config.customFilter.ipType, buffer, &offset);
+ CsrUint32Des((u32 *) &primitive->config.customFilter.udpSourcePort, buffer, &offset);
+ CsrUint32Des((u32 *) &primitive->config.customFilter.udpDestPort, buffer, &offset);
+
+ return primitive;
+}
+
+
+size_t CsrWifiRouterCtrlWifiOnReqSizeof(void *msg)
+{
+ CsrWifiRouterCtrlWifiOnReq *primitive = (CsrWifiRouterCtrlWifiOnReq *) msg;
+ size_t bufferSize = 2;
+
+ /* Calculate the Size of the Serialised Data. Could be more efficient (Try 10) */
+ bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */
+ bufferSize += 4; /* u32 primitive->dataLength */
+ bufferSize += primitive->dataLength; /* u8 primitive->data */
+ return bufferSize;
+}
+
+
+u8* CsrWifiRouterCtrlWifiOnReqSer(u8 *ptr, size_t *len, void *msg)
+{
+ CsrWifiRouterCtrlWifiOnReq *primitive = (CsrWifiRouterCtrlWifiOnReq *)msg;
+ *len = 0;
+ CsrUint16Ser(ptr, len, primitive->common.type);
+ CsrUint16Ser(ptr, len, (u16) primitive->clientData);
+ CsrUint32Ser(ptr, len, (u32) primitive->dataLength);
+ if (primitive->dataLength)
+ {
+ CsrMemCpySer(ptr, len, (const void *) primitive->data, ((u16) (primitive->dataLength)));
+ }
+ return(ptr);
+}
+
+
+void* CsrWifiRouterCtrlWifiOnReqDes(u8 *buffer, size_t length)
+{
+ CsrWifiRouterCtrlWifiOnReq *primitive = kmalloc(sizeof(CsrWifiRouterCtrlWifiOnReq), GFP_KERNEL);
+ size_t offset;
+ offset = 0;
+
+ CsrUint16Des(&primitive->common.type, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset);
+ CsrUint32Des((u32 *) &primitive->dataLength, buffer, &offset);
+ if (primitive->dataLength)
+ {
+ primitive->data = kmalloc(primitive->dataLength, GFP_KERNEL);
+ CsrMemCpyDes(primitive->data, buffer, &offset, ((u16) (primitive->dataLength)));
+ }
+ else
+ {
+ primitive->data = NULL;
+ }
+
+ return primitive;
+}
+
+
+void CsrWifiRouterCtrlWifiOnReqSerFree(void *voidPrimitivePointer)
+{
+ CsrWifiRouterCtrlWifiOnReq *primitive = (CsrWifiRouterCtrlWifiOnReq *) voidPrimitivePointer;
+ kfree(primitive->data);
+ kfree(primitive);
+}
+
+
+size_t CsrWifiRouterCtrlWifiOnResSizeof(void *msg)
+{
+ CsrWifiRouterCtrlWifiOnRes *primitive = (CsrWifiRouterCtrlWifiOnRes *) msg;
+ size_t bufferSize = 2;
+
+ /* Calculate the Size of the Serialised Data. Could be more efficient (Try 30) */
+ bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */
+ bufferSize += 2; /* CsrResult primitive->status */
+ bufferSize += 2; /* u16 primitive->numInterfaceAddress */
+ {
+ u16 i1;
+ for (i1 = 0; i1 < 2; i1++)
+ {
+ bufferSize += 6; /* u8 primitive->stationMacAddress[i1].a[6] */
+ }
+ }
+ bufferSize += 4; /* u32 primitive->smeVersions.firmwarePatch */
+ bufferSize += (primitive->smeVersions.smeBuild ? strlen(primitive->smeVersions.smeBuild) : 0) + 1; /* char* primitive->smeVersions.smeBuild (0 byte len + 1 for NULL Term) */
+ bufferSize += 4; /* u32 primitive->smeVersions.smeHip */
+ bufferSize += 1; /* u8 primitive->scheduledInterrupt */
+ return bufferSize;
+}
+
+
+u8* CsrWifiRouterCtrlWifiOnResSer(u8 *ptr, size_t *len, void *msg)
+{
+ CsrWifiRouterCtrlWifiOnRes *primitive = (CsrWifiRouterCtrlWifiOnRes *)msg;
+ *len = 0;
+ CsrUint16Ser(ptr, len, primitive->common.type);
+ CsrUint16Ser(ptr, len, (u16) primitive->clientData);
+ CsrUint16Ser(ptr, len, (u16) primitive->status);
+ CsrUint16Ser(ptr, len, (u16) primitive->numInterfaceAddress);
+ {
+ u16 i1;
+ for (i1 = 0; i1 < 2; i1++)
+ {
+ CsrMemCpySer(ptr, len, (const void *) primitive->stationMacAddress[i1].a, ((u16) (6)));
+ }
+ }
+ CsrUint32Ser(ptr, len, (u32) primitive->smeVersions.firmwarePatch);
+ CsrCharStringSer(ptr, len, primitive->smeVersions.smeBuild);
+ CsrUint32Ser(ptr, len, (u32) primitive->smeVersions.smeHip);
+ CsrUint8Ser(ptr, len, (u8) primitive->scheduledInterrupt);
+ return(ptr);
+}
+
+
+void* CsrWifiRouterCtrlWifiOnResDes(u8 *buffer, size_t length)
+{
+ CsrWifiRouterCtrlWifiOnRes *primitive = kmalloc(sizeof(CsrWifiRouterCtrlWifiOnRes), GFP_KERNEL);
+ size_t offset;
+ offset = 0;
+
+ CsrUint16Des(&primitive->common.type, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->numInterfaceAddress, buffer, &offset);
+ {
+ u16 i1;
+ for (i1 = 0; i1 < 2; i1++)
+ {
+ CsrMemCpyDes(primitive->stationMacAddress[i1].a, buffer, &offset, ((u16) (6)));
+ }
+ }
+ CsrUint32Des((u32 *) &primitive->smeVersions.firmwarePatch, buffer, &offset);
+ CsrCharStringDes(&primitive->smeVersions.smeBuild, buffer, &offset);
+ CsrUint32Des((u32 *) &primitive->smeVersions.smeHip, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->scheduledInterrupt, buffer, &offset);
+
+ return primitive;
+}
+
+
+void CsrWifiRouterCtrlWifiOnResSerFree(void *voidPrimitivePointer)
+{
+ CsrWifiRouterCtrlWifiOnRes *primitive = (CsrWifiRouterCtrlWifiOnRes *) voidPrimitivePointer;
+ kfree(primitive->smeVersions.smeBuild);
+ kfree(primitive);
+}
+
+
+size_t CsrWifiRouterCtrlM4TransmitReqSizeof(void *msg)
+{
+ size_t bufferSize = 2;
+
+ /* Calculate the Size of the Serialised Data. Could be more efficient (Try 7) */
+ bufferSize += 2; /* u16 primitive->interfaceTag */
+ bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */
+ return bufferSize;
+}
+
+
+u8* CsrWifiRouterCtrlM4TransmitReqSer(u8 *ptr, size_t *len, void *msg)
+{
+ CsrWifiRouterCtrlM4TransmitReq *primitive = (CsrWifiRouterCtrlM4TransmitReq *)msg;
+ *len = 0;
+ CsrUint16Ser(ptr, len, primitive->common.type);
+ CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
+ CsrUint16Ser(ptr, len, (u16) primitive->clientData);
+ return(ptr);
+}
+
+
+void* CsrWifiRouterCtrlM4TransmitReqDes(u8 *buffer, size_t length)
+{
+ CsrWifiRouterCtrlM4TransmitReq *primitive = kmalloc(sizeof(CsrWifiRouterCtrlM4TransmitReq), GFP_KERNEL);
+ size_t offset;
+ offset = 0;
+
+ CsrUint16Des(&primitive->common.type, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset);
+
+ return primitive;
+}
+
+
+size_t CsrWifiRouterCtrlModeSetReqSizeof(void *msg)
+{
+ size_t bufferSize = 2;
+
+ /* Calculate the Size of the Serialised Data. Could be more efficient (Try 16) */
+ bufferSize += 2; /* u16 primitive->interfaceTag */
+ bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */
+ bufferSize += 1; /* CsrWifiRouterCtrlMode primitive->mode */
+ bufferSize += 6; /* u8 primitive->bssid.a[6] */
+ bufferSize += 1; /* u8 primitive->protection */
+ bufferSize += 1; /* u8 primitive->intraBssDistEnabled */
+ return bufferSize;
+}
+
+
+u8* CsrWifiRouterCtrlModeSetReqSer(u8 *ptr, size_t *len, void *msg)
+{
+ CsrWifiRouterCtrlModeSetReq *primitive = (CsrWifiRouterCtrlModeSetReq *)msg;
+ *len = 0;
+ CsrUint16Ser(ptr, len, primitive->common.type);
+ CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
+ CsrUint16Ser(ptr, len, (u16) primitive->clientData);
+ CsrUint8Ser(ptr, len, (u8) primitive->mode);
+ CsrMemCpySer(ptr, len, (const void *) primitive->bssid.a, ((u16) (6)));
+ CsrUint8Ser(ptr, len, (u8) primitive->protection);
+ CsrUint8Ser(ptr, len, (u8) primitive->intraBssDistEnabled);
+ return(ptr);
+}
+
+
+void* CsrWifiRouterCtrlModeSetReqDes(u8 *buffer, size_t length)
+{
+ CsrWifiRouterCtrlModeSetReq *primitive = kmalloc(sizeof(CsrWifiRouterCtrlModeSetReq), GFP_KERNEL);
+ size_t offset;
+ offset = 0;
+
+ CsrUint16Des(&primitive->common.type, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->mode, buffer, &offset);
+ CsrMemCpyDes(primitive->bssid.a, buffer, &offset, ((u16) (6)));
+ CsrUint8Des((u8 *) &primitive->protection, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->intraBssDistEnabled, buffer, &offset);
+
+ return primitive;
+}
+
+
+size_t CsrWifiRouterCtrlPeerAddReqSizeof(void *msg)
+{
+ size_t bufferSize = 2;
+
+ /* Calculate the Size of the Serialised Data. Could be more efficient (Try 21) */
+ bufferSize += 2; /* u16 primitive->interfaceTag */
+ bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */
+ bufferSize += 6; /* u8 primitive->peerMacAddress.a[6] */
+ bufferSize += 2; /* u16 primitive->associationId */
+ bufferSize += 1; /* u8 primitive->staInfo.wmmOrQosEnabled */
+ bufferSize += 2; /* CsrWifiRouterCtrlPowersaveTypeMask primitive->staInfo.powersaveMode */
+ bufferSize += 1; /* u8 primitive->staInfo.maxSpLength */
+ bufferSize += 2; /* u16 primitive->staInfo.listenIntervalInTus */
+ return bufferSize;
+}
+
+
+u8* CsrWifiRouterCtrlPeerAddReqSer(u8 *ptr, size_t *len, void *msg)
+{
+ CsrWifiRouterCtrlPeerAddReq *primitive = (CsrWifiRouterCtrlPeerAddReq *)msg;
+ *len = 0;
+ CsrUint16Ser(ptr, len, primitive->common.type);
+ CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
+ CsrUint16Ser(ptr, len, (u16) primitive->clientData);
+ CsrMemCpySer(ptr, len, (const void *) primitive->peerMacAddress.a, ((u16) (6)));
+ CsrUint16Ser(ptr, len, (u16) primitive->associationId);
+ CsrUint8Ser(ptr, len, (u8) primitive->staInfo.wmmOrQosEnabled);
+ CsrUint16Ser(ptr, len, (u16) primitive->staInfo.powersaveMode);
+ CsrUint8Ser(ptr, len, (u8) primitive->staInfo.maxSpLength);
+ CsrUint16Ser(ptr, len, (u16) primitive->staInfo.listenIntervalInTus);
+ return(ptr);
+}
+
+
+void* CsrWifiRouterCtrlPeerAddReqDes(u8 *buffer, size_t length)
+{
+ CsrWifiRouterCtrlPeerAddReq *primitive = kmalloc(sizeof(CsrWifiRouterCtrlPeerAddReq), GFP_KERNEL);
+ size_t offset;
+ offset = 0;
+
+ CsrUint16Des(&primitive->common.type, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset);
+ CsrMemCpyDes(primitive->peerMacAddress.a, buffer, &offset, ((u16) (6)));
+ CsrUint16Des((u16 *) &primitive->associationId, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->staInfo.wmmOrQosEnabled, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->staInfo.powersaveMode, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->staInfo.maxSpLength, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->staInfo.listenIntervalInTus, buffer, &offset);
+
+ return primitive;
+}
+
+
+size_t CsrWifiRouterCtrlPeerDelReqSizeof(void *msg)
+{
+ size_t bufferSize = 2;
+
+ /* Calculate the Size of the Serialised Data. Could be more efficient (Try 11) */
+ bufferSize += 2; /* u16 primitive->interfaceTag */
+ bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */
+ bufferSize += 4; /* CsrWifiRouterCtrlPeerRecordHandle primitive->peerRecordHandle */
+ return bufferSize;
+}
+
+
+u8* CsrWifiRouterCtrlPeerDelReqSer(u8 *ptr, size_t *len, void *msg)
+{
+ CsrWifiRouterCtrlPeerDelReq *primitive = (CsrWifiRouterCtrlPeerDelReq *)msg;
+ *len = 0;
+ CsrUint16Ser(ptr, len, primitive->common.type);
+ CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
+ CsrUint16Ser(ptr, len, (u16) primitive->clientData);
+ CsrUint32Ser(ptr, len, (u32) primitive->peerRecordHandle);
+ return(ptr);
+}
+
+
+void* CsrWifiRouterCtrlPeerDelReqDes(u8 *buffer, size_t length)
+{
+ CsrWifiRouterCtrlPeerDelReq *primitive = kmalloc(sizeof(CsrWifiRouterCtrlPeerDelReq), GFP_KERNEL);
+ size_t offset;
+ offset = 0;
+
+ CsrUint16Des(&primitive->common.type, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset);
+ CsrUint32Des((u32 *) &primitive->peerRecordHandle, buffer, &offset);
+
+ return primitive;
+}
+
+
+size_t CsrWifiRouterCtrlPeerUpdateReqSizeof(void *msg)
+{
+ size_t bufferSize = 2;
+
+ /* Calculate the Size of the Serialised Data. Could be more efficient (Try 13) */
+ bufferSize += 2; /* u16 primitive->interfaceTag */
+ bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */
+ bufferSize += 4; /* CsrWifiRouterCtrlPeerRecordHandle primitive->peerRecordHandle */
+ bufferSize += 2; /* CsrWifiRouterCtrlPowersaveTypeMask primitive->powersaveMode */
+ return bufferSize;
+}
+
+
+u8* CsrWifiRouterCtrlPeerUpdateReqSer(u8 *ptr, size_t *len, void *msg)
+{
+ CsrWifiRouterCtrlPeerUpdateReq *primitive = (CsrWifiRouterCtrlPeerUpdateReq *)msg;
+ *len = 0;
+ CsrUint16Ser(ptr, len, primitive->common.type);
+ CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
+ CsrUint16Ser(ptr, len, (u16) primitive->clientData);
+ CsrUint32Ser(ptr, len, (u32) primitive->peerRecordHandle);
+ CsrUint16Ser(ptr, len, (u16) primitive->powersaveMode);
+ return(ptr);
+}
+
+
+void* CsrWifiRouterCtrlPeerUpdateReqDes(u8 *buffer, size_t length)
+{
+ CsrWifiRouterCtrlPeerUpdateReq *primitive = kmalloc(sizeof(CsrWifiRouterCtrlPeerUpdateReq), GFP_KERNEL);
+ size_t offset;
+ offset = 0;
+
+ CsrUint16Des(&primitive->common.type, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset);
+ CsrUint32Des((u32 *) &primitive->peerRecordHandle, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->powersaveMode, buffer, &offset);
+
+ return primitive;
+}
+
+
+size_t CsrWifiRouterCtrlBlockAckEnableReqSizeof(void *msg)
+{
+ size_t bufferSize = 2;
+
+ /* Calculate the Size of the Serialised Data. Could be more efficient (Try 21) */
+ bufferSize += 2; /* u16 primitive->interfaceTag */
+ bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */
+ bufferSize += 6; /* u8 primitive->macAddress.a[6] */
+ bufferSize += 1; /* CsrWifiRouterCtrlTrafficStreamId primitive->trafficStreamID */
+ bufferSize += 1; /* CsrWifiRouterCtrlBlockAckRole primitive->role */
+ bufferSize += 2; /* u16 primitive->bufferSize */
+ bufferSize += 2; /* u16 primitive->timeout */
+ bufferSize += 2; /* u16 primitive->ssn */
+ return bufferSize;
+}
+
+
+u8* CsrWifiRouterCtrlBlockAckEnableReqSer(u8 *ptr, size_t *len, void *msg)
+{
+ CsrWifiRouterCtrlBlockAckEnableReq *primitive = (CsrWifiRouterCtrlBlockAckEnableReq *)msg;
+ *len = 0;
+ CsrUint16Ser(ptr, len, primitive->common.type);
+ CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
+ CsrUint16Ser(ptr, len, (u16) primitive->clientData);
+ CsrMemCpySer(ptr, len, (const void *) primitive->macAddress.a, ((u16) (6)));
+ CsrUint8Ser(ptr, len, (u8) primitive->trafficStreamID);
+ CsrUint8Ser(ptr, len, (u8) primitive->role);
+ CsrUint16Ser(ptr, len, (u16) primitive->bufferSize);
+ CsrUint16Ser(ptr, len, (u16) primitive->timeout);
+ CsrUint16Ser(ptr, len, (u16) primitive->ssn);
+ return(ptr);
+}
+
+
+void* CsrWifiRouterCtrlBlockAckEnableReqDes(u8 *buffer, size_t length)
+{
+ CsrWifiRouterCtrlBlockAckEnableReq *primitive = kmalloc(sizeof(CsrWifiRouterCtrlBlockAckEnableReq), GFP_KERNEL);
+ size_t offset;
+ offset = 0;
+
+ CsrUint16Des(&primitive->common.type, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset);
+ CsrMemCpyDes(primitive->macAddress.a, buffer, &offset, ((u16) (6)));
+ CsrUint8Des((u8 *) &primitive->trafficStreamID, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->role, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->bufferSize, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->timeout, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->ssn, buffer, &offset);
+
+ return primitive;
+}
+
+
+size_t CsrWifiRouterCtrlBlockAckDisableReqSizeof(void *msg)
+{
+ size_t bufferSize = 2;
+
+ /* Calculate the Size of the Serialised Data. Could be more efficient (Try 15) */
+ bufferSize += 2; /* u16 primitive->interfaceTag */
+ bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */
+ bufferSize += 6; /* u8 primitive->macAddress.a[6] */
+ bufferSize += 1; /* CsrWifiRouterCtrlTrafficStreamId primitive->trafficStreamID */
+ bufferSize += 1; /* CsrWifiRouterCtrlBlockAckRole primitive->role */
+ return bufferSize;
+}
+
+
+u8* CsrWifiRouterCtrlBlockAckDisableReqSer(u8 *ptr, size_t *len, void *msg)
+{
+ CsrWifiRouterCtrlBlockAckDisableReq *primitive = (CsrWifiRouterCtrlBlockAckDisableReq *)msg;
+ *len = 0;
+ CsrUint16Ser(ptr, len, primitive->common.type);
+ CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
+ CsrUint16Ser(ptr, len, (u16) primitive->clientData);
+ CsrMemCpySer(ptr, len, (const void *) primitive->macAddress.a, ((u16) (6)));
+ CsrUint8Ser(ptr, len, (u8) primitive->trafficStreamID);
+ CsrUint8Ser(ptr, len, (u8) primitive->role);
+ return(ptr);
+}
+
+
+void* CsrWifiRouterCtrlBlockAckDisableReqDes(u8 *buffer, size_t length)
+{
+ CsrWifiRouterCtrlBlockAckDisableReq *primitive = kmalloc(sizeof(CsrWifiRouterCtrlBlockAckDisableReq), GFP_KERNEL);
+ size_t offset;
+ offset = 0;
+
+ CsrUint16Des(&primitive->common.type, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset);
+ CsrMemCpyDes(primitive->macAddress.a, buffer, &offset, ((u16) (6)));
+ CsrUint8Des((u8 *) &primitive->trafficStreamID, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->role, buffer, &offset);
+
+ return primitive;
+}
+
+
+size_t CsrWifiRouterCtrlWapiRxPktReqSizeof(void *msg)
+{
+ CsrWifiRouterCtrlWapiRxPktReq *primitive = (CsrWifiRouterCtrlWapiRxPktReq *) msg;
+ size_t bufferSize = 2;
+
+ /* Calculate the Size of the Serialised Data. Could be more efficient (Try 11) */
+ bufferSize += 2; /* u16 primitive->interfaceTag */
+ bufferSize += 2; /* u16 primitive->signalLength */
+ bufferSize += primitive->signalLength; /* u8 primitive->signal */
+ bufferSize += 2; /* u16 primitive->dataLength */
+ bufferSize += primitive->dataLength; /* u8 primitive->data */
+ return bufferSize;
+}
+
+
+u8* CsrWifiRouterCtrlWapiRxPktReqSer(u8 *ptr, size_t *len, void *msg)
+{
+ CsrWifiRouterCtrlWapiRxPktReq *primitive = (CsrWifiRouterCtrlWapiRxPktReq *)msg;
+ *len = 0;
+ CsrUint16Ser(ptr, len, primitive->common.type);
+ CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
+ CsrUint16Ser(ptr, len, (u16) primitive->signalLength);
+ if (primitive->signalLength)
+ {
+ CsrMemCpySer(ptr, len, (const void *) primitive->signal, ((u16) (primitive->signalLength)));
+ }
+ CsrUint16Ser(ptr, len, (u16) primitive->dataLength);
+ if (primitive->dataLength)
+ {
+ CsrMemCpySer(ptr, len, (const void *) primitive->data, ((u16) (primitive->dataLength)));
+ }
+ return(ptr);
+}
+
+
+void* CsrWifiRouterCtrlWapiRxPktReqDes(u8 *buffer, size_t length)
+{
+ CsrWifiRouterCtrlWapiRxPktReq *primitive = kmalloc(sizeof(CsrWifiRouterCtrlWapiRxPktReq), GFP_KERNEL);
+ size_t offset;
+ offset = 0;
+
+ CsrUint16Des(&primitive->common.type, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->signalLength, buffer, &offset);
+ if (primitive->signalLength)
+ {
+ primitive->signal = kmalloc(primitive->signalLength, GFP_KERNEL);
+ CsrMemCpyDes(primitive->signal, buffer, &offset, ((u16) (primitive->signalLength)));
+ }
+ else
+ {
+ primitive->signal = NULL;
+ }
+ CsrUint16Des((u16 *) &primitive->dataLength, buffer, &offset);
+ if (primitive->dataLength)
+ {
+ primitive->data = kmalloc(primitive->dataLength, GFP_KERNEL);
+ CsrMemCpyDes(primitive->data, buffer, &offset, ((u16) (primitive->dataLength)));
+ }
+ else
+ {
+ primitive->data = NULL;
+ }
+
+ return primitive;
+}
+
+
+void CsrWifiRouterCtrlWapiRxPktReqSerFree(void *voidPrimitivePointer)
+{
+ CsrWifiRouterCtrlWapiRxPktReq *primitive = (CsrWifiRouterCtrlWapiRxPktReq *) voidPrimitivePointer;
+ kfree(primitive->signal);
+ kfree(primitive->data);
+ kfree(primitive);
+}
+
+
+size_t CsrWifiRouterCtrlWapiUnicastTxPktReqSizeof(void *msg)
+{
+ CsrWifiRouterCtrlWapiUnicastTxPktReq *primitive = (CsrWifiRouterCtrlWapiUnicastTxPktReq *) msg;
+ size_t bufferSize = 2;
+
+ /* Calculate the Size of the Serialised Data. Could be more efficient (Try 8) */
+ bufferSize += 2; /* u16 primitive->interfaceTag */
+ bufferSize += 2; /* u16 primitive->dataLength */
+ bufferSize += primitive->dataLength; /* u8 primitive->data */
+ return bufferSize;
+}
+
+
+u8* CsrWifiRouterCtrlWapiUnicastTxPktReqSer(u8 *ptr, size_t *len, void *msg)
+{
+ CsrWifiRouterCtrlWapiUnicastTxPktReq *primitive = (CsrWifiRouterCtrlWapiUnicastTxPktReq *)msg;
+ *len = 0;
+ CsrUint16Ser(ptr, len, primitive->common.type);
+ CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
+ CsrUint16Ser(ptr, len, (u16) primitive->dataLength);
+ if (primitive->dataLength)
+ {
+ CsrMemCpySer(ptr, len, (const void *) primitive->data, ((u16) (primitive->dataLength)));
+ }
+ return(ptr);
+}
+
+
+void* CsrWifiRouterCtrlWapiUnicastTxPktReqDes(u8 *buffer, size_t length)
+{
+ CsrWifiRouterCtrlWapiUnicastTxPktReq *primitive = kmalloc(sizeof(CsrWifiRouterCtrlWapiUnicastTxPktReq), GFP_KERNEL);
+ size_t offset;
+ offset = 0;
+
+ CsrUint16Des(&primitive->common.type, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->dataLength, buffer, &offset);
+ if (primitive->dataLength)
+ {
+ primitive->data = kmalloc(primitive->dataLength, GFP_KERNEL);
+ CsrMemCpyDes(primitive->data, buffer, &offset, ((u16) (primitive->dataLength)));
+ }
+ else
+ {
+ primitive->data = NULL;
+ }
+
+ return primitive;
+}
+
+
+void CsrWifiRouterCtrlWapiUnicastTxPktReqSerFree(void *voidPrimitivePointer)
+{
+ CsrWifiRouterCtrlWapiUnicastTxPktReq *primitive = (CsrWifiRouterCtrlWapiUnicastTxPktReq *) voidPrimitivePointer;
+ kfree(primitive->data);
+ kfree(primitive);
+}
+
+
+size_t CsrWifiRouterCtrlHipIndSizeof(void *msg)
+{
+ CsrWifiRouterCtrlHipInd *primitive = (CsrWifiRouterCtrlHipInd *) msg;
+ size_t bufferSize = 2;
+
+ /* Calculate the Size of the Serialised Data. Could be more efficient (Try 12) */
+ bufferSize += 2; /* u16 primitive->mlmeCommandLength */
+ bufferSize += primitive->mlmeCommandLength; /* u8 primitive->mlmeCommand */
+ bufferSize += 2; /* u16 primitive->dataRef1Length */
+ bufferSize += primitive->dataRef1Length; /* u8 primitive->dataRef1 */
+ bufferSize += 2; /* u16 primitive->dataRef2Length */
+ bufferSize += primitive->dataRef2Length; /* u8 primitive->dataRef2 */
+ return bufferSize;
+}
+
+
+u8* CsrWifiRouterCtrlHipIndSer(u8 *ptr, size_t *len, void *msg)
+{
+ CsrWifiRouterCtrlHipInd *primitive = (CsrWifiRouterCtrlHipInd *)msg;
+ *len = 0;
+ CsrUint16Ser(ptr, len, primitive->common.type);
+ CsrUint16Ser(ptr, len, (u16) primitive->mlmeCommandLength);
+ if (primitive->mlmeCommandLength)
+ {
+ CsrMemCpySer(ptr, len, (const void *) primitive->mlmeCommand, ((u16) (primitive->mlmeCommandLength)));
+ }
+ CsrUint16Ser(ptr, len, (u16) primitive->dataRef1Length);
+ if (primitive->dataRef1Length)
+ {
+ CsrMemCpySer(ptr, len, (const void *) primitive->dataRef1, ((u16) (primitive->dataRef1Length)));
+ }
+ CsrUint16Ser(ptr, len, (u16) primitive->dataRef2Length);
+ if (primitive->dataRef2Length)
+ {
+ CsrMemCpySer(ptr, len, (const void *) primitive->dataRef2, ((u16) (primitive->dataRef2Length)));
+ }
+ return(ptr);
+}
+
+
+void* CsrWifiRouterCtrlHipIndDes(u8 *buffer, size_t length)
+{
+ CsrWifiRouterCtrlHipInd *primitive = kmalloc(sizeof(CsrWifiRouterCtrlHipInd), GFP_KERNEL);
+ size_t offset;
+ offset = 0;
+
+ CsrUint16Des(&primitive->common.type, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->mlmeCommandLength, buffer, &offset);
+ if (primitive->mlmeCommandLength)
+ {
+ primitive->mlmeCommand = kmalloc(primitive->mlmeCommandLength, GFP_KERNEL);
+ CsrMemCpyDes(primitive->mlmeCommand, buffer, &offset, ((u16) (primitive->mlmeCommandLength)));
+ }
+ else
+ {
+ primitive->mlmeCommand = NULL;
+ }
+ CsrUint16Des((u16 *) &primitive->dataRef1Length, buffer, &offset);
+ if (primitive->dataRef1Length)
+ {
+ primitive->dataRef1 = kmalloc(primitive->dataRef1Length, GFP_KERNEL);
+ CsrMemCpyDes(primitive->dataRef1, buffer, &offset, ((u16) (primitive->dataRef1Length)));
+ }
+ else
+ {
+ primitive->dataRef1 = NULL;
+ }
+ CsrUint16Des((u16 *) &primitive->dataRef2Length, buffer, &offset);
+ if (primitive->dataRef2Length)
+ {
+ primitive->dataRef2 = kmalloc(primitive->dataRef2Length, GFP_KERNEL);
+ CsrMemCpyDes(primitive->dataRef2, buffer, &offset, ((u16) (primitive->dataRef2Length)));
+ }
+ else
+ {
+ primitive->dataRef2 = NULL;
+ }
+
+ return primitive;
+}
+
+
+void CsrWifiRouterCtrlHipIndSerFree(void *voidPrimitivePointer)
+{
+ CsrWifiRouterCtrlHipInd *primitive = (CsrWifiRouterCtrlHipInd *) voidPrimitivePointer;
+ kfree(primitive->mlmeCommand);
+ kfree(primitive->dataRef1);
+ kfree(primitive->dataRef2);
+ kfree(primitive);
+}
+
+
+size_t CsrWifiRouterCtrlMulticastAddressIndSizeof(void *msg)
+{
+ CsrWifiRouterCtrlMulticastAddressInd *primitive = (CsrWifiRouterCtrlMulticastAddressInd *) msg;
+ size_t bufferSize = 2;
+
+ /* Calculate the Size of the Serialised Data. Could be more efficient (Try 15) */
+ bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */
+ bufferSize += 2; /* u16 primitive->interfaceTag */
+ bufferSize += 1; /* CsrWifiRouterCtrlListAction primitive->action */
+ bufferSize += 1; /* u8 primitive->setAddressesCount */
+ {
+ u16 i1;
+ for (i1 = 0; i1 < primitive->setAddressesCount; i1++)
+ {
+ bufferSize += 6; /* u8 primitive->setAddresses[i1].a[6] */
+ }
+ }
+ return bufferSize;
+}
+
+
+u8* CsrWifiRouterCtrlMulticastAddressIndSer(u8 *ptr, size_t *len, void *msg)
+{
+ CsrWifiRouterCtrlMulticastAddressInd *primitive = (CsrWifiRouterCtrlMulticastAddressInd *)msg;
+ *len = 0;
+ CsrUint16Ser(ptr, len, primitive->common.type);
+ CsrUint16Ser(ptr, len, (u16) primitive->clientData);
+ CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
+ CsrUint8Ser(ptr, len, (u8) primitive->action);
+ CsrUint8Ser(ptr, len, (u8) primitive->setAddressesCount);
+ {
+ u16 i1;
+ for (i1 = 0; i1 < primitive->setAddressesCount; i1++)
+ {
+ CsrMemCpySer(ptr, len, (const void *) primitive->setAddresses[i1].a, ((u16) (6)));
+ }
+ }
+ return(ptr);
+}
+
+
+void* CsrWifiRouterCtrlMulticastAddressIndDes(u8 *buffer, size_t length)
+{
+ CsrWifiRouterCtrlMulticastAddressInd *primitive = kmalloc(sizeof(CsrWifiRouterCtrlMulticastAddressInd), GFP_KERNEL);
+ size_t offset;
+ offset = 0;
+
+ CsrUint16Des(&primitive->common.type, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->action, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->setAddressesCount, buffer, &offset);
+ primitive->setAddresses = NULL;
+ if (primitive->setAddressesCount)
+ {
+ primitive->setAddresses = kmalloc(sizeof(CsrWifiMacAddress) * primitive->setAddressesCount, GFP_KERNEL);
+ }
+ {
+ u16 i1;
+ for (i1 = 0; i1 < primitive->setAddressesCount; i1++)
+ {
+ CsrMemCpyDes(primitive->setAddresses[i1].a, buffer, &offset, ((u16) (6)));
+ }
+ }
+
+ return primitive;
+}
+
+
+void CsrWifiRouterCtrlMulticastAddressIndSerFree(void *voidPrimitivePointer)
+{
+ CsrWifiRouterCtrlMulticastAddressInd *primitive = (CsrWifiRouterCtrlMulticastAddressInd *) voidPrimitivePointer;
+ kfree(primitive->setAddresses);
+ kfree(primitive);
+}
+
+
+size_t CsrWifiRouterCtrlPortConfigureCfmSizeof(void *msg)
+{
+ size_t bufferSize = 2;
+
+ /* Calculate the Size of the Serialised Data. Could be more efficient (Try 15) */
+ bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */
+ bufferSize += 2; /* u16 primitive->interfaceTag */
+ bufferSize += 2; /* CsrResult primitive->status */
+ bufferSize += 6; /* u8 primitive->macAddress.a[6] */
+ return bufferSize;
+}
+
+
+u8* CsrWifiRouterCtrlPortConfigureCfmSer(u8 *ptr, size_t *len, void *msg)
+{
+ CsrWifiRouterCtrlPortConfigureCfm *primitive = (CsrWifiRouterCtrlPortConfigureCfm *)msg;
+ *len = 0;
+ CsrUint16Ser(ptr, len, primitive->common.type);
+ CsrUint16Ser(ptr, len, (u16) primitive->clientData);
+ CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
+ CsrUint16Ser(ptr, len, (u16) primitive->status);
+ CsrMemCpySer(ptr, len, (const void *) primitive->macAddress.a, ((u16) (6)));
+ return(ptr);
+}
+
+
+void* CsrWifiRouterCtrlPortConfigureCfmDes(u8 *buffer, size_t length)
+{
+ CsrWifiRouterCtrlPortConfigureCfm *primitive = kmalloc(sizeof(CsrWifiRouterCtrlPortConfigureCfm), GFP_KERNEL);
+ size_t offset;
+ offset = 0;
+
+ CsrUint16Des(&primitive->common.type, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
+ CsrMemCpyDes(primitive->macAddress.a, buffer, &offset, ((u16) (6)));
+
+ return primitive;
+}
+
+
+size_t CsrWifiRouterCtrlSuspendIndSizeof(void *msg)
+{
+ size_t bufferSize = 2;
+
+ /* Calculate the Size of the Serialised Data. Could be more efficient (Try 7) */
+ bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */
+ bufferSize += 1; /* u8 primitive->hardSuspend */
+ bufferSize += 1; /* u8 primitive->d3Suspend */
+ return bufferSize;
+}
+
+
+u8* CsrWifiRouterCtrlSuspendIndSer(u8 *ptr, size_t *len, void *msg)
+{
+ CsrWifiRouterCtrlSuspendInd *primitive = (CsrWifiRouterCtrlSuspendInd *)msg;
+ *len = 0;
+ CsrUint16Ser(ptr, len, primitive->common.type);
+ CsrUint16Ser(ptr, len, (u16) primitive->clientData);
+ CsrUint8Ser(ptr, len, (u8) primitive->hardSuspend);
+ CsrUint8Ser(ptr, len, (u8) primitive->d3Suspend);
+ return(ptr);
+}
+
+
+void* CsrWifiRouterCtrlSuspendIndDes(u8 *buffer, size_t length)
+{
+ CsrWifiRouterCtrlSuspendInd *primitive = kmalloc(sizeof(CsrWifiRouterCtrlSuspendInd), GFP_KERNEL);
+ size_t offset;
+ offset = 0;
+
+ CsrUint16Des(&primitive->common.type, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->hardSuspend, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->d3Suspend, buffer, &offset);
+
+ return primitive;
+}
+
+
+size_t CsrWifiRouterCtrlTclasAddCfmSizeof(void *msg)
+{
+ size_t bufferSize = 2;
+
+ /* Calculate the Size of the Serialised Data. Could be more efficient (Try 9) */
+ bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */
+ bufferSize += 2; /* u16 primitive->interfaceTag */
+ bufferSize += 2; /* CsrResult primitive->status */
+ return bufferSize;
+}
+
+
+u8* CsrWifiRouterCtrlTclasAddCfmSer(u8 *ptr, size_t *len, void *msg)
+{
+ CsrWifiRouterCtrlTclasAddCfm *primitive = (CsrWifiRouterCtrlTclasAddCfm *)msg;
+ *len = 0;
+ CsrUint16Ser(ptr, len, primitive->common.type);
+ CsrUint16Ser(ptr, len, (u16) primitive->clientData);
+ CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
+ CsrUint16Ser(ptr, len, (u16) primitive->status);
+ return(ptr);
+}
+
+
+void* CsrWifiRouterCtrlTclasAddCfmDes(u8 *buffer, size_t length)
+{
+ CsrWifiRouterCtrlTclasAddCfm *primitive = kmalloc(sizeof(CsrWifiRouterCtrlTclasAddCfm), GFP_KERNEL);
+ size_t offset;
+ offset = 0;
+
+ CsrUint16Des(&primitive->common.type, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
+
+ return primitive;
+}
+
+
+size_t CsrWifiRouterCtrlRawSdioDeinitialiseCfmSizeof(void *msg)
+{
+ size_t bufferSize = 2;
+
+ /* Calculate the Size of the Serialised Data. Could be more efficient (Try 7) */
+ bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */
+ bufferSize += 2; /* CsrResult primitive->result */
+ return bufferSize;
+}
+
+
+u8* CsrWifiRouterCtrlRawSdioDeinitialiseCfmSer(u8 *ptr, size_t *len, void *msg)
+{
+ CsrWifiRouterCtrlRawSdioDeinitialiseCfm *primitive = (CsrWifiRouterCtrlRawSdioDeinitialiseCfm *)msg;
+ *len = 0;
+ CsrUint16Ser(ptr, len, primitive->common.type);
+ CsrUint16Ser(ptr, len, (u16) primitive->clientData);
+ CsrUint16Ser(ptr, len, (u16) primitive->result);
+ return(ptr);
+}
+
+
+void* CsrWifiRouterCtrlRawSdioDeinitialiseCfmDes(u8 *buffer, size_t length)
+{
+ CsrWifiRouterCtrlRawSdioDeinitialiseCfm *primitive = kmalloc(sizeof(CsrWifiRouterCtrlRawSdioDeinitialiseCfm), GFP_KERNEL);
+ size_t offset;
+ offset = 0;
+
+ CsrUint16Des(&primitive->common.type, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->result, buffer, &offset);
+
+ return primitive;
+}
+
+
+size_t CsrWifiRouterCtrlRawSdioInitialiseCfmSizeof(void *msg)
+{
+ size_t bufferSize = 2;
+
+ /* Calculate the Size of the Serialised Data. Could be more efficient (Try 39) */
+ bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */
+ bufferSize += 2; /* CsrResult primitive->result */
+ bufferSize += 4; /* CsrWifiRouterCtrlRawSdioByteRead primitive->byteRead */
+ bufferSize += 4; /* CsrWifiRouterCtrlRawSdioByteWrite primitive->byteWrite */
+ bufferSize += 4; /* CsrWifiRouterCtrlRawSdioFirmwareDownload primitive->firmwareDownload */
+ bufferSize += 4; /* CsrWifiRouterCtrlRawSdioReset primitive->reset */
+ bufferSize += 4; /* CsrWifiRouterCtrlRawSdioCoreDumpPrepare primitive->coreDumpPrepare */
+ bufferSize += 4; /* CsrWifiRouterCtrlRawSdioByteBlockRead primitive->byteBlockRead */
+ bufferSize += 4; /* CsrWifiRouterCtrlRawSdioGpRead16 primitive->gpRead16 */
+ bufferSize += 4; /* CsrWifiRouterCtrlRawSdioGpWrite16 primitive->gpWrite16 */
+ return bufferSize;
+}
+
+
+u8* CsrWifiRouterCtrlRawSdioInitialiseCfmSer(u8 *ptr, size_t *len, void *msg)
+{
+ CsrWifiRouterCtrlRawSdioInitialiseCfm *primitive = (CsrWifiRouterCtrlRawSdioInitialiseCfm *)msg;
+ *len = 0;
+ CsrUint16Ser(ptr, len, primitive->common.type);
+ CsrUint16Ser(ptr, len, (u16) primitive->clientData);
+ CsrUint16Ser(ptr, len, (u16) primitive->result);
+ CsrUint32Ser(ptr, len, 0); /* Special for Function Pointers... primitive->byteRead */
+ CsrUint32Ser(ptr, len, 0); /* Special for Function Pointers... primitive->byteWrite */
+ CsrUint32Ser(ptr, len, 0); /* Special for Function Pointers... primitive->firmwareDownload */
+ CsrUint32Ser(ptr, len, 0); /* Special for Function Pointers... primitive->reset */
+ CsrUint32Ser(ptr, len, 0); /* Special for Function Pointers... primitive->coreDumpPrepare */
+ CsrUint32Ser(ptr, len, 0); /* Special for Function Pointers... primitive->byteBlockRead */
+ CsrUint32Ser(ptr, len, 0); /* Special for Function Pointers... primitive->gpRead16 */
+ CsrUint32Ser(ptr, len, 0); /* Special for Function Pointers... primitive->gpWrite16 */
+ return(ptr);
+}
+
+
+void* CsrWifiRouterCtrlRawSdioInitialiseCfmDes(u8 *buffer, size_t length)
+{
+ CsrWifiRouterCtrlRawSdioInitialiseCfm *primitive = kmalloc(sizeof(CsrWifiRouterCtrlRawSdioInitialiseCfm), GFP_KERNEL);
+ size_t offset;
+ offset = 0;
+
+ CsrUint16Des(&primitive->common.type, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->result, buffer, &offset);
+ primitive->byteRead = NULL; /* Special for Function Pointers... */
+ offset += 4;
+ primitive->byteWrite = NULL; /* Special for Function Pointers... */
+ offset += 4;
+ primitive->firmwareDownload = NULL; /* Special for Function Pointers... */
+ offset += 4;
+ primitive->reset = NULL; /* Special for Function Pointers... */
+ offset += 4;
+ primitive->coreDumpPrepare = NULL; /* Special for Function Pointers... */
+ offset += 4;
+ primitive->byteBlockRead = NULL; /* Special for Function Pointers... */
+ offset += 4;
+ primitive->gpRead16 = NULL; /* Special for Function Pointers... */
+ offset += 4;
+ primitive->gpWrite16 = NULL; /* Special for Function Pointers... */
+ offset += 4;
+
+ return primitive;
+}
+
+
+size_t CsrWifiRouterCtrlTclasDelCfmSizeof(void *msg)
+{
+ size_t bufferSize = 2;
+
+ /* Calculate the Size of the Serialised Data. Could be more efficient (Try 9) */
+ bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */
+ bufferSize += 2; /* u16 primitive->interfaceTag */
+ bufferSize += 2; /* CsrResult primitive->status */
+ return bufferSize;
+}
+
+
+u8* CsrWifiRouterCtrlTclasDelCfmSer(u8 *ptr, size_t *len, void *msg)
+{
+ CsrWifiRouterCtrlTclasDelCfm *primitive = (CsrWifiRouterCtrlTclasDelCfm *)msg;
+ *len = 0;
+ CsrUint16Ser(ptr, len, primitive->common.type);
+ CsrUint16Ser(ptr, len, (u16) primitive->clientData);
+ CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
+ CsrUint16Ser(ptr, len, (u16) primitive->status);
+ return(ptr);
+}
+
+
+void* CsrWifiRouterCtrlTclasDelCfmDes(u8 *buffer, size_t length)
+{
+ CsrWifiRouterCtrlTclasDelCfm *primitive = kmalloc(sizeof(CsrWifiRouterCtrlTclasDelCfm), GFP_KERNEL);
+ size_t offset;
+ offset = 0;
+
+ CsrUint16Des(&primitive->common.type, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
+
+ return primitive;
+}
+
+
+size_t CsrWifiRouterCtrlTrafficProtocolIndSizeof(void *msg)
+{
+ size_t bufferSize = 2;
+
+ /* Calculate the Size of the Serialised Data. Could be more efficient (Try 17) */
+ bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */
+ bufferSize += 2; /* u16 primitive->interfaceTag */
+ bufferSize += 2; /* CsrWifiRouterCtrlTrafficPacketType primitive->packetType */
+ bufferSize += 2; /* CsrWifiRouterCtrlProtocolDirection primitive->direction */
+ bufferSize += 6; /* u8 primitive->srcAddress.a[6] */
+ return bufferSize;
+}
+
+
+u8* CsrWifiRouterCtrlTrafficProtocolIndSer(u8 *ptr, size_t *len, void *msg)
+{
+ CsrWifiRouterCtrlTrafficProtocolInd *primitive = (CsrWifiRouterCtrlTrafficProtocolInd *)msg;
+ *len = 0;
+ CsrUint16Ser(ptr, len, primitive->common.type);
+ CsrUint16Ser(ptr, len, (u16) primitive->clientData);
+ CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
+ CsrUint16Ser(ptr, len, (u16) primitive->packetType);
+ CsrUint16Ser(ptr, len, (u16) primitive->direction);
+ CsrMemCpySer(ptr, len, (const void *) primitive->srcAddress.a, ((u16) (6)));
+ return(ptr);
+}
+
+
+void* CsrWifiRouterCtrlTrafficProtocolIndDes(u8 *buffer, size_t length)
+{
+ CsrWifiRouterCtrlTrafficProtocolInd *primitive = kmalloc(sizeof(CsrWifiRouterCtrlTrafficProtocolInd), GFP_KERNEL);
+ size_t offset;
+ offset = 0;
+
+ CsrUint16Des(&primitive->common.type, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->packetType, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->direction, buffer, &offset);
+ CsrMemCpyDes(primitive->srcAddress.a, buffer, &offset, ((u16) (6)));
+
+ return primitive;
+}
+
+
+size_t CsrWifiRouterCtrlTrafficSampleIndSizeof(void *msg)
+{
+ size_t bufferSize = 2;
+
+ /* Calculate the Size of the Serialised Data. Could be more efficient (Try 38) */
+ bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */
+ bufferSize += 2; /* u16 primitive->interfaceTag */
+ bufferSize += 4; /* u32 primitive->stats.rxMeanRate */
+ bufferSize += 4; /* u32 primitive->stats.rxFramesNum */
+ bufferSize += 4; /* u32 primitive->stats.txFramesNum */
+ bufferSize += 4; /* u32 primitive->stats.rxBytesCount */
+ bufferSize += 4; /* u32 primitive->stats.txBytesCount */
+ bufferSize += 11; /* u8 primitive->stats.intervals[11] */
+ return bufferSize;
+}
+
+
+u8* CsrWifiRouterCtrlTrafficSampleIndSer(u8 *ptr, size_t *len, void *msg)
+{
+ CsrWifiRouterCtrlTrafficSampleInd *primitive = (CsrWifiRouterCtrlTrafficSampleInd *)msg;
+ *len = 0;
+ CsrUint16Ser(ptr, len, primitive->common.type);
+ CsrUint16Ser(ptr, len, (u16) primitive->clientData);
+ CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
+ CsrUint32Ser(ptr, len, (u32) primitive->stats.rxMeanRate);
+ CsrUint32Ser(ptr, len, (u32) primitive->stats.rxFramesNum);
+ CsrUint32Ser(ptr, len, (u32) primitive->stats.txFramesNum);
+ CsrUint32Ser(ptr, len, (u32) primitive->stats.rxBytesCount);
+ CsrUint32Ser(ptr, len, (u32) primitive->stats.txBytesCount);
+ CsrMemCpySer(ptr, len, (const void *) primitive->stats.intervals, ((u16) (11)));
+ return(ptr);
+}
+
+
+void* CsrWifiRouterCtrlTrafficSampleIndDes(u8 *buffer, size_t length)
+{
+ CsrWifiRouterCtrlTrafficSampleInd *primitive = kmalloc(sizeof(CsrWifiRouterCtrlTrafficSampleInd), GFP_KERNEL);
+ size_t offset;
+ offset = 0;
+
+ CsrUint16Des(&primitive->common.type, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
+ CsrUint32Des((u32 *) &primitive->stats.rxMeanRate, buffer, &offset);
+ CsrUint32Des((u32 *) &primitive->stats.rxFramesNum, buffer, &offset);
+ CsrUint32Des((u32 *) &primitive->stats.txFramesNum, buffer, &offset);
+ CsrUint32Des((u32 *) &primitive->stats.rxBytesCount, buffer, &offset);
+ CsrUint32Des((u32 *) &primitive->stats.txBytesCount, buffer, &offset);
+ CsrMemCpyDes(primitive->stats.intervals, buffer, &offset, ((u16) (11)));
+
+ return primitive;
+}
+
+
+size_t CsrWifiRouterCtrlWifiOnIndSizeof(void *msg)
+{
+ CsrWifiRouterCtrlWifiOnInd *primitive = (CsrWifiRouterCtrlWifiOnInd *) msg;
+ size_t bufferSize = 2;
+
+ /* Calculate the Size of the Serialised Data. Could be more efficient (Try 27) */
+ bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */
+ bufferSize += 2; /* CsrResult primitive->status */
+ bufferSize += 4; /* u32 primitive->versions.chipId */
+ bufferSize += 4; /* u32 primitive->versions.chipVersion */
+ bufferSize += 4; /* u32 primitive->versions.firmwareBuild */
+ bufferSize += 4; /* u32 primitive->versions.firmwareHip */
+ bufferSize += (primitive->versions.routerBuild ? strlen(primitive->versions.routerBuild) : 0) + 1; /* char* primitive->versions.routerBuild (0 byte len + 1 for NULL Term) */
+ bufferSize += 4; /* u32 primitive->versions.routerHip */
+ return bufferSize;
+}
+
+
+u8* CsrWifiRouterCtrlWifiOnIndSer(u8 *ptr, size_t *len, void *msg)
+{
+ CsrWifiRouterCtrlWifiOnInd *primitive = (CsrWifiRouterCtrlWifiOnInd *)msg;
+ *len = 0;
+ CsrUint16Ser(ptr, len, primitive->common.type);
+ CsrUint16Ser(ptr, len, (u16) primitive->clientData);
+ CsrUint16Ser(ptr, len, (u16) primitive->status);
+ CsrUint32Ser(ptr, len, (u32) primitive->versions.chipId);
+ CsrUint32Ser(ptr, len, (u32) primitive->versions.chipVersion);
+ CsrUint32Ser(ptr, len, (u32) primitive->versions.firmwareBuild);
+ CsrUint32Ser(ptr, len, (u32) primitive->versions.firmwareHip);
+ CsrCharStringSer(ptr, len, primitive->versions.routerBuild);
+ CsrUint32Ser(ptr, len, (u32) primitive->versions.routerHip);
+ return(ptr);
+}
+
+
+void* CsrWifiRouterCtrlWifiOnIndDes(u8 *buffer, size_t length)
+{
+ CsrWifiRouterCtrlWifiOnInd *primitive = kmalloc(sizeof(CsrWifiRouterCtrlWifiOnInd), GFP_KERNEL);
+ size_t offset;
+ offset = 0;
+
+ CsrUint16Des(&primitive->common.type, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
+ CsrUint32Des((u32 *) &primitive->versions.chipId, buffer, &offset);
+ CsrUint32Des((u32 *) &primitive->versions.chipVersion, buffer, &offset);
+ CsrUint32Des((u32 *) &primitive->versions.firmwareBuild, buffer, &offset);
+ CsrUint32Des((u32 *) &primitive->versions.firmwareHip, buffer, &offset);
+ CsrCharStringDes(&primitive->versions.routerBuild, buffer, &offset);
+ CsrUint32Des((u32 *) &primitive->versions.routerHip, buffer, &offset);
+
+ return primitive;
+}
+
+
+void CsrWifiRouterCtrlWifiOnIndSerFree(void *voidPrimitivePointer)
+{
+ CsrWifiRouterCtrlWifiOnInd *primitive = (CsrWifiRouterCtrlWifiOnInd *) voidPrimitivePointer;
+ kfree(primitive->versions.routerBuild);
+ kfree(primitive);
+}
+
+
+size_t CsrWifiRouterCtrlWifiOnCfmSizeof(void *msg)
+{
+ size_t bufferSize = 2;
+
+ /* Calculate the Size of the Serialised Data. Could be more efficient (Try 7) */
+ bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */
+ bufferSize += 2; /* CsrResult primitive->status */
+ return bufferSize;
+}
+
+
+u8* CsrWifiRouterCtrlWifiOnCfmSer(u8 *ptr, size_t *len, void *msg)
+{
+ CsrWifiRouterCtrlWifiOnCfm *primitive = (CsrWifiRouterCtrlWifiOnCfm *)msg;
+ *len = 0;
+ CsrUint16Ser(ptr, len, primitive->common.type);
+ CsrUint16Ser(ptr, len, (u16) primitive->clientData);
+ CsrUint16Ser(ptr, len, (u16) primitive->status);
+ return(ptr);
+}
+
+
+void* CsrWifiRouterCtrlWifiOnCfmDes(u8 *buffer, size_t length)
+{
+ CsrWifiRouterCtrlWifiOnCfm *primitive = kmalloc(sizeof(CsrWifiRouterCtrlWifiOnCfm), GFP_KERNEL);
+ size_t offset;
+ offset = 0;
+
+ CsrUint16Des(&primitive->common.type, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
+
+ return primitive;
+}
+
+
+size_t CsrWifiRouterCtrlM4ReadyToSendIndSizeof(void *msg)
+{
+ size_t bufferSize = 2;
+
+ /* Calculate the Size of the Serialised Data. Could be more efficient (Try 13) */
+ bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */
+ bufferSize += 2; /* u16 primitive->interfaceTag */
+ bufferSize += 6; /* u8 primitive->peerMacAddress.a[6] */
+ return bufferSize;
+}
+
+
+u8* CsrWifiRouterCtrlM4ReadyToSendIndSer(u8 *ptr, size_t *len, void *msg)
+{
+ CsrWifiRouterCtrlM4ReadyToSendInd *primitive = (CsrWifiRouterCtrlM4ReadyToSendInd *)msg;
+ *len = 0;
+ CsrUint16Ser(ptr, len, primitive->common.type);
+ CsrUint16Ser(ptr, len, (u16) primitive->clientData);
+ CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
+ CsrMemCpySer(ptr, len, (const void *) primitive->peerMacAddress.a, ((u16) (6)));
+ return(ptr);
+}
+
+
+void* CsrWifiRouterCtrlM4ReadyToSendIndDes(u8 *buffer, size_t length)
+{
+ CsrWifiRouterCtrlM4ReadyToSendInd *primitive = kmalloc(sizeof(CsrWifiRouterCtrlM4ReadyToSendInd), GFP_KERNEL);
+ size_t offset;
+ offset = 0;
+
+ CsrUint16Des(&primitive->common.type, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
+ CsrMemCpyDes(primitive->peerMacAddress.a, buffer, &offset, ((u16) (6)));
+
+ return primitive;
+}
+
+
+size_t CsrWifiRouterCtrlM4TransmittedIndSizeof(void *msg)
+{
+ size_t bufferSize = 2;
+
+ /* Calculate the Size of the Serialised Data. Could be more efficient (Try 15) */
+ bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */
+ bufferSize += 2; /* u16 primitive->interfaceTag */
+ bufferSize += 6; /* u8 primitive->peerMacAddress.a[6] */
+ bufferSize += 2; /* CsrResult primitive->status */
+ return bufferSize;
+}
+
+
+u8* CsrWifiRouterCtrlM4TransmittedIndSer(u8 *ptr, size_t *len, void *msg)
+{
+ CsrWifiRouterCtrlM4TransmittedInd *primitive = (CsrWifiRouterCtrlM4TransmittedInd *)msg;
+ *len = 0;
+ CsrUint16Ser(ptr, len, primitive->common.type);
+ CsrUint16Ser(ptr, len, (u16) primitive->clientData);
+ CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
+ CsrMemCpySer(ptr, len, (const void *) primitive->peerMacAddress.a, ((u16) (6)));
+ CsrUint16Ser(ptr, len, (u16) primitive->status);
+ return(ptr);
+}
+
+
+void* CsrWifiRouterCtrlM4TransmittedIndDes(u8 *buffer, size_t length)
+{
+ CsrWifiRouterCtrlM4TransmittedInd *primitive = kmalloc(sizeof(CsrWifiRouterCtrlM4TransmittedInd), GFP_KERNEL);
+ size_t offset;
+ offset = 0;
+
+ CsrUint16Des(&primitive->common.type, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
+ CsrMemCpyDes(primitive->peerMacAddress.a, buffer, &offset, ((u16) (6)));
+ CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
+
+ return primitive;
+}
+
+
+size_t CsrWifiRouterCtrlMicFailureIndSizeof(void *msg)
+{
+ size_t bufferSize = 2;
+
+ /* Calculate the Size of the Serialised Data. Could be more efficient (Try 14) */
+ bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */
+ bufferSize += 2; /* u16 primitive->interfaceTag */
+ bufferSize += 6; /* u8 primitive->peerMacAddress.a[6] */
+ bufferSize += 1; /* u8 primitive->unicastPdu */
+ return bufferSize;
+}
+
+
+u8* CsrWifiRouterCtrlMicFailureIndSer(u8 *ptr, size_t *len, void *msg)
+{
+ CsrWifiRouterCtrlMicFailureInd *primitive = (CsrWifiRouterCtrlMicFailureInd *)msg;
+ *len = 0;
+ CsrUint16Ser(ptr, len, primitive->common.type);
+ CsrUint16Ser(ptr, len, (u16) primitive->clientData);
+ CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
+ CsrMemCpySer(ptr, len, (const void *) primitive->peerMacAddress.a, ((u16) (6)));
+ CsrUint8Ser(ptr, len, (u8) primitive->unicastPdu);
+ return(ptr);
+}
+
+
+void* CsrWifiRouterCtrlMicFailureIndDes(u8 *buffer, size_t length)
+{
+ CsrWifiRouterCtrlMicFailureInd *primitive = kmalloc(sizeof(CsrWifiRouterCtrlMicFailureInd), GFP_KERNEL);
+ size_t offset;
+ offset = 0;
+
+ CsrUint16Des(&primitive->common.type, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
+ CsrMemCpyDes(primitive->peerMacAddress.a, buffer, &offset, ((u16) (6)));
+ CsrUint8Des((u8 *) &primitive->unicastPdu, buffer, &offset);
+
+ return primitive;
+}
+
+
+size_t CsrWifiRouterCtrlConnectedIndSizeof(void *msg)
+{
+ size_t bufferSize = 2;
+
+ /* Calculate the Size of the Serialised Data. Could be more efficient (Try 14) */
+ bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */
+ bufferSize += 2; /* u16 primitive->interfaceTag */
+ bufferSize += 6; /* u8 primitive->peerMacAddress.a[6] */
+ bufferSize += 1; /* CsrWifiRouterCtrlPeerStatus primitive->peerStatus */
+ return bufferSize;
+}
+
+
+u8* CsrWifiRouterCtrlConnectedIndSer(u8 *ptr, size_t *len, void *msg)
+{
+ CsrWifiRouterCtrlConnectedInd *primitive = (CsrWifiRouterCtrlConnectedInd *)msg;
+ *len = 0;
+ CsrUint16Ser(ptr, len, primitive->common.type);
+ CsrUint16Ser(ptr, len, (u16) primitive->clientData);
+ CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
+ CsrMemCpySer(ptr, len, (const void *) primitive->peerMacAddress.a, ((u16) (6)));
+ CsrUint8Ser(ptr, len, (u8) primitive->peerStatus);
+ return(ptr);
+}
+
+
+void* CsrWifiRouterCtrlConnectedIndDes(u8 *buffer, size_t length)
+{
+ CsrWifiRouterCtrlConnectedInd *primitive = kmalloc(sizeof(CsrWifiRouterCtrlConnectedInd), GFP_KERNEL);
+ size_t offset;
+ offset = 0;
+
+ CsrUint16Des(&primitive->common.type, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
+ CsrMemCpyDes(primitive->peerMacAddress.a, buffer, &offset, ((u16) (6)));
+ CsrUint8Des((u8 *) &primitive->peerStatus, buffer, &offset);
+
+ return primitive;
+}
+
+
+size_t CsrWifiRouterCtrlPeerAddCfmSizeof(void *msg)
+{
+ size_t bufferSize = 2;
+
+ /* Calculate the Size of the Serialised Data. Could be more efficient (Try 19) */
+ bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */
+ bufferSize += 2; /* u16 primitive->interfaceTag */
+ bufferSize += 6; /* u8 primitive->peerMacAddress.a[6] */
+ bufferSize += 4; /* CsrWifiRouterCtrlPeerRecordHandle primitive->peerRecordHandle */
+ bufferSize += 2; /* CsrResult primitive->status */
+ return bufferSize;
+}
+
+
+u8* CsrWifiRouterCtrlPeerAddCfmSer(u8 *ptr, size_t *len, void *msg)
+{
+ CsrWifiRouterCtrlPeerAddCfm *primitive = (CsrWifiRouterCtrlPeerAddCfm *)msg;
+ *len = 0;
+ CsrUint16Ser(ptr, len, primitive->common.type);
+ CsrUint16Ser(ptr, len, (u16) primitive->clientData);
+ CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
+ CsrMemCpySer(ptr, len, (const void *) primitive->peerMacAddress.a, ((u16) (6)));
+ CsrUint32Ser(ptr, len, (u32) primitive->peerRecordHandle);
+ CsrUint16Ser(ptr, len, (u16) primitive->status);
+ return(ptr);
+}
+
+
+void* CsrWifiRouterCtrlPeerAddCfmDes(u8 *buffer, size_t length)
+{
+ CsrWifiRouterCtrlPeerAddCfm *primitive = kmalloc(sizeof(CsrWifiRouterCtrlPeerAddCfm), GFP_KERNEL);
+ size_t offset;
+ offset = 0;
+
+ CsrUint16Des(&primitive->common.type, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
+ CsrMemCpyDes(primitive->peerMacAddress.a, buffer, &offset, ((u16) (6)));
+ CsrUint32Des((u32 *) &primitive->peerRecordHandle, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
+
+ return primitive;
+}
+
+
+size_t CsrWifiRouterCtrlPeerDelCfmSizeof(void *msg)
+{
+ size_t bufferSize = 2;
+
+ /* Calculate the Size of the Serialised Data. Could be more efficient (Try 9) */
+ bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */
+ bufferSize += 2; /* u16 primitive->interfaceTag */
+ bufferSize += 2; /* CsrResult primitive->status */
+ return bufferSize;
+}
+
+
+u8* CsrWifiRouterCtrlPeerDelCfmSer(u8 *ptr, size_t *len, void *msg)
+{
+ CsrWifiRouterCtrlPeerDelCfm *primitive = (CsrWifiRouterCtrlPeerDelCfm *)msg;
+ *len = 0;
+ CsrUint16Ser(ptr, len, primitive->common.type);
+ CsrUint16Ser(ptr, len, (u16) primitive->clientData);
+ CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
+ CsrUint16Ser(ptr, len, (u16) primitive->status);
+ return(ptr);
+}
+
+
+void* CsrWifiRouterCtrlPeerDelCfmDes(u8 *buffer, size_t length)
+{
+ CsrWifiRouterCtrlPeerDelCfm *primitive = kmalloc(sizeof(CsrWifiRouterCtrlPeerDelCfm), GFP_KERNEL);
+ size_t offset;
+ offset = 0;
+
+ CsrUint16Des(&primitive->common.type, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
+
+ return primitive;
+}
+
+
+size_t CsrWifiRouterCtrlUnexpectedFrameIndSizeof(void *msg)
+{
+ size_t bufferSize = 2;
+
+ /* Calculate the Size of the Serialised Data. Could be more efficient (Try 13) */
+ bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */
+ bufferSize += 2; /* u16 primitive->interfaceTag */
+ bufferSize += 6; /* u8 primitive->peerMacAddress.a[6] */
+ return bufferSize;
+}
+
+
+u8* CsrWifiRouterCtrlUnexpectedFrameIndSer(u8 *ptr, size_t *len, void *msg)
+{
+ CsrWifiRouterCtrlUnexpectedFrameInd *primitive = (CsrWifiRouterCtrlUnexpectedFrameInd *)msg;
+ *len = 0;
+ CsrUint16Ser(ptr, len, primitive->common.type);
+ CsrUint16Ser(ptr, len, (u16) primitive->clientData);
+ CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
+ CsrMemCpySer(ptr, len, (const void *) primitive->peerMacAddress.a, ((u16) (6)));
+ return(ptr);
+}
+
+
+void* CsrWifiRouterCtrlUnexpectedFrameIndDes(u8 *buffer, size_t length)
+{
+ CsrWifiRouterCtrlUnexpectedFrameInd *primitive = kmalloc(sizeof(CsrWifiRouterCtrlUnexpectedFrameInd), GFP_KERNEL);
+ size_t offset;
+ offset = 0;
+
+ CsrUint16Des(&primitive->common.type, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
+ CsrMemCpyDes(primitive->peerMacAddress.a, buffer, &offset, ((u16) (6)));
+
+ return primitive;
+}
+
+
+size_t CsrWifiRouterCtrlPeerUpdateCfmSizeof(void *msg)
+{
+ size_t bufferSize = 2;
+
+ /* Calculate the Size of the Serialised Data. Could be more efficient (Try 9) */
+ bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */
+ bufferSize += 2; /* u16 primitive->interfaceTag */
+ bufferSize += 2; /* CsrResult primitive->status */
+ return bufferSize;
+}
+
+
+u8* CsrWifiRouterCtrlPeerUpdateCfmSer(u8 *ptr, size_t *len, void *msg)
+{
+ CsrWifiRouterCtrlPeerUpdateCfm *primitive = (CsrWifiRouterCtrlPeerUpdateCfm *)msg;
+ *len = 0;
+ CsrUint16Ser(ptr, len, primitive->common.type);
+ CsrUint16Ser(ptr, len, (u16) primitive->clientData);
+ CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
+ CsrUint16Ser(ptr, len, (u16) primitive->status);
+ return(ptr);
+}
+
+
+void* CsrWifiRouterCtrlPeerUpdateCfmDes(u8 *buffer, size_t length)
+{
+ CsrWifiRouterCtrlPeerUpdateCfm *primitive = kmalloc(sizeof(CsrWifiRouterCtrlPeerUpdateCfm), GFP_KERNEL);
+ size_t offset;
+ offset = 0;
+
+ CsrUint16Des(&primitive->common.type, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
+
+ return primitive;
+}
+
+
+size_t CsrWifiRouterCtrlCapabilitiesCfmSizeof(void *msg)
+{
+ size_t bufferSize = 2;
+
+ /* Calculate the Size of the Serialised Data. Could be more efficient (Try 9) */
+ bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */
+ bufferSize += 2; /* u16 primitive->commandQueueSize */
+ bufferSize += 2; /* u16 primitive->trafficQueueSize */
+ return bufferSize;
+}
+
+
+u8* CsrWifiRouterCtrlCapabilitiesCfmSer(u8 *ptr, size_t *len, void *msg)
+{
+ CsrWifiRouterCtrlCapabilitiesCfm *primitive = (CsrWifiRouterCtrlCapabilitiesCfm *)msg;
+ *len = 0;
+ CsrUint16Ser(ptr, len, primitive->common.type);
+ CsrUint16Ser(ptr, len, (u16) primitive->clientData);
+ CsrUint16Ser(ptr, len, (u16) primitive->commandQueueSize);
+ CsrUint16Ser(ptr, len, (u16) primitive->trafficQueueSize);
+ return(ptr);
+}
+
+
+void* CsrWifiRouterCtrlCapabilitiesCfmDes(u8 *buffer, size_t length)
+{
+ CsrWifiRouterCtrlCapabilitiesCfm *primitive = kmalloc(sizeof(CsrWifiRouterCtrlCapabilitiesCfm), GFP_KERNEL);
+ size_t offset;
+ offset = 0;
+
+ CsrUint16Des(&primitive->common.type, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->commandQueueSize, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->trafficQueueSize, buffer, &offset);
+
+ return primitive;
+}
+
+
+size_t CsrWifiRouterCtrlBlockAckEnableCfmSizeof(void *msg)
+{
+ size_t bufferSize = 2;
+
+ /* Calculate the Size of the Serialised Data. Could be more efficient (Try 9) */
+ bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */
+ bufferSize += 2; /* u16 primitive->interfaceTag */
+ bufferSize += 2; /* CsrResult primitive->status */
+ return bufferSize;
+}
+
+
+u8* CsrWifiRouterCtrlBlockAckEnableCfmSer(u8 *ptr, size_t *len, void *msg)
+{
+ CsrWifiRouterCtrlBlockAckEnableCfm *primitive = (CsrWifiRouterCtrlBlockAckEnableCfm *)msg;
+ *len = 0;
+ CsrUint16Ser(ptr, len, primitive->common.type);
+ CsrUint16Ser(ptr, len, (u16) primitive->clientData);
+ CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
+ CsrUint16Ser(ptr, len, (u16) primitive->status);
+ return(ptr);
+}
+
+
+void* CsrWifiRouterCtrlBlockAckEnableCfmDes(u8 *buffer, size_t length)
+{
+ CsrWifiRouterCtrlBlockAckEnableCfm *primitive = kmalloc(sizeof(CsrWifiRouterCtrlBlockAckEnableCfm), GFP_KERNEL);
+ size_t offset;
+ offset = 0;
+
+ CsrUint16Des(&primitive->common.type, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
+
+ return primitive;
+}
+
+
+size_t CsrWifiRouterCtrlBlockAckDisableCfmSizeof(void *msg)
+{
+ size_t bufferSize = 2;
+
+ /* Calculate the Size of the Serialised Data. Could be more efficient (Try 9) */
+ bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */
+ bufferSize += 2; /* u16 primitive->interfaceTag */
+ bufferSize += 2; /* CsrResult primitive->status */
+ return bufferSize;
+}
+
+
+u8* CsrWifiRouterCtrlBlockAckDisableCfmSer(u8 *ptr, size_t *len, void *msg)
+{
+ CsrWifiRouterCtrlBlockAckDisableCfm *primitive = (CsrWifiRouterCtrlBlockAckDisableCfm *)msg;
+ *len = 0;
+ CsrUint16Ser(ptr, len, primitive->common.type);
+ CsrUint16Ser(ptr, len, (u16) primitive->clientData);
+ CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
+ CsrUint16Ser(ptr, len, (u16) primitive->status);
+ return(ptr);
+}
+
+
+void* CsrWifiRouterCtrlBlockAckDisableCfmDes(u8 *buffer, size_t length)
+{
+ CsrWifiRouterCtrlBlockAckDisableCfm *primitive = kmalloc(sizeof(CsrWifiRouterCtrlBlockAckDisableCfm), GFP_KERNEL);
+ size_t offset;
+ offset = 0;
+
+ CsrUint16Des(&primitive->common.type, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
+
+ return primitive;
+}
+
+
+size_t CsrWifiRouterCtrlBlockAckErrorIndSizeof(void *msg)
+{
+ size_t bufferSize = 2;
+
+ /* Calculate the Size of the Serialised Data. Could be more efficient (Try 16) */
+ bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */
+ bufferSize += 2; /* u16 primitive->interfaceTag */
+ bufferSize += 1; /* CsrWifiRouterCtrlTrafficStreamId primitive->trafficStreamID */
+ bufferSize += 6; /* u8 primitive->peerMacAddress.a[6] */
+ bufferSize += 2; /* CsrResult primitive->status */
+ return bufferSize;
+}
+
+
+u8* CsrWifiRouterCtrlBlockAckErrorIndSer(u8 *ptr, size_t *len, void *msg)
+{
+ CsrWifiRouterCtrlBlockAckErrorInd *primitive = (CsrWifiRouterCtrlBlockAckErrorInd *)msg;
+ *len = 0;
+ CsrUint16Ser(ptr, len, primitive->common.type);
+ CsrUint16Ser(ptr, len, (u16) primitive->clientData);
+ CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
+ CsrUint8Ser(ptr, len, (u8) primitive->trafficStreamID);
+ CsrMemCpySer(ptr, len, (const void *) primitive->peerMacAddress.a, ((u16) (6)));
+ CsrUint16Ser(ptr, len, (u16) primitive->status);
+ return(ptr);
+}
+
+
+void* CsrWifiRouterCtrlBlockAckErrorIndDes(u8 *buffer, size_t length)
+{
+ CsrWifiRouterCtrlBlockAckErrorInd *primitive = kmalloc(sizeof(CsrWifiRouterCtrlBlockAckErrorInd), GFP_KERNEL);
+ size_t offset;
+ offset = 0;
+
+ CsrUint16Des(&primitive->common.type, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->trafficStreamID, buffer, &offset);
+ CsrMemCpyDes(primitive->peerMacAddress.a, buffer, &offset, ((u16) (6)));
+ CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
+
+ return primitive;
+}
+
+
+size_t CsrWifiRouterCtrlStaInactiveIndSizeof(void *msg)
+{
+ size_t bufferSize = 2;
+
+ /* Calculate the Size of the Serialised Data. Could be more efficient (Try 13) */
+ bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */
+ bufferSize += 2; /* u16 primitive->interfaceTag */
+ bufferSize += 6; /* u8 primitive->staAddress.a[6] */
+ return bufferSize;
+}
+
+
+u8* CsrWifiRouterCtrlStaInactiveIndSer(u8 *ptr, size_t *len, void *msg)
+{
+ CsrWifiRouterCtrlStaInactiveInd *primitive = (CsrWifiRouterCtrlStaInactiveInd *)msg;
+ *len = 0;
+ CsrUint16Ser(ptr, len, primitive->common.type);
+ CsrUint16Ser(ptr, len, (u16) primitive->clientData);
+ CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
+ CsrMemCpySer(ptr, len, (const void *) primitive->staAddress.a, ((u16) (6)));
+ return(ptr);
+}
+
+
+void* CsrWifiRouterCtrlStaInactiveIndDes(u8 *buffer, size_t length)
+{
+ CsrWifiRouterCtrlStaInactiveInd *primitive = kmalloc(sizeof(CsrWifiRouterCtrlStaInactiveInd), GFP_KERNEL);
+ size_t offset;
+ offset = 0;
+
+ CsrUint16Des(&primitive->common.type, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
+ CsrMemCpyDes(primitive->staAddress.a, buffer, &offset, ((u16) (6)));
+
+ return primitive;
+}
+
+
+size_t CsrWifiRouterCtrlWapiRxMicCheckIndSizeof(void *msg)
+{
+ CsrWifiRouterCtrlWapiRxMicCheckInd *primitive = (CsrWifiRouterCtrlWapiRxMicCheckInd *) msg;
+ size_t bufferSize = 2;
+
+ /* Calculate the Size of the Serialised Data. Could be more efficient (Try 13) */
+ bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */
+ bufferSize += 2; /* u16 primitive->interfaceTag */
+ bufferSize += 2; /* u16 primitive->signalLength */
+ bufferSize += primitive->signalLength; /* u8 primitive->signal */
+ bufferSize += 2; /* u16 primitive->dataLength */
+ bufferSize += primitive->dataLength; /* u8 primitive->data */
+ return bufferSize;
+}
+
+
+u8* CsrWifiRouterCtrlWapiRxMicCheckIndSer(u8 *ptr, size_t *len, void *msg)
+{
+ CsrWifiRouterCtrlWapiRxMicCheckInd *primitive = (CsrWifiRouterCtrlWapiRxMicCheckInd *)msg;
+ *len = 0;
+ CsrUint16Ser(ptr, len, primitive->common.type);
+ CsrUint16Ser(ptr, len, (u16) primitive->clientData);
+ CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
+ CsrUint16Ser(ptr, len, (u16) primitive->signalLength);
+ if (primitive->signalLength)
+ {
+ CsrMemCpySer(ptr, len, (const void *) primitive->signal, ((u16) (primitive->signalLength)));
+ }
+ CsrUint16Ser(ptr, len, (u16) primitive->dataLength);
+ if (primitive->dataLength)
+ {
+ CsrMemCpySer(ptr, len, (const void *) primitive->data, ((u16) (primitive->dataLength)));
+ }
+ return(ptr);
+}
+
+
+void* CsrWifiRouterCtrlWapiRxMicCheckIndDes(u8 *buffer, size_t length)
+{
+ CsrWifiRouterCtrlWapiRxMicCheckInd *primitive = kmalloc(sizeof(CsrWifiRouterCtrlWapiRxMicCheckInd), GFP_KERNEL);
+ size_t offset;
+ offset = 0;
+
+ CsrUint16Des(&primitive->common.type, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->signalLength, buffer, &offset);
+ if (primitive->signalLength)
+ {
+ primitive->signal = kmalloc(primitive->signalLength, GFP_KERNEL);
+ CsrMemCpyDes(primitive->signal, buffer, &offset, ((u16) (primitive->signalLength)));
+ }
+ else
+ {
+ primitive->signal = NULL;
+ }
+ CsrUint16Des((u16 *) &primitive->dataLength, buffer, &offset);
+ if (primitive->dataLength)
+ {
+ primitive->data = kmalloc(primitive->dataLength, GFP_KERNEL);
+ CsrMemCpyDes(primitive->data, buffer, &offset, ((u16) (primitive->dataLength)));
+ }
+ else
+ {
+ primitive->data = NULL;
+ }
+
+ return primitive;
+}
+
+
+void CsrWifiRouterCtrlWapiRxMicCheckIndSerFree(void *voidPrimitivePointer)
+{
+ CsrWifiRouterCtrlWapiRxMicCheckInd *primitive = (CsrWifiRouterCtrlWapiRxMicCheckInd *) voidPrimitivePointer;
+ kfree(primitive->signal);
+ kfree(primitive->data);
+ kfree(primitive);
+}
+
+
+size_t CsrWifiRouterCtrlModeSetCfmSizeof(void *msg)
+{
+ size_t bufferSize = 2;
+
+ /* Calculate the Size of the Serialised Data. Could be more efficient (Try 10) */
+ bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */
+ bufferSize += 2; /* u16 primitive->interfaceTag */
+ bufferSize += 1; /* CsrWifiRouterCtrlMode primitive->mode */
+ bufferSize += 2; /* CsrResult primitive->status */
+ return bufferSize;
+}
+
+
+u8* CsrWifiRouterCtrlModeSetCfmSer(u8 *ptr, size_t *len, void *msg)
+{
+ CsrWifiRouterCtrlModeSetCfm *primitive = (CsrWifiRouterCtrlModeSetCfm *)msg;
+ *len = 0;
+ CsrUint16Ser(ptr, len, primitive->common.type);
+ CsrUint16Ser(ptr, len, (u16) primitive->clientData);
+ CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
+ CsrUint8Ser(ptr, len, (u8) primitive->mode);
+ CsrUint16Ser(ptr, len, (u16) primitive->status);
+ return(ptr);
+}
+
+
+void* CsrWifiRouterCtrlModeSetCfmDes(u8 *buffer, size_t length)
+{
+ CsrWifiRouterCtrlModeSetCfm *primitive = kmalloc(sizeof(CsrWifiRouterCtrlModeSetCfm), GFP_KERNEL);
+ size_t offset;
+ offset = 0;
+
+ CsrUint16Des(&primitive->common.type, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->mode, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
+
+ return primitive;
+}
+
+
+size_t CsrWifiRouterCtrlWapiUnicastTxEncryptIndSizeof(void *msg)
+{
+ CsrWifiRouterCtrlWapiUnicastTxEncryptInd *primitive = (CsrWifiRouterCtrlWapiUnicastTxEncryptInd *) msg;
+ size_t bufferSize = 2;
+
+ /* Calculate the Size of the Serialised Data. Could be more efficient (Try 10) */
+ bufferSize += 2; /* CsrWifiRouterCtrlRequestorInfo primitive->clientData */
+ bufferSize += 2; /* u16 primitive->interfaceTag */
+ bufferSize += 2; /* u16 primitive->dataLength */
+ bufferSize += primitive->dataLength; /* u8 primitive->data */
+ return bufferSize;
+}
+
+
+u8* CsrWifiRouterCtrlWapiUnicastTxEncryptIndSer(u8 *ptr, size_t *len, void *msg)
+{
+ CsrWifiRouterCtrlWapiUnicastTxEncryptInd *primitive = (CsrWifiRouterCtrlWapiUnicastTxEncryptInd *)msg;
+ *len = 0;
+ CsrUint16Ser(ptr, len, primitive->common.type);
+ CsrUint16Ser(ptr, len, (u16) primitive->clientData);
+ CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
+ CsrUint16Ser(ptr, len, (u16) primitive->dataLength);
+ if (primitive->dataLength)
+ {
+ CsrMemCpySer(ptr, len, (const void *) primitive->data, ((u16) (primitive->dataLength)));
+ }
+ return(ptr);
+}
+
+
+void* CsrWifiRouterCtrlWapiUnicastTxEncryptIndDes(u8 *buffer, size_t length)
+{
+ CsrWifiRouterCtrlWapiUnicastTxEncryptInd *primitive = kmalloc(sizeof(CsrWifiRouterCtrlWapiUnicastTxEncryptInd), GFP_KERNEL);
+ size_t offset;
+ offset = 0;
+
+ CsrUint16Des(&primitive->common.type, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->clientData, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->dataLength, buffer, &offset);
+ if (primitive->dataLength)
+ {
+ primitive->data = kmalloc(primitive->dataLength, GFP_KERNEL);
+ CsrMemCpyDes(primitive->data, buffer, &offset, ((u16) (primitive->dataLength)));
+ }
+ else
+ {
+ primitive->data = NULL;
+ }
+
+ return primitive;
+}
+
+
+void CsrWifiRouterCtrlWapiUnicastTxEncryptIndSerFree(void *voidPrimitivePointer)
+{
+ CsrWifiRouterCtrlWapiUnicastTxEncryptInd *primitive = (CsrWifiRouterCtrlWapiUnicastTxEncryptInd *) voidPrimitivePointer;
+ kfree(primitive->data);
+ kfree(primitive);
+}
+
+
diff --git a/drivers/staging/csr/csr_wifi_router_ctrl_serialize.h b/drivers/staging/csr/csr_wifi_router_ctrl_serialize.h
new file mode 100644
index 000000000000..2c2a229f4bf1
--- /dev/null
+++ b/drivers/staging/csr/csr_wifi_router_ctrl_serialize.h
@@ -0,0 +1,341 @@
+/*****************************************************************************
+
+ (c) Cambridge Silicon Radio Limited 2012
+ All rights reserved and confidential information of CSR
+
+ Refer to LICENSE.txt included with this source for details
+ on the license terms.
+
+*****************************************************************************/
+
+/* Note: this is an auto-generated file. */
+
+#ifndef CSR_WIFI_ROUTER_CTRL_SERIALIZE_H__
+#define CSR_WIFI_ROUTER_CTRL_SERIALIZE_H__
+
+#include "csr_wifi_msgconv.h"
+
+#include "csr_wifi_router_ctrl_prim.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern void CsrWifiRouterCtrlPfree(void *ptr);
+
+extern u8* CsrWifiRouterCtrlConfigurePowerModeReqSer(u8 *ptr, size_t *len, void *msg);
+extern void* CsrWifiRouterCtrlConfigurePowerModeReqDes(u8 *buffer, size_t len);
+extern size_t CsrWifiRouterCtrlConfigurePowerModeReqSizeof(void *msg);
+#define CsrWifiRouterCtrlConfigurePowerModeReqSerFree CsrWifiRouterCtrlPfree
+
+extern u8* CsrWifiRouterCtrlHipReqSer(u8 *ptr, size_t *len, void *msg);
+extern void* CsrWifiRouterCtrlHipReqDes(u8 *buffer, size_t len);
+extern size_t CsrWifiRouterCtrlHipReqSizeof(void *msg);
+extern void CsrWifiRouterCtrlHipReqSerFree(void *msg);
+
+extern u8* CsrWifiRouterCtrlMediaStatusReqSer(u8 *ptr, size_t *len, void *msg);
+extern void* CsrWifiRouterCtrlMediaStatusReqDes(u8 *buffer, size_t len);
+extern size_t CsrWifiRouterCtrlMediaStatusReqSizeof(void *msg);
+#define CsrWifiRouterCtrlMediaStatusReqSerFree CsrWifiRouterCtrlPfree
+
+extern u8* CsrWifiRouterCtrlMulticastAddressResSer(u8 *ptr, size_t *len, void *msg);
+extern void* CsrWifiRouterCtrlMulticastAddressResDes(u8 *buffer, size_t len);
+extern size_t CsrWifiRouterCtrlMulticastAddressResSizeof(void *msg);
+extern void CsrWifiRouterCtrlMulticastAddressResSerFree(void *msg);
+
+extern u8* CsrWifiRouterCtrlPortConfigureReqSer(u8 *ptr, size_t *len, void *msg);
+extern void* CsrWifiRouterCtrlPortConfigureReqDes(u8 *buffer, size_t len);
+extern size_t CsrWifiRouterCtrlPortConfigureReqSizeof(void *msg);
+#define CsrWifiRouterCtrlPortConfigureReqSerFree CsrWifiRouterCtrlPfree
+
+extern u8* CsrWifiRouterCtrlQosControlReqSer(u8 *ptr, size_t *len, void *msg);
+extern void* CsrWifiRouterCtrlQosControlReqDes(u8 *buffer, size_t len);
+extern size_t CsrWifiRouterCtrlQosControlReqSizeof(void *msg);
+#define CsrWifiRouterCtrlQosControlReqSerFree CsrWifiRouterCtrlPfree
+
+extern u8* CsrWifiRouterCtrlSuspendResSer(u8 *ptr, size_t *len, void *msg);
+extern void* CsrWifiRouterCtrlSuspendResDes(u8 *buffer, size_t len);
+extern size_t CsrWifiRouterCtrlSuspendResSizeof(void *msg);
+#define CsrWifiRouterCtrlSuspendResSerFree CsrWifiRouterCtrlPfree
+
+extern u8* CsrWifiRouterCtrlTclasAddReqSer(u8 *ptr, size_t *len, void *msg);
+extern void* CsrWifiRouterCtrlTclasAddReqDes(u8 *buffer, size_t len);
+extern size_t CsrWifiRouterCtrlTclasAddReqSizeof(void *msg);
+extern void CsrWifiRouterCtrlTclasAddReqSerFree(void *msg);
+
+extern u8* CsrWifiRouterCtrlResumeResSer(u8 *ptr, size_t *len, void *msg);
+extern void* CsrWifiRouterCtrlResumeResDes(u8 *buffer, size_t len);
+extern size_t CsrWifiRouterCtrlResumeResSizeof(void *msg);
+#define CsrWifiRouterCtrlResumeResSerFree CsrWifiRouterCtrlPfree
+
+#define CsrWifiRouterCtrlRawSdioDeinitialiseReqSer CsrWifiEventCsrUint16Ser
+#define CsrWifiRouterCtrlRawSdioDeinitialiseReqDes CsrWifiEventCsrUint16Des
+#define CsrWifiRouterCtrlRawSdioDeinitialiseReqSizeof CsrWifiEventCsrUint16Sizeof
+#define CsrWifiRouterCtrlRawSdioDeinitialiseReqSerFree CsrWifiRouterCtrlPfree
+
+#define CsrWifiRouterCtrlRawSdioInitialiseReqSer CsrWifiEventCsrUint16Ser
+#define CsrWifiRouterCtrlRawSdioInitialiseReqDes CsrWifiEventCsrUint16Des
+#define CsrWifiRouterCtrlRawSdioInitialiseReqSizeof CsrWifiEventCsrUint16Sizeof
+#define CsrWifiRouterCtrlRawSdioInitialiseReqSerFree CsrWifiRouterCtrlPfree
+
+extern u8* CsrWifiRouterCtrlTclasDelReqSer(u8 *ptr, size_t *len, void *msg);
+extern void* CsrWifiRouterCtrlTclasDelReqDes(u8 *buffer, size_t len);
+extern size_t CsrWifiRouterCtrlTclasDelReqSizeof(void *msg);
+extern void CsrWifiRouterCtrlTclasDelReqSerFree(void *msg);
+
+extern u8* CsrWifiRouterCtrlTrafficClassificationReqSer(u8 *ptr, size_t *len, void *msg);
+extern void* CsrWifiRouterCtrlTrafficClassificationReqDes(u8 *buffer, size_t len);
+extern size_t CsrWifiRouterCtrlTrafficClassificationReqSizeof(void *msg);
+#define CsrWifiRouterCtrlTrafficClassificationReqSerFree CsrWifiRouterCtrlPfree
+
+extern u8* CsrWifiRouterCtrlTrafficConfigReqSer(u8 *ptr, size_t *len, void *msg);
+extern void* CsrWifiRouterCtrlTrafficConfigReqDes(u8 *buffer, size_t len);
+extern size_t CsrWifiRouterCtrlTrafficConfigReqSizeof(void *msg);
+#define CsrWifiRouterCtrlTrafficConfigReqSerFree CsrWifiRouterCtrlPfree
+
+#define CsrWifiRouterCtrlWifiOffReqSer CsrWifiEventCsrUint16Ser
+#define CsrWifiRouterCtrlWifiOffReqDes CsrWifiEventCsrUint16Des
+#define CsrWifiRouterCtrlWifiOffReqSizeof CsrWifiEventCsrUint16Sizeof
+#define CsrWifiRouterCtrlWifiOffReqSerFree CsrWifiRouterCtrlPfree
+
+#define CsrWifiRouterCtrlWifiOffResSer CsrWifiEventCsrUint16Ser
+#define CsrWifiRouterCtrlWifiOffResDes CsrWifiEventCsrUint16Des
+#define CsrWifiRouterCtrlWifiOffResSizeof CsrWifiEventCsrUint16Sizeof
+#define CsrWifiRouterCtrlWifiOffResSerFree CsrWifiRouterCtrlPfree
+
+extern u8* CsrWifiRouterCtrlWifiOnReqSer(u8 *ptr, size_t *len, void *msg);
+extern void* CsrWifiRouterCtrlWifiOnReqDes(u8 *buffer, size_t len);
+extern size_t CsrWifiRouterCtrlWifiOnReqSizeof(void *msg);
+extern void CsrWifiRouterCtrlWifiOnReqSerFree(void *msg);
+
+extern u8* CsrWifiRouterCtrlWifiOnResSer(u8 *ptr, size_t *len, void *msg);
+extern void* CsrWifiRouterCtrlWifiOnResDes(u8 *buffer, size_t len);
+extern size_t CsrWifiRouterCtrlWifiOnResSizeof(void *msg);
+extern void CsrWifiRouterCtrlWifiOnResSerFree(void *msg);
+
+extern u8* CsrWifiRouterCtrlM4TransmitReqSer(u8 *ptr, size_t *len, void *msg);
+extern void* CsrWifiRouterCtrlM4TransmitReqDes(u8 *buffer, size_t len);
+extern size_t CsrWifiRouterCtrlM4TransmitReqSizeof(void *msg);
+#define CsrWifiRouterCtrlM4TransmitReqSerFree CsrWifiRouterCtrlPfree
+
+extern u8* CsrWifiRouterCtrlModeSetReqSer(u8 *ptr, size_t *len, void *msg);
+extern void* CsrWifiRouterCtrlModeSetReqDes(u8 *buffer, size_t len);
+extern size_t CsrWifiRouterCtrlModeSetReqSizeof(void *msg);
+#define CsrWifiRouterCtrlModeSetReqSerFree CsrWifiRouterCtrlPfree
+
+extern u8* CsrWifiRouterCtrlPeerAddReqSer(u8 *ptr, size_t *len, void *msg);
+extern void* CsrWifiRouterCtrlPeerAddReqDes(u8 *buffer, size_t len);
+extern size_t CsrWifiRouterCtrlPeerAddReqSizeof(void *msg);
+#define CsrWifiRouterCtrlPeerAddReqSerFree CsrWifiRouterCtrlPfree
+
+extern u8* CsrWifiRouterCtrlPeerDelReqSer(u8 *ptr, size_t *len, void *msg);
+extern void* CsrWifiRouterCtrlPeerDelReqDes(u8 *buffer, size_t len);
+extern size_t CsrWifiRouterCtrlPeerDelReqSizeof(void *msg);
+#define CsrWifiRouterCtrlPeerDelReqSerFree CsrWifiRouterCtrlPfree
+
+extern u8* CsrWifiRouterCtrlPeerUpdateReqSer(u8 *ptr, size_t *len, void *msg);
+extern void* CsrWifiRouterCtrlPeerUpdateReqDes(u8 *buffer, size_t len);
+extern size_t CsrWifiRouterCtrlPeerUpdateReqSizeof(void *msg);
+#define CsrWifiRouterCtrlPeerUpdateReqSerFree CsrWifiRouterCtrlPfree
+
+#define CsrWifiRouterCtrlCapabilitiesReqSer CsrWifiEventCsrUint16Ser
+#define CsrWifiRouterCtrlCapabilitiesReqDes CsrWifiEventCsrUint16Des
+#define CsrWifiRouterCtrlCapabilitiesReqSizeof CsrWifiEventCsrUint16Sizeof
+#define CsrWifiRouterCtrlCapabilitiesReqSerFree CsrWifiRouterCtrlPfree
+
+extern u8* CsrWifiRouterCtrlBlockAckEnableReqSer(u8 *ptr, size_t *len, void *msg);
+extern void* CsrWifiRouterCtrlBlockAckEnableReqDes(u8 *buffer, size_t len);
+extern size_t CsrWifiRouterCtrlBlockAckEnableReqSizeof(void *msg);
+#define CsrWifiRouterCtrlBlockAckEnableReqSerFree CsrWifiRouterCtrlPfree
+
+extern u8* CsrWifiRouterCtrlBlockAckDisableReqSer(u8 *ptr, size_t *len, void *msg);
+extern void* CsrWifiRouterCtrlBlockAckDisableReqDes(u8 *buffer, size_t len);
+extern size_t CsrWifiRouterCtrlBlockAckDisableReqSizeof(void *msg);
+#define CsrWifiRouterCtrlBlockAckDisableReqSerFree CsrWifiRouterCtrlPfree
+
+extern u8* CsrWifiRouterCtrlWapiRxPktReqSer(u8 *ptr, size_t *len, void *msg);
+extern void* CsrWifiRouterCtrlWapiRxPktReqDes(u8 *buffer, size_t len);
+extern size_t CsrWifiRouterCtrlWapiRxPktReqSizeof(void *msg);
+extern void CsrWifiRouterCtrlWapiRxPktReqSerFree(void *msg);
+
+#define CsrWifiRouterCtrlWapiMulticastFilterReqSer CsrWifiEventCsrUint16CsrUint8Ser
+#define CsrWifiRouterCtrlWapiMulticastFilterReqDes CsrWifiEventCsrUint16CsrUint8Des
+#define CsrWifiRouterCtrlWapiMulticastFilterReqSizeof CsrWifiEventCsrUint16CsrUint8Sizeof
+#define CsrWifiRouterCtrlWapiMulticastFilterReqSerFree CsrWifiRouterCtrlPfree
+
+#define CsrWifiRouterCtrlWapiUnicastFilterReqSer CsrWifiEventCsrUint16CsrUint8Ser
+#define CsrWifiRouterCtrlWapiUnicastFilterReqDes CsrWifiEventCsrUint16CsrUint8Des
+#define CsrWifiRouterCtrlWapiUnicastFilterReqSizeof CsrWifiEventCsrUint16CsrUint8Sizeof
+#define CsrWifiRouterCtrlWapiUnicastFilterReqSerFree CsrWifiRouterCtrlPfree
+
+extern u8* CsrWifiRouterCtrlWapiUnicastTxPktReqSer(u8 *ptr, size_t *len, void *msg);
+extern void* CsrWifiRouterCtrlWapiUnicastTxPktReqDes(u8 *buffer, size_t len);
+extern size_t CsrWifiRouterCtrlWapiUnicastTxPktReqSizeof(void *msg);
+extern void CsrWifiRouterCtrlWapiUnicastTxPktReqSerFree(void *msg);
+
+#define CsrWifiRouterCtrlWapiFilterReqSer CsrWifiEventCsrUint16CsrUint8Ser
+#define CsrWifiRouterCtrlWapiFilterReqDes CsrWifiEventCsrUint16CsrUint8Des
+#define CsrWifiRouterCtrlWapiFilterReqSizeof CsrWifiEventCsrUint16CsrUint8Sizeof
+#define CsrWifiRouterCtrlWapiFilterReqSerFree CsrWifiRouterCtrlPfree
+
+extern u8* CsrWifiRouterCtrlHipIndSer(u8 *ptr, size_t *len, void *msg);
+extern void* CsrWifiRouterCtrlHipIndDes(u8 *buffer, size_t len);
+extern size_t CsrWifiRouterCtrlHipIndSizeof(void *msg);
+extern void CsrWifiRouterCtrlHipIndSerFree(void *msg);
+
+extern u8* CsrWifiRouterCtrlMulticastAddressIndSer(u8 *ptr, size_t *len, void *msg);
+extern void* CsrWifiRouterCtrlMulticastAddressIndDes(u8 *buffer, size_t len);
+extern size_t CsrWifiRouterCtrlMulticastAddressIndSizeof(void *msg);
+extern void CsrWifiRouterCtrlMulticastAddressIndSerFree(void *msg);
+
+extern u8* CsrWifiRouterCtrlPortConfigureCfmSer(u8 *ptr, size_t *len, void *msg);
+extern void* CsrWifiRouterCtrlPortConfigureCfmDes(u8 *buffer, size_t len);
+extern size_t CsrWifiRouterCtrlPortConfigureCfmSizeof(void *msg);
+#define CsrWifiRouterCtrlPortConfigureCfmSerFree CsrWifiRouterCtrlPfree
+
+#define CsrWifiRouterCtrlResumeIndSer CsrWifiEventCsrUint16CsrUint8Ser
+#define CsrWifiRouterCtrlResumeIndDes CsrWifiEventCsrUint16CsrUint8Des
+#define CsrWifiRouterCtrlResumeIndSizeof CsrWifiEventCsrUint16CsrUint8Sizeof
+#define CsrWifiRouterCtrlResumeIndSerFree CsrWifiRouterCtrlPfree
+
+extern u8* CsrWifiRouterCtrlSuspendIndSer(u8 *ptr, size_t *len, void *msg);
+extern void* CsrWifiRouterCtrlSuspendIndDes(u8 *buffer, size_t len);
+extern size_t CsrWifiRouterCtrlSuspendIndSizeof(void *msg);
+#define CsrWifiRouterCtrlSuspendIndSerFree CsrWifiRouterCtrlPfree
+
+extern u8* CsrWifiRouterCtrlTclasAddCfmSer(u8 *ptr, size_t *len, void *msg);
+extern void* CsrWifiRouterCtrlTclasAddCfmDes(u8 *buffer, size_t len);
+extern size_t CsrWifiRouterCtrlTclasAddCfmSizeof(void *msg);
+#define CsrWifiRouterCtrlTclasAddCfmSerFree CsrWifiRouterCtrlPfree
+
+extern u8* CsrWifiRouterCtrlRawSdioDeinitialiseCfmSer(u8 *ptr, size_t *len, void *msg);
+extern void* CsrWifiRouterCtrlRawSdioDeinitialiseCfmDes(u8 *buffer, size_t len);
+extern size_t CsrWifiRouterCtrlRawSdioDeinitialiseCfmSizeof(void *msg);
+#define CsrWifiRouterCtrlRawSdioDeinitialiseCfmSerFree CsrWifiRouterCtrlPfree
+
+extern u8* CsrWifiRouterCtrlRawSdioInitialiseCfmSer(u8 *ptr, size_t *len, void *msg);
+extern void* CsrWifiRouterCtrlRawSdioInitialiseCfmDes(u8 *buffer, size_t len);
+extern size_t CsrWifiRouterCtrlRawSdioInitialiseCfmSizeof(void *msg);
+#define CsrWifiRouterCtrlRawSdioInitialiseCfmSerFree CsrWifiRouterCtrlPfree
+
+extern u8* CsrWifiRouterCtrlTclasDelCfmSer(u8 *ptr, size_t *len, void *msg);
+extern void* CsrWifiRouterCtrlTclasDelCfmDes(u8 *buffer, size_t len);
+extern size_t CsrWifiRouterCtrlTclasDelCfmSizeof(void *msg);
+#define CsrWifiRouterCtrlTclasDelCfmSerFree CsrWifiRouterCtrlPfree
+
+extern u8* CsrWifiRouterCtrlTrafficProtocolIndSer(u8 *ptr, size_t *len, void *msg);
+extern void* CsrWifiRouterCtrlTrafficProtocolIndDes(u8 *buffer, size_t len);
+extern size_t CsrWifiRouterCtrlTrafficProtocolIndSizeof(void *msg);
+#define CsrWifiRouterCtrlTrafficProtocolIndSerFree CsrWifiRouterCtrlPfree
+
+extern u8* CsrWifiRouterCtrlTrafficSampleIndSer(u8 *ptr, size_t *len, void *msg);
+extern void* CsrWifiRouterCtrlTrafficSampleIndDes(u8 *buffer, size_t len);
+extern size_t CsrWifiRouterCtrlTrafficSampleIndSizeof(void *msg);
+#define CsrWifiRouterCtrlTrafficSampleIndSerFree CsrWifiRouterCtrlPfree
+
+#define CsrWifiRouterCtrlWifiOffIndSer CsrWifiEventCsrUint16CsrUint8Ser
+#define CsrWifiRouterCtrlWifiOffIndDes CsrWifiEventCsrUint16CsrUint8Des
+#define CsrWifiRouterCtrlWifiOffIndSizeof CsrWifiEventCsrUint16CsrUint8Sizeof
+#define CsrWifiRouterCtrlWifiOffIndSerFree CsrWifiRouterCtrlPfree
+
+#define CsrWifiRouterCtrlWifiOffCfmSer CsrWifiEventCsrUint16Ser
+#define CsrWifiRouterCtrlWifiOffCfmDes CsrWifiEventCsrUint16Des
+#define CsrWifiRouterCtrlWifiOffCfmSizeof CsrWifiEventCsrUint16Sizeof
+#define CsrWifiRouterCtrlWifiOffCfmSerFree CsrWifiRouterCtrlPfree
+
+extern u8* CsrWifiRouterCtrlWifiOnIndSer(u8 *ptr, size_t *len, void *msg);
+extern void* CsrWifiRouterCtrlWifiOnIndDes(u8 *buffer, size_t len);
+extern size_t CsrWifiRouterCtrlWifiOnIndSizeof(void *msg);
+extern void CsrWifiRouterCtrlWifiOnIndSerFree(void *msg);
+
+extern u8* CsrWifiRouterCtrlWifiOnCfmSer(u8 *ptr, size_t *len, void *msg);
+extern void* CsrWifiRouterCtrlWifiOnCfmDes(u8 *buffer, size_t len);
+extern size_t CsrWifiRouterCtrlWifiOnCfmSizeof(void *msg);
+#define CsrWifiRouterCtrlWifiOnCfmSerFree CsrWifiRouterCtrlPfree
+
+extern u8* CsrWifiRouterCtrlM4ReadyToSendIndSer(u8 *ptr, size_t *len, void *msg);
+extern void* CsrWifiRouterCtrlM4ReadyToSendIndDes(u8 *buffer, size_t len);
+extern size_t CsrWifiRouterCtrlM4ReadyToSendIndSizeof(void *msg);
+#define CsrWifiRouterCtrlM4ReadyToSendIndSerFree CsrWifiRouterCtrlPfree
+
+extern u8* CsrWifiRouterCtrlM4TransmittedIndSer(u8 *ptr, size_t *len, void *msg);
+extern void* CsrWifiRouterCtrlM4TransmittedIndDes(u8 *buffer, size_t len);
+extern size_t CsrWifiRouterCtrlM4TransmittedIndSizeof(void *msg);
+#define CsrWifiRouterCtrlM4TransmittedIndSerFree CsrWifiRouterCtrlPfree
+
+extern u8* CsrWifiRouterCtrlMicFailureIndSer(u8 *ptr, size_t *len, void *msg);
+extern void* CsrWifiRouterCtrlMicFailureIndDes(u8 *buffer, size_t len);
+extern size_t CsrWifiRouterCtrlMicFailureIndSizeof(void *msg);
+#define CsrWifiRouterCtrlMicFailureIndSerFree CsrWifiRouterCtrlPfree
+
+extern u8* CsrWifiRouterCtrlConnectedIndSer(u8 *ptr, size_t *len, void *msg);
+extern void* CsrWifiRouterCtrlConnectedIndDes(u8 *buffer, size_t len);
+extern size_t CsrWifiRouterCtrlConnectedIndSizeof(void *msg);
+#define CsrWifiRouterCtrlConnectedIndSerFree CsrWifiRouterCtrlPfree
+
+extern u8* CsrWifiRouterCtrlPeerAddCfmSer(u8 *ptr, size_t *len, void *msg);
+extern void* CsrWifiRouterCtrlPeerAddCfmDes(u8 *buffer, size_t len);
+extern size_t CsrWifiRouterCtrlPeerAddCfmSizeof(void *msg);
+#define CsrWifiRouterCtrlPeerAddCfmSerFree CsrWifiRouterCtrlPfree
+
+extern u8* CsrWifiRouterCtrlPeerDelCfmSer(u8 *ptr, size_t *len, void *msg);
+extern void* CsrWifiRouterCtrlPeerDelCfmDes(u8 *buffer, size_t len);
+extern size_t CsrWifiRouterCtrlPeerDelCfmSizeof(void *msg);
+#define CsrWifiRouterCtrlPeerDelCfmSerFree CsrWifiRouterCtrlPfree
+
+extern u8* CsrWifiRouterCtrlUnexpectedFrameIndSer(u8 *ptr, size_t *len, void *msg);
+extern void* CsrWifiRouterCtrlUnexpectedFrameIndDes(u8 *buffer, size_t len);
+extern size_t CsrWifiRouterCtrlUnexpectedFrameIndSizeof(void *msg);
+#define CsrWifiRouterCtrlUnexpectedFrameIndSerFree CsrWifiRouterCtrlPfree
+
+extern u8* CsrWifiRouterCtrlPeerUpdateCfmSer(u8 *ptr, size_t *len, void *msg);
+extern void* CsrWifiRouterCtrlPeerUpdateCfmDes(u8 *buffer, size_t len);
+extern size_t CsrWifiRouterCtrlPeerUpdateCfmSizeof(void *msg);
+#define CsrWifiRouterCtrlPeerUpdateCfmSerFree CsrWifiRouterCtrlPfree
+
+extern u8* CsrWifiRouterCtrlCapabilitiesCfmSer(u8 *ptr, size_t *len, void *msg);
+extern void* CsrWifiRouterCtrlCapabilitiesCfmDes(u8 *buffer, size_t len);
+extern size_t CsrWifiRouterCtrlCapabilitiesCfmSizeof(void *msg);
+#define CsrWifiRouterCtrlCapabilitiesCfmSerFree CsrWifiRouterCtrlPfree
+
+extern u8* CsrWifiRouterCtrlBlockAckEnableCfmSer(u8 *ptr, size_t *len, void *msg);
+extern void* CsrWifiRouterCtrlBlockAckEnableCfmDes(u8 *buffer, size_t len);
+extern size_t CsrWifiRouterCtrlBlockAckEnableCfmSizeof(void *msg);
+#define CsrWifiRouterCtrlBlockAckEnableCfmSerFree CsrWifiRouterCtrlPfree
+
+extern u8* CsrWifiRouterCtrlBlockAckDisableCfmSer(u8 *ptr, size_t *len, void *msg);
+extern void* CsrWifiRouterCtrlBlockAckDisableCfmDes(u8 *buffer, size_t len);
+extern size_t CsrWifiRouterCtrlBlockAckDisableCfmSizeof(void *msg);
+#define CsrWifiRouterCtrlBlockAckDisableCfmSerFree CsrWifiRouterCtrlPfree
+
+extern u8* CsrWifiRouterCtrlBlockAckErrorIndSer(u8 *ptr, size_t *len, void *msg);
+extern void* CsrWifiRouterCtrlBlockAckErrorIndDes(u8 *buffer, size_t len);
+extern size_t CsrWifiRouterCtrlBlockAckErrorIndSizeof(void *msg);
+#define CsrWifiRouterCtrlBlockAckErrorIndSerFree CsrWifiRouterCtrlPfree
+
+extern u8* CsrWifiRouterCtrlStaInactiveIndSer(u8 *ptr, size_t *len, void *msg);
+extern void* CsrWifiRouterCtrlStaInactiveIndDes(u8 *buffer, size_t len);
+extern size_t CsrWifiRouterCtrlStaInactiveIndSizeof(void *msg);
+#define CsrWifiRouterCtrlStaInactiveIndSerFree CsrWifiRouterCtrlPfree
+
+extern u8* CsrWifiRouterCtrlWapiRxMicCheckIndSer(u8 *ptr, size_t *len, void *msg);
+extern void* CsrWifiRouterCtrlWapiRxMicCheckIndDes(u8 *buffer, size_t len);
+extern size_t CsrWifiRouterCtrlWapiRxMicCheckIndSizeof(void *msg);
+extern void CsrWifiRouterCtrlWapiRxMicCheckIndSerFree(void *msg);
+
+extern u8* CsrWifiRouterCtrlModeSetCfmSer(u8 *ptr, size_t *len, void *msg);
+extern void* CsrWifiRouterCtrlModeSetCfmDes(u8 *buffer, size_t len);
+extern size_t CsrWifiRouterCtrlModeSetCfmSizeof(void *msg);
+#define CsrWifiRouterCtrlModeSetCfmSerFree CsrWifiRouterCtrlPfree
+
+extern u8* CsrWifiRouterCtrlWapiUnicastTxEncryptIndSer(u8 *ptr, size_t *len, void *msg);
+extern void* CsrWifiRouterCtrlWapiUnicastTxEncryptIndDes(u8 *buffer, size_t len);
+extern size_t CsrWifiRouterCtrlWapiUnicastTxEncryptIndSizeof(void *msg);
+extern void CsrWifiRouterCtrlWapiUnicastTxEncryptIndSerFree(void *msg);
+
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* CSR_WIFI_ROUTER_CTRL_SERIALIZE_H__ */
+
diff --git a/drivers/staging/csr/csr_wifi_router_free_downstream_contents.c b/drivers/staging/csr/csr_wifi_router_free_downstream_contents.c
new file mode 100644
index 000000000000..c4badc565a91
--- /dev/null
+++ b/drivers/staging/csr/csr_wifi_router_free_downstream_contents.c
@@ -0,0 +1,53 @@
+/*****************************************************************************
+
+ (c) Cambridge Silicon Radio Limited 2011
+ All rights reserved and confidential information of CSR
+
+ Refer to LICENSE.txt included with this source for details
+ on the license terms.
+
+*****************************************************************************/
+
+/* Note: this is an auto-generated file. */
+#include <linux/slab.h>
+#include "csr_wifi_router_prim.h"
+#include "csr_wifi_router_lib.h"
+
+/*----------------------------------------------------------------------------*
+ * NAME
+ * CsrWifiRouterFreeDownstreamMessageContents
+ *
+ * DESCRIPTION
+ *
+ *
+ * PARAMETERS
+ * eventClass: only the value CSR_WIFI_ROUTER_PRIM will be handled
+ * message: the message to free
+ *----------------------------------------------------------------------------*/
+void CsrWifiRouterFreeDownstreamMessageContents(u16 eventClass, void *message)
+{
+ if (eventClass != CSR_WIFI_ROUTER_PRIM)
+ {
+ return;
+ }
+ if (NULL == message)
+ {
+ return;
+ }
+
+ switch (*((CsrWifiRouterPrim *) message))
+ {
+ case CSR_WIFI_ROUTER_MA_PACKET_REQ:
+ {
+ CsrWifiRouterMaPacketReq *p = (CsrWifiRouterMaPacketReq *)message;
+ kfree(p->frame);
+ p->frame = NULL;
+ break;
+ }
+
+ default:
+ break;
+ }
+}
+
+
diff --git a/drivers/staging/csr/csr_wifi_router_free_upstream_contents.c b/drivers/staging/csr/csr_wifi_router_free_upstream_contents.c
new file mode 100644
index 000000000000..de1086d7158d
--- /dev/null
+++ b/drivers/staging/csr/csr_wifi_router_free_upstream_contents.c
@@ -0,0 +1,53 @@
+/*****************************************************************************
+
+ (c) Cambridge Silicon Radio Limited 2011
+ All rights reserved and confidential information of CSR
+
+ Refer to LICENSE.txt included with this source for details
+ on the license terms.
+
+*****************************************************************************/
+
+/* Note: this is an auto-generated file. */
+#include <linux/slab.h>
+#include "csr_wifi_router_prim.h"
+#include "csr_wifi_router_lib.h"
+
+/*----------------------------------------------------------------------------*
+ * NAME
+ * CsrWifiRouterFreeUpstreamMessageContents
+ *
+ * DESCRIPTION
+ *
+ *
+ * PARAMETERS
+ * eventClass: only the value CSR_WIFI_ROUTER_PRIM will be handled
+ * message: the message to free
+ *----------------------------------------------------------------------------*/
+void CsrWifiRouterFreeUpstreamMessageContents(u16 eventClass, void *message)
+{
+ if (eventClass != CSR_WIFI_ROUTER_PRIM)
+ {
+ return;
+ }
+ if (NULL == message)
+ {
+ return;
+ }
+
+ switch (*((CsrWifiRouterPrim *) message))
+ {
+ case CSR_WIFI_ROUTER_MA_PACKET_IND:
+ {
+ CsrWifiRouterMaPacketInd *p = (CsrWifiRouterMaPacketInd *)message;
+ kfree(p->frame);
+ p->frame = NULL;
+ break;
+ }
+
+ default:
+ break;
+ }
+}
+
+
diff --git a/drivers/staging/csr/csr_wifi_router_lib.h b/drivers/staging/csr/csr_wifi_router_lib.h
new file mode 100644
index 000000000000..06a2214714b7
--- /dev/null
+++ b/drivers/staging/csr/csr_wifi_router_lib.h
@@ -0,0 +1,427 @@
+/*****************************************************************************
+
+ (c) Cambridge Silicon Radio Limited 2011
+ All rights reserved and confidential information of CSR
+
+ Refer to LICENSE.txt included with this source for details
+ on the license terms.
+
+*****************************************************************************/
+
+/* Note: this is an auto-generated file. */
+
+#ifndef CSR_WIFI_ROUTER_LIB_H__
+#define CSR_WIFI_ROUTER_LIB_H__
+
+#include "csr_sched.h"
+#include "csr_macro.h"
+#include "csr_msg_transport.h"
+
+#include "csr_wifi_lib.h"
+
+#include "csr_wifi_router_prim.h"
+#include "csr_wifi_router_task.h"
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*----------------------------------------------------------------------------*
+ * CsrWifiRouterFreeUpstreamMessageContents
+ *
+ * DESCRIPTION
+ * Free the allocated memory in a CSR_WIFI_ROUTER upstream message. Does not
+ * free the message itself, and can only be used for upstream messages.
+ *
+ * PARAMETERS
+ * Deallocates the resources in a CSR_WIFI_ROUTER upstream message
+ *----------------------------------------------------------------------------*/
+void CsrWifiRouterFreeUpstreamMessageContents(u16 eventClass, void *message);
+
+/*----------------------------------------------------------------------------*
+ * CsrWifiRouterFreeDownstreamMessageContents
+ *
+ * DESCRIPTION
+ * Free the allocated memory in a CSR_WIFI_ROUTER downstream message. Does not
+ * free the message itself, and can only be used for downstream messages.
+ *
+ * PARAMETERS
+ * Deallocates the resources in a CSR_WIFI_ROUTER downstream message
+ *----------------------------------------------------------------------------*/
+void CsrWifiRouterFreeDownstreamMessageContents(u16 eventClass, void *message);
+
+/*----------------------------------------------------------------------------*
+ * Enum to string functions
+ *----------------------------------------------------------------------------*/
+const char* CsrWifiRouterAppTypeToString(CsrWifiRouterAppType value);
+const char* CsrWifiRouterEncapsulationToString(CsrWifiRouterEncapsulation value);
+const char* CsrWifiRouterOuiToString(CsrWifiRouterOui value);
+const char* CsrWifiRouterPriorityToString(CsrWifiRouterPriority value);
+
+
+/*----------------------------------------------------------------------------*
+ * CsrPrim Type toString function.
+ * Converts a message type to the String name of the Message
+ *----------------------------------------------------------------------------*/
+const char* CsrWifiRouterPrimTypeToString(CsrPrim msgType);
+
+/*----------------------------------------------------------------------------*
+ * Lookup arrays for PrimType name Strings
+ *----------------------------------------------------------------------------*/
+extern const char *CsrWifiRouterUpstreamPrimNames[CSR_WIFI_ROUTER_PRIM_UPSTREAM_COUNT];
+extern const char *CsrWifiRouterDownstreamPrimNames[CSR_WIFI_ROUTER_PRIM_DOWNSTREAM_COUNT];
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiRouterMaPacketCancelReqSend
+
+ DESCRIPTION
+ This primitive is used to request cancellation of a previously send
+ CsrWifiRouterMaPacketReq.
+ The frame may already have been transmitted so there is no guarantees
+ that the CsrWifiRouterMaPacketCancelReq actually cancels the transmission
+ of the frame in question.
+ If the cancellation fails, the Router will send, if required,
+ CsrWifiRouterMaPacketCfm.
+ If the cancellation succeeds, the Router will not send
+ CsrWifiRouterMaPacketCfm.
+
+ PARAMETERS
+ queue - Message Source Task Queue (Cfm's will be sent to this Queue)
+ interfaceTag - Interface Identifier; unique identifier of an interface
+ hostTag - The hostTag for the frame, which should be cancelled.
+ priority - Priority of the frame, which should be cancelled
+ peerMacAddress - Destination MAC address of the frame, which should be
+ cancelled
+
+*******************************************************************************/
+#define CsrWifiRouterMaPacketCancelReqCreate(msg__, dst__, src__, interfaceTag__, hostTag__, priority__, peerMacAddress__) \
+ msg__ = kmalloc(sizeof(CsrWifiRouterMaPacketCancelReq), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_PRIM, CSR_WIFI_ROUTER_MA_PACKET_CANCEL_REQ, dst__, src__); \
+ msg__->interfaceTag = (interfaceTag__); \
+ msg__->hostTag = (hostTag__); \
+ msg__->priority = (priority__); \
+ msg__->peerMacAddress = (peerMacAddress__);
+
+#define CsrWifiRouterMaPacketCancelReqSendTo(dst__, src__, interfaceTag__, hostTag__, priority__, peerMacAddress__) \
+ { \
+ CsrWifiRouterMaPacketCancelReq *msg__; \
+ CsrWifiRouterMaPacketCancelReqCreate(msg__, dst__, src__, interfaceTag__, hostTag__, priority__, peerMacAddress__); \
+ CsrMsgTransport(dst__, CSR_WIFI_ROUTER_PRIM, msg__); \
+ }
+
+#define CsrWifiRouterMaPacketCancelReqSend(src__, interfaceTag__, hostTag__, priority__, peerMacAddress__) \
+ CsrWifiRouterMaPacketCancelReqSendTo(CSR_WIFI_ROUTER_IFACEQUEUE, src__, interfaceTag__, hostTag__, priority__, peerMacAddress__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiRouterMaPacketReqSend
+
+ DESCRIPTION
+ A task sends this primitive to transmit a frame.
+
+ PARAMETERS
+ queue - Message Source Task Queue (Cfm's will be sent to this Queue)
+ interfaceTag - Interface Identifier; unique identifier of an interface
+ subscriptionHandle - The handle of the subscription
+ frameLength - Length of the frame to be sent in bytes
+ frame - Pointer to the frame to be sent
+ freeFunction - Pointer to function to be used to free the frame
+ priority - Priority of the frame, which should be sent
+ hostTag - An application shall set the bits b31..b28 using one of
+ the CSR_WIFI_ROUTER_APP_TYPE_* masks. Bits b0..b27 can
+ be used by the requestor without any restrictions, but
+ the hostTag shall be unique so the hostTag for
+ CSR_WIFI_ROUTER_APP _TYPE_OTHER should be constructured
+ in the following way [ CSR_WIFI_ROUTER_APP_TYPE_OTHER
+ (4 bits) | SubscriptionHandle (8 bits) | Sequence no.
+ (20 bits) ]. If the hostTag is not unique, the
+ behaviour of the system is unpredicatable with respect
+ to data/management frame transfer.
+ cfmRequested - Indicates if the requestor needs a confirm for packet
+ requests sent under this subscription. If set to TRUE,
+ the router will send a confirm, else it will not send
+ any confirm
+
+*******************************************************************************/
+#define CsrWifiRouterMaPacketReqCreate(msg__, dst__, src__, interfaceTag__, subscriptionHandle__, frameLength__, frame__, freeFunction__, priority__, hostTag__, cfmRequested__) \
+ msg__ = kmalloc(sizeof(CsrWifiRouterMaPacketReq), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_PRIM, CSR_WIFI_ROUTER_MA_PACKET_REQ, dst__, src__); \
+ msg__->interfaceTag = (interfaceTag__); \
+ msg__->subscriptionHandle = (subscriptionHandle__); \
+ msg__->frameLength = (frameLength__); \
+ msg__->frame = (frame__); \
+ msg__->freeFunction = (freeFunction__); \
+ msg__->priority = (priority__); \
+ msg__->hostTag = (hostTag__); \
+ msg__->cfmRequested = (cfmRequested__);
+
+#define CsrWifiRouterMaPacketReqSendTo(dst__, src__, interfaceTag__, subscriptionHandle__, frameLength__, frame__, freeFunction__, priority__, hostTag__, cfmRequested__) \
+ { \
+ CsrWifiRouterMaPacketReq *msg__; \
+ CsrWifiRouterMaPacketReqCreate(msg__, dst__, src__, interfaceTag__, subscriptionHandle__, frameLength__, frame__, freeFunction__, priority__, hostTag__, cfmRequested__); \
+ CsrMsgTransport(dst__, CSR_WIFI_ROUTER_PRIM, msg__); \
+ }
+
+#define CsrWifiRouterMaPacketReqSend(src__, interfaceTag__, subscriptionHandle__, frameLength__, frame__, freeFunction__, priority__, hostTag__, cfmRequested__) \
+ CsrWifiRouterMaPacketReqSendTo(CSR_WIFI_ROUTER_IFACEQUEUE, src__, interfaceTag__, subscriptionHandle__, frameLength__, frame__, freeFunction__, priority__, hostTag__, cfmRequested__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiRouterMaPacketIndSend
+
+ DESCRIPTION
+ The router sends the primitive to a subscribed task when it receives a
+ frame matching the subscription.
+
+ PARAMETERS
+ queue - Destination Task Queue
+ interfaceTag - Interface Identifier; unique identifier of an interface
+ subscriptionHandle - The handle of the subscription
+ result - Status of the operation
+ frameLength - Length of the received frame in bytes
+ frame - Pointer to the received frame
+ freeFunction - Pointer to function to be used to free the frame
+ rssi - Received signal strength indication in dBm
+ snr - Signal to Noise Ratio
+ rate - Transmission/Reception rate
+
+*******************************************************************************/
+#define CsrWifiRouterMaPacketIndCreate(msg__, dst__, src__, interfaceTag__, subscriptionHandle__, result__, frameLength__, frame__, freeFunction__, rssi__, snr__, rate__) \
+ msg__ = kmalloc(sizeof(CsrWifiRouterMaPacketInd), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_PRIM, CSR_WIFI_ROUTER_MA_PACKET_IND, dst__, src__); \
+ msg__->interfaceTag = (interfaceTag__); \
+ msg__->subscriptionHandle = (subscriptionHandle__); \
+ msg__->result = (result__); \
+ msg__->frameLength = (frameLength__); \
+ msg__->frame = (frame__); \
+ msg__->freeFunction = (freeFunction__); \
+ msg__->rssi = (rssi__); \
+ msg__->snr = (snr__); \
+ msg__->rate = (rate__);
+
+#define CsrWifiRouterMaPacketIndSendTo(dst__, src__, interfaceTag__, subscriptionHandle__, result__, frameLength__, frame__, freeFunction__, rssi__, snr__, rate__) \
+ { \
+ CsrWifiRouterMaPacketInd *msg__; \
+ CsrWifiRouterMaPacketIndCreate(msg__, dst__, src__, interfaceTag__, subscriptionHandle__, result__, frameLength__, frame__, freeFunction__, rssi__, snr__, rate__); \
+ CsrSchedMessagePut(dst__, CSR_WIFI_ROUTER_PRIM, msg__); \
+ }
+
+#define CsrWifiRouterMaPacketIndSend(dst__, interfaceTag__, subscriptionHandle__, result__, frameLength__, frame__, freeFunction__, rssi__, snr__, rate__) \
+ CsrWifiRouterMaPacketIndSendTo(dst__, CSR_WIFI_ROUTER_IFACEQUEUE, interfaceTag__, subscriptionHandle__, result__, frameLength__, frame__, freeFunction__, rssi__, snr__, rate__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiRouterMaPacketResSend
+
+ DESCRIPTION
+ A task send this primitive to confirm the reception of the received
+ frame.
+
+ PARAMETERS
+ interfaceTag - Interface Identifier; unique identifier of an interface
+ subscriptionHandle - The handle of the subscription
+ result - Status of the operation
+
+*******************************************************************************/
+#define CsrWifiRouterMaPacketResCreate(msg__, dst__, src__, interfaceTag__, subscriptionHandle__, result__) \
+ msg__ = kmalloc(sizeof(CsrWifiRouterMaPacketRes), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_PRIM, CSR_WIFI_ROUTER_MA_PACKET_RES, dst__, src__); \
+ msg__->interfaceTag = (interfaceTag__); \
+ msg__->subscriptionHandle = (subscriptionHandle__); \
+ msg__->result = (result__);
+
+#define CsrWifiRouterMaPacketResSendTo(dst__, src__, interfaceTag__, subscriptionHandle__, result__) \
+ { \
+ CsrWifiRouterMaPacketRes *msg__; \
+ CsrWifiRouterMaPacketResCreate(msg__, dst__, src__, interfaceTag__, subscriptionHandle__, result__); \
+ CsrMsgTransport(dst__, CSR_WIFI_ROUTER_PRIM, msg__); \
+ }
+
+#define CsrWifiRouterMaPacketResSend(src__, interfaceTag__, subscriptionHandle__, result__) \
+ CsrWifiRouterMaPacketResSendTo(CSR_WIFI_ROUTER_IFACEQUEUE, src__, interfaceTag__, subscriptionHandle__, result__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiRouterMaPacketCfmSend
+
+ DESCRIPTION
+ The router sends the primitive to confirm the result of the transmission
+ of the packet of the corresponding CSR_WIFI_ROUTER MA_PACKET_REQ request.
+
+ PARAMETERS
+ queue - Destination Task Queue
+ interfaceTag - Interface Identifier; unique identifier of an interface
+ result - Status of the operation
+ hostTag - The hostTrag will match the hostTag sent in the request.
+ rate - Transmission/Reception rate
+
+*******************************************************************************/
+#define CsrWifiRouterMaPacketCfmCreate(msg__, dst__, src__, interfaceTag__, result__, hostTag__, rate__) \
+ msg__ = kmalloc(sizeof(CsrWifiRouterMaPacketCfm), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_PRIM, CSR_WIFI_ROUTER_MA_PACKET_CFM, dst__, src__); \
+ msg__->interfaceTag = (interfaceTag__); \
+ msg__->result = (result__); \
+ msg__->hostTag = (hostTag__); \
+ msg__->rate = (rate__);
+
+#define CsrWifiRouterMaPacketCfmSendTo(dst__, src__, interfaceTag__, result__, hostTag__, rate__) \
+ { \
+ CsrWifiRouterMaPacketCfm *msg__; \
+ CsrWifiRouterMaPacketCfmCreate(msg__, dst__, src__, interfaceTag__, result__, hostTag__, rate__); \
+ CsrSchedMessagePut(dst__, CSR_WIFI_ROUTER_PRIM, msg__); \
+ }
+
+#define CsrWifiRouterMaPacketCfmSend(dst__, interfaceTag__, result__, hostTag__, rate__) \
+ CsrWifiRouterMaPacketCfmSendTo(dst__, CSR_WIFI_ROUTER_IFACEQUEUE, interfaceTag__, result__, hostTag__, rate__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiRouterMaPacketSubscribeReqSend
+
+ DESCRIPTION
+ A task can use this primitive to subscribe for a particular OUI/protocol
+ and transmit and receive frames matching the subscription.
+ NOTE: Multiple subscriptions for a given protocol and OUI will result in
+ the first subscription receiving the data and not the subsequent
+ subscriptions.
+
+ PARAMETERS
+ queue - Message Source Task Queue (Cfm's will be sent to this Queue)
+ interfaceTag - Interface Identifier; unique identifier of an interface
+ encapsulation - Specifies the encapsulation type, which will be used for the
+ subscription
+ protocol - Together with the OUI, specifies the protocol, which a task
+ wants to subscribe to
+ oui - Specifies the OUI for the protocol, which a task wants to
+ subscribe to
+
+*******************************************************************************/
+#define CsrWifiRouterMaPacketSubscribeReqCreate(msg__, dst__, src__, interfaceTag__, encapsulation__, protocol__, oui__) \
+ msg__ = kmalloc(sizeof(CsrWifiRouterMaPacketSubscribeReq), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_PRIM, CSR_WIFI_ROUTER_MA_PACKET_SUBSCRIBE_REQ, dst__, src__); \
+ msg__->interfaceTag = (interfaceTag__); \
+ msg__->encapsulation = (encapsulation__); \
+ msg__->protocol = (protocol__); \
+ msg__->oui = (oui__);
+
+#define CsrWifiRouterMaPacketSubscribeReqSendTo(dst__, src__, interfaceTag__, encapsulation__, protocol__, oui__) \
+ { \
+ CsrWifiRouterMaPacketSubscribeReq *msg__; \
+ CsrWifiRouterMaPacketSubscribeReqCreate(msg__, dst__, src__, interfaceTag__, encapsulation__, protocol__, oui__); \
+ CsrMsgTransport(dst__, CSR_WIFI_ROUTER_PRIM, msg__); \
+ }
+
+#define CsrWifiRouterMaPacketSubscribeReqSend(src__, interfaceTag__, encapsulation__, protocol__, oui__) \
+ CsrWifiRouterMaPacketSubscribeReqSendTo(CSR_WIFI_ROUTER_IFACEQUEUE, src__, interfaceTag__, encapsulation__, protocol__, oui__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiRouterMaPacketSubscribeCfmSend
+
+ DESCRIPTION
+ The router sends this primitive to confirm the result of the
+ subscription.
+
+ PARAMETERS
+ queue - Destination Task Queue
+ interfaceTag - Interface Identifier; unique identifier of an interface
+ subscriptionHandle - Handle to the subscription
+ This handle must be used in all subsequent requests
+ status - Status of the operation
+ allocOffset - Size of the offset for the frames of the subscription
+
+*******************************************************************************/
+#define CsrWifiRouterMaPacketSubscribeCfmCreate(msg__, dst__, src__, interfaceTag__, subscriptionHandle__, status__, allocOffset__) \
+ msg__ = kmalloc(sizeof(CsrWifiRouterMaPacketSubscribeCfm), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_PRIM, CSR_WIFI_ROUTER_MA_PACKET_SUBSCRIBE_CFM, dst__, src__); \
+ msg__->interfaceTag = (interfaceTag__); \
+ msg__->subscriptionHandle = (subscriptionHandle__); \
+ msg__->status = (status__); \
+ msg__->allocOffset = (allocOffset__);
+
+#define CsrWifiRouterMaPacketSubscribeCfmSendTo(dst__, src__, interfaceTag__, subscriptionHandle__, status__, allocOffset__) \
+ { \
+ CsrWifiRouterMaPacketSubscribeCfm *msg__; \
+ CsrWifiRouterMaPacketSubscribeCfmCreate(msg__, dst__, src__, interfaceTag__, subscriptionHandle__, status__, allocOffset__); \
+ CsrSchedMessagePut(dst__, CSR_WIFI_ROUTER_PRIM, msg__); \
+ }
+
+#define CsrWifiRouterMaPacketSubscribeCfmSend(dst__, interfaceTag__, subscriptionHandle__, status__, allocOffset__) \
+ CsrWifiRouterMaPacketSubscribeCfmSendTo(dst__, CSR_WIFI_ROUTER_IFACEQUEUE, interfaceTag__, subscriptionHandle__, status__, allocOffset__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiRouterMaPacketUnsubscribeReqSend
+
+ DESCRIPTION
+ A task sends this primitive to unsubscribe a subscription
+
+ PARAMETERS
+ queue - Message Source Task Queue (Cfm's will be sent to this Queue)
+ interfaceTag - Interface Identifier; unique identifier of an interface
+ subscriptionHandle - The handle of the subscription
+
+*******************************************************************************/
+#define CsrWifiRouterMaPacketUnsubscribeReqCreate(msg__, dst__, src__, interfaceTag__, subscriptionHandle__) \
+ msg__ = kmalloc(sizeof(CsrWifiRouterMaPacketUnsubscribeReq), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_PRIM, CSR_WIFI_ROUTER_MA_PACKET_UNSUBSCRIBE_REQ, dst__, src__); \
+ msg__->interfaceTag = (interfaceTag__); \
+ msg__->subscriptionHandle = (subscriptionHandle__);
+
+#define CsrWifiRouterMaPacketUnsubscribeReqSendTo(dst__, src__, interfaceTag__, subscriptionHandle__) \
+ { \
+ CsrWifiRouterMaPacketUnsubscribeReq *msg__; \
+ CsrWifiRouterMaPacketUnsubscribeReqCreate(msg__, dst__, src__, interfaceTag__, subscriptionHandle__); \
+ CsrMsgTransport(dst__, CSR_WIFI_ROUTER_PRIM, msg__); \
+ }
+
+#define CsrWifiRouterMaPacketUnsubscribeReqSend(src__, interfaceTag__, subscriptionHandle__) \
+ CsrWifiRouterMaPacketUnsubscribeReqSendTo(CSR_WIFI_ROUTER_IFACEQUEUE, src__, interfaceTag__, subscriptionHandle__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiRouterMaPacketUnsubscribeCfmSend
+
+ DESCRIPTION
+ The router sends this primitive to confirm the result of the
+ unsubscription.
+
+ PARAMETERS
+ queue - Destination Task Queue
+ interfaceTag - Interface Identifier; unique identifier of an interface
+ status - Status of the operation
+
+*******************************************************************************/
+#define CsrWifiRouterMaPacketUnsubscribeCfmCreate(msg__, dst__, src__, interfaceTag__, status__) \
+ msg__ = kmalloc(sizeof(CsrWifiRouterMaPacketUnsubscribeCfm), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_ROUTER_PRIM, CSR_WIFI_ROUTER_MA_PACKET_UNSUBSCRIBE_CFM, dst__, src__); \
+ msg__->interfaceTag = (interfaceTag__); \
+ msg__->status = (status__);
+
+#define CsrWifiRouterMaPacketUnsubscribeCfmSendTo(dst__, src__, interfaceTag__, status__) \
+ { \
+ CsrWifiRouterMaPacketUnsubscribeCfm *msg__; \
+ CsrWifiRouterMaPacketUnsubscribeCfmCreate(msg__, dst__, src__, interfaceTag__, status__); \
+ CsrSchedMessagePut(dst__, CSR_WIFI_ROUTER_PRIM, msg__); \
+ }
+
+#define CsrWifiRouterMaPacketUnsubscribeCfmSend(dst__, interfaceTag__, status__) \
+ CsrWifiRouterMaPacketUnsubscribeCfmSendTo(dst__, CSR_WIFI_ROUTER_IFACEQUEUE, interfaceTag__, status__)
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* CSR_WIFI_ROUTER_LIB_H__ */
diff --git a/drivers/staging/csr/csr_wifi_router_prim.h b/drivers/staging/csr/csr_wifi_router_prim.h
new file mode 100644
index 000000000000..c61486fbb6d6
--- /dev/null
+++ b/drivers/staging/csr/csr_wifi_router_prim.h
@@ -0,0 +1,430 @@
+/*****************************************************************************
+
+ (c) Cambridge Silicon Radio Limited 2011
+ All rights reserved and confidential information of CSR
+
+ Refer to LICENSE.txt included with this source for details
+ on the license terms.
+
+*****************************************************************************/
+
+/* Note: this is an auto-generated file. */
+
+#ifndef CSR_WIFI_ROUTER_PRIM_H__
+#define CSR_WIFI_ROUTER_PRIM_H__
+
+#include <linux/types.h>
+#include "csr_prim_defs.h"
+#include "csr_sched.h"
+#include "csr_wifi_common.h"
+#include "csr_result.h"
+#include "csr_wifi_fsm_event.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define CSR_WIFI_ROUTER_PRIM (0x0400)
+
+typedef CsrPrim CsrWifiRouterPrim;
+
+typedef void (*CsrWifiRouterFrameFreeFunction)(void *frame);
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiRouterAppType
+
+ DESCRIPTION
+
+ VALUES
+ CSR_WIFI_ROUTER_APP_TYPE_SME -
+ CSR_WIFI_ROUTER_APP_TYPE_PAL -
+ CSR_WIFI_ROUTER_APP_TYPE_NME -
+ CSR_WIFI_ROUTER_APP_TYPE_OTHER -
+
+*******************************************************************************/
+typedef u8 CsrWifiRouterAppType;
+#define CSR_WIFI_ROUTER_APP_TYPE_SME ((CsrWifiRouterAppType) 0x0)
+#define CSR_WIFI_ROUTER_APP_TYPE_PAL ((CsrWifiRouterAppType) 0x1)
+#define CSR_WIFI_ROUTER_APP_TYPE_NME ((CsrWifiRouterAppType) 0x2)
+#define CSR_WIFI_ROUTER_APP_TYPE_OTHER ((CsrWifiRouterAppType) 0x3)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiRouterEncapsulation
+
+ DESCRIPTION
+ Indicates the type of encapsulation used for the subscription
+
+ VALUES
+ CSR_WIFI_ROUTER_ENCAPSULATION_ETHERNET
+ - Ethernet encapsulation
+ CSR_WIFI_ROUTER_ENCAPSULATION_LLC_SNAP
+ - LLC/SNAP encapsulation
+
+*******************************************************************************/
+typedef u8 CsrWifiRouterEncapsulation;
+#define CSR_WIFI_ROUTER_ENCAPSULATION_ETHERNET ((CsrWifiRouterEncapsulation) 0x00)
+#define CSR_WIFI_ROUTER_ENCAPSULATION_LLC_SNAP ((CsrWifiRouterEncapsulation) 0x01)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiRouterOui
+
+ DESCRIPTION
+
+ VALUES
+ CSR_WIFI_ROUTER_OUI_RFC_1042 -
+ CSR_WIFI_ROUTER_OUI_BT -
+
+*******************************************************************************/
+typedef u32 CsrWifiRouterOui;
+#define CSR_WIFI_ROUTER_OUI_RFC_1042 ((CsrWifiRouterOui) 0x000000)
+#define CSR_WIFI_ROUTER_OUI_BT ((CsrWifiRouterOui) 0x001958)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiRouterPriority
+
+ DESCRIPTION
+ As defined in the IEEE 802.11 standards
+
+ VALUES
+ CSR_WIFI_ROUTER_PRIORITY_QOS_UP0
+ - See IEEE 802.11 Standard
+ CSR_WIFI_ROUTER_PRIORITY_QOS_UP1
+ - See IEEE 802.11 Standard
+ CSR_WIFI_ROUTER_PRIORITY_QOS_UP2
+ - See IEEE 802.11 Standard
+ CSR_WIFI_ROUTER_PRIORITY_QOS_UP3
+ - See IEEE 802.11 Standard
+ CSR_WIFI_ROUTER_PRIORITY_QOS_UP4
+ - See IEEE 802.11 Standard
+ CSR_WIFI_ROUTER_PRIORITY_QOS_UP5
+ - See IEEE 802.11 Standard
+ CSR_WIFI_ROUTER_PRIORITY_QOS_UP6
+ - See IEEE 802.11 Standard
+ CSR_WIFI_ROUTER_PRIORITY_QOS_UP7
+ - See IEEE 802.11 Standard
+ CSR_WIFI_ROUTER_PRIORITY_CONTENTION
+ - See IEEE 802.11 Standard
+ CSR_WIFI_ROUTER_PRIORITY_MANAGEMENT
+ - See IEEE 802.11 Standard
+
+*******************************************************************************/
+typedef u16 CsrWifiRouterPriority;
+#define CSR_WIFI_ROUTER_PRIORITY_QOS_UP0 ((CsrWifiRouterPriority) 0x0000)
+#define CSR_WIFI_ROUTER_PRIORITY_QOS_UP1 ((CsrWifiRouterPriority) 0x0001)
+#define CSR_WIFI_ROUTER_PRIORITY_QOS_UP2 ((CsrWifiRouterPriority) 0x0002)
+#define CSR_WIFI_ROUTER_PRIORITY_QOS_UP3 ((CsrWifiRouterPriority) 0x0003)
+#define CSR_WIFI_ROUTER_PRIORITY_QOS_UP4 ((CsrWifiRouterPriority) 0x0004)
+#define CSR_WIFI_ROUTER_PRIORITY_QOS_UP5 ((CsrWifiRouterPriority) 0x0005)
+#define CSR_WIFI_ROUTER_PRIORITY_QOS_UP6 ((CsrWifiRouterPriority) 0x0006)
+#define CSR_WIFI_ROUTER_PRIORITY_QOS_UP7 ((CsrWifiRouterPriority) 0x0007)
+#define CSR_WIFI_ROUTER_PRIORITY_CONTENTION ((CsrWifiRouterPriority) 0x8000)
+#define CSR_WIFI_ROUTER_PRIORITY_MANAGEMENT ((CsrWifiRouterPriority) 0x8010)
+
+
+/* Downstream */
+#define CSR_WIFI_ROUTER_PRIM_DOWNSTREAM_LOWEST (0x0000)
+
+#define CSR_WIFI_ROUTER_MA_PACKET_SUBSCRIBE_REQ ((CsrWifiRouterPrim) (0x0000 + CSR_WIFI_ROUTER_PRIM_DOWNSTREAM_LOWEST))
+#define CSR_WIFI_ROUTER_MA_PACKET_UNSUBSCRIBE_REQ ((CsrWifiRouterPrim) (0x0001 + CSR_WIFI_ROUTER_PRIM_DOWNSTREAM_LOWEST))
+#define CSR_WIFI_ROUTER_MA_PACKET_REQ ((CsrWifiRouterPrim) (0x0002 + CSR_WIFI_ROUTER_PRIM_DOWNSTREAM_LOWEST))
+#define CSR_WIFI_ROUTER_MA_PACKET_RES ((CsrWifiRouterPrim) (0x0003 + CSR_WIFI_ROUTER_PRIM_DOWNSTREAM_LOWEST))
+#define CSR_WIFI_ROUTER_MA_PACKET_CANCEL_REQ ((CsrWifiRouterPrim) (0x0004 + CSR_WIFI_ROUTER_PRIM_DOWNSTREAM_LOWEST))
+
+
+#define CSR_WIFI_ROUTER_PRIM_DOWNSTREAM_HIGHEST (0x0004 + CSR_WIFI_ROUTER_PRIM_DOWNSTREAM_LOWEST)
+
+/* Upstream */
+#define CSR_WIFI_ROUTER_PRIM_UPSTREAM_LOWEST (0x0000 + CSR_PRIM_UPSTREAM)
+
+#define CSR_WIFI_ROUTER_MA_PACKET_SUBSCRIBE_CFM ((CsrWifiRouterPrim)(0x0000 + CSR_WIFI_ROUTER_PRIM_UPSTREAM_LOWEST))
+#define CSR_WIFI_ROUTER_MA_PACKET_UNSUBSCRIBE_CFM ((CsrWifiRouterPrim)(0x0001 + CSR_WIFI_ROUTER_PRIM_UPSTREAM_LOWEST))
+#define CSR_WIFI_ROUTER_MA_PACKET_CFM ((CsrWifiRouterPrim)(0x0002 + CSR_WIFI_ROUTER_PRIM_UPSTREAM_LOWEST))
+#define CSR_WIFI_ROUTER_MA_PACKET_IND ((CsrWifiRouterPrim)(0x0003 + CSR_WIFI_ROUTER_PRIM_UPSTREAM_LOWEST))
+
+#define CSR_WIFI_ROUTER_PRIM_UPSTREAM_HIGHEST (0x0003 + CSR_WIFI_ROUTER_PRIM_UPSTREAM_LOWEST)
+
+#define CSR_WIFI_ROUTER_PRIM_DOWNSTREAM_COUNT (CSR_WIFI_ROUTER_PRIM_DOWNSTREAM_HIGHEST + 1 - CSR_WIFI_ROUTER_PRIM_DOWNSTREAM_LOWEST)
+#define CSR_WIFI_ROUTER_PRIM_UPSTREAM_COUNT (CSR_WIFI_ROUTER_PRIM_UPSTREAM_HIGHEST + 1 - CSR_WIFI_ROUTER_PRIM_UPSTREAM_LOWEST)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiRouterMaPacketSubscribeReq
+
+ DESCRIPTION
+ A task can use this primitive to subscribe for a particular OUI/protocol
+ and transmit and receive frames matching the subscription.
+ NOTE: Multiple subscriptions for a given protocol and OUI will result in
+ the first subscription receiving the data and not the subsequent
+ subscriptions.
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ interfaceTag - Interface Identifier; unique identifier of an interface
+ encapsulation - Specifies the encapsulation type, which will be used for the
+ subscription
+ protocol - Together with the OUI, specifies the protocol, which a task
+ wants to subscribe to
+ oui - Specifies the OUI for the protocol, which a task wants to
+ subscribe to
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ u16 interfaceTag;
+ CsrWifiRouterEncapsulation encapsulation;
+ u16 protocol;
+ u32 oui;
+} CsrWifiRouterMaPacketSubscribeReq;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiRouterMaPacketUnsubscribeReq
+
+ DESCRIPTION
+ A task sends this primitive to unsubscribe a subscription
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ interfaceTag - Interface Identifier; unique identifier of an interface
+ subscriptionHandle - The handle of the subscription
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ u16 interfaceTag;
+ u8 subscriptionHandle;
+} CsrWifiRouterMaPacketUnsubscribeReq;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiRouterMaPacketReq
+
+ DESCRIPTION
+ A task sends this primitive to transmit a frame.
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ interfaceTag - Interface Identifier; unique identifier of an interface
+ subscriptionHandle - The handle of the subscription
+ frameLength - Length of the frame to be sent in bytes
+ frame - Pointer to the frame to be sent
+ freeFunction - Pointer to function to be used to free the frame
+ priority - Priority of the frame, which should be sent
+ hostTag - An application shall set the bits b31..b28 using one of
+ the CSR_WIFI_ROUTER_APP_TYPE_* masks. Bits b0..b27 can
+ be used by the requestor without any restrictions, but
+ the hostTag shall be unique so the hostTag for
+ CSR_WIFI_ROUTER_APP _TYPE_OTHER should be constructured
+ in the following way [ CSR_WIFI_ROUTER_APP_TYPE_OTHER
+ (4 bits) | SubscriptionHandle (8 bits) | Sequence no.
+ (20 bits) ]. If the hostTag is not unique, the
+ behaviour of the system is unpredicatable with respect
+ to data/management frame transfer.
+ cfmRequested - Indicates if the requestor needs a confirm for packet
+ requests sent under this subscription. If set to TRUE,
+ the router will send a confirm, else it will not send
+ any confirm
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ u16 interfaceTag;
+ u8 subscriptionHandle;
+ u16 frameLength;
+ u8 *frame;
+ CsrWifiRouterFrameFreeFunction freeFunction;
+ CsrWifiRouterPriority priority;
+ u32 hostTag;
+ u8 cfmRequested;
+} CsrWifiRouterMaPacketReq;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiRouterMaPacketRes
+
+ DESCRIPTION
+ A task send this primitive to confirm the reception of the received
+ frame.
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ interfaceTag - Interface Identifier; unique identifier of an interface
+ subscriptionHandle - The handle of the subscription
+ result - Status of the operation
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ u16 interfaceTag;
+ u8 subscriptionHandle;
+ CsrResult result;
+} CsrWifiRouterMaPacketRes;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiRouterMaPacketCancelReq
+
+ DESCRIPTION
+ This primitive is used to request cancellation of a previously send
+ CsrWifiRouterMaPacketReq.
+ The frame may already have been transmitted so there is no guarantees
+ that the CsrWifiRouterMaPacketCancelReq actually cancels the transmission
+ of the frame in question.
+ If the cancellation fails, the Router will send, if required,
+ CsrWifiRouterMaPacketCfm.
+ If the cancellation succeeds, the Router will not send
+ CsrWifiRouterMaPacketCfm.
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ interfaceTag - Interface Identifier; unique identifier of an interface
+ hostTag - The hostTag for the frame, which should be cancelled.
+ priority - Priority of the frame, which should be cancelled
+ peerMacAddress - Destination MAC address of the frame, which should be
+ cancelled
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ u16 interfaceTag;
+ u32 hostTag;
+ CsrWifiRouterPriority priority;
+ CsrWifiMacAddress peerMacAddress;
+} CsrWifiRouterMaPacketCancelReq;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiRouterMaPacketSubscribeCfm
+
+ DESCRIPTION
+ The router sends this primitive to confirm the result of the
+ subscription.
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ interfaceTag - Interface Identifier; unique identifier of an interface
+ subscriptionHandle - Handle to the subscription
+ This handle must be used in all subsequent requests
+ status - Status of the operation
+ allocOffset - Size of the offset for the frames of the subscription
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ u16 interfaceTag;
+ u8 subscriptionHandle;
+ CsrResult status;
+ u16 allocOffset;
+} CsrWifiRouterMaPacketSubscribeCfm;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiRouterMaPacketUnsubscribeCfm
+
+ DESCRIPTION
+ The router sends this primitive to confirm the result of the
+ unsubscription.
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ interfaceTag - Interface Identifier; unique identifier of an interface
+ status - Status of the operation
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ u16 interfaceTag;
+ CsrResult status;
+} CsrWifiRouterMaPacketUnsubscribeCfm;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiRouterMaPacketCfm
+
+ DESCRIPTION
+ The router sends the primitive to confirm the result of the transmission
+ of the packet of the corresponding CSR_WIFI_ROUTER MA_PACKET_REQ request.
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ interfaceTag - Interface Identifier; unique identifier of an interface
+ result - Status of the operation
+ hostTag - The hostTrag will match the hostTag sent in the request.
+ rate - Transmission/Reception rate
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ u16 interfaceTag;
+ CsrResult result;
+ u32 hostTag;
+ u16 rate;
+} CsrWifiRouterMaPacketCfm;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiRouterMaPacketInd
+
+ DESCRIPTION
+ The router sends the primitive to a subscribed task when it receives a
+ frame matching the subscription.
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ interfaceTag - Interface Identifier; unique identifier of an interface
+ subscriptionHandle - The handle of the subscription
+ result - Status of the operation
+ frameLength - Length of the received frame in bytes
+ frame - Pointer to the received frame
+ freeFunction - Pointer to function to be used to free the frame
+ rssi - Received signal strength indication in dBm
+ snr - Signal to Noise Ratio
+ rate - Transmission/Reception rate
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ u16 interfaceTag;
+ u8 subscriptionHandle;
+ CsrResult result;
+ u16 frameLength;
+ u8 *frame;
+ CsrWifiRouterFrameFreeFunction freeFunction;
+ s16 rssi;
+ s16 snr;
+ u16 rate;
+} CsrWifiRouterMaPacketInd;
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* CSR_WIFI_ROUTER_PRIM_H__ */
+
diff --git a/drivers/staging/csr/csr_wifi_router_sef.c b/drivers/staging/csr/csr_wifi_router_sef.c
new file mode 100644
index 000000000000..45a10fb77296
--- /dev/null
+++ b/drivers/staging/csr/csr_wifi_router_sef.c
@@ -0,0 +1,19 @@
+/*****************************************************************************
+
+ (c) Cambridge Silicon Radio Limited 2010
+ Confidential information of CSR
+
+ Refer to LICENSE.txt included with this source for details
+ on the license terms.
+
+ *****************************************************************************/
+#include "csr_wifi_router_sef.h"
+
+const CsrWifiRouterStateHandlerType CsrWifiRouterDownstreamStateHandlers[CSR_WIFI_ROUTER_PRIM_DOWNSTREAM_COUNT] =
+{
+ /* 0x0000 */ CsrWifiRouterMaPacketSubscribeReqHandler,
+ /* 0x0001 */ CsrWifiRouterMaPacketUnsubscribeReqHandler,
+ /* 0x0002 */ CsrWifiRouterMaPacketReqHandler,
+ /* 0x0003 */ CsrWifiRouterMaPacketResHandler,
+ /* 0x0004 */ CsrWifiRouterMaPacketCancelReqHandler,
+};
diff --git a/drivers/staging/csr/csr_wifi_router_sef.h b/drivers/staging/csr/csr_wifi_router_sef.h
new file mode 100644
index 000000000000..49dd158fa98d
--- /dev/null
+++ b/drivers/staging/csr/csr_wifi_router_sef.h
@@ -0,0 +1,33 @@
+/*****************************************************************************
+
+ (c) Cambridge Silicon Radio Limited 2010
+ Confidential information of CSR
+
+ Refer to LICENSE.txt included with this source for details
+ on the license terms.
+
+ *****************************************************************************/
+#ifndef CSR_WIFI_ROUTER_SEF_CSR_WIFI_ROUTER_H__
+#define CSR_WIFI_ROUTER_SEF_CSR_WIFI_ROUTER_H__
+
+#include "csr_wifi_router_prim.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+ typedef void (*CsrWifiRouterStateHandlerType)(void* drvpriv, CsrWifiFsmEvent* msg);
+
+ extern const CsrWifiRouterStateHandlerType CsrWifiRouterDownstreamStateHandlers[CSR_WIFI_ROUTER_PRIM_DOWNSTREAM_COUNT];
+
+ extern void CsrWifiRouterMaPacketSubscribeReqHandler(void* drvpriv, CsrWifiFsmEvent* msg);
+ extern void CsrWifiRouterMaPacketUnsubscribeReqHandler(void* drvpriv, CsrWifiFsmEvent* msg);
+ extern void CsrWifiRouterMaPacketReqHandler(void* drvpriv, CsrWifiFsmEvent* msg);
+ extern void CsrWifiRouterMaPacketResHandler(void* drvpriv, CsrWifiFsmEvent* msg);
+ extern void CsrWifiRouterMaPacketCancelReqHandler(void* drvpriv, CsrWifiFsmEvent* msg);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* CSR_WIFI_ROUTER_SEF_CSR_WIFI_ROUTER_H__ */
diff --git a/drivers/staging/csr/csr_wifi_router_serialize.c b/drivers/staging/csr/csr_wifi_router_serialize.c
new file mode 100644
index 000000000000..4eccf5d6c289
--- /dev/null
+++ b/drivers/staging/csr/csr_wifi_router_serialize.c
@@ -0,0 +1,418 @@
+/*****************************************************************************
+
+ (c) Cambridge Silicon Radio Limited 2011
+ All rights reserved and confidential information of CSR
+
+ Refer to LICENSE.txt included with this source for details
+ on the license terms.
+
+*****************************************************************************/
+
+/* Note: this is an auto-generated file. */
+#include <linux/slab.h>
+#include "csr_msgconv.h"
+#include "csr_wifi_router_prim.h"
+#include "csr_wifi_router_serialize.h"
+
+void CsrWifiRouterPfree(void *ptr)
+{
+ kfree(ptr);
+}
+
+
+size_t CsrWifiRouterMaPacketSubscribeReqSizeof(void *msg)
+{
+ size_t bufferSize = 2;
+
+ /* Calculate the Size of the Serialised Data. Could be more efficient (Try 12) */
+ bufferSize += 2; /* u16 primitive->interfaceTag */
+ bufferSize += 1; /* CsrWifiRouterEncapsulation primitive->encapsulation */
+ bufferSize += 2; /* u16 primitive->protocol */
+ bufferSize += 4; /* u32 primitive->oui */
+ return bufferSize;
+}
+
+
+u8* CsrWifiRouterMaPacketSubscribeReqSer(u8 *ptr, size_t *len, void *msg)
+{
+ CsrWifiRouterMaPacketSubscribeReq *primitive = (CsrWifiRouterMaPacketSubscribeReq *)msg;
+ *len = 0;
+ CsrUint16Ser(ptr, len, primitive->common.type);
+ CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
+ CsrUint8Ser(ptr, len, (u8) primitive->encapsulation);
+ CsrUint16Ser(ptr, len, (u16) primitive->protocol);
+ CsrUint32Ser(ptr, len, (u32) primitive->oui);
+ return(ptr);
+}
+
+
+void* CsrWifiRouterMaPacketSubscribeReqDes(u8 *buffer, size_t length)
+{
+ CsrWifiRouterMaPacketSubscribeReq *primitive = kmalloc(sizeof(CsrWifiRouterMaPacketSubscribeReq), GFP_KERNEL);
+ size_t offset;
+ offset = 0;
+
+ CsrUint16Des(&primitive->common.type, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->encapsulation, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->protocol, buffer, &offset);
+ CsrUint32Des((u32 *) &primitive->oui, buffer, &offset);
+
+ return primitive;
+}
+
+
+size_t CsrWifiRouterMaPacketReqSizeof(void *msg)
+{
+ CsrWifiRouterMaPacketReq *primitive = (CsrWifiRouterMaPacketReq *) msg;
+ size_t bufferSize = 2;
+
+ /* Calculate the Size of the Serialised Data. Could be more efficient (Try 20) */
+ bufferSize += 2; /* u16 primitive->interfaceTag */
+ bufferSize += 1; /* u8 primitive->subscriptionHandle */
+ bufferSize += 2; /* u16 primitive->frameLength */
+ bufferSize += primitive->frameLength; /* u8 primitive->frame */
+ bufferSize += 4; /* CsrWifiRouterFrameFreeFunction primitive->freeFunction */
+ bufferSize += 2; /* CsrWifiRouterPriority primitive->priority */
+ bufferSize += 4; /* u32 primitive->hostTag */
+ bufferSize += 1; /* u8 primitive->cfmRequested */
+ return bufferSize;
+}
+
+
+u8* CsrWifiRouterMaPacketReqSer(u8 *ptr, size_t *len, void *msg)
+{
+ CsrWifiRouterMaPacketReq *primitive = (CsrWifiRouterMaPacketReq *)msg;
+ *len = 0;
+ CsrUint16Ser(ptr, len, primitive->common.type);
+ CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
+ CsrUint8Ser(ptr, len, (u8) primitive->subscriptionHandle);
+ CsrUint16Ser(ptr, len, (u16) primitive->frameLength);
+ if (primitive->frameLength)
+ {
+ CsrMemCpySer(ptr, len, (const void *) primitive->frame, ((u16) (primitive->frameLength)));
+ }
+ CsrUint32Ser(ptr, len, 0); /* Special for Function Pointers... primitive->freeFunction */
+ CsrUint16Ser(ptr, len, (u16) primitive->priority);
+ CsrUint32Ser(ptr, len, (u32) primitive->hostTag);
+ CsrUint8Ser(ptr, len, (u8) primitive->cfmRequested);
+ return(ptr);
+}
+
+
+void* CsrWifiRouterMaPacketReqDes(u8 *buffer, size_t length)
+{
+ CsrWifiRouterMaPacketReq *primitive = kmalloc(sizeof(CsrWifiRouterMaPacketReq), GFP_KERNEL);
+ size_t offset;
+ offset = 0;
+
+ CsrUint16Des(&primitive->common.type, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->subscriptionHandle, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->frameLength, buffer, &offset);
+ if (primitive->frameLength)
+ {
+ primitive->frame = kmalloc(primitive->frameLength, GFP_KERNEL);
+ CsrMemCpyDes(primitive->frame, buffer, &offset, ((u16) (primitive->frameLength)));
+ }
+ else
+ {
+ primitive->frame = NULL;
+ }
+ primitive->freeFunction = NULL; /* Special for Function Pointers... */
+ offset += 4;
+ CsrUint16Des((u16 *) &primitive->priority, buffer, &offset);
+ CsrUint32Des((u32 *) &primitive->hostTag, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->cfmRequested, buffer, &offset);
+
+ return primitive;
+}
+
+
+void CsrWifiRouterMaPacketReqSerFree(void *voidPrimitivePointer)
+{
+ CsrWifiRouterMaPacketReq *primitive = (CsrWifiRouterMaPacketReq *) voidPrimitivePointer;
+ kfree(primitive->frame);
+ kfree(primitive);
+}
+
+
+size_t CsrWifiRouterMaPacketResSizeof(void *msg)
+{
+ size_t bufferSize = 2;
+
+ /* Calculate the Size of the Serialised Data. Could be more efficient (Try 8) */
+ bufferSize += 2; /* u16 primitive->interfaceTag */
+ bufferSize += 1; /* u8 primitive->subscriptionHandle */
+ bufferSize += 2; /* CsrResult primitive->result */
+ return bufferSize;
+}
+
+
+u8* CsrWifiRouterMaPacketResSer(u8 *ptr, size_t *len, void *msg)
+{
+ CsrWifiRouterMaPacketRes *primitive = (CsrWifiRouterMaPacketRes *)msg;
+ *len = 0;
+ CsrUint16Ser(ptr, len, primitive->common.type);
+ CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
+ CsrUint8Ser(ptr, len, (u8) primitive->subscriptionHandle);
+ CsrUint16Ser(ptr, len, (u16) primitive->result);
+ return(ptr);
+}
+
+
+void* CsrWifiRouterMaPacketResDes(u8 *buffer, size_t length)
+{
+ CsrWifiRouterMaPacketRes *primitive = kmalloc(sizeof(CsrWifiRouterMaPacketRes), GFP_KERNEL);
+ size_t offset;
+ offset = 0;
+
+ CsrUint16Des(&primitive->common.type, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->subscriptionHandle, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->result, buffer, &offset);
+
+ return primitive;
+}
+
+
+size_t CsrWifiRouterMaPacketCancelReqSizeof(void *msg)
+{
+ size_t bufferSize = 2;
+
+ /* Calculate the Size of the Serialised Data. Could be more efficient (Try 17) */
+ bufferSize += 2; /* u16 primitive->interfaceTag */
+ bufferSize += 4; /* u32 primitive->hostTag */
+ bufferSize += 2; /* CsrWifiRouterPriority primitive->priority */
+ bufferSize += 6; /* u8 primitive->peerMacAddress.a[6] */
+ return bufferSize;
+}
+
+
+u8* CsrWifiRouterMaPacketCancelReqSer(u8 *ptr, size_t *len, void *msg)
+{
+ CsrWifiRouterMaPacketCancelReq *primitive = (CsrWifiRouterMaPacketCancelReq *)msg;
+ *len = 0;
+ CsrUint16Ser(ptr, len, primitive->common.type);
+ CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
+ CsrUint32Ser(ptr, len, (u32) primitive->hostTag);
+ CsrUint16Ser(ptr, len, (u16) primitive->priority);
+ CsrMemCpySer(ptr, len, (const void *) primitive->peerMacAddress.a, ((u16) (6)));
+ return(ptr);
+}
+
+
+void* CsrWifiRouterMaPacketCancelReqDes(u8 *buffer, size_t length)
+{
+ CsrWifiRouterMaPacketCancelReq *primitive = kmalloc(sizeof(CsrWifiRouterMaPacketCancelReq), GFP_KERNEL);
+ size_t offset;
+ offset = 0;
+
+ CsrUint16Des(&primitive->common.type, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
+ CsrUint32Des((u32 *) &primitive->hostTag, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->priority, buffer, &offset);
+ CsrMemCpyDes(primitive->peerMacAddress.a, buffer, &offset, ((u16) (6)));
+
+ return primitive;
+}
+
+
+size_t CsrWifiRouterMaPacketSubscribeCfmSizeof(void *msg)
+{
+ size_t bufferSize = 2;
+
+ /* Calculate the Size of the Serialised Data. Could be more efficient (Try 10) */
+ bufferSize += 2; /* u16 primitive->interfaceTag */
+ bufferSize += 1; /* u8 primitive->subscriptionHandle */
+ bufferSize += 2; /* CsrResult primitive->status */
+ bufferSize += 2; /* u16 primitive->allocOffset */
+ return bufferSize;
+}
+
+
+u8* CsrWifiRouterMaPacketSubscribeCfmSer(u8 *ptr, size_t *len, void *msg)
+{
+ CsrWifiRouterMaPacketSubscribeCfm *primitive = (CsrWifiRouterMaPacketSubscribeCfm *)msg;
+ *len = 0;
+ CsrUint16Ser(ptr, len, primitive->common.type);
+ CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
+ CsrUint8Ser(ptr, len, (u8) primitive->subscriptionHandle);
+ CsrUint16Ser(ptr, len, (u16) primitive->status);
+ CsrUint16Ser(ptr, len, (u16) primitive->allocOffset);
+ return(ptr);
+}
+
+
+void* CsrWifiRouterMaPacketSubscribeCfmDes(u8 *buffer, size_t length)
+{
+ CsrWifiRouterMaPacketSubscribeCfm *primitive = kmalloc(sizeof(CsrWifiRouterMaPacketSubscribeCfm), GFP_KERNEL);
+ size_t offset;
+ offset = 0;
+
+ CsrUint16Des(&primitive->common.type, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->subscriptionHandle, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->allocOffset, buffer, &offset);
+
+ return primitive;
+}
+
+
+size_t CsrWifiRouterMaPacketUnsubscribeCfmSizeof(void *msg)
+{
+ size_t bufferSize = 2;
+
+ /* Calculate the Size of the Serialised Data. Could be more efficient (Try 7) */
+ bufferSize += 2; /* u16 primitive->interfaceTag */
+ bufferSize += 2; /* CsrResult primitive->status */
+ return bufferSize;
+}
+
+
+u8* CsrWifiRouterMaPacketUnsubscribeCfmSer(u8 *ptr, size_t *len, void *msg)
+{
+ CsrWifiRouterMaPacketUnsubscribeCfm *primitive = (CsrWifiRouterMaPacketUnsubscribeCfm *)msg;
+ *len = 0;
+ CsrUint16Ser(ptr, len, primitive->common.type);
+ CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
+ CsrUint16Ser(ptr, len, (u16) primitive->status);
+ return(ptr);
+}
+
+
+void* CsrWifiRouterMaPacketUnsubscribeCfmDes(u8 *buffer, size_t length)
+{
+ CsrWifiRouterMaPacketUnsubscribeCfm *primitive = kmalloc(sizeof(CsrWifiRouterMaPacketUnsubscribeCfm), GFP_KERNEL);
+ size_t offset;
+ offset = 0;
+
+ CsrUint16Des(&primitive->common.type, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
+
+ return primitive;
+}
+
+
+size_t CsrWifiRouterMaPacketCfmSizeof(void *msg)
+{
+ size_t bufferSize = 2;
+
+ /* Calculate the Size of the Serialised Data. Could be more efficient (Try 13) */
+ bufferSize += 2; /* u16 primitive->interfaceTag */
+ bufferSize += 2; /* CsrResult primitive->result */
+ bufferSize += 4; /* u32 primitive->hostTag */
+ bufferSize += 2; /* u16 primitive->rate */
+ return bufferSize;
+}
+
+
+u8* CsrWifiRouterMaPacketCfmSer(u8 *ptr, size_t *len, void *msg)
+{
+ CsrWifiRouterMaPacketCfm *primitive = (CsrWifiRouterMaPacketCfm *)msg;
+ *len = 0;
+ CsrUint16Ser(ptr, len, primitive->common.type);
+ CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
+ CsrUint16Ser(ptr, len, (u16) primitive->result);
+ CsrUint32Ser(ptr, len, (u32) primitive->hostTag);
+ CsrUint16Ser(ptr, len, (u16) primitive->rate);
+ return(ptr);
+}
+
+
+void* CsrWifiRouterMaPacketCfmDes(u8 *buffer, size_t length)
+{
+ CsrWifiRouterMaPacketCfm *primitive = kmalloc(sizeof(CsrWifiRouterMaPacketCfm), GFP_KERNEL);
+ size_t offset;
+ offset = 0;
+
+ CsrUint16Des(&primitive->common.type, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->result, buffer, &offset);
+ CsrUint32Des((u32 *) &primitive->hostTag, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->rate, buffer, &offset);
+
+ return primitive;
+}
+
+
+size_t CsrWifiRouterMaPacketIndSizeof(void *msg)
+{
+ CsrWifiRouterMaPacketInd *primitive = (CsrWifiRouterMaPacketInd *) msg;
+ size_t bufferSize = 2;
+
+ /* Calculate the Size of the Serialised Data. Could be more efficient (Try 21) */
+ bufferSize += 2; /* u16 primitive->interfaceTag */
+ bufferSize += 1; /* u8 primitive->subscriptionHandle */
+ bufferSize += 2; /* CsrResult primitive->result */
+ bufferSize += 2; /* u16 primitive->frameLength */
+ bufferSize += primitive->frameLength; /* u8 primitive->frame */
+ bufferSize += 4; /* CsrWifiRouterFrameFreeFunction primitive->freeFunction */
+ bufferSize += 2; /* s16 primitive->rssi */
+ bufferSize += 2; /* s16 primitive->snr */
+ bufferSize += 2; /* u16 primitive->rate */
+ return bufferSize;
+}
+
+
+u8* CsrWifiRouterMaPacketIndSer(u8 *ptr, size_t *len, void *msg)
+{
+ CsrWifiRouterMaPacketInd *primitive = (CsrWifiRouterMaPacketInd *)msg;
+ *len = 0;
+ CsrUint16Ser(ptr, len, primitive->common.type);
+ CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
+ CsrUint8Ser(ptr, len, (u8) primitive->subscriptionHandle);
+ CsrUint16Ser(ptr, len, (u16) primitive->result);
+ CsrUint16Ser(ptr, len, (u16) primitive->frameLength);
+ if (primitive->frameLength)
+ {
+ CsrMemCpySer(ptr, len, (const void *) primitive->frame, ((u16) (primitive->frameLength)));
+ }
+ CsrUint32Ser(ptr, len, 0); /* Special for Function Pointers... primitive->freeFunction */
+ CsrUint16Ser(ptr, len, (u16) primitive->rssi);
+ CsrUint16Ser(ptr, len, (u16) primitive->snr);
+ CsrUint16Ser(ptr, len, (u16) primitive->rate);
+ return(ptr);
+}
+
+
+void* CsrWifiRouterMaPacketIndDes(u8 *buffer, size_t length)
+{
+ CsrWifiRouterMaPacketInd *primitive = kmalloc(sizeof(CsrWifiRouterMaPacketInd), GFP_KERNEL);
+ size_t offset;
+ offset = 0;
+
+ CsrUint16Des(&primitive->common.type, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->subscriptionHandle, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->result, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->frameLength, buffer, &offset);
+ if (primitive->frameLength)
+ {
+ primitive->frame = kmalloc(primitive->frameLength, GFP_KERNEL);
+ CsrMemCpyDes(primitive->frame, buffer, &offset, ((u16) (primitive->frameLength)));
+ }
+ else
+ {
+ primitive->frame = NULL;
+ }
+ primitive->freeFunction = NULL; /* Special for Function Pointers... */
+ offset += 4;
+ CsrUint16Des((u16 *) &primitive->rssi, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->snr, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->rate, buffer, &offset);
+
+ return primitive;
+}
+
+
+void CsrWifiRouterMaPacketIndSerFree(void *voidPrimitivePointer)
+{
+ CsrWifiRouterMaPacketInd *primitive = (CsrWifiRouterMaPacketInd *) voidPrimitivePointer;
+ kfree(primitive->frame);
+ kfree(primitive);
+}
+
+
diff --git a/drivers/staging/csr/csr_wifi_router_serialize.h b/drivers/staging/csr/csr_wifi_router_serialize.h
new file mode 100644
index 000000000000..07e21b2b4363
--- /dev/null
+++ b/drivers/staging/csr/csr_wifi_router_serialize.h
@@ -0,0 +1,75 @@
+/*****************************************************************************
+
+ (c) Cambridge Silicon Radio Limited 2011
+ All rights reserved and confidential information of CSR
+
+ Refer to LICENSE.txt included with this source for details
+ on the license terms.
+
+*****************************************************************************/
+
+/* Note: this is an auto-generated file. */
+
+#ifndef CSR_WIFI_ROUTER_SERIALIZE_H__
+#define CSR_WIFI_ROUTER_SERIALIZE_H__
+
+#include "csr_wifi_msgconv.h"
+#include "csr_wifi_router_prim.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern void CsrWifiRouterPfree(void *ptr);
+
+extern u8* CsrWifiRouterMaPacketSubscribeReqSer(u8 *ptr, size_t *len, void *msg);
+extern void* CsrWifiRouterMaPacketSubscribeReqDes(u8 *buffer, size_t len);
+extern size_t CsrWifiRouterMaPacketSubscribeReqSizeof(void *msg);
+#define CsrWifiRouterMaPacketSubscribeReqSerFree CsrWifiRouterPfree
+
+#define CsrWifiRouterMaPacketUnsubscribeReqSer CsrWifiEventCsrUint16CsrUint8Ser
+#define CsrWifiRouterMaPacketUnsubscribeReqDes CsrWifiEventCsrUint16CsrUint8Des
+#define CsrWifiRouterMaPacketUnsubscribeReqSizeof CsrWifiEventCsrUint16CsrUint8Sizeof
+#define CsrWifiRouterMaPacketUnsubscribeReqSerFree CsrWifiRouterPfree
+
+extern u8* CsrWifiRouterMaPacketReqSer(u8 *ptr, size_t *len, void *msg);
+extern void* CsrWifiRouterMaPacketReqDes(u8 *buffer, size_t len);
+extern size_t CsrWifiRouterMaPacketReqSizeof(void *msg);
+extern void CsrWifiRouterMaPacketReqSerFree(void *msg);
+
+extern u8* CsrWifiRouterMaPacketResSer(u8 *ptr, size_t *len, void *msg);
+extern void* CsrWifiRouterMaPacketResDes(u8 *buffer, size_t len);
+extern size_t CsrWifiRouterMaPacketResSizeof(void *msg);
+#define CsrWifiRouterMaPacketResSerFree CsrWifiRouterPfree
+
+extern u8* CsrWifiRouterMaPacketCancelReqSer(u8 *ptr, size_t *len, void *msg);
+extern void* CsrWifiRouterMaPacketCancelReqDes(u8 *buffer, size_t len);
+extern size_t CsrWifiRouterMaPacketCancelReqSizeof(void *msg);
+#define CsrWifiRouterMaPacketCancelReqSerFree CsrWifiRouterPfree
+
+extern u8* CsrWifiRouterMaPacketSubscribeCfmSer(u8 *ptr, size_t *len, void *msg);
+extern void* CsrWifiRouterMaPacketSubscribeCfmDes(u8 *buffer, size_t len);
+extern size_t CsrWifiRouterMaPacketSubscribeCfmSizeof(void *msg);
+#define CsrWifiRouterMaPacketSubscribeCfmSerFree CsrWifiRouterPfree
+
+extern u8* CsrWifiRouterMaPacketUnsubscribeCfmSer(u8 *ptr, size_t *len, void *msg);
+extern void* CsrWifiRouterMaPacketUnsubscribeCfmDes(u8 *buffer, size_t len);
+extern size_t CsrWifiRouterMaPacketUnsubscribeCfmSizeof(void *msg);
+#define CsrWifiRouterMaPacketUnsubscribeCfmSerFree CsrWifiRouterPfree
+
+extern u8* CsrWifiRouterMaPacketCfmSer(u8 *ptr, size_t *len, void *msg);
+extern void* CsrWifiRouterMaPacketCfmDes(u8 *buffer, size_t len);
+extern size_t CsrWifiRouterMaPacketCfmSizeof(void *msg);
+#define CsrWifiRouterMaPacketCfmSerFree CsrWifiRouterPfree
+
+extern u8* CsrWifiRouterMaPacketIndSer(u8 *ptr, size_t *len, void *msg);
+extern void* CsrWifiRouterMaPacketIndDes(u8 *buffer, size_t len);
+extern size_t CsrWifiRouterMaPacketIndSizeof(void *msg);
+extern void CsrWifiRouterMaPacketIndSerFree(void *msg);
+
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* CSR_WIFI_ROUTER_SERIALIZE_H__ */
+
diff --git a/drivers/staging/csr/csr_wifi_router_task.h b/drivers/staging/csr/csr_wifi_router_task.h
new file mode 100644
index 000000000000..4e51fae4cda0
--- /dev/null
+++ b/drivers/staging/csr/csr_wifi_router_task.h
@@ -0,0 +1,33 @@
+/*****************************************************************************
+
+ (c) Cambridge Silicon Radio Limited 2011
+ All rights reserved and confidential information of CSR
+
+ Refer to LICENSE.txt included with this source for details
+ on the license terms.
+
+*****************************************************************************/
+
+/* Note: this is an auto-generated file. */
+
+#ifndef CSR_WIFI_ROUTER_TASK_H__
+#define CSR_WIFI_ROUTER_TASK_H__
+
+#include "csr_sched.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define CSR_WIFI_ROUTER_LOG_ID 0x1201FFFF
+extern CsrSchedQid CSR_WIFI_ROUTER_IFACEQUEUE;
+void CsrWifiRouterInit(void **gash);
+void CsrWifiRouterDeinit(void **gash);
+void CsrWifiRouterHandler(void **gash);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* CSR_WIFI_ROUTER_TASK_H__ */
+
diff --git a/drivers/staging/csr/csr_wifi_router_transport.c b/drivers/staging/csr/csr_wifi_router_transport.c
new file mode 100644
index 000000000000..e905ead9389b
--- /dev/null
+++ b/drivers/staging/csr/csr_wifi_router_transport.c
@@ -0,0 +1,199 @@
+/** @file router_transport.c
+ *
+ *
+ * Copyright (C) Cambridge Silicon Radio Ltd 2006-2010. All rights reserved.
+ *
+ * Refer to LICENSE.txt included with this source code for details on
+ * the license terms.
+ *
+ ****************************************************************************/
+
+#include "unifi_priv.h"
+
+#include "csr_sched.h"
+#include "csr_msgconv.h"
+
+#include "sme_userspace.h"
+
+#include "csr_wifi_hostio_prim.h"
+#include "csr_wifi_router_lib.h"
+#include "csr_wifi_router_sef.h"
+#include "csr_wifi_router_converter_init.h"
+#include "csr_wifi_router_ctrl_lib.h"
+#include "csr_wifi_router_ctrl_sef.h"
+#include "csr_wifi_router_ctrl_converter_init.h"
+#include "csr_wifi_sme_prim.h"
+#include "csr_wifi_sme_sef.h"
+#include "csr_wifi_sme_converter_init.h"
+#ifdef CSR_SUPPORT_WEXT
+#ifdef CSR_SUPPORT_WEXT_AP
+#include "csr_wifi_nme_ap_prim.h"
+#include "csr_wifi_nme_ap_sef.h"
+#include "csr_wifi_nme_ap_converter_init.h"
+#endif
+#endif
+
+static unifi_priv_t *drvpriv = NULL;
+void CsrWifiRouterTransportInit(unifi_priv_t *priv)
+{
+ unifi_trace(priv, UDBG1, "CsrWifiRouterTransportInit: \n");
+
+ drvpriv = priv;
+ (void)CsrMsgConvInit();
+ CsrWifiRouterConverterInit();
+ CsrWifiRouterCtrlConverterInit();
+ CsrWifiSmeConverterInit();
+#ifdef CSR_SUPPORT_WEXT
+#ifdef CSR_SUPPORT_WEXT_AP
+ CsrWifiNmeApConverterInit();
+#endif
+#endif
+}
+
+void CsrWifiRouterTransportRecv(unifi_priv_t *priv, u8* buffer, size_t bufferLength)
+{
+ CsrMsgConvMsgEntry* msgEntry;
+ u16 primType;
+ CsrSchedQid src;
+ CsrSchedQid dest;
+ u16 msgType;
+ size_t offset = 0;
+ CsrWifiFsmEvent* msg;
+
+ /* Decode the prim and message type */
+ CsrUint16Des(&primType, buffer, &offset);
+ CsrUint16Des(&src, buffer, &offset);
+ CsrUint16Des(&dest, buffer, &offset);
+ CsrUint16Des(&msgType, buffer, &offset);
+ offset -= 2; /* Adjust as the Deserialise Function will read this as well */
+
+ unifi_trace(priv, UDBG4, "CsrWifiRouterTransportRecv: primType=0x%.4X, msgType=0x%.4X, bufferLength=%d\n",
+ primType, msgType, bufferLength);
+
+ /* Special handling for HOSTIO messages.... */
+ if (primType == CSR_WIFI_HOSTIO_PRIM)
+ {
+ CsrWifiRouterCtrlHipReq req = {{CSR_WIFI_ROUTER_CTRL_HIP_REQ, CSR_WIFI_ROUTER_CTRL_PRIM, dest, src, NULL}, 0, NULL, 0, NULL, 0, NULL};
+
+ req.mlmeCommandLength = bufferLength;
+ req.mlmeCommand = buffer;
+
+ offset += 8;/* Skip the id, src, dest and slot number */
+ CsrUint16Des(&req.dataRef1Length, buffer, &offset);
+ offset += 2; /* Skip the slot number */
+ CsrUint16Des(&req.dataRef2Length, buffer, &offset);
+
+ if (req.dataRef1Length)
+ {
+ u16 dr1Offset = (bufferLength - req.dataRef2Length) - req.dataRef1Length;
+ req.dataRef1 = &buffer[dr1Offset];
+ }
+
+ if (req.dataRef2Length)
+ {
+ u16 dr2Offset = bufferLength - req.dataRef2Length;
+ req.dataRef2 = &buffer[dr2Offset];
+ }
+
+ /* Copy the hip data but strip off the prim type */
+ req.mlmeCommandLength -= (req.dataRef1Length + req.dataRef2Length + 6);
+ req.mlmeCommand = &buffer[6];
+
+ CsrWifiRouterCtrlHipReqHandler(priv, &req.common);
+ return;
+ }
+
+ msgEntry = CsrMsgConvFindEntry(primType, msgType);
+ if (!msgEntry)
+ {
+ unifi_error(priv, "CsrWifiRouterTransportDeserialiseAndSend can not process the message. primType=0x%.4X, msgType=0x%.4X\n",
+ primType, msgType);
+ dump(buffer, bufferLength);
+ return;
+ }
+
+ msg = (CsrWifiFsmEvent*)(msgEntry->deserFunc)(&buffer[offset], bufferLength - offset);
+
+ msg->primtype = primType;
+ msg->type = msgType;
+ msg->source = src;
+ msg->destination = dest;
+
+ switch(primType)
+ {
+ case CSR_WIFI_ROUTER_CTRL_PRIM:
+ CsrWifiRouterCtrlDownstreamStateHandlers[msg->type - CSR_WIFI_ROUTER_CTRL_PRIM_DOWNSTREAM_LOWEST](priv, msg);
+ CsrWifiRouterCtrlFreeDownstreamMessageContents(CSR_WIFI_ROUTER_CTRL_PRIM, msg);
+ break;
+ case CSR_WIFI_ROUTER_PRIM:
+ CsrWifiRouterDownstreamStateHandlers[msg->type - CSR_WIFI_ROUTER_PRIM_DOWNSTREAM_LOWEST](priv, msg);
+ CsrWifiRouterFreeDownstreamMessageContents(CSR_WIFI_ROUTER_PRIM, msg);
+ break;
+ case CSR_WIFI_SME_PRIM:
+ CsrWifiSmeUpstreamStateHandlers[msg->type - CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST](priv, msg);
+ CsrWifiSmeFreeUpstreamMessageContents(CSR_WIFI_SME_PRIM, msg);
+ break;
+#ifdef CSR_SUPPORT_WEXT
+#ifdef CSR_SUPPORT_WEXT_AP
+ case CSR_WIFI_NME_AP_PRIM:
+ CsrWifiNmeApUpstreamStateHandlers(priv, msg);
+ CsrWifiNmeApFreeUpstreamMessageContents(CSR_WIFI_NME_AP_PRIM, msg);
+ break;
+#endif
+#endif
+ default:
+ unifi_error(priv, "CsrWifiRouterTransportDeserialiseAndSend unhandled prim type 0x%.4X\n", primType);
+ break;
+ }
+ kfree(msg);
+}
+
+static void CsrWifiRouterTransportSerialiseAndSend(u16 primType, void* msg)
+{
+ CsrWifiFsmEvent* evt = (CsrWifiFsmEvent*)msg;
+ CsrMsgConvMsgEntry* msgEntry;
+ size_t msgSize;
+ size_t encodeBufferLen = 0;
+ size_t offset = 0;
+ u8* encodeBuffer;
+
+ unifi_trace(drvpriv, UDBG4, "CsrWifiRouterTransportSerialiseAndSend: primType=0x%.4X, msgType=0x%.4X\n",
+ primType, evt->type);
+
+ msgEntry = CsrMsgConvFindEntry(primType, evt->type);
+ if (!msgEntry)
+ {
+ unifi_error(drvpriv, "CsrWifiRouterTransportSerialiseAndSend can not process the message. primType=0x%.4X, msgType=0x%.4X\n",
+ primType, evt->type);
+ return;
+ }
+
+ msgSize = 6 + (msgEntry->sizeofFunc)((void*)msg);
+
+ encodeBuffer = kmalloc(msgSize, GFP_KERNEL);
+
+ /* Encode PrimType */
+ CsrUint16Ser(encodeBuffer, &encodeBufferLen, primType);
+ CsrUint16Ser(encodeBuffer, &encodeBufferLen, evt->source);
+ CsrUint16Ser(encodeBuffer, &encodeBufferLen, evt->destination);
+
+ (void)(msgEntry->serFunc)(&encodeBuffer[encodeBufferLen], &offset, msg);
+ encodeBufferLen += offset;
+
+ uf_sme_queue_message(drvpriv, encodeBuffer, encodeBufferLen);
+
+ /* Do not use msgEntry->freeFunc because the memory is owned by the driver */
+ kfree(msg);
+}
+
+#if defined(CSR_LOG_ENABLE) && defined(CSR_LOG_INCLUDE_FILE_NAME_AND_LINE_NUMBER)
+void CsrSchedMessagePutStringLog(CsrSchedQid q, u16 mi, void *mv, u32 line, char *file)
+#else
+void CsrSchedMessagePut(CsrSchedQid q, u16 mi, void *mv)
+#endif
+{
+ CsrWifiFsmEvent* evt = (CsrWifiFsmEvent*)mv;
+ evt->destination = q;
+ CsrWifiRouterTransportSerialiseAndSend(mi, mv);
+}
+
diff --git a/drivers/staging/csr/csr_wifi_serialize_primitive_types.c b/drivers/staging/csr/csr_wifi_serialize_primitive_types.c
new file mode 100644
index 000000000000..dd93d0061190
--- /dev/null
+++ b/drivers/staging/csr/csr_wifi_serialize_primitive_types.c
@@ -0,0 +1,256 @@
+/*****************************************************************************
+
+ (c) Cambridge Silicon Radio Limited 2011
+ All rights reserved and confidential information of CSR
+
+ Refer to LICENSE.txt included with this source for details
+ on the license terms.
+
+*****************************************************************************/
+
+#include <linux/module.h>
+#include <linux/slab.h>
+#include "csr_macro.h"
+#include "csr_msgconv.h"
+#include "csr_wifi_msgconv.h"
+#include "csr_wifi_lib.h"
+
+void CsrUint24Des(u32 *v, u8 *buffer, size_t *offset)
+{
+ u32 val;
+
+ val = ((buffer[(*offset) + 2] << 16) |
+ (buffer[(*offset) + 1] << 8) |
+ (buffer[(*offset)]));
+
+ *offset += 3;
+ *v = val;
+}
+
+
+/* Big endian :e.g WSC, TCLAS */
+void CsrUint16DesBigEndian(u16 *v, u8 *buffer, size_t *offset)
+{
+ u16 val;
+
+ val = (buffer[(*offset)] << 8) | (buffer[(*offset) + 1]);
+ *offset += 2;
+
+ *v = val;
+}
+
+
+void CsrUint24DesBigEndian(u32 *v, u8 *buffer, size_t *offset)
+{
+ u32 val;
+
+ val = ((buffer[(*offset)] << 16) |
+ (buffer[(*offset) + 1] << 8) |
+ (buffer[(*offset) + 2]));
+
+ *offset += 3;
+ *v = val;
+}
+
+
+void CsrUint32DesBigEndian(u32 *v, u8 *buffer, size_t *offset)
+{
+ u32 val;
+
+ val = ((buffer[(*offset)] << 24) |
+ (buffer[(*offset) + 1] << 16) |
+ (buffer[(*offset) + 2] << 8) |
+ (buffer[(*offset) + 3]));
+
+ *offset += 4;
+ *v = val;
+}
+
+
+void CsrUint24Ser(u8 *ptr, size_t *len, u32 v)
+{
+ ptr[(*len) + 2] = (u8)((v & 0x00ff0000) >> 16);
+ ptr[(*len) + 1] = (u8)((v & 0x0000ff00) >> 8);
+ ptr[(*len)] = (u8)((v & 0x000000ff));
+
+ *len += 3;
+}
+
+
+/* Big endian :e.g WSC, TCLAS */
+void CsrUint16SerBigEndian(u8 *ptr, size_t *len, u16 v)
+{
+ ptr[(*len)] = (u8)((v & 0xff00) >> 8);
+ ptr[(*len) + 1] = (u8)((v & 0x00ff));
+
+ *len += 2;
+}
+
+
+void CsrUint32SerBigEndian(u8 *ptr, size_t *len, u32 v)
+{
+ ptr[(*len)] = (u8)((v & 0xff000000) >> 24);
+ ptr[(*len) + 1] = (u8)((v & 0x00ff0000) >> 16);
+ ptr[(*len) + 2] = (u8)((v & 0x0000ff00) >> 8);
+ ptr[(*len) + 3] = (u8)((v & 0x000000ff));
+
+ *len += 4;
+}
+
+
+void CsrUint24SerBigEndian(u8 *ptr, size_t *len, u32 v)
+{
+ ptr[(*len)] = (u8)((v & 0x00ff0000) >> 16);
+ ptr[(*len) + 1] = (u8)((v & 0x0000ff00) >> 8);
+ ptr[(*len) + 2] = (u8)((v & 0x000000ff));
+
+ *len += 3;
+}
+
+
+size_t CsrWifiEventSizeof(void *msg)
+{
+ return 2;
+}
+EXPORT_SYMBOL_GPL(CsrWifiEventSizeof);
+
+u8* CsrWifiEventSer(u8 *ptr, size_t *len, void *msg)
+{
+ CsrWifiFsmEvent *primitive = (CsrWifiFsmEvent *)msg;
+ *len = 0;
+ CsrUint16Ser(ptr, len, primitive->type);
+ return(ptr);
+}
+EXPORT_SYMBOL_GPL(CsrWifiEventSer);
+
+void* CsrWifiEventDes(u8 *buffer, size_t length)
+{
+ CsrWifiFsmEvent *primitive = kmalloc(sizeof(CsrWifiFsmEvent), GFP_KERNEL);
+ size_t offset = 0;
+ CsrUint16Des(&primitive->type, buffer, &offset);
+
+ return primitive;
+}
+EXPORT_SYMBOL_GPL(CsrWifiEventDes);
+
+size_t CsrWifiEventCsrUint8Sizeof(void *msg)
+{
+ return 3;
+}
+EXPORT_SYMBOL_GPL(CsrWifiEventCsrUint8Sizeof);
+
+u8* CsrWifiEventCsrUint8Ser(u8 *ptr, size_t *len, void *msg)
+{
+ CsrWifiEventCsrUint8 *primitive = (CsrWifiEventCsrUint8 *)msg;
+ *len = 0;
+ CsrUint16Ser(ptr, len, primitive->common.type);
+ CsrUint8Ser(ptr, len, primitive->value);
+ return(ptr);
+}
+EXPORT_SYMBOL_GPL(CsrWifiEventCsrUint8Ser);
+
+
+void* CsrWifiEventCsrUint8Des(u8 *buffer, size_t length)
+{
+ CsrWifiEventCsrUint8 *primitive = kmalloc(sizeof(CsrWifiEventCsrUint8), GFP_KERNEL);
+
+ size_t offset = 0;
+ CsrUint16Des(&primitive->common.type, buffer, &offset);
+ CsrUint8Des(&primitive->value, buffer, &offset);
+
+ return primitive;
+}
+EXPORT_SYMBOL_GPL(CsrWifiEventCsrUint8Des);
+
+
+size_t CsrWifiEventCsrUint16Sizeof(void *msg)
+{
+ return 4;
+}
+EXPORT_SYMBOL_GPL(CsrWifiEventCsrUint16Sizeof);
+
+
+u8* CsrWifiEventCsrUint16Ser(u8 *ptr, size_t *len, void *msg)
+{
+ CsrWifiEventCsrUint16 *primitive = (CsrWifiEventCsrUint16 *)msg;
+ *len = 0;
+ CsrUint16Ser(ptr, len, primitive->common.type);
+ CsrUint16Ser(ptr, len, primitive->value);
+ return(ptr);
+}
+EXPORT_SYMBOL_GPL(CsrWifiEventCsrUint16Ser);
+
+void* CsrWifiEventCsrUint16Des(u8 *buffer, size_t length)
+{
+ CsrWifiEventCsrUint16 *primitive = kmalloc(sizeof(CsrWifiEventCsrUint16), GFP_KERNEL);
+
+ size_t offset = 0;
+ CsrUint16Des(&primitive->common.type, buffer, &offset);
+ CsrUint16Des(&primitive->value, buffer, &offset);
+
+ return primitive;
+}
+EXPORT_SYMBOL_GPL(CsrWifiEventCsrUint16Des);
+
+
+size_t CsrWifiEventCsrUint32Sizeof(void *msg)
+{
+ return 6;
+}
+EXPORT_SYMBOL_GPL(CsrWifiEventCsrUint32Sizeof);
+
+u8* CsrWifiEventCsrUint32Ser(u8 *ptr, size_t *len, void *msg)
+{
+ CsrWifiEventCsrUint32 *primitive = (CsrWifiEventCsrUint32 *)msg;
+ *len = 0;
+ CsrUint16Ser(ptr, len, primitive->common.type);
+ CsrUint32Ser(ptr, len, primitive->value);
+ return(ptr);
+}
+EXPORT_SYMBOL_GPL(CsrWifiEventCsrUint32Ser);
+
+
+void* CsrWifiEventCsrUint32Des(u8 *buffer, size_t length)
+{
+ CsrWifiEventCsrUint32 *primitive = kmalloc(sizeof(CsrWifiEventCsrUint32), GFP_KERNEL);
+
+ size_t offset = 0;
+ CsrUint16Des(&primitive->common.type, buffer, &offset);
+ CsrUint32Des(&primitive->value, buffer, &offset);
+
+ return primitive;
+}
+EXPORT_SYMBOL_GPL(CsrWifiEventCsrUint32Des);
+
+size_t CsrWifiEventCsrUint16CsrUint8Sizeof(void *msg)
+{
+ return 5;
+}
+EXPORT_SYMBOL_GPL(CsrWifiEventCsrUint16CsrUint8Sizeof);
+
+u8* CsrWifiEventCsrUint16CsrUint8Ser(u8 *ptr, size_t *len, void *msg)
+{
+ CsrWifiEventCsrUint16CsrUint8 *primitive = (CsrWifiEventCsrUint16CsrUint8 *)msg;
+ *len = 0;
+ CsrUint16Ser(ptr, len, primitive->common.type);
+ CsrUint16Ser(ptr, len, primitive->value16);
+ CsrUint8Ser(ptr, len, primitive->value8);
+ return(ptr);
+}
+EXPORT_SYMBOL_GPL(CsrWifiEventCsrUint16CsrUint8Ser);
+
+
+void* CsrWifiEventCsrUint16CsrUint8Des(u8 *buffer, size_t length)
+{
+ CsrWifiEventCsrUint16CsrUint8 *primitive = kmalloc(sizeof(CsrWifiEventCsrUint16CsrUint8), GFP_KERNEL);
+
+ size_t offset = 0;
+ CsrUint16Des(&primitive->common.type, buffer, &offset);
+ CsrUint16Des(&primitive->value16, buffer, &offset);
+ CsrUint8Des(&primitive->value8, buffer, &offset);
+
+ return primitive;
+}
+EXPORT_SYMBOL_GPL(CsrWifiEventCsrUint16CsrUint8Des);
+
+
diff --git a/drivers/staging/csr/csr_wifi_sme_ap_lib.h b/drivers/staging/csr/csr_wifi_sme_ap_lib.h
new file mode 100644
index 000000000000..350cb9ec3012
--- /dev/null
+++ b/drivers/staging/csr/csr_wifi_sme_ap_lib.h
@@ -0,0 +1,783 @@
+/*****************************************************************************
+
+ (c) Cambridge Silicon Radio Limited 2012
+ All rights reserved and confidential information of CSR
+
+ Refer to LICENSE.txt included with this source for details
+ on the license terms.
+
+*****************************************************************************/
+
+/* Note: this is an auto-generated file. */
+
+#ifndef CSR_WIFI_SME_AP_LIB_H__
+#define CSR_WIFI_SME_AP_LIB_H__
+
+#include "csr_sched.h"
+#include "csr_macro.h"
+#include "csr_msg_transport.h"
+
+#include "csr_wifi_lib.h"
+
+#include "csr_wifi_sme_ap_prim.h"
+#include "csr_wifi_sme_task.h"
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef CSR_WIFI_AP_ENABLE
+#error CSR_WIFI_AP_ENABLE MUST be defined inorder to use csr_wifi_sme_ap_lib.h
+#endif
+
+/*----------------------------------------------------------------------------*
+ * CsrWifiSmeApFreeUpstreamMessageContents
+ *
+ * DESCRIPTION
+ * Free the allocated memory in a CSR_WIFI_SME_AP upstream message. Does not
+ * free the message itself, and can only be used for upstream messages.
+ *
+ * PARAMETERS
+ * Deallocates the resources in a CSR_WIFI_SME_AP upstream message
+ *----------------------------------------------------------------------------*/
+void CsrWifiSmeApFreeUpstreamMessageContents(u16 eventClass, void *message);
+
+/*----------------------------------------------------------------------------*
+ * CsrWifiSmeApFreeDownstreamMessageContents
+ *
+ * DESCRIPTION
+ * Free the allocated memory in a CSR_WIFI_SME_AP downstream message. Does not
+ * free the message itself, and can only be used for downstream messages.
+ *
+ * PARAMETERS
+ * Deallocates the resources in a CSR_WIFI_SME_AP downstream message
+ *----------------------------------------------------------------------------*/
+void CsrWifiSmeApFreeDownstreamMessageContents(u16 eventClass, void *message);
+
+/*----------------------------------------------------------------------------*
+ * Enum to string functions
+ *----------------------------------------------------------------------------*/
+const char* CsrWifiSmeApAccessTypeToString(CsrWifiSmeApAccessType value);
+const char* CsrWifiSmeApAuthSupportToString(CsrWifiSmeApAuthSupport value);
+const char* CsrWifiSmeApAuthTypeToString(CsrWifiSmeApAuthType value);
+const char* CsrWifiSmeApDirectionToString(CsrWifiSmeApDirection value);
+const char* CsrWifiSmeApPhySupportToString(CsrWifiSmeApPhySupport value);
+const char* CsrWifiSmeApTypeToString(CsrWifiSmeApType value);
+
+
+/*----------------------------------------------------------------------------*
+ * CsrPrim Type toString function.
+ * Converts a message type to the String name of the Message
+ *----------------------------------------------------------------------------*/
+const char* CsrWifiSmeApPrimTypeToString(CsrPrim msgType);
+
+/*----------------------------------------------------------------------------*
+ * Lookup arrays for PrimType name Strings
+ *----------------------------------------------------------------------------*/
+extern const char *CsrWifiSmeApUpstreamPrimNames[CSR_WIFI_SME_AP_PRIM_UPSTREAM_COUNT];
+extern const char *CsrWifiSmeApDownstreamPrimNames[CSR_WIFI_SME_AP_PRIM_DOWNSTREAM_COUNT];
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeApActiveBaGetReqSend
+
+ DESCRIPTION
+ This primitive used to retrieve information related to the active block
+ ack sessions
+
+ PARAMETERS
+ queue - Message Source Task Queue (Cfm's will be sent to this Queue)
+ interfaceTag -
+
+*******************************************************************************/
+#define CsrWifiSmeApActiveBaGetReqCreate(msg__, dst__, src__, interfaceTag__) \
+ msg__ = kmalloc(sizeof(CsrWifiSmeApActiveBaGetReq), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_AP_PRIM, CSR_WIFI_SME_AP_ACTIVE_BA_GET_REQ, dst__, src__); \
+ msg__->interfaceTag = (interfaceTag__);
+
+#define CsrWifiSmeApActiveBaGetReqSendTo(dst__, src__, interfaceTag__) \
+ { \
+ CsrWifiSmeApActiveBaGetReq *msg__; \
+ CsrWifiSmeApActiveBaGetReqCreate(msg__, dst__, src__, interfaceTag__); \
+ CsrMsgTransport(dst__, CSR_WIFI_SME_AP_PRIM, msg__); \
+ }
+
+#define CsrWifiSmeApActiveBaGetReqSend(src__, interfaceTag__) \
+ CsrWifiSmeApActiveBaGetReqSendTo(CSR_WIFI_SME_IFACEQUEUE, src__, interfaceTag__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeApActiveBaGetCfmSend
+
+ DESCRIPTION
+ This primitive carries the information related to the active ba sessions
+
+ PARAMETERS
+ queue - Destination Task Queue
+ interfaceTag -
+ status - Reports the result of the request
+ activeBaCount - Number of active block ack session
+ activeBaSessions - Points to a buffer containing an array of
+ CsrWifiSmeApBaSession structures.
+
+*******************************************************************************/
+#define CsrWifiSmeApActiveBaGetCfmCreate(msg__, dst__, src__, interfaceTag__, status__, activeBaCount__, activeBaSessions__) \
+ msg__ = kmalloc(sizeof(CsrWifiSmeApActiveBaGetCfm), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_AP_PRIM, CSR_WIFI_SME_AP_ACTIVE_BA_GET_CFM, dst__, src__); \
+ msg__->interfaceTag = (interfaceTag__); \
+ msg__->status = (status__); \
+ msg__->activeBaCount = (activeBaCount__); \
+ msg__->activeBaSessions = (activeBaSessions__);
+
+#define CsrWifiSmeApActiveBaGetCfmSendTo(dst__, src__, interfaceTag__, status__, activeBaCount__, activeBaSessions__) \
+ { \
+ CsrWifiSmeApActiveBaGetCfm *msg__; \
+ CsrWifiSmeApActiveBaGetCfmCreate(msg__, dst__, src__, interfaceTag__, status__, activeBaCount__, activeBaSessions__); \
+ CsrSchedMessagePut(dst__, CSR_WIFI_SME_AP_PRIM, msg__); \
+ }
+
+#define CsrWifiSmeApActiveBaGetCfmSend(dst__, interfaceTag__, status__, activeBaCount__, activeBaSessions__) \
+ CsrWifiSmeApActiveBaGetCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, interfaceTag__, status__, activeBaCount__, activeBaSessions__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeApBaDeleteReqSend
+
+ DESCRIPTION
+ This primitive is used to delete an active block ack session
+
+ PARAMETERS
+ queue - Message Source Task Queue (Cfm's will be sent to this Queue)
+ interfaceTag -
+ reason -
+ baSession - BA session to be deleted
+
+*******************************************************************************/
+#define CsrWifiSmeApBaDeleteReqCreate(msg__, dst__, src__, interfaceTag__, reason__, baSession__) \
+ msg__ = kmalloc(sizeof(CsrWifiSmeApBaDeleteReq), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_AP_PRIM, CSR_WIFI_SME_AP_BA_DELETE_REQ, dst__, src__); \
+ msg__->interfaceTag = (interfaceTag__); \
+ msg__->reason = (reason__); \
+ msg__->baSession = (baSession__);
+
+#define CsrWifiSmeApBaDeleteReqSendTo(dst__, src__, interfaceTag__, reason__, baSession__) \
+ { \
+ CsrWifiSmeApBaDeleteReq *msg__; \
+ CsrWifiSmeApBaDeleteReqCreate(msg__, dst__, src__, interfaceTag__, reason__, baSession__); \
+ CsrMsgTransport(dst__, CSR_WIFI_SME_AP_PRIM, msg__); \
+ }
+
+#define CsrWifiSmeApBaDeleteReqSend(src__, interfaceTag__, reason__, baSession__) \
+ CsrWifiSmeApBaDeleteReqSendTo(CSR_WIFI_SME_IFACEQUEUE, src__, interfaceTag__, reason__, baSession__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeApBaDeleteCfmSend
+
+ DESCRIPTION
+ This primitive confirms the BA is deleted
+
+ PARAMETERS
+ queue - Destination Task Queue
+ interfaceTag -
+ status - Reports the result of the request
+ baSession - deleted BA session
+
+*******************************************************************************/
+#define CsrWifiSmeApBaDeleteCfmCreate(msg__, dst__, src__, interfaceTag__, status__, baSession__) \
+ msg__ = kmalloc(sizeof(CsrWifiSmeApBaDeleteCfm), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_AP_PRIM, CSR_WIFI_SME_AP_BA_DELETE_CFM, dst__, src__); \
+ msg__->interfaceTag = (interfaceTag__); \
+ msg__->status = (status__); \
+ msg__->baSession = (baSession__);
+
+#define CsrWifiSmeApBaDeleteCfmSendTo(dst__, src__, interfaceTag__, status__, baSession__) \
+ { \
+ CsrWifiSmeApBaDeleteCfm *msg__; \
+ CsrWifiSmeApBaDeleteCfmCreate(msg__, dst__, src__, interfaceTag__, status__, baSession__); \
+ CsrSchedMessagePut(dst__, CSR_WIFI_SME_AP_PRIM, msg__); \
+ }
+
+#define CsrWifiSmeApBaDeleteCfmSend(dst__, interfaceTag__, status__, baSession__) \
+ CsrWifiSmeApBaDeleteCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, interfaceTag__, status__, baSession__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeApBeaconingStartReqSend
+
+ DESCRIPTION
+ This primitive requests the SME to start AP or GO functionality
+
+ PARAMETERS
+ queue - Message Source Task Queue (Cfm's will be sent to this Queue)
+ interfaceTag -
+ initialPresence - Set to 0, if Not in a group fomration phase, set to 1 ,
+ during group formation phase
+ apType - apType : Legacy AP or P2PGO
+ cloakSsid - cloakSsid flag.
+ ssid - ssid.
+ ifIndex - Radio Interface
+ channel - channel.
+ maxConnections - Maximum Stations + P2PClients allowed
+ apCredentials - AP security credeitals used to advertise in beacon /probe
+ response
+ smeApConfig - AP configuration
+ p2pGoParam - P2P specific GO parameters. Ignored if it is a leagacy AP
+
+*******************************************************************************/
+#define CsrWifiSmeApBeaconingStartReqCreate(msg__, dst__, src__, interfaceTag__, initialPresence__, apType__, cloakSsid__, ssid__, ifIndex__, channel__, maxConnections__, apCredentials__, smeApConfig__, p2pGoParam__) \
+ msg__ = kmalloc(sizeof(CsrWifiSmeApBeaconingStartReq), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_AP_PRIM, CSR_WIFI_SME_AP_BEACONING_START_REQ, dst__, src__); \
+ msg__->interfaceTag = (interfaceTag__); \
+ msg__->initialPresence = (initialPresence__); \
+ msg__->apType = (apType__); \
+ msg__->cloakSsid = (cloakSsid__); \
+ msg__->ssid = (ssid__); \
+ msg__->ifIndex = (ifIndex__); \
+ msg__->channel = (channel__); \
+ msg__->maxConnections = (maxConnections__); \
+ msg__->apCredentials = (apCredentials__); \
+ msg__->smeApConfig = (smeApConfig__); \
+ msg__->p2pGoParam = (p2pGoParam__);
+
+#define CsrWifiSmeApBeaconingStartReqSendTo(dst__, src__, interfaceTag__, initialPresence__, apType__, cloakSsid__, ssid__, ifIndex__, channel__, maxConnections__, apCredentials__, smeApConfig__, p2pGoParam__) \
+ { \
+ CsrWifiSmeApBeaconingStartReq *msg__; \
+ CsrWifiSmeApBeaconingStartReqCreate(msg__, dst__, src__, interfaceTag__, initialPresence__, apType__, cloakSsid__, ssid__, ifIndex__, channel__, maxConnections__, apCredentials__, smeApConfig__, p2pGoParam__); \
+ CsrMsgTransport(dst__, CSR_WIFI_SME_AP_PRIM, msg__); \
+ }
+
+#define CsrWifiSmeApBeaconingStartReqSend(src__, interfaceTag__, initialPresence__, apType__, cloakSsid__, ssid__, ifIndex__, channel__, maxConnections__, apCredentials__, smeApConfig__, p2pGoParam__) \
+ CsrWifiSmeApBeaconingStartReqSendTo(CSR_WIFI_SME_IFACEQUEUE, src__, interfaceTag__, initialPresence__, apType__, cloakSsid__, ssid__, ifIndex__, channel__, maxConnections__, apCredentials__, smeApConfig__, p2pGoParam__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeApBeaconingStartCfmSend
+
+ DESCRIPTION
+ This primitive confirms the completion of the request along with the
+ status
+
+ PARAMETERS
+ queue - Destination Task Queue
+ interfaceTag -
+ status -
+ secIeLength -
+ secIe -
+
+*******************************************************************************/
+#define CsrWifiSmeApBeaconingStartCfmCreate(msg__, dst__, src__, interfaceTag__, status__, secIeLength__, secIe__) \
+ msg__ = kmalloc(sizeof(CsrWifiSmeApBeaconingStartCfm), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_AP_PRIM, CSR_WIFI_SME_AP_BEACONING_START_CFM, dst__, src__); \
+ msg__->interfaceTag = (interfaceTag__); \
+ msg__->status = (status__); \
+ msg__->secIeLength = (secIeLength__); \
+ msg__->secIe = (secIe__);
+
+#define CsrWifiSmeApBeaconingStartCfmSendTo(dst__, src__, interfaceTag__, status__, secIeLength__, secIe__) \
+ { \
+ CsrWifiSmeApBeaconingStartCfm *msg__; \
+ CsrWifiSmeApBeaconingStartCfmCreate(msg__, dst__, src__, interfaceTag__, status__, secIeLength__, secIe__); \
+ CsrSchedMessagePut(dst__, CSR_WIFI_SME_AP_PRIM, msg__); \
+ }
+
+#define CsrWifiSmeApBeaconingStartCfmSend(dst__, interfaceTag__, status__, secIeLength__, secIe__) \
+ CsrWifiSmeApBeaconingStartCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, interfaceTag__, status__, secIeLength__, secIe__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeApBeaconingStopReqSend
+
+ DESCRIPTION
+ This primitive requests the SME to STOP AP or P2PGO operation
+
+ PARAMETERS
+ queue - Message Source Task Queue (Cfm's will be sent to this Queue)
+ interfaceTag -
+
+*******************************************************************************/
+#define CsrWifiSmeApBeaconingStopReqCreate(msg__, dst__, src__, interfaceTag__) \
+ msg__ = kmalloc(sizeof(CsrWifiSmeApBeaconingStopReq), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_AP_PRIM, CSR_WIFI_SME_AP_BEACONING_STOP_REQ, dst__, src__); \
+ msg__->interfaceTag = (interfaceTag__);
+
+#define CsrWifiSmeApBeaconingStopReqSendTo(dst__, src__, interfaceTag__) \
+ { \
+ CsrWifiSmeApBeaconingStopReq *msg__; \
+ CsrWifiSmeApBeaconingStopReqCreate(msg__, dst__, src__, interfaceTag__); \
+ CsrMsgTransport(dst__, CSR_WIFI_SME_AP_PRIM, msg__); \
+ }
+
+#define CsrWifiSmeApBeaconingStopReqSend(src__, interfaceTag__) \
+ CsrWifiSmeApBeaconingStopReqSendTo(CSR_WIFI_SME_IFACEQUEUE, src__, interfaceTag__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeApBeaconingStopCfmSend
+
+ DESCRIPTION
+ This primitive confirms AP or P2PGO operation is terminated
+
+ PARAMETERS
+ queue - Destination Task Queue
+ interfaceTag -
+ status -
+
+*******************************************************************************/
+#define CsrWifiSmeApBeaconingStopCfmCreate(msg__, dst__, src__, interfaceTag__, status__) \
+ msg__ = kmalloc(sizeof(CsrWifiSmeApBeaconingStopCfm), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_AP_PRIM, CSR_WIFI_SME_AP_BEACONING_STOP_CFM, dst__, src__); \
+ msg__->interfaceTag = (interfaceTag__); \
+ msg__->status = (status__);
+
+#define CsrWifiSmeApBeaconingStopCfmSendTo(dst__, src__, interfaceTag__, status__) \
+ { \
+ CsrWifiSmeApBeaconingStopCfm *msg__; \
+ CsrWifiSmeApBeaconingStopCfmCreate(msg__, dst__, src__, interfaceTag__, status__); \
+ CsrSchedMessagePut(dst__, CSR_WIFI_SME_AP_PRIM, msg__); \
+ }
+
+#define CsrWifiSmeApBeaconingStopCfmSend(dst__, interfaceTag__, status__) \
+ CsrWifiSmeApBeaconingStopCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, interfaceTag__, status__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeApErrorIndSend
+
+ DESCRIPTION
+ This primitve is sent by SME to indicate some error in AP operationi
+ after AP operations were started successfully and continuing the AP
+ operation may lead to undesired behaviour. It is the responsibility of
+ the upper layers to stop AP operation if needed
+
+ PARAMETERS
+ queue - Destination Task Queue
+ interfaceTag - Range 0-1
+ apType -
+ status - Contains the error status
+
+*******************************************************************************/
+#define CsrWifiSmeApErrorIndCreate(msg__, dst__, src__, interfaceTag__, apType__, status__) \
+ msg__ = kmalloc(sizeof(CsrWifiSmeApErrorInd), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_AP_PRIM, CSR_WIFI_SME_AP_ERROR_IND, dst__, src__); \
+ msg__->interfaceTag = (interfaceTag__); \
+ msg__->apType = (apType__); \
+ msg__->status = (status__);
+
+#define CsrWifiSmeApErrorIndSendTo(dst__, src__, interfaceTag__, apType__, status__) \
+ { \
+ CsrWifiSmeApErrorInd *msg__; \
+ CsrWifiSmeApErrorIndCreate(msg__, dst__, src__, interfaceTag__, apType__, status__); \
+ CsrSchedMessagePut(dst__, CSR_WIFI_SME_AP_PRIM, msg__); \
+ }
+
+#define CsrWifiSmeApErrorIndSend(dst__, interfaceTag__, apType__, status__) \
+ CsrWifiSmeApErrorIndSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, interfaceTag__, apType__, status__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeApStaConnectStartIndSend
+
+ DESCRIPTION
+ This primitive indicates that a stations request to join the group/BSS is
+ accepted
+
+ PARAMETERS
+ queue - Destination Task Queue
+ interfaceTag -
+ peerMacAddress -
+
+*******************************************************************************/
+#define CsrWifiSmeApStaConnectStartIndCreate(msg__, dst__, src__, interfaceTag__, peerMacAddress__) \
+ msg__ = kmalloc(sizeof(CsrWifiSmeApStaConnectStartInd), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_AP_PRIM, CSR_WIFI_SME_AP_STA_CONNECT_START_IND, dst__, src__); \
+ msg__->interfaceTag = (interfaceTag__); \
+ msg__->peerMacAddress = (peerMacAddress__);
+
+#define CsrWifiSmeApStaConnectStartIndSendTo(dst__, src__, interfaceTag__, peerMacAddress__) \
+ { \
+ CsrWifiSmeApStaConnectStartInd *msg__; \
+ CsrWifiSmeApStaConnectStartIndCreate(msg__, dst__, src__, interfaceTag__, peerMacAddress__); \
+ CsrSchedMessagePut(dst__, CSR_WIFI_SME_AP_PRIM, msg__); \
+ }
+
+#define CsrWifiSmeApStaConnectStartIndSend(dst__, interfaceTag__, peerMacAddress__) \
+ CsrWifiSmeApStaConnectStartIndSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, interfaceTag__, peerMacAddress__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeApStaDisconnectReqSend
+
+ DESCRIPTION
+ This primitive tells SME to deauth ot disassociate a particular station
+ within BSS
+
+ PARAMETERS
+ queue - Message Source Task Queue (Cfm's will be sent to this Queue)
+ interfaceTag -
+ deauthReason -
+ disassocReason -
+ peerMacaddress -
+ keepBlocking - If TRUE, the station is blocked. If FALSE and the station
+ is connected, disconnect the station. If FALSE and the
+ station is not connected, no action is taken.
+
+*******************************************************************************/
+#define CsrWifiSmeApStaDisconnectReqCreate(msg__, dst__, src__, interfaceTag__, deauthReason__, disassocReason__, peerMacaddress__, keepBlocking__) \
+ msg__ = kmalloc(sizeof(CsrWifiSmeApStaDisconnectReq), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_AP_PRIM, CSR_WIFI_SME_AP_STA_DISCONNECT_REQ, dst__, src__); \
+ msg__->interfaceTag = (interfaceTag__); \
+ msg__->deauthReason = (deauthReason__); \
+ msg__->disassocReason = (disassocReason__); \
+ msg__->peerMacaddress = (peerMacaddress__); \
+ msg__->keepBlocking = (keepBlocking__);
+
+#define CsrWifiSmeApStaDisconnectReqSendTo(dst__, src__, interfaceTag__, deauthReason__, disassocReason__, peerMacaddress__, keepBlocking__) \
+ { \
+ CsrWifiSmeApStaDisconnectReq *msg__; \
+ CsrWifiSmeApStaDisconnectReqCreate(msg__, dst__, src__, interfaceTag__, deauthReason__, disassocReason__, peerMacaddress__, keepBlocking__); \
+ CsrMsgTransport(dst__, CSR_WIFI_SME_AP_PRIM, msg__); \
+ }
+
+#define CsrWifiSmeApStaDisconnectReqSend(src__, interfaceTag__, deauthReason__, disassocReason__, peerMacaddress__, keepBlocking__) \
+ CsrWifiSmeApStaDisconnectReqSendTo(CSR_WIFI_SME_IFACEQUEUE, src__, interfaceTag__, deauthReason__, disassocReason__, peerMacaddress__, keepBlocking__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeApStaDisconnectCfmSend
+
+ DESCRIPTION
+ This primitive confirms the station is disconnected
+
+ PARAMETERS
+ queue - Destination Task Queue
+ interfaceTag -
+ status -
+ peerMacaddress -
+
+*******************************************************************************/
+#define CsrWifiSmeApStaDisconnectCfmCreate(msg__, dst__, src__, interfaceTag__, status__, peerMacaddress__) \
+ msg__ = kmalloc(sizeof(CsrWifiSmeApStaDisconnectCfm), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_AP_PRIM, CSR_WIFI_SME_AP_STA_DISCONNECT_CFM, dst__, src__); \
+ msg__->interfaceTag = (interfaceTag__); \
+ msg__->status = (status__); \
+ msg__->peerMacaddress = (peerMacaddress__);
+
+#define CsrWifiSmeApStaDisconnectCfmSendTo(dst__, src__, interfaceTag__, status__, peerMacaddress__) \
+ { \
+ CsrWifiSmeApStaDisconnectCfm *msg__; \
+ CsrWifiSmeApStaDisconnectCfmCreate(msg__, dst__, src__, interfaceTag__, status__, peerMacaddress__); \
+ CsrSchedMessagePut(dst__, CSR_WIFI_SME_AP_PRIM, msg__); \
+ }
+
+#define CsrWifiSmeApStaDisconnectCfmSend(dst__, interfaceTag__, status__, peerMacaddress__) \
+ CsrWifiSmeApStaDisconnectCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, interfaceTag__, status__, peerMacaddress__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeApStaNotifyIndSend
+
+ DESCRIPTION
+ This primitive indicates that a station has joined or a previously joined
+ station has left the BSS/group
+
+ PARAMETERS
+ queue - Destination Task Queue
+ interfaceTag -
+ mediaStatus -
+ peerMacAddress -
+ peerDeviceAddress -
+ disassocReason -
+ deauthReason -
+ WpsRegistration -
+ secIeLength -
+ secIe -
+ groupKeyId -
+ seqNumber -
+
+*******************************************************************************/
+#define CsrWifiSmeApStaNotifyIndCreate(msg__, dst__, src__, interfaceTag__, mediaStatus__, peerMacAddress__, peerDeviceAddress__, disassocReason__, deauthReason__, WpsRegistration__, secIeLength__, secIe__, groupKeyId__, seqNumber__) \
+ msg__ = kmalloc(sizeof(CsrWifiSmeApStaNotifyInd), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_AP_PRIM, CSR_WIFI_SME_AP_STA_NOTIFY_IND, dst__, src__); \
+ msg__->interfaceTag = (interfaceTag__); \
+ msg__->mediaStatus = (mediaStatus__); \
+ msg__->peerMacAddress = (peerMacAddress__); \
+ msg__->peerDeviceAddress = (peerDeviceAddress__); \
+ msg__->disassocReason = (disassocReason__); \
+ msg__->deauthReason = (deauthReason__); \
+ msg__->WpsRegistration = (WpsRegistration__); \
+ msg__->secIeLength = (secIeLength__); \
+ msg__->secIe = (secIe__); \
+ msg__->groupKeyId = (groupKeyId__); \
+ memcpy(msg__->seqNumber, (seqNumber__), sizeof(u16) * 8);
+
+#define CsrWifiSmeApStaNotifyIndSendTo(dst__, src__, interfaceTag__, mediaStatus__, peerMacAddress__, peerDeviceAddress__, disassocReason__, deauthReason__, WpsRegistration__, secIeLength__, secIe__, groupKeyId__, seqNumber__) \
+ { \
+ CsrWifiSmeApStaNotifyInd *msg__; \
+ CsrWifiSmeApStaNotifyIndCreate(msg__, dst__, src__, interfaceTag__, mediaStatus__, peerMacAddress__, peerDeviceAddress__, disassocReason__, deauthReason__, WpsRegistration__, secIeLength__, secIe__, groupKeyId__, seqNumber__); \
+ CsrSchedMessagePut(dst__, CSR_WIFI_SME_AP_PRIM, msg__); \
+ }
+
+#define CsrWifiSmeApStaNotifyIndSend(dst__, interfaceTag__, mediaStatus__, peerMacAddress__, peerDeviceAddress__, disassocReason__, deauthReason__, WpsRegistration__, secIeLength__, secIe__, groupKeyId__, seqNumber__) \
+ CsrWifiSmeApStaNotifyIndSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, interfaceTag__, mediaStatus__, peerMacAddress__, peerDeviceAddress__, disassocReason__, deauthReason__, WpsRegistration__, secIeLength__, secIe__, groupKeyId__, seqNumber__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeApWmmParamUpdateReqSend
+
+ DESCRIPTION
+ Application uses this primitive to update the WMM parameters on the fly
+
+ PARAMETERS
+ queue - Message Source Task Queue (Cfm's will be sent to this Queue)
+ interfaceTag -
+ wmmApParams - WMM parameters to be used for local firmware queue
+ configuration
+ wmmApBcParams - WMM parameters to be advertised in beacon/probe response
+
+*******************************************************************************/
+#define CsrWifiSmeApWmmParamUpdateReqCreate(msg__, dst__, src__, interfaceTag__, wmmApParams__, wmmApBcParams__) \
+ msg__ = kmalloc(sizeof(CsrWifiSmeApWmmParamUpdateReq), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_AP_PRIM, CSR_WIFI_SME_AP_WMM_PARAM_UPDATE_REQ, dst__, src__); \
+ msg__->interfaceTag = (interfaceTag__); \
+ memcpy(msg__->wmmApParams, (wmmApParams__), sizeof(CsrWifiSmeWmmAcParams) * 4); \
+ memcpy(msg__->wmmApBcParams, (wmmApBcParams__), sizeof(CsrWifiSmeWmmAcParams) * 4);
+
+#define CsrWifiSmeApWmmParamUpdateReqSendTo(dst__, src__, interfaceTag__, wmmApParams__, wmmApBcParams__) \
+ { \
+ CsrWifiSmeApWmmParamUpdateReq *msg__; \
+ CsrWifiSmeApWmmParamUpdateReqCreate(msg__, dst__, src__, interfaceTag__, wmmApParams__, wmmApBcParams__); \
+ CsrMsgTransport(dst__, CSR_WIFI_SME_AP_PRIM, msg__); \
+ }
+
+#define CsrWifiSmeApWmmParamUpdateReqSend(src__, interfaceTag__, wmmApParams__, wmmApBcParams__) \
+ CsrWifiSmeApWmmParamUpdateReqSendTo(CSR_WIFI_SME_IFACEQUEUE, src__, interfaceTag__, wmmApParams__, wmmApBcParams__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeApWmmParamUpdateCfmSend
+
+ DESCRIPTION
+ A confirm for CSR_WIFI_SME_AP_WMM_PARAM_UPDATE.request
+
+ PARAMETERS
+ queue - Destination Task Queue
+ interfaceTag -
+ status -
+
+*******************************************************************************/
+#define CsrWifiSmeApWmmParamUpdateCfmCreate(msg__, dst__, src__, interfaceTag__, status__) \
+ msg__ = kmalloc(sizeof(CsrWifiSmeApWmmParamUpdateCfm), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_AP_PRIM, CSR_WIFI_SME_AP_WMM_PARAM_UPDATE_CFM, dst__, src__); \
+ msg__->interfaceTag = (interfaceTag__); \
+ msg__->status = (status__);
+
+#define CsrWifiSmeApWmmParamUpdateCfmSendTo(dst__, src__, interfaceTag__, status__) \
+ { \
+ CsrWifiSmeApWmmParamUpdateCfm *msg__; \
+ CsrWifiSmeApWmmParamUpdateCfmCreate(msg__, dst__, src__, interfaceTag__, status__); \
+ CsrSchedMessagePut(dst__, CSR_WIFI_SME_AP_PRIM, msg__); \
+ }
+
+#define CsrWifiSmeApWmmParamUpdateCfmSend(dst__, interfaceTag__, status__) \
+ CsrWifiSmeApWmmParamUpdateCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, interfaceTag__, status__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeApWpsConfigurationReqSend
+
+ DESCRIPTION
+ This primitive passes the WPS information for the device to SME. This may
+ be accepted only if no interface is active.
+
+ PARAMETERS
+ queue - Message Source Task Queue (Cfm's will be sent to this Queue)
+ wpsConfig - WPS config.
+
+*******************************************************************************/
+#define CsrWifiSmeApWpsConfigurationReqCreate(msg__, dst__, src__, wpsConfig__) \
+ msg__ = kmalloc(sizeof(CsrWifiSmeApWpsConfigurationReq), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_AP_PRIM, CSR_WIFI_SME_AP_WPS_CONFIGURATION_REQ, dst__, src__); \
+ msg__->wpsConfig = (wpsConfig__);
+
+#define CsrWifiSmeApWpsConfigurationReqSendTo(dst__, src__, wpsConfig__) \
+ { \
+ CsrWifiSmeApWpsConfigurationReq *msg__; \
+ CsrWifiSmeApWpsConfigurationReqCreate(msg__, dst__, src__, wpsConfig__); \
+ CsrMsgTransport(dst__, CSR_WIFI_SME_AP_PRIM, msg__); \
+ }
+
+#define CsrWifiSmeApWpsConfigurationReqSend(src__, wpsConfig__) \
+ CsrWifiSmeApWpsConfigurationReqSendTo(CSR_WIFI_SME_IFACEQUEUE, src__, wpsConfig__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeApWpsConfigurationCfmSend
+
+ DESCRIPTION
+ Confirm.
+
+ PARAMETERS
+ queue - Destination Task Queue
+ status - Status of the request.
+
+*******************************************************************************/
+#define CsrWifiSmeApWpsConfigurationCfmCreate(msg__, dst__, src__, status__) \
+ msg__ = kmalloc(sizeof(CsrWifiSmeApWpsConfigurationCfm), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_AP_PRIM, CSR_WIFI_SME_AP_WPS_CONFIGURATION_CFM, dst__, src__); \
+ msg__->status = (status__);
+
+#define CsrWifiSmeApWpsConfigurationCfmSendTo(dst__, src__, status__) \
+ { \
+ CsrWifiSmeApWpsConfigurationCfm *msg__; \
+ CsrWifiSmeApWpsConfigurationCfmCreate(msg__, dst__, src__, status__); \
+ CsrSchedMessagePut(dst__, CSR_WIFI_SME_AP_PRIM, msg__); \
+ }
+
+#define CsrWifiSmeApWpsConfigurationCfmSend(dst__, status__) \
+ CsrWifiSmeApWpsConfigurationCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, status__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeApWpsRegistrationFinishedReqSend
+
+ DESCRIPTION
+ This primitive tells SME that WPS registration procedure has finished
+
+ PARAMETERS
+ queue - Message Source Task Queue (Cfm's will be sent to this Queue)
+ interfaceTag -
+
+*******************************************************************************/
+#define CsrWifiSmeApWpsRegistrationFinishedReqCreate(msg__, dst__, src__, interfaceTag__) \
+ msg__ = kmalloc(sizeof(CsrWifiSmeApWpsRegistrationFinishedReq), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_AP_PRIM, CSR_WIFI_SME_AP_WPS_REGISTRATION_FINISHED_REQ, dst__, src__); \
+ msg__->interfaceTag = (interfaceTag__);
+
+#define CsrWifiSmeApWpsRegistrationFinishedReqSendTo(dst__, src__, interfaceTag__) \
+ { \
+ CsrWifiSmeApWpsRegistrationFinishedReq *msg__; \
+ CsrWifiSmeApWpsRegistrationFinishedReqCreate(msg__, dst__, src__, interfaceTag__); \
+ CsrMsgTransport(dst__, CSR_WIFI_SME_AP_PRIM, msg__); \
+ }
+
+#define CsrWifiSmeApWpsRegistrationFinishedReqSend(src__, interfaceTag__) \
+ CsrWifiSmeApWpsRegistrationFinishedReqSendTo(CSR_WIFI_SME_IFACEQUEUE, src__, interfaceTag__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeApWpsRegistrationFinishedCfmSend
+
+ DESCRIPTION
+ A confirm for UNIFI_MGT_AP_WPS_REGISTRATION_FINISHED.request
+
+ PARAMETERS
+ queue - Destination Task Queue
+ interfaceTag -
+ status -
+
+*******************************************************************************/
+#define CsrWifiSmeApWpsRegistrationFinishedCfmCreate(msg__, dst__, src__, interfaceTag__, status__) \
+ msg__ = kmalloc(sizeof(CsrWifiSmeApWpsRegistrationFinishedCfm), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_AP_PRIM, CSR_WIFI_SME_AP_WPS_REGISTRATION_FINISHED_CFM, dst__, src__); \
+ msg__->interfaceTag = (interfaceTag__); \
+ msg__->status = (status__);
+
+#define CsrWifiSmeApWpsRegistrationFinishedCfmSendTo(dst__, src__, interfaceTag__, status__) \
+ { \
+ CsrWifiSmeApWpsRegistrationFinishedCfm *msg__; \
+ CsrWifiSmeApWpsRegistrationFinishedCfmCreate(msg__, dst__, src__, interfaceTag__, status__); \
+ CsrSchedMessagePut(dst__, CSR_WIFI_SME_AP_PRIM, msg__); \
+ }
+
+#define CsrWifiSmeApWpsRegistrationFinishedCfmSend(dst__, interfaceTag__, status__) \
+ CsrWifiSmeApWpsRegistrationFinishedCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, interfaceTag__, status__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeApWpsRegistrationStartedReqSend
+
+ DESCRIPTION
+ This primitive tells SME that WPS registration procedure has started
+
+ PARAMETERS
+ queue - Message Source Task Queue (Cfm's will be sent to this Queue)
+ interfaceTag -
+ SelectedDevicePasswordId -
+ SelectedconfigMethod -
+
+*******************************************************************************/
+#define CsrWifiSmeApWpsRegistrationStartedReqCreate(msg__, dst__, src__, interfaceTag__, SelectedDevicePasswordId__, SelectedconfigMethod__) \
+ msg__ = kmalloc(sizeof(CsrWifiSmeApWpsRegistrationStartedReq), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_AP_PRIM, CSR_WIFI_SME_AP_WPS_REGISTRATION_STARTED_REQ, dst__, src__); \
+ msg__->interfaceTag = (interfaceTag__); \
+ msg__->SelectedDevicePasswordId = (SelectedDevicePasswordId__); \
+ msg__->SelectedconfigMethod = (SelectedconfigMethod__);
+
+#define CsrWifiSmeApWpsRegistrationStartedReqSendTo(dst__, src__, interfaceTag__, SelectedDevicePasswordId__, SelectedconfigMethod__) \
+ { \
+ CsrWifiSmeApWpsRegistrationStartedReq *msg__; \
+ CsrWifiSmeApWpsRegistrationStartedReqCreate(msg__, dst__, src__, interfaceTag__, SelectedDevicePasswordId__, SelectedconfigMethod__); \
+ CsrMsgTransport(dst__, CSR_WIFI_SME_AP_PRIM, msg__); \
+ }
+
+#define CsrWifiSmeApWpsRegistrationStartedReqSend(src__, interfaceTag__, SelectedDevicePasswordId__, SelectedconfigMethod__) \
+ CsrWifiSmeApWpsRegistrationStartedReqSendTo(CSR_WIFI_SME_IFACEQUEUE, src__, interfaceTag__, SelectedDevicePasswordId__, SelectedconfigMethod__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeApWpsRegistrationStartedCfmSend
+
+ DESCRIPTION
+ A confirm for UNIFI_MGT_AP_WPS_REGISTRATION_STARTED.request
+
+ PARAMETERS
+ queue - Destination Task Queue
+ interfaceTag -
+ status -
+
+*******************************************************************************/
+#define CsrWifiSmeApWpsRegistrationStartedCfmCreate(msg__, dst__, src__, interfaceTag__, status__) \
+ msg__ = kmalloc(sizeof(CsrWifiSmeApWpsRegistrationStartedCfm), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_AP_PRIM, CSR_WIFI_SME_AP_WPS_REGISTRATION_STARTED_CFM, dst__, src__); \
+ msg__->interfaceTag = (interfaceTag__); \
+ msg__->status = (status__);
+
+#define CsrWifiSmeApWpsRegistrationStartedCfmSendTo(dst__, src__, interfaceTag__, status__) \
+ { \
+ CsrWifiSmeApWpsRegistrationStartedCfm *msg__; \
+ CsrWifiSmeApWpsRegistrationStartedCfmCreate(msg__, dst__, src__, interfaceTag__, status__); \
+ CsrSchedMessagePut(dst__, CSR_WIFI_SME_AP_PRIM, msg__); \
+ }
+
+#define CsrWifiSmeApWpsRegistrationStartedCfmSend(dst__, interfaceTag__, status__) \
+ CsrWifiSmeApWpsRegistrationStartedCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, interfaceTag__, status__)
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* CSR_WIFI_SME_AP_LIB_H__ */
diff --git a/drivers/staging/csr/csr_wifi_sme_ap_prim.h b/drivers/staging/csr/csr_wifi_sme_ap_prim.h
new file mode 100644
index 000000000000..93b64e9154c8
--- /dev/null
+++ b/drivers/staging/csr/csr_wifi_sme_ap_prim.h
@@ -0,0 +1,1038 @@
+/*****************************************************************************
+
+ (c) Cambridge Silicon Radio Limited 2012
+ All rights reserved and confidential information of CSR
+
+ Refer to LICENSE.txt included with this source for details
+ on the license terms.
+
+*****************************************************************************/
+
+/* Note: this is an auto-generated file. */
+
+#ifndef CSR_WIFI_SME_AP_PRIM_H__
+#define CSR_WIFI_SME_AP_PRIM_H__
+
+#include "csr_prim_defs.h"
+#include "csr_sched.h"
+#include "csr_wifi_common.h"
+#include "csr_result.h"
+#include "csr_wifi_fsm_event.h"
+#include "csr_wifi_sme_prim.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef CSR_WIFI_AP_ENABLE
+#error CSR_WIFI_AP_ENABLE MUST be defined inorder to use csr_wifi_sme_ap_prim.h
+#endif
+
+#define CSR_WIFI_SME_AP_PRIM (0x0407)
+
+typedef CsrPrim CsrWifiSmeApPrim;
+
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeApAccessType
+
+ DESCRIPTION
+ Allow or deny STAs based on MAC address
+
+ VALUES
+ CSR_WIFI_AP_ACCESS_TYPE_NONE - None
+ CSR_WIFI_AP_ACCESS_TYPE_ALLOW - Allow only if MAC address is from the list
+ CSR_WIFI_AP_ACCESS_TYPE_DENY - Disallow if MAC address is from the list
+
+*******************************************************************************/
+typedef u8 CsrWifiSmeApAccessType;
+#define CSR_WIFI_AP_ACCESS_TYPE_NONE ((CsrWifiSmeApAccessType) 0x00)
+#define CSR_WIFI_AP_ACCESS_TYPE_ALLOW ((CsrWifiSmeApAccessType) 0x01)
+#define CSR_WIFI_AP_ACCESS_TYPE_DENY ((CsrWifiSmeApAccessType) 0x02)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeApAuthSupport
+
+ DESCRIPTION
+ Define bits for AP authentication support
+
+ VALUES
+ CSR_WIFI_SME_RSN_AUTH_WPAPSK - RSN WPA-PSK Support
+ CSR_WIFI_SME_RSN_AUTH_WPA2PSK - RSN WPA2-PSK Support
+ CSR_WIFI_SME_AUTH_WAPIPSK - WAPI-PSK Support
+
+*******************************************************************************/
+typedef u8 CsrWifiSmeApAuthSupport;
+#define CSR_WIFI_SME_RSN_AUTH_WPAPSK ((CsrWifiSmeApAuthSupport) 0x01)
+#define CSR_WIFI_SME_RSN_AUTH_WPA2PSK ((CsrWifiSmeApAuthSupport) 0x02)
+#define CSR_WIFI_SME_AUTH_WAPIPSK ((CsrWifiSmeApAuthSupport) 0x04)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeApAuthType
+
+ DESCRIPTION
+ Definition of the SME AP Authentication Options
+
+ VALUES
+ CSR_WIFI_SME_AP_AUTH_TYPE_OPEN_SYSTEM
+ - Open authentication
+ CSR_WIFI_SME_AP_AUTH_TYPE_PERSONAL
+ - Personal authentication using a passphrase or a pre-shared
+ key.
+ CSR_WIFI_SME_AP_AUTH_TYPE_WEP
+ - WEP authentication. This can be either open or shared key
+
+*******************************************************************************/
+typedef u8 CsrWifiSmeApAuthType;
+#define CSR_WIFI_SME_AP_AUTH_TYPE_OPEN_SYSTEM ((CsrWifiSmeApAuthType) 0x00)
+#define CSR_WIFI_SME_AP_AUTH_TYPE_PERSONAL ((CsrWifiSmeApAuthType) 0x01)
+#define CSR_WIFI_SME_AP_AUTH_TYPE_WEP ((CsrWifiSmeApAuthType) 0x02)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeApDirection
+
+ DESCRIPTION
+ Definition of Direction
+
+ VALUES
+ CSR_WIFI_AP_DIRECTION_RECEIPIENT - Receipient
+ CSR_WIFI_AP_DIRECTION_ORIGINATOR - Originator
+
+*******************************************************************************/
+typedef u8 CsrWifiSmeApDirection;
+#define CSR_WIFI_AP_DIRECTION_RECEIPIENT ((CsrWifiSmeApDirection) 0x00)
+#define CSR_WIFI_AP_DIRECTION_ORIGINATOR ((CsrWifiSmeApDirection) 0x01)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeApPhySupport
+
+ DESCRIPTION
+ Define bits for CsrWifiSmeApPhySupportMask
+
+ VALUES
+ CSR_WIFI_SME_AP_PHY_SUPPORT_A - 802.11a. It is not supported in the current
+ release.
+ CSR_WIFI_SME_AP_PHY_SUPPORT_B - 802.11b
+ CSR_WIFI_SME_AP_PHY_SUPPORT_G - 802.11g
+ CSR_WIFI_SME_AP_PHY_SUPPORT_N - 802.11n
+
+*******************************************************************************/
+typedef u8 CsrWifiSmeApPhySupport;
+#define CSR_WIFI_SME_AP_PHY_SUPPORT_A ((CsrWifiSmeApPhySupport) 0x01)
+#define CSR_WIFI_SME_AP_PHY_SUPPORT_B ((CsrWifiSmeApPhySupport) 0x02)
+#define CSR_WIFI_SME_AP_PHY_SUPPORT_G ((CsrWifiSmeApPhySupport) 0x04)
+#define CSR_WIFI_SME_AP_PHY_SUPPORT_N ((CsrWifiSmeApPhySupport) 0x08)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeApType
+
+ DESCRIPTION
+ Definition of AP types
+
+ VALUES
+ CSR_WIFI_AP_TYPE_LEGACY - Legacy AP
+ CSR_WIFI_AP_TYPE_P2P - P2P Group Owner(GO)
+
+*******************************************************************************/
+typedef u8 CsrWifiSmeApType;
+#define CSR_WIFI_AP_TYPE_LEGACY ((CsrWifiSmeApType) 0x00)
+#define CSR_WIFI_AP_TYPE_P2P ((CsrWifiSmeApType) 0x01)
+
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeApAuthSupportMask
+
+ DESCRIPTION
+ See CsrWifiSmeApAuthSupport for bit definitions
+
+*******************************************************************************/
+typedef u8 CsrWifiSmeApAuthSupportMask;
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeApPhySupportMask
+
+ DESCRIPTION
+ Mask type for use with the values defined by CsrWifiSmeApPhySupport
+
+*******************************************************************************/
+typedef u8 CsrWifiSmeApPhySupportMask;
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeApRsnCapabilities
+
+ DESCRIPTION
+ Set to 0 for the current release
+
+*******************************************************************************/
+typedef u16 CsrWifiSmeApRsnCapabilities;
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeApRsnCapabilitiesMask
+
+ DESCRIPTION
+ Mask type for use with the values defined by CsrWifiSmeApRsnCapabilities
+
+*******************************************************************************/
+typedef u16 CsrWifiSmeApRsnCapabilitiesMask;
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeApWapiCapabilities
+
+ DESCRIPTION
+ Ignored by the stack as WAPI is not supported for AP operations in the
+ current release
+
+*******************************************************************************/
+typedef u16 CsrWifiSmeApWapiCapabilities;
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeApWapiCapabilitiesMask
+
+ DESCRIPTION
+ Mask type for use with the values defined by CsrWifiSmeApWapiCapabilities
+
+*******************************************************************************/
+typedef u16 CsrWifiSmeApWapiCapabilitiesMask;
+
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeApHtParams
+
+ DESCRIPTION
+ Structure holding HT parameters
+
+ MEMBERS
+ greenfieldSupported - Indicates if the AP supports Htgreenfield operation
+ subject to the chip capability. If the chip does not
+ support Htgreenfield operation, this parameter will be
+ ignored.
+ NOTE: if shortGi20MHz is set to TRUE and the chip
+ supports short GI operation for 20MHz this field will
+ be be ignored and the AP will not support Htgreenfield
+ operation.
+ NOTE: This field is ignored by the Wi-Fi stack for the
+ current release. It implies that AP does not support
+ greenfield operation.
+ shortGi20MHz - Indicates if the AP support short GI operation for
+ 20MHz subject to the chip capability.If the chip does
+ not support short GI for 20MHz, this parameter is
+ ignored
+ rxStbc - Support for STBC for receive. 0 => No support for STBC
+ , 1=> Use STBC for Rx
+ rifsModeAllowed - RIFS Mode is allowed to protect overlapping non-HT BSS
+ htProtection - Deprecated
+ dualCtsProtection - Dual CTS Protection enabled
+
+*******************************************************************************/
+typedef struct
+{
+ u8 greenfieldSupported;
+ u8 shortGi20MHz;
+ u8 rxStbc;
+ u8 rifsModeAllowed;
+ u8 htProtection;
+ u8 dualCtsProtection;
+} CsrWifiSmeApHtParams;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeApP2pOperatingChanEntry
+
+ DESCRIPTION
+
+ MEMBERS
+ operatingClass - Channel operating class
+ operatingChannelCount - Number of channels in this entry
+ operatingChannel - List of channels
+
+*******************************************************************************/
+typedef struct
+{
+ u8 operatingClass;
+ u8 operatingChannelCount;
+ u8 *operatingChannel;
+} CsrWifiSmeApP2pOperatingChanEntry;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeApP2pOperatingChanList
+
+ DESCRIPTION
+ This structure contains the lists of P2P operating channels
+
+ MEMBERS
+ country - Country
+ channelEntryListCount - Number of entries
+ channelEntryList - List of entries
+
+*******************************************************************************/
+typedef struct
+{
+ u8 country[3];
+ u8 channelEntryListCount;
+ CsrWifiSmeApP2pOperatingChanEntry *channelEntryList;
+} CsrWifiSmeApP2pOperatingChanList;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeApAuthPers
+
+ DESCRIPTION
+
+ MEMBERS
+ authSupport -
+ encryptionModeMask -
+ rsnCapabilities -
+ wapiCapabilities -
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiSmeApAuthSupportMask authSupport;
+ CsrWifiSmeEncryptionMask encryptionModeMask;
+ CsrWifiSmeApRsnCapabilitiesMask rsnCapabilities;
+ CsrWifiSmeApWapiCapabilitiesMask wapiCapabilities;
+} CsrWifiSmeApAuthPers;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeApBaSession
+
+ DESCRIPTION
+
+ MEMBERS
+ peerMacAddress - Indicates MAC address of the peer station
+ tid - Specifies the TID of the MSDUs for which this Block Ack has
+ been set up. Range: 0-15
+ direction - Specifies if the AP is the originator or the recipient of
+ the data stream that uses the Block Ack.
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiMacAddress peerMacAddress;
+ u8 tid;
+ CsrWifiSmeApDirection direction;
+} CsrWifiSmeApBaSession;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeApMacConfig
+
+ DESCRIPTION
+ Structure holding AP MAC configuration.
+
+ MEMBERS
+ phySupportedBitmap - Indicates supported physical layers
+ beaconInterval - Beacon interval in terms of TUs
+ dtimPeriod - DTIM period in terms of number of beacon intervals
+ maxListenInterval - Maximum allowed listen interval as number of beacon
+ intervals
+ supportedRatesCount - Number of supported rates. Range : 0 to 20
+ supportedRates - List of supportedRates. A rate is specied in the
+ units of 500kbps. An entry for a basic rate shall
+ have the MSB set to 1.
+ preamble - Preamble to be advertised in beacons and probe
+ responses
+ shortSlotTimeEnabled - TRUE indicates the AP shall use short slot time if
+ all the stations use short slot operation.
+ ctsProtectionType - CTS protection to be used
+ wmmEnabled - Indicate whether WMM is enabled or not. If set to
+ FALSE,the WMM parameters shall be ignored by the
+ receiver.
+ wmmApParams - WMM parameters to be used for local firmware queue
+ configuration. Array index corresponds to the ACI.
+ wmmApBcParams - WMM parameters to be advertised in beacon/probe
+ response. Array index corresponds to the ACI
+ accessType - Specifies whether the MAC addresses from the list
+ should be allowed or denied
+ macAddressListCount - Number of MAC addresses
+ macAddressList - List of MAC addresses
+ apHtParams - AP HT parameters. The stack shall use these
+ parameters only if phySupportedBitmap indicates
+ support for IEEE 802.11n
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiSmeApPhySupportMask phySupportedBitmap;
+ u16 beaconInterval;
+ u8 dtimPeriod;
+ u16 maxListenInterval;
+ u8 supportedRatesCount;
+ u8 supportedRates[20];
+ CsrWifiSmePreambleType preamble;
+ u8 shortSlotTimeEnabled;
+ CsrWifiSmeCtsProtectionType ctsProtectionType;
+ u8 wmmEnabled;
+ CsrWifiSmeWmmAcParams wmmApParams[4];
+ CsrWifiSmeWmmAcParams wmmApBcParams[4];
+ CsrWifiSmeApAccessType accessType;
+ u8 macAddressListCount;
+ CsrWifiMacAddress *macAddressList;
+ CsrWifiSmeApHtParams apHtParams;
+} CsrWifiSmeApMacConfig;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeApP2pGoConfig
+
+ DESCRIPTION
+
+ MEMBERS
+ groupCapability - Indicates the P2P group capabilities
+ operatingChanList - List of operating channels in the order of
+ decreasing priority. It may contain channel
+ entry/entries not supported by the wifi stack.
+ These shall be filtered out by the wifi stack
+ opPsEnabled - Indicates whether opportunistic power save can
+ be used.
+ Note: This parameter is ignored by the WiFi
+ stack for the current release
+ ctWindow - Define Client Traffic window to be used in terms
+ of number of TUs. Range: 0 to 127.
+ Note: This parameter is ignored by the WiFi
+ stack for the current release.
+ noaConfigMethod - Notice of Absence configuration method.
+ Note: This parameter is ignored by the WiFi
+ stack for the current release.
+ allowNoaWithNonP2pDevices - Indicates if NOA should be allowed if non P2P
+ devices are connected. If allowed the non P2P
+ devices may suffer in throughput.
+ Note: This parameter is ignored by the WiFi
+ stack for the current release.
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiSmeP2pGroupCapabilityMask groupCapability;
+ CsrWifiSmeApP2pOperatingChanList operatingChanList;
+ u8 opPsEnabled;
+ u8 ctWindow;
+ CsrWifiSmeP2pNoaConfigMethod noaConfigMethod;
+ u8 allowNoaWithNonP2pDevices;
+} CsrWifiSmeApP2pGoConfig;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeApCredentials
+
+ DESCRIPTION
+
+ MEMBERS
+ authType -
+ smeAuthType -
+ smeAuthTypeopenSystemEmpty -
+ smeAuthTypeauthwep -
+ smeAuthTypeauthPers -
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiSmeApAuthType authType;
+ union {
+ CsrWifiSmeEmpty openSystemEmpty;
+ CsrWifiSmeWepAuth authwep;
+ CsrWifiSmeApAuthPers authPers;
+ } smeAuthType;
+} CsrWifiSmeApCredentials;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeApSecConfig
+
+ DESCRIPTION
+
+ MEMBERS
+ apCredentials -
+ wpsEnabled -
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiSmeApCredentials apCredentials;
+ u8 wpsEnabled;
+} CsrWifiSmeApSecConfig;
+
+
+/* Downstream */
+#define CSR_WIFI_SME_AP_PRIM_DOWNSTREAM_LOWEST (0x0000)
+
+#define CSR_WIFI_SME_AP_BEACONING_START_REQ ((CsrWifiSmeApPrim) (0x0000 + CSR_WIFI_SME_AP_PRIM_DOWNSTREAM_LOWEST))
+#define CSR_WIFI_SME_AP_BEACONING_STOP_REQ ((CsrWifiSmeApPrim) (0x0001 + CSR_WIFI_SME_AP_PRIM_DOWNSTREAM_LOWEST))
+#define CSR_WIFI_SME_AP_WPS_REGISTRATION_STARTED_REQ ((CsrWifiSmeApPrim) (0x0002 + CSR_WIFI_SME_AP_PRIM_DOWNSTREAM_LOWEST))
+#define CSR_WIFI_SME_AP_WPS_REGISTRATION_FINISHED_REQ ((CsrWifiSmeApPrim) (0x0003 + CSR_WIFI_SME_AP_PRIM_DOWNSTREAM_LOWEST))
+#define CSR_WIFI_SME_AP_WMM_PARAM_UPDATE_REQ ((CsrWifiSmeApPrim) (0x0004 + CSR_WIFI_SME_AP_PRIM_DOWNSTREAM_LOWEST))
+#define CSR_WIFI_SME_AP_STA_DISCONNECT_REQ ((CsrWifiSmeApPrim) (0x0005 + CSR_WIFI_SME_AP_PRIM_DOWNSTREAM_LOWEST))
+#define CSR_WIFI_SME_AP_WPS_CONFIGURATION_REQ ((CsrWifiSmeApPrim) (0x0006 + CSR_WIFI_SME_AP_PRIM_DOWNSTREAM_LOWEST))
+#define CSR_WIFI_SME_AP_ACTIVE_BA_GET_REQ ((CsrWifiSmeApPrim) (0x0007 + CSR_WIFI_SME_AP_PRIM_DOWNSTREAM_LOWEST))
+#define CSR_WIFI_SME_AP_BA_DELETE_REQ ((CsrWifiSmeApPrim) (0x0008 + CSR_WIFI_SME_AP_PRIM_DOWNSTREAM_LOWEST))
+
+
+#define CSR_WIFI_SME_AP_PRIM_DOWNSTREAM_HIGHEST (0x0008 + CSR_WIFI_SME_AP_PRIM_DOWNSTREAM_LOWEST)
+
+/* Upstream */
+#define CSR_WIFI_SME_AP_PRIM_UPSTREAM_LOWEST (0x0000 + CSR_PRIM_UPSTREAM)
+
+#define CSR_WIFI_SME_AP_BEACONING_START_CFM ((CsrWifiSmeApPrim)(0x0000 + CSR_WIFI_SME_AP_PRIM_UPSTREAM_LOWEST))
+#define CSR_WIFI_SME_AP_BEACONING_STOP_CFM ((CsrWifiSmeApPrim)(0x0001 + CSR_WIFI_SME_AP_PRIM_UPSTREAM_LOWEST))
+#define CSR_WIFI_SME_AP_STA_NOTIFY_IND ((CsrWifiSmeApPrim)(0x0002 + CSR_WIFI_SME_AP_PRIM_UPSTREAM_LOWEST))
+#define CSR_WIFI_SME_AP_STA_CONNECT_START_IND ((CsrWifiSmeApPrim)(0x0003 + CSR_WIFI_SME_AP_PRIM_UPSTREAM_LOWEST))
+#define CSR_WIFI_SME_AP_WPS_REGISTRATION_STARTED_CFM ((CsrWifiSmeApPrim)(0x0004 + CSR_WIFI_SME_AP_PRIM_UPSTREAM_LOWEST))
+#define CSR_WIFI_SME_AP_WPS_REGISTRATION_FINISHED_CFM ((CsrWifiSmeApPrim)(0x0005 + CSR_WIFI_SME_AP_PRIM_UPSTREAM_LOWEST))
+#define CSR_WIFI_SME_AP_WMM_PARAM_UPDATE_CFM ((CsrWifiSmeApPrim)(0x0006 + CSR_WIFI_SME_AP_PRIM_UPSTREAM_LOWEST))
+#define CSR_WIFI_SME_AP_STA_DISCONNECT_CFM ((CsrWifiSmeApPrim)(0x0007 + CSR_WIFI_SME_AP_PRIM_UPSTREAM_LOWEST))
+#define CSR_WIFI_SME_AP_WPS_CONFIGURATION_CFM ((CsrWifiSmeApPrim)(0x0008 + CSR_WIFI_SME_AP_PRIM_UPSTREAM_LOWEST))
+#define CSR_WIFI_SME_AP_ERROR_IND ((CsrWifiSmeApPrim)(0x0009 + CSR_WIFI_SME_AP_PRIM_UPSTREAM_LOWEST))
+#define CSR_WIFI_SME_AP_ACTIVE_BA_GET_CFM ((CsrWifiSmeApPrim)(0x000A + CSR_WIFI_SME_AP_PRIM_UPSTREAM_LOWEST))
+#define CSR_WIFI_SME_AP_BA_DELETE_CFM ((CsrWifiSmeApPrim)(0x000B + CSR_WIFI_SME_AP_PRIM_UPSTREAM_LOWEST))
+
+#define CSR_WIFI_SME_AP_PRIM_UPSTREAM_HIGHEST (0x000B + CSR_WIFI_SME_AP_PRIM_UPSTREAM_LOWEST)
+
+#define CSR_WIFI_SME_AP_PRIM_DOWNSTREAM_COUNT (CSR_WIFI_SME_AP_PRIM_DOWNSTREAM_HIGHEST + 1 - CSR_WIFI_SME_AP_PRIM_DOWNSTREAM_LOWEST)
+#define CSR_WIFI_SME_AP_PRIM_UPSTREAM_COUNT (CSR_WIFI_SME_AP_PRIM_UPSTREAM_HIGHEST + 1 - CSR_WIFI_SME_AP_PRIM_UPSTREAM_LOWEST)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeApBeaconingStartReq
+
+ DESCRIPTION
+ This primitive requests the SME to start AP or GO functionality
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ interfaceTag -
+ initialPresence - Set to 0, if Not in a group fomration phase, set to 1 ,
+ during group formation phase
+ apType - apType : Legacy AP or P2PGO
+ cloakSsid - cloakSsid flag.
+ ssid - ssid.
+ ifIndex - Radio Interface
+ channel - channel.
+ maxConnections - Maximum Stations + P2PClients allowed
+ apCredentials - AP security credeitals used to advertise in beacon /probe
+ response
+ smeApConfig - AP configuration
+ p2pGoParam - P2P specific GO parameters. Ignored if it is a leagacy AP
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ u16 interfaceTag;
+ u8 initialPresence;
+ CsrWifiSmeApType apType;
+ u8 cloakSsid;
+ CsrWifiSsid ssid;
+ CsrWifiSmeRadioIF ifIndex;
+ u8 channel;
+ u8 maxConnections;
+ CsrWifiSmeApSecConfig apCredentials;
+ CsrWifiSmeApMacConfig smeApConfig;
+ CsrWifiSmeApP2pGoConfig p2pGoParam;
+} CsrWifiSmeApBeaconingStartReq;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeApBeaconingStopReq
+
+ DESCRIPTION
+ This primitive requests the SME to STOP AP or P2PGO operation
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ interfaceTag -
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ u16 interfaceTag;
+} CsrWifiSmeApBeaconingStopReq;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeApWpsRegistrationStartedReq
+
+ DESCRIPTION
+ This primitive tells SME that WPS registration procedure has started
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ interfaceTag -
+ SelectedDevicePasswordId -
+ SelectedconfigMethod -
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ u16 interfaceTag;
+ CsrWifiSmeWpsDpid SelectedDevicePasswordId;
+ CsrWifiSmeWpsConfigType SelectedconfigMethod;
+} CsrWifiSmeApWpsRegistrationStartedReq;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeApWpsRegistrationFinishedReq
+
+ DESCRIPTION
+ This primitive tells SME that WPS registration procedure has finished
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ interfaceTag -
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ u16 interfaceTag;
+} CsrWifiSmeApWpsRegistrationFinishedReq;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeApWmmParamUpdateReq
+
+ DESCRIPTION
+ Application uses this primitive to update the WMM parameters on the fly
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ interfaceTag -
+ wmmApParams - WMM parameters to be used for local firmware queue
+ configuration
+ wmmApBcParams - WMM parameters to be advertised in beacon/probe response
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ u16 interfaceTag;
+ CsrWifiSmeWmmAcParams wmmApParams[4];
+ CsrWifiSmeWmmAcParams wmmApBcParams[4];
+} CsrWifiSmeApWmmParamUpdateReq;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeApStaDisconnectReq
+
+ DESCRIPTION
+ This primitive tells SME to deauth ot disassociate a particular station
+ within BSS
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ interfaceTag -
+ deauthReason -
+ disassocReason -
+ peerMacaddress -
+ keepBlocking - If TRUE, the station is blocked. If FALSE and the station
+ is connected, disconnect the station. If FALSE and the
+ station is not connected, no action is taken.
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ u16 interfaceTag;
+ CsrWifiSmeIEEE80211Reason deauthReason;
+ CsrWifiSmeIEEE80211Reason disassocReason;
+ CsrWifiMacAddress peerMacaddress;
+ u8 keepBlocking;
+} CsrWifiSmeApStaDisconnectReq;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeApWpsConfigurationReq
+
+ DESCRIPTION
+ This primitive passes the WPS information for the device to SME. This may
+ be accepted only if no interface is active.
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ wpsConfig - WPS config.
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ CsrWifiSmeWpsConfig wpsConfig;
+} CsrWifiSmeApWpsConfigurationReq;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeApActiveBaGetReq
+
+ DESCRIPTION
+ This primitive used to retrieve information related to the active block
+ ack sessions
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ interfaceTag -
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ u16 interfaceTag;
+} CsrWifiSmeApActiveBaGetReq;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeApBaDeleteReq
+
+ DESCRIPTION
+ This primitive is used to delete an active block ack session
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ interfaceTag -
+ reason -
+ baSession - BA session to be deleted
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ u16 interfaceTag;
+ CsrWifiSmeIEEE80211Reason reason;
+ CsrWifiSmeApBaSession baSession;
+} CsrWifiSmeApBaDeleteReq;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeApBeaconingStartCfm
+
+ DESCRIPTION
+ This primitive confirms the completion of the request along with the
+ status
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ interfaceTag -
+ status -
+ secIeLength -
+ secIe -
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ u16 interfaceTag;
+ CsrResult status;
+ u16 secIeLength;
+ u8 *secIe;
+} CsrWifiSmeApBeaconingStartCfm;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeApBeaconingStopCfm
+
+ DESCRIPTION
+ This primitive confirms AP or P2PGO operation is terminated
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ interfaceTag -
+ status -
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ u16 interfaceTag;
+ CsrResult status;
+} CsrWifiSmeApBeaconingStopCfm;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeApStaNotifyInd
+
+ DESCRIPTION
+ This primitive indicates that a station has joined or a previously joined
+ station has left the BSS/group
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ interfaceTag -
+ mediaStatus -
+ peerMacAddress -
+ peerDeviceAddress -
+ disassocReason -
+ deauthReason -
+ WpsRegistration -
+ secIeLength -
+ secIe -
+ groupKeyId -
+ seqNumber -
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ u16 interfaceTag;
+ CsrWifiSmeMediaStatus mediaStatus;
+ CsrWifiMacAddress peerMacAddress;
+ CsrWifiMacAddress peerDeviceAddress;
+ CsrWifiSmeIEEE80211Reason disassocReason;
+ CsrWifiSmeIEEE80211Reason deauthReason;
+ CsrWifiSmeWpsRegistration WpsRegistration;
+ u8 secIeLength;
+ u8 *secIe;
+ u8 groupKeyId;
+ u16 seqNumber[8];
+} CsrWifiSmeApStaNotifyInd;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeApStaConnectStartInd
+
+ DESCRIPTION
+ This primitive indicates that a stations request to join the group/BSS is
+ accepted
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ interfaceTag -
+ peerMacAddress -
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ u16 interfaceTag;
+ CsrWifiMacAddress peerMacAddress;
+} CsrWifiSmeApStaConnectStartInd;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeApWpsRegistrationStartedCfm
+
+ DESCRIPTION
+ A confirm for UNIFI_MGT_AP_WPS_REGISTRATION_STARTED.request
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ interfaceTag -
+ status -
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ u16 interfaceTag;
+ CsrResult status;
+} CsrWifiSmeApWpsRegistrationStartedCfm;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeApWpsRegistrationFinishedCfm
+
+ DESCRIPTION
+ A confirm for UNIFI_MGT_AP_WPS_REGISTRATION_FINISHED.request
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ interfaceTag -
+ status -
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ u16 interfaceTag;
+ CsrResult status;
+} CsrWifiSmeApWpsRegistrationFinishedCfm;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeApWmmParamUpdateCfm
+
+ DESCRIPTION
+ A confirm for CSR_WIFI_SME_AP_WMM_PARAM_UPDATE.request
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ interfaceTag -
+ status -
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ u16 interfaceTag;
+ CsrResult status;
+} CsrWifiSmeApWmmParamUpdateCfm;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeApStaDisconnectCfm
+
+ DESCRIPTION
+ This primitive confirms the station is disconnected
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ interfaceTag -
+ status -
+ peerMacaddress -
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ u16 interfaceTag;
+ CsrResult status;
+ CsrWifiMacAddress peerMacaddress;
+} CsrWifiSmeApStaDisconnectCfm;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeApWpsConfigurationCfm
+
+ DESCRIPTION
+ Confirm.
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ status - Status of the request.
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ CsrResult status;
+} CsrWifiSmeApWpsConfigurationCfm;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeApErrorInd
+
+ DESCRIPTION
+ This primitve is sent by SME to indicate some error in AP operationi
+ after AP operations were started successfully and continuing the AP
+ operation may lead to undesired behaviour. It is the responsibility of
+ the upper layers to stop AP operation if needed
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ interfaceTag - Range 0-1
+ apType -
+ status - Contains the error status
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ u16 interfaceTag;
+ CsrWifiSmeApType apType;
+ CsrResult status;
+} CsrWifiSmeApErrorInd;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeApActiveBaGetCfm
+
+ DESCRIPTION
+ This primitive carries the information related to the active ba sessions
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ interfaceTag -
+ status - Reports the result of the request
+ activeBaCount - Number of active block ack session
+ activeBaSessions - Points to a buffer containing an array of
+ CsrWifiSmeApBaSession structures.
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ u16 interfaceTag;
+ CsrResult status;
+ u16 activeBaCount;
+ CsrWifiSmeApBaSession *activeBaSessions;
+} CsrWifiSmeApActiveBaGetCfm;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeApBaDeleteCfm
+
+ DESCRIPTION
+ This primitive confirms the BA is deleted
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ interfaceTag -
+ status - Reports the result of the request
+ baSession - deleted BA session
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ u16 interfaceTag;
+ CsrResult status;
+ CsrWifiSmeApBaSession baSession;
+} CsrWifiSmeApBaDeleteCfm;
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* CSR_WIFI_SME_AP_PRIM_H__ */
+
diff --git a/drivers/staging/csr/csr_wifi_sme_converter_init.c b/drivers/staging/csr/csr_wifi_sme_converter_init.c
new file mode 100644
index 000000000000..31835f06bbc2
--- /dev/null
+++ b/drivers/staging/csr/csr_wifi_sme_converter_init.c
@@ -0,0 +1,201 @@
+/*****************************************************************************
+
+ (c) Cambridge Silicon Radio Limited 2012
+ All rights reserved and confidential information of CSR
+
+ Refer to LICENSE.txt included with this source for details
+ on the license terms.
+
+*****************************************************************************/
+
+/* Note: this is an auto-generated file. */
+
+#include "csr_msgconv.h"
+#include "csr_macro.h"
+
+
+#ifdef CSR_LOG_ENABLE
+#include "csr_log.h"
+#endif
+
+#ifndef EXCLUDE_CSR_WIFI_SME_MODULE
+#include "csr_wifi_sme_serialize.h"
+#include "csr_wifi_sme_prim.h"
+
+static CsrMsgConvMsgEntry csrwifisme_conv_lut[] = {
+ { CSR_WIFI_SME_ACTIVATE_REQ, CsrWifiSmeActivateReqSizeof, CsrWifiSmeActivateReqSer, CsrWifiSmeActivateReqDes, CsrWifiSmeActivateReqSerFree },
+ { CSR_WIFI_SME_ADHOC_CONFIG_GET_REQ, CsrWifiSmeAdhocConfigGetReqSizeof, CsrWifiSmeAdhocConfigGetReqSer, CsrWifiSmeAdhocConfigGetReqDes, CsrWifiSmeAdhocConfigGetReqSerFree },
+ { CSR_WIFI_SME_ADHOC_CONFIG_SET_REQ, CsrWifiSmeAdhocConfigSetReqSizeof, CsrWifiSmeAdhocConfigSetReqSer, CsrWifiSmeAdhocConfigSetReqDes, CsrWifiSmeAdhocConfigSetReqSerFree },
+ { CSR_WIFI_SME_BLACKLIST_REQ, CsrWifiSmeBlacklistReqSizeof, CsrWifiSmeBlacklistReqSer, CsrWifiSmeBlacklistReqDes, CsrWifiSmeBlacklistReqSerFree },
+ { CSR_WIFI_SME_CALIBRATION_DATA_GET_REQ, CsrWifiSmeCalibrationDataGetReqSizeof, CsrWifiSmeCalibrationDataGetReqSer, CsrWifiSmeCalibrationDataGetReqDes, CsrWifiSmeCalibrationDataGetReqSerFree },
+ { CSR_WIFI_SME_CALIBRATION_DATA_SET_REQ, CsrWifiSmeCalibrationDataSetReqSizeof, CsrWifiSmeCalibrationDataSetReqSer, CsrWifiSmeCalibrationDataSetReqDes, CsrWifiSmeCalibrationDataSetReqSerFree },
+ { CSR_WIFI_SME_CCX_CONFIG_GET_REQ, CsrWifiSmeCcxConfigGetReqSizeof, CsrWifiSmeCcxConfigGetReqSer, CsrWifiSmeCcxConfigGetReqDes, CsrWifiSmeCcxConfigGetReqSerFree },
+ { CSR_WIFI_SME_CCX_CONFIG_SET_REQ, CsrWifiSmeCcxConfigSetReqSizeof, CsrWifiSmeCcxConfigSetReqSer, CsrWifiSmeCcxConfigSetReqDes, CsrWifiSmeCcxConfigSetReqSerFree },
+ { CSR_WIFI_SME_COEX_CONFIG_GET_REQ, CsrWifiSmeCoexConfigGetReqSizeof, CsrWifiSmeCoexConfigGetReqSer, CsrWifiSmeCoexConfigGetReqDes, CsrWifiSmeCoexConfigGetReqSerFree },
+ { CSR_WIFI_SME_COEX_CONFIG_SET_REQ, CsrWifiSmeCoexConfigSetReqSizeof, CsrWifiSmeCoexConfigSetReqSer, CsrWifiSmeCoexConfigSetReqDes, CsrWifiSmeCoexConfigSetReqSerFree },
+ { CSR_WIFI_SME_COEX_INFO_GET_REQ, CsrWifiSmeCoexInfoGetReqSizeof, CsrWifiSmeCoexInfoGetReqSer, CsrWifiSmeCoexInfoGetReqDes, CsrWifiSmeCoexInfoGetReqSerFree },
+ { CSR_WIFI_SME_CONNECT_REQ, CsrWifiSmeConnectReqSizeof, CsrWifiSmeConnectReqSer, CsrWifiSmeConnectReqDes, CsrWifiSmeConnectReqSerFree },
+ { CSR_WIFI_SME_CONNECTION_CONFIG_GET_REQ, CsrWifiSmeConnectionConfigGetReqSizeof, CsrWifiSmeConnectionConfigGetReqSer, CsrWifiSmeConnectionConfigGetReqDes, CsrWifiSmeConnectionConfigGetReqSerFree },
+ { CSR_WIFI_SME_CONNECTION_INFO_GET_REQ, CsrWifiSmeConnectionInfoGetReqSizeof, CsrWifiSmeConnectionInfoGetReqSer, CsrWifiSmeConnectionInfoGetReqDes, CsrWifiSmeConnectionInfoGetReqSerFree },
+ { CSR_WIFI_SME_CONNECTION_STATS_GET_REQ, CsrWifiSmeConnectionStatsGetReqSizeof, CsrWifiSmeConnectionStatsGetReqSer, CsrWifiSmeConnectionStatsGetReqDes, CsrWifiSmeConnectionStatsGetReqSerFree },
+ { CSR_WIFI_SME_DEACTIVATE_REQ, CsrWifiSmeDeactivateReqSizeof, CsrWifiSmeDeactivateReqSer, CsrWifiSmeDeactivateReqDes, CsrWifiSmeDeactivateReqSerFree },
+ { CSR_WIFI_SME_DISCONNECT_REQ, CsrWifiSmeDisconnectReqSizeof, CsrWifiSmeDisconnectReqSer, CsrWifiSmeDisconnectReqDes, CsrWifiSmeDisconnectReqSerFree },
+ { CSR_WIFI_SME_EVENT_MASK_SET_REQ, CsrWifiSmeEventMaskSetReqSizeof, CsrWifiSmeEventMaskSetReqSer, CsrWifiSmeEventMaskSetReqDes, CsrWifiSmeEventMaskSetReqSerFree },
+ { CSR_WIFI_SME_HOST_CONFIG_GET_REQ, CsrWifiSmeHostConfigGetReqSizeof, CsrWifiSmeHostConfigGetReqSer, CsrWifiSmeHostConfigGetReqDes, CsrWifiSmeHostConfigGetReqSerFree },
+ { CSR_WIFI_SME_HOST_CONFIG_SET_REQ, CsrWifiSmeHostConfigSetReqSizeof, CsrWifiSmeHostConfigSetReqSer, CsrWifiSmeHostConfigSetReqDes, CsrWifiSmeHostConfigSetReqSerFree },
+ { CSR_WIFI_SME_KEY_REQ, CsrWifiSmeKeyReqSizeof, CsrWifiSmeKeyReqSer, CsrWifiSmeKeyReqDes, CsrWifiSmeKeyReqSerFree },
+ { CSR_WIFI_SME_LINK_QUALITY_GET_REQ, CsrWifiSmeLinkQualityGetReqSizeof, CsrWifiSmeLinkQualityGetReqSer, CsrWifiSmeLinkQualityGetReqDes, CsrWifiSmeLinkQualityGetReqSerFree },
+ { CSR_WIFI_SME_MIB_CONFIG_GET_REQ, CsrWifiSmeMibConfigGetReqSizeof, CsrWifiSmeMibConfigGetReqSer, CsrWifiSmeMibConfigGetReqDes, CsrWifiSmeMibConfigGetReqSerFree },
+ { CSR_WIFI_SME_MIB_CONFIG_SET_REQ, CsrWifiSmeMibConfigSetReqSizeof, CsrWifiSmeMibConfigSetReqSer, CsrWifiSmeMibConfigSetReqDes, CsrWifiSmeMibConfigSetReqSerFree },
+ { CSR_WIFI_SME_MIB_GET_NEXT_REQ, CsrWifiSmeMibGetNextReqSizeof, CsrWifiSmeMibGetNextReqSer, CsrWifiSmeMibGetNextReqDes, CsrWifiSmeMibGetNextReqSerFree },
+ { CSR_WIFI_SME_MIB_GET_REQ, CsrWifiSmeMibGetReqSizeof, CsrWifiSmeMibGetReqSer, CsrWifiSmeMibGetReqDes, CsrWifiSmeMibGetReqSerFree },
+ { CSR_WIFI_SME_MIB_SET_REQ, CsrWifiSmeMibSetReqSizeof, CsrWifiSmeMibSetReqSer, CsrWifiSmeMibSetReqDes, CsrWifiSmeMibSetReqSerFree },
+ { CSR_WIFI_SME_MULTICAST_ADDRESS_REQ, CsrWifiSmeMulticastAddressReqSizeof, CsrWifiSmeMulticastAddressReqSer, CsrWifiSmeMulticastAddressReqDes, CsrWifiSmeMulticastAddressReqSerFree },
+ { CSR_WIFI_SME_PACKET_FILTER_SET_REQ, CsrWifiSmePacketFilterSetReqSizeof, CsrWifiSmePacketFilterSetReqSer, CsrWifiSmePacketFilterSetReqDes, CsrWifiSmePacketFilterSetReqSerFree },
+ { CSR_WIFI_SME_PERMANENT_MAC_ADDRESS_GET_REQ, CsrWifiSmePermanentMacAddressGetReqSizeof, CsrWifiSmePermanentMacAddressGetReqSer, CsrWifiSmePermanentMacAddressGetReqDes, CsrWifiSmePermanentMacAddressGetReqSerFree },
+ { CSR_WIFI_SME_PMKID_REQ, CsrWifiSmePmkidReqSizeof, CsrWifiSmePmkidReqSer, CsrWifiSmePmkidReqDes, CsrWifiSmePmkidReqSerFree },
+ { CSR_WIFI_SME_POWER_CONFIG_GET_REQ, CsrWifiSmePowerConfigGetReqSizeof, CsrWifiSmePowerConfigGetReqSer, CsrWifiSmePowerConfigGetReqDes, CsrWifiSmePowerConfigGetReqSerFree },
+ { CSR_WIFI_SME_POWER_CONFIG_SET_REQ, CsrWifiSmePowerConfigSetReqSizeof, CsrWifiSmePowerConfigSetReqSer, CsrWifiSmePowerConfigSetReqDes, CsrWifiSmePowerConfigSetReqSerFree },
+ { CSR_WIFI_SME_REGULATORY_DOMAIN_INFO_GET_REQ, CsrWifiSmeRegulatoryDomainInfoGetReqSizeof, CsrWifiSmeRegulatoryDomainInfoGetReqSer, CsrWifiSmeRegulatoryDomainInfoGetReqDes, CsrWifiSmeRegulatoryDomainInfoGetReqSerFree },
+ { CSR_WIFI_SME_ROAMING_CONFIG_GET_REQ, CsrWifiSmeRoamingConfigGetReqSizeof, CsrWifiSmeRoamingConfigGetReqSer, CsrWifiSmeRoamingConfigGetReqDes, CsrWifiSmeRoamingConfigGetReqSerFree },
+ { CSR_WIFI_SME_ROAMING_CONFIG_SET_REQ, CsrWifiSmeRoamingConfigSetReqSizeof, CsrWifiSmeRoamingConfigSetReqSer, CsrWifiSmeRoamingConfigSetReqDes, CsrWifiSmeRoamingConfigSetReqSerFree },
+ { CSR_WIFI_SME_SCAN_CONFIG_GET_REQ, CsrWifiSmeScanConfigGetReqSizeof, CsrWifiSmeScanConfigGetReqSer, CsrWifiSmeScanConfigGetReqDes, CsrWifiSmeScanConfigGetReqSerFree },
+ { CSR_WIFI_SME_SCAN_CONFIG_SET_REQ, CsrWifiSmeScanConfigSetReqSizeof, CsrWifiSmeScanConfigSetReqSer, CsrWifiSmeScanConfigSetReqDes, CsrWifiSmeScanConfigSetReqSerFree },
+ { CSR_WIFI_SME_SCAN_FULL_REQ, CsrWifiSmeScanFullReqSizeof, CsrWifiSmeScanFullReqSer, CsrWifiSmeScanFullReqDes, CsrWifiSmeScanFullReqSerFree },
+ { CSR_WIFI_SME_SCAN_RESULTS_FLUSH_REQ, CsrWifiSmeScanResultsFlushReqSizeof, CsrWifiSmeScanResultsFlushReqSer, CsrWifiSmeScanResultsFlushReqDes, CsrWifiSmeScanResultsFlushReqSerFree },
+ { CSR_WIFI_SME_SCAN_RESULTS_GET_REQ, CsrWifiSmeScanResultsGetReqSizeof, CsrWifiSmeScanResultsGetReqSer, CsrWifiSmeScanResultsGetReqDes, CsrWifiSmeScanResultsGetReqSerFree },
+ { CSR_WIFI_SME_SME_STA_CONFIG_GET_REQ, CsrWifiSmeSmeStaConfigGetReqSizeof, CsrWifiSmeSmeStaConfigGetReqSer, CsrWifiSmeSmeStaConfigGetReqDes, CsrWifiSmeSmeStaConfigGetReqSerFree },
+ { CSR_WIFI_SME_SME_STA_CONFIG_SET_REQ, CsrWifiSmeSmeStaConfigSetReqSizeof, CsrWifiSmeSmeStaConfigSetReqSer, CsrWifiSmeSmeStaConfigSetReqDes, CsrWifiSmeSmeStaConfigSetReqSerFree },
+ { CSR_WIFI_SME_STATION_MAC_ADDRESS_GET_REQ, CsrWifiSmeStationMacAddressGetReqSizeof, CsrWifiSmeStationMacAddressGetReqSer, CsrWifiSmeStationMacAddressGetReqDes, CsrWifiSmeStationMacAddressGetReqSerFree },
+ { CSR_WIFI_SME_TSPEC_REQ, CsrWifiSmeTspecReqSizeof, CsrWifiSmeTspecReqSer, CsrWifiSmeTspecReqDes, CsrWifiSmeTspecReqSerFree },
+ { CSR_WIFI_SME_VERSIONS_GET_REQ, CsrWifiSmeVersionsGetReqSizeof, CsrWifiSmeVersionsGetReqSer, CsrWifiSmeVersionsGetReqDes, CsrWifiSmeVersionsGetReqSerFree },
+ { CSR_WIFI_SME_WIFI_FLIGHTMODE_REQ, CsrWifiSmeWifiFlightmodeReqSizeof, CsrWifiSmeWifiFlightmodeReqSer, CsrWifiSmeWifiFlightmodeReqDes, CsrWifiSmeWifiFlightmodeReqSerFree },
+ { CSR_WIFI_SME_WIFI_OFF_REQ, CsrWifiSmeWifiOffReqSizeof, CsrWifiSmeWifiOffReqSer, CsrWifiSmeWifiOffReqDes, CsrWifiSmeWifiOffReqSerFree },
+ { CSR_WIFI_SME_WIFI_ON_REQ, CsrWifiSmeWifiOnReqSizeof, CsrWifiSmeWifiOnReqSer, CsrWifiSmeWifiOnReqDes, CsrWifiSmeWifiOnReqSerFree },
+ { CSR_WIFI_SME_CLOAKED_SSIDS_SET_REQ, CsrWifiSmeCloakedSsidsSetReqSizeof, CsrWifiSmeCloakedSsidsSetReqSer, CsrWifiSmeCloakedSsidsSetReqDes, CsrWifiSmeCloakedSsidsSetReqSerFree },
+ { CSR_WIFI_SME_CLOAKED_SSIDS_GET_REQ, CsrWifiSmeCloakedSsidsGetReqSizeof, CsrWifiSmeCloakedSsidsGetReqSer, CsrWifiSmeCloakedSsidsGetReqDes, CsrWifiSmeCloakedSsidsGetReqSerFree },
+ { CSR_WIFI_SME_SME_COMMON_CONFIG_GET_REQ, CsrWifiSmeSmeCommonConfigGetReqSizeof, CsrWifiSmeSmeCommonConfigGetReqSer, CsrWifiSmeSmeCommonConfigGetReqDes, CsrWifiSmeSmeCommonConfigGetReqSerFree },
+ { CSR_WIFI_SME_SME_COMMON_CONFIG_SET_REQ, CsrWifiSmeSmeCommonConfigSetReqSizeof, CsrWifiSmeSmeCommonConfigSetReqSer, CsrWifiSmeSmeCommonConfigSetReqDes, CsrWifiSmeSmeCommonConfigSetReqSerFree },
+ { CSR_WIFI_SME_INTERFACE_CAPABILITY_GET_REQ, CsrWifiSmeInterfaceCapabilityGetReqSizeof, CsrWifiSmeInterfaceCapabilityGetReqSer, CsrWifiSmeInterfaceCapabilityGetReqDes, CsrWifiSmeInterfaceCapabilityGetReqSerFree },
+ { CSR_WIFI_SME_WPS_CONFIGURATION_REQ, CsrWifiSmeWpsConfigurationReqSizeof, CsrWifiSmeWpsConfigurationReqSer, CsrWifiSmeWpsConfigurationReqDes, CsrWifiSmeWpsConfigurationReqSerFree },
+ { CSR_WIFI_SME_SET_REQ, CsrWifiSmeSetReqSizeof, CsrWifiSmeSetReqSer, CsrWifiSmeSetReqDes, CsrWifiSmeSetReqSerFree },
+ { CSR_WIFI_SME_ACTIVATE_CFM, CsrWifiSmeActivateCfmSizeof, CsrWifiSmeActivateCfmSer, CsrWifiSmeActivateCfmDes, CsrWifiSmeActivateCfmSerFree },
+ { CSR_WIFI_SME_ADHOC_CONFIG_GET_CFM, CsrWifiSmeAdhocConfigGetCfmSizeof, CsrWifiSmeAdhocConfigGetCfmSer, CsrWifiSmeAdhocConfigGetCfmDes, CsrWifiSmeAdhocConfigGetCfmSerFree },
+ { CSR_WIFI_SME_ADHOC_CONFIG_SET_CFM, CsrWifiSmeAdhocConfigSetCfmSizeof, CsrWifiSmeAdhocConfigSetCfmSer, CsrWifiSmeAdhocConfigSetCfmDes, CsrWifiSmeAdhocConfigSetCfmSerFree },
+ { CSR_WIFI_SME_ASSOCIATION_COMPLETE_IND, CsrWifiSmeAssociationCompleteIndSizeof, CsrWifiSmeAssociationCompleteIndSer, CsrWifiSmeAssociationCompleteIndDes, CsrWifiSmeAssociationCompleteIndSerFree },
+ { CSR_WIFI_SME_ASSOCIATION_START_IND, CsrWifiSmeAssociationStartIndSizeof, CsrWifiSmeAssociationStartIndSer, CsrWifiSmeAssociationStartIndDes, CsrWifiSmeAssociationStartIndSerFree },
+ { CSR_WIFI_SME_BLACKLIST_CFM, CsrWifiSmeBlacklistCfmSizeof, CsrWifiSmeBlacklistCfmSer, CsrWifiSmeBlacklistCfmDes, CsrWifiSmeBlacklistCfmSerFree },
+ { CSR_WIFI_SME_CALIBRATION_DATA_GET_CFM, CsrWifiSmeCalibrationDataGetCfmSizeof, CsrWifiSmeCalibrationDataGetCfmSer, CsrWifiSmeCalibrationDataGetCfmDes, CsrWifiSmeCalibrationDataGetCfmSerFree },
+ { CSR_WIFI_SME_CALIBRATION_DATA_SET_CFM, CsrWifiSmeCalibrationDataSetCfmSizeof, CsrWifiSmeCalibrationDataSetCfmSer, CsrWifiSmeCalibrationDataSetCfmDes, CsrWifiSmeCalibrationDataSetCfmSerFree },
+ { CSR_WIFI_SME_CCX_CONFIG_GET_CFM, CsrWifiSmeCcxConfigGetCfmSizeof, CsrWifiSmeCcxConfigGetCfmSer, CsrWifiSmeCcxConfigGetCfmDes, CsrWifiSmeCcxConfigGetCfmSerFree },
+ { CSR_WIFI_SME_CCX_CONFIG_SET_CFM, CsrWifiSmeCcxConfigSetCfmSizeof, CsrWifiSmeCcxConfigSetCfmSer, CsrWifiSmeCcxConfigSetCfmDes, CsrWifiSmeCcxConfigSetCfmSerFree },
+ { CSR_WIFI_SME_COEX_CONFIG_GET_CFM, CsrWifiSmeCoexConfigGetCfmSizeof, CsrWifiSmeCoexConfigGetCfmSer, CsrWifiSmeCoexConfigGetCfmDes, CsrWifiSmeCoexConfigGetCfmSerFree },
+ { CSR_WIFI_SME_COEX_CONFIG_SET_CFM, CsrWifiSmeCoexConfigSetCfmSizeof, CsrWifiSmeCoexConfigSetCfmSer, CsrWifiSmeCoexConfigSetCfmDes, CsrWifiSmeCoexConfigSetCfmSerFree },
+ { CSR_WIFI_SME_COEX_INFO_GET_CFM, CsrWifiSmeCoexInfoGetCfmSizeof, CsrWifiSmeCoexInfoGetCfmSer, CsrWifiSmeCoexInfoGetCfmDes, CsrWifiSmeCoexInfoGetCfmSerFree },
+ { CSR_WIFI_SME_CONNECT_CFM, CsrWifiSmeConnectCfmSizeof, CsrWifiSmeConnectCfmSer, CsrWifiSmeConnectCfmDes, CsrWifiSmeConnectCfmSerFree },
+ { CSR_WIFI_SME_CONNECTION_CONFIG_GET_CFM, CsrWifiSmeConnectionConfigGetCfmSizeof, CsrWifiSmeConnectionConfigGetCfmSer, CsrWifiSmeConnectionConfigGetCfmDes, CsrWifiSmeConnectionConfigGetCfmSerFree },
+ { CSR_WIFI_SME_CONNECTION_INFO_GET_CFM, CsrWifiSmeConnectionInfoGetCfmSizeof, CsrWifiSmeConnectionInfoGetCfmSer, CsrWifiSmeConnectionInfoGetCfmDes, CsrWifiSmeConnectionInfoGetCfmSerFree },
+ { CSR_WIFI_SME_CONNECTION_QUALITY_IND, CsrWifiSmeConnectionQualityIndSizeof, CsrWifiSmeConnectionQualityIndSer, CsrWifiSmeConnectionQualityIndDes, CsrWifiSmeConnectionQualityIndSerFree },
+ { CSR_WIFI_SME_CONNECTION_STATS_GET_CFM, CsrWifiSmeConnectionStatsGetCfmSizeof, CsrWifiSmeConnectionStatsGetCfmSer, CsrWifiSmeConnectionStatsGetCfmDes, CsrWifiSmeConnectionStatsGetCfmSerFree },
+ { CSR_WIFI_SME_DEACTIVATE_CFM, CsrWifiSmeDeactivateCfmSizeof, CsrWifiSmeDeactivateCfmSer, CsrWifiSmeDeactivateCfmDes, CsrWifiSmeDeactivateCfmSerFree },
+ { CSR_WIFI_SME_DISCONNECT_CFM, CsrWifiSmeDisconnectCfmSizeof, CsrWifiSmeDisconnectCfmSer, CsrWifiSmeDisconnectCfmDes, CsrWifiSmeDisconnectCfmSerFree },
+ { CSR_WIFI_SME_EVENT_MASK_SET_CFM, CsrWifiSmeEventMaskSetCfmSizeof, CsrWifiSmeEventMaskSetCfmSer, CsrWifiSmeEventMaskSetCfmDes, CsrWifiSmeEventMaskSetCfmSerFree },
+ { CSR_WIFI_SME_HOST_CONFIG_GET_CFM, CsrWifiSmeHostConfigGetCfmSizeof, CsrWifiSmeHostConfigGetCfmSer, CsrWifiSmeHostConfigGetCfmDes, CsrWifiSmeHostConfigGetCfmSerFree },
+ { CSR_WIFI_SME_HOST_CONFIG_SET_CFM, CsrWifiSmeHostConfigSetCfmSizeof, CsrWifiSmeHostConfigSetCfmSer, CsrWifiSmeHostConfigSetCfmDes, CsrWifiSmeHostConfigSetCfmSerFree },
+ { CSR_WIFI_SME_IBSS_STATION_IND, CsrWifiSmeIbssStationIndSizeof, CsrWifiSmeIbssStationIndSer, CsrWifiSmeIbssStationIndDes, CsrWifiSmeIbssStationIndSerFree },
+ { CSR_WIFI_SME_KEY_CFM, CsrWifiSmeKeyCfmSizeof, CsrWifiSmeKeyCfmSer, CsrWifiSmeKeyCfmDes, CsrWifiSmeKeyCfmSerFree },
+ { CSR_WIFI_SME_LINK_QUALITY_GET_CFM, CsrWifiSmeLinkQualityGetCfmSizeof, CsrWifiSmeLinkQualityGetCfmSer, CsrWifiSmeLinkQualityGetCfmDes, CsrWifiSmeLinkQualityGetCfmSerFree },
+ { CSR_WIFI_SME_MEDIA_STATUS_IND, CsrWifiSmeMediaStatusIndSizeof, CsrWifiSmeMediaStatusIndSer, CsrWifiSmeMediaStatusIndDes, CsrWifiSmeMediaStatusIndSerFree },
+ { CSR_WIFI_SME_MIB_CONFIG_GET_CFM, CsrWifiSmeMibConfigGetCfmSizeof, CsrWifiSmeMibConfigGetCfmSer, CsrWifiSmeMibConfigGetCfmDes, CsrWifiSmeMibConfigGetCfmSerFree },
+ { CSR_WIFI_SME_MIB_CONFIG_SET_CFM, CsrWifiSmeMibConfigSetCfmSizeof, CsrWifiSmeMibConfigSetCfmSer, CsrWifiSmeMibConfigSetCfmDes, CsrWifiSmeMibConfigSetCfmSerFree },
+ { CSR_WIFI_SME_MIB_GET_CFM, CsrWifiSmeMibGetCfmSizeof, CsrWifiSmeMibGetCfmSer, CsrWifiSmeMibGetCfmDes, CsrWifiSmeMibGetCfmSerFree },
+ { CSR_WIFI_SME_MIB_GET_NEXT_CFM, CsrWifiSmeMibGetNextCfmSizeof, CsrWifiSmeMibGetNextCfmSer, CsrWifiSmeMibGetNextCfmDes, CsrWifiSmeMibGetNextCfmSerFree },
+ { CSR_WIFI_SME_MIB_SET_CFM, CsrWifiSmeMibSetCfmSizeof, CsrWifiSmeMibSetCfmSer, CsrWifiSmeMibSetCfmDes, CsrWifiSmeMibSetCfmSerFree },
+ { CSR_WIFI_SME_MIC_FAILURE_IND, CsrWifiSmeMicFailureIndSizeof, CsrWifiSmeMicFailureIndSer, CsrWifiSmeMicFailureIndDes, CsrWifiSmeMicFailureIndSerFree },
+ { CSR_WIFI_SME_MULTICAST_ADDRESS_CFM, CsrWifiSmeMulticastAddressCfmSizeof, CsrWifiSmeMulticastAddressCfmSer, CsrWifiSmeMulticastAddressCfmDes, CsrWifiSmeMulticastAddressCfmSerFree },
+ { CSR_WIFI_SME_PACKET_FILTER_SET_CFM, CsrWifiSmePacketFilterSetCfmSizeof, CsrWifiSmePacketFilterSetCfmSer, CsrWifiSmePacketFilterSetCfmDes, CsrWifiSmePacketFilterSetCfmSerFree },
+ { CSR_WIFI_SME_PERMANENT_MAC_ADDRESS_GET_CFM, CsrWifiSmePermanentMacAddressGetCfmSizeof, CsrWifiSmePermanentMacAddressGetCfmSer, CsrWifiSmePermanentMacAddressGetCfmDes, CsrWifiSmePermanentMacAddressGetCfmSerFree },
+ { CSR_WIFI_SME_PMKID_CANDIDATE_LIST_IND, CsrWifiSmePmkidCandidateListIndSizeof, CsrWifiSmePmkidCandidateListIndSer, CsrWifiSmePmkidCandidateListIndDes, CsrWifiSmePmkidCandidateListIndSerFree },
+ { CSR_WIFI_SME_PMKID_CFM, CsrWifiSmePmkidCfmSizeof, CsrWifiSmePmkidCfmSer, CsrWifiSmePmkidCfmDes, CsrWifiSmePmkidCfmSerFree },
+ { CSR_WIFI_SME_POWER_CONFIG_GET_CFM, CsrWifiSmePowerConfigGetCfmSizeof, CsrWifiSmePowerConfigGetCfmSer, CsrWifiSmePowerConfigGetCfmDes, CsrWifiSmePowerConfigGetCfmSerFree },
+ { CSR_WIFI_SME_POWER_CONFIG_SET_CFM, CsrWifiSmePowerConfigSetCfmSizeof, CsrWifiSmePowerConfigSetCfmSer, CsrWifiSmePowerConfigSetCfmDes, CsrWifiSmePowerConfigSetCfmSerFree },
+ { CSR_WIFI_SME_REGULATORY_DOMAIN_INFO_GET_CFM, CsrWifiSmeRegulatoryDomainInfoGetCfmSizeof, CsrWifiSmeRegulatoryDomainInfoGetCfmSer, CsrWifiSmeRegulatoryDomainInfoGetCfmDes, CsrWifiSmeRegulatoryDomainInfoGetCfmSerFree },
+ { CSR_WIFI_SME_ROAM_COMPLETE_IND, CsrWifiSmeRoamCompleteIndSizeof, CsrWifiSmeRoamCompleteIndSer, CsrWifiSmeRoamCompleteIndDes, CsrWifiSmeRoamCompleteIndSerFree },
+ { CSR_WIFI_SME_ROAM_START_IND, CsrWifiSmeRoamStartIndSizeof, CsrWifiSmeRoamStartIndSer, CsrWifiSmeRoamStartIndDes, CsrWifiSmeRoamStartIndSerFree },
+ { CSR_WIFI_SME_ROAMING_CONFIG_GET_CFM, CsrWifiSmeRoamingConfigGetCfmSizeof, CsrWifiSmeRoamingConfigGetCfmSer, CsrWifiSmeRoamingConfigGetCfmDes, CsrWifiSmeRoamingConfigGetCfmSerFree },
+ { CSR_WIFI_SME_ROAMING_CONFIG_SET_CFM, CsrWifiSmeRoamingConfigSetCfmSizeof, CsrWifiSmeRoamingConfigSetCfmSer, CsrWifiSmeRoamingConfigSetCfmDes, CsrWifiSmeRoamingConfigSetCfmSerFree },
+ { CSR_WIFI_SME_SCAN_CONFIG_GET_CFM, CsrWifiSmeScanConfigGetCfmSizeof, CsrWifiSmeScanConfigGetCfmSer, CsrWifiSmeScanConfigGetCfmDes, CsrWifiSmeScanConfigGetCfmSerFree },
+ { CSR_WIFI_SME_SCAN_CONFIG_SET_CFM, CsrWifiSmeScanConfigSetCfmSizeof, CsrWifiSmeScanConfigSetCfmSer, CsrWifiSmeScanConfigSetCfmDes, CsrWifiSmeScanConfigSetCfmSerFree },
+ { CSR_WIFI_SME_SCAN_FULL_CFM, CsrWifiSmeScanFullCfmSizeof, CsrWifiSmeScanFullCfmSer, CsrWifiSmeScanFullCfmDes, CsrWifiSmeScanFullCfmSerFree },
+ { CSR_WIFI_SME_SCAN_RESULT_IND, CsrWifiSmeScanResultIndSizeof, CsrWifiSmeScanResultIndSer, CsrWifiSmeScanResultIndDes, CsrWifiSmeScanResultIndSerFree },
+ { CSR_WIFI_SME_SCAN_RESULTS_FLUSH_CFM, CsrWifiSmeScanResultsFlushCfmSizeof, CsrWifiSmeScanResultsFlushCfmSer, CsrWifiSmeScanResultsFlushCfmDes, CsrWifiSmeScanResultsFlushCfmSerFree },
+ { CSR_WIFI_SME_SCAN_RESULTS_GET_CFM, CsrWifiSmeScanResultsGetCfmSizeof, CsrWifiSmeScanResultsGetCfmSer, CsrWifiSmeScanResultsGetCfmDes, CsrWifiSmeScanResultsGetCfmSerFree },
+ { CSR_WIFI_SME_SME_STA_CONFIG_GET_CFM, CsrWifiSmeSmeStaConfigGetCfmSizeof, CsrWifiSmeSmeStaConfigGetCfmSer, CsrWifiSmeSmeStaConfigGetCfmDes, CsrWifiSmeSmeStaConfigGetCfmSerFree },
+ { CSR_WIFI_SME_SME_STA_CONFIG_SET_CFM, CsrWifiSmeSmeStaConfigSetCfmSizeof, CsrWifiSmeSmeStaConfigSetCfmSer, CsrWifiSmeSmeStaConfigSetCfmDes, CsrWifiSmeSmeStaConfigSetCfmSerFree },
+ { CSR_WIFI_SME_STATION_MAC_ADDRESS_GET_CFM, CsrWifiSmeStationMacAddressGetCfmSizeof, CsrWifiSmeStationMacAddressGetCfmSer, CsrWifiSmeStationMacAddressGetCfmDes, CsrWifiSmeStationMacAddressGetCfmSerFree },
+ { CSR_WIFI_SME_TSPEC_IND, CsrWifiSmeTspecIndSizeof, CsrWifiSmeTspecIndSer, CsrWifiSmeTspecIndDes, CsrWifiSmeTspecIndSerFree },
+ { CSR_WIFI_SME_TSPEC_CFM, CsrWifiSmeTspecCfmSizeof, CsrWifiSmeTspecCfmSer, CsrWifiSmeTspecCfmDes, CsrWifiSmeTspecCfmSerFree },
+ { CSR_WIFI_SME_VERSIONS_GET_CFM, CsrWifiSmeVersionsGetCfmSizeof, CsrWifiSmeVersionsGetCfmSer, CsrWifiSmeVersionsGetCfmDes, CsrWifiSmeVersionsGetCfmSerFree },
+ { CSR_WIFI_SME_WIFI_FLIGHTMODE_CFM, CsrWifiSmeWifiFlightmodeCfmSizeof, CsrWifiSmeWifiFlightmodeCfmSer, CsrWifiSmeWifiFlightmodeCfmDes, CsrWifiSmeWifiFlightmodeCfmSerFree },
+ { CSR_WIFI_SME_WIFI_OFF_IND, CsrWifiSmeWifiOffIndSizeof, CsrWifiSmeWifiOffIndSer, CsrWifiSmeWifiOffIndDes, CsrWifiSmeWifiOffIndSerFree },
+ { CSR_WIFI_SME_WIFI_OFF_CFM, CsrWifiSmeWifiOffCfmSizeof, CsrWifiSmeWifiOffCfmSer, CsrWifiSmeWifiOffCfmDes, CsrWifiSmeWifiOffCfmSerFree },
+ { CSR_WIFI_SME_WIFI_ON_CFM, CsrWifiSmeWifiOnCfmSizeof, CsrWifiSmeWifiOnCfmSer, CsrWifiSmeWifiOnCfmDes, CsrWifiSmeWifiOnCfmSerFree },
+ { CSR_WIFI_SME_CLOAKED_SSIDS_SET_CFM, CsrWifiSmeCloakedSsidsSetCfmSizeof, CsrWifiSmeCloakedSsidsSetCfmSer, CsrWifiSmeCloakedSsidsSetCfmDes, CsrWifiSmeCloakedSsidsSetCfmSerFree },
+ { CSR_WIFI_SME_CLOAKED_SSIDS_GET_CFM, CsrWifiSmeCloakedSsidsGetCfmSizeof, CsrWifiSmeCloakedSsidsGetCfmSer, CsrWifiSmeCloakedSsidsGetCfmDes, CsrWifiSmeCloakedSsidsGetCfmSerFree },
+ { CSR_WIFI_SME_WIFI_ON_IND, CsrWifiSmeWifiOnIndSizeof, CsrWifiSmeWifiOnIndSer, CsrWifiSmeWifiOnIndDes, CsrWifiSmeWifiOnIndSerFree },
+ { CSR_WIFI_SME_SME_COMMON_CONFIG_GET_CFM, CsrWifiSmeSmeCommonConfigGetCfmSizeof, CsrWifiSmeSmeCommonConfigGetCfmSer, CsrWifiSmeSmeCommonConfigGetCfmDes, CsrWifiSmeSmeCommonConfigGetCfmSerFree },
+ { CSR_WIFI_SME_SME_COMMON_CONFIG_SET_CFM, CsrWifiSmeSmeCommonConfigSetCfmSizeof, CsrWifiSmeSmeCommonConfigSetCfmSer, CsrWifiSmeSmeCommonConfigSetCfmDes, CsrWifiSmeSmeCommonConfigSetCfmSerFree },
+ { CSR_WIFI_SME_INTERFACE_CAPABILITY_GET_CFM, CsrWifiSmeInterfaceCapabilityGetCfmSizeof, CsrWifiSmeInterfaceCapabilityGetCfmSer, CsrWifiSmeInterfaceCapabilityGetCfmDes, CsrWifiSmeInterfaceCapabilityGetCfmSerFree },
+ { CSR_WIFI_SME_ERROR_IND, CsrWifiSmeErrorIndSizeof, CsrWifiSmeErrorIndSer, CsrWifiSmeErrorIndDes, CsrWifiSmeErrorIndSerFree },
+ { CSR_WIFI_SME_INFO_IND, CsrWifiSmeInfoIndSizeof, CsrWifiSmeInfoIndSer, CsrWifiSmeInfoIndDes, CsrWifiSmeInfoIndSerFree },
+ { CSR_WIFI_SME_CORE_DUMP_IND, CsrWifiSmeCoreDumpIndSizeof, CsrWifiSmeCoreDumpIndSer, CsrWifiSmeCoreDumpIndDes, CsrWifiSmeCoreDumpIndSerFree },
+ { CSR_WIFI_SME_AMP_STATUS_CHANGE_IND, CsrWifiSmeAmpStatusChangeIndSizeof, CsrWifiSmeAmpStatusChangeIndSer, CsrWifiSmeAmpStatusChangeIndDes, CsrWifiSmeAmpStatusChangeIndSerFree },
+ { CSR_WIFI_SME_WPS_CONFIGURATION_CFM, CsrWifiSmeWpsConfigurationCfmSizeof, CsrWifiSmeWpsConfigurationCfmSer, CsrWifiSmeWpsConfigurationCfmDes, CsrWifiSmeWpsConfigurationCfmSerFree },
+
+ { 0, NULL, NULL, NULL, NULL },
+};
+
+CsrMsgConvMsgEntry* CsrWifiSmeConverterLookup(CsrMsgConvMsgEntry *ce, u16 msgType)
+{
+ if (msgType & CSR_PRIM_UPSTREAM)
+ {
+ u16 idx = (msgType & ~CSR_PRIM_UPSTREAM) + CSR_WIFI_SME_PRIM_DOWNSTREAM_COUNT;
+ if (idx < (CSR_WIFI_SME_PRIM_UPSTREAM_COUNT + CSR_WIFI_SME_PRIM_DOWNSTREAM_COUNT) &&
+ csrwifisme_conv_lut[idx].msgType == msgType)
+ {
+ return &csrwifisme_conv_lut[idx];
+ }
+ }
+ else
+ {
+ if (msgType < CSR_WIFI_SME_PRIM_DOWNSTREAM_COUNT &&
+ csrwifisme_conv_lut[msgType].msgType == msgType)
+ {
+ return &csrwifisme_conv_lut[msgType];
+ }
+ }
+ return NULL;
+}
+
+
+void CsrWifiSmeConverterInit(void)
+{
+ CsrMsgConvInsert(CSR_WIFI_SME_PRIM, csrwifisme_conv_lut);
+ CsrMsgConvCustomLookupRegister(CSR_WIFI_SME_PRIM, CsrWifiSmeConverterLookup);
+}
+
+
+#ifdef CSR_LOG_ENABLE
+static const CsrLogPrimitiveInformation csrwifisme_conv_info = {
+ CSR_WIFI_SME_PRIM,
+ (char *)"CSR_WIFI_SME_PRIM",
+ csrwifisme_conv_lut
+};
+const CsrLogPrimitiveInformation* CsrWifiSmeTechInfoGet(void)
+{
+ return &csrwifisme_conv_info;
+}
+
+
+#endif /* CSR_LOG_ENABLE */
+#endif /* EXCLUDE_CSR_WIFI_SME_MODULE */
diff --git a/drivers/staging/csr/csr_wifi_sme_converter_init.h b/drivers/staging/csr/csr_wifi_sme_converter_init.h
new file mode 100644
index 000000000000..fb895dec7688
--- /dev/null
+++ b/drivers/staging/csr/csr_wifi_sme_converter_init.h
@@ -0,0 +1,42 @@
+/*****************************************************************************
+
+ (c) Cambridge Silicon Radio Limited 2012
+ All rights reserved and confidential information of CSR
+
+ Refer to LICENSE.txt included with this source for details
+ on the license terms.
+
+*****************************************************************************/
+
+/* Note: this is an auto-generated file. */
+
+#ifndef CSR_WIFI_SME_CONVERTER_INIT_H__
+#define CSR_WIFI_SME_CONVERTER_INIT_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef EXCLUDE_CSR_WIFI_SME_MODULE
+
+#include "csr_msgconv.h"
+
+#ifdef CSR_LOG_ENABLE
+#include "csr_log.h"
+
+extern const CsrLogPrimitiveInformation* CsrWifiSmeTechInfoGet(void);
+#endif /* CSR_LOG_ENABLE */
+
+extern void CsrWifiSmeConverterInit(void);
+
+#else /* EXCLUDE_CSR_WIFI_SME_MODULE */
+
+#define CsrWifiSmeConverterInit()
+
+#endif /* EXCLUDE_CSR_WIFI_SME_MODULE */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* CSR_WIFI_SME_CONVERTER_INIT_H__ */
diff --git a/drivers/staging/csr/csr_wifi_sme_free_downstream_contents.c b/drivers/staging/csr/csr_wifi_sme_free_downstream_contents.c
new file mode 100644
index 000000000000..03b5ddb22cd7
--- /dev/null
+++ b/drivers/staging/csr/csr_wifi_sme_free_downstream_contents.c
@@ -0,0 +1,187 @@
+/*****************************************************************************
+
+ (c) Cambridge Silicon Radio Limited 2012
+ All rights reserved and confidential information of CSR
+
+ Refer to LICENSE.txt included with this source for details
+ on the license terms.
+
+*****************************************************************************/
+
+/* Note: this is an auto-generated file. */
+#include <linux/slab.h>
+#include "csr_wifi_sme_prim.h"
+#include "csr_wifi_sme_lib.h"
+
+/*----------------------------------------------------------------------------*
+ * NAME
+ * CsrWifiSmeFreeDownstreamMessageContents
+ *
+ * DESCRIPTION
+ *
+ *
+ * PARAMETERS
+ * eventClass: only the value CSR_WIFI_SME_PRIM will be handled
+ * message: the message to free
+ *----------------------------------------------------------------------------*/
+void CsrWifiSmeFreeDownstreamMessageContents(u16 eventClass, void *message)
+{
+ if (eventClass != CSR_WIFI_SME_PRIM)
+ {
+ return;
+ }
+ if (NULL == message)
+ {
+ return;
+ }
+
+ switch (*((CsrWifiSmePrim *) message))
+ {
+ case CSR_WIFI_SME_BLACKLIST_REQ:
+ {
+ CsrWifiSmeBlacklistReq *p = (CsrWifiSmeBlacklistReq *)message;
+ kfree(p->setAddresses);
+ p->setAddresses = NULL;
+ break;
+ }
+ case CSR_WIFI_SME_CALIBRATION_DATA_SET_REQ:
+ {
+ CsrWifiSmeCalibrationDataSetReq *p = (CsrWifiSmeCalibrationDataSetReq *)message;
+ kfree(p->calibrationData);
+ p->calibrationData = NULL;
+ break;
+ }
+ case CSR_WIFI_SME_CONNECT_REQ:
+ {
+ CsrWifiSmeConnectReq *p = (CsrWifiSmeConnectReq *)message;
+ kfree(p->connectionConfig.mlmeAssociateReqInformationElements);
+ p->connectionConfig.mlmeAssociateReqInformationElements = NULL;
+ break;
+ }
+ case CSR_WIFI_SME_MIB_GET_NEXT_REQ:
+ {
+ CsrWifiSmeMibGetNextReq *p = (CsrWifiSmeMibGetNextReq *)message;
+ kfree(p->mibAttribute);
+ p->mibAttribute = NULL;
+ break;
+ }
+ case CSR_WIFI_SME_MIB_GET_REQ:
+ {
+ CsrWifiSmeMibGetReq *p = (CsrWifiSmeMibGetReq *)message;
+ kfree(p->mibAttribute);
+ p->mibAttribute = NULL;
+ break;
+ }
+ case CSR_WIFI_SME_MIB_SET_REQ:
+ {
+ CsrWifiSmeMibSetReq *p = (CsrWifiSmeMibSetReq *)message;
+ kfree(p->mibAttribute);
+ p->mibAttribute = NULL;
+ break;
+ }
+ case CSR_WIFI_SME_MULTICAST_ADDRESS_REQ:
+ {
+ CsrWifiSmeMulticastAddressReq *p = (CsrWifiSmeMulticastAddressReq *)message;
+ kfree(p->setAddresses);
+ p->setAddresses = NULL;
+ break;
+ }
+ case CSR_WIFI_SME_PACKET_FILTER_SET_REQ:
+ {
+ CsrWifiSmePacketFilterSetReq *p = (CsrWifiSmePacketFilterSetReq *)message;
+ kfree(p->filter);
+ p->filter = NULL;
+ break;
+ }
+ case CSR_WIFI_SME_PMKID_REQ:
+ {
+ CsrWifiSmePmkidReq *p = (CsrWifiSmePmkidReq *)message;
+ kfree(p->setPmkids);
+ p->setPmkids = NULL;
+ break;
+ }
+ case CSR_WIFI_SME_SCAN_CONFIG_SET_REQ:
+ {
+ CsrWifiSmeScanConfigSetReq *p = (CsrWifiSmeScanConfigSetReq *)message;
+ kfree(p->scanConfig.passiveChannelList);
+ p->scanConfig.passiveChannelList = NULL;
+ break;
+ }
+ case CSR_WIFI_SME_SCAN_FULL_REQ:
+ {
+ CsrWifiSmeScanFullReq *p = (CsrWifiSmeScanFullReq *)message;
+ kfree(p->ssid);
+ p->ssid = NULL;
+ kfree(p->channelList);
+ p->channelList = NULL;
+ kfree(p->probeIe);
+ p->probeIe = NULL;
+ break;
+ }
+ case CSR_WIFI_SME_TSPEC_REQ:
+ {
+ CsrWifiSmeTspecReq *p = (CsrWifiSmeTspecReq *)message;
+ kfree(p->tspec);
+ p->tspec = NULL;
+ kfree(p->tclas);
+ p->tclas = NULL;
+ break;
+ }
+ case CSR_WIFI_SME_WIFI_FLIGHTMODE_REQ:
+ {
+ CsrWifiSmeWifiFlightmodeReq *p = (CsrWifiSmeWifiFlightmodeReq *)message;
+ {
+ u16 i1;
+ for (i1 = 0; i1 < p->mibFilesCount; i1++)
+ {
+ kfree(p->mibFiles[i1].data);
+ p->mibFiles[i1].data = NULL;
+ }
+ }
+ kfree(p->mibFiles);
+ p->mibFiles = NULL;
+ break;
+ }
+ case CSR_WIFI_SME_WIFI_ON_REQ:
+ {
+ CsrWifiSmeWifiOnReq *p = (CsrWifiSmeWifiOnReq *)message;
+ {
+ u16 i1;
+ for (i1 = 0; i1 < p->mibFilesCount; i1++)
+ {
+ kfree(p->mibFiles[i1].data);
+ p->mibFiles[i1].data = NULL;
+ }
+ }
+ kfree(p->mibFiles);
+ p->mibFiles = NULL;
+ break;
+ }
+ case CSR_WIFI_SME_CLOAKED_SSIDS_SET_REQ:
+ {
+ CsrWifiSmeCloakedSsidsSetReq *p = (CsrWifiSmeCloakedSsidsSetReq *)message;
+ kfree(p->cloakedSsids.cloakedSsids);
+ p->cloakedSsids.cloakedSsids = NULL;
+ break;
+ }
+ case CSR_WIFI_SME_WPS_CONFIGURATION_REQ:
+ {
+ CsrWifiSmeWpsConfigurationReq *p = (CsrWifiSmeWpsConfigurationReq *)message;
+ kfree(p->wpsConfig.secondaryDeviceType);
+ p->wpsConfig.secondaryDeviceType = NULL;
+ break;
+ }
+ case CSR_WIFI_SME_SET_REQ:
+ {
+ CsrWifiSmeSetReq *p = (CsrWifiSmeSetReq *)message;
+ kfree(p->data);
+ p->data = NULL;
+ break;
+ }
+
+ default:
+ break;
+ }
+}
+
+
diff --git a/drivers/staging/csr/csr_wifi_sme_free_upstream_contents.c b/drivers/staging/csr/csr_wifi_sme_free_upstream_contents.c
new file mode 100644
index 000000000000..c04767baaa5b
--- /dev/null
+++ b/drivers/staging/csr/csr_wifi_sme_free_upstream_contents.c
@@ -0,0 +1,275 @@
+/*****************************************************************************
+
+ (c) Cambridge Silicon Radio Limited 2011
+ All rights reserved and confidential information of CSR
+
+ Refer to LICENSE.txt included with this source for details
+ on the license terms.
+
+*****************************************************************************/
+
+/* Note: this is an auto-generated file. */
+#include <linux/slab.h>
+#include "csr_wifi_sme_prim.h"
+#include "csr_wifi_sme_lib.h"
+
+/*----------------------------------------------------------------------------*
+ * NAME
+ * CsrWifiSmeFreeUpstreamMessageContents
+ *
+ * DESCRIPTION
+ *
+ *
+ * PARAMETERS
+ * eventClass: only the value CSR_WIFI_SME_PRIM will be handled
+ * message: the message to free
+ *----------------------------------------------------------------------------*/
+void CsrWifiSmeFreeUpstreamMessageContents(u16 eventClass, void *message)
+{
+ if (eventClass != CSR_WIFI_SME_PRIM)
+ {
+ return;
+ }
+ if (NULL == message)
+ {
+ return;
+ }
+
+ switch (*((CsrWifiSmePrim *) message))
+ {
+ case CSR_WIFI_SME_ASSOCIATION_COMPLETE_IND:
+ {
+ CsrWifiSmeAssociationCompleteInd *p = (CsrWifiSmeAssociationCompleteInd *)message;
+ kfree(p->connectionInfo.beaconFrame);
+ p->connectionInfo.beaconFrame = NULL;
+ kfree(p->connectionInfo.associationReqFrame);
+ p->connectionInfo.associationReqFrame = NULL;
+ kfree(p->connectionInfo.associationRspFrame);
+ p->connectionInfo.associationRspFrame = NULL;
+ kfree(p->connectionInfo.assocScanInfoElements);
+ p->connectionInfo.assocScanInfoElements = NULL;
+ kfree(p->connectionInfo.assocReqInfoElements);
+ p->connectionInfo.assocReqInfoElements = NULL;
+ kfree(p->connectionInfo.assocRspInfoElements);
+ p->connectionInfo.assocRspInfoElements = NULL;
+ break;
+ }
+ case CSR_WIFI_SME_BLACKLIST_CFM:
+ {
+ CsrWifiSmeBlacklistCfm *p = (CsrWifiSmeBlacklistCfm *)message;
+ kfree(p->getAddresses);
+ p->getAddresses = NULL;
+ break;
+ }
+ case CSR_WIFI_SME_CALIBRATION_DATA_GET_CFM:
+ {
+ CsrWifiSmeCalibrationDataGetCfm *p = (CsrWifiSmeCalibrationDataGetCfm *)message;
+ kfree(p->calibrationData);
+ p->calibrationData = NULL;
+ break;
+ }
+ case CSR_WIFI_SME_CONNECTION_CONFIG_GET_CFM:
+ {
+ CsrWifiSmeConnectionConfigGetCfm *p = (CsrWifiSmeConnectionConfigGetCfm *)message;
+ kfree(p->connectionConfig.mlmeAssociateReqInformationElements);
+ p->connectionConfig.mlmeAssociateReqInformationElements = NULL;
+ break;
+ }
+ case CSR_WIFI_SME_CONNECTION_INFO_GET_CFM:
+ {
+ CsrWifiSmeConnectionInfoGetCfm *p = (CsrWifiSmeConnectionInfoGetCfm *)message;
+ kfree(p->connectionInfo.beaconFrame);
+ p->connectionInfo.beaconFrame = NULL;
+ kfree(p->connectionInfo.associationReqFrame);
+ p->connectionInfo.associationReqFrame = NULL;
+ kfree(p->connectionInfo.associationRspFrame);
+ p->connectionInfo.associationRspFrame = NULL;
+ kfree(p->connectionInfo.assocScanInfoElements);
+ p->connectionInfo.assocScanInfoElements = NULL;
+ kfree(p->connectionInfo.assocReqInfoElements);
+ p->connectionInfo.assocReqInfoElements = NULL;
+ kfree(p->connectionInfo.assocRspInfoElements);
+ p->connectionInfo.assocRspInfoElements = NULL;
+ break;
+ }
+ case CSR_WIFI_SME_MEDIA_STATUS_IND:
+ {
+ CsrWifiSmeMediaStatusInd *p = (CsrWifiSmeMediaStatusInd *)message;
+ kfree(p->connectionInfo.beaconFrame);
+ p->connectionInfo.beaconFrame = NULL;
+ kfree(p->connectionInfo.associationReqFrame);
+ p->connectionInfo.associationReqFrame = NULL;
+ kfree(p->connectionInfo.associationRspFrame);
+ p->connectionInfo.associationRspFrame = NULL;
+ kfree(p->connectionInfo.assocScanInfoElements);
+ p->connectionInfo.assocScanInfoElements = NULL;
+ kfree(p->connectionInfo.assocReqInfoElements);
+ p->connectionInfo.assocReqInfoElements = NULL;
+ kfree(p->connectionInfo.assocRspInfoElements);
+ p->connectionInfo.assocRspInfoElements = NULL;
+ break;
+ }
+ case CSR_WIFI_SME_MIB_GET_CFM:
+ {
+ CsrWifiSmeMibGetCfm *p = (CsrWifiSmeMibGetCfm *)message;
+ kfree(p->mibAttribute);
+ p->mibAttribute = NULL;
+ break;
+ }
+ case CSR_WIFI_SME_MIB_GET_NEXT_CFM:
+ {
+ CsrWifiSmeMibGetNextCfm *p = (CsrWifiSmeMibGetNextCfm *)message;
+ kfree(p->mibAttribute);
+ p->mibAttribute = NULL;
+ break;
+ }
+ case CSR_WIFI_SME_MULTICAST_ADDRESS_CFM:
+ {
+ CsrWifiSmeMulticastAddressCfm *p = (CsrWifiSmeMulticastAddressCfm *)message;
+ kfree(p->getAddresses);
+ p->getAddresses = NULL;
+ break;
+ }
+ case CSR_WIFI_SME_PMKID_CANDIDATE_LIST_IND:
+ {
+ CsrWifiSmePmkidCandidateListInd *p = (CsrWifiSmePmkidCandidateListInd *)message;
+ kfree(p->pmkidCandidates);
+ p->pmkidCandidates = NULL;
+ break;
+ }
+ case CSR_WIFI_SME_PMKID_CFM:
+ {
+ CsrWifiSmePmkidCfm *p = (CsrWifiSmePmkidCfm *)message;
+ kfree(p->getPmkids);
+ p->getPmkids = NULL;
+ break;
+ }
+ case CSR_WIFI_SME_SCAN_CONFIG_GET_CFM:
+ {
+ CsrWifiSmeScanConfigGetCfm *p = (CsrWifiSmeScanConfigGetCfm *)message;
+ kfree(p->scanConfig.passiveChannelList);
+ p->scanConfig.passiveChannelList = NULL;
+ break;
+ }
+ case CSR_WIFI_SME_SCAN_RESULT_IND:
+ {
+ CsrWifiSmeScanResultInd *p = (CsrWifiSmeScanResultInd *)message;
+ kfree(p->result.informationElements);
+ p->result.informationElements = NULL;
+ switch (p->result.p2pDeviceRole)
+ {
+ case CSR_WIFI_SME_P2P_ROLE_GO:
+ {
+ u16 i4;
+ for (i4 = 0; i4 < p->result.deviceInfo.groupInfo.p2pClientInfoCount; i4++)
+ {
+ kfree(p->result.deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.secDeviceType);
+ p->result.deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.secDeviceType = NULL;
+ }
+ }
+ kfree(p->result.deviceInfo.groupInfo.p2PClientInfo);
+ p->result.deviceInfo.groupInfo.p2PClientInfo = NULL;
+ break;
+ case CSR_WIFI_SME_P2P_ROLE_STANDALONE:
+ kfree(p->result.deviceInfo.standalonedevInfo.secDeviceType);
+ p->result.deviceInfo.standalonedevInfo.secDeviceType = NULL;
+ break;
+ default:
+ break;
+ }
+ break;
+ }
+ case CSR_WIFI_SME_SCAN_RESULTS_GET_CFM:
+ {
+ CsrWifiSmeScanResultsGetCfm *p = (CsrWifiSmeScanResultsGetCfm *)message;
+ {
+ u16 i1;
+ for (i1 = 0; i1 < p->scanResultsCount; i1++)
+ {
+ kfree(p->scanResults[i1].informationElements);
+ p->scanResults[i1].informationElements = NULL;
+ switch (p->scanResults[i1].p2pDeviceRole)
+ {
+ case CSR_WIFI_SME_P2P_ROLE_GO:
+ {
+ u16 i4;
+ for (i4 = 0; i4 < p->scanResults[i1].deviceInfo.groupInfo.p2pClientInfoCount; i4++)
+ {
+ kfree(p->scanResults[i1].deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.secDeviceType);
+ p->scanResults[i1].deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.secDeviceType = NULL;
+ }
+ }
+ kfree(p->scanResults[i1].deviceInfo.groupInfo.p2PClientInfo);
+ p->scanResults[i1].deviceInfo.groupInfo.p2PClientInfo = NULL;
+ break;
+ case CSR_WIFI_SME_P2P_ROLE_STANDALONE:
+ kfree(p->scanResults[i1].deviceInfo.standalonedevInfo.secDeviceType);
+ p->scanResults[i1].deviceInfo.standalonedevInfo.secDeviceType = NULL;
+ break;
+ default:
+ break;
+ }
+ }
+ }
+ kfree(p->scanResults);
+ p->scanResults = NULL;
+ break;
+ }
+ case CSR_WIFI_SME_TSPEC_IND:
+ {
+ CsrWifiSmeTspecInd *p = (CsrWifiSmeTspecInd *)message;
+ kfree(p->tspec);
+ p->tspec = NULL;
+ break;
+ }
+ case CSR_WIFI_SME_TSPEC_CFM:
+ {
+ CsrWifiSmeTspecCfm *p = (CsrWifiSmeTspecCfm *)message;
+ kfree(p->tspec);
+ p->tspec = NULL;
+ break;
+ }
+ case CSR_WIFI_SME_VERSIONS_GET_CFM:
+ {
+ CsrWifiSmeVersionsGetCfm *p = (CsrWifiSmeVersionsGetCfm *)message;
+ kfree(p->versions.routerBuild);
+ p->versions.routerBuild = NULL;
+ kfree(p->versions.smeBuild);
+ p->versions.smeBuild = NULL;
+ break;
+ }
+ case CSR_WIFI_SME_CLOAKED_SSIDS_GET_CFM:
+ {
+ CsrWifiSmeCloakedSsidsGetCfm *p = (CsrWifiSmeCloakedSsidsGetCfm *)message;
+ kfree(p->cloakedSsids.cloakedSsids);
+ p->cloakedSsids.cloakedSsids = NULL;
+ break;
+ }
+ case CSR_WIFI_SME_ERROR_IND:
+ {
+ CsrWifiSmeErrorInd *p = (CsrWifiSmeErrorInd *)message;
+ kfree(p->errorMessage);
+ p->errorMessage = NULL;
+ break;
+ }
+ case CSR_WIFI_SME_INFO_IND:
+ {
+ CsrWifiSmeInfoInd *p = (CsrWifiSmeInfoInd *)message;
+ kfree(p->infoMessage);
+ p->infoMessage = NULL;
+ break;
+ }
+ case CSR_WIFI_SME_CORE_DUMP_IND:
+ {
+ CsrWifiSmeCoreDumpInd *p = (CsrWifiSmeCoreDumpInd *)message;
+ kfree(p->data);
+ p->data = NULL;
+ break;
+ }
+
+ default:
+ break;
+ }
+}
+
+
diff --git a/drivers/staging/csr/csr_wifi_sme_lib.h b/drivers/staging/csr/csr_wifi_sme_lib.h
new file mode 100644
index 000000000000..3ca745608252
--- /dev/null
+++ b/drivers/staging/csr/csr_wifi_sme_lib.h
@@ -0,0 +1,4313 @@
+/*****************************************************************************
+
+ (c) Cambridge Silicon Radio Limited 2012
+ All rights reserved and confidential information of CSR
+
+ Refer to LICENSE.txt included with this source for details
+ on the license terms.
+
+*****************************************************************************/
+
+/* Note: this is an auto-generated file. */
+
+#ifndef CSR_WIFI_SME_LIB_H__
+#define CSR_WIFI_SME_LIB_H__
+
+#include "csr_sched.h"
+#include "csr_macro.h"
+#include "csr_msg_transport.h"
+
+#include "csr_wifi_lib.h"
+
+#include "csr_wifi_sme_prim.h"
+#include "csr_wifi_sme_task.h"
+
+
+#ifndef CSR_WIFI_SME_LIB_DESTINATION_QUEUE
+# ifdef CSR_WIFI_NME_ENABLE
+# include "csr_wifi_nme_task.h"
+# define CSR_WIFI_SME_LIB_DESTINATION_QUEUE CSR_WIFI_NME_IFACEQUEUE
+# else
+# define CSR_WIFI_SME_LIB_DESTINATION_QUEUE CSR_WIFI_SME_IFACEQUEUE
+# endif
+#endif
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*----------------------------------------------------------------------------*
+ * CsrWifiSmeFreeUpstreamMessageContents
+ *
+ * DESCRIPTION
+ * Free the allocated memory in a CSR_WIFI_SME upstream message. Does not
+ * free the message itself, and can only be used for upstream messages.
+ *
+ * PARAMETERS
+ * Deallocates the resources in a CSR_WIFI_SME upstream message
+ *----------------------------------------------------------------------------*/
+void CsrWifiSmeFreeUpstreamMessageContents(u16 eventClass, void *message);
+
+/*----------------------------------------------------------------------------*
+ * CsrWifiSmeFreeDownstreamMessageContents
+ *
+ * DESCRIPTION
+ * Free the allocated memory in a CSR_WIFI_SME downstream message. Does not
+ * free the message itself, and can only be used for downstream messages.
+ *
+ * PARAMETERS
+ * Deallocates the resources in a CSR_WIFI_SME downstream message
+ *----------------------------------------------------------------------------*/
+void CsrWifiSmeFreeDownstreamMessageContents(u16 eventClass, void *message);
+
+/*----------------------------------------------------------------------------*
+ * Enum to string functions
+ *----------------------------------------------------------------------------*/
+const char* CsrWifiSme80211NetworkTypeToString(CsrWifiSme80211NetworkType value);
+const char* CsrWifiSme80211PrivacyModeToString(CsrWifiSme80211PrivacyMode value);
+const char* CsrWifiSme80211dTrustLevelToString(CsrWifiSme80211dTrustLevel value);
+const char* CsrWifiSmeAmpStatusToString(CsrWifiSmeAmpStatus value);
+const char* CsrWifiSmeAuthModeToString(CsrWifiSmeAuthMode value);
+const char* CsrWifiSmeBasicUsabilityToString(CsrWifiSmeBasicUsability value);
+const char* CsrWifiSmeBssTypeToString(CsrWifiSmeBssType value);
+const char* CsrWifiSmeCoexSchemeToString(CsrWifiSmeCoexScheme value);
+const char* CsrWifiSmeControlIndicationToString(CsrWifiSmeControlIndication value);
+const char* CsrWifiSmeCtsProtectionTypeToString(CsrWifiSmeCtsProtectionType value);
+const char* CsrWifiSmeD3AutoScanModeToString(CsrWifiSmeD3AutoScanMode value);
+const char* CsrWifiSmeEncryptionToString(CsrWifiSmeEncryption value);
+const char* CsrWifiSmeFirmwareDriverInterfaceToString(CsrWifiSmeFirmwareDriverInterface value);
+const char* CsrWifiSmeHostPowerModeToString(CsrWifiSmeHostPowerMode value);
+const char* CsrWifiSmeIEEE80211ReasonToString(CsrWifiSmeIEEE80211Reason value);
+const char* CsrWifiSmeIEEE80211ResultToString(CsrWifiSmeIEEE80211Result value);
+const char* CsrWifiSmeIndicationsToString(CsrWifiSmeIndications value);
+const char* CsrWifiSmeKeyTypeToString(CsrWifiSmeKeyType value);
+const char* CsrWifiSmeListActionToString(CsrWifiSmeListAction value);
+const char* CsrWifiSmeMediaStatusToString(CsrWifiSmeMediaStatus value);
+const char* CsrWifiSmeP2pCapabilityToString(CsrWifiSmeP2pCapability value);
+const char* CsrWifiSmeP2pGroupCapabilityToString(CsrWifiSmeP2pGroupCapability value);
+const char* CsrWifiSmeP2pNoaConfigMethodToString(CsrWifiSmeP2pNoaConfigMethod value);
+const char* CsrWifiSmeP2pRoleToString(CsrWifiSmeP2pRole value);
+const char* CsrWifiSmeP2pStatusToString(CsrWifiSmeP2pStatus value);
+const char* CsrWifiSmePacketFilterModeToString(CsrWifiSmePacketFilterMode value);
+const char* CsrWifiSmePowerSaveLevelToString(CsrWifiSmePowerSaveLevel value);
+const char* CsrWifiSmePreambleTypeToString(CsrWifiSmePreambleType value);
+const char* CsrWifiSmeRadioIFToString(CsrWifiSmeRadioIF value);
+const char* CsrWifiSmeRegulatoryDomainToString(CsrWifiSmeRegulatoryDomain value);
+const char* CsrWifiSmeRoamReasonToString(CsrWifiSmeRoamReason value);
+const char* CsrWifiSmeScanTypeToString(CsrWifiSmeScanType value);
+const char* CsrWifiSmeTrafficTypeToString(CsrWifiSmeTrafficType value);
+const char* CsrWifiSmeTspecCtrlToString(CsrWifiSmeTspecCtrl value);
+const char* CsrWifiSmeTspecResultCodeToString(CsrWifiSmeTspecResultCode value);
+const char* CsrWifiSmeWepAuthModeToString(CsrWifiSmeWepAuthMode value);
+const char* CsrWifiSmeWepCredentialTypeToString(CsrWifiSmeWepCredentialType value);
+const char* CsrWifiSmeWmmModeToString(CsrWifiSmeWmmMode value);
+const char* CsrWifiSmeWmmQosInfoToString(CsrWifiSmeWmmQosInfo value);
+const char* CsrWifiSmeWpsConfigTypeToString(CsrWifiSmeWpsConfigType value);
+const char* CsrWifiSmeWpsDeviceCategoryToString(CsrWifiSmeWpsDeviceCategory value);
+const char* CsrWifiSmeWpsDeviceSubCategoryToString(CsrWifiSmeWpsDeviceSubCategory value);
+const char* CsrWifiSmeWpsDpidToString(CsrWifiSmeWpsDpid value);
+const char* CsrWifiSmeWpsRegistrationToString(CsrWifiSmeWpsRegistration value);
+
+
+/*----------------------------------------------------------------------------*
+ * CsrPrim Type toString function.
+ * Converts a message type to the String name of the Message
+ *----------------------------------------------------------------------------*/
+const char* CsrWifiSmePrimTypeToString(CsrPrim msgType);
+
+/*----------------------------------------------------------------------------*
+ * Lookup arrays for PrimType name Strings
+ *----------------------------------------------------------------------------*/
+extern const char *CsrWifiSmeUpstreamPrimNames[CSR_WIFI_SME_PRIM_UPSTREAM_COUNT];
+extern const char *CsrWifiSmeDownstreamPrimNames[CSR_WIFI_SME_PRIM_DOWNSTREAM_COUNT];
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeActivateReqSend
+
+ DESCRIPTION
+ The WMA sends this primitive to activate the SME.
+ The WMA must activate the SME before it can send any other primitive.
+
+ PARAMETERS
+ queue - Message Source Task Queue (Cfm's will be sent to this Queue)
+
+*******************************************************************************/
+#define CsrWifiSmeActivateReqCreate(msg__, dst__, src__) \
+ msg__ = kmalloc(sizeof(CsrWifiSmeActivateReq), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_ACTIVATE_REQ, dst__, src__);
+
+#define CsrWifiSmeActivateReqSendTo(dst__, src__) \
+ { \
+ CsrWifiSmeActivateReq *msg__; \
+ CsrWifiSmeActivateReqCreate(msg__, dst__, src__); \
+ CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \
+ }
+
+#define CsrWifiSmeActivateReqSend(src__) \
+ CsrWifiSmeActivateReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeActivateCfmSend
+
+ DESCRIPTION
+ The SME sends this primitive when the activation is complete.
+
+ PARAMETERS
+ queue - Destination Task Queue
+ status - Reports the result of the request
+
+*******************************************************************************/
+#define CsrWifiSmeActivateCfmCreate(msg__, dst__, src__, status__) \
+ msg__ = kmalloc(sizeof(CsrWifiSmeActivateCfm), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_ACTIVATE_CFM, dst__, src__); \
+ msg__->status = (status__);
+
+#define CsrWifiSmeActivateCfmSendTo(dst__, src__, status__) \
+ { \
+ CsrWifiSmeActivateCfm *msg__; \
+ CsrWifiSmeActivateCfmCreate(msg__, dst__, src__, status__); \
+ CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
+ }
+
+#define CsrWifiSmeActivateCfmSend(dst__, status__) \
+ CsrWifiSmeActivateCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, status__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeAdhocConfigGetReqSend
+
+ DESCRIPTION
+ This primitive gets the value of the adHocConfig parameter.
+
+ PARAMETERS
+ queue - Message Source Task Queue (Cfm's will be sent to this Queue)
+
+*******************************************************************************/
+#define CsrWifiSmeAdhocConfigGetReqCreate(msg__, dst__, src__) \
+ msg__ = kmalloc(sizeof(CsrWifiSmeAdhocConfigGetReq), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_ADHOC_CONFIG_GET_REQ, dst__, src__);
+
+#define CsrWifiSmeAdhocConfigGetReqSendTo(dst__, src__) \
+ { \
+ CsrWifiSmeAdhocConfigGetReq *msg__; \
+ CsrWifiSmeAdhocConfigGetReqCreate(msg__, dst__, src__); \
+ CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \
+ }
+
+#define CsrWifiSmeAdhocConfigGetReqSend(src__) \
+ CsrWifiSmeAdhocConfigGetReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeAdhocConfigGetCfmSend
+
+ DESCRIPTION
+ This primitive reports the result of the request.
+
+ PARAMETERS
+ queue - Destination Task Queue
+ status - Reports the result of the request
+ adHocConfig - Contains the values used when starting an Ad-hoc (IBSS)
+ connection.
+
+*******************************************************************************/
+#define CsrWifiSmeAdhocConfigGetCfmCreate(msg__, dst__, src__, status__, adHocConfig__) \
+ msg__ = kmalloc(sizeof(CsrWifiSmeAdhocConfigGetCfm), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_ADHOC_CONFIG_GET_CFM, dst__, src__); \
+ msg__->status = (status__); \
+ msg__->adHocConfig = (adHocConfig__);
+
+#define CsrWifiSmeAdhocConfigGetCfmSendTo(dst__, src__, status__, adHocConfig__) \
+ { \
+ CsrWifiSmeAdhocConfigGetCfm *msg__; \
+ CsrWifiSmeAdhocConfigGetCfmCreate(msg__, dst__, src__, status__, adHocConfig__); \
+ CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
+ }
+
+#define CsrWifiSmeAdhocConfigGetCfmSend(dst__, status__, adHocConfig__) \
+ CsrWifiSmeAdhocConfigGetCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, status__, adHocConfig__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeAdhocConfigSetReqSend
+
+ DESCRIPTION
+ This primitive sets the value of the adHocConfig parameter.
+
+ PARAMETERS
+ queue - Message Source Task Queue (Cfm's will be sent to this Queue)
+ adHocConfig - Sets the values to use when starting an ad hoc network.
+
+*******************************************************************************/
+#define CsrWifiSmeAdhocConfigSetReqCreate(msg__, dst__, src__, adHocConfig__) \
+ msg__ = kmalloc(sizeof(CsrWifiSmeAdhocConfigSetReq), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_ADHOC_CONFIG_SET_REQ, dst__, src__); \
+ msg__->adHocConfig = (adHocConfig__);
+
+#define CsrWifiSmeAdhocConfigSetReqSendTo(dst__, src__, adHocConfig__) \
+ { \
+ CsrWifiSmeAdhocConfigSetReq *msg__; \
+ CsrWifiSmeAdhocConfigSetReqCreate(msg__, dst__, src__, adHocConfig__); \
+ CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \
+ }
+
+#define CsrWifiSmeAdhocConfigSetReqSend(src__, adHocConfig__) \
+ CsrWifiSmeAdhocConfigSetReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__, adHocConfig__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeAdhocConfigSetCfmSend
+
+ DESCRIPTION
+ This primitive reports the result of the request.
+
+ PARAMETERS
+ queue - Destination Task Queue
+ status - Reports the result of the request
+
+*******************************************************************************/
+#define CsrWifiSmeAdhocConfigSetCfmCreate(msg__, dst__, src__, status__) \
+ msg__ = kmalloc(sizeof(CsrWifiSmeAdhocConfigSetCfm), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_ADHOC_CONFIG_SET_CFM, dst__, src__); \
+ msg__->status = (status__);
+
+#define CsrWifiSmeAdhocConfigSetCfmSendTo(dst__, src__, status__) \
+ { \
+ CsrWifiSmeAdhocConfigSetCfm *msg__; \
+ CsrWifiSmeAdhocConfigSetCfmCreate(msg__, dst__, src__, status__); \
+ CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
+ }
+
+#define CsrWifiSmeAdhocConfigSetCfmSend(dst__, status__) \
+ CsrWifiSmeAdhocConfigSetCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, status__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeAmpStatusChangeIndSend
+
+ DESCRIPTION
+ Indication of change to AMP activity.
+
+ PARAMETERS
+ queue - Destination Task Queue
+ interfaceTag - Interface on which the AMP activity changed.
+ ampStatus - The new status of AMP activity.Range: {AMP_ACTIVE,
+ AMP_INACTIVE}.
+
+*******************************************************************************/
+#define CsrWifiSmeAmpStatusChangeIndCreate(msg__, dst__, src__, interfaceTag__, ampStatus__) \
+ msg__ = kmalloc(sizeof(CsrWifiSmeAmpStatusChangeInd), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_AMP_STATUS_CHANGE_IND, dst__, src__); \
+ msg__->interfaceTag = (interfaceTag__); \
+ msg__->ampStatus = (ampStatus__);
+
+#define CsrWifiSmeAmpStatusChangeIndSendTo(dst__, src__, interfaceTag__, ampStatus__) \
+ { \
+ CsrWifiSmeAmpStatusChangeInd *msg__; \
+ CsrWifiSmeAmpStatusChangeIndCreate(msg__, dst__, src__, interfaceTag__, ampStatus__); \
+ CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
+ }
+
+#define CsrWifiSmeAmpStatusChangeIndSend(dst__, interfaceTag__, ampStatus__) \
+ CsrWifiSmeAmpStatusChangeIndSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, interfaceTag__, ampStatus__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeAssociationCompleteIndSend
+
+ DESCRIPTION
+ The SME will send this primitive to all the tasks that have registered to
+ receive it whenever it completes an attempt to associate with an AP. If
+ the association was successful, status will be set to
+ CSR_WIFI_SME_STATUS_SUCCESS, otherwise status and deauthReason shall be
+ set to appropriate error codes.
+
+ PARAMETERS
+ queue - Destination Task Queue
+ interfaceTag - Interface Identifier; unique identifier of an interface
+ status - Reports the result of the association procedure
+ connectionInfo - This parameter is relevant only if result is
+ CSR_WIFI_SME_STATUS_SUCCESS:
+ it points to the connection information for the new network
+ deauthReason - This parameter is relevant only if result is not
+ CSR_WIFI_SME_STATUS_SUCCESS:
+ if the AP deauthorised the station, it gives the reason of
+ the deauthorization
+
+*******************************************************************************/
+#define CsrWifiSmeAssociationCompleteIndCreate(msg__, dst__, src__, interfaceTag__, status__, connectionInfo__, deauthReason__) \
+ msg__ = kmalloc(sizeof(CsrWifiSmeAssociationCompleteInd), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_ASSOCIATION_COMPLETE_IND, dst__, src__); \
+ msg__->interfaceTag = (interfaceTag__); \
+ msg__->status = (status__); \
+ msg__->connectionInfo = (connectionInfo__); \
+ msg__->deauthReason = (deauthReason__);
+
+#define CsrWifiSmeAssociationCompleteIndSendTo(dst__, src__, interfaceTag__, status__, connectionInfo__, deauthReason__) \
+ { \
+ CsrWifiSmeAssociationCompleteInd *msg__; \
+ CsrWifiSmeAssociationCompleteIndCreate(msg__, dst__, src__, interfaceTag__, status__, connectionInfo__, deauthReason__); \
+ CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
+ }
+
+#define CsrWifiSmeAssociationCompleteIndSend(dst__, interfaceTag__, status__, connectionInfo__, deauthReason__) \
+ CsrWifiSmeAssociationCompleteIndSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, interfaceTag__, status__, connectionInfo__, deauthReason__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeAssociationStartIndSend
+
+ DESCRIPTION
+ The SME will send this primitive to all the tasks that have registered to
+ receive it whenever it begins an attempt to associate with an AP.
+
+ PARAMETERS
+ queue - Destination Task Queue
+ interfaceTag - Interface Identifier; unique identifier of an interface
+ address - BSSID of the associating network
+ ssid - Service Set identifier of the associating network
+
+*******************************************************************************/
+#define CsrWifiSmeAssociationStartIndCreate(msg__, dst__, src__, interfaceTag__, address__, ssid__) \
+ msg__ = kmalloc(sizeof(CsrWifiSmeAssociationStartInd), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_ASSOCIATION_START_IND, dst__, src__); \
+ msg__->interfaceTag = (interfaceTag__); \
+ msg__->address = (address__); \
+ msg__->ssid = (ssid__);
+
+#define CsrWifiSmeAssociationStartIndSendTo(dst__, src__, interfaceTag__, address__, ssid__) \
+ { \
+ CsrWifiSmeAssociationStartInd *msg__; \
+ CsrWifiSmeAssociationStartIndCreate(msg__, dst__, src__, interfaceTag__, address__, ssid__); \
+ CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
+ }
+
+#define CsrWifiSmeAssociationStartIndSend(dst__, interfaceTag__, address__, ssid__) \
+ CsrWifiSmeAssociationStartIndSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, interfaceTag__, address__, ssid__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeBlacklistReqSend
+
+ DESCRIPTION
+ The wireless manager application should call this primitive to notify the
+ driver of any networks that should not be connected to. The interface
+ allows the wireless manager application to query, add, remove, and flush
+ the BSSIDs that the driver may not connect or roam to.
+ When this primitive adds to the black list the BSSID to which the SME is
+ currently connected, the SME will try to roam, if applicable, to another
+ BSSID in the same ESS; if the roaming procedure fails, the SME will
+ disconnect.
+
+ PARAMETERS
+ queue - Message Source Task Queue (Cfm's will be sent to this Queue)
+ interfaceTag - Interface Identifier; unique identifier of an interface
+ action - The value of the CsrWifiSmeListAction parameter instructs
+ the driver to modify or provide the list of blacklisted
+ networks.
+ setAddressCount - Number of BSSIDs sent with this primitive
+ setAddresses - Pointer to the list of BBSIDs sent with the primitive, set
+ to NULL if none is sent.
+
+*******************************************************************************/
+#define CsrWifiSmeBlacklistReqCreate(msg__, dst__, src__, interfaceTag__, action__, setAddressCount__, setAddresses__) \
+ msg__ = kmalloc(sizeof(CsrWifiSmeBlacklistReq), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_BLACKLIST_REQ, dst__, src__); \
+ msg__->interfaceTag = (interfaceTag__); \
+ msg__->action = (action__); \
+ msg__->setAddressCount = (setAddressCount__); \
+ msg__->setAddresses = (setAddresses__);
+
+#define CsrWifiSmeBlacklistReqSendTo(dst__, src__, interfaceTag__, action__, setAddressCount__, setAddresses__) \
+ { \
+ CsrWifiSmeBlacklistReq *msg__; \
+ CsrWifiSmeBlacklistReqCreate(msg__, dst__, src__, interfaceTag__, action__, setAddressCount__, setAddresses__); \
+ CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \
+ }
+
+#define CsrWifiSmeBlacklistReqSend(src__, interfaceTag__, action__, setAddressCount__, setAddresses__) \
+ CsrWifiSmeBlacklistReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__, interfaceTag__, action__, setAddressCount__, setAddresses__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeBlacklistCfmSend
+
+ DESCRIPTION
+ The SME will call this primitive when the action on the blacklist has
+ completed. For a GET action, this primitive also reports the list of
+ BBSIDs in the blacklist.
+
+ PARAMETERS
+ queue - Destination Task Queue
+ interfaceTag - Interface Identifier; unique identifier of an interface
+ status - Reports the result of the request
+ action - Action in the request
+ getAddressCount - This parameter is only relevant if action is
+ CSR_WIFI_SME_LIST_ACTION_GET:
+ number of BSSIDs sent with this primitive
+ getAddresses - Pointer to the list of BBSIDs sent with the primitive, set
+ to NULL if none is sent.
+
+*******************************************************************************/
+#define CsrWifiSmeBlacklistCfmCreate(msg__, dst__, src__, interfaceTag__, status__, action__, getAddressCount__, getAddresses__) \
+ msg__ = kmalloc(sizeof(CsrWifiSmeBlacklistCfm), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_BLACKLIST_CFM, dst__, src__); \
+ msg__->interfaceTag = (interfaceTag__); \
+ msg__->status = (status__); \
+ msg__->action = (action__); \
+ msg__->getAddressCount = (getAddressCount__); \
+ msg__->getAddresses = (getAddresses__);
+
+#define CsrWifiSmeBlacklistCfmSendTo(dst__, src__, interfaceTag__, status__, action__, getAddressCount__, getAddresses__) \
+ { \
+ CsrWifiSmeBlacklistCfm *msg__; \
+ CsrWifiSmeBlacklistCfmCreate(msg__, dst__, src__, interfaceTag__, status__, action__, getAddressCount__, getAddresses__); \
+ CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
+ }
+
+#define CsrWifiSmeBlacklistCfmSend(dst__, interfaceTag__, status__, action__, getAddressCount__, getAddresses__) \
+ CsrWifiSmeBlacklistCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, interfaceTag__, status__, action__, getAddressCount__, getAddresses__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeCalibrationDataGetReqSend
+
+ DESCRIPTION
+ This primitive retrieves the Wi-Fi radio calibration data.
+
+ PARAMETERS
+ queue - Message Source Task Queue (Cfm's will be sent to this Queue)
+
+*******************************************************************************/
+#define CsrWifiSmeCalibrationDataGetReqCreate(msg__, dst__, src__) \
+ msg__ = kmalloc(sizeof(CsrWifiSmeCalibrationDataGetReq), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_CALIBRATION_DATA_GET_REQ, dst__, src__);
+
+#define CsrWifiSmeCalibrationDataGetReqSendTo(dst__, src__) \
+ { \
+ CsrWifiSmeCalibrationDataGetReq *msg__; \
+ CsrWifiSmeCalibrationDataGetReqCreate(msg__, dst__, src__); \
+ CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \
+ }
+
+#define CsrWifiSmeCalibrationDataGetReqSend(src__) \
+ CsrWifiSmeCalibrationDataGetReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeCalibrationDataGetCfmSend
+
+ DESCRIPTION
+ This primitive reports the result of the request.
+
+ PARAMETERS
+ queue - Destination Task Queue
+ status - Reports the result of the request
+ calibrationDataLength - Number of bytes in the buffer pointed by
+ calibrationData
+ calibrationData - Pointer to a buffer of length calibrationDataLength
+ containing the calibration data
+
+*******************************************************************************/
+#define CsrWifiSmeCalibrationDataGetCfmCreate(msg__, dst__, src__, status__, calibrationDataLength__, calibrationData__) \
+ msg__ = kmalloc(sizeof(CsrWifiSmeCalibrationDataGetCfm), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_CALIBRATION_DATA_GET_CFM, dst__, src__); \
+ msg__->status = (status__); \
+ msg__->calibrationDataLength = (calibrationDataLength__); \
+ msg__->calibrationData = (calibrationData__);
+
+#define CsrWifiSmeCalibrationDataGetCfmSendTo(dst__, src__, status__, calibrationDataLength__, calibrationData__) \
+ { \
+ CsrWifiSmeCalibrationDataGetCfm *msg__; \
+ CsrWifiSmeCalibrationDataGetCfmCreate(msg__, dst__, src__, status__, calibrationDataLength__, calibrationData__); \
+ CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
+ }
+
+#define CsrWifiSmeCalibrationDataGetCfmSend(dst__, status__, calibrationDataLength__, calibrationData__) \
+ CsrWifiSmeCalibrationDataGetCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, status__, calibrationDataLength__, calibrationData__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeCalibrationDataSetReqSend
+
+ DESCRIPTION
+ This primitive sets the Wi-Fi radio calibration data.
+ The usage of the primitive with proper calibration data will avoid
+ time-consuming configuration after power-up.
+
+ PARAMETERS
+ queue - Message Source Task Queue (Cfm's will be sent to this Queue)
+ calibrationDataLength - Number of bytes in the buffer pointed by
+ calibrationData
+ calibrationData - Pointer to a buffer of length calibrationDataLength
+ containing the calibration data
+
+*******************************************************************************/
+#define CsrWifiSmeCalibrationDataSetReqCreate(msg__, dst__, src__, calibrationDataLength__, calibrationData__) \
+ msg__ = kmalloc(sizeof(CsrWifiSmeCalibrationDataSetReq), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_CALIBRATION_DATA_SET_REQ, dst__, src__); \
+ msg__->calibrationDataLength = (calibrationDataLength__); \
+ msg__->calibrationData = (calibrationData__);
+
+#define CsrWifiSmeCalibrationDataSetReqSendTo(dst__, src__, calibrationDataLength__, calibrationData__) \
+ { \
+ CsrWifiSmeCalibrationDataSetReq *msg__; \
+ CsrWifiSmeCalibrationDataSetReqCreate(msg__, dst__, src__, calibrationDataLength__, calibrationData__); \
+ CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \
+ }
+
+#define CsrWifiSmeCalibrationDataSetReqSend(src__, calibrationDataLength__, calibrationData__) \
+ CsrWifiSmeCalibrationDataSetReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__, calibrationDataLength__, calibrationData__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeCalibrationDataSetCfmSend
+
+ DESCRIPTION
+ This primitive reports the result of the request.
+
+ PARAMETERS
+ queue - Destination Task Queue
+ status - Reports the result of the request
+
+*******************************************************************************/
+#define CsrWifiSmeCalibrationDataSetCfmCreate(msg__, dst__, src__, status__) \
+ msg__ = kmalloc(sizeof(CsrWifiSmeCalibrationDataSetCfm), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_CALIBRATION_DATA_SET_CFM, dst__, src__); \
+ msg__->status = (status__);
+
+#define CsrWifiSmeCalibrationDataSetCfmSendTo(dst__, src__, status__) \
+ { \
+ CsrWifiSmeCalibrationDataSetCfm *msg__; \
+ CsrWifiSmeCalibrationDataSetCfmCreate(msg__, dst__, src__, status__); \
+ CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
+ }
+
+#define CsrWifiSmeCalibrationDataSetCfmSend(dst__, status__) \
+ CsrWifiSmeCalibrationDataSetCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, status__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeCcxConfigGetReqSend
+
+ DESCRIPTION
+ This primitive gets the value of the CcxConfig parameter.
+ CURRENTLY NOT SUPPORTED.
+
+ PARAMETERS
+ queue - Message Source Task Queue (Cfm's will be sent to this Queue)
+ interfaceTag - Interface Identifier; unique identifier of an interface
+
+*******************************************************************************/
+#define CsrWifiSmeCcxConfigGetReqCreate(msg__, dst__, src__, interfaceTag__) \
+ msg__ = kmalloc(sizeof(CsrWifiSmeCcxConfigGetReq), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_CCX_CONFIG_GET_REQ, dst__, src__); \
+ msg__->interfaceTag = (interfaceTag__);
+
+#define CsrWifiSmeCcxConfigGetReqSendTo(dst__, src__, interfaceTag__) \
+ { \
+ CsrWifiSmeCcxConfigGetReq *msg__; \
+ CsrWifiSmeCcxConfigGetReqCreate(msg__, dst__, src__, interfaceTag__); \
+ CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \
+ }
+
+#define CsrWifiSmeCcxConfigGetReqSend(src__, interfaceTag__) \
+ CsrWifiSmeCcxConfigGetReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__, interfaceTag__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeCcxConfigGetCfmSend
+
+ DESCRIPTION
+ This primitive reports the result of the request.
+
+ PARAMETERS
+ queue - Destination Task Queue
+ interfaceTag - Interface Identifier; unique identifier of an interface
+ status - Reports the result of the request
+ ccxConfig - Currently not supported
+
+*******************************************************************************/
+#define CsrWifiSmeCcxConfigGetCfmCreate(msg__, dst__, src__, interfaceTag__, status__, ccxConfig__) \
+ msg__ = kmalloc(sizeof(CsrWifiSmeCcxConfigGetCfm), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_CCX_CONFIG_GET_CFM, dst__, src__); \
+ msg__->interfaceTag = (interfaceTag__); \
+ msg__->status = (status__); \
+ msg__->ccxConfig = (ccxConfig__);
+
+#define CsrWifiSmeCcxConfigGetCfmSendTo(dst__, src__, interfaceTag__, status__, ccxConfig__) \
+ { \
+ CsrWifiSmeCcxConfigGetCfm *msg__; \
+ CsrWifiSmeCcxConfigGetCfmCreate(msg__, dst__, src__, interfaceTag__, status__, ccxConfig__); \
+ CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
+ }
+
+#define CsrWifiSmeCcxConfigGetCfmSend(dst__, interfaceTag__, status__, ccxConfig__) \
+ CsrWifiSmeCcxConfigGetCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, interfaceTag__, status__, ccxConfig__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeCcxConfigSetReqSend
+
+ DESCRIPTION
+ This primitive sets the value of the CcxConfig parameter.
+ CURRENTLY NOT SUPPORTED.
+
+ PARAMETERS
+ queue - Message Source Task Queue (Cfm's will be sent to this Queue)
+ interfaceTag - Interface Identifier; unique identifier of an interface
+ ccxConfig - Currently not supported
+
+*******************************************************************************/
+#define CsrWifiSmeCcxConfigSetReqCreate(msg__, dst__, src__, interfaceTag__, ccxConfig__) \
+ msg__ = kmalloc(sizeof(CsrWifiSmeCcxConfigSetReq), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_CCX_CONFIG_SET_REQ, dst__, src__); \
+ msg__->interfaceTag = (interfaceTag__); \
+ msg__->ccxConfig = (ccxConfig__);
+
+#define CsrWifiSmeCcxConfigSetReqSendTo(dst__, src__, interfaceTag__, ccxConfig__) \
+ { \
+ CsrWifiSmeCcxConfigSetReq *msg__; \
+ CsrWifiSmeCcxConfigSetReqCreate(msg__, dst__, src__, interfaceTag__, ccxConfig__); \
+ CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \
+ }
+
+#define CsrWifiSmeCcxConfigSetReqSend(src__, interfaceTag__, ccxConfig__) \
+ CsrWifiSmeCcxConfigSetReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__, interfaceTag__, ccxConfig__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeCcxConfigSetCfmSend
+
+ DESCRIPTION
+ This primitive reports the result of the request.
+
+ PARAMETERS
+ queue - Destination Task Queue
+ interfaceTag - Interface Identifier; unique identifier of an interface
+ status - Reports the result of the request
+
+*******************************************************************************/
+#define CsrWifiSmeCcxConfigSetCfmCreate(msg__, dst__, src__, interfaceTag__, status__) \
+ msg__ = kmalloc(sizeof(CsrWifiSmeCcxConfigSetCfm), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_CCX_CONFIG_SET_CFM, dst__, src__); \
+ msg__->interfaceTag = (interfaceTag__); \
+ msg__->status = (status__);
+
+#define CsrWifiSmeCcxConfigSetCfmSendTo(dst__, src__, interfaceTag__, status__) \
+ { \
+ CsrWifiSmeCcxConfigSetCfm *msg__; \
+ CsrWifiSmeCcxConfigSetCfmCreate(msg__, dst__, src__, interfaceTag__, status__); \
+ CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
+ }
+
+#define CsrWifiSmeCcxConfigSetCfmSend(dst__, interfaceTag__, status__) \
+ CsrWifiSmeCcxConfigSetCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, interfaceTag__, status__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeCloakedSsidsGetReqSend
+
+ DESCRIPTION
+ This primitive gets the value of the CloakedSsids parameter.
+
+ PARAMETERS
+ queue - Message Source Task Queue (Cfm's will be sent to this Queue)
+
+*******************************************************************************/
+#define CsrWifiSmeCloakedSsidsGetReqCreate(msg__, dst__, src__) \
+ msg__ = kmalloc(sizeof(CsrWifiSmeCloakedSsidsGetReq), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_CLOAKED_SSIDS_GET_REQ, dst__, src__);
+
+#define CsrWifiSmeCloakedSsidsGetReqSendTo(dst__, src__) \
+ { \
+ CsrWifiSmeCloakedSsidsGetReq *msg__; \
+ CsrWifiSmeCloakedSsidsGetReqCreate(msg__, dst__, src__); \
+ CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \
+ }
+
+#define CsrWifiSmeCloakedSsidsGetReqSend(src__) \
+ CsrWifiSmeCloakedSsidsGetReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeCloakedSsidsGetCfmSend
+
+ DESCRIPTION
+ This primitive reports the result of the request.
+
+ PARAMETERS
+ queue - Destination Task Queue
+ status - Reports the result of the request
+ cloakedSsids - Reports list of cloaked SSIDs that are explicitly scanned for
+ by the driver
+
+*******************************************************************************/
+#define CsrWifiSmeCloakedSsidsGetCfmCreate(msg__, dst__, src__, status__, cloakedSsids__) \
+ msg__ = kmalloc(sizeof(CsrWifiSmeCloakedSsidsGetCfm), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_CLOAKED_SSIDS_GET_CFM, dst__, src__); \
+ msg__->status = (status__); \
+ msg__->cloakedSsids = (cloakedSsids__);
+
+#define CsrWifiSmeCloakedSsidsGetCfmSendTo(dst__, src__, status__, cloakedSsids__) \
+ { \
+ CsrWifiSmeCloakedSsidsGetCfm *msg__; \
+ CsrWifiSmeCloakedSsidsGetCfmCreate(msg__, dst__, src__, status__, cloakedSsids__); \
+ CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
+ }
+
+#define CsrWifiSmeCloakedSsidsGetCfmSend(dst__, status__, cloakedSsids__) \
+ CsrWifiSmeCloakedSsidsGetCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, status__, cloakedSsids__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeCloakedSsidsSetReqSend
+
+ DESCRIPTION
+ This primitive sets the list of cloaked SSIDs for which the WMA possesses
+ profiles.
+ When the driver detects a cloaked AP, the SME will explicitly scan for it
+ using the list of cloaked SSIDs provided it, and, if the scan succeeds,
+ it will report the AP to the WMA either via CSR_WIFI_SME_SCAN_RESULT_IND
+ (if registered) or via CSR_WIFI_SCAN_RESULT_GET_CFM.
+
+ PARAMETERS
+ queue - Message Source Task Queue (Cfm's will be sent to this Queue)
+ cloakedSsids - Sets the list of cloaked SSIDs
+
+*******************************************************************************/
+#define CsrWifiSmeCloakedSsidsSetReqCreate(msg__, dst__, src__, cloakedSsids__) \
+ msg__ = kmalloc(sizeof(CsrWifiSmeCloakedSsidsSetReq), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_CLOAKED_SSIDS_SET_REQ, dst__, src__); \
+ msg__->cloakedSsids = (cloakedSsids__);
+
+#define CsrWifiSmeCloakedSsidsSetReqSendTo(dst__, src__, cloakedSsids__) \
+ { \
+ CsrWifiSmeCloakedSsidsSetReq *msg__; \
+ CsrWifiSmeCloakedSsidsSetReqCreate(msg__, dst__, src__, cloakedSsids__); \
+ CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \
+ }
+
+#define CsrWifiSmeCloakedSsidsSetReqSend(src__, cloakedSsids__) \
+ CsrWifiSmeCloakedSsidsSetReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__, cloakedSsids__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeCloakedSsidsSetCfmSend
+
+ DESCRIPTION
+ This primitive reports the result of the request.
+
+ PARAMETERS
+ queue - Destination Task Queue
+ status - Reports the result of the request
+
+*******************************************************************************/
+#define CsrWifiSmeCloakedSsidsSetCfmCreate(msg__, dst__, src__, status__) \
+ msg__ = kmalloc(sizeof(CsrWifiSmeCloakedSsidsSetCfm), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_CLOAKED_SSIDS_SET_CFM, dst__, src__); \
+ msg__->status = (status__);
+
+#define CsrWifiSmeCloakedSsidsSetCfmSendTo(dst__, src__, status__) \
+ { \
+ CsrWifiSmeCloakedSsidsSetCfm *msg__; \
+ CsrWifiSmeCloakedSsidsSetCfmCreate(msg__, dst__, src__, status__); \
+ CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
+ }
+
+#define CsrWifiSmeCloakedSsidsSetCfmSend(dst__, status__) \
+ CsrWifiSmeCloakedSsidsSetCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, status__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeCoexConfigGetReqSend
+
+ DESCRIPTION
+ This primitive gets the value of the CoexConfig parameter.
+
+ PARAMETERS
+ queue - Message Source Task Queue (Cfm's will be sent to this Queue)
+
+*******************************************************************************/
+#define CsrWifiSmeCoexConfigGetReqCreate(msg__, dst__, src__) \
+ msg__ = kmalloc(sizeof(CsrWifiSmeCoexConfigGetReq), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_COEX_CONFIG_GET_REQ, dst__, src__);
+
+#define CsrWifiSmeCoexConfigGetReqSendTo(dst__, src__) \
+ { \
+ CsrWifiSmeCoexConfigGetReq *msg__; \
+ CsrWifiSmeCoexConfigGetReqCreate(msg__, dst__, src__); \
+ CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \
+ }
+
+#define CsrWifiSmeCoexConfigGetReqSend(src__) \
+ CsrWifiSmeCoexConfigGetReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeCoexConfigGetCfmSend
+
+ DESCRIPTION
+ This primitive reports the result of the request.
+
+ PARAMETERS
+ queue - Destination Task Queue
+ status - Reports the result of the request
+ coexConfig - Reports the parameters used to configure the coexistence
+ behaviour
+
+*******************************************************************************/
+#define CsrWifiSmeCoexConfigGetCfmCreate(msg__, dst__, src__, status__, coexConfig__) \
+ msg__ = kmalloc(sizeof(CsrWifiSmeCoexConfigGetCfm), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_COEX_CONFIG_GET_CFM, dst__, src__); \
+ msg__->status = (status__); \
+ msg__->coexConfig = (coexConfig__);
+
+#define CsrWifiSmeCoexConfigGetCfmSendTo(dst__, src__, status__, coexConfig__) \
+ { \
+ CsrWifiSmeCoexConfigGetCfm *msg__; \
+ CsrWifiSmeCoexConfigGetCfmCreate(msg__, dst__, src__, status__, coexConfig__); \
+ CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
+ }
+
+#define CsrWifiSmeCoexConfigGetCfmSend(dst__, status__, coexConfig__) \
+ CsrWifiSmeCoexConfigGetCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, status__, coexConfig__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeCoexConfigSetReqSend
+
+ DESCRIPTION
+ This primitive sets the value of the CoexConfig parameter.
+
+ PARAMETERS
+ queue - Message Source Task Queue (Cfm's will be sent to this Queue)
+ coexConfig - Configures the coexistence behaviour
+
+*******************************************************************************/
+#define CsrWifiSmeCoexConfigSetReqCreate(msg__, dst__, src__, coexConfig__) \
+ msg__ = kmalloc(sizeof(CsrWifiSmeCoexConfigSetReq), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_COEX_CONFIG_SET_REQ, dst__, src__); \
+ msg__->coexConfig = (coexConfig__);
+
+#define CsrWifiSmeCoexConfigSetReqSendTo(dst__, src__, coexConfig__) \
+ { \
+ CsrWifiSmeCoexConfigSetReq *msg__; \
+ CsrWifiSmeCoexConfigSetReqCreate(msg__, dst__, src__, coexConfig__); \
+ CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \
+ }
+
+#define CsrWifiSmeCoexConfigSetReqSend(src__, coexConfig__) \
+ CsrWifiSmeCoexConfigSetReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__, coexConfig__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeCoexConfigSetCfmSend
+
+ DESCRIPTION
+ This primitive reports the result of the request.
+
+ PARAMETERS
+ queue - Destination Task Queue
+ status - Reports the result of the request
+
+*******************************************************************************/
+#define CsrWifiSmeCoexConfigSetCfmCreate(msg__, dst__, src__, status__) \
+ msg__ = kmalloc(sizeof(CsrWifiSmeCoexConfigSetCfm), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_COEX_CONFIG_SET_CFM, dst__, src__); \
+ msg__->status = (status__);
+
+#define CsrWifiSmeCoexConfigSetCfmSendTo(dst__, src__, status__) \
+ { \
+ CsrWifiSmeCoexConfigSetCfm *msg__; \
+ CsrWifiSmeCoexConfigSetCfmCreate(msg__, dst__, src__, status__); \
+ CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
+ }
+
+#define CsrWifiSmeCoexConfigSetCfmSend(dst__, status__) \
+ CsrWifiSmeCoexConfigSetCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, status__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeCoexInfoGetReqSend
+
+ DESCRIPTION
+ This primitive gets the value of the CoexInfo parameter.
+
+ PARAMETERS
+ queue - Message Source Task Queue (Cfm's will be sent to this Queue)
+
+*******************************************************************************/
+#define CsrWifiSmeCoexInfoGetReqCreate(msg__, dst__, src__) \
+ msg__ = kmalloc(sizeof(CsrWifiSmeCoexInfoGetReq), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_COEX_INFO_GET_REQ, dst__, src__);
+
+#define CsrWifiSmeCoexInfoGetReqSendTo(dst__, src__) \
+ { \
+ CsrWifiSmeCoexInfoGetReq *msg__; \
+ CsrWifiSmeCoexInfoGetReqCreate(msg__, dst__, src__); \
+ CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \
+ }
+
+#define CsrWifiSmeCoexInfoGetReqSend(src__) \
+ CsrWifiSmeCoexInfoGetReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeCoexInfoGetCfmSend
+
+ DESCRIPTION
+ This primitive reports the result of the request.
+
+ PARAMETERS
+ queue - Destination Task Queue
+ status - Reports the result of the request
+ coexInfo - Reports information and state related to coexistence.
+
+*******************************************************************************/
+#define CsrWifiSmeCoexInfoGetCfmCreate(msg__, dst__, src__, status__, coexInfo__) \
+ msg__ = kmalloc(sizeof(CsrWifiSmeCoexInfoGetCfm), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_COEX_INFO_GET_CFM, dst__, src__); \
+ msg__->status = (status__); \
+ msg__->coexInfo = (coexInfo__);
+
+#define CsrWifiSmeCoexInfoGetCfmSendTo(dst__, src__, status__, coexInfo__) \
+ { \
+ CsrWifiSmeCoexInfoGetCfm *msg__; \
+ CsrWifiSmeCoexInfoGetCfmCreate(msg__, dst__, src__, status__, coexInfo__); \
+ CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
+ }
+
+#define CsrWifiSmeCoexInfoGetCfmSend(dst__, status__, coexInfo__) \
+ CsrWifiSmeCoexInfoGetCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, status__, coexInfo__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeConnectReqSend
+
+ DESCRIPTION
+ The wireless manager application calls this primitive to start the
+ process of joining an 802.11 wireless network or to start an ad hoc
+ network.
+ The structure pointed by connectionConfig contains parameters describing
+ the network to join or, in case of an ad hoc network, to host or join.
+ The SME will select a network, perform the IEEE 802.11 Join, Authenticate
+ and Associate exchanges.
+ The SME selects the networks from the current scan list that match both
+ the SSID and BSSID, however either or both of these may be the wildcard
+ value. Using this rule, the following operations are possible:
+ * To connect to a network by name, specify the SSID and set the BSSID to
+ 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF. If there are two or more networks visible,
+ the SME will select the one with the strongest signal.
+ * To connect to a specific network, specify the BSSID. The SSID is
+ optional, but if given it must match the SSID of the network. An empty
+ SSID may be specified by setting the SSID length to zero. Please note
+ that if the BSSID is specified (i.e. not equal to 0xFF 0xFF 0xFF 0xFF
+ 0xFF 0xFF), the SME will not attempt to roam if signal conditions become
+ poor, even if there is an alternative AP with an SSID that matches the
+ current network SSID.
+ * To connect to any network matching the other parameters (i.e. security,
+ etc), set the SSID length to zero and set the BSSID to 0xFF 0xFF 0xFF
+ 0xFF 0xFF 0xFF. In this case, the SME will order all available networks
+ by their signal strengths and will iterate through this list until it
+ successfully connects.
+ NOTE: Specifying the BSSID will restrict the selection to one specific
+ network. If SSID and BSSID are given, they must both match the network
+ for it to be selected. To select a network based on the SSID only, the
+ wireless manager application must set the BSSID to 0xFF 0xFF 0xFF 0xFF
+ 0xFF 0xFF.
+ The SME will try to connect to each network that matches the provided
+ parameters, one by one, until it succeeds or has tried unsuccessfully
+ with all the matching networks.
+ If there is no network that matches the parameters and the request allows
+ to host an ad hoc network, the SME will advertise a new ad hoc network
+ instead.
+ If the SME cannot connect, it will notify the failure in the confirm.
+
+ PARAMETERS
+ queue - Message Source Task Queue (Cfm's will be sent to this Queue)
+ interfaceTag - Interface Identifier; unique identifier of an interface
+ connectionConfig - Describes the candidate network to join or to host.
+
+*******************************************************************************/
+#define CsrWifiSmeConnectReqCreate(msg__, dst__, src__, interfaceTag__, connectionConfig__) \
+ msg__ = kmalloc(sizeof(CsrWifiSmeConnectReq), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_CONNECT_REQ, dst__, src__); \
+ msg__->interfaceTag = (interfaceTag__); \
+ msg__->connectionConfig = (connectionConfig__);
+
+#define CsrWifiSmeConnectReqSendTo(dst__, src__, interfaceTag__, connectionConfig__) \
+ { \
+ CsrWifiSmeConnectReq *msg__; \
+ CsrWifiSmeConnectReqCreate(msg__, dst__, src__, interfaceTag__, connectionConfig__); \
+ CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \
+ }
+
+#define CsrWifiSmeConnectReqSend(src__, interfaceTag__, connectionConfig__) \
+ CsrWifiSmeConnectReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__, interfaceTag__, connectionConfig__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeConnectCfmSend
+
+ DESCRIPTION
+ The SME calls this primitive when the connection exchange is complete or
+ all connection attempts fail.
+
+ PARAMETERS
+ queue - Destination Task Queue
+ interfaceTag - Interface Identifier; unique identifier of an interface
+ status - Reports the result of the request.
+ CSR_WIFI_SME_STATUS_NOT_FOUND: all attempts by the SME to
+ locate the requested AP failed
+
+*******************************************************************************/
+#define CsrWifiSmeConnectCfmCreate(msg__, dst__, src__, interfaceTag__, status__) \
+ msg__ = kmalloc(sizeof(CsrWifiSmeConnectCfm), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_CONNECT_CFM, dst__, src__); \
+ msg__->interfaceTag = (interfaceTag__); \
+ msg__->status = (status__);
+
+#define CsrWifiSmeConnectCfmSendTo(dst__, src__, interfaceTag__, status__) \
+ { \
+ CsrWifiSmeConnectCfm *msg__; \
+ CsrWifiSmeConnectCfmCreate(msg__, dst__, src__, interfaceTag__, status__); \
+ CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
+ }
+
+#define CsrWifiSmeConnectCfmSend(dst__, interfaceTag__, status__) \
+ CsrWifiSmeConnectCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, interfaceTag__, status__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeConnectionConfigGetReqSend
+
+ DESCRIPTION
+ This primitive gets the value of the ConnectionConfig parameter.
+
+ PARAMETERS
+ queue - Message Source Task Queue (Cfm's will be sent to this Queue)
+ interfaceTag - Interface Identifier; unique identifier of an interface
+
+*******************************************************************************/
+#define CsrWifiSmeConnectionConfigGetReqCreate(msg__, dst__, src__, interfaceTag__) \
+ msg__ = kmalloc(sizeof(CsrWifiSmeConnectionConfigGetReq), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_CONNECTION_CONFIG_GET_REQ, dst__, src__); \
+ msg__->interfaceTag = (interfaceTag__);
+
+#define CsrWifiSmeConnectionConfigGetReqSendTo(dst__, src__, interfaceTag__) \
+ { \
+ CsrWifiSmeConnectionConfigGetReq *msg__; \
+ CsrWifiSmeConnectionConfigGetReqCreate(msg__, dst__, src__, interfaceTag__); \
+ CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \
+ }
+
+#define CsrWifiSmeConnectionConfigGetReqSend(src__, interfaceTag__) \
+ CsrWifiSmeConnectionConfigGetReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__, interfaceTag__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeConnectionConfigGetCfmSend
+
+ DESCRIPTION
+ This primitive reports the result of the request.
+
+ PARAMETERS
+ queue - Destination Task Queue
+ interfaceTag - Interface Identifier; unique identifier of an interface
+ status - Reports the result of the request
+ connectionConfig - Parameters used by the SME for selecting a network
+
+*******************************************************************************/
+#define CsrWifiSmeConnectionConfigGetCfmCreate(msg__, dst__, src__, interfaceTag__, status__, connectionConfig__) \
+ msg__ = kmalloc(sizeof(CsrWifiSmeConnectionConfigGetCfm), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_CONNECTION_CONFIG_GET_CFM, dst__, src__); \
+ msg__->interfaceTag = (interfaceTag__); \
+ msg__->status = (status__); \
+ msg__->connectionConfig = (connectionConfig__);
+
+#define CsrWifiSmeConnectionConfigGetCfmSendTo(dst__, src__, interfaceTag__, status__, connectionConfig__) \
+ { \
+ CsrWifiSmeConnectionConfigGetCfm *msg__; \
+ CsrWifiSmeConnectionConfigGetCfmCreate(msg__, dst__, src__, interfaceTag__, status__, connectionConfig__); \
+ CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
+ }
+
+#define CsrWifiSmeConnectionConfigGetCfmSend(dst__, interfaceTag__, status__, connectionConfig__) \
+ CsrWifiSmeConnectionConfigGetCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, interfaceTag__, status__, connectionConfig__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeConnectionInfoGetReqSend
+
+ DESCRIPTION
+ This primitive gets the value of the ConnectionInfo parameter.
+
+ PARAMETERS
+ queue - Message Source Task Queue (Cfm's will be sent to this Queue)
+ interfaceTag - Interface Identifier; unique identifier of an interface
+
+*******************************************************************************/
+#define CsrWifiSmeConnectionInfoGetReqCreate(msg__, dst__, src__, interfaceTag__) \
+ msg__ = kmalloc(sizeof(CsrWifiSmeConnectionInfoGetReq), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_CONNECTION_INFO_GET_REQ, dst__, src__); \
+ msg__->interfaceTag = (interfaceTag__);
+
+#define CsrWifiSmeConnectionInfoGetReqSendTo(dst__, src__, interfaceTag__) \
+ { \
+ CsrWifiSmeConnectionInfoGetReq *msg__; \
+ CsrWifiSmeConnectionInfoGetReqCreate(msg__, dst__, src__, interfaceTag__); \
+ CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \
+ }
+
+#define CsrWifiSmeConnectionInfoGetReqSend(src__, interfaceTag__) \
+ CsrWifiSmeConnectionInfoGetReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__, interfaceTag__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeConnectionInfoGetCfmSend
+
+ DESCRIPTION
+ This primitive reports the result of the request.
+
+ PARAMETERS
+ queue - Destination Task Queue
+ interfaceTag - Interface Identifier; unique identifier of an interface
+ status - Reports the result of the request
+ connectionInfo - Information about the current connection
+
+*******************************************************************************/
+#define CsrWifiSmeConnectionInfoGetCfmCreate(msg__, dst__, src__, interfaceTag__, status__, connectionInfo__) \
+ msg__ = kmalloc(sizeof(CsrWifiSmeConnectionInfoGetCfm), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_CONNECTION_INFO_GET_CFM, dst__, src__); \
+ msg__->interfaceTag = (interfaceTag__); \
+ msg__->status = (status__); \
+ msg__->connectionInfo = (connectionInfo__);
+
+#define CsrWifiSmeConnectionInfoGetCfmSendTo(dst__, src__, interfaceTag__, status__, connectionInfo__) \
+ { \
+ CsrWifiSmeConnectionInfoGetCfm *msg__; \
+ CsrWifiSmeConnectionInfoGetCfmCreate(msg__, dst__, src__, interfaceTag__, status__, connectionInfo__); \
+ CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
+ }
+
+#define CsrWifiSmeConnectionInfoGetCfmSend(dst__, interfaceTag__, status__, connectionInfo__) \
+ CsrWifiSmeConnectionInfoGetCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, interfaceTag__, status__, connectionInfo__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeConnectionQualityIndSend
+
+ DESCRIPTION
+ The SME sends this primitive to all the tasks that have registered to
+ receive it whenever the value of the current connection quality
+ parameters change by more than a certain configurable amount.
+ The wireless manager application may configure the trigger thresholds for
+ this indication using the field in smeConfig parameter of
+ CSR_WIFI_SME_SME_CONFIG_SET_REQ.
+ Connection quality messages can be suppressed by setting both thresholds
+ to zero.
+
+ PARAMETERS
+ queue - Destination Task Queue
+ interfaceTag - Interface Identifier; unique identifier of an interface
+ linkQuality - Indicates the quality of the link
+
+*******************************************************************************/
+#define CsrWifiSmeConnectionQualityIndCreate(msg__, dst__, src__, interfaceTag__, linkQuality__) \
+ msg__ = kmalloc(sizeof(CsrWifiSmeConnectionQualityInd), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_CONNECTION_QUALITY_IND, dst__, src__); \
+ msg__->interfaceTag = (interfaceTag__); \
+ msg__->linkQuality = (linkQuality__);
+
+#define CsrWifiSmeConnectionQualityIndSendTo(dst__, src__, interfaceTag__, linkQuality__) \
+ { \
+ CsrWifiSmeConnectionQualityInd *msg__; \
+ CsrWifiSmeConnectionQualityIndCreate(msg__, dst__, src__, interfaceTag__, linkQuality__); \
+ CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
+ }
+
+#define CsrWifiSmeConnectionQualityIndSend(dst__, interfaceTag__, linkQuality__) \
+ CsrWifiSmeConnectionQualityIndSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, interfaceTag__, linkQuality__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeConnectionStatsGetReqSend
+
+ DESCRIPTION
+ This primitive gets the value of the ConnectionStats parameter.
+
+ PARAMETERS
+ queue - Message Source Task Queue (Cfm's will be sent to this Queue)
+ interfaceTag - Interface Identifier; unique identifier of an interface
+
+*******************************************************************************/
+#define CsrWifiSmeConnectionStatsGetReqCreate(msg__, dst__, src__, interfaceTag__) \
+ msg__ = kmalloc(sizeof(CsrWifiSmeConnectionStatsGetReq), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_CONNECTION_STATS_GET_REQ, dst__, src__); \
+ msg__->interfaceTag = (interfaceTag__);
+
+#define CsrWifiSmeConnectionStatsGetReqSendTo(dst__, src__, interfaceTag__) \
+ { \
+ CsrWifiSmeConnectionStatsGetReq *msg__; \
+ CsrWifiSmeConnectionStatsGetReqCreate(msg__, dst__, src__, interfaceTag__); \
+ CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \
+ }
+
+#define CsrWifiSmeConnectionStatsGetReqSend(src__, interfaceTag__) \
+ CsrWifiSmeConnectionStatsGetReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__, interfaceTag__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeConnectionStatsGetCfmSend
+
+ DESCRIPTION
+ This primitive reports the result of the request.
+
+ PARAMETERS
+ queue - Destination Task Queue
+ interfaceTag - Interface Identifier; unique identifier of an interface
+ status - Reports the result of the request
+ connectionStats - Statistics for current connection.
+
+*******************************************************************************/
+#define CsrWifiSmeConnectionStatsGetCfmCreate(msg__, dst__, src__, interfaceTag__, status__, connectionStats__) \
+ msg__ = kmalloc(sizeof(CsrWifiSmeConnectionStatsGetCfm), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_CONNECTION_STATS_GET_CFM, dst__, src__); \
+ msg__->interfaceTag = (interfaceTag__); \
+ msg__->status = (status__); \
+ msg__->connectionStats = (connectionStats__);
+
+#define CsrWifiSmeConnectionStatsGetCfmSendTo(dst__, src__, interfaceTag__, status__, connectionStats__) \
+ { \
+ CsrWifiSmeConnectionStatsGetCfm *msg__; \
+ CsrWifiSmeConnectionStatsGetCfmCreate(msg__, dst__, src__, interfaceTag__, status__, connectionStats__); \
+ CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
+ }
+
+#define CsrWifiSmeConnectionStatsGetCfmSend(dst__, interfaceTag__, status__, connectionStats__) \
+ CsrWifiSmeConnectionStatsGetCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, interfaceTag__, status__, connectionStats__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeCoreDumpIndSend
+
+ DESCRIPTION
+ The SME will send this primitive to all the tasks that have registered to
+ receive Wi-Fi Chip core dump data.
+ The core dump data may be fragmented and sent using more than one
+ indication.
+ To indicate that all the data has been sent, the last indication contains
+ a 'length' of 0 and 'data' of NULL.
+
+ PARAMETERS
+ queue - Destination Task Queue
+ dataLength - Number of bytes in the buffer pointed to by 'data'
+ data - Pointer to the buffer containing 'dataLength' bytes of core
+ dump data
+
+*******************************************************************************/
+#define CsrWifiSmeCoreDumpIndCreate(msg__, dst__, src__, dataLength__, data__) \
+ msg__ = kmalloc(sizeof(CsrWifiSmeCoreDumpInd), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_CORE_DUMP_IND, dst__, src__); \
+ msg__->dataLength = (dataLength__); \
+ msg__->data = (data__);
+
+#define CsrWifiSmeCoreDumpIndSendTo(dst__, src__, dataLength__, data__) \
+ { \
+ CsrWifiSmeCoreDumpInd *msg__; \
+ CsrWifiSmeCoreDumpIndCreate(msg__, dst__, src__, dataLength__, data__); \
+ CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
+ }
+
+#define CsrWifiSmeCoreDumpIndSend(dst__, dataLength__, data__) \
+ CsrWifiSmeCoreDumpIndSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, dataLength__, data__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeDeactivateReqSend
+
+ DESCRIPTION
+ The WMA sends this primitive to deactivate the SME.
+
+ PARAMETERS
+ queue - Message Source Task Queue (Cfm's will be sent to this Queue)
+
+*******************************************************************************/
+#define CsrWifiSmeDeactivateReqCreate(msg__, dst__, src__) \
+ msg__ = kmalloc(sizeof(CsrWifiSmeDeactivateReq), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_DEACTIVATE_REQ, dst__, src__);
+
+#define CsrWifiSmeDeactivateReqSendTo(dst__, src__) \
+ { \
+ CsrWifiSmeDeactivateReq *msg__; \
+ CsrWifiSmeDeactivateReqCreate(msg__, dst__, src__); \
+ CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \
+ }
+
+#define CsrWifiSmeDeactivateReqSend(src__) \
+ CsrWifiSmeDeactivateReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeDeactivateCfmSend
+
+ DESCRIPTION
+ The SME sends this primitive when the deactivation is complete.
+ The WMA cannot send any more primitives until it actives the SME again
+ sending another CSR_WIFI_SME_ACTIVATE_REQ.
+
+ PARAMETERS
+ queue - Destination Task Queue
+ status - Reports the result of the request
+
+*******************************************************************************/
+#define CsrWifiSmeDeactivateCfmCreate(msg__, dst__, src__, status__) \
+ msg__ = kmalloc(sizeof(CsrWifiSmeDeactivateCfm), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_DEACTIVATE_CFM, dst__, src__); \
+ msg__->status = (status__);
+
+#define CsrWifiSmeDeactivateCfmSendTo(dst__, src__, status__) \
+ { \
+ CsrWifiSmeDeactivateCfm *msg__; \
+ CsrWifiSmeDeactivateCfmCreate(msg__, dst__, src__, status__); \
+ CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
+ }
+
+#define CsrWifiSmeDeactivateCfmSend(dst__, status__) \
+ CsrWifiSmeDeactivateCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, status__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeDisconnectReqSend
+
+ DESCRIPTION
+ The wireless manager application may disconnect from the current network
+ by calling this primitive
+
+ PARAMETERS
+ queue - Message Source Task Queue (Cfm's will be sent to this Queue)
+ interfaceTag - Interface Identifier; unique identifier of an interface
+
+*******************************************************************************/
+#define CsrWifiSmeDisconnectReqCreate(msg__, dst__, src__, interfaceTag__) \
+ msg__ = kmalloc(sizeof(CsrWifiSmeDisconnectReq), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_DISCONNECT_REQ, dst__, src__); \
+ msg__->interfaceTag = (interfaceTag__);
+
+#define CsrWifiSmeDisconnectReqSendTo(dst__, src__, interfaceTag__) \
+ { \
+ CsrWifiSmeDisconnectReq *msg__; \
+ CsrWifiSmeDisconnectReqCreate(msg__, dst__, src__, interfaceTag__); \
+ CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \
+ }
+
+#define CsrWifiSmeDisconnectReqSend(src__, interfaceTag__) \
+ CsrWifiSmeDisconnectReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__, interfaceTag__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeDisconnectCfmSend
+
+ DESCRIPTION
+ On reception of CSR_WIFI_SME_DISCONNECT_REQ the SME will perform a
+ disconnect operation, sending a CsrWifiSmeMediaStatusInd with
+ CSR_WIFI_SME_MEDIA_STATUS_DISCONNECTED and then call this primitive when
+ disconnection is complete.
+
+ PARAMETERS
+ queue - Destination Task Queue
+ interfaceTag - Interface Identifier; unique identifier of an interface
+ status - Reports the result of the request
+
+*******************************************************************************/
+#define CsrWifiSmeDisconnectCfmCreate(msg__, dst__, src__, interfaceTag__, status__) \
+ msg__ = kmalloc(sizeof(CsrWifiSmeDisconnectCfm), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_DISCONNECT_CFM, dst__, src__); \
+ msg__->interfaceTag = (interfaceTag__); \
+ msg__->status = (status__);
+
+#define CsrWifiSmeDisconnectCfmSendTo(dst__, src__, interfaceTag__, status__) \
+ { \
+ CsrWifiSmeDisconnectCfm *msg__; \
+ CsrWifiSmeDisconnectCfmCreate(msg__, dst__, src__, interfaceTag__, status__); \
+ CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
+ }
+
+#define CsrWifiSmeDisconnectCfmSend(dst__, interfaceTag__, status__) \
+ CsrWifiSmeDisconnectCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, interfaceTag__, status__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeErrorIndSend
+
+ DESCRIPTION
+ Important error message indicating a error of some importance
+
+ PARAMETERS
+ queue - Destination Task Queue
+ errorMessage - Contains the error message.
+
+*******************************************************************************/
+#define CsrWifiSmeErrorIndCreate(msg__, dst__, src__, errorMessage__) \
+ msg__ = kmalloc(sizeof(CsrWifiSmeErrorInd), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_ERROR_IND, dst__, src__); \
+ msg__->errorMessage = (errorMessage__);
+
+#define CsrWifiSmeErrorIndSendTo(dst__, src__, errorMessage__) \
+ { \
+ CsrWifiSmeErrorInd *msg__; \
+ CsrWifiSmeErrorIndCreate(msg__, dst__, src__, errorMessage__); \
+ CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
+ }
+
+#define CsrWifiSmeErrorIndSend(dst__, errorMessage__) \
+ CsrWifiSmeErrorIndSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, errorMessage__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeEventMaskSetReqSend
+
+ DESCRIPTION
+ The wireless manager application may register with the SME to receive
+ notification of interesting events. Indications will be sent only if the
+ wireless manager explicitly registers to be notified of that event.
+ indMask is a bit mask of values defined in CsrWifiSmeIndicationsMask.
+
+ PARAMETERS
+ queue - Message Source Task Queue (Cfm's will be sent to this Queue)
+ indMask - Set mask with values from CsrWifiSmeIndications
+
+*******************************************************************************/
+#define CsrWifiSmeEventMaskSetReqCreate(msg__, dst__, src__, indMask__) \
+ msg__ = kmalloc(sizeof(CsrWifiSmeEventMaskSetReq), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_EVENT_MASK_SET_REQ, dst__, src__); \
+ msg__->indMask = (indMask__);
+
+#define CsrWifiSmeEventMaskSetReqSendTo(dst__, src__, indMask__) \
+ { \
+ CsrWifiSmeEventMaskSetReq *msg__; \
+ CsrWifiSmeEventMaskSetReqCreate(msg__, dst__, src__, indMask__); \
+ CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \
+ }
+
+#define CsrWifiSmeEventMaskSetReqSend(src__, indMask__) \
+ CsrWifiSmeEventMaskSetReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__, indMask__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeEventMaskSetCfmSend
+
+ DESCRIPTION
+ The SME calls the primitive to report the result of the request
+ primitive.
+
+ PARAMETERS
+ queue - Destination Task Queue
+ status - Reports the result of the request
+
+*******************************************************************************/
+#define CsrWifiSmeEventMaskSetCfmCreate(msg__, dst__, src__, status__) \
+ msg__ = kmalloc(sizeof(CsrWifiSmeEventMaskSetCfm), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_EVENT_MASK_SET_CFM, dst__, src__); \
+ msg__->status = (status__);
+
+#define CsrWifiSmeEventMaskSetCfmSendTo(dst__, src__, status__) \
+ { \
+ CsrWifiSmeEventMaskSetCfm *msg__; \
+ CsrWifiSmeEventMaskSetCfmCreate(msg__, dst__, src__, status__); \
+ CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
+ }
+
+#define CsrWifiSmeEventMaskSetCfmSend(dst__, status__) \
+ CsrWifiSmeEventMaskSetCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, status__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeHostConfigGetReqSend
+
+ DESCRIPTION
+ This primitive gets the value of the hostConfig parameter.
+
+ PARAMETERS
+ queue - Message Source Task Queue (Cfm's will be sent to this Queue)
+ interfaceTag - Interface Identifier; unique identifier of an interface
+
+*******************************************************************************/
+#define CsrWifiSmeHostConfigGetReqCreate(msg__, dst__, src__, interfaceTag__) \
+ msg__ = kmalloc(sizeof(CsrWifiSmeHostConfigGetReq), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_HOST_CONFIG_GET_REQ, dst__, src__); \
+ msg__->interfaceTag = (interfaceTag__);
+
+#define CsrWifiSmeHostConfigGetReqSendTo(dst__, src__, interfaceTag__) \
+ { \
+ CsrWifiSmeHostConfigGetReq *msg__; \
+ CsrWifiSmeHostConfigGetReqCreate(msg__, dst__, src__, interfaceTag__); \
+ CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \
+ }
+
+#define CsrWifiSmeHostConfigGetReqSend(src__, interfaceTag__) \
+ CsrWifiSmeHostConfigGetReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__, interfaceTag__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeHostConfigGetCfmSend
+
+ DESCRIPTION
+ This primitive reports the result of the request.
+
+ PARAMETERS
+ queue - Destination Task Queue
+ interfaceTag - Interface Identifier; unique identifier of an interface
+ status - Reports the result of the request
+ hostConfig - Current host power state.
+
+*******************************************************************************/
+#define CsrWifiSmeHostConfigGetCfmCreate(msg__, dst__, src__, interfaceTag__, status__, hostConfig__) \
+ msg__ = kmalloc(sizeof(CsrWifiSmeHostConfigGetCfm), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_HOST_CONFIG_GET_CFM, dst__, src__); \
+ msg__->interfaceTag = (interfaceTag__); \
+ msg__->status = (status__); \
+ msg__->hostConfig = (hostConfig__);
+
+#define CsrWifiSmeHostConfigGetCfmSendTo(dst__, src__, interfaceTag__, status__, hostConfig__) \
+ { \
+ CsrWifiSmeHostConfigGetCfm *msg__; \
+ CsrWifiSmeHostConfigGetCfmCreate(msg__, dst__, src__, interfaceTag__, status__, hostConfig__); \
+ CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
+ }
+
+#define CsrWifiSmeHostConfigGetCfmSend(dst__, interfaceTag__, status__, hostConfig__) \
+ CsrWifiSmeHostConfigGetCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, interfaceTag__, status__, hostConfig__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeHostConfigSetReqSend
+
+ DESCRIPTION
+ This primitive sets the value of the hostConfig parameter.
+
+ PARAMETERS
+ queue - Message Source Task Queue (Cfm's will be sent to this Queue)
+ interfaceTag - Interface Identifier; unique identifier of an interface
+ hostConfig - Communicates a change of host power state (for example, on
+ mains power, on battery power etc) and of the periodicity of
+ traffic data
+
+*******************************************************************************/
+#define CsrWifiSmeHostConfigSetReqCreate(msg__, dst__, src__, interfaceTag__, hostConfig__) \
+ msg__ = kmalloc(sizeof(CsrWifiSmeHostConfigSetReq), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_HOST_CONFIG_SET_REQ, dst__, src__); \
+ msg__->interfaceTag = (interfaceTag__); \
+ msg__->hostConfig = (hostConfig__);
+
+#define CsrWifiSmeHostConfigSetReqSendTo(dst__, src__, interfaceTag__, hostConfig__) \
+ { \
+ CsrWifiSmeHostConfigSetReq *msg__; \
+ CsrWifiSmeHostConfigSetReqCreate(msg__, dst__, src__, interfaceTag__, hostConfig__); \
+ CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \
+ }
+
+#define CsrWifiSmeHostConfigSetReqSend(src__, interfaceTag__, hostConfig__) \
+ CsrWifiSmeHostConfigSetReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__, interfaceTag__, hostConfig__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeHostConfigSetCfmSend
+
+ DESCRIPTION
+ This primitive reports the result of the request.
+
+ PARAMETERS
+ queue - Destination Task Queue
+ interfaceTag - Interface Identifier; unique identifier of an interface
+ status - Reports the result of the request
+
+*******************************************************************************/
+#define CsrWifiSmeHostConfigSetCfmCreate(msg__, dst__, src__, interfaceTag__, status__) \
+ msg__ = kmalloc(sizeof(CsrWifiSmeHostConfigSetCfm), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_HOST_CONFIG_SET_CFM, dst__, src__); \
+ msg__->interfaceTag = (interfaceTag__); \
+ msg__->status = (status__);
+
+#define CsrWifiSmeHostConfigSetCfmSendTo(dst__, src__, interfaceTag__, status__) \
+ { \
+ CsrWifiSmeHostConfigSetCfm *msg__; \
+ CsrWifiSmeHostConfigSetCfmCreate(msg__, dst__, src__, interfaceTag__, status__); \
+ CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
+ }
+
+#define CsrWifiSmeHostConfigSetCfmSend(dst__, interfaceTag__, status__) \
+ CsrWifiSmeHostConfigSetCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, interfaceTag__, status__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeIbssStationIndSend
+
+ DESCRIPTION
+ The SME will send this primitive to indicate that a station has joined or
+ left the ad-hoc network.
+
+ PARAMETERS
+ queue - Destination Task Queue
+ address - MAC address of the station that has joined or left
+ isconnected - TRUE if the station joined, FALSE if the station left
+
+*******************************************************************************/
+#define CsrWifiSmeIbssStationIndCreate(msg__, dst__, src__, address__, isconnected__) \
+ msg__ = kmalloc(sizeof(CsrWifiSmeIbssStationInd), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_IBSS_STATION_IND, dst__, src__); \
+ msg__->address = (address__); \
+ msg__->isconnected = (isconnected__);
+
+#define CsrWifiSmeIbssStationIndSendTo(dst__, src__, address__, isconnected__) \
+ { \
+ CsrWifiSmeIbssStationInd *msg__; \
+ CsrWifiSmeIbssStationIndCreate(msg__, dst__, src__, address__, isconnected__); \
+ CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
+ }
+
+#define CsrWifiSmeIbssStationIndSend(dst__, address__, isconnected__) \
+ CsrWifiSmeIbssStationIndSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, address__, isconnected__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeInfoIndSend
+
+ DESCRIPTION
+ Message indicating a some info about current activity. Mostly of interest
+ in testing but may be useful in the field.
+
+ PARAMETERS
+ queue - Destination Task Queue
+ infoMessage - Contains the message.
+
+*******************************************************************************/
+#define CsrWifiSmeInfoIndCreate(msg__, dst__, src__, infoMessage__) \
+ msg__ = kmalloc(sizeof(CsrWifiSmeInfoInd), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_INFO_IND, dst__, src__); \
+ msg__->infoMessage = (infoMessage__);
+
+#define CsrWifiSmeInfoIndSendTo(dst__, src__, infoMessage__) \
+ { \
+ CsrWifiSmeInfoInd *msg__; \
+ CsrWifiSmeInfoIndCreate(msg__, dst__, src__, infoMessage__); \
+ CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
+ }
+
+#define CsrWifiSmeInfoIndSend(dst__, infoMessage__) \
+ CsrWifiSmeInfoIndSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, infoMessage__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeInterfaceCapabilityGetReqSend
+
+ DESCRIPTION
+ The Wireless Manager calls this primitive to ask the SME for the
+ capabilities of the supported interfaces
+
+ PARAMETERS
+ queue - Message Source Task Queue (Cfm's will be sent to this Queue)
+
+*******************************************************************************/
+#define CsrWifiSmeInterfaceCapabilityGetReqCreate(msg__, dst__, src__) \
+ msg__ = kmalloc(sizeof(CsrWifiSmeInterfaceCapabilityGetReq), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_INTERFACE_CAPABILITY_GET_REQ, dst__, src__);
+
+#define CsrWifiSmeInterfaceCapabilityGetReqSendTo(dst__, src__) \
+ { \
+ CsrWifiSmeInterfaceCapabilityGetReq *msg__; \
+ CsrWifiSmeInterfaceCapabilityGetReqCreate(msg__, dst__, src__); \
+ CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \
+ }
+
+#define CsrWifiSmeInterfaceCapabilityGetReqSend(src__) \
+ CsrWifiSmeInterfaceCapabilityGetReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeInterfaceCapabilityGetCfmSend
+
+ DESCRIPTION
+ This primitive reports the result of the request.
+
+ PARAMETERS
+ queue - Destination Task Queue
+ status - Result of the request
+ numInterfaces - Number of the interfaces supported
+ capBitmap - Points to the list of capabilities bitmaps provided for each
+ interface.
+ The bits represent the following capabilities:
+ -bits 7 to 4-Reserved
+ -bit 3-AMP
+ -bit 2-P2P
+ -bit 1-AP
+ -bit 0-STA
+
+*******************************************************************************/
+#define CsrWifiSmeInterfaceCapabilityGetCfmCreate(msg__, dst__, src__, status__, numInterfaces__, capBitmap__) \
+ msg__ = kmalloc(sizeof(CsrWifiSmeInterfaceCapabilityGetCfm), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_INTERFACE_CAPABILITY_GET_CFM, dst__, src__); \
+ msg__->status = (status__); \
+ msg__->numInterfaces = (numInterfaces__); \
+ memcpy(msg__->capBitmap, (capBitmap__), sizeof(u8) * 2);
+
+#define CsrWifiSmeInterfaceCapabilityGetCfmSendTo(dst__, src__, status__, numInterfaces__, capBitmap__) \
+ { \
+ CsrWifiSmeInterfaceCapabilityGetCfm *msg__; \
+ CsrWifiSmeInterfaceCapabilityGetCfmCreate(msg__, dst__, src__, status__, numInterfaces__, capBitmap__); \
+ CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
+ }
+
+#define CsrWifiSmeInterfaceCapabilityGetCfmSend(dst__, status__, numInterfaces__, capBitmap__) \
+ CsrWifiSmeInterfaceCapabilityGetCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, status__, numInterfaces__, capBitmap__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeKeyReqSend
+
+ DESCRIPTION
+ The wireless manager application calls this primitive to add or remove
+ keys that the chip should use for encryption of data.
+ The interface allows the wireless manager application to add and remove
+ keys according to the specified action.
+
+ PARAMETERS
+ queue - Message Source Task Queue (Cfm's will be sent to this Queue)
+ interfaceTag - Interface Identifier; unique identifier of an interface
+ action - The value of the CsrWifiSmeListAction parameter instructs the
+ driver to modify or provide the list of keys.
+ CSR_WIFI_SME_LIST_ACTION_GET is not supported here.
+ key - Key to be added or removed
+
+*******************************************************************************/
+#define CsrWifiSmeKeyReqCreate(msg__, dst__, src__, interfaceTag__, action__, key__) \
+ msg__ = kmalloc(sizeof(CsrWifiSmeKeyReq), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_KEY_REQ, dst__, src__); \
+ msg__->interfaceTag = (interfaceTag__); \
+ msg__->action = (action__); \
+ msg__->key = (key__);
+
+#define CsrWifiSmeKeyReqSendTo(dst__, src__, interfaceTag__, action__, key__) \
+ { \
+ CsrWifiSmeKeyReq *msg__; \
+ CsrWifiSmeKeyReqCreate(msg__, dst__, src__, interfaceTag__, action__, key__); \
+ CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \
+ }
+
+#define CsrWifiSmeKeyReqSend(src__, interfaceTag__, action__, key__) \
+ CsrWifiSmeKeyReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__, interfaceTag__, action__, key__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeKeyCfmSend
+
+ DESCRIPTION
+ The SME calls the primitive to report the result of the request
+ primitive.
+
+ PARAMETERS
+ queue - Destination Task Queue
+ interfaceTag - Interface Identifier; unique identifier of an interface
+ status - Reports the result of the request
+ action - Action in the request
+ keyType - Type of the key added/deleted
+ peerMacAddress - Peer MAC Address of the key added/deleted
+
+*******************************************************************************/
+#define CsrWifiSmeKeyCfmCreate(msg__, dst__, src__, interfaceTag__, status__, action__, keyType__, peerMacAddress__) \
+ msg__ = kmalloc(sizeof(CsrWifiSmeKeyCfm), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_KEY_CFM, dst__, src__); \
+ msg__->interfaceTag = (interfaceTag__); \
+ msg__->status = (status__); \
+ msg__->action = (action__); \
+ msg__->keyType = (keyType__); \
+ msg__->peerMacAddress = (peerMacAddress__);
+
+#define CsrWifiSmeKeyCfmSendTo(dst__, src__, interfaceTag__, status__, action__, keyType__, peerMacAddress__) \
+ { \
+ CsrWifiSmeKeyCfm *msg__; \
+ CsrWifiSmeKeyCfmCreate(msg__, dst__, src__, interfaceTag__, status__, action__, keyType__, peerMacAddress__); \
+ CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
+ }
+
+#define CsrWifiSmeKeyCfmSend(dst__, interfaceTag__, status__, action__, keyType__, peerMacAddress__) \
+ CsrWifiSmeKeyCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, interfaceTag__, status__, action__, keyType__, peerMacAddress__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeLinkQualityGetReqSend
+
+ DESCRIPTION
+ This primitive gets the value of the LinkQuality parameter.
+
+ PARAMETERS
+ queue - Message Source Task Queue (Cfm's will be sent to this Queue)
+ interfaceTag - Interface Identifier; unique identifier of an interface
+
+*******************************************************************************/
+#define CsrWifiSmeLinkQualityGetReqCreate(msg__, dst__, src__, interfaceTag__) \
+ msg__ = kmalloc(sizeof(CsrWifiSmeLinkQualityGetReq), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_LINK_QUALITY_GET_REQ, dst__, src__); \
+ msg__->interfaceTag = (interfaceTag__);
+
+#define CsrWifiSmeLinkQualityGetReqSendTo(dst__, src__, interfaceTag__) \
+ { \
+ CsrWifiSmeLinkQualityGetReq *msg__; \
+ CsrWifiSmeLinkQualityGetReqCreate(msg__, dst__, src__, interfaceTag__); \
+ CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \
+ }
+
+#define CsrWifiSmeLinkQualityGetReqSend(src__, interfaceTag__) \
+ CsrWifiSmeLinkQualityGetReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__, interfaceTag__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeLinkQualityGetCfmSend
+
+ DESCRIPTION
+ This primitive reports the result of the request.
+
+ PARAMETERS
+ queue - Destination Task Queue
+ interfaceTag - Interface Identifier; unique identifier of an interface
+ status - Reports the result of the request
+ linkQuality - Indicates the quality of the link
+
+*******************************************************************************/
+#define CsrWifiSmeLinkQualityGetCfmCreate(msg__, dst__, src__, interfaceTag__, status__, linkQuality__) \
+ msg__ = kmalloc(sizeof(CsrWifiSmeLinkQualityGetCfm), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_LINK_QUALITY_GET_CFM, dst__, src__); \
+ msg__->interfaceTag = (interfaceTag__); \
+ msg__->status = (status__); \
+ msg__->linkQuality = (linkQuality__);
+
+#define CsrWifiSmeLinkQualityGetCfmSendTo(dst__, src__, interfaceTag__, status__, linkQuality__) \
+ { \
+ CsrWifiSmeLinkQualityGetCfm *msg__; \
+ CsrWifiSmeLinkQualityGetCfmCreate(msg__, dst__, src__, interfaceTag__, status__, linkQuality__); \
+ CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
+ }
+
+#define CsrWifiSmeLinkQualityGetCfmSend(dst__, interfaceTag__, status__, linkQuality__) \
+ CsrWifiSmeLinkQualityGetCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, interfaceTag__, status__, linkQuality__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeMediaStatusIndSend
+
+ DESCRIPTION
+ The SME sends this primitive to all the tasks that have registered to
+ receive it when a network connection is established, lost or has moved to
+ another AP.
+
+ PARAMETERS
+ queue - Destination Task Queue
+ interfaceTag - Interface Identifier; unique identifier of an interface
+ mediaStatus - Indicates the media status
+ connectionInfo - This parameter is relevant only if the mediaStatus is
+ CSR_WIFI_SME_MEDIA_STATUS_CONNECTED:
+ it points to the connection information for the new network
+ disassocReason - This parameter is relevant only if the mediaStatus is
+ CSR_WIFI_SME_MEDIA_STATUS_DISCONNECTED:
+ if a disassociation has occurred it gives the reason of the
+ disassociation
+ deauthReason - This parameter is relevant only if the mediaStatus is
+ CSR_WIFI_SME_MEDIA_STATUS_DISCONNECTED:
+ if a deauthentication has occurred it gives the reason of
+ the deauthentication
+
+*******************************************************************************/
+#define CsrWifiSmeMediaStatusIndCreate(msg__, dst__, src__, interfaceTag__, mediaStatus__, connectionInfo__, disassocReason__, deauthReason__) \
+ msg__ = kmalloc(sizeof(CsrWifiSmeMediaStatusInd), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_MEDIA_STATUS_IND, dst__, src__); \
+ msg__->interfaceTag = (interfaceTag__); \
+ msg__->mediaStatus = (mediaStatus__); \
+ msg__->connectionInfo = (connectionInfo__); \
+ msg__->disassocReason = (disassocReason__); \
+ msg__->deauthReason = (deauthReason__);
+
+#define CsrWifiSmeMediaStatusIndSendTo(dst__, src__, interfaceTag__, mediaStatus__, connectionInfo__, disassocReason__, deauthReason__) \
+ { \
+ CsrWifiSmeMediaStatusInd *msg__; \
+ CsrWifiSmeMediaStatusIndCreate(msg__, dst__, src__, interfaceTag__, mediaStatus__, connectionInfo__, disassocReason__, deauthReason__); \
+ CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
+ }
+
+#define CsrWifiSmeMediaStatusIndSend(dst__, interfaceTag__, mediaStatus__, connectionInfo__, disassocReason__, deauthReason__) \
+ CsrWifiSmeMediaStatusIndSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, interfaceTag__, mediaStatus__, connectionInfo__, disassocReason__, deauthReason__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeMibConfigGetReqSend
+
+ DESCRIPTION
+ This primitive gets the value of the MibConfig parameter.
+
+ PARAMETERS
+ queue - Message Source Task Queue (Cfm's will be sent to this Queue)
+
+*******************************************************************************/
+#define CsrWifiSmeMibConfigGetReqCreate(msg__, dst__, src__) \
+ msg__ = kmalloc(sizeof(CsrWifiSmeMibConfigGetReq), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_MIB_CONFIG_GET_REQ, dst__, src__);
+
+#define CsrWifiSmeMibConfigGetReqSendTo(dst__, src__) \
+ { \
+ CsrWifiSmeMibConfigGetReq *msg__; \
+ CsrWifiSmeMibConfigGetReqCreate(msg__, dst__, src__); \
+ CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \
+ }
+
+#define CsrWifiSmeMibConfigGetReqSend(src__) \
+ CsrWifiSmeMibConfigGetReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeMibConfigGetCfmSend
+
+ DESCRIPTION
+ This primitive reports the result of the request.
+
+ PARAMETERS
+ queue - Destination Task Queue
+ status - Reports the result of the request
+ mibConfig - Reports various IEEE 802.11 attributes as currently configured
+
+*******************************************************************************/
+#define CsrWifiSmeMibConfigGetCfmCreate(msg__, dst__, src__, status__, mibConfig__) \
+ msg__ = kmalloc(sizeof(CsrWifiSmeMibConfigGetCfm), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_MIB_CONFIG_GET_CFM, dst__, src__); \
+ msg__->status = (status__); \
+ msg__->mibConfig = (mibConfig__);
+
+#define CsrWifiSmeMibConfigGetCfmSendTo(dst__, src__, status__, mibConfig__) \
+ { \
+ CsrWifiSmeMibConfigGetCfm *msg__; \
+ CsrWifiSmeMibConfigGetCfmCreate(msg__, dst__, src__, status__, mibConfig__); \
+ CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
+ }
+
+#define CsrWifiSmeMibConfigGetCfmSend(dst__, status__, mibConfig__) \
+ CsrWifiSmeMibConfigGetCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, status__, mibConfig__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeMibConfigSetReqSend
+
+ DESCRIPTION
+ This primitive sets the value of the MibConfig parameter.
+
+ PARAMETERS
+ queue - Message Source Task Queue (Cfm's will be sent to this Queue)
+ mibConfig - Conveys the desired value of various IEEE 802.11 attributes as
+ currently configured
+
+*******************************************************************************/
+#define CsrWifiSmeMibConfigSetReqCreate(msg__, dst__, src__, mibConfig__) \
+ msg__ = kmalloc(sizeof(CsrWifiSmeMibConfigSetReq), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_MIB_CONFIG_SET_REQ, dst__, src__); \
+ msg__->mibConfig = (mibConfig__);
+
+#define CsrWifiSmeMibConfigSetReqSendTo(dst__, src__, mibConfig__) \
+ { \
+ CsrWifiSmeMibConfigSetReq *msg__; \
+ CsrWifiSmeMibConfigSetReqCreate(msg__, dst__, src__, mibConfig__); \
+ CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \
+ }
+
+#define CsrWifiSmeMibConfigSetReqSend(src__, mibConfig__) \
+ CsrWifiSmeMibConfigSetReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__, mibConfig__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeMibConfigSetCfmSend
+
+ DESCRIPTION
+ This primitive reports the result of the request.
+
+ PARAMETERS
+ queue - Destination Task Queue
+ status - Reports the result of the request
+
+*******************************************************************************/
+#define CsrWifiSmeMibConfigSetCfmCreate(msg__, dst__, src__, status__) \
+ msg__ = kmalloc(sizeof(CsrWifiSmeMibConfigSetCfm), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_MIB_CONFIG_SET_CFM, dst__, src__); \
+ msg__->status = (status__);
+
+#define CsrWifiSmeMibConfigSetCfmSendTo(dst__, src__, status__) \
+ { \
+ CsrWifiSmeMibConfigSetCfm *msg__; \
+ CsrWifiSmeMibConfigSetCfmCreate(msg__, dst__, src__, status__); \
+ CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
+ }
+
+#define CsrWifiSmeMibConfigSetCfmSend(dst__, status__) \
+ CsrWifiSmeMibConfigSetCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, status__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeMibGetCfmSend
+
+ DESCRIPTION
+ The SME calls this primitive to return the requested MIB variable values.
+
+ PARAMETERS
+ queue - Destination Task Queue
+ status - Reports the result of the request
+ mibAttributeLength - Length of mibAttribute
+ mibAttribute - Points to the VarBind or VarBindList containing the
+ names and values of the MIB variables requested
+
+*******************************************************************************/
+#define CsrWifiSmeMibGetCfmCreate(msg__, dst__, src__, status__, mibAttributeLength__, mibAttribute__) \
+ msg__ = kmalloc(sizeof(CsrWifiSmeMibGetCfm), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_MIB_GET_CFM, dst__, src__); \
+ msg__->status = (status__); \
+ msg__->mibAttributeLength = (mibAttributeLength__); \
+ msg__->mibAttribute = (mibAttribute__);
+
+#define CsrWifiSmeMibGetCfmSendTo(dst__, src__, status__, mibAttributeLength__, mibAttribute__) \
+ { \
+ CsrWifiSmeMibGetCfm *msg__; \
+ CsrWifiSmeMibGetCfmCreate(msg__, dst__, src__, status__, mibAttributeLength__, mibAttribute__); \
+ CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
+ }
+
+#define CsrWifiSmeMibGetCfmSend(dst__, status__, mibAttributeLength__, mibAttribute__) \
+ CsrWifiSmeMibGetCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, status__, mibAttributeLength__, mibAttribute__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeMibGetNextReqSend
+
+ DESCRIPTION
+ To read a sequence of MIB parameters, for example a table, call this
+ primitive to find the name of the next MIB variable
+
+ PARAMETERS
+ queue - Message Source Task Queue (Cfm's will be sent to this Queue)
+ mibAttributeLength - Length of mibAttribute
+ mibAttribute - Points to a VarBind or VarBindList containing the
+ name(s) of the MIB variable(s) to search from.
+
+*******************************************************************************/
+#define CsrWifiSmeMibGetNextReqCreate(msg__, dst__, src__, mibAttributeLength__, mibAttribute__) \
+ msg__ = kmalloc(sizeof(CsrWifiSmeMibGetNextReq), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_MIB_GET_NEXT_REQ, dst__, src__); \
+ msg__->mibAttributeLength = (mibAttributeLength__); \
+ msg__->mibAttribute = (mibAttribute__);
+
+#define CsrWifiSmeMibGetNextReqSendTo(dst__, src__, mibAttributeLength__, mibAttribute__) \
+ { \
+ CsrWifiSmeMibGetNextReq *msg__; \
+ CsrWifiSmeMibGetNextReqCreate(msg__, dst__, src__, mibAttributeLength__, mibAttribute__); \
+ CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \
+ }
+
+#define CsrWifiSmeMibGetNextReqSend(src__, mibAttributeLength__, mibAttribute__) \
+ CsrWifiSmeMibGetNextReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__, mibAttributeLength__, mibAttribute__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeMibGetNextCfmSend
+
+ DESCRIPTION
+ The SME calls this primitive to return the requested MIB name(s).
+ The wireless manager application can then read the value of the MIB
+ variable using CSR_WIFI_SME_MIB_GET_REQ, using the names provided.
+
+ PARAMETERS
+ queue - Destination Task Queue
+ status - Reports the result of the request
+ mibAttributeLength - Length of mibAttribute
+ mibAttribute - Points to a VarBind or VarBindList containing the
+ name(s) of the MIB variable(s) lexicographically
+ following the name(s) given in the request
+
+*******************************************************************************/
+#define CsrWifiSmeMibGetNextCfmCreate(msg__, dst__, src__, status__, mibAttributeLength__, mibAttribute__) \
+ msg__ = kmalloc(sizeof(CsrWifiSmeMibGetNextCfm), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_MIB_GET_NEXT_CFM, dst__, src__); \
+ msg__->status = (status__); \
+ msg__->mibAttributeLength = (mibAttributeLength__); \
+ msg__->mibAttribute = (mibAttribute__);
+
+#define CsrWifiSmeMibGetNextCfmSendTo(dst__, src__, status__, mibAttributeLength__, mibAttribute__) \
+ { \
+ CsrWifiSmeMibGetNextCfm *msg__; \
+ CsrWifiSmeMibGetNextCfmCreate(msg__, dst__, src__, status__, mibAttributeLength__, mibAttribute__); \
+ CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
+ }
+
+#define CsrWifiSmeMibGetNextCfmSend(dst__, status__, mibAttributeLength__, mibAttribute__) \
+ CsrWifiSmeMibGetNextCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, status__, mibAttributeLength__, mibAttribute__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeMibGetReqSend
+
+ DESCRIPTION
+ The wireless manager application calls this primitive to retrieve one or
+ more MIB variables.
+
+ PARAMETERS
+ queue - Message Source Task Queue (Cfm's will be sent to this Queue)
+ mibAttributeLength - Length of mibAttribute
+ mibAttribute - Points to the VarBind or VarBindList containing the
+ names of the MIB variables to be retrieved
+
+*******************************************************************************/
+#define CsrWifiSmeMibGetReqCreate(msg__, dst__, src__, mibAttributeLength__, mibAttribute__) \
+ msg__ = kmalloc(sizeof(CsrWifiSmeMibGetReq), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_MIB_GET_REQ, dst__, src__); \
+ msg__->mibAttributeLength = (mibAttributeLength__); \
+ msg__->mibAttribute = (mibAttribute__);
+
+#define CsrWifiSmeMibGetReqSendTo(dst__, src__, mibAttributeLength__, mibAttribute__) \
+ { \
+ CsrWifiSmeMibGetReq *msg__; \
+ CsrWifiSmeMibGetReqCreate(msg__, dst__, src__, mibAttributeLength__, mibAttribute__); \
+ CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \
+ }
+
+#define CsrWifiSmeMibGetReqSend(src__, mibAttributeLength__, mibAttribute__) \
+ CsrWifiSmeMibGetReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__, mibAttributeLength__, mibAttribute__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeMibSetReqSend
+
+ DESCRIPTION
+ The SME provides raw access to the MIB on the chip, which may be used by
+ some configuration or diagnostic utilities, but is not normally needed by
+ the wireless manager application.
+ The MIB access functions use BER encoded names (OID) of the MIB
+ parameters and BER encoded values, as described in the chip Host
+ Interface Protocol Specification.
+ The MIB parameters are described in 'Wi-Fi 5.0.0 Management Information
+ Base Reference Guide'.
+ The wireless manager application calls this primitive to set one or more
+ MIB variables
+
+ PARAMETERS
+ queue - Message Source Task Queue (Cfm's will be sent to this Queue)
+ mibAttributeLength - Length of mibAttribute
+ mibAttribute - Points to the VarBind or VarBindList containing the
+ names and values of the MIB variables to set
+
+*******************************************************************************/
+#define CsrWifiSmeMibSetReqCreate(msg__, dst__, src__, mibAttributeLength__, mibAttribute__) \
+ msg__ = kmalloc(sizeof(CsrWifiSmeMibSetReq), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_MIB_SET_REQ, dst__, src__); \
+ msg__->mibAttributeLength = (mibAttributeLength__); \
+ msg__->mibAttribute = (mibAttribute__);
+
+#define CsrWifiSmeMibSetReqSendTo(dst__, src__, mibAttributeLength__, mibAttribute__) \
+ { \
+ CsrWifiSmeMibSetReq *msg__; \
+ CsrWifiSmeMibSetReqCreate(msg__, dst__, src__, mibAttributeLength__, mibAttribute__); \
+ CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \
+ }
+
+#define CsrWifiSmeMibSetReqSend(src__, mibAttributeLength__, mibAttribute__) \
+ CsrWifiSmeMibSetReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__, mibAttributeLength__, mibAttribute__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeMibSetCfmSend
+
+ DESCRIPTION
+ The SME calls the primitive to report the result of the set primitive.
+
+ PARAMETERS
+ queue - Destination Task Queue
+ status - Reports the result of the request
+
+*******************************************************************************/
+#define CsrWifiSmeMibSetCfmCreate(msg__, dst__, src__, status__) \
+ msg__ = kmalloc(sizeof(CsrWifiSmeMibSetCfm), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_MIB_SET_CFM, dst__, src__); \
+ msg__->status = (status__);
+
+#define CsrWifiSmeMibSetCfmSendTo(dst__, src__, status__) \
+ { \
+ CsrWifiSmeMibSetCfm *msg__; \
+ CsrWifiSmeMibSetCfmCreate(msg__, dst__, src__, status__); \
+ CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
+ }
+
+#define CsrWifiSmeMibSetCfmSend(dst__, status__) \
+ CsrWifiSmeMibSetCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, status__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeMicFailureIndSend
+
+ DESCRIPTION
+ The SME sends this primitive to all the tasks that have registered to
+ receive it whenever the chip firmware reports a MIC failure.
+
+ PARAMETERS
+ queue - Destination Task Queue
+ interfaceTag - Interface Identifier; unique identifier of an interface
+ secondFailure - TRUE if this indication is for a second failure in 60
+ seconds
+ count - The number of MIC failure events since the connection was
+ established
+ address - MAC address of the transmitter that caused the MIC failure
+ keyType - Type of key for which the failure occurred
+
+*******************************************************************************/
+#define CsrWifiSmeMicFailureIndCreate(msg__, dst__, src__, interfaceTag__, secondFailure__, count__, address__, keyType__) \
+ msg__ = kmalloc(sizeof(CsrWifiSmeMicFailureInd), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_MIC_FAILURE_IND, dst__, src__); \
+ msg__->interfaceTag = (interfaceTag__); \
+ msg__->secondFailure = (secondFailure__); \
+ msg__->count = (count__); \
+ msg__->address = (address__); \
+ msg__->keyType = (keyType__);
+
+#define CsrWifiSmeMicFailureIndSendTo(dst__, src__, interfaceTag__, secondFailure__, count__, address__, keyType__) \
+ { \
+ CsrWifiSmeMicFailureInd *msg__; \
+ CsrWifiSmeMicFailureIndCreate(msg__, dst__, src__, interfaceTag__, secondFailure__, count__, address__, keyType__); \
+ CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
+ }
+
+#define CsrWifiSmeMicFailureIndSend(dst__, interfaceTag__, secondFailure__, count__, address__, keyType__) \
+ CsrWifiSmeMicFailureIndSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, interfaceTag__, secondFailure__, count__, address__, keyType__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeMulticastAddressReqSend
+
+ DESCRIPTION
+ The wireless manager application calls this primitive to specify the
+ multicast addresses which the chip should recognise. The interface allows
+ the wireless manager application to query, add, remove and flush the
+ multicast addresses for the network interface according to the specified
+ action.
+
+ PARAMETERS
+ queue - Message Source Task Queue (Cfm's will be sent to this Queue)
+ interfaceTag - Interface Identifier; unique identifier of an interface
+ action - The value of the CsrWifiSmeListAction parameter
+ instructs the driver to modify or provide the list of
+ MAC addresses.
+ setAddressesCount - Number of MAC addresses sent with the primitive
+ setAddresses - Pointer to the list of MAC Addresses sent with the
+ primitive, set to NULL if none is sent.
+
+*******************************************************************************/
+#define CsrWifiSmeMulticastAddressReqCreate(msg__, dst__, src__, interfaceTag__, action__, setAddressesCount__, setAddresses__) \
+ msg__ = kmalloc(sizeof(CsrWifiSmeMulticastAddressReq), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_MULTICAST_ADDRESS_REQ, dst__, src__); \
+ msg__->interfaceTag = (interfaceTag__); \
+ msg__->action = (action__); \
+ msg__->setAddressesCount = (setAddressesCount__); \
+ msg__->setAddresses = (setAddresses__);
+
+#define CsrWifiSmeMulticastAddressReqSendTo(dst__, src__, interfaceTag__, action__, setAddressesCount__, setAddresses__) \
+ { \
+ CsrWifiSmeMulticastAddressReq *msg__; \
+ CsrWifiSmeMulticastAddressReqCreate(msg__, dst__, src__, interfaceTag__, action__, setAddressesCount__, setAddresses__); \
+ CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \
+ }
+
+#define CsrWifiSmeMulticastAddressReqSend(src__, interfaceTag__, action__, setAddressesCount__, setAddresses__) \
+ CsrWifiSmeMulticastAddressReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__, interfaceTag__, action__, setAddressesCount__, setAddresses__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeMulticastAddressCfmSend
+
+ DESCRIPTION
+ The SME will call this primitive when the operation is complete. For a
+ GET action, this primitive reports the current list of MAC addresses.
+
+ PARAMETERS
+ queue - Destination Task Queue
+ interfaceTag - Interface Identifier; unique identifier of an interface
+ status - Reports the result of the request
+ action - Action in the request
+ getAddressesCount - This parameter is only relevant if action is
+ CSR_WIFI_SME_LIST_ACTION_GET:
+ number of MAC addresses sent with the primitive
+ getAddresses - Pointer to the list of MAC Addresses sent with the
+ primitive, set to NULL if none is sent.
+
+*******************************************************************************/
+#define CsrWifiSmeMulticastAddressCfmCreate(msg__, dst__, src__, interfaceTag__, status__, action__, getAddressesCount__, getAddresses__) \
+ msg__ = kmalloc(sizeof(CsrWifiSmeMulticastAddressCfm), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_MULTICAST_ADDRESS_CFM, dst__, src__); \
+ msg__->interfaceTag = (interfaceTag__); \
+ msg__->status = (status__); \
+ msg__->action = (action__); \
+ msg__->getAddressesCount = (getAddressesCount__); \
+ msg__->getAddresses = (getAddresses__);
+
+#define CsrWifiSmeMulticastAddressCfmSendTo(dst__, src__, interfaceTag__, status__, action__, getAddressesCount__, getAddresses__) \
+ { \
+ CsrWifiSmeMulticastAddressCfm *msg__; \
+ CsrWifiSmeMulticastAddressCfmCreate(msg__, dst__, src__, interfaceTag__, status__, action__, getAddressesCount__, getAddresses__); \
+ CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
+ }
+
+#define CsrWifiSmeMulticastAddressCfmSend(dst__, interfaceTag__, status__, action__, getAddressesCount__, getAddresses__) \
+ CsrWifiSmeMulticastAddressCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, interfaceTag__, status__, action__, getAddressesCount__, getAddresses__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmePacketFilterSetReqSend
+
+ DESCRIPTION
+ The wireless manager application should call this primitive to enable or
+ disable filtering of broadcast packets: uninteresting broadcast packets
+ will be dropped by the Wi-Fi chip, instead of passing them up to the
+ host.
+ This has the advantage of saving power in the host application processor
+ as it removes the need to process unwanted packets.
+ All broadcast packets are filtered according to the filter and the filter
+ mode provided, except ARP packets, which are filtered using
+ arpFilterAddress.
+ Filters are not cumulative: only the parameters specified in the most
+ recent successful request are significant.
+ For more information, see 'UniFi Firmware API Specification'.
+
+ PARAMETERS
+ queue - Message Source Task Queue (Cfm's will be sent to this Queue)
+ interfaceTag - Interface Identifier; unique identifier of an interface
+ filterLength - Length of the filter in bytes.
+ filterLength=0 disables the filter previously set
+ filter - Points to the first byte of the filter provided, if any.
+ This shall include zero or more instance of the
+ information elements of one of these types
+ * Traffic Classification (TCLAS) elements
+ * WMM-SA TCLAS elements
+ mode - Specifies whether the filter selects or excludes packets
+ matching the filter
+ arpFilterAddress - IPv4 address to be used for filtering the ARP packets.
+ * If the specified address is the IPv4 broadcast address
+ (255.255.255.255), all ARP packets are reported to the
+ host,
+ * If the specified address is NOT the IPv4 broadcast
+ address, only ARP packets with the specified address in
+ the Source or Target Protocol Address fields are reported
+ to the host
+
+*******************************************************************************/
+#define CsrWifiSmePacketFilterSetReqCreate(msg__, dst__, src__, interfaceTag__, filterLength__, filter__, mode__, arpFilterAddress__) \
+ msg__ = kmalloc(sizeof(CsrWifiSmePacketFilterSetReq), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_PACKET_FILTER_SET_REQ, dst__, src__); \
+ msg__->interfaceTag = (interfaceTag__); \
+ msg__->filterLength = (filterLength__); \
+ msg__->filter = (filter__); \
+ msg__->mode = (mode__); \
+ msg__->arpFilterAddress = (arpFilterAddress__);
+
+#define CsrWifiSmePacketFilterSetReqSendTo(dst__, src__, interfaceTag__, filterLength__, filter__, mode__, arpFilterAddress__) \
+ { \
+ CsrWifiSmePacketFilterSetReq *msg__; \
+ CsrWifiSmePacketFilterSetReqCreate(msg__, dst__, src__, interfaceTag__, filterLength__, filter__, mode__, arpFilterAddress__); \
+ CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \
+ }
+
+#define CsrWifiSmePacketFilterSetReqSend(src__, interfaceTag__, filterLength__, filter__, mode__, arpFilterAddress__) \
+ CsrWifiSmePacketFilterSetReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__, interfaceTag__, filterLength__, filter__, mode__, arpFilterAddress__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmePacketFilterSetCfmSend
+
+ DESCRIPTION
+ The SME calls the primitive to report the result of the set primitive.
+
+ PARAMETERS
+ queue - Destination Task Queue
+ interfaceTag - Interface Identifier; unique identifier of an interface
+ status - Reports the result of the request
+
+*******************************************************************************/
+#define CsrWifiSmePacketFilterSetCfmCreate(msg__, dst__, src__, interfaceTag__, status__) \
+ msg__ = kmalloc(sizeof(CsrWifiSmePacketFilterSetCfm), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_PACKET_FILTER_SET_CFM, dst__, src__); \
+ msg__->interfaceTag = (interfaceTag__); \
+ msg__->status = (status__);
+
+#define CsrWifiSmePacketFilterSetCfmSendTo(dst__, src__, interfaceTag__, status__) \
+ { \
+ CsrWifiSmePacketFilterSetCfm *msg__; \
+ CsrWifiSmePacketFilterSetCfmCreate(msg__, dst__, src__, interfaceTag__, status__); \
+ CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
+ }
+
+#define CsrWifiSmePacketFilterSetCfmSend(dst__, interfaceTag__, status__) \
+ CsrWifiSmePacketFilterSetCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, interfaceTag__, status__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmePermanentMacAddressGetReqSend
+
+ DESCRIPTION
+ This primitive retrieves the MAC address stored in EEPROM
+
+ PARAMETERS
+ queue - Message Source Task Queue (Cfm's will be sent to this Queue)
+
+*******************************************************************************/
+#define CsrWifiSmePermanentMacAddressGetReqCreate(msg__, dst__, src__) \
+ msg__ = kmalloc(sizeof(CsrWifiSmePermanentMacAddressGetReq), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_PERMANENT_MAC_ADDRESS_GET_REQ, dst__, src__);
+
+#define CsrWifiSmePermanentMacAddressGetReqSendTo(dst__, src__) \
+ { \
+ CsrWifiSmePermanentMacAddressGetReq *msg__; \
+ CsrWifiSmePermanentMacAddressGetReqCreate(msg__, dst__, src__); \
+ CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \
+ }
+
+#define CsrWifiSmePermanentMacAddressGetReqSend(src__) \
+ CsrWifiSmePermanentMacAddressGetReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmePermanentMacAddressGetCfmSend
+
+ DESCRIPTION
+ This primitive reports the result of the request.
+
+ PARAMETERS
+ queue - Destination Task Queue
+ status - Reports the result of the request
+ permanentMacAddress - MAC address stored in the EEPROM
+
+*******************************************************************************/
+#define CsrWifiSmePermanentMacAddressGetCfmCreate(msg__, dst__, src__, status__, permanentMacAddress__) \
+ msg__ = kmalloc(sizeof(CsrWifiSmePermanentMacAddressGetCfm), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_PERMANENT_MAC_ADDRESS_GET_CFM, dst__, src__); \
+ msg__->status = (status__); \
+ msg__->permanentMacAddress = (permanentMacAddress__);
+
+#define CsrWifiSmePermanentMacAddressGetCfmSendTo(dst__, src__, status__, permanentMacAddress__) \
+ { \
+ CsrWifiSmePermanentMacAddressGetCfm *msg__; \
+ CsrWifiSmePermanentMacAddressGetCfmCreate(msg__, dst__, src__, status__, permanentMacAddress__); \
+ CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
+ }
+
+#define CsrWifiSmePermanentMacAddressGetCfmSend(dst__, status__, permanentMacAddress__) \
+ CsrWifiSmePermanentMacAddressGetCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, status__, permanentMacAddress__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmePmkidCandidateListIndSend
+
+ DESCRIPTION
+ The SME will send this primitive to all the tasks that have registered to
+ receive it when a new network supporting preauthentication and/or PMK
+ caching is seen.
+
+ PARAMETERS
+ queue - Destination Task Queue
+ interfaceTag - Interface Identifier; unique identifier of an
+ interface
+ pmkidCandidatesCount - Number of PMKID candidates provided
+ pmkidCandidates - Points to the first PMKID candidate
+
+*******************************************************************************/
+#define CsrWifiSmePmkidCandidateListIndCreate(msg__, dst__, src__, interfaceTag__, pmkidCandidatesCount__, pmkidCandidates__) \
+ msg__ = kmalloc(sizeof(CsrWifiSmePmkidCandidateListInd), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_PMKID_CANDIDATE_LIST_IND, dst__, src__); \
+ msg__->interfaceTag = (interfaceTag__); \
+ msg__->pmkidCandidatesCount = (pmkidCandidatesCount__); \
+ msg__->pmkidCandidates = (pmkidCandidates__);
+
+#define CsrWifiSmePmkidCandidateListIndSendTo(dst__, src__, interfaceTag__, pmkidCandidatesCount__, pmkidCandidates__) \
+ { \
+ CsrWifiSmePmkidCandidateListInd *msg__; \
+ CsrWifiSmePmkidCandidateListIndCreate(msg__, dst__, src__, interfaceTag__, pmkidCandidatesCount__, pmkidCandidates__); \
+ CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
+ }
+
+#define CsrWifiSmePmkidCandidateListIndSend(dst__, interfaceTag__, pmkidCandidatesCount__, pmkidCandidates__) \
+ CsrWifiSmePmkidCandidateListIndSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, interfaceTag__, pmkidCandidatesCount__, pmkidCandidates__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmePmkidReqSend
+
+ DESCRIPTION
+ The wireless manager application calls this primitive to request an
+ operation on the SME PMKID list.
+ The action argument specifies the operation to perform.
+ When the connection is complete, the wireless manager application may
+ then send and receive EAPOL packets to complete WPA or WPA2
+ authentication if appropriate.
+ The wireless manager application can then pass the resulting encryption
+ keys using this primitive.
+
+ PARAMETERS
+ queue - Message Source Task Queue (Cfm's will be sent to this Queue)
+ interfaceTag - Interface Identifier; unique identifier of an interface
+ action - The value of the CsrWifiSmeListAction parameter instructs
+ the driver to modify or provide the list of PMKIDs.
+ setPmkidsCount - Number of PMKIDs sent with the primitive
+ setPmkids - Pointer to the list of PMKIDs sent with the primitive, set
+ to NULL if none is sent.
+
+*******************************************************************************/
+#define CsrWifiSmePmkidReqCreate(msg__, dst__, src__, interfaceTag__, action__, setPmkidsCount__, setPmkids__) \
+ msg__ = kmalloc(sizeof(CsrWifiSmePmkidReq), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_PMKID_REQ, dst__, src__); \
+ msg__->interfaceTag = (interfaceTag__); \
+ msg__->action = (action__); \
+ msg__->setPmkidsCount = (setPmkidsCount__); \
+ msg__->setPmkids = (setPmkids__);
+
+#define CsrWifiSmePmkidReqSendTo(dst__, src__, interfaceTag__, action__, setPmkidsCount__, setPmkids__) \
+ { \
+ CsrWifiSmePmkidReq *msg__; \
+ CsrWifiSmePmkidReqCreate(msg__, dst__, src__, interfaceTag__, action__, setPmkidsCount__, setPmkids__); \
+ CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \
+ }
+
+#define CsrWifiSmePmkidReqSend(src__, interfaceTag__, action__, setPmkidsCount__, setPmkids__) \
+ CsrWifiSmePmkidReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__, interfaceTag__, action__, setPmkidsCount__, setPmkids__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmePmkidCfmSend
+
+ DESCRIPTION
+ The SME will call this primitive when the operation is complete. For a
+ GET action, this primitive reports the current list of PMKIDs
+
+ PARAMETERS
+ queue - Destination Task Queue
+ interfaceTag - Interface Identifier; unique identifier of an interface
+ status - Reports the result of the request
+ action - Action in the request
+ getPmkidsCount - This parameter is only relevant if action is
+ CSR_WIFI_SME_LIST_ACTION_GET:
+ number of PMKIDs sent with the primitive
+ getPmkids - Pointer to the list of PMKIDs sent with the primitive, set
+ to NULL if none is sent.
+
+*******************************************************************************/
+#define CsrWifiSmePmkidCfmCreate(msg__, dst__, src__, interfaceTag__, status__, action__, getPmkidsCount__, getPmkids__) \
+ msg__ = kmalloc(sizeof(CsrWifiSmePmkidCfm), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_PMKID_CFM, dst__, src__); \
+ msg__->interfaceTag = (interfaceTag__); \
+ msg__->status = (status__); \
+ msg__->action = (action__); \
+ msg__->getPmkidsCount = (getPmkidsCount__); \
+ msg__->getPmkids = (getPmkids__);
+
+#define CsrWifiSmePmkidCfmSendTo(dst__, src__, interfaceTag__, status__, action__, getPmkidsCount__, getPmkids__) \
+ { \
+ CsrWifiSmePmkidCfm *msg__; \
+ CsrWifiSmePmkidCfmCreate(msg__, dst__, src__, interfaceTag__, status__, action__, getPmkidsCount__, getPmkids__); \
+ CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
+ }
+
+#define CsrWifiSmePmkidCfmSend(dst__, interfaceTag__, status__, action__, getPmkidsCount__, getPmkids__) \
+ CsrWifiSmePmkidCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, interfaceTag__, status__, action__, getPmkidsCount__, getPmkids__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmePowerConfigGetReqSend
+
+ DESCRIPTION
+ This primitive gets the value of the PowerConfig parameter.
+
+ PARAMETERS
+ queue - Message Source Task Queue (Cfm's will be sent to this Queue)
+
+*******************************************************************************/
+#define CsrWifiSmePowerConfigGetReqCreate(msg__, dst__, src__) \
+ msg__ = kmalloc(sizeof(CsrWifiSmePowerConfigGetReq), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_POWER_CONFIG_GET_REQ, dst__, src__);
+
+#define CsrWifiSmePowerConfigGetReqSendTo(dst__, src__) \
+ { \
+ CsrWifiSmePowerConfigGetReq *msg__; \
+ CsrWifiSmePowerConfigGetReqCreate(msg__, dst__, src__); \
+ CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \
+ }
+
+#define CsrWifiSmePowerConfigGetReqSend(src__) \
+ CsrWifiSmePowerConfigGetReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmePowerConfigGetCfmSend
+
+ DESCRIPTION
+ This primitive reports the result of the request.
+
+ PARAMETERS
+ queue - Destination Task Queue
+ status - Reports the result of the request
+ powerConfig - Returns the current parameters for the power configuration of
+ the firmware
+
+*******************************************************************************/
+#define CsrWifiSmePowerConfigGetCfmCreate(msg__, dst__, src__, status__, powerConfig__) \
+ msg__ = kmalloc(sizeof(CsrWifiSmePowerConfigGetCfm), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_POWER_CONFIG_GET_CFM, dst__, src__); \
+ msg__->status = (status__); \
+ msg__->powerConfig = (powerConfig__);
+
+#define CsrWifiSmePowerConfigGetCfmSendTo(dst__, src__, status__, powerConfig__) \
+ { \
+ CsrWifiSmePowerConfigGetCfm *msg__; \
+ CsrWifiSmePowerConfigGetCfmCreate(msg__, dst__, src__, status__, powerConfig__); \
+ CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
+ }
+
+#define CsrWifiSmePowerConfigGetCfmSend(dst__, status__, powerConfig__) \
+ CsrWifiSmePowerConfigGetCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, status__, powerConfig__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmePowerConfigSetReqSend
+
+ DESCRIPTION
+ This primitive sets the value of the PowerConfig parameter.
+
+ PARAMETERS
+ queue - Message Source Task Queue (Cfm's will be sent to this Queue)
+ powerConfig - Power saving configuration
+
+*******************************************************************************/
+#define CsrWifiSmePowerConfigSetReqCreate(msg__, dst__, src__, powerConfig__) \
+ msg__ = kmalloc(sizeof(CsrWifiSmePowerConfigSetReq), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_POWER_CONFIG_SET_REQ, dst__, src__); \
+ msg__->powerConfig = (powerConfig__);
+
+#define CsrWifiSmePowerConfigSetReqSendTo(dst__, src__, powerConfig__) \
+ { \
+ CsrWifiSmePowerConfigSetReq *msg__; \
+ CsrWifiSmePowerConfigSetReqCreate(msg__, dst__, src__, powerConfig__); \
+ CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \
+ }
+
+#define CsrWifiSmePowerConfigSetReqSend(src__, powerConfig__) \
+ CsrWifiSmePowerConfigSetReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__, powerConfig__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmePowerConfigSetCfmSend
+
+ DESCRIPTION
+ This primitive reports the result of the request.
+
+ PARAMETERS
+ queue - Destination Task Queue
+ status - Reports the result of the request
+
+*******************************************************************************/
+#define CsrWifiSmePowerConfigSetCfmCreate(msg__, dst__, src__, status__) \
+ msg__ = kmalloc(sizeof(CsrWifiSmePowerConfigSetCfm), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_POWER_CONFIG_SET_CFM, dst__, src__); \
+ msg__->status = (status__);
+
+#define CsrWifiSmePowerConfigSetCfmSendTo(dst__, src__, status__) \
+ { \
+ CsrWifiSmePowerConfigSetCfm *msg__; \
+ CsrWifiSmePowerConfigSetCfmCreate(msg__, dst__, src__, status__); \
+ CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
+ }
+
+#define CsrWifiSmePowerConfigSetCfmSend(dst__, status__) \
+ CsrWifiSmePowerConfigSetCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, status__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeRegulatoryDomainInfoGetReqSend
+
+ DESCRIPTION
+ This primitive gets the value of the RegulatoryDomainInfo parameter.
+
+ PARAMETERS
+ queue - Message Source Task Queue (Cfm's will be sent to this Queue)
+
+*******************************************************************************/
+#define CsrWifiSmeRegulatoryDomainInfoGetReqCreate(msg__, dst__, src__) \
+ msg__ = kmalloc(sizeof(CsrWifiSmeRegulatoryDomainInfoGetReq), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_REGULATORY_DOMAIN_INFO_GET_REQ, dst__, src__);
+
+#define CsrWifiSmeRegulatoryDomainInfoGetReqSendTo(dst__, src__) \
+ { \
+ CsrWifiSmeRegulatoryDomainInfoGetReq *msg__; \
+ CsrWifiSmeRegulatoryDomainInfoGetReqCreate(msg__, dst__, src__); \
+ CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \
+ }
+
+#define CsrWifiSmeRegulatoryDomainInfoGetReqSend(src__) \
+ CsrWifiSmeRegulatoryDomainInfoGetReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeRegulatoryDomainInfoGetCfmSend
+
+ DESCRIPTION
+ This primitive reports the result of the request.
+
+ PARAMETERS
+ queue - Destination Task Queue
+ status - Reports the result of the request
+ regDomInfo - Reports information and state related to regulatory domain
+ operation.
+
+*******************************************************************************/
+#define CsrWifiSmeRegulatoryDomainInfoGetCfmCreate(msg__, dst__, src__, status__, regDomInfo__) \
+ msg__ = kmalloc(sizeof(CsrWifiSmeRegulatoryDomainInfoGetCfm), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_REGULATORY_DOMAIN_INFO_GET_CFM, dst__, src__); \
+ msg__->status = (status__); \
+ msg__->regDomInfo = (regDomInfo__);
+
+#define CsrWifiSmeRegulatoryDomainInfoGetCfmSendTo(dst__, src__, status__, regDomInfo__) \
+ { \
+ CsrWifiSmeRegulatoryDomainInfoGetCfm *msg__; \
+ CsrWifiSmeRegulatoryDomainInfoGetCfmCreate(msg__, dst__, src__, status__, regDomInfo__); \
+ CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
+ }
+
+#define CsrWifiSmeRegulatoryDomainInfoGetCfmSend(dst__, status__, regDomInfo__) \
+ CsrWifiSmeRegulatoryDomainInfoGetCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, status__, regDomInfo__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeRoamCompleteIndSend
+
+ DESCRIPTION
+ The SME will send this primitive to all the tasks that have registered to
+ receive it whenever it completes an attempt to roam to an AP. If the roam
+ attempt was successful, status will be set to CSR_WIFI_SME_SUCCESS,
+ otherwise it shall be set to the appropriate error code.
+
+ PARAMETERS
+ queue - Destination Task Queue
+ interfaceTag - Interface Identifier; unique identifier of an interface
+ status - Reports the result of the roaming procedure
+
+*******************************************************************************/
+#define CsrWifiSmeRoamCompleteIndCreate(msg__, dst__, src__, interfaceTag__, status__) \
+ msg__ = kmalloc(sizeof(CsrWifiSmeRoamCompleteInd), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_ROAM_COMPLETE_IND, dst__, src__); \
+ msg__->interfaceTag = (interfaceTag__); \
+ msg__->status = (status__);
+
+#define CsrWifiSmeRoamCompleteIndSendTo(dst__, src__, interfaceTag__, status__) \
+ { \
+ CsrWifiSmeRoamCompleteInd *msg__; \
+ CsrWifiSmeRoamCompleteIndCreate(msg__, dst__, src__, interfaceTag__, status__); \
+ CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
+ }
+
+#define CsrWifiSmeRoamCompleteIndSend(dst__, interfaceTag__, status__) \
+ CsrWifiSmeRoamCompleteIndSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, interfaceTag__, status__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeRoamStartIndSend
+
+ DESCRIPTION
+ The SME will send this primitive to all the tasks that have registered to
+ receive it whenever it begins an attempt to roam to an AP.
+ If the wireless manager application connect request specified the SSID
+ and the BSSID was set to the broadcast address (0xFF 0xFF 0xFF 0xFF 0xFF
+ 0xFF), the SME monitors the signal quality and maintains a list of
+ candidates to roam to. When the signal quality of the current connection
+ falls below a threshold, and there is a candidate with better quality,
+ the SME will attempt to the candidate AP.
+ If the roaming procedure succeeds, the SME will also issue a Media
+ Connect indication to inform the wireless manager application of the
+ change.
+ NOTE: to prevent the SME from initiating roaming the WMA must specify the
+ BSSID in the connection request; this forces the SME to connect only to
+ that AP.
+ The wireless manager application can obtain statistics for roaming
+ purposes using CSR_WIFI_SME_CONNECTION_QUALITY_IND and
+ CSR_WIFI_SME_CONNECTION_STATS_GET_REQ.
+ When the wireless manager application wishes to roam to another AP, it
+ must issue a connection request specifying the BSSID of the desired AP.
+
+ PARAMETERS
+ queue - Destination Task Queue
+ interfaceTag - Interface Identifier; unique identifier of an interface
+ roamReason - Indicates the reason for starting the roaming procedure
+ reason80211 - Indicates the reason for deauthentication or disassociation
+
+*******************************************************************************/
+#define CsrWifiSmeRoamStartIndCreate(msg__, dst__, src__, interfaceTag__, roamReason__, reason80211__) \
+ msg__ = kmalloc(sizeof(CsrWifiSmeRoamStartInd), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_ROAM_START_IND, dst__, src__); \
+ msg__->interfaceTag = (interfaceTag__); \
+ msg__->roamReason = (roamReason__); \
+ msg__->reason80211 = (reason80211__);
+
+#define CsrWifiSmeRoamStartIndSendTo(dst__, src__, interfaceTag__, roamReason__, reason80211__) \
+ { \
+ CsrWifiSmeRoamStartInd *msg__; \
+ CsrWifiSmeRoamStartIndCreate(msg__, dst__, src__, interfaceTag__, roamReason__, reason80211__); \
+ CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
+ }
+
+#define CsrWifiSmeRoamStartIndSend(dst__, interfaceTag__, roamReason__, reason80211__) \
+ CsrWifiSmeRoamStartIndSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, interfaceTag__, roamReason__, reason80211__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeRoamingConfigGetReqSend
+
+ DESCRIPTION
+ This primitive gets the value of the RoamingConfig parameter.
+
+ PARAMETERS
+ queue - Message Source Task Queue (Cfm's will be sent to this Queue)
+ interfaceTag - Interface Identifier; unique identifier of an interface
+
+*******************************************************************************/
+#define CsrWifiSmeRoamingConfigGetReqCreate(msg__, dst__, src__, interfaceTag__) \
+ msg__ = kmalloc(sizeof(CsrWifiSmeRoamingConfigGetReq), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_ROAMING_CONFIG_GET_REQ, dst__, src__); \
+ msg__->interfaceTag = (interfaceTag__);
+
+#define CsrWifiSmeRoamingConfigGetReqSendTo(dst__, src__, interfaceTag__) \
+ { \
+ CsrWifiSmeRoamingConfigGetReq *msg__; \
+ CsrWifiSmeRoamingConfigGetReqCreate(msg__, dst__, src__, interfaceTag__); \
+ CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \
+ }
+
+#define CsrWifiSmeRoamingConfigGetReqSend(src__, interfaceTag__) \
+ CsrWifiSmeRoamingConfigGetReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__, interfaceTag__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeRoamingConfigGetCfmSend
+
+ DESCRIPTION
+ This primitive reports the result of the request.
+
+ PARAMETERS
+ queue - Destination Task Queue
+ interfaceTag - Interface Identifier; unique identifier of an interface
+ status - Reports the result of the request
+ roamingConfig - Reports the roaming behaviour of the driver and firmware
+
+*******************************************************************************/
+#define CsrWifiSmeRoamingConfigGetCfmCreate(msg__, dst__, src__, interfaceTag__, status__, roamingConfig__) \
+ msg__ = kmalloc(sizeof(CsrWifiSmeRoamingConfigGetCfm), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_ROAMING_CONFIG_GET_CFM, dst__, src__); \
+ msg__->interfaceTag = (interfaceTag__); \
+ msg__->status = (status__); \
+ msg__->roamingConfig = (roamingConfig__);
+
+#define CsrWifiSmeRoamingConfigGetCfmSendTo(dst__, src__, interfaceTag__, status__, roamingConfig__) \
+ { \
+ CsrWifiSmeRoamingConfigGetCfm *msg__; \
+ CsrWifiSmeRoamingConfigGetCfmCreate(msg__, dst__, src__, interfaceTag__, status__, roamingConfig__); \
+ CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
+ }
+
+#define CsrWifiSmeRoamingConfigGetCfmSend(dst__, interfaceTag__, status__, roamingConfig__) \
+ CsrWifiSmeRoamingConfigGetCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, interfaceTag__, status__, roamingConfig__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeRoamingConfigSetReqSend
+
+ DESCRIPTION
+ This primitive sets the value of the RoamingConfig parameter.
+
+ PARAMETERS
+ queue - Message Source Task Queue (Cfm's will be sent to this Queue)
+ interfaceTag - Interface Identifier; unique identifier of an interface
+ roamingConfig - Desired roaming behaviour values
+
+*******************************************************************************/
+#define CsrWifiSmeRoamingConfigSetReqCreate(msg__, dst__, src__, interfaceTag__, roamingConfig__) \
+ msg__ = kmalloc(sizeof(CsrWifiSmeRoamingConfigSetReq), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_ROAMING_CONFIG_SET_REQ, dst__, src__); \
+ msg__->interfaceTag = (interfaceTag__); \
+ msg__->roamingConfig = (roamingConfig__);
+
+#define CsrWifiSmeRoamingConfigSetReqSendTo(dst__, src__, interfaceTag__, roamingConfig__) \
+ { \
+ CsrWifiSmeRoamingConfigSetReq *msg__; \
+ CsrWifiSmeRoamingConfigSetReqCreate(msg__, dst__, src__, interfaceTag__, roamingConfig__); \
+ CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \
+ }
+
+#define CsrWifiSmeRoamingConfigSetReqSend(src__, interfaceTag__, roamingConfig__) \
+ CsrWifiSmeRoamingConfigSetReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__, interfaceTag__, roamingConfig__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeRoamingConfigSetCfmSend
+
+ DESCRIPTION
+ This primitive sets the value of the RoamingConfig parameter.
+
+ PARAMETERS
+ queue - Destination Task Queue
+ interfaceTag - Interface Identifier; unique identifier of an interface
+ status - Reports the result of the request
+
+*******************************************************************************/
+#define CsrWifiSmeRoamingConfigSetCfmCreate(msg__, dst__, src__, interfaceTag__, status__) \
+ msg__ = kmalloc(sizeof(CsrWifiSmeRoamingConfigSetCfm), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_ROAMING_CONFIG_SET_CFM, dst__, src__); \
+ msg__->interfaceTag = (interfaceTag__); \
+ msg__->status = (status__);
+
+#define CsrWifiSmeRoamingConfigSetCfmSendTo(dst__, src__, interfaceTag__, status__) \
+ { \
+ CsrWifiSmeRoamingConfigSetCfm *msg__; \
+ CsrWifiSmeRoamingConfigSetCfmCreate(msg__, dst__, src__, interfaceTag__, status__); \
+ CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
+ }
+
+#define CsrWifiSmeRoamingConfigSetCfmSend(dst__, interfaceTag__, status__) \
+ CsrWifiSmeRoamingConfigSetCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, interfaceTag__, status__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeScanConfigGetReqSend
+
+ DESCRIPTION
+ This primitive gets the value of the ScanConfig parameter.
+
+ PARAMETERS
+ queue - Message Source Task Queue (Cfm's will be sent to this Queue)
+
+*******************************************************************************/
+#define CsrWifiSmeScanConfigGetReqCreate(msg__, dst__, src__) \
+ msg__ = kmalloc(sizeof(CsrWifiSmeScanConfigGetReq), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_SCAN_CONFIG_GET_REQ, dst__, src__);
+
+#define CsrWifiSmeScanConfigGetReqSendTo(dst__, src__) \
+ { \
+ CsrWifiSmeScanConfigGetReq *msg__; \
+ CsrWifiSmeScanConfigGetReqCreate(msg__, dst__, src__); \
+ CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \
+ }
+
+#define CsrWifiSmeScanConfigGetReqSend(src__) \
+ CsrWifiSmeScanConfigGetReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeScanConfigGetCfmSend
+
+ DESCRIPTION
+ This primitive reports the result of the request.
+
+ PARAMETERS
+ queue - Destination Task Queue
+ status - Reports the result of the request
+ scanConfig - Returns the current parameters for the autonomous scanning
+ behaviour of the firmware
+
+*******************************************************************************/
+#define CsrWifiSmeScanConfigGetCfmCreate(msg__, dst__, src__, status__, scanConfig__) \
+ msg__ = kmalloc(sizeof(CsrWifiSmeScanConfigGetCfm), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_SCAN_CONFIG_GET_CFM, dst__, src__); \
+ msg__->status = (status__); \
+ msg__->scanConfig = (scanConfig__);
+
+#define CsrWifiSmeScanConfigGetCfmSendTo(dst__, src__, status__, scanConfig__) \
+ { \
+ CsrWifiSmeScanConfigGetCfm *msg__; \
+ CsrWifiSmeScanConfigGetCfmCreate(msg__, dst__, src__, status__, scanConfig__); \
+ CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
+ }
+
+#define CsrWifiSmeScanConfigGetCfmSend(dst__, status__, scanConfig__) \
+ CsrWifiSmeScanConfigGetCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, status__, scanConfig__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeScanConfigSetReqSend
+
+ DESCRIPTION
+ This primitive sets the value of the ScanConfig parameter.
+ The SME normally configures the firmware to perform autonomous scanning
+ without involving the host.
+ The firmware passes beacon / probe response or indicates loss of beacon
+ on certain changes of state, for example:
+ * A new AP is seen for the first time
+ * An AP is no longer visible
+ * The signal strength of an AP changes by more than a certain amount, as
+ configured by the thresholds in the scanConfig parameter
+ In addition to the autonomous scan, the wireless manager application may
+ request a scan at any time using CSR_WIFI_SME_SCAN_FULL_REQ.
+
+ PARAMETERS
+ queue - Message Source Task Queue (Cfm's will be sent to this Queue)
+ scanConfig - Reports the configuration for the autonomous scanning behaviour
+ of the firmware
+
+*******************************************************************************/
+#define CsrWifiSmeScanConfigSetReqCreate(msg__, dst__, src__, scanConfig__) \
+ msg__ = kmalloc(sizeof(CsrWifiSmeScanConfigSetReq), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_SCAN_CONFIG_SET_REQ, dst__, src__); \
+ msg__->scanConfig = (scanConfig__);
+
+#define CsrWifiSmeScanConfigSetReqSendTo(dst__, src__, scanConfig__) \
+ { \
+ CsrWifiSmeScanConfigSetReq *msg__; \
+ CsrWifiSmeScanConfigSetReqCreate(msg__, dst__, src__, scanConfig__); \
+ CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \
+ }
+
+#define CsrWifiSmeScanConfigSetReqSend(src__, scanConfig__) \
+ CsrWifiSmeScanConfigSetReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__, scanConfig__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeScanConfigSetCfmSend
+
+ DESCRIPTION
+ This primitive reports the result of the request.
+
+ PARAMETERS
+ queue - Destination Task Queue
+ status - Reports the result of the request
+
+*******************************************************************************/
+#define CsrWifiSmeScanConfigSetCfmCreate(msg__, dst__, src__, status__) \
+ msg__ = kmalloc(sizeof(CsrWifiSmeScanConfigSetCfm), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_SCAN_CONFIG_SET_CFM, dst__, src__); \
+ msg__->status = (status__);
+
+#define CsrWifiSmeScanConfigSetCfmSendTo(dst__, src__, status__) \
+ { \
+ CsrWifiSmeScanConfigSetCfm *msg__; \
+ CsrWifiSmeScanConfigSetCfmCreate(msg__, dst__, src__, status__); \
+ CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
+ }
+
+#define CsrWifiSmeScanConfigSetCfmSend(dst__, status__) \
+ CsrWifiSmeScanConfigSetCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, status__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeScanFullReqSend
+
+ DESCRIPTION
+ The wireless manager application should call this primitive to request a
+ full scan.
+ Channels are scanned actively or passively according to the requirement
+ set by regulatory domain.
+ If the SME receives this primitive while a full scan is going on, the new
+ request is buffered and it will be served after the current full scan is
+ completed.
+
+ PARAMETERS
+ queue - Message Source Task Queue (Cfm's will be sent to this Queue)
+ ssidCount - Number of SSIDs provided.
+ If it is 0, the SME will attempt to detect any network
+ ssid - Points to the first SSID provided, if any.
+ bssid - BSS identifier.
+ If it is equal to FF-FF-FF-FF-FF, the SME will listen for
+ messages from any BSS.
+ If it is different from FF-FF-FF-FF-FF and any SSID is
+ provided, one SSID must match the network of the BSS.
+ forceScan - Forces the scan even if the SME is in a state which would
+ normally prevent it (e.g. autonomous scan is running).
+ bssType - Type of BSS to scan for
+ scanType - Type of scan to perform
+ channelListCount - Number of channels provided.
+ If it is 0, the SME will initiate a scan of all the
+ supported channels that are permitted by the current
+ regulatory domain.
+ channelList - Points to the first channel , or NULL if channelListCount
+ is zero.
+ probeIeLength - Length of the information element in bytes to be sent
+ with the probe message.
+ probeIe - Points to the first byte of the information element to be
+ sent with the probe message.
+
+*******************************************************************************/
+#define CsrWifiSmeScanFullReqCreate(msg__, dst__, src__, ssidCount__, ssid__, bssid__, forceScan__, bssType__, scanType__, channelListCount__, channelList__, probeIeLength__, probeIe__) \
+ msg__ = kmalloc(sizeof(CsrWifiSmeScanFullReq), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_SCAN_FULL_REQ, dst__, src__); \
+ msg__->ssidCount = (ssidCount__); \
+ msg__->ssid = (ssid__); \
+ msg__->bssid = (bssid__); \
+ msg__->forceScan = (forceScan__); \
+ msg__->bssType = (bssType__); \
+ msg__->scanType = (scanType__); \
+ msg__->channelListCount = (channelListCount__); \
+ msg__->channelList = (channelList__); \
+ msg__->probeIeLength = (probeIeLength__); \
+ msg__->probeIe = (probeIe__);
+
+#define CsrWifiSmeScanFullReqSendTo(dst__, src__, ssidCount__, ssid__, bssid__, forceScan__, bssType__, scanType__, channelListCount__, channelList__, probeIeLength__, probeIe__) \
+ { \
+ CsrWifiSmeScanFullReq *msg__; \
+ CsrWifiSmeScanFullReqCreate(msg__, dst__, src__, ssidCount__, ssid__, bssid__, forceScan__, bssType__, scanType__, channelListCount__, channelList__, probeIeLength__, probeIe__); \
+ CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \
+ }
+
+#define CsrWifiSmeScanFullReqSend(src__, ssidCount__, ssid__, bssid__, forceScan__, bssType__, scanType__, channelListCount__, channelList__, probeIeLength__, probeIe__) \
+ CsrWifiSmeScanFullReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__, ssidCount__, ssid__, bssid__, forceScan__, bssType__, scanType__, channelListCount__, channelList__, probeIeLength__, probeIe__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeScanFullCfmSend
+
+ DESCRIPTION
+ The SME calls this primitive when the results from the scan are
+ available.
+
+ PARAMETERS
+ queue - Destination Task Queue
+ status - Reports the result of the request
+
+*******************************************************************************/
+#define CsrWifiSmeScanFullCfmCreate(msg__, dst__, src__, status__) \
+ msg__ = kmalloc(sizeof(CsrWifiSmeScanFullCfm), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_SCAN_FULL_CFM, dst__, src__); \
+ msg__->status = (status__);
+
+#define CsrWifiSmeScanFullCfmSendTo(dst__, src__, status__) \
+ { \
+ CsrWifiSmeScanFullCfm *msg__; \
+ CsrWifiSmeScanFullCfmCreate(msg__, dst__, src__, status__); \
+ CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
+ }
+
+#define CsrWifiSmeScanFullCfmSend(dst__, status__) \
+ CsrWifiSmeScanFullCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, status__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeScanResultIndSend
+
+ DESCRIPTION
+ The SME sends this primitive to all the tasks that have registered to
+ receive it whenever a scan indication is received from the firmware.
+
+ PARAMETERS
+ queue - Destination Task Queue
+ result - Points to a buffer containing a scan result.
+
+*******************************************************************************/
+#define CsrWifiSmeScanResultIndCreate(msg__, dst__, src__, result__) \
+ msg__ = kmalloc(sizeof(CsrWifiSmeScanResultInd), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_SCAN_RESULT_IND, dst__, src__); \
+ msg__->result = (result__);
+
+#define CsrWifiSmeScanResultIndSendTo(dst__, src__, result__) \
+ { \
+ CsrWifiSmeScanResultInd *msg__; \
+ CsrWifiSmeScanResultIndCreate(msg__, dst__, src__, result__); \
+ CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
+ }
+
+#define CsrWifiSmeScanResultIndSend(dst__, result__) \
+ CsrWifiSmeScanResultIndSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, result__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeScanResultsFlushReqSend
+
+ DESCRIPTION
+ The Wireless Manager calls this primitive to ask the SME to delete all
+ scan results from its cache, except for the scan result of any currently
+ connected network.
+ As scan results are received by the SME from the firmware, they are
+ cached in the SME memory.
+ Any time the Wireless Manager requests scan results, they are returned
+ from the SME internal cache.
+ For some applications it may be desirable to clear this cache prior to
+ requesting that a scan be performed; this will ensure that the cache then
+ only contains the networks detected in the most recent scan.
+
+ PARAMETERS
+ queue - Message Source Task Queue (Cfm's will be sent to this Queue)
+
+*******************************************************************************/
+#define CsrWifiSmeScanResultsFlushReqCreate(msg__, dst__, src__) \
+ msg__ = kmalloc(sizeof(CsrWifiSmeScanResultsFlushReq), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_SCAN_RESULTS_FLUSH_REQ, dst__, src__);
+
+#define CsrWifiSmeScanResultsFlushReqSendTo(dst__, src__) \
+ { \
+ CsrWifiSmeScanResultsFlushReq *msg__; \
+ CsrWifiSmeScanResultsFlushReqCreate(msg__, dst__, src__); \
+ CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \
+ }
+
+#define CsrWifiSmeScanResultsFlushReqSend(src__) \
+ CsrWifiSmeScanResultsFlushReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeScanResultsFlushCfmSend
+
+ DESCRIPTION
+ The SME will call this primitive when the cache has been cleared.
+
+ PARAMETERS
+ queue - Destination Task Queue
+ status - Reports the result of the request
+
+*******************************************************************************/
+#define CsrWifiSmeScanResultsFlushCfmCreate(msg__, dst__, src__, status__) \
+ msg__ = kmalloc(sizeof(CsrWifiSmeScanResultsFlushCfm), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_SCAN_RESULTS_FLUSH_CFM, dst__, src__); \
+ msg__->status = (status__);
+
+#define CsrWifiSmeScanResultsFlushCfmSendTo(dst__, src__, status__) \
+ { \
+ CsrWifiSmeScanResultsFlushCfm *msg__; \
+ CsrWifiSmeScanResultsFlushCfmCreate(msg__, dst__, src__, status__); \
+ CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
+ }
+
+#define CsrWifiSmeScanResultsFlushCfmSend(dst__, status__) \
+ CsrWifiSmeScanResultsFlushCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, status__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeScanResultsGetReqSend
+
+ DESCRIPTION
+ The wireless manager application calls this primitive to retrieve the
+ current set of scan results, either after receiving a successful
+ CSR_WIFI_SME_SCAN_FULL_CFM, or to get autonomous scan results.
+
+ PARAMETERS
+ queue - Message Source Task Queue (Cfm's will be sent to this Queue)
+
+*******************************************************************************/
+#define CsrWifiSmeScanResultsGetReqCreate(msg__, dst__, src__) \
+ msg__ = kmalloc(sizeof(CsrWifiSmeScanResultsGetReq), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_SCAN_RESULTS_GET_REQ, dst__, src__);
+
+#define CsrWifiSmeScanResultsGetReqSendTo(dst__, src__) \
+ { \
+ CsrWifiSmeScanResultsGetReq *msg__; \
+ CsrWifiSmeScanResultsGetReqCreate(msg__, dst__, src__); \
+ CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \
+ }
+
+#define CsrWifiSmeScanResultsGetReqSend(src__) \
+ CsrWifiSmeScanResultsGetReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeScanResultsGetCfmSend
+
+ DESCRIPTION
+ The SME sends this primitive to provide the current set of scan results.
+
+ PARAMETERS
+ queue - Destination Task Queue
+ status - Reports the result of the request
+ scanResultsCount - Number of scan results
+ scanResults - Points to a buffer containing an array of
+ CsrWifiSmeScanResult structures.
+
+*******************************************************************************/
+#define CsrWifiSmeScanResultsGetCfmCreate(msg__, dst__, src__, status__, scanResultsCount__, scanResults__) \
+ msg__ = kmalloc(sizeof(CsrWifiSmeScanResultsGetCfm), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_SCAN_RESULTS_GET_CFM, dst__, src__); \
+ msg__->status = (status__); \
+ msg__->scanResultsCount = (scanResultsCount__); \
+ msg__->scanResults = (scanResults__);
+
+#define CsrWifiSmeScanResultsGetCfmSendTo(dst__, src__, status__, scanResultsCount__, scanResults__) \
+ { \
+ CsrWifiSmeScanResultsGetCfm *msg__; \
+ CsrWifiSmeScanResultsGetCfmCreate(msg__, dst__, src__, status__, scanResultsCount__, scanResults__); \
+ CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
+ }
+
+#define CsrWifiSmeScanResultsGetCfmSend(dst__, status__, scanResultsCount__, scanResults__) \
+ CsrWifiSmeScanResultsGetCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, status__, scanResultsCount__, scanResults__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeSetReqSend
+
+ DESCRIPTION
+ Used to pass custom data to the SME. Format is the same as 802.11 Info
+ Elements => | Id | Length | Data
+ 1) Cmanr Test Mode "Id:0 Length:1 Data:0x00 = OFF 0x01 = ON" "0x00 0x01
+ (0x00|0x01)"
+
+ PARAMETERS
+ queue - Message Source Task Queue (Cfm's will be sent to this Queue)
+ dataLength - Number of bytes in the buffer pointed to by 'data'
+ data - Pointer to the buffer containing 'dataLength' bytes
+
+*******************************************************************************/
+#define CsrWifiSmeSetReqCreate(msg__, dst__, src__, dataLength__, data__) \
+ msg__ = kmalloc(sizeof(CsrWifiSmeSetReq), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_SET_REQ, dst__, src__); \
+ msg__->dataLength = (dataLength__); \
+ msg__->data = (data__);
+
+#define CsrWifiSmeSetReqSendTo(dst__, src__, dataLength__, data__) \
+ { \
+ CsrWifiSmeSetReq *msg__; \
+ CsrWifiSmeSetReqCreate(msg__, dst__, src__, dataLength__, data__); \
+ CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \
+ }
+
+#define CsrWifiSmeSetReqSend(src__, dataLength__, data__) \
+ CsrWifiSmeSetReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__, dataLength__, data__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeSmeCommonConfigGetReqSend
+
+ DESCRIPTION
+ This primitive gets the value of the Sme common parameter.
+
+ PARAMETERS
+ queue - Message Source Task Queue (Cfm's will be sent to this Queue)
+
+*******************************************************************************/
+#define CsrWifiSmeSmeCommonConfigGetReqCreate(msg__, dst__, src__) \
+ msg__ = kmalloc(sizeof(CsrWifiSmeSmeCommonConfigGetReq), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_SME_COMMON_CONFIG_GET_REQ, dst__, src__);
+
+#define CsrWifiSmeSmeCommonConfigGetReqSendTo(dst__, src__) \
+ { \
+ CsrWifiSmeSmeCommonConfigGetReq *msg__; \
+ CsrWifiSmeSmeCommonConfigGetReqCreate(msg__, dst__, src__); \
+ CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \
+ }
+
+#define CsrWifiSmeSmeCommonConfigGetReqSend(src__) \
+ CsrWifiSmeSmeCommonConfigGetReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeSmeCommonConfigGetCfmSend
+
+ DESCRIPTION
+ This primitive reports the result of the request.
+
+ PARAMETERS
+ queue - Destination Task Queue
+ status - Reports the result of the request
+ deviceConfig - Configuration options in the SME
+
+*******************************************************************************/
+#define CsrWifiSmeSmeCommonConfigGetCfmCreate(msg__, dst__, src__, status__, deviceConfig__) \
+ msg__ = kmalloc(sizeof(CsrWifiSmeSmeCommonConfigGetCfm), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_SME_COMMON_CONFIG_GET_CFM, dst__, src__); \
+ msg__->status = (status__); \
+ msg__->deviceConfig = (deviceConfig__);
+
+#define CsrWifiSmeSmeCommonConfigGetCfmSendTo(dst__, src__, status__, deviceConfig__) \
+ { \
+ CsrWifiSmeSmeCommonConfigGetCfm *msg__; \
+ CsrWifiSmeSmeCommonConfigGetCfmCreate(msg__, dst__, src__, status__, deviceConfig__); \
+ CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
+ }
+
+#define CsrWifiSmeSmeCommonConfigGetCfmSend(dst__, status__, deviceConfig__) \
+ CsrWifiSmeSmeCommonConfigGetCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, status__, deviceConfig__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeSmeCommonConfigSetReqSend
+
+ DESCRIPTION
+ This primitive sets the value of the Sme common.
+
+ PARAMETERS
+ queue - Message Source Task Queue (Cfm's will be sent to this Queue)
+ deviceConfig - Configuration options in the SME
+
+*******************************************************************************/
+#define CsrWifiSmeSmeCommonConfigSetReqCreate(msg__, dst__, src__, deviceConfig__) \
+ msg__ = kmalloc(sizeof(CsrWifiSmeSmeCommonConfigSetReq), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_SME_COMMON_CONFIG_SET_REQ, dst__, src__); \
+ msg__->deviceConfig = (deviceConfig__);
+
+#define CsrWifiSmeSmeCommonConfigSetReqSendTo(dst__, src__, deviceConfig__) \
+ { \
+ CsrWifiSmeSmeCommonConfigSetReq *msg__; \
+ CsrWifiSmeSmeCommonConfigSetReqCreate(msg__, dst__, src__, deviceConfig__); \
+ CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \
+ }
+
+#define CsrWifiSmeSmeCommonConfigSetReqSend(src__, deviceConfig__) \
+ CsrWifiSmeSmeCommonConfigSetReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__, deviceConfig__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeSmeCommonConfigSetCfmSend
+
+ DESCRIPTION
+ Reports the result of the request
+
+ PARAMETERS
+ queue - Destination Task Queue
+ status - Reports the result of the request
+
+*******************************************************************************/
+#define CsrWifiSmeSmeCommonConfigSetCfmCreate(msg__, dst__, src__, status__) \
+ msg__ = kmalloc(sizeof(CsrWifiSmeSmeCommonConfigSetCfm), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_SME_COMMON_CONFIG_SET_CFM, dst__, src__); \
+ msg__->status = (status__);
+
+#define CsrWifiSmeSmeCommonConfigSetCfmSendTo(dst__, src__, status__) \
+ { \
+ CsrWifiSmeSmeCommonConfigSetCfm *msg__; \
+ CsrWifiSmeSmeCommonConfigSetCfmCreate(msg__, dst__, src__, status__); \
+ CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
+ }
+
+#define CsrWifiSmeSmeCommonConfigSetCfmSend(dst__, status__) \
+ CsrWifiSmeSmeCommonConfigSetCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, status__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeSmeStaConfigGetReqSend
+
+ DESCRIPTION
+ This primitive gets the value of the SmeStaConfig parameter.
+
+ PARAMETERS
+ queue - Message Source Task Queue (Cfm's will be sent to this Queue)
+ interfaceTag - Interface Identifier; unique identifier of an interface
+
+*******************************************************************************/
+#define CsrWifiSmeSmeStaConfigGetReqCreate(msg__, dst__, src__, interfaceTag__) \
+ msg__ = kmalloc(sizeof(CsrWifiSmeSmeStaConfigGetReq), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_SME_STA_CONFIG_GET_REQ, dst__, src__); \
+ msg__->interfaceTag = (interfaceTag__);
+
+#define CsrWifiSmeSmeStaConfigGetReqSendTo(dst__, src__, interfaceTag__) \
+ { \
+ CsrWifiSmeSmeStaConfigGetReq *msg__; \
+ CsrWifiSmeSmeStaConfigGetReqCreate(msg__, dst__, src__, interfaceTag__); \
+ CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \
+ }
+
+#define CsrWifiSmeSmeStaConfigGetReqSend(src__, interfaceTag__) \
+ CsrWifiSmeSmeStaConfigGetReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__, interfaceTag__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeSmeStaConfigGetCfmSend
+
+ DESCRIPTION
+ This primitive reports the result of the request.
+
+ PARAMETERS
+ queue - Destination Task Queue
+ interfaceTag - Interface Identifier; unique identifier of an interface
+ status - Reports the result of the request
+ smeConfig - Current SME Station Parameters
+
+*******************************************************************************/
+#define CsrWifiSmeSmeStaConfigGetCfmCreate(msg__, dst__, src__, interfaceTag__, status__, smeConfig__) \
+ msg__ = kmalloc(sizeof(CsrWifiSmeSmeStaConfigGetCfm), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_SME_STA_CONFIG_GET_CFM, dst__, src__); \
+ msg__->interfaceTag = (interfaceTag__); \
+ msg__->status = (status__); \
+ msg__->smeConfig = (smeConfig__);
+
+#define CsrWifiSmeSmeStaConfigGetCfmSendTo(dst__, src__, interfaceTag__, status__, smeConfig__) \
+ { \
+ CsrWifiSmeSmeStaConfigGetCfm *msg__; \
+ CsrWifiSmeSmeStaConfigGetCfmCreate(msg__, dst__, src__, interfaceTag__, status__, smeConfig__); \
+ CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
+ }
+
+#define CsrWifiSmeSmeStaConfigGetCfmSend(dst__, interfaceTag__, status__, smeConfig__) \
+ CsrWifiSmeSmeStaConfigGetCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, interfaceTag__, status__, smeConfig__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeSmeStaConfigSetReqSend
+
+ DESCRIPTION
+ This primitive sets the value of the SmeConfig parameter.
+
+ PARAMETERS
+ queue - Message Source Task Queue (Cfm's will be sent to this Queue)
+ interfaceTag - Interface Identifier; unique identifier of an interface
+ smeConfig - SME Station Parameters to be set
+
+*******************************************************************************/
+#define CsrWifiSmeSmeStaConfigSetReqCreate(msg__, dst__, src__, interfaceTag__, smeConfig__) \
+ msg__ = kmalloc(sizeof(CsrWifiSmeSmeStaConfigSetReq), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_SME_STA_CONFIG_SET_REQ, dst__, src__); \
+ msg__->interfaceTag = (interfaceTag__); \
+ msg__->smeConfig = (smeConfig__);
+
+#define CsrWifiSmeSmeStaConfigSetReqSendTo(dst__, src__, interfaceTag__, smeConfig__) \
+ { \
+ CsrWifiSmeSmeStaConfigSetReq *msg__; \
+ CsrWifiSmeSmeStaConfigSetReqCreate(msg__, dst__, src__, interfaceTag__, smeConfig__); \
+ CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \
+ }
+
+#define CsrWifiSmeSmeStaConfigSetReqSend(src__, interfaceTag__, smeConfig__) \
+ CsrWifiSmeSmeStaConfigSetReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__, interfaceTag__, smeConfig__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeSmeStaConfigSetCfmSend
+
+ DESCRIPTION
+ This primitive reports the result of the request.
+
+ PARAMETERS
+ queue - Destination Task Queue
+ interfaceTag - Interface Identifier; unique identifier of an interface
+ status - Reports the result of the request
+
+*******************************************************************************/
+#define CsrWifiSmeSmeStaConfigSetCfmCreate(msg__, dst__, src__, interfaceTag__, status__) \
+ msg__ = kmalloc(sizeof(CsrWifiSmeSmeStaConfigSetCfm), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_SME_STA_CONFIG_SET_CFM, dst__, src__); \
+ msg__->interfaceTag = (interfaceTag__); \
+ msg__->status = (status__);
+
+#define CsrWifiSmeSmeStaConfigSetCfmSendTo(dst__, src__, interfaceTag__, status__) \
+ { \
+ CsrWifiSmeSmeStaConfigSetCfm *msg__; \
+ CsrWifiSmeSmeStaConfigSetCfmCreate(msg__, dst__, src__, interfaceTag__, status__); \
+ CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
+ }
+
+#define CsrWifiSmeSmeStaConfigSetCfmSend(dst__, interfaceTag__, status__) \
+ CsrWifiSmeSmeStaConfigSetCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, interfaceTag__, status__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeStationMacAddressGetReqSend
+
+ DESCRIPTION
+ This primitives is used to retrieve the current MAC address used by the
+ station.
+
+ PARAMETERS
+ queue - Message Source Task Queue (Cfm's will be sent to this Queue)
+
+*******************************************************************************/
+#define CsrWifiSmeStationMacAddressGetReqCreate(msg__, dst__, src__) \
+ msg__ = kmalloc(sizeof(CsrWifiSmeStationMacAddressGetReq), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_STATION_MAC_ADDRESS_GET_REQ, dst__, src__);
+
+#define CsrWifiSmeStationMacAddressGetReqSendTo(dst__, src__) \
+ { \
+ CsrWifiSmeStationMacAddressGetReq *msg__; \
+ CsrWifiSmeStationMacAddressGetReqCreate(msg__, dst__, src__); \
+ CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \
+ }
+
+#define CsrWifiSmeStationMacAddressGetReqSend(src__) \
+ CsrWifiSmeStationMacAddressGetReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeStationMacAddressGetCfmSend
+
+ DESCRIPTION
+ This primitive reports the result of the request.
+
+ PARAMETERS
+ queue - Destination Task Queue
+ status - Reports the result of the request
+ stationMacAddress - Current MAC address of the station.
+
+*******************************************************************************/
+#define CsrWifiSmeStationMacAddressGetCfmCreate(msg__, dst__, src__, status__, stationMacAddress__) \
+ msg__ = kmalloc(sizeof(CsrWifiSmeStationMacAddressGetCfm), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_STATION_MAC_ADDRESS_GET_CFM, dst__, src__); \
+ msg__->status = (status__); \
+ memcpy(msg__->stationMacAddress, (stationMacAddress__), sizeof(CsrWifiMacAddress) * 2);
+
+#define CsrWifiSmeStationMacAddressGetCfmSendTo(dst__, src__, status__, stationMacAddress__) \
+ { \
+ CsrWifiSmeStationMacAddressGetCfm *msg__; \
+ CsrWifiSmeStationMacAddressGetCfmCreate(msg__, dst__, src__, status__, stationMacAddress__); \
+ CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
+ }
+
+#define CsrWifiSmeStationMacAddressGetCfmSend(dst__, status__, stationMacAddress__) \
+ CsrWifiSmeStationMacAddressGetCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, status__, stationMacAddress__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeTspecReqSend
+
+ DESCRIPTION
+ The wireless manager application should call this primitive to use the
+ TSPEC feature.
+ The chip supports the use of TSPECs and TCLAS for the use of IEEE
+ 802.11/WMM Quality of Service features.
+ The API allows the wireless manager application to supply a correctly
+ formatted TSPEC and TCLAS pair to the driver.
+ After performing basic validation, the driver negotiates the installation
+ of the TSPEC with the AP as defined by the 802.11 specification.
+ The driver retains all TSPEC and TCLAS pairs until they are specifically
+ removed.
+ It is not compulsory for a TSPEC to have a TCLAS (NULL is used to
+ indicate that no TCLAS is supplied), while a TCLASS always require a
+ TSPEC.
+ The format of the TSPEC element is specified in 'WMM (including WMM Power
+ Save) Specification - Version 1.1' and 'ANSI/IEEE Std 802.11-REVmb/D3.0'.
+ For more information, see 'UniFi Configuring WMM and WMM-PS'.
+
+ PARAMETERS
+ queue - Message Source Task Queue (Cfm's will be sent to this Queue)
+ interfaceTag - Interface Identifier; unique identifier of an interface
+ action - Specifies the action to be carried out on the list of TSPECs.
+ CSR_WIFI_SME_LIST_ACTION_FLUSH is not applicable here.
+ transactionId - Unique Transaction ID for the TSPEC, as assigned by the
+ driver
+ strict - If it set to false, allows the SME to perform automatic
+ TSPEC negotiation
+ ctrlMask - Additional TSPEC configuration for CCX.
+ Set mask with values from CsrWifiSmeTspecCtrl.
+ CURRENTLY NOT SUPPORTED
+ tspecLength - Length of the TSPEC.
+ tspec - Points to the first byte of the TSPEC
+ tclasLength - Length of the TCLAS.
+ If it is equal to 0, no TCLASS is provided for the TSPEC
+ tclas - Points to the first byte of the TCLAS, if any.
+
+*******************************************************************************/
+#define CsrWifiSmeTspecReqCreate(msg__, dst__, src__, interfaceTag__, action__, transactionId__, strict__, ctrlMask__, tspecLength__, tspec__, tclasLength__, tclas__) \
+ msg__ = kmalloc(sizeof(CsrWifiSmeTspecReq), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_TSPEC_REQ, dst__, src__); \
+ msg__->interfaceTag = (interfaceTag__); \
+ msg__->action = (action__); \
+ msg__->transactionId = (transactionId__); \
+ msg__->strict = (strict__); \
+ msg__->ctrlMask = (ctrlMask__); \
+ msg__->tspecLength = (tspecLength__); \
+ msg__->tspec = (tspec__); \
+ msg__->tclasLength = (tclasLength__); \
+ msg__->tclas = (tclas__);
+
+#define CsrWifiSmeTspecReqSendTo(dst__, src__, interfaceTag__, action__, transactionId__, strict__, ctrlMask__, tspecLength__, tspec__, tclasLength__, tclas__) \
+ { \
+ CsrWifiSmeTspecReq *msg__; \
+ CsrWifiSmeTspecReqCreate(msg__, dst__, src__, interfaceTag__, action__, transactionId__, strict__, ctrlMask__, tspecLength__, tspec__, tclasLength__, tclas__); \
+ CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \
+ }
+
+#define CsrWifiSmeTspecReqSend(src__, interfaceTag__, action__, transactionId__, strict__, ctrlMask__, tspecLength__, tspec__, tclasLength__, tclas__) \
+ CsrWifiSmeTspecReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__, interfaceTag__, action__, transactionId__, strict__, ctrlMask__, tspecLength__, tspec__, tclasLength__, tclas__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeTspecIndSend
+
+ DESCRIPTION
+ The SME will send this primitive to all the task that have registered to
+ receive it when a status change in the TSPEC occurs.
+
+ PARAMETERS
+ queue - Destination Task Queue
+ interfaceTag - Interface Identifier; unique identifier of an interface
+ transactionId - Unique Transaction ID for the TSPEC, as assigned by the
+ driver
+ tspecResultCode - Specifies the TSPEC operation requested by the peer
+ station
+ tspecLength - Length of the TSPEC.
+ tspec - Points to the first byte of the TSPEC
+
+*******************************************************************************/
+#define CsrWifiSmeTspecIndCreate(msg__, dst__, src__, interfaceTag__, transactionId__, tspecResultCode__, tspecLength__, tspec__) \
+ msg__ = kmalloc(sizeof(CsrWifiSmeTspecInd), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_TSPEC_IND, dst__, src__); \
+ msg__->interfaceTag = (interfaceTag__); \
+ msg__->transactionId = (transactionId__); \
+ msg__->tspecResultCode = (tspecResultCode__); \
+ msg__->tspecLength = (tspecLength__); \
+ msg__->tspec = (tspec__);
+
+#define CsrWifiSmeTspecIndSendTo(dst__, src__, interfaceTag__, transactionId__, tspecResultCode__, tspecLength__, tspec__) \
+ { \
+ CsrWifiSmeTspecInd *msg__; \
+ CsrWifiSmeTspecIndCreate(msg__, dst__, src__, interfaceTag__, transactionId__, tspecResultCode__, tspecLength__, tspec__); \
+ CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
+ }
+
+#define CsrWifiSmeTspecIndSend(dst__, interfaceTag__, transactionId__, tspecResultCode__, tspecLength__, tspec__) \
+ CsrWifiSmeTspecIndSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, interfaceTag__, transactionId__, tspecResultCode__, tspecLength__, tspec__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeTspecCfmSend
+
+ DESCRIPTION
+ The SME calls the primitive to report the result of the TSpec primitive
+ request.
+
+ PARAMETERS
+ queue - Destination Task Queue
+ interfaceTag - Interface Identifier; unique identifier of an interface
+ status - Reports the result of the request
+ transactionId - Unique Transaction ID for the TSPEC, as assigned by the
+ driver
+ tspecResultCode - Specifies the result of the negotiated TSPEC operation
+ tspecLength - Length of the TSPEC.
+ tspec - Points to the first byte of the TSPEC
+
+*******************************************************************************/
+#define CsrWifiSmeTspecCfmCreate(msg__, dst__, src__, interfaceTag__, status__, transactionId__, tspecResultCode__, tspecLength__, tspec__) \
+ msg__ = kmalloc(sizeof(CsrWifiSmeTspecCfm), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_TSPEC_CFM, dst__, src__); \
+ msg__->interfaceTag = (interfaceTag__); \
+ msg__->status = (status__); \
+ msg__->transactionId = (transactionId__); \
+ msg__->tspecResultCode = (tspecResultCode__); \
+ msg__->tspecLength = (tspecLength__); \
+ msg__->tspec = (tspec__);
+
+#define CsrWifiSmeTspecCfmSendTo(dst__, src__, interfaceTag__, status__, transactionId__, tspecResultCode__, tspecLength__, tspec__) \
+ { \
+ CsrWifiSmeTspecCfm *msg__; \
+ CsrWifiSmeTspecCfmCreate(msg__, dst__, src__, interfaceTag__, status__, transactionId__, tspecResultCode__, tspecLength__, tspec__); \
+ CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
+ }
+
+#define CsrWifiSmeTspecCfmSend(dst__, interfaceTag__, status__, transactionId__, tspecResultCode__, tspecLength__, tspec__) \
+ CsrWifiSmeTspecCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, interfaceTag__, status__, transactionId__, tspecResultCode__, tspecLength__, tspec__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeVersionsGetReqSend
+
+ DESCRIPTION
+ This primitive gets the value of the Versions parameter.
+
+ PARAMETERS
+ queue - Message Source Task Queue (Cfm's will be sent to this Queue)
+
+*******************************************************************************/
+#define CsrWifiSmeVersionsGetReqCreate(msg__, dst__, src__) \
+ msg__ = kmalloc(sizeof(CsrWifiSmeVersionsGetReq), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_VERSIONS_GET_REQ, dst__, src__);
+
+#define CsrWifiSmeVersionsGetReqSendTo(dst__, src__) \
+ { \
+ CsrWifiSmeVersionsGetReq *msg__; \
+ CsrWifiSmeVersionsGetReqCreate(msg__, dst__, src__); \
+ CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \
+ }
+
+#define CsrWifiSmeVersionsGetReqSend(src__) \
+ CsrWifiSmeVersionsGetReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeVersionsGetCfmSend
+
+ DESCRIPTION
+ This primitive reports the result of the request.
+
+ PARAMETERS
+ queue - Destination Task Queue
+ status - Reports the result of the request
+ versions - Version IDs of the product
+
+*******************************************************************************/
+#define CsrWifiSmeVersionsGetCfmCreate(msg__, dst__, src__, status__, versions__) \
+ msg__ = kmalloc(sizeof(CsrWifiSmeVersionsGetCfm), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_VERSIONS_GET_CFM, dst__, src__); \
+ msg__->status = (status__); \
+ msg__->versions = (versions__);
+
+#define CsrWifiSmeVersionsGetCfmSendTo(dst__, src__, status__, versions__) \
+ { \
+ CsrWifiSmeVersionsGetCfm *msg__; \
+ CsrWifiSmeVersionsGetCfmCreate(msg__, dst__, src__, status__, versions__); \
+ CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
+ }
+
+#define CsrWifiSmeVersionsGetCfmSend(dst__, status__, versions__) \
+ CsrWifiSmeVersionsGetCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, status__, versions__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeWifiFlightmodeReqSend
+
+ DESCRIPTION
+ The wireless manager application may call this primitive on boot-up of
+ the platform to ensure that the chip is placed in a mode that prevents
+ any emission of RF energy.
+ This primitive is an alternative to CSR_WIFI_SME_WIFI_ON_REQ.
+ As in CSR_WIFI_SME_WIFI_ON_REQ, it causes the download of the patch file
+ (if any) and the programming of the initial MIB settings (if supplied by
+ the WMA), but it also ensures that the chip is left in its lowest
+ possible power-mode with the radio subsystems disabled.
+ This feature is useful on platforms where power cannot be removed from
+ the chip (leaving the chip not initialised will cause it to consume more
+ power so calling this function ensures that the chip is initialised into
+ a low power mode but without entering a state where it could emit any RF
+ energy).
+ NOTE: this primitive does not cause the Wi-Fi to change state: Wi-Fi
+ stays conceptually off. Configuration primitives can be sent after
+ CSR_WIFI_SME_WIFI_FLIGHTMODE_REQ and the configuration will be maintained.
+ Requests that require the state of the Wi-Fi to be ON will return
+ CSR_WIFI_SME_STATUS_WIFI_OFF in their confirms.
+
+ PARAMETERS
+ queue - Message Source Task Queue (Cfm's will be sent to this Queue)
+ address - Optionally specifies a station MAC address.
+ In normal use, the manager should set the address to 0xFF
+ 0xFF 0xFF 0xFF 0xFF 0xFF, which will cause the chip to use
+ the MAC address in the MIB.
+ mibFilesCount - Number of provided data blocks with initial MIB values
+ mibFiles - Points to the first data block with initial MIB values.
+ These data blocks are typically the contents of the provided
+ files ufmib.dat and localmib.dat, available from the host
+ file system, if they exist.
+ These files typically contain radio tuning and calibration
+ values.
+ More values can be created using the Host Tools.
+
+*******************************************************************************/
+#define CsrWifiSmeWifiFlightmodeReqCreate(msg__, dst__, src__, address__, mibFilesCount__, mibFiles__) \
+ msg__ = kmalloc(sizeof(CsrWifiSmeWifiFlightmodeReq), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_WIFI_FLIGHTMODE_REQ, dst__, src__); \
+ msg__->address = (address__); \
+ msg__->mibFilesCount = (mibFilesCount__); \
+ msg__->mibFiles = (mibFiles__);
+
+#define CsrWifiSmeWifiFlightmodeReqSendTo(dst__, src__, address__, mibFilesCount__, mibFiles__) \
+ { \
+ CsrWifiSmeWifiFlightmodeReq *msg__; \
+ CsrWifiSmeWifiFlightmodeReqCreate(msg__, dst__, src__, address__, mibFilesCount__, mibFiles__); \
+ CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \
+ }
+
+#define CsrWifiSmeWifiFlightmodeReqSend(src__, address__, mibFilesCount__, mibFiles__) \
+ CsrWifiSmeWifiFlightmodeReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__, address__, mibFilesCount__, mibFiles__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeWifiFlightmodeCfmSend
+
+ DESCRIPTION
+ The SME calls this primitive when the chip is initialised for low power
+ mode and with the radio subsystem disabled. To leave flight mode, and
+ enable Wi-Fi, the wireless manager application should call
+ CSR_WIFI_SME_WIFI_ON_REQ.
+
+ PARAMETERS
+ queue - Destination Task Queue
+ status - Reports the result of the request
+
+*******************************************************************************/
+#define CsrWifiSmeWifiFlightmodeCfmCreate(msg__, dst__, src__, status__) \
+ msg__ = kmalloc(sizeof(CsrWifiSmeWifiFlightmodeCfm), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_WIFI_FLIGHTMODE_CFM, dst__, src__); \
+ msg__->status = (status__);
+
+#define CsrWifiSmeWifiFlightmodeCfmSendTo(dst__, src__, status__) \
+ { \
+ CsrWifiSmeWifiFlightmodeCfm *msg__; \
+ CsrWifiSmeWifiFlightmodeCfmCreate(msg__, dst__, src__, status__); \
+ CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
+ }
+
+#define CsrWifiSmeWifiFlightmodeCfmSend(dst__, status__) \
+ CsrWifiSmeWifiFlightmodeCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, status__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeWifiOffReqSend
+
+ DESCRIPTION
+ The wireless manager application calls this primitive to turn off the
+ chip, thus saving power when Wi-Fi is not in use.
+
+ PARAMETERS
+ queue - Message Source Task Queue (Cfm's will be sent to this Queue)
+
+*******************************************************************************/
+#define CsrWifiSmeWifiOffReqCreate(msg__, dst__, src__) \
+ msg__ = kmalloc(sizeof(CsrWifiSmeWifiOffReq), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_WIFI_OFF_REQ, dst__, src__);
+
+#define CsrWifiSmeWifiOffReqSendTo(dst__, src__) \
+ { \
+ CsrWifiSmeWifiOffReq *msg__; \
+ CsrWifiSmeWifiOffReqCreate(msg__, dst__, src__); \
+ CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \
+ }
+
+#define CsrWifiSmeWifiOffReqSend(src__) \
+ CsrWifiSmeWifiOffReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeWifiOffIndSend
+
+ DESCRIPTION
+ The SME sends this primitive to all the tasks that have registered to
+ receive it to report that the chip has been turned off.
+
+ PARAMETERS
+ queue - Destination Task Queue
+ reason - Indicates the reason why the Wi-Fi has been switched off.
+
+*******************************************************************************/
+#define CsrWifiSmeWifiOffIndCreate(msg__, dst__, src__, reason__) \
+ msg__ = kmalloc(sizeof(CsrWifiSmeWifiOffInd), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_WIFI_OFF_IND, dst__, src__); \
+ msg__->reason = (reason__);
+
+#define CsrWifiSmeWifiOffIndSendTo(dst__, src__, reason__) \
+ { \
+ CsrWifiSmeWifiOffInd *msg__; \
+ CsrWifiSmeWifiOffIndCreate(msg__, dst__, src__, reason__); \
+ CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
+ }
+
+#define CsrWifiSmeWifiOffIndSend(dst__, reason__) \
+ CsrWifiSmeWifiOffIndSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, reason__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeWifiOffCfmSend
+
+ DESCRIPTION
+ After receiving CSR_WIFI_SME_WIFI_OFF_REQ, if the chip is connected to a
+ network, the SME will perform a disconnect operation, will send a
+ CSR_WIFI_SME_MEDIA_STATUS_IND with
+ CSR_WIFI_SME_MEDIA_STATUS_DISCONNECTED, and then will call
+ CSR_WIFI_SME_WIFI_OFF_CFM when the chip is off.
+
+ PARAMETERS
+ queue - Destination Task Queue
+ status - Reports the result of the request
+
+*******************************************************************************/
+#define CsrWifiSmeWifiOffCfmCreate(msg__, dst__, src__, status__) \
+ msg__ = kmalloc(sizeof(CsrWifiSmeWifiOffCfm), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_WIFI_OFF_CFM, dst__, src__); \
+ msg__->status = (status__);
+
+#define CsrWifiSmeWifiOffCfmSendTo(dst__, src__, status__) \
+ { \
+ CsrWifiSmeWifiOffCfm *msg__; \
+ CsrWifiSmeWifiOffCfmCreate(msg__, dst__, src__, status__); \
+ CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
+ }
+
+#define CsrWifiSmeWifiOffCfmSend(dst__, status__) \
+ CsrWifiSmeWifiOffCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, status__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeWifiOnReqSend
+
+ DESCRIPTION
+ The wireless manager application calls this primitive to turn on the
+ Wi-Fi chip.
+ If the Wi-Fi chip is currently off, the SME turns the Wi-Fi chip on,
+ downloads the patch file (if any), and programs the initial MIB settings
+ (if supplied by the WMA).
+ The patch file is not provided with the SME API; its downloading is
+ automatic and handled internally by the system.
+ The MIB settings, when provided, override the default values that the
+ firmware loads from EEPROM.
+ If the Wi-Fi chip is already on, the SME takes no action and returns a
+ successful status in the confirm.
+
+ PARAMETERS
+ queue - Message Source Task Queue (Cfm's will be sent to this Queue)
+ address - Optionally specifies a station MAC address.
+ In normal use, the manager should set the address to 0xFF
+ 0xFF 0xFF 0xFF 0xFF 0xFF, which will cause the chip to use
+ the MAC address in the MIB
+ mibFilesCount - Number of provided data blocks with initial MIB values
+ mibFiles - Points to the first data block with initial MIB values.
+ These data blocks are typically the contents of the provided
+ files ufmib.dat and localmib.dat, available from the host
+ file system, if they exist.
+ These files typically contain radio tuning and calibration
+ values.
+ More values can be created using the Host Tools.
+
+*******************************************************************************/
+#define CsrWifiSmeWifiOnReqCreate(msg__, dst__, src__, address__, mibFilesCount__, mibFiles__) \
+ msg__ = kmalloc(sizeof(CsrWifiSmeWifiOnReq), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_WIFI_ON_REQ, dst__, src__); \
+ msg__->address = (address__); \
+ msg__->mibFilesCount = (mibFilesCount__); \
+ msg__->mibFiles = (mibFiles__);
+
+#define CsrWifiSmeWifiOnReqSendTo(dst__, src__, address__, mibFilesCount__, mibFiles__) \
+ { \
+ CsrWifiSmeWifiOnReq *msg__; \
+ CsrWifiSmeWifiOnReqCreate(msg__, dst__, src__, address__, mibFilesCount__, mibFiles__); \
+ CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \
+ }
+
+#define CsrWifiSmeWifiOnReqSend(src__, address__, mibFilesCount__, mibFiles__) \
+ CsrWifiSmeWifiOnReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__, address__, mibFilesCount__, mibFiles__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeWifiOnIndSend
+
+ DESCRIPTION
+ The SME sends this primitive to all tasks that have registered to receive
+ it once the chip becomes available and ready to use.
+
+ PARAMETERS
+ queue - Destination Task Queue
+ address - Current MAC address
+
+*******************************************************************************/
+#define CsrWifiSmeWifiOnIndCreate(msg__, dst__, src__, address__) \
+ msg__ = kmalloc(sizeof(CsrWifiSmeWifiOnInd), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_WIFI_ON_IND, dst__, src__); \
+ msg__->address = (address__);
+
+#define CsrWifiSmeWifiOnIndSendTo(dst__, src__, address__) \
+ { \
+ CsrWifiSmeWifiOnInd *msg__; \
+ CsrWifiSmeWifiOnIndCreate(msg__, dst__, src__, address__); \
+ CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
+ }
+
+#define CsrWifiSmeWifiOnIndSend(dst__, address__) \
+ CsrWifiSmeWifiOnIndSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, address__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeWifiOnCfmSend
+
+ DESCRIPTION
+ The SME sends this primitive to the task that has sent the request once
+ the chip has been initialised and is available for use.
+
+ PARAMETERS
+ queue - Destination Task Queue
+ status - Reports the result of the request
+
+*******************************************************************************/
+#define CsrWifiSmeWifiOnCfmCreate(msg__, dst__, src__, status__) \
+ msg__ = kmalloc(sizeof(CsrWifiSmeWifiOnCfm), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_WIFI_ON_CFM, dst__, src__); \
+ msg__->status = (status__);
+
+#define CsrWifiSmeWifiOnCfmSendTo(dst__, src__, status__) \
+ { \
+ CsrWifiSmeWifiOnCfm *msg__; \
+ CsrWifiSmeWifiOnCfmCreate(msg__, dst__, src__, status__); \
+ CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
+ }
+
+#define CsrWifiSmeWifiOnCfmSend(dst__, status__) \
+ CsrWifiSmeWifiOnCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, status__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeWpsConfigurationReqSend
+
+ DESCRIPTION
+ This primitive passes the WPS information for the device to SME. This may
+ be accepted only if no interface is active.
+
+ PARAMETERS
+ queue - Message Source Task Queue (Cfm's will be sent to this Queue)
+ wpsConfig - WPS config.
+
+*******************************************************************************/
+#define CsrWifiSmeWpsConfigurationReqCreate(msg__, dst__, src__, wpsConfig__) \
+ msg__ = kmalloc(sizeof(CsrWifiSmeWpsConfigurationReq), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_WPS_CONFIGURATION_REQ, dst__, src__); \
+ msg__->wpsConfig = (wpsConfig__);
+
+#define CsrWifiSmeWpsConfigurationReqSendTo(dst__, src__, wpsConfig__) \
+ { \
+ CsrWifiSmeWpsConfigurationReq *msg__; \
+ CsrWifiSmeWpsConfigurationReqCreate(msg__, dst__, src__, wpsConfig__); \
+ CsrMsgTransport(dst__, CSR_WIFI_SME_PRIM, msg__); \
+ }
+
+#define CsrWifiSmeWpsConfigurationReqSend(src__, wpsConfig__) \
+ CsrWifiSmeWpsConfigurationReqSendTo(CSR_WIFI_SME_LIB_DESTINATION_QUEUE, src__, wpsConfig__)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeWpsConfigurationCfmSend
+
+ DESCRIPTION
+ Confirm.
+
+ PARAMETERS
+ queue - Destination Task Queue
+ status - Status of the request.
+
+*******************************************************************************/
+#define CsrWifiSmeWpsConfigurationCfmCreate(msg__, dst__, src__, status__) \
+ msg__ = kmalloc(sizeof(CsrWifiSmeWpsConfigurationCfm), GFP_KERNEL); \
+ CsrWifiFsmEventInit(&msg__->common, CSR_WIFI_SME_PRIM, CSR_WIFI_SME_WPS_CONFIGURATION_CFM, dst__, src__); \
+ msg__->status = (status__);
+
+#define CsrWifiSmeWpsConfigurationCfmSendTo(dst__, src__, status__) \
+ { \
+ CsrWifiSmeWpsConfigurationCfm *msg__; \
+ CsrWifiSmeWpsConfigurationCfmCreate(msg__, dst__, src__, status__); \
+ CsrSchedMessagePut(dst__, CSR_WIFI_SME_PRIM, msg__); \
+ }
+
+#define CsrWifiSmeWpsConfigurationCfmSend(dst__, status__) \
+ CsrWifiSmeWpsConfigurationCfmSendTo(dst__, CSR_WIFI_SME_IFACEQUEUE, status__)
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* CSR_WIFI_SME_LIB_H__ */
diff --git a/drivers/staging/csr/csr_wifi_sme_prim.h b/drivers/staging/csr/csr_wifi_sme_prim.h
new file mode 100644
index 000000000000..55cac5059bf7
--- /dev/null
+++ b/drivers/staging/csr/csr_wifi_sme_prim.h
@@ -0,0 +1,6519 @@
+/*****************************************************************************
+
+ (c) Cambridge Silicon Radio Limited 2012
+ All rights reserved and confidential information of CSR
+
+ Refer to LICENSE.txt included with this source for details
+ on the license terms.
+
+*****************************************************************************/
+
+/* Note: this is an auto-generated file. */
+
+#ifndef CSR_WIFI_SME_PRIM_H__
+#define CSR_WIFI_SME_PRIM_H__
+
+#include <linux/types.h>
+#include "csr_prim_defs.h"
+#include "csr_sched.h"
+#include "csr_wifi_common.h"
+#include "csr_result.h"
+#include "csr_wifi_fsm_event.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define CSR_WIFI_SME_PRIM (0x0404)
+
+typedef CsrPrim CsrWifiSmePrim;
+
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSme80211NetworkType
+
+ DESCRIPTION
+ Indicates the physical layer of the network
+
+ VALUES
+ CSR_WIFI_SME_80211_NETWORK_TYPE_DS
+ - Direct-sequence spread spectrum
+ CSR_WIFI_SME_80211_NETWORK_TYPE_OFDM24
+ - Orthogonal Frequency Division Multiplexing at 2.4 GHz
+ CSR_WIFI_SME_80211_NETWORK_TYPE_OFDM5
+ - Orthogonal Frequency Division Multiplexing at 5 GHz
+ CSR_WIFI_SME_80211_NETWORK_TYPE_AUTO
+ - Automatic
+
+*******************************************************************************/
+typedef u8 CsrWifiSme80211NetworkType;
+#define CSR_WIFI_SME_80211_NETWORK_TYPE_DS ((CsrWifiSme80211NetworkType) 0x00)
+#define CSR_WIFI_SME_80211_NETWORK_TYPE_OFDM24 ((CsrWifiSme80211NetworkType) 0x01)
+#define CSR_WIFI_SME_80211_NETWORK_TYPE_OFDM5 ((CsrWifiSme80211NetworkType) 0x02)
+#define CSR_WIFI_SME_80211_NETWORK_TYPE_AUTO ((CsrWifiSme80211NetworkType) 0x03)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSme80211PrivacyMode
+
+ DESCRIPTION
+ Bits to enable or disable the privacy mode
+
+ VALUES
+ CSR_WIFI_SME_80211_PRIVACY_MODE_DISABLED
+ - Privacy mode is enabled: use of WEP for confidentiality is
+ required.
+ CSR_WIFI_SME_80211_PRIVACY_MODE_ENABLED
+ - Privacy mode is disabled
+
+*******************************************************************************/
+typedef u8 CsrWifiSme80211PrivacyMode;
+#define CSR_WIFI_SME_80211_PRIVACY_MODE_DISABLED ((CsrWifiSme80211PrivacyMode) 0x00)
+#define CSR_WIFI_SME_80211_PRIVACY_MODE_ENABLED ((CsrWifiSme80211PrivacyMode) 0x01)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSme80211dTrustLevel
+
+ DESCRIPTION
+ Level of trust for the information coming from the network
+
+ VALUES
+ CSR_WIFI_SME_80211D_TRUST_LEVEL_STRICT
+ - Start with passive scanning and only accept country IE for
+ updating channel lists
+ CSR_WIFI_SME_80211D_TRUST_LEVEL_ADJUNCT
+ - As above plus accept adjunct technology location
+ information
+ CSR_WIFI_SME_80211D_TRUST_LEVEL_BSS
+ - As above accept plus receiving channel from infrastructure
+ networks
+ CSR_WIFI_SME_80211D_TRUST_LEVEL_IBSS
+ - As above accept plus receiving channel from the ad hoc
+ networks
+ CSR_WIFI_SME_80211D_TRUST_LEVEL_MIB
+ - Start with active scanning with list of active channels
+ from the MIB and accept as above
+ CSR_WIFI_SME_80211D_TRUST_LEVEL_DISABLED
+ - Start with active scanning with list of active channels
+ from the MIB and ignore any channel information from the
+ network
+
+*******************************************************************************/
+typedef u8 CsrWifiSme80211dTrustLevel;
+#define CSR_WIFI_SME_80211D_TRUST_LEVEL_STRICT ((CsrWifiSme80211dTrustLevel) 0x01)
+#define CSR_WIFI_SME_80211D_TRUST_LEVEL_ADJUNCT ((CsrWifiSme80211dTrustLevel) 0x02)
+#define CSR_WIFI_SME_80211D_TRUST_LEVEL_BSS ((CsrWifiSme80211dTrustLevel) 0x03)
+#define CSR_WIFI_SME_80211D_TRUST_LEVEL_IBSS ((CsrWifiSme80211dTrustLevel) 0x04)
+#define CSR_WIFI_SME_80211D_TRUST_LEVEL_MIB ((CsrWifiSme80211dTrustLevel) 0x05)
+#define CSR_WIFI_SME_80211D_TRUST_LEVEL_DISABLED ((CsrWifiSme80211dTrustLevel) 0x06)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeAmpStatus
+
+ DESCRIPTION
+ AMP Current Status
+
+ VALUES
+ CSR_WIFI_SME_AMP_ACTIVE - AMP ACTIVE.
+ CSR_WIFI_SME_AMP_INACTIVE - AMP INACTIVE
+
+*******************************************************************************/
+typedef u8 CsrWifiSmeAmpStatus;
+#define CSR_WIFI_SME_AMP_ACTIVE ((CsrWifiSmeAmpStatus) 0x00)
+#define CSR_WIFI_SME_AMP_INACTIVE ((CsrWifiSmeAmpStatus) 0x01)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeAuthMode
+
+ DESCRIPTION
+ Define bits for CsrWifiSmeAuthMode
+
+ VALUES
+ CSR_WIFI_SME_AUTH_MODE_80211_OPEN
+ - Connects to an open system network (i.e. no authentication,
+ no encryption) or to a WEP enabled network.
+ CSR_WIFI_SME_AUTH_MODE_80211_SHARED
+ - Connect to a WEP enabled network.
+ CSR_WIFI_SME_AUTH_MODE_8021X_WPA
+ - Connects to a WPA Enterprise enabled network.
+ CSR_WIFI_SME_AUTH_MODE_8021X_WPAPSK
+ - Connects to a WPA with Pre-Shared Key enabled network.
+ CSR_WIFI_SME_AUTH_MODE_8021X_WPA2
+ - Connects to a WPA2 Enterprise enabled network.
+ CSR_WIFI_SME_AUTH_MODE_8021X_WPA2PSK
+ - Connects to a WPA2 with Pre-Shared Key enabled network.
+ CSR_WIFI_SME_AUTH_MODE_8021X_CCKM
+ - Connects to a CCKM enabled network.
+ CSR_WIFI_SME_AUTH_MODE_WAPI_WAI
+ - Connects to a WAPI Enterprise enabled network.
+ CSR_WIFI_SME_AUTH_MODE_WAPI_WAIPSK
+ - Connects to a WAPI with Pre-Shared Key enabled network.
+ CSR_WIFI_SME_AUTH_MODE_8021X_OTHER1X
+ - For future use.
+
+*******************************************************************************/
+typedef u16 CsrWifiSmeAuthMode;
+#define CSR_WIFI_SME_AUTH_MODE_80211_OPEN ((CsrWifiSmeAuthMode) 0x0001)
+#define CSR_WIFI_SME_AUTH_MODE_80211_SHARED ((CsrWifiSmeAuthMode) 0x0002)
+#define CSR_WIFI_SME_AUTH_MODE_8021X_WPA ((CsrWifiSmeAuthMode) 0x0004)
+#define CSR_WIFI_SME_AUTH_MODE_8021X_WPAPSK ((CsrWifiSmeAuthMode) 0x0008)
+#define CSR_WIFI_SME_AUTH_MODE_8021X_WPA2 ((CsrWifiSmeAuthMode) 0x0010)
+#define CSR_WIFI_SME_AUTH_MODE_8021X_WPA2PSK ((CsrWifiSmeAuthMode) 0x0020)
+#define CSR_WIFI_SME_AUTH_MODE_8021X_CCKM ((CsrWifiSmeAuthMode) 0x0040)
+#define CSR_WIFI_SME_AUTH_MODE_WAPI_WAI ((CsrWifiSmeAuthMode) 0x0080)
+#define CSR_WIFI_SME_AUTH_MODE_WAPI_WAIPSK ((CsrWifiSmeAuthMode) 0x0100)
+#define CSR_WIFI_SME_AUTH_MODE_8021X_OTHER1X ((CsrWifiSmeAuthMode) 0x0200)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeBasicUsability
+
+ DESCRIPTION
+ Indicates the usability level of a channel
+
+ VALUES
+ CSR_WIFI_SME_BASIC_USABILITY_UNUSABLE
+ - Not usable; connection not recommended
+ CSR_WIFI_SME_BASIC_USABILITY_POOR
+ - Poor quality; connect only if nothing better is available
+ CSR_WIFI_SME_BASIC_USABILITY_SATISFACTORY
+ - Quality is satisfactory
+ CSR_WIFI_SME_BASIC_USABILITY_NOT_CONNECTED
+ - Not connected
+
+*******************************************************************************/
+typedef u8 CsrWifiSmeBasicUsability;
+#define CSR_WIFI_SME_BASIC_USABILITY_UNUSABLE ((CsrWifiSmeBasicUsability) 0x00)
+#define CSR_WIFI_SME_BASIC_USABILITY_POOR ((CsrWifiSmeBasicUsability) 0x01)
+#define CSR_WIFI_SME_BASIC_USABILITY_SATISFACTORY ((CsrWifiSmeBasicUsability) 0x02)
+#define CSR_WIFI_SME_BASIC_USABILITY_NOT_CONNECTED ((CsrWifiSmeBasicUsability) 0x03)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeBssType
+
+ DESCRIPTION
+ Indicates the BSS type
+
+ VALUES
+ CSR_WIFI_SME_BSS_TYPE_INFRASTRUCTURE
+ - Infrastructure BSS.
+ CSR_WIFI_SME_BSS_TYPE_ADHOC
+ - Ad hoc or Independent BSS.
+ CSR_WIFI_SME_BSS_TYPE_ANY_BSS
+ - Specifies any type of BSS
+ CSR_WIFI_SME_BSS_TYPE_P2P
+ - Specifies P2P
+
+*******************************************************************************/
+typedef u8 CsrWifiSmeBssType;
+#define CSR_WIFI_SME_BSS_TYPE_INFRASTRUCTURE ((CsrWifiSmeBssType) 0x00)
+#define CSR_WIFI_SME_BSS_TYPE_ADHOC ((CsrWifiSmeBssType) 0x01)
+#define CSR_WIFI_SME_BSS_TYPE_ANY_BSS ((CsrWifiSmeBssType) 0x02)
+#define CSR_WIFI_SME_BSS_TYPE_P2P ((CsrWifiSmeBssType) 0x03)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeCoexScheme
+
+ DESCRIPTION
+ Options for the coexistence signalling
+ Same as MibValues
+
+ VALUES
+ CSR_WIFI_SME_COEX_SCHEME_DISABLED
+ - The coexistence signalling is disabled
+ CSR_WIFI_SME_COEX_SCHEME_CSR
+ - Basic CSR coexistence signalling
+ CSR_WIFI_SME_COEX_SCHEME_CSR_CHANNEL
+ - Full CSR coexistence signalling
+ CSR_WIFI_SME_COEX_SCHEME_PTA
+ - Packet Traffic Arbitrator coexistence signalling
+
+*******************************************************************************/
+typedef u8 CsrWifiSmeCoexScheme;
+#define CSR_WIFI_SME_COEX_SCHEME_DISABLED ((CsrWifiSmeCoexScheme) 0x00)
+#define CSR_WIFI_SME_COEX_SCHEME_CSR ((CsrWifiSmeCoexScheme) 0x01)
+#define CSR_WIFI_SME_COEX_SCHEME_CSR_CHANNEL ((CsrWifiSmeCoexScheme) 0x02)
+#define CSR_WIFI_SME_COEX_SCHEME_PTA ((CsrWifiSmeCoexScheme) 0x03)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeControlIndication
+
+ DESCRIPTION
+ Indicates the reason why the Wi-Fi has been switched off.
+ The values of this type are used across the NME/SME/Router API's and they
+ must be kept consistent with the corresponding types in the .xml of the
+ ottherinterfaces
+
+ VALUES
+ CSR_WIFI_SME_CONTROL_INDICATION_ERROR
+ - An unrecoverable error (for example, an unrecoverable SDIO
+ error) has occurred.
+ The wireless manager application should reinitialise the
+ chip by calling CSR_WIFI_SME_WIFI_ON_REQ.
+ CSR_WIFI_SME_CONTROL_INDICATION_EXIT
+ - The chip became unavailable due to an external action, for
+ example, when a plug-in card is ejected or the driver is
+ unloaded.
+ CSR_WIFI_SME_CONTROL_INDICATION_USER_REQUESTED
+ - The Wi-Fi has been switched off as the wireless manager
+ application has sent CSR_WIFI_SME_WIFI_OFF_REQ
+
+*******************************************************************************/
+typedef u8 CsrWifiSmeControlIndication;
+#define CSR_WIFI_SME_CONTROL_INDICATION_ERROR ((CsrWifiSmeControlIndication) 0x01)
+#define CSR_WIFI_SME_CONTROL_INDICATION_EXIT ((CsrWifiSmeControlIndication) 0x02)
+#define CSR_WIFI_SME_CONTROL_INDICATION_USER_REQUESTED ((CsrWifiSmeControlIndication) 0x03)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeCtsProtectionType
+
+ DESCRIPTION
+ SME CTS Protection Types
+
+ VALUES
+ CSR_WIFI_SME_CTS_PROTECTION_AUTOMATIC
+ - AP CTS Protection automatic based on non-ERP station in own
+ BSS or neighbouring BSS on the same channel based on OLBC.
+ This requires monitoring of beacons from other APs.
+ CSR_WIFI_SME_CTS_PROTECTION_FORCE_ENABLED
+ - AP CTS Protection Force enabled
+ CSR_WIFI_SME_CTS_PROTECTION_FORCE_DISABLED
+ - AP CTS Protection Force disabled.
+ CSR_WIFI_SME_CTS_PROTECTION_AUTOMATIC_NO_OLBC
+ - AP CTS Protection automatic without considering OLBC but
+ considering non-ERP station in the own BSS Valid only if AP
+ is configured to work in 802.11bg or 802.11g mode otherwise
+ this option specifies the same behaviour as AUTOMATIC
+
+*******************************************************************************/
+typedef u8 CsrWifiSmeCtsProtectionType;
+#define CSR_WIFI_SME_CTS_PROTECTION_AUTOMATIC ((CsrWifiSmeCtsProtectionType) 0x00)
+#define CSR_WIFI_SME_CTS_PROTECTION_FORCE_ENABLED ((CsrWifiSmeCtsProtectionType) 0x01)
+#define CSR_WIFI_SME_CTS_PROTECTION_FORCE_DISABLED ((CsrWifiSmeCtsProtectionType) 0x02)
+#define CSR_WIFI_SME_CTS_PROTECTION_AUTOMATIC_NO_OLBC ((CsrWifiSmeCtsProtectionType) 0x03)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeD3AutoScanMode
+
+ DESCRIPTION
+ Autonomous scan status while in D3 suspended period
+
+ VALUES
+ CSR_WIFI_SME_D3AUTO_SCAN_MODE_PSON
+ - Autonomous scan stays on
+ CSR_WIFI_SME_D3AUTO_SCAN_MODE_PSOFF
+ - Autonomous scan is switched off
+ CSR_WIFI_SME_D3AUTO_SCAN_MODE_PSAUTO
+ - Automatically select autoscanning behaviour.
+ CURRENTLY NOT SUPPORTED
+
+*******************************************************************************/
+typedef u8 CsrWifiSmeD3AutoScanMode;
+#define CSR_WIFI_SME_D3AUTO_SCAN_MODE_PSON ((CsrWifiSmeD3AutoScanMode) 0x00)
+#define CSR_WIFI_SME_D3AUTO_SCAN_MODE_PSOFF ((CsrWifiSmeD3AutoScanMode) 0x01)
+#define CSR_WIFI_SME_D3AUTO_SCAN_MODE_PSAUTO ((CsrWifiSmeD3AutoScanMode) 0x02)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeEncryption
+
+ DESCRIPTION
+ Defines bits for CsrWifiSmeEncryption
+ For a WEP enabled network, the caller must specify the correct
+ combination of flags in the encryptionModeMask.
+
+ VALUES
+ CSR_WIFI_SME_ENCRYPTION_CIPHER_NONE
+ - No encryption set
+ CSR_WIFI_SME_ENCRYPTION_CIPHER_PAIRWISE_WEP40
+ - Selects 40 byte key WEP for unicast communication
+ CSR_WIFI_SME_ENCRYPTION_CIPHER_PAIRWISE_WEP104
+ - Selects 104 byte key WEP for unicast communication
+ CSR_WIFI_SME_ENCRYPTION_CIPHER_PAIRWISE_TKIP
+ - Selects TKIP for unicast communication
+ CSR_WIFI_SME_ENCRYPTION_CIPHER_PAIRWISE_CCMP
+ - Selects CCMP for unicast communication
+ CSR_WIFI_SME_ENCRYPTION_CIPHER_PAIRWISE_SMS4
+ - Selects SMS4 for unicast communication
+ CSR_WIFI_SME_ENCRYPTION_CIPHER_GROUP_WEP40
+ - Selects 40 byte key WEP for broadcast messages
+ CSR_WIFI_SME_ENCRYPTION_CIPHER_GROUP_WEP104
+ - Selects 104 byte key WEP for broadcast messages
+ CSR_WIFI_SME_ENCRYPTION_CIPHER_GROUP_TKIP
+ - Selects a TKIP for broadcast messages
+ CSR_WIFI_SME_ENCRYPTION_CIPHER_GROUP_CCMP
+ - Selects CCMP for broadcast messages
+ CSR_WIFI_SME_ENCRYPTION_CIPHER_GROUP_SMS4
+ - Selects SMS4 for broadcast messages
+
+*******************************************************************************/
+typedef u16 CsrWifiSmeEncryption;
+#define CSR_WIFI_SME_ENCRYPTION_CIPHER_NONE ((CsrWifiSmeEncryption) 0x0000)
+#define CSR_WIFI_SME_ENCRYPTION_CIPHER_PAIRWISE_WEP40 ((CsrWifiSmeEncryption) 0x0001)
+#define CSR_WIFI_SME_ENCRYPTION_CIPHER_PAIRWISE_WEP104 ((CsrWifiSmeEncryption) 0x0002)
+#define CSR_WIFI_SME_ENCRYPTION_CIPHER_PAIRWISE_TKIP ((CsrWifiSmeEncryption) 0x0004)
+#define CSR_WIFI_SME_ENCRYPTION_CIPHER_PAIRWISE_CCMP ((CsrWifiSmeEncryption) 0x0008)
+#define CSR_WIFI_SME_ENCRYPTION_CIPHER_PAIRWISE_SMS4 ((CsrWifiSmeEncryption) 0x0010)
+#define CSR_WIFI_SME_ENCRYPTION_CIPHER_GROUP_WEP40 ((CsrWifiSmeEncryption) 0x0020)
+#define CSR_WIFI_SME_ENCRYPTION_CIPHER_GROUP_WEP104 ((CsrWifiSmeEncryption) 0x0040)
+#define CSR_WIFI_SME_ENCRYPTION_CIPHER_GROUP_TKIP ((CsrWifiSmeEncryption) 0x0080)
+#define CSR_WIFI_SME_ENCRYPTION_CIPHER_GROUP_CCMP ((CsrWifiSmeEncryption) 0x0100)
+#define CSR_WIFI_SME_ENCRYPTION_CIPHER_GROUP_SMS4 ((CsrWifiSmeEncryption) 0x0200)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeFirmwareDriverInterface
+
+ DESCRIPTION
+ Type of communication between Host and Firmware
+
+ VALUES
+ CSR_WIFI_SME_FIRMWARE_DRIVER_INTERFACE_UNIT_DATA_INTERFACE
+ - No preformated header. NOT SUPPORTED in the current release
+ CSR_WIFI_SME_FIRMWARE_DRIVER_INTERFACE_PACKET_INTERFACE
+ - Preformated IEEE 802.11 header for user plane
+
+*******************************************************************************/
+typedef u8 CsrWifiSmeFirmwareDriverInterface;
+#define CSR_WIFI_SME_FIRMWARE_DRIVER_INTERFACE_UNIT_DATA_INTERFACE ((CsrWifiSmeFirmwareDriverInterface) 0x00)
+#define CSR_WIFI_SME_FIRMWARE_DRIVER_INTERFACE_PACKET_INTERFACE ((CsrWifiSmeFirmwareDriverInterface) 0x01)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeHostPowerMode
+
+ DESCRIPTION
+ Defines the power mode
+
+ VALUES
+ CSR_WIFI_SME_HOST_POWER_MODE_ACTIVE
+ - Host device is running on external power.
+ CSR_WIFI_SME_HOST_POWER_MODE_POWER_SAVE
+ - Host device is running on (internal) battery power.
+ CSR_WIFI_SME_HOST_POWER_MODE_FULL_POWER_SAVE
+ - For future use.
+
+*******************************************************************************/
+typedef u8 CsrWifiSmeHostPowerMode;
+#define CSR_WIFI_SME_HOST_POWER_MODE_ACTIVE ((CsrWifiSmeHostPowerMode) 0x00)
+#define CSR_WIFI_SME_HOST_POWER_MODE_POWER_SAVE ((CsrWifiSmeHostPowerMode) 0x01)
+#define CSR_WIFI_SME_HOST_POWER_MODE_FULL_POWER_SAVE ((CsrWifiSmeHostPowerMode) 0x02)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeIEEE80211Reason
+
+ DESCRIPTION
+ As definined in the IEEE 802.11 standards
+
+ VALUES
+ CSR_WIFI_SME_IEEE80211_REASON_SUCCESS
+ - See IEEE 802.11 Standard
+ CSR_WIFI_SME_IEEE80211_REASON_UNSPECIFIED_REASON
+ - See IEEE 802.11 Standard
+ CSR_WIFI_SME_IEEE80211_REASON_AUTHENTICATION_NOT_VALID
+ - See IEEE 802.11 Standard
+ CSR_WIFI_SME_IEEE80211_REASON_DEAUTHENTICATED_LEAVE_BSS
+ - See IEEE 802.11 Standard
+ CSR_WIFI_SME_IEEE80211_REASON_DISASSOCIATED_INACTIVITY
+ - See IEEE 802.11 Standard
+ CSR_WIFI_SME_IEEE80211_REASON_AP_OVERLOAD
+ - See IEEE 802.11 Standard
+ CSR_WIFI_SME_IEEE80211_REASON_CLASS_2FRAME_ERROR
+ - See IEEE 802.11 Standard
+ CSR_WIFI_SME_IEEE80211_REASON_CLASS_3FRAME_ERROR
+ - See IEEE 802.11 Standard
+ CSR_WIFI_SME_IEEE80211_REASON_DISASSOCIATED_LEAVE_BSS
+ - See IEEE 802.11 Standard
+ CSR_WIFI_SME_IEEE80211_REASON_ASSOCIATION_NOT_AUTHENTICATED
+ - See IEEE 802.11 Standard
+ CSR_WIFI_SME_IEEE80211_REASON_DISASSOCIATED_POWER_CAPABILITY
+ - See IEEE 802.11 Standard
+ CSR_WIFI_SME_IEEE80211_REASON_DISASSOCIATED_SUPPORTED_CHANNELS
+ - See IEEE 802.11 Standard
+ CSR_WIFI_SME_IEEE80211_REASON_INVALID_INFORMATION_ELEMENT
+ - See IEEE 802.11 Standard
+ CSR_WIFI_SME_IEEE80211_REASON_MICHAEL_MIC_FAILURE
+ - See IEEE 802.11 Standard
+ CSR_WIFI_SME_IEEE80211_REASON_FOURWAY_HANDSHAKE_TIMEOUT
+ - See IEEE 802.11 Standard
+ CSR_WIFI_SME_IEEE80211_REASON_GROUP_KEY_UPDATE_TIMEOUT
+ - See IEEE 802.11 Standard
+ CSR_WIFI_SME_IEEE80211_REASON_HANDSHAKE_ELEMENT_DIFFERENT
+ - See IEEE 802.11 Standard
+ CSR_WIFI_SME_IEEE80211_REASON_INVALID_GROUP_CIPHER
+ - See IEEE 802.11 Standard
+ CSR_WIFI_SME_IEEE80211_REASON_INVALID_PAIRWISE_CIPHER
+ - See IEEE 802.11 Standard
+ CSR_WIFI_SME_IEEE80211_REASON_INVALID_AKMP
+ - See IEEE 802.11 Standard
+ CSR_WIFI_SME_IEEE80211_REASON_UNSUPPORTED_RSN_IEVERSION
+ - See IEEE 802.11 Standard
+ CSR_WIFI_SME_IEEE80211_REASON_INVALID_RSN_IECAPABILITIES
+ - See IEEE 802.11 Standard
+ CSR_WIFI_SME_IEEE80211_REASON_DOT1X_AUTH_FAILED
+ - See IEEE 802.11 Standard
+ CSR_WIFI_SME_IEEE80211_REASON_CIPHER_REJECTED_BY_POLICY
+ - See IEEE 802.11 Standard
+ CSR_WIFI_SME_IEEE80211_REASON_SERVICE_CHANGE_PRECLUDES_TS
+ - See IEEE 802.11 Standard
+ CSR_WIFI_SME_IEEE80211_REASON_QOS_UNSPECIFIED_REASON
+ - See IEEE 802.11 Standard
+ CSR_WIFI_SME_IEEE80211_REASON_QOS_INSUFFICIENT_BANDWIDTH
+ - See IEEE 802.11 Standard
+ CSR_WIFI_SME_IEEE80211_REASON_QOS_EXCESSIVE_NOT_ACK
+ - See IEEE 802.11 Standard
+ CSR_WIFI_SME_IEEE80211_REASON_QOS_TXOPLIMIT_EXCEEDED
+ - See IEEE 802.11 Standard
+ CSR_WIFI_SME_IEEE80211_REASON_QSTA_LEAVING
+ - See IEEE 802.11 Standard
+ CSR_WIFI_SME_IEEE80211_REASON_END_TS
+ - See IEEE 802.11 Standard
+ CSR_WIFI_SME_IEEE80211_REASON_END_DLS
+ - See IEEE 802.11 Standard
+ CSR_WIFI_SME_IEEE80211_REASON_END_BA
+ - See IEEE 802.11 Standard
+ CSR_WIFI_SME_IEEE80211_REASON_UNKNOWN_TS
+ - See IEEE 802.11 Standard
+ CSR_WIFI_SME_IEEE80211_REASON_UNKNOWN_BA
+ - See IEEE 802.11 Standard
+ CSR_WIFI_SME_IEEE80211_REASON_UNKNOWN_DLS
+ - See IEEE 802.11 Standard
+ CSR_WIFI_SME_IEEE80211_REASON_TIMEOUT
+ - See IEEE 802.11 Standard
+ CSR_WIFI_SME_IEEE80211_REASON_STAKEY_MISMATCH
+ - See IEEE 802.11 Standard
+ CSR_WIFI_SME_IEEE80211_REASON_UNICAST_KEY_NEGOTIATION_TIMEOUT
+ - See IEEE 802.11 Standard
+ CSR_WIFI_SME_IEEE80211_REASON_MULTICAST_KEY_ANNOUNCEMENT_TIMEOUT
+ - See IEEE 802.11 Standard
+ CSR_WIFI_SME_IEEE80211_REASON_INCOMPATIBLE_UNICAST_KEY_NEGOTIATION_IE
+ - See IEEE 802.11 Standard
+ CSR_WIFI_SME_IEEE80211_REASON_INVALID_MULTICAST_CIPHER
+ - See IEEE 802.11 Standard
+ CSR_WIFI_SME_IEEE80211_REASON_INVALID_UNICAST_CIPHER
+ - See IEEE 802.11 Standard
+ CSR_WIFI_SME_IEEE80211_REASON_UNSUPPORTED_WAPI_IE_VERSION
+ - See IEEE 802.11 Standard
+ CSR_WIFI_SME_IEEE80211_REASON_INVALID_WAPI_CAPABILITY_IE
+ - See IEEE 802.11 Standard
+ CSR_WIFI_SME_IEEE80211_REASON_WAI_CERTIFICATE_AUTHENTICATION_FAILED
+ - See IEEE 802.11 Standard
+
+*******************************************************************************/
+typedef u16 CsrWifiSmeIEEE80211Reason;
+#define CSR_WIFI_SME_IEEE80211_REASON_SUCCESS ((CsrWifiSmeIEEE80211Reason) 0x0000)
+#define CSR_WIFI_SME_IEEE80211_REASON_UNSPECIFIED_REASON ((CsrWifiSmeIEEE80211Reason) 0x0001)
+#define CSR_WIFI_SME_IEEE80211_REASON_AUTHENTICATION_NOT_VALID ((CsrWifiSmeIEEE80211Reason) 0x0002)
+#define CSR_WIFI_SME_IEEE80211_REASON_DEAUTHENTICATED_LEAVE_BSS ((CsrWifiSmeIEEE80211Reason) 0x0003)
+#define CSR_WIFI_SME_IEEE80211_REASON_DISASSOCIATED_INACTIVITY ((CsrWifiSmeIEEE80211Reason) 0x0004)
+#define CSR_WIFI_SME_IEEE80211_REASON_AP_OVERLOAD ((CsrWifiSmeIEEE80211Reason) 0x0005)
+#define CSR_WIFI_SME_IEEE80211_REASON_CLASS_2FRAME_ERROR ((CsrWifiSmeIEEE80211Reason) 0x0006)
+#define CSR_WIFI_SME_IEEE80211_REASON_CLASS_3FRAME_ERROR ((CsrWifiSmeIEEE80211Reason) 0x0007)
+#define CSR_WIFI_SME_IEEE80211_REASON_DISASSOCIATED_LEAVE_BSS ((CsrWifiSmeIEEE80211Reason) 0x0008)
+#define CSR_WIFI_SME_IEEE80211_REASON_ASSOCIATION_NOT_AUTHENTICATED ((CsrWifiSmeIEEE80211Reason) 0x0009)
+#define CSR_WIFI_SME_IEEE80211_REASON_DISASSOCIATED_POWER_CAPABILITY ((CsrWifiSmeIEEE80211Reason) 0x000a)
+#define CSR_WIFI_SME_IEEE80211_REASON_DISASSOCIATED_SUPPORTED_CHANNELS ((CsrWifiSmeIEEE80211Reason) 0x000b)
+#define CSR_WIFI_SME_IEEE80211_REASON_INVALID_INFORMATION_ELEMENT ((CsrWifiSmeIEEE80211Reason) 0x000d)
+#define CSR_WIFI_SME_IEEE80211_REASON_MICHAEL_MIC_FAILURE ((CsrWifiSmeIEEE80211Reason) 0x000e)
+#define CSR_WIFI_SME_IEEE80211_REASON_FOURWAY_HANDSHAKE_TIMEOUT ((CsrWifiSmeIEEE80211Reason) 0x000f)
+#define CSR_WIFI_SME_IEEE80211_REASON_GROUP_KEY_UPDATE_TIMEOUT ((CsrWifiSmeIEEE80211Reason) 0x0010)
+#define CSR_WIFI_SME_IEEE80211_REASON_HANDSHAKE_ELEMENT_DIFFERENT ((CsrWifiSmeIEEE80211Reason) 0x0011)
+#define CSR_WIFI_SME_IEEE80211_REASON_INVALID_GROUP_CIPHER ((CsrWifiSmeIEEE80211Reason) 0x0012)
+#define CSR_WIFI_SME_IEEE80211_REASON_INVALID_PAIRWISE_CIPHER ((CsrWifiSmeIEEE80211Reason) 0x0013)
+#define CSR_WIFI_SME_IEEE80211_REASON_INVALID_AKMP ((CsrWifiSmeIEEE80211Reason) 0x0014)
+#define CSR_WIFI_SME_IEEE80211_REASON_UNSUPPORTED_RSN_IEVERSION ((CsrWifiSmeIEEE80211Reason) 0x0015)
+#define CSR_WIFI_SME_IEEE80211_REASON_INVALID_RSN_IECAPABILITIES ((CsrWifiSmeIEEE80211Reason) 0x0016)
+#define CSR_WIFI_SME_IEEE80211_REASON_DOT1X_AUTH_FAILED ((CsrWifiSmeIEEE80211Reason) 0x0017)
+#define CSR_WIFI_SME_IEEE80211_REASON_CIPHER_REJECTED_BY_POLICY ((CsrWifiSmeIEEE80211Reason) 0x0018)
+#define CSR_WIFI_SME_IEEE80211_REASON_SERVICE_CHANGE_PRECLUDES_TS ((CsrWifiSmeIEEE80211Reason) 0x001F)
+#define CSR_WIFI_SME_IEEE80211_REASON_QOS_UNSPECIFIED_REASON ((CsrWifiSmeIEEE80211Reason) 0x0020)
+#define CSR_WIFI_SME_IEEE80211_REASON_QOS_INSUFFICIENT_BANDWIDTH ((CsrWifiSmeIEEE80211Reason) 0x0021)
+#define CSR_WIFI_SME_IEEE80211_REASON_QOS_EXCESSIVE_NOT_ACK ((CsrWifiSmeIEEE80211Reason) 0x0022)
+#define CSR_WIFI_SME_IEEE80211_REASON_QOS_TXOPLIMIT_EXCEEDED ((CsrWifiSmeIEEE80211Reason) 0x0023)
+#define CSR_WIFI_SME_IEEE80211_REASON_QSTA_LEAVING ((CsrWifiSmeIEEE80211Reason) 0x0024)
+#define CSR_WIFI_SME_IEEE80211_REASON_END_TS ((CsrWifiSmeIEEE80211Reason) 0x0025)
+#define CSR_WIFI_SME_IEEE80211_REASON_END_DLS ((CsrWifiSmeIEEE80211Reason) 0x0025)
+#define CSR_WIFI_SME_IEEE80211_REASON_END_BA ((CsrWifiSmeIEEE80211Reason) 0x0025)
+#define CSR_WIFI_SME_IEEE80211_REASON_UNKNOWN_TS ((CsrWifiSmeIEEE80211Reason) 0x0026)
+#define CSR_WIFI_SME_IEEE80211_REASON_UNKNOWN_BA ((CsrWifiSmeIEEE80211Reason) 0x0026)
+#define CSR_WIFI_SME_IEEE80211_REASON_UNKNOWN_DLS ((CsrWifiSmeIEEE80211Reason) 0x0026)
+#define CSR_WIFI_SME_IEEE80211_REASON_TIMEOUT ((CsrWifiSmeIEEE80211Reason) 0x0027)
+#define CSR_WIFI_SME_IEEE80211_REASON_STAKEY_MISMATCH ((CsrWifiSmeIEEE80211Reason) 0x002d)
+#define CSR_WIFI_SME_IEEE80211_REASON_UNICAST_KEY_NEGOTIATION_TIMEOUT ((CsrWifiSmeIEEE80211Reason) 0xf019)
+#define CSR_WIFI_SME_IEEE80211_REASON_MULTICAST_KEY_ANNOUNCEMENT_TIMEOUT ((CsrWifiSmeIEEE80211Reason) 0xf01a)
+#define CSR_WIFI_SME_IEEE80211_REASON_INCOMPATIBLE_UNICAST_KEY_NEGOTIATION_IE ((CsrWifiSmeIEEE80211Reason) 0xf01b)
+#define CSR_WIFI_SME_IEEE80211_REASON_INVALID_MULTICAST_CIPHER ((CsrWifiSmeIEEE80211Reason) 0xf01c)
+#define CSR_WIFI_SME_IEEE80211_REASON_INVALID_UNICAST_CIPHER ((CsrWifiSmeIEEE80211Reason) 0xf01d)
+#define CSR_WIFI_SME_IEEE80211_REASON_UNSUPPORTED_WAPI_IE_VERSION ((CsrWifiSmeIEEE80211Reason) 0xf01e)
+#define CSR_WIFI_SME_IEEE80211_REASON_INVALID_WAPI_CAPABILITY_IE ((CsrWifiSmeIEEE80211Reason) 0xf01f)
+#define CSR_WIFI_SME_IEEE80211_REASON_WAI_CERTIFICATE_AUTHENTICATION_FAILED ((CsrWifiSmeIEEE80211Reason) 0xf020)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeIEEE80211Result
+
+ DESCRIPTION
+ As definined in the IEEE 802.11 standards
+
+ VALUES
+ CSR_WIFI_SME_IEEE80211_RESULT_SUCCESS
+ - See IEEE 802.11 Standard
+ CSR_WIFI_SME_IEEE80211_RESULT_UNSPECIFIED_FAILURE
+ - See IEEE 802.11 Standard
+ CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_CAPABILITIES_MISMATCH
+ - See IEEE 802.11 Standard
+ CSR_WIFI_SME_IEEE80211_RESULT_REASSOCIATION_DENIED_NO_ASSOCIATION
+ - See IEEE 802.11 Standard
+ CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_EXTERNAL_REASON
+ - See IEEE 802.11 Standard
+ CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_AUTHENTICATION_MISMATCH
+ - See IEEE 802.11 Standard
+ CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_INVALID_AUTHENTICATION_SEQUENCE_NUMBER
+ - See IEEE 802.11 Standard
+ CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_CHALLENGE_FAILURE
+ - See IEEE 802.11 Standard
+ CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_AUTHENTICATION_TIMEOUT
+ - See IEEE 802.11 Standard
+ CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_AP_OUT_OF_MEMORY
+ - See IEEE 802.11 Standard
+ CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_BASIC_RATES_MISMATCH
+ - See IEEE 802.11 Standard
+ CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_SHORT_PREAMBLE_REQUIRED
+ - See IEEE 802.11 Standard
+ CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_PBCC_MODULATION_REQUIRED
+ - See IEEE 802.11 Standard
+ CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_CHANNEL_AGILITY_REQUIRED
+ - See IEEE 802.11 Standard
+ CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_SPECTRUM_MANAGEMENT_REQUIRED
+ - See IEEE 802.11 Standard
+ CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_POWER_CAPABILITY_UNACCEPTABLE
+ - See IEEE 802.11 Standard
+ CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_SUPPORTED_CHANNELS_UNACCEPTABLE
+ - See IEEE 802.11 Standard
+ CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_SHORT_SLOT_REQUIRED
+ - See IEEE 802.11 Standard
+ CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_DSSS_OFDMREQUIRED
+ - See IEEE 802.11 Standard
+ CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_NO_HT_SUPPORT
+ - See IEEE 802.11 Standard
+ CSR_WIFI_SME_IEEE80211_RESULT_R0KH_UNREACHABLE
+ - See IEEE 802.11 Standard
+ CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_PCO_TRANSITION_SUPPORT
+ - See IEEE 802.11 Standard
+ CSR_WIFI_SME_IEEE80211_RESULT_ASSOCIATION_REQUEST_REJECTED_TEMPORARILY
+ - See IEEE 802.11 Standard
+ CSR_WIFI_SME_IEEE80211_RESULT_ROBUST_MANAGEMENT_FRAME_POLICY_VIOLATION
+ - See IEEE 802.11 Standard
+ CSR_WIFI_SME_IEEE80211_RESULT_FAILURE
+ - See IEEE 802.11 Standard
+ CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_AP_BANDWIDTH_INSUFFICIENT
+ - See IEEE 802.11 Standard
+ CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_POOR_OPERATING_CHANNEL
+ - See IEEE 802.11 Standard
+ CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_QOS_REQUIRED
+ - See IEEE 802.11 Standard
+ CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_REASON_UNSPECIFIED
+ - See IEEE 802.11 Standard
+ CSR_WIFI_SME_IEEE80211_RESULT_REFUSED
+ - See IEEE 802.11 Standard
+ CSR_WIFI_SME_IEEE80211_RESULT_INVALID_PARAMETERS
+ - See IEEE 802.11 Standard
+ CSR_WIFI_SME_IEEE80211_RESULT_REJECTED_WITH_SUGGESTED_TSPEC_CHANGES
+ - See IEEE 802.11 Standard
+ CSR_WIFI_SME_IEEE80211_RESULT_REJECTED_INVALID_IE
+ - See IEEE 802.11 Standard
+ CSR_WIFI_SME_IEEE80211_RESULT_REJECTED_INVALID_GROUP_CIPHER
+ - See IEEE 802.11 Standard
+ CSR_WIFI_SME_IEEE80211_RESULT_REJECTED_INVALID_PAIRWISE_CIPHER
+ - See IEEE 802.11 Standard
+ CSR_WIFI_SME_IEEE80211_RESULT_REJECTED_INVALID_AKMP
+ - See IEEE 802.11 Standard
+ CSR_WIFI_SME_IEEE80211_RESULT_REJECTED_UNSUPPORTED_RSN_VERSION
+ - See IEEE 802.11 Standard
+ CSR_WIFI_SME_IEEE80211_RESULT_REJECTED_INVALID_RSN_CAPABILITY
+ - See IEEE 802.11 Standard
+ CSR_WIFI_SME_IEEE80211_RESULT_REJECTED_SECURITY_POLICY
+ - See IEEE 802.11 Standard
+ CSR_WIFI_SME_IEEE80211_RESULT_REJECTED_FOR_DELAY_PERIOD
+ - See IEEE 802.11 Standard
+ CSR_WIFI_SME_IEEE80211_RESULT_NOT_ALLOWED
+ - See IEEE 802.11 Standard
+ CSR_WIFI_SME_IEEE80211_RESULT_NOT_PRESENT
+ - See IEEE 802.11 Standard
+ CSR_WIFI_SME_IEEE80211_RESULT_NOT_QSTA
+ - See IEEE 802.11 Standard
+ CSR_WIFI_SME_IEEE80211_RESULT_REJECTED_LISTEN_INTERVAL_TOO_LARGE
+ - See IEEE 802.11 Standard
+ CSR_WIFI_SME_IEEE80211_RESULT_INVALID_FT_ACTION_FRAME_COUNT
+ - See IEEE 802.11 Standard
+ CSR_WIFI_SME_IEEE80211_RESULT_INVALID_PMKID
+ - See IEEE 802.11 Standard
+ CSR_WIFI_SME_IEEE80211_RESULT_INVALID_MDIE
+ - See IEEE 802.11 Standard
+ CSR_WIFI_SME_IEEE80211_RESULT_INVALID_FTIE
+ - See IEEE 802.11 Standard
+ CSR_WIFI_SME_IEEE80211_RESULT_UNSPECIFIED_QOS_FAILURE
+ - See IEEE 802.11 Standard
+ CSR_WIFI_SME_IEEE80211_RESULT_WRONG_POLICY
+ - See IEEE 802.11 Standard
+ CSR_WIFI_SME_IEEE80211_RESULT_INSUFFICIENT_BANDWIDTH
+ - See IEEE 802.11 Standard
+ CSR_WIFI_SME_IEEE80211_RESULT_INVALID_TSPEC_PARAMETERS
+ - See IEEE 802.11 Standard
+ CSR_WIFI_SME_IEEE80211_RESULT_TIMEOUT
+ - See IEEE 802.11 Standard
+ CSR_WIFI_SME_IEEE80211_RESULT_TOO_MANY_SIMULTANEOUS_REQUESTS
+ - See IEEE 802.11 Standard
+ CSR_WIFI_SME_IEEE80211_RESULT_BSS_ALREADY_STARTED_OR_JOINED
+ - See IEEE 802.11 Standard
+ CSR_WIFI_SME_IEEE80211_RESULT_NOT_SUPPORTED
+ - See IEEE 802.11 Standard
+ CSR_WIFI_SME_IEEE80211_RESULT_TRANSMISSION_FAILURE
+ - See IEEE 802.11 Standard
+ CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_NOT_AUTHENTICATED
+ - See IEEE 802.11 Standard
+ CSR_WIFI_SME_IEEE80211_RESULT_RESET_REQUIRED_BEFORE_START
+ - See IEEE 802.11 Standard
+ CSR_WIFI_SME_IEEE80211_RESULT_LM_INFO_UNAVAILABLE
+ - See IEEE 802.11 Standard
+ CSR_WIFI_SME_IEEE80211_RESULT_INVALID_UNICAST_CIPHER
+ - See IEEE 802.11 Standard
+ CSR_WIFI_SME_IEEE80211_RESULT_INVALID_MULTICAST_CIPHER
+ - See IEEE 802.11 Standard
+ CSR_WIFI_SME_IEEE80211_RESULT_UNSUPPORTED_WAPI_IE_VERSION
+ - See IEEE 802.11 Standard
+ CSR_WIFI_SME_IEEE80211_RESULT_INVALID_WAPI_CAPABILITY_IE
+ - See IEEE 802.11 Standard
+
+*******************************************************************************/
+typedef u16 CsrWifiSmeIEEE80211Result;
+#define CSR_WIFI_SME_IEEE80211_RESULT_SUCCESS ((CsrWifiSmeIEEE80211Result) 0x0000)
+#define CSR_WIFI_SME_IEEE80211_RESULT_UNSPECIFIED_FAILURE ((CsrWifiSmeIEEE80211Result) 0x0001)
+#define CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_CAPABILITIES_MISMATCH ((CsrWifiSmeIEEE80211Result) 0x000a)
+#define CSR_WIFI_SME_IEEE80211_RESULT_REASSOCIATION_DENIED_NO_ASSOCIATION ((CsrWifiSmeIEEE80211Result) 0x000b)
+#define CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_EXTERNAL_REASON ((CsrWifiSmeIEEE80211Result) 0x000c)
+#define CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_AUTHENTICATION_MISMATCH ((CsrWifiSmeIEEE80211Result) 0x000d)
+#define CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_INVALID_AUTHENTICATION_SEQUENCE_NUMBER ((CsrWifiSmeIEEE80211Result) 0x000e)
+#define CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_CHALLENGE_FAILURE ((CsrWifiSmeIEEE80211Result) 0x000f)
+#define CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_AUTHENTICATION_TIMEOUT ((CsrWifiSmeIEEE80211Result) 0x0010)
+#define CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_AP_OUT_OF_MEMORY ((CsrWifiSmeIEEE80211Result) 0x0011)
+#define CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_BASIC_RATES_MISMATCH ((CsrWifiSmeIEEE80211Result) 0x0012)
+#define CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_SHORT_PREAMBLE_REQUIRED ((CsrWifiSmeIEEE80211Result) 0x0013)
+#define CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_PBCC_MODULATION_REQUIRED ((CsrWifiSmeIEEE80211Result) 0x0014)
+#define CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_CHANNEL_AGILITY_REQUIRED ((CsrWifiSmeIEEE80211Result) 0x0015)
+#define CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_SPECTRUM_MANAGEMENT_REQUIRED ((CsrWifiSmeIEEE80211Result) 0x0016)
+#define CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_POWER_CAPABILITY_UNACCEPTABLE ((CsrWifiSmeIEEE80211Result) 0x0017)
+#define CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_SUPPORTED_CHANNELS_UNACCEPTABLE ((CsrWifiSmeIEEE80211Result) 0x0018)
+#define CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_SHORT_SLOT_REQUIRED ((CsrWifiSmeIEEE80211Result) 0x0019)
+#define CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_DSSS_OFDMREQUIRED ((CsrWifiSmeIEEE80211Result) 0x001a)
+#define CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_NO_HT_SUPPORT ((CsrWifiSmeIEEE80211Result) 0x001b)
+#define CSR_WIFI_SME_IEEE80211_RESULT_R0KH_UNREACHABLE ((CsrWifiSmeIEEE80211Result) 0x001c)
+#define CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_PCO_TRANSITION_SUPPORT ((CsrWifiSmeIEEE80211Result) 0x001d)
+#define CSR_WIFI_SME_IEEE80211_RESULT_ASSOCIATION_REQUEST_REJECTED_TEMPORARILY ((CsrWifiSmeIEEE80211Result) 0x001e)
+#define CSR_WIFI_SME_IEEE80211_RESULT_ROBUST_MANAGEMENT_FRAME_POLICY_VIOLATION ((CsrWifiSmeIEEE80211Result) 0x001f)
+#define CSR_WIFI_SME_IEEE80211_RESULT_FAILURE ((CsrWifiSmeIEEE80211Result) 0x0020)
+#define CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_AP_BANDWIDTH_INSUFFICIENT ((CsrWifiSmeIEEE80211Result) 0x0021)
+#define CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_POOR_OPERATING_CHANNEL ((CsrWifiSmeIEEE80211Result) 0x0022)
+#define CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_QOS_REQUIRED ((CsrWifiSmeIEEE80211Result) 0x0023)
+#define CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_REASON_UNSPECIFIED ((CsrWifiSmeIEEE80211Result) 0x0025)
+#define CSR_WIFI_SME_IEEE80211_RESULT_REFUSED ((CsrWifiSmeIEEE80211Result) 0x0025)
+#define CSR_WIFI_SME_IEEE80211_RESULT_INVALID_PARAMETERS ((CsrWifiSmeIEEE80211Result) 0x0026)
+#define CSR_WIFI_SME_IEEE80211_RESULT_REJECTED_WITH_SUGGESTED_TSPEC_CHANGES ((CsrWifiSmeIEEE80211Result) 0x0027)
+#define CSR_WIFI_SME_IEEE80211_RESULT_REJECTED_INVALID_IE ((CsrWifiSmeIEEE80211Result) 0x0028)
+#define CSR_WIFI_SME_IEEE80211_RESULT_REJECTED_INVALID_GROUP_CIPHER ((CsrWifiSmeIEEE80211Result) 0x0029)
+#define CSR_WIFI_SME_IEEE80211_RESULT_REJECTED_INVALID_PAIRWISE_CIPHER ((CsrWifiSmeIEEE80211Result) 0x002a)
+#define CSR_WIFI_SME_IEEE80211_RESULT_REJECTED_INVALID_AKMP ((CsrWifiSmeIEEE80211Result) 0x002b)
+#define CSR_WIFI_SME_IEEE80211_RESULT_REJECTED_UNSUPPORTED_RSN_VERSION ((CsrWifiSmeIEEE80211Result) 0x002c)
+#define CSR_WIFI_SME_IEEE80211_RESULT_REJECTED_INVALID_RSN_CAPABILITY ((CsrWifiSmeIEEE80211Result) 0x002d)
+#define CSR_WIFI_SME_IEEE80211_RESULT_REJECTED_SECURITY_POLICY ((CsrWifiSmeIEEE80211Result) 0x002e)
+#define CSR_WIFI_SME_IEEE80211_RESULT_REJECTED_FOR_DELAY_PERIOD ((CsrWifiSmeIEEE80211Result) 0x002f)
+#define CSR_WIFI_SME_IEEE80211_RESULT_NOT_ALLOWED ((CsrWifiSmeIEEE80211Result) 0x0030)
+#define CSR_WIFI_SME_IEEE80211_RESULT_NOT_PRESENT ((CsrWifiSmeIEEE80211Result) 0x0031)
+#define CSR_WIFI_SME_IEEE80211_RESULT_NOT_QSTA ((CsrWifiSmeIEEE80211Result) 0x0032)
+#define CSR_WIFI_SME_IEEE80211_RESULT_REJECTED_LISTEN_INTERVAL_TOO_LARGE ((CsrWifiSmeIEEE80211Result) 0x0033)
+#define CSR_WIFI_SME_IEEE80211_RESULT_INVALID_FT_ACTION_FRAME_COUNT ((CsrWifiSmeIEEE80211Result) 0x0034)
+#define CSR_WIFI_SME_IEEE80211_RESULT_INVALID_PMKID ((CsrWifiSmeIEEE80211Result) 0x0035)
+#define CSR_WIFI_SME_IEEE80211_RESULT_INVALID_MDIE ((CsrWifiSmeIEEE80211Result) 0x0036)
+#define CSR_WIFI_SME_IEEE80211_RESULT_INVALID_FTIE ((CsrWifiSmeIEEE80211Result) 0x0037)
+#define CSR_WIFI_SME_IEEE80211_RESULT_UNSPECIFIED_QOS_FAILURE ((CsrWifiSmeIEEE80211Result) 0x00c8)
+#define CSR_WIFI_SME_IEEE80211_RESULT_WRONG_POLICY ((CsrWifiSmeIEEE80211Result) 0x00c9)
+#define CSR_WIFI_SME_IEEE80211_RESULT_INSUFFICIENT_BANDWIDTH ((CsrWifiSmeIEEE80211Result) 0x00ca)
+#define CSR_WIFI_SME_IEEE80211_RESULT_INVALID_TSPEC_PARAMETERS ((CsrWifiSmeIEEE80211Result) 0x00cb)
+#define CSR_WIFI_SME_IEEE80211_RESULT_TIMEOUT ((CsrWifiSmeIEEE80211Result) 0x8000)
+#define CSR_WIFI_SME_IEEE80211_RESULT_TOO_MANY_SIMULTANEOUS_REQUESTS ((CsrWifiSmeIEEE80211Result) 0x8001)
+#define CSR_WIFI_SME_IEEE80211_RESULT_BSS_ALREADY_STARTED_OR_JOINED ((CsrWifiSmeIEEE80211Result) 0x8002)
+#define CSR_WIFI_SME_IEEE80211_RESULT_NOT_SUPPORTED ((CsrWifiSmeIEEE80211Result) 0x8003)
+#define CSR_WIFI_SME_IEEE80211_RESULT_TRANSMISSION_FAILURE ((CsrWifiSmeIEEE80211Result) 0x8004)
+#define CSR_WIFI_SME_IEEE80211_RESULT_REFUSED_NOT_AUTHENTICATED ((CsrWifiSmeIEEE80211Result) 0x8005)
+#define CSR_WIFI_SME_IEEE80211_RESULT_RESET_REQUIRED_BEFORE_START ((CsrWifiSmeIEEE80211Result) 0x8006)
+#define CSR_WIFI_SME_IEEE80211_RESULT_LM_INFO_UNAVAILABLE ((CsrWifiSmeIEEE80211Result) 0x8007)
+#define CSR_WIFI_SME_IEEE80211_RESULT_INVALID_UNICAST_CIPHER ((CsrWifiSmeIEEE80211Result) 0xf02f)
+#define CSR_WIFI_SME_IEEE80211_RESULT_INVALID_MULTICAST_CIPHER ((CsrWifiSmeIEEE80211Result) 0xf030)
+#define CSR_WIFI_SME_IEEE80211_RESULT_UNSUPPORTED_WAPI_IE_VERSION ((CsrWifiSmeIEEE80211Result) 0xf031)
+#define CSR_WIFI_SME_IEEE80211_RESULT_INVALID_WAPI_CAPABILITY_IE ((CsrWifiSmeIEEE80211Result) 0xf032)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeIndications
+
+ DESCRIPTION
+ Defines bits for CsrWifiSmeIndicationsMask
+
+ VALUES
+ CSR_WIFI_SME_INDICATIONS_NONE
+ - Used to cancel the registrations for receiving indications
+ CSR_WIFI_SME_INDICATIONS_WIFIOFF
+ - Used to register for CSR_WIFI_SME_WIFI_OFF_IND events
+ CSR_WIFI_SME_INDICATIONS_SCANRESULT
+ - Used to register for CSR_WIFI_SME_SCAN_RESULT_IND events
+ CSR_WIFI_SME_INDICATIONS_CONNECTIONQUALITY
+ - Used to register for CSR_WIFI_SME_CONNECTION_QUALITY_IND
+ events
+ CSR_WIFI_SME_INDICATIONS_MEDIASTATUS
+ - Used to register for CSR_WIFI_SME_MEDIA_STATUS_IND events
+ CSR_WIFI_SME_INDICATIONS_MICFAILURE
+ - Used to register for CSR_WIFI_SME_MICFAILURE_IND events
+ CSR_WIFI_SME_INDICATIONS_PMKIDCANDIDATELIST
+ - Used to register for CSR_WIFI_SME_PMKIDCANDIDATE_LIST_IND
+ events
+ CSR_WIFI_SME_INDICATIONS_TSPEC
+ - Used to register for CSR_WIFI_SME_TSPEC_IND events
+ CSR_WIFI_SME_INDICATIONS_ROAMSTART
+ - Used to register for CSR_WIFI_SME_ROAM_START_IND events
+ CSR_WIFI_SME_INDICATIONS_ROAMCOMPLETE
+ - Used to register for CSR_WIFI_SME_ROAM_COMPLETE_IND events
+ CSR_WIFI_SME_INDICATIONS_ASSOCIATIONSTART
+ - Used to register for CSR_WIFI_SME_ASSOCIATION_START_IND
+ events
+ CSR_WIFI_SME_INDICATIONS_ASSOCIATIONCOMPLETE
+ - Used to register for CSR_WIFI_SME_ASSOCIATION_COMPLETE_IND
+ events
+ CSR_WIFI_SME_INDICATIONS_IBSSSTATION
+ - Used to register for CSR_WIFI_SME_IBSS_STATION_IND events
+ CSR_WIFI_SME_INDICATIONS_WIFION
+ - Used to register for CSR_WIFI_SME_WIFI_ON_IND events
+ CSR_WIFI_SME_INDICATIONS_ERROR
+ - Used to register for CSR_WIFI_SME_ERROR_IND events
+ CSR_WIFI_SME_INDICATIONS_INFO
+ - Used to register for CSR_WIFI_SME_INFO_IND events
+ CSR_WIFI_SME_INDICATIONS_COREDUMP
+ - Used to register for CSR_WIFI_SME_CORE_DUMP_IND events
+ CSR_WIFI_SME_INDICATIONS_ALL
+ - Used to register for all available indications
+
+*******************************************************************************/
+typedef u32 CsrWifiSmeIndications;
+#define CSR_WIFI_SME_INDICATIONS_NONE ((CsrWifiSmeIndications) 0x00000000)
+#define CSR_WIFI_SME_INDICATIONS_WIFIOFF ((CsrWifiSmeIndications) 0x00000001)
+#define CSR_WIFI_SME_INDICATIONS_SCANRESULT ((CsrWifiSmeIndications) 0x00000002)
+#define CSR_WIFI_SME_INDICATIONS_CONNECTIONQUALITY ((CsrWifiSmeIndications) 0x00000004)
+#define CSR_WIFI_SME_INDICATIONS_MEDIASTATUS ((CsrWifiSmeIndications) 0x00000008)
+#define CSR_WIFI_SME_INDICATIONS_MICFAILURE ((CsrWifiSmeIndications) 0x00000010)
+#define CSR_WIFI_SME_INDICATIONS_PMKIDCANDIDATELIST ((CsrWifiSmeIndications) 0x00000020)
+#define CSR_WIFI_SME_INDICATIONS_TSPEC ((CsrWifiSmeIndications) 0x00000040)
+#define CSR_WIFI_SME_INDICATIONS_ROAMSTART ((CsrWifiSmeIndications) 0x00000080)
+#define CSR_WIFI_SME_INDICATIONS_ROAMCOMPLETE ((CsrWifiSmeIndications) 0x00000100)
+#define CSR_WIFI_SME_INDICATIONS_ASSOCIATIONSTART ((CsrWifiSmeIndications) 0x00000200)
+#define CSR_WIFI_SME_INDICATIONS_ASSOCIATIONCOMPLETE ((CsrWifiSmeIndications) 0x00000400)
+#define CSR_WIFI_SME_INDICATIONS_IBSSSTATION ((CsrWifiSmeIndications) 0x00000800)
+#define CSR_WIFI_SME_INDICATIONS_WIFION ((CsrWifiSmeIndications) 0x00001000)
+#define CSR_WIFI_SME_INDICATIONS_ERROR ((CsrWifiSmeIndications) 0x00002000)
+#define CSR_WIFI_SME_INDICATIONS_INFO ((CsrWifiSmeIndications) 0x00004000)
+#define CSR_WIFI_SME_INDICATIONS_COREDUMP ((CsrWifiSmeIndications) 0x00008000)
+#define CSR_WIFI_SME_INDICATIONS_ALL ((CsrWifiSmeIndications) 0xFFFFFFFF)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeKeyType
+
+ DESCRIPTION
+ Indicates the type of the key
+
+ VALUES
+ CSR_WIFI_SME_KEY_TYPE_GROUP - Key for broadcast communication
+ CSR_WIFI_SME_KEY_TYPE_PAIRWISE - Key for unicast communication
+ CSR_WIFI_SME_KEY_TYPE_STAKEY - Key for direct link communication to
+ another station in infrastructure networks
+ CSR_WIFI_SME_KEY_TYPE_IGTK - Integrity Group Temporal Key
+ CSR_WIFI_SME_KEY_TYPE_CCKM - Key for Cisco Centralized Key Management
+
+*******************************************************************************/
+typedef u8 CsrWifiSmeKeyType;
+#define CSR_WIFI_SME_KEY_TYPE_GROUP ((CsrWifiSmeKeyType) 0x00)
+#define CSR_WIFI_SME_KEY_TYPE_PAIRWISE ((CsrWifiSmeKeyType) 0x01)
+#define CSR_WIFI_SME_KEY_TYPE_STAKEY ((CsrWifiSmeKeyType) 0x02)
+#define CSR_WIFI_SME_KEY_TYPE_IGTK ((CsrWifiSmeKeyType) 0x03)
+#define CSR_WIFI_SME_KEY_TYPE_CCKM ((CsrWifiSmeKeyType) 0x04)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeListAction
+
+ DESCRIPTION
+ Identifies the type of action to be performed on a list of items
+ The values of this type are used across the NME/SME/Router API's and they
+ must be kept consistent with the corresponding types in the .xml of the
+ ottherinterfaces
+
+ VALUES
+ CSR_WIFI_SME_LIST_ACTION_GET - Retrieve the current list of items
+ CSR_WIFI_SME_LIST_ACTION_ADD - Add one or more items
+ CSR_WIFI_SME_LIST_ACTION_REMOVE - Remove one or more items
+ CSR_WIFI_SME_LIST_ACTION_FLUSH - Remove all items
+
+*******************************************************************************/
+typedef u8 CsrWifiSmeListAction;
+#define CSR_WIFI_SME_LIST_ACTION_GET ((CsrWifiSmeListAction) 0x00)
+#define CSR_WIFI_SME_LIST_ACTION_ADD ((CsrWifiSmeListAction) 0x01)
+#define CSR_WIFI_SME_LIST_ACTION_REMOVE ((CsrWifiSmeListAction) 0x02)
+#define CSR_WIFI_SME_LIST_ACTION_FLUSH ((CsrWifiSmeListAction) 0x03)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeMediaStatus
+
+ DESCRIPTION
+ Indicates the connection status
+ The values of this type are used across the NME/SME/Router API's and they
+ must be kept consistent with the corresponding types in the .xml of the
+ ottherinterfaces
+
+ VALUES
+ CSR_WIFI_SME_MEDIA_STATUS_CONNECTED
+ - Value CSR_WIFI_SME_MEDIA_STATUS_CONNECTED can happen in two
+ situations:
+ * A network connection is established. Specifically, this is
+ when the MLME_ASSOCIATION completes or the first peer
+ relationship is established in an IBSS. In a WPA/WPA2
+ network, this indicates that the stack is ready to perform
+ the 4-way handshake or 802.1x authentication if CSR NME
+ security library is not used. If CSR NME security library
+ is used this indicates, completion of 4way handshake or
+ 802.1x authentication
+ * The SME roams to another AP on the same ESS
+ During the AP operation, it indicates that the peer station
+ is connected to the AP and is ready for data transfer.
+ CSR_WIFI_SME_MEDIA_STATUS_DISCONNECTED
+ - Value CSR_WIFI_SME_MEDIA_STATUS_DISCONNECTED can happen in
+ two situations:
+ * when the connection to a network is lost and there is no
+ alternative on the same ESS to roam to
+ * when a CSR_WIFI_SME_DISCONNECT_REQ request is issued
+ During AP or P2PGO operation, it indicates that the peer
+ station has disconnected from the AP
+
+*******************************************************************************/
+typedef u8 CsrWifiSmeMediaStatus;
+#define CSR_WIFI_SME_MEDIA_STATUS_CONNECTED ((CsrWifiSmeMediaStatus) 0x00)
+#define CSR_WIFI_SME_MEDIA_STATUS_DISCONNECTED ((CsrWifiSmeMediaStatus) 0x01)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeP2pCapability
+
+ DESCRIPTION
+ Defines P2P Device Capabilities
+
+ VALUES
+ CSR_WIFI_SME_P2P_SERVICE_DISCOVERY_CAPABILITY
+ - This field is set to 1 if the P2P Device supports Service
+ Discovery, and to 0 otherwise
+ CSR_WIFI_SME_P2P_CLIENT_DISCOVERABILITY_CAPABILITY
+ - This field is set to 1 when the P2P Device supports P2P
+ Client Discoverability, and to 0 otherwise.
+ CSR_WIFI_SME_P2P_CONCURRENT_OPERATION_CAPABILITY
+ - This field is set to 1 when the P2P Device supports
+ Concurrent Operation with WLAN, and to 0 otherwise.
+ CSR_WIFI_SME_P2P_MANAGED_DEVICE_CAPABILITY
+ - This field is set to 1 when the P2P interface of the P2P
+ Device is capable of being managed by the WLAN
+ (infrastructure network) based on P2P coexistence
+ parameters, and to 0 otherwise
+ CSR_WIFI_SME_P2P_INVITAION_CAPABILITY
+ - This field is set to 1 if the P2P Device is capable of
+ processing P2P Invitation Procedure signaling, and to 0
+ otherwise.
+
+*******************************************************************************/
+typedef u8 CsrWifiSmeP2pCapability;
+#define CSR_WIFI_SME_P2P_SERVICE_DISCOVERY_CAPABILITY ((CsrWifiSmeP2pCapability) 0x01)
+#define CSR_WIFI_SME_P2P_CLIENT_DISCOVERABILITY_CAPABILITY ((CsrWifiSmeP2pCapability) 0x02)
+#define CSR_WIFI_SME_P2P_CONCURRENT_OPERATION_CAPABILITY ((CsrWifiSmeP2pCapability) 0x04)
+#define CSR_WIFI_SME_P2P_MANAGED_DEVICE_CAPABILITY ((CsrWifiSmeP2pCapability) 0x08)
+#define CSR_WIFI_SME_P2P_INVITAION_CAPABILITY ((CsrWifiSmeP2pCapability) 0x20)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeP2pGroupCapability
+
+ DESCRIPTION
+ Define bits for P2P Group Capability
+
+ VALUES
+ CSR_WIFI_P2P_GRP_CAP_GO
+ - Indicates if the local device has become a GO after GO
+ negotiation
+ CSR_WIFI_P2P_GRP_CAP_PERSISTENT
+ - Persistent group
+ CSR_WIFI_P2P_GRP_CAP_INTRABSS_DIST
+ - Intra-BSS data distribution support
+ CSR_WIFI_P2P_GRP_CAP_CROSS_CONN
+ - Support of cross connection
+ CSR_WIFI_P2P_GRP_CAP_PERSISTENT_RECONNECT
+ - Support of persistent reconnect
+
+*******************************************************************************/
+typedef u8 CsrWifiSmeP2pGroupCapability;
+#define CSR_WIFI_P2P_GRP_CAP_GO ((CsrWifiSmeP2pGroupCapability) 0x01)
+#define CSR_WIFI_P2P_GRP_CAP_PERSISTENT ((CsrWifiSmeP2pGroupCapability) 0x02)
+#define CSR_WIFI_P2P_GRP_CAP_INTRABSS_DIST ((CsrWifiSmeP2pGroupCapability) 0x08)
+#define CSR_WIFI_P2P_GRP_CAP_CROSS_CONN ((CsrWifiSmeP2pGroupCapability) 0x10)
+#define CSR_WIFI_P2P_GRP_CAP_PERSISTENT_RECONNECT ((CsrWifiSmeP2pGroupCapability) 0x20)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeP2pNoaConfigMethod
+
+ DESCRIPTION
+ Notice of Absece Configuration
+
+ VALUES
+ CSR_WIFI_P2P_NOA_NONE - Do not use NOA
+ CSR_WIFI_P2P_NOA_AUTONOMOUS - NOA based on the traffic analysis
+ CSR_WIFI_P2P_NOA_USER_DEFINED - NOA as specified by the user
+
+*******************************************************************************/
+typedef u8 CsrWifiSmeP2pNoaConfigMethod;
+#define CSR_WIFI_P2P_NOA_NONE ((CsrWifiSmeP2pNoaConfigMethod) 0x00)
+#define CSR_WIFI_P2P_NOA_AUTONOMOUS ((CsrWifiSmeP2pNoaConfigMethod) 0x01)
+#define CSR_WIFI_P2P_NOA_USER_DEFINED ((CsrWifiSmeP2pNoaConfigMethod) 0x02)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeP2pRole
+
+ DESCRIPTION
+ Definition of roles for a P2P Device
+
+ VALUES
+ CSR_WIFI_SME_P2P_ROLE_NONE - A non-P2PDevice device
+ CSR_WIFI_SME_P2P_ROLE_STANDALONE - A Standalone P2P device
+ CSR_WIFI_SME_P2P_ROLE_GO - Role Assumed is that of a Group Owner
+ within a P2P Group
+ CSR_WIFI_SME_P2P_ROLE_CLI - Role Assumed is that of a P2P Client
+ within a P2P Group
+
+*******************************************************************************/
+typedef u8 CsrWifiSmeP2pRole;
+#define CSR_WIFI_SME_P2P_ROLE_NONE ((CsrWifiSmeP2pRole) 0x00)
+#define CSR_WIFI_SME_P2P_ROLE_STANDALONE ((CsrWifiSmeP2pRole) 0x01)
+#define CSR_WIFI_SME_P2P_ROLE_GO ((CsrWifiSmeP2pRole) 0x02)
+#define CSR_WIFI_SME_P2P_ROLE_CLI ((CsrWifiSmeP2pRole) 0x03)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeP2pStatus
+
+ DESCRIPTION
+ This data type enumerates the outcome of P2P procedure
+
+ VALUES
+ CSR_WIFI_SME_P2P_STATUS_SUCCESS
+ - Success
+ CSR_WIFI_SME_P2P_STATUS_FAIL_INFO_UNAVAILABLE
+ - Fail; information is currently unavailable
+ CSR_WIFI_SME_P2P_STATUS_FAIL_INCOMPATIBLE_PARAM
+ - Fail; incompatible parameters
+ CSR_WIFI_SME_P2P_STATUS_FAIL_LIMIT_REACHED
+ - Fail; limit reached
+ CSR_WIFI_SME_P2P_STATUS_FAIL_INVALID_PARAM
+ - Fail; invalid parameters
+ CSR_WIFI_SME_P2P_STATUS_FAIL_ACCOMODATE
+ - Fail; unable to accommodate request
+ CSR_WIFI_SME_P2P_STATUS_FAIL_PREV_ERROR
+ - Fail; previous protocol error, or disruptive behavior
+ CSR_WIFI_SME_P2P_STATUS_FAIL_COMMON_CHANNELS
+ - Fail; no common channels
+ CSR_WIFI_SME_P2P_STATUS_FAIL_UNKNOWN_GROUP
+ - Fail; unknown P2P Group
+ CSR_WIFI_SME_P2P_STATUS_FAIL_GO_INTENT
+ - Fail: both P2P Devices indicated an Intent of 15 in Group
+ Owner Negotiation
+ CSR_WIFI_SME_P2P_STATUS_FAIL_PROVISION_METHOD_INCOMPATIBLE
+ - Fail; incompatible provisioning method
+ CSR_WIFI_SME_P2P_STATUS_FAIL_REJECT
+ - Fail: rejected by user
+ CSR_WIFI_SME_P2P_STATUS_FAIL_RESERVED
+ - Fail; Status Reserved
+
+*******************************************************************************/
+typedef u8 CsrWifiSmeP2pStatus;
+#define CSR_WIFI_SME_P2P_STATUS_SUCCESS ((CsrWifiSmeP2pStatus) 0x00)
+#define CSR_WIFI_SME_P2P_STATUS_FAIL_INFO_UNAVAILABLE ((CsrWifiSmeP2pStatus) 0x01)
+#define CSR_WIFI_SME_P2P_STATUS_FAIL_INCOMPATIBLE_PARAM ((CsrWifiSmeP2pStatus) 0x02)
+#define CSR_WIFI_SME_P2P_STATUS_FAIL_LIMIT_REACHED ((CsrWifiSmeP2pStatus) 0x03)
+#define CSR_WIFI_SME_P2P_STATUS_FAIL_INVALID_PARAM ((CsrWifiSmeP2pStatus) 0x04)
+#define CSR_WIFI_SME_P2P_STATUS_FAIL_ACCOMODATE ((CsrWifiSmeP2pStatus) 0x05)
+#define CSR_WIFI_SME_P2P_STATUS_FAIL_PREV_ERROR ((CsrWifiSmeP2pStatus) 0x06)
+#define CSR_WIFI_SME_P2P_STATUS_FAIL_COMMON_CHANNELS ((CsrWifiSmeP2pStatus) 0x07)
+#define CSR_WIFI_SME_P2P_STATUS_FAIL_UNKNOWN_GROUP ((CsrWifiSmeP2pStatus) 0x08)
+#define CSR_WIFI_SME_P2P_STATUS_FAIL_GO_INTENT ((CsrWifiSmeP2pStatus) 0x09)
+#define CSR_WIFI_SME_P2P_STATUS_FAIL_PROVISION_METHOD_INCOMPATIBLE ((CsrWifiSmeP2pStatus) 0x0A)
+#define CSR_WIFI_SME_P2P_STATUS_FAIL_REJECT ((CsrWifiSmeP2pStatus) 0x0B)
+#define CSR_WIFI_SME_P2P_STATUS_FAIL_RESERVED ((CsrWifiSmeP2pStatus) 0xFF)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmePacketFilterMode
+
+ DESCRIPTION
+ Options for the filter mode parameter.
+ The Values here match the HIP interface
+
+ VALUES
+ CSR_WIFI_SME_PACKET_FILTER_MODE_OPT_OUT
+ - Broadcast packets are always reported to the host unless
+ they match at least one of the specified TCLAS IEs.
+ CSR_WIFI_SME_PACKET_FILTER_MODE_OPT_IN
+ - Broadcast packets are reported to the host only if they
+ match at least one of the specified TCLAS IEs.
+
+*******************************************************************************/
+typedef u8 CsrWifiSmePacketFilterMode;
+#define CSR_WIFI_SME_PACKET_FILTER_MODE_OPT_OUT ((CsrWifiSmePacketFilterMode) 0x00)
+#define CSR_WIFI_SME_PACKET_FILTER_MODE_OPT_IN ((CsrWifiSmePacketFilterMode) 0x03)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmePowerSaveLevel
+
+ DESCRIPTION
+ Power Save Level options as defined in the IEEE 802.11 standards
+ First 3 values are set to match the mlme PowerManagementMode
+
+ VALUES
+ CSR_WIFI_SME_POWER_SAVE_LEVEL_LOW - No power save: the driver will remain
+ active at all times
+ CSR_WIFI_SME_POWER_SAVE_LEVEL_HIGH - Enter power save after all packets in
+ the queues are transmitted and received
+ CSR_WIFI_SME_POWER_SAVE_LEVEL_MED - Enter power save after all packets in
+ the queues are transmitted and received
+ and a further configurable delay
+ (default 1s) has elapsed
+ CSR_WIFI_SME_POWER_SAVE_LEVEL_AUTO - The SME will decide when to enter power
+ save mode according to the traffic
+ analysis
+
+*******************************************************************************/
+typedef u8 CsrWifiSmePowerSaveLevel;
+#define CSR_WIFI_SME_POWER_SAVE_LEVEL_LOW ((CsrWifiSmePowerSaveLevel) 0x00)
+#define CSR_WIFI_SME_POWER_SAVE_LEVEL_HIGH ((CsrWifiSmePowerSaveLevel) 0x01)
+#define CSR_WIFI_SME_POWER_SAVE_LEVEL_MED ((CsrWifiSmePowerSaveLevel) 0x02)
+#define CSR_WIFI_SME_POWER_SAVE_LEVEL_AUTO ((CsrWifiSmePowerSaveLevel) 0x03)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmePreambleType
+
+ DESCRIPTION
+ SME Preamble Types
+
+ VALUES
+ CSR_WIFI_SME_USE_LONG_PREAMBLE - Use legacy (long) preamble
+ CSR_WIFI_SME_USE_SHORT_PREAMBLE - Use short PPDU format
+
+*******************************************************************************/
+typedef u8 CsrWifiSmePreambleType;
+#define CSR_WIFI_SME_USE_LONG_PREAMBLE ((CsrWifiSmePreambleType) 0x00)
+#define CSR_WIFI_SME_USE_SHORT_PREAMBLE ((CsrWifiSmePreambleType) 0x01)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeRadioIF
+
+ DESCRIPTION
+ Indicates the frequency
+
+ VALUES
+ CSR_WIFI_SME_RADIO_IF_GHZ_2_4 - Indicates the 2.4 GHZ frequency
+ CSR_WIFI_SME_RADIO_IF_GHZ_5_0 - Future use: currently not supported
+ CSR_WIFI_SME_RADIO_IF_BOTH - Future use: currently not supported
+
+*******************************************************************************/
+typedef u8 CsrWifiSmeRadioIF;
+#define CSR_WIFI_SME_RADIO_IF_GHZ_2_4 ((CsrWifiSmeRadioIF) 0x01)
+#define CSR_WIFI_SME_RADIO_IF_GHZ_5_0 ((CsrWifiSmeRadioIF) 0x02)
+#define CSR_WIFI_SME_RADIO_IF_BOTH ((CsrWifiSmeRadioIF) 0x03)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeRegulatoryDomain
+
+ DESCRIPTION
+ Indicates the regulatory domain as defined in IEEE 802.11 standards
+
+ VALUES
+ CSR_WIFI_SME_REGULATORY_DOMAIN_OTHER
+ - See IEEE 802.11 Standard
+ CSR_WIFI_SME_REGULATORY_DOMAIN_FCC
+ - See IEEE 802.11 Standard
+ CSR_WIFI_SME_REGULATORY_DOMAIN_IC
+ - See IEEE 802.11 Standard
+ CSR_WIFI_SME_REGULATORY_DOMAIN_ETSI
+ - See IEEE 802.11 Standard
+ CSR_WIFI_SME_REGULATORY_DOMAIN_SPAIN
+ - See IEEE 802.11 Standard
+ CSR_WIFI_SME_REGULATORY_DOMAIN_FRANCE
+ - See IEEE 802.11 Standard
+ CSR_WIFI_SME_REGULATORY_DOMAIN_JAPAN
+ - See IEEE 802.11 Standard
+ CSR_WIFI_SME_REGULATORY_DOMAIN_JAPANBIS
+ - See IEEE 802.11 Standard
+ CSR_WIFI_SME_REGULATORY_DOMAIN_CHINA
+ - See IEEE 802.11 Standard
+ CSR_WIFI_SME_REGULATORY_DOMAIN_CHINABIS
+ - See IEEE 802.11 Standard
+ CSR_WIFI_SME_REGULATORY_DOMAIN_NONE
+ - See IEEE 802.11 Standard
+
+*******************************************************************************/
+typedef u8 CsrWifiSmeRegulatoryDomain;
+#define CSR_WIFI_SME_REGULATORY_DOMAIN_OTHER ((CsrWifiSmeRegulatoryDomain) 0x00)
+#define CSR_WIFI_SME_REGULATORY_DOMAIN_FCC ((CsrWifiSmeRegulatoryDomain) 0x10)
+#define CSR_WIFI_SME_REGULATORY_DOMAIN_IC ((CsrWifiSmeRegulatoryDomain) 0x20)
+#define CSR_WIFI_SME_REGULATORY_DOMAIN_ETSI ((CsrWifiSmeRegulatoryDomain) 0x30)
+#define CSR_WIFI_SME_REGULATORY_DOMAIN_SPAIN ((CsrWifiSmeRegulatoryDomain) 0x31)
+#define CSR_WIFI_SME_REGULATORY_DOMAIN_FRANCE ((CsrWifiSmeRegulatoryDomain) 0x32)
+#define CSR_WIFI_SME_REGULATORY_DOMAIN_JAPAN ((CsrWifiSmeRegulatoryDomain) 0x40)
+#define CSR_WIFI_SME_REGULATORY_DOMAIN_JAPANBIS ((CsrWifiSmeRegulatoryDomain) 0x41)
+#define CSR_WIFI_SME_REGULATORY_DOMAIN_CHINA ((CsrWifiSmeRegulatoryDomain) 0x50)
+#define CSR_WIFI_SME_REGULATORY_DOMAIN_CHINABIS ((CsrWifiSmeRegulatoryDomain) 0x51)
+#define CSR_WIFI_SME_REGULATORY_DOMAIN_NONE ((CsrWifiSmeRegulatoryDomain) 0xFF)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeRoamReason
+
+ DESCRIPTION
+ Indicates the reason for roaming
+
+ VALUES
+ CSR_WIFI_SME_ROAM_REASON_BEACONLOST
+ - The station cannot receive the beacon signal any more
+ CSR_WIFI_SME_ROAM_REASON_DISASSOCIATED
+ - The station has been disassociated
+ CSR_WIFI_SME_ROAM_REASON_DEAUTHENTICATED
+ - The station has been deauthenticated
+ CSR_WIFI_SME_ROAM_REASON_BETTERAPFOUND
+ - A better AP has been found
+
+*******************************************************************************/
+typedef u8 CsrWifiSmeRoamReason;
+#define CSR_WIFI_SME_ROAM_REASON_BEACONLOST ((CsrWifiSmeRoamReason) 0x00)
+#define CSR_WIFI_SME_ROAM_REASON_DISASSOCIATED ((CsrWifiSmeRoamReason) 0x01)
+#define CSR_WIFI_SME_ROAM_REASON_DEAUTHENTICATED ((CsrWifiSmeRoamReason) 0x02)
+#define CSR_WIFI_SME_ROAM_REASON_BETTERAPFOUND ((CsrWifiSmeRoamReason) 0x03)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeScanType
+
+ DESCRIPTION
+ Identifies the type of scan to be performed
+
+ VALUES
+ CSR_WIFI_SME_SCAN_TYPE_ALL - Scan actively or passively according to the
+ regulatory domain restrictions
+ CSR_WIFI_SME_SCAN_TYPE_ACTIVE - Scan actively only: send probes and listen
+ for answers
+ CSR_WIFI_SME_SCAN_TYPE_PASSIVE - Scan passively only: listen for beacon
+ messages
+
+*******************************************************************************/
+typedef u8 CsrWifiSmeScanType;
+#define CSR_WIFI_SME_SCAN_TYPE_ALL ((CsrWifiSmeScanType) 0x00)
+#define CSR_WIFI_SME_SCAN_TYPE_ACTIVE ((CsrWifiSmeScanType) 0x01)
+#define CSR_WIFI_SME_SCAN_TYPE_PASSIVE ((CsrWifiSmeScanType) 0x02)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeTrafficType
+
+ DESCRIPTION
+ Identifies the type of traffic going on on the connection.
+ The values of this type are used across the NME/SME/Router API's and they
+ must be kept consistent with the corresponding types in the .xml of the
+ ottherinterfaces
+
+ VALUES
+ CSR_WIFI_SME_TRAFFIC_TYPE_OCCASIONAL
+ - During the last 30 seconds there were fewer than 20 packets
+ per seconds in each second in both directions
+ CSR_WIFI_SME_TRAFFIC_TYPE_BURSTY
+ - During the last 30 seconds there was at least one second
+ during which more than 20 packets were received in either
+ direction
+ CSR_WIFI_SME_TRAFFIC_TYPE_PERIODIC
+ - During the last 5 seconds there were at least 10 packets
+ received each second and a defined period for the traffic
+ can be recognized
+ CSR_WIFI_SME_TRAFFIC_TYPE_CONTINUOUS
+ - During the last 5 seconds there were at least 20 packets
+ received each second in either direction
+
+*******************************************************************************/
+typedef u8 CsrWifiSmeTrafficType;
+#define CSR_WIFI_SME_TRAFFIC_TYPE_OCCASIONAL ((CsrWifiSmeTrafficType) 0x00)
+#define CSR_WIFI_SME_TRAFFIC_TYPE_BURSTY ((CsrWifiSmeTrafficType) 0x01)
+#define CSR_WIFI_SME_TRAFFIC_TYPE_PERIODIC ((CsrWifiSmeTrafficType) 0x02)
+#define CSR_WIFI_SME_TRAFFIC_TYPE_CONTINUOUS ((CsrWifiSmeTrafficType) 0x03)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeTspecCtrl
+
+ DESCRIPTION
+ Defines bits for CsrWifiSmeTspecCtrlMask for additional CCX configuration.
+ CURRENTLY NOT SUPPORTED.
+
+ VALUES
+ CSR_WIFI_SME_TSPEC_CTRL_STRICT
+ - No automatic negotiation
+ CSR_WIFI_SME_TSPEC_CTRL_CCX_SIGNALLING
+ - Signalling TSPEC
+ CSR_WIFI_SME_TSPEC_CTRL_CCX_VOICE
+ - Voice traffic TSPEC
+
+*******************************************************************************/
+typedef u8 CsrWifiSmeTspecCtrl;
+#define CSR_WIFI_SME_TSPEC_CTRL_STRICT ((CsrWifiSmeTspecCtrl) 0x01)
+#define CSR_WIFI_SME_TSPEC_CTRL_CCX_SIGNALLING ((CsrWifiSmeTspecCtrl) 0x02)
+#define CSR_WIFI_SME_TSPEC_CTRL_CCX_VOICE ((CsrWifiSmeTspecCtrl) 0x04)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeTspecResultCode
+
+ DESCRIPTION
+ Defines the result of the TSPEC exchanges with the AP
+
+ VALUES
+ CSR_WIFI_SME_TSPEC_RESULT_SUCCESS
+ - TSPEC command has been processed correctly
+ CSR_WIFI_SME_TSPEC_RESULT_UNSPECIFIED_QOS_FAILURE
+ - The Access Point reported a failure
+ CSR_WIFI_SME_TSPEC_RESULT_FAILURE
+ - Internal failure in the SME
+ CSR_WIFI_SME_TSPEC_RESULT_INVALID_TSPEC_PARAMETERS
+ - The TSPEC parameters are invalid
+ CSR_WIFI_SME_TSPEC_RESULT_INVALID_TCLAS_PARAMETERS
+ - The TCLASS parameters are invalid
+ CSR_WIFI_SME_TSPEC_RESULT_INSUFFICIENT_BANDWIDTH
+ - As specified by the WMM Spec
+ CSR_WIFI_SME_TSPEC_RESULT_WRONG_POLICY
+ - As specified by the WMM Spec
+ CSR_WIFI_SME_TSPEC_RESULT_REJECTED_WITH_SUGGESTED_CHANGES
+ - As specified by the WMM Spec
+ CSR_WIFI_SME_TSPEC_RESULT_TIMEOUT
+ - The TSPEC negotiation timed out
+ CSR_WIFI_SME_TSPEC_RESULT_NOT_SUPPORTED
+ - The Access Point does not support the TSPEC
+ CSR_WIFI_SME_TSPEC_RESULT_IE_LENGTH_INCORRECT
+ - The length of the TSPEC is not correct
+ CSR_WIFI_SME_TSPEC_RESULT_INVALID_TRANSACTION_ID
+ - The TSPEC transaction id is not in the list
+ CSR_WIFI_SME_TSPEC_RESULT_INSTALLED
+ - The TSPEC has been installed and it is now active.
+ CSR_WIFI_SME_TSPEC_RESULT_TID_ALREADY_INSTALLED
+ - The Traffic ID has already been installed
+ CSR_WIFI_SME_TSPEC_RESULT_TSPEC_REMOTELY_DELETED
+ - The AP has deleted the TSPEC
+
+*******************************************************************************/
+typedef u8 CsrWifiSmeTspecResultCode;
+#define CSR_WIFI_SME_TSPEC_RESULT_SUCCESS ((CsrWifiSmeTspecResultCode) 0x00)
+#define CSR_WIFI_SME_TSPEC_RESULT_UNSPECIFIED_QOS_FAILURE ((CsrWifiSmeTspecResultCode) 0x01)
+#define CSR_WIFI_SME_TSPEC_RESULT_FAILURE ((CsrWifiSmeTspecResultCode) 0x02)
+#define CSR_WIFI_SME_TSPEC_RESULT_INVALID_TSPEC_PARAMETERS ((CsrWifiSmeTspecResultCode) 0x05)
+#define CSR_WIFI_SME_TSPEC_RESULT_INVALID_TCLAS_PARAMETERS ((CsrWifiSmeTspecResultCode) 0x06)
+#define CSR_WIFI_SME_TSPEC_RESULT_INSUFFICIENT_BANDWIDTH ((CsrWifiSmeTspecResultCode) 0x07)
+#define CSR_WIFI_SME_TSPEC_RESULT_WRONG_POLICY ((CsrWifiSmeTspecResultCode) 0x08)
+#define CSR_WIFI_SME_TSPEC_RESULT_REJECTED_WITH_SUGGESTED_CHANGES ((CsrWifiSmeTspecResultCode) 0x09)
+#define CSR_WIFI_SME_TSPEC_RESULT_TIMEOUT ((CsrWifiSmeTspecResultCode) 0x0D)
+#define CSR_WIFI_SME_TSPEC_RESULT_NOT_SUPPORTED ((CsrWifiSmeTspecResultCode) 0x0E)
+#define CSR_WIFI_SME_TSPEC_RESULT_IE_LENGTH_INCORRECT ((CsrWifiSmeTspecResultCode) 0x10)
+#define CSR_WIFI_SME_TSPEC_RESULT_INVALID_TRANSACTION_ID ((CsrWifiSmeTspecResultCode) 0x11)
+#define CSR_WIFI_SME_TSPEC_RESULT_INSTALLED ((CsrWifiSmeTspecResultCode) 0x12)
+#define CSR_WIFI_SME_TSPEC_RESULT_TID_ALREADY_INSTALLED ((CsrWifiSmeTspecResultCode) 0x13)
+#define CSR_WIFI_SME_TSPEC_RESULT_TSPEC_REMOTELY_DELETED ((CsrWifiSmeTspecResultCode) 0x14)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeWepAuthMode
+
+ DESCRIPTION
+ Define bits for CsrWifiSmeWepAuthMode
+
+ VALUES
+ CSR_WIFI_SME_WEP_AUTH_MODE_OPEN - Open-WEP enabled network
+ CSR_WIFI_SME_WEP_AUTH_MODE_SHARED - Shared-key WEP enabled network.
+
+*******************************************************************************/
+typedef u8 CsrWifiSmeWepAuthMode;
+#define CSR_WIFI_SME_WEP_AUTH_MODE_OPEN ((CsrWifiSmeWepAuthMode) 0x00)
+#define CSR_WIFI_SME_WEP_AUTH_MODE_SHARED ((CsrWifiSmeWepAuthMode) 0x01)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeWepCredentialType
+
+ DESCRIPTION
+ Definition of types of WEP Credentials
+
+ VALUES
+ CSR_WIFI_SME_CREDENTIAL_TYPE_WEP64
+ - WEP 64 credential
+ CSR_WIFI_SME_CREDENTIAL_TYPE_WEP128
+ - WEP 128 credential
+
+*******************************************************************************/
+typedef u8 CsrWifiSmeWepCredentialType;
+#define CSR_WIFI_SME_CREDENTIAL_TYPE_WEP64 ((CsrWifiSmeWepCredentialType) 0x00)
+#define CSR_WIFI_SME_CREDENTIAL_TYPE_WEP128 ((CsrWifiSmeWepCredentialType) 0x01)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeWmmMode
+
+ DESCRIPTION
+ Defines bits for CsrWifiSmeWmmModeMask: enable/disable WMM features.
+
+ VALUES
+ CSR_WIFI_SME_WMM_MODE_DISABLED - Disables the WMM features.
+ CSR_WIFI_SME_WMM_MODE_AC_ENABLED - Enables support for WMM-AC.
+ CSR_WIFI_SME_WMM_MODE_PS_ENABLED - Enables support for WMM Power Save.
+ CSR_WIFI_SME_WMM_MODE_SA_ENABLED - Currently not supported
+ CSR_WIFI_SME_WMM_MODE_ENABLED - Enables support for all currently
+ available WMM features.
+
+*******************************************************************************/
+typedef u8 CsrWifiSmeWmmMode;
+#define CSR_WIFI_SME_WMM_MODE_DISABLED ((CsrWifiSmeWmmMode) 0x00)
+#define CSR_WIFI_SME_WMM_MODE_AC_ENABLED ((CsrWifiSmeWmmMode) 0x01)
+#define CSR_WIFI_SME_WMM_MODE_PS_ENABLED ((CsrWifiSmeWmmMode) 0x02)
+#define CSR_WIFI_SME_WMM_MODE_SA_ENABLED ((CsrWifiSmeWmmMode) 0x04)
+#define CSR_WIFI_SME_WMM_MODE_ENABLED ((CsrWifiSmeWmmMode) 0xFF)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeWmmQosInfo
+
+ DESCRIPTION
+ Defines bits for the QoS Info Octect as defined in the WMM specification.
+ The first four values define one bit each that can be set or cleared.
+ Each of the last four values define all the remaining 4 bits and only one
+ of them at the time shall be used.
+ For more information, see 'WMM (including WMM Power Save) Specification -
+ Version 1.1' and 'UniFi Configuring WMM and WMM-PS, Application Note'.
+
+ VALUES
+ CSR_WIFI_SME_WMM_QOS_INFO_AC_MAX_SP_ALL
+ - WMM AP may deliver all buffered frames
+ CSR_WIFI_SME_WMM_QOS_INFO_AC_VO
+ - Enable UAPSD(both trigger and delivery) for Voice Access
+ Category
+ CSR_WIFI_SME_WMM_QOS_INFO_AC_VI
+ - Enable UAPSD(both trigger and delivery) for Video Access
+ Category
+ CSR_WIFI_SME_WMM_QOS_INFO_AC_BK
+ - Enable UAPSD(both trigger and delivery) for Background
+ Access Category
+ CSR_WIFI_SME_WMM_QOS_INFO_AC_BE
+ - Enable UAPSD(both trigger and delivery) for Best Effort
+ Access Category
+ CSR_WIFI_SME_WMM_QOS_INFO_AC_MAX_SP_TWO
+ - WMM AP may deliver a maximum of 2 buffered frames (MSDUs
+ and MMPDUs) per USP
+ CSR_WIFI_SME_WMM_QOS_INFO_AC_MAX_SP_FOUR
+ - WMM AP may deliver a maximum of 4 buffered frames (MSDUs
+ and MMPDUs) per USP
+ CSR_WIFI_SME_WMM_QOS_INFO_AC_MAX_SP_SIX
+ - WMM AP may deliver a maximum of 6 buffered frames (MSDUs
+ and MMPDUs) per USP
+
+*******************************************************************************/
+typedef u8 CsrWifiSmeWmmQosInfo;
+#define CSR_WIFI_SME_WMM_QOS_INFO_AC_MAX_SP_ALL ((CsrWifiSmeWmmQosInfo) 0x00)
+#define CSR_WIFI_SME_WMM_QOS_INFO_AC_VO ((CsrWifiSmeWmmQosInfo) 0x01)
+#define CSR_WIFI_SME_WMM_QOS_INFO_AC_VI ((CsrWifiSmeWmmQosInfo) 0x02)
+#define CSR_WIFI_SME_WMM_QOS_INFO_AC_BK ((CsrWifiSmeWmmQosInfo) 0x04)
+#define CSR_WIFI_SME_WMM_QOS_INFO_AC_BE ((CsrWifiSmeWmmQosInfo) 0x08)
+#define CSR_WIFI_SME_WMM_QOS_INFO_AC_MAX_SP_TWO ((CsrWifiSmeWmmQosInfo) 0x20)
+#define CSR_WIFI_SME_WMM_QOS_INFO_AC_MAX_SP_FOUR ((CsrWifiSmeWmmQosInfo) 0x40)
+#define CSR_WIFI_SME_WMM_QOS_INFO_AC_MAX_SP_SIX ((CsrWifiSmeWmmQosInfo) 0x60)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeWpsConfigType
+
+ DESCRIPTION
+ WPS config methods supported/used by a device
+
+ VALUES
+ CSR_WIFI_WPS_CONFIG_LABEL
+ - Label
+ CSR_WIFI_WPS_CONFIG_DISPLAY
+ - Display
+ CSR_WIFI_WPS_CONFIG_EXT_NFC
+ - External NFC : Not supported in this release
+ CSR_WIFI_WPS_CONFIG_INT_NFC
+ - Internal NFC : Not supported in this release
+ CSR_WIFI_WPS_CONFIG_NFC_IFACE
+ - NFC interface : Not supported in this release
+ CSR_WIFI_WPS_CONFIG_PBC
+ - PBC
+ CSR_WIFI_WPS_CONFIG_KEYPAD
+ - KeyPad
+ CSR_WIFI_WPS_CONFIG_VIRTUAL_PBC
+ - PBC through software user interface
+ CSR_WIFI_WPS_CONFIG_PHYSICAL_PBC
+ - Physical PBC
+ CSR_WIFI_WPS_CONFIG_VIRTUAL_DISPLAY
+ - Virtual Display : via html config page etc
+ CSR_WIFI_WPS_CONFIG_PHYSICAL_DISPLAY
+ - Physical Display : Attached to the device
+
+*******************************************************************************/
+typedef u16 CsrWifiSmeWpsConfigType;
+#define CSR_WIFI_WPS_CONFIG_LABEL ((CsrWifiSmeWpsConfigType) 0x0004)
+#define CSR_WIFI_WPS_CONFIG_DISPLAY ((CsrWifiSmeWpsConfigType) 0x0008)
+#define CSR_WIFI_WPS_CONFIG_EXT_NFC ((CsrWifiSmeWpsConfigType) 0x0010)
+#define CSR_WIFI_WPS_CONFIG_INT_NFC ((CsrWifiSmeWpsConfigType) 0x0020)
+#define CSR_WIFI_WPS_CONFIG_NFC_IFACE ((CsrWifiSmeWpsConfigType) 0x0040)
+#define CSR_WIFI_WPS_CONFIG_PBC ((CsrWifiSmeWpsConfigType) 0x0080)
+#define CSR_WIFI_WPS_CONFIG_KEYPAD ((CsrWifiSmeWpsConfigType) 0x0100)
+#define CSR_WIFI_WPS_CONFIG_VIRTUAL_PBC ((CsrWifiSmeWpsConfigType) 0x0280)
+#define CSR_WIFI_WPS_CONFIG_PHYSICAL_PBC ((CsrWifiSmeWpsConfigType) 0x0480)
+#define CSR_WIFI_WPS_CONFIG_VIRTUAL_DISPLAY ((CsrWifiSmeWpsConfigType) 0x2008)
+#define CSR_WIFI_WPS_CONFIG_PHYSICAL_DISPLAY ((CsrWifiSmeWpsConfigType) 0x4008)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeWpsDeviceCategory
+
+ DESCRIPTION
+ Wps Primary Device Types
+
+ VALUES
+ CSR_WIFI_SME_WPS_CATEGORY_UNSPECIFIED
+ - Unspecified.
+ CSR_WIFI_SME_WPS_CATEGORY_COMPUTER
+ - Computer.
+ CSR_WIFI_SME_WPS_CATEGORY_INPUT_DEV
+ - Input device
+ CSR_WIFI_SME_WPS_CATEGORY_PRT_SCAN_FX_CP
+ - Printer Scanner Fax Copier etc
+ CSR_WIFI_SME_WPS_CATEGORY_CAMERA
+ - Camera
+ CSR_WIFI_SME_WPS_CATEGORY_STORAGE
+ - Storage
+ CSR_WIFI_SME_WPS_CATEGORY_NET_INFRA
+ - Net Infra
+ CSR_WIFI_SME_WPS_CATEGORY_DISPLAY
+ - Display
+ CSR_WIFI_SME_WPS_CATEGORY_MULTIMEDIA
+ - Multimedia
+ CSR_WIFI_SME_WPS_CATEGORY_GAMING
+ - Gaming.
+ CSR_WIFI_SME_WPS_CATEGORY_TELEPHONE
+ - Telephone.
+ CSR_WIFI_SME_WPS_CATEGORY_AUDIO
+ - Audio
+ CSR_WIFI_SME_WPS_CATEOARY_OTHERS
+ - Others.
+
+*******************************************************************************/
+typedef u8 CsrWifiSmeWpsDeviceCategory;
+#define CSR_WIFI_SME_WPS_CATEGORY_UNSPECIFIED ((CsrWifiSmeWpsDeviceCategory) 0x00)
+#define CSR_WIFI_SME_WPS_CATEGORY_COMPUTER ((CsrWifiSmeWpsDeviceCategory) 0x01)
+#define CSR_WIFI_SME_WPS_CATEGORY_INPUT_DEV ((CsrWifiSmeWpsDeviceCategory) 0x02)
+#define CSR_WIFI_SME_WPS_CATEGORY_PRT_SCAN_FX_CP ((CsrWifiSmeWpsDeviceCategory) 0x03)
+#define CSR_WIFI_SME_WPS_CATEGORY_CAMERA ((CsrWifiSmeWpsDeviceCategory) 0x04)
+#define CSR_WIFI_SME_WPS_CATEGORY_STORAGE ((CsrWifiSmeWpsDeviceCategory) 0x05)
+#define CSR_WIFI_SME_WPS_CATEGORY_NET_INFRA ((CsrWifiSmeWpsDeviceCategory) 0x06)
+#define CSR_WIFI_SME_WPS_CATEGORY_DISPLAY ((CsrWifiSmeWpsDeviceCategory) 0x07)
+#define CSR_WIFI_SME_WPS_CATEGORY_MULTIMEDIA ((CsrWifiSmeWpsDeviceCategory) 0x08)
+#define CSR_WIFI_SME_WPS_CATEGORY_GAMING ((CsrWifiSmeWpsDeviceCategory) 0x09)
+#define CSR_WIFI_SME_WPS_CATEGORY_TELEPHONE ((CsrWifiSmeWpsDeviceCategory) 0x0A)
+#define CSR_WIFI_SME_WPS_CATEGORY_AUDIO ((CsrWifiSmeWpsDeviceCategory) 0x0B)
+#define CSR_WIFI_SME_WPS_CATEOARY_OTHERS ((CsrWifiSmeWpsDeviceCategory) 0xFF)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeWpsDeviceSubCategory
+
+ DESCRIPTION
+ Wps Secondary Device Types
+
+ VALUES
+ CSR_WIFI_SME_WPS_SUB_CATEGORY_UNSPECIFIED
+ - Unspecied
+ CSR_WIFI_SME_WPS_STORAGE_SUB_CATEGORY_NAS
+ - Network Associated Storage
+ CSR_WIFI_SME_WPS_PSFC_SUB_CATEGORY_PRNTR
+ - Printer or print server
+ CSR_WIFI_SME_WPS_TELEPHONE_SUB_CATEGORY_WM
+ - Windows mobile
+ CSR_WIFI_SME_WPS_AUDIO_SUB_CATEGORY_TUNER
+ - Audio tuner/receiver
+ CSR_WIFI_SME_WPS_CAMERA_SUB_CATEGORY_DIG_STL
+ - Digital still camera
+ CSR_WIFI_SME_WPS_NET_INFRA_SUB_CATEGORY_AP
+ - Access Point
+ CSR_WIFI_SME_WPS_DISPLAY_SUB_CATEGORY_TV
+ - TV.
+ CSR_WIFI_SME_WPS_MM_SUB_CATEGORY_DAR
+ - DAR.
+ CSR_WIFI_SME_WPS_INPUT_DEV_SUB_CATEGORY_KEYBD
+ - Keyboard.
+ CSR_WIFI_SME_WPS_COMPUTER_SUB_CATEGORY_PC
+ - PC.
+ CSR_WIFI_SME_WPS_GAMING_SUB_CATEGORY_XBOX
+ - Xbox.
+ CSR_WIFI_SME_WPS_PSFC_SUB_CATEGORY_SCNR
+ - Scanner
+ CSR_WIFI_SME_WPS_COMPUTER_SUB_CATEGORY_SERVER
+ - Server
+ CSR_WIFI_SME_WPS_NET_INFRA_SUB_CATEGORY_ROUTER
+ - Router
+ CSR_WIFI_SME_WPS_MM_SUB_CATEGORY_PVR
+ - PVR
+ CSR_WIFI_SME_WPS_AUDIO_SUB_CATEGORY_SPEAKER
+ - Speaker
+ CSR_WIFI_SME_WPS_TELEPHONE_SUB_CATEGORY_FP_SM
+ - Feature phone - Single mode
+ CSR_WIFI_SME_WPS_CAMERA_SUB_CATEGORY_VIDEO
+ - Video camera
+ CSR_WIFI_SME_WPS_DISPLAY_SUB_CATEGORY_PIC_FRM
+ - Picture frame
+ CSR_WIFI_SME_WPS_GAMING_SUB_CATEGORY_XBOX_360
+ - Xbox360
+ CSR_WIFI_SME_WPS_INPUT_DEV_SUB_CATEGORY_MOUSE
+ - Mouse
+ CSR_WIFI_SME_WPS_NET_INFRA_SUB_CATEGORY_SWITCH
+ - Switch
+ CSR_WIFI_SME_WPS_AUDIO_SUB_CATEGORY_PMP
+ - Portable music player
+ CSR_WIFI_SME_WPS_INPUT_DEV_SUB_CATEGORY_JOYSTK
+ - Joy stick
+ CSR_WIFI_SME_WPS_GAMING_SUB_CATEGORY_PLAY_STN
+ - Play-station
+ CSR_WIFI_SME_WPS_COMPUTER_SUB_CATEGORY_MED_CENT
+ - Media Center
+ CSR_WIFI_SME_WPS_MM_SUB_CATEGORY_MCX
+ - MCX
+ CSR_WIFI_SME_WPS_TELEPHONE_SUB_CATEGORY_FP_DM
+ - Feature phone - Dual mode
+ CSR_WIFI_SME_WPS_CAMERA_SUB_CATEGORY_WEB
+ - Web camera
+ CSR_WIFI_SME_WPS_PSFC_SUB_CATEGORY_FAX
+ - Fax
+ CSR_WIFI_SME_WPS_DISPLAY_SUB_CATEGORY_PROJECTOR
+ - Projector
+ CSR_WIFI_SME_WPS_INPUT_DEV_SUB_CATEGORY_TRKBL
+ - Track Ball
+ CSR_WIFI_SME_WPS_MM_SUB_CATEGORY_ST_BOX
+ - Set-Top-Box
+ CSR_WIFI_SME_WPS_NET_INFRA_SUB_CATEGORY_GATEWAY
+ - GateWay.
+ CSR_WIFI_SME_WPS_CAMERA_SUB_CATEGORY_SECURITY
+ - Security camera
+ CSR_WIFI_SME_WPS_COMPUTER_SUB_CATEGORY_ULTRA_MOB_PC
+ - Ultra mobile PC.
+ CSR_WIFI_SME_WPS_GAMING_SUB_CATEGORY_CONSOLE
+ - Game console/Game console adapter
+ CSR_WIFI_SME_WPS_PSFC_SUB_CATEGORY_CPR
+ - Copier
+ CSR_WIFI_SME_WPS_AUDIO_SUB_CATEGORY_HEADSET
+ - Headset(headphones + microphone)
+ CSR_WIFI_SME_WPS_TELEPHONE_SUB_CATEGORY_SP_SM
+ - Smart phone - Single mode
+ CSR_WIFI_SME_WPS_DISPLAY_SUB_CATEGORY_MONITOR
+ - Monitor.
+ CSR_WIFI_SME_WPS_INPUT_DEV_SUB_CATEGORY_GAME_CTRL
+ - Game control.
+ CSR_WIFI_SME_WPS_PSFC_SUB_CATEGORY_ALL
+ - All-in-One
+ CSR_WIFI_SME_WPS_MM_SUB_CATEGORY_MEDIA
+ - Media Server/Media Adapter/Media Extender
+ CSR_WIFI_SME_WPS_TELEPHONE_SUB_CATEGORY_SP_DM
+ - Smart phone - Dual mode
+ CSR_WIFI_SME_WPS_GAMING_SUB_CATEGORY_PORT_DEV
+ - Portable gaming device
+ CSR_WIFI_SME_WPS_AUDIO_SUB_CATEGORY_HEADPHONE
+ - Headphone.
+ CSR_WIFI_SME_WPS_COMPUTER_SUB_CATEGORY_NOTEBOOK
+ - Notebook.
+ CSR_WIFI_SME_WPS_INPUT_DEV_SUB_CATEGORY_REMOTE
+ - Remote control
+ CSR_WIFI_SME_WPS_AUDIO_SUB_CATEGORY_MIC
+ - Microphone
+ CSR_WIFI_SME_WPS_COMPUTER_SUB_CATEGORY_DESKTOP
+ - Desktop.
+ CSR_WIFI_SME_WPS_MM_SUB_CATEGORY_VP
+ - Portable video player
+ CSR_WIFI_SME_WPS_COMPUTER_SUB_CATEGORY_MID
+ - Mobile internet device
+ CSR_WIFI_SME_WPS_INPUT_DEV_SUB_CATEGORY_TOUCH_SCRN
+ - Touch screen
+ CSR_WIFI_SME_WPS_INPUT_DEV_SUB_CATEGORY_BIOMET_RDR
+ - Biometric reader
+ CSR_WIFI_SME_WPS_COMPUTER_SUB_CATEGORY_NETBOOK
+ - Netbook
+ CSR_WIFI_SME_WPS_INPUT_DEV_SUB_CATEGORY_BRCD_RDR
+ - Bar code reader.
+
+*******************************************************************************/
+typedef u8 CsrWifiSmeWpsDeviceSubCategory;
+#define CSR_WIFI_SME_WPS_SUB_CATEGORY_UNSPECIFIED ((CsrWifiSmeWpsDeviceSubCategory) 0x00)
+#define CSR_WIFI_SME_WPS_STORAGE_SUB_CATEGORY_NAS ((CsrWifiSmeWpsDeviceSubCategory) 0x01)
+#define CSR_WIFI_SME_WPS_PSFC_SUB_CATEGORY_PRNTR ((CsrWifiSmeWpsDeviceSubCategory) 0x01)
+#define CSR_WIFI_SME_WPS_TELEPHONE_SUB_CATEGORY_WM ((CsrWifiSmeWpsDeviceSubCategory) 0x01)
+#define CSR_WIFI_SME_WPS_AUDIO_SUB_CATEGORY_TUNER ((CsrWifiSmeWpsDeviceSubCategory) 0x01)
+#define CSR_WIFI_SME_WPS_CAMERA_SUB_CATEGORY_DIG_STL ((CsrWifiSmeWpsDeviceSubCategory) 0x01)
+#define CSR_WIFI_SME_WPS_NET_INFRA_SUB_CATEGORY_AP ((CsrWifiSmeWpsDeviceSubCategory) 0x01)
+#define CSR_WIFI_SME_WPS_DISPLAY_SUB_CATEGORY_TV ((CsrWifiSmeWpsDeviceSubCategory) 0x01)
+#define CSR_WIFI_SME_WPS_MM_SUB_CATEGORY_DAR ((CsrWifiSmeWpsDeviceSubCategory) 0x01)
+#define CSR_WIFI_SME_WPS_INPUT_DEV_SUB_CATEGORY_KEYBD ((CsrWifiSmeWpsDeviceSubCategory) 0x01)
+#define CSR_WIFI_SME_WPS_COMPUTER_SUB_CATEGORY_PC ((CsrWifiSmeWpsDeviceSubCategory) 0x01)
+#define CSR_WIFI_SME_WPS_GAMING_SUB_CATEGORY_XBOX ((CsrWifiSmeWpsDeviceSubCategory) 0x01)
+#define CSR_WIFI_SME_WPS_PSFC_SUB_CATEGORY_SCNR ((CsrWifiSmeWpsDeviceSubCategory) 0x02)
+#define CSR_WIFI_SME_WPS_COMPUTER_SUB_CATEGORY_SERVER ((CsrWifiSmeWpsDeviceSubCategory) 0x02)
+#define CSR_WIFI_SME_WPS_NET_INFRA_SUB_CATEGORY_ROUTER ((CsrWifiSmeWpsDeviceSubCategory) 0x02)
+#define CSR_WIFI_SME_WPS_MM_SUB_CATEGORY_PVR ((CsrWifiSmeWpsDeviceSubCategory) 0x02)
+#define CSR_WIFI_SME_WPS_AUDIO_SUB_CATEGORY_SPEAKER ((CsrWifiSmeWpsDeviceSubCategory) 0x02)
+#define CSR_WIFI_SME_WPS_TELEPHONE_SUB_CATEGORY_FP_SM ((CsrWifiSmeWpsDeviceSubCategory) 0x02)
+#define CSR_WIFI_SME_WPS_CAMERA_SUB_CATEGORY_VIDEO ((CsrWifiSmeWpsDeviceSubCategory) 0x02)
+#define CSR_WIFI_SME_WPS_DISPLAY_SUB_CATEGORY_PIC_FRM ((CsrWifiSmeWpsDeviceSubCategory) 0x02)
+#define CSR_WIFI_SME_WPS_GAMING_SUB_CATEGORY_XBOX_360 ((CsrWifiSmeWpsDeviceSubCategory) 0x02)
+#define CSR_WIFI_SME_WPS_INPUT_DEV_SUB_CATEGORY_MOUSE ((CsrWifiSmeWpsDeviceSubCategory) 0x02)
+#define CSR_WIFI_SME_WPS_NET_INFRA_SUB_CATEGORY_SWITCH ((CsrWifiSmeWpsDeviceSubCategory) 0x03)
+#define CSR_WIFI_SME_WPS_AUDIO_SUB_CATEGORY_PMP ((CsrWifiSmeWpsDeviceSubCategory) 0x03)
+#define CSR_WIFI_SME_WPS_INPUT_DEV_SUB_CATEGORY_JOYSTK ((CsrWifiSmeWpsDeviceSubCategory) 0x03)
+#define CSR_WIFI_SME_WPS_GAMING_SUB_CATEGORY_PLAY_STN ((CsrWifiSmeWpsDeviceSubCategory) 0x03)
+#define CSR_WIFI_SME_WPS_COMPUTER_SUB_CATEGORY_MED_CENT ((CsrWifiSmeWpsDeviceSubCategory) 0x03)
+#define CSR_WIFI_SME_WPS_MM_SUB_CATEGORY_MCX ((CsrWifiSmeWpsDeviceSubCategory) 0x03)
+#define CSR_WIFI_SME_WPS_TELEPHONE_SUB_CATEGORY_FP_DM ((CsrWifiSmeWpsDeviceSubCategory) 0x03)
+#define CSR_WIFI_SME_WPS_CAMERA_SUB_CATEGORY_WEB ((CsrWifiSmeWpsDeviceSubCategory) 0x03)
+#define CSR_WIFI_SME_WPS_PSFC_SUB_CATEGORY_FAX ((CsrWifiSmeWpsDeviceSubCategory) 0x03)
+#define CSR_WIFI_SME_WPS_DISPLAY_SUB_CATEGORY_PROJECTOR ((CsrWifiSmeWpsDeviceSubCategory) 0x03)
+#define CSR_WIFI_SME_WPS_INPUT_DEV_SUB_CATEGORY_TRKBL ((CsrWifiSmeWpsDeviceSubCategory) 0x04)
+#define CSR_WIFI_SME_WPS_MM_SUB_CATEGORY_ST_BOX ((CsrWifiSmeWpsDeviceSubCategory) 0x04)
+#define CSR_WIFI_SME_WPS_NET_INFRA_SUB_CATEGORY_GATEWAY ((CsrWifiSmeWpsDeviceSubCategory) 0x04)
+#define CSR_WIFI_SME_WPS_CAMERA_SUB_CATEGORY_SECURITY ((CsrWifiSmeWpsDeviceSubCategory) 0x04)
+#define CSR_WIFI_SME_WPS_COMPUTER_SUB_CATEGORY_ULTRA_MOB_PC ((CsrWifiSmeWpsDeviceSubCategory) 0x04)
+#define CSR_WIFI_SME_WPS_GAMING_SUB_CATEGORY_CONSOLE ((CsrWifiSmeWpsDeviceSubCategory) 0x04)
+#define CSR_WIFI_SME_WPS_PSFC_SUB_CATEGORY_CPR ((CsrWifiSmeWpsDeviceSubCategory) 0x04)
+#define CSR_WIFI_SME_WPS_AUDIO_SUB_CATEGORY_HEADSET ((CsrWifiSmeWpsDeviceSubCategory) 0x04)
+#define CSR_WIFI_SME_WPS_TELEPHONE_SUB_CATEGORY_SP_SM ((CsrWifiSmeWpsDeviceSubCategory) 0x04)
+#define CSR_WIFI_SME_WPS_DISPLAY_SUB_CATEGORY_MONITOR ((CsrWifiSmeWpsDeviceSubCategory) 0x04)
+#define CSR_WIFI_SME_WPS_INPUT_DEV_SUB_CATEGORY_GAME_CTRL ((CsrWifiSmeWpsDeviceSubCategory) 0x05)
+#define CSR_WIFI_SME_WPS_PSFC_SUB_CATEGORY_ALL ((CsrWifiSmeWpsDeviceSubCategory) 0x05)
+#define CSR_WIFI_SME_WPS_MM_SUB_CATEGORY_MEDIA ((CsrWifiSmeWpsDeviceSubCategory) 0x05)
+#define CSR_WIFI_SME_WPS_TELEPHONE_SUB_CATEGORY_SP_DM ((CsrWifiSmeWpsDeviceSubCategory) 0x05)
+#define CSR_WIFI_SME_WPS_GAMING_SUB_CATEGORY_PORT_DEV ((CsrWifiSmeWpsDeviceSubCategory) 0x05)
+#define CSR_WIFI_SME_WPS_AUDIO_SUB_CATEGORY_HEADPHONE ((CsrWifiSmeWpsDeviceSubCategory) 0x05)
+#define CSR_WIFI_SME_WPS_COMPUTER_SUB_CATEGORY_NOTEBOOK ((CsrWifiSmeWpsDeviceSubCategory) 0x05)
+#define CSR_WIFI_SME_WPS_INPUT_DEV_SUB_CATEGORY_REMOTE ((CsrWifiSmeWpsDeviceSubCategory) 0x06)
+#define CSR_WIFI_SME_WPS_AUDIO_SUB_CATEGORY_MIC ((CsrWifiSmeWpsDeviceSubCategory) 0x06)
+#define CSR_WIFI_SME_WPS_COMPUTER_SUB_CATEGORY_DESKTOP ((CsrWifiSmeWpsDeviceSubCategory) 0x06)
+#define CSR_WIFI_SME_WPS_MM_SUB_CATEGORY_VP ((CsrWifiSmeWpsDeviceSubCategory) 0x06)
+#define CSR_WIFI_SME_WPS_COMPUTER_SUB_CATEGORY_MID ((CsrWifiSmeWpsDeviceSubCategory) 0x07)
+#define CSR_WIFI_SME_WPS_INPUT_DEV_SUB_CATEGORY_TOUCH_SCRN ((CsrWifiSmeWpsDeviceSubCategory) 0x07)
+#define CSR_WIFI_SME_WPS_INPUT_DEV_SUB_CATEGORY_BIOMET_RDR ((CsrWifiSmeWpsDeviceSubCategory) 0x08)
+#define CSR_WIFI_SME_WPS_COMPUTER_SUB_CATEGORY_NETBOOK ((CsrWifiSmeWpsDeviceSubCategory) 0x08)
+#define CSR_WIFI_SME_WPS_INPUT_DEV_SUB_CATEGORY_BRCD_RDR ((CsrWifiSmeWpsDeviceSubCategory) 0x09)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeWpsDpid
+
+ DESCRIPTION
+ Device Password ID for the chosen config method
+
+ VALUES
+ CSR_WIFI_SME_WPS_DPID_PIN - PIN
+ CSR_WIFI_SME_WPS_DPID_USER - User specified : Used only during P2P GO
+ negotiation procedure
+ CSR_WIFI_SME_WPS_DPID_MACHINE - Machine specified i: Not used in this
+ release
+ CSR_WIFI_SME_WPS_DPID_REKEY - Rekey : Not used in this release
+ CSR_WIFI_SME_WPS_DPID_PBC - PBC
+ CSR_WIFI_SME_WPS_DPID_REGISTRAR - Registrar specified : Used only in P2P Go
+ negotiation procedure
+
+*******************************************************************************/
+typedef u16 CsrWifiSmeWpsDpid;
+#define CSR_WIFI_SME_WPS_DPID_PIN ((CsrWifiSmeWpsDpid) 0x0000)
+#define CSR_WIFI_SME_WPS_DPID_USER ((CsrWifiSmeWpsDpid) 0x0001)
+#define CSR_WIFI_SME_WPS_DPID_MACHINE ((CsrWifiSmeWpsDpid) 0x0002)
+#define CSR_WIFI_SME_WPS_DPID_REKEY ((CsrWifiSmeWpsDpid) 0x0003)
+#define CSR_WIFI_SME_WPS_DPID_PBC ((CsrWifiSmeWpsDpid) 0x0004)
+#define CSR_WIFI_SME_WPS_DPID_REGISTRAR ((CsrWifiSmeWpsDpid) 0x0005)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeWpsRegistration
+
+ DESCRIPTION
+
+ VALUES
+ CSR_WIFI_SME_WPS_REG_NOT_REQUIRED - No encryption set
+ CSR_WIFI_SME_WPS_REG_REQUIRED - No encryption set
+ CSR_WIFI_SME_WPS_REG_UNKNOWN - No encryption set
+
+*******************************************************************************/
+typedef u8 CsrWifiSmeWpsRegistration;
+#define CSR_WIFI_SME_WPS_REG_NOT_REQUIRED ((CsrWifiSmeWpsRegistration) 0x00)
+#define CSR_WIFI_SME_WPS_REG_REQUIRED ((CsrWifiSmeWpsRegistration) 0x01)
+#define CSR_WIFI_SME_WPS_REG_UNKNOWN ((CsrWifiSmeWpsRegistration) 0x02)
+
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeAuthModeMask
+
+ DESCRIPTION
+ Mask type for use with the values defined by CsrWifiSmeAuthMode
+
+*******************************************************************************/
+typedef u16 CsrWifiSmeAuthModeMask;
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeEncryptionMask
+
+ DESCRIPTION
+ Mask type for use with the values defined by CsrWifiSmeEncryption
+
+*******************************************************************************/
+typedef u16 CsrWifiSmeEncryptionMask;
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeIndicationsMask
+
+ DESCRIPTION
+ Mask type for use with the values defined by CsrWifiSmeIndications
+
+*******************************************************************************/
+typedef u32 CsrWifiSmeIndicationsMask;
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeP2pCapabilityMask
+
+ DESCRIPTION
+ Mask type for use with the values defined by CsrWifiSmeP2pCapability
+
+*******************************************************************************/
+typedef u8 CsrWifiSmeP2pCapabilityMask;
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeP2pGroupCapabilityMask
+
+ DESCRIPTION
+ Mask type for use with the values defined by CsrWifiSmeP2pGroupCapability
+
+*******************************************************************************/
+typedef u8 CsrWifiSmeP2pGroupCapabilityMask;
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeTspecCtrlMask
+
+ DESCRIPTION
+ Mask type for use with the values defined by CsrWifiSmeTspecCtrl
+
+*******************************************************************************/
+typedef u8 CsrWifiSmeTspecCtrlMask;
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeWmmModeMask
+
+ DESCRIPTION
+ Mask type for use with the values defined by CsrWifiSmeWmmMode
+
+*******************************************************************************/
+typedef u8 CsrWifiSmeWmmModeMask;
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeWmmQosInfoMask
+
+ DESCRIPTION
+ Mask type for use with the values defined by CsrWifiSmeWmmQosInfo
+
+*******************************************************************************/
+typedef u8 CsrWifiSmeWmmQosInfoMask;
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeWpsConfigTypeMask
+
+ DESCRIPTION
+ Mask type for use with the values defined by CsrWifiSmeWpsConfigType
+
+*******************************************************************************/
+typedef u16 CsrWifiSmeWpsConfigTypeMask;
+
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeAdHocConfig
+
+ DESCRIPTION
+ Defines values to use when starting an Ad-hoc (IBSS) network.
+
+ MEMBERS
+ atimWindowTu - ATIM window specified for IBSS
+ beaconPeriodTu - Interval between beacon packets
+ joinOnlyAttempts - Maximum number of attempts to join an ad-hoc network.
+ The default value is 1.
+ Set to 0 for infinite attempts.
+ joinAttemptIntervalMs - Time between scans for joining the requested IBSS.
+
+*******************************************************************************/
+typedef struct
+{
+ u16 atimWindowTu;
+ u16 beaconPeriodTu;
+ u16 joinOnlyAttempts;
+ u16 joinAttemptIntervalMs;
+} CsrWifiSmeAdHocConfig;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeAvailabilityConfig
+
+ DESCRIPTION
+
+ MEMBERS
+ listenChannel -
+ availabilityDuration -
+ avalabilityPeriod -
+
+*******************************************************************************/
+typedef struct
+{
+ u8 listenChannel;
+ u16 availabilityDuration;
+ u16 avalabilityPeriod;
+} CsrWifiSmeAvailabilityConfig;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeCcxConfig
+
+ DESCRIPTION
+ This type is reserved for future use and should not be used.
+
+ MEMBERS
+ keepAliveTimeMs - NOT USED
+ apRoamingEnabled - NOT USED
+ measurementsMask - NOT USED
+ ccxRadioMgtEnabled - NOT USED
+
+*******************************************************************************/
+typedef struct
+{
+ u8 keepAliveTimeMs;
+ u8 apRoamingEnabled;
+ u8 measurementsMask;
+ u8 ccxRadioMgtEnabled;
+} CsrWifiSmeCcxConfig;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeCoexConfig
+
+ DESCRIPTION
+ Parameters for the coexistence behaviour.
+
+ MEMBERS
+ coexEnableSchemeManagement - Enables the Coexistence Management Scheme
+ coexPeriodicWakeHost - If TRUE the firmware wakes up the host
+ periodically according to the traffic
+ period and latency parameters; the host
+ will then send the data to transmit only
+ when woken up.
+ If FALSE, the firmware does not wake up the
+ host and the host will send the data to
+ transmit to the firmware whenever there is
+ data to transmit
+ coexTrafficBurstyLatencyMs - Period of awakening for the firmware used
+ when bursty traffic is detected
+ coexTrafficContinuousLatencyMs - Period of awakening for the firmware used
+ when continuous traffic is detected
+ coexObexBlackoutDurationMs - Blackout Duration when a Obex Connection is
+ used
+ coexObexBlackoutPeriodMs - Blackout Period when a Obex Connection is
+ used
+ coexA2dpBrBlackoutDurationMs - Blackout Duration when a Basic Rate A2DP
+ Connection streaming data
+ coexA2dpBrBlackoutPeriodMs - Blackout Period when a Basic Rate A2DP
+ Connection streaming data
+ coexA2dpEdrBlackoutDurationMs - Blackout Duration when an Enhanced Data
+ Rate A2DP Connection streaming data
+ coexA2dpEdrBlackoutPeriodMs - Blackout Period when an Enhanced Data Rate
+ A2DP Connection streaming data
+ coexPagingBlackoutDurationMs - Blackout Duration when a BT page is active
+ coexPagingBlackoutPeriodMs - Blackout Period when a BT page is active
+ coexInquiryBlackoutDurationMs - Blackout Duration when a BT inquiry is
+ active
+ coexInquiryBlackoutPeriodMs - Blackout Period when a BT inquiry is active
+
+*******************************************************************************/
+typedef struct
+{
+ u8 coexEnableSchemeManagement;
+ u8 coexPeriodicWakeHost;
+ u16 coexTrafficBurstyLatencyMs;
+ u16 coexTrafficContinuousLatencyMs;
+ u16 coexObexBlackoutDurationMs;
+ u16 coexObexBlackoutPeriodMs;
+ u16 coexA2dpBrBlackoutDurationMs;
+ u16 coexA2dpBrBlackoutPeriodMs;
+ u16 coexA2dpEdrBlackoutDurationMs;
+ u16 coexA2dpEdrBlackoutPeriodMs;
+ u16 coexPagingBlackoutDurationMs;
+ u16 coexPagingBlackoutPeriodMs;
+ u16 coexInquiryBlackoutDurationMs;
+ u16 coexInquiryBlackoutPeriodMs;
+} CsrWifiSmeCoexConfig;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeConnectionStats
+
+ DESCRIPTION
+ Indicates the statistics of the connection.
+ The dot11 fields are defined in the Annex D of the IEEE 802.11 standard.
+
+ MEMBERS
+ unifiTxDataRate
+ - The bit rate currently in use for transmissions of unicast
+ data frames; a data rate in units of 500kbit/s.
+ On an infrastructure BSS, this is the data rate used in
+ communicating with the associated access point; if there is
+ none, an error is returned.
+ On an IBSS, this is the data rate used for the last
+ transmission of a unicast data frame to any station in the
+ IBSS. If no such transmission has been made, an error is
+ returned.
+ unifiRxDataRate
+ - As above for receiving data
+ dot11RetryCount
+ - See IEEE 802.11 Standard
+ dot11MultipleRetryCount
+ - See IEEE 802.11 Standard
+ dot11AckFailureCount
+ - See IEEE 802.11 Standard
+ dot11FrameDuplicateCount
+ - See IEEE 802.11 Standard
+ dot11FcsErrorCount
+ - See IEEE 802.11 Standard
+ dot11RtsSuccessCount
+ - See IEEE 802.11 Standard
+ dot11RtsFailureCount
+ - See IEEE 802.11 Standard
+ dot11FailedCount
+ - See IEEE 802.11 Standard
+ dot11TransmittedFragmentCount
+ - See IEEE 802.11 Standard
+ dot11TransmittedFrameCount
+ - See IEEE 802.11 Standard
+ dot11WepExcludedCount
+ - See IEEE 802.11 Standard
+ dot11WepIcvErrorCount
+ - See IEEE 802.11 Standard
+ dot11WepUndecryptableCount
+ - See IEEE 802.11 Standard
+ dot11MulticastReceivedFrameCount
+ - See IEEE 802.11 Standard
+ dot11MulticastTransmittedFrameCount
+ - See IEEE 802.11 Standard
+ dot11ReceivedFragmentCount
+ - See IEEE 802.11 Standard
+ dot11Rsna4WayHandshakeFailures
+ - See IEEE 802.11 Standard
+ dot11RsnaTkipCounterMeasuresInvoked
+ - See IEEE 802.11 Standard
+ dot11RsnaStatsTkipLocalMicFailures
+ - See IEEE 802.11 Standard
+ dot11RsnaStatsTkipReplays
+ - See IEEE 802.11 Standard
+ dot11RsnaStatsTkipIcvErrors
+ - See IEEE 802.11 Standard
+ dot11RsnaStatsCcmpReplays
+ - See IEEE 802.11 Standard
+ dot11RsnaStatsCcmpDecryptErrors
+ - See IEEE 802.11 Standard
+
+*******************************************************************************/
+typedef struct
+{
+ u8 unifiTxDataRate;
+ u8 unifiRxDataRate;
+ u32 dot11RetryCount;
+ u32 dot11MultipleRetryCount;
+ u32 dot11AckFailureCount;
+ u32 dot11FrameDuplicateCount;
+ u32 dot11FcsErrorCount;
+ u32 dot11RtsSuccessCount;
+ u32 dot11RtsFailureCount;
+ u32 dot11FailedCount;
+ u32 dot11TransmittedFragmentCount;
+ u32 dot11TransmittedFrameCount;
+ u32 dot11WepExcludedCount;
+ u32 dot11WepIcvErrorCount;
+ u32 dot11WepUndecryptableCount;
+ u32 dot11MulticastReceivedFrameCount;
+ u32 dot11MulticastTransmittedFrameCount;
+ u32 dot11ReceivedFragmentCount;
+ u32 dot11Rsna4WayHandshakeFailures;
+ u32 dot11RsnaTkipCounterMeasuresInvoked;
+ u32 dot11RsnaStatsTkipLocalMicFailures;
+ u32 dot11RsnaStatsTkipReplays;
+ u32 dot11RsnaStatsTkipIcvErrors;
+ u32 dot11RsnaStatsCcmpReplays;
+ u32 dot11RsnaStatsCcmpDecryptErrors;
+} CsrWifiSmeConnectionStats;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeDataBlock
+
+ DESCRIPTION
+ Holds a generic data block to be passed through the interface
+
+ MEMBERS
+ length - Length of the data block
+ data - Points to the first byte of the data block
+
+*******************************************************************************/
+typedef struct
+{
+ u16 length;
+ u8 *data;
+} CsrWifiSmeDataBlock;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeEmpty
+
+ DESCRIPTION
+ Empty Structure to indicate that no parameters are available.
+
+ MEMBERS
+ empty - Only element of the empty structure (always set to 0).
+
+*******************************************************************************/
+typedef struct
+{
+ u8 empty;
+} CsrWifiSmeEmpty;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeLinkQuality
+
+ DESCRIPTION
+ Indicates the quality of the link
+
+ MEMBERS
+ unifiRssi - Indicates the received signal strength indication of the link in
+ dBm
+ unifiSnr - Indicates the signal to noise ratio of the link in dB
+
+*******************************************************************************/
+typedef struct
+{
+ s16 unifiRssi;
+ s16 unifiSnr;
+} CsrWifiSmeLinkQuality;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeMibConfig
+
+ DESCRIPTION
+ Allows low level configuration in the chip.
+
+ MEMBERS
+ unifiFixMaxTxDataRate - This attribute is used in combination with
+ unifiFixTxDataRate. If it is FALSE, then
+ unifiFixTxDataRate specifies a specific data
+ rate to use. If it is TRUE, unifiFixTxDataRate
+ instead specifies a maximum data rate.
+ unifiFixTxDataRate - Transmit rate for unicast data.
+ See MIB description for more details
+ dot11RtsThreshold - See IEEE 802.11 Standard
+ dot11FragmentationThreshold - See IEEE 802.11 Standard
+ dot11CurrentTxPowerLevel - See IEEE 802.11 Standard
+
+*******************************************************************************/
+typedef struct
+{
+ u8 unifiFixMaxTxDataRate;
+ u8 unifiFixTxDataRate;
+ u16 dot11RtsThreshold;
+ u16 dot11FragmentationThreshold;
+ u16 dot11CurrentTxPowerLevel;
+} CsrWifiSmeMibConfig;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeP2pProfileIdentity
+
+ DESCRIPTION
+ Details to be filled in
+
+ MEMBERS
+ listenChannel -
+ availabilityDuration -
+ avalabilityPeriod -
+
+*******************************************************************************/
+typedef struct
+{
+ u8 listenChannel;
+ u16 availabilityDuration;
+ u16 avalabilityPeriod;
+} CsrWifiSmeP2pProfileIdentity;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmePmkid
+
+ DESCRIPTION
+ Defines a PMKID association with BSS
+
+ MEMBERS
+ bssid - BSS identifier
+ pmkid - PMKID
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiMacAddress bssid;
+ u8 pmkid[16];
+} CsrWifiSmePmkid;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmePmkidCandidate
+
+ DESCRIPTION
+ Information for a PMKID candidate
+
+ MEMBERS
+ bssid - BSS identifier
+ preAuthAllowed - Indicates whether preauthentication is allowed
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiMacAddress bssid;
+ u8 preAuthAllowed;
+} CsrWifiSmePmkidCandidate;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmePmkidList
+
+ DESCRIPTION
+ NOT USED
+ Used in the Sync access API
+
+ MEMBERS
+ pmkidsCount - Number of PMKIDs in the list
+ pmkids - Points to the first PMKID in the list
+
+*******************************************************************************/
+typedef struct
+{
+ u8 pmkidsCount;
+ CsrWifiSmePmkid *pmkids;
+} CsrWifiSmePmkidList;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeRegulatoryDomainInfo
+
+ DESCRIPTION
+ Regulatory domain options.
+
+ MEMBERS
+ dot11MultiDomainCapabilityImplemented
+ - TRUE is the multi domain capability is implemented
+ dot11MultiDomainCapabilityEnabled
+ - TRUE is the multi domain capability is enabled
+ currentRegulatoryDomain
+ - Current regulatory domain
+ currentCountryCode
+ - Current country code as defined by the IEEE 802.11
+ standards
+
+*******************************************************************************/
+typedef struct
+{
+ u8 dot11MultiDomainCapabilityImplemented;
+ u8 dot11MultiDomainCapabilityEnabled;
+ CsrWifiSmeRegulatoryDomain currentRegulatoryDomain;
+ u8 currentCountryCode[2];
+} CsrWifiSmeRegulatoryDomainInfo;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeRoamingBandData
+
+ DESCRIPTION
+ Thresholds to define one usability level category for the received signal
+
+ MEMBERS
+ rssiHighThreshold - Received Signal Strength Indication upper bound in dBm
+ for the usability level
+ rssiLowThreshold - Received Signal Strength Indication lower bound in dBm
+ for the usability level
+ snrHighThreshold - Signal to Noise Ratio upper bound in dB for the
+ usability level
+ snrLowThreshold - Signal to Noise Ratio lower bound in dB for the
+ usability level
+
+*******************************************************************************/
+typedef struct
+{
+ s16 rssiHighThreshold;
+ s16 rssiLowThreshold;
+ s16 snrHighThreshold;
+ s16 snrLowThreshold;
+} CsrWifiSmeRoamingBandData;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeScanConfigData
+
+ DESCRIPTION
+ Configures the scanning behaviour of the driver and firmware
+
+ MEMBERS
+ intervalSeconds - All the channels will be scanned once in this time
+ interval.
+ If connected, the channel scans are spread across
+ the interval.
+ If disconnected, all the channels will be scanned
+ together
+ validitySeconds - How long the scan result are cached
+ minActiveChannelTimeTu - Minimum time of listening on a channel being
+ actively scanned before leaving if no probe
+ responses or beacon frames have been received
+ maxActiveChannelTimeTu - Maximum time of listening on a channel being
+ actively scanned
+ minPassiveChannelTimeTu - Minimum time of listening on a channel being
+ passive scanned before leaving if no beacon frames
+ have been received
+ maxPassiveChannelTimeTu - Maximum time of listening on a channel being
+ passively scanned
+
+*******************************************************************************/
+typedef struct
+{
+ u16 intervalSeconds;
+ u16 validitySeconds;
+ u16 minActiveChannelTimeTu;
+ u16 maxActiveChannelTimeTu;
+ u16 minPassiveChannelTimeTu;
+ u16 maxPassiveChannelTimeTu;
+} CsrWifiSmeScanConfigData;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeTsfTime
+
+ DESCRIPTION
+ Time stamp representation
+
+ MEMBERS
+ data - TSF Bytes
+
+*******************************************************************************/
+typedef struct
+{
+ u8 data[8];
+} CsrWifiSmeTsfTime;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeVersions
+
+ DESCRIPTION
+ Reports version information for the chip, the firmware and the driver and
+ the SME.
+
+ MEMBERS
+ chipId - Chip ID
+ chipVersion - Chip version ID
+ firmwareBuild - Firmware Rom build number
+ firmwarePatch - Firmware Patch build number (if applicable)
+ firmwareHip - Firmware HIP protocol version number
+ routerBuild - Router build number
+ routerHip - Router HIP protocol version number
+ smeBuild - SME build number
+ smeHip - SME HIP protocol version number
+
+*******************************************************************************/
+typedef struct
+{
+ u32 chipId;
+ u32 chipVersion;
+ u32 firmwareBuild;
+ u32 firmwarePatch;
+ u32 firmwareHip;
+ char *routerBuild;
+ u32 routerHip;
+ char *smeBuild;
+ u32 smeHip;
+} CsrWifiSmeVersions;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeWmmAcParams
+
+ DESCRIPTION
+ Structure holding WMM AC params data.
+
+ MEMBERS
+ cwMin - Exponent for the calculation of CWmin. Range: 0
+ to 15
+ cwMax - Exponent for the calculation of CWmax. Range: 0
+ to15
+ aifs - Arbitration Inter Frame Spacing in terms of
+ number of timeslots. Range 2 to 15
+ txopLimit - TXOP Limit in the units of 32 microseconds
+ admissionControlMandatory - Indicates whether the admission control is
+ mandatory or not. Current release does not
+ support admission control , hence shall be set
+ to FALSE.
+
+*******************************************************************************/
+typedef struct
+{
+ u8 cwMin;
+ u8 cwMax;
+ u8 aifs;
+ u16 txopLimit;
+ u8 admissionControlMandatory;
+} CsrWifiSmeWmmAcParams;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeWpsDeviceType
+
+ DESCRIPTION
+ Structure holding AP WPS device type data.
+
+ MEMBERS
+ deviceDetails - category , sub category etc
+
+*******************************************************************************/
+typedef struct
+{
+ u8 deviceDetails[8];
+} CsrWifiSmeWpsDeviceType;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeWpsDeviceTypeCommon
+
+ DESCRIPTION
+
+ MEMBERS
+ spportWps -
+ deviceType -
+
+*******************************************************************************/
+typedef struct
+{
+ u8 spportWps;
+ u8 deviceType;
+} CsrWifiSmeWpsDeviceTypeCommon;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeWpsInfo
+
+ DESCRIPTION
+
+ MEMBERS
+ version -
+ configMethods -
+ devicePassworId -
+
+*******************************************************************************/
+typedef struct
+{
+ u16 version;
+ u16 configMethods;
+ u16 devicePassworId;
+} CsrWifiSmeWpsInfo;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeCloakedSsidConfig
+
+ DESCRIPTION
+ List of cloaked SSIDs .
+
+ MEMBERS
+ cloakedSsidsCount - Number of cloaked SSID
+ cloakedSsids - Points to the first byte of the first SSID provided
+
+*******************************************************************************/
+typedef struct
+{
+ u8 cloakedSsidsCount;
+ CsrWifiSsid *cloakedSsids;
+} CsrWifiSmeCloakedSsidConfig;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeCoexInfo
+
+ DESCRIPTION
+ Information and state related to coexistence.
+
+ MEMBERS
+ hasTrafficData - TRUE if any Wi-Fi traffic is detected
+ currentTrafficType - Current type of traffic
+ currentPeriodMs - Period of the traffic as detected by the traffic
+ analysis.
+ If the traffic is not periodic, it is set to 0.
+ currentPowerSave - Current power save level
+ currentCoexPeriodMs - Period of awakening for the firmware used when
+ periodic traffic is detected.
+ If the traffic is not periodic, it is set to 0.
+ currentCoexLatencyMs - Period of awakening for the firmware used when
+ non-periodic traffic is detected
+ hasBtDevice - TRUE if there is a Bluetooth device connected
+ currentBlackoutDurationUs - Current blackout duration for protecting
+ Bluetooth
+ currentBlackoutPeriodUs - Current blackout period
+ currentCoexScheme - Defines the scheme for the coexistence
+ signalling
+
+*******************************************************************************/
+typedef struct
+{
+ u8 hasTrafficData;
+ CsrWifiSmeTrafficType currentTrafficType;
+ u16 currentPeriodMs;
+ CsrWifiSmePowerSaveLevel currentPowerSave;
+ u16 currentCoexPeriodMs;
+ u16 currentCoexLatencyMs;
+ u8 hasBtDevice;
+ u32 currentBlackoutDurationUs;
+ u32 currentBlackoutPeriodUs;
+ CsrWifiSmeCoexScheme currentCoexScheme;
+} CsrWifiSmeCoexInfo;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeConnectionConfig
+
+ DESCRIPTION
+ Specifies the parameters that the SME should use in selecting a network.
+
+ MEMBERS
+ ssid
+ - Service Set identifier
+ bssid
+ - BSS identifier
+ bssType
+ - Indicates the type of BSS
+ ifIndex
+ - Indicates the radio interface
+ privacyMode
+ - Specifies whether the privacy mode is enabled or disabled.
+ authModeMask
+ - Sets the authentication options that the SME can use while
+ associating to the AP
+ Set mask with values from CsrWifiSmeAuthMode
+ encryptionModeMask
+ - Sets the encryption options that the SME can use while
+ associating to the AP
+ Set mask with values from CsrWifiSmeEncryption
+ mlmeAssociateReqInformationElementsLength
+ - Length in bytes of information elements to be sent in the
+ Association Request.
+ mlmeAssociateReqInformationElements
+ - Points to the first byte of the information elements, if
+ any.
+ wmmQosInfo
+ - This parameter allows the driver's WMM behaviour to be
+ configured.
+ To enable support for WMM, use
+ CSR_WIFI_SME_SME_CONFIG_SET_REQ with the
+ CSR_WIFI_SME_WMM_MODE_AC_ENABLED bit set in wmmModeMask
+ field in smeConfig parameter.
+ Set mask with values from CsrWifiSmeWmmQosInfo
+ adhocJoinOnly
+ - This parameter is relevant only if bssType is NOT set to
+ CSR_WIFI_SME_BSS_TYPE_INFRASTRUCTURE:
+ if TRUE the SME will only try to join an ad-hoc network if
+ there is one already established;
+ if FALSE the SME will try to join an ad-hoc network if
+ there is one already established or it will try to
+ establish a new one
+ adhocChannel
+ - This parameter is relevant only if bssType is NOT set to
+ CSR_WIFI_SME_BSS_TYPE_INFRASTRUCTURE:
+ it indicates the channel to use joining an ad hoc network.
+ Setting this to 0 causes the SME to select a channel from
+ those permitted in the regulatory domain.
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiSsid ssid;
+ CsrWifiMacAddress bssid;
+ CsrWifiSmeBssType bssType;
+ CsrWifiSmeRadioIF ifIndex;
+ CsrWifiSme80211PrivacyMode privacyMode;
+ CsrWifiSmeAuthModeMask authModeMask;
+ CsrWifiSmeEncryptionMask encryptionModeMask;
+ u16 mlmeAssociateReqInformationElementsLength;
+ u8 *mlmeAssociateReqInformationElements;
+ CsrWifiSmeWmmQosInfoMask wmmQosInfo;
+ u8 adhocJoinOnly;
+ u8 adhocChannel;
+} CsrWifiSmeConnectionConfig;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeConnectionInfo
+
+ DESCRIPTION
+ Parameters that the SME should use in selecting a network
+
+ MEMBERS
+ ssid - Service set identifier
+ bssid - BSS identifier
+ networkType80211 - Physical layer used for the connection
+ channelNumber - Channel number
+ channelFrequency - Channel frequency
+ authMode - Authentication mode used for the connection
+ pairwiseCipher - Encryption type for peer to peer communication
+ groupCipher - Encryption type for broadcast and multicast
+ communication
+ ifIndex - Indicates the radio interface
+ atimWindowTu - ATIM window specified for IBSS
+ beaconPeriodTu - Interval between beacon packets
+ reassociation - Indicates whether a reassociation occurred
+ beaconFrameLength - Indicates the number of bytes of the beacon
+ frame
+ beaconFrame - Points at the first byte of the beacon frame
+ associationReqFrameLength - Indicates the number of bytes of the
+ association request frame
+ associationReqFrame - Points at the first byte of the association
+ request frame
+ associationRspFrameLength - Indicates the number of bytes of the
+ association response frame
+ associationRspFrame - Points at the first byte of the association
+ response frame
+ assocScanInfoElementsLength - Indicates the number of bytes in the buffer
+ pointed by assocScanInfoElements
+ assocScanInfoElements - Pointer to the buffer containing the
+ information elements of the probe response
+ received after the probe requests sent before
+ attempting to authenticate to the network
+ assocReqCapabilities - Reports the content of the Capability
+ information element as specified in the
+ association request.
+ assocReqListenIntervalTu - Listen Interval specified in the association
+ request
+ assocReqApAddress - AP address to which the association requests
+ has been sent
+ assocReqInfoElementsLength - Indicates the number of bytes of the
+ association request information elements
+ assocReqInfoElements - Points at the first byte of the association
+ request information elements
+ assocRspResult - Result reported in the association response
+ assocRspCapabilityInfo - Reports the content of the Capability
+ information element as received in the
+ association response.
+ assocRspAssociationId - Reports the association ID received in the
+ association response.
+ assocRspInfoElementsLength - Indicates the number of bytes of the
+ association response information elements
+ assocRspInfoElements - Points at the first byte of the association
+ response information elements
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiSsid ssid;
+ CsrWifiMacAddress bssid;
+ CsrWifiSme80211NetworkType networkType80211;
+ u8 channelNumber;
+ u16 channelFrequency;
+ CsrWifiSmeAuthMode authMode;
+ CsrWifiSmeEncryption pairwiseCipher;
+ CsrWifiSmeEncryption groupCipher;
+ CsrWifiSmeRadioIF ifIndex;
+ u16 atimWindowTu;
+ u16 beaconPeriodTu;
+ u8 reassociation;
+ u16 beaconFrameLength;
+ u8 *beaconFrame;
+ u16 associationReqFrameLength;
+ u8 *associationReqFrame;
+ u16 associationRspFrameLength;
+ u8 *associationRspFrame;
+ u16 assocScanInfoElementsLength;
+ u8 *assocScanInfoElements;
+ u16 assocReqCapabilities;
+ u16 assocReqListenIntervalTu;
+ CsrWifiMacAddress assocReqApAddress;
+ u16 assocReqInfoElementsLength;
+ u8 *assocReqInfoElements;
+ CsrWifiSmeIEEE80211Result assocRspResult;
+ u16 assocRspCapabilityInfo;
+ u16 assocRspAssociationId;
+ u16 assocRspInfoElementsLength;
+ u8 *assocRspInfoElements;
+} CsrWifiSmeConnectionInfo;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeDeviceConfig
+
+ DESCRIPTION
+ General configuration options in the SME
+
+ MEMBERS
+ trustLevel - Level of trust of the information coming from the
+ network
+ countryCode - Country code as specified by IEEE 802.11 standard
+ firmwareDriverInterface - Specifies the type of communication between Host
+ and Firmware
+ enableStrictDraftN - If TRUE TKIP is disallowed when connecting to
+ 802.11n enabled access points
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiSme80211dTrustLevel trustLevel;
+ u8 countryCode[2];
+ CsrWifiSmeFirmwareDriverInterface firmwareDriverInterface;
+ u8 enableStrictDraftN;
+} CsrWifiSmeDeviceConfig;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeDeviceInfo
+
+ DESCRIPTION
+ P2P Information for a P2P Device
+
+ MEMBERS
+ deviceAddress - Device Address of the P2P device
+ configMethods - Supported WPS configuration methods.
+ p2PDeviceCap - P2P device capabilities
+ primDeviceType - Primary WPS device type
+ secondaryDeviceTypeCount - Number of secondary device types
+ secDeviceType - list of secondary WPS device types
+ deviceName - Device name without up to 32 characters'\0'.
+ deviceNameLength - Number of characters of the device name
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiMacAddress deviceAddress;
+ CsrWifiSmeWpsConfigTypeMask configMethods;
+ CsrWifiSmeP2pCapabilityMask p2PDeviceCap;
+ CsrWifiSmeWpsDeviceType primDeviceType;
+ u8 secondaryDeviceTypeCount;
+ CsrWifiSmeWpsDeviceType *secDeviceType;
+ u8 deviceName[32];
+ u8 deviceNameLength;
+} CsrWifiSmeDeviceInfo;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeDeviceInfoCommon
+
+ DESCRIPTION
+ Structure holding device information.
+
+ MEMBERS
+ p2pDeviceAddress -
+ primaryDeviceType -
+ secondaryDeviceTypesCount -
+ secondaryDeviceTypes -
+ deviceNameLength -
+ deviceName -
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiMacAddress p2pDeviceAddress;
+ CsrWifiSmeWpsDeviceTypeCommon primaryDeviceType;
+ u8 secondaryDeviceTypesCount;
+ u8 secondaryDeviceTypes[10];
+ u8 deviceNameLength;
+ u8 deviceName[32];
+} CsrWifiSmeDeviceInfoCommon;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeHostConfig
+
+ DESCRIPTION
+ Defines the host power state (for example, on mains power, on battery
+ power etc) and the periodicity of the traffic data.
+
+ MEMBERS
+ powerMode - The wireless manager application should use the
+ powerMode parameter to inform the SME of the host
+ power state.
+ applicationDataPeriodMs - The applicationDataPeriodMs parameter allows a
+ wireless manager application to inform the SME
+ that an application is running that generates
+ periodic network traffic and the period of the
+ traffic.
+ An example of such an application is a VoIP client.
+ The wireless manager application should set
+ applicationDataPeriodMs to the period in
+ milliseconds between data packets or zero if no
+ periodic application is running.
+ Voip etc 0 = No Periodic Data
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiSmeHostPowerMode powerMode;
+ u16 applicationDataPeriodMs;
+} CsrWifiSmeHostConfig;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeKey
+
+ DESCRIPTION
+ Information for a key to be used for encryption
+
+ MEMBERS
+ keyType - Specifies whether the key is a pairwise or group key; it
+ should be set to CSR_WIFI_SME_GROUP_KEY or
+ CSR_WIFI_SME_PAIRWISE_KEY, as required.
+ keyIndex - Specifies which WEP key (0-3) to set; it should be set to 0
+ for a WPA/WPA2 pairwise key and non-zero for a WPA/WPA2
+ group key.
+ wepTxKey - If wepTxKey is TRUE, and the key is a WEP key, the key will
+ be selected for encrypting transmitted packets.
+ To select a previously defined key as the transmit
+ encryption key, set keyIndex to the required key, wepTxKey
+ to TRUE and the keyLength to 0.
+ keyRsc - Key Receive Sequence Counter
+ authenticator - If TRUE the WMA will act as authenticator.
+ CURRENTLY NOT SUPPORTED
+ address - BSS identifier of the AP
+ keyLength - Length of the key in bytes
+ key - Points to the first byte of the key
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiSmeKeyType keyType;
+ u8 keyIndex;
+ u8 wepTxKey;
+ u16 keyRsc[8];
+ u8 authenticator;
+ CsrWifiMacAddress address;
+ u8 keyLength;
+ u8 key[32];
+} CsrWifiSmeKey;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeP2pClientInfoType
+
+ DESCRIPTION
+ P2P Information for a P2P Client
+
+ MEMBERS
+ p2PClientInterfaceAddress - MAC address of the P2P Client
+ clientDeviceInfo - Device Information
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiMacAddress p2PClientInterfaceAddress;
+ CsrWifiSmeDeviceInfo clientDeviceInfo;
+} CsrWifiSmeP2pClientInfoType;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeP2pGroupInfo
+
+ DESCRIPTION
+ P2P Information for a P2P Group
+
+ MEMBERS
+ groupCapability - P2P group capabilities
+ p2pDeviceAddress - Device Address of the GO
+ p2pClientInfoCount - Number of P2P Clients that belong to the group.
+ p2PClientInfo - Pointer to the list containing client information for
+ each client in the group
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiSmeP2pGroupCapabilityMask groupCapability;
+ CsrWifiMacAddress p2pDeviceAddress;
+ u8 p2pClientInfoCount;
+ CsrWifiSmeP2pClientInfoType *p2PClientInfo;
+} CsrWifiSmeP2pGroupInfo;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmePowerConfig
+
+ DESCRIPTION
+ Configures the power-save behaviour of the driver and firmware.
+
+ MEMBERS
+ powerSaveLevel - Power Save Level option
+ listenIntervalTu - Interval for waking to receive beacon frames
+ rxDtims - If TRUE, wake for DTIM every beacon period, to
+ allow the reception broadcast packets
+ d3AutoScanMode - Defines whether the autonomous scanning will be
+ turned off or will stay on during a D3 suspended
+ period
+ clientTrafficWindow - Deprecated
+ opportunisticPowerSave - Deprecated
+ noticeOfAbsence - Deprecated
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiSmePowerSaveLevel powerSaveLevel;
+ u16 listenIntervalTu;
+ u8 rxDtims;
+ CsrWifiSmeD3AutoScanMode d3AutoScanMode;
+ u8 clientTrafficWindow;
+ u8 opportunisticPowerSave;
+ u8 noticeOfAbsence;
+} CsrWifiSmePowerConfig;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeRoamingConfig
+
+ DESCRIPTION
+ Configures the roaming behaviour of the driver and firmware
+
+ MEMBERS
+ roamingBands - Defines the thresholds to determine the usability
+ level of the current connection.
+ roamingBands is indexed by the first 3 entries of
+ the CsrWifiSmeBasicUsability enum
+ disableSmoothRoaming - Disable the RSSI/SNR triggers from the Firmware
+ that the SME uses to detect the quality of the
+ connection.
+ This implicitly disables disableRoamScans
+ disableRoamScans - Disables the scanning for the roaming operation
+ reconnectLimit - Maximum number of times SME may reconnect in the
+ given interval
+ reconnectLimitIntervalMs - Interval for maximum number of times SME may
+ reconnect to the same Access Point
+ roamScanCfg - Scanning behaviour for the specifically aimed at
+ improving roaming performance.
+ roamScanCfg is indexed by the first 3 entries of
+ the CsrWifiSmeBasicUsability enum
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiSmeRoamingBandData roamingBands[3];
+ u8 disableSmoothRoaming;
+ u8 disableRoamScans;
+ u8 reconnectLimit;
+ u16 reconnectLimitIntervalMs;
+ CsrWifiSmeScanConfigData roamScanCfg[3];
+} CsrWifiSmeRoamingConfig;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeScanConfig
+
+ DESCRIPTION
+ Parameters for the autonomous scanning behaviour of the system
+
+ MEMBERS
+ scanCfg - Scan configuration data.
+ Indexed by the CsrWifiSmeBasicUsability enum
+ disableAutonomousScans - Enables or disables the autonomous scan
+ maxResults - Maximum number of results to be cached in the SME
+ highRssiThreshold - High received signal strength indication threshold
+ in dBm for an AP above which the system will
+ report scan indications
+ lowRssiThreshold - Low received signal strength indication threshold
+ in dBm for an AP below which the system will
+ report scan indications
+ deltaRssiThreshold - Minimum difference for received signal strength
+ indication in dBm for an AP which trigger a scan
+ indication to be sent.
+ highSnrThreshold - High Signal to Noise Ratio threshold in dB for an
+ AP above which the system will report scan
+ indications
+ lowSnrThreshold - Low Signal to Noise Ratio threshold in dB for an
+ AP below which the system will report scan
+ indications
+ deltaSnrThreshold - Minimum difference for Signal to Noise Ratio in dB
+ for an AP which trigger a scan indication to be
+ sent.
+ passiveChannelListCount - Number of channels to be scanned passively.
+ passiveChannelList - Points to the first channel to be scanned
+ passively , if any.
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiSmeScanConfigData scanCfg[4];
+ u8 disableAutonomousScans;
+ u16 maxResults;
+ s8 highRssiThreshold;
+ s8 lowRssiThreshold;
+ s8 deltaRssiThreshold;
+ s8 highSnrThreshold;
+ s8 lowSnrThreshold;
+ s8 deltaSnrThreshold;
+ u16 passiveChannelListCount;
+ u8 *passiveChannelList;
+} CsrWifiSmeScanConfig;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeScanResult
+
+ DESCRIPTION
+ This structure defines the scan result for each BSS found
+
+ MEMBERS
+ ssid - Service set identifier
+ bssid - BSS identifier
+ rssi - Received signal strength indication in dBm
+ snr - Signal to noise ratio in dB
+ ifIndex - Indicates the radio interface
+ beaconPeriodTu - Interval between beacon frames
+ timeStamp - Timestamp in the BSS
+ localTime - Timestamp in the Access Point
+ channelFrequency - Channel frequency
+ capabilityInformation - Capabilities of the BSS.
+ channelNumber - Channel number
+ usability - Indicates the usability level.
+ bssType - Type of BSS.
+ informationElementsLength - Number of bytes of the information elements
+ received as part of the beacon or probe
+ response.
+ informationElements - Points to the first byte of the IEs received
+ as part of the beacon or probe response.
+ The format of the IEs is as specified in the
+ IEEE 802.11 specification.
+ p2pDeviceRole - Role of the P2P device.
+ Relevant only if bssType is
+ CSR_WIFI_SME_BSS_TYPE_P2P
+ deviceInfo - Union containing P2P device info which
+ depends on p2pDeviceRole parameter.
+ deviceInforeservedCli -
+ deviceInfogroupInfo -
+ deviceInforeservedNone -
+ deviceInfostandalonedevInfo -
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiSsid ssid;
+ CsrWifiMacAddress bssid;
+ s16 rssi;
+ s16 snr;
+ CsrWifiSmeRadioIF ifIndex;
+ u16 beaconPeriodTu;
+ CsrWifiSmeTsfTime timeStamp;
+ CsrWifiSmeTsfTime localTime;
+ u16 channelFrequency;
+ u16 capabilityInformation;
+ u8 channelNumber;
+ CsrWifiSmeBasicUsability usability;
+ CsrWifiSmeBssType bssType;
+ u16 informationElementsLength;
+ u8 *informationElements;
+ CsrWifiSmeP2pRole p2pDeviceRole;
+ union {
+ CsrWifiSmeEmpty reservedCli;
+ CsrWifiSmeP2pGroupInfo groupInfo;
+ CsrWifiSmeEmpty reservedNone;
+ CsrWifiSmeDeviceInfo standalonedevInfo;
+ } deviceInfo;
+} CsrWifiSmeScanResult;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeStaConfig
+
+ DESCRIPTION
+ Station configuration options in the SME
+
+ MEMBERS
+ connectionQualityRssiChangeTrigger - Sets the difference of RSSI
+ measurements which triggers reports
+ from the Firmware
+ connectionQualitySnrChangeTrigger - Sets the difference of SNR measurements
+ which triggers reports from the
+ Firmware
+ wmmModeMask - Mask containing one or more values from
+ CsrWifiSmeWmmMode
+ ifIndex - Indicates the band of frequencies used
+ allowUnicastUseGroupCipher - If TRUE, it allows to use groupwise
+ keys if no pairwise key is specified
+ enableOpportunisticKeyCaching - If TRUE, enables the Opportunistic Key
+ Caching feature
+
+*******************************************************************************/
+typedef struct
+{
+ u8 connectionQualityRssiChangeTrigger;
+ u8 connectionQualitySnrChangeTrigger;
+ CsrWifiSmeWmmModeMask wmmModeMask;
+ CsrWifiSmeRadioIF ifIndex;
+ u8 allowUnicastUseGroupCipher;
+ u8 enableOpportunisticKeyCaching;
+} CsrWifiSmeStaConfig;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeWep128Keys
+
+ DESCRIPTION
+ Structure holding WEP Authentication Type and WEP keys that can be used
+ when using WEP128.
+
+ MEMBERS
+ wepAuthType - Mask to select the WEP authentication type (Open or Shared)
+ selectedWepKey - Index to one of the four keys below indicating the
+ currently used WEP key. Mapping From SME/User -> firmware.
+ Key 1 -> Index 0. Key 2 -> Index 1. key 3 -> Index 2. Key
+ 4-> Index 3.
+ key1 - Value for key number 1.
+ key2 - Value for key number 2.
+ key3 - Value for key number 3.
+ key4 - Value for key number 4.
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiSmeWepAuthMode wepAuthType;
+ u8 selectedWepKey;
+ u8 key1[13];
+ u8 key2[13];
+ u8 key3[13];
+ u8 key4[13];
+} CsrWifiSmeWep128Keys;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeWep64Keys
+
+ DESCRIPTION
+ Structure holding WEP Authentication Type and WEP keys that can be used
+ when using WEP64.
+
+ MEMBERS
+ wepAuthType - Mask to select the WEP authentication type (Open or Shared)
+ selectedWepKey - Index to one of the four keys below indicating the
+ currently used WEP key. Mapping From SME/User -> firmware.
+ Key 1 -> Index 0. Key 2 -> Index 1. key 3 -> Index 2. Key
+ 4-> Index 3.
+ key1 - Value for key number 1.
+ key2 - Value for key number 2.
+ key3 - Value for key number 3.
+ key4 - Value for key number 4.
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiSmeWepAuthMode wepAuthType;
+ u8 selectedWepKey;
+ u8 key1[5];
+ u8 key2[5];
+ u8 key3[5];
+ u8 key4[5];
+} CsrWifiSmeWep64Keys;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeWepAuth
+
+ DESCRIPTION
+ WEP authentication parameter structure
+
+ MEMBERS
+ wepKeyType - WEP key try (128 bit or 64 bit)
+ wepCredentials - Union containing credentials which depends on
+ wepKeyType parameter.
+ wepCredentialswep128Key -
+ wepCredentialswep64Key -
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiSmeWepCredentialType wepKeyType;
+ union {
+ CsrWifiSmeWep128Keys wep128Key;
+ CsrWifiSmeWep64Keys wep64Key;
+ } wepCredentials;
+} CsrWifiSmeWepAuth;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeWpsConfig
+
+ DESCRIPTION
+ Structure holding AP WPS Config data.
+
+ MEMBERS
+ wpsVersion - wpsVersion should be 0x10 for WPS1.0h or 0x20 for
+ WSC2.0
+ uuid - uuid.
+ deviceName - Device name upto 32 characters without '\0'.
+ deviceNameLength - deviceNameLen.
+ manufacturer - manufacturer: CSR
+ manufacturerLength - manufacturerLen.
+ modelName - modelName Unifi
+ modelNameLength - modelNameLen.
+ modelNumber - modelNumber
+ modelNumberLength - modelNumberLen.
+ serialNumber - serialNumber
+ primDeviceType - Primary WPS device type
+ secondaryDeviceTypeCount - Number of secondary device types
+ secondaryDeviceType - list of secondary WPS device types
+ configMethods - Supported WPS config methods
+ rfBands - RfBands.
+ osVersion - Os version on which the device is running
+
+*******************************************************************************/
+typedef struct
+{
+ u8 wpsVersion;
+ u8 uuid[16];
+ u8 deviceName[32];
+ u8 deviceNameLength;
+ u8 manufacturer[64];
+ u8 manufacturerLength;
+ u8 modelName[32];
+ u8 modelNameLength;
+ u8 modelNumber[32];
+ u8 modelNumberLength;
+ u8 serialNumber[32];
+ CsrWifiSmeWpsDeviceType primDeviceType;
+ u8 secondaryDeviceTypeCount;
+ CsrWifiSmeWpsDeviceType *secondaryDeviceType;
+ CsrWifiSmeWpsConfigTypeMask configMethods;
+ u8 rfBands;
+ u8 osVersion[4];
+} CsrWifiSmeWpsConfig;
+
+
+/* Downstream */
+#define CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST (0x0000)
+
+#define CSR_WIFI_SME_ACTIVATE_REQ ((CsrWifiSmePrim) (0x0000 + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST))
+#define CSR_WIFI_SME_ADHOC_CONFIG_GET_REQ ((CsrWifiSmePrim) (0x0001 + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST))
+#define CSR_WIFI_SME_ADHOC_CONFIG_SET_REQ ((CsrWifiSmePrim) (0x0002 + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST))
+#define CSR_WIFI_SME_BLACKLIST_REQ ((CsrWifiSmePrim) (0x0003 + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST))
+#define CSR_WIFI_SME_CALIBRATION_DATA_GET_REQ ((CsrWifiSmePrim) (0x0004 + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST))
+#define CSR_WIFI_SME_CALIBRATION_DATA_SET_REQ ((CsrWifiSmePrim) (0x0005 + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST))
+#define CSR_WIFI_SME_CCX_CONFIG_GET_REQ ((CsrWifiSmePrim) (0x0006 + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST))
+#define CSR_WIFI_SME_CCX_CONFIG_SET_REQ ((CsrWifiSmePrim) (0x0007 + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST))
+#define CSR_WIFI_SME_COEX_CONFIG_GET_REQ ((CsrWifiSmePrim) (0x0008 + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST))
+#define CSR_WIFI_SME_COEX_CONFIG_SET_REQ ((CsrWifiSmePrim) (0x0009 + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST))
+#define CSR_WIFI_SME_COEX_INFO_GET_REQ ((CsrWifiSmePrim) (0x000A + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST))
+#define CSR_WIFI_SME_CONNECT_REQ ((CsrWifiSmePrim) (0x000B + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST))
+#define CSR_WIFI_SME_CONNECTION_CONFIG_GET_REQ ((CsrWifiSmePrim) (0x000C + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST))
+#define CSR_WIFI_SME_CONNECTION_INFO_GET_REQ ((CsrWifiSmePrim) (0x000D + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST))
+#define CSR_WIFI_SME_CONNECTION_STATS_GET_REQ ((CsrWifiSmePrim) (0x000E + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST))
+#define CSR_WIFI_SME_DEACTIVATE_REQ ((CsrWifiSmePrim) (0x000F + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST))
+#define CSR_WIFI_SME_DISCONNECT_REQ ((CsrWifiSmePrim) (0x0010 + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST))
+#define CSR_WIFI_SME_EVENT_MASK_SET_REQ ((CsrWifiSmePrim) (0x0011 + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST))
+#define CSR_WIFI_SME_HOST_CONFIG_GET_REQ ((CsrWifiSmePrim) (0x0012 + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST))
+#define CSR_WIFI_SME_HOST_CONFIG_SET_REQ ((CsrWifiSmePrim) (0x0013 + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST))
+#define CSR_WIFI_SME_KEY_REQ ((CsrWifiSmePrim) (0x0014 + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST))
+#define CSR_WIFI_SME_LINK_QUALITY_GET_REQ ((CsrWifiSmePrim) (0x0015 + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST))
+#define CSR_WIFI_SME_MIB_CONFIG_GET_REQ ((CsrWifiSmePrim) (0x0016 + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST))
+#define CSR_WIFI_SME_MIB_CONFIG_SET_REQ ((CsrWifiSmePrim) (0x0017 + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST))
+#define CSR_WIFI_SME_MIB_GET_NEXT_REQ ((CsrWifiSmePrim) (0x0018 + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST))
+#define CSR_WIFI_SME_MIB_GET_REQ ((CsrWifiSmePrim) (0x0019 + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST))
+#define CSR_WIFI_SME_MIB_SET_REQ ((CsrWifiSmePrim) (0x001A + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST))
+#define CSR_WIFI_SME_MULTICAST_ADDRESS_REQ ((CsrWifiSmePrim) (0x001B + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST))
+#define CSR_WIFI_SME_PACKET_FILTER_SET_REQ ((CsrWifiSmePrim) (0x001C + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST))
+#define CSR_WIFI_SME_PERMANENT_MAC_ADDRESS_GET_REQ ((CsrWifiSmePrim) (0x001D + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST))
+#define CSR_WIFI_SME_PMKID_REQ ((CsrWifiSmePrim) (0x001E + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST))
+#define CSR_WIFI_SME_POWER_CONFIG_GET_REQ ((CsrWifiSmePrim) (0x001F + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST))
+#define CSR_WIFI_SME_POWER_CONFIG_SET_REQ ((CsrWifiSmePrim) (0x0020 + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST))
+#define CSR_WIFI_SME_REGULATORY_DOMAIN_INFO_GET_REQ ((CsrWifiSmePrim) (0x0021 + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST))
+#define CSR_WIFI_SME_ROAMING_CONFIG_GET_REQ ((CsrWifiSmePrim) (0x0022 + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST))
+#define CSR_WIFI_SME_ROAMING_CONFIG_SET_REQ ((CsrWifiSmePrim) (0x0023 + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST))
+#define CSR_WIFI_SME_SCAN_CONFIG_GET_REQ ((CsrWifiSmePrim) (0x0024 + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST))
+#define CSR_WIFI_SME_SCAN_CONFIG_SET_REQ ((CsrWifiSmePrim) (0x0025 + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST))
+#define CSR_WIFI_SME_SCAN_FULL_REQ ((CsrWifiSmePrim) (0x0026 + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST))
+#define CSR_WIFI_SME_SCAN_RESULTS_FLUSH_REQ ((CsrWifiSmePrim) (0x0027 + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST))
+#define CSR_WIFI_SME_SCAN_RESULTS_GET_REQ ((CsrWifiSmePrim) (0x0028 + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST))
+#define CSR_WIFI_SME_SME_STA_CONFIG_GET_REQ ((CsrWifiSmePrim) (0x0029 + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST))
+#define CSR_WIFI_SME_SME_STA_CONFIG_SET_REQ ((CsrWifiSmePrim) (0x002A + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST))
+#define CSR_WIFI_SME_STATION_MAC_ADDRESS_GET_REQ ((CsrWifiSmePrim) (0x002B + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST))
+#define CSR_WIFI_SME_TSPEC_REQ ((CsrWifiSmePrim) (0x002C + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST))
+#define CSR_WIFI_SME_VERSIONS_GET_REQ ((CsrWifiSmePrim) (0x002D + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST))
+#define CSR_WIFI_SME_WIFI_FLIGHTMODE_REQ ((CsrWifiSmePrim) (0x002E + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST))
+#define CSR_WIFI_SME_WIFI_OFF_REQ ((CsrWifiSmePrim) (0x002F + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST))
+#define CSR_WIFI_SME_WIFI_ON_REQ ((CsrWifiSmePrim) (0x0030 + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST))
+#define CSR_WIFI_SME_CLOAKED_SSIDS_SET_REQ ((CsrWifiSmePrim) (0x0031 + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST))
+#define CSR_WIFI_SME_CLOAKED_SSIDS_GET_REQ ((CsrWifiSmePrim) (0x0032 + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST))
+#define CSR_WIFI_SME_SME_COMMON_CONFIG_GET_REQ ((CsrWifiSmePrim) (0x0033 + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST))
+#define CSR_WIFI_SME_SME_COMMON_CONFIG_SET_REQ ((CsrWifiSmePrim) (0x0034 + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST))
+#define CSR_WIFI_SME_INTERFACE_CAPABILITY_GET_REQ ((CsrWifiSmePrim) (0x0035 + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST))
+#define CSR_WIFI_SME_WPS_CONFIGURATION_REQ ((CsrWifiSmePrim) (0x0036 + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST))
+#define CSR_WIFI_SME_SET_REQ ((CsrWifiSmePrim) (0x0037 + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST))
+
+
+#define CSR_WIFI_SME_PRIM_DOWNSTREAM_HIGHEST (0x0037 + CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST)
+
+/* Upstream */
+#define CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST (0x0000 + CSR_PRIM_UPSTREAM)
+
+#define CSR_WIFI_SME_ACTIVATE_CFM ((CsrWifiSmePrim)(0x0000 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
+#define CSR_WIFI_SME_ADHOC_CONFIG_GET_CFM ((CsrWifiSmePrim)(0x0001 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
+#define CSR_WIFI_SME_ADHOC_CONFIG_SET_CFM ((CsrWifiSmePrim)(0x0002 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
+#define CSR_WIFI_SME_ASSOCIATION_COMPLETE_IND ((CsrWifiSmePrim)(0x0003 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
+#define CSR_WIFI_SME_ASSOCIATION_START_IND ((CsrWifiSmePrim)(0x0004 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
+#define CSR_WIFI_SME_BLACKLIST_CFM ((CsrWifiSmePrim)(0x0005 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
+#define CSR_WIFI_SME_CALIBRATION_DATA_GET_CFM ((CsrWifiSmePrim)(0x0006 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
+#define CSR_WIFI_SME_CALIBRATION_DATA_SET_CFM ((CsrWifiSmePrim)(0x0007 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
+#define CSR_WIFI_SME_CCX_CONFIG_GET_CFM ((CsrWifiSmePrim)(0x0008 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
+#define CSR_WIFI_SME_CCX_CONFIG_SET_CFM ((CsrWifiSmePrim)(0x0009 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
+#define CSR_WIFI_SME_COEX_CONFIG_GET_CFM ((CsrWifiSmePrim)(0x000A + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
+#define CSR_WIFI_SME_COEX_CONFIG_SET_CFM ((CsrWifiSmePrim)(0x000B + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
+#define CSR_WIFI_SME_COEX_INFO_GET_CFM ((CsrWifiSmePrim)(0x000C + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
+#define CSR_WIFI_SME_CONNECT_CFM ((CsrWifiSmePrim)(0x000D + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
+#define CSR_WIFI_SME_CONNECTION_CONFIG_GET_CFM ((CsrWifiSmePrim)(0x000E + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
+#define CSR_WIFI_SME_CONNECTION_INFO_GET_CFM ((CsrWifiSmePrim)(0x000F + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
+#define CSR_WIFI_SME_CONNECTION_QUALITY_IND ((CsrWifiSmePrim)(0x0010 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
+#define CSR_WIFI_SME_CONNECTION_STATS_GET_CFM ((CsrWifiSmePrim)(0x0011 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
+#define CSR_WIFI_SME_DEACTIVATE_CFM ((CsrWifiSmePrim)(0x0012 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
+#define CSR_WIFI_SME_DISCONNECT_CFM ((CsrWifiSmePrim)(0x0013 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
+#define CSR_WIFI_SME_EVENT_MASK_SET_CFM ((CsrWifiSmePrim)(0x0014 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
+#define CSR_WIFI_SME_HOST_CONFIG_GET_CFM ((CsrWifiSmePrim)(0x0015 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
+#define CSR_WIFI_SME_HOST_CONFIG_SET_CFM ((CsrWifiSmePrim)(0x0016 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
+#define CSR_WIFI_SME_IBSS_STATION_IND ((CsrWifiSmePrim)(0x0017 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
+#define CSR_WIFI_SME_KEY_CFM ((CsrWifiSmePrim)(0x0018 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
+#define CSR_WIFI_SME_LINK_QUALITY_GET_CFM ((CsrWifiSmePrim)(0x0019 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
+#define CSR_WIFI_SME_MEDIA_STATUS_IND ((CsrWifiSmePrim)(0x001A + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
+#define CSR_WIFI_SME_MIB_CONFIG_GET_CFM ((CsrWifiSmePrim)(0x001B + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
+#define CSR_WIFI_SME_MIB_CONFIG_SET_CFM ((CsrWifiSmePrim)(0x001C + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
+#define CSR_WIFI_SME_MIB_GET_CFM ((CsrWifiSmePrim)(0x001D + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
+#define CSR_WIFI_SME_MIB_GET_NEXT_CFM ((CsrWifiSmePrim)(0x001E + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
+#define CSR_WIFI_SME_MIB_SET_CFM ((CsrWifiSmePrim)(0x001F + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
+#define CSR_WIFI_SME_MIC_FAILURE_IND ((CsrWifiSmePrim)(0x0020 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
+#define CSR_WIFI_SME_MULTICAST_ADDRESS_CFM ((CsrWifiSmePrim)(0x0021 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
+#define CSR_WIFI_SME_PACKET_FILTER_SET_CFM ((CsrWifiSmePrim)(0x0022 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
+#define CSR_WIFI_SME_PERMANENT_MAC_ADDRESS_GET_CFM ((CsrWifiSmePrim)(0x0023 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
+#define CSR_WIFI_SME_PMKID_CANDIDATE_LIST_IND ((CsrWifiSmePrim)(0x0024 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
+#define CSR_WIFI_SME_PMKID_CFM ((CsrWifiSmePrim)(0x0025 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
+#define CSR_WIFI_SME_POWER_CONFIG_GET_CFM ((CsrWifiSmePrim)(0x0026 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
+#define CSR_WIFI_SME_POWER_CONFIG_SET_CFM ((CsrWifiSmePrim)(0x0027 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
+#define CSR_WIFI_SME_REGULATORY_DOMAIN_INFO_GET_CFM ((CsrWifiSmePrim)(0x0028 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
+#define CSR_WIFI_SME_ROAM_COMPLETE_IND ((CsrWifiSmePrim)(0x0029 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
+#define CSR_WIFI_SME_ROAM_START_IND ((CsrWifiSmePrim)(0x002A + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
+#define CSR_WIFI_SME_ROAMING_CONFIG_GET_CFM ((CsrWifiSmePrim)(0x002B + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
+#define CSR_WIFI_SME_ROAMING_CONFIG_SET_CFM ((CsrWifiSmePrim)(0x002C + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
+#define CSR_WIFI_SME_SCAN_CONFIG_GET_CFM ((CsrWifiSmePrim)(0x002D + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
+#define CSR_WIFI_SME_SCAN_CONFIG_SET_CFM ((CsrWifiSmePrim)(0x002E + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
+#define CSR_WIFI_SME_SCAN_FULL_CFM ((CsrWifiSmePrim)(0x002F + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
+#define CSR_WIFI_SME_SCAN_RESULT_IND ((CsrWifiSmePrim)(0x0030 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
+#define CSR_WIFI_SME_SCAN_RESULTS_FLUSH_CFM ((CsrWifiSmePrim)(0x0031 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
+#define CSR_WIFI_SME_SCAN_RESULTS_GET_CFM ((CsrWifiSmePrim)(0x0032 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
+#define CSR_WIFI_SME_SME_STA_CONFIG_GET_CFM ((CsrWifiSmePrim)(0x0033 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
+#define CSR_WIFI_SME_SME_STA_CONFIG_SET_CFM ((CsrWifiSmePrim)(0x0034 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
+#define CSR_WIFI_SME_STATION_MAC_ADDRESS_GET_CFM ((CsrWifiSmePrim)(0x0035 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
+#define CSR_WIFI_SME_TSPEC_IND ((CsrWifiSmePrim)(0x0036 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
+#define CSR_WIFI_SME_TSPEC_CFM ((CsrWifiSmePrim)(0x0037 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
+#define CSR_WIFI_SME_VERSIONS_GET_CFM ((CsrWifiSmePrim)(0x0038 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
+#define CSR_WIFI_SME_WIFI_FLIGHTMODE_CFM ((CsrWifiSmePrim)(0x0039 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
+#define CSR_WIFI_SME_WIFI_OFF_IND ((CsrWifiSmePrim)(0x003A + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
+#define CSR_WIFI_SME_WIFI_OFF_CFM ((CsrWifiSmePrim)(0x003B + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
+#define CSR_WIFI_SME_WIFI_ON_CFM ((CsrWifiSmePrim)(0x003C + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
+#define CSR_WIFI_SME_CLOAKED_SSIDS_SET_CFM ((CsrWifiSmePrim)(0x003D + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
+#define CSR_WIFI_SME_CLOAKED_SSIDS_GET_CFM ((CsrWifiSmePrim)(0x003E + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
+#define CSR_WIFI_SME_WIFI_ON_IND ((CsrWifiSmePrim)(0x003F + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
+#define CSR_WIFI_SME_SME_COMMON_CONFIG_GET_CFM ((CsrWifiSmePrim)(0x0040 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
+#define CSR_WIFI_SME_SME_COMMON_CONFIG_SET_CFM ((CsrWifiSmePrim)(0x0041 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
+#define CSR_WIFI_SME_INTERFACE_CAPABILITY_GET_CFM ((CsrWifiSmePrim)(0x0042 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
+#define CSR_WIFI_SME_ERROR_IND ((CsrWifiSmePrim)(0x0043 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
+#define CSR_WIFI_SME_INFO_IND ((CsrWifiSmePrim)(0x0044 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
+#define CSR_WIFI_SME_CORE_DUMP_IND ((CsrWifiSmePrim)(0x0045 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
+#define CSR_WIFI_SME_AMP_STATUS_CHANGE_IND ((CsrWifiSmePrim)(0x0046 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
+#define CSR_WIFI_SME_WPS_CONFIGURATION_CFM ((CsrWifiSmePrim)(0x0047 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST))
+
+#define CSR_WIFI_SME_PRIM_UPSTREAM_HIGHEST (0x0047 + CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST)
+
+#define CSR_WIFI_SME_PRIM_DOWNSTREAM_COUNT (CSR_WIFI_SME_PRIM_DOWNSTREAM_HIGHEST + 1 - CSR_WIFI_SME_PRIM_DOWNSTREAM_LOWEST)
+#define CSR_WIFI_SME_PRIM_UPSTREAM_COUNT (CSR_WIFI_SME_PRIM_UPSTREAM_HIGHEST + 1 - CSR_WIFI_SME_PRIM_UPSTREAM_LOWEST)
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeActivateReq
+
+ DESCRIPTION
+ The WMA sends this primitive to activate the SME.
+ The WMA must activate the SME before it can send any other primitive.
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+} CsrWifiSmeActivateReq;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeAdhocConfigGetReq
+
+ DESCRIPTION
+ This primitive gets the value of the adHocConfig parameter.
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+} CsrWifiSmeAdhocConfigGetReq;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeAdhocConfigSetReq
+
+ DESCRIPTION
+ This primitive sets the value of the adHocConfig parameter.
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ adHocConfig - Sets the values to use when starting an ad hoc network.
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ CsrWifiSmeAdHocConfig adHocConfig;
+} CsrWifiSmeAdhocConfigSetReq;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeBlacklistReq
+
+ DESCRIPTION
+ The wireless manager application should call this primitive to notify the
+ driver of any networks that should not be connected to. The interface
+ allows the wireless manager application to query, add, remove, and flush
+ the BSSIDs that the driver may not connect or roam to.
+ When this primitive adds to the black list the BSSID to which the SME is
+ currently connected, the SME will try to roam, if applicable, to another
+ BSSID in the same ESS; if the roaming procedure fails, the SME will
+ disconnect.
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ interfaceTag - Interface Identifier; unique identifier of an interface
+ action - The value of the CsrWifiSmeListAction parameter instructs
+ the driver to modify or provide the list of blacklisted
+ networks.
+ setAddressCount - Number of BSSIDs sent with this primitive
+ setAddresses - Pointer to the list of BBSIDs sent with the primitive, set
+ to NULL if none is sent.
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ u16 interfaceTag;
+ CsrWifiSmeListAction action;
+ u8 setAddressCount;
+ CsrWifiMacAddress *setAddresses;
+} CsrWifiSmeBlacklistReq;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeCalibrationDataGetReq
+
+ DESCRIPTION
+ This primitive retrieves the Wi-Fi radio calibration data.
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+} CsrWifiSmeCalibrationDataGetReq;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeCalibrationDataSetReq
+
+ DESCRIPTION
+ This primitive sets the Wi-Fi radio calibration data.
+ The usage of the primitive with proper calibration data will avoid
+ time-consuming configuration after power-up.
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ calibrationDataLength - Number of bytes in the buffer pointed by
+ calibrationData
+ calibrationData - Pointer to a buffer of length calibrationDataLength
+ containing the calibration data
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ u16 calibrationDataLength;
+ u8 *calibrationData;
+} CsrWifiSmeCalibrationDataSetReq;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeCcxConfigGetReq
+
+ DESCRIPTION
+ This primitive gets the value of the CcxConfig parameter.
+ CURRENTLY NOT SUPPORTED.
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ interfaceTag - Interface Identifier; unique identifier of an interface
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ u16 interfaceTag;
+} CsrWifiSmeCcxConfigGetReq;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeCcxConfigSetReq
+
+ DESCRIPTION
+ This primitive sets the value of the CcxConfig parameter.
+ CURRENTLY NOT SUPPORTED.
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ interfaceTag - Interface Identifier; unique identifier of an interface
+ ccxConfig - Currently not supported
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ u16 interfaceTag;
+ CsrWifiSmeCcxConfig ccxConfig;
+} CsrWifiSmeCcxConfigSetReq;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeCoexConfigGetReq
+
+ DESCRIPTION
+ This primitive gets the value of the CoexConfig parameter.
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+} CsrWifiSmeCoexConfigGetReq;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeCoexConfigSetReq
+
+ DESCRIPTION
+ This primitive sets the value of the CoexConfig parameter.
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ coexConfig - Configures the coexistence behaviour
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ CsrWifiSmeCoexConfig coexConfig;
+} CsrWifiSmeCoexConfigSetReq;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeCoexInfoGetReq
+
+ DESCRIPTION
+ This primitive gets the value of the CoexInfo parameter.
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+} CsrWifiSmeCoexInfoGetReq;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeConnectReq
+
+ DESCRIPTION
+ The wireless manager application calls this primitive to start the
+ process of joining an 802.11 wireless network or to start an ad hoc
+ network.
+ The structure pointed by connectionConfig contains parameters describing
+ the network to join or, in case of an ad hoc network, to host or join.
+ The SME will select a network, perform the IEEE 802.11 Join, Authenticate
+ and Associate exchanges.
+ The SME selects the networks from the current scan list that match both
+ the SSID and BSSID, however either or both of these may be the wildcard
+ value. Using this rule, the following operations are possible:
+ * To connect to a network by name, specify the SSID and set the BSSID to
+ 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF. If there are two or more networks visible,
+ the SME will select the one with the strongest signal.
+ * To connect to a specific network, specify the BSSID. The SSID is
+ optional, but if given it must match the SSID of the network. An empty
+ SSID may be specified by setting the SSID length to zero. Please note
+ that if the BSSID is specified (i.e. not equal to 0xFF 0xFF 0xFF 0xFF
+ 0xFF 0xFF), the SME will not attempt to roam if signal conditions become
+ poor, even if there is an alternative AP with an SSID that matches the
+ current network SSID.
+ * To connect to any network matching the other parameters (i.e. security,
+ etc), set the SSID length to zero and set the BSSID to 0xFF 0xFF 0xFF
+ 0xFF 0xFF 0xFF. In this case, the SME will order all available networks
+ by their signal strengths and will iterate through this list until it
+ successfully connects.
+ NOTE: Specifying the BSSID will restrict the selection to one specific
+ network. If SSID and BSSID are given, they must both match the network
+ for it to be selected. To select a network based on the SSID only, the
+ wireless manager application must set the BSSID to 0xFF 0xFF 0xFF 0xFF
+ 0xFF 0xFF.
+ The SME will try to connect to each network that matches the provided
+ parameters, one by one, until it succeeds or has tried unsuccessfully
+ with all the matching networks.
+ If there is no network that matches the parameters and the request allows
+ to host an ad hoc network, the SME will advertise a new ad hoc network
+ instead.
+ If the SME cannot connect, it will notify the failure in the confirm.
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ interfaceTag - Interface Identifier; unique identifier of an interface
+ connectionConfig - Describes the candidate network to join or to host.
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ u16 interfaceTag;
+ CsrWifiSmeConnectionConfig connectionConfig;
+} CsrWifiSmeConnectReq;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeConnectionConfigGetReq
+
+ DESCRIPTION
+ This primitive gets the value of the ConnectionConfig parameter.
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ interfaceTag - Interface Identifier; unique identifier of an interface
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ u16 interfaceTag;
+} CsrWifiSmeConnectionConfigGetReq;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeConnectionInfoGetReq
+
+ DESCRIPTION
+ This primitive gets the value of the ConnectionInfo parameter.
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ interfaceTag - Interface Identifier; unique identifier of an interface
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ u16 interfaceTag;
+} CsrWifiSmeConnectionInfoGetReq;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeConnectionStatsGetReq
+
+ DESCRIPTION
+ This primitive gets the value of the ConnectionStats parameter.
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ interfaceTag - Interface Identifier; unique identifier of an interface
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ u16 interfaceTag;
+} CsrWifiSmeConnectionStatsGetReq;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeDeactivateReq
+
+ DESCRIPTION
+ The WMA sends this primitive to deactivate the SME.
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+} CsrWifiSmeDeactivateReq;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeDisconnectReq
+
+ DESCRIPTION
+ The wireless manager application may disconnect from the current network
+ by calling this primitive
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ interfaceTag - Interface Identifier; unique identifier of an interface
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ u16 interfaceTag;
+} CsrWifiSmeDisconnectReq;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeEventMaskSetReq
+
+ DESCRIPTION
+ The wireless manager application may register with the SME to receive
+ notification of interesting events. Indications will be sent only if the
+ wireless manager explicitly registers to be notified of that event.
+ indMask is a bit mask of values defined in CsrWifiSmeIndicationsMask.
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ indMask - Set mask with values from CsrWifiSmeIndications
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ CsrWifiSmeIndicationsMask indMask;
+} CsrWifiSmeEventMaskSetReq;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeHostConfigGetReq
+
+ DESCRIPTION
+ This primitive gets the value of the hostConfig parameter.
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ interfaceTag - Interface Identifier; unique identifier of an interface
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ u16 interfaceTag;
+} CsrWifiSmeHostConfigGetReq;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeHostConfigSetReq
+
+ DESCRIPTION
+ This primitive sets the value of the hostConfig parameter.
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ interfaceTag - Interface Identifier; unique identifier of an interface
+ hostConfig - Communicates a change of host power state (for example, on
+ mains power, on battery power etc) and of the periodicity of
+ traffic data
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ u16 interfaceTag;
+ CsrWifiSmeHostConfig hostConfig;
+} CsrWifiSmeHostConfigSetReq;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeKeyReq
+
+ DESCRIPTION
+ The wireless manager application calls this primitive to add or remove
+ keys that the chip should use for encryption of data.
+ The interface allows the wireless manager application to add and remove
+ keys according to the specified action.
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ interfaceTag - Interface Identifier; unique identifier of an interface
+ action - The value of the CsrWifiSmeListAction parameter instructs the
+ driver to modify or provide the list of keys.
+ CSR_WIFI_SME_LIST_ACTION_GET is not supported here.
+ key - Key to be added or removed
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ u16 interfaceTag;
+ CsrWifiSmeListAction action;
+ CsrWifiSmeKey key;
+} CsrWifiSmeKeyReq;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeLinkQualityGetReq
+
+ DESCRIPTION
+ This primitive gets the value of the LinkQuality parameter.
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ interfaceTag - Interface Identifier; unique identifier of an interface
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ u16 interfaceTag;
+} CsrWifiSmeLinkQualityGetReq;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeMibConfigGetReq
+
+ DESCRIPTION
+ This primitive gets the value of the MibConfig parameter.
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+} CsrWifiSmeMibConfigGetReq;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeMibConfigSetReq
+
+ DESCRIPTION
+ This primitive sets the value of the MibConfig parameter.
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ mibConfig - Conveys the desired value of various IEEE 802.11 attributes as
+ currently configured
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ CsrWifiSmeMibConfig mibConfig;
+} CsrWifiSmeMibConfigSetReq;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeMibGetNextReq
+
+ DESCRIPTION
+ To read a sequence of MIB parameters, for example a table, call this
+ primitive to find the name of the next MIB variable
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ mibAttributeLength - Length of mibAttribute
+ mibAttribute - Points to a VarBind or VarBindList containing the
+ name(s) of the MIB variable(s) to search from.
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ u16 mibAttributeLength;
+ u8 *mibAttribute;
+} CsrWifiSmeMibGetNextReq;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeMibGetReq
+
+ DESCRIPTION
+ The wireless manager application calls this primitive to retrieve one or
+ more MIB variables.
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ mibAttributeLength - Length of mibAttribute
+ mibAttribute - Points to the VarBind or VarBindList containing the
+ names of the MIB variables to be retrieved
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ u16 mibAttributeLength;
+ u8 *mibAttribute;
+} CsrWifiSmeMibGetReq;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeMibSetReq
+
+ DESCRIPTION
+ The SME provides raw access to the MIB on the chip, which may be used by
+ some configuration or diagnostic utilities, but is not normally needed by
+ the wireless manager application.
+ The MIB access functions use BER encoded names (OID) of the MIB
+ parameters and BER encoded values, as described in the chip Host
+ Interface Protocol Specification.
+ The MIB parameters are described in 'Wi-Fi 5.0.0 Management Information
+ Base Reference Guide'.
+ The wireless manager application calls this primitive to set one or more
+ MIB variables
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ mibAttributeLength - Length of mibAttribute
+ mibAttribute - Points to the VarBind or VarBindList containing the
+ names and values of the MIB variables to set
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ u16 mibAttributeLength;
+ u8 *mibAttribute;
+} CsrWifiSmeMibSetReq;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeMulticastAddressReq
+
+ DESCRIPTION
+ The wireless manager application calls this primitive to specify the
+ multicast addresses which the chip should recognise. The interface allows
+ the wireless manager application to query, add, remove and flush the
+ multicast addresses for the network interface according to the specified
+ action.
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ interfaceTag - Interface Identifier; unique identifier of an interface
+ action - The value of the CsrWifiSmeListAction parameter
+ instructs the driver to modify or provide the list of
+ MAC addresses.
+ setAddressesCount - Number of MAC addresses sent with the primitive
+ setAddresses - Pointer to the list of MAC Addresses sent with the
+ primitive, set to NULL if none is sent.
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ u16 interfaceTag;
+ CsrWifiSmeListAction action;
+ u8 setAddressesCount;
+ CsrWifiMacAddress *setAddresses;
+} CsrWifiSmeMulticastAddressReq;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmePacketFilterSetReq
+
+ DESCRIPTION
+ The wireless manager application should call this primitive to enable or
+ disable filtering of broadcast packets: uninteresting broadcast packets
+ will be dropped by the Wi-Fi chip, instead of passing them up to the
+ host.
+ This has the advantage of saving power in the host application processor
+ as it removes the need to process unwanted packets.
+ All broadcast packets are filtered according to the filter and the filter
+ mode provided, except ARP packets, which are filtered using
+ arpFilterAddress.
+ Filters are not cumulative: only the parameters specified in the most
+ recent successful request are significant.
+ For more information, see 'UniFi Firmware API Specification'.
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ interfaceTag - Interface Identifier; unique identifier of an interface
+ filterLength - Length of the filter in bytes.
+ filterLength=0 disables the filter previously set
+ filter - Points to the first byte of the filter provided, if any.
+ This shall include zero or more instance of the
+ information elements of one of these types
+ * Traffic Classification (TCLAS) elements
+ * WMM-SA TCLAS elements
+ mode - Specifies whether the filter selects or excludes packets
+ matching the filter
+ arpFilterAddress - IPv4 address to be used for filtering the ARP packets.
+ * If the specified address is the IPv4 broadcast address
+ (255.255.255.255), all ARP packets are reported to the
+ host,
+ * If the specified address is NOT the IPv4 broadcast
+ address, only ARP packets with the specified address in
+ the Source or Target Protocol Address fields are reported
+ to the host
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ u16 interfaceTag;
+ u16 filterLength;
+ u8 *filter;
+ CsrWifiSmePacketFilterMode mode;
+ CsrWifiIp4Address arpFilterAddress;
+} CsrWifiSmePacketFilterSetReq;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmePermanentMacAddressGetReq
+
+ DESCRIPTION
+ This primitive retrieves the MAC address stored in EEPROM
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+} CsrWifiSmePermanentMacAddressGetReq;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmePmkidReq
+
+ DESCRIPTION
+ The wireless manager application calls this primitive to request an
+ operation on the SME PMKID list.
+ The action argument specifies the operation to perform.
+ When the connection is complete, the wireless manager application may
+ then send and receive EAPOL packets to complete WPA or WPA2
+ authentication if appropriate.
+ The wireless manager application can then pass the resulting encryption
+ keys using this primitive.
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ interfaceTag - Interface Identifier; unique identifier of an interface
+ action - The value of the CsrWifiSmeListAction parameter instructs
+ the driver to modify or provide the list of PMKIDs.
+ setPmkidsCount - Number of PMKIDs sent with the primitive
+ setPmkids - Pointer to the list of PMKIDs sent with the primitive, set
+ to NULL if none is sent.
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ u16 interfaceTag;
+ CsrWifiSmeListAction action;
+ u8 setPmkidsCount;
+ CsrWifiSmePmkid *setPmkids;
+} CsrWifiSmePmkidReq;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmePowerConfigGetReq
+
+ DESCRIPTION
+ This primitive gets the value of the PowerConfig parameter.
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+} CsrWifiSmePowerConfigGetReq;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmePowerConfigSetReq
+
+ DESCRIPTION
+ This primitive sets the value of the PowerConfig parameter.
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ powerConfig - Power saving configuration
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ CsrWifiSmePowerConfig powerConfig;
+} CsrWifiSmePowerConfigSetReq;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeRegulatoryDomainInfoGetReq
+
+ DESCRIPTION
+ This primitive gets the value of the RegulatoryDomainInfo parameter.
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+} CsrWifiSmeRegulatoryDomainInfoGetReq;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeRoamingConfigGetReq
+
+ DESCRIPTION
+ This primitive gets the value of the RoamingConfig parameter.
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ interfaceTag - Interface Identifier; unique identifier of an interface
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ u16 interfaceTag;
+} CsrWifiSmeRoamingConfigGetReq;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeRoamingConfigSetReq
+
+ DESCRIPTION
+ This primitive sets the value of the RoamingConfig parameter.
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ interfaceTag - Interface Identifier; unique identifier of an interface
+ roamingConfig - Desired roaming behaviour values
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ u16 interfaceTag;
+ CsrWifiSmeRoamingConfig roamingConfig;
+} CsrWifiSmeRoamingConfigSetReq;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeScanConfigGetReq
+
+ DESCRIPTION
+ This primitive gets the value of the ScanConfig parameter.
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+} CsrWifiSmeScanConfigGetReq;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeScanConfigSetReq
+
+ DESCRIPTION
+ This primitive sets the value of the ScanConfig parameter.
+ The SME normally configures the firmware to perform autonomous scanning
+ without involving the host.
+ The firmware passes beacon / probe response or indicates loss of beacon
+ on certain changes of state, for example:
+ * A new AP is seen for the first time
+ * An AP is no longer visible
+ * The signal strength of an AP changes by more than a certain amount, as
+ configured by the thresholds in the scanConfig parameter
+ In addition to the autonomous scan, the wireless manager application may
+ request a scan at any time using CSR_WIFI_SME_SCAN_FULL_REQ.
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ scanConfig - Reports the configuration for the autonomous scanning behaviour
+ of the firmware
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ CsrWifiSmeScanConfig scanConfig;
+} CsrWifiSmeScanConfigSetReq;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeScanFullReq
+
+ DESCRIPTION
+ The wireless manager application should call this primitive to request a
+ full scan.
+ Channels are scanned actively or passively according to the requirement
+ set by regulatory domain.
+ If the SME receives this primitive while a full scan is going on, the new
+ request is buffered and it will be served after the current full scan is
+ completed.
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ ssidCount - Number of SSIDs provided.
+ If it is 0, the SME will attempt to detect any network
+ ssid - Points to the first SSID provided, if any.
+ bssid - BSS identifier.
+ If it is equal to FF-FF-FF-FF-FF, the SME will listen for
+ messages from any BSS.
+ If it is different from FF-FF-FF-FF-FF and any SSID is
+ provided, one SSID must match the network of the BSS.
+ forceScan - Forces the scan even if the SME is in a state which would
+ normally prevent it (e.g. autonomous scan is running).
+ bssType - Type of BSS to scan for
+ scanType - Type of scan to perform
+ channelListCount - Number of channels provided.
+ If it is 0, the SME will initiate a scan of all the
+ supported channels that are permitted by the current
+ regulatory domain.
+ channelList - Points to the first channel , or NULL if channelListCount
+ is zero.
+ probeIeLength - Length of the information element in bytes to be sent
+ with the probe message.
+ probeIe - Points to the first byte of the information element to be
+ sent with the probe message.
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ u8 ssidCount;
+ CsrWifiSsid *ssid;
+ CsrWifiMacAddress bssid;
+ u8 forceScan;
+ CsrWifiSmeBssType bssType;
+ CsrWifiSmeScanType scanType;
+ u16 channelListCount;
+ u8 *channelList;
+ u16 probeIeLength;
+ u8 *probeIe;
+} CsrWifiSmeScanFullReq;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeScanResultsFlushReq
+
+ DESCRIPTION
+ The Wireless Manager calls this primitive to ask the SME to delete all
+ scan results from its cache, except for the scan result of any currently
+ connected network.
+ As scan results are received by the SME from the firmware, they are
+ cached in the SME memory.
+ Any time the Wireless Manager requests scan results, they are returned
+ from the SME internal cache.
+ For some applications it may be desirable to clear this cache prior to
+ requesting that a scan be performed; this will ensure that the cache then
+ only contains the networks detected in the most recent scan.
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+} CsrWifiSmeScanResultsFlushReq;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeScanResultsGetReq
+
+ DESCRIPTION
+ The wireless manager application calls this primitive to retrieve the
+ current set of scan results, either after receiving a successful
+ CSR_WIFI_SME_SCAN_FULL_CFM, or to get autonomous scan results.
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+} CsrWifiSmeScanResultsGetReq;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeSmeStaConfigGetReq
+
+ DESCRIPTION
+ This primitive gets the value of the SmeStaConfig parameter.
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ interfaceTag - Interface Identifier; unique identifier of an interface
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ u16 interfaceTag;
+} CsrWifiSmeSmeStaConfigGetReq;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeSmeStaConfigSetReq
+
+ DESCRIPTION
+ This primitive sets the value of the SmeConfig parameter.
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ interfaceTag - Interface Identifier; unique identifier of an interface
+ smeConfig - SME Station Parameters to be set
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ u16 interfaceTag;
+ CsrWifiSmeStaConfig smeConfig;
+} CsrWifiSmeSmeStaConfigSetReq;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeStationMacAddressGetReq
+
+ DESCRIPTION
+ This primitives is used to retrieve the current MAC address used by the
+ station.
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+} CsrWifiSmeStationMacAddressGetReq;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeTspecReq
+
+ DESCRIPTION
+ The wireless manager application should call this primitive to use the
+ TSPEC feature.
+ The chip supports the use of TSPECs and TCLAS for the use of IEEE
+ 802.11/WMM Quality of Service features.
+ The API allows the wireless manager application to supply a correctly
+ formatted TSPEC and TCLAS pair to the driver.
+ After performing basic validation, the driver negotiates the installation
+ of the TSPEC with the AP as defined by the 802.11 specification.
+ The driver retains all TSPEC and TCLAS pairs until they are specifically
+ removed.
+ It is not compulsory for a TSPEC to have a TCLAS (NULL is used to
+ indicate that no TCLAS is supplied), while a TCLASS always require a
+ TSPEC.
+ The format of the TSPEC element is specified in 'WMM (including WMM Power
+ Save) Specification - Version 1.1' and 'ANSI/IEEE Std 802.11-REVmb/D3.0'.
+ For more information, see 'UniFi Configuring WMM and WMM-PS'.
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ interfaceTag - Interface Identifier; unique identifier of an interface
+ action - Specifies the action to be carried out on the list of TSPECs.
+ CSR_WIFI_SME_LIST_ACTION_FLUSH is not applicable here.
+ transactionId - Unique Transaction ID for the TSPEC, as assigned by the
+ driver
+ strict - If it set to false, allows the SME to perform automatic
+ TSPEC negotiation
+ ctrlMask - Additional TSPEC configuration for CCX.
+ Set mask with values from CsrWifiSmeTspecCtrl.
+ CURRENTLY NOT SUPPORTED
+ tspecLength - Length of the TSPEC.
+ tspec - Points to the first byte of the TSPEC
+ tclasLength - Length of the TCLAS.
+ If it is equal to 0, no TCLASS is provided for the TSPEC
+ tclas - Points to the first byte of the TCLAS, if any.
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ u16 interfaceTag;
+ CsrWifiSmeListAction action;
+ u32 transactionId;
+ u8 strict;
+ CsrWifiSmeTspecCtrlMask ctrlMask;
+ u16 tspecLength;
+ u8 *tspec;
+ u16 tclasLength;
+ u8 *tclas;
+} CsrWifiSmeTspecReq;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeVersionsGetReq
+
+ DESCRIPTION
+ This primitive gets the value of the Versions parameter.
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+} CsrWifiSmeVersionsGetReq;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeWifiFlightmodeReq
+
+ DESCRIPTION
+ The wireless manager application may call this primitive on boot-up of
+ the platform to ensure that the chip is placed in a mode that prevents
+ any emission of RF energy.
+ This primitive is an alternative to CSR_WIFI_SME_WIFI_ON_REQ.
+ As in CSR_WIFI_SME_WIFI_ON_REQ, it causes the download of the patch file
+ (if any) and the programming of the initial MIB settings (if supplied by
+ the WMA), but it also ensures that the chip is left in its lowest
+ possible power-mode with the radio subsystems disabled.
+ This feature is useful on platforms where power cannot be removed from
+ the chip (leaving the chip not initialised will cause it to consume more
+ power so calling this function ensures that the chip is initialised into
+ a low power mode but without entering a state where it could emit any RF
+ energy).
+ NOTE: this primitive does not cause the Wi-Fi to change state: Wi-Fi
+ stays conceptually off. Configuration primitives can be sent after
+ CSR_WIFI_SME_WIFI_FLIGHTMODE_REQ and the configuration will be maintained.
+ Requests that require the state of the Wi-Fi to be ON will return
+ CSR_WIFI_SME_STATUS_WIFI_OFF in their confirms.
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ address - Optionally specifies a station MAC address.
+ In normal use, the manager should set the address to 0xFF
+ 0xFF 0xFF 0xFF 0xFF 0xFF, which will cause the chip to use
+ the MAC address in the MIB.
+ mibFilesCount - Number of provided data blocks with initial MIB values
+ mibFiles - Points to the first data block with initial MIB values.
+ These data blocks are typically the contents of the provided
+ files ufmib.dat and localmib.dat, available from the host
+ file system, if they exist.
+ These files typically contain radio tuning and calibration
+ values.
+ More values can be created using the Host Tools.
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ CsrWifiMacAddress address;
+ u16 mibFilesCount;
+ CsrWifiSmeDataBlock *mibFiles;
+} CsrWifiSmeWifiFlightmodeReq;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeWifiOffReq
+
+ DESCRIPTION
+ The wireless manager application calls this primitive to turn off the
+ chip, thus saving power when Wi-Fi is not in use.
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+} CsrWifiSmeWifiOffReq;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeWifiOnReq
+
+ DESCRIPTION
+ The wireless manager application calls this primitive to turn on the
+ Wi-Fi chip.
+ If the Wi-Fi chip is currently off, the SME turns the Wi-Fi chip on,
+ downloads the patch file (if any), and programs the initial MIB settings
+ (if supplied by the WMA).
+ The patch file is not provided with the SME API; its downloading is
+ automatic and handled internally by the system.
+ The MIB settings, when provided, override the default values that the
+ firmware loads from EEPROM.
+ If the Wi-Fi chip is already on, the SME takes no action and returns a
+ successful status in the confirm.
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ address - Optionally specifies a station MAC address.
+ In normal use, the manager should set the address to 0xFF
+ 0xFF 0xFF 0xFF 0xFF 0xFF, which will cause the chip to use
+ the MAC address in the MIB
+ mibFilesCount - Number of provided data blocks with initial MIB values
+ mibFiles - Points to the first data block with initial MIB values.
+ These data blocks are typically the contents of the provided
+ files ufmib.dat and localmib.dat, available from the host
+ file system, if they exist.
+ These files typically contain radio tuning and calibration
+ values.
+ More values can be created using the Host Tools.
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ CsrWifiMacAddress address;
+ u16 mibFilesCount;
+ CsrWifiSmeDataBlock *mibFiles;
+} CsrWifiSmeWifiOnReq;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeCloakedSsidsSetReq
+
+ DESCRIPTION
+ This primitive sets the list of cloaked SSIDs for which the WMA possesses
+ profiles.
+ When the driver detects a cloaked AP, the SME will explicitly scan for it
+ using the list of cloaked SSIDs provided it, and, if the scan succeeds,
+ it will report the AP to the WMA either via CSR_WIFI_SME_SCAN_RESULT_IND
+ (if registered) or via CSR_WIFI_SCAN_RESULT_GET_CFM.
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ cloakedSsids - Sets the list of cloaked SSIDs
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ CsrWifiSmeCloakedSsidConfig cloakedSsids;
+} CsrWifiSmeCloakedSsidsSetReq;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeCloakedSsidsGetReq
+
+ DESCRIPTION
+ This primitive gets the value of the CloakedSsids parameter.
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+} CsrWifiSmeCloakedSsidsGetReq;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeSmeCommonConfigGetReq
+
+ DESCRIPTION
+ This primitive gets the value of the Sme common parameter.
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+} CsrWifiSmeSmeCommonConfigGetReq;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeSmeCommonConfigSetReq
+
+ DESCRIPTION
+ This primitive sets the value of the Sme common.
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ deviceConfig - Configuration options in the SME
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ CsrWifiSmeDeviceConfig deviceConfig;
+} CsrWifiSmeSmeCommonConfigSetReq;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeInterfaceCapabilityGetReq
+
+ DESCRIPTION
+ The Wireless Manager calls this primitive to ask the SME for the
+ capabilities of the supported interfaces
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+} CsrWifiSmeInterfaceCapabilityGetReq;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeWpsConfigurationReq
+
+ DESCRIPTION
+ This primitive passes the WPS information for the device to SME. This may
+ be accepted only if no interface is active.
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ wpsConfig - WPS config.
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ CsrWifiSmeWpsConfig wpsConfig;
+} CsrWifiSmeWpsConfigurationReq;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeSetReq
+
+ DESCRIPTION
+ Used to pass custom data to the SME. Format is the same as 802.11 Info
+ Elements => | Id | Length | Data
+ 1) Cmanr Test Mode "Id:0 Length:1 Data:0x00 = OFF 0x01 = ON" "0x00 0x01
+ (0x00|0x01)"
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ dataLength - Number of bytes in the buffer pointed to by 'data'
+ data - Pointer to the buffer containing 'dataLength' bytes
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ u32 dataLength;
+ u8 *data;
+} CsrWifiSmeSetReq;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeActivateCfm
+
+ DESCRIPTION
+ The SME sends this primitive when the activation is complete.
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ status - Reports the result of the request
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ CsrResult status;
+} CsrWifiSmeActivateCfm;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeAdhocConfigGetCfm
+
+ DESCRIPTION
+ This primitive reports the result of the request.
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ status - Reports the result of the request
+ adHocConfig - Contains the values used when starting an Ad-hoc (IBSS)
+ connection.
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ CsrResult status;
+ CsrWifiSmeAdHocConfig adHocConfig;
+} CsrWifiSmeAdhocConfigGetCfm;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeAdhocConfigSetCfm
+
+ DESCRIPTION
+ This primitive reports the result of the request.
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ status - Reports the result of the request
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ CsrResult status;
+} CsrWifiSmeAdhocConfigSetCfm;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeAssociationCompleteInd
+
+ DESCRIPTION
+ The SME will send this primitive to all the tasks that have registered to
+ receive it whenever it completes an attempt to associate with an AP. If
+ the association was successful, status will be set to
+ CSR_WIFI_SME_STATUS_SUCCESS, otherwise status and deauthReason shall be
+ set to appropriate error codes.
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ interfaceTag - Interface Identifier; unique identifier of an interface
+ status - Reports the result of the association procedure
+ connectionInfo - This parameter is relevant only if result is
+ CSR_WIFI_SME_STATUS_SUCCESS:
+ it points to the connection information for the new network
+ deauthReason - This parameter is relevant only if result is not
+ CSR_WIFI_SME_STATUS_SUCCESS:
+ if the AP deauthorised the station, it gives the reason of
+ the deauthorization
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ u16 interfaceTag;
+ CsrResult status;
+ CsrWifiSmeConnectionInfo connectionInfo;
+ CsrWifiSmeIEEE80211Reason deauthReason;
+} CsrWifiSmeAssociationCompleteInd;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeAssociationStartInd
+
+ DESCRIPTION
+ The SME will send this primitive to all the tasks that have registered to
+ receive it whenever it begins an attempt to associate with an AP.
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ interfaceTag - Interface Identifier; unique identifier of an interface
+ address - BSSID of the associating network
+ ssid - Service Set identifier of the associating network
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ u16 interfaceTag;
+ CsrWifiMacAddress address;
+ CsrWifiSsid ssid;
+} CsrWifiSmeAssociationStartInd;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeBlacklistCfm
+
+ DESCRIPTION
+ The SME will call this primitive when the action on the blacklist has
+ completed. For a GET action, this primitive also reports the list of
+ BBSIDs in the blacklist.
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ interfaceTag - Interface Identifier; unique identifier of an interface
+ status - Reports the result of the request
+ action - Action in the request
+ getAddressCount - This parameter is only relevant if action is
+ CSR_WIFI_SME_LIST_ACTION_GET:
+ number of BSSIDs sent with this primitive
+ getAddresses - Pointer to the list of BBSIDs sent with the primitive, set
+ to NULL if none is sent.
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ u16 interfaceTag;
+ CsrResult status;
+ CsrWifiSmeListAction action;
+ u8 getAddressCount;
+ CsrWifiMacAddress *getAddresses;
+} CsrWifiSmeBlacklistCfm;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeCalibrationDataGetCfm
+
+ DESCRIPTION
+ This primitive reports the result of the request.
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ status - Reports the result of the request
+ calibrationDataLength - Number of bytes in the buffer pointed by
+ calibrationData
+ calibrationData - Pointer to a buffer of length calibrationDataLength
+ containing the calibration data
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ CsrResult status;
+ u16 calibrationDataLength;
+ u8 *calibrationData;
+} CsrWifiSmeCalibrationDataGetCfm;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeCalibrationDataSetCfm
+
+ DESCRIPTION
+ This primitive reports the result of the request.
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ status - Reports the result of the request
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ CsrResult status;
+} CsrWifiSmeCalibrationDataSetCfm;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeCcxConfigGetCfm
+
+ DESCRIPTION
+ This primitive reports the result of the request.
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ interfaceTag - Interface Identifier; unique identifier of an interface
+ status - Reports the result of the request
+ ccxConfig - Currently not supported
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ u16 interfaceTag;
+ CsrResult status;
+ CsrWifiSmeCcxConfig ccxConfig;
+} CsrWifiSmeCcxConfigGetCfm;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeCcxConfigSetCfm
+
+ DESCRIPTION
+ This primitive reports the result of the request.
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ interfaceTag - Interface Identifier; unique identifier of an interface
+ status - Reports the result of the request
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ u16 interfaceTag;
+ CsrResult status;
+} CsrWifiSmeCcxConfigSetCfm;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeCoexConfigGetCfm
+
+ DESCRIPTION
+ This primitive reports the result of the request.
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ status - Reports the result of the request
+ coexConfig - Reports the parameters used to configure the coexistence
+ behaviour
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ CsrResult status;
+ CsrWifiSmeCoexConfig coexConfig;
+} CsrWifiSmeCoexConfigGetCfm;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeCoexConfigSetCfm
+
+ DESCRIPTION
+ This primitive reports the result of the request.
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ status - Reports the result of the request
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ CsrResult status;
+} CsrWifiSmeCoexConfigSetCfm;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeCoexInfoGetCfm
+
+ DESCRIPTION
+ This primitive reports the result of the request.
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ status - Reports the result of the request
+ coexInfo - Reports information and state related to coexistence.
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ CsrResult status;
+ CsrWifiSmeCoexInfo coexInfo;
+} CsrWifiSmeCoexInfoGetCfm;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeConnectCfm
+
+ DESCRIPTION
+ The SME calls this primitive when the connection exchange is complete or
+ all connection attempts fail.
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ interfaceTag - Interface Identifier; unique identifier of an interface
+ status - Reports the result of the request.
+ CSR_WIFI_SME_STATUS_NOT_FOUND: all attempts by the SME to
+ locate the requested AP failed
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ u16 interfaceTag;
+ CsrResult status;
+} CsrWifiSmeConnectCfm;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeConnectionConfigGetCfm
+
+ DESCRIPTION
+ This primitive reports the result of the request.
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ interfaceTag - Interface Identifier; unique identifier of an interface
+ status - Reports the result of the request
+ connectionConfig - Parameters used by the SME for selecting a network
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ u16 interfaceTag;
+ CsrResult status;
+ CsrWifiSmeConnectionConfig connectionConfig;
+} CsrWifiSmeConnectionConfigGetCfm;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeConnectionInfoGetCfm
+
+ DESCRIPTION
+ This primitive reports the result of the request.
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ interfaceTag - Interface Identifier; unique identifier of an interface
+ status - Reports the result of the request
+ connectionInfo - Information about the current connection
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ u16 interfaceTag;
+ CsrResult status;
+ CsrWifiSmeConnectionInfo connectionInfo;
+} CsrWifiSmeConnectionInfoGetCfm;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeConnectionQualityInd
+
+ DESCRIPTION
+ The SME sends this primitive to all the tasks that have registered to
+ receive it whenever the value of the current connection quality
+ parameters change by more than a certain configurable amount.
+ The wireless manager application may configure the trigger thresholds for
+ this indication using the field in smeConfig parameter of
+ CSR_WIFI_SME_SME_CONFIG_SET_REQ.
+ Connection quality messages can be suppressed by setting both thresholds
+ to zero.
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ interfaceTag - Interface Identifier; unique identifier of an interface
+ linkQuality - Indicates the quality of the link
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ u16 interfaceTag;
+ CsrWifiSmeLinkQuality linkQuality;
+} CsrWifiSmeConnectionQualityInd;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeConnectionStatsGetCfm
+
+ DESCRIPTION
+ This primitive reports the result of the request.
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ interfaceTag - Interface Identifier; unique identifier of an interface
+ status - Reports the result of the request
+ connectionStats - Statistics for current connection.
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ u16 interfaceTag;
+ CsrResult status;
+ CsrWifiSmeConnectionStats connectionStats;
+} CsrWifiSmeConnectionStatsGetCfm;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeDeactivateCfm
+
+ DESCRIPTION
+ The SME sends this primitive when the deactivation is complete.
+ The WMA cannot send any more primitives until it actives the SME again
+ sending another CSR_WIFI_SME_ACTIVATE_REQ.
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ status - Reports the result of the request
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ CsrResult status;
+} CsrWifiSmeDeactivateCfm;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeDisconnectCfm
+
+ DESCRIPTION
+ On reception of CSR_WIFI_SME_DISCONNECT_REQ the SME will perform a
+ disconnect operation, sending a CsrWifiSmeMediaStatusInd with
+ CSR_WIFI_SME_MEDIA_STATUS_DISCONNECTED and then call this primitive when
+ disconnection is complete.
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ interfaceTag - Interface Identifier; unique identifier of an interface
+ status - Reports the result of the request
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ u16 interfaceTag;
+ CsrResult status;
+} CsrWifiSmeDisconnectCfm;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeEventMaskSetCfm
+
+ DESCRIPTION
+ The SME calls the primitive to report the result of the request
+ primitive.
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ status - Reports the result of the request
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ CsrResult status;
+} CsrWifiSmeEventMaskSetCfm;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeHostConfigGetCfm
+
+ DESCRIPTION
+ This primitive reports the result of the request.
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ interfaceTag - Interface Identifier; unique identifier of an interface
+ status - Reports the result of the request
+ hostConfig - Current host power state.
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ u16 interfaceTag;
+ CsrResult status;
+ CsrWifiSmeHostConfig hostConfig;
+} CsrWifiSmeHostConfigGetCfm;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeHostConfigSetCfm
+
+ DESCRIPTION
+ This primitive reports the result of the request.
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ interfaceTag - Interface Identifier; unique identifier of an interface
+ status - Reports the result of the request
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ u16 interfaceTag;
+ CsrResult status;
+} CsrWifiSmeHostConfigSetCfm;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeIbssStationInd
+
+ DESCRIPTION
+ The SME will send this primitive to indicate that a station has joined or
+ left the ad-hoc network.
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ address - MAC address of the station that has joined or left
+ isconnected - TRUE if the station joined, FALSE if the station left
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ CsrWifiMacAddress address;
+ u8 isconnected;
+} CsrWifiSmeIbssStationInd;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeKeyCfm
+
+ DESCRIPTION
+ The SME calls the primitive to report the result of the request
+ primitive.
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ interfaceTag - Interface Identifier; unique identifier of an interface
+ status - Reports the result of the request
+ action - Action in the request
+ keyType - Type of the key added/deleted
+ peerMacAddress - Peer MAC Address of the key added/deleted
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ u16 interfaceTag;
+ CsrResult status;
+ CsrWifiSmeListAction action;
+ CsrWifiSmeKeyType keyType;
+ CsrWifiMacAddress peerMacAddress;
+} CsrWifiSmeKeyCfm;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeLinkQualityGetCfm
+
+ DESCRIPTION
+ This primitive reports the result of the request.
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ interfaceTag - Interface Identifier; unique identifier of an interface
+ status - Reports the result of the request
+ linkQuality - Indicates the quality of the link
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ u16 interfaceTag;
+ CsrResult status;
+ CsrWifiSmeLinkQuality linkQuality;
+} CsrWifiSmeLinkQualityGetCfm;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeMediaStatusInd
+
+ DESCRIPTION
+ The SME sends this primitive to all the tasks that have registered to
+ receive it when a network connection is established, lost or has moved to
+ another AP.
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ interfaceTag - Interface Identifier; unique identifier of an interface
+ mediaStatus - Indicates the media status
+ connectionInfo - This parameter is relevant only if the mediaStatus is
+ CSR_WIFI_SME_MEDIA_STATUS_CONNECTED:
+ it points to the connection information for the new network
+ disassocReason - This parameter is relevant only if the mediaStatus is
+ CSR_WIFI_SME_MEDIA_STATUS_DISCONNECTED:
+ if a disassociation has occurred it gives the reason of the
+ disassociation
+ deauthReason - This parameter is relevant only if the mediaStatus is
+ CSR_WIFI_SME_MEDIA_STATUS_DISCONNECTED:
+ if a deauthentication has occurred it gives the reason of
+ the deauthentication
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ u16 interfaceTag;
+ CsrWifiSmeMediaStatus mediaStatus;
+ CsrWifiSmeConnectionInfo connectionInfo;
+ CsrWifiSmeIEEE80211Reason disassocReason;
+ CsrWifiSmeIEEE80211Reason deauthReason;
+} CsrWifiSmeMediaStatusInd;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeMibConfigGetCfm
+
+ DESCRIPTION
+ This primitive reports the result of the request.
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ status - Reports the result of the request
+ mibConfig - Reports various IEEE 802.11 attributes as currently configured
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ CsrResult status;
+ CsrWifiSmeMibConfig mibConfig;
+} CsrWifiSmeMibConfigGetCfm;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeMibConfigSetCfm
+
+ DESCRIPTION
+ This primitive reports the result of the request.
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ status - Reports the result of the request
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ CsrResult status;
+} CsrWifiSmeMibConfigSetCfm;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeMibGetCfm
+
+ DESCRIPTION
+ The SME calls this primitive to return the requested MIB variable values.
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ status - Reports the result of the request
+ mibAttributeLength - Length of mibAttribute
+ mibAttribute - Points to the VarBind or VarBindList containing the
+ names and values of the MIB variables requested
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ CsrResult status;
+ u16 mibAttributeLength;
+ u8 *mibAttribute;
+} CsrWifiSmeMibGetCfm;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeMibGetNextCfm
+
+ DESCRIPTION
+ The SME calls this primitive to return the requested MIB name(s).
+ The wireless manager application can then read the value of the MIB
+ variable using CSR_WIFI_SME_MIB_GET_REQ, using the names provided.
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ status - Reports the result of the request
+ mibAttributeLength - Length of mibAttribute
+ mibAttribute - Points to a VarBind or VarBindList containing the
+ name(s) of the MIB variable(s) lexicographically
+ following the name(s) given in the request
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ CsrResult status;
+ u16 mibAttributeLength;
+ u8 *mibAttribute;
+} CsrWifiSmeMibGetNextCfm;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeMibSetCfm
+
+ DESCRIPTION
+ The SME calls the primitive to report the result of the set primitive.
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ status - Reports the result of the request
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ CsrResult status;
+} CsrWifiSmeMibSetCfm;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeMicFailureInd
+
+ DESCRIPTION
+ The SME sends this primitive to all the tasks that have registered to
+ receive it whenever the chip firmware reports a MIC failure.
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ interfaceTag - Interface Identifier; unique identifier of an interface
+ secondFailure - TRUE if this indication is for a second failure in 60
+ seconds
+ count - The number of MIC failure events since the connection was
+ established
+ address - MAC address of the transmitter that caused the MIC failure
+ keyType - Type of key for which the failure occurred
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ u16 interfaceTag;
+ u8 secondFailure;
+ u16 count;
+ CsrWifiMacAddress address;
+ CsrWifiSmeKeyType keyType;
+} CsrWifiSmeMicFailureInd;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeMulticastAddressCfm
+
+ DESCRIPTION
+ The SME will call this primitive when the operation is complete. For a
+ GET action, this primitive reports the current list of MAC addresses.
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ interfaceTag - Interface Identifier; unique identifier of an interface
+ status - Reports the result of the request
+ action - Action in the request
+ getAddressesCount - This parameter is only relevant if action is
+ CSR_WIFI_SME_LIST_ACTION_GET:
+ number of MAC addresses sent with the primitive
+ getAddresses - Pointer to the list of MAC Addresses sent with the
+ primitive, set to NULL if none is sent.
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ u16 interfaceTag;
+ CsrResult status;
+ CsrWifiSmeListAction action;
+ u8 getAddressesCount;
+ CsrWifiMacAddress *getAddresses;
+} CsrWifiSmeMulticastAddressCfm;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmePacketFilterSetCfm
+
+ DESCRIPTION
+ The SME calls the primitive to report the result of the set primitive.
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ interfaceTag - Interface Identifier; unique identifier of an interface
+ status - Reports the result of the request
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ u16 interfaceTag;
+ CsrResult status;
+} CsrWifiSmePacketFilterSetCfm;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmePermanentMacAddressGetCfm
+
+ DESCRIPTION
+ This primitive reports the result of the request.
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ status - Reports the result of the request
+ permanentMacAddress - MAC address stored in the EEPROM
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ CsrResult status;
+ CsrWifiMacAddress permanentMacAddress;
+} CsrWifiSmePermanentMacAddressGetCfm;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmePmkidCandidateListInd
+
+ DESCRIPTION
+ The SME will send this primitive to all the tasks that have registered to
+ receive it when a new network supporting preauthentication and/or PMK
+ caching is seen.
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ interfaceTag - Interface Identifier; unique identifier of an
+ interface
+ pmkidCandidatesCount - Number of PMKID candidates provided
+ pmkidCandidates - Points to the first PMKID candidate
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ u16 interfaceTag;
+ u8 pmkidCandidatesCount;
+ CsrWifiSmePmkidCandidate *pmkidCandidates;
+} CsrWifiSmePmkidCandidateListInd;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmePmkidCfm
+
+ DESCRIPTION
+ The SME will call this primitive when the operation is complete. For a
+ GET action, this primitive reports the current list of PMKIDs
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ interfaceTag - Interface Identifier; unique identifier of an interface
+ status - Reports the result of the request
+ action - Action in the request
+ getPmkidsCount - This parameter is only relevant if action is
+ CSR_WIFI_SME_LIST_ACTION_GET:
+ number of PMKIDs sent with the primitive
+ getPmkids - Pointer to the list of PMKIDs sent with the primitive, set
+ to NULL if none is sent.
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ u16 interfaceTag;
+ CsrResult status;
+ CsrWifiSmeListAction action;
+ u8 getPmkidsCount;
+ CsrWifiSmePmkid *getPmkids;
+} CsrWifiSmePmkidCfm;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmePowerConfigGetCfm
+
+ DESCRIPTION
+ This primitive reports the result of the request.
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ status - Reports the result of the request
+ powerConfig - Returns the current parameters for the power configuration of
+ the firmware
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ CsrResult status;
+ CsrWifiSmePowerConfig powerConfig;
+} CsrWifiSmePowerConfigGetCfm;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmePowerConfigSetCfm
+
+ DESCRIPTION
+ This primitive reports the result of the request.
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ status - Reports the result of the request
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ CsrResult status;
+} CsrWifiSmePowerConfigSetCfm;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeRegulatoryDomainInfoGetCfm
+
+ DESCRIPTION
+ This primitive reports the result of the request.
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ status - Reports the result of the request
+ regDomInfo - Reports information and state related to regulatory domain
+ operation.
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ CsrResult status;
+ CsrWifiSmeRegulatoryDomainInfo regDomInfo;
+} CsrWifiSmeRegulatoryDomainInfoGetCfm;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeRoamCompleteInd
+
+ DESCRIPTION
+ The SME will send this primitive to all the tasks that have registered to
+ receive it whenever it completes an attempt to roam to an AP. If the roam
+ attempt was successful, status will be set to CSR_WIFI_SME_SUCCESS,
+ otherwise it shall be set to the appropriate error code.
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ interfaceTag - Interface Identifier; unique identifier of an interface
+ status - Reports the result of the roaming procedure
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ u16 interfaceTag;
+ CsrResult status;
+} CsrWifiSmeRoamCompleteInd;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeRoamStartInd
+
+ DESCRIPTION
+ The SME will send this primitive to all the tasks that have registered to
+ receive it whenever it begins an attempt to roam to an AP.
+ If the wireless manager application connect request specified the SSID
+ and the BSSID was set to the broadcast address (0xFF 0xFF 0xFF 0xFF 0xFF
+ 0xFF), the SME monitors the signal quality and maintains a list of
+ candidates to roam to. When the signal quality of the current connection
+ falls below a threshold, and there is a candidate with better quality,
+ the SME will attempt to the candidate AP.
+ If the roaming procedure succeeds, the SME will also issue a Media
+ Connect indication to inform the wireless manager application of the
+ change.
+ NOTE: to prevent the SME from initiating roaming the WMA must specify the
+ BSSID in the connection request; this forces the SME to connect only to
+ that AP.
+ The wireless manager application can obtain statistics for roaming
+ purposes using CSR_WIFI_SME_CONNECTION_QUALITY_IND and
+ CSR_WIFI_SME_CONNECTION_STATS_GET_REQ.
+ When the wireless manager application wishes to roam to another AP, it
+ must issue a connection request specifying the BSSID of the desired AP.
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ interfaceTag - Interface Identifier; unique identifier of an interface
+ roamReason - Indicates the reason for starting the roaming procedure
+ reason80211 - Indicates the reason for deauthentication or disassociation
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ u16 interfaceTag;
+ CsrWifiSmeRoamReason roamReason;
+ CsrWifiSmeIEEE80211Reason reason80211;
+} CsrWifiSmeRoamStartInd;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeRoamingConfigGetCfm
+
+ DESCRIPTION
+ This primitive reports the result of the request.
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ interfaceTag - Interface Identifier; unique identifier of an interface
+ status - Reports the result of the request
+ roamingConfig - Reports the roaming behaviour of the driver and firmware
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ u16 interfaceTag;
+ CsrResult status;
+ CsrWifiSmeRoamingConfig roamingConfig;
+} CsrWifiSmeRoamingConfigGetCfm;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeRoamingConfigSetCfm
+
+ DESCRIPTION
+ This primitive sets the value of the RoamingConfig parameter.
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ interfaceTag - Interface Identifier; unique identifier of an interface
+ status - Reports the result of the request
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ u16 interfaceTag;
+ CsrResult status;
+} CsrWifiSmeRoamingConfigSetCfm;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeScanConfigGetCfm
+
+ DESCRIPTION
+ This primitive reports the result of the request.
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ status - Reports the result of the request
+ scanConfig - Returns the current parameters for the autonomous scanning
+ behaviour of the firmware
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ CsrResult status;
+ CsrWifiSmeScanConfig scanConfig;
+} CsrWifiSmeScanConfigGetCfm;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeScanConfigSetCfm
+
+ DESCRIPTION
+ This primitive reports the result of the request.
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ status - Reports the result of the request
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ CsrResult status;
+} CsrWifiSmeScanConfigSetCfm;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeScanFullCfm
+
+ DESCRIPTION
+ The SME calls this primitive when the results from the scan are
+ available.
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ status - Reports the result of the request
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ CsrResult status;
+} CsrWifiSmeScanFullCfm;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeScanResultInd
+
+ DESCRIPTION
+ The SME sends this primitive to all the tasks that have registered to
+ receive it whenever a scan indication is received from the firmware.
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ result - Points to a buffer containing a scan result.
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ CsrWifiSmeScanResult result;
+} CsrWifiSmeScanResultInd;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeScanResultsFlushCfm
+
+ DESCRIPTION
+ The SME will call this primitive when the cache has been cleared.
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ status - Reports the result of the request
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ CsrResult status;
+} CsrWifiSmeScanResultsFlushCfm;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeScanResultsGetCfm
+
+ DESCRIPTION
+ The SME sends this primitive to provide the current set of scan results.
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ status - Reports the result of the request
+ scanResultsCount - Number of scan results
+ scanResults - Points to a buffer containing an array of
+ CsrWifiSmeScanResult structures.
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ CsrResult status;
+ u16 scanResultsCount;
+ CsrWifiSmeScanResult *scanResults;
+} CsrWifiSmeScanResultsGetCfm;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeSmeStaConfigGetCfm
+
+ DESCRIPTION
+ This primitive reports the result of the request.
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ interfaceTag - Interface Identifier; unique identifier of an interface
+ status - Reports the result of the request
+ smeConfig - Current SME Station Parameters
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ u16 interfaceTag;
+ CsrResult status;
+ CsrWifiSmeStaConfig smeConfig;
+} CsrWifiSmeSmeStaConfigGetCfm;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeSmeStaConfigSetCfm
+
+ DESCRIPTION
+ This primitive reports the result of the request.
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ interfaceTag - Interface Identifier; unique identifier of an interface
+ status - Reports the result of the request
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ u16 interfaceTag;
+ CsrResult status;
+} CsrWifiSmeSmeStaConfigSetCfm;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeStationMacAddressGetCfm
+
+ DESCRIPTION
+ This primitive reports the result of the request.
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ status - Reports the result of the request
+ stationMacAddress - Current MAC address of the station.
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ CsrResult status;
+ CsrWifiMacAddress stationMacAddress[2];
+} CsrWifiSmeStationMacAddressGetCfm;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeTspecInd
+
+ DESCRIPTION
+ The SME will send this primitive to all the task that have registered to
+ receive it when a status change in the TSPEC occurs.
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ interfaceTag - Interface Identifier; unique identifier of an interface
+ transactionId - Unique Transaction ID for the TSPEC, as assigned by the
+ driver
+ tspecResultCode - Specifies the TSPEC operation requested by the peer
+ station
+ tspecLength - Length of the TSPEC.
+ tspec - Points to the first byte of the TSPEC
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ u16 interfaceTag;
+ u32 transactionId;
+ CsrWifiSmeTspecResultCode tspecResultCode;
+ u16 tspecLength;
+ u8 *tspec;
+} CsrWifiSmeTspecInd;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeTspecCfm
+
+ DESCRIPTION
+ The SME calls the primitive to report the result of the TSpec primitive
+ request.
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ interfaceTag - Interface Identifier; unique identifier of an interface
+ status - Reports the result of the request
+ transactionId - Unique Transaction ID for the TSPEC, as assigned by the
+ driver
+ tspecResultCode - Specifies the result of the negotiated TSPEC operation
+ tspecLength - Length of the TSPEC.
+ tspec - Points to the first byte of the TSPEC
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ u16 interfaceTag;
+ CsrResult status;
+ u32 transactionId;
+ CsrWifiSmeTspecResultCode tspecResultCode;
+ u16 tspecLength;
+ u8 *tspec;
+} CsrWifiSmeTspecCfm;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeVersionsGetCfm
+
+ DESCRIPTION
+ This primitive reports the result of the request.
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ status - Reports the result of the request
+ versions - Version IDs of the product
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ CsrResult status;
+ CsrWifiSmeVersions versions;
+} CsrWifiSmeVersionsGetCfm;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeWifiFlightmodeCfm
+
+ DESCRIPTION
+ The SME calls this primitive when the chip is initialised for low power
+ mode and with the radio subsystem disabled. To leave flight mode, and
+ enable Wi-Fi, the wireless manager application should call
+ CSR_WIFI_SME_WIFI_ON_REQ.
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ status - Reports the result of the request
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ CsrResult status;
+} CsrWifiSmeWifiFlightmodeCfm;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeWifiOffInd
+
+ DESCRIPTION
+ The SME sends this primitive to all the tasks that have registered to
+ receive it to report that the chip has been turned off.
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ reason - Indicates the reason why the Wi-Fi has been switched off.
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ CsrWifiSmeControlIndication reason;
+} CsrWifiSmeWifiOffInd;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeWifiOffCfm
+
+ DESCRIPTION
+ After receiving CSR_WIFI_SME_WIFI_OFF_REQ, if the chip is connected to a
+ network, the SME will perform a disconnect operation, will send a
+ CSR_WIFI_SME_MEDIA_STATUS_IND with
+ CSR_WIFI_SME_MEDIA_STATUS_DISCONNECTED, and then will call
+ CSR_WIFI_SME_WIFI_OFF_CFM when the chip is off.
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ status - Reports the result of the request
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ CsrResult status;
+} CsrWifiSmeWifiOffCfm;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeWifiOnCfm
+
+ DESCRIPTION
+ The SME sends this primitive to the task that has sent the request once
+ the chip has been initialised and is available for use.
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ status - Reports the result of the request
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ CsrResult status;
+} CsrWifiSmeWifiOnCfm;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeCloakedSsidsSetCfm
+
+ DESCRIPTION
+ This primitive reports the result of the request.
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ status - Reports the result of the request
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ CsrResult status;
+} CsrWifiSmeCloakedSsidsSetCfm;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeCloakedSsidsGetCfm
+
+ DESCRIPTION
+ This primitive reports the result of the request.
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ status - Reports the result of the request
+ cloakedSsids - Reports list of cloaked SSIDs that are explicitly scanned for
+ by the driver
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ CsrResult status;
+ CsrWifiSmeCloakedSsidConfig cloakedSsids;
+} CsrWifiSmeCloakedSsidsGetCfm;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeWifiOnInd
+
+ DESCRIPTION
+ The SME sends this primitive to all tasks that have registered to receive
+ it once the chip becomes available and ready to use.
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ address - Current MAC address
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ CsrWifiMacAddress address;
+} CsrWifiSmeWifiOnInd;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeSmeCommonConfigGetCfm
+
+ DESCRIPTION
+ This primitive reports the result of the request.
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ status - Reports the result of the request
+ deviceConfig - Configuration options in the SME
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ CsrResult status;
+ CsrWifiSmeDeviceConfig deviceConfig;
+} CsrWifiSmeSmeCommonConfigGetCfm;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeSmeCommonConfigSetCfm
+
+ DESCRIPTION
+ Reports the result of the request
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ status - Reports the result of the request
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ CsrResult status;
+} CsrWifiSmeSmeCommonConfigSetCfm;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeInterfaceCapabilityGetCfm
+
+ DESCRIPTION
+ This primitive reports the result of the request.
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ status - Result of the request
+ numInterfaces - Number of the interfaces supported
+ capBitmap - Points to the list of capabilities bitmaps provided for each
+ interface.
+ The bits represent the following capabilities:
+ -bits 7 to 4-Reserved
+ -bit 3-AMP
+ -bit 2-P2P
+ -bit 1-AP
+ -bit 0-STA
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ CsrResult status;
+ u16 numInterfaces;
+ u8 capBitmap[2];
+} CsrWifiSmeInterfaceCapabilityGetCfm;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeErrorInd
+
+ DESCRIPTION
+ Important error message indicating a error of some importance
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ errorMessage - Contains the error message.
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ char *errorMessage;
+} CsrWifiSmeErrorInd;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeInfoInd
+
+ DESCRIPTION
+ Message indicating a some info about current activity. Mostly of interest
+ in testing but may be useful in the field.
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ infoMessage - Contains the message.
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ char *infoMessage;
+} CsrWifiSmeInfoInd;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeCoreDumpInd
+
+ DESCRIPTION
+ The SME will send this primitive to all the tasks that have registered to
+ receive Wi-Fi Chip core dump data.
+ The core dump data may be fragmented and sent using more than one
+ indication.
+ To indicate that all the data has been sent, the last indication contains
+ a 'length' of 0 and 'data' of NULL.
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ dataLength - Number of bytes in the buffer pointed to by 'data'
+ data - Pointer to the buffer containing 'dataLength' bytes of core
+ dump data
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ u32 dataLength;
+ u8 *data;
+} CsrWifiSmeCoreDumpInd;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeAmpStatusChangeInd
+
+ DESCRIPTION
+ Indication of change to AMP activity.
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ interfaceTag - Interface on which the AMP activity changed.
+ ampStatus - The new status of AMP activity.Range: {AMP_ACTIVE,
+ AMP_INACTIVE}.
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ u16 interfaceTag;
+ CsrWifiSmeAmpStatus ampStatus;
+} CsrWifiSmeAmpStatusChangeInd;
+
+/*******************************************************************************
+
+ NAME
+ CsrWifiSmeWpsConfigurationCfm
+
+ DESCRIPTION
+ Confirm.
+
+ MEMBERS
+ common - Common header for use with the CsrWifiFsm Module
+ status - Status of the request.
+
+*******************************************************************************/
+typedef struct
+{
+ CsrWifiFsmEvent common;
+ CsrResult status;
+} CsrWifiSmeWpsConfigurationCfm;
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* CSR_WIFI_SME_PRIM_H__ */
+
diff --git a/drivers/staging/csr/csr_wifi_sme_sef.c b/drivers/staging/csr/csr_wifi_sme_sef.c
new file mode 100644
index 000000000000..cf32254335c4
--- /dev/null
+++ b/drivers/staging/csr/csr_wifi_sme_sef.c
@@ -0,0 +1,85 @@
+/*****************************************************************************
+
+ (c) Cambridge Silicon Radio Limited 2010
+ Confidential information of CSR
+
+ Refer to LICENSE.txt included with this source for details
+ on the license terms.
+
+ *****************************************************************************/
+#include "csr_wifi_sme_sef.h"
+
+const CsrWifiSmeStateHandlerType CsrWifiSmeUpstreamStateHandlers[CSR_WIFI_SME_PRIM_UPSTREAM_COUNT] =
+{
+ /* 0x8000 */ CsrWifiSmeActivateCfmHandler,
+ /* 0x8001 */ CsrWifiSmeAdhocConfigGetCfmHandler,
+ /* 0x8002 */ CsrWifiSmeAdhocConfigSetCfmHandler,
+ /* 0x8003 */ CsrWifiSmeAssociationCompleteIndHandler,
+ /* 0x8004 */ CsrWifiSmeAssociationStartIndHandler,
+ /* 0x8005 */ CsrWifiSmeBlacklistCfmHandler,
+ /* 0x8006 */ CsrWifiSmeCalibrationDataGetCfmHandler,
+ /* 0x8007 */ CsrWifiSmeCalibrationDataSetCfmHandler,
+ /* 0x8008 */ CsrWifiSmeCcxConfigGetCfmHandler,
+ /* 0x8009 */ CsrWifiSmeCcxConfigSetCfmHandler,
+ /* 0x800A */ CsrWifiSmeCoexConfigGetCfmHandler,
+ /* 0x800B */ CsrWifiSmeCoexConfigSetCfmHandler,
+ /* 0x800C */ CsrWifiSmeCoexInfoGetCfmHandler,
+ /* 0x800D */ CsrWifiSmeConnectCfmHandler,
+ /* 0x800E */ CsrWifiSmeConnectionConfigGetCfmHandler,
+ /* 0x800F */ CsrWifiSmeConnectionInfoGetCfmHandler,
+ /* 0x8010 */ CsrWifiSmeConnectionQualityIndHandler,
+ /* 0x8011 */ CsrWifiSmeConnectionStatsGetCfmHandler,
+ /* 0x8012 */ CsrWifiSmeDeactivateCfmHandler,
+ /* 0x8013 */ CsrWifiSmeDisconnectCfmHandler,
+ /* 0x8014 */ CsrWifiSmeEventMaskSetCfmHandler,
+ /* 0x8015 */ CsrWifiSmeHostConfigGetCfmHandler,
+ /* 0x8016 */ CsrWifiSmeHostConfigSetCfmHandler,
+ /* 0x8017 */ CsrWifiSmeIbssStationIndHandler,
+ /* 0x8018 */ CsrWifiSmeKeyCfmHandler,
+ /* 0x8019 */ CsrWifiSmeLinkQualityGetCfmHandler,
+ /* 0x801A */ CsrWifiSmeMediaStatusIndHandler,
+ /* 0x801B */ CsrWifiSmeMibConfigGetCfmHandler,
+ /* 0x801C */ CsrWifiSmeMibConfigSetCfmHandler,
+ /* 0x801D */ CsrWifiSmeMibGetCfmHandler,
+ /* 0x801E */ CsrWifiSmeMibGetNextCfmHandler,
+ /* 0x801F */ CsrWifiSmeMibSetCfmHandler,
+ /* 0x8020 */ CsrWifiSmeMicFailureIndHandler,
+ /* 0x8021 */ CsrWifiSmeMulticastAddressCfmHandler,
+ /* 0x8022 */ CsrWifiSmePacketFilterSetCfmHandler,
+ /* 0x8023 */ CsrWifiSmePermanentMacAddressGetCfmHandler,
+ /* 0x8024 */ CsrWifiSmePmkidCandidateListIndHandler,
+ /* 0x8025 */ CsrWifiSmePmkidCfmHandler,
+ /* 0x8026 */ CsrWifiSmePowerConfigGetCfmHandler,
+ /* 0x8027 */ CsrWifiSmePowerConfigSetCfmHandler,
+ /* 0x8028 */ CsrWifiSmeRegulatoryDomainInfoGetCfmHandler,
+ /* 0x8029 */ CsrWifiSmeRoamCompleteIndHandler,
+ /* 0x802A */ CsrWifiSmeRoamStartIndHandler,
+ /* 0x802B */ CsrWifiSmeRoamingConfigGetCfmHandler,
+ /* 0x802C */ CsrWifiSmeRoamingConfigSetCfmHandler,
+ /* 0x802D */ CsrWifiSmeScanConfigGetCfmHandler,
+ /* 0x802E */ CsrWifiSmeScanConfigSetCfmHandler,
+ /* 0x802F */ CsrWifiSmeScanFullCfmHandler,
+ /* 0x8030 */ CsrWifiSmeScanResultIndHandler,
+ /* 0x8031 */ CsrWifiSmeScanResultsFlushCfmHandler,
+ /* 0x8032 */ CsrWifiSmeScanResultsGetCfmHandler,
+ /* 0x8033 */ CsrWifiSmeSmeStaConfigGetCfmHandler,
+ /* 0x8034 */ CsrWifiSmeSmeStaConfigSetCfmHandler,
+ /* 0x8035 */ CsrWifiSmeStationMacAddressGetCfmHandler,
+ /* 0x8036 */ CsrWifiSmeTspecIndHandler,
+ /* 0x8037 */ CsrWifiSmeTspecCfmHandler,
+ /* 0x8038 */ CsrWifiSmeVersionsGetCfmHandler,
+ /* 0x8039 */ CsrWifiSmeWifiFlightmodeCfmHandler,
+ /* 0x803A */ CsrWifiSmeWifiOffIndHandler,
+ /* 0x803B */ CsrWifiSmeWifiOffCfmHandler,
+ /* 0x803C */ CsrWifiSmeWifiOnCfmHandler,
+ /* 0x803D */ CsrWifiSmeCloakedSsidsSetCfmHandler,
+ /* 0x803E */ CsrWifiSmeCloakedSsidsGetCfmHandler,
+ /* 0x803F */ CsrWifiSmeWifiOnIndHandler,
+ /* 0x8040 */ CsrWifiSmeSmeCommonConfigGetCfmHandler,
+ /* 0x8041 */ CsrWifiSmeSmeCommonConfigSetCfmHandler,
+ /* 0x8042 */ CsrWifiSmeGetInterfaceCapabilityCfmHandler,
+ /* 0x8043 */ CsrWifiSmeErrorIndHandler,
+ /* 0x8044 */ CsrWifiSmeInfoIndHandler,
+ /* 0x8045 */ CsrWifiSmeCoreDumpIndHandler,
+ /* 0x8046 */ CsrWifiSmeAmpStatusChangeIndHandler,
+};
diff --git a/drivers/staging/csr/csr_wifi_sme_sef.h b/drivers/staging/csr/csr_wifi_sme_sef.h
new file mode 100644
index 000000000000..c8741811b2e4
--- /dev/null
+++ b/drivers/staging/csr/csr_wifi_sme_sef.h
@@ -0,0 +1,101 @@
+/*****************************************************************************
+
+ (c) Cambridge Silicon Radio Limited 2010
+ Confidential information of CSR
+
+ Refer to LICENSE.txt included with this source for details
+ on the license terms.
+
+*****************************************************************************/
+#ifndef CSR_WIFI_ROUTER_SEF_CSR_WIFI_SME_H__
+#define CSR_WIFI_ROUTER_SEF_CSR_WIFI_SME_H__
+
+#include "csr_wifi_sme_prim.h"
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef void (*CsrWifiSmeStateHandlerType)(void* drvpriv, CsrWifiFsmEvent* msg);
+
+extern const CsrWifiSmeStateHandlerType CsrWifiSmeUpstreamStateHandlers[CSR_WIFI_SME_PRIM_UPSTREAM_COUNT];
+
+
+extern void CsrWifiSmeActivateCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg);
+extern void CsrWifiSmeAdhocConfigGetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg);
+extern void CsrWifiSmeAdhocConfigSetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg);
+extern void CsrWifiSmeAssociationCompleteIndHandler(void* drvpriv, CsrWifiFsmEvent* msg);
+extern void CsrWifiSmeAssociationStartIndHandler(void* drvpriv, CsrWifiFsmEvent* msg);
+extern void CsrWifiSmeBlacklistCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg);
+extern void CsrWifiSmeCalibrationDataGetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg);
+extern void CsrWifiSmeCalibrationDataSetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg);
+extern void CsrWifiSmeCcxConfigGetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg);
+extern void CsrWifiSmeCcxConfigSetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg);
+extern void CsrWifiSmeCoexConfigGetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg);
+extern void CsrWifiSmeCoexConfigSetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg);
+extern void CsrWifiSmeCoexInfoGetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg);
+extern void CsrWifiSmeConnectCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg);
+extern void CsrWifiSmeConnectionConfigGetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg);
+extern void CsrWifiSmeConnectionInfoGetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg);
+extern void CsrWifiSmeConnectionQualityIndHandler(void* drvpriv, CsrWifiFsmEvent* msg);
+extern void CsrWifiSmeConnectionStatsGetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg);
+extern void CsrWifiSmeDeactivateCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg);
+extern void CsrWifiSmeDisconnectCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg);
+extern void CsrWifiSmeEventMaskSetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg);
+extern void CsrWifiSmeHostConfigGetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg);
+extern void CsrWifiSmeHostConfigSetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg);
+extern void CsrWifiSmeIbssStationIndHandler(void* drvpriv, CsrWifiFsmEvent* msg);
+extern void CsrWifiSmeKeyCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg);
+extern void CsrWifiSmeLinkQualityGetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg);
+extern void CsrWifiSmeMediaStatusIndHandler(void* drvpriv, CsrWifiFsmEvent* msg);
+extern void CsrWifiSmeMibConfigGetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg);
+extern void CsrWifiSmeMibConfigSetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg);
+extern void CsrWifiSmeMibGetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg);
+extern void CsrWifiSmeMibGetNextCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg);
+extern void CsrWifiSmeMibSetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg);
+extern void CsrWifiSmeMicFailureIndHandler(void* drvpriv, CsrWifiFsmEvent* msg);
+extern void CsrWifiSmeMulticastAddressCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg);
+extern void CsrWifiSmePacketFilterSetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg);
+extern void CsrWifiSmePermanentMacAddressGetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg);
+extern void CsrWifiSmePmkidCandidateListIndHandler(void* drvpriv, CsrWifiFsmEvent* msg);
+extern void CsrWifiSmePmkidCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg);
+extern void CsrWifiSmePowerConfigGetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg);
+extern void CsrWifiSmePowerConfigSetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg);
+extern void CsrWifiSmeRegulatoryDomainInfoGetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg);
+extern void CsrWifiSmeRoamCompleteIndHandler(void* drvpriv, CsrWifiFsmEvent* msg);
+extern void CsrWifiSmeRoamStartIndHandler(void* drvpriv, CsrWifiFsmEvent* msg);
+extern void CsrWifiSmeRoamingConfigGetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg);
+extern void CsrWifiSmeRoamingConfigSetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg);
+extern void CsrWifiSmeScanConfigGetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg);
+extern void CsrWifiSmeScanConfigSetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg);
+extern void CsrWifiSmeScanFullCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg);
+extern void CsrWifiSmeScanResultIndHandler(void* drvpriv, CsrWifiFsmEvent* msg);
+extern void CsrWifiSmeScanResultsFlushCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg);
+extern void CsrWifiSmeScanResultsGetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg);
+extern void CsrWifiSmeSmeStaConfigGetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg);
+extern void CsrWifiSmeSmeStaConfigSetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg);
+extern void CsrWifiSmeStationMacAddressGetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg);
+extern void CsrWifiSmeTspecIndHandler(void* drvpriv, CsrWifiFsmEvent* msg);
+extern void CsrWifiSmeTspecCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg);
+extern void CsrWifiSmeVersionsGetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg);
+extern void CsrWifiSmeWifiFlightmodeCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg);
+extern void CsrWifiSmeWifiOffIndHandler(void* drvpriv, CsrWifiFsmEvent* msg);
+extern void CsrWifiSmeWifiOffCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg);
+extern void CsrWifiSmeWifiOnCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg);
+extern void CsrWifiSmeCloakedSsidsSetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg);
+extern void CsrWifiSmeCloakedSsidsGetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg);
+extern void CsrWifiSmeWifiOnIndHandler(void* drvpriv, CsrWifiFsmEvent* msg);
+extern void CsrWifiSmeSmeCommonConfigGetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg);
+extern void CsrWifiSmeSmeCommonConfigSetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg);
+extern void CsrWifiSmeGetInterfaceCapabilityCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg);
+extern void CsrWifiSmeErrorIndHandler(void* drvpriv, CsrWifiFsmEvent* msg);
+extern void CsrWifiSmeInfoIndHandler(void* drvpriv, CsrWifiFsmEvent* msg);
+extern void CsrWifiSmeCoreDumpIndHandler(void* drvpriv, CsrWifiFsmEvent* msg);
+extern void CsrWifiSmeAmpStatusChangeIndHandler(void* drvpriv, CsrWifiFsmEvent* msg);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* CSR_WIFI_ROUTER_SEF_CSR_WIFI_SME_H__ */
diff --git a/drivers/staging/csr/csr_wifi_sme_serialize.c b/drivers/staging/csr/csr_wifi_sme_serialize.c
new file mode 100644
index 000000000000..7d7e1d8b5ed3
--- /dev/null
+++ b/drivers/staging/csr/csr_wifi_sme_serialize.c
@@ -0,0 +1,5809 @@
+/*****************************************************************************
+
+ (c) Cambridge Silicon Radio Limited 2012
+ All rights reserved and confidential information of CSR
+
+ Refer to LICENSE.txt included with this source for details
+ on the license terms.
+
+*****************************************************************************/
+
+/* Note: this is an auto-generated file. */
+#include <linux/string.h>
+#include <linux/slab.h>
+#include "csr_msgconv.h"
+#include "csr_wifi_sme_prim.h"
+#include "csr_wifi_sme_serialize.h"
+
+void CsrWifiSmePfree(void *ptr)
+{
+ kfree(ptr);
+}
+
+
+size_t CsrWifiSmeAdhocConfigSetReqSizeof(void *msg)
+{
+ size_t bufferSize = 2;
+
+ /* Calculate the Size of the Serialised Data. Could be more efficient (Try 11) */
+ bufferSize += 2; /* u16 primitive->adHocConfig.atimWindowTu */
+ bufferSize += 2; /* u16 primitive->adHocConfig.beaconPeriodTu */
+ bufferSize += 2; /* u16 primitive->adHocConfig.joinOnlyAttempts */
+ bufferSize += 2; /* u16 primitive->adHocConfig.joinAttemptIntervalMs */
+ return bufferSize;
+}
+
+
+u8* CsrWifiSmeAdhocConfigSetReqSer(u8 *ptr, size_t *len, void *msg)
+{
+ CsrWifiSmeAdhocConfigSetReq *primitive = (CsrWifiSmeAdhocConfigSetReq *)msg;
+ *len = 0;
+ CsrUint16Ser(ptr, len, primitive->common.type);
+ CsrUint16Ser(ptr, len, (u16) primitive->adHocConfig.atimWindowTu);
+ CsrUint16Ser(ptr, len, (u16) primitive->adHocConfig.beaconPeriodTu);
+ CsrUint16Ser(ptr, len, (u16) primitive->adHocConfig.joinOnlyAttempts);
+ CsrUint16Ser(ptr, len, (u16) primitive->adHocConfig.joinAttemptIntervalMs);
+ return(ptr);
+}
+
+
+void* CsrWifiSmeAdhocConfigSetReqDes(u8 *buffer, size_t length)
+{
+ CsrWifiSmeAdhocConfigSetReq *primitive = kmalloc(sizeof(CsrWifiSmeAdhocConfigSetReq), GFP_KERNEL);
+ size_t offset;
+ offset = 0;
+
+ CsrUint16Des(&primitive->common.type, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->adHocConfig.atimWindowTu, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->adHocConfig.beaconPeriodTu, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->adHocConfig.joinOnlyAttempts, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->adHocConfig.joinAttemptIntervalMs, buffer, &offset);
+
+ return primitive;
+}
+
+
+size_t CsrWifiSmeBlacklistReqSizeof(void *msg)
+{
+ CsrWifiSmeBlacklistReq *primitive = (CsrWifiSmeBlacklistReq *) msg;
+ size_t bufferSize = 2;
+
+ /* Calculate the Size of the Serialised Data. Could be more efficient (Try 13) */
+ bufferSize += 2; /* u16 primitive->interfaceTag */
+ bufferSize += 1; /* CsrWifiSmeListAction primitive->action */
+ bufferSize += 1; /* u8 primitive->setAddressCount */
+ {
+ u16 i1;
+ for (i1 = 0; i1 < primitive->setAddressCount; i1++)
+ {
+ bufferSize += 6; /* u8 primitive->setAddresses[i1].a[6] */
+ }
+ }
+ return bufferSize;
+}
+
+
+u8* CsrWifiSmeBlacklistReqSer(u8 *ptr, size_t *len, void *msg)
+{
+ CsrWifiSmeBlacklistReq *primitive = (CsrWifiSmeBlacklistReq *)msg;
+ *len = 0;
+ CsrUint16Ser(ptr, len, primitive->common.type);
+ CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
+ CsrUint8Ser(ptr, len, (u8) primitive->action);
+ CsrUint8Ser(ptr, len, (u8) primitive->setAddressCount);
+ {
+ u16 i1;
+ for (i1 = 0; i1 < primitive->setAddressCount; i1++)
+ {
+ CsrMemCpySer(ptr, len, (const void *) primitive->setAddresses[i1].a, ((u16) (6)));
+ }
+ }
+ return(ptr);
+}
+
+
+void* CsrWifiSmeBlacklistReqDes(u8 *buffer, size_t length)
+{
+ CsrWifiSmeBlacklistReq *primitive = kmalloc(sizeof(CsrWifiSmeBlacklistReq), GFP_KERNEL);
+ size_t offset;
+ offset = 0;
+
+ CsrUint16Des(&primitive->common.type, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->action, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->setAddressCount, buffer, &offset);
+ primitive->setAddresses = NULL;
+ if (primitive->setAddressCount)
+ {
+ primitive->setAddresses = kmalloc(sizeof(CsrWifiMacAddress) * primitive->setAddressCount, GFP_KERNEL);
+ }
+ {
+ u16 i1;
+ for (i1 = 0; i1 < primitive->setAddressCount; i1++)
+ {
+ CsrMemCpyDes(primitive->setAddresses[i1].a, buffer, &offset, ((u16) (6)));
+ }
+ }
+
+ return primitive;
+}
+
+
+void CsrWifiSmeBlacklistReqSerFree(void *voidPrimitivePointer)
+{
+ CsrWifiSmeBlacklistReq *primitive = (CsrWifiSmeBlacklistReq *) voidPrimitivePointer;
+ kfree(primitive->setAddresses);
+ kfree(primitive);
+}
+
+
+size_t CsrWifiSmeCalibrationDataSetReqSizeof(void *msg)
+{
+ CsrWifiSmeCalibrationDataSetReq *primitive = (CsrWifiSmeCalibrationDataSetReq *) msg;
+ size_t bufferSize = 2;
+
+ /* Calculate the Size of the Serialised Data. Could be more efficient (Try 6) */
+ bufferSize += 2; /* u16 primitive->calibrationDataLength */
+ bufferSize += primitive->calibrationDataLength; /* u8 primitive->calibrationData */
+ return bufferSize;
+}
+
+
+u8* CsrWifiSmeCalibrationDataSetReqSer(u8 *ptr, size_t *len, void *msg)
+{
+ CsrWifiSmeCalibrationDataSetReq *primitive = (CsrWifiSmeCalibrationDataSetReq *)msg;
+ *len = 0;
+ CsrUint16Ser(ptr, len, primitive->common.type);
+ CsrUint16Ser(ptr, len, (u16) primitive->calibrationDataLength);
+ if (primitive->calibrationDataLength)
+ {
+ CsrMemCpySer(ptr, len, (const void *) primitive->calibrationData, ((u16) (primitive->calibrationDataLength)));
+ }
+ return(ptr);
+}
+
+
+void* CsrWifiSmeCalibrationDataSetReqDes(u8 *buffer, size_t length)
+{
+ CsrWifiSmeCalibrationDataSetReq *primitive = kmalloc(sizeof(CsrWifiSmeCalibrationDataSetReq), GFP_KERNEL);
+ size_t offset;
+ offset = 0;
+
+ CsrUint16Des(&primitive->common.type, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->calibrationDataLength, buffer, &offset);
+ if (primitive->calibrationDataLength)
+ {
+ primitive->calibrationData = kmalloc(primitive->calibrationDataLength, GFP_KERNEL);
+ CsrMemCpyDes(primitive->calibrationData, buffer, &offset, ((u16) (primitive->calibrationDataLength)));
+ }
+ else
+ {
+ primitive->calibrationData = NULL;
+ }
+
+ return primitive;
+}
+
+
+void CsrWifiSmeCalibrationDataSetReqSerFree(void *voidPrimitivePointer)
+{
+ CsrWifiSmeCalibrationDataSetReq *primitive = (CsrWifiSmeCalibrationDataSetReq *) voidPrimitivePointer;
+ kfree(primitive->calibrationData);
+ kfree(primitive);
+}
+
+
+size_t CsrWifiSmeCcxConfigSetReqSizeof(void *msg)
+{
+ size_t bufferSize = 2;
+
+ /* Calculate the Size of the Serialised Data. Could be more efficient (Try 9) */
+ bufferSize += 2; /* u16 primitive->interfaceTag */
+ bufferSize += 1; /* u8 primitive->ccxConfig.keepAliveTimeMs */
+ bufferSize += 1; /* u8 primitive->ccxConfig.apRoamingEnabled */
+ bufferSize += 1; /* u8 primitive->ccxConfig.measurementsMask */
+ bufferSize += 1; /* u8 primitive->ccxConfig.ccxRadioMgtEnabled */
+ return bufferSize;
+}
+
+
+u8* CsrWifiSmeCcxConfigSetReqSer(u8 *ptr, size_t *len, void *msg)
+{
+ CsrWifiSmeCcxConfigSetReq *primitive = (CsrWifiSmeCcxConfigSetReq *)msg;
+ *len = 0;
+ CsrUint16Ser(ptr, len, primitive->common.type);
+ CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
+ CsrUint8Ser(ptr, len, (u8) primitive->ccxConfig.keepAliveTimeMs);
+ CsrUint8Ser(ptr, len, (u8) primitive->ccxConfig.apRoamingEnabled);
+ CsrUint8Ser(ptr, len, (u8) primitive->ccxConfig.measurementsMask);
+ CsrUint8Ser(ptr, len, (u8) primitive->ccxConfig.ccxRadioMgtEnabled);
+ return(ptr);
+}
+
+
+void* CsrWifiSmeCcxConfigSetReqDes(u8 *buffer, size_t length)
+{
+ CsrWifiSmeCcxConfigSetReq *primitive = kmalloc(sizeof(CsrWifiSmeCcxConfigSetReq), GFP_KERNEL);
+ size_t offset;
+ offset = 0;
+
+ CsrUint16Des(&primitive->common.type, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->ccxConfig.keepAliveTimeMs, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->ccxConfig.apRoamingEnabled, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->ccxConfig.measurementsMask, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->ccxConfig.ccxRadioMgtEnabled, buffer, &offset);
+
+ return primitive;
+}
+
+
+size_t CsrWifiSmeCoexConfigSetReqSizeof(void *msg)
+{
+ size_t bufferSize = 2;
+
+ /* Calculate the Size of the Serialised Data. Could be more efficient (Try 29) */
+ bufferSize += 1; /* u8 primitive->coexConfig.coexEnableSchemeManagement */
+ bufferSize += 1; /* u8 primitive->coexConfig.coexPeriodicWakeHost */
+ bufferSize += 2; /* u16 primitive->coexConfig.coexTrafficBurstyLatencyMs */
+ bufferSize += 2; /* u16 primitive->coexConfig.coexTrafficContinuousLatencyMs */
+ bufferSize += 2; /* u16 primitive->coexConfig.coexObexBlackoutDurationMs */
+ bufferSize += 2; /* u16 primitive->coexConfig.coexObexBlackoutPeriodMs */
+ bufferSize += 2; /* u16 primitive->coexConfig.coexA2dpBrBlackoutDurationMs */
+ bufferSize += 2; /* u16 primitive->coexConfig.coexA2dpBrBlackoutPeriodMs */
+ bufferSize += 2; /* u16 primitive->coexConfig.coexA2dpEdrBlackoutDurationMs */
+ bufferSize += 2; /* u16 primitive->coexConfig.coexA2dpEdrBlackoutPeriodMs */
+ bufferSize += 2; /* u16 primitive->coexConfig.coexPagingBlackoutDurationMs */
+ bufferSize += 2; /* u16 primitive->coexConfig.coexPagingBlackoutPeriodMs */
+ bufferSize += 2; /* u16 primitive->coexConfig.coexInquiryBlackoutDurationMs */
+ bufferSize += 2; /* u16 primitive->coexConfig.coexInquiryBlackoutPeriodMs */
+ return bufferSize;
+}
+
+
+u8* CsrWifiSmeCoexConfigSetReqSer(u8 *ptr, size_t *len, void *msg)
+{
+ CsrWifiSmeCoexConfigSetReq *primitive = (CsrWifiSmeCoexConfigSetReq *)msg;
+ *len = 0;
+ CsrUint16Ser(ptr, len, primitive->common.type);
+ CsrUint8Ser(ptr, len, (u8) primitive->coexConfig.coexEnableSchemeManagement);
+ CsrUint8Ser(ptr, len, (u8) primitive->coexConfig.coexPeriodicWakeHost);
+ CsrUint16Ser(ptr, len, (u16) primitive->coexConfig.coexTrafficBurstyLatencyMs);
+ CsrUint16Ser(ptr, len, (u16) primitive->coexConfig.coexTrafficContinuousLatencyMs);
+ CsrUint16Ser(ptr, len, (u16) primitive->coexConfig.coexObexBlackoutDurationMs);
+ CsrUint16Ser(ptr, len, (u16) primitive->coexConfig.coexObexBlackoutPeriodMs);
+ CsrUint16Ser(ptr, len, (u16) primitive->coexConfig.coexA2dpBrBlackoutDurationMs);
+ CsrUint16Ser(ptr, len, (u16) primitive->coexConfig.coexA2dpBrBlackoutPeriodMs);
+ CsrUint16Ser(ptr, len, (u16) primitive->coexConfig.coexA2dpEdrBlackoutDurationMs);
+ CsrUint16Ser(ptr, len, (u16) primitive->coexConfig.coexA2dpEdrBlackoutPeriodMs);
+ CsrUint16Ser(ptr, len, (u16) primitive->coexConfig.coexPagingBlackoutDurationMs);
+ CsrUint16Ser(ptr, len, (u16) primitive->coexConfig.coexPagingBlackoutPeriodMs);
+ CsrUint16Ser(ptr, len, (u16) primitive->coexConfig.coexInquiryBlackoutDurationMs);
+ CsrUint16Ser(ptr, len, (u16) primitive->coexConfig.coexInquiryBlackoutPeriodMs);
+ return(ptr);
+}
+
+
+void* CsrWifiSmeCoexConfigSetReqDes(u8 *buffer, size_t length)
+{
+ CsrWifiSmeCoexConfigSetReq *primitive = kmalloc(sizeof(CsrWifiSmeCoexConfigSetReq), GFP_KERNEL);
+ size_t offset;
+ offset = 0;
+
+ CsrUint16Des(&primitive->common.type, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->coexConfig.coexEnableSchemeManagement, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->coexConfig.coexPeriodicWakeHost, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->coexConfig.coexTrafficBurstyLatencyMs, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->coexConfig.coexTrafficContinuousLatencyMs, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->coexConfig.coexObexBlackoutDurationMs, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->coexConfig.coexObexBlackoutPeriodMs, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->coexConfig.coexA2dpBrBlackoutDurationMs, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->coexConfig.coexA2dpBrBlackoutPeriodMs, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->coexConfig.coexA2dpEdrBlackoutDurationMs, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->coexConfig.coexA2dpEdrBlackoutPeriodMs, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->coexConfig.coexPagingBlackoutDurationMs, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->coexConfig.coexPagingBlackoutPeriodMs, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->coexConfig.coexInquiryBlackoutDurationMs, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->coexConfig.coexInquiryBlackoutPeriodMs, buffer, &offset);
+
+ return primitive;
+}
+
+
+size_t CsrWifiSmeConnectReqSizeof(void *msg)
+{
+ CsrWifiSmeConnectReq *primitive = (CsrWifiSmeConnectReq *) msg;
+ size_t bufferSize = 2;
+
+ /* Calculate the Size of the Serialised Data. Could be more efficient (Try 57) */
+ bufferSize += 2; /* u16 primitive->interfaceTag */
+ bufferSize += 32; /* u8 primitive->connectionConfig.ssid.ssid[32] */
+ bufferSize += 1; /* u8 primitive->connectionConfig.ssid.length */
+ bufferSize += 6; /* u8 primitive->connectionConfig.bssid.a[6] */
+ bufferSize += 1; /* CsrWifiSmeBssType primitive->connectionConfig.bssType */
+ bufferSize += 1; /* CsrWifiSmeRadioIF primitive->connectionConfig.ifIndex */
+ bufferSize += 1; /* CsrWifiSme80211PrivacyMode primitive->connectionConfig.privacyMode */
+ bufferSize += 2; /* CsrWifiSmeAuthModeMask primitive->connectionConfig.authModeMask */
+ bufferSize += 2; /* CsrWifiSmeEncryptionMask primitive->connectionConfig.encryptionModeMask */
+ bufferSize += 2; /* u16 primitive->connectionConfig.mlmeAssociateReqInformationElementsLength */
+ bufferSize += primitive->connectionConfig.mlmeAssociateReqInformationElementsLength; /* u8 primitive->connectionConfig.mlmeAssociateReqInformationElements */
+ bufferSize += 1; /* CsrWifiSmeWmmQosInfoMask primitive->connectionConfig.wmmQosInfo */
+ bufferSize += 1; /* u8 primitive->connectionConfig.adhocJoinOnly */
+ bufferSize += 1; /* u8 primitive->connectionConfig.adhocChannel */
+ return bufferSize;
+}
+
+
+u8* CsrWifiSmeConnectReqSer(u8 *ptr, size_t *len, void *msg)
+{
+ CsrWifiSmeConnectReq *primitive = (CsrWifiSmeConnectReq *)msg;
+ *len = 0;
+ CsrUint16Ser(ptr, len, primitive->common.type);
+ CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
+ CsrMemCpySer(ptr, len, (const void *) primitive->connectionConfig.ssid.ssid, ((u16) (32)));
+ CsrUint8Ser(ptr, len, (u8) primitive->connectionConfig.ssid.length);
+ CsrMemCpySer(ptr, len, (const void *) primitive->connectionConfig.bssid.a, ((u16) (6)));
+ CsrUint8Ser(ptr, len, (u8) primitive->connectionConfig.bssType);
+ CsrUint8Ser(ptr, len, (u8) primitive->connectionConfig.ifIndex);
+ CsrUint8Ser(ptr, len, (u8) primitive->connectionConfig.privacyMode);
+ CsrUint16Ser(ptr, len, (u16) primitive->connectionConfig.authModeMask);
+ CsrUint16Ser(ptr, len, (u16) primitive->connectionConfig.encryptionModeMask);
+ CsrUint16Ser(ptr, len, (u16) primitive->connectionConfig.mlmeAssociateReqInformationElementsLength);
+ if (primitive->connectionConfig.mlmeAssociateReqInformationElementsLength)
+ {
+ CsrMemCpySer(ptr, len, (const void *) primitive->connectionConfig.mlmeAssociateReqInformationElements, ((u16) (primitive->connectionConfig.mlmeAssociateReqInformationElementsLength)));
+ }
+ CsrUint8Ser(ptr, len, (u8) primitive->connectionConfig.wmmQosInfo);
+ CsrUint8Ser(ptr, len, (u8) primitive->connectionConfig.adhocJoinOnly);
+ CsrUint8Ser(ptr, len, (u8) primitive->connectionConfig.adhocChannel);
+ return(ptr);
+}
+
+
+void* CsrWifiSmeConnectReqDes(u8 *buffer, size_t length)
+{
+ CsrWifiSmeConnectReq *primitive = kmalloc(sizeof(CsrWifiSmeConnectReq), GFP_KERNEL);
+ size_t offset;
+ offset = 0;
+
+ CsrUint16Des(&primitive->common.type, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
+ CsrMemCpyDes(primitive->connectionConfig.ssid.ssid, buffer, &offset, ((u16) (32)));
+ CsrUint8Des((u8 *) &primitive->connectionConfig.ssid.length, buffer, &offset);
+ CsrMemCpyDes(primitive->connectionConfig.bssid.a, buffer, &offset, ((u16) (6)));
+ CsrUint8Des((u8 *) &primitive->connectionConfig.bssType, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->connectionConfig.ifIndex, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->connectionConfig.privacyMode, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->connectionConfig.authModeMask, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->connectionConfig.encryptionModeMask, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->connectionConfig.mlmeAssociateReqInformationElementsLength, buffer, &offset);
+ if (primitive->connectionConfig.mlmeAssociateReqInformationElementsLength)
+ {
+ primitive->connectionConfig.mlmeAssociateReqInformationElements = kmalloc(primitive->connectionConfig.mlmeAssociateReqInformationElementsLength, GFP_KERNEL);
+ CsrMemCpyDes(primitive->connectionConfig.mlmeAssociateReqInformationElements, buffer, &offset, ((u16) (primitive->connectionConfig.mlmeAssociateReqInformationElementsLength)));
+ }
+ else
+ {
+ primitive->connectionConfig.mlmeAssociateReqInformationElements = NULL;
+ }
+ CsrUint8Des((u8 *) &primitive->connectionConfig.wmmQosInfo, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->connectionConfig.adhocJoinOnly, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->connectionConfig.adhocChannel, buffer, &offset);
+
+ return primitive;
+}
+
+
+void CsrWifiSmeConnectReqSerFree(void *voidPrimitivePointer)
+{
+ CsrWifiSmeConnectReq *primitive = (CsrWifiSmeConnectReq *) voidPrimitivePointer;
+ kfree(primitive->connectionConfig.mlmeAssociateReqInformationElements);
+ kfree(primitive);
+}
+
+
+size_t CsrWifiSmeHostConfigSetReqSizeof(void *msg)
+{
+ size_t bufferSize = 2;
+
+ /* Calculate the Size of the Serialised Data. Could be more efficient (Try 8) */
+ bufferSize += 2; /* u16 primitive->interfaceTag */
+ bufferSize += 1; /* CsrWifiSmeHostPowerMode primitive->hostConfig.powerMode */
+ bufferSize += 2; /* u16 primitive->hostConfig.applicationDataPeriodMs */
+ return bufferSize;
+}
+
+
+u8* CsrWifiSmeHostConfigSetReqSer(u8 *ptr, size_t *len, void *msg)
+{
+ CsrWifiSmeHostConfigSetReq *primitive = (CsrWifiSmeHostConfigSetReq *)msg;
+ *len = 0;
+ CsrUint16Ser(ptr, len, primitive->common.type);
+ CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
+ CsrUint8Ser(ptr, len, (u8) primitive->hostConfig.powerMode);
+ CsrUint16Ser(ptr, len, (u16) primitive->hostConfig.applicationDataPeriodMs);
+ return(ptr);
+}
+
+
+void* CsrWifiSmeHostConfigSetReqDes(u8 *buffer, size_t length)
+{
+ CsrWifiSmeHostConfigSetReq *primitive = kmalloc(sizeof(CsrWifiSmeHostConfigSetReq), GFP_KERNEL);
+ size_t offset;
+ offset = 0;
+
+ CsrUint16Des(&primitive->common.type, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->hostConfig.powerMode, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->hostConfig.applicationDataPeriodMs, buffer, &offset);
+
+ return primitive;
+}
+
+
+size_t CsrWifiSmeKeyReqSizeof(void *msg)
+{
+ size_t bufferSize = 2;
+
+ /* Calculate the Size of the Serialised Data. Could be more efficient (Try 65) */
+ bufferSize += 2; /* u16 primitive->interfaceTag */
+ bufferSize += 1; /* CsrWifiSmeListAction primitive->action */
+ bufferSize += 1; /* CsrWifiSmeKeyType primitive->key.keyType */
+ bufferSize += 1; /* u8 primitive->key.keyIndex */
+ bufferSize += 1; /* u8 primitive->key.wepTxKey */
+ {
+ u16 i2;
+ for (i2 = 0; i2 < 8; i2++)
+ {
+ bufferSize += 2; /* u16 primitive->key.keyRsc[8] */
+ }
+ }
+ bufferSize += 1; /* u8 primitive->key.authenticator */
+ bufferSize += 6; /* u8 primitive->key.address.a[6] */
+ bufferSize += 1; /* u8 primitive->key.keyLength */
+ bufferSize += 32; /* u8 primitive->key.key[32] */
+ return bufferSize;
+}
+
+
+u8* CsrWifiSmeKeyReqSer(u8 *ptr, size_t *len, void *msg)
+{
+ CsrWifiSmeKeyReq *primitive = (CsrWifiSmeKeyReq *)msg;
+ *len = 0;
+ CsrUint16Ser(ptr, len, primitive->common.type);
+ CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
+ CsrUint8Ser(ptr, len, (u8) primitive->action);
+ CsrUint8Ser(ptr, len, (u8) primitive->key.keyType);
+ CsrUint8Ser(ptr, len, (u8) primitive->key.keyIndex);
+ CsrUint8Ser(ptr, len, (u8) primitive->key.wepTxKey);
+ {
+ u16 i2;
+ for (i2 = 0; i2 < 8; i2++)
+ {
+ CsrUint16Ser(ptr, len, (u16) primitive->key.keyRsc[i2]);
+ }
+ }
+ CsrUint8Ser(ptr, len, (u8) primitive->key.authenticator);
+ CsrMemCpySer(ptr, len, (const void *) primitive->key.address.a, ((u16) (6)));
+ CsrUint8Ser(ptr, len, (u8) primitive->key.keyLength);
+ CsrMemCpySer(ptr, len, (const void *) primitive->key.key, ((u16) (32)));
+ return(ptr);
+}
+
+
+void* CsrWifiSmeKeyReqDes(u8 *buffer, size_t length)
+{
+ CsrWifiSmeKeyReq *primitive = kmalloc(sizeof(CsrWifiSmeKeyReq), GFP_KERNEL);
+ size_t offset;
+ offset = 0;
+
+ CsrUint16Des(&primitive->common.type, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->action, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->key.keyType, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->key.keyIndex, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->key.wepTxKey, buffer, &offset);
+ {
+ u16 i2;
+ for (i2 = 0; i2 < 8; i2++)
+ {
+ CsrUint16Des((u16 *) &primitive->key.keyRsc[i2], buffer, &offset);
+ }
+ }
+ CsrUint8Des((u8 *) &primitive->key.authenticator, buffer, &offset);
+ CsrMemCpyDes(primitive->key.address.a, buffer, &offset, ((u16) (6)));
+ CsrUint8Des((u8 *) &primitive->key.keyLength, buffer, &offset);
+ CsrMemCpyDes(primitive->key.key, buffer, &offset, ((u16) (32)));
+
+ return primitive;
+}
+
+
+size_t CsrWifiSmeMibConfigSetReqSizeof(void *msg)
+{
+ size_t bufferSize = 2;
+
+ /* Calculate the Size of the Serialised Data. Could be more efficient (Try 11) */
+ bufferSize += 1; /* u8 primitive->mibConfig.unifiFixMaxTxDataRate */
+ bufferSize += 1; /* u8 primitive->mibConfig.unifiFixTxDataRate */
+ bufferSize += 2; /* u16 primitive->mibConfig.dot11RtsThreshold */
+ bufferSize += 2; /* u16 primitive->mibConfig.dot11FragmentationThreshold */
+ bufferSize += 2; /* u16 primitive->mibConfig.dot11CurrentTxPowerLevel */
+ return bufferSize;
+}
+
+
+u8* CsrWifiSmeMibConfigSetReqSer(u8 *ptr, size_t *len, void *msg)
+{
+ CsrWifiSmeMibConfigSetReq *primitive = (CsrWifiSmeMibConfigSetReq *)msg;
+ *len = 0;
+ CsrUint16Ser(ptr, len, primitive->common.type);
+ CsrUint8Ser(ptr, len, (u8) primitive->mibConfig.unifiFixMaxTxDataRate);
+ CsrUint8Ser(ptr, len, (u8) primitive->mibConfig.unifiFixTxDataRate);
+ CsrUint16Ser(ptr, len, (u16) primitive->mibConfig.dot11RtsThreshold);
+ CsrUint16Ser(ptr, len, (u16) primitive->mibConfig.dot11FragmentationThreshold);
+ CsrUint16Ser(ptr, len, (u16) primitive->mibConfig.dot11CurrentTxPowerLevel);
+ return(ptr);
+}
+
+
+void* CsrWifiSmeMibConfigSetReqDes(u8 *buffer, size_t length)
+{
+ CsrWifiSmeMibConfigSetReq *primitive = kmalloc(sizeof(CsrWifiSmeMibConfigSetReq), GFP_KERNEL);
+ size_t offset;
+ offset = 0;
+
+ CsrUint16Des(&primitive->common.type, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->mibConfig.unifiFixMaxTxDataRate, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->mibConfig.unifiFixTxDataRate, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->mibConfig.dot11RtsThreshold, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->mibConfig.dot11FragmentationThreshold, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->mibConfig.dot11CurrentTxPowerLevel, buffer, &offset);
+
+ return primitive;
+}
+
+
+size_t CsrWifiSmeMibGetNextReqSizeof(void *msg)
+{
+ CsrWifiSmeMibGetNextReq *primitive = (CsrWifiSmeMibGetNextReq *) msg;
+ size_t bufferSize = 2;
+
+ /* Calculate the Size of the Serialised Data. Could be more efficient (Try 6) */
+ bufferSize += 2; /* u16 primitive->mibAttributeLength */
+ bufferSize += primitive->mibAttributeLength; /* u8 primitive->mibAttribute */
+ return bufferSize;
+}
+
+
+u8* CsrWifiSmeMibGetNextReqSer(u8 *ptr, size_t *len, void *msg)
+{
+ CsrWifiSmeMibGetNextReq *primitive = (CsrWifiSmeMibGetNextReq *)msg;
+ *len = 0;
+ CsrUint16Ser(ptr, len, primitive->common.type);
+ CsrUint16Ser(ptr, len, (u16) primitive->mibAttributeLength);
+ if (primitive->mibAttributeLength)
+ {
+ CsrMemCpySer(ptr, len, (const void *) primitive->mibAttribute, ((u16) (primitive->mibAttributeLength)));
+ }
+ return(ptr);
+}
+
+
+void* CsrWifiSmeMibGetNextReqDes(u8 *buffer, size_t length)
+{
+ CsrWifiSmeMibGetNextReq *primitive = kmalloc(sizeof(CsrWifiSmeMibGetNextReq), GFP_KERNEL);
+ size_t offset;
+ offset = 0;
+
+ CsrUint16Des(&primitive->common.type, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->mibAttributeLength, buffer, &offset);
+ if (primitive->mibAttributeLength)
+ {
+ primitive->mibAttribute = kmalloc(primitive->mibAttributeLength, GFP_KERNEL);
+ CsrMemCpyDes(primitive->mibAttribute, buffer, &offset, ((u16) (primitive->mibAttributeLength)));
+ }
+ else
+ {
+ primitive->mibAttribute = NULL;
+ }
+
+ return primitive;
+}
+
+
+void CsrWifiSmeMibGetNextReqSerFree(void *voidPrimitivePointer)
+{
+ CsrWifiSmeMibGetNextReq *primitive = (CsrWifiSmeMibGetNextReq *) voidPrimitivePointer;
+ kfree(primitive->mibAttribute);
+ kfree(primitive);
+}
+
+
+size_t CsrWifiSmeMibGetReqSizeof(void *msg)
+{
+ CsrWifiSmeMibGetReq *primitive = (CsrWifiSmeMibGetReq *) msg;
+ size_t bufferSize = 2;
+
+ /* Calculate the Size of the Serialised Data. Could be more efficient (Try 6) */
+ bufferSize += 2; /* u16 primitive->mibAttributeLength */
+ bufferSize += primitive->mibAttributeLength; /* u8 primitive->mibAttribute */
+ return bufferSize;
+}
+
+
+u8* CsrWifiSmeMibGetReqSer(u8 *ptr, size_t *len, void *msg)
+{
+ CsrWifiSmeMibGetReq *primitive = (CsrWifiSmeMibGetReq *)msg;
+ *len = 0;
+ CsrUint16Ser(ptr, len, primitive->common.type);
+ CsrUint16Ser(ptr, len, (u16) primitive->mibAttributeLength);
+ if (primitive->mibAttributeLength)
+ {
+ CsrMemCpySer(ptr, len, (const void *) primitive->mibAttribute, ((u16) (primitive->mibAttributeLength)));
+ }
+ return(ptr);
+}
+
+
+void* CsrWifiSmeMibGetReqDes(u8 *buffer, size_t length)
+{
+ CsrWifiSmeMibGetReq *primitive = kmalloc(sizeof(CsrWifiSmeMibGetReq), GFP_KERNEL);
+ size_t offset;
+ offset = 0;
+
+ CsrUint16Des(&primitive->common.type, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->mibAttributeLength, buffer, &offset);
+ if (primitive->mibAttributeLength)
+ {
+ primitive->mibAttribute = kmalloc(primitive->mibAttributeLength, GFP_KERNEL);
+ CsrMemCpyDes(primitive->mibAttribute, buffer, &offset, ((u16) (primitive->mibAttributeLength)));
+ }
+ else
+ {
+ primitive->mibAttribute = NULL;
+ }
+
+ return primitive;
+}
+
+
+void CsrWifiSmeMibGetReqSerFree(void *voidPrimitivePointer)
+{
+ CsrWifiSmeMibGetReq *primitive = (CsrWifiSmeMibGetReq *) voidPrimitivePointer;
+ kfree(primitive->mibAttribute);
+ kfree(primitive);
+}
+
+
+size_t CsrWifiSmeMibSetReqSizeof(void *msg)
+{
+ CsrWifiSmeMibSetReq *primitive = (CsrWifiSmeMibSetReq *) msg;
+ size_t bufferSize = 2;
+
+ /* Calculate the Size of the Serialised Data. Could be more efficient (Try 6) */
+ bufferSize += 2; /* u16 primitive->mibAttributeLength */
+ bufferSize += primitive->mibAttributeLength; /* u8 primitive->mibAttribute */
+ return bufferSize;
+}
+
+
+u8* CsrWifiSmeMibSetReqSer(u8 *ptr, size_t *len, void *msg)
+{
+ CsrWifiSmeMibSetReq *primitive = (CsrWifiSmeMibSetReq *)msg;
+ *len = 0;
+ CsrUint16Ser(ptr, len, primitive->common.type);
+ CsrUint16Ser(ptr, len, (u16) primitive->mibAttributeLength);
+ if (primitive->mibAttributeLength)
+ {
+ CsrMemCpySer(ptr, len, (const void *) primitive->mibAttribute, ((u16) (primitive->mibAttributeLength)));
+ }
+ return(ptr);
+}
+
+
+void* CsrWifiSmeMibSetReqDes(u8 *buffer, size_t length)
+{
+ CsrWifiSmeMibSetReq *primitive = kmalloc(sizeof(CsrWifiSmeMibSetReq), GFP_KERNEL);
+ size_t offset;
+ offset = 0;
+
+ CsrUint16Des(&primitive->common.type, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->mibAttributeLength, buffer, &offset);
+ if (primitive->mibAttributeLength)
+ {
+ primitive->mibAttribute = kmalloc(primitive->mibAttributeLength, GFP_KERNEL);
+ CsrMemCpyDes(primitive->mibAttribute, buffer, &offset, ((u16) (primitive->mibAttributeLength)));
+ }
+ else
+ {
+ primitive->mibAttribute = NULL;
+ }
+
+ return primitive;
+}
+
+
+void CsrWifiSmeMibSetReqSerFree(void *voidPrimitivePointer)
+{
+ CsrWifiSmeMibSetReq *primitive = (CsrWifiSmeMibSetReq *) voidPrimitivePointer;
+ kfree(primitive->mibAttribute);
+ kfree(primitive);
+}
+
+
+size_t CsrWifiSmeMulticastAddressReqSizeof(void *msg)
+{
+ CsrWifiSmeMulticastAddressReq *primitive = (CsrWifiSmeMulticastAddressReq *) msg;
+ size_t bufferSize = 2;
+
+ /* Calculate the Size of the Serialised Data. Could be more efficient (Try 13) */
+ bufferSize += 2; /* u16 primitive->interfaceTag */
+ bufferSize += 1; /* CsrWifiSmeListAction primitive->action */
+ bufferSize += 1; /* u8 primitive->setAddressesCount */
+ {
+ u16 i1;
+ for (i1 = 0; i1 < primitive->setAddressesCount; i1++)
+ {
+ bufferSize += 6; /* u8 primitive->setAddresses[i1].a[6] */
+ }
+ }
+ return bufferSize;
+}
+
+
+u8* CsrWifiSmeMulticastAddressReqSer(u8 *ptr, size_t *len, void *msg)
+{
+ CsrWifiSmeMulticastAddressReq *primitive = (CsrWifiSmeMulticastAddressReq *)msg;
+ *len = 0;
+ CsrUint16Ser(ptr, len, primitive->common.type);
+ CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
+ CsrUint8Ser(ptr, len, (u8) primitive->action);
+ CsrUint8Ser(ptr, len, (u8) primitive->setAddressesCount);
+ {
+ u16 i1;
+ for (i1 = 0; i1 < primitive->setAddressesCount; i1++)
+ {
+ CsrMemCpySer(ptr, len, (const void *) primitive->setAddresses[i1].a, ((u16) (6)));
+ }
+ }
+ return(ptr);
+}
+
+
+void* CsrWifiSmeMulticastAddressReqDes(u8 *buffer, size_t length)
+{
+ CsrWifiSmeMulticastAddressReq *primitive = kmalloc(sizeof(CsrWifiSmeMulticastAddressReq), GFP_KERNEL);
+ size_t offset;
+ offset = 0;
+
+ CsrUint16Des(&primitive->common.type, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->action, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->setAddressesCount, buffer, &offset);
+ primitive->setAddresses = NULL;
+ if (primitive->setAddressesCount)
+ {
+ primitive->setAddresses = kmalloc(sizeof(CsrWifiMacAddress) * primitive->setAddressesCount, GFP_KERNEL);
+ }
+ {
+ u16 i1;
+ for (i1 = 0; i1 < primitive->setAddressesCount; i1++)
+ {
+ CsrMemCpyDes(primitive->setAddresses[i1].a, buffer, &offset, ((u16) (6)));
+ }
+ }
+
+ return primitive;
+}
+
+
+void CsrWifiSmeMulticastAddressReqSerFree(void *voidPrimitivePointer)
+{
+ CsrWifiSmeMulticastAddressReq *primitive = (CsrWifiSmeMulticastAddressReq *) voidPrimitivePointer;
+ kfree(primitive->setAddresses);
+ kfree(primitive);
+}
+
+
+size_t CsrWifiSmePacketFilterSetReqSizeof(void *msg)
+{
+ CsrWifiSmePacketFilterSetReq *primitive = (CsrWifiSmePacketFilterSetReq *) msg;
+ size_t bufferSize = 2;
+
+ /* Calculate the Size of the Serialised Data. Could be more efficient (Try 13) */
+ bufferSize += 2; /* u16 primitive->interfaceTag */
+ bufferSize += 2; /* u16 primitive->filterLength */
+ bufferSize += primitive->filterLength; /* u8 primitive->filter */
+ bufferSize += 1; /* CsrWifiSmePacketFilterMode primitive->mode */
+ bufferSize += 4; /* u8 primitive->arpFilterAddress.a[4] */
+ return bufferSize;
+}
+
+
+u8* CsrWifiSmePacketFilterSetReqSer(u8 *ptr, size_t *len, void *msg)
+{
+ CsrWifiSmePacketFilterSetReq *primitive = (CsrWifiSmePacketFilterSetReq *)msg;
+ *len = 0;
+ CsrUint16Ser(ptr, len, primitive->common.type);
+ CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
+ CsrUint16Ser(ptr, len, (u16) primitive->filterLength);
+ if (primitive->filterLength)
+ {
+ CsrMemCpySer(ptr, len, (const void *) primitive->filter, ((u16) (primitive->filterLength)));
+ }
+ CsrUint8Ser(ptr, len, (u8) primitive->mode);
+ CsrMemCpySer(ptr, len, (const void *) primitive->arpFilterAddress.a, ((u16) (4)));
+ return(ptr);
+}
+
+
+void* CsrWifiSmePacketFilterSetReqDes(u8 *buffer, size_t length)
+{
+ CsrWifiSmePacketFilterSetReq *primitive = kmalloc(sizeof(CsrWifiSmePacketFilterSetReq), GFP_KERNEL);
+ size_t offset;
+ offset = 0;
+
+ CsrUint16Des(&primitive->common.type, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->filterLength, buffer, &offset);
+ if (primitive->filterLength)
+ {
+ primitive->filter = kmalloc(primitive->filterLength, GFP_KERNEL);
+ CsrMemCpyDes(primitive->filter, buffer, &offset, ((u16) (primitive->filterLength)));
+ }
+ else
+ {
+ primitive->filter = NULL;
+ }
+ CsrUint8Des((u8 *) &primitive->mode, buffer, &offset);
+ CsrMemCpyDes(primitive->arpFilterAddress.a, buffer, &offset, ((u16) (4)));
+
+ return primitive;
+}
+
+
+void CsrWifiSmePacketFilterSetReqSerFree(void *voidPrimitivePointer)
+{
+ CsrWifiSmePacketFilterSetReq *primitive = (CsrWifiSmePacketFilterSetReq *) voidPrimitivePointer;
+ kfree(primitive->filter);
+ kfree(primitive);
+}
+
+
+size_t CsrWifiSmePmkidReqSizeof(void *msg)
+{
+ CsrWifiSmePmkidReq *primitive = (CsrWifiSmePmkidReq *) msg;
+ size_t bufferSize = 2;
+
+ /* Calculate the Size of the Serialised Data. Could be more efficient (Try 29) */
+ bufferSize += 2; /* u16 primitive->interfaceTag */
+ bufferSize += 1; /* CsrWifiSmeListAction primitive->action */
+ bufferSize += 1; /* u8 primitive->setPmkidsCount */
+ {
+ u16 i1;
+ for (i1 = 0; i1 < primitive->setPmkidsCount; i1++)
+ {
+ bufferSize += 6; /* u8 primitive->setPmkids[i1].bssid.a[6] */
+ bufferSize += 16; /* u8 primitive->setPmkids[i1].pmkid[16] */
+ }
+ }
+ return bufferSize;
+}
+
+
+u8* CsrWifiSmePmkidReqSer(u8 *ptr, size_t *len, void *msg)
+{
+ CsrWifiSmePmkidReq *primitive = (CsrWifiSmePmkidReq *)msg;
+ *len = 0;
+ CsrUint16Ser(ptr, len, primitive->common.type);
+ CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
+ CsrUint8Ser(ptr, len, (u8) primitive->action);
+ CsrUint8Ser(ptr, len, (u8) primitive->setPmkidsCount);
+ {
+ u16 i1;
+ for (i1 = 0; i1 < primitive->setPmkidsCount; i1++)
+ {
+ CsrMemCpySer(ptr, len, (const void *) primitive->setPmkids[i1].bssid.a, ((u16) (6)));
+ CsrMemCpySer(ptr, len, (const void *) primitive->setPmkids[i1].pmkid, ((u16) (16)));
+ }
+ }
+ return(ptr);
+}
+
+
+void* CsrWifiSmePmkidReqDes(u8 *buffer, size_t length)
+{
+ CsrWifiSmePmkidReq *primitive = kmalloc(sizeof(CsrWifiSmePmkidReq), GFP_KERNEL);
+ size_t offset;
+ offset = 0;
+
+ CsrUint16Des(&primitive->common.type, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->action, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->setPmkidsCount, buffer, &offset);
+ primitive->setPmkids = NULL;
+ if (primitive->setPmkidsCount)
+ {
+ primitive->setPmkids = kmalloc(sizeof(CsrWifiSmePmkid) * primitive->setPmkidsCount, GFP_KERNEL);
+ }
+ {
+ u16 i1;
+ for (i1 = 0; i1 < primitive->setPmkidsCount; i1++)
+ {
+ CsrMemCpyDes(primitive->setPmkids[i1].bssid.a, buffer, &offset, ((u16) (6)));
+ CsrMemCpyDes(primitive->setPmkids[i1].pmkid, buffer, &offset, ((u16) (16)));
+ }
+ }
+
+ return primitive;
+}
+
+
+void CsrWifiSmePmkidReqSerFree(void *voidPrimitivePointer)
+{
+ CsrWifiSmePmkidReq *primitive = (CsrWifiSmePmkidReq *) voidPrimitivePointer;
+ kfree(primitive->setPmkids);
+ kfree(primitive);
+}
+
+
+size_t CsrWifiSmePowerConfigSetReqSizeof(void *msg)
+{
+ size_t bufferSize = 2;
+
+ /* Calculate the Size of the Serialised Data. Could be more efficient (Try 11) */
+ bufferSize += 1; /* CsrWifiSmePowerSaveLevel primitive->powerConfig.powerSaveLevel */
+ bufferSize += 2; /* u16 primitive->powerConfig.listenIntervalTu */
+ bufferSize += 1; /* u8 primitive->powerConfig.rxDtims */
+ bufferSize += 1; /* CsrWifiSmeD3AutoScanMode primitive->powerConfig.d3AutoScanMode */
+ bufferSize += 1; /* u8 primitive->powerConfig.clientTrafficWindow */
+ bufferSize += 1; /* u8 primitive->powerConfig.opportunisticPowerSave */
+ bufferSize += 1; /* u8 primitive->powerConfig.noticeOfAbsence */
+ return bufferSize;
+}
+
+
+u8* CsrWifiSmePowerConfigSetReqSer(u8 *ptr, size_t *len, void *msg)
+{
+ CsrWifiSmePowerConfigSetReq *primitive = (CsrWifiSmePowerConfigSetReq *)msg;
+ *len = 0;
+ CsrUint16Ser(ptr, len, primitive->common.type);
+ CsrUint8Ser(ptr, len, (u8) primitive->powerConfig.powerSaveLevel);
+ CsrUint16Ser(ptr, len, (u16) primitive->powerConfig.listenIntervalTu);
+ CsrUint8Ser(ptr, len, (u8) primitive->powerConfig.rxDtims);
+ CsrUint8Ser(ptr, len, (u8) primitive->powerConfig.d3AutoScanMode);
+ CsrUint8Ser(ptr, len, (u8) primitive->powerConfig.clientTrafficWindow);
+ CsrUint8Ser(ptr, len, (u8) primitive->powerConfig.opportunisticPowerSave);
+ CsrUint8Ser(ptr, len, (u8) primitive->powerConfig.noticeOfAbsence);
+ return(ptr);
+}
+
+
+void* CsrWifiSmePowerConfigSetReqDes(u8 *buffer, size_t length)
+{
+ CsrWifiSmePowerConfigSetReq *primitive = kmalloc(sizeof(CsrWifiSmePowerConfigSetReq), GFP_KERNEL);
+ size_t offset;
+ offset = 0;
+
+ CsrUint16Des(&primitive->common.type, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->powerConfig.powerSaveLevel, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->powerConfig.listenIntervalTu, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->powerConfig.rxDtims, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->powerConfig.d3AutoScanMode, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->powerConfig.clientTrafficWindow, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->powerConfig.opportunisticPowerSave, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->powerConfig.noticeOfAbsence, buffer, &offset);
+
+ return primitive;
+}
+
+
+size_t CsrWifiSmeRoamingConfigSetReqSizeof(void *msg)
+{
+ size_t bufferSize = 2;
+
+ /* Calculate the Size of the Serialised Data. Could be more efficient (Try 70) */
+ bufferSize += 2; /* u16 primitive->interfaceTag */
+ {
+ u16 i2;
+ for (i2 = 0; i2 < 3; i2++)
+ {
+ bufferSize += 2; /* s16 primitive->roamingConfig.roamingBands[i2].rssiHighThreshold */
+ bufferSize += 2; /* s16 primitive->roamingConfig.roamingBands[i2].rssiLowThreshold */
+ bufferSize += 2; /* s16 primitive->roamingConfig.roamingBands[i2].snrHighThreshold */
+ bufferSize += 2; /* s16 primitive->roamingConfig.roamingBands[i2].snrLowThreshold */
+ }
+ }
+ bufferSize += 1; /* u8 primitive->roamingConfig.disableSmoothRoaming */
+ bufferSize += 1; /* u8 primitive->roamingConfig.disableRoamScans */
+ bufferSize += 1; /* u8 primitive->roamingConfig.reconnectLimit */
+ bufferSize += 2; /* u16 primitive->roamingConfig.reconnectLimitIntervalMs */
+ {
+ u16 i2;
+ for (i2 = 0; i2 < 3; i2++)
+ {
+ bufferSize += 2; /* u16 primitive->roamingConfig.roamScanCfg[i2].intervalSeconds */
+ bufferSize += 2; /* u16 primitive->roamingConfig.roamScanCfg[i2].validitySeconds */
+ bufferSize += 2; /* u16 primitive->roamingConfig.roamScanCfg[i2].minActiveChannelTimeTu */
+ bufferSize += 2; /* u16 primitive->roamingConfig.roamScanCfg[i2].maxActiveChannelTimeTu */
+ bufferSize += 2; /* u16 primitive->roamingConfig.roamScanCfg[i2].minPassiveChannelTimeTu */
+ bufferSize += 2; /* u16 primitive->roamingConfig.roamScanCfg[i2].maxPassiveChannelTimeTu */
+ }
+ }
+ return bufferSize;
+}
+
+
+u8* CsrWifiSmeRoamingConfigSetReqSer(u8 *ptr, size_t *len, void *msg)
+{
+ CsrWifiSmeRoamingConfigSetReq *primitive = (CsrWifiSmeRoamingConfigSetReq *)msg;
+ *len = 0;
+ CsrUint16Ser(ptr, len, primitive->common.type);
+ CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
+ {
+ u16 i2;
+ for (i2 = 0; i2 < 3; i2++)
+ {
+ CsrUint16Ser(ptr, len, (u16) primitive->roamingConfig.roamingBands[i2].rssiHighThreshold);
+ CsrUint16Ser(ptr, len, (u16) primitive->roamingConfig.roamingBands[i2].rssiLowThreshold);
+ CsrUint16Ser(ptr, len, (u16) primitive->roamingConfig.roamingBands[i2].snrHighThreshold);
+ CsrUint16Ser(ptr, len, (u16) primitive->roamingConfig.roamingBands[i2].snrLowThreshold);
+ }
+ }
+ CsrUint8Ser(ptr, len, (u8) primitive->roamingConfig.disableSmoothRoaming);
+ CsrUint8Ser(ptr, len, (u8) primitive->roamingConfig.disableRoamScans);
+ CsrUint8Ser(ptr, len, (u8) primitive->roamingConfig.reconnectLimit);
+ CsrUint16Ser(ptr, len, (u16) primitive->roamingConfig.reconnectLimitIntervalMs);
+ {
+ u16 i2;
+ for (i2 = 0; i2 < 3; i2++)
+ {
+ CsrUint16Ser(ptr, len, (u16) primitive->roamingConfig.roamScanCfg[i2].intervalSeconds);
+ CsrUint16Ser(ptr, len, (u16) primitive->roamingConfig.roamScanCfg[i2].validitySeconds);
+ CsrUint16Ser(ptr, len, (u16) primitive->roamingConfig.roamScanCfg[i2].minActiveChannelTimeTu);
+ CsrUint16Ser(ptr, len, (u16) primitive->roamingConfig.roamScanCfg[i2].maxActiveChannelTimeTu);
+ CsrUint16Ser(ptr, len, (u16) primitive->roamingConfig.roamScanCfg[i2].minPassiveChannelTimeTu);
+ CsrUint16Ser(ptr, len, (u16) primitive->roamingConfig.roamScanCfg[i2].maxPassiveChannelTimeTu);
+ }
+ }
+ return(ptr);
+}
+
+
+void* CsrWifiSmeRoamingConfigSetReqDes(u8 *buffer, size_t length)
+{
+ CsrWifiSmeRoamingConfigSetReq *primitive = kmalloc(sizeof(CsrWifiSmeRoamingConfigSetReq), GFP_KERNEL);
+ size_t offset;
+ offset = 0;
+
+ CsrUint16Des(&primitive->common.type, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
+ {
+ u16 i2;
+ for (i2 = 0; i2 < 3; i2++)
+ {
+ CsrUint16Des((u16 *) &primitive->roamingConfig.roamingBands[i2].rssiHighThreshold, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->roamingConfig.roamingBands[i2].rssiLowThreshold, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->roamingConfig.roamingBands[i2].snrHighThreshold, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->roamingConfig.roamingBands[i2].snrLowThreshold, buffer, &offset);
+ }
+ }
+ CsrUint8Des((u8 *) &primitive->roamingConfig.disableSmoothRoaming, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->roamingConfig.disableRoamScans, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->roamingConfig.reconnectLimit, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->roamingConfig.reconnectLimitIntervalMs, buffer, &offset);
+ {
+ u16 i2;
+ for (i2 = 0; i2 < 3; i2++)
+ {
+ CsrUint16Des((u16 *) &primitive->roamingConfig.roamScanCfg[i2].intervalSeconds, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->roamingConfig.roamScanCfg[i2].validitySeconds, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->roamingConfig.roamScanCfg[i2].minActiveChannelTimeTu, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->roamingConfig.roamScanCfg[i2].maxActiveChannelTimeTu, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->roamingConfig.roamScanCfg[i2].minPassiveChannelTimeTu, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->roamingConfig.roamScanCfg[i2].maxPassiveChannelTimeTu, buffer, &offset);
+ }
+ }
+
+ return primitive;
+}
+
+
+size_t CsrWifiSmeScanConfigSetReqSizeof(void *msg)
+{
+ CsrWifiSmeScanConfigSetReq *primitive = (CsrWifiSmeScanConfigSetReq *) msg;
+ size_t bufferSize = 2;
+
+ /* Calculate the Size of the Serialised Data. Could be more efficient (Try 63) */
+ {
+ u16 i2;
+ for (i2 = 0; i2 < 4; i2++)
+ {
+ bufferSize += 2; /* u16 primitive->scanConfig.scanCfg[i2].intervalSeconds */
+ bufferSize += 2; /* u16 primitive->scanConfig.scanCfg[i2].validitySeconds */
+ bufferSize += 2; /* u16 primitive->scanConfig.scanCfg[i2].minActiveChannelTimeTu */
+ bufferSize += 2; /* u16 primitive->scanConfig.scanCfg[i2].maxActiveChannelTimeTu */
+ bufferSize += 2; /* u16 primitive->scanConfig.scanCfg[i2].minPassiveChannelTimeTu */
+ bufferSize += 2; /* u16 primitive->scanConfig.scanCfg[i2].maxPassiveChannelTimeTu */
+ }
+ }
+ bufferSize += 1; /* u8 primitive->scanConfig.disableAutonomousScans */
+ bufferSize += 2; /* u16 primitive->scanConfig.maxResults */
+ bufferSize += 1; /* s8 primitive->scanConfig.highRssiThreshold */
+ bufferSize += 1; /* s8 primitive->scanConfig.lowRssiThreshold */
+ bufferSize += 1; /* s8 primitive->scanConfig.deltaRssiThreshold */
+ bufferSize += 1; /* s8 primitive->scanConfig.highSnrThreshold */
+ bufferSize += 1; /* s8 primitive->scanConfig.lowSnrThreshold */
+ bufferSize += 1; /* s8 primitive->scanConfig.deltaSnrThreshold */
+ bufferSize += 2; /* u16 primitive->scanConfig.passiveChannelListCount */
+ bufferSize += primitive->scanConfig.passiveChannelListCount; /* u8 primitive->scanConfig.passiveChannelList */
+ return bufferSize;
+}
+
+
+u8* CsrWifiSmeScanConfigSetReqSer(u8 *ptr, size_t *len, void *msg)
+{
+ CsrWifiSmeScanConfigSetReq *primitive = (CsrWifiSmeScanConfigSetReq *)msg;
+ *len = 0;
+ CsrUint16Ser(ptr, len, primitive->common.type);
+ {
+ u16 i2;
+ for (i2 = 0; i2 < 4; i2++)
+ {
+ CsrUint16Ser(ptr, len, (u16) primitive->scanConfig.scanCfg[i2].intervalSeconds);
+ CsrUint16Ser(ptr, len, (u16) primitive->scanConfig.scanCfg[i2].validitySeconds);
+ CsrUint16Ser(ptr, len, (u16) primitive->scanConfig.scanCfg[i2].minActiveChannelTimeTu);
+ CsrUint16Ser(ptr, len, (u16) primitive->scanConfig.scanCfg[i2].maxActiveChannelTimeTu);
+ CsrUint16Ser(ptr, len, (u16) primitive->scanConfig.scanCfg[i2].minPassiveChannelTimeTu);
+ CsrUint16Ser(ptr, len, (u16) primitive->scanConfig.scanCfg[i2].maxPassiveChannelTimeTu);
+ }
+ }
+ CsrUint8Ser(ptr, len, (u8) primitive->scanConfig.disableAutonomousScans);
+ CsrUint16Ser(ptr, len, (u16) primitive->scanConfig.maxResults);
+ CsrUint8Ser(ptr, len, (u8) primitive->scanConfig.highRssiThreshold);
+ CsrUint8Ser(ptr, len, (u8) primitive->scanConfig.lowRssiThreshold);
+ CsrUint8Ser(ptr, len, (u8) primitive->scanConfig.deltaRssiThreshold);
+ CsrUint8Ser(ptr, len, (u8) primitive->scanConfig.highSnrThreshold);
+ CsrUint8Ser(ptr, len, (u8) primitive->scanConfig.lowSnrThreshold);
+ CsrUint8Ser(ptr, len, (u8) primitive->scanConfig.deltaSnrThreshold);
+ CsrUint16Ser(ptr, len, (u16) primitive->scanConfig.passiveChannelListCount);
+ if (primitive->scanConfig.passiveChannelListCount)
+ {
+ CsrMemCpySer(ptr, len, (const void *) primitive->scanConfig.passiveChannelList, ((u16) (primitive->scanConfig.passiveChannelListCount)));
+ }
+ return(ptr);
+}
+
+
+void* CsrWifiSmeScanConfigSetReqDes(u8 *buffer, size_t length)
+{
+ CsrWifiSmeScanConfigSetReq *primitive = kmalloc(sizeof(CsrWifiSmeScanConfigSetReq), GFP_KERNEL);
+ size_t offset;
+ offset = 0;
+
+ CsrUint16Des(&primitive->common.type, buffer, &offset);
+ {
+ u16 i2;
+ for (i2 = 0; i2 < 4; i2++)
+ {
+ CsrUint16Des((u16 *) &primitive->scanConfig.scanCfg[i2].intervalSeconds, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->scanConfig.scanCfg[i2].validitySeconds, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->scanConfig.scanCfg[i2].minActiveChannelTimeTu, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->scanConfig.scanCfg[i2].maxActiveChannelTimeTu, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->scanConfig.scanCfg[i2].minPassiveChannelTimeTu, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->scanConfig.scanCfg[i2].maxPassiveChannelTimeTu, buffer, &offset);
+ }
+ }
+ CsrUint8Des((u8 *) &primitive->scanConfig.disableAutonomousScans, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->scanConfig.maxResults, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->scanConfig.highRssiThreshold, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->scanConfig.lowRssiThreshold, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->scanConfig.deltaRssiThreshold, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->scanConfig.highSnrThreshold, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->scanConfig.lowSnrThreshold, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->scanConfig.deltaSnrThreshold, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->scanConfig.passiveChannelListCount, buffer, &offset);
+ if (primitive->scanConfig.passiveChannelListCount)
+ {
+ primitive->scanConfig.passiveChannelList = kmalloc(primitive->scanConfig.passiveChannelListCount, GFP_KERNEL);
+ CsrMemCpyDes(primitive->scanConfig.passiveChannelList, buffer, &offset, ((u16) (primitive->scanConfig.passiveChannelListCount)));
+ }
+ else
+ {
+ primitive->scanConfig.passiveChannelList = NULL;
+ }
+
+ return primitive;
+}
+
+
+void CsrWifiSmeScanConfigSetReqSerFree(void *voidPrimitivePointer)
+{
+ CsrWifiSmeScanConfigSetReq *primitive = (CsrWifiSmeScanConfigSetReq *) voidPrimitivePointer;
+ kfree(primitive->scanConfig.passiveChannelList);
+ kfree(primitive);
+}
+
+
+size_t CsrWifiSmeScanFullReqSizeof(void *msg)
+{
+ CsrWifiSmeScanFullReq *primitive = (CsrWifiSmeScanFullReq *) msg;
+ size_t bufferSize = 2;
+
+ /* Calculate the Size of the Serialised Data. Could be more efficient (Try 52) */
+ bufferSize += 1; /* u8 primitive->ssidCount */
+ {
+ u16 i1;
+ for (i1 = 0; i1 < primitive->ssidCount; i1++)
+ {
+ bufferSize += 32; /* u8 primitive->ssid[i1].ssid[32] */
+ bufferSize += 1; /* u8 primitive->ssid[i1].length */
+ }
+ }
+ bufferSize += 6; /* u8 primitive->bssid.a[6] */
+ bufferSize += 1; /* u8 primitive->forceScan */
+ bufferSize += 1; /* CsrWifiSmeBssType primitive->bssType */
+ bufferSize += 1; /* CsrWifiSmeScanType primitive->scanType */
+ bufferSize += 2; /* u16 primitive->channelListCount */
+ bufferSize += primitive->channelListCount; /* u8 primitive->channelList */
+ bufferSize += 2; /* u16 primitive->probeIeLength */
+ bufferSize += primitive->probeIeLength; /* u8 primitive->probeIe */
+ return bufferSize;
+}
+
+
+u8* CsrWifiSmeScanFullReqSer(u8 *ptr, size_t *len, void *msg)
+{
+ CsrWifiSmeScanFullReq *primitive = (CsrWifiSmeScanFullReq *)msg;
+ *len = 0;
+ CsrUint16Ser(ptr, len, primitive->common.type);
+ CsrUint8Ser(ptr, len, (u8) primitive->ssidCount);
+ {
+ u16 i1;
+ for (i1 = 0; i1 < primitive->ssidCount; i1++)
+ {
+ CsrMemCpySer(ptr, len, (const void *) primitive->ssid[i1].ssid, ((u16) (32)));
+ CsrUint8Ser(ptr, len, (u8) primitive->ssid[i1].length);
+ }
+ }
+ CsrMemCpySer(ptr, len, (const void *) primitive->bssid.a, ((u16) (6)));
+ CsrUint8Ser(ptr, len, (u8) primitive->forceScan);
+ CsrUint8Ser(ptr, len, (u8) primitive->bssType);
+ CsrUint8Ser(ptr, len, (u8) primitive->scanType);
+ CsrUint16Ser(ptr, len, (u16) primitive->channelListCount);
+ if (primitive->channelListCount)
+ {
+ CsrMemCpySer(ptr, len, (const void *) primitive->channelList, ((u16) (primitive->channelListCount)));
+ }
+ CsrUint16Ser(ptr, len, (u16) primitive->probeIeLength);
+ if (primitive->probeIeLength)
+ {
+ CsrMemCpySer(ptr, len, (const void *) primitive->probeIe, ((u16) (primitive->probeIeLength)));
+ }
+ return(ptr);
+}
+
+
+void* CsrWifiSmeScanFullReqDes(u8 *buffer, size_t length)
+{
+ CsrWifiSmeScanFullReq *primitive = kmalloc(sizeof(CsrWifiSmeScanFullReq), GFP_KERNEL);
+ size_t offset;
+ offset = 0;
+
+ CsrUint16Des(&primitive->common.type, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->ssidCount, buffer, &offset);
+ primitive->ssid = NULL;
+ if (primitive->ssidCount)
+ {
+ primitive->ssid = kmalloc(sizeof(CsrWifiSsid) * primitive->ssidCount, GFP_KERNEL);
+ }
+ {
+ u16 i1;
+ for (i1 = 0; i1 < primitive->ssidCount; i1++)
+ {
+ CsrMemCpyDes(primitive->ssid[i1].ssid, buffer, &offset, ((u16) (32)));
+ CsrUint8Des((u8 *) &primitive->ssid[i1].length, buffer, &offset);
+ }
+ }
+ CsrMemCpyDes(primitive->bssid.a, buffer, &offset, ((u16) (6)));
+ CsrUint8Des((u8 *) &primitive->forceScan, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->bssType, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->scanType, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->channelListCount, buffer, &offset);
+ if (primitive->channelListCount)
+ {
+ primitive->channelList = kmalloc(primitive->channelListCount, GFP_KERNEL);
+ CsrMemCpyDes(primitive->channelList, buffer, &offset, ((u16) (primitive->channelListCount)));
+ }
+ else
+ {
+ primitive->channelList = NULL;
+ }
+ CsrUint16Des((u16 *) &primitive->probeIeLength, buffer, &offset);
+ if (primitive->probeIeLength)
+ {
+ primitive->probeIe = kmalloc(primitive->probeIeLength, GFP_KERNEL);
+ CsrMemCpyDes(primitive->probeIe, buffer, &offset, ((u16) (primitive->probeIeLength)));
+ }
+ else
+ {
+ primitive->probeIe = NULL;
+ }
+
+ return primitive;
+}
+
+
+void CsrWifiSmeScanFullReqSerFree(void *voidPrimitivePointer)
+{
+ CsrWifiSmeScanFullReq *primitive = (CsrWifiSmeScanFullReq *) voidPrimitivePointer;
+ kfree(primitive->ssid);
+ kfree(primitive->channelList);
+ kfree(primitive->probeIe);
+ kfree(primitive);
+}
+
+
+size_t CsrWifiSmeSmeStaConfigSetReqSizeof(void *msg)
+{
+ size_t bufferSize = 2;
+
+ /* Calculate the Size of the Serialised Data. Could be more efficient (Try 11) */
+ bufferSize += 2; /* u16 primitive->interfaceTag */
+ bufferSize += 1; /* u8 primitive->smeConfig.connectionQualityRssiChangeTrigger */
+ bufferSize += 1; /* u8 primitive->smeConfig.connectionQualitySnrChangeTrigger */
+ bufferSize += 1; /* CsrWifiSmeWmmModeMask primitive->smeConfig.wmmModeMask */
+ bufferSize += 1; /* CsrWifiSmeRadioIF primitive->smeConfig.ifIndex */
+ bufferSize += 1; /* u8 primitive->smeConfig.allowUnicastUseGroupCipher */
+ bufferSize += 1; /* u8 primitive->smeConfig.enableOpportunisticKeyCaching */
+ return bufferSize;
+}
+
+
+u8* CsrWifiSmeSmeStaConfigSetReqSer(u8 *ptr, size_t *len, void *msg)
+{
+ CsrWifiSmeSmeStaConfigSetReq *primitive = (CsrWifiSmeSmeStaConfigSetReq *)msg;
+ *len = 0;
+ CsrUint16Ser(ptr, len, primitive->common.type);
+ CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
+ CsrUint8Ser(ptr, len, (u8) primitive->smeConfig.connectionQualityRssiChangeTrigger);
+ CsrUint8Ser(ptr, len, (u8) primitive->smeConfig.connectionQualitySnrChangeTrigger);
+ CsrUint8Ser(ptr, len, (u8) primitive->smeConfig.wmmModeMask);
+ CsrUint8Ser(ptr, len, (u8) primitive->smeConfig.ifIndex);
+ CsrUint8Ser(ptr, len, (u8) primitive->smeConfig.allowUnicastUseGroupCipher);
+ CsrUint8Ser(ptr, len, (u8) primitive->smeConfig.enableOpportunisticKeyCaching);
+ return(ptr);
+}
+
+
+void* CsrWifiSmeSmeStaConfigSetReqDes(u8 *buffer, size_t length)
+{
+ CsrWifiSmeSmeStaConfigSetReq *primitive = kmalloc(sizeof(CsrWifiSmeSmeStaConfigSetReq), GFP_KERNEL);
+ size_t offset;
+ offset = 0;
+
+ CsrUint16Des(&primitive->common.type, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->smeConfig.connectionQualityRssiChangeTrigger, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->smeConfig.connectionQualitySnrChangeTrigger, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->smeConfig.wmmModeMask, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->smeConfig.ifIndex, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->smeConfig.allowUnicastUseGroupCipher, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->smeConfig.enableOpportunisticKeyCaching, buffer, &offset);
+
+ return primitive;
+}
+
+
+size_t CsrWifiSmeTspecReqSizeof(void *msg)
+{
+ CsrWifiSmeTspecReq *primitive = (CsrWifiSmeTspecReq *) msg;
+ size_t bufferSize = 2;
+
+ /* Calculate the Size of the Serialised Data. Could be more efficient (Try 18) */
+ bufferSize += 2; /* u16 primitive->interfaceTag */
+ bufferSize += 1; /* CsrWifiSmeListAction primitive->action */
+ bufferSize += 4; /* u32 primitive->transactionId */
+ bufferSize += 1; /* u8 primitive->strict */
+ bufferSize += 1; /* CsrWifiSmeTspecCtrlMask primitive->ctrlMask */
+ bufferSize += 2; /* u16 primitive->tspecLength */
+ bufferSize += primitive->tspecLength; /* u8 primitive->tspec */
+ bufferSize += 2; /* u16 primitive->tclasLength */
+ bufferSize += primitive->tclasLength; /* u8 primitive->tclas */
+ return bufferSize;
+}
+
+
+u8* CsrWifiSmeTspecReqSer(u8 *ptr, size_t *len, void *msg)
+{
+ CsrWifiSmeTspecReq *primitive = (CsrWifiSmeTspecReq *)msg;
+ *len = 0;
+ CsrUint16Ser(ptr, len, primitive->common.type);
+ CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
+ CsrUint8Ser(ptr, len, (u8) primitive->action);
+ CsrUint32Ser(ptr, len, (u32) primitive->transactionId);
+ CsrUint8Ser(ptr, len, (u8) primitive->strict);
+ CsrUint8Ser(ptr, len, (u8) primitive->ctrlMask);
+ CsrUint16Ser(ptr, len, (u16) primitive->tspecLength);
+ if (primitive->tspecLength)
+ {
+ CsrMemCpySer(ptr, len, (const void *) primitive->tspec, ((u16) (primitive->tspecLength)));
+ }
+ CsrUint16Ser(ptr, len, (u16) primitive->tclasLength);
+ if (primitive->tclasLength)
+ {
+ CsrMemCpySer(ptr, len, (const void *) primitive->tclas, ((u16) (primitive->tclasLength)));
+ }
+ return(ptr);
+}
+
+
+void* CsrWifiSmeTspecReqDes(u8 *buffer, size_t length)
+{
+ CsrWifiSmeTspecReq *primitive = kmalloc(sizeof(CsrWifiSmeTspecReq), GFP_KERNEL);
+ size_t offset;
+ offset = 0;
+
+ CsrUint16Des(&primitive->common.type, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->action, buffer, &offset);
+ CsrUint32Des((u32 *) &primitive->transactionId, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->strict, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->ctrlMask, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->tspecLength, buffer, &offset);
+ if (primitive->tspecLength)
+ {
+ primitive->tspec = kmalloc(primitive->tspecLength, GFP_KERNEL);
+ CsrMemCpyDes(primitive->tspec, buffer, &offset, ((u16) (primitive->tspecLength)));
+ }
+ else
+ {
+ primitive->tspec = NULL;
+ }
+ CsrUint16Des((u16 *) &primitive->tclasLength, buffer, &offset);
+ if (primitive->tclasLength)
+ {
+ primitive->tclas = kmalloc(primitive->tclasLength, GFP_KERNEL);
+ CsrMemCpyDes(primitive->tclas, buffer, &offset, ((u16) (primitive->tclasLength)));
+ }
+ else
+ {
+ primitive->tclas = NULL;
+ }
+
+ return primitive;
+}
+
+
+void CsrWifiSmeTspecReqSerFree(void *voidPrimitivePointer)
+{
+ CsrWifiSmeTspecReq *primitive = (CsrWifiSmeTspecReq *) voidPrimitivePointer;
+ kfree(primitive->tspec);
+ kfree(primitive->tclas);
+ kfree(primitive);
+}
+
+
+size_t CsrWifiSmeWifiFlightmodeReqSizeof(void *msg)
+{
+ CsrWifiSmeWifiFlightmodeReq *primitive = (CsrWifiSmeWifiFlightmodeReq *) msg;
+ size_t bufferSize = 2;
+
+ /* Calculate the Size of the Serialised Data. Could be more efficient (Try 14) */
+ bufferSize += 6; /* u8 primitive->address.a[6] */
+ bufferSize += 2; /* u16 primitive->mibFilesCount */
+ {
+ u16 i1;
+ for (i1 = 0; i1 < primitive->mibFilesCount; i1++)
+ {
+ bufferSize += 2; /* u16 primitive->mibFiles[i1].length */
+ bufferSize += primitive->mibFiles[i1].length; /* u8 primitive->mibFiles[i1].data */
+ }
+ }
+ return bufferSize;
+}
+
+
+u8* CsrWifiSmeWifiFlightmodeReqSer(u8 *ptr, size_t *len, void *msg)
+{
+ CsrWifiSmeWifiFlightmodeReq *primitive = (CsrWifiSmeWifiFlightmodeReq *)msg;
+ *len = 0;
+ CsrUint16Ser(ptr, len, primitive->common.type);
+ CsrMemCpySer(ptr, len, (const void *) primitive->address.a, ((u16) (6)));
+ CsrUint16Ser(ptr, len, (u16) primitive->mibFilesCount);
+ {
+ u16 i1;
+ for (i1 = 0; i1 < primitive->mibFilesCount; i1++)
+ {
+ CsrUint16Ser(ptr, len, (u16) primitive->mibFiles[i1].length);
+ if (primitive->mibFiles[i1].length)
+ {
+ CsrMemCpySer(ptr, len, (const void *) primitive->mibFiles[i1].data, ((u16) (primitive->mibFiles[i1].length)));
+ }
+ }
+ }
+ return(ptr);
+}
+
+
+void* CsrWifiSmeWifiFlightmodeReqDes(u8 *buffer, size_t length)
+{
+ CsrWifiSmeWifiFlightmodeReq *primitive = kmalloc(sizeof(CsrWifiSmeWifiFlightmodeReq), GFP_KERNEL);
+ size_t offset;
+ offset = 0;
+
+ CsrUint16Des(&primitive->common.type, buffer, &offset);
+ CsrMemCpyDes(primitive->address.a, buffer, &offset, ((u16) (6)));
+ CsrUint16Des((u16 *) &primitive->mibFilesCount, buffer, &offset);
+ primitive->mibFiles = NULL;
+ if (primitive->mibFilesCount)
+ {
+ primitive->mibFiles = kmalloc(sizeof(CsrWifiSmeDataBlock) * primitive->mibFilesCount, GFP_KERNEL);
+ }
+ {
+ u16 i1;
+ for (i1 = 0; i1 < primitive->mibFilesCount; i1++)
+ {
+ CsrUint16Des((u16 *) &primitive->mibFiles[i1].length, buffer, &offset);
+ if (primitive->mibFiles[i1].length)
+ {
+ primitive->mibFiles[i1].data = kmalloc(primitive->mibFiles[i1].length, GFP_KERNEL);
+ CsrMemCpyDes(primitive->mibFiles[i1].data, buffer, &offset, ((u16) (primitive->mibFiles[i1].length)));
+ }
+ else
+ {
+ primitive->mibFiles[i1].data = NULL;
+ }
+ }
+ }
+
+ return primitive;
+}
+
+
+void CsrWifiSmeWifiFlightmodeReqSerFree(void *voidPrimitivePointer)
+{
+ CsrWifiSmeWifiFlightmodeReq *primitive = (CsrWifiSmeWifiFlightmodeReq *) voidPrimitivePointer;
+ {
+ u16 i1;
+ for (i1 = 0; i1 < primitive->mibFilesCount; i1++)
+ {
+ kfree(primitive->mibFiles[i1].data);
+ }
+ }
+ kfree(primitive->mibFiles);
+ kfree(primitive);
+}
+
+
+size_t CsrWifiSmeWifiOnReqSizeof(void *msg)
+{
+ CsrWifiSmeWifiOnReq *primitive = (CsrWifiSmeWifiOnReq *) msg;
+ size_t bufferSize = 2;
+
+ /* Calculate the Size of the Serialised Data. Could be more efficient (Try 14) */
+ bufferSize += 6; /* u8 primitive->address.a[6] */
+ bufferSize += 2; /* u16 primitive->mibFilesCount */
+ {
+ u16 i1;
+ for (i1 = 0; i1 < primitive->mibFilesCount; i1++)
+ {
+ bufferSize += 2; /* u16 primitive->mibFiles[i1].length */
+ bufferSize += primitive->mibFiles[i1].length; /* u8 primitive->mibFiles[i1].data */
+ }
+ }
+ return bufferSize;
+}
+
+
+u8* CsrWifiSmeWifiOnReqSer(u8 *ptr, size_t *len, void *msg)
+{
+ CsrWifiSmeWifiOnReq *primitive = (CsrWifiSmeWifiOnReq *)msg;
+ *len = 0;
+ CsrUint16Ser(ptr, len, primitive->common.type);
+ CsrMemCpySer(ptr, len, (const void *) primitive->address.a, ((u16) (6)));
+ CsrUint16Ser(ptr, len, (u16) primitive->mibFilesCount);
+ {
+ u16 i1;
+ for (i1 = 0; i1 < primitive->mibFilesCount; i1++)
+ {
+ CsrUint16Ser(ptr, len, (u16) primitive->mibFiles[i1].length);
+ if (primitive->mibFiles[i1].length)
+ {
+ CsrMemCpySer(ptr, len, (const void *) primitive->mibFiles[i1].data, ((u16) (primitive->mibFiles[i1].length)));
+ }
+ }
+ }
+ return(ptr);
+}
+
+
+void* CsrWifiSmeWifiOnReqDes(u8 *buffer, size_t length)
+{
+ CsrWifiSmeWifiOnReq *primitive = kmalloc(sizeof(CsrWifiSmeWifiOnReq), GFP_KERNEL);
+ size_t offset;
+ offset = 0;
+
+ CsrUint16Des(&primitive->common.type, buffer, &offset);
+ CsrMemCpyDes(primitive->address.a, buffer, &offset, ((u16) (6)));
+ CsrUint16Des((u16 *) &primitive->mibFilesCount, buffer, &offset);
+ primitive->mibFiles = NULL;
+ if (primitive->mibFilesCount)
+ {
+ primitive->mibFiles = kmalloc(sizeof(CsrWifiSmeDataBlock) * primitive->mibFilesCount, GFP_KERNEL);
+ }
+ {
+ u16 i1;
+ for (i1 = 0; i1 < primitive->mibFilesCount; i1++)
+ {
+ CsrUint16Des((u16 *) &primitive->mibFiles[i1].length, buffer, &offset);
+ if (primitive->mibFiles[i1].length)
+ {
+ primitive->mibFiles[i1].data = kmalloc(primitive->mibFiles[i1].length, GFP_KERNEL);
+ CsrMemCpyDes(primitive->mibFiles[i1].data, buffer, &offset, ((u16) (primitive->mibFiles[i1].length)));
+ }
+ else
+ {
+ primitive->mibFiles[i1].data = NULL;
+ }
+ }
+ }
+
+ return primitive;
+}
+
+
+void CsrWifiSmeWifiOnReqSerFree(void *voidPrimitivePointer)
+{
+ CsrWifiSmeWifiOnReq *primitive = (CsrWifiSmeWifiOnReq *) voidPrimitivePointer;
+ {
+ u16 i1;
+ for (i1 = 0; i1 < primitive->mibFilesCount; i1++)
+ {
+ kfree(primitive->mibFiles[i1].data);
+ }
+ }
+ kfree(primitive->mibFiles);
+ kfree(primitive);
+}
+
+
+size_t CsrWifiSmeCloakedSsidsSetReqSizeof(void *msg)
+{
+ CsrWifiSmeCloakedSsidsSetReq *primitive = (CsrWifiSmeCloakedSsidsSetReq *) msg;
+ size_t bufferSize = 2;
+
+ /* Calculate the Size of the Serialised Data. Could be more efficient (Try 37) */
+ bufferSize += 1; /* u8 primitive->cloakedSsids.cloakedSsidsCount */
+ {
+ u16 i2;
+ for (i2 = 0; i2 < primitive->cloakedSsids.cloakedSsidsCount; i2++)
+ {
+ bufferSize += 32; /* u8 primitive->cloakedSsids.cloakedSsids[i2].ssid[32] */
+ bufferSize += 1; /* u8 primitive->cloakedSsids.cloakedSsids[i2].length */
+ }
+ }
+ return bufferSize;
+}
+
+
+u8* CsrWifiSmeCloakedSsidsSetReqSer(u8 *ptr, size_t *len, void *msg)
+{
+ CsrWifiSmeCloakedSsidsSetReq *primitive = (CsrWifiSmeCloakedSsidsSetReq *)msg;
+ *len = 0;
+ CsrUint16Ser(ptr, len, primitive->common.type);
+ CsrUint8Ser(ptr, len, (u8) primitive->cloakedSsids.cloakedSsidsCount);
+ {
+ u16 i2;
+ for (i2 = 0; i2 < primitive->cloakedSsids.cloakedSsidsCount; i2++)
+ {
+ CsrMemCpySer(ptr, len, (const void *) primitive->cloakedSsids.cloakedSsids[i2].ssid, ((u16) (32)));
+ CsrUint8Ser(ptr, len, (u8) primitive->cloakedSsids.cloakedSsids[i2].length);
+ }
+ }
+ return(ptr);
+}
+
+
+void* CsrWifiSmeCloakedSsidsSetReqDes(u8 *buffer, size_t length)
+{
+ CsrWifiSmeCloakedSsidsSetReq *primitive = kmalloc(sizeof(CsrWifiSmeCloakedSsidsSetReq), GFP_KERNEL);
+ size_t offset;
+ offset = 0;
+
+ CsrUint16Des(&primitive->common.type, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->cloakedSsids.cloakedSsidsCount, buffer, &offset);
+ primitive->cloakedSsids.cloakedSsids = NULL;
+ if (primitive->cloakedSsids.cloakedSsidsCount)
+ {
+ primitive->cloakedSsids.cloakedSsids = kmalloc(sizeof(CsrWifiSsid) * primitive->cloakedSsids.cloakedSsidsCount, GFP_KERNEL);
+ }
+ {
+ u16 i2;
+ for (i2 = 0; i2 < primitive->cloakedSsids.cloakedSsidsCount; i2++)
+ {
+ CsrMemCpyDes(primitive->cloakedSsids.cloakedSsids[i2].ssid, buffer, &offset, ((u16) (32)));
+ CsrUint8Des((u8 *) &primitive->cloakedSsids.cloakedSsids[i2].length, buffer, &offset);
+ }
+ }
+
+ return primitive;
+}
+
+
+void CsrWifiSmeCloakedSsidsSetReqSerFree(void *voidPrimitivePointer)
+{
+ CsrWifiSmeCloakedSsidsSetReq *primitive = (CsrWifiSmeCloakedSsidsSetReq *) voidPrimitivePointer;
+ kfree(primitive->cloakedSsids.cloakedSsids);
+ kfree(primitive);
+}
+
+
+size_t CsrWifiSmeSmeCommonConfigSetReqSizeof(void *msg)
+{
+ size_t bufferSize = 2;
+
+ /* Calculate the Size of the Serialised Data. Could be more efficient (Try 8) */
+ bufferSize += 1; /* CsrWifiSme80211dTrustLevel primitive->deviceConfig.trustLevel */
+ bufferSize += 2; /* u8 primitive->deviceConfig.countryCode[2] */
+ bufferSize += 1; /* CsrWifiSmeFirmwareDriverInterface primitive->deviceConfig.firmwareDriverInterface */
+ bufferSize += 1; /* u8 primitive->deviceConfig.enableStrictDraftN */
+ return bufferSize;
+}
+
+
+u8* CsrWifiSmeSmeCommonConfigSetReqSer(u8 *ptr, size_t *len, void *msg)
+{
+ CsrWifiSmeSmeCommonConfigSetReq *primitive = (CsrWifiSmeSmeCommonConfigSetReq *)msg;
+ *len = 0;
+ CsrUint16Ser(ptr, len, primitive->common.type);
+ CsrUint8Ser(ptr, len, (u8) primitive->deviceConfig.trustLevel);
+ CsrMemCpySer(ptr, len, (const void *) primitive->deviceConfig.countryCode, ((u16) (2)));
+ CsrUint8Ser(ptr, len, (u8) primitive->deviceConfig.firmwareDriverInterface);
+ CsrUint8Ser(ptr, len, (u8) primitive->deviceConfig.enableStrictDraftN);
+ return(ptr);
+}
+
+
+void* CsrWifiSmeSmeCommonConfigSetReqDes(u8 *buffer, size_t length)
+{
+ CsrWifiSmeSmeCommonConfigSetReq *primitive = kmalloc(sizeof(CsrWifiSmeSmeCommonConfigSetReq), GFP_KERNEL);
+ size_t offset;
+ offset = 0;
+
+ CsrUint16Des(&primitive->common.type, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->deviceConfig.trustLevel, buffer, &offset);
+ CsrMemCpyDes(primitive->deviceConfig.countryCode, buffer, &offset, ((u16) (2)));
+ CsrUint8Des((u8 *) &primitive->deviceConfig.firmwareDriverInterface, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->deviceConfig.enableStrictDraftN, buffer, &offset);
+
+ return primitive;
+}
+
+
+size_t CsrWifiSmeWpsConfigurationReqSizeof(void *msg)
+{
+ CsrWifiSmeWpsConfigurationReq *primitive = (CsrWifiSmeWpsConfigurationReq *) msg;
+ size_t bufferSize = 2;
+
+ /* Calculate the Size of the Serialised Data. Could be more efficient (Try 240) */
+ bufferSize += 1; /* u8 primitive->wpsConfig.wpsVersion */
+ bufferSize += 16; /* u8 primitive->wpsConfig.uuid[16] */
+ bufferSize += 32; /* u8 primitive->wpsConfig.deviceName[32] */
+ bufferSize += 1; /* u8 primitive->wpsConfig.deviceNameLength */
+ bufferSize += 64; /* u8 primitive->wpsConfig.manufacturer[64] */
+ bufferSize += 1; /* u8 primitive->wpsConfig.manufacturerLength */
+ bufferSize += 32; /* u8 primitive->wpsConfig.modelName[32] */
+ bufferSize += 1; /* u8 primitive->wpsConfig.modelNameLength */
+ bufferSize += 32; /* u8 primitive->wpsConfig.modelNumber[32] */
+ bufferSize += 1; /* u8 primitive->wpsConfig.modelNumberLength */
+ bufferSize += 32; /* u8 primitive->wpsConfig.serialNumber[32] */
+ bufferSize += 8; /* u8 primitive->wpsConfig.primDeviceType.deviceDetails[8] */
+ bufferSize += 1; /* u8 primitive->wpsConfig.secondaryDeviceTypeCount */
+ {
+ u16 i2;
+ for (i2 = 0; i2 < primitive->wpsConfig.secondaryDeviceTypeCount; i2++)
+ {
+ bufferSize += 8; /* u8 primitive->wpsConfig.secondaryDeviceType[i2].deviceDetails[8] */
+ }
+ }
+ bufferSize += 2; /* CsrWifiSmeWpsConfigTypeMask primitive->wpsConfig.configMethods */
+ bufferSize += 1; /* u8 primitive->wpsConfig.rfBands */
+ bufferSize += 4; /* u8 primitive->wpsConfig.osVersion[4] */
+ return bufferSize;
+}
+
+
+u8* CsrWifiSmeWpsConfigurationReqSer(u8 *ptr, size_t *len, void *msg)
+{
+ CsrWifiSmeWpsConfigurationReq *primitive = (CsrWifiSmeWpsConfigurationReq *)msg;
+ *len = 0;
+ CsrUint16Ser(ptr, len, primitive->common.type);
+ CsrUint8Ser(ptr, len, (u8) primitive->wpsConfig.wpsVersion);
+ CsrMemCpySer(ptr, len, (const void *) primitive->wpsConfig.uuid, ((u16) (16)));
+ CsrMemCpySer(ptr, len, (const void *) primitive->wpsConfig.deviceName, ((u16) (32)));
+ CsrUint8Ser(ptr, len, (u8) primitive->wpsConfig.deviceNameLength);
+ CsrMemCpySer(ptr, len, (const void *) primitive->wpsConfig.manufacturer, ((u16) (64)));
+ CsrUint8Ser(ptr, len, (u8) primitive->wpsConfig.manufacturerLength);
+ CsrMemCpySer(ptr, len, (const void *) primitive->wpsConfig.modelName, ((u16) (32)));
+ CsrUint8Ser(ptr, len, (u8) primitive->wpsConfig.modelNameLength);
+ CsrMemCpySer(ptr, len, (const void *) primitive->wpsConfig.modelNumber, ((u16) (32)));
+ CsrUint8Ser(ptr, len, (u8) primitive->wpsConfig.modelNumberLength);
+ CsrMemCpySer(ptr, len, (const void *) primitive->wpsConfig.serialNumber, ((u16) (32)));
+ CsrMemCpySer(ptr, len, (const void *) primitive->wpsConfig.primDeviceType.deviceDetails, ((u16) (8)));
+ CsrUint8Ser(ptr, len, (u8) primitive->wpsConfig.secondaryDeviceTypeCount);
+ {
+ u16 i2;
+ for (i2 = 0; i2 < primitive->wpsConfig.secondaryDeviceTypeCount; i2++)
+ {
+ CsrMemCpySer(ptr, len, (const void *) primitive->wpsConfig.secondaryDeviceType[i2].deviceDetails, ((u16) (8)));
+ }
+ }
+ CsrUint16Ser(ptr, len, (u16) primitive->wpsConfig.configMethods);
+ CsrUint8Ser(ptr, len, (u8) primitive->wpsConfig.rfBands);
+ CsrMemCpySer(ptr, len, (const void *) primitive->wpsConfig.osVersion, ((u16) (4)));
+ return(ptr);
+}
+
+
+void* CsrWifiSmeWpsConfigurationReqDes(u8 *buffer, size_t length)
+{
+ CsrWifiSmeWpsConfigurationReq *primitive = kmalloc(sizeof(CsrWifiSmeWpsConfigurationReq), GFP_KERNEL);
+ size_t offset;
+ offset = 0;
+
+ CsrUint16Des(&primitive->common.type, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->wpsConfig.wpsVersion, buffer, &offset);
+ CsrMemCpyDes(primitive->wpsConfig.uuid, buffer, &offset, ((u16) (16)));
+ CsrMemCpyDes(primitive->wpsConfig.deviceName, buffer, &offset, ((u16) (32)));
+ CsrUint8Des((u8 *) &primitive->wpsConfig.deviceNameLength, buffer, &offset);
+ CsrMemCpyDes(primitive->wpsConfig.manufacturer, buffer, &offset, ((u16) (64)));
+ CsrUint8Des((u8 *) &primitive->wpsConfig.manufacturerLength, buffer, &offset);
+ CsrMemCpyDes(primitive->wpsConfig.modelName, buffer, &offset, ((u16) (32)));
+ CsrUint8Des((u8 *) &primitive->wpsConfig.modelNameLength, buffer, &offset);
+ CsrMemCpyDes(primitive->wpsConfig.modelNumber, buffer, &offset, ((u16) (32)));
+ CsrUint8Des((u8 *) &primitive->wpsConfig.modelNumberLength, buffer, &offset);
+ CsrMemCpyDes(primitive->wpsConfig.serialNumber, buffer, &offset, ((u16) (32)));
+ CsrMemCpyDes(primitive->wpsConfig.primDeviceType.deviceDetails, buffer, &offset, ((u16) (8)));
+ CsrUint8Des((u8 *) &primitive->wpsConfig.secondaryDeviceTypeCount, buffer, &offset);
+ primitive->wpsConfig.secondaryDeviceType = NULL;
+ if (primitive->wpsConfig.secondaryDeviceTypeCount)
+ {
+ primitive->wpsConfig.secondaryDeviceType = kmalloc(sizeof(CsrWifiSmeWpsDeviceType) * primitive->wpsConfig.secondaryDeviceTypeCount, GFP_KERNEL);
+ }
+ {
+ u16 i2;
+ for (i2 = 0; i2 < primitive->wpsConfig.secondaryDeviceTypeCount; i2++)
+ {
+ CsrMemCpyDes(primitive->wpsConfig.secondaryDeviceType[i2].deviceDetails, buffer, &offset, ((u16) (8)));
+ }
+ }
+ CsrUint16Des((u16 *) &primitive->wpsConfig.configMethods, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->wpsConfig.rfBands, buffer, &offset);
+ CsrMemCpyDes(primitive->wpsConfig.osVersion, buffer, &offset, ((u16) (4)));
+
+ return primitive;
+}
+
+
+void CsrWifiSmeWpsConfigurationReqSerFree(void *voidPrimitivePointer)
+{
+ CsrWifiSmeWpsConfigurationReq *primitive = (CsrWifiSmeWpsConfigurationReq *) voidPrimitivePointer;
+ kfree(primitive->wpsConfig.secondaryDeviceType);
+ kfree(primitive);
+}
+
+
+size_t CsrWifiSmeSetReqSizeof(void *msg)
+{
+ CsrWifiSmeSetReq *primitive = (CsrWifiSmeSetReq *) msg;
+ size_t bufferSize = 2;
+
+ /* Calculate the Size of the Serialised Data. Could be more efficient (Try 8) */
+ bufferSize += 4; /* u32 primitive->dataLength */
+ bufferSize += primitive->dataLength; /* u8 primitive->data */
+ return bufferSize;
+}
+
+
+u8* CsrWifiSmeSetReqSer(u8 *ptr, size_t *len, void *msg)
+{
+ CsrWifiSmeSetReq *primitive = (CsrWifiSmeSetReq *)msg;
+ *len = 0;
+ CsrUint16Ser(ptr, len, primitive->common.type);
+ CsrUint32Ser(ptr, len, (u32) primitive->dataLength);
+ if (primitive->dataLength)
+ {
+ CsrMemCpySer(ptr, len, (const void *) primitive->data, ((u16) (primitive->dataLength)));
+ }
+ return(ptr);
+}
+
+
+void* CsrWifiSmeSetReqDes(u8 *buffer, size_t length)
+{
+ CsrWifiSmeSetReq *primitive = kmalloc(sizeof(CsrWifiSmeSetReq), GFP_KERNEL);
+ size_t offset;
+ offset = 0;
+
+ CsrUint16Des(&primitive->common.type, buffer, &offset);
+ CsrUint32Des((u32 *) &primitive->dataLength, buffer, &offset);
+ if (primitive->dataLength)
+ {
+ primitive->data = kmalloc(primitive->dataLength, GFP_KERNEL);
+ CsrMemCpyDes(primitive->data, buffer, &offset, ((u16) (primitive->dataLength)));
+ }
+ else
+ {
+ primitive->data = NULL;
+ }
+
+ return primitive;
+}
+
+
+void CsrWifiSmeSetReqSerFree(void *voidPrimitivePointer)
+{
+ CsrWifiSmeSetReq *primitive = (CsrWifiSmeSetReq *) voidPrimitivePointer;
+ kfree(primitive->data);
+ kfree(primitive);
+}
+
+
+size_t CsrWifiSmeAdhocConfigGetCfmSizeof(void *msg)
+{
+ size_t bufferSize = 2;
+
+ /* Calculate the Size of the Serialised Data. Could be more efficient (Try 13) */
+ bufferSize += 2; /* CsrResult primitive->status */
+ bufferSize += 2; /* u16 primitive->adHocConfig.atimWindowTu */
+ bufferSize += 2; /* u16 primitive->adHocConfig.beaconPeriodTu */
+ bufferSize += 2; /* u16 primitive->adHocConfig.joinOnlyAttempts */
+ bufferSize += 2; /* u16 primitive->adHocConfig.joinAttemptIntervalMs */
+ return bufferSize;
+}
+
+
+u8* CsrWifiSmeAdhocConfigGetCfmSer(u8 *ptr, size_t *len, void *msg)
+{
+ CsrWifiSmeAdhocConfigGetCfm *primitive = (CsrWifiSmeAdhocConfigGetCfm *)msg;
+ *len = 0;
+ CsrUint16Ser(ptr, len, primitive->common.type);
+ CsrUint16Ser(ptr, len, (u16) primitive->status);
+ CsrUint16Ser(ptr, len, (u16) primitive->adHocConfig.atimWindowTu);
+ CsrUint16Ser(ptr, len, (u16) primitive->adHocConfig.beaconPeriodTu);
+ CsrUint16Ser(ptr, len, (u16) primitive->adHocConfig.joinOnlyAttempts);
+ CsrUint16Ser(ptr, len, (u16) primitive->adHocConfig.joinAttemptIntervalMs);
+ return(ptr);
+}
+
+
+void* CsrWifiSmeAdhocConfigGetCfmDes(u8 *buffer, size_t length)
+{
+ CsrWifiSmeAdhocConfigGetCfm *primitive = kmalloc(sizeof(CsrWifiSmeAdhocConfigGetCfm), GFP_KERNEL);
+ size_t offset;
+ offset = 0;
+
+ CsrUint16Des(&primitive->common.type, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->adHocConfig.atimWindowTu, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->adHocConfig.beaconPeriodTu, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->adHocConfig.joinOnlyAttempts, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->adHocConfig.joinAttemptIntervalMs, buffer, &offset);
+
+ return primitive;
+}
+
+
+size_t CsrWifiSmeAssociationCompleteIndSizeof(void *msg)
+{
+ CsrWifiSmeAssociationCompleteInd *primitive = (CsrWifiSmeAssociationCompleteInd *) msg;
+ size_t bufferSize = 2;
+
+ /* Calculate the Size of the Serialised Data. Could be more efficient (Try 98) */
+ bufferSize += 2; /* u16 primitive->interfaceTag */
+ bufferSize += 2; /* CsrResult primitive->status */
+ bufferSize += 32; /* u8 primitive->connectionInfo.ssid.ssid[32] */
+ bufferSize += 1; /* u8 primitive->connectionInfo.ssid.length */
+ bufferSize += 6; /* u8 primitive->connectionInfo.bssid.a[6] */
+ bufferSize += 1; /* CsrWifiSme80211NetworkType primitive->connectionInfo.networkType80211 */
+ bufferSize += 1; /* u8 primitive->connectionInfo.channelNumber */
+ bufferSize += 2; /* u16 primitive->connectionInfo.channelFrequency */
+ bufferSize += 2; /* CsrWifiSmeAuthMode primitive->connectionInfo.authMode */
+ bufferSize += 2; /* CsrWifiSmeEncryption primitive->connectionInfo.pairwiseCipher */
+ bufferSize += 2; /* CsrWifiSmeEncryption primitive->connectionInfo.groupCipher */
+ bufferSize += 1; /* CsrWifiSmeRadioIF primitive->connectionInfo.ifIndex */
+ bufferSize += 2; /* u16 primitive->connectionInfo.atimWindowTu */
+ bufferSize += 2; /* u16 primitive->connectionInfo.beaconPeriodTu */
+ bufferSize += 1; /* u8 primitive->connectionInfo.reassociation */
+ bufferSize += 2; /* u16 primitive->connectionInfo.beaconFrameLength */
+ bufferSize += primitive->connectionInfo.beaconFrameLength; /* u8 primitive->connectionInfo.beaconFrame */
+ bufferSize += 2; /* u16 primitive->connectionInfo.associationReqFrameLength */
+ bufferSize += primitive->connectionInfo.associationReqFrameLength; /* u8 primitive->connectionInfo.associationReqFrame */
+ bufferSize += 2; /* u16 primitive->connectionInfo.associationRspFrameLength */
+ bufferSize += primitive->connectionInfo.associationRspFrameLength; /* u8 primitive->connectionInfo.associationRspFrame */
+ bufferSize += 2; /* u16 primitive->connectionInfo.assocScanInfoElementsLength */
+ bufferSize += primitive->connectionInfo.assocScanInfoElementsLength; /* u8 primitive->connectionInfo.assocScanInfoElements */
+ bufferSize += 2; /* u16 primitive->connectionInfo.assocReqCapabilities */
+ bufferSize += 2; /* u16 primitive->connectionInfo.assocReqListenIntervalTu */
+ bufferSize += 6; /* u8 primitive->connectionInfo.assocReqApAddress.a[6] */
+ bufferSize += 2; /* u16 primitive->connectionInfo.assocReqInfoElementsLength */
+ bufferSize += primitive->connectionInfo.assocReqInfoElementsLength; /* u8 primitive->connectionInfo.assocReqInfoElements */
+ bufferSize += 2; /* CsrWifiSmeIEEE80211Result primitive->connectionInfo.assocRspResult */
+ bufferSize += 2; /* u16 primitive->connectionInfo.assocRspCapabilityInfo */
+ bufferSize += 2; /* u16 primitive->connectionInfo.assocRspAssociationId */
+ bufferSize += 2; /* u16 primitive->connectionInfo.assocRspInfoElementsLength */
+ bufferSize += primitive->connectionInfo.assocRspInfoElementsLength; /* u8 primitive->connectionInfo.assocRspInfoElements */
+ bufferSize += 2; /* CsrWifiSmeIEEE80211Reason primitive->deauthReason */
+ return bufferSize;
+}
+
+
+u8* CsrWifiSmeAssociationCompleteIndSer(u8 *ptr, size_t *len, void *msg)
+{
+ CsrWifiSmeAssociationCompleteInd *primitive = (CsrWifiSmeAssociationCompleteInd *)msg;
+ *len = 0;
+ CsrUint16Ser(ptr, len, primitive->common.type);
+ CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
+ CsrUint16Ser(ptr, len, (u16) primitive->status);
+ CsrMemCpySer(ptr, len, (const void *) primitive->connectionInfo.ssid.ssid, ((u16) (32)));
+ CsrUint8Ser(ptr, len, (u8) primitive->connectionInfo.ssid.length);
+ CsrMemCpySer(ptr, len, (const void *) primitive->connectionInfo.bssid.a, ((u16) (6)));
+ CsrUint8Ser(ptr, len, (u8) primitive->connectionInfo.networkType80211);
+ CsrUint8Ser(ptr, len, (u8) primitive->connectionInfo.channelNumber);
+ CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.channelFrequency);
+ CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.authMode);
+ CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.pairwiseCipher);
+ CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.groupCipher);
+ CsrUint8Ser(ptr, len, (u8) primitive->connectionInfo.ifIndex);
+ CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.atimWindowTu);
+ CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.beaconPeriodTu);
+ CsrUint8Ser(ptr, len, (u8) primitive->connectionInfo.reassociation);
+ CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.beaconFrameLength);
+ if (primitive->connectionInfo.beaconFrameLength)
+ {
+ CsrMemCpySer(ptr, len, (const void *) primitive->connectionInfo.beaconFrame, ((u16) (primitive->connectionInfo.beaconFrameLength)));
+ }
+ CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.associationReqFrameLength);
+ if (primitive->connectionInfo.associationReqFrameLength)
+ {
+ CsrMemCpySer(ptr, len, (const void *) primitive->connectionInfo.associationReqFrame, ((u16) (primitive->connectionInfo.associationReqFrameLength)));
+ }
+ CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.associationRspFrameLength);
+ if (primitive->connectionInfo.associationRspFrameLength)
+ {
+ CsrMemCpySer(ptr, len, (const void *) primitive->connectionInfo.associationRspFrame, ((u16) (primitive->connectionInfo.associationRspFrameLength)));
+ }
+ CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.assocScanInfoElementsLength);
+ if (primitive->connectionInfo.assocScanInfoElementsLength)
+ {
+ CsrMemCpySer(ptr, len, (const void *) primitive->connectionInfo.assocScanInfoElements, ((u16) (primitive->connectionInfo.assocScanInfoElementsLength)));
+ }
+ CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.assocReqCapabilities);
+ CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.assocReqListenIntervalTu);
+ CsrMemCpySer(ptr, len, (const void *) primitive->connectionInfo.assocReqApAddress.a, ((u16) (6)));
+ CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.assocReqInfoElementsLength);
+ if (primitive->connectionInfo.assocReqInfoElementsLength)
+ {
+ CsrMemCpySer(ptr, len, (const void *) primitive->connectionInfo.assocReqInfoElements, ((u16) (primitive->connectionInfo.assocReqInfoElementsLength)));
+ }
+ CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.assocRspResult);
+ CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.assocRspCapabilityInfo);
+ CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.assocRspAssociationId);
+ CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.assocRspInfoElementsLength);
+ if (primitive->connectionInfo.assocRspInfoElementsLength)
+ {
+ CsrMemCpySer(ptr, len, (const void *) primitive->connectionInfo.assocRspInfoElements, ((u16) (primitive->connectionInfo.assocRspInfoElementsLength)));
+ }
+ CsrUint16Ser(ptr, len, (u16) primitive->deauthReason);
+ return(ptr);
+}
+
+
+void* CsrWifiSmeAssociationCompleteIndDes(u8 *buffer, size_t length)
+{
+ CsrWifiSmeAssociationCompleteInd *primitive = kmalloc(sizeof(CsrWifiSmeAssociationCompleteInd), GFP_KERNEL);
+ size_t offset;
+ offset = 0;
+
+ CsrUint16Des(&primitive->common.type, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
+ CsrMemCpyDes(primitive->connectionInfo.ssid.ssid, buffer, &offset, ((u16) (32)));
+ CsrUint8Des((u8 *) &primitive->connectionInfo.ssid.length, buffer, &offset);
+ CsrMemCpyDes(primitive->connectionInfo.bssid.a, buffer, &offset, ((u16) (6)));
+ CsrUint8Des((u8 *) &primitive->connectionInfo.networkType80211, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->connectionInfo.channelNumber, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->connectionInfo.channelFrequency, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->connectionInfo.authMode, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->connectionInfo.pairwiseCipher, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->connectionInfo.groupCipher, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->connectionInfo.ifIndex, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->connectionInfo.atimWindowTu, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->connectionInfo.beaconPeriodTu, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->connectionInfo.reassociation, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->connectionInfo.beaconFrameLength, buffer, &offset);
+ if (primitive->connectionInfo.beaconFrameLength)
+ {
+ primitive->connectionInfo.beaconFrame = kmalloc(primitive->connectionInfo.beaconFrameLength, GFP_KERNEL);
+ CsrMemCpyDes(primitive->connectionInfo.beaconFrame, buffer, &offset, ((u16) (primitive->connectionInfo.beaconFrameLength)));
+ }
+ else
+ {
+ primitive->connectionInfo.beaconFrame = NULL;
+ }
+ CsrUint16Des((u16 *) &primitive->connectionInfo.associationReqFrameLength, buffer, &offset);
+ if (primitive->connectionInfo.associationReqFrameLength)
+ {
+ primitive->connectionInfo.associationReqFrame = kmalloc(primitive->connectionInfo.associationReqFrameLength, GFP_KERNEL);
+ CsrMemCpyDes(primitive->connectionInfo.associationReqFrame, buffer, &offset, ((u16) (primitive->connectionInfo.associationReqFrameLength)));
+ }
+ else
+ {
+ primitive->connectionInfo.associationReqFrame = NULL;
+ }
+ CsrUint16Des((u16 *) &primitive->connectionInfo.associationRspFrameLength, buffer, &offset);
+ if (primitive->connectionInfo.associationRspFrameLength)
+ {
+ primitive->connectionInfo.associationRspFrame = kmalloc(primitive->connectionInfo.associationRspFrameLength, GFP_KERNEL);
+ CsrMemCpyDes(primitive->connectionInfo.associationRspFrame, buffer, &offset, ((u16) (primitive->connectionInfo.associationRspFrameLength)));
+ }
+ else
+ {
+ primitive->connectionInfo.associationRspFrame = NULL;
+ }
+ CsrUint16Des((u16 *) &primitive->connectionInfo.assocScanInfoElementsLength, buffer, &offset);
+ if (primitive->connectionInfo.assocScanInfoElementsLength)
+ {
+ primitive->connectionInfo.assocScanInfoElements = kmalloc(primitive->connectionInfo.assocScanInfoElementsLength, GFP_KERNEL);
+ CsrMemCpyDes(primitive->connectionInfo.assocScanInfoElements, buffer, &offset, ((u16) (primitive->connectionInfo.assocScanInfoElementsLength)));
+ }
+ else
+ {
+ primitive->connectionInfo.assocScanInfoElements = NULL;
+ }
+ CsrUint16Des((u16 *) &primitive->connectionInfo.assocReqCapabilities, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->connectionInfo.assocReqListenIntervalTu, buffer, &offset);
+ CsrMemCpyDes(primitive->connectionInfo.assocReqApAddress.a, buffer, &offset, ((u16) (6)));
+ CsrUint16Des((u16 *) &primitive->connectionInfo.assocReqInfoElementsLength, buffer, &offset);
+ if (primitive->connectionInfo.assocReqInfoElementsLength)
+ {
+ primitive->connectionInfo.assocReqInfoElements = kmalloc(primitive->connectionInfo.assocReqInfoElementsLength, GFP_KERNEL);
+ CsrMemCpyDes(primitive->connectionInfo.assocReqInfoElements, buffer, &offset, ((u16) (primitive->connectionInfo.assocReqInfoElementsLength)));
+ }
+ else
+ {
+ primitive->connectionInfo.assocReqInfoElements = NULL;
+ }
+ CsrUint16Des((u16 *) &primitive->connectionInfo.assocRspResult, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->connectionInfo.assocRspCapabilityInfo, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->connectionInfo.assocRspAssociationId, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->connectionInfo.assocRspInfoElementsLength, buffer, &offset);
+ if (primitive->connectionInfo.assocRspInfoElementsLength)
+ {
+ primitive->connectionInfo.assocRspInfoElements = kmalloc(primitive->connectionInfo.assocRspInfoElementsLength, GFP_KERNEL);
+ CsrMemCpyDes(primitive->connectionInfo.assocRspInfoElements, buffer, &offset, ((u16) (primitive->connectionInfo.assocRspInfoElementsLength)));
+ }
+ else
+ {
+ primitive->connectionInfo.assocRspInfoElements = NULL;
+ }
+ CsrUint16Des((u16 *) &primitive->deauthReason, buffer, &offset);
+
+ return primitive;
+}
+
+
+void CsrWifiSmeAssociationCompleteIndSerFree(void *voidPrimitivePointer)
+{
+ CsrWifiSmeAssociationCompleteInd *primitive = (CsrWifiSmeAssociationCompleteInd *) voidPrimitivePointer;
+ kfree(primitive->connectionInfo.beaconFrame);
+ kfree(primitive->connectionInfo.associationReqFrame);
+ kfree(primitive->connectionInfo.associationRspFrame);
+ kfree(primitive->connectionInfo.assocScanInfoElements);
+ kfree(primitive->connectionInfo.assocReqInfoElements);
+ kfree(primitive->connectionInfo.assocRspInfoElements);
+ kfree(primitive);
+}
+
+
+size_t CsrWifiSmeAssociationStartIndSizeof(void *msg)
+{
+ size_t bufferSize = 2;
+
+ /* Calculate the Size of the Serialised Data. Could be more efficient (Try 44) */
+ bufferSize += 2; /* u16 primitive->interfaceTag */
+ bufferSize += 6; /* u8 primitive->address.a[6] */
+ bufferSize += 32; /* u8 primitive->ssid.ssid[32] */
+ bufferSize += 1; /* u8 primitive->ssid.length */
+ return bufferSize;
+}
+
+
+u8* CsrWifiSmeAssociationStartIndSer(u8 *ptr, size_t *len, void *msg)
+{
+ CsrWifiSmeAssociationStartInd *primitive = (CsrWifiSmeAssociationStartInd *)msg;
+ *len = 0;
+ CsrUint16Ser(ptr, len, primitive->common.type);
+ CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
+ CsrMemCpySer(ptr, len, (const void *) primitive->address.a, ((u16) (6)));
+ CsrMemCpySer(ptr, len, (const void *) primitive->ssid.ssid, ((u16) (32)));
+ CsrUint8Ser(ptr, len, (u8) primitive->ssid.length);
+ return(ptr);
+}
+
+
+void* CsrWifiSmeAssociationStartIndDes(u8 *buffer, size_t length)
+{
+ CsrWifiSmeAssociationStartInd *primitive = kmalloc(sizeof(CsrWifiSmeAssociationStartInd), GFP_KERNEL);
+ size_t offset;
+ offset = 0;
+
+ CsrUint16Des(&primitive->common.type, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
+ CsrMemCpyDes(primitive->address.a, buffer, &offset, ((u16) (6)));
+ CsrMemCpyDes(primitive->ssid.ssid, buffer, &offset, ((u16) (32)));
+ CsrUint8Des((u8 *) &primitive->ssid.length, buffer, &offset);
+
+ return primitive;
+}
+
+
+size_t CsrWifiSmeBlacklistCfmSizeof(void *msg)
+{
+ CsrWifiSmeBlacklistCfm *primitive = (CsrWifiSmeBlacklistCfm *) msg;
+ size_t bufferSize = 2;
+
+ /* Calculate the Size of the Serialised Data. Could be more efficient (Try 15) */
+ bufferSize += 2; /* u16 primitive->interfaceTag */
+ bufferSize += 2; /* CsrResult primitive->status */
+ bufferSize += 1; /* CsrWifiSmeListAction primitive->action */
+ bufferSize += 1; /* u8 primitive->getAddressCount */
+ {
+ u16 i1;
+ for (i1 = 0; i1 < primitive->getAddressCount; i1++)
+ {
+ bufferSize += 6; /* u8 primitive->getAddresses[i1].a[6] */
+ }
+ }
+ return bufferSize;
+}
+
+
+u8* CsrWifiSmeBlacklistCfmSer(u8 *ptr, size_t *len, void *msg)
+{
+ CsrWifiSmeBlacklistCfm *primitive = (CsrWifiSmeBlacklistCfm *)msg;
+ *len = 0;
+ CsrUint16Ser(ptr, len, primitive->common.type);
+ CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
+ CsrUint16Ser(ptr, len, (u16) primitive->status);
+ CsrUint8Ser(ptr, len, (u8) primitive->action);
+ CsrUint8Ser(ptr, len, (u8) primitive->getAddressCount);
+ {
+ u16 i1;
+ for (i1 = 0; i1 < primitive->getAddressCount; i1++)
+ {
+ CsrMemCpySer(ptr, len, (const void *) primitive->getAddresses[i1].a, ((u16) (6)));
+ }
+ }
+ return(ptr);
+}
+
+
+void* CsrWifiSmeBlacklistCfmDes(u8 *buffer, size_t length)
+{
+ CsrWifiSmeBlacklistCfm *primitive = kmalloc(sizeof(CsrWifiSmeBlacklistCfm), GFP_KERNEL);
+ size_t offset;
+ offset = 0;
+
+ CsrUint16Des(&primitive->common.type, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->action, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->getAddressCount, buffer, &offset);
+ primitive->getAddresses = NULL;
+ if (primitive->getAddressCount)
+ {
+ primitive->getAddresses = kmalloc(sizeof(CsrWifiMacAddress) * primitive->getAddressCount, GFP_KERNEL);
+ }
+ {
+ u16 i1;
+ for (i1 = 0; i1 < primitive->getAddressCount; i1++)
+ {
+ CsrMemCpyDes(primitive->getAddresses[i1].a, buffer, &offset, ((u16) (6)));
+ }
+ }
+
+ return primitive;
+}
+
+
+void CsrWifiSmeBlacklistCfmSerFree(void *voidPrimitivePointer)
+{
+ CsrWifiSmeBlacklistCfm *primitive = (CsrWifiSmeBlacklistCfm *) voidPrimitivePointer;
+ kfree(primitive->getAddresses);
+ kfree(primitive);
+}
+
+
+size_t CsrWifiSmeCalibrationDataGetCfmSizeof(void *msg)
+{
+ CsrWifiSmeCalibrationDataGetCfm *primitive = (CsrWifiSmeCalibrationDataGetCfm *) msg;
+ size_t bufferSize = 2;
+
+ /* Calculate the Size of the Serialised Data. Could be more efficient (Try 8) */
+ bufferSize += 2; /* CsrResult primitive->status */
+ bufferSize += 2; /* u16 primitive->calibrationDataLength */
+ bufferSize += primitive->calibrationDataLength; /* u8 primitive->calibrationData */
+ return bufferSize;
+}
+
+
+u8* CsrWifiSmeCalibrationDataGetCfmSer(u8 *ptr, size_t *len, void *msg)
+{
+ CsrWifiSmeCalibrationDataGetCfm *primitive = (CsrWifiSmeCalibrationDataGetCfm *)msg;
+ *len = 0;
+ CsrUint16Ser(ptr, len, primitive->common.type);
+ CsrUint16Ser(ptr, len, (u16) primitive->status);
+ CsrUint16Ser(ptr, len, (u16) primitive->calibrationDataLength);
+ if (primitive->calibrationDataLength)
+ {
+ CsrMemCpySer(ptr, len, (const void *) primitive->calibrationData, ((u16) (primitive->calibrationDataLength)));
+ }
+ return(ptr);
+}
+
+
+void* CsrWifiSmeCalibrationDataGetCfmDes(u8 *buffer, size_t length)
+{
+ CsrWifiSmeCalibrationDataGetCfm *primitive = kmalloc(sizeof(CsrWifiSmeCalibrationDataGetCfm), GFP_KERNEL);
+ size_t offset;
+ offset = 0;
+
+ CsrUint16Des(&primitive->common.type, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->calibrationDataLength, buffer, &offset);
+ if (primitive->calibrationDataLength)
+ {
+ primitive->calibrationData = kmalloc(primitive->calibrationDataLength, GFP_KERNEL);
+ CsrMemCpyDes(primitive->calibrationData, buffer, &offset, ((u16) (primitive->calibrationDataLength)));
+ }
+ else
+ {
+ primitive->calibrationData = NULL;
+ }
+
+ return primitive;
+}
+
+
+void CsrWifiSmeCalibrationDataGetCfmSerFree(void *voidPrimitivePointer)
+{
+ CsrWifiSmeCalibrationDataGetCfm *primitive = (CsrWifiSmeCalibrationDataGetCfm *) voidPrimitivePointer;
+ kfree(primitive->calibrationData);
+ kfree(primitive);
+}
+
+
+size_t CsrWifiSmeCcxConfigGetCfmSizeof(void *msg)
+{
+ size_t bufferSize = 2;
+
+ /* Calculate the Size of the Serialised Data. Could be more efficient (Try 11) */
+ bufferSize += 2; /* u16 primitive->interfaceTag */
+ bufferSize += 2; /* CsrResult primitive->status */
+ bufferSize += 1; /* u8 primitive->ccxConfig.keepAliveTimeMs */
+ bufferSize += 1; /* u8 primitive->ccxConfig.apRoamingEnabled */
+ bufferSize += 1; /* u8 primitive->ccxConfig.measurementsMask */
+ bufferSize += 1; /* u8 primitive->ccxConfig.ccxRadioMgtEnabled */
+ return bufferSize;
+}
+
+
+u8* CsrWifiSmeCcxConfigGetCfmSer(u8 *ptr, size_t *len, void *msg)
+{
+ CsrWifiSmeCcxConfigGetCfm *primitive = (CsrWifiSmeCcxConfigGetCfm *)msg;
+ *len = 0;
+ CsrUint16Ser(ptr, len, primitive->common.type);
+ CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
+ CsrUint16Ser(ptr, len, (u16) primitive->status);
+ CsrUint8Ser(ptr, len, (u8) primitive->ccxConfig.keepAliveTimeMs);
+ CsrUint8Ser(ptr, len, (u8) primitive->ccxConfig.apRoamingEnabled);
+ CsrUint8Ser(ptr, len, (u8) primitive->ccxConfig.measurementsMask);
+ CsrUint8Ser(ptr, len, (u8) primitive->ccxConfig.ccxRadioMgtEnabled);
+ return(ptr);
+}
+
+
+void* CsrWifiSmeCcxConfigGetCfmDes(u8 *buffer, size_t length)
+{
+ CsrWifiSmeCcxConfigGetCfm *primitive = kmalloc(sizeof(CsrWifiSmeCcxConfigGetCfm), GFP_KERNEL);
+ size_t offset;
+ offset = 0;
+
+ CsrUint16Des(&primitive->common.type, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->ccxConfig.keepAliveTimeMs, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->ccxConfig.apRoamingEnabled, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->ccxConfig.measurementsMask, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->ccxConfig.ccxRadioMgtEnabled, buffer, &offset);
+
+ return primitive;
+}
+
+
+size_t CsrWifiSmeCcxConfigSetCfmSizeof(void *msg)
+{
+ size_t bufferSize = 2;
+
+ /* Calculate the Size of the Serialised Data. Could be more efficient (Try 7) */
+ bufferSize += 2; /* u16 primitive->interfaceTag */
+ bufferSize += 2; /* CsrResult primitive->status */
+ return bufferSize;
+}
+
+
+u8* CsrWifiSmeCcxConfigSetCfmSer(u8 *ptr, size_t *len, void *msg)
+{
+ CsrWifiSmeCcxConfigSetCfm *primitive = (CsrWifiSmeCcxConfigSetCfm *)msg;
+ *len = 0;
+ CsrUint16Ser(ptr, len, primitive->common.type);
+ CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
+ CsrUint16Ser(ptr, len, (u16) primitive->status);
+ return(ptr);
+}
+
+
+void* CsrWifiSmeCcxConfigSetCfmDes(u8 *buffer, size_t length)
+{
+ CsrWifiSmeCcxConfigSetCfm *primitive = kmalloc(sizeof(CsrWifiSmeCcxConfigSetCfm), GFP_KERNEL);
+ size_t offset;
+ offset = 0;
+
+ CsrUint16Des(&primitive->common.type, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
+
+ return primitive;
+}
+
+
+size_t CsrWifiSmeCoexConfigGetCfmSizeof(void *msg)
+{
+ size_t bufferSize = 2;
+
+ /* Calculate the Size of the Serialised Data. Could be more efficient (Try 31) */
+ bufferSize += 2; /* CsrResult primitive->status */
+ bufferSize += 1; /* u8 primitive->coexConfig.coexEnableSchemeManagement */
+ bufferSize += 1; /* u8 primitive->coexConfig.coexPeriodicWakeHost */
+ bufferSize += 2; /* u16 primitive->coexConfig.coexTrafficBurstyLatencyMs */
+ bufferSize += 2; /* u16 primitive->coexConfig.coexTrafficContinuousLatencyMs */
+ bufferSize += 2; /* u16 primitive->coexConfig.coexObexBlackoutDurationMs */
+ bufferSize += 2; /* u16 primitive->coexConfig.coexObexBlackoutPeriodMs */
+ bufferSize += 2; /* u16 primitive->coexConfig.coexA2dpBrBlackoutDurationMs */
+ bufferSize += 2; /* u16 primitive->coexConfig.coexA2dpBrBlackoutPeriodMs */
+ bufferSize += 2; /* u16 primitive->coexConfig.coexA2dpEdrBlackoutDurationMs */
+ bufferSize += 2; /* u16 primitive->coexConfig.coexA2dpEdrBlackoutPeriodMs */
+ bufferSize += 2; /* u16 primitive->coexConfig.coexPagingBlackoutDurationMs */
+ bufferSize += 2; /* u16 primitive->coexConfig.coexPagingBlackoutPeriodMs */
+ bufferSize += 2; /* u16 primitive->coexConfig.coexInquiryBlackoutDurationMs */
+ bufferSize += 2; /* u16 primitive->coexConfig.coexInquiryBlackoutPeriodMs */
+ return bufferSize;
+}
+
+
+u8* CsrWifiSmeCoexConfigGetCfmSer(u8 *ptr, size_t *len, void *msg)
+{
+ CsrWifiSmeCoexConfigGetCfm *primitive = (CsrWifiSmeCoexConfigGetCfm *)msg;
+ *len = 0;
+ CsrUint16Ser(ptr, len, primitive->common.type);
+ CsrUint16Ser(ptr, len, (u16) primitive->status);
+ CsrUint8Ser(ptr, len, (u8) primitive->coexConfig.coexEnableSchemeManagement);
+ CsrUint8Ser(ptr, len, (u8) primitive->coexConfig.coexPeriodicWakeHost);
+ CsrUint16Ser(ptr, len, (u16) primitive->coexConfig.coexTrafficBurstyLatencyMs);
+ CsrUint16Ser(ptr, len, (u16) primitive->coexConfig.coexTrafficContinuousLatencyMs);
+ CsrUint16Ser(ptr, len, (u16) primitive->coexConfig.coexObexBlackoutDurationMs);
+ CsrUint16Ser(ptr, len, (u16) primitive->coexConfig.coexObexBlackoutPeriodMs);
+ CsrUint16Ser(ptr, len, (u16) primitive->coexConfig.coexA2dpBrBlackoutDurationMs);
+ CsrUint16Ser(ptr, len, (u16) primitive->coexConfig.coexA2dpBrBlackoutPeriodMs);
+ CsrUint16Ser(ptr, len, (u16) primitive->coexConfig.coexA2dpEdrBlackoutDurationMs);
+ CsrUint16Ser(ptr, len, (u16) primitive->coexConfig.coexA2dpEdrBlackoutPeriodMs);
+ CsrUint16Ser(ptr, len, (u16) primitive->coexConfig.coexPagingBlackoutDurationMs);
+ CsrUint16Ser(ptr, len, (u16) primitive->coexConfig.coexPagingBlackoutPeriodMs);
+ CsrUint16Ser(ptr, len, (u16) primitive->coexConfig.coexInquiryBlackoutDurationMs);
+ CsrUint16Ser(ptr, len, (u16) primitive->coexConfig.coexInquiryBlackoutPeriodMs);
+ return(ptr);
+}
+
+
+void* CsrWifiSmeCoexConfigGetCfmDes(u8 *buffer, size_t length)
+{
+ CsrWifiSmeCoexConfigGetCfm *primitive = kmalloc(sizeof(CsrWifiSmeCoexConfigGetCfm), GFP_KERNEL);
+ size_t offset;
+ offset = 0;
+
+ CsrUint16Des(&primitive->common.type, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->coexConfig.coexEnableSchemeManagement, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->coexConfig.coexPeriodicWakeHost, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->coexConfig.coexTrafficBurstyLatencyMs, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->coexConfig.coexTrafficContinuousLatencyMs, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->coexConfig.coexObexBlackoutDurationMs, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->coexConfig.coexObexBlackoutPeriodMs, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->coexConfig.coexA2dpBrBlackoutDurationMs, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->coexConfig.coexA2dpBrBlackoutPeriodMs, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->coexConfig.coexA2dpEdrBlackoutDurationMs, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->coexConfig.coexA2dpEdrBlackoutPeriodMs, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->coexConfig.coexPagingBlackoutDurationMs, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->coexConfig.coexPagingBlackoutPeriodMs, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->coexConfig.coexInquiryBlackoutDurationMs, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->coexConfig.coexInquiryBlackoutPeriodMs, buffer, &offset);
+
+ return primitive;
+}
+
+
+size_t CsrWifiSmeCoexInfoGetCfmSizeof(void *msg)
+{
+ size_t bufferSize = 2;
+
+ /* Calculate the Size of the Serialised Data. Could be more efficient (Try 24) */
+ bufferSize += 2; /* CsrResult primitive->status */
+ bufferSize += 1; /* u8 primitive->coexInfo.hasTrafficData */
+ bufferSize += 1; /* CsrWifiSmeTrafficType primitive->coexInfo.currentTrafficType */
+ bufferSize += 2; /* u16 primitive->coexInfo.currentPeriodMs */
+ bufferSize += 1; /* CsrWifiSmePowerSaveLevel primitive->coexInfo.currentPowerSave */
+ bufferSize += 2; /* u16 primitive->coexInfo.currentCoexPeriodMs */
+ bufferSize += 2; /* u16 primitive->coexInfo.currentCoexLatencyMs */
+ bufferSize += 1; /* u8 primitive->coexInfo.hasBtDevice */
+ bufferSize += 4; /* u32 primitive->coexInfo.currentBlackoutDurationUs */
+ bufferSize += 4; /* u32 primitive->coexInfo.currentBlackoutPeriodUs */
+ bufferSize += 1; /* CsrWifiSmeCoexScheme primitive->coexInfo.currentCoexScheme */
+ return bufferSize;
+}
+
+
+u8* CsrWifiSmeCoexInfoGetCfmSer(u8 *ptr, size_t *len, void *msg)
+{
+ CsrWifiSmeCoexInfoGetCfm *primitive = (CsrWifiSmeCoexInfoGetCfm *)msg;
+ *len = 0;
+ CsrUint16Ser(ptr, len, primitive->common.type);
+ CsrUint16Ser(ptr, len, (u16) primitive->status);
+ CsrUint8Ser(ptr, len, (u8) primitive->coexInfo.hasTrafficData);
+ CsrUint8Ser(ptr, len, (u8) primitive->coexInfo.currentTrafficType);
+ CsrUint16Ser(ptr, len, (u16) primitive->coexInfo.currentPeriodMs);
+ CsrUint8Ser(ptr, len, (u8) primitive->coexInfo.currentPowerSave);
+ CsrUint16Ser(ptr, len, (u16) primitive->coexInfo.currentCoexPeriodMs);
+ CsrUint16Ser(ptr, len, (u16) primitive->coexInfo.currentCoexLatencyMs);
+ CsrUint8Ser(ptr, len, (u8) primitive->coexInfo.hasBtDevice);
+ CsrUint32Ser(ptr, len, (u32) primitive->coexInfo.currentBlackoutDurationUs);
+ CsrUint32Ser(ptr, len, (u32) primitive->coexInfo.currentBlackoutPeriodUs);
+ CsrUint8Ser(ptr, len, (u8) primitive->coexInfo.currentCoexScheme);
+ return(ptr);
+}
+
+
+void* CsrWifiSmeCoexInfoGetCfmDes(u8 *buffer, size_t length)
+{
+ CsrWifiSmeCoexInfoGetCfm *primitive = kmalloc(sizeof(CsrWifiSmeCoexInfoGetCfm), GFP_KERNEL);
+ size_t offset;
+ offset = 0;
+
+ CsrUint16Des(&primitive->common.type, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->coexInfo.hasTrafficData, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->coexInfo.currentTrafficType, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->coexInfo.currentPeriodMs, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->coexInfo.currentPowerSave, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->coexInfo.currentCoexPeriodMs, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->coexInfo.currentCoexLatencyMs, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->coexInfo.hasBtDevice, buffer, &offset);
+ CsrUint32Des((u32 *) &primitive->coexInfo.currentBlackoutDurationUs, buffer, &offset);
+ CsrUint32Des((u32 *) &primitive->coexInfo.currentBlackoutPeriodUs, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->coexInfo.currentCoexScheme, buffer, &offset);
+
+ return primitive;
+}
+
+
+size_t CsrWifiSmeConnectCfmSizeof(void *msg)
+{
+ size_t bufferSize = 2;
+
+ /* Calculate the Size of the Serialised Data. Could be more efficient (Try 7) */
+ bufferSize += 2; /* u16 primitive->interfaceTag */
+ bufferSize += 2; /* CsrResult primitive->status */
+ return bufferSize;
+}
+
+
+u8* CsrWifiSmeConnectCfmSer(u8 *ptr, size_t *len, void *msg)
+{
+ CsrWifiSmeConnectCfm *primitive = (CsrWifiSmeConnectCfm *)msg;
+ *len = 0;
+ CsrUint16Ser(ptr, len, primitive->common.type);
+ CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
+ CsrUint16Ser(ptr, len, (u16) primitive->status);
+ return(ptr);
+}
+
+
+void* CsrWifiSmeConnectCfmDes(u8 *buffer, size_t length)
+{
+ CsrWifiSmeConnectCfm *primitive = kmalloc(sizeof(CsrWifiSmeConnectCfm), GFP_KERNEL);
+ size_t offset;
+ offset = 0;
+
+ CsrUint16Des(&primitive->common.type, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
+
+ return primitive;
+}
+
+
+size_t CsrWifiSmeConnectionConfigGetCfmSizeof(void *msg)
+{
+ CsrWifiSmeConnectionConfigGetCfm *primitive = (CsrWifiSmeConnectionConfigGetCfm *) msg;
+ size_t bufferSize = 2;
+
+ /* Calculate the Size of the Serialised Data. Could be more efficient (Try 59) */
+ bufferSize += 2; /* u16 primitive->interfaceTag */
+ bufferSize += 2; /* CsrResult primitive->status */
+ bufferSize += 32; /* u8 primitive->connectionConfig.ssid.ssid[32] */
+ bufferSize += 1; /* u8 primitive->connectionConfig.ssid.length */
+ bufferSize += 6; /* u8 primitive->connectionConfig.bssid.a[6] */
+ bufferSize += 1; /* CsrWifiSmeBssType primitive->connectionConfig.bssType */
+ bufferSize += 1; /* CsrWifiSmeRadioIF primitive->connectionConfig.ifIndex */
+ bufferSize += 1; /* CsrWifiSme80211PrivacyMode primitive->connectionConfig.privacyMode */
+ bufferSize += 2; /* CsrWifiSmeAuthModeMask primitive->connectionConfig.authModeMask */
+ bufferSize += 2; /* CsrWifiSmeEncryptionMask primitive->connectionConfig.encryptionModeMask */
+ bufferSize += 2; /* u16 primitive->connectionConfig.mlmeAssociateReqInformationElementsLength */
+ bufferSize += primitive->connectionConfig.mlmeAssociateReqInformationElementsLength; /* u8 primitive->connectionConfig.mlmeAssociateReqInformationElements */
+ bufferSize += 1; /* CsrWifiSmeWmmQosInfoMask primitive->connectionConfig.wmmQosInfo */
+ bufferSize += 1; /* u8 primitive->connectionConfig.adhocJoinOnly */
+ bufferSize += 1; /* u8 primitive->connectionConfig.adhocChannel */
+ return bufferSize;
+}
+
+
+u8* CsrWifiSmeConnectionConfigGetCfmSer(u8 *ptr, size_t *len, void *msg)
+{
+ CsrWifiSmeConnectionConfigGetCfm *primitive = (CsrWifiSmeConnectionConfigGetCfm *)msg;
+ *len = 0;
+ CsrUint16Ser(ptr, len, primitive->common.type);
+ CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
+ CsrUint16Ser(ptr, len, (u16) primitive->status);
+ CsrMemCpySer(ptr, len, (const void *) primitive->connectionConfig.ssid.ssid, ((u16) (32)));
+ CsrUint8Ser(ptr, len, (u8) primitive->connectionConfig.ssid.length);
+ CsrMemCpySer(ptr, len, (const void *) primitive->connectionConfig.bssid.a, ((u16) (6)));
+ CsrUint8Ser(ptr, len, (u8) primitive->connectionConfig.bssType);
+ CsrUint8Ser(ptr, len, (u8) primitive->connectionConfig.ifIndex);
+ CsrUint8Ser(ptr, len, (u8) primitive->connectionConfig.privacyMode);
+ CsrUint16Ser(ptr, len, (u16) primitive->connectionConfig.authModeMask);
+ CsrUint16Ser(ptr, len, (u16) primitive->connectionConfig.encryptionModeMask);
+ CsrUint16Ser(ptr, len, (u16) primitive->connectionConfig.mlmeAssociateReqInformationElementsLength);
+ if (primitive->connectionConfig.mlmeAssociateReqInformationElementsLength)
+ {
+ CsrMemCpySer(ptr, len, (const void *) primitive->connectionConfig.mlmeAssociateReqInformationElements, ((u16) (primitive->connectionConfig.mlmeAssociateReqInformationElementsLength)));
+ }
+ CsrUint8Ser(ptr, len, (u8) primitive->connectionConfig.wmmQosInfo);
+ CsrUint8Ser(ptr, len, (u8) primitive->connectionConfig.adhocJoinOnly);
+ CsrUint8Ser(ptr, len, (u8) primitive->connectionConfig.adhocChannel);
+ return(ptr);
+}
+
+
+void* CsrWifiSmeConnectionConfigGetCfmDes(u8 *buffer, size_t length)
+{
+ CsrWifiSmeConnectionConfigGetCfm *primitive = kmalloc(sizeof(CsrWifiSmeConnectionConfigGetCfm), GFP_KERNEL);
+ size_t offset;
+ offset = 0;
+
+ CsrUint16Des(&primitive->common.type, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
+ CsrMemCpyDes(primitive->connectionConfig.ssid.ssid, buffer, &offset, ((u16) (32)));
+ CsrUint8Des((u8 *) &primitive->connectionConfig.ssid.length, buffer, &offset);
+ CsrMemCpyDes(primitive->connectionConfig.bssid.a, buffer, &offset, ((u16) (6)));
+ CsrUint8Des((u8 *) &primitive->connectionConfig.bssType, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->connectionConfig.ifIndex, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->connectionConfig.privacyMode, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->connectionConfig.authModeMask, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->connectionConfig.encryptionModeMask, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->connectionConfig.mlmeAssociateReqInformationElementsLength, buffer, &offset);
+ if (primitive->connectionConfig.mlmeAssociateReqInformationElementsLength)
+ {
+ primitive->connectionConfig.mlmeAssociateReqInformationElements = kmalloc(primitive->connectionConfig.mlmeAssociateReqInformationElementsLength, GFP_KERNEL);
+ CsrMemCpyDes(primitive->connectionConfig.mlmeAssociateReqInformationElements, buffer, &offset, ((u16) (primitive->connectionConfig.mlmeAssociateReqInformationElementsLength)));
+ }
+ else
+ {
+ primitive->connectionConfig.mlmeAssociateReqInformationElements = NULL;
+ }
+ CsrUint8Des((u8 *) &primitive->connectionConfig.wmmQosInfo, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->connectionConfig.adhocJoinOnly, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->connectionConfig.adhocChannel, buffer, &offset);
+
+ return primitive;
+}
+
+
+void CsrWifiSmeConnectionConfigGetCfmSerFree(void *voidPrimitivePointer)
+{
+ CsrWifiSmeConnectionConfigGetCfm *primitive = (CsrWifiSmeConnectionConfigGetCfm *) voidPrimitivePointer;
+ kfree(primitive->connectionConfig.mlmeAssociateReqInformationElements);
+ kfree(primitive);
+}
+
+
+size_t CsrWifiSmeConnectionInfoGetCfmSizeof(void *msg)
+{
+ CsrWifiSmeConnectionInfoGetCfm *primitive = (CsrWifiSmeConnectionInfoGetCfm *) msg;
+ size_t bufferSize = 2;
+
+ /* Calculate the Size of the Serialised Data. Could be more efficient (Try 96) */
+ bufferSize += 2; /* u16 primitive->interfaceTag */
+ bufferSize += 2; /* CsrResult primitive->status */
+ bufferSize += 32; /* u8 primitive->connectionInfo.ssid.ssid[32] */
+ bufferSize += 1; /* u8 primitive->connectionInfo.ssid.length */
+ bufferSize += 6; /* u8 primitive->connectionInfo.bssid.a[6] */
+ bufferSize += 1; /* CsrWifiSme80211NetworkType primitive->connectionInfo.networkType80211 */
+ bufferSize += 1; /* u8 primitive->connectionInfo.channelNumber */
+ bufferSize += 2; /* u16 primitive->connectionInfo.channelFrequency */
+ bufferSize += 2; /* CsrWifiSmeAuthMode primitive->connectionInfo.authMode */
+ bufferSize += 2; /* CsrWifiSmeEncryption primitive->connectionInfo.pairwiseCipher */
+ bufferSize += 2; /* CsrWifiSmeEncryption primitive->connectionInfo.groupCipher */
+ bufferSize += 1; /* CsrWifiSmeRadioIF primitive->connectionInfo.ifIndex */
+ bufferSize += 2; /* u16 primitive->connectionInfo.atimWindowTu */
+ bufferSize += 2; /* u16 primitive->connectionInfo.beaconPeriodTu */
+ bufferSize += 1; /* u8 primitive->connectionInfo.reassociation */
+ bufferSize += 2; /* u16 primitive->connectionInfo.beaconFrameLength */
+ bufferSize += primitive->connectionInfo.beaconFrameLength; /* u8 primitive->connectionInfo.beaconFrame */
+ bufferSize += 2; /* u16 primitive->connectionInfo.associationReqFrameLength */
+ bufferSize += primitive->connectionInfo.associationReqFrameLength; /* u8 primitive->connectionInfo.associationReqFrame */
+ bufferSize += 2; /* u16 primitive->connectionInfo.associationRspFrameLength */
+ bufferSize += primitive->connectionInfo.associationRspFrameLength; /* u8 primitive->connectionInfo.associationRspFrame */
+ bufferSize += 2; /* u16 primitive->connectionInfo.assocScanInfoElementsLength */
+ bufferSize += primitive->connectionInfo.assocScanInfoElementsLength; /* u8 primitive->connectionInfo.assocScanInfoElements */
+ bufferSize += 2; /* u16 primitive->connectionInfo.assocReqCapabilities */
+ bufferSize += 2; /* u16 primitive->connectionInfo.assocReqListenIntervalTu */
+ bufferSize += 6; /* u8 primitive->connectionInfo.assocReqApAddress.a[6] */
+ bufferSize += 2; /* u16 primitive->connectionInfo.assocReqInfoElementsLength */
+ bufferSize += primitive->connectionInfo.assocReqInfoElementsLength; /* u8 primitive->connectionInfo.assocReqInfoElements */
+ bufferSize += 2; /* CsrWifiSmeIEEE80211Result primitive->connectionInfo.assocRspResult */
+ bufferSize += 2; /* u16 primitive->connectionInfo.assocRspCapabilityInfo */
+ bufferSize += 2; /* u16 primitive->connectionInfo.assocRspAssociationId */
+ bufferSize += 2; /* u16 primitive->connectionInfo.assocRspInfoElementsLength */
+ bufferSize += primitive->connectionInfo.assocRspInfoElementsLength; /* u8 primitive->connectionInfo.assocRspInfoElements */
+ return bufferSize;
+}
+
+
+u8* CsrWifiSmeConnectionInfoGetCfmSer(u8 *ptr, size_t *len, void *msg)
+{
+ CsrWifiSmeConnectionInfoGetCfm *primitive = (CsrWifiSmeConnectionInfoGetCfm *)msg;
+ *len = 0;
+ CsrUint16Ser(ptr, len, primitive->common.type);
+ CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
+ CsrUint16Ser(ptr, len, (u16) primitive->status);
+ CsrMemCpySer(ptr, len, (const void *) primitive->connectionInfo.ssid.ssid, ((u16) (32)));
+ CsrUint8Ser(ptr, len, (u8) primitive->connectionInfo.ssid.length);
+ CsrMemCpySer(ptr, len, (const void *) primitive->connectionInfo.bssid.a, ((u16) (6)));
+ CsrUint8Ser(ptr, len, (u8) primitive->connectionInfo.networkType80211);
+ CsrUint8Ser(ptr, len, (u8) primitive->connectionInfo.channelNumber);
+ CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.channelFrequency);
+ CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.authMode);
+ CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.pairwiseCipher);
+ CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.groupCipher);
+ CsrUint8Ser(ptr, len, (u8) primitive->connectionInfo.ifIndex);
+ CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.atimWindowTu);
+ CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.beaconPeriodTu);
+ CsrUint8Ser(ptr, len, (u8) primitive->connectionInfo.reassociation);
+ CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.beaconFrameLength);
+ if (primitive->connectionInfo.beaconFrameLength)
+ {
+ CsrMemCpySer(ptr, len, (const void *) primitive->connectionInfo.beaconFrame, ((u16) (primitive->connectionInfo.beaconFrameLength)));
+ }
+ CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.associationReqFrameLength);
+ if (primitive->connectionInfo.associationReqFrameLength)
+ {
+ CsrMemCpySer(ptr, len, (const void *) primitive->connectionInfo.associationReqFrame, ((u16) (primitive->connectionInfo.associationReqFrameLength)));
+ }
+ CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.associationRspFrameLength);
+ if (primitive->connectionInfo.associationRspFrameLength)
+ {
+ CsrMemCpySer(ptr, len, (const void *) primitive->connectionInfo.associationRspFrame, ((u16) (primitive->connectionInfo.associationRspFrameLength)));
+ }
+ CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.assocScanInfoElementsLength);
+ if (primitive->connectionInfo.assocScanInfoElementsLength)
+ {
+ CsrMemCpySer(ptr, len, (const void *) primitive->connectionInfo.assocScanInfoElements, ((u16) (primitive->connectionInfo.assocScanInfoElementsLength)));
+ }
+ CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.assocReqCapabilities);
+ CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.assocReqListenIntervalTu);
+ CsrMemCpySer(ptr, len, (const void *) primitive->connectionInfo.assocReqApAddress.a, ((u16) (6)));
+ CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.assocReqInfoElementsLength);
+ if (primitive->connectionInfo.assocReqInfoElementsLength)
+ {
+ CsrMemCpySer(ptr, len, (const void *) primitive->connectionInfo.assocReqInfoElements, ((u16) (primitive->connectionInfo.assocReqInfoElementsLength)));
+ }
+ CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.assocRspResult);
+ CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.assocRspCapabilityInfo);
+ CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.assocRspAssociationId);
+ CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.assocRspInfoElementsLength);
+ if (primitive->connectionInfo.assocRspInfoElementsLength)
+ {
+ CsrMemCpySer(ptr, len, (const void *) primitive->connectionInfo.assocRspInfoElements, ((u16) (primitive->connectionInfo.assocRspInfoElementsLength)));
+ }
+ return(ptr);
+}
+
+
+void* CsrWifiSmeConnectionInfoGetCfmDes(u8 *buffer, size_t length)
+{
+ CsrWifiSmeConnectionInfoGetCfm *primitive = kmalloc(sizeof(CsrWifiSmeConnectionInfoGetCfm), GFP_KERNEL);
+ size_t offset;
+ offset = 0;
+
+ CsrUint16Des(&primitive->common.type, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
+ CsrMemCpyDes(primitive->connectionInfo.ssid.ssid, buffer, &offset, ((u16) (32)));
+ CsrUint8Des((u8 *) &primitive->connectionInfo.ssid.length, buffer, &offset);
+ CsrMemCpyDes(primitive->connectionInfo.bssid.a, buffer, &offset, ((u16) (6)));
+ CsrUint8Des((u8 *) &primitive->connectionInfo.networkType80211, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->connectionInfo.channelNumber, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->connectionInfo.channelFrequency, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->connectionInfo.authMode, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->connectionInfo.pairwiseCipher, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->connectionInfo.groupCipher, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->connectionInfo.ifIndex, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->connectionInfo.atimWindowTu, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->connectionInfo.beaconPeriodTu, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->connectionInfo.reassociation, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->connectionInfo.beaconFrameLength, buffer, &offset);
+ if (primitive->connectionInfo.beaconFrameLength)
+ {
+ primitive->connectionInfo.beaconFrame = kmalloc(primitive->connectionInfo.beaconFrameLength, GFP_KERNEL);
+ CsrMemCpyDes(primitive->connectionInfo.beaconFrame, buffer, &offset, ((u16) (primitive->connectionInfo.beaconFrameLength)));
+ }
+ else
+ {
+ primitive->connectionInfo.beaconFrame = NULL;
+ }
+ CsrUint16Des((u16 *) &primitive->connectionInfo.associationReqFrameLength, buffer, &offset);
+ if (primitive->connectionInfo.associationReqFrameLength)
+ {
+ primitive->connectionInfo.associationReqFrame = kmalloc(primitive->connectionInfo.associationReqFrameLength, GFP_KERNEL);
+ CsrMemCpyDes(primitive->connectionInfo.associationReqFrame, buffer, &offset, ((u16) (primitive->connectionInfo.associationReqFrameLength)));
+ }
+ else
+ {
+ primitive->connectionInfo.associationReqFrame = NULL;
+ }
+ CsrUint16Des((u16 *) &primitive->connectionInfo.associationRspFrameLength, buffer, &offset);
+ if (primitive->connectionInfo.associationRspFrameLength)
+ {
+ primitive->connectionInfo.associationRspFrame = kmalloc(primitive->connectionInfo.associationRspFrameLength, GFP_KERNEL);
+ CsrMemCpyDes(primitive->connectionInfo.associationRspFrame, buffer, &offset, ((u16) (primitive->connectionInfo.associationRspFrameLength)));
+ }
+ else
+ {
+ primitive->connectionInfo.associationRspFrame = NULL;
+ }
+ CsrUint16Des((u16 *) &primitive->connectionInfo.assocScanInfoElementsLength, buffer, &offset);
+ if (primitive->connectionInfo.assocScanInfoElementsLength)
+ {
+ primitive->connectionInfo.assocScanInfoElements = kmalloc(primitive->connectionInfo.assocScanInfoElementsLength, GFP_KERNEL);
+ CsrMemCpyDes(primitive->connectionInfo.assocScanInfoElements, buffer, &offset, ((u16) (primitive->connectionInfo.assocScanInfoElementsLength)));
+ }
+ else
+ {
+ primitive->connectionInfo.assocScanInfoElements = NULL;
+ }
+ CsrUint16Des((u16 *) &primitive->connectionInfo.assocReqCapabilities, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->connectionInfo.assocReqListenIntervalTu, buffer, &offset);
+ CsrMemCpyDes(primitive->connectionInfo.assocReqApAddress.a, buffer, &offset, ((u16) (6)));
+ CsrUint16Des((u16 *) &primitive->connectionInfo.assocReqInfoElementsLength, buffer, &offset);
+ if (primitive->connectionInfo.assocReqInfoElementsLength)
+ {
+ primitive->connectionInfo.assocReqInfoElements = kmalloc(primitive->connectionInfo.assocReqInfoElementsLength, GFP_KERNEL);
+ CsrMemCpyDes(primitive->connectionInfo.assocReqInfoElements, buffer, &offset, ((u16) (primitive->connectionInfo.assocReqInfoElementsLength)));
+ }
+ else
+ {
+ primitive->connectionInfo.assocReqInfoElements = NULL;
+ }
+ CsrUint16Des((u16 *) &primitive->connectionInfo.assocRspResult, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->connectionInfo.assocRspCapabilityInfo, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->connectionInfo.assocRspAssociationId, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->connectionInfo.assocRspInfoElementsLength, buffer, &offset);
+ if (primitive->connectionInfo.assocRspInfoElementsLength)
+ {
+ primitive->connectionInfo.assocRspInfoElements = kmalloc(primitive->connectionInfo.assocRspInfoElementsLength, GFP_KERNEL);
+ CsrMemCpyDes(primitive->connectionInfo.assocRspInfoElements, buffer, &offset, ((u16) (primitive->connectionInfo.assocRspInfoElementsLength)));
+ }
+ else
+ {
+ primitive->connectionInfo.assocRspInfoElements = NULL;
+ }
+
+ return primitive;
+}
+
+
+void CsrWifiSmeConnectionInfoGetCfmSerFree(void *voidPrimitivePointer)
+{
+ CsrWifiSmeConnectionInfoGetCfm *primitive = (CsrWifiSmeConnectionInfoGetCfm *) voidPrimitivePointer;
+ kfree(primitive->connectionInfo.beaconFrame);
+ kfree(primitive->connectionInfo.associationReqFrame);
+ kfree(primitive->connectionInfo.associationRspFrame);
+ kfree(primitive->connectionInfo.assocScanInfoElements);
+ kfree(primitive->connectionInfo.assocReqInfoElements);
+ kfree(primitive->connectionInfo.assocRspInfoElements);
+ kfree(primitive);
+}
+
+
+size_t CsrWifiSmeConnectionQualityIndSizeof(void *msg)
+{
+ size_t bufferSize = 2;
+
+ /* Calculate the Size of the Serialised Data. Could be more efficient (Try 9) */
+ bufferSize += 2; /* u16 primitive->interfaceTag */
+ bufferSize += 2; /* s16 primitive->linkQuality.unifiRssi */
+ bufferSize += 2; /* s16 primitive->linkQuality.unifiSnr */
+ return bufferSize;
+}
+
+
+u8* CsrWifiSmeConnectionQualityIndSer(u8 *ptr, size_t *len, void *msg)
+{
+ CsrWifiSmeConnectionQualityInd *primitive = (CsrWifiSmeConnectionQualityInd *)msg;
+ *len = 0;
+ CsrUint16Ser(ptr, len, primitive->common.type);
+ CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
+ CsrUint16Ser(ptr, len, (u16) primitive->linkQuality.unifiRssi);
+ CsrUint16Ser(ptr, len, (u16) primitive->linkQuality.unifiSnr);
+ return(ptr);
+}
+
+
+void* CsrWifiSmeConnectionQualityIndDes(u8 *buffer, size_t length)
+{
+ CsrWifiSmeConnectionQualityInd *primitive = kmalloc(sizeof(CsrWifiSmeConnectionQualityInd), GFP_KERNEL);
+ size_t offset;
+ offset = 0;
+
+ CsrUint16Des(&primitive->common.type, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->linkQuality.unifiRssi, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->linkQuality.unifiSnr, buffer, &offset);
+
+ return primitive;
+}
+
+
+size_t CsrWifiSmeConnectionStatsGetCfmSizeof(void *msg)
+{
+ size_t bufferSize = 2;
+
+ /* Calculate the Size of the Serialised Data. Could be more efficient (Try 101) */
+ bufferSize += 2; /* u16 primitive->interfaceTag */
+ bufferSize += 2; /* CsrResult primitive->status */
+ bufferSize += 1; /* u8 primitive->connectionStats.unifiTxDataRate */
+ bufferSize += 1; /* u8 primitive->connectionStats.unifiRxDataRate */
+ bufferSize += 4; /* u32 primitive->connectionStats.dot11RetryCount */
+ bufferSize += 4; /* u32 primitive->connectionStats.dot11MultipleRetryCount */
+ bufferSize += 4; /* u32 primitive->connectionStats.dot11AckFailureCount */
+ bufferSize += 4; /* u32 primitive->connectionStats.dot11FrameDuplicateCount */
+ bufferSize += 4; /* u32 primitive->connectionStats.dot11FcsErrorCount */
+ bufferSize += 4; /* u32 primitive->connectionStats.dot11RtsSuccessCount */
+ bufferSize += 4; /* u32 primitive->connectionStats.dot11RtsFailureCount */
+ bufferSize += 4; /* u32 primitive->connectionStats.dot11FailedCount */
+ bufferSize += 4; /* u32 primitive->connectionStats.dot11TransmittedFragmentCount */
+ bufferSize += 4; /* u32 primitive->connectionStats.dot11TransmittedFrameCount */
+ bufferSize += 4; /* u32 primitive->connectionStats.dot11WepExcludedCount */
+ bufferSize += 4; /* u32 primitive->connectionStats.dot11WepIcvErrorCount */
+ bufferSize += 4; /* u32 primitive->connectionStats.dot11WepUndecryptableCount */
+ bufferSize += 4; /* u32 primitive->connectionStats.dot11MulticastReceivedFrameCount */
+ bufferSize += 4; /* u32 primitive->connectionStats.dot11MulticastTransmittedFrameCount */
+ bufferSize += 4; /* u32 primitive->connectionStats.dot11ReceivedFragmentCount */
+ bufferSize += 4; /* u32 primitive->connectionStats.dot11Rsna4WayHandshakeFailures */
+ bufferSize += 4; /* u32 primitive->connectionStats.dot11RsnaTkipCounterMeasuresInvoked */
+ bufferSize += 4; /* u32 primitive->connectionStats.dot11RsnaStatsTkipLocalMicFailures */
+ bufferSize += 4; /* u32 primitive->connectionStats.dot11RsnaStatsTkipReplays */
+ bufferSize += 4; /* u32 primitive->connectionStats.dot11RsnaStatsTkipIcvErrors */
+ bufferSize += 4; /* u32 primitive->connectionStats.dot11RsnaStatsCcmpReplays */
+ bufferSize += 4; /* u32 primitive->connectionStats.dot11RsnaStatsCcmpDecryptErrors */
+ return bufferSize;
+}
+
+
+u8* CsrWifiSmeConnectionStatsGetCfmSer(u8 *ptr, size_t *len, void *msg)
+{
+ CsrWifiSmeConnectionStatsGetCfm *primitive = (CsrWifiSmeConnectionStatsGetCfm *)msg;
+ *len = 0;
+ CsrUint16Ser(ptr, len, primitive->common.type);
+ CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
+ CsrUint16Ser(ptr, len, (u16) primitive->status);
+ CsrUint8Ser(ptr, len, (u8) primitive->connectionStats.unifiTxDataRate);
+ CsrUint8Ser(ptr, len, (u8) primitive->connectionStats.unifiRxDataRate);
+ CsrUint32Ser(ptr, len, (u32) primitive->connectionStats.dot11RetryCount);
+ CsrUint32Ser(ptr, len, (u32) primitive->connectionStats.dot11MultipleRetryCount);
+ CsrUint32Ser(ptr, len, (u32) primitive->connectionStats.dot11AckFailureCount);
+ CsrUint32Ser(ptr, len, (u32) primitive->connectionStats.dot11FrameDuplicateCount);
+ CsrUint32Ser(ptr, len, (u32) primitive->connectionStats.dot11FcsErrorCount);
+ CsrUint32Ser(ptr, len, (u32) primitive->connectionStats.dot11RtsSuccessCount);
+ CsrUint32Ser(ptr, len, (u32) primitive->connectionStats.dot11RtsFailureCount);
+ CsrUint32Ser(ptr, len, (u32) primitive->connectionStats.dot11FailedCount);
+ CsrUint32Ser(ptr, len, (u32) primitive->connectionStats.dot11TransmittedFragmentCount);
+ CsrUint32Ser(ptr, len, (u32) primitive->connectionStats.dot11TransmittedFrameCount);
+ CsrUint32Ser(ptr, len, (u32) primitive->connectionStats.dot11WepExcludedCount);
+ CsrUint32Ser(ptr, len, (u32) primitive->connectionStats.dot11WepIcvErrorCount);
+ CsrUint32Ser(ptr, len, (u32) primitive->connectionStats.dot11WepUndecryptableCount);
+ CsrUint32Ser(ptr, len, (u32) primitive->connectionStats.dot11MulticastReceivedFrameCount);
+ CsrUint32Ser(ptr, len, (u32) primitive->connectionStats.dot11MulticastTransmittedFrameCount);
+ CsrUint32Ser(ptr, len, (u32) primitive->connectionStats.dot11ReceivedFragmentCount);
+ CsrUint32Ser(ptr, len, (u32) primitive->connectionStats.dot11Rsna4WayHandshakeFailures);
+ CsrUint32Ser(ptr, len, (u32) primitive->connectionStats.dot11RsnaTkipCounterMeasuresInvoked);
+ CsrUint32Ser(ptr, len, (u32) primitive->connectionStats.dot11RsnaStatsTkipLocalMicFailures);
+ CsrUint32Ser(ptr, len, (u32) primitive->connectionStats.dot11RsnaStatsTkipReplays);
+ CsrUint32Ser(ptr, len, (u32) primitive->connectionStats.dot11RsnaStatsTkipIcvErrors);
+ CsrUint32Ser(ptr, len, (u32) primitive->connectionStats.dot11RsnaStatsCcmpReplays);
+ CsrUint32Ser(ptr, len, (u32) primitive->connectionStats.dot11RsnaStatsCcmpDecryptErrors);
+ return(ptr);
+}
+
+
+void* CsrWifiSmeConnectionStatsGetCfmDes(u8 *buffer, size_t length)
+{
+ CsrWifiSmeConnectionStatsGetCfm *primitive = kmalloc(sizeof(CsrWifiSmeConnectionStatsGetCfm), GFP_KERNEL);
+ size_t offset;
+ offset = 0;
+
+ CsrUint16Des(&primitive->common.type, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->connectionStats.unifiTxDataRate, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->connectionStats.unifiRxDataRate, buffer, &offset);
+ CsrUint32Des((u32 *) &primitive->connectionStats.dot11RetryCount, buffer, &offset);
+ CsrUint32Des((u32 *) &primitive->connectionStats.dot11MultipleRetryCount, buffer, &offset);
+ CsrUint32Des((u32 *) &primitive->connectionStats.dot11AckFailureCount, buffer, &offset);
+ CsrUint32Des((u32 *) &primitive->connectionStats.dot11FrameDuplicateCount, buffer, &offset);
+ CsrUint32Des((u32 *) &primitive->connectionStats.dot11FcsErrorCount, buffer, &offset);
+ CsrUint32Des((u32 *) &primitive->connectionStats.dot11RtsSuccessCount, buffer, &offset);
+ CsrUint32Des((u32 *) &primitive->connectionStats.dot11RtsFailureCount, buffer, &offset);
+ CsrUint32Des((u32 *) &primitive->connectionStats.dot11FailedCount, buffer, &offset);
+ CsrUint32Des((u32 *) &primitive->connectionStats.dot11TransmittedFragmentCount, buffer, &offset);
+ CsrUint32Des((u32 *) &primitive->connectionStats.dot11TransmittedFrameCount, buffer, &offset);
+ CsrUint32Des((u32 *) &primitive->connectionStats.dot11WepExcludedCount, buffer, &offset);
+ CsrUint32Des((u32 *) &primitive->connectionStats.dot11WepIcvErrorCount, buffer, &offset);
+ CsrUint32Des((u32 *) &primitive->connectionStats.dot11WepUndecryptableCount, buffer, &offset);
+ CsrUint32Des((u32 *) &primitive->connectionStats.dot11MulticastReceivedFrameCount, buffer, &offset);
+ CsrUint32Des((u32 *) &primitive->connectionStats.dot11MulticastTransmittedFrameCount, buffer, &offset);
+ CsrUint32Des((u32 *) &primitive->connectionStats.dot11ReceivedFragmentCount, buffer, &offset);
+ CsrUint32Des((u32 *) &primitive->connectionStats.dot11Rsna4WayHandshakeFailures, buffer, &offset);
+ CsrUint32Des((u32 *) &primitive->connectionStats.dot11RsnaTkipCounterMeasuresInvoked, buffer, &offset);
+ CsrUint32Des((u32 *) &primitive->connectionStats.dot11RsnaStatsTkipLocalMicFailures, buffer, &offset);
+ CsrUint32Des((u32 *) &primitive->connectionStats.dot11RsnaStatsTkipReplays, buffer, &offset);
+ CsrUint32Des((u32 *) &primitive->connectionStats.dot11RsnaStatsTkipIcvErrors, buffer, &offset);
+ CsrUint32Des((u32 *) &primitive->connectionStats.dot11RsnaStatsCcmpReplays, buffer, &offset);
+ CsrUint32Des((u32 *) &primitive->connectionStats.dot11RsnaStatsCcmpDecryptErrors, buffer, &offset);
+
+ return primitive;
+}
+
+
+size_t CsrWifiSmeDisconnectCfmSizeof(void *msg)
+{
+ size_t bufferSize = 2;
+
+ /* Calculate the Size of the Serialised Data. Could be more efficient (Try 7) */
+ bufferSize += 2; /* u16 primitive->interfaceTag */
+ bufferSize += 2; /* CsrResult primitive->status */
+ return bufferSize;
+}
+
+
+u8* CsrWifiSmeDisconnectCfmSer(u8 *ptr, size_t *len, void *msg)
+{
+ CsrWifiSmeDisconnectCfm *primitive = (CsrWifiSmeDisconnectCfm *)msg;
+ *len = 0;
+ CsrUint16Ser(ptr, len, primitive->common.type);
+ CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
+ CsrUint16Ser(ptr, len, (u16) primitive->status);
+ return(ptr);
+}
+
+
+void* CsrWifiSmeDisconnectCfmDes(u8 *buffer, size_t length)
+{
+ CsrWifiSmeDisconnectCfm *primitive = kmalloc(sizeof(CsrWifiSmeDisconnectCfm), GFP_KERNEL);
+ size_t offset;
+ offset = 0;
+
+ CsrUint16Des(&primitive->common.type, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
+
+ return primitive;
+}
+
+
+size_t CsrWifiSmeHostConfigGetCfmSizeof(void *msg)
+{
+ size_t bufferSize = 2;
+
+ /* Calculate the Size of the Serialised Data. Could be more efficient (Try 10) */
+ bufferSize += 2; /* u16 primitive->interfaceTag */
+ bufferSize += 2; /* CsrResult primitive->status */
+ bufferSize += 1; /* CsrWifiSmeHostPowerMode primitive->hostConfig.powerMode */
+ bufferSize += 2; /* u16 primitive->hostConfig.applicationDataPeriodMs */
+ return bufferSize;
+}
+
+
+u8* CsrWifiSmeHostConfigGetCfmSer(u8 *ptr, size_t *len, void *msg)
+{
+ CsrWifiSmeHostConfigGetCfm *primitive = (CsrWifiSmeHostConfigGetCfm *)msg;
+ *len = 0;
+ CsrUint16Ser(ptr, len, primitive->common.type);
+ CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
+ CsrUint16Ser(ptr, len, (u16) primitive->status);
+ CsrUint8Ser(ptr, len, (u8) primitive->hostConfig.powerMode);
+ CsrUint16Ser(ptr, len, (u16) primitive->hostConfig.applicationDataPeriodMs);
+ return(ptr);
+}
+
+
+void* CsrWifiSmeHostConfigGetCfmDes(u8 *buffer, size_t length)
+{
+ CsrWifiSmeHostConfigGetCfm *primitive = kmalloc(sizeof(CsrWifiSmeHostConfigGetCfm), GFP_KERNEL);
+ size_t offset;
+ offset = 0;
+
+ CsrUint16Des(&primitive->common.type, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->hostConfig.powerMode, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->hostConfig.applicationDataPeriodMs, buffer, &offset);
+
+ return primitive;
+}
+
+
+size_t CsrWifiSmeHostConfigSetCfmSizeof(void *msg)
+{
+ size_t bufferSize = 2;
+
+ /* Calculate the Size of the Serialised Data. Could be more efficient (Try 7) */
+ bufferSize += 2; /* u16 primitive->interfaceTag */
+ bufferSize += 2; /* CsrResult primitive->status */
+ return bufferSize;
+}
+
+
+u8* CsrWifiSmeHostConfigSetCfmSer(u8 *ptr, size_t *len, void *msg)
+{
+ CsrWifiSmeHostConfigSetCfm *primitive = (CsrWifiSmeHostConfigSetCfm *)msg;
+ *len = 0;
+ CsrUint16Ser(ptr, len, primitive->common.type);
+ CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
+ CsrUint16Ser(ptr, len, (u16) primitive->status);
+ return(ptr);
+}
+
+
+void* CsrWifiSmeHostConfigSetCfmDes(u8 *buffer, size_t length)
+{
+ CsrWifiSmeHostConfigSetCfm *primitive = kmalloc(sizeof(CsrWifiSmeHostConfigSetCfm), GFP_KERNEL);
+ size_t offset;
+ offset = 0;
+
+ CsrUint16Des(&primitive->common.type, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
+
+ return primitive;
+}
+
+
+size_t CsrWifiSmeIbssStationIndSizeof(void *msg)
+{
+ size_t bufferSize = 2;
+
+ /* Calculate the Size of the Serialised Data. Could be more efficient (Try 10) */
+ bufferSize += 6; /* u8 primitive->address.a[6] */
+ bufferSize += 1; /* u8 primitive->isconnected */
+ return bufferSize;
+}
+
+
+u8* CsrWifiSmeIbssStationIndSer(u8 *ptr, size_t *len, void *msg)
+{
+ CsrWifiSmeIbssStationInd *primitive = (CsrWifiSmeIbssStationInd *)msg;
+ *len = 0;
+ CsrUint16Ser(ptr, len, primitive->common.type);
+ CsrMemCpySer(ptr, len, (const void *) primitive->address.a, ((u16) (6)));
+ CsrUint8Ser(ptr, len, (u8) primitive->isconnected);
+ return(ptr);
+}
+
+
+void* CsrWifiSmeIbssStationIndDes(u8 *buffer, size_t length)
+{
+ CsrWifiSmeIbssStationInd *primitive = kmalloc(sizeof(CsrWifiSmeIbssStationInd), GFP_KERNEL);
+ size_t offset;
+ offset = 0;
+
+ CsrUint16Des(&primitive->common.type, buffer, &offset);
+ CsrMemCpyDes(primitive->address.a, buffer, &offset, ((u16) (6)));
+ CsrUint8Des((u8 *) &primitive->isconnected, buffer, &offset);
+
+ return primitive;
+}
+
+
+size_t CsrWifiSmeKeyCfmSizeof(void *msg)
+{
+ size_t bufferSize = 2;
+
+ /* Calculate the Size of the Serialised Data. Could be more efficient (Try 15) */
+ bufferSize += 2; /* u16 primitive->interfaceTag */
+ bufferSize += 2; /* CsrResult primitive->status */
+ bufferSize += 1; /* CsrWifiSmeListAction primitive->action */
+ bufferSize += 1; /* CsrWifiSmeKeyType primitive->keyType */
+ bufferSize += 6; /* u8 primitive->peerMacAddress.a[6] */
+ return bufferSize;
+}
+
+
+u8* CsrWifiSmeKeyCfmSer(u8 *ptr, size_t *len, void *msg)
+{
+ CsrWifiSmeKeyCfm *primitive = (CsrWifiSmeKeyCfm *)msg;
+ *len = 0;
+ CsrUint16Ser(ptr, len, primitive->common.type);
+ CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
+ CsrUint16Ser(ptr, len, (u16) primitive->status);
+ CsrUint8Ser(ptr, len, (u8) primitive->action);
+ CsrUint8Ser(ptr, len, (u8) primitive->keyType);
+ CsrMemCpySer(ptr, len, (const void *) primitive->peerMacAddress.a, ((u16) (6)));
+ return(ptr);
+}
+
+
+void* CsrWifiSmeKeyCfmDes(u8 *buffer, size_t length)
+{
+ CsrWifiSmeKeyCfm *primitive = kmalloc(sizeof(CsrWifiSmeKeyCfm), GFP_KERNEL);
+ size_t offset;
+ offset = 0;
+
+ CsrUint16Des(&primitive->common.type, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->action, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->keyType, buffer, &offset);
+ CsrMemCpyDes(primitive->peerMacAddress.a, buffer, &offset, ((u16) (6)));
+
+ return primitive;
+}
+
+
+size_t CsrWifiSmeLinkQualityGetCfmSizeof(void *msg)
+{
+ size_t bufferSize = 2;
+
+ /* Calculate the Size of the Serialised Data. Could be more efficient (Try 11) */
+ bufferSize += 2; /* u16 primitive->interfaceTag */
+ bufferSize += 2; /* CsrResult primitive->status */
+ bufferSize += 2; /* s16 primitive->linkQuality.unifiRssi */
+ bufferSize += 2; /* s16 primitive->linkQuality.unifiSnr */
+ return bufferSize;
+}
+
+
+u8* CsrWifiSmeLinkQualityGetCfmSer(u8 *ptr, size_t *len, void *msg)
+{
+ CsrWifiSmeLinkQualityGetCfm *primitive = (CsrWifiSmeLinkQualityGetCfm *)msg;
+ *len = 0;
+ CsrUint16Ser(ptr, len, primitive->common.type);
+ CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
+ CsrUint16Ser(ptr, len, (u16) primitive->status);
+ CsrUint16Ser(ptr, len, (u16) primitive->linkQuality.unifiRssi);
+ CsrUint16Ser(ptr, len, (u16) primitive->linkQuality.unifiSnr);
+ return(ptr);
+}
+
+
+void* CsrWifiSmeLinkQualityGetCfmDes(u8 *buffer, size_t length)
+{
+ CsrWifiSmeLinkQualityGetCfm *primitive = kmalloc(sizeof(CsrWifiSmeLinkQualityGetCfm), GFP_KERNEL);
+ size_t offset;
+ offset = 0;
+
+ CsrUint16Des(&primitive->common.type, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->linkQuality.unifiRssi, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->linkQuality.unifiSnr, buffer, &offset);
+
+ return primitive;
+}
+
+
+size_t CsrWifiSmeMediaStatusIndSizeof(void *msg)
+{
+ CsrWifiSmeMediaStatusInd *primitive = (CsrWifiSmeMediaStatusInd *) msg;
+ size_t bufferSize = 2;
+
+ /* Calculate the Size of the Serialised Data. Could be more efficient (Try 99) */
+ bufferSize += 2; /* u16 primitive->interfaceTag */
+ bufferSize += 1; /* CsrWifiSmeMediaStatus primitive->mediaStatus */
+ bufferSize += 32; /* u8 primitive->connectionInfo.ssid.ssid[32] */
+ bufferSize += 1; /* u8 primitive->connectionInfo.ssid.length */
+ bufferSize += 6; /* u8 primitive->connectionInfo.bssid.a[6] */
+ bufferSize += 1; /* CsrWifiSme80211NetworkType primitive->connectionInfo.networkType80211 */
+ bufferSize += 1; /* u8 primitive->connectionInfo.channelNumber */
+ bufferSize += 2; /* u16 primitive->connectionInfo.channelFrequency */
+ bufferSize += 2; /* CsrWifiSmeAuthMode primitive->connectionInfo.authMode */
+ bufferSize += 2; /* CsrWifiSmeEncryption primitive->connectionInfo.pairwiseCipher */
+ bufferSize += 2; /* CsrWifiSmeEncryption primitive->connectionInfo.groupCipher */
+ bufferSize += 1; /* CsrWifiSmeRadioIF primitive->connectionInfo.ifIndex */
+ bufferSize += 2; /* u16 primitive->connectionInfo.atimWindowTu */
+ bufferSize += 2; /* u16 primitive->connectionInfo.beaconPeriodTu */
+ bufferSize += 1; /* u8 primitive->connectionInfo.reassociation */
+ bufferSize += 2; /* u16 primitive->connectionInfo.beaconFrameLength */
+ bufferSize += primitive->connectionInfo.beaconFrameLength; /* u8 primitive->connectionInfo.beaconFrame */
+ bufferSize += 2; /* u16 primitive->connectionInfo.associationReqFrameLength */
+ bufferSize += primitive->connectionInfo.associationReqFrameLength; /* u8 primitive->connectionInfo.associationReqFrame */
+ bufferSize += 2; /* u16 primitive->connectionInfo.associationRspFrameLength */
+ bufferSize += primitive->connectionInfo.associationRspFrameLength; /* u8 primitive->connectionInfo.associationRspFrame */
+ bufferSize += 2; /* u16 primitive->connectionInfo.assocScanInfoElementsLength */
+ bufferSize += primitive->connectionInfo.assocScanInfoElementsLength; /* u8 primitive->connectionInfo.assocScanInfoElements */
+ bufferSize += 2; /* u16 primitive->connectionInfo.assocReqCapabilities */
+ bufferSize += 2; /* u16 primitive->connectionInfo.assocReqListenIntervalTu */
+ bufferSize += 6; /* u8 primitive->connectionInfo.assocReqApAddress.a[6] */
+ bufferSize += 2; /* u16 primitive->connectionInfo.assocReqInfoElementsLength */
+ bufferSize += primitive->connectionInfo.assocReqInfoElementsLength; /* u8 primitive->connectionInfo.assocReqInfoElements */
+ bufferSize += 2; /* CsrWifiSmeIEEE80211Result primitive->connectionInfo.assocRspResult */
+ bufferSize += 2; /* u16 primitive->connectionInfo.assocRspCapabilityInfo */
+ bufferSize += 2; /* u16 primitive->connectionInfo.assocRspAssociationId */
+ bufferSize += 2; /* u16 primitive->connectionInfo.assocRspInfoElementsLength */
+ bufferSize += primitive->connectionInfo.assocRspInfoElementsLength; /* u8 primitive->connectionInfo.assocRspInfoElements */
+ bufferSize += 2; /* CsrWifiSmeIEEE80211Reason primitive->disassocReason */
+ bufferSize += 2; /* CsrWifiSmeIEEE80211Reason primitive->deauthReason */
+ return bufferSize;
+}
+
+
+u8* CsrWifiSmeMediaStatusIndSer(u8 *ptr, size_t *len, void *msg)
+{
+ CsrWifiSmeMediaStatusInd *primitive = (CsrWifiSmeMediaStatusInd *)msg;
+ *len = 0;
+ CsrUint16Ser(ptr, len, primitive->common.type);
+ CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
+ CsrUint8Ser(ptr, len, (u8) primitive->mediaStatus);
+ CsrMemCpySer(ptr, len, (const void *) primitive->connectionInfo.ssid.ssid, ((u16) (32)));
+ CsrUint8Ser(ptr, len, (u8) primitive->connectionInfo.ssid.length);
+ CsrMemCpySer(ptr, len, (const void *) primitive->connectionInfo.bssid.a, ((u16) (6)));
+ CsrUint8Ser(ptr, len, (u8) primitive->connectionInfo.networkType80211);
+ CsrUint8Ser(ptr, len, (u8) primitive->connectionInfo.channelNumber);
+ CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.channelFrequency);
+ CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.authMode);
+ CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.pairwiseCipher);
+ CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.groupCipher);
+ CsrUint8Ser(ptr, len, (u8) primitive->connectionInfo.ifIndex);
+ CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.atimWindowTu);
+ CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.beaconPeriodTu);
+ CsrUint8Ser(ptr, len, (u8) primitive->connectionInfo.reassociation);
+ CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.beaconFrameLength);
+ if (primitive->connectionInfo.beaconFrameLength)
+ {
+ CsrMemCpySer(ptr, len, (const void *) primitive->connectionInfo.beaconFrame, ((u16) (primitive->connectionInfo.beaconFrameLength)));
+ }
+ CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.associationReqFrameLength);
+ if (primitive->connectionInfo.associationReqFrameLength)
+ {
+ CsrMemCpySer(ptr, len, (const void *) primitive->connectionInfo.associationReqFrame, ((u16) (primitive->connectionInfo.associationReqFrameLength)));
+ }
+ CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.associationRspFrameLength);
+ if (primitive->connectionInfo.associationRspFrameLength)
+ {
+ CsrMemCpySer(ptr, len, (const void *) primitive->connectionInfo.associationRspFrame, ((u16) (primitive->connectionInfo.associationRspFrameLength)));
+ }
+ CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.assocScanInfoElementsLength);
+ if (primitive->connectionInfo.assocScanInfoElementsLength)
+ {
+ CsrMemCpySer(ptr, len, (const void *) primitive->connectionInfo.assocScanInfoElements, ((u16) (primitive->connectionInfo.assocScanInfoElementsLength)));
+ }
+ CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.assocReqCapabilities);
+ CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.assocReqListenIntervalTu);
+ CsrMemCpySer(ptr, len, (const void *) primitive->connectionInfo.assocReqApAddress.a, ((u16) (6)));
+ CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.assocReqInfoElementsLength);
+ if (primitive->connectionInfo.assocReqInfoElementsLength)
+ {
+ CsrMemCpySer(ptr, len, (const void *) primitive->connectionInfo.assocReqInfoElements, ((u16) (primitive->connectionInfo.assocReqInfoElementsLength)));
+ }
+ CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.assocRspResult);
+ CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.assocRspCapabilityInfo);
+ CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.assocRspAssociationId);
+ CsrUint16Ser(ptr, len, (u16) primitive->connectionInfo.assocRspInfoElementsLength);
+ if (primitive->connectionInfo.assocRspInfoElementsLength)
+ {
+ CsrMemCpySer(ptr, len, (const void *) primitive->connectionInfo.assocRspInfoElements, ((u16) (primitive->connectionInfo.assocRspInfoElementsLength)));
+ }
+ CsrUint16Ser(ptr, len, (u16) primitive->disassocReason);
+ CsrUint16Ser(ptr, len, (u16) primitive->deauthReason);
+ return(ptr);
+}
+
+
+void* CsrWifiSmeMediaStatusIndDes(u8 *buffer, size_t length)
+{
+ CsrWifiSmeMediaStatusInd *primitive = kmalloc(sizeof(CsrWifiSmeMediaStatusInd), GFP_KERNEL);
+ size_t offset;
+ offset = 0;
+
+ CsrUint16Des(&primitive->common.type, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->mediaStatus, buffer, &offset);
+ CsrMemCpyDes(primitive->connectionInfo.ssid.ssid, buffer, &offset, ((u16) (32)));
+ CsrUint8Des((u8 *) &primitive->connectionInfo.ssid.length, buffer, &offset);
+ CsrMemCpyDes(primitive->connectionInfo.bssid.a, buffer, &offset, ((u16) (6)));
+ CsrUint8Des((u8 *) &primitive->connectionInfo.networkType80211, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->connectionInfo.channelNumber, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->connectionInfo.channelFrequency, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->connectionInfo.authMode, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->connectionInfo.pairwiseCipher, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->connectionInfo.groupCipher, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->connectionInfo.ifIndex, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->connectionInfo.atimWindowTu, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->connectionInfo.beaconPeriodTu, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->connectionInfo.reassociation, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->connectionInfo.beaconFrameLength, buffer, &offset);
+ if (primitive->connectionInfo.beaconFrameLength)
+ {
+ primitive->connectionInfo.beaconFrame = kmalloc(primitive->connectionInfo.beaconFrameLength, GFP_KERNEL);
+ CsrMemCpyDes(primitive->connectionInfo.beaconFrame, buffer, &offset, ((u16) (primitive->connectionInfo.beaconFrameLength)));
+ }
+ else
+ {
+ primitive->connectionInfo.beaconFrame = NULL;
+ }
+ CsrUint16Des((u16 *) &primitive->connectionInfo.associationReqFrameLength, buffer, &offset);
+ if (primitive->connectionInfo.associationReqFrameLength)
+ {
+ primitive->connectionInfo.associationReqFrame = kmalloc(primitive->connectionInfo.associationReqFrameLength, GFP_KERNEL);
+ CsrMemCpyDes(primitive->connectionInfo.associationReqFrame, buffer, &offset, ((u16) (primitive->connectionInfo.associationReqFrameLength)));
+ }
+ else
+ {
+ primitive->connectionInfo.associationReqFrame = NULL;
+ }
+ CsrUint16Des((u16 *) &primitive->connectionInfo.associationRspFrameLength, buffer, &offset);
+ if (primitive->connectionInfo.associationRspFrameLength)
+ {
+ primitive->connectionInfo.associationRspFrame = kmalloc(primitive->connectionInfo.associationRspFrameLength, GFP_KERNEL);
+ CsrMemCpyDes(primitive->connectionInfo.associationRspFrame, buffer, &offset, ((u16) (primitive->connectionInfo.associationRspFrameLength)));
+ }
+ else
+ {
+ primitive->connectionInfo.associationRspFrame = NULL;
+ }
+ CsrUint16Des((u16 *) &primitive->connectionInfo.assocScanInfoElementsLength, buffer, &offset);
+ if (primitive->connectionInfo.assocScanInfoElementsLength)
+ {
+ primitive->connectionInfo.assocScanInfoElements = kmalloc(primitive->connectionInfo.assocScanInfoElementsLength, GFP_KERNEL);
+ CsrMemCpyDes(primitive->connectionInfo.assocScanInfoElements, buffer, &offset, ((u16) (primitive->connectionInfo.assocScanInfoElementsLength)));
+ }
+ else
+ {
+ primitive->connectionInfo.assocScanInfoElements = NULL;
+ }
+ CsrUint16Des((u16 *) &primitive->connectionInfo.assocReqCapabilities, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->connectionInfo.assocReqListenIntervalTu, buffer, &offset);
+ CsrMemCpyDes(primitive->connectionInfo.assocReqApAddress.a, buffer, &offset, ((u16) (6)));
+ CsrUint16Des((u16 *) &primitive->connectionInfo.assocReqInfoElementsLength, buffer, &offset);
+ if (primitive->connectionInfo.assocReqInfoElementsLength)
+ {
+ primitive->connectionInfo.assocReqInfoElements = kmalloc(primitive->connectionInfo.assocReqInfoElementsLength, GFP_KERNEL);
+ CsrMemCpyDes(primitive->connectionInfo.assocReqInfoElements, buffer, &offset, ((u16) (primitive->connectionInfo.assocReqInfoElementsLength)));
+ }
+ else
+ {
+ primitive->connectionInfo.assocReqInfoElements = NULL;
+ }
+ CsrUint16Des((u16 *) &primitive->connectionInfo.assocRspResult, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->connectionInfo.assocRspCapabilityInfo, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->connectionInfo.assocRspAssociationId, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->connectionInfo.assocRspInfoElementsLength, buffer, &offset);
+ if (primitive->connectionInfo.assocRspInfoElementsLength)
+ {
+ primitive->connectionInfo.assocRspInfoElements = kmalloc(primitive->connectionInfo.assocRspInfoElementsLength, GFP_KERNEL);
+ CsrMemCpyDes(primitive->connectionInfo.assocRspInfoElements, buffer, &offset, ((u16) (primitive->connectionInfo.assocRspInfoElementsLength)));
+ }
+ else
+ {
+ primitive->connectionInfo.assocRspInfoElements = NULL;
+ }
+ CsrUint16Des((u16 *) &primitive->disassocReason, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->deauthReason, buffer, &offset);
+
+ return primitive;
+}
+
+
+void CsrWifiSmeMediaStatusIndSerFree(void *voidPrimitivePointer)
+{
+ CsrWifiSmeMediaStatusInd *primitive = (CsrWifiSmeMediaStatusInd *) voidPrimitivePointer;
+ kfree(primitive->connectionInfo.beaconFrame);
+ kfree(primitive->connectionInfo.associationReqFrame);
+ kfree(primitive->connectionInfo.associationRspFrame);
+ kfree(primitive->connectionInfo.assocScanInfoElements);
+ kfree(primitive->connectionInfo.assocReqInfoElements);
+ kfree(primitive->connectionInfo.assocRspInfoElements);
+ kfree(primitive);
+}
+
+
+size_t CsrWifiSmeMibConfigGetCfmSizeof(void *msg)
+{
+ size_t bufferSize = 2;
+
+ /* Calculate the Size of the Serialised Data. Could be more efficient (Try 13) */
+ bufferSize += 2; /* CsrResult primitive->status */
+ bufferSize += 1; /* u8 primitive->mibConfig.unifiFixMaxTxDataRate */
+ bufferSize += 1; /* u8 primitive->mibConfig.unifiFixTxDataRate */
+ bufferSize += 2; /* u16 primitive->mibConfig.dot11RtsThreshold */
+ bufferSize += 2; /* u16 primitive->mibConfig.dot11FragmentationThreshold */
+ bufferSize += 2; /* u16 primitive->mibConfig.dot11CurrentTxPowerLevel */
+ return bufferSize;
+}
+
+
+u8* CsrWifiSmeMibConfigGetCfmSer(u8 *ptr, size_t *len, void *msg)
+{
+ CsrWifiSmeMibConfigGetCfm *primitive = (CsrWifiSmeMibConfigGetCfm *)msg;
+ *len = 0;
+ CsrUint16Ser(ptr, len, primitive->common.type);
+ CsrUint16Ser(ptr, len, (u16) primitive->status);
+ CsrUint8Ser(ptr, len, (u8) primitive->mibConfig.unifiFixMaxTxDataRate);
+ CsrUint8Ser(ptr, len, (u8) primitive->mibConfig.unifiFixTxDataRate);
+ CsrUint16Ser(ptr, len, (u16) primitive->mibConfig.dot11RtsThreshold);
+ CsrUint16Ser(ptr, len, (u16) primitive->mibConfig.dot11FragmentationThreshold);
+ CsrUint16Ser(ptr, len, (u16) primitive->mibConfig.dot11CurrentTxPowerLevel);
+ return(ptr);
+}
+
+
+void* CsrWifiSmeMibConfigGetCfmDes(u8 *buffer, size_t length)
+{
+ CsrWifiSmeMibConfigGetCfm *primitive = kmalloc(sizeof(CsrWifiSmeMibConfigGetCfm), GFP_KERNEL);
+ size_t offset;
+ offset = 0;
+
+ CsrUint16Des(&primitive->common.type, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->mibConfig.unifiFixMaxTxDataRate, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->mibConfig.unifiFixTxDataRate, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->mibConfig.dot11RtsThreshold, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->mibConfig.dot11FragmentationThreshold, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->mibConfig.dot11CurrentTxPowerLevel, buffer, &offset);
+
+ return primitive;
+}
+
+
+size_t CsrWifiSmeMibGetCfmSizeof(void *msg)
+{
+ CsrWifiSmeMibGetCfm *primitive = (CsrWifiSmeMibGetCfm *) msg;
+ size_t bufferSize = 2;
+
+ /* Calculate the Size of the Serialised Data. Could be more efficient (Try 8) */
+ bufferSize += 2; /* CsrResult primitive->status */
+ bufferSize += 2; /* u16 primitive->mibAttributeLength */
+ bufferSize += primitive->mibAttributeLength; /* u8 primitive->mibAttribute */
+ return bufferSize;
+}
+
+
+u8* CsrWifiSmeMibGetCfmSer(u8 *ptr, size_t *len, void *msg)
+{
+ CsrWifiSmeMibGetCfm *primitive = (CsrWifiSmeMibGetCfm *)msg;
+ *len = 0;
+ CsrUint16Ser(ptr, len, primitive->common.type);
+ CsrUint16Ser(ptr, len, (u16) primitive->status);
+ CsrUint16Ser(ptr, len, (u16) primitive->mibAttributeLength);
+ if (primitive->mibAttributeLength)
+ {
+ CsrMemCpySer(ptr, len, (const void *) primitive->mibAttribute, ((u16) (primitive->mibAttributeLength)));
+ }
+ return(ptr);
+}
+
+
+void* CsrWifiSmeMibGetCfmDes(u8 *buffer, size_t length)
+{
+ CsrWifiSmeMibGetCfm *primitive = kmalloc(sizeof(CsrWifiSmeMibGetCfm), GFP_KERNEL);
+ size_t offset;
+ offset = 0;
+
+ CsrUint16Des(&primitive->common.type, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->mibAttributeLength, buffer, &offset);
+ if (primitive->mibAttributeLength)
+ {
+ primitive->mibAttribute = kmalloc(primitive->mibAttributeLength, GFP_KERNEL);
+ CsrMemCpyDes(primitive->mibAttribute, buffer, &offset, ((u16) (primitive->mibAttributeLength)));
+ }
+ else
+ {
+ primitive->mibAttribute = NULL;
+ }
+
+ return primitive;
+}
+
+
+void CsrWifiSmeMibGetCfmSerFree(void *voidPrimitivePointer)
+{
+ CsrWifiSmeMibGetCfm *primitive = (CsrWifiSmeMibGetCfm *) voidPrimitivePointer;
+ kfree(primitive->mibAttribute);
+ kfree(primitive);
+}
+
+
+size_t CsrWifiSmeMibGetNextCfmSizeof(void *msg)
+{
+ CsrWifiSmeMibGetNextCfm *primitive = (CsrWifiSmeMibGetNextCfm *) msg;
+ size_t bufferSize = 2;
+
+ /* Calculate the Size of the Serialised Data. Could be more efficient (Try 8) */
+ bufferSize += 2; /* CsrResult primitive->status */
+ bufferSize += 2; /* u16 primitive->mibAttributeLength */
+ bufferSize += primitive->mibAttributeLength; /* u8 primitive->mibAttribute */
+ return bufferSize;
+}
+
+
+u8* CsrWifiSmeMibGetNextCfmSer(u8 *ptr, size_t *len, void *msg)
+{
+ CsrWifiSmeMibGetNextCfm *primitive = (CsrWifiSmeMibGetNextCfm *)msg;
+ *len = 0;
+ CsrUint16Ser(ptr, len, primitive->common.type);
+ CsrUint16Ser(ptr, len, (u16) primitive->status);
+ CsrUint16Ser(ptr, len, (u16) primitive->mibAttributeLength);
+ if (primitive->mibAttributeLength)
+ {
+ CsrMemCpySer(ptr, len, (const void *) primitive->mibAttribute, ((u16) (primitive->mibAttributeLength)));
+ }
+ return(ptr);
+}
+
+
+void* CsrWifiSmeMibGetNextCfmDes(u8 *buffer, size_t length)
+{
+ CsrWifiSmeMibGetNextCfm *primitive = kmalloc(sizeof(CsrWifiSmeMibGetNextCfm), GFP_KERNEL);
+ size_t offset;
+ offset = 0;
+
+ CsrUint16Des(&primitive->common.type, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->mibAttributeLength, buffer, &offset);
+ if (primitive->mibAttributeLength)
+ {
+ primitive->mibAttribute = kmalloc(primitive->mibAttributeLength, GFP_KERNEL);
+ CsrMemCpyDes(primitive->mibAttribute, buffer, &offset, ((u16) (primitive->mibAttributeLength)));
+ }
+ else
+ {
+ primitive->mibAttribute = NULL;
+ }
+
+ return primitive;
+}
+
+
+void CsrWifiSmeMibGetNextCfmSerFree(void *voidPrimitivePointer)
+{
+ CsrWifiSmeMibGetNextCfm *primitive = (CsrWifiSmeMibGetNextCfm *) voidPrimitivePointer;
+ kfree(primitive->mibAttribute);
+ kfree(primitive);
+}
+
+
+size_t CsrWifiSmeMicFailureIndSizeof(void *msg)
+{
+ size_t bufferSize = 2;
+
+ /* Calculate the Size of the Serialised Data. Could be more efficient (Try 15) */
+ bufferSize += 2; /* u16 primitive->interfaceTag */
+ bufferSize += 1; /* u8 primitive->secondFailure */
+ bufferSize += 2; /* u16 primitive->count */
+ bufferSize += 6; /* u8 primitive->address.a[6] */
+ bufferSize += 1; /* CsrWifiSmeKeyType primitive->keyType */
+ return bufferSize;
+}
+
+
+u8* CsrWifiSmeMicFailureIndSer(u8 *ptr, size_t *len, void *msg)
+{
+ CsrWifiSmeMicFailureInd *primitive = (CsrWifiSmeMicFailureInd *)msg;
+ *len = 0;
+ CsrUint16Ser(ptr, len, primitive->common.type);
+ CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
+ CsrUint8Ser(ptr, len, (u8) primitive->secondFailure);
+ CsrUint16Ser(ptr, len, (u16) primitive->count);
+ CsrMemCpySer(ptr, len, (const void *) primitive->address.a, ((u16) (6)));
+ CsrUint8Ser(ptr, len, (u8) primitive->keyType);
+ return(ptr);
+}
+
+
+void* CsrWifiSmeMicFailureIndDes(u8 *buffer, size_t length)
+{
+ CsrWifiSmeMicFailureInd *primitive = kmalloc(sizeof(CsrWifiSmeMicFailureInd), GFP_KERNEL);
+ size_t offset;
+ offset = 0;
+
+ CsrUint16Des(&primitive->common.type, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->secondFailure, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->count, buffer, &offset);
+ CsrMemCpyDes(primitive->address.a, buffer, &offset, ((u16) (6)));
+ CsrUint8Des((u8 *) &primitive->keyType, buffer, &offset);
+
+ return primitive;
+}
+
+
+size_t CsrWifiSmeMulticastAddressCfmSizeof(void *msg)
+{
+ CsrWifiSmeMulticastAddressCfm *primitive = (CsrWifiSmeMulticastAddressCfm *) msg;
+ size_t bufferSize = 2;
+
+ /* Calculate the Size of the Serialised Data. Could be more efficient (Try 15) */
+ bufferSize += 2; /* u16 primitive->interfaceTag */
+ bufferSize += 2; /* CsrResult primitive->status */
+ bufferSize += 1; /* CsrWifiSmeListAction primitive->action */
+ bufferSize += 1; /* u8 primitive->getAddressesCount */
+ {
+ u16 i1;
+ for (i1 = 0; i1 < primitive->getAddressesCount; i1++)
+ {
+ bufferSize += 6; /* u8 primitive->getAddresses[i1].a[6] */
+ }
+ }
+ return bufferSize;
+}
+
+
+u8* CsrWifiSmeMulticastAddressCfmSer(u8 *ptr, size_t *len, void *msg)
+{
+ CsrWifiSmeMulticastAddressCfm *primitive = (CsrWifiSmeMulticastAddressCfm *)msg;
+ *len = 0;
+ CsrUint16Ser(ptr, len, primitive->common.type);
+ CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
+ CsrUint16Ser(ptr, len, (u16) primitive->status);
+ CsrUint8Ser(ptr, len, (u8) primitive->action);
+ CsrUint8Ser(ptr, len, (u8) primitive->getAddressesCount);
+ {
+ u16 i1;
+ for (i1 = 0; i1 < primitive->getAddressesCount; i1++)
+ {
+ CsrMemCpySer(ptr, len, (const void *) primitive->getAddresses[i1].a, ((u16) (6)));
+ }
+ }
+ return(ptr);
+}
+
+
+void* CsrWifiSmeMulticastAddressCfmDes(u8 *buffer, size_t length)
+{
+ CsrWifiSmeMulticastAddressCfm *primitive = kmalloc(sizeof(CsrWifiSmeMulticastAddressCfm), GFP_KERNEL);
+ size_t offset;
+ offset = 0;
+
+ CsrUint16Des(&primitive->common.type, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->action, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->getAddressesCount, buffer, &offset);
+ primitive->getAddresses = NULL;
+ if (primitive->getAddressesCount)
+ {
+ primitive->getAddresses = kmalloc(sizeof(CsrWifiMacAddress) * primitive->getAddressesCount, GFP_KERNEL);
+ }
+ {
+ u16 i1;
+ for (i1 = 0; i1 < primitive->getAddressesCount; i1++)
+ {
+ CsrMemCpyDes(primitive->getAddresses[i1].a, buffer, &offset, ((u16) (6)));
+ }
+ }
+
+ return primitive;
+}
+
+
+void CsrWifiSmeMulticastAddressCfmSerFree(void *voidPrimitivePointer)
+{
+ CsrWifiSmeMulticastAddressCfm *primitive = (CsrWifiSmeMulticastAddressCfm *) voidPrimitivePointer;
+ kfree(primitive->getAddresses);
+ kfree(primitive);
+}
+
+
+size_t CsrWifiSmePacketFilterSetCfmSizeof(void *msg)
+{
+ size_t bufferSize = 2;
+
+ /* Calculate the Size of the Serialised Data. Could be more efficient (Try 7) */
+ bufferSize += 2; /* u16 primitive->interfaceTag */
+ bufferSize += 2; /* CsrResult primitive->status */
+ return bufferSize;
+}
+
+
+u8* CsrWifiSmePacketFilterSetCfmSer(u8 *ptr, size_t *len, void *msg)
+{
+ CsrWifiSmePacketFilterSetCfm *primitive = (CsrWifiSmePacketFilterSetCfm *)msg;
+ *len = 0;
+ CsrUint16Ser(ptr, len, primitive->common.type);
+ CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
+ CsrUint16Ser(ptr, len, (u16) primitive->status);
+ return(ptr);
+}
+
+
+void* CsrWifiSmePacketFilterSetCfmDes(u8 *buffer, size_t length)
+{
+ CsrWifiSmePacketFilterSetCfm *primitive = kmalloc(sizeof(CsrWifiSmePacketFilterSetCfm), GFP_KERNEL);
+ size_t offset;
+ offset = 0;
+
+ CsrUint16Des(&primitive->common.type, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
+
+ return primitive;
+}
+
+
+size_t CsrWifiSmePermanentMacAddressGetCfmSizeof(void *msg)
+{
+ size_t bufferSize = 2;
+
+ /* Calculate the Size of the Serialised Data. Could be more efficient (Try 11) */
+ bufferSize += 2; /* CsrResult primitive->status */
+ bufferSize += 6; /* u8 primitive->permanentMacAddress.a[6] */
+ return bufferSize;
+}
+
+
+u8* CsrWifiSmePermanentMacAddressGetCfmSer(u8 *ptr, size_t *len, void *msg)
+{
+ CsrWifiSmePermanentMacAddressGetCfm *primitive = (CsrWifiSmePermanentMacAddressGetCfm *)msg;
+ *len = 0;
+ CsrUint16Ser(ptr, len, primitive->common.type);
+ CsrUint16Ser(ptr, len, (u16) primitive->status);
+ CsrMemCpySer(ptr, len, (const void *) primitive->permanentMacAddress.a, ((u16) (6)));
+ return(ptr);
+}
+
+
+void* CsrWifiSmePermanentMacAddressGetCfmDes(u8 *buffer, size_t length)
+{
+ CsrWifiSmePermanentMacAddressGetCfm *primitive = kmalloc(sizeof(CsrWifiSmePermanentMacAddressGetCfm), GFP_KERNEL);
+ size_t offset;
+ offset = 0;
+
+ CsrUint16Des(&primitive->common.type, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
+ CsrMemCpyDes(primitive->permanentMacAddress.a, buffer, &offset, ((u16) (6)));
+
+ return primitive;
+}
+
+
+size_t CsrWifiSmePmkidCandidateListIndSizeof(void *msg)
+{
+ CsrWifiSmePmkidCandidateListInd *primitive = (CsrWifiSmePmkidCandidateListInd *) msg;
+ size_t bufferSize = 2;
+
+ /* Calculate the Size of the Serialised Data. Could be more efficient (Try 13) */
+ bufferSize += 2; /* u16 primitive->interfaceTag */
+ bufferSize += 1; /* u8 primitive->pmkidCandidatesCount */
+ {
+ u16 i1;
+ for (i1 = 0; i1 < primitive->pmkidCandidatesCount; i1++)
+ {
+ bufferSize += 6; /* u8 primitive->pmkidCandidates[i1].bssid.a[6] */
+ bufferSize += 1; /* u8 primitive->pmkidCandidates[i1].preAuthAllowed */
+ }
+ }
+ return bufferSize;
+}
+
+
+u8* CsrWifiSmePmkidCandidateListIndSer(u8 *ptr, size_t *len, void *msg)
+{
+ CsrWifiSmePmkidCandidateListInd *primitive = (CsrWifiSmePmkidCandidateListInd *)msg;
+ *len = 0;
+ CsrUint16Ser(ptr, len, primitive->common.type);
+ CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
+ CsrUint8Ser(ptr, len, (u8) primitive->pmkidCandidatesCount);
+ {
+ u16 i1;
+ for (i1 = 0; i1 < primitive->pmkidCandidatesCount; i1++)
+ {
+ CsrMemCpySer(ptr, len, (const void *) primitive->pmkidCandidates[i1].bssid.a, ((u16) (6)));
+ CsrUint8Ser(ptr, len, (u8) primitive->pmkidCandidates[i1].preAuthAllowed);
+ }
+ }
+ return(ptr);
+}
+
+
+void* CsrWifiSmePmkidCandidateListIndDes(u8 *buffer, size_t length)
+{
+ CsrWifiSmePmkidCandidateListInd *primitive = kmalloc(sizeof(CsrWifiSmePmkidCandidateListInd), GFP_KERNEL);
+ size_t offset;
+ offset = 0;
+
+ CsrUint16Des(&primitive->common.type, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->pmkidCandidatesCount, buffer, &offset);
+ primitive->pmkidCandidates = NULL;
+ if (primitive->pmkidCandidatesCount)
+ {
+ primitive->pmkidCandidates = kmalloc(sizeof(CsrWifiSmePmkidCandidate) * primitive->pmkidCandidatesCount, GFP_KERNEL);
+ }
+ {
+ u16 i1;
+ for (i1 = 0; i1 < primitive->pmkidCandidatesCount; i1++)
+ {
+ CsrMemCpyDes(primitive->pmkidCandidates[i1].bssid.a, buffer, &offset, ((u16) (6)));
+ CsrUint8Des((u8 *) &primitive->pmkidCandidates[i1].preAuthAllowed, buffer, &offset);
+ }
+ }
+
+ return primitive;
+}
+
+
+void CsrWifiSmePmkidCandidateListIndSerFree(void *voidPrimitivePointer)
+{
+ CsrWifiSmePmkidCandidateListInd *primitive = (CsrWifiSmePmkidCandidateListInd *) voidPrimitivePointer;
+ kfree(primitive->pmkidCandidates);
+ kfree(primitive);
+}
+
+
+size_t CsrWifiSmePmkidCfmSizeof(void *msg)
+{
+ CsrWifiSmePmkidCfm *primitive = (CsrWifiSmePmkidCfm *) msg;
+ size_t bufferSize = 2;
+
+ /* Calculate the Size of the Serialised Data. Could be more efficient (Try 31) */
+ bufferSize += 2; /* u16 primitive->interfaceTag */
+ bufferSize += 2; /* CsrResult primitive->status */
+ bufferSize += 1; /* CsrWifiSmeListAction primitive->action */
+ bufferSize += 1; /* u8 primitive->getPmkidsCount */
+ {
+ u16 i1;
+ for (i1 = 0; i1 < primitive->getPmkidsCount; i1++)
+ {
+ bufferSize += 6; /* u8 primitive->getPmkids[i1].bssid.a[6] */
+ bufferSize += 16; /* u8 primitive->getPmkids[i1].pmkid[16] */
+ }
+ }
+ return bufferSize;
+}
+
+
+u8* CsrWifiSmePmkidCfmSer(u8 *ptr, size_t *len, void *msg)
+{
+ CsrWifiSmePmkidCfm *primitive = (CsrWifiSmePmkidCfm *)msg;
+ *len = 0;
+ CsrUint16Ser(ptr, len, primitive->common.type);
+ CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
+ CsrUint16Ser(ptr, len, (u16) primitive->status);
+ CsrUint8Ser(ptr, len, (u8) primitive->action);
+ CsrUint8Ser(ptr, len, (u8) primitive->getPmkidsCount);
+ {
+ u16 i1;
+ for (i1 = 0; i1 < primitive->getPmkidsCount; i1++)
+ {
+ CsrMemCpySer(ptr, len, (const void *) primitive->getPmkids[i1].bssid.a, ((u16) (6)));
+ CsrMemCpySer(ptr, len, (const void *) primitive->getPmkids[i1].pmkid, ((u16) (16)));
+ }
+ }
+ return(ptr);
+}
+
+
+void* CsrWifiSmePmkidCfmDes(u8 *buffer, size_t length)
+{
+ CsrWifiSmePmkidCfm *primitive = kmalloc(sizeof(CsrWifiSmePmkidCfm), GFP_KERNEL);
+ size_t offset;
+ offset = 0;
+
+ CsrUint16Des(&primitive->common.type, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->action, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->getPmkidsCount, buffer, &offset);
+ primitive->getPmkids = NULL;
+ if (primitive->getPmkidsCount)
+ {
+ primitive->getPmkids = kmalloc(sizeof(CsrWifiSmePmkid) * primitive->getPmkidsCount, GFP_KERNEL);
+ }
+ {
+ u16 i1;
+ for (i1 = 0; i1 < primitive->getPmkidsCount; i1++)
+ {
+ CsrMemCpyDes(primitive->getPmkids[i1].bssid.a, buffer, &offset, ((u16) (6)));
+ CsrMemCpyDes(primitive->getPmkids[i1].pmkid, buffer, &offset, ((u16) (16)));
+ }
+ }
+
+ return primitive;
+}
+
+
+void CsrWifiSmePmkidCfmSerFree(void *voidPrimitivePointer)
+{
+ CsrWifiSmePmkidCfm *primitive = (CsrWifiSmePmkidCfm *) voidPrimitivePointer;
+ kfree(primitive->getPmkids);
+ kfree(primitive);
+}
+
+
+size_t CsrWifiSmePowerConfigGetCfmSizeof(void *msg)
+{
+ size_t bufferSize = 2;
+
+ /* Calculate the Size of the Serialised Data. Could be more efficient (Try 13) */
+ bufferSize += 2; /* CsrResult primitive->status */
+ bufferSize += 1; /* CsrWifiSmePowerSaveLevel primitive->powerConfig.powerSaveLevel */
+ bufferSize += 2; /* u16 primitive->powerConfig.listenIntervalTu */
+ bufferSize += 1; /* u8 primitive->powerConfig.rxDtims */
+ bufferSize += 1; /* CsrWifiSmeD3AutoScanMode primitive->powerConfig.d3AutoScanMode */
+ bufferSize += 1; /* u8 primitive->powerConfig.clientTrafficWindow */
+ bufferSize += 1; /* u8 primitive->powerConfig.opportunisticPowerSave */
+ bufferSize += 1; /* u8 primitive->powerConfig.noticeOfAbsence */
+ return bufferSize;
+}
+
+
+u8* CsrWifiSmePowerConfigGetCfmSer(u8 *ptr, size_t *len, void *msg)
+{
+ CsrWifiSmePowerConfigGetCfm *primitive = (CsrWifiSmePowerConfigGetCfm *)msg;
+ *len = 0;
+ CsrUint16Ser(ptr, len, primitive->common.type);
+ CsrUint16Ser(ptr, len, (u16) primitive->status);
+ CsrUint8Ser(ptr, len, (u8) primitive->powerConfig.powerSaveLevel);
+ CsrUint16Ser(ptr, len, (u16) primitive->powerConfig.listenIntervalTu);
+ CsrUint8Ser(ptr, len, (u8) primitive->powerConfig.rxDtims);
+ CsrUint8Ser(ptr, len, (u8) primitive->powerConfig.d3AutoScanMode);
+ CsrUint8Ser(ptr, len, (u8) primitive->powerConfig.clientTrafficWindow);
+ CsrUint8Ser(ptr, len, (u8) primitive->powerConfig.opportunisticPowerSave);
+ CsrUint8Ser(ptr, len, (u8) primitive->powerConfig.noticeOfAbsence);
+ return(ptr);
+}
+
+
+void* CsrWifiSmePowerConfigGetCfmDes(u8 *buffer, size_t length)
+{
+ CsrWifiSmePowerConfigGetCfm *primitive = kmalloc(sizeof(CsrWifiSmePowerConfigGetCfm), GFP_KERNEL);
+ size_t offset;
+ offset = 0;
+
+ CsrUint16Des(&primitive->common.type, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->powerConfig.powerSaveLevel, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->powerConfig.listenIntervalTu, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->powerConfig.rxDtims, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->powerConfig.d3AutoScanMode, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->powerConfig.clientTrafficWindow, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->powerConfig.opportunisticPowerSave, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->powerConfig.noticeOfAbsence, buffer, &offset);
+
+ return primitive;
+}
+
+
+size_t CsrWifiSmeRegulatoryDomainInfoGetCfmSizeof(void *msg)
+{
+ size_t bufferSize = 2;
+
+ /* Calculate the Size of the Serialised Data. Could be more efficient (Try 10) */
+ bufferSize += 2; /* CsrResult primitive->status */
+ bufferSize += 1; /* u8 primitive->regDomInfo.dot11MultiDomainCapabilityImplemented */
+ bufferSize += 1; /* u8 primitive->regDomInfo.dot11MultiDomainCapabilityEnabled */
+ bufferSize += 1; /* CsrWifiSmeRegulatoryDomain primitive->regDomInfo.currentRegulatoryDomain */
+ bufferSize += 2; /* u8 primitive->regDomInfo.currentCountryCode[2] */
+ return bufferSize;
+}
+
+
+u8* CsrWifiSmeRegulatoryDomainInfoGetCfmSer(u8 *ptr, size_t *len, void *msg)
+{
+ CsrWifiSmeRegulatoryDomainInfoGetCfm *primitive = (CsrWifiSmeRegulatoryDomainInfoGetCfm *)msg;
+ *len = 0;
+ CsrUint16Ser(ptr, len, primitive->common.type);
+ CsrUint16Ser(ptr, len, (u16) primitive->status);
+ CsrUint8Ser(ptr, len, (u8) primitive->regDomInfo.dot11MultiDomainCapabilityImplemented);
+ CsrUint8Ser(ptr, len, (u8) primitive->regDomInfo.dot11MultiDomainCapabilityEnabled);
+ CsrUint8Ser(ptr, len, (u8) primitive->regDomInfo.currentRegulatoryDomain);
+ CsrMemCpySer(ptr, len, (const void *) primitive->regDomInfo.currentCountryCode, ((u16) (2)));
+ return(ptr);
+}
+
+
+void* CsrWifiSmeRegulatoryDomainInfoGetCfmDes(u8 *buffer, size_t length)
+{
+ CsrWifiSmeRegulatoryDomainInfoGetCfm *primitive = kmalloc(sizeof(CsrWifiSmeRegulatoryDomainInfoGetCfm), GFP_KERNEL);
+ size_t offset;
+ offset = 0;
+
+ CsrUint16Des(&primitive->common.type, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->regDomInfo.dot11MultiDomainCapabilityImplemented, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->regDomInfo.dot11MultiDomainCapabilityEnabled, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->regDomInfo.currentRegulatoryDomain, buffer, &offset);
+ CsrMemCpyDes(primitive->regDomInfo.currentCountryCode, buffer, &offset, ((u16) (2)));
+
+ return primitive;
+}
+
+
+size_t CsrWifiSmeRoamCompleteIndSizeof(void *msg)
+{
+ size_t bufferSize = 2;
+
+ /* Calculate the Size of the Serialised Data. Could be more efficient (Try 7) */
+ bufferSize += 2; /* u16 primitive->interfaceTag */
+ bufferSize += 2; /* CsrResult primitive->status */
+ return bufferSize;
+}
+
+
+u8* CsrWifiSmeRoamCompleteIndSer(u8 *ptr, size_t *len, void *msg)
+{
+ CsrWifiSmeRoamCompleteInd *primitive = (CsrWifiSmeRoamCompleteInd *)msg;
+ *len = 0;
+ CsrUint16Ser(ptr, len, primitive->common.type);
+ CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
+ CsrUint16Ser(ptr, len, (u16) primitive->status);
+ return(ptr);
+}
+
+
+void* CsrWifiSmeRoamCompleteIndDes(u8 *buffer, size_t length)
+{
+ CsrWifiSmeRoamCompleteInd *primitive = kmalloc(sizeof(CsrWifiSmeRoamCompleteInd), GFP_KERNEL);
+ size_t offset;
+ offset = 0;
+
+ CsrUint16Des(&primitive->common.type, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
+
+ return primitive;
+}
+
+
+size_t CsrWifiSmeRoamStartIndSizeof(void *msg)
+{
+ size_t bufferSize = 2;
+
+ /* Calculate the Size of the Serialised Data. Could be more efficient (Try 8) */
+ bufferSize += 2; /* u16 primitive->interfaceTag */
+ bufferSize += 1; /* CsrWifiSmeRoamReason primitive->roamReason */
+ bufferSize += 2; /* CsrWifiSmeIEEE80211Reason primitive->reason80211 */
+ return bufferSize;
+}
+
+
+u8* CsrWifiSmeRoamStartIndSer(u8 *ptr, size_t *len, void *msg)
+{
+ CsrWifiSmeRoamStartInd *primitive = (CsrWifiSmeRoamStartInd *)msg;
+ *len = 0;
+ CsrUint16Ser(ptr, len, primitive->common.type);
+ CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
+ CsrUint8Ser(ptr, len, (u8) primitive->roamReason);
+ CsrUint16Ser(ptr, len, (u16) primitive->reason80211);
+ return(ptr);
+}
+
+
+void* CsrWifiSmeRoamStartIndDes(u8 *buffer, size_t length)
+{
+ CsrWifiSmeRoamStartInd *primitive = kmalloc(sizeof(CsrWifiSmeRoamStartInd), GFP_KERNEL);
+ size_t offset;
+ offset = 0;
+
+ CsrUint16Des(&primitive->common.type, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->roamReason, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->reason80211, buffer, &offset);
+
+ return primitive;
+}
+
+
+size_t CsrWifiSmeRoamingConfigGetCfmSizeof(void *msg)
+{
+ size_t bufferSize = 2;
+
+ /* Calculate the Size of the Serialised Data. Could be more efficient (Try 72) */
+ bufferSize += 2; /* u16 primitive->interfaceTag */
+ bufferSize += 2; /* CsrResult primitive->status */
+ {
+ u16 i2;
+ for (i2 = 0; i2 < 3; i2++)
+ {
+ bufferSize += 2; /* s16 primitive->roamingConfig.roamingBands[i2].rssiHighThreshold */
+ bufferSize += 2; /* s16 primitive->roamingConfig.roamingBands[i2].rssiLowThreshold */
+ bufferSize += 2; /* s16 primitive->roamingConfig.roamingBands[i2].snrHighThreshold */
+ bufferSize += 2; /* s16 primitive->roamingConfig.roamingBands[i2].snrLowThreshold */
+ }
+ }
+ bufferSize += 1; /* u8 primitive->roamingConfig.disableSmoothRoaming */
+ bufferSize += 1; /* u8 primitive->roamingConfig.disableRoamScans */
+ bufferSize += 1; /* u8 primitive->roamingConfig.reconnectLimit */
+ bufferSize += 2; /* u16 primitive->roamingConfig.reconnectLimitIntervalMs */
+ {
+ u16 i2;
+ for (i2 = 0; i2 < 3; i2++)
+ {
+ bufferSize += 2; /* u16 primitive->roamingConfig.roamScanCfg[i2].intervalSeconds */
+ bufferSize += 2; /* u16 primitive->roamingConfig.roamScanCfg[i2].validitySeconds */
+ bufferSize += 2; /* u16 primitive->roamingConfig.roamScanCfg[i2].minActiveChannelTimeTu */
+ bufferSize += 2; /* u16 primitive->roamingConfig.roamScanCfg[i2].maxActiveChannelTimeTu */
+ bufferSize += 2; /* u16 primitive->roamingConfig.roamScanCfg[i2].minPassiveChannelTimeTu */
+ bufferSize += 2; /* u16 primitive->roamingConfig.roamScanCfg[i2].maxPassiveChannelTimeTu */
+ }
+ }
+ return bufferSize;
+}
+
+
+u8* CsrWifiSmeRoamingConfigGetCfmSer(u8 *ptr, size_t *len, void *msg)
+{
+ CsrWifiSmeRoamingConfigGetCfm *primitive = (CsrWifiSmeRoamingConfigGetCfm *)msg;
+ *len = 0;
+ CsrUint16Ser(ptr, len, primitive->common.type);
+ CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
+ CsrUint16Ser(ptr, len, (u16) primitive->status);
+ {
+ u16 i2;
+ for (i2 = 0; i2 < 3; i2++)
+ {
+ CsrUint16Ser(ptr, len, (u16) primitive->roamingConfig.roamingBands[i2].rssiHighThreshold);
+ CsrUint16Ser(ptr, len, (u16) primitive->roamingConfig.roamingBands[i2].rssiLowThreshold);
+ CsrUint16Ser(ptr, len, (u16) primitive->roamingConfig.roamingBands[i2].snrHighThreshold);
+ CsrUint16Ser(ptr, len, (u16) primitive->roamingConfig.roamingBands[i2].snrLowThreshold);
+ }
+ }
+ CsrUint8Ser(ptr, len, (u8) primitive->roamingConfig.disableSmoothRoaming);
+ CsrUint8Ser(ptr, len, (u8) primitive->roamingConfig.disableRoamScans);
+ CsrUint8Ser(ptr, len, (u8) primitive->roamingConfig.reconnectLimit);
+ CsrUint16Ser(ptr, len, (u16) primitive->roamingConfig.reconnectLimitIntervalMs);
+ {
+ u16 i2;
+ for (i2 = 0; i2 < 3; i2++)
+ {
+ CsrUint16Ser(ptr, len, (u16) primitive->roamingConfig.roamScanCfg[i2].intervalSeconds);
+ CsrUint16Ser(ptr, len, (u16) primitive->roamingConfig.roamScanCfg[i2].validitySeconds);
+ CsrUint16Ser(ptr, len, (u16) primitive->roamingConfig.roamScanCfg[i2].minActiveChannelTimeTu);
+ CsrUint16Ser(ptr, len, (u16) primitive->roamingConfig.roamScanCfg[i2].maxActiveChannelTimeTu);
+ CsrUint16Ser(ptr, len, (u16) primitive->roamingConfig.roamScanCfg[i2].minPassiveChannelTimeTu);
+ CsrUint16Ser(ptr, len, (u16) primitive->roamingConfig.roamScanCfg[i2].maxPassiveChannelTimeTu);
+ }
+ }
+ return(ptr);
+}
+
+
+void* CsrWifiSmeRoamingConfigGetCfmDes(u8 *buffer, size_t length)
+{
+ CsrWifiSmeRoamingConfigGetCfm *primitive = kmalloc(sizeof(CsrWifiSmeRoamingConfigGetCfm), GFP_KERNEL);
+ size_t offset;
+ offset = 0;
+
+ CsrUint16Des(&primitive->common.type, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
+ {
+ u16 i2;
+ for (i2 = 0; i2 < 3; i2++)
+ {
+ CsrUint16Des((u16 *) &primitive->roamingConfig.roamingBands[i2].rssiHighThreshold, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->roamingConfig.roamingBands[i2].rssiLowThreshold, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->roamingConfig.roamingBands[i2].snrHighThreshold, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->roamingConfig.roamingBands[i2].snrLowThreshold, buffer, &offset);
+ }
+ }
+ CsrUint8Des((u8 *) &primitive->roamingConfig.disableSmoothRoaming, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->roamingConfig.disableRoamScans, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->roamingConfig.reconnectLimit, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->roamingConfig.reconnectLimitIntervalMs, buffer, &offset);
+ {
+ u16 i2;
+ for (i2 = 0; i2 < 3; i2++)
+ {
+ CsrUint16Des((u16 *) &primitive->roamingConfig.roamScanCfg[i2].intervalSeconds, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->roamingConfig.roamScanCfg[i2].validitySeconds, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->roamingConfig.roamScanCfg[i2].minActiveChannelTimeTu, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->roamingConfig.roamScanCfg[i2].maxActiveChannelTimeTu, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->roamingConfig.roamScanCfg[i2].minPassiveChannelTimeTu, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->roamingConfig.roamScanCfg[i2].maxPassiveChannelTimeTu, buffer, &offset);
+ }
+ }
+
+ return primitive;
+}
+
+
+size_t CsrWifiSmeRoamingConfigSetCfmSizeof(void *msg)
+{
+ size_t bufferSize = 2;
+
+ /* Calculate the Size of the Serialised Data. Could be more efficient (Try 7) */
+ bufferSize += 2; /* u16 primitive->interfaceTag */
+ bufferSize += 2; /* CsrResult primitive->status */
+ return bufferSize;
+}
+
+
+u8* CsrWifiSmeRoamingConfigSetCfmSer(u8 *ptr, size_t *len, void *msg)
+{
+ CsrWifiSmeRoamingConfigSetCfm *primitive = (CsrWifiSmeRoamingConfigSetCfm *)msg;
+ *len = 0;
+ CsrUint16Ser(ptr, len, primitive->common.type);
+ CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
+ CsrUint16Ser(ptr, len, (u16) primitive->status);
+ return(ptr);
+}
+
+
+void* CsrWifiSmeRoamingConfigSetCfmDes(u8 *buffer, size_t length)
+{
+ CsrWifiSmeRoamingConfigSetCfm *primitive = kmalloc(sizeof(CsrWifiSmeRoamingConfigSetCfm), GFP_KERNEL);
+ size_t offset;
+ offset = 0;
+
+ CsrUint16Des(&primitive->common.type, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
+
+ return primitive;
+}
+
+
+size_t CsrWifiSmeScanConfigGetCfmSizeof(void *msg)
+{
+ CsrWifiSmeScanConfigGetCfm *primitive = (CsrWifiSmeScanConfigGetCfm *) msg;
+ size_t bufferSize = 2;
+
+ /* Calculate the Size of the Serialised Data. Could be more efficient (Try 65) */
+ bufferSize += 2; /* CsrResult primitive->status */
+ {
+ u16 i2;
+ for (i2 = 0; i2 < 4; i2++)
+ {
+ bufferSize += 2; /* u16 primitive->scanConfig.scanCfg[i2].intervalSeconds */
+ bufferSize += 2; /* u16 primitive->scanConfig.scanCfg[i2].validitySeconds */
+ bufferSize += 2; /* u16 primitive->scanConfig.scanCfg[i2].minActiveChannelTimeTu */
+ bufferSize += 2; /* u16 primitive->scanConfig.scanCfg[i2].maxActiveChannelTimeTu */
+ bufferSize += 2; /* u16 primitive->scanConfig.scanCfg[i2].minPassiveChannelTimeTu */
+ bufferSize += 2; /* u16 primitive->scanConfig.scanCfg[i2].maxPassiveChannelTimeTu */
+ }
+ }
+ bufferSize += 1; /* u8 primitive->scanConfig.disableAutonomousScans */
+ bufferSize += 2; /* u16 primitive->scanConfig.maxResults */
+ bufferSize += 1; /* s8 primitive->scanConfig.highRssiThreshold */
+ bufferSize += 1; /* s8 primitive->scanConfig.lowRssiThreshold */
+ bufferSize += 1; /* s8 primitive->scanConfig.deltaRssiThreshold */
+ bufferSize += 1; /* s8 primitive->scanConfig.highSnrThreshold */
+ bufferSize += 1; /* s8 primitive->scanConfig.lowSnrThreshold */
+ bufferSize += 1; /* s8 primitive->scanConfig.deltaSnrThreshold */
+ bufferSize += 2; /* u16 primitive->scanConfig.passiveChannelListCount */
+ bufferSize += primitive->scanConfig.passiveChannelListCount; /* u8 primitive->scanConfig.passiveChannelList */
+ return bufferSize;
+}
+
+
+u8* CsrWifiSmeScanConfigGetCfmSer(u8 *ptr, size_t *len, void *msg)
+{
+ CsrWifiSmeScanConfigGetCfm *primitive = (CsrWifiSmeScanConfigGetCfm *)msg;
+ *len = 0;
+ CsrUint16Ser(ptr, len, primitive->common.type);
+ CsrUint16Ser(ptr, len, (u16) primitive->status);
+ {
+ u16 i2;
+ for (i2 = 0; i2 < 4; i2++)
+ {
+ CsrUint16Ser(ptr, len, (u16) primitive->scanConfig.scanCfg[i2].intervalSeconds);
+ CsrUint16Ser(ptr, len, (u16) primitive->scanConfig.scanCfg[i2].validitySeconds);
+ CsrUint16Ser(ptr, len, (u16) primitive->scanConfig.scanCfg[i2].minActiveChannelTimeTu);
+ CsrUint16Ser(ptr, len, (u16) primitive->scanConfig.scanCfg[i2].maxActiveChannelTimeTu);
+ CsrUint16Ser(ptr, len, (u16) primitive->scanConfig.scanCfg[i2].minPassiveChannelTimeTu);
+ CsrUint16Ser(ptr, len, (u16) primitive->scanConfig.scanCfg[i2].maxPassiveChannelTimeTu);
+ }
+ }
+ CsrUint8Ser(ptr, len, (u8) primitive->scanConfig.disableAutonomousScans);
+ CsrUint16Ser(ptr, len, (u16) primitive->scanConfig.maxResults);
+ CsrUint8Ser(ptr, len, (u8) primitive->scanConfig.highRssiThreshold);
+ CsrUint8Ser(ptr, len, (u8) primitive->scanConfig.lowRssiThreshold);
+ CsrUint8Ser(ptr, len, (u8) primitive->scanConfig.deltaRssiThreshold);
+ CsrUint8Ser(ptr, len, (u8) primitive->scanConfig.highSnrThreshold);
+ CsrUint8Ser(ptr, len, (u8) primitive->scanConfig.lowSnrThreshold);
+ CsrUint8Ser(ptr, len, (u8) primitive->scanConfig.deltaSnrThreshold);
+ CsrUint16Ser(ptr, len, (u16) primitive->scanConfig.passiveChannelListCount);
+ if (primitive->scanConfig.passiveChannelListCount)
+ {
+ CsrMemCpySer(ptr, len, (const void *) primitive->scanConfig.passiveChannelList, ((u16) (primitive->scanConfig.passiveChannelListCount)));
+ }
+ return(ptr);
+}
+
+
+void* CsrWifiSmeScanConfigGetCfmDes(u8 *buffer, size_t length)
+{
+ CsrWifiSmeScanConfigGetCfm *primitive = kmalloc(sizeof(CsrWifiSmeScanConfigGetCfm), GFP_KERNEL);
+ size_t offset;
+ offset = 0;
+
+ CsrUint16Des(&primitive->common.type, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
+ {
+ u16 i2;
+ for (i2 = 0; i2 < 4; i2++)
+ {
+ CsrUint16Des((u16 *) &primitive->scanConfig.scanCfg[i2].intervalSeconds, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->scanConfig.scanCfg[i2].validitySeconds, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->scanConfig.scanCfg[i2].minActiveChannelTimeTu, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->scanConfig.scanCfg[i2].maxActiveChannelTimeTu, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->scanConfig.scanCfg[i2].minPassiveChannelTimeTu, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->scanConfig.scanCfg[i2].maxPassiveChannelTimeTu, buffer, &offset);
+ }
+ }
+ CsrUint8Des((u8 *) &primitive->scanConfig.disableAutonomousScans, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->scanConfig.maxResults, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->scanConfig.highRssiThreshold, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->scanConfig.lowRssiThreshold, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->scanConfig.deltaRssiThreshold, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->scanConfig.highSnrThreshold, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->scanConfig.lowSnrThreshold, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->scanConfig.deltaSnrThreshold, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->scanConfig.passiveChannelListCount, buffer, &offset);
+ if (primitive->scanConfig.passiveChannelListCount)
+ {
+ primitive->scanConfig.passiveChannelList = kmalloc(primitive->scanConfig.passiveChannelListCount, GFP_KERNEL);
+ CsrMemCpyDes(primitive->scanConfig.passiveChannelList, buffer, &offset, ((u16) (primitive->scanConfig.passiveChannelListCount)));
+ }
+ else
+ {
+ primitive->scanConfig.passiveChannelList = NULL;
+ }
+
+ return primitive;
+}
+
+
+void CsrWifiSmeScanConfigGetCfmSerFree(void *voidPrimitivePointer)
+{
+ CsrWifiSmeScanConfigGetCfm *primitive = (CsrWifiSmeScanConfigGetCfm *) voidPrimitivePointer;
+ kfree(primitive->scanConfig.passiveChannelList);
+ kfree(primitive);
+}
+
+
+size_t CsrWifiSmeScanResultIndSizeof(void *msg)
+{
+ CsrWifiSmeScanResultInd *primitive = (CsrWifiSmeScanResultInd *) msg;
+ size_t bufferSize = 2;
+
+ /* Calculate the Size of the Serialised Data. Could be more efficient (Try 149) */
+ bufferSize += 32; /* u8 primitive->result.ssid.ssid[32] */
+ bufferSize += 1; /* u8 primitive->result.ssid.length */
+ bufferSize += 6; /* u8 primitive->result.bssid.a[6] */
+ bufferSize += 2; /* s16 primitive->result.rssi */
+ bufferSize += 2; /* s16 primitive->result.snr */
+ bufferSize += 1; /* CsrWifiSmeRadioIF primitive->result.ifIndex */
+ bufferSize += 2; /* u16 primitive->result.beaconPeriodTu */
+ bufferSize += 8; /* u8 primitive->result.timeStamp.data[8] */
+ bufferSize += 8; /* u8 primitive->result.localTime.data[8] */
+ bufferSize += 2; /* u16 primitive->result.channelFrequency */
+ bufferSize += 2; /* u16 primitive->result.capabilityInformation */
+ bufferSize += 1; /* u8 primitive->result.channelNumber */
+ bufferSize += 1; /* CsrWifiSmeBasicUsability primitive->result.usability */
+ bufferSize += 1; /* CsrWifiSmeBssType primitive->result.bssType */
+ bufferSize += 2; /* u16 primitive->result.informationElementsLength */
+ bufferSize += primitive->result.informationElementsLength; /* u8 primitive->result.informationElements */
+ bufferSize += 1; /* CsrWifiSmeP2pRole primitive->result.p2pDeviceRole */
+ switch (primitive->result.p2pDeviceRole)
+ {
+ case CSR_WIFI_SME_P2P_ROLE_CLI:
+ bufferSize += 1; /* u8 primitive->result.deviceInfo.reservedCli.empty */
+ break;
+ case CSR_WIFI_SME_P2P_ROLE_GO:
+ bufferSize += 1; /* CsrWifiSmeP2pGroupCapabilityMask primitive->result.deviceInfo.groupInfo.groupCapability */
+ bufferSize += 6; /* u8 primitive->result.deviceInfo.groupInfo.p2pDeviceAddress.a[6] */
+ bufferSize += 1; /* u8 primitive->result.deviceInfo.groupInfo.p2pClientInfoCount */
+ {
+ u16 i4;
+ for (i4 = 0; i4 < primitive->result.deviceInfo.groupInfo.p2pClientInfoCount; i4++)
+ {
+ bufferSize += 6; /* u8 primitive->result.deviceInfo.groupInfo.p2PClientInfo[i4].p2PClientInterfaceAddress.a[6] */
+ bufferSize += 6; /* u8 primitive->result.deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.deviceAddress.a[6] */
+ bufferSize += 2; /* CsrWifiSmeWpsConfigTypeMask primitive->result.deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.configMethods */
+ bufferSize += 1; /* CsrWifiSmeP2pCapabilityMask primitive->result.deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.p2PDeviceCap */
+ bufferSize += 8; /* u8 primitive->result.deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.primDeviceType.deviceDetails[8] */
+ bufferSize += 1; /* u8 primitive->result.deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.secondaryDeviceTypeCount */
+ {
+ u16 i6;
+ for (i6 = 0; i6 < primitive->result.deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.secondaryDeviceTypeCount; i6++)
+ {
+ bufferSize += 8; /* u8 primitive->result.deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.secDeviceType[i6].deviceDetails[8] */
+ }
+ }
+ bufferSize += 32; /* u8 primitive->result.deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.deviceName[32] */
+ bufferSize += 1; /* u8 primitive->result.deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.deviceNameLength */
+ }
+ }
+ break;
+ case CSR_WIFI_SME_P2P_ROLE_NONE:
+ bufferSize += 1; /* u8 primitive->result.deviceInfo.reservedNone.empty */
+ break;
+ case CSR_WIFI_SME_P2P_ROLE_STANDALONE:
+ bufferSize += 6; /* u8 primitive->result.deviceInfo.standalonedevInfo.deviceAddress.a[6] */
+ bufferSize += 2; /* CsrWifiSmeWpsConfigTypeMask primitive->result.deviceInfo.standalonedevInfo.configMethods */
+ bufferSize += 1; /* CsrWifiSmeP2pCapabilityMask primitive->result.deviceInfo.standalonedevInfo.p2PDeviceCap */
+ bufferSize += 8; /* u8 primitive->result.deviceInfo.standalonedevInfo.primDeviceType.deviceDetails[8] */
+ bufferSize += 1; /* u8 primitive->result.deviceInfo.standalonedevInfo.secondaryDeviceTypeCount */
+ {
+ u16 i4;
+ for (i4 = 0; i4 < primitive->result.deviceInfo.standalonedevInfo.secondaryDeviceTypeCount; i4++)
+ {
+ bufferSize += 8; /* u8 primitive->result.deviceInfo.standalonedevInfo.secDeviceType[i4].deviceDetails[8] */
+ }
+ }
+ bufferSize += 32; /* u8 primitive->result.deviceInfo.standalonedevInfo.deviceName[32] */
+ bufferSize += 1; /* u8 primitive->result.deviceInfo.standalonedevInfo.deviceNameLength */
+ break;
+ default:
+ break;
+ }
+ return bufferSize;
+}
+
+
+u8* CsrWifiSmeScanResultIndSer(u8 *ptr, size_t *len, void *msg)
+{
+ CsrWifiSmeScanResultInd *primitive = (CsrWifiSmeScanResultInd *)msg;
+ *len = 0;
+ CsrUint16Ser(ptr, len, primitive->common.type);
+ CsrMemCpySer(ptr, len, (const void *) primitive->result.ssid.ssid, ((u16) (32)));
+ CsrUint8Ser(ptr, len, (u8) primitive->result.ssid.length);
+ CsrMemCpySer(ptr, len, (const void *) primitive->result.bssid.a, ((u16) (6)));
+ CsrUint16Ser(ptr, len, (u16) primitive->result.rssi);
+ CsrUint16Ser(ptr, len, (u16) primitive->result.snr);
+ CsrUint8Ser(ptr, len, (u8) primitive->result.ifIndex);
+ CsrUint16Ser(ptr, len, (u16) primitive->result.beaconPeriodTu);
+ CsrMemCpySer(ptr, len, (const void *) primitive->result.timeStamp.data, ((u16) (8)));
+ CsrMemCpySer(ptr, len, (const void *) primitive->result.localTime.data, ((u16) (8)));
+ CsrUint16Ser(ptr, len, (u16) primitive->result.channelFrequency);
+ CsrUint16Ser(ptr, len, (u16) primitive->result.capabilityInformation);
+ CsrUint8Ser(ptr, len, (u8) primitive->result.channelNumber);
+ CsrUint8Ser(ptr, len, (u8) primitive->result.usability);
+ CsrUint8Ser(ptr, len, (u8) primitive->result.bssType);
+ CsrUint16Ser(ptr, len, (u16) primitive->result.informationElementsLength);
+ if (primitive->result.informationElementsLength)
+ {
+ CsrMemCpySer(ptr, len, (const void *) primitive->result.informationElements, ((u16) (primitive->result.informationElementsLength)));
+ }
+ CsrUint8Ser(ptr, len, (u8) primitive->result.p2pDeviceRole);
+ switch (primitive->result.p2pDeviceRole)
+ {
+ case CSR_WIFI_SME_P2P_ROLE_CLI:
+ CsrUint8Ser(ptr, len, (u8) primitive->result.deviceInfo.reservedCli.empty);
+ break;
+ case CSR_WIFI_SME_P2P_ROLE_GO:
+ CsrUint8Ser(ptr, len, (u8) primitive->result.deviceInfo.groupInfo.groupCapability);
+ CsrMemCpySer(ptr, len, (const void *) primitive->result.deviceInfo.groupInfo.p2pDeviceAddress.a, ((u16) (6)));
+ CsrUint8Ser(ptr, len, (u8) primitive->result.deviceInfo.groupInfo.p2pClientInfoCount);
+ {
+ u16 i4;
+ for (i4 = 0; i4 < primitive->result.deviceInfo.groupInfo.p2pClientInfoCount; i4++)
+ {
+ CsrMemCpySer(ptr, len, (const void *) primitive->result.deviceInfo.groupInfo.p2PClientInfo[i4].p2PClientInterfaceAddress.a, ((u16) (6)));
+ CsrMemCpySer(ptr, len, (const void *) primitive->result.deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.deviceAddress.a, ((u16) (6)));
+ CsrUint16Ser(ptr, len, (u16) primitive->result.deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.configMethods);
+ CsrUint8Ser(ptr, len, (u8) primitive->result.deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.p2PDeviceCap);
+ CsrMemCpySer(ptr, len, (const void *) primitive->result.deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.primDeviceType.deviceDetails, ((u16) (8)));
+ CsrUint8Ser(ptr, len, (u8) primitive->result.deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.secondaryDeviceTypeCount);
+ {
+ u16 i6;
+ for (i6 = 0; i6 < primitive->result.deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.secondaryDeviceTypeCount; i6++)
+ {
+ CsrMemCpySer(ptr, len, (const void *) primitive->result.deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.secDeviceType[i6].deviceDetails, ((u16) (8)));
+ }
+ }
+ CsrMemCpySer(ptr, len, (const void *) primitive->result.deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.deviceName, ((u16) (32)));
+ CsrUint8Ser(ptr, len, (u8) primitive->result.deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.deviceNameLength);
+ }
+ }
+ break;
+ case CSR_WIFI_SME_P2P_ROLE_NONE:
+ CsrUint8Ser(ptr, len, (u8) primitive->result.deviceInfo.reservedNone.empty);
+ break;
+ case CSR_WIFI_SME_P2P_ROLE_STANDALONE:
+ CsrMemCpySer(ptr, len, (const void *) primitive->result.deviceInfo.standalonedevInfo.deviceAddress.a, ((u16) (6)));
+ CsrUint16Ser(ptr, len, (u16) primitive->result.deviceInfo.standalonedevInfo.configMethods);
+ CsrUint8Ser(ptr, len, (u8) primitive->result.deviceInfo.standalonedevInfo.p2PDeviceCap);
+ CsrMemCpySer(ptr, len, (const void *) primitive->result.deviceInfo.standalonedevInfo.primDeviceType.deviceDetails, ((u16) (8)));
+ CsrUint8Ser(ptr, len, (u8) primitive->result.deviceInfo.standalonedevInfo.secondaryDeviceTypeCount);
+ {
+ u16 i4;
+ for (i4 = 0; i4 < primitive->result.deviceInfo.standalonedevInfo.secondaryDeviceTypeCount; i4++)
+ {
+ CsrMemCpySer(ptr, len, (const void *) primitive->result.deviceInfo.standalonedevInfo.secDeviceType[i4].deviceDetails, ((u16) (8)));
+ }
+ }
+ CsrMemCpySer(ptr, len, (const void *) primitive->result.deviceInfo.standalonedevInfo.deviceName, ((u16) (32)));
+ CsrUint8Ser(ptr, len, (u8) primitive->result.deviceInfo.standalonedevInfo.deviceNameLength);
+ break;
+ default:
+ break;
+ }
+ return(ptr);
+}
+
+
+void* CsrWifiSmeScanResultIndDes(u8 *buffer, size_t length)
+{
+ CsrWifiSmeScanResultInd *primitive = kmalloc(sizeof(CsrWifiSmeScanResultInd), GFP_KERNEL);
+ size_t offset;
+ offset = 0;
+
+ CsrUint16Des(&primitive->common.type, buffer, &offset);
+ CsrMemCpyDes(primitive->result.ssid.ssid, buffer, &offset, ((u16) (32)));
+ CsrUint8Des((u8 *) &primitive->result.ssid.length, buffer, &offset);
+ CsrMemCpyDes(primitive->result.bssid.a, buffer, &offset, ((u16) (6)));
+ CsrUint16Des((u16 *) &primitive->result.rssi, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->result.snr, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->result.ifIndex, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->result.beaconPeriodTu, buffer, &offset);
+ CsrMemCpyDes(primitive->result.timeStamp.data, buffer, &offset, ((u16) (8)));
+ CsrMemCpyDes(primitive->result.localTime.data, buffer, &offset, ((u16) (8)));
+ CsrUint16Des((u16 *) &primitive->result.channelFrequency, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->result.capabilityInformation, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->result.channelNumber, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->result.usability, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->result.bssType, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->result.informationElementsLength, buffer, &offset);
+ if (primitive->result.informationElementsLength)
+ {
+ primitive->result.informationElements = kmalloc(primitive->result.informationElementsLength, GFP_KERNEL);
+ CsrMemCpyDes(primitive->result.informationElements, buffer, &offset, ((u16) (primitive->result.informationElementsLength)));
+ }
+ else
+ {
+ primitive->result.informationElements = NULL;
+ }
+ CsrUint8Des((u8 *) &primitive->result.p2pDeviceRole, buffer, &offset);
+ switch (primitive->result.p2pDeviceRole)
+ {
+ case CSR_WIFI_SME_P2P_ROLE_CLI:
+ CsrUint8Des((u8 *) &primitive->result.deviceInfo.reservedCli.empty, buffer, &offset);
+ break;
+ case CSR_WIFI_SME_P2P_ROLE_GO:
+ CsrUint8Des((u8 *) &primitive->result.deviceInfo.groupInfo.groupCapability, buffer, &offset);
+ CsrMemCpyDes(primitive->result.deviceInfo.groupInfo.p2pDeviceAddress.a, buffer, &offset, ((u16) (6)));
+ CsrUint8Des((u8 *) &primitive->result.deviceInfo.groupInfo.p2pClientInfoCount, buffer, &offset);
+ primitive->result.deviceInfo.groupInfo.p2PClientInfo = NULL;
+ if (primitive->result.deviceInfo.groupInfo.p2pClientInfoCount)
+ {
+ primitive->result.deviceInfo.groupInfo.p2PClientInfo = kmalloc(sizeof(CsrWifiSmeP2pClientInfoType) * primitive->result.deviceInfo.groupInfo.p2pClientInfoCount, GFP_KERNEL);
+ }
+ {
+ u16 i4;
+ for (i4 = 0; i4 < primitive->result.deviceInfo.groupInfo.p2pClientInfoCount; i4++)
+ {
+ CsrMemCpyDes(primitive->result.deviceInfo.groupInfo.p2PClientInfo[i4].p2PClientInterfaceAddress.a, buffer, &offset, ((u16) (6)));
+ CsrMemCpyDes(primitive->result.deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.deviceAddress.a, buffer, &offset, ((u16) (6)));
+ CsrUint16Des((u16 *) &primitive->result.deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.configMethods, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->result.deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.p2PDeviceCap, buffer, &offset);
+ CsrMemCpyDes(primitive->result.deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.primDeviceType.deviceDetails, buffer, &offset, ((u16) (8)));
+ CsrUint8Des((u8 *) &primitive->result.deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.secondaryDeviceTypeCount, buffer, &offset);
+ primitive->result.deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.secDeviceType = NULL;
+ if (primitive->result.deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.secondaryDeviceTypeCount)
+ {
+ primitive->result.deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.secDeviceType = kmalloc(sizeof(CsrWifiSmeWpsDeviceType) * primitive->result.deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.secondaryDeviceTypeCount, GFP_KERNEL);
+ }
+ {
+ u16 i6;
+ for (i6 = 0; i6 < primitive->result.deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.secondaryDeviceTypeCount; i6++)
+ {
+ CsrMemCpyDes(primitive->result.deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.secDeviceType[i6].deviceDetails, buffer, &offset, ((u16) (8)));
+ }
+ }
+ CsrMemCpyDes(primitive->result.deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.deviceName, buffer, &offset, ((u16) (32)));
+ CsrUint8Des((u8 *) &primitive->result.deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.deviceNameLength, buffer, &offset);
+ }
+ }
+ break;
+ case CSR_WIFI_SME_P2P_ROLE_NONE:
+ CsrUint8Des((u8 *) &primitive->result.deviceInfo.reservedNone.empty, buffer, &offset);
+ break;
+ case CSR_WIFI_SME_P2P_ROLE_STANDALONE:
+ CsrMemCpyDes(primitive->result.deviceInfo.standalonedevInfo.deviceAddress.a, buffer, &offset, ((u16) (6)));
+ CsrUint16Des((u16 *) &primitive->result.deviceInfo.standalonedevInfo.configMethods, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->result.deviceInfo.standalonedevInfo.p2PDeviceCap, buffer, &offset);
+ CsrMemCpyDes(primitive->result.deviceInfo.standalonedevInfo.primDeviceType.deviceDetails, buffer, &offset, ((u16) (8)));
+ CsrUint8Des((u8 *) &primitive->result.deviceInfo.standalonedevInfo.secondaryDeviceTypeCount, buffer, &offset);
+ primitive->result.deviceInfo.standalonedevInfo.secDeviceType = NULL;
+ if (primitive->result.deviceInfo.standalonedevInfo.secondaryDeviceTypeCount)
+ {
+ primitive->result.deviceInfo.standalonedevInfo.secDeviceType = kmalloc(sizeof(CsrWifiSmeWpsDeviceType) * primitive->result.deviceInfo.standalonedevInfo.secondaryDeviceTypeCount, GFP_KERNEL);
+ }
+ {
+ u16 i4;
+ for (i4 = 0; i4 < primitive->result.deviceInfo.standalonedevInfo.secondaryDeviceTypeCount; i4++)
+ {
+ CsrMemCpyDes(primitive->result.deviceInfo.standalonedevInfo.secDeviceType[i4].deviceDetails, buffer, &offset, ((u16) (8)));
+ }
+ }
+ CsrMemCpyDes(primitive->result.deviceInfo.standalonedevInfo.deviceName, buffer, &offset, ((u16) (32)));
+ CsrUint8Des((u8 *) &primitive->result.deviceInfo.standalonedevInfo.deviceNameLength, buffer, &offset);
+ break;
+ default:
+ break;
+ }
+
+ return primitive;
+}
+
+
+void CsrWifiSmeScanResultIndSerFree(void *voidPrimitivePointer)
+{
+ CsrWifiSmeScanResultInd *primitive = (CsrWifiSmeScanResultInd *) voidPrimitivePointer;
+ kfree(primitive->result.informationElements);
+ switch (primitive->result.p2pDeviceRole)
+ {
+ case CSR_WIFI_SME_P2P_ROLE_GO:
+ {
+ u16 i4;
+ for (i4 = 0; i4 < primitive->result.deviceInfo.groupInfo.p2pClientInfoCount; i4++)
+ {
+ kfree(primitive->result.deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.secDeviceType);
+ }
+ }
+ kfree(primitive->result.deviceInfo.groupInfo.p2PClientInfo);
+ break;
+ case CSR_WIFI_SME_P2P_ROLE_STANDALONE:
+ kfree(primitive->result.deviceInfo.standalonedevInfo.secDeviceType);
+ break;
+ default:
+ break;
+ }
+ kfree(primitive);
+}
+
+
+size_t CsrWifiSmeScanResultsGetCfmSizeof(void *msg)
+{
+ CsrWifiSmeScanResultsGetCfm *primitive = (CsrWifiSmeScanResultsGetCfm *) msg;
+ size_t bufferSize = 2;
+
+ /* Calculate the Size of the Serialised Data. Could be more efficient (Try 153) */
+ bufferSize += 2; /* CsrResult primitive->status */
+ bufferSize += 2; /* u16 primitive->scanResultsCount */
+ {
+ u16 i1;
+ for (i1 = 0; i1 < primitive->scanResultsCount; i1++)
+ {
+ bufferSize += 32; /* u8 primitive->scanResults[i1].ssid.ssid[32] */
+ bufferSize += 1; /* u8 primitive->scanResults[i1].ssid.length */
+ bufferSize += 6; /* u8 primitive->scanResults[i1].bssid.a[6] */
+ bufferSize += 2; /* s16 primitive->scanResults[i1].rssi */
+ bufferSize += 2; /* s16 primitive->scanResults[i1].snr */
+ bufferSize += 1; /* CsrWifiSmeRadioIF primitive->scanResults[i1].ifIndex */
+ bufferSize += 2; /* u16 primitive->scanResults[i1].beaconPeriodTu */
+ bufferSize += 8; /* u8 primitive->scanResults[i1].timeStamp.data[8] */
+ bufferSize += 8; /* u8 primitive->scanResults[i1].localTime.data[8] */
+ bufferSize += 2; /* u16 primitive->scanResults[i1].channelFrequency */
+ bufferSize += 2; /* u16 primitive->scanResults[i1].capabilityInformation */
+ bufferSize += 1; /* u8 primitive->scanResults[i1].channelNumber */
+ bufferSize += 1; /* CsrWifiSmeBasicUsability primitive->scanResults[i1].usability */
+ bufferSize += 1; /* CsrWifiSmeBssType primitive->scanResults[i1].bssType */
+ bufferSize += 2; /* u16 primitive->scanResults[i1].informationElementsLength */
+ bufferSize += primitive->scanResults[i1].informationElementsLength; /* u8 primitive->scanResults[i1].informationElements */
+ bufferSize += 1; /* CsrWifiSmeP2pRole primitive->scanResults[i1].p2pDeviceRole */
+ switch (primitive->scanResults[i1].p2pDeviceRole)
+ {
+ case CSR_WIFI_SME_P2P_ROLE_CLI:
+ bufferSize += 1; /* u8 primitive->scanResults[i1].deviceInfo.reservedCli.empty */
+ break;
+ case CSR_WIFI_SME_P2P_ROLE_GO:
+ bufferSize += 1; /* CsrWifiSmeP2pGroupCapabilityMask primitive->scanResults[i1].deviceInfo.groupInfo.groupCapability */
+ bufferSize += 6; /* u8 primitive->scanResults[i1].deviceInfo.groupInfo.p2pDeviceAddress.a[6] */
+ bufferSize += 1; /* u8 primitive->scanResults[i1].deviceInfo.groupInfo.p2pClientInfoCount */
+ {
+ u16 i4;
+ for (i4 = 0; i4 < primitive->scanResults[i1].deviceInfo.groupInfo.p2pClientInfoCount; i4++)
+ {
+ bufferSize += 6; /* u8 primitive->scanResults[i1].deviceInfo.groupInfo.p2PClientInfo[i4].p2PClientInterfaceAddress.a[6] */
+ bufferSize += 6; /* u8 primitive->scanResults[i1].deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.deviceAddress.a[6] */
+ bufferSize += 2; /* CsrWifiSmeWpsConfigTypeMask primitive->scanResults[i1].deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.configMethods */
+ bufferSize += 1; /* CsrWifiSmeP2pCapabilityMask primitive->scanResults[i1].deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.p2PDeviceCap */
+ bufferSize += 8; /* u8 primitive->scanResults[i1].deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.primDeviceType.deviceDetails[8] */
+ bufferSize += 1; /* u8 primitive->scanResults[i1].deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.secondaryDeviceTypeCount */
+ {
+ u16 i6;
+ for (i6 = 0; i6 < primitive->scanResults[i1].deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.secondaryDeviceTypeCount; i6++)
+ {
+ bufferSize += 8; /* u8 primitive->scanResults[i1].deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.secDeviceType[i6].deviceDetails[8] */
+ }
+ }
+ bufferSize += 32; /* u8 primitive->scanResults[i1].deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.deviceName[32] */
+ bufferSize += 1; /* u8 primitive->scanResults[i1].deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.deviceNameLength */
+ }
+ }
+ break;
+ case CSR_WIFI_SME_P2P_ROLE_NONE:
+ bufferSize += 1; /* u8 primitive->scanResults[i1].deviceInfo.reservedNone.empty */
+ break;
+ case CSR_WIFI_SME_P2P_ROLE_STANDALONE:
+ bufferSize += 6; /* u8 primitive->scanResults[i1].deviceInfo.standalonedevInfo.deviceAddress.a[6] */
+ bufferSize += 2; /* CsrWifiSmeWpsConfigTypeMask primitive->scanResults[i1].deviceInfo.standalonedevInfo.configMethods */
+ bufferSize += 1; /* CsrWifiSmeP2pCapabilityMask primitive->scanResults[i1].deviceInfo.standalonedevInfo.p2PDeviceCap */
+ bufferSize += 8; /* u8 primitive->scanResults[i1].deviceInfo.standalonedevInfo.primDeviceType.deviceDetails[8] */
+ bufferSize += 1; /* u8 primitive->scanResults[i1].deviceInfo.standalonedevInfo.secondaryDeviceTypeCount */
+ {
+ u16 i4;
+ for (i4 = 0; i4 < primitive->scanResults[i1].deviceInfo.standalonedevInfo.secondaryDeviceTypeCount; i4++)
+ {
+ bufferSize += 8; /* u8 primitive->scanResults[i1].deviceInfo.standalonedevInfo.secDeviceType[i4].deviceDetails[8] */
+ }
+ }
+ bufferSize += 32; /* u8 primitive->scanResults[i1].deviceInfo.standalonedevInfo.deviceName[32] */
+ bufferSize += 1; /* u8 primitive->scanResults[i1].deviceInfo.standalonedevInfo.deviceNameLength */
+ break;
+ default:
+ break;
+ }
+ }
+ }
+ return bufferSize;
+}
+
+
+u8* CsrWifiSmeScanResultsGetCfmSer(u8 *ptr, size_t *len, void *msg)
+{
+ CsrWifiSmeScanResultsGetCfm *primitive = (CsrWifiSmeScanResultsGetCfm *)msg;
+ *len = 0;
+ CsrUint16Ser(ptr, len, primitive->common.type);
+ CsrUint16Ser(ptr, len, (u16) primitive->status);
+ CsrUint16Ser(ptr, len, (u16) primitive->scanResultsCount);
+ {
+ u16 i1;
+ for (i1 = 0; i1 < primitive->scanResultsCount; i1++)
+ {
+ CsrMemCpySer(ptr, len, (const void *) primitive->scanResults[i1].ssid.ssid, ((u16) (32)));
+ CsrUint8Ser(ptr, len, (u8) primitive->scanResults[i1].ssid.length);
+ CsrMemCpySer(ptr, len, (const void *) primitive->scanResults[i1].bssid.a, ((u16) (6)));
+ CsrUint16Ser(ptr, len, (u16) primitive->scanResults[i1].rssi);
+ CsrUint16Ser(ptr, len, (u16) primitive->scanResults[i1].snr);
+ CsrUint8Ser(ptr, len, (u8) primitive->scanResults[i1].ifIndex);
+ CsrUint16Ser(ptr, len, (u16) primitive->scanResults[i1].beaconPeriodTu);
+ CsrMemCpySer(ptr, len, (const void *) primitive->scanResults[i1].timeStamp.data, ((u16) (8)));
+ CsrMemCpySer(ptr, len, (const void *) primitive->scanResults[i1].localTime.data, ((u16) (8)));
+ CsrUint16Ser(ptr, len, (u16) primitive->scanResults[i1].channelFrequency);
+ CsrUint16Ser(ptr, len, (u16) primitive->scanResults[i1].capabilityInformation);
+ CsrUint8Ser(ptr, len, (u8) primitive->scanResults[i1].channelNumber);
+ CsrUint8Ser(ptr, len, (u8) primitive->scanResults[i1].usability);
+ CsrUint8Ser(ptr, len, (u8) primitive->scanResults[i1].bssType);
+ CsrUint16Ser(ptr, len, (u16) primitive->scanResults[i1].informationElementsLength);
+ if (primitive->scanResults[i1].informationElementsLength)
+ {
+ CsrMemCpySer(ptr, len, (const void *) primitive->scanResults[i1].informationElements, ((u16) (primitive->scanResults[i1].informationElementsLength)));
+ }
+ CsrUint8Ser(ptr, len, (u8) primitive->scanResults[i1].p2pDeviceRole);
+ switch (primitive->scanResults[i1].p2pDeviceRole)
+ {
+ case CSR_WIFI_SME_P2P_ROLE_CLI:
+ CsrUint8Ser(ptr, len, (u8) primitive->scanResults[i1].deviceInfo.reservedCli.empty);
+ break;
+ case CSR_WIFI_SME_P2P_ROLE_GO:
+ CsrUint8Ser(ptr, len, (u8) primitive->scanResults[i1].deviceInfo.groupInfo.groupCapability);
+ CsrMemCpySer(ptr, len, (const void *) primitive->scanResults[i1].deviceInfo.groupInfo.p2pDeviceAddress.a, ((u16) (6)));
+ CsrUint8Ser(ptr, len, (u8) primitive->scanResults[i1].deviceInfo.groupInfo.p2pClientInfoCount);
+ {
+ u16 i4;
+ for (i4 = 0; i4 < primitive->scanResults[i1].deviceInfo.groupInfo.p2pClientInfoCount; i4++)
+ {
+ CsrMemCpySer(ptr, len, (const void *) primitive->scanResults[i1].deviceInfo.groupInfo.p2PClientInfo[i4].p2PClientInterfaceAddress.a, ((u16) (6)));
+ CsrMemCpySer(ptr, len, (const void *) primitive->scanResults[i1].deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.deviceAddress.a, ((u16) (6)));
+ CsrUint16Ser(ptr, len, (u16) primitive->scanResults[i1].deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.configMethods);
+ CsrUint8Ser(ptr, len, (u8) primitive->scanResults[i1].deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.p2PDeviceCap);
+ CsrMemCpySer(ptr, len, (const void *) primitive->scanResults[i1].deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.primDeviceType.deviceDetails, ((u16) (8)));
+ CsrUint8Ser(ptr, len, (u8) primitive->scanResults[i1].deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.secondaryDeviceTypeCount);
+ {
+ u16 i6;
+ for (i6 = 0; i6 < primitive->scanResults[i1].deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.secondaryDeviceTypeCount; i6++)
+ {
+ CsrMemCpySer(ptr, len, (const void *) primitive->scanResults[i1].deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.secDeviceType[i6].deviceDetails, ((u16) (8)));
+ }
+ }
+ CsrMemCpySer(ptr, len, (const void *) primitive->scanResults[i1].deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.deviceName, ((u16) (32)));
+ CsrUint8Ser(ptr, len, (u8) primitive->scanResults[i1].deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.deviceNameLength);
+ }
+ }
+ break;
+ case CSR_WIFI_SME_P2P_ROLE_NONE:
+ CsrUint8Ser(ptr, len, (u8) primitive->scanResults[i1].deviceInfo.reservedNone.empty);
+ break;
+ case CSR_WIFI_SME_P2P_ROLE_STANDALONE:
+ CsrMemCpySer(ptr, len, (const void *) primitive->scanResults[i1].deviceInfo.standalonedevInfo.deviceAddress.a, ((u16) (6)));
+ CsrUint16Ser(ptr, len, (u16) primitive->scanResults[i1].deviceInfo.standalonedevInfo.configMethods);
+ CsrUint8Ser(ptr, len, (u8) primitive->scanResults[i1].deviceInfo.standalonedevInfo.p2PDeviceCap);
+ CsrMemCpySer(ptr, len, (const void *) primitive->scanResults[i1].deviceInfo.standalonedevInfo.primDeviceType.deviceDetails, ((u16) (8)));
+ CsrUint8Ser(ptr, len, (u8) primitive->scanResults[i1].deviceInfo.standalonedevInfo.secondaryDeviceTypeCount);
+ {
+ u16 i4;
+ for (i4 = 0; i4 < primitive->scanResults[i1].deviceInfo.standalonedevInfo.secondaryDeviceTypeCount; i4++)
+ {
+ CsrMemCpySer(ptr, len, (const void *) primitive->scanResults[i1].deviceInfo.standalonedevInfo.secDeviceType[i4].deviceDetails, ((u16) (8)));
+ }
+ }
+ CsrMemCpySer(ptr, len, (const void *) primitive->scanResults[i1].deviceInfo.standalonedevInfo.deviceName, ((u16) (32)));
+ CsrUint8Ser(ptr, len, (u8) primitive->scanResults[i1].deviceInfo.standalonedevInfo.deviceNameLength);
+ break;
+ default:
+ break;
+ }
+ }
+ }
+ return(ptr);
+}
+
+
+void* CsrWifiSmeScanResultsGetCfmDes(u8 *buffer, size_t length)
+{
+ CsrWifiSmeScanResultsGetCfm *primitive = kmalloc(sizeof(CsrWifiSmeScanResultsGetCfm), GFP_KERNEL);
+ size_t offset;
+ offset = 0;
+
+ CsrUint16Des(&primitive->common.type, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->scanResultsCount, buffer, &offset);
+ primitive->scanResults = NULL;
+ if (primitive->scanResultsCount)
+ {
+ primitive->scanResults = kmalloc(sizeof(CsrWifiSmeScanResult) * primitive->scanResultsCount, GFP_KERNEL);
+ }
+ {
+ u16 i1;
+ for (i1 = 0; i1 < primitive->scanResultsCount; i1++)
+ {
+ CsrMemCpyDes(primitive->scanResults[i1].ssid.ssid, buffer, &offset, ((u16) (32)));
+ CsrUint8Des((u8 *) &primitive->scanResults[i1].ssid.length, buffer, &offset);
+ CsrMemCpyDes(primitive->scanResults[i1].bssid.a, buffer, &offset, ((u16) (6)));
+ CsrUint16Des((u16 *) &primitive->scanResults[i1].rssi, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->scanResults[i1].snr, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->scanResults[i1].ifIndex, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->scanResults[i1].beaconPeriodTu, buffer, &offset);
+ CsrMemCpyDes(primitive->scanResults[i1].timeStamp.data, buffer, &offset, ((u16) (8)));
+ CsrMemCpyDes(primitive->scanResults[i1].localTime.data, buffer, &offset, ((u16) (8)));
+ CsrUint16Des((u16 *) &primitive->scanResults[i1].channelFrequency, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->scanResults[i1].capabilityInformation, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->scanResults[i1].channelNumber, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->scanResults[i1].usability, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->scanResults[i1].bssType, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->scanResults[i1].informationElementsLength, buffer, &offset);
+ if (primitive->scanResults[i1].informationElementsLength)
+ {
+ primitive->scanResults[i1].informationElements = kmalloc(primitive->scanResults[i1].informationElementsLength, GFP_KERNEL);
+ CsrMemCpyDes(primitive->scanResults[i1].informationElements, buffer, &offset, ((u16) (primitive->scanResults[i1].informationElementsLength)));
+ }
+ else
+ {
+ primitive->scanResults[i1].informationElements = NULL;
+ }
+ CsrUint8Des((u8 *) &primitive->scanResults[i1].p2pDeviceRole, buffer, &offset);
+ switch (primitive->scanResults[i1].p2pDeviceRole)
+ {
+ case CSR_WIFI_SME_P2P_ROLE_CLI:
+ CsrUint8Des((u8 *) &primitive->scanResults[i1].deviceInfo.reservedCli.empty, buffer, &offset);
+ break;
+ case CSR_WIFI_SME_P2P_ROLE_GO:
+ CsrUint8Des((u8 *) &primitive->scanResults[i1].deviceInfo.groupInfo.groupCapability, buffer, &offset);
+ CsrMemCpyDes(primitive->scanResults[i1].deviceInfo.groupInfo.p2pDeviceAddress.a, buffer, &offset, ((u16) (6)));
+ CsrUint8Des((u8 *) &primitive->scanResults[i1].deviceInfo.groupInfo.p2pClientInfoCount, buffer, &offset);
+ primitive->scanResults[i1].deviceInfo.groupInfo.p2PClientInfo = NULL;
+ if (primitive->scanResults[i1].deviceInfo.groupInfo.p2pClientInfoCount)
+ {
+ primitive->scanResults[i1].deviceInfo.groupInfo.p2PClientInfo = kmalloc(sizeof(CsrWifiSmeP2pClientInfoType) * primitive->scanResults[i1].deviceInfo.groupInfo.p2pClientInfoCount, GFP_KERNEL);
+ }
+ {
+ u16 i4;
+ for (i4 = 0; i4 < primitive->scanResults[i1].deviceInfo.groupInfo.p2pClientInfoCount; i4++)
+ {
+ CsrMemCpyDes(primitive->scanResults[i1].deviceInfo.groupInfo.p2PClientInfo[i4].p2PClientInterfaceAddress.a, buffer, &offset, ((u16) (6)));
+ CsrMemCpyDes(primitive->scanResults[i1].deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.deviceAddress.a, buffer, &offset, ((u16) (6)));
+ CsrUint16Des((u16 *) &primitive->scanResults[i1].deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.configMethods, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->scanResults[i1].deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.p2PDeviceCap, buffer, &offset);
+ CsrMemCpyDes(primitive->scanResults[i1].deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.primDeviceType.deviceDetails, buffer, &offset, ((u16) (8)));
+ CsrUint8Des((u8 *) &primitive->scanResults[i1].deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.secondaryDeviceTypeCount, buffer, &offset);
+ primitive->scanResults[i1].deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.secDeviceType = NULL;
+ if (primitive->scanResults[i1].deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.secondaryDeviceTypeCount)
+ {
+ primitive->scanResults[i1].deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.secDeviceType = kmalloc(sizeof(CsrWifiSmeWpsDeviceType) * primitive->scanResults[i1].deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.secondaryDeviceTypeCount, GFP_KERNEL);
+ }
+ {
+ u16 i6;
+ for (i6 = 0; i6 < primitive->scanResults[i1].deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.secondaryDeviceTypeCount; i6++)
+ {
+ CsrMemCpyDes(primitive->scanResults[i1].deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.secDeviceType[i6].deviceDetails, buffer, &offset, ((u16) (8)));
+ }
+ }
+ CsrMemCpyDes(primitive->scanResults[i1].deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.deviceName, buffer, &offset, ((u16) (32)));
+ CsrUint8Des((u8 *) &primitive->scanResults[i1].deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.deviceNameLength, buffer, &offset);
+ }
+ }
+ break;
+ case CSR_WIFI_SME_P2P_ROLE_NONE:
+ CsrUint8Des((u8 *) &primitive->scanResults[i1].deviceInfo.reservedNone.empty, buffer, &offset);
+ break;
+ case CSR_WIFI_SME_P2P_ROLE_STANDALONE:
+ CsrMemCpyDes(primitive->scanResults[i1].deviceInfo.standalonedevInfo.deviceAddress.a, buffer, &offset, ((u16) (6)));
+ CsrUint16Des((u16 *) &primitive->scanResults[i1].deviceInfo.standalonedevInfo.configMethods, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->scanResults[i1].deviceInfo.standalonedevInfo.p2PDeviceCap, buffer, &offset);
+ CsrMemCpyDes(primitive->scanResults[i1].deviceInfo.standalonedevInfo.primDeviceType.deviceDetails, buffer, &offset, ((u16) (8)));
+ CsrUint8Des((u8 *) &primitive->scanResults[i1].deviceInfo.standalonedevInfo.secondaryDeviceTypeCount, buffer, &offset);
+ primitive->scanResults[i1].deviceInfo.standalonedevInfo.secDeviceType = NULL;
+ if (primitive->scanResults[i1].deviceInfo.standalonedevInfo.secondaryDeviceTypeCount)
+ {
+ primitive->scanResults[i1].deviceInfo.standalonedevInfo.secDeviceType = kmalloc(sizeof(CsrWifiSmeWpsDeviceType) * primitive->scanResults[i1].deviceInfo.standalonedevInfo.secondaryDeviceTypeCount, GFP_KERNEL);
+ }
+ {
+ u16 i4;
+ for (i4 = 0; i4 < primitive->scanResults[i1].deviceInfo.standalonedevInfo.secondaryDeviceTypeCount; i4++)
+ {
+ CsrMemCpyDes(primitive->scanResults[i1].deviceInfo.standalonedevInfo.secDeviceType[i4].deviceDetails, buffer, &offset, ((u16) (8)));
+ }
+ }
+ CsrMemCpyDes(primitive->scanResults[i1].deviceInfo.standalonedevInfo.deviceName, buffer, &offset, ((u16) (32)));
+ CsrUint8Des((u8 *) &primitive->scanResults[i1].deviceInfo.standalonedevInfo.deviceNameLength, buffer, &offset);
+ break;
+ default:
+ break;
+ }
+ }
+ }
+
+ return primitive;
+}
+
+
+void CsrWifiSmeScanResultsGetCfmSerFree(void *voidPrimitivePointer)
+{
+ CsrWifiSmeScanResultsGetCfm *primitive = (CsrWifiSmeScanResultsGetCfm *) voidPrimitivePointer;
+ {
+ u16 i1;
+ for (i1 = 0; i1 < primitive->scanResultsCount; i1++)
+ {
+ kfree(primitive->scanResults[i1].informationElements);
+ switch (primitive->scanResults[i1].p2pDeviceRole)
+ {
+ case CSR_WIFI_SME_P2P_ROLE_GO:
+ {
+ u16 i4;
+ for (i4 = 0; i4 < primitive->scanResults[i1].deviceInfo.groupInfo.p2pClientInfoCount; i4++)
+ {
+ kfree(primitive->scanResults[i1].deviceInfo.groupInfo.p2PClientInfo[i4].clientDeviceInfo.secDeviceType);
+ }
+ }
+ kfree(primitive->scanResults[i1].deviceInfo.groupInfo.p2PClientInfo);
+ break;
+ case CSR_WIFI_SME_P2P_ROLE_STANDALONE:
+ kfree(primitive->scanResults[i1].deviceInfo.standalonedevInfo.secDeviceType);
+ break;
+ default:
+ break;
+ }
+ }
+ }
+ kfree(primitive->scanResults);
+ kfree(primitive);
+}
+
+
+size_t CsrWifiSmeSmeStaConfigGetCfmSizeof(void *msg)
+{
+ size_t bufferSize = 2;
+
+ /* Calculate the Size of the Serialised Data. Could be more efficient (Try 13) */
+ bufferSize += 2; /* u16 primitive->interfaceTag */
+ bufferSize += 2; /* CsrResult primitive->status */
+ bufferSize += 1; /* u8 primitive->smeConfig.connectionQualityRssiChangeTrigger */
+ bufferSize += 1; /* u8 primitive->smeConfig.connectionQualitySnrChangeTrigger */
+ bufferSize += 1; /* CsrWifiSmeWmmModeMask primitive->smeConfig.wmmModeMask */
+ bufferSize += 1; /* CsrWifiSmeRadioIF primitive->smeConfig.ifIndex */
+ bufferSize += 1; /* u8 primitive->smeConfig.allowUnicastUseGroupCipher */
+ bufferSize += 1; /* u8 primitive->smeConfig.enableOpportunisticKeyCaching */
+ return bufferSize;
+}
+
+
+u8* CsrWifiSmeSmeStaConfigGetCfmSer(u8 *ptr, size_t *len, void *msg)
+{
+ CsrWifiSmeSmeStaConfigGetCfm *primitive = (CsrWifiSmeSmeStaConfigGetCfm *)msg;
+ *len = 0;
+ CsrUint16Ser(ptr, len, primitive->common.type);
+ CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
+ CsrUint16Ser(ptr, len, (u16) primitive->status);
+ CsrUint8Ser(ptr, len, (u8) primitive->smeConfig.connectionQualityRssiChangeTrigger);
+ CsrUint8Ser(ptr, len, (u8) primitive->smeConfig.connectionQualitySnrChangeTrigger);
+ CsrUint8Ser(ptr, len, (u8) primitive->smeConfig.wmmModeMask);
+ CsrUint8Ser(ptr, len, (u8) primitive->smeConfig.ifIndex);
+ CsrUint8Ser(ptr, len, (u8) primitive->smeConfig.allowUnicastUseGroupCipher);
+ CsrUint8Ser(ptr, len, (u8) primitive->smeConfig.enableOpportunisticKeyCaching);
+ return(ptr);
+}
+
+
+void* CsrWifiSmeSmeStaConfigGetCfmDes(u8 *buffer, size_t length)
+{
+ CsrWifiSmeSmeStaConfigGetCfm *primitive = kmalloc(sizeof(CsrWifiSmeSmeStaConfigGetCfm), GFP_KERNEL);
+ size_t offset;
+ offset = 0;
+
+ CsrUint16Des(&primitive->common.type, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->smeConfig.connectionQualityRssiChangeTrigger, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->smeConfig.connectionQualitySnrChangeTrigger, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->smeConfig.wmmModeMask, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->smeConfig.ifIndex, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->smeConfig.allowUnicastUseGroupCipher, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->smeConfig.enableOpportunisticKeyCaching, buffer, &offset);
+
+ return primitive;
+}
+
+
+size_t CsrWifiSmeSmeStaConfigSetCfmSizeof(void *msg)
+{
+ size_t bufferSize = 2;
+
+ /* Calculate the Size of the Serialised Data. Could be more efficient (Try 7) */
+ bufferSize += 2; /* u16 primitive->interfaceTag */
+ bufferSize += 2; /* CsrResult primitive->status */
+ return bufferSize;
+}
+
+
+u8* CsrWifiSmeSmeStaConfigSetCfmSer(u8 *ptr, size_t *len, void *msg)
+{
+ CsrWifiSmeSmeStaConfigSetCfm *primitive = (CsrWifiSmeSmeStaConfigSetCfm *)msg;
+ *len = 0;
+ CsrUint16Ser(ptr, len, primitive->common.type);
+ CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
+ CsrUint16Ser(ptr, len, (u16) primitive->status);
+ return(ptr);
+}
+
+
+void* CsrWifiSmeSmeStaConfigSetCfmDes(u8 *buffer, size_t length)
+{
+ CsrWifiSmeSmeStaConfigSetCfm *primitive = kmalloc(sizeof(CsrWifiSmeSmeStaConfigSetCfm), GFP_KERNEL);
+ size_t offset;
+ offset = 0;
+
+ CsrUint16Des(&primitive->common.type, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
+
+ return primitive;
+}
+
+
+size_t CsrWifiSmeStationMacAddressGetCfmSizeof(void *msg)
+{
+ size_t bufferSize = 2;
+
+ /* Calculate the Size of the Serialised Data. Could be more efficient (Try 17) */
+ bufferSize += 2; /* CsrResult primitive->status */
+ {
+ u16 i1;
+ for (i1 = 0; i1 < 2; i1++)
+ {
+ bufferSize += 6; /* u8 primitive->stationMacAddress[i1].a[6] */
+ }
+ }
+ return bufferSize;
+}
+
+
+u8* CsrWifiSmeStationMacAddressGetCfmSer(u8 *ptr, size_t *len, void *msg)
+{
+ CsrWifiSmeStationMacAddressGetCfm *primitive = (CsrWifiSmeStationMacAddressGetCfm *)msg;
+ *len = 0;
+ CsrUint16Ser(ptr, len, primitive->common.type);
+ CsrUint16Ser(ptr, len, (u16) primitive->status);
+ {
+ u16 i1;
+ for (i1 = 0; i1 < 2; i1++)
+ {
+ CsrMemCpySer(ptr, len, (const void *) primitive->stationMacAddress[i1].a, ((u16) (6)));
+ }
+ }
+ return(ptr);
+}
+
+
+void* CsrWifiSmeStationMacAddressGetCfmDes(u8 *buffer, size_t length)
+{
+ CsrWifiSmeStationMacAddressGetCfm *primitive = kmalloc(sizeof(CsrWifiSmeStationMacAddressGetCfm), GFP_KERNEL);
+ size_t offset;
+ offset = 0;
+
+ CsrUint16Des(&primitive->common.type, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
+ {
+ u16 i1;
+ for (i1 = 0; i1 < 2; i1++)
+ {
+ CsrMemCpyDes(primitive->stationMacAddress[i1].a, buffer, &offset, ((u16) (6)));
+ }
+ }
+
+ return primitive;
+}
+
+
+size_t CsrWifiSmeTspecIndSizeof(void *msg)
+{
+ CsrWifiSmeTspecInd *primitive = (CsrWifiSmeTspecInd *) msg;
+ size_t bufferSize = 2;
+
+ /* Calculate the Size of the Serialised Data. Could be more efficient (Try 13) */
+ bufferSize += 2; /* u16 primitive->interfaceTag */
+ bufferSize += 4; /* u32 primitive->transactionId */
+ bufferSize += 1; /* CsrWifiSmeTspecResultCode primitive->tspecResultCode */
+ bufferSize += 2; /* u16 primitive->tspecLength */
+ bufferSize += primitive->tspecLength; /* u8 primitive->tspec */
+ return bufferSize;
+}
+
+
+u8* CsrWifiSmeTspecIndSer(u8 *ptr, size_t *len, void *msg)
+{
+ CsrWifiSmeTspecInd *primitive = (CsrWifiSmeTspecInd *)msg;
+ *len = 0;
+ CsrUint16Ser(ptr, len, primitive->common.type);
+ CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
+ CsrUint32Ser(ptr, len, (u32) primitive->transactionId);
+ CsrUint8Ser(ptr, len, (u8) primitive->tspecResultCode);
+ CsrUint16Ser(ptr, len, (u16) primitive->tspecLength);
+ if (primitive->tspecLength)
+ {
+ CsrMemCpySer(ptr, len, (const void *) primitive->tspec, ((u16) (primitive->tspecLength)));
+ }
+ return(ptr);
+}
+
+
+void* CsrWifiSmeTspecIndDes(u8 *buffer, size_t length)
+{
+ CsrWifiSmeTspecInd *primitive = kmalloc(sizeof(CsrWifiSmeTspecInd), GFP_KERNEL);
+ size_t offset;
+ offset = 0;
+
+ CsrUint16Des(&primitive->common.type, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
+ CsrUint32Des((u32 *) &primitive->transactionId, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->tspecResultCode, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->tspecLength, buffer, &offset);
+ if (primitive->tspecLength)
+ {
+ primitive->tspec = kmalloc(primitive->tspecLength, GFP_KERNEL);
+ CsrMemCpyDes(primitive->tspec, buffer, &offset, ((u16) (primitive->tspecLength)));
+ }
+ else
+ {
+ primitive->tspec = NULL;
+ }
+
+ return primitive;
+}
+
+
+void CsrWifiSmeTspecIndSerFree(void *voidPrimitivePointer)
+{
+ CsrWifiSmeTspecInd *primitive = (CsrWifiSmeTspecInd *) voidPrimitivePointer;
+ kfree(primitive->tspec);
+ kfree(primitive);
+}
+
+
+size_t CsrWifiSmeTspecCfmSizeof(void *msg)
+{
+ CsrWifiSmeTspecCfm *primitive = (CsrWifiSmeTspecCfm *) msg;
+ size_t bufferSize = 2;
+
+ /* Calculate the Size of the Serialised Data. Could be more efficient (Try 15) */
+ bufferSize += 2; /* u16 primitive->interfaceTag */
+ bufferSize += 2; /* CsrResult primitive->status */
+ bufferSize += 4; /* u32 primitive->transactionId */
+ bufferSize += 1; /* CsrWifiSmeTspecResultCode primitive->tspecResultCode */
+ bufferSize += 2; /* u16 primitive->tspecLength */
+ bufferSize += primitive->tspecLength; /* u8 primitive->tspec */
+ return bufferSize;
+}
+
+
+u8* CsrWifiSmeTspecCfmSer(u8 *ptr, size_t *len, void *msg)
+{
+ CsrWifiSmeTspecCfm *primitive = (CsrWifiSmeTspecCfm *)msg;
+ *len = 0;
+ CsrUint16Ser(ptr, len, primitive->common.type);
+ CsrUint16Ser(ptr, len, (u16) primitive->interfaceTag);
+ CsrUint16Ser(ptr, len, (u16) primitive->status);
+ CsrUint32Ser(ptr, len, (u32) primitive->transactionId);
+ CsrUint8Ser(ptr, len, (u8) primitive->tspecResultCode);
+ CsrUint16Ser(ptr, len, (u16) primitive->tspecLength);
+ if (primitive->tspecLength)
+ {
+ CsrMemCpySer(ptr, len, (const void *) primitive->tspec, ((u16) (primitive->tspecLength)));
+ }
+ return(ptr);
+}
+
+
+void* CsrWifiSmeTspecCfmDes(u8 *buffer, size_t length)
+{
+ CsrWifiSmeTspecCfm *primitive = kmalloc(sizeof(CsrWifiSmeTspecCfm), GFP_KERNEL);
+ size_t offset;
+ offset = 0;
+
+ CsrUint16Des(&primitive->common.type, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->interfaceTag, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
+ CsrUint32Des((u32 *) &primitive->transactionId, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->tspecResultCode, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->tspecLength, buffer, &offset);
+ if (primitive->tspecLength)
+ {
+ primitive->tspec = kmalloc(primitive->tspecLength, GFP_KERNEL);
+ CsrMemCpyDes(primitive->tspec, buffer, &offset, ((u16) (primitive->tspecLength)));
+ }
+ else
+ {
+ primitive->tspec = NULL;
+ }
+
+ return primitive;
+}
+
+
+void CsrWifiSmeTspecCfmSerFree(void *voidPrimitivePointer)
+{
+ CsrWifiSmeTspecCfm *primitive = (CsrWifiSmeTspecCfm *) voidPrimitivePointer;
+ kfree(primitive->tspec);
+ kfree(primitive);
+}
+
+
+size_t CsrWifiSmeVersionsGetCfmSizeof(void *msg)
+{
+ CsrWifiSmeVersionsGetCfm *primitive = (CsrWifiSmeVersionsGetCfm *) msg;
+ size_t bufferSize = 2;
+
+ /* Calculate the Size of the Serialised Data. Could be more efficient (Try 33) */
+ bufferSize += 2; /* CsrResult primitive->status */
+ bufferSize += 4; /* u32 primitive->versions.chipId */
+ bufferSize += 4; /* u32 primitive->versions.chipVersion */
+ bufferSize += 4; /* u32 primitive->versions.firmwareBuild */
+ bufferSize += 4; /* u32 primitive->versions.firmwarePatch */
+ bufferSize += 4; /* u32 primitive->versions.firmwareHip */
+ bufferSize += (primitive->versions.routerBuild ? strlen(primitive->versions.routerBuild) : 0) + 1; /* char* primitive->versions.routerBuild (0 byte len + 1 for NULL Term) */
+ bufferSize += 4; /* u32 primitive->versions.routerHip */
+ bufferSize += (primitive->versions.smeBuild ? strlen(primitive->versions.smeBuild) : 0) + 1; /* char* primitive->versions.smeBuild (0 byte len + 1 for NULL Term) */
+ bufferSize += 4; /* u32 primitive->versions.smeHip */
+ return bufferSize;
+}
+
+
+u8* CsrWifiSmeVersionsGetCfmSer(u8 *ptr, size_t *len, void *msg)
+{
+ CsrWifiSmeVersionsGetCfm *primitive = (CsrWifiSmeVersionsGetCfm *)msg;
+ *len = 0;
+ CsrUint16Ser(ptr, len, primitive->common.type);
+ CsrUint16Ser(ptr, len, (u16) primitive->status);
+ CsrUint32Ser(ptr, len, (u32) primitive->versions.chipId);
+ CsrUint32Ser(ptr, len, (u32) primitive->versions.chipVersion);
+ CsrUint32Ser(ptr, len, (u32) primitive->versions.firmwareBuild);
+ CsrUint32Ser(ptr, len, (u32) primitive->versions.firmwarePatch);
+ CsrUint32Ser(ptr, len, (u32) primitive->versions.firmwareHip);
+ CsrCharStringSer(ptr, len, primitive->versions.routerBuild);
+ CsrUint32Ser(ptr, len, (u32) primitive->versions.routerHip);
+ CsrCharStringSer(ptr, len, primitive->versions.smeBuild);
+ CsrUint32Ser(ptr, len, (u32) primitive->versions.smeHip);
+ return(ptr);
+}
+
+
+void* CsrWifiSmeVersionsGetCfmDes(u8 *buffer, size_t length)
+{
+ CsrWifiSmeVersionsGetCfm *primitive = kmalloc(sizeof(CsrWifiSmeVersionsGetCfm), GFP_KERNEL);
+ size_t offset;
+ offset = 0;
+
+ CsrUint16Des(&primitive->common.type, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
+ CsrUint32Des((u32 *) &primitive->versions.chipId, buffer, &offset);
+ CsrUint32Des((u32 *) &primitive->versions.chipVersion, buffer, &offset);
+ CsrUint32Des((u32 *) &primitive->versions.firmwareBuild, buffer, &offset);
+ CsrUint32Des((u32 *) &primitive->versions.firmwarePatch, buffer, &offset);
+ CsrUint32Des((u32 *) &primitive->versions.firmwareHip, buffer, &offset);
+ CsrCharStringDes(&primitive->versions.routerBuild, buffer, &offset);
+ CsrUint32Des((u32 *) &primitive->versions.routerHip, buffer, &offset);
+ CsrCharStringDes(&primitive->versions.smeBuild, buffer, &offset);
+ CsrUint32Des((u32 *) &primitive->versions.smeHip, buffer, &offset);
+
+ return primitive;
+}
+
+
+void CsrWifiSmeVersionsGetCfmSerFree(void *voidPrimitivePointer)
+{
+ CsrWifiSmeVersionsGetCfm *primitive = (CsrWifiSmeVersionsGetCfm *) voidPrimitivePointer;
+ kfree(primitive->versions.routerBuild);
+ kfree(primitive->versions.smeBuild);
+ kfree(primitive);
+}
+
+
+size_t CsrWifiSmeCloakedSsidsGetCfmSizeof(void *msg)
+{
+ CsrWifiSmeCloakedSsidsGetCfm *primitive = (CsrWifiSmeCloakedSsidsGetCfm *) msg;
+ size_t bufferSize = 2;
+
+ /* Calculate the Size of the Serialised Data. Could be more efficient (Try 39) */
+ bufferSize += 2; /* CsrResult primitive->status */
+ bufferSize += 1; /* u8 primitive->cloakedSsids.cloakedSsidsCount */
+ {
+ u16 i2;
+ for (i2 = 0; i2 < primitive->cloakedSsids.cloakedSsidsCount; i2++)
+ {
+ bufferSize += 32; /* u8 primitive->cloakedSsids.cloakedSsids[i2].ssid[32] */
+ bufferSize += 1; /* u8 primitive->cloakedSsids.cloakedSsids[i2].length */
+ }
+ }
+ return bufferSize;
+}
+
+
+u8* CsrWifiSmeCloakedSsidsGetCfmSer(u8 *ptr, size_t *len, void *msg)
+{
+ CsrWifiSmeCloakedSsidsGetCfm *primitive = (CsrWifiSmeCloakedSsidsGetCfm *)msg;
+ *len = 0;
+ CsrUint16Ser(ptr, len, primitive->common.type);
+ CsrUint16Ser(ptr, len, (u16) primitive->status);
+ CsrUint8Ser(ptr, len, (u8) primitive->cloakedSsids.cloakedSsidsCount);
+ {
+ u16 i2;
+ for (i2 = 0; i2 < primitive->cloakedSsids.cloakedSsidsCount; i2++)
+ {
+ CsrMemCpySer(ptr, len, (const void *) primitive->cloakedSsids.cloakedSsids[i2].ssid, ((u16) (32)));
+ CsrUint8Ser(ptr, len, (u8) primitive->cloakedSsids.cloakedSsids[i2].length);
+ }
+ }
+ return(ptr);
+}
+
+
+void* CsrWifiSmeCloakedSsidsGetCfmDes(u8 *buffer, size_t length)
+{
+ CsrWifiSmeCloakedSsidsGetCfm *primitive = kmalloc(sizeof(CsrWifiSmeCloakedSsidsGetCfm), GFP_KERNEL);
+ size_t offset;
+ offset = 0;
+
+ CsrUint16Des(&primitive->common.type, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->cloakedSsids.cloakedSsidsCount, buffer, &offset);
+ primitive->cloakedSsids.cloakedSsids = NULL;
+ if (primitive->cloakedSsids.cloakedSsidsCount)
+ {
+ primitive->cloakedSsids.cloakedSsids = kmalloc(sizeof(CsrWifiSsid) * primitive->cloakedSsids.cloakedSsidsCount, GFP_KERNEL);
+ }
+ {
+ u16 i2;
+ for (i2 = 0; i2 < primitive->cloakedSsids.cloakedSsidsCount; i2++)
+ {
+ CsrMemCpyDes(primitive->cloakedSsids.cloakedSsids[i2].ssid, buffer, &offset, ((u16) (32)));
+ CsrUint8Des((u8 *) &primitive->cloakedSsids.cloakedSsids[i2].length, buffer, &offset);
+ }
+ }
+
+ return primitive;
+}
+
+
+void CsrWifiSmeCloakedSsidsGetCfmSerFree(void *voidPrimitivePointer)
+{
+ CsrWifiSmeCloakedSsidsGetCfm *primitive = (CsrWifiSmeCloakedSsidsGetCfm *) voidPrimitivePointer;
+ kfree(primitive->cloakedSsids.cloakedSsids);
+ kfree(primitive);
+}
+
+
+size_t CsrWifiSmeWifiOnIndSizeof(void *msg)
+{
+ size_t bufferSize = 2;
+
+ /* Calculate the Size of the Serialised Data. Could be more efficient (Try 9) */
+ bufferSize += 6; /* u8 primitive->address.a[6] */
+ return bufferSize;
+}
+
+
+u8* CsrWifiSmeWifiOnIndSer(u8 *ptr, size_t *len, void *msg)
+{
+ CsrWifiSmeWifiOnInd *primitive = (CsrWifiSmeWifiOnInd *)msg;
+ *len = 0;
+ CsrUint16Ser(ptr, len, primitive->common.type);
+ CsrMemCpySer(ptr, len, (const void *) primitive->address.a, ((u16) (6)));
+ return(ptr);
+}
+
+
+void* CsrWifiSmeWifiOnIndDes(u8 *buffer, size_t length)
+{
+ CsrWifiSmeWifiOnInd *primitive = kmalloc(sizeof(CsrWifiSmeWifiOnInd), GFP_KERNEL);
+ size_t offset;
+ offset = 0;
+
+ CsrUint16Des(&primitive->common.type, buffer, &offset);
+ CsrMemCpyDes(primitive->address.a, buffer, &offset, ((u16) (6)));
+
+ return primitive;
+}
+
+
+size_t CsrWifiSmeSmeCommonConfigGetCfmSizeof(void *msg)
+{
+ size_t bufferSize = 2;
+
+ /* Calculate the Size of the Serialised Data. Could be more efficient (Try 10) */
+ bufferSize += 2; /* CsrResult primitive->status */
+ bufferSize += 1; /* CsrWifiSme80211dTrustLevel primitive->deviceConfig.trustLevel */
+ bufferSize += 2; /* u8 primitive->deviceConfig.countryCode[2] */
+ bufferSize += 1; /* CsrWifiSmeFirmwareDriverInterface primitive->deviceConfig.firmwareDriverInterface */
+ bufferSize += 1; /* u8 primitive->deviceConfig.enableStrictDraftN */
+ return bufferSize;
+}
+
+
+u8* CsrWifiSmeSmeCommonConfigGetCfmSer(u8 *ptr, size_t *len, void *msg)
+{
+ CsrWifiSmeSmeCommonConfigGetCfm *primitive = (CsrWifiSmeSmeCommonConfigGetCfm *)msg;
+ *len = 0;
+ CsrUint16Ser(ptr, len, primitive->common.type);
+ CsrUint16Ser(ptr, len, (u16) primitive->status);
+ CsrUint8Ser(ptr, len, (u8) primitive->deviceConfig.trustLevel);
+ CsrMemCpySer(ptr, len, (const void *) primitive->deviceConfig.countryCode, ((u16) (2)));
+ CsrUint8Ser(ptr, len, (u8) primitive->deviceConfig.firmwareDriverInterface);
+ CsrUint8Ser(ptr, len, (u8) primitive->deviceConfig.enableStrictDraftN);
+ return(ptr);
+}
+
+
+void* CsrWifiSmeSmeCommonConfigGetCfmDes(u8 *buffer, size_t length)
+{
+ CsrWifiSmeSmeCommonConfigGetCfm *primitive = kmalloc(sizeof(CsrWifiSmeSmeCommonConfigGetCfm), GFP_KERNEL);
+ size_t offset;
+ offset = 0;
+
+ CsrUint16Des(&primitive->common.type, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->deviceConfig.trustLevel, buffer, &offset);
+ CsrMemCpyDes(primitive->deviceConfig.countryCode, buffer, &offset, ((u16) (2)));
+ CsrUint8Des((u8 *) &primitive->deviceConfig.firmwareDriverInterface, buffer, &offset);
+ CsrUint8Des((u8 *) &primitive->deviceConfig.enableStrictDraftN, buffer, &offset);
+
+ return primitive;
+}
+
+
+size_t CsrWifiSmeInterfaceCapabilityGetCfmSizeof(void *msg)
+{
+ size_t bufferSize = 2;
+
+ /* Calculate the Size of the Serialised Data. Could be more efficient (Try 9) */
+ bufferSize += 2; /* CsrResult primitive->status */
+ bufferSize += 2; /* u16 primitive->numInterfaces */
+ bufferSize += 2; /* u8 primitive->capBitmap[2] */
+ return bufferSize;
+}
+
+
+u8* CsrWifiSmeInterfaceCapabilityGetCfmSer(u8 *ptr, size_t *len, void *msg)
+{
+ CsrWifiSmeInterfaceCapabilityGetCfm *primitive = (CsrWifiSmeInterfaceCapabilityGetCfm *)msg;
+ *len = 0;
+ CsrUint16Ser(ptr, len, primitive->common.type);
+ CsrUint16Ser(ptr, len, (u16) primitive->status);
+ CsrUint16Ser(ptr, len, (u16) primitive->numInterfaces);
+ CsrMemCpySer(ptr, len, (const void *) primitive->capBitmap, ((u16) (2)));
+ return(ptr);
+}
+
+
+void* CsrWifiSmeInterfaceCapabilityGetCfmDes(u8 *buffer, size_t length)
+{
+ CsrWifiSmeInterfaceCapabilityGetCfm *primitive = kmalloc(sizeof(CsrWifiSmeInterfaceCapabilityGetCfm), GFP_KERNEL);
+ size_t offset;
+ offset = 0;
+
+ CsrUint16Des(&primitive->common.type, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->status, buffer, &offset);
+ CsrUint16Des((u16 *) &primitive->numInterfaces, buffer, &offset);
+ CsrMemCpyDes(primitive->capBitmap, buffer, &offset, ((u16) (2)));
+
+ return primitive;
+}
+
+
+size_t CsrWifiSmeErrorIndSizeof(void *msg)
+{
+ CsrWifiSmeErrorInd *primitive = (CsrWifiSmeErrorInd *) msg;
+ size_t bufferSize = 2;
+
+ /* Calculate the Size of the Serialised Data. Could be more efficient (Try 3) */
+ bufferSize += (primitive->errorMessage ? strlen(primitive->errorMessage) : 0) + 1; /* char* primitive->errorMessage (0 byte len + 1 for NULL Term) */
+ return bufferSize;
+}
+
+
+u8* CsrWifiSmeErrorIndSer(u8 *ptr, size_t *len, void *msg)
+{
+ CsrWifiSmeErrorInd *primitive = (CsrWifiSmeErrorInd *)msg;
+ *len = 0;
+ CsrUint16Ser(ptr, len, primitive->common.type);
+ CsrCharStringSer(ptr, len, primitive->errorMessage);
+ return(ptr);
+}
+
+
+void* CsrWifiSmeErrorIndDes(u8 *buffer, size_t length)
+{
+ CsrWifiSmeErrorInd *primitive = kmalloc(sizeof(CsrWifiSmeErrorInd), GFP_KERNEL);
+ size_t offset;
+ offset = 0;
+
+ CsrUint16Des(&primitive->common.type, buffer, &offset);
+ CsrCharStringDes(&primitive->errorMessage, buffer, &offset);
+
+ return primitive;
+}
+
+
+void CsrWifiSmeErrorIndSerFree(void *voidPrimitivePointer)
+{
+ CsrWifiSmeErrorInd *primitive = (CsrWifiSmeErrorInd *) voidPrimitivePointer;
+ kfree(primitive->errorMessage);
+ kfree(primitive);
+}
+
+
+size_t CsrWifiSmeInfoIndSizeof(void *msg)
+{
+ CsrWifiSmeInfoInd *primitive = (CsrWifiSmeInfoInd *) msg;
+ size_t bufferSize = 2;
+
+ /* Calculate the Size of the Serialised Data. Could be more efficient (Try 3) */
+ bufferSize += (primitive->infoMessage ? strlen(primitive->infoMessage) : 0) + 1; /* char* primitive->infoMessage (0 byte len + 1 for NULL Term) */
+ return bufferSize;
+}
+
+
+u8* CsrWifiSmeInfoIndSer(u8 *ptr, size_t *len, void *msg)
+{
+ CsrWifiSmeInfoInd *primitive = (CsrWifiSmeInfoInd *)msg;
+ *len = 0;
+ CsrUint16Ser(ptr, len, primitive->common.type);
+ CsrCharStringSer(ptr, len, primitive->infoMessage);
+ return(ptr);
+}
+
+
+void* CsrWifiSmeInfoIndDes(u8 *buffer, size_t length)
+{
+ CsrWifiSmeInfoInd *primitive = kmalloc(sizeof(CsrWifiSmeInfoInd), GFP_KERNEL);
+ size_t offset;
+ offset = 0;
+
+ CsrUint16Des(&primitive->common.type, buffer, &offset);
+ CsrCharStringDes(&primitive->infoMessage, buffer, &offset);
+
+ return primitive;
+}
+
+
+void CsrWifiSmeInfoIndSerFree(void *voidPrimitivePointer)
+{
+ CsrWifiSmeInfoInd *primitive = (CsrWifiSmeInfoInd *) voidPrimitivePointer;
+ kfree(primitive->infoMessage);
+ kfree(primitive);
+}
+
+
+size_t CsrWifiSmeCoreDumpIndSizeof(void *msg)
+{
+ CsrWifiSmeCoreDumpInd *primitive = (CsrWifiSmeCoreDumpInd *) msg;
+ size_t bufferSize = 2;
+
+ /* Calculate the Size of the Serialised Data. Could be more efficient (Try 8) */
+ bufferSize += 4; /* u32 primitive->dataLength */
+ bufferSize += primitive->dataLength; /* u8 primitive->data */
+ return bufferSize;
+}
+
+
+u8* CsrWifiSmeCoreDumpIndSer(u8 *ptr, size_t *len, void *msg)
+{
+ CsrWifiSmeCoreDumpInd *primitive = (CsrWifiSmeCoreDumpInd *)msg;
+ *len = 0;
+ CsrUint16Ser(ptr, len, primitive->common.type);
+ CsrUint32Ser(ptr, len, (u32) primitive->dataLength);
+ if (primitive->dataLength)
+ {
+ CsrMemCpySer(ptr, len, (const void *) primitive->data, ((u16) (primitive->dataLength)));
+ }
+ return(ptr);
+}
+
+
+void* CsrWifiSmeCoreDumpIndDes(u8 *buffer, size_t length)
+{
+ CsrWifiSmeCoreDumpInd *primitive = kmalloc(sizeof(CsrWifiSmeCoreDumpInd), GFP_KERNEL);
+ size_t offset;
+ offset = 0;
+
+ CsrUint16Des(&primitive->common.type, buffer, &offset);
+ CsrUint32Des((u32 *) &primitive->dataLength, buffer, &offset);
+ if (primitive->dataLength)
+ {
+ primitive->data = kmalloc(primitive->dataLength, GFP_KERNEL);
+ CsrMemCpyDes(primitive->data, buffer, &offset, ((u16) (primitive->dataLength)));
+ }
+ else
+ {
+ primitive->data = NULL;
+ }
+
+ return primitive;
+}
+
+
+void CsrWifiSmeCoreDumpIndSerFree(void *voidPrimitivePointer)
+{
+ CsrWifiSmeCoreDumpInd *primitive = (CsrWifiSmeCoreDumpInd *) voidPrimitivePointer;
+ kfree(primitive->data);
+ kfree(primitive);
+}
+
+
diff --git a/drivers/staging/csr/csr_wifi_sme_serialize.h b/drivers/staging/csr/csr_wifi_sme_serialize.h
new file mode 100644
index 000000000000..4f3af0a6be7c
--- /dev/null
+++ b/drivers/staging/csr/csr_wifi_sme_serialize.h
@@ -0,0 +1,670 @@
+/*****************************************************************************
+
+ (c) Cambridge Silicon Radio Limited 2012
+ All rights reserved and confidential information of CSR
+
+ Refer to LICENSE.txt included with this source for details
+ on the license terms.
+
+*****************************************************************************/
+
+/* Note: this is an auto-generated file. */
+
+#ifndef CSR_WIFI_SME_SERIALIZE_H__
+#define CSR_WIFI_SME_SERIALIZE_H__
+
+#include "csr_wifi_msgconv.h"
+#include "csr_wifi_sme_prim.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern void CsrWifiSmePfree(void *ptr);
+
+#define CsrWifiSmeActivateReqSer CsrWifiEventSer
+#define CsrWifiSmeActivateReqDes CsrWifiEventDes
+#define CsrWifiSmeActivateReqSizeof CsrWifiEventSizeof
+#define CsrWifiSmeActivateReqSerFree CsrWifiSmePfree
+
+#define CsrWifiSmeAdhocConfigGetReqSer CsrWifiEventSer
+#define CsrWifiSmeAdhocConfigGetReqDes CsrWifiEventDes
+#define CsrWifiSmeAdhocConfigGetReqSizeof CsrWifiEventSizeof
+#define CsrWifiSmeAdhocConfigGetReqSerFree CsrWifiSmePfree
+
+extern u8* CsrWifiSmeAdhocConfigSetReqSer(u8 *ptr, size_t *len, void *msg);
+extern void* CsrWifiSmeAdhocConfigSetReqDes(u8 *buffer, size_t len);
+extern size_t CsrWifiSmeAdhocConfigSetReqSizeof(void *msg);
+#define CsrWifiSmeAdhocConfigSetReqSerFree CsrWifiSmePfree
+
+extern u8* CsrWifiSmeBlacklistReqSer(u8 *ptr, size_t *len, void *msg);
+extern void* CsrWifiSmeBlacklistReqDes(u8 *buffer, size_t len);
+extern size_t CsrWifiSmeBlacklistReqSizeof(void *msg);
+extern void CsrWifiSmeBlacklistReqSerFree(void *msg);
+
+#define CsrWifiSmeCalibrationDataGetReqSer CsrWifiEventSer
+#define CsrWifiSmeCalibrationDataGetReqDes CsrWifiEventDes
+#define CsrWifiSmeCalibrationDataGetReqSizeof CsrWifiEventSizeof
+#define CsrWifiSmeCalibrationDataGetReqSerFree CsrWifiSmePfree
+
+extern u8* CsrWifiSmeCalibrationDataSetReqSer(u8 *ptr, size_t *len, void *msg);
+extern void* CsrWifiSmeCalibrationDataSetReqDes(u8 *buffer, size_t len);
+extern size_t CsrWifiSmeCalibrationDataSetReqSizeof(void *msg);
+extern void CsrWifiSmeCalibrationDataSetReqSerFree(void *msg);
+
+#define CsrWifiSmeCcxConfigGetReqSer CsrWifiEventCsrUint16Ser
+#define CsrWifiSmeCcxConfigGetReqDes CsrWifiEventCsrUint16Des
+#define CsrWifiSmeCcxConfigGetReqSizeof CsrWifiEventCsrUint16Sizeof
+#define CsrWifiSmeCcxConfigGetReqSerFree CsrWifiSmePfree
+
+extern u8* CsrWifiSmeCcxConfigSetReqSer(u8 *ptr, size_t *len, void *msg);
+extern void* CsrWifiSmeCcxConfigSetReqDes(u8 *buffer, size_t len);
+extern size_t CsrWifiSmeCcxConfigSetReqSizeof(void *msg);
+#define CsrWifiSmeCcxConfigSetReqSerFree CsrWifiSmePfree
+
+#define CsrWifiSmeCoexConfigGetReqSer CsrWifiEventSer
+#define CsrWifiSmeCoexConfigGetReqDes CsrWifiEventDes
+#define CsrWifiSmeCoexConfigGetReqSizeof CsrWifiEventSizeof
+#define CsrWifiSmeCoexConfigGetReqSerFree CsrWifiSmePfree
+
+extern u8* CsrWifiSmeCoexConfigSetReqSer(u8 *ptr, size_t *len, void *msg);
+extern void* CsrWifiSmeCoexConfigSetReqDes(u8 *buffer, size_t len);
+extern size_t CsrWifiSmeCoexConfigSetReqSizeof(void *msg);
+#define CsrWifiSmeCoexConfigSetReqSerFree CsrWifiSmePfree
+
+#define CsrWifiSmeCoexInfoGetReqSer CsrWifiEventSer
+#define CsrWifiSmeCoexInfoGetReqDes CsrWifiEventDes
+#define CsrWifiSmeCoexInfoGetReqSizeof CsrWifiEventSizeof
+#define CsrWifiSmeCoexInfoGetReqSerFree CsrWifiSmePfree
+
+extern u8* CsrWifiSmeConnectReqSer(u8 *ptr, size_t *len, void *msg);
+extern void* CsrWifiSmeConnectReqDes(u8 *buffer, size_t len);
+extern size_t CsrWifiSmeConnectReqSizeof(void *msg);
+extern void CsrWifiSmeConnectReqSerFree(void *msg);
+
+#define CsrWifiSmeConnectionConfigGetReqSer CsrWifiEventCsrUint16Ser
+#define CsrWifiSmeConnectionConfigGetReqDes CsrWifiEventCsrUint16Des
+#define CsrWifiSmeConnectionConfigGetReqSizeof CsrWifiEventCsrUint16Sizeof
+#define CsrWifiSmeConnectionConfigGetReqSerFree CsrWifiSmePfree
+
+#define CsrWifiSmeConnectionInfoGetReqSer CsrWifiEventCsrUint16Ser
+#define CsrWifiSmeConnectionInfoGetReqDes CsrWifiEventCsrUint16Des
+#define CsrWifiSmeConnectionInfoGetReqSizeof CsrWifiEventCsrUint16Sizeof
+#define CsrWifiSmeConnectionInfoGetReqSerFree CsrWifiSmePfree
+
+#define CsrWifiSmeConnectionStatsGetReqSer CsrWifiEventCsrUint16Ser
+#define CsrWifiSmeConnectionStatsGetReqDes CsrWifiEventCsrUint16Des
+#define CsrWifiSmeConnectionStatsGetReqSizeof CsrWifiEventCsrUint16Sizeof
+#define CsrWifiSmeConnectionStatsGetReqSerFree CsrWifiSmePfree
+
+#define CsrWifiSmeDeactivateReqSer CsrWifiEventSer
+#define CsrWifiSmeDeactivateReqDes CsrWifiEventDes
+#define CsrWifiSmeDeactivateReqSizeof CsrWifiEventSizeof
+#define CsrWifiSmeDeactivateReqSerFree CsrWifiSmePfree
+
+#define CsrWifiSmeDisconnectReqSer CsrWifiEventCsrUint16Ser
+#define CsrWifiSmeDisconnectReqDes CsrWifiEventCsrUint16Des
+#define CsrWifiSmeDisconnectReqSizeof CsrWifiEventCsrUint16Sizeof
+#define CsrWifiSmeDisconnectReqSerFree CsrWifiSmePfree
+
+#define CsrWifiSmeEventMaskSetReqSer CsrWifiEventCsrUint32Ser
+#define CsrWifiSmeEventMaskSetReqDes CsrWifiEventCsrUint32Des
+#define CsrWifiSmeEventMaskSetReqSizeof CsrWifiEventCsrUint32Sizeof
+#define CsrWifiSmeEventMaskSetReqSerFree CsrWifiSmePfree
+
+#define CsrWifiSmeHostConfigGetReqSer CsrWifiEventCsrUint16Ser
+#define CsrWifiSmeHostConfigGetReqDes CsrWifiEventCsrUint16Des
+#define CsrWifiSmeHostConfigGetReqSizeof CsrWifiEventCsrUint16Sizeof
+#define CsrWifiSmeHostConfigGetReqSerFree CsrWifiSmePfree
+
+extern u8* CsrWifiSmeHostConfigSetReqSer(u8 *ptr, size_t *len, void *msg);
+extern void* CsrWifiSmeHostConfigSetReqDes(u8 *buffer, size_t len);
+extern size_t CsrWifiSmeHostConfigSetReqSizeof(void *msg);
+#define CsrWifiSmeHostConfigSetReqSerFree CsrWifiSmePfree
+
+extern u8* CsrWifiSmeKeyReqSer(u8 *ptr, size_t *len, void *msg);
+extern void* CsrWifiSmeKeyReqDes(u8 *buffer, size_t len);
+extern size_t CsrWifiSmeKeyReqSizeof(void *msg);
+#define CsrWifiSmeKeyReqSerFree CsrWifiSmePfree
+
+#define CsrWifiSmeLinkQualityGetReqSer CsrWifiEventCsrUint16Ser
+#define CsrWifiSmeLinkQualityGetReqDes CsrWifiEventCsrUint16Des
+#define CsrWifiSmeLinkQualityGetReqSizeof CsrWifiEventCsrUint16Sizeof
+#define CsrWifiSmeLinkQualityGetReqSerFree CsrWifiSmePfree
+
+#define CsrWifiSmeMibConfigGetReqSer CsrWifiEventSer
+#define CsrWifiSmeMibConfigGetReqDes CsrWifiEventDes
+#define CsrWifiSmeMibConfigGetReqSizeof CsrWifiEventSizeof
+#define CsrWifiSmeMibConfigGetReqSerFree CsrWifiSmePfree
+
+extern u8* CsrWifiSmeMibConfigSetReqSer(u8 *ptr, size_t *len, void *msg);
+extern void* CsrWifiSmeMibConfigSetReqDes(u8 *buffer, size_t len);
+extern size_t CsrWifiSmeMibConfigSetReqSizeof(void *msg);
+#define CsrWifiSmeMibConfigSetReqSerFree CsrWifiSmePfree
+
+extern u8* CsrWifiSmeMibGetNextReqSer(u8 *ptr, size_t *len, void *msg);
+extern void* CsrWifiSmeMibGetNextReqDes(u8 *buffer, size_t len);
+extern size_t CsrWifiSmeMibGetNextReqSizeof(void *msg);
+extern void CsrWifiSmeMibGetNextReqSerFree(void *msg);
+
+extern u8* CsrWifiSmeMibGetReqSer(u8 *ptr, size_t *len, void *msg);
+extern void* CsrWifiSmeMibGetReqDes(u8 *buffer, size_t len);
+extern size_t CsrWifiSmeMibGetReqSizeof(void *msg);
+extern void CsrWifiSmeMibGetReqSerFree(void *msg);
+
+extern u8* CsrWifiSmeMibSetReqSer(u8 *ptr, size_t *len, void *msg);
+extern void* CsrWifiSmeMibSetReqDes(u8 *buffer, size_t len);
+extern size_t CsrWifiSmeMibSetReqSizeof(void *msg);
+extern void CsrWifiSmeMibSetReqSerFree(void *msg);
+
+extern u8* CsrWifiSmeMulticastAddressReqSer(u8 *ptr, size_t *len, void *msg);
+extern void* CsrWifiSmeMulticastAddressReqDes(u8 *buffer, size_t len);
+extern size_t CsrWifiSmeMulticastAddressReqSizeof(void *msg);
+extern void CsrWifiSmeMulticastAddressReqSerFree(void *msg);
+
+extern u8* CsrWifiSmePacketFilterSetReqSer(u8 *ptr, size_t *len, void *msg);
+extern void* CsrWifiSmePacketFilterSetReqDes(u8 *buffer, size_t len);
+extern size_t CsrWifiSmePacketFilterSetReqSizeof(void *msg);
+extern void CsrWifiSmePacketFilterSetReqSerFree(void *msg);
+
+#define CsrWifiSmePermanentMacAddressGetReqSer CsrWifiEventSer
+#define CsrWifiSmePermanentMacAddressGetReqDes CsrWifiEventDes
+#define CsrWifiSmePermanentMacAddressGetReqSizeof CsrWifiEventSizeof
+#define CsrWifiSmePermanentMacAddressGetReqSerFree CsrWifiSmePfree
+
+extern u8* CsrWifiSmePmkidReqSer(u8 *ptr, size_t *len, void *msg);
+extern void* CsrWifiSmePmkidReqDes(u8 *buffer, size_t len);
+extern size_t CsrWifiSmePmkidReqSizeof(void *msg);
+extern void CsrWifiSmePmkidReqSerFree(void *msg);
+
+#define CsrWifiSmePowerConfigGetReqSer CsrWifiEventSer
+#define CsrWifiSmePowerConfigGetReqDes CsrWifiEventDes
+#define CsrWifiSmePowerConfigGetReqSizeof CsrWifiEventSizeof
+#define CsrWifiSmePowerConfigGetReqSerFree CsrWifiSmePfree
+
+extern u8* CsrWifiSmePowerConfigSetReqSer(u8 *ptr, size_t *len, void *msg);
+extern void* CsrWifiSmePowerConfigSetReqDes(u8 *buffer, size_t len);
+extern size_t CsrWifiSmePowerConfigSetReqSizeof(void *msg);
+#define CsrWifiSmePowerConfigSetReqSerFree CsrWifiSmePfree
+
+#define CsrWifiSmeRegulatoryDomainInfoGetReqSer CsrWifiEventSer
+#define CsrWifiSmeRegulatoryDomainInfoGetReqDes CsrWifiEventDes
+#define CsrWifiSmeRegulatoryDomainInfoGetReqSizeof CsrWifiEventSizeof
+#define CsrWifiSmeRegulatoryDomainInfoGetReqSerFree CsrWifiSmePfree
+
+#define CsrWifiSmeRoamingConfigGetReqSer CsrWifiEventCsrUint16Ser
+#define CsrWifiSmeRoamingConfigGetReqDes CsrWifiEventCsrUint16Des
+#define CsrWifiSmeRoamingConfigGetReqSizeof CsrWifiEventCsrUint16Sizeof
+#define CsrWifiSmeRoamingConfigGetReqSerFree CsrWifiSmePfree
+
+extern u8* CsrWifiSmeRoamingConfigSetReqSer(u8 *ptr, size_t *len, void *msg);
+extern void* CsrWifiSmeRoamingConfigSetReqDes(u8 *buffer, size_t len);
+extern size_t CsrWifiSmeRoamingConfigSetReqSizeof(void *msg);
+#define CsrWifiSmeRoamingConfigSetReqSerFree CsrWifiSmePfree
+
+#define CsrWifiSmeScanConfigGetReqSer CsrWifiEventSer
+#define CsrWifiSmeScanConfigGetReqDes CsrWifiEventDes
+#define CsrWifiSmeScanConfigGetReqSizeof CsrWifiEventSizeof
+#define CsrWifiSmeScanConfigGetReqSerFree CsrWifiSmePfree
+
+extern u8* CsrWifiSmeScanConfigSetReqSer(u8 *ptr, size_t *len, void *msg);
+extern void* CsrWifiSmeScanConfigSetReqDes(u8 *buffer, size_t len);
+extern size_t CsrWifiSmeScanConfigSetReqSizeof(void *msg);
+extern void CsrWifiSmeScanConfigSetReqSerFree(void *msg);
+
+extern u8* CsrWifiSmeScanFullReqSer(u8 *ptr, size_t *len, void *msg);
+extern void* CsrWifiSmeScanFullReqDes(u8 *buffer, size_t len);
+extern size_t CsrWifiSmeScanFullReqSizeof(void *msg);
+extern void CsrWifiSmeScanFullReqSerFree(void *msg);
+
+#define CsrWifiSmeScanResultsFlushReqSer CsrWifiEventSer
+#define CsrWifiSmeScanResultsFlushReqDes CsrWifiEventDes
+#define CsrWifiSmeScanResultsFlushReqSizeof CsrWifiEventSizeof
+#define CsrWifiSmeScanResultsFlushReqSerFree CsrWifiSmePfree
+
+#define CsrWifiSmeScanResultsGetReqSer CsrWifiEventSer
+#define CsrWifiSmeScanResultsGetReqDes CsrWifiEventDes
+#define CsrWifiSmeScanResultsGetReqSizeof CsrWifiEventSizeof
+#define CsrWifiSmeScanResultsGetReqSerFree CsrWifiSmePfree
+
+#define CsrWifiSmeSmeStaConfigGetReqSer CsrWifiEventCsrUint16Ser
+#define CsrWifiSmeSmeStaConfigGetReqDes CsrWifiEventCsrUint16Des
+#define CsrWifiSmeSmeStaConfigGetReqSizeof CsrWifiEventCsrUint16Sizeof
+#define CsrWifiSmeSmeStaConfigGetReqSerFree CsrWifiSmePfree
+
+extern u8* CsrWifiSmeSmeStaConfigSetReqSer(u8 *ptr, size_t *len, void *msg);
+extern void* CsrWifiSmeSmeStaConfigSetReqDes(u8 *buffer, size_t len);
+extern size_t CsrWifiSmeSmeStaConfigSetReqSizeof(void *msg);
+#define CsrWifiSmeSmeStaConfigSetReqSerFree CsrWifiSmePfree
+
+#define CsrWifiSmeStationMacAddressGetReqSer CsrWifiEventSer
+#define CsrWifiSmeStationMacAddressGetReqDes CsrWifiEventDes
+#define CsrWifiSmeStationMacAddressGetReqSizeof CsrWifiEventSizeof
+#define CsrWifiSmeStationMacAddressGetReqSerFree CsrWifiSmePfree
+
+extern u8* CsrWifiSmeTspecReqSer(u8 *ptr, size_t *len, void *msg);
+extern void* CsrWifiSmeTspecReqDes(u8 *buffer, size_t len);
+extern size_t CsrWifiSmeTspecReqSizeof(void *msg);
+extern void CsrWifiSmeTspecReqSerFree(void *msg);
+
+#define CsrWifiSmeVersionsGetReqSer CsrWifiEventSer
+#define CsrWifiSmeVersionsGetReqDes CsrWifiEventDes
+#define CsrWifiSmeVersionsGetReqSizeof CsrWifiEventSizeof
+#define CsrWifiSmeVersionsGetReqSerFree CsrWifiSmePfree
+
+extern u8* CsrWifiSmeWifiFlightmodeReqSer(u8 *ptr, size_t *len, void *msg);
+extern void* CsrWifiSmeWifiFlightmodeReqDes(u8 *buffer, size_t len);
+extern size_t CsrWifiSmeWifiFlightmodeReqSizeof(void *msg);
+extern void CsrWifiSmeWifiFlightmodeReqSerFree(void *msg);
+
+#define CsrWifiSmeWifiOffReqSer CsrWifiEventSer
+#define CsrWifiSmeWifiOffReqDes CsrWifiEventDes
+#define CsrWifiSmeWifiOffReqSizeof CsrWifiEventSizeof
+#define CsrWifiSmeWifiOffReqSerFree CsrWifiSmePfree
+
+extern u8* CsrWifiSmeWifiOnReqSer(u8 *ptr, size_t *len, void *msg);
+extern void* CsrWifiSmeWifiOnReqDes(u8 *buffer, size_t len);
+extern size_t CsrWifiSmeWifiOnReqSizeof(void *msg);
+extern void CsrWifiSmeWifiOnReqSerFree(void *msg);
+
+extern u8* CsrWifiSmeCloakedSsidsSetReqSer(u8 *ptr, size_t *len, void *msg);
+extern void* CsrWifiSmeCloakedSsidsSetReqDes(u8 *buffer, size_t len);
+extern size_t CsrWifiSmeCloakedSsidsSetReqSizeof(void *msg);
+extern void CsrWifiSmeCloakedSsidsSetReqSerFree(void *msg);
+
+#define CsrWifiSmeCloakedSsidsGetReqSer CsrWifiEventSer
+#define CsrWifiSmeCloakedSsidsGetReqDes CsrWifiEventDes
+#define CsrWifiSmeCloakedSsidsGetReqSizeof CsrWifiEventSizeof
+#define CsrWifiSmeCloakedSsidsGetReqSerFree CsrWifiSmePfree
+
+#define CsrWifiSmeSmeCommonConfigGetReqSer CsrWifiEventSer
+#define CsrWifiSmeSmeCommonConfigGetReqDes CsrWifiEventDes
+#define CsrWifiSmeSmeCommonConfigGetReqSizeof CsrWifiEventSizeof
+#define CsrWifiSmeSmeCommonConfigGetReqSerFree CsrWifiSmePfree
+
+extern u8* CsrWifiSmeSmeCommonConfigSetReqSer(u8 *ptr, size_t *len, void *msg);
+extern void* CsrWifiSmeSmeCommonConfigSetReqDes(u8 *buffer, size_t len);
+extern size_t CsrWifiSmeSmeCommonConfigSetReqSizeof(void *msg);
+#define CsrWifiSmeSmeCommonConfigSetReqSerFree CsrWifiSmePfree
+
+#define CsrWifiSmeInterfaceCapabilityGetReqSer CsrWifiEventSer
+#define CsrWifiSmeInterfaceCapabilityGetReqDes CsrWifiEventDes
+#define CsrWifiSmeInterfaceCapabilityGetReqSizeof CsrWifiEventSizeof
+#define CsrWifiSmeInterfaceCapabilityGetReqSerFree CsrWifiSmePfree
+
+extern u8* CsrWifiSmeWpsConfigurationReqSer(u8 *ptr, size_t *len, void *msg);
+extern void* CsrWifiSmeWpsConfigurationReqDes(u8 *buffer, size_t len);
+extern size_t CsrWifiSmeWpsConfigurationReqSizeof(void *msg);
+extern void CsrWifiSmeWpsConfigurationReqSerFree(void *msg);
+
+extern u8* CsrWifiSmeSetReqSer(u8 *ptr, size_t *len, void *msg);
+extern void* CsrWifiSmeSetReqDes(u8 *buffer, size_t len);
+extern size_t CsrWifiSmeSetReqSizeof(void *msg);
+extern void CsrWifiSmeSetReqSerFree(void *msg);
+
+#define CsrWifiSmeActivateCfmSer CsrWifiEventCsrUint16Ser
+#define CsrWifiSmeActivateCfmDes CsrWifiEventCsrUint16Des
+#define CsrWifiSmeActivateCfmSizeof CsrWifiEventCsrUint16Sizeof
+#define CsrWifiSmeActivateCfmSerFree CsrWifiSmePfree
+
+extern u8* CsrWifiSmeAdhocConfigGetCfmSer(u8 *ptr, size_t *len, void *msg);
+extern void* CsrWifiSmeAdhocConfigGetCfmDes(u8 *buffer, size_t len);
+extern size_t CsrWifiSmeAdhocConfigGetCfmSizeof(void *msg);
+#define CsrWifiSmeAdhocConfigGetCfmSerFree CsrWifiSmePfree
+
+#define CsrWifiSmeAdhocConfigSetCfmSer CsrWifiEventCsrUint16Ser
+#define CsrWifiSmeAdhocConfigSetCfmDes CsrWifiEventCsrUint16Des
+#define CsrWifiSmeAdhocConfigSetCfmSizeof CsrWifiEventCsrUint16Sizeof
+#define CsrWifiSmeAdhocConfigSetCfmSerFree CsrWifiSmePfree
+
+extern u8* CsrWifiSmeAssociationCompleteIndSer(u8 *ptr, size_t *len, void *msg);
+extern void* CsrWifiSmeAssociationCompleteIndDes(u8 *buffer, size_t len);
+extern size_t CsrWifiSmeAssociationCompleteIndSizeof(void *msg);
+extern void CsrWifiSmeAssociationCompleteIndSerFree(void *msg);
+
+extern u8* CsrWifiSmeAssociationStartIndSer(u8 *ptr, size_t *len, void *msg);
+extern void* CsrWifiSmeAssociationStartIndDes(u8 *buffer, size_t len);
+extern size_t CsrWifiSmeAssociationStartIndSizeof(void *msg);
+#define CsrWifiSmeAssociationStartIndSerFree CsrWifiSmePfree
+
+extern u8* CsrWifiSmeBlacklistCfmSer(u8 *ptr, size_t *len, void *msg);
+extern void* CsrWifiSmeBlacklistCfmDes(u8 *buffer, size_t len);
+extern size_t CsrWifiSmeBlacklistCfmSizeof(void *msg);
+extern void CsrWifiSmeBlacklistCfmSerFree(void *msg);
+
+extern u8* CsrWifiSmeCalibrationDataGetCfmSer(u8 *ptr, size_t *len, void *msg);
+extern void* CsrWifiSmeCalibrationDataGetCfmDes(u8 *buffer, size_t len);
+extern size_t CsrWifiSmeCalibrationDataGetCfmSizeof(void *msg);
+extern void CsrWifiSmeCalibrationDataGetCfmSerFree(void *msg);
+
+#define CsrWifiSmeCalibrationDataSetCfmSer CsrWifiEventCsrUint16Ser
+#define CsrWifiSmeCalibrationDataSetCfmDes CsrWifiEventCsrUint16Des
+#define CsrWifiSmeCalibrationDataSetCfmSizeof CsrWifiEventCsrUint16Sizeof
+#define CsrWifiSmeCalibrationDataSetCfmSerFree CsrWifiSmePfree
+
+extern u8* CsrWifiSmeCcxConfigGetCfmSer(u8 *ptr, size_t *len, void *msg);
+extern void* CsrWifiSmeCcxConfigGetCfmDes(u8 *buffer, size_t len);
+extern size_t CsrWifiSmeCcxConfigGetCfmSizeof(void *msg);
+#define CsrWifiSmeCcxConfigGetCfmSerFree CsrWifiSmePfree
+
+extern u8* CsrWifiSmeCcxConfigSetCfmSer(u8 *ptr, size_t *len, void *msg);
+extern void* CsrWifiSmeCcxConfigSetCfmDes(u8 *buffer, size_t len);
+extern size_t CsrWifiSmeCcxConfigSetCfmSizeof(void *msg);
+#define CsrWifiSmeCcxConfigSetCfmSerFree CsrWifiSmePfree
+
+extern u8* CsrWifiSmeCoexConfigGetCfmSer(u8 *ptr, size_t *len, void *msg);
+extern void* CsrWifiSmeCoexConfigGetCfmDes(u8 *buffer, size_t len);
+extern size_t CsrWifiSmeCoexConfigGetCfmSizeof(void *msg);
+#define CsrWifiSmeCoexConfigGetCfmSerFree CsrWifiSmePfree
+
+#define CsrWifiSmeCoexConfigSetCfmSer CsrWifiEventCsrUint16Ser
+#define CsrWifiSmeCoexConfigSetCfmDes CsrWifiEventCsrUint16Des
+#define CsrWifiSmeCoexConfigSetCfmSizeof CsrWifiEventCsrUint16Sizeof
+#define CsrWifiSmeCoexConfigSetCfmSerFree CsrWifiSmePfree
+
+extern u8* CsrWifiSmeCoexInfoGetCfmSer(u8 *ptr, size_t *len, void *msg);
+extern void* CsrWifiSmeCoexInfoGetCfmDes(u8 *buffer, size_t len);
+extern size_t CsrWifiSmeCoexInfoGetCfmSizeof(void *msg);
+#define CsrWifiSmeCoexInfoGetCfmSerFree CsrWifiSmePfree
+
+extern u8* CsrWifiSmeConnectCfmSer(u8 *ptr, size_t *len, void *msg);
+extern void* CsrWifiSmeConnectCfmDes(u8 *buffer, size_t len);
+extern size_t CsrWifiSmeConnectCfmSizeof(void *msg);
+#define CsrWifiSmeConnectCfmSerFree CsrWifiSmePfree
+
+extern u8* CsrWifiSmeConnectionConfigGetCfmSer(u8 *ptr, size_t *len, void *msg);
+extern void* CsrWifiSmeConnectionConfigGetCfmDes(u8 *buffer, size_t len);
+extern size_t CsrWifiSmeConnectionConfigGetCfmSizeof(void *msg);
+extern void CsrWifiSmeConnectionConfigGetCfmSerFree(void *msg);
+
+extern u8* CsrWifiSmeConnectionInfoGetCfmSer(u8 *ptr, size_t *len, void *msg);
+extern void* CsrWifiSmeConnectionInfoGetCfmDes(u8 *buffer, size_t len);
+extern size_t CsrWifiSmeConnectionInfoGetCfmSizeof(void *msg);
+extern void CsrWifiSmeConnectionInfoGetCfmSerFree(void *msg);
+
+extern u8* CsrWifiSmeConnectionQualityIndSer(u8 *ptr, size_t *len, void *msg);
+extern void* CsrWifiSmeConnectionQualityIndDes(u8 *buffer, size_t len);
+extern size_t CsrWifiSmeConnectionQualityIndSizeof(void *msg);
+#define CsrWifiSmeConnectionQualityIndSerFree CsrWifiSmePfree
+
+extern u8* CsrWifiSmeConnectionStatsGetCfmSer(u8 *ptr, size_t *len, void *msg);
+extern void* CsrWifiSmeConnectionStatsGetCfmDes(u8 *buffer, size_t len);
+extern size_t CsrWifiSmeConnectionStatsGetCfmSizeof(void *msg);
+#define CsrWifiSmeConnectionStatsGetCfmSerFree CsrWifiSmePfree
+
+#define CsrWifiSmeDeactivateCfmSer CsrWifiEventCsrUint16Ser
+#define CsrWifiSmeDeactivateCfmDes CsrWifiEventCsrUint16Des
+#define CsrWifiSmeDeactivateCfmSizeof CsrWifiEventCsrUint16Sizeof
+#define CsrWifiSmeDeactivateCfmSerFree CsrWifiSmePfree
+
+extern u8* CsrWifiSmeDisconnectCfmSer(u8 *ptr, size_t *len, void *msg);
+extern void* CsrWifiSmeDisconnectCfmDes(u8 *buffer, size_t len);
+extern size_t CsrWifiSmeDisconnectCfmSizeof(void *msg);
+#define CsrWifiSmeDisconnectCfmSerFree CsrWifiSmePfree
+
+#define CsrWifiSmeEventMaskSetCfmSer CsrWifiEventCsrUint16Ser
+#define CsrWifiSmeEventMaskSetCfmDes CsrWifiEventCsrUint16Des
+#define CsrWifiSmeEventMaskSetCfmSizeof CsrWifiEventCsrUint16Sizeof
+#define CsrWifiSmeEventMaskSetCfmSerFree CsrWifiSmePfree
+
+extern u8* CsrWifiSmeHostConfigGetCfmSer(u8 *ptr, size_t *len, void *msg);
+extern void* CsrWifiSmeHostConfigGetCfmDes(u8 *buffer, size_t len);
+extern size_t CsrWifiSmeHostConfigGetCfmSizeof(void *msg);
+#define CsrWifiSmeHostConfigGetCfmSerFree CsrWifiSmePfree
+
+extern u8* CsrWifiSmeHostConfigSetCfmSer(u8 *ptr, size_t *len, void *msg);
+extern void* CsrWifiSmeHostConfigSetCfmDes(u8 *buffer, size_t len);
+extern size_t CsrWifiSmeHostConfigSetCfmSizeof(void *msg);
+#define CsrWifiSmeHostConfigSetCfmSerFree CsrWifiSmePfree
+
+extern u8* CsrWifiSmeIbssStationIndSer(u8 *ptr, size_t *len, void *msg);
+extern void* CsrWifiSmeIbssStationIndDes(u8 *buffer, size_t len);
+extern size_t CsrWifiSmeIbssStationIndSizeof(void *msg);
+#define CsrWifiSmeIbssStationIndSerFree CsrWifiSmePfree
+
+extern u8* CsrWifiSmeKeyCfmSer(u8 *ptr, size_t *len, void *msg);
+extern void* CsrWifiSmeKeyCfmDes(u8 *buffer, size_t len);
+extern size_t CsrWifiSmeKeyCfmSizeof(void *msg);
+#define CsrWifiSmeKeyCfmSerFree CsrWifiSmePfree
+
+extern u8* CsrWifiSmeLinkQualityGetCfmSer(u8 *ptr, size_t *len, void *msg);
+extern void* CsrWifiSmeLinkQualityGetCfmDes(u8 *buffer, size_t len);
+extern size_t CsrWifiSmeLinkQualityGetCfmSizeof(void *msg);
+#define CsrWifiSmeLinkQualityGetCfmSerFree CsrWifiSmePfree
+
+extern u8* CsrWifiSmeMediaStatusIndSer(u8 *ptr, size_t *len, void *msg);
+extern void* CsrWifiSmeMediaStatusIndDes(u8 *buffer, size_t len);
+extern size_t CsrWifiSmeMediaStatusIndSizeof(void *msg);
+extern void CsrWifiSmeMediaStatusIndSerFree(void *msg);
+
+extern u8* CsrWifiSmeMibConfigGetCfmSer(u8 *ptr, size_t *len, void *msg);
+extern void* CsrWifiSmeMibConfigGetCfmDes(u8 *buffer, size_t len);
+extern size_t CsrWifiSmeMibConfigGetCfmSizeof(void *msg);
+#define CsrWifiSmeMibConfigGetCfmSerFree CsrWifiSmePfree
+
+#define CsrWifiSmeMibConfigSetCfmSer CsrWifiEventCsrUint16Ser
+#define CsrWifiSmeMibConfigSetCfmDes CsrWifiEventCsrUint16Des
+#define CsrWifiSmeMibConfigSetCfmSizeof CsrWifiEventCsrUint16Sizeof
+#define CsrWifiSmeMibConfigSetCfmSerFree CsrWifiSmePfree
+
+extern u8* CsrWifiSmeMibGetCfmSer(u8 *ptr, size_t *len, void *msg);
+extern void* CsrWifiSmeMibGetCfmDes(u8 *buffer, size_t len);
+extern size_t CsrWifiSmeMibGetCfmSizeof(void *msg);
+extern void CsrWifiSmeMibGetCfmSerFree(void *msg);
+
+extern u8* CsrWifiSmeMibGetNextCfmSer(u8 *ptr, size_t *len, void *msg);
+extern void* CsrWifiSmeMibGetNextCfmDes(u8 *buffer, size_t len);
+extern size_t CsrWifiSmeMibGetNextCfmSizeof(void *msg);
+extern void CsrWifiSmeMibGetNextCfmSerFree(void *msg);
+
+#define CsrWifiSmeMibSetCfmSer CsrWifiEventCsrUint16Ser
+#define CsrWifiSmeMibSetCfmDes CsrWifiEventCsrUint16Des
+#define CsrWifiSmeMibSetCfmSizeof CsrWifiEventCsrUint16Sizeof
+#define CsrWifiSmeMibSetCfmSerFree CsrWifiSmePfree
+
+extern u8* CsrWifiSmeMicFailureIndSer(u8 *ptr, size_t *len, void *msg);
+extern void* CsrWifiSmeMicFailureIndDes(u8 *buffer, size_t len);
+extern size_t CsrWifiSmeMicFailureIndSizeof(void *msg);
+#define CsrWifiSmeMicFailureIndSerFree CsrWifiSmePfree
+
+extern u8* CsrWifiSmeMulticastAddressCfmSer(u8 *ptr, size_t *len, void *msg);
+extern void* CsrWifiSmeMulticastAddressCfmDes(u8 *buffer, size_t len);
+extern size_t CsrWifiSmeMulticastAddressCfmSizeof(void *msg);
+extern void CsrWifiSmeMulticastAddressCfmSerFree(void *msg);
+
+extern u8* CsrWifiSmePacketFilterSetCfmSer(u8 *ptr, size_t *len, void *msg);
+extern void* CsrWifiSmePacketFilterSetCfmDes(u8 *buffer, size_t len);
+extern size_t CsrWifiSmePacketFilterSetCfmSizeof(void *msg);
+#define CsrWifiSmePacketFilterSetCfmSerFree CsrWifiSmePfree
+
+extern u8* CsrWifiSmePermanentMacAddressGetCfmSer(u8 *ptr, size_t *len, void *msg);
+extern void* CsrWifiSmePermanentMacAddressGetCfmDes(u8 *buffer, size_t len);
+extern size_t CsrWifiSmePermanentMacAddressGetCfmSizeof(void *msg);
+#define CsrWifiSmePermanentMacAddressGetCfmSerFree CsrWifiSmePfree
+
+extern u8* CsrWifiSmePmkidCandidateListIndSer(u8 *ptr, size_t *len, void *msg);
+extern void* CsrWifiSmePmkidCandidateListIndDes(u8 *buffer, size_t len);
+extern size_t CsrWifiSmePmkidCandidateListIndSizeof(void *msg);
+extern void CsrWifiSmePmkidCandidateListIndSerFree(void *msg);
+
+extern u8* CsrWifiSmePmkidCfmSer(u8 *ptr, size_t *len, void *msg);
+extern void* CsrWifiSmePmkidCfmDes(u8 *buffer, size_t len);
+extern size_t CsrWifiSmePmkidCfmSizeof(void *msg);
+extern void CsrWifiSmePmkidCfmSerFree(void *msg);
+
+extern u8* CsrWifiSmePowerConfigGetCfmSer(u8 *ptr, size_t *len, void *msg);
+extern void* CsrWifiSmePowerConfigGetCfmDes(u8 *buffer, size_t len);
+extern size_t CsrWifiSmePowerConfigGetCfmSizeof(void *msg);
+#define CsrWifiSmePowerConfigGetCfmSerFree CsrWifiSmePfree
+
+#define CsrWifiSmePowerConfigSetCfmSer CsrWifiEventCsrUint16Ser
+#define CsrWifiSmePowerConfigSetCfmDes CsrWifiEventCsrUint16Des
+#define CsrWifiSmePowerConfigSetCfmSizeof CsrWifiEventCsrUint16Sizeof
+#define CsrWifiSmePowerConfigSetCfmSerFree CsrWifiSmePfree
+
+extern u8* CsrWifiSmeRegulatoryDomainInfoGetCfmSer(u8 *ptr, size_t *len, void *msg);
+extern void* CsrWifiSmeRegulatoryDomainInfoGetCfmDes(u8 *buffer, size_t len);
+extern size_t CsrWifiSmeRegulatoryDomainInfoGetCfmSizeof(void *msg);
+#define CsrWifiSmeRegulatoryDomainInfoGetCfmSerFree CsrWifiSmePfree
+
+extern u8* CsrWifiSmeRoamCompleteIndSer(u8 *ptr, size_t *len, void *msg);
+extern void* CsrWifiSmeRoamCompleteIndDes(u8 *buffer, size_t len);
+extern size_t CsrWifiSmeRoamCompleteIndSizeof(void *msg);
+#define CsrWifiSmeRoamCompleteIndSerFree CsrWifiSmePfree
+
+extern u8* CsrWifiSmeRoamStartIndSer(u8 *ptr, size_t *len, void *msg);
+extern void* CsrWifiSmeRoamStartIndDes(u8 *buffer, size_t len);
+extern size_t CsrWifiSmeRoamStartIndSizeof(void *msg);
+#define CsrWifiSmeRoamStartIndSerFree CsrWifiSmePfree
+
+extern u8* CsrWifiSmeRoamingConfigGetCfmSer(u8 *ptr, size_t *len, void *msg);
+extern void* CsrWifiSmeRoamingConfigGetCfmDes(u8 *buffer, size_t len);
+extern size_t CsrWifiSmeRoamingConfigGetCfmSizeof(void *msg);
+#define CsrWifiSmeRoamingConfigGetCfmSerFree CsrWifiSmePfree
+
+extern u8* CsrWifiSmeRoamingConfigSetCfmSer(u8 *ptr, size_t *len, void *msg);
+extern void* CsrWifiSmeRoamingConfigSetCfmDes(u8 *buffer, size_t len);
+extern size_t CsrWifiSmeRoamingConfigSetCfmSizeof(void *msg);
+#define CsrWifiSmeRoamingConfigSetCfmSerFree CsrWifiSmePfree
+
+extern u8* CsrWifiSmeScanConfigGetCfmSer(u8 *ptr, size_t *len, void *msg);
+extern void* CsrWifiSmeScanConfigGetCfmDes(u8 *buffer, size_t len);
+extern size_t CsrWifiSmeScanConfigGetCfmSizeof(void *msg);
+extern void CsrWifiSmeScanConfigGetCfmSerFree(void *msg);
+
+#define CsrWifiSmeScanConfigSetCfmSer CsrWifiEventCsrUint16Ser
+#define CsrWifiSmeScanConfigSetCfmDes CsrWifiEventCsrUint16Des
+#define CsrWifiSmeScanConfigSetCfmSizeof CsrWifiEventCsrUint16Sizeof
+#define CsrWifiSmeScanConfigSetCfmSerFree CsrWifiSmePfree
+
+#define CsrWifiSmeScanFullCfmSer CsrWifiEventCsrUint16Ser
+#define CsrWifiSmeScanFullCfmDes CsrWifiEventCsrUint16Des
+#define CsrWifiSmeScanFullCfmSizeof CsrWifiEventCsrUint16Sizeof
+#define CsrWifiSmeScanFullCfmSerFree CsrWifiSmePfree
+
+extern u8* CsrWifiSmeScanResultIndSer(u8 *ptr, size_t *len, void *msg);
+extern void* CsrWifiSmeScanResultIndDes(u8 *buffer, size_t len);
+extern size_t CsrWifiSmeScanResultIndSizeof(void *msg);
+extern void CsrWifiSmeScanResultIndSerFree(void *msg);
+
+#define CsrWifiSmeScanResultsFlushCfmSer CsrWifiEventCsrUint16Ser
+#define CsrWifiSmeScanResultsFlushCfmDes CsrWifiEventCsrUint16Des
+#define CsrWifiSmeScanResultsFlushCfmSizeof CsrWifiEventCsrUint16Sizeof
+#define CsrWifiSmeScanResultsFlushCfmSerFree CsrWifiSmePfree
+
+extern u8* CsrWifiSmeScanResultsGetCfmSer(u8 *ptr, size_t *len, void *msg);
+extern void* CsrWifiSmeScanResultsGetCfmDes(u8 *buffer, size_t len);
+extern size_t CsrWifiSmeScanResultsGetCfmSizeof(void *msg);
+extern void CsrWifiSmeScanResultsGetCfmSerFree(void *msg);
+
+extern u8* CsrWifiSmeSmeStaConfigGetCfmSer(u8 *ptr, size_t *len, void *msg);
+extern void* CsrWifiSmeSmeStaConfigGetCfmDes(u8 *buffer, size_t len);
+extern size_t CsrWifiSmeSmeStaConfigGetCfmSizeof(void *msg);
+#define CsrWifiSmeSmeStaConfigGetCfmSerFree CsrWifiSmePfree
+
+extern u8* CsrWifiSmeSmeStaConfigSetCfmSer(u8 *ptr, size_t *len, void *msg);
+extern void* CsrWifiSmeSmeStaConfigSetCfmDes(u8 *buffer, size_t len);
+extern size_t CsrWifiSmeSmeStaConfigSetCfmSizeof(void *msg);
+#define CsrWifiSmeSmeStaConfigSetCfmSerFree CsrWifiSmePfree
+
+extern u8* CsrWifiSmeStationMacAddressGetCfmSer(u8 *ptr, size_t *len, void *msg);
+extern void* CsrWifiSmeStationMacAddressGetCfmDes(u8 *buffer, size_t len);
+extern size_t CsrWifiSmeStationMacAddressGetCfmSizeof(void *msg);
+#define CsrWifiSmeStationMacAddressGetCfmSerFree CsrWifiSmePfree
+
+extern u8* CsrWifiSmeTspecIndSer(u8 *ptr, size_t *len, void *msg);
+extern void* CsrWifiSmeTspecIndDes(u8 *buffer, size_t len);
+extern size_t CsrWifiSmeTspecIndSizeof(void *msg);
+extern void CsrWifiSmeTspecIndSerFree(void *msg);
+
+extern u8* CsrWifiSmeTspecCfmSer(u8 *ptr, size_t *len, void *msg);
+extern void* CsrWifiSmeTspecCfmDes(u8 *buffer, size_t len);
+extern size_t CsrWifiSmeTspecCfmSizeof(void *msg);
+extern void CsrWifiSmeTspecCfmSerFree(void *msg);
+
+extern u8* CsrWifiSmeVersionsGetCfmSer(u8 *ptr, size_t *len, void *msg);
+extern void* CsrWifiSmeVersionsGetCfmDes(u8 *buffer, size_t len);
+extern size_t CsrWifiSmeVersionsGetCfmSizeof(void *msg);
+extern void CsrWifiSmeVersionsGetCfmSerFree(void *msg);
+
+#define CsrWifiSmeWifiFlightmodeCfmSer CsrWifiEventCsrUint16Ser
+#define CsrWifiSmeWifiFlightmodeCfmDes CsrWifiEventCsrUint16Des
+#define CsrWifiSmeWifiFlightmodeCfmSizeof CsrWifiEventCsrUint16Sizeof
+#define CsrWifiSmeWifiFlightmodeCfmSerFree CsrWifiSmePfree
+
+#define CsrWifiSmeWifiOffIndSer CsrWifiEventCsrUint8Ser
+#define CsrWifiSmeWifiOffIndDes CsrWifiEventCsrUint8Des
+#define CsrWifiSmeWifiOffIndSizeof CsrWifiEventCsrUint8Sizeof
+#define CsrWifiSmeWifiOffIndSerFree CsrWifiSmePfree
+
+#define CsrWifiSmeWifiOffCfmSer CsrWifiEventCsrUint16Ser
+#define CsrWifiSmeWifiOffCfmDes CsrWifiEventCsrUint16Des
+#define CsrWifiSmeWifiOffCfmSizeof CsrWifiEventCsrUint16Sizeof
+#define CsrWifiSmeWifiOffCfmSerFree CsrWifiSmePfree
+
+#define CsrWifiSmeWifiOnCfmSer CsrWifiEventCsrUint16Ser
+#define CsrWifiSmeWifiOnCfmDes CsrWifiEventCsrUint16Des
+#define CsrWifiSmeWifiOnCfmSizeof CsrWifiEventCsrUint16Sizeof
+#define CsrWifiSmeWifiOnCfmSerFree CsrWifiSmePfree
+
+#define CsrWifiSmeCloakedSsidsSetCfmSer CsrWifiEventCsrUint16Ser
+#define CsrWifiSmeCloakedSsidsSetCfmDes CsrWifiEventCsrUint16Des
+#define CsrWifiSmeCloakedSsidsSetCfmSizeof CsrWifiEventCsrUint16Sizeof
+#define CsrWifiSmeCloakedSsidsSetCfmSerFree CsrWifiSmePfree
+
+extern u8* CsrWifiSmeCloakedSsidsGetCfmSer(u8 *ptr, size_t *len, void *msg);
+extern void* CsrWifiSmeCloakedSsidsGetCfmDes(u8 *buffer, size_t len);
+extern size_t CsrWifiSmeCloakedSsidsGetCfmSizeof(void *msg);
+extern void CsrWifiSmeCloakedSsidsGetCfmSerFree(void *msg);
+
+extern u8* CsrWifiSmeWifiOnIndSer(u8 *ptr, size_t *len, void *msg);
+extern void* CsrWifiSmeWifiOnIndDes(u8 *buffer, size_t len);
+extern size_t CsrWifiSmeWifiOnIndSizeof(void *msg);
+#define CsrWifiSmeWifiOnIndSerFree CsrWifiSmePfree
+
+extern u8* CsrWifiSmeSmeCommonConfigGetCfmSer(u8 *ptr, size_t *len, void *msg);
+extern void* CsrWifiSmeSmeCommonConfigGetCfmDes(u8 *buffer, size_t len);
+extern size_t CsrWifiSmeSmeCommonConfigGetCfmSizeof(void *msg);
+#define CsrWifiSmeSmeCommonConfigGetCfmSerFree CsrWifiSmePfree
+
+#define CsrWifiSmeSmeCommonConfigSetCfmSer CsrWifiEventCsrUint16Ser
+#define CsrWifiSmeSmeCommonConfigSetCfmDes CsrWifiEventCsrUint16Des
+#define CsrWifiSmeSmeCommonConfigSetCfmSizeof CsrWifiEventCsrUint16Sizeof
+#define CsrWifiSmeSmeCommonConfigSetCfmSerFree CsrWifiSmePfree
+
+extern u8* CsrWifiSmeInterfaceCapabilityGetCfmSer(u8 *ptr, size_t *len, void *msg);
+extern void* CsrWifiSmeInterfaceCapabilityGetCfmDes(u8 *buffer, size_t len);
+extern size_t CsrWifiSmeInterfaceCapabilityGetCfmSizeof(void *msg);
+#define CsrWifiSmeInterfaceCapabilityGetCfmSerFree CsrWifiSmePfree
+
+extern u8* CsrWifiSmeErrorIndSer(u8 *ptr, size_t *len, void *msg);
+extern void* CsrWifiSmeErrorIndDes(u8 *buffer, size_t len);
+extern size_t CsrWifiSmeErrorIndSizeof(void *msg);
+extern void CsrWifiSmeErrorIndSerFree(void *msg);
+
+extern u8* CsrWifiSmeInfoIndSer(u8 *ptr, size_t *len, void *msg);
+extern void* CsrWifiSmeInfoIndDes(u8 *buffer, size_t len);
+extern size_t CsrWifiSmeInfoIndSizeof(void *msg);
+extern void CsrWifiSmeInfoIndSerFree(void *msg);
+
+extern u8* CsrWifiSmeCoreDumpIndSer(u8 *ptr, size_t *len, void *msg);
+extern void* CsrWifiSmeCoreDumpIndDes(u8 *buffer, size_t len);
+extern size_t CsrWifiSmeCoreDumpIndSizeof(void *msg);
+extern void CsrWifiSmeCoreDumpIndSerFree(void *msg);
+
+#define CsrWifiSmeAmpStatusChangeIndSer CsrWifiEventCsrUint16CsrUint8Ser
+#define CsrWifiSmeAmpStatusChangeIndDes CsrWifiEventCsrUint16CsrUint8Des
+#define CsrWifiSmeAmpStatusChangeIndSizeof CsrWifiEventCsrUint16CsrUint8Sizeof
+#define CsrWifiSmeAmpStatusChangeIndSerFree CsrWifiSmePfree
+
+#define CsrWifiSmeWpsConfigurationCfmSer CsrWifiEventCsrUint16Ser
+#define CsrWifiSmeWpsConfigurationCfmDes CsrWifiEventCsrUint16Des
+#define CsrWifiSmeWpsConfigurationCfmSizeof CsrWifiEventCsrUint16Sizeof
+#define CsrWifiSmeWpsConfigurationCfmSerFree CsrWifiSmePfree
+
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* CSR_WIFI_SME_SERIALIZE_H__ */
+
diff --git a/drivers/staging/csr/csr_wifi_sme_task.h b/drivers/staging/csr/csr_wifi_sme_task.h
new file mode 100644
index 000000000000..0f725e454939
--- /dev/null
+++ b/drivers/staging/csr/csr_wifi_sme_task.h
@@ -0,0 +1,33 @@
+/*****************************************************************************
+
+ (c) Cambridge Silicon Radio Limited 2011
+ All rights reserved and confidential information of CSR
+
+ Refer to LICENSE.txt included with this source for details
+ on the license terms.
+
+*****************************************************************************/
+
+/* Note: this is an auto-generated file. */
+
+#ifndef CSR_WIFI_SME_TASK_H__
+#define CSR_WIFI_SME_TASK_H__
+
+#include "csr_sched.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define CSR_WIFI_SME_LOG_ID 0x1202FFFF
+extern CsrSchedQid CSR_WIFI_SME_IFACEQUEUE;
+void CsrWifiSmeInit(void **gash);
+void CsrWifiSmeDeinit(void **gash);
+void CsrWifiSmeHandler(void **gash);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* CSR_WIFI_SME_TASK_H__ */
+
diff --git a/drivers/staging/csr/csr_wifi_vif_utils.h b/drivers/staging/csr/csr_wifi_vif_utils.h
new file mode 100644
index 000000000000..523172d1ac92
--- /dev/null
+++ b/drivers/staging/csr/csr_wifi_vif_utils.h
@@ -0,0 +1,108 @@
+/*****************************************************************************
+
+ (c) Cambridge Silicon Radio Limited 2011
+ All rights reserved and confidential information of CSR
+
+ Refer to LICENSE.txt included with this source for details
+ on the license terms.
+
+*****************************************************************************/
+
+#ifndef CSR_WIFI_VIF_UTILS_H
+#define CSR_WIFI_VIF_UTILS_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* STANDARD INCLUDES ********************************************************/
+
+/* PROJECT INCLUDES *********************************************************/
+/* including this file for CsrWifiInterfaceMode*/
+#include "csr_wifi_private_common.h"
+
+/* MACROS *******************************************************************/
+
+/* Common macros for NME and SME to be used temporarily until SoftMAC changes are made */
+#define CSR_WIFI_NUM_INTERFACES (u8)0x1
+#define CSR_WIFI_INTERFACE_IN_USE (u16)0x0
+
+/* This is used at places where interface Id isn't available*/
+#define CSR_WIFI_INTERFACE_ZERO 0
+#define CSR_WIFI_INTERFACE_STA 0
+#define CSR_WIFI_INTERFACE_AMP 0
+
+
+#define CSR_WIFI_VIF_UTILS_UNDEFINED_TAG 0xFFFF
+
+/* Extract the Interface Id from the event */
+#define CsrWifiVifUtilsGetVifTagFromEvent(msg) \
+ ((u16) * ((u16 *) ((u8 *) (msg) + sizeof(CsrWifiFsmEvent))))
+
+/* The HPI Vif combines the type and the interface id */
+#define CsrWifiVifUtilsGetVifTagFromHipEvent(msg) \
+ ((msg)->virtualInterfaceIdentifier & 0x00FF)
+
+#define CsrWifiVifUtilsPackHipEventVif(type, interfaceId) \
+ ((u16)((interfaceId) | ((type) << 8)))
+
+
+/* TYPES DEFINITIONS ********************************************************/
+
+/* GLOBAL VARIABLE DECLARATIONS *********************************************/
+
+/* PUBLIC FUNCTION PROTOTYPES ***********************************************/
+
+/**
+ * @brief
+ * First checks if the mode is supported capability bitmap of the interface.
+ * If this succeeds, then checks if running this mode on this interface is allowed.
+ *
+ * @param[in] u8 : interface capability bitmap
+ * @param[in] u8* : pointer to the array of current interface modes
+ * @param[in] u16 : interfaceTag
+ * @param[in] CsrWifiInterfaceMode : mode
+ *
+ * @return
+ * u8 : returns true if the interface is allowed to operate in the mode otherwise false.
+ */
+extern u8 CsrWifiVifUtilsCheckCompatibility(u8 interfaceCapability,
+ u8 *currentInterfaceModes,
+ u16 interfaceTag,
+ CsrWifiInterfaceMode mode);
+
+/**
+ * @brief
+ * Checks if the specified interface is supported.
+ * NOTE: Only checks that the interface is supported, no checks are made to
+ * determine whether a supported interface may be made active.
+ *
+ * @param[in] u16 : interfaceTag
+ *
+ * @return
+ * u8 : returns true if the interface is supported, otherwise false.
+ */
+extern u8 CsrWifiVifUtilsIsSupported(u16 interfaceTag);
+
+#ifdef CSR_LOG_ENABLE
+/**
+ * @brief
+ * Registers the virtual interface utils logging details.
+ * Should only be called once at initialisation.
+ *
+ * @param[in/out] None
+ *
+ * @return
+ * None
+ */
+void CsrWifiVifUtilsLogTextRegister(void);
+#else
+#define CsrWifiVifUtilsLogTextRegister()
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* CSR_WIFI_VIF_UTILS_H */
+
diff --git a/drivers/staging/csr/data_tx.c b/drivers/staging/csr/data_tx.c
new file mode 100644
index 000000000000..8ed7a7845cc6
--- /dev/null
+++ b/drivers/staging/csr/data_tx.c
@@ -0,0 +1,57 @@
+/*
+ * ---------------------------------------------------------------------------
+ * FILE: data_tx.c
+ *
+ * PURPOSE:
+ * This file provides functions to send data requests to the UniFi.
+ *
+ * Copyright (C) 2007-2009 by Cambridge Silicon Radio Ltd.
+ *
+ * Refer to LICENSE.txt included with this source code for details on
+ * the license terms.
+ *
+ * ---------------------------------------------------------------------------
+ */
+#include "csr_wifi_hip_unifi.h"
+#include "unifi_priv.h"
+
+int
+uf_verify_m4(unifi_priv_t *priv, const unsigned char *packet, unsigned int length)
+{
+ const unsigned char *p = packet;
+ u16 keyinfo;
+
+
+ if (length < (4 + 5 + 8 + 32 + 16 + 8 + 8 + 16 + 1 + 8)) {
+ return 1;
+ }
+
+ p += 8;
+ keyinfo = p[5] << 8 | p[6]; /* big-endian */
+ if (
+ (p[0] == 1 || p[0] == 2) /* protocol version 802.1X-2001 (WPA) or -2004 (WPA2) */ &&
+ p[1] == 3 /* EAPOL-Key */ &&
+ /* don't bother checking p[2] p[3] (hh ll, packet body length) */
+ (p[4] == 254 || p[4] == 2) /* descriptor type P802.1i-D3.0 (WPA) or 802.11i-2004 (WPA2) */ &&
+ ((keyinfo & 0x0007) == 1 || (keyinfo & 0x0007) == 2) /* key descriptor version */ &&
+ (keyinfo & ~0x0207U) == 0x0108 && /* key info for 4/4 or 4/2 -- ignore key desc version and sec bit (since varies in WPA 4/4) */
+ (p[4 + 5 + 8 + 32 + 16 + 8 + 8 + 16 + 0] == 0 && /* key data length (2 octets) 0 for 4/4 only */
+ p[4 + 5 + 8 + 32 + 16 + 8 + 8 + 16 + 1] == 0)
+ ) {
+ unifi_trace(priv, UDBG1, "uf_verify_m4: M4 detected \n");
+ return 0;
+ }
+ else
+ {
+ return 1;
+ }
+}
+
+/*
+ * ---------------------------------------------------------------------------
+ *
+ * Data transport signals.
+ *
+ * ---------------------------------------------------------------------------
+ */
+
diff --git a/drivers/staging/csr/drv.c b/drivers/staging/csr/drv.c
new file mode 100644
index 000000000000..b2c27f4f03d4
--- /dev/null
+++ b/drivers/staging/csr/drv.c
@@ -0,0 +1,2262 @@
+/*
+ * ---------------------------------------------------------------------------
+ * FILE: drv.c
+ *
+ * PURPOSE:
+ * Conventional device interface for debugging/monitoring of the
+ * driver and h/w using unicli. This interface is also being used
+ * by the SME linux implementation and the helper apps.
+ *
+ * Copyright (C) 2005-2009 by Cambridge Silicon Radio Ltd.
+ *
+ * Refer to LICENSE.txt included with this source code for details on
+ * the license terms.
+ *
+ * ---------------------------------------------------------------------------
+ */
+
+
+
+/*
+ * Porting Notes:
+ * Part of this file contains an example for how to glue the OS layer
+ * with the HIP core lib, the SDIO glue layer, and the SME.
+ *
+ * When the unifi_sdio.ko modules loads, the linux kernel calls unifi_load().
+ * unifi_load() calls uf_sdio_load() which is exported by the SDIO glue
+ * layer. uf_sdio_load() registers this driver with the underlying SDIO driver.
+ * When a card is detected, the SDIO glue layer calls register_unifi_sdio()
+ * to pass the SDIO function context and ask the OS layer to initialise
+ * the card. register_unifi_sdio() allocates all the private data of the OS
+ * layer and calls uf_run_unifihelper() to start the SME. The SME calls
+ * unifi_sys_wifi_on_req() which uses the HIP core lib to initialise the card.
+ */
+
+#include <linux/init.h>
+#include <linux/slab.h>
+#include <linux/poll.h>
+#include <asm/uaccess.h>
+#include <linux/jiffies.h>
+
+#include "csr_wifi_hip_unifiversion.h"
+#include "unifi_priv.h"
+#include "csr_wifi_hip_conversions.h"
+#include "unifi_native.h"
+
+/* Module parameter variables */
+int buswidth = 0; /* 0 means use default, values 1,4 */
+int sdio_clock = 50000; /* kHz */
+int unifi_debug = 0;
+/* fw_init prevents f/w initialisation on error. */
+int fw_init[MAX_UNIFI_DEVS] = {-1, -1};
+int use_5g = 0;
+int led_mask = 0; /* 0x0c00 for dev-pc-1503c, dev-pc-1528a */
+int disable_hw_reset = 0;
+int disable_power_control = 0;
+int enable_wol = UNIFI_WOL_OFF; /* 0 for none, 1 for SDIO IRQ, 2 for PIO */
+#if (defined CSR_SUPPORT_SME) && (defined CSR_SUPPORT_WEXT)
+int tl_80211d = (int)CSR_WIFI_SME_80211D_TRUST_LEVEL_MIB;
+#endif
+int sdio_block_size = -1; /* Override SDIO block size */
+int sdio_byte_mode = 0; /* 0 for block mode + padding, 1 for byte mode */
+int coredump_max = CSR_WIFI_HIP_NUM_COREDUMP_BUFFERS;
+int run_bh_once = -1; /* Set for scheduled interrupt mode, -1 = default */
+int bh_priority = -1;
+#ifdef CSR_WIFI_HIP_DEBUG_OFFLINE
+#define UNIFI_LOG_HIP_SIGNALS_FILTER_BULKDATA (1 << 1)
+#define UNIFI_LOG_HIP_SIGNALS_FILTER_TIMESTAMP (1 << 2)
+int log_hip_signals = 0;
+#endif
+
+MODULE_DESCRIPTION("CSR UniFi (SDIO)");
+
+module_param(buswidth, int, S_IRUGO|S_IWUSR);
+module_param(sdio_clock, int, S_IRUGO|S_IWUSR);
+module_param(unifi_debug, int, S_IRUGO|S_IWUSR);
+module_param_array(fw_init, int, NULL, S_IRUGO|S_IWUSR);
+module_param(use_5g, int, S_IRUGO|S_IWUSR);
+module_param(led_mask, int, S_IRUGO|S_IWUSR);
+module_param(disable_hw_reset, int, S_IRUGO|S_IWUSR);
+module_param(disable_power_control, int, S_IRUGO|S_IWUSR);
+module_param(enable_wol, int, S_IRUGO|S_IWUSR);
+#if (defined CSR_SUPPORT_SME) && (defined CSR_SUPPORT_WEXT)
+module_param(tl_80211d, int, S_IRUGO|S_IWUSR);
+#endif
+module_param(sdio_block_size, int, S_IRUGO|S_IWUSR);
+module_param(sdio_byte_mode, int, S_IRUGO|S_IWUSR);
+module_param(coredump_max, int, S_IRUGO|S_IWUSR);
+module_param(run_bh_once, int, S_IRUGO|S_IWUSR);
+module_param(bh_priority, int, S_IRUGO|S_IWUSR);
+#ifdef CSR_WIFI_HIP_DEBUG_OFFLINE
+module_param(log_hip_signals, int, S_IRUGO|S_IWUSR);
+#endif
+
+MODULE_PARM_DESC(buswidth, "SDIO bus width (0=default), set 1 for 1-bit or 4 for 4-bit mode");
+MODULE_PARM_DESC(sdio_clock, "SDIO bus frequency in kHz, (default = 50 MHz)");
+MODULE_PARM_DESC(unifi_debug, "Diagnostic reporting level");
+MODULE_PARM_DESC(fw_init, "Set to 0 to prevent f/w initialization on error");
+MODULE_PARM_DESC(use_5g, "Use the 5G (802.11a) radio band");
+MODULE_PARM_DESC(led_mask, "LED mask flags");
+MODULE_PARM_DESC(disable_hw_reset, "Set to 1 to disable hardware reset");
+MODULE_PARM_DESC(disable_power_control, "Set to 1 to disable SDIO power control");
+MODULE_PARM_DESC(enable_wol, "Enable wake-on-wlan function 0=off, 1=SDIO, 2=PIO");
+#if (defined CSR_SUPPORT_SME) && (defined CSR_SUPPORT_WEXT)
+MODULE_PARM_DESC(tl_80211d, "802.11d Trust Level (1-6, default = 5)");
+#endif
+MODULE_PARM_DESC(sdio_block_size, "Set to override SDIO block size");
+MODULE_PARM_DESC(sdio_byte_mode, "Set to 1 for byte mode SDIO");
+MODULE_PARM_DESC(coredump_max, "Number of chip mini-coredump buffers to allocate");
+MODULE_PARM_DESC(run_bh_once, "Run BH only when firmware interrupts");
+MODULE_PARM_DESC(bh_priority, "Modify the BH thread priority");
+#ifdef CSR_WIFI_HIP_DEBUG_OFFLINE
+MODULE_PARM_DESC(log_hip_signals, "Set to 1 to enable HIP signal offline logging");
+#endif
+
+
+/* Callback for event logging to UDI clients */
+static void udi_log_event(ul_client_t *client,
+ const u8 *signal, int signal_len,
+ const bulk_data_param_t *bulkdata,
+ int dir);
+
+static void udi_set_log_filter(ul_client_t *pcli,
+ unifiio_filter_t *udi_filter);
+
+
+/* Mutex to protect access to priv->sme_cli */
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 37)
+DEFINE_SEMAPHORE(udi_mutex);
+#else
+DECLARE_MUTEX(udi_mutex);
+#endif
+
+s32 CsrHipResultToStatus(CsrResult csrResult)
+{
+ s32 r = -EIO;
+
+ switch (csrResult)
+ {
+ case CSR_RESULT_SUCCESS:
+ r = 0;
+ break;
+ case CSR_WIFI_HIP_RESULT_RANGE:
+ r = -ERANGE;
+ break;
+ case CSR_WIFI_HIP_RESULT_NO_DEVICE:
+ r = -ENODEV;
+ break;
+ case CSR_WIFI_HIP_RESULT_INVALID_VALUE:
+ r = -EINVAL;
+ break;
+ case CSR_WIFI_HIP_RESULT_NOT_FOUND:
+ r = -ENOENT;
+ break;
+ case CSR_WIFI_HIP_RESULT_NO_SPACE:
+ r = -ENOSPC;
+ break;
+ case CSR_WIFI_HIP_RESULT_NO_MEMORY:
+ r = -ENOMEM;
+ break;
+ case CSR_RESULT_FAILURE:
+ r = -EIO;
+ break;
+ default:
+ /*unifi_warning(card->ospriv, "CsrHipResultToStatus: Unrecognised csrResult error code: %d\n", csrResult);*/
+ r = -EIO;
+ }
+ return r;
+}
+
+
+static const char*
+trace_putest_cmdid(unifi_putest_command_t putest_cmd)
+{
+ switch (putest_cmd)
+ {
+ case UNIFI_PUTEST_START:
+ return "START";
+ case UNIFI_PUTEST_STOP:
+ return "STOP";
+ case UNIFI_PUTEST_SET_SDIO_CLOCK:
+ return "SET CLOCK";
+ case UNIFI_PUTEST_CMD52_READ:
+ return "CMD52R";
+ case UNIFI_PUTEST_CMD52_BLOCK_READ:
+ return "CMD52BR";
+ case UNIFI_PUTEST_CMD52_WRITE:
+ return "CMD52W";
+ case UNIFI_PUTEST_DL_FW:
+ return "D/L FW";
+ case UNIFI_PUTEST_DL_FW_BUFF:
+ return "D/L FW BUFFER";
+ case UNIFI_PUTEST_COREDUMP_PREPARE:
+ return "PREPARE COREDUMP";
+ case UNIFI_PUTEST_GP_READ16:
+ return "GP16R";
+ case UNIFI_PUTEST_GP_WRITE16:
+ return "GP16W";
+ default:
+ return "ERROR: unrecognised command";
+ }
+ }
+
+#ifdef CSR_WIFI_HIP_DEBUG_OFFLINE
+int uf_register_hip_offline_debug(unifi_priv_t *priv)
+{
+ ul_client_t *udi_cli;
+ int i;
+
+ udi_cli = ul_register_client(priv, CLI_USING_WIRE_FORMAT, udi_log_event);
+ if (udi_cli == NULL) {
+ /* Too many clients already using this device */
+ unifi_error(priv, "Too many UDI clients already open\n");
+ return -ENOSPC;
+ }
+ unifi_trace(priv, UDBG1, "Offline HIP client is registered\n");
+
+ down(&priv->udi_logging_mutex);
+ udi_cli->event_hook = udi_log_event;
+ unifi_set_udi_hook(priv->card, logging_handler);
+ /* Log all signals by default */
+ for (i = 0; i < SIG_FILTER_SIZE; i++) {
+ udi_cli->signal_filter[i] = 0xFFFF;
+ }
+ priv->logging_client = udi_cli;
+ up(&priv->udi_logging_mutex);
+
+ return 0;
+}
+
+int uf_unregister_hip_offline_debug(unifi_priv_t *priv)
+{
+ ul_client_t *udi_cli = priv->logging_client;
+ if (udi_cli == NULL)
+ {
+ unifi_error(priv, "Unknown HIP client unregister request\n");
+ return -ERANGE;
+ }
+
+ unifi_trace(priv, UDBG1, "Offline HIP client is unregistered\n");
+
+ down(&priv->udi_logging_mutex);
+ priv->logging_client = NULL;
+ udi_cli->event_hook = NULL;
+ up(&priv->udi_logging_mutex);
+
+ ul_deregister_client(udi_cli);
+
+ return 0;
+}
+#endif
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * unifi_open
+ * unifi_release
+ *
+ * Open and release entry points for the UniFi debug driver.
+ *
+ * Arguments:
+ * Normal linux driver args.
+ *
+ * Returns:
+ * Linux error code.
+ * ---------------------------------------------------------------------------
+ */
+static int
+unifi_open(struct inode *inode, struct file *file)
+{
+ int devno;
+ unifi_priv_t *priv;
+ ul_client_t *udi_cli;
+
+ func_enter();
+
+ devno = MINOR(inode->i_rdev) >> 1;
+
+ /*
+ * Increase the ref_count for the char device clients.
+ * Make sure you call uf_put_instance() to decreace it if
+ * unifi_open returns an error.
+ */
+ priv = uf_get_instance(devno);
+ if (priv == NULL) {
+ unifi_error(NULL, "unifi_open: No device present\n");
+ func_exit();
+ return -ENODEV;
+ }
+
+ /* Register this instance in the client's list. */
+ /* The minor number determines the nature of the client (Unicli or SME). */
+ if (MINOR(inode->i_rdev) & 0x1) {
+ udi_cli = ul_register_client(priv, CLI_USING_WIRE_FORMAT, udi_log_event);
+ if (udi_cli == NULL) {
+ /* Too many clients already using this device */
+ unifi_error(priv, "Too many clients already open\n");
+ uf_put_instance(devno);
+ func_exit();
+ return -ENOSPC;
+ }
+ unifi_trace(priv, UDBG1, "Client is registered to /dev/unifiudi%d\n", devno);
+ } else {
+ /*
+ * Even-numbered device nodes are the control application.
+ * This is the userspace helper containing SME or
+ * unifi_manager.
+ */
+
+ down(&udi_mutex);
+
+#ifdef CSR_SME_USERSPACE
+ /* Check if a config client is already attached */
+ if (priv->sme_cli) {
+ up(&udi_mutex);
+ uf_put_instance(devno);
+
+ unifi_info(priv, "There is already a configuration client using the character device\n");
+ func_exit();
+ return -EBUSY;
+ }
+#endif /* CSR_SME_USERSPACE */
+
+#ifdef CSR_SUPPORT_SME
+ udi_cli = ul_register_client(priv,
+ CLI_USING_WIRE_FORMAT | CLI_SME_USERSPACE,
+ sme_log_event);
+#else
+ /* Config client for native driver */
+ udi_cli = ul_register_client(priv,
+ 0,
+ sme_native_log_event);
+#endif
+ if (udi_cli == NULL) {
+ /* Too many clients already using this device */
+ up(&udi_mutex);
+ uf_put_instance(devno);
+
+ unifi_error(priv, "Too many clients already open\n");
+ func_exit();
+ return -ENOSPC;
+ }
+
+ /*
+ * Fill-in the pointer to the configuration client.
+ * This is the SME userspace helper or unifi_manager.
+ * Not used in the SME embedded version.
+ */
+ unifi_trace(priv, UDBG1, "SME client (id:%d s:0x%X) is registered\n",
+ udi_cli->client_id, udi_cli->sender_id);
+ /* Store the SME UniFi Linux Client */
+ if (priv->sme_cli == NULL) {
+ priv->sme_cli = udi_cli;
+ }
+
+ up(&udi_mutex);
+ }
+
+
+ /*
+ * Store the pointer to the client.
+ * All char driver's entry points will pass this pointer.
+ */
+ file->private_data = udi_cli;
+
+ func_exit();
+ return 0;
+} /* unifi_open() */
+
+
+static int
+unifi_release(struct inode *inode, struct file *filp)
+{
+ ul_client_t *udi_cli = (void*)filp->private_data;
+ int devno;
+ unifi_priv_t *priv;
+
+ func_enter();
+
+ priv = uf_find_instance(udi_cli->instance);
+ if (!priv) {
+ unifi_error(priv, "unifi_close: instance for device not found\n");
+ return -ENODEV;
+ }
+
+ devno = MINOR(inode->i_rdev) >> 1;
+
+ /* Even device nodes are the config client (i.e. SME or unifi_manager) */
+ if ((MINOR(inode->i_rdev) & 0x1) == 0) {
+
+ if (priv->sme_cli != udi_cli) {
+ unifi_notice(priv, "Surprise closing config device: not the sme client\n");
+ }
+ unifi_notice(priv, "SME client close (unifi%d)\n", devno);
+
+ /*
+ * Clear sme_cli before calling unifi_sys_... so it doesn't try to
+ * queue a reply to the (now gone) SME.
+ */
+ down(&udi_mutex);
+ priv->sme_cli = NULL;
+ up(&udi_mutex);
+
+#ifdef CSR_SME_USERSPACE
+ /* Power-down when config client closes */
+ {
+ CsrWifiRouterCtrlWifiOffReq req = {{CSR_WIFI_ROUTER_CTRL_HIP_REQ, 0, 0, 0, NULL}};
+ CsrWifiRouterCtrlWifiOffReqHandler(priv, &req.common);
+ }
+
+ uf_sme_deinit(priv);
+
+ /* It is possible that a blocking SME request was made from another process
+ * which did not get read by the SME before the WifiOffReq.
+ * So check for a pending request which will go unanswered and cancel
+ * the wait for event. As only one blocking request can be in progress at
+ * a time, up to one event should be completed.
+ */
+ uf_sme_cancel_request(priv, 0);
+
+#endif /* CSR_SME_USERSPACE */
+ } else {
+
+ unifi_trace(priv, UDBG2, "UDI client close (unifiudi%d)\n", devno);
+
+ /* If the pointer matches the logging client, stop logging. */
+ down(&priv->udi_logging_mutex);
+ if (udi_cli == priv->logging_client) {
+ priv->logging_client = NULL;
+ }
+ up(&priv->udi_logging_mutex);
+
+ if (udi_cli == priv->amp_client) {
+ priv->amp_client = NULL;
+ }
+ }
+
+ /* Deregister this instance from the client's list. */
+ ul_deregister_client(udi_cli);
+
+ uf_put_instance(devno);
+
+ return 0;
+} /* unifi_release() */
+
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * unifi_read
+ *
+ * The read() driver entry point.
+ *
+ * Arguments:
+ * filp The file descriptor returned by unifi_open()
+ * p The user space buffer to copy the read data
+ * len The size of the p buffer
+ * poff
+ *
+ * Returns:
+ * number of bytes read or an error code on failure
+ * ---------------------------------------------------------------------------
+ */
+static ssize_t
+unifi_read(struct file *filp, char *p, size_t len, loff_t *poff)
+{
+ ul_client_t *pcli = (void*)filp->private_data;
+ unifi_priv_t *priv;
+ udi_log_t *logptr = NULL;
+ udi_msg_t *msgptr;
+ struct list_head *l;
+ int msglen;
+
+ func_enter();
+
+ priv = uf_find_instance(pcli->instance);
+ if (!priv) {
+ unifi_error(priv, "invalid priv\n");
+ return -ENODEV;
+ }
+
+ if (!pcli->udi_enabled) {
+ unifi_error(priv, "unifi_read: unknown client.");
+ return -EINVAL;
+ }
+
+ if (list_empty(&pcli->udi_log)) {
+ if (filp->f_flags & O_NONBLOCK) {
+ /* Non-blocking - just return if the udi_log is empty */
+ return 0;
+ } else {
+ /* Blocking - wait on the UDI wait queue */
+ if (wait_event_interruptible(pcli->udi_wq,
+ !list_empty(&pcli->udi_log)))
+ {
+ unifi_error(priv, "unifi_read: wait_event_interruptible failed.");
+ return -ERESTARTSYS;
+ }
+ }
+ }
+
+ /* Read entry from list head and remove it from the list */
+ if (down_interruptible(&pcli->udi_sem)) {
+ return -ERESTARTSYS;
+ }
+ l = pcli->udi_log.next;
+ list_del(l);
+ up(&pcli->udi_sem);
+
+ /* Get a pointer to whole struct */
+ logptr = list_entry(l, udi_log_t, q);
+ if (logptr == NULL) {
+ unifi_error(priv, "unifi_read: failed to get event.\n");
+ return -EINVAL;
+ }
+
+ /* Get the real message */
+ msgptr = &logptr->msg;
+ msglen = msgptr->length;
+ if (msglen > len) {
+ printk(KERN_WARNING "truncated read to %d actual msg len is %lu\n", msglen, (long unsigned int)len);
+ msglen = len;
+ }
+
+ /* and pass it to the client (SME or Unicli). */
+ if (copy_to_user(p, msgptr, msglen))
+ {
+ printk(KERN_ERR "Failed to copy UDI log to user\n");
+ kfree(logptr);
+ return -EFAULT;
+ }
+
+ /* It is our resposibility to free the message buffer. */
+ kfree(logptr);
+
+ func_exit_r(msglen);
+ return msglen;
+
+} /* unifi_read() */
+
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * udi_send_signal_unpacked
+ *
+ * Sends an unpacked signal to UniFi.
+ *
+ * Arguments:
+ * priv Pointer to private context struct
+ * data Pointer to request structure and data to send
+ * data_len Length of data in data pointer.
+ *
+ * Returns:
+ * Number of bytes written, error otherwise.
+ *
+ * Notes:
+ * All clients that use this function to send a signal to the unifi
+ * must use the host formatted structures.
+ * ---------------------------------------------------------------------------
+ */
+static int
+udi_send_signal_unpacked(unifi_priv_t *priv, unsigned char* data, uint data_len)
+{
+ CSR_SIGNAL *sigptr = (CSR_SIGNAL*)data;
+ CSR_DATAREF *datarefptr;
+ bulk_data_param_t bulk_data;
+ uint signal_size, i;
+ uint bulk_data_offset = 0;
+ int bytecount, r;
+ CsrResult csrResult;
+
+ /* Number of bytes in the signal */
+ signal_size = SigGetSize(sigptr);
+ if (!signal_size || (signal_size > data_len)) {
+ unifi_error(priv, "unifi_sme_mlme_req - Invalid signal 0x%x size should be %d bytes\n",
+ sigptr->SignalPrimitiveHeader.SignalId,
+ signal_size);
+ return -EINVAL;
+ }
+ bytecount = signal_size;
+
+ /* Get a pointer to the information of the first data reference */
+ datarefptr = (CSR_DATAREF*)&sigptr->u;
+
+ /* Initialize the offset in the data buffer, bulk data is right after the signal. */
+ bulk_data_offset = signal_size;
+
+ /* store the references and the size of the bulk data to the bulkdata structure */
+ for (i = 0; i < UNIFI_MAX_DATA_REFERENCES; i++) {
+ /* the length of the bulk data is in the signal */
+ if ((datarefptr+i)->DataLength) {
+ void *dest;
+
+ csrResult = unifi_net_data_malloc(priv, &bulk_data.d[i], (datarefptr+i)->DataLength);
+ if (csrResult != CSR_RESULT_SUCCESS) {
+ unifi_error(priv, "udi_send_signal_unpacked: failed to allocate request_data.\n");
+ return -EIO;
+ }
+
+ dest = (void*)bulk_data.d[i].os_data_ptr;
+ memcpy(dest, data + bulk_data_offset, bulk_data.d[i].data_length);
+ } else {
+ bulk_data.d[i].data_length = 0;
+ }
+
+ bytecount += bulk_data.d[i].data_length;
+ /* advance the offset, to point the next bulk data */
+ bulk_data_offset += bulk_data.d[i].data_length;
+ }
+
+
+ unifi_trace(priv, UDBG3, "SME Send: signal 0x%.4X\n", sigptr->SignalPrimitiveHeader.SignalId);
+
+ /* Send the signal. */
+ r = ul_send_signal_unpacked(priv, sigptr, &bulk_data);
+ if (r < 0) {
+ unifi_error(priv, "udi_send_signal_unpacked: send failed (%d)\n", r);
+ for(i=0;i<UNIFI_MAX_DATA_REFERENCES;i++) {
+ if(bulk_data.d[i].data_length != 0) {
+ unifi_net_data_free(priv, &bulk_data.d[i]);
+ }
+ }
+ func_exit();
+ return -EIO;
+ }
+
+ return bytecount;
+} /* udi_send_signal_unpacked() */
+
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * udi_send_signal_raw
+ *
+ * Sends a packed signal to UniFi.
+ *
+ * Arguments:
+ * priv Pointer to private context struct
+ * buf Pointer to request structure and data to send
+ * buflen Length of data in data pointer.
+ *
+ * Returns:
+ * Number of bytes written, error otherwise.
+ *
+ * Notes:
+ * All clients that use this function to send a signal to the unifi
+ * must use the wire formatted structures.
+ * ---------------------------------------------------------------------------
+ */
+static int
+udi_send_signal_raw(unifi_priv_t *priv, unsigned char *buf, int buflen)
+{
+ int signal_size;
+ int sig_id;
+ bulk_data_param_t data_ptrs;
+ int i, r;
+ unsigned int num_data_refs;
+ int bytecount;
+ CsrResult csrResult;
+
+ func_enter();
+
+ /*
+ * The signal is the first thing in buf, the signal id is the
+ * first 16 bits of the signal.
+ */
+ /* Number of bytes in the signal */
+ sig_id = GET_SIGNAL_ID(buf);
+ signal_size = buflen;
+ signal_size -= GET_PACKED_DATAREF_LEN(buf, 0);
+ signal_size -= GET_PACKED_DATAREF_LEN(buf, 1);
+ if ((signal_size <= 0) || (signal_size > buflen)) {
+ unifi_error(priv, "udi_send_signal_raw - Couldn't find length of signal 0x%x\n",
+ sig_id);
+ func_exit();
+ return -EINVAL;
+ }
+ unifi_trace(priv, UDBG2, "udi_send_signal_raw: signal 0x%.4X len:%d\n",
+ sig_id, signal_size);
+ /* Zero the data ref arrays */
+ memset(&data_ptrs, 0, sizeof(data_ptrs));
+
+ /*
+ * Find the number of associated bulk data packets. Scan through
+ * the data refs to check that we have enough data and pick out
+ * pointers to appended bulk data.
+ */
+ num_data_refs = 0;
+ bytecount = signal_size;
+
+ for (i = 0; i < UNIFI_MAX_DATA_REFERENCES; ++i)
+ {
+ unsigned int len = GET_PACKED_DATAREF_LEN(buf, i);
+ unifi_trace(priv, UDBG3, "udi_send_signal_raw: data_ref length = %d\n", len);
+
+ if (len != 0) {
+ void *dest;
+
+ csrResult = unifi_net_data_malloc(priv, &data_ptrs.d[i], len);
+ if (csrResult != CSR_RESULT_SUCCESS) {
+ unifi_error(priv, "udi_send_signal_raw: failed to allocate request_data.\n");
+ return -EIO;
+ }
+
+ dest = (void*)data_ptrs.d[i].os_data_ptr;
+ memcpy(dest, buf + bytecount, len);
+
+ bytecount += len;
+ num_data_refs++;
+ }
+ data_ptrs.d[i].data_length = len;
+ }
+
+ unifi_trace(priv, UDBG3, "Queueing signal 0x%.4X from UDI with %u data refs\n",
+ sig_id,
+ num_data_refs);
+
+ if (bytecount > buflen) {
+ unifi_error(priv, "udi_send_signal_raw: Not enough data (%d instead of %d)\n", buflen, bytecount);
+ func_exit();
+ return -EINVAL;
+ }
+
+ /* Send the signal calling the function that uses the wire-formatted signals. */
+ r = ul_send_signal_raw(priv, buf, signal_size, &data_ptrs);
+ if (r < 0) {
+ unifi_error(priv, "udi_send_signal_raw: send failed (%d)\n", r);
+ func_exit();
+ return -EIO;
+ }
+
+#ifdef CSR_NATIVE_LINUX
+ if (sig_id == CSR_MLME_POWERMGT_REQUEST_ID) {
+ int power_mode = CSR_GET_UINT16_FROM_LITTLE_ENDIAN((buf +
+ SIZEOF_SIGNAL_HEADER + (UNIFI_MAX_DATA_REFERENCES*SIZEOF_DATAREF)));
+#ifdef CSR_SUPPORT_WEXT
+ /* Overide the wext power mode to the new value */
+ priv->wext_conf.power_mode = power_mode;
+#endif
+ /* Configure deep sleep signaling */
+ if (power_mode || (priv->interfacePriv[0]->connected == UnifiNotConnected)) {
+ csrResult = unifi_configure_low_power_mode(priv->card,
+ UNIFI_LOW_POWER_ENABLED,
+ UNIFI_PERIODIC_WAKE_HOST_DISABLED);
+ } else {
+ csrResult = unifi_configure_low_power_mode(priv->card,
+ UNIFI_LOW_POWER_DISABLED,
+ UNIFI_PERIODIC_WAKE_HOST_DISABLED);
+ }
+ }
+#endif
+
+ func_exit_r(bytecount);
+
+ return bytecount;
+} /* udi_send_signal_raw */
+
+/*
+ * ---------------------------------------------------------------------------
+ * unifi_write
+ *
+ * The write() driver entry point.
+ * A UniFi Debug Interface client such as unicli can write a signal
+ * plus bulk data to the driver for sending to the UniFi chip.
+ *
+ * Only one signal may be sent per write operation.
+ *
+ * Arguments:
+ * filp The file descriptor returned by unifi_open()
+ * p The user space buffer to get the data from
+ * len The size of the p buffer
+ * poff
+ *
+ * Returns:
+ * number of bytes written or an error code on failure
+ * ---------------------------------------------------------------------------
+ */
+static ssize_t
+unifi_write(struct file *filp, const char *p, size_t len, loff_t *poff)
+{
+ ul_client_t *pcli = (ul_client_t*)filp->private_data;
+ unifi_priv_t *priv;
+ unsigned char *buf;
+ unsigned char *bufptr;
+ int remaining;
+ int bytes_written;
+ int r;
+ bulk_data_param_t bulkdata;
+ CsrResult csrResult;
+
+ func_enter();
+
+ priv = uf_find_instance(pcli->instance);
+ if (!priv) {
+ unifi_error(priv, "invalid priv\n");
+ return -ENODEV;
+ }
+
+ unifi_trace(priv, UDBG5, "unifi_write: len = %d\n", len);
+
+ if (!pcli->udi_enabled) {
+ unifi_error(priv, "udi disabled\n");
+ return -EINVAL;
+ }
+
+ /*
+ * AMP client sends only one signal at a time, so we can use
+ * unifi_net_data_malloc to save the extra copy.
+ */
+ if (pcli == priv->amp_client) {
+ int signal_size;
+ int sig_id;
+ unsigned char *signal_buf;
+ char *user_data_buf;
+
+ csrResult = unifi_net_data_malloc(priv, &bulkdata.d[0], len);
+ if (csrResult != CSR_RESULT_SUCCESS) {
+ unifi_error(priv, "unifi_write: failed to allocate request_data.\n");
+ func_exit();
+ return -ENOMEM;
+ }
+
+ user_data_buf = (char*)bulkdata.d[0].os_data_ptr;
+
+ /* Get the data from the AMP client. */
+ if (copy_from_user((void*)user_data_buf, p, len)) {
+ unifi_error(priv, "unifi_write: copy from user failed\n");
+ unifi_net_data_free(priv, &bulkdata.d[0]);
+ func_exit();
+ return -EFAULT;
+ }
+
+ bulkdata.d[1].os_data_ptr = NULL;
+ bulkdata.d[1].data_length = 0;
+
+ /* Number of bytes in the signal */
+ sig_id = GET_SIGNAL_ID(bulkdata.d[0].os_data_ptr);
+ signal_size = len;
+ signal_size -= GET_PACKED_DATAREF_LEN(bulkdata.d[0].os_data_ptr, 0);
+ signal_size -= GET_PACKED_DATAREF_LEN(bulkdata.d[0].os_data_ptr, 1);
+ if ((signal_size <= 0) || (signal_size > len)) {
+ unifi_error(priv, "unifi_write - Couldn't find length of signal 0x%x\n",
+ sig_id);
+ unifi_net_data_free(priv, &bulkdata.d[0]);
+ func_exit();
+ return -EINVAL;
+ }
+
+ unifi_trace(priv, UDBG2, "unifi_write: signal 0x%.4X len:%d\n",
+ sig_id, signal_size);
+
+ /* Allocate a buffer for the signal */
+ signal_buf = kmalloc(signal_size, GFP_KERNEL);
+ if (!signal_buf) {
+ unifi_net_data_free(priv, &bulkdata.d[0]);
+ func_exit();
+ return -ENOMEM;
+ }
+
+ /* Get the signal from the os_data_ptr */
+ memcpy(signal_buf, bulkdata.d[0].os_data_ptr, signal_size);
+ signal_buf[5] = (pcli->sender_id >> 8) & 0xff;
+
+ if (signal_size < len) {
+ /* Remove the signal from the os_data_ptr */
+ bulkdata.d[0].data_length -= signal_size;
+ bulkdata.d[0].os_data_ptr += signal_size;
+ } else {
+ bulkdata.d[0].data_length = 0;
+ bulkdata.d[0].os_data_ptr = NULL;
+ }
+
+ /* Send the signal calling the function that uses the wire-formatted signals. */
+ r = ul_send_signal_raw(priv, signal_buf, signal_size, &bulkdata);
+ if (r < 0) {
+ unifi_error(priv, "unifi_write: send failed (%d)\n", r);
+ if (bulkdata.d[0].os_data_ptr != NULL) {
+ unifi_net_data_free(priv, &bulkdata.d[0]);
+ }
+ }
+
+ /* Free the signal buffer and return */
+ kfree(signal_buf);
+ return len;
+ }
+
+ buf = kmalloc(len, GFP_KERNEL);
+ if (!buf) {
+ return -ENOMEM;
+ }
+
+ /* Get the data from the client (SME or Unicli). */
+ if (copy_from_user((void*)buf, p, len)) {
+ unifi_error(priv, "copy from user failed\n");
+ kfree(buf);
+ return -EFAULT;
+ }
+
+ /*
+ * In SME userspace build read() contains a SYS or MGT message.
+ * Note that even though the SME sends one signal at a time, we can not
+ * use unifi_net_data_malloc because in the early stages, before having
+ * initialised the core, it will fail since the I/O block size is unknown.
+ */
+#ifdef CSR_SME_USERSPACE
+ if (pcli->configuration & CLI_SME_USERSPACE) {
+ CsrWifiRouterTransportRecv(priv, buf, len);
+ kfree(buf);
+ return len;
+ }
+#endif
+
+ /* ul_send_signal_raw will do a sanity check of len against signal content */
+
+ /*
+ * udi_send_signal_raw() and udi_send_signal_unpacked() return the number of bytes consumed.
+ * A write call can pass multiple signal concatenated together.
+ */
+ bytes_written = 0;
+ remaining = len;
+ bufptr = buf;
+ while (remaining > 0)
+ {
+ int r;
+
+ /*
+ * Set the SenderProcessId.
+ * The SignalPrimitiveHeader is the first 3 16-bit words of the signal,
+ * the SenderProcessId is bytes 4,5.
+ * The MSB of the sender ID needs to be set to the client ID.
+ * The LSB is controlled by the SME.
+ */
+ bufptr[5] = (pcli->sender_id >> 8) & 0xff;
+
+ /* use the appropriate interface, depending on the clients' configuration */
+ if (pcli->configuration & CLI_USING_WIRE_FORMAT) {
+ unifi_trace(priv, UDBG1, "unifi_write: call udi_send_signal().\n");
+ r = udi_send_signal_raw(priv, bufptr, remaining);
+ } else {
+ r = udi_send_signal_unpacked(priv, bufptr, remaining);
+ }
+ if (r < 0) {
+ /* Set the return value to the error code */
+ unifi_error(priv, "unifi_write: (udi or sme)_send_signal() returns %d\n", r);
+ bytes_written = r;
+ break;
+ }
+ bufptr += r;
+ remaining -= r;
+ bytes_written += r;
+ }
+
+ kfree(buf);
+
+ func_exit_r(bytes_written);
+
+ return bytes_written;
+} /* unifi_write() */
+
+
+static const char* build_type_to_string(unsigned char build_type)
+{
+ switch (build_type)
+ {
+ case UNIFI_BUILD_NME: return "NME";
+ case UNIFI_BUILD_WEXT: return "WEXT";
+ case UNIFI_BUILD_AP: return "AP";
+ }
+ return "unknown";
+}
+
+
+/*
+ * ----------------------------------------------------------------
+ * unifi_ioctl
+ *
+ * Ioctl handler for unifi driver.
+ *
+ * Arguments:
+ * inodep Pointer to inode structure.
+ * filp Pointer to file structure.
+ * cmd Ioctl cmd passed by user.
+ * arg Ioctl arg passed by user.
+ *
+ * Returns:
+ * 0 on success, -ve error code on error.
+ * ----------------------------------------------------------------
+ */
+static long
+unifi_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
+{
+ ul_client_t *pcli = (ul_client_t*)filp->private_data;
+ unifi_priv_t *priv;
+ struct net_device *dev;
+ int r = 0;
+ int int_param, i;
+ u8* buf;
+ CsrResult csrResult;
+#if (defined CSR_SUPPORT_SME)
+ unifi_cfg_command_t cfg_cmd;
+#if (defined CSR_SUPPORT_WEXT)
+ CsrWifiSmeCoexConfig coex_config;
+ unsigned char uchar_param;
+ unsigned char varbind[MAX_VARBIND_LENGTH];
+ int vblen;
+#endif
+#endif
+ unifi_putest_command_t putest_cmd;
+
+ priv = uf_find_instance(pcli->instance);
+ if (!priv) {
+ unifi_error(priv, "ioctl error: unknown instance=%d\n", pcli->instance);
+ r = -ENODEV;
+ goto out;
+ }
+ unifi_trace(priv, UDBG5, "unifi_ioctl: cmd=0x%X, arg=0x%lX\n", cmd, arg);
+
+ switch (cmd) {
+
+ case UNIFI_GET_UDI_ENABLE:
+ unifi_trace(priv, UDBG4, "UniFi Get UDI Enable\n");
+
+ down(&priv->udi_logging_mutex);
+ int_param = (priv->logging_client == NULL) ? 0 : 1;
+ up(&priv->udi_logging_mutex);
+
+ if (put_user(int_param, (int*)arg))
+ {
+ unifi_error(priv, "UNIFI_GET_UDI_ENABLE: Failed to copy to user\n");
+ r = -EFAULT;
+ goto out;
+ }
+ break;
+
+ case UNIFI_SET_UDI_ENABLE:
+ unifi_trace(priv, UDBG4, "UniFi Set UDI Enable\n");
+ if (get_user(int_param, (int*)arg))
+ {
+ unifi_error(priv, "UNIFI_SET_UDI_ENABLE: Failed to copy from user\n");
+ r = -EFAULT;
+ goto out;
+ }
+
+#ifdef CSR_WIFI_HIP_DEBUG_OFFLINE
+ if (log_hip_signals) {
+ unifi_error(priv, "omnicli cannot be used when log_hip_signals is used\n");
+ r = -EFAULT;
+ goto out;
+ }
+#endif
+
+ down(&priv->udi_logging_mutex);
+ if (int_param) {
+ pcli->event_hook = udi_log_event;
+ unifi_set_udi_hook(priv->card, logging_handler);
+ /* Log all signals by default */
+ for (i = 0; i < SIG_FILTER_SIZE; i++) {
+ pcli->signal_filter[i] = 0xFFFF;
+ }
+ priv->logging_client = pcli;
+
+ } else {
+ priv->logging_client = NULL;
+ pcli->event_hook = NULL;
+ }
+ up(&priv->udi_logging_mutex);
+
+ break;
+
+ case UNIFI_SET_MIB:
+ unifi_trace(priv, UDBG4, "UniFi Set MIB\n");
+#if (defined CSR_SUPPORT_SME) && (defined CSR_SUPPORT_WEXT)
+ /* Read first 2 bytes and check length */
+ if (copy_from_user((void*)varbind, (void*)arg, 2)) {
+ unifi_error(priv,
+ "UNIFI_SET_MIB: Failed to copy in varbind header\n");
+ r = -EFAULT;
+ goto out;
+ }
+ vblen = varbind[1];
+ if ((vblen + 2) > MAX_VARBIND_LENGTH) {
+ unifi_error(priv,
+ "UNIFI_SET_MIB: Varbind too long (%d, limit %d)\n",
+ (vblen+2), MAX_VARBIND_LENGTH);
+ r = -EINVAL;
+ goto out;
+ }
+ /* Read rest of varbind */
+ if (copy_from_user((void*)(varbind+2), (void*)(arg+2), vblen)) {
+ unifi_error(priv, "UNIFI_SET_MIB: Failed to copy in varbind\n");
+ r = -EFAULT;
+ goto out;
+ }
+
+ /* send to SME */
+ vblen += 2;
+ r = sme_mgt_mib_set(priv, varbind, vblen);
+ if (r) {
+ goto out;
+ }
+#else
+ unifi_notice(priv, "UNIFI_SET_MIB: Unsupported.\n");
+#endif /* CSR_SUPPORT_WEXT */
+ break;
+
+ case UNIFI_GET_MIB:
+ unifi_trace(priv, UDBG4, "UniFi Get MIB\n");
+#if (defined CSR_SUPPORT_SME) && (defined CSR_SUPPORT_WEXT)
+ /* Read first 2 bytes and check length */
+ if (copy_from_user((void*)varbind, (void*)arg, 2)) {
+ unifi_error(priv, "UNIFI_GET_MIB: Failed to copy in varbind header\n");
+ r = -EFAULT;
+ goto out;
+ }
+ vblen = varbind[1];
+ if ((vblen+2) > MAX_VARBIND_LENGTH) {
+ unifi_error(priv, "UNIFI_GET_MIB: Varbind too long (%d, limit %d)\n",
+ (vblen+2), MAX_VARBIND_LENGTH);
+ r = -EINVAL;
+ goto out;
+ }
+ /* Read rest of varbind */
+ if (copy_from_user((void*)(varbind+2), (void*)(arg+2), vblen)) {
+ unifi_error(priv, "UNIFI_GET_MIB: Failed to copy in varbind\n");
+ r = -EFAULT;
+ goto out;
+ }
+
+ vblen += 2;
+ r = sme_mgt_mib_get(priv, varbind, &vblen);
+ if (r) {
+ goto out;
+ }
+ /* copy out varbind */
+ if (vblen > MAX_VARBIND_LENGTH) {
+ unifi_error(priv,
+ "UNIFI_GET_MIB: Varbind result too long (%d, limit %d)\n",
+ vblen, MAX_VARBIND_LENGTH);
+ r = -EINVAL;
+ goto out;
+ }
+ if (copy_to_user((void*)arg, varbind, vblen)) {
+ r = -EFAULT;
+ goto out;
+ }
+#else
+ unifi_notice(priv, "UNIFI_GET_MIB: Unsupported.\n");
+#endif /* CSR_SUPPORT_WEXT */
+ break;
+
+ case UNIFI_CFG:
+#if (defined CSR_SUPPORT_SME)
+ if (get_user(cfg_cmd, (unifi_cfg_command_t*)arg))
+ {
+ unifi_error(priv, "UNIFI_CFG: Failed to get the command\n");
+ r = -EFAULT;
+ goto out;
+ }
+
+ unifi_trace(priv, UDBG1, "UNIFI_CFG: Command is %d (t=%u) sz=%d\n",
+ cfg_cmd, jiffies_to_msecs(jiffies), sizeof(unifi_cfg_command_t));
+ switch (cfg_cmd) {
+ case UNIFI_CFG_POWER:
+ r = unifi_cfg_power(priv, (unsigned char*)arg);
+ break;
+ case UNIFI_CFG_POWERSAVE:
+ r = unifi_cfg_power_save(priv, (unsigned char*)arg);
+ break;
+ case UNIFI_CFG_POWERSUPPLY:
+ r = unifi_cfg_power_supply(priv, (unsigned char*)arg);
+ break;
+ case UNIFI_CFG_FILTER:
+ r = unifi_cfg_packet_filters(priv, (unsigned char*)arg);
+ break;
+ case UNIFI_CFG_GET:
+ r = unifi_cfg_get_info(priv, (unsigned char*)arg);
+ break;
+ case UNIFI_CFG_WMM_QOSINFO:
+ r = unifi_cfg_wmm_qos_info(priv, (unsigned char*)arg);
+ break;
+ case UNIFI_CFG_WMM_ADDTS:
+ r = unifi_cfg_wmm_addts(priv, (unsigned char*)arg);
+ break;
+ case UNIFI_CFG_WMM_DELTS:
+ r = unifi_cfg_wmm_delts(priv, (unsigned char*)arg);
+ break;
+ case UNIFI_CFG_STRICT_DRAFT_N:
+ r = unifi_cfg_strict_draft_n(priv, (unsigned char*)arg);
+ break;
+ case UNIFI_CFG_ENABLE_OKC:
+ r = unifi_cfg_enable_okc(priv, (unsigned char*)arg);
+ break;
+#ifdef CSR_SUPPORT_SME
+ case UNIFI_CFG_CORE_DUMP:
+ CsrWifiRouterCtrlWifiOffIndSend(priv->CSR_WIFI_SME_IFACEQUEUE,0,CSR_WIFI_SME_CONTROL_INDICATION_ERROR);
+ unifi_trace(priv, UDBG2, "UNIFI_CFG_CORE_DUMP: sent wifi off indication\n");
+ break;
+#endif
+#ifdef CSR_SUPPORT_WEXT_AP
+ case UNIFI_CFG_SET_AP_CONFIG:
+ r= unifi_cfg_set_ap_config(priv,(unsigned char*)arg);
+ break;
+#endif
+ default:
+ unifi_error(priv, "UNIFI_CFG: Unknown Command (%d)\n", cfg_cmd);
+ r = -EINVAL;
+ goto out;
+ }
+#endif
+
+ break;
+
+ case UNIFI_PUTEST:
+ if (get_user(putest_cmd, (unifi_putest_command_t*)arg))
+ {
+ unifi_error(priv, "UNIFI_PUTEST: Failed to get the command\n");
+ r = -EFAULT;
+ goto out;
+ }
+
+ unifi_trace(priv, UDBG1, "UNIFI_PUTEST: Command is %s\n",
+ trace_putest_cmdid(putest_cmd));
+ switch (putest_cmd) {
+ case UNIFI_PUTEST_START:
+ r = unifi_putest_start(priv, (unsigned char*)arg);
+ break;
+ case UNIFI_PUTEST_STOP:
+ r = unifi_putest_stop(priv, (unsigned char*)arg);
+ break;
+ case UNIFI_PUTEST_SET_SDIO_CLOCK:
+ r = unifi_putest_set_sdio_clock(priv, (unsigned char*)arg);
+ break;
+ case UNIFI_PUTEST_CMD52_READ:
+ r = unifi_putest_cmd52_read(priv, (unsigned char*)arg);
+ break;
+ case UNIFI_PUTEST_CMD52_BLOCK_READ:
+ r = unifi_putest_cmd52_block_read(priv, (unsigned char*)arg);
+ break;
+ case UNIFI_PUTEST_CMD52_WRITE:
+ r = unifi_putest_cmd52_write(priv, (unsigned char*)arg);
+ break;
+ case UNIFI_PUTEST_DL_FW:
+ r = unifi_putest_dl_fw(priv, (unsigned char*)arg);
+ break;
+ case UNIFI_PUTEST_DL_FW_BUFF:
+ r = unifi_putest_dl_fw_buff(priv, (unsigned char*)arg);
+ break;
+ case UNIFI_PUTEST_COREDUMP_PREPARE:
+ r = unifi_putest_coredump_prepare(priv, (unsigned char*)arg);
+ break;
+ case UNIFI_PUTEST_GP_READ16:
+ r = unifi_putest_gp_read16(priv, (unsigned char*)arg);
+ break;
+ case UNIFI_PUTEST_GP_WRITE16:
+ r = unifi_putest_gp_write16(priv, (unsigned char*)arg);
+ break;
+ default:
+ unifi_error(priv, "UNIFI_PUTEST: Unknown Command (%d)\n", putest_cmd);
+ r = -EINVAL;
+ goto out;
+ }
+
+ break;
+ case UNIFI_BUILD_TYPE:
+ unifi_trace(priv, UDBG2, "UNIFI_BUILD_TYPE userspace=%s\n", build_type_to_string(*(unsigned char*)arg));
+#ifndef CSR_SUPPORT_WEXT_AP
+ if (UNIFI_BUILD_AP == *(unsigned char*)arg)
+ {
+ unifi_error(priv, "Userspace has AP support, which is incompatible\n");
+ }
+#endif
+
+#ifndef CSR_SUPPORT_WEXT
+ if (UNIFI_BUILD_WEXT == *(unsigned char*)arg)
+ {
+ unifi_error(priv, "Userspace has WEXT support, which is incompatible\n");
+ }
+#endif
+ break;
+ case UNIFI_INIT_HW:
+ unifi_trace(priv, UDBG2, "UNIFI_INIT_HW.\n");
+ priv->init_progress = UNIFI_INIT_NONE;
+
+#if defined(CSR_SUPPORT_WEXT) || defined (CSR_NATIVE_LINUX)
+ /* At this point we are ready to start the SME. */
+ r = sme_mgt_wifi_on(priv);
+ if (r) {
+ goto out;
+ }
+#endif
+
+ break;
+
+ case UNIFI_INIT_NETDEV:
+ {
+ /* get the proper interfaceTagId */
+ u16 interfaceTag=0;
+ netInterface_priv_t *interfacePriv = priv->interfacePriv[interfaceTag];
+
+ dev = priv->netdev[interfaceTag];
+ unifi_trace(priv, UDBG2, "UNIFI_INIT_NETDEV.\n");
+
+ if (copy_from_user((void*)dev->dev_addr, (void*)arg, 6)) {
+ r = -EFAULT;
+ goto out;
+ }
+
+ /* Attach the network device to the stack */
+ if (!interfacePriv->netdev_registered)
+ {
+ r = uf_register_netdev(priv,interfaceTag);
+ if (r) {
+ unifi_error(priv, "Failed to register the network device.\n");
+ goto out;
+ }
+ }
+
+ /* Apply scheduled interrupt mode, if requested by module param */
+ if (run_bh_once != -1) {
+ unifi_set_interrupt_mode(priv->card, (u32)run_bh_once);
+ }
+
+ priv->init_progress = UNIFI_INIT_COMPLETED;
+
+ /* Firmware initialisation is complete, so let the SDIO bus
+ * clock be raised when convienent to the core.
+ */
+ unifi_request_max_sdio_clock(priv->card);
+
+#ifdef CSR_SUPPORT_WEXT
+ /* Notify the Android wpa_supplicant that we are ready */
+ wext_send_started_event(priv);
+#endif
+
+ unifi_info(priv, "UniFi ready\n");
+
+#ifdef ANDROID_BUILD
+ /* Release the wakelock */
+ unifi_trace(priv, UDBG1, "netdev_init: release wake lock\n");
+ wake_unlock(&unifi_sdio_wake_lock);
+#endif
+#ifdef CSR_NATIVE_SOFTMAC /* For softmac dev, force-enable the network interface rather than wait for a connected-ind */
+ {
+ struct net_device *dev = priv->netdev[interfaceTag];
+#ifdef CSR_SUPPORT_WEXT
+ interfacePriv->wait_netdev_change = TRUE;
+#endif
+ netif_carrier_on(dev);
+ }
+#endif
+ }
+ break;
+ case UNIFI_GET_INIT_STATUS:
+ unifi_trace(priv, UDBG2, "UNIFI_GET_INIT_STATUS.\n");
+ if (put_user(priv->init_progress, (int*)arg))
+ {
+ printk(KERN_ERR "UNIFI_GET_INIT_STATUS: Failed to copy to user\n");
+ r = -EFAULT;
+ goto out;
+ }
+ break;
+
+ case UNIFI_KICK:
+ unifi_trace(priv, UDBG4, "Kick UniFi\n");
+ unifi_sdio_interrupt_handler(priv->card);
+ break;
+
+ case UNIFI_SET_DEBUG:
+ unifi_debug = arg;
+ unifi_trace(priv, UDBG4, "unifi_debug set to %d\n", unifi_debug);
+ break;
+
+ case UNIFI_SET_TRACE:
+ /* no longer supported */
+ r = -EINVAL;
+ break;
+
+
+ case UNIFI_SET_UDI_LOG_MASK:
+ {
+ unifiio_filter_t udi_filter;
+ uint16_t *sig_ids_addr;
+#define UF_MAX_SIG_IDS 128 /* Impose a sensible limit */
+
+ if (copy_from_user((void*)(&udi_filter), (void*)arg, sizeof(udi_filter))) {
+ r = -EFAULT;
+ goto out;
+ }
+ if ((udi_filter.action < UfSigFil_AllOn) ||
+ (udi_filter.action > UfSigFil_SelectOff))
+ {
+ printk(KERN_WARNING
+ "UNIFI_SET_UDI_LOG_MASK: Bad action value: %d\n",
+ udi_filter.action);
+ r = -EINVAL;
+ goto out;
+ }
+ /* No signal list for "All" actions */
+ if ((udi_filter.action == UfSigFil_AllOn) ||
+ (udi_filter.action == UfSigFil_AllOff))
+ {
+ udi_filter.num_sig_ids = 0;
+ }
+
+ if (udi_filter.num_sig_ids > UF_MAX_SIG_IDS) {
+ printk(KERN_WARNING
+ "UNIFI_SET_UDI_LOG_MASK: too many signal ids (%d, max %d)\n",
+ udi_filter.num_sig_ids, UF_MAX_SIG_IDS);
+ r = -EINVAL;
+ goto out;
+ }
+
+ /* Copy in signal id list if given */
+ if (udi_filter.num_sig_ids > 0) {
+ /* Preserve userspace address of sig_ids array */
+ sig_ids_addr = udi_filter.sig_ids;
+ /* Allocate kernel memory for sig_ids and copy to it */
+ udi_filter.sig_ids =
+ kmalloc(udi_filter.num_sig_ids * sizeof(uint16_t), GFP_KERNEL);
+ if (!udi_filter.sig_ids) {
+ r = -ENOMEM;
+ goto out;
+ }
+ if (copy_from_user((void*)udi_filter.sig_ids,
+ (void*)sig_ids_addr,
+ udi_filter.num_sig_ids * sizeof(uint16_t)))
+ {
+ kfree(udi_filter.sig_ids);
+ r = -EFAULT;
+ goto out;
+ }
+ }
+
+ udi_set_log_filter(pcli, &udi_filter);
+
+ if (udi_filter.num_sig_ids > 0) {
+ kfree(udi_filter.sig_ids);
+ }
+ }
+ break;
+
+ case UNIFI_SET_AMP_ENABLE:
+ unifi_trace(priv, UDBG4, "UniFi Set AMP Enable\n");
+ if (get_user(int_param, (int*)arg))
+ {
+ unifi_error(priv, "UNIFI_SET_AMP_ENABLE: Failed to copy from user\n");
+ r = -EFAULT;
+ goto out;
+ }
+
+ if (int_param) {
+ priv->amp_client = pcli;
+ } else {
+ priv->amp_client = NULL;
+ }
+
+ int_param = 0;
+ buf = (u8*)&int_param;
+ buf[0] = UNIFI_SOFT_COMMAND_Q_LENGTH - 1;
+ buf[1] = UNIFI_SOFT_TRAFFIC_Q_LENGTH - 1;
+ if (copy_to_user((void*)arg, &int_param, sizeof(int))) {
+ r = -EFAULT;
+ goto out;
+ }
+ break;
+
+ case UNIFI_SET_UDI_SNAP_MASK:
+ {
+ unifiio_snap_filter_t snap_filter;
+
+ if (copy_from_user((void*)(&snap_filter), (void*)arg, sizeof(snap_filter))) {
+ r = -EFAULT;
+ goto out;
+ }
+
+ if (pcli->snap_filter.count) {
+ pcli->snap_filter.count = 0;
+ kfree(pcli->snap_filter.protocols);
+ }
+
+ if (snap_filter.count == 0) {
+ break;
+ }
+
+ pcli->snap_filter.protocols = kmalloc(snap_filter.count * sizeof(u16), GFP_KERNEL);
+ if (!pcli->snap_filter.protocols) {
+ r = -ENOMEM;
+ goto out;
+ }
+ if (copy_from_user((void*)pcli->snap_filter.protocols,
+ (void*)snap_filter.protocols,
+ snap_filter.count * sizeof(u16)))
+ {
+ kfree(pcli->snap_filter.protocols);
+ r = -EFAULT;
+ goto out;
+ }
+
+ pcli->snap_filter.count = snap_filter.count;
+
+ }
+ break;
+
+ case UNIFI_SME_PRESENT:
+ {
+ u8 ind;
+ unifi_trace(priv, UDBG4, "UniFi SME Present IOCTL.\n");
+ if (copy_from_user((void*)(&int_param), (void*)arg, sizeof(int)))
+ {
+ printk(KERN_ERR "UNIFI_SME_PRESENT: Failed to copy from user\n");
+ r = -EFAULT;
+ goto out;
+ }
+
+ priv->sme_is_present = int_param;
+ if (priv->sme_is_present == 1) {
+ ind = CONFIG_SME_PRESENT;
+ } else {
+ ind = CONFIG_SME_NOT_PRESENT;
+ }
+ /* Send an indication to the helper app. */
+ ul_log_config_ind(priv, &ind, sizeof(u8));
+ }
+ break;
+
+ case UNIFI_CFG_PERIOD_TRAFFIC:
+ {
+#if (defined CSR_SUPPORT_SME) && (defined CSR_SUPPORT_WEXT)
+ CsrWifiSmeCoexConfig coexConfig;
+#endif /* CSR_SUPPORT_SME && CSR_SUPPORT_WEXT */
+ unifi_trace(priv, UDBG4, "UniFi Configure Periodic Traffic.\n");
+#if (defined CSR_SUPPORT_SME) && (defined CSR_SUPPORT_WEXT)
+ if (copy_from_user((void*)(&uchar_param), (void*)arg, sizeof(unsigned char))) {
+ unifi_error(priv, "UNIFI_CFG_PERIOD_TRAFFIC: Failed to copy from user\n");
+ r = -EFAULT;
+ goto out;
+ }
+
+ if (uchar_param == 0) {
+ r = sme_mgt_coex_config_get(priv, &coexConfig);
+ if (r) {
+ unifi_error(priv, "UNIFI_CFG_PERIOD_TRAFFIC: Get unifi_CoexInfoValue failed.\n");
+ goto out;
+ }
+ if (copy_to_user((void*)(arg + 1),
+ (void*)&coexConfig,
+ sizeof(CsrWifiSmeCoexConfig))) {
+ r = -EFAULT;
+ goto out;
+ }
+ goto out;
+ }
+
+ if (copy_from_user((void*)(&coex_config), (void*)(arg + 1), sizeof(CsrWifiSmeCoexConfig)))
+ {
+ unifi_error(priv, "UNIFI_CFG_PERIOD_TRAFFIC: Failed to copy from user\n");
+ r = -EFAULT;
+ goto out;
+ }
+
+ coexConfig = coex_config;
+ r = sme_mgt_coex_config_set(priv, &coexConfig);
+ if (r) {
+ unifi_error(priv, "UNIFI_CFG_PERIOD_TRAFFIC: Set unifi_CoexInfoValue failed.\n");
+ goto out;
+ }
+
+#endif /* CSR_SUPPORT_SME && CSR_SUPPORT_WEXT */
+ break;
+ }
+ case UNIFI_CFG_UAPSD_TRAFFIC:
+ unifi_trace(priv, UDBG4, "UniFi Configure U-APSD Mask.\n");
+#if (defined CSR_SUPPORT_SME) && (defined CSR_SUPPORT_WEXT)
+ if (copy_from_user((void*)(&uchar_param), (void*)arg, sizeof(unsigned char))) {
+ unifi_error(priv, "UNIFI_CFG_UAPSD_TRAFFIC: Failed to copy from user\n");
+ r = -EFAULT;
+ goto out;
+ }
+ unifi_trace(priv, UDBG4, "New U-APSD Mask: 0x%x\n", uchar_param);
+#endif /* CSR_SUPPORT_SME && CSR_SUPPORT_WEXT */
+ break;
+
+#ifndef UNIFI_DISABLE_COREDUMP
+ case UNIFI_COREDUMP_GET_REG:
+ unifi_trace(priv, UDBG4, "Mini-coredump data request\n");
+ {
+ unifiio_coredump_req_t dump_req; /* Public OS layer structure */
+ unifi_coredump_req_t priv_req; /* Private HIP structure */
+
+ if (copy_from_user((void*)(&dump_req), (void*)arg, sizeof(dump_req))) {
+ r = -EFAULT;
+ goto out;
+ }
+ memset(&priv_req, 0, sizeof(priv_req));
+ priv_req.index = dump_req.index;
+ priv_req.offset = dump_req.offset;
+
+ /* Convert OS-layer's XAP memory space ID to HIP's ID in case they differ */
+ switch (dump_req.space) {
+ case UNIFIIO_COREDUMP_MAC_REG: priv_req.space = UNIFI_COREDUMP_MAC_REG; break;
+ case UNIFIIO_COREDUMP_PHY_REG: priv_req.space = UNIFI_COREDUMP_PHY_REG; break;
+ case UNIFIIO_COREDUMP_SH_DMEM: priv_req.space = UNIFI_COREDUMP_SH_DMEM; break;
+ case UNIFIIO_COREDUMP_MAC_DMEM: priv_req.space = UNIFI_COREDUMP_MAC_DMEM; break;
+ case UNIFIIO_COREDUMP_PHY_DMEM: priv_req.space = UNIFI_COREDUMP_PHY_DMEM; break;
+ case UNIFIIO_COREDUMP_TRIGGER_MAGIC: priv_req.space = UNIFI_COREDUMP_TRIGGER_MAGIC; break;
+ default:
+ r = -EINVAL;
+ goto out;
+ }
+
+ if (priv_req.space == UNIFI_COREDUMP_TRIGGER_MAGIC) {
+ /* Force a coredump grab now */
+ unifi_trace(priv, UDBG2, "UNIFI_COREDUMP_GET_REG: Force capture\n");
+ csrResult = unifi_coredump_capture(priv->card, &priv_req);
+ r = CsrHipResultToStatus(csrResult);
+ unifi_trace(priv, UDBG5, "UNIFI_COREDUMP_GET_REG: status %d\n", r);
+ } else {
+ /* Retrieve the appropriate register entry */
+ csrResult = unifi_coredump_get_value(priv->card, &priv_req);
+ r = CsrHipResultToStatus(csrResult);
+ if (r) {
+ unifi_trace(priv, UDBG5, "UNIFI_COREDUMP_GET_REG: Status %d\n", r);
+ goto out;
+ }
+ /* Update the OS-layer structure with values returned in the private */
+ dump_req.value = priv_req.value;
+ dump_req.timestamp = priv_req.timestamp;
+ dump_req.requestor = priv_req.requestor;
+ dump_req.serial = priv_req.serial;
+ dump_req.chip_ver = priv_req.chip_ver;
+ dump_req.fw_ver = priv_req.fw_ver;
+ dump_req.drv_build = 0;
+
+ unifi_trace(priv, UDBG6,
+ "Dump: %d (seq %d): V:0x%04x (%d) @0x%02x:%04x = 0x%04x\n",
+ dump_req.index, dump_req.serial,
+ dump_req.chip_ver, dump_req.drv_build,
+ dump_req.space, dump_req.offset, dump_req.value);
+ }
+ if (copy_to_user((void*)arg, (void*)&dump_req, sizeof(dump_req))) {
+ r = -EFAULT;
+ goto out;
+ }
+ }
+ break;
+#endif
+ default:
+ r = -EINVAL;
+ }
+
+out:
+ return (long)r;
+} /* unifi_ioctl() */
+
+
+
+static unsigned int
+unifi_poll(struct file *filp, poll_table *wait)
+{
+ ul_client_t *pcli = (ul_client_t*)filp->private_data;
+ unsigned int mask = 0;
+ int ready;
+
+ func_enter();
+
+ ready = !list_empty(&pcli->udi_log);
+
+ poll_wait(filp, &pcli->udi_wq, wait);
+
+ if (ready) {
+ mask |= POLLIN | POLLRDNORM; /* readable */
+ }
+
+ func_exit();
+
+ return mask;
+} /* unifi_poll() */
+
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * udi_set_log_filter
+ *
+ * Configure the bit mask that determines which signal primitives are
+ * passed to the logging process.
+ *
+ * Arguments:
+ * pcli Pointer to the client to configure.
+ * udi_filter Pointer to a unifiio_filter_t containing instructions.
+ *
+ * Returns:
+ * None.
+ *
+ * Notes:
+ * SigGetFilterPos() returns a 32-bit value that contains an index and a
+ * mask for accessing a signal_filter array. The top 16 bits specify an
+ * index into a signal_filter, the bottom 16 bits specify a mask to
+ * apply.
+ * ---------------------------------------------------------------------------
+ */
+static void
+udi_set_log_filter(ul_client_t *pcli, unifiio_filter_t *udi_filter)
+{
+ u32 filter_pos;
+ int i;
+
+ if (udi_filter->action == UfSigFil_AllOn)
+ {
+ for (i = 0; i < SIG_FILTER_SIZE; i++) {
+ pcli->signal_filter[i] = 0xFFFF;
+ }
+ }
+ else if (udi_filter->action == UfSigFil_AllOff)
+ {
+ for (i = 0; i < SIG_FILTER_SIZE; i++) {
+ pcli->signal_filter[i] = 0;
+ }
+ }
+ else if (udi_filter->action == UfSigFil_SelectOn)
+ {
+ for (i = 0; i < udi_filter->num_sig_ids; i++) {
+ filter_pos = SigGetFilterPos(udi_filter->sig_ids[i]);
+ if (filter_pos == 0xFFFFFFFF)
+ {
+ printk(KERN_WARNING
+ "Unrecognised signal id (0x%X) specifed in logging filter\n",
+ udi_filter->sig_ids[i]);
+ } else {
+ pcli->signal_filter[filter_pos >> 16] |= (filter_pos & 0xFFFF);
+ }
+ }
+ }
+ else if (udi_filter->action == UfSigFil_SelectOff)
+ {
+ for (i = 0; i < udi_filter->num_sig_ids; i++) {
+ filter_pos = SigGetFilterPos(udi_filter->sig_ids[i]);
+ if (filter_pos == 0xFFFFFFFF)
+ {
+ printk(KERN_WARNING
+ "Unrecognised signal id (0x%X) specifed in logging filter\n",
+ udi_filter->sig_ids[i]);
+ } else {
+ pcli->signal_filter[filter_pos >> 16] &= ~(filter_pos & 0xFFFF);
+ }
+ }
+ }
+
+} /* udi_set_log_filter() */
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * udi_log_event
+ *
+ * Callback function to be registered as the UDI hook callback.
+ * Copies the signal content into a new udi_log_t struct and adds
+ * it to the read queue for this UDI client.
+ *
+ * Arguments:
+ * pcli A pointer to the client instance.
+ * signal Pointer to the received signal.
+ * signal_len Size of the signal structure in bytes.
+ * bulkdata Pointers to any associated bulk data.
+ * dir Direction of the signal. Zero means from host,
+ * non-zero means to host.
+ *
+ * Returns:
+ * None.
+ * ---------------------------------------------------------------------------
+ */
+void
+udi_log_event(ul_client_t *pcli,
+ const u8 *signal, int signal_len,
+ const bulk_data_param_t *bulkdata,
+ int dir)
+{
+ udi_log_t *logptr;
+ u8 *p;
+ int i;
+ int total_len;
+ udi_msg_t *msgptr;
+ u32 filter_pos;
+#ifdef OMNICLI_LINUX_EXTRA_LOG
+ static volatile unsigned int printk_cpu = UINT_MAX;
+ unsigned long long t;
+ unsigned long nanosec_rem;
+ unsigned long n_1000;
+#endif
+
+ func_enter();
+
+ /* Just a sanity check */
+ if ((signal == NULL) || (signal_len <= 0)) {
+ return;
+ }
+
+#ifdef CSR_WIFI_HIP_DEBUG_OFFLINE
+ /* When HIP offline signal logging is enabled, omnicli cannot run */
+ if (log_hip_signals)
+ {
+ /* Add timestamp */
+ if (log_hip_signals & UNIFI_LOG_HIP_SIGNALS_FILTER_TIMESTAMP)
+ {
+ int timestamp = jiffies_to_msecs(jiffies);
+ unifi_debug_log_to_buf("T:");
+ unifi_debug_log_to_buf("%04X%04X ", *(((u16*)&timestamp) + 1),
+ *(u16*)&timestamp);
+ }
+
+ /* Add signal */
+ unifi_debug_log_to_buf("S%s:%04X R:%04X D:%04X ",
+ dir ? "T" : "F",
+ *(u16*)signal,
+ *(u16*)(signal + 2),
+ *(u16*)(signal + 4));
+ unifi_debug_hex_to_buf(signal + 6, signal_len - 6);
+
+ /* Add bulk data (assume 1 bulk data per signal) */
+ if ((log_hip_signals & UNIFI_LOG_HIP_SIGNALS_FILTER_BULKDATA) &&
+ (bulkdata->d[0].data_length > 0))
+ {
+ unifi_debug_log_to_buf("\nD:");
+ unifi_debug_hex_to_buf(bulkdata->d[0].os_data_ptr, bulkdata->d[0].data_length);
+ }
+ unifi_debug_log_to_buf("\n");
+
+ return;
+ }
+#endif
+
+#ifdef CSR_NATIVE_LINUX
+ uf_native_process_udi_signal(pcli, signal, signal_len, bulkdata, dir);
+#endif
+
+ /*
+ * Apply the logging filter - only report signals that have their
+ * bit set in the filter mask.
+ */
+ filter_pos = SigGetFilterPos(GET_SIGNAL_ID(signal));
+
+ if ((filter_pos != 0xFFFFFFFF) &&
+ ((pcli->signal_filter[filter_pos >> 16] & (filter_pos & 0xFFFF)) == 0))
+ {
+ /* Signal is not wanted by client */
+ return;
+ }
+
+
+ /* Calculate the buffer we need to store signal plus bulk data */
+ total_len = signal_len;
+ for (i = 0; i < UNIFI_MAX_DATA_REFERENCES; i++) {
+ total_len += bulkdata->d[i].data_length;
+ }
+
+ /* Allocate log structure plus actual signal. */
+ logptr = (udi_log_t *)kmalloc(sizeof(udi_log_t) + total_len, GFP_KERNEL);
+
+ if (logptr == NULL) {
+ printk(KERN_ERR
+ "Failed to allocate %lu bytes for a UDI log record\n",
+ (long unsigned int)(sizeof(udi_log_t) + total_len));
+ return;
+ }
+
+ /* Fill in udi_log struct */
+ INIT_LIST_HEAD(&logptr->q);
+ msgptr = &logptr->msg;
+ msgptr->length = sizeof(udi_msg_t) + total_len;
+#ifdef OMNICLI_LINUX_EXTRA_LOG
+ t = cpu_clock(printk_cpu);
+ nanosec_rem = do_div(t, 1000000000);
+ n_1000 = nanosec_rem/1000;
+ msgptr->timestamp = (t <<10 ) | ((unsigned long)(n_1000 >> 10) & 0x3ff);
+#else
+ msgptr->timestamp = jiffies_to_msecs(jiffies);
+#endif
+ msgptr->direction = dir;
+ msgptr->signal_length = signal_len;
+
+ /* Copy signal and bulk data to the log */
+ p = (u8 *)(msgptr + 1);
+ memcpy(p, signal, signal_len);
+ p += signal_len;
+
+ /* Append any bulk data */
+ for (i = 0; i < UNIFI_MAX_DATA_REFERENCES; i++) {
+ int len = bulkdata->d[i].data_length;
+
+ /*
+ * Len here might not be the same as the length in the bulk data slot.
+ * The slot length will always be even, but len could be odd.
+ */
+ if (len > 0) {
+ if (bulkdata->d[i].os_data_ptr) {
+ memcpy(p, bulkdata->d[i].os_data_ptr, len);
+ } else {
+ memset(p, 0, len);
+ }
+ p += len;
+ }
+ }
+
+ /* Add to tail of log queue */
+ if (down_interruptible(&pcli->udi_sem)) {
+ printk(KERN_WARNING "udi_log_event_q: Failed to get udi sem\n");
+ kfree(logptr);
+ func_exit();
+ return;
+ }
+ list_add_tail(&logptr->q, &pcli->udi_log);
+ up(&pcli->udi_sem);
+
+ /* Wake any waiting user process */
+ wake_up_interruptible(&pcli->udi_wq);
+
+ func_exit();
+} /* udi_log_event() */
+
+#ifdef CSR_SME_USERSPACE
+int
+uf_sme_queue_message(unifi_priv_t *priv, u8 *buffer, int length)
+{
+ udi_log_t *logptr;
+ udi_msg_t *msgptr;
+ u8 *p;
+
+ func_enter();
+
+ /* Just a sanity check */
+ if ((buffer == NULL) || (length <= 0)) {
+ return -EINVAL;
+ }
+
+ /* Allocate log structure plus actual signal. */
+ logptr = (udi_log_t *)kmalloc(sizeof(udi_log_t) + length, GFP_ATOMIC);
+ if (logptr == NULL) {
+ unifi_error(priv, "Failed to allocate %d bytes for an SME message\n",
+ sizeof(udi_log_t) + length);
+ kfree(buffer);
+ return -ENOMEM;
+ }
+
+ /* Fill in udi_log struct */
+ INIT_LIST_HEAD(&logptr->q);
+ msgptr = &logptr->msg;
+ msgptr->length = sizeof(udi_msg_t) + length;
+ msgptr->signal_length = length;
+
+ /* Copy signal and bulk data to the log */
+ p = (u8 *)(msgptr + 1);
+ memcpy(p, buffer, length);
+
+ /* Add to tail of log queue */
+ down(&udi_mutex);
+ if (priv->sme_cli == NULL) {
+ kfree(logptr);
+ kfree(buffer);
+ up(&udi_mutex);
+ unifi_info(priv, "Message for the SME dropped, SME has gone away\n");
+ return 0;
+ }
+
+ down(&priv->sme_cli->udi_sem);
+ list_add_tail(&logptr->q, &priv->sme_cli->udi_log);
+ up(&priv->sme_cli->udi_sem);
+
+ /* Wake any waiting user process */
+ wake_up_interruptible(&priv->sme_cli->udi_wq);
+ up(&udi_mutex);
+
+ /* It is our responsibility to free the buffer allocated in build_packed_*() */
+ kfree(buffer);
+
+ func_exit();
+
+ return 0;
+
+} /* uf_sme_queue_message() */
+#endif
+
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27)
+#define UF_DEVICE_CREATE(_class, _parent, _devno, _priv, _fmt, _args) \
+ device_create(_class, _parent, _devno, _priv, _fmt, _args)
+#elif LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,26)
+#define UF_DEVICE_CREATE(_class, _parent, _devno, _priv, _fmt, _args) \
+ device_create_drvdata(_class, _parent, _devno, _priv, _fmt, _args)
+#else
+#define UF_DEVICE_CREATE(_class, _parent, _devno, _priv, _fmt, _args) \
+ device_create(_class, _parent, _devno, _fmt, _args)
+#endif
+
+/*
+ ****************************************************************************
+ *
+ * Driver instantiation
+ *
+ ****************************************************************************
+ */
+static struct file_operations unifi_fops = {
+ .owner = THIS_MODULE,
+ .open = unifi_open,
+ .release = unifi_release,
+ .read = unifi_read,
+ .write = unifi_write,
+ .unlocked_ioctl = unifi_ioctl,
+ .poll = unifi_poll,
+};
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27)
+#define UF_DEVICE_CREATE(_class, _parent, _devno, _priv, _fmt, _args) \
+ device_create(_class, _parent, _devno, _priv, _fmt, _args)
+#elif LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,26)
+#define UF_DEVICE_CREATE(_class, _parent, _devno, _priv, _fmt, _args) \
+ device_create_drvdata(_class, _parent, _devno, _priv, _fmt, _args)
+#else
+#define UF_DEVICE_CREATE(_class, _parent, _devno, _priv, _fmt, _args) \
+ device_create(_class, _parent, _devno, _fmt, _args)
+#endif
+
+static dev_t unifi_first_devno;
+static struct class *unifi_class;
+
+
+int uf_create_device_nodes(unifi_priv_t *priv, int bus_id)
+{
+ dev_t devno;
+ int r;
+
+ cdev_init(&priv->unifi_cdev, &unifi_fops);
+
+ /* cdev_init() should set the cdev owner, but it does not */
+ priv->unifi_cdev.owner = THIS_MODULE;
+
+ devno = MKDEV(MAJOR(unifi_first_devno),
+ MINOR(unifi_first_devno) + (bus_id * 2));
+ r = cdev_add(&priv->unifi_cdev, devno, 1);
+ if (r) {
+ return r;
+ }
+
+#ifdef SDIO_EXPORTS_STRUCT_DEVICE
+ if (!UF_DEVICE_CREATE(unifi_class, priv->unifi_device,
+ devno, priv, "unifi%d", bus_id)) {
+#else
+ priv->unifi_device = UF_DEVICE_CREATE(unifi_class, NULL,
+ devno, priv, "unifi%d", bus_id);
+ if (priv->unifi_device == NULL) {
+#endif /* SDIO_EXPORTS_STRUCT_DEVICE */
+
+ cdev_del(&priv->unifi_cdev);
+ return -EINVAL;
+ }
+
+ cdev_init(&priv->unifiudi_cdev, &unifi_fops);
+
+ /* cdev_init() should set the cdev owner, but it does not */
+ priv->unifiudi_cdev.owner = THIS_MODULE;
+
+ devno = MKDEV(MAJOR(unifi_first_devno),
+ MINOR(unifi_first_devno) + (bus_id * 2) + 1);
+ r = cdev_add(&priv->unifiudi_cdev, devno, 1);
+ if (r) {
+ device_destroy(unifi_class, priv->unifi_cdev.dev);
+ cdev_del(&priv->unifi_cdev);
+ return r;
+ }
+
+ if (!UF_DEVICE_CREATE(unifi_class,
+#ifdef SDIO_EXPORTS_STRUCT_DEVICE
+ priv->unifi_device,
+#else
+ NULL,
+#endif /* SDIO_EXPORTS_STRUCT_DEVICE */
+ devno, priv, "unifiudi%d", bus_id)) {
+ device_destroy(unifi_class, priv->unifi_cdev.dev);
+ cdev_del(&priv->unifiudi_cdev);
+ cdev_del(&priv->unifi_cdev);
+ return -EINVAL;
+ }
+
+ return 0;
+}
+
+
+void uf_destroy_device_nodes(unifi_priv_t *priv)
+{
+ device_destroy(unifi_class, priv->unifiudi_cdev.dev);
+ device_destroy(unifi_class, priv->unifi_cdev.dev);
+ cdev_del(&priv->unifiudi_cdev);
+ cdev_del(&priv->unifi_cdev);
+}
+
+
+
+/*
+ * ----------------------------------------------------------------
+ * uf_create_debug_device
+ *
+ * Allocates device numbers for unifi character device nodes
+ * and creates a unifi class in sysfs
+ *
+ * Arguments:
+ * fops Pointer to the char device operations structure.
+ *
+ * Returns:
+ * 0 on success, -ve error code on error.
+ * ----------------------------------------------------------------
+ */
+static int
+uf_create_debug_device(struct file_operations *fops)
+{
+ int ret;
+
+ /* Allocate two device numbers for each device. */
+ ret = alloc_chrdev_region(&unifi_first_devno, 0, MAX_UNIFI_DEVS*2, UNIFI_NAME);
+ if (ret) {
+ unifi_error(NULL, "Failed to add alloc dev numbers: %d\n", ret);
+ return ret;
+ }
+
+ /* Create a UniFi class */
+ unifi_class = class_create(THIS_MODULE, UNIFI_NAME);
+ if (IS_ERR(unifi_class)) {
+ unifi_error(NULL, "Failed to create UniFi class\n");
+
+ /* Release device numbers */
+ unregister_chrdev_region(unifi_first_devno, MAX_UNIFI_DEVS*2);
+ unifi_first_devno = 0;
+ return -EINVAL;
+ }
+
+ return 0;
+} /* uf_create_debug_device() */
+
+
+/*
+ * ----------------------------------------------------------------
+ * uf_remove_debug_device
+ *
+ * Destroys the unifi class and releases the allocated
+ * device numbers for unifi character device nodes.
+ *
+ * Arguments:
+ *
+ * Returns:
+ * ----------------------------------------------------------------
+ */
+static void
+uf_remove_debug_device(void)
+{
+ /* Destroy the UniFi class */
+ class_destroy(unifi_class);
+
+ /* Release device numbers */
+ unregister_chrdev_region(unifi_first_devno, MAX_UNIFI_DEVS*2);
+ unifi_first_devno = 0;
+
+} /* uf_remove_debug_device() */
+
+
+/*
+ * ---------------------------------------------------------------------------
+ *
+ * Module loading.
+ *
+ * ---------------------------------------------------------------------------
+ */
+int __init
+unifi_load(void)
+{
+ int r;
+
+ printk("UniFi SDIO Driver: %s %s %s\n",
+ CSR_WIFI_VERSION,
+ __DATE__, __TIME__);
+
+#ifdef CSR_SME_USERSPACE
+#ifdef CSR_SUPPORT_WEXT
+ printk("CSR SME with WEXT support\n");
+#else
+ printk("CSR SME no WEXT support\n");
+#endif /* CSR_SUPPORT_WEXT */
+#endif /* CSR_SME_USERSPACE */
+
+#ifdef CSR_NATIVE_LINUX
+#ifdef CSR_SUPPORT_WEXT
+#error WEXT unsupported in the native driver
+#endif
+ printk("CSR native no WEXT support\n");
+#endif
+#ifdef CSR_WIFI_SPLIT_PATCH
+ printk("Split patch support\n");
+#endif
+ printk("Kernel %d.%d.%d\n",
+ ((LINUX_VERSION_CODE) >> 16) & 0xff,
+ ((LINUX_VERSION_CODE) >> 8) & 0xff,
+ (LINUX_VERSION_CODE) & 0xff);
+ /*
+ * Instantiate the /dev/unifi* device nodes.
+ * We must do this before registering with the SDIO driver because it
+ * will immediately call the "insert" callback if the card is
+ * already present.
+ */
+ r = uf_create_debug_device(&unifi_fops);
+ if (r) {
+ return r;
+ }
+
+ /* Now register with the SDIO driver */
+ r = uf_sdio_load();
+ if (r) {
+ uf_remove_debug_device();
+ return r;
+ }
+
+ if (sdio_block_size > -1) {
+ unifi_info(NULL, "sdio_block_size %d\n", sdio_block_size);
+ }
+
+ if (sdio_byte_mode) {
+ unifi_info(NULL, "sdio_byte_mode\n");
+ }
+
+ if (disable_power_control) {
+ unifi_info(NULL, "disable_power_control\n");
+ }
+
+ if (disable_hw_reset) {
+ unifi_info(NULL, "disable_hw_reset\n");
+ }
+
+ if (enable_wol) {
+ unifi_info(NULL, "enable_wol %d\n", enable_wol);
+ }
+
+ if (run_bh_once != -1) {
+ unifi_info(NULL, "run_bh_once %d\n", run_bh_once);
+ }
+
+ return 0;
+} /* unifi_load() */
+
+
+void __exit
+unifi_unload(void)
+{
+ /* The SDIO remove hook will call unifi_disconnect(). */
+ uf_sdio_unload();
+
+ uf_remove_debug_device();
+
+} /* unifi_unload() */
+
+module_init(unifi_load);
+module_exit(unifi_unload);
+
+MODULE_DESCRIPTION("UniFi Device driver");
+MODULE_AUTHOR("Cambridge Silicon Radio Ltd.");
+MODULE_LICENSE("GPL and additional rights");
diff --git a/drivers/staging/csr/firmware.c b/drivers/staging/csr/firmware.c
new file mode 100644
index 000000000000..d14e11839618
--- /dev/null
+++ b/drivers/staging/csr/firmware.c
@@ -0,0 +1,413 @@
+/*
+ * ---------------------------------------------------------------------------
+ * FILE: firmware.c
+ *
+ * PURPOSE:
+ * Implements the f/w related HIP core lib API.
+ * It is part of the porting exercise in Linux.
+ *
+ * Also, it contains example code for reading the loader and f/w files
+ * from the userspace and starting the SME in Linux.
+ *
+ * Copyright (C) 2005-2009 by Cambridge Silicon Radio Ltd.
+ *
+ * Refer to LICENSE.txt included with this source code for details on
+ * the license terms.
+ *
+ * ---------------------------------------------------------------------------
+ */
+#include <linux/kmod.h>
+#include <linux/vmalloc.h>
+#include <linux/firmware.h>
+#include <asm/uaccess.h>
+#include "csr_wifi_hip_unifi.h"
+#include "csr_wifi_hip_unifi_udi.h"
+#include "unifiio.h"
+#include "unifi_priv.h"
+
+/*
+ * ---------------------------------------------------------------------------
+ *
+ * F/W download. Part of the HIP core API
+ *
+ * ---------------------------------------------------------------------------
+ */
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * unifi_fw_read_start
+ *
+ * Returns a structure to be passed in unifi_fw_read().
+ * This structure is an OS specific description of the f/w file.
+ * In the linux implementation it is a buffer with the f/w and its' length.
+ * The HIP driver calls this functions to request for the loader or
+ * the firmware file.
+ * The structure pointer can be freed when unifi_fw_read_stop() is called.
+ *
+ * Arguments:
+ * ospriv Pointer to driver context.
+ * is_fw Type of firmware to retrieve
+ * info Versions information. Can be used to determine
+ * the appropriate f/w file to load.
+ *
+ * Returns:
+ * O on success, non-zero otherwise.
+ *
+ * ---------------------------------------------------------------------------
+ */
+void*
+unifi_fw_read_start(void *ospriv, s8 is_fw, const card_info_t *info)
+{
+ unifi_priv_t *priv = (unifi_priv_t*)ospriv;
+ CSR_UNUSED(info);
+
+ func_enter();
+
+ if (is_fw == UNIFI_FW_STA) {
+ /* F/w may have been released after a previous successful download. */
+ if (priv->fw_sta.dl_data == NULL) {
+ unifi_trace(priv, UDBG2, "Attempt reload of sta f/w\n");
+ uf_request_firmware_files(priv, UNIFI_FW_STA);
+ }
+ /* Set up callback struct for readfunc() */
+ if (priv->fw_sta.dl_data != NULL) {
+ func_exit();
+ return &priv->fw_sta;
+ }
+
+ } else {
+ unifi_error(priv, "downloading firmware... unknown request: %d\n", is_fw);
+ }
+
+ func_exit();
+ return NULL;
+} /* unifi_fw_read_start() */
+
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * unifi_fw_read_stop
+ *
+ * Called when the HIP driver has finished using the loader or
+ * the firmware file.
+ * The firmware buffer may be released now.
+ *
+ * Arguments:
+ * ospriv Pointer to driver context.
+ * dlpriv The pointer returned by unifi_fw_read_start()
+ *
+ * ---------------------------------------------------------------------------
+ */
+void
+unifi_fw_read_stop(void *ospriv, void *dlpriv)
+{
+ unifi_priv_t *priv = (unifi_priv_t*)ospriv;
+ struct dlpriv *dl_struct = (struct dlpriv *)dlpriv;
+ func_enter();
+
+ if (dl_struct != NULL) {
+ if (dl_struct->dl_data != NULL) {
+ unifi_trace(priv, UDBG2, "Release f/w buffer %p, %d bytes\n",
+ dl_struct->dl_data, dl_struct->dl_len);
+ }
+ uf_release_firmware(priv, dl_struct);
+ }
+
+ func_exit();
+} /* unifi_fw_read_stop() */
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * unifi_fw_open_buffer
+ *
+ * Returns a handle for a buffer dynamically allocated by the driver,
+ * e.g. into which a firmware file may have been converted from another format
+ * which is the case with some production test images.
+ *
+ * The handle may then be used by unifi_fw_read() to access the contents of
+ * the buffer.
+ *
+ * Arguments:
+ * ospriv Pointer to driver context.
+ * fwbuf Buffer containing firmware image
+ * len Length of buffer in bytes
+ *
+ * Returns
+ * Handle for buffer, or NULL on error
+ * ---------------------------------------------------------------------------
+ */
+void *
+unifi_fw_open_buffer(void *ospriv, void *fwbuf, u32 len)
+{
+ unifi_priv_t *priv = (unifi_priv_t*)ospriv;
+ func_enter();
+
+ if (fwbuf == NULL) {
+ func_exit();
+ return NULL;
+ }
+ priv->fw_conv.dl_data = fwbuf;
+ priv->fw_conv.dl_len = len;
+ priv->fw_conv.fw_desc = NULL; /* No OS f/w resource is associated */
+
+ func_exit();
+ return &priv->fw_conv;
+}
+
+/*
+ * ---------------------------------------------------------------------------
+ * unifi_fw_close_buffer
+ *
+ * Releases any handle for a buffer dynamically allocated by the driver,
+ * e.g. into which a firmware file may have been converted from another format
+ * which is the case with some production test images.
+ *
+ *
+ * Arguments:
+ * ospriv Pointer to driver context.
+ * fwbuf Buffer containing firmware image
+ *
+ * Returns
+ * Handle for buffer, or NULL on error
+ * ---------------------------------------------------------------------------
+ */
+void unifi_fw_close_buffer(void *ospriv, void *fwbuf)
+{
+}
+
+/*
+ * ---------------------------------------------------------------------------
+ * unifi_fw_read
+ *
+ * The HIP driver calls this function to ask for a part of the loader or
+ * the firmware file.
+ *
+ * Arguments:
+ * ospriv Pointer to driver context.
+ * arg The pointer returned by unifi_fw_read_start().
+ * offset The offset in the file to return from.
+ * buf A buffer to store the requested data.
+ * len The size of the buf and the size of the requested data.
+ *
+ * Returns
+ * The number of bytes read from the firmware image, or -ve on error
+ * ---------------------------------------------------------------------------
+ */
+s32
+unifi_fw_read(void *ospriv, void *arg, u32 offset, void *buf, u32 len)
+{
+ const struct dlpriv *dlpriv = arg;
+
+ if (offset >= dlpriv->dl_len) {
+ /* at end of file */
+ return 0;
+ }
+
+ if ((offset + len) > dlpriv->dl_len) {
+ /* attempt to read past end of file */
+ return -1;
+ }
+
+ memcpy(buf, dlpriv->dl_data+offset, len);
+
+ return len;
+
+} /* unifi_fw_read() */
+
+
+
+
+#define UNIFIHELPER_INIT_MODE_SMEUSER 2
+#define UNIFIHELPER_INIT_MODE_NATIVE 1
+
+/*
+ * ---------------------------------------------------------------------------
+ * uf_run_unifihelper
+ *
+ * Ask userspace to send us firmware for download by running
+ * '/usr/sbin/unififw'.
+ * The same script starts the SME userspace application.
+ * Derived from net_run_sbin_hotplug().
+ *
+ * Arguments:
+ * priv Pointer to OS private struct.
+ *
+ * Returns:
+ * None.
+ * ---------------------------------------------------------------------------
+ */
+int
+uf_run_unifihelper(unifi_priv_t *priv)
+{
+#ifdef CONFIG_HOTPLUG
+
+#ifdef ANDROID_BUILD
+ char *prog = "/system/bin/unififw";
+#else
+ char *prog = "/usr/sbin/unififw";
+#endif /* ANDROID_BUILD */
+
+ char *argv[6], *envp[4];
+ char inst_str[8];
+ char init_mode[8];
+ int i, r;
+
+#if (defined CSR_SME_USERSPACE) && (!defined CSR_SUPPORT_WEXT)
+ unifi_trace(priv, UDBG1, "SME userspace build: run unifi_helper manually\n");
+ return 0;
+#endif
+
+ unifi_trace(priv, UDBG1, "starting %s\n", prog);
+
+ snprintf(inst_str, 8, "%d", priv->instance);
+#if (defined CSR_SME_USERSPACE)
+ snprintf(init_mode, 8, "%d", UNIFIHELPER_INIT_MODE_SMEUSER);
+#else
+ snprintf(init_mode, 8, "%d", UNIFIHELPER_INIT_MODE_NATIVE);
+#endif /* CSR_SME_USERSPACE */
+
+ i = 0;
+ argv[i++] = prog;
+ argv[i++] = inst_str;
+ argv[i++] = init_mode;
+ argv[i++] = 0;
+ argv[i] = 0;
+ /* Don't add more args without making argv bigger */
+
+ /* minimal command environment */
+ i = 0;
+ envp[i++] = "HOME=/";
+ envp[i++] = "PATH=/sbin:/bin:/usr/sbin:/usr/bin";
+ envp[i] = 0;
+ /* Don't add more without making envp bigger */
+
+ unifi_trace(priv, UDBG2, "running %s %s %s\n", argv[0], argv[1], argv[2]);
+
+ r = call_usermodehelper(argv[0], argv, envp, 0);
+
+ return r;
+#else
+ unifi_trace(priv, UDBG1, "Can't automatically download firmware because kernel does not have HOTPLUG\n");
+ return -1;
+#endif
+} /* uf_run_unifihelper() */
+
+#ifdef CSR_WIFI_SPLIT_PATCH
+static u8 is_ap_mode(unifi_priv_t *priv)
+{
+ if (priv == NULL || priv->interfacePriv[0] == NULL)
+ {
+ return FALSE;
+ }
+
+ /* Test for mode requiring AP patch */
+ return(CSR_WIFI_HIP_IS_AP_FW(priv->interfacePriv[0]->interfaceMode));
+}
+#endif
+
+/*
+ * ---------------------------------------------------------------------------
+ * uf_request_firmware_files
+ *
+ * Get the firmware files from userspace.
+ *
+ * Arguments:
+ * priv Pointer to OS private struct.
+ * is_fw type of firmware to load (UNIFI_FW_STA/LOADER)
+ *
+ * Returns:
+ * None.
+ * ---------------------------------------------------------------------------
+ */
+int uf_request_firmware_files(unifi_priv_t *priv, int is_fw)
+{
+ /* uses the default method to get the firmware */
+ const struct firmware *fw_entry;
+ int postfix;
+#define UNIFI_MAX_FW_PATH_LEN 32
+ char fw_name[UNIFI_MAX_FW_PATH_LEN];
+ int r;
+
+#if (defined CSR_SUPPORT_SME) && (defined CSR_SUPPORT_WEXT)
+ if (priv->mib_data.length) {
+ vfree(priv->mib_data.data);
+ priv->mib_data.data = NULL;
+ priv->mib_data.length = 0;
+ }
+#endif /* CSR_SUPPORT_SME && CSR_SUPPORT_WEXT*/
+
+ postfix = priv->instance;
+
+ if (is_fw == UNIFI_FW_STA) {
+ /* Free kernel buffer and reload */
+ uf_release_firmware(priv, &priv->fw_sta);
+#ifdef CSR_WIFI_SPLIT_PATCH
+ scnprintf(fw_name, UNIFI_MAX_FW_PATH_LEN, "unifi-sdio-%d/%s",
+ postfix, (is_ap_mode(priv) ? "ap.xbv" : "staonly.xbv") );
+#else
+ scnprintf(fw_name, UNIFI_MAX_FW_PATH_LEN, "unifi-sdio-%d/%s",
+ postfix, "sta.xbv" );
+#endif
+ r = request_firmware(&fw_entry, fw_name, priv->unifi_device);
+ if (r == 0) {
+ priv->fw_sta.dl_data = fw_entry->data;
+ priv->fw_sta.dl_len = fw_entry->size;
+ priv->fw_sta.fw_desc = (void *)fw_entry;
+ } else {
+ unifi_trace(priv, UDBG2, "Firmware file not available\n");
+ }
+ }
+
+ return 0;
+
+} /* uf_request_firmware_files() */
+
+/*
+ * ---------------------------------------------------------------------------
+ * uf_release_firmware_files
+ *
+ * Release all buffers used to store firmware files
+ *
+ * Arguments:
+ * priv Pointer to OS private struct.
+ *
+ * Returns:
+ * None.
+ * ---------------------------------------------------------------------------
+ */
+int uf_release_firmware_files(unifi_priv_t *priv)
+{
+ uf_release_firmware(priv, &priv->fw_sta);
+
+ return 0;
+}
+
+/*
+ * ---------------------------------------------------------------------------
+ * uf_release_firmware
+ *
+ * Release specific buffer used to store firmware
+ *
+ * Arguments:
+ * priv Pointer to OS private struct.
+ * to_free Pointer to specific buffer to release
+ *
+ * Returns:
+ * None.
+ * ---------------------------------------------------------------------------
+ */
+int uf_release_firmware(unifi_priv_t *priv, struct dlpriv *to_free)
+{
+ if (to_free != NULL) {
+ if (to_free->fw_desc != NULL) {
+ release_firmware((const struct firmware *)to_free->fw_desc);
+ }
+ to_free->fw_desc = NULL;
+ to_free->dl_data = NULL;
+ to_free->dl_len = 0;
+ }
+ return 0;
+}
diff --git a/drivers/staging/csr/inet.c b/drivers/staging/csr/inet.c
new file mode 100644
index 000000000000..b4acb54ecc62
--- /dev/null
+++ b/drivers/staging/csr/inet.c
@@ -0,0 +1,106 @@
+/*
+ * ---------------------------------------------------------------------------
+ * FILE: inet.c
+ *
+ * PURPOSE:
+ * Routines related to IP address changes.
+ * Optional part of the porting exercise. It uses system network
+ * handlers to obtain the UniFi IP address and pass it to the SME
+ * using the unifi_sys_ip_configured_ind().
+ *
+ * Copyright (C) 2008-2009 Cambridge Silicon Radio Ltd.
+ *
+ * Refer to LICENSE.txt included with this source code for details on
+ * the license terms.
+ *
+ * ---------------------------------------------------------------------------
+ */
+#include <linux/inetdevice.h>
+#include <linux/notifier.h>
+
+#include "unifi_priv.h"
+#include "csr_wifi_hip_conversions.h"
+
+/*
+ * The inet notifier is global and not per-netdev. To avoid having a
+ * notifier registered when there are no unifi devices present, it's
+ * registered after the first unifi network device is registered, and
+ * unregistered when the last unifi network device is unregistered.
+ */
+
+static atomic_t inet_notif_refs = ATOMIC_INIT(0);
+
+static int uf_inetaddr_event(struct notifier_block *notif, unsigned long event, void *ifa)
+{
+ struct net_device *ndev;
+ unifi_priv_t *priv;
+ struct in_ifaddr *if_addr;
+ netInterface_priv_t *InterfacePriv = (netInterface_priv_t *)NULL;
+
+ if (!ifa || !((struct in_ifaddr *)ifa)->ifa_dev) {
+ unifi_trace(NULL, UDBG1, "uf_inetaddr_event (%lu) ifa=%p\n", event, ifa);
+ return NOTIFY_DONE;
+ }
+
+ ndev = ((struct in_ifaddr *)ifa)->ifa_dev->dev;
+ InterfacePriv = (netInterface_priv_t*) netdev_priv(ndev);
+
+ /* As the notifier is global, the call may be for a non-UniFi netdev.
+ * Therefore check the netdev_priv to make sure it's a known UniFi one.
+ */
+ if (uf_find_netdev_priv(InterfacePriv) == -1) {
+ unifi_trace(NULL, UDBG1, "uf_inetaddr_event (%lu) ndev=%p, other netdev_priv=%p\n",
+ event, ndev, InterfacePriv);
+ return NOTIFY_DONE;
+ }
+
+ if (!InterfacePriv->privPtr) {
+ unifi_error(NULL, "uf_inetaddr_event null priv (%lu) ndev=%p, InterfacePriv=%p\n",
+ event, ndev, InterfacePriv);
+ return NOTIFY_DONE;
+ }
+
+ priv = InterfacePriv->privPtr;
+ if_addr = (struct in_ifaddr *)ifa;
+
+ /* If this event is for a UniFi device, notify the SME that an IP
+ * address has been added or removed. */
+ if (uf_find_priv(priv) != -1) {
+ switch (event) {
+ case NETDEV_UP:
+ unifi_info(priv, "IP address assigned for %s\n", priv->netdev[InterfacePriv->InterfaceTag]->name);
+ priv->sta_ip_address = if_addr->ifa_address;
+#ifdef CSR_SUPPORT_WEXT
+ sme_mgt_packet_filter_set(priv);
+#endif
+ break;
+ case NETDEV_DOWN:
+ unifi_info(priv, "IP address removed for %s\n", priv->netdev[InterfacePriv->InterfaceTag]->name);
+ priv->sta_ip_address = 0xFFFFFFFF;
+#ifdef CSR_SUPPORT_WEXT
+ sme_mgt_packet_filter_set(priv);
+#endif
+ break;
+ }
+ }
+
+ return NOTIFY_DONE;
+}
+
+static struct notifier_block uf_inetaddr_notifier = {
+ .notifier_call = uf_inetaddr_event,
+};
+
+void uf_register_inet_notifier(void)
+{
+ if (atomic_inc_return(&inet_notif_refs) == 1) {
+ register_inetaddr_notifier(&uf_inetaddr_notifier);
+ }
+}
+
+void uf_unregister_inet_notifier(void)
+{
+ if (atomic_dec_return(&inet_notif_refs) == 0) {
+ unregister_inetaddr_notifier(&uf_inetaddr_notifier);
+ }
+}
diff --git a/drivers/staging/csr/init_hw.c b/drivers/staging/csr/init_hw.c
new file mode 100644
index 000000000000..3b8a4babf9a6
--- /dev/null
+++ b/drivers/staging/csr/init_hw.c
@@ -0,0 +1,108 @@
+/*
+ * ---------------------------------------------------------------------------
+ * FILE: init_hw.c
+ *
+ * PURPOSE:
+ * Use the HIP core lib to initialise the UniFi chip.
+ * It is part of the porting exercise in Linux.
+ *
+ * Copyright (C) 2009 by Cambridge Silicon Radio Ltd.
+ *
+ * Refer to LICENSE.txt included with this source code for details on
+ * the license terms.
+ *
+ * ---------------------------------------------------------------------------
+ */
+#include "csr_wifi_hip_unifi.h"
+#include "unifi_priv.h"
+
+
+#define MAX_INIT_ATTEMPTS 4
+
+extern int led_mask;
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * uf_init_hw
+ *
+ * Resets hardware, downloads and initialises f/w.
+ * This function demonstrates how to use the HIP core lib API
+ * to implement the SME unifi_sys_wifi_on_req() part of the SYS API.
+ *
+ * In a simple implementation, all this function needs to do is call
+ * unifi_init_card() and then unifi_card_info().
+ * In the Linux implementation, it will retry to initialise UniFi or
+ * try to debug the reasons if unifi_init_card() returns an error.
+ *
+ * Arguments:
+ * ospriv Pointer to OS driver structure for the device.
+ *
+ * Returns:
+ * O on success, non-zero otherwise.
+ *
+ * ---------------------------------------------------------------------------
+ */
+int
+uf_init_hw(unifi_priv_t *priv)
+{
+ int attempts = 0;
+ int priv_instance;
+ CsrResult csrResult = CSR_RESULT_FAILURE;
+
+ priv_instance = uf_find_priv(priv);
+ if (priv_instance == -1) {
+ unifi_warning(priv, "uf_init_hw: Unknown priv instance, will use fw_init[0]\n");
+ priv_instance = 0;
+ }
+
+ while (1) {
+ if (attempts > MAX_INIT_ATTEMPTS) {
+ unifi_error(priv, "Failed to initialise UniFi after %d attempts, "
+ "giving up.\n",
+ attempts);
+ break;
+ }
+ attempts++;
+
+ unifi_info(priv, "Initialising UniFi, attempt %d\n", attempts);
+
+ if (fw_init[priv_instance] > 0) {
+ unifi_notice(priv, "f/w init prevented by module parameter\n");
+ break;
+ } else if (fw_init[priv_instance] == 0) {
+ fw_init[priv_instance] ++;
+ }
+
+ /*
+ * Initialise driver core. This will perform a reset of UniFi
+ * internals, but not the SDIO CCCR.
+ */
+ CsrSdioClaim(priv->sdio);
+ csrResult = unifi_init_card(priv->card, led_mask);
+ CsrSdioRelease(priv->sdio);
+
+ if (csrResult == CSR_WIFI_HIP_RESULT_NO_DEVICE) {
+ return CsrHipResultToStatus(csrResult);
+ }
+ if (csrResult == CSR_WIFI_HIP_RESULT_NOT_FOUND) {
+ unifi_error(priv, "Firmware file required, but not found.\n");
+ return CsrHipResultToStatus(csrResult);
+ }
+ if (csrResult != CSR_RESULT_SUCCESS) {
+ /* failed. Reset h/w and try again */
+ unifi_error(priv, "Failed to initialise UniFi chip.\n");
+ continue;
+ }
+
+ /* Get the version information from the lib_hip */
+ unifi_card_info(priv->card, &priv->card_info);
+
+ return CsrHipResultToStatus(csrResult);
+ }
+
+ return CsrHipResultToStatus(csrResult);
+
+} /* uf_init_hw */
+
+
diff --git a/drivers/staging/csr/io.c b/drivers/staging/csr/io.c
new file mode 100644
index 000000000000..e6503d9620a4
--- /dev/null
+++ b/drivers/staging/csr/io.c
@@ -0,0 +1,1166 @@
+/*
+ * ---------------------------------------------------------------------------
+ * FILE: io.c
+ *
+ * PURPOSE:
+ * This file contains routines that the SDIO driver can call when a
+ * UniFi card is first inserted (or detected) and removed.
+ *
+ * When used with sdioemb, the udev scripts (at least on Ubuntu) don't
+ * recognise a UniFi being added to the system. This is because sdioemb
+ * does not register itself as a device_driver, it uses it's own code
+ * to handle insert and remove.
+ * To have Ubuntu recognise UniFi, edit /etc/udev/rules.d/85-ifupdown.rules
+ * to change this line:
+ * SUBSYSTEM=="net", DRIVERS=="?*", GOTO="net_start"
+ * to these:
+ * #SUBSYSTEM=="net", DRIVERS=="?*", GOTO="net_start"
+ * SUBSYSTEM=="net", GOTO="net_start"
+ *
+ * Then you can add a stanza to /etc/network/interfaces like this:
+ * auto eth1
+ * iface eth1 inet dhcp
+ * wpa-conf /etc/wpa_supplicant.conf
+ * This will then automatically associate when a car dis inserted.
+ *
+ * Copyright (C) 2006-2009 by Cambridge Silicon Radio Ltd.
+ *
+ * Refer to LICENSE.txt included with this source code for details on
+ * the license terms.
+ *
+ * ---------------------------------------------------------------------------
+ */
+#include <linux/proc_fs.h>
+
+#include "csr_wifi_hip_unifi.h"
+#include "csr_wifi_hip_unifiversion.h"
+#include "csr_wifi_hip_unifi_udi.h" /* for unifi_print_status() */
+#include "unifiio.h"
+#include "unifi_priv.h"
+
+
+/*
+ * Array of pointers to context structs for unifi devices that are present.
+ * The index in the array corresponds to the wlan interface number
+ * (if "wlan*" is used). If "eth*" is used, the eth* numbers are allocated
+ * after any Ethernet cards.
+ *
+ * The Arasan PCI-SDIO controller card supported by this driver has 2 slots,
+ * hence a max of 2 devices.
+ */
+static unifi_priv_t *Unifi_instances[MAX_UNIFI_DEVS];
+
+/* Array of pointers to netdev objects used by the UniFi driver, as there
+ * are now many per instance. This is used to determine which netdev events
+ * are for UniFi as opposed to other net interfaces.
+ */
+static netInterface_priv_t *Unifi_netdev_instances[MAX_UNIFI_DEVS * CSR_WIFI_NUM_INTERFACES];
+
+/*
+ * Array to hold the status of each unifi device in each slot.
+ * We only process an insert event when In_use[] for the slot is
+ * UNIFI_DEV_NOT_IN_USE. Otherwise, it means that the slot is in use or
+ * we are in the middle of a cleanup (the action on unplug).
+ */
+#define UNIFI_DEV_NOT_IN_USE 0
+#define UNIFI_DEV_IN_USE 1
+#define UNIFI_DEV_CLEANUP 2
+static int In_use[MAX_UNIFI_DEVS];
+/*
+ * Mutex to prevent UDI clients to open the character device before the priv
+ * is created and initialised.
+ */
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 37)
+DEFINE_SEMAPHORE(Unifi_instance_mutex);
+#else
+DECLARE_MUTEX(Unifi_instance_mutex);
+#endif
+/*
+ * When the device is removed, unregister waits on Unifi_cleanup_wq
+ * until all the UDI clients release the character device.
+ */
+DECLARE_WAIT_QUEUE_HEAD(Unifi_cleanup_wq);
+
+
+static int uf_read_proc(char *page, char **start, off_t offset, int count,
+ int *eof, void *data);
+
+#ifdef CSR_WIFI_RX_PATH_SPLIT
+
+static CsrResult signal_buffer_init(unifi_priv_t * priv, int size)
+{
+ int i;
+ func_enter();
+
+ priv->rxSignalBuffer.writePointer =
+ priv->rxSignalBuffer.readPointer = 0;
+ priv->rxSignalBuffer.size = size;
+ /* Allocating Memory for Signal primitive pointer */
+ for(i=0; i<size; i++)
+ {
+ priv->rxSignalBuffer.rx_buff[i].sig_len=0;
+ priv->rxSignalBuffer.rx_buff[i].bufptr = kmalloc(UNIFI_PACKED_SIGBUF_SIZE, GFP_KERNEL);
+ if (priv->rxSignalBuffer.rx_buff[i].bufptr == NULL)
+ {
+ int j;
+ unifi_error(priv,"signal_buffer_init:Failed to Allocate shared memory for T-H signals \n");
+ for(j=0;j<i;j++)
+ {
+ priv->rxSignalBuffer.rx_buff[j].sig_len=0;
+ kfree(priv->rxSignalBuffer.rx_buff[j].bufptr);
+ priv->rxSignalBuffer.rx_buff[j].bufptr = NULL;
+ }
+ func_exit();
+ return -1;
+ }
+ }
+ func_exit();
+ return 0;
+}
+
+
+static void signal_buffer_free(unifi_priv_t * priv, int size)
+{
+ int i;
+
+ for(i=0; i<size; i++)
+ {
+ priv->rxSignalBuffer.rx_buff[i].sig_len=0;
+ kfree(priv->rxSignalBuffer.rx_buff[i].bufptr);
+ priv->rxSignalBuffer.rx_buff[i].bufptr = NULL;
+ }
+}
+#endif
+/*
+ * ---------------------------------------------------------------------------
+ * uf_register_netdev
+ *
+ * Registers the network interface, installes the qdisc,
+ * and registers the inet handler.
+ * In the porting exercise, register the driver to the network
+ * stack if necessary.
+ *
+ * Arguments:
+ * priv Pointer to driver context.
+ *
+ * Returns:
+ * O on success, non-zero otherwise.
+ *
+ * Notes:
+ * We will only unregister when the card is ejected, so we must
+ * only do it once.
+ * ---------------------------------------------------------------------------
+ */
+int
+uf_register_netdev(unifi_priv_t *priv, int interfaceTag)
+{
+ int r;
+ netInterface_priv_t *interfacePriv = priv->interfacePriv[interfaceTag];
+
+ if (interfaceTag >= CSR_WIFI_NUM_INTERFACES) {
+ unifi_error(priv, "uf_register_netdev bad interfaceTag\n");
+ return -EINVAL;
+ }
+
+ /*
+ * Allocates a device number and registers device with the network
+ * stack.
+ */
+ unifi_trace(priv, UDBG5, "uf_register_netdev: netdev %d - 0x%p\n",
+ interfaceTag, priv->netdev[interfaceTag]);
+ r = register_netdev(priv->netdev[interfaceTag]);
+ if (r) {
+ unifi_error(priv, "Failed to register net device\n");
+ return -EINVAL;
+ }
+
+ /* The device is registed */
+ interfacePriv->netdev_registered = 1;
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,28)
+#ifdef CONFIG_NET_SCHED
+ /*
+ * IMPORTANT:
+ * uf_install_qdisc() holds the network device lock, we can not
+ * install the qdisk before the network device is registered.
+ */
+ r = uf_install_qdisc(priv->netdev[interfaceTag]);
+ if (r) {
+ unifi_error(priv, "Failed to install qdisc\n");
+ return r;
+ }
+#endif /* CONFIG_NET_SCHED */
+#endif /* LINUX_VERSION_CODE */
+
+#ifdef CSR_SUPPORT_SME
+ /*
+ * Register the inet handler; it notifies us for changes in the IP address.
+ */
+ uf_register_inet_notifier();
+#endif /* CSR_SUPPORT_SME */
+
+ unifi_notice(priv, "unifi%d is %s\n",
+ priv->instance, priv->netdev[interfaceTag]->name);
+
+ return 0;
+} /* uf_register_netdev */
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * uf_unregister_netdev
+ *
+ * Unregisters the network interface and the inet handler.
+ *
+ * Arguments:
+ * priv Pointer to driver context.
+ *
+ * Returns:
+ * None.
+ *
+ * ---------------------------------------------------------------------------
+ */
+void
+uf_unregister_netdev(unifi_priv_t *priv)
+{
+ int i=0;
+
+#ifdef CSR_SUPPORT_SME
+ /* Unregister the inet handler... */
+ uf_unregister_inet_notifier();
+#endif /* CSR_SUPPORT_SME */
+
+ for (i=0; i<CSR_WIFI_NUM_INTERFACES; i++) {
+ netInterface_priv_t *interfacePriv = priv->interfacePriv[i];
+ if (interfacePriv->netdev_registered) {
+ unifi_trace(priv, UDBG5,
+ "uf_unregister_netdev: netdev %d - 0x%p\n",
+ i, priv->netdev[i]);
+
+ /* ... and the netdev */
+ unregister_netdev(priv->netdev[i]);
+ interfacePriv->netdev_registered = 0;
+ }
+
+ interfacePriv->interfaceMode = 0;
+
+ /* Enable all queues by default */
+ interfacePriv->queueEnabled[0] = 1;
+ interfacePriv->queueEnabled[1] = 1;
+ interfacePriv->queueEnabled[2] = 1;
+ interfacePriv->queueEnabled[3] = 1;
+ }
+
+ priv->totalInterfaceCount = 0;
+} /* uf_unregister_netdev() */
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * register_unifi_sdio
+ *
+ * This function is called from the Probe (or equivalent) method of
+ * the SDIO driver when a UniFi card is detected.
+ * We allocate the Linux net_device struct, initialise the HIP core
+ * lib, create the char device nodes and start the userspace helper
+ * to initialise the device.
+ *
+ * Arguments:
+ * sdio_dev Pointer to SDIO context handle to use for all
+ * SDIO ops.
+ * bus_id A small number indicating the SDIO card position on the
+ * bus. Typically this is the slot number, e.g. 0, 1 etc.
+ * Valid values are 0 to MAX_UNIFI_DEVS-1.
+ * dev Pointer to kernel device manager struct.
+ *
+ * Returns:
+ * Pointer to the unifi instance, or NULL on error.
+ * ---------------------------------------------------------------------------
+ */
+static unifi_priv_t *
+register_unifi_sdio(CsrSdioFunction *sdio_dev, int bus_id, struct device *dev)
+{
+ unifi_priv_t *priv = NULL;
+ int r = -1;
+ CsrResult csrResult;
+
+ func_enter();
+
+ if ((bus_id < 0) || (bus_id >= MAX_UNIFI_DEVS)) {
+ unifi_error(priv, "register_unifi_sdio: invalid device %d\n",
+ bus_id);
+ return NULL;
+ }
+
+ down(&Unifi_instance_mutex);
+
+ if (In_use[bus_id] != UNIFI_DEV_NOT_IN_USE) {
+ unifi_error(priv, "register_unifi_sdio: device %d is already in use\n",
+ bus_id);
+ goto failed0;
+ }
+
+
+ /* Allocate device private and net_device structs */
+ priv = uf_alloc_netdevice(sdio_dev, bus_id);
+ if (priv == NULL) {
+ unifi_error(priv, "Failed to allocate driver private\n");
+ goto failed0;
+ }
+
+ priv->unifi_device = dev;
+
+ SET_NETDEV_DEV(priv->netdev[0], dev);
+
+ /* We are not ready to send data yet. */
+ netif_carrier_off(priv->netdev[0]);
+
+ /* Allocate driver context. */
+ priv->card = unifi_alloc_card(priv->sdio, priv);
+ if (priv->card == NULL) {
+ unifi_error(priv, "Failed to allocate UniFi driver card struct.\n");
+ goto failed1;
+ }
+
+ if (Unifi_instances[bus_id]) {
+ unifi_error(priv, "Internal error: instance for slot %d is already taken\n",
+ bus_id);
+ }
+ Unifi_instances[bus_id] = priv;
+ In_use[bus_id] = UNIFI_DEV_IN_USE;
+
+ /* Save the netdev_priv for use by the netdev event callback mechanism */
+ Unifi_netdev_instances[bus_id * CSR_WIFI_NUM_INTERFACES] = netdev_priv(priv->netdev[0]);
+
+ /* Initialise the mini-coredump capture buffers */
+ csrResult = unifi_coredump_init(priv->card, (u16)coredump_max);
+ if (csrResult != CSR_RESULT_SUCCESS) {
+ unifi_error(priv, "Couldn't allocate mini-coredump buffers\n");
+ }
+
+ /* Create the character device nodes */
+ r = uf_create_device_nodes(priv, bus_id);
+ if (r) {
+ goto failed1;
+ }
+
+ /*
+ * We use the slot number as unifi device index.
+ */
+ snprintf(priv->proc_entry_name, 64, "driver/unifi%d", priv->instance);
+ /*
+ * The following complex casting is in place in order to eliminate 64-bit compilation warning
+ * "cast to/from pointer from/to integer of different size"
+ */
+ if (!create_proc_read_entry(priv->proc_entry_name, 0, 0,
+ uf_read_proc, (void *)(long)priv->instance))
+ {
+ unifi_error(priv, "unifi: can't create /proc/driver/unifi\n");
+ }
+
+ /* Allocate the net_device for interfaces other than 0. */
+ {
+ int i;
+ priv->totalInterfaceCount =0;
+
+ for(i=1;i<CSR_WIFI_NUM_INTERFACES;i++)
+ {
+ if( !uf_alloc_netdevice_for_other_interfaces(priv,i) )
+ {
+ /* error occured while allocating the net_device for interface[i]. The net_device are
+ * allocated for the interfaces with id<i. Dont worry, all the allocated net_device will
+ * be releasing chen the control goes to the label failed0.
+ */
+ unifi_error(priv, "Failed to allocate driver private for interface[%d]\n",i);
+ goto failed0;
+ }
+ else
+ {
+ SET_NETDEV_DEV(priv->netdev[i], dev);
+
+ /* We are not ready to send data yet. */
+ netif_carrier_off(priv->netdev[i]);
+
+ /* Save the netdev_priv for use by the netdev event callback mechanism */
+ Unifi_netdev_instances[bus_id * CSR_WIFI_NUM_INTERFACES + i] = netdev_priv(priv->netdev[i]);
+ }
+ }
+
+ for(i=0;i<CSR_WIFI_NUM_INTERFACES;i++)
+ {
+ netInterface_priv_t *interfacePriv = priv->interfacePriv[i];
+ interfacePriv->netdev_registered=0;
+ }
+ }
+
+#ifdef CSR_WIFI_RX_PATH_SPLIT
+ if (signal_buffer_init(priv, CSR_WIFI_RX_SIGNAL_BUFFER_SIZE))
+ {
+ unifi_error(priv,"Failed to allocate shared memory for T-H signals\n");
+ goto failed2;
+ }
+ priv->rx_workqueue = create_singlethread_workqueue("rx_workq");
+ if (priv->rx_workqueue == NULL) {
+ unifi_error(priv,"create_singlethread_workqueue failed \n");
+ goto failed3;
+ }
+ INIT_WORK(&priv->rx_work_struct, rx_wq_handler);
+#endif
+
+#ifdef CSR_WIFI_HIP_DEBUG_OFFLINE
+ if (log_hip_signals)
+ {
+ uf_register_hip_offline_debug(priv);
+ }
+#endif
+
+ /* Initialise the SME related threads and parameters */
+ r = uf_sme_init(priv);
+ if (r) {
+ unifi_error(priv, "SME initialisation failed.\n");
+ goto failed4;
+ }
+
+ /*
+ * Run the userspace helper program (unififw) to perform
+ * the device initialisation.
+ */
+ unifi_trace(priv, UDBG1, "run UniFi helper app...\n");
+ r = uf_run_unifihelper(priv);
+ if (r) {
+ unifi_notice(priv, "unable to run UniFi helper app\n");
+ /* Not a fatal error. */
+ }
+
+ up(&Unifi_instance_mutex);
+
+ func_exit();
+ return priv;
+
+failed4:
+#ifdef CSR_WIFI_HIP_DEBUG_OFFLINE
+if (log_hip_signals)
+{
+ uf_unregister_hip_offline_debug(priv);
+}
+#endif
+#ifdef CSR_WIFI_RX_PATH_SPLIT
+ flush_workqueue(priv->rx_workqueue);
+ destroy_workqueue(priv->rx_workqueue);
+failed3:
+ signal_buffer_free(priv,CSR_WIFI_RX_SIGNAL_BUFFER_SIZE);
+failed2:
+#endif
+ /* Remove the device nodes */
+ uf_destroy_device_nodes(priv);
+failed1:
+ /* Deregister priv->netdev_client */
+ ul_deregister_client(priv->netdev_client);
+
+failed0:
+ if (priv && priv->card) {
+ unifi_coredump_free(priv->card);
+ unifi_free_card(priv->card);
+ }
+ if (priv) {
+ uf_free_netdevice(priv);
+ }
+
+ up(&Unifi_instance_mutex);
+
+ func_exit();
+ return NULL;
+} /* register_unifi_sdio() */
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * ask_unifi_sdio_cleanup
+ *
+ * We can not free our private context, until all the char device
+ * clients have closed the file handles. unregister_unifi_sdio() which
+ * is called when a card is removed, waits on Unifi_cleanup_wq until
+ * the reference count becomes zero. It is time to wake it up now.
+ *
+ * Arguments:
+ * priv Pointer to driver context.
+ *
+ * Returns:
+ * None.
+ * ---------------------------------------------------------------------------
+ */
+static void
+ask_unifi_sdio_cleanup(unifi_priv_t *priv)
+{
+ func_enter();
+
+ /*
+ * Now clear the flag that says the old instance is in use.
+ * This is used to prevent a new instance being started before old
+ * one has finshed closing down, for example if bounce makes the card
+ * appear to be ejected and re-inserted quickly.
+ */
+ In_use[priv->instance] = UNIFI_DEV_CLEANUP;
+
+ unifi_trace(NULL, UDBG5, "ask_unifi_sdio_cleanup: wake up cleanup workqueue.\n");
+ wake_up(&Unifi_cleanup_wq);
+
+ func_exit();
+
+} /* ask_unifi_sdio_cleanup() */
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * cleanup_unifi_sdio
+ *
+ * Release any resources owned by a unifi instance.
+ *
+ * Arguments:
+ * priv Pointer to the instance to free.
+ *
+ * Returns:
+ * None.
+ * ---------------------------------------------------------------------------
+ */
+static void
+cleanup_unifi_sdio(unifi_priv_t *priv)
+{
+ int priv_instance;
+ int i;
+ static const CsrWifiMacAddress broadcast_address = {{0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}};
+
+ func_enter();
+
+ /* Remove the device nodes */
+ uf_destroy_device_nodes(priv);
+
+ /* Mark this device as gone away by NULLing the entry in Unifi_instances */
+ Unifi_instances[priv->instance] = NULL;
+
+ unifi_trace(priv, UDBG5, "cleanup_unifi_sdio: remove_proc_entry\n");
+ /*
+ * Free the children of priv before unifi_free_netdevice() frees
+ * the priv struct
+ */
+ remove_proc_entry(priv->proc_entry_name, 0);
+
+
+ /* Unregister netdev as a client. */
+ if (priv->netdev_client) {
+ unifi_trace(priv, UDBG2, "Netdev client (id:%d s:0x%X) is unregistered\n",
+ priv->netdev_client->client_id, priv->netdev_client->sender_id);
+ ul_deregister_client(priv->netdev_client);
+ }
+
+ /* Destroy the SME related threads and parameters */
+ uf_sme_deinit(priv);
+
+#ifdef CSR_SME_USERSPACE
+ priv->smepriv = NULL;
+#endif
+
+#ifdef CSR_WIFI_HIP_DEBUG_OFFLINE
+ if (log_hip_signals)
+ {
+ uf_unregister_hip_offline_debug(priv);
+ }
+#endif
+
+ /* Free any packets left in the Rx queues */
+ for(i=0;i<CSR_WIFI_NUM_INTERFACES;i++)
+ {
+ uf_free_pending_rx_packets(priv, UF_UNCONTROLLED_PORT_Q, broadcast_address,i);
+ uf_free_pending_rx_packets(priv, UF_CONTROLLED_PORT_Q, broadcast_address,i);
+ }
+ /*
+ * We need to free the resources held by the core, which include tx skbs,
+ * otherwise we can not call unregister_netdev().
+ */
+ if (priv->card) {
+ unifi_trace(priv, UDBG5, "cleanup_unifi_sdio: free card\n");
+ unifi_coredump_free(priv->card);
+ unifi_free_card(priv->card);
+ priv->card = NULL;
+ }
+
+ /*
+ * Unregister the network device.
+ * We can not unregister the netdev before we release
+ * all pending packets in the core.
+ */
+ uf_unregister_netdev(priv);
+ priv->totalInterfaceCount = 0;
+
+ /* Clear the table of registered netdev_priv's */
+ for (i = 0; i < CSR_WIFI_NUM_INTERFACES; i++) {
+ Unifi_netdev_instances[priv->instance * CSR_WIFI_NUM_INTERFACES + i] = NULL;
+ }
+
+ unifi_trace(priv, UDBG5, "cleanup_unifi_sdio: uf_free_netdevice\n");
+ /*
+ * When uf_free_netdevice() returns, the priv is invalid
+ * so we need to remember the instance to clear the global flag later.
+ */
+ priv_instance = priv->instance;
+
+#ifdef CSR_WIFI_RX_PATH_SPLIT
+ flush_workqueue(priv->rx_workqueue);
+ destroy_workqueue(priv->rx_workqueue);
+ signal_buffer_free(priv,CSR_WIFI_RX_SIGNAL_BUFFER_SIZE);
+#endif
+
+ /* Priv is freed as part of the net_device */
+ uf_free_netdevice(priv);
+
+ /*
+ * Now clear the flag that says the old instance is in use.
+ * This is used to prevent a new instance being started before old
+ * one has finshed closing down, for example if bounce makes the card
+ * appear to be ejected and re-inserted quickly.
+ */
+ In_use[priv_instance] = UNIFI_DEV_NOT_IN_USE;
+
+ unifi_trace(NULL, UDBG5, "cleanup_unifi_sdio: DONE.\n");
+
+ func_exit();
+
+} /* cleanup_unifi_sdio() */
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * unregister_unifi_sdio
+ *
+ * Call from SDIO driver when it detects that UniFi has been removed.
+ *
+ * Arguments:
+ * bus_id Number of the card that was ejected.
+ *
+ * Returns:
+ * None.
+ * ---------------------------------------------------------------------------
+ */
+static void
+unregister_unifi_sdio(int bus_id)
+{
+ unifi_priv_t *priv;
+ int interfaceTag=0;
+ u8 reason = CONFIG_IND_EXIT;
+
+ if ((bus_id < 0) || (bus_id >= MAX_UNIFI_DEVS)) {
+ unifi_error(NULL, "unregister_unifi_sdio: invalid device %d\n",
+ bus_id);
+ return;
+ }
+
+ priv = Unifi_instances[bus_id];
+ if (priv == NULL) {
+ unifi_error(priv, "unregister_unifi_sdio: device %d is not registered\n",
+ bus_id);
+ func_exit();
+ return;
+ }
+
+ /* Stop the network traffic before freeing the core. */
+ for(interfaceTag=0;interfaceTag<priv->totalInterfaceCount;interfaceTag++)
+ {
+ netInterface_priv_t *interfacePriv = priv->interfacePriv[interfaceTag];
+ if(interfacePriv->netdev_registered)
+ {
+ netif_carrier_off(priv->netdev[interfaceTag]);
+ UF_NETIF_TX_STOP_ALL_QUEUES(priv->netdev[interfaceTag]);
+ }
+ }
+
+#ifdef CSR_NATIVE_LINUX
+ /*
+ * If the unifi thread was started, signal it to stop. This
+ * should cause any userspace processes with open unifi device to
+ * close them.
+ */
+ uf_stop_thread(priv, &priv->bh_thread);
+
+ /* Unregister the interrupt handler */
+ if (csr_sdio_linux_remove_irq(priv->sdio)) {
+ unifi_notice(priv,
+ "csr_sdio_linux_remove_irq failed to talk to card.\n");
+ }
+
+ /* Ensure no MLME functions are waiting on a the mlme_event semaphore. */
+ uf_abort_mlme(priv);
+#endif /* CSR_NATIVE_LINUX */
+
+ ul_log_config_ind(priv, &reason, sizeof(u8));
+
+ /* Deregister the UDI hook from the core. */
+ unifi_remove_udi_hook(priv->card, logging_handler);
+
+ uf_put_instance(bus_id);
+
+ /*
+ * Wait until the device is cleaned up. i.e., when all userspace
+ * processes have closed any open unifi devices.
+ */
+ wait_event(Unifi_cleanup_wq, In_use[bus_id] == UNIFI_DEV_CLEANUP);
+ unifi_trace(NULL, UDBG5, "Received clean up event\n");
+
+ /* Now we can free the private context and the char device nodes */
+ cleanup_unifi_sdio(priv);
+
+} /* unregister_unifi_sdio() */
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * uf_find_instance
+ *
+ * Find the context structure for a given UniFi device instance.
+ *
+ * Arguments:
+ * inst The instance number to look for.
+ *
+ * Returns:
+ * None.
+ * ---------------------------------------------------------------------------
+ */
+unifi_priv_t *
+uf_find_instance(int inst)
+{
+ if ((inst < 0) || (inst >= MAX_UNIFI_DEVS)) {
+ return NULL;
+ }
+ return Unifi_instances[inst];
+} /* uf_find_instance() */
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * uf_find_priv
+ *
+ * Find the device instance for a given context structure.
+ *
+ * Arguments:
+ * priv The context structure pointer to look for.
+ *
+ * Returns:
+ * index of instance, -1 otherwise.
+ * ---------------------------------------------------------------------------
+ */
+int
+uf_find_priv(unifi_priv_t *priv)
+{
+ int inst;
+
+ if (!priv) {
+ return -1;
+ }
+
+ for (inst = 0; inst < MAX_UNIFI_DEVS; inst++) {
+ if (Unifi_instances[inst] == priv) {
+ return inst;
+ }
+ }
+
+ return -1;
+} /* uf_find_priv() */
+
+/*
+ * ---------------------------------------------------------------------------
+ * uf_find_netdev_priv
+ *
+ * Find the device instance for a given netdev context structure.
+ *
+ * Arguments:
+ * priv The context structure pointer to look for.
+ *
+ * Returns:
+ * index of instance, -1 otherwise.
+ * ---------------------------------------------------------------------------
+ */
+int
+uf_find_netdev_priv(netInterface_priv_t *priv)
+{
+ int inst;
+
+ if (!priv) {
+ return -1;
+ }
+
+ for (inst = 0; inst < MAX_UNIFI_DEVS * CSR_WIFI_NUM_INTERFACES; inst++) {
+ if (Unifi_netdev_instances[inst] == priv) {
+ return inst;
+ }
+ }
+
+ return -1;
+} /* uf_find_netdev_priv() */
+
+/*
+ * ---------------------------------------------------------------------------
+ * uf_get_instance
+ *
+ * Find the context structure for a given UniFi device instance
+ * and increment the reference count.
+ *
+ * Arguments:
+ * inst The instance number to look for.
+ *
+ * Returns:
+ * Pointer to the instance or NULL if no instance exists.
+ * ---------------------------------------------------------------------------
+ */
+unifi_priv_t *
+uf_get_instance(int inst)
+{
+ unifi_priv_t *priv;
+
+ down(&Unifi_instance_mutex);
+
+ priv = uf_find_instance(inst);
+ if (priv) {
+ priv->ref_count++;
+ }
+
+ up(&Unifi_instance_mutex);
+
+ return priv;
+}
+
+/*
+ * ---------------------------------------------------------------------------
+ * uf_put_instance
+ *
+ * Decrement the context reference count, freeing resources and
+ * shutting down the driver when the count reaches zero.
+ *
+ * Arguments:
+ * inst The instance number to look for.
+ *
+ * Returns:
+ * Pointer to the instance or NULL if no instance exists.
+ * ---------------------------------------------------------------------------
+ */
+void
+uf_put_instance(int inst)
+{
+ unifi_priv_t *priv;
+
+ down(&Unifi_instance_mutex);
+
+ priv = uf_find_instance(inst);
+ if (priv) {
+ priv->ref_count--;
+ if (priv->ref_count == 0) {
+ ask_unifi_sdio_cleanup(priv);
+ }
+ }
+
+ up(&Unifi_instance_mutex);
+}
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * uf_read_proc
+ *
+ * Read method for driver node in /proc/driver/unifi0
+ *
+ * Arguments:
+ * page
+ * start
+ * offset
+ * count
+ * eof
+ * data
+ *
+ * Returns:
+ * None.
+ * ---------------------------------------------------------------------------
+ */
+#ifdef CONFIG_PROC_FS
+static int
+uf_read_proc(char *page, char **start, off_t offset, int count,
+ int *eof, void *data)
+{
+#define UNIFI_DEBUG_TXT_BUFFER 8*1024
+ unifi_priv_t *priv;
+ int actual_amount_to_copy;
+ char *p, *orig_p;
+ s32 remain = UNIFI_DEBUG_TXT_BUFFER;
+ s32 written;
+ int i;
+
+ /*
+ * The following complex casting is in place in order to eliminate 64-bit compilation warning
+ * "cast to/from pointer from/to integer of different size"
+ */
+ priv = uf_find_instance((int)(long)data);
+ if (!priv) {
+ return 0;
+ }
+
+ p = kmalloc( UNIFI_DEBUG_TXT_BUFFER, GFP_KERNEL );
+
+ orig_p = p;
+
+ written = CsrSnprintf(p, remain, "UniFi SDIO Driver: %s %s %s\n",
+ CSR_WIFI_VERSION, __DATE__, __TIME__);
+ UNIFI_SNPRINTF_RET(p, remain, written);
+#ifdef CSR_SME_USERSPACE
+ written = CsrSnprintf(p, remain, "SME: CSR userspace ");
+ UNIFI_SNPRINTF_RET(p, remain, written);
+#ifdef CSR_SUPPORT_WEXT
+ written = CsrSnprintf(p, remain, "with WEXT support\n");
+#else
+ written = CsrSnprintf(p, remain, "\n");
+#endif /* CSR_SUPPORT_WEXT */
+ UNIFI_SNPRINTF_RET(p, remain, written);
+#endif /* CSR_SME_USERSPACE */
+#ifdef CSR_NATIVE_LINUX
+ written = CsrSnprintf(p, remain, "SME: native\n");
+ UNIFI_SNPRINTF_RET(p, remain, written);
+#endif
+
+#ifdef CSR_SUPPORT_SME
+ written = CsrSnprintf(p, remain,
+ "Firmware (ROM) build:%lu, Patch:%lu\n",
+ priv->card_info.fw_build,
+ priv->sme_versions.firmwarePatch);
+ UNIFI_SNPRINTF_RET(p, remain, written);
+#endif
+ p += unifi_print_status(priv->card, p, &remain);
+
+ written = CsrSnprintf(p, remain, "Last dbg str: %s\n",
+ priv->last_debug_string);
+ UNIFI_SNPRINTF_RET(p, remain, written);
+
+ written = CsrSnprintf(p, remain, "Last dbg16:");
+ UNIFI_SNPRINTF_RET(p, remain, written);
+ for (i = 0; i < 8; i++) {
+ written = CsrSnprintf(p, remain, " %04X",
+ priv->last_debug_word16[i]);
+ UNIFI_SNPRINTF_RET(p, remain, written);
+ }
+ written = CsrSnprintf(p, remain, "\n");
+ UNIFI_SNPRINTF_RET(p, remain, written);
+ written = CsrSnprintf(p, remain, " ");
+ UNIFI_SNPRINTF_RET(p, remain, written);
+ for (; i < 16; i++) {
+ written = CsrSnprintf(p, remain, " %04X",
+ priv->last_debug_word16[i]);
+ UNIFI_SNPRINTF_RET(p, remain, written);
+ }
+ written = CsrSnprintf(p, remain, "\n");
+ UNIFI_SNPRINTF_RET(p, remain, written);
+ *start = page;
+
+ written = UNIFI_DEBUG_TXT_BUFFER - remain;
+
+ if( offset >= written )
+ {
+ *eof = 1;
+ kfree( orig_p );
+ return(0);
+ }
+
+ if( offset + count > written )
+ {
+ actual_amount_to_copy = written - offset;
+ *eof = 1;
+ }
+ else
+ {
+ actual_amount_to_copy = count;
+ }
+
+ memcpy( page, &(orig_p[offset]), actual_amount_to_copy );
+
+ kfree( orig_p );
+
+ return( actual_amount_to_copy );
+} /* uf_read_proc() */
+#endif
+
+
+
+
+static void
+uf_lx_suspend(CsrSdioFunction *sdio_ctx)
+{
+ unifi_priv_t *priv = sdio_ctx->driverData;
+ unifi_suspend(priv);
+
+ CsrSdioSuspendAcknowledge(sdio_ctx, CSR_RESULT_SUCCESS);
+}
+
+static void
+uf_lx_resume(CsrSdioFunction *sdio_ctx)
+{
+ unifi_priv_t *priv = sdio_ctx->driverData;
+ unifi_resume(priv);
+
+ CsrSdioResumeAcknowledge(sdio_ctx, CSR_RESULT_SUCCESS);
+}
+
+static int active_slot = MAX_UNIFI_DEVS;
+static struct device *os_devices[MAX_UNIFI_DEVS];
+
+void
+uf_add_os_device(int bus_id, struct device *os_device)
+{
+ if ((bus_id < 0) || (bus_id >= MAX_UNIFI_DEVS)) {
+ unifi_error(NULL, "uf_add_os_device: invalid device %d\n",
+ bus_id);
+ return;
+ }
+
+ active_slot = bus_id;
+ os_devices[bus_id] = os_device;
+} /* uf_add_os_device() */
+
+void
+uf_remove_os_device(int bus_id)
+{
+ if ((bus_id < 0) || (bus_id >= MAX_UNIFI_DEVS)) {
+ unifi_error(NULL, "uf_remove_os_device: invalid device %d\n",
+ bus_id);
+ return;
+ }
+
+ active_slot = bus_id;
+ os_devices[bus_id] = NULL;
+} /* uf_remove_os_device() */
+
+static void
+uf_sdio_inserted(CsrSdioFunction *sdio_ctx)
+{
+ unifi_priv_t *priv;
+
+ unifi_trace(NULL, UDBG5, "uf_sdio_inserted(0x%p), slot_id=%d, dev=%p\n",
+ sdio_ctx, active_slot, os_devices[active_slot]);
+
+ priv = register_unifi_sdio(sdio_ctx, active_slot, os_devices[active_slot]);
+ if (priv == NULL) {
+ CsrSdioInsertedAcknowledge(sdio_ctx, CSR_RESULT_FAILURE);
+ return;
+ }
+
+ sdio_ctx->driverData = priv;
+
+ CsrSdioInsertedAcknowledge(sdio_ctx, CSR_RESULT_SUCCESS);
+} /* uf_sdio_inserted() */
+
+
+static void
+uf_sdio_removed(CsrSdioFunction *sdio_ctx)
+{
+ unregister_unifi_sdio(active_slot);
+ CsrSdioRemovedAcknowledge(sdio_ctx);
+} /* uf_sdio_removed() */
+
+
+static void
+uf_sdio_dsr_handler(CsrSdioFunction *sdio_ctx)
+{
+ unifi_priv_t *priv = sdio_ctx->driverData;
+
+ unifi_sdio_interrupt_handler(priv->card);
+} /* uf_sdio_dsr_handler() */
+
+/*
+ * ---------------------------------------------------------------------------
+ * uf_sdio_int_handler
+ *
+ * Interrupt callback function for SDIO interrupts.
+ * This is called in kernel context (i.e. not interrupt context).
+ * We retrieve the unifi context pointer and call the main UniFi
+ * interrupt handler.
+ *
+ * Arguments:
+ * fdev SDIO context pointer
+ *
+ * Returns:
+ * None.
+ * ---------------------------------------------------------------------------
+ */
+static CsrSdioInterruptDsrCallback
+uf_sdio_int_handler(CsrSdioFunction *sdio_ctx)
+{
+ return uf_sdio_dsr_handler;
+} /* uf_sdio_int_handler() */
+
+
+
+
+static CsrSdioFunctionId unifi_ids[] =
+{
+ {
+ .manfId = SDIO_MANF_ID_CSR,
+ .cardId = SDIO_CARD_ID_UNIFI_3,
+ .sdioFunction = SDIO_WLAN_FUNC_ID_UNIFI_3,
+ .sdioInterface = CSR_SDIO_ANY_SDIO_INTERFACE,
+ },
+ {
+ .manfId = SDIO_MANF_ID_CSR,
+ .cardId = SDIO_CARD_ID_UNIFI_4,
+ .sdioFunction = SDIO_WLAN_FUNC_ID_UNIFI_4,
+ .sdioInterface = CSR_SDIO_ANY_SDIO_INTERFACE,
+ }
+};
+
+
+/*
+ * Structure to register with the glue layer.
+ */
+static CsrSdioFunctionDriver unifi_sdioFunction_drv =
+{
+ .inserted = uf_sdio_inserted,
+ .removed = uf_sdio_removed,
+ .intr = uf_sdio_int_handler,
+ .suspend = uf_lx_suspend,
+ .resume = uf_lx_resume,
+
+ .ids = unifi_ids,
+ .idsCount = sizeof(unifi_ids) / sizeof(unifi_ids[0])
+};
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * uf_sdio_load
+ * uf_sdio_unload
+ *
+ * These functions are called from the main module load and unload
+ * functions. They perform the appropriate operations for the monolithic
+ * driver.
+ *
+ * Arguments:
+ * None.
+ *
+ * Returns:
+ * None.
+ * ---------------------------------------------------------------------------
+ */
+int __init
+uf_sdio_load(void)
+{
+ CsrResult csrResult;
+
+ csrResult = CsrSdioFunctionDriverRegister(&unifi_sdioFunction_drv);
+ if (csrResult != CSR_RESULT_SUCCESS) {
+ unifi_error(NULL, "Failed to register UniFi SDIO driver: csrResult=%d\n", csrResult);
+ return -EIO;
+ }
+
+ return 0;
+} /* uf_sdio_load() */
+
+
+
+void __exit
+uf_sdio_unload(void)
+{
+ CsrSdioFunctionDriverUnregister(&unifi_sdioFunction_drv);
+} /* uf_sdio_unload() */
+
diff --git a/drivers/staging/csr/mlme.c b/drivers/staging/csr/mlme.c
new file mode 100644
index 000000000000..ed767eccbb32
--- /dev/null
+++ b/drivers/staging/csr/mlme.c
@@ -0,0 +1,436 @@
+/*
+ * ---------------------------------------------------------------------------
+ * FILE: mlme.c
+ *
+ * PURPOSE:
+ * This file provides functions to send MLME requests to the UniFi.
+ *
+ * Copyright (C) 2007-2008 by Cambridge Silicon Radio Ltd.
+ *
+ * Refer to LICENSE.txt included with this source code for details on
+ * the license terms.
+ *
+ * ---------------------------------------------------------------------------
+ */
+#include "csr_wifi_hip_unifi.h"
+#include "unifi_priv.h"
+
+/*
+ * ---------------------------------------------------------------------------
+ * unifi_mlme_wait_for_reply
+ *
+ * Wait for a reply after sending a signal.
+ *
+ * Arguments:
+ * priv Pointer to device private context struct
+ * ul_client Pointer to linux client
+ * sig_reply_id ID of the expected reply (defined in sigs.h).
+ * timeout timeout in ms
+ *
+ * Returns:
+ * 0 on success, -ve POSIX code on error.
+ *
+ * Notes:
+ * This function waits for a specific (sig_reply_id) signal from UniFi.
+ * It also match the sequence number of the received (cfm) signal, with
+ * the latest sequence number of the signal (req) we have sent.
+ * These two number match be equal.
+ * Should only be used for waiting xxx.cfm signals and only after
+ * we have sent the matching xxx.req signal to UniFi.
+ * If no response is received within the expected time (timeout), we assume
+ * that the UniFi is busy and return an error.
+ * If the wait is aborted by a kernel signal arriving, we stop waiting.
+ * If a response from UniFi is not what we expected, we discard it and
+ * wait again. This could be a response from an aborted request. If we
+ * see several bad responses we assume we have lost synchronisation with
+ * UniFi.
+ * ---------------------------------------------------------------------------
+ */
+static int
+unifi_mlme_wait_for_reply(unifi_priv_t *priv, ul_client_t *pcli, int sig_reply_id, int timeout)
+{
+ int retries = 0;
+ long r;
+ long t = timeout;
+ unsigned int sent_seq_no;
+
+ /* Convert t in ms to jiffies */
+ t = msecs_to_jiffies(t);
+
+ do {
+ /* Wait for the confirm or timeout. */
+ r = wait_event_interruptible_timeout(pcli->udi_wq,
+ (pcli->wake_up_wq_id) || (priv->io_aborted == 1),
+ t);
+ /* Check for general i/o error */
+ if (priv->io_aborted) {
+ unifi_error(priv, "MLME operation aborted\n");
+ return -EIO;
+ }
+
+ /*
+ * If r=0 the request has timed-out.
+ * If r>0 the request has completed successfully.
+ * If r=-ERESTARTSYS an event (kill signal) has interrupted the wait_event.
+ */
+ if ((r == 0) && (pcli->wake_up_wq_id == 0)) {
+ unifi_error(priv, "mlme_wait: timed-out waiting for 0x%.4X, after %lu msec.\n",
+ sig_reply_id, jiffies_to_msecs(t));
+ pcli->wake_up_wq_id = 0;
+ return -ETIMEDOUT;
+ } else if (r == -ERESTARTSYS) {
+ unifi_error(priv, "mlme_wait: waiting for 0x%.4X was aborted.\n", sig_reply_id);
+ pcli->wake_up_wq_id = 0;
+ return -EINTR;
+ } else {
+ /* Get the sequence number of the signal that we previously set. */
+ if (pcli->seq_no != 0) {
+ sent_seq_no = pcli->seq_no - 1;
+ } else {
+ sent_seq_no = 0x0F;
+ }
+
+ unifi_trace(priv, UDBG5, "Received 0x%.4X, seq: (r:%d, s:%d)\n",
+ pcli->wake_up_wq_id,
+ pcli->wake_seq_no, sent_seq_no);
+
+ /* The two sequence ids must match. */
+ if (pcli->wake_seq_no == sent_seq_no) {
+ /* and the signal ids must match. */
+ if (sig_reply_id == pcli->wake_up_wq_id) {
+ /* Found the expected signal */
+ break;
+ } else {
+ /* This should never happen ... */
+ unifi_error(priv, "mlme_wait: mismatching signal id (0x%.4X - exp 0x%.4X) (seq %d)\n",
+ pcli->wake_up_wq_id,
+ sig_reply_id,
+ pcli->wake_seq_no);
+ pcli->wake_up_wq_id = 0;
+ return -EIO;
+ }
+ }
+ /* Wait for the next signal. */
+ pcli->wake_up_wq_id = 0;
+
+ retries ++;
+ if (retries >= 3) {
+ unifi_error(priv, "mlme_wait: confirm wait retries exhausted (0x%.4X - exp 0x%.4X)\n",
+ pcli->wake_up_wq_id,
+ sig_reply_id);
+ pcli->wake_up_wq_id = 0;
+ return -EIO;
+ }
+ }
+ } while (1);
+
+ pcli->wake_up_wq_id = 0;
+
+ return 0;
+} /* unifi_mlme_wait_for_reply() */
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * unifi_mlme_blocking_request
+ *
+ * Send a MLME request signal to UniFi.
+ *
+ * Arguments:
+ * priv Pointer to device private context struct
+ * pcli Pointer to context of calling process
+ * sig Pointer to the signal to send
+ * data_ptrs Pointer to the bulk data of the signal
+ * timeout The request's timeout.
+ *
+ * Returns:
+ * 0 on success, 802.11 result code on error.
+ * ---------------------------------------------------------------------------
+ */
+int
+unifi_mlme_blocking_request(unifi_priv_t *priv, ul_client_t *pcli,
+ CSR_SIGNAL *sig, bulk_data_param_t *data_ptrs,
+ int timeout)
+{
+ int r;
+
+ func_enter();
+
+ if (sig->SignalPrimitiveHeader.SignalId == 0) {
+ unifi_error(priv, "unifi_mlme_blocking_request: Invalid Signal Id (0x%x)\n",
+ sig->SignalPrimitiveHeader.SignalId);
+ return -EINVAL;
+ }
+
+ down(&priv->mlme_blocking_mutex);
+
+ sig->SignalPrimitiveHeader.ReceiverProcessId = 0;
+ sig->SignalPrimitiveHeader.SenderProcessId = pcli->sender_id | pcli->seq_no;
+
+ unifi_trace(priv, UDBG2, "Send client=%d, S:0x%04X, sig 0x%.4X\n",
+ pcli->client_id,
+ sig->SignalPrimitiveHeader.SenderProcessId,
+ sig->SignalPrimitiveHeader.SignalId);
+ /* Send the signal to UniFi */
+ r = ul_send_signal_unpacked(priv, sig, data_ptrs);
+ if (r) {
+ up(&priv->mlme_blocking_mutex);
+ unifi_error(priv, "Error queueing MLME REQUEST signal\n");
+ return r;
+ }
+
+ unifi_trace(priv, UDBG5, "Send 0x%.4X, seq = %d\n",
+ sig->SignalPrimitiveHeader.SignalId, pcli->seq_no);
+
+ /*
+ * Advance the sequence number of the last sent signal, only
+ * if the signal has been successfully set.
+ */
+ pcli->seq_no++;
+ if (pcli->seq_no > 0x0F) {
+ pcli->seq_no = 0;
+ }
+
+ r = unifi_mlme_wait_for_reply(priv, pcli, (sig->SignalPrimitiveHeader.SignalId + 1), timeout);
+ up(&priv->mlme_blocking_mutex);
+
+ if (r) {
+ unifi_error(priv, "Error waiting for MLME CONFIRM signal\n");
+ return r;
+ }
+
+ func_exit();
+ return 0;
+} /* unifi_mlme_blocking_request() */
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * unifi_mlme_copy_reply_and_wakeup_client
+ *
+ * Copy the reply signal from UniFi to the client's structure
+ * and wake up the waiting client.
+ *
+ * Arguments:
+ * None.
+ *
+ * Returns:
+ * None.
+ * ---------------------------------------------------------------------------
+ */
+void
+unifi_mlme_copy_reply_and_wakeup_client(ul_client_t *pcli,
+ CSR_SIGNAL *signal, int signal_len,
+ const bulk_data_param_t *bulkdata)
+{
+ int i;
+
+ /* Copy the signal to the reply */
+ memcpy(pcli->reply_signal, signal, signal_len);
+
+ /* Get the sequence number of the signal that woke us up. */
+ pcli->wake_seq_no = pcli->reply_signal->SignalPrimitiveHeader.ReceiverProcessId & 0x0F;
+
+ /* Append any bulk data */
+ for (i = 0; i < UNIFI_MAX_DATA_REFERENCES; i++) {
+ if (bulkdata->d[i].data_length > 0) {
+ if (bulkdata->d[i].os_data_ptr) {
+ memcpy(pcli->reply_bulkdata[i]->ptr, bulkdata->d[i].os_data_ptr, bulkdata->d[i].data_length);
+ pcli->reply_bulkdata[i]->length = bulkdata->d[i].data_length;
+ } else {
+ pcli->reply_bulkdata[i]->length = 0;
+ }
+ }
+ }
+
+ /* Wake the requesting MLME function. */
+ pcli->wake_up_wq_id = pcli->reply_signal->SignalPrimitiveHeader.SignalId;
+ wake_up_interruptible(&pcli->udi_wq);
+
+} /* unifi_mlme_copy_reply_and_wakeup_client() */
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * uf_abort_mlme
+ *
+ * Abort any MLME operation in progress.
+ * This is used in the error recovery mechanism.
+ *
+ * Arguments:
+ * priv Pointer to driver context.
+ *
+ * Returns:
+ * 0 on success.
+ * ---------------------------------------------------------------------------
+ */
+int
+uf_abort_mlme(unifi_priv_t *priv)
+{
+ ul_client_t *ul_cli;
+
+ /* Ensure no MLME functions are waiting on a the mlme_event semaphore. */
+ priv->io_aborted = 1;
+
+ ul_cli = priv->netdev_client;
+ if (ul_cli) {
+ wake_up_interruptible(&ul_cli->udi_wq);
+ }
+
+ ul_cli = priv->wext_client;
+ if (ul_cli) {
+ wake_up_interruptible(&ul_cli->udi_wq);
+ }
+
+ return 0;
+} /* uf_abort_mlme() */
+
+
+
+/*
+ * ---------------------------------------------------------------------------
+ *
+ * Human-readable decoding of Reason and Result codes.
+ *
+ * ---------------------------------------------------------------------------
+ */
+
+struct mlme_code {
+ const char *name;
+ int id;
+};
+
+static const struct mlme_code Result_codes[] = {
+ { "Success", 0x0000 },
+ { "Unspecified Failure", 0x0001 },
+ /* (Reserved) 0x0002 - 0x0009 */
+ { "Refused Capabilities Mismatch", 0x000A },
+ /* (Reserved) 0x000B */
+ { "Refused External Reason", 0x000C },
+ /* (Reserved) 0x000D - 0x0010 */
+ { "Refused AP Out Of Memory", 0x0011 },
+ { "Refused Basic Rates Mismatch", 0x0012 },
+ /* (Reserved) 0x0013 - 0x001F */
+ { "Failure", 0x0020 },
+ /* (Reserved) 0x0021 - 0x0024 */
+ { "Refused Reason Unspecified", 0x0025 },
+ { "Invalid Parameters", 0x0026 },
+ { "Rejected With Suggested Changes", 0x0027 },
+ /* (Reserved) 0x0028 - 0x002E */
+ { "Rejected For Delay Period", 0x002F },
+ { "Not Allowed", 0x0030 },
+ { "Not Present", 0x0031 },
+ { "Not QSTA", 0x0032 },
+ /* (Reserved) 0x0033 - 0x7FFF */
+ { "Timeout", 0x8000 },
+ { "Too Many Simultaneous Requests", 0x8001 },
+ { "BSS Already Started Or Joined", 0x8002 },
+ { "Not Supported", 0x8003 },
+ { "Transmission Failure", 0x8004 },
+ { "Refused Not Authenticated", 0x8005 },
+ { "Reset Required Before Start", 0x8006 },
+ { "LM Info Unavailable", 0x8007 },
+ { NULL, -1 }
+};
+
+static const struct mlme_code Reason_codes[] = {
+ /* (Reserved) 0x0000 */
+ { "Unspecified Reason", 0x0001 },
+ { "Authentication Not Valid", 0x0002 },
+ { "Deauthenticated Leave BSS", 0x0003 },
+ { "Disassociated Inactivity", 0x0004 },
+ { "AP Overload", 0x0005 },
+ { "Class2 Frame Error", 0x0006 },
+ { "Class3 Frame Error", 0x0007 },
+ { "Disassociated Leave BSS", 0x0008 },
+ { "Association Not Authenticated", 0x0009 },
+ { "Disassociated Power Capability", 0x000A },
+ { "Disassociated Supported Channels", 0x000B },
+ /* (Reserved) 0x000C */
+ { "Invalid Information Element", 0x000D },
+ { "Michael MIC Failure", 0x000E },
+ { "Fourway Handshake Timeout", 0x000F },
+ { "Group Key Update Timeout", 0x0010 },
+ { "Handshake Element Different", 0x0011 },
+ { "Invalid Group Cipher", 0x0012 },
+ { "Invalid Pairwise Cipher", 0x0013 },
+ { "Invalid AKMP", 0x0014 },
+ { "Unsupported RSN IE Version", 0x0015 },
+ { "Invalid RSN IE Capabilities", 0x0016 },
+ { "Dot1X Auth Failed", 0x0017 },
+ { "Cipher Rejected By Policy", 0x0018 },
+ /* (Reserved) 0x0019 - 0x001F */
+ { "QoS Unspecified Reason", 0x0020 },
+ { "QoS Insufficient Bandwidth", 0x0021 },
+ { "QoS Excessive Not Ack", 0x0022 },
+ { "QoS TXOP Limit Exceeded", 0x0023 },
+ { "QSTA Leaving", 0x0024 },
+ { "End TS, End DLS, End BA", 0x0025 },
+ { "Unknown TS, Unknown DLS, Unknown BA", 0x0026 },
+ { "Timeout", 0x0027 },
+ /* (Reserved) 0x0028 - 0x002C */
+ { "STAKey Mismatch", 0x002D },
+ { NULL, -1 }
+};
+
+
+static const char *
+lookup_something(const struct mlme_code *n, int id)
+{
+ for (; n->name; n++) {
+ if (n->id == id) {
+ return n->name;
+ }
+ }
+
+ /* not found */
+ return NULL;
+} /* lookup_something() */
+
+
+const char *
+lookup_result_code(int result)
+{
+ static char fallback[16];
+ const char *str;
+
+ str = lookup_something(Result_codes, result);
+
+ if (str == NULL) {
+ snprintf(fallback, 16, "%d", result);
+ str = fallback;
+ }
+
+ return str;
+} /* lookup_result_code() */
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * lookup_reason
+ *
+ * Return a description string for a WiFi MLME ReasonCode.
+ *
+ * Arguments:
+ * reason The ReasonCode to interpret.
+ *
+ * Returns:
+ * Pointer to description string.
+ * ---------------------------------------------------------------------------
+ */
+const char *
+lookup_reason_code(int reason)
+{
+ static char fallback[16];
+ const char *str;
+
+ str = lookup_something(Reason_codes, reason);
+
+ if (str == NULL) {
+ snprintf(fallback, 16, "%d", reason);
+ str = fallback;
+ }
+
+ return str;
+} /* lookup_reason_code() */
+
diff --git a/drivers/staging/csr/monitor.c b/drivers/staging/csr/monitor.c
new file mode 100644
index 000000000000..628782ad641e
--- /dev/null
+++ b/drivers/staging/csr/monitor.c
@@ -0,0 +1,399 @@
+/*
+ * ---------------------------------------------------------------------------
+ * FILE: monitor.c
+ *
+ * Copyright (C) 2006-2008 by Cambridge Silicon Radio Ltd.
+ *
+ * Refer to LICENSE.txt included with this source code for details on
+ * the license terms.
+ *
+ * ---------------------------------------------------------------------------
+ */
+
+#include "unifi_priv.h"
+
+#ifdef UNIFI_SNIFF_ARPHRD
+
+
+#if (UNIFI_SNIFF_ARPHRD == ARPHRD_IEEE80211_RADIOTAP)
+#include <net/ieee80211_radiotap.h>
+#endif
+
+#ifndef ETH_P_80211_RAW
+#define ETH_P_80211_RAW ETH_P_ALL
+#endif
+
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * uf_start_sniff
+ *
+ * Start UniFi capture in SNIFF mode, i.e capture everything it hears.
+ *
+ * Arguments:
+ * priv Pointer to device private context struct
+ *
+ * Returns:
+ * 0 on success or kernel error code
+ * ---------------------------------------------------------------------------
+ */
+int
+uf_start_sniff(unifi_priv_t *priv)
+{
+ ul_client_t *pcli = priv->wext_client;
+ CSR_SIGNAL signal;
+ CSR_MLME_SNIFFJOIN_REQUEST *req = &signal.u.MlmeSniffjoinRequest;
+ int timeout = 1000;
+ int r;
+
+ req->Ifindex = priv->if_index;
+ req->Channel = priv->wext_conf.channel;
+ req->ChannelStartingFactor = 0;
+
+ signal.SignalPrimitiveHeader.SignalId = CSR_MLME_SNIFFJOIN_REQUEST_ID;
+
+ r = unifi_mlme_blocking_request(priv, pcli, &signal, NULL, timeout);
+ if (r < 0) {
+ unifi_error(priv, "failed to send SNIFFJOIN request, error %d\n", r);
+ return r;
+ }
+
+ r = pcli->reply_signal->u.MlmeSniffjoinConfirm.Resultcode;
+ if (r) {
+ unifi_notice(priv, "SNIFFJOIN request was rejected with result 0x%X (%s)\n",
+ r, lookup_result_code(r));
+ return -EIO;
+ }
+
+ return 0;
+} /* uf_start_sniff() */
+
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * netrx_radiotap
+ *
+ * Reformat a UniFi SNIFFDATA signal into a radiotap packet.
+ *
+ * Arguments:
+ * priv OS private context pointer.
+ * ind Pointer to a MA_UNITDATA_INDICATION or
+ * DS_UNITDATA_INDICATION indication structure.
+ *
+ * Notes:
+ * Radiotap header values are all little-endian, UniFi signals will have
+ * been converted to host-endian.
+ * ---------------------------------------------------------------------------
+ */
+#if (UNIFI_SNIFF_ARPHRD == ARPHRD_IEEE80211_RADIOTAP)
+static void
+netrx_radiotap(unifi_priv_t *priv,
+ const CSR_MA_SNIFFDATA_INDICATION *ind,
+ struct sk_buff *skb_orig)
+{
+ struct net_device *dev = priv->netdev;
+ struct sk_buff *skb = NULL;
+ unsigned char *ptr;
+ unsigned char *base;
+ int ind_data_len = skb_orig->len - 2 - ETH_HLEN;
+ struct unifi_rx_radiotap_header {
+ struct ieee80211_radiotap_header rt_hdr;
+ /* IEEE80211_RADIOTAP_TSFT */
+ u64 rt_tsft;
+ /* IEEE80211_RADIOTAP_FLAGS */
+ u8 rt_flags;
+ /* IEEE80211_RADIOTAP_RATE */
+ u8 rt_rate;
+ /* IEEE80211_RADIOTAP_CHANNEL */
+ u16 rt_chan;
+ u16 rt_chan_flags;
+ /* IEEE80211_RADIOTAP_DBM_ANTSIGNAL */
+ u8 rt_dbm_antsignal;
+ /* IEEE80211_RADIOTAP_DBM_ANTNOISE */
+ u8 rt_dbm_antnoise;
+ /* IEEE80211_RADIOTAP_ANTENNA */
+ u8 rt_antenna;
+
+ /* pad to 4-byte boundary */
+ u8 pad[3];
+ } __attribute__((__packed__));
+
+ struct unifi_rx_radiotap_header *unifi_rt;
+ int signal, noise, snr;
+
+ func_enter();
+
+ if (ind_data_len <= 0) {
+ unifi_error(priv, "Invalid length in CSR_MA_SNIFFDATA_INDICATION.\n");
+ return;
+ }
+
+ /*
+ * Allocate a SKB for the received data packet, including radiotap
+ * header.
+ */
+ skb = dev_alloc_skb(ind_data_len + sizeof(struct unifi_rx_radiotap_header) + 4);
+ if (! skb) {
+ unifi_error(priv, "alloc_skb failed.\n");
+ priv->stats.rx_errors++;
+ return;
+ }
+
+ base = skb->data;
+
+ /* Reserve the radiotap header at the front of skb */
+ unifi_rt = (struct unifi_rx_radiotap_header *)
+ skb_put(skb, sizeof(struct unifi_rx_radiotap_header));
+
+ /* Copy in the 802.11 frame */
+ ptr = skb_put(skb, ind_data_len);
+ memcpy(ptr, skb_orig->data, ind_data_len);
+
+ unifi_rt->rt_hdr.it_version = PKTHDR_RADIOTAP_VERSION;
+ unifi_rt->rt_hdr.it_pad = 0; /* always good to zero */
+ unifi_rt->rt_hdr.it_len = sizeof(struct unifi_rx_radiotap_header);
+
+ /* Big bitfield of all the fields we provide in radiotap */
+ unifi_rt->rt_hdr.it_present = 0
+ | (1 << IEEE80211_RADIOTAP_TSFT)
+ | (1 << IEEE80211_RADIOTAP_FLAGS)
+ | (1 << IEEE80211_RADIOTAP_RATE)
+ | (1 << IEEE80211_RADIOTAP_CHANNEL)
+ | (1 << IEEE80211_RADIOTAP_DBM_ANTSIGNAL)
+ | (1 << IEEE80211_RADIOTAP_DBM_ANTNOISE)
+ | (1 << IEEE80211_RADIOTAP_ANTENNA)
+ ;
+
+
+ /* No flags to set */
+ unifi_rt->rt_tsft = (((u64)ind->Timestamp.x[7]) | (((u64)ind->Timestamp.x[6]) << 8) |
+ (((u64)ind->Timestamp.x[5]) << 16) | (((u64)ind->Timestamp.x[4]) << 24) |
+ (((u64)ind->Timestamp.x[3]) << 32) | (((u64)ind->Timestamp.x[2]) << 40) |
+ (((u64)ind->Timestamp.x[1]) << 48) | (((u64)ind->Timestamp.x[0]) << 56));
+
+ unifi_rt->rt_flags = 0;
+
+ unifi_rt->rt_rate = ind->Rate;
+
+ unifi_rt->rt_chan = cpu_to_le16(ieee80211chan2mhz(priv->wext_conf.channel));
+ unifi_rt->rt_chan_flags = 0;
+
+ /* Convert signal to dBm */
+ signal = (s16)unifi2host_16(ind->Rssi); /* in dBm */
+ snr = (s16)unifi2host_16(ind->Snr); /* in dB */
+ noise = signal - snr;
+
+ unifi_rt->rt_dbm_antsignal = signal;
+ unifi_rt->rt_dbm_antnoise = noise;
+
+ unifi_rt->rt_antenna = ind->AntennaId;
+
+
+ skb->dev = dev;
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,22)
+ skb->mac_header = skb->data;
+#else
+ skb->mac.raw = skb->data;
+#endif
+ skb->pkt_type = PACKET_OTHERHOST;
+ skb->protocol = __constant_htons(ETH_P_80211_RAW);
+ memset(skb->cb, 0, sizeof(skb->cb));
+
+ /* Pass up to Linux network stack */
+ netif_rx_ni(skb);
+
+ dev->last_rx = jiffies;
+
+ /* Bump the rx stats */
+ priv->stats.rx_packets++;
+ priv->stats.rx_bytes += ind_data_len;
+
+ func_exit();
+} /* netrx_radiotap() */
+#endif /* RADIOTAP */
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * netrx_prism
+ *
+ * Reformat a UniFi SNIFFDATA signal into a Prism format sniff packet.
+ *
+ * Arguments:
+ * priv OS private context pointer.
+ * ind Pointer to a MA_UNITDATA_INDICATION or
+ * DS_UNITDATA_INDICATION indication structure.
+ *
+ * Notes:
+ * Radiotap header values are all little-endian, UniFi signals will have
+ * been converted to host-endian.
+ * ---------------------------------------------------------------------------
+ */
+#if (UNIFI_SNIFF_ARPHRD == ARPHRD_IEEE80211_PRISM)
+static void
+netrx_prism(unifi_priv_t *priv,
+ const CSR_MA_SNIFFDATA_INDICATION *ind,
+ struct sk_buff *skb_orig)
+{
+ struct net_device *dev = priv->netdev;
+ struct sk_buff *skb = NULL;
+ unsigned char *ptr;
+ unsigned char *base;
+ int ind_data_len = skb_orig->len - 2 - ETH_HLEN;
+#define WLANCAP_MAGIC_COOKIE_V1 0x80211001
+ struct avs_header_v1 {
+ uint32 version;
+ uint32 length;
+ uint64 mactime;
+ uint64 hosttime;
+ uint32 phytype;
+ uint32 channel;
+ uint32 datarate;
+ uint32 antenna;
+ uint32 priority;
+ uint32 ssi_type;
+ int32 ssi_signal;
+ int32 ssi_noise;
+ uint32 preamble;
+ uint32 encoding;
+ } *avs;
+ int signal, noise, snr;
+
+ func_enter();
+
+ if (ind_data_len <= 0) {
+ unifi_error(priv, "Invalid length in CSR_MA_SNIFFDATA_INDICATION.\n");
+ return;
+ }
+
+ /*
+ * Allocate a SKB for the received data packet, including radiotap
+ * header.
+ */
+ skb = dev_alloc_skb(ind_data_len + sizeof(struct avs_header_v1) + 4);
+ if (! skb) {
+ unifi_error(priv, "alloc_skb failed.\n");
+ priv->stats.rx_errors++;
+ return;
+ }
+
+ base = skb->data;
+
+ /* Reserve the radiotap header at the front of skb */
+ avs = (struct avs_header_v1 *)skb_put(skb, sizeof(struct avs_header_v1));
+
+ /* Copy in the 802.11 frame */
+ ptr = skb_put(skb, ind_data_len);
+ memcpy(ptr, skb_orig->data, ind_data_len);
+
+ /* Convert signal to dBm */
+ signal = 0x10000 - ((s16)unifi2host_16(ind->Rssi)); /* in dBm */
+ snr = (s16)unifi2host_16(ind->Snr); /* in dB */
+ noise = signal - snr;
+
+ avs->version = htonl(WLANCAP_MAGIC_COOKIE_V1);
+ avs->length = htonl(sizeof(struct avs_header_v1));
+ avs->mactime = __cpu_to_be64(ind->Timestamp);
+ avs->hosttime = __cpu_to_be64(jiffies);
+ avs->phytype = htonl(9); /* dss_ofdm_dot11_g */
+ avs->channel = htonl(priv->wext_conf.channel);
+ avs->datarate = htonl(ind->Rate * 5);
+ avs->antenna = htonl(ind->Antenna);
+ avs->priority = htonl(0); /* unknown */
+ avs->ssi_type = htonl(2); /* dBm */
+ avs->ssi_signal = htonl(signal);
+ avs->ssi_noise = htonl(noise);
+ avs->preamble = htonl(0); /* unknown */
+ avs->encoding = htonl(0); /* unknown */
+
+
+ skb->dev = dev;
+ skb->mac.raw = skb->data;
+ skb->pkt_type = PACKET_OTHERHOST;
+ skb->protocol = __constant_htons(ETH_P_80211_RAW);
+ memset(skb->cb, 0, sizeof(skb->cb));
+
+ /* Pass up to Linux network stack */
+ netif_rx_ni(skb);
+
+ dev->last_rx = jiffies;
+
+ /* Bump the rx stats */
+ priv->stats.rx_packets++;
+ priv->stats.rx_bytes += ind_data_len;
+
+ func_exit();
+} /* netrx_prism() */
+#endif /* PRISM */
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * ma_sniffdata_ind
+ *
+ * Reformat a UniFi SNIFFDATA signal into a network
+ *
+ * Arguments:
+ * ospriv OS private context pointer.
+ * ind Pointer to a MA_UNITDATA_INDICATION or
+ * DS_UNITDATA_INDICATION indication structure.
+ * bulkdata Pointer to a bulk data structure, describing
+ * the data received.
+ *
+ * Notes:
+ * Radiotap header values are all little-endian, UniFi signals will have
+ * been converted to host-endian.
+ * ---------------------------------------------------------------------------
+ */
+void
+ma_sniffdata_ind(void *ospriv,
+ const CSR_MA_SNIFFDATA_INDICATION *ind,
+ const bulk_data_param_t *bulkdata)
+{
+ unifi_priv_t *priv = ospriv;
+ struct net_device *dev = priv->netdev;
+ struct sk_buff *skb = (struct sk_buff*)bulkdata->d[0].os_net_buf_ptr;
+
+ func_enter();
+
+ if (bulkdata->d[0].data_length == 0) {
+ unifi_warning(priv, "rx: MA-SNIFFDATA indication with zero bulk data\n");
+ func_exit();
+ return;
+ }
+
+ skb->len = bulkdata->d[0].data_length;
+
+ /* We only process data packets if the interface is open */
+ if (unlikely(!netif_running(dev))) {
+ priv->stats.rx_dropped++;
+ priv->wext_conf.wireless_stats.discard.misc++;
+ dev_kfree_skb(skb);
+ return;
+ }
+
+ if (ind->ReceptionStatus) {
+ priv->stats.rx_dropped++;
+ priv->wext_conf.wireless_stats.discard.misc++;
+ printk(KERN_INFO "unifi: Dropping corrupt sniff packet\n");
+ dev_kfree_skb(skb);
+ return;
+ }
+
+#if (UNIFI_SNIFF_ARPHRD == ARPHRD_IEEE80211_PRISM)
+ netrx_prism(priv, ind, skb);
+#endif /* PRISM */
+
+#if (UNIFI_SNIFF_ARPHRD == ARPHRD_IEEE80211_RADIOTAP)
+ netrx_radiotap(priv, ind, skb);
+#endif /* RADIOTAP */
+
+ dev_kfree_skb(skb);
+
+} /* ma_sniffdata_ind() */
+
+
+#endif /* UNIFI_SNIFF_ARPHRD */
+
diff --git a/drivers/staging/csr/netdev.c b/drivers/staging/csr/netdev.c
new file mode 100644
index 000000000000..1e6e111a8e15
--- /dev/null
+++ b/drivers/staging/csr/netdev.c
@@ -0,0 +1,3993 @@
+/*
+ * ---------------------------------------------------------------------------
+ * FILE: netdev.c
+ *
+ * PURPOSE:
+ * This file provides the upper edge interface to the linux netdevice
+ * and wireless extensions.
+ * It is part of the porting exercise.
+ *
+ * Copyright (C) 2005-2010 by Cambridge Silicon Radio Ltd.
+ *
+ * Refer to LICENSE.txt included with this source code for details on
+ * the license terms.
+ *
+ * ---------------------------------------------------------------------------
+ */
+
+
+/*
+ * Porting Notes:
+ * This file implements the data plane of the UniFi linux driver.
+ *
+ * All the Tx packets are passed to the HIP core lib, using the
+ * unifi_send_signal() API. For EAPOL packets use the MLME-EAPOL.req
+ * signal, for all other use the MLME-UNITDATA.req. The unifi_send_signal()
+ * expects the wire-formatted (packed) signal. For convenience, in the OS
+ * layer we only use the native (unpacked) signal structures. The HIP core lib
+ * provides the write_pack() helper function to convert to the packed signal.
+ * The packet is stored in the bulk data of the signal. We do not need to
+ * allocate new memory to store the packet, because unifi_net_data_malloc()
+ * is implemented to return a skb, which is the format of packet in Linux.
+ * The HIP core lib frees the bulk data buffers, so we do not need to do
+ * this in the OS layer.
+ *
+ * All the Rx packets are MLME-UNITDATA.ind signals, passed by the HIP core lib
+ * in unifi_receive_event(). We do not need to allocate an skb and copy the
+ * received packet because the HIP core lib has stored in memory allocated by
+ * unifi_net_data_malloc(). Also, we can perform the 802.11 to Ethernet
+ * translation in-place because we allocate the extra memory allocated in
+ * unifi_net_data_malloc().
+ *
+ * If possible, the porting exercise should appropriately implement
+ * unifi_net_data_malloc() and unifi_net_data_free() to save copies between
+ * network and driver buffers.
+ */
+
+#include <linux/types.h>
+#include <linux/etherdevice.h>
+#include <linux/mutex.h>
+#include <linux/semaphore.h>
+
+#include <linux/vmalloc.h>
+#include "csr_wifi_hip_unifi.h"
+#include "csr_wifi_hip_conversions.h"
+#include "unifi_priv.h"
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,13)
+#include <net/iw_handler.h>
+#endif
+#include <net/pkt_sched.h>
+
+
+/* ALLOW_Q_PAUSE: Pre 2.6.28 kernels do not support multiple driver queues (required for QoS).
+ * In order to support QoS in these kernels, multiple queues are implemented in the driver. But since
+ * there is only a single queue in the kernel (leading to multiple queues in the driver) there is no possibility
+ * of stopping a particular queue in the kernel. Stopping the single kernel queue leads to undesirable starvation
+ * of driver queues. One of the proposals is to not stop the kernel queue but to prevent dequeuing from the
+ * 'stopped' driver queue. Allow q pause is an experimental implementation of this scheme for pre 2.6.28 kernels.
+ * When NOT defined, queues are paused locally in the driver and packets are dequeued for transmission only from the
+ * unpaused queues. When Allow q pause is defined the kernel queue is stopped whenever any driver queue is paused.
+ */
+#define ALLOW_Q_PAUSE
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,28)
+#ifdef UNIFI_NET_NAME
+#define UF_ALLOC_NETDEV(_dev, _size, _name, _setup, _num_of_queues) \
+ do { \
+ static char name[8]; \
+ sprintf(name, "%s%s", UNIFI_NET_NAME, _name); \
+ _dev = alloc_netdev_mq(_size, name, _setup, _num_of_queues); \
+ } while (0);
+#else
+#define UF_ALLOC_NETDEV(_dev, _size, _name, _setup, _num_of_queues) \
+ do { \
+ _dev = alloc_etherdev_mq(_size, _num_of_queues); \
+ } while (0);
+#endif /* UNIFI_NET_NAME */
+#else
+#ifdef UNIFI_NET_NAME
+#define UF_ALLOC_NETDEV(_dev, _size, _name, _setup, _num_of_queues) \
+ do { \
+ static char name[8]; \
+ sprintf(name, "%s%s", UNIFI_NET_NAME, _name); \
+ _dev = alloc_netdev(_size, name, _setup); \
+ } while (0);
+#else
+#define UF_ALLOC_NETDEV(_dev, _size, _name, _setup, _num_of_queues) \
+ do { \
+ _dev = alloc_etherdev(_size); \
+ } while (0);
+#endif /* UNIFI_NET_NAME */
+#endif /* LINUX_VERSION_CODE */
+
+
+/* Wext handler is suported only if CSR_SUPPORT_WEXT is defined */
+#ifdef CSR_SUPPORT_WEXT
+extern struct iw_handler_def unifi_iw_handler_def;
+#endif /* CSR_SUPPORT_WEXT */
+static void check_ba_frame_age_timeout( unifi_priv_t *priv,
+ netInterface_priv_t *interfacePriv,
+ ba_session_rx_struct *ba_session);
+static void process_ba_frame(unifi_priv_t *priv,
+ netInterface_priv_t *interfacePriv,
+ ba_session_rx_struct *ba_session,
+ frame_desc_struct *frame_desc);
+static void process_ba_complete(unifi_priv_t *priv, netInterface_priv_t *interfacePriv);
+static void process_ma_packet_error_ind(unifi_priv_t *priv, CSR_SIGNAL *signal, bulk_data_param_t *bulkdata);
+static void process_amsdu(unifi_priv_t *priv, CSR_SIGNAL *signal, bulk_data_param_t *bulkdata);
+static int uf_net_open(struct net_device *dev);
+static int uf_net_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
+static int uf_net_stop(struct net_device *dev);
+static struct net_device_stats *uf_net_get_stats(struct net_device *dev);
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,28)
+static u16 uf_net_select_queue(struct net_device *dev, struct sk_buff *skb);
+#endif
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,32)
+static netdev_tx_t uf_net_xmit(struct sk_buff *skb, struct net_device *dev);
+#else
+static int uf_net_xmit(struct sk_buff *skb, struct net_device *dev);
+#ifndef NETDEV_TX_OK
+#define NETDEV_TX_OK 0
+#endif
+#ifndef NETDEV_TX_BUSY
+#define NETDEV_TX_BUSY 1
+#endif
+#endif
+static void uf_set_multicast_list(struct net_device *dev);
+
+
+typedef int (*tx_signal_handler)(unifi_priv_t *priv, struct sk_buff *skb, const struct ethhdr *ehdr, CSR_PRIORITY priority);
+
+#ifdef CONFIG_NET_SCHED
+/*
+ * Queueing Discipline Interface
+ * Only used if kernel is configured with CONFIG_NET_SCHED
+ */
+
+/*
+ * The driver uses the qdisc interface to buffer and control all
+ * outgoing traffic. We create a root qdisc, register our qdisc operations
+ * and later we create two subsiduary pfifo queues for the uncontrolled
+ * and controlled ports.
+ *
+ * The network stack delivers all outgoing packets in our enqueue handler.
+ * There, we classify the packet and decide whether to store it or drop it
+ * (if the controlled port state is set to "discard").
+ * If the packet is enqueued, the network stack call our dequeue handler.
+ * There, we decide whether we can send the packet, delay it or drop it
+ * (the controlled port configuration might have changed meanwhile).
+ * If a packet is dequeued, then the network stack calls our hard_start_xmit
+ * handler where finally we send the packet.
+ *
+ * If the hard_start_xmit handler fails to send the packet, we return
+ * NETDEV_TX_BUSY and the network stack call our requeue handler where
+ * we put the packet back in the same queue in came from.
+ *
+ */
+
+struct uf_sched_data
+{
+ /* Traffic Classifier TBD */
+ struct tcf_proto *filter_list;
+ /* Our two queues */
+ struct Qdisc *queues[UNIFI_TRAFFIC_Q_MAX];
+};
+
+struct uf_tx_packet_data {
+ /* Queue the packet is stored in */
+ unifi_TrafficQueue queue;
+ /* QoS Priority determined when enqueing packet */
+ CSR_PRIORITY priority;
+ /* Debug */
+ unsigned long host_tag;
+};
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,28)
+static int uf_qdiscop_enqueue(struct sk_buff *skb, struct Qdisc* qd);
+static int uf_qdiscop_requeue(struct sk_buff *skb, struct Qdisc* qd);
+static struct sk_buff *uf_qdiscop_dequeue(struct Qdisc* qd);
+static void uf_qdiscop_reset(struct Qdisc* qd);
+static void uf_qdiscop_destroy(struct Qdisc* qd);
+static int uf_qdiscop_dump(struct Qdisc *qd, struct sk_buff *skb);
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,25)
+static int uf_qdiscop_tune(struct Qdisc *qd, struct nlattr *opt);
+static int uf_qdiscop_init(struct Qdisc *qd, struct nlattr *opt);
+#else
+static int uf_qdiscop_tune(struct Qdisc *qd, struct rtattr *opt);
+static int uf_qdiscop_init(struct Qdisc *qd, struct rtattr *opt);
+#endif
+#endif
+
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,28)
+/* queueing discipline operations */
+static struct Qdisc_ops uf_qdisc_ops =
+{
+ .next = NULL,
+ .cl_ops = NULL,
+ .id = "UniFi Qdisc",
+ .priv_size = sizeof(struct uf_sched_data),
+
+ .enqueue = uf_qdiscop_enqueue,
+ .dequeue = uf_qdiscop_dequeue,
+ .requeue = uf_qdiscop_requeue,
+ .drop = NULL, /* drop not needed since we are always the root qdisc */
+
+ .init = uf_qdiscop_init,
+ .reset = uf_qdiscop_reset,
+ .destroy = uf_qdiscop_destroy,
+ .change = uf_qdiscop_tune,
+
+ .dump = uf_qdiscop_dump,
+};
+#endif /* LINUX_VERSION_CODE */
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,28)
+#define UF_QDISC_CREATE_DFLT(_dev, _ops, _root)
+#elif LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27)
+#define UF_QDISC_CREATE_DFLT(_dev, _ops, _root) \
+ qdisc_create_dflt(dev, netdev_get_tx_queue(_dev, 0), _ops, _root)
+#elif LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
+#define UF_QDISC_CREATE_DFLT(_dev, _ops, _root) \
+ qdisc_create_dflt(dev, _ops, _root)
+#else
+#define UF_QDISC_CREATE_DFLT(_dev, _ops, _root) \
+ qdisc_create_dflt(dev, _ops)
+#endif /* LINUX_VERSION_CODE */
+
+#endif /* CONFIG_NET_SCHED */
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,29)
+static const struct net_device_ops uf_netdev_ops =
+{
+ .ndo_open = uf_net_open,
+ .ndo_stop = uf_net_stop,
+ .ndo_start_xmit = uf_net_xmit,
+ .ndo_do_ioctl = uf_net_ioctl,
+ .ndo_get_stats = uf_net_get_stats, /* called by /proc/net/dev */
+ .ndo_set_rx_mode = uf_set_multicast_list,
+ .ndo_select_queue = uf_net_select_queue,
+};
+#endif
+
+static u8 oui_rfc1042[P80211_OUI_LEN] = { 0x00, 0x00, 0x00 };
+static u8 oui_8021h[P80211_OUI_LEN] = { 0x00, 0x00, 0xf8 };
+
+
+/* Callback for event logging to blocking clients */
+static void netdev_mlme_event_handler(ul_client_t *client,
+ const u8 *sig_packed, int sig_len,
+ const bulk_data_param_t *bulkdata,
+ int dir);
+
+#ifdef CSR_SUPPORT_WEXT
+/* Declare netdev_notifier block which will contain the state change
+ * handler callback function
+ */
+static struct notifier_block uf_netdev_notifier;
+#endif
+
+/*
+ * ---------------------------------------------------------------------------
+ * uf_alloc_netdevice
+ *
+ * Allocate memory for the net_device and device private structs
+ * for this interface.
+ * Fill in the fields, but don't register the interface yet.
+ * We need to configure the UniFi first.
+ *
+ * Arguments:
+ * sdio_dev Pointer to SDIO context handle to use for all
+ * SDIO ops.
+ * bus_id A small number indicating the SDIO card position on the
+ * bus. Typically this is the slot number, e.g. 0, 1 etc.
+ * Valid values are 0 to MAX_UNIFI_DEVS-1.
+ *
+ * Returns:
+ * Pointer to device private struct.
+ *
+ * Notes:
+ * The net_device and device private structs are allocated together
+ * and should be freed by freeing the net_device pointer.
+ * ---------------------------------------------------------------------------
+ */
+unifi_priv_t *
+uf_alloc_netdevice(CsrSdioFunction *sdio_dev, int bus_id)
+{
+ struct net_device *dev;
+ unifi_priv_t *priv;
+ netInterface_priv_t *interfacePriv;
+#ifdef CSR_SUPPORT_WEXT
+ int rc;
+#endif
+ unsigned char i; /* loop index */
+
+ /*
+ * Allocate netdevice struct, assign name template and
+ * setup as an ethernet device.
+ * The net_device and private structs are zeroed. Ether_setup() then
+ * sets up ethernet handlers and values.
+ * The RedHat 9 redhat-config-network tool doesn't recognise wlan* devices,
+ * so use "eth*" (like other wireless extns drivers).
+ */
+ UF_ALLOC_NETDEV(dev, sizeof(unifi_priv_t)+sizeof(netInterface_priv_t), "%d", ether_setup, UNIFI_TRAFFIC_Q_MAX);
+
+ if (dev == NULL) {
+ return NULL;
+ }
+
+ /* Set up back pointer from priv to netdev */
+ interfacePriv = (netInterface_priv_t *)netdev_priv(dev);
+ priv = (unifi_priv_t *)(interfacePriv + 1);
+ interfacePriv->privPtr = priv;
+ interfacePriv->InterfaceTag = 0;
+
+
+ /* Initialize all supported netdev interface to be NULL */
+ for(i=0; i<CSR_WIFI_NUM_INTERFACES; i++) {
+ priv->netdev[i] = NULL;
+ priv->interfacePriv[i] = NULL;
+ }
+ priv->netdev[0] = dev;
+ priv->interfacePriv[0] = interfacePriv;
+
+ /* Setup / override net_device fields */
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,29)
+ dev->netdev_ops = &uf_netdev_ops;
+#else
+ dev->open = uf_net_open;
+ dev->stop = uf_net_stop;
+ dev->hard_start_xmit = uf_net_xmit;
+ dev->do_ioctl = uf_net_ioctl;
+
+ /* called by /proc/net/dev */
+ dev->get_stats = uf_net_get_stats;
+
+ dev->set_multicast_list = uf_set_multicast_list;
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,28)
+ dev->select_queue = uf_net_select_queue;
+#endif
+#endif
+
+#ifdef CSR_SUPPORT_WEXT
+ dev->wireless_handlers = &unifi_iw_handler_def;
+#if IW_HANDLER_VERSION < 6
+ dev->get_wireless_stats = unifi_get_wireless_stats;
+#endif /* IW_HANDLER_VERSION */
+#endif /* CSR_SUPPORT_WEXT */
+
+ /* This gives us enough headroom to add the 802.11 header */
+ dev->needed_headroom = 32;
+
+ /* Use bus_id as instance number */
+ priv->instance = bus_id;
+ /* Store SDIO pointer to pass in the core */
+ priv->sdio = sdio_dev;
+
+ sdio_dev->driverData = (void*)priv;
+ /* Consider UniFi to be uninitialised */
+ priv->init_progress = UNIFI_INIT_NONE;
+
+ priv->prev_queue = 0;
+
+ /*
+ * Initialise the clients structure array.
+ * We do not need protection around ul_init_clients() because
+ * the character device can not be used until uf_alloc_netdevice()
+ * returns and Unifi_instances[bus_id]=priv is set, since unifi_open()
+ * will return -ENODEV.
+ */
+ ul_init_clients(priv);
+
+ /*
+ * Register a new ul client to send the multicast list signals.
+ * Note: priv->instance must be set before calling this.
+ */
+ priv->netdev_client = ul_register_client(priv,
+ 0,
+ netdev_mlme_event_handler);
+ if (priv->netdev_client == NULL) {
+ unifi_error(priv,
+ "Failed to register a unifi client for background netdev processing\n");
+ free_netdev(priv->netdev[0]);
+ return NULL;
+ }
+ unifi_trace(priv, UDBG2, "Netdev %p client (id:%d s:0x%X) is registered\n",
+ dev, priv->netdev_client->client_id, priv->netdev_client->sender_id);
+
+ priv->sta_wmm_capabilities = 0;
+
+#if (defined(CSR_WIFI_SECURITY_WAPI_ENABLE) && defined(CSR_SUPPORT_SME))
+ priv->wapi_multicast_filter = 0;
+ priv->wapi_unicast_filter = 0;
+ priv->wapi_unicast_queued_pkt_filter = 0;
+#ifdef CSR_WIFI_SECURITY_WAPI_QOSCTRL_MIC_WORKAROUND
+ priv->isWapiConnection = FALSE;
+#endif
+#endif
+
+ /* Enable all queues by default */
+ interfacePriv->queueEnabled[0] = 1;
+ interfacePriv->queueEnabled[1] = 1;
+ interfacePriv->queueEnabled[2] = 1;
+ interfacePriv->queueEnabled[3] = 1;
+
+#ifdef CSR_SUPPORT_SME
+ priv->allPeerDozing = 0;
+#endif
+ /*
+ * Initialise the OS private struct.
+ */
+ /*
+ * Instead of deciding in advance to use 11bg or 11a, we could do a more
+ * clever scan on both radios.
+ */
+ if (use_5g) {
+ priv->if_index = CSR_INDEX_5G;
+ unifi_info(priv, "Using the 802.11a radio\n");
+ } else {
+ priv->if_index = CSR_INDEX_2G4;
+ }
+
+ /* Initialise bh thread structure */
+ priv->bh_thread.thread_task = NULL;
+ priv->bh_thread.block_thread = 1;
+ init_waitqueue_head(&priv->bh_thread.wakeup_q);
+ priv->bh_thread.wakeup_flag = 0;
+ sprintf(priv->bh_thread.name, "uf_bh_thread");
+
+ /* reset the connected state for the interface */
+ interfacePriv->connected = UnifiConnectedUnknown; /* -1 unknown, 0 no, 1 yes */
+
+#ifdef USE_DRIVER_LOCK
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 37)
+ sema_init(&priv->lock, 1);
+#else
+ init_MUTEX(&priv->lock);
+#endif
+#endif /* USE_DRIVER_LOCK */
+
+ spin_lock_init(&priv->send_signal_lock);
+
+ spin_lock_init(&priv->m4_lock);
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 37)
+ sema_init(&priv->ba_mutex, 1);
+#else
+ init_MUTEX(&priv->ba_mutex);
+#endif
+
+#if (defined(CSR_WIFI_SECURITY_WAPI_ENABLE) && defined(CSR_WIFI_SECURITY_WAPI_SW_ENCRYPTION))
+ spin_lock_init(&priv->wapi_lock);
+#endif
+
+#ifdef CSR_SUPPORT_SME
+ spin_lock_init(&priv->staRecord_lock);
+ spin_lock_init(&priv->tx_q_lock);
+#endif
+
+ /* Create the Traffic Analysis workqueue */
+ priv->unifi_workqueue = create_singlethread_workqueue("unifi_workq");
+ if (priv->unifi_workqueue == NULL) {
+ /* Deregister priv->netdev_client */
+ ul_deregister_client(priv->netdev_client);
+ free_netdev(priv->netdev[0]);
+ return NULL;
+ }
+
+#ifdef CSR_SUPPORT_SME
+ /* Create the Multicast Addresses list work structure */
+ INIT_WORK(&priv->multicast_list_task, uf_multicast_list_wq);
+
+ /* Create m4 buffering work structure */
+ INIT_WORK(&interfacePriv->send_m4_ready_task, uf_send_m4_ready_wq);
+
+#if (defined(CSR_WIFI_SECURITY_WAPI_ENABLE) && defined(CSR_WIFI_SECURITY_WAPI_SW_ENCRYPTION))
+ /* Create work structure to buffer the WAPI data packets to be sent to SME for encryption */
+ INIT_WORK(&interfacePriv->send_pkt_to_encrypt, uf_send_pkt_to_encrypt);
+#endif
+#endif
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,28)
+#ifdef CONFIG_NET_SCHED
+ /* Register the qdisc operations */
+ register_qdisc(&uf_qdisc_ops);
+#endif /* CONFIG_NET_SCHED */
+#endif /* LINUX_VERSION_CODE */
+
+ priv->ref_count = 1;
+
+
+ priv->amp_client = NULL;
+ priv->coredump_mode = 0;
+ priv->ptest_mode = 0;
+ priv->wol_suspend = FALSE;
+ INIT_LIST_HEAD(&interfacePriv->rx_uncontrolled_list);
+ INIT_LIST_HEAD(&interfacePriv->rx_controlled_list);
+ sema_init(&priv->rx_q_sem, 1);
+
+#ifdef CSR_SUPPORT_WEXT
+ interfacePriv->netdev_callback_registered = FALSE;
+ interfacePriv->wait_netdev_change = FALSE;
+ /* Register callback for netdevice state changes */
+ if ((rc = register_netdevice_notifier(&uf_netdev_notifier)) == 0) {
+ interfacePriv->netdev_callback_registered = TRUE;
+ }
+ else {
+ unifi_warning(priv, "Failed to register netdevice notifier : %d %p\n", rc, dev);
+ }
+#endif /* CSR_SUPPORT_WEXT */
+
+#ifdef CSR_WIFI_SPLIT_PATCH
+ /* set it to some invalid value */
+ priv->pending_mode_set.common.destination = 0xaaaa;
+#endif
+
+ return priv;
+} /* uf_alloc_netdevice() */
+
+/*
+ *---------------------------------------------------------------------------
+ * uf_alloc_netdevice_for_other_interfaces
+ *
+ * Allocate memory for the net_device and device private structs
+ * for this interface.
+ * Fill in the fields, but don't register the interface yet.
+ * We need to configure the UniFi first.
+ *
+ * Arguments:
+ * interfaceTag Interface number.
+ * sdio_dev Pointer to SDIO context handle to use for all
+ * SDIO ops.
+ * bus_id A small number indicating the SDIO card position on the
+ * bus. Typically this is the slot number, e.g. 0, 1 etc.
+ * Valid values are 0 to MAX_UNIFI_DEVS-1.
+ *
+ * Returns:
+ * Pointer to device private struct.
+ *
+ * Notes:
+ * The device private structure contains the interfaceTag and pointer to the unifi_priv
+ * structure created allocated by net_device od interface0.
+ * The net_device and device private structs are allocated together
+ * and should be freed by freeing the net_device pointer.
+ * ---------------------------------------------------------------------------
+ */
+u8
+uf_alloc_netdevice_for_other_interfaces(unifi_priv_t *priv, u16 interfaceTag)
+{
+ struct net_device *dev;
+ netInterface_priv_t *interfacePriv;
+
+ /*
+ * Allocate netdevice struct, assign name template and
+ * setup as an ethernet device.
+ * The net_device and private structs are zeroed. Ether_setup() then
+ * sets up ethernet handlers and values.
+ * The RedHat 9 redhat-config-network tool doesn't recognise wlan* devices,
+ * so use "eth*" (like other wireless extns drivers).
+ */
+ UF_ALLOC_NETDEV(dev, sizeof(netInterface_priv_t), "%d", ether_setup, 1);
+ if (dev == NULL) {
+ return FALSE;
+ }
+
+ if (interfaceTag >= CSR_WIFI_NUM_INTERFACES) {
+ unifi_error(priv, "uf_alloc_netdevice_for_other_interfaces bad interfaceTag\n");
+ return FALSE;
+ }
+
+ /* Set up back pointer from priv to netdev */
+ interfacePriv = (netInterface_priv_t *)netdev_priv(dev);
+ interfacePriv->privPtr = priv;
+ interfacePriv->InterfaceTag = interfaceTag;
+ priv->netdev[interfaceTag] = dev;
+ priv->interfacePriv[interfacePriv->InterfaceTag] = interfacePriv;
+
+ /* reset the connected state for the interface */
+ interfacePriv->connected = UnifiConnectedUnknown; /* -1 unknown, 0 no, 1 yes */
+ INIT_LIST_HEAD(&interfacePriv->rx_uncontrolled_list);
+ INIT_LIST_HEAD(&interfacePriv->rx_controlled_list);
+
+ /* Setup / override net_device fields */
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,29)
+ dev->netdev_ops = &uf_netdev_ops;
+#else
+ dev->open = uf_net_open;
+ dev->stop = uf_net_stop;
+ dev->hard_start_xmit = uf_net_xmit;
+ dev->do_ioctl = uf_net_ioctl;
+
+ /* called by /proc/net/dev */
+ dev->get_stats = uf_net_get_stats;
+
+ dev->set_multicast_list = uf_set_multicast_list;
+#endif
+
+#ifdef CSR_SUPPORT_WEXT
+ dev->wireless_handlers = &unifi_iw_handler_def;
+#if IW_HANDLER_VERSION < 6
+ dev->get_wireless_stats = unifi_get_wireless_stats;
+#endif /* IW_HANDLER_VERSION */
+#endif /* CSR_SUPPORT_WEXT */
+ return TRUE;
+} /* uf_alloc_netdevice() */
+
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * uf_free_netdevice
+ *
+ * Unregister the network device and free the memory allocated for it.
+ * NB This includes the memory for the priv struct.
+ *
+ * Arguments:
+ * priv Device private pointer.
+ *
+ * Returns:
+ * None.
+ * ---------------------------------------------------------------------------
+ */
+int
+uf_free_netdevice(unifi_priv_t *priv)
+{
+ int i;
+ unsigned long flags;
+
+ func_enter();
+
+ unifi_trace(priv, UDBG1, "uf_free_netdevice\n");
+
+ if (!priv) {
+ return -EINVAL;
+ }
+
+ /*
+ * Free any buffers used for holding firmware
+ */
+ uf_release_firmware_files(priv);
+
+#if (defined CSR_SUPPORT_SME) && (defined CSR_SUPPORT_WEXT)
+ if (priv->connection_config.mlmeAssociateReqInformationElements) {
+ kfree(priv->connection_config.mlmeAssociateReqInformationElements);
+ }
+ priv->connection_config.mlmeAssociateReqInformationElements = NULL;
+ priv->connection_config.mlmeAssociateReqInformationElementsLength = 0;
+
+ if (priv->mib_data.length) {
+ vfree(priv->mib_data.data);
+ }
+ priv->mib_data.data = NULL;
+ priv->mib_data.length = 0;
+
+#endif /* CSR_SUPPORT_SME && CSR_SUPPORT_WEXT*/
+
+ /* Free any bulkdata buffers allocated for M4 caching */
+ spin_lock_irqsave(&priv->m4_lock, flags);
+ for (i = 0; i < CSR_WIFI_NUM_INTERFACES; i++) {
+ netInterface_priv_t *interfacePriv = priv->interfacePriv[i];
+ if (interfacePriv->m4_bulk_data.data_length > 0) {
+ unifi_trace(priv, UDBG5, "uf_free_netdevice: free M4 bulkdata %d\n", i);
+ unifi_net_data_free(priv, &interfacePriv->m4_bulk_data);
+ }
+ }
+ spin_unlock_irqrestore(&priv->m4_lock, flags);
+
+#if (defined(CSR_WIFI_SECURITY_WAPI_ENABLE) && defined(CSR_WIFI_SECURITY_WAPI_SW_ENCRYPTION))
+ /* Free any bulkdata buffers allocated for M4 caching */
+ spin_lock_irqsave(&priv->wapi_lock, flags);
+ for (i = 0; i < CSR_WIFI_NUM_INTERFACES; i++) {
+ netInterface_priv_t *interfacePriv = priv->interfacePriv[i];
+ if (interfacePriv->wapi_unicast_bulk_data.data_length > 0) {
+ unifi_trace(priv, UDBG5, "uf_free_netdevice: free WAPI PKT bulk data %d\n", i);
+ unifi_net_data_free(priv, &interfacePriv->wapi_unicast_bulk_data);
+ }
+ }
+ spin_unlock_irqrestore(&priv->wapi_lock, flags);
+#endif
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,28)
+#ifdef CONFIG_NET_SCHED
+ /* Unregister the qdisc operations */
+ unregister_qdisc(&uf_qdisc_ops);
+#endif /* CONFIG_NET_SCHED */
+#endif /* LINUX_VERSION_CODE */
+
+#ifdef CSR_SUPPORT_WEXT
+ /* Unregister callback for netdevice state changes */
+ unregister_netdevice_notifier(&uf_netdev_notifier);
+#endif /* CSR_SUPPORT_WEXT */
+
+#ifdef CSR_SUPPORT_SME
+ /* Cancel work items and destroy the workqueue */
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,23)
+ cancel_work_sync(&priv->multicast_list_task);
+#endif
+#endif
+/* Destroy the workqueues. */
+ flush_workqueue(priv->unifi_workqueue);
+ destroy_workqueue(priv->unifi_workqueue);
+
+ /* Free up netdev in reverse order: priv is allocated with netdev[0].
+ * So, netdev[0] should be freed after all other netdevs are freed up
+ */
+ for (i=CSR_WIFI_NUM_INTERFACES-1; i>=0; i--) {
+ /*Free the netdev struct and priv, which are all one lump*/
+ if (priv->netdev[i]) {
+ unifi_error(priv, "uf_free_netdevice: netdev %d %p\n", i, priv->netdev[i]);
+ free_netdev(priv->netdev[i]);
+ }
+ }
+
+ func_exit();
+ return 0;
+} /* uf_free_netdevice() */
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * uf_net_open
+ *
+ * Called when userland does "ifconfig wlan0 up".
+ *
+ * Arguments:
+ * dev Device pointer.
+ *
+ * Returns:
+ * None.
+ * ---------------------------------------------------------------------------
+ */
+static int
+uf_net_open(struct net_device *dev)
+{
+ netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev);
+ unifi_priv_t *priv = interfacePriv->privPtr;
+
+ func_enter();
+
+ /* If we haven't finished UniFi initialisation, we can't start */
+ if (priv->init_progress != UNIFI_INIT_COMPLETED) {
+ unifi_warning(priv, "%s: unifi not ready, failing net_open\n", __FUNCTION__);
+ return -EINVAL;
+ }
+
+#if (defined CSR_NATIVE_LINUX) && (defined UNIFI_SNIFF_ARPHRD) && defined(CSR_SUPPORT_WEXT)
+ /*
+ * To sniff, the user must do "iwconfig mode monitor", which sets
+ * priv->wext_conf.mode to IW_MODE_MONITOR.
+ * Then he/she must do "ifconfig ethn up", which calls this fn.
+ * There is no point in starting the sniff with SNIFFJOIN until
+ * this point.
+ */
+ if (priv->wext_conf.mode == IW_MODE_MONITOR) {
+ int err;
+ err = uf_start_sniff(priv);
+ if (err) {
+ return err;
+ }
+ netif_carrier_on(dev);
+ }
+#endif
+
+#ifdef CSR_SUPPORT_WEXT
+ if (interfacePriv->wait_netdev_change) {
+ unifi_trace(priv, UDBG1, "%s: Waiting for NETDEV_CHANGE, assume connected\n",
+ __FUNCTION__);
+ interfacePriv->connected = UnifiConnected;
+ interfacePriv->wait_netdev_change = FALSE;
+ }
+#endif
+
+ UF_NETIF_TX_START_ALL_QUEUES(dev);
+
+ func_exit();
+ return 0;
+} /* uf_net_open() */
+
+
+static int
+uf_net_stop(struct net_device *dev)
+{
+#if defined(CSR_NATIVE_LINUX) && defined(UNIFI_SNIFF_ARPHRD) && defined(CSR_SUPPORT_WEXT)
+ netInterface_priv_t *interfacePriv = (netInterface_priv_t*)netdev_priv(dev);
+ unifi_priv_t *priv = interfacePriv->privPtr;
+
+ func_enter();
+
+ /* Stop sniffing if in Monitor mode */
+ if (priv->wext_conf.mode == IW_MODE_MONITOR) {
+ if (priv->card) {
+ int err;
+ err = unifi_reset_state(priv, dev->dev_addr, 1);
+ if (err) {
+ return err;
+ }
+ }
+ }
+#else
+ func_enter();
+#endif
+
+ UF_NETIF_TX_STOP_ALL_QUEUES(dev);
+
+ func_exit();
+ return 0;
+} /* uf_net_stop() */
+
+
+/* This is called after the WE handlers */
+static int
+uf_net_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
+{
+ int rc;
+
+ rc = -EOPNOTSUPP;
+
+ return rc;
+} /* uf_net_ioctl() */
+
+
+
+static struct net_device_stats *
+uf_net_get_stats(struct net_device *dev)
+{
+ netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev);
+
+ return &interfacePriv->stats;
+} /* uf_net_get_stats() */
+
+static CSR_PRIORITY uf_get_packet_priority(unifi_priv_t *priv, netInterface_priv_t *interfacePriv, struct sk_buff *skb, const int proto)
+{
+ CSR_PRIORITY priority = CSR_CONTENTION;
+
+ func_enter();
+ priority = (CSR_PRIORITY) (skb->priority >> 5);
+
+ if (priority == CSR_QOS_UP0) { /* 0 */
+
+ unifi_trace(priv, UDBG5, "uf_get_packet_priority: proto = 0x%.4X\n", proto);
+
+ switch (proto) {
+ case 0x0800: /* IPv4 */
+ case 0x814C: /* SNMP */
+ case 0x880C: /* GSMP */
+ priority = (CSR_PRIORITY) (skb->data[1 + ETH_HLEN] >> 5);
+ break;
+
+ case 0x8100: /* VLAN */
+ priority = (CSR_PRIORITY) (skb->data[0 + ETH_HLEN] >> 5);
+ break;
+
+ case 0x86DD: /* IPv6 */
+ priority = (CSR_PRIORITY) ((skb->data[0 + ETH_HLEN] & 0x0E) >> 1);
+ break;
+
+ default:
+ priority = CSR_QOS_UP0;
+ break;
+ }
+ }
+
+ /* Check if we are allowed to transmit on this AC. Because of ACM we may have to downgrade to a lower
+ * priority */
+ if (interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_STA ||
+ interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_P2PCLI) {
+ unifi_TrafficQueue queue;
+
+ /* Keep trying lower priorities until we find a queue
+ * Priority to queue mapping is 1,2 - BK, 0,3 - BE, 4,5 - VI, 6,7 - VO */
+ queue = unifi_frame_priority_to_queue(priority);
+
+ while (queue > UNIFI_TRAFFIC_Q_BK && !interfacePriv->queueEnabled[queue]) {
+ queue--;
+ priority = unifi_get_default_downgrade_priority(queue);
+ }
+ }
+
+ unifi_trace(priv, UDBG5, "Packet priority = %d\n", priority);
+
+ func_exit();
+ return priority;
+}
+
+/*
+ */
+/*
+ * ---------------------------------------------------------------------------
+ * get_packet_priority
+ *
+ * Arguments:
+ * priv private data area of functional driver
+ * skb socket buffer
+ * ehdr ethernet header to fetch protocol
+ * interfacePriv For accessing station record database
+ *
+ *
+ * Returns:
+ * CSR_PRIORITY.
+ * ---------------------------------------------------------------------------
+ */
+CSR_PRIORITY
+get_packet_priority(unifi_priv_t *priv, struct sk_buff *skb, const struct ethhdr *ehdr, netInterface_priv_t *interfacePriv)
+{
+ CSR_PRIORITY priority = CSR_CONTENTION;
+ const int proto = ntohs(ehdr->h_proto);
+
+ u8 interfaceMode = interfacePriv->interfaceMode;
+
+ func_enter();
+
+ /* Priority Mapping for all the Modes */
+ switch(interfaceMode)
+ {
+ case CSR_WIFI_ROUTER_CTRL_MODE_STA:
+ case CSR_WIFI_ROUTER_CTRL_MODE_P2PCLI:
+ unifi_trace(priv, UDBG4, "mode is STA \n");
+ if ((priv->sta_wmm_capabilities & QOS_CAPABILITY_WMM_ENABLED) == 1) {
+ priority = uf_get_packet_priority(priv, interfacePriv, skb, proto);
+ } else {
+ priority = CSR_CONTENTION;
+ }
+ break;
+#ifdef CSR_SUPPORT_SME
+ case CSR_WIFI_ROUTER_CTRL_MODE_AP:
+ case CSR_WIFI_ROUTER_CTRL_MODE_P2PGO:
+ case CSR_WIFI_ROUTER_CTRL_MODE_IBSS:
+ {
+ CsrWifiRouterCtrlStaInfo_t * dstStaInfo =
+ CsrWifiRouterCtrlGetStationRecordFromPeerMacAddress(priv,ehdr->h_dest, interfacePriv->InterfaceTag);
+ unifi_trace(priv, UDBG4, "mode is AP \n");
+ if (!(ehdr->h_dest[0] & 0x01) && dstStaInfo && dstStaInfo->wmmOrQosEnabled) {
+ /* If packet is not Broadcast/multicast */
+ priority = uf_get_packet_priority(priv, interfacePriv, skb, proto);
+ } else {
+ /* Since packet destination is not QSTA, set priority to CSR_CONTENTION */
+ unifi_trace(priv, UDBG4, "Destination is not QSTA or BroadCast/Multicast\n");
+ priority = CSR_CONTENTION;
+ }
+ }
+ break;
+#endif
+ default:
+ unifi_trace(priv, UDBG3, " mode unknown in %s func, mode=%x\n", __FUNCTION__, interfaceMode);
+ }
+ unifi_trace(priv, UDBG5, "priority = %x\n", priority);
+
+ func_exit();
+ return priority;
+}
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,28)
+/*
+ * ---------------------------------------------------------------------------
+ * uf_net_select_queue
+ *
+ * Called by the kernel to select which queue to put the packet in
+ *
+ * Arguments:
+ * dev Device pointer
+ * skb Packet
+ *
+ * Returns:
+ * Queue index
+ * ---------------------------------------------------------------------------
+ */
+static u16
+uf_net_select_queue(struct net_device *dev, struct sk_buff *skb)
+{
+ netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev);
+ unifi_priv_t *priv = (unifi_priv_t *)interfacePriv->privPtr;
+ struct ethhdr ehdr;
+ unifi_TrafficQueue queue;
+ int proto;
+ CSR_PRIORITY priority;
+
+ func_enter();
+
+ memcpy(&ehdr, skb->data, ETH_HLEN);
+ proto = ntohs(ehdr.h_proto);
+
+ /* 802.1x - apply controlled/uncontrolled port rules */
+ if ((proto != ETH_P_PAE)
+#ifdef CSR_WIFI_SECURITY_WAPI_ENABLE
+ && (proto != ETH_P_WAI)
+#endif
+ ) {
+ /* queues 0 - 3 */
+ priority = get_packet_priority(priv, skb, &ehdr, interfacePriv);
+ queue = unifi_frame_priority_to_queue(priority);
+ } else {
+ /* queue 4 */
+ queue = UNIFI_TRAFFIC_Q_EAPOL;
+ }
+
+
+ func_exit();
+ return (u16)queue;
+} /* uf_net_select_queue() */
+#endif
+
+int
+skb_add_llc_snap(struct net_device *dev, struct sk_buff *skb, int proto)
+{
+ llc_snap_hdr_t *snap;
+ netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev);
+ unifi_priv_t *priv = interfacePriv->privPtr;
+ int headroom;
+
+ /* get the headroom available in skb */
+ headroom = skb_headroom(skb);
+ /* step 1: classify ether frame, DIX or 802.3? */
+
+ if (proto < 0x600) {
+ /* codes <= 1500 reserved for 802.3 lengths */
+ /* it's 802.3, pass ether payload unchanged, */
+ unifi_trace(priv, UDBG3, "802.3 len: %d\n", skb->len);
+
+ /* leave off any PAD octets. */
+ skb_trim(skb, proto);
+ } else if (proto == ETH_P_8021Q) {
+
+ /* Store the VLAN SNAP (should be 87-65). */
+ u16 vlan_snap = *(u16*)skb->data;
+ /* check for headroom availability before skb_push 14 = (4 + 10) */
+ if (headroom < 14) {
+ unifi_trace(priv, UDBG3, "cant append vlan snap: debug\n");
+ return -1;
+ }
+ /* Add AA-AA-03-00-00-00 */
+ snap = (llc_snap_hdr_t *)skb_push(skb, 4);
+ snap->dsap = snap->ssap = 0xAA;
+ snap->ctrl = 0x03;
+ memcpy(snap->oui, oui_rfc1042, P80211_OUI_LEN);
+
+ /* Add AA-AA-03-00-00-00 */
+ snap = (llc_snap_hdr_t *)skb_push(skb, 10);
+ snap->dsap = snap->ssap = 0xAA;
+ snap->ctrl = 0x03;
+ memcpy(snap->oui, oui_rfc1042, P80211_OUI_LEN);
+
+ /* Add the VLAN specific information */
+ snap->protocol = htons(proto);
+ *(u16*)(snap + 1) = vlan_snap;
+
+ } else
+ {
+ /* it's DIXII, time for some conversion */
+ unifi_trace(priv, UDBG3, "DIXII len: %d\n", skb->len);
+
+ /* check for headroom availability before skb_push */
+ if (headroom < sizeof(llc_snap_hdr_t)) {
+ unifi_trace(priv, UDBG3, "cant append snap: debug\n");
+ return -1;
+ }
+ /* tack on SNAP */
+ snap = (llc_snap_hdr_t *)skb_push(skb, sizeof(llc_snap_hdr_t));
+ snap->dsap = snap->ssap = 0xAA;
+ snap->ctrl = 0x03;
+ /* Use the appropriate OUI. */
+ if ((proto == ETH_P_AARP) || (proto == ETH_P_IPX)) {
+ memcpy(snap->oui, oui_8021h, P80211_OUI_LEN);
+ } else {
+ memcpy(snap->oui, oui_rfc1042, P80211_OUI_LEN);
+ }
+ snap->protocol = htons(proto);
+ }
+
+ return 0;
+} /* skb_add_llc_snap() */
+
+#ifdef CSR_SUPPORT_SME
+static int
+_identify_sme_ma_pkt_ind(unifi_priv_t *priv,
+ const s8 *oui, u16 protocol,
+ const CSR_SIGNAL *signal,
+ bulk_data_param_t *bulkdata,
+ const unsigned char *daddr,
+ const unsigned char *saddr)
+{
+ CSR_MA_PACKET_INDICATION *pkt_ind = (CSR_MA_PACKET_INDICATION*)&signal->u.MaPacketIndication;
+ int r;
+ u8 i;
+
+ unifi_trace(priv, UDBG5,
+ "_identify_sme_ma_pkt_ind -->\n");
+ for (i = 0; i < MAX_MA_UNIDATA_IND_FILTERS; i++) {
+ if (priv->sme_unidata_ind_filters[i].in_use) {
+ if (!memcmp(oui, priv->sme_unidata_ind_filters[i].oui, 3) &&
+ (protocol == priv->sme_unidata_ind_filters[i].protocol)) {
+
+ /* Send to client */
+ if (priv->sme_cli) {
+ /*
+ * Pass the packet to the SME, using unifi_sys_ma_unitdata_ind().
+ * The frame needs to be converted according to the encapsulation.
+ */
+ unifi_trace(priv, UDBG1,
+ "_identify_sme_ma_pkt_ind: handle=%d, encap=%d, proto=%x\n",
+ i, priv->sme_unidata_ind_filters[i].encapsulation,
+ priv->sme_unidata_ind_filters[i].protocol);
+ if (priv->sme_unidata_ind_filters[i].encapsulation == CSR_WIFI_ROUTER_ENCAPSULATION_ETHERNET) {
+ struct sk_buff *skb;
+ /* The translation is performed on skb... */
+ skb = (struct sk_buff*)bulkdata->d[0].os_net_buf_ptr;
+ skb->len = bulkdata->d[0].data_length;
+
+ unifi_trace(priv, UDBG1,
+ "_identify_sme_ma_pkt_ind: skb_80211_to_ether -->\n");
+ r = skb_80211_to_ether(priv, skb, daddr, saddr,
+ signal, bulkdata);
+ unifi_trace(priv, UDBG1,
+ "_identify_sme_ma_pkt_ind: skb_80211_to_ether <--\n");
+ if (r) {
+ return -EINVAL;
+ }
+
+ /* ... but we indicate buffer and length */
+ bulkdata->d[0].os_data_ptr = skb->data;
+ bulkdata->d[0].data_length = skb->len;
+ } else {
+ /* Add the MAC addresses before the SNAP */
+ bulkdata->d[0].os_data_ptr -= 2*ETH_ALEN;
+ bulkdata->d[0].data_length += 2*ETH_ALEN;
+ memcpy((void*)bulkdata->d[0].os_data_ptr, daddr, ETH_ALEN);
+ memcpy((void*)bulkdata->d[0].os_data_ptr + ETH_ALEN, saddr, ETH_ALEN);
+ }
+
+ unifi_trace(priv, UDBG1,
+ "_identify_sme_ma_pkt_ind: unifi_sys_ma_pkt_ind -->\n");
+ CsrWifiRouterMaPacketIndSend(priv->sme_unidata_ind_filters[i].appHandle,
+ (pkt_ind->VirtualInterfaceIdentifier & 0xff),
+ i,
+ pkt_ind->ReceptionStatus,
+ bulkdata->d[0].data_length,
+ (u8*)bulkdata->d[0].os_data_ptr,
+ NULL,
+ pkt_ind->Rssi,
+ pkt_ind->Snr,
+ pkt_ind->ReceivedRate);
+
+
+ unifi_trace(priv, UDBG1,
+ "_identify_sme_ma_pkt_ind: unifi_sys_ma_pkt_ind <--\n");
+ }
+
+ return 1;
+ }
+ }
+ }
+
+ return -1;
+}
+#endif /* CSR_SUPPORT_SME */
+
+/*
+ * ---------------------------------------------------------------------------
+ * skb_80211_to_ether
+ *
+ * Make sure the received frame is in Ethernet (802.3) form.
+ * De-encapsulates SNAP if necessary, adds a ethernet header.
+ * The source buffer should not contain an 802.11 MAC header
+ *
+ * Arguments:
+ * payload Pointer to packet data received from UniFi.
+ * payload_length Number of bytes of data received from UniFi.
+ * daddr Destination MAC address.
+ * saddr Source MAC address.
+ *
+ * Returns:
+ * 0 on success, -1 if the packet is bad and should be dropped,
+ * 1 if the packet was forwarded to the SME or AMP client.
+ * ---------------------------------------------------------------------------
+ */
+int
+skb_80211_to_ether(unifi_priv_t *priv, struct sk_buff *skb,
+ const unsigned char *daddr, const unsigned char *saddr,
+ const CSR_SIGNAL *signal,
+ bulk_data_param_t *bulkdata)
+{
+ unsigned char *payload;
+ int payload_length;
+ struct ethhdr *eth;
+ llc_snap_hdr_t *snap;
+ int headroom;
+#define UF_VLAN_LLC_HEADER_SIZE 18
+ static const u8 vlan_inner_snap[] = { 0xAA, 0xAA, 0x03, 0x00, 0x00, 0x00 };
+#if defined(CSR_NATIVE_SOFTMAC) && defined(CSR_SUPPORT_SME)
+ const CSR_MA_PACKET_INDICATION *pkt_ind = &signal->u.MaPacketIndication;
+#endif
+
+ if(skb== NULL || daddr == NULL || saddr == NULL){
+ unifi_error(priv,"skb_80211_to_ether: PBC fail\n");
+ return 1;
+ }
+
+ payload = skb->data;
+ payload_length = skb->len;
+
+ snap = (llc_snap_hdr_t *)payload;
+ eth = (struct ethhdr *)payload;
+
+ /* get the skb headroom size */
+ headroom = skb_headroom(skb);
+
+ /*
+ * Test for the various encodings
+ */
+ if ((payload_length >= sizeof(llc_snap_hdr_t)) &&
+ (snap->dsap == 0xAA) &&
+ (snap->ssap == 0xAA) &&
+ (snap->ctrl == 0x03) &&
+ (snap->oui[0] == 0) &&
+ (snap->oui[1] == 0) &&
+ ((snap->oui[2] == 0) || (snap->oui[2] == 0xF8)))
+ {
+ /* AppleTalk AARP (2) or IPX SNAP */
+ if ((snap->oui[2] == 0) &&
+ ((ntohs(snap->protocol) == ETH_P_AARP) || (ntohs(snap->protocol) == ETH_P_IPX)))
+ {
+ u16 len;
+
+ unifi_trace(priv, UDBG3, "%s len: %d\n",
+ (ntohs(snap->protocol) == ETH_P_AARP) ? "ETH_P_AARP" : "ETH_P_IPX",
+ payload_length);
+
+ /* check for headroom availability before skb_push */
+ if (headroom < (2 * ETH_ALEN + 2)) {
+ unifi_warning(priv, "headroom not available to skb_push ether header\n");
+ return -1;
+ }
+
+ /* Add 802.3 header and leave full payload */
+ len = htons(skb->len);
+ memcpy(skb_push(skb, 2), &len, 2);
+ memcpy(skb_push(skb, ETH_ALEN), saddr, ETH_ALEN);
+ memcpy(skb_push(skb, ETH_ALEN), daddr, ETH_ALEN);
+
+ return 0;
+ }
+ /* VLAN-tagged IP */
+ if ((snap->oui[2] == 0) && (ntohs(snap->protocol) == ETH_P_8021Q))
+ {
+ /*
+ * The translation doesn't change the packet length, so is done in-place.
+ *
+ * Example header (from Std 802.11-2007 Annex M):
+ * AA-AA-03-00-00-00-81-00-87-65-AA-AA-03-00-00-00-08-06
+ * -------SNAP-------p1-p1-ll-ll-------SNAP--------p2-p2
+ * dd-dd-dd-dd-dd-dd-aa-aa-aa-aa-aa-aa-p1-p1-ll-ll-p2-p2
+ * dd-dd-dd-dd-dd-dd-aa-aa-aa-aa-aa-aa-81-00-87-65-08-06
+ */
+ u16 vlan_snap;
+
+ if (payload_length < UF_VLAN_LLC_HEADER_SIZE) {
+ unifi_warning(priv, "VLAN SNAP header too short: %d bytes\n", payload_length);
+ return -1;
+ }
+
+ if (memcmp(payload + 10, vlan_inner_snap, 6)) {
+ unifi_warning(priv, "VLAN malformatted SNAP header.\n");
+ return -1;
+ }
+
+ unifi_trace(priv, UDBG3, "VLAN SNAP: %02x-%02x\n", payload[8], payload[9]);
+ unifi_trace(priv, UDBG3, "VLAN len: %d\n", payload_length);
+
+ /* Create the 802.3 header */
+
+ vlan_snap = *((u16*)(payload + 8));
+
+ /* Create LLC header without byte-swapping */
+ eth->h_proto = snap->protocol;
+
+ memcpy(eth->h_dest, daddr, ETH_ALEN);
+ memcpy(eth->h_source, saddr, ETH_ALEN);
+ *(u16*)(eth + 1) = vlan_snap;
+ return 0;
+ }
+
+ /* it's a SNAP + RFC1042 frame */
+ unifi_trace(priv, UDBG3, "SNAP+RFC1042 len: %d\n", payload_length);
+
+ /* chop SNAP+llc header from skb. */
+ skb_pull(skb, sizeof(llc_snap_hdr_t));
+
+ /* Since skb_pull called above to chop snap+llc, no need to check for headroom
+ * availability before skb_push
+ */
+ /* create 802.3 header at beginning of skb. */
+ eth = (struct ethhdr *)skb_push(skb, ETH_HLEN);
+ memcpy(eth->h_dest, daddr, ETH_ALEN);
+ memcpy(eth->h_source, saddr, ETH_ALEN);
+ /* Copy protocol field without byte-swapping */
+ eth->h_proto = snap->protocol;
+ } else {
+ u16 len;
+
+ /* check for headroom availability before skb_push */
+ if (headroom < (2 * ETH_ALEN + 2)) {
+ unifi_warning(priv, "headroom not available to skb_push ether header\n");
+ return -1;
+ }
+ /* Add 802.3 header and leave full payload */
+ len = htons(skb->len);
+ memcpy(skb_push(skb, 2), &len, 2);
+ memcpy(skb_push(skb, ETH_ALEN), saddr, ETH_ALEN);
+ memcpy(skb_push(skb, ETH_ALEN), daddr, ETH_ALEN);
+
+ return 1;
+ }
+
+ return 0;
+} /* skb_80211_to_ether() */
+
+
+static CsrWifiRouterCtrlPortAction verify_port(unifi_priv_t *priv, unsigned char *address, int queue, u16 interfaceTag)
+{
+#ifdef CSR_NATIVE_LINUX
+#ifdef CSR_SUPPORT_WEXT
+ if (queue == UF_CONTROLLED_PORT_Q) {
+ return priv->wext_conf.block_controlled_port;
+ } else {
+ return CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_OPEN;
+ }
+#else
+ return CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_OPEN; /* default to open for softmac dev */
+#endif
+#else
+ return uf_sme_port_state(priv, address, queue, interfaceTag);
+#endif
+}
+
+/*
+ * ---------------------------------------------------------------------------
+ * prepare_and_add_macheader
+ *
+ *
+ * These functions adds mac header for packet from netdev
+ * to UniFi for transmission.
+ * EAP protocol packets are also appended with Mac header &
+ * sent using send_ma_pkt_request().
+ *
+ * Arguments:
+ * priv Pointer to device private context struct
+ * skb Socket buffer containing data packet to transmit
+ * newSkb Socket buffer containing data packet + Mac header if no sufficient headroom in skb
+ * serviceClass to append QOS control header in Mac header
+ * bulkdata if newSkb allocated then bulkdata updated to send to unifi
+ * interfaceTag the interfaceID on which activity going on
+ * daddr destination address
+ * saddr source address
+ * protection protection bit set in framce control of mac header
+ *
+ * Returns:
+ * Zero on success or error code.
+ * ---------------------------------------------------------------------------
+ */
+
+int prepare_and_add_macheader(unifi_priv_t *priv, struct sk_buff *skb, struct sk_buff *newSkb,
+ CSR_PRIORITY priority,
+ bulk_data_param_t *bulkdata,
+ u16 interfaceTag,
+ const u8 *daddr,
+ const u8 *saddr,
+ u8 protection)
+{
+ u16 fc = 0;
+ u8 qc = 0;
+ u8 macHeaderLengthInBytes = MAC_HEADER_SIZE, *bufPtr = NULL;
+ bulk_data_param_t data_ptrs;
+ CsrResult csrResult;
+ int headroom =0;
+ u8 direction = 0;
+ netInterface_priv_t *interfacePriv = priv->interfacePriv[interfaceTag];
+ u8 *addressOne;
+ u8 bQosNull = false;
+
+ if (skb == NULL) {
+ unifi_error(priv,"prepare_and_add_macheader: Invalid SKB reference\n");
+ return -1;
+ }
+
+ /* add a MAC header refer: 7.1.3.1 Frame Control field in P802.11REVmb.book */
+ if (priority != CSR_CONTENTION) {
+ /* EAPOL packets don't go as QOS_DATA */
+ if (priority == CSR_MANAGEMENT) {
+ fc |= cpu_to_le16(IEEE802_11_FC_TYPE_DATA);
+ } else {
+ /* Qos Control Field */
+ macHeaderLengthInBytes += QOS_CONTROL_HEADER_SIZE;
+
+ if (skb->len) {
+
+ fc |= cpu_to_le16(IEEE802_11_FC_TYPE_QOS_DATA);
+ } else {
+ fc |= cpu_to_le16(IEEE802_11_FC_TYPE_QOS_NULL);
+ bQosNull = true;
+ }
+ }
+ } else {
+ if(skb->len == 0) {
+ fc |= cpu_to_le16(IEEE802_11_FC_TYPE_NULL);
+ } else {
+ fc |= cpu_to_le16(IEEE802_11_FC_TYPE_DATA);
+ }
+ }
+
+ switch (interfacePriv->interfaceMode)
+ {
+ case CSR_WIFI_ROUTER_CTRL_MODE_STA:
+ case CSR_WIFI_ROUTER_CTRL_MODE_P2PCLI:
+ direction = 2;
+ fc |= cpu_to_le16(IEEE802_11_FC_TO_DS_MASK);
+ break;
+ case CSR_WIFI_ROUTER_CTRL_MODE_IBSS:
+ direction = 0;
+ break;
+ case CSR_WIFI_ROUTER_CTRL_MODE_AP:
+ case CSR_WIFI_ROUTER_CTRL_MODE_P2PGO:
+ direction = 1;
+ fc |= cpu_to_le16(IEEE802_11_FC_FROM_DS_MASK);
+ break;
+ case CSR_WIFI_ROUTER_CTRL_MODE_AMP:
+ if (priority == CSR_MANAGEMENT ) {
+
+ direction = 2;
+ fc |= cpu_to_le16(IEEE802_11_FC_TO_DS_MASK);
+ } else {
+ /* Data frames have to use WDS 4 address frames */
+ direction = 3;
+ fc |= cpu_to_le16(IEEE802_11_FC_TO_DS_MASK | IEEE802_11_FC_FROM_DS_MASK);
+ macHeaderLengthInBytes += 6;
+ }
+ break;
+ default:
+ unifi_warning(priv, "prepare_and_add_macheader: Unknown mode %d\n",
+ interfacePriv->interfaceMode);
+ }
+
+
+ /* If Sta is QOS & HTC is supported then need to set 'order' bit */
+ /* We don't support HT Control for now */
+
+ if(protection) {
+ fc |= cpu_to_le16(IEEE802_11_FC_PROTECTED_MASK);
+ }
+
+ /* check the skb headroom before pushing mac header */
+ headroom = skb_headroom(skb);
+
+ if (headroom < macHeaderLengthInBytes) {
+ unifi_trace(priv, UDBG5,
+ "prepare_and_add_macheader: Allocate headroom extra %d bytes\n",
+ macHeaderLengthInBytes);
+
+ csrResult = unifi_net_data_malloc(priv, &data_ptrs.d[0], skb->len + macHeaderLengthInBytes);
+
+ if (csrResult != CSR_RESULT_SUCCESS) {
+ unifi_error(priv, " failed to allocate request_data. in %s func\n", __FUNCTION__);
+ return -1;
+ }
+ newSkb = (struct sk_buff *)(data_ptrs.d[0].os_net_buf_ptr);
+ newSkb->len = skb->len + macHeaderLengthInBytes;
+
+ memcpy((void*)data_ptrs.d[0].os_data_ptr + macHeaderLengthInBytes,
+ skb->data, skb->len);
+
+ bulkdata->d[0].os_data_ptr = newSkb->data;
+ bulkdata->d[0].os_net_buf_ptr = (unsigned char*)newSkb;
+ bulkdata->d[0].data_length = newSkb->len;
+
+ bufPtr = (u8*)data_ptrs.d[0].os_data_ptr;
+
+ /* The old skb will not be used again */
+ kfree_skb(skb);
+ } else {
+
+ /* headroom has sufficient size, so will get proper pointer */
+ bufPtr = (u8*)skb_push(skb, macHeaderLengthInBytes);
+ bulkdata->d[0].os_data_ptr = skb->data;
+ bulkdata->d[0].os_net_buf_ptr = (unsigned char*)skb;
+ bulkdata->d[0].data_length = skb->len;
+ }
+
+ /* Frame the actual MAC header */
+
+ memset(bufPtr, 0, macHeaderLengthInBytes);
+
+ /* copy frameControl field */
+ memcpy(bufPtr, &fc, sizeof(fc));
+ bufPtr += sizeof(fc);
+ macHeaderLengthInBytes -= sizeof(fc);
+
+ /* Duration/ID field which is 2 bytes */
+ bufPtr += 2;
+ macHeaderLengthInBytes -= 2;
+
+ switch(direction)
+ {
+ case 0:
+ /* Its an Ad-Hoc no need to route it through AP */
+ /* Address1: MAC address of the destination from eth header */
+ memcpy(bufPtr, daddr, ETH_ALEN);
+ bufPtr += ETH_ALEN;
+ macHeaderLengthInBytes -= ETH_ALEN;
+
+ /* Address2: MAC address of the source */
+ memcpy(bufPtr, saddr, ETH_ALEN);
+ bufPtr += ETH_ALEN;
+ macHeaderLengthInBytes -= ETH_ALEN;
+
+ /* Address3: the BSSID (locally generated in AdHoc (creators Bssid)) */
+ memcpy(bufPtr, &interfacePriv->bssid, ETH_ALEN);
+ bufPtr += ETH_ALEN;
+ macHeaderLengthInBytes -= ETH_ALEN;
+ break;
+ case 1:
+ /* Address1: MAC address of the actual destination */
+ memcpy(bufPtr, daddr, ETH_ALEN);
+ bufPtr += ETH_ALEN;
+ macHeaderLengthInBytes -= ETH_ALEN;
+ /* Address2: The MAC address of the AP */
+ memcpy(bufPtr, &interfacePriv->bssid, ETH_ALEN);
+ bufPtr += ETH_ALEN;
+ macHeaderLengthInBytes -= ETH_ALEN;
+
+ /* Address3: MAC address of the source from eth header */
+ memcpy(bufPtr, saddr, ETH_ALEN);
+ bufPtr += ETH_ALEN;
+ macHeaderLengthInBytes -= ETH_ALEN;
+ break;
+ case 2:
+ /* Address1: To AP is the MAC address of the AP to which its associated */
+ memcpy(bufPtr, &interfacePriv->bssid, ETH_ALEN);
+ bufPtr += ETH_ALEN;
+ macHeaderLengthInBytes -= ETH_ALEN;
+
+ /* Address2: MAC address of the source from eth header */
+ memcpy(bufPtr, saddr, ETH_ALEN);
+ bufPtr += ETH_ALEN;
+ macHeaderLengthInBytes -= ETH_ALEN;
+
+ /* Address3: MAC address of the actual destination on the distribution system */
+ memcpy(bufPtr, daddr, ETH_ALEN);
+ bufPtr += ETH_ALEN;
+ macHeaderLengthInBytes -= ETH_ALEN;
+ break;
+ case 3:
+ memcpy(bufPtr, &interfacePriv->bssid, ETH_ALEN);
+ bufPtr += ETH_ALEN;
+ macHeaderLengthInBytes -= ETH_ALEN;
+
+ /* Address2: MAC address of the source from eth header */
+ memcpy(bufPtr, saddr, ETH_ALEN);
+ bufPtr += ETH_ALEN;
+ macHeaderLengthInBytes -= ETH_ALEN;
+
+ /* Address3: MAC address of the actual destination on the distribution system */
+ memcpy(bufPtr, daddr, ETH_ALEN);
+ bufPtr += ETH_ALEN;
+ macHeaderLengthInBytes -= ETH_ALEN;
+ break;
+ default:
+ unifi_error(priv,"Unknown direction =%d : Not handled now\n",direction);
+ return -1;
+ }
+ /* 2 bytes of frame control field, appended by firmware */
+ bufPtr += 2;
+ macHeaderLengthInBytes -= 2;
+
+ if (3 == direction) {
+ /* Address4: MAC address of the source */
+ memcpy(bufPtr, saddr, ETH_ALEN);
+ bufPtr += ETH_ALEN;
+ macHeaderLengthInBytes -= ETH_ALEN;
+ }
+
+ /* IF Qos Data or Qos Null Data then set QosControl field */
+ if ((priority != CSR_CONTENTION) && (macHeaderLengthInBytes >= QOS_CONTROL_HEADER_SIZE)) {
+
+ if (priority > 7) {
+ unifi_trace(priv, UDBG1, "data packets priority is more than 7, priority = %x\n", priority);
+ qc |= 7;
+ } else {
+ qc |= priority;
+ }
+ /*assigning address1
+ * Address1 offset taken fromm bufPtr(currently bufPtr pointing to Qos contorl) variable in reverse direction
+ * Address4 don't exit
+ */
+
+ addressOne = bufPtr- ADDRESS_ONE_OFFSET;
+
+ if (addressOne[0] & 0x1) {
+ /* multicast/broadcast frames, no acknowledgement needed */
+ qc |= 1 << 5;
+ }
+ /* non-AP mode only for now */
+ if(interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_STA ||
+ interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_IBSS ||
+ interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_P2PCLI) {
+ /* In case of STA and IBSS case eosp and txop limit is 0. */
+ } else {
+ if(bQosNull) {
+ qc |= 1 << 4;
+ }
+ }
+
+ /* append Qos control field to mac header */
+ bufPtr[0] = qc;
+ /* txop limit is 0 */
+ bufPtr[1] = 0;
+ macHeaderLengthInBytes -= QOS_CONTROL_HEADER_SIZE;
+ }
+ if (macHeaderLengthInBytes) {
+ unifi_warning(priv, " Mac header not appended properly\n");
+ return -1;
+ }
+ return 0;
+}
+
+/*
+ * ---------------------------------------------------------------------------
+ * send_ma_pkt_request
+ *
+ * These functions send a data packet to UniFi for transmission.
+ * EAP protocol packets are also sent as send_ma_pkt_request().
+ *
+ * Arguments:
+ * priv Pointer to device private context struct
+ * skb Socket buffer containing data packet to transmit
+ * ehdr Pointer to Ethernet header within skb.
+ *
+ * Returns:
+ * Zero on success or error code.
+ * ---------------------------------------------------------------------------
+ */
+
+static int
+send_ma_pkt_request(unifi_priv_t *priv, struct sk_buff *skb, const struct ethhdr *ehdr, CSR_PRIORITY priority)
+{
+ int r;
+ u16 i;
+ u8 eapolStore = FALSE;
+ struct sk_buff *newSkb = NULL;
+ bulk_data_param_t bulkdata;
+ const int proto = ntohs(ehdr->h_proto);
+ u16 interfaceTag;
+ CsrWifiMacAddress peerAddress;
+ CSR_TRANSMISSION_CONTROL transmissionControl = CSR_NO_CONFIRM_REQUIRED;
+ s8 protection;
+ netInterface_priv_t *interfacePriv = NULL;
+ CSR_RATE TransmitRate = (CSR_RATE)0;
+
+ unifi_trace(priv, UDBG5, "entering send_ma_pkt_request\n");
+
+ /* Get the interface Tag by means of source Mac address */
+ for (i = 0; i < CSR_WIFI_NUM_INTERFACES; i++) {
+ if (!memcmp(priv->netdev[i]->dev_addr, ehdr->h_source, ETH_ALEN)) {
+ interfaceTag = i;
+ interfacePriv = priv->interfacePriv[interfaceTag];
+ break;
+ }
+ }
+
+ if (interfacePriv == NULL) {
+ /* No match found - error */
+ interfaceTag = 0;
+ interfacePriv = priv->interfacePriv[interfaceTag];
+ unifi_warning(priv, "Mac address not matching ... debugging needed\n");
+ interfacePriv->stats.tx_dropped++;
+ kfree_skb(skb);
+ return -1;
+ }
+
+ /* Add a SNAP header if necessary */
+ if (skb_add_llc_snap(priv->netdev[interfaceTag], skb, proto) != 0) {
+ /* convert failed */
+ unifi_error(priv, "skb_add_llc_snap failed.\n");
+ kfree_skb(skb);
+ return -1;
+ }
+
+ bulkdata.d[0].os_data_ptr = skb->data;
+ bulkdata.d[0].os_net_buf_ptr = (unsigned char*)skb;
+ bulkdata.d[0].net_buf_length = bulkdata.d[0].data_length = skb->len;
+ bulkdata.d[1].os_data_ptr = NULL;
+ bulkdata.d[1].os_net_buf_ptr = NULL;
+ bulkdata.d[1].net_buf_length = bulkdata.d[1].data_length = 0;
+
+#ifdef CSR_SUPPORT_SME
+ /* Notify the TA module for the Tx frame for non AP/P2PGO mode*/
+ if ((interfacePriv->interfaceMode != CSR_WIFI_ROUTER_CTRL_MODE_AP) &&
+ (interfacePriv->interfaceMode != CSR_WIFI_ROUTER_CTRL_MODE_P2PGO)) {
+ unifi_ta_sample(priv->card, CSR_WIFI_ROUTER_CTRL_PROTOCOL_DIRECTION_TX,
+ &bulkdata.d[0], ehdr->h_source,
+ priv->netdev[interfaceTag]->dev_addr,
+ jiffies_to_msecs(jiffies),
+ 0); /* rate is unknown on tx */
+ }
+#endif /* CSR_SUPPORT_SME */
+
+ if ((proto == ETH_P_PAE)
+#ifdef CSR_WIFI_SECURITY_WAPI_ENABLE
+ || (proto == ETH_P_WAI)
+#endif
+ )
+ {
+ /* check for m4 detection */
+ if (0 == uf_verify_m4(priv, bulkdata.d[0].os_data_ptr, bulkdata.d[0].data_length)) {
+ eapolStore = TRUE;
+ }
+ }
+
+#ifdef CSR_WIFI_SECURITY_WAPI_ENABLE
+ if (proto == ETH_P_WAI)
+ {
+ protection = 0; /*WAI packets always sent unencrypted*/
+ }
+ else
+ {
+#endif
+#ifdef CSR_SUPPORT_SME
+ if ((protection = uf_get_protection_bit_from_interfacemode(priv, interfaceTag, ehdr->h_dest)) < 0) {
+ unifi_warning(priv, "unicast address, but destination not in station record database\n");
+ unifi_net_data_free(priv, &bulkdata.d[0]);
+ return -1;
+ }
+#else
+ protection = 0;
+#endif
+#ifdef CSR_WIFI_SECURITY_WAPI_ENABLE
+ }
+#endif
+
+ /* append Mac header for Eapol as well as data packet */
+ if (prepare_and_add_macheader(priv, skb, newSkb, priority, &bulkdata, interfaceTag, ehdr->h_dest, ehdr->h_source, protection)) {
+ unifi_error(priv, "failed to create MAC header\n");
+ unifi_net_data_free(priv, &bulkdata.d[0]);
+ return -1;
+ }
+
+ /* RA adrress must contain the immediate destination MAC address that is similiar to
+ * the Address 1 field of 802.11 Mac header here 4 is: (sizeof(framecontrol) + sizeof (durationID))
+ * which is address 1 field
+ */
+ memcpy(peerAddress.a, ((u8 *) bulkdata.d[0].os_data_ptr) + 4, ETH_ALEN);
+
+ unifi_trace(priv, UDBG5, "RA[0]=%x, RA[1]=%x, RA[2]=%x, RA[3]=%x, RA[4]=%x, RA[5]=%x\n",
+ peerAddress.a[0],peerAddress.a[1], peerAddress.a[2], peerAddress.a[3],
+ peerAddress.a[4],peerAddress.a[5]);
+
+
+ if ((proto == ETH_P_PAE)
+#ifdef CSR_WIFI_SECURITY_WAPI_ENABLE
+ || (proto == ETH_P_WAI)
+#endif
+ )
+ {
+ CSR_SIGNAL signal;
+ CSR_MA_PACKET_REQUEST *req = &signal.u.MaPacketRequest;
+
+ /* initialize signal to zero */
+ memset(&signal, 0, sizeof(CSR_SIGNAL));
+
+ /* Frame MA_PACKET request */
+ signal.SignalPrimitiveHeader.SignalId = CSR_MA_PACKET_REQUEST_ID;
+ signal.SignalPrimitiveHeader.ReceiverProcessId = 0;
+ signal.SignalPrimitiveHeader.SenderProcessId = priv->netdev_client->sender_id;
+
+ transmissionControl = req->TransmissionControl = 0;
+#ifdef CSR_SUPPORT_SME
+ if (eapolStore)
+ {
+ netInterface_priv_t *netpriv = (netInterface_priv_t *)netdev_priv(priv->netdev[interfaceTag]);
+
+ /* Fill the MA-PACKET.req */
+
+ req->Priority = priority;
+ unifi_trace(priv, UDBG3, "Tx Frame with Priority: %x\n", req->Priority);
+
+ /* rate selected by firmware */
+ req->TransmitRate = 0;
+ req->HostTag = CSR_WIFI_EAPOL_M4_HOST_TAG;
+ /* RA address matching with address 1 of Mac header */
+ memcpy(req->Ra.x, ((u8 *) bulkdata.d[0].os_data_ptr) + 4, ETH_ALEN);
+
+ spin_lock(&priv->m4_lock);
+ /* Store the M4-PACKET.req for later */
+ interfacePriv->m4_signal = signal;
+ interfacePriv->m4_bulk_data.net_buf_length = bulkdata.d[0].net_buf_length;
+ interfacePriv->m4_bulk_data.data_length = bulkdata.d[0].data_length;
+ interfacePriv->m4_bulk_data.os_data_ptr = bulkdata.d[0].os_data_ptr;
+ interfacePriv->m4_bulk_data.os_net_buf_ptr = bulkdata.d[0].os_net_buf_ptr;
+ spin_unlock(&priv->m4_lock);
+
+ /* Signal the workqueue to call CsrWifiRouterCtrlM4ReadyToSendIndSend().
+ * It cannot be called directly from the tx path because it
+ * does a non-atomic kmalloc via the framework's CsrPmemAlloc().
+ */
+ queue_work(priv->unifi_workqueue, &netpriv->send_m4_ready_task);
+
+ return 0;
+ }
+#endif
+ }/*EAPOL or WAI packet*/
+
+#if (defined(CSR_WIFI_SECURITY_WAPI_ENABLE) && defined(CSR_WIFI_SECURITY_WAPI_SW_ENCRYPTION))
+ if ((CSR_WIFI_ROUTER_CTRL_MODE_STA == interfacePriv->interfaceMode) && \
+ (priv->wapi_unicast_filter) && \
+ (proto != ETH_P_PAE) && \
+ (proto != ETH_P_WAI) && \
+ (skb->len > 0))
+ {
+ CSR_SIGNAL signal;
+ CSR_MA_PACKET_REQUEST *req = &signal.u.MaPacketRequest;
+ netInterface_priv_t *netpriv = (netInterface_priv_t *)netdev_priv(priv->netdev[interfaceTag]);
+
+ unifi_trace(priv, UDBG4, "send_ma_pkt_request() - WAPI unicast data packet when USKID = 1 \n");
+
+ /* initialize signal to zero */
+ memset(&signal, 0, sizeof(CSR_SIGNAL));
+ /* Frame MA_PACKET request */
+ signal.SignalPrimitiveHeader.SignalId = CSR_MA_PACKET_REQUEST_ID;
+ signal.SignalPrimitiveHeader.ReceiverProcessId = 0;
+ signal.SignalPrimitiveHeader.SenderProcessId = priv->netdev_client->sender_id;
+
+ /* Fill the MA-PACKET.req */
+ req->TransmissionControl = 0;
+ req->Priority = priority;
+ unifi_trace(priv, UDBG3, "Tx Frame with Priority: %x\n", req->Priority);
+ req->TransmitRate = (CSR_RATE) 0; /* rate selected by firmware */
+ req->HostTag = 0xffffffff; /* Ask for a new HostTag */
+ /* RA address matching with address 1 of Mac header */
+ memcpy(req->Ra.x, ((u8 *) bulkdata.d[0].os_data_ptr) + 4, ETH_ALEN);
+
+ /* Store the M4-PACKET.req for later */
+ spin_lock(&priv->wapi_lock);
+ interfacePriv->wapi_unicast_ma_pkt_sig = signal;
+ interfacePriv->wapi_unicast_bulk_data.net_buf_length = bulkdata.d[0].net_buf_length;
+ interfacePriv->wapi_unicast_bulk_data.data_length = bulkdata.d[0].data_length;
+ interfacePriv->wapi_unicast_bulk_data.os_data_ptr = bulkdata.d[0].os_data_ptr;
+ interfacePriv->wapi_unicast_bulk_data.os_net_buf_ptr = bulkdata.d[0].os_net_buf_ptr;
+ spin_unlock(&priv->wapi_lock);
+
+ /* Signal the workqueue to call CsrWifiRouterCtrlWapiUnicastTxEncryptIndSend().
+ * It cannot be called directly from the tx path because it
+ * does a non-atomic kmalloc via the framework's CsrPmemAlloc().
+ */
+ queue_work(priv->unifi_workqueue, &netpriv->send_pkt_to_encrypt);
+
+ return 0;
+ }
+#endif
+
+ if(priv->cmanrTestMode)
+ {
+ TransmitRate = priv->cmanrTestModeTransmitRate;
+ unifi_trace(priv, UDBG2, "send_ma_pkt_request: cmanrTestModeTransmitRate = %d TransmitRate=%d\n",
+ priv->cmanrTestModeTransmitRate,
+ TransmitRate
+ );
+ }
+
+ /* Send UniFi msg */
+ /* Here hostTag is been sent as 0xffffffff, its been appended properly while framing MA-Packet request in pdu_processing.c file */
+ r = uf_process_ma_packet_req(priv,
+ peerAddress.a,
+ 0xffffffff, /* Ask for a new HostTag */
+ interfaceTag,
+ transmissionControl,
+ TransmitRate,
+ priority,
+ priv->netdev_client->sender_id,
+ &bulkdata);
+
+ if (r) {
+ unifi_trace(priv, UDBG1, "(HIP validation failure) r = %x\n", r);
+ unifi_net_data_free(priv, &bulkdata.d[0]);
+ return -1;
+ }
+
+ unifi_trace(priv, UDBG3, "leaving send_ma_pkt_request, UNITDATA result code = %d\n", r);
+
+ return r;
+} /* send_ma_pkt_request() */
+
+/*
+ * ---------------------------------------------------------------------------
+ * uf_net_xmit
+ *
+ * This function is called by the higher level stack to transmit an
+ * ethernet packet.
+ *
+ * Arguments:
+ * skb Ethernet packet to send.
+ * dev Pointer to the linux net device.
+ *
+ * Returns:
+ * 0 on success (packet was consumed, not necessarily transmitted)
+ * 1 if packet was requeued
+ * -1 on error
+ *
+ *
+ * Notes:
+ * The controlled port is handled in the qdisc dequeue handler.
+ * ---------------------------------------------------------------------------
+ */
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,32)
+static netdev_tx_t
+#else
+static int
+#endif
+uf_net_xmit(struct sk_buff *skb, struct net_device *dev)
+{
+ netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev);
+ unifi_priv_t *priv = interfacePriv->privPtr;
+ struct ethhdr ehdr;
+ int proto, port;
+ int result;
+ static tx_signal_handler tx_handler;
+ CSR_PRIORITY priority;
+#if !defined (CONFIG_NET_SCHED) || (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,28))
+ CsrWifiRouterCtrlPortAction port_action;
+#endif /* CONFIG_NET_SCHED */
+
+ func_enter();
+
+ unifi_trace(priv, UDBG5, "unifi_net_xmit: skb = %x\n", skb);
+
+ memcpy(&ehdr, skb->data, ETH_HLEN);
+ proto = ntohs(ehdr.h_proto);
+ priority = get_packet_priority(priv, skb, &ehdr, interfacePriv);
+
+ /* All frames are sent as MA-PACKET.req (EAPOL also) */
+ tx_handler = send_ma_pkt_request;
+
+ /* 802.1x - apply controlled/uncontrolled port rules */
+ if ((proto != ETH_P_PAE)
+#ifdef CSR_WIFI_SECURITY_WAPI_ENABLE
+ && (proto != ETH_P_WAI)
+#endif
+ ) {
+ port = UF_CONTROLLED_PORT_Q;
+ } else {
+ /* queue 4 */
+ port = UF_UNCONTROLLED_PORT_Q;
+ }
+
+#if defined (CONFIG_NET_SCHED) && (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,28))
+ /* Remove the ethernet header */
+ skb_pull(skb, ETH_HLEN);
+ result = tx_handler(priv, skb, &ehdr, priority);
+#else
+ /* Uncontrolled port rules apply */
+ port_action = verify_port(priv
+ , (((CSR_WIFI_ROUTER_CTRL_MODE_STA == interfacePriv->interfaceMode)||(CSR_WIFI_ROUTER_CTRL_MODE_P2PCLI== interfacePriv->interfaceMode))? interfacePriv->bssid.a: ehdr.h_dest)
+ , port
+ , interfacePriv->InterfaceTag);
+
+ if (port_action == CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_OPEN) {
+ unifi_trace(priv, UDBG5,
+ "uf_net_xmit: %s controlled port open\n",
+ port ? "" : "un");
+ /* Remove the ethernet header */
+ skb_pull(skb, ETH_HLEN);
+ result = tx_handler(priv, skb, &ehdr, priority);
+ } else {
+
+ /* Discard the packet if necessary */
+ unifi_trace(priv, UDBG2,
+ "uf_net_xmit: %s controlled port %s\n",
+ port ? "" : "un", port_action==CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_CLOSED_BLOCK ? "blocked" : "closed");
+ interfacePriv->stats.tx_dropped++;
+ kfree_skb(skb);
+
+ func_exit();
+ return NETDEV_TX_OK;
+ }
+#endif /* CONFIG_NET_SCHED */
+
+ if (result == NETDEV_TX_OK) {
+#if (defined(CSR_WIFI_SECURITY_WAPI_ENABLE) && defined(CSR_WIFI_SECURITY_WAPI_SW_ENCRYPTION))
+ /* Don't update the tx stats when the pkt is to be sent for sw encryption*/
+ if (!((CSR_WIFI_ROUTER_CTRL_MODE_STA == interfacePriv->interfaceMode) &&
+ (priv->wapi_unicast_filter == 1)))
+ {
+ dev->trans_start = jiffies;
+ /* Should really count tx stats in the UNITDATA.status signal but
+ * that doesn't have the length.
+ */
+ interfacePriv->stats.tx_packets++;
+ /* count only the packet payload */
+ interfacePriv->stats.tx_bytes += skb->len;
+
+ }
+#else
+ dev->trans_start = jiffies;
+
+ /*
+ * Should really count tx stats in the UNITDATA.status signal but
+ * that doesn't have the length.
+ */
+ interfacePriv->stats.tx_packets++;
+ /* count only the packet payload */
+ interfacePriv->stats.tx_bytes += skb->len;
+#endif
+ } else if (result < 0) {
+
+ /* Failed to send: fh queue was full, and the skb was discarded.
+ * Return OK to indicate that the buffer was consumed, to stop the
+ * kernel re-transmitting the freed buffer.
+ */
+ interfacePriv->stats.tx_dropped++;
+ unifi_trace(priv, UDBG1, "unifi_net_xmit: (Packet Drop), dropped count = %x\n", interfacePriv->stats.tx_dropped);
+ result = NETDEV_TX_OK;
+ }
+
+ /* The skb will have been freed by send_XXX_request() */
+
+ func_exit();
+ return result;
+} /* uf_net_xmit() */
+
+/*
+ * ---------------------------------------------------------------------------
+ * unifi_pause_xmit
+ * unifi_restart_xmit
+ *
+ * These functions are called from the UniFi core to control the flow
+ * of packets from the upper layers.
+ * unifi_pause_xmit() is called when the internal queue is full and
+ * should take action to stop unifi_ma_unitdata() being called.
+ * When the queue has drained, unifi_restart_xmit() will be called to
+ * re-enable the flow of packets for transmission.
+ *
+ * Arguments:
+ * ospriv OS private context pointer.
+ *
+ * Returns:
+ * unifi_pause_xmit() is called from interrupt context.
+ * ---------------------------------------------------------------------------
+ */
+void
+unifi_pause_xmit(void *ospriv, unifi_TrafficQueue queue)
+{
+ unifi_priv_t *priv = ospriv;
+ int i; /* used as a loop counter */
+
+ func_enter();
+ unifi_trace(priv, UDBG2, "Stopping queue %d\n", queue);
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,28)
+ for(i=0;i<CSR_WIFI_NUM_INTERFACES;i++)
+ {
+ if (netif_running(priv->netdev[i]))
+ {
+ netif_stop_subqueue(priv->netdev[i], (u16)queue);
+ }
+ }
+#else
+#ifdef ALLOW_Q_PAUSE
+ unifi_trace(priv, UDBG2, "Stopping netif\n");
+ /* stop the traffic from all the interfaces. */
+ for(i=0;i<CSR_WIFI_NUM_INTERFACES;i++)
+ {
+ if (netif_running(priv->netdev[i])) {
+ UF_NETIF_TX_STOP_ALL_QUEUES(priv->netdev[i]);
+ }
+ }
+#else
+ if (net_is_tx_q_paused(priv, queue)) {
+ unifi_trace(priv, UDBG2, "Queue already stopped\n");
+ return;
+ }
+ net_tx_q_pause(priv, queue);
+#endif
+#endif
+
+#ifdef CSR_SUPPORT_SME
+ if(queue<=3) {
+ routerStartBuffering(priv,queue);
+ unifi_trace(priv,UDBG2,"Start buffering %d\n", queue);
+ } else {
+ routerStartBuffering(priv,0);
+ unifi_error(priv, "Start buffering %d defaulting to 0\n", queue);
+ }
+#endif
+ func_exit();
+
+} /* unifi_pause_xmit() */
+
+void
+unifi_restart_xmit(void *ospriv, unifi_TrafficQueue queue)
+{
+ unifi_priv_t *priv = ospriv;
+ int i=0; /* used as a loop counter */
+
+ func_enter();
+ unifi_trace(priv, UDBG2, "Waking queue %d\n", queue);
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,28)
+ for(i=0;i<CSR_WIFI_NUM_INTERFACES;i++)
+ {
+ if (netif_running(priv->netdev[i]))
+ {
+ netif_wake_subqueue(priv->netdev[i], (u16)queue);
+ }
+ }
+#else
+#ifdef ALLOW_Q_PAUSE
+ /* Need to supply queue number depending on Kernel support */
+ /* Resume the traffic from all the interfaces */
+ for(i=0;i<CSR_WIFI_NUM_INTERFACES;i++)
+ {
+ if (netif_running(priv->netdev[i])) {
+ UF_NETIF_TX_WAKE_ALL_QUEUES(priv->netdev[i]);
+ }
+ }
+#else
+ if (!(net_is_tx_q_paused(priv, queue))) {
+ unifi_trace(priv, UDBG2, "Queue already running\n");
+ func_exit();
+ return;
+ }
+ net_tx_q_unpause(priv, queue);
+#endif
+#endif
+
+#ifdef CSR_SUPPORT_SME
+ if(queue <=3) {
+ routerStopBuffering(priv,queue);
+ uf_send_buffered_frames(priv,queue);
+ } else {
+ routerStopBuffering(priv,0);
+ uf_send_buffered_frames(priv,0);
+ }
+#endif
+ func_exit();
+} /* unifi_restart_xmit() */
+
+
+static void
+indicate_rx_skb(unifi_priv_t *priv, u16 ifTag, u8* dst_a, u8* src_a, struct sk_buff *skb, CSR_SIGNAL *signal,
+ bulk_data_param_t *bulkdata)
+{
+ int r, sr = 0;
+ struct net_device *dev;
+
+#ifdef CSR_SUPPORT_SME
+ llc_snap_hdr_t *snap;
+
+ snap = (llc_snap_hdr_t *)skb->data;
+
+ sr = _identify_sme_ma_pkt_ind(priv,
+ snap->oui, ntohs(snap->protocol),
+ signal,
+ bulkdata,
+ dst_a, src_a );
+#endif
+
+ /*
+ * Decapsulate any SNAP header and
+ * prepend an ethernet header so that the skb manipulation and ARP
+ * stuff works.
+ */
+ r = skb_80211_to_ether(priv, skb, dst_a, src_a,
+ signal, bulkdata);
+ if (r == -1) {
+ /* Drop the packet and return */
+ priv->interfacePriv[ifTag]->stats.rx_errors++;
+ priv->interfacePriv[ifTag]->stats.rx_frame_errors++;
+ unifi_net_data_free(priv, &bulkdata->d[0]);
+ unifi_notice(priv, "indicate_rx_skb: Discard unknown frame.\n");
+ func_exit();
+ return;
+ }
+
+ /* Handle the case where packet is sent up through the subscription
+ * API but should not be given to the network stack (AMP PAL case)
+ * LLC header is different from WiFi and the packet has been subscribed for
+ */
+ if (r == 1 && sr == 1) {
+ unifi_net_data_free(priv, &bulkdata->d[0]);
+ unifi_trace(priv, UDBG5, "indicate_rx_skb: Data given to subscription"
+ "API, not being given to kernel\n");
+ func_exit();
+ return;
+ }
+
+ dev = priv->netdev[ifTag];
+ /* Now we look like a regular ethernet frame */
+ /* Fill in SKB meta data */
+ skb->dev = dev;
+ skb->protocol = eth_type_trans(skb, dev);
+ skb->ip_summed = CHECKSUM_UNNECESSARY;
+
+ /* Test for an overlength frame */
+ if (skb->len > (dev->mtu + ETH_HLEN)) {
+ /* A bogus length ethfrm has been encap'd. */
+ /* Is someone trying an oflow attack? */
+ unifi_error(priv, "%s: oversize frame (%d > %d)\n",
+ dev->name,
+ skb->len, dev->mtu + ETH_HLEN);
+
+ /* Drop the packet and return */
+ priv->interfacePriv[ifTag]->stats.rx_errors++;
+ priv->interfacePriv[ifTag]->stats.rx_length_errors++;
+ unifi_net_data_free(priv, &bulkdata->d[0]);
+ func_exit();
+ return;
+ }
+
+
+ if(priv->cmanrTestMode)
+ {
+ const CSR_MA_PACKET_INDICATION *pkt_ind = &signal->u.MaPacketIndication;
+ priv->cmanrTestModeTransmitRate = pkt_ind->ReceivedRate;
+ unifi_trace(priv, UDBG2, "indicate_rx_skb: cmanrTestModeTransmitRate=%d\n", priv->cmanrTestModeTransmitRate);
+ }
+
+ /* Pass SKB up the stack */
+#ifdef CSR_WIFI_USE_NETIF_RX
+ netif_rx(skb);
+#else
+ netif_rx_ni(skb);
+#endif
+
+ if (dev != NULL) {
+ dev->last_rx = jiffies;
+ }
+
+ /* Bump rx stats */
+ priv->interfacePriv[ifTag]->stats.rx_packets++;
+ priv->interfacePriv[ifTag]->stats.rx_bytes += bulkdata->d[0].data_length;
+
+ func_exit();
+ return;
+}
+
+void
+uf_process_rx_pending_queue(unifi_priv_t *priv, int queue,
+ CsrWifiMacAddress source_address,
+ int indicate, u16 interfaceTag)
+{
+ rx_buffered_packets_t *rx_q_item;
+ struct list_head *rx_list;
+ struct list_head *n;
+ struct list_head *l_h;
+ static const CsrWifiMacAddress broadcast_address = {{0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}};
+ netInterface_priv_t *interfacePriv = priv->interfacePriv[interfaceTag];
+
+ if (interfaceTag >= CSR_WIFI_NUM_INTERFACES) {
+ unifi_error(priv, "uf_process_rx_pending_queue bad interfaceTag\n");
+ return;
+ }
+
+ if (queue == UF_CONTROLLED_PORT_Q) {
+ rx_list = &interfacePriv->rx_controlled_list;
+ } else {
+ rx_list = &interfacePriv->rx_uncontrolled_list;
+ }
+
+ down(&priv->rx_q_sem);
+ list_for_each_safe(l_h, n, rx_list) {
+ rx_q_item = list_entry(l_h, rx_buffered_packets_t, q);
+
+ /* Validate against the source address */
+ if (memcmp(broadcast_address.a, source_address.a, ETH_ALEN) &&
+ memcmp(rx_q_item->sa.a, source_address.a, ETH_ALEN)) {
+
+ unifi_trace(priv, UDBG2,
+ "uf_process_rx_pending_queue: Skipping sa=%02X%02X%02X%02X%02X%02X skb=%p, bulkdata=%p\n",
+ rx_q_item->sa.a[0], rx_q_item->sa.a[1],
+ rx_q_item->sa.a[2], rx_q_item->sa.a[3],
+ rx_q_item->sa.a[4], rx_q_item->sa.a[5],
+ rx_q_item->skb, &rx_q_item->bulkdata.d[0]);
+ continue;
+ }
+
+ list_del(l_h);
+
+
+ unifi_trace(priv, UDBG2,
+ "uf_process_rx_pending_queue: Was Blocked skb=%p, bulkdata=%p\n",
+ rx_q_item->skb, &rx_q_item->bulkdata);
+
+ if (indicate) {
+ indicate_rx_skb(priv, interfaceTag, rx_q_item->da.a, rx_q_item->sa.a, rx_q_item->skb, &rx_q_item->signal, &rx_q_item->bulkdata);
+ } else {
+ interfacePriv->stats.rx_dropped++;
+ unifi_net_data_free(priv, &rx_q_item->bulkdata.d[0]);
+ }
+
+ /* It is our resposibility to free the Rx structure object. */
+ kfree(rx_q_item);
+ }
+ up(&priv->rx_q_sem);
+}
+
+/*
+ * ---------------------------------------------------------------------------
+ * uf_resume_data_plane
+ *
+ * Is called when the (un)controlled port is set to open,
+ * to notify the network stack to schedule for transmission
+ * any packets queued in the qdisk while port was closed and
+ * indicated to the stack any packets buffered in the Rx queues.
+ *
+ * Arguments:
+ * priv Pointer to device private struct
+ *
+ * Returns:
+ * ---------------------------------------------------------------------------
+ */
+void
+uf_resume_data_plane(unifi_priv_t *priv, int queue,
+ CsrWifiMacAddress peer_address,
+ u16 interfaceTag)
+{
+#ifdef CSR_SUPPORT_WEXT
+ netInterface_priv_t *interfacePriv = priv->interfacePriv[interfaceTag];
+#endif
+
+ if (interfaceTag >= CSR_WIFI_NUM_INTERFACES) {
+ unifi_error(priv, "uf_resume_data_plane bad interfaceTag\n");
+ return;
+ }
+
+ unifi_trace(priv, UDBG2, "Resuming netif\n");
+
+ /*
+ * If we are waiting for the net device to enter the up state, don't
+ * process the rx queue yet as it will be done by the callback when
+ * the device is ready.
+ */
+#ifdef CSR_SUPPORT_WEXT
+ if (!interfacePriv->wait_netdev_change)
+#endif
+ {
+#ifdef CONFIG_NET_SCHED
+ if (netif_running(priv->netdev[interfaceTag])) {
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,28)
+ netif_tx_schedule_all(priv->netdev[interfaceTag]);
+#elif LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27)
+ netif_schedule_queue(netdev_get_tx_queue(priv->netdev[interfaceTag], 0));
+#else
+ netif_schedule(priv->netdev[interfaceTag]);
+#endif /* LINUX_VERSION_CODE */
+ }
+#endif
+ uf_process_rx_pending_queue(priv, queue, peer_address, 1,interfaceTag);
+ }
+} /* uf_resume_data_plane() */
+
+
+void uf_free_pending_rx_packets(unifi_priv_t *priv, int queue, CsrWifiMacAddress peer_address,u16 interfaceTag)
+{
+ uf_process_rx_pending_queue(priv, queue, peer_address, 0,interfaceTag);
+
+} /* uf_free_pending_rx_packets() */
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * unifi_rx
+ *
+ * Reformat a UniFi data received packet into a p80211 packet and
+ * pass it up the protocol stack.
+ *
+ * Arguments:
+ * None.
+ *
+ * Returns:
+ * None.
+ * ---------------------------------------------------------------------------
+ */
+static void
+unifi_rx(unifi_priv_t *priv, CSR_SIGNAL *signal, bulk_data_param_t *bulkdata)
+{
+ u16 interfaceTag;
+ bulk_data_desc_t *pData;
+ const CSR_MA_PACKET_INDICATION *pkt_ind = &signal->u.MaPacketIndication;
+ struct sk_buff *skb;
+ CsrWifiRouterCtrlPortAction port_action;
+ u8 dataFrameType;
+ int proto;
+ int queue;
+
+ u8 da[ETH_ALEN], sa[ETH_ALEN];
+ u8 toDs, fromDs, frameType, macHeaderLengthInBytes = MAC_HEADER_SIZE;
+ u16 frameControl;
+ netInterface_priv_t *interfacePriv;
+ struct ethhdr ehdr;
+
+ func_enter();
+
+ interfaceTag = (pkt_ind->VirtualInterfaceIdentifier & 0xff);
+ interfacePriv = priv->interfacePriv[interfaceTag];
+
+ /* Sanity check that the VIF refers to a sensible interface */
+ if (interfaceTag >= CSR_WIFI_NUM_INTERFACES)
+ {
+ unifi_error(priv, "%s: MA-PACKET indication with bad interfaceTag %d\n", __FUNCTION__, interfaceTag);
+ unifi_net_data_free(priv,&bulkdata->d[0]);
+ func_exit();
+ return;
+ }
+
+ /* Sanity check that the VIF refers to an allocated netdev */
+ if (!interfacePriv->netdev_registered)
+ {
+ unifi_error(priv, "%s: MA-PACKET indication with unallocated interfaceTag %d\n", __FUNCTION__, interfaceTag);
+ unifi_net_data_free(priv, &bulkdata->d[0]);
+ func_exit();
+ return;
+ }
+
+ if (bulkdata->d[0].data_length == 0) {
+ unifi_warning(priv, "%s: MA-PACKET indication with zero bulk data\n", __FUNCTION__);
+ unifi_net_data_free(priv,&bulkdata->d[0]);
+ func_exit();
+ return;
+ }
+
+
+ skb = (struct sk_buff*)bulkdata->d[0].os_net_buf_ptr;
+ skb->len = bulkdata->d[0].data_length;
+
+ /* Point to the addresses */
+ toDs = (skb->data[1] & 0x01) ? 1 : 0;
+ fromDs = (skb->data[1] & 0x02) ? 1 : 0;
+
+ memcpy(da,(skb->data+4+toDs*12),ETH_ALEN);/* Address1 or 3 */
+ memcpy(sa,(skb->data+10+fromDs*(6+toDs*8)),ETH_ALEN); /* Address2, 3 or 4 */
+
+
+ pData = &bulkdata->d[0];
+ frameControl = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(pData->os_data_ptr);
+ frameType = ((frameControl & 0x000C) >> 2);
+
+ dataFrameType =((frameControl & 0x00f0) >> 4);
+ unifi_trace(priv, UDBG6,
+ "%s: Receive Data Frame Type %d \n", __FUNCTION__,dataFrameType);
+
+ switch(dataFrameType)
+ {
+ case QOS_DATA:
+ case QOS_DATA_NULL:
+ /* If both are set then the Address4 exists (only for AP) */
+ if (fromDs && toDs)
+ {
+ /* 6 is the size of Address4 field */
+ macHeaderLengthInBytes += (QOS_CONTROL_HEADER_SIZE + 6);
+ }
+ else
+ {
+ macHeaderLengthInBytes += QOS_CONTROL_HEADER_SIZE;
+ }
+
+ /* If order bit set then HT control field is the part of MAC header */
+ if (frameControl & FRAME_CONTROL_ORDER_BIT)
+ macHeaderLengthInBytes += HT_CONTROL_HEADER_SIZE;
+ break;
+ default:
+ if (fromDs && toDs)
+ macHeaderLengthInBytes += 6;
+ }
+
+ /* Prepare the ethernet header from snap header of skb data */
+ switch(dataFrameType)
+ {
+ case DATA_NULL:
+ case QOS_DATA_NULL:
+ /* This is for only queue info fetching, EAPOL wont come as
+ * null data so the proto is initialized as zero
+ */
+ proto = 0x0;
+ break;
+ default:
+ {
+ llc_snap_hdr_t *snap;
+ /* Fetch a snap header to find protocol (for IPV4/IPV6 packets
+ * the snap header fetching offset is same)
+ */
+ snap = (llc_snap_hdr_t *) (skb->data + macHeaderLengthInBytes);
+
+ /* prepare the ethernet header from the snap header & addresses */
+ ehdr.h_proto = snap->protocol;
+ memcpy(ehdr.h_dest, da, ETH_ALEN);
+ memcpy(ehdr.h_source, sa, ETH_ALEN);
+ }
+ proto = ntohs(ehdr.h_proto);
+ }
+ unifi_trace(priv, UDBG3, "in unifi_rx protocol from snap header = 0x%x\n", proto);
+
+ if ((proto != ETH_P_PAE)
+#ifdef CSR_WIFI_SECURITY_WAPI_ENABLE
+ && (proto != ETH_P_WAI)
+#endif
+ ) {
+ queue = UF_CONTROLLED_PORT_Q;
+ } else {
+ queue = UF_UNCONTROLLED_PORT_Q;
+ }
+
+ port_action = verify_port(priv, (unsigned char*)sa, queue, interfaceTag);
+ unifi_trace(priv, UDBG3, "in unifi_rx port action is = 0x%x & queue = %x\n", port_action, queue);
+
+#ifdef CSR_SUPPORT_SME
+ /* Notify the TA module for the Rx frame for non P2PGO and AP cases*/
+ if((interfacePriv->interfaceMode != CSR_WIFI_ROUTER_CTRL_MODE_AP) &&
+ (interfacePriv->interfaceMode != CSR_WIFI_ROUTER_CTRL_MODE_P2PGO))
+ {
+ /* Remove MAC header of length(macHeaderLengthInBytes) before sampling */
+ skb_pull(skb, macHeaderLengthInBytes);
+ pData->os_data_ptr = skb->data;
+ pData->data_length -= macHeaderLengthInBytes;
+
+ if (pData->data_length) {
+ unifi_ta_sample(priv->card, CSR_WIFI_ROUTER_CTRL_PROTOCOL_DIRECTION_RX,
+ &bulkdata->d[0],
+ sa, priv->netdev[interfaceTag]->dev_addr,
+ jiffies_to_msecs(jiffies),
+ pkt_ind->ReceivedRate);
+ }
+ } else {
+
+ /* AP/P2PGO specific handling here */
+ CsrWifiRouterCtrlStaInfo_t * srcStaInfo =
+ CsrWifiRouterCtrlGetStationRecordFromPeerMacAddress(priv,sa,interfaceTag);
+
+ /* Defensive check only; Source address is already checked in
+ process_ma_packet_ind and we should have a valid source address here */
+
+ if(srcStaInfo == NULL) {
+ CsrWifiMacAddress peerMacAddress;
+ /* Unknown data PDU */
+ memcpy(peerMacAddress.a,sa,ETH_ALEN);
+ unifi_trace(priv, UDBG1, "%s: Unexpected frame from peer = %x:%x:%x:%x:%x:%x\n", __FUNCTION__,
+ sa[0], sa[1],sa[2], sa[3], sa[4],sa[5]);
+ CsrWifiRouterCtrlUnexpectedFrameIndSend(priv->CSR_WIFI_SME_IFACEQUEUE,0,interfaceTag,peerMacAddress);
+ unifi_net_data_free(priv, &bulkdata->d[0]);
+ func_exit();
+ return;
+ }
+
+ /* For AP GO mode, don't store the PDUs */
+ if (port_action != CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_OPEN) {
+ /* Drop the packet and return */
+ CsrWifiMacAddress peerMacAddress;
+ memcpy(peerMacAddress.a,sa,ETH_ALEN);
+ unifi_trace(priv, UDBG3, "%s: Port is not open: unexpected frame from peer = %x:%x:%x:%x:%x:%x\n",
+ __FUNCTION__, sa[0], sa[1],sa[2], sa[3], sa[4],sa[5]);
+
+ CsrWifiRouterCtrlUnexpectedFrameIndSend(priv->CSR_WIFI_SME_IFACEQUEUE,0,interfaceTag,peerMacAddress);
+ interfacePriv->stats.rx_dropped++;
+ unifi_net_data_free(priv, &bulkdata->d[0]);
+ unifi_notice(priv, "%s: Dropping packet, proto=0x%04x, %s port\n", __FUNCTION__,
+ proto, queue ? "Controlled" : "Un-controlled");
+ func_exit();
+ return;
+ }
+
+ /* Qos NULL/Data NULL are freed here and not processed further */
+ if((dataFrameType == QOS_DATA_NULL) || (dataFrameType == DATA_NULL)){
+ unifi_trace(priv, UDBG5, "%s: Null Frame Received and Freed\n", __FUNCTION__);
+ unifi_net_data_free(priv, &bulkdata->d[0]);
+ func_exit();
+ return;
+ }
+
+ /* Now we have done with MAC header so proceed with the real data part*/
+ /* This function takes care of appropriate routing for AP/P2PGO case*/
+ /* the function hadnles following things
+ 2. Routing the PDU to appropriate location
+ 3. Error case handling
+ */
+ if(!(uf_ap_process_data_pdu(priv, skb, &ehdr, srcStaInfo,
+ signal,
+ bulkdata,
+ macHeaderLengthInBytes)))
+ {
+ func_exit();
+ return;
+ }
+ unifi_trace(priv, UDBG5, "unifi_rx: no specific AP handling process as normal frame, MAC Header len %d\n",macHeaderLengthInBytes);
+ /* Remove the MAC header for subsequent conversion */
+ skb_pull(skb, macHeaderLengthInBytes);
+ pData->os_data_ptr = skb->data;
+ pData->data_length -= macHeaderLengthInBytes;
+ pData->os_net_buf_ptr = (unsigned char*)skb;
+ pData->net_buf_length = skb->len;
+ }
+#endif /* CSR_SUPPORT_SME */
+
+
+ /* Now that the MAC header is removed, null-data frames have zero length
+ * and can be dropped
+ */
+ if (pData->data_length == 0) {
+ if (((frameControl & 0x00f0) >> 4) != QOS_DATA_NULL &&
+ ((frameControl & 0x00f0) >> 4) != DATA_NULL) {
+ unifi_trace(priv, UDBG1, "Zero length frame, but not null-data %04x\n", frameControl);
+ }
+ unifi_net_data_free(priv, &bulkdata->d[0]);
+ func_exit();
+ return;
+ }
+
+ if (port_action == CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_CLOSED_DISCARD) {
+ /* Drop the packet and return */
+ interfacePriv->stats.rx_dropped++;
+ unifi_net_data_free(priv, &bulkdata->d[0]);
+ unifi_notice(priv, "%s: Dropping packet, proto=0x%04x, %s port\n",
+ __FUNCTION__, proto, queue ? "controlled" : "uncontrolled");
+ func_exit();
+ return;
+ } else if ( (port_action == CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_CLOSED_BLOCK) ||
+ (interfacePriv->connected != UnifiConnected) ) {
+
+ /* Buffer the packet into the Rx queues */
+ rx_buffered_packets_t *rx_q_item;
+ struct list_head *rx_list;
+
+ rx_q_item = (rx_buffered_packets_t *)kmalloc(sizeof(rx_buffered_packets_t),
+ GFP_KERNEL);
+ if (rx_q_item == NULL) {
+ unifi_error(priv, "%s: Failed to allocate %d bytes for rx packet record\n",
+ __FUNCTION__, sizeof(rx_buffered_packets_t));
+ interfacePriv->stats.rx_dropped++;
+ unifi_net_data_free(priv, &bulkdata->d[0]);
+ func_exit();
+ return;
+ }
+
+ INIT_LIST_HEAD(&rx_q_item->q);
+ rx_q_item->bulkdata = *bulkdata;
+ rx_q_item->skb = skb;
+ rx_q_item->signal = *signal;
+ memcpy(rx_q_item->sa.a, sa, ETH_ALEN);
+ memcpy(rx_q_item->da.a, da, ETH_ALEN);
+ unifi_trace(priv, UDBG2, "%s: Blocked skb=%p, bulkdata=%p\n",
+ __FUNCTION__, rx_q_item->skb, &rx_q_item->bulkdata);
+
+ if (queue == UF_CONTROLLED_PORT_Q) {
+ rx_list = &interfacePriv->rx_controlled_list;
+ } else {
+ rx_list = &interfacePriv->rx_uncontrolled_list;
+ }
+
+ /* Add to tail of packets queue */
+ down(&priv->rx_q_sem);
+ list_add_tail(&rx_q_item->q, rx_list);
+ up(&priv->rx_q_sem);
+
+ func_exit();
+ return;
+
+ }
+
+ indicate_rx_skb(priv, interfaceTag, da, sa, skb, signal, bulkdata);
+
+ func_exit();
+
+} /* unifi_rx() */
+
+static void process_ma_packet_cfm(unifi_priv_t *priv, CSR_SIGNAL *signal, bulk_data_param_t *bulkdata)
+{
+ u16 interfaceTag;
+ const CSR_MA_PACKET_CONFIRM *pkt_cfm = &signal->u.MaPacketConfirm;
+ netInterface_priv_t *interfacePriv;
+
+ func_enter();
+ interfaceTag = (pkt_cfm->VirtualInterfaceIdentifier & 0xff);
+ interfacePriv = priv->interfacePriv[interfaceTag];
+
+ /* Sanity check that the VIF refers to a sensible interface */
+ if (interfaceTag >= CSR_WIFI_NUM_INTERFACES)
+ {
+ unifi_error(priv, "%s: MA-PACKET confirm with bad interfaceTag %d\n", __FUNCTION__, interfaceTag);
+ func_exit();
+ return;
+ }
+#ifdef CSR_SUPPORT_SME
+ if(interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_AP ||
+ interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_P2PGO) {
+
+ uf_process_ma_pkt_cfm_for_ap(priv,interfaceTag,pkt_cfm);
+ } else if (interfacePriv->m4_sent && (pkt_cfm->HostTag == interfacePriv->m4_hostTag)) {
+ /* Check if this is a confirm for EAPOL M4 frame and we need to send transmistted ind*/
+ CsrResult result = pkt_cfm->TransmissionStatus == CSR_TX_SUCCESSFUL?CSR_RESULT_SUCCESS:CSR_RESULT_FAILURE;
+ CsrWifiMacAddress peerMacAddress;
+ memcpy(peerMacAddress.a, interfacePriv->m4_signal.u.MaPacketRequest.Ra.x, ETH_ALEN);
+
+ unifi_trace(priv, UDBG1, "%s: Sending M4 Transmit CFM\n", __FUNCTION__);
+ CsrWifiRouterCtrlM4TransmittedIndSend(priv->CSR_WIFI_SME_IFACEQUEUE, 0,
+ interfaceTag,
+ peerMacAddress,
+ result);
+ interfacePriv->m4_sent = FALSE;
+ interfacePriv->m4_hostTag = 0xffffffff;
+ }
+#endif
+ func_exit();
+ return;
+}
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * unifi_rx
+ *
+ * Reformat a UniFi data received packet into a p80211 packet and
+ * pass it up the protocol stack.
+ *
+ * Arguments:
+ * None.
+ *
+ * Returns:
+ * None.
+ * ---------------------------------------------------------------------------
+ */
+static void process_ma_packet_ind(unifi_priv_t *priv, CSR_SIGNAL *signal, bulk_data_param_t *bulkdata)
+{
+ u16 interfaceTag;
+ bulk_data_desc_t *pData;
+ CSR_MA_PACKET_INDICATION *pkt_ind = (CSR_MA_PACKET_INDICATION*)&signal->u.MaPacketIndication;
+ struct sk_buff *skb;
+ u16 frameControl;
+ netInterface_priv_t *interfacePriv;
+ u8 da[ETH_ALEN], sa[ETH_ALEN];
+ u8 *bssid = NULL, *ba_addr = NULL;
+ u8 toDs, fromDs, frameType;
+ u8 i =0;
+
+#ifdef CSR_SUPPORT_SME
+ u8 dataFrameType = 0;
+ u8 powerSaveChanged = FALSE;
+ u8 pmBit = 0;
+ CsrWifiRouterCtrlStaInfo_t *srcStaInfo = NULL;
+ u16 qosControl;
+
+#endif
+
+ func_enter();
+
+ interfaceTag = (pkt_ind->VirtualInterfaceIdentifier & 0xff);
+ interfacePriv = priv->interfacePriv[interfaceTag];
+
+
+ /* Sanity check that the VIF refers to a sensible interface */
+ if (interfaceTag >= CSR_WIFI_NUM_INTERFACES)
+ {
+ unifi_error(priv, "%s: MA-PACKET indication with bad interfaceTag %d\n", __FUNCTION__, interfaceTag);
+ unifi_net_data_free(priv,&bulkdata->d[0]);
+ func_exit();
+ return;
+ }
+
+ /* Sanity check that the VIF refers to an allocated netdev */
+ if (!interfacePriv->netdev_registered)
+ {
+ unifi_error(priv, "%s: MA-PACKET indication with unallocated interfaceTag %d\n", __FUNCTION__, interfaceTag);
+ unifi_net_data_free(priv, &bulkdata->d[0]);
+ func_exit();
+ return;
+ }
+
+ if (bulkdata->d[0].data_length == 0) {
+ unifi_warning(priv, "%s: MA-PACKET indication with zero bulk data\n", __FUNCTION__);
+ unifi_net_data_free(priv,&bulkdata->d[0]);
+ func_exit();
+ return;
+ }
+ /* For monitor mode we need to pass this indication to the registered application
+ handle this seperately*/
+ /* MIC failure is already taken care of so no need to send the PDUs which are not successfully received in non-monitor mode*/
+ if(pkt_ind->ReceptionStatus != CSR_RX_SUCCESS)
+ {
+ unifi_warning(priv, "%s: MA-PACKET indication with status = %d\n",__FUNCTION__, pkt_ind->ReceptionStatus);
+ unifi_net_data_free(priv,&bulkdata->d[0]);
+ func_exit();
+ return;
+ }
+
+
+ skb = (struct sk_buff*)bulkdata->d[0].os_net_buf_ptr;
+ skb->len = bulkdata->d[0].data_length;
+
+ /* Point to the addresses */
+ toDs = (skb->data[1] & 0x01) ? 1 : 0;
+ fromDs = (skb->data[1] & 0x02) ? 1 : 0;
+
+ memcpy(da,(skb->data+4+toDs*12),ETH_ALEN);/* Address1 or 3 */
+ memcpy(sa,(skb->data+10+fromDs*(6+toDs*8)),ETH_ALEN); /* Address2, 3 or 4 */
+
+ /* Find the BSSID, which will be used to match the BA session */
+ if (toDs && fromDs)
+ {
+ unifi_trace(priv, UDBG6, "4 address frame - don't try to find BSSID\n");
+ bssid = NULL;
+ }
+ else
+ {
+ bssid = (u8 *) (skb->data + 4 + 12 - (fromDs * 6) - (toDs * 12));
+ }
+
+ pData = &bulkdata->d[0];
+ frameControl = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(pData->os_data_ptr);
+ frameType = ((frameControl & 0x000C) >> 2);
+
+ unifi_trace(priv, UDBG3, "Rx Frame Type: %d sn: %d\n",frameType,
+ (le16_to_cpu(*((u16*)(bulkdata->d[0].os_data_ptr + IEEE802_11_SEQUENCE_CONTROL_OFFSET))) >> 4) & 0xfff);
+ if(frameType == IEEE802_11_FRAMETYPE_CONTROL){
+#ifdef CSR_SUPPORT_SME
+ unifi_trace(priv, UDBG6, "%s: Received Control Frame\n", __FUNCTION__);
+
+ if((frameControl & 0x00f0) == 0x00A0){
+ /* This is a PS-POLL request */
+ u8 pmBit = (frameControl & 0x1000)?0x01:0x00;
+ unifi_trace(priv, UDBG6, "%s: Received PS-POLL Frame\n", __FUNCTION__);
+
+ uf_process_ps_poll(priv,sa,da,pmBit,interfaceTag);
+ }
+ else {
+ unifi_warning(priv, "%s: Non PS-POLL control frame is received\n", __FUNCTION__);
+ }
+#endif
+ unifi_net_data_free(priv,&bulkdata->d[0]);
+ func_exit();
+ return;
+ }
+ if(frameType != IEEE802_11_FRAMETYPE_DATA) {
+ unifi_warning(priv, "%s: Non control Non Data frame is received\n",__FUNCTION__);
+ unifi_net_data_free(priv,&bulkdata->d[0]);
+ func_exit();
+ return;
+ }
+
+#ifdef CSR_SUPPORT_SME
+ if((interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_AP) ||
+ (interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_P2PGO)){
+
+ srcStaInfo = CsrWifiRouterCtrlGetStationRecordFromPeerMacAddress(priv,sa,interfaceTag);
+
+ if(srcStaInfo == NULL) {
+ CsrWifiMacAddress peerMacAddress;
+ /* Unknown data PDU */
+ memcpy(peerMacAddress.a,sa,ETH_ALEN);
+ unifi_trace(priv, UDBG1, "%s: Unexpected frame from peer = %x:%x:%x:%x:%x:%x\n", __FUNCTION__,
+ sa[0], sa[1],sa[2], sa[3], sa[4],sa[5]);
+ CsrWifiRouterCtrlUnexpectedFrameIndSend(priv->CSR_WIFI_SME_IFACEQUEUE,0,interfaceTag,peerMacAddress);
+ unifi_net_data_free(priv, &bulkdata->d[0]);
+ func_exit();
+ return;
+ }
+
+ /*
+ verify power management bit here so as to ensure host and unifi are always
+ in sync with power management status of peer.
+
+ If we do it later, it may so happen we have stored the frame in BA re-ordering
+ buffer and hence host and unifi are out of sync for power management status
+ */
+
+ pmBit = (frameControl & 0x1000)?0x01:0x00;
+ powerSaveChanged = uf_process_pm_bit_for_peer(priv,srcStaInfo,pmBit,interfaceTag);
+
+ /* Update station last activity time */
+ srcStaInfo->activity_flag = TRUE;
+
+ /* For Qos Frame if PM bit is toggled to indicate the change in power save state then it shall not be
+ considered as Trigger Frame. Enter only if WMM STA and peer is in Power save */
+
+ dataFrameType = ((frameControl & 0x00f0) >> 4);
+
+ if((powerSaveChanged == FALSE)&&(srcStaInfo->wmmOrQosEnabled == TRUE)&&
+ (srcStaInfo->currentPeerState == CSR_WIFI_ROUTER_CTRL_PEER_CONNECTED_POWER_SAVE)){
+
+ if((dataFrameType == QOS_DATA) || (dataFrameType == QOS_DATA_NULL)){
+
+ /*
+ * QoS control field is offset from frame control by 2 (frame control)
+ * + 2 (duration/ID) + 2 (sequence control) + 3*ETH_ALEN or 4*ETH_ALEN
+ */
+ if((frameControl & IEEE802_11_FC_TO_DS_MASK) && (frameControl & IEEE802_11_FC_FROM_DS_MASK)){
+ qosControl= CSR_GET_UINT16_FROM_LITTLE_ENDIAN(pData->os_data_ptr + 30);
+ }
+ else{
+ qosControl = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(pData->os_data_ptr + 24);
+ }
+ unifi_trace(priv, UDBG5, "%s: Check if U-APSD operations are triggered for qosControl: 0x%x\n",__FUNCTION__,qosControl);
+ uf_process_wmm_deliver_ac_uapsd(priv,srcStaInfo,qosControl,interfaceTag);
+ }
+ }
+ }
+
+#endif
+
+ if( ((frameControl & 0x00f0) >> 4) == QOS_DATA) {
+ u8 *qos_control_ptr = (u8*)bulkdata->d[0].os_data_ptr + (((frameControl & IEEE802_11_FC_TO_DS_MASK) && (frameControl & IEEE802_11_FC_FROM_DS_MASK))?30: 24);
+ int tID = *qos_control_ptr & IEEE802_11_QC_TID_MASK; /* using ls octet of qos control */
+ ba_session_rx_struct *ba_session;
+ u8 ba_session_idx = 0;
+ /* Get the BA originator address */
+ if(interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_AP ||
+ interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_P2PGO){
+ ba_addr = sa;
+ }else{
+ ba_addr = bssid;
+ }
+
+ down(&priv->ba_mutex);
+ for (ba_session_idx=0; ba_session_idx < MAX_SUPPORTED_BA_SESSIONS_RX; ba_session_idx++){
+ ba_session = interfacePriv->ba_session_rx[ba_session_idx];
+ if (ba_session){
+ unifi_trace(priv, UDBG6, "found ba_session=0x%x ba_session_idx=%d", ba_session, ba_session_idx);
+ if ((!memcmp(ba_session->macAddress.a, ba_addr, ETH_ALEN)) && (ba_session->tID == tID)){
+ frame_desc_struct frame_desc;
+ frame_desc.bulkdata = *bulkdata;
+ frame_desc.signal = *signal;
+ frame_desc.sn = (le16_to_cpu(*((u16*)(bulkdata->d[0].os_data_ptr + IEEE802_11_SEQUENCE_CONTROL_OFFSET))) >> 4) & 0xfff;
+ frame_desc.active = TRUE;
+ unifi_trace(priv, UDBG6, "%s: calling process_ba_frame (session=%d)\n", __FUNCTION__, ba_session_idx);
+ process_ba_frame(priv, interfacePriv, ba_session, &frame_desc);
+ up(&priv->ba_mutex);
+ process_ba_complete(priv, interfacePriv);
+ break;
+ }
+ }
+ }
+ if (ba_session_idx == MAX_SUPPORTED_BA_SESSIONS_RX){
+ up(&priv->ba_mutex);
+ unifi_trace(priv, UDBG6, "%s: calling process_amsdu()", __FUNCTION__);
+ process_amsdu(priv, signal, bulkdata);
+ }
+ } else {
+ unifi_trace(priv, UDBG6, "calling unifi_rx()");
+ unifi_rx(priv, signal, bulkdata);
+ }
+
+ /* check if the frames in reorder buffer has aged, the check
+ * is done after receive processing so that if the missing frame
+ * has arrived in this receive process, then it is handled cleanly.
+ *
+ * And also this code here takes care that timeout check is made for all
+ * the receive indications
+ */
+ down(&priv->ba_mutex);
+ for (i=0; i < MAX_SUPPORTED_BA_SESSIONS_RX; i++){
+ ba_session_rx_struct *ba_session;
+ ba_session = interfacePriv->ba_session_rx[i];
+ if (ba_session){
+ check_ba_frame_age_timeout(priv, interfacePriv, ba_session);
+ }
+ }
+ up(&priv->ba_mutex);
+ process_ba_complete(priv, interfacePriv);
+
+ func_exit();
+}
+/*
+ * ---------------------------------------------------------------------------
+ * uf_set_multicast_list
+ *
+ * This function is called by the higher level stack to set
+ * a list of multicast rx addresses.
+ *
+ * Arguments:
+ * dev Network Device pointer.
+ *
+ * Returns:
+ * None.
+ *
+ * Notes:
+ * ---------------------------------------------------------------------------
+ */
+
+static void
+uf_set_multicast_list(struct net_device *dev)
+{
+ netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev);
+ unifi_priv_t *priv = interfacePriv->privPtr;
+
+#ifdef CSR_NATIVE_LINUX
+ unifi_trace(priv, UDBG3, "uf_set_multicast_list unsupported\n");
+ return;
+#else
+
+ u8 *mc_list = interfacePriv->mc_list;
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,34)
+ struct netdev_hw_addr *mc_addr;
+ int mc_addr_count;
+#else
+ struct dev_mc_list *p; /* Pointer to the addresses structure. */
+ int i;
+#endif
+
+ if (priv->init_progress != UNIFI_INIT_COMPLETED) {
+ return;
+ }
+
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,34)
+ mc_addr_count = netdev_mc_count(dev);
+
+ unifi_trace(priv, UDBG3,
+ "uf_set_multicast_list (count=%d)\n", mc_addr_count);
+
+
+ /* Not enough space? */
+ if (mc_addr_count > UNIFI_MAX_MULTICAST_ADDRESSES) {
+ return;
+ }
+
+ /* Store the list to be processed by the work item. */
+ interfacePriv->mc_list_count = mc_addr_count;
+ netdev_hw_addr_list_for_each(mc_addr, &dev->mc) {
+ memcpy(mc_list, mc_addr->addr, ETH_ALEN);
+ mc_list += ETH_ALEN;
+ }
+
+#else
+ unifi_trace(priv, UDBG3,
+ "uf_set_multicast_list (count=%d)\n", dev->mc_count);
+
+ /* Not enough space? */
+ if (dev->mc_count > UNIFI_MAX_MULTICAST_ADDRESSES) {
+ return;
+ }
+
+ /* Store the list to be processed by the work item. */
+ interfacePriv->mc_list_count = dev->mc_count;
+ p = dev->mc_list;
+ for (i = 0; i < dev->mc_count; i++) {
+ memcpy(mc_list, p->dmi_addr, ETH_ALEN);
+ p = p->next;
+ mc_list += ETH_ALEN;
+ }
+#endif
+
+ /* Send a message to the workqueue */
+ queue_work(priv->unifi_workqueue, &priv->multicast_list_task);
+#endif
+
+} /* uf_set_multicast_list() */
+
+/*
+ * ---------------------------------------------------------------------------
+ * netdev_mlme_event_handler
+ *
+ * Callback function to be used as the udi_event_callback when registering
+ * as a netdev client.
+ * To use it, a client specifies this function as the udi_event_callback
+ * to ul_register_client(). The signal dispatcher in
+ * unifi_receive_event() will call this function to deliver a signal.
+ *
+ * Arguments:
+ * pcli Pointer to the client instance.
+ * signal Pointer to the received signal.
+ * signal_len Size of the signal structure in bytes.
+ * bulkdata Pointer to structure containing any associated bulk data.
+ * dir Direction of the signal. Zero means from host,
+ * non-zero means to host.
+ *
+ * Returns:
+ * None.
+ * ---------------------------------------------------------------------------
+ */
+static void
+netdev_mlme_event_handler(ul_client_t *pcli, const u8 *sig_packed, int sig_len,
+ const bulk_data_param_t *bulkdata_o, int dir)
+{
+ CSR_SIGNAL signal;
+ unifi_priv_t *priv = uf_find_instance(pcli->instance);
+ int id, r;
+ bulk_data_param_t bulkdata;
+
+ func_enter();
+
+ /* Just a sanity check */
+ if (sig_packed == NULL) {
+ return;
+ }
+
+ /*
+ * This copy is to silence a compiler warning about discarding the
+ * const qualifier.
+ */
+ bulkdata = *bulkdata_o;
+
+ /* Get the unpacked signal */
+ r = read_unpack_signal(sig_packed, &signal);
+ if (r) {
+ /*
+ * The CSR_MLME_CONNECTED_INDICATION_ID has a receiverID=0 so will
+ * fall through this case. It is safe to ignore this signal.
+ */
+ unifi_trace(priv, UDBG1,
+ "Netdev - Received unknown signal 0x%.4X.\n",
+ CSR_GET_UINT16_FROM_LITTLE_ENDIAN(sig_packed));
+ return;
+ }
+
+ id = signal.SignalPrimitiveHeader.SignalId;
+ unifi_trace(priv, UDBG3, "Netdev - Process signal 0x%.4X\n", id);
+
+ /*
+ * Take the appropriate action for the signal.
+ */
+ switch (id) {
+ case CSR_MA_PACKET_ERROR_INDICATION_ID:
+ process_ma_packet_error_ind(priv, &signal, &bulkdata);
+ break;
+ case CSR_MA_PACKET_INDICATION_ID:
+ process_ma_packet_ind(priv, &signal, &bulkdata);
+ break;
+ case CSR_MA_PACKET_CONFIRM_ID:
+ process_ma_packet_cfm(priv, &signal, &bulkdata);
+ break;
+#ifdef CSR_SUPPORT_SME
+ case CSR_MLME_SET_TIM_CONFIRM_ID:
+ /* Handle TIM confirms from FW & set the station record's TIM state appropriately,
+ * In case of failures, tries with max_retransmit limit
+ */
+ uf_handle_tim_cfm(priv, &signal.u.MlmeSetTimConfirm, signal.SignalPrimitiveHeader.ReceiverProcessId);
+ break;
+#endif
+ case CSR_DEBUG_STRING_INDICATION_ID:
+ debug_string_indication(priv, bulkdata.d[0].os_data_ptr, bulkdata.d[0].data_length);
+ break;
+
+ case CSR_DEBUG_WORD16_INDICATION_ID:
+ debug_word16_indication(priv, &signal);
+ break;
+
+ case CSR_DEBUG_GENERIC_CONFIRM_ID:
+ case CSR_DEBUG_GENERIC_INDICATION_ID:
+ debug_generic_indication(priv, &signal);
+ break;
+ default:
+ break;
+ }
+
+ func_exit();
+} /* netdev_mlme_event_handler() */
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * uf_net_get_name
+ *
+ * Retrieve the name (e.g. eth1) associated with this network device
+ *
+ * Arguments:
+ * dev Pointer to the network device.
+ * name Buffer to write name
+ * len Size of buffer in bytes
+ *
+ * Returns:
+ * None
+ *
+ * Notes:
+ * ---------------------------------------------------------------------------
+ */
+void uf_net_get_name(struct net_device *dev, char *name, int len)
+{
+ *name = '\0';
+ if (dev) {
+ strlcpy(name, dev->name, (len > IFNAMSIZ) ? IFNAMSIZ : len);
+ }
+
+} /* uf_net_get_name */
+
+
+
+
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,28)
+#ifdef CONFIG_NET_SCHED
+
+/*
+ * ---------------------------------------------------------------------------
+ * uf_install_qdisc
+ *
+ * Creates a root qdisc, registers our qdisc handlers and
+ * overrides the device's qdisc_sleeping to prevent the system
+ * from creating a new one for our network device.
+ *
+ * Arguments:
+ * dev Pointer to the network device.
+ *
+ * Returns:
+ * 0 on success, Linux error code otherwise.
+ *
+ * Notes:
+ * This function holds the qdisk lock so it needs to be called
+ * after registering the network device in uf_register_netdev().
+ * Also, the qdisc_create_dflt() API has changed in 2.6.20 to
+ * include the parentid.
+ * ---------------------------------------------------------------------------
+ */
+int uf_install_qdisc(struct net_device *dev)
+{
+ struct Qdisc *qdisc;
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27)
+ struct netdev_queue *queue0;
+#endif /* LINUX_VERSION_CODE */
+
+
+ func_enter();
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27)
+ /*
+ * check that there is no qdisc currently attached to device
+ * this ensures that we will be the root qdisc. (I can't find a better
+ * way to test this explicitly)
+ */
+ if (dev->qdisc_sleeping != &noop_qdisc) {
+ func_exit_r(-EFAULT);
+ return -EINVAL;
+ }
+#endif /* LINUX_VERSION_CODE */
+
+ qdisc = UF_QDISC_CREATE_DFLT(dev, &uf_qdisc_ops, TC_H_ROOT);
+ if (!qdisc) {
+ unifi_error(NULL, "%s: qdisc installation failed\n", dev->name);
+ func_exit_r(-EFAULT);
+ return -EFAULT;
+ }
+ unifi_trace(NULL, UDBG5, "%s: parent qdisc=0x%p\n",
+ dev->name, qdisc);
+
+ qdisc->handle = 0x80020000;
+ qdisc->flags = 0x0;
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27)
+ queue0 = netdev_get_tx_queue(dev, 0);
+ if (queue0 == NULL) {
+ unifi_error(NULL, "%s: netdev_get_tx_queue returned no queue\n",
+ dev->name);
+ func_exit_r(-EFAULT);
+ return -EFAULT;
+ }
+ queue0->qdisc = qdisc;
+ queue0->qdisc_sleeping = qdisc;
+#else
+ qdisc_lock_tree(dev);
+ list_add_tail(&qdisc->list, &dev->qdisc_list);
+ dev->qdisc_sleeping = qdisc;
+ qdisc_unlock_tree(dev);
+#endif /* LINUX_VERSION_CODE */
+
+ func_exit_r(0);
+ return 0;
+
+} /* uf_install_qdisc() */
+
+static int uf_qdiscop_enqueue(struct sk_buff *skb, struct Qdisc* qd)
+{
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27)
+ netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(qd->dev_queue->dev);
+#else
+ netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(qd->dev);
+#endif /* LINUX_VERSION_CODE */
+ unifi_priv_t *priv = interfacePriv->privPtr;
+ struct uf_sched_data *q = qdisc_priv(qd);
+ struct uf_tx_packet_data *pkt_data = (struct uf_tx_packet_data *) skb->cb;
+ struct ethhdr ehdr;
+ struct Qdisc *qdisc;
+ int r, proto;
+
+ func_enter();
+
+ memcpy(&ehdr, skb->data, ETH_HLEN);
+ proto = ntohs(ehdr.h_proto);
+
+ /* 802.1x - apply controlled/uncontrolled port rules */
+ if ((proto != ETH_P_PAE)
+#ifdef CSR_WIFI_SECURITY_WAPI_ENABLE
+ && (proto != ETH_P_WAI)
+#endif
+ ) {
+ /* queues 0 - 3 */
+ pkt_data->priority = get_packet_priority(priv, skb, &ehdr, interfacePriv);
+ pkt_data->queue = unifi_frame_priority_to_queue(pkt_data->priority);
+ } else {
+ pkt_data->queue = UNIFI_TRAFFIC_Q_EAPOL;
+ }
+
+ qdisc = q->queues[pkt_data->queue];
+ r = qdisc->enqueue(skb, qdisc);
+ if (r == NET_XMIT_SUCCESS) {
+ qd->q.qlen++;
+ qd->bstats.bytes += skb->len;
+ qd->bstats.packets++;
+ func_exit_r(NET_XMIT_SUCCESS);
+ return NET_XMIT_SUCCESS;
+ }
+
+ unifi_error(priv, "uf_qdiscop_enqueue: dropped\n");
+ qd->qstats.drops++;
+
+ func_exit_r(r);
+ return r;
+
+} /* uf_qdiscop_enqueue() */
+
+
+static int uf_qdiscop_requeue(struct sk_buff *skb, struct Qdisc* qd)
+{
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27)
+ netInterface_priv_t *interfacePriv = (netInterface_priv_t*)netdev_priv(qd->dev_queue->dev);
+#else
+ netInterface_priv_t *interfacePriv = (netInterface_priv_t*)netdev_priv(qd->dev);
+#endif /* LINUX_VERSION_CODE */
+ unifi_priv_t *priv = interfacePriv->privPtr;
+ struct uf_sched_data *q = qdisc_priv(qd);
+ struct uf_tx_packet_data *pkt_data = (struct uf_tx_packet_data *) skb->cb;
+ struct Qdisc *qdisc;
+ int r;
+
+ func_enter();
+
+ unifi_trace(priv, UDBG5, "uf_qdiscop_requeue: (q=%d), tag=%u\n",
+ pkt_data->queue, pkt_data->host_tag);
+
+ /* we recorded which queue to use earlier! */
+ qdisc = q->queues[pkt_data->queue];
+
+ if ((r = qdisc->ops->requeue(skb, qdisc)) == 0) {
+ qd->q.qlen++;
+ func_exit_r(0);
+ return 0;
+ }
+
+ unifi_error(priv, "uf_qdiscop_requeue: dropped\n");
+ qd->qstats.drops++;
+
+ func_exit_r(r);
+ return r;
+} /* uf_qdiscop_requeue() */
+
+static struct sk_buff *uf_qdiscop_dequeue(struct Qdisc* qd)
+{
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27)
+ netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(qd->dev_queue->dev);
+#else
+ netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(qd->dev);
+#endif /* LINUX_VERSION_CODE */
+ unifi_priv_t *priv = interfacePriv->privPtr;
+ struct uf_sched_data *q = qdisc_priv(qd);
+ struct sk_buff *skb;
+ struct Qdisc *qdisc;
+ int queue, i;
+ struct ethhdr ehdr;
+ struct uf_tx_packet_data *pkt_data;
+ CsrWifiRouterCtrlPortAction port_action;
+
+ func_enter();
+
+ /* check all the queues */
+ for (i = UNIFI_TRAFFIC_Q_MAX - 1; i >= 0; i--) {
+
+ if (i != UNIFI_TRAFFIC_Q_EAPOL) {
+ queue = priv->prev_queue;
+ if (++priv->prev_queue >= UNIFI_TRAFFIC_Q_EAPOL) {
+ priv->prev_queue = 0;
+ }
+ } else {
+ queue = i;
+ }
+
+#ifndef ALLOW_Q_PAUSE
+ /* If queue is paused, do not dequeue */
+ if (net_is_tx_q_paused(priv, queue)) {
+ unifi_trace(priv, UDBG5,
+ "uf_qdiscop_dequeue: tx queue paused (q=%d)\n", queue);
+ continue;
+ }
+#endif
+
+ qdisc = q->queues[queue];
+ skb = qdisc->dequeue(qdisc);
+ if (skb) {
+ /* A packet has been dequeued, decrease the queued packets count */
+ qd->q.qlen--;
+
+ pkt_data = (struct uf_tx_packet_data *) skb->cb;
+
+ /* Check the (un)controlled port status */
+ memcpy(&ehdr, skb->data, ETH_HLEN);
+
+ port_action = verify_port(priv
+ , (((CSR_WIFI_ROUTER_CTRL_MODE_STA == interfacePriv->interfaceMode) ||(CSR_WIFI_ROUTER_CTRL_MODE_P2PCLI == interfacePriv->interfaceMode))? interfacePriv->bssid.a: ehdr.h_dest)
+ , (UNIFI_TRAFFIC_Q_EAPOL == queue? UF_UNCONTROLLED_PORT_Q: UF_CONTROLLED_PORT_Q)
+ , interfacePriv->InterfaceTag);
+
+ /* Dequeue packet if port is open */
+ if (port_action == CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_OPEN) {
+ unifi_trace(priv, UDBG5,
+ "uf_qdiscop_dequeue: new (q=%d), tag=%u\n",
+ queue, pkt_data->host_tag);
+
+ func_exit();
+ return skb;
+ }
+
+ /* Discard or block the packet if necessary */
+ if (port_action == CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_CLOSED_DISCARD) {
+ unifi_trace(priv, UDBG5,
+ "uf_qdiscop_dequeue: drop (q=%d), tag=%u\n",
+ queue, pkt_data->host_tag);
+ kfree_skb(skb);
+ break;
+ }
+
+ /* We can not send the packet now, put it back to the queue */
+ if (qdisc->ops->requeue(skb, qdisc) != 0) {
+ unifi_error(priv,
+ "uf_qdiscop_dequeue: requeue (q=%d) failed, tag=%u, drop it\n",
+ queue, pkt_data->host_tag);
+
+ /* Requeue failed, drop the packet */
+ kfree_skb(skb);
+ break;
+ }
+ /* We requeued the packet, increase the queued packets count */
+ qd->q.qlen++;
+
+ unifi_trace(priv, UDBG5,
+ "uf_qdiscop_dequeue: skip (q=%d), tag=%u\n",
+ queue, pkt_data->host_tag);
+ }
+ }
+
+ func_exit();
+ return NULL;
+} /* uf_qdiscop_dequeue() */
+
+
+static void uf_qdiscop_reset(struct Qdisc* qd)
+{
+ struct uf_sched_data *q = qdisc_priv(qd);
+ int queue;
+ func_enter();
+
+ for (queue = 0; queue < UNIFI_TRAFFIC_Q_MAX; queue++) {
+ qdisc_reset(q->queues[queue]);
+ }
+ qd->q.qlen = 0;
+
+ func_exit();
+} /* uf_qdiscop_reset() */
+
+
+static void uf_qdiscop_destroy(struct Qdisc* qd)
+{
+ struct uf_sched_data *q = qdisc_priv(qd);
+ int queue;
+
+ func_enter();
+
+ for (queue=0; queue < UNIFI_TRAFFIC_Q_MAX; queue++) {
+ qdisc_destroy(q->queues[queue]);
+ q->queues[queue] = &noop_qdisc;
+ }
+
+ func_exit();
+} /* uf_qdiscop_destroy() */
+
+
+/* called whenever parameters are updated on existing qdisc */
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,25)
+static int uf_qdiscop_tune(struct Qdisc *qd, struct nlattr *opt)
+#else
+static int uf_qdiscop_tune(struct Qdisc *qd, struct rtattr *opt)
+#endif
+{
+ func_enter();
+ func_exit();
+ return 0;
+} /* uf_qdiscop_tune() */
+
+
+/* called during initial creation of qdisc on device */
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,25)
+static int uf_qdiscop_init(struct Qdisc *qd, struct nlattr *opt)
+#else
+static int uf_qdiscop_init(struct Qdisc *qd, struct rtattr *opt)
+#endif
+{
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27)
+ struct net_device *dev = qd->dev_queue->dev;
+#else
+ struct net_device *dev = qd->dev;
+#endif /* LINUX_VERSION_CODE */
+ netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev);
+ unifi_priv_t *priv = interfacePriv->privPtr;
+ struct uf_sched_data *q = qdisc_priv(qd);
+ int err = 0, i;
+
+ func_enter();
+
+ /* make sure we do not mess with the ingress qdisc */
+ if (qd->flags & TCQ_F_INGRESS) {
+ func_exit();
+ return -EINVAL;
+ }
+
+ /* if options were passed in, set them */
+ if (opt) {
+ err = uf_qdiscop_tune(qd, opt);
+ }
+
+ /* create child queues */
+ for (i = 0; i < UNIFI_TRAFFIC_Q_MAX; i++) {
+ q->queues[i] = UF_QDISC_CREATE_DFLT(dev, &pfifo_qdisc_ops,
+ qd->handle);
+ if (!q->queues[i]) {
+ q->queues[i] = &noop_qdisc;
+ unifi_error(priv, "%s child qdisc %i creation failed\n");
+ }
+
+ unifi_trace(priv, UDBG5, "%s: child qdisc=0x%p\n",
+ dev->name, q->queues[i]);
+ }
+
+ func_exit_r(err);
+ return err;
+} /* uf_qdiscop_init() */
+
+
+static int uf_qdiscop_dump(struct Qdisc *qd, struct sk_buff *skb)
+{
+ func_enter();
+ func_exit_r(skb->len);
+ return skb->len;
+} /* uf_qdiscop_dump() */
+
+#endif /* CONFIG_NET_SCHED */
+#endif /* LINUX_VERSION_CODE */
+
+#ifdef CSR_SUPPORT_WEXT
+
+/*
+ * ---------------------------------------------------------------------------
+ * uf_netdev_event
+ *
+ * Callback function to handle netdev state changes
+ *
+ * Arguments:
+ * notif Pointer to a notifier_block.
+ * event Event prompting notification
+ * ptr net_device pointer
+ *
+ * Returns:
+ * None
+ *
+ * Notes:
+ * The event handler is global, and may occur on non-UniFi netdevs.
+ * ---------------------------------------------------------------------------
+ */
+static int
+uf_netdev_event(struct notifier_block *notif, unsigned long event, void* ptr) {
+ struct net_device *netdev = ptr;
+ netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(netdev);
+ unifi_priv_t *priv = NULL;
+ static const CsrWifiMacAddress broadcast_address = {{0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}};
+
+ /* Check that the event is for a UniFi netdev. If it's not, the netdev_priv
+ * structure is not safe to use.
+ */
+ if (uf_find_netdev_priv(interfacePriv) == -1) {
+ unifi_trace(NULL, UDBG1, "uf_netdev_event: ignore e=%d, ptr=%p, priv=%p %s\n",
+ event, ptr, interfacePriv, netdev->name);
+ return 0;
+ }
+
+ switch(event) {
+ case NETDEV_CHANGE:
+ priv = interfacePriv->privPtr;
+ unifi_trace(priv, UDBG1, "NETDEV_CHANGE: %p %s %s waiting for it\n",
+ ptr,
+ netdev->name,
+ interfacePriv->wait_netdev_change ? "" : "not");
+
+ if (interfacePriv->wait_netdev_change) {
+ UF_NETIF_TX_WAKE_ALL_QUEUES(priv->netdev[interfacePriv->InterfaceTag]);
+ interfacePriv->connected = UnifiConnected;
+ interfacePriv->wait_netdev_change = FALSE;
+ /* Note: passing the broadcast address here will allow anyone to attempt to join our adhoc network */
+ uf_process_rx_pending_queue(priv, UF_UNCONTROLLED_PORT_Q, broadcast_address, 1,interfacePriv->InterfaceTag);
+ uf_process_rx_pending_queue(priv, UF_CONTROLLED_PORT_Q, broadcast_address, 1,interfacePriv->InterfaceTag);
+ }
+ break;
+
+ default:
+ break;
+ }
+ return 0;
+}
+
+static struct notifier_block uf_netdev_notifier = {
+ .notifier_call = uf_netdev_event,
+};
+#endif /* CSR_SUPPORT_WEXT */
+
+
+static void
+ process_amsdu(unifi_priv_t *priv, CSR_SIGNAL *signal, bulk_data_param_t *bulkdata)
+{
+ u32 offset;
+ u32 length = bulkdata->d[0].data_length;
+ u32 subframe_length, subframe_body_length, dot11_hdr_size;
+ u8 *ptr;
+ bulk_data_param_t subframe_bulkdata;
+ u8 *dot11_hdr_ptr = (u8*)bulkdata->d[0].os_data_ptr;
+ CsrResult csrResult;
+ u16 frameControl;
+ u8 *qos_control_ptr;
+
+ frameControl = le16_to_cpu(*((u16*)dot11_hdr_ptr));
+ qos_control_ptr = dot11_hdr_ptr + (((frameControl & IEEE802_11_FC_TO_DS_MASK) && (frameControl & IEEE802_11_FC_FROM_DS_MASK))?30: 24);
+ if(!(*qos_control_ptr & IEEE802_11_QC_A_MSDU_PRESENT)) {
+ unifi_trace(priv, UDBG6, "%s: calling unifi_rx()", __FUNCTION__);
+ unifi_rx(priv, signal, bulkdata);
+ return;
+ }
+ *qos_control_ptr &= ~(IEEE802_11_QC_A_MSDU_PRESENT);
+
+ ptr = qos_control_ptr + 2;
+ offset = dot11_hdr_size = ptr - dot11_hdr_ptr;
+
+ while(length > (offset + sizeof(struct ethhdr) + sizeof(llc_snap_hdr_t))) {
+ subframe_body_length = ntohs(((struct ethhdr*)ptr)->h_proto);
+ if(subframe_body_length > IEEE802_11_MAX_DATA_LEN) {
+ unifi_error(priv, "%s: bad subframe_body_length = %d\n", __FUNCTION__, subframe_body_length);
+ break;
+ }
+ subframe_length = sizeof(struct ethhdr) + subframe_body_length;
+ memset(&subframe_bulkdata, 0, sizeof(bulk_data_param_t));
+
+ csrResult = unifi_net_data_malloc(priv, &subframe_bulkdata.d[0], dot11_hdr_size + subframe_body_length);
+
+ if (csrResult != CSR_RESULT_SUCCESS) {
+ unifi_error(priv, "%s: unifi_net_data_malloc failed\n", __FUNCTION__);
+ break;
+ }
+
+ memcpy((u8*)subframe_bulkdata.d[0].os_data_ptr, dot11_hdr_ptr, dot11_hdr_size);
+
+
+ /* When to DS=0 and from DS=0, address 3 will already have BSSID so no need to re-program */
+ if ((frameControl & IEEE802_11_FC_TO_DS_MASK) && !(frameControl & IEEE802_11_FC_FROM_DS_MASK)){
+ memcpy((u8*)subframe_bulkdata.d[0].os_data_ptr + IEEE802_11_ADDR3_OFFSET, ((struct ethhdr*)ptr)->h_dest, ETH_ALEN);
+ }
+ else if (!(frameControl & IEEE802_11_FC_TO_DS_MASK) && (frameControl & IEEE802_11_FC_FROM_DS_MASK)){
+ memcpy((u8*)subframe_bulkdata.d[0].os_data_ptr + IEEE802_11_ADDR3_OFFSET,
+ ((struct ethhdr*)ptr)->h_source,
+ ETH_ALEN);
+ }
+
+ memcpy((u8*)subframe_bulkdata.d[0].os_data_ptr + dot11_hdr_size,
+ ptr + sizeof(struct ethhdr),
+ subframe_body_length);
+ unifi_trace(priv, UDBG6, "%s: calling unifi_rx. length = %d subframe_length = %d\n", __FUNCTION__, length, subframe_length);
+ unifi_rx(priv, signal, &subframe_bulkdata);
+
+ subframe_length = (subframe_length + 3)&(~0x3);
+ ptr += subframe_length;
+ offset += subframe_length;
+ }
+ unifi_net_data_free(priv, &bulkdata->d[0]);
+}
+
+
+#define SN_TO_INDEX(__ba_session, __sn) (((__sn - __ba_session->start_sn) & 0xFFF) % __ba_session->wind_size)
+
+
+#define ADVANCE_EXPECTED_SN(__ba_session) \
+{ \
+ __ba_session->expected_sn++; \
+ __ba_session->expected_sn &= 0xFFF; \
+}
+
+#define FREE_BUFFER_SLOT(__ba_session, __index) \
+{ \
+ __ba_session->occupied_slots--; \
+ __ba_session->buffer[__index].active = FALSE; \
+ ADVANCE_EXPECTED_SN(__ba_session); \
+}
+
+static void add_frame_to_ba_complete(unifi_priv_t *priv,
+ netInterface_priv_t *interfacePriv,
+ frame_desc_struct *frame_desc)
+{
+ interfacePriv->ba_complete[interfacePriv->ba_complete_index] = *frame_desc;
+ interfacePriv->ba_complete_index++;
+}
+
+
+static void update_expected_sn(unifi_priv_t *priv,
+ netInterface_priv_t *interfacePriv,
+ ba_session_rx_struct *ba_session,
+ u16 sn)
+{
+ int i, j;
+ u16 gap;
+
+ gap = (sn - ba_session->expected_sn) & 0xFFF;
+ unifi_trace(priv, UDBG6, "%s: proccess the frames up to new_expected_sn = %d gap = %d\n", __FUNCTION__, sn, gap);
+ for(j = 0; j < gap && j < ba_session->wind_size; j++) {
+ i = SN_TO_INDEX(ba_session, ba_session->expected_sn);
+ unifi_trace(priv, UDBG6, "%s: proccess the slot index = %d\n", __FUNCTION__, i);
+ if(ba_session->buffer[i].active) {
+ add_frame_to_ba_complete(priv, interfacePriv, &ba_session->buffer[i]);
+ unifi_trace(priv, UDBG6, "%s: proccess the frame at index = %d expected_sn = %d\n", __FUNCTION__, i, ba_session->expected_sn);
+ FREE_BUFFER_SLOT(ba_session, i);
+ } else {
+ unifi_trace(priv, UDBG6, "%s: empty slot at index = %d\n", __FUNCTION__, i);
+ ADVANCE_EXPECTED_SN(ba_session);
+ }
+ }
+ ba_session->expected_sn = sn;
+}
+
+
+static void complete_ready_sequence(unifi_priv_t *priv,
+ netInterface_priv_t *interfacePriv,
+ ba_session_rx_struct *ba_session)
+{
+ int i;
+
+ i = SN_TO_INDEX(ba_session, ba_session->expected_sn);
+ while (ba_session->buffer[i].active) {
+ add_frame_to_ba_complete(priv, interfacePriv, &ba_session->buffer[i]);
+ unifi_trace(priv, UDBG6, "%s: completed stored frame(expected_sn=%d) at i = %d\n", __FUNCTION__, ba_session->expected_sn, i);
+ FREE_BUFFER_SLOT(ba_session, i);
+ i = SN_TO_INDEX(ba_session, ba_session->expected_sn);
+ }
+}
+
+
+void scroll_ba_window(unifi_priv_t *priv,
+ netInterface_priv_t *interfacePriv,
+ ba_session_rx_struct *ba_session,
+ u16 sn)
+{
+ if(((sn - ba_session->expected_sn) & 0xFFF) <= 2048) {
+ update_expected_sn(priv, interfacePriv, ba_session, sn);
+ complete_ready_sequence(priv, interfacePriv, ba_session);
+ }
+}
+
+
+static int consume_frame_or_get_buffer_index(unifi_priv_t *priv,
+ netInterface_priv_t *interfacePriv,
+ ba_session_rx_struct *ba_session,
+ u16 sn,
+ frame_desc_struct *frame_desc) {
+ int i;
+ u16 sn_temp;
+
+ if(((sn - ba_session->expected_sn) & 0xFFF) <= 2048) {
+
+ /* once we are in BA window, set the flag for BA trigger */
+ if(!ba_session->trigger_ba_after_ssn){
+ ba_session->trigger_ba_after_ssn = TRUE;
+ }
+
+ sn_temp = ba_session->expected_sn + ba_session->wind_size;
+ unifi_trace(priv, UDBG6, "%s: new frame: sn=%d\n", __FUNCTION__, sn);
+ if(!(((sn - sn_temp) & 0xFFF) > 2048)) {
+ u16 new_expected_sn;
+ unifi_trace(priv, UDBG6, "%s: frame is out of window\n", __FUNCTION__);
+ sn_temp = (sn - ba_session->wind_size) & 0xFFF;
+ new_expected_sn = (sn_temp + 1) & 0xFFF;
+ update_expected_sn(priv, interfacePriv, ba_session, new_expected_sn);
+ }
+ i = -1;
+ if (sn == ba_session->expected_sn) {
+ unifi_trace(priv, UDBG6, "%s: sn = ba_session->expected_sn = %d\n", __FUNCTION__, sn);
+ ADVANCE_EXPECTED_SN(ba_session);
+ add_frame_to_ba_complete(priv, interfacePriv, frame_desc);
+ } else {
+ i = SN_TO_INDEX(ba_session, sn);
+ unifi_trace(priv, UDBG6, "%s: sn(%d) != ba_session->expected_sn(%d), i = %d\n", __FUNCTION__, sn, ba_session->expected_sn, i);
+ if (ba_session->buffer[i].active) {
+ unifi_trace(priv, UDBG6, "%s: free frame at i = %d\n", __FUNCTION__, i);
+ i = -1;
+ unifi_net_data_free(priv, &frame_desc->bulkdata.d[0]);
+ }
+ }
+ } else {
+ i = -1;
+ if(!ba_session->trigger_ba_after_ssn){
+ unifi_trace(priv, UDBG6, "%s: frame before ssn, pass it up: sn=%d\n", __FUNCTION__, sn);
+ add_frame_to_ba_complete(priv, interfacePriv, frame_desc);
+ }else{
+ unifi_trace(priv, UDBG6, "%s: old frame, drop: sn=%d, expected_sn=%d\n", __FUNCTION__, sn, ba_session->expected_sn);
+ unifi_net_data_free(priv, &frame_desc->bulkdata.d[0]);
+ }
+ }
+ return i;
+}
+
+
+
+static void process_ba_frame(unifi_priv_t *priv,
+ netInterface_priv_t *interfacePriv,
+ ba_session_rx_struct *ba_session,
+ frame_desc_struct *frame_desc)
+{
+ int i;
+ u16 sn = frame_desc->sn;
+
+ if (ba_session->timeout) {
+ mod_timer(&ba_session->timer, (jiffies + usecs_to_jiffies((ba_session->timeout) * 1024)));
+ }
+ unifi_trace(priv, UDBG6, "%s: got frame(sn=%d)\n", __FUNCTION__, sn);
+
+ i = consume_frame_or_get_buffer_index(priv, interfacePriv, ba_session, sn, frame_desc);
+ if(i >= 0) {
+ unifi_trace(priv, UDBG6, "%s: store frame(sn=%d) at i = %d\n", __FUNCTION__, sn, i);
+ ba_session->buffer[i] = *frame_desc;
+ ba_session->buffer[i].recv_time = CsrTimeGet(NULL);
+ ba_session->occupied_slots++;
+ } else {
+ unifi_trace(priv, UDBG6, "%s: frame consumed - sn = %d\n", __FUNCTION__, sn);
+ }
+ complete_ready_sequence(priv, interfacePriv, ba_session);
+}
+
+
+static void process_ba_complete(unifi_priv_t *priv, netInterface_priv_t *interfacePriv)
+{
+ frame_desc_struct *frame_desc;
+ u8 i;
+
+ for(i = 0; i < interfacePriv->ba_complete_index; i++) {
+ frame_desc = &interfacePriv->ba_complete[i];
+ unifi_trace(priv, UDBG6, "%s: calling process_amsdu()\n", __FUNCTION__);
+ process_amsdu(priv, &frame_desc->signal, &frame_desc->bulkdata);
+ }
+ interfacePriv->ba_complete_index = 0;
+
+}
+
+
+/* Check if the frames in BA reoder buffer has aged and
+ * if so release the frames to upper processes and move
+ * the window
+ */
+static void check_ba_frame_age_timeout( unifi_priv_t *priv,
+ netInterface_priv_t *interfacePriv,
+ ba_session_rx_struct *ba_session)
+{
+ CsrTime now;
+ CsrTime age;
+ u8 i, j;
+ u16 sn_temp;
+
+ /* gap is started at 1 because we have buffered frames and
+ * hence a minimum gap of 1 exists
+ */
+ u8 gap=1;
+
+ now = CsrTimeGet(NULL);
+
+ if (ba_session->occupied_slots)
+ {
+ /* expected sequence has not arrived so start searching from next
+ * sequence number until a frame is available and determine the gap.
+ * Check if the frame available has timedout, if so advance the
+ * expected sequence number and release the frames
+ */
+ sn_temp = (ba_session->expected_sn + 1) & 0xFFF;
+
+ for(j = 0; j < ba_session->wind_size; j++)
+ {
+ i = SN_TO_INDEX(ba_session, sn_temp);
+
+ if(ba_session->buffer[i].active)
+ {
+ unifi_trace(priv, UDBG6, "check age at slot index = %d sn = %d recv_time = %u now = %u\n",
+ i,
+ ba_session->buffer[i].sn,
+ ba_session->buffer[i].recv_time,
+ now);
+
+ if (ba_session->buffer[i].recv_time > now)
+ {
+ /* timer wrap */
+ age = CsrTimeAdd((CsrTime)CsrTimeSub(CSR_SCHED_TIME_MAX, ba_session->buffer[i].recv_time), now);
+ }
+ else
+ {
+ age = (CsrTime)CsrTimeSub(now, ba_session->buffer[i].recv_time);
+ }
+
+ if (age >= CSR_WIFI_BA_MPDU_FRAME_AGE_TIMEOUT)
+ {
+ unifi_trace(priv, UDBG2, "release the frame at index = %d gap = %d expected_sn = %d sn = %d\n",
+ i,
+ gap,
+ ba_session->expected_sn,
+ ba_session->buffer[i].sn);
+
+ /* if it has timedout don't wait for missing frames, move the window */
+ while (gap--)
+ {
+ ADVANCE_EXPECTED_SN(ba_session);
+ }
+ add_frame_to_ba_complete(priv, interfacePriv, &ba_session->buffer[i]);
+ FREE_BUFFER_SLOT(ba_session, i);
+ complete_ready_sequence(priv, interfacePriv, ba_session);
+ }
+ break;
+
+ }
+ else
+ {
+ /* advance temp sequence number and frame gap */
+ sn_temp = (sn_temp + 1) & 0xFFF;
+ gap++;
+ }
+ }
+ }
+}
+
+
+static void process_ma_packet_error_ind(unifi_priv_t *priv, CSR_SIGNAL *signal, bulk_data_param_t *bulkdata)
+{
+ u16 interfaceTag;
+ const CSR_MA_PACKET_ERROR_INDICATION *pkt_err_ind = &signal->u.MaPacketErrorIndication;
+ netInterface_priv_t *interfacePriv;
+ ba_session_rx_struct *ba_session;
+ u8 ba_session_idx = 0;
+ CSR_PRIORITY UserPriority;
+ CSR_SEQUENCE_NUMBER sn;
+
+ func_enter();
+
+ interfaceTag = (pkt_err_ind->VirtualInterfaceIdentifier & 0xff);
+
+
+ /* Sanity check that the VIF refers to a sensible interface */
+ if (interfaceTag >= CSR_WIFI_NUM_INTERFACES)
+ {
+ unifi_error(priv, "%s: MaPacketErrorIndication indication with bad interfaceTag %d\n", __FUNCTION__, interfaceTag);
+ func_exit();
+ return;
+ }
+
+ interfacePriv = priv->interfacePriv[interfaceTag];
+ UserPriority = pkt_err_ind->UserPriority;
+ if(UserPriority > 15) {
+ unifi_error(priv, "%s: MaPacketErrorIndication indication with bad UserPriority=%d\n", __FUNCTION__, UserPriority);
+ func_exit();
+ }
+ sn = pkt_err_ind->SequenceNumber;
+
+ down(&priv->ba_mutex);
+ /* To find the right ba_session loop through the BA sessions, compare MAC address and tID */
+ for (ba_session_idx=0; ba_session_idx < MAX_SUPPORTED_BA_SESSIONS_RX; ba_session_idx++){
+ ba_session = interfacePriv->ba_session_rx[ba_session_idx];
+ if (ba_session){
+ if ((!memcmp(ba_session->macAddress.a, pkt_err_ind->PeerQstaAddress.x, ETH_ALEN)) && (ba_session->tID == UserPriority)){
+ if (ba_session->timeout) {
+ mod_timer(&ba_session->timer, (jiffies + usecs_to_jiffies((ba_session->timeout) * 1024)));
+ }
+ scroll_ba_window(priv, interfacePriv, ba_session, sn);
+ break;
+ }
+ }
+ }
+
+ up(&priv->ba_mutex);
+ process_ba_complete(priv, interfacePriv);
+ func_exit();
+}
+
+
diff --git a/drivers/staging/csr/os.c b/drivers/staging/csr/os.c
new file mode 100644
index 000000000000..35dc9087d79f
--- /dev/null
+++ b/drivers/staging/csr/os.c
@@ -0,0 +1,483 @@
+/*
+ * ---------------------------------------------------------------------------
+ * FILE: os.c
+ *
+ * PURPOSE:
+ * Routines to fulfil the OS-abstraction for the HIP lib.
+ * It is part of the porting exercise.
+ *
+ * Copyright (C) 2005-2009 by Cambridge Silicon Radio Ltd.
+ *
+ * Refer to LICENSE.txt included with this source code for details on
+ * the license terms.
+ *
+ * ---------------------------------------------------------------------------
+ */
+
+/**
+ * The HIP lib OS abstraction consists of the implementation
+ * of the functions in this file. It is part of the porting exercise.
+ */
+
+#include "unifi_priv.h"
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * unifi_net_data_malloc
+ *
+ * Allocate an OS specific net data buffer of "size" bytes.
+ * The bulk_data_slot.os_data_ptr must be initialised to point
+ * to the buffer allocated. The bulk_data_slot.length must be
+ * initialised to the requested size, zero otherwise.
+ * The bulk_data_slot.os_net_buf_ptr can be initialised to
+ * an OS specific pointer to be used in the unifi_net_data_free().
+ *
+ *
+ * Arguments:
+ * ospriv Pointer to device private context struct.
+ * bulk_data_slot Pointer to the bulk data structure to initialise.
+ * size Size of the buffer to be allocated.
+ *
+ * Returns:
+ * CSR_RESULT_SUCCESS on success, CSR_RESULT_FAILURE otherwise.
+ * ---------------------------------------------------------------------------
+ */
+CsrResult
+unifi_net_data_malloc(void *ospriv, bulk_data_desc_t *bulk_data_slot, unsigned int size)
+{
+ struct sk_buff *skb;
+ unifi_priv_t *priv = (unifi_priv_t*)ospriv;
+ int rounded_length;
+
+ if (priv->card_info.sdio_block_size == 0) {
+ unifi_error(priv, "unifi_net_data_malloc: Invalid SDIO block size\n");
+ return CSR_RESULT_FAILURE;
+ }
+
+ rounded_length = (size + priv->card_info.sdio_block_size - 1) & ~(priv->card_info.sdio_block_size - 1);
+
+ /*
+ * (ETH_HLEN + 2) bytes tailroom for header manipulation
+ * CSR_WIFI_ALIGN_BYTES bytes headroom for alignment manipulation
+ */
+ skb = dev_alloc_skb(rounded_length + 2 + ETH_HLEN + CSR_WIFI_ALIGN_BYTES);
+ if (! skb) {
+ unifi_error(ospriv, "alloc_skb failed.\n");
+ bulk_data_slot->os_net_buf_ptr = NULL;
+ bulk_data_slot->net_buf_length = 0;
+ bulk_data_slot->os_data_ptr = NULL;
+ bulk_data_slot->data_length = 0;
+ return CSR_RESULT_FAILURE;
+ }
+
+ bulk_data_slot->os_net_buf_ptr = (const unsigned char*)skb;
+ bulk_data_slot->net_buf_length = rounded_length + 2 + ETH_HLEN + CSR_WIFI_ALIGN_BYTES;
+ bulk_data_slot->os_data_ptr = (const void*)skb->data;
+ bulk_data_slot->data_length = size;
+
+ return CSR_RESULT_SUCCESS;
+} /* unifi_net_data_malloc() */
+
+/*
+ * ---------------------------------------------------------------------------
+ * unifi_net_data_free
+ *
+ * Free an OS specific net data buffer.
+ * The bulk_data_slot.length must be initialised to 0.
+ *
+ *
+ * Arguments:
+ * ospriv Pointer to device private context struct.
+ * bulk_data_slot Pointer to the bulk data structure that
+ * holds the data to be freed.
+ *
+ * Returns:
+ * None.
+ * ---------------------------------------------------------------------------
+ */
+void
+unifi_net_data_free(void *ospriv, bulk_data_desc_t *bulk_data_slot)
+{
+ struct sk_buff *skb;
+ CSR_UNUSED(ospriv);
+
+ skb = (struct sk_buff *)bulk_data_slot->os_net_buf_ptr;
+ dev_kfree_skb(skb);
+
+ bulk_data_slot->net_buf_length = 0;
+ bulk_data_slot->data_length = 0;
+ bulk_data_slot->os_data_ptr = bulk_data_slot->os_net_buf_ptr = NULL;
+
+} /* unifi_net_data_free() */
+
+
+/*
+* ---------------------------------------------------------------------------
+* unifi_net_dma_align
+*
+* DMA align an OS specific net data buffer.
+* The buffer must be empty.
+*
+*
+* Arguments:
+* ospriv Pointer to device private context struct.
+* bulk_data_slot Pointer to the bulk data structure that
+* holds the data to be aligned.
+*
+* Returns:
+* None.
+* ---------------------------------------------------------------------------
+*/
+CsrResult
+unifi_net_dma_align(void *ospriv, bulk_data_desc_t *bulk_data_slot)
+{
+ struct sk_buff *skb;
+ unsigned long buf_address;
+ int offset;
+ unifi_priv_t *priv = (unifi_priv_t*)ospriv;
+
+ if ((bulk_data_slot == NULL) || (CSR_WIFI_ALIGN_BYTES == 0)) {
+ return CSR_RESULT_SUCCESS;
+ }
+
+ if ((bulk_data_slot->os_data_ptr == NULL) || (bulk_data_slot->data_length == 0)) {
+ return CSR_RESULT_SUCCESS;
+ }
+
+ buf_address = (unsigned long)(bulk_data_slot->os_data_ptr) & (CSR_WIFI_ALIGN_BYTES - 1);
+
+ unifi_trace(priv, UDBG5,
+ "unifi_net_dma_align: Allign buffer (0x%p) by %d bytes\n",
+ bulk_data_slot->os_data_ptr, buf_address);
+
+ offset = CSR_WIFI_ALIGN_BYTES - buf_address;
+ if (offset < 0) {
+ unifi_error(priv, "unifi_net_dma_align: Failed (offset=%d)\n", offset);
+ return CSR_RESULT_FAILURE;
+ }
+
+ skb = (struct sk_buff*)(bulk_data_slot->os_net_buf_ptr);
+ skb_reserve(skb, offset);
+ bulk_data_slot->os_net_buf_ptr = (const unsigned char*)skb;
+ bulk_data_slot->os_data_ptr = (const void*)(skb->data);
+
+ return CSR_RESULT_SUCCESS;
+
+} /* unifi_net_dma_align() */
+
+#ifdef ANDROID_TIMESTAMP
+static volatile unsigned int printk_cpu = UINT_MAX;
+char tbuf[30];
+
+char* print_time(void )
+{
+ unsigned long long t;
+ unsigned long nanosec_rem;
+
+ t = cpu_clock(printk_cpu);
+ nanosec_rem = do_div(t, 1000000000);
+ sprintf(tbuf, "[%5lu.%06lu] ",
+ (unsigned long) t,
+ nanosec_rem / 1000);
+
+ return tbuf;
+}
+#endif
+
+
+/* Module parameters */
+extern int unifi_debug;
+
+#ifdef UNIFI_DEBUG
+#define DEBUG_BUFFER_SIZE 120
+
+#define FORMAT_TRACE(_s, _len, _args, _fmt) \
+ do { \
+ va_start(_args, _fmt); \
+ _len += vsnprintf(&(_s)[_len], \
+ (DEBUG_BUFFER_SIZE - _len), \
+ _fmt, _args); \
+ va_end(_args); \
+ if (_len >= DEBUG_BUFFER_SIZE) { \
+ (_s)[DEBUG_BUFFER_SIZE - 2] = '\n'; \
+ (_s)[DEBUG_BUFFER_SIZE - 1] = 0; \
+ } \
+ } while (0)
+
+void
+unifi_error(void* ospriv, const char *fmt, ...)
+{
+ unifi_priv_t *priv = (unifi_priv_t*) ospriv;
+ char s[DEBUG_BUFFER_SIZE];
+ va_list args;
+ unsigned int len;
+#ifdef ANDROID_TIMESTAMP
+ if (priv != NULL) {
+ len = snprintf(s, DEBUG_BUFFER_SIZE, KERN_ERR "%s unifi%d: ", print_time(), priv->instance);
+ } else {
+ len = snprintf(s, DEBUG_BUFFER_SIZE, KERN_ERR "%s unifi: ", print_time());
+ }
+#else
+ if (priv != NULL) {
+ len = snprintf(s, DEBUG_BUFFER_SIZE, KERN_ERR "unifi%d: ", priv->instance);
+ } else {
+ len = snprintf(s, DEBUG_BUFFER_SIZE, KERN_ERR "unifi: ");
+ }
+#endif /* ANDROID_TIMESTAMP */
+ FORMAT_TRACE(s, len, args, fmt);
+
+ printk("%s", s);
+}
+
+void
+unifi_warning(void* ospriv, const char *fmt, ...)
+{
+ unifi_priv_t *priv = (unifi_priv_t*) ospriv;
+ char s[DEBUG_BUFFER_SIZE];
+ va_list args;
+ unsigned int len;
+
+#ifdef ANDROID_TIMESTAMP
+ if (priv != NULL) {
+ len = snprintf(s, DEBUG_BUFFER_SIZE, KERN_WARNING "%s unifi%d: ", print_time(), priv->instance);
+ } else {
+ len = snprintf(s, DEBUG_BUFFER_SIZE, KERN_WARNING "%s unifi: ", print_time());
+ }
+#else
+ if (priv != NULL) {
+ len = snprintf(s, DEBUG_BUFFER_SIZE, KERN_WARNING "unifi%d: ", priv->instance);
+ } else {
+ len = snprintf(s, DEBUG_BUFFER_SIZE, KERN_WARNING "unifi: ");
+ }
+#endif /* ANDROID_TIMESTAMP */
+
+ FORMAT_TRACE(s, len, args, fmt);
+
+ printk("%s", s);
+}
+
+
+void
+unifi_notice(void* ospriv, const char *fmt, ...)
+{
+ unifi_priv_t *priv = (unifi_priv_t*) ospriv;
+ char s[DEBUG_BUFFER_SIZE];
+ va_list args;
+ unsigned int len;
+
+#ifdef ANDROID_TIMESTAMP
+ if (priv != NULL) {
+ len = snprintf(s, DEBUG_BUFFER_SIZE, KERN_NOTICE "%s unifi%d: ", print_time(), priv->instance);
+ } else {
+ len = snprintf(s, DEBUG_BUFFER_SIZE, KERN_NOTICE "%s unifi: ", print_time());
+ }
+#else
+ if (priv != NULL) {
+ len = snprintf(s, DEBUG_BUFFER_SIZE, KERN_NOTICE "unifi%d: ", priv->instance);
+ } else {
+ len = snprintf(s, DEBUG_BUFFER_SIZE, KERN_NOTICE "unifi: ");
+ }
+#endif /* ANDROID_TIMESTAMP */
+
+ FORMAT_TRACE(s, len, args, fmt);
+
+ printk("%s", s);
+}
+
+
+void
+unifi_info(void* ospriv, const char *fmt, ...)
+{
+ unifi_priv_t *priv = (unifi_priv_t*) ospriv;
+ char s[DEBUG_BUFFER_SIZE];
+ va_list args;
+ unsigned int len;
+
+#ifdef ANDROID_TIMESTAMP
+ if (priv != NULL) {
+ len = snprintf(s, DEBUG_BUFFER_SIZE, KERN_INFO "%s unifi%d: ", print_time(), priv->instance);
+ } else {
+ len = snprintf(s, DEBUG_BUFFER_SIZE, KERN_INFO "%s unifi: ", print_time());
+ }
+#else
+ if (priv != NULL) {
+ len = snprintf(s, DEBUG_BUFFER_SIZE, KERN_INFO "unifi%d: ", priv->instance);
+ } else {
+ len = snprintf(s, DEBUG_BUFFER_SIZE, KERN_INFO "unifi: ");
+ }
+#endif /* ANDROID_TIMESTAMP */
+
+ FORMAT_TRACE(s, len, args, fmt);
+
+ printk("%s", s);
+}
+
+/* debugging */
+void
+unifi_trace(void* ospriv, int level, const char *fmt, ...)
+{
+ unifi_priv_t *priv = (unifi_priv_t*) ospriv;
+ char s[DEBUG_BUFFER_SIZE];
+ va_list args;
+ unsigned int len;
+
+ if (unifi_debug >= level) {
+#ifdef ANDROID_TIMESTAMP
+ if (priv != NULL) {
+ len = snprintf(s, DEBUG_BUFFER_SIZE, KERN_ERR "%s unifi%d: ", print_time(), priv->instance);
+ } else {
+ len = snprintf(s, DEBUG_BUFFER_SIZE, KERN_ERR "%s unifi: ", print_time());
+ }
+#else
+ if (priv != NULL) {
+ len = snprintf(s, DEBUG_BUFFER_SIZE, KERN_ERR "unifi%d: ", priv->instance);
+ } else {
+ len = snprintf(s, DEBUG_BUFFER_SIZE, KERN_ERR "unifi: ");
+ }
+#endif /* ANDROID_TIMESTAMP */
+
+ FORMAT_TRACE(s, len, args, fmt);
+
+ printk("%s", s);
+ }
+}
+
+#else
+
+void
+unifi_error_nop(void* ospriv, const char *fmt, ...)
+{
+}
+
+void
+unifi_trace_nop(void* ospriv, int level, const char *fmt, ...)
+{
+}
+
+#endif /* UNIFI_DEBUG */
+
+
+/*
+ * ---------------------------------------------------------------------------
+ *
+ * Debugging support.
+ *
+ * ---------------------------------------------------------------------------
+ */
+
+#ifdef UNIFI_DEBUG
+
+/* Memory dump with level filter controlled by unifi_debug */
+void
+unifi_dump(void *ospriv, int level, const char *msg, void *mem, u16 len)
+{
+ unifi_priv_t *priv = (unifi_priv_t*) ospriv;
+
+ if (unifi_debug >= level) {
+#ifdef ANDROID_TIMESTAMP
+ if (priv != NULL) {
+ printk(KERN_ERR "%s unifi%d: --- dump: %s ---\n", print_time(), priv->instance, msg ? msg : "");
+ } else {
+ printk(KERN_ERR "%s unifi: --- dump: %s ---\n", print_time(), msg ? msg : "");
+ }
+#else
+ if (priv != NULL) {
+ printk(KERN_ERR "unifi%d: --- dump: %s ---\n", priv->instance, msg ? msg : "");
+ } else {
+ printk(KERN_ERR "unifi: --- dump: %s ---\n", msg ? msg : "");
+ }
+#endif /* ANDROID_TIMESTAMP */
+ dump(mem, len);
+
+ if (priv != NULL) {
+ printk(KERN_ERR "unifi%d: --- end of dump ---\n", priv->instance);
+ } else {
+ printk(KERN_ERR "unifi: --- end of dump ---\n");
+ }
+ }
+}
+
+/* Memory dump that appears all the time, use sparingly */
+void
+dump(void *mem, u16 len)
+{
+ int i, col = 0;
+ unsigned char *pdata = (unsigned char *)mem;
+#ifdef ANDROID_TIMESTAMP
+ printk("timestamp %s \n", print_time());
+#endif /* ANDROID_TIMESTAMP */
+ if (mem == NULL) {
+ printk("(null dump)\n");
+ return;
+ }
+ for (i = 0; i < len; i++) {
+ if (col == 0) {
+ printk("0x%02X: ", i);
+ }
+
+ printk(" %02X", pdata[i]);
+
+ if (++col == 16) {
+ printk("\n");
+ col = 0;
+ }
+ }
+ if (col) {
+ printk("\n");
+ }
+} /* dump() */
+
+
+void
+dump16(void *mem, u16 len)
+{
+ int i, col=0;
+ unsigned short *p = (unsigned short *)mem;
+#ifdef ANDROID_TIMESTAMP
+ printk("timestamp %s \n", print_time());
+#endif /* ANDROID_TIMESTAMP */
+ for (i = 0; i < len; i+=2) {
+ if (col == 0) {
+ printk("0x%02X: ", i);
+ }
+
+ printk(" %04X", *p++);
+
+ if (++col == 8) {
+ printk("\n");
+ col = 0;
+ }
+ }
+ if (col) {
+ printk("\n");
+ }
+}
+
+
+#ifdef CSR_WIFI_HIP_DEBUG_OFFLINE
+void
+dump_str(void *mem, u16 len)
+{
+ int i, col = 0;
+ unsigned char *pdata = (unsigned char *)mem;
+#ifdef ANDROID_TIMESTAMP
+ printk("timestamp %s \n", print_time());
+#endif /* ANDROID_TIMESTAMP */
+ for (i = 0; i < len; i++) {
+ printk("%c", pdata[i]);
+ }
+ if (col) {
+ printk("\n");
+ }
+
+} /* dump_str() */
+#endif /* CSR_ONLY_NOTES */
+
+
+#endif /* UNIFI_DEBUG */
+
+
+/* ---------------------------------------------------------------------------
+ * - End -
+ * ------------------------------------------------------------------------- */
diff --git a/drivers/staging/csr/putest.c b/drivers/staging/csr/putest.c
new file mode 100644
index 000000000000..5613cf0e16b0
--- /dev/null
+++ b/drivers/staging/csr/putest.c
@@ -0,0 +1,685 @@
+/*
+ * ***************************************************************************
+ * FILE: putest.c
+ *
+ * PURPOSE: putest related functions.
+ *
+ * Copyright (C) 2008-2009 by Cambridge Silicon Radio Ltd.
+ *
+ * Refer to LICENSE.txt included with this source code for details on
+ * the license terms.
+ *
+ * ***************************************************************************
+ */
+
+#include <linux/vmalloc.h>
+#include <linux/firmware.h>
+
+#include "unifi_priv.h"
+#include "csr_wifi_hip_chiphelper.h"
+
+#define UNIFI_PROC_BOTH 3
+
+
+int unifi_putest_cmd52_read(unifi_priv_t *priv, unsigned char *arg)
+{
+ struct unifi_putest_cmd52 cmd52_params;
+ u8 *arg_pos;
+ unsigned int cmd_param_size;
+ int r;
+ CsrResult csrResult;
+ unsigned char ret_buffer[32];
+ u8 *ret_buffer_pos;
+ u8 retries;
+
+ arg_pos = (u8*)(((unifi_putest_command_t*)arg) + 1);
+ if (get_user(cmd_param_size, (int*)arg_pos)) {
+ unifi_error(priv,
+ "unifi_putest_cmd52_read: Failed to get the argument\n");
+ return -EFAULT;
+ }
+
+ if (cmd_param_size != sizeof(struct unifi_putest_cmd52)) {
+ unifi_error(priv,
+ "unifi_putest_cmd52_read: cmd52 struct mismatch\n");
+ return -EINVAL;
+ }
+
+ arg_pos += sizeof(unsigned int);
+ if (copy_from_user(&cmd52_params,
+ (void*)arg_pos,
+ sizeof(struct unifi_putest_cmd52))) {
+ unifi_error(priv,
+ "unifi_putest_cmd52_read: Failed to get the cmd52 params\n");
+ return -EFAULT;
+ }
+
+ unifi_trace(priv, UDBG2, "cmd52r: func=%d addr=0x%x ",
+ cmd52_params.funcnum, cmd52_params.addr);
+
+ retries = 3;
+ CsrSdioClaim(priv->sdio);
+ do {
+ if (cmd52_params.funcnum == 0) {
+ csrResult = CsrSdioF0Read8(priv->sdio, cmd52_params.addr, &cmd52_params.data);
+ } else {
+ csrResult = CsrSdioRead8(priv->sdio, cmd52_params.addr, &cmd52_params.data);
+ }
+ } while (--retries && ((csrResult == CSR_SDIO_RESULT_CRC_ERROR) || (csrResult == CSR_SDIO_RESULT_TIMEOUT)));
+ CsrSdioRelease(priv->sdio);
+
+ if (csrResult != CSR_RESULT_SUCCESS) {
+ unifi_error(priv,
+ "\nunifi_putest_cmd52_read: Read8() failed (csrResult=0x%x)\n", csrResult);
+ return -EFAULT;
+ }
+ unifi_trace(priv, UDBG2, "data=%d\n", cmd52_params.data);
+
+ /* Copy the info to the out buffer */
+ *(unifi_putest_command_t*)ret_buffer = UNIFI_PUTEST_CMD52_READ;
+ ret_buffer_pos = (u8*)(((unifi_putest_command_t*)ret_buffer) + 1);
+ *(unsigned int*)ret_buffer_pos = sizeof(struct unifi_putest_cmd52);
+ ret_buffer_pos += sizeof(unsigned int);
+ memcpy(ret_buffer_pos, &cmd52_params, sizeof(struct unifi_putest_cmd52));
+ ret_buffer_pos += sizeof(struct unifi_putest_cmd52);
+
+ r = copy_to_user((void*)arg,
+ ret_buffer,
+ ret_buffer_pos - ret_buffer);
+ if (r) {
+ unifi_error(priv,
+ "unifi_putest_cmd52_read: Failed to return the data\n");
+ return -EFAULT;
+ }
+
+ return 0;
+}
+
+
+int unifi_putest_cmd52_write(unifi_priv_t *priv, unsigned char *arg)
+{
+ struct unifi_putest_cmd52 cmd52_params;
+ u8 *arg_pos;
+ unsigned int cmd_param_size;
+ CsrResult csrResult;
+ u8 retries;
+
+ arg_pos = (u8*)(((unifi_putest_command_t*)arg) + 1);
+ if (get_user(cmd_param_size, (int*)arg_pos)) {
+ unifi_error(priv,
+ "unifi_putest_cmd52_write: Failed to get the argument\n");
+ return -EFAULT;
+ }
+
+ if (cmd_param_size != sizeof(struct unifi_putest_cmd52)) {
+ unifi_error(priv,
+ "unifi_putest_cmd52_write: cmd52 struct mismatch\n");
+ return -EINVAL;
+ }
+
+ arg_pos += sizeof(unsigned int);
+ if (copy_from_user(&cmd52_params,
+ (void*)(arg_pos),
+ sizeof(struct unifi_putest_cmd52))) {
+ unifi_error(priv,
+ "unifi_putest_cmd52_write: Failed to get the cmd52 params\n");
+ return -EFAULT;
+ }
+
+ unifi_trace(priv, UDBG2, "cmd52w: func=%d addr=0x%x data=%d\n",
+ cmd52_params.funcnum, cmd52_params.addr, cmd52_params.data);
+
+ retries = 3;
+ CsrSdioClaim(priv->sdio);
+ do {
+ if (cmd52_params.funcnum == 0) {
+ csrResult = CsrSdioF0Write8(priv->sdio, cmd52_params.addr, cmd52_params.data);
+ } else {
+ csrResult = CsrSdioWrite8(priv->sdio, cmd52_params.addr, cmd52_params.data);
+ }
+ } while (--retries && ((csrResult == CSR_SDIO_RESULT_CRC_ERROR) || (csrResult == CSR_SDIO_RESULT_TIMEOUT)));
+ CsrSdioRelease(priv->sdio);
+
+ if (csrResult != CSR_RESULT_SUCCESS) {
+ unifi_error(priv,
+ "unifi_putest_cmd52_write: Write8() failed (csrResult=0x%x)\n", csrResult);
+ return -EFAULT;
+ }
+
+ return 0;
+}
+
+int unifi_putest_gp_read16(unifi_priv_t *priv, unsigned char *arg)
+{
+ struct unifi_putest_gp_rw16 gp_r16_params;
+ u8 *arg_pos;
+ unsigned int cmd_param_size;
+ int r;
+ CsrResult csrResult;
+ unsigned char ret_buffer[32];
+ u8 *ret_buffer_pos;
+
+ arg_pos = (u8*)(((unifi_putest_command_t*)arg) + 1);
+ if (get_user(cmd_param_size, (int*)arg_pos)) {
+ unifi_error(priv,
+ "unifi_putest_gp_read16: Failed to get the argument\n");
+ return -EFAULT;
+ }
+
+ if (cmd_param_size != sizeof(struct unifi_putest_gp_rw16)) {
+ unifi_error(priv,
+ "unifi_putest_gp_read16: struct mismatch\n");
+ return -EINVAL;
+ }
+
+ arg_pos += sizeof(unsigned int);
+ if (copy_from_user(&gp_r16_params,
+ (void*)arg_pos,
+ sizeof(struct unifi_putest_gp_rw16))) {
+ unifi_error(priv,
+ "unifi_putest_gp_read16: Failed to get the params\n");
+ return -EFAULT;
+ }
+ CsrSdioClaim(priv->sdio);
+ csrResult = unifi_card_read16(priv->card, gp_r16_params.addr, &gp_r16_params.data);
+ CsrSdioRelease(priv->sdio);
+ if (csrResult != CSR_RESULT_SUCCESS) {
+ unifi_error(priv,
+ "unifi_putest_gp_read16: unifi_card_read16() GP=0x%x failed (csrResult=0x%x)\n", gp_r16_params.addr, csrResult);
+ return -EFAULT;
+ }
+
+ unifi_trace(priv, UDBG2, "gp_r16: GP=0x%08x, data=0x%04x\n", gp_r16_params.addr, gp_r16_params.data);
+
+ /* Copy the info to the out buffer */
+ *(unifi_putest_command_t*)ret_buffer = UNIFI_PUTEST_GP_READ16;
+ ret_buffer_pos = (u8*)(((unifi_putest_command_t*)ret_buffer) + 1);
+ *(unsigned int*)ret_buffer_pos = sizeof(struct unifi_putest_gp_rw16);
+ ret_buffer_pos += sizeof(unsigned int);
+ memcpy(ret_buffer_pos, &gp_r16_params, sizeof(struct unifi_putest_gp_rw16));
+ ret_buffer_pos += sizeof(struct unifi_putest_gp_rw16);
+
+ r = copy_to_user((void*)arg,
+ ret_buffer,
+ ret_buffer_pos - ret_buffer);
+ if (r) {
+ unifi_error(priv,
+ "unifi_putest_gp_read16: Failed to return the data\n");
+ return -EFAULT;
+ }
+
+ return 0;
+}
+
+int unifi_putest_gp_write16(unifi_priv_t *priv, unsigned char *arg)
+{
+ struct unifi_putest_gp_rw16 gp_w16_params;
+ u8 *arg_pos;
+ unsigned int cmd_param_size;
+ CsrResult csrResult;
+
+ arg_pos = (u8*)(((unifi_putest_command_t*)arg) + 1);
+ if (get_user(cmd_param_size, (int*)arg_pos)) {
+ unifi_error(priv,
+ "unifi_putest_gp_write16: Failed to get the argument\n");
+ return -EFAULT;
+ }
+
+ if (cmd_param_size != sizeof(struct unifi_putest_gp_rw16)) {
+ unifi_error(priv,
+ "unifi_putest_gp_write16: struct mismatch\n");
+ return -EINVAL;
+ }
+
+ arg_pos += sizeof(unsigned int);
+ if (copy_from_user(&gp_w16_params,
+ (void*)(arg_pos),
+ sizeof(struct unifi_putest_gp_rw16))) {
+ unifi_error(priv,
+ "unifi_putest_gp_write16: Failed to get the params\n");
+ return -EFAULT;
+ }
+
+ unifi_trace(priv, UDBG2, "gp_w16: GP=0x%08x, data=0x%04x\n", gp_w16_params.addr, gp_w16_params.data);
+ CsrSdioClaim(priv->sdio);
+ csrResult = unifi_card_write16(priv->card, gp_w16_params.addr, gp_w16_params.data);
+ CsrSdioRelease(priv->sdio);
+ if (csrResult != CSR_RESULT_SUCCESS) {
+ unifi_error(priv,
+ "unifi_putest_gp_write16: unifi_card_write16() GP=%x failed (csrResult=0x%x)\n", gp_w16_params.addr, csrResult);
+ return -EFAULT;
+ }
+
+ return 0;
+}
+
+int unifi_putest_set_sdio_clock(unifi_priv_t *priv, unsigned char *arg)
+{
+ int sdio_clock_speed;
+ CsrResult csrResult;
+
+ if (get_user(sdio_clock_speed, (int*)(((unifi_putest_command_t*)arg) + 1))) {
+ unifi_error(priv,
+ "unifi_putest_set_sdio_clock: Failed to get the argument\n");
+ return -EFAULT;
+ }
+
+ unifi_trace(priv, UDBG2, "set sdio clock: %d KHz\n", sdio_clock_speed);
+
+ CsrSdioClaim(priv->sdio);
+ csrResult = CsrSdioMaxBusClockFrequencySet(priv->sdio, sdio_clock_speed * 1000);
+ CsrSdioRelease(priv->sdio);
+ if (csrResult != CSR_RESULT_SUCCESS) {
+ unifi_error(priv,
+ "unifi_putest_set_sdio_clock: Set clock failed (csrResult=0x%x)\n", csrResult);
+ return -EFAULT;
+ }
+
+ return 0;
+}
+
+
+int unifi_putest_start(unifi_priv_t *priv, unsigned char *arg)
+{
+ int r;
+ CsrResult csrResult;
+ int already_in_test = priv->ptest_mode;
+
+ /* Ensure that sme_sys_suspend() doesn't power down the chip because:
+ * 1) Power is needed anyway for ptest.
+ * 2) The app code uses the START ioctl as a reset, so it gets called
+ * multiple times. If the app stops the XAPs, but the power_down/up
+ * sequence doesn't actually power down the chip, there can be problems
+ * resetting, because part of the power_up sequence disables function 1
+ */
+ priv->ptest_mode = 1;
+
+ /* Suspend the SME and UniFi */
+ if (priv->sme_cli) {
+ r = sme_sys_suspend(priv);
+ if (r) {
+ unifi_error(priv,
+ "unifi_putest_start: failed to suspend UniFi\n");
+ return r;
+ }
+ }
+
+ /* Application may have stopped the XAPs, but they are needed for reset */
+ if (already_in_test) {
+ CsrSdioClaim(priv->sdio);
+ csrResult = unifi_start_processors(priv->card);
+ CsrSdioRelease(priv->sdio);
+ if (csrResult != CSR_RESULT_SUCCESS) {
+ unifi_error(priv, "Failed to start XAPs. Hard reset required.\n");
+ }
+ } else {
+ /* Ensure chip is powered for the case where there's no unifi_helper */
+ CsrSdioClaim(priv->sdio);
+ csrResult = CsrSdioPowerOn(priv->sdio);
+ CsrSdioRelease(priv->sdio);
+ if (csrResult != CSR_RESULT_SUCCESS) {
+ unifi_error(priv, "CsrSdioPowerOn csrResult = %d\n", csrResult);
+ }
+ }
+ CsrSdioClaim(priv->sdio);
+ csrResult = unifi_init(priv->card);
+ CsrSdioRelease(priv->sdio);
+ if (csrResult != CSR_RESULT_SUCCESS) {
+ unifi_error(priv,
+ "unifi_putest_start: failed to init UniFi\n");
+ return CsrHipResultToStatus(csrResult);
+ }
+
+ return 0;
+}
+
+
+int unifi_putest_stop(unifi_priv_t *priv, unsigned char *arg)
+{
+ int r = 0;
+ CsrResult csrResult;
+
+ /* Application may have stopped the XAPs, but they are needed for reset */
+ CsrSdioClaim(priv->sdio);
+ csrResult = unifi_start_processors(priv->card);
+ CsrSdioRelease(priv->sdio);
+ if (csrResult != CSR_RESULT_SUCCESS) {
+ unifi_error(priv, "Failed to start XAPs. Hard reset required.\n");
+ }
+
+ /* PUTEST_STOP is also used to resume the XAPs after SME coredump.
+ * Don't power off the chip, leave that to the normal wifi-off which is
+ * about to carry on. No need to resume the SME either, as it wasn't suspended.
+ */
+ if (priv->coredump_mode) {
+ priv->coredump_mode = 0;
+ return 0;
+ }
+
+ /* At this point function 1 is enabled and the XAPs are running, so it is
+ * safe to let the card power down. Power is restored later, asynchronously,
+ * during the wifi_on requested by the SME.
+ */
+ CsrSdioClaim(priv->sdio);
+ CsrSdioPowerOff(priv->sdio);
+ CsrSdioRelease(priv->sdio);
+
+ /* Resume the SME and UniFi */
+ if (priv->sme_cli) {
+ r = sme_sys_resume(priv);
+ if (r) {
+ unifi_error(priv,
+ "unifi_putest_stop: failed to resume SME\n");
+ }
+ }
+ priv->ptest_mode = 0;
+
+ return r;
+}
+
+
+int unifi_putest_dl_fw(unifi_priv_t *priv, unsigned char *arg)
+{
+#define UF_PUTEST_MAX_FW_FILE_NAME 16
+#define UNIFI_MAX_FW_PATH_LEN 32
+ unsigned int fw_name_length;
+ unsigned char fw_name[UF_PUTEST_MAX_FW_FILE_NAME+1];
+ unsigned char *name_buffer;
+ int postfix;
+ char fw_path[UNIFI_MAX_FW_PATH_LEN];
+ const struct firmware *fw_entry;
+ struct dlpriv temp_fw_sta;
+ int r;
+ CsrResult csrResult;
+
+ /* Get the f/w file name length */
+ if (get_user(fw_name_length, (unsigned int*)(((unifi_putest_command_t*)arg) + 1))) {
+ unifi_error(priv,
+ "unifi_putest_dl_fw: Failed to get the length argument\n");
+ return -EFAULT;
+ }
+
+ unifi_trace(priv, UDBG2, "unifi_putest_dl_fw: file name size = %d\n", fw_name_length);
+
+ /* Sanity check for the f/w file name length */
+ if (fw_name_length > UF_PUTEST_MAX_FW_FILE_NAME) {
+ unifi_error(priv,
+ "unifi_putest_dl_fw: F/W file name is too long\n");
+ return -EINVAL;
+ }
+
+ /* Get the f/w file name */
+ name_buffer = ((unsigned char*)arg) + sizeof(unifi_putest_command_t) + sizeof(unsigned int);
+ if (copy_from_user(fw_name, (void*)name_buffer, fw_name_length)) {
+ unifi_error(priv, "unifi_putest_dl_fw: Failed to get the file name\n");
+ return -EFAULT;
+ }
+ fw_name[fw_name_length] = '\0';
+ unifi_trace(priv, UDBG2, "unifi_putest_dl_fw: file = %s\n", fw_name);
+
+ /* Keep the existing f/w to a temp, we need to restore it later */
+ temp_fw_sta = priv->fw_sta;
+
+ /* Get the putest f/w */
+ postfix = priv->instance;
+ scnprintf(fw_path, UNIFI_MAX_FW_PATH_LEN, "unifi-sdio-%d/%s",
+ postfix, fw_name);
+ r = request_firmware(&fw_entry, fw_path, priv->unifi_device);
+ if (r == 0) {
+ priv->fw_sta.fw_desc = (void *)fw_entry;
+ priv->fw_sta.dl_data = fw_entry->data;
+ priv->fw_sta.dl_len = fw_entry->size;
+ } else {
+ unifi_error(priv, "Firmware file not available\n");
+ return -EINVAL;
+ }
+
+ /* Application may have stopped the XAPs, but they are needed for reset */
+ CsrSdioClaim(priv->sdio);
+ csrResult = unifi_start_processors(priv->card);
+ CsrSdioRelease(priv->sdio);
+ if (csrResult != CSR_RESULT_SUCCESS) {
+ unifi_error(priv, "Failed to start XAPs. Hard reset required.\n");
+ }
+
+ /* Download the f/w. On UF6xxx this will cause the f/w file to convert
+ * into patch format and download via the ROM boot loader
+ */
+ CsrSdioClaim(priv->sdio);
+ csrResult = unifi_download(priv->card, 0x0c00);
+ CsrSdioRelease(priv->sdio);
+ if (csrResult != CSR_RESULT_SUCCESS) {
+ unifi_error(priv,
+ "unifi_putest_dl_fw: failed to download the f/w\n");
+ goto free_fw;
+ }
+
+ /* Free the putest f/w... */
+free_fw:
+ uf_release_firmware(priv, &priv->fw_sta);
+ /* ... and restore the original f/w */
+ priv->fw_sta = temp_fw_sta;
+
+ return CsrHipResultToStatus(csrResult);
+}
+
+
+int unifi_putest_dl_fw_buff(unifi_priv_t *priv, unsigned char *arg)
+{
+ unsigned int fw_length;
+ unsigned char *fw_buf = NULL;
+ unsigned char *fw_user_ptr;
+ struct dlpriv temp_fw_sta;
+ CsrResult csrResult;
+
+ /* Get the f/w buffer length */
+ if (get_user(fw_length, (unsigned int*)(((unifi_putest_command_t*)arg) + 1))) {
+ unifi_error(priv,
+ "unifi_putest_dl_fw_buff: Failed to get the length arg\n");
+ return -EFAULT;
+ }
+
+ unifi_trace(priv, UDBG2, "unifi_putest_dl_fw_buff: size = %d\n", fw_length);
+
+ /* Sanity check for the buffer length */
+ if (fw_length == 0 || fw_length > 0xfffffff) {
+ unifi_error(priv,
+ "unifi_putest_dl_fw_buff: buffer length bad %u\n", fw_length);
+ return -EINVAL;
+ }
+
+ /* Buffer for kernel copy of the f/w image */
+ fw_buf = kmalloc(fw_length, GFP_KERNEL);
+ if (!fw_buf) {
+ unifi_error(priv, "unifi_putest_dl_fw_buff: malloc fail\n");
+ return -ENOMEM;
+ }
+
+ /* Get the f/w image */
+ fw_user_ptr = ((unsigned char*)arg) + sizeof(unifi_putest_command_t) + sizeof(unsigned int);
+ if (copy_from_user(fw_buf, (void*)fw_user_ptr, fw_length)) {
+ unifi_error(priv, "unifi_putest_dl_fw_buff: Failed to get the buffer\n");
+ kfree(fw_buf);
+ return -EFAULT;
+ }
+
+ /* Save the existing f/w to a temp, we need to restore it later */
+ temp_fw_sta = priv->fw_sta;
+
+ /* Setting fw_desc NULL indicates to the core that no f/w file was loaded
+ * via the kernel request_firmware() mechanism. This indicates to the core
+ * that it shouldn't call release_firmware() after the download is done.
+ */
+ priv->fw_sta.fw_desc = NULL; /* No OS f/w resource */
+ priv->fw_sta.dl_data = fw_buf;
+ priv->fw_sta.dl_len = fw_length;
+
+ /* Application may have stopped the XAPs, but they are needed for reset */
+ CsrSdioClaim(priv->sdio);
+ csrResult = unifi_start_processors(priv->card);
+ CsrSdioRelease(priv->sdio);
+ if (csrResult != CSR_RESULT_SUCCESS) {
+ unifi_error(priv, "Failed to start XAPs. Hard reset required.\n");
+ }
+
+ /* Download the f/w. On UF6xxx this will cause the f/w file to convert
+ * into patch format and download via the ROM boot loader
+ */
+ CsrSdioClaim(priv->sdio);
+ csrResult = unifi_download(priv->card, 0x0c00);
+ CsrSdioRelease(priv->sdio);
+ if (csrResult != CSR_RESULT_SUCCESS) {
+ unifi_error(priv,
+ "unifi_putest_dl_fw_buff: failed to download the f/w\n");
+ goto free_fw;
+ }
+
+free_fw:
+ /* Finished with the putest f/w, so restore the station f/w */
+ priv->fw_sta = temp_fw_sta;
+ kfree(fw_buf);
+
+ return CsrHipResultToStatus(csrResult);
+}
+
+
+int unifi_putest_coredump_prepare(unifi_priv_t *priv, unsigned char *arg)
+{
+ u16 data_u16;
+ s32 i;
+ CsrResult r;
+
+ unifi_info(priv, "Preparing for SDIO coredump\n");
+#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE)
+ unifi_debug_buf_dump();
+#endif
+
+ /* Sanity check that userspace hasn't called a PUTEST_START, because that
+ * would have reset UniFi, potentially power cycling it and losing context
+ */
+ if (priv->ptest_mode) {
+ unifi_error(priv, "PUTEST_START shouldn't be used before a coredump\n");
+ }
+
+ /* Flag that the userspace has requested coredump. Even if this preparation
+ * fails, the SME will call PUTEST_STOP to tidy up.
+ */
+ priv->coredump_mode = 1;
+
+ for (i = 0; i < 3; i++) {
+ CsrSdioClaim(priv->sdio);
+ r = CsrSdioRead16(priv->sdio, CHIP_HELPER_UNIFI_GBL_CHIP_VERSION*2, &data_u16);
+ CsrSdioRelease(priv->sdio);
+ if (r != CSR_RESULT_SUCCESS) {
+ unifi_info(priv, "Failed to read chip version! Try %d\n", i);
+
+ /* First try, re-enable function which may have been disabled by f/w panic */
+ if (i == 0) {
+ unifi_info(priv, "Try function enable\n");
+ CsrSdioClaim(priv->sdio);
+ r = CsrSdioFunctionEnable(priv->sdio);
+ CsrSdioRelease(priv->sdio);
+ if (r != CSR_RESULT_SUCCESS) {
+ unifi_error(priv, "CsrSdioFunctionEnable failed %d\n", r);
+ }
+ continue;
+ }
+
+ /* Subsequent tries, reset */
+
+ /* Set clock speed low */
+ CsrSdioClaim(priv->sdio);
+ r = CsrSdioMaxBusClockFrequencySet(priv->sdio, UNIFI_SDIO_CLOCK_SAFE_HZ);
+ CsrSdioRelease(priv->sdio);
+ if (r != CSR_RESULT_SUCCESS) {
+ unifi_error(priv, "CsrSdioMaxBusClockFrequencySet() failed %d\n", r);
+ }
+
+ /* Card software reset */
+ CsrSdioClaim(priv->sdio);
+ r = unifi_card_hard_reset(priv->card);
+ CsrSdioRelease(priv->sdio);
+ if (r != CSR_RESULT_SUCCESS) {
+ unifi_error(priv, "unifi_card_hard_reset() failed %d\n", r);
+ }
+ } else {
+ unifi_info(priv, "Read chip version of 0x%04x\n", data_u16);
+ break;
+ }
+ }
+
+ if (r != CSR_RESULT_SUCCESS) {
+ unifi_error(priv, "Failed to prepare chip\n");
+ return -EIO;
+ }
+
+ /* Stop the XAPs for coredump. The PUTEST_STOP must be called, e.g. at
+ * Raw SDIO deinit, to resume them.
+ */
+ CsrSdioClaim(priv->sdio);
+ r = unifi_card_stop_processor(priv->card, UNIFI_PROC_BOTH);
+ CsrSdioRelease(priv->sdio);
+ if (r != CSR_RESULT_SUCCESS) {
+ unifi_error(priv, "Failed to stop processors\n");
+ }
+
+ return 0;
+}
+
+int unifi_putest_cmd52_block_read(unifi_priv_t *priv, unsigned char *arg)
+{
+ struct unifi_putest_block_cmd52_r block_cmd52;
+ u8 *arg_pos;
+ unsigned int cmd_param_size;
+ CsrResult r;
+ u8 *block_local_buffer;
+
+ arg_pos = (u8*)(((unifi_putest_command_t*)arg) + 1);
+ if (get_user(cmd_param_size, (int*)arg_pos)) {
+ unifi_error(priv,
+ "cmd52r_block: Failed to get the argument\n");
+ return -EFAULT;
+ }
+
+ if (cmd_param_size != sizeof(struct unifi_putest_block_cmd52_r)) {
+ unifi_error(priv,
+ "cmd52r_block: cmd52 struct mismatch\n");
+ return -EINVAL;
+ }
+
+ arg_pos += sizeof(unsigned int);
+ if (copy_from_user(&block_cmd52,
+ (void*)arg_pos,
+ sizeof(struct unifi_putest_block_cmd52_r))) {
+ unifi_error(priv,
+ "cmd52r_block: Failed to get the cmd52 params\n");
+ return -EFAULT;
+ }
+
+ unifi_trace(priv, UDBG2, "cmd52r_block: func=%d addr=0x%x len=0x%x ",
+ block_cmd52.funcnum, block_cmd52.addr, block_cmd52.length);
+
+ block_local_buffer = vmalloc(block_cmd52.length);
+ if (block_local_buffer == NULL) {
+ unifi_error(priv, "cmd52r_block: Failed to allocate buffer\n");
+ return -ENOMEM;
+ }
+
+ CsrSdioClaim(priv->sdio);
+ r = unifi_card_readn(priv->card, block_cmd52.addr, block_local_buffer, block_cmd52.length);
+ CsrSdioRelease(priv->sdio);
+ if (r != CSR_RESULT_SUCCESS) {
+ unifi_error(priv, "cmd52r_block: unifi_readn failed\n");
+ return -EIO;
+ }
+
+ if (copy_to_user((void*)block_cmd52.data,
+ block_local_buffer,
+ block_cmd52.length)) {
+ unifi_error(priv,
+ "cmd52r_block: Failed to return the data\n");
+ return -EFAULT;
+ }
+
+ return 0;
+}
diff --git a/drivers/staging/csr/sdio_events.c b/drivers/staging/csr/sdio_events.c
new file mode 100644
index 000000000000..6892c2e281bc
--- /dev/null
+++ b/drivers/staging/csr/sdio_events.c
@@ -0,0 +1,134 @@
+/*
+ * ---------------------------------------------------------------------------
+ * FILE: sdio_events.c
+ *
+ * PURPOSE:
+ * Process the events received by the SDIO glue layer.
+ * Optional part of the porting exercise.
+ *
+ * Copyright (C) 2009 by Cambridge Silicon Radio Ltd.
+ *
+ * Refer to LICENSE.txt included with this source code for details on
+ * the license terms.
+ *
+ * ---------------------------------------------------------------------------
+ */
+#include "unifi_priv.h"
+
+
+/*
+ * Porting Notes:
+ * There are two ways to support the suspend/resume system events in a driver.
+ * In some operating systems these events are delivered to the OS driver
+ * directly from the system. In this case, the OS driver needs to pass these
+ * events to the API described in the CSR SDIO Abstration API document.
+ * In Linux, and other embedded operating systems, the suspend/resume events
+ * come from the SDIO driver. In this case, simply get these events in the
+ * SDIO glue layer and notify the OS layer.
+ *
+ * In either case, typically, the events are processed by the SME.
+ * Use the unifi_sys_suspend_ind() and unifi_sys_resume_ind() to pass
+ * the events to the SME.
+ */
+
+/*
+ * ---------------------------------------------------------------------------
+ * unifi_suspend
+ *
+ * Handles a suspend request from the SDIO driver.
+ *
+ * Arguments:
+ * ospriv Pointer to OS driver context.
+ *
+ * ---------------------------------------------------------------------------
+ */
+void unifi_suspend(void *ospriv)
+{
+ unifi_priv_t *priv = ospriv;
+ int interfaceTag=0;
+
+ /* For powered suspend, tell the resume's wifi_on() not to reinit UniFi */
+ priv->wol_suspend = (enable_wol == UNIFI_WOL_OFF) ? FALSE : TRUE;
+
+ unifi_trace(priv, UDBG1, "unifi_suspend: wol_suspend %d, enable_wol %d",
+ priv->wol_suspend, enable_wol );
+
+ /* Stop network traffic. */
+ /* need to stop all the netdevices*/
+ for( interfaceTag=0;interfaceTag<CSR_WIFI_NUM_INTERFACES;interfaceTag++)
+ {
+ netInterface_priv_t *interfacePriv = priv->interfacePriv[interfaceTag];
+ if (interfacePriv->netdev_registered == 1)
+ {
+ if( priv->wol_suspend ) {
+ unifi_trace(priv, UDBG1, "unifi_suspend: Don't netif_carrier_off");
+ } else {
+ unifi_trace(priv, UDBG1, "unifi_suspend: netif_carrier_off");
+ netif_carrier_off(priv->netdev[interfaceTag]);
+ }
+ UF_NETIF_TX_STOP_ALL_QUEUES(priv->netdev[interfaceTag]);
+ }
+ }
+
+ unifi_trace(priv, UDBG1, "unifi_suspend: suspend SME");
+
+ sme_sys_suspend(priv);
+
+} /* unifi_suspend() */
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * unifi_resume
+ *
+ * Handles a resume request from the SDIO driver.
+ *
+ * Arguments:
+ * ospriv Pointer to OS driver context.
+ *
+ * ---------------------------------------------------------------------------
+ */
+void unifi_resume(void *ospriv)
+{
+ unifi_priv_t *priv = ospriv;
+ int interfaceTag=0;
+ int r;
+ int wol = priv->wol_suspend;
+
+ unifi_trace(priv, UDBG1, "unifi_resume: resume SME, enable_wol=%d", enable_wol);
+
+ /* The resume causes wifi-on which will re-enable the BH and reinstall the ISR */
+ r = sme_sys_resume(priv);
+ if (r) {
+ unifi_error(priv, "Failed to resume UniFi\n");
+ }
+
+ /* Resume the network interfaces. For the cold resume case, this will
+ * happen upon reconnection.
+ */
+ if (wol) {
+ unifi_trace(priv, UDBG1, "unifi_resume: try to enable carrier");
+
+ /* need to start all the netdevices*/
+ for( interfaceTag=0;interfaceTag<CSR_WIFI_NUM_INTERFACES;interfaceTag++) {
+ netInterface_priv_t *interfacePriv = priv->interfacePriv[interfaceTag];
+
+ unifi_trace(priv, UDBG1, "unifi_resume: interfaceTag %d netdev_registered %d mode %d\n",
+ interfaceTag, interfacePriv->netdev_registered, interfacePriv->interfaceMode);
+
+ if (interfacePriv->netdev_registered == 1)
+ {
+ netif_carrier_on(priv->netdev[interfaceTag]);
+ UF_NETIF_TX_START_ALL_QUEUES(priv->netdev[interfaceTag]);
+ }
+ }
+
+ /* Kick the BH thread (with reason=host) to poll for data that may have
+ * arrived during a powered suspend. This caters for the case where the SME
+ * doesn't interact with the chip (e.g install autonomous scans) during resume.
+ */
+ unifi_send_signal(priv->card, NULL, 0, NULL);
+ }
+
+} /* unifi_resume() */
+
diff --git a/drivers/staging/csr/sdio_mmc.c b/drivers/staging/csr/sdio_mmc.c
new file mode 100644
index 000000000000..d3fd57cdde0b
--- /dev/null
+++ b/drivers/staging/csr/sdio_mmc.c
@@ -0,0 +1,1340 @@
+/*
+ * ---------------------------------------------------------------------------
+ *
+ * FILE: sdio_mmc.c
+ *
+ * PURPOSE: SDIO driver interface for generic MMC stack.
+ *
+ * Copyright (C) 2008-2009 by Cambridge Silicon Radio Ltd.
+ *
+ * ---------------------------------------------------------------------------
+ */
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/kernel.h>
+#include <linux/mutex.h>
+#include <linux/gfp.h>
+
+#include <linux/mmc/core.h>
+#include <linux/mmc/card.h>
+#include <linux/mmc/host.h>
+#include <linux/mmc/sdio_func.h>
+#include <linux/mmc/sdio_ids.h>
+#include <linux/mmc/sdio.h>
+#include <linux/suspend.h>
+
+#include "unifi_priv.h"
+
+#ifdef ANDROID_BUILD
+struct wake_lock unifi_sdio_wake_lock; /* wakelock to prevent suspend while resuming */
+#endif
+
+static CsrSdioFunctionDriver *sdio_func_drv;
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,32)
+#ifdef CONFIG_PM
+static int uf_sdio_mmc_power_event(struct notifier_block *this, unsigned long event, void *ptr);
+#endif
+
+/*
+ * We need to keep track of the power on/off because we can not call
+ * mmc_power_restore_host() when the card is already powered.
+ * Even then, we need to patch the MMC driver to add a power_restore handler
+ * in the mmc_sdio_ops structure. If the MMC driver before 2.6.37 is not patched,
+ * mmc_power_save_host() and mmc_power_restore_host() are no-ops in the kernel,
+ * returning immediately (at least on x86).
+ */
+static int card_is_powered = 1;
+#endif /* 2.6.32 */
+
+/* MMC uses ENOMEDIUM to indicate card gone away */
+
+static CsrResult
+ConvertSdioToCsrSdioResult(int r)
+{
+ CsrResult csrResult = CSR_RESULT_FAILURE;
+
+ switch (r) {
+ case 0:
+ csrResult = CSR_RESULT_SUCCESS;
+ break;
+ case -EIO:
+ case -EILSEQ:
+ csrResult = CSR_SDIO_RESULT_CRC_ERROR;
+ break;
+ /* Timeout errors */
+ case -ETIMEDOUT:
+ case -EBUSY:
+ csrResult = CSR_SDIO_RESULT_TIMEOUT;
+ break;
+ case -ENODEV:
+ case -ENOMEDIUM:
+ csrResult = CSR_SDIO_RESULT_NO_DEVICE;
+ break;
+ case -EINVAL:
+ csrResult = CSR_SDIO_RESULT_INVALID_VALUE;
+ break;
+ case -ENOMEM:
+ case -ENOSYS:
+ case -ERANGE:
+ case -ENXIO:
+ csrResult = CSR_RESULT_FAILURE;
+ break;
+ default:
+ unifi_warning(NULL, "Unrecognised SDIO error code: %d\n", r);
+ break;
+ }
+
+ return csrResult;
+}
+
+
+static int
+csr_io_rw_direct(struct mmc_card *card, int write, uint8_t fn,
+ uint32_t addr, uint8_t in, uint8_t* out)
+{
+ struct mmc_command cmd;
+ int err;
+
+ BUG_ON(!card);
+ BUG_ON(fn > 7);
+
+ memset(&cmd, 0, sizeof(struct mmc_command));
+
+ cmd.opcode = SD_IO_RW_DIRECT;
+ cmd.arg = write ? 0x80000000 : 0x00000000;
+ cmd.arg |= fn << 28;
+ cmd.arg |= (write && out) ? 0x08000000 : 0x00000000;
+ cmd.arg |= addr << 9;
+ cmd.arg |= in;
+ cmd.flags = MMC_RSP_SPI_R5 | MMC_RSP_R5 | MMC_CMD_AC;
+
+ err = mmc_wait_for_cmd(card->host, &cmd, 0);
+ if (err)
+ return err;
+
+ /* this function is not exported, so we will need to sort it out here
+ * for now, lets hard code it to sdio */
+ if (0) {
+ /* old arg (mmc_host_is_spi(card->host)) { */
+ /* host driver already reported errors */
+ } else {
+ if (cmd.resp[0] & R5_ERROR) {
+ printk(KERN_ERR "%s: r5 error 0x%02x\n",
+ __FUNCTION__, cmd.resp[0]);
+ return -EIO;
+ }
+ if (cmd.resp[0] & R5_FUNCTION_NUMBER)
+ return -EINVAL;
+ if (cmd.resp[0] & R5_OUT_OF_RANGE)
+ return -ERANGE;
+ }
+
+ if (out) {
+ if (0) { /* old argument (mmc_host_is_spi(card->host)) */
+ *out = (cmd.resp[0] >> 8) & 0xFF;
+ }
+ else {
+ *out = cmd.resp[0] & 0xFF;
+ }
+ }
+
+ return CSR_RESULT_SUCCESS;
+}
+
+
+CsrResult
+CsrSdioRead8(CsrSdioFunction *function, u32 address, u8 *data)
+{
+ struct sdio_func *func = (struct sdio_func *)function->priv;
+ int err = 0;
+
+ _sdio_claim_host(func);
+ *data = sdio_readb(func, address, &err);
+ _sdio_release_host(func);
+
+ if (err) {
+ func_exit_r(err);
+ return ConvertSdioToCsrSdioResult(err);
+ }
+
+ return CSR_RESULT_SUCCESS;
+} /* CsrSdioRead8() */
+
+CsrResult
+CsrSdioWrite8(CsrSdioFunction *function, u32 address, u8 data)
+{
+ struct sdio_func *func = (struct sdio_func *)function->priv;
+ int err = 0;
+
+ _sdio_claim_host(func);
+ sdio_writeb(func, data, address, &err);
+ _sdio_release_host(func);
+
+ if (err) {
+ func_exit_r(err);
+ return ConvertSdioToCsrSdioResult(err);
+ }
+
+ return CSR_RESULT_SUCCESS;
+} /* CsrSdioWrite8() */
+
+CsrResult
+CsrSdioRead16(CsrSdioFunction *function, u32 address, u16 *data)
+{
+ struct sdio_func *func = (struct sdio_func *)function->priv;
+ int err;
+ uint8_t b0, b1;
+
+ _sdio_claim_host(func);
+ b0 = sdio_readb(func, address, &err);
+ if (err) {
+ _sdio_release_host(func);
+ return ConvertSdioToCsrSdioResult(err);
+ }
+
+ b1 = sdio_readb(func, address+1, &err);
+ if (err) {
+ _sdio_release_host(func);
+ return ConvertSdioToCsrSdioResult(err);
+ }
+ _sdio_release_host(func);
+
+ *data = ((uint16_t)b1 << 8) | b0;
+
+ return CSR_RESULT_SUCCESS;
+} /* CsrSdioRead16() */
+
+
+CsrResult
+CsrSdioWrite16(CsrSdioFunction *function, u32 address, u16 data)
+{
+ struct sdio_func *func = (struct sdio_func *)function->priv;
+ int err;
+ uint8_t b0, b1;
+
+ _sdio_claim_host(func);
+ b1 = (data >> 8) & 0xFF;
+ sdio_writeb(func, b1, address+1, &err);
+ if (err) {
+ _sdio_release_host(func);
+ return ConvertSdioToCsrSdioResult(err);
+ }
+
+ b0 = data & 0xFF;
+ sdio_writeb(func, b0, address, &err);
+ if (err) {
+ _sdio_release_host(func);
+ return ConvertSdioToCsrSdioResult(err);
+ }
+
+ _sdio_release_host(func);
+ return CSR_RESULT_SUCCESS;
+} /* CsrSdioWrite16() */
+
+
+CsrResult
+CsrSdioF0Read8(CsrSdioFunction *function, u32 address, u8 *data)
+{
+ struct sdio_func *func = (struct sdio_func *)function->priv;
+ int err = 0;
+
+ _sdio_claim_host(func);
+#ifdef MMC_QUIRK_LENIENT_FN0
+ *data = sdio_f0_readb(func, address, &err);
+#else
+ err = csr_io_rw_direct(func->card, 0, 0, address, 0, data);
+#endif
+ _sdio_release_host(func);
+
+ if (err) {
+ func_exit_r(err);
+ return ConvertSdioToCsrSdioResult(err);
+ }
+
+ return CSR_RESULT_SUCCESS;
+} /* CsrSdioF0Read8() */
+
+CsrResult
+CsrSdioF0Write8(CsrSdioFunction *function, u32 address, u8 data)
+{
+ struct sdio_func *func = (struct sdio_func *)function->priv;
+ int err = 0;
+
+ _sdio_claim_host(func);
+#ifdef MMC_QUIRK_LENIENT_FN0
+ sdio_f0_writeb(func, data, address, &err);
+#else
+ err = csr_io_rw_direct(func->card, 1, 0, address, data, NULL);
+#endif
+ _sdio_release_host(func);
+
+ if (err) {
+ func_exit_r(err);
+ return ConvertSdioToCsrSdioResult(err);
+ }
+
+ return CSR_RESULT_SUCCESS;
+} /* CsrSdioF0Write8() */
+
+
+CsrResult
+CsrSdioRead(CsrSdioFunction *function, u32 address, void *data, u32 length)
+{
+ struct sdio_func *func = (struct sdio_func *)function->priv;
+ int err;
+
+ _sdio_claim_host(func);
+ err = sdio_readsb(func, data, address, length);
+ _sdio_release_host(func);
+
+ if (err) {
+ func_exit_r(err);
+ return ConvertSdioToCsrSdioResult(err);
+ }
+
+ return CSR_RESULT_SUCCESS;
+} /* CsrSdioRead() */
+
+CsrResult
+CsrSdioWrite(CsrSdioFunction *function, u32 address, const void *data, u32 length)
+{
+ struct sdio_func *func = (struct sdio_func *)function->priv;
+ int err;
+
+ _sdio_claim_host(func);
+ err = sdio_writesb(func, address, (void*)data, length);
+ _sdio_release_host(func);
+
+ if (err) {
+ func_exit_r(err);
+ return ConvertSdioToCsrSdioResult(err);
+ }
+
+ return CSR_RESULT_SUCCESS;
+} /* CsrSdioWrite() */
+
+
+static int
+csr_sdio_enable_hs(struct mmc_card *card)
+{
+ int ret;
+ u8 speed;
+
+ if (!(card->host->caps & MMC_CAP_SD_HIGHSPEED)) {
+ /* We've asked for HS clock rates, but controller doesn't
+ * claim to support it. We should limit the clock
+ * to 25MHz via module parameter.
+ */
+ printk(KERN_INFO "unifi: request HS but not MMC_CAP_SD_HIGHSPEED");
+ return 0;
+ }
+
+ if (!card->cccr.high_speed)
+ return 0;
+
+#if 1
+ ret = csr_io_rw_direct(card, 0, 0, SDIO_CCCR_SPEED, 0, &speed);
+ if (ret)
+ return ret;
+
+ speed |= SDIO_SPEED_EHS;
+#else
+ /* Optimisation: Eliminate read by always assuming SHS and that reserved bits can be zero */
+ speed = SDIO_SPEED_EHS | SDIO_SPEED_SHS;
+#endif
+
+ ret = csr_io_rw_direct(card, 1, 0, SDIO_CCCR_SPEED, speed, NULL);
+ if (ret)
+ return ret;
+
+ mmc_card_set_highspeed(card);
+ card->host->ios.timing = MMC_TIMING_SD_HS;
+ card->host->ops->set_ios(card->host, &card->host->ios);
+
+ return 0;
+}
+
+static int
+csr_sdio_disable_hs(struct mmc_card *card)
+{
+ int ret;
+ u8 speed;
+
+ if (!(card->host->caps & MMC_CAP_SD_HIGHSPEED))
+ return 0;
+
+ if (!card->cccr.high_speed)
+ return 0;
+#if 1
+ ret = csr_io_rw_direct(card, 0, 0, SDIO_CCCR_SPEED, 0, &speed);
+ if (ret)
+ return ret;
+
+ speed &= ~SDIO_SPEED_EHS;
+#else
+ /* Optimisation: Eliminate read by always assuming SHS and that reserved bits can be zero */
+ speed = SDIO_SPEED_SHS; /* clear SDIO_SPEED_EHS */
+#endif
+
+ ret = csr_io_rw_direct(card, 1, 0, SDIO_CCCR_SPEED, speed, NULL);
+ if (ret)
+ return ret;
+
+ card->state &= ~MMC_STATE_HIGHSPEED;
+ card->host->ios.timing = MMC_TIMING_LEGACY;
+ card->host->ops->set_ios(card->host, &card->host->ios);
+
+ return 0;
+}
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * CsrSdioMaxBusClockFrequencySet
+ *
+ * Set the maximum SDIO bus clock speed to use.
+ *
+ * Arguments:
+ * sdio SDIO context pointer
+ * maxFrequency maximum clock speed in Hz
+ *
+ * Returns:
+ * an error code.
+ * ---------------------------------------------------------------------------
+ */
+CsrResult
+CsrSdioMaxBusClockFrequencySet(CsrSdioFunction *function, u32 maxFrequency)
+{
+ struct sdio_func *func = (struct sdio_func *)function->priv;
+ struct mmc_host *host = func->card->host;
+ struct mmc_ios *ios = &host->ios;
+ unsigned int max_hz;
+ int err;
+ u32 max_khz = maxFrequency/1000;
+
+ if (!max_khz || max_khz > sdio_clock) {
+ max_khz = sdio_clock;
+ }
+
+ _sdio_claim_host(func);
+ max_hz = 1000 * max_khz;
+ if (max_hz > host->f_max) {
+ max_hz = host->f_max;
+ }
+
+ if (max_hz > 25000000) {
+ err = csr_sdio_enable_hs(func->card);
+ } else {
+ err = csr_sdio_disable_hs(func->card);
+ }
+ if (err) {
+ printk(KERN_ERR "SDIO warning: Failed to configure SDIO clock mode\n");
+ _sdio_release_host(func);
+ return CSR_RESULT_SUCCESS;
+ }
+
+ ios->clock = max_hz;
+ host->ops->set_ios(host, ios);
+
+ _sdio_release_host(func);
+
+ return CSR_RESULT_SUCCESS;
+} /* CsrSdioMaxBusClockFrequencySet() */
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * CsrSdioInterruptEnable
+ * CsrSdioInterruptDisable
+ *
+ * Enable or disable the SDIO interrupt.
+ * The driver disables the SDIO interrupt until the i/o thread can
+ * process it.
+ * The SDIO interrupt can be disabled by modifying the SDIO_INT_ENABLE
+ * register in the Card Common Control Register block, but this requires
+ * two CMD52 operations. A better solution is to mask the interrupt at
+ * the host controller.
+ *
+ * Arguments:
+ * sdio SDIO context pointer
+ *
+ * Returns:
+ * Zero on success or a UniFi driver error code.
+ *
+ * ---------------------------------------------------------------------------
+ */
+CsrResult
+CsrSdioInterruptEnable(CsrSdioFunction *function)
+{
+ struct sdio_func *func = (struct sdio_func *)function->priv;
+ int err = 0;
+
+#ifdef CSR_CONFIG_MMC_INT_BYPASS_KSOFTIRQD
+ sdio_unblock_card_irq(func);
+#else
+ _sdio_claim_host(func);
+ /* Write the Int Enable in CCCR block */
+#ifdef MMC_QUIRK_LENIENT_FN0
+ sdio_f0_writeb(func, 0x3, SDIO_CCCR_IENx, &err);
+#else
+ err = csr_io_rw_direct(func->card, 1, 0, SDIO_CCCR_IENx, 0x03, NULL);
+#endif
+ _sdio_release_host(func);
+
+ func_exit();
+ if (err) {
+ printk(KERN_ERR "unifi: %s: error %d writing IENx\n", __FUNCTION__, err);
+ return ConvertSdioToCsrSdioResult(err);
+ }
+#endif
+ return CSR_RESULT_SUCCESS;
+} /* CsrSdioInterruptEnable() */
+
+CsrResult
+CsrSdioInterruptDisable(CsrSdioFunction *function)
+{
+ struct sdio_func *func = (struct sdio_func *)function->priv;
+ int err = 0;
+
+#ifdef CSR_CONFIG_MMC_INT_BYPASS_KSOFTIRQD
+ sdio_block_card_irq(func);
+#else
+ _sdio_claim_host(func);
+ /* Write the Int Enable in CCCR block */
+#ifdef MMC_QUIRK_LENIENT_FN0
+ sdio_f0_writeb(func, 0, SDIO_CCCR_IENx, &err);
+#else
+ err = csr_io_rw_direct(func->card, 1, 0, SDIO_CCCR_IENx, 0x00, NULL);
+#endif
+ _sdio_release_host(func);
+
+ func_exit();
+ if (err) {
+ printk(KERN_ERR "unifi: %s: error %d writing IENx\n", __FUNCTION__, err);
+ return ConvertSdioToCsrSdioResult(err);
+ }
+#endif
+ return CSR_RESULT_SUCCESS;
+} /* CsrSdioInterruptDisable() */
+
+
+void CsrSdioInterruptAcknowledge(CsrSdioFunction *function)
+{
+}
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * CsrSdioFunctionEnable
+ *
+ * Enable i/o on function 1.
+ *
+ * Arguments:
+ * sdio SDIO context pointer
+ *
+ * Returns:
+ * UniFi driver error code.
+ * ---------------------------------------------------------------------------
+ */
+CsrResult
+CsrSdioFunctionEnable(CsrSdioFunction *function)
+{
+ struct sdio_func *func = (struct sdio_func *)function->priv;
+ int err;
+
+ func_enter();
+
+ /* Enable UniFi function 1 (the 802.11 part). */
+ _sdio_claim_host(func);
+ err = sdio_enable_func(func);
+ _sdio_release_host(func);
+ if (err) {
+ unifi_error(NULL, "Failed to enable SDIO function %d\n", func->num);
+ }
+
+ func_exit();
+ return ConvertSdioToCsrSdioResult(err);
+} /* CsrSdioFunctionEnable() */
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * CsrSdioFunctionDisable
+ *
+ * Enable i/o on function 1.
+ *
+ * Arguments:
+ * sdio SDIO context pointer
+ *
+ * Returns:
+ * UniFi driver error code.
+ * ---------------------------------------------------------------------------
+ */
+CsrResult
+CsrSdioFunctionDisable(CsrSdioFunction *function)
+{
+ struct sdio_func *func = (struct sdio_func *)function->priv;
+ int err;
+
+ func_enter();
+
+ /* Disable UniFi function 1 (the 802.11 part). */
+ _sdio_claim_host(func);
+ err = sdio_disable_func(func);
+ _sdio_release_host(func);
+ if (err) {
+ unifi_error(NULL, "Failed to disable SDIO function %d\n", func->num);
+ }
+
+ func_exit();
+ return ConvertSdioToCsrSdioResult(err);
+} /* CsrSdioFunctionDisable() */
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * CsrSdioFunctionActive
+ *
+ * No-op as the bus goes to an active state at the start of every
+ * command.
+ *
+ * Arguments:
+ * sdio SDIO context pointer
+ * ---------------------------------------------------------------------------
+ */
+void
+CsrSdioFunctionActive(CsrSdioFunction *function)
+{
+} /* CsrSdioFunctionActive() */
+
+/*
+ * ---------------------------------------------------------------------------
+ * CsrSdioFunctionIdle
+ *
+ * Set the function as idle.
+ *
+ * Arguments:
+ * sdio SDIO context pointer
+ * ---------------------------------------------------------------------------
+ */
+void
+CsrSdioFunctionIdle(CsrSdioFunction *function)
+{
+} /* CsrSdioFunctionIdle() */
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * CsrSdioPowerOn
+ *
+ * Power on UniFi.
+ *
+ * Arguments:
+ * sdio SDIO context pointer
+ * ---------------------------------------------------------------------------
+ */
+CsrResult
+CsrSdioPowerOn(CsrSdioFunction *function)
+{
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,32)
+ struct sdio_func *func = (struct sdio_func *)function->priv;
+ struct mmc_host *host = func->card->host;
+
+ _sdio_claim_host(func);
+ if (!card_is_powered) {
+ mmc_power_restore_host(host);
+ card_is_powered = 1;
+ } else {
+ printk(KERN_INFO "SDIO: Skip power on; card is already powered.\n");
+ }
+ _sdio_release_host(func);
+#endif /* 2.6.32 */
+
+ return CSR_RESULT_SUCCESS;
+} /* CsrSdioPowerOn() */
+
+/*
+ * ---------------------------------------------------------------------------
+ * CsrSdioPowerOff
+ *
+ * Power off UniFi.
+ *
+ * Arguments:
+ * sdio SDIO context pointer
+ * ---------------------------------------------------------------------------
+ */
+void
+CsrSdioPowerOff(CsrSdioFunction *function)
+{
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,32)
+ struct sdio_func *func = (struct sdio_func *)function->priv;
+ struct mmc_host *host = func->card->host;
+
+ _sdio_claim_host(func);
+ if (card_is_powered) {
+ mmc_power_save_host(host);
+ card_is_powered = 0;
+ } else {
+ printk(KERN_INFO "SDIO: Skip power off; card is already powered off.\n");
+ }
+ _sdio_release_host(func);
+#endif /* 2.6.32 */
+} /* CsrSdioPowerOff() */
+
+
+static int
+sdio_set_block_size_ignore_first_error(struct sdio_func *func, unsigned blksz)
+{
+ int ret;
+
+ if (blksz > func->card->host->max_blk_size)
+ return -EINVAL;
+
+ if (blksz == 0) {
+ blksz = min(func->max_blksize, func->card->host->max_blk_size);
+ blksz = min(blksz, 512u);
+ }
+
+ /*
+ * Ignore -ERANGE (OUT_OF_RANGE in R5) on the first byte as
+ * the block size may be invalid until both bytes are written.
+ */
+ ret = csr_io_rw_direct(func->card, 1, 0,
+ SDIO_FBR_BASE(func->num) + SDIO_FBR_BLKSIZE,
+ blksz & 0xff, NULL);
+ if (ret && ret != -ERANGE)
+ return ret;
+ ret = csr_io_rw_direct(func->card, 1, 0,
+ SDIO_FBR_BASE(func->num) + SDIO_FBR_BLKSIZE + 1,
+ (blksz >> 8) & 0xff, NULL);
+ if (ret)
+ return ret;
+ func->cur_blksize = blksz;
+
+ return 0;
+}
+
+CsrResult
+CsrSdioBlockSizeSet(CsrSdioFunction *function, u16 blockSize)
+{
+ struct sdio_func *func = (struct sdio_func *)function->priv;
+ int r = 0;
+
+ /* Module parameter overrides */
+ if (sdio_block_size > -1) {
+ blockSize = sdio_block_size;
+ }
+
+ unifi_trace(NULL, UDBG1, "Set SDIO function block size to %d\n",
+ blockSize);
+
+ _sdio_claim_host(func);
+ r = sdio_set_block_size(func, blockSize);
+ _sdio_release_host(func);
+
+ /*
+ * The MMC driver for kernels prior to 2.6.32 may fail this request
+ * with -ERANGE. In this case use our workaround.
+ */
+ if (r == -ERANGE) {
+ _sdio_claim_host(func);
+ r = sdio_set_block_size_ignore_first_error(func, blockSize);
+ _sdio_release_host(func);
+ }
+ if (r) {
+ unifi_error(NULL, "Error %d setting block size\n", r);
+ }
+
+ /* Determine the achieved block size to pass to the core */
+ function->blockSize = func->cur_blksize;
+
+ return ConvertSdioToCsrSdioResult(r);
+} /* CsrSdioBlockSizeSet() */
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * CsrSdioHardReset
+ *
+ * Hard Resets UniFi is possible.
+ *
+ * Arguments:
+ * sdio SDIO context pointer
+ * ---------------------------------------------------------------------------
+ */
+CsrResult
+CsrSdioHardReset(CsrSdioFunction *function)
+{
+ return CSR_RESULT_FAILURE;
+} /* CsrSdioHardReset() */
+
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * uf_glue_sdio_int_handler
+ *
+ * Interrupt callback function for SDIO interrupts.
+ * This is called in kernel context (i.e. not interrupt context).
+ *
+ * Arguments:
+ * func SDIO context pointer
+ *
+ * Returns:
+ * None.
+ *
+ * Note: Called with host already claimed.
+ * ---------------------------------------------------------------------------
+ */
+static void
+uf_glue_sdio_int_handler(struct sdio_func *func)
+{
+ CsrSdioFunction *sdio_ctx;
+ CsrSdioInterruptDsrCallback func_dsr_callback;
+ int r;
+
+ sdio_ctx = sdio_get_drvdata(func);
+ if (!sdio_ctx) {
+ return;
+ }
+
+#ifndef CSR_CONFIG_MMC_INT_BYPASS_KSOFTIRQD
+ /*
+ * Normally, we are not allowed to do any SDIO commands here.
+ * However, this is called in a thread context and with the SDIO lock
+ * so we disable the interrupts here instead of trying to do complicated
+ * things with the SDIO lock.
+ */
+#ifdef MMC_QUIRK_LENIENT_FN0
+ sdio_f0_writeb(func, 0, SDIO_CCCR_IENx, &r);
+#else
+ r = csr_io_rw_direct(func->card, 1, 0, SDIO_CCCR_IENx, 0x00, NULL);
+#endif
+ if (r) {
+ printk(KERN_ERR "UniFi MMC Int handler: Failed to disable interrupts %d\n", r);
+ }
+#endif
+
+ /* If the function driver has registered a handler, call it */
+ if (sdio_func_drv && sdio_func_drv->intr) {
+
+ func_dsr_callback = sdio_func_drv->intr(sdio_ctx);
+
+ /* If interrupt handle returns a DSR handle, call it */
+ if (func_dsr_callback) {
+ func_dsr_callback(sdio_ctx);
+ }
+ }
+
+} /* uf_glue_sdio_int_handler() */
+
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * csr_sdio_linux_remove_irq
+ *
+ * Unregister the interrupt handler.
+ * This means that the linux layer can not process interrupts any more.
+ *
+ * Arguments:
+ * sdio SDIO context pointer
+ *
+ * Returns:
+ * Status of the removal.
+ * ---------------------------------------------------------------------------
+ */
+int
+csr_sdio_linux_remove_irq(CsrSdioFunction *function)
+{
+ struct sdio_func *func = (struct sdio_func *)function->priv;
+ int r;
+
+ unifi_trace(NULL, UDBG1, "csr_sdio_linux_remove_irq\n");
+
+ sdio_claim_host(func);
+ r = sdio_release_irq(func);
+ sdio_release_host(func);
+
+ return r;
+
+} /* csr_sdio_linux_remove_irq() */
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * csr_sdio_linux_install_irq
+ *
+ * Register the interrupt handler.
+ * This means that the linux layer can process interrupts.
+ *
+ * Arguments:
+ * sdio SDIO context pointer
+ *
+ * Returns:
+ * Status of the removal.
+ * ---------------------------------------------------------------------------
+ */
+int
+csr_sdio_linux_install_irq(CsrSdioFunction *function)
+{
+ struct sdio_func *func = (struct sdio_func *)function->priv;
+ int r;
+
+ unifi_trace(NULL, UDBG1, "csr_sdio_linux_install_irq\n");
+
+ /* Register our interrupt handle */
+ sdio_claim_host(func);
+ r = sdio_claim_irq(func, uf_glue_sdio_int_handler);
+ sdio_release_host(func);
+
+ /* If the interrupt was installed earlier, is fine */
+ if (r == -EBUSY) {
+ r = 0;
+ }
+
+ return r;
+} /* csr_sdio_linux_install_irq() */
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,32)
+#ifdef CONFIG_PM
+
+/*
+ * Power Management notifier
+ */
+struct uf_sdio_mmc_pm_notifier
+{
+ struct list_head list;
+
+ CsrSdioFunction *sdio_ctx;
+ struct notifier_block pm_notifier;
+};
+
+/* PM notifier list head */
+static struct uf_sdio_mmc_pm_notifier uf_sdio_mmc_pm_notifiers = {
+ .sdio_ctx = NULL,
+};
+
+/*
+ * ---------------------------------------------------------------------------
+ * uf_sdio_mmc_register_pm_notifier
+ * uf_sdio_mmc_unregister_pm_notifier
+ *
+ * Register/unregister for power management events. A list is used to
+ * allow multiple card instances to be supported.
+ *
+ * Arguments:
+ * sdio_ctx - CSR SDIO context to associate PM notifier to
+ *
+ * Returns:
+ * Register function returns NULL on error
+ * ---------------------------------------------------------------------------
+ */
+static struct uf_sdio_mmc_pm_notifier *
+uf_sdio_mmc_register_pm_notifier(CsrSdioFunction *sdio_ctx)
+{
+ /* Allocate notifier context for this card instance */
+ struct uf_sdio_mmc_pm_notifier *notifier_ctx = kmalloc(sizeof(struct uf_sdio_mmc_pm_notifier), GFP_KERNEL);
+
+ if (notifier_ctx)
+ {
+ notifier_ctx->sdio_ctx = sdio_ctx;
+ notifier_ctx->pm_notifier.notifier_call = uf_sdio_mmc_power_event;
+
+ list_add(&notifier_ctx->list, &uf_sdio_mmc_pm_notifiers.list);
+
+ if (register_pm_notifier(&notifier_ctx->pm_notifier)) {
+ printk(KERN_ERR "unifi: register_pm_notifier failed\n");
+ }
+ }
+
+ return notifier_ctx;
+}
+
+static void
+uf_sdio_mmc_unregister_pm_notifier(CsrSdioFunction *sdio_ctx)
+{
+ struct uf_sdio_mmc_pm_notifier *notifier_ctx;
+ struct list_head *node, *q;
+
+ list_for_each_safe(node, q, &uf_sdio_mmc_pm_notifiers.list) {
+ notifier_ctx = list_entry(node, struct uf_sdio_mmc_pm_notifier, list);
+
+ /* If it matches, unregister and free the notifier context */
+ if (notifier_ctx && notifier_ctx->sdio_ctx == sdio_ctx)
+ {
+ if (unregister_pm_notifier(&notifier_ctx->pm_notifier)) {
+ printk(KERN_ERR "unifi: unregister_pm_notifier failed\n");
+ }
+
+ /* Remove from list */
+ notifier_ctx->sdio_ctx = NULL;
+ list_del(node);
+ kfree(notifier_ctx);
+ }
+ }
+}
+
+/*
+ * ---------------------------------------------------------------------------
+ * uf_sdio_mmc_power_event
+ *
+ * Handler for power management events.
+ *
+ * We need to handle suspend/resume events while the userspace is unsuspended
+ * to allow the SME to run its suspend/resume state machines.
+ *
+ * Arguments:
+ * event event ID
+ *
+ * Returns:
+ * Status of the event handling
+ * ---------------------------------------------------------------------------
+ */
+static int
+uf_sdio_mmc_power_event(struct notifier_block *this, unsigned long event, void *ptr)
+{
+ struct uf_sdio_mmc_pm_notifier *notifier_ctx = container_of(this,
+ struct uf_sdio_mmc_pm_notifier,
+ pm_notifier);
+
+ /* Call the CSR SDIO function driver's suspend/resume method
+ * while the userspace is unsuspended.
+ */
+ switch (event) {
+ case PM_POST_HIBERNATION:
+ case PM_POST_SUSPEND:
+ printk(KERN_INFO "%s:%d resume\n", __FUNCTION__, __LINE__ );
+ if (sdio_func_drv && sdio_func_drv->resume) {
+ sdio_func_drv->resume(notifier_ctx->sdio_ctx);
+ }
+ break;
+
+ case PM_HIBERNATION_PREPARE:
+ case PM_SUSPEND_PREPARE:
+ printk(KERN_INFO "%s:%d suspend\n", __FUNCTION__, __LINE__ );
+ if (sdio_func_drv && sdio_func_drv->suspend) {
+ sdio_func_drv->suspend(notifier_ctx->sdio_ctx);
+ }
+ break;
+ }
+ return NOTIFY_DONE;
+}
+
+#endif /* CONFIG_PM */
+#endif /* 2.6.32 */
+
+/*
+ * ---------------------------------------------------------------------------
+ * uf_glue_sdio_probe
+ *
+ * Card insert callback.
+ *
+ * Arguments:
+ * func Our (glue layer) context pointer.
+ *
+ * Returns:
+ * UniFi driver error code.
+ * ---------------------------------------------------------------------------
+ */
+static int
+uf_glue_sdio_probe(struct sdio_func *func,
+ const struct sdio_device_id *id)
+{
+ int instance;
+ CsrSdioFunction *sdio_ctx;
+
+ func_enter();
+
+ /* First of all claim the SDIO driver */
+ sdio_claim_host(func);
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,32)
+ /* Assume that the card is already powered */
+ card_is_powered = 1;
+#endif
+
+ /* Assumes one card per host, which is true for SDIO */
+ instance = func->card->host->index;
+ printk("sdio bus_id: %16s - UniFi card 0x%X inserted\n",
+ sdio_func_id(func), instance);
+
+ /* Allocate context */
+ sdio_ctx = (CsrSdioFunction *)kmalloc(sizeof(CsrSdioFunction),
+ GFP_KERNEL);
+ if (sdio_ctx == NULL) {
+ sdio_release_host(func);
+ return -ENOMEM;
+ }
+
+ /* Initialise the context */
+ sdio_ctx->sdioId.manfId = func->vendor;
+ sdio_ctx->sdioId.cardId = func->device;
+ sdio_ctx->sdioId.sdioFunction = func->num;
+ sdio_ctx->sdioId.sdioInterface = func->class;
+ sdio_ctx->blockSize = func->cur_blksize;
+ sdio_ctx->priv = (void *)func;
+ sdio_ctx->features = 0;
+
+ /* Module parameter enables byte mode */
+ if (sdio_byte_mode) {
+ sdio_ctx->features |= CSR_SDIO_FEATURE_BYTE_MODE;
+ }
+
+ if (func->card->host->caps & MMC_CAP_SD_HIGHSPEED) {
+ unifi_trace(NULL, UDBG1, "MMC_CAP_SD_HIGHSPEED is available\n");
+ }
+
+#ifdef MMC_QUIRK_LENIENT_FN0
+ func->card->quirks |= MMC_QUIRK_LENIENT_FN0;
+#endif
+
+ /* Pass context to the SDIO driver */
+ sdio_set_drvdata(func, sdio_ctx);
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,32)
+#ifdef CONFIG_PM
+ /* Register to get PM events */
+ if (uf_sdio_mmc_register_pm_notifier(sdio_ctx) == NULL) {
+ unifi_error(NULL, "%s: Failed to register for PM events\n", __FUNCTION__);
+ }
+#endif
+#endif
+
+ /* Register this device with the SDIO function driver */
+ /* Call the main UniFi driver inserted handler */
+ if (sdio_func_drv && sdio_func_drv->inserted) {
+ uf_add_os_device(instance, &func->dev);
+ sdio_func_drv->inserted(sdio_ctx);
+ }
+
+ /* We have finished, so release the SDIO driver */
+ sdio_release_host(func);
+
+#ifdef ANDROID_BUILD
+ /* Take the wakelock */
+ unifi_trace(NULL, UDBG1, "probe: take wake lock\n");
+ wake_lock(&unifi_sdio_wake_lock);
+#endif
+
+ func_exit();
+ return 0;
+} /* uf_glue_sdio_probe() */
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * uf_glue_sdio_remove
+ *
+ * Card removal callback.
+ *
+ * Arguments:
+ * func Our (glue layer) context pointer.
+ *
+ * Returns:
+ * UniFi driver error code.
+ * ---------------------------------------------------------------------------
+ */
+static void
+uf_glue_sdio_remove(struct sdio_func *func)
+{
+ CsrSdioFunction *sdio_ctx;
+
+ sdio_ctx = sdio_get_drvdata(func);
+ if (!sdio_ctx) {
+ return;
+ }
+
+ func_enter();
+
+ unifi_info(NULL, "UniFi card removed\n");
+
+ /* Clean up the SDIO function driver */
+ if (sdio_func_drv && sdio_func_drv->removed) {
+ uf_remove_os_device(func->card->host->index);
+ sdio_func_drv->removed(sdio_ctx);
+ }
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,32)
+#ifdef CONFIG_PM
+ /* Unregister for PM events */
+ uf_sdio_mmc_unregister_pm_notifier(sdio_ctx);
+#endif
+#endif
+
+ kfree(sdio_ctx);
+
+ func_exit();
+
+} /* uf_glue_sdio_remove */
+
+
+/*
+ * SDIO ids *must* be statically declared, so we can't take
+ * them from the list passed in csr_sdio_register_driver().
+ */
+static const struct sdio_device_id unifi_ids[] = {
+ { SDIO_DEVICE(SDIO_MANF_ID_CSR,SDIO_CARD_ID_UNIFI_3) },
+ { SDIO_DEVICE(SDIO_MANF_ID_CSR,SDIO_CARD_ID_UNIFI_4) },
+ { /* end: all zeroes */ },
+};
+
+MODULE_DEVICE_TABLE(sdio, unifi_ids);
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,32)
+#ifdef CONFIG_PM
+
+/*
+ * ---------------------------------------------------------------------------
+ * uf_glue_sdio_suspend
+ *
+ * Card suspend callback. The userspace will already be suspended.
+ *
+ * Arguments:
+ * dev The struct device owned by the MMC driver
+ *
+ * Returns:
+ * None
+ * ---------------------------------------------------------------------------
+ */
+static int
+uf_glue_sdio_suspend(struct device *dev)
+{
+ func_enter();
+
+ unifi_trace(NULL, UDBG1, "uf_glue_sdio_suspend");
+
+ func_exit();
+ return 0;
+} /* uf_glue_sdio_suspend */
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * uf_glue_sdio_resume
+ *
+ * Card resume callback. The userspace will still be suspended.
+ *
+ * Arguments:
+ * dev The struct device owned by the MMC driver
+ *
+ * Returns:
+ * None
+ * ---------------------------------------------------------------------------
+ */
+static int
+uf_glue_sdio_resume(struct device *dev)
+{
+ func_enter();
+
+ unifi_trace(NULL, UDBG1, "uf_glue_sdio_resume");
+
+#ifdef ANDROID_BUILD
+ unifi_trace(NULL, UDBG1, "resume: take wakelock\n");
+ wake_lock(&unifi_sdio_wake_lock);
+#endif
+
+ func_exit();
+ return 0;
+
+} /* uf_glue_sdio_resume */
+
+static struct dev_pm_ops unifi_pm_ops = {
+ .suspend = uf_glue_sdio_suspend,
+ .resume = uf_glue_sdio_resume,
+};
+
+#define UNIFI_PM_OPS (&unifi_pm_ops)
+
+#else
+
+#define UNIFI_PM_OPS NULL
+
+#endif /* CONFIG_PM */
+#endif /* 2.6.32 */
+
+static struct sdio_driver unifi_driver = {
+ .probe = uf_glue_sdio_probe,
+ .remove = uf_glue_sdio_remove,
+ .name = "unifi",
+ .id_table = unifi_ids,
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,32)
+ .drv.pm = UNIFI_PM_OPS,
+#endif /* 2.6.32 */
+};
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * CsrSdioFunctionDriverRegister
+ * CsrSdioFunctionDriverUnregister
+ *
+ * These functions are called from the main module load and unload
+ * functions. They perform the appropriate operations for the
+ * linux MMC/SDIO driver.
+ *
+ * Arguments:
+ * sdio_drv Pointer to the function driver's SDIO structure.
+ *
+ * Returns:
+ * None.
+ * ---------------------------------------------------------------------------
+ */
+CsrResult
+CsrSdioFunctionDriverRegister(CsrSdioFunctionDriver *sdio_drv)
+{
+ int r;
+
+ printk("UniFi: Using native Linux MMC driver for SDIO.\n");
+
+ if (sdio_func_drv) {
+ unifi_error(NULL, "sdio_mmc: UniFi driver already registered\n");
+ return CSR_SDIO_RESULT_INVALID_VALUE;
+ }
+
+#ifdef ANDROID_BUILD
+ wake_lock_init(&unifi_sdio_wake_lock, WAKE_LOCK_SUSPEND, "unifi_sdio_work");
+#endif
+
+ /* Save the registered driver description */
+ /*
+ * FIXME:
+ * Need a table here to handle a call to register for just one function.
+ * mmc only allows us to register for the whole device
+ */
+ sdio_func_drv = sdio_drv;
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,32)
+#ifdef CONFIG_PM
+ /* Initialise PM notifier list */
+ INIT_LIST_HEAD(&uf_sdio_mmc_pm_notifiers.list);
+#endif
+#endif
+
+ /* Register ourself with mmc_core */
+ r = sdio_register_driver(&unifi_driver);
+ if (r) {
+ printk(KERN_ERR "unifi_sdio: Failed to register UniFi SDIO driver: %d\n", r);
+ return ConvertSdioToCsrSdioResult(r);
+ }
+
+ return CSR_RESULT_SUCCESS;
+} /* CsrSdioFunctionDriverRegister() */
+
+
+
+void
+CsrSdioFunctionDriverUnregister(CsrSdioFunctionDriver *sdio_drv)
+{
+ printk(KERN_INFO "UniFi: unregister from MMC sdio\n");
+
+#ifdef ANDROID_BUILD
+ wake_lock_destroy(&unifi_sdio_wake_lock);
+#endif
+ sdio_unregister_driver(&unifi_driver);
+
+ sdio_func_drv = NULL;
+
+} /* CsrSdioFunctionDriverUnregister() */
+
diff --git a/drivers/staging/csr/sdio_stubs.c b/drivers/staging/csr/sdio_stubs.c
new file mode 100644
index 000000000000..839fae01d96c
--- /dev/null
+++ b/drivers/staging/csr/sdio_stubs.c
@@ -0,0 +1,82 @@
+/*
+ * Stubs for some of the bottom edge functions.
+ *
+ * These stubs are optional functions in the bottom edge (SDIO driver
+ * interface) API that not all platforms or SDIO drivers may support.
+ *
+ * They're declared as weak symbols so they can be overridden by
+ * simply providing a non-weak declaration.
+ *
+ * Copyright (C) 2007-2008 by Cambridge Silicon Radio Ltd.
+ *
+ * Refer to LICENSE.txt included with this source code for details on
+ * the license terms.
+ *
+ */
+#include "csr_wifi_hip_unifi.h"
+
+void __attribute__((weak)) CsrSdioFunctionIdle(CsrSdioFunction *function)
+{
+}
+
+void __attribute__((weak)) CsrSdioFunctionActive(CsrSdioFunction *function)
+{
+}
+
+CsrResult __attribute__((weak)) CsrSdioPowerOn(CsrSdioFunction *function)
+{
+ return CSR_RESULT_SUCCESS;
+}
+
+void __attribute__((weak)) CsrSdioPowerOff(CsrSdioFunction *function)
+{
+}
+
+CsrResult __attribute__((weak)) CsrSdioHardReset(CsrSdioFunction *function)
+{
+ return CSR_SDIO_RESULT_NOT_RESET;
+}
+
+CsrResult __attribute__((weak)) CsrSdioBlockSizeSet(CsrSdioFunction *function,
+ u16 blockSize)
+{
+ return CSR_RESULT_SUCCESS;
+}
+
+CsrResult __attribute__((weak)) CsrSdioSuspend(CsrSdioFunction *function)
+{
+ return CSR_RESULT_SUCCESS;
+}
+
+CsrResult __attribute__((weak)) CsrSdioResume(CsrSdioFunction *function)
+{
+ return CSR_RESULT_SUCCESS;
+}
+
+int __attribute__((weak)) csr_sdio_linux_install_irq(CsrSdioFunction *function)
+{
+ return 0;
+}
+
+int __attribute__((weak)) csr_sdio_linux_remove_irq(CsrSdioFunction *function)
+{
+ return 0;
+}
+
+void __attribute__((weak)) CsrSdioInsertedAcknowledge(CsrSdioFunction *function, CsrResult result)
+{
+}
+
+void __attribute__((weak)) CsrSdioRemovedAcknowledge(CsrSdioFunction *function)
+{
+}
+
+void __attribute__((weak)) CsrSdioSuspendAcknowledge(CsrSdioFunction *function, CsrResult result)
+{
+}
+
+void __attribute__((weak)) CsrSdioResumeAcknowledge(CsrSdioFunction *function, CsrResult result)
+{
+}
+
+
diff --git a/drivers/staging/csr/sme_blocking.c b/drivers/staging/csr/sme_blocking.c
new file mode 100644
index 000000000000..acf0f0fe3b37
--- /dev/null
+++ b/drivers/staging/csr/sme_blocking.c
@@ -0,0 +1,1535 @@
+/*
+ * ---------------------------------------------------------------------------
+ * FILE: sme_mgt_blocking.c
+ *
+ * PURPOSE:
+ * This file contains the driver specific implementation of
+ * the WEXT <==> SME MGT interface for all SME builds that support WEXT.
+ *
+ * Copyright (C) 2009 by Cambridge Silicon Radio Ltd.
+ *
+ * Refer to LICENSE.txt included with this source code for details on
+ * the license terms.
+ *
+ * ---------------------------------------------------------------------------
+ */
+
+#include "unifi_priv.h"
+
+
+/*
+ * This file also contains the implementation of the asyncronous
+ * requests to the SME.
+ *
+ * Before calling an asyncronous SME function, we call sme_init_request()
+ * which gets hold of the SME semaphore and updates the request status.
+ * The semaphore makes sure that there is only one pending request to
+ * the SME at a time.
+ *
+ * Now we are ready to call the SME function, but only if
+ * sme_init_request() has returned 0.
+ *
+ * When the SME function returns, we need to wait
+ * for the reply. This is done in sme_wait_for_reply().
+ * If the request times-out, the request status is set to SME_REQUEST_TIMEDOUT
+ * and the sme_wait_for_reply() returns.
+ *
+ * If the SME replies in time, we call sme_complete_request().
+ * There we change the request status to SME_REQUEST_RECEIVED. This will
+ * wake up the process waiting on sme_wait_for_reply().
+ * It is important that we copy the reply data in priv->sme_reply
+ * before calling sme_complete_request().
+ *
+ * Handling the wext requests, we need to block
+ * until the SME sends the response to our request.
+ * We use the sme_init_request() and sme_wait_for_reply()
+ * to implement this behavior in the following functions:
+ * sme_mgt_wifi_on()
+ * sme_mgt_wifi_off()
+ * sme_mgt_scan_full()
+ * sme_mgt_scan_results_get_async()
+ * sme_mgt_connect()
+ * unifi_mgt_media_status_ind()
+ * sme_mgt_disconnect()
+ * sme_mgt_pmkid()
+ * sme_mgt_key()
+ * sme_mgt_mib_get()
+ * sme_mgt_mib_set()
+ * sme_mgt_versions_get()
+ * sme_mgt_set_value()
+ * sme_mgt_get_value()
+ * sme_mgt_set_value_async()
+ * sme_mgt_get_value_async()
+ * sme_mgt_packet_filter_set()
+ * sme_mgt_tspec()
+ */
+
+
+/*
+ * Handling the suspend and resume system events, we need to block
+ * until the SME sends the response to our indication.
+ * We use the sme_init_request() and sme_wait_for_reply()
+ * to implement this behavior in the following functions:
+ * sme_sys_suspend()
+ * sme_sys_resume()
+ */
+
+#define UNIFI_SME_MGT_SHORT_TIMEOUT 10000
+#define UNIFI_SME_MGT_LONG_TIMEOUT 19000
+#define UNIFI_SME_SYS_LONG_TIMEOUT 10000
+
+#ifdef UNIFI_DEBUG
+# define sme_wait_for_reply(priv, t) _sme_wait_for_reply(priv, t, __func__)
+#else
+# define sme_wait_for_reply(priv, t) _sme_wait_for_reply(priv, t, NULL)
+#endif
+
+static int
+sme_init_request(unifi_priv_t *priv)
+{
+ if (priv == NULL) {
+ unifi_error(priv, "sme_init_request: Invalid priv\n");
+ return -EIO;
+ }
+
+ unifi_trace(priv, UDBG5, "sme_init_request: wait sem\n");
+
+ /* Grab the SME semaphore until the reply comes, or timeout */
+ if (down_interruptible(&priv->sme_sem)) {
+ unifi_error(priv, "sme_init_request: Failed to get SME semaphore\n");
+ return -EIO;
+ }
+ unifi_trace(priv, UDBG5, "sme_init_request: got sem: pending\n");
+
+ priv->sme_reply.request_status = SME_REQUEST_PENDING;
+
+ return 0;
+
+} /* sme_init_request() */
+
+
+void
+uf_sme_complete_request(unifi_priv_t *priv, CsrResult reply_status, const char *func)
+{
+ if (priv == NULL) {
+ unifi_error(priv, "sme_complete_request: Invalid priv\n");
+ return;
+ }
+
+ if (priv->sme_reply.request_status != SME_REQUEST_PENDING) {
+ unifi_notice(priv,
+ "sme_complete_request: request not pending %s (s:%d)\n",
+ (func ? func : ""), priv->sme_reply.request_status);
+ return;
+ }
+ unifi_trace(priv, UDBG5,
+ "sme_complete_request: completed %s (s:%d)\n",
+ (func ? func : ""), priv->sme_reply.request_status);
+
+ priv->sme_reply.request_status = SME_REQUEST_RECEIVED;
+ priv->sme_reply.reply_status = reply_status;
+
+ wake_up_interruptible(&priv->sme_request_wq);
+
+ return;
+}
+
+
+void
+uf_sme_cancel_request(unifi_priv_t *priv, CsrResult reply_status)
+{
+ /* Check for a blocking SME request in progress, and cancel the wait.
+ * This should be used when the character device is closed.
+ */
+
+ if (priv == NULL) {
+ unifi_error(priv, "sme_cancel_request: Invalid priv\n");
+ return;
+ }
+
+ /* If no request is pending, nothing to wake up */
+ if (priv->sme_reply.request_status != SME_REQUEST_PENDING) {
+ unifi_trace(priv, UDBG5,
+ "sme_cancel_request: no request was pending (s:%d)\n",
+ priv->sme_reply.request_status);
+ /* Nothing to do */
+ return;
+ }
+ unifi_trace(priv, UDBG5,
+ "sme_cancel_request: request cancelled (s:%d)\n",
+ priv->sme_reply.request_status);
+
+ /* Wake up the wait with an error status */
+ priv->sme_reply.request_status = SME_REQUEST_CANCELLED;
+ priv->sme_reply.reply_status = reply_status; /* unimportant since the CANCELLED state will fail the ioctl */
+
+ wake_up_interruptible(&priv->sme_request_wq);
+
+ return;
+}
+
+
+static int
+_sme_wait_for_reply(unifi_priv_t *priv,
+ unsigned long timeout, const char *func)
+{
+ long r;
+
+ unifi_trace(priv, UDBG5, "sme_wait_for_reply: %s sleep\n", func ? func : "");
+ r = wait_event_interruptible_timeout(priv->sme_request_wq,
+ (priv->sme_reply.request_status != SME_REQUEST_PENDING),
+ msecs_to_jiffies(timeout));
+ unifi_trace(priv, UDBG5, "sme_wait_for_reply: %s awake (%d)\n", func ? func : "", r);
+
+ if (r == -ERESTARTSYS) {
+ /* The thread was killed */
+ unifi_info(priv, "ERESTARTSYS in _sme_wait_for_reply\n");
+ up(&priv->sme_sem);
+ return r;
+ }
+ if (priv->sme_reply.request_status == SME_REQUEST_CANCELLED) {
+ unifi_trace(priv, UDBG5, "Cancelled waiting for SME to reply (%s s:%d, t:%d, r:%d)\n",
+ (func ? func : ""), priv->sme_reply.request_status, timeout, r);
+
+ /* Release the SME semaphore that was downed in sme_init_request() */
+ up(&priv->sme_sem);
+ return -EIO; /* fail the ioctl */
+ }
+ if ((r == 0) && (priv->sme_reply.request_status != SME_REQUEST_RECEIVED)) {
+ unifi_notice(priv, "Timeout waiting for SME to reply (%s s:%d, t:%d)\n",
+ (func ? func : ""), priv->sme_reply.request_status, timeout);
+
+ priv->sme_reply.request_status = SME_REQUEST_TIMEDOUT;
+
+ /* Release the SME semaphore that was downed in sme_init_request() */
+ up(&priv->sme_sem);
+
+ return -ETIMEDOUT;
+ }
+
+ unifi_trace(priv, UDBG5, "sme_wait_for_reply: %s received (%d)\n",
+ func ? func : "", r);
+
+ /* Release the SME semaphore that was downed in sme_init_request() */
+ up(&priv->sme_sem);
+
+ return 0;
+} /* sme_wait_for_reply() */
+
+
+
+
+#ifdef CSR_SUPPORT_WEXT
+int sme_mgt_wifi_on(unifi_priv_t *priv)
+{
+ u16 numElements;
+ CsrWifiSmeDataBlock* dataList;
+#ifdef CSR_SUPPORT_WEXT_AP
+ int r;
+#endif
+
+ if (priv->smepriv == NULL) {
+ unifi_error(priv, "sme_mgt_wifi_on: invalid smepriv\n");
+ return -EIO;
+ }
+
+ if (priv->mib_data.length) {
+ numElements = 1;
+ dataList = &priv->mib_data;
+ } else {
+ numElements = 0;
+ dataList = NULL;
+ }
+ /* Start the SME */
+#ifdef CSR_SUPPORT_WEXT_AP
+ r = sme_init_request(priv);
+ if (r) {
+ return -EIO;
+ }
+#endif
+ CsrWifiSmeWifiOnReqSend(0, priv->sta_mac_address, numElements, dataList);
+#ifdef CSR_SUPPORT_WEXT_AP
+ r = sme_wait_for_reply(priv, UNIFI_SME_MGT_LONG_TIMEOUT);
+ unifi_trace(priv, UDBG4,
+ "sme_mgt_wifi_on: unifi_mgt_wifi_oo_req <-- (r=%d, status=%d)\n",
+ r, priv->sme_reply.reply_status);
+ return convert_sme_error(priv->sme_reply.reply_status);
+#else
+ return 0;
+#endif
+} /* sme_mgt_wifi_on() */
+
+
+int sme_mgt_wifi_off(unifi_priv_t *priv)
+{
+ int r;
+
+ if (priv->smepriv == NULL) {
+ unifi_error(priv, "sme_mgt_wifi_off: invalid smepriv\n");
+ return -EIO;
+ }
+
+ r = sme_init_request(priv);
+ if (r) {
+ return -EIO;
+ }
+
+ /* Stop the SME */
+ CsrWifiSmeWifiOffReqSend(0);
+
+ r = sme_wait_for_reply(priv, UNIFI_SME_MGT_LONG_TIMEOUT);
+ if (r) {
+ return r;
+ }
+
+ unifi_trace(priv, UDBG4,
+ "sme_mgt_wifi_off: unifi_mgt_wifi_off_req <-- (r=%d, status=%d)\n",
+ r, priv->sme_reply.reply_status);
+ return convert_sme_error(priv->sme_reply.reply_status);
+
+} /* sme_mgt_wifi_off */
+
+int sme_mgt_key(unifi_priv_t *priv, CsrWifiSmeKey *sme_key,
+ CsrWifiSmeListAction action)
+{
+ int r;
+
+ if (priv->smepriv == NULL) {
+ unifi_error(priv, "sme_mgt_key: invalid smepriv\n");
+ return -EIO;
+ }
+
+ r = sme_init_request(priv);
+ if (r) {
+ return -EIO;
+ }
+
+ CsrWifiSmeKeyReqSend(0, CSR_WIFI_INTERFACE_IN_USE, action, *sme_key);
+
+ r = sme_wait_for_reply(priv, UNIFI_SME_MGT_SHORT_TIMEOUT);
+ if (r) {
+ return r;
+ }
+
+ return convert_sme_error(priv->sme_reply.reply_status);
+}
+
+
+int sme_mgt_scan_full(unifi_priv_t *priv,
+ CsrWifiSsid *specific_ssid,
+ int num_channels,
+ unsigned char *channel_list)
+{
+ CsrWifiMacAddress bcastAddress = {{0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }};
+ u8 is_active = (num_channels > 0) ? TRUE : FALSE;
+ int r;
+
+ if (priv->smepriv == NULL) {
+ unifi_error(priv, "sme_mgt_scan_full: invalid smepriv\n");
+ return -EIO;
+ }
+
+ unifi_trace(priv, UDBG4, "sme_mgt_scan_full: -->\n");
+
+ r = sme_init_request(priv);
+ if (r) {
+ return -EIO;
+ }
+
+ /* If a channel list is provided, do an active scan */
+ if (is_active) {
+ unifi_trace(priv, UDBG1,
+ "channel list - num_channels: %d, active scan\n",
+ num_channels);
+ }
+
+ CsrWifiSmeScanFullReqSend(0,
+ specific_ssid->length?1:0, /* 0 or 1 SSIDS */
+ specific_ssid,
+ bcastAddress,
+ is_active,
+ CSR_WIFI_SME_BSS_TYPE_ANY_BSS,
+ CSR_WIFI_SME_SCAN_TYPE_ALL,
+ (u16)num_channels, channel_list,
+ 0, NULL);
+
+ r = sme_wait_for_reply(priv, UNIFI_SME_MGT_LONG_TIMEOUT);
+ if (r) {
+ return r;
+ }
+
+ unifi_trace(priv, UDBG4, "sme_mgt_scan_full: <-- (status=%d)\n", priv->sme_reply.reply_status);
+ if (priv->sme_reply.reply_status == CSR_WIFI_RESULT_UNAVAILABLE) {
+ return 0; /* initial scan already underway */
+ } else {
+ return convert_sme_error(priv->sme_reply.reply_status);
+ }
+}
+
+
+int sme_mgt_scan_results_get_async(unifi_priv_t *priv,
+ struct iw_request_info *info,
+ char *scan_results,
+ long scan_results_len)
+{
+ u16 scan_result_list_count;
+ CsrWifiSmeScanResult *scan_result_list;
+ CsrWifiSmeScanResult *scan_result;
+ int r;
+ int i;
+ char *current_ev = scan_results;
+
+ if (priv->smepriv == NULL) {
+ unifi_error(priv, "sme_mgt_scan_results_get_async: invalid smepriv\n");
+ return -EIO;
+ }
+
+ r = sme_init_request(priv);
+ if (r) {
+ return -EIO;
+ }
+
+ CsrWifiSmeScanResultsGetReqSend(0);
+ r = sme_wait_for_reply(priv, UNIFI_SME_MGT_LONG_TIMEOUT);
+ if (r) {
+ return r;
+ }
+
+ scan_result_list_count = priv->sme_reply.reply_scan_results_count;
+ scan_result_list = priv->sme_reply.reply_scan_results;
+ unifi_trace(priv, UDBG2,
+ "scan_results: Scan returned %d, numElements=%d\n",
+ r, scan_result_list_count);
+
+ /* OK, now we have the scan results */
+ for (i = 0; i < scan_result_list_count; ++i) {
+ scan_result = &scan_result_list[i];
+
+ unifi_trace(priv, UDBG2, "Scan Result: %.*s\n",
+ scan_result->ssid.length,
+ scan_result->ssid.ssid);
+
+ r = unifi_translate_scan(priv->netdev[0], info,
+ current_ev,
+ scan_results + scan_results_len,
+ scan_result, i+1);
+
+ if (r < 0) {
+ kfree(scan_result_list);
+ priv->sme_reply.reply_scan_results_count = 0;
+ priv->sme_reply.reply_scan_results = NULL;
+ return r;
+ }
+
+ current_ev += r;
+ }
+
+ /*
+ * Free the scan results allocated in unifi_mgt_scan_results_get_cfm()
+ * and invalidate the reply_scan_results to avoid re-using
+ * the freed pointers.
+ */
+ kfree(scan_result_list);
+ priv->sme_reply.reply_scan_results_count = 0;
+ priv->sme_reply.reply_scan_results = NULL;
+
+ unifi_trace(priv, UDBG2,
+ "scan_results: Scan translated to %d bytes\n",
+ current_ev - scan_results);
+ return (current_ev - scan_results);
+}
+
+
+int sme_mgt_connect(unifi_priv_t *priv)
+{
+ int r;
+
+ if (priv->smepriv == NULL) {
+ unifi_error(priv, "sme_mgt_connect: invalid smepriv\n");
+ return -EIO;
+ }
+
+ unifi_trace(priv, UDBG2, "sme_mgt_connect: %.*s\n",
+ priv->connection_config.ssid.length,
+ priv->connection_config.ssid.ssid);
+
+ r = sme_init_request(priv);
+ if (r) {
+ return -EIO;
+ }
+
+ CsrWifiSmeConnectReqSend(0, CSR_WIFI_INTERFACE_IN_USE, priv->connection_config);
+ r = sme_wait_for_reply(priv, UNIFI_SME_MGT_SHORT_TIMEOUT);
+ if (r) {
+ return r;
+ }
+
+ if (priv->sme_reply.reply_status) {
+ unifi_trace(priv, UDBG1, "sme_mgt_connect: failed with SME status %d\n",
+ priv->sme_reply.reply_status);
+ }
+
+ return convert_sme_error(priv->sme_reply.reply_status);
+}
+
+
+int sme_mgt_disconnect(unifi_priv_t *priv)
+{
+ int r;
+
+ if (priv->smepriv == NULL) {
+ unifi_error(priv, "sme_mgt_disconnect: invalid smepriv\n");
+ return -EIO;
+ }
+
+ r = sme_init_request(priv);
+ if (r) {
+ return -EIO;
+ }
+
+ CsrWifiSmeDisconnectReqSend(0, CSR_WIFI_INTERFACE_IN_USE);
+ r = sme_wait_for_reply(priv, UNIFI_SME_MGT_SHORT_TIMEOUT);
+ if (r) {
+ return r;
+ }
+
+ unifi_trace(priv, UDBG4, "sme_mgt_disconnect: <-- (status=%d)\n", priv->sme_reply.reply_status);
+ return convert_sme_error(priv->sme_reply.reply_status);
+}
+
+
+int sme_mgt_pmkid(unifi_priv_t *priv,
+ CsrWifiSmeListAction action,
+ CsrWifiSmePmkidList *pmkid_list)
+{
+ int r;
+
+ if (priv->smepriv == NULL) {
+ unifi_error(priv, "sme_mgt_pmkid: invalid smepriv\n");
+ return -EIO;
+ }
+
+ r = sme_init_request(priv);
+ if (r) {
+ return -EIO;
+ }
+
+ CsrWifiSmePmkidReqSend(0, CSR_WIFI_INTERFACE_IN_USE, action,
+ pmkid_list->pmkidsCount, pmkid_list->pmkids);
+ r = sme_wait_for_reply(priv, UNIFI_SME_MGT_SHORT_TIMEOUT);
+ if (r) {
+ return r;
+ }
+
+ unifi_trace(priv, UDBG4, "sme_mgt_pmkid: <-- (status=%d)\n", priv->sme_reply.reply_status);
+ return convert_sme_error(priv->sme_reply.reply_status);
+}
+
+
+int sme_mgt_mib_get(unifi_priv_t *priv,
+ unsigned char *varbind, int *length)
+{
+ int r;
+
+ if (priv->smepriv == NULL) {
+ unifi_error(priv, "sme_mgt_mib_get: invalid smepriv\n");
+ return -EIO;
+ }
+
+ r = sme_init_request(priv);
+ if (r) {
+ return -EIO;
+ }
+
+ priv->mib_cfm_buffer = varbind;
+ priv->mib_cfm_buffer_length = MAX_VARBIND_LENGTH;
+
+ CsrWifiSmeMibGetReqSend(0, *length, varbind);
+ r = sme_wait_for_reply(priv, UNIFI_SME_MGT_SHORT_TIMEOUT);
+ if (r) {
+ priv->mib_cfm_buffer_length = 0;
+ priv->mib_cfm_buffer = NULL;
+ return r;
+ }
+
+ *length = priv->mib_cfm_buffer_length;
+
+ priv->mib_cfm_buffer_length = 0;
+ priv->mib_cfm_buffer = NULL;
+ unifi_trace(priv, UDBG4, "sme_mgt_mib_get: <-- (status=%d)\n", priv->sme_reply.reply_status);
+ return convert_sme_error(priv->sme_reply.reply_status);
+}
+
+int sme_mgt_mib_set(unifi_priv_t *priv,
+ unsigned char *varbind, int length)
+{
+ int r;
+
+ if (priv->smepriv == NULL) {
+ unifi_error(priv, "sme_mgt_mib_get: invalid smepriv\n");
+ return -EIO;
+ }
+
+ r = sme_init_request(priv);
+ if (r) {
+ return -EIO;
+ }
+
+ CsrWifiSmeMibSetReqSend(0, length, varbind);
+ r = sme_wait_for_reply(priv, UNIFI_SME_MGT_SHORT_TIMEOUT);
+ if (r) {
+ return r;
+ }
+
+ unifi_trace(priv, UDBG4, "sme_mgt_mib_set: <-- (status=%d)\n", priv->sme_reply.reply_status);
+ return convert_sme_error(priv->sme_reply.reply_status);
+}
+
+#endif /* CSR_SUPPORT_WEXT */
+
+int sme_mgt_power_config_set(unifi_priv_t *priv, CsrWifiSmePowerConfig *powerConfig)
+{
+#ifdef CSR_SME_USERSPACE
+ int r;
+
+ if (priv->smepriv == NULL) {
+ unifi_error(priv, "sme_mgt_set_value_async: invalid smepriv\n");
+ return -EIO;
+ }
+
+ r = sme_init_request(priv);
+ if (r) {
+ return -EIO;
+ }
+
+ CsrWifiSmePowerConfigSetReqSend(0, *powerConfig);
+
+ r = sme_wait_for_reply(priv, UNIFI_SME_MGT_SHORT_TIMEOUT);
+ if (r) {
+ return r;
+ }
+
+ unifi_trace(priv, UDBG4,
+ "sme_mgt_set_value_async: unifi_mgt_set_value_req <-- (r=%d status=%d)\n",
+ r, priv->sme_reply.reply_status);
+ return convert_sme_error(priv->sme_reply.reply_status);
+#else
+ CsrResult status;
+ if (priv->smepriv == NULL) {
+ unifi_error(priv, "sme_mgt_set_value: invalid smepriv\n");
+ return -EIO;
+ }
+ CsrWifiSmeMgtClaimSyncAccess(priv->smepriv);
+ status = CsrWifiSmeMgtPowerConfigSetReq(priv->smepriv, *powerConfig);
+ CsrWifiSmeMgtReleaseSyncAccess(priv->smepriv);
+ return convert_sme_error(status);
+#endif
+}
+
+int sme_mgt_sme_config_set(unifi_priv_t *priv, CsrWifiSmeStaConfig *staConfig, CsrWifiSmeDeviceConfig *deviceConfig)
+{
+#ifdef CSR_SME_USERSPACE
+ int r;
+
+ if (priv->smepriv == NULL) {
+ unifi_error(priv, "sme_mgt_sme_config_set: invalid smepriv\n");
+ return -EIO;
+ }
+
+ r = sme_init_request(priv);
+ if (r) {
+ return -EIO;
+ }
+
+ CsrWifiSmeSmeStaConfigSetReqSend(0, CSR_WIFI_INTERFACE_IN_USE, *staConfig);
+ r = sme_wait_for_reply(priv, UNIFI_SME_MGT_SHORT_TIMEOUT);
+ if (r) {
+ return r;
+ }
+ unifi_trace(priv, UDBG4,
+ "sme_mgt_sme_config_set: CsrWifiSmeSmeStaConfigSetReq <-- (r=%d status=%d)\n",
+ r, priv->sme_reply.reply_status);
+
+ r = sme_init_request(priv);
+ if (r) {
+ return -EIO;
+ }
+
+ CsrWifiSmeSmeCommonConfigSetReqSend(0, *deviceConfig);
+ r = sme_wait_for_reply(priv, UNIFI_SME_MGT_SHORT_TIMEOUT);
+ if (r) {
+ return r;
+ }
+
+ unifi_trace(priv, UDBG4,
+ "sme_mgt_sme_config_set: CsrWifiSmeSmeCommonConfigSetReq <-- (r=%d status=%d)\n",
+ r, priv->sme_reply.reply_status);
+
+ return convert_sme_error(priv->sme_reply.reply_status);
+#else
+ CsrResult status;
+ if (priv->smepriv == NULL) {
+ unifi_error(priv, "sme_mgt_sme_config_set: invalid smepriv\n");
+ return -EIO;
+ }
+ CsrWifiSmeMgtClaimSyncAccess(priv->smepriv);
+ status = CsrWifiSmeMgtSmeConfigSetReq(priv->smepriv, *staConfig);
+ status = CsrWifiSmeMgtDeviceConfigSetReq(priv->smepriv, *deviceConfig);
+ CsrWifiSmeMgtReleaseSyncAccess(priv->smepriv);
+ return convert_sme_error(status);
+#endif
+}
+
+#ifdef CSR_SUPPORT_WEXT
+
+int sme_mgt_mib_config_set(unifi_priv_t *priv, CsrWifiSmeMibConfig *mibConfig)
+{
+#ifdef CSR_SME_USERSPACE
+ int r;
+
+ if (priv->smepriv == NULL) {
+ unifi_error(priv, "sme_mgt_mib_config_set: invalid smepriv\n");
+ return -EIO;
+ }
+
+ r = sme_init_request(priv);
+ if (r) {
+ return -EIO;
+ }
+
+ CsrWifiSmeMibConfigSetReqSend(0, *mibConfig);
+
+ r = sme_wait_for_reply(priv, UNIFI_SME_MGT_SHORT_TIMEOUT);
+ if (r) {
+ return r;
+ }
+
+ unifi_trace(priv, UDBG4,
+ "sme_mgt_mib_config_set: unifi_mgt_set_mib_config_req <-- (r=%d status=%d)\n",
+ r, priv->sme_reply.reply_status);
+ return convert_sme_error(priv->sme_reply.reply_status);
+#else
+ CsrResult status;
+ if (priv->smepriv == NULL) {
+ unifi_error(priv, "sme_mgt_mib_config_set: invalid smepriv\n");
+ return -EIO;
+ }
+ CsrWifiSmeMgtClaimSyncAccess(priv->smepriv);
+ status = CsrWifiSmeMgtMibConfigSetReq(priv->smepriv, *mibConfig);
+ CsrWifiSmeMgtReleaseSyncAccess(priv->smepriv);
+ return convert_sme_error(status);
+#endif
+}
+
+int sme_mgt_coex_config_set(unifi_priv_t *priv, CsrWifiSmeCoexConfig *coexConfig)
+{
+#ifdef CSR_SME_USERSPACE
+ int r;
+
+ if (priv->smepriv == NULL) {
+ unifi_error(priv, "sme_mgt_coex_config_set: invalid smepriv\n");
+ return -EIO;
+ }
+
+ r = sme_init_request(priv);
+ if (r) {
+ return -EIO;
+ }
+
+ CsrWifiSmeCoexConfigSetReqSend(0, *coexConfig);
+
+ r = sme_wait_for_reply(priv, UNIFI_SME_MGT_SHORT_TIMEOUT);
+ if (r) {
+ return r;
+ }
+
+ unifi_trace(priv, UDBG4,
+ "sme_mgt_coex_config_set: unifi_mgt_set_mib_config_req <-- (r=%d status=%d)\n",
+ r, priv->sme_reply.reply_status);
+ return convert_sme_error(priv->sme_reply.reply_status);
+#else
+ CsrResult status;
+ if (priv->smepriv == NULL) {
+ unifi_error(priv, "sme_mgt_coex_config_set: invalid smepriv\n");
+ return -EIO;
+ }
+ CsrWifiSmeMgtClaimSyncAccess(priv->smepriv);
+ status = CsrWifiSmeMgtCoexConfigSetReq(priv->smepriv, *coexConfig);
+ CsrWifiSmeMgtReleaseSyncAccess(priv->smepriv);
+ return convert_sme_error(status);
+#endif
+}
+
+#endif /* CSR_SUPPORT_WEXT */
+
+int sme_mgt_host_config_set(unifi_priv_t *priv, CsrWifiSmeHostConfig *hostConfig)
+{
+#ifdef CSR_SME_USERSPACE
+ int r;
+
+ if (priv->smepriv == NULL) {
+ unifi_error(priv, "sme_mgt_host_config_set: invalid smepriv\n");
+ return -EIO;
+ }
+
+ r = sme_init_request(priv);
+ if (r) {
+ return -EIO;
+ }
+
+ CsrWifiSmeHostConfigSetReqSend(0, CSR_WIFI_INTERFACE_IN_USE, *hostConfig);
+
+ r = sme_wait_for_reply(priv, UNIFI_SME_MGT_SHORT_TIMEOUT);
+ if (r) {
+ return r;
+ }
+
+ unifi_trace(priv, UDBG4,
+ "sme_mgt_host_config_set: unifi_mgt_set_host_config_req <-- (r=%d status=%d)\n",
+ r, priv->sme_reply.reply_status);
+ return convert_sme_error(priv->sme_reply.reply_status);
+#else
+ CsrResult status;
+ if (priv->smepriv == NULL) {
+ unifi_error(priv, "sme_mgt_host_config_set: invalid smepriv\n");
+ return -EIO;
+ }
+ CsrWifiSmeMgtClaimSyncAccess(priv->smepriv);
+ status = CsrWifiSmeMgtHostConfigSetReq(priv->smepriv, *hostConfig);
+ CsrWifiSmeMgtReleaseSyncAccess(priv->smepriv);
+ return convert_sme_error(status);
+#endif
+}
+
+#ifdef CSR_SUPPORT_WEXT
+
+int sme_mgt_versions_get(unifi_priv_t *priv, CsrWifiSmeVersions *versions)
+{
+#ifdef CSR_SME_USERSPACE
+ int r;
+
+ if (priv->smepriv == NULL) {
+ unifi_error(priv, "sme_mgt_versions_get: invalid smepriv\n");
+ return -EIO;
+ }
+
+ unifi_trace(priv, UDBG4, "sme_mgt_versions_get: unifi_mgt_versions_get_req -->\n");
+ r = sme_init_request(priv);
+ if (r) {
+ return -EIO;
+ }
+
+ CsrWifiSmeVersionsGetReqSend(0);
+
+ r = sme_wait_for_reply(priv, UNIFI_SME_MGT_SHORT_TIMEOUT);
+ if (r) {
+ return r;
+ }
+
+ /* store the reply */
+ if (versions != NULL) {
+ memcpy((unsigned char*)versions,
+ (unsigned char*)&priv->sme_reply.versions,
+ sizeof(CsrWifiSmeVersions));
+ }
+
+ unifi_trace(priv, UDBG4,
+ "sme_mgt_versions_get: unifi_mgt_versions_get_req <-- (r=%d status=%d)\n",
+ r, priv->sme_reply.reply_status);
+
+ return convert_sme_error(priv->sme_reply.reply_status);
+#else
+ CsrResult status;
+ CsrWifiSmeMgtClaimSyncAccess(priv->smepriv);
+ status = CsrWifiSmeMgtVersionsGetReq(priv->smepriv, versions);
+ CsrWifiSmeMgtReleaseSyncAccess(priv->smepriv);
+ return convert_sme_error(status);
+#endif
+}
+
+#endif /* CSR_SUPPORT_WEXT */
+
+int sme_mgt_power_config_get(unifi_priv_t *priv, CsrWifiSmePowerConfig *powerConfig)
+{
+#ifdef CSR_SME_USERSPACE
+ int r;
+
+ if (priv->smepriv == NULL) {
+ unifi_error(priv, "sme_mgt_power_config_get: invalid smepriv\n");
+ return -EIO;
+ }
+
+ unifi_trace(priv, UDBG4, "sme_mgt_power_config_get: unifi_mgt_power_config_req -->\n");
+ r = sme_init_request(priv);
+ if (r) {
+ return -EIO;
+ }
+
+ CsrWifiSmePowerConfigGetReqSend(0);
+
+ r = sme_wait_for_reply(priv, UNIFI_SME_MGT_SHORT_TIMEOUT);
+ if (r) {
+ return r;
+ }
+
+ /* store the reply */
+ if (powerConfig != NULL) {
+ memcpy((unsigned char*)powerConfig,
+ (unsigned char*)&priv->sme_reply.powerConfig,
+ sizeof(CsrWifiSmePowerConfig));
+ }
+
+ unifi_trace(priv, UDBG4,
+ "sme_mgt_get_versions: unifi_mgt_power_config_req <-- (r=%d status=%d)\n",
+ r, priv->sme_reply.reply_status);
+
+ return convert_sme_error(priv->sme_reply.reply_status);
+#else
+ CsrResult status;
+ CsrWifiSmeMgtClaimSyncAccess(priv->smepriv);
+ status = CsrWifiSmeMgtPowerConfigGetReq(priv->smepriv, powerConfig);
+ CsrWifiSmeMgtReleaseSyncAccess(priv->smepriv);
+ return convert_sme_error(status);
+#endif
+}
+
+int sme_mgt_host_config_get(unifi_priv_t *priv, CsrWifiSmeHostConfig *hostConfig)
+{
+#ifdef CSR_SME_USERSPACE
+ int r;
+
+ if (priv->smepriv == NULL) {
+ unifi_error(priv, "sme_mgt_host_config_get: invalid smepriv\n");
+ return -EIO;
+ }
+
+ unifi_trace(priv, UDBG4, "sme_mgt_host_config_get: unifi_mgt_host_config_get_req -->\n");
+ r = sme_init_request(priv);
+ if (r) {
+ return -EIO;
+ }
+
+ CsrWifiSmeHostConfigGetReqSend(0, CSR_WIFI_INTERFACE_IN_USE);
+
+ r = sme_wait_for_reply(priv, UNIFI_SME_MGT_SHORT_TIMEOUT);
+ if (r) {
+ return r;
+ }
+
+ /* store the reply */
+ if (hostConfig != NULL) {
+ memcpy((unsigned char*)hostConfig,
+ (unsigned char*)&priv->sme_reply.hostConfig,
+ sizeof(CsrWifiSmeHostConfig));
+ }
+
+ unifi_trace(priv, UDBG4,
+ "sme_mgt_host_config_get: unifi_mgt_host_config_get_req <-- (r=%d status=%d)\n",
+ r, priv->sme_reply.reply_status);
+
+ return convert_sme_error(priv->sme_reply.reply_status);
+#else
+ CsrResult status;
+ CsrWifiSmeMgtClaimSyncAccess(priv->smepriv);
+ status = CsrWifiSmeMgtHostConfigGetReq(priv->smepriv, hostConfig);
+ CsrWifiSmeMgtReleaseSyncAccess(priv->smepriv);
+ return convert_sme_error(status);
+#endif
+}
+
+int sme_mgt_sme_config_get(unifi_priv_t *priv, CsrWifiSmeStaConfig *staConfig, CsrWifiSmeDeviceConfig *deviceConfig)
+{
+#ifdef CSR_SME_USERSPACE
+ int r;
+
+ if (priv->smepriv == NULL) {
+ unifi_error(priv, "sme_mgt_sme_config_get: invalid smepriv\n");
+ return -EIO;
+ }
+
+ unifi_trace(priv, UDBG4, "sme_mgt_sme_config_get: unifi_mgt_sme_config_get_req -->\n");
+
+ /* Common device config */
+ r = sme_init_request(priv);
+ if (r) {
+ return -EIO;
+ }
+
+ CsrWifiSmeSmeCommonConfigGetReqSend(0);
+ r = sme_wait_for_reply(priv, UNIFI_SME_MGT_SHORT_TIMEOUT);
+ if (r) {
+ return r;
+ }
+
+ /* store the reply */
+ if (deviceConfig != NULL) {
+ memcpy((unsigned char*)deviceConfig,
+ (unsigned char*)&priv->sme_reply.deviceConfig,
+ sizeof(CsrWifiSmeDeviceConfig));
+ }
+
+ /* STA config */
+ r = sme_init_request(priv);
+ if (r) {
+ return -EIO;
+ }
+
+ CsrWifiSmeSmeStaConfigGetReqSend(0, CSR_WIFI_INTERFACE_IN_USE);
+ r = sme_wait_for_reply(priv, UNIFI_SME_MGT_SHORT_TIMEOUT);
+ if (r) {
+ return r;
+ }
+
+ /* store the reply */
+ if (staConfig != NULL) {
+ memcpy((unsigned char*)staConfig,
+ (unsigned char*)&priv->sme_reply.staConfig,
+ sizeof(CsrWifiSmeStaConfig));
+ }
+
+ unifi_trace(priv, UDBG4,
+ "sme_mgt_sme_config_get: unifi_mgt_sme_config_get_req <-- (r=%d status=%d)\n",
+ r, priv->sme_reply.reply_status);
+
+ return convert_sme_error(priv->sme_reply.reply_status);
+#else
+ CsrResult status;
+ CsrWifiSmeMgtClaimSyncAccess(priv->smepriv);
+ status = CsrWifiSmeMgtSmeConfigGetReq(priv->smepriv, staConfig);
+ status = CsrWifiSmeMgtDeviceConfigGetReq(priv->smepriv, deviceConfig);
+ CsrWifiSmeMgtReleaseSyncAccess(priv->smepriv);
+ return convert_sme_error(status);
+#endif
+}
+
+int sme_mgt_coex_info_get(unifi_priv_t *priv, CsrWifiSmeCoexInfo *coexInfo)
+{
+#ifdef CSR_SME_USERSPACE
+ int r;
+
+ if (priv->smepriv == NULL) {
+ unifi_error(priv, "sme_mgt_coex_info_get: invalid smepriv\n");
+ return -EIO;
+ }
+
+ unifi_trace(priv, UDBG4, "sme_mgt_coex_info_get: unifi_mgt_coex_info_get_req -->\n");
+ r = sme_init_request(priv);
+ if (r) {
+ return -EIO;
+ }
+
+ CsrWifiSmeCoexInfoGetReqSend(0);
+
+ r = sme_wait_for_reply(priv, UNIFI_SME_MGT_SHORT_TIMEOUT);
+ if (r) {
+ return r;
+ }
+
+ /* store the reply */
+ if (coexInfo != NULL) {
+ memcpy((unsigned char*)coexInfo,
+ (unsigned char*)&priv->sme_reply.coexInfo,
+ sizeof(CsrWifiSmeCoexInfo));
+ }
+
+ unifi_trace(priv, UDBG4,
+ "sme_mgt_coex_info_get: unifi_mgt_coex_info_get_req <-- (r=%d status=%d)\n",
+ r, priv->sme_reply.reply_status);
+
+ return convert_sme_error(priv->sme_reply.reply_status);
+#else
+ CsrResult status;
+ CsrWifiSmeMgtClaimSyncAccess(priv->smepriv);
+ status = CsrWifiSmeMgtCoexInfoGetReq(priv->smepriv, coexInfo);
+ CsrWifiSmeMgtReleaseSyncAccess(priv->smepriv);
+ return convert_sme_error(status);
+#endif
+}
+
+#ifdef CSR_SUPPORT_WEXT
+
+int sme_mgt_coex_config_get(unifi_priv_t *priv, CsrWifiSmeCoexConfig *coexConfig)
+{
+#ifdef CSR_SME_USERSPACE
+ int r;
+
+ if (priv->smepriv == NULL) {
+ unifi_error(priv, "sme_mgt_coex_config_get: invalid smepriv\n");
+ return -EIO;
+ }
+
+ unifi_trace(priv, UDBG4, "sme_mgt_coex_config_get: unifi_mgt_coex_config_get_req -->\n");
+ r = sme_init_request(priv);
+ if (r) {
+ return -EIO;
+ }
+
+ CsrWifiSmeCoexConfigGetReqSend(0);
+
+ r = sme_wait_for_reply(priv, UNIFI_SME_MGT_SHORT_TIMEOUT);
+ if (r) {
+ return r;
+ }
+
+ /* store the reply */
+ if (coexConfig != NULL) {
+ memcpy((unsigned char*)coexConfig,
+ (unsigned char*)&priv->sme_reply.coexConfig,
+ sizeof(CsrWifiSmeCoexConfig));
+ }
+
+ unifi_trace(priv, UDBG4,
+ "sme_mgt_coex_config_get: unifi_mgt_coex_config_get_req <-- (r=%d status=%d)\n",
+ r, priv->sme_reply.reply_status);
+
+ return convert_sme_error(priv->sme_reply.reply_status);
+#else
+ CsrResult status;
+ CsrWifiSmeMgtClaimSyncAccess(priv->smepriv);
+ status = CsrWifiSmeMgtCoexConfigGetReq(priv->smepriv, coexConfig);
+ CsrWifiSmeMgtReleaseSyncAccess(priv->smepriv);
+ return convert_sme_error(status);
+#endif
+}
+
+int sme_mgt_mib_config_get(unifi_priv_t *priv, CsrWifiSmeMibConfig *mibConfig)
+{
+#ifdef CSR_SME_USERSPACE
+ int r;
+
+ if (priv->smepriv == NULL) {
+ unifi_error(priv, "sme_mgt_mib_config_get: invalid smepriv\n");
+ return -EIO;
+ }
+
+ unifi_trace(priv, UDBG4, "sme_mgt_mib_config_get: unifi_mgt_mib_config_get_req -->\n");
+ r = sme_init_request(priv);
+ if (r) {
+ return -EIO;
+ }
+
+ CsrWifiSmeMibConfigGetReqSend(0);
+
+ r = sme_wait_for_reply(priv, UNIFI_SME_MGT_SHORT_TIMEOUT);
+ if (r) {
+ return r;
+ }
+
+ /* store the reply */
+ if (mibConfig != NULL) {
+ memcpy((unsigned char*)mibConfig,
+ (unsigned char*)&priv->sme_reply.mibConfig,
+ sizeof(CsrWifiSmeMibConfig));
+ }
+
+ unifi_trace(priv, UDBG4,
+ "sme_mgt_mib_config_get: unifi_mgt_mib_config_get_req <-- (r=%d status=%d)\n",
+ r, priv->sme_reply.reply_status);
+
+ return convert_sme_error(priv->sme_reply.reply_status);
+#else
+ CsrResult status;
+ CsrWifiSmeMgtClaimSyncAccess(priv->smepriv);
+ status = CsrWifiSmeMgtMibConfigGetReq(priv->smepriv, mibConfig);
+ CsrWifiSmeMgtReleaseSyncAccess(priv->smepriv);
+ return convert_sme_error(status);
+#endif
+}
+
+int sme_mgt_connection_info_get(unifi_priv_t *priv, CsrWifiSmeConnectionInfo *connectionInfo)
+{
+#ifdef CSR_SME_USERSPACE
+ int r;
+
+ if (priv->smepriv == NULL) {
+ unifi_error(priv, "sme_mgt_connection_info_get: invalid smepriv\n");
+ return -EIO;
+ }
+
+ unifi_trace(priv, UDBG4, "sme_mgt_connection_info_get: unifi_mgt_connection_info_get_req -->\n");
+ r = sme_init_request(priv);
+ if (r) {
+ return -EIO;
+ }
+
+ CsrWifiSmeConnectionInfoGetReqSend(0, CSR_WIFI_INTERFACE_IN_USE);
+
+ r = sme_wait_for_reply(priv, UNIFI_SME_MGT_SHORT_TIMEOUT);
+ if (r) {
+ return r;
+ }
+
+ /* store the reply */
+ if (connectionInfo != NULL) {
+ memcpy((unsigned char*)connectionInfo,
+ (unsigned char*)&priv->sme_reply.connectionInfo,
+ sizeof(CsrWifiSmeConnectionInfo));
+ }
+
+ unifi_trace(priv, UDBG4,
+ "sme_mgt_connection_info_get: unifi_mgt_connection_info_get_req <-- (r=%d status=%d)\n",
+ r, priv->sme_reply.reply_status);
+
+ return convert_sme_error(priv->sme_reply.reply_status);
+#else
+ CsrResult status;
+ CsrWifiSmeMgtClaimSyncAccess(priv->smepriv);
+ status = CsrWifiSmeMgtConnectionInfoGetReq(priv->smepriv, connectionInfo);
+ CsrWifiSmeMgtReleaseSyncAccess(priv->smepriv);
+ return convert_sme_error(status);
+#endif
+}
+
+int sme_mgt_connection_config_get(unifi_priv_t *priv, CsrWifiSmeConnectionConfig *connectionConfig)
+{
+#ifdef CSR_SME_USERSPACE
+ int r;
+
+ if (priv->smepriv == NULL) {
+ unifi_error(priv, "sme_mgt_connection_config_get: invalid smepriv\n");
+ return -EIO;
+ }
+
+ unifi_trace(priv, UDBG4, "sme_mgt_connection_config_get: unifi_mgt_connection_config_get_req -->\n");
+ r = sme_init_request(priv);
+ if (r) {
+ return -EIO;
+ }
+
+ CsrWifiSmeConnectionConfigGetReqSend(0, CSR_WIFI_INTERFACE_IN_USE);
+
+ r = sme_wait_for_reply(priv, UNIFI_SME_MGT_SHORT_TIMEOUT);
+ if (r) {
+ return r;
+ }
+
+ /* store the reply */
+ if (connectionConfig != NULL) {
+ memcpy((unsigned char*)connectionConfig,
+ (unsigned char*)&priv->sme_reply.connectionConfig,
+ sizeof(CsrWifiSmeConnectionConfig));
+ }
+
+ unifi_trace(priv, UDBG4,
+ "sme_mgt_connection_config_get: unifi_mgt_connection_config_get_req <-- (r=%d status=%d)\n",
+ r, priv->sme_reply.reply_status);
+
+ return convert_sme_error(priv->sme_reply.reply_status);
+#else
+ CsrResult status;
+ CsrWifiSmeMgtClaimSyncAccess(priv->smepriv);
+ status = CsrWifiSmeMgtConnectionConfigGetReq(priv->smepriv, connectionConfig);
+ CsrWifiSmeMgtReleaseSyncAccess(priv->smepriv);
+ return convert_sme_error(status);
+#endif
+}
+
+int sme_mgt_connection_stats_get(unifi_priv_t *priv, CsrWifiSmeConnectionStats *connectionStats)
+{
+#ifdef CSR_SME_USERSPACE
+ int r;
+
+ if (priv->smepriv == NULL) {
+ unifi_error(priv, "sme_mgt_connection_stats_get: invalid smepriv\n");
+ return -EIO;
+ }
+
+ unifi_trace(priv, UDBG4, "sme_mgt_connection_stats_get: unifi_mgt_connection_stats_get_req -->\n");
+ r = sme_init_request(priv);
+ if (r) {
+ return -EIO;
+ }
+
+ CsrWifiSmeConnectionStatsGetReqSend(0, CSR_WIFI_INTERFACE_IN_USE);
+
+ r = sme_wait_for_reply(priv, UNIFI_SME_MGT_SHORT_TIMEOUT);
+ if (r) {
+ return r;
+ }
+
+ /* store the reply */
+ if (connectionStats != NULL) {
+ memcpy((unsigned char*)connectionStats,
+ (unsigned char*)&priv->sme_reply.connectionStats,
+ sizeof(CsrWifiSmeConnectionStats));
+ }
+
+ unifi_trace(priv, UDBG4,
+ "sme_mgt_connection_stats_get: unifi_mgt_connection_stats_get_req <-- (r=%d status=%d)\n",
+ r, priv->sme_reply.reply_status);
+
+ return convert_sme_error(priv->sme_reply.reply_status);
+#else
+ CsrResult status;
+ CsrWifiSmeMgtClaimSyncAccess(priv->smepriv);
+ status = CsrWifiSmeMgtConnectionStatsGetReq(priv->smepriv, connectionStats);
+ CsrWifiSmeMgtReleaseSyncAccess(priv->smepriv);
+ return convert_sme_error(status);
+#endif
+}
+
+#endif /* CSR_SUPPORT_WEXT */
+
+int sme_mgt_packet_filter_set(unifi_priv_t *priv)
+{
+ CsrWifiIp4Address ipAddress = {{0xFF, 0xFF, 0xFF, 0xFF }};
+ if (priv->smepriv == NULL) {
+ unifi_error(priv, "sme_mgt_packet_filter_set: invalid smepriv\n");
+ return -EIO;
+ }
+ if (priv->packet_filters.arp_filter) {
+ ipAddress.a[0] = (priv->sta_ip_address ) & 0xFF;
+ ipAddress.a[1] = (priv->sta_ip_address >> 8) & 0xFF;
+ ipAddress.a[2] = (priv->sta_ip_address >> 16) & 0xFF;
+ ipAddress.a[3] = (priv->sta_ip_address >> 24) & 0xFF;
+ }
+
+ unifi_trace(priv, UDBG5,
+ "sme_mgt_packet_filter_set: IP address %d.%d.%d.%d\n",
+ ipAddress.a[0], ipAddress.a[1],
+ ipAddress.a[2], ipAddress.a[3]);
+
+ /* Doesn't block for a confirm */
+ CsrWifiSmePacketFilterSetReqSend(0, CSR_WIFI_INTERFACE_IN_USE,
+ priv->packet_filters.tclas_ies_length,
+ priv->filter_tclas_ies,
+ priv->packet_filters.filter_mode,
+ ipAddress);
+ return 0;
+}
+
+int sme_mgt_tspec(unifi_priv_t *priv, CsrWifiSmeListAction action,
+ u32 tid, CsrWifiSmeDataBlock *tspec, CsrWifiSmeDataBlock *tclas)
+{
+ int r;
+
+ if (priv->smepriv == NULL) {
+ unifi_error(priv, "sme_mgt_tspec: invalid smepriv\n");
+ return -EIO;
+ }
+
+ r = sme_init_request(priv);
+ if (r) {
+ return -EIO;
+ }
+
+ CsrWifiSmeTspecReqSend(0, CSR_WIFI_INTERFACE_IN_USE,
+ action, tid, TRUE, 0,
+ tspec->length, tspec->data,
+ tclas->length, tclas->data);
+ r = sme_wait_for_reply(priv, UNIFI_SME_MGT_SHORT_TIMEOUT);
+ if (r) {
+ return r;
+ }
+
+ unifi_trace(priv, UDBG4, "sme_mgt_tspec: <-- (status=%d)\n", priv->sme_reply.reply_status);
+ return convert_sme_error(priv->sme_reply.reply_status);
+}
+
+
+
+int sme_sys_suspend(unifi_priv_t *priv)
+{
+ int r;
+ CsrResult csrResult;
+
+ if (priv->smepriv == NULL) {
+ unifi_error(priv, "sme_sys_suspend: invalid smepriv\n");
+ return -EIO;
+ }
+
+ r = sme_init_request(priv);
+ if (r) {
+ return -EIO;
+ }
+
+ /* Suspend the SME, which MAY cause it to power down UniFi */
+ CsrWifiRouterCtrlSuspendIndSend(priv->CSR_WIFI_SME_IFACEQUEUE,0, 0, priv->wol_suspend);
+ r = sme_wait_for_reply(priv, UNIFI_SME_SYS_LONG_TIMEOUT);
+ if (r) {
+ /* No reply - forcibly power down in case the request wasn't processed */
+ unifi_notice(priv,
+ "suspend: SME did not reply %s, ",
+ (priv->ptest_mode | priv->wol_suspend) ? "leave powered" : "power off UniFi anyway\n");
+
+ /* Leave power on for production test, though */
+ if (!priv->ptest_mode) {
+ /* Put UniFi to deep sleep, in case we can not power it off */
+ CsrSdioClaim(priv->sdio);
+ unifi_trace(priv, UDBG1, "Force deep sleep");
+ csrResult = unifi_force_low_power_mode(priv->card);
+
+ /* For WOL, the UniFi must stay powered */
+ if (!priv->wol_suspend) {
+ unifi_trace(priv, UDBG1, "Power off\n");
+ CsrSdioPowerOff(priv->sdio);
+ }
+ CsrSdioRelease(priv->sdio);
+ }
+ }
+
+ if (priv->wol_suspend) {
+ unifi_trace(priv, UDBG1, "UniFi left powered for WOL\n");
+
+ /* Remove the IRQ, which also disables the card SDIO interrupt.
+ * Disabling the card SDIO interrupt enables the PIO WOL source.
+ * Removal of the of the handler ensures that in both SDIO and PIO cases
+ * the card interrupt only wakes the host. The card will be polled
+ * after resume to handle any pending data.
+ */
+ if (csr_sdio_linux_remove_irq(priv->sdio)) {
+ unifi_notice(priv, "WOL csr_sdio_linux_remove_irq failed\n");
+ }
+
+ if (enable_wol == UNIFI_WOL_SDIO) {
+ /* Because csr_sdio_linux_remove_irq() disabled the card SDIO interrupt,
+ * it must be left enabled to wake-on-SDIO.
+ */
+ unifi_trace(priv, UDBG1, "Enable card SDIO interrupt for SDIO WOL\n");
+
+ CsrSdioClaim(priv->sdio);
+ csrResult = CsrSdioInterruptEnable(priv->sdio);
+ CsrSdioRelease(priv->sdio);
+
+ if (csrResult != CSR_RESULT_SUCCESS) {
+ unifi_error(priv, "WOL CsrSdioInterruptEnable failed %d\n", csrResult);
+ }
+ } else {
+ unifi_trace(priv, UDBG1, "Disabled card SDIO interrupt for PIO WOL\n");
+ }
+
+ /* Prevent the BH thread from running during the suspend.
+ * Upon resume, sme_sys_resume() will trigger a wifi-on, this will cause
+ * the BH thread to be re-enabled and reinstall the ISR.
+ */
+ priv->bh_thread.block_thread = 1;
+
+ unifi_trace(priv, UDBG1, "unifi_suspend: suspended BH");
+ }
+
+ /* Consider UniFi to be uninitialised */
+ priv->init_progress = UNIFI_INIT_NONE;
+
+ unifi_trace(priv, UDBG1, "sme_sys_suspend: <-- (r=%d status=%d)\n", r, priv->sme_reply.reply_status);
+ return convert_sme_error(priv->sme_reply.reply_status);
+}
+
+
+int sme_sys_resume(unifi_priv_t *priv)
+{
+ int r;
+
+ unifi_trace(priv, UDBG1, "sme_sys_resume %s\n", priv->wol_suspend ? "warm" : "");
+
+ if (priv->smepriv == NULL) {
+ unifi_error(priv, "sme_sys_resume: invalid smepriv\n");
+ return -EIO;
+ }
+
+ r = sme_init_request(priv);
+ if (r) {
+ return -EIO;
+ }
+
+ CsrWifiRouterCtrlResumeIndSend(priv->CSR_WIFI_SME_IFACEQUEUE,0, priv->wol_suspend);
+
+ r = sme_wait_for_reply(priv, UNIFI_SME_SYS_LONG_TIMEOUT);
+ if (r) {
+ unifi_notice(priv,
+ "resume: SME did not reply, return success anyway\n");
+ }
+
+ return 0;
+}
+
+#ifdef CSR_SUPPORT_WEXT_AP
+int sme_ap_stop(unifi_priv_t *priv,u16 interface_tag)
+{
+ int r;
+
+ if (priv->smepriv == NULL) {
+ unifi_error(priv, "sme_ap_stop: invalid smepriv\n");
+ return -EIO;
+ }
+
+ r = sme_init_request(priv);
+ if (r) {
+ return -EIO;
+ }
+
+ CsrWifiNmeApStopReqSend(0,interface_tag);
+
+ r = sme_wait_for_reply(priv, UNIFI_SME_MGT_SHORT_TIMEOUT);
+ if (r) {
+ return r;
+ }
+
+ unifi_trace(priv, UDBG4,
+ "sme_ap_stop <-- (r=%d status=%d)\n",
+ r, priv->sme_reply.reply_status);
+ return convert_sme_error(priv->sme_reply.reply_status);
+
+}
+
+int sme_ap_start(unifi_priv_t *priv,u16 interface_tag,
+ CsrWifiSmeApConfig_t * ap_config)
+{
+ int r;
+ CsrWifiSmeApP2pGoConfig p2p_go_param;
+ memset(&p2p_go_param,0,sizeof(CsrWifiSmeApP2pGoConfig));
+
+ if (priv->smepriv == NULL) {
+ unifi_error(priv, "sme_ap_start: invalid smepriv\n");
+ return -EIO;
+ }
+
+ r = sme_init_request(priv);
+ if (r) {
+ return -EIO;
+ }
+
+ CsrWifiNmeApStartReqSend(0,interface_tag,CSR_WIFI_AP_TYPE_LEGACY,FALSE,
+ ap_config->ssid,1,ap_config->channel,
+ ap_config->credentials,ap_config->max_connections,
+ p2p_go_param,FALSE);
+
+ r = sme_wait_for_reply(priv, UNIFI_SME_MGT_SHORT_TIMEOUT);
+ if (r) {
+ return r;
+ }
+
+ unifi_trace(priv, UDBG4,
+ "sme_ap_start <-- (r=%d status=%d)\n",
+ r, priv->sme_reply.reply_status);
+ return convert_sme_error(priv->sme_reply.reply_status);
+}
+
+int sme_ap_config(unifi_priv_t *priv,
+ CsrWifiSmeApMacConfig *ap_mac_config,
+ CsrWifiNmeApConfig *group_security_config)
+{
+ int r;
+ CsrWifiSmeApP2pGoConfig p2p_go_param;
+ memset(&p2p_go_param,0,sizeof(CsrWifiSmeApP2pGoConfig));
+
+ if (priv->smepriv == NULL) {
+ unifi_error(priv, "sme_ap_config: invalid smepriv\n");
+ return -EIO;
+ }
+
+ r = sme_init_request(priv);
+ if (r) {
+ return -EIO;
+ }
+
+ CsrWifiNmeApConfigSetReqSend(0,*group_security_config,
+ *ap_mac_config);
+
+ r = sme_wait_for_reply(priv, UNIFI_SME_MGT_SHORT_TIMEOUT);
+
+ unifi_trace(priv, UDBG4,
+ "sme_ap_config <-- (r=%d status=%d)\n",
+ r, priv->sme_reply.reply_status);
+ return convert_sme_error(priv->sme_reply.reply_status);
+}
+#endif
diff --git a/drivers/staging/csr/sme_mgt.c b/drivers/staging/csr/sme_mgt.c
new file mode 100644
index 000000000000..58d1b3b72932
--- /dev/null
+++ b/drivers/staging/csr/sme_mgt.c
@@ -0,0 +1,1012 @@
+/*
+ * ---------------------------------------------------------------------------
+ * FILE: sme_mgt.c
+ *
+ * PURPOSE:
+ * This file contains the driver specific implementation of
+ * the SME MGT SAP.
+ * It is part of the porting exercise.
+ *
+ * Copyright (C) 2008-2009 by Cambridge Silicon Radio Ltd.
+ *
+ * Refer to LICENSE.txt included with this source code for details on
+ * the license terms.
+ *
+ * ---------------------------------------------------------------------------
+ */
+
+#include "csr_wifi_hip_unifiversion.h"
+#include "unifi_priv.h"
+#include "csr_wifi_hip_conversions.h"
+/*
+ * This file implements the SME MGT API. It contains the following functions:
+ * CsrWifiSmeWifiFlightmodeCfmSend()
+ * CsrWifiSmeWifiOnCfmSend()
+ * CsrWifiSmeWifiOffCfmSend()
+ * CsrWifiSmeWifiOffIndSend()
+ * CsrWifiSmeScanFullCfmSend()
+ * CsrWifiSmeScanResultsGetCfmSend()
+ * CsrWifiSmeScanResultIndSend()
+ * CsrWifiSmeScanResultsFlushCfmSend()
+ * CsrWifiSmeConnectCfmSend()
+ * CsrWifiSmeMediaStatusIndSend()
+ * CsrWifiSmeDisconnectCfmSend()
+ * CsrWifiSmeKeyCfmSend()
+ * CsrWifiSmeMulticastAddressCfmSend()
+ * CsrWifiSmeSetValueCfmSend()
+ * CsrWifiSmeGetValueCfmSend()
+ * CsrWifiSmeMicFailureIndSend()
+ * CsrWifiSmePmkidCfmSend()
+ * CsrWifiSmePmkidCandidateListIndSend()
+ * CsrWifiSmeMibSetCfmSend()
+ * CsrWifiSmeMibGetCfmSend()
+ * CsrWifiSmeMibGetNextCfmSend()
+ * CsrWifiSmeConnectionQualityIndSend()
+ * CsrWifiSmePacketFilterSetCfmSend()
+ * CsrWifiSmeTspecCfmSend()
+ * CsrWifiSmeTspecIndSend()
+ * CsrWifiSmeBlacklistCfmSend()
+ * CsrWifiSmeEventMaskSetCfmSend()
+ * CsrWifiSmeRoamStartIndSend()
+ * CsrWifiSmeRoamCompleteIndSend()
+ * CsrWifiSmeAssociationStartIndSend()
+ * CsrWifiSmeAssociationCompleteIndSend()
+ * CsrWifiSmeIbssStationIndSend()
+ */
+
+
+void CsrWifiSmeMicFailureIndHandler(void* drvpriv, CsrWifiFsmEvent* msg)
+{
+#ifdef CSR_SUPPORT_WEXT
+ unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
+ CsrWifiSmeMicFailureInd* ind = (CsrWifiSmeMicFailureInd*)msg;
+
+ if (priv == NULL) {
+ unifi_error(NULL, "CsrWifiSmeMicFailureIndSend: invalid priv\n");
+ return;
+ }
+
+ unifi_trace(priv, UDBG1,
+ "CsrWifiSmeMicFailureIndSend: count=%d, KeyType=%d\n",
+ ind->count, ind->keyType);
+
+ wext_send_michaelmicfailure_event(priv, ind->count, ind->address, ind->keyType, ind->interfaceTag);
+#endif
+}
+
+
+void CsrWifiSmePmkidCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg)
+{
+#ifdef CSR_SUPPORT_WEXT
+ unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
+ CsrWifiSmePmkidCfm* cfm = (CsrWifiSmePmkidCfm*)msg;
+
+ if (priv == NULL) {
+ unifi_error(NULL, "CsrWifiSmePmkidCfmSend: Invalid ospriv.\n");
+ return;
+ }
+
+ /*
+ * WEXT never does a GET operation the PMKIDs, so we don't need
+ * handle data returned in pmkids.
+ */
+
+ sme_complete_request(priv, cfm->status);
+#endif
+}
+
+
+void CsrWifiSmePmkidCandidateListIndHandler(void* drvpriv, CsrWifiFsmEvent* msg)
+{
+#ifdef CSR_SUPPORT_WEXT
+ unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
+ CsrWifiSmePmkidCandidateListInd* ind = (CsrWifiSmePmkidCandidateListInd*)msg;
+ int i;
+
+ if (priv->smepriv == NULL) {
+ unifi_error(priv, "CsrWifiSmePmkidCandidateListIndSend: invalid smepriv\n");
+ return;
+ }
+
+ for (i = 0; i < ind->pmkidCandidatesCount; i++)
+ {
+ wext_send_pmkid_candidate_event(priv, ind->pmkidCandidates[i].bssid, ind->pmkidCandidates[i].preAuthAllowed, ind->interfaceTag);
+ }
+#endif
+}
+
+void CsrWifiSmeScanResultsFlushCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg)
+{
+}
+
+void CsrWifiSmeScanResultsGetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg)
+{
+#ifdef CSR_SUPPORT_WEXT
+ unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
+ CsrWifiSmeScanResultsGetCfm* cfm = (CsrWifiSmeScanResultsGetCfm*)msg;
+ int bytesRequired = cfm->scanResultsCount * sizeof(CsrWifiSmeScanResult);
+ int i;
+ u8* current_buff;
+ CsrWifiSmeScanResult* scanCopy;
+
+ if (priv == NULL) {
+ unifi_error(NULL, "CsrWifiSmeScanResultsGetCfmSend: Invalid ospriv.\n");
+ return;
+ }
+
+ /* Calc the size of the buffer reuired */
+ for (i = 0; i < cfm->scanResultsCount; ++i) {
+ const CsrWifiSmeScanResult *scan_result = &cfm->scanResults[i];
+ bytesRequired += scan_result->informationElementsLength;
+ }
+
+ /* Take a Copy of the scan Results :-) */
+ scanCopy = kmalloc(bytesRequired, GFP_KERNEL);
+ memcpy(scanCopy, cfm->scanResults, sizeof(CsrWifiSmeScanResult) * cfm->scanResultsCount);
+
+ /* Take a Copy of the Info Elements AND update the scan result pointers */
+ current_buff = (u8*)&scanCopy[cfm->scanResultsCount];
+ for (i = 0; i < cfm->scanResultsCount; ++i)
+ {
+ CsrWifiSmeScanResult *scan_result = &scanCopy[i];
+ memcpy(current_buff, scan_result->informationElements, scan_result->informationElementsLength);
+ scan_result->informationElements = current_buff;
+ current_buff += scan_result->informationElementsLength;
+ }
+
+ priv->sme_reply.reply_scan_results_count = cfm->scanResultsCount;
+ priv->sme_reply.reply_scan_results = scanCopy;
+
+ sme_complete_request(priv, cfm->status);
+#endif
+}
+
+
+void CsrWifiSmeScanFullCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg)
+{
+#ifdef CSR_SUPPORT_WEXT
+ unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
+ CsrWifiSmeScanFullCfm* cfm = (CsrWifiSmeScanFullCfm*)msg;
+
+ if (priv == NULL) {
+ unifi_error(NULL, "CsrWifiSmeScanFullCfmSend: Invalid ospriv.\n");
+ return;
+ }
+
+ sme_complete_request(priv, cfm->status);
+#endif
+}
+
+
+void CsrWifiSmeScanResultIndHandler(void* drvpriv, CsrWifiFsmEvent* msg)
+{
+
+}
+
+
+void CsrWifiSmeConnectCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg)
+{
+#ifdef CSR_SUPPORT_WEXT
+ unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
+ CsrWifiSmeConnectCfm* cfm = (CsrWifiSmeConnectCfm*)msg;
+
+ if (priv == NULL) {
+ unifi_error(NULL, "CsrWifiSmeConnectCfmSend: Invalid ospriv.\n");
+ return;
+ }
+
+ sme_complete_request(priv, cfm->status);
+#endif
+}
+
+
+void CsrWifiSmeDisconnectCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg)
+{
+#ifdef CSR_SUPPORT_WEXT
+ unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
+ CsrWifiSmeDisconnectCfm* cfm = (CsrWifiSmeDisconnectCfm*)msg;
+
+ if (priv == NULL) {
+ unifi_error(NULL, "CsrWifiSmeDisconnectCfmSend: Invalid ospriv.\n");
+ return;
+ }
+
+ sme_complete_request(priv, cfm->status);
+#endif
+}
+
+
+void CsrWifiSmeKeyCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg)
+{
+#ifdef CSR_SUPPORT_WEXT
+ unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
+ CsrWifiSmeKeyCfm* cfm = (CsrWifiSmeKeyCfm*)msg;
+
+ if (priv == NULL) {
+ unifi_error(NULL, "CsrWifiSmeKeyCfmSend: Invalid ospriv.\n");
+ return;
+ }
+
+ sme_complete_request(priv, cfm->status);
+#endif
+}
+
+
+void CsrWifiSmeMulticastAddressCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg)
+{
+#ifdef CSR_SUPPORT_WEXT
+ unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
+ CsrWifiSmeMulticastAddressCfm* cfm = (CsrWifiSmeMulticastAddressCfm*)msg;
+
+ if (priv == NULL) {
+ unifi_error(NULL, "CsrWifiSmeMulticastAddressCfmSend: Invalid ospriv.\n");
+ return;
+ }
+
+ sme_complete_request(priv, cfm->status);
+#endif
+}
+
+void CsrWifiSmeWifiFlightmodeCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg)
+{
+#ifdef CSR_SUPPORT_WEXT
+ unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
+ CsrWifiSmeWifiFlightmodeCfm* cfm = (CsrWifiSmeWifiFlightmodeCfm*)msg;
+
+ if (priv == NULL) {
+ unifi_error(NULL, "CsrWifiSmeWifiFlightmodeCfmSend: Invalid ospriv.\n");
+ return;
+ }
+
+ sme_complete_request(priv, cfm->status);
+#endif
+}
+
+void CsrWifiSmeWifiOnCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg)
+{
+#ifdef CSR_SUPPORT_WEXT
+ unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
+ CsrWifiSmeWifiOnCfm* cfm = (CsrWifiSmeWifiOnCfm*)msg;
+
+ if (priv == NULL) {
+ unifi_error(NULL, "CsrWifiSmeWifiOnCfmSend: Invalid ospriv.\n");
+ return;
+ }
+
+ unifi_trace(priv, UDBG4,
+ "CsrWifiSmeWifiOnCfmSend: wake up status %d\n", cfm->status);
+#ifdef CSR_SUPPORT_WEXT_AP
+ sme_complete_request(priv, cfm->status);
+#endif
+
+#endif
+}
+
+void CsrWifiSmeWifiOffCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg)
+{
+#ifdef CSR_SUPPORT_WEXT
+ unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
+ CsrWifiSmeWifiOffCfm* cfm = (CsrWifiSmeWifiOffCfm*)msg;
+
+ if (priv == NULL) {
+ unifi_error(NULL, "CsrWifiSmeWifiOffCfmSend: Invalid ospriv.\n");
+ return;
+ }
+
+ sme_complete_request(priv, cfm->status);
+#endif
+}
+
+
+void CsrWifiSmeWifiOffIndHandler(void* drvpriv, CsrWifiFsmEvent* msg)
+{
+#ifdef CSR_SUPPORT_WEXT
+ unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
+ CsrWifiSmeWifiOffInd* ind = (CsrWifiSmeWifiOffInd*)msg;
+
+ if (priv == NULL) {
+ unifi_error(NULL, "CsrWifiRouterCtrlStoppedReqSend: Invalid ospriv.\n");
+ return;
+ }
+
+ if (priv->smepriv == NULL) {
+ unifi_error(priv, "CsrWifiRouterCtrlStoppedReqSend: invalid smepriv\n");
+ return;
+ }
+
+ /*
+ * If the status indicates an error, the SME is in a stopped state.
+ * We need to start it again in order to reinitialise UniFi.
+ */
+ switch (ind->reason) {
+ case CSR_WIFI_SME_CONTROL_INDICATION_ERROR:
+ unifi_trace(priv, UDBG1,
+ "CsrWifiRouterCtrlStoppedReqSend: Restarting SME (ind:%d)\n",
+ ind->reason);
+
+ /* On error, restart the SME */
+ sme_mgt_wifi_on(priv);
+ break;
+ case CSR_WIFI_SME_CONTROL_INDICATION_EXIT:
+#ifdef CSR_SUPPORT_WEXT_AP
+ sme_complete_request(priv, 0);
+#endif
+ break;
+ default:
+ break;
+ }
+
+#endif
+}
+
+void CsrWifiSmeVersionsGetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg)
+{
+#ifdef CSR_SUPPORT_WEXT
+ unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
+ CsrWifiSmeVersionsGetCfm* cfm = (CsrWifiSmeVersionsGetCfm*)msg;
+
+ if (priv == NULL) {
+ unifi_error(NULL, "CsrWifiSmeVersionsGetCfmSend: Invalid ospriv.\n");
+ return;
+ }
+
+ priv->sme_reply.versions = cfm->versions;
+ sme_complete_request(priv, cfm->status);
+#endif
+}
+
+void CsrWifiSmePowerConfigGetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg)
+{
+ unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
+ CsrWifiSmePowerConfigGetCfm* cfm = (CsrWifiSmePowerConfigGetCfm*)msg;
+
+ if (priv == NULL) {
+ unifi_error(NULL, "CsrWifiSmePowerConfigGetCfmSend: Invalid ospriv.\n");
+ return;
+ }
+
+ priv->sme_reply.powerConfig = cfm->powerConfig;
+ sme_complete_request(priv, cfm->status);
+}
+
+void CsrWifiSmeHostConfigGetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg)
+{
+ unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
+ CsrWifiSmeHostConfigGetCfm* cfm = (CsrWifiSmeHostConfigGetCfm*)msg;
+
+ if (priv == NULL) {
+ unifi_error(NULL, "CsrWifiSmeHostConfigGetCfmSend: Invalid ospriv.\n");
+ return;
+ }
+
+ priv->sme_reply.hostConfig = cfm->hostConfig;
+ sme_complete_request(priv, cfm->status);
+}
+
+void CsrWifiSmeCoexInfoGetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg)
+{
+ unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
+ CsrWifiSmeCoexInfoGetCfm* cfm = (CsrWifiSmeCoexInfoGetCfm*)msg;
+
+ if (priv == NULL) {
+ unifi_error(NULL, "CsrWifiSmeCoexInfoGetCfmSend: Invalid ospriv.\n");
+ return;
+ }
+
+ priv->sme_reply.coexInfo = cfm->coexInfo;
+ sme_complete_request(priv, cfm->status);
+}
+
+void CsrWifiSmeCoexConfigGetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg)
+{
+#ifdef CSR_SUPPORT_WEXT
+ unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
+ CsrWifiSmeCoexConfigGetCfm* cfm = (CsrWifiSmeCoexConfigGetCfm*)msg;
+
+ if (priv == NULL) {
+ unifi_error(NULL, "CsrWifiSmeCoexConfigGetCfmSend: Invalid ospriv.\n");
+ return;
+ }
+
+ priv->sme_reply.coexConfig = cfm->coexConfig;
+ sme_complete_request(priv, cfm->status);
+#endif
+}
+
+void CsrWifiSmeMibConfigGetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg)
+{
+#ifdef CSR_SUPPORT_WEXT
+ unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
+ CsrWifiSmeMibConfigGetCfm* cfm = (CsrWifiSmeMibConfigGetCfm*)msg;
+
+ if (priv == NULL) {
+ unifi_error(NULL, "CsrWifiSmeMibConfigGetCfmSend: Invalid ospriv.\n");
+ return;
+ }
+
+ priv->sme_reply.mibConfig = cfm->mibConfig;
+ sme_complete_request(priv, cfm->status);
+#endif
+}
+
+void CsrWifiSmeConnectionInfoGetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg)
+{
+#ifdef CSR_SUPPORT_WEXT
+ unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
+ CsrWifiSmeConnectionInfoGetCfm* cfm = (CsrWifiSmeConnectionInfoGetCfm*)msg;
+
+ if (priv == NULL) {
+ unifi_error(NULL, "CsrWifiSmeConnectionInfoGetCfmSend: Invalid ospriv.\n");
+ return;
+ }
+
+ priv->sme_reply.connectionInfo = cfm->connectionInfo;
+ sme_complete_request(priv, cfm->status);
+#endif
+}
+
+void CsrWifiSmeConnectionConfigGetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg)
+{
+#ifdef CSR_SUPPORT_WEXT
+ unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
+ CsrWifiSmeConnectionConfigGetCfm* cfm = (CsrWifiSmeConnectionConfigGetCfm*)msg;
+
+ if (priv == NULL) {
+ unifi_error(NULL, "CsrWifiSmeConnectionConfigGetCfmSend: Invalid ospriv.\n");
+ return;
+ }
+
+ priv->sme_reply.connectionConfig = cfm->connectionConfig;
+ sme_complete_request(priv, cfm->status);
+#endif
+}
+
+void CsrWifiSmeConnectionStatsGetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg)
+{
+#ifdef CSR_SUPPORT_WEXT
+ unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
+ CsrWifiSmeConnectionStatsGetCfm* cfm = (CsrWifiSmeConnectionStatsGetCfm*)msg;
+
+ if (priv == NULL) {
+ unifi_error(NULL, "CsrWifiSmeConnectionStatsGetCfmSend: Invalid ospriv.\n");
+ return;
+ }
+
+ priv->sme_reply.connectionStats = cfm->connectionStats;
+ sme_complete_request(priv, cfm->status);
+#endif
+}
+
+void CsrWifiSmeMibSetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg)
+{
+#ifdef CSR_SUPPORT_WEXT
+ unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
+ CsrWifiSmeMibSetCfm* cfm = (CsrWifiSmeMibSetCfm*)msg;
+
+ if (priv == NULL) {
+ unifi_error(NULL, "CsrWifiSmeMibSetCfmSend: Invalid ospriv.\n");
+ return;
+ }
+
+ sme_complete_request(priv, cfm->status);
+#endif
+}
+
+void CsrWifiSmeMibGetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg)
+{
+#ifdef CSR_SUPPORT_WEXT
+ unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
+ CsrWifiSmeMibGetCfm* cfm = (CsrWifiSmeMibGetCfm*)msg;
+
+ if (priv == NULL) {
+ unifi_error(NULL, "CsrWifiSmeMibGetCfmSend: Invalid ospriv.\n");
+ return;
+ }
+
+ if (cfm->mibAttribute == NULL) {
+ unifi_error(priv, "CsrWifiSmeMibGetCfmSend: Empty reply.\n");
+ sme_complete_request(priv, cfm->status);
+ return;
+ }
+
+ if ((priv->mib_cfm_buffer != NULL) &&
+ (priv->mib_cfm_buffer_length >= cfm->mibAttributeLength)) {
+ memcpy(priv->mib_cfm_buffer, cfm->mibAttribute, cfm->mibAttributeLength);
+ priv->mib_cfm_buffer_length = cfm->mibAttributeLength;
+ } else {
+ unifi_error(priv,
+ "CsrWifiSmeMibGetCfmSend: No room to store MIB data (have=%d need=%d).\n",
+ priv->mib_cfm_buffer_length, cfm->mibAttributeLength);
+ }
+
+ sme_complete_request(priv, cfm->status);
+#endif
+}
+
+void CsrWifiSmeMibGetNextCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg)
+{
+#ifdef CSR_SUPPORT_WEXT
+ unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
+ CsrWifiSmeMibGetNextCfm* cfm = (CsrWifiSmeMibGetNextCfm*)msg;
+
+ if (priv == NULL) {
+ unifi_error(NULL, "CsrWifiSmeMibGetNextCfmSend: Invalid ospriv.\n");
+ return;
+ }
+
+ /* Need to copy MIB data */
+ sme_complete_request(priv, cfm->status);
+#endif
+}
+
+void CsrWifiSmeConnectionQualityIndHandler(void* drvpriv, CsrWifiFsmEvent* msg)
+{
+#ifdef CSR_SUPPORT_WEXT
+ unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
+ CsrWifiSmeConnectionQualityInd* ind = (CsrWifiSmeConnectionQualityInd*)msg;
+ int signal, noise, snr;
+
+ if (priv == NULL) {
+ unifi_error(NULL, "CsrWifiSmeConnectionQualityIndSend: Invalid ospriv.\n");
+ return;
+ }
+
+ /*
+ * level and noise below are mapped into an unsigned 8 bit number,
+ * ranging from [-192; 63]. The way this is achieved is simply to
+ * add 0x100 onto the number if it is negative,
+ * once clipped to the correct range.
+ */
+ signal = ind->linkQuality.unifiRssi;
+ /* Clip range of snr */
+ snr = (ind->linkQuality.unifiSnr > 0) ? ind->linkQuality.unifiSnr : 0; /* In dB relative, from 0 - 255 */
+ snr = (snr < 255) ? snr : 255;
+ noise = signal - snr;
+
+ /* Clip range of signal */
+ signal = (signal < 63) ? signal : 63;
+ signal = (signal > -192) ? signal : -192;
+
+ /* Clip range of noise */
+ noise = (noise < 63) ? noise : 63;
+ noise = (noise > -192) ? noise : -192;
+
+ /* Make u8 */
+ signal = ( signal < 0 ) ? signal + 0x100 : signal;
+ noise = ( noise < 0 ) ? noise + 0x100 : noise;
+
+ priv->wext_wireless_stats.qual.level = (u8)signal; /* -192 : 63 */
+ priv->wext_wireless_stats.qual.noise = (u8)noise; /* -192 : 63 */
+ priv->wext_wireless_stats.qual.qual = snr; /* 0 : 255 */
+ priv->wext_wireless_stats.qual.updated = 0;
+
+#if WIRELESS_EXT > 16
+ priv->wext_wireless_stats.qual.updated |= IW_QUAL_LEVEL_UPDATED |
+ IW_QUAL_NOISE_UPDATED |
+ IW_QUAL_QUAL_UPDATED;
+#if WIRELESS_EXT > 18
+ priv->wext_wireless_stats.qual.updated |= IW_QUAL_DBM;
+#endif
+#endif
+#endif
+}
+
+void CsrWifiSmePacketFilterSetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg)
+{
+ unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
+
+ if (priv == NULL) {
+ unifi_error(NULL, "CsrWifiSmePacketFilterSetCfmSend: Invalid ospriv.\n");
+ return;
+ }
+
+ /* The packet filter set request does not block for a reply */
+}
+
+void CsrWifiSmeTspecCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg)
+{
+ unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
+ CsrWifiSmeTspecCfm* cfm = (CsrWifiSmeTspecCfm*)msg;
+
+ if (priv == NULL) {
+ unifi_error(NULL, "CsrWifiSmeTspecCfmSend: Invalid ospriv.\n");
+ return;
+ }
+
+ sme_complete_request(priv, cfm->status);
+}
+
+void CsrWifiSmeTspecIndHandler(void* drvpriv, CsrWifiFsmEvent* msg)
+{
+}
+
+void CsrWifiSmeBlacklistCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg)
+{
+}
+
+void CsrWifiSmeEventMaskSetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg)
+{
+}
+
+
+void CsrWifiSmeRoamStartIndHandler(void* drvpriv, CsrWifiFsmEvent* msg)
+{
+}
+
+void CsrWifiSmeRoamCompleteIndHandler(void* drvpriv, CsrWifiFsmEvent* msg)
+{
+ /* This is called when the association completes, before any 802.1x authentication */
+}
+
+void CsrWifiSmeAssociationStartIndHandler(void* drvpriv, CsrWifiFsmEvent* msg)
+{
+}
+
+void CsrWifiSmeAssociationCompleteIndHandler(void* drvpriv, CsrWifiFsmEvent* msg)
+{
+}
+
+void CsrWifiSmeIbssStationIndHandler(void* drvpriv, CsrWifiFsmEvent* msg)
+{
+}
+
+void CsrWifiSmeWifiOnIndHandler(void* drvpriv, CsrWifiFsmEvent* msg)
+{
+}
+
+void CsrWifiSmeRestrictedAccessEnableCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg)
+{
+}
+
+void CsrWifiSmeRestrictedAccessDisableCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg)
+{
+}
+
+
+void CsrWifiSmeAdhocConfigGetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg)
+{
+}
+
+void CsrWifiSmeAdhocConfigSetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg)
+{
+#ifdef CSR_SUPPORT_WEXT
+ unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
+ CsrWifiSmeAdhocConfigSetCfm* cfm = (CsrWifiSmeAdhocConfigSetCfm*)msg;
+
+ if (priv == NULL) {
+ unifi_error(NULL, "CsrWifiSmeSmeConfigSetCfmSend: Invalid ospriv.\n");
+ return;
+ }
+
+ sme_complete_request(priv, cfm->status);
+#endif
+}
+
+void CsrWifiSmeCalibrationDataGetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg)
+{
+}
+
+void CsrWifiSmeCalibrationDataSetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg)
+{
+#ifdef CSR_SUPPORT_WEXT
+ unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
+ CsrWifiSmeCalibrationDataSetCfm* cfm = (CsrWifiSmeCalibrationDataSetCfm*)msg;
+
+ if (priv == NULL) {
+ unifi_error(NULL, "CsrWifiSmeSmeConfigSetCfmSend: Invalid ospriv.\n");
+ return;
+ }
+
+ sme_complete_request(priv, cfm->status);
+#endif
+}
+
+void CsrWifiSmeCcxConfigGetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg)
+{
+}
+
+void CsrWifiSmeCcxConfigSetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg)
+{
+#ifdef CSR_SUPPORT_WEXT
+ unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
+ CsrWifiSmeCcxConfigSetCfm* cfm = (CsrWifiSmeCcxConfigSetCfm*)msg;
+
+ if (priv == NULL) {
+ unifi_error(NULL, "CsrWifiSmeSmeConfigSetCfmSend: Invalid ospriv.\n");
+ return;
+ }
+
+ sme_complete_request(priv, cfm->status);
+#endif
+}
+
+void CsrWifiSmeCloakedSsidsGetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg)
+{
+}
+
+void CsrWifiSmeCloakedSsidsSetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg)
+{
+#ifdef CSR_SUPPORT_WEXT
+ unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
+ CsrWifiSmeCloakedSsidsSetCfm* cfm = (CsrWifiSmeCloakedSsidsSetCfm*)msg;
+
+ if (priv == NULL) {
+ unifi_error(NULL, "CsrWifiSmeSmeConfigSetCfmSend: Invalid ospriv.\n");
+ return;
+ }
+
+ sme_complete_request(priv, cfm->status);
+#endif
+}
+
+
+void CsrWifiSmeCoexConfigSetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg)
+{
+#ifdef CSR_SUPPORT_WEXT
+ unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
+ CsrWifiSmeCoexConfigSetCfm* cfm = (CsrWifiSmeCoexConfigSetCfm*)msg;
+
+ if (priv == NULL) {
+ unifi_error(NULL, "CsrWifiSmeSmeConfigSetCfmSend: Invalid ospriv.\n");
+ return;
+ }
+
+ sme_complete_request(priv, cfm->status);
+#endif
+}
+
+void CsrWifiSmeHostConfigSetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg)
+{
+ unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
+ CsrWifiSmeHostConfigSetCfm* cfm = (CsrWifiSmeHostConfigSetCfm*)msg;
+
+ if (priv == NULL) {
+ unifi_error(NULL, "CsrWifiSmeSmeConfigSetCfmSend: Invalid ospriv.\n");
+ return;
+ }
+
+ sme_complete_request(priv, cfm->status);
+}
+
+void CsrWifiSmeLinkQualityGetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg)
+{
+}
+
+
+void CsrWifiSmeMibConfigSetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg)
+{
+#ifdef CSR_SUPPORT_WEXT
+ unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
+ CsrWifiSmeMibConfigSetCfm* cfm = (CsrWifiSmeMibConfigSetCfm*)msg;
+
+ if (priv == NULL) {
+ unifi_error(NULL, "CsrWifiSmeSmeConfigSetCfmSend: Invalid ospriv.\n");
+ return;
+ }
+
+ sme_complete_request(priv, cfm->status);
+#endif
+}
+
+void CsrWifiSmePermanentMacAddressGetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg)
+{
+}
+
+void CsrWifiSmePowerConfigSetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg)
+{
+ unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
+ CsrWifiSmePowerConfigSetCfm* cfm = (CsrWifiSmePowerConfigSetCfm*)msg;
+
+ if (priv == NULL) {
+ unifi_error(NULL, "CsrWifiSmeSmeConfigSetCfmSend: Invalid ospriv.\n");
+ return;
+ }
+
+ sme_complete_request(priv, cfm->status);
+}
+
+void CsrWifiSmeRegulatoryDomainInfoGetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg)
+{
+}
+
+void CsrWifiSmeRoamingConfigGetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg)
+{
+}
+
+void CsrWifiSmeMediaStatusIndHandler(void* drvpriv, CsrWifiFsmEvent* msg)
+{
+#ifdef CSR_SUPPORT_WEXT
+ unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
+ CsrWifiSmeMediaStatusInd* ind = (CsrWifiSmeMediaStatusInd*)msg;
+
+ if (priv->smepriv == NULL) {
+ unifi_error(priv, "CsrWifiSmeMediaStatusIndSend: invalid smepriv\n");
+ return;
+ }
+
+ if (ind->mediaStatus == CSR_WIFI_SME_MEDIA_STATUS_CONNECTED) {
+ /*
+ * Send wireless-extension event up to userland to announce
+ * connection.
+ */
+ wext_send_assoc_event(priv,
+ (unsigned char *)ind->connectionInfo.bssid.a,
+ (unsigned char *)ind->connectionInfo.assocReqInfoElements,
+ ind->connectionInfo.assocReqInfoElementsLength,
+ (unsigned char *)ind->connectionInfo.assocRspInfoElements,
+ ind->connectionInfo.assocRspInfoElementsLength,
+ (unsigned char *)ind->connectionInfo.assocScanInfoElements,
+ ind->connectionInfo.assocScanInfoElementsLength);
+
+ unifi_trace(priv, UDBG2, "CsrWifiSmeMediaStatusIndSend: IBSS=%pM\n",
+ ind->connectionInfo.bssid.a);
+
+ sme_mgt_packet_filter_set(priv);
+
+ } else {
+ /*
+ * Send wireless-extension event up to userland to announce
+ * connection lost to a BSS.
+ */
+ wext_send_disassoc_event(priv);
+ }
+#endif
+}
+
+void CsrWifiSmeRoamingConfigSetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg)
+{
+ unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
+ CsrWifiSmeRoamingConfigSetCfm* cfm = (CsrWifiSmeRoamingConfigSetCfm*)msg;
+
+ if (priv == NULL) {
+ unifi_error(NULL, "CsrWifiSmeRoamingConfigSetCfmSend: Invalid ospriv.\n");
+ return;
+ }
+
+ sme_complete_request(priv, cfm->status);
+}
+
+void CsrWifiSmeScanConfigGetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg)
+{
+}
+
+void CsrWifiSmeScanConfigSetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg)
+{
+#ifdef CSR_SUPPORT_WEXT
+ unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
+ CsrWifiSmeScanConfigSetCfm* cfm = (CsrWifiSmeScanConfigSetCfm*)msg;
+
+ if (priv == NULL) {
+ unifi_error(NULL, "CsrWifiSmeSmeConfigSetCfmSend: Invalid ospriv.\n");
+ return;
+ }
+
+ sme_complete_request(priv, cfm->status);
+#endif
+}
+
+void CsrWifiSmeStationMacAddressGetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg)
+{
+}
+
+void CsrWifiSmeSmeCommonConfigGetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg)
+{
+ unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
+ CsrWifiSmeSmeCommonConfigGetCfm* cfm = (CsrWifiSmeSmeCommonConfigGetCfm*)msg;
+
+ if (priv == NULL) {
+ unifi_error(NULL, "CsrWifiSmeSmeCommonConfigGetCfmSend: Invalid ospriv.\n");
+ return;
+ }
+
+ priv->sme_reply.deviceConfig = cfm->deviceConfig;
+ sme_complete_request(priv, cfm->status);
+}
+
+void CsrWifiSmeSmeStaConfigGetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg)
+{
+ unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
+ CsrWifiSmeSmeStaConfigGetCfm* cfm = (CsrWifiSmeSmeStaConfigGetCfm*)msg;
+
+ if (priv == NULL) {
+ unifi_error(NULL, "CsrWifiSmeSmeStaConfigGetCfmSend: Invalid ospriv.\n");
+ return;
+ }
+
+ priv->sme_reply.staConfig = cfm->smeConfig;
+ sme_complete_request(priv, cfm->status);
+}
+
+void CsrWifiSmeSmeCommonConfigSetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg)
+{
+ unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
+ CsrWifiSmeSmeCommonConfigSetCfm* cfm = (CsrWifiSmeSmeCommonConfigSetCfm*)msg;
+
+ if (priv == NULL) {
+ unifi_error(NULL, "CsrWifiSmeSmeCommonConfigGetCfmSend: Invalid ospriv.\n");
+ return;
+ }
+
+ sme_complete_request(priv, cfm->status);
+}
+
+void CsrWifiSmeSmeStaConfigSetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg)
+{
+ unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
+ CsrWifiSmeSmeStaConfigSetCfm* cfm = (CsrWifiSmeSmeStaConfigSetCfm*)msg;
+
+ if (priv == NULL) {
+ unifi_error(NULL, "CsrWifiSmeSmeStaConfigGetCfmSend: Invalid ospriv.\n");
+ return;
+ }
+
+ sme_complete_request(priv, cfm->status);
+}
+
+void CsrWifiSmeGetInterfaceCapabilityCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg)
+{
+}
+
+void CsrWifiSmeErrorIndHandler(void* drvpriv, CsrWifiFsmEvent* msg)
+{
+}
+
+void CsrWifiSmeInfoIndHandler(void* drvpriv, CsrWifiFsmEvent* msg)
+{
+}
+
+void CsrWifiSmeCoreDumpIndHandler(void* drvpriv, CsrWifiFsmEvent* msg)
+{
+}
+void CsrWifiSmeAmpStatusChangeIndHandler(void* drvpriv, CsrWifiFsmEvent* msg)
+{
+}
+
+void CsrWifiSmeActivateCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg)
+{
+}
+void CsrWifiSmeDeactivateCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg)
+{
+}
+
+#ifdef CSR_SUPPORT_WEXT
+#ifdef CSR_SUPPORT_WEXT_AP
+void CsrWifiNmeApStartCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg)
+{
+ unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
+ CsrWifiNmeApStartCfm* cfm = (CsrWifiNmeApStartCfm*)msg;
+
+ if (priv == NULL) {
+ unifi_error(NULL, "CsrWifiNmeApStartCfmSend: Invalid ospriv.\n");
+ return;
+ }
+
+ sme_complete_request(priv, cfm->status);
+}
+
+void CsrWifiNmeApStopCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg)
+{
+ unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
+ CsrWifiNmeApStopCfm* cfm = (CsrWifiNmeApStopCfm*)msg;
+
+ if (priv == NULL) {
+ unifi_error(NULL, "CsrWifiNmeApStopCfmSend: Invalid ospriv.\n");
+ return;
+ }
+
+ sme_complete_request(priv, cfm->status);
+}
+
+void CsrWifiNmeApConfigSetCfmHandler(void* drvpriv, CsrWifiFsmEvent* msg)
+{
+ unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
+ CsrWifiNmeApConfigSetCfm* cfm = (CsrWifiNmeApConfigSetCfm*)msg;
+
+ if (priv == NULL) {
+ unifi_error(NULL, "CsrWifiNmeApConfigSetCfmSend: Invalid ospriv.\n");
+ return;
+ }
+ sme_complete_request(priv, cfm->status);
+}
+#endif
+#endif
diff --git a/drivers/staging/csr/sme_native.c b/drivers/staging/csr/sme_native.c
new file mode 100644
index 000000000000..229268fd746c
--- /dev/null
+++ b/drivers/staging/csr/sme_native.c
@@ -0,0 +1,591 @@
+/*
+ * ***************************************************************************
+ *
+ * FILE: sme_native.c
+ *
+ * Copyright (C) 2005-2009 by Cambridge Silicon Radio Ltd.
+ *
+ * Refer to LICENSE.txt included with this source code for details on
+ * the license terms.
+ *
+ * ***************************************************************************
+ */
+
+#include <linux/netdevice.h>
+
+#include "unifi_priv.h"
+#include "csr_wifi_hip_unifi.h"
+#include "csr_wifi_hip_conversions.h"
+
+static const unsigned char wildcard_address[ETH_ALEN] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
+
+int
+uf_sme_init(unifi_priv_t *priv)
+{
+ func_enter();
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 37)
+ sema_init(&priv->mlme_blocking_mutex, 1);
+#else
+ init_MUTEX(&priv->mlme_blocking_mutex);
+#endif
+
+#ifdef CSR_SUPPORT_WEXT
+ {
+ int r = uf_init_wext_interface(priv);
+ if (r != 0) {
+ func_exit();
+ return r;
+ }
+ }
+#endif
+
+
+
+ func_exit();
+ return 0;
+} /* uf_sme_init() */
+
+
+void
+uf_sme_deinit(unifi_priv_t *priv)
+{
+
+ func_enter();
+
+ /* Free memory allocated for the scan table */
+/* unifi_clear_scan_table(priv); */
+
+ /* Cancel any pending workqueue tasks */
+ flush_workqueue(priv->unifi_workqueue);
+
+#ifdef CSR_SUPPORT_WEXT
+ uf_deinit_wext_interface(priv);
+#endif
+
+
+ func_exit();
+} /* uf_sme_deinit() */
+
+
+int sme_mgt_wifi_on(unifi_priv_t *priv)
+{
+ int r,i;
+ s32 csrResult;
+
+ if (priv == NULL) {
+ return -EINVAL;
+ }
+ /* Initialize the interface mode to None */
+ for (i=0; i<CSR_WIFI_NUM_INTERFACES; i++) {
+ priv->interfacePriv[i]->interfaceMode = 0;
+ }
+
+ /* Set up interface mode so that get_packet_priority() can
+ * select the right QOS priority when WMM is enabled.
+ */
+ priv->interfacePriv[0]->interfaceMode = CSR_WIFI_ROUTER_CTRL_MODE_STA;
+
+ r = uf_request_firmware_files(priv, UNIFI_FW_STA);
+ if (r) {
+ unifi_error(priv, "sme_mgt_wifi_on: Failed to get f/w\n");
+ return r;
+ }
+
+ /*
+ * The request to initialise UniFi might come while UniFi is running.
+ * We need to block all I/O activity until the reset completes, otherwise
+ * an SDIO error might occur resulting an indication to the SME which
+ * makes it think that the initialisation has failed.
+ */
+ priv->bh_thread.block_thread = 1;
+
+ /* Power on UniFi */
+ CsrSdioClaim(priv->sdio);
+ csrResult = CsrSdioPowerOn(priv->sdio);
+ CsrSdioRelease(priv->sdio);
+ if(csrResult != CSR_RESULT_SUCCESS && csrResult != CSR_SDIO_RESULT_NOT_RESET) {
+ return -EIO;
+ }
+
+ if (csrResult == CSR_RESULT_SUCCESS) {
+ /* Initialise UniFi hardware */
+ r = uf_init_hw(priv);
+ if (r) {
+ return r;
+ }
+ }
+
+ /* Re-enable the I/O thread */
+ priv->bh_thread.block_thread = 0;
+
+ /* Disable deep sleep signalling during the firmware initialisation, to
+ * prevent the wakeup mechanism raising the SDIO clock beyond INIT before
+ * the first MLME-RESET.ind. It gets re-enabled at the CONNECTED.ind,
+ * immediately after the MLME-RESET.ind
+ */
+ csrResult = unifi_configure_low_power_mode(priv->card,
+ UNIFI_LOW_POWER_DISABLED,
+ UNIFI_PERIODIC_WAKE_HOST_DISABLED);
+ if (csrResult != CSR_RESULT_SUCCESS) {
+ unifi_warning(priv,
+ "sme_mgt_wifi_on: unifi_configure_low_power_mode() returned an error\n");
+ }
+
+
+ /* Start the I/O thread */
+ CsrSdioClaim(priv->sdio);
+ r = uf_init_bh(priv);
+ if (r) {
+ CsrSdioPowerOff(priv->sdio);
+ CsrSdioRelease(priv->sdio);
+ return r;
+ }
+ CsrSdioRelease(priv->sdio);
+
+ priv->init_progress = UNIFI_INIT_FW_DOWNLOADED;
+
+ return 0;
+}
+
+int
+sme_sys_suspend(unifi_priv_t *priv)
+{
+ const int interfaceNum = 0; /* FIXME */
+ CsrResult csrResult;
+
+ /* Abort any pending requests. */
+ uf_abort_mlme(priv);
+
+ /* Allow our mlme request to go through. */
+ priv->io_aborted = 0;
+
+ /* Send MLME-RESET.req to UniFi. */
+ unifi_reset_state(priv, priv->netdev[interfaceNum]->dev_addr, 0);
+
+ /* Stop the network traffic */
+ netif_carrier_off(priv->netdev[interfaceNum]);
+
+ /* Put UniFi to deep sleep */
+ CsrSdioClaim(priv->sdio);
+ csrResult = unifi_force_low_power_mode(priv->card);
+ CsrSdioRelease(priv->sdio);
+
+ return 0;
+} /* sme_sys_suspend() */
+
+
+int
+sme_sys_resume(unifi_priv_t *priv)
+{
+#ifdef CSR_SUPPORT_WEXT
+ /* Send disconnect event so clients will re-initialise connection. */
+ memset(priv->wext_conf.current_ssid, 0, UNIFI_MAX_SSID_LEN);
+ memset((void*)priv->wext_conf.current_bssid, 0, ETH_ALEN);
+ priv->wext_conf.capability = 0;
+ wext_send_disassoc_event(priv);
+#endif
+ return 0;
+} /* sme_sys_resume() */
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * sme_native_log_event
+ *
+ * Callback function to be registered as the SME event callback.
+ * Copies the signal content into a new udi_log_t struct and adds
+ * it to the read queue for the SME client.
+ *
+ * Arguments:
+ * arg This is the value given to unifi_add_udi_hook, in
+ * this case a pointer to the client instance.
+ * signal Pointer to the received signal.
+ * signal_len Size of the signal structure in bytes.
+ * bulkdata Pointers to any associated bulk data.
+ * dir Direction of the signal. Zero means from host,
+ * non-zero means to host.
+ *
+ * Returns:
+ * None.
+ * ---------------------------------------------------------------------------
+ */
+void
+sme_native_log_event(ul_client_t *pcli,
+ const u8 *sig_packed, int sig_len,
+ const bulk_data_param_t *bulkdata,
+ int dir)
+{
+ unifi_priv_t *priv;
+ udi_log_t *logptr;
+ u8 *p;
+ int i, r;
+ int signal_len;
+ int total_len;
+ udi_msg_t *msgptr;
+ CSR_SIGNAL signal;
+ ul_client_t *client = pcli;
+
+ func_enter();
+
+ if (client == NULL) {
+ unifi_error(NULL, "sme_native_log_event: client has exited\n");
+ return;
+ }
+
+ priv = uf_find_instance(client->instance);
+ if (!priv) {
+ unifi_error(priv, "invalid priv\n");
+ return;
+ }
+
+ /* Just a sanity check */
+ if ((sig_packed == NULL) || (sig_len <= 0)) {
+ return;
+ }
+
+ /* Get the unpacked signal */
+ r = read_unpack_signal(sig_packed, &signal);
+ if (r == 0) {
+ signal_len = SigGetSize(&signal);
+ } else {
+ u16 receiver_id = CSR_GET_UINT16_FROM_LITTLE_ENDIAN((sig_packed) + sizeof(u16)) & 0xFF00;
+
+ /* The control indications are 1 byte, pass them to client. */
+ if (sig_len == 1) {
+ unifi_trace(priv, UDBG5,
+ "Control indication (0x%x) for native SME.\n",
+ *sig_packed);
+
+ *(u8*)&signal = *sig_packed;
+ signal_len = sig_len;
+ } else if (receiver_id == 0) {
+ /*
+ * Also "unknown" signals with a ReceiverId of 0 are passed to the client
+ * without unpacking. (This is a code size optimisation to allow signals
+ * that the driver not interested in to be dropped from the unpack code).
+ */
+ unifi_trace(priv, UDBG5,
+ "Signal 0x%.4X with ReceiverId 0 for native SME.\n",
+ CSR_GET_UINT16_FROM_LITTLE_ENDIAN(sig_packed));
+
+ *(u8*)&signal = *sig_packed;
+ signal_len = sig_len;
+ } else {
+ unifi_error(priv,
+ "sme_native_log_event - Received unknown signal 0x%.4X.\n",
+ CSR_GET_UINT16_FROM_LITTLE_ENDIAN(sig_packed));
+ return;
+ }
+ }
+
+ unifi_trace(priv, UDBG3, "sme_native_log_event: signal 0x%.4X for %d\n",
+ signal.SignalPrimitiveHeader.SignalId,
+ client->client_id);
+
+ total_len = signal_len;
+ /* Calculate the buffer we need to store signal plus bulk data */
+ for (i = 0; i < UNIFI_MAX_DATA_REFERENCES; i++) {
+ total_len += bulkdata->d[i].data_length;
+ }
+
+ /* Allocate log structure plus actual signal. */
+ logptr = (udi_log_t *)kmalloc(sizeof(udi_log_t) + total_len, GFP_KERNEL);
+
+ if (logptr == NULL) {
+ unifi_error(priv,
+ "Failed to allocate %d bytes for a UDI log record\n",
+ sizeof(udi_log_t) + total_len);
+ return;
+ }
+
+ /* Fill in udi_log struct */
+ INIT_LIST_HEAD(&logptr->q);
+ msgptr = &logptr->msg;
+ msgptr->length = sizeof(udi_msg_t) + total_len;
+ msgptr->timestamp = jiffies_to_msecs(jiffies);
+ msgptr->direction = dir;
+ msgptr->signal_length = signal_len;
+
+ /* Copy signal and bulk data to the log */
+ p = (u8 *)(msgptr + 1);
+ memcpy(p, &signal, signal_len);
+ p += signal_len;
+
+ /* Append any bulk data */
+ for (i = 0; i < UNIFI_MAX_DATA_REFERENCES; i++) {
+ int len = bulkdata->d[i].data_length;
+
+ /*
+ * Len here might not be the same as the length in the bulk data slot.
+ * The slot length will always be even, but len could be odd.
+ */
+ if (len > 0) {
+ if (bulkdata->d[i].os_data_ptr) {
+ memcpy(p, bulkdata->d[i].os_data_ptr, len);
+ } else {
+ memset(p, 0, len);
+ }
+ p += len;
+ }
+ }
+
+ /* Add to tail of log queue */
+ down(&client->udi_sem);
+ list_add_tail(&logptr->q, &client->udi_log);
+ up(&client->udi_sem);
+
+ /* Wake any waiting user process */
+ wake_up_interruptible(&client->udi_wq);
+
+ func_exit();
+
+} /* sme_native_log_event() */
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * unifi_ta_indicate_protocol
+ *
+ * Report that a packet of a particular type has been seen
+ *
+ * Arguments:
+ * drv_priv The device context pointer passed to ta_init.
+ * protocol The protocol type enum value.
+ * direction Whether the packet was a tx or rx.
+ * src_addr The source MAC address from the data packet.
+ *
+ * Returns:
+ * None.
+ *
+ * Notes:
+ * We defer the actual sending to a background workqueue,
+ * see uf_ta_ind_wq().
+ * ---------------------------------------------------------------------------
+ */
+void
+unifi_ta_indicate_protocol(void *ospriv,
+ CsrWifiRouterCtrlTrafficPacketType packet_type,
+ CsrWifiRouterCtrlProtocolDirection direction,
+ const CsrWifiMacAddress *src_addr)
+{
+
+} /* unifi_ta_indicate_protocol */
+
+/*
+ * ---------------------------------------------------------------------------
+ * unifi_ta_indicate_sampling
+ *
+ * Send the TA sampling information to the SME.
+ *
+ * Arguments:
+ * drv_priv The device context pointer passed to ta_init.
+ * stats The TA sampling data to send.
+ *
+ * Returns:
+ * None.
+ * ---------------------------------------------------------------------------
+ */
+void
+unifi_ta_indicate_sampling(void *ospriv, CsrWifiRouterCtrlTrafficStats *stats)
+{
+
+} /* unifi_ta_indicate_sampling() */
+
+
+void
+unifi_ta_indicate_l4stats(void *ospriv,
+ u32 rxTcpThroughput,
+ u32 txTcpThroughput,
+ u32 rxUdpThroughput,
+ u32 txUdpThroughput)
+{
+
+} /* unifi_ta_indicate_l4stats() */
+
+/*
+ * ---------------------------------------------------------------------------
+ * uf_native_process_udi_signal
+ *
+ * Process interesting signals from the UDI interface.
+ *
+ * Arguments:
+ * pcli A pointer to the client instance.
+ * signal Pointer to the received signal.
+ * signal_len Size of the signal structure in bytes.
+ * bulkdata Pointers to any associated bulk data.
+ * dir Direction of the signal. Zero means from host,
+ * non-zero means to host.
+ *
+ *
+ * Returns:
+ * None.
+ * ---------------------------------------------------------------------------
+ */
+void
+uf_native_process_udi_signal(ul_client_t *pcli,
+ const u8 *packed_signal, int packed_signal_len,
+ const bulk_data_param_t *bulkdata, int dir)
+{
+
+} /* uf_native_process_udi_signal() */
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * sme_native_mlme_event_handler
+ *
+ * Callback function to be used as the udi_event_callback when registering
+ * as a client.
+ * This function implements a blocking request-reply interface for WEXT.
+ * To use it, a client specifies this function as the udi_event_callback
+ * to ul_register_client(). The signal dispatcher in
+ * unifi_receive_event() will call this function to deliver a signal.
+ *
+ * Arguments:
+ * pcli Pointer to the client instance.
+ * signal Pointer to the received signal.
+ * signal_len Size of the signal structure in bytes.
+ * bulkdata Pointer to structure containing any associated bulk data.
+ * dir Direction of the signal. Zero means from host,
+ * non-zero means to host.
+ *
+ * Returns:
+ * None.
+ * ---------------------------------------------------------------------------
+ */
+void
+sme_native_mlme_event_handler(ul_client_t *pcli,
+ const u8 *sig_packed, int sig_len,
+ const bulk_data_param_t *bulkdata,
+ int dir)
+{
+ CSR_SIGNAL signal;
+ int signal_len;
+ unifi_priv_t *priv = uf_find_instance(pcli->instance);
+ int id, r;
+
+ func_enter();
+
+ /* Just a sanity check */
+ if ((sig_packed == NULL) || (sig_len <= 0)) {
+ return;
+ }
+
+ /* Get the unpacked signal */
+ r = read_unpack_signal(sig_packed, &signal);
+ if (r == 0) {
+ signal_len = SigGetSize(&signal);
+ } else {
+ unifi_error(priv,
+ "sme_native_mlme_event_handler - Received unknown signal 0x%.4X.\n",
+ CSR_GET_UINT16_FROM_LITTLE_ENDIAN(sig_packed));
+ return;
+ }
+
+ id = signal.SignalPrimitiveHeader.SignalId;
+ unifi_trace(priv, UDBG4, "wext - Process signal 0x%.4X\n", id);
+
+ /*
+ * Take the appropriate action for the signal.
+ */
+ switch (id) {
+ /*
+ * Confirm replies from UniFi.
+ * These all have zero or one CSR_DATAREF member. (FIXME: check this is still true for softmac)
+ */
+ case CSR_MA_PACKET_CONFIRM_ID:
+ case CSR_MLME_RESET_CONFIRM_ID:
+ case CSR_MLME_GET_CONFIRM_ID:
+ case CSR_MLME_SET_CONFIRM_ID:
+ case CSR_MLME_GET_NEXT_CONFIRM_ID:
+ case CSR_MLME_POWERMGT_CONFIRM_ID:
+ case CSR_MLME_SCAN_CONFIRM_ID:
+ case CSR_MLME_HL_SYNC_CONFIRM_ID:
+ case CSR_MLME_MEASURE_CONFIRM_ID:
+ case CSR_MLME_SETKEYS_CONFIRM_ID:
+ case CSR_MLME_DELETEKEYS_CONFIRM_ID:
+ case CSR_MLME_HL_SYNC_CANCEL_CONFIRM_ID:
+ case CSR_MLME_ADD_PERIODIC_CONFIRM_ID:
+ case CSR_MLME_DEL_PERIODIC_CONFIRM_ID:
+ case CSR_MLME_ADD_AUTONOMOUS_SCAN_CONFIRM_ID:
+ case CSR_MLME_DEL_AUTONOMOUS_SCAN_CONFIRM_ID:
+ case CSR_MLME_SET_PACKET_FILTER_CONFIRM_ID:
+ case CSR_MLME_STOP_MEASURE_CONFIRM_ID:
+ case CSR_MLME_PAUSE_AUTONOMOUS_SCAN_CONFIRM_ID:
+ case CSR_MLME_ADD_TRIGGERED_GET_CONFIRM_ID:
+ case CSR_MLME_DEL_TRIGGERED_GET_CONFIRM_ID:
+ case CSR_MLME_ADD_BLACKOUT_CONFIRM_ID:
+ case CSR_MLME_DEL_BLACKOUT_CONFIRM_ID:
+ case CSR_MLME_ADD_RX_TRIGGER_CONFIRM_ID:
+ case CSR_MLME_DEL_RX_TRIGGER_CONFIRM_ID:
+ case CSR_MLME_CONNECT_STATUS_CONFIRM_ID:
+ case CSR_MLME_MODIFY_BSS_PARAMETER_CONFIRM_ID:
+ case CSR_MLME_ADD_TEMPLATE_CONFIRM_ID:
+ case CSR_MLME_CONFIG_QUEUE_CONFIRM_ID:
+ case CSR_MLME_ADD_TSPEC_CONFIRM_ID:
+ case CSR_MLME_DEL_TSPEC_CONFIRM_ID:
+ case CSR_MLME_START_AGGREGATION_CONFIRM_ID:
+ case CSR_MLME_STOP_AGGREGATION_CONFIRM_ID:
+ case CSR_MLME_SM_START_CONFIRM_ID:
+ case CSR_MLME_LEAVE_CONFIRM_ID:
+ case CSR_MLME_SET_TIM_CONFIRM_ID:
+ case CSR_MLME_GET_KEY_SEQUENCE_CONFIRM_ID:
+ case CSR_MLME_SET_CHANNEL_CONFIRM_ID:
+ case CSR_MLME_ADD_MULTICAST_ADDRESS_CONFIRM_ID:
+ case CSR_DEBUG_GENERIC_CONFIRM_ID:
+ unifi_mlme_copy_reply_and_wakeup_client(pcli, &signal, signal_len, bulkdata);
+ break;
+
+ case CSR_MLME_CONNECTED_INDICATION_ID:
+ /* We currently ignore the connected-ind for softmac f/w development */
+ unifi_info(priv, "CSR_MLME_CONNECTED_INDICATION_ID ignored\n");
+ break;
+
+ default:
+ break;
+ }
+
+ func_exit();
+} /* sme_native_mlme_event_handler() */
+
+
+
+/*
+ * -------------------------------------------------------------------------
+ * unifi_reset_state
+ *
+ * Ensure that a MAC address has been set.
+ * Send the MLME-RESET signal.
+ * This must be called at least once before starting to do any
+ * network activities (e.g. scan, join etc).
+ *
+ * Arguments:
+ * priv Pointer to device private context struct
+ * macaddr Pointer to chip MAC address.
+ * If this is FF:FF:FF:FF:FF:FF it will be replaced
+ * with the MAC address from the chip.
+ * set_default_mib 1 if the f/w must reset the MIB to the default values
+ * 0 otherwise
+ *
+ * Returns:
+ * 0 on success, an error code otherwise.
+ * -------------------------------------------------------------------------
+ */
+int
+unifi_reset_state(unifi_priv_t *priv, unsigned char *macaddr,
+ unsigned char set_default_mib)
+{
+ int r = 0;
+
+ func_enter();
+
+#ifdef CSR_SUPPORT_WEXT
+ /* The reset clears any 802.11 association. */
+ priv->wext_conf.flag_associated = 0;
+#endif
+
+ func_exit();
+ return r;
+} /* unifi_reset_state() */
+
diff --git a/drivers/staging/csr/sme_sys.c b/drivers/staging/csr/sme_sys.c
new file mode 100644
index 000000000000..99de27e678d2
--- /dev/null
+++ b/drivers/staging/csr/sme_sys.c
@@ -0,0 +1,3262 @@
+/*
+ * ---------------------------------------------------------------------------
+ * FILE: sme_sys.c
+ *
+ * PURPOSE:
+ * Driver specific implementation of the SME SYS SAP.
+ * It is part of the porting exercise.
+ *
+ * Copyright (C) 2008-2011 by Cambridge Silicon Radio Ltd.
+ *
+ * Refer to LICENSE.txt included with this source code for details on
+ * the license terms.
+ *
+ * ---------------------------------------------------------------------------
+ */
+
+#include "csr_wifi_hip_unifiversion.h"
+#include "unifi_priv.h"
+#include "csr_wifi_hip_conversions.h"
+#ifdef CSR_SUPPORT_WEXT_AP
+#include "csr_wifi_sme_sef.h"
+#endif
+
+
+/*
+ * This file implements the SME SYS API and contains the following functions:
+ * CsrWifiRouterCtrlMediaStatusReqHandler()
+ * CsrWifiRouterCtrlHipReqHandler()
+ * CsrWifiRouterCtrlPortConfigureReqHandler()
+ * CsrWifiRouterCtrlWifiOnReqHandler()
+ * CsrWifiRouterCtrlWifiOffReqHandler()
+ * CsrWifiRouterCtrlSuspendResHandler()
+ * CsrWifiRouterCtrlResumeResHandler()
+ * CsrWifiRouterCtrlQosControlReqHandler()
+ * CsrWifiRouterCtrlConfigurePowerModeReqHandler()
+ * CsrWifiRouterCtrlWifiOnResHandler()
+ * CsrWifiRouterCtrlWifiOffRspHandler()
+ * CsrWifiRouterCtrlMulticastAddressResHandler()
+ * CsrWifiRouterCtrlTrafficConfigReqHandler()
+ * CsrWifiRouterCtrlTrafficClassificationReqHandler()
+ * CsrWifiRouterCtrlTclasAddReqHandler()
+ * CsrWifiRouterCtrlTclasDelReqHandler()
+ * CsrWifiRouterCtrlSetModeReqHandler()
+ * CsrWifiRouterCtrlWapiMulticastFilterReqHandler()
+ * CsrWifiRouterCtrlWapiUnicastFilterReqHandler()
+ * CsrWifiRouterCtrlWapiUnicastTxPktReqHandler()
+ * CsrWifiRouterCtrlWapiRxPktReqHandler()
+ * CsrWifiRouterCtrlWapiFilterReqHandler()
+ */
+
+#ifdef CSR_SUPPORT_SME
+static void check_inactivity_timer_expire_func(unsigned long data);
+void uf_send_disconnected_ind_wq(struct work_struct *work);
+#endif
+
+void send_auto_ma_packet_confirm(unifi_priv_t *priv,
+ netInterface_priv_t *interfacePriv,
+ struct list_head *buffered_frames_list)
+{
+ tx_buffered_packets_t *buffered_frame_item = NULL;
+ struct list_head *listHead;
+ struct list_head *placeHolder;
+ int client_id;
+
+ CSR_SIGNAL unpacked_signal;
+ u8 sigbuf[UNIFI_PACKED_SIGBUF_SIZE];
+ u16 packed_siglen;
+
+
+ list_for_each_safe(listHead, placeHolder, buffered_frames_list)
+ {
+ buffered_frame_item = list_entry(listHead, tx_buffered_packets_t, q);
+
+ if(!buffered_frame_item) {
+ unifi_error(priv, "Entry should exist, otherwise it is a (BUG)\n");
+ continue;
+ }
+
+ if ((interfacePriv->interfaceMode != CSR_WIFI_ROUTER_CTRL_MODE_NONE) &&
+ (priv->wifi_on_state == wifi_on_done))
+ {
+
+ unifi_warning(priv, "Send MA_PACKET_CONFIRM to SenderProcessId = %x for (HostTag = %x TransmissionControl = %x)\n",
+ (buffered_frame_item->leSenderProcessId),
+ buffered_frame_item->hostTag,
+ buffered_frame_item->transmissionControl);
+
+ client_id = buffered_frame_item->leSenderProcessId & 0xFF00;
+
+ if (client_id == priv->sme_cli->sender_id)
+ {
+ /* construct a MA-PACKET.confirm message for SME */
+ memset(&unpacked_signal, 0, sizeof(unpacked_signal));
+ unpacked_signal.SignalPrimitiveHeader.SignalId = CSR_MA_PACKET_CONFIRM_ID;
+ unpacked_signal.SignalPrimitiveHeader.ReceiverProcessId = buffered_frame_item->leSenderProcessId;
+ unpacked_signal.SignalPrimitiveHeader.SenderProcessId = CSR_WIFI_ROUTER_IFACEQUEUE;
+
+ unpacked_signal.u.MaPacketConfirm.VirtualInterfaceIdentifier = uf_get_vif_identifier(interfacePriv->interfaceMode,
+ interfacePriv->InterfaceTag);
+ unpacked_signal.u.MaPacketConfirm.TransmissionStatus = CSR_RESULT_FAILURE;
+ unpacked_signal.u.MaPacketConfirm.RetryCount = 0;
+ unpacked_signal.u.MaPacketConfirm.Rate = buffered_frame_item->rate;
+ unpacked_signal.u.MaPacketConfirm.HostTag = buffered_frame_item->hostTag;
+
+ write_pack(&unpacked_signal, sigbuf, &packed_siglen);
+ unifi_warning(priv, "MA_PACKET_CONFIRM for SME (0x%x, 0x%x, 0x%x, 0x%x)\n",
+ unpacked_signal.SignalPrimitiveHeader.ReceiverProcessId,
+ unpacked_signal.SignalPrimitiveHeader.SenderProcessId,
+ unpacked_signal.u.MaPacketConfirm.VirtualInterfaceIdentifier,
+ unpacked_signal.u.MaPacketConfirm.HostTag);
+
+ CsrWifiRouterCtrlHipIndSend(priv->CSR_WIFI_SME_IFACEQUEUE,
+ packed_siglen,
+ (u8 *)sigbuf,
+ 0, NULL,
+ 0, NULL);
+ }
+ else if((buffered_frame_item->hostTag & 0x80000000))
+ {
+ /* construct a MA-PACKET.confirm message for NME */
+ unifi_warning(priv, "MA_PACKET_CONFIRM for NME (0x%x, 0x%x, 0x%x, 0x%x)\n",
+ buffered_frame_item->leSenderProcessId,
+ buffered_frame_item->interfaceTag,
+ buffered_frame_item->transmissionControl,
+ (buffered_frame_item->hostTag & 0x3FFFFFFF));
+
+ CsrWifiRouterMaPacketCfmSend((buffered_frame_item->leSenderProcessId & 0xFF),
+ buffered_frame_item->interfaceTag,
+ CSR_RESULT_FAILURE,
+ (buffered_frame_item->hostTag & 0x3FFFFFFF),
+ buffered_frame_item->rate);
+
+ }
+ else
+ {
+ unifi_warning(priv, "Buffered packet dropped without sending a confirm\n");
+ }
+
+ }
+
+ list_del(listHead);
+ kfree(buffered_frame_item);
+ buffered_frame_item = NULL;
+ }
+}
+
+void CsrWifiRouterCtrlMediaStatusReqHandler(void* drvpriv, CsrWifiFsmEvent* msg)
+{
+ unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
+ CsrWifiRouterCtrlMediaStatusReq* req = (CsrWifiRouterCtrlMediaStatusReq*)msg;
+ netInterface_priv_t *interfacePriv = priv->interfacePriv[req->interfaceTag];
+ unsigned long flags;
+
+ if (priv->smepriv == NULL) {
+ unifi_error(priv, "CsrWifiRouterCtrlMediaStatusReqHandler: invalid smepriv\n");
+ return;
+ }
+ if (req->interfaceTag >= CSR_WIFI_NUM_INTERFACES) {
+ unifi_error(priv, "CsrWifiRouterCtrlMediaStatusReqHandler: invalid interfaceTag\n");
+ return;
+ }
+ unifi_trace(priv, UDBG3, "CsrWifiRouterCtrlMediaStatusReqHandler: Mode = %d req->mediaStatus = %d\n",interfacePriv->interfaceMode,req->mediaStatus);
+ if (interfacePriv->interfaceMode != CSR_WIFI_ROUTER_CTRL_MODE_AMP) {
+ bulk_data_desc_t bulk_data;
+
+ bulk_data.data_length = 0;
+
+ spin_lock_irqsave(&priv->m4_lock, flags);
+ if (interfacePriv->m4_bulk_data.data_length > 0) {
+ bulk_data = interfacePriv->m4_bulk_data;
+ interfacePriv->m4_bulk_data.net_buf_length = 0;
+ interfacePriv->m4_bulk_data.data_length = 0;
+ interfacePriv->m4_bulk_data.os_data_ptr = interfacePriv->m4_bulk_data.os_net_buf_ptr = NULL;
+ }
+ spin_unlock_irqrestore(&priv->m4_lock, flags);
+
+ if (bulk_data.data_length != 0) {
+ unifi_trace(priv, UDBG5, "CsrWifiRouterCtrlMediaStatusReqHandler: free M4\n");
+ unifi_net_data_free(priv, &bulk_data);
+ }
+
+ if ((req->mediaStatus == CSR_WIFI_SME_MEDIA_STATUS_CONNECTED) &&
+ (interfacePriv->connected != UnifiConnected)) {
+
+ switch(interfacePriv->interfaceMode){
+ case CSR_WIFI_ROUTER_CTRL_MODE_AP:
+ case CSR_WIFI_ROUTER_CTRL_MODE_P2PGO:
+ interfacePriv->connected = UnifiConnected;
+ netif_carrier_on(priv->netdev[req->interfaceTag]);
+#ifdef CSR_SUPPORT_WEXT
+ wext_send_started_event(priv);
+#endif
+ unifi_trace(priv, UDBG1,
+ "CsrWifiRouterCtrlMediaStatusReqHandler: AP/P2PGO setting netif_carrier_on\n");
+ UF_NETIF_TX_WAKE_ALL_QUEUES(priv->netdev[req->interfaceTag]);
+ break;
+
+ default:
+#ifdef CSR_SUPPORT_WEXT
+ /* In the WEXT builds (sme and native), the userspace is not ready
+ * to process any EAPOL or WAPI packets, until it has been informed
+ * of the NETDEV_CHANGE.
+ */
+ if (interfacePriv->netdev_callback_registered && (interfacePriv->interfaceMode != CSR_WIFI_ROUTER_CTRL_MODE_P2PCLI)) {
+ interfacePriv->wait_netdev_change = TRUE;
+ unifi_trace(priv, UDBG1,
+ "CsrWifiRouterCtrlMediaStatusReqHandler: waiting for NETDEV_CHANGE\n");
+ /*
+ * Carrier can go to on, only after wait_netdev_change is set to TRUE.
+ * Otherwise there can be a race in uf_netdev_event().
+ */
+ netif_carrier_on(priv->netdev[req->interfaceTag]);
+ unifi_trace(priv, UDBG1,
+ "CsrWifiRouterCtrlMediaStatusReqHandler: STA/P2PCLI setting netif_carrier_on\n");
+ }
+ else
+#endif
+ {
+ /* In the NME build, the userspace does not wait for the NETDEV_CHANGE
+ * so it is ready to process all the EAPOL or WAPI packets.
+ * At this point, we enable all the Tx queues, and we indicate any packets
+ * that are queued (and the respective port is opened).
+ */
+ static const CsrWifiMacAddress broadcast_address = {{0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}};
+ interfacePriv->connected = UnifiConnected;
+ unifi_trace(priv, UDBG1,
+ "CsrWifiRouterMediaStatusReqHandler: UnifiConnected && netif_carrier_on\n");
+ netif_carrier_on(priv->netdev[req->interfaceTag]);
+ UF_NETIF_TX_WAKE_ALL_QUEUES(priv->netdev[req->interfaceTag]);
+ uf_process_rx_pending_queue(priv, UF_UNCONTROLLED_PORT_Q, broadcast_address, 1, interfacePriv->InterfaceTag);
+ uf_process_rx_pending_queue(priv, UF_CONTROLLED_PORT_Q, broadcast_address, 1, interfacePriv->InterfaceTag);
+ }
+ break;
+ }
+ }
+
+ if (req->mediaStatus == CSR_WIFI_SME_MEDIA_STATUS_DISCONNECTED) {
+#ifdef CSR_SUPPORT_WEXT
+ unifi_trace(priv, UDBG1,
+ "CsrWifiRouterMediaStatusReqHandler: cancel waiting for NETDEV_CHANGE\n");
+ interfacePriv->wait_netdev_change = FALSE;
+#endif
+ unifi_trace(priv, UDBG1,
+ "CsrWifiRouterMediaStatusReqHandler: setting netif_carrier_off\n");
+ netif_carrier_off(priv->netdev[req->interfaceTag]);
+#ifdef CSR_SUPPORT_WEXT
+ switch(interfacePriv->interfaceMode){
+ case CSR_WIFI_ROUTER_CTRL_MODE_AP:
+ case CSR_WIFI_ROUTER_CTRL_MODE_P2PGO:
+ wext_send_started_event(priv);
+ break;
+ default:
+ break;
+ }
+#endif
+ interfacePriv->connected = UnifiNotConnected;
+ }
+ } else {
+ /* For AMP, just update the L2 connected flag */
+ if (req->mediaStatus == CSR_WIFI_SME_MEDIA_STATUS_CONNECTED) {
+ unifi_trace(priv, UDBG1, "CsrWifiRouterCtrlMediaStatusReqHandler: AMP connected\n");
+ interfacePriv->connected = UnifiConnected;
+ } else {
+ unifi_trace(priv, UDBG1, "CsrWifiRouterCtrlMediaStatusReqHandler: AMP disconnected\n");
+ interfacePriv->connected = UnifiNotConnected;
+ }
+ }
+}
+
+
+void CsrWifiRouterCtrlHipReqHandler(void* drvpriv, CsrWifiFsmEvent* msg)
+{
+ unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
+ CsrWifiRouterCtrlHipReq* hipreq = (CsrWifiRouterCtrlHipReq*)msg;
+ bulk_data_param_t bulkdata;
+ u8 *signal_ptr;
+ int signal_length;
+ int r=0;
+ void *dest;
+ CsrResult csrResult;
+ CSR_SIGNAL *signal;
+ u16 interfaceTag = 0;
+ CSR_MA_PACKET_REQUEST *req;
+ netInterface_priv_t *interfacePriv = priv->interfacePriv[interfaceTag];
+
+ if (priv == NULL) {
+ return;
+ }
+ if (priv->smepriv == NULL) {
+ unifi_error(priv, "CsrWifiRouterCtrlHipReqHandler: invalid smepriv\n");
+ return;
+ }
+ if (interfaceTag >= CSR_WIFI_NUM_INTERFACES) {
+ unifi_error(priv, "CsrWifiRouterCtrlHipReqHandler: invalid interfaceTag\n");
+ return;
+ }
+
+ /* Initialize bulkdata to avoid os_net_buf is garbage */
+ memset(&bulkdata, 0, sizeof(bulk_data_param_t));
+
+ signal = (CSR_SIGNAL *)hipreq->mlmeCommand;
+
+ unifi_trace(priv, UDBG4, "CsrWifiRouterCtrlHipReqHandler: 0x04%X ---->\n",
+ *((u16*)hipreq->mlmeCommand));
+
+ /* Construct the signal. */
+ signal_ptr = (u8*)hipreq->mlmeCommand;
+ signal_length = hipreq->mlmeCommandLength;
+
+ /*
+ * The MSB of the sender ID needs to be set to the client ID.
+ * The LSB is controlled by the SME.
+ */
+ signal_ptr[5] = (priv->sme_cli->sender_id >> 8) & 0xff;
+
+ /* Allocate buffers for the bulk data. */
+ if (hipreq->dataRef1Length) {
+ csrResult = unifi_net_data_malloc(priv, &bulkdata.d[0], hipreq->dataRef1Length);
+ if (csrResult == CSR_RESULT_SUCCESS) {
+ dest = (void*)bulkdata.d[0].os_data_ptr;
+ memcpy(dest, hipreq->dataRef1, hipreq->dataRef1Length);
+ bulkdata.d[0].data_length = hipreq->dataRef1Length;
+ } else {
+ unifi_warning(priv, "signal not sent down, allocation failed in CsrWifiRouterCtrlHipReqHandler\n");
+ return;
+ }
+ } else {
+ bulkdata.d[0].os_data_ptr = NULL;
+ bulkdata.d[0].data_length = 0;
+ }
+ if (hipreq->dataRef2Length) {
+ csrResult = unifi_net_data_malloc(priv, &bulkdata.d[1], hipreq->dataRef2Length);
+ if (csrResult == CSR_RESULT_SUCCESS) {
+ dest = (void*)bulkdata.d[1].os_data_ptr;
+ memcpy(dest, hipreq->dataRef2, hipreq->dataRef2Length);
+ bulkdata.d[1].data_length = hipreq->dataRef2Length;
+ } else {
+ if (bulkdata.d[0].data_length)
+ {
+ unifi_net_data_free(priv, &bulkdata.d[0]);
+ }
+ unifi_warning(priv, "signal not sent down, allocation failed in CsrWifiRouterCtrlHipReqHandler\n");
+ return;
+ }
+ } else {
+ bulkdata.d[1].os_data_ptr = NULL;
+ bulkdata.d[1].data_length = 0;
+ }
+
+ unifi_trace(priv, UDBG3, "SME SEND: Signal 0x%.4X \n",
+ *((u16*)signal_ptr));
+ if (signal->SignalPrimitiveHeader.SignalId == CSR_MA_PACKET_REQUEST_ID)
+ {
+ CSR_SIGNAL unpacked_signal;
+ read_unpack_signal((u8 *) signal, &unpacked_signal);
+ req = &unpacked_signal.u.MaPacketRequest;
+ interfaceTag = req->VirtualInterfaceIdentifier & 0xff;
+ switch(interfacePriv->interfaceMode)
+ {
+ case CSR_WIFI_ROUTER_CTRL_MODE_NONE:
+ unifi_error(priv, "CsrWifiRouterCtrlHipReqHandler: invalid mode: NONE \n");
+ break;
+ default:
+ unifi_trace(priv, UDBG5, "mode is %x\n", interfacePriv->interfaceMode);
+ }
+ /* While sending ensure that first 2 bits b31 and b30 are 00. These are used for local routing*/
+ r = uf_process_ma_packet_req(priv, req->Ra.x, (req->HostTag & 0x3FFFFFFF), interfaceTag,
+ req->TransmissionControl, req->TransmitRate,
+ req->Priority, signal->SignalPrimitiveHeader.SenderProcessId,
+ &bulkdata);
+ if (r)
+ {
+ if (bulkdata.d[0].data_length)
+ {
+ unifi_net_data_free(priv, &bulkdata.d[0]);
+ }
+ if (bulkdata.d[1].data_length)
+ {
+ unifi_net_data_free(priv, &bulkdata.d[1]);
+ }
+ }
+ } else {
+ /* ul_send_signal_raw frees the bulk data if it fails */
+ r = ul_send_signal_raw(priv, signal_ptr, signal_length, &bulkdata);
+ }
+
+ if (r) {
+ unifi_error(priv,
+ "CsrWifiRouterCtrlHipReqHandler: Failed to send signal (0x%.4X - %u)\n",
+ *((u16*)signal_ptr), r);
+ CsrWifiRouterCtrlWifiOffIndSend(priv->CSR_WIFI_SME_IFACEQUEUE,0,CSR_WIFI_SME_CONTROL_INDICATION_ERROR);
+ }
+
+ unifi_trace(priv, UDBG4, "CsrWifiRouterCtrlHipReqHandler: <----\n");
+}
+
+#ifdef CSR_WIFI_SEND_GRATUITOUS_ARP
+static void
+uf_send_gratuitous_arp(unifi_priv_t *priv, u16 interfaceTag)
+{
+ netInterface_priv_t *interfacePriv = priv->interfacePriv[interfaceTag];
+ CSR_PRIORITY priority;
+ CSR_SIGNAL signal;
+ bulk_data_param_t bulkdata;
+ CsrResult csrResult;
+ struct sk_buff *skb, *newSkb = NULL;
+ s8 protection;
+ int r;
+ static const u8 arp_req[36] = {0xaa, 0xaa, 0x03, 0x00, 0x00, 0x00,
+ 0x08, 0x06, 0x00, 0x01, 0x08, 0x00, 0x06, 0x04, 0x00, 0x01,
+ 0x00, 0x02, 0x5f, 0x20, 0x2f, 0x02,
+ 0xc0, 0xa8, 0x00, 0x02,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xc0, 0xa8, 0x00, 0x02};
+
+ func_enter();
+
+ csrResult = unifi_net_data_malloc(priv, &bulkdata.d[0], sizeof(arp_req));
+ if (csrResult != CSR_RESULT_SUCCESS)
+ {
+ unifi_error(priv, "Failed to allocate bulk data in CsrWifiSmeRoamCompleteIndHandler()\n");
+ return;
+ }
+ skb = (struct sk_buff *)(bulkdata.d[0].os_net_buf_ptr);
+ skb->len = bulkdata.d[0].data_length;
+
+ memcpy(skb->data, arp_req, sizeof(arp_req));
+ /* add MAC and IP address */
+ memcpy(skb->data + 16, priv->netdev[interfaceTag]->dev_addr, ETH_ALEN);
+ skb->data[22] = (priv->sta_ip_address ) & 0xFF;
+ skb->data[23] = (priv->sta_ip_address >> 8) & 0xFF;
+ skb->data[24] = (priv->sta_ip_address >> 16) & 0xFF;
+ skb->data[25] = (priv->sta_ip_address >> 24) & 0xFF;
+ skb->data[32] = (priv->sta_ip_address ) & 0xFF;
+ skb->data[33] = (priv->sta_ip_address >> 8) & 0xFF;
+ skb->data[34] = (priv->sta_ip_address >> 16) & 0xFF;
+ skb->data[35] = (priv->sta_ip_address >> 24) & 0xFF;
+
+ bulkdata.d[1].os_data_ptr = NULL;
+ bulkdata.d[1].os_net_buf_ptr = NULL;
+ bulkdata.d[1].net_buf_length = bulkdata.d[1].data_length = 0;
+
+ if ((protection = uf_get_protection_bit_from_interfacemode(priv, interfaceTag, &arp_req[26])) < 0)
+ {
+ unifi_error(priv, "CsrWifiSmeRoamCompleteIndHandler: Failed to determine protection mode\n");
+ unifi_net_data_free(priv, &bulkdata.d[0]);
+ return;
+ }
+
+ if ((priv->sta_wmm_capabilities & QOS_CAPABILITY_WMM_ENABLED) == 1)
+ {
+ priority = CSR_QOS_UP0;
+ }
+ else
+ {
+ priority = CSR_CONTENTION;
+ }
+
+ if (prepare_and_add_macheader(priv, skb, newSkb, priority, &bulkdata,
+ interfaceTag, &arp_req[26],
+ priv->netdev[interfaceTag]->dev_addr, protection))
+ {
+ unifi_error(priv, "CsrWifiSmeRoamCompleteIndHandler: failed to create MAC header\n");
+ unifi_net_data_free(priv, &bulkdata.d[0]);
+ return;
+ }
+ bulkdata.d[0].os_data_ptr = skb->data;
+ bulkdata.d[0].os_net_buf_ptr = skb;
+ bulkdata.d[0].data_length = skb->len;
+
+ unifi_frame_ma_packet_req(priv, priority, 0, 0xffffffff, interfaceTag,
+ CSR_NO_CONFIRM_REQUIRED, priv->netdev_client->sender_id,
+ interfacePriv->bssid.a, &signal);
+
+ r = ul_send_signal_unpacked(priv, &signal, &bulkdata);
+ if (r)
+ {
+ unifi_error(priv, "CsrWifiSmeRoamCompleteIndHandler: failed to send QOS data null packet result: %d\n",r);
+ unifi_net_data_free(priv, &bulkdata.d[0]);
+ return;
+ }
+
+ func_exit();
+
+}
+#endif /* CSR_WIFI_SEND_GRATUITOUS_ARP */
+
+/*
+ * ---------------------------------------------------------------------------
+ * configure_data_port
+ *
+ * Store the new controlled port configuration.
+ *
+ * Arguments:
+ * priv Pointer to device private context struct
+ * port_cfg Pointer to the port configuration
+ *
+ * Returns:
+ * An unifi_ControlledPortAction value.
+ * ---------------------------------------------------------------------------
+ */
+static int
+configure_data_port(unifi_priv_t *priv,
+ CsrWifiRouterCtrlPortAction port_action,
+ const CsrWifiMacAddress *macAddress,
+ const int queue,
+ u16 interfaceTag)
+{
+ const u8 broadcast_mac_address[] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
+ unifi_port_config_t *port;
+ netInterface_priv_t *interfacePriv;
+ int i;
+ const char* controlled_string; /* cosmetic "controlled"/"uncontrolled" for trace */
+
+ if (interfaceTag >= CSR_WIFI_NUM_INTERFACES) {
+ unifi_error(priv, "configure_data_port: bad interfaceTag\n");
+ return -EFAULT;
+ }
+
+ interfacePriv = priv->interfacePriv[interfaceTag];
+
+ if (queue == UF_CONTROLLED_PORT_Q) {
+ port = &interfacePriv->controlled_data_port;
+ controlled_string = "controlled";
+ } else {
+ port = &interfacePriv->uncontrolled_data_port;
+ controlled_string = "uncontrolled";
+ }
+
+ unifi_trace(priv, UDBG2,
+ "port config request %pM %s with port_action %d.\n",
+ macAddress->a, controlled_string, port_action);
+
+ /* If the new configuration has the broadcast MAC address or if we are in infrastructure mode then clear the list first and set port overide mode */
+ if ((CSR_WIFI_ROUTER_CTRL_MODE_STA == interfacePriv->interfaceMode ||
+ interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_P2PCLI) ||
+ !memcmp(macAddress->a, broadcast_mac_address, ETH_ALEN)) {
+
+ port->port_cfg[0].port_action = port_action;
+ port->port_cfg[0].mac_address = *macAddress;
+ port->port_cfg[0].in_use = TRUE;
+ port->entries_in_use = 1;
+ port->overide_action = UF_DATA_PORT_OVERIDE;
+
+ unifi_trace(priv, UDBG2, "%s port override on\n",
+ (queue == UF_CONTROLLED_PORT_Q) ? "Controlled" : "Uncontrolled");
+
+ /* Discard the remaining entries in the port config table */
+ for (i = 1; i < UNIFI_MAX_CONNECTIONS; i++) {
+ port->port_cfg[i].in_use = FALSE;
+ }
+
+ if (port_action == CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_OPEN) {
+ unifi_trace(priv, UDBG1, "%s port broadcast set to open.\n",
+ (queue == UF_CONTROLLED_PORT_Q) ? "Controlled" : "Uncontrolled");
+
+ /*
+ * Ask stack to schedule for transmission any packets queued
+ * while controlled port was not open.
+ * Use netif_schedule() instead of netif_wake_queue() because
+ * transmission should be already enabled at this point. If it
+ * is not, probably the interface is down and should remain as is.
+ */
+ uf_resume_data_plane(priv, queue, *macAddress, interfaceTag);
+
+#ifdef CSR_WIFI_SEND_GRATUITOUS_ARP
+ if ((CSR_WIFI_ROUTER_CTRL_MODE_STA == interfacePriv->interfaceMode) &&
+ (queue == UF_CONTROLLED_PORT_Q) && (priv->sta_ip_address != 0xFFFFFFFF))
+ {
+ uf_send_gratuitous_arp(priv, interfaceTag);
+ }
+#endif
+ } else {
+ unifi_trace(priv, UDBG1, "%s port broadcast set to %s.\n",
+ (queue == UF_CONTROLLED_PORT_Q) ? "Controlled" : "Uncontrolled",
+ (port_action == CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_CLOSED_DISCARD) ? "discard": "closed");
+
+ /* If port is closed, discard all the pending Rx packets */
+ if (port_action == CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_CLOSED_DISCARD) {
+ uf_free_pending_rx_packets(priv, queue, *macAddress,interfaceTag);
+ }
+ }
+ } else {
+ /* store the new configuration, either in the entry with matching mac address (if already present),
+ * otherwise in a new entry
+ */
+
+ int found_entry_flag;
+ int first_free_slot = -1;
+
+ /* If leaving override mode, free the port entry used for override */
+ if (port->overide_action == UF_DATA_PORT_OVERIDE) {
+ port->port_cfg[0].in_use = FALSE;
+ port->entries_in_use = 0;
+ port->overide_action = UF_DATA_PORT_NOT_OVERIDE;
+
+ unifi_trace(priv, UDBG2, "%s port override off\n",
+ (queue == UF_CONTROLLED_PORT_Q) ? "Controlled" : "Uncontrolled");
+ }
+
+ found_entry_flag = 0;
+ for (i = 0; i < UNIFI_MAX_CONNECTIONS; i++) {
+ if (port->port_cfg[i].in_use) {
+ if (!memcmp(&port->port_cfg[i].mac_address.a, macAddress->a, ETH_ALEN)) {
+ /* We've seen this address before, reconfigure it */
+ port->port_cfg[i].port_action = port_action;
+ found_entry_flag = 1;
+ break;
+ }
+ } else if (first_free_slot == -1) {
+ /* Remember the first free slot on the way past so it can be claimed
+ * if this turns out to be a new MAC address (to save walking the list again).
+ */
+ first_free_slot = i;
+ }
+ }
+
+ /* At this point we found an existing entry and have updated it, or need to
+ * add a new entry. If all slots are allocated, give up and return an error.
+ */
+ if (!found_entry_flag) {
+ if (first_free_slot == -1) {
+ unifi_error(priv, "no free slot found in port config array (%d used)\n", port->entries_in_use);
+ return -EFAULT;
+ } else {
+ port->entries_in_use++;
+ }
+
+ unifi_trace(priv, UDBG3, "port config index assigned in config_data_port = %d\n", first_free_slot);
+ port->port_cfg[first_free_slot].in_use = TRUE;
+ port->port_cfg[first_free_slot].port_action = port_action;
+ port->port_cfg[first_free_slot].mac_address = *macAddress;
+ }
+
+ if (port_action == CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_OPEN) {
+ /*
+ * Ask stack to schedule for transmission any packets queued
+ * while controlled port was not open.
+ * Use netif_schedule() instead of netif_wake_queue() because
+ * transmission should be already enabled at this point. If it
+ * is not, probably the interface is down and should remain as is.
+ */
+ uf_resume_data_plane(priv, queue, *macAddress, interfaceTag);
+ }
+
+ /*
+ * If port is closed, discard all the pending Rx packets
+ * coming from the peer station.
+ */
+ if (port_action == CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_CLOSED_DISCARD) {
+ uf_free_pending_rx_packets(priv, queue, *macAddress,interfaceTag);
+ }
+
+ unifi_trace(priv, UDBG2,
+ "port config %pM with port_action %d.\n",
+ macAddress->a, port_action);
+ }
+ return 0;
+} /* configure_data_port() */
+
+
+void CsrWifiRouterCtrlPortConfigureReqHandler(void* drvpriv, CsrWifiFsmEvent* msg)
+{
+ unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
+ CsrWifiRouterCtrlPortConfigureReq* req = (CsrWifiRouterCtrlPortConfigureReq*)msg;
+ netInterface_priv_t *interfacePriv = priv->interfacePriv[req->interfaceTag];
+
+ unifi_trace(priv, UDBG3, "entering CsrWifiRouterCtrlPortConfigureReqHandler\n");
+ if (priv->smepriv == NULL) {
+ unifi_error(priv, "CsrWifiRouterCtrlPortConfigureReqHandler: invalid smepriv\n");
+ return;
+ }
+
+ /* To update the protection status of the peer/station */
+ switch(interfacePriv->interfaceMode)
+ {
+ case CSR_WIFI_ROUTER_CTRL_MODE_STA:
+ case CSR_WIFI_ROUTER_CTRL_MODE_AMP:
+ case CSR_WIFI_ROUTER_CTRL_MODE_IBSS:
+ case CSR_WIFI_ROUTER_CTRL_MODE_P2PCLI:
+ /* Since for Unifi as a station, the station record not maintained & interfaceID is
+ * only needed to update the peer protection status
+ */
+ interfacePriv->protect = req->setProtection;
+ break;
+ case CSR_WIFI_ROUTER_CTRL_MODE_AP:
+ case CSR_WIFI_ROUTER_CTRL_MODE_P2PGO:
+ {
+ u8 i;
+ CsrWifiRouterCtrlStaInfo_t *staRecord;
+ /* Ifscontrolled port is open means, The peer has been added to station record
+ * so that the protection corresponding to the peer is valid in this req
+ */
+ if (req->controlledPortAction == CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_OPEN) {
+ for(i =0; i < UNIFI_MAX_CONNECTIONS; i++) {
+ staRecord = (CsrWifiRouterCtrlStaInfo_t *) (interfacePriv->staInfo[i]);
+ if (staRecord) {
+ /* Find the matching station record & set the protection type */
+ if (!memcmp(req->macAddress.a, staRecord->peerMacAddress.a, ETH_ALEN)) {
+ staRecord->protection = req->setProtection;
+ break;
+ }
+ }
+ }
+ }
+ }
+ break;
+ default:
+ unifi_trace(priv, UDBG1, "CsrWifiRouterCtrlPortConfigureReqHandler(0x%.4X) Uncaught mode %d\n",
+ msg->source, interfacePriv->interfaceMode);
+ }
+
+ configure_data_port(priv, req->uncontrolledPortAction, (const CsrWifiMacAddress *)&req->macAddress,
+ UF_UNCONTROLLED_PORT_Q, req->interfaceTag);
+ configure_data_port(priv, req->controlledPortAction, (const CsrWifiMacAddress *)&req->macAddress,
+ UF_CONTROLLED_PORT_Q, req->interfaceTag);
+
+ CsrWifiRouterCtrlPortConfigureCfmSend(msg->source,req->clientData,req->interfaceTag,
+ CSR_RESULT_SUCCESS, req->macAddress);
+ unifi_trace(priv, UDBG3, "leaving CsrWifiRouterCtrlPortConfigureReqHandler\n");
+}
+
+
+void CsrWifiRouterCtrlWifiOnReqHandler(void* drvpriv, CsrWifiFsmEvent* msg)
+{
+ unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
+ CsrWifiRouterCtrlVersions versions;
+ CsrWifiRouterCtrlWifiOnReq* req = (CsrWifiRouterCtrlWifiOnReq*)msg;
+ int r,i;
+ CsrResult csrResult;
+
+ if (priv == NULL) {
+ return;
+ }
+ if( priv->wol_suspend ) {
+ unifi_trace(priv, UDBG1, "CsrWifiRouterCtrlWifiOnReqHandler: Don't reset mode\n");
+ } else {
+#ifdef ANDROID_BUILD
+ /* Take the wakelock while Wi-Fi On is in progress */
+ unifi_trace(priv, UDBG1, "CsrWifiRouterCtrlWifiOnReqHandler: take wake lock\n");
+ wake_lock(&unifi_sdio_wake_lock);
+#endif
+ for (i=0; i<CSR_WIFI_NUM_INTERFACES; i++) {
+ unifi_trace(priv, UDBG1, "CsrWifiRouterCtrlWifiOnReqHandler: Setting interface %d to NONE\n", i );
+
+ priv->interfacePriv[i]->interfaceMode = 0;
+ }
+ }
+ unifi_trace(priv, UDBG1, "CsrWifiRouterCtrlWifiOnReqHandler(0x%.4X) req->dataLength=%d req->data=0x%x\n", msg->source, req->dataLength, req->data);
+
+ if(req->dataLength==3 && req->data && req->data[0]==0 && req->data[1]==1 && req->data[2]==1)
+ {
+ priv->cmanrTestMode = TRUE;
+ unifi_trace(priv, UDBG1, "CsrWifiRouterCtrlWifiOnReqHandler: cmanrTestMode=%d\n", priv->cmanrTestMode);
+ }
+ else
+ {
+ priv->cmanrTestMode = FALSE;
+ }
+
+ /*
+ * The request to initialise UniFi might come while UniFi is running.
+ * We need to block all I/O activity until the reset completes, otherwise
+ * an SDIO error might occur resulting an indication to the SME which
+ * makes it think that the initialisation has failed.
+ */
+ priv->bh_thread.block_thread = 1;
+
+ /* Update the wifi_on state */
+ priv->wifi_on_state = wifi_on_in_progress;
+
+ /* If UniFi was unpowered, acquire the firmware for download to chip */
+ if (!priv->wol_suspend) {
+ r = uf_request_firmware_files(priv, UNIFI_FW_STA);
+ if (r) {
+ unifi_error(priv, "CsrWifiRouterCtrlWifiOnReqHandler: Failed to get f/w\n");
+ CsrWifiRouterCtrlWifiOnCfmSend(msg->source, req->clientData, CSR_RESULT_FAILURE);
+ return;
+ }
+ } else {
+ unifi_trace(priv, UDBG1, "Don't need firmware\n");
+ }
+
+ /* Power on UniFi (which may not necessarily have been off) */
+ CsrSdioClaim(priv->sdio);
+ csrResult = CsrSdioPowerOn(priv->sdio);
+ CsrSdioRelease(priv->sdio);
+ if (csrResult != CSR_RESULT_SUCCESS && csrResult != CSR_SDIO_RESULT_NOT_RESET) {
+ unifi_error(priv, "CsrWifiRouterCtrlWifiOnReqHandler: Failed to power on UniFi\n");
+ CsrWifiRouterCtrlWifiOnCfmSend(msg->source, req->clientData, CSR_RESULT_FAILURE);
+ return;
+ }
+
+ /* If CsrSdioPowerOn() returns CSR_RESULT_SUCCESS, it means that we need to initialise UniFi */
+ if (csrResult == CSR_RESULT_SUCCESS && !priv->wol_suspend) {
+ /* Initialise UniFi hardware */
+ r = uf_init_hw(priv);
+ if (r) {
+ unifi_error(priv, "CsrWifiRouterCtrlWifiOnReqHandler: Failed to initialise h/w, error %d\n", r);
+ CsrWifiRouterCtrlWifiOnCfmSend(msg->source, req->clientData, CSR_RESULT_FAILURE);
+ return;
+ }
+ } else {
+ unifi_trace(priv, UDBG1, "UniFi already initialised\n");
+ }
+
+ /* Completed handling of wake up from suspend with UniFi powered */
+ priv->wol_suspend = FALSE;
+
+ /* Re-enable the I/O thread */
+ priv->bh_thread.block_thread = 0;
+
+ /*
+ * Start the I/O thread. The thread might be already running.
+ * This fine, just carry on with the request.
+ */
+ r = uf_init_bh(priv);
+ if (r) {
+ CsrSdioClaim(priv->sdio);
+ CsrSdioPowerOff(priv->sdio);
+ CsrSdioRelease(priv->sdio);
+ CsrWifiRouterCtrlWifiOnCfmSend(msg->source, req->clientData, CSR_RESULT_FAILURE);
+ return;
+ }
+
+ /* Get the version information from the core */
+ unifi_card_info(priv->card, &priv->card_info);
+
+ /* Set the sme queue id */
+ priv->CSR_WIFI_SME_IFACEQUEUE = msg->source;
+ CSR_WIFI_SME_IFACEQUEUE = msg->source;
+
+
+ /* Copy to the unifiio_card_info structure. */
+ versions.chipId = priv->card_info.chip_id;
+ versions.chipVersion = priv->card_info.chip_version;
+ versions.firmwareBuild = priv->card_info.fw_build;
+ versions.firmwareHip = priv->card_info.fw_hip_version;
+ versions.routerBuild = (char*)CSR_WIFI_VERSION;
+ versions.routerHip = (UNIFI_HIP_MAJOR_VERSION << 8) | UNIFI_HIP_MINOR_VERSION;
+
+ CsrWifiRouterCtrlWifiOnIndSend(msg->source, 0, CSR_RESULT_SUCCESS, versions);
+
+ /* Update the wifi_on state */
+ priv->wifi_on_state = wifi_on_done;
+}
+
+
+/*
+ * wifi_off:
+ * Common code for CsrWifiRouterCtrlWifiOffReqHandler() and
+ * CsrWifiRouterCtrlWifiOffRspHandler().
+ */
+static void
+wifi_off(unifi_priv_t *priv)
+{
+ int power_off;
+ int priv_instance;
+ int i;
+ CsrResult csrResult;
+
+
+ /* Already off? */
+ if (priv->wifi_on_state == wifi_on_unspecified) {
+ unifi_trace(priv, UDBG1, "wifi_off already\n");
+ return;
+ }
+
+ unifi_trace(priv, UDBG1, "wifi_off\n");
+
+ /* Destroy the Traffic Analysis Module */
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,23)
+ cancel_work_sync(&priv->ta_ind_work.task);
+ cancel_work_sync(&priv->ta_sample_ind_work.task);
+#ifdef CSR_SUPPORT_WEXT
+ cancel_work_sync(&priv->sme_config_task);
+ wext_send_disassoc_event(priv);
+#endif
+
+ /* Cancel pending M4 stuff */
+ for (i = 0; i < CSR_WIFI_NUM_INTERFACES; i++) {
+ if (priv->netdev[i]) {
+ netInterface_priv_t *netpriv = (netInterface_priv_t *) netdev_priv(priv->netdev[i]);
+ cancel_work_sync(&netpriv->send_m4_ready_task);
+ }
+ }
+#endif
+ flush_workqueue(priv->unifi_workqueue);
+
+ /* fw_init parameter can prevent power off UniFi, for debugging */
+ priv_instance = uf_find_priv(priv);
+ if (priv_instance == -1) {
+ unifi_warning(priv,
+ "CsrWifiRouterCtrlStopReqHandler: Unknown priv instance, will power off card.\n");
+ power_off = 1;
+ } else {
+ power_off = (fw_init[priv_instance] > 0) ? 0 : 1;
+ }
+
+ /* Production test mode requires power to the chip, too */
+ if (priv->ptest_mode) {
+ power_off = 0;
+ }
+
+ /* Stop the bh_thread */
+ uf_stop_thread(priv, &priv->bh_thread);
+
+ /* Read the f/w panic codes, if any. Protect against second wifi_off() call,
+ * which may happen if SME requests a wifi_off and closes the char device */
+ if (priv->init_progress != UNIFI_INIT_NONE) {
+ CsrSdioClaim(priv->sdio);
+ unifi_capture_panic(priv->card);
+ CsrSdioRelease(priv->sdio);
+ }
+
+ /* Unregister the interrupt handler */
+ if (csr_sdio_linux_remove_irq(priv->sdio)) {
+ unifi_notice(priv,
+ "csr_sdio_linux_remove_irq failed to talk to card.\n");
+ }
+
+ if (power_off) {
+ unifi_trace(priv, UDBG2,
+ "Force low power and try to power off\n");
+ /* Put UniFi to deep sleep, in case we can not power it off */
+ CsrSdioClaim(priv->sdio);
+ csrResult = unifi_force_low_power_mode(priv->card);
+ CsrSdioRelease(priv->sdio);
+
+ CsrSdioPowerOff(priv->sdio);
+ }
+
+ /* Consider UniFi to be uninitialised */
+ priv->init_progress = UNIFI_INIT_NONE;
+ priv->wifi_on_state = wifi_on_unspecified;
+
+
+} /* wifi_off() */
+
+
+void CsrWifiRouterCtrlWifiOffReqHandler(void* drvpriv, CsrWifiFsmEvent* msg)
+{
+ unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
+ CsrWifiRouterCtrlWifiOffReq* req = (CsrWifiRouterCtrlWifiOffReq*)msg;
+ int i = 0;
+
+ if (priv == NULL) {
+ return;
+ }
+
+ unifi_trace(priv, UDBG1, "CsrWifiRouterCtrlWifiOffReqHandler(0x%.4X)\n", msg->source);
+
+ /* Stop the network traffic on all interfaces before freeing the core. */
+ for (i=0; i<CSR_WIFI_NUM_INTERFACES; i++) {
+ netInterface_priv_t *interfacePriv = priv->interfacePriv[i];
+ if (interfacePriv->netdev_registered == 1) {
+ netif_carrier_off(priv->netdev[i]);
+ UF_NETIF_TX_STOP_ALL_QUEUES(priv->netdev[i]);
+ interfacePriv->connected = UnifiConnectedUnknown;
+ }
+ interfacePriv->interfaceMode = 0;
+
+ /* Enable all queues by default */
+ interfacePriv->queueEnabled[0] = 1;
+ interfacePriv->queueEnabled[1] = 1;
+ interfacePriv->queueEnabled[2] = 1;
+ interfacePriv->queueEnabled[3] = 1;
+ }
+ wifi_off(priv);
+
+ CsrWifiRouterCtrlWifiOffCfmSend(msg->source,req->clientData);
+
+ /* If this is called in response to closing the character device, the
+ * caller must use uf_sme_cancel_request() to terminate any pending SME
+ * blocking request or there will be a delay while the operation times out.
+ */
+}
+
+
+void CsrWifiRouterCtrlQosControlReqHandler(void* drvpriv, CsrWifiFsmEvent* msg)
+{
+ unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
+ CsrWifiRouterCtrlQosControlReq* req = (CsrWifiRouterCtrlQosControlReq*)msg;
+ netInterface_priv_t *interfacePriv;
+
+ if (priv->smepriv == NULL) {
+ unifi_error(priv, "CsrWifiRouterCtrlQosControlReqHandler: invalid smepriv\n");
+ return;
+ }
+
+ unifi_trace(priv, UDBG4, "CsrWifiRouterCtrlQosControlReqHandler:scontrol = %d", req->control);
+
+ if (req->interfaceTag >= CSR_WIFI_NUM_INTERFACES) {
+ unifi_error(priv, "CsrWifiRouterCtrlQosControlReqHandler: interfaceID >= CSR_WIFI_NUM_INTERFACES.\n");
+ return;
+ }
+ interfacePriv = priv->interfacePriv[req->interfaceTag];
+
+ if (req->control == CSR_WIFI_ROUTER_CTRL_QOS_CONTROL_WMM_ON) {
+ priv->sta_wmm_capabilities |= QOS_CAPABILITY_WMM_ENABLED;
+ unifi_trace(priv, UDBG1, "WMM enabled\n");
+
+ unifi_trace(priv, UDBG1, "Queue Config %x\n", req->queueConfig);
+
+ interfacePriv->queueEnabled[UNIFI_TRAFFIC_Q_BK] = (req->queueConfig & CSR_WIFI_ROUTER_CTRL_QUEUE_BK_ENABLE)?1:0;
+ interfacePriv->queueEnabled[UNIFI_TRAFFIC_Q_BE] = (req->queueConfig & CSR_WIFI_ROUTER_CTRL_QUEUE_BE_ENABLE)?1:0;
+ interfacePriv->queueEnabled[UNIFI_TRAFFIC_Q_VI] = (req->queueConfig & CSR_WIFI_ROUTER_CTRL_QUEUE_VI_ENABLE)?1:0;
+ interfacePriv->queueEnabled[UNIFI_TRAFFIC_Q_VO] = (req->queueConfig & CSR_WIFI_ROUTER_CTRL_QUEUE_VO_ENABLE)?1:0;
+
+ } else {
+ priv->sta_wmm_capabilities = 0;
+ unifi_trace(priv, UDBG1, "WMM disabled\n");
+ }
+}
+
+
+void CsrWifiRouterCtrlTclasAddReqHandler(void* drvpriv, CsrWifiFsmEvent* msg)
+{
+ unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
+ CsrWifiRouterCtrlTclasAddReq* req = (CsrWifiRouterCtrlTclasAddReq*)msg;
+
+ if (priv == NULL) {
+ unifi_error(priv, "CsrWifiRouterCtrlTclasAddReqHandler: invalid smepriv\n");
+ return;
+ }
+
+ CsrWifiRouterCtrlTclasAddCfmSend(msg->source, req->clientData, req->interfaceTag , CSR_RESULT_SUCCESS);
+}
+
+void CsrWifiRouterCtrlTclasDelReqHandler(void* drvpriv, CsrWifiFsmEvent* msg)
+{
+ unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
+ CsrWifiRouterCtrlTclasDelReq* req = (CsrWifiRouterCtrlTclasDelReq*)msg;
+
+ if (priv == NULL) {
+ unifi_error(priv, "CsrWifiRouterCtrlTclasDelReqHandler: invalid smepriv\n");
+ return;
+ }
+
+ CsrWifiRouterCtrlTclasDelCfmSend(msg->source, req->clientData, req->interfaceTag, CSR_RESULT_SUCCESS);
+}
+
+
+void CsrWifiRouterCtrlConfigurePowerModeReqHandler(void* drvpriv, CsrWifiFsmEvent* msg)
+{
+ unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
+ CsrWifiRouterCtrlConfigurePowerModeReq* req = (CsrWifiRouterCtrlConfigurePowerModeReq*)msg;
+ enum unifi_low_power_mode pm;
+ CsrResult csrResult;
+
+ if (priv->smepriv == NULL) {
+ unifi_error(priv, "CsrWifiRouterCtrlConfigurePowerModeReqHandler: invalid smepriv\n");
+ return;
+ }
+
+ if (req->mode == CSR_WIFI_ROUTER_CTRL_LOW_POWER_MODE_DISABLED) {
+ pm = UNIFI_LOW_POWER_DISABLED;
+ } else {
+ pm = UNIFI_LOW_POWER_ENABLED;
+ }
+
+ unifi_trace(priv, UDBG2,
+ "CsrWifiRouterCtrlConfigurePowerModeReqHandler (mode=%d, wake=%d)\n",
+ req->mode, req->wakeHost);
+ csrResult = unifi_configure_low_power_mode(priv->card, pm,
+ (req->wakeHost ? UNIFI_PERIODIC_WAKE_HOST_ENABLED : UNIFI_PERIODIC_WAKE_HOST_DISABLED));
+}
+
+
+void CsrWifiRouterCtrlWifiOnResHandler(void* drvpriv, CsrWifiFsmEvent* msg)
+{
+ unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
+ CsrWifiRouterCtrlWifiOnRes* res = (CsrWifiRouterCtrlWifiOnRes*)msg;
+
+ if (priv == NULL) {
+ unifi_error(NULL, "CsrWifiRouterCtrlWifiOnResHandler: Invalid ospriv.\n");
+ return;
+ }
+
+ unifi_trace(priv, UDBG1,
+ "CsrWifiRouterCtrlWifiOnResHandler: status %d (patch %u)\n", res->status, res->smeVersions.firmwarePatch);
+
+ if (res->smeVersions.firmwarePatch != 0) {
+ unifi_info(priv, "Firmware patch %d\n", res->smeVersions.firmwarePatch);
+ }
+
+ if (res->numInterfaceAddress > CSR_WIFI_NUM_INTERFACES) {
+ unifi_error(priv, "WifiOnResHandler bad numInterfaceAddress %d\n", res->numInterfaceAddress);
+ return;
+ }
+
+ /* UniFi is now initialised, complete the init. */
+ if (res->status == CSR_RESULT_SUCCESS)
+ {
+ int i; /* used as a loop counter */
+ u32 intmode = CSR_WIFI_INTMODE_DEFAULT;
+#ifdef CSR_WIFI_SPLIT_PATCH
+ u8 switching_ap_fw = FALSE;
+#endif
+ /* Register the UniFi device with the OS network manager */
+ unifi_trace(priv, UDBG3, "Card Init Completed Successfully\n");
+
+ /* Store the MAC address in the netdev */
+ for(i=0;i<res->numInterfaceAddress;i++)
+ {
+ memcpy(priv->netdev[i]->dev_addr, res->stationMacAddress[i].a, ETH_ALEN);
+ }
+
+ /* Copy version structure into the private versions field */
+ priv->sme_versions = res->smeVersions;
+
+ unifi_trace(priv, UDBG2, "network interfaces count = %d\n",
+ res->numInterfaceAddress);
+
+ /* Register the netdevs for each interface. */
+ for(i=0;i<res->numInterfaceAddress;i++)
+ {
+ netInterface_priv_t *interfacePriv = priv->interfacePriv[i];
+ if(!interfacePriv->netdev_registered)
+ {
+ int r;
+ unifi_trace(priv, UDBG3, "registering net device %d\n", i);
+ r = uf_register_netdev(priv, i);
+ if (r)
+ {
+ /* unregister the net_device that are registered in the previous iterations */
+ uf_unregister_netdev(priv);
+ unifi_error(priv, "Failed to register the network device.\n");
+ CsrWifiRouterCtrlWifiOnCfmSend(msg->source, res->clientData, CSR_RESULT_FAILURE);
+ return;
+ }
+ }
+#ifdef CSR_WIFI_SPLIT_PATCH
+ else
+ {
+ /* If a netdev is already registered, we have received this WifiOnRes
+ * in response to switching AP/STA firmware in a ModeSetReq.
+ * Rememeber this in order to send a ModeSetCfm once
+ */
+ switching_ap_fw = TRUE;
+ }
+#endif
+ }
+ priv->totalInterfaceCount = res->numInterfaceAddress;
+
+ /* If the MIB has selected f/w scheduled interrupt mode, apply it now
+ * but let module param override.
+ */
+ if (run_bh_once != -1) {
+ intmode = (u32)run_bh_once;
+ } else if (res->scheduledInterrupt) {
+ intmode = CSR_WIFI_INTMODE_RUN_BH_ONCE;
+ }
+ unifi_set_interrupt_mode(priv->card, intmode);
+
+ priv->init_progress = UNIFI_INIT_COMPLETED;
+
+ /* Acknowledge the CsrWifiRouterCtrlWifiOnReq now */
+ CsrWifiRouterCtrlWifiOnCfmSend(msg->source, res->clientData, CSR_RESULT_SUCCESS);
+
+#ifdef CSR_WIFI_SPLIT_PATCH
+ if (switching_ap_fw && (priv->pending_mode_set.common.destination != 0xaaaa)) {
+ unifi_info(priv, "Completed firmware reload with %s patch\n",
+ CSR_WIFI_HIP_IS_AP_FW(priv->interfacePriv[0]->interfaceMode) ? "AP" : "STA");
+
+ /* Confirm the ModeSetReq that requested the AP/STA patch switch */
+ CsrWifiRouterCtrlModeSetCfmSend(priv->pending_mode_set.common.source,
+ priv->pending_mode_set.clientData,
+ priv->pending_mode_set.interfaceTag,
+ priv->pending_mode_set.mode,
+ CSR_RESULT_SUCCESS);
+ priv->pending_mode_set.common.destination = 0xaaaa;
+ }
+#endif
+ unifi_info(priv, "UniFi ready\n");
+
+#ifdef ANDROID_BUILD
+ /* Release the wakelock */
+ unifi_trace(priv, UDBG1, "ready: release wake lock\n");
+ wake_unlock(&unifi_sdio_wake_lock);
+#endif
+ /* Firmware initialisation is complete, so let the SDIO bus
+ * clock be raised when convienent to the core.
+ */
+ unifi_request_max_sdio_clock(priv->card);
+
+#ifdef CSR_SUPPORT_WEXT
+ /* Notify the Android wpa_supplicant that we are ready */
+ wext_send_started_event(priv);
+
+ queue_work(priv->unifi_workqueue, &priv->sme_config_task);
+#endif
+
+ } else {
+ /* Acknowledge the CsrWifiRouterCtrlWifiOnReq now */
+ CsrWifiRouterCtrlWifiOnCfmSend(msg->source, res->clientData, CSR_RESULT_FAILURE);
+ }
+}
+
+
+void CsrWifiRouterCtrlWifiOffResHandler(void* drvpriv, CsrWifiFsmEvent* msg)
+{
+}
+
+
+void CsrWifiRouterCtrlMulticastAddressResHandler(void* drvpriv, CsrWifiFsmEvent* msg)
+{
+}
+
+
+void CsrWifiRouterMaPacketSubscribeReqHandler(void* drvpriv, CsrWifiFsmEvent* msg)
+{
+ unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
+ CsrWifiRouterMaPacketSubscribeReq* req = (CsrWifiRouterMaPacketSubscribeReq*)msg;
+ u8 i;
+ CsrResult result;
+
+ if (priv == NULL) {
+ unifi_error(priv, "CsrWifiRouterMaPacketSubscribeReqHandler: invalid priv\n");
+ return;
+ }
+
+ /* Look for an unused filter */
+
+ result = CSR_WIFI_RESULT_NO_ROOM;
+ for (i = 0; i < MAX_MA_UNIDATA_IND_FILTERS; i++) {
+
+ if (!priv->sme_unidata_ind_filters[i].in_use) {
+
+ priv->sme_unidata_ind_filters[i].in_use = 1;
+ priv->sme_unidata_ind_filters[i].appHandle = msg->source;
+ priv->sme_unidata_ind_filters[i].encapsulation = req->encapsulation;
+ priv->sme_unidata_ind_filters[i].protocol = req->protocol;
+
+ priv->sme_unidata_ind_filters[i].oui[2] = (u8) (req->oui & 0xFF);
+ priv->sme_unidata_ind_filters[i].oui[1] = (u8) ((req->oui >> 8) & 0xFF);
+ priv->sme_unidata_ind_filters[i].oui[0] = (u8) ((req->oui >> 16) & 0xFF);
+
+ result = CSR_RESULT_SUCCESS;
+ break;
+ }
+ }
+
+ unifi_trace(priv, UDBG1,
+ "subscribe_req: encap=%d, handle=%d, result=%d\n",
+ req->encapsulation, i, result);
+ CsrWifiRouterMaPacketSubscribeCfmSend(msg->source,req->interfaceTag, i, result, 0);
+}
+
+
+void CsrWifiRouterMaPacketUnsubscribeReqHandler(void* drvpriv, CsrWifiFsmEvent* msg)
+{
+ unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
+ CsrWifiRouterMaPacketUnsubscribeReq* req = (CsrWifiRouterMaPacketUnsubscribeReq*)msg;
+ CsrResult result;
+
+ if (priv == NULL) {
+ unifi_error(priv, "CsrWifiRouterMaPacketUnsubscribeReqHandler: invalid priv\n");
+ return;
+ }
+
+ result = CSR_WIFI_RESULT_NOT_FOUND;
+
+ if (req->subscriptionHandle < MAX_MA_UNIDATA_IND_FILTERS) {
+ if (priv->sme_unidata_ind_filters[req->subscriptionHandle].in_use) {
+ priv->sme_unidata_ind_filters[req->subscriptionHandle].in_use = 0;
+ result = CSR_RESULT_SUCCESS;
+ } else {
+ result = CSR_WIFI_RESULT_NOT_FOUND;
+ }
+ }
+
+ unifi_trace(priv, UDBG1,
+ "unsubscribe_req: handle=%d, result=%d\n",
+ req->subscriptionHandle, result);
+ CsrWifiRouterMaPacketUnsubscribeCfmSend(msg->source,req->interfaceTag, result);
+}
+
+
+void CsrWifiRouterCtrlCapabilitiesReqHandler(void* drvpriv, CsrWifiFsmEvent* msg)
+{
+ unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
+ CsrWifiRouterCtrlCapabilitiesReq* req = (CsrWifiRouterCtrlCapabilitiesReq*)msg;
+
+ if (priv == NULL) {
+ unifi_error(priv, "CsrWifiRouterCtrlCapabilitiesReqHandler: invalid priv\n");
+ return;
+ }
+
+ CsrWifiRouterCtrlCapabilitiesCfmSend(msg->source,req->clientData,
+ UNIFI_SOFT_COMMAND_Q_LENGTH - 1,
+ UNIFI_SOFT_TRAFFIC_Q_LENGTH - 1);
+}
+
+
+void CsrWifiRouterCtrlSuspendResHandler(void* drvpriv, CsrWifiFsmEvent* msg)
+{
+ unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
+ CsrWifiRouterCtrlSuspendRes* res = (CsrWifiRouterCtrlSuspendRes*)msg;
+
+ if (priv == NULL) {
+ unifi_error(priv, "CsrWifiRouterCtrlSuspendResHandler: invalid priv\n");
+ return;
+ }
+
+ sme_complete_request(priv, res->status);
+}
+
+
+void CsrWifiRouterCtrlResumeResHandler(void* drvpriv, CsrWifiFsmEvent* msg)
+{
+ unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
+ CsrWifiRouterCtrlResumeRes* res = (CsrWifiRouterCtrlResumeRes*)msg;
+
+ if (priv == NULL) {
+ unifi_error(priv, "CsrWifiRouterCtrlResumeResHandler: invalid priv\n");
+ return;
+ }
+
+ sme_complete_request(priv, res->status);
+}
+
+
+void CsrWifiRouterCtrlTrafficConfigReqHandler(void* drvpriv, CsrWifiFsmEvent* msg)
+{
+ unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
+ CsrWifiRouterCtrlTrafficConfigReq* req = (CsrWifiRouterCtrlTrafficConfigReq*)msg;
+ CsrResult csrResult;
+
+ if (priv == NULL) {
+ unifi_error(priv, "CsrWifiRouterCtrlTrafficConfigReqHandler: invalid smepriv\n");
+ return;
+ }
+ if (req->trafficConfigType == CSR_WIFI_ROUTER_CTRL_TRAFFIC_CONFIG_TYPE_FILTER)
+ {
+ req->config.packetFilter |= CSR_WIFI_ROUTER_CTRL_TRAFFIC_PACKET_TYPE_CUSTOM;
+ }
+ csrResult = unifi_ta_configure(priv->card, req->trafficConfigType, (const CsrWifiRouterCtrlTrafficConfig *)&req->config);
+}
+
+void CsrWifiRouterCtrlTrafficClassificationReqHandler(void* drvpriv, CsrWifiFsmEvent* msg)
+{
+ unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
+ CsrWifiRouterCtrlTrafficClassificationReq* req = (CsrWifiRouterCtrlTrafficClassificationReq*)msg;
+
+ if (priv == NULL) {
+ unifi_error(priv, "CsrWifiRouterCtrlTrafficClassificationReqHandler: invalid smepriv\n");
+ return;
+ }
+
+ unifi_ta_classification(priv->card, req->trafficType, req->period);
+}
+
+static int
+_sys_packet_req(unifi_priv_t *priv, const CSR_SIGNAL *signal,
+ u8 subscriptionHandle,
+ u16 frameLength, u8 *frame,
+ int proto)
+{
+ int r;
+ const sme_ma_unidata_ind_filter_t *subs;
+ bulk_data_param_t bulkdata;
+ CSR_MA_PACKET_REQUEST req = signal->u.MaPacketRequest;
+ struct sk_buff *skb, *newSkb = NULL;
+ CsrWifiMacAddress peerMacAddress;
+ CsrResult csrResult;
+ u16 interfaceTag = req.VirtualInterfaceIdentifier & 0xff;
+ u8 eapolStore = FALSE;
+ s8 protection = 0;
+ netInterface_priv_t *interfacePriv;
+ unsigned long flags;
+
+ if (interfaceTag >= CSR_WIFI_NUM_INTERFACES) {
+ unifi_error(priv, "_sys_packet_req: interfaceID >= CSR_WIFI_NUM_INTERFACES.\n");
+ return -EINVAL;
+ }
+ interfacePriv = priv->interfacePriv[interfaceTag];
+ if (!priv->sme_unidata_ind_filters[subscriptionHandle].in_use) {
+ unifi_error(priv, "_sys_packet_req: unknown subscription.\n");
+ return -EINVAL;
+ }
+
+ subs = &priv->sme_unidata_ind_filters[subscriptionHandle];
+ unifi_trace(priv, UDBG1,
+ "_sys_packet_req: handle=%d, subs=%p, encap=%d\n",
+ subscriptionHandle, subs, subs->encapsulation);
+
+ csrResult = unifi_net_data_malloc(priv, &bulkdata.d[0], frameLength);
+ if (csrResult != CSR_RESULT_SUCCESS) {
+ unifi_error(priv, "_sys_packet_req: failed to allocate bulkdata.\n");
+ return (int)CsrHipResultToStatus(csrResult);
+ }
+
+ /* get the peer Mac address */
+ memcpy(&peerMacAddress, frame, ETH_ALEN);
+
+ /* Determine if we need to add encapsulation header */
+ if (subs->encapsulation == CSR_WIFI_ROUTER_ENCAPSULATION_ETHERNET) {
+ memcpy((void*)bulkdata.d[0].os_data_ptr, frame, frameLength);
+
+ /* The translation is performed on the skb */
+ skb = (struct sk_buff*)bulkdata.d[0].os_net_buf_ptr;
+
+ unifi_trace(priv, UDBG1,
+ "_sys_packet_req: skb_add_llc_snap -->\n");
+ r = skb_add_llc_snap(priv->netdev[interfaceTag], skb, proto);
+ unifi_trace(priv, UDBG1,
+ "_sys_packet_req: skb_add_llc_snap <--\n");
+ if (r) {
+ unifi_error(priv,
+ "_sys_packet_req: failed to translate eth frame.\n");
+ unifi_net_data_free(priv,&bulkdata.d[0]);
+ return r;
+ }
+
+ bulkdata.d[0].data_length = skb->len;
+ } else {
+ /* Crop the MAC addresses from the packet */
+ memcpy((void*)bulkdata.d[0].os_data_ptr, frame + 2*ETH_ALEN, frameLength - 2*ETH_ALEN);
+ bulkdata.d[0].data_length = frameLength - 2*ETH_ALEN;
+ skb = (struct sk_buff*)bulkdata.d[0].os_net_buf_ptr;
+ skb->len = bulkdata.d[0].data_length;
+
+ }
+
+ bulkdata.d[1].os_data_ptr = NULL;
+ bulkdata.d[1].os_net_buf_ptr = NULL;
+ bulkdata.d[1].data_length = 0;
+
+ /* check for m4 detection */
+ if (0 == uf_verify_m4(priv, bulkdata.d[0].os_data_ptr, bulkdata.d[0].data_length)) {
+ eapolStore = TRUE;
+ }
+
+#ifdef CSR_WIFI_SECURITY_WAPI_ENABLE
+ if (proto == ETH_P_WAI)
+ {
+ protection = 0; /*WAI packets always sent unencrypted*/
+ }
+ else
+ {
+#endif
+
+#ifdef CSR_SUPPORT_SME
+ if ((protection = uf_get_protection_bit_from_interfacemode(priv, interfaceTag, peerMacAddress.a)) < 0) {
+ unifi_error(priv, "unicast address, but destination not in station record database\n");
+ unifi_net_data_free(priv,&bulkdata.d[0]);
+ return -1;
+ }
+#else
+ protection = 0;
+#endif
+
+#ifdef CSR_WIFI_SECURITY_WAPI_ENABLE
+ }
+#endif
+
+ /* add Mac header */
+ if (prepare_and_add_macheader(priv, skb, newSkb, req.Priority, &bulkdata, interfaceTag, frame, frame + ETH_ALEN, protection)) {
+ unifi_error(priv, "failed to create MAC header\n");
+ unifi_net_data_free(priv,&bulkdata.d[0]);
+ return -1;
+ }
+
+ if (eapolStore) {
+ spin_lock_irqsave(&priv->m4_lock, flags);
+ /* Store the EAPOL M4 packet for later */
+ interfacePriv->m4_signal = *signal;
+ interfacePriv->m4_bulk_data.net_buf_length = bulkdata.d[0].net_buf_length;
+ interfacePriv->m4_bulk_data.data_length = bulkdata.d[0].data_length;
+ interfacePriv->m4_bulk_data.os_data_ptr = bulkdata.d[0].os_data_ptr;
+ interfacePriv->m4_bulk_data.os_net_buf_ptr = bulkdata.d[0].os_net_buf_ptr;
+ spin_unlock_irqrestore(&priv->m4_lock, flags);
+ /* Send a signal to SME */
+ unifi_trace(priv, UDBG1, "_sys_packet_req: Sending CsrWifiRouterCtrlM4ReadyToSendInd\n");
+ CsrWifiRouterCtrlM4ReadyToSendIndSend(priv->CSR_WIFI_SME_IFACEQUEUE, 0, interfaceTag, peerMacAddress);
+ return 0;
+ }
+
+ /* Send the signal to UniFi */
+ /* Set the B31 to 1 for local routing*/
+ r= uf_process_ma_packet_req(priv, peerMacAddress.a, (req.HostTag | 0x80000000), interfaceTag, 0,
+ (CSR_RATE)0, req.Priority, signal->SignalPrimitiveHeader.SenderProcessId, &bulkdata);
+ if (r) {
+ unifi_error(priv,
+ "_sys_packet_req: failed to send signal.\n");
+ unifi_net_data_free(priv,&bulkdata.d[0]);
+ return r;
+ }
+ /* The final CsrWifiRouterMaPacketCfmSend() will called when the actual MA-PACKET.cfm is received from the chip */
+
+ return 0;
+}
+
+void CsrWifiRouterMaPacketReqHandler(void* drvpriv, CsrWifiFsmEvent* msg)
+{
+ int r;
+ unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
+ CsrWifiRouterMaPacketReq* mareq = (CsrWifiRouterMaPacketReq*)msg;
+ llc_snap_hdr_t *snap;
+ u16 snap_protocol;
+ CSR_SIGNAL signal;
+ CSR_MA_PACKET_REQUEST *req = &signal.u.MaPacketRequest;
+ CsrWifiRouterCtrlPortAction controlPortaction;
+ u8 *daddr, *saddr;
+ u16 interfaceTag = mareq->interfaceTag & 0x00ff;
+ int queue;
+ netInterface_priv_t *interfacePriv = priv->interfacePriv[interfaceTag];
+
+ if (!mareq->frame || !priv || !priv->smepriv)
+ {
+ unifi_error(priv, "CsrWifiRouterMaPacketReqHandler: invalid frame/priv/priv->smepriv\n");
+ return;
+ }
+
+ if (interfaceTag >= CSR_WIFI_NUM_INTERFACES) {
+ unifi_error(priv, "CsrWifiRouterMaPacketReqHandler: interfaceID >= CSR_WIFI_NUM_INTERFACES.\n");
+ return;
+ }
+ /* get a pointer to dest & source Mac address */
+ daddr = mareq->frame;
+ saddr = (mareq->frame + ETH_ALEN);
+ /* point to the proper position of frame, since frame has MAC header */
+ snap = (llc_snap_hdr_t *) (mareq->frame + 2 * ETH_ALEN);
+ snap_protocol = ntohs(snap->protocol);
+ if((snap_protocol == ETH_P_PAE)
+#ifdef CSR_WIFI_SECURITY_WAPI_ENABLE
+ || (snap_protocol == ETH_P_WAI)
+#endif
+ )
+ {
+ queue = UF_UNCONTROLLED_PORT_Q;
+ }
+ else
+ {
+ queue = UF_CONTROLLED_PORT_Q;
+ }
+
+ /* Controlled port restrictions apply to the packets */
+ controlPortaction = uf_sme_port_state(priv, daddr, queue, interfaceTag);
+ if (controlPortaction != CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_OPEN)
+ {
+ unifi_warning(priv, "CsrWifiRouterMaPacketReqHandler: (%s)controlled port is closed.\n", (queue == UF_CONTROLLED_PORT_Q)?"":"un");
+ if(mareq->cfmRequested)
+ {
+ CsrWifiRouterMaPacketCfmSend(msg->source,
+ interfaceTag,
+ CSR_RESULT_FAILURE,
+ mareq->hostTag, 0);
+ }
+ return;
+ }
+
+ signal.SignalPrimitiveHeader.SignalId = CSR_MA_PACKET_REQUEST_ID;
+ /* Store the appHandle in the LSB of the SenderId. */
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(((priv->sme_cli->sender_id & 0xff00) | (unsigned int)msg->source),
+ (u8*)&signal.SignalPrimitiveHeader.SenderProcessId);
+ signal.SignalPrimitiveHeader.ReceiverProcessId = 0;
+
+ /* Fill in the MA-PACKET.req signal */
+ memcpy(req->Ra.x, daddr, ETH_ALEN);
+ req->Priority = mareq->priority;
+ req->TransmitRate = 0; /* Let firmware select the rate*/
+ req->VirtualInterfaceIdentifier = uf_get_vif_identifier(interfacePriv->interfaceMode,interfaceTag);
+ req->HostTag = mareq->hostTag;
+
+ if(mareq->cfmRequested)
+ req->TransmissionControl = 0;
+ else
+ req->TransmissionControl = CSR_NO_CONFIRM_REQUIRED;
+
+ r = _sys_packet_req(priv, &signal, mareq->subscriptionHandle,
+ mareq->frameLength, mareq->frame, snap_protocol);
+
+ if (r && mareq->cfmRequested)
+ {
+ CsrWifiRouterMaPacketCfmSend(msg->source,interfaceTag,
+ CSR_RESULT_FAILURE,
+ mareq->hostTag, 0);
+ }
+ return;
+}
+
+void CsrWifiRouterMaPacketCancelReqHandler(void* drvpriv, CsrWifiFsmEvent* msg)
+{
+}
+
+void CsrWifiRouterCtrlM4TransmitReqHandler(void* drvpriv, CsrWifiFsmEvent* msg)
+{
+ unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
+ CsrWifiRouterCtrlM4TransmitReq* req = (CsrWifiRouterCtrlM4TransmitReq*)msg;
+ int r;
+ bulk_data_param_t bulkdata;
+ netInterface_priv_t *interfacePriv;
+ CSR_SIGNAL m4_signal;
+ unsigned long flags;
+
+ if (priv == NULL) {
+ unifi_error(priv, "CsrWifiRouterCtrlM4TransmitReqHandler: invalid smepriv\n");
+ return;
+ }
+ if (req->interfaceTag >= CSR_WIFI_NUM_INTERFACES) {
+ unifi_error(priv, "M4TransmitReqHandler: interfaceTag >= CSR_WIFI_NUM_INTERFACES\n");
+ return;
+ }
+
+ interfacePriv = priv->interfacePriv[req->interfaceTag];
+ spin_lock_irqsave(&priv->m4_lock, flags);
+ if (interfacePriv->m4_bulk_data.data_length == 0) {
+ spin_unlock_irqrestore(&priv->m4_lock, flags);
+ unifi_error(priv, "CsrWifiRouterCtrlM4TransmitReqHandler: invalid buffer\n");
+ return;
+ }
+
+ memcpy(&bulkdata.d[0], &interfacePriv->m4_bulk_data, sizeof(bulk_data_desc_t));
+
+ interfacePriv->m4_bulk_data.net_buf_length = 0;
+ interfacePriv->m4_bulk_data.data_length = 0;
+ interfacePriv->m4_bulk_data.os_data_ptr = interfacePriv->m4_bulk_data.os_net_buf_ptr = NULL;
+ m4_signal = interfacePriv->m4_signal;
+ spin_unlock_irqrestore(&priv->m4_lock, flags);
+
+ bulkdata.d[1].os_data_ptr = NULL;
+ bulkdata.d[1].data_length = 0;
+
+ interfacePriv->m4_sent = TRUE;
+ m4_signal.u.MaPacketRequest.HostTag |= 0x80000000;
+ /* Store the hostTag for later varification */
+ interfacePriv->m4_hostTag = m4_signal.u.MaPacketRequest.HostTag;
+ r = ul_send_signal_unpacked(priv, &m4_signal, &bulkdata);
+ unifi_trace(priv, UDBG1,
+ "CsrWifiRouterCtrlM4TransmitReqHandler: sent\n");
+ if (r) {
+ unifi_error(priv,
+ "CsrWifiRouterCtrlM4TransmitReqHandler: failed to send signal.\n");
+ unifi_net_data_free(priv, &bulkdata.d[0]);
+ }
+}
+
+/* reset the station records when the mode is set as CSR_WIFI_ROUTER_CTRL_MODE_NONE */
+static void CsrWifiRouterCtrlResetStationRecordList(unifi_priv_t *priv, u16 interfaceTag)
+{
+ u8 i,j;
+ CsrWifiRouterCtrlStaInfo_t *staInfo=NULL;
+ netInterface_priv_t *interfacePriv = priv->interfacePriv[interfaceTag];
+ unsigned long lock_flags;
+
+ /* create a list for sending confirms of un-delivered packets */
+ struct list_head send_cfm_list;
+
+ if (interfaceTag >= CSR_WIFI_NUM_INTERFACES) {
+ unifi_error(priv, "CsrWifiRouterCtrlResetStationRecordList: bad interfaceTag\n");
+ return;
+ }
+
+ INIT_LIST_HEAD(&send_cfm_list);
+
+ /* Reset the station record to NULL if mode is NONE */
+ for(i = 0; i < UNIFI_MAX_CONNECTIONS; i++) {
+ if ((staInfo=interfacePriv->staInfo[i]) != NULL) {
+ uf_prepare_send_cfm_list_for_queued_pkts(priv,
+ &send_cfm_list,
+ &(staInfo->mgtFrames));
+ uf_flush_list(priv,&(staInfo->mgtFrames));
+ for(j=0;j<MAX_ACCESS_CATOGORY;j++){
+ uf_prepare_send_cfm_list_for_queued_pkts(priv,
+ &send_cfm_list,
+ &(staInfo->dataPdu[j]));
+ uf_flush_list(priv,&(staInfo->dataPdu[j]));
+ }
+
+ spin_lock_irqsave(&priv->staRecord_lock,lock_flags);
+ /* Removing station record information from port config array */
+ memset(staInfo->peerControlledPort, 0, sizeof(unifi_port_cfg_t));
+ staInfo->peerControlledPort->port_action = CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_CLOSED_DISCARD;
+ staInfo->peerControlledPort->in_use = FALSE;
+ interfacePriv->controlled_data_port.entries_in_use--;
+
+ memset(staInfo->peerUnControlledPort, 0, sizeof(unifi_port_cfg_t));
+ staInfo->peerUnControlledPort->port_action = CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_CLOSED_DISCARD;
+ staInfo->peerUnControlledPort->in_use = FALSE;
+ interfacePriv->uncontrolled_data_port.entries_in_use--;
+
+ kfree(interfacePriv->staInfo[i]);
+ interfacePriv->staInfo[i] = NULL;
+ spin_unlock_irqrestore(&priv->staRecord_lock,lock_flags);
+ }
+ }
+ /* after the critical region process the list of frames that requested cfm
+ * and send cfm to requestor one by one
+ */
+ send_auto_ma_packet_confirm(priv, interfacePriv, &send_cfm_list);
+
+#ifdef CSR_SUPPORT_SME
+ /* Interface Independent, no of packet queued, incase of mode is None or AP set to 0 */
+ switch(interfacePriv->interfaceMode)
+ {
+ case CSR_WIFI_ROUTER_CTRL_MODE_AP:
+ case CSR_WIFI_ROUTER_CTRL_MODE_P2PGO:
+ case CSR_WIFI_ROUTER_CTRL_MODE_NONE:
+ if (priv->noOfPktQueuedInDriver) {
+ unifi_warning(priv, "After reset the noOfPktQueuedInDriver = %x\n", priv->noOfPktQueuedInDriver);
+ spin_lock_irqsave(&priv->tx_q_lock,lock_flags);
+ priv->noOfPktQueuedInDriver = 0;
+ spin_unlock_irqrestore(&priv->tx_q_lock,lock_flags);
+ }
+ break;
+ case CSR_WIFI_ROUTER_CTRL_MODE_IBSS:
+ break;
+ default:
+ unifi_error(priv, "interfacemode is not correct in CsrWifiRouterCtrlResetStationRecordList: debug\n");
+ }
+#endif
+
+ if (((interfacePriv->controlled_data_port.entries_in_use != 0) || (interfacePriv->uncontrolled_data_port.entries_in_use != 0))
+ && (interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_NONE)) {
+ /* Print in case if the value of entries goes to -ve/+ve (apart from 0)
+ * we expect the entries should be zero here if mode is set as NONE
+ */
+ unifi_trace(priv, UDBG3, "In %s controlled port entries = %d, uncontrolled port entries = %d\n",
+ __FUNCTION__, interfacePriv->controlled_data_port.entries_in_use,
+ interfacePriv->uncontrolled_data_port.entries_in_use);
+ }
+}
+
+void CsrWifiRouterCtrlInterfaceReset(unifi_priv_t *priv, u16 interfaceTag)
+{
+ netInterface_priv_t *interfacePriv;
+
+ /* create a list for sending confirms of un-delivered packets */
+ struct list_head send_cfm_list;
+
+ if (interfaceTag >= CSR_WIFI_NUM_INTERFACES) {
+ unifi_error(priv, "CsrWifiRouterCtrlInterfaceReset: bad interfaceTag\n");
+ return;
+ }
+
+ interfacePriv = priv->interfacePriv[interfaceTag];
+
+ INIT_LIST_HEAD(&send_cfm_list);
+
+ /* Enable all queues by default */
+ interfacePriv->queueEnabled[0] = 1;
+ interfacePriv->queueEnabled[1] = 1;
+ interfacePriv->queueEnabled[2] = 1;
+ interfacePriv->queueEnabled[3] = 1;
+
+ uf_prepare_send_cfm_list_for_queued_pkts(priv,
+ &send_cfm_list,
+ &(interfacePriv->genericMgtFrames));
+ uf_flush_list(priv,&(interfacePriv->genericMgtFrames));
+
+ uf_prepare_send_cfm_list_for_queued_pkts(priv,
+ &send_cfm_list,
+ &(interfacePriv->genericMulticastOrBroadCastMgtFrames));
+ uf_flush_list(priv,&(interfacePriv->genericMulticastOrBroadCastMgtFrames));
+
+ uf_prepare_send_cfm_list_for_queued_pkts(priv,
+ &send_cfm_list,
+ &(interfacePriv->genericMulticastOrBroadCastFrames));
+
+ uf_flush_list(priv,&(interfacePriv->genericMulticastOrBroadCastFrames));
+
+ /* process the list of frames that requested cfm
+ and send cfm to requestor one by one */
+ send_auto_ma_packet_confirm(priv, interfacePriv, &send_cfm_list);
+
+ /* Reset the station record to NULL if mode is tried to set as NONE */
+ switch(interfacePriv->interfaceMode)
+ {
+ case CSR_WIFI_ROUTER_CTRL_MODE_STA:
+ case CSR_WIFI_ROUTER_CTRL_MODE_P2PCLI:
+ case CSR_WIFI_ROUTER_CTRL_MODE_MONITOR:
+ case CSR_WIFI_ROUTER_CTRL_MODE_AMP:
+ /* station records not available in these modes */
+ break;
+ default:
+ CsrWifiRouterCtrlResetStationRecordList(priv,interfaceTag);
+ }
+
+ interfacePriv->num_stations_joined = 0;
+ interfacePriv->sta_activity_check_enabled = FALSE;
+}
+
+
+void CsrWifiRouterCtrlModeSetReqHandler(void* drvpriv, CsrWifiFsmEvent* msg)
+{
+ unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
+ CsrWifiRouterCtrlModeSetReq* req = (CsrWifiRouterCtrlModeSetReq*)msg;
+
+ if (priv == NULL)
+ {
+ unifi_error(priv, "CsrWifiRouterCtrlModeSetReqHandler: invalid smepriv\n");
+ return;
+ }
+
+ if (req->interfaceTag < CSR_WIFI_NUM_INTERFACES)
+ {
+ netInterface_priv_t *interfacePriv = priv->interfacePriv[req->interfaceTag];
+#ifdef CSR_WIFI_SPLIT_PATCH
+ u8 old_mode = interfacePriv->interfaceMode;
+#endif
+ unifi_trace(priv, UDBG1, "CsrWifiRouterCtrlModeSetReqHandler: interfacePriv->interfaceMode = %d\n",
+ interfacePriv->interfaceMode);
+
+ interfacePriv->interfaceMode = req->mode;
+
+#ifdef CSR_WIFI_SPLIT_PATCH
+ /* Detect a change in mode that requires a switch to/from the AP firmware patch.
+ * This should only happen when transitioning in/out of AP modes.
+ */
+ if (CSR_WIFI_HIP_IS_AP_FW(req->mode) != CSR_WIFI_HIP_IS_AP_FW(old_mode))
+ {
+ CsrWifiRouterCtrlVersions versions;
+ int r;
+
+#ifdef ANDROID_BUILD
+ /* Take the wakelock while switching patch */
+ unifi_trace(priv, UDBG1, "patch switch: take wake lock\n");
+ wake_lock(&unifi_sdio_wake_lock);
+#endif
+ unifi_info(priv, "Resetting UniFi with %s patch\n", CSR_WIFI_HIP_IS_AP_FW(req->mode) ? "AP" : "STA");
+
+ r = uf_request_firmware_files(priv, UNIFI_FW_STA);
+ if (r) {
+ unifi_error(priv, "CsrWifiRouterCtrlModeSetReqHandler: Failed to get f/w\n");
+ CsrWifiRouterCtrlModeSetCfmSend(msg->source, req->clientData, req->interfaceTag,
+ req->mode, CSR_RESULT_FAILURE);
+ return;
+ }
+
+ /* Block the I/O thread */
+ priv->bh_thread.block_thread = 1;
+
+ /* Reset and download the new patch */
+ r = uf_init_hw(priv);
+ if (r) {
+ unifi_error(priv, "CsrWifiRouterCtrlWifiOnReqHandler: Failed to initialise h/w, error %d\n", r);
+ CsrWifiRouterCtrlModeSetCfmSend(msg->source, req->clientData, req->interfaceTag,
+ req->mode, CSR_RESULT_FAILURE);
+ return;
+ }
+
+ /* Re-enable the I/O thread */
+ priv->bh_thread.block_thread = 0;
+
+ /* Get the version information from the core */
+ unifi_card_info(priv->card, &priv->card_info);
+
+ /* Copy to the unifiio_card_info structure. */
+ versions.chipId = priv->card_info.chip_id;
+ versions.chipVersion = priv->card_info.chip_version;
+ versions.firmwareBuild = priv->card_info.fw_build;
+ versions.firmwareHip = priv->card_info.fw_hip_version;
+ versions.routerBuild = (char*)CSR_WIFI_VERSION;
+ versions.routerHip = (UNIFI_HIP_MAJOR_VERSION << 8) | UNIFI_HIP_MINOR_VERSION;
+
+ /* Now that new firmware is running, send a WifiOnInd to the NME. This will
+ * cause it to retransfer the MIB.
+ */
+ CsrWifiRouterCtrlWifiOnIndSend(msg->source, 0, CSR_RESULT_SUCCESS, versions);
+
+ /* Store the request so we know where to send the ModeSetCfm */
+ priv->pending_mode_set = *req;
+ }
+ else
+#endif
+ {
+ /* No patch switch, confirm straightaway */
+ CsrWifiRouterCtrlModeSetCfmSend(msg->source, req->clientData, req->interfaceTag,
+ req->mode, CSR_RESULT_SUCCESS);
+ }
+
+ interfacePriv->bssid = req->bssid;
+ /* For modes other than AP/P2PGO, set below member FALSE */
+ interfacePriv->intraBssEnabled = FALSE;
+ /* Initialise the variable bcTimSet with a value
+ * other then CSR_WIFI_TIM_SET or CSR_WIFI_TIM_RESET value
+ */
+ interfacePriv->bcTimSet = 0xFF;
+ interfacePriv->bcTimSetReqPendingFlag = FALSE;
+ /* Initialise the variable bcTimSetReqQueued with a value
+ * other then CSR_WIFI_TIM_SET or CSR_WIFI_TIM_RESET value
+ */
+ interfacePriv->bcTimSetReqQueued =0xFF;
+ CsrWifiRouterCtrlInterfaceReset(priv,req->interfaceTag);
+
+ if(req->mode == CSR_WIFI_ROUTER_CTRL_MODE_AP ||
+ req->mode == CSR_WIFI_ROUTER_CTRL_MODE_P2PGO) {
+ interfacePriv->protect = req->protection;
+ interfacePriv->dtimActive=FALSE;
+ interfacePriv->multicastPduHostTag = 0xffffffff;
+ /* For AP/P2PGO mode SME sending intraBssDistEnabled
+ * i.e. for AP: intraBssDistEnabled = TRUE, for P2PGO
+ * intraBssDistEnabled = TRUE/FALSE on requirement
+ */
+ interfacePriv->intraBssEnabled = req->intraBssDistEnabled;
+ unifi_trace(priv, UDBG3, "CsrWifiRouterCtrlModeSetReqHandler: IntraBssDisEnabled = %d\n",
+ req->intraBssDistEnabled);
+ } else if (req->mode == CSR_WIFI_ROUTER_CTRL_MODE_NONE) {
+ netif_carrier_off(priv->netdev[req->interfaceTag]);
+ interfacePriv->connected = UnifiConnectedUnknown;
+ }
+ }
+ else {
+ unifi_error(priv, "CsrWifiRouterCtrlModeSetReqHandler: invalid interfaceTag :%d\n",req->interfaceTag);
+ }
+}
+
+void CsrWifiRouterMaPacketResHandler(void* drvpriv, CsrWifiFsmEvent* msg)
+{
+}
+
+/* delete the station record from the station record data base */
+static int peer_delete_record(unifi_priv_t *priv, CsrWifiRouterCtrlPeerDelReq *req)
+{
+ u8 j;
+ CsrWifiRouterCtrlStaInfo_t *staInfo = NULL;
+ unifi_port_config_t *controlledPort;
+ unifi_port_config_t *unControlledPort;
+ netInterface_priv_t *interfacePriv;
+
+ u8 ba_session_idx = 0;
+ ba_session_rx_struct *ba_session_rx = NULL;
+ ba_session_tx_struct *ba_session_tx = NULL;
+
+ /* create a list for sending confirms of un-delivered packets */
+ struct list_head send_cfm_list;
+
+ unsigned long lock_flags;
+
+ if ((req->peerRecordHandle >= UNIFI_MAX_CONNECTIONS) || (req->interfaceTag >= CSR_WIFI_NUM_INTERFACES)) {
+ unifi_error(priv, "handle/interfaceTag is not proper, handle = %d, interfaceTag = %d\n", req->peerRecordHandle, req->interfaceTag);
+ return CSR_RESULT_FAILURE;
+ }
+
+ INIT_LIST_HEAD(&send_cfm_list);
+
+ interfacePriv = priv->interfacePriv[req->interfaceTag];
+ /* remove the station record & make it NULL */
+ if ((staInfo=interfacePriv->staInfo[req->peerRecordHandle])!=NULL) {
+
+ uf_prepare_send_cfm_list_for_queued_pkts(priv,
+ &send_cfm_list,
+ &(staInfo->mgtFrames));
+
+ uf_flush_list(priv,&(staInfo->mgtFrames));
+ for(j=0;j<MAX_ACCESS_CATOGORY;j++){
+ uf_prepare_send_cfm_list_for_queued_pkts(priv,
+ &send_cfm_list,
+ &(staInfo->dataPdu[j]));
+ uf_flush_list(priv,&(staInfo->dataPdu[j]));
+ }
+
+ spin_lock_irqsave(&priv->staRecord_lock,lock_flags);
+ /* clear the port configure array info, for the corresponding peer entry */
+ controlledPort = &interfacePriv->controlled_data_port;
+ unControlledPort = &interfacePriv->uncontrolled_data_port;
+
+ unifi_trace(priv, UDBG1, "peer_delete_record: Peer found handle = %d, port in use: cont(%d), unCont(%d)\n",
+ req->peerRecordHandle, controlledPort->entries_in_use, unControlledPort->entries_in_use);
+
+ memset(staInfo->peerControlledPort, 0, sizeof(unifi_port_cfg_t));
+ staInfo->peerControlledPort->port_action = CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_CLOSED_DISCARD;
+ staInfo->peerControlledPort->in_use = FALSE;
+ if (controlledPort->entries_in_use) {
+ controlledPort->entries_in_use--;
+ } else {
+ unifi_warning(priv, "number of controlled port entries is zero, trying to decrement: debug\n");
+ }
+
+ memset(staInfo->peerUnControlledPort, 0, sizeof(unifi_port_cfg_t));
+ staInfo->peerUnControlledPort->port_action = CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_CLOSED_DISCARD;
+ staInfo->peerUnControlledPort->in_use = FALSE;
+ if (unControlledPort->entries_in_use) {
+ unControlledPort->entries_in_use--;
+ } else {
+ unifi_warning(priv, "number of uncontrolled port entries is zero, trying to decrement: debug\n");
+ }
+
+ spin_unlock_irqrestore(&priv->staRecord_lock,lock_flags);
+ /* update the TIM with zero */
+ if (interfacePriv->interfaceMode != CSR_WIFI_ROUTER_CTRL_MODE_IBSS &&
+ staInfo->timSet == CSR_WIFI_TIM_SET) {
+ unifi_trace(priv, UDBG3, "peer is deleted so TIM updated to 0, in firmware\n");
+ update_tim(priv,staInfo->aid,0,req->interfaceTag, req->peerRecordHandle);
+ }
+
+
+ /* Stop BA session if it is active, for this peer address all BA sessions
+ (per tID per role) are closed */
+
+ down(&priv->ba_mutex);
+ for(ba_session_idx=0; ba_session_idx < MAX_SUPPORTED_BA_SESSIONS_RX; ba_session_idx++){
+ ba_session_rx = priv->interfacePriv[req->interfaceTag]->ba_session_rx[ba_session_idx];
+ if(ba_session_rx) {
+ if(!memcmp(ba_session_rx->macAddress.a, staInfo->peerMacAddress.a, ETH_ALEN)){
+ blockack_session_stop(priv,
+ req->interfaceTag,
+ CSR_WIFI_ROUTER_CTRL_BLOCK_ACK_RECIPIENT,
+ ba_session_rx->tID,
+ ba_session_rx->macAddress);
+ }
+ }
+ }
+
+ for(ba_session_idx=0; ba_session_idx < MAX_SUPPORTED_BA_SESSIONS_TX; ba_session_idx++){
+ ba_session_tx = priv->interfacePriv[req->interfaceTag]->ba_session_tx[ba_session_idx];
+ if(ba_session_tx) {
+ if(!memcmp(ba_session_tx->macAddress.a, staInfo->peerMacAddress.a, ETH_ALEN)){
+ blockack_session_stop(priv,
+ req->interfaceTag,
+ CSR_WIFI_ROUTER_CTRL_BLOCK_ACK_ORIGINATOR,
+ ba_session_tx->tID,
+ ba_session_tx->macAddress);
+ }
+ }
+ }
+
+ up(&priv->ba_mutex);
+
+#ifdef CSR_SUPPORT_SME
+ unifi_trace(priv, UDBG1, "Canceling work queue for STA with AID: %d\n", staInfo->aid);
+ cancel_work_sync(&staInfo->send_disconnected_ind_task);
+#endif
+
+ spin_lock_irqsave(&priv->staRecord_lock,lock_flags);
+#ifdef CSR_SUPPORT_SME
+ interfacePriv->num_stations_joined--;
+
+ staInfo->nullDataHostTag = INVALID_HOST_TAG;
+
+ if ((interfacePriv->sta_activity_check_enabled) &&
+ (interfacePriv->num_stations_joined < STA_INACTIVE_DETECTION_TRIGGER_THRESHOLD))
+ {
+ unifi_trace(priv, UDBG1, "STOPPING the Inactivity Timer (num of stations = %d)\n", interfacePriv->num_stations_joined);
+ interfacePriv->sta_activity_check_enabled = FALSE;
+ del_timer_sync(&interfacePriv->sta_activity_check_timer);
+ }
+#endif
+
+ /* Free the station record for corresponding peer */
+ kfree(interfacePriv->staInfo[req->peerRecordHandle]);
+ interfacePriv->staInfo[req->peerRecordHandle] = NULL;
+ spin_unlock_irqrestore(&priv->staRecord_lock,lock_flags);
+
+ /* after the critical region process the list of frames that requested cfm
+ and send cfm to requestor one by one */
+ send_auto_ma_packet_confirm(priv, interfacePriv, &send_cfm_list);
+
+
+ }
+ else
+ {
+ unifi_trace(priv, UDBG3, " peer not found: Delete request Peer handle[%d]\n", req->peerRecordHandle);
+ }
+
+ return CSR_RESULT_SUCCESS;
+}
+
+void CsrWifiRouterCtrlPeerDelReqHandler(void* drvpriv, CsrWifiFsmEvent* msg)
+{
+ CsrWifiRouterCtrlPeerDelReq* req = (CsrWifiRouterCtrlPeerDelReq*)msg;
+ CsrResult status = CSR_RESULT_SUCCESS;
+ unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
+ netInterface_priv_t *interfacePriv = priv->interfacePriv[req->interfaceTag];
+
+ unifi_trace(priv, UDBG2, "entering CsrWifiRouterCtrlPeerDelReqHandler \n");
+ if (priv == NULL)
+ {
+ unifi_error(priv, "CsrWifiRouterCtrlPeerDelReqHandler: invalid smepriv\n");
+ return;
+ }
+
+ if (req->interfaceTag >= CSR_WIFI_NUM_INTERFACES)
+ {
+ unifi_error(priv, "CsrWifiRouterCtrlPeerDelReqHandler: bad interfaceTag\n");
+ return;
+ }
+
+ switch(interfacePriv->interfaceMode)
+ {
+ case CSR_WIFI_ROUTER_CTRL_MODE_AP:
+ case CSR_WIFI_ROUTER_CTRL_MODE_IBSS:
+ case CSR_WIFI_ROUTER_CTRL_MODE_P2PGO:
+ /* remove the station from station record data base */
+ status = peer_delete_record(priv, req);
+ break;
+ case CSR_WIFI_ROUTER_CTRL_MODE_STA:
+ case CSR_WIFI_ROUTER_CTRL_MODE_P2PCLI:
+ default:
+ /* No station record to maintain in these modes */
+ break;
+ }
+
+ CsrWifiRouterCtrlPeerDelCfmSend(msg->source,req->clientData,req->interfaceTag,status);
+ unifi_trace(priv, UDBG2, "leaving CsrWifiRouterCtrlPeerDelReqHandler \n");
+}
+
+/* Add the new station to the station record data base */
+static int peer_add_new_record(unifi_priv_t *priv,CsrWifiRouterCtrlPeerAddReq *req,u32 *handle)
+{
+ u8 i, powerModeTemp = 0;
+ u8 freeSlotFound = FALSE;
+ CsrWifiRouterCtrlStaInfo_t *newRecord = NULL;
+ netInterface_priv_t *interfacePriv = priv->interfacePriv[req->interfaceTag];
+ CsrTime currentTime, currentTimeHi;
+ unsigned long lock_flags;
+
+ if (req->interfaceTag >= CSR_WIFI_NUM_INTERFACES) {
+ unifi_error(priv, "peer_add_new_record: bad interfaceTag\n");
+ return CSR_RESULT_FAILURE;
+ }
+
+ currentTime = CsrTimeGet(&currentTimeHi);
+
+ for(i = 0; i < UNIFI_MAX_CONNECTIONS; i++) {
+ if(interfacePriv->staInfo[i] == NULL) {
+ /* Slot is empty, so can be used for station record */
+ freeSlotFound = TRUE;
+ *handle = i;
+
+ /* Allocate for the new station record , to avoid race condition would happen between ADD_PEER &
+ * DEL_PEER the allocation made atomic memory rather than kernel memory
+ */
+ newRecord = (CsrWifiRouterCtrlStaInfo_t *) kmalloc(sizeof(CsrWifiRouterCtrlStaInfo_t), GFP_ATOMIC);
+ if (!newRecord) {
+ unifi_error(priv, "failed to allocate the %d bytes of mem for station record\n",
+ sizeof(CsrWifiRouterCtrlStaInfo_t));
+ return CSR_RESULT_FAILURE;
+ }
+
+ unifi_trace(priv, UDBG1, "peer_add_new_record: handle = %d AID = %d addr = %x:%x:%x:%x:%x:%x LI=%u\n",
+ *handle, req->associationId, req->peerMacAddress.a[0], req->peerMacAddress.a[1], req->peerMacAddress.a[2],
+ req->peerMacAddress.a[3], req->peerMacAddress.a[4], req->peerMacAddress.a[5],
+ req->staInfo.listenIntervalInTus);
+
+ /* disable the preemption until station record updated */
+ spin_lock_irqsave(&priv->staRecord_lock,lock_flags);
+
+ interfacePriv->staInfo[i] = newRecord;
+ /* Initialize the record*/
+ memset(newRecord,0,sizeof(CsrWifiRouterCtrlStaInfo_t));
+ /* update the station record */
+ memcpy(newRecord->peerMacAddress.a, req->peerMacAddress.a, ETH_ALEN);
+ newRecord->wmmOrQosEnabled = req->staInfo.wmmOrQosEnabled;
+
+ /* maxSpLength is bit map in qosInfo field, so converting accordingly */
+ newRecord->maxSpLength = req->staInfo.maxSpLength * 2;
+
+ /*Max SP 0 mean any number of packets. since we buffer only 512
+ packets we are hard coding this to zero for the moment */
+
+ if(newRecord->maxSpLength == 0)
+ newRecord->maxSpLength=512;
+
+ newRecord->assignedHandle = i;
+
+ /* copy power save mode of all access catagory (Trigger/Delivery/both enabled/disabled) */
+ powerModeTemp = (u8) ((req->staInfo.powersaveMode >> 4) & 0xff);
+
+ if(!(req->staInfo.powersaveMode & 0x0001))
+ newRecord->powersaveMode[UNIFI_TRAFFIC_Q_BK]= CSR_WIFI_AC_LEGACY_POWER_SAVE;
+ else
+ newRecord->powersaveMode[UNIFI_TRAFFIC_Q_BK]= powerModeTemp & 0x03;
+
+ if(!(req->staInfo.powersaveMode & 0x0002))
+ newRecord->powersaveMode[UNIFI_TRAFFIC_Q_BE]= CSR_WIFI_AC_LEGACY_POWER_SAVE;
+ else
+ newRecord->powersaveMode[UNIFI_TRAFFIC_Q_BE]= ((powerModeTemp & 0x0C)>> 2);
+
+ if(!(req->staInfo.powersaveMode & 0x0004))
+ newRecord->powersaveMode[UNIFI_TRAFFIC_Q_VI]= CSR_WIFI_AC_LEGACY_POWER_SAVE;
+ else
+ newRecord->powersaveMode[UNIFI_TRAFFIC_Q_VI]= ((powerModeTemp & 0x30)>> 4);
+
+ if(!(req->staInfo.powersaveMode & 0x0008))
+ newRecord->powersaveMode[UNIFI_TRAFFIC_Q_VO]= CSR_WIFI_AC_LEGACY_POWER_SAVE;
+ else
+ newRecord->powersaveMode[UNIFI_TRAFFIC_Q_VO]= ((powerModeTemp & 0xC0)>> 6);
+
+ {
+ u8 k;
+ for(k=0; k< MAX_ACCESS_CATOGORY ;k++)
+ unifi_trace(priv, UDBG2, "peer_add_new_record: WMM : %d ,AC %d, powersaveMode %x \n",
+ req->staInfo.wmmOrQosEnabled,k,newRecord->powersaveMode[k]);
+ }
+
+ unifi_trace(priv, UDBG3, "newRecord->wmmOrQosEnabled : %d , MAX SP : %d\n",
+ newRecord->wmmOrQosEnabled,newRecord->maxSpLength);
+
+ /* Initialize the mgtFrames & data Pdu list */
+ {
+ u8 j;
+ INIT_LIST_HEAD(&newRecord->mgtFrames);
+ for(j = 0; j < MAX_ACCESS_CATOGORY; j++) {
+ INIT_LIST_HEAD(&newRecord->dataPdu[j]);
+ }
+ }
+
+ newRecord->lastActivity = currentTime;
+ newRecord->activity_flag = TRUE;
+
+ /* enable the preemption as station record updated */
+ spin_unlock_irqrestore(&priv->staRecord_lock,lock_flags);
+
+ /* First time port actions are set for the peer with below information */
+ configure_data_port(priv, CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_OPEN, &newRecord->peerMacAddress,
+ UF_UNCONTROLLED_PORT_Q, req->interfaceTag);
+
+ if (interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_IBSS) {
+ configure_data_port(priv, CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_OPEN, &newRecord->peerMacAddress,
+ UF_CONTROLLED_PORT_Q, req->interfaceTag);
+ } else {
+ configure_data_port(priv, CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_CLOSED_DISCARD, &newRecord->peerMacAddress,
+ UF_CONTROLLED_PORT_Q, req->interfaceTag);
+ }
+
+
+ spin_lock_irqsave(&priv->staRecord_lock,lock_flags);
+ /* Port status must be already set before calling the Add Peer request */
+ newRecord->peerControlledPort = uf_sme_port_config_handle(priv, newRecord->peerMacAddress.a,
+ UF_CONTROLLED_PORT_Q, req->interfaceTag);
+ newRecord->peerUnControlledPort = uf_sme_port_config_handle(priv, newRecord->peerMacAddress.a,
+ UF_UNCONTROLLED_PORT_Q, req->interfaceTag);
+
+ if (!newRecord->peerControlledPort || !newRecord->peerUnControlledPort) {
+ /* enable the preemption as station record failed to update */
+ unifi_warning(priv, "Un/ControlledPort record not found in port configuration array index = %d\n", i);
+ kfree(interfacePriv->staInfo[i]);
+ interfacePriv->staInfo[i] = NULL;
+ spin_unlock_irqrestore(&priv->staRecord_lock,lock_flags);
+ return CSR_RESULT_FAILURE;
+ }
+
+ newRecord->currentPeerState = CSR_WIFI_ROUTER_CTRL_PEER_CONNECTED_ACTIVE;
+
+ /* changes done during block ack handling */
+ newRecord->txSuspend = FALSE;
+
+ /*U-APSD related data structure*/
+ newRecord->timRequestPendingFlag = FALSE;
+
+ /* Initialise the variable updateTimReqQueued with a value
+ * other then CSR_WIFI_TIM_SET or CSR_WIFI_TIM_RESET value
+ */
+ newRecord->updateTimReqQueued = 0xFF;
+ newRecord->timSet = CSR_WIFI_TIM_RESET;
+ newRecord->uapsdActive = FALSE;
+ newRecord->noOfSpFramesSent =0;
+ newRecord->triggerFramePriority = CSR_QOS_UP0;
+
+ /* The protection bit is updated once the port opens for corresponding peer in
+ * routerPortConfigure request */
+
+ /* update the association ID */
+ newRecord->aid = req->associationId;
+
+#ifdef CSR_SUPPORT_SME
+ interfacePriv->num_stations_joined++;
+ newRecord->interfacePriv = interfacePriv;
+ newRecord->listenIntervalInTus = req->staInfo.listenIntervalInTus;
+ newRecord->nullDataHostTag = INVALID_HOST_TAG;
+
+ INIT_WORK(&newRecord->send_disconnected_ind_task, uf_send_disconnected_ind_wq);
+
+ if(!(interfacePriv->sta_activity_check_enabled) &&
+ (interfacePriv->num_stations_joined >= STA_INACTIVE_DETECTION_TRIGGER_THRESHOLD)){
+ unifi_trace(priv, UDBG1,
+ "peer_add_new_record: STARTING the Inactivity Timer (num of stations = %d)",
+ interfacePriv->num_stations_joined);
+
+ interfacePriv->sta_activity_check_enabled = TRUE;
+ interfacePriv->sta_activity_check_timer.function = check_inactivity_timer_expire_func;
+ interfacePriv->sta_activity_check_timer.data = (unsigned long)interfacePriv;
+
+ init_timer(&interfacePriv->sta_activity_check_timer);
+ mod_timer(&interfacePriv->sta_activity_check_timer,
+ (jiffies + usecs_to_jiffies(STA_INACTIVE_DETECTION_TIMER_INTERVAL * 1000 * 1000)));
+
+ }
+#endif
+ spin_unlock_irqrestore(&priv->staRecord_lock,lock_flags);
+ break;
+ }
+ }
+
+ if(!freeSlotFound) {
+ unifi_error(priv, "Limited connectivity, Free slot not found for station record addition\n");
+ return CSR_RESULT_FAILURE;
+ }
+ return CSR_RESULT_SUCCESS;
+}
+
+#ifdef CSR_SUPPORT_SME
+static void check_inactivity_timer_expire_func(unsigned long data)
+{
+ struct unifi_priv *priv;
+ CsrWifiRouterCtrlStaInfo_t *sta_record = NULL;
+ u8 i = 0;
+ CsrTime now;
+ CsrTime inactive_time;
+ netInterface_priv_t *interfacePriv = (netInterface_priv_t *) data;
+
+ if (!interfacePriv)
+ {
+ return;
+ }
+
+ priv = interfacePriv->privPtr;
+
+ if (interfacePriv->InterfaceTag >= CSR_WIFI_NUM_INTERFACES)
+ {
+ unifi_error(priv, "check_inactivity_timer_expire_func: Invalid interfaceTag\n");
+ return;
+ }
+
+ /* RUN Algorithm to check inactivity for each connected station */
+ now = CsrTimeGet(NULL);
+
+ for(i = 0; i < UNIFI_MAX_CONNECTIONS; i++) {
+ if(interfacePriv->staInfo[i] != NULL) {
+ sta_record = interfacePriv->staInfo[i];
+
+ if (sta_record->activity_flag == TRUE){
+ sta_record->activity_flag = FALSE;
+ sta_record->lastActivity = now;
+ continue;
+ }
+
+ if (sta_record->lastActivity > now)
+ {
+ /* simple timer wrap (for 1 wrap) */
+ inactive_time = CsrTimeAdd((CsrTime)CsrTimeSub(CSR_SCHED_TIME_MAX, sta_record->lastActivity), now);
+ }
+ else
+ {
+ inactive_time = (CsrTime)CsrTimeSub(now, sta_record->lastActivity);
+ }
+
+ if (inactive_time >= STA_INACTIVE_TIMEOUT_VAL)
+ {
+ unifi_trace(priv, UDBG1, "STA is Inactive - AID = %d inactive_time = %d\n",
+ sta_record->aid,
+ inactive_time);
+
+ /* station is in-active, if it is in active mode send a null frame
+ * and the station should acknowledge the null frame, if acknowledgement
+ * is not received throw out the station.
+ * If the station is in Power Save, update TIM for the station so
+ * that it wakes up and register some activity through PS-Poll or
+ * trigger frame.
+ */
+ if (sta_record->currentPeerState == CSR_WIFI_ROUTER_CTRL_PEER_CONNECTED_ACTIVE)
+ {
+ unifi_trace(priv, UDBG1, "STA power save state - Active, send a NULL frame to check if it is ALIVE\n");
+ uf_send_nulldata ( priv,
+ sta_record->interfacePriv->InterfaceTag,
+ sta_record->peerMacAddress.a,
+ CSR_CONTENTION,
+ sta_record);
+ }
+ else if (sta_record->currentPeerState == CSR_WIFI_ROUTER_CTRL_PEER_CONNECTED_POWER_SAVE)
+ {
+ if((sta_record->timSet == CSR_WIFI_TIM_SET) ||
+ (sta_record->timSet == CSR_WIFI_TIM_SETTING))
+ {
+ unifi_trace(priv, UDBG1, "STA power save state - PS, TIM is already SET\n");
+
+ /* If TIM is set and we do not have any activity for
+ * more than 3 listen intervals then send a disconnected
+ * indication to SME, to delete the station from station
+ * record list.
+ * The inactivity is already more than STA_INACTIVE_TIMEOUT_VAL
+ * and this check ensures if the listen interval is a larger
+ * value than STA_INACTIVE_TIMEOUT_VAL.
+ */
+ if (inactive_time > (3 * (sta_record->listenIntervalInTus * 1024)))
+ {
+ unifi_trace(priv, UDBG1, "STA is inactive for more than 3 listen intervals\n");
+ queue_work( priv->unifi_workqueue,
+ &sta_record->send_disconnected_ind_task);
+ }
+
+ }
+ else
+ {
+ unifi_trace(priv, UDBG1, "STA power save state - PS, update TIM to see if it is ALIVE\n");
+ update_tim(priv,
+ sta_record->aid,
+ CSR_WIFI_TIM_SET,
+ interfacePriv->InterfaceTag,
+ sta_record->assignedHandle);
+ }
+ }
+ }
+ }
+ }
+
+ /* re-run the timer interrupt */
+ mod_timer(&interfacePriv->sta_activity_check_timer,
+ (jiffies + usecs_to_jiffies(STA_INACTIVE_DETECTION_TIMER_INTERVAL * 1000 * 1000)));
+
+}
+
+
+void uf_send_disconnected_ind_wq(struct work_struct *work)
+{
+
+ CsrWifiRouterCtrlStaInfo_t *staInfo = container_of(work, CsrWifiRouterCtrlStaInfo_t, send_disconnected_ind_task);
+ unifi_priv_t *priv;
+ u16 interfaceTag;
+ struct list_head send_cfm_list;
+ u8 j;
+
+ func_enter();
+
+ if(!staInfo) {
+ return;
+ }
+
+ if(!staInfo->interfacePriv) {
+ return;
+ }
+
+ priv = staInfo->interfacePriv->privPtr;
+ interfaceTag = staInfo->interfacePriv->InterfaceTag;
+
+ if (interfaceTag >= CSR_WIFI_NUM_INTERFACES) {
+ unifi_error(priv, "uf_send_disconnected_ind_wq: invalid interfaceTag\n");
+ return;
+ }
+
+ /* The SME/NME may be waiting for confirmation for requested frames to this station.
+ * So loop through buffered frames for this station and if confirmation is
+ * requested, send auto confirmation with failure status. Also flush the frames so
+ * that these are not processed again in PEER_DEL_REQ handler.
+ */
+ INIT_LIST_HEAD(&send_cfm_list);
+
+ uf_prepare_send_cfm_list_for_queued_pkts(priv,
+ &send_cfm_list,
+ &(staInfo->mgtFrames));
+
+ uf_flush_list(priv, &(staInfo->mgtFrames));
+
+ for(j = 0; j < MAX_ACCESS_CATOGORY; j++){
+ uf_prepare_send_cfm_list_for_queued_pkts(priv,
+ &send_cfm_list,
+ &(staInfo->dataPdu[j]));
+
+ uf_flush_list(priv,&(staInfo->dataPdu[j]));
+ }
+
+ send_auto_ma_packet_confirm(priv, staInfo->interfacePriv, &send_cfm_list);
+
+ unifi_warning(priv, "uf_send_disconnected_ind_wq: Router Disconnected IND Peer (%x-%x-%x-%x-%x-%x)\n",
+ staInfo->peerMacAddress.a[0],
+ staInfo->peerMacAddress.a[1],
+ staInfo->peerMacAddress.a[2],
+ staInfo->peerMacAddress.a[3],
+ staInfo->peerMacAddress.a[4],
+ staInfo->peerMacAddress.a[5]);
+
+ CsrWifiRouterCtrlConnectedIndSend(priv->CSR_WIFI_SME_IFACEQUEUE,
+ 0,
+ staInfo->interfacePriv->InterfaceTag,
+ staInfo->peerMacAddress,
+ CSR_WIFI_ROUTER_CTRL_PEER_DISCONNECTED);
+
+
+ return;
+}
+
+
+#endif
+void CsrWifiRouterCtrlPeerAddReqHandler(void* drvpriv,CsrWifiFsmEvent* msg)
+{
+ CsrWifiRouterCtrlPeerAddReq* req = (CsrWifiRouterCtrlPeerAddReq*)msg;
+ CsrResult status = CSR_RESULT_SUCCESS;
+ unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
+ u32 handle = 0;
+ netInterface_priv_t *interfacePriv = priv->interfacePriv[req->interfaceTag];
+
+ unifi_trace(priv, UDBG2, "entering CsrWifiRouterCtrlPeerAddReqHandler \n");
+ if (priv == NULL)
+ {
+ unifi_error(priv, "CsrWifiRouterCtrlPeerAddReqHandler: invalid smepriv\n");
+ return;
+ }
+
+ if (req->interfaceTag >= CSR_WIFI_NUM_INTERFACES)
+ {
+ unifi_error(priv, "CsrWifiRouterCtrlPeerAddReqHandler: bad interfaceTag\n");
+ return;
+ }
+
+ switch(interfacePriv->interfaceMode)
+ {
+ case CSR_WIFI_ROUTER_CTRL_MODE_AP:
+ case CSR_WIFI_ROUTER_CTRL_MODE_IBSS:
+ case CSR_WIFI_ROUTER_CTRL_MODE_P2PGO:
+ /* Add station record */
+ status = peer_add_new_record(priv,req,&handle);
+ break;
+ case CSR_WIFI_ROUTER_CTRL_MODE_STA:
+ case CSR_WIFI_ROUTER_CTRL_MODE_P2PCLI:
+ default:
+ /* No station record to maintain in these modes */
+ break;
+ }
+
+ CsrWifiRouterCtrlPeerAddCfmSend(msg->source,req->clientData,req->interfaceTag,req->peerMacAddress,handle,status);
+ unifi_trace(priv, UDBG2, "leaving CsrWifiRouterCtrlPeerAddReqHandler \n");
+}
+
+void CsrWifiRouterCtrlPeerUpdateReqHandler(void* drvpriv,CsrWifiFsmEvent* msg)
+{
+ CsrWifiRouterCtrlPeerUpdateReq* req = (CsrWifiRouterCtrlPeerUpdateReq*)msg;
+ CsrResult status = CSR_RESULT_SUCCESS;
+ unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
+
+ unifi_trace(priv, UDBG2, "entering CsrWifiRouterCtrlPeerUpdateReqHandler \n");
+ if (priv == NULL)
+ {
+ unifi_error(priv, "CsrWifiRouterCtrlPeerUpdateReqHandler: invalid smepriv\n");
+ return;
+ }
+
+ CsrWifiRouterCtrlPeerUpdateCfmSend(msg->source,req->clientData,req->interfaceTag,status);
+ unifi_trace(priv, UDBG2, "leaving CsrWifiRouterCtrlPeerUpdateReqHandler \n");
+}
+
+
+ void CsrWifiRouterCtrlRawSdioDeinitialiseReqHandler(void* drvpriv, CsrWifiFsmEvent* msg)
+{
+ /* This will never be called as it is intercepted in the Userspace */
+}
+
+void CsrWifiRouterCtrlRawSdioInitialiseReqHandler(void* drvpriv, CsrWifiFsmEvent* msg)
+{
+ /* This will never be called as it is intercepted in the Userspace */
+}
+
+void
+uf_send_ba_err_wq(struct work_struct *work)
+{
+ ba_session_rx_struct *ba_session = container_of(work, ba_session_rx_struct, send_ba_err_task);
+ unifi_priv_t *priv;
+
+ if(!ba_session) {
+ return;
+ }
+
+ if(!ba_session->interfacePriv) {
+ return;
+ }
+
+ priv = ba_session->interfacePriv->privPtr;
+
+ if (ba_session->interfacePriv->InterfaceTag >= CSR_WIFI_NUM_INTERFACES) {
+ unifi_error(priv, "%s: invalid interfaceTag\n", __FUNCTION__);
+ return;
+ }
+
+ unifi_warning(priv, "%s: Calling CsrWifiRouterCtrlBlockAckErrorIndSend(%d, %d, %d, %d, %x:%x:%x:%x:%x:%x, %d)\n",
+ __FUNCTION__,
+ priv->CSR_WIFI_SME_IFACEQUEUE,
+ 0,
+ ba_session->interfacePriv->InterfaceTag,
+ ba_session->tID,
+ ba_session->macAddress.a[0],
+ ba_session->macAddress.a[1],
+ ba_session->macAddress.a[2],
+ ba_session->macAddress.a[3],
+ ba_session->macAddress.a[4],
+ ba_session->macAddress.a[5],
+ CSR_RESULT_SUCCESS
+ );
+ CsrWifiRouterCtrlBlockAckErrorIndSend(priv->CSR_WIFI_SME_IFACEQUEUE,
+ 0,
+ ba_session->interfacePriv->InterfaceTag,
+ ba_session->tID,
+ ba_session->macAddress,
+ CSR_RESULT_SUCCESS);
+}
+
+
+static void ba_session_terminate_timer_func(unsigned long data)
+{
+ ba_session_rx_struct *ba_session = (ba_session_rx_struct*)data;
+ struct unifi_priv *priv;
+
+ if(!ba_session) {
+ return;
+ }
+
+ if(!ba_session->interfacePriv) {
+ return;
+ }
+
+ priv = ba_session->interfacePriv->privPtr;
+
+ if (ba_session->interfacePriv->InterfaceTag >= CSR_WIFI_NUM_INTERFACES) {
+ unifi_error(priv, "%s: invalid interfaceTag\n", __FUNCTION__);
+ return;
+ }
+
+ queue_work(priv->unifi_workqueue, &ba_session->send_ba_err_task);
+}
+
+
+u8 blockack_session_stop(unifi_priv_t *priv,
+ u16 interfaceTag,
+ CsrWifiRouterCtrlBlockAckRole role,
+ u16 tID,
+ CsrWifiMacAddress macAddress)
+{
+ netInterface_priv_t *interfacePriv;
+ ba_session_rx_struct *ba_session_rx = NULL;
+ ba_session_tx_struct *ba_session_tx = NULL;
+ u8 ba_session_idx = 0;
+ int i;
+
+ if (interfaceTag >= CSR_WIFI_NUM_INTERFACES) {
+ unifi_error(priv, "%s: bad interfaceTag = %d\n", __FUNCTION__, interfaceTag);
+ return FALSE;
+ }
+
+ interfacePriv = priv->interfacePriv[interfaceTag];
+
+ if(!interfacePriv) {
+ unifi_error(priv, "%s: bad interfacePriv\n", __FUNCTION__);
+ return FALSE;
+ }
+
+ if(tID > 15) {
+ unifi_error(priv, "%s: bad tID = %d\n", __FUNCTION__, tID);
+ return FALSE;
+ }
+
+ if((role != CSR_WIFI_ROUTER_CTRL_BLOCK_ACK_ORIGINATOR) &&
+ (role != CSR_WIFI_ROUTER_CTRL_BLOCK_ACK_RECIPIENT)) {
+ unifi_error(priv, "%s: bad role = %d\n", __FUNCTION__, role);
+ return FALSE;
+ }
+
+ unifi_warning(priv,
+ "%s: stopping ba_session for peer = %pM role = %d tID = %d\n",
+ __func__, macAddress.a, role, tID);
+
+ /* find out the appropriate ba session (/station /tid /role) for which stop is requested */
+ if (role == CSR_WIFI_ROUTER_CTRL_BLOCK_ACK_RECIPIENT){
+ for (ba_session_idx =0; ba_session_idx < MAX_SUPPORTED_BA_SESSIONS_RX; ba_session_idx++){
+
+ ba_session_rx = interfacePriv->ba_session_rx[ba_session_idx];
+
+ if(ba_session_rx){
+ if ((!memcmp(ba_session_rx->macAddress.a, macAddress.a, ETH_ALEN)) && (ba_session_rx->tID == tID)){
+ break;
+ }
+ }
+ }
+
+ if (!ba_session_rx || (ba_session_idx == MAX_SUPPORTED_BA_SESSIONS_RX)) {
+ unifi_error(priv, "%s: bad ba_session for Rx [tID=%d]\n", __FUNCTION__, tID);
+ return FALSE;
+ }
+
+
+ if(ba_session_rx->timeout) {
+ del_timer_sync(&ba_session_rx->timer);
+ }
+ cancel_work_sync(&ba_session_rx->send_ba_err_task);
+ for (i = 0; i < ba_session_rx->wind_size; i++) {
+ if(ba_session_rx->buffer[i].active) {
+ frame_desc_struct *frame_desc = &ba_session_rx->buffer[i];
+ unifi_net_data_free(priv, &frame_desc->bulkdata.d[0]);
+ }
+ }
+ kfree(ba_session_rx->buffer);
+
+ interfacePriv->ba_session_rx[ba_session_idx] = NULL;
+ kfree(ba_session_rx);
+ }else if (role == CSR_WIFI_ROUTER_CTRL_BLOCK_ACK_ORIGINATOR){
+ for (ba_session_idx =0; ba_session_idx < MAX_SUPPORTED_BA_SESSIONS_TX; ba_session_idx++){
+ ba_session_tx = interfacePriv->ba_session_tx[ba_session_idx];
+ if(ba_session_tx){
+ if ((!memcmp(ba_session_tx->macAddress.a, macAddress.a, ETH_ALEN)) && (ba_session_tx->tID == tID)){
+ break;
+ }
+ }
+ }
+
+ if (!ba_session_tx || (ba_session_idx == MAX_SUPPORTED_BA_SESSIONS_TX)) {
+ unifi_error(priv, "%s: bad ba_session for Tx [tID=%d]\n", __FUNCTION__, tID);
+ return FALSE;
+ }
+ interfacePriv->ba_session_tx[ba_session_idx] = NULL;
+ kfree(ba_session_tx);
+
+ }
+
+ return TRUE;
+}
+
+
+void CsrWifiRouterCtrlBlockAckDisableReqHandler(void* drvpriv, CsrWifiFsmEvent* msg)
+{
+ CsrWifiRouterCtrlBlockAckDisableReq* req = (CsrWifiRouterCtrlBlockAckDisableReq*)msg;
+ u8 r;
+ unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
+
+ unifi_trace(priv, UDBG6, "%s: in ok\n", __FUNCTION__);
+
+ down(&priv->ba_mutex);
+ r = blockack_session_stop(priv,
+ req->interfaceTag,
+ req->role,
+ req->trafficStreamID,
+ req->macAddress);
+ up(&priv->ba_mutex);
+
+ CsrWifiRouterCtrlBlockAckDisableCfmSend(msg->source,
+ req->clientData,
+ req->interfaceTag,
+ r?CSR_RESULT_SUCCESS:CSR_RESULT_FAILURE);
+
+ unifi_trace(priv, UDBG6, "%s: out ok\n", __FUNCTION__);
+}
+
+
+u8 blockack_session_start(unifi_priv_t *priv,
+ u16 interfaceTag,
+ u16 tID,
+ u16 timeout,
+ CsrWifiRouterCtrlBlockAckRole role,
+ u16 wind_size,
+ u16 start_sn,
+ CsrWifiMacAddress macAddress
+ )
+{
+ netInterface_priv_t *interfacePriv;
+ ba_session_rx_struct *ba_session_rx = NULL;
+ ba_session_tx_struct *ba_session_tx = NULL;
+ u8 ba_session_idx = 0;
+
+
+ if (interfaceTag >= CSR_WIFI_NUM_INTERFACES) {
+ unifi_error(priv, "%s: bad interfaceTag = %d\n", __FUNCTION__, interfaceTag);
+ return FALSE;
+ }
+
+ interfacePriv = priv->interfacePriv[interfaceTag];
+
+ if(!interfacePriv) {
+ unifi_error(priv, "%s: bad interfacePriv\n", __FUNCTION__);
+ return FALSE;
+ }
+
+ if(tID > 15)
+ {
+ unifi_error(priv, "%s: bad tID=%d\n", __FUNCTION__, tID);
+ return FALSE;
+ }
+
+ if(wind_size > MAX_BA_WIND_SIZE) {
+ unifi_error(priv, "%s: bad wind_size = %d\n", __FUNCTION__, wind_size);
+ return FALSE;
+ }
+
+ if(role != CSR_WIFI_ROUTER_CTRL_BLOCK_ACK_ORIGINATOR &&
+ role != CSR_WIFI_ROUTER_CTRL_BLOCK_ACK_RECIPIENT) {
+ unifi_error(priv, "%s: bad role = %d\n", __FUNCTION__, role);
+ return FALSE;
+ }
+
+ unifi_warning(priv,
+ "%s: ba session with peer= (%pM)\n", __func__,
+ macAddress.a);
+
+ unifi_warning(priv, "%s: ba session for tID=%d timeout=%d role=%d wind_size=%d start_sn=%d\n", __FUNCTION__,
+ tID,
+ timeout,
+ role,
+ wind_size,
+ start_sn);
+
+ /* Check if BA session exists for per station, per TID, per role or not.
+ if BA session exists update parameters and if it does not exist
+ create a new BA session */
+ if (role == CSR_WIFI_ROUTER_CTRL_BLOCK_ACK_ORIGINATOR){
+ for (ba_session_idx =0; ba_session_idx < MAX_SUPPORTED_BA_SESSIONS_TX; ba_session_idx++){
+ ba_session_tx = interfacePriv->ba_session_tx[ba_session_idx];
+ if (ba_session_tx) {
+ if ((!memcmp(ba_session_tx->macAddress.a, macAddress.a, ETH_ALEN)) && (ba_session_tx->tID == tID)){
+ unifi_warning(priv, "%s: ba_session for Tx already exists\n", __FUNCTION__);
+ return TRUE;
+ }
+ }
+ }
+
+ /* we have to create new ba_session_tx struct */
+ ba_session_tx = NULL;
+
+ /* loop through until an empty BA session slot is there and save the session there */
+ for (ba_session_idx=0; ba_session_idx < MAX_SUPPORTED_BA_SESSIONS_TX ; ba_session_idx++){
+ if (!(interfacePriv->ba_session_tx[ba_session_idx])){
+ break;
+ }
+ }
+ if (ba_session_idx == MAX_SUPPORTED_BA_SESSIONS_TX){
+ unifi_error(priv, "%s: All ba_session used for Tx, NO free session available\n", __FUNCTION__);
+ return FALSE;
+ }
+
+ /* create and populate the new BA session structure */
+ ba_session_tx = kmalloc(sizeof(ba_session_tx_struct), GFP_KERNEL);
+ if (!ba_session_tx) {
+ unifi_error(priv, "%s: kmalloc failed for ba_session_tx\n", __FUNCTION__);
+ return FALSE;
+ }
+ memset(ba_session_tx, 0, sizeof(ba_session_tx_struct));
+
+ ba_session_tx->interfacePriv = interfacePriv;
+ ba_session_tx->tID = tID;
+ ba_session_tx->macAddress = macAddress;
+
+ interfacePriv->ba_session_tx[ba_session_idx] = ba_session_tx;
+
+ } else if (role == CSR_WIFI_ROUTER_CTRL_BLOCK_ACK_RECIPIENT){
+
+ for (ba_session_idx =0; ba_session_idx < MAX_SUPPORTED_BA_SESSIONS_RX; ba_session_idx++){
+ ba_session_rx = interfacePriv->ba_session_rx[ba_session_idx];
+ if (ba_session_rx) {
+ if ((!memcmp(ba_session_rx->macAddress.a, macAddress.a, ETH_ALEN)) && (ba_session_rx->tID == tID)){
+ unifi_warning(priv, "%s: ba_session for Rx[tID = %d] already exists\n", __FUNCTION__, tID);
+
+ if(ba_session_rx->wind_size == wind_size &&
+ ba_session_rx->timeout == timeout &&
+ ba_session_rx->expected_sn == start_sn) {
+ return TRUE;
+ }
+
+ if(ba_session_rx->timeout) {
+ del_timer_sync(&ba_session_rx->timer);
+ ba_session_rx->timeout = 0;
+ }
+
+ if(ba_session_rx->wind_size != wind_size) {
+ blockack_session_stop(priv, interfaceTag, role, tID, macAddress);
+ } else {
+ if (timeout) {
+ ba_session_rx->timeout = timeout;
+ ba_session_rx->timer.function = ba_session_terminate_timer_func;
+ ba_session_rx->timer.data = (unsigned long)ba_session_rx;
+ init_timer(&ba_session_rx->timer);
+ mod_timer(&ba_session_rx->timer, (jiffies + usecs_to_jiffies((ba_session_rx->timeout) * 1024)));
+ }
+ /*
+ * The starting sequence number shall remain same if the BA
+ * enable request is issued to update BA parameters only. If
+ * it is not same, then we scroll our window to the new starting
+ * sequence number. This could happen if the DELBA frame from
+ * originator is lost and then we receive ADDBA frame with new SSN.
+ */
+ if(ba_session_rx->start_sn != start_sn) {
+ scroll_ba_window(priv, interfacePriv, ba_session_rx, start_sn);
+ }
+ return TRUE;
+ }
+ }
+ }
+ }
+
+ /* we could have a valid BA session pointer here or un-initialized
+ ba session pointer. but in any case we have to create a new session.
+ so re-initialize the ba_session pointer */
+ ba_session_rx = NULL;
+
+ /* loop through until an empty BA session slot is there and save the session there */
+ for (ba_session_idx=0; ba_session_idx < MAX_SUPPORTED_BA_SESSIONS_RX ; ba_session_idx++){
+ if (!(interfacePriv->ba_session_rx[ba_session_idx])){
+ break;
+ }
+ }
+ if (ba_session_idx == MAX_SUPPORTED_BA_SESSIONS_RX){
+ unifi_error(priv, "%s: All ba_session used for Rx, NO free session available\n", __FUNCTION__);
+ return FALSE;
+ }
+
+ /* It is observed that with some devices there is a race between
+ * EAPOL exchanges and BA session establishment. This results in
+ * some EAPOL authentication packets getting stuck in BA reorder
+ * buffer and hence the conection cannot be established. To avoid
+ * this we check here if the EAPOL authentication is complete and
+ * if so then only allow the BA session to establish.
+ *
+ * It is verified that the peers normally re-establish
+ * the BA session after the initial rejection.
+ */
+ if (CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_OPEN != uf_sme_port_state(priv, macAddress.a, UF_CONTROLLED_PORT_Q, interfacePriv->InterfaceTag))
+ {
+ unifi_warning(priv, "blockack_session_start: Controlled port not opened, Reject BA request\n");
+ return FALSE;
+ }
+
+ ba_session_rx = kmalloc(sizeof(ba_session_rx_struct), GFP_KERNEL);
+ if (!ba_session_rx) {
+ unifi_error(priv, "%s: kmalloc failed for ba_session_rx\n", __FUNCTION__);
+ return FALSE;
+ }
+ memset(ba_session_rx, 0, sizeof(ba_session_rx_struct));
+
+ ba_session_rx->wind_size = wind_size;
+ ba_session_rx->start_sn = ba_session_rx->expected_sn = start_sn;
+ ba_session_rx->trigger_ba_after_ssn = FALSE;
+
+ ba_session_rx->buffer = kmalloc(ba_session_rx->wind_size*sizeof(frame_desc_struct), GFP_KERNEL);
+ if (!ba_session_rx->buffer) {
+ kfree(ba_session_rx);
+ unifi_error(priv, "%s: kmalloc failed for buffer\n", __FUNCTION__);
+ return FALSE;
+ }
+
+ memset(ba_session_rx->buffer, 0, ba_session_rx->wind_size*sizeof(frame_desc_struct));
+
+ INIT_WORK(&ba_session_rx->send_ba_err_task, uf_send_ba_err_wq);
+ if (timeout) {
+ ba_session_rx->timeout = timeout;
+ ba_session_rx->timer.function = ba_session_terminate_timer_func;
+ ba_session_rx->timer.data = (unsigned long)ba_session_rx;
+ init_timer(&ba_session_rx->timer);
+ mod_timer(&ba_session_rx->timer, (jiffies + usecs_to_jiffies((ba_session_rx->timeout) * 1024)));
+ }
+
+ ba_session_rx->interfacePriv = interfacePriv;
+ ba_session_rx->tID = tID;
+ ba_session_rx->macAddress = macAddress;
+
+ interfacePriv->ba_session_rx[ba_session_idx] = ba_session_rx;
+ }
+ return TRUE;
+}
+
+void CsrWifiRouterCtrlBlockAckEnableReqHandler(void* drvpriv, CsrWifiFsmEvent* msg)
+{
+ CsrWifiRouterCtrlBlockAckEnableReq* req = (CsrWifiRouterCtrlBlockAckEnableReq*)msg;
+ u8 r;
+ unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
+
+ unifi_trace(priv, UDBG6, ">>%s\n", __FUNCTION__);
+ down(&priv->ba_mutex);
+ r = blockack_session_start(priv,
+ req->interfaceTag,
+ req->trafficStreamID,
+ req->timeout,
+ req->role,
+ req->bufferSize,
+ req->ssn,
+ req->macAddress
+ );
+ up(&priv->ba_mutex);
+
+ CsrWifiRouterCtrlBlockAckEnableCfmSend(msg->source,
+ req->clientData,
+ req->interfaceTag,
+ r?CSR_RESULT_SUCCESS:CSR_RESULT_FAILURE);
+ unifi_trace(priv, UDBG6, "<<%s: r=%d\n", __FUNCTION__, r);
+
+}
+
+void CsrWifiRouterCtrlWapiMulticastFilterReqHandler(void* drvpriv, CsrWifiFsmEvent* msg)
+{
+#ifdef CSR_WIFI_SECURITY_WAPI_ENABLE
+
+ unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
+ CsrWifiRouterCtrlWapiMulticastFilterReq* req = (CsrWifiRouterCtrlWapiMulticastFilterReq*)msg;
+ netInterface_priv_t *interfacePriv = priv->interfacePriv[req->interfaceTag];
+
+ if (CSR_WIFI_ROUTER_CTRL_MODE_STA == interfacePriv->interfaceMode) {
+
+ unifi_trace(priv, UDBG6, ">>%s\n", __FUNCTION__);
+
+ unifi_trace(priv, UDBG1, "CsrWifiRouterCtrlWapiMulticastFilterReq: req->status = %d\n", req->status);
+
+ /* status 1 - Filter on
+ * status 0 - Filter off */
+ priv->wapi_multicast_filter = req->status;
+
+ unifi_trace(priv, UDBG6, "<<%s\n", __FUNCTION__);
+ } else {
+
+ unifi_warning(priv, "%s is NOT applicable for interface mode - %d\n", __FUNCTION__,interfacePriv->interfaceMode);
+
+ }
+#elif defined(UNIFI_DEBUG)
+ /*WAPI Disabled*/
+ unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
+ unifi_error(priv,"CsrWifiRouterCtrlWapiMulticastFilterReqHandler: called when WAPI isn't enabled\n");
+#endif
+}
+
+void CsrWifiRouterCtrlWapiUnicastFilterReqHandler(void* drvpriv, CsrWifiFsmEvent* msg)
+{
+#ifdef CSR_WIFI_SECURITY_WAPI_ENABLE
+
+ unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
+ CsrWifiRouterCtrlWapiUnicastFilterReq* req = (CsrWifiRouterCtrlWapiUnicastFilterReq*)msg;
+ netInterface_priv_t *interfacePriv = priv->interfacePriv[req->interfaceTag];
+
+ if (CSR_WIFI_ROUTER_CTRL_MODE_STA == interfacePriv->interfaceMode) {
+
+ unifi_trace(priv, UDBG6, ">>%s\n", __FUNCTION__);
+
+ unifi_trace(priv, UDBG1, "CsrWifiRouterCtrlWapiUnicastFilterReq: req->status= %d\n", req->status);
+
+ if ((priv->wapi_unicast_filter == 1) && (req->status == 0)) {
+ /* When we have successfully re-associated and obtained a new unicast key with keyid = 0 */
+ priv->wapi_unicast_queued_pkt_filter = 1;
+ }
+
+ /* status 1 - Filter ON
+ * status 0 - Filter OFF */
+ priv->wapi_unicast_filter = req->status;
+
+ unifi_trace(priv, UDBG6, "<<%s\n", __FUNCTION__);
+ } else {
+
+ unifi_warning(priv, "%s is NOT applicable for interface mode - %d\n", __FUNCTION__,interfacePriv->interfaceMode);
+
+ }
+#elif defined(UNIFI_DEBUG)
+ /*WAPI Disabled*/
+ unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
+ unifi_error(priv,"CsrWifiRouterCtrlWapiUnicastFilterReqHandler: called when WAPI isn't enabled\n");
+#endif
+}
+
+void CsrWifiRouterCtrlWapiRxPktReqHandler(void* drvpriv, CsrWifiFsmEvent* msg)
+{
+#ifdef CSR_WIFI_SECURITY_WAPI_ENABLE
+
+ unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
+ CsrWifiRouterCtrlWapiRxPktReq* req = (CsrWifiRouterCtrlWapiRxPktReq*)msg;
+ int client_id, receiver_id;
+ bulk_data_param_t bulkdata;
+ CsrResult res;
+ ul_client_t *client;
+ CSR_SIGNAL signal;
+ CSR_MA_PACKET_INDICATION *pkt_ind;
+ netInterface_priv_t *interfacePriv = priv->interfacePriv[req->interfaceTag];
+
+ if (CSR_WIFI_ROUTER_CTRL_MODE_STA == interfacePriv->interfaceMode) {
+
+ unifi_trace(priv, UDBG6, ">>%s\n", __FUNCTION__);
+
+ if (priv == NULL) {
+ unifi_error(priv, "CsrWifiRouterCtrlWapiRxPktReq : invalid priv\n",__FUNCTION__);
+ return;
+ }
+
+ if (priv->smepriv == NULL) {
+ unifi_error(priv, "CsrWifiRouterCtrlWapiRxPktReq : invalid sme priv\n",__FUNCTION__);
+ return;
+ }
+
+ if (req->dataLength == 0 || req->data == NULL) {
+ unifi_error(priv, "CsrWifiRouterCtrlWapiRxPktReq: invalid request\n",__FUNCTION__);
+ return;
+ }
+
+ res = unifi_net_data_malloc(priv, &bulkdata.d[0], req->dataLength);
+ if (res != CSR_RESULT_SUCCESS) {
+ unifi_error(priv, "CsrWifiRouterCtrlWapiRxPktReq: Could not allocate net data\n",__FUNCTION__);
+ return;
+ }
+
+ /* This function is expected to be called only when the MIC has been verified by SME to be correct
+ * So reset the reception status to rx_success */
+ res = read_unpack_signal(req->signal, &signal);
+ if (res) {
+ unifi_error(priv,"CsrWifiRouterCtrlWapiRxPktReqHandler: Received unknown or corrupted signal.\n");
+ return;
+ }
+ pkt_ind = (CSR_MA_PACKET_INDICATION*) (&((&signal)->u).MaPacketIndication);
+ if (pkt_ind->ReceptionStatus != CSR_MICHAEL_MIC_ERROR) {
+ unifi_error(priv,"CsrWifiRouterCtrlWapiRxPktReqHandler: Unknown signal with reception status = %d\n",pkt_ind->ReceptionStatus);
+ return;
+ } else {
+ unifi_trace(priv, UDBG4,"CsrWifiRouterCtrlWapiRxPktReqHandler: MIC verified , RX_SUCCESS \n",__FUNCTION__);
+ pkt_ind->ReceptionStatus = CSR_RX_SUCCESS;
+ write_pack(&signal, req->signal, &(req->signalLength));
+ }
+
+ memcpy((void*)bulkdata.d[0].os_data_ptr, req->data, req->dataLength);
+
+ receiver_id = CSR_GET_UINT16_FROM_LITTLE_ENDIAN((req->signal) + sizeof(s16)) & 0xFFF0;
+ client_id = (receiver_id & 0x0F00) >> UDI_SENDER_ID_SHIFT;
+
+ client = &priv->ul_clients[client_id];
+
+ if (client && client->event_hook) {
+ unifi_trace(priv, UDBG3,
+ "CsrWifiRouterCtrlWapiRxPktReq: "
+ "Sending signal to client %d, (s:0x%X, r:0x%X) - Signal 0x%X \n",
+ client->client_id, client->sender_id, receiver_id,
+ CSR_GET_UINT16_FROM_LITTLE_ENDIAN(req->signal));
+
+ client->event_hook(client, req->signal, req->signalLength, &bulkdata, UDI_TO_HOST);
+ } else {
+ unifi_trace(priv, UDBG4, "No client to give the packet to\n");
+ unifi_net_data_free(priv, &bulkdata.d[0]);
+ }
+
+ unifi_trace(priv, UDBG6, "<<%s\n", __FUNCTION__);
+ } else {
+ unifi_warning(priv, "%s is NOT applicable for interface mode - %d\n", __FUNCTION__,interfacePriv->interfaceMode);
+ }
+#elif defined(UNIFI_DEBUG)
+ /*WAPI Disabled*/
+ unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
+ unifi_error(priv,"CsrWifiRouterCtrlWapiRxPktReqHandler: called when WAPI isn't enabled\n");
+#endif
+}
+
+void CsrWifiRouterCtrlWapiUnicastTxPktReqHandler(void* drvpriv, CsrWifiFsmEvent* msg)
+{
+#if (defined(CSR_WIFI_SECURITY_WAPI_ENABLE) && defined(CSR_WIFI_SECURITY_WAPI_SW_ENCRYPTION))
+
+ unifi_priv_t *priv = (unifi_priv_t*) drvpriv;
+ CsrWifiRouterCtrlWapiUnicastTxPktReq *req = (CsrWifiRouterCtrlWapiUnicastTxPktReq*) msg;
+ netInterface_priv_t *interfacePriv = priv->interfacePriv[req->interfaceTag];
+ bulk_data_param_t bulkdata;
+ u8 macHeaderLengthInBytes = MAC_HEADER_SIZE;
+ /*KeyID, Reserved, PN, MIC*/
+ u8 appendedCryptoFields = 1 + 1 + 16 + 16;
+ CsrResult result;
+ /* Retrieve the MA PACKET REQ fields from the Signal retained from send_ma_pkt_request() */
+ CSR_MA_PACKET_REQUEST *storedSignalMAPktReq = &interfacePriv->wapi_unicast_ma_pkt_sig.u.MaPacketRequest;
+
+ if (CSR_WIFI_ROUTER_CTRL_MODE_STA == interfacePriv->interfaceMode) {
+
+ unifi_trace(priv, UDBG6, ">>%s\n", __FUNCTION__);
+
+ if (priv == NULL) {
+ unifi_error(priv, "CsrWifiRouterCtrlWapiUnicastTxPktReqHandler : invalid priv\n",__FUNCTION__);
+ return;
+ }
+ if (priv->smepriv == NULL) {
+ unifi_error(priv, "CsrWifiRouterCtrlWapiUnicastTxPktReqHandler : invalid sme priv\n",__FUNCTION__);
+ return;
+ }
+ if (req->data == NULL) {
+ unifi_error(priv, "CsrWifiRouterCtrlWapiUnicastTxPktReqHandler: invalid request\n",__FUNCTION__);
+ return;
+ } else {
+ /* If it is QoS data (type = data subtype = QoS), frame header contains QoS control field */
+ if ((req->data[0] & 0x88) == 0x88) {
+ macHeaderLengthInBytes = macHeaderLengthInBytes + QOS_CONTROL_HEADER_SIZE;
+ }
+ }
+ if ( !(req->dataLength>(macHeaderLengthInBytes+appendedCryptoFields)) ) {
+ unifi_error(priv, "CsrWifiRouterCtrlWapiUnicastTxPktReqHandler: invalid dataLength\n",__FUNCTION__);
+ return;
+ }
+
+ /* Encrypted DATA Packet contained in (req->data)
+ * -------------------------------------------------------------------
+ * |MAC Header| KeyId | Reserved | PN | xxDataxx | xxMICxxx |
+ * -------------------------------------------------------------------
+ * (<-----Encrypted----->)
+ * -------------------------------------------------------------------
+ * |24/26(QoS)| 1 | 1 | 16 | x | 16 |
+ * -------------------------------------------------------------------
+ */
+ result = unifi_net_data_malloc(priv, &bulkdata.d[0], req->dataLength);
+ if (result != CSR_RESULT_SUCCESS) {
+ unifi_error(priv, "CsrWifiRouterCtrlWapiUnicastTxPktReqHandler: Could not allocate net data\n",__FUNCTION__);
+ return;
+ }
+ memcpy((void*)bulkdata.d[0].os_data_ptr, req->data, req->dataLength);
+ bulkdata.d[0].data_length = req->dataLength;
+ bulkdata.d[1].os_data_ptr = NULL;
+ bulkdata.d[1].data_length = 0;
+
+ /* Send UniFi msg */
+ /* Here hostTag is been sent as 0xffffffff, its been appended properly while framing MA-Packet request in pdu_processing.c file */
+ result = uf_process_ma_packet_req(priv,
+ storedSignalMAPktReq->Ra.x,
+ storedSignalMAPktReq->HostTag,/* Ask for a new HostTag */
+ req->interfaceTag,
+ storedSignalMAPktReq->TransmissionControl,
+ storedSignalMAPktReq->TransmitRate,
+ storedSignalMAPktReq->Priority, /* Retained value */
+ interfacePriv->wapi_unicast_ma_pkt_sig.SignalPrimitiveHeader.SenderProcessId, /*FIXME AP: VALIDATE ???*/
+ &bulkdata);
+
+ if (result == NETDEV_TX_OK) {
+ (priv->netdev[req->interfaceTag])->trans_start = jiffies;
+ /* Should really count tx stats in the UNITDATA.status signal but
+ * that doesn't have the length.
+ */
+ interfacePriv->stats.tx_packets++;
+
+ /* count only the packet payload */
+ interfacePriv->stats.tx_bytes += req->dataLength - macHeaderLengthInBytes - appendedCryptoFields;
+ unifi_trace(priv, UDBG1, "CsrWifiRouterCtrlWapiUnicastTxPktReqHandler: (Packet Sent), sent count = %x\n", interfacePriv->stats.tx_packets);
+ } else {
+ /* Failed to send: fh queue was full, and the skb was discarded*/
+ unifi_trace(priv, UDBG1, "(HIP validation failure) Result = %d\n", result);
+ unifi_net_data_free(priv, &bulkdata.d[0]);
+
+ interfacePriv->stats.tx_dropped++;
+ unifi_trace(priv, UDBG1, "CsrWifiRouterCtrlWapiUnicastTxPktReqHandler: (Packet Drop), dropped count = %x\n", interfacePriv->stats.tx_dropped);
+ }
+
+ unifi_trace(priv, UDBG6, "<<%s\n", __FUNCTION__);
+
+ } else {
+
+ unifi_warning(priv, "%s is NOT applicable for interface mode - %d\n", __FUNCTION__,interfacePriv->interfaceMode);
+
+ }
+#elif defined(UNIFI_DEBUG)
+ /*WAPI Disabled*/
+ unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
+ unifi_error(priv,"CsrWifiRouterCtrlWapiUnicastTxPktReqHandler: called when WAPI SW ENCRYPTION isn't enabled\n");
+#endif
+}
+
+void CsrWifiRouterCtrlWapiFilterReqHandler(void* drvpriv, CsrWifiFsmEvent* msg)
+{
+#ifdef CSR_WIFI_SECURITY_WAPI_ENABLE
+
+#ifdef CSR_WIFI_SECURITY_WAPI_QOSCTRL_MIC_WORKAROUND
+ unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
+ CsrWifiRouterCtrlWapiFilterReq* req = (CsrWifiRouterCtrlWapiFilterReq*)msg;
+ netInterface_priv_t *interfacePriv = priv->interfacePriv[req->interfaceTag];
+
+ if (CSR_WIFI_ROUTER_CTRL_MODE_STA == interfacePriv->interfaceMode) {
+
+ unifi_trace(priv, UDBG6, ">>%s\n", __FUNCTION__);
+
+ unifi_trace(priv, UDBG1, "CsrWifiRouterCtrlWapiFilterReq: req->isWapiConnected [0/1] = %d \n",req->isWapiConnected);
+
+ priv->isWapiConnection = req->isWapiConnected;
+
+ unifi_trace(priv, UDBG6, "<<%s\n", __FUNCTION__);
+ } else {
+
+ unifi_warning(priv, "%s is NOT applicable for interface mode - %d\n", __FUNCTION__,interfacePriv->interfaceMode);
+
+ }
+#endif
+
+#elif defined(UNIFI_DEBUG)
+ /*WAPI Disabled*/
+ unifi_priv_t *priv = (unifi_priv_t*)drvpriv;
+ unifi_error(priv,"CsrWifiRouterCtrlWapiFilterReq: called when WAPI isn't enabled\n");
+#endif
+}
diff --git a/drivers/staging/csr/sme_userspace.c b/drivers/staging/csr/sme_userspace.c
new file mode 100644
index 000000000000..abcb446fb8c0
--- /dev/null
+++ b/drivers/staging/csr/sme_userspace.c
@@ -0,0 +1,315 @@
+/*
+ *****************************************************************************
+ *
+ * FILE : sme_userspace.c
+ *
+ * PURPOSE : Support functions for userspace SME helper application.
+ *
+ *
+ * Copyright (C) 2008-2011 by Cambridge Silicon Radio Ltd.
+ *
+ * Refer to LICENSE.txt included with this source code for details on
+ * the license terms.
+ *
+ *****************************************************************************
+ */
+
+#include "unifi_priv.h"
+
+/*
+ * Fix Me..... These need to be the correct values...
+ * Dynamic from the user space.
+ */
+CsrSchedQid CSR_WIFI_ROUTER_IFACEQUEUE = 0xFFFF;
+CsrSchedQid CSR_WIFI_SME_IFACEQUEUE = 0xFFFF;
+#ifdef CSR_SUPPORT_WEXT_AP
+CsrSchedQid CSR_WIFI_NME_IFACEQUEUE = 0xFFFF;
+#endif
+int
+uf_sme_init(unifi_priv_t *priv)
+{
+ int i, j;
+
+ CsrWifiRouterTransportInit(priv);
+
+ priv->smepriv = priv;
+
+ init_waitqueue_head(&priv->sme_request_wq);
+
+ priv->filter_tclas_ies = NULL;
+ memset(&priv->packet_filters, 0, sizeof(uf_cfg_bcast_packet_filter_t));
+
+#ifdef CSR_SUPPORT_WEXT
+ priv->ignore_bssid_join = FALSE;
+ priv->mib_data.length = 0;
+
+ uf_sme_wext_set_defaults(priv);
+#endif /* CSR_SUPPORT_WEXT*/
+
+ priv->sta_ip_address = 0xFFFFFFFF;
+
+ priv->wifi_on_state = wifi_on_unspecified;
+
+ sema_init(&priv->sme_sem, 1);
+ memset(&priv->sme_reply, 0, sizeof(sme_reply_t));
+
+ priv->ta_ind_work.in_use = 0;
+ priv->ta_sample_ind_work.in_use = 0;
+
+ priv->CSR_WIFI_SME_IFACEQUEUE = 0xFFFF;
+
+ for (i = 0; i < MAX_MA_UNIDATA_IND_FILTERS; i++) {
+ priv->sme_unidata_ind_filters[i].in_use = 0;
+ }
+
+ /* Create a work queue item for Traffic Analysis indications to SME */
+ INIT_WORK(&priv->ta_ind_work.task, uf_ta_ind_wq);
+ INIT_WORK(&priv->ta_sample_ind_work.task, uf_ta_sample_ind_wq);
+#ifdef CSR_SUPPORT_WEXT
+ INIT_WORK(&priv->sme_config_task, uf_sme_config_wq);
+#endif
+
+ for (i = 0; i < CSR_WIFI_NUM_INTERFACES; i++) {
+ netInterface_priv_t *interfacePriv = priv->interfacePriv[i];
+ interfacePriv->m4_sent = FALSE;
+ interfacePriv->m4_bulk_data.net_buf_length = 0;
+ interfacePriv->m4_bulk_data.data_length = 0;
+ interfacePriv->m4_bulk_data.os_data_ptr = interfacePriv->m4_bulk_data.os_net_buf_ptr = NULL;
+
+ memset(&interfacePriv->controlled_data_port, 0, sizeof(unifi_port_config_t));
+ interfacePriv->controlled_data_port.entries_in_use = 1;
+ interfacePriv->controlled_data_port.port_cfg[0].in_use = TRUE;
+ interfacePriv->controlled_data_port.port_cfg[0].port_action = CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_CLOSED_DISCARD;
+ interfacePriv->controlled_data_port.overide_action = UF_DATA_PORT_OVERIDE;
+
+ memset(&interfacePriv->uncontrolled_data_port, 0, sizeof(unifi_port_config_t));
+ interfacePriv->uncontrolled_data_port.entries_in_use = 1;
+ interfacePriv->uncontrolled_data_port.port_cfg[0].in_use = TRUE;
+ interfacePriv->uncontrolled_data_port.port_cfg[0].port_action = CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_CLOSED_DISCARD;
+ interfacePriv->uncontrolled_data_port.overide_action = UF_DATA_PORT_OVERIDE;
+
+ /* Mark the remainder of the port config table as unallocated */
+ for(j = 1; j < UNIFI_MAX_CONNECTIONS; j++) {
+ interfacePriv->controlled_data_port.port_cfg[j].in_use = FALSE;
+ interfacePriv->controlled_data_port.port_cfg[j].port_action = CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_CLOSED_DISCARD;
+
+ interfacePriv->uncontrolled_data_port.port_cfg[j].in_use = FALSE;
+ interfacePriv->uncontrolled_data_port.port_cfg[j].port_action = CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_CLOSED_DISCARD;
+ }
+
+ /* intializing the lists */
+ INIT_LIST_HEAD(&interfacePriv->genericMgtFrames);
+ INIT_LIST_HEAD(&interfacePriv->genericMulticastOrBroadCastMgtFrames);
+ INIT_LIST_HEAD(&interfacePriv->genericMulticastOrBroadCastFrames);
+
+ for(j = 0; j < UNIFI_MAX_CONNECTIONS; j++) {
+ interfacePriv->staInfo[j] = NULL;
+ }
+
+ interfacePriv->num_stations_joined = 0;
+ interfacePriv->sta_activity_check_enabled = FALSE;
+ }
+
+
+ return 0;
+} /* uf_sme_init() */
+
+
+void
+uf_sme_deinit(unifi_priv_t *priv)
+{
+ int i,j;
+ u8 ba_session_idx;
+ ba_session_rx_struct *ba_session_rx = NULL;
+ ba_session_tx_struct *ba_session_tx = NULL;
+ CsrWifiRouterCtrlStaInfo_t *staInfo = NULL;
+ netInterface_priv_t *interfacePriv = NULL;
+
+ /* Free any TCLASs previously allocated */
+ if (priv->packet_filters.tclas_ies_length) {
+ priv->packet_filters.tclas_ies_length = 0;
+ kfree(priv->filter_tclas_ies);
+ priv->filter_tclas_ies = NULL;
+ }
+
+ for (i = 0; i < MAX_MA_UNIDATA_IND_FILTERS; i++) {
+ priv->sme_unidata_ind_filters[i].in_use = 0;
+ }
+
+ /* Remove all the Peer database, before going down */
+ for (i = 0; i < CSR_WIFI_NUM_INTERFACES; i++) {
+ down(&priv->ba_mutex);
+ for(ba_session_idx=0; ba_session_idx < MAX_SUPPORTED_BA_SESSIONS_RX; ba_session_idx++){
+ ba_session_rx = priv->interfacePriv[i]->ba_session_rx[ba_session_idx];
+ if(ba_session_rx) {
+ blockack_session_stop(priv,
+ i,
+ CSR_WIFI_ROUTER_CTRL_BLOCK_ACK_RECIPIENT,
+ ba_session_rx->tID,
+ ba_session_rx->macAddress);
+ }
+ }
+ for(ba_session_idx=0; ba_session_idx < MAX_SUPPORTED_BA_SESSIONS_TX; ba_session_idx++){
+ ba_session_tx = priv->interfacePriv[i]->ba_session_tx[ba_session_idx];
+ if(ba_session_tx) {
+ blockack_session_stop(priv,
+ i,
+ CSR_WIFI_ROUTER_CTRL_BLOCK_ACK_ORIGINATOR,
+ ba_session_tx->tID,
+ ba_session_tx->macAddress);
+ }
+ }
+
+ up(&priv->ba_mutex);
+ interfacePriv = priv->interfacePriv[i];
+ if(interfacePriv){
+ for(j = 0; j < UNIFI_MAX_CONNECTIONS; j++) {
+ if ((staInfo=interfacePriv->staInfo[j]) != NULL) {
+ /* Clear the STA activity parameters before freeing station Record */
+ unifi_trace(priv, UDBG1, "uf_sme_deinit: Canceling work queue for STA with AID: %d\n", staInfo->aid);
+ cancel_work_sync(&staInfo->send_disconnected_ind_task);
+ staInfo->nullDataHostTag = INVALID_HOST_TAG;
+ }
+ }
+ if (interfacePriv->sta_activity_check_enabled){
+ interfacePriv->sta_activity_check_enabled = FALSE;
+ del_timer_sync(&interfacePriv->sta_activity_check_timer);
+ }
+ }
+ CsrWifiRouterCtrlInterfaceReset(priv, i);
+ priv->interfacePriv[i]->interfaceMode = CSR_WIFI_ROUTER_CTRL_MODE_NONE;
+ }
+
+
+} /* uf_sme_deinit() */
+
+
+
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * unifi_ta_indicate_protocol
+ *
+ * Report that a packet of a particular type has been seen
+ *
+ * Arguments:
+ * drv_priv The device context pointer passed to ta_init.
+ * protocol The protocol type enum value.
+ * direction Whether the packet was a tx or rx.
+ * src_addr The source MAC address from the data packet.
+ *
+ * Returns:
+ * None.
+ *
+ * Notes:
+ * We defer the actual sending to a background workqueue,
+ * see uf_ta_ind_wq().
+ * ---------------------------------------------------------------------------
+ */
+void
+unifi_ta_indicate_protocol(void *ospriv,
+ CsrWifiRouterCtrlTrafficPacketType packet_type,
+ CsrWifiRouterCtrlProtocolDirection direction,
+ const CsrWifiMacAddress *src_addr)
+{
+ unifi_priv_t *priv = (unifi_priv_t*)ospriv;
+
+ if (priv->ta_ind_work.in_use) {
+ unifi_warning(priv,
+ "unifi_ta_indicate_protocol: workqueue item still in use, not sending\n");
+ return;
+ }
+
+ if (CSR_WIFI_ROUTER_CTRL_PROTOCOL_DIRECTION_RX == direction)
+ {
+ u16 interfaceTag = 0;
+ CsrWifiRouterCtrlTrafficProtocolIndSend(priv->CSR_WIFI_SME_IFACEQUEUE,0,
+ interfaceTag,
+ packet_type,
+ direction,
+ *src_addr);
+ }
+ else
+ {
+ priv->ta_ind_work.packet_type = packet_type;
+ priv->ta_ind_work.direction = direction;
+ priv->ta_ind_work.src_addr = *src_addr;
+
+ queue_work(priv->unifi_workqueue, &priv->ta_ind_work.task);
+ }
+
+} /* unifi_ta_indicate_protocol() */
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * unifi_ta_indicate_sampling
+ *
+ * Send the TA sampling information to the SME.
+ *
+ * Arguments:
+ * drv_priv The device context pointer passed to ta_init.
+ * stats The TA sampling data to send.
+ *
+ * Returns:
+ * None.
+ * ---------------------------------------------------------------------------
+ */
+void
+unifi_ta_indicate_sampling(void *ospriv, CsrWifiRouterCtrlTrafficStats *stats)
+{
+ unifi_priv_t *priv = (unifi_priv_t*)ospriv;
+
+ if (!priv) {
+ return;
+ }
+
+ if (priv->ta_sample_ind_work.in_use) {
+ unifi_warning(priv,
+ "unifi_ta_indicate_sampling: workqueue item still in use, not sending\n");
+ return;
+ }
+
+ priv->ta_sample_ind_work.stats = *stats;
+
+ queue_work(priv->unifi_workqueue, &priv->ta_sample_ind_work.task);
+
+} /* unifi_ta_indicate_sampling() */
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * unifi_ta_indicate_l4stats
+ *
+ * Send the TA TCP/UDP throughput information to the driver.
+ *
+ * Arguments:
+ * drv_priv The device context pointer passed to ta_init.
+ * rxTcpThroughput TCP RX throughput in KiloBytes
+ * txTcpThroughput TCP TX throughput in KiloBytes
+ * rxUdpThroughput UDP RX throughput in KiloBytes
+ * txUdpThroughput UDP TX throughput in KiloBytes
+ *
+ * Returns:
+ * None.
+ * ---------------------------------------------------------------------------
+ */
+void
+unifi_ta_indicate_l4stats(void *ospriv,
+ u32 rxTcpThroughput,
+ u32 txTcpThroughput,
+ u32 rxUdpThroughput,
+ u32 txUdpThroughput)
+{
+ unifi_priv_t *priv = (unifi_priv_t*)ospriv;
+
+ if (!priv) {
+ return;
+ }
+ /* Save the info. The actual action will be taken in unifi_ta_indicate_sampling() */
+ priv->rxTcpThroughput = rxTcpThroughput;
+ priv->txTcpThroughput = txTcpThroughput;
+ priv->rxUdpThroughput = rxUdpThroughput;
+ priv->txUdpThroughput = txUdpThroughput;
+} /* unifi_ta_indicate_l4stats() */
diff --git a/drivers/staging/csr/sme_userspace.h b/drivers/staging/csr/sme_userspace.h
new file mode 100644
index 000000000000..7816b15b4b5d
--- /dev/null
+++ b/drivers/staging/csr/sme_userspace.h
@@ -0,0 +1,38 @@
+/*
+ * ***************************************************************************
+ * FILE: sme_userspace.h
+ *
+ * PURPOSE: SME related definitions.
+ *
+ * Copyright (C) 2007-2008 by Cambridge Silicon Radio Ltd.
+ *
+ * Refer to LICENSE.txt included with this source code for details on
+ * the license terms.
+ *
+ * ***************************************************************************
+ */
+#ifndef __LINUX_SME_USERSPACE_H__
+#define __LINUX_SME_USERSPACE_H__ 1
+
+#include <linux/kernel.h>
+
+int uf_sme_init(unifi_priv_t *priv);
+void uf_sme_deinit(unifi_priv_t *priv);
+int uf_sme_queue_message(unifi_priv_t *priv, u8 *buffer, int length);
+
+
+#include "csr_wifi_router_lib.h"
+#include "csr_wifi_router_sef.h"
+#include "csr_wifi_router_ctrl_lib.h"
+#include "csr_wifi_router_ctrl_sef.h"
+#include "csr_wifi_sme_task.h"
+#ifdef CSR_SUPPORT_WEXT_AP
+#include "csr_wifi_nme_ap_lib.h"
+#endif
+#include "csr_wifi_sme_lib.h"
+
+void CsrWifiRouterTransportInit(unifi_priv_t *priv);
+void CsrWifiRouterTransportRecv(unifi_priv_t *priv, u8* buffer, size_t bufferLength);
+void CsrWifiRouterTransportDeInit(unifi_priv_t *priv);
+
+#endif /* __LINUX_SME_USERSPACE_H__ */
diff --git a/drivers/staging/csr/sme_wext.c b/drivers/staging/csr/sme_wext.c
new file mode 100644
index 000000000000..7e85907e29a3
--- /dev/null
+++ b/drivers/staging/csr/sme_wext.c
@@ -0,0 +1,3381 @@
+/*
+ * ---------------------------------------------------------------------------
+ * FILE: sme_wext.c
+ *
+ * PURPOSE:
+ * Handlers for ioctls from iwconfig.
+ * These provide the control plane operations.
+ *
+ * Copyright (C) 2007-2009 by Cambridge Silicon Radio Ltd.
+ *
+ * Refer to LICENSE.txt included with this source code for details on
+ * the license terms.
+ *
+ * ---------------------------------------------------------------------------
+ */
+#include <linux/types.h>
+#include <linux/etherdevice.h>
+#include <linux/if_arp.h>
+#include <asm/uaccess.h>
+#include <linux/ctype.h>
+#include "unifi_priv.h"
+#include <linux/rtnetlink.h>
+
+#define CHECK_INITED(_priv) \
+ do { \
+ if (_priv->init_progress != UNIFI_INIT_COMPLETED) { \
+ unifi_trace(_priv, UDBG2, "%s unifi not ready, failing wext call\n", __FUNCTION__); \
+ return -ENODEV; \
+ } \
+ } while (0)
+
+/* Workaround for the wpa_supplicant hanging issue - disabled on Android */
+#ifndef ANDROID_BUILD
+#define CSR_WIFI_WEXT_HANG_WORKAROUND
+#endif
+
+#ifdef CSR_WIFI_WEXT_HANG_WORKAROUND
+# define UF_RTNL_LOCK() rtnl_lock()
+# define UF_RTNL_UNLOCK() rtnl_unlock()
+#else
+# define UF_RTNL_LOCK()
+# define UF_RTNL_UNLOCK()
+#endif
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * Helper functions
+ * ---------------------------------------------------------------------------
+ */
+
+/*
+ * ---------------------------------------------------------------------------
+ * wext_freq_to_channel
+ * channel_to_mhz
+ *
+ * These functions convert between channel number and frequency.
+ *
+ * Arguments:
+ * ch Channel number, as defined in 802.11 specs
+ * m, e Mantissa and exponent as provided by wireless extension.
+ *
+ * Returns:
+ * channel or frequency (in MHz) value
+ * ---------------------------------------------------------------------------
+ */
+static int
+wext_freq_to_channel(int m, int e)
+{
+ int mhz;
+
+ mhz = m;
+ while (e < 6) {
+ mhz /= 10;
+ e++;
+ }
+ while (e > 6) {
+ mhz *= 10;
+ e--;
+ }
+
+ if (mhz >= 5000) {
+ return ((mhz - 5000) / 5);
+ }
+
+ if (mhz == 2482) {
+ return 14;
+ }
+
+ if (mhz >= 2407) {
+ return ((mhz - 2407) / 5);
+ }
+
+ return 0;
+} /* wext_freq_to_channel() */
+
+static int
+channel_to_mhz(int ch, int dot11a)
+{
+
+ if (ch == 0) return 0;
+ if (ch > 200) return 0;
+
+ /* 5G */
+ if (dot11a) {
+ return (5000 + (5 * ch));
+ }
+
+ /* 2.4G */
+ if (ch == 14) {
+ return 2484;
+ }
+
+ if ((ch < 14) && (ch > 0)) {
+ return (2407 + (5 * ch));
+ }
+
+ return 0;
+}
+#ifdef CSR_SUPPORT_WEXT_AP
+void uf_sme_wext_ap_set_defaults(unifi_priv_t *priv)
+{
+ memcpy(priv->ap_config.ssid.ssid,"defaultssid",sizeof("defaultssid"));
+
+ priv->ap_config.ssid.length = 8;
+ priv->ap_config.channel = 6;
+ priv->ap_config.if_index = 1;
+ priv->ap_config.credentials.authType = 0;
+ priv->ap_config.max_connections=8;
+
+ priv->group_sec_config.apGroupkeyTimeout = 0;
+ priv->group_sec_config.apStrictGtkRekey = 0;
+ priv->group_sec_config.apGmkTimeout = 0;
+ priv->group_sec_config.apResponseTimeout = 100; /* Default*/
+ priv->group_sec_config.apRetransLimit = 3; /* Default*/
+ /* Set default params even if they may not be used*/
+ /* Until Here*/
+
+ priv->ap_mac_config.preamble = CSR_WIFI_SME_USE_LONG_PREAMBLE;
+ priv->ap_mac_config.shortSlotTimeEnabled = FALSE;
+ priv->ap_mac_config.ctsProtectionType=CSR_WIFI_SME_CTS_PROTECTION_AUTOMATIC;
+
+ priv->ap_mac_config.wmmEnabled = TRUE;
+ priv->ap_mac_config.wmmApParams[0].cwMin=4;
+ priv->ap_mac_config.wmmApParams[0].cwMax=10;
+ priv->ap_mac_config.wmmApParams[0].aifs=3;
+ priv->ap_mac_config.wmmApParams[0].txopLimit=0;
+ priv->ap_mac_config.wmmApParams[0].admissionControlMandatory=FALSE;
+ priv->ap_mac_config.wmmApParams[1].cwMin=4;
+ priv->ap_mac_config.wmmApParams[1].cwMax=10;
+ priv->ap_mac_config.wmmApParams[1].aifs=7;
+ priv->ap_mac_config.wmmApParams[1].txopLimit=0;
+ priv->ap_mac_config.wmmApParams[1].admissionControlMandatory=FALSE;
+ priv->ap_mac_config.wmmApParams[2].cwMin=3;
+ priv->ap_mac_config.wmmApParams[2].cwMax=4;
+ priv->ap_mac_config.wmmApParams[2].aifs=1;
+ priv->ap_mac_config.wmmApParams[2].txopLimit=94;
+ priv->ap_mac_config.wmmApParams[2].admissionControlMandatory=FALSE;
+ priv->ap_mac_config.wmmApParams[3].cwMin=2;
+ priv->ap_mac_config.wmmApParams[3].cwMax=3;
+ priv->ap_mac_config.wmmApParams[3].aifs=1;
+ priv->ap_mac_config.wmmApParams[3].txopLimit=47;
+ priv->ap_mac_config.wmmApParams[3].admissionControlMandatory=FALSE;
+
+ priv->ap_mac_config.wmmApBcParams[0].cwMin=4;
+ priv->ap_mac_config.wmmApBcParams[0].cwMax=10;
+ priv->ap_mac_config.wmmApBcParams[0].aifs=3;
+ priv->ap_mac_config.wmmApBcParams[0].txopLimit=0;
+ priv->ap_mac_config.wmmApBcParams[0].admissionControlMandatory=FALSE;
+ priv->ap_mac_config.wmmApBcParams[1].cwMin=4;
+ priv->ap_mac_config.wmmApBcParams[1].cwMax=10;
+ priv->ap_mac_config.wmmApBcParams[1].aifs=7;
+ priv->ap_mac_config.wmmApBcParams[1].txopLimit=0;
+ priv->ap_mac_config.wmmApBcParams[1].admissionControlMandatory=FALSE;
+ priv->ap_mac_config.wmmApBcParams[2].cwMin=3;
+ priv->ap_mac_config.wmmApBcParams[2].cwMax=4;
+ priv->ap_mac_config.wmmApBcParams[2].aifs=2;
+ priv->ap_mac_config.wmmApBcParams[2].txopLimit=94;
+ priv->ap_mac_config.wmmApBcParams[2].admissionControlMandatory=FALSE;
+ priv->ap_mac_config.wmmApBcParams[3].cwMin=2;
+ priv->ap_mac_config.wmmApBcParams[3].cwMax=3;
+ priv->ap_mac_config.wmmApBcParams[3].aifs=2;
+ priv->ap_mac_config.wmmApBcParams[3].txopLimit=47;
+ priv->ap_mac_config.wmmApBcParams[3].admissionControlMandatory=FALSE;
+
+ priv->ap_mac_config.accessType=CSR_WIFI_AP_ACCESS_TYPE_NONE;
+ priv->ap_mac_config.macAddressListCount=0;
+ priv->ap_mac_config.macAddressList=NULL;
+
+ priv->ap_mac_config.apHtParams.rxStbc=1;
+ priv->ap_mac_config.apHtParams.rifsModeAllowed=TRUE;
+ priv->ap_mac_config.apHtParams.greenfieldSupported=FALSE;
+ priv->ap_mac_config.apHtParams.shortGi20MHz=TRUE;
+ priv->ap_mac_config.apHtParams.htProtection=0;
+ priv->ap_mac_config.apHtParams.dualCtsProtection=FALSE;
+
+ priv->ap_mac_config.phySupportedBitmap =
+ (CSR_WIFI_SME_AP_PHY_SUPPORT_B|CSR_WIFI_SME_AP_PHY_SUPPORT_G|CSR_WIFI_SME_AP_PHY_SUPPORT_N);
+ priv->ap_mac_config.beaconInterval= 100;
+ priv->ap_mac_config.dtimPeriod=3;
+ priv->ap_mac_config.maxListenInterval=0x00ff;/* Set it to a large value
+ to enable different types of
+ devices to join us */
+ priv->ap_mac_config.supportedRatesCount =
+ uf_configure_supported_rates(priv->ap_mac_config.supportedRates,priv->ap_mac_config.phySupportedBitmap);
+}
+#endif
+/*
+ * ---------------------------------------------------------------------------
+ * uf_sme_wext_set_defaults
+ *
+ * Set up power-on defaults for driver config.
+ *
+ * Note: The SME Management API *cannot* be used in this function.
+ *
+ * Arguments:
+ * priv Pointer to device private context struct
+ *
+ * Returns:
+ * None.
+ * ---------------------------------------------------------------------------
+ */
+void
+uf_sme_wext_set_defaults(unifi_priv_t *priv)
+{
+ memset(&priv->connection_config, 0, sizeof(CsrWifiSmeConnectionConfig));
+
+ priv->connection_config.bssType = CSR_WIFI_SME_BSS_TYPE_INFRASTRUCTURE;
+ priv->connection_config.authModeMask = CSR_WIFI_SME_AUTH_MODE_80211_OPEN;
+ priv->connection_config.encryptionModeMask = CSR_WIFI_SME_ENCRYPTION_CIPHER_NONE;
+ priv->connection_config.privacyMode = CSR_WIFI_SME_80211_PRIVACY_MODE_DISABLED;
+ priv->connection_config.wmmQosInfo = 0xFF;
+ priv->connection_config.ifIndex = CSR_WIFI_SME_RADIO_IF_BOTH;
+ priv->connection_config.adhocJoinOnly = FALSE;
+ priv->connection_config.adhocChannel = 6;
+
+ priv->wep_tx_key_index = 0;
+
+ priv->wext_wireless_stats.qual.qual = 0;
+ priv->wext_wireless_stats.qual.level = 0;
+ priv->wext_wireless_stats.qual.noise = 0;
+ priv->wext_wireless_stats.qual.updated = 0x70;
+#ifdef CSR_SUPPORT_WEXT_AP
+ /* Initialize the default configuration for AP */
+ uf_sme_wext_ap_set_defaults(priv);
+#endif
+
+
+} /* uf_sme_wext_set_defaults() */
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * WEXT methods
+ * ---------------------------------------------------------------------------
+ */
+
+/*
+ * ---------------------------------------------------------------------------
+ * unifi_giwname - handler for SIOCGIWNAME
+ * unifi_siwfreq - handler for SIOCSIWFREQ
+ * unifi_giwfreq - handler for SIOCGIWFREQ
+ * unifi_siwmode - handler for SIOCSIWMODE
+ * unifi_giwmode - handler for SIOCGIWMODE
+ * unifi_giwrange - handler for SIOCGIWRANGE
+ * unifi_siwap - handler for SIOCSIWAP
+ * unifi_giwap - handler for SIOCGIWAP
+ * unifi_siwscan - handler for SIOCSIWSCAN
+ * unifi_giwscan - handler for SIOCGIWSCAN
+ * unifi_siwessid - handler for SIOCSIWESSID
+ * unifi_giwessid - handler for SIOCGIWESSID
+ * unifi_siwencode - handler for SIOCSIWENCODE
+ * unifi_giwencode - handler for SIOCGIWENCODE
+ *
+ * Handler functions for IW extensions.
+ * These are registered via the unifi_iw_handler_def struct below
+ * and called by the generic IW driver support code.
+ * See include/net/iw_handler.h.
+ *
+ * Arguments:
+ * None.
+ *
+ * Returns:
+ * None.
+ * ---------------------------------------------------------------------------
+ */
+static int
+iwprivsdefs(struct net_device *dev, struct iw_request_info *info,
+ union iwreq_data *wrqu, char *extra)
+{
+ int r;
+ netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev);
+ unifi_priv_t *priv = interfacePriv->privPtr;
+ CsrWifiSmeMibConfig mibConfig;
+ CsrWifiSmePowerConfig powerConfig;
+
+ unifi_trace(priv, UDBG1, "iwprivs80211defaults: reload defaults\n");
+
+ uf_sme_wext_set_defaults(priv);
+
+ /* Get, modify and set the MIB data */
+ r = sme_mgt_mib_config_get(priv, &mibConfig);
+ if (r) {
+ unifi_error(priv, "iwprivs80211defaults: Get CsrWifiSmeMibConfigValue failed.\n");
+ return r;
+ }
+ mibConfig.dot11RtsThreshold = 2347;
+ mibConfig.dot11FragmentationThreshold = 2346;
+ r = sme_mgt_mib_config_set(priv, &mibConfig);
+ if (r) {
+ unifi_error(priv, "iwprivs80211defaults: Set CsrWifiSmeMibConfigValue failed.\n");
+ return r;
+ }
+
+ powerConfig.powerSaveLevel = CSR_WIFI_SME_POWER_SAVE_LEVEL_LOW;
+ powerConfig.listenIntervalTu = 100;
+ powerConfig.rxDtims = 1;
+
+ r = sme_mgt_power_config_set(priv, &powerConfig);
+ if (r) {
+ unifi_error(priv, "iwprivs80211defaults: Set unifi_PowerConfigValue failed.\n");
+ return r;
+ }
+
+ return 0;
+} /* iwprivsdefs() */
+
+static int
+iwprivs80211ps(struct net_device *dev, struct iw_request_info *info,
+ union iwreq_data *wrqu, char *extra)
+{
+ int r = 0;
+ netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev);
+ unifi_priv_t *priv = interfacePriv->privPtr;
+
+ int ps_mode = (int)(*extra);
+ CsrWifiSmePowerConfig powerConfig;
+
+ unifi_trace(priv, UDBG1, "iwprivs80211ps: power save mode = %d\n", ps_mode);
+
+ r = sme_mgt_power_config_get(priv, &powerConfig);
+ if (r) {
+ unifi_error(priv, "iwprivs80211ps: Get unifi_PowerConfigValue failed.\n");
+ return r;
+ }
+
+ switch (ps_mode) {
+ case CSR_PMM_ACTIVE_MODE:
+ powerConfig.powerSaveLevel = CSR_WIFI_SME_POWER_SAVE_LEVEL_LOW;
+ break;
+ case CSR_PMM_POWER_SAVE:
+ powerConfig.powerSaveLevel = CSR_WIFI_SME_POWER_SAVE_LEVEL_HIGH;
+ break;
+ case CSR_PMM_FAST_POWER_SAVE:
+ powerConfig.powerSaveLevel = CSR_WIFI_SME_POWER_SAVE_LEVEL_MED;
+ break;
+ default:
+ powerConfig.powerSaveLevel = CSR_WIFI_SME_POWER_SAVE_LEVEL_AUTO;
+ break;
+ }
+
+ r = sme_mgt_power_config_set(priv, &powerConfig);
+ if (r) {
+ unifi_error(priv, "iwprivs80211ps: Set unifi_PowerConfigValue failed.\n");
+ }
+
+ return r;
+}
+
+static int
+iwprivg80211ps(struct net_device *dev, struct iw_request_info *info,
+ union iwreq_data *wrqu, char *extra)
+{
+ netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev);
+ unifi_priv_t *priv = interfacePriv->privPtr;
+
+ CsrWifiSmePowerConfig powerConfig;
+ int r;
+
+ r = sme_mgt_power_config_get(priv, &powerConfig);
+ if (r) {
+ unifi_error(priv, "iwprivg80211ps: Get 802.11 power mode failed.\n");
+ return r;
+ }
+
+ switch (powerConfig.powerSaveLevel) {
+ case CSR_WIFI_SME_POWER_SAVE_LEVEL_LOW:
+ snprintf(extra, IWPRIV_POWER_SAVE_MAX_STRING,
+ "Power save mode: %d (Active)",
+ powerConfig.powerSaveLevel);
+ break;
+ case CSR_WIFI_SME_POWER_SAVE_LEVEL_MED:
+ snprintf(extra, IWPRIV_POWER_SAVE_MAX_STRING,
+ "Power save mode: %d (Fast)",
+ powerConfig.powerSaveLevel);
+ break;
+ case CSR_WIFI_SME_POWER_SAVE_LEVEL_HIGH:
+ snprintf(extra, IWPRIV_POWER_SAVE_MAX_STRING,
+ "Power save mode: %d (Full)",
+ powerConfig.powerSaveLevel);
+ break;
+ case CSR_WIFI_SME_POWER_SAVE_LEVEL_AUTO:
+ snprintf(extra, IWPRIV_POWER_SAVE_MAX_STRING,
+ "Power save mode: %d (Auto)",
+ powerConfig.powerSaveLevel);
+ break;
+ default:
+ snprintf(extra, IWPRIV_POWER_SAVE_MAX_STRING,
+ "Power save mode: %d (Unknown)",
+ powerConfig.powerSaveLevel);
+ break;
+ }
+
+ wrqu->data.length = strlen(extra) + 1;
+
+ return 0;
+}
+
+static int
+iwprivssmedebug(struct net_device *dev, struct iw_request_info *info,
+ union iwreq_data *wrqu, char *extra)
+{
+ /* No longer supported on the API */
+#if defined (CSR_WIFI_HIP_DEBUG_OFFLINE)
+ unifi_debug_buf_dump();
+#endif
+
+ return 0;
+}
+
+#ifdef CSR_SUPPORT_WEXT_AP
+#define PARAM_TYPE_INT 0
+#define PARAM_TYPE_STRING 1
+#define CSR_WIFI_MAX_SSID_LEN 32
+#define CSR_WIFI_MAX_SEC_LEN 16
+#define CSR_WIFI_MAX_KEY_LEN 65
+
+static int hex_look_up(char x)
+{
+ if(x>='0' && x<='9')
+ return (x-48);
+ if(x>= 'a' && x <= 'f')
+ return (x-87);
+ return -1;
+}
+
+static int power (int a, int b)
+{
+ int i;
+ int num =1;
+ for(i=0;i<b;i++)
+ num *=a;
+ return num;
+}
+
+static int decode_parameter_from_string(unifi_priv_t* priv, char **str_ptr,
+ const char *token, int param_type,
+ void *dst, int param_max_len)
+{
+ u8 int_str[7] = "0";
+ u32 param_str_len;
+ u8 *param_str_begin,*param_str_end;
+ u8 *orig_str = *str_ptr;
+
+ if (!strncmp(*str_ptr, token, strlen(token))) {
+ strsep(str_ptr, "=,");
+ param_str_begin = *str_ptr;
+ strsep(str_ptr, "=,");
+ if (*str_ptr == NULL) {
+ param_str_len = strlen(param_str_begin);
+ } else {
+ param_str_end = *str_ptr-1;
+ param_str_len = param_str_end - param_str_begin;
+ }
+ unifi_trace(priv,UDBG2,"'token:%s', len:%d, ", token, param_str_len);
+ if (param_str_len > param_max_len) {
+ unifi_notice(priv,"extracted param len:%d is > MAX:%d\n",param_str_len, param_max_len);
+ param_str_len = param_max_len;
+ }
+ switch (param_type) {
+ case PARAM_TYPE_INT:
+ {
+ u32 *pdst_int = dst,num =0;
+ int i,j=0;
+ if (param_str_len > sizeof(int_str)) {
+ param_str_len = sizeof(int_str);
+ }
+ memcpy(int_str, param_str_begin, param_str_len);
+ for(i = param_str_len; i>0;i--) {
+ if(int_str[i-1] >= '0' && int_str[i-1] <='9') {
+ num += ((int_str[i-1]-'0')*power(10,j));
+ j++;
+ } else {
+ unifi_error(priv,"decode_parameter_from_string:not a number %c\n",(int_str[i-1]));
+ return -1;
+ }
+ }
+ *pdst_int = num;
+ unifi_trace(priv,UDBG2,"decode_parameter_from_string:decoded int = %d\n",*pdst_int);
+ }
+ break;
+ default:
+ memcpy(dst, param_str_begin, param_str_len);
+ *((char *)dst + param_str_len) = 0;
+ unifi_trace(priv,UDBG2,"decode_parameter_from_string:decoded string = %s\n",(char *)dst);
+ break;
+ }
+ } else {
+ unifi_error(priv,"decode_parameter_from_string: Token:%s not found in %s \n",token,orig_str);
+ return -1;
+ }
+ return 0;
+}
+static int store_ap_advanced_config_from_string(unifi_priv_t *priv, char *param_str)
+{
+ char * str_ptr=param_str;
+ int ret = 0,tmp_var;
+ char phy_mode[6];
+ CsrWifiSmeApMacConfig * ap_mac_config = &priv->ap_mac_config;
+
+ /* Check for BI */
+ ret = decode_parameter_from_string(priv, &str_ptr, "BI=",
+ PARAM_TYPE_INT, &tmp_var, 5);
+ if(ret) {
+ unifi_error(priv,"store_ap_advanced_config_from_string: BI not found\n");
+ return -1;
+ }
+ ap_mac_config->beaconInterval = tmp_var;
+ ret = decode_parameter_from_string(priv, &str_ptr, "DTIM_PER=",
+ PARAM_TYPE_INT, &tmp_var, 5);
+ if(ret) {
+ unifi_error(priv,"store_ap_advanced_config_from_string: DTIM_PER not found\n");
+ return -1;
+ }
+ ap_mac_config->dtimPeriod = tmp_var;
+ ret = decode_parameter_from_string(priv, &str_ptr, "WMM=",
+ PARAM_TYPE_INT, &tmp_var, 5);
+ if(ret) {
+ unifi_error(priv,"store_ap_advanced_config_from_string: WMM not found\n");
+ return -1;
+ }
+ ap_mac_config->wmmEnabled = tmp_var;
+ ret = decode_parameter_from_string(priv, &str_ptr, "PHY=",
+ PARAM_TYPE_STRING, phy_mode, 5);
+ if(ret) {
+ unifi_error(priv,"store_ap_advanced_config_from_string: PHY not found\n");
+ } else {
+ if(strstr(phy_mode,"b")){
+ ap_mac_config->phySupportedBitmap = CSR_WIFI_SME_AP_PHY_SUPPORT_B;
+ }
+ if(strstr(phy_mode,"g")) {
+ ap_mac_config->phySupportedBitmap |= CSR_WIFI_SME_AP_PHY_SUPPORT_G;
+ }
+ if(strstr(phy_mode,"n")) {
+ ap_mac_config->phySupportedBitmap |= CSR_WIFI_SME_AP_PHY_SUPPORT_N;
+ }
+ ap_mac_config->supportedRatesCount =
+ uf_configure_supported_rates(ap_mac_config->supportedRates, ap_mac_config->phySupportedBitmap);
+ }
+ return ret;
+}
+
+static int store_ap_config_from_string( unifi_priv_t * priv,char *param_str)
+
+{
+ char *str_ptr = param_str;
+ char sub_cmd[16];
+ char sec[CSR_WIFI_MAX_SEC_LEN];
+ char key[CSR_WIFI_MAX_KEY_LEN];
+ int ret = 0,tmp_var;
+ CsrWifiSmeApConfig_t *ap_config = &priv->ap_config;
+ CsrWifiSmeApMacConfig * ap_mac_config = &priv->ap_mac_config;
+ memset(sub_cmd, 0, sizeof(sub_cmd));
+ if(!strstr(param_str,"END")) {
+ unifi_error(priv,"store_ap_config_from_string:Invalid config string:%s\n",param_str);
+ return -1;
+ }
+ if (decode_parameter_from_string(priv,&str_ptr, "ASCII_CMD=",
+ PARAM_TYPE_STRING, sub_cmd, 6) != 0) {
+ return -1;
+ }
+ if (strncmp(sub_cmd, "AP_CFG", 6)) {
+
+ if(!strncmp(sub_cmd ,"ADVCFG", 6)) {
+ return store_ap_advanced_config_from_string(priv, str_ptr);
+ }
+ unifi_error(priv,"store_ap_config_from_string: sub_cmd:%s != 'AP_CFG or ADVCFG'!\n", sub_cmd);
+ return -1;
+ }
+ memset(ap_config, 0, sizeof(CsrWifiSmeApConfig_t));
+ ret = decode_parameter_from_string(priv,&str_ptr, "SSID=",
+ PARAM_TYPE_STRING, ap_config->ssid.ssid,
+ CSR_WIFI_MAX_SSID_LEN);
+ if(ret) {
+ unifi_error(priv,"store_ap_config_from_string: SSID not found\n");
+ return -1;
+ }
+ ap_config->ssid.length = strlen(ap_config->ssid.ssid);
+
+ ret = decode_parameter_from_string(priv, &str_ptr, "SEC=",
+ PARAM_TYPE_STRING, sec, CSR_WIFI_MAX_SEC_LEN);
+ if(ret) {
+ unifi_error(priv,"store_ap_config_from_string: SEC not found\n");
+ return -1;
+ }
+ ret = decode_parameter_from_string(priv,&str_ptr, "KEY=",
+ PARAM_TYPE_STRING, key, CSR_WIFI_MAX_KEY_LEN);
+ if(!strcasecmp(sec,"open")) {
+ unifi_trace(priv,UDBG2,"store_ap_config_from_string: security open");
+ ap_config->credentials.authType = CSR_WIFI_SME_AP_AUTH_TYPE_OPEN_SYSTEM;
+ if(ret) {
+ unifi_notice(priv,"store_ap_config_from_string: KEY not found:fine with Open\n");
+ }
+ }
+ else if(!strcasecmp(sec,"wpa2-psk")) {
+ int i,j=0;
+ CsrWifiNmeApAuthPers *pers =
+ ((CsrWifiNmeApAuthPers *)&(ap_config->credentials.nmeAuthType.authTypePersonal));
+ u8 *psk = pers->authPers_credentials.psk.psk;
+
+ unifi_trace(priv,UDBG2,"store_ap_config_from_string: security WPA2");
+ if(ret) {
+ unifi_error(priv,"store_ap_config_from_string: KEY not found for WPA2\n");
+ return -1;
+ }
+ ap_config->credentials.authType = CSR_WIFI_SME_AP_AUTH_TYPE_PERSONAL;
+ pers->authSupport = CSR_WIFI_SME_RSN_AUTH_WPA2PSK;
+ pers->rsnCapabilities =0;
+ pers->wapiCapabilities =0;
+ pers->pskOrPassphrase=CSR_WIFI_NME_AP_CREDENTIAL_TYPE_PSK;
+ pers->authPers_credentials.psk.encryptionMode =
+ (CSR_WIFI_NME_ENCRYPTION_CIPHER_PAIRWISE_CCMP |CSR_WIFI_NME_ENCRYPTION_CIPHER_GROUP_CCMP) ;
+ for(i=0;i<32;i++){
+ psk[i] = (16*hex_look_up(key[j]))+hex_look_up(key[j+1]);
+ j+=2;
+ }
+
+ } else {
+ unifi_notice(priv,"store_ap_config_from_string: Unknown security: Assuming Open");
+ ap_config->credentials.authType = CSR_WIFI_SME_AP_AUTH_TYPE_OPEN_SYSTEM;
+ return -1;
+ }
+ /* Get the decoded value in a temp int variable to ensure that other fields within the struct
+ which are of type other than int are not over written */
+ ret = decode_parameter_from_string(priv,&str_ptr, "CHANNEL=", PARAM_TYPE_INT, &tmp_var, 5);
+ if(ret)
+ return -1;
+ ap_config->channel = tmp_var;
+ ret = decode_parameter_from_string(priv,&str_ptr, "PREAMBLE=", PARAM_TYPE_INT, &tmp_var, 5);
+ if(ret)
+ return -1;
+ ap_mac_config->preamble = tmp_var;
+ ret = decode_parameter_from_string(priv,&str_ptr, "MAX_SCB=", PARAM_TYPE_INT, &tmp_var, 5);
+ ap_config->max_connections = tmp_var;
+ return ret;
+}
+
+static int
+iwprivsapstart(struct net_device *dev, struct iw_request_info *info,
+ union iwreq_data *wrqu, char *extra)
+{
+ netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev);
+ unifi_priv_t *priv = interfacePriv->privPtr;
+ int r;
+
+ unifi_trace(priv, UDBG1, "iwprivsapstart\n" );
+ r = sme_ap_start(priv,interfacePriv->InterfaceTag,&priv->ap_config);
+ if(r) {
+ unifi_error(priv,"iwprivsapstart AP START failed : %d\n",-r);
+ }
+ return r;
+}
+
+static int
+iwprivsapconfig(struct net_device *dev, struct iw_request_info *info,
+ union iwreq_data *wrqu, char *extra)
+{
+ netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev);
+ unifi_priv_t *priv = interfacePriv->privPtr;
+ char *cfg_str = NULL;
+ int r;
+
+ unifi_trace(priv, UDBG1, "iwprivsapconfig\n" );
+ if (wrqu->data.length != 0) {
+ char *str;
+ if (!(cfg_str = kmalloc(wrqu->data.length+1, GFP_KERNEL)))
+ {
+ return -ENOMEM;
+ }
+ if (copy_from_user(cfg_str, wrqu->data.pointer, wrqu->data.length)) {
+ kfree(cfg_str);
+ return -EFAULT;
+ }
+ cfg_str[wrqu->data.length] = 0;
+ unifi_trace(priv,UDBG2,"length:%d\n",wrqu->data.length);
+ unifi_trace(priv,UDBG2,"AP configuration string:%s\n",cfg_str);
+ str = cfg_str;
+ if ((r = store_ap_config_from_string(priv,str))) {
+ unifi_error(priv, "iwprivsapconfig:Failed to decode the string %d\n",r);
+ kfree(cfg_str);
+ return -EIO;
+
+ }
+ } else {
+ unifi_error(priv,"iwprivsapconfig argument length = 0 \n");
+ return -EIO;
+ }
+ r = sme_ap_config(priv, &priv->ap_mac_config, &priv->group_sec_config);
+ if(r) {
+ unifi_error(priv,"iwprivsapstop AP Config failed : %d\n",-r);
+ } else if(interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_AP ||
+ interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_P2PGO) {
+ unifi_trace(priv, UDBG1, "iwprivsapconfig: Starting the AP");
+ r = sme_ap_start(priv,interfacePriv->InterfaceTag,&priv->ap_config);
+ if(r) {
+ unifi_error(priv,"iwprivsapstart AP START failed : %d\n",-r);
+ }
+ }
+ kfree(cfg_str);
+ return r;
+}
+
+static int
+iwprivsapstop(struct net_device *dev, struct iw_request_info *info,
+ union iwreq_data *wrqu, char *extra)
+{
+ netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev);
+ unifi_priv_t *priv = interfacePriv->privPtr;
+ int r;
+ u16 interface_tag = interfacePriv->InterfaceTag;
+
+ unifi_trace(priv, UDBG1, "iwprivsapstop\n" );
+ r = sme_ap_stop(priv,interface_tag);
+ if(r) {
+ unifi_error(priv,"iwprivsapstop AP STOP failed : %d\n",-r);
+ }
+ return r;
+}
+
+#ifdef ANDROID_BUILD
+static int
+iwprivsapfwreload(struct net_device *dev, struct iw_request_info *info,
+ union iwreq_data *wrqu, char *extra)
+{
+ netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev);
+ unifi_priv_t *priv = interfacePriv->privPtr;
+
+ unifi_trace(priv, UDBG1, "iwprivsapfwreload\n" );
+ return 0;
+}
+
+static int
+iwprivsstackstart(struct net_device *dev, struct iw_request_info *info,
+ union iwreq_data *wrqu, char *extra)
+{
+ netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev);
+ unifi_priv_t *priv = interfacePriv->privPtr;
+ unifi_trace(priv, UDBG1, "iwprivsstackstart\n" );
+ return 0;
+}
+
+static int
+iwprivsstackstop(struct net_device *dev, struct iw_request_info *info,
+ union iwreq_data *wrqu, char *extra)
+{
+ netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev);
+ unifi_priv_t *priv = interfacePriv->privPtr;
+ int r = 0;
+ u16 interface_tag = interfacePriv->InterfaceTag;
+
+ unifi_trace(priv, UDBG1, "iwprivsstackstop\n" );
+
+ switch(interfacePriv->interfaceMode) {
+ case CSR_WIFI_ROUTER_CTRL_MODE_STA:
+ case CSR_WIFI_ROUTER_CTRL_MODE_P2PCLI:
+ case CSR_WIFI_ROUTER_CTRL_MODE_IBSS:
+ r = sme_mgt_disconnect(priv);
+ break;
+ case CSR_WIFI_ROUTER_CTRL_MODE_AP:
+ case CSR_WIFI_ROUTER_CTRL_MODE_P2PGO:
+ r = sme_ap_stop(priv,interface_tag);
+ break;
+ default :
+ break;
+ }
+
+ if(r) {
+ unifi_error(priv,"iwprivsstackstop Stack stop failed : %d\n",-r);
+ }
+ return 0;
+}
+#endif /* ANDROID_BUILD */
+#endif /* CSR_SUPPORT_WEXT_AP */
+
+#ifdef CSR_WIFI_SECURITY_WAPI_ENABLE
+static int
+iwprivsconfwapi(struct net_device *dev, struct iw_request_info *info,
+ union iwreq_data *wrqu, char *extra)
+{
+ u8 enable;
+ netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev);
+ unifi_priv_t *priv = interfacePriv->privPtr;
+ func_enter();
+
+ unifi_trace(priv, UDBG1, "iwprivsconfwapi\n" );
+
+ if(interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_AP ||
+ interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_P2PGO) {
+ unifi_error(priv, "iwprivsconfwapi: not permitted in Mode %d\n",
+ interfacePriv->interfaceMode);
+ return -EPERM;
+ }
+
+ enable = *(u8*)(extra);
+
+ if (enable) {
+ priv->connection_config.authModeMask = CSR_WIFI_SME_AUTH_MODE_80211_OPEN;
+ priv->connection_config.authModeMask |= (CSR_WIFI_SME_AUTH_MODE_WAPI_WAIPSK | CSR_WIFI_SME_AUTH_MODE_WAPI_WAI);
+ priv->connection_config.encryptionModeMask |=
+ CSR_WIFI_SME_ENCRYPTION_CIPHER_PAIRWISE_SMS4 | CSR_WIFI_SME_ENCRYPTION_CIPHER_GROUP_SMS4;
+ } else {
+ priv->connection_config.authModeMask &= ~(CSR_WIFI_SME_AUTH_MODE_WAPI_WAIPSK | CSR_WIFI_SME_AUTH_MODE_WAPI_WAI);
+ priv->connection_config.encryptionModeMask &=
+ ~(CSR_WIFI_SME_ENCRYPTION_CIPHER_PAIRWISE_SMS4 | CSR_WIFI_SME_ENCRYPTION_CIPHER_GROUP_SMS4);
+ }
+
+ func_exit();
+ return 0;
+}
+
+static int
+iwprivswpikey(struct net_device *dev, struct iw_request_info *info,
+ union iwreq_data *wrqu, char *extra)
+{
+ int r = 0, i;
+ CsrWifiSmeKey key;
+ unifiio_wapi_key_t inKey;
+ netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev);
+ unifi_priv_t *priv = interfacePriv->privPtr;
+ func_enter();
+
+ unifi_trace(priv, UDBG1, "iwprivswpikey\n" );
+
+ if(interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_AP ||
+ interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_P2PGO) {
+ unifi_error(priv, "iwprivswpikey: not permitted in Mode %d\n",
+ interfacePriv->interfaceMode);
+ return -EPERM;
+ }
+
+ inKey = *(unifiio_wapi_key_t*)(extra);
+
+ if (inKey.unicastKey) {
+ key.keyType = CSR_WIFI_SME_KEY_TYPE_PAIRWISE;
+ } else {
+ key.keyType = CSR_WIFI_SME_KEY_TYPE_GROUP;
+ }
+
+ key.keyIndex = inKey.keyIndex;
+
+ /* memcpy(key.keyRsc, inKey.keyRsc, 16); */
+ for (i = 0; i < 16; i+= 2)
+ {
+ key.keyRsc[i/2] = inKey.keyRsc[i+1] << 8 | inKey.keyRsc[i];
+ }
+
+ memcpy(key.address.a, inKey.address, 6);
+ key.keyLength = 32;
+ memcpy(key.key, inKey.key, 32);
+ key.authenticator = 0;
+ key.wepTxKey = 0;
+
+ unifi_trace(priv, UDBG1, "keyType = %d, keyIndex = %d, wepTxKey = %d, keyRsc = %x:%x, auth = %d, address = %x:%x, "
+ "keylength = %d, key = %x:%x\n", key.keyType, key.keyIndex, key.wepTxKey,
+ key.keyRsc[0], key.keyRsc[7], key.authenticator,
+ key.address.a[0], key.address.a[5], key.keyLength, key.key[0],
+ key.key[15]);
+
+ r = sme_mgt_key(priv, &key, CSR_WIFI_SME_LIST_ACTION_ADD);
+ if (r) {
+ unifi_error(priv, "SETKEYS request was rejected with result %d\n", r);
+ return convert_sme_error(r);
+ }
+
+ func_exit();
+ return r;
+}
+#endif
+
+
+static int
+unifi_giwname(struct net_device *dev, struct iw_request_info *info,
+ union iwreq_data *wrqu, char *extra)
+{
+ netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev);
+ unifi_priv_t *priv = interfacePriv->privPtr;
+ char *name = wrqu->name;
+ unifi_trace(priv, UDBG2, "unifi_giwname\n");
+
+ if (priv->if_index == CSR_INDEX_5G) {
+ strcpy(name, "IEEE 802.11-a");
+ } else {
+ strcpy(name, "IEEE 802.11-bgn");
+ }
+ return 0;
+} /* unifi_giwname() */
+
+
+static int
+unifi_siwfreq(struct net_device *dev, struct iw_request_info *info,
+ union iwreq_data *wrqu, char *extra)
+{
+ netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev);
+ unifi_priv_t *priv = interfacePriv->privPtr;
+ struct iw_freq *freq = (struct iw_freq *)wrqu;
+
+ func_enter();
+ unifi_trace(priv, UDBG2, "unifi_siwfreq\n");
+
+ if(interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_AP ||
+ interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_P2PGO) {
+ unifi_error(priv, "unifi_siwfreq: not permitted in Mode %d\n",
+ interfacePriv->interfaceMode);
+ return -EPERM;
+ }
+
+
+ /*
+ * Channel is stored in the connection configuration,
+ * and set later when ask for a connection.
+ */
+ if ((freq->e == 0) && (freq->m <= 1000)) {
+ priv->connection_config.adhocChannel = freq->m;
+ } else {
+ priv->connection_config.adhocChannel = wext_freq_to_channel(freq->m, freq->e);
+ }
+
+ func_exit();
+ return 0;
+} /* unifi_siwfreq() */
+
+
+static int
+unifi_giwfreq(struct net_device *dev, struct iw_request_info *info,
+ union iwreq_data *wrqu, char *extra)
+{
+ netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev);
+ unifi_priv_t *priv = interfacePriv->privPtr;
+ struct iw_freq *freq = (struct iw_freq *)wrqu;
+ int err = 0;
+ CsrWifiSmeConnectionInfo connectionInfo;
+
+ func_enter();
+ unifi_trace(priv, UDBG2, "unifi_giwfreq\n");
+ CHECK_INITED(priv);
+
+ if(interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_AP ||
+ interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_P2PGO) {
+ unifi_error(priv, "unifi_giwfreq: not permitted in Mode %d\n",
+ interfacePriv->interfaceMode);
+ return -EPERM;
+ }
+
+
+ UF_RTNL_UNLOCK();
+ err = sme_mgt_connection_info_get(priv, &connectionInfo);
+ UF_RTNL_LOCK();
+
+ freq->m = channel_to_mhz(connectionInfo.channelNumber,
+ (connectionInfo.networkType80211 == CSR_WIFI_SME_RADIO_IF_GHZ_5_0));
+ freq->e = 6;
+
+ func_exit();
+ return convert_sme_error(err);
+} /* unifi_giwfreq() */
+
+
+static int
+unifi_siwmode(struct net_device *dev, struct iw_request_info *info,
+ union iwreq_data *wrqu, char *extra)
+{
+ netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev);
+ unifi_priv_t *priv = interfacePriv->privPtr;
+
+ func_enter();
+ unifi_trace(priv, UDBG2, "unifi_siwmode\n");
+
+ if(interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_AP ||
+ interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_P2PGO) {
+ unifi_error(priv, "unifi_siwmode: not permitted in Mode %d\n",
+ interfacePriv->interfaceMode);
+ return -EPERM;
+ }
+
+
+ switch(wrqu->mode) {
+ case IW_MODE_ADHOC:
+ priv->connection_config.bssType = CSR_WIFI_SME_BSS_TYPE_ADHOC;
+ break;
+ case IW_MODE_INFRA:
+ priv->connection_config.bssType = CSR_WIFI_SME_BSS_TYPE_INFRASTRUCTURE;
+ break;
+ case IW_MODE_AUTO:
+ priv->connection_config.bssType = CSR_WIFI_SME_BSS_TYPE_ANY_BSS;
+ break;
+ default:
+ unifi_notice(priv, "Unknown IW MODE value.\n");
+ }
+
+ /* Clear the SSID and BSSID configuration */
+ priv->connection_config.ssid.length = 0;
+ memset(priv->connection_config.bssid.a, 0xFF, ETH_ALEN);
+
+ func_exit();
+ return 0;
+} /* unifi_siwmode() */
+
+
+
+static int
+unifi_giwmode(struct net_device *dev, struct iw_request_info *info,
+ union iwreq_data *wrqu, char *extra)
+{
+ int r = 0;
+ netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev);
+ unifi_priv_t *priv = interfacePriv->privPtr;
+ CsrWifiSmeConnectionConfig connectionConfig;
+
+ func_enter();
+ unifi_trace(priv, UDBG2, "unifi_giwmode\n");
+ CHECK_INITED(priv);
+
+ unifi_trace(priv, UDBG2, "unifi_giwmode: Exisitng mode = 0x%x\n",
+ interfacePriv->interfaceMode);
+ switch(interfacePriv->interfaceMode) {
+ case CSR_WIFI_ROUTER_CTRL_MODE_STA:
+ case CSR_WIFI_ROUTER_CTRL_MODE_P2PCLI:
+ wrqu->mode = IW_MODE_INFRA;
+ break;
+ case CSR_WIFI_ROUTER_CTRL_MODE_AP:
+ case CSR_WIFI_ROUTER_CTRL_MODE_P2PGO:
+ wrqu->mode = IW_MODE_MASTER;
+ break;
+ case CSR_WIFI_ROUTER_CTRL_MODE_IBSS:
+ wrqu->mode = IW_MODE_ADHOC;
+ break;
+ case CSR_WIFI_ROUTER_CTRL_MODE_P2P:
+ case CSR_WIFI_ROUTER_CTRL_MODE_NONE:
+ UF_RTNL_UNLOCK();
+ r = sme_mgt_connection_config_get(priv, &connectionConfig);
+ UF_RTNL_LOCK();
+ if (r == 0) {
+ switch(connectionConfig.bssType) {
+ case CSR_WIFI_SME_BSS_TYPE_ADHOC:
+ wrqu->mode = IW_MODE_ADHOC;
+ break;
+ case CSR_WIFI_SME_BSS_TYPE_INFRASTRUCTURE:
+ wrqu->mode = IW_MODE_INFRA;
+ break;
+ default:
+ wrqu->mode = IW_MODE_AUTO;
+ unifi_notice(priv, "Unknown IW MODE value.\n");
+ }
+ }
+ break;
+ default:
+ wrqu->mode = IW_MODE_AUTO;
+ unifi_notice(priv, "Unknown IW MODE value.\n");
+
+ }
+ unifi_trace(priv, UDBG4, "unifi_giwmode: mode = 0x%x\n", wrqu->mode);
+ func_exit();
+ return r;
+} /* unifi_giwmode() */
+
+
+
+static int
+unifi_giwrange(struct net_device *dev, struct iw_request_info *info,
+ union iwreq_data *wrqu, char *extra)
+{
+ struct iw_point *dwrq = &wrqu->data;
+ struct iw_range *range = (struct iw_range *) extra;
+ int i;
+
+ unifi_trace(NULL, UDBG2, "unifi_giwrange\n");
+
+ dwrq->length = sizeof(struct iw_range);
+ memset(range, 0, sizeof(*range));
+ range->min_nwid = 0x0000;
+ range->max_nwid = 0x0000;
+
+ /*
+ * Don't report the frequency/channel table, then the channel
+ * number returned elsewhere will be printed as a channel number.
+ */
+
+ /* Ranges of values reported in quality structs */
+ range->max_qual.qual = 40; /* Max expected qual value */
+ range->max_qual.level = -120; /* Noise floor in dBm */
+ range->max_qual.noise = -120; /* Noise floor in dBm */
+
+
+ /* space for IW_MAX_BITRATES (8 up to WE15, 32 later) */
+ i = 0;
+#if WIRELESS_EXT > 15
+ range->bitrate[i++] = 2 * 500000;
+ range->bitrate[i++] = 4 * 500000;
+ range->bitrate[i++] = 11 * 500000;
+ range->bitrate[i++] = 22 * 500000;
+ range->bitrate[i++] = 12 * 500000;
+ range->bitrate[i++] = 18 * 500000;
+ range->bitrate[i++] = 24 * 500000;
+ range->bitrate[i++] = 36 * 500000;
+ range->bitrate[i++] = 48 * 500000;
+ range->bitrate[i++] = 72 * 500000;
+ range->bitrate[i++] = 96 * 500000;
+ range->bitrate[i++] = 108 * 500000;
+#else
+ range->bitrate[i++] = 2 * 500000;
+ range->bitrate[i++] = 4 * 500000;
+ range->bitrate[i++] = 11 * 500000;
+ range->bitrate[i++] = 22 * 500000;
+ range->bitrate[i++] = 24 * 500000;
+ range->bitrate[i++] = 48 * 500000;
+ range->bitrate[i++] = 96 * 500000;
+ range->bitrate[i++] = 108 * 500000;
+#endif /* WIRELESS_EXT < 16 */
+ range->num_bitrates = i;
+
+ range->max_encoding_tokens = NUM_WEPKEYS;
+ range->num_encoding_sizes = 2;
+ range->encoding_size[0] = 5;
+ range->encoding_size[1] = 13;
+
+ range->we_version_source = 20;
+ range->we_version_compiled = WIRELESS_EXT;
+
+ /* Number of channels available in h/w */
+ range->num_channels = 14;
+ /* Number of entries in freq[] array */
+ range->num_frequency = 14;
+ for (i = 0; (i < range->num_frequency) && (i < IW_MAX_FREQUENCIES); i++) {
+ int chan = i + 1;
+ range->freq[i].i = chan;
+ range->freq[i].m = channel_to_mhz(chan, 0);
+ range->freq[i].e = 6;
+ }
+ if ((i+3) < IW_MAX_FREQUENCIES) {
+ range->freq[i].i = 36;
+ range->freq[i].m = channel_to_mhz(36, 1);
+ range->freq[i].e = 6;
+ range->freq[i+1].i = 40;
+ range->freq[i+1].m = channel_to_mhz(40, 1);
+ range->freq[i+1].e = 6;
+ range->freq[i+2].i = 44;
+ range->freq[i+2].m = channel_to_mhz(44, 1);
+ range->freq[i+2].e = 6;
+ range->freq[i+3].i = 48;
+ range->freq[i+3].m = channel_to_mhz(48, 1);
+ range->freq[i+3].e = 6;
+ }
+
+#if WIRELESS_EXT > 16
+ /* Event capability (kernel + driver) */
+ range->event_capa[0] = (IW_EVENT_CAPA_K_0 |
+ IW_EVENT_CAPA_MASK(SIOCGIWTHRSPY) |
+ IW_EVENT_CAPA_MASK(SIOCGIWAP) |
+ IW_EVENT_CAPA_MASK(SIOCGIWSCAN));
+ range->event_capa[1] = IW_EVENT_CAPA_K_1;
+ range->event_capa[4] = (IW_EVENT_CAPA_MASK(IWEVTXDROP) |
+ IW_EVENT_CAPA_MASK(IWEVCUSTOM) |
+ IW_EVENT_CAPA_MASK(IWEVREGISTERED) |
+ IW_EVENT_CAPA_MASK(IWEVEXPIRED));
+#endif /* WIRELESS_EXT > 16 */
+
+#if WIRELESS_EXT > 17
+ range->enc_capa = IW_ENC_CAPA_WPA | IW_ENC_CAPA_WPA2 |
+ IW_ENC_CAPA_CIPHER_TKIP | IW_ENC_CAPA_CIPHER_CCMP;
+#endif /* WIRELESS_EXT > 17 */
+
+
+ return 0;
+} /* unifi_giwrange() */
+
+
+static int
+unifi_siwap(struct net_device *dev, struct iw_request_info *info,
+ union iwreq_data *wrqu, char *extra)
+{
+ netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev);
+ unifi_priv_t *priv = interfacePriv->privPtr;
+ int err = 0;
+ const unsigned char zero_bssid[ETH_ALEN] = {0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00};
+
+ func_enter();
+
+ CHECK_INITED(priv);
+
+ if(interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_AP ||
+ interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_P2PGO) {
+ unifi_error(priv, "unifi_siwap: not permitted in Mode %d\n",
+ interfacePriv->interfaceMode);
+ return -EPERM;
+ }
+
+
+ if (wrqu->ap_addr.sa_family != ARPHRD_ETHER) {
+ return -EINVAL;
+ }
+
+ unifi_trace(priv, UDBG1, "unifi_siwap: asked for %pM\n",
+ wrqu->ap_addr.sa_data);
+
+ if (!memcmp(wrqu->ap_addr.sa_data, zero_bssid, ETH_ALEN)) {
+ priv->ignore_bssid_join = FALSE;
+ err = sme_mgt_disconnect(priv);
+ if (err) {
+ unifi_trace(priv, UDBG4, "unifi_siwap: Disconnect failed, status %d\n", err);
+ }
+ return 0;
+ }
+
+ if (priv->ignore_bssid_join) {
+ unifi_trace(priv, UDBG4, "unifi_siwap: ignoring second join\n");
+ priv->ignore_bssid_join = FALSE;
+ } else {
+ memcpy(priv->connection_config.bssid.a, wrqu->ap_addr.sa_data, ETH_ALEN);
+ unifi_trace(priv, UDBG1, "unifi_siwap: Joining %X:%X:%X:%X:%X:%X\n",
+ priv->connection_config.bssid.a[0],
+ priv->connection_config.bssid.a[1],
+ priv->connection_config.bssid.a[2],
+ priv->connection_config.bssid.a[3],
+ priv->connection_config.bssid.a[4],
+ priv->connection_config.bssid.a[5]);
+ err = sme_mgt_connect(priv);
+ if (err) {
+ unifi_error(priv, "unifi_siwap: Join failed, status %d\n", err);
+ func_exit();
+ return convert_sme_error(err);
+ }
+ }
+ func_exit();
+
+ return 0;
+} /* unifi_siwap() */
+
+
+static int
+unifi_giwap(struct net_device *dev, struct iw_request_info *info,
+ union iwreq_data *wrqu, char *extra)
+{
+ netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev);
+ unifi_priv_t *priv = interfacePriv->privPtr;
+ CsrWifiSmeConnectionInfo connectionInfo;
+ int r = 0;
+ u8 *bssid;
+
+ func_enter();
+
+ CHECK_INITED(priv);
+ unifi_trace(priv, UDBG2, "unifi_giwap\n");
+
+ if(interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_AP ||
+ interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_P2PGO) {
+ unifi_error(priv, "iwprivswpikey: not permitted in Mode %d\n",
+ interfacePriv->interfaceMode);
+ return -EPERM;
+ }
+
+ UF_RTNL_UNLOCK();
+ r = sme_mgt_connection_info_get(priv, &connectionInfo);
+ UF_RTNL_LOCK();
+
+ if (r == 0) {
+ bssid = connectionInfo.bssid.a;
+ wrqu->ap_addr.sa_family = ARPHRD_ETHER;
+ unifi_trace(priv, UDBG4, "unifi_giwap: BSSID = %pM\n", bssid);
+
+ memcpy(wrqu->ap_addr.sa_data, bssid, ETH_ALEN);
+ } else {
+ memset(wrqu->ap_addr.sa_data, 0, ETH_ALEN);
+ }
+
+ func_exit();
+ return 0;
+} /* unifi_giwap() */
+
+
+static int
+unifi_siwscan(struct net_device *dev, struct iw_request_info *info,
+ union iwreq_data *wrqu, char *extra)
+{
+ netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev);
+ unifi_priv_t *priv = interfacePriv->privPtr;
+ int scantype;
+ int r;
+ CsrWifiSsid scan_ssid;
+ unsigned char *channel_list = NULL;
+ int chans_good = 0;
+#if WIRELESS_EXT > 17
+ struct iw_point *data = &wrqu->data;
+ struct iw_scan_req *req = (struct iw_scan_req *) extra;
+#endif
+
+ func_enter();
+
+ CHECK_INITED(priv);
+
+ if(interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_AP ||
+ interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_P2PGO) {
+ unifi_error(priv, "unifi_siwscan: not permitted in Mode %d\n",
+ interfacePriv->interfaceMode);
+ return -EPERM;
+ }
+
+
+ scantype = UNIFI_SCAN_ACTIVE;
+
+#if WIRELESS_EXT > 17
+ /* Providing a valid channel list will force an active scan */
+ if (req) {
+ if ((req->num_channels > 0) && (req->num_channels < IW_MAX_FREQUENCIES)) {
+ channel_list = kmalloc(req->num_channels, GFP_KERNEL);
+ if (channel_list) {
+ int i;
+ for (i = 0; i < req->num_channels; i++) {
+ /* Convert frequency to channel number */
+ int ch = wext_freq_to_channel(req->channel_list[i].m,
+ req->channel_list[i].e);
+ if (ch) {
+ channel_list[chans_good++] = ch;
+ }
+ }
+ unifi_trace(priv, UDBG1,
+ "SIWSCAN: Scanning %d channels\n", chans_good);
+ } else {
+ /* Fall back to scanning all */
+ unifi_error(priv, "SIWSCAN: Can't alloc channel_list (%d)\n",
+ req->num_channels);
+ }
+ }
+ }
+
+ if (req && (data->flags & IW_SCAN_THIS_ESSID)) {
+ memcpy(scan_ssid.ssid, req->essid, req->essid_len);
+ scan_ssid.length = req->essid_len;
+ unifi_trace(priv, UDBG1,
+ "SIWSCAN: Scanning for %.*s\n",
+ scan_ssid.length, scan_ssid.ssid);
+ } else
+#endif
+ {
+ unifi_trace(priv, UDBG1, "SIWSCAN: Scanning for all APs\n");
+ scan_ssid.length = 0;
+ }
+
+ r = sme_mgt_scan_full(priv, &scan_ssid, chans_good, channel_list);
+ if (r) {
+ unifi_error(priv, "SIWSCAN: Scan returned error %d\n", r);
+ } else {
+ unifi_trace(priv, UDBG1, "SIWSCAN: Scan done\n");
+ wext_send_scan_results_event(priv);
+ }
+
+ if (channel_list) {
+ kfree(channel_list);
+ }
+
+ func_exit();
+ return r;
+
+} /* unifi_siwscan() */
+
+
+static const unsigned char *
+unifi_find_info_element(int id, const unsigned char *info, int len)
+{
+ const unsigned char *ie = info;
+
+ while (len > 1)
+ {
+ int e_id, e_len;
+ e_id = ie[0];
+ e_len = ie[1];
+
+ /* Return if we find a match */
+ if (e_id == id)
+ {
+ return ie;
+ }
+
+ len -= (e_len + 2);
+ ie += (e_len + 2);
+ }
+
+ return NULL;
+} /* unifi_find_info_element() */
+
+
+/*
+ * Translate scan data returned from the card to a card independent
+ * format that the Wireless Tools will understand - Jean II
+ */
+int
+unifi_translate_scan(struct net_device *dev,
+ struct iw_request_info *info,
+ char *current_ev, char *end_buf,
+ CsrWifiSmeScanResult *scan_data,
+ int scan_index)
+{
+ struct iw_event iwe; /* Temporary buffer */
+ unsigned char *info_elems;
+ int info_elem_len;
+ const unsigned char *elem;
+ u16 capabilities;
+ int signal, noise, snr;
+ char *start_buf = current_ev;
+ char *current_val; /* For rates */
+ int i, r;
+
+ info_elems = scan_data->informationElements;
+ info_elem_len = scan_data->informationElementsLength;
+
+ if (!scan_data->informationElementsLength || !scan_data->informationElements) {
+ unifi_error(NULL, "*** NULL SCAN IEs ***\n");
+ return -EIO;
+ }
+
+ /* get capinfo bits */
+ capabilities = scan_data->capabilityInformation;
+
+ unifi_trace(NULL, UDBG5, "Capabilities: 0x%x\n", capabilities);
+
+ /* First entry *MUST* be the AP MAC address */
+ memset(&iwe, 0, sizeof(iwe));
+ iwe.cmd = SIOCGIWAP;
+ iwe.u.ap_addr.sa_family = ARPHRD_ETHER;
+ memcpy(iwe.u.ap_addr.sa_data, scan_data->bssid.a, ETH_ALEN);
+ iwe.len = IW_EV_ADDR_LEN;
+ r = uf_iwe_stream_add_event(info, start_buf, end_buf, &iwe, IW_EV_ADDR_LEN);
+ if (r < 0) {
+ return r;
+ }
+ start_buf += r;
+
+ /* Other entries will be displayed in the order we give them */
+
+ /* Add the ESSID */
+ /* find SSID in Info Elems */
+ elem = unifi_find_info_element(IE_SSID_ID, info_elems, info_elem_len);
+ if (elem) {
+ int e_len = elem[1];
+ const unsigned char *e_ptr = elem + 2;
+ unsigned char buf[33];
+
+ memset(&iwe, 0, sizeof(iwe));
+ iwe.cmd = SIOCGIWESSID;
+ iwe.u.essid.length = e_len;
+ if (iwe.u.essid.length > 32) {
+ iwe.u.essid.length = 32;
+ }
+ iwe.u.essid.flags = scan_index;
+ memcpy(buf, e_ptr, iwe.u.essid.length);
+ buf[iwe.u.essid.length] = '\0';
+ r = uf_iwe_stream_add_point(info, start_buf, end_buf, &iwe, buf);
+ if (r < 0) {
+ return r;
+ }
+ start_buf += r;
+
+ }
+
+ /* Add mode */
+ memset(&iwe, 0, sizeof(iwe));
+ iwe.cmd = SIOCGIWMODE;
+ if (scan_data->bssType == CSR_WIFI_SME_BSS_TYPE_INFRASTRUCTURE) {
+ iwe.u.mode = IW_MODE_INFRA;
+ } else {
+ iwe.u.mode = IW_MODE_ADHOC;
+ }
+ iwe.len = IW_EV_UINT_LEN;
+ r = uf_iwe_stream_add_event(info, start_buf, end_buf, &iwe, IW_EV_UINT_LEN);
+ if (r < 0) {
+ return r;
+ }
+ start_buf += r;
+
+ /* Add frequency. iwlist will convert to channel using table given in giwrange */
+ memset(&iwe, 0, sizeof(iwe));
+ iwe.cmd = SIOCGIWFREQ;
+ iwe.u.freq.m = scan_data->channelFrequency;
+ iwe.u.freq.e = 6;
+ r = uf_iwe_stream_add_event(info, start_buf, end_buf, &iwe, IW_EV_FREQ_LEN);
+ if (r < 0) {
+ return r;
+ }
+ start_buf += r;
+
+
+ /* Add quality statistics */
+ iwe.cmd = IWEVQUAL;
+ /*
+ * level and noise below are mapped into an unsigned 8 bit number,
+ * ranging from [-192; 63]. The way this is achieved is simply to
+ * add 0x100 onto the number if it is negative,
+ * once clipped to the correct range.
+ */
+ signal = scan_data->rssi; /* This value is in dBm */
+ /* Clip range of snr */
+ snr = (scan_data->snr > 0) ? scan_data->snr : 0; /* In dB relative, from 0 - 255 */
+ snr = (snr < 255) ? snr : 255;
+ noise = signal - snr;
+
+ /* Clip range of signal */
+ signal = (signal < 63) ? signal : 63;
+ signal = (signal > -192) ? signal : -192;
+
+ /* Clip range of noise */
+ noise = (noise < 63) ? noise : 63;
+ noise = (noise > -192) ? noise : -192;
+
+ /* Make u8 */
+ signal = ( signal < 0 ) ? signal + 0x100 : signal;
+ noise = ( noise < 0 ) ? noise + 0x100 : noise;
+
+ iwe.u.qual.level = (u8)signal; /* -192 : 63 */
+ iwe.u.qual.noise = (u8)noise; /* -192 : 63 */
+ iwe.u.qual.qual = snr; /* 0 : 255 */
+ iwe.u.qual.updated = 0;
+#if WIRELESS_EXT > 16
+ iwe.u.qual.updated |= IW_QUAL_LEVEL_UPDATED | IW_QUAL_NOISE_UPDATED |
+ IW_QUAL_QUAL_UPDATED;
+#if WIRELESS_EXT > 18
+ iwe.u.qual.updated |= IW_QUAL_DBM;
+#endif
+#endif
+ r = uf_iwe_stream_add_event(info, start_buf, end_buf, &iwe, IW_EV_QUAL_LEN);
+ if (r < 0) {
+ return r;
+ }
+ start_buf += r;
+
+ /* Add encryption capability */
+ iwe.cmd = SIOCGIWENCODE;
+ if (capabilities & SIG_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;
+ iwe.len = IW_EV_POINT_LEN + iwe.u.data.length;
+ r = uf_iwe_stream_add_point(info, start_buf, end_buf, &iwe, "");
+ if (r < 0) {
+ return r;
+ }
+ start_buf += r;
+
+
+ /*
+ * Rate : stuffing multiple values in a single event require a bit
+ * more of magic - Jean II
+ */
+ current_val = start_buf + IW_EV_LCP_LEN;
+
+ iwe.cmd = SIOCGIWRATE;
+ /* Those two flags are ignored... */
+ iwe.u.bitrate.fixed = iwe.u.bitrate.disabled = 0;
+
+ elem = unifi_find_info_element(IE_SUPPORTED_RATES_ID,
+ info_elems, info_elem_len);
+ if (elem) {
+ int e_len = elem[1];
+ const unsigned char *e_ptr = elem + 2;
+
+ /*
+ * Count how many rates we have.
+ * Zero marks the end of the list, if the list is not truncated.
+ */
+ /* Max 8 values */
+ for (i = 0; i < e_len; i++) {
+ if (e_ptr[i] == 0) {
+ break;
+ }
+ /* Bit rate given in 500 kb/s units (+ 0x80) */
+ iwe.u.bitrate.value = ((e_ptr[i] & 0x7f) * 500000);
+ /* Add new value to event */
+ r = uf_iwe_stream_add_value(info, start_buf, current_val, end_buf, &iwe, IW_EV_PARAM_LEN);
+ if (r < 0) {
+ return r;
+ }
+ current_val +=r;
+
+ }
+ }
+ elem = unifi_find_info_element(IE_EXTENDED_SUPPORTED_RATES_ID,
+ info_elems, info_elem_len);
+ if (elem) {
+ int e_len = elem[1];
+ const unsigned char *e_ptr = elem + 2;
+
+ /*
+ * Count how many rates we have.
+ * Zero marks the end of the list, if the list is not truncated.
+ */
+ /* Max 8 values */
+ for (i = 0; i < e_len; i++) {
+ if (e_ptr[i] == 0) {
+ break;
+ }
+ /* Bit rate given in 500 kb/s units (+ 0x80) */
+ iwe.u.bitrate.value = ((e_ptr[i] & 0x7f) * 500000);
+ /* Add new value to event */
+ r = uf_iwe_stream_add_value(info, start_buf, current_val, end_buf, &iwe, IW_EV_PARAM_LEN);
+ if (r < 0) {
+ return r;
+ }
+ current_val +=r;
+ }
+ }
+ /* Check if we added any rates event */
+ if ((current_val - start_buf) > IW_EV_LCP_LEN) {
+ start_buf = current_val;
+ }
+
+
+#if WIRELESS_EXT > 17
+ memset(&iwe, 0, sizeof(iwe));
+ iwe.cmd = IWEVGENIE;
+ iwe.u.data.length = info_elem_len;
+
+ r = uf_iwe_stream_add_point(info, start_buf, end_buf, &iwe, info_elems);
+ if (r < 0) {
+ return r;
+ }
+
+ start_buf += r;
+#endif /* WE > 17 */
+
+ return (start_buf - current_ev);
+} /* unifi_translate_scan() */
+
+
+
+static int
+unifi_giwscan(struct net_device *dev, struct iw_request_info *info,
+ union iwreq_data *wrqu, char *extra)
+{
+ netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev);
+ unifi_priv_t *priv = interfacePriv->privPtr;
+ struct iw_point *dwrq = &wrqu->data;
+ int r;
+
+ CHECK_INITED(priv);
+
+ if(interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_AP ||
+ interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_P2PGO) {
+ unifi_error(priv, "unifi_giwscan: not permitted in Mode %d\n",
+ interfacePriv->interfaceMode);
+ return -EPERM;
+ }
+
+
+ unifi_trace(priv, UDBG1,
+ "unifi_giwscan: buffer (%d bytes) \n",
+ dwrq->length);
+ UF_RTNL_UNLOCK();
+ r = sme_mgt_scan_results_get_async(priv, info, extra, dwrq->length);
+ UF_RTNL_LOCK();
+ if (r < 0) {
+ unifi_trace(priv, UDBG1,
+ "unifi_giwscan: buffer (%d bytes) not big enough.\n",
+ dwrq->length);
+ return r;
+ }
+
+ dwrq->length = r;
+ dwrq->flags = 0;
+
+ return 0;
+} /* unifi_giwscan() */
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * unifi_siwessid
+ *
+ * Request to join a network or start and AdHoc.
+ *
+ * Arguments:
+ * dev Pointer to network device struct.
+ * info Pointer to broken-out ioctl request.
+ * data Pointer to argument data.
+ * essid Pointer to string giving name of network to join
+ * or start
+ *
+ * Returns:
+ * 0 on success and everything complete
+ * -EINPROGRESS to have the higher level call the commit method.
+ * ---------------------------------------------------------------------------
+ */
+static int
+unifi_siwessid(struct net_device *dev, struct iw_request_info *info,
+ struct iw_point *data, char *essid)
+{
+ netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev);
+ unifi_priv_t *priv = interfacePriv->privPtr;
+ int len;
+ int err = 0;
+
+ func_enter();
+ CHECK_INITED(priv);
+
+ if(interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_AP ||
+ interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_P2PGO) {
+ unifi_error(priv, "unifi_siwessid: not permitted in Mode %d\n",
+ interfacePriv->interfaceMode);
+ return -EPERM;
+ }
+
+
+ len = 0;
+ if (data->flags & 1) {
+ /* Limit length */
+ len = data->length;
+ if (len > UNIFI_MAX_SSID_LEN) {
+ len = UNIFI_MAX_SSID_LEN;
+ }
+ }
+
+#ifdef UNIFI_DEBUG
+ {
+ char essid_str[UNIFI_MAX_SSID_LEN+1];
+ int i;
+
+ for (i = 0; i < len; i++) {
+ essid_str[i] = (isprint(essid[i]) ? essid[i] : '?');
+ }
+ essid_str[i] = '\0';
+
+ unifi_trace(priv, UDBG1, "unifi_siwessid: asked for '%*s' (%d)\n", len, essid_str, len);
+ unifi_trace(priv, UDBG2, " with authModeMask = %d", priv->connection_config.authModeMask);
+ }
+#endif
+
+ memset(priv->connection_config.bssid.a, 0xFF, ETH_ALEN);
+ if (len) {
+ if (essid[len - 1] == 0) {
+ len --;
+ }
+
+ memcpy(priv->connection_config.ssid.ssid, essid, len);
+ priv->connection_config.ssid.length = len;
+
+ } else {
+ priv->connection_config.ssid.length = 0;
+ }
+
+ UF_RTNL_UNLOCK();
+ err = sme_mgt_connect(priv);
+ UF_RTNL_LOCK();
+ if (err) {
+ unifi_error(priv, "unifi_siwessid: Join failed, status %d\n", err);
+ func_exit();
+ return convert_sme_error(err);
+ }
+
+ func_exit();
+ return 0;
+} /* unifi_siwessid() */
+
+
+static int
+unifi_giwessid(struct net_device *dev, struct iw_request_info *info,
+ union iwreq_data *wrqu, char *essid)
+{
+ netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev);
+ unifi_priv_t *priv = interfacePriv->privPtr;
+ struct iw_point *data = &wrqu->essid;
+ CsrWifiSmeConnectionInfo connectionInfo;
+ int r = 0;
+
+ func_enter();
+ unifi_trace(priv, UDBG2, "unifi_giwessid\n");
+ CHECK_INITED(priv);
+
+ if(interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_AP ||
+ interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_P2PGO) {
+ unifi_error(priv, "unifi_giwessid: not permitted in Mode %d\n",
+ interfacePriv->interfaceMode);
+ return -EPERM;
+ }
+
+ UF_RTNL_UNLOCK();
+ r = sme_mgt_connection_info_get(priv, &connectionInfo);
+ UF_RTNL_LOCK();
+
+ if (r == 0) {
+ data->length = connectionInfo.ssid.length;
+ strncpy(essid,
+ connectionInfo.ssid.ssid,
+ data->length);
+ data->flags = 1; /* active */
+
+ unifi_trace(priv, UDBG2, "unifi_giwessid: %.*s\n",
+ data->length, essid);
+ }
+
+ func_exit();
+
+ return 0;
+} /* unifi_giwessid() */
+
+
+static int
+unifi_siwrate(struct net_device *dev, struct iw_request_info *info,
+ union iwreq_data *wrqu, char *extra)
+{
+ netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev);
+ unifi_priv_t *priv = interfacePriv->privPtr;
+ struct iw_param *args = &wrqu->bitrate;
+ CsrWifiSmeMibConfig mibConfig;
+ int r;
+
+ func_enter();
+
+ CHECK_INITED(priv);
+ unifi_trace(priv, UDBG2, "unifi_siwrate\n");
+
+ /*
+ * If args->fixed == 0, value is max rate or -1 for best
+ * If args->fixed == 1, value is rate to set or -1 for best
+ * args->disabled and args->flags are not used in SIOCSIWRATE
+ */
+
+ /* Get, modify and set the MIB data */
+ UF_RTNL_UNLOCK();
+ r = sme_mgt_mib_config_get(priv, &mibConfig);
+ UF_RTNL_LOCK();
+ if (r) {
+ unifi_error(priv, "unifi_siwrate: Get CsrWifiSmeMibConfigValue failed.\n");
+ return r;
+ }
+
+ /* Default to auto rate algorithm */
+ /* in 500Kbit/s, 0 means auto */
+ mibConfig.unifiFixTxDataRate = 0;
+
+ if (args->value != -1) {
+ mibConfig.unifiFixTxDataRate = args->value / 500000;
+ }
+
+ /* 1 means rate is a maximum, 2 means rate is a set value */
+ if (args->fixed == 1) {
+ mibConfig.unifiFixMaxTxDataRate = 0;
+ } else {
+ mibConfig.unifiFixMaxTxDataRate = 1;
+ }
+ UF_RTNL_UNLOCK();
+ r = sme_mgt_mib_config_set(priv, &mibConfig);
+ UF_RTNL_LOCK();
+ if (r) {
+ unifi_error(priv, "unifi_siwrate: Set CsrWifiSmeMibConfigValue failed.\n");
+ return r;
+ }
+
+ func_exit();
+
+ return 0;
+} /* unifi_siwrate() */
+
+
+
+static int
+unifi_giwrate(struct net_device *dev, struct iw_request_info *info,
+ union iwreq_data *wrqu, char *extra)
+{
+ netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev);
+ unifi_priv_t *priv = interfacePriv->privPtr;
+ struct iw_param *args = &wrqu->bitrate;
+ int r;
+ int bitrate, flag;
+ CsrWifiSmeMibConfig mibConfig;
+ CsrWifiSmeConnectionStats connectionStats;
+
+ func_enter();
+ unifi_trace(priv, UDBG2, "unifi_giwrate\n");
+ CHECK_INITED(priv);
+
+ flag = 0;
+ bitrate = 0;
+ UF_RTNL_UNLOCK();
+ r = sme_mgt_mib_config_get(priv, &mibConfig);
+ UF_RTNL_LOCK();
+ if (r) {
+ unifi_error(priv, "unifi_giwrate: Get CsrWifiSmeMibConfigValue failed.\n");
+ return r;
+ }
+
+ bitrate = mibConfig.unifiFixTxDataRate;
+ flag = mibConfig.unifiFixMaxTxDataRate;
+
+ /* Used the value returned by the SME if MIB returns 0 */
+ if (bitrate == 0) {
+ UF_RTNL_UNLOCK();
+ r = sme_mgt_connection_stats_get(priv, &connectionStats);
+ UF_RTNL_LOCK();
+ /* Ignore errors, we may be disconnected */
+ if (r == 0) {
+ bitrate = connectionStats.unifiTxDataRate;
+ }
+ }
+
+ args->value = bitrate * 500000;
+ args->fixed = !flag;
+
+ func_exit();
+
+ return 0;
+} /* unifi_giwrate() */
+
+
+static int
+unifi_siwrts(struct net_device *dev, struct iw_request_info *info,
+ union iwreq_data *wrqu, char *extra)
+{
+ netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev);
+ unifi_priv_t *priv = interfacePriv->privPtr;
+ int val = wrqu->rts.value;
+ int r = 0;
+ CsrWifiSmeMibConfig mibConfig;
+
+ unifi_trace(priv, UDBG2, "unifi_siwrts\n");
+ CHECK_INITED(priv);
+
+ if (wrqu->rts.disabled) {
+ val = 2347;
+ }
+
+ if ( (val < 0) || (val > 2347) )
+ {
+ return -EINVAL;
+ }
+
+ /* Get, modify and set the MIB data */
+ UF_RTNL_UNLOCK();
+ r = sme_mgt_mib_config_get(priv, &mibConfig);
+ UF_RTNL_LOCK();
+ if (r) {
+ unifi_error(priv, "unifi_siwrts: Get CsrWifiSmeMibConfigValue failed.\n");
+ return r;
+ }
+ mibConfig.dot11RtsThreshold = val;
+ UF_RTNL_UNLOCK();
+ r = sme_mgt_mib_config_set(priv, &mibConfig);
+ UF_RTNL_LOCK();
+ if (r) {
+ unifi_error(priv, "unifi_siwrts: Set CsrWifiSmeMibConfigValue failed.\n");
+ return r;
+ }
+
+ return 0;
+}
+
+
+static int
+unifi_giwrts(struct net_device *dev, struct iw_request_info *info,
+ union iwreq_data *wrqu, char *extra)
+{
+ netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev);
+ unifi_priv_t *priv = interfacePriv->privPtr;
+ int r;
+ int rts_thresh;
+ CsrWifiSmeMibConfig mibConfig;
+
+ unifi_trace(priv, UDBG2, "unifi_giwrts\n");
+ CHECK_INITED(priv);
+
+ UF_RTNL_UNLOCK();
+ r = sme_mgt_mib_config_get(priv, &mibConfig);
+ UF_RTNL_LOCK();
+ if (r) {
+ unifi_error(priv, "unifi_giwrts: Get CsrWifiSmeMibConfigValue failed.\n");
+ return r;
+ }
+
+ rts_thresh = mibConfig.dot11RtsThreshold;
+ if (rts_thresh > 2347) {
+ rts_thresh = 2347;
+ }
+
+ wrqu->rts.value = rts_thresh;
+ wrqu->rts.disabled = (rts_thresh == 2347);
+ wrqu->rts.fixed = 1;
+
+ return 0;
+}
+
+
+static int
+unifi_siwfrag(struct net_device *dev, struct iw_request_info *info,
+ union iwreq_data *wrqu, char *extra)
+{
+ netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev);
+ unifi_priv_t *priv = interfacePriv->privPtr;
+ int val = wrqu->frag.value;
+ int r = 0;
+ CsrWifiSmeMibConfig mibConfig;
+
+ unifi_trace(priv, UDBG2, "unifi_siwfrag\n");
+ CHECK_INITED(priv);
+
+ if (wrqu->frag.disabled)
+ val = 2346;
+
+ if ( (val < 256) || (val > 2347) )
+ return -EINVAL;
+
+ /* Get, modify and set the MIB data */
+ UF_RTNL_UNLOCK();
+ r = sme_mgt_mib_config_get(priv, &mibConfig);
+ UF_RTNL_LOCK();
+ if (r) {
+ unifi_error(priv, "unifi_siwfrag: Get CsrWifiSmeMibConfigValue failed.\n");
+ return r;
+ }
+ /* Fragmentation Threashold must be even */
+ mibConfig.dot11FragmentationThreshold = (val & ~0x1);
+ UF_RTNL_UNLOCK();
+ r = sme_mgt_mib_config_set(priv, &mibConfig);
+ UF_RTNL_LOCK();
+ if (r) {
+ unifi_error(priv, "unifi_siwfrag: Set CsrWifiSmeMibConfigValue failed.\n");
+ return r;
+ }
+
+ return 0;
+}
+
+
+static int
+unifi_giwfrag(struct net_device *dev, struct iw_request_info *info,
+ union iwreq_data *wrqu, char *extra)
+{
+ netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev);
+ unifi_priv_t *priv = interfacePriv->privPtr;
+ int r;
+ int frag_thresh;
+ CsrWifiSmeMibConfig mibConfig;
+
+ unifi_trace(priv, UDBG2, "unifi_giwfrag\n");
+ CHECK_INITED(priv);
+
+ UF_RTNL_UNLOCK();
+ r = sme_mgt_mib_config_get(priv, &mibConfig);
+ UF_RTNL_LOCK();
+ if (r) {
+ unifi_error(priv, "unifi_giwfrag: Get CsrWifiSmeMibConfigValue failed.\n");
+ return r;
+ }
+
+ frag_thresh = mibConfig.dot11FragmentationThreshold;
+
+ /* Build the return structure */
+ wrqu->frag.value = frag_thresh;
+ wrqu->frag.disabled = (frag_thresh >= 2346);
+ wrqu->frag.fixed = 1;
+
+ return 0;
+}
+
+
+static int
+unifi_siwencode(struct net_device *dev, struct iw_request_info *info,
+ union iwreq_data *wrqu, char *extra)
+{
+ netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev);
+ unifi_priv_t *priv = interfacePriv->privPtr;
+ struct iw_point *erq = &wrqu->encoding;
+ int index;
+ int rc = 0;
+ int privacy = -1;
+ CsrWifiSmeKey sme_key;
+
+ func_enter();
+ unifi_trace(priv, UDBG2, "unifi_siwencode\n");
+
+ CHECK_INITED(priv);
+
+ if(interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_AP ||
+ interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_P2PGO) {
+ unifi_error(priv, "unifi_siwencode: not permitted in Mode %d\n",
+ interfacePriv->interfaceMode);
+ return -EPERM;
+ }
+
+
+ /*
+ * Key index is encoded in the flags.
+ * 0 - use current default,
+ * 1-4 - if a key value is given set that key
+ * if not use that key
+ */
+ index = (erq->flags & IW_ENCODE_INDEX); /* key number, 1-4 */
+ if ((index < 0) || (index > 4)) {
+ unifi_error(priv, "unifi_siwencode: Request to set an invalid key (index:%d)", index);
+ return -EINVAL;
+ }
+
+ /*
+ * Basic checking: do we have a key to set ?
+ * The IW_ENCODE_NOKEY flag is set when no key is present (only change flags),
+ * but older versions rely on sending a key id 1-4.
+ */
+ if (erq->length > 0) {
+
+ /* Check the size of the key */
+ if ((erq->length > LARGE_KEY_SIZE) || (erq->length < SMALL_KEY_SIZE)) {
+ unifi_error(priv, "unifi_siwencode: Request to set an invalid key (length:%d)",
+ erq->length);
+ return -EINVAL;
+ }
+
+ /* Check the index (none (i.e. 0) means use current) */
+ if ((index < 1) || (index > 4)) {
+ /* If we do not have a previous key, use 1 as default */
+ if (!priv->wep_tx_key_index) {
+ priv->wep_tx_key_index = 1;
+ }
+ index = priv->wep_tx_key_index;
+ }
+
+ /* If we didn't have a key and a valid index is set, we want to remember it*/
+ if (!priv->wep_tx_key_index) {
+ priv->wep_tx_key_index = index;
+ }
+
+ unifi_trace(priv, UDBG1, "Tx key Index is %d\n", priv->wep_tx_key_index);
+
+ privacy = 1;
+
+ /* Check if the key is not marked as invalid */
+ if ((erq->flags & IW_ENCODE_NOKEY) == 0) {
+
+ unifi_trace(priv, UDBG1, "New %s key (len=%d, index=%d)\n",
+ (priv->wep_tx_key_index == index) ? "tx" : "",
+ erq->length, index);
+
+ sme_key.wepTxKey = (priv->wep_tx_key_index == index);
+ if (priv->wep_tx_key_index == index) {
+ sme_key.keyType = CSR_WIFI_SME_KEY_TYPE_PAIRWISE;
+ } else {
+ sme_key.keyType = CSR_WIFI_SME_KEY_TYPE_GROUP;
+ }
+ /* Key index is zero based in SME but 1 based in wext */
+ sme_key.keyIndex = (index - 1);
+ sme_key.keyLength = erq->length;
+ sme_key.authenticator = 0;
+ memset(sme_key.address.a, 0xFF, ETH_ALEN);
+ memcpy(sme_key.key, extra, erq->length);
+
+ UF_RTNL_UNLOCK();
+ rc = sme_mgt_key(priv, &sme_key, CSR_WIFI_SME_LIST_ACTION_ADD);
+ UF_RTNL_LOCK();
+ if (rc) {
+ unifi_error(priv, "unifi_siwencode: Set key failed (%d)", rc);
+ return convert_sme_error(rc);
+ }
+
+ /* Store the key to be reported by the SIOCGIWENCODE handler */
+ priv->wep_keys[index - 1].len = erq->length;
+ memcpy(priv->wep_keys[index - 1].key, extra, erq->length);
+ }
+ } else {
+ /*
+ * No additional key data, so it must be a request to change the
+ * active key.
+ */
+ if (index != 0) {
+ unifi_trace(priv, UDBG1, "Tx key Index is %d\n", index - 1);
+
+ /* Store the index to be reported by the SIOCGIWENCODE handler */
+ priv->wep_tx_key_index = index;
+
+ sme_key.wepTxKey = 1;
+ sme_key.keyType = CSR_WIFI_SME_KEY_TYPE_PAIRWISE;
+
+ /* Key index is zero based in SME but 1 based in wext */
+ sme_key.keyIndex = (index - 1);
+ sme_key.keyLength = 0;
+ sme_key.authenticator = 0;
+ UF_RTNL_UNLOCK();
+ rc = sme_mgt_key(priv, &sme_key, CSR_WIFI_SME_LIST_ACTION_ADD);
+ UF_RTNL_LOCK();
+ if (rc) {
+ unifi_error(priv, "unifi_siwencode: Set key failed (%d)", rc);
+ return convert_sme_error(rc);
+ }
+
+ /* Turn on encryption */
+ privacy = 1;
+ }
+ }
+
+ /* Read the flags */
+ if (erq->flags & IW_ENCODE_DISABLED) {
+ /* disable encryption */
+ unifi_trace(priv, UDBG1, "disable WEP encryption\n");
+ privacy = 0;
+
+ priv->wep_tx_key_index = 0;
+
+ unifi_trace(priv, UDBG1, "IW_ENCODE_DISABLED: CSR_WIFI_SME_AUTH_MODE_80211_OPEN\n");
+ priv->connection_config.authModeMask = CSR_WIFI_SME_AUTH_MODE_80211_OPEN;
+ }
+
+ if (erq->flags & IW_ENCODE_RESTRICTED) {
+ /* Use shared key auth */
+ unifi_trace(priv, UDBG1, "IW_ENCODE_RESTRICTED: CSR_WIFI_SME_AUTH_MODE_80211_SHARED\n");
+ priv->connection_config.authModeMask = CSR_WIFI_SME_AUTH_MODE_80211_SHARED;
+
+ /* Turn on encryption */
+ privacy = 1;
+ }
+ if (erq->flags & IW_ENCODE_OPEN) {
+ unifi_trace(priv, UDBG1, "IW_ENCODE_OPEN: CSR_WIFI_SME_AUTH_MODE_80211_OPEN\n");
+ priv->connection_config.authModeMask = CSR_WIFI_SME_AUTH_MODE_80211_OPEN;
+ }
+
+ /* Commit the changes to flags if needed */
+ if (privacy != -1) {
+ priv->connection_config.privacyMode = privacy ? CSR_WIFI_SME_80211_PRIVACY_MODE_ENABLED : CSR_WIFI_SME_80211_PRIVACY_MODE_DISABLED;
+ priv->connection_config.encryptionModeMask = privacy ? (CSR_WIFI_SME_ENCRYPTION_CIPHER_PAIRWISE_WEP40 |
+ CSR_WIFI_SME_ENCRYPTION_CIPHER_PAIRWISE_WEP104 |
+ CSR_WIFI_SME_ENCRYPTION_CIPHER_GROUP_WEP40 |
+ CSR_WIFI_SME_ENCRYPTION_CIPHER_GROUP_WEP104) :
+ CSR_WIFI_SME_ENCRYPTION_CIPHER_NONE;
+ }
+
+ func_exit_r(rc);
+ return convert_sme_error(rc);
+
+} /* unifi_siwencode() */
+
+
+
+static int
+unifi_giwencode(struct net_device *dev, struct iw_request_info *info,
+ union iwreq_data *wrqu, char *extra)
+{
+ netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev);
+ unifi_priv_t *priv = interfacePriv->privPtr;
+ struct iw_point *erq = &wrqu->encoding;
+
+ unifi_trace(priv, UDBG2, "unifi_giwencode\n");
+
+ CHECK_INITED(priv);
+
+ if(interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_AP ||
+ interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_P2PGO) {
+ unifi_error(priv, "unifi_giwencode: not permitted in Mode %d\n",
+ interfacePriv->interfaceMode);
+ return -EPERM;
+ }
+
+
+ if (priv->connection_config.authModeMask == CSR_WIFI_SME_AUTH_MODE_80211_SHARED) {
+ erq->flags = IW_ENCODE_RESTRICTED;
+ }
+ else {
+ if (priv->connection_config.privacyMode == CSR_WIFI_SME_80211_PRIVACY_MODE_DISABLED) {
+ erq->flags = IW_ENCODE_DISABLED;
+ } else {
+ erq->flags = IW_ENCODE_OPEN;
+ }
+ }
+
+ erq->length = 0;
+
+ if (erq->flags != IW_ENCODE_DISABLED) {
+ int index = priv->wep_tx_key_index;
+
+ if ((index > 0) && (index <= NUM_WEPKEYS)) {
+ erq->flags |= (index & IW_ENCODE_INDEX);
+ erq->length = priv->wep_keys[index - 1].len;
+ memcpy(extra, priv->wep_keys[index - 1].key, erq->length);
+ } else {
+ unifi_notice(priv, "unifi_giwencode: Surprise, do not have a valid key index (%d)\n",
+ index);
+ }
+ }
+
+ return 0;
+} /* unifi_giwencode() */
+
+
+static int
+unifi_siwpower(struct net_device *dev, struct iw_request_info *info,
+ union iwreq_data *wrqu, char *extra)
+{
+ struct iw_param *args = &wrqu->power;
+ netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev);
+ unifi_priv_t *priv = interfacePriv->privPtr;
+ int listen_interval, wake_for_dtim;
+ int r = 0;
+ CsrWifiSmePowerConfig powerConfig;
+
+ unifi_trace(priv, UDBG2, "unifi_siwpower\n");
+
+ CHECK_INITED(priv);
+
+ if(interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_AP ||
+ interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_P2PGO) {
+ unifi_error(priv, "unifi_siwpower: not permitted in Mode %d\n",
+ interfacePriv->interfaceMode);
+ return -EPERM;
+ }
+
+ UF_RTNL_UNLOCK();
+ r = sme_mgt_power_config_get(priv, &powerConfig);
+ UF_RTNL_LOCK();
+ if (r) {
+ unifi_error(priv, "unifi_siwpower: Get unifi_PowerConfigValue failed.\n");
+ return r;
+ }
+
+ listen_interval = -1;
+ wake_for_dtim = -1;
+ if (args->disabled) {
+ powerConfig.powerSaveLevel = CSR_WIFI_SME_POWER_SAVE_LEVEL_LOW;
+ }
+ else
+ {
+ powerConfig.powerSaveLevel = CSR_WIFI_SME_POWER_SAVE_LEVEL_HIGH;
+
+ switch (args->flags & IW_POWER_TYPE) {
+ case 0:
+ /* not specified */
+ break;
+ case IW_POWER_PERIOD:
+ listen_interval = args->value / 1000;
+ break;
+ default:
+ return -EINVAL;
+ }
+
+ switch (args->flags & IW_POWER_MODE) {
+ case 0:
+ /* not specified */
+ break;
+ case IW_POWER_UNICAST_R:
+ /* not interested in broadcast packets */
+ wake_for_dtim = 0;
+ break;
+ case IW_POWER_ALL_R:
+ /* yes, we are interested in broadcast packets */
+ wake_for_dtim = 1;
+ break;
+ default:
+ return -EINVAL;
+ }
+ }
+
+ if (listen_interval > 0) {
+ powerConfig.listenIntervalTu = listen_interval;
+ unifi_trace(priv, UDBG4, "unifi_siwpower: new Listen Interval = %d.\n",
+ powerConfig.listenIntervalTu);
+ }
+
+ if (wake_for_dtim >= 0) {
+ powerConfig.rxDtims = wake_for_dtim;
+ }
+ UF_RTNL_UNLOCK();
+ r = sme_mgt_power_config_set(priv, &powerConfig);
+ UF_RTNL_LOCK();
+ if (r) {
+ unifi_error(priv, "unifi_siwpower: Set unifi_PowerConfigValue failed.\n");
+ return r;
+ }
+
+ return 0;
+} /* unifi_siwpower() */
+
+
+static int
+unifi_giwpower(struct net_device *dev, struct iw_request_info *info,
+ union iwreq_data *wrqu, char *extra)
+{
+ struct iw_param *args = &wrqu->power;
+ netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev);
+ unifi_priv_t *priv = interfacePriv->privPtr;
+ CsrWifiSmePowerConfig powerConfig;
+ int r;
+
+ unifi_trace(priv, UDBG2, "unifi_giwpower\n");
+
+ CHECK_INITED(priv);
+
+ if(interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_AP ||
+ interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_P2PGO) {
+ unifi_error(priv, "unifi_giwpower: not permitted in Mode %d\n",
+ interfacePriv->interfaceMode);
+ return -EPERM;
+ }
+
+
+ args->flags = 0;
+ UF_RTNL_UNLOCK();
+ r = sme_mgt_power_config_get(priv, &powerConfig);
+ UF_RTNL_LOCK();
+ if (r) {
+ unifi_error(priv, "unifi_giwpower: Get unifi_PowerConfigValue failed.\n");
+ return r;
+ }
+
+ unifi_trace(priv, UDBG4, "unifi_giwpower: mode=%d\n",
+ powerConfig.powerSaveLevel);
+
+ args->disabled = (powerConfig.powerSaveLevel == CSR_WIFI_SME_POWER_SAVE_LEVEL_LOW);
+ if (args->disabled) {
+ args->flags = 0;
+ return 0;
+ }
+
+ args->value = powerConfig.listenIntervalTu * 1000;
+ args->flags |= IW_POWER_PERIOD;
+
+ if (powerConfig.rxDtims) {
+ args->flags |= IW_POWER_ALL_R;
+ } else {
+ args->flags |= IW_POWER_UNICAST_R;
+ }
+
+ return 0;
+} /* unifi_giwpower() */
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * unifi_siwcommit - handler for SIOCSIWCOMMIT
+ *
+ * Apply all the parameters that have been set.
+ * In practice this means:
+ * - do a scan
+ * - join a network or start an AdHoc
+ * - authenticate and associate.
+ *
+ * Arguments:
+ * None.
+ *
+ * Returns:
+ * None.
+ * ---------------------------------------------------------------------------
+ */
+static int
+unifi_siwcommit(struct net_device *dev, struct iw_request_info *info,
+ union iwreq_data *wrqu, char *extra)
+{
+ return 0;
+} /* unifi_siwcommit() */
+
+
+
+static int
+unifi_siwmlme(struct net_device *dev, struct iw_request_info *info,
+ union iwreq_data *wrqu, char *extra)
+{
+ netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev);
+ unifi_priv_t *priv = interfacePriv->privPtr;
+ struct iw_mlme *mlme = (struct iw_mlme *)extra;
+ func_enter();
+
+ unifi_trace(priv, UDBG2, "unifi_siwmlme\n");
+ CHECK_INITED(priv);
+
+ if(interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_AP ||
+ interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_P2PGO) {
+ unifi_error(priv, "unifi_siwmlme: not permitted in Mode %d\n",
+ interfacePriv->interfaceMode);
+ return -EPERM;
+ }
+
+
+ switch (mlme->cmd) {
+ case IW_MLME_DEAUTH:
+ case IW_MLME_DISASSOC:
+ UF_RTNL_UNLOCK();
+ sme_mgt_disconnect(priv);
+ UF_RTNL_LOCK();
+ break;
+ default:
+ func_exit_r(-EOPNOTSUPP);
+ return -EOPNOTSUPP;
+ }
+
+ func_exit();
+ return 0;
+} /* unifi_siwmlme() */
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * unifi_siwgenie
+ * unifi_giwgenie
+ *
+ * WPA : Generic IEEE 802.11 information element (e.g., for WPA/RSN/WMM).
+ * Handlers for SIOCSIWGENIE, SIOCGIWGENIE - set/get generic IE
+ *
+ * The host program (e.g. wpa_supplicant) uses this call to set the
+ * additional IEs to accompany the next (Associate?) request.
+ *
+ * Arguments:
+ * None.
+ *
+ * Returns:
+ * None.
+ * Notes:
+ * From wireless.h:
+ * This ioctl uses struct iw_point and data buffer that includes IE id
+ * and len fields. More than one IE may be included in the
+ * request. Setting the generic IE to empty buffer (len=0) removes the
+ * generic IE from the driver.
+ * ---------------------------------------------------------------------------
+ */
+static int
+unifi_siwgenie(struct net_device *dev, struct iw_request_info *info,
+ union iwreq_data *wrqu, char *extra)
+{
+ netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev);
+ unifi_priv_t *priv = interfacePriv->privPtr;
+ int len;
+
+ func_enter();
+ unifi_trace(priv, UDBG2, "unifi_siwgenie\n");
+
+ if(interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_AP ||
+ interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_P2PGO) {
+ unifi_error(priv, "unifi_siwgenie: not permitted in Mode %d\n",
+ interfacePriv->interfaceMode);
+ return -EPERM;
+ }
+
+
+ if ( priv->connection_config.mlmeAssociateReqInformationElements) {
+ kfree( priv->connection_config.mlmeAssociateReqInformationElements);
+ }
+ priv->connection_config.mlmeAssociateReqInformationElementsLength = 0;
+ priv->connection_config.mlmeAssociateReqInformationElements = NULL;
+
+ len = wrqu->data.length;
+ if (len == 0) {
+ func_exit();
+ return 0;
+ }
+
+ priv->connection_config.mlmeAssociateReqInformationElements = kmalloc(len, GFP_KERNEL);
+ if (priv->connection_config.mlmeAssociateReqInformationElements == NULL) {
+ func_exit();
+ return -ENOMEM;
+ }
+
+ priv->connection_config.mlmeAssociateReqInformationElementsLength = len;
+ memcpy( priv->connection_config.mlmeAssociateReqInformationElements, extra, len);
+
+ func_exit();
+ return 0;
+} /* unifi_siwgenie() */
+
+
+static int
+unifi_giwgenie(struct net_device *dev, struct iw_request_info *info,
+ union iwreq_data *wrqu, char *extra)
+{
+ netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev);
+ unifi_priv_t *priv = interfacePriv->privPtr;
+ int len;
+
+ func_enter();
+ unifi_trace(priv, UDBG2, "unifi_giwgenie\n");
+
+ if(interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_AP ||
+ interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_P2PGO) {
+ unifi_error(priv, "unifi_giwgenie: not permitted in Mode %d\n",
+ interfacePriv->interfaceMode);
+ return -EPERM;
+ }
+
+
+ len = priv->connection_config.mlmeAssociateReqInformationElementsLength;
+
+ if (len == 0) {
+ wrqu->data.length = 0;
+ return 0;
+ }
+
+ if (wrqu->data.length < len) {
+ return -E2BIG;
+ }
+
+ wrqu->data.length = len;
+ memcpy(extra, priv->connection_config.mlmeAssociateReqInformationElements, len);
+
+ func_exit();
+ return 0;
+} /* unifi_giwgenie() */
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * unifi_siwauth
+ * unifi_giwauth
+ *
+ * Handlers for SIOCSIWAUTH, SIOCGIWAUTH
+ * Set/get various authentication parameters.
+ *
+ * Arguments:
+ *
+ *
+ * Returns:
+ * None.
+ * ---------------------------------------------------------------------------
+ */
+static int
+_unifi_siwauth(struct net_device *dev, struct iw_request_info *info,
+ union iwreq_data *wrqu, char *extra)
+{
+ netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev);
+ unifi_priv_t *priv = interfacePriv->privPtr;
+ CsrWifiSmeAuthModeMask new_auth;
+
+ func_enter();
+ unifi_trace(priv, UDBG2, "unifi_siwauth\n");
+
+ if(interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_AP ||
+ interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_P2PGO) {
+ unifi_error(priv, "unifi_siwauth: not permitted in Mode %d\n",
+ interfacePriv->interfaceMode);
+ return -EPERM;
+ }
+
+
+ /*
+ * This ioctl is safe to call even when UniFi is powered off.
+ * wpa_supplicant calls it to test whether we support WPA.
+ */
+
+ switch (wrqu->param.flags & IW_AUTH_INDEX) {
+
+ case IW_AUTH_WPA_ENABLED:
+ unifi_trace(priv, UDBG1, "IW_AUTH_WPA_ENABLED: %d\n", wrqu->param.value);
+
+ if (wrqu->param.value == 0) {
+ unifi_trace(priv, UDBG5, "IW_AUTH_WPA_ENABLED: CSR_WIFI_SME_AUTH_MODE_80211_OPEN\n");
+ priv->connection_config.authModeMask = CSR_WIFI_SME_AUTH_MODE_80211_OPEN;
+ }
+ break;
+
+ case IW_AUTH_PRIVACY_INVOKED:
+ unifi_trace(priv, UDBG1, "IW_AUTH_PRIVACY_INVOKED: %d\n", wrqu->param.value);
+
+ priv->connection_config.privacyMode = wrqu->param.value ? CSR_WIFI_SME_80211_PRIVACY_MODE_ENABLED : CSR_WIFI_SME_80211_PRIVACY_MODE_DISABLED;
+ if (wrqu->param.value == CSR_WIFI_SME_80211_PRIVACY_MODE_DISABLED)
+ {
+ priv->connection_config.encryptionModeMask = CSR_WIFI_SME_ENCRYPTION_CIPHER_NONE;
+ }
+ break;
+
+ case IW_AUTH_80211_AUTH_ALG:
+ /*
+ IW_AUTH_ALG_OPEN_SYSTEM 0x00000001
+ IW_AUTH_ALG_SHARED_KEY 0x00000002
+ IW_AUTH_ALG_LEAP 0x00000004
+ */
+ new_auth = 0;
+ if (wrqu->param.value & IW_AUTH_ALG_OPEN_SYSTEM) {
+ unifi_trace(priv, UDBG1, "IW_AUTH_80211_AUTH_ALG: %d (IW_AUTH_ALG_OPEN_SYSTEM)\n", wrqu->param.value);
+ new_auth |= CSR_WIFI_SME_AUTH_MODE_80211_OPEN;
+ }
+ if (wrqu->param.value & IW_AUTH_ALG_SHARED_KEY) {
+ unifi_trace(priv, UDBG1, "IW_AUTH_80211_AUTH_ALG: %d (IW_AUTH_ALG_SHARED_KEY)\n", wrqu->param.value);
+ new_auth |= CSR_WIFI_SME_AUTH_MODE_80211_SHARED;
+ }
+ if (wrqu->param.value & IW_AUTH_ALG_LEAP) {
+ /* Initial exchanges using open-system to set EAP */
+ unifi_trace(priv, UDBG1, "IW_AUTH_80211_AUTH_ALG: %d (IW_AUTH_ALG_LEAP)\n", wrqu->param.value);
+ new_auth |= CSR_WIFI_SME_AUTH_MODE_8021X_OTHER1X;
+ }
+ if (new_auth == 0) {
+ unifi_trace(priv, UDBG1, "IW_AUTH_80211_AUTH_ALG: invalid value %d\n",
+ wrqu->param.value);
+ return -EINVAL;
+ } else {
+ priv->connection_config.authModeMask = new_auth;
+ }
+ break;
+
+ case IW_AUTH_WPA_VERSION:
+ unifi_trace(priv, UDBG1, "IW_AUTH_WPA_VERSION: %d\n", wrqu->param.value);
+ priv->ignore_bssid_join = TRUE;
+ /*
+ IW_AUTH_WPA_VERSION_DISABLED 0x00000001
+ IW_AUTH_WPA_VERSION_WPA 0x00000002
+ IW_AUTH_WPA_VERSION_WPA2 0x00000004
+ */
+
+ if (!(wrqu->param.value & IW_AUTH_WPA_VERSION_DISABLED)) {
+
+ priv->connection_config.authModeMask = CSR_WIFI_SME_AUTH_MODE_80211_OPEN;
+
+ if (wrqu->param.value & IW_AUTH_WPA_VERSION_WPA) {
+ unifi_trace(priv, UDBG4, "IW_AUTH_WPA_VERSION: WPA, WPA-PSK\n");
+ priv->connection_config.authModeMask |= (CSR_WIFI_SME_AUTH_MODE_8021X_WPA | CSR_WIFI_SME_AUTH_MODE_8021X_WPAPSK);
+ }
+ if (wrqu->param.value & IW_AUTH_WPA_VERSION_WPA2) {
+ unifi_trace(priv, UDBG4, "IW_AUTH_WPA_VERSION: WPA2, WPA2-PSK\n");
+ priv->connection_config.authModeMask |= (CSR_WIFI_SME_AUTH_MODE_8021X_WPA2 | CSR_WIFI_SME_AUTH_MODE_8021X_WPA2PSK);
+ }
+ }
+ break;
+
+ case IW_AUTH_CIPHER_PAIRWISE:
+ unifi_trace(priv, UDBG1, "IW_AUTH_CIPHER_PAIRWISE: %d\n", wrqu->param.value);
+ /*
+ * one of:
+ IW_AUTH_CIPHER_NONE 0x00000001
+ IW_AUTH_CIPHER_WEP40 0x00000002
+ IW_AUTH_CIPHER_TKIP 0x00000004
+ IW_AUTH_CIPHER_CCMP 0x00000008
+ IW_AUTH_CIPHER_WEP104 0x00000010
+ */
+
+ priv->connection_config.encryptionModeMask = CSR_WIFI_SME_ENCRYPTION_CIPHER_NONE;
+
+ if (wrqu->param.value & IW_AUTH_CIPHER_WEP40) {
+ priv->connection_config.encryptionModeMask |=
+ CSR_WIFI_SME_ENCRYPTION_CIPHER_PAIRWISE_WEP40 | CSR_WIFI_SME_ENCRYPTION_CIPHER_GROUP_WEP40;
+ }
+ if (wrqu->param.value & IW_AUTH_CIPHER_WEP104) {
+ priv->connection_config.encryptionModeMask |=
+ CSR_WIFI_SME_ENCRYPTION_CIPHER_PAIRWISE_WEP104 | CSR_WIFI_SME_ENCRYPTION_CIPHER_GROUP_WEP104;
+ }
+ if (wrqu->param.value & IW_AUTH_CIPHER_TKIP) {
+ priv->connection_config.encryptionModeMask |=
+ CSR_WIFI_SME_ENCRYPTION_CIPHER_PAIRWISE_TKIP | CSR_WIFI_SME_ENCRYPTION_CIPHER_GROUP_TKIP;
+ }
+ if (wrqu->param.value & IW_AUTH_CIPHER_CCMP) {
+ priv->connection_config.encryptionModeMask |=
+ CSR_WIFI_SME_ENCRYPTION_CIPHER_PAIRWISE_CCMP | CSR_WIFI_SME_ENCRYPTION_CIPHER_GROUP_CCMP;
+ }
+
+ break;
+
+ case IW_AUTH_CIPHER_GROUP:
+ unifi_trace(priv, UDBG1, "IW_AUTH_CIPHER_GROUP: %d\n", wrqu->param.value);
+ /*
+ * Use the WPA version and the group cipher suite to set the permitted
+ * group key in the MIB. f/w uses this value to validate WPA and RSN IEs
+ * in the probe responses from the desired BSS(ID)
+ */
+
+ priv->connection_config.encryptionModeMask &= ~(CSR_WIFI_SME_ENCRYPTION_CIPHER_GROUP_WEP40 |
+ CSR_WIFI_SME_ENCRYPTION_CIPHER_GROUP_WEP104 |
+ CSR_WIFI_SME_ENCRYPTION_CIPHER_GROUP_TKIP |
+ CSR_WIFI_SME_ENCRYPTION_CIPHER_GROUP_CCMP);
+ if (wrqu->param.value & IW_AUTH_CIPHER_WEP40) {
+ priv->connection_config.encryptionModeMask |= CSR_WIFI_SME_ENCRYPTION_CIPHER_GROUP_WEP40;
+ }
+ if (wrqu->param.value & IW_AUTH_CIPHER_WEP104) {
+ priv->connection_config.encryptionModeMask |= CSR_WIFI_SME_ENCRYPTION_CIPHER_GROUP_WEP104;
+ }
+ if (wrqu->param.value & IW_AUTH_CIPHER_TKIP) {
+ priv->connection_config.encryptionModeMask |= CSR_WIFI_SME_ENCRYPTION_CIPHER_GROUP_TKIP;
+ }
+ if (wrqu->param.value & IW_AUTH_CIPHER_CCMP) {
+ priv->connection_config.encryptionModeMask |= CSR_WIFI_SME_ENCRYPTION_CIPHER_GROUP_CCMP;
+ }
+
+ break;
+
+ case IW_AUTH_KEY_MGMT:
+ unifi_trace(priv, UDBG1, "IW_AUTH_KEY_MGMT: %d\n", wrqu->param.value);
+ /*
+ IW_AUTH_KEY_MGMT_802_1X 1
+ IW_AUTH_KEY_MGMT_PSK 2
+ */
+ if (priv->connection_config.authModeMask & (CSR_WIFI_SME_AUTH_MODE_8021X_WPA | CSR_WIFI_SME_AUTH_MODE_8021X_WPAPSK)) {
+ /* Check for explicitly set mode. */
+ if (wrqu->param.value == IW_AUTH_KEY_MGMT_802_1X) {
+ priv->connection_config.authModeMask &= ~CSR_WIFI_SME_AUTH_MODE_8021X_WPAPSK;
+ }
+ if (wrqu->param.value == IW_AUTH_KEY_MGMT_PSK) {
+ priv->connection_config.authModeMask &= ~CSR_WIFI_SME_AUTH_MODE_8021X_WPA;
+ }
+ unifi_trace(priv, UDBG5, "IW_AUTH_KEY_MGMT: WPA: %d\n",
+ priv->connection_config.authModeMask);
+ }
+ if (priv->connection_config.authModeMask & (CSR_WIFI_SME_AUTH_MODE_8021X_WPA2 | CSR_WIFI_SME_AUTH_MODE_8021X_WPA2PSK)) {
+ /* Check for explicitly set mode. */
+ if (wrqu->param.value == IW_AUTH_KEY_MGMT_802_1X) {
+ priv->connection_config.authModeMask &= ~CSR_WIFI_SME_AUTH_MODE_8021X_WPA2PSK;
+ }
+ if (wrqu->param.value == IW_AUTH_KEY_MGMT_PSK) {
+ priv->connection_config.authModeMask &= ~CSR_WIFI_SME_AUTH_MODE_8021X_WPA2;
+ }
+ unifi_trace(priv, UDBG5, "IW_AUTH_KEY_MGMT: WPA2: %d\n",
+ priv->connection_config.authModeMask);
+ }
+
+ break;
+ case IW_AUTH_TKIP_COUNTERMEASURES:
+ /*
+ * Set to true at the start of the 60 second backup-off period
+ * following 2 MichaelMIC failures within 60s.
+ */
+ unifi_trace(priv, UDBG1, "IW_AUTH_TKIP_COUNTERMEASURES: %d\n", wrqu->param.value);
+ break;
+
+ case IW_AUTH_DROP_UNENCRYPTED:
+ /*
+ * Set to true on init.
+ * Set to false just before associate if encryption will not be
+ * required.
+ *
+ * Note this is not the same as the 802.1X controlled port
+ */
+ unifi_trace(priv, UDBG1, "IW_AUTH_DROP_UNENCRYPTED: %d\n", wrqu->param.value);
+ break;
+
+ case IW_AUTH_RX_UNENCRYPTED_EAPOL:
+ /*
+ * This is set by wpa_supplicant to allow unencrypted EAPOL messages
+ * even if pairwise keys are set when not using WPA. IEEE 802.1X
+ * specifies that these frames are not encrypted, but WPA encrypts
+ * them when pairwise keys are in use.
+ * I think the UniFi f/w handles this decision for us.
+ */
+ unifi_trace(priv, UDBG1, "IW_AUTH_RX_UNENCRYPTED_EAPOL: %d\n", wrqu->param.value);
+ break;
+
+ case IW_AUTH_ROAMING_CONTROL:
+ unifi_trace(priv, UDBG1, "IW_AUTH_ROAMING_CONTROL: %d\n", wrqu->param.value);
+ break;
+
+ default:
+ unifi_trace(priv, UDBG1, "Unsupported auth param %d to 0x%X\n",
+ wrqu->param.flags & IW_AUTH_INDEX,
+ wrqu->param.value);
+ return -EOPNOTSUPP;
+ }
+
+ unifi_trace(priv, UDBG2, "authModeMask = %d", priv->connection_config.authModeMask);
+ func_exit();
+
+ return 0;
+} /* _unifi_siwauth() */
+
+
+static int
+unifi_siwauth(struct net_device *dev, struct iw_request_info *info,
+ union iwreq_data *wrqu, char *extra)
+{
+ int err = 0;
+
+ UF_RTNL_UNLOCK();
+ err = _unifi_siwauth(dev, info, wrqu, extra);
+ UF_RTNL_LOCK();
+
+ return err;
+} /* unifi_siwauth() */
+
+
+static int
+unifi_giwauth(struct net_device *dev, struct iw_request_info *info,
+ union iwreq_data *wrqu, char *extra)
+{
+ unifi_trace(NULL, UDBG2, "unifi_giwauth\n");
+ return -EOPNOTSUPP;
+} /* unifi_giwauth() */
+
+/*
+ * ---------------------------------------------------------------------------
+ * unifi_siwencodeext
+ * unifi_giwencodeext
+ *
+ * Handlers for SIOCSIWENCODEEXT, SIOCGIWENCODEEXT - set/get
+ * encoding token & mode
+ *
+ * Arguments:
+ * None.
+ *
+ * Returns:
+ * None.
+ *
+ * Notes:
+ * For WPA/WPA2 we don't take note of the IW_ENCODE_EXT_SET_TX_KEY flag.
+ * This flag means "use this key to encode transmissions"; we just
+ * assume only one key will be set and that is the one to use.
+ * ---------------------------------------------------------------------------
+ */
+static int
+_unifi_siwencodeext(struct net_device *dev, struct iw_request_info *info,
+ union iwreq_data *wrqu, char *extra)
+{
+ netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev);
+ unifi_priv_t *priv = interfacePriv->privPtr;
+ struct iw_encode_ext *ext = (struct iw_encode_ext *)extra;
+ int r = 0;
+ unsigned char *keydata;
+ unsigned char tkip_key[32];
+ int keyid;
+ unsigned char *a = (unsigned char *)ext->addr.sa_data;
+ CsrWifiSmeKey sme_key;
+ CsrWifiSmeKeyType key_type;
+
+ func_enter();
+
+ CHECK_INITED(priv);
+
+ if(interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_AP ||
+ interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_P2PGO) {
+ unifi_error(priv, "unifi_siwencodeext: not permitted in Mode %d\n",
+ interfacePriv->interfaceMode);
+ return -EPERM;
+ }
+
+
+ unifi_trace(priv, UDBG1, "siwencodeext: flags=0x%X, alg=%d, ext_flags=0x%X, len=%d, index=%d,\n",
+ wrqu->encoding.flags, ext->alg, ext->ext_flags,
+ ext->key_len, (wrqu->encoding.flags & IW_ENCODE_INDEX));
+ unifi_trace(priv, UDBG3, " addr=%pM\n", a);
+
+ if ((ext->key_len == 0) && (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)) {
+ /* This means use a different key (given by key_idx) for Tx. */
+ /* NYI */
+ unifi_trace(priv, UDBG1, KERN_ERR "unifi_siwencodeext: NYI should change tx key id here!!\n");
+ return -ENOTSUPP;
+ }
+
+ memset(&sme_key, 0, sizeof(sme_key));
+
+ keydata = (unsigned char *)(ext + 1);
+ keyid = (wrqu->encoding.flags & IW_ENCODE_INDEX);
+
+ /*
+ * Check for request to delete keys for an address.
+ */
+ /* Pick out request for no privacy. */
+ if (ext->alg == IW_ENCODE_ALG_NONE) {
+
+ unifi_trace(priv, UDBG1, "Deleting %s key %d\n",
+ (ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) ? "GROUP" : "PAIRWISE",
+ keyid);
+
+ if (ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) {
+ sme_key.keyType = CSR_WIFI_SME_KEY_TYPE_GROUP;
+ } else {
+ sme_key.keyType = CSR_WIFI_SME_KEY_TYPE_PAIRWISE;
+ }
+ sme_key.keyIndex = (keyid - 1);
+ sme_key.keyLength = 0;
+ sme_key.authenticator = 0;
+ memcpy(sme_key.address.a, a, ETH_ALEN);
+ UF_RTNL_UNLOCK();
+ r = sme_mgt_key(priv, &sme_key, CSR_WIFI_SME_LIST_ACTION_REMOVE);
+ UF_RTNL_LOCK();
+ if (r) {
+ unifi_error(priv, "Delete key request was rejected with result %d\n", r);
+ return convert_sme_error(r);
+ }
+
+ return 0;
+ }
+
+ /*
+ * Request is to set a key, not delete
+ */
+
+ /* Pick out WEP and use set_wep_key(). */
+ if (ext->alg == IW_ENCODE_ALG_WEP) {
+ /* WEP-40, WEP-104 */
+
+ /* Check for valid key length */
+ if (!((ext->key_len == 5) || (ext->key_len == 13))) {
+ unifi_trace(priv, UDBG1, KERN_ERR "Invalid length for WEP key: %d\n", ext->key_len);
+ return -EINVAL;
+ }
+
+ unifi_trace(priv, UDBG1, "Setting WEP key %d tx:%d\n",
+ keyid, ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY);
+
+ if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY) {
+ sme_key.wepTxKey = TRUE;
+ sme_key.keyType = CSR_WIFI_SME_KEY_TYPE_PAIRWISE;
+ } else {
+ sme_key.wepTxKey = FALSE;
+ sme_key.keyType = CSR_WIFI_SME_KEY_TYPE_GROUP;
+ }
+ sme_key.keyIndex = (keyid - 1);
+ sme_key.keyLength = ext->key_len;
+ sme_key.authenticator = 0;
+ memset(sme_key.address.a, 0xFF, ETH_ALEN);
+ memcpy(sme_key.key, keydata, ext->key_len);
+ UF_RTNL_UNLOCK();
+ r = sme_mgt_key(priv, &sme_key, CSR_WIFI_SME_LIST_ACTION_ADD);
+ UF_RTNL_LOCK();
+ if (r) {
+ unifi_error(priv, "siwencodeext: Set key failed (%d)", r);
+ return convert_sme_error(r);
+ }
+
+ return 0;
+ }
+
+ /*
+ *
+ * If we reach here, we are dealing with a WPA/WPA2 key
+ *
+ */
+ if (ext->key_len > 32) {
+ return -EINVAL;
+ }
+
+ /*
+ * TKIP keys from wpa_supplicant need swapping.
+ * What about other supplicants (when they come along)?
+ */
+ if ((ext->alg == IW_ENCODE_ALG_TKIP) && (ext->key_len == 32)) {
+ memcpy(tkip_key, keydata, 16);
+ memcpy(tkip_key + 16, keydata + 24, 8);
+ memcpy(tkip_key + 24, keydata + 16, 8);
+ keydata = tkip_key;
+ }
+
+ key_type = (ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) ?
+ CSR_WIFI_SME_KEY_TYPE_GROUP : /* Group Key */
+ CSR_WIFI_SME_KEY_TYPE_PAIRWISE; /* Pairwise Key */
+
+ sme_key.keyType = key_type;
+ sme_key.keyIndex = (keyid - 1);
+ sme_key.keyLength = ext->key_len;
+ sme_key.authenticator = 0;
+ memcpy(sme_key.address.a, ext->addr.sa_data, ETH_ALEN);
+ if (ext->ext_flags & IW_ENCODE_EXT_RX_SEQ_VALID) {
+
+ unifi_trace(priv, UDBG5, "RSC first 6 bytes = %02X:%02X:%02X:%02X:%02X:%02X\n",
+ ext->rx_seq[0], ext->rx_seq[1], ext->rx_seq[2], ext->rx_seq[3], ext->rx_seq[4], ext->rx_seq[5]);
+
+ /* memcpy((u8*)(&sme_key.keyRsc), ext->rx_seq, 8); */
+ sme_key.keyRsc[0] = ext->rx_seq[1] << 8 | ext->rx_seq[0];
+ sme_key.keyRsc[1] = ext->rx_seq[3] << 8 | ext->rx_seq[2];
+ sme_key.keyRsc[2] = ext->rx_seq[5] << 8 | ext->rx_seq[4];
+ sme_key.keyRsc[3] = ext->rx_seq[7] << 8 | ext->rx_seq[6];
+
+ }
+
+ memcpy(sme_key.key, keydata, ext->key_len);
+ UF_RTNL_UNLOCK();
+ r = sme_mgt_key(priv, &sme_key, CSR_WIFI_SME_LIST_ACTION_ADD);
+ UF_RTNL_LOCK();
+ if (r) {
+ unifi_error(priv, "SETKEYS request was rejected with result %d\n", r);
+ return convert_sme_error(r);
+ }
+
+ func_exit();
+ return r;
+} /* _unifi_siwencodeext() */
+
+
+static int
+unifi_siwencodeext(struct net_device *dev, struct iw_request_info *info,
+ union iwreq_data *wrqu, char *extra)
+{
+ int err = 0;
+
+ err = _unifi_siwencodeext(dev, info, wrqu, extra);
+
+ return err;
+} /* unifi_siwencodeext() */
+
+
+static int
+unifi_giwencodeext(struct net_device *dev, struct iw_request_info *info,
+ union iwreq_data *wrqu, char *extra)
+{
+ return -EOPNOTSUPP;
+} /* unifi_giwencodeext() */
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * unifi_siwpmksa
+ *
+ * SIOCSIWPMKSA - PMKSA cache operation
+ * The caller passes a pmksa structure:
+ * - cmd one of ADD, REMOVE, FLUSH
+ * - bssid MAC address
+ * - pmkid ID string (16 bytes)
+ *
+ * Arguments:
+ * None.
+ *
+ * Returns:
+ * None.
+ *
+ * Notes:
+ * This is not needed since we provide a siwgenie method.
+ * ---------------------------------------------------------------------------
+ */
+#define UNIFI_PMKID_KEY_SIZE 16
+static int
+unifi_siwpmksa(struct net_device *dev, struct iw_request_info *info,
+ union iwreq_data *wrqu, char *extra)
+{
+ netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev);
+ unifi_priv_t *priv = interfacePriv->privPtr;
+ struct iw_pmksa *pmksa = (struct iw_pmksa *)extra;
+ CsrResult r = 0;
+ CsrWifiSmePmkidList pmkid_list;
+ CsrWifiSmePmkid pmkid;
+ CsrWifiSmeListAction action;
+
+ CHECK_INITED(priv);
+
+ if(interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_AP ||
+ interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_P2PGO) {
+ unifi_error(priv, "unifi_siwpmksa: not permitted in Mode %d\n",
+ interfacePriv->interfaceMode);
+ return -EPERM;
+ }
+
+
+ unifi_trace(priv, UDBG1, "SIWPMKSA: cmd %d, %pM\n", pmksa->cmd,
+ pmksa->bssid.sa_data);
+
+ pmkid_list.pmkids = NULL;
+ switch (pmksa->cmd) {
+ case IW_PMKSA_ADD:
+ pmkid_list.pmkids = &pmkid;
+ action = CSR_WIFI_SME_LIST_ACTION_ADD;
+ pmkid_list.pmkidsCount = 1;
+ memcpy(pmkid.bssid.a, pmksa->bssid.sa_data, ETH_ALEN);
+ memcpy(pmkid.pmkid, pmksa->pmkid, UNIFI_PMKID_KEY_SIZE);
+ break;
+ case IW_PMKSA_REMOVE:
+ pmkid_list.pmkids = &pmkid;
+ action = CSR_WIFI_SME_LIST_ACTION_REMOVE;
+ pmkid_list.pmkidsCount = 1;
+ memcpy(pmkid.bssid.a, pmksa->bssid.sa_data, ETH_ALEN);
+ memcpy(pmkid.pmkid, pmksa->pmkid, UNIFI_PMKID_KEY_SIZE);
+ break;
+ case IW_PMKSA_FLUSH:
+ /* Replace current PMKID's with an empty list */
+ pmkid_list.pmkidsCount = 0;
+ action = CSR_WIFI_SME_LIST_ACTION_FLUSH;
+ break;
+ default:
+ unifi_notice(priv, "SIWPMKSA: Unknown command (0x%x)\n", pmksa->cmd);
+ return -EINVAL;
+ }
+
+ /* Set the Value the pmkid's will have 1 added OR 1 removed OR be cleared at this point */
+ UF_RTNL_UNLOCK();
+ r = sme_mgt_pmkid(priv, action, &pmkid_list);
+ UF_RTNL_LOCK();
+ if (r) {
+ unifi_error(priv, "SIWPMKSA: Set PMKID's Failed.\n");
+ }
+
+ return r;
+
+} /* unifi_siwpmksa() */
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * unifi_get_wireless_stats
+ *
+ * get_wireless_stats method for Linux wireless extensions.
+ *
+ * Arguments:
+ * dev Pointer to associated netdevice.
+ *
+ * Returns:
+ * Pointer to iw_statistics struct.
+ * ---------------------------------------------------------------------------
+ */
+struct iw_statistics *
+unifi_get_wireless_stats(struct net_device *dev)
+{
+ netInterface_priv_t *interfacePriv = (netInterface_priv_t *)netdev_priv(dev);
+ unifi_priv_t *priv = interfacePriv->privPtr;
+
+ if (priv->init_progress != UNIFI_INIT_COMPLETED) {
+ return NULL;
+ }
+
+ return &priv->wext_wireless_stats;
+} /* unifi_get_wireless_stats() */
+
+
+/*
+ * Structures to export the Wireless Handlers
+ */
+
+static const struct iw_priv_args unifi_private_args[] = {
+ /*{ cmd, set_args, get_args, name } */
+ { SIOCIWS80211POWERSAVEPRIV, IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 1,
+ IW_PRIV_TYPE_NONE, "iwprivs80211ps" },
+ { SIOCIWG80211POWERSAVEPRIV, IW_PRIV_TYPE_NONE,
+ IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED | IWPRIV_POWER_SAVE_MAX_STRING, "iwprivg80211ps" },
+ { SIOCIWS80211RELOADDEFAULTSPRIV, IW_PRIV_TYPE_NONE,
+ IW_PRIV_TYPE_NONE, "iwprivsdefs" },
+ { SIOCIWSSMEDEBUGPRIV, IW_PRIV_TYPE_CHAR | IWPRIV_SME_DEBUG_MAX_STRING, IW_PRIV_TYPE_NONE, "iwprivssmedebug" },
+#ifdef CSR_WIFI_SECURITY_WAPI_ENABLE
+ { SIOCIWSCONFWAPIPRIV, IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 1,
+ IW_PRIV_TYPE_NONE, "iwprivsconfwapi" },
+ { SIOCIWSWAPIKEYPRIV, IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | sizeof(unifiio_wapi_key_t),
+ IW_PRIV_TYPE_NONE, "iwprivswpikey" },
+#endif
+#ifdef CSR_SUPPORT_WEXT_AP
+ { SIOCIWSAPCFGPRIV, IW_PRIV_TYPE_CHAR | 256, IW_PRIV_TYPE_NONE, "AP_SET_CFG" },
+ { SIOCIWSAPSTARTPRIV, 0,IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED|IWPRIV_SME_MAX_STRING,"AP_BSS_START" },
+ { SIOCIWSAPSTOPPRIV, IW_PRIV_TYPE_CHAR |IW_PRIV_SIZE_FIXED|0,
+ IW_PRIV_TYPE_CHAR |IW_PRIV_SIZE_FIXED|0, "AP_BSS_STOP" },
+#ifdef ANDROID_BUILD
+ { SIOCIWSFWRELOADPRIV, IW_PRIV_TYPE_CHAR |256,
+ IW_PRIV_TYPE_CHAR |IW_PRIV_SIZE_FIXED|0, "WL_FW_RELOAD" },
+ { SIOCIWSSTACKSTART, 0,
+ IW_PRIV_TYPE_CHAR |IW_PRIV_SIZE_FIXED|IWPRIV_SME_MAX_STRING, "START" },
+ { SIOCIWSSTACKSTOP, 0,
+ IW_PRIV_TYPE_CHAR |IW_PRIV_SIZE_FIXED|IWPRIV_SME_MAX_STRING, "STOP" },
+#endif /* ANDROID_BUILD */
+#endif /* CSR_SUPPORT_WEXT_AP */
+};
+
+static const iw_handler unifi_handler[] =
+{
+ (iw_handler) unifi_siwcommit, /* SIOCSIWCOMMIT */
+ (iw_handler) unifi_giwname, /* SIOCGIWNAME */
+ (iw_handler) NULL, /* SIOCSIWNWID */
+ (iw_handler) NULL, /* SIOCGIWNWID */
+ (iw_handler) unifi_siwfreq, /* SIOCSIWFREQ */
+ (iw_handler) unifi_giwfreq, /* SIOCGIWFREQ */
+ (iw_handler) unifi_siwmode, /* SIOCSIWMODE */
+ (iw_handler) unifi_giwmode, /* SIOCGIWMODE */
+ (iw_handler) NULL, /* SIOCSIWSENS */
+ (iw_handler) NULL, /* SIOCGIWSENS */
+ (iw_handler) NULL, /* SIOCSIWRANGE */
+ (iw_handler) unifi_giwrange, /* SIOCGIWRANGE */
+ (iw_handler) NULL, /* SIOCSIWPRIV */
+ (iw_handler) NULL, /* SIOCGIWPRIV */
+ (iw_handler) NULL, /* SIOCSIWSTATS */
+ (iw_handler) NULL, /* SIOCGIWSTATS */
+ (iw_handler) NULL, /* SIOCSIWSPY */
+ (iw_handler) NULL, /* SIOCGIWSPY */
+ (iw_handler) NULL, /* SIOCSIWTHRSPY */
+ (iw_handler) NULL, /* SIOCGIWTHRSPY */
+ (iw_handler) unifi_siwap, /* SIOCSIWAP */
+ (iw_handler) unifi_giwap, /* SIOCGIWAP */
+#if WIRELESS_EXT > 17
+ /* WPA : IEEE 802.11 MLME requests */
+ unifi_siwmlme, /* SIOCSIWMLME, request MLME operation */
+#else
+ (iw_handler) NULL, /* -- hole -- */
+#endif
+ (iw_handler) NULL, /* SIOCGIWAPLIST */
+ (iw_handler) unifi_siwscan, /* SIOCSIWSCAN */
+ (iw_handler) unifi_giwscan, /* SIOCGIWSCAN */
+ (iw_handler) unifi_siwessid, /* SIOCSIWESSID */
+ (iw_handler) unifi_giwessid, /* SIOCGIWESSID */
+ (iw_handler) NULL, /* SIOCSIWNICKN */
+ (iw_handler) NULL, /* SIOCGIWNICKN */
+ (iw_handler) NULL, /* -- hole -- */
+ (iw_handler) NULL, /* -- hole -- */
+ unifi_siwrate, /* SIOCSIWRATE */
+ unifi_giwrate, /* SIOCGIWRATE */
+ unifi_siwrts, /* SIOCSIWRTS */
+ unifi_giwrts, /* SIOCGIWRTS */
+ unifi_siwfrag, /* SIOCSIWFRAG */
+ unifi_giwfrag, /* SIOCGIWFRAG */
+ (iw_handler) NULL, /* SIOCSIWTXPOW */
+ (iw_handler) NULL, /* SIOCGIWTXPOW */
+ (iw_handler) NULL, /* SIOCSIWRETRY */
+ (iw_handler) NULL, /* SIOCGIWRETRY */
+ unifi_siwencode, /* SIOCSIWENCODE */
+ unifi_giwencode, /* SIOCGIWENCODE */
+ unifi_siwpower, /* SIOCSIWPOWER */
+ unifi_giwpower, /* SIOCGIWPOWER */
+#if WIRELESS_EXT > 17
+ (iw_handler) NULL, /* -- hole -- */
+ (iw_handler) NULL, /* -- hole -- */
+
+ /* WPA : Generic IEEE 802.11 informatiom element (e.g., for WPA/RSN/WMM). */
+ unifi_siwgenie, /* SIOCSIWGENIE */ /* set generic IE */
+ unifi_giwgenie, /* SIOCGIWGENIE */ /* get generic IE */
+
+ /* WPA : Authentication mode parameters */
+ unifi_siwauth, /* SIOCSIWAUTH */ /* set authentication mode params */
+ unifi_giwauth, /* SIOCGIWAUTH */ /* get authentication mode params */
+
+ /* WPA : Extended version of encoding configuration */
+ unifi_siwencodeext, /* SIOCSIWENCODEEXT */ /* set encoding token & mode */
+ unifi_giwencodeext, /* SIOCGIWENCODEEXT */ /* get encoding token & mode */
+
+ /* WPA2 : PMKSA cache management */
+ unifi_siwpmksa, /* SIOCSIWPMKSA */ /* PMKSA cache operation */
+ (iw_handler) NULL, /* -- hole -- */
+#endif /* WIRELESS_EXT > 17 */
+};
+
+
+static const iw_handler unifi_private_handler[] =
+{
+ iwprivs80211ps, /* SIOCIWFIRSTPRIV */
+ iwprivg80211ps, /* SIOCIWFIRSTPRIV + 1 */
+ iwprivsdefs, /* SIOCIWFIRSTPRIV + 2 */
+ (iw_handler) NULL,
+#ifdef CSR_WIFI_SECURITY_WAPI_ENABLE
+ iwprivsconfwapi, /* SIOCIWFIRSTPRIV + 4 */
+ (iw_handler) NULL, /* SIOCIWFIRSTPRIV + 5 */
+ iwprivswpikey, /* SIOCIWFIRSTPRIV + 6 */
+#else
+ (iw_handler) NULL,
+ (iw_handler) NULL,
+ (iw_handler) NULL,
+#endif
+ (iw_handler) NULL,
+ iwprivssmedebug, /* SIOCIWFIRSTPRIV + 8 */
+#ifdef CSR_SUPPORT_WEXT_AP
+ (iw_handler) NULL,
+ iwprivsapconfig,
+ (iw_handler) NULL,
+ iwprivsapstart,
+ (iw_handler) NULL,
+ iwprivsapstop,
+ (iw_handler) NULL,
+#ifdef ANDROID_BUILD
+ iwprivsapfwreload,
+ (iw_handler) NULL,
+ iwprivsstackstart,
+ (iw_handler) NULL,
+ iwprivsstackstop,
+#else
+ (iw_handler) NULL,
+ (iw_handler) NULL,
+ (iw_handler) NULL,
+ (iw_handler) NULL,
+ (iw_handler) NULL,
+#endif /* ANDROID_BUILD */
+#else
+ (iw_handler) NULL,
+ (iw_handler) NULL,
+ (iw_handler) NULL,
+ (iw_handler) NULL,
+ (iw_handler) NULL,
+ (iw_handler) NULL,
+ (iw_handler) NULL,
+ (iw_handler) NULL,
+ (iw_handler) NULL,
+ (iw_handler) NULL,
+ (iw_handler) NULL,
+ (iw_handler) NULL,
+#endif /* CSR_SUPPORT_WEXT_AP */
+};
+
+struct iw_handler_def unifi_iw_handler_def =
+{
+ .num_standard = sizeof(unifi_handler) / sizeof(iw_handler),
+ .num_private = sizeof(unifi_private_handler) / sizeof(iw_handler),
+ .num_private_args = sizeof(unifi_private_args) / sizeof(struct iw_priv_args),
+ .standard = (iw_handler *) unifi_handler,
+ .private = (iw_handler *) unifi_private_handler,
+ .private_args = (struct iw_priv_args *) unifi_private_args,
+#if IW_HANDLER_VERSION >= 6
+ .get_wireless_stats = unifi_get_wireless_stats,
+#endif
+};
+
+
diff --git a/drivers/staging/csr/ul_int.c b/drivers/staging/csr/ul_int.c
new file mode 100644
index 000000000000..46d3507fd8f1
--- /dev/null
+++ b/drivers/staging/csr/ul_int.c
@@ -0,0 +1,532 @@
+/*
+ * ***************************************************************************
+ * FILE: ul_int.c
+ *
+ * PURPOSE:
+ * Manage list of client applications using UniFi.
+ *
+ * Copyright (C) 2006-2009 by Cambridge Silicon Radio Ltd.
+ *
+ * Refer to LICENSE.txt included with this source code for details on
+ * the license terms.
+ *
+ * ***************************************************************************
+ */
+#include "csr_wifi_hip_unifi.h"
+#include "csr_wifi_hip_conversions.h"
+#include "unifi_priv.h"
+#include "unifiio.h"
+#include "unifi_os.h"
+
+static void free_bulkdata_buffers(unifi_priv_t *priv, bulk_data_param_t *bulkdata);
+static void reset_driver_status(unifi_priv_t *priv);
+
+/*
+ * ---------------------------------------------------------------------------
+ * ul_init_clients
+ *
+ * Initialise the clients array to empty.
+ *
+ * Arguments:
+ * priv Pointer to device private context struct
+ *
+ * Returns:
+ * None.
+ *
+ * Notes:
+ * This function needs to be called before priv is stored in
+ * Unifi_instances[].
+ * ---------------------------------------------------------------------------
+ */
+void
+ul_init_clients(unifi_priv_t *priv)
+{
+ int id;
+ ul_client_t *ul_clients;
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 37)
+ sema_init(&priv->udi_logging_mutex, 1);
+#else
+ init_MUTEX(&priv->udi_logging_mutex);
+#endif
+ priv->logging_client = NULL;
+
+ ul_clients = priv->ul_clients;
+
+ for (id = 0; id < MAX_UDI_CLIENTS; id++) {
+ memset(&ul_clients[id], 0, sizeof(ul_client_t));
+
+ ul_clients[id].client_id = id;
+ ul_clients[id].sender_id = UDI_SENDER_ID_BASE + (id << UDI_SENDER_ID_SHIFT);
+ ul_clients[id].instance = -1;
+ ul_clients[id].event_hook = NULL;
+
+ INIT_LIST_HEAD(&ul_clients[id].udi_log);
+ init_waitqueue_head(&ul_clients[id].udi_wq);
+ sema_init(&ul_clients[id].udi_sem, 1);
+
+ ul_clients[id].wake_up_wq_id = 0;
+ ul_clients[id].seq_no = 0;
+ ul_clients[id].wake_seq_no = 0;
+ ul_clients[id].snap_filter.count = 0;
+ }
+} /* ul_init_clients() */
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * ul_register_client
+ *
+ * This function registers a new ul client.
+ *
+ * Arguments:
+ * priv Pointer to device private context struct
+ * configuration Special configuration for the client.
+ * udi_event_clbk Callback for receiving event from unifi.
+ *
+ * Returns:
+ * 0 if a new clients is registered, -1 otherwise.
+ * ---------------------------------------------------------------------------
+ */
+ul_client_t *
+ul_register_client(unifi_priv_t *priv, unsigned int configuration,
+ udi_event_t udi_event_clbk)
+{
+ unsigned char id, ref;
+ ul_client_t *ul_clients;
+
+ ul_clients = priv->ul_clients;
+
+ /* check for an unused entry */
+ for (id = 0; id < MAX_UDI_CLIENTS; id++) {
+ if (ul_clients[id].udi_enabled == 0) {
+ ul_clients[id].instance = priv->instance;
+ ul_clients[id].udi_enabled = 1;
+ ul_clients[id].configuration = configuration;
+
+ /* Allocate memory for the reply signal.. */
+ ul_clients[id].reply_signal = kmalloc(sizeof(CSR_SIGNAL), GFP_KERNEL);
+ if (ul_clients[id].reply_signal == NULL) {
+ unifi_error(priv, "Failed to allocate reply signal for client.\n");
+ return NULL;
+ }
+ /* .. and the bulk data of the reply signal. */
+ for (ref = 0; ref < UNIFI_MAX_DATA_REFERENCES; ref ++) {
+ ul_clients[id].reply_bulkdata[ref] = kmalloc(sizeof(bulk_data_t), GFP_KERNEL);
+ /* If allocation fails, free allocated memory. */
+ if (ul_clients[id].reply_bulkdata[ref] == NULL) {
+ for (; ref > 0; ref --) {
+ kfree(ul_clients[id].reply_bulkdata[ref - 1]);
+ }
+ kfree(ul_clients[id].reply_signal);
+ unifi_error(priv, "Failed to allocate bulk data buffers for client.\n");
+ return NULL;
+ }
+ }
+
+ /* Set the event callback. */
+ ul_clients[id].event_hook = udi_event_clbk;
+
+ unifi_trace(priv, UDBG2, "UDI %d (0x%x) registered. configuration = 0x%x\n",
+ id, &ul_clients[id], configuration);
+ return &ul_clients[id];
+ }
+ }
+ return NULL;
+} /* ul_register_client() */
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * ul_deregister_client
+ *
+ * This function deregisters a blocking UDI client.
+ *
+ * Arguments:
+ * client Pointer to the client we deregister.
+ *
+ * Returns:
+ * 0 if a new clients is deregistered.
+ * ---------------------------------------------------------------------------
+ */
+int
+ul_deregister_client(ul_client_t *ul_client)
+{
+ struct list_head *pos, *n;
+ udi_log_t *logptr;
+ unifi_priv_t *priv = uf_find_instance(ul_client->instance);
+ int ref;
+
+ ul_client->instance = -1;
+ ul_client->event_hook = NULL;
+ ul_client->udi_enabled = 0;
+ unifi_trace(priv, UDBG5, "UDI (0x%x) deregistered.\n", ul_client);
+
+ /* Free memory allocated for the reply signal and its bulk data. */
+ kfree(ul_client->reply_signal);
+ for (ref = 0; ref < UNIFI_MAX_DATA_REFERENCES; ref ++) {
+ kfree(ul_client->reply_bulkdata[ref]);
+ }
+
+ if (ul_client->snap_filter.count) {
+ ul_client->snap_filter.count = 0;
+ kfree(ul_client->snap_filter.protocols);
+ }
+
+ /* Free anything pending on the udi_log list */
+ down(&ul_client->udi_sem);
+ list_for_each_safe(pos, n, &ul_client->udi_log)
+ {
+ logptr = list_entry(pos, udi_log_t, q);
+ list_del(pos);
+ kfree(logptr);
+ }
+ up(&ul_client->udi_sem);
+
+ return 0;
+} /* ul_deregister_client() */
+
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * logging_handler
+ *
+ * This function is registered with the driver core.
+ * It is called every time a UniFi HIP Signal is sent. It iterates over
+ * the list of processes interested in receiving log events and
+ * delivers the events to them.
+ *
+ * Arguments:
+ * ospriv Pointer to driver's private data.
+ * sigdata Pointer to the packed signal buffer.
+ * signal_len Length of the packed signal.
+ * bulkdata Pointer to the signal's bulk data.
+ * dir Direction of the signal
+ * 0 = from-host
+ * 1 = to-host
+ *
+ * Returns:
+ * None.
+ * ---------------------------------------------------------------------------
+ */
+void
+logging_handler(void *ospriv,
+ u8 *sigdata, u32 signal_len,
+ const bulk_data_param_t *bulkdata,
+ enum udi_log_direction direction)
+{
+ unifi_priv_t *priv = (unifi_priv_t*)ospriv;
+ ul_client_t *client;
+ int dir;
+
+ dir = (direction == UDI_LOG_FROM_HOST) ? UDI_FROM_HOST : UDI_TO_HOST;
+
+ down(&priv->udi_logging_mutex);
+ client = priv->logging_client;
+ if (client != NULL) {
+ client->event_hook(client, sigdata, signal_len,
+ bulkdata, dir);
+ }
+ up(&priv->udi_logging_mutex);
+
+} /* logging_handler() */
+
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * ul_log_config_ind
+ *
+ * This function uses the client's register callback
+ * to indicate configuration information e.g core errors.
+ *
+ * Arguments:
+ * priv Pointer to driver's private data.
+ * conf_param Pointer to the configuration data.
+ * len Length of the configuration data.
+ *
+ * Returns:
+ * None.
+ * ---------------------------------------------------------------------------
+ */
+void
+ul_log_config_ind(unifi_priv_t *priv, u8 *conf_param, int len)
+{
+#ifdef CSR_SUPPORT_SME
+ if (priv->smepriv == NULL)
+ {
+ return;
+ }
+ if ((CONFIG_IND_ERROR == (*conf_param)) && (priv->wifi_on_state == wifi_on_in_progress)) {
+ unifi_notice(priv, "ul_log_config_ind: wifi on in progress, suppress error\n");
+ } else {
+ /* wifi_off_ind (error or exit) */
+ CsrWifiRouterCtrlWifiOffIndSend(priv->CSR_WIFI_SME_IFACEQUEUE,0, (CsrWifiRouterCtrlControlIndication)(*conf_param));
+ }
+#ifdef CSR_WIFI_HIP_DEBUG_OFFLINE
+ unifi_debug_buf_dump();
+#endif
+#else
+ bulk_data_param_t bulkdata;
+
+ /*
+ * If someone killed unifi_managed before the driver was unloaded
+ * the g_drvpriv pointer is going to be NULL. In this case it is
+ * safe to assume that there is no client to get the indication.
+ */
+ if (!priv) {
+ unifi_notice(NULL, "uf_sme_event_ind: NULL priv\n");
+ return;
+ }
+
+ /* Create a null bulkdata structure. */
+ bulkdata.d[0].data_length = 0;
+ bulkdata.d[1].data_length = 0;
+
+ sme_native_log_event(priv->sme_cli, conf_param, sizeof(u8),
+ &bulkdata, UDI_CONFIG_IND);
+
+#endif /* CSR_SUPPORT_SME */
+
+} /* ul_log_config_ind */
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * free_bulkdata_buffers
+ *
+ * Free the bulkdata buffers e.g. after a failed unifi_send_signal().
+ *
+ * Arguments:
+ * priv Pointer to device private struct
+ * bulkdata Pointer to bulkdata parameter table
+ *
+ * Returns:
+ * None.
+ * ---------------------------------------------------------------------------
+ */
+static void
+free_bulkdata_buffers(unifi_priv_t *priv, bulk_data_param_t *bulkdata)
+{
+ int i;
+
+ if (bulkdata) {
+ for (i = 0; i < UNIFI_MAX_DATA_REFERENCES; ++i) {
+ if (bulkdata->d[i].data_length != 0) {
+ unifi_net_data_free(priv, (bulk_data_desc_t *)(&bulkdata->d[i]));
+ /* data_length is now 0 */
+ }
+ }
+ }
+
+} /* free_bulkdata_buffers */
+
+static int
+_align_bulk_data_buffers(unifi_priv_t *priv, u8 *signal,
+ bulk_data_param_t *bulkdata)
+{
+ unsigned int i;
+
+ if ((bulkdata == NULL) || (CSR_WIFI_ALIGN_BYTES == 0)) {
+ return 0;
+ }
+
+ for (i = 0; i < UNIFI_MAX_DATA_REFERENCES; i++)
+ {
+ struct sk_buff *skb;
+ /*
+ * The following complex casting is in place in order to eliminate 64-bit compilation warning
+ * "cast to/from pointer from/to integer of different size"
+ */
+ u32 align_offset = (u32)(long)(bulkdata->d[i].os_data_ptr) & (CSR_WIFI_ALIGN_BYTES-1);
+ if (align_offset)
+ {
+ skb = (struct sk_buff*)bulkdata->d[i].os_net_buf_ptr;
+ if (skb == NULL) {
+ unifi_warning(priv,
+ "_align_bulk_data_buffers: Align offset found (%d) but skb is NULL!\n",
+ align_offset);
+ return -EINVAL;
+ }
+ if (bulkdata->d[i].data_length == 0) {
+ unifi_warning(priv,
+ "_align_bulk_data_buffers: Align offset found (%d) but length is zero\n",
+ align_offset);
+ return CSR_RESULT_SUCCESS;
+ }
+ unifi_trace(priv, UDBG5,
+ "Align f-h buffer (0x%p) by %d bytes (skb->data: 0x%p)\n",
+ bulkdata->d[i].os_data_ptr, align_offset, skb->data);
+
+
+ /* Check if there is enough headroom... */
+ if (unlikely(skb_headroom(skb) < align_offset))
+ {
+ struct sk_buff *tmp = skb;
+
+ unifi_trace(priv, UDBG5, "Headroom not enough - realloc it\n");
+ skb = skb_realloc_headroom(skb, align_offset);
+ if (skb == NULL) {
+ unifi_error(priv,
+ "_align_bulk_data_buffers: skb_realloc_headroom failed - signal is dropped\n");
+ return -EFAULT;
+ }
+ /* Free the old bulk data only if allocation succeeds */
+ kfree_skb(tmp);
+ /* Bulkdata needs to point to the new skb */
+ bulkdata->d[i].os_net_buf_ptr = (const unsigned char*)skb;
+ bulkdata->d[i].os_data_ptr = (const void*)skb->data;
+ }
+ /* ... before pushing the data to the right alignment offset */
+ skb_push(skb, align_offset);
+
+ }
+ /* The direction bit is zero for the from-host */
+ signal[SIZEOF_SIGNAL_HEADER + (i * SIZEOF_DATAREF) + 1] = align_offset;
+
+ }
+ return 0;
+} /* _align_bulk_data_buffers() */
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * ul_send_signal_unpacked
+ *
+ * This function sends a host formatted signal to unifi.
+ *
+ * Arguments:
+ * priv Pointer to driver's private data.
+ * sigptr Pointer to the signal.
+ * bulkdata Pointer to the signal's bulk data.
+ *
+ * Returns:
+ * O on success, error code otherwise.
+ *
+ * Notes:
+ * The signals have to be sent in the format described in the host interface
+ * specification, i.e wire formatted. Certain clients use the host formatted
+ * structures. The write_pack() transforms the host formatted signal
+ * into the wired formatted signal. The code is in the core, since the signals
+ * are defined therefore binded to the host interface specification.
+ * ---------------------------------------------------------------------------
+ */
+int
+ul_send_signal_unpacked(unifi_priv_t *priv, CSR_SIGNAL *sigptr,
+ bulk_data_param_t *bulkdata)
+{
+ u8 sigbuf[UNIFI_PACKED_SIGBUF_SIZE];
+ u16 packed_siglen;
+ CsrResult csrResult;
+ unsigned long lock_flags;
+ int r;
+
+
+ csrResult = write_pack(sigptr, sigbuf, &packed_siglen);
+ if (csrResult != CSR_RESULT_SUCCESS) {
+ unifi_error(priv, "Malformed HIP signal in ul_send_signal_unpacked()\n");
+ return CsrHipResultToStatus(csrResult);
+ }
+ r = _align_bulk_data_buffers(priv, sigbuf, (bulk_data_param_t*)bulkdata);
+ if (r) {
+ return r;
+ }
+
+ spin_lock_irqsave(&priv->send_signal_lock, lock_flags);
+ csrResult = unifi_send_signal(priv->card, sigbuf, packed_siglen, bulkdata);
+ if (csrResult != CSR_RESULT_SUCCESS) {
+ /* free_bulkdata_buffers(priv, (bulk_data_param_t *)bulkdata); */
+ spin_unlock_irqrestore(&priv->send_signal_lock, lock_flags);
+ return CsrHipResultToStatus(csrResult);
+ }
+ spin_unlock_irqrestore(&priv->send_signal_lock, lock_flags);
+
+ return 0;
+} /* ul_send_signal_unpacked() */
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * reset_driver_status
+ *
+ * This function is called from ul_send_signal_raw() when it detects
+ * that the SME has sent a MLME-RESET request.
+ *
+ * Arguments:
+ * priv Pointer to device private struct
+ *
+ * Returns:
+ * None.
+ * ---------------------------------------------------------------------------
+ */
+static void
+reset_driver_status(unifi_priv_t *priv)
+{
+ priv->sta_wmm_capabilities = 0;
+#ifdef CSR_NATIVE_LINUX
+#ifdef CSR_SUPPORT_WEXT
+ priv->wext_conf.flag_associated = 0;
+ priv->wext_conf.block_controlled_port = CSR_WIFI_ROUTER_PORT_ACTION_8021X_PORT_OPEN;
+ priv->wext_conf.bss_wmm_capabilities = 0;
+ priv->wext_conf.disable_join_on_ssid_set = 0;
+#endif
+#endif
+} /* reset_driver_status() */
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * ul_send_signal_raw
+ *
+ * This function sends a wire formatted data signal to unifi.
+ *
+ * Arguments:
+ * priv Pointer to driver's private data.
+ * sigptr Pointer to the signal.
+ * siglen Length of the signal.
+ * bulkdata Pointer to the signal's bulk data.
+ *
+ * Returns:
+ * O on success, error code otherwise.
+ * ---------------------------------------------------------------------------
+ */
+int
+ul_send_signal_raw(unifi_priv_t *priv, unsigned char *sigptr, int siglen,
+ bulk_data_param_t *bulkdata)
+{
+ CsrResult csrResult;
+ unsigned long lock_flags;
+ int r;
+
+ /*
+ * Make sure that the signal is updated with the bulk data
+ * alignment for DMA.
+ */
+ r = _align_bulk_data_buffers(priv, (u8*)sigptr, bulkdata);
+ if (r) {
+ return r;
+ }
+
+ spin_lock_irqsave(&priv->send_signal_lock, lock_flags);
+ csrResult = unifi_send_signal(priv->card, sigptr, siglen, bulkdata);
+ if (csrResult != CSR_RESULT_SUCCESS) {
+ free_bulkdata_buffers(priv, bulkdata);
+ spin_unlock_irqrestore(&priv->send_signal_lock, lock_flags);
+ return CsrHipResultToStatus(csrResult);
+ }
+ spin_unlock_irqrestore(&priv->send_signal_lock, lock_flags);
+
+ /*
+ * Since this is use by unicli, if we get an MLME reset request
+ * we need to initialize a few status parameters
+ * that the driver uses to make decisions.
+ */
+ if (GET_SIGNAL_ID(sigptr) == CSR_MLME_RESET_REQUEST_ID) {
+ reset_driver_status(priv);
+ }
+
+ return 0;
+} /* ul_send_signal_raw() */
+
+
diff --git a/drivers/staging/csr/unifi_clients.h b/drivers/staging/csr/unifi_clients.h
new file mode 100644
index 000000000000..df853e160ea5
--- /dev/null
+++ b/drivers/staging/csr/unifi_clients.h
@@ -0,0 +1,129 @@
+/*
+ *****************************************************************************
+ *
+ * FILE : unifi_clients.h
+ *
+ * PURPOSE : Private header file for unifi clients.
+ *
+ * UDI = UniFi Debug Interface
+ *
+ * Copyright (C) 2005-2008 by Cambridge Silicon Radio Ltd.
+ *
+ * Refer to LICENSE.txt included with this source code for details on
+ * the license terms.
+ *
+ *****************************************************************************
+ */
+#ifndef __LINUX_UNIFI_CLIENTS_H__
+#define __LINUX_UNIFI_CLIENTS_H__ 1
+
+#include <linux/kernel.h>
+
+#define MAX_UDI_CLIENTS 8
+
+/* The start of the range of process ids allocated for ul clients */
+#define UDI_SENDER_ID_BASE 0xC000
+#define UDI_SENDER_ID_SHIFT 8
+
+
+/* Structure to hold a UDI logged signal */
+typedef struct {
+
+ /* List link structure */
+ struct list_head q;
+
+ /* The message that will be passed to the user app */
+ udi_msg_t msg;
+
+ /* Signal body and data follow */
+
+} udi_log_t;
+
+
+
+typedef struct ul_client ul_client_t;
+
+typedef void (*udi_event_t)(ul_client_t *client,
+ const u8 *sigdata, int signal_len,
+ const bulk_data_param_t *bulkdata,
+ int dir);
+
+void logging_handler(void *ospriv,
+ u8 *sigdata, u32 signal_len,
+ const bulk_data_param_t *bulkdata,
+ enum udi_log_direction direction);
+
+
+/*
+ * Structure describing a bulk data slot.
+ * The length field is used to indicate empty/occupied state.
+ */
+typedef struct _bulk_data
+{
+ unsigned char ptr[2000];
+ unsigned int length;
+} bulk_data_t;
+
+
+struct ul_client {
+ /* Index of this client in the ul_clients array. */
+ int client_id;
+
+ /* Index of UniFi device to which this client is attached. */
+ int instance;
+
+ /* Flag to say whether this client has been enabled. */
+ int udi_enabled;
+
+ /* Value to use in signal->SenderProcessId */
+ int sender_id;
+
+ /* Configuration flags, e.g blocking, logging, etc. */
+ unsigned int configuration;
+
+ udi_event_t event_hook;
+
+ /* A list to hold signals received from UniFi for reading by read() */
+ struct list_head udi_log;
+
+ /* Semaphore to protect the udi_log list */
+ struct semaphore udi_sem;
+
+ /*
+ * Linux waitqueue to support blocking read and poll.
+ * Logging clients should wait on udi_log. while
+ * blocking clients should wait on wake_up_wq.
+ */
+ wait_queue_head_t udi_wq;
+ CSR_SIGNAL* reply_signal;
+ bulk_data_t* reply_bulkdata[UNIFI_MAX_DATA_REFERENCES];
+
+ u16 signal_filter[SIG_FILTER_SIZE];
+
+
+ /* ------------------------------------------------------------------- */
+ /* Code below here is used by the sme_native configuration only */
+
+ /* Flag to wake up blocking clients waiting on udi_wq. */
+ int wake_up_wq_id;
+
+ /*
+ * A 0x00 - 0x0F mask to apply in signal->SenderProcessId.
+ * Every time we do a blocking mlme request we increase this value.
+ * The mlme_wait_for_reply() will wait for this sequence number.
+ * Only the MLME blocking functions update this field.
+ */
+ unsigned char seq_no;
+
+ /*
+ * A 0x00 - 0x0F counter, containing the sequence number of
+ * the signal that this client has last received.
+ * Only the MLME blocking functions update this field.
+ */
+ unsigned char wake_seq_no;
+
+ unifiio_snap_filter_t snap_filter;
+}; /* struct ul_client */
+
+
+#endif /* __LINUX_UNIFI_CLIENTS_H__ */
diff --git a/drivers/staging/csr/unifi_config.h b/drivers/staging/csr/unifi_config.h
new file mode 100644
index 000000000000..fe119707844a
--- /dev/null
+++ b/drivers/staging/csr/unifi_config.h
@@ -0,0 +1,34 @@
+/*
+ * ---------------------------------------------------------------------------
+ *
+ * FILE: unifi_config.h
+ *
+ * PURPOSE:
+ * This header file provides parameters that configure the operation
+ * of the driver.
+ *
+ * Copyright (C) 2006-2008 by Cambridge Silicon Radio Ltd.
+ *
+ * Refer to LICENSE.txt included with this source code for details on
+ * the license terms.
+ *
+ * ---------------------------------------------------------------------------
+ */
+#ifndef __UNIFI_CONFIG_H__
+#define __UNIFI_CONFIG_H__ 1
+
+/*
+ * Override for the SDIO function block size on this host. When byte mode CMD53s
+ * are not used/supported by the SD host controller, transfers are padded up to
+ * the next block boundary. The 512-byte default on UF6xxx wastes too much space
+ * on the chip, so the block size is reduced to support this configuration.
+ */
+#define CSR_WIFI_HIP_SDIO_BLOCK_SIZE 64
+
+/* Define the number of mini-coredump buffers to allocate at startup. These are
+ * used to record chip status for the last n unexpected resets.
+ */
+#define CSR_WIFI_HIP_NUM_COREDUMP_BUFFERS 5
+
+
+#endif /* __UNIFI_CONFIG_H__ */
diff --git a/drivers/staging/csr/unifi_dbg.c b/drivers/staging/csr/unifi_dbg.c
new file mode 100644
index 000000000000..38d57085a26a
--- /dev/null
+++ b/drivers/staging/csr/unifi_dbg.c
@@ -0,0 +1,110 @@
+/*
+ * ***************************************************************************
+ * FILE: unifi_dbg.c
+ *
+ * PURPOSE:
+ * Handle debug signals received from UniFi.
+ *
+ * Copyright (C) 2007-2008 by Cambridge Silicon Radio Ltd.
+ *
+ * Refer to LICENSE.txt included with this source code for details on
+ * the license terms.
+ *
+ * ***************************************************************************
+ */
+#include "unifi_priv.h"
+
+/*
+ * ---------------------------------------------------------------------------
+ * debug_string_indication
+ * debug_word16_indication
+ *
+ * Handlers for debug indications.
+ *
+ * Arguments:
+ * priv Pointer to private context structure.
+ *
+ * Returns:
+ * None.
+ * ---------------------------------------------------------------------------
+ */
+void
+debug_string_indication(unifi_priv_t *priv, const unsigned char *extra, unsigned int extralen)
+{
+ const unsigned int maxlen = sizeof(priv->last_debug_string) - 1;
+
+ if (extralen > maxlen) {
+ extralen = maxlen;
+ }
+
+ strncpy(priv->last_debug_string, extra, extralen);
+
+ /* Make sure the string is terminated */
+ priv->last_debug_string[extralen] = '\0';
+
+ unifi_info(priv, "unifi debug: %s\n", priv->last_debug_string);
+
+} /* debug_string_indication() */
+
+
+
+void
+debug_word16_indication(unifi_priv_t *priv, const CSR_SIGNAL *sigptr)
+{
+ int i;
+
+ if (priv == NULL) {
+ unifi_info(priv, "Priv is NULL\n");
+ return;
+ }
+
+ for (i = 0; i < 16; i++) {
+ priv->last_debug_word16[i] =
+ sigptr->u.DebugWord16Indication.DebugWords[i];
+ }
+
+ if (priv->last_debug_word16[0] == 0xFA11) {
+ unsigned long ts;
+ ts = (priv->last_debug_word16[6] << 16) | priv->last_debug_word16[5];
+ unifi_info(priv, " %10lu: %s fault %04x, arg %04x (x%d)\n",
+ ts,
+ priv->last_debug_word16[3] == 0x8000 ? "MAC" :
+ priv->last_debug_word16[3] == 0x4000 ? "PHY" :
+ "???",
+ priv->last_debug_word16[1],
+ priv->last_debug_word16[2],
+ priv->last_debug_word16[4]);
+ }
+ else if (priv->last_debug_word16[0] != 0xDBAC)
+ /* suppress SDL Trace output (note: still available to unicli). */
+ {
+ unifi_info(priv, "unifi debug: %04X %04X %04X %04X %04X %04X %04X %04X\n",
+ priv->last_debug_word16[0], priv->last_debug_word16[1],
+ priv->last_debug_word16[2], priv->last_debug_word16[3],
+ priv->last_debug_word16[4], priv->last_debug_word16[5],
+ priv->last_debug_word16[6], priv->last_debug_word16[7]);
+ unifi_info(priv, " %04X %04X %04X %04X %04X %04X %04X %04X\n",
+ priv->last_debug_word16[8], priv->last_debug_word16[9],
+ priv->last_debug_word16[10], priv->last_debug_word16[11],
+ priv->last_debug_word16[12], priv->last_debug_word16[13],
+ priv->last_debug_word16[14], priv->last_debug_word16[15]);
+ }
+
+} /* debug_word16_indication() */
+
+
+void
+debug_generic_indication(unifi_priv_t *priv, const CSR_SIGNAL *sigptr)
+{
+ unifi_info(priv, "debug: %04X %04X %04X %04X %04X %04X %04X %04X\n",
+ sigptr->u.DebugGenericIndication.DebugWords[0],
+ sigptr->u.DebugGenericIndication.DebugWords[1],
+ sigptr->u.DebugGenericIndication.DebugWords[2],
+ sigptr->u.DebugGenericIndication.DebugWords[3],
+ sigptr->u.DebugGenericIndication.DebugWords[4],
+ sigptr->u.DebugGenericIndication.DebugWords[5],
+ sigptr->u.DebugGenericIndication.DebugWords[6],
+ sigptr->u.DebugGenericIndication.DebugWords[7]);
+
+} /* debug_generic_indication() */
+
diff --git a/drivers/staging/csr/unifi_event.c b/drivers/staging/csr/unifi_event.c
new file mode 100644
index 000000000000..c27b23daf399
--- /dev/null
+++ b/drivers/staging/csr/unifi_event.c
@@ -0,0 +1,700 @@
+/*
+ * ***************************************************************************
+ * FILE: unifi_event.c
+ *
+ * PURPOSE:
+ * Process the signals received by UniFi.
+ * It is part of the porting exercise.
+ *
+ * Copyright (C) 2009 by Cambridge Silicon Radio Ltd.
+ *
+ * Refer to LICENSE.txt included with this source code for details on
+ * the license terms.
+ *
+ * ***************************************************************************
+ */
+
+
+/*
+ * Porting notes:
+ * The implementation of unifi_receive_event() in Linux is fairly complicated.
+ * The linux driver support multiple userspace applications and several
+ * build configurations, so the received signals are processed by different
+ * processes and multiple times.
+ * In a simple implementation, this function needs to deliver:
+ * - The MLME-UNITDATA.ind signals to the Rx data plane and to the Traffic
+ * Analysis using unifi_ta_sample().
+ * - The MLME-UNITDATA-STATUS.ind signals to the Tx data plane.
+ * - All the other signals to the SME using unifi_sys_hip_ind().
+ */
+
+#include "csr_wifi_hip_unifi.h"
+#include "csr_wifi_hip_conversions.h"
+#include "unifi_priv.h"
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * send_to_client
+ *
+ * Helper for unifi_receive_event.
+ *
+ * This function forwards a signal to one client.
+ *
+ * Arguments:
+ * priv Pointer to driver's private data.
+ * client Pointer to the client structure.
+ * receiver_id The reciever id of the signal.
+ * sigdata Pointer to the packed signal buffer.
+ * siglen Length of the packed signal.
+ * bulkdata Pointer to the signal's bulk data.
+ *
+ * Returns:
+ * None.
+ *
+ * ---------------------------------------------------------------------------
+ */
+static void send_to_client(unifi_priv_t *priv, ul_client_t *client,
+ int receiver_id,
+ unsigned char *sigdata, int siglen,
+ const bulk_data_param_t *bulkdata)
+{
+ if (client && client->event_hook) {
+ /*unifi_trace(priv, UDBG3,
+ "Receive: client %d, (s:0x%X, r:0x%X) - Signal 0x%.4X \n",
+ client->client_id, client->sender_id, receiver_id,
+ CSR_GET_UINT16_FROM_LITTLE_ENDIAN(sigdata));*/
+
+ client->event_hook(client, sigdata, siglen, bulkdata, UDI_TO_HOST);
+ }
+}
+
+/*
+ * ---------------------------------------------------------------------------
+ * process_pkt_data_ind
+ *
+ * Dispatcher for received signals.
+ *
+ * This function receives the 'to host' signals and forwards
+ * them to the unifi linux clients.
+ *
+ * Arguments:
+ * priv Context
+ * sigdata Pointer to the packed signal buffer(Its in form of MA-PACKET.ind).
+ * bulkdata Pointer to signal's bulkdata
+ * freeBulkData Pointer to a flag which gets set if the bulkdata needs to
+ * be freed after calling the logging handlers. If it is not
+ * set the bulkdata must be freed by the MLME handler or
+ * passed to the network stack.
+ * Returns:
+ * TRUE if the packet should be routed to the SME etc.
+ * FALSE if the packet is for the driver or network stack
+ * ---------------------------------------------------------------------------
+ */
+static u8 check_routing_pkt_data_ind(unifi_priv_t *priv,
+ u8 *sigdata,
+ const bulk_data_param_t* bulkdata,
+ u8 *freeBulkData,
+ netInterface_priv_t *interfacePriv)
+{
+ u16 frmCtrl, receptionStatus, frmCtrlSubType;
+ u8 *macHdrLocation;
+ u8 interfaceTag;
+ u8 isDataFrame;
+ u8 isProtocolVerInvalid = FALSE;
+ u8 isDataFrameSubTypeNoData = FALSE;
+
+#ifdef CSR_WIFI_SECURITY_WAPI_ENABLE
+ static const u8 wapiProtocolIdSNAPHeader[] = {0x88,0xb4};
+ static const u8 wapiProtocolIdSNAPHeaderOffset = 6;
+ u8 *destAddr;
+ u8 *srcAddr;
+ u8 isWapiUnicastPkt = FALSE;
+
+#ifdef CSR_WIFI_SECURITY_WAPI_QOSCTRL_MIC_WORKAROUND
+ u16 qosControl;
+#endif
+
+ u8 llcSnapHeaderOffset = 0;
+
+ destAddr = (u8 *) bulkdata->d[0].os_data_ptr + MAC_HEADER_ADDR1_OFFSET;
+ srcAddr = (u8 *) bulkdata->d[0].os_data_ptr + MAC_HEADER_ADDR2_OFFSET;
+
+ /*Individual/Group bit - Bit 0 of first byte*/
+ isWapiUnicastPkt = (!(destAddr[0] & 0x01)) ? TRUE : FALSE;
+#endif
+
+#define CSR_WIFI_MA_PKT_IND_RECEPTION_STATUS_OFFSET sizeof(CSR_SIGNAL_PRIMITIVE_HEADER) + 22
+
+ *freeBulkData = FALSE;
+
+ /* Fetch the MAC header location from MA_PKT_IND packet */
+ macHdrLocation = (u8 *) bulkdata->d[0].os_data_ptr;
+ /* Fetch the Frame Control value from MAC header */
+ frmCtrl = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(macHdrLocation);
+
+ /* Pull out interface tag from virtual interface identifier */
+ interfaceTag = (CSR_GET_UINT16_FROM_LITTLE_ENDIAN(sigdata + 14)) & 0xff;
+
+ /* check for MIC failure before processing the signal */
+ receptionStatus = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(sigdata + CSR_WIFI_MA_PKT_IND_RECEPTION_STATUS_OFFSET);
+
+ /* To discard any spurious MIC failures that could be reported by the firmware */
+ isDataFrame = ((frmCtrl & IEEE80211_FC_TYPE_MASK) == (IEEE802_11_FC_TYPE_DATA & IEEE80211_FC_TYPE_MASK)) ? TRUE : FALSE;
+ /* 0x00 is the only valid protocol version*/
+ isProtocolVerInvalid = (frmCtrl & IEEE80211_FC_PROTO_VERSION_MASK) ? TRUE : FALSE;
+ frmCtrlSubType = (frmCtrl & IEEE80211_FC_SUBTYPE_MASK) >> FRAME_CONTROL_SUBTYPE_FIELD_OFFSET;
+ /*Exclude the no data & reserved sub-types from MIC failure processing*/
+ isDataFrameSubTypeNoData = (((frmCtrlSubType>0x03)&&(frmCtrlSubType<0x08)) || (frmCtrlSubType>0x0B)) ? TRUE : FALSE;
+ if ((receptionStatus == CSR_MICHAEL_MIC_ERROR) &&
+ ((!isDataFrame) || isProtocolVerInvalid || (isDataFrame && isDataFrameSubTypeNoData))) {
+ /* Currently MIC errors are discarded for frames other than data frames. This might need changing when we start
+ * supporting 802.11w (Protected Management frames)
+ */
+ *freeBulkData = TRUE;
+ unifi_trace(priv, UDBG4, "Discarding this frame and ignoring the MIC failure as this is a garbage/non-data/no data frame\n");
+ return FALSE;
+ }
+
+#ifdef CSR_WIFI_SECURITY_WAPI_ENABLE
+
+ if (receptionStatus == CSR_MICHAEL_MIC_ERROR) {
+
+ if (interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_STA) {
+
+#ifdef CSR_WIFI_SECURITY_WAPI_QOSCTRL_MIC_WORKAROUND
+ if ((isDataFrame) &&
+ ((IEEE802_11_FC_TYPE_QOS_DATA & IEEE80211_FC_SUBTYPE_MASK) == (frmCtrl & IEEE80211_FC_SUBTYPE_MASK)) &&
+ (priv->isWapiConnection))
+ {
+ qosControl = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(macHdrLocation + (((frmCtrl & IEEE802_11_FC_TO_DS_MASK) && (frmCtrl & IEEE802_11_FC_FROM_DS_MASK)) ? 30 : 24) );
+
+ unifi_trace(priv, UDBG4, "check_routing_pkt_data_ind() :: Value of the QoS control field - 0x%04x \n", qosControl);
+
+ if (qosControl & IEEE802_11_QC_NON_TID_BITS_MASK)
+ {
+ unifi_trace(priv, UDBG4, "Ignore the MIC failure and pass the MPDU to the stack when any of bits [4-15] is set in the QoS control field\n");
+
+ /*Exclude the MIC [16] and the PN [16] that are appended by the firmware*/
+ ((bulk_data_param_t*)bulkdata)->d[0].data_length = bulkdata->d[0].data_length - 32;
+
+ /*Clear the reception status of the signal (CSR_RX_SUCCESS)*/
+ *(sigdata + CSR_WIFI_MA_PKT_IND_RECEPTION_STATUS_OFFSET) = 0x00;
+ *(sigdata + CSR_WIFI_MA_PKT_IND_RECEPTION_STATUS_OFFSET+1) = 0x00;
+
+ *freeBulkData = FALSE;
+
+ return FALSE;
+ }
+ }
+#endif
+ /* If this MIC ERROR reported by the firmware is either for
+ * [1] a WAPI Multicast MPDU and the Multicast filter has NOT been set (It is set only when group key index (MSKID) = 1 in Group Rekeying) OR
+ * [2] a WAPI Unicast MPDU and either the CONTROL PORT is open or the WAPI Unicast filter or filter(s) is NOT set
+ * then report a MIC FAILURE indication to the SME.
+ */
+#ifndef CSR_WIFI_SECURITY_WAPI_SW_ENCRYPTION
+ if ((priv->wapi_multicast_filter == 0) || isWapiUnicastPkt) {
+#else
+ /*When SW encryption is enabled and USKID=1 (wapi_unicast_filter = 1), we are expected
+ *to receive MIC failure INDs for unicast MPDUs*/
+ if ( ((priv->wapi_multicast_filter == 0) && !isWapiUnicastPkt) ||
+ ((priv->wapi_unicast_filter == 0) && isWapiUnicastPkt) ) {
+#endif
+ /*Discard the frame*/
+ *freeBulkData = TRUE;
+ unifi_trace(priv, UDBG4, "Discarding the contents of the frame with MIC failure \n");
+
+ if (isWapiUnicastPkt &&
+ ((uf_sme_port_state(priv,srcAddr,UF_CONTROLLED_PORT_Q,interfaceTag) != CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_OPEN)||
+#ifndef CSR_WIFI_SECURITY_WAPI_SW_ENCRYPTION
+ (priv->wapi_unicast_filter) ||
+#endif
+ (priv->wapi_unicast_queued_pkt_filter))) {
+
+ /* Workaround to handle MIC failures reported by the firmware for encrypted packets from the AP
+ * while we are in the process of re-association induced by unsupported WAPI Unicast key index
+ * - Discard the packets with MIC failures "until" we have
+ * a. negotiated a key,
+ * b. opened the CONTROL PORT and
+ * c. the AP has started using the new key
+ */
+ unifi_trace(priv, UDBG4, "Ignoring the MIC failure as either a. CONTROL PORT isn't OPEN or b. Unicast filter is set or c. WAPI AP using old key for buffered pkts\n");
+
+ /*Ignore this MIC failure*/
+ return FALSE;
+
+ }/*WAPI re-key specific workaround*/
+
+ unifi_trace(priv, UDBG6, "check_routing_pkt_data_ind - MIC FAILURE : interfaceTag %x Src Addr %x:%x:%x:%x:%x:%x\n",
+ interfaceTag, srcAddr[0], srcAddr[1], srcAddr[2], srcAddr[3], srcAddr[4], srcAddr[5]);
+ unifi_trace(priv, UDBG6, "check_routing_pkt_data_ind - MIC FAILURE : Dest Addr %x:%x:%x:%x:%x:%x\n",
+ destAddr[0], destAddr[1], destAddr[2], destAddr[3], destAddr[4], destAddr[5]);
+ unifi_trace(priv, UDBG6, "check_routing_pkt_data_ind - MIC FAILURE : Control Port State - 0x%.4X \n",
+ uf_sme_port_state(priv,srcAddr,UF_CONTROLLED_PORT_Q,interfaceTag));
+
+ unifi_error(priv, "MIC failure in %s\n", __FUNCTION__);
+
+ /*Report the MIC failure to the SME*/
+ return TRUE;
+ }
+ }/* STA mode */
+ else {
+ /* Its AP Mode . Just Return */
+ *freeBulkData = TRUE;
+ unifi_error(priv, "MIC failure in %s\n", __FUNCTION__);
+ return TRUE;
+ } /* AP mode */
+ }/* MIC error */
+#else
+ if (receptionStatus == CSR_MICHAEL_MIC_ERROR) {
+ *freeBulkData = TRUE;
+ unifi_error(priv, "MIC failure in %s\n", __FUNCTION__);
+ return TRUE;
+ }
+#endif /*CSR_WIFI_SECURITY_WAPI_ENABLE*/
+
+ unifi_trace(priv, UDBG4, "frmCtrl = 0x%04x %s\n",
+ frmCtrl,
+ (((frmCtrl & 0x000c)>>FRAME_CONTROL_TYPE_FIELD_OFFSET) == IEEE802_11_FRAMETYPE_MANAGEMENT) ?
+ "Mgt" : "Ctrl/Data");
+
+#ifdef CSR_WIFI_SECURITY_WAPI_ENABLE
+ /* To ignore MIC failures reported due to the WAPI AP using the old key for queued packets before
+ * starting to use the new key negotiated as part of unicast re-keying
+ */
+ if ((interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_STA)&&
+ isWapiUnicastPkt &&
+ (receptionStatus == CSR_RX_SUCCESS) &&
+ (priv->wapi_unicast_queued_pkt_filter==1)) {
+
+ unifi_trace(priv, UDBG6, "check_routing_pkt_data_ind(): WAPI unicast pkt received when the (wapi_unicast_queued_pkt_filter) is set\n");
+
+ if (isDataFrame) {
+ switch(frmCtrl & IEEE80211_FC_SUBTYPE_MASK) {
+ case IEEE802_11_FC_TYPE_QOS_DATA & IEEE80211_FC_SUBTYPE_MASK:
+ llcSnapHeaderOffset = MAC_HEADER_SIZE + 2;
+ break;
+ case IEEE802_11_FC_TYPE_QOS_NULL & IEEE80211_FC_SUBTYPE_MASK:
+ case IEEE802_11_FC_TYPE_NULL & IEEE80211_FC_SUBTYPE_MASK:
+ break;
+ default:
+ llcSnapHeaderOffset = MAC_HEADER_SIZE;
+ }
+ }
+
+ if (llcSnapHeaderOffset > 0) {
+ /* QoS data or Data */
+ unifi_trace(priv, UDBG6, "check_routing_pkt_data_ind(): SNAP header found & its offset %d\n",llcSnapHeaderOffset);
+ if (memcmp((u8 *)(bulkdata->d[0].os_data_ptr+llcSnapHeaderOffset+wapiProtocolIdSNAPHeaderOffset),
+ wapiProtocolIdSNAPHeader,sizeof(wapiProtocolIdSNAPHeader))) {
+
+ unifi_trace(priv, UDBG6, "check_routing_pkt_data_ind(): This is a data & NOT a WAI protocol packet\n");
+ /* On the first unicast data pkt that is decrypted successfully after re-keying, reset the filter */
+ priv->wapi_unicast_queued_pkt_filter = 0;
+ unifi_trace(priv, UDBG4, "check_routing_pkt_data_ind(): WAPI AP has started using the new unicast key, no more MIC failures expected (reset filter)\n");
+ }
+ else {
+ unifi_trace(priv, UDBG6, "check_routing_pkt_data_ind(): WAPI - This is a WAI protocol packet\n");
+ }
+ }
+ }
+#endif
+
+
+ switch ((frmCtrl & 0x000c)>>FRAME_CONTROL_TYPE_FIELD_OFFSET) {
+ case IEEE802_11_FRAMETYPE_MANAGEMENT:
+ *freeBulkData = TRUE; /* Free (after SME handler copies it) */
+
+ /* In P2P device mode, filter the legacy AP beacons here */
+ if((interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_P2P)&&\
+ ((CSR_WIFI_80211_GET_FRAME_SUBTYPE(macHdrLocation)) == CSR_WIFI_80211_FRAME_SUBTYPE_BEACON)){
+
+ u8 *pSsid, *pSsidLen;
+ static u8 P2PWildCardSsid[CSR_WIFI_P2P_WILDCARD_SSID_LENGTH] = {'D', 'I', 'R', 'E', 'C', 'T', '-'};
+
+ pSsidLen = macHdrLocation + MAC_HEADER_SIZE + CSR_WIFI_BEACON_FIXED_LENGTH;
+ pSsid = pSsidLen + 2;
+
+ if(*(pSsidLen + 1) >= CSR_WIFI_P2P_WILDCARD_SSID_LENGTH){
+ if(memcmp(pSsid, P2PWildCardSsid, CSR_WIFI_P2P_WILDCARD_SSID_LENGTH) == 0){
+ unifi_trace(priv, UDBG6, "Received a P2P Beacon, pass it to SME\n");
+ return TRUE;
+ }
+ }
+ unifi_trace(priv, UDBG6, "Received a Legacy AP beacon in P2P mode, drop it\n");
+ return FALSE;
+ }
+ return TRUE; /* Route to SME */
+ case IEEE802_11_FRAMETYPE_DATA:
+ case IEEE802_11_FRAMETYPE_CONTROL:
+ *freeBulkData = FALSE; /* Network stack or MLME handler frees */
+ return FALSE;
+ default:
+ unifi_error(priv, "Unhandled frame type %04x\n", frmCtrl);
+ *freeBulkData = TRUE; /* Not interested, but must free it */
+ return FALSE;
+ }
+}
+
+/*
+ * ---------------------------------------------------------------------------
+ * unifi_process_receive_event
+ *
+ * Dispatcher for received signals.
+ *
+ * This function receives the 'to host' signals and forwards
+ * them to the unifi linux clients.
+ *
+ * Arguments:
+ * ospriv Pointer to driver's private data.
+ * sigdata Pointer to the packed signal buffer.
+ * siglen Length of the packed signal.
+ * bulkdata Pointer to the signal's bulk data.
+ *
+ * Returns:
+ * None.
+ *
+ * Notes:
+ * The signals are received in the format described in the host interface
+ * specification, i.e wire formatted. Certain clients use the same format
+ * to interpret them and other clients use the host formatted structures.
+ * Each client has to call read_unpack_signal() to transform the wire
+ * formatted signal into the host formatted signal, if necessary.
+ * The code is in the core, since the signals are defined therefore
+ * binded to the host interface specification.
+ * ---------------------------------------------------------------------------
+ */
+static void
+unifi_process_receive_event(void *ospriv,
+ u8 *sigdata, u32 siglen,
+ const bulk_data_param_t *bulkdata)
+{
+ unifi_priv_t *priv = (unifi_priv_t*)ospriv;
+ int i, receiver_id;
+ int client_id;
+ s16 signal_id;
+ u8 pktIndToSme = FALSE, freeBulkData = FALSE;
+
+ func_enter();
+
+ unifi_trace(priv, UDBG5, "unifi_process_receive_event: "
+ "%04x %04x %04x %04x %04x %04x %04x %04x (%d)\n",
+ CSR_GET_UINT16_FROM_LITTLE_ENDIAN((sigdata) + sizeof(s16)*0) & 0xFFFF,
+ CSR_GET_UINT16_FROM_LITTLE_ENDIAN((sigdata) + sizeof(s16)*1) & 0xFFFF,
+ CSR_GET_UINT16_FROM_LITTLE_ENDIAN((sigdata) + sizeof(s16)*2) & 0xFFFF,
+ CSR_GET_UINT16_FROM_LITTLE_ENDIAN((sigdata) + sizeof(s16)*3) & 0xFFFF,
+ CSR_GET_UINT16_FROM_LITTLE_ENDIAN((sigdata) + sizeof(s16)*4) & 0xFFFF,
+ CSR_GET_UINT16_FROM_LITTLE_ENDIAN((sigdata) + sizeof(s16)*5) & 0xFFFF,
+ CSR_GET_UINT16_FROM_LITTLE_ENDIAN((sigdata) + sizeof(s16)*6) & 0xFFFF,
+ CSR_GET_UINT16_FROM_LITTLE_ENDIAN((sigdata) + sizeof(s16)*7) & 0xFFFF,
+ siglen);
+
+ receiver_id = CSR_GET_UINT16_FROM_LITTLE_ENDIAN((sigdata) + sizeof(s16)) & 0xFF00;
+ client_id = (receiver_id & 0x0F00) >> UDI_SENDER_ID_SHIFT;
+ signal_id = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(sigdata);
+
+
+
+ /* check for the type of frame received (checks for 802.11 management frames) */
+ if (signal_id == CSR_MA_PACKET_INDICATION_ID)
+ {
+#define CSR_MA_PACKET_INDICATION_INTERFACETAG_OFFSET 14
+ u8 interfaceTag;
+ netInterface_priv_t *interfacePriv;
+
+ /* Pull out interface tag from virtual interface identifier */
+ interfaceTag = (CSR_GET_UINT16_FROM_LITTLE_ENDIAN(sigdata + CSR_MA_PACKET_INDICATION_INTERFACETAG_OFFSET)) & 0xff;
+ interfacePriv = priv->interfacePriv[interfaceTag];
+
+ /* Update activity for this station in case of IBSS */
+#ifdef CSR_SUPPORT_SME
+ if (interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_IBSS)
+ {
+ u8 *saddr;
+ /* Fetch the source address from mac header */
+ saddr = (u8 *) bulkdata->d[0].os_data_ptr + MAC_HEADER_ADDR2_OFFSET;
+ unifi_trace(priv, UDBG5,
+ "Updating sta activity in IBSS interfaceTag %x Src Addr %x:%x:%x:%x:%x:%x\n",
+ interfaceTag, saddr[0], saddr[1], saddr[2], saddr[3], saddr[4], saddr[5]);
+
+ uf_update_sta_activity(priv, interfaceTag, saddr);
+ }
+#endif
+
+ pktIndToSme = check_routing_pkt_data_ind(priv, sigdata, bulkdata, &freeBulkData, interfacePriv);
+
+ unifi_trace(priv, UDBG6, "RX: packet entry point to driver from HIP,pkt to SME ?(%s) \n", (pktIndToSme)? "YES":"NO");
+
+ }
+
+ if (pktIndToSme)
+ {
+ /* Management MA_PACKET_IND for SME */
+ if(sigdata != NULL && bulkdata != NULL){
+ send_to_client(priv, priv->sme_cli, receiver_id, sigdata, siglen, bulkdata);
+ }
+ else{
+ unifi_error(priv, "unifi_receive_event2: sigdata or Bulkdata is NULL \n");
+ }
+#ifdef CSR_NATIVE_LINUX
+ send_to_client(priv, priv->wext_client,
+ receiver_id,
+ sigdata, siglen, bulkdata);
+#endif
+ }
+ else
+ {
+ /* Signals with ReceiverId==0 are also reported to SME / WEXT,
+ * unless they are data/control MA_PACKET_INDs or VIF_AVAILABILITY_INDs
+ */
+ if (!receiver_id) {
+ if(signal_id == CSR_MA_VIF_AVAILABILITY_INDICATION_ID) {
+ uf_process_ma_vif_availibility_ind(priv, sigdata, siglen);
+ }
+ else if (signal_id != CSR_MA_PACKET_INDICATION_ID) {
+ send_to_client(priv, priv->sme_cli, receiver_id, sigdata, siglen, bulkdata);
+#ifdef CSR_NATIVE_LINUX
+ send_to_client(priv, priv->wext_client,
+ receiver_id,
+ sigdata, siglen, bulkdata);
+#endif
+ }
+ else
+ {
+
+#if (defined(CSR_SUPPORT_SME) && defined(CSR_WIFI_SECURITY_WAPI_ENABLE))
+ #define CSR_MA_PACKET_INDICATION_RECEPTION_STATUS_OFFSET sizeof(CSR_SIGNAL_PRIMITIVE_HEADER) + 22
+ netInterface_priv_t *interfacePriv;
+ u8 interfaceTag;
+ u16 receptionStatus = CSR_RX_SUCCESS;
+
+ /* Pull out interface tag from virtual interface identifier */
+ interfaceTag = (CSR_GET_UINT16_FROM_LITTLE_ENDIAN(sigdata + CSR_MA_PACKET_INDICATION_INTERFACETAG_OFFSET)) & 0xff;
+ interfacePriv = priv->interfacePriv[interfaceTag];
+
+ /* check for MIC failure */
+ receptionStatus = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(sigdata + CSR_MA_PACKET_INDICATION_RECEPTION_STATUS_OFFSET);
+
+ /* Send a WAPI MPDU to SME for re-check MIC if the respective filter has been set*/
+ if ((!freeBulkData) &&
+ (interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_STA) &&
+ (receptionStatus == CSR_MICHAEL_MIC_ERROR) &&
+ ((priv->wapi_multicast_filter == 1)
+#ifdef CSR_WIFI_SECURITY_WAPI_SW_ENCRYPTION
+ || (priv->wapi_unicast_filter == 1)
+#endif
+ ))
+ {
+ CSR_SIGNAL signal;
+ u8 *destAddr;
+ CsrResult res;
+ u16 interfaceTag = 0;
+ u8 isMcastPkt = TRUE;
+
+ unifi_trace(priv, UDBG6, "Received a WAPI data packet when the Unicast/Multicast filter is set\n");
+ res = read_unpack_signal(sigdata, &signal);
+ if (res) {
+ unifi_error(priv, "Received unknown or corrupted signal (0x%x).\n",
+ CSR_GET_UINT16_FROM_LITTLE_ENDIAN(sigdata));
+ return;
+ }
+
+ /* Check if the type of MPDU and the respective filter status*/
+ destAddr = (u8 *) bulkdata->d[0].os_data_ptr + MAC_HEADER_ADDR1_OFFSET;
+ isMcastPkt = (destAddr[0] & 0x01) ? TRUE : FALSE;
+ unifi_trace(priv, UDBG6,
+ "1.MPDU type: (%s), 2.Multicast filter: (%s), 3. Unicast filter: (%s)\n",
+ ((isMcastPkt) ? "Multiast":"Unicast"),
+ ((priv->wapi_multicast_filter) ? "Enabled":"Disabled"),
+ ((priv->wapi_unicast_filter) ? "Enabled":"Disabled"));
+
+ if (((isMcastPkt) && (priv->wapi_multicast_filter == 1))
+#ifdef CSR_WIFI_SECURITY_WAPI_SW_ENCRYPTION
+ || ((!isMcastPkt) && (priv->wapi_unicast_filter == 1))
+#endif
+ )
+ {
+ unifi_trace(priv, UDBG4, "Sending the WAPI MPDU for MIC check\n");
+ CsrWifiRouterCtrlWapiRxMicCheckIndSend(priv->CSR_WIFI_SME_IFACEQUEUE, 0, interfaceTag, siglen, sigdata, bulkdata->d[0].data_length, (u8*)bulkdata->d[0].os_data_ptr);
+
+ for (i = 0; i < UNIFI_MAX_DATA_REFERENCES; i++) {
+ if (bulkdata->d[i].data_length != 0) {
+ unifi_net_data_free(priv, (void *)&bulkdata->d[i]);
+ }
+ }
+ func_exit();
+ return;
+ }
+ } /* CSR_MA_PACKET_INDICATION_ID */
+#endif /*CSR_SUPPORT_SME && CSR_WIFI_SECURITY_WAPI_ENABLE*/
+ }
+ }
+
+ /* calls the registered clients handler callback func.
+ * netdev_mlme_event_handler is one of the registered handler used to route
+ * data packet to network stack or AMP/EAPOL related data to SME
+ *
+ * The freeBulkData check ensures that, it has received a management frame and
+ * the frame needs to be freed here. So not to be passed to netdev handler
+ */
+ if(!freeBulkData){
+ if ((client_id < MAX_UDI_CLIENTS) &&
+ (&priv->ul_clients[client_id] != priv->logging_client)) {
+ unifi_trace(priv, UDBG6, "Call the registered clients handler callback func\n");
+ send_to_client(priv, &priv->ul_clients[client_id],
+ receiver_id,
+ sigdata, siglen, bulkdata);
+ }
+ }
+ }
+
+ /*
+ * Free bulk data buffers here unless it is a CSR_MA_PACKET_INDICATION
+ */
+ switch (signal_id)
+ {
+#ifdef UNIFI_SNIFF_ARPHRD
+ case CSR_MA_SNIFFDATA_INDICATION_ID:
+#endif
+ break;
+
+ case CSR_MA_PACKET_INDICATION_ID:
+ if (!freeBulkData)
+ {
+ break;
+ }
+ /* FALLS THROUGH... */
+ default:
+ for (i = 0; i < UNIFI_MAX_DATA_REFERENCES; i++) {
+ if (bulkdata->d[i].data_length != 0) {
+ unifi_net_data_free(priv, (void *)&bulkdata->d[i]);
+ }
+ }
+ }
+
+ func_exit();
+} /* unifi_process_receive_event() */
+
+
+#ifdef CSR_WIFI_RX_PATH_SPLIT
+static u8 signal_buffer_is_full(unifi_priv_t* priv)
+{
+ return (((priv->rxSignalBuffer.writePointer + 1)% priv->rxSignalBuffer.size) == (priv->rxSignalBuffer.readPointer));
+}
+
+void unifi_rx_queue_flush(void *ospriv)
+{
+ unifi_priv_t *priv = (unifi_priv_t*)ospriv;
+
+ func_enter();
+ unifi_trace(priv, UDBG4, "rx_wq_handler: RdPtr = %d WritePtr = %d\n",
+ priv->rxSignalBuffer.readPointer,priv->rxSignalBuffer.writePointer);
+ if(priv != NULL) {
+ u8 readPointer = priv->rxSignalBuffer.readPointer;
+ while (readPointer != priv->rxSignalBuffer.writePointer)
+ {
+ rx_buff_struct_t *buf = &priv->rxSignalBuffer.rx_buff[readPointer];
+ unifi_trace(priv, UDBG6, "rx_wq_handler: RdPtr = %d WritePtr = %d\n",
+ readPointer,priv->rxSignalBuffer.writePointer);
+ unifi_process_receive_event(priv, buf->bufptr, buf->sig_len, &buf->data_ptrs);
+ readPointer ++;
+ if(readPointer >= priv->rxSignalBuffer.size) {
+ readPointer = 0;
+ }
+ }
+ priv->rxSignalBuffer.readPointer = readPointer;
+ }
+ func_exit();
+}
+
+void rx_wq_handler(struct work_struct *work)
+{
+ unifi_priv_t *priv = container_of(work, unifi_priv_t, rx_work_struct);
+ unifi_rx_queue_flush(priv);
+}
+#endif
+
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * unifi_receive_event
+ *
+ * Dispatcher for received signals.
+ *
+ * This function receives the 'to host' signals and forwards
+ * them to the unifi linux clients.
+ *
+ * Arguments:
+ * ospriv Pointer to driver's private data.
+ * sigdata Pointer to the packed signal buffer.
+ * siglen Length of the packed signal.
+ * bulkdata Pointer to the signal's bulk data.
+ *
+ * Returns:
+ * None.
+ *
+ * Notes:
+ * The signals are received in the format described in the host interface
+ * specification, i.e wire formatted. Certain clients use the same format
+ * to interpret them and other clients use the host formatted structures.
+ * Each client has to call read_unpack_signal() to transform the wire
+ * formatted signal into the host formatted signal, if necessary.
+ * The code is in the core, since the signals are defined therefore
+ * binded to the host interface specification.
+ * ---------------------------------------------------------------------------
+ */
+void
+unifi_receive_event(void *ospriv,
+ u8 *sigdata, u32 siglen,
+ const bulk_data_param_t *bulkdata)
+{
+#ifdef CSR_WIFI_RX_PATH_SPLIT
+ unifi_priv_t *priv = (unifi_priv_t*)ospriv;
+ u8 writePointer;
+ int i;
+ rx_buff_struct_t * rx_buff;
+ func_enter();
+
+ unifi_trace(priv, UDBG5, "unifi_receive_event: "
+ "%04x %04x %04x %04x %04x %04x %04x %04x (%d)\n",
+ CSR_GET_UINT16_FROM_LITTLE_ENDIAN((sigdata) + sizeof(s16)*0) & 0xFFFF,
+ CSR_GET_UINT16_FROM_LITTLE_ENDIAN((sigdata) + sizeof(s16)*1) & 0xFFFF,
+ CSR_GET_UINT16_FROM_LITTLE_ENDIAN((sigdata) + sizeof(s16)*2) & 0xFFFF,
+ CSR_GET_UINT16_FROM_LITTLE_ENDIAN((sigdata) + sizeof(s16)*3) & 0xFFFF,
+ CSR_GET_UINT16_FROM_LITTLE_ENDIAN((sigdata) + sizeof(s16)*4) & 0xFFFF,
+ CSR_GET_UINT16_FROM_LITTLE_ENDIAN((sigdata) + sizeof(s16)*5) & 0xFFFF,
+ CSR_GET_UINT16_FROM_LITTLE_ENDIAN((sigdata) + sizeof(s16)*6) & 0xFFFF,
+ CSR_GET_UINT16_FROM_LITTLE_ENDIAN((sigdata) + sizeof(s16)*7) & 0xFFFF, siglen);
+ if(signal_buffer_is_full(priv)) {
+ unifi_error(priv,"TO HOST signal queue FULL dropping the PDU\n");
+ for (i = 0; i < UNIFI_MAX_DATA_REFERENCES; i++) {
+ if (bulkdata->d[i].data_length != 0) {
+ unifi_net_data_free(priv, (void *)&bulkdata->d[i]);
+ }
+ }
+ return;
+ }
+ writePointer = priv->rxSignalBuffer.writePointer;
+ rx_buff = &priv->rxSignalBuffer.rx_buff[writePointer];
+ memcpy(rx_buff->bufptr,sigdata,siglen);
+ rx_buff->sig_len = siglen;
+ rx_buff->data_ptrs = *bulkdata;
+ writePointer++;
+ if(writePointer >= priv->rxSignalBuffer.size) {
+ writePointer =0;
+ }
+ unifi_trace(priv, UDBG4, "unifi_receive_event:writePtr = %d\n",priv->rxSignalBuffer.writePointer);
+ priv->rxSignalBuffer.writePointer = writePointer;
+
+#ifndef CSR_WIFI_RX_PATH_SPLIT_DONT_USE_WQ
+ queue_work(priv->rx_workqueue, &priv->rx_work_struct);
+#endif
+
+#else
+ unifi_process_receive_event(ospriv, sigdata, siglen, bulkdata);
+#endif
+ func_exit();
+} /* unifi_receive_event() */
+
diff --git a/drivers/staging/csr/unifi_native.h b/drivers/staging/csr/unifi_native.h
new file mode 100644
index 000000000000..a73b38e5e480
--- /dev/null
+++ b/drivers/staging/csr/unifi_native.h
@@ -0,0 +1,257 @@
+/*
+ *****************************************************************************
+ *
+ * FILE : unifi_native.h
+ *
+ * PURPOSE : Private header file for unifi driver support to wireless extensions.
+ *
+ * UDI = UniFi Debug Interface
+ *
+ * Copyright (C) 2005-2008 by Cambridge Silicon Radio Ltd.
+ *
+ * Refer to LICENSE.txt included with this source code for details on
+ * the license terms.
+ *
+ *****************************************************************************
+ */
+#ifndef __LINUX_UNIFI_NATIVE_H__
+#define __LINUX_UNIFI_NATIVE_H__ 1
+
+#include <linux/kernel.h>
+#include <linux/if_arp.h>
+
+
+/*
+ * scan.c wext.c autojoin.c
+ */
+/* Structure to hold results of a scan */
+typedef struct scan_info {
+
+/* CSR_MLME_SCAN_INDICATION msi; */
+
+ unsigned char *info_elems;
+ int info_elem_length;
+
+} scan_info_t;
+
+
+#define IE_VECTOR_MAXLEN 1024
+
+#ifdef CSR_SUPPORT_WEXT
+/*
+ * Structre to hold the wireless network configuration info.
+ */
+struct wext_config {
+
+ /* Requested channel when setting up an adhoc network */
+ int channel;
+
+ /* wireless extns mode: IW_MODE_AUTO, ADHOC, INFRA, MASTER ... MONITOR */
+ int mode;
+
+ /* The capabilities of the currently joined network */
+ int capability;
+
+ /* The interval between beacons if we create an IBSS */
+ int beacon_period;
+
+ /*
+ * Power-save parameters
+ */
+ /* The listen interval to ask for in Associate req. */
+ int assoc_listen_interval;
+ /* Power-mode to put UniFi into */
+
+ unsigned char desired_ssid[UNIFI_MAX_SSID_LEN]; /* the last ESSID set by SIOCSIWESSID */
+ int power_mode;
+ /* Whether to wake for broadcast packets (using DTIM interval) */
+ int wakeup_for_dtims;
+
+ /* Currently selected WEP Key ID (0..3) */
+ int wep_key_id;
+
+ wep_key_t wep_keys[NUM_WEPKEYS];
+
+/* CSR_AUTHENTICATION_TYPE auth_type; */
+ int privacy;
+
+ u32 join_failure_timeout;
+ u32 auth_failure_timeout;
+ u32 assoc_failure_timeout;
+
+ unsigned char generic_ie[IE_VECTOR_MAXLEN];
+ int generic_ie_len;
+
+ struct iw_statistics wireless_stats;
+
+
+ /* the ESSID we are currently associated to */
+ unsigned char current_ssid[UNIFI_MAX_SSID_LEN];
+ /* the BSSID we are currently associated to */
+ unsigned char current_bssid[6];
+
+ /*
+ * IW_AUTH_WPA_VERSION_DISABLED 0x00000001
+ * IW_AUTH_WPA_VERSION_WPA 0x00000002
+ * IW_AUTH_WPA_VERSION_WPA2 0x00000004
+ */
+ unsigned char wpa_version;
+
+ /*
+ * cipher selection:
+ * IW_AUTH_CIPHER_NONE 0x00000001
+ * IW_AUTH_CIPHER_WEP40 0x00000002
+ * IW_AUTH_CIPHER_TKIP 0x00000004
+ * IW_AUTH_CIPHER_CCMP 0x00000008
+ * IW_AUTH_CIPHER_WEP104 0x00000010
+ */
+ unsigned char pairwise_cipher_used;
+ unsigned char group_cipher_used;
+
+ unsigned int frag_thresh;
+ unsigned int rts_thresh;
+
+ /* U-APSD value, send with Association Request to WMM Enabled APs */
+ unsigned char wmm_bss_uapsd_mask;
+ /* The WMM capabilities of the selected BSS */
+ unsigned int bss_wmm_capabilities;
+
+ /* Flag to prevent a join when the ssid is set */
+ int disable_join_on_ssid_set;
+
+ /* Scan info */
+#define UNIFI_MAX_SCANS 32
+ scan_info_t scan_list[UNIFI_MAX_SCANS];
+ int num_scan_info;
+
+ /* Flag on whether non-802.1x packets are allowed out */
+/* CsrWifiRouterPortAction block_controlled_port;*/
+
+ /* Flag on whether we have completed an authenticate/associate process */
+ unsigned int flag_associated : 1;
+}; /* struct wext_config */
+
+#endif /* CSR_SUPPORT_WEXT */
+
+
+/*
+ * wext.c
+ */
+/*int mlme_set_protection(unifi_priv_t *priv, unsigned char *addr,
+ CSR_PROTECT_TYPE prot, CSR_KEY_TYPE key_type);
+*/
+
+/*
+ * scan.c
+ */
+/*
+void unifi_scan_indication_handler(unifi_priv_t *priv,
+ const CSR_MLME_SCAN_INDICATION *msg,
+ const unsigned char *extra,
+ unsigned int len);
+*/
+void unifi_clear_scan_table(unifi_priv_t *priv);
+scan_info_t *unifi_get_scan_report(unifi_priv_t *priv, int index);
+
+
+/*
+ * Utility functions
+ */
+const unsigned char *unifi_find_info_element(int id,
+ const unsigned char *info,
+ int len);
+int unifi_add_info_element(unsigned char *info,
+ int ie_id,
+ const unsigned char *ie_data,
+ int ie_len);
+
+/*
+ * autojoin.c
+ */
+/* Higher level fns */
+int unifi_autojoin(unifi_priv_t *priv, const char *ssid);
+/*
+int unifi_do_scan(unifi_priv_t *priv, int scantype, CSR_BSS_TYPE bsstype,
+ const char *ssid, int ssid_len);
+*/
+int unifi_set_powermode(unifi_priv_t *priv);
+int unifi_join_ap(unifi_priv_t *priv, scan_info_t *si);
+int unifi_join_bss(unifi_priv_t *priv, unsigned char *macaddr);
+int unifi_leave(unifi_priv_t *priv);
+unsigned int unifi_get_wmm_bss_capabilities(unifi_priv_t *priv,
+ unsigned char *ie_vector,
+ int ie_len, int *ap_capabilities);
+
+/*
+ * Status and management.
+ */
+int uf_init_wext_interface(unifi_priv_t *priv);
+void uf_deinit_wext_interface(unifi_priv_t *priv);
+
+/*
+ * Function to reset UniFi's 802.11 state by sending MLME-RESET.req
+ */
+int unifi_reset_state(unifi_priv_t *priv, unsigned char *macaddr, unsigned char set_default_mib);
+
+
+/*
+ * mlme.c
+ */
+/* Abort an MLME operation - useful in error recovery */
+int uf_abort_mlme(unifi_priv_t *priv);
+
+int unifi_mlme_blocking_request(unifi_priv_t *priv, ul_client_t *pcli,
+ CSR_SIGNAL *sig, bulk_data_param_t *data_ptrs,
+ int timeout);
+void unifi_mlme_copy_reply_and_wakeup_client(ul_client_t *pcli,
+ CSR_SIGNAL *signal, int signal_len,
+ const bulk_data_param_t *bulkdata);
+
+/*
+ * Utility functions
+ */
+const char *lookup_reason_code(int reason);
+const char *lookup_result_code(int result);
+
+
+/*
+ * sme_native.c
+ */
+int uf_sme_init(unifi_priv_t *priv);
+void uf_sme_deinit(unifi_priv_t *priv);
+int sme_sys_suspend(unifi_priv_t *priv);
+int sme_sys_resume(unifi_priv_t *priv);
+int sme_mgt_wifi_on(unifi_priv_t *priv);
+
+/* Callback for event logging to SME clients (unifi_manager) */
+void sme_native_log_event(ul_client_t *client,
+ const u8 *sig_packed, int sig_len,
+ const bulk_data_param_t *bulkdata,
+ int dir);
+
+void sme_native_mlme_event_handler(ul_client_t *pcli,
+ const u8 *sig_packed, int sig_len,
+ const bulk_data_param_t *bulkdata,
+ int dir);
+
+/* Task to query statistics from the MIB */
+#define UF_SME_STATS_WQ_TIMEOUT 2000 /* in msecs */
+void uf_sme_stats_wq(struct work_struct *work);
+
+void uf_native_process_udi_signal(ul_client_t *pcli,
+ const u8 *packed_signal,
+ int packed_signal_len,
+ const bulk_data_param_t *bulkdata, int dir);
+#ifdef UNIFI_SNIFF_ARPHRD
+/*
+ * monitor.c
+ */
+int uf_start_sniff(unifi_priv_t *priv);
+/*
+void ma_sniffdata_ind(void *ospriv,
+ const CSR_MA_SNIFFDATA_INDICATION *ind,
+ const bulk_data_param_t *bulkdata);
+*/
+#endif /* ARPHRD_IEEE80211_PRISM */
+
+#endif /* __LINUX_UNIFI_NATIVE_H__ */
diff --git a/drivers/staging/csr/unifi_os.h b/drivers/staging/csr/unifi_os.h
new file mode 100644
index 000000000000..4e63a942f1a2
--- /dev/null
+++ b/drivers/staging/csr/unifi_os.h
@@ -0,0 +1,145 @@
+/*
+ * ---------------------------------------------------------------------------
+ *
+ * FILE: os_linux/unifi_os.h
+ *
+ * PURPOSE:
+ * This header file provides the OS-dependent facilities for a linux
+ * environment.
+ *
+ * Copyright (C) 2005-2008 by Cambridge Silicon Radio Ltd.
+ *
+ * Refer to LICENSE.txt included with this source code for details on
+ * the license terms.
+ *
+ * ---------------------------------------------------------------------------
+ */
+#ifndef __UNIFI_OS_LINUX_H__
+#define __UNIFI_OS_LINUX_H__ 1
+
+#include <linux/kernel.h>
+#include <linux/time.h>
+#include <linux/list.h>
+#include <linux/delay.h>
+#include <linux/string.h>
+
+/*
+ * Needed for core/signals.c
+ */
+#include <stddef.h>
+
+
+/* Define INLINE directive*/
+#define INLINE inline
+
+/* Malloc and free */
+CsrResult unifi_net_data_malloc(void *ospriv, bulk_data_desc_t *bulk_data_slot, unsigned int size);
+void unifi_net_data_free(void *ospriv, bulk_data_desc_t *bulk_data_slot);
+#define CSR_WIFI_ALIGN_BYTES 4
+CsrResult unifi_net_dma_align(void *ospriv, bulk_data_desc_t *bulk_data_slot);
+
+/*
+ * Byte Order
+ * Note that __le*_to_cpu and __cpu_to_le* return an unsigned value!
+ */
+#ifdef __KERNEL__
+#define unifi2host_16(n) (__le16_to_cpu((n)))
+#define unifi2host_32(n) (__le32_to_cpu((n)))
+#define host2unifi_16(n) (__cpu_to_le16((n)))
+#define host2unifi_32(n) (__cpu_to_le32((n)))
+#endif
+
+/* Module parameters */
+extern int unifi_debug;
+
+/* debugging */
+#ifdef UNIFI_DEBUG
+/*
+ * unifi_debug is a verbosity level for debug messages
+ * UDBG0 msgs are always printed if UNIFI_DEBUG is defined
+ * UDBG1 msgs are printed if UNIFI_DEBUG is defined and unifi_debug > 0
+ * etc.
+ */
+
+#define func_enter() \
+ do { \
+ if (unifi_debug >= 5) { \
+ printk("unifi: => %s\n", __FUNCTION__); \
+ } \
+ } while (0)
+#define func_exit() \
+ do { \
+ if (unifi_debug >= 5) { \
+ printk("unifi: <= %s\n", __FUNCTION__); \
+ } \
+ } while (0)
+#define func_exit_r(_rc) \
+ do { \
+ if (unifi_debug >= 5) { \
+ printk("unifi: <= %s %d\n", __FUNCTION__, (int)(_rc)); \
+ } \
+ } while (0)
+
+
+#define ASSERT(cond) \
+ do { \
+ if (!(cond)) { \
+ printk("Assertion failed in %s at %s:%d: %s\n", \
+ __FUNCTION__, __FILE__, __LINE__, #cond); \
+ } \
+ } while (0)
+
+
+void unifi_dump(void *ospriv, int lvl, const char *msg, void *mem, u16 len);
+void dump(void *mem, u16 len);
+void dump16(void *mem, u16 len);
+#ifdef CSR_WIFI_HIP_DEBUG_OFFLINE
+void dump_str(void *mem, u16 len);
+#endif /* CSR_WIFI_HIP_DEBUG_OFFLINE */
+
+void unifi_error(void* ospriv, const char *fmt, ...);
+void unifi_warning(void* ospriv, const char *fmt, ...);
+void unifi_notice(void* ospriv, const char *fmt, ...);
+void unifi_info(void* ospriv, const char *fmt, ...);
+
+void unifi_trace(void* ospriv, int level, const char *fmt, ...);
+
+#else
+
+/* Stubs */
+#define func_enter()
+#define func_exit()
+#define func_exit_r(_rc)
+
+#define ASSERT(cond)
+
+static inline void unifi_dump(void *ospriv, int lvl, const char *msg, void *mem, u16 len) {}
+static inline void dump(void *mem, u16 len) {}
+static inline void dump16(void *mem, u16 len) {}
+#ifdef CSR_WIFI_HIP_DEBUG_OFFLINE
+static inline void dump_str(void *mem, u16 len) {}
+#endif /* CSR_WIFI_HIP_DEBUG_OFFLINE */
+
+void unifi_error_nop(void* ospriv, const char *fmt, ...);
+void unifi_trace_nop(void* ospriv, int level, const char *fmt, ...);
+#define unifi_error if(1);else unifi_error_nop
+#define unifi_warning if(1);else unifi_error_nop
+#define unifi_notice if(1);else unifi_error_nop
+#define unifi_info if(1);else unifi_error_nop
+#define unifi_trace if(1);else unifi_trace_nop
+
+#endif /* UNIFI_DEBUG */
+
+
+/* Different levels of diagnostic detail... */
+#define UDBG0 0 /* always prints in debug build */
+#define UDBG1 1
+#define UDBG2 2
+#define UDBG3 3
+#define UDBG4 4
+#define UDBG5 5
+#define UDBG6 6
+#define UDBG7 7
+
+
+#endif /* __UNIFI_OS_LINUX_H__ */
diff --git a/drivers/staging/csr/unifi_pdu_processing.c b/drivers/staging/csr/unifi_pdu_processing.c
new file mode 100644
index 000000000000..7c7e8d49ae42
--- /dev/null
+++ b/drivers/staging/csr/unifi_pdu_processing.c
@@ -0,0 +1,3755 @@
+/*
+ * ---------------------------------------------------------------------------
+ * FILE: unifi_pdu_processing.c
+ *
+ * PURPOSE:
+ * This file provides the PDU handling functionality before it gets sent to unfi and after
+ * receiving a PDU from unifi
+ *
+ * Copyright (C) 2010 by Cambridge Silicon Radio Ltd.
+ *
+ * Refer to LICENSE.txt included with this source code for details on
+ * the license terms.
+ *
+ * ---------------------------------------------------------------------------
+ */
+
+
+#include <linux/types.h>
+#include <linux/etherdevice.h>
+#include <linux/vmalloc.h>
+
+#include "csr_wifi_hip_unifi.h"
+#include "csr_wifi_hip_conversions.h"
+#include "csr_time.h"
+#include "unifi_priv.h"
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,13)
+#include <net/iw_handler.h>
+#endif
+#include <net/pkt_sched.h>
+
+#ifdef CSR_SUPPORT_SME
+static void _update_buffered_pkt_params_after_alignment(unifi_priv_t *priv, bulk_data_param_t *bulkdata,
+ tx_buffered_packets_t* buffered_pkt)
+{
+ struct sk_buff *skb ;
+ u32 align_offset;
+
+ if (priv == NULL || bulkdata == NULL || buffered_pkt == NULL){
+ return;
+ }
+
+ skb = (struct sk_buff*)bulkdata->d[0].os_net_buf_ptr;
+ align_offset = (u32)(long)(bulkdata->d[0].os_data_ptr) & (CSR_WIFI_ALIGN_BYTES-1);
+ if(align_offset){
+ skb_pull(skb,align_offset);
+ }
+
+ buffered_pkt->bulkdata.os_data_ptr = bulkdata->d[0].os_data_ptr;
+ buffered_pkt->bulkdata.data_length = bulkdata->d[0].data_length;
+ buffered_pkt->bulkdata.os_net_buf_ptr = bulkdata->d[0].os_net_buf_ptr;
+ buffered_pkt->bulkdata.net_buf_length = bulkdata->d[0].net_buf_length;
+}
+#endif
+
+void
+unifi_frame_ma_packet_req(unifi_priv_t *priv, CSR_PRIORITY priority,
+ CSR_RATE TransmitRate, CSR_CLIENT_TAG hostTag,
+ u16 interfaceTag, CSR_TRANSMISSION_CONTROL transmissionControl,
+ CSR_PROCESS_ID leSenderProcessId, u8 *peerMacAddress,
+ CSR_SIGNAL *signal)
+{
+
+ CSR_MA_PACKET_REQUEST *req = &signal->u.MaPacketRequest;
+ netInterface_priv_t *interfacePriv;
+ u8 ba_session_idx = 0;
+ ba_session_tx_struct *ba_session = NULL;
+ u8 *ba_addr = NULL;
+
+ interfacePriv = priv->interfacePriv[interfaceTag];
+
+ unifi_trace(priv, UDBG5,
+ "In unifi_frame_ma_packet_req, Frame for Peer: %pMF\n",
+ peerMacAddress);
+ signal->SignalPrimitiveHeader.SignalId = CSR_MA_PACKET_REQUEST_ID;
+ signal->SignalPrimitiveHeader.ReceiverProcessId = 0;
+ signal->SignalPrimitiveHeader.SenderProcessId = leSenderProcessId;
+
+ /* Fill the MA-PACKET.req */
+ req->Priority = priority;
+ unifi_trace(priv, UDBG3, "Tx Frame with Priority: 0x%x\n", req->Priority);
+
+ /* A value of 0 is used for auto selection of rates. But for P2P GO case
+ * for action frames the rate is governed by SME. Hence instead of 0,
+ * the rate is filled in with the value passed here
+ */
+ req->TransmitRate = TransmitRate;
+
+ /* packets from netdev then no confirm required but packets from
+ * Nme/Sme eapol data frames requires the confirmation
+ */
+ req->TransmissionControl = transmissionControl;
+ req->VirtualInterfaceIdentifier =
+ uf_get_vif_identifier(interfacePriv->interfaceMode,interfaceTag);
+ memcpy(req->Ra.x, peerMacAddress, ETH_ALEN);
+
+ if (hostTag == 0xffffffff) {
+ req->HostTag = interfacePriv->tag++;
+ req->HostTag |= 0x40000000;
+ unifi_trace(priv, UDBG3, "new host tag assigned = 0x%x\n", req->HostTag);
+ interfacePriv->tag &= 0x0fffffff;
+ } else {
+ req->HostTag = hostTag;
+ unifi_trace(priv, UDBG3, "host tag got from SME = 0x%x\n", req->HostTag);
+ }
+ /* check if BA session exists for the peer MAC address on same tID */
+ if(interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_AP ||
+ interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_P2PGO){
+ ba_addr = peerMacAddress;
+ }else{
+ ba_addr = interfacePriv->bssid.a;
+ }
+ for (ba_session_idx=0; ba_session_idx < MAX_SUPPORTED_BA_SESSIONS_TX; ba_session_idx++){
+ ba_session = interfacePriv->ba_session_tx[ba_session_idx];
+ if (ba_session){
+ if ((!memcmp(ba_session->macAddress.a, ba_addr, ETH_ALEN)) && (ba_session->tID == priority)){
+ req->TransmissionControl |= CSR_ALLOW_BA;
+ break;
+ }
+ }
+ }
+
+ unifi_trace(priv, UDBG5, "leaving unifi_frame_ma_packet_req\n");
+}
+
+#ifdef CSR_SUPPORT_SME
+
+#define TRANSMISSION_CONTROL_TRIGGER_MASK 0x0001
+#define TRANSMISSION_CONTROL_EOSP_MASK 0x0002
+
+static
+int frame_and_send_queued_pdu(unifi_priv_t* priv,tx_buffered_packets_t* buffered_pkt,
+ CsrWifiRouterCtrlStaInfo_t *staRecord,u8 moreData , u8 eosp)
+{
+
+ CSR_SIGNAL signal;
+ bulk_data_param_t bulkdata;
+ int result;
+ u8 toDs, fromDs, macHeaderLengthInBytes = MAC_HEADER_SIZE;
+ u8 *qc;
+ u16 *fc = (u16*)(buffered_pkt->bulkdata.os_data_ptr);
+ unsigned long lock_flags;
+ unifi_trace(priv, UDBG3, "frame_and_send_queued_pdu with moreData: %d , EOSP: %d\n",moreData,eosp);
+ unifi_frame_ma_packet_req(priv, buffered_pkt->priority, buffered_pkt->rate, buffered_pkt->hostTag,
+ buffered_pkt->interfaceTag, buffered_pkt->transmissionControl,
+ buffered_pkt->leSenderProcessId, buffered_pkt->peerMacAddress.a, &signal);
+ bulkdata.d[0].os_data_ptr = buffered_pkt->bulkdata.os_data_ptr;
+ bulkdata.d[0].data_length = buffered_pkt->bulkdata.data_length;
+ bulkdata.d[0].os_net_buf_ptr = buffered_pkt->bulkdata.os_net_buf_ptr;
+ bulkdata.d[0].net_buf_length = buffered_pkt->bulkdata.net_buf_length;
+ bulkdata.d[1].os_data_ptr = NULL;
+ bulkdata.d[1].data_length = 0;
+ bulkdata.d[1].os_net_buf_ptr =0;
+ bulkdata.d[1].net_buf_length =0;
+
+ if(moreData) {
+ *fc |= cpu_to_le16(IEEE802_11_FC_MOREDATA_MASK);
+ } else {
+ *fc &= cpu_to_le16(~IEEE802_11_FC_MOREDATA_MASK);
+ }
+
+ if((staRecord != NULL)&& (staRecord->wmmOrQosEnabled == TRUE))
+ {
+ unifi_trace(priv, UDBG3, "frame_and_send_queued_pdu WMM Enabled: %d \n",staRecord->wmmOrQosEnabled);
+
+ toDs = (*fc & cpu_to_le16(IEEE802_11_FC_TO_DS_MASK))?1 : 0;
+ fromDs = (*fc & cpu_to_le16(IEEE802_11_FC_FROM_DS_MASK))? 1: 0;
+
+ switch(le16_to_cpu(*fc) & IEEE80211_FC_SUBTYPE_MASK)
+ {
+ case IEEE802_11_FC_TYPE_QOS_DATA & IEEE80211_FC_SUBTYPE_MASK:
+ case IEEE802_11_FC_TYPE_QOS_NULL & IEEE80211_FC_SUBTYPE_MASK:
+ /* If both are set then the Address4 exists (only for AP) */
+ if (fromDs && toDs) {
+ /* 6 is the size of Address4 field */
+ macHeaderLengthInBytes += (QOS_CONTROL_HEADER_SIZE + 6);
+ } else {
+ macHeaderLengthInBytes += QOS_CONTROL_HEADER_SIZE;
+ }
+
+ /* If order bit set then HT control field is the part of MAC header */
+ if (*fc & cpu_to_le16(IEEE80211_FC_ORDER_MASK)) {
+ macHeaderLengthInBytes += HT_CONTROL_HEADER_SIZE;
+ qc = (u8*)(buffered_pkt->bulkdata.os_data_ptr + (macHeaderLengthInBytes-6));
+ } else {
+ qc = (u8*)(buffered_pkt->bulkdata.os_data_ptr + (macHeaderLengthInBytes-2));
+ }
+ *qc = eosp ? *qc | (1 << 4) : *qc & (~(1 << 4));
+ break;
+ default:
+ if (fromDs && toDs)
+ macHeaderLengthInBytes += 6;
+ }
+
+ }
+ result = ul_send_signal_unpacked(priv, &signal, &bulkdata);
+ if(result){
+ _update_buffered_pkt_params_after_alignment(priv, &bulkdata,buffered_pkt);
+ }
+
+ /* Decrement the packet counts queued in driver */
+ if (result != -ENOSPC) {
+ /* protect entire counter updation by disabling preemption */
+ if (!priv->noOfPktQueuedInDriver) {
+ unifi_error(priv, "packets queued in driver 0 still decrementing\n");
+ } else {
+ spin_lock_irqsave(&priv->tx_q_lock,lock_flags);
+ priv->noOfPktQueuedInDriver--;
+ spin_unlock_irqrestore(&priv->tx_q_lock,lock_flags);
+ }
+ /* Sta Record is available for all unicast (except genericMgt Frames) & in other case its NULL */
+ if (staRecord) {
+ spin_lock_irqsave(&priv->staRecord_lock,lock_flags);
+ if (!staRecord->noOfPktQueued) {
+ unifi_error(priv, "packets queued in driver per station is 0 still decrementing\n");
+ } else {
+ staRecord->noOfPktQueued--;
+ }
+ /* if the STA alive probe frame has failed then reset the saved host tag */
+ if (result){
+ if (staRecord->nullDataHostTag == buffered_pkt->hostTag){
+ staRecord->nullDataHostTag = INVALID_HOST_TAG;
+ }
+ }
+ spin_unlock_irqrestore(&priv->staRecord_lock,lock_flags);
+ }
+
+ }
+ return result;
+}
+#ifdef CSR_SUPPORT_SME
+static
+void set_eosp_transmit_ctrl(unifi_priv_t *priv, struct list_head *txList)
+{
+ /* dequeue the tx data packets from the appropriate queue */
+ tx_buffered_packets_t *tx_q_item = NULL;
+ struct list_head *listHead;
+ struct list_head *placeHolder;
+ unsigned long lock_flags;
+
+
+ unifi_trace(priv, UDBG5, "entering set_eosp_transmit_ctrl\n");
+ /* check for list empty */
+ if (list_empty(txList)) {
+ unifi_warning(priv, "In set_eosp_transmit_ctrl, the list is empty\n");
+ return;
+ }
+
+ /* return the last node , and modify it. */
+
+ spin_lock_irqsave(&priv->tx_q_lock,lock_flags);
+ list_for_each_prev_safe(listHead, placeHolder, txList) {
+ tx_q_item = list_entry(listHead, tx_buffered_packets_t, q);
+ tx_q_item->transmissionControl |= TRANSMISSION_CONTROL_EOSP_MASK;
+ tx_q_item->transmissionControl = (tx_q_item->transmissionControl & ~(CSR_NO_CONFIRM_REQUIRED));
+ unifi_trace(priv, UDBG1,
+ "set_eosp_transmit_ctrl Transmission Control = 0x%x hostTag = 0x%x \n",tx_q_item->transmissionControl,tx_q_item->hostTag);
+ unifi_trace(priv,UDBG3,"in set_eosp_transmit_ctrl no.of buffered frames %d\n",priv->noOfPktQueuedInDriver);
+ break;
+ }
+ spin_unlock_irqrestore(&priv->tx_q_lock,lock_flags);
+ unifi_trace(priv, UDBG1,"List Empty %d\n",list_empty(txList));
+ unifi_trace(priv, UDBG5, "leaving set_eosp_transmit_ctrl\n");
+ return;
+}
+
+static
+void send_vif_availibility_rsp(unifi_priv_t *priv,CSR_VIF_IDENTIFIER vif,CSR_RESULT_CODE resultCode)
+{
+ CSR_SIGNAL signal;
+ CSR_MA_VIF_AVAILABILITY_RESPONSE *rsp;
+ bulk_data_param_t *bulkdata = NULL;
+ int r;
+
+ unifi_trace(priv, UDBG3, "send_vif_availibility_rsp : invoked with resultCode = %d \n", resultCode);
+
+ memset(&signal,0,sizeof(CSR_SIGNAL));
+ rsp = &signal.u.MaVifAvailabilityResponse;
+ rsp->VirtualInterfaceIdentifier = vif;
+ rsp->ResultCode = resultCode;
+ signal.SignalPrimitiveHeader.SignalId = CSR_MA_VIF_AVAILABILITY_RESPONSE_ID;
+ signal.SignalPrimitiveHeader.ReceiverProcessId = 0;
+ signal.SignalPrimitiveHeader.SenderProcessId = priv->netdev_client->sender_id;
+
+ /* Send the signal to UniFi */
+ r = ul_send_signal_unpacked(priv, &signal, bulkdata);
+ if(r) {
+ unifi_error(priv,"Availibility response sending failed %x status %d\n",vif,r);
+ }
+ else {
+ unifi_trace(priv, UDBG3, "send_vif_availibility_rsp : status = %d \n", r);
+ }
+}
+#endif
+
+static
+void verify_and_accomodate_tx_packet(unifi_priv_t *priv)
+{
+ tx_buffered_packets_t *tx_q_item;
+ unsigned long lock_flags;
+ struct list_head *listHead, *list;
+ struct list_head *placeHolder;
+ u8 i, j,eospFramedeleted=0;
+ u8 thresholdExcedeDueToBroadcast = TRUE;
+ /* it will be made it interface Specific in the future when multi interfaces are supported ,
+ right now interface 0 is considered */
+ netInterface_priv_t *interfacePriv = priv->interfacePriv[0];
+ CsrWifiRouterCtrlStaInfo_t *staInfo = NULL;
+
+ unifi_trace(priv, UDBG3, "entering verify_and_accomodate_tx_packet\n");
+
+ for(i = 0; i < UNIFI_MAX_CONNECTIONS; i++) {
+ staInfo = interfacePriv->staInfo[i];
+ if (staInfo && (staInfo->noOfPktQueued >= CSR_WIFI_DRIVER_MAX_PKT_QUEUING_THRESHOLD_PER_PEER)) {
+ /* remove the first(oldest) packet from the all the access catogory, since data
+ * packets for station record crossed the threshold limit (64 for AP supporting
+ * 8 peers)
+ */
+ unifi_trace(priv,UDBG3,"number of station pkts queued= %d for sta id = %d\n", staInfo->noOfPktQueued, staInfo->aid);
+ for(j = 0; j < MAX_ACCESS_CATOGORY; j++) {
+ list = &staInfo->dataPdu[j];
+ spin_lock_irqsave(&priv->tx_q_lock,lock_flags);
+ list_for_each_safe(listHead, placeHolder, list) {
+ tx_q_item = list_entry(listHead, tx_buffered_packets_t, q);
+ list_del(listHead);
+ thresholdExcedeDueToBroadcast = FALSE;
+ unifi_net_data_free(priv, &tx_q_item->bulkdata);
+ kfree(tx_q_item);
+ tx_q_item = NULL;
+ if (!priv->noOfPktQueuedInDriver) {
+ unifi_error(priv, "packets queued in driver 0 still decrementing in %s\n", __FUNCTION__);
+ } else {
+ /* protection provided by spinlock */
+ priv->noOfPktQueuedInDriver--;
+
+ }
+ /* Sta Record is available for all unicast (except genericMgt Frames) & in other case its NULL */
+ if (!staInfo->noOfPktQueued) {
+ unifi_error(priv, "packets queued in driver per station is 0 still decrementing in %s\n", __FUNCTION__);
+ } else {
+ spin_lock(&priv->staRecord_lock);
+ staInfo->noOfPktQueued--;
+ spin_unlock(&priv->staRecord_lock);
+ }
+ break;
+ }
+ spin_unlock_irqrestore(&priv->tx_q_lock,lock_flags);
+ }
+ }
+ }
+ if (thresholdExcedeDueToBroadcast && interfacePriv->noOfbroadcastPktQueued > CSR_WIFI_DRIVER_MINIMUM_BROADCAST_PKT_THRESHOLD ) {
+ /* Remove the packets from genericMulticastOrBroadCastFrames queue
+ * (the max packets in driver is reached due to broadcast/multicast frames)
+ */
+ spin_lock_irqsave(&priv->tx_q_lock,lock_flags);
+ list_for_each_safe(listHead, placeHolder, &interfacePriv->genericMulticastOrBroadCastFrames) {
+ tx_q_item = list_entry(listHead, tx_buffered_packets_t, q);
+ if(eospFramedeleted){
+ tx_q_item->transmissionControl |= TRANSMISSION_CONTROL_EOSP_MASK;
+ tx_q_item->transmissionControl = (tx_q_item->transmissionControl & ~(CSR_NO_CONFIRM_REQUIRED));
+ unifi_trace(priv, UDBG1,"updating eosp for next packet hostTag:= 0x%x ",tx_q_item->hostTag);
+ eospFramedeleted =0;
+ break;
+ }
+
+ if(tx_q_item->transmissionControl & TRANSMISSION_CONTROL_EOSP_MASK ){
+ eospFramedeleted = 1;
+ }
+ unifi_trace(priv,UDBG1, "freeing of multicast packets ToC = 0x%x hostTag = 0x%x \n",tx_q_item->transmissionControl,tx_q_item->hostTag);
+ list_del(listHead);
+ unifi_net_data_free(priv, &tx_q_item->bulkdata);
+ kfree(tx_q_item);
+ priv->noOfPktQueuedInDriver--;
+ spin_lock(&priv->staRecord_lock);
+ interfacePriv->noOfbroadcastPktQueued--;
+ spin_unlock(&priv->staRecord_lock);
+ if(!eospFramedeleted){
+ break;
+ }
+ }
+ spin_unlock_irqrestore(&priv->tx_q_lock,lock_flags);
+ }
+ unifi_trace(priv, UDBG3, "leaving verify_and_accomodate_tx_packet\n");
+}
+
+static
+CsrResult enque_tx_data_pdu(unifi_priv_t *priv, bulk_data_param_t *bulkdata,
+ struct list_head *list, CSR_SIGNAL *signal,
+ u8 requeueOnSamePos)
+{
+
+ /* queue the tx data packets on to appropriate queue */
+ CSR_MA_PACKET_REQUEST *req = &signal->u.MaPacketRequest;
+ tx_buffered_packets_t *tx_q_item;
+ unsigned long lock_flags;
+
+ unifi_trace(priv, UDBG5, "entering enque_tx_data_pdu\n");
+ if(!list) {
+ unifi_error(priv,"List is not specified\n");
+ return CSR_RESULT_FAILURE;
+ }
+
+ /* Removes aged packets & adds the incoming packet */
+ if (priv->noOfPktQueuedInDriver >= CSR_WIFI_DRIVER_SUPPORT_FOR_MAX_PKT_QUEUEING) {
+ unifi_trace(priv,UDBG3,"number of pkts queued= %d \n", priv->noOfPktQueuedInDriver);
+ verify_and_accomodate_tx_packet(priv);
+ }
+
+
+
+ tx_q_item = (tx_buffered_packets_t *)kmalloc(sizeof(tx_buffered_packets_t), GFP_ATOMIC);
+ if (tx_q_item == NULL) {
+ unifi_error(priv,
+ "Failed to allocate %d bytes for tx packet record\n",
+ sizeof(tx_buffered_packets_t));
+ func_exit();
+ return CSR_RESULT_FAILURE;
+ }
+
+ /* disable the preemption */
+ spin_lock_irqsave(&priv->tx_q_lock,lock_flags);
+ INIT_LIST_HEAD(&tx_q_item->q);
+ /* fill the tx_q structure members */
+ tx_q_item->bulkdata.os_data_ptr = bulkdata->d[0].os_data_ptr;
+ tx_q_item->bulkdata.data_length = bulkdata->d[0].data_length;
+ tx_q_item->bulkdata.os_net_buf_ptr = bulkdata->d[0].os_net_buf_ptr;
+ tx_q_item->bulkdata.net_buf_length = bulkdata->d[0].net_buf_length;
+ tx_q_item->interfaceTag = req->VirtualInterfaceIdentifier & 0xff;
+ tx_q_item->hostTag = req->HostTag;
+ tx_q_item->leSenderProcessId = signal->SignalPrimitiveHeader.SenderProcessId;
+ tx_q_item->transmissionControl = req->TransmissionControl;
+ tx_q_item->priority = req->Priority;
+ tx_q_item->rate = req->TransmitRate;
+ memcpy(tx_q_item->peerMacAddress.a, req->Ra.x, ETH_ALEN);
+
+
+
+ if (requeueOnSamePos) {
+ list_add(&tx_q_item->q, list);
+ } else {
+ list_add_tail(&tx_q_item->q, list);
+ }
+
+ /* Count of packet queued in driver */
+ priv->noOfPktQueuedInDriver++;
+ spin_unlock_irqrestore(&priv->tx_q_lock,lock_flags);
+ unifi_trace(priv, UDBG5, "leaving enque_tx_data_pdu\n");
+ return CSR_RESULT_SUCCESS;
+}
+
+#ifdef CSR_WIFI_REQUEUE_PACKET_TO_HAL
+CsrResult unifi_reque_ma_packet_request (void *ospriv, u32 host_tag,
+ u16 txStatus, bulk_data_desc_t *bulkDataDesc)
+{
+ CsrResult status = CSR_RESULT_SUCCESS;
+ unifi_priv_t *priv = (unifi_priv_t*)ospriv;
+ netInterface_priv_t *interfacePriv;
+ struct list_head *list = NULL;
+ CsrWifiRouterCtrlStaInfo_t *staRecord = NULL;
+ bulk_data_param_t bulkData;
+ CSR_SIGNAL signal;
+ CSR_PRIORITY priority = 0;
+ u16 interfaceTag = 0;
+ unifi_TrafficQueue priority_q;
+ u16 frameControl = 0, frameType = 0;
+ unsigned long lock_flags;
+
+ interfacePriv = priv->interfacePriv[interfaceTag];
+
+ /* If the current mode is not AP or P2PGO then just return failure
+ * to clear the hip slot
+ */
+ if(!((interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_AP) ||
+ (interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_P2PGO))) {
+ return CSR_RESULT_FAILURE;
+ }
+
+ unifi_trace(priv, UDBG6, "unifi_reque_ma_packet_request: host_tag = 0x%x\n", host_tag);
+
+ staRecord = CsrWifiRouterCtrlGetStationRecordFromPeerMacAddress(priv,
+ (((u8 *) bulkDataDesc->os_data_ptr) + 4),
+ interfaceTag);
+ if (NULL == staRecord) {
+ unifi_trace(priv, UDBG5, "unifi_reque_ma_packet_request: Invalid STA record \n");
+ return CSR_RESULT_FAILURE;
+ }
+
+ /* Update TIM if MA-PACKET.cfm fails with status as Tx-retry-limit or No-BSS and then just return failure
+ * to clear the hip slot associated with the Packet
+ */
+ if (CSR_TX_RETRY_LIMIT == txStatus || CSR_TX_NO_BSS == txStatus) {
+ if (staRecord->timSet == CSR_WIFI_TIM_RESET || staRecord->timSet == CSR_WIFI_TIM_RESETTING)
+ {
+ unifi_trace(priv, UDBG2, "unifi_reque_ma_packet_request: CFM failed with Retry Limit or No BSS-->update TIM\n");
+ if (!staRecord->timRequestPendingFlag) {
+ update_tim(priv, staRecord->aid, 1, interfaceTag, staRecord->assignedHandle);
+ }
+ else {
+ /* Cache the TimSet value so that it will processed immidiatly after
+ * completing the current setTim Request
+ */
+ staRecord->updateTimReqQueued = 1;
+ unifi_trace(priv, UDBG6, "unifi_reque_ma_packet_request: One more UpdateTim Request(:%d)Queued for AID %x\n",
+ staRecord->updateTimReqQueued, staRecord->aid);
+ }
+ }
+ return CSR_RESULT_FAILURE;
+ }
+ else if ((CSR_TX_LIFETIME == txStatus) || (CSR_TX_BLOCK_ACK_TIMEOUT == txStatus) ||
+ (CSR_TX_FAIL_TRANSMISSION_VIF_INTERRUPTED == txStatus) ||
+ (CSR_TX_REJECTED_PEER_STATION_SLEEPING == txStatus) ||
+ (CSR_TX_REJECTED_DTIM_STARTED == txStatus)) {
+ /* Extract the Frame control and the frame type */
+ frameControl = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(bulkDataDesc->os_data_ptr);
+ frameType = ((frameControl & IEEE80211_FC_TYPE_MASK) >> FRAME_CONTROL_TYPE_FIELD_OFFSET);
+
+ /* Mgmt frames will not be re-queued for Tx
+ * so just return failure to clear the hip slot
+ */
+ if (IEEE802_11_FRAMETYPE_MANAGEMENT == frameType) {
+ return CSR_RESULT_FAILURE;
+ }
+ else if (IEEE802_11_FRAMETYPE_DATA == frameType) {
+ /* QOS NULL and DATA NULL frames will not be re-queued for Tx
+ * so just return failure to clear the hip slot
+ */
+ if ((((frameControl & IEEE80211_FC_SUBTYPE_MASK) >> FRAME_CONTROL_SUBTYPE_FIELD_OFFSET) == QOS_DATA_NULL) ||
+ (((frameControl & IEEE80211_FC_SUBTYPE_MASK) >> FRAME_CONTROL_SUBTYPE_FIELD_OFFSET)== DATA_NULL )) {
+ return CSR_RESULT_FAILURE;
+ }
+ }
+
+ /* Extract the Packet priority */
+ if (TRUE == staRecord->wmmOrQosEnabled) {
+ u16 qosControl = 0;
+ u8 dataFrameType = 0;
+
+ dataFrameType =((frameControl & IEEE80211_FC_SUBTYPE_MASK) >> 4);
+
+ if (dataFrameType == QOS_DATA) {
+ /* QoS control field is offset from frame control by 2 (frame control)
+ * + 2 (duration/ID) + 2 (sequence control) + 3*ETH_ALEN or 4*ETH_ALEN
+ */
+ if((frameControl & IEEE802_11_FC_TO_DS_MASK) && (frameControl & IEEE802_11_FC_FROM_DS_MASK)) {
+ qosControl= CSR_GET_UINT16_FROM_LITTLE_ENDIAN(bulkDataDesc->os_data_ptr + 30);
+ }
+ else {
+ qosControl = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(bulkDataDesc->os_data_ptr + 24);
+ }
+ }
+
+ priority = (CSR_PRIORITY)(qosControl & IEEE802_11_QC_TID_MASK);
+
+ if (priority < CSR_QOS_UP0 || priority > CSR_QOS_UP7) {
+ unifi_trace(priv, UDBG5, "unifi_reque_ma_packet_request: Invalid priority:%x \n", priority);
+ return CSR_RESULT_FAILURE;
+ }
+ }
+ else {
+ priority = CSR_CONTENTION;
+ }
+
+ /* Frame Bulk data to requeue it back to HAL Queues */
+ bulkData.d[0].os_data_ptr = bulkDataDesc->os_data_ptr;
+ bulkData.d[0].data_length = bulkDataDesc->data_length;
+ bulkData.d[0].os_net_buf_ptr = bulkDataDesc->os_net_buf_ptr;
+ bulkData.d[0].net_buf_length = bulkDataDesc->net_buf_length;
+
+ bulkData.d[1].os_data_ptr = NULL;
+ bulkData.d[1].os_net_buf_ptr = NULL;
+ bulkData.d[1].data_length = bulkData.d[1].net_buf_length = 0;
+
+ /* Initialize signal to zero */
+ memset(&signal, 0, sizeof(CSR_SIGNAL));
+
+ /* Frame MA Packet Req */
+ unifi_frame_ma_packet_req(priv, priority, 0, host_tag,
+ interfaceTag, CSR_NO_CONFIRM_REQUIRED,
+ priv->netdev_client->sender_id,
+ staRecord->peerMacAddress.a, &signal);
+
+ /* Find the Q-Priority */
+ priority_q = unifi_frame_priority_to_queue(priority);
+ list = &staRecord->dataPdu[priority_q];
+
+ /* Place the Packet on to HAL Queue */
+ status = enque_tx_data_pdu(priv, &bulkData, list, &signal, TRUE);
+
+ /* Update the Per-station queued packet counter */
+ if (!status) {
+ spin_lock_irqsave(&priv->staRecord_lock, lock_flags);
+ staRecord->noOfPktQueued++;
+ spin_unlock_irqrestore(&priv->staRecord_lock, lock_flags);
+ }
+ }
+ else {
+ /* Packet will not be re-queued for any of the other MA Packet Tx failure
+ * reasons so just return failure to clear the hip slot
+ */
+ return CSR_RESULT_FAILURE;
+ }
+
+ return status;
+}
+#endif
+
+static void is_all_ac_deliver_enabled_and_moredata(CsrWifiRouterCtrlStaInfo_t *staRecord, u8 *allDeliveryEnabled, u8 *dataAvailable)
+{
+ u8 i;
+ *allDeliveryEnabled = TRUE;
+ for (i = 0 ;i < MAX_ACCESS_CATOGORY; i++) {
+ if (!IS_DELIVERY_ENABLED(staRecord->powersaveMode[i])) {
+ /* One is is not Delivery Enabled */
+ *allDeliveryEnabled = FALSE;
+ break;
+ }
+ }
+ if (*allDeliveryEnabled) {
+ *dataAvailable = (!list_empty(&staRecord->dataPdu[0]) || !list_empty(&staRecord->dataPdu[1])
+ ||!list_empty(&staRecord->dataPdu[2]) ||!list_empty(&staRecord->dataPdu[3])
+ ||!list_empty(&staRecord->mgtFrames));
+ }
+}
+
+/*
+ * ---------------------------------------------------------------------------
+ * uf_handle_tim_cfm
+ *
+ *
+ * This function updates tim status in host depending confirm status from firmware
+ *
+ * Arguments:
+ * priv Pointer to device private context struct
+ * cfm CSR_MLME_SET_TIM_CONFIRM
+ * receiverProcessId SenderProcessID to fetch handle & timSet status
+ *
+ * ---------------------------------------------------------------------------
+ */
+void uf_handle_tim_cfm(unifi_priv_t *priv, CSR_MLME_SET_TIM_CONFIRM *cfm, u16 receiverProcessId)
+{
+ u8 handle = CSR_WIFI_GET_STATION_HANDLE_FROM_RECEIVER_ID(receiverProcessId);
+ u8 timSetStatus = CSR_WIFI_GET_TIMSET_STATE_FROM_RECEIVER_ID(receiverProcessId);
+ u16 interfaceTag = (cfm->VirtualInterfaceIdentifier & 0xff);
+ netInterface_priv_t *interfacePriv = priv->interfacePriv[interfaceTag];
+ CsrWifiRouterCtrlStaInfo_t *staRecord = NULL;
+ /* This variable holds what TIM value we wanted to set in firmware */
+ u16 timSetValue = 0;
+ /* Irrespective of interface the count maintained */
+ static u8 retryCount = 0;
+ unsigned long lock_flags;
+ unifi_trace(priv, UDBG3, "entering %s, handle = %x, timSetStatus = %x\n", __FUNCTION__, handle, timSetStatus);
+
+ if (interfaceTag >= CSR_WIFI_NUM_INTERFACES) {
+ unifi_warning(priv, "bad interfaceTag = %x\n", interfaceTag);
+ return;
+ }
+
+ if ((handle != CSR_WIFI_BROADCAST_OR_MULTICAST_HANDLE) && (handle >= UNIFI_MAX_CONNECTIONS)) {
+ unifi_warning(priv, "bad station Handle = %x\n", handle);
+ return;
+ }
+
+ if (handle != CSR_WIFI_BROADCAST_OR_MULTICAST_HANDLE) {
+ spin_lock_irqsave(&priv->staRecord_lock,lock_flags);
+ if ((staRecord = ((CsrWifiRouterCtrlStaInfo_t *) (interfacePriv->staInfo[handle]))) == NULL) {
+ spin_unlock_irqrestore(&priv->staRecord_lock,lock_flags);
+ unifi_warning(priv, "uf_handle_tim_cfm: station record is NULL handle = %x\n", handle);
+ return;
+ }
+ spin_unlock_irqrestore(&priv->staRecord_lock,lock_flags);
+ }
+ switch(timSetStatus)
+ {
+ case CSR_WIFI_TIM_SETTING:
+ timSetValue = CSR_WIFI_TIM_SET;
+ break;
+ case CSR_WIFI_TIM_RESETTING:
+ timSetValue = CSR_WIFI_TIM_RESET;
+ break;
+ default:
+ unifi_warning(priv, "timSet state is %x: Debug\n", timSetStatus);
+ return;
+ }
+
+ /* check TIM confirm for success/failures */
+ switch(cfm->ResultCode)
+ {
+ case CSR_RC_SUCCESS:
+ if (handle != CSR_WIFI_BROADCAST_OR_MULTICAST_HANDLE) {
+ /* Unicast frame & station record available */
+ if (timSetStatus == staRecord->timSet) {
+ staRecord->timSet = timSetValue;
+ /* fh_cmd_q can also be full at some point of time!,
+ * resetting count as queue is cleaned by firmware at this point
+ */
+ retryCount = 0;
+ unifi_trace(priv, UDBG2, "tim (%s) successfully in firmware\n", (timSetValue)?"SET":"RESET");
+ } else {
+ unifi_trace(priv, UDBG3, "receiver processID = %x, success: request & confirm states are not matching in TIM cfm: Debug status = %x, staRecord->timSet = %x, handle = %x\n",
+ receiverProcessId, timSetStatus, staRecord->timSet, handle);
+ }
+
+ /* Reset TIM pending flag to send next TIM request */
+ staRecord->timRequestPendingFlag = FALSE;
+
+ /* Make sure that one more UpdateTim request is queued, if Queued its value
+ * should be CSR_WIFI_TIM_SET or CSR_WIFI_TIM_RESET
+ */
+ if (0xFF != staRecord->updateTimReqQueued)
+ {
+ /* Process the UpdateTim Request which is queued while previous UpdateTim was in progress */
+ if (staRecord->timSet != staRecord->updateTimReqQueued)
+ {
+ unifi_trace(priv, UDBG2, "uf_handle_tim_cfm : Processing Queued UpdateTimReq \n");
+
+ update_tim(priv, staRecord->aid, staRecord->updateTimReqQueued, interfaceTag, handle);
+
+ staRecord->updateTimReqQueued = 0xFF;
+ }
+ }
+ } else {
+
+ interfacePriv->bcTimSet = timSetValue;
+ /* fh_cmd_q can also be full at some point of time!,
+ * resetting count as queue is cleaned by firmware at this point
+ */
+ retryCount = 0;
+ unifi_trace(priv, UDBG3, "tim (%s) successfully for broadcast frame in firmware\n", (timSetValue)?"SET":"RESET");
+
+ /* Reset DTIM pending flag to send next DTIM request */
+ interfacePriv->bcTimSetReqPendingFlag = FALSE;
+
+ /* Make sure that one more UpdateDTim request is queued, if Queued its value
+ * should be CSR_WIFI_TIM_SET or CSR_WIFI_TIM_RESET
+ */
+ if (0xFF != interfacePriv->bcTimSetReqQueued)
+ {
+ /* Process the UpdateTim Request which is queued while previous UpdateTim was in progress */
+ if (interfacePriv->bcTimSet != interfacePriv->bcTimSetReqQueued)
+ {
+ unifi_trace(priv, UDBG2, "uf_handle_tim_cfm : Processing Queued UpdateDTimReq \n");
+
+ update_tim(priv, 0, interfacePriv->bcTimSetReqQueued, interfaceTag, 0xFFFFFFFF);
+
+ interfacePriv->bcTimSetReqQueued = 0xFF;
+ }
+ }
+
+ }
+ break;
+ case CSR_RC_INVALID_PARAMETERS:
+ case CSR_RC_INSUFFICIENT_RESOURCE:
+ /* check for max retry limit & send again
+ * MAX_RETRY_LIMIT is not maintained for each set of transactions..Its generic
+ * If failure crosses this Limit, we have to take a call to FIX
+ */
+ if (retryCount > UNIFI_MAX_RETRY_LIMIT) {
+ u8 moreData = FALSE;
+ retryCount = 0;
+ /* Because of continuos traffic in fh_cmd_q the tim set request is failing (exceeding retry limit)
+ * but if we didn't synchronize our timSet varible state with firmware then it can cause below issues
+ * cond 1. We want to SET tim in firmware if its fails & max retry limit reached
+ * -> If host set's the timSet to 1, we wont try to send(as max retry reached) update tim but
+ * firmware is not updated with queue(TIM) status so it wont set TIM in beacon finally host start piling
+ * up data & wont try to set tim in firmware (This can cause worser performance)
+ * cond 2. We want to reset tim in firmware it fails & reaches max retry limit
+ * -> If host sets the timSet to Zero, it wont try to set a TIM request unless we wont have any packets
+ * to be queued, so beacon unnecessarily advertizes the TIM
+ */
+
+ if(staRecord) {
+ if(!staRecord->wmmOrQosEnabled) {
+ moreData = (!list_empty(&staRecord->dataPdu[UNIFI_TRAFFIC_Q_CONTENTION]) ||
+ !list_empty(&staRecord->dataPdu[UNIFI_TRAFFIC_Q_VO]) ||
+ !list_empty(&staRecord->mgtFrames));
+ } else {
+ /* Peer is QSTA */
+ u8 allDeliveryEnabled = 0, dataAvailable = 0;
+ /* Check if all AC's are Delivery Enabled */
+ is_all_ac_deliver_enabled_and_moredata(staRecord, &allDeliveryEnabled, &dataAvailable);
+ /*check for more data in non-delivery enabled queues*/
+ moreData = (uf_is_more_data_for_non_delivery_ac(staRecord) || (allDeliveryEnabled && dataAvailable));
+
+ }
+ /* To avoid cond 1 & 2, check internal Queues status, if we have more Data then set RESET the timSet(0),
+ * so we are trying to be in sync with firmware & next packets before queuing atleast try to
+ * set TIM in firmware otherwise it SET timSet(1)
+ */
+ if (moreData) {
+ staRecord->timSet = CSR_WIFI_TIM_RESET;
+ } else {
+ staRecord->timSet = CSR_WIFI_TIM_SET;
+ }
+ } else {
+ /* Its a broadcast frames */
+ moreData = (!list_empty(&interfacePriv->genericMulticastOrBroadCastMgtFrames) ||
+ !list_empty(&interfacePriv->genericMulticastOrBroadCastFrames));
+ if (moreData) {
+ update_tim(priv, 0, CSR_WIFI_TIM_SET, interfaceTag, 0xFFFFFFFF);
+ } else {
+ update_tim(priv, 0, CSR_WIFI_TIM_RESET, interfaceTag, 0xFFFFFFFF);
+ }
+ }
+
+ unifi_error(priv, "no of error's for TIM setting crossed the Limit: verify\n");
+ return;
+ }
+ retryCount++;
+
+ if (handle != CSR_WIFI_BROADCAST_OR_MULTICAST_HANDLE) {
+ if (timSetStatus == staRecord->timSet) {
+ unifi_warning(priv, "tim request failed, retry for AID = %x\n", staRecord->aid);
+ update_tim(priv, staRecord->aid, timSetValue, interfaceTag, handle);
+ } else {
+ unifi_trace(priv, UDBG1, "failure: request & confirm states are not matching in TIM cfm: Debug status = %x, staRecord->timSet = %x\n",
+ timSetStatus, staRecord->timSet);
+ }
+ } else {
+ unifi_warning(priv, "tim request failed, retry for broadcast frames\n");
+ update_tim(priv, 0, timSetValue, interfaceTag, 0xFFFFFFFF);
+ }
+ break;
+ default:
+ unifi_warning(priv, "tim update request failed resultcode = %x\n", cfm->ResultCode);
+ }
+
+ unifi_trace(priv, UDBG2, "leaving %s\n", __FUNCTION__);
+}
+
+/*
+ * ---------------------------------------------------------------------------
+ * update_tim
+ *
+ *
+ * This function updates tim status in firmware for AID[1 to UNIFI_MAX_CONNECTIONS] or
+ * AID[0] for broadcast/multicast packets.
+ *
+ * NOTE: The LSB (least significant BYTE) of senderId while sending this MLME premitive
+ * has been modified(utilized) as below
+ *
+ * SenderID in signal's SignalPrimitiveHeader is 2 byte the lowe byte bitmap is below
+ *
+ * station handle(6 bits) timSet Status (2 bits)
+ * --------------------- ----------------------
+ * 0 0 0 0 0 0 | 0 0
+ *
+ * timSet Status can be one of below:
+ *
+ * CSR_WIFI_TIM_RESET
+ * CSR_WIFI_TIM_RESETTING
+ * CSR_WIFI_TIM_SET
+ * CSR_WIFI_TIM_SETTING
+ *
+ * Arguments:
+ * priv Pointer to device private context struct
+ * aid can be 1 t0 UNIFI_MAX_CONNECTIONS & 0 means multicast/broadcast
+ * setTim value SET(1) / RESET(0)
+ * interfaceTag the interfaceID on which activity going on
+ * handle from (0 <= handle < UNIFI_MAX_CONNECTIONS)
+ *
+ * ---------------------------------------------------------------------------
+ */
+void update_tim(unifi_priv_t * priv, u16 aid, u8 setTim, u16 interfaceTag, u32 handle)
+{
+ CSR_SIGNAL signal;
+ s32 r;
+ CSR_MLME_SET_TIM_REQUEST *req = &signal.u.MlmeSetTimRequest;
+ bulk_data_param_t *bulkdata = NULL;
+ netInterface_priv_t *interfacePriv = priv->interfacePriv[interfaceTag];
+ u8 senderIdLsb = 0;
+ CsrWifiRouterCtrlStaInfo_t *staRecord = NULL;
+ u32 oldTimSetStatus = 0, timSetStatus = 0;
+
+ unifi_trace(priv, UDBG5, "entering the update_tim routine\n");
+
+
+ if (handle == 0xFFFFFFFF) {
+ handle &= CSR_WIFI_BROADCAST_OR_MULTICAST_HANDLE;
+ if (setTim == interfacePriv->bcTimSet)
+ {
+ unifi_trace(priv, UDBG3, "update_tim, Drop:Hdl=%x, timval=%d, globalTim=%d\n", handle, setTim, interfacePriv->bcTimSet);
+ return;
+ }
+ } else if ((handle != 0xFFFFFFFF) && (handle >= UNIFI_MAX_CONNECTIONS)) {
+ unifi_warning(priv, "bad station Handle = %x\n", handle);
+ return;
+ }
+
+ if (setTim) {
+ timSetStatus = CSR_WIFI_TIM_SETTING;
+ } else {
+ timSetStatus = CSR_WIFI_TIM_RESETTING;
+ }
+
+ if (handle != CSR_WIFI_BROADCAST_OR_MULTICAST_HANDLE) {
+ if ((staRecord = ((CsrWifiRouterCtrlStaInfo_t *) (interfacePriv->staInfo[handle]))) == NULL) {
+ unifi_warning(priv, "station record is NULL in update_tim: handle = %x :debug\n", handle);
+ return;
+ }
+ /* In case of signal sending failed, revert back to old state */
+ oldTimSetStatus = staRecord->timSet;
+ staRecord->timSet = timSetStatus;
+ }
+
+ /* pack senderID LSB */
+ senderIdLsb = CSR_WIFI_PACK_SENDER_ID_LSB_FOR_TIM_REQ(handle, timSetStatus);
+
+ /* initialize signal to zero */
+ memset(&signal, 0, sizeof(CSR_SIGNAL));
+
+ /* Frame the MLME-SET-TIM request */
+ signal.SignalPrimitiveHeader.SignalId = CSR_MLME_SET_TIM_REQUEST_ID;
+ signal.SignalPrimitiveHeader.ReceiverProcessId = 0;
+ CSR_COPY_UINT16_TO_LITTLE_ENDIAN(((priv->netdev_client->sender_id & 0xff00) | senderIdLsb),
+ (u8*)&signal.SignalPrimitiveHeader.SenderProcessId);
+
+ /* set The virtual interfaceIdentifier, aid, tim value */
+ req->VirtualInterfaceIdentifier = uf_get_vif_identifier(interfacePriv->interfaceMode,interfaceTag);
+ req->AssociationId = aid;
+ req->TimValue = setTim;
+
+
+ unifi_trace(priv, UDBG2, "update_tim:AID %x,senderIdLsb = 0x%x, handle = 0x%x, timSetStatus = %x, sender proceesID = %x \n",
+ aid,senderIdLsb, handle, timSetStatus, signal.SignalPrimitiveHeader.SenderProcessId);
+
+ /* Send the signal to UniFi */
+ r = ul_send_signal_unpacked(priv, &signal, bulkdata);
+ if (r) {
+ /* No need to free bulk data, as TIM request doesn't carries any data */
+ unifi_error(priv, "Error queueing CSR_MLME_SET_TIM_REQUEST signal\n");
+ if (staRecord) {
+ staRecord->timSet = oldTimSetStatus ;
+ }
+ else
+ {
+ /* MLME_SET_TIM.req sending failed here for AID0, so revert back our bcTimSet status */
+ interfacePriv->bcTimSet = !setTim;
+ }
+ }
+ else {
+ /* Update tim request pending flag and ensure no more TIM set requests are send
+ for the same station until TIM confirm is received */
+ if (staRecord) {
+ staRecord->timRequestPendingFlag = TRUE;
+ }
+ else
+ {
+ /* Update tim request (for AID 0) pending flag and ensure no more DTIM set requests are send
+ * for the same station until TIM confirm is received
+ */
+ interfacePriv->bcTimSetReqPendingFlag = TRUE;
+ }
+ }
+ unifi_trace(priv, UDBG5, "leaving the update_tim routine\n");
+}
+
+static
+void process_peer_active_transition(unifi_priv_t * priv,
+ CsrWifiRouterCtrlStaInfo_t *staRecord,
+ u16 interfaceTag)
+{
+ int r,i;
+ u8 spaceAvail[4] = {TRUE,TRUE,TRUE,TRUE};
+ tx_buffered_packets_t * buffered_pkt = NULL;
+ unsigned long lock_flags;
+ netInterface_priv_t *interfacePriv = priv->interfacePriv[interfaceTag];
+
+ unifi_trace(priv, UDBG5, "entering process_peer_active_transition\n");
+
+ if(IS_DTIM_ACTIVE(interfacePriv->dtimActive,interfacePriv->multicastPduHostTag)) {
+ /* giving more priority to multicast packets so delaying unicast packets*/
+ unifi_trace(priv,UDBG2, "Multicast transmission is going on so resume unicast transmission after DTIM over\n");
+
+ /* As station is active now, even though AP is not able to send frames to it
+ * because of DTIM, it needs to reset the TIM here
+ */
+ if (!staRecord->timRequestPendingFlag){
+ if((staRecord->timSet == CSR_WIFI_TIM_SET) || (staRecord->timSet == CSR_WIFI_TIM_SETTING)){
+ update_tim(priv, staRecord->aid, 0, interfaceTag, staRecord->assignedHandle);
+ }
+ }
+ else
+ {
+ /* Cache the TimSet value so that it will processed immidiatly after
+ * completing the current setTim Request
+ */
+ staRecord->updateTimReqQueued = 0;
+ unifi_trace(priv, UDBG6, "update_tim : One more UpdateTim Request (Tim value:%d) Queued for AID %x\n", staRecord->updateTimReqQueued,
+ staRecord->aid);
+ }
+ return;
+ }
+ while((buffered_pkt=dequeue_tx_data_pdu(priv, &staRecord->mgtFrames))) {
+ buffered_pkt->transmissionControl &=
+ ~(TRANSMISSION_CONTROL_TRIGGER_MASK|TRANSMISSION_CONTROL_EOSP_MASK);
+ if((r=frame_and_send_queued_pdu(priv,buffered_pkt,staRecord,0,FALSE)) == -ENOSPC) {
+ unifi_trace(priv, UDBG2, "p_p_a_t:(ENOSPC) Mgt Frame queueing \n");
+ /* Enqueue at the head of the queue */
+ spin_lock_irqsave(&priv->tx_q_lock,lock_flags);
+ list_add(&buffered_pkt->q, &staRecord->mgtFrames);
+ spin_unlock_irqrestore(&priv->tx_q_lock,lock_flags);
+ priv->pausedStaHandle[3]=(u8)(staRecord->assignedHandle);
+ spaceAvail[3] = FALSE;
+ break;
+ } else {
+ if(r){
+ unifi_trace (priv, UDBG1, " HIP validation failure : PDU sending failed \n");
+ /* the PDU failed where we can't do any thing so free the storage */
+ unifi_net_data_free(priv, &buffered_pkt->bulkdata);
+ }
+ kfree(buffered_pkt);
+ }
+ }
+ if (!staRecord->timRequestPendingFlag) {
+ if (staRecord->txSuspend) {
+ if(staRecord->timSet == CSR_WIFI_TIM_SET) {
+ update_tim(priv,staRecord->aid,0,interfaceTag, staRecord->assignedHandle);
+ }
+ return;
+ }
+ }
+ else
+ {
+ /* Cache the TimSet value so that it will processed immidiatly after
+ * completing the current setTim Request
+ */
+ staRecord->updateTimReqQueued = 0;
+ unifi_trace(priv, UDBG6, "update_tim : One more UpdateTim Request (Tim value:%d) Queued for AID %x\n", staRecord->updateTimReqQueued,
+ staRecord->aid);
+ }
+ for(i=3;i>=0;i--) {
+ if(!spaceAvail[i])
+ continue;
+ unifi_trace(priv, UDBG6, "p_p_a_t:data pkt sending for AC %d \n",i);
+ while((buffered_pkt=dequeue_tx_data_pdu(priv, &staRecord->dataPdu[i]))) {
+ buffered_pkt->transmissionControl &=
+ ~(TRANSMISSION_CONTROL_TRIGGER_MASK|TRANSMISSION_CONTROL_EOSP_MASK);
+ if((r=frame_and_send_queued_pdu(priv,buffered_pkt,staRecord,0,FALSE)) == -ENOSPC) {
+ /* Clear the trigger bit transmission control*/
+ /* Enqueue at the head of the queue */
+ spin_lock_irqsave(&priv->tx_q_lock,lock_flags);
+ list_add(&buffered_pkt->q, &staRecord->dataPdu[i]);
+ spin_unlock_irqrestore(&priv->tx_q_lock,lock_flags);
+ priv->pausedStaHandle[i]=(u8)(staRecord->assignedHandle);
+ break;
+ } else {
+ if(r){
+ unifi_trace (priv, UDBG1, " HIP validation failure : PDU sending failed \n");
+ /* the PDU failed where we can't do any thing so free the storage */
+ unifi_net_data_free(priv, &buffered_pkt->bulkdata);
+ }
+ kfree(buffered_pkt);
+ }
+ }
+ }
+ if (!staRecord->timRequestPendingFlag){
+ if((staRecord->timSet == CSR_WIFI_TIM_SET) || (staRecord->timSet == CSR_WIFI_TIM_SETTING)) {
+ unifi_trace(priv, UDBG3, "p_p_a_t:resetting tim .....\n");
+ update_tim(priv,staRecord->aid,0,interfaceTag, staRecord->assignedHandle);
+ }
+ }
+ else
+ {
+ /* Cache the TimSet value so that it will processed immidiatly after
+ * completing the current setTim Request
+ */
+ staRecord->updateTimReqQueued = 0;
+ unifi_trace(priv, UDBG6, "update_tim : One more UpdateTim Request (Tim value:%d) Queued for AID %x\n", staRecord->updateTimReqQueued,
+ staRecord->aid);
+ }
+ unifi_trace(priv, UDBG5, "leaving process_peer_active_transition\n");
+}
+
+
+
+void uf_process_ma_pkt_cfm_for_ap(unifi_priv_t *priv,u16 interfaceTag, const CSR_MA_PACKET_CONFIRM *pkt_cfm)
+{
+ netInterface_priv_t *interfacePriv;
+ u8 i;
+ CsrWifiRouterCtrlStaInfo_t *staRecord = NULL;
+ interfacePriv = priv->interfacePriv[interfaceTag];
+
+
+ if(pkt_cfm->HostTag == interfacePriv->multicastPduHostTag) {
+ unifi_trace(priv,UDBG2,"CFM for marked Multicast Tag = %x\n",interfacePriv->multicastPduHostTag);
+ interfacePriv->multicastPduHostTag = 0xffffffff;
+ resume_suspended_uapsd(priv,interfaceTag);
+ resume_unicast_buffered_frames(priv,interfaceTag);
+ if(list_empty(&interfacePriv->genericMulticastOrBroadCastMgtFrames) &&
+ list_empty(&interfacePriv->genericMulticastOrBroadCastFrames)) {
+ unifi_trace(priv,UDBG1,"Resetting multicastTIM");
+ if (!interfacePriv->bcTimSetReqPendingFlag)
+ {
+ update_tim(priv,0,CSR_WIFI_TIM_RESET,interfaceTag, 0xFFFFFFFF);
+ }
+ else
+ {
+ /* Cache the DTimSet value so that it will processed immidiatly after
+ * completing the current setDTim Request
+ */
+ interfacePriv->bcTimSetReqQueued = CSR_WIFI_TIM_RESET;
+ unifi_trace(priv, UDBG2, "uf_process_ma_pkt_cfm_for_ap : One more UpdateDTim Request(%d) Queued \n",
+ interfacePriv->bcTimSetReqQueued);
+ }
+
+ }
+ return;
+ }
+
+ /* Check if it is a Confirm for null data frame used
+ * for probing station activity
+ */
+ for(i =0; i < UNIFI_MAX_CONNECTIONS; i++) {
+ staRecord = (CsrWifiRouterCtrlStaInfo_t *) (interfacePriv->staInfo[i]);
+ if (staRecord && (staRecord->nullDataHostTag == pkt_cfm->HostTag)) {
+
+ unifi_trace(priv, UDBG1, "CFM for Inactive probe Null frame (tag = %x, status = %d)\n",
+ pkt_cfm->HostTag,
+ pkt_cfm->TransmissionStatus
+ );
+ staRecord->nullDataHostTag = INVALID_HOST_TAG;
+
+ if(pkt_cfm->TransmissionStatus == CSR_TX_RETRY_LIMIT){
+ CsrTime now;
+ CsrTime inactive_time;
+
+ unifi_trace(priv, UDBG1, "Nulldata to probe STA ALIVE Failed with retry limit\n");
+ /* Recheck if there is some activity after null data is sent.
+ *
+ * If still there is no activity then send a disconnected indication
+ * to SME to delete the station record.
+ */
+ if (staRecord->activity_flag){
+ return;
+ }
+ now = CsrTimeGet(NULL);
+
+ if (staRecord->lastActivity > now)
+ {
+ /* simple timer wrap (for 1 wrap) */
+ inactive_time = CsrTimeAdd((CsrTime)CsrTimeSub(CSR_SCHED_TIME_MAX, staRecord->lastActivity),
+ now);
+ }
+ else
+ {
+ inactive_time = (CsrTime)CsrTimeSub(now, staRecord->lastActivity);
+ }
+
+ if (inactive_time >= STA_INACTIVE_TIMEOUT_VAL)
+ {
+ struct list_head send_cfm_list;
+ u8 j;
+
+ /* The SME/NME may be waiting for confirmation for requested frames to this station.
+ * Though this is --VERY UNLIKELY-- in case of station in active mode. But still as a
+ * a defensive check, it loops through buffered frames for this station and if confirmation
+ * is requested, send auto confirmation with failure status. Also flush the frames so
+ * that these are not processed again in PEER_DEL_REQ handler.
+ */
+ INIT_LIST_HEAD(&send_cfm_list);
+
+ uf_prepare_send_cfm_list_for_queued_pkts(priv,
+ &send_cfm_list,
+ &(staRecord->mgtFrames));
+
+ uf_flush_list(priv, &(staRecord->mgtFrames));
+
+ for(j = 0; j < MAX_ACCESS_CATOGORY; j++){
+ uf_prepare_send_cfm_list_for_queued_pkts(priv,
+ &send_cfm_list,
+ &(staRecord->dataPdu[j]));
+
+ uf_flush_list(priv,&(staRecord->dataPdu[j]));
+ }
+
+ send_auto_ma_packet_confirm(priv, staRecord->interfacePriv, &send_cfm_list);
+
+
+
+ unifi_warning(priv, "uf_process_ma_pkt_cfm_for_ap: Router Disconnected IND Peer (%x-%x-%x-%x-%x-%x)\n",
+ staRecord->peerMacAddress.a[0],
+ staRecord->peerMacAddress.a[1],
+ staRecord->peerMacAddress.a[2],
+ staRecord->peerMacAddress.a[3],
+ staRecord->peerMacAddress.a[4],
+ staRecord->peerMacAddress.a[5]);
+
+ CsrWifiRouterCtrlConnectedIndSend(priv->CSR_WIFI_SME_IFACEQUEUE,
+ 0,
+ staRecord->interfacePriv->InterfaceTag,
+ staRecord->peerMacAddress,
+ CSR_WIFI_ROUTER_CTRL_PEER_DISCONNECTED);
+ }
+
+ }
+ else if (pkt_cfm->TransmissionStatus == CSR_TX_SUCCESSFUL)
+ {
+ staRecord->activity_flag = TRUE;
+ }
+ }
+ }
+}
+
+#endif
+u16 uf_get_vif_identifier (CsrWifiRouterCtrlMode mode, u16 tag)
+{
+ switch(mode)
+ {
+ case CSR_WIFI_ROUTER_CTRL_MODE_STA:
+ case CSR_WIFI_ROUTER_CTRL_MODE_P2PCLI:
+ return (0x02<<8|tag);
+
+ case CSR_WIFI_ROUTER_CTRL_MODE_AP:
+ case CSR_WIFI_ROUTER_CTRL_MODE_P2PGO:
+ return (0x03<<8|tag);
+
+ case CSR_WIFI_ROUTER_CTRL_MODE_IBSS:
+ return (0x01<<8|tag);
+
+ case CSR_WIFI_ROUTER_CTRL_MODE_MONITOR:
+ return (0x04<<8|tag);
+ case CSR_WIFI_ROUTER_CTRL_MODE_AMP:
+ return (0x05<<8|tag);
+ default:
+ return tag;
+ }
+}
+
+#ifdef CSR_SUPPORT_SME
+
+/*
+ * ---------------------------------------------------------------------------
+ * update_macheader
+ *
+ *
+ * These functions updates mac header for intra BSS packet
+ * routing.
+ * NOTE: This function always has to be called in rx context which
+ * is in bh thread context since GFP_KERNEL is used. In soft IRQ/ Interrupt
+ * context shouldn't be used
+ *
+ * Arguments:
+ * priv Pointer to device private context struct
+ * skb Socket buffer containing data packet to transmit
+ * newSkb Socket buffer containing data packet + Mac header if no sufficient headroom in skb
+ * priority to append QOS control header in Mac header
+ * bulkdata if newSkb allocated then bulkdata updated to send to unifi
+ * interfaceTag the interfaceID on which activity going on
+ * macHeaderLengthInBytes no. of bytes of mac header in received frame
+ * qosDestination used to append Qos control field
+ *
+ * Returns:
+ * Zero on success or -1 on error.
+ * ---------------------------------------------------------------------------
+ */
+
+static int update_macheader(unifi_priv_t *priv, struct sk_buff *skb,
+ struct sk_buff *newSkb, CSR_PRIORITY *priority,
+ bulk_data_param_t *bulkdata, u16 interfaceTag,
+ u8 macHeaderLengthInBytes,
+ u8 qosDestination)
+{
+
+ u16 *fc = NULL;
+ u8 direction = 0, toDs, fromDs;
+ u8 *bufPtr = NULL;
+ u8 sa[ETH_ALEN], da[ETH_ALEN];
+ netInterface_priv_t *interfacePriv = priv->interfacePriv[interfaceTag];
+ int headroom;
+ u8 macHeaderBuf[IEEE802_11_DATA_FRAME_MAC_HEADER_SIZE] = {0};
+
+ unifi_trace(priv, UDBG5, "entering the update_macheader function\n");
+
+ /* temporary buffer for the Mac header storage */
+ memcpy(macHeaderBuf, skb->data, macHeaderLengthInBytes);
+
+ /* remove the Macheader from the skb */
+ skb_pull(skb, macHeaderLengthInBytes);
+
+ /* get the skb headroom for skb_push check */
+ headroom = skb_headroom(skb);
+
+ /* pointer to frame control field */
+ fc = (u16*) macHeaderBuf;
+
+ toDs = (*fc & cpu_to_le16(IEEE802_11_FC_TO_DS_MASK))?1 : 0;
+ fromDs = (*fc & cpu_to_le16(IEEE802_11_FC_FROM_DS_MASK))? 1: 0;
+ unifi_trace(priv, UDBG5, "In update_macheader function, fromDs = %x, toDs = %x\n", fromDs, toDs);
+ direction = ((fromDs | (toDs << 1)) & 0x3);
+
+ /* Address1 or 3 from the macheader */
+ memcpy(da, macHeaderBuf+4+toDs*12, ETH_ALEN);
+ /* Address2, 3 or 4 from the mac header */
+ memcpy(sa, macHeaderBuf+10+fromDs*(6+toDs*8), ETH_ALEN);
+
+ unifi_trace(priv, UDBG3, "update_macheader:direction = %x\n", direction);
+ /* update the toDs, fromDs & address fields in Mac header */
+ switch(direction)
+ {
+ case 2:
+ /* toDs = 1 & fromDs = 0 , toAp when frames received from peer
+ * while sending this packet to Destination the Mac header changed
+ * as fromDs = 1 & toDs = 0, fromAp
+ */
+ *fc &= cpu_to_le16(~IEEE802_11_FC_TO_DS_MASK);
+ *fc |= cpu_to_le16(IEEE802_11_FC_FROM_DS_MASK);
+ /* Address1: MAC address of the actual destination (4 = 2+2) */
+ memcpy(macHeaderBuf + 4, da, ETH_ALEN);
+ /* Address2: The MAC address of the AP (10 = 2+2+6) */
+ memcpy(macHeaderBuf + 10, &interfacePriv->bssid, ETH_ALEN);
+ /* Address3: MAC address of the actual source from mac header (16 = 2+2+6+6) */
+ memcpy(macHeaderBuf + 16, sa, ETH_ALEN);
+ break;
+ case 3:
+ unifi_trace(priv, UDBG3, "when both the toDs & fromDS set, NOT SUPPORTED\n");
+ break;
+ default:
+ unifi_trace(priv, UDBG3, "problem in decoding packet in update_macheader \n");
+ return -1;
+ }
+
+ /* frameType is Data always, Validation is done before calling this function */
+
+ /* check for the souce station type */
+ switch(le16_to_cpu(*fc) & IEEE80211_FC_SUBTYPE_MASK)
+ {
+ case IEEE802_11_FC_TYPE_QOS_DATA & IEEE80211_FC_SUBTYPE_MASK:
+ /* No need to modify the qos control field */
+ if (!qosDestination) {
+
+ /* If source Sta is QOS enabled & if this bit set, then HTC is supported by
+ * peer station & htc field present in macHeader
+ */
+ if (*fc & cpu_to_le16(IEEE80211_FC_ORDER_MASK)) {
+ /* HT control field present in Mac header
+ * 6 = sizeof(qosControl) + sizeof(htc)
+ */
+ macHeaderLengthInBytes -= 6;
+ } else {
+ macHeaderLengthInBytes -= 2;
+ }
+ /* Destination STA is non qos so change subtype to DATA */
+ *fc &= cpu_to_le16(~IEEE80211_FC_SUBTYPE_MASK);
+ *fc |= cpu_to_le16(IEEE802_11_FC_TYPE_DATA);
+ /* remove the qos control field & HTC(if present). new macHeaderLengthInBytes is less than old
+ * macHeaderLengthInBytes so no need to verify skb headroom
+ */
+ if (headroom < macHeaderLengthInBytes) {
+ unifi_trace(priv, UDBG1, " sufficient headroom not there to push updated mac header \n");
+ return -1;
+ }
+ bufPtr = (u8 *) skb_push(skb, macHeaderLengthInBytes);
+
+ /* update bulk data os_data_ptr */
+ bulkdata->d[0].os_data_ptr = skb->data;
+ bulkdata->d[0].os_net_buf_ptr = (unsigned char*)skb;
+ bulkdata->d[0].data_length = skb->len;
+
+ } else {
+ /* pointing to QOS control field */
+ u8 qc;
+ if (*fc & cpu_to_le16(IEEE80211_FC_ORDER_MASK)) {
+ qc = *((u8*)(macHeaderBuf + (macHeaderLengthInBytes - 4 - 2)));
+ } else {
+ qc = *((u8*)(macHeaderBuf + (macHeaderLengthInBytes - 2)));
+ }
+
+ if ((qc & IEEE802_11_QC_TID_MASK) > 7) {
+ *priority = 7;
+ } else {
+ *priority = qc & IEEE802_11_QC_TID_MASK;
+ }
+
+ unifi_trace(priv, UDBG1, "Incoming packet priority from QSTA is %x\n", *priority);
+
+ if (headroom < macHeaderLengthInBytes) {
+ unifi_trace(priv, UDBG3, " sufficient headroom not there to push updated mac header \n");
+ return -1;
+ }
+ bufPtr = (u8 *) skb_push(skb, macHeaderLengthInBytes);
+ }
+ break;
+ default:
+ {
+ bulk_data_param_t data_ptrs;
+ CsrResult csrResult;
+ unifi_trace(priv, UDBG5, "normal Data packet, NO QOS \n");
+
+ if (qosDestination) {
+ u8 qc = 0;
+ unifi_trace(priv, UDBG3, "destination is QOS station \n");
+
+ /* Set Ma-Packet.req UP to UP0 */
+ *priority = CSR_QOS_UP0;
+
+ /* prepare the qos control field */
+ qc |= CSR_QOS_UP0;
+ /* no Amsdu is in ap buffer so eosp is left 0 */
+ if (da[0] & 0x1) {
+ /* multicast/broadcast frames, no acknowledgement needed */
+ qc |= 1 << 5;
+ }
+
+ /* update new Mac header Length with 2 = sizeof(qos control) */
+ macHeaderLengthInBytes += 2;
+
+ /* received DATA frame but destiantion is QOS station so update subtype to QOS*/
+ *fc &= cpu_to_le16(~IEEE80211_FC_SUBTYPE_MASK);
+ *fc |= cpu_to_le16(IEEE802_11_FC_TYPE_QOS_DATA);
+
+ /* appendQosControlOffset = macHeaderLengthInBytes - 2, since source sta is not QOS */
+ macHeaderBuf[macHeaderLengthInBytes - 2] = qc;
+ /* txopLimit is 0 */
+ macHeaderBuf[macHeaderLengthInBytes - 1] = 0;
+ if (headroom < macHeaderLengthInBytes) {
+ csrResult = unifi_net_data_malloc(priv, &data_ptrs.d[0], skb->len + macHeaderLengthInBytes);
+
+ if (csrResult != CSR_RESULT_SUCCESS) {
+ unifi_error(priv, " failed to allocate request_data. in update_macheader func\n");
+ return -1;
+ }
+ newSkb = (struct sk_buff *)(data_ptrs.d[0].os_net_buf_ptr);
+ newSkb->len = skb->len + macHeaderLengthInBytes;
+
+ memcpy((void*)data_ptrs.d[0].os_data_ptr + macHeaderLengthInBytes,
+ skb->data, skb->len);
+
+ bulkdata->d[0].os_data_ptr = newSkb->data;
+ bulkdata->d[0].os_net_buf_ptr = (unsigned char*)newSkb;
+ bulkdata->d[0].data_length = newSkb->len;
+
+ bufPtr = (u8*)data_ptrs.d[0].os_data_ptr;
+
+ /* The old skb will not be used again */
+ kfree_skb(skb);
+ } else {
+ /* skb headroom is sufficient to append Macheader */
+ bufPtr = (u8*)skb_push(skb, macHeaderLengthInBytes);
+ bulkdata->d[0].os_data_ptr = skb->data;
+ bulkdata->d[0].os_net_buf_ptr = (unsigned char*)skb;
+ bulkdata->d[0].data_length = skb->len;
+ }
+ } else {
+ unifi_trace(priv, UDBG3, "destination is not a QSTA\n");
+ if (headroom < macHeaderLengthInBytes) {
+ csrResult = unifi_net_data_malloc(priv, &data_ptrs.d[0], skb->len + macHeaderLengthInBytes);
+
+ if (csrResult != CSR_RESULT_SUCCESS) {
+ unifi_error(priv, " failed to allocate request_data. in update_macheader func\n");
+ return -1;
+ }
+ newSkb = (struct sk_buff *)(data_ptrs.d[0].os_net_buf_ptr);
+ newSkb->len = skb->len + macHeaderLengthInBytes;
+
+ memcpy((void*)data_ptrs.d[0].os_data_ptr + macHeaderLengthInBytes,
+ skb->data, skb->len);
+
+ bulkdata->d[0].os_data_ptr = newSkb->data;
+ bulkdata->d[0].os_net_buf_ptr = (unsigned char*)newSkb;
+ bulkdata->d[0].data_length = newSkb->len;
+
+ bufPtr = (u8*)data_ptrs.d[0].os_data_ptr;
+
+ /* The old skb will not be used again */
+ kfree_skb(skb);
+ } else {
+ /* skb headroom is sufficient to append Macheader */
+ bufPtr = (u8*)skb_push(skb, macHeaderLengthInBytes);
+ bulkdata->d[0].os_data_ptr = skb->data;
+ bulkdata->d[0].os_net_buf_ptr = (unsigned char*)skb;
+ bulkdata->d[0].data_length = skb->len;
+ }
+ }
+ }
+ }
+
+ /* prepare the complete skb, by pushing the MAC header to the begining of the skb->data */
+ unifi_trace(priv, UDBG5, "updated Mac Header: %d \n",macHeaderLengthInBytes);
+ memcpy(bufPtr, macHeaderBuf, macHeaderLengthInBytes);
+
+ unifi_trace(priv, UDBG5, "leaving the update_macheader function\n");
+ return 0;
+}
+/*
+ * ---------------------------------------------------------------------------
+ * uf_ap_process_data_pdu
+ *
+ *
+ * Takes care of intra BSS admission control & routing packets within BSS
+ *
+ * Arguments:
+ * priv Pointer to device private context struct
+ * skb Socket buffer containing data packet to transmit
+ * ehdr ethernet header to fetch priority of packet
+ * srcStaInfo source stations record for connection verification
+ * packed_signal
+ * signal_len
+ * signal MA-PACKET.indication signal
+ * bulkdata if newSkb allocated then bulkdata updated to send to unifi
+ * macHeaderLengthInBytes no. of bytes of mac header in received frame
+ *
+ * Returns:
+ * Zero on success(ap processing complete) or -1 if packet also have to be sent to NETDEV.
+ * ---------------------------------------------------------------------------
+ */
+int
+uf_ap_process_data_pdu(unifi_priv_t *priv, struct sk_buff *skb,
+ struct ethhdr *ehdr, CsrWifiRouterCtrlStaInfo_t * srcStaInfo,
+ const CSR_SIGNAL *signal,
+ bulk_data_param_t *bulkdata,
+ u8 macHeaderLengthInBytes)
+{
+ const CSR_MA_PACKET_INDICATION *ind = &(signal->u.MaPacketIndication);
+ u16 interfaceTag = (ind->VirtualInterfaceIdentifier & 0x00ff);
+ struct sk_buff *newSkb = NULL;
+ /* pointer to skb or private skb created using skb_copy() */
+ struct sk_buff *skbPtr = skb;
+ u8 sendToNetdev = FALSE;
+ u8 qosDestination = FALSE;
+ CSR_PRIORITY priority = CSR_CONTENTION;
+ CsrWifiRouterCtrlStaInfo_t *dstStaInfo = NULL;
+ netInterface_priv_t *interfacePriv;
+
+ unifi_trace(priv, UDBG5, "entering uf_ap_process_data_pdu %d\n",macHeaderLengthInBytes);
+ /* InterfaceTag validation from MA_PACKET.indication */
+ if (interfaceTag >= CSR_WIFI_NUM_INTERFACES) {
+ unifi_trace(priv, UDBG1, "Interface Tag is Invalid in uf_ap_process_data_pdu\n");
+ unifi_net_data_free(priv, &bulkdata->d[0]);
+ return 0;
+ }
+ interfacePriv = priv->interfacePriv[interfaceTag];
+
+ if((interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_P2PGO) &&
+ (interfacePriv->intraBssEnabled == FALSE)) {
+ unifi_trace(priv, UDBG2, "uf_ap_process_data_pdu:P2P GO intrabssEnabled?= %d\n", interfacePriv->intraBssEnabled);
+
+ /*In P2P GO case, if intraBSS distribution Disabled then don't do IntraBSS routing */
+ /* If destination in our BSS then drop otherwise give packet to netdev */
+ dstStaInfo = CsrWifiRouterCtrlGetStationRecordFromPeerMacAddress(priv, ehdr->h_dest, interfaceTag);
+ if (dstStaInfo) {
+ unifi_net_data_free(priv, &bulkdata->d[0]);
+ return 0;
+ }
+ /* May be associated P2PCLI trying to send the packets on backbone (Netdev) */
+ return -1;
+ }
+
+ if(!memcmp(ehdr->h_dest, interfacePriv->bssid.a, ETH_ALEN)) {
+ /* This packet will be given to the TCP/IP stack since this packet is for us(AP)
+ * No routing needed */
+ unifi_trace(priv, UDBG4, "destination address is csr_ap\n");
+ return -1;
+ }
+
+ /* fetch the destination record from staion record database */
+ dstStaInfo = CsrWifiRouterCtrlGetStationRecordFromPeerMacAddress(priv, ehdr->h_dest, interfaceTag);
+
+ /* AP mode processing, & if packet is unicast */
+ if(!dstStaInfo) {
+ if (!(ehdr->h_dest[0] & 0x1)) {
+ /* destination not in station record & its a unicast packet, so pass the packet to network stack */
+ unifi_trace(priv, UDBG3, "unicast frame & destination record not exist, send to netdev proto = %x\n", htons(skb->protocol));
+ return -1;
+ } else {
+ /* packet is multicast/broadcast */
+ /* copy the skb to skbPtr, send skb to netdev & skbPtr to multicast/broad cast list */
+ unifi_trace(priv, UDBG5, "skb_copy, in uf_ap_process_data_pdu, protocol = %x\n", htons(skb->protocol));
+ skbPtr = skb_copy(skb, GFP_KERNEL);
+ if(skbPtr == NULL) {
+ /* We don't have memory to don't send the frame in BSS*/
+ unifi_notice(priv, "broacast/multicast frame can't be sent in BSS No memeory: proto = %x\n", htons(skb->protocol));
+ return -1;
+ }
+ sendToNetdev = TRUE;
+ }
+ } else {
+
+ /* validate the Peer & Destination Station record */
+ if (uf_process_station_records_for_sending_data(priv, interfaceTag, srcStaInfo, dstStaInfo)) {
+ unifi_notice(priv, "uf_ap_process_data_pdu: station record validation failed \n");
+ interfacePriv->stats.rx_errors++;
+ unifi_net_data_free(priv, &bulkdata->d[0]);
+ return 0;
+ }
+ }
+
+ /* BroadCast packet received and it's been sent as non QOS packets.
+ * Since WMM spec not mandates broadcast/multicast to be sent as QOS data only,
+ * if all Peers are QSTA
+ */
+ if(sendToNetdev) {
+ /* BroadCast packet and it's been sent as non QOS packets */
+ qosDestination = FALSE;
+ } else if(dstStaInfo && (dstStaInfo->wmmOrQosEnabled == TRUE)) {
+ qosDestination = TRUE;
+ }
+
+ unifi_trace(priv, UDBG3, "uf_ap_process_data_pdu QoS destination = %s\n", (qosDestination)? "TRUE": "FALSE");
+
+ /* packet is allowed to send to unifi, update the Mac header */
+ if (update_macheader(priv, skbPtr, newSkb, &priority, bulkdata, interfaceTag, macHeaderLengthInBytes, qosDestination)) {
+ interfacePriv->stats.rx_errors++;
+ unifi_notice(priv, "(Packet Drop) failed to update the Mac header in uf_ap_process_data_pdu\n");
+ if (sendToNetdev) {
+ /* Free's the skb_copy(skbPtr) data since packet processing failed */
+ bulkdata->d[0].os_data_ptr = skbPtr->data;
+ bulkdata->d[0].os_net_buf_ptr = (unsigned char*)skbPtr;
+ bulkdata->d[0].data_length = skbPtr->len;
+ unifi_net_data_free(priv, &bulkdata->d[0]);
+ }
+ return -1;
+ }
+
+ unifi_trace(priv, UDBG3, "Mac Header updated...calling uf_process_ma_packet_req \n");
+
+ /* Packet is ready to send to unifi ,transmissionControl = 0x0004, confirmation is not needed for data packets */
+ if (uf_process_ma_packet_req(priv, ehdr->h_dest, 0xffffffff, interfaceTag, CSR_NO_CONFIRM_REQUIRED, (CSR_RATE)0,priority, priv->netdev_client->sender_id, bulkdata)) {
+ if (sendToNetdev) {
+ unifi_trace(priv, UDBG1, "In uf_ap_process_data_pdu, (Packet Drop) uf_process_ma_packet_req failed. freeing skb_copy data (original data sent to Netdev)\n");
+ /* Free's the skb_copy(skbPtr) data since packet processing failed */
+ bulkdata->d[0].os_data_ptr = skbPtr->data;
+ bulkdata->d[0].os_net_buf_ptr = (unsigned char*)skbPtr;
+ bulkdata->d[0].data_length = skbPtr->len;
+ unifi_net_data_free(priv, &bulkdata->d[0]);
+ } else {
+ /* This free's the skb data */
+ unifi_trace(priv, UDBG1, "In uf_ap_process_data_pdu, (Packet Drop). Unicast data so freeing original skb \n");
+ unifi_net_data_free(priv, &bulkdata->d[0]);
+ }
+ }
+ unifi_trace(priv, UDBG5, "leaving uf_ap_process_data_pdu\n");
+
+ if (sendToNetdev) {
+ /* The packet is multicast/broadcast, so after AP processing packet has to
+ * be sent to netdev, if peer port state is open
+ */
+ unifi_trace(priv, UDBG4, "Packet will be routed to NetDev\n");
+ return -1;
+ }
+ /* Ap handled the packet & its a unicast packet, no need to send to netdev */
+ return 0;
+}
+
+#endif
+
+CsrResult uf_process_ma_packet_req(unifi_priv_t *priv,
+ u8 *peerMacAddress,
+ CSR_CLIENT_TAG hostTag,
+ u16 interfaceTag,
+ CSR_TRANSMISSION_CONTROL transmissionControl,
+ CSR_RATE TransmitRate,
+ CSR_PRIORITY priority,
+ CSR_PROCESS_ID leSenderProcessId,
+ bulk_data_param_t *bulkdata)
+{
+ CsrResult status = CSR_RESULT_SUCCESS;
+ CSR_SIGNAL signal;
+ int result;
+#ifdef CSR_SUPPORT_SME
+ CsrWifiRouterCtrlStaInfo_t *staRecord = NULL;
+ const u8 *macHdrLocation = bulkdata->d[0].os_data_ptr;
+ CsrWifiPacketType pktType;
+ int frameType = 0;
+ u8 queuePacketDozing = FALSE;
+ u32 priority_q;
+ u16 frmCtrl;
+ struct list_head * list = NULL; /* List to which buffered PDUs are to be enqueued*/
+ u8 setBcTim=FALSE;
+ netInterface_priv_t *interfacePriv;
+ u8 requeueOnSamePos = FALSE;
+ u32 handle = 0xFFFFFFFF;
+ unsigned long lock_flags;
+
+ unifi_trace(priv, UDBG5,
+ "entering uf_process_ma_packet_req, peer: %pMF\n",
+ peerMacAddress);
+
+ if (interfaceTag >= CSR_WIFI_NUM_INTERFACES) {
+ unifi_error(priv, "interfaceTag >= CSR_WIFI_NUM_INTERFACES, interfacetag = %d\n", interfaceTag);
+ return CSR_RESULT_FAILURE;
+ }
+ interfacePriv = priv->interfacePriv[interfaceTag];
+
+
+ /* fetch the station record for corresponding peer mac address */
+ if ((staRecord = CsrWifiRouterCtrlGetStationRecordFromPeerMacAddress(priv, peerMacAddress, interfaceTag))) {
+ handle = staRecord->assignedHandle;
+ }
+
+ /* Frame ma-packet.req, this is saved/transmitted depend on queue state */
+ unifi_frame_ma_packet_req(priv, priority, TransmitRate, hostTag,
+ interfaceTag, transmissionControl, leSenderProcessId,
+ peerMacAddress, &signal);
+
+ /* Since it's common path between STA & AP mode, in case of STA packet
+ * need not to be queued but in AP case we have to queue PDU's in
+ * different scenarios
+ */
+ switch(interfacePriv->interfaceMode)
+ {
+ case CSR_WIFI_ROUTER_CTRL_MODE_AP:
+ case CSR_WIFI_ROUTER_CTRL_MODE_P2PGO:
+ /* For this mode processing done below */
+ break;
+ default:
+ /* In case of STA/IBSS/P2PCLI/AMP, no checks needed send the packet down & return */
+ unifi_trace(priv, UDBG5, "In %s, interface mode is %x \n", __FUNCTION__, interfacePriv->interfaceMode);
+ if (interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_NONE) {
+ unifi_warning(priv, "In %s, interface mode NONE \n", __FUNCTION__);
+ }
+ if ((result = ul_send_signal_unpacked(priv, &signal, bulkdata))) {
+ status = CSR_RESULT_FAILURE;
+ }
+ return status;
+ }
+
+ /* -----Only AP/P2pGO mode handling falls below----- */
+
+ /* convert priority to queue */
+ priority_q = unifi_frame_priority_to_queue((CSR_PRIORITY) priority);
+
+ /* check the powersave status of the peer */
+ if (staRecord && (staRecord->currentPeerState ==
+ CSR_WIFI_ROUTER_CTRL_PEER_CONNECTED_POWER_SAVE)) {
+ /* Peer is dozing & packet have to be delivered, so buffer the packet &
+ * update the TIM
+ */
+ queuePacketDozing = TRUE;
+ }
+
+ /* find the type of frame unicast or mulicast/broadcast */
+ if (*peerMacAddress & 0x1) {
+ /* Multicast/broadCast data are always triggered by vif_availability.ind
+ * at the DTIM
+ */
+ pktType = CSR_WIFI_MULTICAST_PDU;
+ } else {
+ pktType = CSR_WIFI_UNICAST_PDU;
+ }
+
+ /* Fetch the frame control field from mac header & check for frame type */
+ frmCtrl = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(macHdrLocation);
+
+ /* Processing done according to Frame/Packet type */
+ frameType = ((frmCtrl & 0x000c) >> FRAME_CONTROL_TYPE_FIELD_OFFSET);
+ switch(frameType)
+ {
+ case IEEE802_11_FRAMETYPE_MANAGEMENT:
+
+ switch(pktType)
+ {
+ case CSR_WIFI_UNICAST_PDU:
+ unifi_trace(priv, UDBG5, "management unicast PDU in uf_process_ma_packet_req \n");
+ /* push the packet in to the queue with appropriate mgt list */
+ if (!staRecord) {
+ /* push the packet to the unifi if list is empty (if packet lost how to re-enque) */
+ if (list_empty(&interfacePriv->genericMgtFrames)) {
+#ifdef CSR_SUPPORT_SME
+ if(!(IS_DTIM_ACTIVE(interfacePriv->dtimActive,interfacePriv->multicastPduHostTag))) {
+#endif
+
+ unifi_trace(priv, UDBG3, "genericMgtFrames list is empty uf_process_ma_packet_req \n");
+ result = ul_send_signal_unpacked(priv, &signal, bulkdata);
+ /* reque only on ENOSPC */
+ if(result == -ENOSPC) {
+ /* requeue the failed packet to genericMgtFrame with same position */
+ unifi_trace(priv, UDBG1, "(ENOSPC) Sending genericMgtFrames Failed so buffering\n");
+ list = &interfacePriv->genericMgtFrames;
+ requeueOnSamePos = TRUE;
+ }
+#ifdef CSR_SUPPORT_SME
+ }else{
+ list = &interfacePriv->genericMgtFrames;
+ unifi_trace(priv, UDBG3, "genericMgtFrames queue empty and dtim started\n hosttag is 0x%x,\n",signal.u.MaPacketRequest.HostTag);
+ update_eosp_to_head_of_broadcast_list_head(priv,interfaceTag);
+ }
+#endif
+ } else {
+ /* Queue the packet to genericMgtFrame of unifi_priv_t data structure */
+ list = &interfacePriv->genericMgtFrames;
+ unifi_trace(priv, UDBG2, "genericMgtFrames queue not empty\n");
+ }
+ } else {
+ /* check peer power state */
+ if (queuePacketDozing || !list_empty(&staRecord->mgtFrames) || IS_DTIM_ACTIVE(interfacePriv->dtimActive,interfacePriv->multicastPduHostTag)) {
+ /* peer is in dozing mode, so queue packet in mgt frame list of station record */
+ /*if multicast traffic is going on, buffer the unicast packets*/
+ list = &staRecord->mgtFrames;
+
+ unifi_trace(priv, UDBG1, "staRecord->MgtFrames list empty? = %s, handle = %d, queuePacketDozing = %d\n",
+ (list_empty(&staRecord->mgtFrames))? "YES": "NO", staRecord->assignedHandle, queuePacketDozing);
+ if(IS_DTIM_ACTIVE(interfacePriv->dtimActive,interfacePriv->multicastPduHostTag)){
+ update_eosp_to_head_of_broadcast_list_head(priv,interfaceTag);
+ }
+
+ } else {
+ unifi_trace(priv, UDBG5, "staRecord->mgtFrames list is empty uf_process_ma_packet_req \n");
+ result = ul_send_signal_unpacked(priv, &signal, bulkdata);
+ if(result == -ENOSPC) {
+ /* requeue the failed packet to staRecord->mgtFrames with same position */
+ list = &staRecord->mgtFrames;
+ requeueOnSamePos = TRUE;
+ unifi_trace(priv, UDBG1, "(ENOSPC) Sending MgtFrames Failed handle = %d so buffering\n",staRecord->assignedHandle);
+ priv->pausedStaHandle[0]=(u8)(staRecord->assignedHandle);
+ } else if (result) {
+ status = CSR_RESULT_FAILURE;
+ }
+ }
+ }
+ break;
+ case CSR_WIFI_MULTICAST_PDU:
+ unifi_trace(priv, UDBG5, "management multicast/broadcast PDU in uf_process_ma_packet_req 'QUEUE it' \n");
+ /* Queue the packet to genericMulticastOrBroadCastMgtFrames of unifi_priv_t data structure
+ * will be sent when we receive VIF AVAILABILITY from firmware as part of DTIM
+ */
+
+ list = &interfacePriv->genericMulticastOrBroadCastMgtFrames;
+ if((interfacePriv->interfaceMode != CSR_WIFI_ROUTER_CTRL_MODE_IBSS) &&
+ (list_empty(&interfacePriv->genericMulticastOrBroadCastMgtFrames))) {
+ setBcTim=TRUE;
+ }
+ break;
+ default:
+ unifi_error(priv, "condition never meets: packet type unrecognized\n");
+ }
+ break;
+ case IEEE802_11_FRAMETYPE_DATA:
+ switch(pktType)
+ {
+ case CSR_WIFI_UNICAST_PDU:
+ unifi_trace(priv, UDBG5, "data unicast PDU in uf_process_ma_packet_req \n");
+ /* check peer power state, list status & peer port status */
+ if(!staRecord) {
+ unifi_error(priv, "In %s unicast but staRecord = NULL\n", __FUNCTION__);
+ return CSR_RESULT_FAILURE;
+ } else if (queuePacketDozing || isRouterBufferEnabled(priv,priority_q)|| !list_empty(&staRecord->dataPdu[priority_q]) || IS_DTIM_ACTIVE(interfacePriv->dtimActive,interfacePriv->multicastPduHostTag)) {
+ /* peer is in dozing mode, so queue packet in mgt frame list of station record */
+ /* if multicast traffic is going on, buffet the unicast packets */
+ unifi_trace(priv, UDBG2, "Enqueued to staRecord->dataPdu[%d] queuePacketDozing=%d,\
+ Buffering enabled = %d \n", priority_q,queuePacketDozing,isRouterBufferEnabled(priv,priority_q));
+ list = &staRecord->dataPdu[priority_q];
+ } else {
+ unifi_trace(priv, UDBG5, "staRecord->dataPdu[%d] list is empty uf_process_ma_packet_req \n", priority_q);
+ /* Pdu allowed to send to unifi */
+ result = ul_send_signal_unpacked(priv, &signal, bulkdata);
+ if(result == -ENOSPC) {
+ /* requeue the failed packet to staRecord->dataPdu[priority_q] with same position */
+ unifi_trace(priv, UDBG1, "(ENOSPC) Sending Unicast DataPDU to queue %d Failed so buffering\n",priority_q);
+ requeueOnSamePos = TRUE;
+ list = &staRecord->dataPdu[priority_q];
+ priv->pausedStaHandle[priority_q]=(u8)(staRecord->assignedHandle);
+ if(!isRouterBufferEnabled(priv,priority_q)) {
+ unifi_error(priv,"Buffering Not enabled for queue %d \n",priority_q);
+ }
+ } else if (result) {
+ status = CSR_RESULT_FAILURE;
+ }
+ }
+ break;
+ case CSR_WIFI_MULTICAST_PDU:
+ unifi_trace(priv, UDBG5, "data multicast/broadcast PDU in uf_process_ma_packet_req \n");
+ /* Queue the packet to genericMulticastOrBroadCastFrames list of unifi_priv_t data structure
+ * will be sent when we receive VIF AVAILABILITY from firmware as part of DTIM
+ */
+ list = &interfacePriv->genericMulticastOrBroadCastFrames;
+ if(list_empty(&interfacePriv->genericMulticastOrBroadCastFrames)) {
+ setBcTim = TRUE;
+ }
+ break;
+ default:
+ unifi_error(priv, "condition never meets: packet type un recognized\n");
+ }
+ break;
+ default:
+ unifi_error(priv, "unrecognized frame type\n");
+ }
+ if(list) {
+ status = enque_tx_data_pdu(priv, bulkdata,list, &signal,requeueOnSamePos);
+ /* Record no. of packet queued for each peer */
+ if (staRecord && (pktType == CSR_WIFI_UNICAST_PDU) && (!status)) {
+ spin_lock_irqsave(&priv->staRecord_lock,lock_flags);
+ staRecord->noOfPktQueued++;
+ spin_unlock_irqrestore(&priv->staRecord_lock,lock_flags);
+ }
+ else if ((pktType == CSR_WIFI_MULTICAST_PDU) && (!status))
+ {
+ /* If broadcast Tim is set && queuing is successfull, then only update TIM */
+ spin_lock_irqsave(&priv->staRecord_lock,lock_flags);
+ interfacePriv->noOfbroadcastPktQueued++;
+ spin_unlock_irqrestore(&priv->staRecord_lock,lock_flags);
+ }
+ }
+ /* If broadcast Tim is set && queuing is successfull, then only update TIM */
+ if(setBcTim && !status) {
+ unifi_trace(priv, UDBG3, "tim set due to broadcast pkt\n");
+ if (!interfacePriv->bcTimSetReqPendingFlag)
+ {
+ update_tim(priv,0,CSR_WIFI_TIM_SET,interfaceTag, handle);
+ }
+ else
+ {
+ /* Cache the TimSet value so that it will processed immidiatly after
+ * completing the current setTim Request
+ */
+ interfacePriv->bcTimSetReqQueued = CSR_WIFI_TIM_SET;
+ unifi_trace(priv, UDBG2, "uf_process_ma_packet_req : One more UpdateDTim Request(:%d) Queued \n",
+ interfacePriv->bcTimSetReqQueued);
+ }
+ } else if(staRecord && staRecord->currentPeerState ==
+ CSR_WIFI_ROUTER_CTRL_PEER_CONNECTED_POWER_SAVE) {
+ if(staRecord->timSet == CSR_WIFI_TIM_RESET || staRecord->timSet == CSR_WIFI_TIM_RESETTING) {
+ if(!staRecord->wmmOrQosEnabled) {
+ if(!list_empty(&staRecord->mgtFrames) ||
+ !list_empty(&staRecord->dataPdu[3]) ||
+ !list_empty(&staRecord->dataPdu[UNIFI_TRAFFIC_Q_CONTENTION])) {
+ unifi_trace(priv, UDBG3, "tim set due to unicast pkt & peer in powersave\n");
+ if (!staRecord->timRequestPendingFlag){
+ update_tim(priv,staRecord->aid,1,interfaceTag, handle);
+ }
+ else
+ {
+ /* Cache the TimSet value so that it will processed immidiatly after
+ * completing the current setTim Request
+ */
+ staRecord->updateTimReqQueued = 1;
+ unifi_trace(priv, UDBG6, "update_tim : One more UpdateTim Request (Tim value:%d) Queued for AID %x\n", staRecord->updateTimReqQueued,
+ staRecord->aid);
+ }
+ }
+ } else {
+ /* Check for non delivery enable(i.e trigger enable), all delivery enable & legacy AC for TIM update in firmware */
+ u8 allDeliveryEnabled = 0, dataAvailable = 0;
+ /* Check if all AC's are Delivery Enabled */
+ is_all_ac_deliver_enabled_and_moredata(staRecord, &allDeliveryEnabled, &dataAvailable);
+ if (uf_is_more_data_for_non_delivery_ac(staRecord) || (allDeliveryEnabled && dataAvailable)
+ || (!list_empty(&staRecord->mgtFrames))) {
+ if (!staRecord->timRequestPendingFlag) {
+ update_tim(priv,staRecord->aid,1,interfaceTag, handle);
+ }
+ else
+ {
+ /* Cache the TimSet value so that it will processed immidiatly after
+ * completing the current setTim Request
+ */
+ staRecord->updateTimReqQueued = 1;
+ unifi_trace(priv, UDBG6, "update_tim : One more UpdateTim Request (Tim value:%d) Queued for AID %x\n", staRecord->updateTimReqQueued,
+ staRecord->aid);
+ }
+ }
+ }
+ }
+ }
+
+ if((list) && (pktType == CSR_WIFI_UNICAST_PDU && !queuePacketDozing) && !(isRouterBufferEnabled(priv,priority_q)) && !(IS_DTIM_ACTIVE(interfacePriv->dtimActive,interfacePriv->multicastPduHostTag))) {
+ unifi_trace(priv, UDBG2, "buffering cleared for queue = %d So resending buffered frames\n",priority_q);
+ uf_send_buffered_frames(priv, priority_q);
+ }
+ unifi_trace(priv, UDBG5, "leaving uf_process_ma_packet_req \n");
+ return status;
+#else
+#ifdef CSR_NATIVE_LINUX
+ if (interfaceTag >= CSR_WIFI_NUM_INTERFACES) {
+ unifi_error(priv, "interfaceTag >= CSR_WIFI_NUM_INTERFACES, interfacetag = %d\n", interfaceTag);
+ return CSR_RESULT_FAILURE;
+ }
+ /* Frame ma-packet.req, this is saved/transmitted depend on queue state */
+ unifi_frame_ma_packet_req(priv, priority, TransmitRate, hostTag, interfaceTag,
+ transmissionControl, leSenderProcessId,
+ peerMacAddress, &signal);
+ result = ul_send_signal_unpacked(priv, &signal, bulkdata);
+ if (result) {
+ return CSR_RESULT_FAILURE;
+ }
+#endif
+ return status;
+#endif
+}
+
+#ifdef CSR_SUPPORT_SME
+s8 uf_get_protection_bit_from_interfacemode(unifi_priv_t *priv, u16 interfaceTag, const u8 *daddr)
+{
+ s8 protection = 0;
+ netInterface_priv_t *interfacePriv = priv->interfacePriv[interfaceTag];
+
+ switch(interfacePriv->interfaceMode)
+ {
+ case CSR_WIFI_ROUTER_CTRL_MODE_STA:
+ case CSR_WIFI_ROUTER_CTRL_MODE_P2PCLI:
+ case CSR_WIFI_ROUTER_CTRL_MODE_AMP:
+ case CSR_WIFI_ROUTER_CTRL_MODE_IBSS:
+ protection = interfacePriv->protect;
+ break;
+ case CSR_WIFI_ROUTER_CTRL_MODE_AP:
+ case CSR_WIFI_ROUTER_CTRL_MODE_P2PGO:
+ {
+ CsrWifiRouterCtrlStaInfo_t *dstStaInfo = NULL;
+ if (daddr[0] & 0x1) {
+ unifi_trace(priv, UDBG3, "broadcast/multicast packet in send_ma_pkt_request\n");
+ /* In this mode, the protect member of priv structure has an information of how
+ * AP/P2PGO has started, & the member updated in set mode request for AP/P2PGO
+ */
+ protection = interfacePriv->protect;
+ } else {
+ /* fetch the destination record from staion record database */
+ dstStaInfo = CsrWifiRouterCtrlGetStationRecordFromPeerMacAddress(priv, daddr, interfaceTag);
+ if (!dstStaInfo) {
+ unifi_trace(priv, UDBG3, "peer not found in station record in send_ma_pkt_request\n");
+ return -1;
+ }
+ protection = dstStaInfo->protection;
+ }
+ }
+ break;
+ default:
+ unifi_trace(priv, UDBG2, "mode unknown in send_ma_pkt_request\n");
+ }
+ return protection;
+}
+#endif
+#ifdef CSR_SUPPORT_SME
+u8 send_multicast_frames(unifi_priv_t *priv, u16 interfaceTag)
+{
+ int r;
+ tx_buffered_packets_t * buffered_pkt = NULL;
+ u8 moreData = FALSE;
+ u8 pduSent =0;
+ unsigned long lock_flags;
+ netInterface_priv_t *interfacePriv = priv->interfacePriv[interfaceTag];
+ u32 hostTag = 0xffffffff;
+
+ func_enter();
+ if(!isRouterBufferEnabled(priv,UNIFI_TRAFFIC_Q_VO)) {
+ while((interfacePriv->dtimActive)&& (buffered_pkt=dequeue_tx_data_pdu(priv,&interfacePriv->genericMulticastOrBroadCastMgtFrames))) {
+ buffered_pkt->transmissionControl |= (TRANSMISSION_CONTROL_TRIGGER_MASK);
+ moreData = (buffered_pkt->transmissionControl & TRANSMISSION_CONTROL_EOSP_MASK)?FALSE:TRUE;
+
+
+ unifi_trace(priv,UDBG2,"DTIM Occurred for interface:sending Mgt packet %d\n",interfaceTag);
+
+ if((r=frame_and_send_queued_pdu(priv,buffered_pkt,NULL,moreData,FALSE)) == -ENOSPC) {
+ unifi_trace(priv,UDBG1,"frame_and_send_queued_pdu failed with ENOSPC for host tag = %x\n", buffered_pkt->hostTag);
+ /* Enqueue at the head of the queue */
+ spin_lock_irqsave(&priv->tx_q_lock,lock_flags);
+ list_add(&buffered_pkt->q, &interfacePriv->genericMulticastOrBroadCastMgtFrames);
+ spin_unlock_irqrestore(&priv->tx_q_lock,lock_flags);
+ break;
+ } else {
+ unifi_trace(priv,UDBG1,"send_multicast_frames: Send genericMulticastOrBroadCastMgtFrames (%x, %x)\n",
+ buffered_pkt->hostTag,
+ r);
+ if(r) {
+ unifi_net_data_free(priv, &buffered_pkt->bulkdata);
+ }
+ if(!moreData) {
+
+ interfacePriv->dtimActive = FALSE;
+ if(!r) {
+ hostTag = buffered_pkt->hostTag;
+ pduSent++;
+ } else {
+ send_vif_availibility_rsp(priv,uf_get_vif_identifier(interfacePriv->interfaceMode,interfaceTag),CSR_RC_UNSPECIFIED_FAILURE);
+ }
+ }
+ /* Buffered frame sent successfully */
+ spin_lock_irqsave(&priv->staRecord_lock,lock_flags);
+ interfacePriv->noOfbroadcastPktQueued--;
+ spin_unlock_irqrestore(&priv->staRecord_lock,lock_flags);
+ kfree(buffered_pkt);
+ }
+
+ }
+ }
+ if(!isRouterBufferEnabled(priv,UNIFI_TRAFFIC_Q_CONTENTION)) {
+ while((interfacePriv->dtimActive)&& (buffered_pkt=dequeue_tx_data_pdu(priv,&interfacePriv->genericMulticastOrBroadCastFrames))) {
+ buffered_pkt->transmissionControl |= TRANSMISSION_CONTROL_TRIGGER_MASK;
+ moreData = (buffered_pkt->transmissionControl & TRANSMISSION_CONTROL_EOSP_MASK)?FALSE:TRUE;
+
+
+ if((r=frame_and_send_queued_pdu(priv,buffered_pkt,NULL,moreData,FALSE)) == -ENOSPC) {
+ /* Clear the trigger bit transmission control*/
+ buffered_pkt->transmissionControl &= ~(TRANSMISSION_CONTROL_TRIGGER_MASK);
+ /* Enqueue at the head of the queue */
+ spin_lock_irqsave(&priv->tx_q_lock,lock_flags);
+ list_add(&buffered_pkt->q, &interfacePriv->genericMulticastOrBroadCastFrames);
+ spin_unlock_irqrestore(&priv->tx_q_lock,lock_flags);
+ break;
+ } else {
+ if(r) {
+ unifi_trace(priv,UDBG1,"send_multicast_frames: Send genericMulticastOrBroadCastFrame failed (%x, %x)\n",
+ buffered_pkt->hostTag,
+ r);
+ unifi_net_data_free(priv, &buffered_pkt->bulkdata);
+ }
+ if(!moreData) {
+ interfacePriv->dtimActive = FALSE;
+ if(!r) {
+ pduSent ++;
+ hostTag = buffered_pkt->hostTag;
+ } else {
+ send_vif_availibility_rsp(priv,uf_get_vif_identifier(interfacePriv->interfaceMode,interfaceTag),CSR_RC_UNSPECIFIED_FAILURE);
+ }
+ }
+ /* Buffered frame sent successfully */
+ spin_lock_irqsave(&priv->staRecord_lock,lock_flags);
+ interfacePriv->noOfbroadcastPktQueued--;
+ spin_unlock_irqrestore(&priv->staRecord_lock,lock_flags);
+ kfree(buffered_pkt);
+ }
+ }
+ }
+ if((interfacePriv->dtimActive == FALSE)) {
+ /* Record the host Tag*/
+ unifi_trace(priv,UDBG2,"send_multicast_frames: Recorded hostTag of EOSP packet: = 0x%x\n",hostTag);
+ interfacePriv->multicastPduHostTag = hostTag;
+ }
+ return pduSent;
+}
+#endif
+void uf_process_ma_vif_availibility_ind(unifi_priv_t *priv,u8 *sigdata,
+ u32 siglen)
+{
+#ifdef CSR_SUPPORT_SME
+ CSR_SIGNAL signal;
+ CSR_MA_VIF_AVAILABILITY_INDICATION *ind;
+ int r;
+ u16 interfaceTag;
+ u8 pduSent =0;
+ CSR_RESULT_CODE resultCode = CSR_RC_SUCCESS;
+ netInterface_priv_t *interfacePriv;
+
+ func_enter();
+ unifi_trace(priv, UDBG3,
+ "uf_process_ma_vif_availibility_ind: Process signal 0x%.4X\n",
+ *((u16*)sigdata));
+
+ r = read_unpack_signal(sigdata, &signal);
+ if (r) {
+ unifi_error(priv,
+ "uf_process_ma_vif_availibility_ind: Received unknown signal 0x%.4X.\n",
+ CSR_GET_UINT16_FROM_LITTLE_ENDIAN(sigdata));
+ func_exit();
+ return;
+ }
+ ind = &signal.u.MaVifAvailabilityIndication;
+ interfaceTag=ind->VirtualInterfaceIdentifier & 0xff;
+
+ if (interfaceTag >= CSR_WIFI_NUM_INTERFACES) {
+ unifi_error(priv, "in vif_availability_ind interfaceTag is wrong\n");
+ return;
+ }
+
+ interfacePriv = priv->interfacePriv[interfaceTag];
+
+ if(ind->Multicast) {
+ if(list_empty(&interfacePriv->genericMulticastOrBroadCastFrames) &&
+ list_empty(&interfacePriv->genericMulticastOrBroadCastMgtFrames)) {
+ /* This condition can occur because of a potential race where the
+ TIM is not yet reset as host is waiting for confirm but it is sent
+ by firmware and DTIM occurs*/
+ unifi_notice(priv,"ma_vif_availibility_ind recevied for multicast but queues are empty%d\n",interfaceTag);
+ send_vif_availibility_rsp(priv,ind->VirtualInterfaceIdentifier,CSR_RC_NO_BUFFERED_BROADCAST_MULTICAST_FRAMES);
+ interfacePriv->dtimActive = FALSE;
+ if(interfacePriv->multicastPduHostTag == 0xffffffff) {
+ unifi_notice(priv,"ma_vif_availibility_ind recevied for multicast but queues are empty%d\n",interfaceTag);
+ /* This may be an extra request in very rare race conditions but it is fine as it would atleast remove the potential lock up */
+ if (!interfacePriv->bcTimSetReqPendingFlag)
+ {
+ update_tim(priv,0,CSR_WIFI_TIM_RESET,interfaceTag, 0xFFFFFFFF);
+ }
+ else
+ {
+ /* Cache the TimSet value so that it will processed immidiatly after
+ * completing the current setTim Request
+ */
+ interfacePriv->bcTimSetReqQueued = CSR_WIFI_TIM_RESET;
+ unifi_trace(priv, UDBG2, "uf_process_ma_vif_availibility_ind : One more UpdateDTim Request(%d) Queued \n",
+ interfacePriv->bcTimSetReqQueued);
+ }
+ }
+ return;
+ }
+ if(interfacePriv->dtimActive) {
+ unifi_trace(priv,UDBG2,"DTIM Occurred for already active DTIM interface %d\n",interfaceTag);
+ return;
+ } else {
+ unifi_trace(priv,UDBG2,"DTIM Occurred for interface %d\n",interfaceTag);
+ if(list_empty(&interfacePriv->genericMulticastOrBroadCastFrames)) {
+ set_eosp_transmit_ctrl(priv,&interfacePriv->genericMulticastOrBroadCastMgtFrames);
+ } else {
+ set_eosp_transmit_ctrl(priv,&interfacePriv->genericMulticastOrBroadCastFrames);
+ }
+ }
+ interfacePriv->dtimActive = TRUE;
+ pduSent = send_multicast_frames(priv,interfaceTag);
+ }
+ else {
+ unifi_error(priv,"Interface switching is not supported %d\n",interfaceTag);
+ resultCode = CSR_RC_NOT_SUPPORTED;
+ send_vif_availibility_rsp(priv,ind->VirtualInterfaceIdentifier,CSR_RC_NOT_SUPPORTED);
+ }
+#endif
+}
+#ifdef CSR_SUPPORT_SME
+
+#define GET_ACTIVE_INTERFACE_TAG(priv) 0
+
+static u8 uf_is_more_data_for_delivery_ac(unifi_priv_t *priv, CsrWifiRouterCtrlStaInfo_t *staRecord)
+{
+ s8 i;
+
+ for(i=UNIFI_TRAFFIC_Q_VO; i >= UNIFI_TRAFFIC_Q_BK; i--)
+ {
+ if(((staRecord->powersaveMode[i]==CSR_WIFI_AC_DELIVERY_ONLY_ENABLE)
+ ||(staRecord->powersaveMode[i]==CSR_WIFI_AC_TRIGGER_AND_DELIVERY_ENABLED))
+ &&(!list_empty(&staRecord->dataPdu[i]))) {
+ unifi_trace(priv,UDBG2,"uf_is_more_data_for_delivery_ac: Data Available AC = %d\n", i);
+ return TRUE;
+ }
+ }
+
+ unifi_trace(priv,UDBG2,"uf_is_more_data_for_delivery_ac: Data NOT Available \n");
+ return FALSE;
+}
+
+static u8 uf_is_more_data_for_usp_delivery(unifi_priv_t *priv, CsrWifiRouterCtrlStaInfo_t *staRecord, unifi_TrafficQueue queue)
+{
+ s8 i;
+
+ for(i = queue; i >= UNIFI_TRAFFIC_Q_BK; i--)
+ {
+ if(((staRecord->powersaveMode[i]==CSR_WIFI_AC_DELIVERY_ONLY_ENABLE)
+ ||(staRecord->powersaveMode[i]==CSR_WIFI_AC_TRIGGER_AND_DELIVERY_ENABLED))
+ &&(!list_empty(&staRecord->dataPdu[i]))) {
+ unifi_trace(priv,UDBG2,"uf_is_more_data_for_usp_delivery: Data Available AC = %d\n", i);
+ return TRUE;
+ }
+ }
+
+ unifi_trace(priv,UDBG2,"uf_is_more_data_for_usp_delivery: Data NOT Available \n");
+ return FALSE;
+}
+
+/*
+ * ---------------------------------------------------------------------------
+ * uf_send_buffered_data_from_delivery_ac
+ *
+ * This function takes care of
+ * -> Parsing the delivery enabled queue & sending frame down to HIP
+ * -> Setting EOSP=1 when USP to be terminated
+ * -> Depending on MAX SP length services the USP
+ *
+ * NOTE:This function always called from uf_handle_uspframes_delivery(), Dont
+ * call this function from any other location in code
+ *
+ * Arguments:
+ * priv Pointer to device private context struct
+ * vif interface specific HIP vif instance
+ * staInfo peer for which UAPSD to be scheduled
+ * queue AC from which Data to be sent in USP
+ * txList access category for processing list
+ * ---------------------------------------------------------------------------
+ */
+void uf_send_buffered_data_from_delivery_ac(unifi_priv_t *priv,
+ CsrWifiRouterCtrlStaInfo_t * staInfo,
+ u8 queue,
+ struct list_head *txList)
+{
+
+ u16 interfaceTag = GET_ACTIVE_INTERFACE_TAG(priv);
+ tx_buffered_packets_t * buffered_pkt = NULL;
+ unsigned long lock_flags;
+ u8 eosp=FALSE;
+ s8 r =0;
+ u8 moreData = FALSE;
+ netInterface_priv_t *interfacePriv = priv->interfacePriv[interfaceTag];
+
+ unifi_trace(priv, UDBG2, "++uf_send_buffered_data_from_delivery_ac, active=%x\n", staInfo->uapsdActive);
+
+ if (queue > UNIFI_TRAFFIC_Q_VO)
+ {
+ return;
+ }
+ while((buffered_pkt=dequeue_tx_data_pdu(priv, txList))) {
+ if((IS_DTIM_ACTIVE(interfacePriv->dtimActive,interfacePriv->multicastPduHostTag))) {
+ unifi_trace(priv, UDBG2, "uf_send_buffered_data_from_delivery_ac: DTIM Active, suspend UAPSD, staId: 0x%x\n",
+ staInfo->aid);
+
+ /* Once resume called, the U-APSD delivery operation will resume */
+ spin_lock_irqsave(&priv->staRecord_lock,lock_flags);
+ staInfo->uspSuspend = TRUE;
+ spin_unlock_irqrestore(&priv->staRecord_lock,lock_flags);
+ /* re-queueing the packet as DTIM started */
+ spin_lock_irqsave(&priv->tx_q_lock,lock_flags);
+ list_add(&buffered_pkt->q,txList);
+ spin_unlock_irqrestore(&priv->tx_q_lock,lock_flags);
+ break;
+ }
+
+ buffered_pkt->transmissionControl &=
+ ~(TRANSMISSION_CONTROL_TRIGGER_MASK | TRANSMISSION_CONTROL_EOSP_MASK);
+
+
+ if((staInfo->wmmOrQosEnabled == TRUE)&&(staInfo->uapsdActive == TRUE)) {
+
+ buffered_pkt->transmissionControl = TRANSMISSION_CONTROL_TRIGGER_MASK;
+
+ /* Check All delivery enables Ac for more data, because caller of this
+ * function not aware about last packet
+ * (First check in moreData fetching helps in draining out Mgt frames Q)
+ */
+ moreData = (!list_empty(txList) || uf_is_more_data_for_usp_delivery(priv, staInfo, queue));
+
+ if(staInfo->noOfSpFramesSent == (staInfo->maxSpLength - 1)) {
+ moreData = FALSE;
+ }
+
+ if(moreData == FALSE) {
+ eosp = TRUE;
+ buffered_pkt->transmissionControl =
+ (TRANSMISSION_CONTROL_TRIGGER_MASK | TRANSMISSION_CONTROL_EOSP_MASK);
+ }
+ } else {
+ /* Non QoS and non U-APSD */
+ unifi_warning(priv, "uf_send_buffered_data_from_delivery_ac: non U-APSD !!! \n");
+ }
+
+ unifi_trace(priv,UDBG2,"uf_send_buffered_data_from_delivery_ac : MoreData:%d, EOSP:%d\n",moreData,eosp);
+
+ if((r=frame_and_send_queued_pdu(priv,buffered_pkt,staInfo,moreData,eosp)) == -ENOSPC) {
+
+ unifi_trace(priv, UDBG2, "uf_send_buffered_data_from_delivery_ac: UASPD suspended, ENOSPC in hipQ=%x\n", queue);
+
+ /* Once resume called, the U-APSD delivery operation will resume */
+ spin_lock_irqsave(&priv->staRecord_lock,lock_flags);
+ staInfo->uspSuspend = TRUE;
+ spin_unlock_irqrestore(&priv->staRecord_lock,lock_flags);
+
+ spin_lock_irqsave(&priv->tx_q_lock,lock_flags);
+ list_add(&buffered_pkt->q,txList);
+ spin_unlock_irqrestore(&priv->tx_q_lock,lock_flags);
+ priv->pausedStaHandle[queue]=(u8)(staInfo->assignedHandle);
+ break;
+ } else {
+ if(r){
+ /* the PDU failed where we can't do any thing so free the storage */
+ unifi_net_data_free(priv, &buffered_pkt->bulkdata);
+ }
+ kfree(buffered_pkt);
+ spin_lock_irqsave(&priv->staRecord_lock,lock_flags);
+ staInfo->noOfSpFramesSent++;
+ if((!moreData) || (staInfo->noOfSpFramesSent == staInfo->maxSpLength)) {
+ unifi_trace(priv, UDBG2, "uf_send_buffered_data_from_delivery_ac: Terminating USP\n");
+ staInfo->uapsdActive = FALSE;
+ staInfo->uspSuspend = FALSE;
+ staInfo->noOfSpFramesSent = 0;
+ spin_unlock_irqrestore(&priv->staRecord_lock,lock_flags);
+ break;
+ }
+ spin_unlock_irqrestore(&priv->staRecord_lock,lock_flags);
+ }
+ }
+ unifi_trace(priv, UDBG2, "--uf_send_buffered_data_from_delivery_ac, active=%x\n", staInfo->uapsdActive);
+}
+
+void uf_send_buffered_data_from_ac(unifi_priv_t *priv,
+ CsrWifiRouterCtrlStaInfo_t * staInfo,
+ u8 queue,
+ struct list_head *txList)
+{
+ tx_buffered_packets_t * buffered_pkt = NULL;
+ unsigned long lock_flags;
+ u8 eosp=FALSE;
+ u8 moreData = FALSE;
+ s8 r =0;
+
+ func_enter();
+
+ unifi_trace(priv,UDBG2,"uf_send_buffered_data_from_ac :\n");
+
+ while(!isRouterBufferEnabled(priv,queue) &&
+ ((buffered_pkt=dequeue_tx_data_pdu(priv, txList))!=NULL)){
+
+ buffered_pkt->transmissionControl &=
+ ~(TRANSMISSION_CONTROL_TRIGGER_MASK|TRANSMISSION_CONTROL_EOSP_MASK);
+
+ unifi_trace(priv,UDBG3,"uf_send_buffered_data_from_ac : MoreData:%d, EOSP:%d\n",moreData,eosp);
+
+ if((r=frame_and_send_queued_pdu(priv,buffered_pkt,staInfo,moreData,eosp)) == -ENOSPC) {
+ /* Enqueue at the head of the queue */
+ spin_lock_irqsave(&priv->tx_q_lock,lock_flags);
+ list_add(&buffered_pkt->q,txList);
+ spin_unlock_irqrestore(&priv->tx_q_lock,lock_flags);
+ if(staInfo != NULL){
+ priv->pausedStaHandle[queue]=(u8)(staInfo->assignedHandle);
+ }
+ unifi_trace(priv,UDBG3," uf_send_buffered_data_from_ac: PDU sending failed .. no space for queue %d \n",queue);
+ } else {
+ if(r){
+ /* the PDU failed where we can't do any thing so free the storage */
+ unifi_net_data_free(priv, &buffered_pkt->bulkdata);
+ }
+ kfree(buffered_pkt);
+ }
+ }
+
+ func_exit();
+
+}
+
+void uf_send_buffered_frames(unifi_priv_t *priv,unifi_TrafficQueue q)
+{
+ u16 interfaceTag = GET_ACTIVE_INTERFACE_TAG(priv);
+ u32 startIndex=0,endIndex=0;
+ CsrWifiRouterCtrlStaInfo_t * staInfo = NULL;
+ u8 queue;
+ u8 moreData = FALSE;
+
+ netInterface_priv_t *interfacePriv = priv->interfacePriv[interfaceTag];
+
+ if(!((interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_AP) ||
+ (interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_P2PGO)))
+ return;
+ func_enter();
+
+ queue = (q<=3)?q:0;
+
+ if(interfacePriv->dtimActive) {
+ /* this function updates dtimActive*/
+ send_multicast_frames(priv,interfaceTag);
+ if(!interfacePriv->dtimActive) {
+ moreData = (!list_empty(&interfacePriv->genericMulticastOrBroadCastMgtFrames) ||
+ !list_empty(&interfacePriv->genericMulticastOrBroadCastFrames));
+ if(!moreData) {
+ if (!interfacePriv->bcTimSetReqPendingFlag)
+ {
+ update_tim(priv,0,CSR_WIFI_TIM_RESET,interfaceTag, 0XFFFFFFFF);
+ }
+ else
+ {
+ /* Cache the TimSet value so that it will processed immidiatly after
+ * completing the current setTim Request
+ */
+ interfacePriv->bcTimSetReqQueued = CSR_WIFI_TIM_RESET;
+ unifi_trace(priv, UDBG2, "uf_send_buffered_frames : One more UpdateDTim Request(%d) Queued \n",
+ interfacePriv->bcTimSetReqQueued);
+ }
+ }
+ } else {
+ moreData = (!list_empty(&interfacePriv->genericMulticastOrBroadCastMgtFrames) ||
+ !list_empty(&interfacePriv->genericMulticastOrBroadCastFrames));
+ if(!moreData) {
+ /* This should never happen but if it happens, we need a way out */
+ unifi_error(priv,"ERROR: No More Data but DTIM is active sending Response\n");
+ send_vif_availibility_rsp(priv,uf_get_vif_identifier(interfacePriv->interfaceMode,interfaceTag),CSR_RC_NO_BUFFERED_BROADCAST_MULTICAST_FRAMES);
+ interfacePriv->dtimActive = FALSE;
+ }
+ }
+ func_exit();
+ return;
+ }
+ if(priv->pausedStaHandle[queue] > 7) {
+ priv->pausedStaHandle[queue] = 0;
+ }
+
+ if(queue == UNIFI_TRAFFIC_Q_VO) {
+
+
+ unifi_trace(priv,UDBG2,"uf_send_buffered_frames : trying mgt from queue=%d\n",queue);
+ for(startIndex= 0; startIndex < UNIFI_MAX_CONNECTIONS;startIndex++) {
+ staInfo = CsrWifiRouterCtrlGetStationRecordFromHandle(priv,startIndex,interfaceTag);
+ if(!staInfo ) {
+ continue;
+ } else if((staInfo->currentPeerState == CSR_WIFI_ROUTER_CTRL_PEER_CONNECTED_POWER_SAVE)
+ &&(staInfo->uapsdActive == FALSE) ) {
+ continue;
+ }
+
+ if((staInfo != NULL)&&(staInfo->currentPeerState == CSR_WIFI_ROUTER_CTRL_PEER_CONNECTED_ACTIVE)
+ &&(staInfo->uapsdActive == FALSE)){
+ /*Non-UAPSD case push the management frames out*/
+ if(!list_empty(&staInfo->mgtFrames)){
+ uf_send_buffered_data_from_ac(priv,staInfo, UNIFI_TRAFFIC_Q_VO, &staInfo->mgtFrames);
+ }
+ }
+
+ if(isRouterBufferEnabled(priv,queue)) {
+ unifi_notice(priv,"uf_send_buffered_frames : No space Left for queue = %d\n",queue);
+ break;
+ }
+ }
+ /*push generic management frames out*/
+ if(!list_empty(&interfacePriv->genericMgtFrames)) {
+ unifi_trace(priv,UDBG2,"uf_send_buffered_frames : trying generic mgt from queue=%d\n",queue);
+ uf_send_buffered_data_from_ac(priv,staInfo, UNIFI_TRAFFIC_Q_VO, &interfacePriv->genericMgtFrames);
+ }
+ }
+
+
+ unifi_trace(priv,UDBG2,"uf_send_buffered_frames : Resume called for Queue=%d\n",queue);
+ unifi_trace(priv,UDBG2,"uf_send_buffered_frames : start=%d end=%d\n",startIndex,endIndex);
+
+ startIndex = priv->pausedStaHandle[queue];
+ endIndex = (startIndex + UNIFI_MAX_CONNECTIONS -1) % UNIFI_MAX_CONNECTIONS;
+
+ while(startIndex != endIndex) {
+ staInfo = CsrWifiRouterCtrlGetStationRecordFromHandle(priv,startIndex,interfaceTag);
+ if(!staInfo) {
+ startIndex ++;
+ if(startIndex >= UNIFI_MAX_CONNECTIONS) {
+ startIndex = 0;
+ }
+ continue;
+ } else if((staInfo->currentPeerState == CSR_WIFI_ROUTER_CTRL_PEER_CONNECTED_POWER_SAVE)
+ &&(staInfo->uapsdActive == FALSE)) {
+ startIndex ++;
+ if(startIndex >= UNIFI_MAX_CONNECTIONS) {
+ startIndex = 0;
+ }
+ continue;
+ }
+ /* Peer is active or U-APSD is active so send PDUs to the peer */
+ unifi_trace(priv,UDBG2,"uf_send_buffered_frames : trying data from queue=%d\n",queue);
+
+
+ if((staInfo != NULL)&&(staInfo->currentPeerState == CSR_WIFI_ROUTER_CTRL_PEER_CONNECTED_ACTIVE)
+ &&(staInfo->uapsdActive == FALSE)) {
+ if(!list_empty(&staInfo->dataPdu[queue])) {
+
+ /*Non-UAPSD case push the AC frames out*/
+ uf_send_buffered_data_from_ac(priv, staInfo, queue, (&staInfo->dataPdu[queue]));
+ }
+ }
+ startIndex ++;
+ if(startIndex >= UNIFI_MAX_CONNECTIONS) {
+ startIndex = 0;
+ }
+ }
+ if(isRouterBufferEnabled(priv,queue)) {
+ priv->pausedStaHandle[queue] = endIndex;
+ } else {
+ priv->pausedStaHandle[queue] = 0;
+ }
+
+ /* U-APSD might have stopped because of ENOSPC in lib_hip (pause activity).
+ * So restart it if U-APSD was active with any of the station
+ */
+ unifi_trace(priv, UDBG4, "csrWifiHipSendBufferedFrames: UAPSD Resume Q=%x\n", queue);
+ resume_suspended_uapsd(priv, interfaceTag);
+ func_exit();
+}
+
+
+u8 uf_is_more_data_for_non_delivery_ac(CsrWifiRouterCtrlStaInfo_t *staRecord)
+{
+ u8 i;
+
+ for(i=0;i<=3;i++)
+ {
+ if(((staRecord->powersaveMode[i]==CSR_WIFI_AC_TRIGGER_ONLY_ENABLED)
+ ||(staRecord->powersaveMode[i]==CSR_WIFI_AC_LEGACY_POWER_SAVE))
+ &&(!list_empty(&staRecord->dataPdu[i]))){
+
+ return TRUE;
+ }
+ }
+
+ if(((staRecord->powersaveMode[UNIFI_TRAFFIC_Q_VO]==CSR_WIFI_AC_TRIGGER_ONLY_ENABLED)
+ ||(staRecord->powersaveMode[UNIFI_TRAFFIC_Q_VO]==CSR_WIFI_AC_LEGACY_POWER_SAVE))
+ &&(!list_empty(&staRecord->mgtFrames))){
+
+ return TRUE;
+ }
+
+
+
+ return FALSE;
+}
+
+
+int uf_process_station_records_for_sending_data(unifi_priv_t *priv,u16 interfaceTag,
+ CsrWifiRouterCtrlStaInfo_t *srcStaInfo,
+ CsrWifiRouterCtrlStaInfo_t *dstStaInfo)
+{
+ netInterface_priv_t *interfacePriv = priv->interfacePriv[interfaceTag];
+
+ unifi_trace(priv, UDBG5, "entering uf_process_station_records_for_sending_data\n");
+
+ if (srcStaInfo->currentPeerState == CSR_WIFI_ROUTER_CTRL_PEER_DISCONNECTED) {
+ unifi_error(priv, "Peer State not connected AID = %x, handle = %x, control port state = %x\n",
+ srcStaInfo->aid, srcStaInfo->assignedHandle, srcStaInfo->peerControlledPort->port_action);
+ return -1;
+ }
+ switch (interfacePriv->interfaceMode)
+ {
+ case CSR_WIFI_ROUTER_CTRL_MODE_P2PGO:
+ case CSR_WIFI_ROUTER_CTRL_MODE_AP:
+ unifi_trace(priv, UDBG5, "mode is AP/P2PGO\n");
+ break;
+ default:
+ unifi_warning(priv, "mode is nor AP neither P2PGO, packet cant be xmit\n");
+ return -1;
+ }
+
+ switch(dstStaInfo->peerControlledPort->port_action)
+ {
+ case CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_CLOSED_DISCARD:
+ case CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_CLOSED_BLOCK:
+ unifi_trace(priv, UDBG5, "destination port is closed/blocked, discarding the packet\n");
+ return -1;
+ default:
+ unifi_trace(priv, UDBG5, "destination port state is open\n");
+ }
+
+ /* port state is open, destination station record is valid, Power save state is
+ * validated in uf_process_ma_packet_req function
+ */
+ unifi_trace(priv, UDBG5, "leaving uf_process_station_records_for_sending_data\n");
+ return 0;
+}
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * uf_handle_uspframes_delivery
+ *
+ * This function takes care of handling USP session for peer, when
+ * -> trigger frame from peer
+ * -> suspended USP to be processed (resumed)
+ *
+ * NOTE: uf_send_buffered_data_from_delivery_ac() always called from this function, Dont
+ * make a direct call to uf_send_buffered_data_from_delivery_ac() from any other part of
+ * code
+ *
+ * Arguments:
+ * priv Pointer to device private context struct
+ * staInfo peer for which UAPSD to be scheduled
+ * interfaceTag virtual interface tag
+ * ---------------------------------------------------------------------------
+ */
+static void uf_handle_uspframes_delivery(unifi_priv_t * priv, CsrWifiRouterCtrlStaInfo_t *staInfo, u16 interfaceTag)
+{
+
+ s8 i;
+ u8 allDeliveryEnabled = 0, dataAvailable = 0;
+ netInterface_priv_t *interfacePriv = priv->interfacePriv[interfaceTag];
+ unsigned long lock_flags;
+
+ unifi_trace(priv, UDBG2, " ++ uf_handle_uspframes_delivery, uapsd active=%x, suspended?=%x\n",
+ staInfo->uapsdActive, staInfo->uspSuspend);
+
+ /* Check for Buffered frames according to priority order & deliver it
+ * 1. AC_VO delivery enable & Mgt frames available
+ * 2. Process remaining Ac's from order AC_VO to AC_BK
+ */
+
+ /* USP initiated by WMMPS enabled peer & SET the status flag to TRUE */
+ if (!staInfo->uspSuspend && staInfo->uapsdActive)
+ {
+ unifi_notice(priv, "uf_handle_uspframes_delivery: U-APSD already active! STA=%x:%x:%x:%x:%x:%x\n",
+ staInfo->peerMacAddress.a[0], staInfo->peerMacAddress.a[1],
+ staInfo->peerMacAddress.a[2], staInfo->peerMacAddress.a[3],
+ staInfo->peerMacAddress.a[4], staInfo->peerMacAddress.a[5]);
+ return;
+ }
+
+ spin_lock_irqsave(&priv->staRecord_lock,lock_flags);
+ staInfo->uapsdActive = TRUE;
+ staInfo->uspSuspend = FALSE;
+ spin_unlock_irqrestore(&priv->staRecord_lock,lock_flags);
+
+ if(((staInfo->powersaveMode[UNIFI_TRAFFIC_Q_VO]==CSR_WIFI_AC_TRIGGER_AND_DELIVERY_ENABLED)||
+ (staInfo->powersaveMode[UNIFI_TRAFFIC_Q_VO]==CSR_WIFI_AC_DELIVERY_ONLY_ENABLE))
+ && (!list_empty(&staInfo->mgtFrames))) {
+
+ /* Management queue has data && UNIFI_TRAFFIC_Q_VO is delivery enable */
+ unifi_trace(priv, UDBG4, "uf_handle_uspframes_delivery: Sending buffered management frames\n");
+ uf_send_buffered_data_from_delivery_ac(priv, staInfo, UNIFI_TRAFFIC_Q_VO, &staInfo->mgtFrames);
+ }
+
+ if (!uf_is_more_data_for_delivery_ac(priv, staInfo)) {
+ /* All delivery enable AC's are empty, so QNULL to be sent to terminate the USP
+ * NOTE: If we have sent Mgt frame also, we must send QNULL followed to terminate USP
+ */
+ if (!staInfo->uspSuspend) {
+ spin_lock_irqsave(&priv->staRecord_lock,lock_flags);
+ staInfo->uapsdActive = FALSE;
+ spin_unlock_irqrestore(&priv->staRecord_lock,lock_flags);
+
+ unifi_trace(priv, UDBG2, "uf_handle_uspframes_delivery: sending QNull for trigger\n");
+ uf_send_qos_null(priv, interfaceTag, staInfo->peerMacAddress.a, (CSR_PRIORITY) staInfo->triggerFramePriority, staInfo);
+ staInfo->triggerFramePriority = CSR_QOS_UP0;
+ } else {
+ unifi_trace(priv, UDBG2, "uf_handle_uspframes_delivery: MgtQ xfer suspended\n");
+ }
+ } else {
+ for(i = UNIFI_TRAFFIC_Q_VO; i >= UNIFI_TRAFFIC_Q_BK; i--) {
+ if(((staInfo->powersaveMode[i]==CSR_WIFI_AC_DELIVERY_ONLY_ENABLE)
+ ||(staInfo->powersaveMode[i]==CSR_WIFI_AC_TRIGGER_AND_DELIVERY_ENABLED))
+ && (!list_empty(&staInfo->dataPdu[i]))) {
+ /* Deliver Data according to AC priority (from VO to BK) as part of USP */
+ unifi_trace(priv, UDBG4, "uf_handle_uspframes_delivery: Buffered data frames from Queue (%d) for USP\n", i);
+ uf_send_buffered_data_from_delivery_ac(priv, staInfo, i, &staInfo->dataPdu[i]);
+ }
+
+ if ((!staInfo->uapsdActive) ||
+ (staInfo->uspSuspend && IS_DTIM_ACTIVE(interfacePriv->dtimActive,interfacePriv->multicastPduHostTag))) {
+ /* If DTIM active found on one AC, No need to parse the remaining AC's
+ * as USP suspended. Break out of loop
+ */
+ unifi_trace(priv, UDBG2, "uf_handle_uspframes_delivery: suspend=%x, DTIM=%x, USP terminated=%s\n",
+ staInfo->uspSuspend, IS_DTIM_ACTIVE(interfacePriv->dtimActive,interfacePriv->multicastPduHostTag),
+ staInfo->uapsdActive?"NO":"YES");
+ break;
+ }
+ }
+ }
+
+ /* Depending on the USP status, update the TIM accordingly for delivery enabled AC only
+ * (since we are not manipulating any Non-delivery list(AC))
+ */
+ is_all_ac_deliver_enabled_and_moredata(staInfo, &allDeliveryEnabled, &dataAvailable);
+ if ((allDeliveryEnabled && !dataAvailable)) {
+ if ((staInfo->timSet != CSR_WIFI_TIM_RESET) || (staInfo->timSet != CSR_WIFI_TIM_RESETTING)) {
+ staInfo->updateTimReqQueued = (u8) CSR_WIFI_TIM_RESET;
+ unifi_trace(priv, UDBG4, " --uf_handle_uspframes_delivery, UAPSD timset\n");
+ if (!staInfo->timRequestPendingFlag) {
+ update_tim(priv, staInfo->aid, 0, interfaceTag, staInfo->assignedHandle);
+ }
+ }
+ }
+ unifi_trace(priv, UDBG2, " --uf_handle_uspframes_delivery, uapsd active=%x, suspend?=%x\n",
+ staInfo->uapsdActive, staInfo->uspSuspend);
+}
+
+void uf_process_wmm_deliver_ac_uapsd(unifi_priv_t * priv,
+ CsrWifiRouterCtrlStaInfo_t * srcStaInfo,
+ u16 qosControl,
+ u16 interfaceTag)
+{
+ CSR_PRIORITY priority;
+ unifi_TrafficQueue priority_q;
+ unsigned long lock_flags;
+
+ unifi_trace(priv, UDBG2, "++uf_process_wmm_deliver_ac_uapsd: uapsdactive?=%x\n", srcStaInfo->uapsdActive);
+ /* If recceived Frames trigger Frame and Devlivery enabled AC has data
+ * then transmit from High priorty delivery enabled AC
+ */
+ priority = (CSR_PRIORITY)(qosControl & IEEE802_11_QC_TID_MASK);
+ priority_q = unifi_frame_priority_to_queue((CSR_PRIORITY) priority);
+
+ if((srcStaInfo->powersaveMode[priority_q]==CSR_WIFI_AC_TRIGGER_ONLY_ENABLED)
+ ||(srcStaInfo->powersaveMode[priority_q]==CSR_WIFI_AC_TRIGGER_AND_DELIVERY_ENABLED)) {
+ spin_lock_irqsave(&priv->staRecord_lock,lock_flags);
+ srcStaInfo->triggerFramePriority = priority;
+ spin_unlock_irqrestore(&priv->staRecord_lock,lock_flags);
+ unifi_trace(priv, UDBG2, "uf_process_wmm_deliver_ac_uapsd: trigger frame, Begin U-APSD, triggerQ=%x\n", priority_q);
+ uf_handle_uspframes_delivery(priv, srcStaInfo, interfaceTag);
+ }
+ unifi_trace(priv, UDBG2, "--uf_process_wmm_deliver_ac_uapsd: uapsdactive?=%x\n", srcStaInfo->uapsdActive);
+}
+
+
+void uf_send_qos_null(unifi_priv_t * priv,u16 interfaceTag, const u8 *da,CSR_PRIORITY priority,CsrWifiRouterCtrlStaInfo_t * srcStaInfo)
+{
+ bulk_data_param_t bulkdata;
+ CsrResult csrResult;
+ struct sk_buff *skb, *newSkb = NULL;
+ CsrWifiMacAddress peerAddress;
+ netInterface_priv_t *interfacePriv = priv->interfacePriv[interfaceTag];
+ CSR_TRANSMISSION_CONTROL transmissionControl = (TRANSMISSION_CONTROL_EOSP_MASK | TRANSMISSION_CONTROL_TRIGGER_MASK);
+ int r;
+ CSR_SIGNAL signal;
+ u32 priority_q;
+ CSR_RATE transmitRate = 0;
+
+
+ func_enter();
+ /* Send a Null Frame to Peer,
+ * 32= size of mac header */
+ csrResult = unifi_net_data_malloc(priv, &bulkdata.d[0], MAC_HEADER_SIZE + QOS_CONTROL_HEADER_SIZE);
+
+ if (csrResult != CSR_RESULT_SUCCESS) {
+ unifi_error(priv, " failed to allocate request_data. in uf_send_qos_null func\n");
+ return ;
+ }
+ skb = (struct sk_buff *)(bulkdata.d[0].os_net_buf_ptr);
+ skb->len = 0;
+ bulkdata.d[0].os_data_ptr = skb->data;
+ bulkdata.d[0].os_net_buf_ptr = (unsigned char*)skb;
+ bulkdata.d[0].net_buf_length = bulkdata.d[0].data_length = skb->len;
+ bulkdata.d[1].os_data_ptr = NULL;
+ bulkdata.d[1].os_net_buf_ptr = NULL;
+ bulkdata.d[1].net_buf_length = bulkdata.d[1].data_length = 0;
+
+ /* For null frames protection bit should not be set in MAC header, so passing value 0 below for protection field */
+
+ if (prepare_and_add_macheader(priv, skb, newSkb, priority, &bulkdata, interfaceTag, da, interfacePriv->bssid.a, 0)) {
+ unifi_error(priv, "failed to create MAC header\n");
+ unifi_net_data_free(priv, &bulkdata.d[0]);
+ return;
+ }
+ memcpy(peerAddress.a, ((u8 *) bulkdata.d[0].os_data_ptr) + 4, ETH_ALEN);
+ /* convert priority to queue */
+ priority_q = unifi_frame_priority_to_queue((CSR_PRIORITY) priority);
+
+ /* Frame ma-packet.req, this is saved/transmitted depend on queue state
+ * send the null frame at data rate of 1 Mb/s for AP or 6 Mb/s for P2PGO
+ */
+ switch (interfacePriv->interfaceMode)
+ {
+ case CSR_WIFI_ROUTER_CTRL_MODE_AP:
+ transmitRate = 2;
+ break;
+ case CSR_WIFI_ROUTER_CTRL_MODE_P2PGO:
+ transmitRate = 12;
+ break;
+ default:
+ transmitRate = 0;
+ }
+ unifi_frame_ma_packet_req(priv, priority, transmitRate, 0xffffffff, interfaceTag,
+ transmissionControl, priv->netdev_client->sender_id,
+ peerAddress.a, &signal);
+
+ r = ul_send_signal_unpacked(priv, &signal, &bulkdata);
+ if(r) {
+ unifi_error(priv, "failed to send QOS data null packet result: %d\n",r);
+ unifi_net_data_free(priv, &bulkdata.d[0]);
+ }
+
+ func_exit();
+ return;
+
+}
+void uf_send_nulldata(unifi_priv_t * priv,u16 interfaceTag, const u8 *da,CSR_PRIORITY priority,CsrWifiRouterCtrlStaInfo_t * srcStaInfo)
+{
+ bulk_data_param_t bulkdata;
+ CsrResult csrResult;
+ struct sk_buff *skb, *newSkb = NULL;
+ CsrWifiMacAddress peerAddress;
+ netInterface_priv_t *interfacePriv = priv->interfacePriv[interfaceTag];
+ CSR_TRANSMISSION_CONTROL transmissionControl = 0;
+ int r;
+ CSR_SIGNAL signal;
+ u32 priority_q;
+ CSR_RATE transmitRate = 0;
+ CSR_MA_PACKET_REQUEST *req = &signal.u.MaPacketRequest;
+ unsigned long lock_flags;
+
+ func_enter();
+ /* Send a Null Frame to Peer, size = 24 for MAC header */
+ csrResult = unifi_net_data_malloc(priv, &bulkdata.d[0], MAC_HEADER_SIZE);
+
+ if (csrResult != CSR_RESULT_SUCCESS) {
+ unifi_error(priv, "uf_send_nulldata: Failed to allocate memory for NULL frame\n");
+ return ;
+ }
+ skb = (struct sk_buff *)(bulkdata.d[0].os_net_buf_ptr);
+ skb->len = 0;
+ bulkdata.d[0].os_data_ptr = skb->data;
+ bulkdata.d[0].os_net_buf_ptr = (unsigned char*)skb;
+ bulkdata.d[0].net_buf_length = bulkdata.d[0].data_length = skb->len;
+ bulkdata.d[1].os_data_ptr = NULL;
+ bulkdata.d[1].os_net_buf_ptr = NULL;
+ bulkdata.d[1].net_buf_length = bulkdata.d[1].data_length = 0;
+
+ /* For null frames protection bit should not be set in MAC header, so passing value 0 below for protection field */
+ if (prepare_and_add_macheader(priv, skb, newSkb, priority, &bulkdata, interfaceTag, da, interfacePriv->bssid.a, 0)) {
+ unifi_error(priv, "uf_send_nulldata: Failed to create MAC header\n");
+ unifi_net_data_free(priv, &bulkdata.d[0]);
+ return;
+ }
+ memcpy(peerAddress.a, ((u8 *) bulkdata.d[0].os_data_ptr) + 4, ETH_ALEN);
+ /* convert priority to queue */
+ priority_q = unifi_frame_priority_to_queue((CSR_PRIORITY) priority);
+ transmissionControl &= ~(CSR_NO_CONFIRM_REQUIRED);
+
+ /* Frame ma-packet.req, this is saved/transmitted depend on queue state
+ * send the null frame at data rate of 1 Mb/s for AP or 6 Mb/s for P2PGO
+ */
+ switch (interfacePriv->interfaceMode)
+ {
+ case CSR_WIFI_ROUTER_CTRL_MODE_AP:
+ transmitRate = 2;
+ break;
+ case CSR_WIFI_ROUTER_CTRL_MODE_P2PGO:
+ transmitRate = 12;
+ break;
+ default:
+ transmitRate = 0;
+ }
+ unifi_frame_ma_packet_req(priv, priority, transmitRate, INVALID_HOST_TAG, interfaceTag,
+ transmissionControl, priv->netdev_client->sender_id,
+ peerAddress.a, &signal);
+
+ /* Save host tag to check the status on reception of MA packet confirm */
+ srcStaInfo->nullDataHostTag = req->HostTag;
+ unifi_trace(priv, UDBG1, "uf_send_nulldata: STA AID = %d hostTag = %x\n", srcStaInfo->aid, req->HostTag);
+
+ r = ul_send_signal_unpacked(priv, &signal, &bulkdata);
+
+ if(r == -ENOSPC) {
+ unifi_trace(priv, UDBG1, "uf_send_nulldata: ENOSPC Requeue the Null frame\n");
+ enque_tx_data_pdu(priv, &bulkdata, &srcStaInfo->dataPdu[priority_q], &signal, 1);
+ spin_lock_irqsave(&priv->staRecord_lock,lock_flags);
+ srcStaInfo->noOfPktQueued++;
+ spin_unlock_irqrestore(&priv->staRecord_lock,lock_flags);
+
+
+ }
+ if(r && r != -ENOSPC){
+ unifi_error(priv, "uf_send_nulldata: Failed to send Null frame Error = %d\n",r);
+ unifi_net_data_free(priv, &bulkdata.d[0]);
+ srcStaInfo->nullDataHostTag = INVALID_HOST_TAG;
+ }
+
+ func_exit();
+ return;
+}
+
+u8 uf_check_broadcast_bssid(unifi_priv_t *priv, const bulk_data_param_t *bulkdata)
+{
+ u8 *bssid = NULL;
+ static const CsrWifiMacAddress broadcast_address = {{0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}};
+ u8 toDs, fromDs;
+
+ toDs = (((bulkdata->d[0].os_data_ptr)[1]) & 0x01) ? 1 : 0;
+ fromDs =(((bulkdata->d[0].os_data_ptr)[1]) & 0x02) ? 1 : 0;
+
+ if (toDs && fromDs)
+ {
+ unifi_trace(priv, UDBG6, "Address 4 present, Don't try to find BSSID\n");
+ bssid = NULL;
+ }
+ else if((toDs == 0) && (fromDs ==0))
+ {
+ /* BSSID is Address 3 */
+ bssid = (u8 *) (bulkdata->d[0].os_data_ptr + 4 + (2 * ETH_ALEN));
+ }
+ else if(toDs)
+ {
+ /* BSSID is Address 1 */
+ bssid = (u8 *) (bulkdata->d[0].os_data_ptr + 4);
+ }
+ else if(fromDs)
+ {
+ /* BSSID is Address 2 */
+ bssid = (u8 *) (bulkdata->d[0].os_data_ptr + 4 + ETH_ALEN);
+ }
+
+ if (memcmp(broadcast_address.a, bssid, ETH_ALEN)== 0)
+ {
+ return TRUE;
+ }
+ else
+ {
+ return FALSE;
+ }
+}
+
+
+u8 uf_process_pm_bit_for_peer(unifi_priv_t * priv, CsrWifiRouterCtrlStaInfo_t * srcStaInfo,
+ u8 pmBit,u16 interfaceTag)
+{
+ u8 moreData = FALSE;
+ u8 powerSaveChanged = FALSE;
+ unsigned long lock_flags;
+
+ unifi_trace(priv, UDBG3, "entering uf_process_pm_bit_for_peer\n");
+ if (pmBit) {
+ priv->allPeerDozing |= (0x01 << (srcStaInfo->assignedHandle));
+ } else {
+ priv->allPeerDozing &= ~(0x01 << (srcStaInfo->assignedHandle));
+ }
+ if(pmBit) {
+ if(srcStaInfo->currentPeerState == CSR_WIFI_ROUTER_CTRL_PEER_CONNECTED_ACTIVE) {
+
+ /* disable the preemption */
+ spin_lock_irqsave(&priv->staRecord_lock,lock_flags);
+ srcStaInfo->currentPeerState =CSR_WIFI_ROUTER_CTRL_PEER_CONNECTED_POWER_SAVE;
+ powerSaveChanged = TRUE;
+ /* enable the preemption */
+ spin_unlock_irqrestore(&priv->staRecord_lock,lock_flags);
+ } else {
+ return powerSaveChanged;
+ }
+ } else {
+ if(srcStaInfo->currentPeerState == CSR_WIFI_ROUTER_CTRL_PEER_CONNECTED_POWER_SAVE) {
+ /* disable the preemption */
+ spin_lock_irqsave(&priv->staRecord_lock,lock_flags);
+ srcStaInfo->currentPeerState = CSR_WIFI_ROUTER_CTRL_PEER_CONNECTED_ACTIVE;
+ powerSaveChanged = TRUE;
+ /* enable the preemption */
+ spin_unlock_irqrestore(&priv->staRecord_lock,lock_flags);
+ }else {
+ return powerSaveChanged;
+ }
+ }
+
+
+ if(srcStaInfo->currentPeerState == CSR_WIFI_ROUTER_CTRL_PEER_CONNECTED_ACTIVE) {
+ unifi_trace(priv,UDBG3, "Peer with AID = %d is active now\n",srcStaInfo->aid);
+ process_peer_active_transition(priv,srcStaInfo,interfaceTag);
+ } else {
+ unifi_trace(priv,UDBG3, "Peer with AID = %d is in PS Now\n",srcStaInfo->aid);
+ /* Set TIM if needed */
+ if(!srcStaInfo->wmmOrQosEnabled) {
+ moreData = (!list_empty(&srcStaInfo->mgtFrames) ||
+ !list_empty(&srcStaInfo->dataPdu[UNIFI_TRAFFIC_Q_VO])||
+ !list_empty(&srcStaInfo->dataPdu[UNIFI_TRAFFIC_Q_CONTENTION]));
+ if(moreData && (srcStaInfo->timSet == CSR_WIFI_TIM_RESET)) {
+ unifi_trace(priv, UDBG3, "This condition should not occur\n");
+ if (!srcStaInfo->timRequestPendingFlag){
+ update_tim(priv,srcStaInfo->aid,1,interfaceTag, srcStaInfo->assignedHandle);
+ }
+ else
+ {
+ /* Cache the TimSet value so that it will processed immidiatly after
+ * completing the current setTim Request
+ */
+ srcStaInfo->updateTimReqQueued = 1;
+ unifi_trace(priv, UDBG6, "update_tim : One more UpdateTim Request (Tim value:%d) Queued for AID %x\n", srcStaInfo->updateTimReqQueued,
+ srcStaInfo->aid);
+ }
+
+ }
+ } else {
+ u8 allDeliveryEnabled = 0, dataAvailable = 0;
+ unifi_trace(priv, UDBG5, "Qos in AP Mode\n");
+ /* Check if all AC's are Delivery Enabled */
+ is_all_ac_deliver_enabled_and_moredata(srcStaInfo, &allDeliveryEnabled, &dataAvailable);
+ /*check for more data in non-delivery enabled queues*/
+ moreData = (uf_is_more_data_for_non_delivery_ac(srcStaInfo) || (allDeliveryEnabled && dataAvailable));
+
+ if(moreData && (srcStaInfo->timSet == CSR_WIFI_TIM_RESET)) {
+ if (!srcStaInfo->timRequestPendingFlag){
+ update_tim(priv,srcStaInfo->aid,1,interfaceTag, srcStaInfo->assignedHandle);
+ }
+ else
+ {
+ /* Cache the TimSet value so that it will processed immidiatly after
+ * completing the current setTim Request
+ */
+ srcStaInfo->updateTimReqQueued = 1;
+ unifi_trace(priv, UDBG6, "update_tim : One more UpdateTim Request (Tim value:%d) Queued for AID %x\n", srcStaInfo->updateTimReqQueued,
+ srcStaInfo->aid);
+ }
+ }
+ }
+ }
+ unifi_trace(priv, UDBG3, "leaving uf_process_pm_bit_for_peer\n");
+ return powerSaveChanged;
+}
+
+
+
+void uf_process_ps_poll(unifi_priv_t *priv,u8* sa,u8* da,u8 pmBit,u16 interfaceTag)
+{
+ CsrWifiRouterCtrlStaInfo_t *staRecord =
+ CsrWifiRouterCtrlGetStationRecordFromPeerMacAddress(priv, sa, interfaceTag);
+ tx_buffered_packets_t * buffered_pkt = NULL;
+ CsrWifiMacAddress peerMacAddress;
+ unsigned long lock_flags;
+ s8 r =0;
+ u8 moreData = FALSE;
+ netInterface_priv_t *interfacePriv = priv->interfacePriv[interfaceTag];
+
+ unifi_trace(priv, UDBG3, "entering uf_process_ps_poll\n");
+ if(!staRecord) {
+ memcpy(peerMacAddress.a,sa,ETH_ALEN);
+ unifi_trace(priv, UDBG3, "In uf_process_ps_poll, sta record not found:unexpected frame addr = %x:%x:%x:%x:%x:%x\n",
+ sa[0], sa[1],sa[2], sa[3], sa[4],sa[5]);
+ CsrWifiRouterCtrlUnexpectedFrameIndSend(priv->CSR_WIFI_SME_IFACEQUEUE,0,interfaceTag,peerMacAddress);
+ return;
+ }
+
+ uf_process_pm_bit_for_peer(priv,staRecord,pmBit,interfaceTag);
+
+ /* Update station last activity time */
+ staRecord->activity_flag = TRUE;
+
+ /* This should not change the PM bit as PS-POLL has PM bit always set */
+ if(!pmBit) {
+ unifi_notice (priv," PM bit reset in PS-POLL\n");
+ return;
+ }
+
+ if(IS_DTIM_ACTIVE(interfacePriv->dtimActive,interfacePriv->multicastPduHostTag)) {
+ /* giving more priority to multicast packets so dropping ps-poll*/
+ unifi_notice (priv," multicast transmission is going on so don't take action on PS-POLL\n");
+ return;
+ }
+
+ if(!staRecord->wmmOrQosEnabled) {
+ if((buffered_pkt=dequeue_tx_data_pdu(priv, &staRecord->mgtFrames))) {
+ buffered_pkt->transmissionControl |= TRANSMISSION_CONTROL_TRIGGER_MASK;
+ moreData = (!list_empty(&staRecord->dataPdu[UNIFI_TRAFFIC_Q_CONTENTION]) ||
+ !list_empty(&staRecord->dataPdu[UNIFI_TRAFFIC_Q_VO]) ||
+ !list_empty(&staRecord->mgtFrames));
+
+ buffered_pkt->transmissionControl |= (TRANSMISSION_CONTROL_TRIGGER_MASK | TRANSMISSION_CONTROL_EOSP_MASK);
+ if((r=frame_and_send_queued_pdu(priv,buffered_pkt,staRecord,moreData,FALSE)) == -ENOSPC) {
+ /* Clear the trigger bit transmission control*/
+ buffered_pkt->transmissionControl &= ~(TRANSMISSION_CONTROL_TRIGGER_MASK | TRANSMISSION_CONTROL_EOSP_MASK);
+ /* Enqueue at the head of the queue */
+ spin_lock_irqsave(&priv->tx_q_lock,lock_flags);
+ list_add(&buffered_pkt->q, &staRecord->mgtFrames);
+ spin_unlock_irqrestore(&priv->tx_q_lock,lock_flags);
+ unifi_trace(priv, UDBG1, "(ENOSPC) PS-POLL received : PDU sending failed \n");
+ priv->pausedStaHandle[3]=(u8)(staRecord->assignedHandle);
+ } else {
+ if(r){
+ unifi_trace (priv, UDBG1, " HIP validation failure : PDU sending failed \n");
+ /* the PDU failed where we can't do any thing so free the storage */
+ unifi_net_data_free(priv, &buffered_pkt->bulkdata);
+ }
+ kfree(buffered_pkt);
+ }
+ } else if((buffered_pkt=dequeue_tx_data_pdu(priv, &staRecord->dataPdu[UNIFI_TRAFFIC_Q_VO]))) {
+ buffered_pkt->transmissionControl |= TRANSMISSION_CONTROL_TRIGGER_MASK;
+ moreData = (!list_empty(&staRecord->dataPdu[UNIFI_TRAFFIC_Q_CONTENTION]) ||
+ !list_empty(&staRecord->dataPdu[UNIFI_TRAFFIC_Q_VO]));
+
+ buffered_pkt->transmissionControl |= (TRANSMISSION_CONTROL_TRIGGER_MASK | TRANSMISSION_CONTROL_EOSP_MASK);
+ if((r=frame_and_send_queued_pdu(priv,buffered_pkt,staRecord,moreData,FALSE)) == -ENOSPC) {
+ /* Clear the trigger bit transmission control*/
+ buffered_pkt->transmissionControl &= ~(TRANSMISSION_CONTROL_TRIGGER_MASK | TRANSMISSION_CONTROL_EOSP_MASK);
+ /* Enqueue at the head of the queue */
+ spin_lock_irqsave(&priv->tx_q_lock,lock_flags);
+ list_add(&buffered_pkt->q, &staRecord->dataPdu[UNIFI_TRAFFIC_Q_VO]);
+ spin_unlock_irqrestore(&priv->tx_q_lock,lock_flags);
+ priv->pausedStaHandle[3]=(u8)(staRecord->assignedHandle);
+ unifi_trace(priv, UDBG1, "(ENOSPC) PS-POLL received : PDU sending failed \n");
+ } else {
+ if(r){
+ unifi_trace (priv, UDBG1, " HIP validation failure : PDU sending failed \n");
+ /* the PDU failed where we can't do any thing so free the storage */
+ unifi_net_data_free(priv, &buffered_pkt->bulkdata);
+ }
+ kfree(buffered_pkt);
+ }
+ } else if((buffered_pkt=dequeue_tx_data_pdu(priv, &staRecord->dataPdu[UNIFI_TRAFFIC_Q_CONTENTION]))) {
+ buffered_pkt->transmissionControl |= TRANSMISSION_CONTROL_TRIGGER_MASK;
+ moreData = !list_empty(&staRecord->dataPdu[UNIFI_TRAFFIC_Q_CONTENTION]);
+
+ buffered_pkt->transmissionControl |= (TRANSMISSION_CONTROL_TRIGGER_MASK | TRANSMISSION_CONTROL_EOSP_MASK);
+ if((r=frame_and_send_queued_pdu(priv,buffered_pkt,staRecord,moreData,FALSE)) == -ENOSPC) {
+ /* Clear the trigger bit transmission control*/
+ buffered_pkt->transmissionControl &= ~(TRANSMISSION_CONTROL_TRIGGER_MASK | TRANSMISSION_CONTROL_EOSP_MASK);
+ /* Enqueue at the head of the queue */
+ spin_lock_irqsave(&priv->tx_q_lock,lock_flags);
+ list_add(&buffered_pkt->q, &staRecord->dataPdu[UNIFI_TRAFFIC_Q_CONTENTION]);
+ spin_unlock_irqrestore(&priv->tx_q_lock,lock_flags);
+ priv->pausedStaHandle[0]=(u8)(staRecord->assignedHandle);
+ unifi_trace(priv, UDBG1, "(ENOSPC) PS-POLL received : PDU sending failed \n");
+ } else {
+ if(r){
+ unifi_trace (priv, UDBG1, " HIP validation failure : PDU sending failed \n");
+ /* the PDU failed where we can't do any thing so free the storage */
+ unifi_net_data_free(priv, &buffered_pkt->bulkdata);
+ }
+ kfree(buffered_pkt);
+ }
+ } else {
+ /* Actually since we have sent an ACK, there
+ * there is no need to send a NULL frame*/
+ }
+ moreData = (!list_empty(&staRecord->dataPdu[UNIFI_TRAFFIC_Q_VO]) ||
+ !list_empty(&staRecord->dataPdu[UNIFI_TRAFFIC_Q_CONTENTION]) ||
+ !list_empty(&staRecord->mgtFrames));
+ if(!moreData && (staRecord->timSet == CSR_WIFI_TIM_SET)) {
+ unifi_trace(priv, UDBG3, "more data = NULL, set tim to 0 in uf_process_ps_poll\n");
+ if (!staRecord->timRequestPendingFlag){
+ update_tim(priv,staRecord->aid,0,interfaceTag, staRecord->assignedHandle);
+ }
+ else
+ {
+ /* Cache the TimSet value so that it will processed immidiatly after
+ * completing the current setTim Request
+ */
+ staRecord->updateTimReqQueued = 0;
+ unifi_trace(priv, UDBG6, "update_tim : One more UpdateTim Request (Tim value:%d) Queued for AID %x\n", staRecord->updateTimReqQueued,
+ staRecord->aid);
+ }
+ }
+ } else {
+
+ u8 allDeliveryEnabled = 0, dataAvailable = 0;
+ unifi_trace(priv, UDBG3,"Qos Support station.Processing PS-Poll\n");
+
+ /*Send Data From Management Frames*/
+ /* Priority orders for delivering the buffered packets are
+ * 1. Deliver the Management frames if there
+ * 2. Other access catagory frames which are non deliver enable including UNIFI_TRAFFIC_Q_VO
+ * priority is from VO->BK
+ */
+
+ /* Check if all AC's are Delivery Enabled */
+ is_all_ac_deliver_enabled_and_moredata(staRecord, &allDeliveryEnabled, &dataAvailable);
+
+ if (allDeliveryEnabled) {
+ unifi_trace(priv, UDBG3, "uf_process_ps_poll: All ACs are delivery enable so Sending QOS Null in response of Ps-poll\n");
+ uf_send_qos_null(priv,interfaceTag,sa,CSR_QOS_UP0,staRecord);
+ return;
+ }
+
+ if (!list_empty(&staRecord->mgtFrames)) {
+ if ((buffered_pkt=dequeue_tx_data_pdu(priv, &staRecord->mgtFrames))) {
+ /* We dont have packets in non delivery enabled UNIFI_TRAFFIC_Q_VO, So we are looking in management
+ * queue of the station record
+ */
+ moreData = uf_is_more_data_for_non_delivery_ac(staRecord);
+ buffered_pkt->transmissionControl |= (TRANSMISSION_CONTROL_TRIGGER_MASK | TRANSMISSION_CONTROL_EOSP_MASK);
+
+ /* Last parameter is EOSP & its false always for PS-POLL processing */
+ if((r=frame_and_send_queued_pdu(priv,buffered_pkt,staRecord,moreData,FALSE)) == -ENOSPC) {
+ /* Clear the trigger bit transmission control*/
+ buffered_pkt->transmissionControl &= ~(TRANSMISSION_CONTROL_TRIGGER_MASK | TRANSMISSION_CONTROL_EOSP_MASK);
+ /* Enqueue at the head of the queue */
+ spin_lock_irqsave(&priv->tx_q_lock,lock_flags);
+ list_add(&buffered_pkt->q, &staRecord->mgtFrames);
+ spin_unlock_irqrestore(&priv->tx_q_lock,lock_flags);
+ priv->pausedStaHandle[0]=(u8)(staRecord->assignedHandle);
+ unifi_trace(priv, UDBG1, "(ENOSPC) PS-POLL received : PDU sending failed \n");
+ } else {
+ if(r){
+ unifi_trace (priv, UDBG1, " HIP validation failure : PDU sending failed \n");
+ /* the PDU failed where we can't do any thing so free the storage */
+ unifi_net_data_free(priv, &buffered_pkt->bulkdata);
+ }
+ kfree(buffered_pkt);
+ }
+ } else {
+ unifi_error(priv, "uf_process_ps_poll: Mgt frame list empty!! \n");
+ }
+
+ } else {
+ s8 i;
+ /* We dont have buffered packet in mangement frame queue (1 failed), So proceed with condition 2
+ * UNIFI_TRAFFIC_Q_VO -> VI -> BE -> BK
+ */
+ for(i= 3; i>=0; i--) {
+ if (!IS_DELIVERY_ENABLED(staRecord->powersaveMode[i])) {
+ /* Send One packet, if queue is NULL then continue */
+ if((buffered_pkt=dequeue_tx_data_pdu(priv, &staRecord->dataPdu[i]))) {
+ moreData = uf_is_more_data_for_non_delivery_ac(staRecord);
+
+ buffered_pkt->transmissionControl |= (TRANSMISSION_CONTROL_TRIGGER_MASK | TRANSMISSION_CONTROL_EOSP_MASK);
+
+ /* Last parameter is EOSP & its false always for PS-POLL processing */
+ if((r=frame_and_send_queued_pdu(priv,buffered_pkt,staRecord,moreData,FALSE)) == -ENOSPC) {
+ /* Clear the trigger bit transmission control*/
+ buffered_pkt->transmissionControl &= ~(TRANSMISSION_CONTROL_TRIGGER_MASK | TRANSMISSION_CONTROL_EOSP_MASK);
+ /* Enqueue at the head of the queue */
+ spin_lock_irqsave(&priv->tx_q_lock,lock_flags);
+ list_add(&buffered_pkt->q, &staRecord->dataPdu[i]);
+ spin_unlock_irqrestore(&priv->tx_q_lock,lock_flags);
+ priv->pausedStaHandle[0]=(u8)(staRecord->assignedHandle);
+ unifi_trace(priv, UDBG1, "(ENOSPC) PS-POLL received : PDU sending failed \n");
+ } else {
+ if(r) {
+ unifi_trace (priv, UDBG1, " HIP validation failure : PDU sending failed \n");
+ /* the PDU failed where we can't do any thing so free the storage */
+ unifi_net_data_free(priv, &buffered_pkt->bulkdata);
+ }
+ kfree(buffered_pkt);
+ }
+ break;
+ }
+ }
+ }
+ }
+ /* Check if all AC's are Delivery Enabled */
+ is_all_ac_deliver_enabled_and_moredata(staRecord, &allDeliveryEnabled, &dataAvailable);
+ /*check for more data in non-delivery enabled queues*/
+ moreData = (uf_is_more_data_for_non_delivery_ac(staRecord) || (allDeliveryEnabled && dataAvailable));
+ if(!moreData && (staRecord->timSet == CSR_WIFI_TIM_SET)) {
+ unifi_trace(priv, UDBG3, "more data = NULL, set tim to 0 in uf_process_ps_poll\n");
+ if (!staRecord->timRequestPendingFlag){
+ update_tim(priv,staRecord->aid,0,interfaceTag, staRecord->assignedHandle);
+ }
+ else
+ {
+ /* Cache the TimSet value so that it will processed immidiatly after
+ * completing the current setTim Request
+ */
+ staRecord->updateTimReqQueued = 0;
+ unifi_trace(priv, UDBG6, "update_tim : One more UpdateTim Request (Tim value:%d) Queued for AID %x\n", staRecord->updateTimReqQueued,
+ staRecord->aid);
+ }
+
+ }
+ }
+
+ unifi_trace(priv, UDBG3, "leaving uf_process_ps_poll\n");
+}
+
+
+
+void add_to_send_cfm_list(unifi_priv_t * priv,
+ tx_buffered_packets_t *tx_q_item,
+ struct list_head *frames_need_cfm_list)
+{
+ tx_buffered_packets_t *send_cfm_list_item = NULL;
+
+ send_cfm_list_item = (tx_buffered_packets_t *) kmalloc(sizeof(tx_buffered_packets_t), GFP_ATOMIC);
+
+ if(send_cfm_list_item == NULL){
+ unifi_warning(priv, "%s: Failed to allocate memory for new list item \n");
+ return;
+ }
+
+ INIT_LIST_HEAD(&send_cfm_list_item->q);
+
+ send_cfm_list_item->hostTag = tx_q_item->hostTag;
+ send_cfm_list_item->interfaceTag = tx_q_item->interfaceTag;
+ send_cfm_list_item->transmissionControl = tx_q_item->transmissionControl;
+ send_cfm_list_item->leSenderProcessId = tx_q_item->leSenderProcessId;
+ send_cfm_list_item->rate = tx_q_item->rate;
+ memcpy(send_cfm_list_item->peerMacAddress.a, tx_q_item->peerMacAddress.a, ETH_ALEN);
+ send_cfm_list_item->priority = tx_q_item->priority;
+
+ list_add_tail(&send_cfm_list_item->q, frames_need_cfm_list);
+}
+
+void uf_prepare_send_cfm_list_for_queued_pkts(unifi_priv_t * priv,
+ struct list_head *frames_need_cfm_list,
+ struct list_head * list)
+{
+ tx_buffered_packets_t *tx_q_item = NULL;
+ struct list_head *listHead;
+ struct list_head *placeHolder;
+ unsigned long lock_flags;
+
+ func_enter();
+
+ spin_lock_irqsave(&priv->tx_q_lock,lock_flags);
+
+ /* Search through the list and if confirmation required for any frames,
+ add it to the send_cfm list */
+ list_for_each_safe(listHead, placeHolder, list) {
+ tx_q_item = list_entry(listHead, tx_buffered_packets_t, q);
+
+ if(!tx_q_item) {
+ unifi_error(priv, "Entry should exist, otherwise it is a (BUG)\n");
+ continue;
+ }
+
+ /* check if confirmation is requested and if the sender ID
+ is not netdevice client then save the entry in the list for need cfms */
+ if (!(tx_q_item->transmissionControl & CSR_NO_CONFIRM_REQUIRED) &&
+ (tx_q_item->leSenderProcessId != priv->netdev_client->sender_id)){
+ unifi_trace(priv, UDBG1, "%s: SenderProcessID=%x host tag=%x transmission control=%x\n",
+ __FUNCTION__,
+ tx_q_item->leSenderProcessId,
+ tx_q_item->hostTag,
+ tx_q_item->transmissionControl);
+
+ add_to_send_cfm_list(priv, tx_q_item, frames_need_cfm_list);
+ }
+ }
+
+ spin_unlock_irqrestore(&priv->tx_q_lock,lock_flags);
+
+ func_exit();
+}
+
+
+
+void uf_flush_list(unifi_priv_t * priv, struct list_head * list)
+{
+ tx_buffered_packets_t *tx_q_item;
+ struct list_head *listHead;
+ struct list_head *placeHolder;
+ unsigned long lock_flags;
+
+ unifi_trace(priv, UDBG5, "entering the uf_flush_list \n");
+
+ spin_lock_irqsave(&priv->tx_q_lock,lock_flags);
+ /* go through list, delete & free memory */
+ list_for_each_safe(listHead, placeHolder, list) {
+ tx_q_item = list_entry(listHead, tx_buffered_packets_t, q);
+
+ if(!tx_q_item) {
+ unifi_error(priv, "entry should exists, otherwise crashes (bug)\n");
+ }
+ unifi_trace(priv, UDBG5,
+ "proccess_tx: in uf_flush_list peerMacAddress=%02X%02X%02X%02X%02X%02X senderProcessId=%x\n",
+ tx_q_item->peerMacAddress.a[0], tx_q_item->peerMacAddress.a[1],
+ tx_q_item->peerMacAddress.a[2], tx_q_item->peerMacAddress.a[3],
+ tx_q_item->peerMacAddress.a[4], tx_q_item->peerMacAddress.a[5],
+ tx_q_item->leSenderProcessId);
+
+ list_del(listHead);
+ /* free the allocated memory */
+ unifi_net_data_free(priv, &tx_q_item->bulkdata);
+ kfree(tx_q_item);
+ tx_q_item = NULL;
+ if (!priv->noOfPktQueuedInDriver) {
+ unifi_error(priv, "packets queued in driver 0 still decrementing in %s\n", __FUNCTION__);
+ } else {
+ priv->noOfPktQueuedInDriver--;
+ }
+ }
+ spin_unlock_irqrestore(&priv->tx_q_lock,lock_flags);
+}
+
+tx_buffered_packets_t *dequeue_tx_data_pdu(unifi_priv_t *priv, struct list_head *txList)
+{
+ /* dequeue the tx data packets from the appropriate queue */
+ tx_buffered_packets_t *tx_q_item = NULL;
+ struct list_head *listHead;
+ struct list_head *placeHolder;
+ unsigned long lock_flags;
+
+ unifi_trace(priv, UDBG5, "entering dequeue_tx_data_pdu\n");
+ /* check for list empty */
+ if (list_empty(txList)) {
+ unifi_trace(priv, UDBG5, "In dequeue_tx_data_pdu, the list is empty\n");
+ return NULL;
+ }
+
+ /* Verification, if packet count is negetive */
+ if (priv->noOfPktQueuedInDriver == 0xFFFF) {
+ unifi_warning(priv, "no packet available in queue: debug");
+ return NULL;
+ }
+
+ /* return first node after header, & delete from the list && atleast one item exist */
+ spin_lock_irqsave(&priv->tx_q_lock,lock_flags);
+ list_for_each_safe(listHead, placeHolder, txList) {
+ tx_q_item = list_entry(listHead, tx_buffered_packets_t, q);
+ list_del(listHead);
+ break;
+ }
+ spin_unlock_irqrestore(&priv->tx_q_lock,lock_flags);
+
+ if (tx_q_item) {
+ unifi_trace(priv, UDBG5,
+ "proccess_tx: In dequeue_tx_data_pdu peerMacAddress=%02X%02X%02X%02X%02X%02X senderProcessId=%x\n",
+ tx_q_item->peerMacAddress.a[0], tx_q_item->peerMacAddress.a[1],
+ tx_q_item->peerMacAddress.a[2], tx_q_item->peerMacAddress.a[3],
+ tx_q_item->peerMacAddress.a[4], tx_q_item->peerMacAddress.a[5],
+ tx_q_item->leSenderProcessId);
+ }
+
+ unifi_trace(priv, UDBG5, "leaving dequeue_tx_data_pdu\n");
+ return tx_q_item;
+}
+/* generic function to get the station record handler */
+CsrWifiRouterCtrlStaInfo_t *CsrWifiRouterCtrlGetStationRecordFromPeerMacAddress(unifi_priv_t *priv,
+ const u8 *peerMacAddress,
+ u16 interfaceTag)
+{
+ u8 i;
+ netInterface_priv_t *interfacePriv;
+ unsigned long lock_flags;
+
+ if (interfaceTag >= CSR_WIFI_NUM_INTERFACES) {
+ unifi_error(priv, "interfaceTag is not proper, interfaceTag = %d\n", interfaceTag);
+ return NULL;
+ }
+
+ interfacePriv = priv->interfacePriv[interfaceTag];
+
+ /* disable the preemption untill station record is fetched */
+ spin_lock_irqsave(&priv->staRecord_lock,lock_flags);
+
+ for (i = 0; i < UNIFI_MAX_CONNECTIONS; i++) {
+ if (interfacePriv->staInfo[i]!= NULL) {
+ if (!memcmp(((CsrWifiRouterCtrlStaInfo_t *) (interfacePriv->staInfo[i]))->peerMacAddress.a, peerMacAddress, ETH_ALEN)) {
+ /* enable the preemption as station record is fetched */
+ spin_unlock_irqrestore(&priv->staRecord_lock,lock_flags);
+ unifi_trace(priv, UDBG5, "peer entry found in station record\n");
+ return ((CsrWifiRouterCtrlStaInfo_t *) (interfacePriv->staInfo[i]));
+ }
+ }
+ }
+ /* enable the preemption as station record is fetched */
+ spin_unlock_irqrestore(&priv->staRecord_lock,lock_flags);
+ unifi_trace(priv, UDBG5, "peer entry not found in station record\n");
+ return NULL;
+}
+/* generic function to get the station record handler from the handle */
+CsrWifiRouterCtrlStaInfo_t * CsrWifiRouterCtrlGetStationRecordFromHandle(unifi_priv_t *priv,
+ u32 handle,
+ u16 interfaceTag)
+{
+ netInterface_priv_t *interfacePriv;
+
+ if ((handle >= UNIFI_MAX_CONNECTIONS) || (interfaceTag >= CSR_WIFI_NUM_INTERFACES)) {
+ unifi_error(priv, "handle/interfaceTag is not proper, handle = %d, interfaceTag = %d\n", handle, interfaceTag);
+ return NULL;
+ }
+ interfacePriv = priv->interfacePriv[interfaceTag];
+ return ((CsrWifiRouterCtrlStaInfo_t *) (interfacePriv->staInfo[handle]));
+}
+
+/* Function to do inactivity */
+void uf_check_inactivity(unifi_priv_t *priv, u16 interfaceTag, CsrTime currentTime)
+{
+ u32 i;
+ CsrWifiRouterCtrlStaInfo_t *staInfo;
+ CsrTime elapsedTime; /* Time in microseconds */
+ netInterface_priv_t *interfacePriv = priv->interfacePriv[interfaceTag];
+ CsrWifiMacAddress peerMacAddress;
+ unsigned long lock_flags;
+
+ if (interfacePriv == NULL) {
+ unifi_trace(priv, UDBG3, "uf_check_inactivity: Interface priv is NULL \n");
+ return;
+ }
+
+ spin_lock_irqsave(&priv->staRecord_lock,lock_flags);
+ /* Go through the list of stations to check for inactivity */
+ for(i = 0; i < UNIFI_MAX_CONNECTIONS; i++) {
+ staInfo = CsrWifiRouterCtrlGetStationRecordFromHandle(priv, i, interfaceTag);
+ if(!staInfo ) {
+ continue;
+ }
+
+ unifi_trace(priv, UDBG3, "Running Inactivity handler Time %xus station's last activity %xus\n",
+ currentTime, staInfo->lastActivity);
+
+
+ elapsedTime = (currentTime >= staInfo->lastActivity)?
+ (currentTime - staInfo->lastActivity):
+ (~((u32)0) - staInfo->lastActivity + currentTime);
+ spin_unlock_irqrestore(&priv->staRecord_lock,lock_flags);
+
+ if (elapsedTime > MAX_INACTIVITY_INTERVAL) {
+ memcpy((u8*)&peerMacAddress, (u8*)&staInfo->peerMacAddress, sizeof(CsrWifiMacAddress));
+
+ /* Indicate inactivity for the station */
+ unifi_trace(priv, UDBG3, "Station %x:%x:%x:%x:%x:%x inactive since %xus\n sending Inactive Ind\n",
+ peerMacAddress.a[0], peerMacAddress.a[1],
+ peerMacAddress.a[2], peerMacAddress.a[3],
+ peerMacAddress.a[4], peerMacAddress.a[5],
+ elapsedTime);
+
+ CsrWifiRouterCtrlStaInactiveIndSend(priv->CSR_WIFI_SME_IFACEQUEUE, 0, interfaceTag, peerMacAddress);
+ }
+ }
+
+ interfacePriv->last_inactivity_check = currentTime;
+}
+
+/* Function to update activity of a station */
+void uf_update_sta_activity(unifi_priv_t *priv, u16 interfaceTag, const u8 *peerMacAddress)
+{
+ CsrTime elapsedTime, currentTime; /* Time in microseconds */
+ CsrTime timeHi; /* Not used - Time in microseconds */
+ CsrWifiRouterCtrlStaInfo_t *staInfo;
+ netInterface_priv_t *interfacePriv = priv->interfacePriv[interfaceTag];
+ unsigned long lock_flags;
+
+ if (interfacePriv == NULL) {
+ unifi_trace(priv, UDBG3, "uf_check_inactivity: Interface priv is NULL \n");
+ return;
+ }
+
+ currentTime = CsrTimeGet(&timeHi);
+
+
+ staInfo = CsrWifiRouterCtrlGetStationRecordFromPeerMacAddress(priv, peerMacAddress, interfaceTag);
+
+ if (staInfo == NULL) {
+ unifi_trace(priv, UDBG4, "Sta does not exist yet");
+ return;
+ }
+
+ spin_lock_irqsave(&priv->staRecord_lock,lock_flags);
+ /* Update activity */
+ staInfo->lastActivity = currentTime;
+
+ /* See if inactivity handler needs to be run
+ * Here it is theoretically possible that the counter may have wrapped around. But
+ * since we just want to know when to run the inactivity handler it does not really matter.
+ * Especially since this is data path it makes sense in keeping it simple and avoiding
+ * 64 bit handling */
+ elapsedTime = (currentTime >= interfacePriv->last_inactivity_check)?
+ (currentTime - interfacePriv->last_inactivity_check):
+ (~((u32)0) - interfacePriv->last_inactivity_check + currentTime);
+
+ spin_unlock_irqrestore(&priv->staRecord_lock,lock_flags);
+
+ /* Check if it is time to run the inactivity handler */
+ if (elapsedTime > INACTIVITY_CHECK_INTERVAL) {
+ uf_check_inactivity(priv, interfaceTag, currentTime);
+ }
+}
+void resume_unicast_buffered_frames(unifi_priv_t *priv, u16 interfaceTag)
+{
+
+ netInterface_priv_t *interfacePriv = priv->interfacePriv[interfaceTag];
+ u8 i;
+ int j;
+ tx_buffered_packets_t * buffered_pkt = NULL;
+ u8 hipslotFree[4] = {TRUE,TRUE,TRUE,TRUE};
+ int r;
+ unsigned long lock_flags;
+
+ func_enter();
+ while(!isRouterBufferEnabled(priv,3) &&
+ ((buffered_pkt=dequeue_tx_data_pdu(priv,&interfacePriv->genericMgtFrames))!=NULL)) {
+ buffered_pkt->transmissionControl &=
+ ~(TRANSMISSION_CONTROL_TRIGGER_MASK|TRANSMISSION_CONTROL_EOSP_MASK);
+ if((r=frame_and_send_queued_pdu(priv,buffered_pkt,NULL,0,FALSE)) == -ENOSPC) {
+ /* Enqueue at the head of the queue */
+ spin_lock_irqsave(&priv->tx_q_lock,lock_flags);
+ list_add(&buffered_pkt->q, &interfacePriv->genericMgtFrames);
+ spin_unlock_irqrestore(&priv->tx_q_lock,lock_flags);
+ hipslotFree[3]=FALSE;
+ break;
+ }else {
+ if(r){
+ unifi_trace (priv, UDBG1, " HIP validation failure : PDU sending failed \n");
+ /* the PDU failed where we can't do any thing so free the storage */
+ unifi_net_data_free(priv, &buffered_pkt->bulkdata);
+ }
+ kfree(buffered_pkt);
+ }
+ }
+ for(i = 0; i < UNIFI_MAX_CONNECTIONS; i++) {
+ CsrWifiRouterCtrlStaInfo_t *staInfo = interfacePriv->staInfo[i];
+ if(!hipslotFree[0] && !hipslotFree[1] && !hipslotFree[2] && !hipslotFree[3]) {
+ unifi_trace(priv, UDBG3, "(ENOSPC) in resume_unicast_buffered_frames:: hip slots are full \n");
+ break;
+ }
+ if (staInfo && (staInfo->currentPeerState == CSR_WIFI_ROUTER_CTRL_PEER_CONNECTED_ACTIVE)) {
+ while((( TRUE == hipslotFree[3] ) && (buffered_pkt=dequeue_tx_data_pdu(priv, &staInfo->mgtFrames)))) {
+ buffered_pkt->transmissionControl &=
+ ~(TRANSMISSION_CONTROL_TRIGGER_MASK|TRANSMISSION_CONTROL_EOSP_MASK);
+ if((r=frame_and_send_queued_pdu(priv,buffered_pkt,staInfo,0,FALSE)) == -ENOSPC) {
+ unifi_trace(priv, UDBG3, "(ENOSPC) in resume_unicast_buffered_frames:: hip slots are full for voice queue\n");
+ /* Enqueue at the head of the queue */
+ spin_lock_irqsave(&priv->tx_q_lock,lock_flags);
+ list_add(&buffered_pkt->q, &staInfo->mgtFrames);
+ spin_unlock_irqrestore(&priv->tx_q_lock,lock_flags);
+ priv->pausedStaHandle[3]=(u8)(staInfo->assignedHandle);
+ hipslotFree[3] = FALSE;
+ break;
+ } else {
+ if(r){
+ unifi_trace (priv, UDBG1, " HIP validation failure : PDU sending failed \n");
+ /* the PDU failed where we can't do any thing so free the storage */
+ unifi_net_data_free(priv, &buffered_pkt->bulkdata);
+ }
+ kfree(buffered_pkt);
+ }
+ }
+
+ for(j=3;j>=0;j--) {
+ if(!hipslotFree[j])
+ continue;
+
+ while((buffered_pkt=dequeue_tx_data_pdu(priv, &staInfo->dataPdu[j]))) {
+ buffered_pkt->transmissionControl &=
+ ~(TRANSMISSION_CONTROL_TRIGGER_MASK|TRANSMISSION_CONTROL_EOSP_MASK);
+ if((r=frame_and_send_queued_pdu(priv,buffered_pkt,staInfo,0,FALSE)) == -ENOSPC) {
+ /* Enqueue at the head of the queue */
+ spin_lock_irqsave(&priv->tx_q_lock,lock_flags);
+ list_add(&buffered_pkt->q, &staInfo->dataPdu[j]);
+ spin_unlock_irqrestore(&priv->tx_q_lock,lock_flags);
+ priv->pausedStaHandle[j]=(u8)(staInfo->assignedHandle);
+ hipslotFree[j]=FALSE;
+ break;
+ } else {
+ if(r){
+ unifi_trace (priv, UDBG1, " HIP validation failure : PDU sending failed \n");
+ /* the PDU failed where we can't do any thing so free the storage */
+ unifi_net_data_free(priv, &buffered_pkt->bulkdata);
+ }
+ kfree(buffered_pkt);
+ }
+ }
+ }
+ }
+ }
+ func_exit();
+}
+void update_eosp_to_head_of_broadcast_list_head(unifi_priv_t *priv,u16 interfaceTag)
+{
+
+ netInterface_priv_t *interfacePriv = priv->interfacePriv[interfaceTag];
+ unsigned long lock_flags;
+ struct list_head *listHead;
+ struct list_head *placeHolder;
+ tx_buffered_packets_t *tx_q_item;
+
+ func_enter();
+ if (interfacePriv->noOfbroadcastPktQueued) {
+
+ /* Update the EOSP to the HEAD of b/c list
+ * beacuse we have received any mgmt packet so it should not hold for long time
+ * peer may time out.
+ */
+ spin_lock_irqsave(&priv->tx_q_lock,lock_flags);
+ list_for_each_safe(listHead, placeHolder, &interfacePriv->genericMulticastOrBroadCastFrames) {
+ tx_q_item = list_entry(listHead, tx_buffered_packets_t, q);
+ tx_q_item->transmissionControl |= TRANSMISSION_CONTROL_EOSP_MASK;
+ tx_q_item->transmissionControl = (tx_q_item->transmissionControl & ~(CSR_NO_CONFIRM_REQUIRED));
+ unifi_trace(priv, UDBG1,"updating eosp for list Head hostTag:= 0x%x ",tx_q_item->hostTag);
+ break;
+ }
+ spin_unlock_irqrestore(&priv->tx_q_lock,lock_flags);
+ }
+ func_exit();
+}
+
+/*
+ * ---------------------------------------------------------------------------
+ * resume_suspended_uapsd
+ *
+ * This function takes care processing packets of Unscheduled Service Period,
+ * which been suspended earlier due to DTIM/HIP ENOSPC scenarios
+ *
+ * Arguments:
+ * priv Pointer to device private context struct
+ * interfaceTag For which resume should happen
+ * ---------------------------------------------------------------------------
+ */
+void resume_suspended_uapsd(unifi_priv_t* priv,u16 interfaceTag)
+{
+
+ u8 startIndex;
+ CsrWifiRouterCtrlStaInfo_t * staInfo = NULL;
+ unsigned long lock_flags;
+
+ unifi_trace(priv, UDBG2, "++resume_suspended_uapsd: \n");
+ for(startIndex= 0; startIndex < UNIFI_MAX_CONNECTIONS;startIndex++) {
+ staInfo = CsrWifiRouterCtrlGetStationRecordFromHandle(priv,startIndex,interfaceTag);
+
+ if(!staInfo || !staInfo->wmmOrQosEnabled) {
+ continue;
+ } else if((staInfo->currentPeerState == CSR_WIFI_ROUTER_CTRL_PEER_CONNECTED_POWER_SAVE)
+ &&staInfo->uapsdActive && staInfo->uspSuspend) {
+ /* U-APSD Still active & previously suspended either ENOSPC of FH queues OR
+ * due to DTIM activity
+ */
+ uf_handle_uspframes_delivery(priv, staInfo, interfaceTag);
+ } else {
+ unifi_trace(priv, UDBG2, "resume_suspended_uapsd: PS state=%x, uapsdActive?=%x, suspend?=%x\n",
+ staInfo->currentPeerState, staInfo->uapsdActive, staInfo->uspSuspend);
+ if (staInfo->currentPeerState == CSR_WIFI_ROUTER_CTRL_PEER_CONNECTED_ACTIVE)
+ {
+ spin_lock_irqsave(&priv->staRecord_lock,lock_flags);
+ staInfo->uapsdActive = FALSE;
+ staInfo->uspSuspend = FALSE;
+ spin_unlock_irqrestore(&priv->staRecord_lock,lock_flags);
+ }
+ }
+ }
+ unifi_trace(priv, UDBG2, "--resume_suspended_uapsd:\n");
+}
+
+#endif
diff --git a/drivers/staging/csr/unifi_priv.h b/drivers/staging/csr/unifi_priv.h
new file mode 100644
index 000000000000..6d6b46191a1a
--- /dev/null
+++ b/drivers/staging/csr/unifi_priv.h
@@ -0,0 +1,1177 @@
+/*
+ *****************************************************************************
+ *
+ * FILE : unifi_priv.h
+ *
+ * PURPOSE : Private header file for unifi driver.
+ *
+ * UDI = UniFi Debug Interface
+ *
+ * Copyright (C) 2005-2009 by Cambridge Silicon Radio Ltd.
+ *
+ * Refer to LICENSE.txt included with this source code for details on
+ * the license terms.
+ *
+ *****************************************************************************
+ */
+#ifndef __LINUX_UNIFI_PRIV_H__
+#define __LINUX_UNIFI_PRIV_H__ 1
+
+#include <linux/version.h>
+#include <linux/module.h>
+#include <linux/string.h>
+#include <linux/errno.h>
+#include <linux/kernel.h>
+#include <linux/wait.h>
+#include <linux/sched.h>
+#include <linux/delay.h>
+#include <linux/netdevice.h>
+#include <linux/wireless.h>
+#include <linux/cdev.h>
+#include <linux/kthread.h>
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,19)
+#include <linux/freezer.h>
+#endif
+
+#ifdef CSR_WIFI_SUPPORT_MMC_DRIVER
+#include <linux/mmc/core.h>
+#include <linux/mmc/card.h>
+#include <linux/mmc/host.h>
+#include <linux/mmc/sdio_func.h>
+#include <linux/mmc/sdio_ids.h>
+#include <linux/mmc/sdio.h>
+#endif /* CSR_WIFI_SUPPORT_MMC_DRIVER */
+
+#include <linux/fs.h>
+
+#ifdef ANDROID_BUILD
+#include <linux/wakelock.h>
+#endif
+
+#include "csr_wifi_hip_unifi.h"
+#include "csr_wifi_hip_unifi_udi.h"
+#include "csr_wifi_router_lib.h"
+#include "unifiio.h"
+#ifndef CSR_WIFI_HIP_TA_DISABLE
+#include "csr_wifi_vif_utils.h"
+#endif
+
+/* Define the unifi_priv_t before include the unifi_native.h */
+struct unifi_priv;
+typedef struct unifi_priv unifi_priv_t;
+#ifdef CSR_SUPPORT_WEXT_AP
+struct CsrWifiSmeApConfig;
+typedef struct CsrWifiSmeApConfig CsrWifiSmeApConfig_t;
+#endif
+#ifdef CSR_SUPPORT_WEXT
+#include "unifi_wext.h"
+#endif
+
+#ifdef ANDROID_BUILD
+extern struct wake_lock unifi_sdio_wake_lock;
+#endif
+
+#include "unifi_clients.h"
+
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20)
+#include <linux/workqueue.h>
+
+#undef INIT_WORK
+#define INIT_WORK(_work, _func) \
+ do { \
+ INIT_LIST_HEAD(&(_work)->entry); \
+ (_work)->pending = 0; \
+ PREPARE_WORK((_work), (_func), (_work)); \
+ init_timer(&(_work)->timer); \
+ } while(0)
+
+#endif /* Linux kernel < 2.6.20 */
+
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27)
+#define UF_NETIF_TX_WAKE_ALL_QUEUES(_netdev) netif_tx_wake_all_queues(_netdev)
+#define UF_NETIF_TX_START_ALL_QUEUES(_netdev) netif_tx_start_all_queues(_netdev)
+#define UF_NETIF_TX_STOP_ALL_QUEUES(_netdev) netif_tx_stop_all_queues(_netdev)
+#else
+#define UF_NETIF_TX_WAKE_ALL_QUEUES(_netdev) netif_wake_queue(_netdev)
+#define UF_NETIF_TX_START_ALL_QUEUES(_netdev) netif_start_queue(_netdev)
+#define UF_NETIF_TX_STOP_ALL_QUEUES(_netdev) netif_stop_queue(_netdev)
+#endif /* Linux kernel >= 2.6.27 */
+
+
+#ifdef CSR_NATIVE_LINUX
+#include "sme_native/unifi_native.h"
+#else
+#include "unifi_sme.h"
+#endif
+
+/* The device major number to use when registering the udi driver */
+#define UNIFI_NAME "unifi"
+/*
+ * MAX_UNIFI_DEVS defines the maximum number of UniFi devices that can be present.
+ * This number should be set to the number of SDIO slots supported by the SDIO
+ * host controller on the platform.
+ * Note: If MAX_UNIFI_DEVS value changes, fw_init[] needs to be corrected in drv.c
+ */
+#define MAX_UNIFI_DEVS 2
+
+/* 802.11 Mac header offsets */
+#define MAC_HEADER_SIZE 24
+#define QOS_CONTROL_HEADER_SIZE 2
+#define HT_CONTROL_HEADER_SIZE 4
+#define QOS_DATA 0x8
+#define QOS_DATA_NULL 0xc
+#define DATA_NULL 0x04
+#define FRAME_CONTROL_ORDER_BIT 0x8000
+#define FRAME_CONTROL_TYPE_FIELD_OFFSET 2
+#define FRAME_CONTROL_SUBTYPE_FIELD_OFFSET 4
+#define IEEE802_11_FRAMETYPE_DATA 0x02
+#define IEEE802_11_FRAMETYPE_CONTROL 0x01
+#define IEEE802_11_FRAMETYPE_MANAGEMENT 0x00
+#define IEEE802_11_FRAMETYPE_RESERVED 0x03
+
+/* octet offset from start of mac header for certain fields */
+#define IEEE802_11_ADDR3_OFFSET 16
+#define IEEE802_11_SEQUENCE_CONTROL_OFFSET 22
+#define IEEE802_11_MAX_DATA_LEN 2304
+
+/* frame control (FC) masks, for frame control as 16 bit integer */
+#define IEEE802_11_FC_TO_DS_MASK 0x100
+#define IEEE802_11_FC_FROM_DS_MASK 0x200
+#define IEEE802_11_FC_MOREDATA_MASK 0x2000
+#define IEEE802_11_FC_PROTECTED_MASK 0x4000
+#define IEEE80211_FC_ORDER_MASK 0x8000
+#define IEEE80211_FC_SUBTYPE_MASK 0x00f0
+#define IEEE80211_FC_TYPE_MASK 0x000c
+#define IEEE80211_FC_PROTO_VERSION_MASK 0x0003
+
+/* selected type and subtype combinations as in 7.1.3.1 table 1
+ For frame control as 16 bit integer, or for ls octet
+*/
+#define IEEE802_11_FC_TYPE_DATA 0x08
+#define IEEE802_11_FC_TYPE_NULL 0x48
+#define IEEE802_11_FC_TYPE_QOS_NULL 0xc8
+#define IEEE802_11_FC_TYPE_QOS_DATA 0x88
+
+#define IEEE802_11_FC_TYPE_DATA_SUBTYPE_RESERVED 0x0D
+
+/* qos control (QC) masks for qos control as 16 bit integer, or for ls octet */
+#define IEEE802_11_QC_TID_MASK 0x0f
+#define IEEE802_11_QC_A_MSDU_PRESENT 0x80
+
+#if (defined(CSR_WIFI_SECURITY_WAPI_ENABLE) && defined(CSR_WIFI_SECURITY_WAPI_QOSCTRL_MIC_WORKAROUND))
+#define IEEE802_11_QC_NON_TID_BITS_MASK 0xFFF0
+#endif
+
+#define CSR_WIFI_EAPOL_M4_HOST_TAG 0x50000000
+#define IEEE802_11_DATA_FRAME_MAC_HEADER_SIZE 36
+#define MAX_ACCESS_CATOGORY 4
+
+/* Time in us to check for inactivity of stations 5 mins */
+#define INACTIVITY_CHECK_INTERVAL 300000000
+/* Time in us before a station is flagged as inactive */
+#define MAX_INACTIVITY_INTERVAL 300000000
+
+
+/* Define for maximum BA session */
+#define MAX_SUPPORTED_BA_SESSIONS_TX 1
+#define MAX_SUPPORTED_BA_SESSIONS_RX 4
+
+#define MAX_BA_WIND_SIZE 64
+#define MAC_HEADER_ADDR1_OFFSET 4
+#define MAC_HEADER_ADDR2_OFFSET 10
+
+/* Define for age (in us) value for frames in MPDU reorder buffer */
+#define CSR_WIFI_BA_MPDU_FRAME_AGE_TIMEOUT 30000 /* 30 milli seconds */
+
+/* This macro used in prepare_and_add_macheader*/
+#define ADDRESS_ONE_OFFSET 20
+
+/* Defines for STA inactivity detection */
+#define STA_INACTIVE_DETECTION_TRIGGER_THRESHOLD 1 /* in number of stations */
+#define STA_INACTIVE_DETECTION_TIMER_INTERVAL 30 /* in seconds */
+#define STA_INACTIVE_TIMEOUT_VAL 120*1000*1000 /* 120 seconds */
+
+/* Test for modes requiring AP firmware patch */
+#define CSR_WIFI_HIP_IS_AP_FW(mode) ((((mode) == CSR_WIFI_ROUTER_CTRL_MODE_AP) || \
+ ((mode) == CSR_WIFI_ROUTER_CTRL_MODE_P2PGO)) ? TRUE : FALSE)
+
+/* Defines used in beacon filtering in case of P2P */
+#define CSR_WIFI_P2P_WILDCARD_SSID_LENGTH 0x7
+#define CSR_WIFI_80211_FRAME_SUBTYPE_BEACON 0x8
+#define CSR_WIFI_BEACON_FIXED_LENGTH 12
+#define CSR_WIFI_FRAME_SUBTYPE_BIT_OFFSET 4
+#define CSR_WIFI_80211_FRAME_SUBTYPE_BIT_MASK ((u8)(0xF << CSR_WIFI_FRAME_SUBTYPE_BIT_OFFSET))
+
+#define CSR_WIFI_80211_GET_FRAME_SUBTYPE(frameBuffer) \
+ ((u8)(((u8 *)frameBuffer)[0] & CSR_WIFI_80211_FRAME_SUBTYPE_BIT_MASK) >> CSR_WIFI_FRAME_SUBTYPE_BIT_OFFSET)
+
+/* For M4 request received via netdev*/
+
+typedef u8 CsrWifiPacketType;
+#define CSR_WIFI_UNICAST_PDU ((CsrWifiPacketType) 0x00)
+#define CSR_WIFI_MULTICAST_PDU ((CsrWifiPacketType) 0x1)
+#define CSR_WIFI_BROADCAST_PDU ((CsrWifiPacketType) 0x2)
+
+#define PRIO_TO_NICE(prio) ((prio) - MAX_RT_PRIO - 20)
+
+/* Module parameter variables */
+extern int buswidth;
+extern int sdio_clock;
+extern int use_5g;
+extern int disable_hw_reset;
+extern int disable_power_control;
+extern int enable_wol;
+extern int sme_debug;
+extern int fw_init[MAX_UNIFI_DEVS];
+extern int tl_80211d;
+extern int sdio_byte_mode;
+extern int sdio_block_size;
+extern int coredump_max;
+extern int run_bh_once;
+extern int bh_priority;
+#ifdef CSR_WIFI_HIP_DEBUG_OFFLINE
+extern int log_hip_signals;
+#endif
+
+struct dlpriv {
+ const unsigned char *dl_data;
+ int dl_len;
+ void *fw_desc;
+};
+
+
+struct uf_thread {
+
+ struct task_struct *thread_task;
+
+ /* wait_queue for waking the unifi_thread kernel thread */
+ wait_queue_head_t wakeup_q;
+ unsigned int wakeup_flag;
+
+ /*
+ * Use it to block the I/O thread when
+ * an error occurs or UniFi is reinitialised.
+ */
+ int block_thread;
+
+ char name[16];
+ int prio;
+};
+
+/*
+ * Link list to hold the received packets for the period the port
+ * remains closed.
+ */
+typedef struct rx_buffered_packets {
+ /* List link structure */
+ struct list_head q;
+ /* Packet to indicate when the port reopens */
+ struct sk_buff *skb;
+ /* Bulkdata to free in case the port closes and need to discard the packet */
+ bulk_data_param_t bulkdata;
+ /* The source address of the packet */
+ CsrWifiMacAddress sa;
+ /* The destination address of the packet */
+ CsrWifiMacAddress da;
+ /* Corresponding signal */
+ CSR_SIGNAL signal;
+} rx_buffered_packets_t;
+
+
+typedef u8 CsrWifiAcPowersaveMode;
+#define CSR_WIFI_AC_TRIGGER_ONLY_ENABLED 0x00
+#define CSR_WIFI_AC_DELIVERY_ONLY_ENABLE 0X01
+#define CSR_WIFI_AC_TRIGGER_AND_DELIVERY_ENABLED 0X03
+#define CSR_WIFI_AC_LEGACY_POWER_SAVE 0X02
+
+
+#define IS_DELIVERY_ENABLED(mode) (mode & CSR_WIFI_AC_DELIVERY_ONLY_ENABLE)? 1: 0
+#define IS_DELIVERY_AND_TRIGGER_ENABLED(mode) ((mode & CSR_WIFI_AC_DELIVERY_ONLY_ENABLE)||(mode & CSR_WIFI_AC_TRIGGER_AND_DELIVERY_ENABLED))? 1: 0
+#define IS_DTIM_ACTIVE(flag,hostTag) ((flag == TRUE || hostTag != INVALID_HOST_TAG))
+#define INVALID_HOST_TAG 0xFFFFFFFF
+#define UNIFI_TRAFFIC_Q_CONTENTION UNIFI_TRAFFIC_Q_BE
+
+
+
+
+/* Queue to be used for contention priority */
+
+/*
+ * Link list to hold the tx packets for the period the peer
+ * powersave/free slots in unifi
+ */
+typedef struct tx_buffered_packets {
+ /* List link structure */
+ struct list_head q;
+ u16 interfaceTag;
+ CSR_CLIENT_TAG hostTag;
+ CSR_PROCESS_ID leSenderProcessId;
+ CSR_TRANSMISSION_CONTROL transmissionControl;
+ CSR_RATE rate;
+ /* Bulkdata to free in case the port closes and need to discard the packet */
+ bulk_data_desc_t bulkdata;
+ /* The source address of the packet */
+ CsrWifiMacAddress peerMacAddress;
+ CSR_PRIORITY priority;
+} tx_buffered_packets_t;
+
+/* station record has this data structure */
+typedef struct CsrWifiRouterCtrlStaInfo_t {
+
+ /* Sme sends these parameters */
+ CsrWifiMacAddress peerMacAddress;
+ u32 assignedHandle;
+ u8 wmmOrQosEnabled;
+ CsrWifiAcPowersaveMode powersaveMode[MAX_ACCESS_CATOGORY];
+ u16 maxSpLength;
+ u8 uapsdActive;
+ u16 noOfSpFramesSent;
+
+ /* Router/Driver database */
+#ifdef CSR_SUPPORT_SME
+ unifi_port_cfg_t *peerControlledPort;
+ unifi_port_cfg_t *peerUnControlledPort;
+
+ /* Inactivity feature parameters */
+ struct netInterface_priv *interfacePriv;
+ struct work_struct send_disconnected_ind_task;
+ u8 activity_flag;
+ u16 listenIntervalInTus;
+ CSR_CLIENT_TAG nullDataHostTag;
+
+ /* Activity timestamps for the station */
+ CsrTime lastActivity;
+
+ /* during m/c transmission sp suspended */
+ u8 uspSuspend;
+ CSR_PRIORITY triggerFramePriority;
+#endif
+ CsrWifiRouterCtrlPeerStatus currentPeerState;
+ struct list_head dataPdu[MAX_ACCESS_CATOGORY];
+ struct list_head mgtFrames;
+ u8 spStatus;
+ u8 prevFrmType;
+ u8 prevFrmAccessCatogory;
+ u8 protection;
+ u16 aid;
+ u8 txSuspend;
+ u8 timSet;
+ /* Dont change the value of below macro for SET & RESET */
+#define CSR_WIFI_TIM_RESET 0
+#define CSR_WIFI_TIM_SET 1
+#define CSR_WIFI_TIM_RESETTING 2
+#define CSR_WIFI_TIM_SETTING 3
+
+ u8 timRequestPendingFlag;
+ u8 updateTimReqQueued;
+ u16 noOfPktQueued;
+}CsrWifiRouterCtrlStaInfo_t;
+
+#ifdef CSR_SUPPORT_WEXT_AP
+struct CsrWifiSmeApConfig {
+ CsrWifiSsid ssid;
+ u16 channel;
+ CsrWifiNmeApCredentials credentials;
+ u8 max_connections;
+ u8 if_index;
+};
+#endif
+
+#ifdef CSR_WIFI_RX_PATH_SPLIT
+/* This is a test code and may be removed later*/
+#define CSR_WIFI_RX_SIGNAL_BUFFER_SIZE (60+1)
+
+typedef struct
+{
+ u8 *bufptr; /* Signal Primitive */
+ bulk_data_param_t data_ptrs; /* Bulk Data pointers */
+ u16 sig_len;
+}rx_buff_struct_t;
+
+typedef struct
+{
+ u8 writePointer; /**< write pointer */
+ u8 readPointer; /**< read pointer */
+ u8 size; /**< size of circular buffer */
+ rx_buff_struct_t rx_buff[CSR_WIFI_RX_SIGNAL_BUFFER_SIZE]; /**< Element of ciruclar buffer */
+} rxCircularBuffer_t;
+
+void rx_wq_handler(struct work_struct *work);
+#endif
+
+struct unifi_priv {
+
+ card_t *card;
+ CsrSdioFunction *sdio;
+
+ /* Index into Unifi_instances[] for this device. */
+ int instance;
+ /* Reference count for this instance */
+ int ref_count;
+
+ /* Firmware images */
+ struct dlpriv fw_sta;
+ struct dlpriv fw_conv; /* used for conversion of production test image */
+
+ /* Char device related structures */
+ struct cdev unifi_cdev;
+ struct cdev unifiudi_cdev;
+ struct device *unifi_device;
+
+ /* Which wireless interface to use (1 - 2.4GHz, 2 - 5GHz) */
+ CSR_IFINTERFACE if_index;
+
+ /* For multiple interface support */
+ struct net_device *netdev[CSR_WIFI_NUM_INTERFACES];
+ struct netInterface_priv *interfacePriv[CSR_WIFI_NUM_INTERFACES];
+
+ u8 totalInterfaceCount;
+
+ int prev_queue;
+
+ /* Name of node under /proc */
+ char proc_entry_name[64];
+
+ /*
+ * Flags:
+ * drop_unencrypted
+ * - Not used?
+ * netdev_registered
+ * - whether the netdev has been registered.
+ */
+ unsigned int drop_unencrypted : 1;
+
+ /* Our list of unifi linux clients. */
+ ul_client_t ul_clients[MAX_UDI_CLIENTS];
+
+ /* Mutex to protect using the logging hook after UDI client is gone */
+ struct semaphore udi_logging_mutex;
+ /* Pointer to the ul_clients[] array */
+ ul_client_t *logging_client;
+
+ /* A ul_client_t* used to send the netdev related MIB requests. */
+ ul_client_t *netdev_client;
+
+ /* The SME ul_client_t pointer. */
+ ul_client_t *sme_cli;
+
+ /* The AMP ul_client_t pointer. */
+ ul_client_t *amp_client;
+
+ /*
+ * Semaphore for locking the top-half to one user process.
+ * This is necessary to prevent multiple processes calling driver
+ * operations. This can happen because the network driver entry points
+ * can be called from multiple processes.
+ */
+#ifdef USE_DRIVER_LOCK
+ struct semaphore lock;
+#endif /* USE_DRIVER_LOCK */
+
+ /* Flag to say that an operation was aborted */
+ int io_aborted;
+
+ struct uf_thread bh_thread;
+
+#define UNIFI_INIT_NONE 0x00
+#define UNIFI_INIT_IN_PROGRESS 0x01
+#define UNIFI_INIT_FW_DOWNLOADED 0x02
+#define UNIFI_INIT_COMPLETED 0x04
+ unsigned char init_progress;
+
+ int sme_is_present;
+
+ /* The WMM features that UniFi uses in the current BSS */
+ unsigned int sta_wmm_capabilities;
+
+ /* Debug only */
+ char last_debug_string[256];
+ unsigned short last_debug_word16[16];
+
+#ifdef CSR_SUPPORT_SME
+ /* lock to protect the tx queues list */
+ spinlock_t tx_q_lock;
+ u8 allPeerDozing;
+ u8 pausedStaHandle[MAX_ACCESS_CATOGORY];
+ /* Max packet the driver can queue, irrespective of interface number */
+ u16 noOfPktQueuedInDriver;
+#define CSR_WIFI_DRIVER_SUPPORT_FOR_MAX_PKT_QUEUEING 512
+#define CSR_WIFI_DRIVER_MAX_PKT_QUEUING_THRESHOLD_PER_PEER 64
+#define CSR_WIFI_DRIVER_MINIMUM_BROADCAST_PKT_THRESHOLD 3
+
+ u8 routerBufferEnable[MAX_ACCESS_CATOGORY];
+ /* lock to protect stainfo members and priv members*/
+ spinlock_t staRecord_lock;
+#endif
+#ifdef CSR_NATIVE_LINUX
+#ifdef CSR_SUPPORT_WEXT
+ /* wireless config */
+ struct wext_config wext_conf;
+#endif
+
+ /* Mutex to protect the MLME blocking requests */
+ struct semaphore mlme_blocking_mutex;
+
+ /* The ul_client that provides the blocking API for WEXT calls */
+ ul_client_t *wext_client;
+
+#endif /* CSR_NATIVE_LINUX */
+
+#ifdef CSR_SUPPORT_SME
+ wait_queue_head_t sme_request_wq;
+ /* Semaphore to protect the SME blocking requests */
+ struct semaphore sme_sem;
+ /* Structure to hold the SME blocking requests data*/
+ sme_reply_t sme_reply;
+
+ /* Structure to hold a traffic protocol indication */
+ struct ta_ind {
+ struct work_struct task;
+ CsrWifiRouterCtrlTrafficPacketType packet_type;
+ CsrWifiRouterCtrlProtocolDirection direction;
+ CsrWifiMacAddress src_addr;
+ int in_use;
+ } ta_ind_work;
+
+ struct ta_sample_ind {
+ struct work_struct task;
+ CsrWifiRouterCtrlTrafficStats stats;
+ int in_use;
+ } ta_sample_ind_work;
+
+ __be32 sta_ip_address;
+ CsrWifiRouterCtrlSmeVersions sme_versions;
+
+ /*
+ * Flag to reflect state of unifi_sys_wifi_on_*() progress.
+ * This indicates whether we are in an "wifi on" state when we are
+ * allowed to indication errors with unifi_mgt_wifi_off_ind()
+ */
+ enum {
+ wifi_on_unspecified = -1,
+ wifi_on_in_progress = 0,
+ wifi_on_done = 1,
+ } wifi_on_state;
+
+ /* Userspace TaskId for the SME Set when a wifi on req is received */
+ CsrSchedQid CSR_WIFI_SME_IFACEQUEUE;
+
+ struct work_struct multicast_list_task;
+ /*
+ * The SME installs filters to ask for specific MA-UNITDATA.req
+ * to be passed to different SME components.
+ */
+#define MAX_MA_UNIDATA_IND_FILTERS 8
+ sme_ma_unidata_ind_filter_t sme_unidata_ind_filters[MAX_MA_UNIDATA_IND_FILTERS];
+
+/* UNIFI_CFG related parameters */
+ uf_cfg_bcast_packet_filter_t packet_filters;
+ unsigned char *filter_tclas_ies;
+ /* The structure that holds all the connection configuration. */
+ CsrWifiSmeConnectionConfig connection_config;
+#ifdef CSR_SUPPORT_WEXT
+
+ int ignore_bssid_join;
+ struct iw_statistics wext_wireless_stats;
+
+ /* The MIB and MAC address files contents, read from userspace */
+ CsrWifiSmeDataBlock mib_data;
+ CsrWifiMacAddress sta_mac_address;
+
+ int wep_tx_key_index;
+ wep_key_t wep_keys[NUM_WEPKEYS];
+
+
+#ifdef CSR_SUPPORT_WEXT_AP
+ CsrWifiSmeApMacConfig ap_mac_config;
+ CsrWifiNmeApConfig group_sec_config;
+ CsrWifiSmeApConfig_t ap_config;
+#endif
+ struct work_struct sme_config_task;
+
+#endif /* CSR_SUPPORT_WEXT */
+
+#endif /* CSR_SUPPORT_SME */
+
+#ifdef CSR_SME_USERSPACE
+ void *smepriv;
+#endif /* CSR_SME_USERSPACE */
+
+ card_info_t card_info;
+
+ /* Mutex to protect unifi_send_signal() */
+ spinlock_t send_signal_lock;
+
+
+ /*
+ * The workqueue to offload the TA run
+ * and the multicast addresses list set
+ */
+ struct workqueue_struct *unifi_workqueue;
+
+ unsigned char *mib_cfm_buffer;
+ unsigned int mib_cfm_buffer_length;
+
+ int ptest_mode; /* Set when in production test mode */
+ int coredump_mode; /* Set when SME has requested a coredump */
+ u8 wol_suspend; /* Set when suspending with UniFi powered */
+
+#define UF_UNCONTROLLED_PORT_Q 0
+#define UF_CONTROLLED_PORT_Q 1
+
+ /* Semaphore to protect the rx queues list */
+ struct semaphore rx_q_sem;
+
+ /* Spinlock to protect M4 data */
+ spinlock_t m4_lock;
+ /* Mutex to protect BA RX data */
+ struct semaphore ba_mutex;
+
+#if (defined(CSR_WIFI_SECURITY_WAPI_ENABLE) && defined(CSR_WIFI_SECURITY_WAPI_SW_ENCRYPTION))
+ /* Spinlock to protect the WAPI data */
+ spinlock_t wapi_lock;
+#endif
+
+#ifndef ALLOW_Q_PAUSE
+ /* Array to indicate if a particular Tx queue is paused, this may not be
+ * required in a multiqueue implementation since we can directly stop kernel
+ * queues */
+ u8 tx_q_paused_flag[UNIFI_TRAFFIC_Q_MAX];
+#endif
+
+#ifdef CSR_WIFI_RX_PATH_SPLIT
+ struct workqueue_struct *rx_workqueue;
+ struct work_struct rx_work_struct;
+ rxCircularBuffer_t rxSignalBuffer;
+
+#endif
+
+ u32 rxTcpThroughput;
+ u32 txTcpThroughput;
+ u32 rxUdpThroughput;
+ u32 txUdpThroughput;
+
+#ifdef CSR_WIFI_SECURITY_WAPI_ENABLE
+ /*Set if multicast KeyID = 1*/
+ u8 wapi_multicast_filter;
+ /*Set if unicast KeyID = 1*/
+ u8 wapi_unicast_filter;
+ u8 wapi_unicast_queued_pkt_filter;
+#ifdef CSR_WIFI_SECURITY_WAPI_QOSCTRL_MIC_WORKAROUND
+ u8 isWapiConnection;
+#endif
+#endif
+
+#ifdef CSR_WIFI_SPLIT_PATCH
+ CsrWifiRouterCtrlModeSetReq pending_mode_set;
+#endif
+
+ u8 cmanrTestMode;
+ CSR_RATE cmanrTestModeTransmitRate;
+
+};
+
+typedef struct {
+ u16 queue_length[4];
+ u8 os_queue_paused;
+} unifi_OsQosInfo;
+
+
+typedef struct {
+ u8 active;
+ bulk_data_param_t bulkdata;
+ CSR_SIGNAL signal;
+ u16 sn;
+ CsrTime recv_time;
+} frame_desc_struct;
+
+typedef struct {
+ frame_desc_struct *buffer;
+ u16 wind_size;
+ u16 occupied_slots;
+ struct timer_list timer;
+ u16 timeout;
+ u16 expected_sn;
+ u16 start_sn;
+ u8 trigger_ba_after_ssn;
+ struct netInterface_priv *interfacePriv;
+ u16 tID;
+ CsrWifiMacAddress macAddress;
+ struct work_struct send_ba_err_task;
+} ba_session_rx_struct;
+
+
+typedef struct {
+ struct netInterface_priv *interfacePriv;
+ u16 tID;
+ CsrWifiMacAddress macAddress;
+} ba_session_tx_struct;
+
+typedef struct netInterface_priv
+{
+ u16 InterfaceTag;
+ struct unifi_priv *privPtr;
+ ba_session_tx_struct *ba_session_tx[MAX_SUPPORTED_BA_SESSIONS_TX];
+ ba_session_rx_struct *ba_session_rx[MAX_SUPPORTED_BA_SESSIONS_RX];
+ frame_desc_struct ba_complete[MAX_BA_WIND_SIZE];
+ u8 ba_complete_index;
+ u8 queueEnabled[UNIFI_NO_OF_TX_QS];
+ struct work_struct send_m4_ready_task;
+#ifdef CSR_WIFI_SECURITY_WAPI_ENABLE
+ struct work_struct send_pkt_to_encrypt;
+#endif
+ struct net_device_stats stats;
+ u8 interfaceMode;
+ u8 protect;
+ CsrWifiMacAddress bssid;
+ /*
+ * Flag to reflect state of CONNECTED indication signal.
+ * This indicates whether we are "joined" an Access Point (i.e. have
+ * nominated an AP and are receiving beacons) but give no indication
+ * of whether we are authenticated and/or associated.
+ */
+ enum {
+ UnifiConnectedUnknown = -1,
+ UnifiNotConnected = 0,
+ UnifiConnected = 1,
+ } connected;
+#ifdef CSR_SUPPORT_WEXT
+ /* Tracks when we are waiting for a netdevice state change callback */
+ u8 wait_netdev_change;
+ /* True if we have successfully registered for netdev callbacks */
+ u8 netdev_callback_registered;
+#endif /* CSR_SUPPORT_WEXT */
+ unsigned int netdev_registered;
+#define UNIFI_MAX_MULTICAST_ADDRESSES 10
+ /* The multicast addresses list that the thread needs to set. */
+ u8 mc_list[UNIFI_MAX_MULTICAST_ADDRESSES*ETH_ALEN];
+ /* The multicast addresses count that the thread needs to set. */
+ int mc_list_count;
+ u32 tag;
+#ifdef CSR_SUPPORT_SME
+ /* (un)controlled port configuration */
+ unifi_port_config_t controlled_data_port;
+ unifi_port_config_t uncontrolled_data_port;
+
+ /* station record maintenance related data structures */
+ u8 num_stations_joined;
+ CsrWifiRouterCtrlStaInfo_t *(staInfo)[UNIFI_MAX_CONNECTIONS];
+ struct list_head genericMgtFrames;
+ struct list_head genericMulticastOrBroadCastFrames;
+ struct list_head genericMulticastOrBroadCastMgtFrames;
+
+ /* Timer for detecting station inactivity */
+ struct timer_list sta_activity_check_timer;
+ u8 sta_activity_check_enabled;
+
+ /* Timestamp when the last inactivity check was done */
+ CsrTime last_inactivity_check;
+
+ /*number of multicast or borad cast packets queued*/
+ u16 noOfbroadcastPktQueued;
+#endif
+ /* A list to hold the buffered uncontrolled port packets */
+ struct list_head rx_uncontrolled_list;
+ /* A list to hold the buffered controlled port packets */
+ struct list_head rx_controlled_list;
+ /* Buffered M4 signal to take care of WPA race condition */
+ CSR_SIGNAL m4_signal;
+ bulk_data_desc_t m4_bulk_data;
+
+#if (defined(CSR_WIFI_SECURITY_WAPI_ENABLE) && defined(CSR_WIFI_SECURITY_WAPI_SW_ENCRYPTION))
+ /* Buffered WAPI Unicast MA Packet Request for encryption in Sme */
+ CSR_SIGNAL wapi_unicast_ma_pkt_sig;
+ bulk_data_desc_t wapi_unicast_bulk_data;
+#endif
+
+ /* This should be removed and m4_hostTag should be used for checking*/
+ u8 m4_sent;
+ CSR_CLIENT_TAG m4_hostTag;
+ u8 dtimActive;
+ u8 intraBssEnabled;
+ u32 multicastPduHostTag; /* Used to set the tim after getting
+ a confirm for it */
+ u8 bcTimSet;
+ u8 bcTimSetReqPendingFlag;
+ u8 bcTimSetReqQueued;
+} netInterface_priv_t;
+
+#ifndef ALLOW_Q_PAUSE
+#define net_is_tx_q_paused(priv, q) (priv->tx_q_paused_flag[q])
+#define net_tx_q_unpause(priv, q) (priv->tx_q_paused_flag[q] = 0)
+#define net_tx_q_pause(priv, q) (priv->tx_q_paused_flag[q] = 1)
+#endif
+
+#ifdef CSR_SUPPORT_SME
+#define routerStartBuffering(priv,queue) priv->routerBufferEnable[(queue)] = TRUE;
+#define routerStopBuffering(priv,queue) priv->routerBufferEnable[(queue)] = FALSE;
+#define isRouterBufferEnabled(priv,queue) priv->routerBufferEnable[(queue)]
+#endif
+
+#ifdef USE_DRIVER_LOCK
+#define LOCK_DRIVER(_p) down_interruptible(&(_p)->lock)
+#define UNLOCK_DRIVER(_p) up(&(_p)->lock)
+#else
+#define LOCK_DRIVER(_p) (void)(_p); /* as nothing */
+#define UNLOCK_DRIVER(_p) (void)(_p); /* as nothing */
+#endif /* USE_DRIVER_LOCK */
+
+s32 CsrHipResultToStatus(CsrResult csrResult);
+
+
+/*
+ * SDIO related functions and callbacks
+ */
+int uf_sdio_load(void);
+void uf_sdio_unload(void);
+unifi_priv_t *uf_find_instance(int inst);
+int uf_find_priv(unifi_priv_t *priv);
+int uf_find_netdev_priv(netInterface_priv_t *priv);
+unifi_priv_t *uf_get_instance(int inst);
+void uf_put_instance(int inst);
+int csr_sdio_linux_install_irq(CsrSdioFunction *sdio);
+int csr_sdio_linux_remove_irq(CsrSdioFunction *sdio);
+
+void uf_add_os_device(int bus_id, struct device *os_device);
+void uf_remove_os_device(int bus_id);
+
+
+
+/*
+ * Claim/release SDIO
+ *
+ * For multifunction cards, we cannot grub the SDIO lock around the unifi_bh()
+ * as this prevents other functions using SDIO.
+ * Since some of CSR SDIO API is used regardless of trying to lock unifi_bh()
+ * we have followed this scheme:
+ * 1. If a function needs protection only when CSR_WIFI_SINGLE_FUNCTION is defined
+ * then we call CsrSdioClaim/CsrSdioRelease().
+ * 2. If a function needs protection only when CSR_WIFI_SINGLE_FUNCTION is not defined
+ * then we call _sdio_claim_host/_sdio_claim_host(). Use of this should be restricted
+ * to the SDIO glue layer only (e.g. sdio_mmc.c).
+ * 3. If a function needs protection, regardless of the CSR_WIFI_SINGLE_FUNCTION
+ * then we call directly the sdio_claim_host/sdio_release_host().
+ * Use of this must be restricted to the SDIO glue layer only (e.g. sdio_mmc.c).
+ *
+ * Note: The _func and function pointers are _not_ the same.
+ * The former is the (struct sdio_func*) context, which restricts the use to the SDIO glue layer.
+ * The latter is the (CsrSdioFunction*) context, which allows calls from all layers.
+ */
+
+#ifdef CSR_WIFI_SUPPORT_MMC_DRIVER
+
+#ifdef CSR_WIFI_SINGLE_FUNCTION
+#define CsrSdioClaim(function) sdio_claim_host((function)->priv);
+#define CsrSdioRelease(function) sdio_release_host((function)->priv);
+
+#define _sdio_claim_host(_func)
+#define _sdio_release_host(_func)
+
+#else
+#define CsrSdioClaim(function)
+#define CsrSdioRelease(function)
+
+#define _sdio_claim_host(_func) sdio_claim_host(_func)
+#define _sdio_release_host(_func) sdio_release_host(_func)
+
+#endif /* CSR_WIFI_SINGLE_FUNCTION */
+
+#else
+#define _sdio_claim_host(_func)
+#define _sdio_release_host(_func)
+
+#define CsrSdioClaim(function)
+#define CsrSdioRelease(function)
+
+#endif /* CSR_WIFI_SUPPORT_MMC_DRIVER */
+
+
+/*
+ * Functions to allocate and free an ethernet device.
+ */
+unifi_priv_t *uf_alloc_netdevice(CsrSdioFunction *sdio_dev, int bus_id);
+int uf_free_netdevice(unifi_priv_t *priv);
+
+/* Allocating function for other interfaces */
+u8 uf_alloc_netdevice_for_other_interfaces(unifi_priv_t *priv, u16 interfaceTag);
+
+/*
+ * Firmware download related functions.
+ */
+int uf_run_unifihelper(unifi_priv_t *priv);
+int uf_request_firmware_files(unifi_priv_t *priv, int is_fw);
+int uf_release_firmware_files(unifi_priv_t *priv);
+int uf_release_firmware(unifi_priv_t *priv, struct dlpriv *to_free);
+
+/*
+ * Functions to create and delete the device nodes.
+ */
+int uf_create_device_nodes(unifi_priv_t *priv, int bus_id);
+void uf_destroy_device_nodes(unifi_priv_t *priv);
+
+/*
+ * Upper Edge Initialisation functions
+ */
+int uf_init_bh(unifi_priv_t *priv);
+int uf_init_hw(unifi_priv_t *priv);
+
+/* Thread related helper functions */
+int uf_start_thread(unifi_priv_t *priv, struct uf_thread *thread, int (*func)(void *));
+void uf_stop_thread(unifi_priv_t *priv, struct uf_thread *thread);
+void uf_wait_for_thread_to_stop(unifi_priv_t *priv, struct uf_thread *thread);
+
+
+/*
+ * Unifi Linux functions
+ */
+void ul_init_clients(unifi_priv_t *priv);
+
+/* Configuration flags */
+#define CLI_USING_WIRE_FORMAT 0x0002
+#define CLI_SME_USERSPACE 0x0020
+ul_client_t *ul_register_client(unifi_priv_t *priv,
+ unsigned int configuration,
+ udi_event_t udi_event_clbk);
+int ul_deregister_client(ul_client_t *pcli);
+
+int ul_send_signal_unpacked(unifi_priv_t *priv,
+ CSR_SIGNAL *sigptr,
+ bulk_data_param_t *bulkdata);
+int ul_send_signal_raw(unifi_priv_t *priv,
+ unsigned char *sigptr, int siglen,
+ bulk_data_param_t *bulkdata);
+
+void ul_log_config_ind(unifi_priv_t *priv, u8 *conf_param, int len);
+
+
+/*
+ * Data plane operations
+ */
+/*
+ * data_tx.c
+ */
+int uf_verify_m4(unifi_priv_t *priv, const unsigned char *packet,
+ unsigned int length);
+
+#ifdef CSR_SUPPORT_SME
+u8 uf_check_broadcast_bssid(unifi_priv_t *priv, const bulk_data_param_t *bulkdata);
+u8 uf_process_pm_bit_for_peer(unifi_priv_t * priv, CsrWifiRouterCtrlStaInfo_t * srcStaInfo,u8 pmBit,u16 interfaceTag);
+void uf_process_ps_poll(unifi_priv_t *priv,u8* sa,u8* da,u8 pmBit,u16 interfaceTag);
+int uf_ap_process_data_pdu(unifi_priv_t *priv, struct sk_buff *skb,
+ struct ethhdr *ehdr, CsrWifiRouterCtrlStaInfo_t * srcStaInfo,
+ const CSR_SIGNAL *signal,
+ bulk_data_param_t *bulkdata,
+ u8 macHeaderLengthInBytes);
+u8 uf_is_more_data_for_non_delivery_ac(CsrWifiRouterCtrlStaInfo_t *staRecord);
+void uf_process_wmm_deliver_ac_uapsd ( unifi_priv_t * priv,
+ CsrWifiRouterCtrlStaInfo_t * srcStaInfo,
+ u16 qosControl,
+ u16 interfaceTag);
+
+void uf_send_buffered_data_from_ac(unifi_priv_t *priv, CsrWifiRouterCtrlStaInfo_t * staInfo, u8 queue, struct list_head *txList);
+void uf_send_buffered_data_from_delivery_ac(unifi_priv_t *priv, CsrWifiRouterCtrlStaInfo_t * staInfo, u8 queue, struct list_head *txList);
+
+void uf_continue_uapsd(unifi_priv_t *priv, CsrWifiRouterCtrlStaInfo_t * staInfo);
+void uf_send_qos_null(unifi_priv_t * priv,u16 interfaceTag, const u8 *da,CSR_PRIORITY priority,CsrWifiRouterCtrlStaInfo_t * srcStaInfo);
+void uf_send_nulldata(unifi_priv_t * priv,u16 interfaceTag, const u8 *da,CSR_PRIORITY priority,CsrWifiRouterCtrlStaInfo_t * srcStaInfo);
+
+
+
+#endif
+CsrResult uf_process_ma_packet_req(unifi_priv_t *priv, u8 *peerMacAddress, CSR_CLIENT_TAG hostTag, u16 interfaceTag, CSR_TRANSMISSION_CONTROL transmissionControl, CSR_RATE TransmitRate, CSR_PRIORITY priority, CSR_PROCESS_ID senderId, bulk_data_param_t *bulkdata);
+void uf_process_ma_vif_availibility_ind(unifi_priv_t *priv,u8 *sigdata, u32 siglen);
+#ifdef CSR_SUPPORT_SME
+void uf_send_buffered_frames(unifi_priv_t *priv,unifi_TrafficQueue queue);
+int uf_process_station_records_for_sending_data(unifi_priv_t *priv,u16 interfaceTag,
+ CsrWifiRouterCtrlStaInfo_t *srcStaInfo,
+ CsrWifiRouterCtrlStaInfo_t *dstStaInfo);
+void uf_prepare_send_cfm_list_for_queued_pkts(unifi_priv_t * priv,
+ struct list_head *frames_need_cfm_list,
+ struct list_head * list);
+void send_auto_ma_packet_confirm(unifi_priv_t *priv,
+ netInterface_priv_t *interfacePriv,
+ struct list_head *buffered_frames_list);
+void uf_flush_list(unifi_priv_t * priv, struct list_head * list);
+tx_buffered_packets_t *dequeue_tx_data_pdu(unifi_priv_t *priv, struct list_head *txList);
+void resume_unicast_buffered_frames(unifi_priv_t *priv, u16 interfaceTag);
+void update_eosp_to_head_of_broadcast_list_head(unifi_priv_t *priv,u16 interfaceTag);
+void resume_suspended_uapsd(unifi_priv_t* priv,u16 interfaceTag);
+#endif
+/*
+ * netdev.c
+ */
+
+#ifndef P80211_OUI_LEN
+#define P80211_OUI_LEN 3
+#endif
+typedef struct {
+ u8 dsap; /* always 0xAA */
+ u8 ssap; /* always 0xAA */
+ u8 ctrl; /* always 0x03 */
+ u8 oui[P80211_OUI_LEN]; /* organizational universal id */
+ u16 protocol;
+} __attribute__ ((packed)) llc_snap_hdr_t;
+int skb_add_llc_snap(struct net_device *dev, struct sk_buff *skb, int proto);
+int skb_80211_to_ether(unifi_priv_t *priv, struct sk_buff *skb,
+ const unsigned char *daddr, const unsigned char *saddr,
+ const CSR_SIGNAL *signal,
+ bulk_data_param_t *bulkdata);
+
+const char *result_code_str(int result);
+
+
+/* prepares & appends the Mac header for the payload */
+int prepare_and_add_macheader(unifi_priv_t *priv,
+ struct sk_buff *skb,
+ struct sk_buff *newSkb,
+ CSR_PRIORITY priority,
+ bulk_data_param_t *bulkdata,
+ u16 interfaceTag,
+ const u8 *daddr,
+ const u8 *saddr,
+ u8 protection);
+CSR_PRIORITY
+get_packet_priority(unifi_priv_t *priv, struct sk_buff *skb, const struct ethhdr *ehdr, netInterface_priv_t *interfacePriv);
+
+void
+unifi_frame_ma_packet_req(unifi_priv_t *priv, CSR_PRIORITY priority,
+ CSR_RATE TransmitRate, CSR_CLIENT_TAG hostTag,
+ u16 interfaceTag, CSR_TRANSMISSION_CONTROL transmissionControl,
+ CSR_PROCESS_ID leSenderProcessId, u8 *peerMacAddress,
+ CSR_SIGNAL *signal);
+
+
+/* Pack the LSB to include station handle & status of tim set */
+#define CSR_WIFI_PACK_SENDER_ID_LSB_FOR_TIM_REQ(handle, timState) ((handle << 2) | timState)
+/* get the station record handle from the sender ID */
+#define CSR_WIFI_GET_STATION_HANDLE_FROM_RECEIVER_ID(receiverProcessId) (u8) ((receiverProcessId & 0xff) >> 2)
+/* get the timSet status from the sender ID */
+#define CSR_WIFI_GET_TIMSET_STATE_FROM_RECEIVER_ID(receiverProcessId) (u8) (receiverProcessId & 0x03)
+
+/* handle is 6 bits to accomodate in senderId LSB (only 64 station can be associated) */
+#define CSR_WIFI_BROADCAST_OR_MULTICAST_HANDLE 0x3F
+
+void update_tim(unifi_priv_t * priv, u16 aid, u8 setTim, u16 interfaceTag, u32 handle);
+void uf_handle_tim_cfm(unifi_priv_t *priv, CSR_MLME_SET_TIM_CONFIRM *cfm, u16 senderProcessId);
+
+/* Clear the Peer station Record, in case of wifioff/unexpected card removal */
+void CsrWifiRouterCtrlInterfaceReset(unifi_priv_t *priv, u16 interfaceTag);
+
+void scroll_ba_window(unifi_priv_t *priv,
+ netInterface_priv_t *interfacePriv,
+ ba_session_rx_struct *ba_session,
+ u16 sn);
+
+u8 blockack_session_stop(unifi_priv_t *priv,
+ u16 interfaceTag,
+ CsrWifiRouterCtrlBlockAckRole role,
+ u16 tID,
+ CsrWifiMacAddress macAddress);
+#ifdef CSR_SUPPORT_SME
+/* Fetch the protection information from interface Mode */
+s8 uf_get_protection_bit_from_interfacemode(unifi_priv_t *priv, u16 interfaceTag, const u8 *daddr);
+#endif
+
+/* Fetch the station record handler from data base for matching Mac address */
+#ifdef CSR_SUPPORT_SME
+CsrWifiRouterCtrlStaInfo_t *CsrWifiRouterCtrlGetStationRecordFromPeerMacAddress(unifi_priv_t *priv,
+ const u8 *peerMacAddress,
+ u16 interfaceTag);
+
+/* Fetch the station record handler from data base for matching handle */
+CsrWifiRouterCtrlStaInfo_t * CsrWifiRouterCtrlGetStationRecordFromHandle(unifi_priv_t *priv,
+ u32 handle,
+ u16 interfaceTag);
+
+void uf_update_sta_activity(unifi_priv_t *priv, u16 interfaceTag, const u8 *peerMacAddress);
+void uf_process_ma_pkt_cfm_for_ap(unifi_priv_t *priv,u16 interfaceTag, const CSR_MA_PACKET_CONFIRM *pkt_cfm);
+#endif
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,28)
+int uf_install_qdisc(struct net_device *dev);
+#endif
+
+void uf_resume_data_plane(unifi_priv_t *priv, int queue,
+ CsrWifiMacAddress peer_address,
+ u16 interfaceTag);
+void uf_free_pending_rx_packets(unifi_priv_t *priv, int queue,
+ CsrWifiMacAddress peer_address,u16 interfaceTag);
+
+int uf_register_netdev(unifi_priv_t *priv, int numOfInterface);
+void uf_unregister_netdev(unifi_priv_t *priv);
+
+void uf_net_get_name(struct net_device *dev, char *name, int len);
+
+void uf_send_queue_info(unifi_priv_t *priv);
+u16 uf_get_vif_identifier(CsrWifiRouterCtrlMode mode, u16 tag);
+
+void uf_process_rx_pending_queue(unifi_priv_t *priv, int queue,
+ CsrWifiMacAddress source_address,
+ int indicate, u16 interfaceTag);
+
+#ifdef CSR_WIFI_HIP_DEBUG_OFFLINE
+int uf_register_hip_offline_debug(unifi_priv_t *priv);
+int uf_unregister_hip_offline_debug(unifi_priv_t *priv);
+#endif
+
+/*
+ * inet.c
+ */
+void uf_register_inet_notifier(void);
+void uf_unregister_inet_notifier(void);
+
+
+/*
+ * Suspend / Resume handlers
+ */
+void unifi_resume(void *ospriv);
+void unifi_suspend(void *ospriv);
+
+
+#define QOS_CAPABILITY_WMM_ENABLED 0x0001
+#define QOS_CAPABILITY_WMM_UAPSD 0x0002
+#define QOS_CAPABILITY_ACM_BE_ENABLED 0x0010
+#define QOS_CAPABILITY_ACM_BK_ENABLED 0x0020
+#define QOS_CAPABILITY_ACM_VI_ENABLED 0x0040
+#define QOS_CAPABILITY_ACM_VO_ENABLED 0x0080
+#define QOS_CAPABILITY_TS_BE_ENABLED 0x0100
+#define QOS_CAPABILITY_TS_BK_ENABLED 0x0200
+#define QOS_CAPABILITY_TS_VI_ENABLED 0x0400
+#define QOS_CAPABILITY_TS_VO_ENABLED 0x0800
+
+
+/* EAPOL PDUS */
+#ifndef ETH_P_PAE
+#define ETH_P_PAE 0x888e
+#endif
+#ifndef ETH_P_WAI
+#define ETH_P_WAI 0x88b4
+#endif
+/*
+ * unifi_dbg.c
+ */
+void debug_string_indication(unifi_priv_t *priv,
+ const unsigned char *extra,
+ unsigned int extralen);
+void debug_word16_indication(unifi_priv_t *priv, const CSR_SIGNAL *sigptr);
+void debug_generic_indication(unifi_priv_t *priv, const CSR_SIGNAL *sigptr);
+
+
+/*
+ * putest.c
+ */
+int unifi_putest_start(unifi_priv_t *priv, unsigned char *arg);
+int unifi_putest_cmd52_block_read(unifi_priv_t *priv, unsigned char *arg);
+int unifi_putest_stop(unifi_priv_t *priv, unsigned char *arg);
+int unifi_putest_set_sdio_clock(unifi_priv_t *priv, unsigned char *arg);
+int unifi_putest_cmd52_read(unifi_priv_t *priv, unsigned char *arg);
+int unifi_putest_coredump_prepare(unifi_priv_t *priv, unsigned char *arg);
+int unifi_putest_cmd52_write(unifi_priv_t *priv, unsigned char *arg);
+int unifi_putest_gp_read16(unifi_priv_t *priv, unsigned char *arg);
+int unifi_putest_gp_write16(unifi_priv_t *priv, unsigned char *arg);
+
+int unifi_putest_dl_fw(unifi_priv_t *priv, unsigned char *arg);
+int unifi_putest_dl_fw_buff(unifi_priv_t *priv, unsigned char *arg);
+
+#endif /* __LINUX_UNIFI_PRIV_H__ */
diff --git a/drivers/staging/csr/unifi_sme.c b/drivers/staging/csr/unifi_sme.c
new file mode 100644
index 000000000000..ff639d47d07b
--- /dev/null
+++ b/drivers/staging/csr/unifi_sme.c
@@ -0,0 +1,1239 @@
+/*
+ * ***************************************************************************
+ * FILE: unifi_sme.c
+ *
+ * PURPOSE: SME related functions.
+ *
+ * Copyright (C) 2007-2009 by Cambridge Silicon Radio Ltd.
+ *
+ * Refer to LICENSE.txt included with this source code for details on
+ * the license terms.
+ *
+ * ***************************************************************************
+ */
+
+#include "unifi_priv.h"
+#include "csr_wifi_hip_unifi.h"
+#include "csr_wifi_hip_conversions.h"
+
+
+
+
+ int
+convert_sme_error(CsrResult error)
+{
+ switch (error) {
+ case CSR_RESULT_SUCCESS:
+ return 0;
+ case CSR_RESULT_FAILURE:
+ case CSR_WIFI_RESULT_NOT_FOUND:
+ case CSR_WIFI_RESULT_TIMED_OUT:
+ case CSR_WIFI_RESULT_CANCELLED:
+ case CSR_WIFI_RESULT_UNAVAILABLE:
+ return -EIO;
+ case CSR_WIFI_RESULT_NO_ROOM:
+ return -EBUSY;
+ case CSR_WIFI_RESULT_INVALID_PARAMETER:
+ return -EINVAL;
+ case CSR_WIFI_RESULT_UNSUPPORTED:
+ return -EOPNOTSUPP;
+ default:
+ return -EIO;
+ }
+}
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * sme_log_event
+ *
+ * Callback function to be registered as the SME event callback.
+ * Copies the signal content into a new udi_log_t struct and adds
+ * it to the read queue for the SME client.
+ *
+ * Arguments:
+ * arg This is the value given to unifi_add_udi_hook, in
+ * this case a pointer to the client instance.
+ * signal Pointer to the received signal.
+ * signal_len Size of the signal structure in bytes.
+ * bulkdata Pointers to any associated bulk data.
+ * dir Direction of the signal. Zero means from host,
+ * non-zero means to host.
+ *
+ * Returns:
+ * None.
+ * ---------------------------------------------------------------------------
+ */
+ void
+sme_log_event(ul_client_t *pcli,
+ const u8 *signal, int signal_len,
+ const bulk_data_param_t *bulkdata,
+ int dir)
+{
+ unifi_priv_t *priv;
+ CSR_SIGNAL unpacked_signal;
+ CsrWifiSmeDataBlock mlmeCommand;
+ CsrWifiSmeDataBlock dataref1;
+ CsrWifiSmeDataBlock dataref2;
+ CsrResult result = CSR_RESULT_SUCCESS;
+ int r;
+
+ func_enter();
+ /* Just a sanity check */
+ if ((signal == NULL) || (signal_len <= 0)) {
+ func_exit();
+ return;
+ }
+
+ priv = uf_find_instance(pcli->instance);
+ if (!priv) {
+ unifi_error(priv, "sme_log_event: invalid priv\n");
+ func_exit();
+ return;
+ }
+
+ if (priv->smepriv == NULL) {
+ unifi_error(priv, "sme_log_event: invalid smepriv\n");
+ func_exit();
+ return;
+ }
+
+ unifi_trace(priv, UDBG3,
+ "sme_log_event: Process signal 0x%.4X\n",
+ CSR_GET_UINT16_FROM_LITTLE_ENDIAN(signal));
+
+
+ /* If the signal is known, then do any filtering required, otherwise it pass it to the SME. */
+ r = read_unpack_signal(signal, &unpacked_signal);
+ if (r == CSR_RESULT_SUCCESS) {
+ if ((unpacked_signal.SignalPrimitiveHeader.SignalId == CSR_DEBUG_STRING_INDICATION_ID) ||
+ (unpacked_signal.SignalPrimitiveHeader.SignalId == CSR_DEBUG_WORD16_INDICATION_ID))
+ {
+ func_exit();
+ return;
+ }
+ if (unpacked_signal.SignalPrimitiveHeader.SignalId == CSR_MA_PACKET_INDICATION_ID)
+ {
+ u16 frmCtrl;
+ u8 unicastPdu = TRUE;
+ u8 *macHdrLocation;
+ u8 *raddr = NULL, *taddr = NULL;
+ CsrWifiMacAddress peerMacAddress;
+ /* Check if we need to send CsrWifiRouterCtrlMicFailureInd*/
+ CSR_MA_PACKET_INDICATION *ind = &unpacked_signal.u.MaPacketIndication;
+
+ macHdrLocation = (u8 *) bulkdata->d[0].os_data_ptr;
+ /* Fetch the frame control value from mac header */
+ frmCtrl = CSR_GET_UINT16_FROM_LITTLE_ENDIAN(macHdrLocation);
+
+ /* Point to the addresses */
+ raddr = macHdrLocation + MAC_HEADER_ADDR1_OFFSET;
+ taddr = macHdrLocation + MAC_HEADER_ADDR2_OFFSET;
+
+ memcpy(peerMacAddress.a, taddr, ETH_ALEN);
+
+ if(ind->ReceptionStatus == CSR_MICHAEL_MIC_ERROR)
+ {
+ if (*raddr & 0x1)
+ unicastPdu = FALSE;
+
+ CsrWifiRouterCtrlMicFailureIndSend (priv->CSR_WIFI_SME_IFACEQUEUE, 0,
+ (ind->VirtualInterfaceIdentifier & 0xff),peerMacAddress,
+ unicastPdu);
+ return;
+ }
+ else
+ {
+ if(ind->ReceptionStatus == CSR_RX_SUCCESS)
+ {
+ u8 pmBit = (frmCtrl & 0x1000)?0x01:0x00;
+ u16 interfaceTag = (ind->VirtualInterfaceIdentifier & 0xff);
+ CsrWifiRouterCtrlStaInfo_t *srcStaInfo = CsrWifiRouterCtrlGetStationRecordFromPeerMacAddress(priv,taddr,interfaceTag);
+ if((srcStaInfo != NULL) && (uf_check_broadcast_bssid(priv, bulkdata)== FALSE))
+ {
+ uf_process_pm_bit_for_peer(priv,srcStaInfo,pmBit,interfaceTag);
+
+ /* Update station last activity flag */
+ srcStaInfo->activity_flag = TRUE;
+ }
+ }
+ }
+ }
+
+ if (unpacked_signal.SignalPrimitiveHeader.SignalId == CSR_MA_PACKET_CONFIRM_ID)
+ {
+ CSR_MA_PACKET_CONFIRM *cfm = &unpacked_signal.u.MaPacketConfirm;
+ u16 interfaceTag = (cfm->VirtualInterfaceIdentifier & 0xff);
+ netInterface_priv_t *interfacePriv;
+ CSR_MA_PACKET_REQUEST *req;
+ CsrWifiMacAddress peerMacAddress;
+
+ if (interfaceTag >= CSR_WIFI_NUM_INTERFACES)
+ {
+ unifi_error(priv, "Bad MA_PACKET_CONFIRM interfaceTag %d\n", interfaceTag);
+ func_exit();
+ return;
+ }
+
+ unifi_trace(priv,UDBG1,"MA-PACKET Confirm (%x, %x)\n", cfm->HostTag, cfm->TransmissionStatus);
+
+ interfacePriv = priv->interfacePriv[interfaceTag];
+#ifdef CSR_SUPPORT_SME
+ if(interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_AP ||
+ interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_P2PGO) {
+
+ if(cfm->HostTag == interfacePriv->multicastPduHostTag){
+ uf_process_ma_pkt_cfm_for_ap(priv ,interfaceTag, cfm);
+ }
+ }
+#endif
+
+ req = &interfacePriv->m4_signal.u.MaPacketRequest;
+
+ if(cfm->HostTag & 0x80000000)
+ {
+ if (cfm->TransmissionStatus != CSR_TX_SUCCESSFUL)
+ {
+ result = CSR_RESULT_FAILURE;
+ }
+#ifdef CSR_SUPPORT_SME
+ memcpy(peerMacAddress.a, req->Ra.x, ETH_ALEN);
+ /* Check if this is a confirm for EAPOL M4 frame and we need to send transmistted ind*/
+ if (interfacePriv->m4_sent && (cfm->HostTag == interfacePriv->m4_hostTag))
+ {
+ unifi_trace(priv, UDBG1, "%s: Sending M4 Transmit CFM\n", __FUNCTION__);
+ CsrWifiRouterCtrlM4TransmittedIndSend(priv->CSR_WIFI_SME_IFACEQUEUE, 0,
+ interfaceTag,
+ peerMacAddress,
+ result);
+ interfacePriv->m4_sent = FALSE;
+ interfacePriv->m4_hostTag = 0xffffffff;
+ }
+#endif
+ /* If EAPOL was requested via router APIs then send cfm else ignore*/
+ if((cfm->HostTag & 0x80000000) != CSR_WIFI_EAPOL_M4_HOST_TAG) {
+ CsrWifiRouterMaPacketCfmSend((u16)signal[2],
+ cfm->VirtualInterfaceIdentifier,
+ result,
+ (cfm->HostTag & 0x3fffffff), cfm->Rate);
+ } else {
+ unifi_trace(priv, UDBG1, "%s: M4 received from netdevice\n", __FUNCTION__);
+ }
+ func_exit();
+ return;
+ }
+ }
+ }
+
+ mlmeCommand.length = signal_len;
+ mlmeCommand.data = (u8*)signal;
+
+ dataref1.length = bulkdata->d[0].data_length;
+ if (dataref1.length > 0) {
+ dataref1.data = (u8 *) bulkdata->d[0].os_data_ptr;
+ } else
+ {
+ dataref1.data = NULL;
+ }
+
+ dataref2.length = bulkdata->d[1].data_length;
+ if (dataref2.length > 0) {
+ dataref2.data = (u8 *) bulkdata->d[1].os_data_ptr;
+ } else
+ {
+ dataref2.data = NULL;
+ }
+
+ CsrWifiRouterCtrlHipIndSend(priv->CSR_WIFI_SME_IFACEQUEUE, mlmeCommand.length, mlmeCommand.data,
+ dataref1.length, dataref1.data,
+ dataref2.length, dataref2.data);
+
+ func_exit();
+} /* sme_log_event() */
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * uf_sme_port_state
+ *
+ * Return the state of the controlled port.
+ *
+ * Arguments:
+ * priv Pointer to device private context struct
+ * address Pointer to the destination for tx or sender for rx address
+ * queue Controlled or uncontrolled queue
+ *
+ * Returns:
+ * An unifi_ControlledPortAction value.
+ * ---------------------------------------------------------------------------
+ */
+CsrWifiRouterCtrlPortAction
+uf_sme_port_state(unifi_priv_t *priv, unsigned char *address, int queue, u16 interfaceTag)
+{
+ int i;
+ unifi_port_config_t *port;
+ netInterface_priv_t *interfacePriv;
+
+ if (interfaceTag >= CSR_WIFI_NUM_INTERFACES) {
+ unifi_error(priv, "uf_sme_port_state: bad interfaceTag\n");
+ return CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_CLOSED_DISCARD;
+ }
+
+ interfacePriv = priv->interfacePriv[interfaceTag];
+
+ if (queue == UF_CONTROLLED_PORT_Q) {
+ port = &interfacePriv->controlled_data_port;
+ } else {
+ port = &interfacePriv->uncontrolled_data_port;
+ }
+
+ if (!port->entries_in_use) {
+ unifi_trace(priv, UDBG5, "No port configurations, return Discard.\n");
+ return CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_CLOSED_DISCARD;
+ }
+
+ /* If the port configuration is common for all destinations, return it. */
+ if (port->overide_action == UF_DATA_PORT_OVERIDE) {
+ unifi_trace(priv, UDBG5, "Single port configuration (%d).\n",
+ port->port_cfg[0].port_action);
+ return port->port_cfg[0].port_action;
+ }
+
+ unifi_trace(priv, UDBG5, "Multiple (%d) port configurations.\n", port->entries_in_use);
+
+ /* If multiple configurations exist.. */
+ for (i = 0; i < UNIFI_MAX_CONNECTIONS; i++) {
+ /* .. go through the list and match the destination address. */
+ if (port->port_cfg[i].in_use &&
+ memcmp(address, port->port_cfg[i].mac_address.a, ETH_ALEN) == 0) {
+ /* Return the desired action. */
+ return port->port_cfg[i].port_action;
+ }
+ }
+
+ /* Could not find any information, return Open. */
+ unifi_trace(priv, UDBG5, "port configuration not found, return Open.\n");
+ return CSR_WIFI_ROUTER_CTRL_PORT_ACTION_8021X_PORT_OPEN;
+} /* uf_sme_port_state() */
+
+/*
+ * ---------------------------------------------------------------------------
+ * uf_sme_port_config_handle
+ *
+ * Return the port config handle of the controlled/uncontrolled port.
+ *
+ * Arguments:
+ * priv Pointer to device private context struct
+ * address Pointer to the destination for tx or sender for rx address
+ * queue Controlled or uncontrolled queue
+ *
+ * Returns:
+ * An unifi_port_cfg_t* .
+ * ---------------------------------------------------------------------------
+ */
+unifi_port_cfg_t*
+uf_sme_port_config_handle(unifi_priv_t *priv, unsigned char *address, int queue, u16 interfaceTag)
+{
+ int i;
+ unifi_port_config_t *port;
+ netInterface_priv_t *interfacePriv = priv->interfacePriv[interfaceTag];
+
+ if (interfaceTag >= CSR_WIFI_NUM_INTERFACES) {
+ unifi_error(priv, "uf_sme_port_config_handle: bad interfaceTag\n");
+ return NULL;
+ }
+
+ if (queue == UF_CONTROLLED_PORT_Q) {
+ port = &interfacePriv->controlled_data_port;
+ } else {
+ port = &interfacePriv->uncontrolled_data_port;
+ }
+
+ if (!port->entries_in_use) {
+ unifi_trace(priv, UDBG5, "No port configurations, return Discard.\n");
+ return NULL;
+ }
+
+ /* If the port configuration is common for all destinations, return it. */
+ if (port->overide_action == UF_DATA_PORT_OVERIDE) {
+ unifi_trace(priv, UDBG5, "Single port configuration (%d).\n",
+ port->port_cfg[0].port_action);
+ if (address) {
+ unifi_trace(priv, UDBG5, "addr[0] = %x, addr[1] = %x, addr[2] = %x, addr[3] = %x\n", address[0], address[1], address[2], address[3]);
+ }
+ return &port->port_cfg[0];
+ }
+
+ unifi_trace(priv, UDBG5, "Multiple port configurations.\n");
+
+ /* If multiple configurations exist.. */
+ for (i = 0; i < UNIFI_MAX_CONNECTIONS; i++) {
+ /* .. go through the list and match the destination address. */
+ if (port->port_cfg[i].in_use &&
+ memcmp(address, port->port_cfg[i].mac_address.a, ETH_ALEN) == 0) {
+ /* Return the desired action. */
+ return &port->port_cfg[i];
+ }
+ }
+
+ /* Could not find any information, return Open. */
+ unifi_trace(priv, UDBG5, "port configuration not found, returning NULL (debug).\n");
+ return NULL;
+} /* uf_sme_port_config_handle */
+
+void
+uf_multicast_list_wq(struct work_struct *work)
+{
+ unifi_priv_t *priv = container_of(work, unifi_priv_t,
+ multicast_list_task);
+ int i;
+ u16 interfaceTag = 0;
+ CsrWifiMacAddress* multicast_address_list = NULL;
+ int mc_count;
+ u8 *mc_list;
+ netInterface_priv_t *interfacePriv = priv->interfacePriv[interfaceTag];
+
+ if (interfaceTag >= CSR_WIFI_NUM_INTERFACES) {
+ unifi_error(priv, "uf_multicast_list_wq: bad interfaceTag\n");
+ return;
+ }
+
+ unifi_trace(priv, UDBG5,
+ "uf_multicast_list_wq: list count = %d\n",
+ interfacePriv->mc_list_count);
+
+ /* Flush the current list */
+ CsrWifiRouterCtrlMulticastAddressIndSend(priv->CSR_WIFI_SME_IFACEQUEUE,0, interfaceTag, CSR_WIFI_SME_LIST_ACTION_FLUSH, 0, NULL);
+
+ mc_count = interfacePriv->mc_list_count;
+ mc_list = interfacePriv->mc_list;
+ /*
+ * Allocate a new list, need to free it later
+ * in unifi_mgt_multicast_address_cfm().
+ */
+ multicast_address_list = kmalloc(mc_count * sizeof(CsrWifiMacAddress), GFP_KERNEL);
+
+ if (multicast_address_list == NULL) {
+ return;
+ }
+
+ for (i = 0; i < mc_count; i++) {
+ memcpy(multicast_address_list[i].a, mc_list, ETH_ALEN);
+ mc_list += ETH_ALEN;
+ }
+
+ if (priv->smepriv == NULL) {
+ kfree(multicast_address_list);
+ return;
+ }
+
+ CsrWifiRouterCtrlMulticastAddressIndSend(priv->CSR_WIFI_SME_IFACEQUEUE,0,
+ interfaceTag,
+ CSR_WIFI_SME_LIST_ACTION_ADD,
+ mc_count, multicast_address_list);
+
+ /* The SME will take a copy of the addreses*/
+ kfree(multicast_address_list);
+}
+
+
+int unifi_cfg_power(unifi_priv_t *priv, unsigned char *arg)
+{
+ unifi_cfg_power_t cfg_power;
+ int rc;
+ int wol;
+
+ if (get_user(cfg_power, (unifi_cfg_power_t*)(((unifi_cfg_command_t*)arg) + 1))) {
+ unifi_error(priv, "UNIFI_CFG: Failed to get the argument\n");
+ return -EFAULT;
+ }
+
+ switch (cfg_power) {
+ case UNIFI_CFG_POWER_OFF:
+ priv->wol_suspend = (enable_wol == UNIFI_WOL_OFF) ? FALSE : TRUE;
+ rc = sme_sys_suspend(priv);
+ if (rc) {
+ return rc;
+ }
+ break;
+ case UNIFI_CFG_POWER_ON:
+ wol = priv->wol_suspend;
+ rc = sme_sys_resume(priv);
+ if (rc) {
+ return rc;
+ }
+ if (wol) {
+ /* Kick the BH to ensure pending transfers are handled when
+ * a suspend happened with card powered.
+ */
+ unifi_send_signal(priv->card, NULL, 0, NULL);
+ }
+ break;
+ default:
+ unifi_error(priv, "WIFI POWER: Unknown value.\n");
+ return -EINVAL;
+ }
+
+ return 0;
+}
+
+
+int unifi_cfg_power_save(unifi_priv_t *priv, unsigned char *arg)
+{
+ unifi_cfg_powersave_t cfg_power_save;
+ CsrWifiSmePowerConfig powerConfig;
+ int rc;
+
+ if (get_user(cfg_power_save, (unifi_cfg_powersave_t*)(((unifi_cfg_command_t*)arg) + 1))) {
+ unifi_error(priv, "UNIFI_CFG: Failed to get the argument\n");
+ return -EFAULT;
+ }
+
+ /* Get the coex info from the SME */
+ rc = sme_mgt_power_config_get(priv, &powerConfig);
+ if (rc) {
+ unifi_error(priv, "UNIFI_CFG: Get unifi_PowerConfigValue failed.\n");
+ return rc;
+ }
+
+ switch (cfg_power_save) {
+ case UNIFI_CFG_POWERSAVE_NONE:
+ powerConfig.powerSaveLevel = CSR_WIFI_SME_POWER_SAVE_LEVEL_LOW;
+ break;
+ case UNIFI_CFG_POWERSAVE_FAST:
+ powerConfig.powerSaveLevel = CSR_WIFI_SME_POWER_SAVE_LEVEL_MED;
+ break;
+ case UNIFI_CFG_POWERSAVE_FULL:
+ powerConfig.powerSaveLevel = CSR_WIFI_SME_POWER_SAVE_LEVEL_HIGH;
+ break;
+ case UNIFI_CFG_POWERSAVE_AUTO:
+ powerConfig.powerSaveLevel = CSR_WIFI_SME_POWER_SAVE_LEVEL_AUTO;
+ break;
+ default:
+ unifi_error(priv, "POWERSAVE: Unknown value.\n");
+ return -EINVAL;
+ }
+
+ rc = sme_mgt_power_config_set(priv, &powerConfig);
+
+ if (rc) {
+ unifi_error(priv, "UNIFI_CFG: Set unifi_PowerConfigValue failed.\n");
+ }
+
+ return rc;
+}
+
+
+int unifi_cfg_power_supply(unifi_priv_t *priv, unsigned char *arg)
+{
+ unifi_cfg_powersupply_t cfg_power_supply;
+ CsrWifiSmeHostConfig hostConfig;
+ int rc;
+
+ if (get_user(cfg_power_supply, (unifi_cfg_powersupply_t*)(((unifi_cfg_command_t*)arg) + 1))) {
+ unifi_error(priv, "UNIFI_CFG: Failed to get the argument\n");
+ return -EFAULT;
+ }
+
+ /* Get the coex info from the SME */
+ rc = sme_mgt_host_config_get(priv, &hostConfig);
+ if (rc) {
+ unifi_error(priv, "UNIFI_CFG: Get unifi_HostConfigValue failed.\n");
+ return rc;
+ }
+
+ switch (cfg_power_supply) {
+ case UNIFI_CFG_POWERSUPPLY_MAINS:
+ hostConfig.powerMode = CSR_WIFI_SME_HOST_POWER_MODE_ACTIVE;
+ break;
+ case UNIFI_CFG_POWERSUPPLY_BATTERIES:
+ hostConfig.powerMode = CSR_WIFI_SME_HOST_POWER_MODE_POWER_SAVE;
+ break;
+ default:
+ unifi_error(priv, "POWERSUPPLY: Unknown value.\n");
+ return -EINVAL;
+ }
+
+ rc = sme_mgt_host_config_set(priv, &hostConfig);
+ if (rc) {
+ unifi_error(priv, "UNIFI_CFG: Set unifi_HostConfigValue failed.\n");
+ }
+
+ return rc;
+}
+
+
+int unifi_cfg_packet_filters(unifi_priv_t *priv, unsigned char *arg)
+{
+ unsigned char *tclas_buffer;
+ unsigned int tclas_buffer_length;
+ tclas_t *dhcp_tclas;
+ int rc;
+
+ /* Free any TCLASs previously allocated */
+ if (priv->packet_filters.tclas_ies_length) {
+ kfree(priv->filter_tclas_ies);
+ priv->filter_tclas_ies = NULL;
+ }
+
+ tclas_buffer = ((unsigned char*)arg) + sizeof(unifi_cfg_command_t) + sizeof(unsigned int);
+ if (copy_from_user(&priv->packet_filters, (void*)tclas_buffer,
+ sizeof(uf_cfg_bcast_packet_filter_t))) {
+ unifi_error(priv, "UNIFI_CFG: Failed to get the filter struct\n");
+ return -EFAULT;
+ }
+
+ tclas_buffer_length = priv->packet_filters.tclas_ies_length;
+
+ /* Allocate TCLASs if necessary */
+ if (priv->packet_filters.dhcp_filter) {
+ priv->packet_filters.tclas_ies_length += sizeof(tclas_t);
+ }
+ if (priv->packet_filters.tclas_ies_length > 0) {
+ priv->filter_tclas_ies = kmalloc(priv->packet_filters.tclas_ies_length, GFP_KERNEL);
+ if (priv->filter_tclas_ies == NULL) {
+ return -ENOMEM;
+ }
+ if (tclas_buffer_length) {
+ tclas_buffer += sizeof(uf_cfg_bcast_packet_filter_t) - sizeof(unsigned char*);
+ if (copy_from_user(priv->filter_tclas_ies,
+ tclas_buffer,
+ tclas_buffer_length)) {
+ unifi_error(priv, "UNIFI_CFG: Failed to get the TCLAS buffer\n");
+ return -EFAULT;
+ }
+ }
+ }
+
+ if(priv->packet_filters.dhcp_filter)
+ {
+ /* Append the DHCP tclas IE */
+ dhcp_tclas = (tclas_t*)(priv->filter_tclas_ies + tclas_buffer_length);
+ memset(dhcp_tclas, 0, sizeof(tclas_t));
+ dhcp_tclas->element_id = 14;
+ dhcp_tclas->length = sizeof(tcpip_clsfr_t) + 1;
+ dhcp_tclas->user_priority = 0;
+ dhcp_tclas->tcp_ip_cls_fr.cls_fr_type = 1;
+ dhcp_tclas->tcp_ip_cls_fr.version = 4;
+ ((u8*)(&dhcp_tclas->tcp_ip_cls_fr.source_port))[0] = 0x00;
+ ((u8*)(&dhcp_tclas->tcp_ip_cls_fr.source_port))[1] = 0x44;
+ ((u8*)(&dhcp_tclas->tcp_ip_cls_fr.dest_port))[0] = 0x00;
+ ((u8*)(&dhcp_tclas->tcp_ip_cls_fr.dest_port))[1] = 0x43;
+ dhcp_tclas->tcp_ip_cls_fr.protocol = 0x11;
+ dhcp_tclas->tcp_ip_cls_fr.cls_fr_mask = 0x58; //bits: 3,4,6
+ }
+
+ rc = sme_mgt_packet_filter_set(priv);
+
+ return rc;
+}
+
+
+int unifi_cfg_wmm_qos_info(unifi_priv_t *priv, unsigned char *arg)
+{
+ u8 wmm_qos_info;
+ int rc = 0;
+
+ if (get_user(wmm_qos_info, (u8*)(((unifi_cfg_command_t*)arg) + 1))) {
+ unifi_error(priv, "UNIFI_CFG: Failed to get the argument\n");
+ return -EFAULT;
+ }
+
+ /* Store the value in the connection info */
+ priv->connection_config.wmmQosInfo = wmm_qos_info;
+
+ return rc;
+}
+
+
+int unifi_cfg_wmm_addts(unifi_priv_t *priv, unsigned char *arg)
+{
+ u32 addts_tid;
+ u8 addts_ie_length;
+ u8 *addts_ie;
+ u8 *addts_params;
+ CsrWifiSmeDataBlock tspec;
+ CsrWifiSmeDataBlock tclas;
+ int rc;
+
+ addts_params = (u8*)(((unifi_cfg_command_t*)arg) + 1);
+ if (get_user(addts_tid, (u32*)addts_params)) {
+ unifi_error(priv, "unifi_cfg_wmm_addts: Failed to get the argument\n");
+ return -EFAULT;
+ }
+
+ addts_params += sizeof(u32);
+ if (get_user(addts_ie_length, (u8*)addts_params)) {
+ unifi_error(priv, "unifi_cfg_wmm_addts: Failed to get the argument\n");
+ return -EFAULT;
+ }
+
+ unifi_trace(priv, UDBG4, "addts: tid = 0x%x ie_length = %d\n",
+ addts_tid, addts_ie_length);
+
+ addts_ie = kmalloc(addts_ie_length, GFP_KERNEL);
+ if (addts_ie == NULL) {
+ unifi_error(priv,
+ "unifi_cfg_wmm_addts: Failed to malloc %d bytes for addts_ie buffer\n",
+ addts_ie_length);
+ return -ENOMEM;
+ }
+
+ addts_params += sizeof(u8);
+ rc = copy_from_user(addts_ie, addts_params, addts_ie_length);
+ if (rc) {
+ unifi_error(priv, "unifi_cfg_wmm_addts: Failed to get the addts buffer\n");
+ kfree(addts_ie);
+ return -EFAULT;
+ }
+
+ tspec.data = addts_ie;
+ tspec.length = addts_ie_length;
+ tclas.data = NULL;
+ tclas.length = 0;
+
+ rc = sme_mgt_tspec(priv, CSR_WIFI_SME_LIST_ACTION_ADD, addts_tid,
+ &tspec, &tclas);
+
+ kfree(addts_ie);
+ return rc;
+}
+
+
+int unifi_cfg_wmm_delts(unifi_priv_t *priv, unsigned char *arg)
+{
+ u32 delts_tid;
+ u8 *delts_params;
+ CsrWifiSmeDataBlock tspec;
+ CsrWifiSmeDataBlock tclas;
+ int rc;
+
+ delts_params = (u8*)(((unifi_cfg_command_t*)arg) + 1);
+ if (get_user(delts_tid, (u32*)delts_params)) {
+ unifi_error(priv, "unifi_cfg_wmm_delts: Failed to get the argument\n");
+ return -EFAULT;
+ }
+
+ unifi_trace(priv, UDBG4, "delts: tid = 0x%x\n", delts_tid);
+
+ tspec.data = tclas.data = NULL;
+ tspec.length = tclas.length = 0;
+
+ rc = sme_mgt_tspec(priv, CSR_WIFI_SME_LIST_ACTION_REMOVE, delts_tid,
+ &tspec, &tclas);
+
+ return rc;
+}
+
+int unifi_cfg_strict_draft_n(unifi_priv_t *priv, unsigned char *arg)
+{
+ u8 strict_draft_n;
+ u8 *strict_draft_n_params;
+ int rc;
+
+ CsrWifiSmeStaConfig staConfig;
+ CsrWifiSmeDeviceConfig deviceConfig;
+
+ strict_draft_n_params = (u8*)(((unifi_cfg_command_t*)arg) + 1);
+ if (get_user(strict_draft_n, (u8*)strict_draft_n_params)) {
+ unifi_error(priv, "unifi_cfg_strict_draft_n: Failed to get the argument\n");
+ return -EFAULT;
+ }
+
+ unifi_trace(priv, UDBG4, "strict_draft_n: = %s\n", ((strict_draft_n) ? "yes":"no"));
+
+ rc = sme_mgt_sme_config_get(priv, &staConfig, &deviceConfig);
+
+ if (rc) {
+ unifi_warning(priv, "unifi_cfg_strict_draft_n: Get unifi_SMEConfigValue failed.\n");
+ return -EFAULT;
+ }
+
+ deviceConfig.enableStrictDraftN = strict_draft_n;
+
+ rc = sme_mgt_sme_config_set(priv, &staConfig, &deviceConfig);
+ if (rc) {
+ unifi_warning(priv, "unifi_cfg_strict_draft_n: Set unifi_SMEConfigValue failed.\n");
+ rc = -EFAULT;
+ }
+
+ return rc;
+}
+
+
+int unifi_cfg_enable_okc(unifi_priv_t *priv, unsigned char *arg)
+{
+ u8 enable_okc;
+ u8 *enable_okc_params;
+ int rc;
+
+ CsrWifiSmeStaConfig staConfig;
+ CsrWifiSmeDeviceConfig deviceConfig;
+
+ enable_okc_params = (u8*)(((unifi_cfg_command_t*)arg) + 1);
+ if (get_user(enable_okc, (u8*)enable_okc_params)) {
+ unifi_error(priv, "unifi_cfg_enable_okc: Failed to get the argument\n");
+ return -EFAULT;
+ }
+
+ unifi_trace(priv, UDBG4, "enable_okc: = %s\n", ((enable_okc) ? "yes":"no"));
+
+ rc = sme_mgt_sme_config_get(priv, &staConfig, &deviceConfig);
+ if (rc) {
+ unifi_warning(priv, "unifi_cfg_enable_okc: Get unifi_SMEConfigValue failed.\n");
+ return -EFAULT;
+ }
+
+ staConfig.enableOpportunisticKeyCaching = enable_okc;
+
+ rc = sme_mgt_sme_config_set(priv, &staConfig, &deviceConfig);
+ if (rc) {
+ unifi_warning(priv, "unifi_cfg_enable_okc: Set unifi_SMEConfigValue failed.\n");
+ rc = -EFAULT;
+ }
+
+ return rc;
+}
+
+
+int unifi_cfg_get_info(unifi_priv_t *priv, unsigned char *arg)
+{
+ unifi_cfg_get_t get_cmd;
+ char inst_name[IFNAMSIZ];
+ int rc;
+
+ if (get_user(get_cmd, (unifi_cfg_get_t*)(((unifi_cfg_command_t*)arg) + 1))) {
+ unifi_error(priv, "UNIFI_CFG: Failed to get the argument\n");
+ return -EFAULT;
+ }
+
+ switch (get_cmd) {
+ case UNIFI_CFG_GET_COEX:
+ {
+ CsrWifiSmeCoexInfo coexInfo;
+ /* Get the coex info from the SME */
+ rc = sme_mgt_coex_info_get(priv, &coexInfo);
+ if (rc) {
+ unifi_error(priv, "UNIFI_CFG: Get unifi_CoexInfoValue failed.\n");
+ return rc;
+ }
+
+ /* Copy the info to the out buffer */
+ if (copy_to_user((void*)arg,
+ &coexInfo,
+ sizeof(CsrWifiSmeCoexInfo))) {
+ unifi_error(priv, "UNIFI_CFG: Failed to copy the coex info\n");
+ return -EFAULT;
+ }
+ break;
+ }
+ case UNIFI_CFG_GET_POWER_MODE:
+ {
+ CsrWifiSmePowerConfig powerConfig;
+ rc = sme_mgt_power_config_get(priv, &powerConfig);
+ if (rc) {
+ unifi_error(priv, "UNIFI_CFG: Get unifi_PowerConfigValue failed.\n");
+ return rc;
+ }
+
+ /* Copy the info to the out buffer */
+ if (copy_to_user((void*)arg,
+ &powerConfig.powerSaveLevel,
+ sizeof(CsrWifiSmePowerSaveLevel))) {
+ unifi_error(priv, "UNIFI_CFG: Failed to copy the power save info\n");
+ return -EFAULT;
+ }
+ break;
+ }
+ case UNIFI_CFG_GET_POWER_SUPPLY:
+ {
+ CsrWifiSmeHostConfig hostConfig;
+ rc = sme_mgt_host_config_get(priv, &hostConfig);
+ if (rc) {
+ unifi_error(priv, "UNIFI_CFG: Get unifi_HostConfigValue failed.\n");
+ return rc;
+ }
+
+ /* Copy the info to the out buffer */
+ if (copy_to_user((void*)arg,
+ &hostConfig.powerMode,
+ sizeof(CsrWifiSmeHostPowerMode))) {
+ unifi_error(priv, "UNIFI_CFG: Failed to copy the host power mode\n");
+ return -EFAULT;
+ }
+ break;
+ }
+ case UNIFI_CFG_GET_VERSIONS:
+ break;
+ case UNIFI_CFG_GET_INSTANCE:
+ {
+ u16 InterfaceId=0;
+ uf_net_get_name(priv->netdev[InterfaceId], &inst_name[0], sizeof(inst_name));
+
+ /* Copy the info to the out buffer */
+ if (copy_to_user((void*)arg,
+ &inst_name[0],
+ sizeof(inst_name))) {
+ unifi_error(priv, "UNIFI_CFG: Failed to copy the instance name\n");
+ return -EFAULT;
+ }
+ }
+ break;
+
+ case UNIFI_CFG_GET_AP_CONFIG:
+ {
+#ifdef CSR_SUPPORT_WEXT_AP
+ uf_cfg_ap_config_t cfg_ap_config;
+ cfg_ap_config.channel = priv->ap_config.channel;
+ cfg_ap_config.beaconInterval = priv->ap_mac_config.beaconInterval;
+ cfg_ap_config.wmmEnabled = priv->ap_mac_config.wmmEnabled;
+ cfg_ap_config.dtimPeriod = priv->ap_mac_config.dtimPeriod;
+ cfg_ap_config.phySupportedBitmap = priv->ap_mac_config.phySupportedBitmap;
+ if (copy_to_user((void*)arg,
+ &cfg_ap_config,
+ sizeof(uf_cfg_ap_config_t))) {
+ unifi_error(priv, "UNIFI_CFG: Failed to copy the AP configuration\n");
+ return -EFAULT;
+ }
+#else
+ return -EPERM;
+#endif
+ }
+ break;
+
+
+ default:
+ unifi_error(priv, "unifi_cfg_get_info: Unknown value.\n");
+ return -EINVAL;
+ }
+
+ return 0;
+}
+#ifdef CSR_SUPPORT_WEXT_AP
+int
+ uf_configure_supported_rates(u8 * supportedRates, u8 phySupportedBitmap)
+{
+ int i=0;
+ u8 b=FALSE, g = FALSE, n = FALSE;
+ b = phySupportedBitmap & CSR_WIFI_SME_AP_PHY_SUPPORT_B;
+ n = phySupportedBitmap & CSR_WIFI_SME_AP_PHY_SUPPORT_N;
+ g = phySupportedBitmap & CSR_WIFI_SME_AP_PHY_SUPPORT_G;
+ if(b || g) {
+ supportedRates[i++]=0x82;
+ supportedRates[i++]=0x84;
+ supportedRates[i++]=0x8b;
+ supportedRates[i++]=0x96;
+ } else if(n) {
+ /* For some strange reasons WiFi stack needs both b and g rates*/
+ supportedRates[i++]=0x02;
+ supportedRates[i++]=0x04;
+ supportedRates[i++]=0x0b;
+ supportedRates[i++]=0x16;
+ supportedRates[i++]=0x0c;
+ supportedRates[i++]=0x12;
+ supportedRates[i++]=0x18;
+ supportedRates[i++]=0x24;
+ supportedRates[i++]=0x30;
+ supportedRates[i++]=0x48;
+ supportedRates[i++]=0x60;
+ supportedRates[i++]=0x6c;
+ }
+ if(g) {
+ if(!b) {
+ supportedRates[i++]=0x8c;
+ supportedRates[i++]=0x98;
+ supportedRates[i++]=0xb0;
+ } else {
+ supportedRates[i++]=0x0c;
+ supportedRates[i++]=0x18;
+ supportedRates[i++]=0x30;
+ }
+ supportedRates[i++]=0x48;
+ supportedRates[i++]=0x12;
+ supportedRates[i++]=0x24;
+ supportedRates[i++]=0x60;
+ supportedRates[i++]=0x6c;
+ }
+ return i;
+}
+int unifi_cfg_set_ap_config(unifi_priv_t * priv,unsigned char* arg)
+{
+ uf_cfg_ap_config_t cfg_ap_config;
+ char *buffer;
+
+ buffer = ((unsigned char*)arg) + sizeof(unifi_cfg_command_t) + sizeof(unsigned int);
+ if (copy_from_user(&cfg_ap_config, (void*)buffer,
+ sizeof(uf_cfg_ap_config_t))) {
+ unifi_error(priv, "UNIFI_CFG: Failed to get the ap config struct\n");
+ return -EFAULT;
+ }
+ priv->ap_config.channel = cfg_ap_config.channel;
+ priv->ap_mac_config.dtimPeriod = cfg_ap_config.dtimPeriod;
+ priv->ap_mac_config.beaconInterval = cfg_ap_config.beaconInterval;
+ priv->group_sec_config.apGroupkeyTimeout = cfg_ap_config.groupkeyTimeout;
+ priv->group_sec_config.apStrictGtkRekey = cfg_ap_config.strictGtkRekeyEnabled;
+ priv->group_sec_config.apGmkTimeout = cfg_ap_config.gmkTimeout;
+ priv->group_sec_config.apResponseTimeout = cfg_ap_config.responseTimeout;
+ priv->group_sec_config.apRetransLimit = cfg_ap_config.retransLimit;
+
+ priv->ap_mac_config.shortSlotTimeEnabled = cfg_ap_config.shortSlotTimeEnabled;
+ priv->ap_mac_config.ctsProtectionType=cfg_ap_config.ctsProtectionType;
+
+ priv->ap_mac_config.wmmEnabled = cfg_ap_config.wmmEnabled;
+
+ priv->ap_mac_config.apHtParams.rxStbc=cfg_ap_config.rxStbc;
+ priv->ap_mac_config.apHtParams.rifsModeAllowed=cfg_ap_config.rifsModeAllowed;
+
+ priv->ap_mac_config.phySupportedBitmap = cfg_ap_config.phySupportedBitmap;
+ priv->ap_mac_config.maxListenInterval=cfg_ap_config.maxListenInterval;
+
+ priv->ap_mac_config.supportedRatesCount= uf_configure_supported_rates(priv->ap_mac_config.supportedRates,priv->ap_mac_config.phySupportedBitmap);
+
+ return 0;
+}
+
+#endif
+#ifdef CSR_SUPPORT_WEXT
+
+ void
+uf_sme_config_wq(struct work_struct *work)
+{
+ CsrWifiSmeStaConfig staConfig;
+ CsrWifiSmeDeviceConfig deviceConfig;
+ unifi_priv_t *priv = container_of(work, unifi_priv_t, sme_config_task);
+
+ /* Register to receive indications from the SME */
+ CsrWifiSmeEventMaskSetReqSend(0,
+ CSR_WIFI_SME_INDICATIONS_WIFIOFF | CSR_WIFI_SME_INDICATIONS_CONNECTIONQUALITY |
+ CSR_WIFI_SME_INDICATIONS_MEDIASTATUS | CSR_WIFI_SME_INDICATIONS_MICFAILURE);
+
+ if (sme_mgt_sme_config_get(priv, &staConfig, &deviceConfig)) {
+ unifi_warning(priv, "uf_sme_config_wq: Get unifi_SMEConfigValue failed.\n");
+ return;
+ }
+
+ if (priv->if_index == CSR_INDEX_5G) {
+ staConfig.ifIndex = CSR_WIFI_SME_RADIO_IF_GHZ_5_0;
+ } else {
+ staConfig.ifIndex = CSR_WIFI_SME_RADIO_IF_GHZ_2_4;
+ }
+
+ deviceConfig.trustLevel = (CsrWifiSme80211dTrustLevel)tl_80211d;
+ if (sme_mgt_sme_config_set(priv, &staConfig, &deviceConfig)) {
+ unifi_warning(priv,
+ "SME config for 802.11d Trust Level and Radio Band failed.\n");
+ return;
+ }
+
+} /* uf_sme_config_wq() */
+
+#endif /* CSR_SUPPORT_WEXT */
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * uf_ta_ind_wq
+ *
+ * Deferred work queue function to send Traffic Analysis protocols
+ * indications to the SME.
+ * These are done in a deferred work queue for two reasons:
+ * - the CsrWifiRouterCtrl...Send() functions are not safe for atomic context
+ * - we want to load the main driver data path as lightly as possible
+ *
+ * The TA classifications already come from a workqueue.
+ *
+ * Arguments:
+ * work Pointer to work queue item.
+ *
+ * Returns:
+ * None.
+ * ---------------------------------------------------------------------------
+ */
+ void
+uf_ta_ind_wq(struct work_struct *work)
+{
+ struct ta_ind *ind = container_of(work, struct ta_ind, task);
+ unifi_priv_t *priv = container_of(ind, unifi_priv_t, ta_ind_work);
+ u16 interfaceTag = 0;
+
+
+ CsrWifiRouterCtrlTrafficProtocolIndSend(priv->CSR_WIFI_SME_IFACEQUEUE,0,
+ interfaceTag,
+ ind->packet_type,
+ ind->direction,
+ ind->src_addr);
+ ind->in_use = 0;
+
+} /* uf_ta_ind_wq() */
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * uf_ta_sample_ind_wq
+ *
+ * Deferred work queue function to send Traffic Analysis sample
+ * indications to the SME.
+ * These are done in a deferred work queue for two reasons:
+ * - the CsrWifiRouterCtrl...Send() functions are not safe for atomic context
+ * - we want to load the main driver data path as lightly as possible
+ *
+ * The TA classifications already come from a workqueue.
+ *
+ * Arguments:
+ * work Pointer to work queue item.
+ *
+ * Returns:
+ * None.
+ * ---------------------------------------------------------------------------
+ */
+ void
+uf_ta_sample_ind_wq(struct work_struct *work)
+{
+ struct ta_sample_ind *ind = container_of(work, struct ta_sample_ind, task);
+ unifi_priv_t *priv = container_of(ind, unifi_priv_t, ta_sample_ind_work);
+ u16 interfaceTag = 0;
+
+ unifi_trace(priv, UDBG5, "rxtcp %d txtcp %d rxudp %d txudp %d prio %d\n",
+ priv->rxTcpThroughput,
+ priv->txTcpThroughput,
+ priv->rxUdpThroughput,
+ priv->txUdpThroughput,
+ priv->bh_thread.prio);
+
+ if(priv->rxTcpThroughput > 1000)
+ {
+ if (bh_priority == -1 && priv->bh_thread.prio != 1)
+ {
+ struct sched_param param;
+ priv->bh_thread.prio = 1;
+ unifi_trace(priv, UDBG1, "%s new thread (RT) priority = %d\n",
+ priv->bh_thread.name, priv->bh_thread.prio);
+ param.sched_priority = priv->bh_thread.prio;
+ sched_setscheduler(priv->bh_thread.thread_task, SCHED_FIFO, &param);
+ }
+ } else
+ {
+ if (bh_priority == -1 && priv->bh_thread.prio != DEFAULT_PRIO)
+ {
+ struct sched_param param;
+ param.sched_priority = 0;
+ sched_setscheduler(priv->bh_thread.thread_task, SCHED_NORMAL, &param);
+ priv->bh_thread.prio = DEFAULT_PRIO;
+ unifi_trace(priv, UDBG1, "%s new thread priority = %d\n",
+ priv->bh_thread.name, priv->bh_thread.prio);
+ set_user_nice(priv->bh_thread.thread_task, PRIO_TO_NICE(priv->bh_thread.prio));
+ }
+ }
+
+ CsrWifiRouterCtrlTrafficSampleIndSend(priv->CSR_WIFI_SME_IFACEQUEUE,0, interfaceTag, ind->stats);
+
+ ind->in_use = 0;
+
+} /* uf_ta_sample_ind_wq() */
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * uf_send_m4_ready_wq
+ *
+ * Deferred work queue function to send M4 ReadyToSend inds to the SME.
+ * These are done in a deferred work queue for two reasons:
+ * - the CsrWifiRouterCtrl...Send() functions are not safe for atomic context
+ * - we want to load the main driver data path as lightly as possible
+ *
+ * Arguments:
+ * work Pointer to work queue item.
+ *
+ * Returns:
+ * None.
+ * ---------------------------------------------------------------------------
+ */
+void
+uf_send_m4_ready_wq(struct work_struct *work)
+{
+ netInterface_priv_t *InterfacePriv = container_of(work, netInterface_priv_t, send_m4_ready_task);
+ u16 iface = InterfacePriv->InterfaceTag;
+ unifi_priv_t *priv = InterfacePriv->privPtr;
+ CSR_MA_PACKET_REQUEST *req = &InterfacePriv->m4_signal.u.MaPacketRequest;
+ CsrWifiMacAddress peer;
+ unsigned long flags;
+
+ func_enter();
+
+ /* The peer address was stored in the signal */
+ spin_lock_irqsave(&priv->m4_lock, flags);
+ memcpy(peer.a, req->Ra.x, sizeof(peer.a));
+ spin_unlock_irqrestore(&priv->m4_lock, flags);
+
+ /* Send a signal to SME */
+ CsrWifiRouterCtrlM4ReadyToSendIndSend(priv->CSR_WIFI_SME_IFACEQUEUE, 0, iface, peer);
+
+ unifi_trace(priv, UDBG1, "M4ReadyToSendInd sent for peer %pMF\n",
+ peer.a);
+
+ func_exit();
+
+} /* uf_send_m4_ready_wq() */
+
+#if (defined(CSR_WIFI_SECURITY_WAPI_ENABLE) && defined(CSR_WIFI_SECURITY_WAPI_SW_ENCRYPTION))
+/*
+ * ---------------------------------------------------------------------------
+ * uf_send_pkt_to_encrypt
+ *
+ * Deferred work queue function to send the WAPI data pkts to SME when unicast KeyId = 1
+ * These are done in a deferred work queue for two reasons:
+ * - the CsrWifiRouterCtrl...Send() functions are not safe for atomic context
+ * - we want to load the main driver data path as lightly as possible
+ *
+ * Arguments:
+ * work Pointer to work queue item.
+ *
+ * Returns:
+ * None.
+ * ---------------------------------------------------------------------------
+ */
+void uf_send_pkt_to_encrypt(struct work_struct *work)
+{
+ netInterface_priv_t *interfacePriv = container_of(work, netInterface_priv_t, send_pkt_to_encrypt);
+ u16 interfaceTag = interfacePriv->InterfaceTag;
+ unifi_priv_t *priv = interfacePriv->privPtr;
+
+ u32 pktBulkDataLength;
+ u8 *pktBulkData;
+ unsigned long flags;
+
+ if (interfacePriv->interfaceMode == CSR_WIFI_ROUTER_CTRL_MODE_STA) {
+
+ func_enter();
+
+ pktBulkDataLength = interfacePriv->wapi_unicast_bulk_data.data_length;
+
+ if (pktBulkDataLength > 0) {
+ pktBulkData = kmalloc(pktBulkDataLength, GFP_KERNEL);
+ memset(pktBulkData, 0, pktBulkDataLength);
+ } else {
+ unifi_error(priv, "uf_send_pkt_to_encrypt() : invalid buffer\n");
+ return;
+ }
+
+ spin_lock_irqsave(&priv->wapi_lock, flags);
+ /* Copy over the MA PKT REQ bulk data */
+ memcpy(pktBulkData, (u8*)interfacePriv->wapi_unicast_bulk_data.os_data_ptr, pktBulkDataLength);
+ /* Free any bulk data buffers allocated for the WAPI Data pkt */
+ unifi_net_data_free(priv, &interfacePriv->wapi_unicast_bulk_data);
+ interfacePriv->wapi_unicast_bulk_data.net_buf_length = 0;
+ interfacePriv->wapi_unicast_bulk_data.data_length = 0;
+ interfacePriv->wapi_unicast_bulk_data.os_data_ptr = interfacePriv->wapi_unicast_bulk_data.os_net_buf_ptr = NULL;
+ spin_unlock_irqrestore(&priv->wapi_lock, flags);
+
+ CsrWifiRouterCtrlWapiUnicastTxEncryptIndSend(priv->CSR_WIFI_SME_IFACEQUEUE, 0, interfaceTag, pktBulkDataLength, pktBulkData);
+ unifi_trace(priv, UDBG1, "WapiUnicastTxEncryptInd sent to SME\n");
+
+ kfree(pktBulkData); /* Would have been copied over by the SME Handler */
+
+ func_exit();
+ } else {
+ unifi_warning(priv, "uf_send_pkt_to_encrypt() is NOT applicable for interface mode - %d\n",interfacePriv->interfaceMode);
+ }
+}/* uf_send_pkt_to_encrypt() */
+#endif
diff --git a/drivers/staging/csr/unifi_sme.h b/drivers/staging/csr/unifi_sme.h
new file mode 100644
index 000000000000..b689cfe2b100
--- /dev/null
+++ b/drivers/staging/csr/unifi_sme.h
@@ -0,0 +1,245 @@
+/*
+ * ***************************************************************************
+ * FILE: unifi_sme.h
+ *
+ * PURPOSE: SME related definitions.
+ *
+ * Copyright (C) 2007-2011 by Cambridge Silicon Radio Ltd.
+ *
+ * Refer to LICENSE.txt included with this source code for details on
+ * the license terms.
+ *
+ * ***************************************************************************
+ */
+#ifndef __LINUX_UNIFI_SME_H__
+#define __LINUX_UNIFI_SME_H__ 1
+
+#include <linux/kernel.h>
+
+#ifdef CSR_SME_USERSPACE
+#include "sme_userspace.h"
+#endif
+
+#include "csr_wifi_sme_lib.h"
+
+typedef int unifi_data_port_action;
+
+typedef struct unifi_port_cfg
+{
+ /* TRUE if this port entry is allocated */
+ u8 in_use;
+ CsrWifiRouterCtrlPortAction port_action;
+ CsrWifiMacAddress mac_address;
+} unifi_port_cfg_t;
+
+#define UNIFI_MAX_CONNECTIONS 8
+#define UNIFI_MAX_RETRY_LIMIT 5
+#define UF_DATA_PORT_NOT_OVERIDE 0
+#define UF_DATA_PORT_OVERIDE 1
+
+typedef struct unifi_port_config
+{
+ int entries_in_use;
+ int overide_action;
+ unifi_port_cfg_t port_cfg[UNIFI_MAX_CONNECTIONS];
+} unifi_port_config_t;
+
+
+enum sme_request_status {
+ SME_REQUEST_EMPTY,
+ SME_REQUEST_PENDING,
+ SME_REQUEST_RECEIVED,
+ SME_REQUEST_TIMEDOUT,
+ SME_REQUEST_CANCELLED,
+};
+
+/* Structure to hold a UDI logged signal */
+typedef struct {
+
+ /* The current status of the request */
+ enum sme_request_status request_status;
+
+ /* The status the SME has passed to us */
+ CsrResult reply_status;
+
+ /* SME's reply to a get request */
+ CsrWifiSmeVersions versions;
+ CsrWifiSmePowerConfig powerConfig;
+ CsrWifiSmeHostConfig hostConfig;
+ CsrWifiSmeStaConfig staConfig;
+ CsrWifiSmeDeviceConfig deviceConfig;
+ CsrWifiSmeCoexInfo coexInfo;
+ CsrWifiSmeCoexConfig coexConfig;
+ CsrWifiSmeMibConfig mibConfig;
+ CsrWifiSmeConnectionInfo connectionInfo;
+ CsrWifiSmeConnectionConfig connectionConfig;
+ CsrWifiSmeConnectionStats connectionStats;
+
+
+ /* SME's reply to a scan request */
+ u16 reply_scan_results_count;
+ CsrWifiSmeScanResult* reply_scan_results;
+
+} sme_reply_t;
+
+
+typedef struct {
+ u16 appHandle;
+ CsrWifiRouterEncapsulation encapsulation;
+ u16 protocol;
+ u8 oui[3];
+ u8 in_use;
+} sme_ma_unidata_ind_filter_t;
+
+
+CsrWifiRouterCtrlPortAction uf_sme_port_state(unifi_priv_t *priv,
+ unsigned char *address,
+ int queue,
+ u16 interfaceTag);
+unifi_port_cfg_t *uf_sme_port_config_handle(unifi_priv_t *priv,
+ unsigned char *address,
+ int queue,
+ u16 interfaceTag);
+
+
+
+/* Callback for event logging to SME clients */
+void sme_log_event(ul_client_t *client, const u8 *signal, int signal_len,
+ const bulk_data_param_t *bulkdata, int dir);
+
+/* The workqueue task to the set the multicast addresses list */
+void uf_multicast_list_wq(struct work_struct *work);
+
+/* The workqueue task to execute the TA module */
+void uf_ta_wq(struct work_struct *work);
+
+
+/*
+ * SME blocking helper functions
+ */
+#ifdef UNIFI_DEBUG
+# define sme_complete_request(priv, status) uf_sme_complete_request(priv, status, __func__)
+#else
+# define sme_complete_request(priv, status) uf_sme_complete_request(priv, status, NULL)
+#endif
+
+void uf_sme_complete_request(unifi_priv_t *priv, CsrResult reply_status, const char *func);
+void uf_sme_cancel_request(unifi_priv_t *priv, CsrResult reply_status);
+
+
+/*
+ * Blocking functions using the SME SYS API.
+ */
+int sme_sys_suspend(unifi_priv_t *priv);
+int sme_sys_resume(unifi_priv_t *priv);
+
+
+/*
+ * Traffic Analysis workqueue jobs
+ */
+void uf_ta_ind_wq(struct work_struct *work);
+void uf_ta_sample_ind_wq(struct work_struct *work);
+
+/*
+ * SME config workqueue job
+ */
+void uf_sme_config_wq(struct work_struct *work);
+
+/*
+ * To send M4 read to send IND
+ */
+void uf_send_m4_ready_wq(struct work_struct *work);
+
+#if (defined(CSR_WIFI_SECURITY_WAPI_ENABLE) && defined(CSR_WIFI_SECURITY_WAPI_SW_ENCRYPTION))
+/*
+ * To send data pkt to Sme for encryption
+ */
+void uf_send_pkt_to_encrypt(struct work_struct *work);
+#endif
+
+int sme_mgt_power_config_set(unifi_priv_t *priv, CsrWifiSmePowerConfig *powerConfig);
+int sme_mgt_power_config_get(unifi_priv_t *priv, CsrWifiSmePowerConfig *powerConfig);
+int sme_mgt_host_config_set(unifi_priv_t *priv, CsrWifiSmeHostConfig *hostConfig);
+int sme_mgt_host_config_get(unifi_priv_t *priv, CsrWifiSmeHostConfig *hostConfig);
+int sme_mgt_sme_config_set(unifi_priv_t *priv, CsrWifiSmeStaConfig *staConfig, CsrWifiSmeDeviceConfig *deviceConfig);
+int sme_mgt_sme_config_get(unifi_priv_t *priv, CsrWifiSmeStaConfig *staConfig, CsrWifiSmeDeviceConfig *deviceConfig);
+int sme_mgt_coex_info_get(unifi_priv_t *priv, CsrWifiSmeCoexInfo *coexInfo);
+int sme_mgt_packet_filter_set(unifi_priv_t *priv);
+int sme_mgt_tspec(unifi_priv_t *priv, CsrWifiSmeListAction action,
+ u32 tid, CsrWifiSmeDataBlock *tspec, CsrWifiSmeDataBlock *tclas);
+
+#ifdef CSR_SUPPORT_WEXT
+/*
+ * Blocking functions using the SME MGT API.
+ */
+int sme_mgt_wifi_on(unifi_priv_t *priv);
+int sme_mgt_wifi_off(unifi_priv_t *priv);
+/*int sme_mgt_set_value_async(unifi_priv_t *priv, unifi_AppValue *app_value);
+int sme_mgt_get_value_async(unifi_priv_t *priv, unifi_AppValue *app_value);
+int sme_mgt_get_value(unifi_priv_t *priv, unifi_AppValue *app_value);
+int sme_mgt_set_value(unifi_priv_t *priv, unifi_AppValue *app_value);
+*/
+int sme_mgt_coex_config_set(unifi_priv_t *priv, CsrWifiSmeCoexConfig *coexConfig);
+int sme_mgt_coex_config_get(unifi_priv_t *priv, CsrWifiSmeCoexConfig *coexConfig);
+int sme_mgt_mib_config_set(unifi_priv_t *priv, CsrWifiSmeMibConfig *mibConfig);
+int sme_mgt_mib_config_get(unifi_priv_t *priv, CsrWifiSmeMibConfig *mibConfig);
+
+int sme_mgt_connection_info_set(unifi_priv_t *priv, CsrWifiSmeConnectionInfo *connectionInfo);
+int sme_mgt_connection_info_get(unifi_priv_t *priv, CsrWifiSmeConnectionInfo *connectionInfo);
+int sme_mgt_connection_config_set(unifi_priv_t *priv, CsrWifiSmeConnectionConfig *connectionConfig);
+int sme_mgt_connection_config_get(unifi_priv_t *priv, CsrWifiSmeConnectionConfig *connectionConfig);
+int sme_mgt_connection_stats_get(unifi_priv_t *priv, CsrWifiSmeConnectionStats *connectionStats);
+
+int sme_mgt_versions_get(unifi_priv_t *priv, CsrWifiSmeVersions *versions);
+
+
+int sme_mgt_scan_full(unifi_priv_t *priv, CsrWifiSsid *specific_ssid,
+ int num_channels, unsigned char *channel_list);
+int sme_mgt_scan_results_get_async(unifi_priv_t *priv,
+ struct iw_request_info *info,
+ char *scan_results,
+ long scan_results_len);
+int sme_mgt_disconnect(unifi_priv_t *priv);
+int sme_mgt_connect(unifi_priv_t *priv);
+int sme_mgt_key(unifi_priv_t *priv, CsrWifiSmeKey *sme_key,
+ CsrWifiSmeListAction action);
+int sme_mgt_pmkid(unifi_priv_t *priv, CsrWifiSmeListAction action,
+ CsrWifiSmePmkidList *pmkid_list);
+int sme_mgt_mib_get(unifi_priv_t *priv,
+ unsigned char *varbind, int *length);
+int sme_mgt_mib_set(unifi_priv_t *priv,
+ unsigned char *varbind, int length);
+#ifdef CSR_SUPPORT_WEXT_AP
+int sme_ap_start(unifi_priv_t *priv,u16 interface_tag,CsrWifiSmeApConfig_t *ap_config);
+int sme_ap_stop(unifi_priv_t *priv,u16 interface_tag);
+int sme_ap_config(unifi_priv_t *priv,CsrWifiSmeApMacConfig *ap_mac_config, CsrWifiNmeApConfig *group_security_config);
+int uf_configure_supported_rates(u8 * supportedRates, u8 phySupportedBitmap);
+#endif
+int unifi_translate_scan(struct net_device *dev,
+ struct iw_request_info *info,
+ char *current_ev, char *end_buf,
+ CsrWifiSmeScanResult *scan_data,
+ int scan_index);
+
+#endif /* CSR_SUPPORT_WEXT */
+
+int unifi_cfg_power(unifi_priv_t *priv, unsigned char *arg);
+int unifi_cfg_power_save(unifi_priv_t *priv, unsigned char *arg);
+int unifi_cfg_power_supply(unifi_priv_t *priv, unsigned char *arg);
+int unifi_cfg_packet_filters(unifi_priv_t *priv, unsigned char *arg);
+int unifi_cfg_wmm_qos_info(unifi_priv_t *priv, unsigned char *arg);
+int unifi_cfg_wmm_addts(unifi_priv_t *priv, unsigned char *arg);
+int unifi_cfg_wmm_delts(unifi_priv_t *priv, unsigned char *arg);
+int unifi_cfg_get_info(unifi_priv_t *priv, unsigned char *arg);
+int unifi_cfg_strict_draft_n(unifi_priv_t *priv, unsigned char *arg);
+int unifi_cfg_enable_okc(unifi_priv_t *priv, unsigned char *arg);
+#ifdef CSR_SUPPORT_WEXT_AP
+int unifi_cfg_set_ap_config(unifi_priv_t * priv,unsigned char* arg);
+#endif
+
+
+
+int convert_sme_error(CsrResult error);
+
+
+#endif /* __LINUX_UNIFI_SME_H__ */
diff --git a/drivers/staging/csr/unifi_wext.h b/drivers/staging/csr/unifi_wext.h
new file mode 100644
index 000000000000..6d7a99595083
--- /dev/null
+++ b/drivers/staging/csr/unifi_wext.h
@@ -0,0 +1,124 @@
+/*
+ *****************************************************************************
+ *
+ * FILE : unifi_wext.h
+ *
+ * PURPOSE : Private header file for unifi driver support to wireless extensions.
+ *
+ * Copyright (C) 2005-2008 by Cambridge Silicon Radio Ltd.
+ *
+ * Refer to LICENSE.txt included with this source code for details on
+ * the license terms.
+ *
+*****************************************************************************
+ */
+#ifndef __LINUX_UNIFI_WEXT_H__
+#define __LINUX_UNIFI_WEXT_H__ 1
+
+#include <linux/kernel.h>
+#include <net/iw_handler.h>
+#include "csr_wifi_sme_prim.h"
+
+/*
+ * wext.c
+ */
+/* A few details needed for WEP (Wireless Equivalent Privacy) */
+#define UNIFI_MAX_KEY_SIZE 16
+#define NUM_WEPKEYS 4
+#define SMALL_KEY_SIZE 5
+#define LARGE_KEY_SIZE 13
+typedef struct wep_key_t {
+ int len;
+ unsigned char key[UNIFI_MAX_KEY_SIZE]; /* 40-bit and 104-bit keys */
+} wep_key_t;
+
+#define UNIFI_SCAN_ACTIVE 0
+#define UNIFI_SCAN_PASSIVE 1
+#define UNIFI_MAX_SSID_LEN 32
+
+#define MAX_WPA_IE_LEN 64
+#define MAX_RSN_IE_LEN 255
+
+/*
+ * Function to register in the netdev to report wireless stats.
+ */
+struct iw_statistics *unifi_get_wireless_stats(struct net_device *dev);
+
+void uf_sme_wext_set_defaults(unifi_priv_t *priv);
+
+
+/*
+ * wext_events.c
+ */
+/* Functions to generate Wireless Extension events */
+void wext_send_scan_results_event(unifi_priv_t *priv);
+void wext_send_assoc_event(unifi_priv_t *priv, unsigned char *bssid,
+ unsigned char *req_ie, int req_ie_len,
+ unsigned char *resp_ie, int resp_ie_len,
+ unsigned char *scan_ie, unsigned int scan_ie_len);
+void wext_send_disassoc_event(unifi_priv_t *priv);
+void wext_send_michaelmicfailure_event(unifi_priv_t *priv,
+ u16 count, CsrWifiMacAddress address,
+ CsrWifiSmeKeyType keyType, u16 interfaceTag);
+void wext_send_pmkid_candidate_event(unifi_priv_t *priv, CsrWifiMacAddress bssid, u8 preauth_allowed, u16 interfaceTag);
+void wext_send_started_event(unifi_priv_t *priv);
+
+
+static inline int
+uf_iwe_stream_add_point(struct iw_request_info *info, char *start, char *stop,
+ struct iw_event *piwe, char *extra)
+{
+ char *new_start;
+
+ new_start = iwe_stream_add_point(
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27) || defined (IW_REQUEST_FLAG_COMPAT)
+ info,
+#endif
+ start, stop, piwe, extra);
+ if (unlikely(new_start == start))
+ {
+ return -E2BIG;
+ }
+
+ return (new_start - start);
+}
+
+
+static inline int
+uf_iwe_stream_add_event(struct iw_request_info *info, char *start, char *stop,
+ struct iw_event *piwe, int len)
+{
+ char *new_start;
+
+ new_start = iwe_stream_add_event(
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27) || defined(IW_REQUEST_FLAG_COMPAT)
+ info,
+#endif
+ start, stop, piwe, len);
+ if (unlikely(new_start == start)) {
+ return -E2BIG;
+ }
+
+ return (new_start - start);
+}
+
+static inline int
+uf_iwe_stream_add_value(struct iw_request_info *info, char *stream, char *start,
+ char *stop, struct iw_event *piwe, int len)
+{
+ char *new_start;
+
+ new_start = iwe_stream_add_value(
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27) || defined(IW_REQUEST_FLAG_COMPAT)
+ info,
+#endif
+ stream, start, stop, piwe, len);
+ if (unlikely(new_start == start)) {
+ return -E2BIG;
+ }
+
+ return (new_start - start);
+}
+
+
+#endif /* __LINUX_UNIFI_WEXT_H__ */
diff --git a/drivers/staging/csr/unifiio.h b/drivers/staging/csr/unifiio.h
new file mode 100644
index 000000000000..b9de0cb94e9a
--- /dev/null
+++ b/drivers/staging/csr/unifiio.h
@@ -0,0 +1,398 @@
+/*
+ * ---------------------------------------------------------------------------
+ *
+ * FILE: unifiio.h
+ *
+ * Public definitions for the UniFi linux driver.
+ * This is mostly ioctl command values and structs.
+ *
+ * Include <sys/ioctl.h> or similar before this file
+ *
+ * Copyright (C) 2005-2009 by Cambridge Silicon Radio Ltd.
+ *
+ * Refer to LICENSE.txt included with this source code for details on
+ * the license terms.
+ *
+ * ---------------------------------------------------------------------------
+ */
+#ifndef __UNIFIIO_H__
+#define __UNIFIIO_H__
+
+#include <linux/types.h>
+
+#define UNIFI_GET_UDI_ENABLE _IOR('u', 1, int)
+#define UNIFI_SET_UDI_ENABLE _IOW('u', 2, int)
+/* Values for UDI_ENABLE */
+#define UDI_ENABLE_DATA 0x1
+#define UDI_ENABLE_CONTROL 0x2
+
+/* MIB set/get. Arg is a pointer to a varbind */
+#define UNIFI_GET_MIB _IOWR('u', 3, unsigned char *)
+#define UNIFI_SET_MIB _IOW ('u', 4, unsigned char *)
+#define MAX_VARBIND_LENGTH 127
+
+/* Private IOCTLs */
+#define SIOCIWS80211POWERSAVEPRIV SIOCIWFIRSTPRIV
+#define SIOCIWG80211POWERSAVEPRIV SIOCIWFIRSTPRIV + 1
+#define SIOCIWS80211RELOADDEFAULTSPRIV SIOCIWFIRSTPRIV + 2
+#define SIOCIWSCONFWAPIPRIV SIOCIWFIRSTPRIV + 4
+#define SIOCIWSWAPIKEYPRIV SIOCIWFIRSTPRIV + 6
+#define SIOCIWSSMEDEBUGPRIV SIOCIWFIRSTPRIV + 8
+#define SIOCIWSAPCFGPRIV SIOCIWFIRSTPRIV + 10
+#define SIOCIWSAPSTARTPRIV SIOCIWFIRSTPRIV + 12
+#define SIOCIWSAPSTOPPRIV SIOCIWFIRSTPRIV + 14
+#define SIOCIWSFWRELOADPRIV SIOCIWFIRSTPRIV + 16
+#define SIOCIWSSTACKSTART SIOCIWFIRSTPRIV + 18
+#define SIOCIWSSTACKSTOP SIOCIWFIRSTPRIV + 20
+
+
+
+#define IWPRIV_POWER_SAVE_MAX_STRING 32
+#define IWPRIV_SME_DEBUG_MAX_STRING 32
+#define IWPRIV_SME_MAX_STRING 120
+
+
+/* Private configuration commands */
+#define UNIFI_CFG _IOWR('u', 5, unsigned char *)
+/*
+ * <------------------ Read/Write Buffer -------------------->
+ * _____________________________________________________________
+ * | Cmd | Arg | ... Buffer (opt) ... |
+ * -------------------------------------------------------------
+ * <-- uint --><-- uint --><----- unsigned char buffer ------>
+ *
+ * Cmd: A unifi_cfg_command_t command.
+ * Arg: Out:Length if Cmd==UNIFI_CFG_GET
+ * In:PowerOnOff if Cmd==UNIFI_CFG_POWER
+ * In:PowerMode if Cmd==UNIFI_CFG_POWERSAVE
+ * In:Length if Cmd==UNIFI_CFG_FILTER
+ * In:WMM Qos Info if Cmd==UNIFI_CFG_WMM_QOS_INFO
+ * Buffer: Out:Data if Cmd==UNIFI_CFG_GET
+ * NULL if Cmd==UNIFI_CFG_POWER
+ * NULL if Cmd==UNIFI_CFG_POWERSAVE
+ * In:Filters if Cmd==UNIFI_CFG_FILTER
+ *
+ * where Filters is a uf_cfg_bcast_packet_filter_t structure
+ * followed by 0 - n tclas_t structures. The length of the tclas_t
+ * structures is obtained by uf_cfg_bcast_packet_filter_t::tclas_ies_length.
+ */
+
+
+#define UNIFI_PUTEST _IOWR('u', 6, unsigned char *)
+/*
+ * <------------------ Read/Write Buffer -------------------->
+ * _____________________________________________________________
+ * | Cmd | Arg | ... Buffer (opt) ... |
+ * -------------------------------------------------------------
+ * <-- uint --><-- uint --><----- unsigned char buffer ------>
+ *
+ * Cmd: A unifi_putest_command_t command.
+ * Arg: N/A if Cmd==UNIFI_PUTEST_START
+ * N/A if Cmd==UNIFI_PUTEST_STOP
+ * In:int (Clock Speed) if Cmd==UNIFI_PUTEST_SET_SDIO_CLOCK
+ * In/Out:sizeof(unifi_putest_cmd52) if Cmd==UNIFI_PUTEST_CMD52_READ
+ * In:sizeof(unifi_putest_cmd52) if Cmd==UNIFI_PUTEST_CMD52_WRITE
+ * In:uint (f/w file name length) if Cmd==UNIFI_PUTEST_DL_FW
+ * Buffer: NULL if Cmd==UNIFI_PUTEST_START
+ * NULL if Cmd==UNIFI_PUTEST_STOP
+ * NULL if Cmd==UNIFI_PUTEST_SET_SDIO_CLOCK
+ * In/Out:unifi_putest_cmd52 if Cmd==UNIFI_PUTEST_CMD52_READ
+ * In:unifi_putest_cmd52 if Cmd==UNIFI_PUTEST_CMD52_WRITE
+ * In:f/w file name if Cmd==UNIFI_PUTEST_DL_FW
+ */
+
+#define UNIFI_BUILD_TYPE _IOWR('u', 7, unsigned char)
+#define UNIFI_BUILD_NME 1
+#define UNIFI_BUILD_WEXT 2
+#define UNIFI_BUILD_AP 3
+
+/* debugging */
+#define UNIFI_KICK _IO ('u', 0x10)
+#define UNIFI_SET_DEBUG _IO ('u', 0x11)
+#define UNIFI_SET_TRACE _IO ('u', 0x12)
+
+#define UNIFI_GET_INIT_STATUS _IOR ('u', 0x15, int)
+#define UNIFI_SET_UDI_LOG_MASK _IOR('u', 0x18, unifiio_filter_t)
+#define UNIFI_SET_UDI_SNAP_MASK _IOW('u', 0x1a, unifiio_snap_filter_t)
+#define UNIFI_SET_AMP_ENABLE _IOWR('u', 0x1b, int)
+
+#define UNIFI_INIT_HW _IOR ('u', 0x13, unsigned char)
+#define UNIFI_INIT_NETDEV _IOW ('u', 0x14, unsigned char[6])
+#define UNIFI_SME_PRESENT _IOW ('u', 0x19, int)
+
+#define UNIFI_CFG_PERIOD_TRAFFIC _IOW ('u', 0x21, unsigned char *)
+#define UNIFI_CFG_UAPSD_TRAFFIC _IOW ('u', 0x22, unsigned char)
+
+#define UNIFI_COREDUMP_GET_REG _IOWR('u', 0x23, unifiio_coredump_req_t)
+
+
+/*
+ * Following reset, f/w may only be downloaded using CMD52.
+ * This is slow, so there is a facility to download a secondary
+ * loader first which supports CMD53.
+ * If loader_len is > 0, then loader_data is assumed to point to
+ * a suitable secondary loader that can be used to download the
+ * main image.
+ *
+ * The driver will run the host protocol initialisation sequence
+ * after downloading the image.
+ *
+ * If both lengths are zero, then the f/w is assumed to have been
+ * booted from Flash and the host protocol initialisation sequence
+ * is run.
+ */
+typedef struct {
+
+ /* Number of bytes in the image */
+ int img_len;
+
+ /* Pointer to image data. */
+ unsigned char *img_data;
+
+
+ /* Number of bytes in the loader image */
+ int loader_len;
+
+ /* Pointer to loader image data. */
+ unsigned char *loader_data;
+
+} unifiio_img_t;
+
+
+/* Structure of data read from the unifi device. */
+typedef struct
+{
+ /* Length (in bytes) of entire structure including appended bulk data */
+ int length;
+
+ /* System time (in milliseconds) that signal was transferred */
+ int timestamp;
+
+ /* Direction in which signal was transferred. */
+ int direction;
+#define UDI_FROM_HOST 0
+#define UDI_TO_HOST 1
+#define UDI_CONFIG_IND 2
+
+ /* The length of the signal (in bytes) not including bulk data */
+ int signal_length;
+
+ /* Signal body follows, then any bulk data */
+
+} udi_msg_t;
+
+
+typedef enum
+{
+ UfSigFil_AllOn = 0, /* Log all signal IDs */
+ UfSigFil_AllOff = 1, /* Don't log any signal IDs */
+ UfSigFil_SelectOn = 2, /* Log these signal IDs */
+ UfSigFil_SelectOff = 3 /* Don't log these signal IDs */
+} uf_sigfilter_action_t;
+
+typedef struct {
+
+ /* Number of 16-bit ints in the sig_ids array */
+ int num_sig_ids;
+ /* The action to perform */
+ uf_sigfilter_action_t action;
+ /* List of signal IDs to pass or block */
+ unsigned short *sig_ids;
+
+} unifiio_filter_t;
+
+
+typedef struct {
+ /* Number of 16-bit ints in the protocols array */
+ u16 count;
+ /* List of protocol ids to pass */
+ u16 *protocols;
+} unifiio_snap_filter_t;
+
+
+
+typedef u8 unifi_putest_command_t;
+
+#define UNIFI_PUTEST_START 0
+#define UNIFI_PUTEST_STOP 1
+#define UNIFI_PUTEST_SET_SDIO_CLOCK 2
+#define UNIFI_PUTEST_CMD52_READ 3
+#define UNIFI_PUTEST_CMD52_WRITE 4
+#define UNIFI_PUTEST_DL_FW 5
+#define UNIFI_PUTEST_DL_FW_BUFF 6
+#define UNIFI_PUTEST_CMD52_BLOCK_READ 7
+#define UNIFI_PUTEST_COREDUMP_PREPARE 8
+#define UNIFI_PUTEST_GP_READ16 9
+#define UNIFI_PUTEST_GP_WRITE16 10
+
+
+struct unifi_putest_cmd52 {
+ int funcnum;
+ unsigned long addr;
+ unsigned char data;
+};
+
+
+struct unifi_putest_block_cmd52_r {
+ int funcnum;
+ unsigned long addr;
+ unsigned int length;
+ unsigned char *data;
+};
+
+struct unifi_putest_gp_rw16 {
+ unsigned long addr; /* generic address */
+ unsigned short data;
+};
+
+typedef enum unifi_cfg_command {
+ UNIFI_CFG_GET,
+ UNIFI_CFG_POWER,
+ UNIFI_CFG_POWERSAVE,
+ UNIFI_CFG_FILTER,
+ UNIFI_CFG_POWERSUPPLY,
+ UNIFI_CFG_WMM_QOSINFO,
+ UNIFI_CFG_WMM_ADDTS,
+ UNIFI_CFG_WMM_DELTS,
+ UNIFI_CFG_STRICT_DRAFT_N,
+ UNIFI_CFG_ENABLE_OKC,
+ UNIFI_CFG_SET_AP_CONFIG,
+ UNIFI_CFG_CORE_DUMP /* request to take a fw core dump */
+} unifi_cfg_command_t;
+
+typedef enum unifi_cfg_power {
+ UNIFI_CFG_POWER_UNSPECIFIED,
+ UNIFI_CFG_POWER_OFF,
+ UNIFI_CFG_POWER_ON
+} unifi_cfg_power_t;
+
+typedef enum unifi_cfg_powersupply {
+ UNIFI_CFG_POWERSUPPLY_UNSPECIFIED,
+ UNIFI_CFG_POWERSUPPLY_MAINS,
+ UNIFI_CFG_POWERSUPPLY_BATTERIES
+} unifi_cfg_powersupply_t;
+
+typedef enum unifi_cfg_powersave {
+ UNIFI_CFG_POWERSAVE_UNSPECIFIED,
+ UNIFI_CFG_POWERSAVE_NONE,
+ UNIFI_CFG_POWERSAVE_FAST,
+ UNIFI_CFG_POWERSAVE_FULL,
+ UNIFI_CFG_POWERSAVE_AUTO
+} unifi_cfg_powersave_t;
+
+typedef enum unifi_cfg_get {
+ UNIFI_CFG_GET_COEX,
+ UNIFI_CFG_GET_POWER_MODE,
+ UNIFI_CFG_GET_VERSIONS,
+ UNIFI_CFG_GET_POWER_SUPPLY,
+ UNIFI_CFG_GET_INSTANCE,
+ UNIFI_CFG_GET_AP_CONFIG
+} unifi_cfg_get_t;
+
+#define UNIFI_CFG_FILTER_NONE 0x0000
+#define UNIFI_CFG_FILTER_DHCP 0x0001
+#define UNIFI_CFG_FILTER_ARP 0x0002
+#define UNIFI_CFG_FILTER_NBNS 0x0004
+#define UNIFI_CFG_FILTER_NBDS 0x0008
+#define UNIFI_CFG_FILTER_CUPS 0x0010
+#define UNIFI_CFG_FILTER_ALL 0xFFFF
+
+
+typedef struct uf_cfg_bcast_packet_filter
+{
+ unsigned long filter_mode; //as defined by HIP protocol
+ unsigned char arp_filter;
+ unsigned char dhcp_filter;
+ unsigned long tclas_ies_length; // length of tclas_ies in bytes
+ unsigned char tclas_ies[1]; // variable length depending on above field
+} uf_cfg_bcast_packet_filter_t;
+
+typedef struct uf_cfg_ap_config
+{
+ u8 phySupportedBitmap;
+ u8 channel;
+ u16 beaconInterval;
+ u8 dtimPeriod;
+ u8 wmmEnabled;
+ u8 shortSlotTimeEnabled;
+ u16 groupkeyTimeout;
+ u8 strictGtkRekeyEnabled;
+ u16 gmkTimeout;
+ u16 responseTimeout;
+ u8 retransLimit;
+ u8 rxStbc;
+ u8 rifsModeAllowed;
+ u8 dualCtsProtection;
+ u8 ctsProtectionType;
+ u16 maxListenInterval;
+}uf_cfg_ap_config_t;
+
+typedef struct tcpic_clsfr
+{
+ __u8 cls_fr_type;
+ __u8 cls_fr_mask;
+ __u8 version;
+ __u8 source_ip_addr[4];
+ __u8 dest_ip_addr[4];
+ __u16 source_port;
+ __u16 dest_port;
+ __u8 dscp;
+ __u8 protocol;
+ __u8 reserved;
+} __attribute__ ((packed)) tcpip_clsfr_t;
+
+typedef struct tclas {
+ __u8 element_id;
+ __u8 length;
+ __u8 user_priority;
+ tcpip_clsfr_t tcp_ip_cls_fr;
+} __attribute__ ((packed)) tclas_t;
+
+
+#define CONFIG_IND_ERROR 0x01
+#define CONFIG_IND_EXIT 0x02
+#define CONFIG_SME_NOT_PRESENT 0x10
+#define CONFIG_SME_PRESENT 0x20
+
+/* WAPI Key */
+typedef struct
+{
+ u8 unicastKey;
+ /* If non zero, then unicast key otherwise group key */
+ u8 keyIndex;
+ u8 keyRsc[16];
+ u8 authenticator;
+ /* If non zero, then authenticator otherwise supplicant */
+ u8 address[6];
+ u8 key[32];
+} unifiio_wapi_key_t;
+
+/* Values describing XAP memory regions captured by the mini-coredump system */
+typedef enum unifiio_coredump_space {
+ UNIFIIO_COREDUMP_MAC_REG,
+ UNIFIIO_COREDUMP_PHY_REG,
+ UNIFIIO_COREDUMP_SH_DMEM,
+ UNIFIIO_COREDUMP_MAC_DMEM,
+ UNIFIIO_COREDUMP_PHY_DMEM,
+ UNIFIIO_COREDUMP_TRIGGER_MAGIC = 0xFEED
+} unifiio_coredump_space_t;
+
+/* Userspace tool uses this structure to retrieve a register value from a
+ * mini-coredump buffer previously saved by the HIP
+ */
+typedef struct unifiio_coredump_req {
+ /* From user */
+ int index; /* 0=newest, -1=oldest */
+ unsigned int offset; /* register offset in space */
+ unifiio_coredump_space_t space; /* memory space */
+ /* Filled by driver */
+ unsigned int drv_build; /* driver build id */
+ unsigned int chip_ver; /* chip version */
+ unsigned int fw_ver; /* firmware version */
+ int requestor; /* requestor: 0=auto dump, 1=manual */
+ unsigned int timestamp; /* time of capture by driver */
+ unsigned int serial; /* capture serial number */
+ int value; /* 16 bit register value, -ve for error */
+} unifiio_coredump_req_t; /* Core-dumped register value request */
+
+#endif /* __UNIFIIO_H__ */
diff --git a/drivers/staging/csr/wext_events.c b/drivers/staging/csr/wext_events.c
new file mode 100644
index 000000000000..d356887ac4c6
--- /dev/null
+++ b/drivers/staging/csr/wext_events.c
@@ -0,0 +1,285 @@
+/*
+ * ---------------------------------------------------------------------------
+ * FILE: wext_events.c
+ *
+ * PURPOSE:
+ * Code to generate iwevents.
+ *
+ * Copyright (C) 2006-2008 by Cambridge Silicon Radio Ltd.
+ *
+ * Refer to LICENSE.txt included with this source code for details on
+ * the license terms.
+ *
+ * ---------------------------------------------------------------------------
+ */
+#include <linux/types.h>
+#include <linux/etherdevice.h>
+#include <linux/if_arp.h>
+#include "csr_wifi_hip_unifi.h"
+#include "unifi_priv.h"
+
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * wext_send_assoc_event
+ *
+ * Send wireless-extension events up to userland to announce
+ * successful association with an AP.
+ *
+ * Arguments:
+ * priv Pointer to driver context.
+ * bssid MAC address of AP we associated with
+ * req_ie, req_ie_len IEs in the original request
+ * resp_ie, resp_ie_len IEs in the response
+ *
+ * Returns:
+ * None.
+ *
+ * Notes:
+ * This is sent on first successful association, and again if we
+ * roam to another AP.
+ * ---------------------------------------------------------------------------
+ */
+void
+wext_send_assoc_event(unifi_priv_t *priv, unsigned char *bssid,
+ unsigned char *req_ie, int req_ie_len,
+ unsigned char *resp_ie, int resp_ie_len,
+ unsigned char *scan_ie, unsigned int scan_ie_len)
+{
+#if WIRELESS_EXT > 17
+ union iwreq_data wrqu;
+
+ if (req_ie_len == 0) req_ie = NULL;
+ wrqu.data.length = req_ie_len;
+ wrqu.data.flags = 0;
+ wireless_send_event(priv->netdev[CSR_WIFI_INTERFACE_IN_USE], IWEVASSOCREQIE, &wrqu, req_ie);
+
+ if (resp_ie_len == 0) resp_ie = NULL;
+ wrqu.data.length = resp_ie_len;
+ wrqu.data.flags = 0;
+ wireless_send_event(priv->netdev[CSR_WIFI_INTERFACE_IN_USE], IWEVASSOCRESPIE, &wrqu, resp_ie);
+
+ if (scan_ie_len > 0) {
+ wrqu.data.length = scan_ie_len;
+ wrqu.data.flags = 0;
+ wireless_send_event(priv->netdev[CSR_WIFI_INTERFACE_IN_USE], IWEVGENIE, &wrqu, scan_ie);
+ }
+
+ memcpy(&wrqu.ap_addr.sa_data, bssid, ETH_ALEN);
+ wireless_send_event(priv->netdev[CSR_WIFI_INTERFACE_IN_USE], SIOCGIWAP, &wrqu, NULL);
+#endif
+} /* wext_send_assoc_event() */
+
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * wext_send_disassoc_event
+ *
+ * Send a wireless-extension event up to userland to announce
+ * that we disassociated from an AP.
+ *
+ * Arguments:
+ * priv Pointer to driver context.
+ *
+ * Returns:
+ * None.
+ *
+ * Notes:
+ * The semantics of wpa_supplicant (the userland SME application) are
+ * that a SIOCGIWAP event with MAC address of all zero means
+ * disassociate.
+ * ---------------------------------------------------------------------------
+ */
+void
+wext_send_disassoc_event(unifi_priv_t *priv)
+{
+#if WIRELESS_EXT > 17
+ union iwreq_data wrqu;
+
+ memset(wrqu.ap_addr.sa_data, 0, ETH_ALEN);
+ wireless_send_event(priv->netdev[CSR_WIFI_INTERFACE_IN_USE], SIOCGIWAP, &wrqu, NULL);
+#endif
+} /* wext_send_disassoc_event() */
+
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * wext_send_scan_results_event
+ *
+ * Send wireless-extension events up to userland to announce
+ * completion of a scan.
+ *
+ * Arguments:
+ * priv Pointer to driver context.
+ *
+ * Returns:
+ * None.
+ *
+ * Notes:
+ * This doesn't actually report the results, they are retrieved
+ * using the SIOCGIWSCAN ioctl command.
+ * ---------------------------------------------------------------------------
+ */
+void
+wext_send_scan_results_event(unifi_priv_t *priv)
+{
+#if WIRELESS_EXT > 17
+ union iwreq_data wrqu;
+
+ wrqu.data.length = 0;
+ wrqu.data.flags = 0;
+ wireless_send_event(priv->netdev[CSR_WIFI_INTERFACE_IN_USE], SIOCGIWSCAN, &wrqu, NULL);
+
+#endif
+} /* wext_send_scan_results_event() */
+
+
+
+/*
+ * ---------------------------------------------------------------------------
+ * wext_send_michaelmicfailure_event
+ *
+ * Send wireless-extension events up to userland to announce
+ * completion of a scan.
+ *
+ * Arguments:
+ * priv Pointer to driver context.
+ * count, macaddr, key_type, key_idx, tsc
+ * Parameters from report from UniFi.
+ *
+ * Returns:
+ * None.
+ * ---------------------------------------------------------------------------
+ */
+#if WIRELESS_EXT >= 18
+static inline void
+_send_michaelmicfailure_event(struct net_device *dev,
+ int count, const unsigned char *macaddr,
+ int key_type, int key_idx,
+ unsigned char *tsc)
+{
+ union iwreq_data wrqu;
+ struct iw_michaelmicfailure mmf;
+
+ memset(&mmf, 0, sizeof(mmf));
+
+ mmf.flags = key_idx & IW_MICFAILURE_KEY_ID;
+ if (key_type == CSR_GROUP) {
+ mmf.flags |= IW_MICFAILURE_GROUP;
+ } else {
+ mmf.flags |= IW_MICFAILURE_PAIRWISE;
+ }
+ mmf.flags |= ((count << 5) & IW_MICFAILURE_COUNT);
+
+ mmf.src_addr.sa_family = ARPHRD_ETHER;
+ memcpy(mmf.src_addr.sa_data, macaddr, ETH_ALEN);
+
+ memcpy(mmf.tsc, tsc, IW_ENCODE_SEQ_MAX_SIZE);
+
+ memset(&wrqu, 0, sizeof(wrqu));
+ wrqu.data.length = sizeof(mmf);
+
+ wireless_send_event(dev, IWEVMICHAELMICFAILURE, &wrqu, (char *)&mmf);
+}
+#elif WIRELESS_EXT >= 15
+static inline void
+_send_michaelmicfailure_event(struct net_device *dev,
+ int count, const unsigned char *macaddr,
+ int key_type, int key_idx,
+ unsigned char *tsc)
+{
+ union iwreq_data wrqu;
+ char buf[128];
+
+ sprintf(buf,
+ "MLME-MICHAELMICFAILURE.indication(keyid=%d %scast addr=%02x:%02x:%02x:%02x:%02x:%02x)",
+ key_idx, (key_type == CSR_GROUP) ? "broad" : "uni",
+ macaddr[0], macaddr[1], macaddr[2],
+ macaddr[3], macaddr[4], macaddr[5]);
+ memset(&wrqu, 0, sizeof(wrqu));
+ wrqu.data.length = strlen(buf);
+ wireless_send_event(dev, IWEVCUSTOM, &wrqu, buf);
+}
+#else /* WIRELESS_EXT >= 15 */
+static inline void
+_send_michaelmicfailure_event(struct net_device *dev,
+ int count, const unsigned char *macaddr,
+ int key_type, int key_idx,
+ unsigned char *tsc)
+{
+ /* Not supported before WEXT 15 */
+}
+#endif /* WIRELESS_EXT >= 15 */
+
+
+void
+wext_send_michaelmicfailure_event(unifi_priv_t *priv,
+ u16 count,
+ CsrWifiMacAddress address,
+ CsrWifiSmeKeyType keyType,
+ u16 interfaceTag)
+{
+ unsigned char tsc[8] = {0};
+
+ if (interfaceTag >= CSR_WIFI_NUM_INTERFACES) {
+ unifi_error(priv, "wext_send_michaelmicfailure_event bad interfaceTag\n");
+ return;
+ }
+
+ _send_michaelmicfailure_event(priv->netdev[interfaceTag],
+ count,
+ address.a,
+ keyType,
+ 0,
+ tsc);
+} /* wext_send_michaelmicfailure_event() */
+
+void
+wext_send_pmkid_candidate_event(unifi_priv_t *priv, CsrWifiMacAddress bssid, u8 preauth_allowed, u16 interfaceTag)
+{
+#if WIRELESS_EXT > 17
+ union iwreq_data wrqu;
+ struct iw_pmkid_cand pmkid_cand;
+
+ if (interfaceTag >= CSR_WIFI_NUM_INTERFACES) {
+ unifi_error(priv, "wext_send_pmkid_candidate_event bad interfaceTag\n");
+ return;
+ }
+
+ memset(&pmkid_cand, 0, sizeof(pmkid_cand));
+
+ if (preauth_allowed) {
+ pmkid_cand.flags |= IW_PMKID_CAND_PREAUTH;
+ }
+ pmkid_cand.bssid.sa_family = ARPHRD_ETHER;
+ memcpy(pmkid_cand.bssid.sa_data, bssid.a, ETH_ALEN);
+ /* Used as priority, smaller the number higher the priority, not really used in our case */
+ pmkid_cand.index = 1;
+
+ memset(&wrqu, 0, sizeof(wrqu));
+ wrqu.data.length = sizeof(pmkid_cand);
+
+ wireless_send_event(priv->netdev[interfaceTag], IWEVPMKIDCAND, &wrqu, (char *)&pmkid_cand);
+#endif
+} /* wext_send_pmkid_candidate_event() */
+
+/*
+ * Send a custom WEXT event to say we have completed initialisation
+ * and are now ready for WEXT ioctls. Used by Android wpa_supplicant.
+ */
+void
+wext_send_started_event(unifi_priv_t *priv)
+{
+#if WIRELESS_EXT > 17
+ union iwreq_data wrqu;
+ char data[] = "STARTED";
+
+ wrqu.data.length = sizeof(data);
+ wrqu.data.flags = 0;
+ wireless_send_event(priv->netdev[CSR_WIFI_INTERFACE_IN_USE], IWEVCUSTOM, &wrqu, data);
+#endif
+} /* wext_send_started_event() */
+
diff --git a/drivers/staging/echo/echo.c b/drivers/staging/echo/echo.c
index afbf5442b42b..ca87ce9874b1 100644
--- a/drivers/staging/echo/echo.c
+++ b/drivers/staging/echo/echo.c
@@ -118,7 +118,8 @@
#ifdef __bfin__
static inline void lms_adapt_bg(struct oslec_state *ec, int clean, int shift)
{
- int i, j;
+ int i;
+ int j;
int offset1;
int offset2;
int factor;
@@ -335,7 +336,8 @@ int16_t oslec_update(struct oslec_state *ec, int16_t tx, int16_t rx)
{
int32_t echo_value;
int clean_bg;
- int tmp, tmp1;
+ int tmp;
+ int tmp1;
/*
* Input scaling was found be required to prevent problems when tx
@@ -624,7 +626,8 @@ EXPORT_SYMBOL_GPL(oslec_update);
int16_t oslec_hpf_tx(struct oslec_state *ec, int16_t tx)
{
- int tmp, tmp1;
+ int tmp;
+ int tmp1;
if (ec->adaption_mode & ECHO_CAN_USE_TX_HPF) {
tmp = tx << 15;
diff --git a/drivers/staging/echo/echo.h b/drivers/staging/echo/echo.h
index 754e66d30c1b..32ca9dedeca4 100644
--- a/drivers/staging/echo/echo.h
+++ b/drivers/staging/echo/echo.h
@@ -36,7 +36,6 @@ What does it do?
This module aims to provide G.168-2002 compliant echo cancellation, to remove
electrical echoes (e.g. from 2-4 wire hybrids) from voice calls.
-
How does it work?
The heart of the echo cancellor is FIR filter. This is adapted to match the
@@ -128,7 +127,8 @@ a minor burden.
echo canceller.
*/
struct oslec_state {
- int16_t tx, rx;
+ int16_t tx;
+ int16_t rx;
int16_t clean;
int16_t clean_nlp;
@@ -145,11 +145,18 @@ struct oslec_state {
int16_t shift;
/* Average levels and averaging filter states */
- int Ltxacc, Lrxacc, Lcleanacc, Lclean_bgacc;
- int Ltx, Lrx;
+ int Ltxacc;
+ int Lrxacc;
+ int Lcleanacc;
+ int Lclean_bgacc;
+ int Ltx;
+ int Lrx;
int Lclean;
int Lclean_bg;
- int Lbgn, Lbgn_acc, Lbgn_upper, Lbgn_upper_acc;
+ int Lbgn;
+ int Lbgn_acc;
+ int Lbgn_upper;
+ int Lbgn_upper_acc;
/* foreground and background filter states */
struct fir16_state_t fir_state;
@@ -157,11 +164,16 @@ struct oslec_state {
int16_t *fir_taps16[2];
/* DC blocking filter states */
- int tx_1, tx_2, rx_1, rx_2;
+ int tx_1;
+ int tx_2;
+ int rx_1;
+ int rx_2;
/* optional High Pass Filter states */
- int32_t xvtx[5], yvtx[5];
- int32_t xvrx[5], yvrx[5];
+ int32_t xvtx[5];
+ int32_t yvtx[5];
+ int32_t xvrx[5];
+ int32_t yvrx[5];
/* Parameters for the optional Hoth noise generator */
int cng_level;
diff --git a/drivers/staging/et131x/et131x.c b/drivers/staging/et131x/et131x.c
index 886f5650444e..029725c89e58 100644
--- a/drivers/staging/et131x/et131x.c
+++ b/drivers/staging/et131x/et131x.c
@@ -53,6 +53,8 @@
*
*/
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
#include <linux/pci.h>
#include <linux/init.h>
#include <linux/module.h>
@@ -85,8 +87,7 @@
MODULE_AUTHOR("Victor Soriano <vjsoriano@agere.com>");
MODULE_AUTHOR("Mark Einon <mark.einon@gmail.com>");
MODULE_LICENSE("Dual BSD/GPL");
-MODULE_DESCRIPTION("10/100/1000 Base-T Ethernet Driver "
- "for the ET1310 by Agere Systems");
+MODULE_DESCRIPTION("10/100/1000 Base-T Ethernet Driver for the ET1310 by Agere Systems");
/* EEPROM defines */
#define MAX_NUM_REGISTER_POLLS 1000
@@ -1710,7 +1711,8 @@ static int et131x_mdio_read(struct mii_bus *bus, int phy_addr, int reg)
return value;
}
-static int et131x_mdio_write(struct mii_bus *bus, int phy_addr, int reg, u16 value)
+static int et131x_mdio_write(struct mii_bus *bus, int phy_addr,
+ int reg, u16 value)
{
struct net_device *netdev = bus->priv;
struct et131x_adapter *adapter = netdev_priv(netdev);
@@ -1766,8 +1768,8 @@ static void et131x_xcvr_init(struct et131x_adapter *adapter)
/* Set the link status interrupt only. Bad behavior when link status
* and auto neg are set, we run into a nested interrupt problem
*/
- imr |= (ET_PHY_INT_MASK_AUTONEGSTAT &
- ET_PHY_INT_MASK_LINKSTAT &
+ imr |= (ET_PHY_INT_MASK_AUTONEGSTAT |
+ ET_PHY_INT_MASK_LINKSTAT |
ET_PHY_INT_MASK_ENABLE);
et131x_mii_write(adapter, PHY_INTERRUPT_MASK, imr);
@@ -1783,7 +1785,7 @@ static void et131x_xcvr_init(struct et131x_adapter *adapter)
if ((adapter->eeprom_data[1] & 0x4) == 0) {
et131x_mii_read(adapter, PHY_LED_2, &lcr2);
- lcr2 &= (ET_LED2_LED_100TX & ET_LED2_LED_1000T);
+ lcr2 &= (ET_LED2_LED_100TX | ET_LED2_LED_1000T);
lcr2 |= (LED_VAL_LINKON_ACTIVE << LED_LINK_SHIFT);
if ((adapter->eeprom_data[1] & 0x8) == 0)
@@ -2553,8 +2555,8 @@ static int et131x_rx_dma_memory_alloc(struct et131x_adapter *adapter)
"Cannot alloc memory for Packet Status Ring\n");
return -ENOMEM;
}
- printk(KERN_INFO "Packet Status Ring %lx\n",
- (unsigned long) rx_ring->ps_ring_physaddr);
+ pr_info("Packet Status Ring %llx\n",
+ (unsigned long long) rx_ring->ps_ring_physaddr);
/*
* NOTE : dma_alloc_coherent(), used above to alloc DMA regions,
@@ -2574,7 +2576,7 @@ static int et131x_rx_dma_memory_alloc(struct et131x_adapter *adapter)
return -ENOMEM;
}
rx_ring->num_rfd = NIC_DEFAULT_NUM_RFD;
- printk(KERN_INFO "PRS %lx\n", (unsigned long)rx_ring->rx_status_bus);
+ pr_info("PRS %llx\n", (unsigned long long)rx_ring->rx_status_bus);
/* Recv
* kmem_cache_create initializes a lookaside list. After successful
@@ -2966,11 +2968,10 @@ static struct rfd *nic_rx_pkts(struct et131x_adapter *adapter)
(ring_index == 0 &&
buff_index > rx_local->fbr[1]->num_entries - 1) ||
(ring_index == 1 &&
- buff_index > rx_local->fbr[0]->num_entries - 1))
+ buff_index > rx_local->fbr[0]->num_entries - 1)) {
#else
- if (ring_index != 1 || buff_index > rx_local->fbr[0]->num_entries - 1)
+ if (ring_index != 1 || buff_index > rx_local->fbr[0]->num_entries - 1) {
#endif
- {
/* Illegal buffer or ring index cannot be used by S/W*/
dev_err(&adapter->pdev->dev,
"NICRxPkts PSR Entry %d indicates "
@@ -3944,12 +3945,6 @@ static struct ethtool_ops et131x_ethtool_ops = {
.get_regs = et131x_get_regs,
.get_link = ethtool_op_get_link,
};
-
-static void et131x_set_ethtool_ops(struct net_device *netdev)
-{
- SET_ETHTOOL_OPS(netdev, &et131x_ethtool_ops);
-}
-
/**
* et131x_hwaddr_init - set up the MAC Address on the ET1310
* @adapter: pointer to our private adapter structure
@@ -4013,7 +4008,7 @@ static int et131x_pci_init(struct et131x_adapter *adapter,
dev_err(&pdev->dev, "Missing PCIe capabilities\n");
goto err_out;
}
-
+
/* Let's set up the PORT LOGIC Register. First we need to know what
* the max_payload_size is
*/
@@ -4060,7 +4055,7 @@ static int et131x_pci_init(struct et131x_adapter *adapter,
goto err_out;
}
- ctl = (ctl & ~PCI_EXP_DEVCTL_READRQ) | ( 0x04 << 12);
+ ctl = (ctl & ~PCI_EXP_DEVCTL_READRQ) | (0x04 << 12);
if (pci_write_config_word(pdev, cap + PCI_EXP_DEVCTL, ctl)) {
dev_err(&pdev->dev,
@@ -4325,8 +4320,7 @@ static int et131x_mii_probe(struct net_device *netdev)
phydev->advertising = phydev->supported;
adapter->phydev = phydev;
- dev_info(&adapter->pdev->dev, "attached PHY driver [%s] "
- "(mii_bus:phy_addr=%s)\n",
+ dev_info(&adapter->pdev->dev, "attached PHY driver [%s] (mii_bus:phy_addr=%s)\n",
phydev->drv->name, dev_name(&phydev->dev));
return 0;
@@ -4824,7 +4818,8 @@ static int et131x_open(struct net_device *netdev)
adapter->error_timer.data = (unsigned long)adapter;
add_timer(&adapter->error_timer);
- result = request_irq(irq, et131x_isr, IRQF_SHARED, netdev->name, netdev);
+ result = request_irq(irq, et131x_isr,
+ IRQF_SHARED, netdev->name, netdev);
if (result) {
dev_err(&pdev->dev, "could not register IRQ %d\n", irq);
return result;
@@ -5187,8 +5182,8 @@ static int et131x_set_mac_addr(struct net_device *netdev, void *new_mac)
memcpy(netdev->dev_addr, address->sa_data, netdev->addr_len);
- printk(KERN_INFO "%s: Setting MAC address to %pM\n",
- netdev->name, netdev->dev_addr);
+ netdev_info(netdev, "Setting MAC address to %pM\n",
+ netdev->dev_addr);
/* Free Rx DMA memory */
et131x_adapter_memory_free(adapter);
@@ -5302,7 +5297,7 @@ static int __devinit et131x_pci_setup(struct pci_dev *pdev,
netdev->netdev_ops = &et131x_netdev_ops;
SET_NETDEV_DEV(netdev, &pdev->dev);
- et131x_set_ethtool_ops(netdev);
+ SET_ETHTOOL_OPS(netdev, &et131x_ethtool_ops);
adapter = et131x_adapter_init(netdev, pdev);
@@ -5446,24 +5441,4 @@ static struct pci_driver et131x_driver = {
.driver.pm = ET131X_PM_OPS,
};
-/**
- * et131x_init_module - The "main" entry point called on driver initialization
- *
- * Returns 0 on success, errno on failure (as defined in errno.h)
- */
-static int __init et131x_init_module(void)
-{
- return pci_register_driver(&et131x_driver);
-}
-
-/**
- * et131x_cleanup_module - The entry point called on driver cleanup
- */
-static void __exit et131x_cleanup_module(void)
-{
- pci_unregister_driver(&et131x_driver);
-}
-
-module_init(et131x_init_module);
-module_exit(et131x_cleanup_module);
-
+module_pci_driver(et131x_driver);
diff --git a/drivers/staging/frontier/alphatrack.c b/drivers/staging/frontier/alphatrack.c
index 3bf0f40e97fd..33085782689e 100644
--- a/drivers/staging/frontier/alphatrack.c
+++ b/drivers/staging/frontier/alphatrack.c
@@ -333,8 +333,8 @@ static int usb_alphatrack_open(struct inode *inode, struct file *file)
interface = usb_find_interface(&usb_alphatrack_driver, subminor);
if (!interface) {
- err("%s - error, can't find device for minor %d\n",
- __func__, subminor);
+ pr_err("%s - error, can't find device for minor %d\n",
+ __func__, subminor);
retval = -ENODEV;
goto unlock_disconnect_exit;
}
@@ -494,7 +494,8 @@ static ssize_t usb_alphatrack_read(struct file *file, char __user *buffer,
/* verify that the device wasn't unplugged */
if (dev->intf == NULL) {
retval = -ENODEV;
- err("No device or device unplugged %d\n", retval);
+ pr_err("%s: No device or device unplugged %d\n",
+ __func__, retval);
goto unlock_exit;
}
@@ -564,7 +565,8 @@ static ssize_t usb_alphatrack_write(struct file *file,
/* verify that the device wasn't unplugged */
if (dev->intf == NULL) {
retval = -ENODEV;
- err("No device or device unplugged %d\n", retval);
+ pr_err("%s: No device or device unplugged %d\n",
+ __func__, retval);
goto unlock_exit;
}
@@ -599,7 +601,7 @@ static ssize_t usb_alphatrack_write(struct file *file,
}
if (dev->interrupt_out_endpoint == NULL) {
- err("Endpoint should not be be null!\n");
+ dev_err(&dev->intf->dev, "Endpoint should not be be null!\n");
goto unlock_exit;
}
@@ -619,7 +621,8 @@ static ssize_t usb_alphatrack_write(struct file *file,
retval = usb_submit_urb(dev->interrupt_out_urb, GFP_KERNEL);
if (retval) {
dev->interrupt_out_busy = 0;
- err("Couldn't submit interrupt_out_urb %d\n", retval);
+ dev_err(&dev->intf->dev,
+ "Couldn't submit interrupt_out_urb %d\n", retval);
atomic_dec(&dev->writes_pending);
goto unlock_exit;
}
diff --git a/drivers/staging/frontier/tranzport.c b/drivers/staging/frontier/tranzport.c
index 29e99bbcae48..5196a4e053e6 100644
--- a/drivers/staging/frontier/tranzport.c
+++ b/drivers/staging/frontier/tranzport.c
@@ -353,8 +353,8 @@ static int usb_tranzport_open(struct inode *inode, struct file *file)
interface = usb_find_interface(&usb_tranzport_driver, subminor);
if (!interface) {
- err("%s - error, can't find device for minor %d\n",
- __func__, subminor);
+ pr_err("%s - error, can't find device for minor %d\n",
+ __func__, subminor);
retval = -ENODEV;
goto unlock_disconnect_exit;
}
@@ -517,9 +517,11 @@ static ssize_t usb_tranzport_read(struct file *file, char __user *buffer,
goto exit;
}
- /* verify that the device wasn't unplugged */ if (dev->intf == NULL) {
+ /* verify that the device wasn't unplugged */
+ if (dev->intf == NULL) {
retval = -ENODEV;
- err("No device or device unplugged %d\n", retval);
+ pr_err("%s: No device or device unplugged %d\n",
+ __func__, retval);
goto unlock_exit;
}
@@ -691,7 +693,8 @@ static ssize_t usb_tranzport_write(struct file *file,
/* verify that the device wasn't unplugged */
if (dev->intf == NULL) {
retval = -ENODEV;
- err("No device or device unplugged %d\n", retval);
+ pr_err("%s: No device or device unplugged %d\n",
+ __func__, retval);
goto unlock_exit;
}
@@ -726,7 +729,7 @@ static ssize_t usb_tranzport_write(struct file *file,
}
if (dev->interrupt_out_endpoint == NULL) {
- err("Endpoint should not be be null!\n");
+ dev_err(&dev->intf->dev, "Endpoint should not be be null!\n");
goto unlock_exit;
}
@@ -746,7 +749,8 @@ static ssize_t usb_tranzport_write(struct file *file,
retval = usb_submit_urb(dev->interrupt_out_urb, GFP_KERNEL);
if (retval) {
dev->interrupt_out_busy = 0;
- err("Couldn't submit interrupt_out_urb %d\n", retval);
+ dev_err(&dev->intf->dev,
+ "Couldn't submit interrupt_out_urb %d\n", retval);
goto unlock_exit;
}
retval = bytes_to_write;
diff --git a/drivers/staging/ft1000/ft1000-pcmcia/ft1000_hw.c b/drivers/staging/ft1000/ft1000-pcmcia/ft1000_hw.c
index c4a8a0a26eb5..86a680c09ba2 100644
--- a/drivers/staging/ft1000/ft1000-pcmcia/ft1000_hw.c
+++ b/drivers/staging/ft1000/ft1000-pcmcia/ft1000_hw.c
@@ -97,11 +97,10 @@ static inline u16 ft1000_read_fifo_len(struct net_device *dev)
{
struct ft1000_info *info = netdev_priv(dev);
- if (info->AsicID == ELECTRABUZZ_ID) {
+ if (info->AsicID == ELECTRABUZZ_ID)
return (ft1000_read_reg(dev, FT1000_REG_UFIFO_STAT) - 16);
- } else {
+ else
return (ft1000_read_reg(dev, FT1000_REG_MAG_UFSR) - 16);
- }
}
//---------------------------------------------------------------------------
@@ -116,7 +115,7 @@ static inline u16 ft1000_read_fifo_len(struct net_device *dev)
// value - value of dpram
//
//---------------------------------------------------------------------------
-u16 ft1000_read_dpram(struct net_device * dev, int offset)
+u16 ft1000_read_dpram(struct net_device *dev, int offset)
{
struct ft1000_info *info = netdev_priv(dev);
unsigned long flags;
@@ -1997,42 +1996,43 @@ static irqreturn_t ft1000_interrupt(int irq, void *dev_id)
inttype = ft1000_read_reg(dev, FT1000_REG_SUP_ISR);
// Make sure we process all interrupt before leaving the ISR due to the edge trigger interrupt type
- while (inttype) {
- if (inttype & ISR_DOORBELL_PEND) {
- ft1000_parse_dpram_msg(dev);
- }
+ while (inttype) {
+ if (inttype & ISR_DOORBELL_PEND)
+ ft1000_parse_dpram_msg(dev);
- if (inttype & ISR_RCV) {
- DEBUG(1, "Data in FIFO\n");
+ if (inttype & ISR_RCV) {
+ DEBUG(1, "Data in FIFO\n");
- cnt = 0;
- do {
- // Check if we have packets in the Downlink FIFO
- if (info->AsicID == ELECTRABUZZ_ID) {
- tempword =
- ft1000_read_reg(dev, FT1000_REG_DFIFO_STAT);
- } else {
- tempword =
- ft1000_read_reg(dev, FT1000_REG_MAG_DFSR);
- }
- if (tempword & 0x1f) {
- ft1000_copy_up_pkt(dev);
- } else {
- break;
- }
- cnt++;
- } while (cnt < MAX_RCV_LOOP);
+ cnt = 0;
+ do {
+ // Check if we have packets in the Downlink FIFO
+ if (info->AsicID == ELECTRABUZZ_ID) {
+ tempword =
+ ft1000_read_reg(dev,
+ FT1000_REG_DFIFO_STAT);
+ } else {
+ tempword =
+ ft1000_read_reg(dev,
+ FT1000_REG_MAG_DFSR);
+ }
+ if (tempword & 0x1f) {
+ ft1000_copy_up_pkt(dev);
+ } else {
+ break;
+ }
+ cnt++;
+ } while (cnt < MAX_RCV_LOOP);
+ }
+ // clear interrupts
+ tempword = ft1000_read_reg(dev, FT1000_REG_SUP_ISR);
+ DEBUG(1, "ft1000_hw: interrupt status register = 0x%x\n", tempword);
+ ft1000_write_reg(dev, FT1000_REG_SUP_ISR, tempword);
+
+ // Read interrupt type
+ inttype = ft1000_read_reg (dev, FT1000_REG_SUP_ISR);
+ DEBUG(1,"ft1000_hw: interrupt status register after clear = 0x%x\n",inttype);
}
- // clear interrupts
- tempword = ft1000_read_reg(dev, FT1000_REG_SUP_ISR);
- DEBUG(1, "ft1000_hw: interrupt status register = 0x%x\n", tempword);
- ft1000_write_reg(dev, FT1000_REG_SUP_ISR, tempword);
-
- // Read interrupt type
- inttype = ft1000_read_reg (dev, FT1000_REG_SUP_ISR);
- DEBUG(1,"ft1000_hw: interrupt status register after clear = 0x%x\n",inttype);
- }
ft1000_enable_interrupts(dev);
return IRQ_HANDLED;
}
diff --git a/drivers/staging/ft1000/ft1000-pcmcia/ft1000_proc.c b/drivers/staging/ft1000/ft1000-pcmcia/ft1000_proc.c
index 71aaad31270b..72727c6b9e2e 100644
--- a/drivers/staging/ft1000/ft1000-pcmcia/ft1000_proc.c
+++ b/drivers/staging/ft1000/ft1000-pcmcia/ft1000_proc.c
@@ -34,16 +34,14 @@
#define PUTX_TO_PAGE(len, page, message, size, var) \
len += snprintf(page+len, PAGE_SIZE - len, message); \
- for(i = 0; i < (size - 1); i++) \
- { \
+ for(i = 0; i < (size - 1); i++) { \
len += snprintf(page+len, PAGE_SIZE - len, "%02x:", var[i]); \
} \
len += snprintf(page+len, PAGE_SIZE - len, "%02x\n", var[i])
#define PUTD_TO_PAGE(len, page, message, size, var) \
len += snprintf(page+len, PAGE_SIZE - len, message); \
- for(i = 0; i < (size - 1); i++) \
- { \
+ for(i = 0; i < (size - 1); i++) { \
len += snprintf(page+len, PAGE_SIZE - len, "%d.", var[i]); \
} \
len += snprintf(page+len, PAGE_SIZE - len, "%d\n", var[i])
@@ -55,8 +53,8 @@ static int ft1000ReadProc(char *page, char **start, off_t off,
int len;
int i;
struct ft1000_info *info;
- char *status[] =
- { "Idle (Disconnect)", "Searching", "Active (Connected)",
+ char *status[] = {
+ "Idle (Disconnect)", "Searching", "Active (Connected)",
"Waiting for L2", "Sleep", "No Coverage", "", ""
};
char *signal[] = { "", "*", "**", "***", "****" };
diff --git a/drivers/staging/ft1000/ft1000-usb/ft1000_debug.c b/drivers/staging/ft1000/ft1000-usb/ft1000_debug.c
index 19db23fe73ca..6d911fda47fb 100644
--- a/drivers/staging/ft1000/ft1000-usb/ft1000_debug.c
+++ b/drivers/staging/ft1000/ft1000-usb/ft1000_debug.c
@@ -167,7 +167,7 @@ int ft1000_create_dev(struct ft1000_device *dev)
goto fail;
}
- dir = debugfs_create_dir(info->DeviceName, 0);
+ dir = debugfs_create_dir(info->DeviceName, NULL);
if (IS_ERR(dir)) {
result = PTR_ERR(dir);
goto debug_dir_fail;
diff --git a/drivers/staging/ft1000/ft1000-usb/ft1000_hw.c b/drivers/staging/ft1000/ft1000-usb/ft1000_hw.c
index 43b1d363107e..31929ef5332d 100644
--- a/drivers/staging/ft1000/ft1000-usb/ft1000_hw.c
+++ b/drivers/staging/ft1000/ft1000-usb/ft1000_hw.c
@@ -1178,7 +1178,6 @@ static int ft1000_open(struct net_device *dev)
{
struct ft1000_info *pInfo = netdev_priv(dev);
struct timeval tv;
- int ret;
DEBUG("ft1000_open is called for card %d\n", pInfo->CardNumber);
@@ -1194,9 +1193,7 @@ static int ft1000_open(struct net_device *dev)
netif_carrier_on(dev);
- ret = ft1000_submit_rx_urb(pInfo);
-
- return ret;
+ return ft1000_submit_rx_urb(pInfo);
}
//---------------------------------------------------------------------------
@@ -1754,8 +1751,8 @@ out:
return status;
}
-int ft1000_poll(void* dev_id) {
-
+int ft1000_poll(void* dev_id)
+{
struct ft1000_device *dev = (struct ft1000_device *)dev_id;
struct ft1000_info *info = netdev_priv(dev->net);
diff --git a/drivers/staging/ft1000/ft1000-usb/ft1000_usb.c b/drivers/staging/ft1000/ft1000-usb/ft1000_usb.c
index 84c38d5c9397..b2ecd0e6780e 100644
--- a/drivers/staging/ft1000/ft1000-usb/ft1000_usb.c
+++ b/drivers/staging/ft1000/ft1000-usb/ft1000_usb.c
@@ -37,9 +37,9 @@ static struct usb_device_id id_table[] = {
MODULE_DEVICE_TABLE(usb, id_table);
static bool gPollingfailed = FALSE;
-int ft1000_poll_thread(void *arg)
+static int ft1000_poll_thread(void *arg)
{
- int ret = STATUS_SUCCESS;
+ int ret;
while (!kthread_should_stop()) {
msleep(10);
@@ -67,15 +67,13 @@ static int ft1000_probe(struct usb_interface *interface,
struct ft1000_info *pft1000info = NULL;
const struct firmware *dsp_fw;
- ft1000dev = kmalloc(sizeof(struct ft1000_device), GFP_KERNEL);
+ ft1000dev = kzalloc(sizeof(struct ft1000_device), GFP_KERNEL);
if (!ft1000dev) {
- printk(KERN_ERR "out of memory allocating device structure\n");
- return 0;
+ pr_err("out of memory allocating device structure\n");
+ return -ENOMEM;
}
- memset(ft1000dev, 0, sizeof(*ft1000dev));
-
dev = interface_to_usbdev(interface);
DEBUG("ft1000_probe: usb device descriptor info:\n");
DEBUG("ft1000_probe: number of configuration is %d\n",
@@ -140,7 +138,7 @@ static int ft1000_probe(struct usb_interface *interface,
ret = request_firmware(&dsp_fw, "ft3000.img", &dev->dev);
if (ret < 0) {
- printk(KERN_ERR "Error request_firmware().\n");
+ pr_err("Error request_firmware().\n");
goto err_fw;
}
@@ -168,7 +166,7 @@ static int ft1000_probe(struct usb_interface *interface,
DEBUG("In probe: pft1000info=%p\n", pft1000info);
ret = dsp_reload(ft1000dev);
if (ret) {
- printk(KERN_ERR "Problem with DSP image loading\n");
+ pr_err("Problem with DSP image loading\n");
goto err_load;
}
@@ -239,7 +237,7 @@ static void ft1000_disconnect(struct usb_interface *interface)
ft1000_destroy_dev(pft1000info->pFt1000Dev->net);
unregister_netdev(pft1000info->pFt1000Dev->net);
DEBUG
- ("ft1000_disconnect: network device unregisterd\n");
+ ("ft1000_disconnect: network device unregistered\n");
free_netdev(pft1000info->pFt1000Dev->net);
}
diff --git a/drivers/staging/ft1000/ft1000-usb/ft1000_usb.h b/drivers/staging/ft1000/ft1000-usb/ft1000_usb.h
index 51c084756b4a..642bb89942f5 100644
--- a/drivers/staging/ft1000/ft1000-usb/ft1000_usb.h
+++ b/drivers/staging/ft1000/ft1000-usb/ft1000_usb.h
@@ -1,7 +1,6 @@
#ifndef _FT1000_USB_H_
#define _FT1000_USB_H_
-/*Jim*/
#include "../ft1000.h"
#include "ft1000_ioctl.h"
#define FT1000_DRV_VER 0x01010403
@@ -15,19 +14,18 @@
#define SUCCESS 0x00
struct app_info_block {
- u32 nTxMsg; // DPRAM msg sent to DSP with app_id
- u32 nRxMsg; // DPRAM msg rcv from dsp with app_id
- u32 nTxMsgReject; // DPRAM msg rejected due to DSP doorbell set
- u32 nRxMsgMiss; // DPRAM msg dropped due to overflow
- struct fown_struct *fileobject;// Application's file object
- u16 app_id; // Application id
+ u32 nTxMsg; /* DPRAM msg sent to DSP with app_id */
+ u32 nRxMsg; /* DPRAM msg rcv from dsp with app_id */
+ u32 nTxMsgReject; /* DPRAM msg rejected due to DSP doorbell set */
+ u32 nRxMsgMiss; /* DPRAM msg dropped due to overflow */
+ struct fown_struct *fileobject;/* Application's file object */
+ u16 app_id; /* Application id */
int DspBCMsgFlag;
- int NumOfMsg; // number of messages queued up
+ int NumOfMsg; /* number of messages queued up */
wait_queue_head_t wait_dpram_msg;
- struct list_head app_sqlist; // link list of msgs for applicaton on slow queue
-} __attribute__((packed));
+ struct list_head app_sqlist; /* link list of msgs for applicaton on slow queue */
+} __packed;
-/*end of Jim*/
#define DEBUG(args...) printk(KERN_INFO args)
#define FALSE 0
@@ -47,20 +45,19 @@ struct app_info_block {
#undef FT1000_DPRAM_RX_BASE
#define FT1000_DPRAM_RX_BASE 0x1800 /* RX AREA (SlowQ) */
-// MEMORY MAP FOR MAGNEMITE
+/* MEMORY MAP FOR MAGNEMITE */
/* the indexes are swapped comparing to PCMCIA - is it OK or a bug? */
#undef FT1000_MAG_DSP_LED_INDX
#define FT1000_MAG_DSP_LED_INDX 0x1 /* dsp led status for PAD device */
#undef FT1000_MAG_DSP_CON_STATE_INDX
#define FT1000_MAG_DSP_CON_STATE_INDX 0x0 /* DSP Connection Status Info */
-// Maximum times trying to get ASIC out of reset
+/* Maximum times trying to get ASIC out of reset */
#define MAX_ASIC_RESET_CNT 20
#define MAX_BUF_SIZE 4096
-struct ft1000_device
-{
+struct ft1000_device {
struct usb_device *dev;
struct net_device *net;
@@ -74,11 +71,7 @@ struct ft1000_device
u8 bulk_in_endpointAddr;
u8 bulk_out_endpointAddr;
-
- //struct ft1000_ethernet_configuration configuration;
-
-// struct net_device_stats stats; //mbelian
-} __attribute__ ((packed));
+} __packed;
struct ft1000_debug_dirs {
struct list_head list;
@@ -88,90 +81,101 @@ struct ft1000_debug_dirs {
};
struct ft1000_info {
- struct ft1000_device *pFt1000Dev;
- struct net_device_stats stats;
+ struct ft1000_device *pFt1000Dev;
+ struct net_device_stats stats;
- struct task_struct *pPollThread;
+ struct task_struct *pPollThread;
- unsigned char fcodeldr;
- unsigned char bootmode;
+ unsigned char fcodeldr;
+ unsigned char bootmode;
unsigned char usbboot;
- unsigned short dspalive;
- u16 ASIC_ID;
- bool fProvComplete;
- bool fCondResetPend;
- bool fAppMsgPend;
- u16 DrvErrNum;
- u16 AsicID;
- int DspAsicReset;
- int DeviceCreated;
- int CardReady;
- int NetDevRegDone;
- u8 CardNumber;
- u8 DeviceName[15];
- struct ft1000_debug_dirs nodes;
- int registered;
- int mediastate;
- u8 squeseqnum; // sequence number on slow queue
- spinlock_t dpram_lock;
- spinlock_t fifo_lock;
- u16 fifo_cnt;
- u8 DspVer[DSPVERSZ]; // DSP version number
- u8 HwSerNum[HWSERNUMSZ]; // Hardware Serial Number
- u8 Sku[SKUSZ]; // SKU
- u8 eui64[EUISZ]; // EUI64
- time_t ConTm; // Connection Time
- u8 ProductMode[MODESZ];
- u8 RfCalVer[CALVERSZ];
- u8 RfCalDate[CALDATESZ];
- u16 DSP_TIME[4];
- u16 LedStat; //mbelian
- u16 ConStat; //mbelian
- u16 ProgConStat;
- struct list_head prov_list;
- int appcnt;
+ unsigned short dspalive;
+ u16 ASIC_ID;
+ bool fProvComplete;
+ bool fCondResetPend;
+ bool fAppMsgPend;
+ u16 DrvErrNum;
+ u16 AsicID;
+ int DspAsicReset;
+ int DeviceCreated;
+ int CardReady;
+ int NetDevRegDone;
+ u8 CardNumber;
+ u8 DeviceName[15];
+ struct ft1000_debug_dirs nodes;
+ int registered;
+ int mediastate;
+ u8 squeseqnum; /* sequence number on slow queue */
+ spinlock_t dpram_lock;
+ spinlock_t fifo_lock;
+ u16 fifo_cnt;
+ u8 DspVer[DSPVERSZ]; /* DSP version number */
+ u8 HwSerNum[HWSERNUMSZ]; /* Hardware Serial Number */
+ u8 Sku[SKUSZ]; /* SKU */
+ u8 eui64[EUISZ]; /* EUI64 */
+ time_t ConTm; /* Connection Time */
+ u8 ProductMode[MODESZ];
+ u8 RfCalVer[CALVERSZ];
+ u8 RfCalDate[CALDATESZ];
+ u16 DSP_TIME[4];
+ u16 LedStat;
+ u16 ConStat;
+ u16 ProgConStat;
+ struct list_head prov_list;
+ int appcnt;
struct app_info_block app_info[MAX_NUM_APP];
- u16 DSPInfoBlklen;
- u16 DrvMsgPend;
- int (*ft1000_reset)(struct net_device *dev);
- u16 DSPInfoBlk[MAX_DSP_SESS_REC];
- union {
- u16 Rec[MAX_DSP_SESS_REC];
- u32 MagRec[MAX_DSP_SESS_REC/2];
- } DSPSess;
+ u16 DSPInfoBlklen;
+ u16 DrvMsgPend;
+ int (*ft1000_reset)(struct net_device *dev);
+ u16 DSPInfoBlk[MAX_DSP_SESS_REC];
+ union {
+ u16 Rec[MAX_DSP_SESS_REC];
+ u32 MagRec[MAX_DSP_SESS_REC/2];
+ } DSPSess;
unsigned short tempbuf[32];
char netdevname[IFNAMSIZ];
- struct proc_dir_entry *ft1000_proc_dir; //mbelian
+ struct proc_dir_entry *ft1000_proc_dir;
};
struct dpram_blk {
- struct list_head list;
- u16 *pbuffer;
-} __attribute__ ((packed));
-
-int ft1000_read_register(struct ft1000_device *ft1000dev, u16* Data, u16 nRegIndx);
-int ft1000_write_register(struct ft1000_device *ft1000dev, u16 value, u16 nRegIndx);
-int ft1000_read_dpram32(struct ft1000_device *ft1000dev, u16 indx, u8 *buffer, u16 cnt);
-int ft1000_write_dpram32(struct ft1000_device *ft1000dev, u16 indx, u8 *buffer, u16 cnt);
-int ft1000_read_dpram16(struct ft1000_device *ft1000dev, u16 indx, u8 *buffer, u8 highlow);
-int ft1000_write_dpram16(struct ft1000_device *ft1000dev, u16 indx, u16 value, u8 highlow);
-int fix_ft1000_read_dpram32(struct ft1000_device *ft1000dev, u16 indx, u8 *buffer);
-int fix_ft1000_write_dpram32(struct ft1000_device *ft1000dev, u16 indx, u8 *buffer);
+ struct list_head list;
+ u16 *pbuffer;
+} __packed;
+
+int ft1000_read_register(struct ft1000_device *ft1000dev,
+ u16 *Data, u16 nRegIndx);
+int ft1000_write_register(struct ft1000_device *ft1000dev,
+ u16 value, u16 nRegIndx);
+int ft1000_read_dpram32(struct ft1000_device *ft1000dev,
+ u16 indx, u8 *buffer, u16 cnt);
+int ft1000_write_dpram32(struct ft1000_device *ft1000dev,
+ u16 indx, u8 *buffer, u16 cnt);
+int ft1000_read_dpram16(struct ft1000_device *ft1000dev,
+ u16 indx, u8 *buffer, u8 highlow);
+int ft1000_write_dpram16(struct ft1000_device *ft1000dev,
+ u16 indx, u16 value, u8 highlow);
+int fix_ft1000_read_dpram32(struct ft1000_device *ft1000dev,
+ u16 indx, u8 *buffer);
+int fix_ft1000_write_dpram32(struct ft1000_device *ft1000dev,
+ u16 indx, u8 *buffer);
extern void *pFileStart;
extern size_t FileLength;
extern int numofmsgbuf;
-int ft1000_close (struct net_device *dev);
-u16 scram_dnldr(struct ft1000_device *ft1000dev, void *pFileStart, u32 FileLength);
+int ft1000_close(struct net_device *dev);
+u16 scram_dnldr(struct ft1000_device *ft1000dev, void *pFileStart,
+ u32 FileLength);
extern struct list_head freercvpool;
-extern spinlock_t free_buff_lock; // lock to arbitrate free buffer list for receive command data
+
+extern spinlock_t free_buff_lock; /* lock to arbitrate free buffer list for receive command data */
int ft1000_create_dev(struct ft1000_device *dev);
void ft1000_destroy_dev(struct net_device *dev);
-extern void card_send_command(struct ft1000_device *ft1000dev, void *ptempbuffer, int size);
+extern void card_send_command(struct ft1000_device *ft1000dev,
+ void *ptempbuffer, int size);
struct dpram_blk *ft1000_get_buffer(struct list_head *bufflist);
void ft1000_free_buffer(struct dpram_blk *pdpram_blk, struct list_head *plist);
@@ -179,8 +183,9 @@ void ft1000_free_buffer(struct dpram_blk *pdpram_blk, struct list_head *plist);
int dsp_reload(struct ft1000_device *ft1000dev);
int init_ft1000_netdev(struct ft1000_device *ft1000dev);
struct usb_interface;
-int reg_ft1000_netdev(struct ft1000_device *ft1000dev, struct usb_interface *intf);
-int ft1000_poll(void* dev_id);
+int reg_ft1000_netdev(struct ft1000_device *ft1000dev,
+ struct usb_interface *intf);
+int ft1000_poll(void *dev_id);
int ft1000_init_proc(struct net_device *dev);
void ft1000_cleanup_proc(struct ft1000_info *info);
diff --git a/drivers/staging/gdm72xx/Kconfig b/drivers/staging/gdm72xx/Kconfig
new file mode 100644
index 000000000000..3c18efe31365
--- /dev/null
+++ b/drivers/staging/gdm72xx/Kconfig
@@ -0,0 +1,46 @@
+#
+# GCT GDM72xx WiMAX driver configuration
+#
+
+menuconfig WIMAX_GDM72XX
+ tristate "GCT GDM72xx WiMAX support"
+ depends on NET
+ help
+ Support for the GCT GDM72xx WiMAX chip
+
+if WIMAX_GDM72XX
+
+config WIMAX_GDM72XX_QOS
+ bool "Enable QoS support"
+ default n
+
+config WIMAX_GDM72XX_K_MODE
+ bool "Enable K mode"
+ default n
+
+config WIMAX_GDM72XX_WIMAX2
+ bool "Enable WIMAX2 support"
+ default n
+
+choice
+ prompt "Select interface"
+
+config WIMAX_GDM72XX_USB
+ bool "USB interface"
+ depends on USB
+
+config WIMAX_GDM72XX_SDIO
+ bool "SDIO interface"
+ depends on MMC
+
+endchoice
+
+if WIMAX_GDM72XX_USB
+
+config WIMAX_GDM72XX_USB_PM
+ bool "Enable power managerment support"
+ depends on USB_SUSPEND
+
+endif # WIMAX_GDM72XX_USB
+
+endif # WIMAX_GDM72XX
diff --git a/drivers/staging/gdm72xx/Makefile b/drivers/staging/gdm72xx/Makefile
new file mode 100644
index 000000000000..35da7b90b19b
--- /dev/null
+++ b/drivers/staging/gdm72xx/Makefile
@@ -0,0 +1,6 @@
+obj-$(CONFIG_WIMAX_GDM72XX) := gdmwm.o
+
+gdmwm-y += gdm_wimax.o netlink_k.o
+gdmwm-$(CONFIG_WIMAX_GDM72XX_QOS) += gdm_qos.o
+gdmwm-$(CONFIG_WIMAX_GDM72XX_SDIO) += gdm_sdio.o sdio_boot.o
+gdmwm-$(CONFIG_WIMAX_GDM72XX_USB) += gdm_usb.o usb_boot.o
diff --git a/drivers/staging/gdm72xx/TODO b/drivers/staging/gdm72xx/TODO
new file mode 100644
index 000000000000..30ac01ab972f
--- /dev/null
+++ b/drivers/staging/gdm72xx/TODO
@@ -0,0 +1,5 @@
+TODO:
+- Replace kernel_thread with kthread in gdm_usb.c
+- Replace hard-coded firmware paths with request_firmware in
+ sdio_boot.c and usb_boot.c
+- Clean up coding style to meet kernel standard.
diff --git a/drivers/staging/gdm72xx/gdm_qos.c b/drivers/staging/gdm72xx/gdm_qos.c
new file mode 100644
index 000000000000..80bde053fbc2
--- /dev/null
+++ b/drivers/staging/gdm72xx/gdm_qos.c
@@ -0,0 +1,458 @@
+/*
+ * Copyright (c) 2012 GCT Semiconductor, Inc. All rights reserved.
+ *
+ * This software is licensed under the terms of the GNU General Public
+ * License version 2, as published by the Free Software Foundation, and
+ * may be copied, distributed, and modified under those terms.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+
+#include <linux/etherdevice.h>
+#include <asm/byteorder.h>
+
+#include <linux/ip.h>
+#include <linux/tcp.h>
+#include <linux/if_ether.h>
+
+#include "gdm_wimax.h"
+#include "hci.h"
+#include "gdm_qos.h"
+
+#define B2H(x) __be16_to_cpu(x)
+
+#undef dprintk
+#define dprintk(fmt, args ...) printk(KERN_DEBUG "[QoS] " fmt, ## args)
+#undef wprintk
+#define wprintk(fmt, args ...) \
+ printk(KERN_WARNING "[QoS WARNING] " fmt, ## args)
+#undef eprintk
+#define eprintk(fmt, args ...) printk(KERN_ERR "[QoS ERROR] " fmt, ## args)
+
+
+#define MAX_FREE_LIST_CNT 32
+static struct {
+ struct list_head head;
+ int cnt;
+ spinlock_t lock;
+} qos_free_list;
+
+static void init_qos_entry_list(void)
+{
+ qos_free_list.cnt = 0;
+ INIT_LIST_HEAD(&qos_free_list.head);
+ spin_lock_init(&qos_free_list.lock);
+}
+
+static void *alloc_qos_entry(void)
+{
+ struct qos_entry_s *entry;
+ unsigned long flags;
+
+ spin_lock_irqsave(&qos_free_list.lock, flags);
+ if (qos_free_list.cnt) {
+ entry = list_entry(qos_free_list.head.prev, struct qos_entry_s,
+ list);
+ list_del(&entry->list);
+ qos_free_list.cnt--;
+ spin_unlock_irqrestore(&qos_free_list.lock, flags);
+ return entry;
+ }
+ spin_unlock_irqrestore(&qos_free_list.lock, flags);
+
+ entry = kmalloc(sizeof(struct qos_entry_s), GFP_ATOMIC);
+ return entry;
+}
+
+static void free_qos_entry(void *entry)
+{
+ struct qos_entry_s *qentry = (struct qos_entry_s *) entry;
+ unsigned long flags;
+
+ spin_lock_irqsave(&qos_free_list.lock, flags);
+ if (qos_free_list.cnt < MAX_FREE_LIST_CNT) {
+ list_add(&qentry->list, &qos_free_list.head);
+ qos_free_list.cnt++;
+ spin_unlock_irqrestore(&qos_free_list.lock, flags);
+ return;
+ }
+ spin_unlock_irqrestore(&qos_free_list.lock, flags);
+
+ kfree(entry);
+}
+
+static void free_qos_entry_list(struct list_head *free_list)
+{
+ struct qos_entry_s *entry, *n;
+ int total_free = 0;
+
+ list_for_each_entry_safe(entry, n, free_list, list) {
+ list_del(&entry->list);
+ kfree(entry);
+ total_free++;
+ }
+
+ dprintk("%s: total_free_cnt=%d\n", __func__, total_free);
+}
+
+void gdm_qos_init(void *nic_ptr)
+{
+ struct nic *nic = nic_ptr;
+ struct qos_cb_s *qcb = &nic->qos;
+ int i;
+
+ for (i = 0 ; i < QOS_MAX; i++) {
+ INIT_LIST_HEAD(&qcb->qos_list[i]);
+ qcb->csr[i].QoSBufCount = 0;
+ qcb->csr[i].Enabled = 0;
+ }
+
+ qcb->qos_list_cnt = 0;
+ qcb->qos_null_idx = QOS_MAX-1;
+ qcb->qos_limit_size = 255;
+
+ spin_lock_init(&qcb->qos_lock);
+
+ init_qos_entry_list();
+}
+
+void gdm_qos_release_list(void *nic_ptr)
+{
+ struct nic *nic = nic_ptr;
+ struct qos_cb_s *qcb = &nic->qos;
+ unsigned long flags;
+ struct qos_entry_s *entry, *n;
+ struct list_head free_list;
+ int i;
+
+ INIT_LIST_HEAD(&free_list);
+
+ spin_lock_irqsave(&qcb->qos_lock, flags);
+
+ for (i = 0; i < QOS_MAX; i++) {
+ qcb->csr[i].QoSBufCount = 0;
+ qcb->csr[i].Enabled = 0;
+ }
+
+ qcb->qos_list_cnt = 0;
+ qcb->qos_null_idx = QOS_MAX-1;
+
+ for (i = 0; i < QOS_MAX; i++) {
+ list_for_each_entry_safe(entry, n, &qcb->qos_list[i], list) {
+ list_move_tail(&entry->list, &free_list);
+ }
+ }
+ spin_unlock_irqrestore(&qcb->qos_lock, flags);
+ free_qos_entry_list(&free_list);
+}
+
+static u32 chk_ipv4_rule(struct gdm_wimax_csr_s *csr, u8 *Stream, u8 *port)
+{
+ int i;
+
+ if (csr->ClassifierRuleEnable&IPTYPEOFSERVICE) {
+ if (((Stream[1] & csr->IPToSMask) < csr->IPToSLow) ||
+ ((Stream[1] & csr->IPToSMask) > csr->IPToSHigh))
+ return 1;
+ }
+
+ if (csr->ClassifierRuleEnable&PROTOCOL) {
+ if (Stream[9] != csr->Protocol)
+ return 1;
+ }
+
+ if (csr->ClassifierRuleEnable&IPMASKEDSRCADDRESS) {
+ for (i = 0; i < 4; i++) {
+ if ((Stream[12 + i] & csr->IPSrcAddrMask[i]) !=
+ (csr->IPSrcAddr[i] & csr->IPSrcAddrMask[i]))
+ return 1;
+ }
+ }
+
+ if (csr->ClassifierRuleEnable&IPMASKEDDSTADDRESS) {
+ for (i = 0; i < 4; i++) {
+ if ((Stream[16 + i] & csr->IPDstAddrMask[i]) !=
+ (csr->IPDstAddr[i] & csr->IPDstAddrMask[i]))
+ return 1;
+ }
+ }
+
+ if (csr->ClassifierRuleEnable&PROTOCOLSRCPORTRANGE) {
+ i = ((port[0]<<8)&0xff00)+port[1];
+ if ((i < csr->SrcPortLow) || (i > csr->SrcPortHigh))
+ return 1;
+ }
+
+ if (csr->ClassifierRuleEnable&PROTOCOLDSTPORTRANGE) {
+ i = ((port[2]<<8)&0xff00)+port[3];
+ if ((i < csr->DstPortLow) || (i > csr->DstPortHigh))
+ return 1;
+ }
+
+ return 0;
+}
+
+static u32 get_qos_index(struct nic *nic, u8 *iph, u8 *tcpudph)
+{
+ u32 IP_Ver, Header_Len, i;
+ struct qos_cb_s *qcb = &nic->qos;
+
+ if (iph == NULL || tcpudph == NULL)
+ return -1;
+
+ IP_Ver = (iph[0]>>4)&0xf;
+ Header_Len = iph[0]&0xf;
+
+ if (IP_Ver == 4) {
+ for (i = 0; i < QOS_MAX; i++) {
+ if (qcb->csr[i].Enabled) {
+ if (qcb->csr[i].ClassifierRuleEnable) {
+ if (chk_ipv4_rule(&qcb->csr[i], iph,
+ tcpudph) == 0)
+ return i;
+ }
+ }
+ }
+ }
+
+ return -1;
+}
+
+static u32 extract_qos_list(struct nic *nic, struct list_head *head)
+{
+ struct qos_cb_s *qcb = &nic->qos;
+ struct qos_entry_s *entry;
+ int i;
+
+ INIT_LIST_HEAD(head);
+
+ for (i = 0; i < QOS_MAX; i++) {
+ if (qcb->csr[i].Enabled) {
+ if (qcb->csr[i].QoSBufCount < qcb->qos_limit_size) {
+ if (!list_empty(&qcb->qos_list[i])) {
+ entry = list_entry(
+ qcb->qos_list[i].prev,
+ struct qos_entry_s, list);
+ list_move_tail(&entry->list, head);
+ qcb->csr[i].QoSBufCount++;
+
+ if (!list_empty(&qcb->qos_list[i]))
+ wprintk("QoS Index(%d) is piled!!\n", i);
+ }
+ }
+ }
+ }
+
+ return 0;
+}
+
+static void send_qos_list(struct nic *nic, struct list_head *head)
+{
+ struct qos_entry_s *entry, *n;
+
+ list_for_each_entry_safe(entry, n, head, list) {
+ list_del(&entry->list);
+ free_qos_entry(entry);
+ gdm_wimax_send_tx(entry->skb, entry->dev);
+ }
+}
+
+int gdm_qos_send_hci_pkt(struct sk_buff *skb, struct net_device *dev)
+{
+ struct nic *nic = netdev_priv(dev);
+ int index;
+ struct qos_cb_s *qcb = &nic->qos;
+ unsigned long flags;
+ struct ethhdr *ethh = (struct ethhdr *) (skb->data + HCI_HEADER_SIZE);
+ struct iphdr *iph = (struct iphdr *) ((char *) ethh + ETH_HLEN);
+ struct tcphdr *tcph;
+ struct qos_entry_s *entry = NULL;
+ struct list_head send_list;
+ int ret = 0;
+
+ tcph = (struct tcphdr *) iph + iph->ihl*4;
+
+ if (B2H(ethh->h_proto) == ETH_P_IP) {
+ if (qcb->qos_list_cnt && !qos_free_list.cnt) {
+ entry = alloc_qos_entry();
+ entry->skb = skb;
+ entry->dev = dev;
+ dprintk("qcb->qos_list_cnt=%d\n", qcb->qos_list_cnt);
+ }
+
+ spin_lock_irqsave(&qcb->qos_lock, flags);
+ if (qcb->qos_list_cnt) {
+ index = get_qos_index(nic, (u8 *)iph, (u8 *) tcph);
+ if (index == -1)
+ index = qcb->qos_null_idx;
+
+ if (!entry) {
+ entry = alloc_qos_entry();
+ entry->skb = skb;
+ entry->dev = dev;
+ }
+
+ list_add_tail(&entry->list, &qcb->qos_list[index]);
+ extract_qos_list(nic, &send_list);
+ spin_unlock_irqrestore(&qcb->qos_lock, flags);
+ send_qos_list(nic, &send_list);
+ goto out;
+ }
+ spin_unlock_irqrestore(&qcb->qos_lock, flags);
+ if (entry)
+ free_qos_entry(entry);
+ }
+
+ ret = gdm_wimax_send_tx(skb, dev);
+out:
+ return ret;
+}
+
+static u32 get_csr(struct qos_cb_s *qcb, u32 SFID, int mode)
+{
+ int i;
+
+ for (i = 0; i < qcb->qos_list_cnt; i++) {
+ if (qcb->csr[i].SFID == SFID)
+ return i;
+ }
+
+ if (mode) {
+ for (i = 0; i < QOS_MAX; i++) {
+ if (qcb->csr[i].Enabled == 0) {
+ qcb->csr[i].Enabled = 1;
+ qcb->qos_list_cnt++;
+ return i;
+ }
+ }
+ }
+ return -1;
+}
+
+#define QOS_CHANGE_DEL 0xFC
+#define QOS_ADD 0xFD
+#define QOS_REPORT 0xFE
+
+void gdm_recv_qos_hci_packet(void *nic_ptr, u8 *buf, int size)
+{
+ struct nic *nic = nic_ptr;
+ u32 i, SFID, index, pos;
+ u8 subCmdEvt;
+ u8 len;
+ struct qos_cb_s *qcb = &nic->qos;
+ struct qos_entry_s *entry, *n;
+ struct list_head send_list;
+ struct list_head free_list;
+ unsigned long flags;
+
+ subCmdEvt = (u8)buf[4];
+
+ if (subCmdEvt == QOS_REPORT) {
+ len = (u8)buf[5];
+
+ spin_lock_irqsave(&qcb->qos_lock, flags);
+ for (i = 0; i < qcb->qos_list_cnt; i++) {
+ SFID = ((buf[(i*5)+6]<<24)&0xff000000);
+ SFID += ((buf[(i*5)+7]<<16)&0xff0000);
+ SFID += ((buf[(i*5)+8]<<8)&0xff00);
+ SFID += (buf[(i*5)+9]);
+ index = get_csr(qcb, SFID, 0);
+ if (index == -1) {
+ spin_unlock_irqrestore(&qcb->qos_lock, flags);
+ eprintk("QoS ERROR: No SF\n");
+ return;
+ }
+ qcb->csr[index].QoSBufCount = buf[(i*5)+10];
+ }
+
+ extract_qos_list(nic, &send_list);
+ spin_unlock_irqrestore(&qcb->qos_lock, flags);
+ send_qos_list(nic, &send_list);
+ return;
+ } else if (subCmdEvt == QOS_ADD) {
+ pos = 5;
+ len = (u8)buf[pos++];
+
+ SFID = ((buf[pos++]<<24)&0xff000000);
+ SFID += ((buf[pos++]<<16)&0xff0000);
+ SFID += ((buf[pos++]<<8)&0xff00);
+ SFID += (buf[pos++]);
+
+ index = get_csr(qcb, SFID, 1);
+ if (index == -1) {
+ eprintk("QoS ERROR: csr Update Error\n");
+ return;
+ }
+
+ dprintk("QOS_ADD SFID = 0x%x, index=%d\n", SFID, index);
+
+ spin_lock_irqsave(&qcb->qos_lock, flags);
+ qcb->csr[index].SFID = SFID;
+ qcb->csr[index].ClassifierRuleEnable = ((buf[pos++]<<8)&0xff00);
+ qcb->csr[index].ClassifierRuleEnable += buf[pos++];
+ if (qcb->csr[index].ClassifierRuleEnable == 0)
+ qcb->qos_null_idx = index;
+ qcb->csr[index].IPToSMask = buf[pos++];
+ qcb->csr[index].IPToSLow = buf[pos++];
+ qcb->csr[index].IPToSHigh = buf[pos++];
+ qcb->csr[index].Protocol = buf[pos++];
+ qcb->csr[index].IPSrcAddrMask[0] = buf[pos++];
+ qcb->csr[index].IPSrcAddrMask[1] = buf[pos++];
+ qcb->csr[index].IPSrcAddrMask[2] = buf[pos++];
+ qcb->csr[index].IPSrcAddrMask[3] = buf[pos++];
+ qcb->csr[index].IPSrcAddr[0] = buf[pos++];
+ qcb->csr[index].IPSrcAddr[1] = buf[pos++];
+ qcb->csr[index].IPSrcAddr[2] = buf[pos++];
+ qcb->csr[index].IPSrcAddr[3] = buf[pos++];
+ qcb->csr[index].IPDstAddrMask[0] = buf[pos++];
+ qcb->csr[index].IPDstAddrMask[1] = buf[pos++];
+ qcb->csr[index].IPDstAddrMask[2] = buf[pos++];
+ qcb->csr[index].IPDstAddrMask[3] = buf[pos++];
+ qcb->csr[index].IPDstAddr[0] = buf[pos++];
+ qcb->csr[index].IPDstAddr[1] = buf[pos++];
+ qcb->csr[index].IPDstAddr[2] = buf[pos++];
+ qcb->csr[index].IPDstAddr[3] = buf[pos++];
+ qcb->csr[index].SrcPortLow = ((buf[pos++]<<8)&0xff00);
+ qcb->csr[index].SrcPortLow += buf[pos++];
+ qcb->csr[index].SrcPortHigh = ((buf[pos++]<<8)&0xff00);
+ qcb->csr[index].SrcPortHigh += buf[pos++];
+ qcb->csr[index].DstPortLow = ((buf[pos++]<<8)&0xff00);
+ qcb->csr[index].DstPortLow += buf[pos++];
+ qcb->csr[index].DstPortHigh = ((buf[pos++]<<8)&0xff00);
+ qcb->csr[index].DstPortHigh += buf[pos++];
+
+ qcb->qos_limit_size = 254/qcb->qos_list_cnt;
+ spin_unlock_irqrestore(&qcb->qos_lock, flags);
+ } else if (subCmdEvt == QOS_CHANGE_DEL) {
+ pos = 5;
+ len = (u8)buf[pos++];
+ SFID = ((buf[pos++]<<24)&0xff000000);
+ SFID += ((buf[pos++]<<16)&0xff0000);
+ SFID += ((buf[pos++]<<8)&0xff00);
+ SFID += (buf[pos++]);
+ index = get_csr(qcb, SFID, 1);
+ if (index == -1) {
+ eprintk("QoS ERROR: Wrong index(%d)\n", index);
+ return;
+ }
+
+ dprintk("QOS_CHANGE_DEL SFID = 0x%x, index=%d\n", SFID, index);
+
+ INIT_LIST_HEAD(&free_list);
+
+ spin_lock_irqsave(&qcb->qos_lock, flags);
+ qcb->csr[index].Enabled = 0;
+ qcb->qos_list_cnt--;
+ qcb->qos_limit_size = 254/qcb->qos_list_cnt;
+
+ list_for_each_entry_safe(entry, n, &qcb->qos_list[index],
+ list) {
+ list_move_tail(&entry->list, &free_list);
+ }
+ spin_unlock_irqrestore(&qcb->qos_lock, flags);
+ free_qos_entry_list(&free_list);
+ }
+}
diff --git a/drivers/staging/gdm72xx/gdm_qos.h b/drivers/staging/gdm72xx/gdm_qos.h
new file mode 100644
index 000000000000..33f2bd4cee32
--- /dev/null
+++ b/drivers/staging/gdm72xx/gdm_qos.h
@@ -0,0 +1,93 @@
+/*
+ * Copyright (c) 2012 GCT Semiconductor, Inc. All rights reserved.
+ *
+ * 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.
+ */
+
+#if !defined(GDM_QOS_H_20090403)
+#define GDM_QOS_H_20090403
+
+#include <linux/types.h>
+#include <linux/usb.h>
+#include <linux/list.h>
+
+#define BOOLEAN u8
+
+#define QOS_MAX 16
+#define IPTYPEOFSERVICE 0x8000
+#define PROTOCOL 0x4000
+#define IPMASKEDSRCADDRESS 0x2000
+#define IPMASKEDDSTADDRESS 0x1000
+#define PROTOCOLSRCPORTRANGE 0x800
+#define PROTOCOLDSTPORTRANGE 0x400
+#define DSTMACADDR 0x200
+#define SRCMACADDR 0x100
+#define ETHERTYPE 0x80
+#define IEEE802_1DUSERPRIORITY 0x40
+#define IEEE802_1QVLANID 0x10
+
+struct gdm_wimax_csr_s {
+ /* union{
+ U16 all;
+ struct _CS_CLASSIFIER_RULE_ENABLE{
+ IPTypeOfService:1,
+ Protocol:1,
+ IPMaskedSrcAddress:1,
+ IPMaskedDstAddress:1,
+ ProtocolSrcPortRange:1,
+ ProtocolDstPortRange:1,
+ DstMacAddr:1,
+ SrcMacAddr:1,
+ Ethertype:1,
+ IEEE802_1DUserPriority:1,
+ IEEE802_1QVLANID:1,
+ Reserved:5;
+ } fields;
+ } */
+ BOOLEAN Enabled;
+ u32 SFID;
+ u8 QoSBufCount;
+ u16 ClassifierRuleEnable;
+ u8 IPToSLow;
+ u8 IPToSHigh;
+ u8 IPToSMask;
+ u8 Protocol;
+ u8 IPSrcAddr[16];
+ u8 IPSrcAddrMask[16];
+ u8 IPDstAddr[16];
+ u8 IPDstAddrMask[16];
+ u16 SrcPortLow;
+ u16 SrcPortHigh;
+ u16 DstPortLow;
+ u16 DstPortHigh;
+};
+
+struct qos_entry_s {
+ struct list_head list;
+ struct sk_buff *skb;
+ struct net_device *dev;
+
+};
+
+struct qos_cb_s {
+ struct list_head qos_list[QOS_MAX];
+ u32 qos_list_cnt;
+ u32 qos_null_idx;
+ struct gdm_wimax_csr_s csr[QOS_MAX];
+ spinlock_t qos_lock;
+ u32 qos_limit_size;
+};
+
+void gdm_qos_init(void *nic_ptr);
+void gdm_qos_release_list(void *nic_ptr);
+int gdm_qos_send_hci_pkt(struct sk_buff *skb, struct net_device *dev);
+void gdm_recv_qos_hci_packet(void *nic_ptr, u8 *buf, int size);
+
+#endif
diff --git a/drivers/staging/gdm72xx/gdm_sdio.c b/drivers/staging/gdm72xx/gdm_sdio.c
new file mode 100644
index 000000000000..3e43c012ef27
--- /dev/null
+++ b/drivers/staging/gdm72xx/gdm_sdio.c
@@ -0,0 +1,750 @@
+/*
+ * Copyright (c) 2012 GCT Semiconductor, Inc. All rights reserved.
+ *
+ * This software is licensed under the terms of the GNU General Public
+ * License version 2, as published by the Free Software Foundation, and
+ * may be copied, distributed, and modified under those terms.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/kernel.h>
+
+#include <linux/mmc/core.h>
+#include <linux/mmc/card.h>
+#include <linux/mmc/sdio_func.h>
+#include <linux/mmc/sdio_ids.h>
+
+#include "gdm_sdio.h"
+#include "gdm_wimax.h"
+#include "sdio_boot.h"
+#include "hci.h"
+
+#define TYPE_A_HEADER_SIZE 4
+#define TYPE_A_LOOKAHEAD_SIZE 16
+
+#define MAX_NR_RX_BUF 4
+
+#define SDU_TX_BUF_SIZE 2048
+#define TX_BUF_SIZE 2048
+#define TX_CHUNK_SIZE (2048 - TYPE_A_HEADER_SIZE)
+#define RX_BUF_SIZE (25*1024)
+
+#define TX_HZ 2000
+#define TX_INTERVAL (1000000/TX_HZ)
+
+/*#define DEBUG*/
+
+static int init_sdio(struct sdiowm_dev *sdev);
+static void release_sdio(struct sdiowm_dev *sdev);
+
+#ifdef DEBUG
+static void hexdump(char *title, u8 *data, int len)
+{
+ int i;
+
+ printk(KERN_DEBUG "%s: length = %d\n", title, len);
+ for (i = 0; i < len; i++) {
+ printk(KERN_DEBUG "%02x ", data[i]);
+ if ((i & 0xf) == 0xf)
+ printk(KERN_DEBUG "\n");
+ }
+ printk(KERN_DEBUG "\n");
+}
+#endif
+
+static struct sdio_tx *alloc_tx_struct(struct tx_cxt *tx)
+{
+ struct sdio_tx *t = NULL;
+
+ t = kmalloc(sizeof(*t), GFP_ATOMIC);
+ if (t == NULL)
+ goto out;
+
+ memset(t, 0, sizeof(*t));
+
+ t->buf = kmalloc(TX_BUF_SIZE, GFP_ATOMIC);
+ if (t->buf == NULL)
+ goto out;
+
+ t->tx_cxt = tx;
+
+ return t;
+out:
+ if (t) {
+ kfree(t->buf);
+ kfree(t);
+ }
+ return NULL;
+}
+
+static void free_tx_struct(struct sdio_tx *t)
+{
+ if (t) {
+ kfree(t->buf);
+ kfree(t);
+ }
+}
+
+static struct sdio_rx *alloc_rx_struct(struct rx_cxt *rx)
+{
+ struct sdio_rx *r = NULL;
+
+ r = kmalloc(sizeof(*r), GFP_ATOMIC);
+ if (r == NULL)
+ goto out;
+
+ memset(r, 0, sizeof(*r));
+
+ r->rx_cxt = rx;
+
+ return r;
+out:
+ kfree(r);
+ return NULL;
+}
+
+static void free_rx_struct(struct sdio_rx *r)
+{
+ kfree(r);
+}
+
+/* Before this function is called, spin lock should be locked. */
+static struct sdio_tx *get_tx_struct(struct tx_cxt *tx, int *no_spc)
+{
+ struct sdio_tx *t;
+
+ if (list_empty(&tx->free_list))
+ return NULL;
+
+ t = list_entry(tx->free_list.prev, struct sdio_tx, list);
+ list_del(&t->list);
+
+ *no_spc = list_empty(&tx->free_list) ? 1 : 0;
+
+ return t;
+}
+
+/* Before this function is called, spin lock should be locked. */
+static void put_tx_struct(struct tx_cxt *tx, struct sdio_tx *t)
+{
+ list_add_tail(&t->list, &tx->free_list);
+}
+
+/* Before this function is called, spin lock should be locked. */
+static struct sdio_rx *get_rx_struct(struct rx_cxt *rx)
+{
+ struct sdio_rx *r;
+
+ if (list_empty(&rx->free_list))
+ return NULL;
+
+ r = list_entry(rx->free_list.prev, struct sdio_rx, list);
+ list_del(&r->list);
+
+ return r;
+}
+
+/* Before this function is called, spin lock should be locked. */
+static void put_rx_struct(struct rx_cxt *rx, struct sdio_rx *r)
+{
+ list_add_tail(&r->list, &rx->free_list);
+}
+
+static int init_sdio(struct sdiowm_dev *sdev)
+{
+ int ret = 0, i;
+ struct tx_cxt *tx = &sdev->tx;
+ struct rx_cxt *rx = &sdev->rx;
+ struct sdio_tx *t;
+ struct sdio_rx *r;
+
+ INIT_LIST_HEAD(&tx->free_list);
+ INIT_LIST_HEAD(&tx->sdu_list);
+ INIT_LIST_HEAD(&tx->hci_list);
+
+ spin_lock_init(&tx->lock);
+
+ tx->sdu_buf = kmalloc(SDU_TX_BUF_SIZE, GFP_KERNEL);
+ if (tx->sdu_buf == NULL) {
+ printk(KERN_ERR "Failed to allocate SDU tx buffer.\n");
+ goto fail;
+ }
+
+ for (i = 0; i < MAX_NR_SDU_BUF; i++) {
+ t = alloc_tx_struct(tx);
+ if (t == NULL) {
+ ret = -ENOMEM;
+ goto fail;
+ }
+ list_add(&t->list, &tx->free_list);
+ }
+
+ INIT_LIST_HEAD(&rx->free_list);
+ INIT_LIST_HEAD(&rx->req_list);
+
+ spin_lock_init(&rx->lock);
+
+ for (i = 0; i < MAX_NR_RX_BUF; i++) {
+ r = alloc_rx_struct(rx);
+ if (r == NULL) {
+ ret = -ENOMEM;
+ goto fail;
+ }
+ list_add(&r->list, &rx->free_list);
+ }
+
+ rx->rx_buf = kmalloc(RX_BUF_SIZE, GFP_KERNEL);
+ if (rx->rx_buf == NULL) {
+ printk(KERN_ERR "Failed to allocate rx buffer.\n");
+ goto fail;
+ }
+
+ return 0;
+
+fail:
+ release_sdio(sdev);
+ return ret;
+}
+
+static void release_sdio(struct sdiowm_dev *sdev)
+{
+ struct tx_cxt *tx = &sdev->tx;
+ struct rx_cxt *rx = &sdev->rx;
+ struct sdio_tx *t, *t_next;
+ struct sdio_rx *r, *r_next;
+
+ kfree(tx->sdu_buf);
+
+ list_for_each_entry_safe(t, t_next, &tx->free_list, list) {
+ list_del(&t->list);
+ free_tx_struct(t);
+ }
+
+ list_for_each_entry_safe(t, t_next, &tx->sdu_list, list) {
+ list_del(&t->list);
+ free_tx_struct(t);
+ }
+
+ list_for_each_entry_safe(t, t_next, &tx->hci_list, list) {
+ list_del(&t->list);
+ free_tx_struct(t);
+ }
+
+ kfree(rx->rx_buf);
+
+ list_for_each_entry_safe(r, r_next, &rx->free_list, list) {
+ list_del(&r->list);
+ free_rx_struct(r);
+ }
+
+ list_for_each_entry_safe(r, r_next, &rx->req_list, list) {
+ list_del(&r->list);
+ free_rx_struct(r);
+ }
+}
+
+static void send_sdio_pkt(struct sdio_func *func, u8 *data, int len)
+{
+ int n, blocks, ret, remain;
+
+ sdio_claim_host(func);
+
+ blocks = len / func->cur_blksize;
+ n = blocks * func->cur_blksize;
+ if (blocks) {
+ ret = sdio_memcpy_toio(func, 0, data, n);
+ if (ret < 0) {
+ if (ret != -ENOMEDIUM)
+ printk(KERN_ERR "gdmwms: %s error: ret = %d\n",
+ __func__, ret);
+ goto end_io;
+ }
+ }
+
+ remain = len - n;
+ remain = (remain + 3) & ~3;
+
+ if (remain) {
+ ret = sdio_memcpy_toio(func, 0, data + n, remain);
+ if (ret < 0) {
+ if (ret != -ENOMEDIUM)
+ printk(KERN_ERR "gdmwms: %s error: ret = %d\n",
+ __func__, ret);
+ goto end_io;
+ }
+ }
+
+end_io:
+ sdio_release_host(func);
+}
+
+static void send_sdu(struct sdio_func *func, struct tx_cxt *tx)
+{
+ struct list_head *l, *next;
+ struct hci_s *hci;
+ struct sdio_tx *t;
+ int pos, len, i, estlen, aggr_num = 0, aggr_len;
+ u8 *buf;
+ unsigned long flags;
+
+ spin_lock_irqsave(&tx->lock, flags);
+
+ pos = TYPE_A_HEADER_SIZE + HCI_HEADER_SIZE;
+ list_for_each_entry(t, &tx->sdu_list, list) {
+ estlen = ((t->len + 3) & ~3) + 4;
+ if ((pos + estlen) > SDU_TX_BUF_SIZE)
+ break;
+
+ aggr_num++;
+ memcpy(tx->sdu_buf + pos, t->buf, t->len);
+ memset(tx->sdu_buf + pos + t->len, 0, estlen - t->len);
+ pos += estlen;
+ }
+ aggr_len = pos;
+
+ hci = (struct hci_s *)(tx->sdu_buf + TYPE_A_HEADER_SIZE);
+ hci->cmd_evt = H2B(WIMAX_TX_SDU_AGGR);
+ hci->length = H2B(aggr_len - TYPE_A_HEADER_SIZE - HCI_HEADER_SIZE);
+
+ spin_unlock_irqrestore(&tx->lock, flags);
+
+#ifdef DEBUG
+ hexdump("sdio_send", tx->sdu_buf + TYPE_A_HEADER_SIZE,
+ aggr_len - TYPE_A_HEADER_SIZE);
+#endif
+
+ for (pos = TYPE_A_HEADER_SIZE; pos < aggr_len; pos += TX_CHUNK_SIZE) {
+ len = aggr_len - pos;
+ len = len > TX_CHUNK_SIZE ? TX_CHUNK_SIZE : len;
+ buf = tx->sdu_buf + pos - TYPE_A_HEADER_SIZE;
+
+ buf[0] = len & 0xff;
+ buf[1] = (len >> 8) & 0xff;
+ buf[2] = (len >> 16) & 0xff;
+ buf[3] = (pos + len) >= aggr_len ? 0 : 1;
+ send_sdio_pkt(func, buf, len + TYPE_A_HEADER_SIZE);
+ }
+
+ spin_lock_irqsave(&tx->lock, flags);
+
+ for (l = tx->sdu_list.next, i = 0; i < aggr_num; i++, l = next) {
+ next = l->next;
+ t = list_entry(l, struct sdio_tx, list);
+ if (t->callback)
+ t->callback(t->cb_data);
+
+ list_del(l);
+ put_tx_struct(t->tx_cxt, t);
+ }
+
+ do_gettimeofday(&tx->sdu_stamp);
+ spin_unlock_irqrestore(&tx->lock, flags);
+}
+
+static void send_hci(struct sdio_func *func, struct tx_cxt *tx,
+ struct sdio_tx *t)
+{
+ unsigned long flags;
+
+#ifdef DEBUG
+ hexdump("sdio_send", t->buf + TYPE_A_HEADER_SIZE,
+ t->len - TYPE_A_HEADER_SIZE);
+#endif
+ send_sdio_pkt(func, t->buf, t->len);
+
+ spin_lock_irqsave(&tx->lock, flags);
+ if (t->callback)
+ t->callback(t->cb_data);
+ free_tx_struct(t);
+ spin_unlock_irqrestore(&tx->lock, flags);
+}
+
+static void do_tx(struct work_struct *work)
+{
+ struct sdiowm_dev *sdev = container_of(work, struct sdiowm_dev, ws);
+ struct sdio_func *func = sdev->func;
+ struct tx_cxt *tx = &sdev->tx;
+ struct sdio_tx *t = NULL;
+ struct timeval now, *before;
+ int is_sdu = 0;
+ long diff;
+ unsigned long flags;
+
+ spin_lock_irqsave(&tx->lock, flags);
+ if (!tx->can_send) {
+ spin_unlock_irqrestore(&tx->lock, flags);
+ return;
+ }
+
+ if (!list_empty(&tx->hci_list)) {
+ t = list_entry(tx->hci_list.next, struct sdio_tx, list);
+ list_del(&t->list);
+ is_sdu = 0;
+ } else if (!tx->stop_sdu_tx && !list_empty(&tx->sdu_list)) {
+ do_gettimeofday(&now);
+ before = &tx->sdu_stamp;
+
+ diff = (now.tv_sec - before->tv_sec) * 1000000 +
+ (now.tv_usec - before->tv_usec);
+ if (diff >= 0 && diff < TX_INTERVAL) {
+ schedule_work(&sdev->ws);
+ spin_unlock_irqrestore(&tx->lock, flags);
+ return;
+ }
+ is_sdu = 1;
+ }
+
+ if (!is_sdu && t == NULL) {
+ spin_unlock_irqrestore(&tx->lock, flags);
+ return;
+ }
+
+ tx->can_send = 0;
+
+ spin_unlock_irqrestore(&tx->lock, flags);
+
+ if (is_sdu)
+ send_sdu(func, tx);
+ else
+ send_hci(func, tx, t);
+}
+
+static int gdm_sdio_send(void *priv_dev, void *data, int len,
+ void (*cb)(void *data), void *cb_data)
+{
+ struct sdiowm_dev *sdev = priv_dev;
+ struct tx_cxt *tx = &sdev->tx;
+ struct sdio_tx *t;
+ u8 *pkt = data;
+ int no_spc = 0;
+ u16 cmd_evt;
+ unsigned long flags;
+
+ BUG_ON(len > TX_BUF_SIZE - TYPE_A_HEADER_SIZE);
+
+ spin_lock_irqsave(&tx->lock, flags);
+
+ cmd_evt = (pkt[0] << 8) | pkt[1];
+ if (cmd_evt == WIMAX_TX_SDU) {
+ t = get_tx_struct(tx, &no_spc);
+ if (t == NULL) {
+ /* This case must not happen. */
+ spin_unlock_irqrestore(&tx->lock, flags);
+ return -ENOSPC;
+ }
+ list_add_tail(&t->list, &tx->sdu_list);
+
+ memcpy(t->buf, data, len);
+
+ t->len = len;
+ t->callback = cb;
+ t->cb_data = cb_data;
+ } else {
+ t = alloc_tx_struct(tx);
+ if (t == NULL) {
+ spin_unlock_irqrestore(&tx->lock, flags);
+ return -ENOMEM;
+ }
+ list_add_tail(&t->list, &tx->hci_list);
+
+ t->buf[0] = len & 0xff;
+ t->buf[1] = (len >> 8) & 0xff;
+ t->buf[2] = (len >> 16) & 0xff;
+ t->buf[3] = 2;
+ memcpy(t->buf + TYPE_A_HEADER_SIZE, data, len);
+
+ t->len = len + TYPE_A_HEADER_SIZE;
+ t->callback = cb;
+ t->cb_data = cb_data;
+ }
+
+ if (tx->can_send)
+ schedule_work(&sdev->ws);
+
+ spin_unlock_irqrestore(&tx->lock, flags);
+
+ if (no_spc)
+ return -ENOSPC;
+
+ return 0;
+}
+
+/*
+ * Handle the HCI, WIMAX_SDU_TX_FLOW.
+ */
+static int control_sdu_tx_flow(struct sdiowm_dev *sdev, u8 *hci_data, int len)
+{
+ struct tx_cxt *tx = &sdev->tx;
+ u16 cmd_evt;
+ unsigned long flags;
+
+ spin_lock_irqsave(&tx->lock, flags);
+
+ cmd_evt = (hci_data[0] << 8) | (hci_data[1]);
+ if (cmd_evt != WIMAX_SDU_TX_FLOW)
+ goto out;
+
+ if (hci_data[4] == 0) {
+#ifdef DEBUG
+ printk(KERN_DEBUG "WIMAX ==> STOP SDU TX\n");
+#endif
+ tx->stop_sdu_tx = 1;
+ } else if (hci_data[4] == 1) {
+#ifdef DEBUG
+ printk(KERN_DEBUG "WIMAX ==> START SDU TX\n");
+#endif
+ tx->stop_sdu_tx = 0;
+ if (tx->can_send)
+ schedule_work(&sdev->ws);
+ /*
+ * If free buffer for sdu tx doesn't exist, then tx queue
+ * should not be woken. For this reason, don't pass the command,
+ * START_SDU_TX.
+ */
+ if (list_empty(&tx->free_list))
+ len = 0;
+ }
+
+out:
+ spin_unlock_irqrestore(&tx->lock, flags);
+ return len;
+}
+
+static void gdm_sdio_irq(struct sdio_func *func)
+{
+ struct phy_dev *phy_dev = sdio_get_drvdata(func);
+ struct sdiowm_dev *sdev = phy_dev->priv_dev;
+ struct tx_cxt *tx = &sdev->tx;
+ struct rx_cxt *rx = &sdev->rx;
+ struct sdio_rx *r;
+ unsigned long flags;
+ u8 val, hdr[TYPE_A_LOOKAHEAD_SIZE], *buf;
+ u32 len, blocks, n;
+ int ret, remain;
+
+ /* Check interrupt */
+ val = sdio_readb(func, 0x13, &ret);
+ if (val & 0x01)
+ sdio_writeb(func, 0x01, 0x13, &ret); /* clear interrupt */
+ else
+ return;
+
+ ret = sdio_memcpy_fromio(func, hdr, 0x0, TYPE_A_LOOKAHEAD_SIZE);
+ if (ret) {
+ printk(KERN_ERR "Cannot read from function %d\n", func->num);
+ goto done;
+ }
+
+ len = (hdr[2] << 16) | (hdr[1] << 8) | hdr[0];
+ if (len > (RX_BUF_SIZE - TYPE_A_HEADER_SIZE)) {
+ printk(KERN_ERR "Too big Type-A size: %d\n", len);
+ goto done;
+ }
+
+ if (hdr[3] == 1) { /* Ack */
+#ifdef DEBUG
+ u32 *ack_seq = (u32 *)&hdr[4];
+#endif
+ spin_lock_irqsave(&tx->lock, flags);
+ tx->can_send = 1;
+
+ if (!list_empty(&tx->sdu_list) || !list_empty(&tx->hci_list))
+ schedule_work(&sdev->ws);
+ spin_unlock_irqrestore(&tx->lock, flags);
+#ifdef DEBUG
+ printk(KERN_DEBUG "Ack... %0x\n", ntohl(*ack_seq));
+#endif
+ goto done;
+ }
+
+ memcpy(rx->rx_buf, hdr + TYPE_A_HEADER_SIZE,
+ TYPE_A_LOOKAHEAD_SIZE - TYPE_A_HEADER_SIZE);
+
+ buf = rx->rx_buf + TYPE_A_LOOKAHEAD_SIZE - TYPE_A_HEADER_SIZE;
+ remain = len - TYPE_A_LOOKAHEAD_SIZE + TYPE_A_HEADER_SIZE;
+ if (remain <= 0)
+ goto end_io;
+
+ blocks = remain / func->cur_blksize;
+
+ if (blocks) {
+ n = blocks * func->cur_blksize;
+ ret = sdio_memcpy_fromio(func, buf, 0x0, n);
+ if (ret) {
+ printk(KERN_ERR "Cannot read from function %d\n",
+ func->num);
+ goto done;
+ }
+ buf += n;
+ remain -= n;
+ }
+
+ if (remain) {
+ ret = sdio_memcpy_fromio(func, buf, 0x0, remain);
+ if (ret) {
+ printk(KERN_ERR "Cannot read from function %d\n",
+ func->num);
+ goto done;
+ }
+ }
+
+end_io:
+#ifdef DEBUG
+ hexdump("sdio_receive", rx->rx_buf, len);
+#endif
+ len = control_sdu_tx_flow(sdev, rx->rx_buf, len);
+
+ spin_lock_irqsave(&rx->lock, flags);
+
+ if (!list_empty(&rx->req_list)) {
+ r = list_entry(rx->req_list.next, struct sdio_rx, list);
+ spin_unlock_irqrestore(&rx->lock, flags);
+ if (r->callback)
+ r->callback(r->cb_data, rx->rx_buf, len);
+ spin_lock_irqsave(&rx->lock, flags);
+ list_del(&r->list);
+ put_rx_struct(rx, r);
+ }
+
+ spin_unlock_irqrestore(&rx->lock, flags);
+
+done:
+ sdio_writeb(func, 0x00, 0x10, &ret); /* PCRRT */
+ if (!phy_dev->netdev)
+ register_wimax_device(phy_dev, &func->dev);
+}
+
+static int gdm_sdio_receive(void *priv_dev,
+ void (*cb)(void *cb_data, void *data, int len),
+ void *cb_data)
+{
+ struct sdiowm_dev *sdev = priv_dev;
+ struct rx_cxt *rx = &sdev->rx;
+ struct sdio_rx *r;
+ unsigned long flags;
+
+ spin_lock_irqsave(&rx->lock, flags);
+ r = get_rx_struct(rx);
+ if (r == NULL) {
+ spin_unlock_irqrestore(&rx->lock, flags);
+ return -ENOMEM;
+ }
+
+ r->callback = cb;
+ r->cb_data = cb_data;
+
+ list_add_tail(&r->list, &rx->req_list);
+ spin_unlock_irqrestore(&rx->lock, flags);
+
+ return 0;
+}
+
+static int sdio_wimax_probe(struct sdio_func *func,
+ const struct sdio_device_id *id)
+{
+ int ret;
+ struct phy_dev *phy_dev = NULL;
+ struct sdiowm_dev *sdev = NULL;
+
+ printk(KERN_INFO "Found GDM SDIO VID = 0x%04x PID = 0x%04x...\n",
+ func->vendor, func->device);
+ printk(KERN_INFO "GCT WiMax driver version %s\n", DRIVER_VERSION);
+
+ sdio_claim_host(func);
+ sdio_enable_func(func);
+ sdio_claim_irq(func, gdm_sdio_irq);
+
+ ret = sdio_boot(func);
+ if (ret)
+ return ret;
+
+ phy_dev = kzalloc(sizeof(*phy_dev), GFP_KERNEL);
+ if (phy_dev == NULL) {
+ ret = -ENOMEM;
+ goto out;
+ }
+ sdev = kzalloc(sizeof(*sdev), GFP_KERNEL);
+ if (sdev == NULL) {
+ ret = -ENOMEM;
+ goto out;
+ }
+
+ phy_dev->priv_dev = (void *)sdev;
+ phy_dev->send_func = gdm_sdio_send;
+ phy_dev->rcv_func = gdm_sdio_receive;
+
+ ret = init_sdio(sdev);
+ if (sdev < 0)
+ goto out;
+
+ sdev->func = func;
+
+ sdio_writeb(func, 1, 0x14, &ret); /* Enable interrupt */
+ sdio_release_host(func);
+
+ INIT_WORK(&sdev->ws, do_tx);
+
+ sdio_set_drvdata(func, phy_dev);
+out:
+ if (ret) {
+ kfree(phy_dev);
+ kfree(sdev);
+ }
+
+ return ret;
+}
+
+static void sdio_wimax_remove(struct sdio_func *func)
+{
+ struct phy_dev *phy_dev = sdio_get_drvdata(func);
+ struct sdiowm_dev *sdev = phy_dev->priv_dev;
+
+ if (phy_dev->netdev)
+ unregister_wimax_device(phy_dev);
+ sdio_claim_host(func);
+ sdio_release_irq(func);
+ sdio_disable_func(func);
+ sdio_release_host(func);
+ release_sdio(sdev);
+
+ kfree(sdev);
+ kfree(phy_dev);
+}
+
+static const struct sdio_device_id sdio_wimax_ids[] = {
+ { SDIO_DEVICE(0x0296, 0x5347) },
+ {0}
+};
+
+MODULE_DEVICE_TABLE(sdio, sdio_wimax_ids);
+
+static struct sdio_driver sdio_wimax_driver = {
+ .probe = sdio_wimax_probe,
+ .remove = sdio_wimax_remove,
+ .name = "sdio_wimax",
+ .id_table = sdio_wimax_ids,
+};
+
+static int __init sdio_gdm_wimax_init(void)
+{
+ return sdio_register_driver(&sdio_wimax_driver);
+}
+
+static void __exit sdio_gdm_wimax_exit(void)
+{
+ sdio_unregister_driver(&sdio_wimax_driver);
+}
+
+module_init(sdio_gdm_wimax_init);
+module_exit(sdio_gdm_wimax_exit);
+
+MODULE_VERSION(DRIVER_VERSION);
+MODULE_DESCRIPTION("GCT WiMax SDIO Device Driver");
+MODULE_AUTHOR("Ethan Park");
+MODULE_LICENSE("GPL");
diff --git a/drivers/staging/gdm72xx/gdm_sdio.h b/drivers/staging/gdm72xx/gdm_sdio.h
new file mode 100644
index 000000000000..216e98f31bae
--- /dev/null
+++ b/drivers/staging/gdm72xx/gdm_sdio.h
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2012 GCT Semiconductor, Inc. All rights reserved.
+ *
+ * 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 __GDM_SDIO_H__
+#define __GDM_SDIO_H__
+
+#include <linux/types.h>
+#include <linux/time.h>
+
+#define MAX_NR_SDU_BUF 64
+
+struct sdio_tx {
+ struct list_head list;
+ struct tx_cxt *tx_cxt;
+
+ u8 *buf;
+ int len;
+
+ void (*callback)(void *cb_data);
+ void *cb_data;
+};
+
+struct tx_cxt {
+ struct list_head free_list;
+ struct list_head sdu_list;
+ struct list_head hci_list;
+ struct timeval sdu_stamp;
+
+ u8 *sdu_buf;
+
+ spinlock_t lock;
+ int can_send;
+ int stop_sdu_tx;
+};
+
+struct sdio_rx {
+ struct list_head list;
+ struct rx_cxt *rx_cxt;
+
+ void (*callback)(void *cb_data, void *data, int len);
+ void *cb_data;
+};
+
+struct rx_cxt {
+ struct list_head free_list;
+ struct list_head req_list;
+
+ u8 *rx_buf;
+
+ spinlock_t lock;
+};
+
+struct sdiowm_dev {
+ struct sdio_func *func;
+
+ struct tx_cxt tx;
+ struct rx_cxt rx;
+
+ struct work_struct ws;
+};
+
+#endif /* __GDM_SDIO_H__ */
diff --git a/drivers/staging/gdm72xx/gdm_usb.c b/drivers/staging/gdm72xx/gdm_usb.c
new file mode 100644
index 000000000000..d48d49c145ee
--- /dev/null
+++ b/drivers/staging/gdm72xx/gdm_usb.c
@@ -0,0 +1,801 @@
+/*
+ * Copyright (c) 2012 GCT Semiconductor, Inc. All rights reserved.
+ *
+ * This software is licensed under the terms of the GNU General Public
+ * License version 2, as published by the Free Software Foundation, and
+ * may be copied, distributed, and modified under those terms.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/usb.h>
+#include <asm/byteorder.h>
+#include <linux/kthread.h>
+
+#include "gdm_usb.h"
+#include "gdm_wimax.h"
+#include "usb_boot.h"
+#include "hci.h"
+
+#include "usb_ids.h"
+
+MODULE_DEVICE_TABLE(usb, id_table);
+
+#define TX_BUF_SIZE 2048
+#if defined(CONFIG_WIMAX_GDM72XX_WIMAX2)
+#define RX_BUF_SIZE (128*1024) /* For packet aggregation */
+#else
+#define RX_BUF_SIZE 2048
+#endif
+
+#define GDM7205_PADDING 256
+
+#define H2B(x) __cpu_to_be16(x)
+#define B2H(x) __be16_to_cpu(x)
+#define DB2H(x) __be32_to_cpu(x)
+
+#define DOWNLOAD_CONF_VALUE 0x21
+
+#ifdef CONFIG_WIMAX_GDM72XX_K_MODE
+
+static DECLARE_WAIT_QUEUE_HEAD(k_wait);
+static LIST_HEAD(k_list);
+static DEFINE_SPINLOCK(k_lock);
+static int k_mode_stop;
+
+#define K_WAIT_TIME (2 * HZ / 100)
+
+#endif /* CONFIG_WIMAX_GDM72XX_K_MODE */
+
+static int init_usb(struct usbwm_dev *udev);
+static void release_usb(struct usbwm_dev *udev);
+
+/*#define DEBUG */
+#ifdef DEBUG
+static void hexdump(char *title, u8 *data, int len)
+{
+ int i;
+
+ printk(KERN_DEBUG "%s: length = %d\n", title, len);
+ for (i = 0; i < len; i++) {
+ printk(KERN_DEBUG "%02x ", data[i]);
+ if ((i & 0xf) == 0xf)
+ printk(KERN_DEBUG "\n");
+ }
+ printk(KERN_DEBUG "\n");
+}
+#endif
+
+static struct usb_tx *alloc_tx_struct(struct tx_cxt *tx)
+{
+ struct usb_tx *t = NULL;
+
+ t = kmalloc(sizeof(*t), GFP_ATOMIC);
+ if (t == NULL)
+ goto out;
+
+ memset(t, 0, sizeof(*t));
+
+ t->urb = usb_alloc_urb(0, GFP_ATOMIC);
+ t->buf = kmalloc(TX_BUF_SIZE, GFP_ATOMIC);
+ if (t->urb == NULL || t->buf == NULL)
+ goto out;
+
+ t->tx_cxt = tx;
+
+ return t;
+out:
+ if (t) {
+ usb_free_urb(t->urb);
+ kfree(t->buf);
+ kfree(t);
+ }
+ return NULL;
+}
+
+static void free_tx_struct(struct usb_tx *t)
+{
+ if (t) {
+ usb_free_urb(t->urb);
+ kfree(t->buf);
+ kfree(t);
+ }
+}
+
+static struct usb_rx *alloc_rx_struct(struct rx_cxt *rx)
+{
+ struct usb_rx *r = NULL;
+
+ r = kmalloc(sizeof(*r), GFP_ATOMIC);
+ if (r == NULL)
+ goto out;
+
+ memset(r, 0, sizeof(*r));
+
+ r->urb = usb_alloc_urb(0, GFP_ATOMIC);
+ r->buf = kmalloc(RX_BUF_SIZE, GFP_ATOMIC);
+ if (r->urb == NULL || r->buf == NULL)
+ goto out;
+
+ r->rx_cxt = rx;
+ return r;
+out:
+ if (r) {
+ usb_free_urb(r->urb);
+ kfree(r->buf);
+ kfree(r);
+ }
+ return NULL;
+}
+
+static void free_rx_struct(struct usb_rx *r)
+{
+ if (r) {
+ usb_free_urb(r->urb);
+ kfree(r->buf);
+ kfree(r);
+ }
+}
+
+/* Before this function is called, spin lock should be locked. */
+static struct usb_tx *get_tx_struct(struct tx_cxt *tx, int *no_spc)
+{
+ struct usb_tx *t;
+
+ if (list_empty(&tx->free_list)) {
+ *no_spc = 1;
+ return NULL;
+ }
+
+ t = list_entry(tx->free_list.next, struct usb_tx, list);
+ list_del(&t->list);
+
+ *no_spc = list_empty(&tx->free_list) ? 1 : 0;
+
+ return t;
+}
+
+/* Before this function is called, spin lock should be locked. */
+static void put_tx_struct(struct tx_cxt *tx, struct usb_tx *t)
+{
+ list_add_tail(&t->list, &tx->free_list);
+}
+
+/* Before this function is called, spin lock should be locked. */
+static struct usb_rx *get_rx_struct(struct rx_cxt *rx)
+{
+ struct usb_rx *r;
+
+ if (list_empty(&rx->free_list)) {
+ r = alloc_rx_struct(rx);
+ if (r == NULL)
+ return NULL;
+
+ list_add(&r->list, &rx->free_list);
+ }
+
+ r = list_entry(rx->free_list.next, struct usb_rx, list);
+ list_del(&r->list);
+ list_add_tail(&r->list, &rx->used_list);
+
+ return r;
+}
+
+/* Before this function is called, spin lock should be locked. */
+static void put_rx_struct(struct rx_cxt *rx, struct usb_rx *r)
+{
+ list_del(&r->list);
+ list_add(&r->list, &rx->free_list);
+}
+
+static int init_usb(struct usbwm_dev *udev)
+{
+ int ret = 0, i;
+ struct tx_cxt *tx = &udev->tx;
+ struct rx_cxt *rx = &udev->rx;
+ struct usb_tx *t;
+ struct usb_rx *r;
+
+ INIT_LIST_HEAD(&tx->free_list);
+ INIT_LIST_HEAD(&tx->sdu_list);
+ INIT_LIST_HEAD(&tx->hci_list);
+#if defined(CONFIG_WIMAX_GDM72XX_USB_PM) || defined(CONFIG_WIMAX_GDM72XX_K_MODE)
+ INIT_LIST_HEAD(&tx->pending_list);
+#endif
+
+ INIT_LIST_HEAD(&rx->free_list);
+ INIT_LIST_HEAD(&rx->used_list);
+
+ spin_lock_init(&tx->lock);
+ spin_lock_init(&rx->lock);
+
+ for (i = 0; i < MAX_NR_SDU_BUF; i++) {
+ t = alloc_tx_struct(tx);
+ if (t == NULL) {
+ ret = -ENOMEM;
+ goto fail;
+ }
+ list_add(&t->list, &tx->free_list);
+ }
+
+ r = alloc_rx_struct(rx);
+ if (r == NULL) {
+ ret = -ENOMEM;
+ goto fail;
+ }
+
+ list_add(&r->list, &rx->free_list);
+ return ret;
+
+fail:
+ release_usb(udev);
+ return ret;
+}
+
+static void release_usb(struct usbwm_dev *udev)
+{
+ struct tx_cxt *tx = &udev->tx;
+ struct rx_cxt *rx = &udev->rx;
+ struct usb_tx *t, *t_next;
+ struct usb_rx *r, *r_next;
+
+ list_for_each_entry_safe(t, t_next, &tx->sdu_list, list) {
+ list_del(&t->list);
+ free_tx_struct(t);
+ }
+
+ list_for_each_entry_safe(t, t_next, &tx->hci_list, list) {
+ list_del(&t->list);
+ free_tx_struct(t);
+ }
+
+ list_for_each_entry_safe(t, t_next, &tx->free_list, list) {
+ list_del(&t->list);
+ free_tx_struct(t);
+ }
+
+ list_for_each_entry_safe(r, r_next, &rx->free_list, list) {
+ list_del(&r->list);
+ free_rx_struct(r);
+ }
+
+ list_for_each_entry_safe(r, r_next, &rx->used_list, list) {
+ list_del(&r->list);
+ free_rx_struct(r);
+ }
+}
+
+static void __gdm_usb_send_complete(struct urb *urb)
+{
+ struct usb_tx *t = urb->context;
+ struct tx_cxt *tx = t->tx_cxt;
+ u8 *pkt = t->buf;
+ u16 cmd_evt;
+
+ /* Completion by usb_unlink_urb */
+ if (urb->status == -ECONNRESET)
+ return;
+
+ if (t->callback)
+ t->callback(t->cb_data);
+
+ /* Delete from sdu list or hci list. */
+ list_del(&t->list);
+
+ cmd_evt = (pkt[0] << 8) | pkt[1];
+ if (cmd_evt == WIMAX_TX_SDU)
+ put_tx_struct(tx, t);
+ else
+ free_tx_struct(t);
+}
+
+static void gdm_usb_send_complete(struct urb *urb)
+{
+ struct usb_tx *t = urb->context;
+ struct tx_cxt *tx = t->tx_cxt;
+ unsigned long flags;
+
+ spin_lock_irqsave(&tx->lock, flags);
+ __gdm_usb_send_complete(urb);
+ spin_unlock_irqrestore(&tx->lock, flags);
+}
+
+static int gdm_usb_send(void *priv_dev, void *data, int len,
+ void (*cb)(void *data), void *cb_data)
+{
+ struct usbwm_dev *udev = priv_dev;
+ struct usb_device *usbdev = udev->usbdev;
+ struct tx_cxt *tx = &udev->tx;
+ struct usb_tx *t;
+ int padding = udev->padding;
+ int no_spc = 0, ret;
+ u8 *pkt = data;
+ u16 cmd_evt;
+ unsigned long flags;
+
+ if (!udev->usbdev) {
+ printk(KERN_ERR "%s: No such device\n", __func__);
+ return -ENODEV;
+ }
+
+ BUG_ON(len > TX_BUF_SIZE - padding - 1);
+
+ spin_lock_irqsave(&tx->lock, flags);
+
+ cmd_evt = (pkt[0] << 8) | pkt[1];
+ if (cmd_evt == WIMAX_TX_SDU) {
+ t = get_tx_struct(tx, &no_spc);
+ if (t == NULL) {
+ /* This case must not happen. */
+ spin_unlock_irqrestore(&tx->lock, flags);
+ return -ENOSPC;
+ }
+ list_add_tail(&t->list, &tx->sdu_list);
+ } else {
+ t = alloc_tx_struct(tx);
+ if (t == NULL) {
+ spin_unlock_irqrestore(&tx->lock, flags);
+ return -ENOMEM;
+ }
+ list_add_tail(&t->list, &tx->hci_list);
+ }
+
+ memcpy(t->buf + padding, data, len);
+ t->callback = cb;
+ t->cb_data = cb_data;
+
+ /*
+ * In some cases, USB Module of WiMax is blocked when data size is
+ * the multiple of 512. So, increment length by one in that case.
+ */
+ if ((len % 512) == 0)
+ len++;
+
+ usb_fill_bulk_urb(t->urb,
+ usbdev,
+ usb_sndbulkpipe(usbdev, 1),
+ t->buf,
+ len + padding,
+ gdm_usb_send_complete,
+ t);
+
+#ifdef DEBUG
+ hexdump("usb_send", t->buf, len + padding);
+#endif
+#ifdef CONFIG_WIMAX_GDM72XX_USB_PM
+ if (usbdev->state & USB_STATE_SUSPENDED) {
+ list_add_tail(&t->p_list, &tx->pending_list);
+ schedule_work(&udev->pm_ws);
+ goto out;
+ }
+#endif /* CONFIG_WIMAX_GDM72XX_USB_PM */
+
+#ifdef CONFIG_WIMAX_GDM72XX_K_MODE
+ if (udev->bw_switch) {
+ list_add_tail(&t->p_list, &tx->pending_list);
+ goto out;
+ } else if (cmd_evt == WIMAX_SCAN) {
+ struct rx_cxt *rx;
+ struct usb_rx *r;
+
+ rx = &udev->rx;
+
+ list_for_each_entry(r, &rx->used_list, list)
+ usb_unlink_urb(r->urb);
+ udev->bw_switch = 1;
+
+ spin_lock(&k_lock);
+ list_add_tail(&udev->list, &k_list);
+ spin_unlock(&k_lock);
+
+ wake_up(&k_wait);
+ }
+#endif /* CONFIG_WIMAX_GDM72XX_K_MODE */
+
+ ret = usb_submit_urb(t->urb, GFP_ATOMIC);
+ if (ret)
+ goto send_fail;
+
+#ifdef CONFIG_WIMAX_GDM72XX_USB_PM
+ usb_mark_last_busy(usbdev);
+#endif /* CONFIG_WIMAX_GDM72XX_USB_PM */
+
+#if defined(CONFIG_WIMAX_GDM72XX_USB_PM) || defined(CONFIG_WIMAX_GDM72XX_K_MODE)
+out:
+#endif
+ spin_unlock_irqrestore(&tx->lock, flags);
+
+ if (no_spc)
+ return -ENOSPC;
+
+ return 0;
+
+send_fail:
+ t->callback = NULL;
+ __gdm_usb_send_complete(t->urb);
+ spin_unlock_irqrestore(&tx->lock, flags);
+ return ret;
+}
+
+static void gdm_usb_rcv_complete(struct urb *urb)
+{
+ struct usb_rx *r = urb->context;
+ struct rx_cxt *rx = r->rx_cxt;
+ struct usbwm_dev *udev = container_of(r->rx_cxt, struct usbwm_dev, rx);
+ struct tx_cxt *tx = &udev->tx;
+ struct usb_tx *t;
+ u16 cmd_evt;
+ unsigned long flags;
+
+#ifdef CONFIG_WIMAX_GDM72XX_USB_PM
+ struct usb_device *dev = urb->dev;
+#endif
+
+ /* Completion by usb_unlink_urb */
+ if (urb->status == -ECONNRESET)
+ return;
+
+ spin_lock_irqsave(&tx->lock, flags);
+
+ if (!urb->status) {
+ cmd_evt = (r->buf[0] << 8) | (r->buf[1]);
+#ifdef DEBUG
+ hexdump("usb_receive", r->buf, urb->actual_length);
+#endif
+ if (cmd_evt == WIMAX_SDU_TX_FLOW) {
+ if (r->buf[4] == 0) {
+#ifdef DEBUG
+ printk(KERN_DEBUG "WIMAX ==> STOP SDU TX\n");
+#endif
+ list_for_each_entry(t, &tx->sdu_list, list)
+ usb_unlink_urb(t->urb);
+ } else if (r->buf[4] == 1) {
+#ifdef DEBUG
+ printk(KERN_DEBUG "WIMAX ==> START SDU TX\n");
+#endif
+ list_for_each_entry(t, &tx->sdu_list, list) {
+ usb_submit_urb(t->urb, GFP_ATOMIC);
+ }
+ /*
+ * If free buffer for sdu tx doesn't
+ * exist, then tx queue should not be
+ * woken. For this reason, don't pass
+ * the command, START_SDU_TX.
+ */
+ if (list_empty(&tx->free_list))
+ urb->actual_length = 0;
+ }
+ }
+ }
+
+ if (!urb->status && r->callback)
+ r->callback(r->cb_data, r->buf, urb->actual_length);
+
+ spin_lock(&rx->lock);
+ put_rx_struct(rx, r);
+ spin_unlock(&rx->lock);
+
+ spin_unlock_irqrestore(&tx->lock, flags);
+
+#ifdef CONFIG_WIMAX_GDM72XX_USB_PM
+ usb_mark_last_busy(dev);
+#endif
+}
+
+static int gdm_usb_receive(void *priv_dev,
+ void (*cb)(void *cb_data, void *data, int len),
+ void *cb_data)
+{
+ struct usbwm_dev *udev = priv_dev;
+ struct usb_device *usbdev = udev->usbdev;
+ struct rx_cxt *rx = &udev->rx;
+ struct usb_rx *r;
+ unsigned long flags;
+
+ if (!udev->usbdev) {
+ printk(KERN_ERR "%s: No such device\n", __func__);
+ return -ENODEV;
+ }
+
+ spin_lock_irqsave(&rx->lock, flags);
+ r = get_rx_struct(rx);
+ spin_unlock_irqrestore(&rx->lock, flags);
+
+ if (r == NULL)
+ return -ENOMEM;
+
+ r->callback = cb;
+ r->cb_data = cb_data;
+
+ usb_fill_bulk_urb(r->urb,
+ usbdev,
+ usb_rcvbulkpipe(usbdev, 0x82),
+ r->buf,
+ RX_BUF_SIZE,
+ gdm_usb_rcv_complete,
+ r);
+
+ return usb_submit_urb(r->urb, GFP_ATOMIC);
+}
+
+#ifdef CONFIG_WIMAX_GDM72XX_USB_PM
+static void do_pm_control(struct work_struct *work)
+{
+ struct usbwm_dev *udev = container_of(work, struct usbwm_dev, pm_ws);
+ struct tx_cxt *tx = &udev->tx;
+ int ret;
+ unsigned long flags;
+
+ ret = usb_autopm_get_interface(udev->intf);
+ if (!ret)
+ usb_autopm_put_interface(udev->intf);
+
+ spin_lock_irqsave(&tx->lock, flags);
+ if (!(udev->usbdev->state & USB_STATE_SUSPENDED)
+ && (!list_empty(&tx->hci_list) || !list_empty(&tx->sdu_list))) {
+ struct usb_tx *t, *temp;
+
+ list_for_each_entry_safe(t, temp, &tx->pending_list, p_list) {
+ list_del(&t->p_list);
+ ret = usb_submit_urb(t->urb, GFP_ATOMIC);
+
+ if (ret) {
+ t->callback = NULL;
+ __gdm_usb_send_complete(t->urb);
+ }
+ }
+ }
+ spin_unlock_irqrestore(&tx->lock, flags);
+}
+#endif /* CONFIG_WIMAX_GDM72XX_USB_PM */
+
+static int gdm_usb_probe(struct usb_interface *intf,
+ const struct usb_device_id *id)
+{
+ int ret = 0;
+ u8 bConfigurationValue;
+ struct phy_dev *phy_dev = NULL;
+ struct usbwm_dev *udev = NULL;
+ u16 idVendor, idProduct, bcdDevice;
+
+ struct usb_device *usbdev = interface_to_usbdev(intf);
+
+ usb_get_dev(usbdev);
+ bConfigurationValue = usbdev->actconfig->desc.bConfigurationValue;
+
+ /*USB description is set up with Little-Endian*/
+ idVendor = L2H(usbdev->descriptor.idVendor);
+ idProduct = L2H(usbdev->descriptor.idProduct);
+ bcdDevice = L2H(usbdev->descriptor.bcdDevice);
+
+ printk(KERN_INFO "Found GDM USB VID = 0x%04x PID = 0x%04x...\n",
+ idVendor, idProduct);
+ printk(KERN_INFO "GCT WiMax driver version %s\n", DRIVER_VERSION);
+
+
+ if (idProduct == EMERGENCY_PID) {
+ ret = usb_emergency(usbdev);
+ goto out;
+ }
+
+ /* Support for EEPROM bootloader */
+ if (bConfigurationValue == DOWNLOAD_CONF_VALUE ||
+ idProduct & B_DOWNLOAD) {
+ ret = usb_boot(usbdev, bcdDevice);
+ goto out;
+ }
+
+ phy_dev = kzalloc(sizeof(*phy_dev), GFP_KERNEL);
+ if (phy_dev == NULL) {
+ ret = -ENOMEM;
+ goto out;
+ }
+ udev = kzalloc(sizeof(*udev), GFP_KERNEL);
+ if (udev == NULL) {
+ ret = -ENOMEM;
+ goto out;
+ }
+
+ if (idProduct == 0x7205 || idProduct == 0x7206)
+ udev->padding = GDM7205_PADDING;
+ else
+ udev->padding = 0;
+
+ phy_dev->priv_dev = (void *)udev;
+ phy_dev->send_func = gdm_usb_send;
+ phy_dev->rcv_func = gdm_usb_receive;
+
+ ret = init_usb(udev);
+ if (ret < 0)
+ goto out;
+
+ udev->usbdev = usbdev;
+
+#ifdef CONFIG_WIMAX_GDM72XX_USB_PM
+ udev->intf = intf;
+
+ intf->needs_remote_wakeup = 1;
+ device_init_wakeup(&intf->dev, 1);
+
+ pm_runtime_set_autosuspend_delay(&usbdev->dev, 10 * 1000); /* msec */
+
+ INIT_WORK(&udev->pm_ws, do_pm_control);
+#endif /* CONFIG_WIMAX_GDM72XX_USB_PM */
+
+ ret = register_wimax_device(phy_dev, &intf->dev);
+
+out:
+ if (ret) {
+ kfree(phy_dev);
+ kfree(udev);
+ }
+ usb_set_intfdata(intf, phy_dev);
+ return ret;
+}
+
+static void gdm_usb_disconnect(struct usb_interface *intf)
+{
+ u8 bConfigurationValue;
+ struct phy_dev *phy_dev;
+ struct usbwm_dev *udev;
+ u16 idProduct;
+ struct usb_device *usbdev = interface_to_usbdev(intf);
+
+ bConfigurationValue = usbdev->actconfig->desc.bConfigurationValue;
+ phy_dev = usb_get_intfdata(intf);
+
+ /*USB description is set up with Little-Endian*/
+ idProduct = L2H(usbdev->descriptor.idProduct);
+
+ if (idProduct != EMERGENCY_PID &&
+ bConfigurationValue != DOWNLOAD_CONF_VALUE &&
+ (idProduct & B_DOWNLOAD) == 0) {
+ udev = phy_dev->priv_dev;
+ udev->usbdev = NULL;
+
+ unregister_wimax_device(phy_dev);
+ release_usb(udev);
+ kfree(udev);
+ kfree(phy_dev);
+ }
+
+ usb_put_dev(usbdev);
+}
+
+#ifdef CONFIG_WIMAX_GDM72XX_USB_PM
+static int gdm_suspend(struct usb_interface *intf, pm_message_t pm_msg)
+{
+ struct phy_dev *phy_dev;
+ struct usbwm_dev *udev;
+ struct rx_cxt *rx;
+ struct usb_rx *r;
+
+ phy_dev = usb_get_intfdata(intf);
+ udev = phy_dev->priv_dev;
+ rx = &udev->rx;
+
+ list_for_each_entry(r, &rx->used_list, list)
+ usb_unlink_urb(r->urb);
+
+ return 0;
+}
+
+static int gdm_resume(struct usb_interface *intf)
+{
+ struct phy_dev *phy_dev;
+ struct usbwm_dev *udev;
+ struct rx_cxt *rx;
+ struct usb_rx *r;
+
+ phy_dev = usb_get_intfdata(intf);
+ udev = phy_dev->priv_dev;
+ rx = &udev->rx;
+
+ list_for_each_entry(r, &rx->used_list, list)
+ usb_submit_urb(r->urb, GFP_ATOMIC);
+
+ return 0;
+}
+
+#endif /* CONFIG_WIMAX_GDM72XX_USB_PM */
+
+#ifdef CONFIG_WIMAX_GDM72XX_K_MODE
+static int k_mode_thread(void *arg)
+{
+ struct usbwm_dev *udev;
+ struct tx_cxt *tx;
+ struct rx_cxt *rx;
+ struct usb_tx *t, *temp;
+ struct usb_rx *r;
+ unsigned long flags, flags2, expire;
+ int ret;
+
+ daemonize("k_mode_wimax");
+
+ while (!k_mode_stop) {
+
+ spin_lock_irqsave(&k_lock, flags2);
+ while (!list_empty(&k_list)) {
+
+ udev = list_entry(k_list.next, struct usbwm_dev, list);
+ tx = &udev->tx;
+ rx = &udev->rx;
+
+ list_del(&udev->list);
+ spin_unlock_irqrestore(&k_lock, flags2);
+
+ expire = jiffies + K_WAIT_TIME;
+ while (jiffies < expire)
+ schedule_timeout(K_WAIT_TIME);
+
+ list_for_each_entry(r, &rx->used_list, list)
+ usb_submit_urb(r->urb, GFP_ATOMIC);
+
+ spin_lock_irqsave(&tx->lock, flags);
+
+ list_for_each_entry_safe(t, temp, &tx->pending_list,
+ p_list) {
+ list_del(&t->p_list);
+ ret = usb_submit_urb(t->urb, GFP_ATOMIC);
+
+ if (ret) {
+ t->callback = NULL;
+ __gdm_usb_send_complete(t->urb);
+ }
+ }
+
+ udev->bw_switch = 0;
+ spin_unlock_irqrestore(&tx->lock, flags);
+
+ spin_lock_irqsave(&k_lock, flags2);
+ }
+ spin_unlock_irqrestore(&k_lock, flags2);
+
+ interruptible_sleep_on(&k_wait);
+ }
+ return 0;
+}
+#endif /* CONFIG_WIMAX_GDM72XX_K_MODE */
+
+static struct usb_driver gdm_usb_driver = {
+ .name = "gdm_wimax",
+ .probe = gdm_usb_probe,
+ .disconnect = gdm_usb_disconnect,
+ .id_table = id_table,
+#ifdef CONFIG_WIMAX_GDM72XX_USB_PM
+ .supports_autosuspend = 1,
+ .suspend = gdm_suspend,
+ .resume = gdm_resume,
+ .reset_resume = gdm_resume,
+#endif
+};
+
+static int __init usb_gdm_wimax_init(void)
+{
+#ifdef CONFIG_WIMAX_GDM72XX_K_MODE
+ kthread_run(k_mode_thread, NULL, "WiMax_thread");
+#endif /* CONFIG_WIMAX_GDM72XX_K_MODE */
+ return usb_register(&gdm_usb_driver);
+}
+
+static void __exit usb_gdm_wimax_exit(void)
+{
+#ifdef CONFIG_WIMAX_GDM72XX_K_MODE
+ k_mode_stop = 1;
+ wake_up(&k_wait);
+#endif
+ usb_deregister(&gdm_usb_driver);
+}
+
+module_init(usb_gdm_wimax_init);
+module_exit(usb_gdm_wimax_exit);
+
+MODULE_VERSION(DRIVER_VERSION);
+MODULE_DESCRIPTION("GCT WiMax Device Driver");
+MODULE_AUTHOR("Ethan Park");
+MODULE_LICENSE("GPL");
diff --git a/drivers/staging/gdm72xx/gdm_usb.h b/drivers/staging/gdm72xx/gdm_usb.h
new file mode 100644
index 000000000000..ecb891f6a599
--- /dev/null
+++ b/drivers/staging/gdm72xx/gdm_usb.h
@@ -0,0 +1,85 @@
+/*
+ * Copyright (c) 2012 GCT Semiconductor, Inc. All rights reserved.
+ *
+ * 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 __GDM_USB_H__
+#define __GDM_USB_H__
+
+#include <linux/types.h>
+#include <linux/usb.h>
+#include <linux/list.h>
+
+#define B_DIFF_DL_DRV (1<<4)
+#define B_DOWNLOAD (1 << 5)
+#define MAX_NR_SDU_BUF 64
+
+struct usb_tx {
+ struct list_head list;
+#if defined(CONFIG_WIMAX_GDM72XX_USB_PM) || defined(CONFIG_WIMAX_GDM72XX_K_MODE)
+ struct list_head p_list;
+#endif
+ struct tx_cxt *tx_cxt;
+
+ struct urb *urb;
+ u8 *buf;
+
+ void (*callback)(void *cb_data);
+ void *cb_data;
+};
+
+struct tx_cxt {
+ struct list_head free_list;
+ struct list_head sdu_list;
+ struct list_head hci_list;
+#if defined(CONFIG_WIMAX_GDM72XX_USB_PM) || defined(CONFIG_WIMAX_GDM72XX_K_MODE)
+ struct list_head pending_list;
+#endif
+
+ spinlock_t lock;
+};
+
+struct usb_rx {
+ struct list_head list;
+ struct rx_cxt *rx_cxt;
+
+ struct urb *urb;
+ u8 *buf;
+
+ void (*callback)(void *cb_data, void *data, int len);
+ void *cb_data;
+};
+
+struct rx_cxt {
+ struct list_head free_list;
+ struct list_head used_list;
+ spinlock_t lock;
+};
+
+struct usbwm_dev {
+ struct usb_device *usbdev;
+#ifdef CONFIG_WIMAX_GDM72XX_USB_PM
+ struct work_struct pm_ws;
+
+ struct usb_interface *intf;
+#endif
+#ifdef CONFIG_WIMAX_GDM72XX_K_MODE
+ int bw_switch;
+ struct list_head list;
+#endif
+
+ struct tx_cxt tx;
+ struct rx_cxt rx;
+
+ int padding;
+};
+
+#endif /* __GDM_USB_H__ */
diff --git a/drivers/staging/gdm72xx/gdm_wimax.c b/drivers/staging/gdm72xx/gdm_wimax.c
new file mode 100644
index 000000000000..0716efc1817d
--- /dev/null
+++ b/drivers/staging/gdm72xx/gdm_wimax.c
@@ -0,0 +1,1018 @@
+/*
+ * Copyright (c) 2012 GCT Semiconductor, Inc. All rights reserved.
+ *
+ * This software is licensed under the terms of the GNU General Public
+ * License version 2, as published by the Free Software Foundation, and
+ * may be copied, distributed, and modified under those terms.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+
+#include <linux/etherdevice.h>
+#include <asm/byteorder.h>
+#include <linux/ip.h>
+#include <linux/ipv6.h>
+#include <linux/udp.h>
+#include <linux/in.h>
+
+#include "gdm_wimax.h"
+#include "hci.h"
+#include "wm_ioctl.h"
+#include "netlink_k.h"
+
+#define gdm_wimax_send(n, d, l) \
+ (n->phy_dev->send_func)(n->phy_dev->priv_dev, d, l, NULL, NULL)
+#define gdm_wimax_send_with_cb(n, d, l, c, b) \
+ (n->phy_dev->send_func)(n->phy_dev->priv_dev, d, l, c, b)
+#define gdm_wimax_rcv_with_cb(n, c, b) \
+ (n->phy_dev->rcv_func)(n->phy_dev->priv_dev, c, b)
+
+#define EVT_MAX_SIZE 2048
+
+struct evt_entry {
+ struct list_head list;
+ struct net_device *dev;
+ char evt_data[EVT_MAX_SIZE];
+ int size;
+};
+
+static void __gdm_wimax_event_send(struct work_struct *work);
+static inline struct evt_entry *alloc_event_entry(void);
+static inline void free_event_entry(struct evt_entry *e);
+static struct evt_entry *get_event_entry(void);
+static void put_event_entry(struct evt_entry *e);
+
+static struct {
+ int ref_cnt;
+ struct sock *sock;
+ struct list_head evtq;
+ spinlock_t evt_lock;
+
+ struct list_head freeq;
+ struct work_struct ws;
+} wm_event;
+
+static u8 gdm_wimax_macaddr[6] = {0x00, 0x0a, 0x3b, 0xf0, 0x01, 0x30};
+
+static void gdm_wimax_ind_fsm_update(struct net_device *dev, struct fsm_s *fsm);
+static void gdm_wimax_ind_if_updown(struct net_device *dev, int if_up);
+
+#if defined(DEBUG_SDU)
+static void printk_hex(u8 *buf, u32 size)
+{
+ int i;
+
+ for (i = 0; i < size; i++) {
+ if (i && i % 16 == 0)
+ printk(KERN_DEBUG "\n%02x ", *buf++);
+ else
+ printk(KERN_DEBUG "%02x ", *buf++);
+ }
+
+ printk(KERN_DEBUG "\n");
+}
+
+static const char *get_protocol_name(u16 protocol)
+{
+ static char buf[32];
+ const char *name = "-";
+
+ switch (protocol) {
+ case ETH_P_ARP:
+ name = "ARP";
+ break;
+ case ETH_P_IP:
+ name = "IP";
+ break;
+ case ETH_P_IPV6:
+ name = "IPv6";
+ break;
+ }
+
+ sprintf(buf, "0x%04x(%s)", protocol, name);
+ return buf;
+}
+
+static const char *get_ip_protocol_name(u8 ip_protocol)
+{
+ static char buf[32];
+ const char *name = "-";
+
+ switch (ip_protocol) {
+ case IPPROTO_TCP:
+ name = "TCP";
+ break;
+ case IPPROTO_UDP:
+ name = "UDP";
+ break;
+ case IPPROTO_ICMP:
+ name = "ICMP";
+ break;
+ }
+
+ sprintf(buf, "%u(%s)", ip_protocol, name);
+ return buf;
+}
+
+static const char *get_port_name(u16 port)
+{
+ static char buf[32];
+ const char *name = "-";
+
+ switch (port) {
+ case 67:
+ name = "DHCP-Server";
+ break;
+ case 68:
+ name = "DHCP-Client";
+ break;
+ case 69:
+ name = "TFTP";
+ break;
+ }
+
+ sprintf(buf, "%u(%s)", port, name);
+ return buf;
+}
+
+static void dump_eth_packet(const char *title, u8 *data, int len)
+{
+ struct iphdr *ih = NULL;
+ struct udphdr *uh = NULL;
+ u16 protocol = 0;
+ u8 ip_protocol = 0;
+ u16 port = 0;
+
+ protocol = (data[12]<<8) | data[13];
+ ih = (struct iphdr *) (data+ETH_HLEN);
+
+ if (protocol == ETH_P_IP) {
+ uh = (struct udphdr *) ((char *)ih + sizeof(struct iphdr));
+ ip_protocol = ih->protocol;
+ port = ntohs(uh->dest);
+ } else if (protocol == ETH_P_IPV6) {
+ struct ipv6hdr *i6h = (struct ipv6hdr *) data;
+ uh = (struct udphdr *) ((char *)i6h + sizeof(struct ipv6hdr));
+ ip_protocol = i6h->nexthdr;
+ port = ntohs(uh->dest);
+ }
+
+ printk(KERN_DEBUG "[%s] len=%d, %s, %s, %s\n",
+ title, len,
+ get_protocol_name(protocol),
+ get_ip_protocol_name(ip_protocol),
+ get_port_name(port));
+
+ #if 1
+ if (!(data[0] == 0xff && data[1] == 0xff)) {
+ if (protocol == ETH_P_IP) {
+ printk(KERN_DEBUG " src=%u.%u.%u.%u\n",
+ NIPQUAD(ih->saddr));
+ } else if (protocol == ETH_P_IPV6) {
+ #ifdef NIP6
+ printk(KERN_DEBUG " src=%x:%x:%x:%x:%x:%x:%x:%x\n",
+ NIP6(ih->saddr));
+ #else
+ printk(KERN_DEBUG " src=%pI6\n", &ih->saddr);
+ #endif
+ }
+ }
+ #endif
+
+ #if (DUMP_PACKET & DUMP_SDU_ALL)
+ printk_hex(data, len);
+ #else
+ #if (DUMP_PACKET & DUMP_SDU_ARP)
+ if (protocol == ETH_P_ARP)
+ printk_hex(data, len);
+ #endif
+ #if (DUMP_PACKET & DUMP_SDU_IP)
+ if (protocol == ETH_P_IP || protocol == ETH_P_IPV6)
+ printk_hex(data, len);
+ #else
+ #if (DUMP_PACKET & DUMP_SDU_IP_TCP)
+ if (ip_protocol == IPPROTO_TCP)
+ printk_hex(data, len);
+ #endif
+ #if (DUMP_PACKET & DUMP_SDU_IP_UDP)
+ if (ip_protocol == IPPROTO_UDP)
+ printk_hex(data, len);
+ #endif
+ #if (DUMP_PACKET & DUMP_SDU_IP_ICMP)
+ if (ip_protocol == IPPROTO_ICMP)
+ printk_hex(data, len);
+ #endif
+ #endif
+ #endif
+}
+#endif
+
+
+static inline int gdm_wimax_header(struct sk_buff **pskb)
+{
+ u16 buf[HCI_HEADER_SIZE / sizeof(u16)];
+ struct sk_buff *skb = *pskb;
+ int ret = 0;
+
+ if (unlikely(skb_headroom(skb) < HCI_HEADER_SIZE)) {
+ struct sk_buff *skb2;
+
+ skb2 = skb_realloc_headroom(skb, HCI_HEADER_SIZE);
+ if (skb2 == NULL)
+ return -ENOMEM;
+ if (skb->sk)
+ skb_set_owner_w(skb2, skb->sk);
+ kfree_skb(skb);
+ skb = skb2;
+ }
+
+ skb_push(skb, HCI_HEADER_SIZE);
+ buf[0] = H2B(WIMAX_TX_SDU);
+ buf[1] = H2B(skb->len - HCI_HEADER_SIZE);
+ memcpy(skb->data, buf, HCI_HEADER_SIZE);
+
+ *pskb = skb;
+ return ret;
+}
+
+static void gdm_wimax_event_rcv(struct net_device *dev, u16 type, void *msg,
+ int len)
+{
+ struct nic *nic = netdev_priv(dev);
+
+ #if defined(DEBUG_HCI)
+ u8 *buf = (u8 *) msg;
+ u16 hci_cmd = (buf[0]<<8) | buf[1];
+ u16 hci_len = (buf[2]<<8) | buf[3];
+ printk(KERN_DEBUG "H=>D: 0x%04x(%d)\n", hci_cmd, hci_len);
+ #endif
+
+ gdm_wimax_send(nic, msg, len);
+}
+
+static int gdm_wimax_event_init(void)
+{
+ if (!wm_event.ref_cnt) {
+ wm_event.sock = netlink_init(NETLINK_WIMAX,
+ gdm_wimax_event_rcv);
+ if (wm_event.sock)
+ wm_event.ref_cnt++;
+ INIT_LIST_HEAD(&wm_event.evtq);
+ INIT_LIST_HEAD(&wm_event.freeq);
+ INIT_WORK(&wm_event.ws, __gdm_wimax_event_send);
+ spin_lock_init(&wm_event.evt_lock);
+ return 0;
+ }
+
+ printk(KERN_ERR "Creating WiMax Event netlink is failed\n");
+ return -1;
+}
+
+static void gdm_wimax_event_exit(void)
+{
+ if (wm_event.sock && --wm_event.ref_cnt == 0) {
+ struct evt_entry *e, *temp;
+ unsigned long flags;
+
+ spin_lock_irqsave(&wm_event.evt_lock, flags);
+
+ list_for_each_entry_safe(e, temp, &wm_event.evtq, list) {
+ list_del(&e->list);
+ free_event_entry(e);
+ }
+ list_for_each_entry_safe(e, temp, &wm_event.freeq, list) {
+ list_del(&e->list);
+ free_event_entry(e);
+ }
+
+ spin_unlock_irqrestore(&wm_event.evt_lock, flags);
+ netlink_exit(wm_event.sock);
+ wm_event.sock = NULL;
+ }
+}
+
+static inline struct evt_entry *alloc_event_entry(void)
+{
+ return kmalloc(sizeof(struct evt_entry), GFP_ATOMIC);
+}
+
+static inline void free_event_entry(struct evt_entry *e)
+{
+ kfree(e);
+}
+
+static struct evt_entry *get_event_entry(void)
+{
+ struct evt_entry *e;
+
+ if (list_empty(&wm_event.freeq))
+ e = alloc_event_entry();
+ else {
+ e = list_entry(wm_event.freeq.next, struct evt_entry, list);
+ list_del(&e->list);
+ }
+
+ return e;
+}
+
+static void put_event_entry(struct evt_entry *e)
+{
+ BUG_ON(!e);
+
+ list_add_tail(&e->list, &wm_event.freeq);
+}
+
+static void __gdm_wimax_event_send(struct work_struct *work)
+{
+ int idx;
+ unsigned long flags;
+ struct evt_entry *e;
+
+ spin_lock_irqsave(&wm_event.evt_lock, flags);
+
+ while (!list_empty(&wm_event.evtq)) {
+ e = list_entry(wm_event.evtq.next, struct evt_entry, list);
+ spin_unlock_irqrestore(&wm_event.evt_lock, flags);
+
+ sscanf(e->dev->name, "wm%d", &idx);
+ netlink_send(wm_event.sock, idx, 0, e->evt_data, e->size);
+
+ spin_lock_irqsave(&wm_event.evt_lock, flags);
+ list_del(&e->list);
+ put_event_entry(e);
+ }
+
+ spin_unlock_irqrestore(&wm_event.evt_lock, flags);
+}
+
+static int gdm_wimax_event_send(struct net_device *dev, char *buf, int size)
+{
+ struct evt_entry *e;
+ unsigned long flags;
+
+ #if defined(DEBUG_HCI)
+ u16 hci_cmd = ((u8)buf[0]<<8) | (u8)buf[1];
+ u16 hci_len = ((u8)buf[2]<<8) | (u8)buf[3];
+ printk(KERN_DEBUG "D=>H: 0x%04x(%d)\n", hci_cmd, hci_len);
+ #endif
+
+ spin_lock_irqsave(&wm_event.evt_lock, flags);
+
+ e = get_event_entry();
+ if (!e) {
+ printk(KERN_ERR "%s: No memory for event\n", __func__);
+ spin_unlock_irqrestore(&wm_event.evt_lock, flags);
+ return -ENOMEM;
+ }
+
+ e->dev = dev;
+ e->size = size;
+ memcpy(e->evt_data, buf, size);
+
+ list_add_tail(&e->list, &wm_event.evtq);
+ spin_unlock_irqrestore(&wm_event.evt_lock, flags);
+
+ schedule_work(&wm_event.ws);
+
+ return 0;
+}
+
+static void tx_complete(void *arg)
+{
+ struct nic *nic = arg;
+
+ if (netif_queue_stopped(nic->netdev))
+ netif_wake_queue(nic->netdev);
+}
+
+int gdm_wimax_send_tx(struct sk_buff *skb, struct net_device *dev)
+{
+ int ret = 0;
+ struct nic *nic = netdev_priv(dev);
+
+ ret = gdm_wimax_send_with_cb(nic, skb->data, skb->len, tx_complete,
+ nic);
+ if (ret == -ENOSPC) {
+ netif_stop_queue(dev);
+ ret = 0;
+ }
+
+ if (ret) {
+ skb_pull(skb, HCI_HEADER_SIZE);
+ return ret;
+ }
+
+ nic->stats.tx_packets++;
+ nic->stats.tx_bytes += skb->len - HCI_HEADER_SIZE;
+ kfree_skb(skb);
+ return ret;
+}
+
+static int gdm_wimax_tx(struct sk_buff *skb, struct net_device *dev)
+{
+ int ret = 0;
+ struct nic *nic = netdev_priv(dev);
+ struct fsm_s *fsm = (struct fsm_s *) nic->sdk_data[SIOC_DATA_FSM].buf;
+
+ #if defined(DEBUG_SDU)
+ dump_eth_packet("TX", skb->data, skb->len);
+ #endif
+
+ ret = gdm_wimax_header(&skb);
+ if (ret < 0) {
+ skb_pull(skb, HCI_HEADER_SIZE);
+ return ret;
+ }
+
+ #if !defined(LOOPBACK_TEST)
+ if (!fsm)
+ printk(KERN_ERR "ASSERTION ERROR: fsm is NULL!!\n");
+ else if (fsm->m_status != M_CONNECTED) {
+ printk(KERN_EMERG "ASSERTION ERROR: Device is NOT ready. status=%d\n",
+ fsm->m_status);
+ kfree_skb(skb);
+ return 0;
+ }
+ #endif
+
+#if defined(CONFIG_WIMAX_GDM72XX_QOS)
+ ret = gdm_qos_send_hci_pkt(skb, dev);
+#else
+ ret = gdm_wimax_send_tx(skb, dev);
+#endif
+ return ret;
+}
+
+static int gdm_wimax_set_config(struct net_device *dev, struct ifmap *map)
+{
+ if (dev->flags & IFF_UP)
+ return -EBUSY;
+
+ return 0;
+}
+
+static void __gdm_wimax_set_mac_addr(struct net_device *dev, char *mac_addr)
+{
+ u16 hci_pkt_buf[32 / sizeof(u16)];
+ u8 *pkt = (u8 *) &hci_pkt_buf[0];
+ struct nic *nic = netdev_priv(dev);
+
+ /* Since dev is registered as a ethernet device,
+ * ether_setup has made dev->addr_len to be ETH_ALEN
+ */
+ memcpy(dev->dev_addr, mac_addr, dev->addr_len);
+
+ /* Let lower layer know of this change by sending
+ * SetInformation(MAC Address)
+ */
+ hci_pkt_buf[0] = H2B(WIMAX_SET_INFO); /* cmd_evt */
+ hci_pkt_buf[1] = H2B(8); /* size */
+ pkt[4] = 0; /* T */
+ pkt[5] = 6; /* L */
+ memcpy(pkt + 6, mac_addr, dev->addr_len); /* V */
+
+ gdm_wimax_send(nic, pkt, HCI_HEADER_SIZE + 8);
+}
+
+/* A driver function */
+static int gdm_wimax_set_mac_addr(struct net_device *dev, void *p)
+{
+ struct sockaddr *addr = p;
+
+ if (netif_running(dev))
+ return -EBUSY;
+
+ if (!is_valid_ether_addr(addr->sa_data))
+ return -EADDRNOTAVAIL;
+
+ __gdm_wimax_set_mac_addr(dev, addr->sa_data);
+
+ return 0;
+}
+
+static struct net_device_stats *gdm_wimax_stats(struct net_device *dev)
+{
+ struct nic *nic = netdev_priv(dev);
+
+ return &nic->stats;
+}
+
+static int gdm_wimax_open(struct net_device *dev)
+{
+ struct nic *nic = netdev_priv(dev);
+ struct fsm_s *fsm = (struct fsm_s *) nic->sdk_data[SIOC_DATA_FSM].buf;
+
+ netif_start_queue(dev);
+
+ if (fsm && fsm->m_status != M_INIT)
+ gdm_wimax_ind_if_updown(dev, 1);
+ return 0;
+}
+
+static int gdm_wimax_close(struct net_device *dev)
+{
+ struct nic *nic = netdev_priv(dev);
+ struct fsm_s *fsm = (struct fsm_s *) nic->sdk_data[SIOC_DATA_FSM].buf;
+
+ netif_stop_queue(dev);
+
+ if (fsm && fsm->m_status != M_INIT)
+ gdm_wimax_ind_if_updown(dev, 0);
+ return 0;
+}
+
+static void kdelete(void **buf)
+{
+ if (buf && *buf) {
+ kfree(*buf);
+ *buf = NULL;
+ }
+}
+
+static int gdm_wimax_ioctl_get_data(struct data_s *dst, struct data_s *src)
+{
+ int size;
+
+ size = dst->size < src->size ? dst->size : src->size;
+
+ dst->size = size;
+ if (src->size) {
+ if (!dst->buf)
+ return -EINVAL;
+ if (copy_to_user(dst->buf, src->buf, size))
+ return -EFAULT;
+ }
+ return 0;
+}
+
+static int gdm_wimax_ioctl_set_data(struct data_s *dst, struct data_s *src)
+{
+ if (!src->size) {
+ dst->size = 0;
+ return 0;
+ }
+
+ if (!src->buf)
+ return -EINVAL;
+
+ if (!(dst->buf && dst->size == src->size)) {
+ kdelete(&dst->buf);
+ dst->buf = kmalloc(src->size, GFP_KERNEL);
+ if (dst->buf == NULL)
+ return -ENOMEM;
+ }
+
+ if (copy_from_user(dst->buf, src->buf, src->size)) {
+ kdelete(&dst->buf);
+ return -EFAULT;
+ }
+ dst->size = src->size;
+ return 0;
+}
+
+static void gdm_wimax_cleanup_ioctl(struct net_device *dev)
+{
+ struct nic *nic = netdev_priv(dev);
+ int i;
+
+ for (i = 0; i < SIOC_DATA_MAX; i++)
+ kdelete(&nic->sdk_data[i].buf);
+}
+
+static void gdm_update_fsm(struct net_device *dev, struct fsm_s *new_fsm)
+{
+ struct nic *nic = netdev_priv(dev);
+ struct fsm_s *cur_fsm =
+ (struct fsm_s *) nic->sdk_data[SIOC_DATA_FSM].buf;
+
+ if (!cur_fsm)
+ return;
+
+ if (cur_fsm->m_status != new_fsm->m_status ||
+ cur_fsm->c_status != new_fsm->c_status) {
+ if (new_fsm->m_status == M_CONNECTED)
+ netif_carrier_on(dev);
+ else if (cur_fsm->m_status == M_CONNECTED) {
+ netif_carrier_off(dev);
+ #if defined(CONFIG_WIMAX_GDM72XX_QOS)
+ gdm_qos_release_list(nic);
+ #endif
+ }
+ gdm_wimax_ind_fsm_update(dev, new_fsm);
+ }
+}
+
+static int gdm_wimax_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
+{
+ struct wm_req_s *req = (struct wm_req_s *) ifr;
+ struct nic *nic = netdev_priv(dev);
+ int ret;
+
+ if (cmd != SIOCWMIOCTL)
+ return -EOPNOTSUPP;
+
+ switch (req->cmd) {
+ case SIOCG_DATA:
+ case SIOCS_DATA:
+ if (req->data_id >= SIOC_DATA_MAX) {
+ printk(KERN_ERR
+ "%s error: data-index(%d) is invalid!!\n",
+ __func__, req->data_id);
+ return -EOPNOTSUPP;
+ }
+ if (req->cmd == SIOCG_DATA) {
+ ret = gdm_wimax_ioctl_get_data(&req->data,
+ &nic->sdk_data[req->data_id]);
+ if (ret < 0)
+ return ret;
+ } else if (req->cmd == SIOCS_DATA) {
+ if (req->data_id == SIOC_DATA_FSM) {
+ /*NOTE: gdm_update_fsm should be called
+ before gdm_wimax_ioctl_set_data is called*/
+ gdm_update_fsm(dev,
+ (struct fsm_s *) req->data.buf);
+ }
+ ret = gdm_wimax_ioctl_set_data(
+ &nic->sdk_data[req->data_id], &req->data);
+ if (ret < 0)
+ return ret;
+ }
+ break;
+ default:
+ printk(KERN_ERR "%s: %x unknown ioctl\n", __func__, cmd);
+ return -EOPNOTSUPP;
+ }
+
+ return 0;
+}
+
+static void gdm_wimax_prepare_device(struct net_device *dev)
+{
+ struct nic *nic = netdev_priv(dev);
+ u16 buf[32 / sizeof(u16)];
+ struct hci_s *hci = (struct hci_s *) buf;
+ u16 len = 0;
+ u32 val = 0;
+
+ #define BIT_MULTI_CS 0
+ #define BIT_WIMAX 1
+ #define BIT_QOS 2
+ #define BIT_AGGREGATION 3
+
+ /* GetInformation mac address */
+ len = 0;
+ hci->cmd_evt = H2B(WIMAX_GET_INFO);
+ hci->data[len++] = TLV_T(T_MAC_ADDRESS);
+ hci->length = H2B(len);
+ gdm_wimax_send(nic, hci, HCI_HEADER_SIZE+len);
+
+ val = (1<<BIT_WIMAX) | (1<<BIT_MULTI_CS);
+ #if defined(CONFIG_WIMAX_GDM72XX_QOS)
+ val |= (1<<BIT_QOS);
+ #endif
+ #if defined(CONFIG_WIMAX_GDM72XX_WIMAX2)
+ val |= (1<<BIT_AGGREGATION);
+ #endif
+
+ /* Set capability */
+ len = 0;
+ hci->cmd_evt = H2B(WIMAX_SET_INFO);
+ hci->data[len++] = TLV_T(T_CAPABILITY);
+ hci->data[len++] = TLV_L(T_CAPABILITY);
+ val = DH2B(val);
+ memcpy(&hci->data[len], &val, TLV_L(T_CAPABILITY));
+ len += TLV_L(T_CAPABILITY);
+ hci->length = H2B(len);
+ gdm_wimax_send(nic, hci, HCI_HEADER_SIZE+len);
+
+ printk(KERN_INFO "GDM WiMax Set CAPABILITY: 0x%08X\n", DB2H(val));
+}
+
+static int gdm_wimax_hci_get_tlv(u8 *buf, u8 *T, u16 *L, u8 **V)
+{
+ #define __U82U16(b) ((u16)((u8 *)(b))[0] | ((u16)((u8 *)(b))[1] << 8))
+ int next_pos;
+
+ *T = buf[0];
+ if (buf[1] == 0x82) {
+ *L = B2H(__U82U16(&buf[2]));
+ next_pos = 1/*type*/+3/*len*/;
+ } else {
+ *L = buf[1];
+ next_pos = 1/*type*/+1/*len*/;
+ }
+ *V = &buf[next_pos];
+
+ next_pos += *L/*length of val*/;
+ return next_pos;
+}
+
+static int gdm_wimax_get_prepared_info(struct net_device *dev, char *buf,
+ int len)
+{
+ u8 T, *V;
+ u16 L;
+ u16 cmd_evt, cmd_len;
+ int pos = HCI_HEADER_SIZE;
+
+ cmd_evt = B2H(*(u16 *)&buf[0]);
+ cmd_len = B2H(*(u16 *)&buf[2]);
+
+ if (len < cmd_len + HCI_HEADER_SIZE) {
+ printk(KERN_ERR "%s: invalid length [%d/%d]\n", __func__,
+ cmd_len + HCI_HEADER_SIZE, len);
+ return -1;
+ }
+
+ if (cmd_evt == WIMAX_GET_INFO_RESULT) {
+ if (cmd_len < 2) {
+ printk(KERN_ERR "%s: len is too short [%x/%d]\n",
+ __func__, cmd_evt, len);
+ return -1;
+ }
+
+ pos += gdm_wimax_hci_get_tlv(&buf[pos], &T, &L, &V);
+ if (T == TLV_T(T_MAC_ADDRESS)) {
+ if (L != dev->addr_len) {
+ printk(KERN_ERR
+ "%s Invalid inofrmation result T/L "
+ "[%x/%d]\n", __func__, T, L);
+ return -1;
+ }
+ printk(KERN_INFO "MAC change [%pM]->[%pM]\n",
+ dev->dev_addr, V);
+ memcpy(dev->dev_addr, V, dev->addr_len);
+ return 1;
+ }
+ }
+
+ gdm_wimax_event_send(dev, buf, len);
+ return 0;
+}
+
+static void gdm_wimax_netif_rx(struct net_device *dev, char *buf, int len)
+{
+ struct nic *nic = netdev_priv(dev);
+ struct sk_buff *skb;
+ int ret;
+
+ #if defined(DEBUG_SDU)
+ dump_eth_packet("RX", buf, len);
+ #endif
+
+ skb = dev_alloc_skb(len + 2);
+ if (!skb) {
+ printk(KERN_ERR "%s: dev_alloc_skb failed!\n", __func__);
+ return;
+ }
+ skb_reserve(skb, 2);
+
+ nic->stats.rx_packets++;
+ nic->stats.rx_bytes += len;
+
+ memcpy(skb_put(skb, len), buf, len);
+
+ skb->dev = dev;
+ skb->protocol = eth_type_trans(skb, dev); /* what will happen? */
+
+ ret = in_interrupt() ? netif_rx(skb) : netif_rx_ni(skb);
+ if (ret == NET_RX_DROP)
+ printk(KERN_ERR "%s skb dropped\n", __func__);
+}
+
+static void gdm_wimax_transmit_aggr_pkt(struct net_device *dev, char *buf,
+ int len)
+{
+ #define HCI_PADDING_BYTE 4
+ #define HCI_RESERVED_BYTE 4
+ struct hci_s *hci;
+ int length;
+
+ while (len > 0) {
+ hci = (struct hci_s *) buf;
+
+ if (B2H(hci->cmd_evt) != WIMAX_RX_SDU) {
+ printk(KERN_ERR "Wrong cmd_evt(0x%04X)\n",
+ B2H(hci->cmd_evt));
+ break;
+ }
+
+ length = B2H(hci->length);
+ gdm_wimax_netif_rx(dev, hci->data, length);
+
+ if (length & 0x3) {
+ /* Add padding size */
+ length += HCI_PADDING_BYTE - (length & 0x3);
+ }
+
+ length += HCI_HEADER_SIZE + HCI_RESERVED_BYTE;
+ len -= length;
+ buf += length;
+ }
+}
+
+static void gdm_wimax_transmit_pkt(struct net_device *dev, char *buf, int len)
+{
+ #if defined(CONFIG_WIMAX_GDM72XX_QOS)
+ struct nic *nic = netdev_priv(dev);
+ #endif
+ u16 cmd_evt, cmd_len;
+
+ /* This code is added for certain rx packet to be ignored. */
+ if (len == 0)
+ return;
+
+ cmd_evt = B2H(*(u16 *)&buf[0]);
+ cmd_len = B2H(*(u16 *)&buf[2]);
+
+ if (len < cmd_len + HCI_HEADER_SIZE) {
+ if (len)
+ printk(KERN_ERR "%s: invalid length [%d/%d]\n",
+ __func__, cmd_len + HCI_HEADER_SIZE, len);
+ return;
+ }
+
+ switch (cmd_evt) {
+ case WIMAX_RX_SDU_AGGR:
+ gdm_wimax_transmit_aggr_pkt(dev, &buf[HCI_HEADER_SIZE],
+ cmd_len);
+ break;
+ case WIMAX_RX_SDU:
+ gdm_wimax_netif_rx(dev, &buf[HCI_HEADER_SIZE], cmd_len);
+ break;
+ #if defined(CONFIG_WIMAX_GDM72XX_QOS)
+ case WIMAX_EVT_MODEM_REPORT:
+ gdm_recv_qos_hci_packet(nic, buf, len);
+ break;
+ #endif
+ case WIMAX_SDU_TX_FLOW:
+ if (buf[4] == 0) {
+ if (!netif_queue_stopped(dev))
+ netif_stop_queue(dev);
+ } else if (buf[4] == 1) {
+ if (netif_queue_stopped(dev))
+ netif_wake_queue(dev);
+ }
+ break;
+ default:
+ gdm_wimax_event_send(dev, buf, len);
+ break;
+ }
+}
+
+static void gdm_wimax_ind_fsm_update(struct net_device *dev, struct fsm_s *fsm)
+{
+ u16 buf[32 / sizeof(u16)];
+ u8 *hci_pkt_buf = (u8 *)&buf[0];
+
+ /* Indicate updating fsm */
+ buf[0] = H2B(WIMAX_FSM_UPDATE);
+ buf[1] = H2B(sizeof(struct fsm_s));
+ memcpy(&hci_pkt_buf[HCI_HEADER_SIZE], fsm, sizeof(struct fsm_s));
+
+ gdm_wimax_event_send(dev, hci_pkt_buf,
+ HCI_HEADER_SIZE + sizeof(struct fsm_s));
+}
+
+static void gdm_wimax_ind_if_updown(struct net_device *dev, int if_up)
+{
+ u16 buf[32 / sizeof(u16)];
+ struct hci_s *hci = (struct hci_s *) buf;
+ unsigned char up_down;
+
+ up_down = if_up ? WIMAX_IF_UP : WIMAX_IF_DOWN;
+
+ /* Indicate updating fsm */
+ hci->cmd_evt = H2B(WIMAX_IF_UPDOWN);
+ hci->length = H2B(sizeof(up_down));
+ hci->data[0] = up_down;
+
+ gdm_wimax_event_send(dev, (char *)hci, HCI_HEADER_SIZE+sizeof(up_down));
+}
+
+static void rx_complete(void *arg, void *data, int len)
+{
+ struct nic *nic = arg;
+
+ gdm_wimax_transmit_pkt(nic->netdev, data, len);
+ gdm_wimax_rcv_with_cb(nic, rx_complete, nic);
+}
+
+static void prepare_rx_complete(void *arg, void *data, int len)
+{
+ struct nic *nic = arg;
+ int ret;
+
+ ret = gdm_wimax_get_prepared_info(nic->netdev, data, len);
+ if (ret == 1)
+ gdm_wimax_rcv_with_cb(nic, rx_complete, nic);
+ else {
+ if (ret < 0)
+ printk(KERN_ERR "get_prepared_info failed(%d)\n", ret);
+ gdm_wimax_rcv_with_cb(nic, prepare_rx_complete, nic);
+ #if 0
+ /* Re-prepare WiMax device */
+ gdm_wimax_prepare_device(nic->netdev);
+ #endif
+ }
+}
+
+static void start_rx_proc(struct nic *nic)
+{
+ gdm_wimax_rcv_with_cb(nic, prepare_rx_complete, nic);
+}
+
+static struct net_device_ops gdm_netdev_ops = {
+ .ndo_open = gdm_wimax_open,
+ .ndo_stop = gdm_wimax_close,
+ .ndo_set_config = gdm_wimax_set_config,
+ .ndo_start_xmit = gdm_wimax_tx,
+ .ndo_get_stats = gdm_wimax_stats,
+ .ndo_set_mac_address = gdm_wimax_set_mac_addr,
+ .ndo_do_ioctl = gdm_wimax_ioctl,
+};
+
+int register_wimax_device(struct phy_dev *phy_dev, struct device *pdev)
+{
+ struct nic *nic = NULL;
+ struct net_device *dev;
+ int ret;
+
+ dev = (struct net_device *)alloc_netdev(sizeof(*nic),
+ "wm%d", ether_setup);
+
+ if (dev == NULL) {
+ printk(KERN_ERR "alloc_etherdev failed\n");
+ return -ENOMEM;
+ }
+
+ SET_NETDEV_DEV(dev, pdev);
+ dev->mtu = 1400;
+ dev->netdev_ops = &gdm_netdev_ops;
+ dev->flags &= ~IFF_MULTICAST;
+ memcpy(dev->dev_addr, gdm_wimax_macaddr, sizeof(gdm_wimax_macaddr));
+
+ nic = netdev_priv(dev);
+ memset(nic, 0, sizeof(*nic));
+
+ nic->netdev = dev;
+ nic->phy_dev = phy_dev;
+ phy_dev->netdev = dev;
+
+ /* event socket init */
+ ret = gdm_wimax_event_init();
+ if (ret < 0) {
+ printk(KERN_ERR "Cannot create event.\n");
+ goto cleanup;
+ }
+
+ ret = register_netdev(dev);
+ if (ret)
+ goto cleanup;
+
+ #if defined(LOOPBACK_TEST)
+ netif_start_queue(dev);
+ netif_carrier_on(dev);
+ #else
+ netif_carrier_off(dev);
+ #endif
+
+#ifdef CONFIG_WIMAX_GDM72XX_QOS
+ gdm_qos_init(nic);
+#endif
+
+ start_rx_proc(nic);
+
+ /* Prepare WiMax device */
+ gdm_wimax_prepare_device(dev);
+
+ return 0;
+
+cleanup:
+ printk(KERN_ERR "register_netdev failed\n");
+ free_netdev(dev);
+ return ret;
+}
+
+void unregister_wimax_device(struct phy_dev *phy_dev)
+{
+ struct nic *nic = netdev_priv(phy_dev->netdev);
+ struct fsm_s *fsm = (struct fsm_s *) nic->sdk_data[SIOC_DATA_FSM].buf;
+
+ if (fsm)
+ fsm->m_status = M_INIT;
+ unregister_netdev(nic->netdev);
+
+ gdm_wimax_event_exit();
+
+#if defined(CONFIG_WIMAX_GDM72XX_QOS)
+ gdm_qos_release_list(nic);
+#endif
+
+ gdm_wimax_cleanup_ioctl(phy_dev->netdev);
+
+ free_netdev(nic->netdev);
+}
diff --git a/drivers/staging/gdm72xx/gdm_wimax.h b/drivers/staging/gdm72xx/gdm_wimax.h
new file mode 100644
index 000000000000..6ec0ab43e9cc
--- /dev/null
+++ b/drivers/staging/gdm72xx/gdm_wimax.h
@@ -0,0 +1,91 @@
+/*
+ * Copyright (c) 2012 GCT Semiconductor, Inc. All rights reserved.
+ *
+ * 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 __GDM_WIMAX_H__
+#define __GDM_WIMAX_H__
+
+#include <linux/netdevice.h>
+#include <linux/types.h>
+#include "wm_ioctl.h"
+#if defined(CONFIG_WIMAX_GDM72XX_QOS)
+#include "gdm_qos.h"
+#endif
+
+#define DRIVER_VERSION "3.2.3"
+
+/*#define ETH_P_IP 0x0800 */
+/*#define ETH_P_ARP 0x0806 */
+/*#define ETH_P_IPV6 0x86DD */
+
+#define H2L(x) __cpu_to_le16(x)
+#define L2H(x) __le16_to_cpu(x)
+#define DH2L(x) __cpu_to_le32(x)
+#define DL2H(x) __le32_to_cpu(x)
+
+#define H2B(x) __cpu_to_be16(x)
+#define B2H(x) __be16_to_cpu(x)
+#define DH2B(x) __cpu_to_be32(x)
+#define DB2H(x) __be32_to_cpu(x)
+
+struct phy_dev {
+ void *priv_dev;
+ struct net_device *netdev;
+
+ int (*send_func)(void *priv_dev, void *data, int len,
+ void (*cb)(void *cb_data), void *cb_data);
+ int (*rcv_func)(void *priv_dev,
+ void (*cb)(void *cb_data, void *data, int len),
+ void *cb_data);
+};
+
+struct nic {
+ struct net_device *netdev;
+ struct phy_dev *phy_dev;
+
+ struct net_device_stats stats;
+
+ struct data_s sdk_data[SIOC_DATA_MAX];
+
+#if defined(CONFIG_WIMAX_GDM72XX_QOS)
+ struct qos_cb_s qos;
+#endif
+
+};
+
+
+#if 0
+#define dprintk(fmt, args ...) printk(KERN_DEBUG " [GDM] " fmt, ## args)
+#else
+#define dprintk(...)
+#endif
+
+/*#define DEBUG_SDU */
+#if defined(DEBUG_SDU)
+#define DUMP_SDU_ALL (1<<0)
+#define DUMP_SDU_ARP (1<<1)
+#define DUMP_SDU_IP (1<<2)
+#define DUMP_SDU_IP_TCP (1<<8)
+#define DUMP_SDU_IP_UDP (1<<9)
+#define DUMP_SDU_IP_ICMP (1<<10)
+#define DUMP_PACKET (DUMP_SDU_ALL)
+#endif
+
+/*#define DEBUG_HCI */
+
+/*#define LOOPBACK_TEST */
+
+extern int register_wimax_device(struct phy_dev *phy_dev, struct device *pdev);
+extern int gdm_wimax_send_tx(struct sk_buff *skb, struct net_device *dev);
+extern void unregister_wimax_device(struct phy_dev *phy_dev);
+
+#endif
diff --git a/drivers/staging/gdm72xx/hci.h b/drivers/staging/gdm72xx/hci.h
new file mode 100644
index 000000000000..0e0676622f1d
--- /dev/null
+++ b/drivers/staging/gdm72xx/hci.h
@@ -0,0 +1,218 @@
+/*
+ * Copyright (c) 2012 GCT Semiconductor, Inc. All rights reserved.
+ *
+ * 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 HCI_H_20080801
+#define HCI_H_20080801
+
+#define HCI_HEADER_SIZE 4
+#define HCI_VALUE_OFFS (HCI_HEADER_SIZE)
+#define HCI_MAX_PACKET 2048
+#define HCI_MAX_PARAM (HCI_MAX_PACKET-HCI_HEADER_SIZE)
+#define HCI_MAX_TLV 32
+
+/* CMD-EVT */
+
+/* Category 0 */
+#define WIMAX_RESET 0x0000
+#define WIMAX_SET_INFO 0x0001
+#define WIMAX_GET_INFO 0x0002
+#define WIMAX_GET_INFO_RESULT 0x8003
+#define WIMAX_RADIO_OFF 0x0004
+#define WIMAX_RADIO_ON 0x0006
+#define WIMAX_WIMAX_RESET 0x0007 /* Is this still here */
+
+/* Category 1 */
+#define WIMAX_NET_ENTRY 0x0100
+#define WIMAX_NET_DISCONN 0x0102
+#define WIMAX_ENTER_SLEEP 0x0103
+#define WIMAX_EXIT_SLEEP 0x0104
+#define WIMAX_ENTER_IDLE 0x0105
+#define WIMAX_EXIT_IDLE 0x0106
+#define WIMAX_MODE_CHANGE 0x8108
+#define WIMAX_HANDOVER 0x8109 /* obsolete */
+
+#define WIMAX_SCAN 0x010d
+#define WIMAX_SCAN_COMPLETE 0x810e
+#define WIMAX_SCAN_RESULT 0x810f
+
+#define WIMAX_CONNECT 0x0110
+#define WIMAX_CONNECT_START 0x8111
+#define WIMAX_CONNECT_COMPLETE 0x8112
+#define WIMAX_ASSOC_START 0x8113
+#define WIMAX_ASSOC_COMPLETE 0x8114
+#define WIMAX_DISCONN_IND 0x8115
+#define WIMAX_ENTRY_IND 0x8116
+#define WIMAX_HO_START 0x8117
+#define WIMAX_HO_COMPLETE 0x8118
+#define WIMAX_RADIO_STATE_IND 0x8119
+#define WIMAX_IP_RENEW_IND 0x811a
+
+#define WIMAX_DISCOVER_NSP 0x011d
+#define WIMAX_DISCOVER_NSP_RESULT 0x811e
+
+#define WIMAX_SDU_TX_FLOW 0x8125
+
+/* Category 2 */
+#define WIMAX_TX_EAP 0x0200
+#define WIMAX_RX_EAP 0x8201
+#define WIMAX_TX_SDU 0x0202
+#define WIMAX_RX_SDU 0x8203
+#define WIMAX_RX_SDU_AGGR 0x8204
+#define WIMAX_TX_SDU_AGGR 0x0205
+
+/* Category 3 */
+#define WIMAX_DM_CMD 0x030a
+#define WIMAX_DM_RSP 0x830b
+
+#define WIMAX_CLI_CMD 0x030c
+#define WIMAX_CLI_RSP 0x830d
+
+#define WIMAX_DL_IMAGE 0x0310
+#define WIMAX_DL_IMAGE_STATUS 0x8311
+#define WIMAX_UL_IMAGE 0x0312
+#define WIMAX_UL_IMAGE_RESULT 0x8313
+#define WIMAX_UL_IMAGE_STATUS 0x0314
+
+#define WIMAX_EVT_MODEM_REPORT 0x8325
+
+/* Category 0xF */
+#define WIMAX_FSM_UPDATE 0x8F01
+#define WIMAX_IF_UPDOWN 0x8F02
+ #define WIMAX_IF_UP 1
+ #define WIMAX_IF_DOWN 2
+
+/* WIMAX mode */
+#define W_NULL 0
+#define W_STANDBY 1
+#define W_OOZ 2
+#define W_AWAKE 3
+#define W_IDLE 4
+#define W_SLEEP 5
+#define W_WAIT 6
+
+#define W_NET_ENTRY_RNG 0x80
+#define W_NET_ENTRY_SBC 0x81
+#define W_NET_ENTRY_PKM 0x82
+#define W_NET_ENTRY_REG 0x83
+#define W_NET_ENTRY_DSX 0x84
+
+#define W_NET_ENTRY_RNG_FAIL 0x1100100
+#define W_NET_ENTRY_SBC_FAIL 0x1100200
+#define W_NET_ENTRY_PKM_FAIL 0x1102000
+#define W_NET_ENTRY_REG_FAIL 0x1103000
+#define W_NET_ENTRY_DSX_FAIL 0x1104000
+
+/* Scan Type */
+#define W_SCAN_ALL_CHANNEL 0
+#define W_SCAN_ALL_SUBSCRIPTION 1
+#define W_SCAN_SPECIFIED_SUBSCRIPTION 2
+
+/*
+ * TLV
+ *
+ * [31:31] indicates the type is composite.
+ * [30:16] is the length of the type. 0 length means length is variable.
+ * [15:0] is the actual type.
+ *
+ */
+#define TLV_L(x) (((x) >> 16) & 0xff)
+#define TLV_T(x) ((x) & 0xff)
+#define TLV_COMPOSITE(x) ((x) >> 31)
+
+/* GENERAL */
+#define T_MAC_ADDRESS (0x00 | (6 << 16))
+#define T_BSID (0x01 | (6 << 16))
+#define T_MSK (0x02 | (64 << 16))
+#define T_RSSI_THRSHLD (0x03 | (1 << 16))
+#define T_FREQUENCY (0x04 | (4 << 16))
+#define T_CONN_CS_TYPE (0x05 | (1 << 16))
+#define T_HOST_IP_VER (0x06 | (1 << 16))
+#define T_STBY_SCAN_INTERVAL (0x07 | (4 << 16))
+#define T_OOZ_SCAN_INTERVAL (0x08 | (4 << 16))
+#define T_IMEI (0x09 | (8 << 16))
+#define T_PID (0x0a | (12 << 16))
+
+#define T_CAPABILITY (0x1a | (4 << 16))
+#define T_RELEASE_NUMBER (0x1b | (4 << 16))
+#define T_DRIVER_REVISION (0x1c | (4 << 16))
+#define T_FW_REVISION (0x1d | (4 << 16))
+#define T_MAC_HW_REVISION (0x1e | (4 << 16))
+#define T_PHY_HW_REVISION (0x1f | (4 << 16))
+
+/* HANDOVER */
+#define T_SCAN_INTERVAL (0x20 | (1 << 16))
+
+#define T_RSC_RETAIN_TIME (0x2f | (2 << 16))
+
+/* SLEEP */
+#define T_TYPE1_ISW (0x40 | (1 << 16))
+
+#define T_SLP_START_TO (0x4a | (2 << 16))
+
+/* IDLE */
+#define T_IDLE_MODE_TO (0x50 | (2 << 16))
+
+#define T_IDLE_START_TO (0x54 | (2 << 16))
+
+/* MONITOR */
+#define T_RSSI (0x60 | (1 << 16))
+#define T_CINR (0x61 | (1 << 16))
+#define T_TX_POWER (0x6a | (1 << 16))
+#define T_CUR_FREQ (0x7f | (4 << 16))
+
+
+/* WIMAX */
+#define T_MAX_SUBSCRIPTION (0xa1 | (1 << 16))
+#define T_MAX_SF (0xa2 | (1 << 16))
+#define T_PHY_TYPE (0xa3 | (1 << 16))
+#define T_PKM (0xa4 | (1 << 16))
+#define T_AUTH_POLICY (0xa5 | (1 << 16))
+#define T_CS_TYPE (0xa6 | (2 << 16))
+#define T_VENDOR_NAME (0xa7 | (0 << 16))
+#define T_MOD_NAME (0xa8 | (0 << 16))
+#define T_PACKET_FILTER (0xa9 | (1 << 16))
+#define T_NSP_CHANGE_COUNT (0xaa | (4 << 16))
+#define T_RADIO_STATE (0xab | (1 << 16))
+#define T_URI_CONTACT_TYPE (0xac | (1 << 16))
+#define T_URI_TEXT (0xad | (0 << 16))
+#define T_URI (0xae | (0 << 16))
+#define T_ENABLE_AUTH (0xaf | (1 << 16))
+#define T_TIMEOUT (0xb0 | (2 << 16))
+#define T_RUN_MODE (0xb1 | (1 << 16))
+#define T_OMADMT_VER (0xb2 | (4 << 16))
+/* This is measured in seconds from 00:00:00 GMT January 1, 1970. */
+#define T_RTC_TIME (0xb3 | (4 << 16))
+#define T_CERT_STATUS (0xb4 | (4 << 16))
+#define T_CERT_MASK (0xb5 | (4 << 16))
+#define T_EMSK (0xb6 | (64 << 16))
+
+/* Subscription TLV */
+#define T_SUBSCRIPTION_LIST (0xd1 | (0 << 16) | (1 << 31))
+#define T_H_NSPID (0xd2 | (3 << 16))
+#define T_NSP_NAME (0xd3 | (0 << 16))
+#define T_SUBSCRIPTION_NAME (0xd4 | (0 << 16))
+#define T_SUBSCRIPTION_FLAG (0xd5 | (2 << 16))
+#define T_V_NSPID (0xd6 | (3 << 16))
+#define T_NAP_ID (0xd7 | (3 << 16))
+#define T_PREAMBLES (0xd8 | (15 << 16))
+#define T_BW (0xd9 | (4 << 16))
+#define T_FFTSIZE (0xda | (4 << 16))
+#define T_DUPLEX_MODE (0xdb | (4 << 16))
+
+struct hci_s {
+ unsigned short cmd_evt;
+ unsigned short length;
+ unsigned char data[0];
+} __packed;
+
+#endif
diff --git a/drivers/staging/gdm72xx/netlink_k.c b/drivers/staging/gdm72xx/netlink_k.c
new file mode 100644
index 000000000000..3abb31df8f28
--- /dev/null
+++ b/drivers/staging/gdm72xx/netlink_k.c
@@ -0,0 +1,153 @@
+/*
+ * Copyright (c) 2012 GCT Semiconductor, Inc. All rights reserved.
+ *
+ * This software is licensed under the terms of the GNU General Public
+ * License version 2, as published by the Free Software Foundation, and
+ * may be copied, distributed, and modified under those terms.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+
+#include <linux/module.h>
+#include <linux/etherdevice.h>
+#include <linux/netlink.h>
+#include <asm/byteorder.h>
+#include <net/sock.h>
+
+#if !defined(NLMSG_HDRLEN)
+#define NLMSG_HDRLEN ((int) NLMSG_ALIGN(sizeof(struct nlmsghdr)))
+#endif
+
+#define ND_MAX_GROUP 30
+#define ND_IFINDEX_LEN sizeof(int)
+#define ND_NLMSG_SPACE(len) (NLMSG_SPACE(len) + ND_IFINDEX_LEN)
+#define ND_NLMSG_DATA(nlh) \
+ ((void *)((char *)NLMSG_DATA(nlh) + ND_IFINDEX_LEN))
+#define ND_NLMSG_S_LEN(len) (len+ND_IFINDEX_LEN)
+#define ND_NLMSG_R_LEN(nlh) (nlh->nlmsg_len-ND_IFINDEX_LEN)
+#define ND_NLMSG_IFIDX(nlh) NLMSG_DATA(nlh)
+#define ND_MAX_MSG_LEN 8096
+
+#if defined(DEFINE_MUTEX)
+static DEFINE_MUTEX(netlink_mutex);
+#else
+static struct semaphore netlink_mutex;
+#define mutex_lock(x) down(x)
+#define mutex_unlock(x) up(x)
+#endif
+
+static void (*rcv_cb)(struct net_device *dev, u16 type, void *msg, int len);
+
+static void netlink_rcv_cb(struct sk_buff *skb)
+{
+ struct nlmsghdr *nlh;
+ struct net_device *dev;
+ u32 mlen;
+ void *msg;
+ int ifindex;
+
+ if (skb->len >= NLMSG_SPACE(0)) {
+ nlh = (struct nlmsghdr *)skb->data;
+
+ if (skb->len < nlh->nlmsg_len ||
+ nlh->nlmsg_len > ND_MAX_MSG_LEN) {
+ printk(KERN_ERR "Invalid length (%d,%d)\n", skb->len,
+ nlh->nlmsg_len);
+ return;
+ }
+
+ memcpy(&ifindex, ND_NLMSG_IFIDX(nlh), ND_IFINDEX_LEN);
+ msg = ND_NLMSG_DATA(nlh);
+ mlen = ND_NLMSG_R_LEN(nlh);
+
+ if (rcv_cb) {
+ dev = dev_get_by_index(&init_net, ifindex);
+ if (dev) {
+ rcv_cb(dev, nlh->nlmsg_type, msg, mlen);
+ dev_put(dev);
+ } else
+ printk(KERN_ERR "dev_get_by_index(%d) "
+ "is not found.\n", ifindex);
+ } else
+ printk(KERN_ERR "Unregistered Callback\n");
+ }
+}
+
+static void netlink_rcv(struct sk_buff *skb)
+{
+ mutex_lock(&netlink_mutex);
+ netlink_rcv_cb(skb);
+ mutex_unlock(&netlink_mutex);
+}
+
+struct sock *netlink_init(int unit, void (*cb)(struct net_device *dev, u16 type,
+ void *msg, int len))
+{
+ struct sock *sock;
+ struct netlink_kernel_cfg cfg = {
+ .input = netlink_rcv,
+ };
+
+#if !defined(DEFINE_MUTEX)
+ init_MUTEX(&netlink_mutex);
+#endif
+
+ sock = netlink_kernel_create(&init_net, unit, THIS_MODULE, &cfg);
+
+ if (sock)
+ rcv_cb = cb;
+
+ return sock;
+}
+
+void netlink_exit(struct sock *sock)
+{
+ netlink_kernel_release(sock);
+}
+
+int netlink_send(struct sock *sock, int group, u16 type, void *msg, int len)
+{
+ static u32 seq;
+ struct sk_buff *skb = NULL;
+ struct nlmsghdr *nlh;
+ int ret = 0;
+
+ if (group > ND_MAX_GROUP) {
+ printk(KERN_ERR "Group %d is invalied.\n", group);
+ printk(KERN_ERR "Valid group is 0 ~ %d.\n", ND_MAX_GROUP);
+ return -EINVAL;
+ }
+
+ skb = alloc_skb(NLMSG_SPACE(len), GFP_ATOMIC);
+ if (!skb) {
+ printk(KERN_ERR "netlink_broadcast ret=%d\n", ret);
+ return -ENOMEM;
+ }
+
+ seq++;
+ nlh = nlmsg_put(skb, 0, seq, type, len, 0);
+ if (!nlh) {
+ kfree_skb(skb);
+ return -EMSGSIZE;
+ }
+ memcpy(nlmsg_data(nlh), msg, len);
+
+ NETLINK_CB(skb).pid = 0;
+ NETLINK_CB(skb).dst_group = 0;
+
+ ret = netlink_broadcast(sock, skb, 0, group+1, GFP_ATOMIC);
+
+ if (!ret)
+ return len;
+ else {
+ if (ret != -ESRCH) {
+ printk(KERN_ERR "netlink_broadcast g=%d, t=%d, l=%d, r=%d\n",
+ group, type, len, ret);
+ }
+ ret = 0;
+ }
+ return ret;
+}
diff --git a/drivers/staging/gdm72xx/netlink_k.h b/drivers/staging/gdm72xx/netlink_k.h
new file mode 100644
index 000000000000..1dffaa6156e4
--- /dev/null
+++ b/drivers/staging/gdm72xx/netlink_k.h
@@ -0,0 +1,24 @@
+/*
+ * Copyright (c) 2012 GCT Semiconductor, Inc. All rights reserved.
+ *
+ * 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.
+ */
+
+#if !defined(NETLINK_H_20081202)
+#define NETLINK_H_20081202
+#include <linux/netdevice.h>
+#include <net/sock.h>
+
+struct sock *netlink_init(int unit,
+ void (*cb)(struct net_device *dev, u16 type, void *msg, int len));
+void netlink_exit(struct sock *sock);
+int netlink_send(struct sock *sock, int group, u16 type, void *msg, int len);
+
+#endif
diff --git a/drivers/staging/gdm72xx/sdio_boot.c b/drivers/staging/gdm72xx/sdio_boot.c
new file mode 100644
index 000000000000..760efee23d4a
--- /dev/null
+++ b/drivers/staging/gdm72xx/sdio_boot.c
@@ -0,0 +1,158 @@
+/*
+ * Copyright (c) 2012 GCT Semiconductor, Inc. All rights reserved.
+ *
+ * This software is licensed under the terms of the GNU General Public
+ * License version 2, as published by the Free Software Foundation, and
+ * may be copied, distributed, and modified under those terms.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/mm.h>
+#include <linux/uaccess.h>
+#include <linux/fs.h>
+#include <linux/sched.h>
+#include <linux/slab.h>
+
+#include <linux/mmc/core.h>
+#include <linux/mmc/card.h>
+#include <linux/mmc/sdio_func.h>
+
+#include "gdm_sdio.h"
+
+#define TYPE_A_HEADER_SIZE 4
+#define TYPE_A_LOOKAHEAD_SIZE 16
+#define YMEM0_SIZE 0x8000 /* 32kbytes */
+#define DOWNLOAD_SIZE (YMEM0_SIZE - TYPE_A_HEADER_SIZE)
+
+#define KRN_PATH "/lib/firmware/gdm72xx/gdmskrn.bin"
+#define RFS_PATH "/lib/firmware/gdm72xx/gdmsrfs.bin"
+
+static u8 *tx_buf;
+
+static int ack_ready(struct sdio_func *func)
+{
+ unsigned long start = jiffies;
+ u8 val;
+ int ret;
+
+ while ((jiffies - start) < HZ) {
+ val = sdio_readb(func, 0x13, &ret);
+ if (val & 0x01)
+ return 1;
+ schedule();
+ }
+
+ return 0;
+}
+
+static int download_image(struct sdio_func *func, char *img_name)
+{
+ int ret = 0, len, size, pno;
+ struct file *filp = NULL;
+ struct inode *inode = NULL;
+ u8 *buf = tx_buf;
+ loff_t pos = 0;
+
+ filp = filp_open(img_name, O_RDONLY | O_LARGEFILE, 0);
+ if (IS_ERR(filp)) {
+ printk(KERN_ERR "Can't find %s.\n", img_name);
+ return -ENOENT;
+ }
+
+ if (filp->f_dentry)
+ inode = filp->f_dentry->d_inode;
+ if (!inode || !S_ISREG(inode->i_mode)) {
+ printk(KERN_ERR "Invalid file type: %s\n", img_name);
+ ret = -EINVAL;
+ goto out;
+ }
+
+ size = i_size_read(inode->i_mapping->host);
+ if (size <= 0) {
+ printk(KERN_ERR "Unable to find file size: %s\n", img_name);
+ ret = size;
+ goto out;
+ }
+
+ pno = 0;
+ while ((len = filp->f_op->read(filp, buf + TYPE_A_HEADER_SIZE,
+ DOWNLOAD_SIZE, &pos))) {
+ if (len < 0) {
+ ret = -1;
+ goto out;
+ }
+
+ buf[0] = len & 0xff;
+ buf[1] = (len >> 8) & 0xff;
+ buf[2] = (len >> 16) & 0xff;
+
+ if (pos >= size) /* The last packet */
+ buf[3] = 2;
+ else
+ buf[3] = 0;
+
+ ret = sdio_memcpy_toio(func, 0, buf, len + TYPE_A_HEADER_SIZE);
+ if (ret < 0) {
+ printk(KERN_ERR "gdmwm: send image error: "
+ "packet number = %d ret = %d\n", pno, ret);
+ goto out;
+ }
+ if (buf[3] == 2) /* The last packet */
+ break;
+ if (!ack_ready(func)) {
+ ret = -EIO;
+ printk(KERN_ERR "gdmwm: Ack is not ready.\n");
+ goto out;
+ }
+ ret = sdio_memcpy_fromio(func, buf, 0, TYPE_A_LOOKAHEAD_SIZE);
+ if (ret < 0) {
+ printk(KERN_ERR "gdmwm: receive ack error: "
+ "packet number = %d ret = %d\n", pno, ret);
+ goto out;
+ }
+ sdio_writeb(func, 0x01, 0x13, &ret);
+ sdio_writeb(func, 0x00, 0x10, &ret); /* PCRRT */
+
+ pno++;
+ }
+out:
+ filp_close(filp, current->files);
+ return ret;
+}
+
+int sdio_boot(struct sdio_func *func)
+{
+ static mm_segment_t fs;
+ int ret;
+
+ tx_buf = kmalloc(YMEM0_SIZE, GFP_KERNEL);
+ if (tx_buf == NULL) {
+ printk(KERN_ERR "Error: kmalloc: %s %d\n", __func__, __LINE__);
+ return -ENOMEM;
+ }
+
+ fs = get_fs();
+ set_fs(get_ds());
+
+ ret = download_image(func, KRN_PATH);
+ if (ret)
+ goto restore_fs;
+ printk(KERN_INFO "GCT: Kernel download success.\n");
+
+ ret = download_image(func, RFS_PATH);
+ if (ret)
+ goto restore_fs;
+ printk(KERN_INFO "GCT: Filesystem download success.\n");
+
+restore_fs:
+ set_fs(fs);
+ kfree(tx_buf);
+ return ret;
+}
diff --git a/drivers/staging/gdm72xx/sdio_boot.h b/drivers/staging/gdm72xx/sdio_boot.h
new file mode 100644
index 000000000000..373ac28063c6
--- /dev/null
+++ b/drivers/staging/gdm72xx/sdio_boot.h
@@ -0,0 +1,21 @@
+/*
+ * Copyright (c) 2012 GCT Semiconductor, Inc. All rights reserved.
+ *
+ * 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 __SDIO_BOOT_H__
+#define __SDIO_BOOT_H__
+
+struct sdio_func;
+
+extern int sdio_boot(struct sdio_func *func);
+
+#endif /* __SDIO_BOOT_H__ */
diff --git a/drivers/staging/gdm72xx/usb_boot.c b/drivers/staging/gdm72xx/usb_boot.c
new file mode 100644
index 000000000000..fef290c38db6
--- /dev/null
+++ b/drivers/staging/gdm72xx/usb_boot.c
@@ -0,0 +1,403 @@
+/*
+ * Copyright (c) 2012 GCT Semiconductor, Inc. All rights reserved.
+ *
+ * This software is licensed under the terms of the GNU General Public
+ * License version 2, as published by the Free Software Foundation, and
+ * may be copied, distributed, and modified under those terms.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+
+#include <linux/uaccess.h>
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/mm.h>
+#include <linux/usb.h>
+#include <linux/unistd.h>
+#include <linux/slab.h>
+
+#include <asm/byteorder.h>
+#include "gdm_usb.h"
+#include "usb_boot.h"
+
+#define DN_KERNEL_MAGIC_NUMBER 0x10760001
+#define DN_ROOTFS_MAGIC_NUMBER 0x10760002
+
+#define DOWNLOAD_SIZE 1024
+
+#define DH2B(x) __cpu_to_be32(x)
+#define DL2H(x) __le32_to_cpu(x)
+
+#define MIN(a, b) ((a) > (b) ? (b) : (a))
+
+#define MAX_IMG_CNT 16
+#define UIMG_PATH "/lib/firmware/gdm72xx/gdmuimg.bin"
+#define KERN_PATH "/lib/firmware/gdm72xx/zImage"
+#define FS_PATH "/lib/firmware/gdm72xx/ramdisk.jffs2"
+
+struct dn_header {
+ u32 magic_num;
+ u32 file_size;
+};
+
+struct img_header {
+ u32 magic_code;
+ u32 count;
+ u32 len;
+ u32 offset[MAX_IMG_CNT];
+ char hostname[32];
+ char date[32];
+};
+
+struct fw_info {
+ u32 id;
+ u32 len;
+ u32 kernel_len;
+ u32 rootfs_len;
+ u32 kernel_offset;
+ u32 rootfs_offset;
+ u32 fw_ver;
+ u32 mac_ver;
+ char hostname[32];
+ char userid[16];
+ char date[32];
+ char user_desc[128];
+};
+
+static void array_le32_to_cpu(u32 *arr, int num)
+{
+ int i;
+ for (i = 0; i < num; i++, arr++)
+ *arr = DL2H(*arr);
+}
+
+static u8 *tx_buf;
+
+static int gdm_wibro_send(struct usb_device *usbdev, void *data, int len)
+{
+ int ret;
+ int actual;
+
+ ret = usb_bulk_msg(usbdev, usb_sndbulkpipe(usbdev, 1), data, len,
+ &actual, 1000);
+
+ if (ret < 0) {
+ printk(KERN_ERR "Error : usb_bulk_msg ( result = %d )\n", ret);
+ return ret;
+ }
+ return 0;
+}
+
+static int gdm_wibro_recv(struct usb_device *usbdev, void *data, int len)
+{
+ int ret;
+ int actual;
+
+ ret = usb_bulk_msg(usbdev, usb_rcvbulkpipe(usbdev, 2), data, len,
+ &actual, 5000);
+
+ if (ret < 0) {
+ printk(KERN_ERR "Error : usb_bulk_msg(recv) ( result = %d )\n",
+ ret);
+ return ret;
+ }
+ return 0;
+}
+
+static int download_image(struct usb_device *usbdev, struct file *filp,
+ loff_t *pos, u32 img_len, u32 magic_num)
+{
+ struct dn_header h;
+ int ret = 0;
+ u32 size;
+ int len, readn;
+
+ size = (img_len + DOWNLOAD_SIZE - 1) & ~(DOWNLOAD_SIZE - 1);
+ h.magic_num = DH2B(magic_num);
+ h.file_size = DH2B(size);
+
+ ret = gdm_wibro_send(usbdev, &h, sizeof(h));
+ if (ret < 0)
+ goto out;
+
+ readn = 0;
+ while ((len = filp->f_op->read(filp, tx_buf, DOWNLOAD_SIZE, pos))) {
+
+ if (len < 0) {
+ ret = -1;
+ goto out;
+ }
+ readn += len;
+
+ ret = gdm_wibro_send(usbdev, tx_buf, DOWNLOAD_SIZE);
+ if (ret < 0)
+ goto out;
+ if (readn >= img_len)
+ break;
+ }
+
+ if (readn < img_len) {
+ printk(KERN_ERR "gdmwm: Cannot read to the requested size. "
+ "Read = %d Requested = %d\n", readn, img_len);
+ ret = -EIO;
+ }
+out:
+
+ return ret;
+}
+
+int usb_boot(struct usb_device *usbdev, u16 pid)
+{
+ int i, ret = 0;
+ struct file *filp = NULL;
+ struct inode *inode = NULL;
+ static mm_segment_t fs;
+ struct img_header hdr;
+ struct fw_info fw_info;
+ loff_t pos = 0;
+ char *img_name = UIMG_PATH;
+ int len;
+
+ tx_buf = kmalloc(DOWNLOAD_SIZE, GFP_KERNEL);
+ if (tx_buf == NULL) {
+ printk(KERN_ERR "Error: kmalloc\n");
+ return -ENOMEM;
+ }
+
+ fs = get_fs();
+ set_fs(get_ds());
+
+ filp = filp_open(img_name, O_RDONLY | O_LARGEFILE, 0);
+ if (IS_ERR(filp)) {
+ printk(KERN_ERR "Can't find %s.\n", img_name);
+ set_fs(fs);
+ ret = PTR_ERR(filp);
+ goto restore_fs;
+ }
+
+ if (filp->f_dentry)
+ inode = filp->f_dentry->d_inode;
+ if (!inode || !S_ISREG(inode->i_mode)) {
+ printk(KERN_ERR "Invalid file type: %s\n", img_name);
+ ret = -EINVAL;
+ goto out;
+ }
+
+ len = filp->f_op->read(filp, (u8 *)&hdr, sizeof(hdr), &pos);
+ if (len != sizeof(hdr)) {
+ printk(KERN_ERR "gdmwm: Cannot read the image info.\n");
+ ret = -EIO;
+ goto out;
+ }
+
+ array_le32_to_cpu((u32 *)&hdr, 19);
+#if 0
+ if (hdr.magic_code != 0x10767fff) {
+ printk(KERN_ERR "gdmwm: Invalid magic code 0x%08x\n",
+ hdr.magic_code);
+ ret = -EINVAL;
+ goto out;
+ }
+#endif
+ if (hdr.count > MAX_IMG_CNT) {
+ printk(KERN_ERR "gdmwm: Too many images. %d\n", hdr.count);
+ ret = -EINVAL;
+ goto out;
+ }
+
+ for (i = 0; i < hdr.count; i++) {
+ if (hdr.offset[i] > hdr.len) {
+ printk(KERN_ERR "gdmwm: Invalid offset. "
+ "Entry = %d Offset = 0x%08x "
+ "Image length = 0x%08x\n",
+ i, hdr.offset[i], hdr.len);
+ ret = -EINVAL;
+ goto out;
+ }
+
+ pos = hdr.offset[i];
+ len = filp->f_op->read(filp, (u8 *)&fw_info, sizeof(fw_info),
+ &pos);
+ if (len != sizeof(fw_info)) {
+ printk(KERN_ERR "gdmwm: Cannot read the FW info.\n");
+ ret = -EIO;
+ goto out;
+ }
+
+ array_le32_to_cpu((u32 *)&fw_info, 8);
+#if 0
+ if ((fw_info.id & 0xfffff000) != 0x10767000) {
+ printk(KERN_ERR "gdmwm: Invalid FW id. 0x%08x\n",
+ fw_info.id);
+ ret = -EIO;
+ goto out;
+ }
+#endif
+
+ if ((fw_info.id & 0xffff) != pid)
+ continue;
+
+ pos = hdr.offset[i] + fw_info.kernel_offset;
+ ret = download_image(usbdev, filp, &pos, fw_info.kernel_len,
+ DN_KERNEL_MAGIC_NUMBER);
+ if (ret < 0)
+ goto out;
+ printk(KERN_INFO "GCT: Kernel download success.\n");
+
+ pos = hdr.offset[i] + fw_info.rootfs_offset;
+ ret = download_image(usbdev, filp, &pos, fw_info.rootfs_len,
+ DN_ROOTFS_MAGIC_NUMBER);
+ if (ret < 0)
+ goto out;
+ printk(KERN_INFO "GCT: Filesystem download success.\n");
+
+ break;
+ }
+
+ if (i == hdr.count) {
+ printk(KERN_ERR "Firmware for gsk%x is not installed.\n", pid);
+ ret = -EINVAL;
+ }
+out:
+ filp_close(filp, current->files);
+
+restore_fs:
+ set_fs(fs);
+ kfree(tx_buf);
+ return ret;
+}
+
+/*#define GDM7205_PADDING 256 */
+#define DOWNLOAD_CHUCK 2048
+#define KERNEL_TYPE_STRING "linux"
+#define FS_TYPE_STRING "rootfs"
+
+static int em_wait_ack(struct usb_device *usbdev, int send_zlp)
+{
+ int ack;
+ int ret = -1;
+
+ if (send_zlp) {
+ /*Send ZLP*/
+ ret = gdm_wibro_send(usbdev, NULL, 0);
+ if (ret < 0)
+ goto out;
+ }
+
+ /*Wait for ACK*/
+ ret = gdm_wibro_recv(usbdev, &ack, sizeof(ack));
+ if (ret < 0)
+ goto out;
+out:
+ return ret;
+}
+
+static int em_download_image(struct usb_device *usbdev, char *path,
+ char *type_string)
+{
+ struct file *filp;
+ struct inode *inode;
+ static mm_segment_t fs;
+ char *buf = NULL;
+ loff_t pos = 0;
+ int ret = 0;
+ int len, readn = 0;
+ #if defined(GDM7205_PADDING)
+ const int pad_size = GDM7205_PADDING;
+ #else
+ const int pad_size = 0;
+ #endif
+
+ fs = get_fs();
+ set_fs(get_ds());
+
+ filp = filp_open(path, O_RDONLY | O_LARGEFILE, 0);
+ if (IS_ERR(filp)) {
+ printk(KERN_ERR "Can't find %s.\n", path);
+ set_fs(fs);
+ ret = -ENOENT;
+ goto restore_fs;
+ }
+
+ if (filp->f_dentry) {
+ inode = filp->f_dentry->d_inode;
+ if (!inode || !S_ISREG(inode->i_mode)) {
+ printk(KERN_ERR "Invalid file type: %s\n", path);
+ ret = -EINVAL;
+ goto out;
+ }
+ }
+
+ buf = kmalloc(DOWNLOAD_CHUCK + pad_size, GFP_KERNEL);
+ if (buf == NULL) {
+ printk(KERN_ERR "Error: kmalloc\n");
+ return -ENOMEM;
+ }
+
+ strcpy(buf+pad_size, type_string);
+ ret = gdm_wibro_send(usbdev, buf, strlen(type_string)+pad_size);
+ if (ret < 0)
+ goto out;
+
+ while ((len = filp->f_op->read(filp, buf+pad_size, DOWNLOAD_CHUCK,
+ &pos))) {
+ if (len < 0) {
+ ret = -1;
+ goto out;
+ }
+ readn += len;
+
+ ret = gdm_wibro_send(usbdev, buf, len+pad_size);
+ if (ret < 0)
+ goto out;
+
+ ret = em_wait_ack(usbdev, ((len+pad_size) % 512 == 0));
+ if (ret < 0)
+ goto out;
+ }
+
+ ret = em_wait_ack(usbdev, 1);
+ if (ret < 0)
+ goto out;
+
+out:
+ filp_close(filp, current->files);
+
+restore_fs:
+ set_fs(fs);
+
+ kfree(buf);
+
+ return ret;
+}
+
+static int em_fw_reset(struct usb_device *usbdev)
+{
+ int ret;
+
+ /*Send ZLP*/
+ ret = gdm_wibro_send(usbdev, NULL, 0);
+ return ret;
+}
+
+int usb_emergency(struct usb_device *usbdev)
+{
+ int ret;
+
+ ret = em_download_image(usbdev, KERN_PATH, KERNEL_TYPE_STRING);
+ if (ret < 0)
+ goto out;
+ printk(KERN_INFO "GCT Emergency: Kernel download success.\n");
+
+ ret = em_download_image(usbdev, FS_PATH, FS_TYPE_STRING);
+ if (ret < 0)
+ goto out;
+ printk(KERN_INFO "GCT Emergency: Filesystem download success.\n");
+
+ ret = em_fw_reset(usbdev);
+out:
+ return ret;
+}
diff --git a/drivers/staging/gdm72xx/usb_boot.h b/drivers/staging/gdm72xx/usb_boot.h
new file mode 100644
index 000000000000..c715cd3cd300
--- /dev/null
+++ b/drivers/staging/gdm72xx/usb_boot.h
@@ -0,0 +1,22 @@
+/*
+ * Copyright (c) 2012 GCT Semiconductor, Inc. All rights reserved.
+ *
+ * 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 __USB_BOOT_H__
+#define __USB_BOOT_H__
+
+struct usb_device;
+
+extern int usb_boot(struct usb_device *usbdev, u16 pid);
+extern int usb_emergency(struct usb_device *usbdev);
+
+#endif /* __USB_BOOT_H__ */
diff --git a/drivers/staging/gdm72xx/usb_ids.h b/drivers/staging/gdm72xx/usb_ids.h
new file mode 100644
index 000000000000..b34616b7203f
--- /dev/null
+++ b/drivers/staging/gdm72xx/usb_ids.h
@@ -0,0 +1,82 @@
+/*
+ * Copyright (c) 2012 GCT Semiconductor, Inc. All rights reserved.
+ *
+ * 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 __USB_IDS_H__
+#define __USB_IDS_H__
+
+/*You can replace vendor-ID as yours.*/
+#define GCT_VID 0x1076
+
+/*You can replace product-ID as yours.*/
+#define GCT_PID1 0x7e00
+#define GCT_PID2 0x7f00
+
+#define USB_DEVICE_ID_MATCH_DEVICE_INTERFACE \
+ (USB_DEVICE_ID_MATCH_DEVICE | USB_DEVICE_ID_MATCH_INT_CLASS)
+
+#define USB_DEVICE_INTF(vend, prod, intf) \
+ .match_flags = USB_DEVICE_ID_MATCH_DEVICE_INTERFACE, \
+ .idVendor = (vend), .idProduct = (prod), .bInterfaceClass = (intf)
+
+#define EMERGENCY_PID 0x720f
+#define BL_PID_MASK 0xffc0
+
+#define USB_DEVICE_BOOTLOADER(vid, pid) \
+ {USB_DEVICE((vid), ((pid)&BL_PID_MASK)|B_DOWNLOAD)}, \
+ {USB_DEVICE((vid), ((pid)&BL_PID_MASK)|B_DOWNLOAD|B_DIFF_DL_DRV)}
+
+#define USB_DEVICE_CDC_DATA(vid, pid) \
+ {USB_DEVICE_INTF((vid), (pid), USB_CLASS_CDC_DATA)}
+
+static const struct usb_device_id id_table[] = {
+ USB_DEVICE_BOOTLOADER(GCT_VID, GCT_PID1),
+ USB_DEVICE_CDC_DATA(GCT_VID, GCT_PID1),
+ USB_DEVICE_CDC_DATA(GCT_VID, GCT_PID1+0x1),
+ USB_DEVICE_CDC_DATA(GCT_VID, GCT_PID1+0x2),
+ USB_DEVICE_CDC_DATA(GCT_VID, GCT_PID1+0x3),
+ USB_DEVICE_CDC_DATA(GCT_VID, GCT_PID1+0x4),
+ USB_DEVICE_CDC_DATA(GCT_VID, GCT_PID1+0x5),
+ USB_DEVICE_CDC_DATA(GCT_VID, GCT_PID1+0x6),
+ USB_DEVICE_CDC_DATA(GCT_VID, GCT_PID1+0x7),
+ USB_DEVICE_CDC_DATA(GCT_VID, GCT_PID1+0x8),
+ USB_DEVICE_CDC_DATA(GCT_VID, GCT_PID1+0x9),
+ USB_DEVICE_CDC_DATA(GCT_VID, GCT_PID1+0xa),
+ USB_DEVICE_CDC_DATA(GCT_VID, GCT_PID1+0xb),
+ USB_DEVICE_CDC_DATA(GCT_VID, GCT_PID1+0xc),
+ USB_DEVICE_CDC_DATA(GCT_VID, GCT_PID1+0xd),
+ USB_DEVICE_CDC_DATA(GCT_VID, GCT_PID1+0xe),
+ USB_DEVICE_CDC_DATA(GCT_VID, GCT_PID1+0xf),
+
+ USB_DEVICE_BOOTLOADER(GCT_VID, GCT_PID2),
+ USB_DEVICE_CDC_DATA(GCT_VID, GCT_PID2),
+ USB_DEVICE_CDC_DATA(GCT_VID, GCT_PID2+0x1),
+ USB_DEVICE_CDC_DATA(GCT_VID, GCT_PID2+0x2),
+ USB_DEVICE_CDC_DATA(GCT_VID, GCT_PID2+0x3),
+ USB_DEVICE_CDC_DATA(GCT_VID, GCT_PID2+0x4),
+ USB_DEVICE_CDC_DATA(GCT_VID, GCT_PID2+0x5),
+ USB_DEVICE_CDC_DATA(GCT_VID, GCT_PID2+0x6),
+ USB_DEVICE_CDC_DATA(GCT_VID, GCT_PID2+0x7),
+ USB_DEVICE_CDC_DATA(GCT_VID, GCT_PID2+0x8),
+ USB_DEVICE_CDC_DATA(GCT_VID, GCT_PID2+0x9),
+ USB_DEVICE_CDC_DATA(GCT_VID, GCT_PID2+0xa),
+ USB_DEVICE_CDC_DATA(GCT_VID, GCT_PID2+0xb),
+ USB_DEVICE_CDC_DATA(GCT_VID, GCT_PID2+0xc),
+ USB_DEVICE_CDC_DATA(GCT_VID, GCT_PID2+0xd),
+ USB_DEVICE_CDC_DATA(GCT_VID, GCT_PID2+0xe),
+ USB_DEVICE_CDC_DATA(GCT_VID, GCT_PID2+0xf),
+
+ {USB_DEVICE(GCT_VID, EMERGENCY_PID)},
+ { }
+};
+
+#endif /* __USB_IDS_H__ */
diff --git a/drivers/staging/gdm72xx/wm_ioctl.h b/drivers/staging/gdm72xx/wm_ioctl.h
new file mode 100644
index 000000000000..9f46e06f2303
--- /dev/null
+++ b/drivers/staging/gdm72xx/wm_ioctl.h
@@ -0,0 +1,97 @@
+/*
+ * Copyright (c) 2012 GCT Semiconductor, Inc. All rights reserved.
+ *
+ * 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.
+ */
+
+#if !defined(WM_IOCTL_H_20080714)
+#define WM_IOCTL_H_20080714
+#if !defined(__KERNEL__)
+#include <net/if.h>
+#endif
+
+#define NETLINK_WIMAX 31
+
+#define SIOCWMIOCTL SIOCDEVPRIVATE
+
+#define SIOCG_DATA 0x8D10
+#define SIOCS_DATA 0x8D11
+
+enum {
+ SIOC_DATA_FSM,
+ SIOC_DATA_NETLIST,
+ SIOC_DATA_CONNNSP,
+ SIOC_DATA_CONNCOMP,
+ SIOC_DATA_PROFILEID,
+
+ SIOC_DATA_END
+};
+
+#define SIOC_DATA_MAX 16
+
+/* FSM */
+enum {
+ M_INIT = 0,
+ M_OPEN_OFF,
+ M_OPEN_ON,
+ M_SCAN,
+ M_CONNECTING,
+ M_CONNECTED,
+ M_FSM_END,
+
+ C_INIT = 0,
+ C_CONNSTART,
+ C_ASSOCSTART,
+ C_RNG,
+ C_SBC,
+ C_AUTH,
+ C_REG,
+ C_DSX,
+ C_ASSOCCOMPLETE,
+ C_CONNCOMPLETE,
+ C_FSM_END,
+
+ D_INIT = 0,
+ D_READY,
+ D_LISTEN,
+ D_IPACQUISITION,
+
+ END_FSM
+};
+
+struct fsm_s {
+ int m_status; /*main status*/
+ int c_status; /*connection status*/
+ int d_status; /*oma-dm status*/
+};
+
+struct data_s {
+ int size;
+ void *buf;
+};
+
+struct wm_req_s {
+ union {
+ char ifrn_name[IFNAMSIZ];
+ } ifr_ifrn;
+
+ unsigned short cmd;
+
+ unsigned short data_id;
+ struct data_s data;
+
+/* NOTE: sizeof(struct wm_req_s) must be less than sizeof(struct ifreq). */
+};
+
+#ifndef ifr_name
+#define ifr_name ifr_ifrn.ifrn_name
+#endif
+
+#endif
diff --git a/drivers/staging/iio/Documentation/device.txt b/drivers/staging/iio/Documentation/device.txt
index 8926f2448cc9..ea08d6213373 100644
--- a/drivers/staging/iio/Documentation/device.txt
+++ b/drivers/staging/iio/Documentation/device.txt
@@ -8,11 +8,11 @@ The crucial structure for device drivers in iio is iio_dev.
First allocate one using:
-struct iio_dev *indio_dev = iio_allocate_device(sizeof(struct chip_state));
+struct iio_dev *indio_dev = iio_device_alloc(sizeof(struct chip_state));
where chip_state is a structure of local state data for this instance of
the chip.
-That data can be accessed using iio_priv(struct iio_dev *)
+That data can be accessed using iio_priv(struct iio_dev *).
Then fill in the following:
@@ -29,8 +29,6 @@ Then fill in the following:
* info->driver_module:
Set to THIS_MODULE. Used to ensure correct ownership
of various resources allocate by the core.
- * info->num_interrupt_lines:
- Number of event triggering hardware lines the device has.
* info->event_attrs:
Attributes used to enable / disable hardware events.
* info->attrs:
@@ -41,7 +39,7 @@ Then fill in the following:
and for associate parameters such as offsets and scales.
* info->write_raw:
Raw value writing function. Used for writable device values such
- as DAC values and caliboffset.
+ as DAC values and calibbias.
* info->read_event_config:
Typically only set if there are some interrupt lines. This
is used to read if an on sensor event detector is enabled.
@@ -64,8 +62,8 @@ Then fill in the following:
Poll function related elements. This controls what occurs when a trigger
to which this device is attached sends an event.
- indio_dev->channels:
- Specification of device channels. Most attributes etc are built
- form this spec.
+ Specification of device channels. Most attributes etc. are built
+ from this spec.
- indio_dev->num_channels:
How many channels are there?
@@ -78,4 +76,4 @@ be registered afterwards (otherwise the whole parentage of devices
gets confused)
On remove, iio_device_unregister(indio_dev) will remove the device from
-the core, and iio_free_device will clean up.
+the core, and iio_device_free(indio_dev) will clean up.
diff --git a/drivers/staging/iio/Documentation/generic_buffer.c b/drivers/staging/iio/Documentation/generic_buffer.c
index 69a05b9456d6..827e92de8e30 100644
--- a/drivers/staging/iio/Documentation/generic_buffer.c
+++ b/drivers/staging/iio/Documentation/generic_buffer.c
@@ -18,6 +18,8 @@
*
*/
+#define _GNU_SOURCE
+
#include <unistd.h>
#include <dirent.h>
#include <fcntl.h>
@@ -29,12 +31,14 @@
#include <string.h>
#include <poll.h>
#include <endian.h>
+#include <getopt.h>
+#include <inttypes.h>
#include "iio_utils.h"
/**
* size_from_channelarray() - calculate the storage size of a scan
- * @channels: the channel info array
- * @num_channels: size of the channel info array
+ * @channels: the channel info array
+ * @num_channels: number of channels
*
* Has the side effect of filling the channels[i].location values used
* in processing the buffer output.
@@ -58,22 +62,22 @@ int size_from_channelarray(struct iio_channel_info *channels, int num_channels)
void print2byte(int input, struct iio_channel_info *info)
{
/* First swap if incorrect endian */
-
if (info->be)
- input = be16toh((uint_16t)input);
+ input = be16toh((uint16_t)input);
else
- input = le16toh((uint_16t)input);
+ input = le16toh((uint16_t)input);
- /* shift before conversion to avoid sign extension
- of left aligned data */
+ /*
+ * Shift before conversion to avoid sign extension
+ * of left aligned data
+ */
input = input >> info->shift;
if (info->is_signed) {
int16_t val = input;
val &= (1 << info->bits_used) - 1;
val = (int16_t)(val << (16 - info->bits_used)) >>
(16 - info->bits_used);
- printf("%05f ", val,
- (float)(val + info->offset)*info->scale);
+ printf("%05f ", ((float)val + info->offset)*info->scale);
} else {
uint16_t val = input;
val &= (1 << info->bits_used) - 1;
@@ -83,39 +87,39 @@ void print2byte(int input, struct iio_channel_info *info)
/**
* process_scan() - print out the values in SI units
* @data: pointer to the start of the scan
- * @infoarray: information about the channels. Note
+ * @channels: information about the channels. Note
* size_from_channelarray must have been called first to fill the
* location offsets.
- * @num_channels: the number of active channels
+ * @num_channels: number of channels
**/
void process_scan(char *data,
- struct iio_channel_info *infoarray,
+ struct iio_channel_info *channels,
int num_channels)
{
int k;
for (k = 0; k < num_channels; k++)
- switch (infoarray[k].bytes) {
+ switch (channels[k].bytes) {
/* only a few cases implemented so far */
case 2:
- print2byte(*(uint16_t *)(data + infoarray[k].location),
- &infoarray[k]);
+ print2byte(*(uint16_t *)(data + channels[k].location),
+ &channels[k]);
break;
case 8:
- if (infoarray[k].is_signed) {
+ if (channels[k].is_signed) {
int64_t val = *(int64_t *)
(data +
- infoarray[k].location);
- if ((val >> infoarray[k].bits_used) & 1)
- val = (val & infoarray[k].mask) |
- ~infoarray[k].mask;
+ channels[k].location);
+ if ((val >> channels[k].bits_used) & 1)
+ val = (val & channels[k].mask) |
+ ~channels[k].mask;
/* special case for timestamp */
- if (infoarray[k].scale == 1.0f &&
- infoarray[k].offset == 0.0f)
- printf(" %lld", val);
+ if (channels[k].scale == 1.0f &&
+ channels[k].offset == 0.0f)
+ printf("%" PRId64 " ", val);
else
printf("%05f ", ((float)val +
- infoarray[k].offset)*
- infoarray[k].scale);
+ channels[k].offset)*
+ channels[k].scale);
}
break;
default:
@@ -130,10 +134,7 @@ int main(int argc, char **argv)
unsigned long timedelay = 1000000;
unsigned long buf_len = 128;
-
int ret, c, i, j, toread;
-
- FILE *fp_ev;
int fp;
int num_channels;
@@ -149,7 +150,7 @@ int main(int argc, char **argv)
int noevents = 0;
char *dummy;
- struct iio_channel_info *infoarray;
+ struct iio_channel_info *channels;
while ((c = getopt(argc, argv, "l:w:c:et:n:")) != -1) {
switch (c) {
@@ -192,7 +193,7 @@ int main(int argc, char **argv)
asprintf(&dev_dir_name, "%siio:device%d", iio_dir, dev_num);
if (trigger_name == NULL) {
/*
- * Build the trigger name. If it is device associated it's
+ * Build the trigger name. If it is device associated its
* name is <device_name>_dev[n] where n matches the device
* number found above
*/
@@ -217,7 +218,7 @@ int main(int argc, char **argv)
* Parse the files in scan_elements to identify what channels are
* present
*/
- ret = build_channel_array(dev_dir_name, &infoarray, &num_channels);
+ ret = build_channel_array(dev_dir_name, &channels, &num_channels);
if (ret) {
printf("Problem reading scan element information\n");
printf("diag %s\n", dev_dir_name);
@@ -236,7 +237,7 @@ int main(int argc, char **argv)
goto error_free_triggername;
}
printf("%s %s\n", dev_dir_name, trigger_name);
- /* Set the device trigger to be the data rdy trigger found above */
+ /* Set the device trigger to be the data ready trigger found above */
ret = write_sysfs_string_and_verify("trigger/current_trigger",
dev_dir_name,
trigger_name);
@@ -254,7 +255,7 @@ int main(int argc, char **argv)
ret = write_sysfs_int("enable", buf_dir_name, 1);
if (ret < 0)
goto error_free_buf_dir_name;
- scan_size = size_from_channelarray(infoarray, num_channels);
+ scan_size = size_from_channelarray(channels, num_channels);
data = malloc(scan_size*buf_len);
if (!data) {
ret = -ENOMEM;
@@ -269,7 +270,7 @@ int main(int argc, char **argv)
/* Attempt to open non blocking the access dev */
fp = open(buffer_access, O_RDONLY | O_NONBLOCK);
- if (fp == -1) { /*If it isn't there make the node */
+ if (fp == -1) { /* If it isn't there make the node */
printf("Failed to open %s\n", buffer_access);
ret = -errno;
goto error_free_buffer_access;
@@ -300,16 +301,16 @@ int main(int argc, char **argv)
}
for (i = 0; i < read_size/scan_size; i++)
process_scan(data + scan_size*i,
- infoarray,
+ channels,
num_channels);
}
- /* Stop the ring buffer */
+ /* Stop the buffer */
ret = write_sysfs_int("enable", buf_dir_name, 0);
if (ret < 0)
goto error_close_buffer_access;
- /* Disconnect from the trigger - just write a dummy name.*/
+ /* Disconnect the trigger - just write a dummy name. */
write_sysfs_string("trigger/current_trigger",
dev_dir_name, "NULL");
diff --git a/drivers/staging/iio/Documentation/iio_event_monitor.c b/drivers/staging/iio/Documentation/iio_event_monitor.c
index 0d21a277305f..3a9b00087403 100644
--- a/drivers/staging/iio/Documentation/iio_event_monitor.c
+++ b/drivers/staging/iio/Documentation/iio_event_monitor.c
@@ -27,7 +27,7 @@
#include <fcntl.h>
#include <sys/ioctl.h>
#include "iio_utils.h"
-#include "../events.h"
+#include <linux/iio/events.h>
static const char * const iio_chan_type_name_spec[] = {
[IIO_VOLTAGE] = "voltage",
@@ -45,6 +45,7 @@ static const char * const iio_chan_type_name_spec[] = {
[IIO_ANGL] = "angl",
[IIO_TIMESTAMP] = "timestamp",
[IIO_CAPACITANCE] = "capacitance",
+ [IIO_ALTVOLTAGE] = "altvoltage",
};
static const char * const iio_ev_type_text[] = {
@@ -67,6 +68,12 @@ static const char * const iio_modifier_names[] = {
[IIO_MOD_Z] = "z",
[IIO_MOD_LIGHT_BOTH] = "both",
[IIO_MOD_LIGHT_IR] = "ir",
+ [IIO_MOD_ROOT_SUM_SQUARED_X_Y] = "sqrt(x^2+y^2)",
+ [IIO_MOD_SUM_SQUARED_X_Y_Z] = "x^2+y^2+z^2",
+ [IIO_MOD_LIGHT_CLEAR] = "clear",
+ [IIO_MOD_LIGHT_RED] = "red",
+ [IIO_MOD_LIGHT_GREEN] = "green",
+ [IIO_MOD_LIGHT_BLUE] = "blue",
};
static bool event_is_known(struct iio_event_data *event)
@@ -92,6 +99,7 @@ static bool event_is_known(struct iio_event_data *event)
case IIO_ANGL:
case IIO_TIMESTAMP:
case IIO_CAPACITANCE:
+ case IIO_ALTVOLTAGE:
break;
default:
return false;
@@ -104,6 +112,12 @@ static bool event_is_known(struct iio_event_data *event)
case IIO_MOD_Z:
case IIO_MOD_LIGHT_BOTH:
case IIO_MOD_LIGHT_IR:
+ case IIO_MOD_ROOT_SUM_SQUARED_X_Y:
+ case IIO_MOD_SUM_SQUARED_X_Y_Z:
+ case IIO_MOD_LIGHT_CLEAR:
+ case IIO_MOD_LIGHT_RED:
+ case IIO_MOD_LIGHT_GREEN:
+ case IIO_MOD_LIGHT_BLUE:
break;
default:
return false;
diff --git a/drivers/staging/iio/Documentation/iio_utils.h b/drivers/staging/iio/Documentation/iio_utils.h
index 6f3a392297ec..cf32ae099cd6 100644
--- a/drivers/staging/iio/Documentation/iio_utils.h
+++ b/drivers/staging/iio/Documentation/iio_utils.h
@@ -7,14 +7,15 @@
* the Free Software Foundation.
*/
-/* Made up value to limit allocation sizes */
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
#include <stdio.h>
#include <stdint.h>
#include <dirent.h>
+#include <errno.h>
+/* Made up value to limit allocation sizes */
#define IIO_MAX_NAME_LENGTH 30
#define FORMAT_SCAN_ELEMENTS_DIR "%s/scan_elements"
@@ -27,7 +28,7 @@ const char *iio_dir = "/sys/bus/iio/devices/";
* @full_name: the full channel name
* @generic_name: the output generic channel name
**/
-static int iioutils_break_up_name(const char *full_name,
+inline int iioutils_break_up_name(const char *full_name,
char **generic_name)
{
char *current;
@@ -157,7 +158,8 @@ inline int iioutils_get_type(unsigned *is_signed,
&padint, shift);
if (ret < 0) {
printf("failed to pass scan type description\n");
- return ret;
+ ret = -errno;
+ goto error_close_sysfsfp;
}
*be = (endianchar == 'b');
*bytes = padint / 8;
@@ -173,7 +175,11 @@ inline int iioutils_get_type(unsigned *is_signed,
free(filename);
filename = 0;
+ sysfsfp = 0;
}
+error_close_sysfsfp:
+ if (sysfsfp)
+ fclose(sysfsfp);
error_free_filename:
if (filename)
free(filename);
@@ -280,7 +286,7 @@ inline int build_channel_array(const char *device_dir,
{
DIR *dp;
FILE *sysfsfp;
- int count, temp, i;
+ int count, i;
struct iio_channel_info *current;
int ret;
const struct dirent *ent;
@@ -447,7 +453,7 @@ inline int find_type_by_name(const char *name, const char *type)
dp = opendir(iio_dir);
if (dp == NULL) {
- printf("No industrialio devices available");
+ printf("No industrialio devices available\n");
return -ENODEV;
}
@@ -467,23 +473,30 @@ inline int find_type_by_name(const char *name, const char *type)
+ strlen(type)
+ numstrlen
+ 6);
- if (filename == NULL)
+ if (filename == NULL) {
+ closedir(dp);
return -ENOMEM;
+ }
sprintf(filename, "%s%s%d/name",
iio_dir,
type,
number);
nameFile = fopen(filename, "r");
- if (!nameFile)
+ if (!nameFile) {
+ free(filename);
continue;
+ }
free(filename);
fscanf(nameFile, "%s", thisname);
- if (strcmp(name, thisname) == 0)
- return number;
fclose(nameFile);
+ if (strcmp(name, thisname) == 0) {
+ closedir(dp);
+ return number;
+ }
}
}
}
+ closedir(dp);
return -ENODEV;
}
@@ -512,6 +525,7 @@ inline int _write_sysfs_int(char *filename, char *basedir, int val, int verify)
goto error_free;
}
fscanf(sysfsfp, "%d", &test);
+ fclose(sysfsfp);
if (test != val) {
printf("Possible failure in int write %d to %s%s\n",
val,
@@ -561,6 +575,7 @@ int _write_sysfs_string(char *filename, char *basedir, char *val, int verify)
goto error_free;
}
fscanf(sysfsfp, "%s", temp);
+ fclose(sysfsfp);
if (strcmp(temp, val) != 0) {
printf("Possible failure in string write of %s "
"Should be %s "
diff --git a/drivers/staging/iio/Documentation/light/sysfs-bus-iio-light-tsl2583 b/drivers/staging/iio/Documentation/light/sysfs-bus-iio-light-tsl2583
new file mode 100644
index 000000000000..470f7ad9c073
--- /dev/null
+++ b/drivers/staging/iio/Documentation/light/sysfs-bus-iio-light-tsl2583
@@ -0,0 +1,6 @@
+What: /sys/bus/iio/devices/device[n]/in_illuminance0_calibrate
+KernelVersion: 2.6.37
+Contact: linux-iio@vger.kernel.org
+Description:
+ This property causes an internal calibration of the als gain trim
+ value which is later used in calculating illuminance in lux.
diff --git a/drivers/staging/iio/Documentation/light/sysfs-bus-iio-light-tsl2x7x b/drivers/staging/iio/Documentation/light/sysfs-bus-iio-light-tsl2x7x
new file mode 100644
index 000000000000..b2798b258bf7
--- /dev/null
+++ b/drivers/staging/iio/Documentation/light/sysfs-bus-iio-light-tsl2x7x
@@ -0,0 +1,13 @@
+What: /sys/bus/iio/devices/device[n]/in_illuminance0_calibrate
+KernelVersion: 3.3-rc1
+Contact: linux-iio@vger.kernel.org
+Description:
+ Causes an internal calibration of the als gain trim
+ value which is later used in calculating illuminance in lux.
+
+What: /sys/bus/iio/devices/device[n]/in_proximity0_calibrate
+KernelVersion: 3.3-rc1
+Contact: linux-iio@vger.kernel.org
+Description:
+ Causes a recalculation and adjustment to the
+ proximity_thresh_rising_value.
diff --git a/drivers/staging/iio/Documentation/overview.txt b/drivers/staging/iio/Documentation/overview.txt
index afc39ecde9ca..43f92b06bc3e 100644
--- a/drivers/staging/iio/Documentation/overview.txt
+++ b/drivers/staging/iio/Documentation/overview.txt
@@ -8,7 +8,7 @@ actual devices combine some ADCs with digital to analog converters
The aim is to fill the gap between the somewhat similar hwmon and
input subsystems. Hwmon is very much directed at low sample rate
sensors used in applications such as fan speed control and temperature
-measurement. Input is, as it's name suggests focused on input
+measurement. Input is, as its name suggests focused on input
devices. In some cases there is considerable overlap between these and
IIO.
diff --git a/drivers/staging/iio/Documentation/ring.txt b/drivers/staging/iio/Documentation/ring.txt
index e33807761cd7..e1da43381d0e 100644
--- a/drivers/staging/iio/Documentation/ring.txt
+++ b/drivers/staging/iio/Documentation/ring.txt
@@ -15,8 +15,8 @@ struct iio_ring_buffer contains a struct iio_ring_setup_ops *setup_ops
which in turn contains the 4 function pointers
(preenable, postenable, predisable and postdisable).
These are used to perform device specific steps on either side
-of the core changing it's current mode to indicate that the buffer
-is enabled or disabled (along with enabling triggering etc as appropriate).
+of the core changing its current mode to indicate that the buffer
+is enabled or disabled (along with enabling triggering etc. as appropriate).
Also in struct iio_ring_buffer is a struct iio_ring_access_funcs.
The function pointers within here are used to allow the core to handle
diff --git a/drivers/staging/iio/Documentation/sysfs-bus-iio b/drivers/staging/iio/Documentation/sysfs-bus-iio
deleted file mode 100644
index 46a995d6d261..000000000000
--- a/drivers/staging/iio/Documentation/sysfs-bus-iio
+++ /dev/null
@@ -1,741 +0,0 @@
-What: /sys/bus/iio/devices/iio:deviceX
-KernelVersion: 2.6.35
-Contact: linux-iio@vger.kernel.org
-Description:
- Hardware chip or device accessed by one communication port.
- Corresponds to a grouping of sensor channels. X is the IIO
- index of the device.
-
-What: /sys/bus/iio/devices/triggerX
-KernelVersion: 2.6.35
-Contact: linux-iio@vger.kernel.org
-Description:
- An event driven driver of data capture to an in kernel buffer.
- May be provided by a device driver that also has an IIO device
- based on hardware generated events (e.g. data ready) or
- provided by a separate driver for other hardware (e.g.
- periodic timer, GPIO or high resolution timer).
- Contains trigger type specific elements. These do not
- generalize well and hence are not documented in this file.
- X is the IIO index of the trigger.
-
-What: /sys/bus/iio/devices/iio:deviceX/buffer
-KernelVersion: 2.6.35
-Contact: linux-iio@vger.kernel.org
-Description:
- Directory of attributes relating to the buffer for the device.
-
-What: /sys/bus/iio/devices/iio:deviceX/name
-KernelVersion: 2.6.35
-Contact: linux-iio@vger.kernel.org
-Description:
- Description of the physical chip / device for device X.
- Typically a part number.
-
-What: /sys/bus/iio/devices/iio:deviceX/sampling_frequency
-What: /sys/bus/iio/devices/iio:deviceX/buffer/sampling_frequency
-What: /sys/bus/iio/devices/triggerX/sampling_frequency
-KernelVersion: 2.6.35
-Contact: linux-iio@vger.kernel.org
-Description:
- Some devices have internal clocks. This parameter sets the
- resulting sampling frequency. In many devices this
- parameter has an effect on input filters etc rather than
- simply controlling when the input is sampled. As this
- effects datardy triggers, hardware buffers and the sysfs
- direct access interfaces, it may be found in any of the
- relevant directories. If it effects all of the above
- then it is to be found in the base device directory.
-
-What: /sys/bus/iio/devices/iio:deviceX/sampling_frequency_available
-What: /sys/.../iio:deviceX/buffer/sampling_frequency_available
-What: /sys/bus/iio/devices/triggerX/sampling_frequency_available
-KernelVersion: 2.6.35
-Contact: linux-iio@vger.kernel.org
-Description:
- When the internal sampling clock can only take a small
- discrete set of values, this file lists those available.
-
-What: /sys/bus/iio/devices/iio:deviceX/oversampling_ratio
-KernelVersion: 2.6.38
-Contact: linux-iio@vger.kernel.org
-Description:
- Hardware dependent ADC oversampling. Controls the sampling ratio
- of the digital filter if available.
-
-What: /sys/bus/iio/devices/iio:deviceX/oversampling_ratio_available
-KernelVersion: 2.6.38
-Contact: linux-iio@vger.kernel.org
-Description:
- Hardware dependent values supported by the oversampling filter.
-
-What: /sys/bus/iio/devices/iio:deviceX/in_voltageY_raw
-What: /sys/bus/iio/devices/iio:deviceX/in_voltageY_supply_raw
-KernelVersion: 2.6.35
-Contact: linux-iio@vger.kernel.org
-Description:
- Raw (unscaled no bias removal etc) voltage measurement from
- channel Y. In special cases where the channel does not
- correspond to externally available input one of the named
- versions may be used. The number must always be specified and
- unique to allow association with event codes. Units after
- application of scale and offset are microvolts.
-
-What: /sys/bus/iio/devices/iio:deviceX/in_voltageY-voltageZ_raw
-KernelVersion: 2.6.35
-Contact: linux-iio@vger.kernel.org
-Description:
- Raw (unscaled) differential voltage measurement equivalent to
- channel Y - channel Z where these channel numbers apply to the
- physically equivalent inputs when non differential readings are
- separately available. In differential only parts, then all that
- is required is a consistent labeling. Units after application
- of scale and offset are microvolts.
-
-What: /sys/bus/iio/devices/iio:deviceX/in_capacitanceY_raw
-KernelVersion: 3.2
-Contact: linux-iio@vger.kernel.org
-Description:
- Raw capacitance measurement from channel Y. Units after
- application of scale and offset are nanofarads.
-
-What: /sys/.../iio:deviceX/in_capacitanceY-in_capacitanceZ_raw
-KernelVersion: 3.2
-Contact: linux-iio@vger.kernel.org
-Description:
- Raw differential capacitance measurement equivalent to
- channel Y - channel Z where these channel numbers apply to the
- physically equivalent inputs when non differential readings are
- separately available. In differential only parts, then all that
- is required is a consistent labeling. Units after application
- of scale and offset are nanofarads..
-
-What: /sys/bus/iio/devices/iio:deviceX/in_temp_raw
-What: /sys/bus/iio/devices/iio:deviceX/in_tempX_raw
-What: /sys/bus/iio/devices/iio:deviceX/in_temp_x_raw
-What: /sys/bus/iio/devices/iio:deviceX/in_temp_y_raw
-What: /sys/bus/iio/devices/iio:deviceX/in_temp_z_raw
-KernelVersion: 2.6.35
-Contact: linux-iio@vger.kernel.org
-Description:
- Raw (unscaled no bias removal etc) temperature measurement.
- It an axis is specified it generally means that the temperature
- sensor is associated with one part of a compound device (e.g.
- a gyroscope axis). Units after application of scale and offset
- are milli degrees Celsuis.
-
-What: /sys/bus/iio/devices/iio:deviceX/in_tempX_input
-KernelVersion: 2.6.38
-Contact: linux-iio@vger.kernel.org
-Description:
- Scaled temperature measurement in milli degrees Celsius.
-
-What: /sys/bus/iio/devices/iio:deviceX/in_accel_x_raw
-What: /sys/bus/iio/devices/iio:deviceX/in_accel_y_raw
-What: /sys/bus/iio/devices/iio:deviceX/in_accel_z_raw
-KernelVersion: 2.6.35
-Contact: linux-iio@vger.kernel.org
-Description:
- Acceleration in direction x, y or z (may be arbitrarily assigned
- but should match other such assignments on device).
- Has all of the equivalent parameters as per voltageY. Units
- after application of scale and offset are m/s^2.
-
-What: /sys/bus/iio/devices/iio:deviceX/in_anglvel_x_raw
-What: /sys/bus/iio/devices/iio:deviceX/in_anglvel_y_raw
-What: /sys/bus/iio/devices/iio:deviceX/in_anglvel_z_raw
-KernelVersion: 2.6.35
-Contact: linux-iio@vger.kernel.org
-Description:
- Angular velocity about axis x, y or z (may be arbitrarily
- assigned) Data converted by application of offset then scale to
- radians per second. Has all the equivalent parameters as
- per voltageY. Units after application of scale and offset are
- radians per second.
-
-What: /sys/bus/iio/devices/iio:deviceX/in_incli_x_raw
-What: /sys/bus/iio/devices/iio:deviceX/in_incli_y_raw
-What: /sys/bus/iio/devices/iio:deviceX/in_incli_z_raw
-KernelVersion: 2.6.35
-Contact: linux-iio@vger.kernel.org
-Description:
- Inclination raw reading about axis x, y or z (may be
- arbitrarily assigned). Data converted by application of offset
- and scale to Degrees.
-
-What: /sys/bus/iio/devices/iio:deviceX/in_magn_x_raw
-What: /sys/bus/iio/devices/iio:deviceX/in_magn_y_raw
-What: /sys/bus/iio/devices/iio:deviceX/in_magn_z_raw
-KernelVersion: 2.6.35
-Contact: linux-iio@vger.kernel.org
-Description:
- Magnetic field along axis x, y or z (may be arbitrarily
- assigned). Data converted by application of offset
- then scale to Gauss.
-
-What: /sys/bus/iio/devices/iio:deviceX/in_accel_x_peak_raw
-What: /sys/bus/iio/devices/iio:deviceX/in_accel_y_peak_raw
-What: /sys/bus/iio/devices/iio:deviceX/in_accel_z_peak_raw
-KernelVersion: 2.6.36
-Contact: linux-iio@vger.kernel.org
-Description:
- Highest value since some reset condition. These
- attributes allow access to this and are otherwise
- the direct equivalent of the <type>Y[_name]_raw attributes.
-
-What: /sys/bus/iio/devices/iio:deviceX/in_accel_xyz_squared_peak_raw
-KernelVersion: 2.6.36
-Contact: linux-iio@vger.kernel.org
-Description:
- A computed peak value based on the sum squared magnitude of
- the underlying value in the specified directions.
-
-What: /sys/bus/iio/devices/iio:deviceX/in_accel_offset
-What: /sys/bus/iio/devices/iio:deviceX/in_accel_x_offset
-What: /sys/bus/iio/devices/iio:deviceX/in_accel_y_offset
-What: /sys/bus/iio/devices/iio:deviceX/in_accel_z_offset
-What: /sys/bus/iio/devices/iio:deviceX/in_voltageY_offset
-What: /sys/bus/iio/devices/iio:deviceX/in_voltage_offset
-What: /sys/bus/iio/devices/iio:deviceX/in_tempY_offset
-What: /sys/bus/iio/devices/iio:deviceX/in_temp_offset
-KernelVersion: 2.6.35
-Contact: linux-iio@vger.kernel.org
-Description:
- If known for a device, offset to be added to <type>[Y]_raw prior
- to scaling by <type>[Y]_scale in order to obtain value in the
- <type> units as specified in <type>[y]_raw documentation.
- Not present if the offset is always 0 or unknown. If Y or
- axis <x|y|z> is not present, then the offset applies to all
- in channels of <type>.
- May be writable if a variable offset can be applied on the
- device. Note that this is different to calibbias which
- is for devices (or drivers) that apply offsets to compensate
- for variation between different instances of the part, typically
- adjusted by using some hardware supported calibration procedure.
- Calibbias is applied internally, offset is applied in userspace
- to the _raw output.
-
-What: /sys/bus/iio/devices/iio:deviceX/in_voltageY_scale
-What: /sys/bus/iio/devices/iio:deviceX/in_voltageY_supply_scale
-What: /sys/bus/iio/devices/iio:deviceX/in_voltage_scale
-What: /sys/bus/iio/devices/iio:deviceX/out_voltageY_scale
-What: /sys/bus/iio/devices/iio:deviceX/in_accel_scale
-What: /sys/bus/iio/devices/iio:deviceX/in_accel_peak_scale
-What: /sys/bus/iio/devices/iio:deviceX/in_anglvel_scale
-What: /sys/bus/iio/devices/iio:deviceX/in_magn_scale
-What: /sys/bus/iio/devices/iio:deviceX/in_magn_x_scale
-What: /sys/bus/iio/devices/iio:deviceX/in_magn_y_scale
-What: /sys/bus/iio/devices/iio:deviceX/in_magn_z_scale
-KernelVersion: 2.6.35
-Contact: linux-iio@vger.kernel.org
-Description:
- If known for a device, scale to be applied to <type>Y[_name]_raw
- post addition of <type>[Y][_name]_offset in order to obtain the
- measured value in <type> units as specified in
- <type>[Y][_name]_raw documentation.. If shared across all in
- channels then Y and <x|y|z> are not present and the value is
- called <type>[Y][_name]_scale. The peak modifier means this
- value is applied to <type>Y[_name]_peak_raw values.
-
-What: /sys/bus/iio/devices/iio:deviceX/in_accel_x_calibbias
-What: /sys/bus/iio/devices/iio:deviceX/in_accel_y_calibbias
-What: /sys/bus/iio/devices/iio:deviceX/in_accel_z_calibbias
-What: /sys/bus/iio/devices/iio:deviceX/in_anglvel_x_calibbias
-What: /sys/bus/iio/devices/iio:deviceX/in_anglvel_y_calibbias
-What: /sys/bus/iio/devices/iio:deviceX/in_anglvel_z_calibbias
-KernelVersion: 2.6.35
-Contact: linux-iio@vger.kernel.org
-Description:
- Hardware applied calibration offset. (assumed to fix production
- inaccuracies).
-
-What /sys/bus/iio/devices/iio:deviceX/in_voltageY_calibscale
-What /sys/bus/iio/devices/iio:deviceX/in_voltageY_supply_calibscale
-What /sys/bus/iio/devices/iio:deviceX/in_voltage_calibscale
-What /sys/bus/iio/devices/iio:deviceX/in_accel_x_calibscale
-What /sys/bus/iio/devices/iio:deviceX/in_accel_y_calibscale
-What /sys/bus/iio/devices/iio:deviceX/in_accel_z_calibscale
-What /sys/bus/iio/devices/iio:deviceX/in_anglvel_x_calibscale
-What /sys/bus/iio/devices/iio:deviceX/in_anglvel_y_calibscale
-What /sys/bus/iio/devices/iio:deviceX/in_anglvel_z_calibscale
-KernelVersion: 2.6.35
-Contact: linux-iio@vger.kernel.org
-Description:
- Hardware applied calibration scale factor. (assumed to fix
- production inaccuracies). If shared across all channels,
- <type>_calibscale is used.
-
-What: /sys/bus/iio/devices/iio:deviceX/in_accel_scale_available
-What: /sys/.../iio:deviceX/in_voltageX_scale_available
-What: /sys/.../iio:deviceX/in_voltage-voltage_scale_available
-What: /sys/.../iio:deviceX/out_voltageX_scale_available
-What: /sys/.../iio:deviceX/in_capacitance_scale_available
-KernelVersion: 2.635
-Contact: linux-iio@vger.kernel.org
-Description:
- If a discrete set of scale values are available, they
- are listed in this attribute.
-
-What: /sys/.../in_accel_filter_low_pass_3db_frequency
-What: /sys/.../in_magn_filter_low_pass_3db_frequency
-What: /sys/.../in_anglvel_filter_low_pass_3db_frequency
-KernelVersion: 3.2
-Contact: linux-iio@vger.kernel.org
-Description:
- If a known or controllable low pass filter is applied
- to the underlying data channel, then this parameter
- gives the 3dB frequency of the filter in Hz.
-
-What: /sys/bus/iio/devices/iio:deviceX/out_voltageY_raw
-KernelVersion: 2.6.37
-Contact: linux-iio@vger.kernel.org
-Description:
- Raw (unscaled, no bias etc.) output voltage for
- channel Y. The number must always be specified and
- unique if the output corresponds to a single channel.
-
-What: /sys/bus/iio/devices/iio:deviceX/out_voltageY&Z_raw
-KernelVersion: 2.6.37
-Contact: linux-iio@vger.kernel.org
-Description:
- Raw (unscaled, no bias etc.) output voltage for an aggregate of
- channel Y, channel Z, etc. This interface is available in cases
- where a single output sets the value for multiple channels
- simultaneously.
-
-What: /sys/bus/iio/devices/iio:deviceX/out_voltageY_powerdown_mode
-What: /sys/bus/iio/devices/iio:deviceX/out_voltage_powerdown_mode
-KernelVersion: 2.6.38
-Contact: linux-iio@vger.kernel.org
-Description:
- Specifies the output powerdown mode.
- DAC output stage is disconnected from the amplifier and
- 1kohm_to_gnd: connected to ground via an 1kOhm resistor
- 100kohm_to_gnd: connected to ground via an 100kOhm resistor
- three_state: left floating
- For a list of available output power down options read
- outX_powerdown_mode_available. If Y is not present the
- mode is shared across all outputs.
-
-What: /sys/.../iio:deviceX/out_votlageY_powerdown_mode_available
-What: /sys/.../iio:deviceX/out_voltage_powerdown_mode_available
-KernelVersion: 2.6.38
-Contact: linux-iio@vger.kernel.org
-Description:
- Lists all available output power down modes.
- If Y is not present the mode is shared across all outputs.
-
-What: /sys/bus/iio/devices/iio:deviceX/out_voltageY_powerdown
-What: /sys/bus/iio/devices/iio:deviceX/out_voltage_powerdown
-KernelVersion: 2.6.38
-Contact: linux-iio@vger.kernel.org
-Description:
- Writing 1 causes output Y to enter the power down mode specified
- by the corresponding outY_powerdown_mode. Clearing returns to
- normal operation. Y may be suppressed if all outputs are
- controlled together.
-
-What: /sys/bus/iio/devices/iio:deviceX/events
-KernelVersion: 2.6.35
-Contact: linux-iio@vger.kernel.org
-Description:
- Configuration of which hardware generated events are passed up
- to user-space.
-
-What: /sys/.../iio:deviceX/events/in_accel_x_thresh_rising_en
-What: /sys/.../iio:deviceX/events/in_accel_x_thresh_falling_en
-What: /sys/.../iio:deviceX/events/in_accel_y_thresh_rising_en
-What: /sys/.../iio:deviceX/events/in_accel_y_thresh_falling_en
-What: /sys/.../iio:deviceX/events/in_accel_z_thresh_rising_en
-What: /sys/.../iio:deviceX/events/in_accel_z_thresh_falling_en
-What: /sys/.../iio:deviceX/events/in_anglvel_x_thresh_rising_en
-What: /sys/.../iio:deviceX/events/in_anglvel_x_thresh_falling_en
-What: /sys/.../iio:deviceX/events/in_anglvel_y_thresh_rising_en
-What: /sys/.../iio:deviceX/events/in_anglvel_y_thresh_falling_en
-What: /sys/.../iio:deviceX/events/in_anglvel_z_thresh_rising_en
-What: /sys/.../iio:deviceX/events/in_anglvel_z_thresh_falling_en
-What: /sys/.../iio:deviceX/events/in_magn_x_thresh_rising_en
-What: /sys/.../iio:deviceX/events/in_magn_x_thresh_falling_en
-What: /sys/.../iio:deviceX/events/in_magn_y_thresh_rising_en
-What: /sys/.../iio:deviceX/events/in_magn_y_thresh_falling_en
-What: /sys/.../iio:deviceX/events/in_magn_z_thresh_rising_en
-What: /sys/.../iio:deviceX/events/in_magn_z_thresh_falling_en
-What: /sys/.../iio:deviceX/events/in_voltageY_supply_thresh_rising_en
-What: /sys/.../iio:deviceX/events/in_voltageY_supply_thresh_falling_en
-What: /sys/.../iio:deviceX/events/in_voltageY_thresh_rising_en
-What: /sys/.../iio:deviceX/events/in_voltageY_thresh_falling_en
-What: /sys/.../iio:deviceX/events/in_tempY_thresh_rising_en
-What: /sys/.../iio:deviceX/events/in_tempY_thresh_falling_en
-KernelVersion: 2.6.37
-Contact: linux-iio@vger.kernel.org
-Description:
- Event generated when channel passes a threshold in the specified
- (_rising|_falling) direction. If the direction is not specified,
- then either the device will report an event which ever direction
- a single threshold value is passed in (e.g.
- <type>[Y][_name]_<raw|input>_thresh_value) or
- <type>[Y][_name]_<raw|input>_thresh_rising_value and
- <type>[Y][_name]_<raw|input>_thresh_falling_value may take
- different values, but the device can only enable both thresholds
- or neither.
- Note the driver will assume the last p events requested are
- to be enabled where p is however many it supports (which may
- vary depending on the exact set requested. So if you want to be
- sure you have set what you think you have, check the contents of
- these attributes after everything is configured. Drivers may
- have to buffer any parameters so that they are consistent when
- a given event type is enabled a future point (and not those for
- whatever event was previously enabled).
-
-What: /sys/.../iio:deviceX/events/in_accel_x_roc_rising_en
-What: /sys/.../iio:deviceX/events/in_accel_x_roc_falling_en
-What: /sys/.../iio:deviceX/events/in_accel_y_roc_rising_en
-What: /sys/.../iio:deviceX/events/in_accel_y_roc_falling_en
-What: /sys/.../iio:deviceX/events/in_accel_z_roc_rising_en
-What: /sys/.../iio:deviceX/events/in_accel_z_roc_falling_en
-What: /sys/.../iio:deviceX/events/in_anglvel_x_roc_rising_en
-What: /sys/.../iio:deviceX/events/in_anglvel_x_roc_falling_en
-What: /sys/.../iio:deviceX/events/in_anglvel_y_roc_rising_en
-What: /sys/.../iio:deviceX/events/in_anglvel_y_roc_falling_en
-What: /sys/.../iio:deviceX/events/in_anglvel_z_roc_rising_en
-What: /sys/.../iio:deviceX/events/in_anglvel_z_roc_falling_en
-What: /sys/.../iio:deviceX/events/in_magn_x_roc_rising_en
-What: /sys/.../iio:deviceX/events/in_magn_x_roc_falling_en
-What: /sys/.../iio:deviceX/events/in_magn_y_roc_rising_en
-What: /sys/.../iio:deviceX/events/in_magn_y_roc_falling_en
-What: /sys/.../iio:deviceX/events/in_magn_z_roc_rising_en
-What: /sys/.../iio:deviceX/events/in_magn_z_roc_falling_en
-What: /sys/.../iio:deviceX/events/in_voltageY_supply_roc_rising_en
-What: /sys/.../iio:deviceX/events/in_voltageY_supply_roc_falling_en
-What: /sys/.../iio:deviceX/events/in_voltageY_roc_rising_en
-What: /sys/.../iio:deviceX/events/in_voltageY_roc_falling_en
-What: /sys/.../iio:deviceX/events/in_tempY_roc_rising_en
-What: /sys/.../iio:deviceX/events/in_tempY_roc_falling_en
-KernelVersion: 2.6.37
-Contact: linux-iio@vger.kernel.org
-Description:
- Event generated when channel passes a threshold on the rate of
- change (1st differential) in the specified (_rising|_falling)
- direction. If the direction is not specified, then either the
- device will report an event which ever direction a single
- threshold value is passed in (e.g.
- <type>[Y][_name]_<raw|input>_roc_value) or
- <type>[Y][_name]_<raw|input>_roc_rising_value and
- <type>[Y][_name]_<raw|input>_roc_falling_value may take
- different values, but the device can only enable both rate of
- change thresholds or neither.
- Note the driver will assume the last p events requested are
- to be enabled where p is however many it supports (which may
- vary depending on the exact set requested. So if you want to be
- sure you have set what you think you have, check the contents of
- these attributes after everything is configured. Drivers may
- have to buffer any parameters so that they are consistent when
- a given event type is enabled a future point (and not those for
- whatever event was previously enabled).
-
-What: /sys/.../events/in_accel_x_raw_thresh_rising_value
-What: /sys/.../events/in_accel_x_raw_thresh_falling_value
-What: /sys/.../events/in_accel_y_raw_thresh_rising_value
-What: /sys/.../events/in_accel_y_raw_thresh_falling_value
-What: /sys/.../events/in_accel_z_raw_thresh_rising_value
-What: /sys/.../events/in_accel_z_raw_thresh_falling_value
-What: /sys/.../events/in_anglvel_x_raw_thresh_rising_value
-What: /sys/.../events/in_anglvel_x_raw_thresh_falling_value
-What: /sys/.../events/in_anglvel_y_raw_thresh_rising_value
-What: /sys/.../events/in_anglvel_y_raw_thresh_falling_value
-What: /sys/.../events/in_anglvel_z_raw_thresh_rising_value
-What: /sys/.../events/in_anglvel_z_raw_thresh_falling_value
-What: /sys/.../events/in_magn_x_raw_thresh_rising_value
-What: /sys/.../events/in_magn_x_raw_thresh_falling_value
-What: /sys/.../events/in_magn_y_raw_thresh_rising_value
-What: /sys/.../events/in_magn_y_raw_thresh_falling_value
-What: /sys/.../events/in_magn_z_raw_thresh_rising_value
-What: /sys/.../events/in_magn_z_raw_thresh_falling_value
-What: /sys/.../events/in_voltageY_supply_raw_thresh_rising_value
-What: /sys/.../events/in_voltageY_supply_raw_thresh_falling_value
-What: /sys/.../events/in_voltageY_raw_thresh_falling_value
-What: /sys/.../events/in_voltageY_raw_thresh_falling_value
-What: /sys/.../events/in_tempY_raw_thresh_falling_value
-What: /sys/.../events/in_tempY_raw_thresh_falling_value
-KernelVersion: 2.6.37
-Contact: linux-iio@vger.kernel.org
-Description:
- Specifies the value of threshold that the device is comparing
- against for the events enabled by
- <type>Y[_name]_thresh[_rising|falling]_en.
- If separate attributes exist for the two directions, but
- direction is not specified for this attribute, then a single
- threshold value applies to both directions.
- The raw or input element of the name indicates whether the
- value is in raw device units or in processed units (as _raw
- and _input do on sysfs direct channel read attributes).
-
-What: /sys/.../events/in_accel_x_raw_roc_rising_value
-What: /sys/.../events/in_accel_x_raw_roc_falling_value
-What: /sys/.../events/in_accel_y_raw_roc_rising_value
-What: /sys/.../events/in_accel_y_raw_roc_falling_value
-What: /sys/.../events/in_accel_z_raw_roc_rising_value
-What: /sys/.../events/in_accel_z_raw_roc_falling_value
-What: /sys/.../events/in_anglvel_x_raw_roc_rising_value
-What: /sys/.../events/in_anglvel_x_raw_roc_falling_value
-What: /sys/.../events/in_anglvel_y_raw_roc_rising_value
-What: /sys/.../events/in_anglvel_y_raw_roc_falling_value
-What: /sys/.../events/in_anglvel_z_raw_roc_rising_value
-What: /sys/.../events/in_anglvel_z_raw_roc_falling_value
-What: /sys/.../events/in_magn_x_raw_roc_rising_value
-What: /sys/.../events/in_magn_x_raw_roc_falling_value
-What: /sys/.../events/in_magn_y_raw_roc_rising_value
-What: /sys/.../events/in_magn_y_raw_roc_falling_value
-What: /sys/.../events/in_magn_z_raw_roc_rising_value
-What: /sys/.../events/in_magn_z_raw_roc_falling_value
-What: /sys/.../events/in_voltageY_supply_raw_roc_rising_value
-What: /sys/.../events/in_voltageY_supply_raw_roc_falling_value
-What: /sys/.../events/in_voltageY_raw_roc_falling_value
-What: /sys/.../events/in_voltageY_raw_roc_falling_value
-What: /sys/.../events/in_tempY_raw_roc_falling_value
-What: /sys/.../events/in_tempY_raw_roc_falling_value
-KernelVersion: 2.6.37
-Contact: linux-iio@vger.kernel.org
-Description:
- Specifies the value of rate of change threshold that the
- device is comparing against for the events enabled by
- <type>[Y][_name]_roc[_rising|falling]_en.
- If separate attributes exist for the two directions,
- but direction is not specified for this attribute,
- then a single threshold value applies to both directions.
- The raw or input element of the name indicates whether the
- value is in raw device units or in processed units (as _raw
- and _input do on sysfs direct channel read attributes).
-
-What: /sys/.../events/in_accel_x_thresh_rising_period
-What: /sys/.../events/in_accel_x_thresh_falling_period
-hat: /sys/.../events/in_accel_x_roc_rising_period
-What: /sys/.../events/in_accel_x_roc_falling_period
-What: /sys/.../events/in_accel_y_thresh_rising_period
-What: /sys/.../events/in_accel_y_thresh_falling_period
-What: /sys/.../events/in_accel_y_roc_rising_period
-What: /sys/.../events/in_accel_y_roc_falling_period
-What: /sys/.../events/in_accel_z_thresh_rising_period
-What: /sys/.../events/in_accel_z_thresh_falling_period
-What: /sys/.../events/in_accel_z_roc_rising_period
-What: /sys/.../events/in_accel_z_roc_falling_period
-What: /sys/.../events/in_anglvel_x_thresh_rising_period
-What: /sys/.../events/in_anglvel_x_thresh_falling_period
-What: /sys/.../events/in_anglvel_x_roc_rising_period
-What: /sys/.../events/in_anglvel_x_roc_falling_period
-What: /sys/.../events/in_anglvel_y_thresh_rising_period
-What: /sys/.../events/in_anglvel_y_thresh_falling_period
-What: /sys/.../events/in_anglvel_y_roc_rising_period
-What: /sys/.../events/in_anglvel_y_roc_falling_period
-What: /sys/.../events/in_anglvel_z_thresh_rising_period
-What: /sys/.../events/in_anglvel_z_thresh_falling_period
-What: /sys/.../events/in_anglvel_z_roc_rising_period
-What: /sys/.../events/in_anglvel_z_roc_falling_period
-What: /sys/.../events/in_magn_x_thresh_rising_period
-What: /sys/.../events/in_magn_x_thresh_falling_period
-What: /sys/.../events/in_magn_x_roc_rising_period
-What: /sys/.../events/in_magn_x_roc_falling_period
-What: /sys/.../events/in_magn_y_thresh_rising_period
-What: /sys/.../events/in_magn_y_thresh_falling_period
-What: /sys/.../events/in_magn_y_roc_rising_period
-What: /sys/.../events/in_magn_y_roc_falling_period
-What: /sys/.../events/in_magn_z_thresh_rising_period
-What: /sys/.../events/in_magn_z_thresh_falling_period
-What: /sys/.../events/in_magn_z_roc_rising_period
-What: /sys/.../events/in_magn_z_roc_falling_period
-What: /sys/.../events/in_voltageY_supply_thresh_rising_period
-What: /sys/.../events/in_voltageY_supply_thresh_falling_period
-What: /sys/.../events/in_voltageY_supply_roc_rising_period
-What: /sys/.../events/in_voltageY_supply_roc_falling_period
-What: /sys/.../events/in_voltageY_thresh_rising_period
-What: /sys/.../events/in_voltageY_thresh_falling_period
-What: /sys/.../events/in_voltageY_roc_rising_period
-What: /sys/.../events/in_voltageY_roc_falling_period
-What: /sys/.../events/in_tempY_thresh_rising_period
-What: /sys/.../events/in_tempY_thresh_falling_period
-What: /sys/.../events/in_tempY_roc_rising_period
-What: /sys/.../events/in_tempY_roc_falling_period
-What: /sys/.../events/in_accel_x&y&z_mag_falling_period
-KernelVersion: 2.6.37
-Contact: linux-iio@vger.kernel.org
-Description:
- Period of time (in seconds) for which the condition must be
- met before an event is generated. If direction is not
- specified then this period applies to both directions.
-
-What: /sys/.../iio:deviceX/events/in_accel_mag_en
-What: /sys/.../iio:deviceX/events/in_accel_mag_rising_en
-What: /sys/.../iio:deviceX/events/in_accel_mag_falling_en
-What: /sys/.../iio:deviceX/events/in_accel_x_mag_en
-What: /sys/.../iio:deviceX/events/in_accel_x_mag_rising_en
-What: /sys/.../iio:deviceX/events/in_accel_x_mag_falling_en
-What: /sys/.../iio:deviceX/events/in_accel_y_mag_en
-What: /sys/.../iio:deviceX/events/in_accel_y_mag_rising_en
-What: /sys/.../iio:deviceX/events/in_accel_y_mag_falling_en
-What: /sys/.../iio:deviceX/events/in_accel_z_mag_en
-What: /sys/.../iio:deviceX/events/in_accel_z_mag_rising_en
-What: /sys/.../iio:deviceX/events/in_accel_z_mag_falling_en
-What: /sys/.../iio:deviceX/events/in_accel_x&y&z_mag_rising_en
-What: /sys/.../iio:deviceX/events/in_accel_x&y&z_mag_falling_en
-KernelVersion: 2.6.37
-Contact: linux-iio@vger.kernel.org
-Description:
- Similar to in_accel_x_thresh[_rising|_falling]_en, but here the
- magnitude of the channel is compared to the threshold, not its
- signed value.
-
-What: /sys/.../events/in_accel_raw_mag_value
-What: /sys/.../events/in_accel_x_raw_mag_rising_value
-What: /sys/.../events/in_accel_y_raw_mag_rising_value
-What: /sys/.../events/in_accel_z_raw_mag_rising_value
-KernelVersion: 2.6.37
-Contact: linux-iio@vger.kernel.org
-Description:
- The value to which the magnitude of the channel is compared. If
- number or direction is not specified, applies to all channels of
- this type.
-
-What: /sys/bus/iio/devices/iio:deviceX/trigger/current_trigger
-KernelVersion: 2.6.35
-Contact: linux-iio@vger.kernel.org
-Description:
- The name of the trigger source being used, as per string given
- in /sys/class/iio/triggerY/name.
-
-What: /sys/bus/iio/devices/iio:deviceX/buffer/length
-KernelVersion: 2.6.35
-Contact: linux-iio@vger.kernel.org
-Description:
- Number of scans contained by the buffer.
-
-What: /sys/bus/iio/devices/iio:deviceX/buffer/bytes_per_datum
-KernelVersion: 2.6.37
-Contact: linux-iio@vger.kernel.org
-Description:
- Bytes per scan. Due to alignment fun, the scan may be larger
- than implied directly by the scan_element parameters.
-
-What: /sys/bus/iio/devices/iio:deviceX/buffer/enable
-KernelVersion: 2.6.35
-Contact: linux-iio@vger.kernel.org
-Description:
- Actually start the buffer capture up. Will start trigger
- if first device and appropriate.
-
-What: /sys/bus/iio/devices/iio:deviceX/buffer/scan_elements
-KernelVersion: 2.6.37
-Contact: linux-iio@vger.kernel.org
-Description:
- Directory containing interfaces for elements that will be
- captured for a single triggered sample set in the buffer.
-
-What: /sys/.../buffer/scan_elements/in_accel_x_en
-What: /sys/.../buffer/scan_elements/in_accel_y_en
-What: /sys/.../buffer/scan_elements/in_accel_z_en
-What: /sys/.../buffer/scan_elements/in_anglvel_x_en
-What: /sys/.../buffer/scan_elements/in_anglvel_y_en
-What: /sys/.../buffer/scan_elements/in_anglvel_z_en
-What: /sys/.../buffer/scan_elements/in_magn_x_en
-What: /sys/.../buffer/scan_elements/in_magn_y_en
-What: /sys/.../buffer/scan_elements/in_magn_z_en
-What: /sys/.../buffer/scan_elements/in_timestamp_en
-What: /sys/.../buffer/scan_elements/in_voltageY_supply_en
-What: /sys/.../buffer/scan_elements/in_voltageY_en
-What: /sys/.../buffer/scan_elements/in_voltageY-voltageZ_en
-What: /sys/.../buffer/scan_elements/in_incli_x_en
-What: /sys/.../buffer/scan_elements/in_incli_y_en
-KernelVersion: 2.6.37
-Contact: linux-iio@vger.kernel.org
-Description:
- Scan element control for triggered data capture.
-
-What: /sys/.../buffer/scan_elements/in_accel_type
-What: /sys/.../buffer/scan_elements/in_anglvel_type
-What: /sys/.../buffer/scan_elements/in_magn_type
-What: /sys/.../buffer/scan_elements/in_incli_type
-What: /sys/.../buffer/scan_elements/in_voltageY_type
-What: /sys/.../buffer/scan_elements/in_voltage-in_type
-What: /sys/.../buffer/scan_elements/in_voltageY_supply_type
-What: /sys/.../buffer/scan_elements/in_timestamp_type
-KernelVersion: 2.6.37
-Contact: linux-iio@vger.kernel.org
-Description:
- Description of the scan element data storage within the buffer
- and hence the form in which it is read from user-space.
- Form is [be|le]:[s|u]bits/storagebits[>>shift].
- be or le specifies big or little endian. s or u specifies if
- signed (2's complement) or unsigned. bits is the number of bits
- of data and storagebits is the space (after padding) that it
- occupies in the buffer. shift if specified, is the shift that
- needs to be applied prior to masking out unused bits. Some
- devices put their data in the middle of the transferred elements
- with additional information on both sides. Note that some
- devices will have additional information in the unused bits
- so to get a clean value, the bits value must be used to mask
- the buffer output value appropriately. The storagebits value
- also specifies the data alignment. So s48/64>>2 will be a
- signed 48 bit integer stored in a 64 bit location aligned to
- a a64 bit boundary. To obtain the clean value, shift right 2
- and apply a mask to zero the top 16 bits of the result.
- For other storage combinations this attribute will be extended
- appropriately.
-
-What: /sys/.../buffer/scan_elements/in_accel_type_available
-KernelVersion: 2.6.37
-Contact: linux-iio@vger.kernel.org
-Description:
- If the type parameter can take one of a small set of values,
- this attribute lists them.
-
-What: /sys/.../buffer/scan_elements/in_voltageY_index
-What: /sys/.../buffer/scan_elements/in_voltageY_supply_index
-What: /sys/.../buffer/scan_elements/in_accel_x_index
-What: /sys/.../buffer/scan_elements/in_accel_y_index
-What: /sys/.../buffer/scan_elements/in_accel_z_index
-What: /sys/.../buffer/scan_elements/in_anglvel_x_index
-What: /sys/.../buffer/scan_elements/in_anglvel_y_index
-What: /sys/.../buffer/scan_elements/in_anglvel_z_index
-What: /sys/.../buffer/scan_elements/in_magn_x_index
-What: /sys/.../buffer/scan_elements/in_magn_y_index
-What: /sys/.../buffer/scan_elements/in_magn_z_index
-What: /sys/.../buffer/scan_elements/in_incli_x_index
-What: /sys/.../buffer/scan_elements/in_incli_y_index
-What: /sys/.../buffer/scan_elements/in_timestamp_index
-KernelVersion: 2.6.37
-Contact: linux-iio@vger.kernel.org
-Description:
- A single positive integer specifying the position of this
- scan element in the buffer. Note these are not dependent on
- what is enabled and may not be contiguous. Thus for user-space
- to establish the full layout these must be used in conjunction
- with all _en attributes to establish which channels are present,
- and the relevant _type attributes to establish the data storage
- format.
-
-What: /sys/.../iio:deviceX/in_anglvel_z_quadrature_correction_raw
-KernelVersion: 2.6.38
-Contact: linux-iio@vger.kernel.org
-Description:
- This attribute is used to read the amount of quadrature error
- present in the device at a given time.
-
-What: /sys/.../iio:deviceX/ac_excitation_en
-KernelVersion: 3.1.0
-Contact: linux-iio@vger.kernel.org
-Description:
- This attribute, if available, is used to enable the AC
- excitation mode found on some converters. In ac excitation mode,
- the polarity of the excitation voltage is reversed on
- alternate cycles, to eliminate DC errors.
-
-What: /sys/.../iio:deviceX/bridge_switch_en
-KernelVersion: 3.1.0
-Contact: linux-iio@vger.kernel.org
-Description:
- This attribute, if available, is used to close or open the
- bridge power down switch found on some converters.
- In bridge applications, such as strain gauges and load cells,
- the bridge itself consumes the majority of the current in the
- system. To minimize the current consumption of the system,
- the bridge can be disconnected (when it is not being used
- using the bridge_switch_en attribute.
diff --git a/drivers/staging/iio/Documentation/sysfs-bus-iio-ad7192 b/drivers/staging/iio/Documentation/sysfs-bus-iio-ad7192
new file mode 100644
index 000000000000..1c35c507cc05
--- /dev/null
+++ b/drivers/staging/iio/Documentation/sysfs-bus-iio-ad7192
@@ -0,0 +1,20 @@
+What: /sys/.../iio:deviceX/ac_excitation_en
+KernelVersion: 3.1.0
+Contact: linux-iio@vger.kernel.org
+Description:
+ This attribute, if available, is used to enable the AC
+ excitation mode found on some converters. In ac excitation mode,
+ the polarity of the excitation voltage is reversed on
+ alternate cycles, to eliminate DC errors.
+
+What: /sys/.../iio:deviceX/bridge_switch_en
+KernelVersion: 3.1.0
+Contact: linux-iio@vger.kernel.org
+Description:
+ This attribute, if available, is used to close or open the
+ bridge power down switch found on some converters.
+ In bridge applications, such as strain gauges and load cells,
+ the bridge itself consumes the majority of the current in the
+ system. To minimize the current consumption of the system,
+ the bridge can be disconnected (when it is not being used
+ using the bridge_switch_en attribute.
diff --git a/drivers/staging/iio/Documentation/sysfs-bus-iio-dds b/drivers/staging/iio/Documentation/sysfs-bus-iio-dds
index ffdd5478a35d..ee8c509c6733 100644
--- a/drivers/staging/iio/Documentation/sysfs-bus-iio-dds
+++ b/drivers/staging/iio/Documentation/sysfs-bus-iio-dds
@@ -1,83 +1,86 @@
-What: /sys/bus/iio/devices/.../ddsX_freqY
+What: /sys/bus/iio/devices/.../out_altvoltageX_frequencyY
KernelVersion: 2.6.37
Contact: linux-iio@vger.kernel.org
Description:
Stores frequency into tuning word Y.
- There will be more than one ddsX_freqY file, which allows for
- pin controlled FSK Frequency Shift Keying
- (ddsX_pincontrol_freq_en is active) or the user can control
- the desired active tuning word by writing Y to the
- ddsX_freqsymbol file.
+ There will be more than one out_altvoltageX_frequencyY file,
+ which allows for pin controlled FSK Frequency Shift Keying
+ (out_altvoltageX_pincontrol_frequency_en is active) or the user
+ can control the desired active tuning word by writing Y to the
+ out_altvoltageX_frequencysymbol file.
-What: /sys/bus/iio/devices/.../ddsX_freqY_scale
+What: /sys/bus/iio/devices/.../out_altvoltageX_frequencyY_scale
KernelVersion: 2.6.37
Contact: linux-iio@vger.kernel.org
Description:
- Scale to be applied to ddsX_freqY in order to obtain the
- desired value in Hz. If shared across all frequency registers
- Y is not present. It is also possible X is not present if
- shared across all channels.
+ Scale to be applied to out_altvoltageX_frequencyY in order to
+ obtain the desired value in Hz. If shared across all frequency
+ registers Y is not present. It is also possible X is not present
+ if shared across all channels.
-What: /sys/bus/iio/devices/.../ddsX_freqsymbol
+What: /sys/bus/iio/devices/.../out_altvoltageX_frequencysymbol
KernelVersion: 2.6.37
Contact: linux-iio@vger.kernel.org
Description:
Specifies the active output frequency tuning word. The value
- corresponds to the Y in ddsX_freqY. To exit this mode the user
- can write ddsX_pincontrol_freq_en or ddsX_out_enable file.
+ corresponds to the Y in out_altvoltageX_frequencyY.
+ To exit this mode the user can write
+ out_altvoltageX_pincontrol_frequency_en or
+ out_altvoltageX_out_enable file.
-What: /sys/bus/iio/devices/.../ddsX_phaseY
+What: /sys/bus/iio/devices/.../out_altvoltageX_phaseY
KernelVersion: 2.6.37
Contact: linux-iio@vger.kernel.org
Description:
Stores phase into Y.
- There will be more than one ddsX_phaseY file, which allows for
- pin controlled PSK Phase Shift Keying
- (ddsX_pincontrol_phase_en is active) or the user can
+ There will be more than one out_altvoltageX_phaseY file, which
+ allows for pin controlled PSK Phase Shift Keying
+ (out_altvoltageX_pincontrol_phase_en is active) or the user can
control the desired phase Y which is added to the phase
- accumulator output by writing Y to the en_phase file.
+ accumulator output by writing Y to the phase_en file.
-What: /sys/bus/iio/devices/.../ddsX_phaseY_scale
+What: /sys/bus/iio/devices/.../out_altvoltageX_phaseY_scale
KernelVersion: 2.6.37
Contact: linux-iio@vger.kernel.org
Description:
- Scale to be applied to ddsX_phaseY in order to obtain the
- desired value in rad. If shared across all phase registers
+ Scale to be applied to out_altvoltageX_phaseY in order to obtain
+ the desired value in rad. If shared across all phase registers
Y is not present. It is also possible X is not present if
shared across all channels.
-What: /sys/bus/iio/devices/.../ddsX_phasesymbol
+What: /sys/bus/iio/devices/.../out_altvoltageX_phasesymbol
KernelVersion: 2.6.37
Contact: linux-iio@vger.kernel.org
Description:
Specifies the active phase Y which is added to the phase
accumulator output. The value corresponds to the Y in
- ddsX_phaseY. To exit this mode the user can write
- ddsX_pincontrol_phase_en or disable file.
+ out_altvoltageX_phaseY. To exit this mode the user can write
+ out_altvoltageX_pincontrol_phase_en or disable file.
-What: /sys/bus/iio/devices/.../ddsX_pincontrol_en
-What: /sys/bus/iio/devices/.../ddsX_pincontrol_freq_en
-What: /sys/bus/iio/devices/.../ddsX_pincontrol_phase_en
+What: /sys/bus/iio/devices/.../out_altvoltageX_pincontrol_en
+What: /sys/bus/iio/devices/.../out_altvoltageX_pincontrol_frequency_en
+What: /sys/bus/iio/devices/.../out_altvoltageX_pincontrol_phase_en
KernelVersion: 2.6.37
Contact: linux-iio@vger.kernel.org
Description:
- ddsX_pincontrol_en: Both, the active frequency and phase is
- controlled by the respective phase and frequency control inputs.
- In case the device in question allows to independent controls,
- then there are dedicated files (ddsX_pincontrol_freq_en,
- ddsX_pincontrol_phase_en).
+ out_altvoltageX_pincontrol_en: Both, the active frequency and
+ phase is controlled by the respective phase and frequency
+ control inputs. In case the device in features independent
+ controls, then there are dedicated files
+ (out_altvoltageX_pincontrol_frequency_en,
+ out_altvoltageX_pincontrol_phase_en).
-What: /sys/bus/iio/devices/.../ddsX_out_enable
-What: /sys/bus/iio/devices/.../ddsX_outY_enable
+What: /sys/bus/iio/devices/.../out_altvoltageX_out_enable
+What: /sys/bus/iio/devices/.../out_altvoltageX_outY_enable
KernelVersion: 2.6.37
Contact: linux-iio@vger.kernel.org
Description:
- ddsX_outY_enable controls signal generation on output Y of
- channel X. Y may be suppressed if all channels are
+ out_altvoltageX_outY_enable controls signal generation on
+ output Y of channel X. Y may be suppressed if all channels are
controlled together.
-What: /sys/bus/iio/devices/.../ddsX_outY_wavetype
+What: /sys/bus/iio/devices/.../out_altvoltageX_outY_wavetype
KernelVersion: 2.6.37
Contact: linux-iio@vger.kernel.org
Description:
@@ -86,7 +89,7 @@ Description:
For a list of available output waveform options read
available_output_modes.
-What: /sys/bus/iio/devices/.../ddsX_outY_wavetype_available
+What: /sys/bus/iio/devices/.../out_altvoltageX_outY_wavetype_available
KernelVersion: 2.6.37
Contact: linux-iio@vger.kernel.org
Description:
diff --git a/drivers/staging/iio/Documentation/sysfs-bus-iio-light b/drivers/staging/iio/Documentation/sysfs-bus-iio-light
index edbf470e4e30..17e5c9c515d4 100644
--- a/drivers/staging/iio/Documentation/sysfs-bus-iio-light
+++ b/drivers/staging/iio/Documentation/sysfs-bus-iio-light
@@ -26,7 +26,7 @@ Description:
Hardware dependent list of possible values supported for the
adc_resolution of the given sensor.
-What: /sys/bus/iio/devices/device[n]/illuminance0[_input|_raw]
+What: /sys/bus/iio/devices/device[n]/in_illuminance0[_input|_raw]
KernelVersion: 2.6.35
Contact: linux-iio@vger.kernel.org
Description:
@@ -34,7 +34,7 @@ Description:
it comes back in SI units, it should also include _input else it
should include _raw to signify it is not in SI units.
-What: /sys/.../device[n]/proximity_on_chip_ambient_infrared_supression
+What: /sys/.../device[n]/proximity_on_chip_ambient_infrared_suppression
KernelVersion: 2.6.37
Contact: linux-iio@vger.kernel.org
Description:
@@ -45,7 +45,7 @@ Description:
do this calculation manually by reading the infrared sensor
value and doing the negation in sw.
-What: /sys/bus/iio/devices/device[n]/proximity[_input|_raw]
+What: /sys/bus/iio/devices/device[n]/in_proximity[_input|_raw]
KernelVersion: 2.6.37
Contact: linux-iio@vger.kernel.org
Description:
@@ -63,23 +63,45 @@ Description:
and if expressed in SI units, should include _input. If this
value is not in SI units, then it should include _raw.
-What: /sys/bus/iio/devices/device[n]/illuminance0_target
+What: /sys/bus/iio/devices/device[n]/in_illuminance0_target
KernelVersion: 2.6.37
Contact: linux-iio@vger.kernel.org
Description:
This property gets/sets the last known external
lux measurement used in/for calibration.
-What: /sys/bus/iio/devices/device[n]/illuminance0_integration_time
+What: /sys/bus/iio/devices/device[n]/in_illuminance0_integration_time
KernelVersion: 2.6.37
Contact: linux-iio@vger.kernel.org
Description:
This property gets/sets the sensors ADC analog integration time.
-What: /sys/bus/iio/devices/device[n]/illuminance0_calibscale
+What: /sys/bus/iio/devices/device[n]/in_illuminance0_lux_table
KernelVersion: 2.6.37
Contact: linux-iio@vger.kernel.org
Description:
- Hardware or software applied calibration scale factor assumed
- to account for attenuation due to industrial design (glass
- filters or aperture holes).
+ This property gets/sets the table of coefficients
+ used in calculating illuminance in lux.
+
+What: /sys/bus/iio/devices/device[n]/in_intensity_clear[_input|_raw]
+What: /sys/bus/iio/devices/device[n]/in_intensity_red[_input|_raw]
+What: /sys/bus/iio/devices/device[n]/in_intensity_green[_input|_raw]
+What: /sys/bus/iio/devices/device[n]/in_intensity_blue[_input|_raw]
+KernelVersion: 3.6.0
+Contact: linux-iio@vger.kernel.org
+Description:
+ This property is supported by sensors that have a RGBC
+ sensing mode. This value should be the output from a reading
+ and if expressed in SI units, should include _input. If this
+ value is not in SI units (irradiance, uW/mm^2), then it should
+ include _raw.
+
+What: /sys/bus/iio/devices/device[n]/in_cct0[_input|_raw]
+KernelVersion: 3.6.0
+Contact: linux-iio@vger.kernel.org
+Description:
+ This should return the correlated color temperature from the
+ light sensor. If it comes back in SI units, it should also
+ include _input else it should include _raw to signify it is not
+ in SI units.
+
diff --git a/drivers/staging/iio/Documentation/trigger.txt b/drivers/staging/iio/Documentation/trigger.txt
index fc2012ebc100..75cc37ff1ed0 100644
--- a/drivers/staging/iio/Documentation/trigger.txt
+++ b/drivers/staging/iio/Documentation/trigger.txt
@@ -5,7 +5,7 @@ an IIO device. Whilst this can create device specific complexities
such triggers are registered with the core in the same way as
stand-alone triggers.
-struct iio_trig *trig = iio_allocate_trigger("<trigger format string>", ...);
+struct iio_trig *trig = iio_trigger_alloc("<trigger format string>", ...);
allocates a trigger structure. The key elements to then fill in within
a driver are:
diff --git a/drivers/staging/iio/Kconfig b/drivers/staging/iio/Kconfig
index fe1586718880..04cd6ec1f70f 100644
--- a/drivers/staging/iio/Kconfig
+++ b/drivers/staging/iio/Kconfig
@@ -1,16 +1,9 @@
#
# Industrial I/O subsytem configuration
#
+menu "IIO staging drivers"
+ depends on IIO
-menuconfig IIO
- tristate "Industrial I/O support"
- depends on GENERIC_HARDIRQS
- help
- The industrial I/O subsystem provides a unified framework for
- drivers for many different types of embedded sensors using a
- number of different physical interfaces (i2c, spi, etc). See
- drivers/staging/iio/Documentation for more information.
-if IIO
config IIO_ST_HWMON
tristate "Hwmon driver that uses channels specified via iio maps"
depends on HWMON
@@ -19,12 +12,6 @@ config IIO_ST_HWMON
map allows IIO devices to provide basic hwmon functionality
for those channels specified in the map.
-config IIO_BUFFER
- bool "Enable buffer support within IIO"
- help
- Provide core support for various buffer based data
- acquisition methods.
-
if IIO_BUFFER
config IIO_SW_RING
@@ -36,39 +23,13 @@ config IIO_SW_RING
with the intention that some devices would be able to write
in interrupt context.
-config IIO_KFIFO_BUF
- select IIO_TRIGGER
- tristate "Industrial I/O buffering based on kfifo"
- help
- A simple fifo based on kfifo. Use this if you want a fifo
- rather than a ring buffer. Note that this currently provides
- no buffer events so it is up to userspace to work out how
- often to read from the buffer.
-
endif # IIO_BUFFER
-config IIO_TRIGGER
- boolean "Enable triggered sampling support"
- help
- Provides IIO core support for triggers. Currently these
- are used to initialize capture of samples to push into
- ring buffers. The triggers are effectively a 'capture
- data now' interrupt.
-
-config IIO_CONSUMERS_PER_TRIGGER
- int "Maximum number of consumers per trigger"
- depends on IIO_TRIGGER
- default "2"
- help
- This value controls the maximum number of consumers that a
- given trigger may handle. Default is 2.
-
source "drivers/staging/iio/accel/Kconfig"
source "drivers/staging/iio/adc/Kconfig"
source "drivers/staging/iio/addac/Kconfig"
source "drivers/staging/iio/cdc/Kconfig"
-source "drivers/staging/iio/dac/Kconfig"
-source "drivers/staging/iio/dds/Kconfig"
+source "drivers/staging/iio/frequency/Kconfig"
source "drivers/staging/iio/gyro/Kconfig"
source "drivers/staging/iio/impedance-analyzer/Kconfig"
source "drivers/staging/iio/imu/Kconfig"
@@ -104,4 +65,4 @@ config IIO_SIMPLE_DUMMY_BUFFER
endif # IIO_SIMPLE_DUMMY
-endif # IIO
+endmenu
diff --git a/drivers/staging/iio/Makefile b/drivers/staging/iio/Makefile
index 5075291dda7a..fa6937d92ee3 100644
--- a/drivers/staging/iio/Makefile
+++ b/drivers/staging/iio/Makefile
@@ -2,13 +2,7 @@
# Makefile for the industrial I/O core.
#
-obj-$(CONFIG_IIO) += industrialio.o
-industrialio-y := industrialio-core.o industrialio-event.o inkern.o
-industrialio-$(CONFIG_IIO_BUFFER) += industrialio-buffer.o
-industrialio-$(CONFIG_IIO_TRIGGER) += industrialio-trigger.o
-
obj-$(CONFIG_IIO_SW_RING) += ring_sw.o
-obj-$(CONFIG_IIO_KFIFO_BUF) += kfifo_buf.o
obj-$(CONFIG_IIO_SIMPLE_DUMMY) += iio_dummy.o
iio_dummy-y := iio_simple_dummy.o
@@ -23,8 +17,7 @@ obj-y += accel/
obj-y += adc/
obj-y += addac/
obj-y += cdc/
-obj-y += dac/
-obj-y += dds/
+obj-y += frequency/
obj-y += gyro/
obj-y += impedance-analyzer/
obj-y += imu/
diff --git a/drivers/staging/iio/TODO b/drivers/staging/iio/TODO
index d1ad35e24abb..cf3f9489b9da 100644
--- a/drivers/staging/iio/TODO
+++ b/drivers/staging/iio/TODO
@@ -67,7 +67,7 @@ e-mailing the normal IIO list (see below).
Documentation
1) Lots of cleanup and expansion.
-2) Some device require indvidual docs.
+2) Some device require individual docs.
Contact: Jonathan Cameron <jic23@cam.ac.uk>.
Mailing list: linux-iio@vger.kernel.org
diff --git a/drivers/staging/iio/accel/adis16201_core.c b/drivers/staging/iio/accel/adis16201_core.c
index d439e45d07fa..204106b72d24 100644
--- a/drivers/staging/iio/accel/adis16201_core.c
+++ b/drivers/staging/iio/accel/adis16201_core.c
@@ -15,9 +15,9 @@
#include <linux/sysfs.h>
#include <linux/module.h>
-#include "../iio.h"
-#include "../sysfs.h"
-#include "../buffer.h"
+#include <linux/iio/iio.h>
+#include <linux/iio/sysfs.h>
+#include <linux/iio/buffer.h>
#include "adis16201.h"
@@ -159,21 +159,6 @@ static int adis16201_reset(struct iio_dev *indio_dev)
return ret;
}
-static ssize_t adis16201_write_reset(struct device *dev,
- struct device_attribute *attr,
- const char *buf, size_t len)
-{
- int ret;
- bool res;
-
- if (len < 1)
- return -EINVAL;
- ret = strtobool(buf, &res);
- if (ret || !res)
- return ret;
- return adis16201_reset(dev_get_drvdata(dev));
-}
-
int adis16201_set_irq(struct iio_dev *indio_dev, bool enable)
{
int ret = 0;
@@ -298,7 +283,7 @@ static int adis16201_read_raw(struct iio_dev *indio_dev,
s16 val16;
switch (mask) {
- case 0:
+ case IIO_CHAN_INFO_RAW:
mutex_lock(&indio_dev->mlock);
addr = adis16201_addresses[chan->address][0];
ret = adis16201_spi_read_reg_16(indio_dev, addr, &val16);
@@ -406,55 +391,108 @@ static int adis16201_write_raw(struct iio_dev *indio_dev,
}
static struct iio_chan_spec adis16201_channels[] = {
- IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, "supply", 0, 0,
+ {
+ .type = IIO_VOLTAGE,
+ .indexed = 1,
+ .channel = 0,
+ .extend_name = "supply",
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
IIO_CHAN_INFO_SCALE_SEPARATE_BIT,
- in_supply, ADIS16201_SCAN_SUPPLY,
- IIO_ST('u', 12, 16, 0), 0),
- IIO_CHAN(IIO_TEMP, 0, 1, 0, NULL, 0, 0,
+ .address = in_supply,
+ .scan_index = ADIS16201_SCAN_SUPPLY,
+ .scan_type = {
+ .sign = 'u',
+ .realbits = 12,
+ .storagebits = 16,
+ },
+ }, {
+ .type = IIO_TEMP,
+ .indexed = 1,
+ .channel = 0,
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
IIO_CHAN_INFO_SCALE_SEPARATE_BIT |
IIO_CHAN_INFO_OFFSET_SEPARATE_BIT,
- temp, ADIS16201_SCAN_TEMP,
- IIO_ST('u', 12, 16, 0), 0),
- IIO_CHAN(IIO_ACCEL, 1, 0, 0, NULL, 0, IIO_MOD_X,
+ .address = temp,
+ .scan_index = ADIS16201_SCAN_TEMP,
+ .scan_type = {
+ .sign = 'u',
+ .realbits = 12,
+ .storagebits = 16,
+ },
+ }, {
+ .type = IIO_ACCEL,
+ .modified = 1,
+ .channel2 = IIO_MOD_X,
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
IIO_CHAN_INFO_SCALE_SHARED_BIT |
IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT,
- accel_x, ADIS16201_SCAN_ACC_X,
- IIO_ST('s', 14, 16, 0), 0),
- IIO_CHAN(IIO_ACCEL, 1, 0, 0, NULL, 0, IIO_MOD_Y,
+ .address = accel_x,
+ .scan_index = ADIS16201_SCAN_ACC_X,
+ .scan_type = {
+ .sign = 's',
+ .realbits = 14,
+ .storagebits = 16,
+ },
+ }, {
+ .type = IIO_ACCEL,
+ .modified = 1,
+ .channel2 = IIO_MOD_Y,
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
IIO_CHAN_INFO_SCALE_SHARED_BIT |
IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT,
- accel_y, ADIS16201_SCAN_ACC_Y,
- IIO_ST('s', 14, 16, 0), 0),
- IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 1, 0,
+ .address = accel_y,
+ .scan_index = ADIS16201_SCAN_ACC_Y,
+ .scan_type = {
+ .sign = 's',
+ .realbits = 14,
+ .storagebits = 16,
+ },
+ }, {
+ .type = IIO_VOLTAGE,
+ .indexed = 1,
+ .channel = 1,
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
IIO_CHAN_INFO_SCALE_SEPARATE_BIT,
- in_aux, ADIS16201_SCAN_AUX_ADC,
- IIO_ST('u', 12, 16, 0), 0),
- IIO_CHAN(IIO_INCLI, 1, 0, 0, NULL, 0, IIO_MOD_X,
+ .address = in_aux,
+ .scan_index = ADIS16201_SCAN_AUX_ADC,
+ .scan_type = {
+ .sign = 'u',
+ .realbits = 12,
+ .storagebits = 16,
+ },
+ }, {
+ .type = IIO_INCLI,
+ .modified = 1,
+ .channel2 = IIO_MOD_X,
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
IIO_CHAN_INFO_SCALE_SHARED_BIT |
IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT,
- incli_x, ADIS16201_SCAN_INCLI_X,
- IIO_ST('s', 14, 16, 0), 0),
- IIO_CHAN(IIO_INCLI, 1, 0, 0, NULL, 0, IIO_MOD_Y,
+ .address = incli_x,
+ .scan_index = ADIS16201_SCAN_INCLI_X,
+ .scan_type = {
+ .sign = 's',
+ .realbits = 14,
+ .storagebits = 16,
+ },
+ }, {
+ .type = IIO_INCLI,
+ .modified = 1,
+ .channel2 = IIO_MOD_Y,
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
IIO_CHAN_INFO_SCALE_SHARED_BIT |
IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT,
- incli_y, ADIS16201_SCAN_INCLI_Y,
- IIO_ST('s', 14, 16, 0), 0),
+ .address = incli_y,
+ .scan_index = ADIS16201_SCAN_INCLI_Y,
+ .scan_type = {
+ .sign = 's',
+ .realbits = 14,
+ .storagebits = 16,
+ },
+ },
IIO_CHAN_SOFT_TIMESTAMP(7)
};
-static IIO_DEVICE_ATTR(reset, S_IWUSR, NULL, adis16201_write_reset, 0);
-
-static struct attribute *adis16201_attributes[] = {
- &iio_dev_attr_reset.dev_attr.attr,
- NULL
-};
-
-static const struct attribute_group adis16201_attribute_group = {
- .attrs = adis16201_attributes,
-};
-
static const struct iio_info adis16201_info = {
- .attrs = &adis16201_attribute_group,
.read_raw = &adis16201_read_raw,
.write_raw = &adis16201_write_raw,
.driver_module = THIS_MODULE,
@@ -467,7 +505,7 @@ static int __devinit adis16201_probe(struct spi_device *spi)
struct iio_dev *indio_dev;
/* setup the industrialio driver allocated elements */
- indio_dev = iio_allocate_device(sizeof(*st));
+ indio_dev = iio_device_alloc(sizeof(*st));
if (indio_dev == NULL) {
ret = -ENOMEM;
goto error_ret;
@@ -522,7 +560,7 @@ error_uninitialize_ring:
error_unreg_ring_funcs:
adis16201_unconfigure_ring(indio_dev);
error_free_dev:
- iio_free_device(indio_dev);
+ iio_device_free(indio_dev);
error_ret:
return ret;
}
@@ -535,7 +573,7 @@ static int adis16201_remove(struct spi_device *spi)
adis16201_remove_trigger(indio_dev);
iio_buffer_unregister(indio_dev);
adis16201_unconfigure_ring(indio_dev);
- iio_free_device(indio_dev);
+ iio_device_free(indio_dev);
return 0;
}
diff --git a/drivers/staging/iio/accel/adis16201_ring.c b/drivers/staging/iio/accel/adis16201_ring.c
index 97f9e6b159d9..03fcf6e319db 100644
--- a/drivers/staging/iio/accel/adis16201_ring.c
+++ b/drivers/staging/iio/accel/adis16201_ring.c
@@ -5,9 +5,9 @@
#include <linux/spi/spi.h>
#include <linux/slab.h>
-#include "../iio.h"
+#include <linux/iio/iio.h>
#include "../ring_sw.h"
-#include "../trigger_consumer.h"
+#include <linux/iio/trigger_consumer.h>
#include "adis16201.h"
@@ -66,12 +66,11 @@ static irqreturn_t adis16201_trigger_handler(int irq, void *p)
int i = 0;
s16 *data;
- size_t datasize = ring->access->get_bytes_per_datum(ring);
- data = kmalloc(datasize, GFP_KERNEL);
+ data = kmalloc(indio_dev->scan_bytes, GFP_KERNEL);
if (data == NULL) {
dev_err(&st->us->dev, "memory alloc failed in ring bh");
- return -ENOMEM;
+ goto done;
}
if (!bitmap_empty(indio_dev->active_scan_mask, indio_dev->masklength)
@@ -81,13 +80,14 @@ static irqreturn_t adis16201_trigger_handler(int irq, void *p)
data[i] = be16_to_cpup((__be16 *)&(st->rx[i*2]));
/* Guaranteed to be aligned with 8 byte boundary */
- if (ring->scan_timestamp)
+ if (indio_dev->scan_timestamp)
*((s64 *)(data + ((i + 3)/4)*4)) = pf->timestamp;
ring->access->store_to(ring, (u8 *)data, pf->timestamp);
- iio_trigger_notify_done(indio_dev->trig);
kfree(data);
+done:
+ iio_trigger_notify_done(indio_dev->trig);
return IRQ_HANDLED;
}
diff --git a/drivers/staging/iio/accel/adis16201_trigger.c b/drivers/staging/iio/accel/adis16201_trigger.c
index bce505e716d0..96fdabbac201 100644
--- a/drivers/staging/iio/accel/adis16201_trigger.c
+++ b/drivers/staging/iio/accel/adis16201_trigger.c
@@ -3,8 +3,8 @@
#include <linux/spi/spi.h>
#include <linux/export.h>
-#include "../iio.h"
-#include "../trigger.h"
+#include <linux/iio/iio.h>
+#include <linux/iio/trigger.h>
#include "adis16201.h"
/**
@@ -29,7 +29,7 @@ int adis16201_probe_trigger(struct iio_dev *indio_dev)
int ret;
struct adis16201_state *st = iio_priv(indio_dev);
- st->trig = iio_allocate_trigger("adis16201-dev%d", indio_dev->id);
+ st->trig = iio_trigger_alloc("adis16201-dev%d", indio_dev->id);
if (st->trig == NULL) {
ret = -ENOMEM;
goto error_ret;
@@ -56,7 +56,7 @@ int adis16201_probe_trigger(struct iio_dev *indio_dev)
error_free_irq:
free_irq(st->us->irq, st->trig);
error_free_trig:
- iio_free_trigger(st->trig);
+ iio_trigger_free(st->trig);
error_ret:
return ret;
}
@@ -67,5 +67,5 @@ void adis16201_remove_trigger(struct iio_dev *indio_dev)
iio_trigger_unregister(state->trig);
free_irq(state->us->irq, state->trig);
- iio_free_trigger(state->trig);
+ iio_trigger_free(state->trig);
}
diff --git a/drivers/staging/iio/accel/adis16203_core.c b/drivers/staging/iio/accel/adis16203_core.c
index 1a5140f9e3f4..22085e9dfd16 100644
--- a/drivers/staging/iio/accel/adis16203_core.c
+++ b/drivers/staging/iio/accel/adis16203_core.c
@@ -15,9 +15,9 @@
#include <linux/sysfs.h>
#include <linux/module.h>
-#include "../iio.h"
-#include "../sysfs.h"
-#include "../buffer.h"
+#include <linux/iio/iio.h>
+#include <linux/iio/sysfs.h>
+#include <linux/iio/buffer.h>
#include "adis16203.h"
@@ -178,22 +178,6 @@ static int adis16203_reset(struct iio_dev *indio_dev)
return ret;
}
-static ssize_t adis16203_write_reset(struct device *dev,
- struct device_attribute *attr,
- const char *buf, size_t len)
-{
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
- if (len < 1)
- return -EINVAL;
- switch (buf[0]) {
- case '1':
- case 'y':
- case 'Y':
- return adis16203_reset(indio_dev);
- }
- return -EINVAL;
-}
-
int adis16203_set_irq(struct iio_dev *indio_dev, bool enable)
{
int ret = 0;
@@ -305,7 +289,7 @@ static int adis16203_read_raw(struct iio_dev *indio_dev,
u8 addr;
s16 val16;
switch (mask) {
- case 0:
+ case IIO_CHAN_INFO_RAW:
mutex_lock(&indio_dev->mlock);
addr = adis16203_addresses[chan->address][0];
ret = adis16203_spi_read_reg_16(indio_dev, addr, &val16);
@@ -372,45 +356,79 @@ static int adis16203_read_raw(struct iio_dev *indio_dev,
}
static struct iio_chan_spec adis16203_channels[] = {
- IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, "supply", 0, 0,
- IIO_CHAN_INFO_SCALE_SEPARATE_BIT,
- in_supply, ADIS16203_SCAN_SUPPLY,
- IIO_ST('u', 12, 16, 0), 0),
- IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 1, 0,
- IIO_CHAN_INFO_SCALE_SEPARATE_BIT,
- in_aux, ADIS16203_SCAN_AUX_ADC,
- IIO_ST('u', 12, 16, 0), 0),
- IIO_CHAN(IIO_INCLI, 1, 0, 0, NULL, 0, IIO_MOD_X,
- IIO_CHAN_INFO_SCALE_SHARED_BIT |
- IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT,
- incli_x, ADIS16203_SCAN_INCLI_X,
- IIO_ST('s', 14, 16, 0), 0),
- /* Fixme: Not what it appears to be - see data sheet */
- IIO_CHAN(IIO_INCLI, 1, 0, 0, NULL, 0, IIO_MOD_Y,
- IIO_CHAN_INFO_SCALE_SHARED_BIT,
- incli_y, ADIS16203_SCAN_INCLI_Y,
- IIO_ST('s', 14, 16, 0), 0),
- IIO_CHAN(IIO_TEMP, 0, 1, 0, NULL, 0, 0,
- IIO_CHAN_INFO_SCALE_SEPARATE_BIT |
- IIO_CHAN_INFO_OFFSET_SEPARATE_BIT,
- temp, ADIS16203_SCAN_TEMP,
- IIO_ST('u', 12, 16, 0), 0),
+ {
+ .type = IIO_VOLTAGE,
+ .indexed = 1,
+ .channel = 0,
+ .extend_name = "supply",
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
+ IIO_CHAN_INFO_SCALE_SEPARATE_BIT,
+ .address = in_supply,
+ .scan_index = ADIS16203_SCAN_SUPPLY,
+ .scan_type = {
+ .sign = 'u',
+ .realbits = 12,
+ .storagebits = 16,
+ },
+ }, {
+ .type = IIO_VOLTAGE,
+ .indexed = 1,
+ .channel = 1,
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
+ IIO_CHAN_INFO_SCALE_SEPARATE_BIT,
+ .address = in_aux,
+ .scan_index = ADIS16203_SCAN_AUX_ADC,
+ .scan_type = {
+ .sign = 'u',
+ .realbits = 12,
+ .storagebits = 16,
+ },
+ }, {
+ .type = IIO_INCLI,
+ .modified = 1,
+ .channel2 = IIO_MOD_X,
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
+ IIO_CHAN_INFO_SCALE_SHARED_BIT |
+ IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT,
+ .address = incli_x,
+ .scan_index = ADIS16203_SCAN_INCLI_X,
+ .scan_type = {
+ .sign = 's',
+ .realbits = 14,
+ .storagebits = 16,
+ },
+ }, { /* Fixme: Not what it appears to be - see data sheet */
+ .type = IIO_INCLI,
+ .modified = 1,
+ .channel2 = IIO_MOD_Y,
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
+ IIO_CHAN_INFO_SCALE_SHARED_BIT,
+ .address = incli_y,
+ .scan_index = ADIS16203_SCAN_INCLI_Y,
+ .scan_type = {
+ .sign = 's',
+ .realbits = 14,
+ .storagebits = 16,
+ },
+ }, {
+ .type = IIO_TEMP,
+ .indexed = 1,
+ .channel = 0,
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
+ IIO_CHAN_INFO_SCALE_SEPARATE_BIT |
+ IIO_CHAN_INFO_OFFSET_SEPARATE_BIT,
+ .address = temp,
+ .scan_index = ADIS16203_SCAN_TEMP,
+ .scan_type = {
+ .sign = 'u',
+ .realbits = 12,
+ .storagebits = 16,
+ },
+ },
IIO_CHAN_SOFT_TIMESTAMP(5),
};
-static IIO_DEVICE_ATTR(reset, S_IWUSR, NULL, adis16203_write_reset, 0);
-
-static struct attribute *adis16203_attributes[] = {
- &iio_dev_attr_reset.dev_attr.attr,
- NULL
-};
-
-static const struct attribute_group adis16203_attribute_group = {
- .attrs = adis16203_attributes,
-};
-
static const struct iio_info adis16203_info = {
- .attrs = &adis16203_attribute_group,
.read_raw = &adis16203_read_raw,
.write_raw = &adis16203_write_raw,
.driver_module = THIS_MODULE,
@@ -423,7 +441,7 @@ static int __devinit adis16203_probe(struct spi_device *spi)
struct adis16203_state *st;
/* setup the industrialio driver allocated elements */
- indio_dev = iio_allocate_device(sizeof(*st));
+ indio_dev = iio_device_alloc(sizeof(*st));
if (indio_dev == NULL) {
ret = -ENOMEM;
goto error_ret;
@@ -477,7 +495,7 @@ error_uninitialize_ring:
error_unreg_ring_funcs:
adis16203_unconfigure_ring(indio_dev);
error_free_dev:
- iio_free_device(indio_dev);
+ iio_device_free(indio_dev);
error_ret:
return ret;
}
@@ -490,7 +508,7 @@ static int adis16203_remove(struct spi_device *spi)
adis16203_remove_trigger(indio_dev);
iio_buffer_unregister(indio_dev);
adis16203_unconfigure_ring(indio_dev);
- iio_free_device(indio_dev);
+ iio_device_free(indio_dev);
return 0;
}
diff --git a/drivers/staging/iio/accel/adis16203_ring.c b/drivers/staging/iio/accel/adis16203_ring.c
index 6a8963db4f60..c16b2b7323ac 100644
--- a/drivers/staging/iio/accel/adis16203_ring.c
+++ b/drivers/staging/iio/accel/adis16203_ring.c
@@ -5,20 +5,19 @@
#include <linux/spi/spi.h>
#include <linux/slab.h>
-#include "../iio.h"
+#include <linux/iio/iio.h>
#include "../ring_sw.h"
-#include "../trigger_consumer.h"
+#include <linux/iio/trigger_consumer.h>
#include "adis16203.h"
/**
* adis16203_read_ring_data() read data registers which will be placed into ring
- * @dev: device associated with child of actual device (iio_dev or iio_trig)
+ * @indio_dev: the IIO device
* @rx: somewhere to pass back the value read
**/
-static int adis16203_read_ring_data(struct device *dev, u8 *rx)
+static int adis16203_read_ring_data(struct iio_dev *indio_dev, u8 *rx)
{
struct spi_message msg;
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
struct adis16203_state *st = iio_priv(indio_dev);
struct spi_transfer xfers[ADIS16203_OUTPUTS + 1];
int ret;
@@ -66,30 +65,30 @@ static irqreturn_t adis16203_trigger_handler(int irq, void *p)
int i = 0;
s16 *data;
- size_t datasize = ring->access->get_bytes_per_datum(ring);
- data = kmalloc(datasize, GFP_KERNEL);
+ data = kmalloc(indio_dev->scan_bytes, GFP_KERNEL);
if (data == NULL) {
dev_err(&st->us->dev, "memory alloc failed in ring bh");
- return -ENOMEM;
+ goto done;
}
if (!bitmap_empty(indio_dev->active_scan_mask, indio_dev->masklength) &&
- adis16203_read_ring_data(&indio_dev->dev, st->rx) >= 0)
+ adis16203_read_ring_data(indio_dev, st->rx) >= 0)
for (; i < bitmap_weight(indio_dev->active_scan_mask,
indio_dev->masklength); i++)
data[i] = be16_to_cpup((__be16 *)&(st->rx[i*2]));
/* Guaranteed to be aligned with 8 byte boundary */
- if (ring->scan_timestamp)
+ if (indio_dev->scan_timestamp)
*((s64 *)(data + ((i + 3)/4)*4)) = pf->timestamp;
ring->access->store_to(ring,
(u8 *)data,
pf->timestamp);
- iio_trigger_notify_done(indio_dev->trig);
kfree(data);
+done:
+ iio_trigger_notify_done(indio_dev->trig);
return IRQ_HANDLED;
}
diff --git a/drivers/staging/iio/accel/adis16203_trigger.c b/drivers/staging/iio/accel/adis16203_trigger.c
index 24bcb8e15c55..b8a04073d6d7 100644
--- a/drivers/staging/iio/accel/adis16203_trigger.c
+++ b/drivers/staging/iio/accel/adis16203_trigger.c
@@ -3,8 +3,8 @@
#include <linux/spi/spi.h>
#include <linux/export.h>
-#include "../iio.h"
-#include "../trigger.h"
+#include <linux/iio/iio.h>
+#include <linux/iio/trigger.h>
#include "adis16203.h"
/**
@@ -29,7 +29,7 @@ int adis16203_probe_trigger(struct iio_dev *indio_dev)
int ret;
struct adis16203_state *st = iio_priv(indio_dev);
- st->trig = iio_allocate_trigger("adis16203-dev%d", indio_dev->id);
+ st->trig = iio_trigger_alloc("adis16203-dev%d", indio_dev->id);
if (st->trig == NULL) {
ret = -ENOMEM;
goto error_ret;
@@ -58,7 +58,7 @@ int adis16203_probe_trigger(struct iio_dev *indio_dev)
error_free_irq:
free_irq(st->us->irq, st->trig);
error_free_trig:
- iio_free_trigger(st->trig);
+ iio_trigger_free(st->trig);
error_ret:
return ret;
}
@@ -69,5 +69,5 @@ void adis16203_remove_trigger(struct iio_dev *indio_dev)
iio_trigger_unregister(st->trig);
free_irq(st->us->irq, st->trig);
- iio_free_trigger(st->trig);
+ iio_trigger_free(st->trig);
}
diff --git a/drivers/staging/iio/accel/adis16204_core.c b/drivers/staging/iio/accel/adis16204_core.c
index fa89364b841e..5f2e5f11c543 100644
--- a/drivers/staging/iio/accel/adis16204_core.c
+++ b/drivers/staging/iio/accel/adis16204_core.c
@@ -18,9 +18,9 @@
#include <linux/list.h>
#include <linux/module.h>
-#include "../iio.h"
-#include "../sysfs.h"
-#include "../buffer.h"
+#include <linux/iio/iio.h>
+#include <linux/iio/sysfs.h>
+#include <linux/iio/buffer.h>
#include "adis16204.h"
@@ -169,32 +169,6 @@ error_ret:
return ret;
}
-static ssize_t adis16204_read_14bit_signed(struct device *dev,
- struct device_attribute *attr,
- char *buf)
-{
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
- struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
- s16 val = 0;
- ssize_t ret;
-
- mutex_lock(&indio_dev->mlock);
-
- ret = adis16204_spi_read_reg_16(indio_dev,
- this_attr->address, (u16 *)&val);
- if (!ret) {
- if (val & ADIS16204_ERROR_ACTIVE)
- adis16204_check_status(indio_dev);
-
- val = ((s16)(val << 2) >> 2);
- ret = sprintf(buf, "%d\n", val);
- }
-
- mutex_unlock(&indio_dev->mlock);
-
- return ret;
-}
-
static int adis16204_reset(struct iio_dev *indio_dev)
{
int ret;
@@ -207,23 +181,6 @@ static int adis16204_reset(struct iio_dev *indio_dev)
return ret;
}
-static ssize_t adis16204_write_reset(struct device *dev,
- struct device_attribute *attr,
- const char *buf, size_t len)
-{
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
-
- if (len < 1)
- return -EINVAL;
- switch (buf[0]) {
- case '1':
- case 'y':
- case 'Y':
- return adis16204_reset(indio_dev);
- }
- return -EINVAL;
-}
-
int adis16204_set_irq(struct iio_dev *indio_dev, bool enable)
{
int ret = 0;
@@ -299,18 +256,6 @@ err_ret:
}
/* Unique to this driver currently */
-#define IIO_DEV_ATTR_ACCEL_XY(_show, _addr) \
- IIO_DEVICE_ATTR(in_accel_xy, S_IRUGO, _show, NULL, _addr)
-#define IIO_DEV_ATTR_ACCEL_XYPEAK(_show, _addr) \
- IIO_DEVICE_ATTR(in_accel_xypeak, S_IRUGO, _show, NULL, _addr)
-
-static IIO_DEV_ATTR_ACCEL_XY(adis16204_read_14bit_signed,
- ADIS16204_XY_RSS_OUT);
-static IIO_DEV_ATTR_ACCEL_XYPEAK(adis16204_read_14bit_signed,
- ADIS16204_XY_PEAK_OUT);
-static IIO_CONST_ATTR(in_accel_xy_scale, "0.017125");
-
-static IIO_DEVICE_ATTR(reset, S_IWUSR, NULL, adis16204_write_reset, 0);
enum adis16204_channel {
in_supply,
@@ -318,9 +263,10 @@ enum adis16204_channel {
temp,
accel_x,
accel_y,
+ accel_xy,
};
-static u8 adis16204_addresses[5][3] = {
+static u8 adis16204_addresses[6][3] = {
[in_supply] = { ADIS16204_SUPPLY_OUT },
[in_aux] = { ADIS16204_AUX_ADC },
[temp] = { ADIS16204_TEMP_OUT },
@@ -328,6 +274,8 @@ static u8 adis16204_addresses[5][3] = {
ADIS16204_X_PEAK_OUT },
[accel_y] = { ADIS16204_XACCL_OUT, ADIS16204_YACCL_NULL,
ADIS16204_Y_PEAK_OUT },
+ [accel_xy] = { ADIS16204_XY_RSS_OUT, 0,
+ ADIS16204_XY_PEAK_OUT },
};
static int adis16204_read_raw(struct iio_dev *indio_dev,
@@ -342,7 +290,7 @@ static int adis16204_read_raw(struct iio_dev *indio_dev,
int addrind;
switch (mask) {
- case 0:
+ case IIO_CHAN_INFO_RAW:
mutex_lock(&indio_dev->mlock);
addr = adis16204_addresses[chan->address][0];
ret = adis16204_spi_read_reg_16(indio_dev, addr, &val16);
@@ -381,10 +329,16 @@ static int adis16204_read_raw(struct iio_dev *indio_dev,
return IIO_VAL_INT_PLUS_MICRO;
case IIO_ACCEL:
*val = 0;
- if (chan->channel == 'x')
+ switch (chan->channel2) {
+ case IIO_MOD_X:
+ case IIO_MOD_ROOT_SUM_SQUARED_X_Y:
*val2 = 17125;
- else
+ break;
+ case IIO_MOD_Y:
+ case IIO_MOD_Z:
*val2 = 8407;
+ break;
+ }
return IIO_VAL_INT_PLUS_MICRO;
default:
return -EINVAL;
@@ -444,48 +398,96 @@ static int adis16204_write_raw(struct iio_dev *indio_dev,
}
static struct iio_chan_spec adis16204_channels[] = {
- IIO_CHAN(IIO_VOLTAGE, 0, 0, 0, "supply", 0, 0,
- IIO_CHAN_INFO_SCALE_SEPARATE_BIT,
- in_supply, ADIS16204_SCAN_SUPPLY,
- IIO_ST('u', 12, 16, 0), 0),
- IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 1, 0,
- IIO_CHAN_INFO_SCALE_SEPARATE_BIT,
- in_aux, ADIS16204_SCAN_AUX_ADC,
- IIO_ST('u', 12, 16, 0), 0),
- IIO_CHAN(IIO_TEMP, 0, 1, 0, NULL, 0, 0,
- IIO_CHAN_INFO_SCALE_SEPARATE_BIT |
- IIO_CHAN_INFO_OFFSET_SEPARATE_BIT,
- temp, ADIS16204_SCAN_TEMP,
- IIO_ST('u', 12, 16, 0), 0),
- IIO_CHAN(IIO_ACCEL, 1, 0, 0, NULL, 0, IIO_MOD_X,
- IIO_CHAN_INFO_SCALE_SEPARATE_BIT |
- IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT |
- IIO_CHAN_INFO_PEAK_SEPARATE_BIT,
- accel_x, ADIS16204_SCAN_ACC_X,
- IIO_ST('s', 14, 16, 0), 0),
- IIO_CHAN(IIO_ACCEL, 1, 0, 0, NULL, 0, IIO_MOD_Y,
- IIO_CHAN_INFO_SCALE_SEPARATE_BIT |
- IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT |
- IIO_CHAN_INFO_PEAK_SEPARATE_BIT,
- accel_y, ADIS16204_SCAN_ACC_Y,
- IIO_ST('s', 14, 16, 0), 0),
+ {
+ .type = IIO_VOLTAGE,
+ .indexed = 1, /* Note was not previously indexed */
+ .channel = 0,
+ .extend_name = "supply",
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
+ IIO_CHAN_INFO_SCALE_SEPARATE_BIT,
+ .address = in_supply,
+ .scan_index = ADIS16204_SCAN_SUPPLY,
+ .scan_type = {
+ .sign = 'u',
+ .realbits = 12,
+ .storagebits = 16,
+ },
+ }, {
+ .type = IIO_VOLTAGE,
+ .indexed = 1,
+ .channel = 1,
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
+ IIO_CHAN_INFO_SCALE_SEPARATE_BIT,
+ .address = in_aux,
+ .scan_index = ADIS16204_SCAN_AUX_ADC,
+ .scan_type = {
+ .sign = 'u',
+ .realbits = 12,
+ .storagebits = 16,
+ },
+ }, {
+ .type = IIO_TEMP,
+ .indexed = 1,
+ .channel = 0,
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
+ IIO_CHAN_INFO_SCALE_SEPARATE_BIT |
+ IIO_CHAN_INFO_OFFSET_SEPARATE_BIT,
+ .address = temp,
+ .scan_index = ADIS16204_SCAN_TEMP,
+ .scan_type = {
+ .sign = 'u',
+ .realbits = 12,
+ .storagebits = 16,
+ },
+ }, {
+ .type = IIO_ACCEL,
+ .modified = 1,
+ .channel2 = IIO_MOD_X,
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
+ IIO_CHAN_INFO_SCALE_SEPARATE_BIT |
+ IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT |
+ IIO_CHAN_INFO_PEAK_SEPARATE_BIT,
+ .address = accel_x,
+ .scan_index = ADIS16204_SCAN_ACC_X,
+ .scan_type = {
+ .sign = 's',
+ .realbits = 14,
+ .storagebits = 16,
+ },
+ }, {
+ .type = IIO_ACCEL,
+ .modified = 1,
+ .channel2 = IIO_MOD_Y,
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
+ IIO_CHAN_INFO_SCALE_SEPARATE_BIT |
+ IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT |
+ IIO_CHAN_INFO_PEAK_SEPARATE_BIT,
+ .address = accel_y,
+ .scan_index = ADIS16204_SCAN_ACC_Y,
+ .scan_type = {
+ .sign = 's',
+ .realbits = 14,
+ .storagebits = 16,
+ },
+ },
IIO_CHAN_SOFT_TIMESTAMP(5),
-};
-
-static struct attribute *adis16204_attributes[] = {
- &iio_dev_attr_reset.dev_attr.attr,
- &iio_dev_attr_in_accel_xy.dev_attr.attr,
- &iio_dev_attr_in_accel_xypeak.dev_attr.attr,
- &iio_const_attr_in_accel_xy_scale.dev_attr.attr,
- NULL
-};
-
-static const struct attribute_group adis16204_attribute_group = {
- .attrs = adis16204_attributes,
+ {
+ .type = IIO_ACCEL,
+ .modified = 1,
+ .channel2 = IIO_MOD_ROOT_SUM_SQUARED_X_Y,
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
+ IIO_CHAN_INFO_SCALE_SEPARATE_BIT |
+ IIO_CHAN_INFO_PEAK_SEPARATE_BIT,
+ .address = accel_xy,
+ .scan_type = {
+ .sign = 'u',
+ .realbits = 14,
+ .storagebits = 16,
+ },
+ }
};
static const struct iio_info adis16204_info = {
- .attrs = &adis16204_attribute_group,
.read_raw = &adis16204_read_raw,
.write_raw = &adis16204_write_raw,
.driver_module = THIS_MODULE,
@@ -498,7 +500,7 @@ static int __devinit adis16204_probe(struct spi_device *spi)
struct iio_dev *indio_dev;
/* setup the industrialio driver allocated elements */
- indio_dev = iio_allocate_device(sizeof(*st));
+ indio_dev = iio_device_alloc(sizeof(*st));
if (indio_dev == NULL) {
ret = -ENOMEM;
goto error_ret;
@@ -522,7 +524,7 @@ static int __devinit adis16204_probe(struct spi_device *spi)
ret = iio_buffer_register(indio_dev,
adis16204_channels,
- ARRAY_SIZE(adis16204_channels));
+ 6);
if (ret) {
printk(KERN_ERR "failed to initialize the ring\n");
goto error_unreg_ring_funcs;
@@ -551,7 +553,7 @@ error_uninitialize_ring:
error_unreg_ring_funcs:
adis16204_unconfigure_ring(indio_dev);
error_free_dev:
- iio_free_device(indio_dev);
+ iio_device_free(indio_dev);
error_ret:
return ret;
}
@@ -564,7 +566,7 @@ static int adis16204_remove(struct spi_device *spi)
adis16204_remove_trigger(indio_dev);
iio_buffer_unregister(indio_dev);
adis16204_unconfigure_ring(indio_dev);
- iio_free_device(indio_dev);
+ iio_device_free(indio_dev);
return 0;
}
diff --git a/drivers/staging/iio/accel/adis16204_ring.c b/drivers/staging/iio/accel/adis16204_ring.c
index 5c8ab7338864..1d2b31cc849e 100644
--- a/drivers/staging/iio/accel/adis16204_ring.c
+++ b/drivers/staging/iio/accel/adis16204_ring.c
@@ -5,20 +5,19 @@
#include <linux/spi/spi.h>
#include <linux/slab.h>
-#include "../iio.h"
+#include <linux/iio/iio.h>
#include "../ring_sw.h"
-#include "../trigger_consumer.h"
+#include <linux/iio/trigger_consumer.h>
#include "adis16204.h"
/**
* adis16204_read_ring_data() read data registers which will be placed into ring
- * @dev: device associated with child of actual device (iio_dev or iio_trig)
+ * @indio_dev: the IIO device
* @rx: somewhere to pass back the value read
**/
-static int adis16204_read_ring_data(struct device *dev, u8 *rx)
+static int adis16204_read_ring_data(struct iio_dev *indio_dev, u8 *rx)
{
struct spi_message msg;
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
struct adis16204_state *st = iio_priv(indio_dev);
struct spi_transfer xfers[ADIS16204_OUTPUTS + 1];
int ret;
@@ -63,28 +62,28 @@ static irqreturn_t adis16204_trigger_handler(int irq, void *p)
struct iio_buffer *ring = indio_dev->buffer;
int i = 0;
s16 *data;
- size_t datasize = ring->access->get_bytes_per_datum(ring);
- data = kmalloc(datasize, GFP_KERNEL);
+ data = kmalloc(indio_dev->scan_bytes, GFP_KERNEL);
if (data == NULL) {
dev_err(&st->us->dev, "memory alloc failed in ring bh");
- return -ENOMEM;
+ goto done;
}
if (!bitmap_empty(indio_dev->active_scan_mask, indio_dev->masklength) &&
- adis16204_read_ring_data(&indio_dev->dev, st->rx) >= 0)
+ adis16204_read_ring_data(indio_dev, st->rx) >= 0)
for (; i < bitmap_weight(indio_dev->active_scan_mask,
indio_dev->masklength); i++)
data[i] = be16_to_cpup((__be16 *)&(st->rx[i*2]));
/* Guaranteed to be aligned with 8 byte boundary */
- if (ring->scan_timestamp)
+ if (indio_dev->scan_timestamp)
*((s64 *)(data + ((i + 3)/4)*4)) = pf->timestamp;
ring->access->store_to(ring, (u8 *)data, pf->timestamp);
- iio_trigger_notify_done(indio_dev->trig);
kfree(data);
+done:
+ iio_trigger_notify_done(indio_dev->trig);
return IRQ_HANDLED;
}
diff --git a/drivers/staging/iio/accel/adis16204_trigger.c b/drivers/staging/iio/accel/adis16204_trigger.c
index 6e542af02c09..408a1682368e 100644
--- a/drivers/staging/iio/accel/adis16204_trigger.c
+++ b/drivers/staging/iio/accel/adis16204_trigger.c
@@ -3,8 +3,8 @@
#include <linux/spi/spi.h>
#include <linux/export.h>
-#include "../iio.h"
-#include "../trigger.h"
+#include <linux/iio/iio.h>
+#include <linux/iio/trigger.h>
#include "adis16204.h"
/**
@@ -29,7 +29,7 @@ int adis16204_probe_trigger(struct iio_dev *indio_dev)
int ret;
struct adis16204_state *st = iio_priv(indio_dev);
- st->trig = iio_allocate_trigger("adis16204-dev%d", indio_dev->id);
+ st->trig = iio_trigger_alloc("adis16204-dev%d", indio_dev->id);
if (st->trig == NULL) {
ret = -ENOMEM;
goto error_ret;
@@ -58,7 +58,7 @@ int adis16204_probe_trigger(struct iio_dev *indio_dev)
error_free_irq:
free_irq(st->us->irq, st->trig);
error_free_trig:
- iio_free_trigger(st->trig);
+ iio_trigger_free(st->trig);
error_ret:
return ret;
}
@@ -69,5 +69,5 @@ void adis16204_remove_trigger(struct iio_dev *indio_dev)
iio_trigger_unregister(state->trig);
free_irq(state->us->irq, state->trig);
- iio_free_trigger(state->trig);
+ iio_trigger_free(state->trig);
}
diff --git a/drivers/staging/iio/accel/adis16209_core.c b/drivers/staging/iio/accel/adis16209_core.c
index a98715f6bd6d..494570508c36 100644
--- a/drivers/staging/iio/accel/adis16209_core.c
+++ b/drivers/staging/iio/accel/adis16209_core.c
@@ -16,9 +16,9 @@
#include <linux/list.h>
#include <linux/module.h>
-#include "../iio.h"
-#include "../sysfs.h"
-#include "../buffer.h"
+#include <linux/iio/iio.h>
+#include <linux/iio/sysfs.h>
+#include <linux/iio/buffer.h>
#include "adis16209.h"
@@ -153,23 +153,6 @@ static int adis16209_reset(struct iio_dev *indio_dev)
return ret;
}
-static ssize_t adis16209_write_reset(struct device *dev,
- struct device_attribute *attr,
- const char *buf, size_t len)
-{
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
-
- if (len < 1)
- return -EINVAL;
- switch (buf[0]) {
- case '1':
- case 'y':
- case 'Y':
- return adis16209_reset(indio_dev);
- }
- return -EINVAL;
-}
-
int adis16209_set_irq(struct iio_dev *indio_dev, bool enable)
{
int ret = 0;
@@ -331,7 +314,7 @@ static int adis16209_read_raw(struct iio_dev *indio_dev,
s16 val16;
switch (mask) {
- case 0:
+ case IIO_CHAN_INFO_RAW:
mutex_lock(&indio_dev->mlock);
addr = adis16209_addresses[chan->address][0];
ret = adis16209_spi_read_reg_16(indio_dev, addr, &val16);
@@ -408,57 +391,118 @@ static int adis16209_read_raw(struct iio_dev *indio_dev,
}
static struct iio_chan_spec adis16209_channels[] = {
- IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 0, 0,
- IIO_CHAN_INFO_SCALE_SEPARATE_BIT,
- in_supply, ADIS16209_SCAN_SUPPLY,
- IIO_ST('u', 14, 16, 0), 0),
- IIO_CHAN(IIO_TEMP, 0, 1, 0, NULL, 0, 0,
- IIO_CHAN_INFO_SCALE_SEPARATE_BIT |
- IIO_CHAN_INFO_OFFSET_SEPARATE_BIT,
- temp, ADIS16209_SCAN_TEMP,
- IIO_ST('u', 12, 16, 0), 0),
- IIO_CHAN(IIO_ACCEL, 1, 0, 0, NULL, 0, IIO_MOD_X,
- IIO_CHAN_INFO_SCALE_SHARED_BIT |
- IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT,
- accel_x, ADIS16209_SCAN_ACC_X,
- IIO_ST('s', 14, 16, 0), 0),
- IIO_CHAN(IIO_ACCEL, 1, 0, 0, NULL, 0, IIO_MOD_Y,
- IIO_CHAN_INFO_SCALE_SHARED_BIT |
- IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT,
- accel_y, ADIS16209_SCAN_ACC_Y,
- IIO_ST('s', 14, 16, 0), 0),
- IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 1, 0,
- IIO_CHAN_INFO_SCALE_SEPARATE_BIT,
- in_aux, ADIS16209_SCAN_AUX_ADC,
- IIO_ST('u', 12, 16, 0), 0),
- IIO_CHAN(IIO_INCLI, 1, 0, 0, NULL, 0, IIO_MOD_X,
- IIO_CHAN_INFO_SCALE_SHARED_BIT,
- incli_x, ADIS16209_SCAN_INCLI_X,
- IIO_ST('s', 14, 16, 0), 0),
- IIO_CHAN(IIO_INCLI, 1, 0, 0, NULL, 0, IIO_MOD_Y,
- IIO_CHAN_INFO_SCALE_SHARED_BIT,
- incli_y, ADIS16209_SCAN_INCLI_Y,
- IIO_ST('s', 14, 16, 0), 0),
- IIO_CHAN(IIO_ROT, 0, 1, 0, NULL, 0, IIO_MOD_X,
- 0,
- rot, ADIS16209_SCAN_ROT,
- IIO_ST('s', 14, 16, 0), 0),
+ {
+ .type = IIO_VOLTAGE,
+ .indexed = 1,
+ .channel = 0,
+ .extend_name = "supply",
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
+ IIO_CHAN_INFO_SCALE_SEPARATE_BIT,
+ .address = in_supply,
+ .scan_index = ADIS16209_SCAN_SUPPLY,
+ .scan_type = {
+ .sign = 'u',
+ .realbits = 14,
+ .storagebits = 16,
+ },
+ }, {
+ .type = IIO_TEMP,
+ .indexed = 0,
+ .channel = 0,
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
+ IIO_CHAN_INFO_SCALE_SEPARATE_BIT |
+ IIO_CHAN_INFO_OFFSET_SEPARATE_BIT,
+ .address = temp,
+ .scan_index = ADIS16209_SCAN_TEMP,
+ .scan_type = {
+ .sign = 'u',
+ .realbits = 12,
+ .storagebits = 16,
+ },
+ }, {
+ .type = IIO_ACCEL,
+ .modified = 1,
+ .channel2 = IIO_MOD_X,
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
+ IIO_CHAN_INFO_SCALE_SHARED_BIT |
+ IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT,
+ .address = accel_x,
+ .scan_index = ADIS16209_SCAN_ACC_X,
+ .scan_type = {
+ .sign = 's',
+ .realbits = 14,
+ .storagebits = 16,
+ },
+ }, {
+ .type = IIO_ACCEL,
+ .modified = 1,
+ .channel2 = IIO_MOD_Y,
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
+ IIO_CHAN_INFO_SCALE_SHARED_BIT |
+ IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT,
+ .address = accel_y,
+ .scan_index = ADIS16209_SCAN_ACC_Y,
+ .scan_type = {
+ .sign = 's',
+ .realbits = 14,
+ .storagebits = 16,
+ },
+ }, {
+ .type = IIO_VOLTAGE,
+ .indexed = 1,
+ .channel = 1,
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
+ IIO_CHAN_INFO_SCALE_SEPARATE_BIT,
+ .address = in_aux,
+ .scan_index = ADIS16209_SCAN_AUX_ADC,
+ .scan_type = {
+ .sign = 'u',
+ .realbits = 12,
+ .storagebits = 16,
+ },
+ }, {
+ .type = IIO_INCLI,
+ .modified = 1,
+ .channel2 = IIO_MOD_X,
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
+ IIO_CHAN_INFO_SCALE_SHARED_BIT,
+ .address = incli_x,
+ .scan_index = ADIS16209_SCAN_INCLI_X,
+ .scan_type = {
+ .sign = 's',
+ .realbits = 14,
+ .storagebits = 16,
+ },
+ }, {
+ .type = IIO_INCLI,
+ .modified = 1,
+ .channel2 = IIO_MOD_Y,
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
+ IIO_CHAN_INFO_SCALE_SHARED_BIT,
+ .address = incli_y,
+ .scan_index = ADIS16209_SCAN_INCLI_Y,
+ .scan_type = {
+ .sign = 's',
+ .realbits = 14,
+ .storagebits = 16,
+ },
+ }, {
+ .type = IIO_ROT,
+ .modified = 1,
+ .channel2 = IIO_MOD_X,
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT,
+ .address = rot,
+ .scan_index = ADIS16209_SCAN_ROT,
+ .scan_type = {
+ .sign = 's',
+ .realbits = 14,
+ .storagebits = 16,
+ },
+ },
IIO_CHAN_SOFT_TIMESTAMP(8)
};
-static IIO_DEVICE_ATTR(reset, S_IWUSR, NULL, adis16209_write_reset, 0);
-
-static struct attribute *adis16209_attributes[] = {
- &iio_dev_attr_reset.dev_attr.attr,
- NULL
-};
-
-static const struct attribute_group adis16209_attribute_group = {
- .attrs = adis16209_attributes,
-};
-
static const struct iio_info adis16209_info = {
- .attrs = &adis16209_attribute_group,
.read_raw = &adis16209_read_raw,
.write_raw = &adis16209_write_raw,
.driver_module = THIS_MODULE,
@@ -471,7 +515,7 @@ static int __devinit adis16209_probe(struct spi_device *spi)
struct iio_dev *indio_dev;
/* setup the industrialio driver allocated elements */
- indio_dev = iio_allocate_device(sizeof(*st));
+ indio_dev = iio_device_alloc(sizeof(*st));
if (indio_dev == NULL) {
ret = -ENOMEM;
goto error_ret;
@@ -524,7 +568,7 @@ error_uninitialize_ring:
error_unreg_ring_funcs:
adis16209_unconfigure_ring(indio_dev);
error_free_dev:
- iio_free_device(indio_dev);
+ iio_device_free(indio_dev);
error_ret:
return ret;
}
@@ -533,13 +577,11 @@ static int adis16209_remove(struct spi_device *spi)
{
struct iio_dev *indio_dev = spi_get_drvdata(spi);
- flush_scheduled_work();
-
iio_device_unregister(indio_dev);
adis16209_remove_trigger(indio_dev);
iio_buffer_unregister(indio_dev);
adis16209_unconfigure_ring(indio_dev);
- iio_free_device(indio_dev);
+ iio_device_free(indio_dev);
return 0;
}
diff --git a/drivers/staging/iio/accel/adis16209_ring.c b/drivers/staging/iio/accel/adis16209_ring.c
index 57254b6b38b7..1a4a55c27c7c 100644
--- a/drivers/staging/iio/accel/adis16209_ring.c
+++ b/drivers/staging/iio/accel/adis16209_ring.c
@@ -5,20 +5,19 @@
#include <linux/spi/spi.h>
#include <linux/slab.h>
-#include "../iio.h"
+#include <linux/iio/iio.h>
#include "../ring_sw.h"
-#include "../trigger_consumer.h"
+#include <linux/iio/trigger_consumer.h>
#include "adis16209.h"
/**
* adis16209_read_ring_data() read data registers which will be placed into ring
- * @dev: device associated with child of actual device (iio_dev or iio_trig)
+ * @indio_dev: the IIO device
* @rx: somewhere to pass back the value read
**/
-static int adis16209_read_ring_data(struct device *dev, u8 *rx)
+static int adis16209_read_ring_data(struct iio_dev *indio_dev, u8 *rx)
{
struct spi_message msg;
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
struct adis16209_state *st = iio_priv(indio_dev);
struct spi_transfer xfers[ADIS16209_OUTPUTS + 1];
int ret;
@@ -61,31 +60,30 @@ static irqreturn_t adis16209_trigger_handler(int irq, void *p)
struct iio_dev *indio_dev = pf->indio_dev;
struct adis16209_state *st = iio_priv(indio_dev);
struct iio_buffer *ring = indio_dev->buffer;
-
int i = 0;
s16 *data;
- size_t datasize = ring->access->get_bytes_per_datum(ring);
- data = kmalloc(datasize , GFP_KERNEL);
+ data = kmalloc(indio_dev->scan_bytes, GFP_KERNEL);
if (data == NULL) {
dev_err(&st->us->dev, "memory alloc failed in ring bh");
- return -ENOMEM;
+ goto done;
}
if (!bitmap_empty(indio_dev->active_scan_mask, indio_dev->masklength) &&
- adis16209_read_ring_data(&indio_dev->dev, st->rx) >= 0)
+ adis16209_read_ring_data(indio_dev, st->rx) >= 0)
for (; i < bitmap_weight(indio_dev->active_scan_mask,
indio_dev->masklength); i++)
data[i] = be16_to_cpup((__be16 *)&(st->rx[i*2]));
/* Guaranteed to be aligned with 8 byte boundary */
- if (ring->scan_timestamp)
+ if (indio_dev->scan_timestamp)
*((s64 *)(data + ((i + 3)/4)*4)) = pf->timestamp;
ring->access->store_to(ring, (u8 *)data, pf->timestamp);
- iio_trigger_notify_done(indio_dev->trig);
kfree(data);
+done:
+ iio_trigger_notify_done(indio_dev->trig);
return IRQ_HANDLED;
}
diff --git a/drivers/staging/iio/accel/adis16209_trigger.c b/drivers/staging/iio/accel/adis16209_trigger.c
index c5d82c1a55d9..2ad93dcaf40d 100644
--- a/drivers/staging/iio/accel/adis16209_trigger.c
+++ b/drivers/staging/iio/accel/adis16209_trigger.c
@@ -3,8 +3,8 @@
#include <linux/spi/spi.h>
#include <linux/export.h>
-#include "../iio.h"
-#include "../trigger.h"
+#include <linux/iio/iio.h>
+#include <linux/iio/trigger.h>
#include "adis16209.h"
/**
@@ -38,7 +38,7 @@ int adis16209_probe_trigger(struct iio_dev *indio_dev)
int ret;
struct adis16209_state *st = iio_priv(indio_dev);
- st->trig = iio_allocate_trigger("adis16209-dev%d", indio_dev->id);
+ st->trig = iio_trigger_alloc("adis16209-dev%d", indio_dev->id);
if (st->trig == NULL) {
ret = -ENOMEM;
goto error_ret;
@@ -66,7 +66,7 @@ int adis16209_probe_trigger(struct iio_dev *indio_dev)
error_free_irq:
free_irq(st->us->irq, st->trig);
error_free_trig:
- iio_free_trigger(st->trig);
+ iio_trigger_free(st->trig);
error_ret:
return ret;
}
@@ -77,5 +77,5 @@ void adis16209_remove_trigger(struct iio_dev *indio_dev)
iio_trigger_unregister(st->trig);
free_irq(st->us->irq, st->trig);
- iio_free_trigger(st->trig);
+ iio_trigger_free(st->trig);
}
diff --git a/drivers/staging/iio/accel/adis16220_core.c b/drivers/staging/iio/accel/adis16220_core.c
index 51a852d45482..575f1af25d5d 100644
--- a/drivers/staging/iio/accel/adis16220_core.c
+++ b/drivers/staging/iio/accel/adis16220_core.c
@@ -15,8 +15,8 @@
#include <linux/sysfs.h>
#include <linux/module.h>
-#include "../iio.h"
-#include "../sysfs.h"
+#include <linux/iio/iio.h>
+#include <linux/iio/sysfs.h>
#include "adis16220.h"
@@ -145,7 +145,7 @@ static ssize_t adis16220_read_16bit(struct device *dev,
char *buf)
{
struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
ssize_t ret;
s16 val = 0;
@@ -164,7 +164,7 @@ static ssize_t adis16220_write_16bit(struct device *dev,
const char *buf,
size_t len)
{
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
int ret;
u16 val;
@@ -204,31 +204,11 @@ static int adis16220_reset(struct iio_dev *indio_dev)
return ret;
}
-static ssize_t adis16220_write_reset(struct device *dev,
- struct device_attribute *attr,
- const char *buf, size_t len)
-{
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
- bool val;
- int ret;
-
- ret = strtobool(buf, &val);
- if (ret)
- return ret;
- if (!val)
- return -EINVAL;
-
- ret = adis16220_reset(indio_dev);
- if (ret)
- return ret;
- return len;
-}
-
static ssize_t adis16220_write_capture(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t len)
{
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
bool val;
int ret;
@@ -393,7 +373,7 @@ static ssize_t adis16220_accel_bin_read(struct file *filp, struct kobject *kobj,
size_t count)
{
struct device *dev = container_of(kobj, struct device, kobj);
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
return adis16220_capture_buffer_read(indio_dev, buf,
off, count,
@@ -415,7 +395,7 @@ static ssize_t adis16220_adc1_bin_read(struct file *filp, struct kobject *kobj,
size_t count)
{
struct device *dev = container_of(kobj, struct device, kobj);
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
return adis16220_capture_buffer_read(indio_dev, buf,
off, count,
@@ -437,7 +417,7 @@ static ssize_t adis16220_adc2_bin_read(struct file *filp, struct kobject *kobj,
size_t count)
{
struct device *dev = container_of(kobj, struct device, kobj);
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
return adis16220_capture_buffer_read(indio_dev, buf,
off, count,
@@ -454,9 +434,6 @@ static struct bin_attribute adc2_bin = {
.size = ADIS16220_CAPTURE_SIZE,
};
-static IIO_DEVICE_ATTR(reset, S_IWUSR, NULL,
- adis16220_write_reset, 0);
-
#define IIO_DEV_ATTR_CAPTURE(_store) \
IIO_DEVICE_ATTR(capture, S_IWUSR, NULL, _store, 0)
@@ -507,7 +484,7 @@ static int adis16220_read_raw(struct iio_dev *indio_dev,
u8 bits;
switch (mask) {
- case 0:
+ case IIO_CHAN_INFO_RAW:
addrind = 0;
break;
case IIO_CHAN_INFO_OFFSET:
@@ -575,11 +552,13 @@ static const struct iio_chan_spec adis16220_channels[] = {
.indexed = 1,
.channel = 0,
.extend_name = "supply",
- .info_mask = IIO_CHAN_INFO_SCALE_SEPARATE_BIT,
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
+ IIO_CHAN_INFO_SCALE_SEPARATE_BIT,
.address = in_supply,
}, {
.type = IIO_ACCEL,
- .info_mask = IIO_CHAN_INFO_OFFSET_SEPARATE_BIT |
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
+ IIO_CHAN_INFO_OFFSET_SEPARATE_BIT |
IIO_CHAN_INFO_SCALE_SEPARATE_BIT |
IIO_CHAN_INFO_PEAK_SEPARATE_BIT,
.address = accel,
@@ -587,26 +566,28 @@ static const struct iio_chan_spec adis16220_channels[] = {
.type = IIO_TEMP,
.indexed = 1,
.channel = 0,
- .info_mask = IIO_CHAN_INFO_OFFSET_SEPARATE_BIT |
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
+ IIO_CHAN_INFO_OFFSET_SEPARATE_BIT |
IIO_CHAN_INFO_SCALE_SEPARATE_BIT,
.address = temp,
}, {
.type = IIO_VOLTAGE,
.indexed = 1,
.channel = 1,
- .info_mask = IIO_CHAN_INFO_OFFSET_SEPARATE_BIT |
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
+ IIO_CHAN_INFO_OFFSET_SEPARATE_BIT |
IIO_CHAN_INFO_SCALE_SEPARATE_BIT,
.address = in_1,
}, {
.type = IIO_VOLTAGE,
.indexed = 1,
.channel = 2,
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT,
.address = in_2,
}
};
static struct attribute *adis16220_attributes[] = {
- &iio_dev_attr_reset.dev_attr.attr,
&iio_dev_attr_capture.dev_attr.attr,
&iio_dev_attr_capture_count.dev_attr.attr,
NULL
@@ -629,7 +610,7 @@ static int __devinit adis16220_probe(struct spi_device *spi)
struct iio_dev *indio_dev;
/* setup the industrialio driver allocated elements */
- indio_dev = iio_allocate_device(sizeof(*st));
+ indio_dev = iio_device_alloc(sizeof(*st));
if (indio_dev == NULL) {
ret = -ENOMEM;
goto error_ret;
@@ -680,7 +661,7 @@ error_rm_accel_bin:
error_unregister_dev:
iio_device_unregister(indio_dev);
error_free_dev:
- iio_free_device(indio_dev);
+ iio_device_free(indio_dev);
error_ret:
return ret;
}
@@ -689,13 +670,11 @@ static int adis16220_remove(struct spi_device *spi)
{
struct iio_dev *indio_dev = spi_get_drvdata(spi);
- flush_scheduled_work();
-
sysfs_remove_bin_file(&indio_dev->dev.kobj, &adc2_bin);
sysfs_remove_bin_file(&indio_dev->dev.kobj, &adc1_bin);
sysfs_remove_bin_file(&indio_dev->dev.kobj, &accel_bin);
iio_device_unregister(indio_dev);
- iio_free_device(indio_dev);
+ iio_device_free(indio_dev);
return 0;
}
diff --git a/drivers/staging/iio/accel/adis16240_core.c b/drivers/staging/iio/accel/adis16240_core.c
index 17f77fef7f2b..b30b7874ffb0 100644
--- a/drivers/staging/iio/accel/adis16240_core.c
+++ b/drivers/staging/iio/accel/adis16240_core.c
@@ -19,9 +19,9 @@
#include <linux/list.h>
#include <linux/module.h>
-#include "../iio.h"
-#include "../sysfs.h"
-#include "../buffer.h"
+#include <linux/iio/iio.h>
+#include <linux/iio/sysfs.h>
+#include <linux/iio/buffer.h>
#include "adis16240.h"
@@ -154,7 +154,7 @@ static ssize_t adis16240_spi_read_signed(struct device *dev,
char *buf,
unsigned bits)
{
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
int ret;
s16 val = 0;
unsigned shift = 16 - bits;
@@ -177,7 +177,7 @@ static ssize_t adis16240_read_12bit_signed(struct device *dev,
char *buf)
{
ssize_t ret;
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
/* Take the iio_dev status lock */
mutex_lock(&indio_dev->mlock);
@@ -199,23 +199,6 @@ static int adis16240_reset(struct iio_dev *indio_dev)
return ret;
}
-static ssize_t adis16240_write_reset(struct device *dev,
- struct device_attribute *attr,
- const char *buf, size_t len)
-{
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
-
- if (len < 1)
- return -EINVAL;
- switch (buf[0]) {
- case '1':
- case 'y':
- case 'Y':
- return adis16240_reset(indio_dev);
- }
- return -EINVAL;
-}
-
int adis16240_set_irq(struct iio_dev *indio_dev, bool enable)
{
int ret = 0;
@@ -329,8 +312,6 @@ static IIO_DEVICE_ATTR(in_accel_xyz_squared_peak_raw, S_IRUGO,
adis16240_read_12bit_signed, NULL,
ADIS16240_XYZPEAK_OUT);
-static IIO_DEVICE_ATTR(reset, S_IWUSR, NULL, adis16240_write_reset, 0);
-
static IIO_CONST_ATTR_SAMP_FREQ_AVAIL("4096");
enum adis16240_chan {
@@ -365,7 +346,7 @@ static int adis16240_read_raw(struct iio_dev *indio_dev,
s16 val16;
switch (mask) {
- case 0:
+ case IIO_CHAN_INFO_RAW:
mutex_lock(&indio_dev->mlock);
addr = adis16240_addresses[chan->address][0];
ret = adis16240_spi_read_reg_16(indio_dev, addr, &val16);
@@ -468,40 +449,97 @@ static int adis16240_write_raw(struct iio_dev *indio_dev,
}
static struct iio_chan_spec adis16240_channels[] = {
- IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, "supply", 0, 0,
- IIO_CHAN_INFO_SCALE_SEPARATE_BIT,
- in_supply, ADIS16240_SCAN_SUPPLY,
- IIO_ST('u', 10, 16, 0), 0),
- IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 1, 0,
- 0,
- in_aux, ADIS16240_SCAN_AUX_ADC,
- IIO_ST('u', 10, 16, 0), 0),
- IIO_CHAN(IIO_ACCEL, 1, 0, 0, NULL, 0, IIO_MOD_X,
- IIO_CHAN_INFO_SCALE_SHARED_BIT |
- IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT,
- accel_x, ADIS16240_SCAN_ACC_X,
- IIO_ST('s', 10, 16, 0), 0),
- IIO_CHAN(IIO_ACCEL, 1, 0, 0, NULL, 0, IIO_MOD_Y,
- IIO_CHAN_INFO_SCALE_SHARED_BIT |
- IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT,
- accel_y, ADIS16240_SCAN_ACC_Y,
- IIO_ST('s', 10, 16, 0), 0),
- IIO_CHAN(IIO_ACCEL, 1, 0, 0, NULL, 0, IIO_MOD_Z,
- IIO_CHAN_INFO_SCALE_SHARED_BIT |
- IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT,
- accel_z, ADIS16240_SCAN_ACC_Z,
- IIO_ST('s', 10, 16, 0), 0),
- IIO_CHAN(IIO_TEMP, 0, 1, 0, NULL, 0, 0,
- IIO_CHAN_INFO_SCALE_SEPARATE_BIT,
- temp, ADIS16240_SCAN_TEMP,
- IIO_ST('u', 10, 16, 0), 0),
+ {
+ .type = IIO_VOLTAGE,
+ .indexed = 1,
+ .channel = 0,
+ .extend_name = "supply",
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
+ IIO_CHAN_INFO_SCALE_SEPARATE_BIT,
+ .address = in_supply,
+ .scan_index = ADIS16240_SCAN_SUPPLY,
+ .scan_type = {
+ .sign = 'u',
+ .realbits = 10,
+ .storagebits = 16,
+ },
+ }, {
+ .type = IIO_VOLTAGE,
+ .indexed = 1,
+ .channel = 1,
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT,
+ .address = in_aux,
+ .scan_index = ADIS16240_SCAN_AUX_ADC,
+ .scan_type = {
+ .sign = 'u',
+ .realbits = 10,
+ .storagebits = 16,
+ },
+ }, {
+ .type = IIO_ACCEL,
+ .modified = 1,
+ .channel2 = IIO_MOD_X,
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
+ IIO_CHAN_INFO_SCALE_SHARED_BIT |
+ IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT |
+ IIO_CHAN_INFO_PEAK_SEPARATE_BIT,
+ .address = accel_x,
+ .scan_index = ADIS16240_SCAN_ACC_X,
+ .scan_type = {
+ .sign = 's',
+ .realbits = 10,
+ .storagebits = 16,
+ },
+ }, {
+ .type = IIO_ACCEL,
+ .modified = 1,
+ .channel2 = IIO_MOD_Y,
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
+ IIO_CHAN_INFO_SCALE_SHARED_BIT |
+ IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT |
+ IIO_CHAN_INFO_PEAK_SEPARATE_BIT,
+ .address = accel_y,
+ .scan_index = ADIS16240_SCAN_ACC_Y,
+ .scan_type = {
+ .sign = 's',
+ .realbits = 10,
+ .storagebits = 16,
+ },
+ }, {
+ .type = IIO_ACCEL,
+ .modified = 1,
+ .channel2 = IIO_MOD_Z,
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
+ IIO_CHAN_INFO_SCALE_SHARED_BIT |
+ IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT |
+ IIO_CHAN_INFO_PEAK_SEPARATE_BIT,
+ .address = accel_z,
+ .scan_index = ADIS16240_SCAN_ACC_Z,
+ .scan_type = {
+ .sign = 's',
+ .realbits = 10,
+ .storagebits = 16,
+ },
+ }, {
+ .type = IIO_TEMP,
+ .indexed = 1,
+ .channel = 0,
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
+ IIO_CHAN_INFO_SCALE_SEPARATE_BIT,
+ .address = temp,
+ .scan_index = ADIS16240_SCAN_TEMP,
+ .scan_type = {
+ .sign = 'u',
+ .realbits = 10,
+ .storagebits = 16,
+ },
+ },
IIO_CHAN_SOFT_TIMESTAMP(6)
};
static struct attribute *adis16240_attributes[] = {
&iio_dev_attr_in_accel_xyz_squared_peak_raw.dev_attr.attr,
&iio_const_attr_sampling_frequency_available.dev_attr.attr,
- &iio_dev_attr_reset.dev_attr.attr,
NULL
};
@@ -523,7 +561,7 @@ static int __devinit adis16240_probe(struct spi_device *spi)
struct iio_dev *indio_dev;
/* setup the industrialio driver allocated elements */
- indio_dev = iio_allocate_device(sizeof(*st));
+ indio_dev = iio_device_alloc(sizeof(*st));
if (indio_dev == NULL) {
ret = -ENOMEM;
goto error_ret;
@@ -576,7 +614,7 @@ error_uninitialize_ring:
error_unreg_ring_funcs:
adis16240_unconfigure_ring(indio_dev);
error_free_dev:
- iio_free_device(indio_dev);
+ iio_device_free(indio_dev);
error_ret:
return ret;
}
@@ -586,13 +624,11 @@ static int adis16240_remove(struct spi_device *spi)
struct iio_dev *indio_dev = spi_get_drvdata(spi);
- flush_scheduled_work();
-
iio_device_unregister(indio_dev);
adis16240_remove_trigger(indio_dev);
iio_buffer_unregister(indio_dev);
adis16240_unconfigure_ring(indio_dev);
- iio_free_device(indio_dev);
+ iio_device_free(indio_dev);
return 0;
}
diff --git a/drivers/staging/iio/accel/adis16240_ring.c b/drivers/staging/iio/accel/adis16240_ring.c
index 43ba84e993ad..360dfed6d4d1 100644
--- a/drivers/staging/iio/accel/adis16240_ring.c
+++ b/drivers/staging/iio/accel/adis16240_ring.c
@@ -5,20 +5,19 @@
#include <linux/spi/spi.h>
#include <linux/slab.h>
-#include "../iio.h"
+#include <linux/iio/iio.h>
#include "../ring_sw.h"
-#include "../trigger_consumer.h"
+#include <linux/iio/trigger_consumer.h>
#include "adis16240.h"
/**
* adis16240_read_ring_data() read data registers which will be placed into ring
- * @dev: device associated with child of actual device (iio_dev or iio_trig)
+ * @indio_dev: the IIO device
* @rx: somewhere to pass back the value read
**/
-static int adis16240_read_ring_data(struct device *dev, u8 *rx)
+static int adis16240_read_ring_data(struct iio_dev *indio_dev, u8 *rx)
{
struct spi_message msg;
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
struct adis16240_state *st = iio_priv(indio_dev);
struct spi_transfer xfers[ADIS16240_OUTPUTS + 1];
int ret;
@@ -61,28 +60,28 @@ static irqreturn_t adis16240_trigger_handler(int irq, void *p)
int i = 0;
s16 *data;
- size_t datasize = ring->access->get_bytes_per_datum(ring);
- data = kmalloc(datasize, GFP_KERNEL);
+ data = kmalloc(indio_dev->scan_bytes, GFP_KERNEL);
if (data == NULL) {
dev_err(&st->us->dev, "memory alloc failed in ring bh");
- return -ENOMEM;
+ goto done;
}
if (!bitmap_empty(indio_dev->active_scan_mask, indio_dev->masklength) &&
- adis16240_read_ring_data(&indio_dev->dev, st->rx) >= 0)
+ adis16240_read_ring_data(indio_dev, st->rx) >= 0)
for (; i < bitmap_weight(indio_dev->active_scan_mask,
indio_dev->masklength); i++)
data[i] = be16_to_cpup((__be16 *)&(st->rx[i*2]));
/* Guaranteed to be aligned with 8 byte boundary */
- if (ring->scan_timestamp)
+ if (indio_dev->scan_timestamp)
*((s64 *)(data + ((i + 3)/4)*4)) = pf->timestamp;
ring->access->store_to(ring, (u8 *)data, pf->timestamp);
- iio_trigger_notify_done(indio_dev->trig);
kfree(data);
+done:
+ iio_trigger_notify_done(indio_dev->trig);
return IRQ_HANDLED;
}
diff --git a/drivers/staging/iio/accel/adis16240_trigger.c b/drivers/staging/iio/accel/adis16240_trigger.c
index 8e0ce568e64c..fa90a22b143e 100644
--- a/drivers/staging/iio/accel/adis16240_trigger.c
+++ b/drivers/staging/iio/accel/adis16240_trigger.c
@@ -3,8 +3,8 @@
#include <linux/spi/spi.h>
#include <linux/export.h>
-#include "../iio.h"
-#include "../trigger.h"
+#include <linux/iio/iio.h>
+#include <linux/iio/trigger.h>
#include "adis16240.h"
/**
@@ -38,7 +38,7 @@ int adis16240_probe_trigger(struct iio_dev *indio_dev)
int ret;
struct adis16240_state *st = iio_priv(indio_dev);
- st->trig = iio_allocate_trigger("adis16240-dev%d", indio_dev->id);
+ st->trig = iio_trigger_alloc("adis16240-dev%d", indio_dev->id);
if (st->trig == NULL) {
ret = -ENOMEM;
goto error_ret;
@@ -67,7 +67,7 @@ int adis16240_probe_trigger(struct iio_dev *indio_dev)
error_free_irq:
free_irq(st->us->irq, st->trig);
error_free_trig:
- iio_free_trigger(st->trig);
+ iio_trigger_free(st->trig);
error_ret:
return ret;
}
@@ -78,5 +78,5 @@ void adis16240_remove_trigger(struct iio_dev *indio_dev)
iio_trigger_unregister(st->trig);
free_irq(st->us->irq, st->trig);
- iio_free_trigger(st->trig);
+ iio_trigger_free(st->trig);
}
diff --git a/drivers/staging/iio/accel/kxsd9.c b/drivers/staging/iio/accel/kxsd9.c
index d13d7215ff6e..8cf7cd943c90 100644
--- a/drivers/staging/iio/accel/kxsd9.c
+++ b/drivers/staging/iio/accel/kxsd9.c
@@ -23,8 +23,8 @@
#include <linux/slab.h>
#include <linux/module.h>
-#include "../iio.h"
-#include "../sysfs.h"
+#include <linux/iio/iio.h>
+#include <linux/iio/sysfs.h>
#define KXSD9_REG_X 0x00
#define KXSD9_REG_Y 0x02
@@ -158,7 +158,7 @@ static int kxsd9_read_raw(struct iio_dev *indio_dev,
struct kxsd9_state *st = iio_priv(indio_dev);
switch (mask) {
- case 0:
+ case IIO_CHAN_INFO_RAW:
ret = kxsd9_read(indio_dev, chan->address);
if (ret < 0)
goto error_ret;
@@ -181,7 +181,8 @@ error_ret:
.type = IIO_ACCEL, \
.modified = 1, \
.channel2 = IIO_MOD_##axis, \
- .info_mask = IIO_CHAN_INFO_SCALE_SHARED_BIT, \
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT | \
+ IIO_CHAN_INFO_SCALE_SHARED_BIT, \
.address = KXSD9_REG_##axis, \
}
@@ -189,6 +190,7 @@ static struct iio_chan_spec kxsd9_channels[] = {
KXSD9_ACCEL_CHAN(X), KXSD9_ACCEL_CHAN(Y), KXSD9_ACCEL_CHAN(Z),
{
.type = IIO_VOLTAGE,
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT,
.indexed = 1,
.address = KXSD9_REG_AUX,
}
@@ -226,7 +228,7 @@ static int __devinit kxsd9_probe(struct spi_device *spi)
struct kxsd9_state *st;
int ret = 0;
- indio_dev = iio_allocate_device(sizeof(*st));
+ indio_dev = iio_device_alloc(sizeof(*st));
if (indio_dev == NULL) {
ret = -ENOMEM;
goto error_ret;
@@ -254,7 +256,7 @@ static int __devinit kxsd9_probe(struct spi_device *spi)
return 0;
error_free_dev:
- iio_free_device(indio_dev);
+ iio_device_free(indio_dev);
error_ret:
return ret;
}
@@ -262,7 +264,7 @@ error_ret:
static int __devexit kxsd9_remove(struct spi_device *spi)
{
iio_device_unregister(spi_get_drvdata(spi));
- iio_free_device(spi_get_drvdata(spi));
+ iio_device_free(spi_get_drvdata(spi));
return 0;
}
diff --git a/drivers/staging/iio/accel/lis3l02dq_core.c b/drivers/staging/iio/accel/lis3l02dq_core.c
index 376da5137967..9d263484fb86 100644
--- a/drivers/staging/iio/accel/lis3l02dq_core.c
+++ b/drivers/staging/iio/accel/lis3l02dq_core.c
@@ -23,10 +23,10 @@
#include <linux/sysfs.h>
#include <linux/module.h>
-#include "../iio.h"
-#include "../sysfs.h"
-#include "../events.h"
-#include "../buffer.h"
+#include <linux/iio/iio.h>
+#include <linux/iio/sysfs.h>
+#include <linux/iio/events.h>
+#include <linux/iio/buffer.h>
#include "lis3l02dq.h"
@@ -257,7 +257,7 @@ static int lis3l02dq_read_raw(struct iio_dev *indio_dev,
u8 reg;
switch (mask) {
- case 0:
+ case IIO_CHAN_INFO_RAW:
/* Take the iio_dev status lock */
mutex_lock(&indio_dev->mlock);
if (indio_dev->currentmode == INDIO_BUFFER_TRIGGERED) {
@@ -297,7 +297,7 @@ static ssize_t lis3l02dq_read_frequency(struct device *dev,
struct device_attribute *attr,
char *buf)
{
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
int ret, len = 0;
s8 t;
ret = lis3l02dq_spi_read_reg_8(indio_dev,
@@ -328,7 +328,7 @@ static ssize_t lis3l02dq_write_frequency(struct device *dev,
const char *buf,
size_t len)
{
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
unsigned long val;
int ret;
u8 t;
@@ -513,7 +513,8 @@ static irqreturn_t lis3l02dq_event_handler(int irq, void *private)
}
#define LIS3L02DQ_INFO_MASK \
- (IIO_CHAN_INFO_SCALE_SHARED_BIT | \
+ (IIO_CHAN_INFO_RAW_SEPARATE_BIT | \
+ IIO_CHAN_INFO_SCALE_SHARED_BIT | \
IIO_CHAN_INFO_CALIBSCALE_SEPARATE_BIT | \
IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT)
@@ -521,13 +522,26 @@ static irqreturn_t lis3l02dq_event_handler(int irq, void *private)
(IIO_EV_BIT(IIO_EV_TYPE_THRESH, IIO_EV_DIR_RISING) | \
IIO_EV_BIT(IIO_EV_TYPE_THRESH, IIO_EV_DIR_FALLING))
+#define LIS3L02DQ_CHAN(index, mod) \
+ { \
+ .type = IIO_ACCEL, \
+ .modified = 1, \
+ .channel2 = mod, \
+ .info_mask = LIS3L02DQ_INFO_MASK, \
+ .address = index, \
+ .scan_index = index, \
+ .scan_type = { \
+ .sign = 's', \
+ .realbits = 12, \
+ .storagebits = 16, \
+ }, \
+ .event_mask = LIS3L02DQ_EVENT_MASK, \
+ }
+
static struct iio_chan_spec lis3l02dq_channels[] = {
- IIO_CHAN(IIO_ACCEL, 1, 0, 0, NULL, 0, IIO_MOD_X, LIS3L02DQ_INFO_MASK,
- 0, 0, IIO_ST('s', 12, 16, 0), LIS3L02DQ_EVENT_MASK),
- IIO_CHAN(IIO_ACCEL, 1, 0, 0, NULL, 0, IIO_MOD_Y, LIS3L02DQ_INFO_MASK,
- 1, 1, IIO_ST('s', 12, 16, 0), LIS3L02DQ_EVENT_MASK),
- IIO_CHAN(IIO_ACCEL, 1, 0, 0, NULL, 0, IIO_MOD_Z, LIS3L02DQ_INFO_MASK,
- 2, 2, IIO_ST('s', 12, 16, 0), LIS3L02DQ_EVENT_MASK),
+ LIS3L02DQ_CHAN(0, IIO_MOD_X),
+ LIS3L02DQ_CHAN(1, IIO_MOD_Y),
+ LIS3L02DQ_CHAN(2, IIO_MOD_Z),
IIO_CHAN_SOFT_TIMESTAMP(3)
};
@@ -666,7 +680,7 @@ static int __devinit lis3l02dq_probe(struct spi_device *spi)
struct lis3l02dq_state *st;
struct iio_dev *indio_dev;
- indio_dev = iio_allocate_device(sizeof *st);
+ indio_dev = iio_device_alloc(sizeof *st);
if (indio_dev == NULL) {
ret = -ENOMEM;
goto error_ret;
@@ -724,7 +738,7 @@ static int __devinit lis3l02dq_probe(struct spi_device *spi)
return 0;
error_remove_trigger:
- if (indio_dev->modes & INDIO_BUFFER_TRIGGERED)
+ if (spi->irq && gpio_is_valid(irq_to_gpio(spi->irq)))
lis3l02dq_remove_trigger(indio_dev);
error_free_interrupt:
if (spi->irq && gpio_is_valid(irq_to_gpio(spi->irq)) > 0)
@@ -734,7 +748,7 @@ error_uninitialize_buffer:
error_unreg_buffer_funcs:
lis3l02dq_unconfigure_buffer(indio_dev);
error_free_dev:
- iio_free_device(indio_dev);
+ iio_device_free(indio_dev);
error_ret:
return ret;
}
@@ -789,7 +803,7 @@ static int lis3l02dq_remove(struct spi_device *spi)
iio_buffer_unregister(indio_dev);
lis3l02dq_unconfigure_buffer(indio_dev);
- iio_free_device(indio_dev);
+ iio_device_free(indio_dev);
err_ret:
return ret;
}
diff --git a/drivers/staging/iio/accel/lis3l02dq_ring.c b/drivers/staging/iio/accel/lis3l02dq_ring.c
index 0fc3973f32ae..18d108fd967a 100644
--- a/drivers/staging/iio/accel/lis3l02dq_ring.c
+++ b/drivers/staging/iio/accel/lis3l02dq_ring.c
@@ -6,11 +6,11 @@
#include <linux/slab.h>
#include <linux/export.h>
-#include "../iio.h"
+#include <linux/iio/iio.h>
#include "../ring_sw.h"
-#include "../kfifo_buf.h"
-#include "../trigger.h"
-#include "../trigger_consumer.h"
+#include <linux/iio/kfifo_buf.h>
+#include <linux/iio/trigger.h>
+#include <linux/iio/trigger_consumer.h>
#include "lis3l02dq.h"
/**
@@ -137,38 +137,37 @@ static irqreturn_t lis3l02dq_trigger_handler(int irq, void *p)
struct iio_dev *indio_dev = pf->indio_dev;
struct iio_buffer *buffer = indio_dev->buffer;
int len = 0;
- size_t datasize = buffer->access->get_bytes_per_datum(buffer);
- char *data = kmalloc(datasize, GFP_KERNEL);
+ char *data;
+ data = kmalloc(indio_dev->scan_bytes, GFP_KERNEL);
if (data == NULL) {
dev_err(indio_dev->dev.parent,
"memory alloc failed in buffer bh");
- return -ENOMEM;
+ goto done;
}
if (!bitmap_empty(indio_dev->active_scan_mask, indio_dev->masklength))
len = lis3l02dq_get_buffer_element(indio_dev, data);
/* Guaranteed to be aligned with 8 byte boundary */
- if (buffer->scan_timestamp)
- *(s64 *)(((phys_addr_t)data + len
- + sizeof(s64) - 1) & ~(sizeof(s64) - 1))
+ if (indio_dev->scan_timestamp)
+ *(s64 *)((u8 *)data + ALIGN(len, sizeof(s64)))
= pf->timestamp;
buffer->access->store_to(buffer, (u8 *)data, pf->timestamp);
- iio_trigger_notify_done(indio_dev->trig);
kfree(data);
+done:
+ iio_trigger_notify_done(indio_dev->trig);
return IRQ_HANDLED;
}
/* Caller responsible for locking as necessary. */
static int
-__lis3l02dq_write_data_ready_config(struct device *dev, bool state)
+__lis3l02dq_write_data_ready_config(struct iio_dev *indio_dev, bool state)
{
int ret;
u8 valold;
bool currentlyset;
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
struct lis3l02dq_state *st = iio_priv(indio_dev);
/* Get the current event mask register */
@@ -236,7 +235,7 @@ static int lis3l02dq_data_rdy_trigger_set_state(struct iio_trigger *trig,
int ret = 0;
u8 t;
- __lis3l02dq_write_data_ready_config(&indio_dev->dev, state);
+ __lis3l02dq_write_data_ready_config(indio_dev, state);
if (state == false) {
/*
* A possible quirk with the handler is currently worked around
@@ -286,7 +285,7 @@ int lis3l02dq_probe_trigger(struct iio_dev *indio_dev)
int ret;
struct lis3l02dq_state *st = iio_priv(indio_dev);
- st->trig = iio_allocate_trigger("lis3l02dq-dev%d", indio_dev->id);
+ st->trig = iio_trigger_alloc("lis3l02dq-dev%d", indio_dev->id);
if (!st->trig) {
ret = -ENOMEM;
goto error_ret;
@@ -302,7 +301,7 @@ int lis3l02dq_probe_trigger(struct iio_dev *indio_dev)
return 0;
error_free_trig:
- iio_free_trigger(st->trig);
+ iio_trigger_free(st->trig);
error_ret:
return ret;
}
@@ -312,7 +311,7 @@ void lis3l02dq_remove_trigger(struct iio_dev *indio_dev)
struct lis3l02dq_state *st = iio_priv(indio_dev);
iio_trigger_unregister(st->trig);
- iio_free_trigger(st->trig);
+ iio_trigger_free(st->trig);
}
void lis3l02dq_unconfigure_buffer(struct iio_dev *indio_dev)
diff --git a/drivers/staging/iio/accel/sca3000_core.c b/drivers/staging/iio/accel/sca3000_core.c
index 49764fb7181c..c218d71abf1f 100644
--- a/drivers/staging/iio/accel/sca3000_core.c
+++ b/drivers/staging/iio/accel/sca3000_core.c
@@ -18,10 +18,10 @@
#include <linux/spi/spi.h>
#include <linux/sysfs.h>
#include <linux/module.h>
-#include "../iio.h"
-#include "../sysfs.h"
-#include "../events.h"
-#include "../buffer.h"
+#include <linux/iio/iio.h>
+#include <linux/iio/sysfs.h>
+#include <linux/iio/events.h>
+#include <linux/iio/buffer.h>
#include "sca3000.h"
@@ -241,7 +241,7 @@ error_ret:
static int sca3000_check_status(struct device *dev)
{
int ret;
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct sca3000_state *st = iio_priv(indio_dev);
mutex_lock(&st->lock);
@@ -268,7 +268,7 @@ static ssize_t sca3000_show_rev(struct device *dev,
char *buf)
{
int len = 0, ret;
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct sca3000_state *st = iio_priv(indio_dev);
mutex_lock(&st->lock);
@@ -296,7 +296,7 @@ sca3000_show_available_measurement_modes(struct device *dev,
struct device_attribute *attr,
char *buf)
{
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct sca3000_state *st = iio_priv(indio_dev);
int len = 0;
@@ -328,7 +328,7 @@ sca3000_show_measurement_mode(struct device *dev,
struct device_attribute *attr,
char *buf)
{
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct sca3000_state *st = iio_priv(indio_dev);
int len = 0, ret;
@@ -379,7 +379,7 @@ sca3000_store_measurement_mode(struct device *dev,
const char *buf,
size_t len)
{
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct sca3000_state *st = iio_priv(indio_dev);
int ret;
u8 mask = 0x03;
@@ -429,17 +429,31 @@ static IIO_DEVICE_ATTR(measurement_mode, S_IRUGO | S_IWUSR,
static IIO_DEVICE_ATTR(revision, S_IRUGO, sca3000_show_rev, NULL, 0);
#define SCA3000_INFO_MASK \
- IIO_CHAN_INFO_SCALE_SHARED_BIT
+ IIO_CHAN_INFO_RAW_SEPARATE_BIT | IIO_CHAN_INFO_SCALE_SHARED_BIT
#define SCA3000_EVENT_MASK \
(IIO_EV_BIT(IIO_EV_TYPE_MAG, IIO_EV_DIR_RISING))
+#define SCA3000_CHAN(index, mod) \
+ { \
+ .type = IIO_ACCEL, \
+ .modified = 1, \
+ .channel2 = mod, \
+ .info_mask = SCA3000_INFO_MASK, \
+ .address = index, \
+ .scan_index = index, \
+ .scan_type = { \
+ .sign = 's', \
+ .realbits = 11, \
+ .storagebits = 16, \
+ .shift = 5, \
+ }, \
+ .event_mask = SCA3000_EVENT_MASK, \
+ }
+
static struct iio_chan_spec sca3000_channels[] = {
- IIO_CHAN(IIO_ACCEL, 1, 0, 0, NULL, 0, IIO_MOD_X, SCA3000_INFO_MASK,
- 0, 0, IIO_ST('s', 11, 16, 5), SCA3000_EVENT_MASK),
- IIO_CHAN(IIO_ACCEL, 1, 0, 0, NULL, 0, IIO_MOD_Y, SCA3000_INFO_MASK,
- 1, 1, IIO_ST('s', 11, 16, 5), SCA3000_EVENT_MASK),
- IIO_CHAN(IIO_ACCEL, 1, 0, 0, NULL, 0, IIO_MOD_Z, SCA3000_INFO_MASK,
- 2, 2, IIO_ST('s', 11, 16, 5), SCA3000_EVENT_MASK),
+ SCA3000_CHAN(0, IIO_MOD_X),
+ SCA3000_CHAN(1, IIO_MOD_Y),
+ SCA3000_CHAN(2, IIO_MOD_Z),
};
static u8 sca3000_addresses[3][3] = {
@@ -462,7 +476,7 @@ static int sca3000_read_raw(struct iio_dev *indio_dev,
u8 address;
switch (mask) {
- case 0:
+ case IIO_CHAN_INFO_RAW:
mutex_lock(&st->lock);
if (st->mo_det_use_count) {
mutex_unlock(&st->lock);
@@ -503,7 +517,7 @@ static ssize_t sca3000_read_av_freq(struct device *dev,
struct device_attribute *attr,
char *buf)
{
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct sca3000_state *st = iio_priv(indio_dev);
int len = 0, ret, val;
@@ -574,7 +588,7 @@ static ssize_t sca3000_read_frequency(struct device *dev,
struct device_attribute *attr,
char *buf)
{
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct sca3000_state *st = iio_priv(indio_dev);
int ret, len = 0, base_freq = 0, val;
@@ -616,7 +630,7 @@ static ssize_t sca3000_set_frequency(struct device *dev,
const char *buf,
size_t len)
{
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct sca3000_state *st = iio_priv(indio_dev);
int ret, base_freq = 0;
int ctrlval;
@@ -676,7 +690,7 @@ static ssize_t sca3000_read_temp(struct device *dev,
struct device_attribute *attr,
char *buf)
{
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct sca3000_state *st = iio_priv(indio_dev);
int ret;
int val;
@@ -897,7 +911,7 @@ static ssize_t sca3000_query_free_fall_mode(struct device *dev,
char *buf)
{
int ret, len;
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct sca3000_state *st = iio_priv(indio_dev);
int val;
@@ -925,7 +939,7 @@ static ssize_t sca3000_set_free_fall_mode(struct device *dev,
const char *buf,
size_t len)
{
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct sca3000_state *st = iio_priv(indio_dev);
long val;
int ret;
@@ -1131,7 +1145,7 @@ static int __devinit sca3000_probe(struct spi_device *spi)
struct sca3000_state *st;
struct iio_dev *indio_dev;
- indio_dev = iio_allocate_device(sizeof(*st));
+ indio_dev = iio_device_alloc(sizeof(*st));
if (indio_dev == NULL) {
ret = -ENOMEM;
goto error_ret;
@@ -1175,7 +1189,7 @@ static int __devinit sca3000_probe(struct spi_device *spi)
ret = request_threaded_irq(spi->irq,
NULL,
&sca3000_event_handler,
- IRQF_TRIGGER_FALLING,
+ IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
"sca3000",
indio_dev);
if (ret)
@@ -1195,7 +1209,7 @@ error_unregister_ring:
error_unregister_dev:
iio_device_unregister(indio_dev);
error_free_dev:
- iio_free_device(indio_dev);
+ iio_device_free(indio_dev);
error_ret:
return ret;
@@ -1233,7 +1247,7 @@ static int sca3000_remove(struct spi_device *spi)
iio_device_unregister(indio_dev);
iio_buffer_unregister(indio_dev);
sca3000_unconfigure_ring(indio_dev);
- iio_free_device(indio_dev);
+ iio_device_free(indio_dev);
return 0;
}
diff --git a/drivers/staging/iio/accel/sca3000_ring.c b/drivers/staging/iio/accel/sca3000_ring.c
index 6b824a11f7f4..b7e1a002630a 100644
--- a/drivers/staging/iio/accel/sca3000_ring.c
+++ b/drivers/staging/iio/accel/sca3000_ring.c
@@ -18,9 +18,9 @@
#include <linux/sched.h>
#include <linux/poll.h>
-#include "../iio.h"
-#include "../sysfs.h"
-#include "../buffer.h"
+#include <linux/iio/iio.h>
+#include <linux/iio/sysfs.h>
+#include <linux/iio/buffer.h>
#include "../ring_hw.h"
#include "sca3000.h"
@@ -157,7 +157,7 @@ static ssize_t sca3000_query_ring_int(struct device *dev,
{
struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
int ret, val;
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct sca3000_state *st = iio_priv(indio_dev);
mutex_lock(&st->lock);
@@ -178,7 +178,7 @@ static ssize_t sca3000_set_ring_int(struct device *dev,
const char *buf,
size_t len)
{
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct sca3000_state *st = iio_priv(indio_dev);
struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
long val;
@@ -219,7 +219,7 @@ static ssize_t sca3000_show_buffer_scale(struct device *dev,
struct device_attribute *attr,
char *buf)
{
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct sca3000_state *st = iio_priv(indio_dev);
return sprintf(buf, "0.%06d\n", 4*st->info->scale);
diff --git a/drivers/staging/iio/adc/Kconfig b/drivers/staging/iio/adc/Kconfig
index 592eabd85f36..67711b7d718a 100644
--- a/drivers/staging/iio/adc/Kconfig
+++ b/drivers/staging/iio/adc/Kconfig
@@ -13,6 +13,7 @@ config AD7291
config AD7298
tristate "Analog Devices AD7298 ADC driver"
depends on SPI
+ select IIO_TRIGGERED_BUFFER if IIO_BUFFER
help
Say yes here to build support for Analog Devices AD7298
8 Channel ADC with temperature sensor.
@@ -24,8 +25,7 @@ config AD7606
tristate "Analog Devices AD7606 ADC driver"
depends on GPIOLIB
select IIO_BUFFER
- select IIO_TRIGGER
- select IIO_SW_RING
+ select IIO_TRIGGERED_BUFFER
help
Say yes here to build support for Analog Devices:
ad7606, ad7606-6, ad7606-4 analog to digital converters (ADC).
@@ -63,7 +63,7 @@ config AD799X_RING_BUFFER
bool "Analog Devices AD799x: use ring buffer"
depends on AD799X
select IIO_BUFFER
- select IIO_SW_RING
+ select IIO_TRIGGERED_BUFFER
help
Say yes here to include ring buffer support in the AD799X
ADC driver.
@@ -72,8 +72,7 @@ config AD7476
tristate "Analog Devices AD7475/6/7/8 AD7466/7/8 and AD7495 ADC driver"
depends on SPI
select IIO_BUFFER
- select IIO_SW_RING
- select IIO_TRIGGER
+ select IIO_TRIGGERED_BUFFER
help
Say yes here to build support for Analog Devices
AD7475, AD7476, AD7477, AD7478, AD7466, AD7467, AD7468, AD7495
@@ -87,8 +86,7 @@ config AD7887
tristate "Analog Devices AD7887 ADC driver"
depends on SPI
select IIO_BUFFER
- select IIO_SW_RING
- select IIO_TRIGGER
+ select IIO_TRIGGERED_BUFFER
help
Say yes here to build support for Analog Devices
AD7887 SPI analog to digital converter (ADC).
@@ -113,8 +111,7 @@ config AD7793
tristate "Analog Devices AD7792 AD7793 ADC driver"
depends on SPI
select IIO_BUFFER
- select IIO_SW_RING
- select IIO_TRIGGER
+ select IIO_TRIGGERED_BUFFER
help
Say yes here to build support for Analog Devices
AD7792 and AD7793 SPI analog to digital converters (ADC).
@@ -135,8 +132,7 @@ config AD7192
tristate "Analog Devices AD7190 AD7192 AD7195 ADC driver"
depends on SPI
select IIO_BUFFER
- select IIO_SW_RING
- select IIO_TRIGGER
+ select IIO_TRIGGERED_BUFFER
help
Say yes here to build support for Analog Devices AD7190,
AD7192 or AD7195 SPI analog to digital converters (ADC).
@@ -195,11 +191,20 @@ config MAX1363_RING_BUFFER
config LPC32XX_ADC
tristate "NXP LPC32XX ADC"
- depends on ARCH_LPC32XX && !TOUCHSCREEN_LPC32XX
+ depends on ARCH_LPC32XX
help
Say yes here to build support for the integrated ADC inside the
LPC32XX SoC. Note that this feature uses the same hardware as the
- touchscreen driver, so you can only select one of the two drivers
- (lpc32xx_adc or lpc32xx_ts). Provides direct access via sysfs.
+ touchscreen driver, so you should either select only one of the two
+ drivers (lpc32xx_adc or lpc32xx_ts) or, in the OpenFirmware case,
+ activate only one via device tree selection. Provides direct access
+ via sysfs.
+
+config SPEAR_ADC
+ tristate "ST SPEAr ADC"
+ depends on PLAT_SPEAR
+ help
+ Say yes here to build support for the integrated ADC inside the
+ ST SPEAr SoC. Provides direct access via sysfs.
endmenu
diff --git a/drivers/staging/iio/adc/Makefile b/drivers/staging/iio/adc/Makefile
index f83ab9551d8e..14e98b62b70a 100644
--- a/drivers/staging/iio/adc/Makefile
+++ b/drivers/staging/iio/adc/Makefile
@@ -38,3 +38,4 @@ obj-$(CONFIG_ADT7310) += adt7310.o
obj-$(CONFIG_ADT7410) += adt7410.o
obj-$(CONFIG_AD7280) += ad7280a.o
obj-$(CONFIG_LPC32XX_ADC) += lpc32xx_adc.o
+obj-$(CONFIG_SPEAR_ADC) += spear_adc.o
diff --git a/drivers/staging/iio/adc/ad7192.c b/drivers/staging/iio/adc/ad7192.c
index 9fd6d63d2999..22c3923d55eb 100644
--- a/drivers/staging/iio/adc/ad7192.c
+++ b/drivers/staging/iio/adc/ad7192.c
@@ -1,7 +1,7 @@
/*
* AD7190 AD7192 AD7195 SPI ADC driver
*
- * Copyright 2011 Analog Devices Inc.
+ * Copyright 2011-2012 Analog Devices Inc.
*
* Licensed under the GPL-2.
*/
@@ -17,12 +17,12 @@
#include <linux/sched.h>
#include <linux/delay.h>
-#include "../iio.h"
-#include "../sysfs.h"
-#include "../buffer.h"
-#include "../ring_sw.h"
-#include "../trigger.h"
-#include "../trigger_consumer.h"
+#include <linux/iio/iio.h>
+#include <linux/iio/sysfs.h>
+#include <linux/iio/buffer.h>
+#include <linux/iio/trigger.h>
+#include <linux/iio/trigger_consumer.h>
+#include <linux/iio/triggered_buffer.h>
#include "ad7192.h"
@@ -146,7 +146,6 @@ struct ad7192_state {
u32 mode;
u32 conf;
u32 scale_avail[8][2];
- long available_scan_masks[9];
u8 gpocon;
u8 devid;
/*
@@ -456,31 +455,19 @@ out:
static int ad7192_ring_preenable(struct iio_dev *indio_dev)
{
struct ad7192_state *st = iio_priv(indio_dev);
- struct iio_buffer *ring = indio_dev->buffer;
- size_t d_size;
unsigned channel;
+ int ret;
if (bitmap_empty(indio_dev->active_scan_mask, indio_dev->masklength))
return -EINVAL;
+ ret = iio_sw_buffer_preenable(indio_dev);
+ if (ret < 0)
+ return ret;
+
channel = find_first_bit(indio_dev->active_scan_mask,
indio_dev->masklength);
- d_size = bitmap_weight(indio_dev->active_scan_mask,
- indio_dev->masklength) *
- indio_dev->channels[0].scan_type.storagebits / 8;
-
- if (ring->scan_timestamp) {
- d_size += sizeof(s64);
-
- if (d_size % sizeof(s64))
- d_size += sizeof(s64) - (d_size % sizeof(s64));
- }
-
- if (indio_dev->buffer->access->set_bytes_per_datum)
- indio_dev->buffer->access->
- set_bytes_per_datum(indio_dev->buffer, d_size);
-
st->mode = (st->mode & ~AD7192_MODE_SEL(-1)) |
AD7192_MODE_SEL(AD7192_MODE_CONT);
st->conf = (st->conf & ~AD7192_CONF_CHAN(-1)) |
@@ -533,7 +520,7 @@ static irqreturn_t ad7192_trigger_handler(int irq, void *p)
indio_dev->channels[0].scan_type.realbits/8);
/* Guaranteed to be aligned with 8 byte boundary */
- if (ring->scan_timestamp)
+ if (indio_dev->scan_timestamp)
dat64[1] = pf->timestamp;
ring->access->store_to(ring, (u8 *)dat64, pf->timestamp);
@@ -550,45 +537,18 @@ static const struct iio_buffer_setup_ops ad7192_ring_setup_ops = {
.postenable = &iio_triggered_buffer_postenable,
.predisable = &iio_triggered_buffer_predisable,
.postdisable = &ad7192_ring_postdisable,
+ .validate_scan_mask = &iio_validate_scan_mask_onehot,
};
static int ad7192_register_ring_funcs_and_init(struct iio_dev *indio_dev)
{
- int ret;
-
- indio_dev->buffer = iio_sw_rb_allocate(indio_dev);
- if (!indio_dev->buffer) {
- ret = -ENOMEM;
- goto error_ret;
- }
- indio_dev->pollfunc = iio_alloc_pollfunc(&iio_pollfunc_store_time,
- &ad7192_trigger_handler,
- IRQF_ONESHOT,
- indio_dev,
- "ad7192_consumer%d",
- indio_dev->id);
- if (indio_dev->pollfunc == NULL) {
- ret = -ENOMEM;
- goto error_deallocate_sw_rb;
- }
-
- /* Ring buffer functions - here trigger setup related */
- indio_dev->setup_ops = &ad7192_ring_setup_ops;
-
- /* Flag that polled ring buffering is possible */
- indio_dev->modes |= INDIO_BUFFER_TRIGGERED;
- return 0;
-
-error_deallocate_sw_rb:
- iio_sw_rb_free(indio_dev->buffer);
-error_ret:
- return ret;
+ return iio_triggered_buffer_setup(indio_dev, &iio_pollfunc_store_time,
+ &ad7192_trigger_handler, &ad7192_ring_setup_ops);
}
static void ad7192_ring_cleanup(struct iio_dev *indio_dev)
{
- iio_dealloc_pollfunc(indio_dev->pollfunc);
- iio_sw_rb_free(indio_dev->buffer);
+ iio_triggered_buffer_cleanup(indio_dev);
}
/**
@@ -616,7 +576,7 @@ static int ad7192_probe_trigger(struct iio_dev *indio_dev)
struct ad7192_state *st = iio_priv(indio_dev);
int ret;
- st->trig = iio_allocate_trigger("%s-dev%d",
+ st->trig = iio_trigger_alloc("%s-dev%d",
spi_get_device_id(st->spi)->name,
indio_dev->id);
if (st->trig == NULL) {
@@ -649,7 +609,7 @@ static int ad7192_probe_trigger(struct iio_dev *indio_dev)
error_free_irq:
free_irq(st->spi->irq, indio_dev);
error_free_trig:
- iio_free_trigger(st->trig);
+ iio_trigger_free(st->trig);
error_ret:
return ret;
}
@@ -660,14 +620,14 @@ static void ad7192_remove_trigger(struct iio_dev *indio_dev)
iio_trigger_unregister(st->trig);
free_irq(st->spi->irq, indio_dev);
- iio_free_trigger(st->trig);
+ iio_trigger_free(st->trig);
}
static ssize_t ad7192_read_frequency(struct device *dev,
struct device_attribute *attr,
char *buf)
{
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct ad7192_state *st = iio_priv(indio_dev);
return sprintf(buf, "%d\n", st->mclk /
@@ -679,7 +639,7 @@ static ssize_t ad7192_write_frequency(struct device *dev,
const char *buf,
size_t len)
{
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct ad7192_state *st = iio_priv(indio_dev);
unsigned long lval;
int div, ret;
@@ -718,7 +678,7 @@ static IIO_DEV_ATTR_SAMP_FREQ(S_IWUSR | S_IRUGO,
static ssize_t ad7192_show_scale_available(struct device *dev,
struct device_attribute *attr, char *buf)
{
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct ad7192_state *st = iio_priv(indio_dev);
int i, len = 0;
@@ -742,7 +702,7 @@ static ssize_t ad7192_show_ac_excitation(struct device *dev,
struct device_attribute *attr,
char *buf)
{
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct ad7192_state *st = iio_priv(indio_dev);
return sprintf(buf, "%d\n", !!(st->mode & AD7192_MODE_ACX));
@@ -752,7 +712,7 @@ static ssize_t ad7192_show_bridge_switch(struct device *dev,
struct device_attribute *attr,
char *buf)
{
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct ad7192_state *st = iio_priv(indio_dev);
return sprintf(buf, "%d\n", !!(st->gpocon & AD7192_GPOCON_BPDSW));
@@ -763,7 +723,7 @@ static ssize_t ad7192_set(struct device *dev,
const char *buf,
size_t len)
{
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct ad7192_state *st = iio_priv(indio_dev);
struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
int ret;
@@ -849,7 +809,7 @@ static int ad7192_read_raw(struct iio_dev *indio_dev,
bool unipolar = !!(st->conf & AD7192_CONF_UNIPOLAR);
switch (m) {
- case 0:
+ case IIO_CHAN_INFO_RAW:
mutex_lock(&indio_dev->mlock);
if (iio_buffer_enabled(indio_dev))
ret = -EBUSY;
@@ -981,7 +941,8 @@ static const struct iio_info ad7195_info = {
.extend_name = _name, \
.channel = _chan, \
.channel2 = _chan2, \
- .info_mask = IIO_CHAN_INFO_SCALE_SHARED_BIT, \
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT | \
+ IIO_CHAN_INFO_SCALE_SHARED_BIT, \
.address = _address, \
.scan_index = _si, \
.scan_type = IIO_ST('s', 24, 32, 0)}
@@ -990,7 +951,8 @@ static const struct iio_info ad7195_info = {
{ .type = IIO_VOLTAGE, \
.indexed = 1, \
.channel = _chan, \
- .info_mask = IIO_CHAN_INFO_SCALE_SHARED_BIT, \
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT | \
+ IIO_CHAN_INFO_SCALE_SHARED_BIT, \
.address = _address, \
.scan_index = _si, \
.scan_type = IIO_ST('s', 24, 32, 0)}
@@ -999,7 +961,8 @@ static const struct iio_info ad7195_info = {
{ .type = IIO_TEMP, \
.indexed = 1, \
.channel = _chan, \
- .info_mask = IIO_CHAN_INFO_SCALE_SEPARATE_BIT, \
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT | \
+ IIO_CHAN_INFO_SCALE_SEPARATE_BIT, \
.address = _address, \
.scan_index = _si, \
.scan_type = IIO_ST('s', 24, 32, 0)}
@@ -1021,7 +984,7 @@ static int __devinit ad7192_probe(struct spi_device *spi)
struct ad7192_platform_data *pdata = spi->dev.platform_data;
struct ad7192_state *st;
struct iio_dev *indio_dev;
- int ret, i , voltage_uv = 0;
+ int ret , voltage_uv = 0;
if (!pdata) {
dev_err(&spi->dev, "no platform data?\n");
@@ -1033,7 +996,7 @@ static int __devinit ad7192_probe(struct spi_device *spi)
return -ENODEV;
}
- indio_dev = iio_allocate_device(sizeof(*st));
+ indio_dev = iio_device_alloc(sizeof(*st));
if (indio_dev == NULL)
return -ENOMEM;
@@ -1065,17 +1028,11 @@ static int __devinit ad7192_probe(struct spi_device *spi)
indio_dev->modes = INDIO_DIRECT_MODE;
indio_dev->channels = ad7192_channels;
indio_dev->num_channels = ARRAY_SIZE(ad7192_channels);
- indio_dev->available_scan_masks = st->available_scan_masks;
if (st->devid == ID_AD7195)
indio_dev->info = &ad7195_info;
else
indio_dev->info = &ad7192_info;
- for (i = 0; i < indio_dev->num_channels; i++)
- st->available_scan_masks[i] = (1 << i) | (1 <<
- indio_dev->channels[indio_dev->num_channels - 1].
- scan_index);
-
init_waitqueue_head(&st->wq_data_avail);
ret = ad7192_register_ring_funcs_and_init(indio_dev);
@@ -1086,23 +1043,15 @@ static int __devinit ad7192_probe(struct spi_device *spi)
if (ret)
goto error_ring_cleanup;
- ret = iio_buffer_register(indio_dev,
- indio_dev->channels,
- indio_dev->num_channels);
- if (ret)
- goto error_remove_trigger;
-
ret = ad7192_setup(st);
if (ret)
- goto error_unreg_ring;
+ goto error_remove_trigger;
ret = iio_device_register(indio_dev);
if (ret < 0)
- goto error_unreg_ring;
+ goto error_remove_trigger;
return 0;
-error_unreg_ring:
- iio_buffer_unregister(indio_dev);
error_remove_trigger:
ad7192_remove_trigger(indio_dev);
error_ring_cleanup:
@@ -1114,7 +1063,7 @@ error_put_reg:
if (!IS_ERR(st->reg))
regulator_put(st->reg);
- iio_free_device(indio_dev);
+ iio_device_free(indio_dev);
return ret;
}
@@ -1125,7 +1074,6 @@ static int ad7192_remove(struct spi_device *spi)
struct ad7192_state *st = iio_priv(indio_dev);
iio_device_unregister(indio_dev);
- iio_buffer_unregister(indio_dev);
ad7192_remove_trigger(indio_dev);
ad7192_ring_cleanup(indio_dev);
diff --git a/drivers/staging/iio/adc/ad7280a.c b/drivers/staging/iio/adc/ad7280a.c
index 7dbd6812c240..cfc39a703126 100644
--- a/drivers/staging/iio/adc/ad7280a.c
+++ b/drivers/staging/iio/adc/ad7280a.c
@@ -16,9 +16,9 @@
#include <linux/interrupt.h>
#include <linux/module.h>
-#include "../iio.h"
-#include "../sysfs.h"
-#include "../events.h"
+#include <linux/iio/iio.h>
+#include <linux/iio/sysfs.h>
+#include <linux/iio/events.h>
#include "ad7280a.h"
@@ -384,7 +384,7 @@ static ssize_t ad7280_show_balance_sw(struct device *dev,
struct device_attribute *attr,
char *buf)
{
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct ad7280_state *st = iio_priv(indio_dev);
struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
@@ -398,7 +398,7 @@ static ssize_t ad7280_store_balance_sw(struct device *dev,
const char *buf,
size_t len)
{
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct ad7280_state *st = iio_priv(indio_dev);
struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
bool readin;
@@ -429,7 +429,7 @@ static ssize_t ad7280_show_balance_timer(struct device *dev,
struct device_attribute *attr,
char *buf)
{
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct ad7280_state *st = iio_priv(indio_dev);
struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
int ret;
@@ -453,7 +453,7 @@ static ssize_t ad7280_store_balance_timer(struct device *dev,
const char *buf,
size_t len)
{
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct ad7280_state *st = iio_priv(indio_dev);
struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
unsigned long val;
@@ -508,6 +508,7 @@ static int ad7280_channel_init(struct ad7280_state *st)
}
st->channels[cnt].indexed = 1;
st->channels[cnt].info_mask =
+ IIO_CHAN_INFO_RAW_SEPARATE_BIT |
IIO_CHAN_INFO_SCALE_SHARED_BIT;
st->channels[cnt].address =
AD7280A_DEVADDR(dev) << 8 | ch;
@@ -524,7 +525,9 @@ static int ad7280_channel_init(struct ad7280_state *st)
st->channels[cnt].channel2 = dev * 6;
st->channels[cnt].address = AD7280A_ALL_CELLS;
st->channels[cnt].indexed = 1;
- st->channels[cnt].info_mask = IIO_CHAN_INFO_SCALE_SHARED_BIT;
+ st->channels[cnt].info_mask =
+ IIO_CHAN_INFO_RAW_SEPARATE_BIT |
+ IIO_CHAN_INFO_SCALE_SHARED_BIT;
st->channels[cnt].scan_index = cnt;
st->channels[cnt].scan_type.sign = 'u';
st->channels[cnt].scan_type.realbits = 32;
@@ -596,7 +599,7 @@ static ssize_t ad7280_read_channel_config(struct device *dev,
struct device_attribute *attr,
char *buf)
{
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct ad7280_state *st = iio_priv(indio_dev);
struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
unsigned val;
@@ -626,7 +629,7 @@ static ssize_t ad7280_write_channel_config(struct device *dev,
const char *buf,
size_t len)
{
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct ad7280_state *st = iio_priv(indio_dev);
struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
@@ -788,7 +791,7 @@ static int ad7280_read_raw(struct iio_dev *indio_dev,
int ret;
switch (m) {
- case 0:
+ case IIO_CHAN_INFO_RAW:
mutex_lock(&indio_dev->mlock);
if (chan->address == AD7280A_ALL_CELLS)
ret = ad7280_read_all_channels(st, st->scan_cnt, NULL);
@@ -836,7 +839,7 @@ static int __devinit ad7280_probe(struct spi_device *spi)
int ret;
const unsigned short tACQ_ns[4] = {465, 1010, 1460, 1890};
const unsigned short nAVG[4] = {1, 2, 4, 8};
- struct iio_dev *indio_dev = iio_allocate_device(sizeof(*st));
+ struct iio_dev *indio_dev = iio_device_alloc(sizeof(*st));
if (indio_dev == NULL)
return -ENOMEM;
@@ -942,7 +945,7 @@ error_free_channels:
kfree(st->channels);
error_free_device:
- iio_free_device(indio_dev);
+ iio_device_free(indio_dev);
return ret;
}
@@ -961,7 +964,7 @@ static int __devexit ad7280_remove(struct spi_device *spi)
kfree(st->channels);
kfree(st->iio_attr);
- iio_free_device(indio_dev);
+ iio_device_free(indio_dev);
return 0;
}
diff --git a/drivers/staging/iio/adc/ad7291.c b/drivers/staging/iio/adc/ad7291.c
index 81d6b6128cb0..029b39c0ba60 100644
--- a/drivers/staging/iio/adc/ad7291.c
+++ b/drivers/staging/iio/adc/ad7291.c
@@ -17,9 +17,9 @@
#include <linux/regulator/consumer.h>
#include <linux/err.h>
-#include "../iio.h"
-#include "../sysfs.h"
-#include "../events.h"
+#include <linux/iio/iio.h>
+#include <linux/iio/sysfs.h>
+#include <linux/iio/events.h>
/*
* Simplified handling
@@ -132,7 +132,7 @@ static ssize_t ad7291_store_reset(struct device *dev,
const char *buf,
size_t len)
{
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct ad7291_chip_info *chip = iio_priv(indio_dev);
return ad7291_i2c_write(chip, AD7291_COMMAND,
@@ -214,7 +214,7 @@ static inline ssize_t ad7291_show_hyst(struct device *dev,
struct device_attribute *attr,
char *buf)
{
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct ad7291_chip_info *chip = iio_priv(indio_dev);
struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
u16 data;
@@ -232,7 +232,7 @@ static inline ssize_t ad7291_set_hyst(struct device *dev,
const char *buf,
size_t len)
{
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct ad7291_chip_info *chip = iio_priv(indio_dev);
struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
u16 data;
@@ -461,7 +461,7 @@ static int ad7291_read_raw(struct iio_dev *indio_dev,
s16 signval;
switch (mask) {
- case 0:
+ case IIO_CHAN_INFO_RAW:
switch (chan->type) {
case IIO_VOLTAGE:
mutex_lock(&chip->state_lock);
@@ -536,7 +536,8 @@ static int ad7291_read_raw(struct iio_dev *indio_dev,
#define AD7291_VOLTAGE_CHAN(_chan) \
{ \
.type = IIO_VOLTAGE, \
- .info_mask = IIO_CHAN_INFO_SCALE_SHARED_BIT, \
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT | \
+ IIO_CHAN_INFO_SCALE_SHARED_BIT, \
.indexed = 1, \
.channel = _chan, \
.event_mask = IIO_EV_BIT(IIO_EV_TYPE_THRESH, IIO_EV_DIR_RISING)|\
@@ -554,7 +555,8 @@ static const struct iio_chan_spec ad7291_channels[] = {
AD7291_VOLTAGE_CHAN(7),
{
.type = IIO_TEMP,
- .info_mask = IIO_CHAN_INFO_AVERAGE_RAW_SEPARATE_BIT |
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
+ IIO_CHAN_INFO_AVERAGE_RAW_SEPARATE_BIT |
IIO_CHAN_INFO_SCALE_SEPARATE_BIT,
.indexed = 1,
.channel = 0,
@@ -585,7 +587,7 @@ static int __devinit ad7291_probe(struct i2c_client *client,
struct iio_dev *indio_dev;
int ret = 0, voltage_uv = 0;
- indio_dev = iio_allocate_device(sizeof(*chip));
+ indio_dev = iio_device_alloc(sizeof(*chip));
if (indio_dev == NULL) {
ret = -ENOMEM;
goto error_ret;
@@ -667,7 +669,7 @@ error_put_reg:
if (!IS_ERR(chip->reg))
regulator_put(chip->reg);
- iio_free_device(indio_dev);
+ iio_device_free(indio_dev);
error_ret:
return ret;
}
@@ -687,7 +689,7 @@ static int __devexit ad7291_remove(struct i2c_client *client)
regulator_put(chip->reg);
}
- iio_free_device(indio_dev);
+ iio_device_free(indio_dev);
return 0;
}
diff --git a/drivers/staging/iio/adc/ad7298.h b/drivers/staging/iio/adc/ad7298.h
index a0e5dea415ef..18f278723002 100644
--- a/drivers/staging/iio/adc/ad7298.h
+++ b/drivers/staging/iio/adc/ad7298.h
@@ -38,7 +38,6 @@ struct ad7298_platform_data {
struct ad7298_state {
struct spi_device *spi;
struct regulator *reg;
- size_t d_size;
u16 int_vref_mv;
unsigned ext_ref;
struct spi_transfer ring_xfer[10];
@@ -56,6 +55,8 @@ struct ad7298_state {
#ifdef CONFIG_IIO_BUFFER
int ad7298_register_ring_funcs_and_init(struct iio_dev *indio_dev);
void ad7298_ring_cleanup(struct iio_dev *indio_dev);
+int ad7298_update_scan_mode(struct iio_dev *indio_dev,
+ const unsigned long *active_scan_mask);
#else /* CONFIG_IIO_BUFFER */
static inline int
@@ -67,5 +68,8 @@ ad7298_register_ring_funcs_and_init(struct iio_dev *indio_dev)
static inline void ad7298_ring_cleanup(struct iio_dev *indio_dev)
{
}
+
+#define ad7298_update_scan_mode NULL
+
#endif /* CONFIG_IIO_BUFFER */
#endif /* IIO_ADC_AD7298_H_ */
diff --git a/drivers/staging/iio/adc/ad7298_core.c b/drivers/staging/iio/adc/ad7298_core.c
index 8dd6aa9cf928..6141f4a70cfa 100644
--- a/drivers/staging/iio/adc/ad7298_core.c
+++ b/drivers/staging/iio/adc/ad7298_core.c
@@ -16,40 +16,51 @@
#include <linux/delay.h>
#include <linux/module.h>
-#include "../iio.h"
-#include "../sysfs.h"
-#include "../buffer.h"
+#include <linux/iio/iio.h>
+#include <linux/iio/sysfs.h>
+#include <linux/iio/buffer.h>
#include "ad7298.h"
+#define AD7298_V_CHAN(index) \
+ { \
+ .type = IIO_VOLTAGE, \
+ .indexed = 1, \
+ .channel = index, \
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT | \
+ IIO_CHAN_INFO_SCALE_SHARED_BIT, \
+ .address = index, \
+ .scan_index = index, \
+ .scan_type = { \
+ .sign = 'u', \
+ .realbits = 12, \
+ .storagebits = 16, \
+ }, \
+ }
+
static struct iio_chan_spec ad7298_channels[] = {
- IIO_CHAN(IIO_TEMP, 0, 1, 0, NULL, 0, 0,
- IIO_CHAN_INFO_SCALE_SEPARATE_BIT,
- 9, AD7298_CH_TEMP, IIO_ST('s', 32, 32, 0), 0),
- IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 0, 0,
- IIO_CHAN_INFO_SCALE_SHARED_BIT,
- 0, 0, IIO_ST('u', 12, 16, 0), 0),
- IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 1, 0,
- IIO_CHAN_INFO_SCALE_SHARED_BIT,
- 1, 1, IIO_ST('u', 12, 16, 0), 0),
- IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 2, 0,
- IIO_CHAN_INFO_SCALE_SHARED_BIT,
- 2, 2, IIO_ST('u', 12, 16, 0), 0),
- IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 3, 0,
- IIO_CHAN_INFO_SCALE_SHARED_BIT,
- 3, 3, IIO_ST('u', 12, 16, 0), 0),
- IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 4, 0,
- IIO_CHAN_INFO_SCALE_SHARED_BIT,
- 4, 4, IIO_ST('u', 12, 16, 0), 0),
- IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 5, 0,
- IIO_CHAN_INFO_SCALE_SHARED_BIT,
- 5, 5, IIO_ST('u', 12, 16, 0), 0),
- IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 6, 0,
- IIO_CHAN_INFO_SCALE_SHARED_BIT,
- 6, 6, IIO_ST('u', 12, 16, 0), 0),
- IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 7, 0,
- IIO_CHAN_INFO_SCALE_SHARED_BIT,
- 7, 7, IIO_ST('u', 12, 16, 0), 0),
+ {
+ .type = IIO_TEMP,
+ .indexed = 1,
+ .channel = 0,
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
+ IIO_CHAN_INFO_SCALE_SEPARATE_BIT,
+ .address = AD7298_CH_TEMP,
+ .scan_index = -1,
+ .scan_type = {
+ .sign = 's',
+ .realbits = 32,
+ .storagebits = 32,
+ },
+ },
+ AD7298_V_CHAN(0),
+ AD7298_V_CHAN(1),
+ AD7298_V_CHAN(2),
+ AD7298_V_CHAN(3),
+ AD7298_V_CHAN(4),
+ AD7298_V_CHAN(5),
+ AD7298_V_CHAN(6),
+ AD7298_V_CHAN(7),
IIO_CHAN_SOFT_TIMESTAMP(8),
};
@@ -121,7 +132,7 @@ static int ad7298_read_raw(struct iio_dev *indio_dev,
unsigned int scale_uv;
switch (m) {
- case 0:
+ case IIO_CHAN_INFO_RAW:
mutex_lock(&indio_dev->mlock);
if (indio_dev->currentmode == INDIO_BUFFER_TRIGGERED) {
ret = -EBUSY;
@@ -160,6 +171,7 @@ static int ad7298_read_raw(struct iio_dev *indio_dev,
static const struct iio_info ad7298_info = {
.read_raw = &ad7298_read_raw,
+ .update_scan_mode = ad7298_update_scan_mode,
.driver_module = THIS_MODULE,
};
@@ -168,7 +180,7 @@ static int __devinit ad7298_probe(struct spi_device *spi)
struct ad7298_platform_data *pdata = spi->dev.platform_data;
struct ad7298_state *st;
int ret;
- struct iio_dev *indio_dev = iio_allocate_device(sizeof(*st));
+ struct iio_dev *indio_dev = iio_device_alloc(sizeof(*st));
if (indio_dev == NULL)
return -ENOMEM;
@@ -220,19 +232,12 @@ static int __devinit ad7298_probe(struct spi_device *spi)
if (ret)
goto error_disable_reg;
- ret = iio_buffer_register(indio_dev,
- &ad7298_channels[1], /* skip temp0 */
- ARRAY_SIZE(ad7298_channels) - 1);
- if (ret)
- goto error_cleanup_ring;
ret = iio_device_register(indio_dev);
if (ret)
- goto error_unregister_ring;
+ goto error_cleanup_ring;
return 0;
-error_unregister_ring:
- iio_buffer_unregister(indio_dev);
error_cleanup_ring:
ad7298_ring_cleanup(indio_dev);
error_disable_reg:
@@ -241,7 +246,7 @@ error_disable_reg:
error_put_reg:
if (!IS_ERR(st->reg))
regulator_put(st->reg);
- iio_free_device(indio_dev);
+ iio_device_free(indio_dev);
return ret;
}
@@ -252,13 +257,12 @@ static int __devexit ad7298_remove(struct spi_device *spi)
struct ad7298_state *st = iio_priv(indio_dev);
iio_device_unregister(indio_dev);
- iio_buffer_unregister(indio_dev);
ad7298_ring_cleanup(indio_dev);
if (!IS_ERR(st->reg)) {
regulator_disable(st->reg);
regulator_put(st->reg);
}
- iio_free_device(indio_dev);
+ iio_device_free(indio_dev);
return 0;
}
diff --git a/drivers/staging/iio/adc/ad7298_ring.c b/drivers/staging/iio/adc/ad7298_ring.c
index feeb0eeba59a..fd1d855ff57a 100644
--- a/drivers/staging/iio/adc/ad7298_ring.c
+++ b/drivers/staging/iio/adc/ad7298_ring.c
@@ -1,7 +1,7 @@
/*
* AD7298 SPI ADC driver
*
- * Copyright 2011 Analog Devices Inc.
+ * Copyright 2011-2012 Analog Devices Inc.
*
* Licensed under the GPL-2.
*/
@@ -11,47 +11,31 @@
#include <linux/slab.h>
#include <linux/spi/spi.h>
-#include "../iio.h"
-#include "../buffer.h"
-#include "../ring_sw.h"
-#include "../trigger_consumer.h"
+#include <linux/iio/iio.h>
+#include <linux/iio/buffer.h>
+#include <linux/iio/trigger_consumer.h>
+#include <linux/iio/triggered_buffer.h>
#include "ad7298.h"
/**
- * ad7298_ring_preenable() setup the parameters of the ring before enabling
- *
- * The complex nature of the setting of the number of bytes per datum is due
- * to this driver currently ensuring that the timestamp is stored at an 8
- * byte boundary.
+ * ad7298_update_scan_mode() setup the spi transfer buffer for the new scan mask
**/
-static int ad7298_ring_preenable(struct iio_dev *indio_dev)
+int ad7298_update_scan_mode(struct iio_dev *indio_dev,
+ const unsigned long *active_scan_mask)
{
struct ad7298_state *st = iio_priv(indio_dev);
- struct iio_buffer *ring = indio_dev->buffer;
- size_t d_size;
int i, m;
unsigned short command;
- int scan_count = bitmap_weight(indio_dev->active_scan_mask,
- indio_dev->masklength);
- d_size = scan_count * (AD7298_STORAGE_BITS / 8);
-
- if (ring->scan_timestamp) {
- d_size += sizeof(s64);
-
- if (d_size % sizeof(s64))
- d_size += sizeof(s64) - (d_size % sizeof(s64));
- }
-
- if (ring->access->set_bytes_per_datum)
- ring->access->set_bytes_per_datum(ring, d_size);
+ int scan_count;
- st->d_size = d_size;
+ /* Now compute overall size */
+ scan_count = bitmap_weight(active_scan_mask, indio_dev->masklength);
command = AD7298_WRITE | st->ext_ref;
for (i = 0, m = AD7298_CH(0); i < AD7298_MAX_CHAN; i++, m >>= 1)
- if (test_bit(i, indio_dev->active_scan_mask))
+ if (test_bit(i, active_scan_mask))
command |= m;
st->tx_buf[0] = cpu_to_be16(command);
@@ -98,11 +82,11 @@ static irqreturn_t ad7298_trigger_handler(int irq, void *p)
b_sent = spi_sync(st->spi, &st->ring_msg);
if (b_sent)
- return b_sent;
+ goto done;
- if (ring->scan_timestamp) {
+ if (indio_dev->scan_timestamp) {
time_ns = iio_get_time_ns();
- memcpy((u8 *)buf + st->d_size - sizeof(s64),
+ memcpy((u8 *)buf + indio_dev->scan_bytes - sizeof(s64),
&time_ns, sizeof(time_ns));
}
@@ -111,54 +95,20 @@ static irqreturn_t ad7298_trigger_handler(int irq, void *p)
buf[i] = be16_to_cpu(st->rx_buf[i]);
indio_dev->buffer->access->store_to(ring, (u8 *)buf, time_ns);
+
+done:
iio_trigger_notify_done(indio_dev->trig);
return IRQ_HANDLED;
}
-static const struct iio_buffer_setup_ops ad7298_ring_setup_ops = {
- .preenable = &ad7298_ring_preenable,
- .postenable = &iio_triggered_buffer_postenable,
- .predisable = &iio_triggered_buffer_predisable,
-};
-
int ad7298_register_ring_funcs_and_init(struct iio_dev *indio_dev)
{
- int ret;
-
- indio_dev->buffer = iio_sw_rb_allocate(indio_dev);
- if (!indio_dev->buffer) {
- ret = -ENOMEM;
- goto error_ret;
- }
- indio_dev->pollfunc = iio_alloc_pollfunc(NULL,
- &ad7298_trigger_handler,
- IRQF_ONESHOT,
- indio_dev,
- "ad7298_consumer%d",
- indio_dev->id);
-
- if (indio_dev->pollfunc == NULL) {
- ret = -ENOMEM;
- goto error_deallocate_sw_rb;
- }
-
- /* Ring buffer functions - here trigger setup related */
- indio_dev->setup_ops = &ad7298_ring_setup_ops;
- indio_dev->buffer->scan_timestamp = true;
-
- /* Flag that polled ring buffering is possible */
- indio_dev->modes |= INDIO_BUFFER_TRIGGERED;
- return 0;
-
-error_deallocate_sw_rb:
- iio_sw_rb_free(indio_dev->buffer);
-error_ret:
- return ret;
+ return iio_triggered_buffer_setup(indio_dev, NULL,
+ &ad7298_trigger_handler, NULL);
}
void ad7298_ring_cleanup(struct iio_dev *indio_dev)
{
- iio_dealloc_pollfunc(indio_dev->pollfunc);
- iio_sw_rb_free(indio_dev->buffer);
+ iio_triggered_buffer_cleanup(indio_dev);
}
diff --git a/drivers/staging/iio/adc/ad7476.h b/drivers/staging/iio/adc/ad7476.h
index 27f696c75cc4..b1dd9317fe1f 100644
--- a/drivers/staging/iio/adc/ad7476.h
+++ b/drivers/staging/iio/adc/ad7476.h
@@ -27,7 +27,6 @@ struct ad7476_state {
struct spi_device *spi;
const struct ad7476_chip_info *chip_info;
struct regulator *reg;
- size_t d_size;
u16 int_vref_mv;
struct spi_transfer xfer;
struct spi_message msg;
diff --git a/drivers/staging/iio/adc/ad7476_core.c b/drivers/staging/iio/adc/ad7476_core.c
index 0c064d1c3927..4d30a798ba0d 100644
--- a/drivers/staging/iio/adc/ad7476_core.c
+++ b/drivers/staging/iio/adc/ad7476_core.c
@@ -15,9 +15,9 @@
#include <linux/err.h>
#include <linux/module.h>
-#include "../iio.h"
-#include "../sysfs.h"
-#include "../buffer.h"
+#include <linux/iio/iio.h>
+#include <linux/iio/sysfs.h>
+#include <linux/iio/buffer.h>
#include "ad7476.h"
@@ -43,7 +43,7 @@ static int ad7476_read_raw(struct iio_dev *indio_dev,
unsigned int scale_uv;
switch (m) {
- case 0:
+ case IIO_CHAN_INFO_RAW:
mutex_lock(&indio_dev->mlock);
if (iio_buffer_enabled(indio_dev))
ret = -EBUSY;
@@ -66,53 +66,51 @@ static int ad7476_read_raw(struct iio_dev *indio_dev,
return -EINVAL;
}
+#define AD7476_CHAN(bits) \
+ { \
+ .type = IIO_VOLTAGE, \
+ .indexed = 1, \
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT | \
+ IIO_CHAN_INFO_SCALE_SHARED_BIT, \
+ .scan_type = { \
+ .sign = 'u', \
+ .realbits = bits, \
+ .storagebits = 16, \
+ .shift = 12 - bits, \
+ }, \
+}
+
static const struct ad7476_chip_info ad7476_chip_info_tbl[] = {
[ID_AD7466] = {
- .channel[0] = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 0, 0,
- IIO_CHAN_INFO_SCALE_SHARED_BIT,
- 0, 0, IIO_ST('u', 12, 16, 0), 0),
+ .channel[0] = AD7476_CHAN(12),
.channel[1] = IIO_CHAN_SOFT_TIMESTAMP(1),
},
[ID_AD7467] = {
- .channel[0] = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 0, 0,
- IIO_CHAN_INFO_SCALE_SHARED_BIT,
- 0, 0, IIO_ST('u', 10, 16, 2), 0),
+ .channel[0] = AD7476_CHAN(10),
.channel[1] = IIO_CHAN_SOFT_TIMESTAMP(1),
},
[ID_AD7468] = {
- .channel[0] = IIO_CHAN(IIO_VOLTAGE, 0, 1 , 0, NULL, 0, 0,
- IIO_CHAN_INFO_SCALE_SHARED_BIT,
- 0, 0, IIO_ST('u', 8, 16, 4), 0),
+ .channel[0] = AD7476_CHAN(8),
.channel[1] = IIO_CHAN_SOFT_TIMESTAMP(1),
},
[ID_AD7475] = {
- .channel[0] = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 0, 0,
- IIO_CHAN_INFO_SCALE_SHARED_BIT,
- 0, 0, IIO_ST('u', 12, 16, 0), 0),
+ .channel[0] = AD7476_CHAN(12),
.channel[1] = IIO_CHAN_SOFT_TIMESTAMP(1),
},
[ID_AD7476] = {
- .channel[0] = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 0, 0,
- IIO_CHAN_INFO_SCALE_SHARED_BIT,
- 0, 0, IIO_ST('u', 12, 16, 0), 0),
+ .channel[0] = AD7476_CHAN(12),
.channel[1] = IIO_CHAN_SOFT_TIMESTAMP(1),
},
[ID_AD7477] = {
- .channel[0] = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 0, 0,
- IIO_CHAN_INFO_SCALE_SHARED_BIT,
- 0, 0, IIO_ST('u', 10, 16, 2), 0),
+ .channel[0] = AD7476_CHAN(10),
.channel[1] = IIO_CHAN_SOFT_TIMESTAMP(1),
},
[ID_AD7478] = {
- .channel[0] = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 0, 0,
- IIO_CHAN_INFO_SCALE_SHARED_BIT,
- 0, 0, IIO_ST('u', 8, 16, 4), 0),
+ .channel[0] = AD7476_CHAN(8),
.channel[1] = IIO_CHAN_SOFT_TIMESTAMP(1),
},
[ID_AD7495] = {
- .channel[0] = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 0, 0,
- IIO_CHAN_INFO_SCALE_SHARED_BIT,
- 0, 0, IIO_ST('u', 12, 16, 0), 0),
+ .channel[0] = AD7476_CHAN(12),
.channel[1] = IIO_CHAN_SOFT_TIMESTAMP(1),
.int_vref_mv = 2500,
},
@@ -130,7 +128,7 @@ static int __devinit ad7476_probe(struct spi_device *spi)
struct iio_dev *indio_dev;
int ret, voltage_uv = 0;
- indio_dev = iio_allocate_device(sizeof(*st));
+ indio_dev = iio_device_alloc(sizeof(*st));
if (indio_dev == NULL) {
ret = -ENOMEM;
goto error_ret;
@@ -179,20 +177,12 @@ static int __devinit ad7476_probe(struct spi_device *spi)
if (ret)
goto error_disable_reg;
- ret = iio_buffer_register(indio_dev,
- st->chip_info->channel,
- ARRAY_SIZE(st->chip_info->channel));
- if (ret)
- goto error_cleanup_ring;
-
ret = iio_device_register(indio_dev);
if (ret)
goto error_ring_unregister;
return 0;
error_ring_unregister:
- iio_buffer_unregister(indio_dev);
-error_cleanup_ring:
ad7476_ring_cleanup(indio_dev);
error_disable_reg:
if (!IS_ERR(st->reg))
@@ -200,7 +190,7 @@ error_disable_reg:
error_put_reg:
if (!IS_ERR(st->reg))
regulator_put(st->reg);
- iio_free_device(indio_dev);
+ iio_device_free(indio_dev);
error_ret:
return ret;
@@ -212,13 +202,12 @@ static int ad7476_remove(struct spi_device *spi)
struct ad7476_state *st = iio_priv(indio_dev);
iio_device_unregister(indio_dev);
- iio_buffer_unregister(indio_dev);
ad7476_ring_cleanup(indio_dev);
if (!IS_ERR(st->reg)) {
regulator_disable(st->reg);
regulator_put(st->reg);
}
- iio_free_device(indio_dev);
+ iio_device_free(indio_dev);
return 0;
}
diff --git a/drivers/staging/iio/adc/ad7476_ring.c b/drivers/staging/iio/adc/ad7476_ring.c
index d6af6c05ce1c..d087b21c51f6 100644
--- a/drivers/staging/iio/adc/ad7476_ring.c
+++ b/drivers/staging/iio/adc/ad7476_ring.c
@@ -1,5 +1,5 @@
/*
- * Copyright 2010 Analog Devices Inc.
+ * Copyright 2010-2012 Analog Devices Inc.
* Copyright (C) 2008 Jonathan Cameron
*
* Licensed under the GPL-2 or later.
@@ -13,43 +13,13 @@
#include <linux/slab.h>
#include <linux/spi/spi.h>
-#include "../iio.h"
-#include "../buffer.h"
-#include "../ring_sw.h"
-#include "../trigger_consumer.h"
+#include <linux/iio/iio.h>
+#include <linux/iio/buffer.h>
+#include <linux/iio/trigger_consumer.h>
+#include <linux/iio/triggered_buffer.h>
#include "ad7476.h"
-/**
- * ad7476_ring_preenable() setup the parameters of the ring before enabling
- *
- * The complex nature of the setting of the number of bytes per datum is due
- * to this driver currently ensuring that the timestamp is stored at an 8
- * byte boundary.
- **/
-static int ad7476_ring_preenable(struct iio_dev *indio_dev)
-{
- struct ad7476_state *st = iio_priv(indio_dev);
- struct iio_buffer *ring = indio_dev->buffer;
-
- st->d_size = bitmap_weight(indio_dev->active_scan_mask,
- indio_dev->masklength) *
- st->chip_info->channel[0].scan_type.storagebits / 8;
-
- if (ring->scan_timestamp) {
- st->d_size += sizeof(s64);
-
- if (st->d_size % sizeof(s64))
- st->d_size += sizeof(s64) - (st->d_size % sizeof(s64));
- }
-
- if (indio_dev->buffer->access->set_bytes_per_datum)
- indio_dev->buffer->access->
- set_bytes_per_datum(indio_dev->buffer, st->d_size);
-
- return 0;
-}
-
static irqreturn_t ad7476_trigger_handler(int irq, void *p)
{
struct iio_poll_func *pf = p;
@@ -59,9 +29,9 @@ static irqreturn_t ad7476_trigger_handler(int irq, void *p)
__u8 *rxbuf;
int b_sent;
- rxbuf = kzalloc(st->d_size, GFP_KERNEL);
+ rxbuf = kzalloc(indio_dev->scan_bytes, GFP_KERNEL);
if (rxbuf == NULL)
- return -ENOMEM;
+ goto done;
b_sent = spi_read(st->spi, rxbuf,
st->chip_info->channel[0].scan_type.storagebits / 8);
@@ -70,8 +40,8 @@ static irqreturn_t ad7476_trigger_handler(int irq, void *p)
time_ns = iio_get_time_ns();
- if (indio_dev->buffer->scan_timestamp)
- memcpy(rxbuf + st->d_size - sizeof(s64),
+ if (indio_dev->scan_timestamp)
+ memcpy(rxbuf + indio_dev->scan_bytes - sizeof(s64),
&time_ns, sizeof(time_ns));
indio_dev->buffer->access->store_to(indio_dev->buffer, rxbuf, time_ns);
@@ -82,51 +52,13 @@ done:
return IRQ_HANDLED;
}
-static const struct iio_buffer_setup_ops ad7476_ring_setup_ops = {
- .preenable = &ad7476_ring_preenable,
- .postenable = &iio_triggered_buffer_postenable,
- .predisable = &iio_triggered_buffer_predisable,
-};
-
int ad7476_register_ring_funcs_and_init(struct iio_dev *indio_dev)
{
- struct ad7476_state *st = iio_priv(indio_dev);
- int ret = 0;
-
- indio_dev->buffer = iio_sw_rb_allocate(indio_dev);
- if (!indio_dev->buffer) {
- ret = -ENOMEM;
- goto error_ret;
- }
- indio_dev->pollfunc
- = iio_alloc_pollfunc(NULL,
- &ad7476_trigger_handler,
- IRQF_ONESHOT,
- indio_dev,
- "%s_consumer%d",
- spi_get_device_id(st->spi)->name,
- indio_dev->id);
- if (indio_dev->pollfunc == NULL) {
- ret = -ENOMEM;
- goto error_deallocate_sw_rb;
- }
-
- /* Ring buffer functions - here trigger setup related */
- indio_dev->setup_ops = &ad7476_ring_setup_ops;
- indio_dev->buffer->scan_timestamp = true;
-
- /* Flag that polled ring buffering is possible */
- indio_dev->modes |= INDIO_BUFFER_TRIGGERED;
- return 0;
-
-error_deallocate_sw_rb:
- iio_sw_rb_free(indio_dev->buffer);
-error_ret:
- return ret;
+ return iio_triggered_buffer_setup(indio_dev, NULL,
+ &ad7476_trigger_handler, NULL);
}
void ad7476_ring_cleanup(struct iio_dev *indio_dev)
{
- iio_dealloc_pollfunc(indio_dev->pollfunc);
- iio_sw_rb_free(indio_dev->buffer);
+ iio_triggered_buffer_cleanup(indio_dev);
}
diff --git a/drivers/staging/iio/adc/ad7606_core.c b/drivers/staging/iio/adc/ad7606_core.c
index 97e8d3d4471e..ccb97fecdea7 100644
--- a/drivers/staging/iio/adc/ad7606_core.c
+++ b/drivers/staging/iio/adc/ad7606_core.c
@@ -18,9 +18,9 @@
#include <linux/sched.h>
#include <linux/module.h>
-#include "../iio.h"
-#include "../sysfs.h"
-#include "../buffer.h"
+#include <linux/iio/iio.h>
+#include <linux/iio/sysfs.h>
+#include <linux/iio/buffer.h>
#include "ad7606.h"
@@ -88,7 +88,7 @@ static int ad7606_read_raw(struct iio_dev *indio_dev,
unsigned int scale_uv;
switch (m) {
- case 0:
+ case IIO_CHAN_INFO_RAW:
mutex_lock(&indio_dev->mlock);
if (iio_buffer_enabled(indio_dev))
ret = -EBUSY;
@@ -113,7 +113,7 @@ static int ad7606_read_raw(struct iio_dev *indio_dev,
static ssize_t ad7606_show_range(struct device *dev,
struct device_attribute *attr, char *buf)
{
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct ad7606_state *st = iio_priv(indio_dev);
return sprintf(buf, "%u\n", st->range);
@@ -122,7 +122,7 @@ static ssize_t ad7606_show_range(struct device *dev,
static ssize_t ad7606_store_range(struct device *dev,
struct device_attribute *attr, const char *buf, size_t count)
{
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct ad7606_state *st = iio_priv(indio_dev);
unsigned long lval;
@@ -147,7 +147,7 @@ static IIO_CONST_ATTR(in_voltage_range_available, "5000 10000");
static ssize_t ad7606_show_oversampling_ratio(struct device *dev,
struct device_attribute *attr, char *buf)
{
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct ad7606_state *st = iio_priv(indio_dev);
return sprintf(buf, "%u\n", st->oversampling);
@@ -168,7 +168,7 @@ static int ad7606_oversampling_get_index(unsigned val)
static ssize_t ad7606_store_oversampling_ratio(struct device *dev,
struct device_attribute *attr, const char *buf, size_t count)
{
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct ad7606_state *st = iio_priv(indio_dev);
unsigned long lval;
int ret;
@@ -229,14 +229,16 @@ static const struct attribute_group ad7606_attribute_group_range = {
.attrs = ad7606_attributes_range,
};
-#define AD7606_CHANNEL(num) \
- { \
- .type = IIO_VOLTAGE, \
- .indexed = 1, \
- .channel = num, \
- .address = num, \
- .scan_index = num, \
- .scan_type = IIO_ST('s', 16, 16, 0), \
+#define AD7606_CHANNEL(num) \
+ { \
+ .type = IIO_VOLTAGE, \
+ .indexed = 1, \
+ .channel = num, \
+ .address = num, \
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT | \
+ IIO_CHAN_INFO_SCALE_SHARED_BIT, \
+ .scan_index = num, \
+ .scan_type = IIO_ST('s', 16, 16, 0), \
}
static struct iio_chan_spec ad7606_8_channels[] = {
@@ -460,7 +462,7 @@ struct iio_dev *ad7606_probe(struct device *dev, int irq,
struct ad7606_platform_data *pdata = dev->platform_data;
struct ad7606_state *st;
int ret;
- struct iio_dev *indio_dev = iio_allocate_device(sizeof(*st));
+ struct iio_dev *indio_dev = iio_device_alloc(sizeof(*st));
if (indio_dev == NULL) {
ret = -ENOMEM;
@@ -531,20 +533,12 @@ struct iio_dev *ad7606_probe(struct device *dev, int irq,
if (ret)
goto error_free_irq;
- ret = iio_buffer_register(indio_dev,
- indio_dev->channels,
- indio_dev->num_channels);
- if (ret)
- goto error_cleanup_ring;
ret = iio_device_register(indio_dev);
if (ret)
goto error_unregister_ring;
return indio_dev;
error_unregister_ring:
- iio_buffer_unregister(indio_dev);
-
-error_cleanup_ring:
ad7606_ring_cleanup(indio_dev);
error_free_irq:
@@ -559,7 +553,7 @@ error_disable_reg:
error_put_reg:
if (!IS_ERR(st->reg))
regulator_put(st->reg);
- iio_free_device(indio_dev);
+ iio_device_free(indio_dev);
error_ret:
return ERR_PTR(ret);
}
@@ -569,7 +563,6 @@ int ad7606_remove(struct iio_dev *indio_dev, int irq)
struct ad7606_state *st = iio_priv(indio_dev);
iio_device_unregister(indio_dev);
- iio_buffer_unregister(indio_dev);
ad7606_ring_cleanup(indio_dev);
free_irq(irq, indio_dev);
@@ -579,7 +572,7 @@ int ad7606_remove(struct iio_dev *indio_dev, int irq)
}
ad7606_free_gpios(st);
- iio_free_device(indio_dev);
+ iio_device_free(indio_dev);
return 0;
}
diff --git a/drivers/staging/iio/adc/ad7606_par.c b/drivers/staging/iio/adc/ad7606_par.c
index bb152a8e8c92..a53faafec070 100644
--- a/drivers/staging/iio/adc/ad7606_par.c
+++ b/drivers/staging/iio/adc/ad7606_par.c
@@ -12,7 +12,7 @@
#include <linux/err.h>
#include <linux/io.h>
-#include "../iio.h"
+#include <linux/iio/iio.h>
#include "ad7606.h"
static int ad7606_par16_read_block(struct device *dev,
diff --git a/drivers/staging/iio/adc/ad7606_ring.c b/drivers/staging/iio/adc/ad7606_ring.c
index 1ef9fbcaf2de..f15afe47c20d 100644
--- a/drivers/staging/iio/adc/ad7606_ring.c
+++ b/drivers/staging/iio/adc/ad7606_ring.c
@@ -1,5 +1,5 @@
/*
- * Copyright 2011 Analog Devices Inc.
+ * Copyright 2011-2012 Analog Devices Inc.
*
* Licensed under the GPL-2.
*
@@ -11,10 +11,10 @@
#include <linux/kernel.h>
#include <linux/slab.h>
-#include "../iio.h"
-#include "../buffer.h"
-#include "../ring_sw.h"
-#include "../trigger_consumer.h"
+#include <linux/iio/iio.h>
+#include <linux/iio/buffer.h>
+#include <linux/iio/trigger_consumer.h>
+#include <linux/iio/triggered_buffer.h>
#include "ad7606.h"
@@ -51,8 +51,7 @@ static void ad7606_poll_bh_to_ring(struct work_struct *work_s)
__u8 *buf;
int ret;
- buf = kzalloc(ring->access->get_bytes_per_datum(ring),
- GFP_KERNEL);
+ buf = kzalloc(indio_dev->scan_bytes, GFP_KERNEL);
if (buf == NULL)
return;
@@ -82,9 +81,8 @@ static void ad7606_poll_bh_to_ring(struct work_struct *work_s)
time_ns = iio_get_time_ns();
- if (ring->scan_timestamp)
- *((s64 *)(buf + ring->access->get_bytes_per_datum(ring) -
- sizeof(s64))) = time_ns;
+ if (indio_dev->scan_timestamp)
+ *((s64 *)(buf + indio_dev->scan_bytes - sizeof(s64))) = time_ns;
ring->access->store_to(indio_dev->buffer, buf, time_ns);
done:
@@ -93,54 +91,18 @@ done:
kfree(buf);
}
-static const struct iio_buffer_setup_ops ad7606_ring_setup_ops = {
- .preenable = &iio_sw_buffer_preenable,
- .postenable = &iio_triggered_buffer_postenable,
- .predisable = &iio_triggered_buffer_predisable,
-};
-
int ad7606_register_ring_funcs_and_init(struct iio_dev *indio_dev)
{
struct ad7606_state *st = iio_priv(indio_dev);
- int ret;
-
- indio_dev->buffer = iio_sw_rb_allocate(indio_dev);
- if (!indio_dev->buffer) {
- ret = -ENOMEM;
- goto error_ret;
- }
-
- indio_dev->pollfunc = iio_alloc_pollfunc(&ad7606_trigger_handler_th_bh,
- &ad7606_trigger_handler_th_bh,
- 0,
- indio_dev,
- "%s_consumer%d",
- indio_dev->name,
- indio_dev->id);
- if (indio_dev->pollfunc == NULL) {
- ret = -ENOMEM;
- goto error_deallocate_sw_rb;
- }
-
- /* Ring buffer functions - here trigger setup related */
-
- indio_dev->setup_ops = &ad7606_ring_setup_ops;
- indio_dev->buffer->scan_timestamp = true ;
INIT_WORK(&st->poll_work, &ad7606_poll_bh_to_ring);
- /* Flag that polled ring buffering is possible */
- indio_dev->modes |= INDIO_BUFFER_TRIGGERED;
- return 0;
-
-error_deallocate_sw_rb:
- iio_sw_rb_free(indio_dev->buffer);
-error_ret:
- return ret;
+ return iio_triggered_buffer_setup(indio_dev,
+ &ad7606_trigger_handler_th_bh, &ad7606_trigger_handler_th_bh,
+ NULL);
}
void ad7606_ring_cleanup(struct iio_dev *indio_dev)
{
- iio_dealloc_pollfunc(indio_dev->pollfunc);
- iio_sw_rb_free(indio_dev->buffer);
+ iio_triggered_buffer_cleanup(indio_dev);
}
diff --git a/drivers/staging/iio/adc/ad7606_spi.c b/drivers/staging/iio/adc/ad7606_spi.c
index 237f1c44d296..099d347da52d 100644
--- a/drivers/staging/iio/adc/ad7606_spi.c
+++ b/drivers/staging/iio/adc/ad7606_spi.c
@@ -11,7 +11,7 @@
#include <linux/types.h>
#include <linux/err.h>
-#include "../iio.h"
+#include <linux/iio/iio.h>
#include "ad7606.h"
#define MAX_SPI_FREQ_HZ 23500000 /* VDRIVE above 4.75 V */
diff --git a/drivers/staging/iio/adc/ad7780.c b/drivers/staging/iio/adc/ad7780.c
index a13e58c814e6..1ece2ac8de56 100644
--- a/drivers/staging/iio/adc/ad7780.c
+++ b/drivers/staging/iio/adc/ad7780.c
@@ -18,8 +18,8 @@
#include <linux/gpio.h>
#include <linux/module.h>
-#include "../iio.h"
-#include "../sysfs.h"
+#include <linux/iio/iio.h>
+#include <linux/iio/sysfs.h>
#include "ad7780.h"
@@ -94,7 +94,7 @@ static int ad7780_read_raw(struct iio_dev *indio_dev,
unsigned long scale_uv;
switch (m) {
- case 0:
+ case IIO_CHAN_INFO_RAW:
mutex_lock(&indio_dev->mlock);
ret = ad7780_read(st, &smpl);
mutex_unlock(&indio_dev->mlock);
@@ -126,14 +126,34 @@ static int ad7780_read_raw(struct iio_dev *indio_dev,
static const struct ad7780_chip_info ad7780_chip_info_tbl[] = {
[ID_AD7780] = {
- .channel = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 0, 0,
- IIO_CHAN_INFO_SCALE_SHARED_BIT,
- 0, 0, IIO_ST('s', 24, 32, 8), 0),
+ .channel = {
+ .type = IIO_VOLTAGE,
+ .indexed = 1,
+ .channel = 0,
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
+ IIO_CHAN_INFO_SCALE_SHARED_BIT,
+ .scan_type = {
+ .sign = 's',
+ .realbits = 24,
+ .storagebits = 32,
+ .shift = 8,
+ },
+ },
},
[ID_AD7781] = {
- .channel = IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 0, 0,
- IIO_CHAN_INFO_SCALE_SHARED_BIT,
- 0, 0, IIO_ST('s', 20, 32, 12), 0),
+ .channel = {
+ .type = IIO_VOLTAGE,
+ .indexed = 1,
+ .channel = 0,
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
+ IIO_CHAN_INFO_SCALE_SHARED_BIT,
+ .scan_type = {
+ .sign = 's',
+ .realbits = 20,
+ .storagebits = 32,
+ .shift = 12,
+ },
+ },
},
};
@@ -167,7 +187,7 @@ static int __devinit ad7780_probe(struct spi_device *spi)
return -ENODEV;
}
- indio_dev = iio_allocate_device(sizeof(*st));
+ indio_dev = iio_device_alloc(sizeof(*st));
if (indio_dev == NULL)
return -ENOMEM;
@@ -245,7 +265,7 @@ error_put_reg:
if (!IS_ERR(st->reg))
regulator_put(st->reg);
- iio_free_device(indio_dev);
+ iio_device_free(indio_dev);
return ret;
}
@@ -262,7 +282,7 @@ static int ad7780_remove(struct spi_device *spi)
regulator_disable(st->reg);
regulator_put(st->reg);
}
- iio_free_device(indio_dev);
+ iio_device_free(indio_dev);
return 0;
}
diff --git a/drivers/staging/iio/adc/ad7793.c b/drivers/staging/iio/adc/ad7793.c
index 84ecde1ad042..76fdd7145fc5 100644
--- a/drivers/staging/iio/adc/ad7793.c
+++ b/drivers/staging/iio/adc/ad7793.c
@@ -1,7 +1,7 @@
/*
* AD7792/AD7793 SPI ADC driver
*
- * Copyright 2011 Analog Devices Inc.
+ * Copyright 2011-2012 Analog Devices Inc.
*
* Licensed under the GPL-2.
*/
@@ -18,12 +18,12 @@
#include <linux/delay.h>
#include <linux/module.h>
-#include "../iio.h"
-#include "../sysfs.h"
-#include "../buffer.h"
-#include "../ring_sw.h"
-#include "../trigger.h"
-#include "../trigger_consumer.h"
+#include <linux/iio/iio.h>
+#include <linux/iio/sysfs.h>
+#include <linux/iio/buffer.h>
+#include <linux/iio/trigger.h>
+#include <linux/iio/trigger_consumer.h>
+#include <linux/iio/triggered_buffer.h>
#include "ad7793.h"
@@ -52,8 +52,7 @@ struct ad7793_state {
u16 mode;
u16 conf;
u32 scale_avail[8][2];
- /* Note this uses fact that 8 the mask always fits in a long */
- unsigned long available_scan_masks[7];
+
/*
* DMA (thus cache coherency maintenance) requires the
* transfer buffers to live in their own cache lines.
@@ -319,31 +318,18 @@ out:
static int ad7793_ring_preenable(struct iio_dev *indio_dev)
{
struct ad7793_state *st = iio_priv(indio_dev);
- struct iio_buffer *ring = indio_dev->buffer;
- size_t d_size;
unsigned channel;
+ int ret;
if (bitmap_empty(indio_dev->active_scan_mask, indio_dev->masklength))
return -EINVAL;
+ ret = iio_sw_buffer_preenable(indio_dev);
+ if (ret < 0)
+ return ret;
channel = find_first_bit(indio_dev->active_scan_mask,
indio_dev->masklength);
- d_size = bitmap_weight(indio_dev->active_scan_mask,
- indio_dev->masklength) *
- indio_dev->channels[0].scan_type.storagebits / 8;
-
- if (ring->scan_timestamp) {
- d_size += sizeof(s64);
-
- if (d_size % sizeof(s64))
- d_size += sizeof(s64) - (d_size % sizeof(s64));
- }
-
- if (indio_dev->buffer->access->set_bytes_per_datum)
- indio_dev->buffer->access->
- set_bytes_per_datum(indio_dev->buffer, d_size);
-
st->mode = (st->mode & ~AD7793_MODE_SEL(-1)) |
AD7793_MODE_SEL(AD7793_MODE_CONT);
st->conf = (st->conf & ~AD7793_CONF_CHAN(-1)) |
@@ -399,7 +385,7 @@ static irqreturn_t ad7793_trigger_handler(int irq, void *p)
indio_dev->channels[0].scan_type.realbits/8);
/* Guaranteed to be aligned with 8 byte boundary */
- if (ring->scan_timestamp)
+ if (indio_dev->scan_timestamp)
dat64[1] = pf->timestamp;
ring->access->store_to(ring, (u8 *)dat64, pf->timestamp);
@@ -416,45 +402,18 @@ static const struct iio_buffer_setup_ops ad7793_ring_setup_ops = {
.postenable = &iio_triggered_buffer_postenable,
.predisable = &iio_triggered_buffer_predisable,
.postdisable = &ad7793_ring_postdisable,
+ .validate_scan_mask = &iio_validate_scan_mask_onehot,
};
static int ad7793_register_ring_funcs_and_init(struct iio_dev *indio_dev)
{
- int ret;
-
- indio_dev->buffer = iio_sw_rb_allocate(indio_dev);
- if (!indio_dev->buffer) {
- ret = -ENOMEM;
- goto error_ret;
- }
- indio_dev->pollfunc = iio_alloc_pollfunc(&iio_pollfunc_store_time,
- &ad7793_trigger_handler,
- IRQF_ONESHOT,
- indio_dev,
- "ad7793_consumer%d",
- indio_dev->id);
- if (indio_dev->pollfunc == NULL) {
- ret = -ENOMEM;
- goto error_deallocate_sw_rb;
- }
-
- /* Ring buffer functions - here trigger setup related */
- indio_dev->setup_ops = &ad7793_ring_setup_ops;
-
- /* Flag that polled ring buffering is possible */
- indio_dev->modes |= INDIO_BUFFER_TRIGGERED;
- return 0;
-
-error_deallocate_sw_rb:
- iio_sw_rb_free(indio_dev->buffer);
-error_ret:
- return ret;
+ return iio_triggered_buffer_setup(indio_dev, &iio_pollfunc_store_time,
+ &ad7793_trigger_handler, &ad7793_ring_setup_ops);
}
static void ad7793_ring_cleanup(struct iio_dev *indio_dev)
{
- iio_dealloc_pollfunc(indio_dev->pollfunc);
- iio_sw_rb_free(indio_dev->buffer);
+ iio_triggered_buffer_cleanup(indio_dev);
}
/**
@@ -482,7 +441,7 @@ static int ad7793_probe_trigger(struct iio_dev *indio_dev)
struct ad7793_state *st = iio_priv(indio_dev);
int ret;
- st->trig = iio_allocate_trigger("%s-dev%d",
+ st->trig = iio_trigger_alloc("%s-dev%d",
spi_get_device_id(st->spi)->name,
indio_dev->id);
if (st->trig == NULL) {
@@ -516,7 +475,7 @@ static int ad7793_probe_trigger(struct iio_dev *indio_dev)
error_free_irq:
free_irq(st->spi->irq, indio_dev);
error_free_trig:
- iio_free_trigger(st->trig);
+ iio_trigger_free(st->trig);
error_ret:
return ret;
}
@@ -527,7 +486,7 @@ static void ad7793_remove_trigger(struct iio_dev *indio_dev)
iio_trigger_unregister(st->trig);
free_irq(st->spi->irq, indio_dev);
- iio_free_trigger(st->trig);
+ iio_trigger_free(st->trig);
}
static const u16 sample_freq_avail[16] = {0, 470, 242, 123, 62, 50, 39, 33, 19,
@@ -537,7 +496,7 @@ static ssize_t ad7793_read_frequency(struct device *dev,
struct device_attribute *attr,
char *buf)
{
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct ad7793_state *st = iio_priv(indio_dev);
return sprintf(buf, "%d\n",
@@ -549,7 +508,7 @@ static ssize_t ad7793_write_frequency(struct device *dev,
const char *buf,
size_t len)
{
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct ad7793_state *st = iio_priv(indio_dev);
long lval;
int i, ret;
@@ -591,7 +550,7 @@ static IIO_CONST_ATTR_SAMP_FREQ_AVAIL(
static ssize_t ad7793_show_scale_available(struct device *dev,
struct device_attribute *attr, char *buf)
{
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct ad7793_state *st = iio_priv(indio_dev);
int i, len = 0;
@@ -630,7 +589,7 @@ static int ad7793_read_raw(struct iio_dev *indio_dev,
bool unipolar = !!(st->conf & AD7793_CONF_UNIPOLAR);
switch (m) {
- case 0:
+ case IIO_CHAN_INFO_RAW:
mutex_lock(&indio_dev->mlock);
if (iio_buffer_enabled(indio_dev))
ret = -EBUSY;
@@ -760,7 +719,8 @@ static const struct ad7793_chip_info ad7793_chip_info_tbl[] = {
.channel = 0,
.channel2 = 0,
.address = AD7793_CH_AIN1P_AIN1M,
- .info_mask = IIO_CHAN_INFO_SCALE_SHARED_BIT,
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
+ IIO_CHAN_INFO_SCALE_SHARED_BIT,
.scan_index = 0,
.scan_type = IIO_ST('s', 24, 32, 0)
},
@@ -771,7 +731,8 @@ static const struct ad7793_chip_info ad7793_chip_info_tbl[] = {
.channel = 1,
.channel2 = 1,
.address = AD7793_CH_AIN2P_AIN2M,
- .info_mask = IIO_CHAN_INFO_SCALE_SHARED_BIT,
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
+ IIO_CHAN_INFO_SCALE_SHARED_BIT,
.scan_index = 1,
.scan_type = IIO_ST('s', 24, 32, 0)
},
@@ -782,7 +743,8 @@ static const struct ad7793_chip_info ad7793_chip_info_tbl[] = {
.channel = 2,
.channel2 = 2,
.address = AD7793_CH_AIN3P_AIN3M,
- .info_mask = IIO_CHAN_INFO_SCALE_SHARED_BIT,
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
+ IIO_CHAN_INFO_SCALE_SHARED_BIT,
.scan_index = 2,
.scan_type = IIO_ST('s', 24, 32, 0)
},
@@ -794,8 +756,9 @@ static const struct ad7793_chip_info ad7793_chip_info_tbl[] = {
.channel = 2,
.channel2 = 2,
.address = AD7793_CH_AIN1M_AIN1M,
- .info_mask = IIO_CHAN_INFO_SCALE_SHARED_BIT,
- .scan_index = 2,
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
+ IIO_CHAN_INFO_SCALE_SHARED_BIT,
+ .scan_index = 3,
.scan_type = IIO_ST('s', 24, 32, 0)
},
.channel[4] = {
@@ -803,7 +766,8 @@ static const struct ad7793_chip_info ad7793_chip_info_tbl[] = {
.indexed = 1,
.channel = 0,
.address = AD7793_CH_TEMP,
- .info_mask = IIO_CHAN_INFO_SCALE_SEPARATE_BIT,
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
+ IIO_CHAN_INFO_SCALE_SEPARATE_BIT,
.scan_index = 4,
.scan_type = IIO_ST('s', 24, 32, 0),
},
@@ -813,7 +777,8 @@ static const struct ad7793_chip_info ad7793_chip_info_tbl[] = {
.indexed = 1,
.channel = 4,
.address = AD7793_CH_AVDD_MONITOR,
- .info_mask = IIO_CHAN_INFO_SCALE_SEPARATE_BIT,
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
+ IIO_CHAN_INFO_SCALE_SEPARATE_BIT,
.scan_index = 5,
.scan_type = IIO_ST('s', 24, 32, 0),
},
@@ -827,7 +792,8 @@ static const struct ad7793_chip_info ad7793_chip_info_tbl[] = {
.channel = 0,
.channel2 = 0,
.address = AD7793_CH_AIN1P_AIN1M,
- .info_mask = IIO_CHAN_INFO_SCALE_SHARED_BIT,
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
+ IIO_CHAN_INFO_SCALE_SHARED_BIT,
.scan_index = 0,
.scan_type = IIO_ST('s', 16, 32, 0)
},
@@ -838,7 +804,8 @@ static const struct ad7793_chip_info ad7793_chip_info_tbl[] = {
.channel = 1,
.channel2 = 1,
.address = AD7793_CH_AIN2P_AIN2M,
- .info_mask = IIO_CHAN_INFO_SCALE_SHARED_BIT,
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
+ IIO_CHAN_INFO_SCALE_SHARED_BIT,
.scan_index = 1,
.scan_type = IIO_ST('s', 16, 32, 0)
},
@@ -849,7 +816,8 @@ static const struct ad7793_chip_info ad7793_chip_info_tbl[] = {
.channel = 2,
.channel2 = 2,
.address = AD7793_CH_AIN3P_AIN3M,
- .info_mask = IIO_CHAN_INFO_SCALE_SHARED_BIT,
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
+ IIO_CHAN_INFO_SCALE_SHARED_BIT,
.scan_index = 2,
.scan_type = IIO_ST('s', 16, 32, 0)
},
@@ -861,8 +829,9 @@ static const struct ad7793_chip_info ad7793_chip_info_tbl[] = {
.channel = 2,
.channel2 = 2,
.address = AD7793_CH_AIN1M_AIN1M,
- .info_mask = IIO_CHAN_INFO_SCALE_SHARED_BIT,
- .scan_index = 2,
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
+ IIO_CHAN_INFO_SCALE_SHARED_BIT,
+ .scan_index = 3,
.scan_type = IIO_ST('s', 16, 32, 0)
},
.channel[4] = {
@@ -870,7 +839,8 @@ static const struct ad7793_chip_info ad7793_chip_info_tbl[] = {
.indexed = 1,
.channel = 0,
.address = AD7793_CH_TEMP,
- .info_mask = IIO_CHAN_INFO_SCALE_SEPARATE_BIT,
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
+ IIO_CHAN_INFO_SCALE_SEPARATE_BIT,
.scan_index = 4,
.scan_type = IIO_ST('s', 16, 32, 0),
},
@@ -880,7 +850,8 @@ static const struct ad7793_chip_info ad7793_chip_info_tbl[] = {
.indexed = 1,
.channel = 4,
.address = AD7793_CH_AVDD_MONITOR,
- .info_mask = IIO_CHAN_INFO_SCALE_SEPARATE_BIT,
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
+ IIO_CHAN_INFO_SCALE_SEPARATE_BIT,
.scan_index = 5,
.scan_type = IIO_ST('s', 16, 32, 0),
},
@@ -893,7 +864,7 @@ static int __devinit ad7793_probe(struct spi_device *spi)
struct ad7793_platform_data *pdata = spi->dev.platform_data;
struct ad7793_state *st;
struct iio_dev *indio_dev;
- int ret, i, voltage_uv = 0;
+ int ret, voltage_uv = 0;
if (!pdata) {
dev_err(&spi->dev, "no platform data?\n");
@@ -905,7 +876,7 @@ static int __devinit ad7793_probe(struct spi_device *spi)
return -ENODEV;
}
- indio_dev = iio_allocate_device(sizeof(*st));
+ indio_dev = iio_device_alloc(sizeof(*st));
if (indio_dev == NULL)
return -ENOMEM;
@@ -939,17 +910,9 @@ static int __devinit ad7793_probe(struct spi_device *spi)
indio_dev->name = spi_get_device_id(spi)->name;
indio_dev->modes = INDIO_DIRECT_MODE;
indio_dev->channels = st->chip_info->channel;
- indio_dev->available_scan_masks = st->available_scan_masks;
indio_dev->num_channels = 7;
indio_dev->info = &ad7793_info;
- for (i = 0; i < indio_dev->num_channels; i++) {
- set_bit(i, &st->available_scan_masks[i]);
- set_bit(indio_dev->
- channels[indio_dev->num_channels - 1].scan_index,
- &st->available_scan_masks[i]);
- }
-
init_waitqueue_head(&st->wq_data_avail);
ret = ad7793_register_ring_funcs_and_init(indio_dev);
@@ -960,24 +923,16 @@ static int __devinit ad7793_probe(struct spi_device *spi)
if (ret)
goto error_unreg_ring;
- ret = iio_buffer_register(indio_dev,
- indio_dev->channels,
- indio_dev->num_channels);
- if (ret)
- goto error_remove_trigger;
-
ret = ad7793_setup(st);
if (ret)
- goto error_uninitialize_ring;
+ goto error_remove_trigger;
ret = iio_device_register(indio_dev);
if (ret)
- goto error_uninitialize_ring;
+ goto error_remove_trigger;
return 0;
-error_uninitialize_ring:
- iio_buffer_unregister(indio_dev);
error_remove_trigger:
ad7793_remove_trigger(indio_dev);
error_unreg_ring:
@@ -989,7 +944,7 @@ error_put_reg:
if (!IS_ERR(st->reg))
regulator_put(st->reg);
- iio_free_device(indio_dev);
+ iio_device_free(indio_dev);
return ret;
}
@@ -1000,7 +955,6 @@ static int ad7793_remove(struct spi_device *spi)
struct ad7793_state *st = iio_priv(indio_dev);
iio_device_unregister(indio_dev);
- iio_buffer_unregister(indio_dev);
ad7793_remove_trigger(indio_dev);
ad7793_ring_cleanup(indio_dev);
@@ -1009,7 +963,7 @@ static int ad7793_remove(struct spi_device *spi)
regulator_put(st->reg);
}
- iio_free_device(indio_dev);
+ iio_device_free(indio_dev);
return 0;
}
diff --git a/drivers/staging/iio/adc/ad7816.c b/drivers/staging/iio/adc/ad7816.c
index 52b720e2b03a..c5fb9476a2d1 100644
--- a/drivers/staging/iio/adc/ad7816.c
+++ b/drivers/staging/iio/adc/ad7816.c
@@ -16,9 +16,9 @@
#include <linux/spi/spi.h>
#include <linux/module.h>
-#include "../iio.h"
-#include "../sysfs.h"
-#include "../events.h"
+#include <linux/iio/iio.h>
+#include <linux/iio/sysfs.h>
+#include <linux/iio/events.h>
/*
* AD7816 config masks
@@ -113,7 +113,7 @@ static ssize_t ad7816_show_mode(struct device *dev,
struct device_attribute *attr,
char *buf)
{
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct ad7816_chip_info *chip = iio_priv(indio_dev);
if (chip->mode)
@@ -127,7 +127,7 @@ static ssize_t ad7816_store_mode(struct device *dev,
const char *buf,
size_t len)
{
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct ad7816_chip_info *chip = iio_priv(indio_dev);
if (strcmp(buf, "full")) {
@@ -159,7 +159,7 @@ static ssize_t ad7816_show_channel(struct device *dev,
struct device_attribute *attr,
char *buf)
{
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct ad7816_chip_info *chip = iio_priv(indio_dev);
return sprintf(buf, "%d\n", chip->channel_id);
@@ -170,7 +170,7 @@ static ssize_t ad7816_store_channel(struct device *dev,
const char *buf,
size_t len)
{
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct ad7816_chip_info *chip = iio_priv(indio_dev);
unsigned long data;
int ret;
@@ -208,7 +208,7 @@ static ssize_t ad7816_show_value(struct device *dev,
struct device_attribute *attr,
char *buf)
{
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct ad7816_chip_info *chip = iio_priv(indio_dev);
u16 data;
s8 value;
@@ -263,7 +263,7 @@ static ssize_t ad7816_show_oti(struct device *dev,
struct device_attribute *attr,
char *buf)
{
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct ad7816_chip_info *chip = iio_priv(indio_dev);
int value;
@@ -284,7 +284,7 @@ static inline ssize_t ad7816_set_oti(struct device *dev,
const char *buf,
size_t len)
{
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct ad7816_chip_info *chip = iio_priv(indio_dev);
long value;
u8 data;
@@ -354,7 +354,7 @@ static int __devinit ad7816_probe(struct spi_device *spi_dev)
return -EINVAL;
}
- indio_dev = iio_allocate_device(sizeof(*chip));
+ indio_dev = iio_device_alloc(sizeof(*chip));
if (indio_dev == NULL) {
ret = -ENOMEM;
goto error_ret;
@@ -402,7 +402,7 @@ static int __devinit ad7816_probe(struct spi_device *spi_dev)
ret = request_threaded_irq(spi_dev->irq,
NULL,
&ad7816_event_handler,
- IRQF_TRIGGER_LOW,
+ IRQF_TRIGGER_LOW | IRQF_ONESHOT,
indio_dev->name,
indio_dev);
if (ret)
@@ -426,7 +426,7 @@ error_free_gpio_convert:
error_free_gpio_rdwr:
gpio_free(chip->rdwr_pin);
error_free_device:
- iio_free_device(indio_dev);
+ iio_device_free(indio_dev);
error_ret:
return ret;
}
@@ -443,7 +443,7 @@ static int __devexit ad7816_remove(struct spi_device *spi_dev)
gpio_free(chip->busy_pin);
gpio_free(chip->convert_pin);
gpio_free(chip->rdwr_pin);
- iio_free_device(indio_dev);
+ iio_device_free(indio_dev);
return 0;
}
diff --git a/drivers/staging/iio/adc/ad7887.h b/drivers/staging/iio/adc/ad7887.h
index bc53b6532121..2e09e54fc9c5 100644
--- a/drivers/staging/iio/adc/ad7887.h
+++ b/drivers/staging/iio/adc/ad7887.h
@@ -63,7 +63,6 @@ struct ad7887_state {
struct spi_device *spi;
const struct ad7887_chip_info *chip_info;
struct regulator *reg;
- size_t d_size;
u16 int_vref_mv;
struct spi_transfer xfer[4];
struct spi_message msg[3];
diff --git a/drivers/staging/iio/adc/ad7887_core.c b/drivers/staging/iio/adc/ad7887_core.c
index e9bbc3eed15d..397b84947155 100644
--- a/drivers/staging/iio/adc/ad7887_core.c
+++ b/drivers/staging/iio/adc/ad7887_core.c
@@ -15,9 +15,9 @@
#include <linux/err.h>
#include <linux/module.h>
-#include "../iio.h"
-#include "../sysfs.h"
-#include "../buffer.h"
+#include <linux/iio/iio.h>
+#include <linux/iio/sysfs.h>
+#include <linux/iio/buffer.h>
#include "ad7887.h"
@@ -42,7 +42,7 @@ static int ad7887_read_raw(struct iio_dev *indio_dev,
unsigned int scale_uv;
switch (m) {
- case 0:
+ case IIO_CHAN_INFO_RAW:
mutex_lock(&indio_dev->mlock);
if (iio_buffer_enabled(indio_dev))
ret = -EBUSY;
@@ -75,7 +75,8 @@ static const struct ad7887_chip_info ad7887_chip_info_tbl[] = {
.type = IIO_VOLTAGE,
.indexed = 1,
.channel = 1,
- .info_mask = IIO_CHAN_INFO_SCALE_SHARED_BIT,
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
+ IIO_CHAN_INFO_SCALE_SHARED_BIT,
.address = 1,
.scan_index = 1,
.scan_type = IIO_ST('u', 12, 16, 0),
@@ -84,7 +85,8 @@ static const struct ad7887_chip_info ad7887_chip_info_tbl[] = {
.type = IIO_VOLTAGE,
.indexed = 1,
.channel = 0,
- .info_mask = IIO_CHAN_INFO_SCALE_SHARED_BIT,
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
+ IIO_CHAN_INFO_SCALE_SHARED_BIT,
.address = 0,
.scan_index = 0,
.scan_type = IIO_ST('u', 12, 16, 0),
@@ -104,7 +106,7 @@ static int __devinit ad7887_probe(struct spi_device *spi)
struct ad7887_platform_data *pdata = spi->dev.platform_data;
struct ad7887_state *st;
int ret, voltage_uv = 0;
- struct iio_dev *indio_dev = iio_allocate_device(sizeof(*st));
+ struct iio_dev *indio_dev = iio_device_alloc(sizeof(*st));
if (indio_dev == NULL)
return -ENOMEM;
@@ -199,20 +201,12 @@ static int __devinit ad7887_probe(struct spi_device *spi)
if (ret)
goto error_disable_reg;
- ret = iio_buffer_register(indio_dev,
- indio_dev->channels,
- indio_dev->num_channels);
- if (ret)
- goto error_cleanup_ring;
-
ret = iio_device_register(indio_dev);
if (ret)
goto error_unregister_ring;
return 0;
error_unregister_ring:
- iio_buffer_unregister(indio_dev);
-error_cleanup_ring:
ad7887_ring_cleanup(indio_dev);
error_disable_reg:
if (!IS_ERR(st->reg))
@@ -220,7 +214,7 @@ error_disable_reg:
error_put_reg:
if (!IS_ERR(st->reg))
regulator_put(st->reg);
- iio_free_device(indio_dev);
+ iio_device_free(indio_dev);
return ret;
}
@@ -231,13 +225,12 @@ static int ad7887_remove(struct spi_device *spi)
struct ad7887_state *st = iio_priv(indio_dev);
iio_device_unregister(indio_dev);
- iio_buffer_unregister(indio_dev);
ad7887_ring_cleanup(indio_dev);
if (!IS_ERR(st->reg)) {
regulator_disable(st->reg);
regulator_put(st->reg);
}
- iio_free_device(indio_dev);
+ iio_device_free(indio_dev);
return 0;
}
diff --git a/drivers/staging/iio/adc/ad7887_ring.c b/drivers/staging/iio/adc/ad7887_ring.c
index d1809079b63d..c76fdb5081c2 100644
--- a/drivers/staging/iio/adc/ad7887_ring.c
+++ b/drivers/staging/iio/adc/ad7887_ring.c
@@ -1,5 +1,5 @@
/*
- * Copyright 2010-2011 Analog Devices Inc.
+ * Copyright 2010-2012 Analog Devices Inc.
* Copyright (C) 2008 Jonathan Cameron
*
* Licensed under the GPL-2.
@@ -12,10 +12,10 @@
#include <linux/slab.h>
#include <linux/spi/spi.h>
-#include "../iio.h"
-#include "../buffer.h"
-#include "../ring_sw.h"
-#include "../trigger_consumer.h"
+#include <linux/iio/iio.h>
+#include <linux/iio/buffer.h>
+#include <linux/iio/trigger_consumer.h>
+#include <linux/iio/triggered_buffer.h>
#include "ad7887.h"
@@ -29,22 +29,11 @@
static int ad7887_ring_preenable(struct iio_dev *indio_dev)
{
struct ad7887_state *st = iio_priv(indio_dev);
- struct iio_buffer *ring = indio_dev->buffer;
-
- st->d_size = bitmap_weight(indio_dev->active_scan_mask,
- indio_dev->masklength) *
- st->chip_info->channel[0].scan_type.storagebits / 8;
-
- if (ring->scan_timestamp) {
- st->d_size += sizeof(s64);
-
- if (st->d_size % sizeof(s64))
- st->d_size += sizeof(s64) - (st->d_size % sizeof(s64));
- }
+ int ret;
- if (indio_dev->buffer->access->set_bytes_per_datum)
- indio_dev->buffer->access->
- set_bytes_per_datum(indio_dev->buffer, st->d_size);
+ ret = iio_sw_buffer_preenable(indio_dev);
+ if (ret < 0)
+ return ret;
/* We know this is a single long so can 'cheat' */
switch (*indio_dev->active_scan_mask) {
@@ -83,7 +72,6 @@ static irqreturn_t ad7887_trigger_handler(int irq, void *p)
struct iio_poll_func *pf = p;
struct iio_dev *indio_dev = pf->indio_dev;
struct ad7887_state *st = iio_priv(indio_dev);
- struct iio_buffer *ring = indio_dev->buffer;
s64 time_ns;
__u8 *buf;
int b_sent;
@@ -92,9 +80,9 @@ static irqreturn_t ad7887_trigger_handler(int irq, void *p)
indio_dev->masklength) *
st->chip_info->channel[0].scan_type.storagebits / 8;
- buf = kzalloc(st->d_size, GFP_KERNEL);
+ buf = kzalloc(indio_dev->scan_bytes, GFP_KERNEL);
if (buf == NULL)
- return -ENOMEM;
+ goto done;
b_sent = spi_sync(st->spi, st->ring_msg);
if (b_sent)
@@ -103,8 +91,8 @@ static irqreturn_t ad7887_trigger_handler(int irq, void *p)
time_ns = iio_get_time_ns();
memcpy(buf, st->data, bytes);
- if (ring->scan_timestamp)
- memcpy(buf + st->d_size - sizeof(s64),
+ if (indio_dev->scan_timestamp)
+ memcpy(buf + indio_dev->scan_bytes - sizeof(s64),
&time_ns, sizeof(time_ns));
indio_dev->buffer->access->store_to(indio_dev->buffer, buf, time_ns);
@@ -124,38 +112,11 @@ static const struct iio_buffer_setup_ops ad7887_ring_setup_ops = {
int ad7887_register_ring_funcs_and_init(struct iio_dev *indio_dev)
{
- int ret;
-
- indio_dev->buffer = iio_sw_rb_allocate(indio_dev);
- if (!indio_dev->buffer) {
- ret = -ENOMEM;
- goto error_ret;
- }
- indio_dev->pollfunc = iio_alloc_pollfunc(&iio_pollfunc_store_time,
- &ad7887_trigger_handler,
- IRQF_ONESHOT,
- indio_dev,
- "ad7887_consumer%d",
- indio_dev->id);
- if (indio_dev->pollfunc == NULL) {
- ret = -ENOMEM;
- goto error_deallocate_sw_rb;
- }
- /* Ring buffer functions - here trigger setup related */
- indio_dev->setup_ops = &ad7887_ring_setup_ops;
-
- /* Flag that polled ring buffering is possible */
- indio_dev->modes |= INDIO_BUFFER_TRIGGERED;
- return 0;
-
-error_deallocate_sw_rb:
- iio_sw_rb_free(indio_dev->buffer);
-error_ret:
- return ret;
+ return iio_triggered_buffer_setup(indio_dev, &iio_pollfunc_store_time,
+ &ad7887_trigger_handler, &ad7887_ring_setup_ops);
}
void ad7887_ring_cleanup(struct iio_dev *indio_dev)
{
- iio_dealloc_pollfunc(indio_dev->pollfunc);
- iio_sw_rb_free(indio_dev->buffer);
+ iio_triggered_buffer_cleanup(indio_dev);
}
diff --git a/drivers/staging/iio/adc/ad799x.h b/drivers/staging/iio/adc/ad799x.h
index 356f690a76fb..3e363c4ba211 100644
--- a/drivers/staging/iio/adc/ad799x.h
+++ b/drivers/staging/iio/adc/ad799x.h
@@ -104,7 +104,6 @@ struct ad799x_chip_info {
struct ad799x_state {
struct i2c_client *client;
const struct ad799x_chip_info *chip_info;
- size_t d_size;
struct iio_trigger *trig;
struct regulator *reg;
u16 int_vref_mv;
@@ -121,8 +120,6 @@ struct ad799x_platform_data {
u16 vref_mv;
};
-int ad7997_8_set_scan_mode(struct ad799x_state *st, unsigned mask);
-
#ifdef CONFIG_AD799X_RING_BUFFER
int ad799x_register_ring_funcs_and_init(struct iio_dev *indio_dev);
void ad799x_ring_cleanup(struct iio_dev *indio_dev);
diff --git a/drivers/staging/iio/adc/ad799x_core.c b/drivers/staging/iio/adc/ad799x_core.c
index a8458669350f..990050700afc 100644
--- a/drivers/staging/iio/adc/ad799x_core.c
+++ b/drivers/staging/iio/adc/ad799x_core.c
@@ -33,10 +33,10 @@
#include <linux/err.h>
#include <linux/module.h>
-#include "../iio.h"
-#include "../sysfs.h"
-#include "../events.h"
-#include "../buffer.h"
+#include <linux/iio/iio.h>
+#include <linux/iio/sysfs.h>
+#include <linux/iio/events.h>
+#include <linux/iio/buffer.h>
#include "ad799x.h"
@@ -99,10 +99,21 @@ static int ad799x_i2c_write8(struct ad799x_state *st, u8 reg, u8 data)
return ret;
}
-int ad7997_8_set_scan_mode(struct ad799x_state *st, unsigned mask)
+static int ad7997_8_update_scan_mode(struct iio_dev *indio_dev,
+ const unsigned long *scan_mask)
{
- return ad799x_i2c_write16(st, AD7998_CONF_REG,
- st->config | (mask << AD799X_CHANNEL_SHIFT));
+ struct ad799x_state *st = iio_priv(indio_dev);
+
+ switch (st->id) {
+ case ad7997:
+ case ad7998:
+ return ad799x_i2c_write16(st, AD7998_CONF_REG,
+ st->config | (*scan_mask << AD799X_CHANNEL_SHIFT));
+ default:
+ break;
+ }
+
+ return 0;
}
static int ad799x_scan_direct(struct ad799x_state *st, unsigned ch)
@@ -148,7 +159,7 @@ static int ad799x_read_raw(struct iio_dev *indio_dev,
unsigned int scale_uv;
switch (m) {
- case 0:
+ case IIO_CHAN_INFO_RAW:
mutex_lock(&indio_dev->mlock);
if (iio_buffer_enabled(indio_dev))
ret = -EBUSY;
@@ -182,7 +193,7 @@ static ssize_t ad799x_read_frequency(struct device *dev,
struct device_attribute *attr,
char *buf)
{
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct ad799x_state *st = iio_priv(indio_dev);
int ret;
@@ -201,7 +212,7 @@ static ssize_t ad799x_write_frequency(struct device *dev,
const char *buf,
size_t len)
{
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct ad799x_state *st = iio_priv(indio_dev);
long val;
@@ -294,7 +305,7 @@ static ssize_t ad799x_read_channel_config(struct device *dev,
struct device_attribute *attr,
char *buf)
{
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct ad799x_state *st = iio_priv(indio_dev);
struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
@@ -312,7 +323,7 @@ static ssize_t ad799x_write_channel_config(struct device *dev,
const char *buf,
size_t len)
{
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct ad799x_state *st = iio_priv(indio_dev);
struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
@@ -339,10 +350,10 @@ static irqreturn_t ad799x_event_handler(int irq, void *private)
ret = ad799x_i2c_read8(st, AD7998_ALERT_STAT_REG, &status);
if (ret)
- return ret;
+ goto done;
if (!status)
- return -EIO;
+ goto done;
ad799x_i2c_write8(st, AD7998_ALERT_STAT_REG, AD7998_ALERT_STAT_CLEAR);
@@ -361,6 +372,7 @@ static irqreturn_t ad799x_event_handler(int irq, void *private)
iio_get_time_ns());
}
+done:
return IRQ_HANDLED;
}
@@ -442,6 +454,7 @@ static const struct iio_info ad7993_4_7_8_info = {
.read_event_value = &ad799x_read_event_value,
.write_event_value = &ad799x_write_event_value,
.driver_module = THIS_MODULE,
+ .update_scan_mode = ad7997_8_update_scan_mode,
};
#define AD799X_EV_MASK (IIO_EV_BIT(IIO_EV_TYPE_THRESH, IIO_EV_DIR_RISING) | \
@@ -454,6 +467,7 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = {
.type = IIO_VOLTAGE,
.indexed = 1,
.channel = 0,
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT,
.scan_index = 0,
.scan_type = IIO_ST('u', 12, 16, 0),
},
@@ -461,6 +475,7 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = {
.type = IIO_VOLTAGE,
.indexed = 1,
.channel = 1,
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT,
.scan_index = 1,
.scan_type = IIO_ST('u', 12, 16, 0),
},
@@ -468,6 +483,7 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = {
.type = IIO_VOLTAGE,
.indexed = 1,
.channel = 2,
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT,
.scan_index = 2,
.scan_type = IIO_ST('u', 12, 16, 0),
},
@@ -475,6 +491,7 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = {
.type = IIO_VOLTAGE,
.indexed = 1,
.channel = 3,
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT,
.scan_index = 3,
.scan_type = IIO_ST('u', 12, 16, 0),
},
@@ -490,6 +507,7 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = {
.type = IIO_VOLTAGE,
.indexed = 1,
.channel = 0,
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT,
.scan_index = 0,
.scan_type = IIO_ST('u', 10, 16, 2),
},
@@ -497,6 +515,7 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = {
.type = IIO_VOLTAGE,
.indexed = 1,
.channel = 1,
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT,
.scan_index = 1,
.scan_type = IIO_ST('u', 10, 16, 2),
},
@@ -504,6 +523,7 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = {
.type = IIO_VOLTAGE,
.indexed = 1,
.channel = 2,
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT,
.scan_index = 2,
.scan_type = IIO_ST('u', 10, 16, 2),
},
@@ -511,6 +531,7 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = {
.type = IIO_VOLTAGE,
.indexed = 1,
.channel = 3,
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT,
.scan_index = 3,
.scan_type = IIO_ST('u', 10, 16, 2),
},
@@ -526,6 +547,7 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = {
.type = IIO_VOLTAGE,
.indexed = 1,
.channel = 0,
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT,
.scan_index = 0,
.scan_type = IIO_ST('u', 8, 16, 4),
},
@@ -533,6 +555,7 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = {
.type = IIO_VOLTAGE,
.indexed = 1,
.channel = 1,
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT,
.scan_index = 1,
.scan_type = IIO_ST('u', 8, 16, 4),
},
@@ -540,6 +563,7 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = {
.type = IIO_VOLTAGE,
.indexed = 1,
.channel = 2,
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT,
.scan_index = 2,
.scan_type = IIO_ST('u', 8, 16, 4),
},
@@ -547,6 +571,7 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = {
.type = IIO_VOLTAGE,
.indexed = 1,
.channel = 3,
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT,
.scan_index = 3,
.scan_type = IIO_ST('u', 8, 16, 4),
},
@@ -562,6 +587,7 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = {
.type = IIO_VOLTAGE,
.indexed = 1,
.channel = 0,
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT,
.scan_index = 0,
.scan_type = IIO_ST('u', 12, 16, 0),
.event_mask = AD799X_EV_MASK,
@@ -570,6 +596,7 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = {
.type = IIO_VOLTAGE,
.indexed = 1,
.channel = 1,
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT,
.scan_index = 1,
.scan_type = IIO_ST('u', 12, 16, 0),
.event_mask = AD799X_EV_MASK,
@@ -587,6 +614,7 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = {
.type = IIO_VOLTAGE,
.indexed = 1,
.channel = 0,
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT,
.scan_index = 0,
.scan_type = IIO_ST('u', 10, 16, 2),
.event_mask = AD799X_EV_MASK,
@@ -596,6 +624,7 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = {
.indexed = 1,
.channel = 1,
.scan_index = 1,
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT,
.scan_type = IIO_ST('u', 10, 16, 2),
.event_mask = AD799X_EV_MASK,
},
@@ -603,6 +632,7 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = {
.type = IIO_VOLTAGE,
.indexed = 1,
.channel = 2,
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT,
.scan_index = 2,
.scan_type = IIO_ST('u', 10, 16, 2),
.event_mask = AD799X_EV_MASK,
@@ -611,6 +641,7 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = {
.type = IIO_VOLTAGE,
.indexed = 1,
.channel = 3,
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT,
.scan_index = 3,
.scan_type = IIO_ST('u', 10, 16, 2),
.event_mask = AD799X_EV_MASK,
@@ -628,6 +659,7 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = {
.type = IIO_VOLTAGE,
.indexed = 1,
.channel = 0,
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT,
.scan_index = 0,
.scan_type = IIO_ST('u', 12, 16, 0),
.event_mask = AD799X_EV_MASK,
@@ -636,6 +668,7 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = {
.type = IIO_VOLTAGE,
.indexed = 1,
.channel = 1,
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT,
.scan_index = 1,
.scan_type = IIO_ST('u', 12, 16, 0),
.event_mask = AD799X_EV_MASK,
@@ -644,6 +677,7 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = {
.type = IIO_VOLTAGE,
.indexed = 1,
.channel = 2,
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT,
.scan_index = 2,
.scan_type = IIO_ST('u', 12, 16, 0),
.event_mask = AD799X_EV_MASK,
@@ -652,6 +686,7 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = {
.type = IIO_VOLTAGE,
.indexed = 1,
.channel = 3,
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT,
.scan_index = 3,
.scan_type = IIO_ST('u', 12, 16, 0),
.event_mask = AD799X_EV_MASK,
@@ -669,6 +704,7 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = {
.type = IIO_VOLTAGE,
.indexed = 1,
.channel = 0,
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT,
.scan_index = 0,
.scan_type = IIO_ST('u', 10, 16, 2),
.event_mask = AD799X_EV_MASK,
@@ -677,6 +713,7 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = {
.type = IIO_VOLTAGE,
.indexed = 1,
.channel = 1,
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT,
.scan_index = 1,
.scan_type = IIO_ST('u', 10, 16, 2),
.event_mask = AD799X_EV_MASK,
@@ -685,6 +722,7 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = {
.type = IIO_VOLTAGE,
.indexed = 1,
.channel = 2,
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT,
.scan_index = 2,
.scan_type = IIO_ST('u', 10, 16, 2),
.event_mask = AD799X_EV_MASK,
@@ -693,6 +731,7 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = {
.type = IIO_VOLTAGE,
.indexed = 1,
.channel = 3,
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT,
.scan_index = 3,
.scan_type = IIO_ST('u', 10, 16, 2),
.event_mask = AD799X_EV_MASK,
@@ -701,6 +740,7 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = {
.type = IIO_VOLTAGE,
.indexed = 1,
.channel = 4,
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT,
.scan_index = 4,
.scan_type = IIO_ST('u', 10, 16, 2),
},
@@ -708,6 +748,7 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = {
.type = IIO_VOLTAGE,
.indexed = 1,
.channel = 5,
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT,
.scan_index = 5,
.scan_type = IIO_ST('u', 10, 16, 2),
},
@@ -715,6 +756,7 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = {
.type = IIO_VOLTAGE,
.indexed = 1,
.channel = 6,
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT,
.scan_index = 6,
.scan_type = IIO_ST('u', 10, 16, 2),
},
@@ -722,6 +764,7 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = {
.type = IIO_VOLTAGE,
.indexed = 1,
.channel = 7,
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT,
.scan_index = 7,
.scan_type = IIO_ST('u', 10, 16, 2),
},
@@ -738,6 +781,7 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = {
.type = IIO_VOLTAGE,
.indexed = 1,
.channel = 0,
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT,
.scan_index = 0,
.scan_type = IIO_ST('u', 12, 16, 0),
.event_mask = AD799X_EV_MASK,
@@ -746,6 +790,7 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = {
.type = IIO_VOLTAGE,
.indexed = 1,
.channel = 1,
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT,
.scan_index = 1,
.scan_type = IIO_ST('u', 12, 16, 0),
.event_mask = AD799X_EV_MASK,
@@ -754,6 +799,7 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = {
.type = IIO_VOLTAGE,
.indexed = 1,
.channel = 2,
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT,
.scan_index = 2,
.scan_type = IIO_ST('u', 12, 16, 0),
.event_mask = AD799X_EV_MASK,
@@ -762,6 +808,7 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = {
.type = IIO_VOLTAGE,
.indexed = 1,
.channel = 3,
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT,
.scan_index = 3,
.scan_type = IIO_ST('u', 12, 16, 0),
.event_mask = AD799X_EV_MASK,
@@ -770,6 +817,7 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = {
.type = IIO_VOLTAGE,
.indexed = 1,
.channel = 4,
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT,
.scan_index = 4,
.scan_type = IIO_ST('u', 12, 16, 0),
},
@@ -777,6 +825,7 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = {
.type = IIO_VOLTAGE,
.indexed = 1,
.channel = 5,
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT,
.scan_index = 5,
.scan_type = IIO_ST('u', 12, 16, 0),
},
@@ -784,6 +833,7 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = {
.type = IIO_VOLTAGE,
.indexed = 1,
.channel = 6,
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT,
.scan_index = 6,
.scan_type = IIO_ST('u', 12, 16, 0),
},
@@ -791,6 +841,7 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = {
.type = IIO_VOLTAGE,
.indexed = 1,
.channel = 7,
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT,
.scan_index = 7,
.scan_type = IIO_ST('u', 12, 16, 0),
},
@@ -809,7 +860,7 @@ static int __devinit ad799x_probe(struct i2c_client *client,
int ret;
struct ad799x_platform_data *pdata = client->dev.platform_data;
struct ad799x_state *st;
- struct iio_dev *indio_dev = iio_allocate_device(sizeof(*st));
+ struct iio_dev *indio_dev = iio_device_alloc(sizeof(*st));
if (indio_dev == NULL)
return -ENOMEM;
@@ -849,12 +900,6 @@ static int __devinit ad799x_probe(struct i2c_client *client,
if (ret)
goto error_disable_reg;
- ret = iio_buffer_register(indio_dev,
- indio_dev->channels,
- indio_dev->num_channels);
- if (ret)
- goto error_cleanup_ring;
-
if (client->irq > 0) {
ret = request_threaded_irq(client->irq,
NULL,
@@ -882,7 +927,7 @@ error_disable_reg:
error_put_reg:
if (!IS_ERR(st->reg))
regulator_put(st->reg);
- iio_free_device(indio_dev);
+ iio_device_free(indio_dev);
return ret;
}
@@ -896,13 +941,12 @@ static __devexit int ad799x_remove(struct i2c_client *client)
if (client->irq > 0)
free_irq(client->irq, indio_dev);
- iio_buffer_unregister(indio_dev);
ad799x_ring_cleanup(indio_dev);
if (!IS_ERR(st->reg)) {
regulator_disable(st->reg);
regulator_put(st->reg);
}
- iio_free_device(indio_dev);
+ iio_device_free(indio_dev);
return 0;
}
diff --git a/drivers/staging/iio/adc/ad799x_ring.c b/drivers/staging/iio/adc/ad799x_ring.c
index 069765cab275..858a685e3889 100644
--- a/drivers/staging/iio/adc/ad799x_ring.c
+++ b/drivers/staging/iio/adc/ad799x_ring.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2010 Michael Hennerich, Analog Devices Inc.
+ * Copyright (C) 2010-2012 Michael Hennerich, Analog Devices Inc.
* Copyright (C) 2008-2010 Jonathan Cameron
*
* This program is free software; you can redistribute it and/or modify
@@ -16,51 +16,14 @@
#include <linux/i2c.h>
#include <linux/bitops.h>
-#include "../iio.h"
-#include "../buffer.h"
-#include "../ring_sw.h"
-#include "../trigger_consumer.h"
+#include <linux/iio/iio.h>
+#include <linux/iio/buffer.h>
+#include <linux/iio/trigger_consumer.h>
+#include <linux/iio/triggered_buffer.h>
#include "ad799x.h"
/**
- * ad799x_ring_preenable() setup the parameters of the ring before enabling
- *
- * The complex nature of the setting of the number of bytes per datum is due
- * to this driver currently ensuring that the timestamp is stored at an 8
- * byte boundary.
- **/
-static int ad799x_ring_preenable(struct iio_dev *indio_dev)
-{
- struct iio_buffer *ring = indio_dev->buffer;
- struct ad799x_state *st = iio_priv(indio_dev);
-
- /*
- * Need to figure out the current mode based upon the requested
- * scan mask in iio_dev
- */
-
- if (st->id == ad7997 || st->id == ad7998)
- ad7997_8_set_scan_mode(st, *indio_dev->active_scan_mask);
-
- st->d_size = bitmap_weight(indio_dev->active_scan_mask,
- indio_dev->masklength) * 2;
-
- if (ring->scan_timestamp) {
- st->d_size += sizeof(s64);
-
- if (st->d_size % sizeof(s64))
- st->d_size += sizeof(s64) - (st->d_size % sizeof(s64));
- }
-
- if (indio_dev->buffer->access->set_bytes_per_datum)
- indio_dev->buffer->access->
- set_bytes_per_datum(indio_dev->buffer, st->d_size);
-
- return 0;
-}
-
-/**
* ad799x_trigger_handler() bh of trigger launched polling to ring buffer
*
* Currently there is no option in this driver to disable the saving of
@@ -78,7 +41,7 @@ static irqreturn_t ad799x_trigger_handler(int irq, void *p)
int b_sent;
u8 cmd;
- rxbuf = kmalloc(st->d_size, GFP_KERNEL);
+ rxbuf = kmalloc(indio_dev->scan_bytes, GFP_KERNEL);
if (rxbuf == NULL)
goto out;
@@ -111,64 +74,26 @@ static irqreturn_t ad799x_trigger_handler(int irq, void *p)
time_ns = iio_get_time_ns();
- if (ring->scan_timestamp)
- memcpy(rxbuf + st->d_size - sizeof(s64),
+ if (indio_dev->scan_timestamp)
+ memcpy(rxbuf + indio_dev->scan_bytes - sizeof(s64),
&time_ns, sizeof(time_ns));
ring->access->store_to(indio_dev->buffer, rxbuf, time_ns);
done:
kfree(rxbuf);
- if (b_sent < 0)
- return b_sent;
out:
iio_trigger_notify_done(indio_dev->trig);
return IRQ_HANDLED;
}
-static const struct iio_buffer_setup_ops ad799x_buf_setup_ops = {
- .preenable = &ad799x_ring_preenable,
- .postenable = &iio_triggered_buffer_postenable,
- .predisable = &iio_triggered_buffer_predisable,
-};
-
int ad799x_register_ring_funcs_and_init(struct iio_dev *indio_dev)
{
- int ret = 0;
-
- indio_dev->buffer = iio_sw_rb_allocate(indio_dev);
- if (!indio_dev->buffer) {
- ret = -ENOMEM;
- goto error_ret;
- }
- indio_dev->pollfunc = iio_alloc_pollfunc(NULL,
- &ad799x_trigger_handler,
- IRQF_ONESHOT,
- indio_dev,
- "%s_consumer%d",
- indio_dev->name,
- indio_dev->id);
- if (indio_dev->pollfunc == NULL) {
- ret = -ENOMEM;
- goto error_deallocate_sw_rb;
- }
-
- /* Ring buffer functions - here trigger setup related */
- indio_dev->setup_ops = &ad799x_buf_setup_ops;
- indio_dev->buffer->scan_timestamp = true;
-
- /* Flag that polled ring buffering is possible */
- indio_dev->modes |= INDIO_BUFFER_TRIGGERED;
- return 0;
-
-error_deallocate_sw_rb:
- iio_sw_rb_free(indio_dev->buffer);
-error_ret:
- return ret;
+ return iio_triggered_buffer_setup(indio_dev, NULL,
+ &ad799x_trigger_handler, NULL);
}
void ad799x_ring_cleanup(struct iio_dev *indio_dev)
{
- iio_dealloc_pollfunc(indio_dev->pollfunc);
- iio_sw_rb_free(indio_dev->buffer);
+ iio_triggered_buffer_cleanup(indio_dev);
}
diff --git a/drivers/staging/iio/adc/adt7310.c b/drivers/staging/iio/adc/adt7310.c
index caf57c1169b1..72460b6dc2f4 100644
--- a/drivers/staging/iio/adc/adt7310.c
+++ b/drivers/staging/iio/adc/adt7310.c
@@ -15,9 +15,9 @@
#include <linux/spi/spi.h>
#include <linux/module.h>
-#include "../iio.h"
-#include "../sysfs.h"
-#include "../events.h"
+#include <linux/iio/iio.h>
+#include <linux/iio/sysfs.h>
+#include <linux/iio/events.h>
/*
* ADT7310 registers definition
*/
@@ -175,7 +175,7 @@ static ssize_t adt7310_show_mode(struct device *dev,
struct device_attribute *attr,
char *buf)
{
- struct iio_dev *dev_info = dev_get_drvdata(dev);
+ struct iio_dev *dev_info = dev_to_iio_dev(dev);
struct adt7310_chip_info *chip = iio_priv(dev_info);
u8 config;
@@ -198,7 +198,7 @@ static ssize_t adt7310_store_mode(struct device *dev,
const char *buf,
size_t len)
{
- struct iio_dev *dev_info = dev_get_drvdata(dev);
+ struct iio_dev *dev_info = dev_to_iio_dev(dev);
struct adt7310_chip_info *chip = iio_priv(dev_info);
u16 config;
int ret;
@@ -242,7 +242,7 @@ static ssize_t adt7310_show_resolution(struct device *dev,
struct device_attribute *attr,
char *buf)
{
- struct iio_dev *dev_info = dev_get_drvdata(dev);
+ struct iio_dev *dev_info = dev_to_iio_dev(dev);
struct adt7310_chip_info *chip = iio_priv(dev_info);
int ret;
int bits;
@@ -264,7 +264,7 @@ static ssize_t adt7310_store_resolution(struct device *dev,
const char *buf,
size_t len)
{
- struct iio_dev *dev_info = dev_get_drvdata(dev);
+ struct iio_dev *dev_info = dev_to_iio_dev(dev);
struct adt7310_chip_info *chip = iio_priv(dev_info);
unsigned long data;
u16 config;
@@ -300,7 +300,7 @@ static ssize_t adt7310_show_id(struct device *dev,
struct device_attribute *attr,
char *buf)
{
- struct iio_dev *dev_info = dev_get_drvdata(dev);
+ struct iio_dev *dev_info = dev_to_iio_dev(dev);
struct adt7310_chip_info *chip = iio_priv(dev_info);
u8 id;
int ret;
@@ -350,7 +350,7 @@ static ssize_t adt7310_show_value(struct device *dev,
struct device_attribute *attr,
char *buf)
{
- struct iio_dev *dev_info = dev_get_drvdata(dev);
+ struct iio_dev *dev_info = dev_to_iio_dev(dev);
struct adt7310_chip_info *chip = iio_priv(dev_info);
u8 status;
u16 data;
@@ -397,7 +397,7 @@ static irqreturn_t adt7310_event_handler(int irq, void *private)
ret = adt7310_spi_read_byte(chip, ADT7310_STATUS, &status);
if (ret)
- return ret;
+ goto done;
if (status & ADT7310_STAT_T_HIGH)
iio_push_event(indio_dev,
@@ -417,6 +417,8 @@ static irqreturn_t adt7310_event_handler(int irq, void *private)
IIO_EV_TYPE_THRESH,
IIO_EV_DIR_RISING),
timestamp);
+
+done:
return IRQ_HANDLED;
}
@@ -424,7 +426,7 @@ static ssize_t adt7310_show_event_mode(struct device *dev,
struct device_attribute *attr,
char *buf)
{
- struct iio_dev *dev_info = dev_get_drvdata(dev);
+ struct iio_dev *dev_info = dev_to_iio_dev(dev);
struct adt7310_chip_info *chip = iio_priv(dev_info);
int ret;
@@ -443,7 +445,7 @@ static ssize_t adt7310_set_event_mode(struct device *dev,
const char *buf,
size_t len)
{
- struct iio_dev *dev_info = dev_get_drvdata(dev);
+ struct iio_dev *dev_info = dev_to_iio_dev(dev);
struct adt7310_chip_info *chip = iio_priv(dev_info);
u16 config;
int ret;
@@ -476,7 +478,7 @@ static ssize_t adt7310_show_fault_queue(struct device *dev,
struct device_attribute *attr,
char *buf)
{
- struct iio_dev *dev_info = dev_get_drvdata(dev);
+ struct iio_dev *dev_info = dev_to_iio_dev(dev);
struct adt7310_chip_info *chip = iio_priv(dev_info);
int ret;
@@ -492,7 +494,7 @@ static ssize_t adt7310_set_fault_queue(struct device *dev,
const char *buf,
size_t len)
{
- struct iio_dev *dev_info = dev_get_drvdata(dev);
+ struct iio_dev *dev_info = dev_to_iio_dev(dev);
struct adt7310_chip_info *chip = iio_priv(dev_info);
unsigned long data;
int ret;
@@ -522,7 +524,7 @@ static inline ssize_t adt7310_show_t_bound(struct device *dev,
u8 bound_reg,
char *buf)
{
- struct iio_dev *dev_info = dev_get_drvdata(dev);
+ struct iio_dev *dev_info = dev_to_iio_dev(dev);
struct adt7310_chip_info *chip = iio_priv(dev_info);
u16 data;
int ret;
@@ -540,7 +542,7 @@ static inline ssize_t adt7310_set_t_bound(struct device *dev,
const char *buf,
size_t len)
{
- struct iio_dev *dev_info = dev_get_drvdata(dev);
+ struct iio_dev *dev_info = dev_to_iio_dev(dev);
struct adt7310_chip_info *chip = iio_priv(dev_info);
long tmp1, tmp2;
u16 data;
@@ -660,7 +662,7 @@ static ssize_t adt7310_show_t_hyst(struct device *dev,
struct device_attribute *attr,
char *buf)
{
- struct iio_dev *dev_info = dev_get_drvdata(dev);
+ struct iio_dev *dev_info = dev_to_iio_dev(dev);
struct adt7310_chip_info *chip = iio_priv(dev_info);
int ret;
u8 t_hyst;
@@ -677,7 +679,7 @@ static inline ssize_t adt7310_set_t_hyst(struct device *dev,
const char *buf,
size_t len)
{
- struct iio_dev *dev_info = dev_get_drvdata(dev);
+ struct iio_dev *dev_info = dev_to_iio_dev(dev);
struct adt7310_chip_info *chip = iio_priv(dev_info);
int ret;
unsigned long data;
@@ -753,7 +755,7 @@ static int __devinit adt7310_probe(struct spi_device *spi_dev)
unsigned long *adt7310_platform_data = spi_dev->dev.platform_data;
unsigned long irq_flags;
- indio_dev = iio_allocate_device(sizeof(*chip));
+ indio_dev = iio_device_alloc(sizeof(*chip));
if (indio_dev == NULL) {
ret = -ENOMEM;
goto error_ret;
@@ -778,7 +780,7 @@ static int __devinit adt7310_probe(struct spi_device *spi_dev)
ret = request_threaded_irq(spi_dev->irq,
NULL,
&adt7310_event_handler,
- irq_flags,
+ irq_flags | IRQF_ONESHOT,
indio_dev->name,
indio_dev);
if (ret)
@@ -790,7 +792,8 @@ static int __devinit adt7310_probe(struct spi_device *spi_dev)
ret = request_threaded_irq(adt7310_platform_data[0],
NULL,
&adt7310_event_handler,
- adt7310_platform_data[1],
+ adt7310_platform_data[1] |
+ IRQF_ONESHOT,
indio_dev->name,
indio_dev);
if (ret)
@@ -833,7 +836,7 @@ error_unreg_int_irq:
error_unreg_ct_irq:
free_irq(spi_dev->irq, indio_dev);
error_free_dev:
- iio_free_device(indio_dev);
+ iio_device_free(indio_dev);
error_ret:
return ret;
}
@@ -849,7 +852,7 @@ static int __devexit adt7310_remove(struct spi_device *spi_dev)
free_irq(adt7310_platform_data[0], indio_dev);
if (spi_dev->irq)
free_irq(spi_dev->irq, indio_dev);
- iio_free_device(indio_dev);
+ iio_device_free(indio_dev);
return 0;
}
diff --git a/drivers/staging/iio/adc/adt7410.c b/drivers/staging/iio/adc/adt7410.c
index dff3e8ca2d78..4157596ea3b0 100644
--- a/drivers/staging/iio/adc/adt7410.c
+++ b/drivers/staging/iio/adc/adt7410.c
@@ -15,9 +15,9 @@
#include <linux/i2c.h>
#include <linux/module.h>
-#include "../iio.h"
-#include "../sysfs.h"
-#include "../events.h"
+#include <linux/iio/iio.h>
+#include <linux/iio/sysfs.h>
+#include <linux/iio/events.h>
/*
* ADT7410 registers definition
@@ -144,7 +144,7 @@ static ssize_t adt7410_show_mode(struct device *dev,
struct device_attribute *attr,
char *buf)
{
- struct iio_dev *dev_info = dev_get_drvdata(dev);
+ struct iio_dev *dev_info = dev_to_iio_dev(dev);
struct adt7410_chip_info *chip = iio_priv(dev_info);
u8 config;
@@ -167,7 +167,7 @@ static ssize_t adt7410_store_mode(struct device *dev,
const char *buf,
size_t len)
{
- struct iio_dev *dev_info = dev_get_drvdata(dev);
+ struct iio_dev *dev_info = dev_to_iio_dev(dev);
struct adt7410_chip_info *chip = iio_priv(dev_info);
u16 config;
int ret;
@@ -211,7 +211,7 @@ static ssize_t adt7410_show_resolution(struct device *dev,
struct device_attribute *attr,
char *buf)
{
- struct iio_dev *dev_info = dev_get_drvdata(dev);
+ struct iio_dev *dev_info = dev_to_iio_dev(dev);
struct adt7410_chip_info *chip = iio_priv(dev_info);
int ret;
int bits;
@@ -233,7 +233,7 @@ static ssize_t adt7410_store_resolution(struct device *dev,
const char *buf,
size_t len)
{
- struct iio_dev *dev_info = dev_get_drvdata(dev);
+ struct iio_dev *dev_info = dev_to_iio_dev(dev);
struct adt7410_chip_info *chip = iio_priv(dev_info);
unsigned long data;
u16 config;
@@ -257,7 +257,7 @@ static ssize_t adt7410_store_resolution(struct device *dev,
chip->config = config;
- return ret;
+ return len;
}
static IIO_DEVICE_ATTR(resolution, S_IRUGO | S_IWUSR,
@@ -269,7 +269,7 @@ static ssize_t adt7410_show_id(struct device *dev,
struct device_attribute *attr,
char *buf)
{
- struct iio_dev *dev_info = dev_get_drvdata(dev);
+ struct iio_dev *dev_info = dev_to_iio_dev(dev);
struct adt7410_chip_info *chip = iio_priv(dev_info);
u8 id;
int ret;
@@ -293,33 +293,24 @@ static ssize_t adt7410_convert_temperature(struct adt7410_chip_info *chip,
{
char sign = ' ';
- if (chip->config & ADT7410_RESOLUTION) {
- if (data & ADT7410_T16_VALUE_SIGN) {
- /* convert supplement to positive value */
- data = (u16)((ADT7410_T16_VALUE_SIGN << 1) - (u32)data);
- sign = '-';
- }
- return sprintf(buf, "%c%d.%.7d\n", sign,
- (data >> ADT7410_T16_VALUE_FLOAT_OFFSET),
- (data & ADT7410_T16_VALUE_FLOAT_MASK) * 78125);
- } else {
- if (data & ADT7410_T13_VALUE_SIGN) {
- /* convert supplement to positive value */
- data >>= ADT7410_T13_VALUE_OFFSET;
- data = (ADT7410_T13_VALUE_SIGN << 1) - data;
- sign = '-';
- }
- return sprintf(buf, "%c%d.%.4d\n", sign,
- (data >> ADT7410_T13_VALUE_FLOAT_OFFSET),
- (data & ADT7410_T13_VALUE_FLOAT_MASK) * 625);
+ if (!(chip->config & ADT7410_RESOLUTION))
+ data &= ~0x7;
+
+ if (data & ADT7410_T16_VALUE_SIGN) {
+ /* convert supplement to positive value */
+ data = (u16)((ADT7410_T16_VALUE_SIGN << 1) - (u32)data);
+ sign = '-';
}
+ return sprintf(buf, "%c%d.%.7d\n", sign,
+ (data >> ADT7410_T16_VALUE_FLOAT_OFFSET),
+ (data & ADT7410_T16_VALUE_FLOAT_MASK) * 78125);
}
static ssize_t adt7410_show_value(struct device *dev,
struct device_attribute *attr,
char *buf)
{
- struct iio_dev *dev_info = dev_get_drvdata(dev);
+ struct iio_dev *dev_info = dev_to_iio_dev(dev);
struct adt7410_chip_info *chip = iio_priv(dev_info);
u8 status;
u16 data;
@@ -392,7 +383,7 @@ static ssize_t adt7410_show_event_mode(struct device *dev,
struct device_attribute *attr,
char *buf)
{
- struct iio_dev *dev_info = dev_get_drvdata(dev);
+ struct iio_dev *dev_info = dev_to_iio_dev(dev);
struct adt7410_chip_info *chip = iio_priv(dev_info);
int ret;
@@ -411,7 +402,7 @@ static ssize_t adt7410_set_event_mode(struct device *dev,
const char *buf,
size_t len)
{
- struct iio_dev *dev_info = dev_get_drvdata(dev);
+ struct iio_dev *dev_info = dev_to_iio_dev(dev);
struct adt7410_chip_info *chip = iio_priv(dev_info);
u16 config;
int ret;
@@ -444,7 +435,7 @@ static ssize_t adt7410_show_fault_queue(struct device *dev,
struct device_attribute *attr,
char *buf)
{
- struct iio_dev *dev_info = dev_get_drvdata(dev);
+ struct iio_dev *dev_info = dev_to_iio_dev(dev);
struct adt7410_chip_info *chip = iio_priv(dev_info);
int ret;
@@ -460,7 +451,7 @@ static ssize_t adt7410_set_fault_queue(struct device *dev,
const char *buf,
size_t len)
{
- struct iio_dev *dev_info = dev_get_drvdata(dev);
+ struct iio_dev *dev_info = dev_to_iio_dev(dev);
struct adt7410_chip_info *chip = iio_priv(dev_info);
unsigned long data;
int ret;
@@ -490,7 +481,7 @@ static inline ssize_t adt7410_show_t_bound(struct device *dev,
u8 bound_reg,
char *buf)
{
- struct iio_dev *dev_info = dev_get_drvdata(dev);
+ struct iio_dev *dev_info = dev_to_iio_dev(dev);
struct adt7410_chip_info *chip = iio_priv(dev_info);
u16 data;
int ret;
@@ -508,7 +499,7 @@ static inline ssize_t adt7410_set_t_bound(struct device *dev,
const char *buf,
size_t len)
{
- struct iio_dev *dev_info = dev_get_drvdata(dev);
+ struct iio_dev *dev_info = dev_to_iio_dev(dev);
struct adt7410_chip_info *chip = iio_priv(dev_info);
long tmp1, tmp2;
u16 data;
@@ -628,7 +619,7 @@ static ssize_t adt7410_show_t_hyst(struct device *dev,
struct device_attribute *attr,
char *buf)
{
- struct iio_dev *dev_info = dev_get_drvdata(dev);
+ struct iio_dev *dev_info = dev_to_iio_dev(dev);
struct adt7410_chip_info *chip = iio_priv(dev_info);
int ret;
u8 t_hyst;
@@ -645,7 +636,7 @@ static inline ssize_t adt7410_set_t_hyst(struct device *dev,
const char *buf,
size_t len)
{
- struct iio_dev *dev_info = dev_get_drvdata(dev);
+ struct iio_dev *dev_info = dev_to_iio_dev(dev);
struct adt7410_chip_info *chip = iio_priv(dev_info);
int ret;
unsigned long data;
@@ -720,8 +711,9 @@ static int __devinit adt7410_probe(struct i2c_client *client,
struct iio_dev *indio_dev;
int ret = 0;
unsigned long *adt7410_platform_data = client->dev.platform_data;
+ unsigned long local_pdata[] = {0, 0};
- indio_dev = iio_allocate_device(sizeof(*chip));
+ indio_dev = iio_device_alloc(sizeof(*chip));
if (indio_dev == NULL) {
ret = -ENOMEM;
goto error_ret;
@@ -737,12 +729,15 @@ static int __devinit adt7410_probe(struct i2c_client *client,
indio_dev->info = &adt7410_info;
indio_dev->modes = INDIO_DIRECT_MODE;
+ if (!adt7410_platform_data)
+ adt7410_platform_data = local_pdata;
+
/* CT critcal temperature event. line 0 */
if (client->irq) {
ret = request_threaded_irq(client->irq,
NULL,
&adt7410_event_handler,
- IRQF_TRIGGER_LOW,
+ IRQF_TRIGGER_LOW | IRQF_ONESHOT,
id->name,
indio_dev);
if (ret)
@@ -754,20 +749,23 @@ static int __devinit adt7410_probe(struct i2c_client *client,
ret = request_threaded_irq(adt7410_platform_data[0],
NULL,
&adt7410_event_handler,
- adt7410_platform_data[1],
+ adt7410_platform_data[1] |
+ IRQF_ONESHOT,
id->name,
indio_dev);
if (ret)
goto error_unreg_ct_irq;
}
- if (client->irq && adt7410_platform_data[0]) {
+ ret = adt7410_i2c_read_byte(chip, ADT7410_CONFIG, &chip->config);
+ if (ret) {
+ ret = -EIO;
+ goto error_unreg_int_irq;
+ }
- ret = adt7410_i2c_read_byte(chip, ADT7410_CONFIG, &chip->config);
- if (ret) {
- ret = -EIO;
- goto error_unreg_int_irq;
- }
+ chip->config |= ADT7410_RESOLUTION;
+
+ if (client->irq && adt7410_platform_data[0]) {
/* set irq polarity low level */
chip->config &= ~ADT7410_CT_POLARITY;
@@ -776,12 +774,12 @@ static int __devinit adt7410_probe(struct i2c_client *client,
chip->config |= ADT7410_INT_POLARITY;
else
chip->config &= ~ADT7410_INT_POLARITY;
+ }
- ret = adt7410_i2c_write_byte(chip, ADT7410_CONFIG, chip->config);
- if (ret) {
- ret = -EIO;
- goto error_unreg_int_irq;
- }
+ ret = adt7410_i2c_write_byte(chip, ADT7410_CONFIG, chip->config);
+ if (ret) {
+ ret = -EIO;
+ goto error_unreg_int_irq;
}
ret = iio_device_register(indio_dev);
if (ret)
@@ -797,7 +795,7 @@ error_unreg_int_irq:
error_unreg_ct_irq:
free_irq(client->irq, indio_dev);
error_free_dev:
- iio_free_device(indio_dev);
+ iio_device_free(indio_dev);
error_ret:
return ret;
}
@@ -812,7 +810,7 @@ static int __devexit adt7410_remove(struct i2c_client *client)
free_irq(adt7410_platform_data[0], indio_dev);
if (client->irq)
free_irq(client->irq, indio_dev);
- iio_free_device(indio_dev);
+ iio_device_free(indio_dev);
return 0;
}
diff --git a/drivers/staging/iio/adc/lpc32xx_adc.c b/drivers/staging/iio/adc/lpc32xx_adc.c
index dfc9033843a3..348d051fc2f8 100644
--- a/drivers/staging/iio/adc/lpc32xx_adc.c
+++ b/drivers/staging/iio/adc/lpc32xx_adc.c
@@ -30,9 +30,10 @@
#include <linux/clk.h>
#include <linux/err.h>
#include <linux/completion.h>
+#include <linux/of.h>
-#include "../iio.h"
-#include "../sysfs.h"
+#include <linux/iio/iio.h>
+#include <linux/iio/sysfs.h>
/*
* LPC32XX registers definitions
@@ -73,7 +74,7 @@ static int lpc32xx_read_raw(struct iio_dev *indio_dev,
{
struct lpc32xx_adc_info *info = iio_priv(indio_dev);
- if (mask == 0) {
+ if (mask == IIO_CHAN_INFO_RAW) {
mutex_lock(&indio_dev->mlock);
clk_enable(info->clk);
/* Measurement setup */
@@ -98,12 +99,13 @@ static const struct iio_info lpc32xx_adc_iio_info = {
.driver_module = THIS_MODULE,
};
-#define LPC32XX_ADC_CHANNEL(_index) { \
- .type = IIO_VOLTAGE, \
- .indexed = 1, \
- .channel = _index, \
- .address = AD_IN * _index, \
- .scan_index = _index, \
+#define LPC32XX_ADC_CHANNEL(_index) { \
+ .type = IIO_VOLTAGE, \
+ .indexed = 1, \
+ .channel = _index, \
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT, \
+ .address = AD_IN * _index, \
+ .scan_index = _index, \
}
static struct iio_chan_spec lpc32xx_adc_iio_channels[] = {
@@ -139,7 +141,7 @@ static int __devinit lpc32xx_adc_probe(struct platform_device *pdev)
goto errout1;
}
- iodev = iio_allocate_device(sizeof(struct lpc32xx_adc_info));
+ iodev = iio_device_alloc(sizeof(struct lpc32xx_adc_info));
if (!iodev) {
dev_err(&pdev->dev, "failed allocating iio device\n");
retval = -ENOMEM;
@@ -194,13 +196,13 @@ static int __devinit lpc32xx_adc_probe(struct platform_device *pdev)
return 0;
errout5:
- free_irq(irq, iodev);
+ free_irq(irq, info);
errout4:
clk_put(info->clk);
errout3:
iounmap(info->adc_base);
errout2:
- iio_free_device(iodev);
+ iio_device_free(iodev);
errout1:
return retval;
}
@@ -212,21 +214,30 @@ static int __devexit lpc32xx_adc_remove(struct platform_device *pdev)
int irq = platform_get_irq(pdev, 0);
iio_device_unregister(iodev);
- free_irq(irq, iodev);
+ free_irq(irq, info);
platform_set_drvdata(pdev, NULL);
clk_put(info->clk);
iounmap(info->adc_base);
- iio_free_device(iodev);
+ iio_device_free(iodev);
return 0;
}
+#ifdef CONFIG_OF
+static const struct of_device_id lpc32xx_adc_match[] = {
+ { .compatible = "nxp,lpc3220-adc" },
+ {},
+};
+MODULE_DEVICE_TABLE(of, lpc32xx_adc_match);
+#endif
+
static struct platform_driver lpc32xx_adc_driver = {
.probe = lpc32xx_adc_probe,
.remove = __devexit_p(lpc32xx_adc_remove),
.driver = {
.name = MOD_NAME,
.owner = THIS_MODULE,
+ .of_match_table = of_match_ptr(lpc32xx_adc_match),
},
};
diff --git a/drivers/staging/iio/adc/max1363_core.c b/drivers/staging/iio/adc/max1363_core.c
index cf3e2ca7e314..6799ce23a395 100644
--- a/drivers/staging/iio/adc/max1363_core.c
+++ b/drivers/staging/iio/adc/max1363_core.c
@@ -32,10 +32,11 @@
#include <linux/err.h>
#include <linux/module.h>
-#include "../iio.h"
-#include "../sysfs.h"
-#include "../events.h"
-#include "../buffer.h"
+#include <linux/iio/iio.h>
+#include <linux/iio/sysfs.h>
+#include <linux/iio/events.h>
+#include <linux/iio/buffer.h>
+#include <linux/iio/driver.h>
#include "max1363.h"
@@ -248,7 +249,7 @@ static int max1363_read_raw(struct iio_dev *indio_dev,
struct max1363_state *st = iio_priv(indio_dev);
int ret;
switch (m) {
- case 0:
+ case IIO_CHAN_INFO_RAW:
ret = max1363_read_single_chan(indio_dev, chan, val, m);
if (ret < 0)
return ret;
@@ -281,7 +282,8 @@ static const enum max1363_modes max1363_mode_list[] = {
#define MAX1363_EV_M \
(IIO_EV_BIT(IIO_EV_TYPE_THRESH, IIO_EV_DIR_RISING) \
| IIO_EV_BIT(IIO_EV_TYPE_THRESH, IIO_EV_DIR_FALLING))
-#define MAX1363_INFO_MASK IIO_CHAN_INFO_SCALE_SHARED_BIT
+#define MAX1363_INFO_MASK (IIO_CHAN_INFO_RAW_SEPARATE_BIT | \
+ IIO_CHAN_INFO_SCALE_SHARED_BIT)
#define MAX1363_CHAN_U(num, addr, si, bits, evmask) \
{ \
.type = IIO_VOLTAGE, \
@@ -497,7 +499,7 @@ static ssize_t max1363_monitor_show_freq(struct device *dev,
struct device_attribute *attr,
char *buf)
{
- struct max1363_state *st = iio_priv(dev_get_drvdata(dev));
+ struct max1363_state *st = iio_priv(dev_to_iio_dev(dev));
return sprintf(buf, "%d\n", max1363_monitor_speeds[st->monitor_speed]);
}
@@ -506,7 +508,7 @@ static ssize_t max1363_monitor_store_freq(struct device *dev,
const char *buf,
size_t len)
{
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct max1363_state *st = iio_priv(indio_dev);
int i, ret;
unsigned long val;
@@ -830,6 +832,7 @@ static struct attribute_group max1363_event_attribute_group = {
static const struct iio_info max1238_info = {
.read_raw = &max1363_read_raw,
.driver_module = THIS_MODULE,
+ .update_scan_mode = &max1363_update_scan_mode,
};
static const struct iio_info max1363_info = {
@@ -1284,11 +1287,14 @@ static int __devinit max1363_probe(struct i2c_client *client,
if (ret)
goto error_put_reg;
- indio_dev = iio_allocate_device(sizeof(struct max1363_state));
+ indio_dev = iio_device_alloc(sizeof(struct max1363_state));
if (indio_dev == NULL) {
ret = -ENOMEM;
goto error_disable_reg;
}
+ ret = iio_map_array_register(indio_dev, client->dev.platform_data);
+ if (ret < 0)
+ goto error_free_device;
st = iio_priv(indio_dev);
st->reg = reg;
/* this is only used for device removal purposes */
@@ -1299,7 +1305,7 @@ static int __devinit max1363_probe(struct i2c_client *client,
ret = max1363_alloc_scan_masks(indio_dev);
if (ret)
- goto error_free_device;
+ goto error_unregister_map;
/* Estabilish that the iio_dev is a child of the i2c device */
indio_dev->dev.parent = &client->dev;
@@ -1349,8 +1355,10 @@ error_cleanup_ring:
max1363_ring_cleanup(indio_dev);
error_free_available_scan_masks:
kfree(indio_dev->available_scan_masks);
+error_unregister_map:
+ iio_map_array_unregister(indio_dev, client->dev.platform_data);
error_free_device:
- iio_free_device(indio_dev);
+ iio_device_free(indio_dev);
error_disable_reg:
regulator_disable(reg);
error_put_reg:
@@ -1375,7 +1383,8 @@ static int max1363_remove(struct i2c_client *client)
regulator_disable(reg);
regulator_put(reg);
}
- iio_free_device(indio_dev);
+ iio_map_array_unregister(indio_dev, client->dev.platform_data);
+ iio_device_free(indio_dev);
return 0;
}
diff --git a/drivers/staging/iio/adc/max1363_ring.c b/drivers/staging/iio/adc/max1363_ring.c
index d0a60a382930..774ae1b63550 100644
--- a/drivers/staging/iio/adc/max1363_ring.c
+++ b/drivers/staging/iio/adc/max1363_ring.c
@@ -14,10 +14,10 @@
#include <linux/i2c.h>
#include <linux/bitops.h>
-#include "../iio.h"
-#include "../buffer.h"
+#include <linux/iio/iio.h>
+#include <linux/iio/buffer.h>
#include "../ring_sw.h"
-#include "../trigger_consumer.h"
+#include <linux/iio/trigger_consumer.h>
#include "max1363.h"
@@ -54,7 +54,7 @@ static irqreturn_t max1363_trigger_handler(int irq, void *p)
d_size = numvals*2;
else
d_size = numvals;
- if (indio_dev->buffer->scan_timestamp) {
+ if (indio_dev->scan_timestamp) {
d_size += sizeof(s64);
if (d_size % sizeof(s64))
d_size += sizeof(s64) - (d_size % sizeof(s64));
@@ -64,27 +64,28 @@ static irqreturn_t max1363_trigger_handler(int irq, void *p)
* no harm.
*/
if (numvals == 0)
- return IRQ_HANDLED;
+ goto done;
rxbuf = kmalloc(d_size, GFP_KERNEL);
if (rxbuf == NULL)
- return -ENOMEM;
+ goto done;
if (st->chip_info->bits != 8)
b_sent = i2c_master_recv(st->client, rxbuf, numvals*2);
else
b_sent = i2c_master_recv(st->client, rxbuf, numvals);
if (b_sent < 0)
- goto done;
+ goto done_free;
time_ns = iio_get_time_ns();
- if (indio_dev->buffer->scan_timestamp)
+ if (indio_dev->scan_timestamp)
memcpy(rxbuf + d_size - sizeof(s64), &time_ns, sizeof(time_ns));
iio_push_to_buffer(indio_dev->buffer, rxbuf, time_ns);
+done_free:
+ kfree(rxbuf);
done:
iio_trigger_notify_done(indio_dev->trig);
- kfree(rxbuf);
return IRQ_HANDLED;
}
diff --git a/drivers/staging/iio/adc/spear_adc.c b/drivers/staging/iio/adc/spear_adc.c
new file mode 100644
index 000000000000..64d630e6fe29
--- /dev/null
+++ b/drivers/staging/iio/adc/spear_adc.c
@@ -0,0 +1,448 @@
+/*
+ * ST SPEAr ADC driver
+ *
+ * Copyright 2012 Stefan Roese <sr@denx.de>
+ *
+ * Licensed under the GPL-2.
+ */
+
+#include <linux/module.h>
+#include <linux/platform_device.h>
+#include <linux/interrupt.h>
+#include <linux/device.h>
+#include <linux/kernel.h>
+#include <linux/slab.h>
+#include <linux/io.h>
+#include <linux/clk.h>
+#include <linux/err.h>
+#include <linux/completion.h>
+#include <linux/of.h>
+#include <linux/of_address.h>
+
+#include <linux/iio/iio.h>
+#include <linux/iio/sysfs.h>
+
+/*
+ * SPEAR registers definitions
+ */
+
+#define SCAN_RATE_LO(x) ((x) & 0xFFFF)
+#define SCAN_RATE_HI(x) (((x) >> 0x10) & 0xFFFF)
+#define CLK_LOW(x) (((x) & 0xf) << 0)
+#define CLK_HIGH(x) (((x) & 0xf) << 4)
+
+/* Bit definitions for SPEAR_ADC_STATUS */
+#define START_CONVERSION (1 << 0)
+#define CHANNEL_NUM(x) ((x) << 1)
+#define ADC_ENABLE (1 << 4)
+#define AVG_SAMPLE(x) ((x) << 5)
+#define VREF_INTERNAL (1 << 9)
+
+#define DATA_MASK 0x03ff
+#define DATA_BITS 10
+
+#define MOD_NAME "spear-adc"
+
+#define ADC_CHANNEL_NUM 8
+
+#define CLK_MIN 2500000
+#define CLK_MAX 20000000
+
+struct adc_regs_spear3xx {
+ u32 status;
+ u32 average;
+ u32 scan_rate;
+ u32 clk; /* Not avail for 1340 & 1310 */
+ u32 ch_ctrl[ADC_CHANNEL_NUM];
+ u32 ch_data[ADC_CHANNEL_NUM];
+};
+
+struct chan_data {
+ u32 lsb;
+ u32 msb;
+};
+
+struct adc_regs_spear6xx {
+ u32 status;
+ u32 pad[2];
+ u32 clk;
+ u32 ch_ctrl[ADC_CHANNEL_NUM];
+ struct chan_data ch_data[ADC_CHANNEL_NUM];
+ u32 scan_rate_lo;
+ u32 scan_rate_hi;
+ struct chan_data average;
+};
+
+struct spear_adc_info {
+ struct device_node *np;
+ struct adc_regs_spear3xx __iomem *adc_base_spear3xx;
+ struct adc_regs_spear6xx __iomem *adc_base_spear6xx;
+ struct clk *clk;
+ struct completion completion;
+ u32 current_clk;
+ u32 sampling_freq;
+ u32 avg_samples;
+ u32 vref_external;
+ u32 value;
+};
+
+/*
+ * Functions to access some SPEAr ADC register. Abstracted into
+ * static inline functions, because of different register offsets
+ * on different SoC variants (SPEAr300 vs SPEAr600 etc).
+ */
+static void spear_adc_set_status(struct spear_adc_info *info, u32 val)
+{
+ __raw_writel(val, &info->adc_base_spear6xx->status);
+}
+
+static void spear_adc_set_clk(struct spear_adc_info *info, u32 val)
+{
+ u32 clk_high, clk_low, count;
+ u32 apb_clk = clk_get_rate(info->clk);
+
+ count = (apb_clk + val - 1) / val;
+ clk_low = count / 2;
+ clk_high = count - clk_low;
+ info->current_clk = apb_clk / count;
+
+ __raw_writel(CLK_LOW(clk_low) | CLK_HIGH(clk_high),
+ &info->adc_base_spear6xx->clk);
+}
+
+static void spear_adc_set_ctrl(struct spear_adc_info *info, int n,
+ u32 val)
+{
+ __raw_writel(val, &info->adc_base_spear6xx->ch_ctrl[n]);
+}
+
+static u32 spear_adc_get_average(struct spear_adc_info *info)
+{
+ if (of_device_is_compatible(info->np, "st,spear600-adc")) {
+ return __raw_readl(&info->adc_base_spear6xx->average.msb) &
+ DATA_MASK;
+ } else {
+ return __raw_readl(&info->adc_base_spear3xx->average) &
+ DATA_MASK;
+ }
+}
+
+static void spear_adc_set_scanrate(struct spear_adc_info *info, u32 rate)
+{
+ if (of_device_is_compatible(info->np, "st,spear600-adc")) {
+ __raw_writel(SCAN_RATE_LO(rate),
+ &info->adc_base_spear6xx->scan_rate_lo);
+ __raw_writel(SCAN_RATE_HI(rate),
+ &info->adc_base_spear6xx->scan_rate_hi);
+ } else {
+ __raw_writel(rate, &info->adc_base_spear3xx->scan_rate);
+ }
+}
+
+static int spear_read_raw(struct iio_dev *indio_dev,
+ struct iio_chan_spec const *chan,
+ int *val,
+ int *val2,
+ long mask)
+{
+ struct spear_adc_info *info = iio_priv(indio_dev);
+ u32 scale_mv;
+ u32 status;
+
+ switch (mask) {
+ case IIO_CHAN_INFO_RAW:
+ mutex_lock(&indio_dev->mlock);
+
+ status = CHANNEL_NUM(chan->channel) |
+ AVG_SAMPLE(info->avg_samples) |
+ START_CONVERSION | ADC_ENABLE;
+ if (info->vref_external == 0)
+ status |= VREF_INTERNAL;
+
+ spear_adc_set_status(info, status);
+ wait_for_completion(&info->completion); /* set by ISR */
+ *val = info->value;
+
+ mutex_unlock(&indio_dev->mlock);
+
+ return IIO_VAL_INT;
+
+ case IIO_CHAN_INFO_SCALE:
+ scale_mv = (info->vref_external * 1000) >> DATA_BITS;
+ *val = scale_mv / 1000;
+ *val2 = (scale_mv % 1000) * 1000;
+ return IIO_VAL_INT_PLUS_MICRO;
+ }
+
+ return -EINVAL;
+}
+
+#define SPEAR_ADC_CHAN(idx) { \
+ .type = IIO_VOLTAGE, \
+ .indexed = 1, \
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT | \
+ IIO_CHAN_INFO_SCALE_SHARED_BIT, \
+ .channel = idx, \
+ .scan_type = { \
+ .sign = 'u', \
+ .storagebits = 16, \
+ }, \
+}
+
+static struct iio_chan_spec spear_adc_iio_channels[] = {
+ SPEAR_ADC_CHAN(0),
+ SPEAR_ADC_CHAN(1),
+ SPEAR_ADC_CHAN(2),
+ SPEAR_ADC_CHAN(3),
+ SPEAR_ADC_CHAN(4),
+ SPEAR_ADC_CHAN(5),
+ SPEAR_ADC_CHAN(6),
+ SPEAR_ADC_CHAN(7),
+};
+
+static irqreturn_t spear_adc_isr(int irq, void *dev_id)
+{
+ struct spear_adc_info *info = (struct spear_adc_info *)dev_id;
+
+ /* Read value to clear IRQ */
+ info->value = spear_adc_get_average(info);
+ complete(&info->completion);
+
+ return IRQ_HANDLED;
+}
+
+static int spear_adc_configure(struct spear_adc_info *info)
+{
+ int i;
+
+ /* Reset ADC core */
+ spear_adc_set_status(info, 0);
+ __raw_writel(0, &info->adc_base_spear6xx->clk);
+ for (i = 0; i < 8; i++)
+ spear_adc_set_ctrl(info, i, 0);
+ spear_adc_set_scanrate(info, 0);
+
+ spear_adc_set_clk(info, info->sampling_freq);
+
+ return 0;
+}
+
+static ssize_t spear_adc_read_frequency(struct device *dev,
+ struct device_attribute *attr,
+ char *buf)
+{
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
+ struct spear_adc_info *info = iio_priv(indio_dev);
+
+ return sprintf(buf, "%d\n", info->current_clk);
+}
+
+static ssize_t spear_adc_write_frequency(struct device *dev,
+ struct device_attribute *attr,
+ const char *buf,
+ size_t len)
+{
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
+ struct spear_adc_info *info = iio_priv(indio_dev);
+ u32 clk_high, clk_low, count;
+ u32 apb_clk = clk_get_rate(info->clk);
+ unsigned long lval;
+ int ret;
+
+ ret = kstrtoul(buf, 10, &lval);
+ if (ret)
+ return ret;
+
+ mutex_lock(&indio_dev->mlock);
+
+ if ((lval < CLK_MIN) || (lval > CLK_MAX)) {
+ ret = -EINVAL;
+ goto out;
+ }
+
+ count = (apb_clk + lval - 1) / lval;
+ clk_low = count / 2;
+ clk_high = count - clk_low;
+ info->current_clk = apb_clk / count;
+ spear_adc_set_clk(info, lval);
+
+out:
+ mutex_unlock(&indio_dev->mlock);
+
+ return ret ? ret : len;
+}
+
+static IIO_DEV_ATTR_SAMP_FREQ(S_IWUSR | S_IRUGO,
+ spear_adc_read_frequency,
+ spear_adc_write_frequency);
+
+static struct attribute *spear_attributes[] = {
+ &iio_dev_attr_sampling_frequency.dev_attr.attr,
+ NULL
+};
+
+static const struct attribute_group spear_attribute_group = {
+ .attrs = spear_attributes,
+};
+
+static const struct iio_info spear_adc_iio_info = {
+ .read_raw = &spear_read_raw,
+ .attrs = &spear_attribute_group,
+ .driver_module = THIS_MODULE,
+};
+
+static int __devinit spear_adc_probe(struct platform_device *pdev)
+{
+ struct device_node *np = pdev->dev.of_node;
+ struct device *dev = &pdev->dev;
+ struct spear_adc_info *info;
+ struct iio_dev *iodev = NULL;
+ int ret = -ENODEV;
+ int irq;
+
+ iodev = iio_device_alloc(sizeof(struct spear_adc_info));
+ if (!iodev) {
+ dev_err(dev, "failed allocating iio device\n");
+ ret = -ENOMEM;
+ goto errout1;
+ }
+
+ info = iio_priv(iodev);
+ info->np = np;
+
+ /*
+ * SPEAr600 has a different register layout than other SPEAr SoC's
+ * (e.g. SPEAr3xx). Let's provide two register base addresses
+ * to support multi-arch kernels.
+ */
+ info->adc_base_spear6xx = of_iomap(np, 0);
+ if (!info->adc_base_spear6xx) {
+ dev_err(dev, "failed mapping memory\n");
+ ret = -ENOMEM;
+ goto errout2;
+ }
+ info->adc_base_spear3xx =
+ (struct adc_regs_spear3xx *)info->adc_base_spear6xx;
+
+ info->clk = clk_get(dev, NULL);
+ if (IS_ERR(info->clk)) {
+ dev_err(dev, "failed getting clock\n");
+ goto errout3;
+ }
+
+ ret = clk_prepare(info->clk);
+ if (ret) {
+ dev_err(dev, "failed preparing clock\n");
+ goto errout4;
+ }
+
+ ret = clk_enable(info->clk);
+ if (ret) {
+ dev_err(dev, "failed enabling clock\n");
+ goto errout5;
+ }
+
+ irq = platform_get_irq(pdev, 0);
+ if ((irq < 0) || (irq >= NR_IRQS)) {
+ dev_err(dev, "failed getting interrupt resource\n");
+ ret = -EINVAL;
+ goto errout6;
+ }
+
+ ret = devm_request_irq(dev, irq, spear_adc_isr, 0, MOD_NAME, info);
+ if (ret < 0) {
+ dev_err(dev, "failed requesting interrupt\n");
+ goto errout6;
+ }
+
+ if (of_property_read_u32(np, "sampling-frequency",
+ &info->sampling_freq)) {
+ dev_err(dev, "sampling-frequency missing in DT\n");
+ ret = -EINVAL;
+ goto errout6;
+ }
+
+ /*
+ * Optional avg_samples defaults to 0, resulting in single data
+ * conversion
+ */
+ of_property_read_u32(np, "average-samples", &info->avg_samples);
+
+ /*
+ * Optional vref_external defaults to 0, resulting in internal vref
+ * selection
+ */
+ of_property_read_u32(np, "vref-external", &info->vref_external);
+
+ spear_adc_configure(info);
+
+ platform_set_drvdata(pdev, iodev);
+
+ init_completion(&info->completion);
+
+ iodev->name = MOD_NAME;
+ iodev->dev.parent = dev;
+ iodev->info = &spear_adc_iio_info;
+ iodev->modes = INDIO_DIRECT_MODE;
+ iodev->channels = spear_adc_iio_channels;
+ iodev->num_channels = ARRAY_SIZE(spear_adc_iio_channels);
+
+ ret = iio_device_register(iodev);
+ if (ret)
+ goto errout6;
+
+ dev_info(dev, "SPEAR ADC driver loaded, IRQ %d\n", irq);
+
+ return 0;
+
+errout6:
+ clk_disable(info->clk);
+errout5:
+ clk_unprepare(info->clk);
+errout4:
+ clk_put(info->clk);
+errout3:
+ iounmap(info->adc_base_spear6xx);
+errout2:
+ iio_device_free(iodev);
+errout1:
+ return ret;
+}
+
+static int __devexit spear_adc_remove(struct platform_device *pdev)
+{
+ struct iio_dev *iodev = platform_get_drvdata(pdev);
+ struct spear_adc_info *info = iio_priv(iodev);
+
+ iio_device_unregister(iodev);
+ platform_set_drvdata(pdev, NULL);
+ clk_disable(info->clk);
+ clk_unprepare(info->clk);
+ clk_put(info->clk);
+ iounmap(info->adc_base_spear6xx);
+ iio_device_free(iodev);
+
+ return 0;
+}
+
+static const struct of_device_id spear_adc_dt_ids[] = {
+ { .compatible = "st,spear600-adc", },
+ { /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(of, spear_adc_dt_ids);
+
+static struct platform_driver spear_adc_driver = {
+ .probe = spear_adc_probe,
+ .remove = __devexit_p(spear_adc_remove),
+ .driver = {
+ .name = MOD_NAME,
+ .owner = THIS_MODULE,
+ .of_match_table = of_match_ptr(spear_adc_dt_ids),
+ },
+};
+
+module_platform_driver(spear_adc_driver);
+
+MODULE_AUTHOR("Stefan Roese <sr@denx.de>");
+MODULE_DESCRIPTION("SPEAr ADC driver");
+MODULE_LICENSE("GPL");
diff --git a/drivers/staging/iio/addac/adt7316.c b/drivers/staging/iio/addac/adt7316.c
index fd6a45444058..8fb014a046a2 100644
--- a/drivers/staging/iio/addac/adt7316.c
+++ b/drivers/staging/iio/addac/adt7316.c
@@ -19,9 +19,9 @@
#include <linux/rtc.h>
#include <linux/module.h>
-#include "../iio.h"
-#include "../events.h"
-#include "../sysfs.h"
+#include <linux/iio/iio.h>
+#include <linux/iio/events.h>
+#include <linux/iio/sysfs.h>
#include "adt7316.h"
/*
@@ -220,7 +220,7 @@ static ssize_t adt7316_show_enabled(struct device *dev,
struct device_attribute *attr,
char *buf)
{
- struct iio_dev *dev_info = dev_get_drvdata(dev);
+ struct iio_dev *dev_info = dev_to_iio_dev(dev);
struct adt7316_chip_info *chip = iio_priv(dev_info);
return sprintf(buf, "%d\n", !!(chip->config1 & ADT7316_EN));
@@ -252,7 +252,7 @@ static ssize_t adt7316_store_enabled(struct device *dev,
const char *buf,
size_t len)
{
- struct iio_dev *dev_info = dev_get_drvdata(dev);
+ struct iio_dev *dev_info = dev_to_iio_dev(dev);
struct adt7316_chip_info *chip = iio_priv(dev_info);
int enable;
@@ -276,7 +276,7 @@ static ssize_t adt7316_show_select_ex_temp(struct device *dev,
struct device_attribute *attr,
char *buf)
{
- struct iio_dev *dev_info = dev_get_drvdata(dev);
+ struct iio_dev *dev_info = dev_to_iio_dev(dev);
struct adt7316_chip_info *chip = iio_priv(dev_info);
if ((chip->id & ID_FAMILY_MASK) != ID_ADT75XX)
@@ -290,7 +290,7 @@ static ssize_t adt7316_store_select_ex_temp(struct device *dev,
const char *buf,
size_t len)
{
- struct iio_dev *dev_info = dev_get_drvdata(dev);
+ struct iio_dev *dev_info = dev_to_iio_dev(dev);
struct adt7316_chip_info *chip = iio_priv(dev_info);
u8 config1;
int ret;
@@ -320,7 +320,7 @@ static ssize_t adt7316_show_mode(struct device *dev,
struct device_attribute *attr,
char *buf)
{
- struct iio_dev *dev_info = dev_get_drvdata(dev);
+ struct iio_dev *dev_info = dev_to_iio_dev(dev);
struct adt7316_chip_info *chip = iio_priv(dev_info);
if (chip->config2 & ADT7316_AD_SINGLE_CH_MODE)
@@ -334,7 +334,7 @@ static ssize_t adt7316_store_mode(struct device *dev,
const char *buf,
size_t len)
{
- struct iio_dev *dev_info = dev_get_drvdata(dev);
+ struct iio_dev *dev_info = dev_to_iio_dev(dev);
struct adt7316_chip_info *chip = iio_priv(dev_info);
u8 config2;
int ret;
@@ -370,7 +370,7 @@ static ssize_t adt7316_show_ad_channel(struct device *dev,
struct device_attribute *attr,
char *buf)
{
- struct iio_dev *dev_info = dev_get_drvdata(dev);
+ struct iio_dev *dev_info = dev_to_iio_dev(dev);
struct adt7316_chip_info *chip = iio_priv(dev_info);
if (!(chip->config2 & ADT7316_AD_SINGLE_CH_MODE))
@@ -409,7 +409,7 @@ static ssize_t adt7316_store_ad_channel(struct device *dev,
const char *buf,
size_t len)
{
- struct iio_dev *dev_info = dev_get_drvdata(dev);
+ struct iio_dev *dev_info = dev_to_iio_dev(dev);
struct adt7316_chip_info *chip = iio_priv(dev_info);
u8 config2;
unsigned long data = 0;
@@ -455,7 +455,7 @@ static ssize_t adt7316_show_all_ad_channels(struct device *dev,
struct device_attribute *attr,
char *buf)
{
- struct iio_dev *dev_info = dev_get_drvdata(dev);
+ struct iio_dev *dev_info = dev_to_iio_dev(dev);
struct adt7316_chip_info *chip = iio_priv(dev_info);
if (!(chip->config2 & ADT7316_AD_SINGLE_CH_MODE))
@@ -477,7 +477,7 @@ static ssize_t adt7316_show_disable_averaging(struct device *dev,
struct device_attribute *attr,
char *buf)
{
- struct iio_dev *dev_info = dev_get_drvdata(dev);
+ struct iio_dev *dev_info = dev_to_iio_dev(dev);
struct adt7316_chip_info *chip = iio_priv(dev_info);
return sprintf(buf, "%d\n",
@@ -489,7 +489,7 @@ static ssize_t adt7316_store_disable_averaging(struct device *dev,
const char *buf,
size_t len)
{
- struct iio_dev *dev_info = dev_get_drvdata(dev);
+ struct iio_dev *dev_info = dev_to_iio_dev(dev);
struct adt7316_chip_info *chip = iio_priv(dev_info);
u8 config2;
int ret;
@@ -516,7 +516,7 @@ static ssize_t adt7316_show_enable_smbus_timeout(struct device *dev,
struct device_attribute *attr,
char *buf)
{
- struct iio_dev *dev_info = dev_get_drvdata(dev);
+ struct iio_dev *dev_info = dev_to_iio_dev(dev);
struct adt7316_chip_info *chip = iio_priv(dev_info);
return sprintf(buf, "%d\n",
@@ -528,7 +528,7 @@ static ssize_t adt7316_store_enable_smbus_timeout(struct device *dev,
const char *buf,
size_t len)
{
- struct iio_dev *dev_info = dev_get_drvdata(dev);
+ struct iio_dev *dev_info = dev_to_iio_dev(dev);
struct adt7316_chip_info *chip = iio_priv(dev_info);
u8 config2;
int ret;
@@ -557,7 +557,7 @@ static ssize_t adt7316_store_reset(struct device *dev,
const char *buf,
size_t len)
{
- struct iio_dev *dev_info = dev_get_drvdata(dev);
+ struct iio_dev *dev_info = dev_to_iio_dev(dev);
struct adt7316_chip_info *chip = iio_priv(dev_info);
u8 config2;
int ret;
@@ -580,7 +580,7 @@ static ssize_t adt7316_show_powerdown(struct device *dev,
struct device_attribute *attr,
char *buf)
{
- struct iio_dev *dev_info = dev_get_drvdata(dev);
+ struct iio_dev *dev_info = dev_to_iio_dev(dev);
struct adt7316_chip_info *chip = iio_priv(dev_info);
return sprintf(buf, "%d\n", !!(chip->config1 & ADT7316_PD));
@@ -591,7 +591,7 @@ static ssize_t adt7316_store_powerdown(struct device *dev,
const char *buf,
size_t len)
{
- struct iio_dev *dev_info = dev_get_drvdata(dev);
+ struct iio_dev *dev_info = dev_to_iio_dev(dev);
struct adt7316_chip_info *chip = iio_priv(dev_info);
u8 config1;
int ret;
@@ -618,7 +618,7 @@ static ssize_t adt7316_show_fast_ad_clock(struct device *dev,
struct device_attribute *attr,
char *buf)
{
- struct iio_dev *dev_info = dev_get_drvdata(dev);
+ struct iio_dev *dev_info = dev_to_iio_dev(dev);
struct adt7316_chip_info *chip = iio_priv(dev_info);
return sprintf(buf, "%d\n", !!(chip->config3 & ADT7316_ADCLK_22_5));
@@ -629,7 +629,7 @@ static ssize_t adt7316_store_fast_ad_clock(struct device *dev,
const char *buf,
size_t len)
{
- struct iio_dev *dev_info = dev_get_drvdata(dev);
+ struct iio_dev *dev_info = dev_to_iio_dev(dev);
struct adt7316_chip_info *chip = iio_priv(dev_info);
u8 config3;
int ret;
@@ -656,7 +656,7 @@ static ssize_t adt7316_show_da_high_resolution(struct device *dev,
struct device_attribute *attr,
char *buf)
{
- struct iio_dev *dev_info = dev_get_drvdata(dev);
+ struct iio_dev *dev_info = dev_to_iio_dev(dev);
struct adt7316_chip_info *chip = iio_priv(dev_info);
if (chip->config3 & ADT7316_DA_HIGH_RESOLUTION) {
@@ -674,7 +674,7 @@ static ssize_t adt7316_store_da_high_resolution(struct device *dev,
const char *buf,
size_t len)
{
- struct iio_dev *dev_info = dev_get_drvdata(dev);
+ struct iio_dev *dev_info = dev_to_iio_dev(dev);
struct adt7316_chip_info *chip = iio_priv(dev_info);
u8 config3;
int ret;
@@ -708,7 +708,7 @@ static ssize_t adt7316_show_AIN_internal_Vref(struct device *dev,
struct device_attribute *attr,
char *buf)
{
- struct iio_dev *dev_info = dev_get_drvdata(dev);
+ struct iio_dev *dev_info = dev_to_iio_dev(dev);
struct adt7316_chip_info *chip = iio_priv(dev_info);
if ((chip->id & ID_FAMILY_MASK) != ID_ADT75XX)
@@ -723,7 +723,7 @@ static ssize_t adt7316_store_AIN_internal_Vref(struct device *dev,
const char *buf,
size_t len)
{
- struct iio_dev *dev_info = dev_get_drvdata(dev);
+ struct iio_dev *dev_info = dev_to_iio_dev(dev);
struct adt7316_chip_info *chip = iio_priv(dev_info);
u8 config3;
int ret;
@@ -755,7 +755,7 @@ static ssize_t adt7316_show_enable_prop_DACA(struct device *dev,
struct device_attribute *attr,
char *buf)
{
- struct iio_dev *dev_info = dev_get_drvdata(dev);
+ struct iio_dev *dev_info = dev_to_iio_dev(dev);
struct adt7316_chip_info *chip = iio_priv(dev_info);
return sprintf(buf, "%d\n",
@@ -767,7 +767,7 @@ static ssize_t adt7316_store_enable_prop_DACA(struct device *dev,
const char *buf,
size_t len)
{
- struct iio_dev *dev_info = dev_get_drvdata(dev);
+ struct iio_dev *dev_info = dev_to_iio_dev(dev);
struct adt7316_chip_info *chip = iio_priv(dev_info);
u8 config3;
int ret;
@@ -794,7 +794,7 @@ static ssize_t adt7316_show_enable_prop_DACB(struct device *dev,
struct device_attribute *attr,
char *buf)
{
- struct iio_dev *dev_info = dev_get_drvdata(dev);
+ struct iio_dev *dev_info = dev_to_iio_dev(dev);
struct adt7316_chip_info *chip = iio_priv(dev_info);
return sprintf(buf, "%d\n",
@@ -806,7 +806,7 @@ static ssize_t adt7316_store_enable_prop_DACB(struct device *dev,
const char *buf,
size_t len)
{
- struct iio_dev *dev_info = dev_get_drvdata(dev);
+ struct iio_dev *dev_info = dev_to_iio_dev(dev);
struct adt7316_chip_info *chip = iio_priv(dev_info);
u8 config3;
int ret;
@@ -833,7 +833,7 @@ static ssize_t adt7316_show_DAC_2Vref_ch_mask(struct device *dev,
struct device_attribute *attr,
char *buf)
{
- struct iio_dev *dev_info = dev_get_drvdata(dev);
+ struct iio_dev *dev_info = dev_to_iio_dev(dev);
struct adt7316_chip_info *chip = iio_priv(dev_info);
return sprintf(buf, "0x%x\n",
@@ -845,7 +845,7 @@ static ssize_t adt7316_store_DAC_2Vref_ch_mask(struct device *dev,
const char *buf,
size_t len)
{
- struct iio_dev *dev_info = dev_get_drvdata(dev);
+ struct iio_dev *dev_info = dev_to_iio_dev(dev);
struct adt7316_chip_info *chip = iio_priv(dev_info);
u8 dac_config;
unsigned long data = 0;
@@ -876,7 +876,7 @@ static ssize_t adt7316_show_DAC_update_mode(struct device *dev,
struct device_attribute *attr,
char *buf)
{
- struct iio_dev *dev_info = dev_get_drvdata(dev);
+ struct iio_dev *dev_info = dev_to_iio_dev(dev);
struct adt7316_chip_info *chip = iio_priv(dev_info);
if (!(chip->config3 & ADT7316_DA_EN_VIA_DAC_LDCA))
@@ -900,7 +900,7 @@ static ssize_t adt7316_store_DAC_update_mode(struct device *dev,
const char *buf,
size_t len)
{
- struct iio_dev *dev_info = dev_get_drvdata(dev);
+ struct iio_dev *dev_info = dev_to_iio_dev(dev);
struct adt7316_chip_info *chip = iio_priv(dev_info);
u8 dac_config;
unsigned long data;
@@ -934,7 +934,7 @@ static ssize_t adt7316_show_all_DAC_update_modes(struct device *dev,
struct device_attribute *attr,
char *buf)
{
- struct iio_dev *dev_info = dev_get_drvdata(dev);
+ struct iio_dev *dev_info = dev_to_iio_dev(dev);
struct adt7316_chip_info *chip = iio_priv(dev_info);
if (chip->config3 & ADT7316_DA_EN_VIA_DAC_LDCA)
@@ -955,7 +955,7 @@ static ssize_t adt7316_store_update_DAC(struct device *dev,
const char *buf,
size_t len)
{
- struct iio_dev *dev_info = dev_get_drvdata(dev);
+ struct iio_dev *dev_info = dev_to_iio_dev(dev);
struct adt7316_chip_info *chip = iio_priv(dev_info);
u8 ldac_config;
unsigned long data;
@@ -994,7 +994,7 @@ static ssize_t adt7316_show_DA_AB_Vref_bypass(struct device *dev,
struct device_attribute *attr,
char *buf)
{
- struct iio_dev *dev_info = dev_get_drvdata(dev);
+ struct iio_dev *dev_info = dev_to_iio_dev(dev);
struct adt7316_chip_info *chip = iio_priv(dev_info);
if ((chip->id & ID_FAMILY_MASK) == ID_ADT75XX)
@@ -1009,7 +1009,7 @@ static ssize_t adt7316_store_DA_AB_Vref_bypass(struct device *dev,
const char *buf,
size_t len)
{
- struct iio_dev *dev_info = dev_get_drvdata(dev);
+ struct iio_dev *dev_info = dev_to_iio_dev(dev);
struct adt7316_chip_info *chip = iio_priv(dev_info);
u8 dac_config;
int ret;
@@ -1039,7 +1039,7 @@ static ssize_t adt7316_show_DA_CD_Vref_bypass(struct device *dev,
struct device_attribute *attr,
char *buf)
{
- struct iio_dev *dev_info = dev_get_drvdata(dev);
+ struct iio_dev *dev_info = dev_to_iio_dev(dev);
struct adt7316_chip_info *chip = iio_priv(dev_info);
if ((chip->id & ID_FAMILY_MASK) == ID_ADT75XX)
@@ -1054,7 +1054,7 @@ static ssize_t adt7316_store_DA_CD_Vref_bypass(struct device *dev,
const char *buf,
size_t len)
{
- struct iio_dev *dev_info = dev_get_drvdata(dev);
+ struct iio_dev *dev_info = dev_to_iio_dev(dev);
struct adt7316_chip_info *chip = iio_priv(dev_info);
u8 dac_config;
int ret;
@@ -1084,7 +1084,7 @@ static ssize_t adt7316_show_DAC_internal_Vref(struct device *dev,
struct device_attribute *attr,
char *buf)
{
- struct iio_dev *dev_info = dev_get_drvdata(dev);
+ struct iio_dev *dev_info = dev_to_iio_dev(dev);
struct adt7316_chip_info *chip = iio_priv(dev_info);
if ((chip->id & ID_FAMILY_MASK) == ID_ADT75XX)
@@ -1101,7 +1101,7 @@ static ssize_t adt7316_store_DAC_internal_Vref(struct device *dev,
const char *buf,
size_t len)
{
- struct iio_dev *dev_info = dev_get_drvdata(dev);
+ struct iio_dev *dev_info = dev_to_iio_dev(dev);
struct adt7316_chip_info *chip = iio_priv(dev_info);
u8 ldac_config;
unsigned long data;
@@ -1220,7 +1220,7 @@ static ssize_t adt7316_show_VDD(struct device *dev,
struct device_attribute *attr,
char *buf)
{
- struct iio_dev *dev_info = dev_get_drvdata(dev);
+ struct iio_dev *dev_info = dev_to_iio_dev(dev);
struct adt7316_chip_info *chip = iio_priv(dev_info);
return adt7316_show_ad(chip, ADT7316_AD_SINGLE_CH_VDD, buf);
@@ -1231,7 +1231,7 @@ static ssize_t adt7316_show_in_temp(struct device *dev,
struct device_attribute *attr,
char *buf)
{
- struct iio_dev *dev_info = dev_get_drvdata(dev);
+ struct iio_dev *dev_info = dev_to_iio_dev(dev);
struct adt7316_chip_info *chip = iio_priv(dev_info);
return adt7316_show_ad(chip, ADT7316_AD_SINGLE_CH_IN, buf);
@@ -1243,7 +1243,7 @@ static ssize_t adt7316_show_ex_temp_AIN1(struct device *dev,
struct device_attribute *attr,
char *buf)
{
- struct iio_dev *dev_info = dev_get_drvdata(dev);
+ struct iio_dev *dev_info = dev_to_iio_dev(dev);
struct adt7316_chip_info *chip = iio_priv(dev_info);
return adt7316_show_ad(chip, ADT7316_AD_SINGLE_CH_EX, buf);
@@ -1256,7 +1256,7 @@ static ssize_t adt7316_show_AIN2(struct device *dev,
struct device_attribute *attr,
char *buf)
{
- struct iio_dev *dev_info = dev_get_drvdata(dev);
+ struct iio_dev *dev_info = dev_to_iio_dev(dev);
struct adt7316_chip_info *chip = iio_priv(dev_info);
return adt7316_show_ad(chip, ADT7516_AD_SINGLE_CH_AIN2, buf);
@@ -1267,7 +1267,7 @@ static ssize_t adt7316_show_AIN3(struct device *dev,
struct device_attribute *attr,
char *buf)
{
- struct iio_dev *dev_info = dev_get_drvdata(dev);
+ struct iio_dev *dev_info = dev_to_iio_dev(dev);
struct adt7316_chip_info *chip = iio_priv(dev_info);
return adt7316_show_ad(chip, ADT7516_AD_SINGLE_CH_AIN3, buf);
@@ -1278,7 +1278,7 @@ static ssize_t adt7316_show_AIN4(struct device *dev,
struct device_attribute *attr,
char *buf)
{
- struct iio_dev *dev_info = dev_get_drvdata(dev);
+ struct iio_dev *dev_info = dev_to_iio_dev(dev);
struct adt7316_chip_info *chip = iio_priv(dev_info);
return adt7316_show_ad(chip, ADT7516_AD_SINGLE_CH_AIN4, buf);
@@ -1330,7 +1330,7 @@ static ssize_t adt7316_show_in_temp_offset(struct device *dev,
struct device_attribute *attr,
char *buf)
{
- struct iio_dev *dev_info = dev_get_drvdata(dev);
+ struct iio_dev *dev_info = dev_to_iio_dev(dev);
struct adt7316_chip_info *chip = iio_priv(dev_info);
return adt7316_show_temp_offset(chip, ADT7316_IN_TEMP_OFFSET, buf);
@@ -1341,7 +1341,7 @@ static ssize_t adt7316_store_in_temp_offset(struct device *dev,
const char *buf,
size_t len)
{
- struct iio_dev *dev_info = dev_get_drvdata(dev);
+ struct iio_dev *dev_info = dev_to_iio_dev(dev);
struct adt7316_chip_info *chip = iio_priv(dev_info);
return adt7316_store_temp_offset(chip, ADT7316_IN_TEMP_OFFSET, buf, len);
@@ -1355,7 +1355,7 @@ static ssize_t adt7316_show_ex_temp_offset(struct device *dev,
struct device_attribute *attr,
char *buf)
{
- struct iio_dev *dev_info = dev_get_drvdata(dev);
+ struct iio_dev *dev_info = dev_to_iio_dev(dev);
struct adt7316_chip_info *chip = iio_priv(dev_info);
return adt7316_show_temp_offset(chip, ADT7316_EX_TEMP_OFFSET, buf);
@@ -1366,7 +1366,7 @@ static ssize_t adt7316_store_ex_temp_offset(struct device *dev,
const char *buf,
size_t len)
{
- struct iio_dev *dev_info = dev_get_drvdata(dev);
+ struct iio_dev *dev_info = dev_to_iio_dev(dev);
struct adt7316_chip_info *chip = iio_priv(dev_info);
return adt7316_store_temp_offset(chip, ADT7316_EX_TEMP_OFFSET, buf, len);
@@ -1380,7 +1380,7 @@ static ssize_t adt7316_show_in_analog_temp_offset(struct device *dev,
struct device_attribute *attr,
char *buf)
{
- struct iio_dev *dev_info = dev_get_drvdata(dev);
+ struct iio_dev *dev_info = dev_to_iio_dev(dev);
struct adt7316_chip_info *chip = iio_priv(dev_info);
return adt7316_show_temp_offset(chip,
@@ -1392,7 +1392,7 @@ static ssize_t adt7316_store_in_analog_temp_offset(struct device *dev,
const char *buf,
size_t len)
{
- struct iio_dev *dev_info = dev_get_drvdata(dev);
+ struct iio_dev *dev_info = dev_to_iio_dev(dev);
struct adt7316_chip_info *chip = iio_priv(dev_info);
return adt7316_store_temp_offset(chip,
@@ -1407,7 +1407,7 @@ static ssize_t adt7316_show_ex_analog_temp_offset(struct device *dev,
struct device_attribute *attr,
char *buf)
{
- struct iio_dev *dev_info = dev_get_drvdata(dev);
+ struct iio_dev *dev_info = dev_to_iio_dev(dev);
struct adt7316_chip_info *chip = iio_priv(dev_info);
return adt7316_show_temp_offset(chip,
@@ -1419,7 +1419,7 @@ static ssize_t adt7316_store_ex_analog_temp_offset(struct device *dev,
const char *buf,
size_t len)
{
- struct iio_dev *dev_info = dev_get_drvdata(dev);
+ struct iio_dev *dev_info = dev_to_iio_dev(dev);
struct adt7316_chip_info *chip = iio_priv(dev_info);
return adt7316_store_temp_offset(chip,
@@ -1504,7 +1504,7 @@ static ssize_t adt7316_show_DAC_A(struct device *dev,
struct device_attribute *attr,
char *buf)
{
- struct iio_dev *dev_info = dev_get_drvdata(dev);
+ struct iio_dev *dev_info = dev_to_iio_dev(dev);
struct adt7316_chip_info *chip = iio_priv(dev_info);
return adt7316_show_DAC(chip, 0, buf);
@@ -1515,7 +1515,7 @@ static ssize_t adt7316_store_DAC_A(struct device *dev,
const char *buf,
size_t len)
{
- struct iio_dev *dev_info = dev_get_drvdata(dev);
+ struct iio_dev *dev_info = dev_to_iio_dev(dev);
struct adt7316_chip_info *chip = iio_priv(dev_info);
return adt7316_store_DAC(chip, 0, buf, len);
@@ -1528,7 +1528,7 @@ static ssize_t adt7316_show_DAC_B(struct device *dev,
struct device_attribute *attr,
char *buf)
{
- struct iio_dev *dev_info = dev_get_drvdata(dev);
+ struct iio_dev *dev_info = dev_to_iio_dev(dev);
struct adt7316_chip_info *chip = iio_priv(dev_info);
return adt7316_show_DAC(chip, 1, buf);
@@ -1539,7 +1539,7 @@ static ssize_t adt7316_store_DAC_B(struct device *dev,
const char *buf,
size_t len)
{
- struct iio_dev *dev_info = dev_get_drvdata(dev);
+ struct iio_dev *dev_info = dev_to_iio_dev(dev);
struct adt7316_chip_info *chip = iio_priv(dev_info);
return adt7316_store_DAC(chip, 1, buf, len);
@@ -1552,7 +1552,7 @@ static ssize_t adt7316_show_DAC_C(struct device *dev,
struct device_attribute *attr,
char *buf)
{
- struct iio_dev *dev_info = dev_get_drvdata(dev);
+ struct iio_dev *dev_info = dev_to_iio_dev(dev);
struct adt7316_chip_info *chip = iio_priv(dev_info);
return adt7316_show_DAC(chip, 2, buf);
@@ -1563,7 +1563,7 @@ static ssize_t adt7316_store_DAC_C(struct device *dev,
const char *buf,
size_t len)
{
- struct iio_dev *dev_info = dev_get_drvdata(dev);
+ struct iio_dev *dev_info = dev_to_iio_dev(dev);
struct adt7316_chip_info *chip = iio_priv(dev_info);
return adt7316_store_DAC(chip, 2, buf, len);
@@ -1576,7 +1576,7 @@ static ssize_t adt7316_show_DAC_D(struct device *dev,
struct device_attribute *attr,
char *buf)
{
- struct iio_dev *dev_info = dev_get_drvdata(dev);
+ struct iio_dev *dev_info = dev_to_iio_dev(dev);
struct adt7316_chip_info *chip = iio_priv(dev_info);
return adt7316_show_DAC(chip, 3, buf);
@@ -1587,7 +1587,7 @@ static ssize_t adt7316_store_DAC_D(struct device *dev,
const char *buf,
size_t len)
{
- struct iio_dev *dev_info = dev_get_drvdata(dev);
+ struct iio_dev *dev_info = dev_to_iio_dev(dev);
struct adt7316_chip_info *chip = iio_priv(dev_info);
return adt7316_store_DAC(chip, 3, buf, len);
@@ -1600,7 +1600,7 @@ static ssize_t adt7316_show_device_id(struct device *dev,
struct device_attribute *attr,
char *buf)
{
- struct iio_dev *dev_info = dev_get_drvdata(dev);
+ struct iio_dev *dev_info = dev_to_iio_dev(dev);
struct adt7316_chip_info *chip = iio_priv(dev_info);
u8 id;
int ret;
@@ -1618,7 +1618,7 @@ static ssize_t adt7316_show_manufactorer_id(struct device *dev,
struct device_attribute *attr,
char *buf)
{
- struct iio_dev *dev_info = dev_get_drvdata(dev);
+ struct iio_dev *dev_info = dev_to_iio_dev(dev);
struct adt7316_chip_info *chip = iio_priv(dev_info);
u8 id;
int ret;
@@ -1637,7 +1637,7 @@ static ssize_t adt7316_show_device_rev(struct device *dev,
struct device_attribute *attr,
char *buf)
{
- struct iio_dev *dev_info = dev_get_drvdata(dev);
+ struct iio_dev *dev_info = dev_to_iio_dev(dev);
struct adt7316_chip_info *chip = iio_priv(dev_info);
u8 rev;
int ret;
@@ -1655,7 +1655,7 @@ static ssize_t adt7316_show_bus_type(struct device *dev,
struct device_attribute *attr,
char *buf)
{
- struct iio_dev *dev_info = dev_get_drvdata(dev);
+ struct iio_dev *dev_info = dev_to_iio_dev(dev);
struct adt7316_chip_info *chip = iio_priv(dev_info);
u8 stat;
int ret;
@@ -1841,7 +1841,7 @@ static ssize_t adt7316_show_int_mask(struct device *dev,
struct device_attribute *attr,
char *buf)
{
- struct iio_dev *dev_info = dev_get_drvdata(dev);
+ struct iio_dev *dev_info = dev_to_iio_dev(dev);
struct adt7316_chip_info *chip = iio_priv(dev_info);
return sprintf(buf, "0x%x\n", chip->int_mask);
@@ -1855,7 +1855,7 @@ static ssize_t adt7316_set_int_mask(struct device *dev,
const char *buf,
size_t len)
{
- struct iio_dev *dev_info = dev_get_drvdata(dev);
+ struct iio_dev *dev_info = dev_to_iio_dev(dev);
struct adt7316_chip_info *chip = iio_priv(dev_info);
unsigned long data;
int ret;
@@ -1895,7 +1895,7 @@ static inline ssize_t adt7316_show_ad_bound(struct device *dev,
char *buf)
{
struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
- struct iio_dev *dev_info = dev_get_drvdata(dev);
+ struct iio_dev *dev_info = dev_to_iio_dev(dev);
struct adt7316_chip_info *chip = iio_priv(dev_info);
u8 val;
int data;
@@ -1926,7 +1926,7 @@ static inline ssize_t adt7316_set_ad_bound(struct device *dev,
size_t len)
{
struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
- struct iio_dev *dev_info = dev_get_drvdata(dev);
+ struct iio_dev *dev_info = dev_to_iio_dev(dev);
struct adt7316_chip_info *chip = iio_priv(dev_info);
long data;
u8 val;
@@ -1965,7 +1965,7 @@ static ssize_t adt7316_show_int_enabled(struct device *dev,
struct device_attribute *attr,
char *buf)
{
- struct iio_dev *dev_info = dev_get_drvdata(dev);
+ struct iio_dev *dev_info = dev_to_iio_dev(dev);
struct adt7316_chip_info *chip = iio_priv(dev_info);
return sprintf(buf, "%d\n", !!(chip->config1 & ADT7316_INT_EN));
@@ -1976,7 +1976,7 @@ static ssize_t adt7316_set_int_enabled(struct device *dev,
const char *buf,
size_t len)
{
- struct iio_dev *dev_info = dev_get_drvdata(dev);
+ struct iio_dev *dev_info = dev_to_iio_dev(dev);
struct adt7316_chip_info *chip = iio_priv(dev_info);
u8 config1;
int ret;
@@ -2133,7 +2133,7 @@ int __devinit adt7316_probe(struct device *dev, struct adt7316_bus *bus,
unsigned short *adt7316_platform_data = dev->platform_data;
int ret = 0;
- indio_dev = iio_allocate_device(sizeof(*chip));
+ indio_dev = iio_device_alloc(sizeof(*chip));
if (indio_dev == NULL) {
ret = -ENOMEM;
goto error_ret;
@@ -2210,7 +2210,7 @@ int __devinit adt7316_probe(struct device *dev, struct adt7316_bus *bus,
error_unreg_irq:
free_irq(chip->bus.irq, indio_dev);
error_free_dev:
- iio_free_device(indio_dev);
+ iio_device_free(indio_dev);
error_ret:
return ret;
}
@@ -2224,7 +2224,7 @@ int __devexit adt7316_remove(struct device *dev)
iio_device_unregister(indio_dev);
if (chip->bus.irq)
free_irq(chip->bus.irq, indio_dev);
- iio_free_device(indio_dev);
+ iio_device_free(indio_dev);
return 0;
}
diff --git a/drivers/staging/iio/buffer.h b/drivers/staging/iio/buffer.h
deleted file mode 100644
index df2046dcb623..000000000000
--- a/drivers/staging/iio/buffer.h
+++ /dev/null
@@ -1,193 +0,0 @@
-/* The industrial I/O core - generic buffer interfaces.
- *
- * Copyright (c) 2008 Jonathan Cameron
- *
- * 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 _IIO_BUFFER_GENERIC_H_
-#define _IIO_BUFFER_GENERIC_H_
-#include <linux/sysfs.h>
-#include "iio.h"
-
-#ifdef CONFIG_IIO_BUFFER
-
-struct iio_buffer;
-
-/**
- * struct iio_buffer_access_funcs - access functions for buffers.
- * @store_to: actually store stuff to the buffer
- * @read_first_n: try to get a specified number of bytes (must exist)
- * @request_update: if a parameter change has been marked, update underlying
- * storage.
- * @get_bytes_per_datum:get current bytes per datum
- * @set_bytes_per_datum:set number of bytes per datum
- * @get_length: get number of datums in buffer
- * @set_length: set number of datums in buffer
- *
- * The purpose of this structure is to make the buffer element
- * modular as event for a given driver, different usecases may require
- * different buffer designs (space efficiency vs speed for example).
- *
- * It is worth noting that a given buffer implementation may only support a
- * small proportion of these functions. The core code 'should' cope fine with
- * any of them not existing.
- **/
-struct iio_buffer_access_funcs {
- int (*store_to)(struct iio_buffer *buffer, u8 *data, s64 timestamp);
- int (*read_first_n)(struct iio_buffer *buffer,
- size_t n,
- char __user *buf);
-
- int (*request_update)(struct iio_buffer *buffer);
-
- int (*get_bytes_per_datum)(struct iio_buffer *buffer);
- int (*set_bytes_per_datum)(struct iio_buffer *buffer, size_t bpd);
- int (*get_length)(struct iio_buffer *buffer);
- int (*set_length)(struct iio_buffer *buffer, int length);
-};
-
-/**
- * struct iio_buffer - general buffer structure
- * @length: [DEVICE] number of datums in buffer
- * @bytes_per_datum: [DEVICE] size of individual datum including timestamp
- * @scan_el_attrs: [DRIVER] control of scan elements if that scan mode
- * control method is used
- * @scan_mask: [INTERN] bitmask used in masking scan mode elements
- * @scan_index_timestamp:[INTERN] cache of the index to the timestamp
- * @scan_timestamp: [INTERN] does the scan mode include a timestamp
- * @access: [DRIVER] buffer access functions associated with the
- * implementation.
- * @scan_el_dev_attr_list:[INTERN] list of scan element related attributes.
- * @scan_el_group: [DRIVER] attribute group for those attributes not
- * created from the iio_chan_info array.
- * @pollq: [INTERN] wait queue to allow for polling on the buffer.
- * @stufftoread: [INTERN] flag to indicate new data.
- * @demux_list: [INTERN] list of operations required to demux the scan.
- * @demux_bounce: [INTERN] buffer for doing gather from incoming scan.
- **/
-struct iio_buffer {
- int length;
- int bytes_per_datum;
- struct attribute_group *scan_el_attrs;
- long *scan_mask;
- bool scan_timestamp;
- unsigned scan_index_timestamp;
- const struct iio_buffer_access_funcs *access;
- struct list_head scan_el_dev_attr_list;
- struct attribute_group scan_el_group;
- wait_queue_head_t pollq;
- bool stufftoread;
- const struct attribute_group *attrs;
- struct list_head demux_list;
- unsigned char *demux_bounce;
-};
-
-/**
- * iio_buffer_init() - Initialize the buffer structure
- * @buffer: buffer to be initialized
- **/
-void iio_buffer_init(struct iio_buffer *buffer);
-
-/**
- * __iio_update_buffer() - update common elements of buffers
- * @buffer: buffer that is the event source
- * @bytes_per_datum: size of individual datum including timestamp
- * @length: number of datums in buffer
- **/
-static inline void __iio_update_buffer(struct iio_buffer *buffer,
- int bytes_per_datum, int length)
-{
- buffer->bytes_per_datum = bytes_per_datum;
- buffer->length = length;
-}
-
-int iio_scan_mask_query(struct iio_dev *indio_dev,
- struct iio_buffer *buffer, int bit);
-
-/**
- * iio_scan_mask_set() - set particular bit in the scan mask
- * @buffer: the buffer whose scan mask we are interested in
- * @bit: the bit to be set.
- **/
-int iio_scan_mask_set(struct iio_dev *indio_dev,
- struct iio_buffer *buffer, int bit);
-
-/**
- * iio_push_to_buffer() - push to a registered buffer.
- * @buffer: IIO buffer structure for device
- * @scan: Full scan.
- * @timestamp:
- */
-int iio_push_to_buffer(struct iio_buffer *buffer, unsigned char *data,
- s64 timestamp);
-
-int iio_update_demux(struct iio_dev *indio_dev);
-
-/**
- * iio_buffer_register() - register the buffer with IIO core
- * @indio_dev: device with the buffer to be registered
- **/
-int iio_buffer_register(struct iio_dev *indio_dev,
- const struct iio_chan_spec *channels,
- int num_channels);
-
-/**
- * iio_buffer_unregister() - unregister the buffer from IIO core
- * @indio_dev: the device with the buffer to be unregistered
- **/
-void iio_buffer_unregister(struct iio_dev *indio_dev);
-
-/**
- * iio_buffer_read_length() - attr func to get number of datums in the buffer
- **/
-ssize_t iio_buffer_read_length(struct device *dev,
- struct device_attribute *attr,
- char *buf);
-/**
- * iio_buffer_write_length() - attr func to set number of datums in the buffer
- **/
-ssize_t iio_buffer_write_length(struct device *dev,
- struct device_attribute *attr,
- const char *buf,
- size_t len);
-/**
- * iio_buffer_store_enable() - attr to turn the buffer on
- **/
-ssize_t iio_buffer_store_enable(struct device *dev,
- struct device_attribute *attr,
- const char *buf,
- size_t len);
-/**
- * iio_buffer_show_enable() - attr to see if the buffer is on
- **/
-ssize_t iio_buffer_show_enable(struct device *dev,
- struct device_attribute *attr,
- char *buf);
-#define IIO_BUFFER_LENGTH_ATTR DEVICE_ATTR(length, S_IRUGO | S_IWUSR, \
- iio_buffer_read_length, \
- iio_buffer_write_length)
-
-#define IIO_BUFFER_ENABLE_ATTR DEVICE_ATTR(enable, S_IRUGO | S_IWUSR, \
- iio_buffer_show_enable, \
- iio_buffer_store_enable)
-
-int iio_sw_buffer_preenable(struct iio_dev *indio_dev);
-
-#else /* CONFIG_IIO_BUFFER */
-
-static inline int iio_buffer_register(struct iio_dev *indio_dev,
- struct iio_chan_spec *channels,
- int num_channels)
-{
- return 0;
-}
-
-static inline void iio_buffer_unregister(struct iio_dev *indio_dev)
-{};
-
-#endif /* CONFIG_IIO_BUFFER */
-
-#endif /* _IIO_BUFFER_GENERIC_H_ */
diff --git a/drivers/staging/iio/cdc/ad7150.c b/drivers/staging/iio/cdc/ad7150.c
index e4a08dc9b6f5..6a4041417d4e 100644
--- a/drivers/staging/iio/cdc/ad7150.c
+++ b/drivers/staging/iio/cdc/ad7150.c
@@ -13,9 +13,9 @@
#include <linux/i2c.h>
#include <linux/module.h>
-#include "../iio.h"
-#include "../sysfs.h"
-#include "../events.h"
+#include <linux/iio/iio.h>
+#include <linux/iio/sysfs.h>
+#include <linux/iio/events.h>
/*
* AD7150 registers definition
*/
@@ -104,7 +104,7 @@ static int ad7150_read_raw(struct iio_dev *indio_dev,
struct ad7150_chip_info *chip = iio_priv(indio_dev);
switch (mask) {
- case 0:
+ case IIO_CHAN_INFO_RAW:
ret = i2c_smbus_read_word_data(chip->client,
ad7150_addresses[chan->channel][0]);
if (ret < 0)
@@ -341,7 +341,7 @@ static ssize_t ad7150_show_timeout(struct device *dev,
struct device_attribute *attr,
char *buf)
{
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct ad7150_chip_info *chip = iio_priv(indio_dev);
struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
u8 value;
@@ -370,7 +370,7 @@ static ssize_t ad7150_store_timeout(struct device *dev,
const char *buf,
size_t len)
{
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct ad7150_chip_info *chip = iio_priv(indio_dev);
struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
int chan = IIO_EVENT_CODE_EXTRACT_CHAN(this_attr->address);
@@ -429,7 +429,8 @@ static const struct iio_chan_spec ad7150_channels[] = {
.type = IIO_CAPACITANCE,
.indexed = 1,
.channel = 0,
- .info_mask = IIO_CHAN_INFO_AVERAGE_RAW_SEPARATE_BIT,
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
+ IIO_CHAN_INFO_AVERAGE_RAW_SEPARATE_BIT,
.event_mask =
IIO_EV_BIT(IIO_EV_TYPE_THRESH, IIO_EV_DIR_RISING) |
IIO_EV_BIT(IIO_EV_TYPE_THRESH, IIO_EV_DIR_FALLING) |
@@ -441,7 +442,8 @@ static const struct iio_chan_spec ad7150_channels[] = {
.type = IIO_CAPACITANCE,
.indexed = 1,
.channel = 1,
- .info_mask = IIO_CHAN_INFO_AVERAGE_RAW_SEPARATE_BIT,
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
+ IIO_CHAN_INFO_AVERAGE_RAW_SEPARATE_BIT,
.event_mask =
IIO_EV_BIT(IIO_EV_TYPE_THRESH, IIO_EV_DIR_RISING) |
IIO_EV_BIT(IIO_EV_TYPE_THRESH, IIO_EV_DIR_FALLING) |
@@ -556,7 +558,7 @@ static int __devinit ad7150_probe(struct i2c_client *client,
struct ad7150_chip_info *chip;
struct iio_dev *indio_dev;
- indio_dev = iio_allocate_device(sizeof(*chip));
+ indio_dev = iio_device_alloc(sizeof(*chip));
if (indio_dev == NULL) {
ret = -ENOMEM;
goto error_ret;
@@ -583,7 +585,8 @@ static int __devinit ad7150_probe(struct i2c_client *client,
NULL,
&ad7150_event_handler,
IRQF_TRIGGER_RISING |
- IRQF_TRIGGER_FALLING,
+ IRQF_TRIGGER_FALLING |
+ IRQF_ONESHOT,
"ad7150_irq1",
indio_dev);
if (ret)
@@ -596,7 +599,8 @@ static int __devinit ad7150_probe(struct i2c_client *client,
NULL,
&ad7150_event_handler,
IRQF_TRIGGER_RISING |
- IRQF_TRIGGER_FALLING,
+ IRQF_TRIGGER_FALLING |
+ IRQF_ONESHOT,
"ad7150_irq2",
indio_dev);
if (ret)
@@ -619,7 +623,7 @@ error_free_irq:
if (client->irq)
free_irq(client->irq, indio_dev);
error_free_dev:
- iio_free_device(indio_dev);
+ iio_device_free(indio_dev);
error_ret:
return ret;
}
@@ -635,7 +639,7 @@ static int __devexit ad7150_remove(struct i2c_client *client)
if (client->dev.platform_data)
free_irq(*(unsigned int *)client->dev.platform_data, indio_dev);
- iio_free_device(indio_dev);
+ iio_device_free(indio_dev);
return 0;
}
diff --git a/drivers/staging/iio/cdc/ad7152.c b/drivers/staging/iio/cdc/ad7152.c
index fdb83c35e6dd..98c3015116aa 100644
--- a/drivers/staging/iio/cdc/ad7152.c
+++ b/drivers/staging/iio/cdc/ad7152.c
@@ -15,8 +15,8 @@
#include <linux/module.h>
#include <linux/delay.h>
-#include "../iio.h"
-#include "../sysfs.h"
+#include <linux/iio/iio.h>
+#include <linux/iio/sysfs.h>
/*
* TODO: Check compliance of calibbias with abi (units)
@@ -97,7 +97,7 @@ static inline ssize_t ad7152_start_calib(struct device *dev,
size_t len,
u8 regval)
{
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct ad7152_chip_info *chip = iio_priv(indio_dev);
struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
bool doit;
@@ -169,7 +169,7 @@ static ssize_t ad7152_show_filter_rate_setup(struct device *dev,
struct device_attribute *attr,
char *buf)
{
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct ad7152_chip_info *chip = iio_priv(indio_dev);
return sprintf(buf, "%d\n",
@@ -181,7 +181,7 @@ static ssize_t ad7152_store_filter_rate_setup(struct device *dev,
const char *buf,
size_t len)
{
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct ad7152_chip_info *chip = iio_priv(indio_dev);
u8 data;
int ret, i;
@@ -329,7 +329,7 @@ static int ad7152_read_raw(struct iio_dev *indio_dev,
mutex_lock(&indio_dev->mlock);
switch (mask) {
- case 0:
+ case IIO_CHAN_INFO_RAW:
/* First set whether in differential mode */
regval = chip->setup[chan->channel];
@@ -436,7 +436,8 @@ static const struct iio_chan_spec ad7152_channels[] = {
.type = IIO_CAPACITANCE,
.indexed = 1,
.channel = 0,
- .info_mask = IIO_CHAN_INFO_CALIBSCALE_SEPARATE_BIT |
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
+ IIO_CHAN_INFO_CALIBSCALE_SEPARATE_BIT |
IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT |
IIO_CHAN_INFO_SCALE_SEPARATE_BIT,
}, {
@@ -445,14 +446,16 @@ static const struct iio_chan_spec ad7152_channels[] = {
.indexed = 1,
.channel = 0,
.channel2 = 2,
- .info_mask = IIO_CHAN_INFO_CALIBSCALE_SEPARATE_BIT |
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
+ IIO_CHAN_INFO_CALIBSCALE_SEPARATE_BIT |
IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT |
IIO_CHAN_INFO_SCALE_SEPARATE_BIT,
}, {
.type = IIO_CAPACITANCE,
.indexed = 1,
.channel = 1,
- .info_mask = IIO_CHAN_INFO_CALIBSCALE_SEPARATE_BIT |
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
+ IIO_CHAN_INFO_CALIBSCALE_SEPARATE_BIT |
IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT |
IIO_CHAN_INFO_SCALE_SEPARATE_BIT,
}, {
@@ -461,7 +464,8 @@ static const struct iio_chan_spec ad7152_channels[] = {
.indexed = 1,
.channel = 1,
.channel2 = 3,
- .info_mask = IIO_CHAN_INFO_CALIBSCALE_SEPARATE_BIT |
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
+ IIO_CHAN_INFO_CALIBSCALE_SEPARATE_BIT |
IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT |
IIO_CHAN_INFO_SCALE_SEPARATE_BIT,
}
@@ -477,7 +481,7 @@ static int __devinit ad7152_probe(struct i2c_client *client,
struct ad7152_chip_info *chip;
struct iio_dev *indio_dev;
- indio_dev = iio_allocate_device(sizeof(*chip));
+ indio_dev = iio_device_alloc(sizeof(*chip));
if (indio_dev == NULL) {
ret = -ENOMEM;
goto error_ret;
@@ -509,7 +513,7 @@ static int __devinit ad7152_probe(struct i2c_client *client,
return 0;
error_free_dev:
- iio_free_device(indio_dev);
+ iio_device_free(indio_dev);
error_ret:
return ret;
}
@@ -519,7 +523,7 @@ static int __devexit ad7152_remove(struct i2c_client *client)
struct iio_dev *indio_dev = i2c_get_clientdata(client);
iio_device_unregister(indio_dev);
- iio_free_device(indio_dev);
+ iio_device_free(indio_dev);
return 0;
}
diff --git a/drivers/staging/iio/cdc/ad7746.c b/drivers/staging/iio/cdc/ad7746.c
index 40b8512cbc32..754e11e87193 100644
--- a/drivers/staging/iio/cdc/ad7746.c
+++ b/drivers/staging/iio/cdc/ad7746.c
@@ -16,8 +16,8 @@
#include <linux/module.h>
#include <linux/stat.h>
-#include "../iio.h"
-#include "../sysfs.h"
+#include <linux/iio/iio.h>
+#include <linux/iio/sysfs.h>
#include "ad7746.h"
@@ -123,7 +123,8 @@ static const struct iio_chan_spec ad7746_channels[] = {
.type = IIO_VOLTAGE,
.indexed = 1,
.channel = 0,
- .info_mask = IIO_CHAN_INFO_SCALE_SHARED_BIT,
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
+ IIO_CHAN_INFO_SCALE_SHARED_BIT,
.address = AD7746_REG_VT_DATA_HIGH << 8 |
AD7746_VTSETUP_VTMD_EXT_VIN,
},
@@ -132,7 +133,8 @@ static const struct iio_chan_spec ad7746_channels[] = {
.indexed = 1,
.channel = 1,
.extend_name = "supply",
- .info_mask = IIO_CHAN_INFO_SCALE_SHARED_BIT,
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
+ IIO_CHAN_INFO_SCALE_SHARED_BIT,
.address = AD7746_REG_VT_DATA_HIGH << 8 |
AD7746_VTSETUP_VTMD_VDD_MON,
},
@@ -140,7 +142,7 @@ static const struct iio_chan_spec ad7746_channels[] = {
.type = IIO_TEMP,
.indexed = 1,
.channel = 0,
- .processed_val = IIO_PROCESSED,
+ .info_mask = IIO_CHAN_INFO_PROCESSED_SEPARATE_BIT,
.address = AD7746_REG_VT_DATA_HIGH << 8 |
AD7746_VTSETUP_VTMD_INT_TEMP,
},
@@ -148,7 +150,7 @@ static const struct iio_chan_spec ad7746_channels[] = {
.type = IIO_TEMP,
.indexed = 1,
.channel = 1,
- .processed_val = IIO_PROCESSED,
+ .info_mask = IIO_CHAN_INFO_PROCESSED_SEPARATE_BIT,
.address = AD7746_REG_VT_DATA_HIGH << 8 |
AD7746_VTSETUP_VTMD_EXT_TEMP,
},
@@ -156,7 +158,8 @@ static const struct iio_chan_spec ad7746_channels[] = {
.type = IIO_CAPACITANCE,
.indexed = 1,
.channel = 0,
- .info_mask = IIO_CHAN_INFO_CALIBSCALE_SEPARATE_BIT |
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
+ IIO_CHAN_INFO_CALIBSCALE_SEPARATE_BIT |
IIO_CHAN_INFO_CALIBBIAS_SHARED_BIT |
IIO_CHAN_INFO_OFFSET_SEPARATE_BIT |
IIO_CHAN_INFO_SCALE_SHARED_BIT,
@@ -168,7 +171,8 @@ static const struct iio_chan_spec ad7746_channels[] = {
.indexed = 1,
.channel = 0,
.channel2 = 2,
- .info_mask = IIO_CHAN_INFO_CALIBSCALE_SEPARATE_BIT |
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
+ IIO_CHAN_INFO_CALIBSCALE_SEPARATE_BIT |
IIO_CHAN_INFO_CALIBBIAS_SHARED_BIT |
IIO_CHAN_INFO_OFFSET_SEPARATE_BIT |
IIO_CHAN_INFO_SCALE_SHARED_BIT,
@@ -179,7 +183,8 @@ static const struct iio_chan_spec ad7746_channels[] = {
.type = IIO_CAPACITANCE,
.indexed = 1,
.channel = 1,
- .info_mask = IIO_CHAN_INFO_CALIBSCALE_SEPARATE_BIT |
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
+ IIO_CHAN_INFO_CALIBSCALE_SEPARATE_BIT |
IIO_CHAN_INFO_CALIBBIAS_SHARED_BIT |
IIO_CHAN_INFO_OFFSET_SEPARATE_BIT |
IIO_CHAN_INFO_SCALE_SHARED_BIT,
@@ -192,7 +197,8 @@ static const struct iio_chan_spec ad7746_channels[] = {
.indexed = 1,
.channel = 1,
.channel2 = 3,
- .info_mask = IIO_CHAN_INFO_CALIBSCALE_SEPARATE_BIT |
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
+ IIO_CHAN_INFO_CALIBSCALE_SEPARATE_BIT |
IIO_CHAN_INFO_CALIBBIAS_SHARED_BIT |
IIO_CHAN_INFO_OFFSET_SEPARATE_BIT |
IIO_CHAN_INFO_SCALE_SHARED_BIT,
@@ -280,7 +286,7 @@ static inline ssize_t ad7746_start_calib(struct device *dev,
size_t len,
u8 regval)
{
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct ad7746_chip_info *chip = iio_priv(indio_dev);
bool doit;
int ret, timeout = 10;
@@ -319,7 +325,7 @@ static ssize_t ad7746_start_offset_calib(struct device *dev,
const char *buf,
size_t len)
{
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
int ret = ad7746_select_channel(indio_dev,
&ad7746_channels[to_iio_dev_attr(attr)->address]);
if (ret < 0)
@@ -334,7 +340,7 @@ static ssize_t ad7746_start_gain_calib(struct device *dev,
const char *buf,
size_t len)
{
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
int ret = ad7746_select_channel(indio_dev,
&ad7746_channels[to_iio_dev_attr(attr)->address]);
if (ret < 0)
@@ -359,7 +365,7 @@ static ssize_t ad7746_show_cap_filter_rate_setup(struct device *dev,
struct device_attribute *attr,
char *buf)
{
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct ad7746_chip_info *chip = iio_priv(indio_dev);
return sprintf(buf, "%d\n", ad7746_cap_filter_rate_table[
@@ -371,7 +377,7 @@ static ssize_t ad7746_store_cap_filter_rate_setup(struct device *dev,
const char *buf,
size_t len)
{
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct ad7746_chip_info *chip = iio_priv(indio_dev);
u8 data;
int ret, i;
@@ -399,7 +405,7 @@ static ssize_t ad7746_show_vt_filter_rate_setup(struct device *dev,
struct device_attribute *attr,
char *buf)
{
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct ad7746_chip_info *chip = iio_priv(indio_dev);
return sprintf(buf, "%d\n", ad7746_vt_filter_rate_table[
@@ -411,7 +417,7 @@ static ssize_t ad7746_store_vt_filter_rate_setup(struct device *dev,
const char *buf,
size_t len)
{
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct ad7746_chip_info *chip = iio_priv(indio_dev);
u8 data;
int ret, i;
@@ -572,7 +578,8 @@ static int ad7746_read_raw(struct iio_dev *indio_dev,
mutex_lock(&indio_dev->mlock);
switch (mask) {
- case 0:
+ case IIO_CHAN_INFO_RAW:
+ case IIO_CHAN_INFO_PROCESSED:
ret = ad7746_select_channel(indio_dev, chan);
if (ret < 0)
goto out;
@@ -696,7 +703,7 @@ static int __devinit ad7746_probe(struct i2c_client *client,
int ret = 0;
unsigned char regval = 0;
- indio_dev = iio_allocate_device(sizeof(*chip));
+ indio_dev = iio_device_alloc(sizeof(*chip));
if (indio_dev == NULL) {
ret = -ENOMEM;
goto error_ret;
@@ -756,7 +763,7 @@ static int __devinit ad7746_probe(struct i2c_client *client,
return 0;
error_free_dev:
- iio_free_device(indio_dev);
+ iio_device_free(indio_dev);
error_ret:
return ret;
}
@@ -766,7 +773,7 @@ static int __devexit ad7746_remove(struct i2c_client *client)
struct iio_dev *indio_dev = i2c_get_clientdata(client);
iio_device_unregister(indio_dev);
- iio_free_device(indio_dev);
+ iio_device_free(indio_dev);
return 0;
}
diff --git a/drivers/staging/iio/consumer.h b/drivers/staging/iio/consumer.h
deleted file mode 100644
index 36a060cd3a21..000000000000
--- a/drivers/staging/iio/consumer.h
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * Industrial I/O in kernel consumer interface
- *
- * Copyright (c) 2011 Jonathan Cameron
- *
- * 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 _IIO_INKERN_CONSUMER_H_
-#define _IIO_INKERN_CONSUMER_H
-#include "types.h"
-
-struct iio_dev;
-struct iio_chan_spec;
-
-/**
- * struct iio_channel - everything needed for a consumer to use a channel
- * @indio_dev: Device on which the channel exists.
- * @channel: Full description of the channel.
- */
-struct iio_channel {
- struct iio_dev *indio_dev;
- const struct iio_chan_spec *channel;
-};
-
-/**
- * iio_channel_get() - get description of all that is needed to access channel.
- * @name: Unique name of the device as provided in the iio_map
- * with which the desired provider to consumer mapping
- * was registered.
- * @consumer_channel: Unique name to identify the channel on the consumer
- * side. This typically describes the channels use within
- * the consumer. E.g. 'battery_voltage'
- */
-struct iio_channel *iio_st_channel_get(const char *name,
- const char *consumer_channel);
-
-/**
- * iio_st_channel_release() - release channels obtained via iio_st_channel_get
- * @chan: The channel to be released.
- */
-void iio_st_channel_release(struct iio_channel *chan);
-
-/**
- * iio_st_channel_get_all() - get all channels associated with a client
- * @name: name of consumer device.
- *
- * Returns an array of iio_channel structures terminated with one with
- * null iio_dev pointer.
- * This function is used by fairly generic consumers to get all the
- * channels registered as having this consumer.
- */
-struct iio_channel *iio_st_channel_get_all(const char *name);
-
-/**
- * iio_st_channel_release_all() - reverse iio_st_get_all
- * @chan: Array of channels to be released.
- */
-void iio_st_channel_release_all(struct iio_channel *chan);
-
-/**
- * iio_st_read_channel_raw() - read from a given channel
- * @channel: The channel being queried.
- * @val: Value read back.
- *
- * Note raw reads from iio channels are in adc counts and hence
- * scale will need to be applied if standard units required.
- */
-int iio_st_read_channel_raw(struct iio_channel *chan,
- int *val);
-
-/**
- * iio_st_get_channel_type() - get the type of a channel
- * @channel: The channel being queried.
- * @type: The type of the channel.
- *
- * returns the enum iio_chan_type of the channel
- */
-int iio_st_get_channel_type(struct iio_channel *channel,
- enum iio_chan_type *type);
-
-/**
- * iio_st_read_channel_scale() - read the scale value for a channel
- * @channel: The channel being queried.
- * @val: First part of value read back.
- * @val2: Second part of value read back.
- *
- * Note returns a description of what is in val and val2, such
- * as IIO_VAL_INT_PLUS_MICRO telling us we have a value of val
- * + val2/1e6
- */
-int iio_st_read_channel_scale(struct iio_channel *chan, int *val,
- int *val2);
-
-#endif
diff --git a/drivers/staging/iio/dac/Kconfig b/drivers/staging/iio/dac/Kconfig
deleted file mode 100644
index a57803a5d1a7..000000000000
--- a/drivers/staging/iio/dac/Kconfig
+++ /dev/null
@@ -1,121 +0,0 @@
-#
-# DAC drivers
-#
-menu "Digital to analog converters"
-
-config AD5064
- tristate "Analog Devices AD5064/64-1/65/44/45/24/25, AD5628/48/66/68 DAC driver"
- depends on SPI
- help
- Say yes here to build support for Analog Devices AD5024, AD5025, AD5044,
- AD5045, AD5064, AD5064-1, AD5065, AD5628, AD5648, AD5666, AD5668 Digital
- to Analog Converter.
-
- To compile this driver as a module, choose M here: the
- module will be called ad5064.
-
-config AD5360
- tristate "Analog Devices Analog Devices AD5360/61/62/63/70/71/73 DAC driver"
- depends on SPI
- help
- Say yes here to build support for Analog Devices AD5360, AD5361,
- AD5362, AD5363, AD5370, AD5371, AD5373 multi-channel
- Digital to Analog Converters (DAC).
-
- To compile this driver as module choose M here: the module will be called
- ad5360.
-
-config AD5380
- tristate "Analog Devices AD5380/81/82/83/84/90/91/92 DAC driver"
- depends on (SPI_MASTER || I2C)
- select REGMAP_I2C if I2C
- select REGMAP_SPI if SPI_MASTER
- help
- Say yes here to build support for Analog Devices AD5380, AD5381,
- AD5382, AD5383, AD5384, AD5390, AD5391, AD5392 multi-channel
- Digital to Analog Converters (DAC).
-
- To compile this driver as module choose M here: the module will be called
- ad5380.
-
-config AD5421
- tristate "Analog Devices AD5421 DAC driver"
- depends on SPI
- help
- Say yes here to build support for Analog Devices AD5421 loop-powered
- digital-to-analog convertors (DAC).
-
- To compile this driver as module choose M here: the module will be called
- ad5421.
-
-config AD5624R_SPI
- tristate "Analog Devices AD5624/44/64R DAC spi driver"
- depends on SPI
- help
- Say yes here to build support for Analog Devices AD5624R, AD5644R and
- AD5664R converters (DAC). This driver uses the common SPI interface.
-
-config AD5446
- tristate "Analog Devices AD5444/6, AD5620/40/60 and AD5542A/12A DAC SPI driver"
- depends on SPI
- help
- Say yes here to build support for Analog Devices AD5444, AD5446,
- AD5512A, AD5542A, AD5543, AD5553, AD5601, AD5611, AD5620, AD5621,
- AD5640, AD5660, AD5662 DACs.
-
- To compile this driver as a module, choose M here: the
- module will be called ad5446.
-
-config AD5504
- tristate "Analog Devices AD5504/AD5501 DAC SPI driver"
- depends on SPI
- help
- Say yes here to build support for Analog Devices AD5504, AD5501,
- High Voltage Digital to Analog Converter.
-
- To compile this driver as a module, choose M here: the
- module will be called ad5504.
-
-config AD5764
- tristate "Analog Devices AD5764/64R/44/44R DAC driver"
- depends on SPI_MASTER
- help
- Say yes here to build support for Analog Devices AD5764, AD5764R, AD5744,
- AD5744R Digital to Analog Converter.
-
- To compile this driver as a module, choose M here: the
- module will be called ad5764.
-
-config AD5791
- tristate "Analog Devices AD5760/AD5780/AD5781/AD5790/AD5791 DAC SPI driver"
- depends on SPI
- help
- Say yes here to build support for Analog Devices AD5760, AD5780,
- AD5781, AD5790, AD5791 High Resolution Voltage Output Digital to
- Analog Converter.
-
- To compile this driver as a module, choose M here: the
- module will be called ad5791.
-
-config AD5686
- tristate "Analog Devices AD5686R/AD5685R/AD5684R DAC SPI driver"
- depends on SPI
- help
- Say yes here to build support for Analog Devices AD5686R, AD5685R,
- AD5684R, AD5791 Voltage Output Digital to
- Analog Converter.
-
- To compile this driver as a module, choose M here: the
- module will be called ad5686.
-
-config MAX517
- tristate "Maxim MAX517/518/519 DAC driver"
- depends on I2C && EXPERIMENTAL
- help
- If you say yes here you get support for the Maxim chips MAX517,
- MAX518 and MAX519 (I2C 8-Bit DACs with rail-to-rail outputs).
-
- This driver can also be built as a module. If so, the module
- will be called max517.
-
-endmenu
diff --git a/drivers/staging/iio/dac/Makefile b/drivers/staging/iio/dac/Makefile
deleted file mode 100644
index 8ab1d264aab7..000000000000
--- a/drivers/staging/iio/dac/Makefile
+++ /dev/null
@@ -1,15 +0,0 @@
-#
-# Makefile for industrial I/O DAC drivers
-#
-
-obj-$(CONFIG_AD5360) += ad5360.o
-obj-$(CONFIG_AD5380) += ad5380.o
-obj-$(CONFIG_AD5421) += ad5421.o
-obj-$(CONFIG_AD5624R_SPI) += ad5624r_spi.o
-obj-$(CONFIG_AD5064) += ad5064.o
-obj-$(CONFIG_AD5504) += ad5504.o
-obj-$(CONFIG_AD5446) += ad5446.o
-obj-$(CONFIG_AD5764) += ad5764.o
-obj-$(CONFIG_AD5791) += ad5791.o
-obj-$(CONFIG_AD5686) += ad5686.o
-obj-$(CONFIG_MAX517) += max517.o
diff --git a/drivers/staging/iio/dac/ad5064.c b/drivers/staging/iio/dac/ad5064.c
deleted file mode 100644
index 06b162745a3e..000000000000
--- a/drivers/staging/iio/dac/ad5064.c
+++ /dev/null
@@ -1,559 +0,0 @@
-/*
- * AD5024, AD5025, AD5044, AD5045, AD5064, AD5064-1, AD5065, AD5628, AD5648,
- * AD5666, AD5668 Digital to analog converters driver
- *
- * Copyright 2011 Analog Devices Inc.
- *
- * Licensed under the GPL-2.
- */
-
-#include <linux/device.h>
-#include <linux/err.h>
-#include <linux/module.h>
-#include <linux/kernel.h>
-#include <linux/spi/spi.h>
-#include <linux/slab.h>
-#include <linux/sysfs.h>
-#include <linux/regulator/consumer.h>
-
-#include "../iio.h"
-#include "../sysfs.h"
-#include "dac.h"
-
-#define AD5064_MAX_DAC_CHANNELS 8
-#define AD5064_MAX_VREFS 4
-
-#define AD5064_ADDR(x) ((x) << 20)
-#define AD5064_CMD(x) ((x) << 24)
-
-#define AD5064_ADDR_DAC(chan) (chan)
-#define AD5064_ADDR_ALL_DAC 0xF
-
-#define AD5064_CMD_WRITE_INPUT_N 0x0
-#define AD5064_CMD_UPDATE_DAC_N 0x1
-#define AD5064_CMD_WRITE_INPUT_N_UPDATE_ALL 0x2
-#define AD5064_CMD_WRITE_INPUT_N_UPDATE_N 0x3
-#define AD5064_CMD_POWERDOWN_DAC 0x4
-#define AD5064_CMD_CLEAR 0x5
-#define AD5064_CMD_LDAC_MASK 0x6
-#define AD5064_CMD_RESET 0x7
-#define AD5064_CMD_CONFIG 0x8
-
-#define AD5064_CONFIG_DAISY_CHAIN_ENABLE BIT(1)
-#define AD5064_CONFIG_INT_VREF_ENABLE BIT(0)
-
-#define AD5064_LDAC_PWRDN_NONE 0x0
-#define AD5064_LDAC_PWRDN_1K 0x1
-#define AD5064_LDAC_PWRDN_100K 0x2
-#define AD5064_LDAC_PWRDN_3STATE 0x3
-
-/**
- * struct ad5064_chip_info - chip specific information
- * @shared_vref: whether the vref supply is shared between channels
- * @internal_vref: internal reference voltage. 0 if the chip has no internal
- * vref.
- * @channel: channel specification
- * @num_channels: number of channels
- */
-
-struct ad5064_chip_info {
- bool shared_vref;
- unsigned long internal_vref;
- const struct iio_chan_spec *channels;
- unsigned int num_channels;
-};
-
-/**
- * struct ad5064_state - driver instance specific data
- * @spi: spi_device
- * @chip_info: chip model specific constants, available modes etc
- * @vref_reg: vref supply regulators
- * @pwr_down: whether channel is powered down
- * @pwr_down_mode: channel's current power down mode
- * @dac_cache: current DAC raw value (chip does not support readback)
- * @use_internal_vref: set to true if the internal reference voltage should be
- * used.
- * @data: spi transfer buffers
- */
-
-struct ad5064_state {
- struct spi_device *spi;
- const struct ad5064_chip_info *chip_info;
- struct regulator_bulk_data vref_reg[AD5064_MAX_VREFS];
- bool pwr_down[AD5064_MAX_DAC_CHANNELS];
- u8 pwr_down_mode[AD5064_MAX_DAC_CHANNELS];
- unsigned int dac_cache[AD5064_MAX_DAC_CHANNELS];
- bool use_internal_vref;
-
- /*
- * DMA (thus cache coherency maintenance) requires the
- * transfer buffers to live in their own cache lines.
- */
- __be32 data ____cacheline_aligned;
-};
-
-enum ad5064_type {
- ID_AD5024,
- ID_AD5025,
- ID_AD5044,
- ID_AD5045,
- ID_AD5064,
- ID_AD5064_1,
- ID_AD5065,
- ID_AD5628_1,
- ID_AD5628_2,
- ID_AD5648_1,
- ID_AD5648_2,
- ID_AD5666_1,
- ID_AD5666_2,
- ID_AD5668_1,
- ID_AD5668_2,
-};
-
-static int ad5064_spi_write(struct ad5064_state *st, unsigned int cmd,
- unsigned int addr, unsigned int val, unsigned int shift)
-{
- val <<= shift;
-
- st->data = cpu_to_be32(AD5064_CMD(cmd) | AD5064_ADDR(addr) | val);
-
- return spi_write(st->spi, &st->data, sizeof(st->data));
-}
-
-static int ad5064_sync_powerdown_mode(struct ad5064_state *st,
- unsigned int channel)
-{
- unsigned int val;
- int ret;
-
- val = (0x1 << channel);
-
- if (st->pwr_down[channel])
- val |= st->pwr_down_mode[channel] << 8;
-
- ret = ad5064_spi_write(st, AD5064_CMD_POWERDOWN_DAC, 0, val, 0);
-
- return ret;
-}
-
-static const char ad5064_powerdown_modes[][15] = {
- [AD5064_LDAC_PWRDN_NONE] = "",
- [AD5064_LDAC_PWRDN_1K] = "1kohm_to_gnd",
- [AD5064_LDAC_PWRDN_100K] = "100kohm_to_gnd",
- [AD5064_LDAC_PWRDN_3STATE] = "three_state",
-};
-
-static ssize_t ad5064_read_powerdown_mode_available(struct iio_dev *indio_dev,
- const struct iio_chan_spec *chan, char *buf)
-{
- return sprintf(buf, "%s %s %s\n", ad5064_powerdown_modes[1],
- ad5064_powerdown_modes[2], ad5064_powerdown_modes[3]);
-}
-
-static ssize_t ad5064_read_powerdown_mode(struct iio_dev *indio_dev,
- const struct iio_chan_spec *chan, char *buf)
-{
- struct ad5064_state *st = iio_priv(indio_dev);
-
- return sprintf(buf, "%s\n",
- ad5064_powerdown_modes[st->pwr_down_mode[chan->channel]]);
-}
-
-static ssize_t ad5064_write_powerdown_mode(struct iio_dev *indio_dev,
- const struct iio_chan_spec *chan, const char *buf, size_t len)
-{
- struct ad5064_state *st = iio_priv(indio_dev);
- unsigned int mode, i;
- int ret;
-
- mode = 0;
-
- for (i = 1; i < ARRAY_SIZE(ad5064_powerdown_modes); ++i) {
- if (sysfs_streq(buf, ad5064_powerdown_modes[i])) {
- mode = i;
- break;
- }
- }
- if (mode == 0)
- return -EINVAL;
-
- mutex_lock(&indio_dev->mlock);
- st->pwr_down_mode[chan->channel] = mode;
-
- ret = ad5064_sync_powerdown_mode(st, chan->channel);
- mutex_unlock(&indio_dev->mlock);
-
- return ret ? ret : len;
-}
-
-static ssize_t ad5064_read_dac_powerdown(struct iio_dev *indio_dev,
- const struct iio_chan_spec *chan, char *buf)
-{
- struct ad5064_state *st = iio_priv(indio_dev);
-
- return sprintf(buf, "%d\n", st->pwr_down[chan->channel]);
-}
-
-static ssize_t ad5064_write_dac_powerdown(struct iio_dev *indio_dev,
- const struct iio_chan_spec *chan, const char *buf, size_t len)
-{
- struct ad5064_state *st = iio_priv(indio_dev);
- bool pwr_down;
- int ret;
-
- ret = strtobool(buf, &pwr_down);
- if (ret)
- return ret;
-
- mutex_lock(&indio_dev->mlock);
- st->pwr_down[chan->channel] = pwr_down;
-
- ret = ad5064_sync_powerdown_mode(st, chan->channel);
- mutex_unlock(&indio_dev->mlock);
- return ret ? ret : len;
-}
-
-static int ad5064_get_vref(struct ad5064_state *st,
- struct iio_chan_spec const *chan)
-{
- unsigned int i;
-
- if (st->use_internal_vref)
- return st->chip_info->internal_vref;
-
- i = st->chip_info->shared_vref ? 0 : chan->channel;
- return regulator_get_voltage(st->vref_reg[i].consumer);
-}
-
-static int ad5064_read_raw(struct iio_dev *indio_dev,
- struct iio_chan_spec const *chan,
- int *val,
- int *val2,
- long m)
-{
- struct ad5064_state *st = iio_priv(indio_dev);
- int scale_uv;
-
- switch (m) {
- case 0:
- *val = st->dac_cache[chan->channel];
- return IIO_VAL_INT;
- case IIO_CHAN_INFO_SCALE:
- scale_uv = ad5064_get_vref(st, chan);
- if (scale_uv < 0)
- return scale_uv;
-
- scale_uv = (scale_uv * 100) >> chan->scan_type.realbits;
- *val = scale_uv / 100000;
- *val2 = (scale_uv % 100000) * 10;
- return IIO_VAL_INT_PLUS_MICRO;
- default:
- break;
- }
- return -EINVAL;
-}
-
-static int ad5064_write_raw(struct iio_dev *indio_dev,
- struct iio_chan_spec const *chan, int val, int val2, long mask)
-{
- struct ad5064_state *st = iio_priv(indio_dev);
- int ret;
-
- switch (mask) {
- case 0:
- if (val > (1 << chan->scan_type.realbits) || val < 0)
- return -EINVAL;
-
- mutex_lock(&indio_dev->mlock);
- ret = ad5064_spi_write(st, AD5064_CMD_WRITE_INPUT_N_UPDATE_N,
- chan->address, val, chan->scan_type.shift);
- if (ret == 0)
- st->dac_cache[chan->channel] = val;
- mutex_unlock(&indio_dev->mlock);
- break;
- default:
- ret = -EINVAL;
- }
-
- return ret;
-}
-
-static const struct iio_info ad5064_info = {
- .read_raw = ad5064_read_raw,
- .write_raw = ad5064_write_raw,
- .driver_module = THIS_MODULE,
-};
-
-static struct iio_chan_spec_ext_info ad5064_ext_info[] = {
- {
- .name = "powerdown",
- .read = ad5064_read_dac_powerdown,
- .write = ad5064_write_dac_powerdown,
- },
- {
- .name = "powerdown_mode",
- .read = ad5064_read_powerdown_mode,
- .write = ad5064_write_powerdown_mode,
- },
- {
- .name = "powerdown_mode_available",
- .shared = true,
- .read = ad5064_read_powerdown_mode_available,
- },
- { },
-};
-
-#define AD5064_CHANNEL(chan, bits) { \
- .type = IIO_VOLTAGE, \
- .indexed = 1, \
- .output = 1, \
- .channel = (chan), \
- .info_mask = IIO_CHAN_INFO_SCALE_SEPARATE_BIT, \
- .address = AD5064_ADDR_DAC(chan), \
- .scan_type = IIO_ST('u', (bits), 16, 20 - (bits)), \
- .ext_info = ad5064_ext_info, \
-}
-
-#define DECLARE_AD5064_CHANNELS(name, bits) \
-const struct iio_chan_spec name[] = { \
- AD5064_CHANNEL(0, bits), \
- AD5064_CHANNEL(1, bits), \
- AD5064_CHANNEL(2, bits), \
- AD5064_CHANNEL(3, bits), \
- AD5064_CHANNEL(4, bits), \
- AD5064_CHANNEL(5, bits), \
- AD5064_CHANNEL(6, bits), \
- AD5064_CHANNEL(7, bits), \
-}
-
-static DECLARE_AD5064_CHANNELS(ad5024_channels, 12);
-static DECLARE_AD5064_CHANNELS(ad5044_channels, 14);
-static DECLARE_AD5064_CHANNELS(ad5064_channels, 16);
-
-static const struct ad5064_chip_info ad5064_chip_info_tbl[] = {
- [ID_AD5024] = {
- .shared_vref = false,
- .channels = ad5024_channels,
- .num_channels = 4,
- },
- [ID_AD5025] = {
- .shared_vref = false,
- .channels = ad5024_channels,
- .num_channels = 2,
- },
- [ID_AD5044] = {
- .shared_vref = false,
- .channels = ad5044_channels,
- .num_channels = 4,
- },
- [ID_AD5045] = {
- .shared_vref = false,
- .channels = ad5044_channels,
- .num_channels = 2,
- },
- [ID_AD5064] = {
- .shared_vref = false,
- .channels = ad5064_channels,
- .num_channels = 4,
- },
- [ID_AD5064_1] = {
- .shared_vref = true,
- .channels = ad5064_channels,
- .num_channels = 4,
- },
- [ID_AD5065] = {
- .shared_vref = false,
- .channels = ad5064_channels,
- .num_channels = 2,
- },
- [ID_AD5628_1] = {
- .shared_vref = true,
- .internal_vref = 2500000,
- .channels = ad5024_channels,
- .num_channels = 8,
- },
- [ID_AD5628_2] = {
- .shared_vref = true,
- .internal_vref = 5000000,
- .channels = ad5024_channels,
- .num_channels = 8,
- },
- [ID_AD5648_1] = {
- .shared_vref = true,
- .internal_vref = 2500000,
- .channels = ad5044_channels,
- .num_channels = 8,
- },
- [ID_AD5648_2] = {
- .shared_vref = true,
- .internal_vref = 5000000,
- .channels = ad5044_channels,
- .num_channels = 8,
- },
- [ID_AD5666_1] = {
- .shared_vref = true,
- .internal_vref = 2500000,
- .channels = ad5064_channels,
- .num_channels = 4,
- },
- [ID_AD5666_2] = {
- .shared_vref = true,
- .internal_vref = 5000000,
- .channels = ad5064_channels,
- .num_channels = 4,
- },
- [ID_AD5668_1] = {
- .shared_vref = true,
- .internal_vref = 2500000,
- .channels = ad5064_channels,
- .num_channels = 8,
- },
- [ID_AD5668_2] = {
- .shared_vref = true,
- .internal_vref = 5000000,
- .channels = ad5064_channels,
- .num_channels = 8,
- },
-};
-
-static inline unsigned int ad5064_num_vref(struct ad5064_state *st)
-{
- return st->chip_info->shared_vref ? 1 : st->chip_info->num_channels;
-}
-
-static const char * const ad5064_vref_names[] = {
- "vrefA",
- "vrefB",
- "vrefC",
- "vrefD",
-};
-
-static const char * const ad5064_vref_name(struct ad5064_state *st,
- unsigned int vref)
-{
- return st->chip_info->shared_vref ? "vref" : ad5064_vref_names[vref];
-}
-
-static int __devinit ad5064_probe(struct spi_device *spi)
-{
- enum ad5064_type type = spi_get_device_id(spi)->driver_data;
- struct iio_dev *indio_dev;
- struct ad5064_state *st;
- unsigned int i;
- int ret;
-
- indio_dev = iio_allocate_device(sizeof(*st));
- if (indio_dev == NULL)
- return -ENOMEM;
-
- st = iio_priv(indio_dev);
- spi_set_drvdata(spi, indio_dev);
-
- st->chip_info = &ad5064_chip_info_tbl[type];
- st->spi = spi;
-
- for (i = 0; i < ad5064_num_vref(st); ++i)
- st->vref_reg[i].supply = ad5064_vref_name(st, i);
-
- ret = regulator_bulk_get(&st->spi->dev, ad5064_num_vref(st),
- st->vref_reg);
- if (ret) {
- if (!st->chip_info->internal_vref)
- goto error_free;
- st->use_internal_vref = true;
- ret = ad5064_spi_write(st, AD5064_CMD_CONFIG, 0,
- AD5064_CONFIG_INT_VREF_ENABLE, 0);
- if (ret) {
- dev_err(&spi->dev, "Failed to enable internal vref: %d\n",
- ret);
- goto error_free;
- }
- } else {
- ret = regulator_bulk_enable(ad5064_num_vref(st), st->vref_reg);
- if (ret)
- goto error_free_reg;
- }
-
- for (i = 0; i < st->chip_info->num_channels; ++i) {
- st->pwr_down_mode[i] = AD5064_LDAC_PWRDN_1K;
- st->dac_cache[i] = 0x8000;
- }
-
- indio_dev->dev.parent = &spi->dev;
- indio_dev->name = spi_get_device_id(spi)->name;
- indio_dev->info = &ad5064_info;
- indio_dev->modes = INDIO_DIRECT_MODE;
- indio_dev->channels = st->chip_info->channels;
- indio_dev->num_channels = st->chip_info->num_channels;
-
- ret = iio_device_register(indio_dev);
- if (ret)
- goto error_disable_reg;
-
- return 0;
-
-error_disable_reg:
- if (!st->use_internal_vref)
- regulator_bulk_disable(ad5064_num_vref(st), st->vref_reg);
-error_free_reg:
- if (!st->use_internal_vref)
- regulator_bulk_free(ad5064_num_vref(st), st->vref_reg);
-error_free:
- iio_free_device(indio_dev);
-
- return ret;
-}
-
-
-static int __devexit ad5064_remove(struct spi_device *spi)
-{
- struct iio_dev *indio_dev = spi_get_drvdata(spi);
- struct ad5064_state *st = iio_priv(indio_dev);
-
- iio_device_unregister(indio_dev);
-
- if (!st->use_internal_vref) {
- regulator_bulk_disable(ad5064_num_vref(st), st->vref_reg);
- regulator_bulk_free(ad5064_num_vref(st), st->vref_reg);
- }
-
- iio_free_device(indio_dev);
-
- return 0;
-}
-
-static const struct spi_device_id ad5064_id[] = {
- {"ad5024", ID_AD5024},
- {"ad5025", ID_AD5025},
- {"ad5044", ID_AD5044},
- {"ad5045", ID_AD5045},
- {"ad5064", ID_AD5064},
- {"ad5064-1", ID_AD5064_1},
- {"ad5065", ID_AD5065},
- {"ad5628-1", ID_AD5628_1},
- {"ad5628-2", ID_AD5628_2},
- {"ad5648-1", ID_AD5648_1},
- {"ad5648-2", ID_AD5648_2},
- {"ad5666-1", ID_AD5666_1},
- {"ad5666-2", ID_AD5666_2},
- {"ad5668-1", ID_AD5668_1},
- {"ad5668-2", ID_AD5668_2},
- {"ad5668-3", ID_AD5668_2}, /* similar enough to ad5668-2 */
- {}
-};
-MODULE_DEVICE_TABLE(spi, ad5064_id);
-
-static struct spi_driver ad5064_driver = {
- .driver = {
- .name = "ad5064",
- .owner = THIS_MODULE,
- },
- .probe = ad5064_probe,
- .remove = __devexit_p(ad5064_remove),
- .id_table = ad5064_id,
-};
-module_spi_driver(ad5064_driver);
-
-MODULE_AUTHOR("Lars-Peter Clausen <lars@metafoo.de>");
-MODULE_DESCRIPTION("Analog Devices AD5024/25/44/45/64/64-1/65, AD5628/48/66/68 DAC");
-MODULE_LICENSE("GPL v2");
diff --git a/drivers/staging/iio/dac/ad5360.c b/drivers/staging/iio/dac/ad5360.c
deleted file mode 100644
index cec3693b50a3..000000000000
--- a/drivers/staging/iio/dac/ad5360.c
+++ /dev/null
@@ -1,570 +0,0 @@
-/*
- * Analog devices AD5360, AD5361, AD5362, AD5363, AD5370, AD5371, AD5373
- * multi-channel Digital to Analog Converters driver
- *
- * Copyright 2011 Analog Devices Inc.
- *
- * Licensed under the GPL-2.
- */
-
-#include <linux/device.h>
-#include <linux/err.h>
-#include <linux/module.h>
-#include <linux/kernel.h>
-#include <linux/spi/spi.h>
-#include <linux/slab.h>
-#include <linux/sysfs.h>
-#include <linux/regulator/consumer.h>
-
-#include "../iio.h"
-#include "../sysfs.h"
-#include "dac.h"
-
-#define AD5360_CMD(x) ((x) << 22)
-#define AD5360_ADDR(x) ((x) << 16)
-
-#define AD5360_READBACK_TYPE(x) ((x) << 13)
-#define AD5360_READBACK_ADDR(x) ((x) << 7)
-
-#define AD5360_CHAN_ADDR(chan) ((chan) + 0x8)
-
-#define AD5360_CMD_WRITE_DATA 0x3
-#define AD5360_CMD_WRITE_OFFSET 0x2
-#define AD5360_CMD_WRITE_GAIN 0x1
-#define AD5360_CMD_SPECIAL_FUNCTION 0x0
-
-/* Special function register addresses */
-#define AD5360_REG_SF_NOP 0x0
-#define AD5360_REG_SF_CTRL 0x1
-#define AD5360_REG_SF_OFS(x) (0x2 + (x))
-#define AD5360_REG_SF_READBACK 0x5
-
-#define AD5360_SF_CTRL_PWR_DOWN BIT(0)
-
-#define AD5360_READBACK_X1A 0x0
-#define AD5360_READBACK_X1B 0x1
-#define AD5360_READBACK_OFFSET 0x2
-#define AD5360_READBACK_GAIN 0x3
-#define AD5360_READBACK_SF 0x4
-
-
-/**
- * struct ad5360_chip_info - chip specific information
- * @channel_template: channel specification template
- * @num_channels: number of channels
- * @channels_per_group: number of channels per group
- * @num_vrefs: number of vref supplies for the chip
-*/
-
-struct ad5360_chip_info {
- struct iio_chan_spec channel_template;
- unsigned int num_channels;
- unsigned int channels_per_group;
- unsigned int num_vrefs;
-};
-
-/**
- * struct ad5360_state - driver instance specific data
- * @spi: spi_device
- * @chip_info: chip model specific constants, available modes etc
- * @vref_reg: vref supply regulators
- * @ctrl: control register cache
- * @data: spi transfer buffers
- */
-
-struct ad5360_state {
- struct spi_device *spi;
- const struct ad5360_chip_info *chip_info;
- struct regulator_bulk_data vref_reg[3];
- unsigned int ctrl;
-
- /*
- * DMA (thus cache coherency maintenance) requires the
- * transfer buffers to live in their own cache lines.
- */
- union {
- __be32 d32;
- u8 d8[4];
- } data[2] ____cacheline_aligned;
-};
-
-enum ad5360_type {
- ID_AD5360,
- ID_AD5361,
- ID_AD5362,
- ID_AD5363,
- ID_AD5370,
- ID_AD5371,
- ID_AD5372,
- ID_AD5373,
-};
-
-#define AD5360_CHANNEL(bits) { \
- .type = IIO_VOLTAGE, \
- .indexed = 1, \
- .output = 1, \
- .info_mask = IIO_CHAN_INFO_SCALE_SEPARATE_BIT | \
- IIO_CHAN_INFO_OFFSET_SEPARATE_BIT | \
- IIO_CHAN_INFO_CALIBSCALE_SEPARATE_BIT | \
- IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT, \
- .scan_type = IIO_ST('u', (bits), 16, 16 - (bits)) \
-}
-
-static const struct ad5360_chip_info ad5360_chip_info_tbl[] = {
- [ID_AD5360] = {
- .channel_template = AD5360_CHANNEL(16),
- .num_channels = 16,
- .channels_per_group = 8,
- .num_vrefs = 2,
- },
- [ID_AD5361] = {
- .channel_template = AD5360_CHANNEL(14),
- .num_channels = 16,
- .channels_per_group = 8,
- .num_vrefs = 2,
- },
- [ID_AD5362] = {
- .channel_template = AD5360_CHANNEL(16),
- .num_channels = 8,
- .channels_per_group = 4,
- .num_vrefs = 2,
- },
- [ID_AD5363] = {
- .channel_template = AD5360_CHANNEL(14),
- .num_channels = 8,
- .channels_per_group = 4,
- .num_vrefs = 2,
- },
- [ID_AD5370] = {
- .channel_template = AD5360_CHANNEL(16),
- .num_channels = 40,
- .channels_per_group = 8,
- .num_vrefs = 2,
- },
- [ID_AD5371] = {
- .channel_template = AD5360_CHANNEL(14),
- .num_channels = 40,
- .channels_per_group = 8,
- .num_vrefs = 3,
- },
- [ID_AD5372] = {
- .channel_template = AD5360_CHANNEL(16),
- .num_channels = 32,
- .channels_per_group = 8,
- .num_vrefs = 2,
- },
- [ID_AD5373] = {
- .channel_template = AD5360_CHANNEL(14),
- .num_channels = 32,
- .channels_per_group = 8,
- .num_vrefs = 2,
- },
-};
-
-static unsigned int ad5360_get_channel_vref_index(struct ad5360_state *st,
- unsigned int channel)
-{
- unsigned int i;
-
- /* The first groups have their own vref, while the remaining groups
- * share the last vref */
- i = channel / st->chip_info->channels_per_group;
- if (i >= st->chip_info->num_vrefs)
- i = st->chip_info->num_vrefs - 1;
-
- return i;
-}
-
-static int ad5360_get_channel_vref(struct ad5360_state *st,
- unsigned int channel)
-{
- unsigned int i = ad5360_get_channel_vref_index(st, channel);
-
- return regulator_get_voltage(st->vref_reg[i].consumer);
-}
-
-
-static int ad5360_write_unlocked(struct iio_dev *indio_dev,
- unsigned int cmd, unsigned int addr, unsigned int val,
- unsigned int shift)
-{
- struct ad5360_state *st = iio_priv(indio_dev);
-
- val <<= shift;
- val |= AD5360_CMD(cmd) | AD5360_ADDR(addr);
- st->data[0].d32 = cpu_to_be32(val);
-
- return spi_write(st->spi, &st->data[0].d8[1], 3);
-}
-
-static int ad5360_write(struct iio_dev *indio_dev, unsigned int cmd,
- unsigned int addr, unsigned int val, unsigned int shift)
-{
- int ret;
-
- mutex_lock(&indio_dev->mlock);
- ret = ad5360_write_unlocked(indio_dev, cmd, addr, val, shift);
- mutex_unlock(&indio_dev->mlock);
-
- return ret;
-}
-
-static int ad5360_read(struct iio_dev *indio_dev, unsigned int type,
- unsigned int addr)
-{
- struct ad5360_state *st = iio_priv(indio_dev);
- struct spi_message m;
- int ret;
- struct spi_transfer t[] = {
- {
- .tx_buf = &st->data[0].d8[1],
- .len = 3,
- .cs_change = 1,
- }, {
- .rx_buf = &st->data[1].d8[1],
- .len = 3,
- },
- };
-
- spi_message_init(&m);
- spi_message_add_tail(&t[0], &m);
- spi_message_add_tail(&t[1], &m);
-
- mutex_lock(&indio_dev->mlock);
-
- st->data[0].d32 = cpu_to_be32(AD5360_CMD(AD5360_CMD_SPECIAL_FUNCTION) |
- AD5360_ADDR(AD5360_REG_SF_READBACK) |
- AD5360_READBACK_TYPE(type) |
- AD5360_READBACK_ADDR(addr));
-
- ret = spi_sync(st->spi, &m);
- if (ret >= 0)
- ret = be32_to_cpu(st->data[1].d32) & 0xffff;
-
- mutex_unlock(&indio_dev->mlock);
-
- return ret;
-}
-
-static ssize_t ad5360_read_dac_powerdown(struct device *dev,
- struct device_attribute *attr,
- char *buf)
-{
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
- struct ad5360_state *st = iio_priv(indio_dev);
-
- return sprintf(buf, "%d\n", (bool)(st->ctrl & AD5360_SF_CTRL_PWR_DOWN));
-}
-
-static int ad5360_update_ctrl(struct iio_dev *indio_dev, unsigned int set,
- unsigned int clr)
-{
- struct ad5360_state *st = iio_priv(indio_dev);
- unsigned int ret;
-
- mutex_lock(&indio_dev->mlock);
-
- st->ctrl |= set;
- st->ctrl &= ~clr;
-
- ret = ad5360_write_unlocked(indio_dev, AD5360_CMD_SPECIAL_FUNCTION,
- AD5360_REG_SF_CTRL, st->ctrl, 0);
-
- mutex_unlock(&indio_dev->mlock);
-
- return ret;
-}
-
-static ssize_t ad5360_write_dac_powerdown(struct device *dev,
- struct device_attribute *attr, const char *buf, size_t len)
-{
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
- bool pwr_down;
- int ret;
-
- ret = strtobool(buf, &pwr_down);
- if (ret)
- return ret;
-
- if (pwr_down)
- ret = ad5360_update_ctrl(indio_dev, AD5360_SF_CTRL_PWR_DOWN, 0);
- else
- ret = ad5360_update_ctrl(indio_dev, 0, AD5360_SF_CTRL_PWR_DOWN);
-
- return ret ? ret : len;
-}
-
-static IIO_DEVICE_ATTR(out_voltage_powerdown,
- S_IRUGO | S_IWUSR,
- ad5360_read_dac_powerdown,
- ad5360_write_dac_powerdown, 0);
-
-static struct attribute *ad5360_attributes[] = {
- &iio_dev_attr_out_voltage_powerdown.dev_attr.attr,
- NULL,
-};
-
-static const struct attribute_group ad5360_attribute_group = {
- .attrs = ad5360_attributes,
-};
-
-static int ad5360_write_raw(struct iio_dev *indio_dev,
- struct iio_chan_spec const *chan,
- int val,
- int val2,
- long mask)
-{
- struct ad5360_state *st = iio_priv(indio_dev);
- int max_val = (1 << chan->scan_type.realbits);
- unsigned int ofs_index;
-
- switch (mask) {
- case 0:
- if (val >= max_val || val < 0)
- return -EINVAL;
-
- return ad5360_write(indio_dev, AD5360_CMD_WRITE_DATA,
- chan->address, val, chan->scan_type.shift);
-
- case IIO_CHAN_INFO_CALIBBIAS:
- if (val >= max_val || val < 0)
- return -EINVAL;
-
- return ad5360_write(indio_dev, AD5360_CMD_WRITE_OFFSET,
- chan->address, val, chan->scan_type.shift);
-
- case IIO_CHAN_INFO_CALIBSCALE:
- if (val >= max_val || val < 0)
- return -EINVAL;
-
- return ad5360_write(indio_dev, AD5360_CMD_WRITE_GAIN,
- chan->address, val, chan->scan_type.shift);
-
- case IIO_CHAN_INFO_OFFSET:
- if (val <= -max_val || val > 0)
- return -EINVAL;
-
- val = -val;
-
- /* offset is supposed to have the same scale as raw, but it
- * is always 14bits wide, so on a chip where the raw value has
- * more bits, we need to shift offset. */
- val >>= (chan->scan_type.realbits - 14);
-
- /* There is one DAC offset register per vref. Changing one
- * channels offset will also change the offset for all other
- * channels which share the same vref supply. */
- ofs_index = ad5360_get_channel_vref_index(st, chan->channel);
- return ad5360_write(indio_dev, AD5360_CMD_SPECIAL_FUNCTION,
- AD5360_REG_SF_OFS(ofs_index), val, 0);
- default:
- break;
- }
-
- return -EINVAL;
-}
-
-static int ad5360_read_raw(struct iio_dev *indio_dev,
- struct iio_chan_spec const *chan,
- int *val,
- int *val2,
- long m)
-{
- struct ad5360_state *st = iio_priv(indio_dev);
- unsigned int ofs_index;
- int scale_uv;
- int ret;
-
- switch (m) {
- case 0:
- ret = ad5360_read(indio_dev, AD5360_READBACK_X1A,
- chan->address);
- if (ret < 0)
- return ret;
- *val = ret >> chan->scan_type.shift;
- return IIO_VAL_INT;
- case IIO_CHAN_INFO_SCALE:
- /* vout = 4 * vref * dac_code */
- scale_uv = ad5360_get_channel_vref(st, chan->channel) * 4 * 100;
- if (scale_uv < 0)
- return scale_uv;
-
- scale_uv >>= (chan->scan_type.realbits);
- *val = scale_uv / 100000;
- *val2 = (scale_uv % 100000) * 10;
- return IIO_VAL_INT_PLUS_MICRO;
- case IIO_CHAN_INFO_CALIBBIAS:
- ret = ad5360_read(indio_dev, AD5360_READBACK_OFFSET,
- chan->address);
- if (ret < 0)
- return ret;
- *val = ret;
- return IIO_VAL_INT;
- case IIO_CHAN_INFO_CALIBSCALE:
- ret = ad5360_read(indio_dev, AD5360_READBACK_GAIN,
- chan->address);
- if (ret < 0)
- return ret;
- *val = ret;
- return IIO_VAL_INT;
- case IIO_CHAN_INFO_OFFSET:
- ofs_index = ad5360_get_channel_vref_index(st, chan->channel);
- ret = ad5360_read(indio_dev, AD5360_READBACK_SF,
- AD5360_REG_SF_OFS(ofs_index));
- if (ret < 0)
- return ret;
-
- ret <<= (chan->scan_type.realbits - 14);
- *val = -ret;
- return IIO_VAL_INT;
- }
-
- return -EINVAL;
-}
-
-static const struct iio_info ad5360_info = {
- .read_raw = ad5360_read_raw,
- .write_raw = ad5360_write_raw,
- .attrs = &ad5360_attribute_group,
- .driver_module = THIS_MODULE,
-};
-
-static const char * const ad5360_vref_name[] = {
- "vref0", "vref1", "vref2"
-};
-
-static int __devinit ad5360_alloc_channels(struct iio_dev *indio_dev)
-{
- struct ad5360_state *st = iio_priv(indio_dev);
- struct iio_chan_spec *channels;
- unsigned int i;
-
- channels = kcalloc(st->chip_info->num_channels,
- sizeof(struct iio_chan_spec), GFP_KERNEL);
-
- if (!channels)
- return -ENOMEM;
-
- for (i = 0; i < st->chip_info->num_channels; ++i) {
- channels[i] = st->chip_info->channel_template;
- channels[i].channel = i;
- channels[i].address = AD5360_CHAN_ADDR(i);
- }
-
- indio_dev->channels = channels;
-
- return 0;
-}
-
-static int __devinit ad5360_probe(struct spi_device *spi)
-{
- enum ad5360_type type = spi_get_device_id(spi)->driver_data;
- struct iio_dev *indio_dev;
- struct ad5360_state *st;
- unsigned int i;
- int ret;
-
- indio_dev = iio_allocate_device(sizeof(*st));
- if (indio_dev == NULL) {
- dev_err(&spi->dev, "Failed to allocate iio device\n");
- return -ENOMEM;
- }
-
- st = iio_priv(indio_dev);
- spi_set_drvdata(spi, indio_dev);
-
- st->chip_info = &ad5360_chip_info_tbl[type];
- st->spi = spi;
-
- indio_dev->dev.parent = &spi->dev;
- indio_dev->name = spi_get_device_id(spi)->name;
- indio_dev->info = &ad5360_info;
- indio_dev->modes = INDIO_DIRECT_MODE;
- indio_dev->num_channels = st->chip_info->num_channels;
-
- ret = ad5360_alloc_channels(indio_dev);
- if (ret) {
- dev_err(&spi->dev, "Failed to allocate channel spec: %d\n", ret);
- goto error_free;
- }
-
- for (i = 0; i < st->chip_info->num_vrefs; ++i)
- st->vref_reg[i].supply = ad5360_vref_name[i];
-
- ret = regulator_bulk_get(&st->spi->dev, st->chip_info->num_vrefs,
- st->vref_reg);
- if (ret) {
- dev_err(&spi->dev, "Failed to request vref regulators: %d\n", ret);
- goto error_free_channels;
- }
-
- ret = regulator_bulk_enable(st->chip_info->num_vrefs, st->vref_reg);
- if (ret) {
- dev_err(&spi->dev, "Failed to enable vref regulators: %d\n", ret);
- goto error_free_reg;
- }
-
- ret = iio_device_register(indio_dev);
- if (ret) {
- dev_err(&spi->dev, "Failed to register iio device: %d\n", ret);
- goto error_disable_reg;
- }
-
- return 0;
-
-error_disable_reg:
- regulator_bulk_disable(st->chip_info->num_vrefs, st->vref_reg);
-error_free_reg:
- regulator_bulk_free(st->chip_info->num_vrefs, st->vref_reg);
-error_free_channels:
- kfree(indio_dev->channels);
-error_free:
- iio_free_device(indio_dev);
-
- return ret;
-}
-
-static int __devexit ad5360_remove(struct spi_device *spi)
-{
- struct iio_dev *indio_dev = spi_get_drvdata(spi);
- struct ad5360_state *st = iio_priv(indio_dev);
-
- iio_device_unregister(indio_dev);
-
- kfree(indio_dev->channels);
-
- regulator_bulk_disable(st->chip_info->num_vrefs, st->vref_reg);
- regulator_bulk_free(st->chip_info->num_vrefs, st->vref_reg);
-
- iio_free_device(indio_dev);
-
- return 0;
-}
-
-static const struct spi_device_id ad5360_ids[] = {
- { "ad5360", ID_AD5360 },
- { "ad5361", ID_AD5361 },
- { "ad5362", ID_AD5362 },
- { "ad5363", ID_AD5363 },
- { "ad5370", ID_AD5370 },
- { "ad5371", ID_AD5371 },
- { "ad5372", ID_AD5372 },
- { "ad5373", ID_AD5373 },
- {}
-};
-MODULE_DEVICE_TABLE(spi, ad5360_ids);
-
-static struct spi_driver ad5360_driver = {
- .driver = {
- .name = "ad5360",
- .owner = THIS_MODULE,
- },
- .probe = ad5360_probe,
- .remove = __devexit_p(ad5360_remove),
- .id_table = ad5360_ids,
-};
-module_spi_driver(ad5360_driver);
-
-MODULE_AUTHOR("Lars-Peter Clausen <lars@metafoo.de>");
-MODULE_DESCRIPTION("Analog Devices AD5360/61/62/63/70/71/72/73 DAC");
-MODULE_LICENSE("GPL v2");
diff --git a/drivers/staging/iio/dac/ad5380.c b/drivers/staging/iio/dac/ad5380.c
deleted file mode 100644
index 4c50716fa801..000000000000
--- a/drivers/staging/iio/dac/ad5380.c
+++ /dev/null
@@ -1,676 +0,0 @@
-/*
- * Analog devices AD5380, AD5381, AD5382, AD5383, AD5390, AD5391, AD5392
- * multi-channel Digital to Analog Converters driver
- *
- * Copyright 2011 Analog Devices Inc.
- *
- * Licensed under the GPL-2.
- */
-
-#include <linux/device.h>
-#include <linux/err.h>
-#include <linux/i2c.h>
-#include <linux/kernel.h>
-#include <linux/module.h>
-#include <linux/spi/spi.h>
-#include <linux/slab.h>
-#include <linux/sysfs.h>
-#include <linux/regmap.h>
-#include <linux/regulator/consumer.h>
-
-#include "../iio.h"
-#include "../sysfs.h"
-#include "dac.h"
-
-
-#define AD5380_REG_DATA(x) (((x) << 2) | 3)
-#define AD5380_REG_OFFSET(x) (((x) << 2) | 2)
-#define AD5380_REG_GAIN(x) (((x) << 2) | 1)
-#define AD5380_REG_SF_PWR_DOWN (8 << 2)
-#define AD5380_REG_SF_PWR_UP (9 << 2)
-#define AD5380_REG_SF_CTRL (12 << 2)
-
-#define AD5380_CTRL_PWR_DOWN_MODE_OFFSET 13
-#define AD5380_CTRL_INT_VREF_2V5 BIT(12)
-#define AD5380_CTRL_INT_VREF_EN BIT(10)
-
-/**
- * struct ad5380_chip_info - chip specific information
- * @channel_template: channel specification template
- * @num_channels: number of channels
- * @int_vref: internal vref in uV
-*/
-
-struct ad5380_chip_info {
- struct iio_chan_spec channel_template;
- unsigned int num_channels;
- unsigned int int_vref;
-};
-
-/**
- * struct ad5380_state - driver instance specific data
- * @regmap: regmap instance used by the device
- * @chip_info: chip model specific constants, available modes etc
- * @vref_reg: vref supply regulator
- * @vref: actual reference voltage used in uA
- * @pwr_down: whether the chip is currently in power down mode
- */
-
-struct ad5380_state {
- struct regmap *regmap;
- const struct ad5380_chip_info *chip_info;
- struct regulator *vref_reg;
- int vref;
- bool pwr_down;
-};
-
-enum ad5380_type {
- ID_AD5380_3,
- ID_AD5380_5,
- ID_AD5381_3,
- ID_AD5381_5,
- ID_AD5382_3,
- ID_AD5382_5,
- ID_AD5383_3,
- ID_AD5383_5,
- ID_AD5390_3,
- ID_AD5390_5,
- ID_AD5391_3,
- ID_AD5391_5,
- ID_AD5392_3,
- ID_AD5392_5,
-};
-
-#define AD5380_CHANNEL(_bits) { \
- .type = IIO_VOLTAGE, \
- .indexed = 1, \
- .output = 1, \
- .info_mask = IIO_CHAN_INFO_SCALE_SHARED_BIT | \
- IIO_CHAN_INFO_CALIBSCALE_SEPARATE_BIT | \
- IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT, \
- .scan_type = IIO_ST('u', (_bits), 16, 14 - (_bits)) \
-}
-
-static const struct ad5380_chip_info ad5380_chip_info_tbl[] = {
- [ID_AD5380_3] = {
- .channel_template = AD5380_CHANNEL(14),
- .num_channels = 40,
- .int_vref = 1250000,
- },
- [ID_AD5380_5] = {
- .channel_template = AD5380_CHANNEL(14),
- .num_channels = 40,
- .int_vref = 2500000,
- },
- [ID_AD5381_3] = {
- .channel_template = AD5380_CHANNEL(12),
- .num_channels = 16,
- .int_vref = 1250000,
- },
- [ID_AD5381_5] = {
- .channel_template = AD5380_CHANNEL(12),
- .num_channels = 16,
- .int_vref = 2500000,
- },
- [ID_AD5382_3] = {
- .channel_template = AD5380_CHANNEL(14),
- .num_channels = 32,
- .int_vref = 1250000,
- },
- [ID_AD5382_5] = {
- .channel_template = AD5380_CHANNEL(14),
- .num_channels = 32,
- .int_vref = 2500000,
- },
- [ID_AD5383_3] = {
- .channel_template = AD5380_CHANNEL(12),
- .num_channels = 32,
- .int_vref = 1250000,
- },
- [ID_AD5383_5] = {
- .channel_template = AD5380_CHANNEL(12),
- .num_channels = 32,
- .int_vref = 2500000,
- },
- [ID_AD5390_3] = {
- .channel_template = AD5380_CHANNEL(14),
- .num_channels = 16,
- .int_vref = 1250000,
- },
- [ID_AD5390_5] = {
- .channel_template = AD5380_CHANNEL(14),
- .num_channels = 16,
- .int_vref = 2500000,
- },
- [ID_AD5391_3] = {
- .channel_template = AD5380_CHANNEL(12),
- .num_channels = 16,
- .int_vref = 1250000,
- },
- [ID_AD5391_5] = {
- .channel_template = AD5380_CHANNEL(12),
- .num_channels = 16,
- .int_vref = 2500000,
- },
- [ID_AD5392_3] = {
- .channel_template = AD5380_CHANNEL(14),
- .num_channels = 8,
- .int_vref = 1250000,
- },
- [ID_AD5392_5] = {
- .channel_template = AD5380_CHANNEL(14),
- .num_channels = 8,
- .int_vref = 2500000,
- },
-};
-
-static ssize_t ad5380_read_dac_powerdown(struct device *dev,
- struct device_attribute *attr, char *buf)
-{
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
- struct ad5380_state *st = iio_priv(indio_dev);
-
- return sprintf(buf, "%d\n", st->pwr_down);
-}
-
-static ssize_t ad5380_write_dac_powerdown(struct device *dev,
- struct device_attribute *attr, const char *buf, size_t len)
-{
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
- struct ad5380_state *st = iio_priv(indio_dev);
- bool pwr_down;
- int ret;
-
- ret = strtobool(buf, &pwr_down);
- if (ret)
- return ret;
-
- mutex_lock(&indio_dev->mlock);
-
- if (pwr_down)
- ret = regmap_write(st->regmap, AD5380_REG_SF_PWR_DOWN, 0);
- else
- ret = regmap_write(st->regmap, AD5380_REG_SF_PWR_UP, 0);
-
- st->pwr_down = pwr_down;
-
- mutex_unlock(&indio_dev->mlock);
-
- return ret ? ret : len;
-}
-
-static IIO_DEVICE_ATTR(out_voltage_powerdown,
- S_IRUGO | S_IWUSR,
- ad5380_read_dac_powerdown,
- ad5380_write_dac_powerdown, 0);
-
-static const char ad5380_powerdown_modes[][15] = {
- [0] = "100kohm_to_gnd",
- [1] = "three_state",
-};
-
-static ssize_t ad5380_read_powerdown_mode(struct device *dev,
- struct device_attribute *attr, char *buf)
-{
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
- struct ad5380_state *st = iio_priv(indio_dev);
- unsigned int mode;
- int ret;
-
- ret = regmap_read(st->regmap, AD5380_REG_SF_CTRL, &mode);
- if (ret)
- return ret;
-
- mode = (mode >> AD5380_CTRL_PWR_DOWN_MODE_OFFSET) & 1;
-
- return sprintf(buf, "%s\n", ad5380_powerdown_modes[mode]);
-}
-
-static ssize_t ad5380_write_powerdown_mode(struct device *dev,
- struct device_attribute *attr, const char *buf, size_t len)
-{
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
- struct ad5380_state *st = iio_priv(indio_dev);
- unsigned int i;
- int ret;
-
- for (i = 0; i < ARRAY_SIZE(ad5380_powerdown_modes); ++i) {
- if (sysfs_streq(buf, ad5380_powerdown_modes[i]))
- break;
- }
-
- if (i == ARRAY_SIZE(ad5380_powerdown_modes))
- return -EINVAL;
-
- ret = regmap_update_bits(st->regmap, AD5380_REG_SF_CTRL,
- 1 << AD5380_CTRL_PWR_DOWN_MODE_OFFSET,
- i << AD5380_CTRL_PWR_DOWN_MODE_OFFSET);
-
- return ret ? ret : len;
-}
-
-static IIO_DEVICE_ATTR(out_voltage_powerdown_mode,
- S_IRUGO | S_IWUSR,
- ad5380_read_powerdown_mode,
- ad5380_write_powerdown_mode, 0);
-
-static IIO_CONST_ATTR(out_voltage_powerdown_mode_available,
- "100kohm_to_gnd three_state");
-
-static struct attribute *ad5380_attributes[] = {
- &iio_dev_attr_out_voltage_powerdown.dev_attr.attr,
- &iio_dev_attr_out_voltage_powerdown_mode.dev_attr.attr,
- &iio_const_attr_out_voltage_powerdown_mode_available.dev_attr.attr,
- NULL,
-};
-
-static const struct attribute_group ad5380_attribute_group = {
- .attrs = ad5380_attributes,
-};
-
-static unsigned int ad5380_info_to_reg(struct iio_chan_spec const *chan,
- long info)
-{
- switch (info) {
- case 0:
- return AD5380_REG_DATA(chan->address);
- case IIO_CHAN_INFO_CALIBBIAS:
- return AD5380_REG_OFFSET(chan->address);
- case IIO_CHAN_INFO_CALIBSCALE:
- return AD5380_REG_GAIN(chan->address);
- default:
- break;
- }
-
- return 0;
-}
-
-static int ad5380_write_raw(struct iio_dev *indio_dev,
- struct iio_chan_spec const *chan, int val, int val2, long info)
-{
- const unsigned int max_val = (1 << chan->scan_type.realbits);
- struct ad5380_state *st = iio_priv(indio_dev);
-
- switch (info) {
- case 0:
- case IIO_CHAN_INFO_CALIBSCALE:
- if (val >= max_val || val < 0)
- return -EINVAL;
-
- return regmap_write(st->regmap,
- ad5380_info_to_reg(chan, info),
- val << chan->scan_type.shift);
- case IIO_CHAN_INFO_CALIBBIAS:
- val += (1 << chan->scan_type.realbits) / 2;
- if (val >= max_val || val < 0)
- return -EINVAL;
-
- return regmap_write(st->regmap,
- AD5380_REG_OFFSET(chan->address),
- val << chan->scan_type.shift);
- default:
- break;
- }
- return -EINVAL;
-}
-
-static int ad5380_read_raw(struct iio_dev *indio_dev,
- struct iio_chan_spec const *chan, int *val, int *val2, long info)
-{
- struct ad5380_state *st = iio_priv(indio_dev);
- unsigned long scale_uv;
- int ret;
-
- switch (info) {
- case 0:
- case IIO_CHAN_INFO_CALIBSCALE:
- ret = regmap_read(st->regmap, ad5380_info_to_reg(chan, info),
- val);
- if (ret)
- return ret;
- *val >>= chan->scan_type.shift;
- return IIO_VAL_INT;
- case IIO_CHAN_INFO_CALIBBIAS:
- ret = regmap_read(st->regmap, AD5380_REG_OFFSET(chan->address),
- val);
- if (ret)
- return ret;
- *val >>= chan->scan_type.shift;
- val -= (1 << chan->scan_type.realbits) / 2;
- return IIO_VAL_INT;
- case IIO_CHAN_INFO_SCALE:
- scale_uv = ((2 * st->vref) >> chan->scan_type.realbits) * 100;
- *val = scale_uv / 100000;
- *val2 = (scale_uv % 100000) * 10;
- return IIO_VAL_INT_PLUS_MICRO;
- default:
- break;
- }
-
- return -EINVAL;
-}
-
-static const struct iio_info ad5380_info = {
- .read_raw = ad5380_read_raw,
- .write_raw = ad5380_write_raw,
- .attrs = &ad5380_attribute_group,
- .driver_module = THIS_MODULE,
-};
-
-static int __devinit ad5380_alloc_channels(struct iio_dev *indio_dev)
-{
- struct ad5380_state *st = iio_priv(indio_dev);
- struct iio_chan_spec *channels;
- unsigned int i;
-
- channels = kcalloc(st->chip_info->num_channels,
- sizeof(struct iio_chan_spec), GFP_KERNEL);
-
- if (!channels)
- return -ENOMEM;
-
- for (i = 0; i < st->chip_info->num_channels; ++i) {
- channels[i] = st->chip_info->channel_template;
- channels[i].channel = i;
- channels[i].address = i;
- }
-
- indio_dev->channels = channels;
-
- return 0;
-}
-
-static int __devinit ad5380_probe(struct device *dev, struct regmap *regmap,
- enum ad5380_type type, const char *name)
-{
- struct iio_dev *indio_dev;
- struct ad5380_state *st;
- unsigned int ctrl = 0;
- int ret;
-
- indio_dev = iio_allocate_device(sizeof(*st));
- if (indio_dev == NULL) {
- dev_err(dev, "Failed to allocate iio device\n");
- ret = -ENOMEM;
- goto error_regmap_exit;
- }
-
- st = iio_priv(indio_dev);
- dev_set_drvdata(dev, indio_dev);
-
- st->chip_info = &ad5380_chip_info_tbl[type];
- st->regmap = regmap;
-
- indio_dev->dev.parent = dev;
- indio_dev->name = name;
- indio_dev->info = &ad5380_info;
- indio_dev->modes = INDIO_DIRECT_MODE;
- indio_dev->num_channels = st->chip_info->num_channels;
-
- ret = ad5380_alloc_channels(indio_dev);
- if (ret) {
- dev_err(dev, "Failed to allocate channel spec: %d\n", ret);
- goto error_free;
- }
-
- if (st->chip_info->int_vref == 2500000)
- ctrl |= AD5380_CTRL_INT_VREF_2V5;
-
- st->vref_reg = regulator_get(dev, "vref");
- if (!IS_ERR(st->vref_reg)) {
- ret = regulator_enable(st->vref_reg);
- if (ret) {
- dev_err(dev, "Failed to enable vref regulators: %d\n",
- ret);
- goto error_free_reg;
- }
-
- st->vref = regulator_get_voltage(st->vref_reg);
- } else {
- st->vref = st->chip_info->int_vref;
- ctrl |= AD5380_CTRL_INT_VREF_EN;
- }
-
- ret = regmap_write(st->regmap, AD5380_REG_SF_CTRL, ctrl);
- if (ret) {
- dev_err(dev, "Failed to write to device: %d\n", ret);
- goto error_disable_reg;
- }
-
- ret = iio_device_register(indio_dev);
- if (ret) {
- dev_err(dev, "Failed to register iio device: %d\n", ret);
- goto error_disable_reg;
- }
-
- return 0;
-
-error_disable_reg:
- if (!IS_ERR(st->vref_reg))
- regulator_disable(st->vref_reg);
-error_free_reg:
- if (!IS_ERR(st->vref_reg))
- regulator_put(st->vref_reg);
-
- kfree(indio_dev->channels);
-error_free:
- iio_free_device(indio_dev);
-error_regmap_exit:
- regmap_exit(regmap);
-
- return ret;
-}
-
-static int __devexit ad5380_remove(struct device *dev)
-{
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
- struct ad5380_state *st = iio_priv(indio_dev);
-
- iio_device_unregister(indio_dev);
-
- kfree(indio_dev->channels);
-
- if (!IS_ERR(st->vref_reg)) {
- regulator_disable(st->vref_reg);
- regulator_put(st->vref_reg);
- }
-
- regmap_exit(st->regmap);
- iio_free_device(indio_dev);
-
- return 0;
-}
-
-static bool ad5380_reg_false(struct device *dev, unsigned int reg)
-{
- return false;
-}
-
-static const struct regmap_config ad5380_regmap_config = {
- .reg_bits = 10,
- .val_bits = 14,
-
- .max_register = AD5380_REG_DATA(40),
- .cache_type = REGCACHE_RBTREE,
-
- .volatile_reg = ad5380_reg_false,
- .readable_reg = ad5380_reg_false,
-};
-
-#if IS_ENABLED(CONFIG_SPI_MASTER)
-
-static int __devinit ad5380_spi_probe(struct spi_device *spi)
-{
- const struct spi_device_id *id = spi_get_device_id(spi);
- struct regmap *regmap;
-
- regmap = regmap_init_spi(spi, &ad5380_regmap_config);
-
- if (IS_ERR(regmap))
- return PTR_ERR(regmap);
-
- return ad5380_probe(&spi->dev, regmap, id->driver_data, id->name);
-}
-
-static int __devexit ad5380_spi_remove(struct spi_device *spi)
-{
- return ad5380_remove(&spi->dev);
-}
-
-static const struct spi_device_id ad5380_spi_ids[] = {
- { "ad5380-3", ID_AD5380_3 },
- { "ad5380-5", ID_AD5380_5 },
- { "ad5381-3", ID_AD5381_3 },
- { "ad5381-5", ID_AD5381_5 },
- { "ad5382-3", ID_AD5382_3 },
- { "ad5382-5", ID_AD5382_5 },
- { "ad5383-3", ID_AD5383_3 },
- { "ad5383-5", ID_AD5383_5 },
- { "ad5384-3", ID_AD5380_3 },
- { "ad5384-5", ID_AD5380_5 },
- { "ad5390-3", ID_AD5390_3 },
- { "ad5390-5", ID_AD5390_5 },
- { "ad5391-3", ID_AD5391_3 },
- { "ad5391-5", ID_AD5391_5 },
- { "ad5392-3", ID_AD5392_3 },
- { "ad5392-5", ID_AD5392_5 },
- { }
-};
-MODULE_DEVICE_TABLE(spi, ad5380_spi_ids);
-
-static struct spi_driver ad5380_spi_driver = {
- .driver = {
- .name = "ad5380",
- .owner = THIS_MODULE,
- },
- .probe = ad5380_spi_probe,
- .remove = __devexit_p(ad5380_spi_remove),
- .id_table = ad5380_spi_ids,
-};
-
-static inline int ad5380_spi_register_driver(void)
-{
- return spi_register_driver(&ad5380_spi_driver);
-}
-
-static inline void ad5380_spi_unregister_driver(void)
-{
- spi_unregister_driver(&ad5380_spi_driver);
-}
-
-#else
-
-static inline int ad5380_spi_register_driver(void)
-{
- return 0;
-}
-
-static inline void ad5380_spi_unregister_driver(void)
-{
-}
-
-#endif
-
-#if IS_ENABLED(CONFIG_I2C)
-
-static int __devinit ad5380_i2c_probe(struct i2c_client *i2c,
- const struct i2c_device_id *id)
-{
- struct regmap *regmap;
-
- regmap = regmap_init_i2c(i2c, &ad5380_regmap_config);
-
- if (IS_ERR(regmap))
- return PTR_ERR(regmap);
-
- return ad5380_probe(&i2c->dev, regmap, id->driver_data, id->name);
-}
-
-static int __devexit ad5380_i2c_remove(struct i2c_client *i2c)
-{
- return ad5380_remove(&i2c->dev);
-}
-
-static const struct i2c_device_id ad5380_i2c_ids[] = {
- { "ad5380-3", ID_AD5380_3 },
- { "ad5380-5", ID_AD5380_5 },
- { "ad5381-3", ID_AD5381_3 },
- { "ad5381-5", ID_AD5381_5 },
- { "ad5382-3", ID_AD5382_3 },
- { "ad5382-5", ID_AD5382_5 },
- { "ad5383-3", ID_AD5383_3 },
- { "ad5383-5", ID_AD5383_5 },
- { "ad5384-3", ID_AD5380_3 },
- { "ad5384-5", ID_AD5380_5 },
- { "ad5390-3", ID_AD5390_3 },
- { "ad5390-5", ID_AD5390_5 },
- { "ad5391-3", ID_AD5391_3 },
- { "ad5391-5", ID_AD5391_5 },
- { "ad5392-3", ID_AD5392_3 },
- { "ad5392-5", ID_AD5392_5 },
- { }
-};
-MODULE_DEVICE_TABLE(i2c, ad5380_i2c_ids);
-
-static struct i2c_driver ad5380_i2c_driver = {
- .driver = {
- .name = "ad5380",
- .owner = THIS_MODULE,
- },
- .probe = ad5380_i2c_probe,
- .remove = __devexit_p(ad5380_i2c_remove),
- .id_table = ad5380_i2c_ids,
-};
-
-static inline int ad5380_i2c_register_driver(void)
-{
- return i2c_add_driver(&ad5380_i2c_driver);
-}
-
-static inline void ad5380_i2c_unregister_driver(void)
-{
- i2c_del_driver(&ad5380_i2c_driver);
-}
-
-#else
-
-static inline int ad5380_i2c_register_driver(void)
-{
- return 0;
-}
-
-static inline void ad5380_i2c_unregister_driver(void)
-{
-}
-
-#endif
-
-static int __init ad5380_spi_init(void)
-{
- int ret;
-
- ret = ad5380_spi_register_driver();
- if (ret)
- return ret;
-
- ret = ad5380_i2c_register_driver();
- if (ret) {
- ad5380_spi_unregister_driver();
- return ret;
- }
-
- return 0;
-}
-module_init(ad5380_spi_init);
-
-static void __exit ad5380_spi_exit(void)
-{
- ad5380_i2c_unregister_driver();
- ad5380_spi_unregister_driver();
-
-}
-module_exit(ad5380_spi_exit);
-
-MODULE_AUTHOR("Lars-Peter Clausen <lars@metafoo.de>");
-MODULE_DESCRIPTION("Analog Devices AD5380/81/82/83/84/90/91/92 DAC");
-MODULE_LICENSE("GPL v2");
diff --git a/drivers/staging/iio/dac/ad5421.c b/drivers/staging/iio/dac/ad5421.c
deleted file mode 100644
index 0b040b204697..000000000000
--- a/drivers/staging/iio/dac/ad5421.c
+++ /dev/null
@@ -1,544 +0,0 @@
-/*
- * AD5421 Digital to analog converters driver
- *
- * Copyright 2011 Analog Devices Inc.
- *
- * Licensed under the GPL-2.
- */
-
-#include <linux/device.h>
-#include <linux/delay.h>
-#include <linux/err.h>
-#include <linux/module.h>
-#include <linux/interrupt.h>
-#include <linux/kernel.h>
-#include <linux/spi/spi.h>
-#include <linux/slab.h>
-#include <linux/sysfs.h>
-
-#include "../iio.h"
-#include "../sysfs.h"
-#include "../events.h"
-#include "dac.h"
-#include "ad5421.h"
-
-
-#define AD5421_REG_DAC_DATA 0x1
-#define AD5421_REG_CTRL 0x2
-#define AD5421_REG_OFFSET 0x3
-#define AD5421_REG_GAIN 0x4
-/* load dac and fault shared the same register number. Writing to it will cause
- * a dac load command, reading from it will return the fault status register */
-#define AD5421_REG_LOAD_DAC 0x5
-#define AD5421_REG_FAULT 0x5
-#define AD5421_REG_FORCE_ALARM_CURRENT 0x6
-#define AD5421_REG_RESET 0x7
-#define AD5421_REG_START_CONVERSION 0x8
-#define AD5421_REG_NOOP 0x9
-
-#define AD5421_CTRL_WATCHDOG_DISABLE BIT(12)
-#define AD5421_CTRL_AUTO_FAULT_READBACK BIT(11)
-#define AD5421_CTRL_MIN_CURRENT BIT(9)
-#define AD5421_CTRL_ADC_SOURCE_TEMP BIT(8)
-#define AD5421_CTRL_ADC_ENABLE BIT(7)
-#define AD5421_CTRL_PWR_DOWN_INT_VREF BIT(6)
-
-#define AD5421_FAULT_SPI BIT(15)
-#define AD5421_FAULT_PEC BIT(14)
-#define AD5421_FAULT_OVER_CURRENT BIT(13)
-#define AD5421_FAULT_UNDER_CURRENT BIT(12)
-#define AD5421_FAULT_TEMP_OVER_140 BIT(11)
-#define AD5421_FAULT_TEMP_OVER_100 BIT(10)
-#define AD5421_FAULT_UNDER_VOLTAGE_6V BIT(9)
-#define AD5421_FAULT_UNDER_VOLTAGE_12V BIT(8)
-
-/* These bits will cause the fault pin to go high */
-#define AD5421_FAULT_TRIGGER_IRQ \
- (AD5421_FAULT_SPI | AD5421_FAULT_PEC | AD5421_FAULT_OVER_CURRENT | \
- AD5421_FAULT_UNDER_CURRENT | AD5421_FAULT_TEMP_OVER_140)
-
-/**
- * struct ad5421_state - driver instance specific data
- * @spi: spi_device
- * @ctrl: control register cache
- * @current_range: current range which the device is configured for
- * @data: spi transfer buffers
- * @fault_mask: software masking of events
- */
-struct ad5421_state {
- struct spi_device *spi;
- unsigned int ctrl;
- enum ad5421_current_range current_range;
- unsigned int fault_mask;
-
- /*
- * DMA (thus cache coherency maintenance) requires the
- * transfer buffers to live in their own cache lines.
- */
- union {
- u32 d32;
- u8 d8[4];
- } data[2] ____cacheline_aligned;
-};
-
-static const struct iio_chan_spec ad5421_channels[] = {
- {
- .type = IIO_CURRENT,
- .indexed = 1,
- .output = 1,
- .channel = 0,
- .info_mask = IIO_CHAN_INFO_SCALE_SHARED_BIT |
- IIO_CHAN_INFO_OFFSET_SHARED_BIT |
- IIO_CHAN_INFO_CALIBSCALE_SEPARATE_BIT |
- IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT,
- .scan_type = IIO_ST('u', 16, 16, 0),
- .event_mask = IIO_EV_BIT(IIO_EV_TYPE_THRESH, IIO_EV_DIR_RISING) |
- IIO_EV_BIT(IIO_EV_TYPE_THRESH, IIO_EV_DIR_FALLING),
- },
- {
- .type = IIO_TEMP,
- .channel = -1,
- .event_mask = IIO_EV_BIT(IIO_EV_TYPE_THRESH, IIO_EV_DIR_RISING),
- },
-};
-
-static int ad5421_write_unlocked(struct iio_dev *indio_dev,
- unsigned int reg, unsigned int val)
-{
- struct ad5421_state *st = iio_priv(indio_dev);
-
- st->data[0].d32 = cpu_to_be32((reg << 16) | val);
-
- return spi_write(st->spi, &st->data[0].d8[1], 3);
-}
-
-static int ad5421_write(struct iio_dev *indio_dev, unsigned int reg,
- unsigned int val)
-{
- int ret;
-
- mutex_lock(&indio_dev->mlock);
- ret = ad5421_write_unlocked(indio_dev, reg, val);
- mutex_unlock(&indio_dev->mlock);
-
- return ret;
-}
-
-static int ad5421_read(struct iio_dev *indio_dev, unsigned int reg)
-{
- struct ad5421_state *st = iio_priv(indio_dev);
- struct spi_message m;
- int ret;
- struct spi_transfer t[] = {
- {
- .tx_buf = &st->data[0].d8[1],
- .len = 3,
- .cs_change = 1,
- }, {
- .rx_buf = &st->data[1].d8[1],
- .len = 3,
- },
- };
-
- spi_message_init(&m);
- spi_message_add_tail(&t[0], &m);
- spi_message_add_tail(&t[1], &m);
-
- mutex_lock(&indio_dev->mlock);
-
- st->data[0].d32 = cpu_to_be32((1 << 23) | (reg << 16));
-
- ret = spi_sync(st->spi, &m);
- if (ret >= 0)
- ret = be32_to_cpu(st->data[1].d32) & 0xffff;
-
- mutex_unlock(&indio_dev->mlock);
-
- return ret;
-}
-
-static int ad5421_update_ctrl(struct iio_dev *indio_dev, unsigned int set,
- unsigned int clr)
-{
- struct ad5421_state *st = iio_priv(indio_dev);
- unsigned int ret;
-
- mutex_lock(&indio_dev->mlock);
-
- st->ctrl &= ~clr;
- st->ctrl |= set;
-
- ret = ad5421_write_unlocked(indio_dev, AD5421_REG_CTRL, st->ctrl);
-
- mutex_unlock(&indio_dev->mlock);
-
- return ret;
-}
-
-static irqreturn_t ad5421_fault_handler(int irq, void *data)
-{
- struct iio_dev *indio_dev = data;
- struct ad5421_state *st = iio_priv(indio_dev);
- unsigned int fault;
- unsigned int old_fault = 0;
- unsigned int events;
-
- fault = ad5421_read(indio_dev, AD5421_REG_FAULT);
- if (!fault)
- return IRQ_NONE;
-
- /* If we had a fault, this might mean that the DAC has lost its state
- * and has been reset. Make sure that the control register actually
- * contains what we expect it to contain. Otherwise the watchdog might
- * be enabled and we get watchdog timeout faults, which will render the
- * DAC unusable. */
- ad5421_update_ctrl(indio_dev, 0, 0);
-
-
- /* The fault pin stays high as long as a fault condition is present and
- * it is not possible to mask fault conditions. For certain fault
- * conditions for example like over-temperature it takes some time
- * until the fault condition disappears. If we would exit the interrupt
- * handler immediately after handling the event it would be entered
- * again instantly. Thus we fall back to polling in case we detect that
- * a interrupt condition is still present.
- */
- do {
- /* 0xffff is a invalid value for the register and will only be
- * read if there has been a communication error */
- if (fault == 0xffff)
- fault = 0;
-
- /* we are only interested in new events */
- events = (old_fault ^ fault) & fault;
- events &= st->fault_mask;
-
- if (events & AD5421_FAULT_OVER_CURRENT) {
- iio_push_event(indio_dev,
- IIO_UNMOD_EVENT_CODE(IIO_CURRENT,
- 0,
- IIO_EV_TYPE_THRESH,
- IIO_EV_DIR_RISING),
- iio_get_time_ns());
- }
-
- if (events & AD5421_FAULT_UNDER_CURRENT) {
- iio_push_event(indio_dev,
- IIO_UNMOD_EVENT_CODE(IIO_CURRENT,
- 0,
- IIO_EV_TYPE_THRESH,
- IIO_EV_DIR_FALLING),
- iio_get_time_ns());
- }
-
- if (events & AD5421_FAULT_TEMP_OVER_140) {
- iio_push_event(indio_dev,
- IIO_UNMOD_EVENT_CODE(IIO_TEMP,
- 0,
- IIO_EV_TYPE_MAG,
- IIO_EV_DIR_RISING),
- iio_get_time_ns());
- }
-
- old_fault = fault;
- fault = ad5421_read(indio_dev, AD5421_REG_FAULT);
-
- /* still active? go to sleep for some time */
- if (fault & AD5421_FAULT_TRIGGER_IRQ)
- msleep(1000);
-
- } while (fault & AD5421_FAULT_TRIGGER_IRQ);
-
-
- return IRQ_HANDLED;
-}
-
-static void ad5421_get_current_min_max(struct ad5421_state *st,
- unsigned int *min, unsigned int *max)
-{
- /* The current range is configured using external pins, which are
- * usually hard-wired and not run-time switchable. */
- switch (st->current_range) {
- case AD5421_CURRENT_RANGE_4mA_20mA:
- *min = 4000;
- *max = 20000;
- break;
- case AD5421_CURRENT_RANGE_3mA8_21mA:
- *min = 3800;
- *max = 21000;
- break;
- case AD5421_CURRENT_RANGE_3mA2_24mA:
- *min = 3200;
- *max = 24000;
- break;
- default:
- *min = 0;
- *max = 1;
- break;
- }
-}
-
-static inline unsigned int ad5421_get_offset(struct ad5421_state *st)
-{
- unsigned int min, max;
-
- ad5421_get_current_min_max(st, &min, &max);
- return (min * (1 << 16)) / (max - min);
-}
-
-static inline unsigned int ad5421_get_scale(struct ad5421_state *st)
-{
- unsigned int min, max;
-
- ad5421_get_current_min_max(st, &min, &max);
- return ((max - min) * 1000) / (1 << 16);
-}
-
-static int ad5421_read_raw(struct iio_dev *indio_dev,
- struct iio_chan_spec const *chan, int *val, int *val2, long m)
-{
- struct ad5421_state *st = iio_priv(indio_dev);
- int ret;
-
- if (chan->type != IIO_CURRENT)
- return -EINVAL;
-
- switch (m) {
- case 0:
- ret = ad5421_read(indio_dev, AD5421_REG_DAC_DATA);
- if (ret < 0)
- return ret;
- *val = ret;
- return IIO_VAL_INT;
- case IIO_CHAN_INFO_SCALE:
- *val = 0;
- *val2 = ad5421_get_scale(st);
- return IIO_VAL_INT_PLUS_MICRO;
- case IIO_CHAN_INFO_OFFSET:
- *val = ad5421_get_offset(st);
- return IIO_VAL_INT;
- case IIO_CHAN_INFO_CALIBBIAS:
- ret = ad5421_read(indio_dev, AD5421_REG_OFFSET);
- if (ret < 0)
- return ret;
- *val = ret - 32768;
- return IIO_VAL_INT;
- case IIO_CHAN_INFO_CALIBSCALE:
- ret = ad5421_read(indio_dev, AD5421_REG_GAIN);
- if (ret < 0)
- return ret;
- *val = ret;
- return IIO_VAL_INT;
- }
-
- return -EINVAL;
-}
-
-static int ad5421_write_raw(struct iio_dev *indio_dev,
- struct iio_chan_spec const *chan, int val, int val2, long mask)
-{
- const unsigned int max_val = 1 << 16;
-
- switch (mask) {
- case 0:
- if (val >= max_val || val < 0)
- return -EINVAL;
-
- return ad5421_write(indio_dev, AD5421_REG_DAC_DATA, val);
- case IIO_CHAN_INFO_CALIBBIAS:
- val += 32768;
- if (val >= max_val || val < 0)
- return -EINVAL;
-
- return ad5421_write(indio_dev, AD5421_REG_OFFSET, val);
- case IIO_CHAN_INFO_CALIBSCALE:
- if (val >= max_val || val < 0)
- return -EINVAL;
-
- return ad5421_write(indio_dev, AD5421_REG_GAIN, val);
- default:
- break;
- }
-
- return -EINVAL;
-}
-
-static int ad5421_write_event_config(struct iio_dev *indio_dev,
- u64 event_code, int state)
-{
- struct ad5421_state *st = iio_priv(indio_dev);
- unsigned int mask;
-
- switch (IIO_EVENT_CODE_EXTRACT_CHAN_TYPE(event_code)) {
- case IIO_CURRENT:
- if (IIO_EVENT_CODE_EXTRACT_DIR(event_code) ==
- IIO_EV_DIR_RISING)
- mask = AD5421_FAULT_OVER_CURRENT;
- else
- mask = AD5421_FAULT_UNDER_CURRENT;
- break;
- case IIO_TEMP:
- mask = AD5421_FAULT_TEMP_OVER_140;
- break;
- default:
- return -EINVAL;
- }
-
- mutex_lock(&indio_dev->mlock);
- if (state)
- st->fault_mask |= mask;
- else
- st->fault_mask &= ~mask;
- mutex_unlock(&indio_dev->mlock);
-
- return 0;
-}
-
-static int ad5421_read_event_config(struct iio_dev *indio_dev,
- u64 event_code)
-{
- struct ad5421_state *st = iio_priv(indio_dev);
- unsigned int mask;
-
- switch (IIO_EVENT_CODE_EXTRACT_CHAN_TYPE(event_code)) {
- case IIO_CURRENT:
- if (IIO_EVENT_CODE_EXTRACT_DIR(event_code) ==
- IIO_EV_DIR_RISING)
- mask = AD5421_FAULT_OVER_CURRENT;
- else
- mask = AD5421_FAULT_UNDER_CURRENT;
- break;
- case IIO_TEMP:
- mask = AD5421_FAULT_TEMP_OVER_140;
- break;
- default:
- return -EINVAL;
- }
-
- return (bool)(st->fault_mask & mask);
-}
-
-static int ad5421_read_event_value(struct iio_dev *indio_dev, u64 event_code,
- int *val)
-{
- int ret;
-
- switch (IIO_EVENT_CODE_EXTRACT_CHAN_TYPE(event_code)) {
- case IIO_CURRENT:
- ret = ad5421_read(indio_dev, AD5421_REG_DAC_DATA);
- if (ret < 0)
- return ret;
- *val = ret;
- break;
- case IIO_TEMP:
- *val = 140000;
- break;
- default:
- return -EINVAL;
- }
-
- return 0;
-}
-
-static const struct iio_info ad5421_info = {
- .read_raw = ad5421_read_raw,
- .write_raw = ad5421_write_raw,
- .read_event_config = ad5421_read_event_config,
- .write_event_config = ad5421_write_event_config,
- .read_event_value = ad5421_read_event_value,
- .driver_module = THIS_MODULE,
-};
-
-static int __devinit ad5421_probe(struct spi_device *spi)
-{
- struct ad5421_platform_data *pdata = dev_get_platdata(&spi->dev);
- struct iio_dev *indio_dev;
- struct ad5421_state *st;
- int ret;
-
- indio_dev = iio_allocate_device(sizeof(*st));
- if (indio_dev == NULL) {
- dev_err(&spi->dev, "Failed to allocate iio device\n");
- return -ENOMEM;
- }
-
- st = iio_priv(indio_dev);
- spi_set_drvdata(spi, indio_dev);
-
- st->spi = spi;
-
- indio_dev->dev.parent = &spi->dev;
- indio_dev->name = "ad5421";
- indio_dev->info = &ad5421_info;
- indio_dev->modes = INDIO_DIRECT_MODE;
- indio_dev->channels = ad5421_channels;
- indio_dev->num_channels = ARRAY_SIZE(ad5421_channels);
-
- st->ctrl = AD5421_CTRL_WATCHDOG_DISABLE |
- AD5421_CTRL_AUTO_FAULT_READBACK;
-
- if (pdata) {
- st->current_range = pdata->current_range;
- if (pdata->external_vref)
- st->ctrl |= AD5421_CTRL_PWR_DOWN_INT_VREF;
- } else {
- st->current_range = AD5421_CURRENT_RANGE_4mA_20mA;
- }
-
- /* write initial ctrl register value */
- ad5421_update_ctrl(indio_dev, 0, 0);
-
- if (spi->irq) {
- ret = request_threaded_irq(spi->irq,
- NULL,
- ad5421_fault_handler,
- IRQF_TRIGGER_HIGH | IRQF_ONESHOT,
- "ad5421 fault",
- indio_dev);
- if (ret)
- goto error_free;
- }
-
- ret = iio_device_register(indio_dev);
- if (ret) {
- dev_err(&spi->dev, "Failed to register iio device: %d\n", ret);
- goto error_free_irq;
- }
-
- return 0;
-
-error_free_irq:
- if (spi->irq)
- free_irq(spi->irq, indio_dev);
-error_free:
- iio_free_device(indio_dev);
-
- return ret;
-}
-
-static int __devexit ad5421_remove(struct spi_device *spi)
-{
- struct iio_dev *indio_dev = spi_get_drvdata(spi);
-
- iio_device_unregister(indio_dev);
- if (spi->irq)
- free_irq(spi->irq, indio_dev);
- iio_free_device(indio_dev);
-
- return 0;
-}
-
-static struct spi_driver ad5421_driver = {
- .driver = {
- .name = "ad5421",
- .owner = THIS_MODULE,
- },
- .probe = ad5421_probe,
- .remove = __devexit_p(ad5421_remove),
-};
-module_spi_driver(ad5421_driver);
-
-MODULE_AUTHOR("Lars-Peter Clausen <lars@metafoo.de>");
-MODULE_DESCRIPTION("Analog Devices AD5421 DAC");
-MODULE_LICENSE("GPL v2");
-MODULE_ALIAS("spi:ad5421");
diff --git a/drivers/staging/iio/dac/ad5421.h b/drivers/staging/iio/dac/ad5421.h
deleted file mode 100644
index cd2bb84ff1b0..000000000000
--- a/drivers/staging/iio/dac/ad5421.h
+++ /dev/null
@@ -1,32 +0,0 @@
-#ifndef __IIO_DAC_AD5421_H__
-#define __IIO_DAC_AD5421_H__
-
-/*
- * TODO: This file needs to go into include/linux/iio
- */
-
-/**
- * enum ad5421_current_range - Current range the AD5421 is configured for.
- * @AD5421_CURRENT_RANGE_4mA_20mA: 4 mA to 20 mA (RANGE1,0 pins = 00)
- * @AD5421_CURRENT_RANGE_3mA8_21mA: 3.8 mA to 21 mA (RANGE1,0 pins = x1)
- * @AD5421_CURRENT_RANGE_3mA2_24mA: 3.2 mA to 24 mA (RANGE1,0 pins = 10)
- */
-
-enum ad5421_current_range {
- AD5421_CURRENT_RANGE_4mA_20mA,
- AD5421_CURRENT_RANGE_3mA8_21mA,
- AD5421_CURRENT_RANGE_3mA2_24mA,
-};
-
-/**
- * struct ad5421_platform_data - AD5421 DAC driver platform data
- * @external_vref: whether an external reference voltage is used or not
- * @current_range: Current range the AD5421 is configured for
- */
-
-struct ad5421_platform_data {
- bool external_vref;
- enum ad5421_current_range current_range;
-};
-
-#endif
diff --git a/drivers/staging/iio/dac/ad5446.c b/drivers/staging/iio/dac/ad5446.c
deleted file mode 100644
index 633ffbb21814..000000000000
--- a/drivers/staging/iio/dac/ad5446.c
+++ /dev/null
@@ -1,440 +0,0 @@
-/*
- * AD5446 SPI DAC driver
- *
- * Copyright 2010 Analog Devices Inc.
- *
- * Licensed under the GPL-2 or later.
- */
-
-#include <linux/interrupt.h>
-#include <linux/workqueue.h>
-#include <linux/device.h>
-#include <linux/kernel.h>
-#include <linux/slab.h>
-#include <linux/sysfs.h>
-#include <linux/list.h>
-#include <linux/spi/spi.h>
-#include <linux/regulator/consumer.h>
-#include <linux/err.h>
-#include <linux/module.h>
-
-#include "../iio.h"
-#include "../sysfs.h"
-#include "dac.h"
-
-#include "ad5446.h"
-
-static void ad5446_store_sample(struct ad5446_state *st, unsigned val)
-{
- st->data.d16 = cpu_to_be16(AD5446_LOAD | val);
-}
-
-static void ad5542_store_sample(struct ad5446_state *st, unsigned val)
-{
- st->data.d16 = cpu_to_be16(val);
-}
-
-static void ad5620_store_sample(struct ad5446_state *st, unsigned val)
-{
- st->data.d16 = cpu_to_be16(AD5620_LOAD | val);
-}
-
-static void ad5660_store_sample(struct ad5446_state *st, unsigned val)
-{
- val |= AD5660_LOAD;
- st->data.d24[0] = (val >> 16) & 0xFF;
- st->data.d24[1] = (val >> 8) & 0xFF;
- st->data.d24[2] = val & 0xFF;
-}
-
-static void ad5620_store_pwr_down(struct ad5446_state *st, unsigned mode)
-{
- st->data.d16 = cpu_to_be16(mode << 14);
-}
-
-static void ad5660_store_pwr_down(struct ad5446_state *st, unsigned mode)
-{
- unsigned val = mode << 16;
-
- st->data.d24[0] = (val >> 16) & 0xFF;
- st->data.d24[1] = (val >> 8) & 0xFF;
- st->data.d24[2] = val & 0xFF;
-}
-
-static ssize_t ad5446_write_powerdown_mode(struct device *dev,
- struct device_attribute *attr,
- const char *buf, size_t len)
-{
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
- struct ad5446_state *st = iio_priv(indio_dev);
-
- if (sysfs_streq(buf, "1kohm_to_gnd"))
- st->pwr_down_mode = MODE_PWRDWN_1k;
- else if (sysfs_streq(buf, "100kohm_to_gnd"))
- st->pwr_down_mode = MODE_PWRDWN_100k;
- else if (sysfs_streq(buf, "three_state"))
- st->pwr_down_mode = MODE_PWRDWN_TRISTATE;
- else
- return -EINVAL;
-
- return len;
-}
-
-static ssize_t ad5446_read_powerdown_mode(struct device *dev,
- struct device_attribute *attr, char *buf)
-{
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
- struct ad5446_state *st = iio_priv(indio_dev);
-
- char mode[][15] = {"", "1kohm_to_gnd", "100kohm_to_gnd", "three_state"};
-
- return sprintf(buf, "%s\n", mode[st->pwr_down_mode]);
-}
-
-static ssize_t ad5446_read_dac_powerdown(struct device *dev,
- struct device_attribute *attr,
- char *buf)
-{
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
- struct ad5446_state *st = iio_priv(indio_dev);
-
- return sprintf(buf, "%d\n", st->pwr_down);
-}
-
-static ssize_t ad5446_write_dac_powerdown(struct device *dev,
- struct device_attribute *attr,
- const char *buf, size_t len)
-{
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
- struct ad5446_state *st = iio_priv(indio_dev);
- unsigned long readin;
- int ret;
-
- ret = strict_strtol(buf, 10, &readin);
- if (ret)
- return ret;
-
- if (readin > 1)
- ret = -EINVAL;
-
- mutex_lock(&indio_dev->mlock);
- st->pwr_down = readin;
-
- if (st->pwr_down)
- st->chip_info->store_pwr_down(st, st->pwr_down_mode);
- else
- st->chip_info->store_sample(st, st->cached_val);
-
- ret = spi_sync(st->spi, &st->msg);
- mutex_unlock(&indio_dev->mlock);
-
- return ret ? ret : len;
-}
-
-static IIO_DEVICE_ATTR(out_voltage_powerdown_mode, S_IRUGO | S_IWUSR,
- ad5446_read_powerdown_mode,
- ad5446_write_powerdown_mode, 0);
-
-static IIO_CONST_ATTR(out_voltage_powerdown_mode_available,
- "1kohm_to_gnd 100kohm_to_gnd three_state");
-
-static IIO_DEVICE_ATTR(out_voltage0_powerdown, S_IRUGO | S_IWUSR,
- ad5446_read_dac_powerdown,
- ad5446_write_dac_powerdown, 0);
-
-static struct attribute *ad5446_attributes[] = {
- &iio_dev_attr_out_voltage0_powerdown.dev_attr.attr,
- &iio_dev_attr_out_voltage_powerdown_mode.dev_attr.attr,
- &iio_const_attr_out_voltage_powerdown_mode_available.dev_attr.attr,
- NULL,
-};
-
-static const struct attribute_group ad5446_attribute_group = {
- .attrs = ad5446_attributes,
-};
-
-#define AD5446_CHANNEL(bits, storage, shift) { \
- .type = IIO_VOLTAGE, \
- .indexed = 1, \
- .output = 1, \
- .channel = 0, \
- .info_mask = IIO_CHAN_INFO_SCALE_SHARED_BIT, \
- .scan_type = IIO_ST('u', (bits), (storage), (shift)) \
-}
-
-static const struct ad5446_chip_info ad5446_chip_info_tbl[] = {
- [ID_AD5444] = {
- .channel = AD5446_CHANNEL(12, 16, 2),
- .store_sample = ad5446_store_sample,
- },
- [ID_AD5446] = {
- .channel = AD5446_CHANNEL(14, 16, 0),
- .store_sample = ad5446_store_sample,
- },
- [ID_AD5541A] = {
- .channel = AD5446_CHANNEL(16, 16, 0),
- .store_sample = ad5542_store_sample,
- },
- [ID_AD5542A] = {
- .channel = AD5446_CHANNEL(16, 16, 0),
- .store_sample = ad5542_store_sample,
- },
- [ID_AD5543] = {
- .channel = AD5446_CHANNEL(16, 16, 0),
- .store_sample = ad5542_store_sample,
- },
- [ID_AD5512A] = {
- .channel = AD5446_CHANNEL(12, 16, 4),
- .store_sample = ad5542_store_sample,
- },
- [ID_AD5553] = {
- .channel = AD5446_CHANNEL(14, 16, 0),
- .store_sample = ad5542_store_sample,
- },
- [ID_AD5601] = {
- .channel = AD5446_CHANNEL(8, 16, 6),
- .store_sample = ad5542_store_sample,
- .store_pwr_down = ad5620_store_pwr_down,
- },
- [ID_AD5611] = {
- .channel = AD5446_CHANNEL(10, 16, 4),
- .store_sample = ad5542_store_sample,
- .store_pwr_down = ad5620_store_pwr_down,
- },
- [ID_AD5621] = {
- .channel = AD5446_CHANNEL(12, 16, 2),
- .store_sample = ad5542_store_sample,
- .store_pwr_down = ad5620_store_pwr_down,
- },
- [ID_AD5620_2500] = {
- .channel = AD5446_CHANNEL(12, 16, 2),
- .int_vref_mv = 2500,
- .store_sample = ad5620_store_sample,
- .store_pwr_down = ad5620_store_pwr_down,
- },
- [ID_AD5620_1250] = {
- .channel = AD5446_CHANNEL(12, 16, 2),
- .int_vref_mv = 1250,
- .store_sample = ad5620_store_sample,
- .store_pwr_down = ad5620_store_pwr_down,
- },
- [ID_AD5640_2500] = {
- .channel = AD5446_CHANNEL(14, 16, 0),
- .int_vref_mv = 2500,
- .store_sample = ad5620_store_sample,
- .store_pwr_down = ad5620_store_pwr_down,
- },
- [ID_AD5640_1250] = {
- .channel = AD5446_CHANNEL(14, 16, 0),
- .int_vref_mv = 1250,
- .store_sample = ad5620_store_sample,
- .store_pwr_down = ad5620_store_pwr_down,
- },
- [ID_AD5660_2500] = {
- .channel = AD5446_CHANNEL(16, 16, 0),
- .int_vref_mv = 2500,
- .store_sample = ad5660_store_sample,
- .store_pwr_down = ad5660_store_pwr_down,
- },
- [ID_AD5660_1250] = {
- .channel = AD5446_CHANNEL(16, 16, 0),
- .int_vref_mv = 1250,
- .store_sample = ad5660_store_sample,
- .store_pwr_down = ad5660_store_pwr_down,
- },
-};
-
-static int ad5446_read_raw(struct iio_dev *indio_dev,
- struct iio_chan_spec const *chan,
- int *val,
- int *val2,
- long m)
-{
- struct ad5446_state *st = iio_priv(indio_dev);
- unsigned long scale_uv;
-
- switch (m) {
- case IIO_CHAN_INFO_SCALE:
- scale_uv = (st->vref_mv * 1000) >> chan->scan_type.realbits;
- *val = scale_uv / 1000;
- *val2 = (scale_uv % 1000) * 1000;
- return IIO_VAL_INT_PLUS_MICRO;
-
- }
- return -EINVAL;
-}
-
-static int ad5446_write_raw(struct iio_dev *indio_dev,
- struct iio_chan_spec const *chan,
- int val,
- int val2,
- long mask)
-{
- struct ad5446_state *st = iio_priv(indio_dev);
- int ret;
-
- switch (mask) {
- case 0:
- if (val >= (1 << chan->scan_type.realbits) || val < 0)
- return -EINVAL;
-
- val <<= chan->scan_type.shift;
- mutex_lock(&indio_dev->mlock);
- st->cached_val = val;
- st->chip_info->store_sample(st, val);
- ret = spi_sync(st->spi, &st->msg);
- mutex_unlock(&indio_dev->mlock);
- break;
- default:
- ret = -EINVAL;
- }
-
- return ret;
-}
-
-static const struct iio_info ad5446_info = {
- .read_raw = ad5446_read_raw,
- .write_raw = ad5446_write_raw,
- .attrs = &ad5446_attribute_group,
- .driver_module = THIS_MODULE,
-};
-
-static const struct iio_info ad5446_info_no_pwr_down = {
- .read_raw = ad5446_read_raw,
- .write_raw = ad5446_write_raw,
- .driver_module = THIS_MODULE,
-};
-
-static int __devinit ad5446_probe(struct spi_device *spi)
-{
- struct ad5446_state *st;
- struct iio_dev *indio_dev;
- struct regulator *reg;
- int ret, voltage_uv = 0;
-
- reg = regulator_get(&spi->dev, "vcc");
- if (!IS_ERR(reg)) {
- ret = regulator_enable(reg);
- if (ret)
- goto error_put_reg;
-
- voltage_uv = regulator_get_voltage(reg);
- }
-
- indio_dev = iio_allocate_device(sizeof(*st));
- if (indio_dev == NULL) {
- ret = -ENOMEM;
- goto error_disable_reg;
- }
- st = iio_priv(indio_dev);
- st->chip_info =
- &ad5446_chip_info_tbl[spi_get_device_id(spi)->driver_data];
-
- spi_set_drvdata(spi, indio_dev);
- st->reg = reg;
- st->spi = spi;
-
- /* Establish that the iio_dev is a child of the spi device */
- indio_dev->dev.parent = &spi->dev;
- indio_dev->name = spi_get_device_id(spi)->name;
- if (st->chip_info->store_pwr_down)
- indio_dev->info = &ad5446_info;
- else
- indio_dev->info = &ad5446_info_no_pwr_down;
- indio_dev->modes = INDIO_DIRECT_MODE;
- indio_dev->channels = &st->chip_info->channel;
- indio_dev->num_channels = 1;
-
- /* Setup default message */
-
- st->xfer.tx_buf = &st->data;
- st->xfer.len = st->chip_info->channel.scan_type.storagebits / 8;
-
- spi_message_init(&st->msg);
- spi_message_add_tail(&st->xfer, &st->msg);
-
- switch (spi_get_device_id(spi)->driver_data) {
- case ID_AD5620_2500:
- case ID_AD5620_1250:
- case ID_AD5640_2500:
- case ID_AD5640_1250:
- case ID_AD5660_2500:
- case ID_AD5660_1250:
- st->vref_mv = st->chip_info->int_vref_mv;
- break;
- default:
- if (voltage_uv)
- st->vref_mv = voltage_uv / 1000;
- else
- dev_warn(&spi->dev,
- "reference voltage unspecified\n");
- }
-
- ret = iio_device_register(indio_dev);
- if (ret)
- goto error_free_device;
-
- return 0;
-
-error_free_device:
- iio_free_device(indio_dev);
-error_disable_reg:
- if (!IS_ERR(reg))
- regulator_disable(reg);
-error_put_reg:
- if (!IS_ERR(reg))
- regulator_put(reg);
-
- return ret;
-}
-
-static int ad5446_remove(struct spi_device *spi)
-{
- struct iio_dev *indio_dev = spi_get_drvdata(spi);
- struct ad5446_state *st = iio_priv(indio_dev);
-
- iio_device_unregister(indio_dev);
- if (!IS_ERR(st->reg)) {
- regulator_disable(st->reg);
- regulator_put(st->reg);
- }
- iio_free_device(indio_dev);
-
- return 0;
-}
-
-static const struct spi_device_id ad5446_id[] = {
- {"ad5444", ID_AD5444},
- {"ad5446", ID_AD5446},
- {"ad5512a", ID_AD5512A},
- {"ad5541a", ID_AD5541A},
- {"ad5542a", ID_AD5542A},
- {"ad5543", ID_AD5543},
- {"ad5553", ID_AD5553},
- {"ad5601", ID_AD5601},
- {"ad5611", ID_AD5611},
- {"ad5621", ID_AD5621},
- {"ad5620-2500", ID_AD5620_2500}, /* AD5620/40/60: */
- {"ad5620-1250", ID_AD5620_1250}, /* part numbers may look differently */
- {"ad5640-2500", ID_AD5640_2500},
- {"ad5640-1250", ID_AD5640_1250},
- {"ad5660-2500", ID_AD5660_2500},
- {"ad5660-1250", ID_AD5660_1250},
- {}
-};
-MODULE_DEVICE_TABLE(spi, ad5446_id);
-
-static struct spi_driver ad5446_driver = {
- .driver = {
- .name = "ad5446",
- .owner = THIS_MODULE,
- },
- .probe = ad5446_probe,
- .remove = __devexit_p(ad5446_remove),
- .id_table = ad5446_id,
-};
-module_spi_driver(ad5446_driver);
-
-MODULE_AUTHOR("Michael Hennerich <hennerich@blackfin.uclinux.org>");
-MODULE_DESCRIPTION("Analog Devices AD5444/AD5446 DAC");
-MODULE_LICENSE("GPL v2");
diff --git a/drivers/staging/iio/dac/ad5446.h b/drivers/staging/iio/dac/ad5446.h
deleted file mode 100644
index 4ea3476fb065..000000000000
--- a/drivers/staging/iio/dac/ad5446.h
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * AD5446 SPI DAC driver
- *
- * Copyright 2010 Analog Devices Inc.
- *
- * Licensed under the GPL-2 or later.
- */
-#ifndef IIO_DAC_AD5446_H_
-#define IIO_DAC_AD5446_H_
-
-/* DAC Control Bits */
-
-#define AD5446_LOAD (0x0 << 14) /* Load and update */
-#define AD5446_SDO_DIS (0x1 << 14) /* Disable SDO */
-#define AD5446_NOP (0x2 << 14) /* No operation */
-#define AD5446_CLK_RISING (0x3 << 14) /* Clock data on rising edge */
-
-#define AD5620_LOAD (0x0 << 14) /* Load and update Norm Operation*/
-#define AD5620_PWRDWN_1k (0x1 << 14) /* Power-down: 1kOhm to GND */
-#define AD5620_PWRDWN_100k (0x2 << 14) /* Power-down: 100kOhm to GND */
-#define AD5620_PWRDWN_TRISTATE (0x3 << 14) /* Power-down: Three-state */
-
-#define AD5660_LOAD (0x0 << 16) /* Load and update Norm Operation*/
-#define AD5660_PWRDWN_1k (0x1 << 16) /* Power-down: 1kOhm to GND */
-#define AD5660_PWRDWN_100k (0x2 << 16) /* Power-down: 100kOhm to GND */
-#define AD5660_PWRDWN_TRISTATE (0x3 << 16) /* Power-down: Three-state */
-
-#define MODE_PWRDWN_1k 0x1
-#define MODE_PWRDWN_100k 0x2
-#define MODE_PWRDWN_TRISTATE 0x3
-
-/**
- * struct ad5446_state - driver instance specific data
- * @spi: spi_device
- * @chip_info: chip model specific constants, available modes etc
- * @reg: supply regulator
- * @poll_work: bottom half of polling interrupt handler
- * @vref_mv: actual reference voltage used
- * @xfer: default spi transfer
- * @msg: default spi message
- * @data: spi transmit buffer
- */
-
-struct ad5446_state {
- struct spi_device *spi;
- const struct ad5446_chip_info *chip_info;
- struct regulator *reg;
- struct work_struct poll_work;
- unsigned short vref_mv;
- unsigned cached_val;
- unsigned pwr_down_mode;
- unsigned pwr_down;
- struct spi_transfer xfer;
- struct spi_message msg;
- union {
- unsigned short d16;
- unsigned char d24[3];
- } data;
-};
-
-/**
- * struct ad5446_chip_info - chip specific information
- * @channel: channel spec for the DAC
- * @int_vref_mv: AD5620/40/60: the internal reference voltage
- * @store_sample: chip specific helper function to store the datum
- * @store_sample: chip specific helper function to store the powerpown cmd
- */
-
-struct ad5446_chip_info {
- struct iio_chan_spec channel;
- u16 int_vref_mv;
- void (*store_sample) (struct ad5446_state *st, unsigned val);
- void (*store_pwr_down) (struct ad5446_state *st, unsigned mode);
-};
-
-/**
- * ad5446_supported_device_ids:
- * The AD5620/40/60 parts are available in different fixed internal reference
- * voltage options. The actual part numbers may look differently
- * (and a bit cryptic), however this style is used to make clear which
- * parts are supported here.
- */
-
-enum ad5446_supported_device_ids {
- ID_AD5444,
- ID_AD5446,
- ID_AD5541A,
- ID_AD5542A,
- ID_AD5543,
- ID_AD5512A,
- ID_AD5553,
- ID_AD5601,
- ID_AD5611,
- ID_AD5621,
- ID_AD5620_2500,
- ID_AD5620_1250,
- ID_AD5640_2500,
- ID_AD5640_1250,
- ID_AD5660_2500,
- ID_AD5660_1250,
-};
-
-#endif /* IIO_DAC_AD5446_H_ */
diff --git a/drivers/staging/iio/dac/ad5504.c b/drivers/staging/iio/dac/ad5504.c
deleted file mode 100644
index bc17205fe722..000000000000
--- a/drivers/staging/iio/dac/ad5504.c
+++ /dev/null
@@ -1,396 +0,0 @@
-/*
- * AD5504, AD5501 High Voltage Digital to Analog Converter
- *
- * Copyright 2011 Analog Devices Inc.
- *
- * Licensed under the GPL-2.
- */
-
-#include <linux/interrupt.h>
-#include <linux/fs.h>
-#include <linux/device.h>
-#include <linux/kernel.h>
-#include <linux/spi/spi.h>
-#include <linux/slab.h>
-#include <linux/sysfs.h>
-#include <linux/regulator/consumer.h>
-#include <linux/module.h>
-
-#include "../iio.h"
-#include "../sysfs.h"
-#include "../events.h"
-#include "dac.h"
-#include "ad5504.h"
-
-#define AD5504_CHANNEL(_chan) { \
- .type = IIO_VOLTAGE, \
- .indexed = 1, \
- .output = 1, \
- .channel = (_chan), \
- .info_mask = IIO_CHAN_INFO_SCALE_SHARED_BIT, \
- .address = AD5504_ADDR_DAC(_chan), \
- .scan_type = IIO_ST('u', 12, 16, 0), \
-}
-
-static const struct iio_chan_spec ad5504_channels[] = {
- AD5504_CHANNEL(0),
- AD5504_CHANNEL(1),
- AD5504_CHANNEL(2),
- AD5504_CHANNEL(3),
-};
-
-static int ad5504_spi_write(struct spi_device *spi, u8 addr, u16 val)
-{
- u16 tmp = cpu_to_be16(AD5504_CMD_WRITE |
- AD5504_ADDR(addr) |
- (val & AD5504_RES_MASK));
-
- return spi_write(spi, (u8 *)&tmp, 2);
-}
-
-static int ad5504_spi_read(struct spi_device *spi, u8 addr)
-{
- u16 tmp = cpu_to_be16(AD5504_CMD_READ | AD5504_ADDR(addr));
- u16 val;
- int ret;
- struct spi_transfer t = {
- .tx_buf = &tmp,
- .rx_buf = &val,
- .len = 2,
- };
- struct spi_message m;
-
- spi_message_init(&m);
- spi_message_add_tail(&t, &m);
- ret = spi_sync(spi, &m);
-
- if (ret < 0)
- return ret;
-
- return be16_to_cpu(val) & AD5504_RES_MASK;
-}
-
-static int ad5504_read_raw(struct iio_dev *indio_dev,
- struct iio_chan_spec const *chan,
- int *val,
- int *val2,
- long m)
-{
- struct ad5504_state *st = iio_priv(indio_dev);
- unsigned long scale_uv;
- int ret;
-
- switch (m) {
- case 0:
- ret = ad5504_spi_read(st->spi, chan->address);
- if (ret < 0)
- return ret;
-
- *val = ret;
-
- return IIO_VAL_INT;
- case IIO_CHAN_INFO_SCALE:
- scale_uv = (st->vref_mv * 1000) >> chan->scan_type.realbits;
- *val = scale_uv / 1000;
- *val2 = (scale_uv % 1000) * 1000;
- return IIO_VAL_INT_PLUS_MICRO;
-
- }
- return -EINVAL;
-}
-
-static int ad5504_write_raw(struct iio_dev *indio_dev,
- struct iio_chan_spec const *chan,
- int val,
- int val2,
- long mask)
-{
- struct ad5504_state *st = iio_priv(indio_dev);
- int ret;
-
- switch (mask) {
- case 0:
- if (val >= (1 << chan->scan_type.realbits) || val < 0)
- return -EINVAL;
-
- return ad5504_spi_write(st->spi, chan->address, val);
- default:
- ret = -EINVAL;
- }
-
- return -EINVAL;
-}
-
-static ssize_t ad5504_read_powerdown_mode(struct device *dev,
- struct device_attribute *attr, char *buf)
-{
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
- struct ad5504_state *st = iio_priv(indio_dev);
-
- const char mode[][14] = {"20kohm_to_gnd", "three_state"};
-
- return sprintf(buf, "%s\n", mode[st->pwr_down_mode]);
-}
-
-static ssize_t ad5504_write_powerdown_mode(struct device *dev,
- struct device_attribute *attr,
- const char *buf, size_t len)
-{
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
- struct ad5504_state *st = iio_priv(indio_dev);
- int ret;
-
- if (sysfs_streq(buf, "20kohm_to_gnd"))
- st->pwr_down_mode = AD5504_DAC_PWRDN_20K;
- else if (sysfs_streq(buf, "three_state"))
- st->pwr_down_mode = AD5504_DAC_PWRDN_3STATE;
- else
- ret = -EINVAL;
-
- return ret ? ret : len;
-}
-
-static ssize_t ad5504_read_dac_powerdown(struct device *dev,
- struct device_attribute *attr,
- char *buf)
-{
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
- struct ad5504_state *st = iio_priv(indio_dev);
- struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
-
- return sprintf(buf, "%d\n",
- !(st->pwr_down_mask & (1 << this_attr->address)));
-}
-
-static ssize_t ad5504_write_dac_powerdown(struct device *dev,
- struct device_attribute *attr,
- const char *buf, size_t len)
-{
- long readin;
- int ret;
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
- struct ad5504_state *st = iio_priv(indio_dev);
- struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
-
- ret = strict_strtol(buf, 10, &readin);
- if (ret)
- return ret;
-
- if (readin == 0)
- st->pwr_down_mask |= (1 << this_attr->address);
- else if (readin == 1)
- st->pwr_down_mask &= ~(1 << this_attr->address);
- else
- ret = -EINVAL;
-
- ret = ad5504_spi_write(st->spi, AD5504_ADDR_CTRL,
- AD5504_DAC_PWRDWN_MODE(st->pwr_down_mode) |
- AD5504_DAC_PWR(st->pwr_down_mask));
-
- /* writes to the CTRL register must be followed by a NOOP */
- ad5504_spi_write(st->spi, AD5504_ADDR_NOOP, 0);
-
- return ret ? ret : len;
-}
-
-static IIO_DEVICE_ATTR(out_voltage_powerdown_mode, S_IRUGO |
- S_IWUSR, ad5504_read_powerdown_mode,
- ad5504_write_powerdown_mode, 0);
-
-static IIO_CONST_ATTR(out_voltage_powerdown_mode_available,
- "20kohm_to_gnd three_state");
-
-#define IIO_DEV_ATTR_DAC_POWERDOWN(_num, _show, _store, _addr) \
- IIO_DEVICE_ATTR(out_voltage##_num##_powerdown, \
- S_IRUGO | S_IWUSR, _show, _store, _addr)
-static IIO_DEV_ATTR_DAC_POWERDOWN(0, ad5504_read_dac_powerdown,
- ad5504_write_dac_powerdown, 0);
-static IIO_DEV_ATTR_DAC_POWERDOWN(1, ad5504_read_dac_powerdown,
- ad5504_write_dac_powerdown, 1);
-static IIO_DEV_ATTR_DAC_POWERDOWN(2, ad5504_read_dac_powerdown,
- ad5504_write_dac_powerdown, 2);
-static IIO_DEV_ATTR_DAC_POWERDOWN(3, ad5504_read_dac_powerdown,
- ad5504_write_dac_powerdown, 3);
-
-static struct attribute *ad5504_attributes[] = {
- &iio_dev_attr_out_voltage0_powerdown.dev_attr.attr,
- &iio_dev_attr_out_voltage1_powerdown.dev_attr.attr,
- &iio_dev_attr_out_voltage2_powerdown.dev_attr.attr,
- &iio_dev_attr_out_voltage3_powerdown.dev_attr.attr,
- &iio_dev_attr_out_voltage_powerdown_mode.dev_attr.attr,
- &iio_const_attr_out_voltage_powerdown_mode_available.dev_attr.attr,
- NULL,
-};
-
-static const struct attribute_group ad5504_attribute_group = {
- .attrs = ad5504_attributes,
-};
-
-static struct attribute *ad5501_attributes[] = {
- &iio_dev_attr_out_voltage0_powerdown.dev_attr.attr,
- &iio_dev_attr_out_voltage_powerdown_mode.dev_attr.attr,
- &iio_const_attr_out_voltage_powerdown_mode_available.dev_attr.attr,
- NULL,
-};
-
-static const struct attribute_group ad5501_attribute_group = {
- .attrs = ad5501_attributes,
-};
-
-static IIO_CONST_ATTR(temp0_thresh_rising_value, "110000");
-static IIO_CONST_ATTR(temp0_thresh_rising_en, "1");
-
-static struct attribute *ad5504_ev_attributes[] = {
- &iio_const_attr_temp0_thresh_rising_value.dev_attr.attr,
- &iio_const_attr_temp0_thresh_rising_en.dev_attr.attr,
- NULL,
-};
-
-static struct attribute_group ad5504_ev_attribute_group = {
- .attrs = ad5504_ev_attributes,
- .name = "events",
-};
-
-static irqreturn_t ad5504_event_handler(int irq, void *private)
-{
- iio_push_event(private,
- IIO_UNMOD_EVENT_CODE(IIO_TEMP,
- 0,
- IIO_EV_TYPE_THRESH,
- IIO_EV_DIR_RISING),
- iio_get_time_ns());
-
- return IRQ_HANDLED;
-}
-
-static const struct iio_info ad5504_info = {
- .write_raw = ad5504_write_raw,
- .read_raw = ad5504_read_raw,
- .attrs = &ad5504_attribute_group,
- .event_attrs = &ad5504_ev_attribute_group,
- .driver_module = THIS_MODULE,
-};
-
-static const struct iio_info ad5501_info = {
- .write_raw = ad5504_write_raw,
- .read_raw = ad5504_read_raw,
- .attrs = &ad5501_attribute_group,
- .event_attrs = &ad5504_ev_attribute_group,
- .driver_module = THIS_MODULE,
-};
-
-static int __devinit ad5504_probe(struct spi_device *spi)
-{
- struct ad5504_platform_data *pdata = spi->dev.platform_data;
- struct iio_dev *indio_dev;
- struct ad5504_state *st;
- struct regulator *reg;
- int ret, voltage_uv = 0;
-
- indio_dev = iio_allocate_device(sizeof(*st));
- if (indio_dev == NULL) {
- ret = -ENOMEM;
- goto error_ret;
- }
- reg = regulator_get(&spi->dev, "vcc");
- if (!IS_ERR(reg)) {
- ret = regulator_enable(reg);
- if (ret)
- goto error_put_reg;
-
- voltage_uv = regulator_get_voltage(reg);
- }
-
- spi_set_drvdata(spi, indio_dev);
- st = iio_priv(indio_dev);
- if (voltage_uv)
- st->vref_mv = voltage_uv / 1000;
- else if (pdata)
- st->vref_mv = pdata->vref_mv;
- else
- dev_warn(&spi->dev, "reference voltage unspecified\n");
-
- st->reg = reg;
- st->spi = spi;
- indio_dev->dev.parent = &spi->dev;
- indio_dev->name = spi_get_device_id(st->spi)->name;
- if (spi_get_device_id(st->spi)->driver_data == ID_AD5501) {
- indio_dev->info = &ad5501_info;
- indio_dev->num_channels = 1;
- } else {
- indio_dev->info = &ad5504_info;
- indio_dev->num_channels = 4;
- }
- indio_dev->channels = ad5504_channels;
- indio_dev->modes = INDIO_DIRECT_MODE;
-
- if (spi->irq) {
- ret = request_threaded_irq(spi->irq,
- NULL,
- &ad5504_event_handler,
- IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
- spi_get_device_id(st->spi)->name,
- indio_dev);
- if (ret)
- goto error_disable_reg;
- }
-
- ret = iio_device_register(indio_dev);
- if (ret)
- goto error_free_irq;
-
- return 0;
-
-error_free_irq:
- free_irq(spi->irq, indio_dev);
-error_disable_reg:
- if (!IS_ERR(reg))
- regulator_disable(reg);
-error_put_reg:
- if (!IS_ERR(reg))
- regulator_put(reg);
-
- iio_free_device(indio_dev);
-error_ret:
- return ret;
-}
-
-static int __devexit ad5504_remove(struct spi_device *spi)
-{
- struct iio_dev *indio_dev = spi_get_drvdata(spi);
- struct ad5504_state *st = iio_priv(indio_dev);
-
- iio_device_unregister(indio_dev);
- if (spi->irq)
- free_irq(spi->irq, indio_dev);
-
- if (!IS_ERR(st->reg)) {
- regulator_disable(st->reg);
- regulator_put(st->reg);
- }
- iio_free_device(indio_dev);
-
- return 0;
-}
-
-static const struct spi_device_id ad5504_id[] = {
- {"ad5504", ID_AD5504},
- {"ad5501", ID_AD5501},
- {}
-};
-MODULE_DEVICE_TABLE(spi, ad5504_id);
-
-static struct spi_driver ad5504_driver = {
- .driver = {
- .name = "ad5504",
- .owner = THIS_MODULE,
- },
- .probe = ad5504_probe,
- .remove = __devexit_p(ad5504_remove),
- .id_table = ad5504_id,
-};
-module_spi_driver(ad5504_driver);
-
-MODULE_AUTHOR("Michael Hennerich <hennerich@blackfin.uclinux.org>");
-MODULE_DESCRIPTION("Analog Devices AD5501/AD5501 DAC");
-MODULE_LICENSE("GPL v2");
diff --git a/drivers/staging/iio/dac/ad5504.h b/drivers/staging/iio/dac/ad5504.h
deleted file mode 100644
index afe09522f53c..000000000000
--- a/drivers/staging/iio/dac/ad5504.h
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * AD5504 SPI DAC driver
- *
- * Copyright 2011 Analog Devices Inc.
- *
- * Licensed under the GPL-2.
- */
-
-#ifndef SPI_AD5504_H_
-#define SPI_AD5504_H_
-
-#define AD5505_BITS 12
-#define AD5504_RES_MASK ((1 << (AD5505_BITS)) - 1)
-
-#define AD5504_CMD_READ (1 << 15)
-#define AD5504_CMD_WRITE (0 << 15)
-#define AD5504_ADDR(addr) ((addr) << 12)
-
-/* Registers */
-#define AD5504_ADDR_NOOP 0
-#define AD5504_ADDR_DAC(x) ((x) + 1)
-#define AD5504_ADDR_ALL_DAC 5
-#define AD5504_ADDR_CTRL 7
-
-/* Control Register */
-#define AD5504_DAC_PWR(ch) ((ch) << 2)
-#define AD5504_DAC_PWRDWN_MODE(mode) ((mode) << 6)
-#define AD5504_DAC_PWRDN_20K 0
-#define AD5504_DAC_PWRDN_3STATE 1
-
-/*
- * TODO: struct ad5504_platform_data needs to go into include/linux/iio
- */
-
-struct ad5504_platform_data {
- u16 vref_mv;
-};
-
-/**
- * struct ad5446_state - driver instance specific data
- * @us: spi_device
- * @reg: supply regulator
- * @vref_mv: actual reference voltage used
- * @pwr_down_mask power down mask
- * @pwr_down_mode current power down mode
- */
-
-struct ad5504_state {
- struct spi_device *spi;
- struct regulator *reg;
- unsigned short vref_mv;
- unsigned pwr_down_mask;
- unsigned pwr_down_mode;
-};
-
-/**
- * ad5504_supported_device_ids:
- */
-
-enum ad5504_supported_device_ids {
- ID_AD5504,
- ID_AD5501,
-};
-
-#endif /* SPI_AD5504_H_ */
diff --git a/drivers/staging/iio/dac/ad5624r.h b/drivers/staging/iio/dac/ad5624r.h
deleted file mode 100644
index 5dca3028cdfd..000000000000
--- a/drivers/staging/iio/dac/ad5624r.h
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * AD5624R SPI DAC driver
- *
- * Copyright 2010-2011 Analog Devices Inc.
- *
- * Licensed under the GPL-2.
- */
-#ifndef SPI_AD5624R_H_
-#define SPI_AD5624R_H_
-
-#define AD5624R_DAC_CHANNELS 4
-
-#define AD5624R_ADDR_DAC0 0x0
-#define AD5624R_ADDR_DAC1 0x1
-#define AD5624R_ADDR_DAC2 0x2
-#define AD5624R_ADDR_DAC3 0x3
-#define AD5624R_ADDR_ALL_DAC 0x7
-
-#define AD5624R_CMD_WRITE_INPUT_N 0x0
-#define AD5624R_CMD_UPDATE_DAC_N 0x1
-#define AD5624R_CMD_WRITE_INPUT_N_UPDATE_ALL 0x2
-#define AD5624R_CMD_WRITE_INPUT_N_UPDATE_N 0x3
-#define AD5624R_CMD_POWERDOWN_DAC 0x4
-#define AD5624R_CMD_RESET 0x5
-#define AD5624R_CMD_LDAC_SETUP 0x6
-#define AD5624R_CMD_INTERNAL_REFER_SETUP 0x7
-
-#define AD5624R_LDAC_PWRDN_NONE 0x0
-#define AD5624R_LDAC_PWRDN_1K 0x1
-#define AD5624R_LDAC_PWRDN_100K 0x2
-#define AD5624R_LDAC_PWRDN_3STATE 0x3
-
-/**
- * struct ad5624r_chip_info - chip specific information
- * @channels: channel spec for the DAC
- * @int_vref_mv: AD5620/40/60: the internal reference voltage
- */
-
-struct ad5624r_chip_info {
- const struct iio_chan_spec *channels;
- u16 int_vref_mv;
-};
-
-/**
- * struct ad5446_state - driver instance specific data
- * @indio_dev: the industrial I/O device
- * @us: spi_device
- * @chip_info: chip model specific constants, available modes etc
- * @reg: supply regulator
- * @vref_mv: actual reference voltage used
- * @pwr_down_mask power down mask
- * @pwr_down_mode current power down mode
- */
-
-struct ad5624r_state {
- struct spi_device *us;
- const struct ad5624r_chip_info *chip_info;
- struct regulator *reg;
- unsigned short vref_mv;
- unsigned pwr_down_mask;
- unsigned pwr_down_mode;
-};
-
-/**
- * ad5624r_supported_device_ids:
- * The AD5624/44/64 parts are available in different
- * fixed internal reference voltage options.
- */
-
-enum ad5624r_supported_device_ids {
- ID_AD5624R3,
- ID_AD5644R3,
- ID_AD5664R3,
- ID_AD5624R5,
- ID_AD5644R5,
- ID_AD5664R5,
-};
-
-#endif /* SPI_AD5624R_H_ */
diff --git a/drivers/staging/iio/dac/ad5624r_spi.c b/drivers/staging/iio/dac/ad5624r_spi.c
deleted file mode 100644
index 10c7484366ef..000000000000
--- a/drivers/staging/iio/dac/ad5624r_spi.c
+++ /dev/null
@@ -1,353 +0,0 @@
-/*
- * AD5624R, AD5644R, AD5664R Digital to analog convertors spi driver
- *
- * Copyright 2010-2011 Analog Devices Inc.
- *
- * Licensed under the GPL-2.
- */
-
-#include <linux/interrupt.h>
-#include <linux/fs.h>
-#include <linux/device.h>
-#include <linux/kernel.h>
-#include <linux/spi/spi.h>
-#include <linux/slab.h>
-#include <linux/sysfs.h>
-#include <linux/regulator/consumer.h>
-#include <linux/module.h>
-
-#include "../iio.h"
-#include "../sysfs.h"
-#include "dac.h"
-#include "ad5624r.h"
-
-#define AD5624R_CHANNEL(_chan, _bits) { \
- .type = IIO_VOLTAGE, \
- .indexed = 1, \
- .output = 1, \
- .channel = (_chan), \
- .info_mask = IIO_CHAN_INFO_SCALE_SHARED_BIT, \
- .address = (_chan), \
- .scan_type = IIO_ST('u', (_bits), 16, 16 - (_bits)), \
-}
-
-#define DECLARE_AD5624R_CHANNELS(_name, _bits) \
- const struct iio_chan_spec _name##_channels[] = { \
- AD5624R_CHANNEL(0, _bits), \
- AD5624R_CHANNEL(1, _bits), \
- AD5624R_CHANNEL(2, _bits), \
- AD5624R_CHANNEL(3, _bits), \
-}
-
-static DECLARE_AD5624R_CHANNELS(ad5624r, 12);
-static DECLARE_AD5624R_CHANNELS(ad5644r, 14);
-static DECLARE_AD5624R_CHANNELS(ad5664r, 16);
-
-static const struct ad5624r_chip_info ad5624r_chip_info_tbl[] = {
- [ID_AD5624R3] = {
- .channels = ad5624r_channels,
- .int_vref_mv = 1250,
- },
- [ID_AD5624R5] = {
- .channels = ad5624r_channels,
- .int_vref_mv = 2500,
- },
- [ID_AD5644R3] = {
- .channels = ad5644r_channels,
- .int_vref_mv = 1250,
- },
- [ID_AD5644R5] = {
- .channels = ad5644r_channels,
- .int_vref_mv = 2500,
- },
- [ID_AD5664R3] = {
- .channels = ad5664r_channels,
- .int_vref_mv = 1250,
- },
- [ID_AD5664R5] = {
- .channels = ad5664r_channels,
- .int_vref_mv = 2500,
- },
-};
-
-static int ad5624r_spi_write(struct spi_device *spi,
- u8 cmd, u8 addr, u16 val, u8 len)
-{
- u32 data;
- u8 msg[3];
-
- /*
- * The input shift register is 24 bits wide. The first two bits are
- * don't care bits. The next three are the command bits, C2 to C0,
- * followed by the 3-bit DAC address, A2 to A0, and then the
- * 16-, 14-, 12-bit data-word. The data-word comprises the 16-,
- * 14-, 12-bit input code followed by 0, 2, or 4 don't care bits,
- * for the AD5664R, AD5644R, and AD5624R, respectively.
- */
- data = (0 << 22) | (cmd << 19) | (addr << 16) | (val << (16 - len));
- msg[0] = data >> 16;
- msg[1] = data >> 8;
- msg[2] = data;
-
- return spi_write(spi, msg, 3);
-}
-
-static int ad5624r_read_raw(struct iio_dev *indio_dev,
- struct iio_chan_spec const *chan,
- int *val,
- int *val2,
- long m)
-{
- struct ad5624r_state *st = iio_priv(indio_dev);
- unsigned long scale_uv;
-
- switch (m) {
- case IIO_CHAN_INFO_SCALE:
- scale_uv = (st->vref_mv * 1000) >> chan->scan_type.realbits;
- *val = scale_uv / 1000;
- *val2 = (scale_uv % 1000) * 1000;
- return IIO_VAL_INT_PLUS_MICRO;
-
- }
- return -EINVAL;
-}
-
-static int ad5624r_write_raw(struct iio_dev *indio_dev,
- struct iio_chan_spec const *chan,
- int val,
- int val2,
- long mask)
-{
- struct ad5624r_state *st = iio_priv(indio_dev);
- int ret;
-
- switch (mask) {
- case 0:
- if (val >= (1 << chan->scan_type.realbits) || val < 0)
- return -EINVAL;
-
- return ad5624r_spi_write(st->us,
- AD5624R_CMD_WRITE_INPUT_N_UPDATE_N,
- chan->address, val,
- chan->scan_type.shift);
- default:
- ret = -EINVAL;
- }
-
- return -EINVAL;
-}
-
-static ssize_t ad5624r_read_powerdown_mode(struct device *dev,
- struct device_attribute *attr, char *buf)
-{
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
- struct ad5624r_state *st = iio_priv(indio_dev);
-
- char mode[][15] = {"", "1kohm_to_gnd", "100kohm_to_gnd", "three_state"};
-
- return sprintf(buf, "%s\n", mode[st->pwr_down_mode]);
-}
-
-static ssize_t ad5624r_write_powerdown_mode(struct device *dev,
- struct device_attribute *attr,
- const char *buf, size_t len)
-{
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
- struct ad5624r_state *st = iio_priv(indio_dev);
- int ret;
-
- if (sysfs_streq(buf, "1kohm_to_gnd"))
- st->pwr_down_mode = AD5624R_LDAC_PWRDN_1K;
- else if (sysfs_streq(buf, "100kohm_to_gnd"))
- st->pwr_down_mode = AD5624R_LDAC_PWRDN_100K;
- else if (sysfs_streq(buf, "three_state"))
- st->pwr_down_mode = AD5624R_LDAC_PWRDN_3STATE;
- else
- ret = -EINVAL;
-
- return ret ? ret : len;
-}
-
-static ssize_t ad5624r_read_dac_powerdown(struct device *dev,
- struct device_attribute *attr,
- char *buf)
-{
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
- struct ad5624r_state *st = iio_priv(indio_dev);
- struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
-
- return sprintf(buf, "%d\n",
- !!(st->pwr_down_mask & (1 << this_attr->address)));
-}
-
-static ssize_t ad5624r_write_dac_powerdown(struct device *dev,
- struct device_attribute *attr,
- const char *buf, size_t len)
-{
- long readin;
- int ret;
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
- struct ad5624r_state *st = iio_priv(indio_dev);
- struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
-
- ret = strict_strtol(buf, 10, &readin);
- if (ret)
- return ret;
-
- if (readin == 1)
- st->pwr_down_mask |= (1 << this_attr->address);
- else if (!readin)
- st->pwr_down_mask &= ~(1 << this_attr->address);
- else
- ret = -EINVAL;
-
- ret = ad5624r_spi_write(st->us, AD5624R_CMD_POWERDOWN_DAC, 0,
- (st->pwr_down_mode << 4) |
- st->pwr_down_mask, 16);
-
- return ret ? ret : len;
-}
-
-static IIO_DEVICE_ATTR(out_voltage_powerdown_mode, S_IRUGO |
- S_IWUSR, ad5624r_read_powerdown_mode,
- ad5624r_write_powerdown_mode, 0);
-
-static IIO_CONST_ATTR(out_voltage_powerdown_mode_available,
- "1kohm_to_gnd 100kohm_to_gnd three_state");
-
-#define IIO_DEV_ATTR_DAC_POWERDOWN(_num, _show, _store, _addr) \
- IIO_DEVICE_ATTR(out_voltage##_num##_powerdown, \
- S_IRUGO | S_IWUSR, _show, _store, _addr)
-
-static IIO_DEV_ATTR_DAC_POWERDOWN(0, ad5624r_read_dac_powerdown,
- ad5624r_write_dac_powerdown, 0);
-static IIO_DEV_ATTR_DAC_POWERDOWN(1, ad5624r_read_dac_powerdown,
- ad5624r_write_dac_powerdown, 1);
-static IIO_DEV_ATTR_DAC_POWERDOWN(2, ad5624r_read_dac_powerdown,
- ad5624r_write_dac_powerdown, 2);
-static IIO_DEV_ATTR_DAC_POWERDOWN(3, ad5624r_read_dac_powerdown,
- ad5624r_write_dac_powerdown, 3);
-
-static struct attribute *ad5624r_attributes[] = {
- &iio_dev_attr_out_voltage0_powerdown.dev_attr.attr,
- &iio_dev_attr_out_voltage1_powerdown.dev_attr.attr,
- &iio_dev_attr_out_voltage2_powerdown.dev_attr.attr,
- &iio_dev_attr_out_voltage3_powerdown.dev_attr.attr,
- &iio_dev_attr_out_voltage_powerdown_mode.dev_attr.attr,
- &iio_const_attr_out_voltage_powerdown_mode_available.dev_attr.attr,
- NULL,
-};
-
-static const struct attribute_group ad5624r_attribute_group = {
- .attrs = ad5624r_attributes,
-};
-
-static const struct iio_info ad5624r_info = {
- .write_raw = ad5624r_write_raw,
- .read_raw = ad5624r_read_raw,
- .attrs = &ad5624r_attribute_group,
- .driver_module = THIS_MODULE,
-};
-
-static int __devinit ad5624r_probe(struct spi_device *spi)
-{
- struct ad5624r_state *st;
- struct iio_dev *indio_dev;
- int ret, voltage_uv = 0;
-
- indio_dev = iio_allocate_device(sizeof(*st));
- if (indio_dev == NULL) {
- ret = -ENOMEM;
- goto error_ret;
- }
- st = iio_priv(indio_dev);
- st->reg = regulator_get(&spi->dev, "vcc");
- if (!IS_ERR(st->reg)) {
- ret = regulator_enable(st->reg);
- if (ret)
- goto error_put_reg;
-
- voltage_uv = regulator_get_voltage(st->reg);
- }
-
- spi_set_drvdata(spi, indio_dev);
- st->chip_info =
- &ad5624r_chip_info_tbl[spi_get_device_id(spi)->driver_data];
-
- if (voltage_uv)
- st->vref_mv = voltage_uv / 1000;
- else
- st->vref_mv = st->chip_info->int_vref_mv;
-
- st->us = spi;
-
- indio_dev->dev.parent = &spi->dev;
- indio_dev->name = spi_get_device_id(spi)->name;
- indio_dev->info = &ad5624r_info;
- indio_dev->modes = INDIO_DIRECT_MODE;
- indio_dev->channels = st->chip_info->channels;
- indio_dev->num_channels = AD5624R_DAC_CHANNELS;
-
- ret = ad5624r_spi_write(spi, AD5624R_CMD_INTERNAL_REFER_SETUP, 0,
- !!voltage_uv, 16);
- if (ret)
- goto error_disable_reg;
-
- ret = iio_device_register(indio_dev);
- if (ret)
- goto error_disable_reg;
-
- return 0;
-
-error_disable_reg:
- if (!IS_ERR(st->reg))
- regulator_disable(st->reg);
-error_put_reg:
- if (!IS_ERR(st->reg))
- regulator_put(st->reg);
- iio_free_device(indio_dev);
-error_ret:
-
- return ret;
-}
-
-static int __devexit ad5624r_remove(struct spi_device *spi)
-{
- struct iio_dev *indio_dev = spi_get_drvdata(spi);
- struct ad5624r_state *st = iio_priv(indio_dev);
-
- iio_device_unregister(indio_dev);
- if (!IS_ERR(st->reg)) {
- regulator_disable(st->reg);
- regulator_put(st->reg);
- }
- iio_free_device(indio_dev);
-
- return 0;
-}
-
-static const struct spi_device_id ad5624r_id[] = {
- {"ad5624r3", ID_AD5624R3},
- {"ad5644r3", ID_AD5644R3},
- {"ad5664r3", ID_AD5664R3},
- {"ad5624r5", ID_AD5624R5},
- {"ad5644r5", ID_AD5644R5},
- {"ad5664r5", ID_AD5664R5},
- {}
-};
-MODULE_DEVICE_TABLE(spi, ad5624r_id);
-
-static struct spi_driver ad5624r_driver = {
- .driver = {
- .name = "ad5624r",
- .owner = THIS_MODULE,
- },
- .probe = ad5624r_probe,
- .remove = __devexit_p(ad5624r_remove),
- .id_table = ad5624r_id,
-};
-module_spi_driver(ad5624r_driver);
-
-MODULE_AUTHOR("Barry Song <21cnbao@gmail.com>");
-MODULE_DESCRIPTION("Analog Devices AD5624/44/64R DAC spi driver");
-MODULE_LICENSE("GPL v2");
diff --git a/drivers/staging/iio/dac/ad5686.c b/drivers/staging/iio/dac/ad5686.c
deleted file mode 100644
index 2415a6e60c77..000000000000
--- a/drivers/staging/iio/dac/ad5686.c
+++ /dev/null
@@ -1,454 +0,0 @@
-/*
- * AD5686R, AD5685R, AD5684R Digital to analog converters driver
- *
- * Copyright 2011 Analog Devices Inc.
- *
- * Licensed under the GPL-2.
- */
-
-#include <linux/interrupt.h>
-#include <linux/fs.h>
-#include <linux/device.h>
-#include <linux/module.h>
-#include <linux/kernel.h>
-#include <linux/spi/spi.h>
-#include <linux/slab.h>
-#include <linux/sysfs.h>
-#include <linux/regulator/consumer.h>
-
-#include "../iio.h"
-#include "../sysfs.h"
-#include "dac.h"
-
-#define AD5686_DAC_CHANNELS 4
-
-#define AD5686_ADDR(x) ((x) << 16)
-#define AD5686_CMD(x) ((x) << 20)
-
-#define AD5686_ADDR_DAC(chan) (0x1 << (chan))
-#define AD5686_ADDR_ALL_DAC 0xF
-
-#define AD5686_CMD_NOOP 0x0
-#define AD5686_CMD_WRITE_INPUT_N 0x1
-#define AD5686_CMD_UPDATE_DAC_N 0x2
-#define AD5686_CMD_WRITE_INPUT_N_UPDATE_N 0x3
-#define AD5686_CMD_POWERDOWN_DAC 0x4
-#define AD5686_CMD_LDAC_MASK 0x5
-#define AD5686_CMD_RESET 0x6
-#define AD5686_CMD_INTERNAL_REFER_SETUP 0x7
-#define AD5686_CMD_DAISY_CHAIN_ENABLE 0x8
-#define AD5686_CMD_READBACK_ENABLE 0x9
-
-#define AD5686_LDAC_PWRDN_NONE 0x0
-#define AD5686_LDAC_PWRDN_1K 0x1
-#define AD5686_LDAC_PWRDN_100K 0x2
-#define AD5686_LDAC_PWRDN_3STATE 0x3
-
-/**
- * struct ad5686_chip_info - chip specific information
- * @int_vref_mv: AD5620/40/60: the internal reference voltage
- * @channel: channel specification
-*/
-
-struct ad5686_chip_info {
- u16 int_vref_mv;
- struct iio_chan_spec channel[AD5686_DAC_CHANNELS];
-};
-
-/**
- * struct ad5446_state - driver instance specific data
- * @spi: spi_device
- * @chip_info: chip model specific constants, available modes etc
- * @reg: supply regulator
- * @vref_mv: actual reference voltage used
- * @pwr_down_mask: power down mask
- * @pwr_down_mode: current power down mode
- * @data: spi transfer buffers
- */
-
-struct ad5686_state {
- struct spi_device *spi;
- const struct ad5686_chip_info *chip_info;
- struct regulator *reg;
- unsigned short vref_mv;
- unsigned pwr_down_mask;
- unsigned pwr_down_mode;
- /*
- * DMA (thus cache coherency maintenance) requires the
- * transfer buffers to live in their own cache lines.
- */
-
- union {
- u32 d32;
- u8 d8[4];
- } data[3] ____cacheline_aligned;
-};
-
-/**
- * ad5686_supported_device_ids:
- */
-
-enum ad5686_supported_device_ids {
- ID_AD5684,
- ID_AD5685,
- ID_AD5686,
-};
-#define AD5868_CHANNEL(chan, bits, shift) { \
- .type = IIO_VOLTAGE, \
- .indexed = 1, \
- .output = 1, \
- .channel = chan, \
- .info_mask = IIO_CHAN_INFO_SCALE_SHARED_BIT, \
- .address = AD5686_ADDR_DAC(chan), \
- .scan_type = IIO_ST('u', bits, 16, shift) \
-}
-static const struct ad5686_chip_info ad5686_chip_info_tbl[] = {
- [ID_AD5684] = {
- .channel[0] = AD5868_CHANNEL(0, 12, 4),
- .channel[1] = AD5868_CHANNEL(1, 12, 4),
- .channel[2] = AD5868_CHANNEL(2, 12, 4),
- .channel[3] = AD5868_CHANNEL(3, 12, 4),
- .int_vref_mv = 2500,
- },
- [ID_AD5685] = {
- .channel[0] = AD5868_CHANNEL(0, 14, 2),
- .channel[1] = AD5868_CHANNEL(1, 14, 2),
- .channel[2] = AD5868_CHANNEL(2, 14, 2),
- .channel[3] = AD5868_CHANNEL(3, 14, 2),
- .int_vref_mv = 2500,
- },
- [ID_AD5686] = {
- .channel[0] = AD5868_CHANNEL(0, 16, 0),
- .channel[1] = AD5868_CHANNEL(1, 16, 0),
- .channel[2] = AD5868_CHANNEL(2, 16, 0),
- .channel[3] = AD5868_CHANNEL(3, 16, 0),
- .int_vref_mv = 2500,
- },
-};
-
-static int ad5686_spi_write(struct ad5686_state *st,
- u8 cmd, u8 addr, u16 val, u8 shift)
-{
- val <<= shift;
-
- st->data[0].d32 = cpu_to_be32(AD5686_CMD(cmd) |
- AD5686_ADDR(addr) |
- val);
-
- return spi_write(st->spi, &st->data[0].d8[1], 3);
-}
-
-static int ad5686_spi_read(struct ad5686_state *st, u8 addr)
-{
- struct spi_transfer t[] = {
- {
- .tx_buf = &st->data[0].d8[1],
- .len = 3,
- .cs_change = 1,
- }, {
- .tx_buf = &st->data[1].d8[1],
- .rx_buf = &st->data[2].d8[1],
- .len = 3,
- },
- };
- struct spi_message m;
- int ret;
-
- spi_message_init(&m);
- spi_message_add_tail(&t[0], &m);
- spi_message_add_tail(&t[1], &m);
-
- st->data[0].d32 = cpu_to_be32(AD5686_CMD(AD5686_CMD_READBACK_ENABLE) |
- AD5686_ADDR(addr));
- st->data[1].d32 = cpu_to_be32(AD5686_CMD(AD5686_CMD_NOOP));
-
- ret = spi_sync(st->spi, &m);
- if (ret < 0)
- return ret;
-
- return be32_to_cpu(st->data[2].d32);
-}
-
-static ssize_t ad5686_read_powerdown_mode(struct device *dev,
- struct device_attribute *attr, char *buf)
-{
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
- struct ad5686_state *st = iio_priv(indio_dev);
- struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
-
- char mode[][15] = {"", "1kohm_to_gnd", "100kohm_to_gnd", "three_state"};
-
- return sprintf(buf, "%s\n", mode[(st->pwr_down_mode >>
- (this_attr->address * 2)) & 0x3]);
-}
-
-static ssize_t ad5686_write_powerdown_mode(struct device *dev,
- struct device_attribute *attr,
- const char *buf, size_t len)
-{
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
- struct ad5686_state *st = iio_priv(indio_dev);
- struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
- unsigned mode;
-
- if (sysfs_streq(buf, "1kohm_to_gnd"))
- mode = AD5686_LDAC_PWRDN_1K;
- else if (sysfs_streq(buf, "100kohm_to_gnd"))
- mode = AD5686_LDAC_PWRDN_100K;
- else if (sysfs_streq(buf, "three_state"))
- mode = AD5686_LDAC_PWRDN_3STATE;
- else
- return -EINVAL;
-
- st->pwr_down_mode &= ~(0x3 << (this_attr->address * 2));
- st->pwr_down_mode |= (mode << (this_attr->address * 2));
-
- return len;
-}
-
-static ssize_t ad5686_read_dac_powerdown(struct device *dev,
- struct device_attribute *attr,
- char *buf)
-{
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
- struct ad5686_state *st = iio_priv(indio_dev);
- struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
-
- return sprintf(buf, "%d\n", !!(st->pwr_down_mask &
- (0x3 << (this_attr->address * 2))));
-}
-
-static ssize_t ad5686_write_dac_powerdown(struct device *dev,
- struct device_attribute *attr,
- const char *buf, size_t len)
-{
- bool readin;
- int ret;
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
- struct ad5686_state *st = iio_priv(indio_dev);
- struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
-
- ret = strtobool(buf, &readin);
- if (ret)
- return ret;
-
- if (readin == true)
- st->pwr_down_mask |= (0x3 << (this_attr->address * 2));
- else
- st->pwr_down_mask &= ~(0x3 << (this_attr->address * 2));
-
- ret = ad5686_spi_write(st, AD5686_CMD_POWERDOWN_DAC, 0,
- st->pwr_down_mask & st->pwr_down_mode, 0);
-
- return ret ? ret : len;
-}
-
-static IIO_CONST_ATTR(out_voltage_powerdown_mode_available,
- "1kohm_to_gnd 100kohm_to_gnd three_state");
-
-#define IIO_DEV_ATTR_DAC_POWERDOWN_MODE(_num) \
- IIO_DEVICE_ATTR(out_voltage##_num##_powerdown_mode, \
- S_IRUGO | S_IWUSR, \
- ad5686_read_powerdown_mode, \
- ad5686_write_powerdown_mode, _num)
-
-static IIO_DEV_ATTR_DAC_POWERDOWN_MODE(0);
-static IIO_DEV_ATTR_DAC_POWERDOWN_MODE(1);
-static IIO_DEV_ATTR_DAC_POWERDOWN_MODE(2);
-static IIO_DEV_ATTR_DAC_POWERDOWN_MODE(3);
-
-#define IIO_DEV_ATTR_DAC_POWERDOWN(_num) \
- IIO_DEVICE_ATTR(out_voltage##_num##_powerdown, \
- S_IRUGO | S_IWUSR, \
- ad5686_read_dac_powerdown, \
- ad5686_write_dac_powerdown, _num)
-
-static IIO_DEV_ATTR_DAC_POWERDOWN(0);
-static IIO_DEV_ATTR_DAC_POWERDOWN(1);
-static IIO_DEV_ATTR_DAC_POWERDOWN(2);
-static IIO_DEV_ATTR_DAC_POWERDOWN(3);
-
-static struct attribute *ad5686_attributes[] = {
- &iio_dev_attr_out_voltage0_powerdown.dev_attr.attr,
- &iio_dev_attr_out_voltage1_powerdown.dev_attr.attr,
- &iio_dev_attr_out_voltage2_powerdown.dev_attr.attr,
- &iio_dev_attr_out_voltage3_powerdown.dev_attr.attr,
- &iio_dev_attr_out_voltage0_powerdown_mode.dev_attr.attr,
- &iio_dev_attr_out_voltage1_powerdown_mode.dev_attr.attr,
- &iio_dev_attr_out_voltage2_powerdown_mode.dev_attr.attr,
- &iio_dev_attr_out_voltage3_powerdown_mode.dev_attr.attr,
- &iio_const_attr_out_voltage_powerdown_mode_available.dev_attr.attr,
- NULL,
-};
-
-static const struct attribute_group ad5686_attribute_group = {
- .attrs = ad5686_attributes,
-};
-
-static int ad5686_read_raw(struct iio_dev *indio_dev,
- struct iio_chan_spec const *chan,
- int *val,
- int *val2,
- long m)
-{
- struct ad5686_state *st = iio_priv(indio_dev);
- unsigned long scale_uv;
- int ret;
-
- switch (m) {
- case 0:
- mutex_lock(&indio_dev->mlock);
- ret = ad5686_spi_read(st, chan->address);
- mutex_unlock(&indio_dev->mlock);
- if (ret < 0)
- return ret;
- *val = ret;
- return IIO_VAL_INT;
- break;
- case IIO_CHAN_INFO_SCALE:
- scale_uv = (st->vref_mv * 100000)
- >> (chan->scan_type.realbits);
- *val = scale_uv / 100000;
- *val2 = (scale_uv % 100000) * 10;
- return IIO_VAL_INT_PLUS_MICRO;
-
- }
- return -EINVAL;
-}
-
-static int ad5686_write_raw(struct iio_dev *indio_dev,
- struct iio_chan_spec const *chan,
- int val,
- int val2,
- long mask)
-{
- struct ad5686_state *st = iio_priv(indio_dev);
- int ret;
-
- switch (mask) {
- case 0:
- if (val > (1 << chan->scan_type.realbits) || val < 0)
- return -EINVAL;
-
- mutex_lock(&indio_dev->mlock);
- ret = ad5686_spi_write(st,
- AD5686_CMD_WRITE_INPUT_N_UPDATE_N,
- chan->address,
- val,
- chan->scan_type.shift);
- mutex_unlock(&indio_dev->mlock);
- break;
- default:
- ret = -EINVAL;
- }
-
- return ret;
-}
-
-static const struct iio_info ad5686_info = {
- .read_raw = ad5686_read_raw,
- .write_raw = ad5686_write_raw,
- .attrs = &ad5686_attribute_group,
- .driver_module = THIS_MODULE,
-};
-
-static int __devinit ad5686_probe(struct spi_device *spi)
-{
- struct ad5686_state *st;
- struct iio_dev *indio_dev;
- int ret, regdone = 0, voltage_uv = 0;
-
- indio_dev = iio_allocate_device(sizeof(*st));
- if (indio_dev == NULL)
- return -ENOMEM;
-
- st = iio_priv(indio_dev);
- spi_set_drvdata(spi, indio_dev);
-
- st->reg = regulator_get(&spi->dev, "vcc");
- if (!IS_ERR(st->reg)) {
- ret = regulator_enable(st->reg);
- if (ret)
- goto error_put_reg;
-
- voltage_uv = regulator_get_voltage(st->reg);
- }
-
- st->chip_info =
- &ad5686_chip_info_tbl[spi_get_device_id(spi)->driver_data];
-
- if (voltage_uv)
- st->vref_mv = voltage_uv / 1000;
- else
- st->vref_mv = st->chip_info->int_vref_mv;
-
- st->spi = spi;
-
- indio_dev->dev.parent = &spi->dev;
- indio_dev->name = spi_get_device_id(spi)->name;
- indio_dev->info = &ad5686_info;
- indio_dev->modes = INDIO_DIRECT_MODE;
- indio_dev->channels = st->chip_info->channel;
- indio_dev->num_channels = AD5686_DAC_CHANNELS;
-
- regdone = 1;
- ret = ad5686_spi_write(st, AD5686_CMD_INTERNAL_REFER_SETUP, 0,
- !!voltage_uv, 0);
- if (ret)
- goto error_disable_reg;
-
- ret = iio_device_register(indio_dev);
- if (ret)
- goto error_disable_reg;
-
- return 0;
-
-error_disable_reg:
- if (!IS_ERR(st->reg))
- regulator_disable(st->reg);
-error_put_reg:
- if (!IS_ERR(st->reg))
- regulator_put(st->reg);
-
- iio_free_device(indio_dev);
-
- return ret;
-}
-
-static int __devexit ad5686_remove(struct spi_device *spi)
-{
- struct iio_dev *indio_dev = spi_get_drvdata(spi);
- struct ad5686_state *st = iio_priv(indio_dev);
-
- iio_device_unregister(indio_dev);
- if (!IS_ERR(st->reg)) {
- regulator_disable(st->reg);
- regulator_put(st->reg);
- }
- iio_free_device(indio_dev);
-
- return 0;
-}
-
-static const struct spi_device_id ad5686_id[] = {
- {"ad5684", ID_AD5684},
- {"ad5685", ID_AD5685},
- {"ad5686", ID_AD5686},
- {}
-};
-MODULE_DEVICE_TABLE(spi, ad5686_id);
-
-static struct spi_driver ad5686_driver = {
- .driver = {
- .name = "ad5686",
- .owner = THIS_MODULE,
- },
- .probe = ad5686_probe,
- .remove = __devexit_p(ad5686_remove),
- .id_table = ad5686_id,
-};
-module_spi_driver(ad5686_driver);
-
-MODULE_AUTHOR("Michael Hennerich <hennerich@blackfin.uclinux.org>");
-MODULE_DESCRIPTION("Analog Devices AD5686/85/84 DAC");
-MODULE_LICENSE("GPL v2");
diff --git a/drivers/staging/iio/dac/ad5764.c b/drivers/staging/iio/dac/ad5764.c
deleted file mode 100644
index f73a73079490..000000000000
--- a/drivers/staging/iio/dac/ad5764.c
+++ /dev/null
@@ -1,382 +0,0 @@
-/*
- * Analog devices AD5764, AD5764R, AD5744, AD5744R quad-channel
- * Digital to Analog Converters driver
- *
- * Copyright 2011 Analog Devices Inc.
- *
- * Licensed under the GPL-2.
- */
-
-#include <linux/device.h>
-#include <linux/err.h>
-#include <linux/module.h>
-#include <linux/kernel.h>
-#include <linux/spi/spi.h>
-#include <linux/slab.h>
-#include <linux/sysfs.h>
-#include <linux/regulator/consumer.h>
-
-#include "../iio.h"
-#include "../sysfs.h"
-#include "dac.h"
-
-#define AD5764_REG_SF_NOP 0x0
-#define AD5764_REG_SF_CONFIG 0x1
-#define AD5764_REG_SF_CLEAR 0x4
-#define AD5764_REG_SF_LOAD 0x5
-#define AD5764_REG_DATA(x) ((2 << 3) | (x))
-#define AD5764_REG_COARSE_GAIN(x) ((3 << 3) | (x))
-#define AD5764_REG_FINE_GAIN(x) ((4 << 3) | (x))
-#define AD5764_REG_OFFSET(x) ((5 << 3) | (x))
-
-#define AD5764_NUM_CHANNELS 4
-
-/**
- * struct ad5764_chip_info - chip specific information
- * @int_vref: Value of the internal reference voltage in uV - 0 if external
- * reference voltage is used
- * @channel channel specification
-*/
-
-struct ad5764_chip_info {
- unsigned long int_vref;
- const struct iio_chan_spec *channels;
-};
-
-/**
- * struct ad5764_state - driver instance specific data
- * @spi: spi_device
- * @chip_info: chip info
- * @vref_reg: vref supply regulators
- * @data: spi transfer buffers
- */
-
-struct ad5764_state {
- struct spi_device *spi;
- const struct ad5764_chip_info *chip_info;
- struct regulator_bulk_data vref_reg[2];
-
- /*
- * DMA (thus cache coherency maintenance) requires the
- * transfer buffers to live in their own cache lines.
- */
- union {
- __be32 d32;
- u8 d8[4];
- } data[2] ____cacheline_aligned;
-};
-
-enum ad5764_type {
- ID_AD5744,
- ID_AD5744R,
- ID_AD5764,
- ID_AD5764R,
-};
-
-#define AD5764_CHANNEL(_chan, _bits) { \
- .type = IIO_VOLTAGE, \
- .indexed = 1, \
- .output = 1, \
- .channel = (_chan), \
- .address = (_chan), \
- .info_mask = IIO_CHAN_INFO_OFFSET_SHARED_BIT | \
- IIO_CHAN_INFO_SCALE_SEPARATE_BIT | \
- IIO_CHAN_INFO_CALIBSCALE_SEPARATE_BIT | \
- IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT, \
- .scan_type = IIO_ST('u', (_bits), 16, 16 - (_bits)) \
-}
-
-#define DECLARE_AD5764_CHANNELS(_name, _bits) \
-const struct iio_chan_spec _name##_channels[] = { \
- AD5764_CHANNEL(0, (_bits)), \
- AD5764_CHANNEL(1, (_bits)), \
- AD5764_CHANNEL(2, (_bits)), \
- AD5764_CHANNEL(3, (_bits)), \
-};
-
-static DECLARE_AD5764_CHANNELS(ad5764, 16);
-static DECLARE_AD5764_CHANNELS(ad5744, 14);
-
-static const struct ad5764_chip_info ad5764_chip_infos[] = {
- [ID_AD5744] = {
- .int_vref = 0,
- .channels = ad5744_channels,
- },
- [ID_AD5744R] = {
- .int_vref = 5000000,
- .channels = ad5744_channels,
- },
- [ID_AD5764] = {
- .int_vref = 0,
- .channels = ad5764_channels,
- },
- [ID_AD5764R] = {
- .int_vref = 5000000,
- .channels = ad5764_channels,
- },
-};
-
-static int ad5764_write(struct iio_dev *indio_dev, unsigned int reg,
- unsigned int val)
-{
- struct ad5764_state *st = iio_priv(indio_dev);
- int ret;
-
- mutex_lock(&indio_dev->mlock);
- st->data[0].d32 = cpu_to_be32((reg << 16) | val);
-
- ret = spi_write(st->spi, &st->data[0].d8[1], 3);
- mutex_unlock(&indio_dev->mlock);
-
- return ret;
-}
-
-static int ad5764_read(struct iio_dev *indio_dev, unsigned int reg,
- unsigned int *val)
-{
- struct ad5764_state *st = iio_priv(indio_dev);
- struct spi_message m;
- int ret;
- struct spi_transfer t[] = {
- {
- .tx_buf = &st->data[0].d8[1],
- .len = 3,
- .cs_change = 1,
- }, {
- .rx_buf = &st->data[1].d8[1],
- .len = 3,
- },
- };
-
- spi_message_init(&m);
- spi_message_add_tail(&t[0], &m);
- spi_message_add_tail(&t[1], &m);
-
- mutex_lock(&indio_dev->mlock);
-
- st->data[0].d32 = cpu_to_be32((1 << 23) | (reg << 16));
-
- ret = spi_sync(st->spi, &m);
- if (ret >= 0)
- *val = be32_to_cpu(st->data[1].d32) & 0xffff;
-
- mutex_unlock(&indio_dev->mlock);
-
- return ret;
-}
-
-static int ad5764_chan_info_to_reg(struct iio_chan_spec const *chan, long info)
-{
- switch (info) {
- case 0:
- return AD5764_REG_DATA(chan->address);
- case IIO_CHAN_INFO_CALIBBIAS:
- return AD5764_REG_OFFSET(chan->address);
- case IIO_CHAN_INFO_CALIBSCALE:
- return AD5764_REG_FINE_GAIN(chan->address);
- default:
- break;
- }
-
- return 0;
-}
-
-static int ad5764_write_raw(struct iio_dev *indio_dev,
- struct iio_chan_spec const *chan, int val, int val2, long info)
-{
- const int max_val = (1 << chan->scan_type.realbits);
- unsigned int reg;
-
- switch (info) {
- case 0:
- if (val >= max_val || val < 0)
- return -EINVAL;
- val <<= chan->scan_type.shift;
- break;
- case IIO_CHAN_INFO_CALIBBIAS:
- if (val >= 128 || val < -128)
- return -EINVAL;
- break;
- case IIO_CHAN_INFO_CALIBSCALE:
- if (val >= 32 || val < -32)
- return -EINVAL;
- break;
- default:
- return -EINVAL;
- }
-
- reg = ad5764_chan_info_to_reg(chan, info);
- return ad5764_write(indio_dev, reg, (u16)val);
-}
-
-static int ad5764_get_channel_vref(struct ad5764_state *st,
- unsigned int channel)
-{
- if (st->chip_info->int_vref)
- return st->chip_info->int_vref;
- else
- return regulator_get_voltage(st->vref_reg[channel / 2].consumer);
-}
-
-static int ad5764_read_raw(struct iio_dev *indio_dev,
- struct iio_chan_spec const *chan, int *val, int *val2, long info)
-{
- struct ad5764_state *st = iio_priv(indio_dev);
- unsigned long scale_uv;
- unsigned int reg;
- int vref;
- int ret;
-
- switch (info) {
- case 0:
- reg = AD5764_REG_DATA(chan->address);
- ret = ad5764_read(indio_dev, reg, val);
- if (ret < 0)
- return ret;
- *val >>= chan->scan_type.shift;
- return IIO_VAL_INT;
- case IIO_CHAN_INFO_CALIBBIAS:
- reg = AD5764_REG_OFFSET(chan->address);
- ret = ad5764_read(indio_dev, reg, val);
- if (ret < 0)
- return ret;
- *val = sign_extend32(*val, 7);
- return IIO_VAL_INT;
- case IIO_CHAN_INFO_CALIBSCALE:
- reg = AD5764_REG_FINE_GAIN(chan->address);
- ret = ad5764_read(indio_dev, reg, val);
- if (ret < 0)
- return ret;
- *val = sign_extend32(*val, 5);
- return IIO_VAL_INT;
- case IIO_CHAN_INFO_SCALE:
- /* vout = 4 * vref + ((dac_code / 65535) - 0.5) */
- vref = ad5764_get_channel_vref(st, chan->channel);
- if (vref < 0)
- return vref;
-
- scale_uv = (vref * 4 * 100) >> chan->scan_type.realbits;
- *val = scale_uv / 100000;
- *val2 = (scale_uv % 100000) * 10;
- return IIO_VAL_INT_PLUS_MICRO;
- case IIO_CHAN_INFO_OFFSET:
- *val = -(1 << chan->scan_type.realbits) / 2;
- return IIO_VAL_INT;
- }
-
- return -EINVAL;
-}
-
-static const struct iio_info ad5764_info = {
- .read_raw = ad5764_read_raw,
- .write_raw = ad5764_write_raw,
- .driver_module = THIS_MODULE,
-};
-
-static int __devinit ad5764_probe(struct spi_device *spi)
-{
- enum ad5764_type type = spi_get_device_id(spi)->driver_data;
- struct iio_dev *indio_dev;
- struct ad5764_state *st;
- int ret;
-
- indio_dev = iio_allocate_device(sizeof(*st));
- if (indio_dev == NULL) {
- dev_err(&spi->dev, "Failed to allocate iio device\n");
- return -ENOMEM;
- }
-
- st = iio_priv(indio_dev);
- spi_set_drvdata(spi, indio_dev);
-
- st->spi = spi;
- st->chip_info = &ad5764_chip_infos[type];
-
- indio_dev->dev.parent = &spi->dev;
- indio_dev->name = spi_get_device_id(spi)->name;
- indio_dev->info = &ad5764_info;
- indio_dev->modes = INDIO_DIRECT_MODE;
- indio_dev->num_channels = AD5764_NUM_CHANNELS;
- indio_dev->channels = st->chip_info->channels;
-
- if (st->chip_info->int_vref == 0) {
- st->vref_reg[0].supply = "vrefAB";
- st->vref_reg[1].supply = "vrefCD";
-
- ret = regulator_bulk_get(&st->spi->dev,
- ARRAY_SIZE(st->vref_reg), st->vref_reg);
- if (ret) {
- dev_err(&spi->dev, "Failed to request vref regulators: %d\n",
- ret);
- goto error_free;
- }
-
- ret = regulator_bulk_enable(ARRAY_SIZE(st->vref_reg),
- st->vref_reg);
- if (ret) {
- dev_err(&spi->dev, "Failed to enable vref regulators: %d\n",
- ret);
- goto error_free_reg;
- }
- }
-
- ret = iio_device_register(indio_dev);
- if (ret) {
- dev_err(&spi->dev, "Failed to register iio device: %d\n", ret);
- goto error_disable_reg;
- }
-
- return 0;
-
-error_disable_reg:
- if (st->chip_info->int_vref == 0)
- regulator_bulk_disable(ARRAY_SIZE(st->vref_reg), st->vref_reg);
-error_free_reg:
- if (st->chip_info->int_vref == 0)
- regulator_bulk_free(ARRAY_SIZE(st->vref_reg), st->vref_reg);
-error_free:
- iio_free_device(indio_dev);
-
- return ret;
-}
-
-static int __devexit ad5764_remove(struct spi_device *spi)
-{
- struct iio_dev *indio_dev = spi_get_drvdata(spi);
- struct ad5764_state *st = iio_priv(indio_dev);
-
- iio_device_unregister(indio_dev);
-
- if (st->chip_info->int_vref == 0) {
- regulator_bulk_disable(ARRAY_SIZE(st->vref_reg), st->vref_reg);
- regulator_bulk_free(ARRAY_SIZE(st->vref_reg), st->vref_reg);
- }
-
- iio_free_device(indio_dev);
-
- return 0;
-}
-
-static const struct spi_device_id ad5764_ids[] = {
- { "ad5744", ID_AD5744 },
- { "ad5744r", ID_AD5744R },
- { "ad5764", ID_AD5764 },
- { "ad5764r", ID_AD5764R },
- { }
-};
-MODULE_DEVICE_TABLE(spi, ad5764_ids);
-
-static struct spi_driver ad5764_driver = {
- .driver = {
- .name = "ad5764",
- .owner = THIS_MODULE,
- },
- .probe = ad5764_probe,
- .remove = __devexit_p(ad5764_remove),
- .id_table = ad5764_ids,
-};
-module_spi_driver(ad5764_driver);
-
-MODULE_AUTHOR("Lars-Peter Clausen <lars@metafoo.de>");
-MODULE_DESCRIPTION("Analog Devices AD5744/AD5744R/AD5764/AD5764R DAC");
-MODULE_LICENSE("GPL v2");
diff --git a/drivers/staging/iio/dac/ad5791.c b/drivers/staging/iio/dac/ad5791.c
deleted file mode 100644
index ac45636a8d72..000000000000
--- a/drivers/staging/iio/dac/ad5791.c
+++ /dev/null
@@ -1,420 +0,0 @@
-/*
- * AD5760, AD5780, AD5781, AD5790, AD5791 Voltage Output Digital to Analog
- * Converter
- *
- * Copyright 2011 Analog Devices Inc.
- *
- * Licensed under the GPL-2.
- */
-
-#include <linux/interrupt.h>
-#include <linux/fs.h>
-#include <linux/device.h>
-#include <linux/kernel.h>
-#include <linux/spi/spi.h>
-#include <linux/slab.h>
-#include <linux/sysfs.h>
-#include <linux/regulator/consumer.h>
-#include <linux/module.h>
-
-#include "../iio.h"
-#include "../sysfs.h"
-#include "dac.h"
-#include "ad5791.h"
-
-static int ad5791_spi_write(struct spi_device *spi, u8 addr, u32 val)
-{
- union {
- u32 d32;
- u8 d8[4];
- } data;
-
- data.d32 = cpu_to_be32(AD5791_CMD_WRITE |
- AD5791_ADDR(addr) |
- (val & AD5791_DAC_MASK));
-
- return spi_write(spi, &data.d8[1], 3);
-}
-
-static int ad5791_spi_read(struct spi_device *spi, u8 addr, u32 *val)
-{
- union {
- u32 d32;
- u8 d8[4];
- } data[3];
- int ret;
- struct spi_message msg;
- struct spi_transfer xfers[] = {
- {
- .tx_buf = &data[0].d8[1],
- .bits_per_word = 8,
- .len = 3,
- .cs_change = 1,
- }, {
- .tx_buf = &data[1].d8[1],
- .rx_buf = &data[2].d8[1],
- .bits_per_word = 8,
- .len = 3,
- },
- };
-
- data[0].d32 = cpu_to_be32(AD5791_CMD_READ |
- AD5791_ADDR(addr));
- data[1].d32 = cpu_to_be32(AD5791_ADDR(AD5791_ADDR_NOOP));
-
- spi_message_init(&msg);
- spi_message_add_tail(&xfers[0], &msg);
- spi_message_add_tail(&xfers[1], &msg);
- ret = spi_sync(spi, &msg);
-
- *val = be32_to_cpu(data[2].d32);
-
- return ret;
-}
-
-#define AD5791_CHAN(bits, shift) { \
- .type = IIO_VOLTAGE, \
- .output = 1, \
- .indexed = 1, \
- .address = AD5791_ADDR_DAC0, \
- .channel = 0, \
- .info_mask = IIO_CHAN_INFO_SCALE_SHARED_BIT | \
- IIO_CHAN_INFO_OFFSET_SHARED_BIT, \
- .scan_type = IIO_ST('u', bits, 24, shift) \
-}
-
-static const struct iio_chan_spec ad5791_channels[] = {
- [ID_AD5760] = AD5791_CHAN(16, 4),
- [ID_AD5780] = AD5791_CHAN(18, 2),
- [ID_AD5781] = AD5791_CHAN(18, 2),
- [ID_AD5791] = AD5791_CHAN(20, 0)
-};
-
-static ssize_t ad5791_read_powerdown_mode(struct device *dev,
- struct device_attribute *attr, char *buf)
-{
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
- struct ad5791_state *st = iio_priv(indio_dev);
-
- const char mode[][14] = {"6kohm_to_gnd", "three_state"};
-
- return sprintf(buf, "%s\n", mode[st->pwr_down_mode]);
-}
-
-static ssize_t ad5791_write_powerdown_mode(struct device *dev,
- struct device_attribute *attr,
- const char *buf, size_t len)
-{
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
- struct ad5791_state *st = iio_priv(indio_dev);
- int ret;
-
- if (sysfs_streq(buf, "6kohm_to_gnd"))
- st->pwr_down_mode = AD5791_DAC_PWRDN_6K;
- else if (sysfs_streq(buf, "three_state"))
- st->pwr_down_mode = AD5791_DAC_PWRDN_3STATE;
- else
- ret = -EINVAL;
-
- return ret ? ret : len;
-}
-
-static ssize_t ad5791_read_dac_powerdown(struct device *dev,
- struct device_attribute *attr,
- char *buf)
-{
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
- struct ad5791_state *st = iio_priv(indio_dev);
-
- return sprintf(buf, "%d\n", st->pwr_down);
-}
-
-static ssize_t ad5791_write_dac_powerdown(struct device *dev,
- struct device_attribute *attr,
- const char *buf, size_t len)
-{
- long readin;
- int ret;
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
- struct ad5791_state *st = iio_priv(indio_dev);
-
- ret = strict_strtol(buf, 10, &readin);
- if (ret)
- return ret;
-
- if (readin == 0) {
- st->pwr_down = false;
- st->ctrl &= ~(AD5791_CTRL_OPGND | AD5791_CTRL_DACTRI);
- } else if (readin == 1) {
- st->pwr_down = true;
- if (st->pwr_down_mode == AD5791_DAC_PWRDN_6K)
- st->ctrl |= AD5791_CTRL_OPGND;
- else if (st->pwr_down_mode == AD5791_DAC_PWRDN_3STATE)
- st->ctrl |= AD5791_CTRL_DACTRI;
- } else
- ret = -EINVAL;
-
- ret = ad5791_spi_write(st->spi, AD5791_ADDR_CTRL, st->ctrl);
-
- return ret ? ret : len;
-}
-
-static IIO_DEVICE_ATTR(out_voltage_powerdown_mode, S_IRUGO |
- S_IWUSR, ad5791_read_powerdown_mode,
- ad5791_write_powerdown_mode, 0);
-
-static IIO_CONST_ATTR(out_voltage_powerdown_mode_available,
- "6kohm_to_gnd three_state");
-
-#define IIO_DEV_ATTR_DAC_POWERDOWN(_num, _show, _store, _addr) \
- IIO_DEVICE_ATTR(out_voltage##_num##_powerdown, \
- S_IRUGO | S_IWUSR, _show, _store, _addr)
-
-static IIO_DEV_ATTR_DAC_POWERDOWN(0, ad5791_read_dac_powerdown,
- ad5791_write_dac_powerdown, 0);
-
-static struct attribute *ad5791_attributes[] = {
- &iio_dev_attr_out_voltage0_powerdown.dev_attr.attr,
- &iio_dev_attr_out_voltage_powerdown_mode.dev_attr.attr,
- &iio_const_attr_out_voltage_powerdown_mode_available.dev_attr.attr,
- NULL,
-};
-
-static const struct attribute_group ad5791_attribute_group = {
- .attrs = ad5791_attributes,
-};
-
-static int ad5791_get_lin_comp(unsigned int span)
-{
- if (span <= 10000)
- return AD5791_LINCOMP_0_10;
- else if (span <= 12000)
- return AD5791_LINCOMP_10_12;
- else if (span <= 16000)
- return AD5791_LINCOMP_12_16;
- else if (span <= 19000)
- return AD5791_LINCOMP_16_19;
- else
- return AD5791_LINCOMP_19_20;
-}
-
-static int ad5780_get_lin_comp(unsigned int span)
-{
- if (span <= 10000)
- return AD5780_LINCOMP_0_10;
- else
- return AD5780_LINCOMP_10_20;
-}
-static const struct ad5791_chip_info ad5791_chip_info_tbl[] = {
- [ID_AD5760] = {
- .get_lin_comp = ad5780_get_lin_comp,
- },
- [ID_AD5780] = {
- .get_lin_comp = ad5780_get_lin_comp,
- },
- [ID_AD5781] = {
- .get_lin_comp = ad5791_get_lin_comp,
- },
- [ID_AD5791] = {
- .get_lin_comp = ad5791_get_lin_comp,
- },
-};
-
-static int ad5791_read_raw(struct iio_dev *indio_dev,
- struct iio_chan_spec const *chan,
- int *val,
- int *val2,
- long m)
-{
- struct ad5791_state *st = iio_priv(indio_dev);
- u64 val64;
- int ret;
-
- switch (m) {
- case 0:
- ret = ad5791_spi_read(st->spi, chan->address, val);
- if (ret)
- return ret;
- *val &= AD5791_DAC_MASK;
- *val >>= chan->scan_type.shift;
- return IIO_VAL_INT;
- case IIO_CHAN_INFO_SCALE:
- *val = 0;
- *val2 = (((u64)st->vref_mv) * 1000000ULL) >> chan->scan_type.realbits;
- return IIO_VAL_INT_PLUS_MICRO;
- case IIO_CHAN_INFO_OFFSET:
- val64 = (((u64)st->vref_neg_mv) << chan->scan_type.realbits);
- do_div(val64, st->vref_mv);
- *val = -val64;
- return IIO_VAL_INT;
- default:
- return -EINVAL;
- }
-
-};
-
-
-static int ad5791_write_raw(struct iio_dev *indio_dev,
- struct iio_chan_spec const *chan,
- int val,
- int val2,
- long mask)
-{
- struct ad5791_state *st = iio_priv(indio_dev);
-
- switch (mask) {
- case 0:
- val &= AD5791_RES_MASK(chan->scan_type.realbits);
- val <<= chan->scan_type.shift;
-
- return ad5791_spi_write(st->spi, chan->address, val);
-
- default:
- return -EINVAL;
- }
-}
-
-static const struct iio_info ad5791_info = {
- .read_raw = &ad5791_read_raw,
- .write_raw = &ad5791_write_raw,
- .attrs = &ad5791_attribute_group,
- .driver_module = THIS_MODULE,
-};
-
-static int __devinit ad5791_probe(struct spi_device *spi)
-{
- struct ad5791_platform_data *pdata = spi->dev.platform_data;
- struct iio_dev *indio_dev;
- struct ad5791_state *st;
- int ret, pos_voltage_uv = 0, neg_voltage_uv = 0;
-
- indio_dev = iio_allocate_device(sizeof(*st));
- if (indio_dev == NULL) {
- ret = -ENOMEM;
- goto error_ret;
- }
- st = iio_priv(indio_dev);
- st->reg_vdd = regulator_get(&spi->dev, "vdd");
- if (!IS_ERR(st->reg_vdd)) {
- ret = regulator_enable(st->reg_vdd);
- if (ret)
- goto error_put_reg_pos;
-
- pos_voltage_uv = regulator_get_voltage(st->reg_vdd);
- }
-
- st->reg_vss = regulator_get(&spi->dev, "vss");
- if (!IS_ERR(st->reg_vss)) {
- ret = regulator_enable(st->reg_vss);
- if (ret)
- goto error_put_reg_neg;
-
- neg_voltage_uv = regulator_get_voltage(st->reg_vss);
- }
-
- st->pwr_down = true;
- st->spi = spi;
-
- if (!IS_ERR(st->reg_vss) && !IS_ERR(st->reg_vdd)) {
- st->vref_mv = (pos_voltage_uv + neg_voltage_uv) / 1000;
- st->vref_neg_mv = neg_voltage_uv / 1000;
- } else if (pdata) {
- st->vref_mv = pdata->vref_pos_mv + pdata->vref_neg_mv;
- st->vref_neg_mv = pdata->vref_neg_mv;
- } else {
- dev_warn(&spi->dev, "reference voltage unspecified\n");
- }
-
- ret = ad5791_spi_write(spi, AD5791_ADDR_SW_CTRL, AD5791_SWCTRL_RESET);
- if (ret)
- goto error_disable_reg_neg;
-
- st->chip_info = &ad5791_chip_info_tbl[spi_get_device_id(spi)
- ->driver_data];
-
-
- st->ctrl = AD5761_CTRL_LINCOMP(st->chip_info->get_lin_comp(st->vref_mv))
- | ((pdata && pdata->use_rbuf_gain2) ? 0 : AD5791_CTRL_RBUF) |
- AD5791_CTRL_BIN2SC;
-
- ret = ad5791_spi_write(spi, AD5791_ADDR_CTRL, st->ctrl |
- AD5791_CTRL_OPGND | AD5791_CTRL_DACTRI);
- if (ret)
- goto error_disable_reg_neg;
-
- spi_set_drvdata(spi, indio_dev);
- indio_dev->dev.parent = &spi->dev;
- indio_dev->info = &ad5791_info;
- indio_dev->modes = INDIO_DIRECT_MODE;
- indio_dev->channels
- = &ad5791_channels[spi_get_device_id(spi)->driver_data];
- indio_dev->num_channels = 1;
- indio_dev->name = spi_get_device_id(st->spi)->name;
- ret = iio_device_register(indio_dev);
- if (ret)
- goto error_disable_reg_neg;
-
- return 0;
-
-error_disable_reg_neg:
- if (!IS_ERR(st->reg_vss))
- regulator_disable(st->reg_vss);
-error_put_reg_neg:
- if (!IS_ERR(st->reg_vss))
- regulator_put(st->reg_vss);
-
- if (!IS_ERR(st->reg_vdd))
- regulator_disable(st->reg_vdd);
-error_put_reg_pos:
- if (!IS_ERR(st->reg_vdd))
- regulator_put(st->reg_vdd);
- iio_free_device(indio_dev);
-error_ret:
-
- return ret;
-}
-
-static int __devexit ad5791_remove(struct spi_device *spi)
-{
- struct iio_dev *indio_dev = spi_get_drvdata(spi);
- struct ad5791_state *st = iio_priv(indio_dev);
-
- iio_device_unregister(indio_dev);
- if (!IS_ERR(st->reg_vdd)) {
- regulator_disable(st->reg_vdd);
- regulator_put(st->reg_vdd);
- }
-
- if (!IS_ERR(st->reg_vss)) {
- regulator_disable(st->reg_vss);
- regulator_put(st->reg_vss);
- }
- iio_free_device(indio_dev);
-
- return 0;
-}
-
-static const struct spi_device_id ad5791_id[] = {
- {"ad5760", ID_AD5760},
- {"ad5780", ID_AD5780},
- {"ad5781", ID_AD5781},
- {"ad5790", ID_AD5791},
- {"ad5791", ID_AD5791},
- {}
-};
-MODULE_DEVICE_TABLE(spi, ad5791_id);
-
-static struct spi_driver ad5791_driver = {
- .driver = {
- .name = "ad5791",
- .owner = THIS_MODULE,
- },
- .probe = ad5791_probe,
- .remove = __devexit_p(ad5791_remove),
- .id_table = ad5791_id,
-};
-module_spi_driver(ad5791_driver);
-
-MODULE_AUTHOR("Michael Hennerich <hennerich@blackfin.uclinux.org>");
-MODULE_DESCRIPTION("Analog Devices AD5760/AD5780/AD5781/AD5790/AD5791 DAC");
-MODULE_LICENSE("GPL v2");
diff --git a/drivers/staging/iio/dac/ad5791.h b/drivers/staging/iio/dac/ad5791.h
deleted file mode 100644
index fd7edbdb4ec3..000000000000
--- a/drivers/staging/iio/dac/ad5791.h
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
- * AD5791 SPI DAC driver
- *
- * Copyright 2011 Analog Devices Inc.
- *
- * Licensed under the GPL-2.
- */
-
-#ifndef SPI_AD5791_H_
-#define SPI_AD5791_H_
-
-#define AD5791_RES_MASK(x) ((1 << (x)) - 1)
-#define AD5791_DAC_MASK AD5791_RES_MASK(20)
-#define AD5791_DAC_MSB (1 << 19)
-
-#define AD5791_CMD_READ (1 << 23)
-#define AD5791_CMD_WRITE (0 << 23)
-#define AD5791_ADDR(addr) ((addr) << 20)
-
-/* Registers */
-#define AD5791_ADDR_NOOP 0
-#define AD5791_ADDR_DAC0 1
-#define AD5791_ADDR_CTRL 2
-#define AD5791_ADDR_CLRCODE 3
-#define AD5791_ADDR_SW_CTRL 4
-
-/* Control Register */
-#define AD5791_CTRL_RBUF (1 << 1)
-#define AD5791_CTRL_OPGND (1 << 2)
-#define AD5791_CTRL_DACTRI (1 << 3)
-#define AD5791_CTRL_BIN2SC (1 << 4)
-#define AD5791_CTRL_SDODIS (1 << 5)
-#define AD5761_CTRL_LINCOMP(x) ((x) << 6)
-
-#define AD5791_LINCOMP_0_10 0
-#define AD5791_LINCOMP_10_12 1
-#define AD5791_LINCOMP_12_16 2
-#define AD5791_LINCOMP_16_19 3
-#define AD5791_LINCOMP_19_20 12
-
-#define AD5780_LINCOMP_0_10 0
-#define AD5780_LINCOMP_10_20 12
-
-/* Software Control Register */
-#define AD5791_SWCTRL_LDAC (1 << 0)
-#define AD5791_SWCTRL_CLR (1 << 1)
-#define AD5791_SWCTRL_RESET (1 << 2)
-
-#define AD5791_DAC_PWRDN_6K 0
-#define AD5791_DAC_PWRDN_3STATE 1
-
-/*
- * TODO: struct ad5791_platform_data needs to go into include/linux/iio
- */
-
-/**
- * struct ad5791_platform_data - platform specific information
- * @vref_pos_mv: Vdd Positive Analog Supply Volatge (mV)
- * @vref_neg_mv: Vdd Negative Analog Supply Volatge (mV)
- * @use_rbuf_gain2: ext. amplifier connected in gain of two configuration
- */
-
-struct ad5791_platform_data {
- u16 vref_pos_mv;
- u16 vref_neg_mv;
- bool use_rbuf_gain2;
-};
-
-/**
- * struct ad5791_chip_info - chip specific information
- * @get_lin_comp: function pointer to the device specific function
- */
-
-struct ad5791_chip_info {
- int (*get_lin_comp) (unsigned int span);
-};
-
-/**
- * struct ad5791_state - driver instance specific data
- * @us: spi_device
- * @reg_vdd: positive supply regulator
- * @reg_vss: negative supply regulator
- * @chip_info: chip model specific constants
- * @vref_mv: actual reference voltage used
- * @vref_neg_mv: voltage of the negative supply
- * @pwr_down_mode current power down mode
- */
-
-struct ad5791_state {
- struct spi_device *spi;
- struct regulator *reg_vdd;
- struct regulator *reg_vss;
- const struct ad5791_chip_info *chip_info;
- unsigned short vref_mv;
- unsigned int vref_neg_mv;
- unsigned ctrl;
- unsigned pwr_down_mode;
- bool pwr_down;
-};
-
-/**
- * ad5791_supported_device_ids:
- */
-
-enum ad5791_supported_device_ids {
- ID_AD5760,
- ID_AD5780,
- ID_AD5781,
- ID_AD5791,
-};
-
-#endif /* SPI_AD5791_H_ */
diff --git a/drivers/staging/iio/dac/dac.h b/drivers/staging/iio/dac/dac.h
deleted file mode 100644
index 0754d715cf9c..000000000000
--- a/drivers/staging/iio/dac/dac.h
+++ /dev/null
@@ -1,6 +0,0 @@
-/*
- * dac.h - sysfs attributes associated with DACs
- */
-
-#define IIO_DEV_ATTR_OUT_RAW(_num, _store, _addr) \
- IIO_DEVICE_ATTR(out_voltage##_num##_raw, S_IWUSR, NULL, _store, _addr)
diff --git a/drivers/staging/iio/dac/max517.c b/drivers/staging/iio/dac/max517.c
deleted file mode 100644
index 41483c72cec1..000000000000
--- a/drivers/staging/iio/dac/max517.c
+++ /dev/null
@@ -1,293 +0,0 @@
-/*
- * max517.c - Support for Maxim MAX517, MAX518 and MAX519
- *
- * Copyright (C) 2010, 2011 Roland Stigge <stigge@antcom.de>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-#include <linux/module.h>
-#include <linux/init.h>
-#include <linux/slab.h>
-#include <linux/jiffies.h>
-#include <linux/i2c.h>
-#include <linux/err.h>
-
-#include "../iio.h"
-#include "../sysfs.h"
-#include "dac.h"
-
-#include "max517.h"
-
-#define MAX517_DRV_NAME "max517"
-
-/* Commands */
-#define COMMAND_CHANNEL0 0x00
-#define COMMAND_CHANNEL1 0x01 /* for MAX518 and MAX519 */
-#define COMMAND_PD 0x08 /* Power Down */
-
-enum max517_device_ids {
- ID_MAX517,
- ID_MAX518,
- ID_MAX519,
-};
-
-struct max517_data {
- struct iio_dev *indio_dev;
- struct i2c_client *client;
- unsigned short vref_mv[2];
-};
-
-/*
- * channel: bit 0: channel 1
- * bit 1: channel 2
- * (this way, it's possible to set both channels at once)
- */
-static ssize_t max517_set_value(struct device *dev,
- struct device_attribute *attr,
- const char *buf, size_t count, int channel)
-{
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
- struct max517_data *data = iio_priv(indio_dev);
- struct i2c_client *client = data->client;
- u8 outbuf[4]; /* 1x or 2x command + value */
- int outbuf_size = 0;
- int res;
- long val;
-
- res = strict_strtol(buf, 10, &val);
-
- if (res)
- return res;
-
- if (val < 0 || val > 255)
- return -EINVAL;
-
- if (channel & 1) {
- outbuf[outbuf_size++] = COMMAND_CHANNEL0;
- outbuf[outbuf_size++] = val;
- }
- if (channel & 2) {
- outbuf[outbuf_size++] = COMMAND_CHANNEL1;
- outbuf[outbuf_size++] = val;
- }
-
- /*
- * At this point, there are always 1 or 2 two-byte commands in
- * outbuf. With 2 commands, the device can set two outputs
- * simultaneously, latching the values upon the end of the I2C
- * transfer.
- */
-
- res = i2c_master_send(client, outbuf, outbuf_size);
- if (res < 0)
- return res;
-
- return count;
-}
-
-static ssize_t max517_set_value_1(struct device *dev,
- struct device_attribute *attr,
- const char *buf, size_t count)
-{
- return max517_set_value(dev, attr, buf, count, 1);
-}
-static IIO_DEV_ATTR_OUT_RAW(1, max517_set_value_1, 0);
-
-static ssize_t max517_set_value_2(struct device *dev,
- struct device_attribute *attr,
- const char *buf, size_t count)
-{
- return max517_set_value(dev, attr, buf, count, 2);
-}
-static IIO_DEV_ATTR_OUT_RAW(2, max517_set_value_2, 1);
-
-static ssize_t max517_set_value_both(struct device *dev,
- struct device_attribute *attr,
- const char *buf, size_t count)
-{
- return max517_set_value(dev, attr, buf, count, 3);
-}
-static IIO_DEVICE_ATTR_NAMED(out_voltage1and2_raw,
- out_voltage1&2_raw, S_IWUSR, NULL,
- max517_set_value_both, -1);
-
-static ssize_t max517_show_scale(struct device *dev,
- struct device_attribute *attr,
- char *buf, int channel)
-{
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
- struct max517_data *data = iio_priv(indio_dev);
- /* Corresponds to Vref / 2^(bits) */
- unsigned int scale_uv = (data->vref_mv[channel - 1] * 1000) >> 8;
-
- return sprintf(buf, "%d.%03d\n", scale_uv / 1000, scale_uv % 1000);
-}
-
-static ssize_t max517_show_scale1(struct device *dev,
- struct device_attribute *attr,
- char *buf)
-{
- return max517_show_scale(dev, attr, buf, 1);
-}
-static IIO_DEVICE_ATTR(out_voltage1_scale, S_IRUGO,
- max517_show_scale1, NULL, 0);
-
-static ssize_t max517_show_scale2(struct device *dev,
- struct device_attribute *attr,
- char *buf)
-{
- return max517_show_scale(dev, attr, buf, 2);
-}
-static IIO_DEVICE_ATTR(out_voltage2_scale, S_IRUGO,
- max517_show_scale2, NULL, 0);
-
-/* On MAX517 variant, we have one output */
-static struct attribute *max517_attributes[] = {
- &iio_dev_attr_out_voltage1_raw.dev_attr.attr,
- &iio_dev_attr_out_voltage1_scale.dev_attr.attr,
- NULL
-};
-
-static struct attribute_group max517_attribute_group = {
- .attrs = max517_attributes,
-};
-
-/* On MAX518 and MAX519 variant, we have two outputs */
-static struct attribute *max518_attributes[] = {
- &iio_dev_attr_out_voltage1_raw.dev_attr.attr,
- &iio_dev_attr_out_voltage1_scale.dev_attr.attr,
- &iio_dev_attr_out_voltage2_raw.dev_attr.attr,
- &iio_dev_attr_out_voltage2_scale.dev_attr.attr,
- &iio_dev_attr_out_voltage1and2_raw.dev_attr.attr,
- NULL
-};
-
-static struct attribute_group max518_attribute_group = {
- .attrs = max518_attributes,
-};
-
-#ifdef CONFIG_PM_SLEEP
-static int max517_suspend(struct device *dev)
-{
- u8 outbuf = COMMAND_PD;
-
- return i2c_master_send(to_i2c_client(dev), &outbuf, 1);
-}
-
-static int max517_resume(struct device *dev)
-{
- u8 outbuf = 0;
-
- return i2c_master_send(to_i2c_client(dev), &outbuf, 1);
-}
-
-static SIMPLE_DEV_PM_OPS(max517_pm_ops, max517_suspend, max517_resume);
-#define MAX517_PM_OPS (&max517_pm_ops)
-#else
-#define MAX517_PM_OPS NULL
-#endif
-
-static const struct iio_info max517_info = {
- .attrs = &max517_attribute_group,
- .driver_module = THIS_MODULE,
-};
-
-static const struct iio_info max518_info = {
- .attrs = &max518_attribute_group,
- .driver_module = THIS_MODULE,
-};
-
-static int max517_probe(struct i2c_client *client,
- const struct i2c_device_id *id)
-{
- struct max517_data *data;
- struct iio_dev *indio_dev;
- struct max517_platform_data *platform_data = client->dev.platform_data;
- int err;
-
- indio_dev = iio_allocate_device(sizeof(*data));
- if (indio_dev == NULL) {
- err = -ENOMEM;
- goto exit;
- }
- data = iio_priv(indio_dev);
- i2c_set_clientdata(client, indio_dev);
- data->client = client;
-
- /* establish that the iio_dev is a child of the i2c device */
- indio_dev->dev.parent = &client->dev;
-
- /* reduced attribute set for MAX517 */
- if (id->driver_data == ID_MAX517)
- indio_dev->info = &max517_info;
- else
- indio_dev->info = &max518_info;
- indio_dev->modes = INDIO_DIRECT_MODE;
-
- /*
- * Reference voltage on MAX518 and default is 5V, else take vref_mv
- * from platform_data
- */
- if (id->driver_data == ID_MAX518 || !platform_data) {
- data->vref_mv[0] = data->vref_mv[1] = 5000; /* mV */
- } else {
- data->vref_mv[0] = platform_data->vref_mv[0];
- data->vref_mv[1] = platform_data->vref_mv[1];
- }
-
- err = iio_device_register(indio_dev);
- if (err)
- goto exit_free_device;
-
- dev_info(&client->dev, "DAC registered\n");
-
- return 0;
-
-exit_free_device:
- iio_free_device(indio_dev);
-exit:
- return err;
-}
-
-static int max517_remove(struct i2c_client *client)
-{
- iio_free_device(i2c_get_clientdata(client));
-
- return 0;
-}
-
-static const struct i2c_device_id max517_id[] = {
- { "max517", ID_MAX517 },
- { "max518", ID_MAX518 },
- { "max519", ID_MAX519 },
- { }
-};
-MODULE_DEVICE_TABLE(i2c, max517_id);
-
-static struct i2c_driver max517_driver = {
- .driver = {
- .name = MAX517_DRV_NAME,
- .pm = MAX517_PM_OPS,
- },
- .probe = max517_probe,
- .remove = max517_remove,
- .id_table = max517_id,
-};
-module_i2c_driver(max517_driver);
-
-MODULE_AUTHOR("Roland Stigge <stigge@antcom.de>");
-MODULE_DESCRIPTION("MAX517/MAX518/MAX519 8-bit DAC");
-MODULE_LICENSE("GPL");
diff --git a/drivers/staging/iio/dac/max517.h b/drivers/staging/iio/dac/max517.h
deleted file mode 100644
index 8106cf24642a..000000000000
--- a/drivers/staging/iio/dac/max517.h
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
- * MAX517 DAC driver
- *
- * Copyright 2011 Roland Stigge <stigge@antcom.de>
- *
- * Licensed under the GPL-2 or later.
- */
-#ifndef IIO_DAC_MAX517_H_
-#define IIO_DAC_MAX517_H_
-
-/*
- * TODO: struct max517_platform_data needs to go into include/linux/iio
- */
-
-struct max517_platform_data {
- u16 vref_mv[2];
-};
-
-#endif /* IIO_DAC_MAX517_H_ */
diff --git a/drivers/staging/iio/dds/dds.h b/drivers/staging/iio/dds/dds.h
deleted file mode 100644
index d8ac3a93baf6..000000000000
--- a/drivers/staging/iio/dds/dds.h
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- * dds.h - sysfs attributes associated with DDS devices
- *
- * Copyright (c) 2010 Analog Devices Inc.
- *
- * Licensed under the GPL-2 or later.
- */
-
-/**
- * /sys/bus/iio/devices/.../ddsX_freqY
- */
-
-#define IIO_DEV_ATTR_FREQ(_channel, _num, _mode, _show, _store, _addr) \
- IIO_DEVICE_ATTR(dds##_channel##_freq##_num, \
- _mode, _show, _store, _addr)
-
-/**
- * /sys/bus/iio/devices/.../ddsX_freqY_scale
- */
-
-#define IIO_CONST_ATTR_FREQ_SCALE(_channel, _string) \
- IIO_CONST_ATTR(dds##_channel##_freq_scale, _string)
-
-/**
- * /sys/bus/iio/devices/.../ddsX_freqsymbol
- */
-
-#define IIO_DEV_ATTR_FREQSYMBOL(_channel, _mode, _show, _store, _addr) \
- IIO_DEVICE_ATTR(dds##_channel##_freqsymbol, \
- _mode, _show, _store, _addr);
-
-/**
- * /sys/bus/iio/devices/.../ddsX_phaseY
- */
-
-#define IIO_DEV_ATTR_PHASE(_channel, _num, _mode, _show, _store, _addr) \
- IIO_DEVICE_ATTR(dds##_channel##_phase##_num, \
- _mode, _show, _store, _addr)
-
-/**
- * /sys/bus/iio/devices/.../ddsX_phaseY_scale
- */
-
-#define IIO_CONST_ATTR_PHASE_SCALE(_channel, _string) \
- IIO_CONST_ATTR(dds##_channel##_phase_scale, _string)
-
-/**
- * /sys/bus/iio/devices/.../ddsX_phasesymbol
- */
-
-#define IIO_DEV_ATTR_PHASESYMBOL(_channel, _mode, _show, _store, _addr) \
- IIO_DEVICE_ATTR(dds##_channel##_phasesymbol, \
- _mode, _show, _store, _addr);
-
-/**
- * /sys/bus/iio/devices/.../ddsX_pincontrol_en
- */
-
-#define IIO_DEV_ATTR_PINCONTROL_EN(_channel, _mode, _show, _store, _addr)\
- IIO_DEVICE_ATTR(dds##_channel##_pincontrol_en, \
- _mode, _show, _store, _addr);
-
-/**
- * /sys/bus/iio/devices/.../ddsX_pincontrol_freq_en
- */
-
-#define IIO_DEV_ATTR_PINCONTROL_FREQ_EN(_channel, _mode, _show, _store, _addr)\
- IIO_DEVICE_ATTR(dds##_channel##_pincontrol_freq_en, \
- _mode, _show, _store, _addr);
-
-/**
- * /sys/bus/iio/devices/.../ddsX_pincontrol_phase_en
- */
-
-#define IIO_DEV_ATTR_PINCONTROL_PHASE_EN(_channel, _mode, _show, _store, _addr)\
- IIO_DEVICE_ATTR(dds##_channel##_pincontrol_phase_en, \
- _mode, _show, _store, _addr);
-
-/**
- * /sys/bus/iio/devices/.../ddsX_out_enable
- */
-
-#define IIO_DEV_ATTR_OUT_ENABLE(_channel, _mode, _show, _store, _addr) \
- IIO_DEVICE_ATTR(dds##_channel##_out_enable, \
- _mode, _show, _store, _addr);
-
-/**
- * /sys/bus/iio/devices/.../ddsX_outY_enable
- */
-
-#define IIO_DEV_ATTR_OUTY_ENABLE(_channel, _output, \
- _mode, _show, _store, _addr) \
- IIO_DEVICE_ATTR(dds##_channel##_out##_output##_enable, \
- _mode, _show, _store, _addr);
-
-/**
- * /sys/bus/iio/devices/.../ddsX_outY_wavetype
- */
-
-#define IIO_DEV_ATTR_OUT_WAVETYPE(_channel, _output, _store, _addr) \
- IIO_DEVICE_ATTR(dds##_channel##_out##_output##_wavetype, \
- S_IWUSR, NULL, _store, _addr);
-
-/**
- * /sys/bus/iio/devices/.../ddsX_outY_wavetype_available
- */
-
-#define IIO_CONST_ATTR_OUT_WAVETYPES_AVAILABLE(_channel, _output, _modes)\
- IIO_CONST_ATTR(dds##_channel##_out##_output##_wavetype_available,\
- _modes);
diff --git a/drivers/staging/iio/driver.h b/drivers/staging/iio/driver.h
deleted file mode 100644
index a4f8b2e05af5..000000000000
--- a/drivers/staging/iio/driver.h
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Industrial I/O in kernel access map interface.
- *
- * Copyright (c) 2011 Jonathan Cameron
- *
- * 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 _IIO_INKERN_H_
-#define _IIO_INKERN_H_
-
-struct iio_map;
-
-/**
- * iio_map_array_register() - tell the core about inkernel consumers
- * @indio_dev: provider device
- * @map: array of mappings specifying association of channel with client
- */
-int iio_map_array_register(struct iio_dev *indio_dev,
- struct iio_map *map);
-
-/**
- * iio_map_array_unregister() - tell the core to remove consumer mappings
- * @indio_dev: provider device
- * @map: array of mappings to remove. Note these must have same memory
- * addresses as those originally added not just equal parameter
- * values.
- */
-int iio_map_array_unregister(struct iio_dev *indio_dev,
- struct iio_map *map);
-
-#endif
diff --git a/drivers/staging/iio/events.h b/drivers/staging/iio/events.h
deleted file mode 100644
index c25f0e3c92e9..000000000000
--- a/drivers/staging/iio/events.h
+++ /dev/null
@@ -1,105 +0,0 @@
-/* The industrial I/O - event passing to userspace
- *
- * Copyright (c) 2008-2011 Jonathan Cameron
- *
- * 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 _IIO_EVENTS_H_
-#define _IIO_EVENTS_H_
-
-#include <linux/ioctl.h>
-#include <linux/types.h>
-#include "types.h"
-
-/**
- * struct iio_event_data - The actual event being pushed to userspace
- * @id: event identifier
- * @timestamp: best estimate of time of event occurrence (often from
- * the interrupt handler)
- */
-struct iio_event_data {
- __u64 id;
- __s64 timestamp;
-};
-
-#define IIO_GET_EVENT_FD_IOCTL _IOR('i', 0x90, int)
-
-enum iio_event_type {
- IIO_EV_TYPE_THRESH,
- IIO_EV_TYPE_MAG,
- IIO_EV_TYPE_ROC,
- IIO_EV_TYPE_THRESH_ADAPTIVE,
- IIO_EV_TYPE_MAG_ADAPTIVE,
-};
-
-enum iio_event_direction {
- IIO_EV_DIR_EITHER,
- IIO_EV_DIR_RISING,
- IIO_EV_DIR_FALLING,
-};
-
-/**
- * IIO_EVENT_CODE() - create event identifier
- * @chan_type: Type of the channel. Should be one of enum iio_chan_type.
- * @diff: Whether the event is for an differential channel or not.
- * @modifier: Modifier for the channel. Should be one of enum iio_modifier.
- * @direction: Direction of the event. One of enum iio_event_direction.
- * @type: Type of the event. Should be one enum iio_event_type.
- * @chan: Channel number for non-differential channels.
- * @chan1: First channel number for differential channels.
- * @chan2: Second channel number for differential channels.
- */
-
-#define IIO_EVENT_CODE(chan_type, diff, modifier, direction, \
- type, chan, chan1, chan2) \
- (((u64)type << 56) | ((u64)diff << 55) | \
- ((u64)direction << 48) | ((u64)modifier << 40) | \
- ((u64)chan_type << 32) | (((u16)chan2) << 16) | ((u16)chan1) | \
- ((u16)chan))
-
-
-#define IIO_EV_DIR_MAX 4
-#define IIO_EV_BIT(type, direction) \
- (1 << (type*IIO_EV_DIR_MAX + direction))
-
-/**
- * IIO_MOD_EVENT_CODE() - create event identifier for modified channels
- * @chan_type: Type of the channel. Should be one of enum iio_chan_type.
- * @number: Channel number.
- * @modifier: Modifier for the channel. Should be one of enum iio_modifier.
- * @type: Type of the event. Should be one enum iio_event_type.
- * @direction: Direction of the event. One of enum iio_event_direction.
- */
-
-#define IIO_MOD_EVENT_CODE(chan_type, number, modifier, \
- type, direction) \
- IIO_EVENT_CODE(chan_type, 0, modifier, direction, type, number, 0, 0)
-
-/**
- * IIO_UNMOD_EVENT_CODE() - create event identifier for unmodified channels
- * @chan_type: Type of the channel. Should be one of enum iio_chan_type.
- * @number: Channel number.
- * @type: Type of the event. Should be one enum iio_event_type.
- * @direction: Direction of the event. One of enum iio_event_direction.
- */
-
-#define IIO_UNMOD_EVENT_CODE(chan_type, number, type, direction) \
- IIO_EVENT_CODE(chan_type, 0, 0, direction, type, number, 0, 0)
-
-#define IIO_EVENT_CODE_EXTRACT_TYPE(mask) ((mask >> 56) & 0xFF)
-
-#define IIO_EVENT_CODE_EXTRACT_DIR(mask) ((mask >> 48) & 0xCF)
-
-#define IIO_EVENT_CODE_EXTRACT_CHAN_TYPE(mask) ((mask >> 32) & 0xFF)
-
-/* Event code number extraction depends on which type of event we have.
- * Perhaps review this function in the future*/
-#define IIO_EVENT_CODE_EXTRACT_CHAN(mask) ((__s16)(mask & 0xFFFF))
-#define IIO_EVENT_CODE_EXTRACT_CHAN2(mask) ((__s16)(((mask) >> 16) & 0xFFFF))
-
-#define IIO_EVENT_CODE_EXTRACT_MODIFIER(mask) ((mask >> 40) & 0xFF)
-#define IIO_EVENT_CODE_EXTRACT_DIFF(mask) (((mask) >> 55) & 0x1)
-
-#endif
diff --git a/drivers/staging/iio/dds/Kconfig b/drivers/staging/iio/frequency/Kconfig
index 93b7141b2c1f..93b7141b2c1f 100644
--- a/drivers/staging/iio/dds/Kconfig
+++ b/drivers/staging/iio/frequency/Kconfig
diff --git a/drivers/staging/iio/dds/Makefile b/drivers/staging/iio/frequency/Makefile
index 147746176b9b..147746176b9b 100644
--- a/drivers/staging/iio/dds/Makefile
+++ b/drivers/staging/iio/frequency/Makefile
diff --git a/drivers/staging/iio/dds/ad5930.c b/drivers/staging/iio/frequency/ad5930.c
index 9c32d1beae25..2d541d0eebef 100644
--- a/drivers/staging/iio/dds/ad5930.c
+++ b/drivers/staging/iio/frequency/ad5930.c
@@ -16,8 +16,8 @@
#include <linux/sysfs.h>
#include <linux/module.h>
-#include "../iio.h"
-#include "../sysfs.h"
+#include <linux/iio/iio.h>
+#include <linux/iio/sysfs.h>
#define DRV_NAME "ad5930"
@@ -48,7 +48,7 @@ static ssize_t ad5930_set_parameter(struct device *dev,
struct spi_transfer xfer;
int ret;
struct ad5903_config *config = (struct ad5903_config *)buf;
- struct iio_dev *idev = dev_get_drvdata(dev);
+ struct iio_dev *idev = dev_to_iio_dev(dev);
struct ad5930_state *st = iio_priv(idev);
config->control = (config->control & ~value_mask);
@@ -97,7 +97,7 @@ static int __devinit ad5930_probe(struct spi_device *spi)
struct iio_dev *idev;
int ret = 0;
- idev = iio_allocate_device(sizeof(*st));
+ idev = iio_device_alloc(sizeof(*st));
if (idev == NULL) {
ret = -ENOMEM;
goto error_ret;
@@ -122,7 +122,7 @@ static int __devinit ad5930_probe(struct spi_device *spi)
return 0;
error_free_dev:
- iio_free_device(idev);
+ iio_device_free(idev);
error_ret:
return ret;
}
@@ -130,7 +130,7 @@ error_ret:
static int __devexit ad5930_remove(struct spi_device *spi)
{
iio_device_unregister(spi_get_drvdata(spi));
- iio_free_device(spi_get_drvdata(spi));
+ iio_device_free(spi_get_drvdata(spi));
return 0;
}
diff --git a/drivers/staging/iio/dds/ad9832.c b/drivers/staging/iio/frequency/ad9832.c
index 2ccf25dd9289..fed39404e34a 100644
--- a/drivers/staging/iio/dds/ad9832.c
+++ b/drivers/staging/iio/frequency/ad9832.c
@@ -16,8 +16,8 @@
#include <linux/module.h>
#include <asm/div64.h>
-#include "../iio.h"
-#include "../sysfs.h"
+#include <linux/iio/iio.h>
+#include <linux/iio/sysfs.h>
#include "dds.h"
#include "ad9832.h"
@@ -77,7 +77,7 @@ static ssize_t ad9832_write(struct device *dev,
const char *buf,
size_t len)
{
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct ad9832_state *st = iio_priv(indio_dev);
struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
int ret;
@@ -177,18 +177,18 @@ static IIO_DEV_ATTR_OUT_ENABLE(0, S_IWUSR, NULL,
ad9832_write, AD9832_OUTPUT_EN);
static struct attribute *ad9832_attributes[] = {
- &iio_dev_attr_dds0_freq0.dev_attr.attr,
- &iio_dev_attr_dds0_freq1.dev_attr.attr,
- &iio_const_attr_dds0_freq_scale.dev_attr.attr,
- &iio_dev_attr_dds0_phase0.dev_attr.attr,
- &iio_dev_attr_dds0_phase1.dev_attr.attr,
- &iio_dev_attr_dds0_phase2.dev_attr.attr,
- &iio_dev_attr_dds0_phase3.dev_attr.attr,
- &iio_const_attr_dds0_phase_scale.dev_attr.attr,
- &iio_dev_attr_dds0_pincontrol_en.dev_attr.attr,
- &iio_dev_attr_dds0_freqsymbol.dev_attr.attr,
- &iio_dev_attr_dds0_phasesymbol.dev_attr.attr,
- &iio_dev_attr_dds0_out_enable.dev_attr.attr,
+ &iio_dev_attr_out_altvoltage0_frequency0.dev_attr.attr,
+ &iio_dev_attr_out_altvoltage0_frequency1.dev_attr.attr,
+ &iio_const_attr_out_altvoltage0_frequency_scale.dev_attr.attr,
+ &iio_dev_attr_out_altvoltage0_phase0.dev_attr.attr,
+ &iio_dev_attr_out_altvoltage0_phase1.dev_attr.attr,
+ &iio_dev_attr_out_altvoltage0_phase2.dev_attr.attr,
+ &iio_dev_attr_out_altvoltage0_phase3.dev_attr.attr,
+ &iio_const_attr_out_altvoltage0_phase_scale.dev_attr.attr,
+ &iio_dev_attr_out_altvoltage0_pincontrol_en.dev_attr.attr,
+ &iio_dev_attr_out_altvoltage0_frequencysymbol.dev_attr.attr,
+ &iio_dev_attr_out_altvoltage0_phasesymbol.dev_attr.attr,
+ &iio_dev_attr_out_altvoltage0_out_enable.dev_attr.attr,
NULL,
};
@@ -221,7 +221,7 @@ static int __devinit ad9832_probe(struct spi_device *spi)
goto error_put_reg;
}
- indio_dev = iio_allocate_device(sizeof(*st));
+ indio_dev = iio_device_alloc(sizeof(*st));
if (indio_dev == NULL) {
ret = -ENOMEM;
goto error_disable_reg;
@@ -313,7 +313,7 @@ static int __devinit ad9832_probe(struct spi_device *spi)
return 0;
error_free_device:
- iio_free_device(indio_dev);
+ iio_device_free(indio_dev);
error_disable_reg:
if (!IS_ERR(reg))
regulator_disable(reg);
@@ -334,7 +334,7 @@ static int __devexit ad9832_remove(struct spi_device *spi)
regulator_disable(st->reg);
regulator_put(st->reg);
}
- iio_free_device(indio_dev);
+ iio_device_free(indio_dev);
return 0;
}
diff --git a/drivers/staging/iio/dds/ad9832.h b/drivers/staging/iio/frequency/ad9832.h
index c5b701f8aabb..c5b701f8aabb 100644
--- a/drivers/staging/iio/dds/ad9832.h
+++ b/drivers/staging/iio/frequency/ad9832.h
diff --git a/drivers/staging/iio/dds/ad9834.c b/drivers/staging/iio/frequency/ad9834.c
index 38a2de08626f..1b2dc741d2ce 100644
--- a/drivers/staging/iio/dds/ad9834.c
+++ b/drivers/staging/iio/frequency/ad9834.c
@@ -19,8 +19,8 @@
#include <linux/module.h>
#include <asm/div64.h>
-#include "../iio.h"
-#include "../sysfs.h"
+#include <linux/iio/iio.h>
+#include <linux/iio/sysfs.h>
#include "dds.h"
#include "ad9834.h"
@@ -66,7 +66,7 @@ static ssize_t ad9834_write(struct device *dev,
const char *buf,
size_t len)
{
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct ad9834_state *st = iio_priv(indio_dev);
struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
int ret;
@@ -145,7 +145,7 @@ static ssize_t ad9834_store_wavetype(struct device *dev,
const char *buf,
size_t len)
{
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct ad9834_state *st = iio_priv(indio_dev);
struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
int ret = 0;
@@ -203,7 +203,7 @@ static ssize_t ad9834_show_out0_wavetype_available(struct device *dev,
struct device_attribute *attr,
char *buf)
{
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct ad9834_state *st = iio_priv(indio_dev);
char *str;
@@ -218,14 +218,14 @@ static ssize_t ad9834_show_out0_wavetype_available(struct device *dev,
}
-static IIO_DEVICE_ATTR(dds0_out0_wavetype_available, S_IRUGO,
+static IIO_DEVICE_ATTR(out_altvoltage0_out0_wavetype_available, S_IRUGO,
ad9834_show_out0_wavetype_available, NULL, 0);
static ssize_t ad9834_show_out1_wavetype_available(struct device *dev,
struct device_attribute *attr,
char *buf)
{
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct ad9834_state *st = iio_priv(indio_dev);
char *str;
@@ -237,7 +237,7 @@ static ssize_t ad9834_show_out1_wavetype_available(struct device *dev,
return sprintf(buf, "%s\n", str);
}
-static IIO_DEVICE_ATTR(dds0_out1_wavetype_available, S_IRUGO,
+static IIO_DEVICE_ATTR(out_altvoltage0_out1_wavetype_available, S_IRUGO,
ad9834_show_out1_wavetype_available, NULL, 0);
/**
@@ -263,36 +263,36 @@ static IIO_DEV_ATTR_OUT_WAVETYPE(0, 0, ad9834_store_wavetype, 0);
static IIO_DEV_ATTR_OUT_WAVETYPE(0, 1, ad9834_store_wavetype, 1);
static struct attribute *ad9834_attributes[] = {
- &iio_dev_attr_dds0_freq0.dev_attr.attr,
- &iio_dev_attr_dds0_freq1.dev_attr.attr,
- &iio_const_attr_dds0_freq_scale.dev_attr.attr,
- &iio_dev_attr_dds0_phase0.dev_attr.attr,
- &iio_dev_attr_dds0_phase1.dev_attr.attr,
- &iio_const_attr_dds0_phase_scale.dev_attr.attr,
- &iio_dev_attr_dds0_pincontrol_en.dev_attr.attr,
- &iio_dev_attr_dds0_freqsymbol.dev_attr.attr,
- &iio_dev_attr_dds0_phasesymbol.dev_attr.attr,
- &iio_dev_attr_dds0_out_enable.dev_attr.attr,
- &iio_dev_attr_dds0_out1_enable.dev_attr.attr,
- &iio_dev_attr_dds0_out0_wavetype.dev_attr.attr,
- &iio_dev_attr_dds0_out1_wavetype.dev_attr.attr,
- &iio_dev_attr_dds0_out0_wavetype_available.dev_attr.attr,
- &iio_dev_attr_dds0_out1_wavetype_available.dev_attr.attr,
+ &iio_dev_attr_out_altvoltage0_frequency0.dev_attr.attr,
+ &iio_dev_attr_out_altvoltage0_frequency1.dev_attr.attr,
+ &iio_const_attr_out_altvoltage0_frequency_scale.dev_attr.attr,
+ &iio_dev_attr_out_altvoltage0_phase0.dev_attr.attr,
+ &iio_dev_attr_out_altvoltage0_phase1.dev_attr.attr,
+ &iio_const_attr_out_altvoltage0_phase_scale.dev_attr.attr,
+ &iio_dev_attr_out_altvoltage0_pincontrol_en.dev_attr.attr,
+ &iio_dev_attr_out_altvoltage0_frequencysymbol.dev_attr.attr,
+ &iio_dev_attr_out_altvoltage0_phasesymbol.dev_attr.attr,
+ &iio_dev_attr_out_altvoltage0_out_enable.dev_attr.attr,
+ &iio_dev_attr_out_altvoltage0_out1_enable.dev_attr.attr,
+ &iio_dev_attr_out_altvoltage0_out0_wavetype.dev_attr.attr,
+ &iio_dev_attr_out_altvoltage0_out1_wavetype.dev_attr.attr,
+ &iio_dev_attr_out_altvoltage0_out0_wavetype_available.dev_attr.attr,
+ &iio_dev_attr_out_altvoltage0_out1_wavetype_available.dev_attr.attr,
NULL,
};
static struct attribute *ad9833_attributes[] = {
- &iio_dev_attr_dds0_freq0.dev_attr.attr,
- &iio_dev_attr_dds0_freq1.dev_attr.attr,
- &iio_const_attr_dds0_freq_scale.dev_attr.attr,
- &iio_dev_attr_dds0_phase0.dev_attr.attr,
- &iio_dev_attr_dds0_phase1.dev_attr.attr,
- &iio_const_attr_dds0_phase_scale.dev_attr.attr,
- &iio_dev_attr_dds0_freqsymbol.dev_attr.attr,
- &iio_dev_attr_dds0_phasesymbol.dev_attr.attr,
- &iio_dev_attr_dds0_out_enable.dev_attr.attr,
- &iio_dev_attr_dds0_out0_wavetype.dev_attr.attr,
- &iio_dev_attr_dds0_out0_wavetype_available.dev_attr.attr,
+ &iio_dev_attr_out_altvoltage0_frequency0.dev_attr.attr,
+ &iio_dev_attr_out_altvoltage0_frequency1.dev_attr.attr,
+ &iio_const_attr_out_altvoltage0_frequency_scale.dev_attr.attr,
+ &iio_dev_attr_out_altvoltage0_phase0.dev_attr.attr,
+ &iio_dev_attr_out_altvoltage0_phase1.dev_attr.attr,
+ &iio_const_attr_out_altvoltage0_phase_scale.dev_attr.attr,
+ &iio_dev_attr_out_altvoltage0_frequencysymbol.dev_attr.attr,
+ &iio_dev_attr_out_altvoltage0_phasesymbol.dev_attr.attr,
+ &iio_dev_attr_out_altvoltage0_out_enable.dev_attr.attr,
+ &iio_dev_attr_out_altvoltage0_out0_wavetype.dev_attr.attr,
+ &iio_dev_attr_out_altvoltage0_out0_wavetype_available.dev_attr.attr,
NULL,
};
@@ -334,7 +334,7 @@ static int __devinit ad9834_probe(struct spi_device *spi)
goto error_put_reg;
}
- indio_dev = iio_allocate_device(sizeof(*st));
+ indio_dev = iio_device_alloc(sizeof(*st));
if (indio_dev == NULL) {
ret = -ENOMEM;
goto error_disable_reg;
@@ -414,7 +414,7 @@ static int __devinit ad9834_probe(struct spi_device *spi)
return 0;
error_free_device:
- iio_free_device(indio_dev);
+ iio_device_free(indio_dev);
error_disable_reg:
if (!IS_ERR(reg))
regulator_disable(reg);
@@ -434,7 +434,7 @@ static int __devexit ad9834_remove(struct spi_device *spi)
regulator_disable(st->reg);
regulator_put(st->reg);
}
- iio_free_device(indio_dev);
+ iio_device_free(indio_dev);
return 0;
}
diff --git a/drivers/staging/iio/dds/ad9834.h b/drivers/staging/iio/frequency/ad9834.h
index ed5ed8d0007f..ed5ed8d0007f 100644
--- a/drivers/staging/iio/dds/ad9834.h
+++ b/drivers/staging/iio/frequency/ad9834.h
diff --git a/drivers/staging/iio/dds/ad9850.c b/drivers/staging/iio/frequency/ad9850.c
index f4f731bb2191..74abee054ac0 100644
--- a/drivers/staging/iio/dds/ad9850.c
+++ b/drivers/staging/iio/frequency/ad9850.c
@@ -16,8 +16,8 @@
#include <linux/sysfs.h>
#include <linux/module.h>
-#include "../iio.h"
-#include "../sysfs.h"
+#include <linux/iio/iio.h>
+#include <linux/iio/sysfs.h>
#define DRV_NAME "ad9850"
@@ -43,7 +43,7 @@ static ssize_t ad9850_set_parameter(struct device *dev,
struct spi_transfer xfer;
int ret;
struct ad9850_config *config = (struct ad9850_config *)buf;
- struct iio_dev *idev = dev_get_drvdata(dev);
+ struct iio_dev *idev = dev_to_iio_dev(dev);
struct ad9850_state *st = iio_priv(idev);
xfer.len = len;
@@ -83,7 +83,7 @@ static int __devinit ad9850_probe(struct spi_device *spi)
struct iio_dev *idev;
int ret = 0;
- idev = iio_allocate_device(sizeof(*st));
+ idev = iio_device_alloc(sizeof(*st));
if (idev == NULL) {
ret = -ENOMEM;
goto error_ret;
@@ -108,7 +108,7 @@ static int __devinit ad9850_probe(struct spi_device *spi)
return 0;
error_free_dev:
- iio_free_device(idev);
+ iio_device_free(idev);
error_ret:
return ret;
}
@@ -116,7 +116,7 @@ error_ret:
static int __devexit ad9850_remove(struct spi_device *spi)
{
iio_device_unregister(spi_get_drvdata(spi));
- iio_free_device(spi_get_drvdata(spi));
+ iio_device_free(spi_get_drvdata(spi));
return 0;
}
diff --git a/drivers/staging/iio/dds/ad9852.c b/drivers/staging/iio/frequency/ad9852.c
index 554266c615a8..fd9d14a413a5 100644
--- a/drivers/staging/iio/dds/ad9852.c
+++ b/drivers/staging/iio/frequency/ad9852.c
@@ -16,8 +16,8 @@
#include <linux/sysfs.h>
#include <linux/module.h>
-#include "../iio.h"
-#include "../sysfs.h"
+#include <linux/iio/iio.h>
+#include <linux/iio/sysfs.h>
#define DRV_NAME "ad9852"
@@ -71,7 +71,7 @@ static ssize_t ad9852_set_parameter(struct device *dev,
struct spi_transfer xfer;
int ret;
struct ad9852_config *config = (struct ad9852_config *)buf;
- struct iio_dev *idev = dev_get_drvdata(dev);
+ struct iio_dev *idev = dev_to_iio_dev(dev);
struct ad9852_state *st = iio_priv(idev);
xfer.len = 3;
@@ -232,7 +232,7 @@ static int __devinit ad9852_probe(struct spi_device *spi)
struct iio_dev *idev;
int ret = 0;
- idev = iio_allocate_device(sizeof(*st));
+ idev = iio_device_alloc(sizeof(*st));
if (idev == NULL) {
ret = -ENOMEM;
goto error_ret;
@@ -258,7 +258,7 @@ static int __devinit ad9852_probe(struct spi_device *spi)
return 0;
error_free_dev:
- iio_free_device(idev);
+ iio_device_free(idev);
error_ret:
return ret;
@@ -267,7 +267,7 @@ error_ret:
static int __devexit ad9852_remove(struct spi_device *spi)
{
iio_device_unregister(spi_get_drvdata(spi));
- iio_free_device(spi_get_drvdata(spi));
+ iio_device_free(spi_get_drvdata(spi));
return 0;
}
diff --git a/drivers/staging/iio/dds/ad9910.c b/drivers/staging/iio/frequency/ad9910.c
index 3985766d6f87..5a7ba305b75a 100644
--- a/drivers/staging/iio/dds/ad9910.c
+++ b/drivers/staging/iio/frequency/ad9910.c
@@ -16,8 +16,8 @@
#include <linux/sysfs.h>
#include <linux/module.h>
-#include "../iio.h"
-#include "../sysfs.h"
+#include <linux/iio/iio.h>
+#include <linux/iio/sysfs.h>
#define DRV_NAME "ad9910"
@@ -123,7 +123,7 @@ static ssize_t ad9910_set_parameter(struct device *dev,
struct spi_transfer xfer;
int ret;
struct ad9910_config *config = (struct ad9910_config *)buf;
- struct iio_dev *idev = dev_get_drvdata(dev);
+ struct iio_dev *idev = dev_to_iio_dev(dev);
struct ad9910_state *st = iio_priv(idev);
xfer.len = 5;
@@ -367,7 +367,7 @@ static int __devinit ad9910_probe(struct spi_device *spi)
struct iio_dev *idev;
int ret = 0;
- idev = iio_allocate_device(sizeof(*st));
+ idev = iio_device_alloc(sizeof(*st));
if (idev == NULL) {
ret = -ENOMEM;
goto error_ret;
@@ -392,7 +392,7 @@ static int __devinit ad9910_probe(struct spi_device *spi)
return 0;
error_free_dev:
- iio_free_device(idev);
+ iio_device_free(idev);
error_ret:
return ret;
}
@@ -400,7 +400,7 @@ error_ret:
static int __devexit ad9910_remove(struct spi_device *spi)
{
iio_device_unregister(spi_get_drvdata(spi));
- iio_free_device(spi_get_drvdata(spi));
+ iio_device_free(spi_get_drvdata(spi));
return 0;
}
diff --git a/drivers/staging/iio/dds/ad9951.c b/drivers/staging/iio/frequency/ad9951.c
index 4d150048002a..ba6f49ff09ae 100644
--- a/drivers/staging/iio/dds/ad9951.c
+++ b/drivers/staging/iio/frequency/ad9951.c
@@ -16,8 +16,8 @@
#include <linux/sysfs.h>
#include <linux/module.h>
-#include "../iio.h"
-#include "../sysfs.h"
+#include <linux/iio/iio.h>
+#include <linux/iio/sysfs.h>
#define DRV_NAME "ad9951"
@@ -64,7 +64,7 @@ static ssize_t ad9951_set_parameter(struct device *dev,
struct spi_transfer xfer;
int ret;
struct ad9951_config *config = (struct ad9951_config *)buf;
- struct iio_dev *idev = dev_get_drvdata(dev);
+ struct iio_dev *idev = dev_to_iio_dev(dev);
struct ad9951_state *st = iio_priv(idev);
xfer.len = 3;
@@ -176,7 +176,7 @@ static int __devinit ad9951_probe(struct spi_device *spi)
struct iio_dev *idev;
int ret = 0;
- idev = iio_allocate_device(sizeof(*st));
+ idev = iio_device_alloc(sizeof(*st));
if (idev == NULL) {
ret = -ENOMEM;
goto error_ret;
@@ -202,7 +202,7 @@ static int __devinit ad9951_probe(struct spi_device *spi)
return 0;
error_free_dev:
- iio_free_device(idev);
+ iio_device_free(idev);
error_ret:
return ret;
@@ -211,7 +211,7 @@ error_ret:
static int __devexit ad9951_remove(struct spi_device *spi)
{
iio_device_unregister(spi_get_drvdata(spi));
- iio_free_device(spi_get_drvdata(spi));
+ iio_device_free(spi_get_drvdata(spi));
return 0;
}
diff --git a/drivers/staging/iio/frequency/dds.h b/drivers/staging/iio/frequency/dds.h
new file mode 100644
index 000000000000..c3342f6e052b
--- /dev/null
+++ b/drivers/staging/iio/frequency/dds.h
@@ -0,0 +1,110 @@
+/*
+ * dds.h - sysfs attributes associated with DDS devices
+ *
+ * Copyright (c) 2010 Analog Devices Inc.
+ *
+ * Licensed under the GPL-2 or later.
+ */
+
+/**
+ * /sys/bus/iio/devices/.../out_altvoltageX_frequencyY
+ */
+
+#define IIO_DEV_ATTR_FREQ(_channel, _num, _mode, _show, _store, _addr) \
+ IIO_DEVICE_ATTR(out_altvoltage##_channel##_frequency##_num, \
+ _mode, _show, _store, _addr)
+
+/**
+ * /sys/bus/iio/devices/.../out_altvoltageX_frequencyY_scale
+ */
+
+#define IIO_CONST_ATTR_FREQ_SCALE(_channel, _string) \
+ IIO_CONST_ATTR(out_altvoltage##_channel##_frequency_scale, _string)
+
+/**
+ * /sys/bus/iio/devices/.../out_altvoltageX_frequencysymbol
+ */
+
+#define IIO_DEV_ATTR_FREQSYMBOL(_channel, _mode, _show, _store, _addr) \
+ IIO_DEVICE_ATTR(out_altvoltage##_channel##_frequencysymbol, \
+ _mode, _show, _store, _addr);
+
+/**
+ * /sys/bus/iio/devices/.../out_altvoltageX_phaseY
+ */
+
+#define IIO_DEV_ATTR_PHASE(_channel, _num, _mode, _show, _store, _addr) \
+ IIO_DEVICE_ATTR(out_altvoltage##_channel##_phase##_num, \
+ _mode, _show, _store, _addr)
+
+/**
+ * /sys/bus/iio/devices/.../out_altvoltageX_phaseY_scale
+ */
+
+#define IIO_CONST_ATTR_PHASE_SCALE(_channel, _string) \
+ IIO_CONST_ATTR(out_altvoltage##_channel##_phase_scale, _string)
+
+/**
+ * /sys/bus/iio/devices/.../out_altvoltageX_phasesymbol
+ */
+
+#define IIO_DEV_ATTR_PHASESYMBOL(_channel, _mode, _show, _store, _addr) \
+ IIO_DEVICE_ATTR(out_altvoltage##_channel##_phasesymbol, \
+ _mode, _show, _store, _addr);
+
+/**
+ * /sys/bus/iio/devices/.../out_altvoltageX_pincontrol_en
+ */
+
+#define IIO_DEV_ATTR_PINCONTROL_EN(_channel, _mode, _show, _store, _addr)\
+ IIO_DEVICE_ATTR(out_altvoltage##_channel##_pincontrol_en, \
+ _mode, _show, _store, _addr);
+
+/**
+ * /sys/bus/iio/devices/.../out_altvoltageX_pincontrol_frequency_en
+ */
+
+#define IIO_DEV_ATTR_PINCONTROL_FREQ_EN(_channel, _mode, _show, _store, _addr)\
+ IIO_DEVICE_ATTR(out_altvoltage##_channel##_pincontrol_frequency_en,\
+ _mode, _show, _store, _addr);
+
+/**
+ * /sys/bus/iio/devices/.../out_altvoltageX_pincontrol_phase_en
+ */
+
+#define IIO_DEV_ATTR_PINCONTROL_PHASE_EN(_channel, _mode, _show, _store, _addr)\
+ IIO_DEVICE_ATTR(out_altvoltage##_channel##_pincontrol_phase_en, \
+ _mode, _show, _store, _addr);
+
+/**
+ * /sys/bus/iio/devices/.../out_altvoltageX_out_enable
+ */
+
+#define IIO_DEV_ATTR_OUT_ENABLE(_channel, _mode, _show, _store, _addr) \
+ IIO_DEVICE_ATTR(out_altvoltage##_channel##_out_enable, \
+ _mode, _show, _store, _addr);
+
+/**
+ * /sys/bus/iio/devices/.../out_altvoltageX_outY_enable
+ */
+
+#define IIO_DEV_ATTR_OUTY_ENABLE(_channel, _output, \
+ _mode, _show, _store, _addr) \
+ IIO_DEVICE_ATTR(out_altvoltage##_channel##_out##_output##_enable,\
+ _mode, _show, _store, _addr);
+
+/**
+ * /sys/bus/iio/devices/.../out_altvoltageX_outY_wavetype
+ */
+
+#define IIO_DEV_ATTR_OUT_WAVETYPE(_channel, _output, _store, _addr) \
+ IIO_DEVICE_ATTR(out_altvoltage##_channel##_out##_output##_wavetype,\
+ S_IWUSR, NULL, _store, _addr);
+
+/**
+ * /sys/bus/iio/devices/.../out_altvoltageX_outY_wavetype_available
+ */
+
+#define IIO_CONST_ATTR_OUT_WAVETYPES_AVAILABLE(_channel, _output, _modes)\
+ IIO_CONST_ATTR( \
+ out_altvoltage##_channel##_out##_output##_wavetype_available, _modes);
diff --git a/drivers/staging/iio/gyro/adis16060_core.c b/drivers/staging/iio/gyro/adis16060_core.c
index 02cc23420b90..9931e2060e1f 100644
--- a/drivers/staging/iio/gyro/adis16060_core.c
+++ b/drivers/staging/iio/gyro/adis16060_core.c
@@ -15,8 +15,8 @@
#include <linux/slab.h>
#include <linux/sysfs.h>
-#include "../iio.h"
-#include "../sysfs.h"
+#include <linux/iio/iio.h>
+#include <linux/iio/sysfs.h>
#define ADIS16060_GYRO 0x20 /* Measure Angular Rate (Gyro) */
#define ADIS16060_TEMP_OUT 0x10 /* Measure Temperature */
@@ -85,7 +85,7 @@ static int adis16060_read_raw(struct iio_dev *indio_dev,
int ret;
switch (mask) {
- case 0:
+ case IIO_CHAN_INFO_RAW:
/* Take the iio_dev status lock */
mutex_lock(&indio_dev->mlock);
ret = adis16060_spi_write(indio_dev, chan->address);
@@ -120,22 +120,26 @@ static const struct iio_chan_spec adis16060_channels[] = {
.type = IIO_ANGL_VEL,
.modified = 1,
.channel2 = IIO_MOD_Z,
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT,
.address = ADIS16060_GYRO,
}, {
.type = IIO_VOLTAGE,
.indexed = 1,
.channel = 0,
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT,
.address = ADIS16060_AIN1,
}, {
.type = IIO_VOLTAGE,
.indexed = 1,
.channel = 1,
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT,
.address = ADIS16060_AIN2,
}, {
.type = IIO_TEMP,
.indexed = 1,
.channel = 0,
- .info_mask = IIO_CHAN_INFO_OFFSET_SEPARATE_BIT |
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
+ IIO_CHAN_INFO_OFFSET_SEPARATE_BIT |
IIO_CHAN_INFO_SCALE_SEPARATE_BIT,
.address = ADIS16060_TEMP_OUT,
}
@@ -148,7 +152,7 @@ static int __devinit adis16060_r_probe(struct spi_device *spi)
struct iio_dev *indio_dev;
/* setup the industrialio driver allocated elements */
- indio_dev = iio_allocate_device(sizeof(*st));
+ indio_dev = iio_device_alloc(sizeof(*st));
if (indio_dev == NULL) {
ret = -ENOMEM;
goto error_ret;
@@ -174,7 +178,7 @@ static int __devinit adis16060_r_probe(struct spi_device *spi)
return 0;
error_free_dev:
- iio_free_device(indio_dev);
+ iio_device_free(indio_dev);
error_ret:
return ret;
}
@@ -183,7 +187,7 @@ error_ret:
static int adis16060_r_remove(struct spi_device *spi)
{
iio_device_unregister(spi_get_drvdata(spi));
- iio_free_device(spi_get_drvdata(spi));
+ iio_device_free(spi_get_drvdata(spi));
return 0;
}
diff --git a/drivers/staging/iio/gyro/adis16080_core.c b/drivers/staging/iio/gyro/adis16080_core.c
index 1815490db8b4..345e4fa778ba 100644
--- a/drivers/staging/iio/gyro/adis16080_core.c
+++ b/drivers/staging/iio/gyro/adis16080_core.c
@@ -14,8 +14,8 @@
#include <linux/sysfs.h>
#include <linux/module.h>
-#include "../iio.h"
-#include "../sysfs.h"
+#include <linux/iio/iio.h>
+#include <linux/iio/sysfs.h>
#define ADIS16080_DIN_GYRO (0 << 10) /* Gyroscope output */
#define ADIS16080_DIN_TEMP (1 << 10) /* Temperature output */
@@ -82,12 +82,12 @@ static int adis16080_read_raw(struct iio_dev *indio_dev,
long mask)
{
int ret = -EINVAL;
- u16 ut;
+ u16 ut = 0;
/* Take the iio_dev status lock */
mutex_lock(&indio_dev->mlock);
switch (mask) {
- case 0:
+ case IIO_CHAN_INFO_RAW:
ret = adis16080_spi_write(indio_dev,
chan->address |
ADIS16080_DIN_WRITE);
@@ -110,21 +110,25 @@ static const struct iio_chan_spec adis16080_channels[] = {
.type = IIO_ANGL_VEL,
.modified = 1,
.channel2 = IIO_MOD_Z,
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT,
.address = ADIS16080_DIN_GYRO,
}, {
.type = IIO_VOLTAGE,
.indexed = 1,
.channel = 0,
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT,
.address = ADIS16080_DIN_AIN1,
}, {
.type = IIO_VOLTAGE,
.indexed = 1,
.channel = 1,
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT,
.address = ADIS16080_DIN_AIN2,
}, {
.type = IIO_TEMP,
.indexed = 1,
.channel = 0,
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT,
.address = ADIS16080_DIN_TEMP,
}
};
@@ -141,7 +145,7 @@ static int __devinit adis16080_probe(struct spi_device *spi)
struct iio_dev *indio_dev;
/* setup the industrialio driver allocated elements */
- indio_dev = iio_allocate_device(sizeof(*st));
+ indio_dev = iio_device_alloc(sizeof(*st));
if (indio_dev == NULL) {
ret = -ENOMEM;
goto error_ret;
@@ -167,7 +171,7 @@ static int __devinit adis16080_probe(struct spi_device *spi)
return 0;
error_free_dev:
- iio_free_device(indio_dev);
+ iio_device_free(indio_dev);
error_ret:
return ret;
}
@@ -176,7 +180,7 @@ error_ret:
static int adis16080_remove(struct spi_device *spi)
{
iio_device_unregister(spi_get_drvdata(spi));
- iio_free_device(spi_get_drvdata(spi));
+ iio_device_free(spi_get_drvdata(spi));
return 0;
}
diff --git a/drivers/staging/iio/gyro/adis16130_core.c b/drivers/staging/iio/gyro/adis16130_core.c
index 947eb86f05d8..bf61cd0b5bbc 100644
--- a/drivers/staging/iio/gyro/adis16130_core.c
+++ b/drivers/staging/iio/gyro/adis16130_core.c
@@ -16,8 +16,8 @@
#include <linux/list.h>
#include <linux/module.h>
-#include "../iio.h"
-#include "../sysfs.h"
+#include <linux/iio/iio.h>
+#include <linux/iio/sysfs.h>
#define ADIS16130_CON 0x0
#define ADIS16130_CON_RD (1 << 6)
@@ -100,11 +100,13 @@ static const struct iio_chan_spec adis16130_channels[] = {
.type = IIO_ANGL_VEL,
.modified = 1,
.channel2 = IIO_MOD_Z,
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT,
.address = ADIS16130_RATEDATA,
}, {
.type = IIO_TEMP,
.indexed = 1,
.channel = 0,
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT,
.address = ADIS16130_TEMPDATA,
}
};
@@ -121,7 +123,7 @@ static int __devinit adis16130_probe(struct spi_device *spi)
struct iio_dev *indio_dev;
/* setup the industrialio driver allocated elements */
- indio_dev = iio_allocate_device(sizeof(*st));
+ indio_dev = iio_device_alloc(sizeof(*st));
if (indio_dev == NULL) {
ret = -ENOMEM;
goto error_ret;
@@ -145,7 +147,7 @@ static int __devinit adis16130_probe(struct spi_device *spi)
return 0;
error_free_dev:
- iio_free_device(indio_dev);
+ iio_device_free(indio_dev);
error_ret:
return ret;
@@ -155,7 +157,7 @@ error_ret:
static int adis16130_remove(struct spi_device *spi)
{
iio_device_unregister(spi_get_drvdata(spi));
- iio_free_device(spi_get_drvdata(spi));
+ iio_device_free(spi_get_drvdata(spi));
return 0;
}
diff --git a/drivers/staging/iio/gyro/adis16260_core.c b/drivers/staging/iio/gyro/adis16260_core.c
index 8f6af47e9559..93aa431287ac 100644
--- a/drivers/staging/iio/gyro/adis16260_core.c
+++ b/drivers/staging/iio/gyro/adis16260_core.c
@@ -18,9 +18,9 @@
#include <linux/list.h>
#include <linux/module.h>
-#include "../iio.h"
-#include "../sysfs.h"
-#include "../buffer.h"
+#include <linux/iio/iio.h>
+#include <linux/iio/sysfs.h>
+#include <linux/iio/buffer.h>
#include "adis16260.h"
@@ -149,7 +149,7 @@ static ssize_t adis16260_read_frequency_available(struct device *dev,
struct device_attribute *attr,
char *buf)
{
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct adis16260_state *st = iio_priv(indio_dev);
if (spi_get_device_id(st->us)->driver_data)
return sprintf(buf, "%s\n", "0.129 ~ 256");
@@ -161,7 +161,7 @@ static ssize_t adis16260_read_frequency(struct device *dev,
struct device_attribute *attr,
char *buf)
{
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct adis16260_state *st = iio_priv(indio_dev);
int ret, len = 0;
u16 t;
@@ -186,7 +186,7 @@ static ssize_t adis16260_write_frequency(struct device *dev,
const char *buf,
size_t len)
{
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct adis16260_state *st = iio_priv(indio_dev);
long val;
int ret;
@@ -233,22 +233,6 @@ static int adis16260_reset(struct iio_dev *indio_dev)
return ret;
}
-static ssize_t adis16260_write_reset(struct device *dev,
- struct device_attribute *attr,
- const char *buf, size_t len)
-{
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
- if (len < 1)
- return -EINVAL;
- switch (buf[0]) {
- case '1':
- case 'y':
- case 'Y':
- return adis16260_reset(indio_dev);
- }
- return -EINVAL;
-}
-
int adis16260_set_irq(struct iio_dev *indio_dev, bool enable)
{
int ret;
@@ -375,8 +359,6 @@ static IIO_DEV_ATTR_SAMP_FREQ(S_IWUSR | S_IRUGO,
adis16260_read_frequency,
adis16260_write_frequency);
-static IIO_DEVICE_ATTR(reset, S_IWUSR, NULL, adis16260_write_reset, 0);
-
static IIO_DEVICE_ATTR(sampling_frequency_available,
S_IRUGO, adis16260_read_frequency_available, NULL, 0);
@@ -389,30 +371,76 @@ enum adis16260_channel {
};
#define ADIS16260_GYRO_CHANNEL_SET(axis, mod) \
struct iio_chan_spec adis16260_channels_##axis[] = { \
- IIO_CHAN(IIO_ANGL_VEL, 1, 0, 0, NULL, 0, mod, \
- IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT | \
- IIO_CHAN_INFO_CALIBSCALE_SEPARATE_BIT | \
- IIO_CHAN_INFO_SCALE_SEPARATE_BIT, \
- gyro, ADIS16260_SCAN_GYRO, \
- IIO_ST('s', 14, 16, 0), 0), \
- IIO_CHAN(IIO_ANGL, 1, 0, 0, NULL, 0, mod, \
- 0, \
- angle, ADIS16260_SCAN_ANGL, \
- IIO_ST('u', 14, 16, 0), 0), \
- IIO_CHAN(IIO_TEMP, 0, 1, 0, NULL, 0, 0, \
- IIO_CHAN_INFO_OFFSET_SEPARATE_BIT | \
- IIO_CHAN_INFO_SCALE_SEPARATE_BIT, \
- temp, ADIS16260_SCAN_TEMP, \
- IIO_ST('u', 12, 16, 0), 0), \
- IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, "supply", 0, 0, \
- IIO_CHAN_INFO_SCALE_SEPARATE_BIT, \
- in_supply, ADIS16260_SCAN_SUPPLY, \
- IIO_ST('u', 12, 16, 0), 0), \
- IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, NULL, 1, 0, \
- IIO_CHAN_INFO_SCALE_SEPARATE_BIT, \
- in_aux, ADIS16260_SCAN_AUX_ADC, \
- IIO_ST('u', 12, 16, 0), 0), \
- IIO_CHAN_SOFT_TIMESTAMP(5) \
+ { \
+ .type = IIO_ANGL_VEL, \
+ .modified = 1, \
+ .channel2 = mod, \
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT | \
+ IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT | \
+ IIO_CHAN_INFO_CALIBSCALE_SEPARATE_BIT | \
+ IIO_CHAN_INFO_SCALE_SEPARATE_BIT, \
+ .address = gyro, \
+ .scan_index = ADIS16260_SCAN_GYRO, \
+ .scan_type = { \
+ .sign = 's', \
+ .realbits = 14, \
+ .storagebits = 16, \
+ }, \
+ }, { \
+ .type = IIO_ANGL, \
+ .modified = 1, \
+ .channel2 = mod, \
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT, \
+ .address = angle, \
+ .scan_index = ADIS16260_SCAN_ANGL, \
+ .scan_type = { \
+ .sign = 'u', \
+ .realbits = 14, \
+ .storagebits = 16, \
+ }, \
+ }, { \
+ .type = IIO_TEMP, \
+ .indexed = 1, \
+ .channel = 0, \
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT | \
+ IIO_CHAN_INFO_OFFSET_SEPARATE_BIT | \
+ IIO_CHAN_INFO_SCALE_SEPARATE_BIT, \
+ .address = temp, \
+ .scan_index = ADIS16260_SCAN_TEMP, \
+ .scan_type = { \
+ .sign = 'u', \
+ .realbits = 12, \
+ .storagebits = 16, \
+ }, \
+ }, { \
+ .type = IIO_VOLTAGE, \
+ .indexed = 1, \
+ .channel = 0, \
+ .extend_name = "supply", \
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT | \
+ IIO_CHAN_INFO_SCALE_SEPARATE_BIT, \
+ .address = in_supply, \
+ .scan_index = ADIS16260_SCAN_SUPPLY, \
+ .scan_type = { \
+ .sign = 'u', \
+ .realbits = 12, \
+ .storagebits = 16, \
+ }, \
+ }, { \
+ .type = IIO_VOLTAGE, \
+ .indexed = 1, \
+ .channel = 1, \
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT | \
+ IIO_CHAN_INFO_SCALE_SEPARATE_BIT, \
+ .address = in_aux, \
+ .scan_index = ADIS16260_SCAN_AUX_ADC, \
+ .scan_type = { \
+ .sign = 'u', \
+ .realbits = 12, \
+ .storagebits = 16, \
+ }, \
+ }, \
+ IIO_CHAN_SOFT_TIMESTAMP(5), \
}
static const ADIS16260_GYRO_CHANNEL_SET(x, IIO_MOD_X);
@@ -440,7 +468,7 @@ static int adis16260_read_raw(struct iio_dev *indio_dev,
s16 val16;
switch (mask) {
- case 0:
+ case IIO_CHAN_INFO_RAW:
mutex_lock(&indio_dev->mlock);
addr = adis16260_addresses[chan->address][0];
ret = adis16260_spi_read_reg_16(indio_dev, addr, &val16);
@@ -558,7 +586,6 @@ static int adis16260_write_raw(struct iio_dev *indio_dev,
static struct attribute *adis16260_attributes[] = {
&iio_dev_attr_sampling_frequency.dev_attr.attr,
&iio_dev_attr_sampling_frequency_available.dev_attr.attr,
- &iio_dev_attr_reset.dev_attr.attr,
NULL
};
@@ -581,7 +608,7 @@ static int __devinit adis16260_probe(struct spi_device *spi)
struct iio_dev *indio_dev;
/* setup the industrialio driver allocated elements */
- indio_dev = iio_allocate_device(sizeof(*st));
+ indio_dev = iio_device_alloc(sizeof(*st));
if (indio_dev == NULL) {
ret = -ENOMEM;
goto error_ret;
@@ -590,7 +617,7 @@ static int __devinit adis16260_probe(struct spi_device *spi)
if (pd)
st->negate = pd->negate;
/* this is only used for removal purposes */
- spi_set_drvdata(spi, st);
+ spi_set_drvdata(spi, indio_dev);
st->us = spi;
mutex_init(&st->buf_lock);
@@ -666,7 +693,7 @@ error_uninitialize_ring:
error_unreg_ring_funcs:
adis16260_unconfigure_ring(indio_dev);
error_free_dev:
- iio_free_device(indio_dev);
+ iio_device_free(indio_dev);
error_ret:
return ret;
}
@@ -682,12 +709,10 @@ static int adis16260_remove(struct spi_device *spi)
if (ret)
goto err_ret;
- flush_scheduled_work();
-
adis16260_remove_trigger(indio_dev);
iio_buffer_unregister(indio_dev);
adis16260_unconfigure_ring(indio_dev);
- iio_free_device(indio_dev);
+ iio_device_free(indio_dev);
err_ret:
return ret;
diff --git a/drivers/staging/iio/gyro/adis16260_ring.c b/drivers/staging/iio/gyro/adis16260_ring.c
index 711f15122a08..eeee8e760e6c 100644
--- a/drivers/staging/iio/gyro/adis16260_ring.c
+++ b/drivers/staging/iio/gyro/adis16260_ring.c
@@ -5,20 +5,19 @@
#include <linux/spi/spi.h>
#include <linux/slab.h>
-#include "../iio.h"
+#include <linux/iio/iio.h>
#include "../ring_sw.h"
-#include "../trigger_consumer.h"
+#include <linux/iio/trigger_consumer.h>
#include "adis16260.h"
/**
* adis16260_read_ring_data() read data registers which will be placed into ring
- * @dev: device associated with child of actual device (iio_dev or iio_trig)
+ * @indio_dev: the IIO device
* @rx: somewhere to pass back the value read
**/
-static int adis16260_read_ring_data(struct device *dev, u8 *rx)
+static int adis16260_read_ring_data(struct iio_dev *indio_dev, u8 *rx)
{
struct spi_message msg;
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
struct adis16260_state *st = iio_priv(indio_dev);
struct spi_transfer xfers[ADIS16260_OUTPUTS + 1];
int ret;
@@ -66,28 +65,28 @@ static irqreturn_t adis16260_trigger_handler(int irq, void *p)
struct iio_buffer *ring = indio_dev->buffer;
int i = 0;
s16 *data;
- size_t datasize = ring->access->get_bytes_per_datum(ring);
- data = kmalloc(datasize , GFP_KERNEL);
+ data = kmalloc(indio_dev->scan_bytes, GFP_KERNEL);
if (data == NULL) {
dev_err(&st->us->dev, "memory alloc failed in ring bh");
- return -ENOMEM;
+ goto done;
}
if (!bitmap_empty(indio_dev->active_scan_mask, indio_dev->masklength) &&
- adis16260_read_ring_data(&indio_dev->dev, st->rx) >= 0)
+ adis16260_read_ring_data(indio_dev, st->rx) >= 0)
for (; i < bitmap_weight(indio_dev->active_scan_mask,
indio_dev->masklength); i++)
data[i] = be16_to_cpup((__be16 *)&(st->rx[i*2]));
/* Guaranteed to be aligned with 8 byte boundary */
- if (ring->scan_timestamp)
+ if (indio_dev->scan_timestamp)
*((s64 *)(data + ((i + 3)/4)*4)) = pf->timestamp;
ring->access->store_to(ring, (u8 *)data, pf->timestamp);
- iio_trigger_notify_done(indio_dev->trig);
kfree(data);
+done:
+ iio_trigger_notify_done(indio_dev->trig);
return IRQ_HANDLED;
}
diff --git a/drivers/staging/iio/gyro/adis16260_trigger.c b/drivers/staging/iio/gyro/adis16260_trigger.c
index 8299cd18d705..034559e4d5b9 100644
--- a/drivers/staging/iio/gyro/adis16260_trigger.c
+++ b/drivers/staging/iio/gyro/adis16260_trigger.c
@@ -3,8 +3,8 @@
#include <linux/spi/spi.h>
#include <linux/export.h>
-#include "../iio.h"
-#include "../trigger.h"
+#include <linux/iio/iio.h>
+#include <linux/iio/trigger.h>
#include "adis16260.h"
/**
@@ -29,7 +29,7 @@ int adis16260_probe_trigger(struct iio_dev *indio_dev)
int ret;
struct adis16260_state *st = iio_priv(indio_dev);
- st->trig = iio_allocate_trigger("%s-dev%d",
+ st->trig = iio_trigger_alloc("%s-dev%d",
spi_get_device_id(st->us)->name,
indio_dev->id);
if (st->trig == NULL) {
@@ -60,7 +60,7 @@ int adis16260_probe_trigger(struct iio_dev *indio_dev)
error_free_irq:
free_irq(st->us->irq, st->trig);
error_free_trig:
- iio_free_trigger(st->trig);
+ iio_trigger_free(st->trig);
error_ret:
return ret;
}
@@ -71,5 +71,5 @@ void adis16260_remove_trigger(struct iio_dev *indio_dev)
iio_trigger_unregister(st->trig);
free_irq(st->us->irq, st->trig);
- iio_free_trigger(st->trig);
+ iio_trigger_free(st->trig);
}
diff --git a/drivers/staging/iio/gyro/adxrs450.h b/drivers/staging/iio/gyro/adxrs450.h
index af0c870100b6..f8cf21f02943 100644
--- a/drivers/staging/iio/gyro/adxrs450.h
+++ b/drivers/staging/iio/gyro/adxrs450.h
@@ -49,7 +49,7 @@ enum {
* @us: actual spi_device
* @buf_lock: mutex to protect tx and rx
* @tx: transmit buffer
- * @rx: recieve buffer
+ * @rx: receive buffer
**/
struct adxrs450_state {
struct spi_device *us;
diff --git a/drivers/staging/iio/gyro/adxrs450_core.c b/drivers/staging/iio/gyro/adxrs450_core.c
index 15e2496f70c8..6513119b1e90 100644
--- a/drivers/staging/iio/gyro/adxrs450_core.c
+++ b/drivers/staging/iio/gyro/adxrs450_core.c
@@ -18,8 +18,8 @@
#include <linux/list.h>
#include <linux/module.h>
-#include "../iio.h"
-#include "../sysfs.h"
+#include <linux/iio/iio.h>
+#include <linux/iio/sysfs.h>
#include "adxrs450.h"
@@ -265,7 +265,7 @@ static int adxrs450_read_raw(struct iio_dev *indio_dev,
s16 t;
switch (mask) {
- case 0:
+ case IIO_CHAN_INFO_RAW:
switch (chan->type) {
case IIO_ANGL_VEL:
ret = adxrs450_spi_sensor_data(indio_dev, &t);
@@ -329,14 +329,16 @@ static const struct iio_chan_spec adxrs450_channels[2][2] = {
.type = IIO_ANGL_VEL,
.modified = 1,
.channel2 = IIO_MOD_Z,
- .info_mask = IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT |
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
+ IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT |
IIO_CHAN_INFO_QUADRATURE_CORRECTION_RAW_SEPARATE_BIT |
IIO_CHAN_INFO_SCALE_SEPARATE_BIT,
}, {
.type = IIO_TEMP,
.indexed = 1,
.channel = 0,
- .info_mask = IIO_CHAN_INFO_SCALE_SEPARATE_BIT,
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
+ IIO_CHAN_INFO_SCALE_SEPARATE_BIT,
}
},
[ID_ADXRS453] = {
@@ -344,13 +346,15 @@ static const struct iio_chan_spec adxrs450_channels[2][2] = {
.type = IIO_ANGL_VEL,
.modified = 1,
.channel2 = IIO_MOD_Z,
- .info_mask = IIO_CHAN_INFO_SCALE_SEPARATE_BIT |
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
+ IIO_CHAN_INFO_SCALE_SEPARATE_BIT |
IIO_CHAN_INFO_QUADRATURE_CORRECTION_RAW_SEPARATE_BIT,
}, {
.type = IIO_TEMP,
.indexed = 1,
.channel = 0,
- .info_mask = IIO_CHAN_INFO_SCALE_SEPARATE_BIT,
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
+ IIO_CHAN_INFO_SCALE_SEPARATE_BIT,
}
},
};
@@ -368,7 +372,7 @@ static int __devinit adxrs450_probe(struct spi_device *spi)
struct iio_dev *indio_dev;
/* setup the industrialio driver allocated elements */
- indio_dev = iio_allocate_device(sizeof(*st));
+ indio_dev = iio_device_alloc(sizeof(*st));
if (indio_dev == NULL) {
ret = -ENOMEM;
goto error_ret;
@@ -399,7 +403,7 @@ static int __devinit adxrs450_probe(struct spi_device *spi)
error_initial:
iio_device_unregister(indio_dev);
error_free_dev:
- iio_free_device(indio_dev);
+ iio_device_free(indio_dev);
error_ret:
return ret;
@@ -408,7 +412,7 @@ error_ret:
static int adxrs450_remove(struct spi_device *spi)
{
iio_device_unregister(spi_get_drvdata(spi));
- iio_free_device(spi_get_drvdata(spi));
+ iio_device_free(spi_get_drvdata(spi));
return 0;
}
diff --git a/drivers/staging/iio/iio.h b/drivers/staging/iio/iio.h
deleted file mode 100644
index b9cd454f69e2..000000000000
--- a/drivers/staging/iio/iio.h
+++ /dev/null
@@ -1,471 +0,0 @@
-
-/* The industrial I/O core
- *
- * Copyright (c) 2008 Jonathan Cameron
- *
- * 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 _INDUSTRIAL_IO_H_
-#define _INDUSTRIAL_IO_H_
-
-#include <linux/device.h>
-#include <linux/cdev.h>
-#include "types.h"
-/* IIO TODO LIST */
-/*
- * Provide means of adjusting timer accuracy.
- * Currently assumes nano seconds.
- */
-
-enum iio_data_type {
- IIO_RAW,
- IIO_PROCESSED,
-};
-
-/* Could add the raw attributes as well - allowing buffer only devices */
-enum iio_chan_info_enum {
- /* 0 is reserved for raw attributes */
- IIO_CHAN_INFO_SCALE = 1,
- IIO_CHAN_INFO_OFFSET,
- IIO_CHAN_INFO_CALIBSCALE,
- IIO_CHAN_INFO_CALIBBIAS,
- IIO_CHAN_INFO_PEAK,
- IIO_CHAN_INFO_PEAK_SCALE,
- IIO_CHAN_INFO_QUADRATURE_CORRECTION_RAW,
- IIO_CHAN_INFO_AVERAGE_RAW,
- IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY,
-};
-
-#define IIO_CHAN_INFO_SHARED_BIT(type) BIT(type*2)
-#define IIO_CHAN_INFO_SEPARATE_BIT(type) BIT(type*2 + 1)
-
-#define IIO_CHAN_INFO_SCALE_SEPARATE_BIT \
- IIO_CHAN_INFO_SEPARATE_BIT(IIO_CHAN_INFO_SCALE)
-#define IIO_CHAN_INFO_SCALE_SHARED_BIT \
- IIO_CHAN_INFO_SHARED_BIT(IIO_CHAN_INFO_SCALE)
-#define IIO_CHAN_INFO_OFFSET_SEPARATE_BIT \
- IIO_CHAN_INFO_SEPARATE_BIT(IIO_CHAN_INFO_OFFSET)
-#define IIO_CHAN_INFO_OFFSET_SHARED_BIT \
- IIO_CHAN_INFO_SHARED_BIT(IIO_CHAN_INFO_OFFSET)
-#define IIO_CHAN_INFO_CALIBSCALE_SEPARATE_BIT \
- IIO_CHAN_INFO_SEPARATE_BIT(IIO_CHAN_INFO_CALIBSCALE)
-#define IIO_CHAN_INFO_CALIBSCALE_SHARED_BIT \
- IIO_CHAN_INFO_SHARED_BIT(IIO_CHAN_INFO_CALIBSCALE)
-#define IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT \
- IIO_CHAN_INFO_SEPARATE_BIT(IIO_CHAN_INFO_CALIBBIAS)
-#define IIO_CHAN_INFO_CALIBBIAS_SHARED_BIT \
- IIO_CHAN_INFO_SHARED_BIT(IIO_CHAN_INFO_CALIBBIAS)
-#define IIO_CHAN_INFO_PEAK_SEPARATE_BIT \
- IIO_CHAN_INFO_SEPARATE_BIT(IIO_CHAN_INFO_PEAK)
-#define IIO_CHAN_INFO_PEAK_SHARED_BIT \
- IIO_CHAN_INFO_SHARED_BIT(IIO_CHAN_INFO_PEAK)
-#define IIO_CHAN_INFO_PEAKSCALE_SEPARATE_BIT \
- IIO_CHAN_INFO_SEPARATE_BIT(IIO_CHAN_INFO_PEAKSCALE)
-#define IIO_CHAN_INFO_PEAKSCALE_SHARED_BIT \
- IIO_CHAN_INFO_SHARED_BIT(IIO_CHAN_INFO_PEAKSCALE)
-#define IIO_CHAN_INFO_QUADRATURE_CORRECTION_RAW_SEPARATE_BIT \
- IIO_CHAN_INFO_SEPARATE_BIT( \
- IIO_CHAN_INFO_QUADRATURE_CORRECTION_RAW)
-#define IIO_CHAN_INFO_QUADRATURE_CORRECTION_RAW_SHARED_BIT \
- IIO_CHAN_INFO_SHARED_BIT( \
- IIO_CHAN_INFO_QUADRATURE_CORRECTION_RAW)
-#define IIO_CHAN_INFO_AVERAGE_RAW_SEPARATE_BIT \
- IIO_CHAN_INFO_SEPARATE_BIT(IIO_CHAN_INFO_AVERAGE_RAW)
-#define IIO_CHAN_INFO_AVERAGE_RAW_SHARED_BIT \
- IIO_CHAN_INFO_SHARED_BIT(IIO_CHAN_INFO_AVERAGE_RAW)
-#define IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY_SHARED_BIT \
- IIO_CHAN_INFO_SHARED_BIT( \
- IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY)
-#define IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY_SEPARATE_BIT \
- IIO_CHAN_INFO_SEPARATE_BIT( \
- IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY)
-
-enum iio_endian {
- IIO_CPU,
- IIO_BE,
- IIO_LE,
-};
-
-struct iio_chan_spec;
-struct iio_dev;
-
-/**
- * struct iio_chan_spec_ext_info - Extended channel info attribute
- * @name: Info attribute name
- * @shared: Whether this attribute is shared between all channels.
- * @read: Read callback for this info attribute, may be NULL.
- * @write: Write callback for this info attribute, may be NULL.
- */
-struct iio_chan_spec_ext_info {
- const char *name;
- bool shared;
- ssize_t (*read)(struct iio_dev *, struct iio_chan_spec const *,
- char *buf);
- ssize_t (*write)(struct iio_dev *, struct iio_chan_spec const *,
- const char *buf, size_t len);
-};
-
-/**
- * struct iio_chan_spec - specification of a single channel
- * @type: What type of measurement is the channel making.
- * @channel: What number or name do we wish to assign the channel.
- * @channel2: If there is a second number for a differential
- * channel then this is it. If modified is set then the
- * value here specifies the modifier.
- * @address: Driver specific identifier.
- * @scan_index: Monotonic index to give ordering in scans when read
- * from a buffer.
- * @scan_type: Sign: 's' or 'u' to specify signed or unsigned
- * realbits: Number of valid bits of data
- * storage_bits: Realbits + padding
- * shift: Shift right by this before masking out
- * realbits.
- * endianness: little or big endian
- * @info_mask: What information is to be exported about this channel.
- * This includes calibbias, scale etc.
- * @event_mask: What events can this channel produce.
- * @ext_info: Array of extended info attributes for this channel.
- * The array is NULL terminated, the last element should
- * have it's name field set to NULL.
- * @extend_name: Allows labeling of channel attributes with an
- * informative name. Note this has no effect codes etc,
- * unlike modifiers.
- * @datasheet_name: A name used in in kernel mapping of channels. It should
- * correspond to the first name that the channel is referred
- * to by in the datasheet (e.g. IND), or the nearest
- * possible compound name (e.g. IND-INC).
- * @processed_val: Flag to specify the data access attribute should be
- * *_input rather than *_raw.
- * @modified: Does a modifier apply to this channel. What these are
- * depends on the channel type. Modifier is set in
- * channel2. Examples are IIO_MOD_X for axial sensors about
- * the 'x' axis.
- * @indexed: Specify the channel has a numerical index. If not,
- * the value in channel will be suppressed for attribute
- * but not for event codes. Typically set it to 0 when
- * the index is false.
- * @differential: Channel is differential.
- */
-struct iio_chan_spec {
- enum iio_chan_type type;
- int channel;
- int channel2;
- unsigned long address;
- int scan_index;
- struct {
- char sign;
- u8 realbits;
- u8 storagebits;
- u8 shift;
- enum iio_endian endianness;
- } scan_type;
- long info_mask;
- long event_mask;
- const struct iio_chan_spec_ext_info *ext_info;
- char *extend_name;
- const char *datasheet_name;
- unsigned processed_val:1;
- unsigned modified:1;
- unsigned indexed:1;
- unsigned output:1;
- unsigned differential:1;
-};
-
-#define IIO_ST(si, rb, sb, sh) \
- { .sign = si, .realbits = rb, .storagebits = sb, .shift = sh }
-
-/* Macro assumes input channels */
-#define IIO_CHAN(_type, _mod, _indexed, _proc, _name, _chan, _chan2, \
- _inf_mask, _address, _si, _stype, _event_mask) \
- { .type = _type, \
- .output = 0, \
- .modified = _mod, \
- .indexed = _indexed, \
- .processed_val = _proc, \
- .extend_name = _name, \
- .channel = _chan, \
- .channel2 = _chan2, \
- .info_mask = _inf_mask, \
- .address = _address, \
- .scan_index = _si, \
- .scan_type = _stype, \
- .event_mask = _event_mask }
-
-#define IIO_CHAN_SOFT_TIMESTAMP(_si) \
- { .type = IIO_TIMESTAMP, .channel = -1, \
- .scan_index = _si, .scan_type = IIO_ST('s', 64, 64, 0) }
-
-/**
- * iio_get_time_ns() - utility function to get a time stamp for events etc
- **/
-static inline s64 iio_get_time_ns(void)
-{
- struct timespec ts;
- /*
- * calls getnstimeofday.
- * If hrtimers then up to ns accurate, if not microsecond.
- */
- ktime_get_real_ts(&ts);
-
- return timespec_to_ns(&ts);
-}
-
-/* Device operating modes */
-#define INDIO_DIRECT_MODE 0x01
-#define INDIO_BUFFER_TRIGGERED 0x02
-#define INDIO_BUFFER_HARDWARE 0x08
-
-#define INDIO_ALL_BUFFER_MODES \
- (INDIO_BUFFER_TRIGGERED | INDIO_BUFFER_HARDWARE)
-
-struct iio_trigger; /* forward declaration */
-struct iio_dev;
-
-/**
- * struct iio_info - constant information about device
- * @driver_module: module structure used to ensure correct
- * ownership of chrdevs etc
- * @event_attrs: event control attributes
- * @attrs: general purpose device attributes
- * @read_raw: function to request a value from the device.
- * mask specifies which value. Note 0 means a reading of
- * the channel in question. Return value will specify the
- * type of value returned by the device. val and val2 will
- * contain the elements making up the returned value.
- * @write_raw: function to write a value to the device.
- * Parameters are the same as for read_raw.
- * @write_raw_get_fmt: callback function to query the expected
- * format/precision. If not set by the driver, write_raw
- * returns IIO_VAL_INT_PLUS_MICRO.
- * @read_event_config: find out if the event is enabled.
- * @write_event_config: set if the event is enabled.
- * @read_event_value: read a value associated with the event. Meaning
- * is event dependant. event_code specifies which event.
- * @write_event_value: write the value associated with the event.
- * Meaning is event dependent.
- * @validate_trigger: function to validate the trigger when the
- * current trigger gets changed.
- **/
-struct iio_info {
- struct module *driver_module;
- struct attribute_group *event_attrs;
- const struct attribute_group *attrs;
-
- int (*read_raw)(struct iio_dev *indio_dev,
- struct iio_chan_spec const *chan,
- int *val,
- int *val2,
- long mask);
-
- int (*write_raw)(struct iio_dev *indio_dev,
- struct iio_chan_spec const *chan,
- int val,
- int val2,
- long mask);
-
- int (*write_raw_get_fmt)(struct iio_dev *indio_dev,
- struct iio_chan_spec const *chan,
- long mask);
-
- int (*read_event_config)(struct iio_dev *indio_dev,
- u64 event_code);
-
- int (*write_event_config)(struct iio_dev *indio_dev,
- u64 event_code,
- int state);
-
- int (*read_event_value)(struct iio_dev *indio_dev,
- u64 event_code,
- int *val);
- int (*write_event_value)(struct iio_dev *indio_dev,
- u64 event_code,
- int val);
- int (*validate_trigger)(struct iio_dev *indio_dev,
- struct iio_trigger *trig);
- int (*update_scan_mode)(struct iio_dev *indio_dev,
- const unsigned long *scan_mask);
- int (*debugfs_reg_access)(struct iio_dev *indio_dev,
- unsigned reg, unsigned writeval,
- unsigned *readval);
-};
-
-/**
- * struct iio_buffer_setup_ops - buffer setup related callbacks
- * @preenable: [DRIVER] function to run prior to marking buffer enabled
- * @postenable: [DRIVER] function to run after marking buffer enabled
- * @predisable: [DRIVER] function to run prior to marking buffer
- * disabled
- * @postdisable: [DRIVER] function to run after marking buffer disabled
- */
-struct iio_buffer_setup_ops {
- int (*preenable)(struct iio_dev *);
- int (*postenable)(struct iio_dev *);
- int (*predisable)(struct iio_dev *);
- int (*postdisable)(struct iio_dev *);
-};
-
-/**
- * struct iio_dev - industrial I/O device
- * @id: [INTERN] used to identify device internally
- * @modes: [DRIVER] operating modes supported by device
- * @currentmode: [DRIVER] current operating mode
- * @dev: [DRIVER] device structure, should be assigned a parent
- * and owner
- * @event_interface: [INTERN] event chrdevs associated with interrupt lines
- * @buffer: [DRIVER] any buffer present
- * @mlock: [INTERN] lock used to prevent simultaneous device state
- * changes
- * @available_scan_masks: [DRIVER] optional array of allowed bitmasks
- * @masklength: [INTERN] the length of the mask established from
- * channels
- * @active_scan_mask: [INTERN] union of all scan masks requested by buffers
- * @trig: [INTERN] current device trigger (buffer modes)
- * @pollfunc: [DRIVER] function run on trigger being received
- * @channels: [DRIVER] channel specification structure table
- * @num_channels: [DRIVER] number of chanels specified in @channels.
- * @channel_attr_list: [INTERN] keep track of automatically created channel
- * attributes
- * @chan_attr_group: [INTERN] group for all attrs in base directory
- * @name: [DRIVER] name of the device.
- * @info: [DRIVER] callbacks and constant info from driver
- * @info_exist_lock: [INTERN] lock to prevent use during removal
- * @chrdev: [INTERN] associated character device
- * @groups: [INTERN] attribute groups
- * @groupcounter: [INTERN] index of next attribute group
- * @flags: [INTERN] file ops related flags including busy flag.
- * @debugfs_dentry: [INTERN] device specific debugfs dentry.
- * @cached_reg_addr: [INTERN] cached register address for debugfs reads.
- */
-struct iio_dev {
- int id;
-
- int modes;
- int currentmode;
- struct device dev;
-
- struct iio_event_interface *event_interface;
-
- struct iio_buffer *buffer;
- struct mutex mlock;
-
- const unsigned long *available_scan_masks;
- unsigned masklength;
- const unsigned long *active_scan_mask;
- struct iio_trigger *trig;
- struct iio_poll_func *pollfunc;
-
- struct iio_chan_spec const *channels;
- int num_channels;
-
- struct list_head channel_attr_list;
- struct attribute_group chan_attr_group;
- const char *name;
- const struct iio_info *info;
- struct mutex info_exist_lock;
- const struct iio_buffer_setup_ops *setup_ops;
- struct cdev chrdev;
-#define IIO_MAX_GROUPS 6
- const struct attribute_group *groups[IIO_MAX_GROUPS + 1];
- int groupcounter;
-
- unsigned long flags;
-#if defined(CONFIG_DEBUG_FS)
- struct dentry *debugfs_dentry;
- unsigned cached_reg_addr;
-#endif
-};
-
-/**
- * iio_find_channel_from_si() - get channel from its scan index
- * @indio_dev: device
- * @si: scan index to match
- */
-const struct iio_chan_spec
-*iio_find_channel_from_si(struct iio_dev *indio_dev, int si);
-
-/**
- * iio_device_register() - register a device with the IIO subsystem
- * @indio_dev: Device structure filled by the device driver
- **/
-int iio_device_register(struct iio_dev *indio_dev);
-
-/**
- * iio_device_unregister() - unregister a device from the IIO subsystem
- * @indio_dev: Device structure representing the device.
- **/
-void iio_device_unregister(struct iio_dev *indio_dev);
-
-/**
- * iio_push_event() - try to add event to the list for userspace reading
- * @indio_dev: IIO device structure
- * @ev_code: What event
- * @timestamp: When the event occurred
- **/
-int iio_push_event(struct iio_dev *indio_dev, u64 ev_code, s64 timestamp);
-
-extern struct bus_type iio_bus_type;
-
-/**
- * iio_put_device() - reference counted deallocation of struct device
- * @dev: the iio_device containing the device
- **/
-static inline void iio_put_device(struct iio_dev *indio_dev)
-{
- if (indio_dev)
- put_device(&indio_dev->dev);
-};
-
-/* Can we make this smaller? */
-#define IIO_ALIGN L1_CACHE_BYTES
-/**
- * iio_allocate_device() - allocate an iio_dev from a driver
- * @sizeof_priv: Space to allocate for private structure.
- **/
-struct iio_dev *iio_allocate_device(int sizeof_priv);
-
-static inline void *iio_priv(const struct iio_dev *indio_dev)
-{
- return (char *)indio_dev + ALIGN(sizeof(struct iio_dev), IIO_ALIGN);
-}
-
-static inline struct iio_dev *iio_priv_to_dev(void *priv)
-{
- return (struct iio_dev *)((char *)priv -
- ALIGN(sizeof(struct iio_dev), IIO_ALIGN));
-}
-
-/**
- * iio_free_device() - free an iio_dev from a driver
- * @dev: the iio_dev associated with the device
- **/
-void iio_free_device(struct iio_dev *indio_dev);
-
-/**
- * iio_buffer_enabled() - helper function to test if the buffer is enabled
- * @indio_dev: IIO device info structure for device
- **/
-static inline bool iio_buffer_enabled(struct iio_dev *indio_dev)
-{
- return indio_dev->currentmode
- & (INDIO_BUFFER_TRIGGERED | INDIO_BUFFER_HARDWARE);
-};
-
-/**
- * iio_get_debugfs_dentry() - helper function to get the debugfs_dentry
- * @indio_dev: IIO device info structure for device
- **/
-#if defined(CONFIG_DEBUG_FS)
-static inline struct dentry *iio_get_debugfs_dentry(struct iio_dev *indio_dev)
-{
- return indio_dev->debugfs_dentry;
-};
-#else
-static inline struct dentry *iio_get_debugfs_dentry(struct iio_dev *indio_dev)
-{
- return NULL;
-};
-#endif
-
-#endif /* _INDUSTRIAL_IO_H_ */
diff --git a/drivers/staging/iio/iio_core.h b/drivers/staging/iio/iio_core.h
deleted file mode 100644
index c9dfcba0bac8..000000000000
--- a/drivers/staging/iio/iio_core.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/* The industrial I/O core function defs.
- *
- * Copyright (c) 2008 Jonathan Cameron
- *
- * 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.
- *
- * These definitions are meant for use only within the IIO core, not individual
- * drivers.
- */
-
-#ifndef _IIO_CORE_H_
-#define _IIO_CORE_H_
-
-int __iio_add_chan_devattr(const char *postfix,
- struct iio_chan_spec const *chan,
- ssize_t (*func)(struct device *dev,
- struct device_attribute *attr,
- char *buf),
- ssize_t (*writefunc)(struct device *dev,
- struct device_attribute *attr,
- const char *buf,
- size_t len),
- u64 mask,
- bool generic,
- struct device *dev,
- struct list_head *attr_list);
-
-/* Event interface flags */
-#define IIO_BUSY_BIT_POS 1
-
-#ifdef CONFIG_IIO_BUFFER
-struct poll_table_struct;
-
-unsigned int iio_buffer_poll(struct file *filp,
- struct poll_table_struct *wait);
-ssize_t iio_buffer_read_first_n_outer(struct file *filp, char __user *buf,
- size_t n, loff_t *f_ps);
-
-
-#define iio_buffer_poll_addr (&iio_buffer_poll)
-#define iio_buffer_read_first_n_outer_addr (&iio_buffer_read_first_n_outer)
-
-#else
-
-#define iio_buffer_poll_addr NULL
-#define iio_buffer_read_first_n_outer_addr NULL
-
-#endif
-
-int iio_device_register_eventset(struct iio_dev *indio_dev);
-void iio_device_unregister_eventset(struct iio_dev *indio_dev);
-int iio_event_getfd(struct iio_dev *indio_dev);
-
-#endif
diff --git a/drivers/staging/iio/iio_core_trigger.h b/drivers/staging/iio/iio_core_trigger.h
deleted file mode 100644
index 6f7c56fcbe78..000000000000
--- a/drivers/staging/iio/iio_core_trigger.h
+++ /dev/null
@@ -1,46 +0,0 @@
-
-/* The industrial I/O core, trigger consumer handling functions
- *
- * Copyright (c) 2008 Jonathan Cameron
- *
- * 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.
- */
-
-#ifdef CONFIG_IIO_TRIGGER
-/**
- * iio_device_register_trigger_consumer() - set up an iio_dev to use triggers
- * @indio_dev: iio_dev associated with the device that will consume the trigger
- **/
-void iio_device_register_trigger_consumer(struct iio_dev *indio_dev);
-
-/**
- * iio_device_unregister_trigger_consumer() - reverse the registration process
- * @indio_dev: iio_dev associated with the device that consumed the trigger
- **/
-void iio_device_unregister_trigger_consumer(struct iio_dev *indio_dev);
-
-#else
-
-/**
- * iio_device_register_trigger_consumer() - set up an iio_dev to use triggers
- * @indio_dev: iio_dev associated with the device that will consume the trigger
- **/
-static int iio_device_register_trigger_consumer(struct iio_dev *indio_dev)
-{
- return 0;
-};
-
-/**
- * iio_device_unregister_trigger_consumer() - reverse the registration process
- * @indio_dev: iio_dev associated with the device that consumed the trigger
- **/
-static void iio_device_unregister_trigger_consumer(struct iio_dev *indio_dev)
-{
-};
-
-#endif /* CONFIG_TRIGGER_CONSUMER */
-
-
-
diff --git a/drivers/staging/iio/iio_dummy_evgen.c b/drivers/staging/iio/iio_dummy_evgen.c
index f39f346bf04f..0cd4fe916bf9 100644
--- a/drivers/staging/iio/iio_dummy_evgen.c
+++ b/drivers/staging/iio/iio_dummy_evgen.c
@@ -22,8 +22,8 @@
#include <linux/sysfs.h>
#include "iio_dummy_evgen.h"
-#include "iio.h"
-#include "sysfs.h"
+#include <linux/iio/iio.h>
+#include <linux/iio/sysfs.h>
/* Fiddly bit of faking and irq without hardware */
#define IIO_EVENTGEN_NO 10
diff --git a/drivers/staging/iio/iio_hwmon.c b/drivers/staging/iio/iio_hwmon.c
index a603a5f51f93..27d27ec9521f 100644
--- a/drivers/staging/iio/iio_hwmon.c
+++ b/drivers/staging/iio/iio_hwmon.c
@@ -14,8 +14,8 @@
#include <linux/platform_device.h>
#include <linux/hwmon.h>
#include <linux/hwmon-sysfs.h>
-#include "consumer.h"
-#include "types.h"
+#include <linux/iio/consumer.h>
+#include <linux/iio/types.h>
/**
* struct iio_hwmon_state - device instance state
@@ -51,12 +51,12 @@ static ssize_t iio_hwmon_read_val(struct device *dev,
* No locking between this pair, so theoretically possible
* the scale has changed.
*/
- ret = iio_st_read_channel_raw(&state->channels[sattr->index],
+ ret = iio_read_channel_raw(&state->channels[sattr->index],
&val);
if (ret < 0)
return ret;
- ret = iio_st_read_channel_scale(&state->channels[sattr->index],
+ ret = iio_read_channel_scale(&state->channels[sattr->index],
&scaleint, &scalepart);
if (ret < 0)
return ret;
@@ -106,7 +106,7 @@ static int __devinit iio_hwmon_probe(struct platform_device *pdev)
goto error_ret;
}
- st->channels = iio_st_channel_get_all(dev_name(&pdev->dev));
+ st->channels = iio_channel_get_all(dev_name(&pdev->dev));
if (IS_ERR(st->channels)) {
ret = PTR_ERR(st->channels);
goto error_free_state;
@@ -130,7 +130,7 @@ static int __devinit iio_hwmon_probe(struct platform_device *pdev)
}
sysfs_attr_init(&a->dev_attr.attr);
- ret = iio_st_get_channel_type(&st->channels[i], &type);
+ ret = iio_get_channel_type(&st->channels[i], &type);
if (ret < 0) {
kfree(a);
goto error_free_attrs;
@@ -186,7 +186,7 @@ error_free_attrs:
iio_hwmon_free_attrs(st);
kfree(st->attrs);
error_release_channels:
- iio_st_channel_release_all(st->channels);
+ iio_channel_release_all(st->channels);
error_free_state:
kfree(st);
error_ret:
@@ -201,7 +201,7 @@ static int __devexit iio_hwmon_remove(struct platform_device *pdev)
sysfs_remove_group(&pdev->dev.kobj, &st->attr_group);
iio_hwmon_free_attrs(st);
kfree(st->attrs);
- iio_st_channel_release_all(st->channels);
+ iio_channel_release_all(st->channels);
return 0;
}
diff --git a/drivers/staging/iio/iio_simple_dummy.c b/drivers/staging/iio/iio_simple_dummy.c
index e3a94572bb40..155a49a9da7e 100644
--- a/drivers/staging/iio/iio_simple_dummy.c
+++ b/drivers/staging/iio/iio_simple_dummy.c
@@ -19,15 +19,15 @@
#include <linux/module.h>
#include <linux/moduleparam.h>
-#include "iio.h"
-#include "sysfs.h"
-#include "events.h"
-#include "buffer.h"
+#include <linux/iio/iio.h>
+#include <linux/iio/sysfs.h>
+#include <linux/iio/events.h>
+#include <linux/iio/buffer.h>
#include "iio_simple_dummy.h"
/*
* A few elements needed to fake a bus for this driver
- * Note instances parmeter controls how many of these
+ * Note instances parameter controls how many of these
* dummy devices are registered.
*/
static unsigned instances = 1;
@@ -73,6 +73,12 @@ static struct iio_chan_spec iio_dummy_channels[] = {
/* What other information is available? */
.info_mask =
/*
+ * in_voltage0_raw
+ * Raw (unscaled no bias removal etc) measurement
+ * from the device.
+ */
+ IIO_CHAN_INFO_RAW_SEPARATE_BIT |
+ /*
* in_voltage0_offset
* Offset for userspace to apply prior to scale
* when converting to standard units (microvolts)
@@ -114,6 +120,12 @@ static struct iio_chan_spec iio_dummy_channels[] = {
.channel2 = 2,
.info_mask =
/*
+ * in_voltage1-voltage2_raw
+ * Raw (unscaled no bias removal etc) measurement
+ * from the device.
+ */
+ IIO_CHAN_INFO_RAW_SEPARATE_BIT |
+ /*
* in_voltage-voltage_scale
* Shared version of scale - shared by differential
* input channels of type IIO_VOLTAGE.
@@ -135,6 +147,7 @@ static struct iio_chan_spec iio_dummy_channels[] = {
.channel = 3,
.channel2 = 4,
.info_mask =
+ IIO_CHAN_INFO_RAW_SEPARATE_BIT |
IIO_CHAN_INFO_SCALE_SHARED_BIT,
.scan_index = diffvoltage3m4,
.scan_type = {
@@ -154,6 +167,7 @@ static struct iio_chan_spec iio_dummy_channels[] = {
/* Channel 2 is use for modifiers */
.channel2 = IIO_MOD_X,
.info_mask =
+ IIO_CHAN_INFO_RAW_SEPARATE_BIT |
/*
* Internal bias correction value. Applied
* by the hardware or driver prior to userspace
@@ -164,7 +178,7 @@ static struct iio_chan_spec iio_dummy_channels[] = {
.scan_index = accelx,
.scan_type = { /* Description of storage in buffer */
.sign = 's', /* signed */
- .realbits = 16, /* 12 bits */
+ .realbits = 16, /* 16 bits */
.storagebits = 16, /* 16 bits used for storage */
.shift = 0, /* zero shift */
},
@@ -177,6 +191,7 @@ static struct iio_chan_spec iio_dummy_channels[] = {
/* DAC channel out_voltage0_raw */
{
.type = IIO_VOLTAGE,
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT,
.output = 1,
.indexed = 1,
.channel = 0,
@@ -203,7 +218,7 @@ static int iio_dummy_read_raw(struct iio_dev *indio_dev,
mutex_lock(&st->lock);
switch (mask) {
- case 0: /* magic value - channel value read */
+ case IIO_CHAN_INFO_RAW: /* magic value - channel value read */
switch (chan->type) {
case IIO_VOLTAGE:
if (chan->output) {
@@ -270,9 +285,9 @@ static int iio_dummy_read_raw(struct iio_dev *indio_dev,
* iio_dummy_write_raw() - data write function.
* @indio_dev: the struct iio_dev associated with this device instance
* @chan: the channel whose data is to be read
- * @val: first element of returned value (typically INT)
- * @val2: second element of returned value (typically MICRO)
- * @mask: what we actually want to read. 0 is the channel, everything else
+ * @val: first element of value to set (typically INT)
+ * @val2: second element of value to set (typically MICRO)
+ * @mask: what we actually want to write. 0 is the channel, everything else
* is as per the info_mask in iio_chan_spec.
*
* Note that all raw writes are assumed IIO_VAL_INT and info mask elements
@@ -290,7 +305,7 @@ static int iio_dummy_write_raw(struct iio_dev *indio_dev,
struct iio_dummy_state *st = iio_priv(indio_dev);
switch (mask) {
- case 0:
+ case IIO_CHAN_INFO_RAW:
if (chan->output == 0)
return -EINVAL;
@@ -377,7 +392,7 @@ static int __devinit iio_dummy_probe(int index)
* It also has a region (accessed by iio_priv()
* for chip specific state information.
*/
- indio_dev = iio_allocate_device(sizeof(*st));
+ indio_dev = iio_device_alloc(sizeof(*st));
if (indio_dev == NULL) {
ret = -ENOMEM;
goto error_ret;
@@ -455,9 +470,7 @@ error_unconfigure_buffer:
error_unregister_events:
iio_simple_dummy_events_unregister(indio_dev);
error_free_device:
- /* Note free device should only be called, before registration
- * has succeeded. */
- iio_free_device(indio_dev);
+ iio_device_free(indio_dev);
error_ret:
return ret;
}
@@ -494,7 +507,7 @@ static int iio_dummy_remove(int index)
goto error_ret;
/* Free all structures */
- iio_free_device(indio_dev);
+ iio_device_free(indio_dev);
error_ret:
return ret;
diff --git a/drivers/staging/iio/iio_simple_dummy_buffer.c b/drivers/staging/iio/iio_simple_dummy_buffer.c
index bb4daf744362..bd628de472a9 100644
--- a/drivers/staging/iio/iio_simple_dummy_buffer.c
+++ b/drivers/staging/iio/iio_simple_dummy_buffer.c
@@ -18,9 +18,9 @@
#include <linux/irq.h>
#include <linux/bitmap.h>
-#include "iio.h"
-#include "trigger_consumer.h"
-#include "kfifo_buf.h"
+#include <linux/iio/iio.h>
+#include <linux/iio/trigger_consumer.h>
+#include <linux/iio/kfifo_buf.h>
#include "iio_simple_dummy.h"
@@ -37,7 +37,7 @@ static const s16 fakedata[] = {
* @irq: the interrupt number
* @p: private data - always a pointer to the poll func.
*
- * This is the guts of buffered capture. On a trigger event occuring,
+ * This is the guts of buffered capture. On a trigger event occurring,
* if the pollfunc is attached then this handler is called as a threaded
* interrupt (and hence may sleep). It is responsible for grabbing data
* from the device and pushing it into the associated buffer.
@@ -48,14 +48,11 @@ static irqreturn_t iio_simple_dummy_trigger_h(int irq, void *p)
struct iio_dev *indio_dev = pf->indio_dev;
struct iio_buffer *buffer = indio_dev->buffer;
int len = 0;
- /*
- * The datasize is obtained from the buffer. It was stored when
- * the preenable setup function was called.
- */
- size_t datasize = buffer->access->get_bytes_per_datum(buffer);
- u16 *data = kmalloc(datasize, GFP_KERNEL);
+ u16 *data;
+
+ data = kmalloc(indio_dev->scan_bytes, GFP_KERNEL);
if (data == NULL)
- return -ENOMEM;
+ goto done;
if (!bitmap_empty(indio_dev->active_scan_mask, indio_dev->masklength)) {
/*
@@ -64,37 +61,37 @@ static irqreturn_t iio_simple_dummy_trigger_h(int irq, void *p)
* up a fast read. The capture will consist of all of them.
* Hence we just call the grab data function and fill the
* buffer without processing.
- * sofware scans: can be considered to be random access
+ * software scans: can be considered to be random access
* so efficient reading is just a case of minimal bus
* transactions.
* software culled hardware scans:
* occasionally a driver may process the nearest hardware
* scan to avoid storing elements that are not desired. This
- * is the fidliest option by far.
- * Here lets pretend we have random access. And the values are
+ * is the fiddliest option by far.
+ * Here let's pretend we have random access. And the values are
* in the constant table fakedata.
*/
int i, j;
for (i = 0, j = 0;
i < bitmap_weight(indio_dev->active_scan_mask,
indio_dev->masklength);
- i++) {
+ i++, j++) {
j = find_next_bit(buffer->scan_mask,
- indio_dev->masklength, j + 1);
- /* random access read form the 'device' */
+ indio_dev->masklength, j);
+ /* random access read from the 'device' */
data[i] = fakedata[j];
len += 2;
}
}
- /* Store a timestampe at an 8 byte boundary */
- if (buffer->scan_timestamp)
- *(s64 *)(((phys_addr_t)data + len
- + sizeof(s64) - 1) & ~(sizeof(s64) - 1))
+ /* Store the timestamp at an 8 byte aligned offset */
+ if (indio_dev->scan_timestamp)
+ *(s64 *)((u8 *)data + ALIGN(len, sizeof(s64)))
= iio_get_time_ns();
buffer->access->store_to(buffer, (u8 *)data, pf->timestamp);
kfree(data);
+done:
/*
* Tell the core we are done with this trigger and ready for the
* next one.
diff --git a/drivers/staging/iio/iio_simple_dummy_events.c b/drivers/staging/iio/iio_simple_dummy_events.c
index 449c7a5ece80..317b77465db4 100644
--- a/drivers/staging/iio/iio_simple_dummy_events.c
+++ b/drivers/staging/iio/iio_simple_dummy_events.c
@@ -12,9 +12,9 @@
#include <linux/interrupt.h>
#include <linux/irq.h>
-#include "iio.h"
-#include "sysfs.h"
-#include "events.h"
+#include <linux/iio/iio.h>
+#include <linux/iio/sysfs.h>
+#include <linux/iio/events.h>
#include "iio_simple_dummy.h"
/* Evgen 'fakes' interrupt events for this example */
@@ -122,7 +122,7 @@ int iio_simple_dummy_write_event_value(struct iio_dev *indio_dev,
* @private: pointer to device instance state.
*
* This handler is responsible for querying the device to find out what
- * event occured and for then pushing that event towards userspace.
+ * event occurred and for then pushing that event towards userspace.
* Here only one event occurs so we push that directly on with locally
* grabbed timestamp.
*/
diff --git a/drivers/staging/iio/impedance-analyzer/ad5933.c b/drivers/staging/iio/impedance-analyzer/ad5933.c
index cd82b56d58af..a8e51bc04439 100644
--- a/drivers/staging/iio/impedance-analyzer/ad5933.c
+++ b/drivers/staging/iio/impedance-analyzer/ad5933.c
@@ -19,9 +19,9 @@
#include <linux/module.h>
#include <asm/div64.h>
-#include "../iio.h"
-#include "../sysfs.h"
-#include "../buffer.h"
+#include <linux/iio/iio.h>
+#include <linux/iio/sysfs.h>
+#include <linux/iio/buffer.h>
#include "../ring_sw.h"
#include "ad5933.h"
@@ -109,15 +109,46 @@ static struct ad5933_platform_data ad5933_default_pdata = {
};
static struct iio_chan_spec ad5933_channels[] = {
- IIO_CHAN(IIO_TEMP, 0, 1, 1, NULL, 0, 0, 0,
- 0, AD5933_REG_TEMP_DATA, IIO_ST('s', 14, 16, 0), 0),
- /* Ring Channels */
- IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, "real_raw", 0, 0,
- IIO_CHAN_INFO_SCALE_SEPARATE_BIT,
- AD5933_REG_REAL_DATA, 0, IIO_ST('s', 16, 16, 0), 0),
- IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, "imag_raw", 0, 0,
- IIO_CHAN_INFO_SCALE_SEPARATE_BIT,
- AD5933_REG_IMAG_DATA, 1, IIO_ST('s', 16, 16, 0), 0),
+ {
+ .type = IIO_TEMP,
+ .indexed = 1,
+ .channel = 0,
+ .info_mask = IIO_CHAN_INFO_PROCESSED_SEPARATE_BIT,
+ .address = AD5933_REG_TEMP_DATA,
+ .scan_type = {
+ .sign = 's',
+ .realbits = 14,
+ .storagebits = 16,
+ },
+ }, { /* Ring Channels */
+ .type = IIO_VOLTAGE,
+ .indexed = 1,
+ .channel = 0,
+ .extend_name = "real_raw",
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
+ IIO_CHAN_INFO_SCALE_SEPARATE_BIT,
+ .address = AD5933_REG_REAL_DATA,
+ .scan_index = 0,
+ .scan_type = {
+ .sign = 's',
+ .realbits = 16,
+ .storagebits = 16,
+ },
+ }, {
+ .type = IIO_VOLTAGE,
+ .indexed = 1,
+ .channel = 0,
+ .extend_name = "imag_raw",
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
+ IIO_CHAN_INFO_SCALE_SEPARATE_BIT,
+ .address = AD5933_REG_IMAG_DATA,
+ .scan_index = 1,
+ .scan_type = {
+ .sign = 's',
+ .realbits = 16,
+ .storagebits = 16,
+ },
+ },
};
static int ad5933_i2c_write(struct i2c_client *client,
@@ -260,7 +291,7 @@ static ssize_t ad5933_show_frequency(struct device *dev,
struct device_attribute *attr,
char *buf)
{
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct ad5933_state *st = iio_priv(indio_dev);
struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
int ret;
@@ -289,7 +320,7 @@ static ssize_t ad5933_store_frequency(struct device *dev,
const char *buf,
size_t len)
{
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct ad5933_state *st = iio_priv(indio_dev);
struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
long val;
@@ -323,7 +354,7 @@ static ssize_t ad5933_show(struct device *dev,
struct device_attribute *attr,
char *buf)
{
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct ad5933_state *st = iio_priv(indio_dev);
struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
int ret = 0, len = 0;
@@ -366,7 +397,7 @@ static ssize_t ad5933_store(struct device *dev,
const char *buf,
size_t len)
{
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct ad5933_state *st = iio_priv(indio_dev);
struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
long val;
@@ -495,7 +526,8 @@ static int ad5933_read_raw(struct iio_dev *indio_dev,
mutex_lock(&indio_dev->mlock);
switch (m) {
- case 0:
+ case IIO_CHAN_INFO_RAW:
+ case IIO_CHAN_INFO_PROCESSED:
if (iio_buffer_enabled(indio_dev)) {
ret = -EBUSY;
goto out;
@@ -537,19 +569,14 @@ static const struct iio_info ad5933_info = {
static int ad5933_ring_preenable(struct iio_dev *indio_dev)
{
struct ad5933_state *st = iio_priv(indio_dev);
- size_t d_size;
int ret;
if (bitmap_empty(indio_dev->active_scan_mask, indio_dev->masklength))
return -EINVAL;
- d_size = bitmap_weight(indio_dev->active_scan_mask,
- indio_dev->masklength) *
- ad5933_channels[1].scan_type.storagebits / 8;
-
- if (indio_dev->buffer->access->set_bytes_per_datum)
- indio_dev->buffer->access->
- set_bytes_per_datum(indio_dev->buffer, d_size);
+ ret = iio_sw_buffer_preenable(indio_dev);
+ if (ret < 0)
+ return ret;
ret = ad5933_reset(st);
if (ret < 0)
@@ -678,7 +705,7 @@ static int __devinit ad5933_probe(struct i2c_client *client,
int ret, voltage_uv = 0;
struct ad5933_platform_data *pdata = client->dev.platform_data;
struct ad5933_state *st;
- struct iio_dev *indio_dev = iio_allocate_device(sizeof(*st));
+ struct iio_dev *indio_dev = iio_device_alloc(sizeof(*st));
if (indio_dev == NULL)
return -ENOMEM;
@@ -757,7 +784,7 @@ error_put_reg:
if (!IS_ERR(st->reg))
regulator_put(st->reg);
- iio_free_device(indio_dev);
+ iio_device_free(indio_dev);
return ret;
}
@@ -774,7 +801,7 @@ static __devexit int ad5933_remove(struct i2c_client *client)
regulator_disable(st->reg);
regulator_put(st->reg);
}
- iio_free_device(indio_dev);
+ iio_device_free(indio_dev);
return 0;
}
diff --git a/drivers/staging/iio/imu/adis16400.h b/drivers/staging/iio/imu/adis16400.h
index 83d133efaac6..9dd9f1459a4d 100644
--- a/drivers/staging/iio/imu/adis16400.h
+++ b/drivers/staging/iio/imu/adis16400.h
@@ -42,7 +42,8 @@
#define ADIS16350_ZTEMP_OUT 0x14 /* Z-axis gyroscope temperature measurement */
#define ADIS16300_PITCH_OUT 0x12 /* X axis inclinometer output measurement */
-#define ADIS16300_ROLL_OUT 0x12 /* Y axis inclinometer output measurement */
+#define ADIS16300_ROLL_OUT 0x14 /* Y axis inclinometer output measurement */
+#define ADIS16300_AUX_ADC 0x16 /* Auxiliary ADC measurement */
/* Calibration parameters */
#define ADIS16400_XGYRO_OFF 0x1A /* X-axis gyroscope bias offset factor */
diff --git a/drivers/staging/iio/imu/adis16400_core.c b/drivers/staging/iio/imu/adis16400_core.c
index e73ad7818d85..1f4c17779b5a 100644
--- a/drivers/staging/iio/imu/adis16400_core.c
+++ b/drivers/staging/iio/imu/adis16400_core.c
@@ -26,9 +26,9 @@
#include <linux/list.h>
#include <linux/module.h>
-#include "../iio.h"
-#include "../sysfs.h"
-#include "../buffer.h"
+#include <linux/iio/iio.h>
+#include <linux/iio/sysfs.h>
+#include <linux/iio/buffer.h>
#include "adis16400.h"
enum adis16400_chip_variant {
@@ -179,7 +179,7 @@ static ssize_t adis16400_read_frequency(struct device *dev,
struct device_attribute *attr,
char *buf)
{
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
int ret, len = 0;
ret = adis16400_get_freq(indio_dev);
if (ret < 0)
@@ -225,7 +225,7 @@ static ssize_t adis16400_write_frequency(struct device *dev,
const char *buf,
size_t len)
{
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct adis16400_state *st = iio_priv(indio_dev);
long val;
int ret;
@@ -268,25 +268,6 @@ static int adis16400_reset(struct iio_dev *indio_dev)
return ret;
}
-static ssize_t adis16400_write_reset(struct device *dev,
- struct device_attribute *attr,
- const char *buf, size_t len)
-{
- bool val;
- int ret;
-
- ret = strtobool(buf, &val);
- if (ret < 0)
- return ret;
- if (val) {
- ret = adis16400_reset(dev_get_drvdata(dev));
- if (ret < 0)
- return ret;
- }
-
- return len;
-}
-
int adis16400_set_irq(struct iio_dev *indio_dev, bool enable)
{
int ret;
@@ -454,8 +435,6 @@ static IIO_DEV_ATTR_SAMP_FREQ(S_IWUSR | S_IRUGO,
adis16400_read_frequency,
adis16400_write_frequency);
-static IIO_DEVICE_ATTR(reset, S_IWUSR, NULL, adis16400_write_reset, 0);
-
static IIO_CONST_ATTR_SAMP_FREQ_AVAIL("409 546 819 1638");
enum adis16400_chan {
@@ -472,11 +451,12 @@ enum adis16400_chan {
temp,
temp0, temp1, temp2,
in1,
+ in2,
incli_x,
incli_y,
};
-static u8 adis16400_addresses[17][2] = {
+static u8 adis16400_addresses[18][2] = {
[in_supply] = { ADIS16400_SUPPLY_OUT },
[gyro_x] = { ADIS16400_XGYRO_OUT, ADIS16400_XGYRO_OFF },
[gyro_y] = { ADIS16400_YGYRO_OUT, ADIS16400_YGYRO_OFF },
@@ -491,7 +471,8 @@ static u8 adis16400_addresses[17][2] = {
[temp0] = { ADIS16350_XTEMP_OUT },
[temp1] = { ADIS16350_YTEMP_OUT },
[temp2] = { ADIS16350_ZTEMP_OUT },
- [in1] = { ADIS16400_AUX_ADC },
+ [in1] = { ADIS16300_AUX_ADC },
+ [in2] = { ADIS16400_AUX_ADC },
[incli_x] = { ADIS16300_PITCH_OUT },
[incli_y] = { ADIS16300_ROLL_OUT }
};
@@ -545,7 +526,7 @@ static int adis16400_read_raw(struct iio_dev *indio_dev,
s16 val16;
switch (mask) {
- case 0:
+ case IIO_CHAN_INFO_RAW:
mutex_lock(&indio_dev->mlock);
ret = adis16400_spi_read_reg_16(indio_dev,
adis16400_addresses[chan->address][0],
@@ -635,7 +616,8 @@ static struct iio_chan_spec adis16400_channels[] = {
.indexed = 1,
.channel = 0,
.extend_name = "supply",
- .info_mask = IIO_CHAN_INFO_SCALE_SEPARATE_BIT,
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
+ IIO_CHAN_INFO_SCALE_SEPARATE_BIT,
.address = in_supply,
.scan_index = ADIS16400_SCAN_SUPPLY,
.scan_type = IIO_ST('u', 14, 16, 0)
@@ -643,7 +625,8 @@ static struct iio_chan_spec adis16400_channels[] = {
.type = IIO_ANGL_VEL,
.modified = 1,
.channel2 = IIO_MOD_X,
- .info_mask = IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT |
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
+ IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT |
IIO_CHAN_INFO_SCALE_SHARED_BIT |
IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY_SHARED_BIT,
.address = gyro_x,
@@ -653,7 +636,8 @@ static struct iio_chan_spec adis16400_channels[] = {
.type = IIO_ANGL_VEL,
.modified = 1,
.channel2 = IIO_MOD_Y,
- .info_mask = IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT |
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
+ IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT |
IIO_CHAN_INFO_SCALE_SHARED_BIT |
IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY_SHARED_BIT,
.address = gyro_y,
@@ -663,7 +647,8 @@ static struct iio_chan_spec adis16400_channels[] = {
.type = IIO_ANGL_VEL,
.modified = 1,
.channel2 = IIO_MOD_Z,
- .info_mask = IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT |
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
+ IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT |
IIO_CHAN_INFO_SCALE_SHARED_BIT |
IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY_SHARED_BIT,
.address = gyro_z,
@@ -673,7 +658,8 @@ static struct iio_chan_spec adis16400_channels[] = {
.type = IIO_ACCEL,
.modified = 1,
.channel2 = IIO_MOD_X,
- .info_mask = IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT |
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
+ IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT |
IIO_CHAN_INFO_SCALE_SHARED_BIT |
IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY_SHARED_BIT,
.address = accel_x,
@@ -683,7 +669,8 @@ static struct iio_chan_spec adis16400_channels[] = {
.type = IIO_ACCEL,
.modified = 1,
.channel2 = IIO_MOD_Y,
- .info_mask = IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT |
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
+ IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT |
IIO_CHAN_INFO_SCALE_SHARED_BIT |
IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY_SHARED_BIT,
.address = accel_y,
@@ -693,7 +680,8 @@ static struct iio_chan_spec adis16400_channels[] = {
.type = IIO_ACCEL,
.modified = 1,
.channel2 = IIO_MOD_Z,
- .info_mask = IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT |
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
+ IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT |
IIO_CHAN_INFO_SCALE_SHARED_BIT |
IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY_SHARED_BIT,
.address = accel_z,
@@ -703,7 +691,8 @@ static struct iio_chan_spec adis16400_channels[] = {
.type = IIO_MAGN,
.modified = 1,
.channel2 = IIO_MOD_X,
- .info_mask = IIO_CHAN_INFO_SCALE_SHARED_BIT |
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
+ IIO_CHAN_INFO_SCALE_SHARED_BIT |
IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY_SHARED_BIT,
.address = magn_x,
.scan_index = ADIS16400_SCAN_MAGN_X,
@@ -712,7 +701,8 @@ static struct iio_chan_spec adis16400_channels[] = {
.type = IIO_MAGN,
.modified = 1,
.channel2 = IIO_MOD_Y,
- .info_mask = IIO_CHAN_INFO_SCALE_SHARED_BIT |
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
+ IIO_CHAN_INFO_SCALE_SHARED_BIT |
IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY_SHARED_BIT,
.address = magn_y,
.scan_index = ADIS16400_SCAN_MAGN_Y,
@@ -721,7 +711,8 @@ static struct iio_chan_spec adis16400_channels[] = {
.type = IIO_MAGN,
.modified = 1,
.channel2 = IIO_MOD_Z,
- .info_mask = IIO_CHAN_INFO_SCALE_SHARED_BIT |
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
+ IIO_CHAN_INFO_SCALE_SHARED_BIT |
IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY_SHARED_BIT,
.address = magn_z,
.scan_index = ADIS16400_SCAN_MAGN_Z,
@@ -730,7 +721,8 @@ static struct iio_chan_spec adis16400_channels[] = {
.type = IIO_TEMP,
.indexed = 1,
.channel = 0,
- .info_mask = IIO_CHAN_INFO_OFFSET_SEPARATE_BIT |
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
+ IIO_CHAN_INFO_OFFSET_SEPARATE_BIT |
IIO_CHAN_INFO_SCALE_SEPARATE_BIT,
.address = temp,
.scan_index = ADIS16400_SCAN_TEMP,
@@ -739,8 +731,9 @@ static struct iio_chan_spec adis16400_channels[] = {
.type = IIO_VOLTAGE,
.indexed = 1,
.channel = 1,
- .info_mask = IIO_CHAN_INFO_SCALE_SEPARATE_BIT,
- .address = in1,
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
+ IIO_CHAN_INFO_SCALE_SEPARATE_BIT,
+ .address = in2,
.scan_index = ADIS16400_SCAN_ADC_0,
.scan_type = IIO_ST('s', 12, 16, 0),
},
@@ -753,7 +746,8 @@ static struct iio_chan_spec adis16350_channels[] = {
.indexed = 1,
.channel = 0,
.extend_name = "supply",
- .info_mask = IIO_CHAN_INFO_SCALE_SEPARATE_BIT,
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
+ IIO_CHAN_INFO_SCALE_SEPARATE_BIT,
.address = in_supply,
.scan_index = ADIS16400_SCAN_SUPPLY,
.scan_type = IIO_ST('u', 12, 16, 0)
@@ -761,7 +755,8 @@ static struct iio_chan_spec adis16350_channels[] = {
.type = IIO_ANGL_VEL,
.modified = 1,
.channel2 = IIO_MOD_X,
- .info_mask = IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT |
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
+ IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT |
IIO_CHAN_INFO_SCALE_SHARED_BIT |
IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY_SHARED_BIT,
.address = gyro_x,
@@ -771,7 +766,8 @@ static struct iio_chan_spec adis16350_channels[] = {
.type = IIO_ANGL_VEL,
.modified = 1,
.channel2 = IIO_MOD_Y,
- .info_mask = IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT |
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
+ IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT |
IIO_CHAN_INFO_SCALE_SHARED_BIT |
IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY_SHARED_BIT,
.address = gyro_y,
@@ -781,17 +777,19 @@ static struct iio_chan_spec adis16350_channels[] = {
.type = IIO_ANGL_VEL,
.modified = 1,
.channel2 = IIO_MOD_Z,
- .info_mask = IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT |
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
+ IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT |
IIO_CHAN_INFO_SCALE_SHARED_BIT |
IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY_SHARED_BIT,
.address = gyro_z,
.scan_index = ADIS16400_SCAN_GYRO_Z,
.scan_type = IIO_ST('s', 14, 16, 0),
}, {
- .type = IIO_ACCEL,
+ .type = IIO_ACCEL,
.modified = 1,
.channel2 = IIO_MOD_X,
- .info_mask = IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT |
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
+ IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT |
IIO_CHAN_INFO_SCALE_SHARED_BIT |
IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY_SHARED_BIT,
.address = accel_x,
@@ -801,7 +799,8 @@ static struct iio_chan_spec adis16350_channels[] = {
.type = IIO_ACCEL,
.modified = 1,
.channel2 = IIO_MOD_Y,
- .info_mask = IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT |
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
+ IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT |
IIO_CHAN_INFO_SCALE_SHARED_BIT |
IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY_SHARED_BIT,
.address = accel_y,
@@ -811,7 +810,8 @@ static struct iio_chan_spec adis16350_channels[] = {
.type = IIO_ACCEL,
.modified = 1,
.channel2 = IIO_MOD_Z,
- .info_mask = IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT |
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
+ IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT |
IIO_CHAN_INFO_SCALE_SHARED_BIT |
IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY_SHARED_BIT,
.address = accel_z,
@@ -822,7 +822,8 @@ static struct iio_chan_spec adis16350_channels[] = {
.indexed = 1,
.channel = 0,
.extend_name = "x",
- .info_mask = IIO_CHAN_INFO_OFFSET_SEPARATE_BIT |
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
+ IIO_CHAN_INFO_OFFSET_SEPARATE_BIT |
IIO_CHAN_INFO_SCALE_SEPARATE_BIT |
IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY_SHARED_BIT,
.address = temp0,
@@ -833,7 +834,8 @@ static struct iio_chan_spec adis16350_channels[] = {
.indexed = 1,
.channel = 1,
.extend_name = "y",
- .info_mask = IIO_CHAN_INFO_OFFSET_SEPARATE_BIT |
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
+ IIO_CHAN_INFO_OFFSET_SEPARATE_BIT |
IIO_CHAN_INFO_SCALE_SEPARATE_BIT |
IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY_SHARED_BIT,
.address = temp1,
@@ -844,7 +846,8 @@ static struct iio_chan_spec adis16350_channels[] = {
.indexed = 1,
.channel = 2,
.extend_name = "z",
- .info_mask = IIO_CHAN_INFO_OFFSET_SEPARATE_BIT |
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
+ IIO_CHAN_INFO_OFFSET_SEPARATE_BIT |
IIO_CHAN_INFO_SCALE_SEPARATE_BIT,
.address = temp2,
.scan_index = ADIS16350_SCAN_TEMP_Z,
@@ -853,7 +856,8 @@ static struct iio_chan_spec adis16350_channels[] = {
.type = IIO_VOLTAGE,
.indexed = 1,
.channel = 1,
- .info_mask = IIO_CHAN_INFO_SCALE_SEPARATE_BIT,
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
+ IIO_CHAN_INFO_SCALE_SEPARATE_BIT,
.address = in1,
.scan_index = ADIS16350_SCAN_ADC_0,
.scan_type = IIO_ST('s', 12, 16, 0),
@@ -867,7 +871,8 @@ static struct iio_chan_spec adis16300_channels[] = {
.indexed = 1,
.channel = 0,
.extend_name = "supply",
- .info_mask = IIO_CHAN_INFO_SCALE_SEPARATE_BIT,
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
+ IIO_CHAN_INFO_SCALE_SEPARATE_BIT,
.address = in_supply,
.scan_index = ADIS16400_SCAN_SUPPLY,
.scan_type = IIO_ST('u', 12, 16, 0)
@@ -875,7 +880,8 @@ static struct iio_chan_spec adis16300_channels[] = {
.type = IIO_ANGL_VEL,
.modified = 1,
.channel2 = IIO_MOD_X,
- .info_mask = IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT |
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
+ IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT |
IIO_CHAN_INFO_SCALE_SHARED_BIT |
IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY_SHARED_BIT,
.address = gyro_x,
@@ -885,7 +891,8 @@ static struct iio_chan_spec adis16300_channels[] = {
.type = IIO_ACCEL,
.modified = 1,
.channel2 = IIO_MOD_X,
- .info_mask = IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT |
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
+ IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT |
IIO_CHAN_INFO_SCALE_SHARED_BIT |
IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY_SHARED_BIT,
.address = accel_x,
@@ -895,7 +902,8 @@ static struct iio_chan_spec adis16300_channels[] = {
.type = IIO_ACCEL,
.modified = 1,
.channel2 = IIO_MOD_Y,
- .info_mask = IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT |
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
+ IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT |
IIO_CHAN_INFO_SCALE_SHARED_BIT |
IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY_SHARED_BIT,
.address = accel_y,
@@ -905,7 +913,8 @@ static struct iio_chan_spec adis16300_channels[] = {
.type = IIO_ACCEL,
.modified = 1,
.channel2 = IIO_MOD_Z,
- .info_mask = IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT |
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
+ IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT |
IIO_CHAN_INFO_SCALE_SHARED_BIT |
IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY_SHARED_BIT,
.address = accel_z,
@@ -915,16 +924,18 @@ static struct iio_chan_spec adis16300_channels[] = {
.type = IIO_TEMP,
.indexed = 1,
.channel = 0,
- .info_mask = IIO_CHAN_INFO_OFFSET_SEPARATE_BIT |
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
+ IIO_CHAN_INFO_OFFSET_SEPARATE_BIT |
IIO_CHAN_INFO_SCALE_SEPARATE_BIT,
- .address = temp,
+ .address = temp0,
.scan_index = ADIS16400_SCAN_TEMP,
.scan_type = IIO_ST('s', 12, 16, 0),
}, {
.type = IIO_VOLTAGE,
.indexed = 1,
.channel = 1,
- .info_mask = IIO_CHAN_INFO_SCALE_SEPARATE_BIT,
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
+ IIO_CHAN_INFO_SCALE_SEPARATE_BIT,
.address = in1,
.scan_index = ADIS16350_SCAN_ADC_0,
.scan_type = IIO_ST('s', 12, 16, 0),
@@ -932,7 +943,8 @@ static struct iio_chan_spec adis16300_channels[] = {
.type = IIO_INCLI,
.modified = 1,
.channel2 = IIO_MOD_X,
- .info_mask = IIO_CHAN_INFO_SCALE_SHARED_BIT,
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
+ IIO_CHAN_INFO_SCALE_SHARED_BIT,
.address = incli_x,
.scan_index = ADIS16300_SCAN_INCLI_X,
.scan_type = IIO_ST('s', 13, 16, 0),
@@ -940,7 +952,8 @@ static struct iio_chan_spec adis16300_channels[] = {
.type = IIO_INCLI,
.modified = 1,
.channel2 = IIO_MOD_Y,
- .info_mask = IIO_CHAN_INFO_SCALE_SHARED_BIT,
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
+ IIO_CHAN_INFO_SCALE_SHARED_BIT,
.address = incli_y,
.scan_index = ADIS16300_SCAN_INCLI_Y,
.scan_type = IIO_ST('s', 13, 16, 0),
@@ -953,7 +966,8 @@ static const struct iio_chan_spec adis16334_channels[] = {
.type = IIO_ANGL_VEL,
.modified = 1,
.channel2 = IIO_MOD_X,
- .info_mask = IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT |
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
+ IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT |
IIO_CHAN_INFO_SCALE_SHARED_BIT |
IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY_SHARED_BIT,
.address = gyro_x,
@@ -963,7 +977,8 @@ static const struct iio_chan_spec adis16334_channels[] = {
.type = IIO_ANGL_VEL,
.modified = 1,
.channel2 = IIO_MOD_Y,
- .info_mask = IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT |
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
+ IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT |
IIO_CHAN_INFO_SCALE_SHARED_BIT |
IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY_SHARED_BIT,
.address = gyro_y,
@@ -973,7 +988,8 @@ static const struct iio_chan_spec adis16334_channels[] = {
.type = IIO_ANGL_VEL,
.modified = 1,
.channel2 = IIO_MOD_Z,
- .info_mask = IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT |
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
+ IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT |
IIO_CHAN_INFO_SCALE_SHARED_BIT |
IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY_SHARED_BIT,
.address = gyro_z,
@@ -983,7 +999,8 @@ static const struct iio_chan_spec adis16334_channels[] = {
.type = IIO_ACCEL,
.modified = 1,
.channel2 = IIO_MOD_X,
- .info_mask = IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT |
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
+ IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT |
IIO_CHAN_INFO_SCALE_SHARED_BIT |
IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY_SHARED_BIT,
.address = accel_x,
@@ -993,7 +1010,8 @@ static const struct iio_chan_spec adis16334_channels[] = {
.type = IIO_ACCEL,
.modified = 1,
.channel2 = IIO_MOD_Y,
- .info_mask = IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT |
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
+ IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT |
IIO_CHAN_INFO_SCALE_SHARED_BIT |
IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY_SHARED_BIT,
.address = accel_y,
@@ -1003,7 +1021,8 @@ static const struct iio_chan_spec adis16334_channels[] = {
.type = IIO_ACCEL,
.modified = 1,
.channel2 = IIO_MOD_Z,
- .info_mask = IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT |
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
+ IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT |
IIO_CHAN_INFO_SCALE_SHARED_BIT |
IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY_SHARED_BIT,
.address = accel_z,
@@ -1013,10 +1032,11 @@ static const struct iio_chan_spec adis16334_channels[] = {
.type = IIO_TEMP,
.indexed = 1,
.channel = 0,
- .info_mask = IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT |
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
+ IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT |
IIO_CHAN_INFO_SCALE_SHARED_BIT,
- .address = accel_z,
- .scan_index = ADIS16400_SCAN_ACC_Z,
+ .address = temp0,
+ .scan_index = ADIS16400_SCAN_TEMP,
.scan_type = IIO_ST('s', 14, 16, 0),
},
IIO_CHAN_SOFT_TIMESTAMP(12)
@@ -1025,7 +1045,6 @@ static const struct iio_chan_spec adis16334_channels[] = {
static struct attribute *adis16400_attributes[] = {
&iio_dev_attr_sampling_frequency.dev_attr.attr,
&iio_const_attr_sampling_frequency_available.dev_attr.attr,
- &iio_dev_attr_reset.dev_attr.attr,
NULL
};
@@ -1122,7 +1141,7 @@ static int __devinit adis16400_probe(struct spi_device *spi)
{
int ret;
struct adis16400_state *st;
- struct iio_dev *indio_dev = iio_allocate_device(sizeof(*st));
+ struct iio_dev *indio_dev = iio_device_alloc(sizeof(*st));
if (indio_dev == NULL) {
ret = -ENOMEM;
goto error_ret;
@@ -1172,14 +1191,14 @@ static int __devinit adis16400_probe(struct spi_device *spi)
return 0;
error_remove_trigger:
- if (indio_dev->modes & INDIO_BUFFER_TRIGGERED)
+ if (spi->irq)
adis16400_remove_trigger(indio_dev);
error_uninitialize_ring:
iio_buffer_unregister(indio_dev);
error_unreg_ring_funcs:
adis16400_unconfigure_ring(indio_dev);
error_free_dev:
- iio_free_device(indio_dev);
+ iio_device_free(indio_dev);
error_ret:
return ret;
}
@@ -1198,7 +1217,7 @@ static int adis16400_remove(struct spi_device *spi)
adis16400_remove_trigger(indio_dev);
iio_buffer_unregister(indio_dev);
adis16400_unconfigure_ring(indio_dev);
- iio_free_device(indio_dev);
+ iio_device_free(indio_dev);
return 0;
diff --git a/drivers/staging/iio/imu/adis16400_ring.c b/drivers/staging/iio/imu/adis16400_ring.c
index 8daa038b23e6..beec650ddbdb 100644
--- a/drivers/staging/iio/imu/adis16400_ring.c
+++ b/drivers/staging/iio/imu/adis16400_ring.c
@@ -6,20 +6,19 @@
#include <linux/bitops.h>
#include <linux/export.h>
-#include "../iio.h"
+#include <linux/iio/iio.h>
#include "../ring_sw.h"
-#include "../trigger_consumer.h"
+#include <linux/iio/trigger_consumer.h>
#include "adis16400.h"
/**
* adis16400_spi_read_burst() - read all data registers
- * @dev: device associated with child of actual device (iio_dev or iio_trig)
+ * @indio_dev: the IIO device
* @rx: somewhere to pass back the value read (min size is 24 bytes)
**/
-static int adis16400_spi_read_burst(struct device *dev, u8 *rx)
+static int adis16400_spi_read_burst(struct iio_dev *indio_dev, u8 *rx)
{
struct spi_message msg;
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
struct adis16400_state *st = iio_priv(indio_dev);
u32 old_speed_hz = st->us->max_speed_hz;
int ret;
@@ -71,9 +70,8 @@ static const u16 read_all_tx_array[] = {
cpu_to_be16(ADIS16400_READ_REG(ADIS16400_AUX_ADC)),
};
-static int adis16350_spi_read_all(struct device *dev, u8 *rx)
+static int adis16350_spi_read_all(struct iio_dev *indio_dev, u8 *rx)
{
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
struct adis16400_state *st = iio_priv(indio_dev);
struct spi_message msg;
@@ -119,28 +117,28 @@ static irqreturn_t adis16400_trigger_handler(int irq, void *p)
struct iio_buffer *ring = indio_dev->buffer;
int i = 0, j, ret = 0;
s16 *data;
- size_t datasize = ring->access->get_bytes_per_datum(ring);
+
/* Asumption that long is enough for maximum channels */
unsigned long mask = *indio_dev->active_scan_mask;
int scan_count = bitmap_weight(indio_dev->active_scan_mask,
indio_dev->masklength);
- data = kmalloc(datasize , GFP_KERNEL);
+ data = kmalloc(indio_dev->scan_bytes, GFP_KERNEL);
if (data == NULL) {
dev_err(&st->us->dev, "memory alloc failed in ring bh");
- return -ENOMEM;
+ goto done;
}
if (scan_count) {
if (st->variant->flags & ADIS16400_NO_BURST) {
- ret = adis16350_spi_read_all(&indio_dev->dev, st->rx);
+ ret = adis16350_spi_read_all(indio_dev, st->rx);
if (ret < 0)
- goto err;
+ goto done;
for (; i < scan_count; i++)
data[i] = *(s16 *)(st->rx + i*2);
} else {
- ret = adis16400_spi_read_burst(&indio_dev->dev, st->rx);
+ ret = adis16400_spi_read_burst(indio_dev, st->rx);
if (ret < 0)
- goto err;
+ goto done;
for (; i < scan_count; i++) {
j = __ffs(mask);
mask &= ~(1 << j);
@@ -154,14 +152,11 @@ static irqreturn_t adis16400_trigger_handler(int irq, void *p)
*((s64 *)(data + ((i + 3)/4)*4)) = pf->timestamp;
ring->access->store_to(indio_dev->buffer, (u8 *) data, pf->timestamp);
+done:
+ kfree(data);
iio_trigger_notify_done(indio_dev->trig);
- kfree(data);
return IRQ_HANDLED;
-
-err:
- kfree(data);
- return ret;
}
void adis16400_unconfigure_ring(struct iio_dev *indio_dev)
diff --git a/drivers/staging/iio/imu/adis16400_trigger.c b/drivers/staging/iio/imu/adis16400_trigger.c
index 5bf000757522..42a678e92fc6 100644
--- a/drivers/staging/iio/imu/adis16400_trigger.c
+++ b/drivers/staging/iio/imu/adis16400_trigger.c
@@ -3,8 +3,8 @@
#include <linux/spi/spi.h>
#include <linux/export.h>
-#include "../iio.h"
-#include "../trigger.h"
+#include <linux/iio/iio.h>
+#include <linux/iio/trigger.h>
#include "adis16400.h"
/**
@@ -29,7 +29,7 @@ int adis16400_probe_trigger(struct iio_dev *indio_dev)
int ret;
struct adis16400_state *st = iio_priv(indio_dev);
- st->trig = iio_allocate_trigger("%s-dev%d",
+ st->trig = iio_trigger_alloc("%s-dev%d",
indio_dev->name,
indio_dev->id);
if (st->trig == NULL) {
@@ -59,7 +59,7 @@ int adis16400_probe_trigger(struct iio_dev *indio_dev)
error_free_irq:
free_irq(st->us->irq, st->trig);
error_free_trig:
- iio_free_trigger(st->trig);
+ iio_trigger_free(st->trig);
error_ret:
return ret;
}
@@ -70,5 +70,5 @@ void adis16400_remove_trigger(struct iio_dev *indio_dev)
iio_trigger_unregister(st->trig);
free_irq(st->us->irq, st->trig);
- iio_free_trigger(st->trig);
+ iio_trigger_free(st->trig);
}
diff --git a/drivers/staging/iio/industrialio-buffer.c b/drivers/staging/iio/industrialio-buffer.c
deleted file mode 100644
index 386ba760f3f1..000000000000
--- a/drivers/staging/iio/industrialio-buffer.c
+++ /dev/null
@@ -1,734 +0,0 @@
-/* The industrial I/O core
- *
- * Copyright (c) 2008 Jonathan Cameron
- *
- * 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.
- *
- * Handling of buffer allocation / resizing.
- *
- *
- * Things to look at here.
- * - Better memory allocation techniques?
- * - Alternative access techniques?
- */
-#include <linux/kernel.h>
-#include <linux/export.h>
-#include <linux/device.h>
-#include <linux/fs.h>
-#include <linux/cdev.h>
-#include <linux/slab.h>
-#include <linux/poll.h>
-
-#include "iio.h"
-#include "iio_core.h"
-#include "sysfs.h"
-#include "buffer.h"
-
-static const char * const iio_endian_prefix[] = {
- [IIO_BE] = "be",
- [IIO_LE] = "le",
-};
-
-/**
- * iio_buffer_read_first_n_outer() - chrdev read for buffer access
- *
- * This function relies on all buffer implementations having an
- * iio_buffer as their first element.
- **/
-ssize_t iio_buffer_read_first_n_outer(struct file *filp, char __user *buf,
- size_t n, loff_t *f_ps)
-{
- struct iio_dev *indio_dev = filp->private_data;
- struct iio_buffer *rb = indio_dev->buffer;
-
- if (!rb || !rb->access->read_first_n)
- return -EINVAL;
- return rb->access->read_first_n(rb, n, buf);
-}
-
-/**
- * iio_buffer_poll() - poll the buffer to find out if it has data
- */
-unsigned int iio_buffer_poll(struct file *filp,
- struct poll_table_struct *wait)
-{
- struct iio_dev *indio_dev = filp->private_data;
- struct iio_buffer *rb = indio_dev->buffer;
-
- poll_wait(filp, &rb->pollq, wait);
- if (rb->stufftoread)
- return POLLIN | POLLRDNORM;
- /* need a way of knowing if there may be enough data... */
- return 0;
-}
-
-void iio_buffer_init(struct iio_buffer *buffer)
-{
- INIT_LIST_HEAD(&buffer->demux_list);
- init_waitqueue_head(&buffer->pollq);
-}
-EXPORT_SYMBOL(iio_buffer_init);
-
-static ssize_t iio_show_scan_index(struct device *dev,
- struct device_attribute *attr,
- char *buf)
-{
- return sprintf(buf, "%u\n", to_iio_dev_attr(attr)->c->scan_index);
-}
-
-static ssize_t iio_show_fixed_type(struct device *dev,
- struct device_attribute *attr,
- char *buf)
-{
- struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
- u8 type = this_attr->c->scan_type.endianness;
-
- if (type == IIO_CPU) {
-#ifdef __LITTLE_ENDIAN
- type = IIO_LE;
-#else
- type = IIO_BE;
-#endif
- }
- return sprintf(buf, "%s:%c%d/%d>>%u\n",
- iio_endian_prefix[type],
- this_attr->c->scan_type.sign,
- this_attr->c->scan_type.realbits,
- this_attr->c->scan_type.storagebits,
- this_attr->c->scan_type.shift);
-}
-
-static ssize_t iio_scan_el_show(struct device *dev,
- struct device_attribute *attr,
- char *buf)
-{
- int ret;
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
-
- ret = test_bit(to_iio_dev_attr(attr)->address,
- indio_dev->buffer->scan_mask);
-
- return sprintf(buf, "%d\n", ret);
-}
-
-static int iio_scan_mask_clear(struct iio_buffer *buffer, int bit)
-{
- clear_bit(bit, buffer->scan_mask);
- return 0;
-}
-
-static ssize_t iio_scan_el_store(struct device *dev,
- struct device_attribute *attr,
- const char *buf,
- size_t len)
-{
- int ret = 0;
- bool state;
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
- struct iio_buffer *buffer = indio_dev->buffer;
- struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
-
- state = !(buf[0] == '0');
- mutex_lock(&indio_dev->mlock);
- if (iio_buffer_enabled(indio_dev)) {
- ret = -EBUSY;
- goto error_ret;
- }
- ret = iio_scan_mask_query(indio_dev, buffer, this_attr->address);
- if (ret < 0)
- goto error_ret;
- if (!state && ret) {
- ret = iio_scan_mask_clear(buffer, this_attr->address);
- if (ret)
- goto error_ret;
- } else if (state && !ret) {
- ret = iio_scan_mask_set(indio_dev, buffer, this_attr->address);
- if (ret)
- goto error_ret;
- }
-
-error_ret:
- mutex_unlock(&indio_dev->mlock);
-
- return ret < 0 ? ret : len;
-
-}
-
-static ssize_t iio_scan_el_ts_show(struct device *dev,
- struct device_attribute *attr,
- char *buf)
-{
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
- return sprintf(buf, "%d\n", indio_dev->buffer->scan_timestamp);
-}
-
-static ssize_t iio_scan_el_ts_store(struct device *dev,
- struct device_attribute *attr,
- const char *buf,
- size_t len)
-{
- int ret = 0;
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
- bool state;
-
- state = !(buf[0] == '0');
- mutex_lock(&indio_dev->mlock);
- if (iio_buffer_enabled(indio_dev)) {
- ret = -EBUSY;
- goto error_ret;
- }
- indio_dev->buffer->scan_timestamp = state;
-error_ret:
- mutex_unlock(&indio_dev->mlock);
-
- return ret ? ret : len;
-}
-
-static int iio_buffer_add_channel_sysfs(struct iio_dev *indio_dev,
- const struct iio_chan_spec *chan)
-{
- int ret, attrcount = 0;
- struct iio_buffer *buffer = indio_dev->buffer;
-
- ret = __iio_add_chan_devattr("index",
- chan,
- &iio_show_scan_index,
- NULL,
- 0,
- 0,
- &indio_dev->dev,
- &buffer->scan_el_dev_attr_list);
- if (ret)
- goto error_ret;
- attrcount++;
- ret = __iio_add_chan_devattr("type",
- chan,
- &iio_show_fixed_type,
- NULL,
- 0,
- 0,
- &indio_dev->dev,
- &buffer->scan_el_dev_attr_list);
- if (ret)
- goto error_ret;
- attrcount++;
- if (chan->type != IIO_TIMESTAMP)
- ret = __iio_add_chan_devattr("en",
- chan,
- &iio_scan_el_show,
- &iio_scan_el_store,
- chan->scan_index,
- 0,
- &indio_dev->dev,
- &buffer->scan_el_dev_attr_list);
- else
- ret = __iio_add_chan_devattr("en",
- chan,
- &iio_scan_el_ts_show,
- &iio_scan_el_ts_store,
- chan->scan_index,
- 0,
- &indio_dev->dev,
- &buffer->scan_el_dev_attr_list);
- attrcount++;
- ret = attrcount;
-error_ret:
- return ret;
-}
-
-static void iio_buffer_remove_and_free_scan_dev_attr(struct iio_dev *indio_dev,
- struct iio_dev_attr *p)
-{
- kfree(p->dev_attr.attr.name);
- kfree(p);
-}
-
-static void __iio_buffer_attr_cleanup(struct iio_dev *indio_dev)
-{
- struct iio_dev_attr *p, *n;
- struct iio_buffer *buffer = indio_dev->buffer;
-
- list_for_each_entry_safe(p, n,
- &buffer->scan_el_dev_attr_list, l)
- iio_buffer_remove_and_free_scan_dev_attr(indio_dev, p);
-}
-
-static const char * const iio_scan_elements_group_name = "scan_elements";
-
-int iio_buffer_register(struct iio_dev *indio_dev,
- const struct iio_chan_spec *channels,
- int num_channels)
-{
- struct iio_dev_attr *p;
- struct attribute **attr;
- struct iio_buffer *buffer = indio_dev->buffer;
- int ret, i, attrn, attrcount, attrcount_orig = 0;
-
- if (buffer->attrs)
- indio_dev->groups[indio_dev->groupcounter++] = buffer->attrs;
-
- if (buffer->scan_el_attrs != NULL) {
- attr = buffer->scan_el_attrs->attrs;
- while (*attr++ != NULL)
- attrcount_orig++;
- }
- attrcount = attrcount_orig;
- INIT_LIST_HEAD(&buffer->scan_el_dev_attr_list);
- if (channels) {
- /* new magic */
- for (i = 0; i < num_channels; i++) {
- /* Establish necessary mask length */
- if (channels[i].scan_index >
- (int)indio_dev->masklength - 1)
- indio_dev->masklength
- = indio_dev->channels[i].scan_index + 1;
-
- ret = iio_buffer_add_channel_sysfs(indio_dev,
- &channels[i]);
- if (ret < 0)
- goto error_cleanup_dynamic;
- attrcount += ret;
- if (channels[i].type == IIO_TIMESTAMP)
- buffer->scan_index_timestamp =
- channels[i].scan_index;
- }
- if (indio_dev->masklength && buffer->scan_mask == NULL) {
- buffer->scan_mask = kcalloc(BITS_TO_LONGS(indio_dev->masklength),
- sizeof(*buffer->scan_mask),
- GFP_KERNEL);
- if (buffer->scan_mask == NULL) {
- ret = -ENOMEM;
- goto error_cleanup_dynamic;
- }
- }
- }
-
- buffer->scan_el_group.name = iio_scan_elements_group_name;
-
- buffer->scan_el_group.attrs = kcalloc(attrcount + 1,
- sizeof(buffer->scan_el_group.attrs[0]),
- GFP_KERNEL);
- if (buffer->scan_el_group.attrs == NULL) {
- ret = -ENOMEM;
- goto error_free_scan_mask;
- }
- if (buffer->scan_el_attrs)
- memcpy(buffer->scan_el_group.attrs, buffer->scan_el_attrs,
- sizeof(buffer->scan_el_group.attrs[0])*attrcount_orig);
- attrn = attrcount_orig;
-
- list_for_each_entry(p, &buffer->scan_el_dev_attr_list, l)
- buffer->scan_el_group.attrs[attrn++] = &p->dev_attr.attr;
- indio_dev->groups[indio_dev->groupcounter++] = &buffer->scan_el_group;
-
- return 0;
-
-error_free_scan_mask:
- kfree(buffer->scan_mask);
-error_cleanup_dynamic:
- __iio_buffer_attr_cleanup(indio_dev);
-
- return ret;
-}
-EXPORT_SYMBOL(iio_buffer_register);
-
-void iio_buffer_unregister(struct iio_dev *indio_dev)
-{
- kfree(indio_dev->buffer->scan_mask);
- kfree(indio_dev->buffer->scan_el_group.attrs);
- __iio_buffer_attr_cleanup(indio_dev);
-}
-EXPORT_SYMBOL(iio_buffer_unregister);
-
-ssize_t iio_buffer_read_length(struct device *dev,
- struct device_attribute *attr,
- char *buf)
-{
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
- struct iio_buffer *buffer = indio_dev->buffer;
-
- if (buffer->access->get_length)
- return sprintf(buf, "%d\n",
- buffer->access->get_length(buffer));
-
- return 0;
-}
-EXPORT_SYMBOL(iio_buffer_read_length);
-
-ssize_t iio_buffer_write_length(struct device *dev,
- struct device_attribute *attr,
- const char *buf,
- size_t len)
-{
- int ret;
- ulong val;
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
- struct iio_buffer *buffer = indio_dev->buffer;
-
- ret = strict_strtoul(buf, 10, &val);
- if (ret)
- return ret;
-
- if (buffer->access->get_length)
- if (val == buffer->access->get_length(buffer))
- return len;
-
- mutex_lock(&indio_dev->mlock);
- if (iio_buffer_enabled(indio_dev)) {
- ret = -EBUSY;
- } else {
- if (buffer->access->set_length)
- buffer->access->set_length(buffer, val);
- ret = 0;
- }
- mutex_unlock(&indio_dev->mlock);
-
- return ret ? ret : len;
-}
-EXPORT_SYMBOL(iio_buffer_write_length);
-
-ssize_t iio_buffer_store_enable(struct device *dev,
- struct device_attribute *attr,
- const char *buf,
- size_t len)
-{
- int ret;
- bool requested_state, current_state;
- int previous_mode;
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
- struct iio_buffer *buffer = indio_dev->buffer;
-
- mutex_lock(&indio_dev->mlock);
- previous_mode = indio_dev->currentmode;
- requested_state = !(buf[0] == '0');
- current_state = iio_buffer_enabled(indio_dev);
- if (current_state == requested_state) {
- printk(KERN_INFO "iio-buffer, current state requested again\n");
- goto done;
- }
- if (requested_state) {
- if (indio_dev->setup_ops->preenable) {
- ret = indio_dev->setup_ops->preenable(indio_dev);
- if (ret) {
- printk(KERN_ERR
- "Buffer not started:"
- "buffer preenable failed\n");
- goto error_ret;
- }
- }
- if (buffer->access->request_update) {
- ret = buffer->access->request_update(buffer);
- if (ret) {
- printk(KERN_INFO
- "Buffer not started:"
- "buffer parameter update failed\n");
- goto error_ret;
- }
- }
- /* Definitely possible for devices to support both of these.*/
- if (indio_dev->modes & INDIO_BUFFER_TRIGGERED) {
- if (!indio_dev->trig) {
- printk(KERN_INFO
- "Buffer not started: no trigger\n");
- ret = -EINVAL;
- goto error_ret;
- }
- indio_dev->currentmode = INDIO_BUFFER_TRIGGERED;
- } else if (indio_dev->modes & INDIO_BUFFER_HARDWARE)
- indio_dev->currentmode = INDIO_BUFFER_HARDWARE;
- else { /* should never be reached */
- ret = -EINVAL;
- goto error_ret;
- }
-
- if (indio_dev->setup_ops->postenable) {
- ret = indio_dev->setup_ops->postenable(indio_dev);
- if (ret) {
- printk(KERN_INFO
- "Buffer not started:"
- "postenable failed\n");
- indio_dev->currentmode = previous_mode;
- if (indio_dev->setup_ops->postdisable)
- indio_dev->setup_ops->
- postdisable(indio_dev);
- goto error_ret;
- }
- }
- } else {
- if (indio_dev->setup_ops->predisable) {
- ret = indio_dev->setup_ops->predisable(indio_dev);
- if (ret)
- goto error_ret;
- }
- indio_dev->currentmode = INDIO_DIRECT_MODE;
- if (indio_dev->setup_ops->postdisable) {
- ret = indio_dev->setup_ops->postdisable(indio_dev);
- if (ret)
- goto error_ret;
- }
- }
-done:
- mutex_unlock(&indio_dev->mlock);
- return len;
-
-error_ret:
- mutex_unlock(&indio_dev->mlock);
- return ret;
-}
-EXPORT_SYMBOL(iio_buffer_store_enable);
-
-ssize_t iio_buffer_show_enable(struct device *dev,
- struct device_attribute *attr,
- char *buf)
-{
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
- return sprintf(buf, "%d\n", iio_buffer_enabled(indio_dev));
-}
-EXPORT_SYMBOL(iio_buffer_show_enable);
-
-/* note NULL used as error indicator as it doesn't make sense. */
-static const unsigned long *iio_scan_mask_match(const unsigned long *av_masks,
- unsigned int masklength,
- const unsigned long *mask)
-{
- if (bitmap_empty(mask, masklength))
- return NULL;
- while (*av_masks) {
- if (bitmap_subset(mask, av_masks, masklength))
- return av_masks;
- av_masks += BITS_TO_LONGS(masklength);
- }
- return NULL;
-}
-
-int iio_sw_buffer_preenable(struct iio_dev *indio_dev)
-{
- struct iio_buffer *buffer = indio_dev->buffer;
- const struct iio_chan_spec *ch;
- unsigned bytes = 0;
- int length, i;
- dev_dbg(&indio_dev->dev, "%s\n", __func__);
-
- /* How much space will the demuxed element take? */
- for_each_set_bit(i, buffer->scan_mask,
- indio_dev->masklength) {
- ch = iio_find_channel_from_si(indio_dev, i);
- length = ch->scan_type.storagebits/8;
- bytes = ALIGN(bytes, length);
- bytes += length;
- }
- if (buffer->scan_timestamp) {
- ch = iio_find_channel_from_si(indio_dev,
- buffer->scan_index_timestamp);
- length = ch->scan_type.storagebits/8;
- bytes = ALIGN(bytes, length);
- bytes += length;
- }
- buffer->access->set_bytes_per_datum(buffer, bytes);
-
- /* What scan mask do we actually have ?*/
- if (indio_dev->available_scan_masks)
- indio_dev->active_scan_mask =
- iio_scan_mask_match(indio_dev->available_scan_masks,
- indio_dev->masklength,
- buffer->scan_mask);
- else
- indio_dev->active_scan_mask = buffer->scan_mask;
- iio_update_demux(indio_dev);
-
- if (indio_dev->info->update_scan_mode)
- return indio_dev->info
- ->update_scan_mode(indio_dev,
- indio_dev->active_scan_mask);
- return 0;
-}
-EXPORT_SYMBOL(iio_sw_buffer_preenable);
-
-/**
- * iio_scan_mask_set() - set particular bit in the scan mask
- * @buffer: the buffer whose scan mask we are interested in
- * @bit: the bit to be set.
- **/
-int iio_scan_mask_set(struct iio_dev *indio_dev,
- struct iio_buffer *buffer, int bit)
-{
- const unsigned long *mask;
- unsigned long *trialmask;
-
- trialmask = kmalloc(sizeof(*trialmask)*
- BITS_TO_LONGS(indio_dev->masklength),
- GFP_KERNEL);
-
- if (trialmask == NULL)
- return -ENOMEM;
- if (!indio_dev->masklength) {
- WARN_ON("trying to set scanmask prior to registering buffer\n");
- kfree(trialmask);
- return -EINVAL;
- }
- bitmap_copy(trialmask, buffer->scan_mask, indio_dev->masklength);
- set_bit(bit, trialmask);
-
- if (indio_dev->available_scan_masks) {
- mask = iio_scan_mask_match(indio_dev->available_scan_masks,
- indio_dev->masklength,
- trialmask);
- if (!mask) {
- kfree(trialmask);
- return -EINVAL;
- }
- }
- bitmap_copy(buffer->scan_mask, trialmask, indio_dev->masklength);
-
- kfree(trialmask);
-
- return 0;
-};
-EXPORT_SYMBOL_GPL(iio_scan_mask_set);
-
-int iio_scan_mask_query(struct iio_dev *indio_dev,
- struct iio_buffer *buffer, int bit)
-{
- if (bit > indio_dev->masklength)
- return -EINVAL;
-
- if (!buffer->scan_mask)
- return 0;
-
- return test_bit(bit, buffer->scan_mask);
-};
-EXPORT_SYMBOL_GPL(iio_scan_mask_query);
-
-/**
- * struct iio_demux_table() - table describing demux memcpy ops
- * @from: index to copy from
- * @to: index to copy to
- * @length: how many bytes to copy
- * @l: list head used for management
- */
-struct iio_demux_table {
- unsigned from;
- unsigned to;
- unsigned length;
- struct list_head l;
-};
-
-static unsigned char *iio_demux(struct iio_buffer *buffer,
- unsigned char *datain)
-{
- struct iio_demux_table *t;
-
- if (list_empty(&buffer->demux_list))
- return datain;
- list_for_each_entry(t, &buffer->demux_list, l)
- memcpy(buffer->demux_bounce + t->to,
- datain + t->from, t->length);
-
- return buffer->demux_bounce;
-}
-
-int iio_push_to_buffer(struct iio_buffer *buffer, unsigned char *data,
- s64 timestamp)
-{
- unsigned char *dataout = iio_demux(buffer, data);
-
- return buffer->access->store_to(buffer, dataout, timestamp);
-}
-EXPORT_SYMBOL_GPL(iio_push_to_buffer);
-
-int iio_update_demux(struct iio_dev *indio_dev)
-{
- const struct iio_chan_spec *ch;
- struct iio_buffer *buffer = indio_dev->buffer;
- int ret, in_ind = -1, out_ind, length;
- unsigned in_loc = 0, out_loc = 0;
- struct iio_demux_table *p, *q;
-
- /* Clear out any old demux */
- list_for_each_entry_safe(p, q, &buffer->demux_list, l) {
- list_del(&p->l);
- kfree(p);
- }
- kfree(buffer->demux_bounce);
- buffer->demux_bounce = NULL;
-
- /* First work out which scan mode we will actually have */
- if (bitmap_equal(indio_dev->active_scan_mask,
- buffer->scan_mask,
- indio_dev->masklength))
- return 0;
-
- /* Now we have the two masks, work from least sig and build up sizes */
- for_each_set_bit(out_ind,
- indio_dev->active_scan_mask,
- indio_dev->masklength) {
- in_ind = find_next_bit(indio_dev->active_scan_mask,
- indio_dev->masklength,
- in_ind + 1);
- while (in_ind != out_ind) {
- in_ind = find_next_bit(indio_dev->active_scan_mask,
- indio_dev->masklength,
- in_ind + 1);
- ch = iio_find_channel_from_si(indio_dev, in_ind);
- length = ch->scan_type.storagebits/8;
- /* Make sure we are aligned */
- in_loc += length;
- if (in_loc % length)
- in_loc += length - in_loc % length;
- }
- p = kmalloc(sizeof(*p), GFP_KERNEL);
- if (p == NULL) {
- ret = -ENOMEM;
- goto error_clear_mux_table;
- }
- ch = iio_find_channel_from_si(indio_dev, in_ind);
- length = ch->scan_type.storagebits/8;
- if (out_loc % length)
- out_loc += length - out_loc % length;
- if (in_loc % length)
- in_loc += length - in_loc % length;
- p->from = in_loc;
- p->to = out_loc;
- p->length = length;
- list_add_tail(&p->l, &buffer->demux_list);
- out_loc += length;
- in_loc += length;
- }
- /* Relies on scan_timestamp being last */
- if (buffer->scan_timestamp) {
- p = kmalloc(sizeof(*p), GFP_KERNEL);
- if (p == NULL) {
- ret = -ENOMEM;
- goto error_clear_mux_table;
- }
- ch = iio_find_channel_from_si(indio_dev,
- buffer->scan_index_timestamp);
- length = ch->scan_type.storagebits/8;
- if (out_loc % length)
- out_loc += length - out_loc % length;
- if (in_loc % length)
- in_loc += length - in_loc % length;
- p->from = in_loc;
- p->to = out_loc;
- p->length = length;
- list_add_tail(&p->l, &buffer->demux_list);
- out_loc += length;
- in_loc += length;
- }
- buffer->demux_bounce = kzalloc(out_loc, GFP_KERNEL);
- if (buffer->demux_bounce == NULL) {
- ret = -ENOMEM;
- goto error_clear_mux_table;
- }
- return 0;
-
-error_clear_mux_table:
- list_for_each_entry_safe(p, q, &buffer->demux_list, l) {
- list_del(&p->l);
- kfree(p);
- }
- return ret;
-}
-EXPORT_SYMBOL_GPL(iio_update_demux);
diff --git a/drivers/staging/iio/industrialio-core.c b/drivers/staging/iio/industrialio-core.c
deleted file mode 100644
index d303bfbff27f..000000000000
--- a/drivers/staging/iio/industrialio-core.c
+++ /dev/null
@@ -1,927 +0,0 @@
-/* The industrial I/O core
- *
- * Copyright (c) 2008 Jonathan Cameron
- *
- * 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.
- *
- * Based on elements of hwmon and input subsystems.
- */
-
-#include <linux/kernel.h>
-#include <linux/module.h>
-#include <linux/idr.h>
-#include <linux/kdev_t.h>
-#include <linux/err.h>
-#include <linux/device.h>
-#include <linux/fs.h>
-#include <linux/poll.h>
-#include <linux/sched.h>
-#include <linux/wait.h>
-#include <linux/cdev.h>
-#include <linux/slab.h>
-#include <linux/anon_inodes.h>
-#include <linux/debugfs.h>
-#include "iio.h"
-#include "iio_core.h"
-#include "iio_core_trigger.h"
-#include "sysfs.h"
-#include "events.h"
-
-/* IDA to assign each registered device a unique id*/
-static DEFINE_IDA(iio_ida);
-
-static dev_t iio_devt;
-
-#define IIO_DEV_MAX 256
-struct bus_type iio_bus_type = {
- .name = "iio",
-};
-EXPORT_SYMBOL(iio_bus_type);
-
-static struct dentry *iio_debugfs_dentry;
-
-static const char * const iio_data_type_name[] = {
- [IIO_RAW] = "raw",
- [IIO_PROCESSED] = "input",
-};
-
-static const char * const iio_direction[] = {
- [0] = "in",
- [1] = "out",
-};
-
-static const char * const iio_chan_type_name_spec[] = {
- [IIO_VOLTAGE] = "voltage",
- [IIO_CURRENT] = "current",
- [IIO_POWER] = "power",
- [IIO_ACCEL] = "accel",
- [IIO_ANGL_VEL] = "anglvel",
- [IIO_MAGN] = "magn",
- [IIO_LIGHT] = "illuminance",
- [IIO_INTENSITY] = "intensity",
- [IIO_PROXIMITY] = "proximity",
- [IIO_TEMP] = "temp",
- [IIO_INCLI] = "incli",
- [IIO_ROT] = "rot",
- [IIO_ANGL] = "angl",
- [IIO_TIMESTAMP] = "timestamp",
- [IIO_CAPACITANCE] = "capacitance",
-};
-
-static const char * const iio_modifier_names[] = {
- [IIO_MOD_X] = "x",
- [IIO_MOD_Y] = "y",
- [IIO_MOD_Z] = "z",
- [IIO_MOD_LIGHT_BOTH] = "both",
- [IIO_MOD_LIGHT_IR] = "ir",
-};
-
-/* relies on pairs of these shared then separate */
-static const char * const iio_chan_info_postfix[] = {
- [IIO_CHAN_INFO_SCALE] = "scale",
- [IIO_CHAN_INFO_OFFSET] = "offset",
- [IIO_CHAN_INFO_CALIBSCALE] = "calibscale",
- [IIO_CHAN_INFO_CALIBBIAS] = "calibbias",
- [IIO_CHAN_INFO_PEAK] = "peak_raw",
- [IIO_CHAN_INFO_PEAK_SCALE] = "peak_scale",
- [IIO_CHAN_INFO_QUADRATURE_CORRECTION_RAW] = "quadrature_correction_raw",
- [IIO_CHAN_INFO_AVERAGE_RAW] = "mean_raw",
- [IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY]
- = "filter_low_pass_3db_frequency",
-};
-
-const struct iio_chan_spec
-*iio_find_channel_from_si(struct iio_dev *indio_dev, int si)
-{
- int i;
-
- for (i = 0; i < indio_dev->num_channels; i++)
- if (indio_dev->channels[i].scan_index == si)
- return &indio_dev->channels[i];
- return NULL;
-}
-
-/* This turns up an awful lot */
-ssize_t iio_read_const_attr(struct device *dev,
- struct device_attribute *attr,
- char *buf)
-{
- return sprintf(buf, "%s\n", to_iio_const_attr(attr)->string);
-}
-EXPORT_SYMBOL(iio_read_const_attr);
-
-static int __init iio_init(void)
-{
- int ret;
-
- /* Register sysfs bus */
- ret = bus_register(&iio_bus_type);
- if (ret < 0) {
- printk(KERN_ERR
- "%s could not register bus type\n",
- __FILE__);
- goto error_nothing;
- }
-
- ret = alloc_chrdev_region(&iio_devt, 0, IIO_DEV_MAX, "iio");
- if (ret < 0) {
- printk(KERN_ERR "%s: failed to allocate char dev region\n",
- __FILE__);
- goto error_unregister_bus_type;
- }
-
- iio_debugfs_dentry = debugfs_create_dir("iio", NULL);
-
- return 0;
-
-error_unregister_bus_type:
- bus_unregister(&iio_bus_type);
-error_nothing:
- return ret;
-}
-
-static void __exit iio_exit(void)
-{
- if (iio_devt)
- unregister_chrdev_region(iio_devt, IIO_DEV_MAX);
- bus_unregister(&iio_bus_type);
- debugfs_remove(iio_debugfs_dentry);
-}
-
-#if defined(CONFIG_DEBUG_FS)
-static int iio_debugfs_open(struct inode *inode, struct file *file)
-{
- if (inode->i_private)
- file->private_data = inode->i_private;
-
- return 0;
-}
-
-static ssize_t iio_debugfs_read_reg(struct file *file, char __user *userbuf,
- size_t count, loff_t *ppos)
-{
- struct iio_dev *indio_dev = file->private_data;
- char buf[20];
- unsigned val = 0;
- ssize_t len;
- int ret;
-
- ret = indio_dev->info->debugfs_reg_access(indio_dev,
- indio_dev->cached_reg_addr,
- 0, &val);
- if (ret)
- dev_err(indio_dev->dev.parent, "%s: read failed\n", __func__);
-
- len = snprintf(buf, sizeof(buf), "0x%X\n", val);
-
- return simple_read_from_buffer(userbuf, count, ppos, buf, len);
-}
-
-static ssize_t iio_debugfs_write_reg(struct file *file,
- const char __user *userbuf, size_t count, loff_t *ppos)
-{
- struct iio_dev *indio_dev = file->private_data;
- unsigned reg, val;
- char buf[80];
- int ret;
-
- count = min_t(size_t, count, (sizeof(buf)-1));
- if (copy_from_user(buf, userbuf, count))
- return -EFAULT;
-
- buf[count] = 0;
-
- ret = sscanf(buf, "%i %i", &reg, &val);
-
- switch (ret) {
- case 1:
- indio_dev->cached_reg_addr = reg;
- break;
- case 2:
- indio_dev->cached_reg_addr = reg;
- ret = indio_dev->info->debugfs_reg_access(indio_dev, reg,
- val, NULL);
- if (ret) {
- dev_err(indio_dev->dev.parent, "%s: write failed\n",
- __func__);
- return ret;
- }
- break;
- default:
- return -EINVAL;
- }
-
- return count;
-}
-
-static const struct file_operations iio_debugfs_reg_fops = {
- .open = iio_debugfs_open,
- .read = iio_debugfs_read_reg,
- .write = iio_debugfs_write_reg,
-};
-
-static void iio_device_unregister_debugfs(struct iio_dev *indio_dev)
-{
- debugfs_remove_recursive(indio_dev->debugfs_dentry);
-}
-
-static int iio_device_register_debugfs(struct iio_dev *indio_dev)
-{
- struct dentry *d;
-
- if (indio_dev->info->debugfs_reg_access == NULL)
- return 0;
-
- if (IS_ERR(iio_debugfs_dentry))
- return 0;
-
- indio_dev->debugfs_dentry =
- debugfs_create_dir(dev_name(&indio_dev->dev),
- iio_debugfs_dentry);
- if (IS_ERR(indio_dev->debugfs_dentry))
- return PTR_ERR(indio_dev->debugfs_dentry);
-
- if (indio_dev->debugfs_dentry == NULL) {
- dev_warn(indio_dev->dev.parent,
- "Failed to create debugfs directory\n");
- return -EFAULT;
- }
-
- d = debugfs_create_file("direct_reg_access", 0644,
- indio_dev->debugfs_dentry,
- indio_dev, &iio_debugfs_reg_fops);
- if (!d) {
- iio_device_unregister_debugfs(indio_dev);
- return -ENOMEM;
- }
-
- return 0;
-}
-#else
-static int iio_device_register_debugfs(struct iio_dev *indio_dev)
-{
- return 0;
-}
-
-static void iio_device_unregister_debugfs(struct iio_dev *indio_dev)
-{
-}
-#endif /* CONFIG_DEBUG_FS */
-
-static ssize_t iio_read_channel_ext_info(struct device *dev,
- struct device_attribute *attr,
- char *buf)
-{
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
- struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
- const struct iio_chan_spec_ext_info *ext_info;
-
- ext_info = &this_attr->c->ext_info[this_attr->address];
-
- return ext_info->read(indio_dev, this_attr->c, buf);
-}
-
-static ssize_t iio_write_channel_ext_info(struct device *dev,
- struct device_attribute *attr,
- const char *buf,
- size_t len)
-{
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
- struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
- const struct iio_chan_spec_ext_info *ext_info;
-
- ext_info = &this_attr->c->ext_info[this_attr->address];
-
- return ext_info->write(indio_dev, this_attr->c, buf, len);
-}
-
-static ssize_t iio_read_channel_info(struct device *dev,
- struct device_attribute *attr,
- char *buf)
-{
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
- struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
- int val, val2;
- int ret = indio_dev->info->read_raw(indio_dev, this_attr->c,
- &val, &val2, this_attr->address);
-
- if (ret < 0)
- return ret;
-
- if (ret == IIO_VAL_INT)
- return sprintf(buf, "%d\n", val);
- else if (ret == IIO_VAL_INT_PLUS_MICRO) {
- if (val2 < 0)
- return sprintf(buf, "-%d.%06u\n", val, -val2);
- else
- return sprintf(buf, "%d.%06u\n", val, val2);
- } else if (ret == IIO_VAL_INT_PLUS_NANO) {
- if (val2 < 0)
- return sprintf(buf, "-%d.%09u\n", val, -val2);
- else
- return sprintf(buf, "%d.%09u\n", val, val2);
- } else
- return 0;
-}
-
-static ssize_t iio_write_channel_info(struct device *dev,
- struct device_attribute *attr,
- const char *buf,
- size_t len)
-{
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
- struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
- int ret, integer = 0, fract = 0, fract_mult = 100000;
- bool integer_part = true, negative = false;
-
- /* Assumes decimal - precision based on number of digits */
- if (!indio_dev->info->write_raw)
- return -EINVAL;
-
- if (indio_dev->info->write_raw_get_fmt)
- switch (indio_dev->info->write_raw_get_fmt(indio_dev,
- this_attr->c, this_attr->address)) {
- case IIO_VAL_INT_PLUS_MICRO:
- fract_mult = 100000;
- break;
- case IIO_VAL_INT_PLUS_NANO:
- fract_mult = 100000000;
- break;
- default:
- return -EINVAL;
- }
-
- if (buf[0] == '-') {
- negative = true;
- buf++;
- }
-
- while (*buf) {
- if ('0' <= *buf && *buf <= '9') {
- if (integer_part)
- integer = integer*10 + *buf - '0';
- else {
- fract += fract_mult*(*buf - '0');
- if (fract_mult == 1)
- break;
- fract_mult /= 10;
- }
- } else if (*buf == '\n') {
- if (*(buf + 1) == '\0')
- break;
- else
- return -EINVAL;
- } else if (*buf == '.') {
- integer_part = false;
- } else {
- return -EINVAL;
- }
- buf++;
- }
- if (negative) {
- if (integer)
- integer = -integer;
- else
- fract = -fract;
- }
-
- ret = indio_dev->info->write_raw(indio_dev, this_attr->c,
- integer, fract, this_attr->address);
- if (ret)
- return ret;
-
- return len;
-}
-
-static
-int __iio_device_attr_init(struct device_attribute *dev_attr,
- const char *postfix,
- struct iio_chan_spec const *chan,
- ssize_t (*readfunc)(struct device *dev,
- struct device_attribute *attr,
- char *buf),
- ssize_t (*writefunc)(struct device *dev,
- struct device_attribute *attr,
- const char *buf,
- size_t len),
- bool generic)
-{
- int ret;
- char *name_format, *full_postfix;
- sysfs_attr_init(&dev_attr->attr);
-
- /* Build up postfix of <extend_name>_<modifier>_postfix */
- if (chan->modified && !generic) {
- if (chan->extend_name)
- full_postfix = kasprintf(GFP_KERNEL, "%s_%s_%s",
- iio_modifier_names[chan
- ->channel2],
- chan->extend_name,
- postfix);
- else
- full_postfix = kasprintf(GFP_KERNEL, "%s_%s",
- iio_modifier_names[chan
- ->channel2],
- postfix);
- } else {
- if (chan->extend_name == NULL)
- full_postfix = kstrdup(postfix, GFP_KERNEL);
- else
- full_postfix = kasprintf(GFP_KERNEL,
- "%s_%s",
- chan->extend_name,
- postfix);
- }
- if (full_postfix == NULL) {
- ret = -ENOMEM;
- goto error_ret;
- }
-
- if (chan->differential) { /* Differential can not have modifier */
- if (generic)
- name_format
- = kasprintf(GFP_KERNEL, "%s_%s-%s_%s",
- iio_direction[chan->output],
- iio_chan_type_name_spec[chan->type],
- iio_chan_type_name_spec[chan->type],
- full_postfix);
- else if (chan->indexed)
- name_format
- = kasprintf(GFP_KERNEL, "%s_%s%d-%s%d_%s",
- iio_direction[chan->output],
- iio_chan_type_name_spec[chan->type],
- chan->channel,
- iio_chan_type_name_spec[chan->type],
- chan->channel2,
- full_postfix);
- else {
- WARN_ON("Differential channels must be indexed\n");
- ret = -EINVAL;
- goto error_free_full_postfix;
- }
- } else { /* Single ended */
- if (generic)
- name_format
- = kasprintf(GFP_KERNEL, "%s_%s_%s",
- iio_direction[chan->output],
- iio_chan_type_name_spec[chan->type],
- full_postfix);
- else if (chan->indexed)
- name_format
- = kasprintf(GFP_KERNEL, "%s_%s%d_%s",
- iio_direction[chan->output],
- iio_chan_type_name_spec[chan->type],
- chan->channel,
- full_postfix);
- else
- name_format
- = kasprintf(GFP_KERNEL, "%s_%s_%s",
- iio_direction[chan->output],
- iio_chan_type_name_spec[chan->type],
- full_postfix);
- }
- if (name_format == NULL) {
- ret = -ENOMEM;
- goto error_free_full_postfix;
- }
- dev_attr->attr.name = kasprintf(GFP_KERNEL,
- name_format,
- chan->channel,
- chan->channel2);
- if (dev_attr->attr.name == NULL) {
- ret = -ENOMEM;
- goto error_free_name_format;
- }
-
- if (readfunc) {
- dev_attr->attr.mode |= S_IRUGO;
- dev_attr->show = readfunc;
- }
-
- if (writefunc) {
- dev_attr->attr.mode |= S_IWUSR;
- dev_attr->store = writefunc;
- }
- kfree(name_format);
- kfree(full_postfix);
-
- return 0;
-
-error_free_name_format:
- kfree(name_format);
-error_free_full_postfix:
- kfree(full_postfix);
-error_ret:
- return ret;
-}
-
-static void __iio_device_attr_deinit(struct device_attribute *dev_attr)
-{
- kfree(dev_attr->attr.name);
-}
-
-int __iio_add_chan_devattr(const char *postfix,
- struct iio_chan_spec const *chan,
- ssize_t (*readfunc)(struct device *dev,
- struct device_attribute *attr,
- char *buf),
- ssize_t (*writefunc)(struct device *dev,
- struct device_attribute *attr,
- const char *buf,
- size_t len),
- u64 mask,
- bool generic,
- struct device *dev,
- struct list_head *attr_list)
-{
- int ret;
- struct iio_dev_attr *iio_attr, *t;
-
- iio_attr = kzalloc(sizeof *iio_attr, GFP_KERNEL);
- if (iio_attr == NULL) {
- ret = -ENOMEM;
- goto error_ret;
- }
- ret = __iio_device_attr_init(&iio_attr->dev_attr,
- postfix, chan,
- readfunc, writefunc, generic);
- if (ret)
- goto error_iio_dev_attr_free;
- iio_attr->c = chan;
- iio_attr->address = mask;
- list_for_each_entry(t, attr_list, l)
- if (strcmp(t->dev_attr.attr.name,
- iio_attr->dev_attr.attr.name) == 0) {
- if (!generic)
- dev_err(dev, "tried to double register : %s\n",
- t->dev_attr.attr.name);
- ret = -EBUSY;
- goto error_device_attr_deinit;
- }
- list_add(&iio_attr->l, attr_list);
-
- return 0;
-
-error_device_attr_deinit:
- __iio_device_attr_deinit(&iio_attr->dev_attr);
-error_iio_dev_attr_free:
- kfree(iio_attr);
-error_ret:
- return ret;
-}
-
-static int iio_device_add_channel_sysfs(struct iio_dev *indio_dev,
- struct iio_chan_spec const *chan)
-{
- int ret, i, attrcount = 0;
- const struct iio_chan_spec_ext_info *ext_info;
-
- if (chan->channel < 0)
- return 0;
-
- ret = __iio_add_chan_devattr(iio_data_type_name[chan->processed_val],
- chan,
- &iio_read_channel_info,
- (chan->output ?
- &iio_write_channel_info : NULL),
- 0,
- 0,
- &indio_dev->dev,
- &indio_dev->channel_attr_list);
- if (ret)
- goto error_ret;
- attrcount++;
-
- for_each_set_bit(i, &chan->info_mask, sizeof(long)*8) {
- ret = __iio_add_chan_devattr(iio_chan_info_postfix[i/2],
- chan,
- &iio_read_channel_info,
- &iio_write_channel_info,
- i/2,
- !(i%2),
- &indio_dev->dev,
- &indio_dev->channel_attr_list);
- if (ret == -EBUSY && (i%2 == 0)) {
- ret = 0;
- continue;
- }
- if (ret < 0)
- goto error_ret;
- attrcount++;
- }
-
- if (chan->ext_info) {
- unsigned int i = 0;
- for (ext_info = chan->ext_info; ext_info->name; ext_info++) {
- ret = __iio_add_chan_devattr(ext_info->name,
- chan,
- ext_info->read ?
- &iio_read_channel_ext_info : NULL,
- ext_info->write ?
- &iio_write_channel_ext_info : NULL,
- i,
- ext_info->shared,
- &indio_dev->dev,
- &indio_dev->channel_attr_list);
- i++;
- if (ret == -EBUSY && ext_info->shared)
- continue;
-
- if (ret)
- goto error_ret;
-
- attrcount++;
- }
- }
-
- ret = attrcount;
-error_ret:
- return ret;
-}
-
-static void iio_device_remove_and_free_read_attr(struct iio_dev *indio_dev,
- struct iio_dev_attr *p)
-{
- kfree(p->dev_attr.attr.name);
- kfree(p);
-}
-
-static ssize_t iio_show_dev_name(struct device *dev,
- struct device_attribute *attr,
- char *buf)
-{
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
- return sprintf(buf, "%s\n", indio_dev->name);
-}
-
-static DEVICE_ATTR(name, S_IRUGO, iio_show_dev_name, NULL);
-
-static int iio_device_register_sysfs(struct iio_dev *indio_dev)
-{
- int i, ret = 0, attrcount, attrn, attrcount_orig = 0;
- struct iio_dev_attr *p, *n;
- struct attribute **attr;
-
- /* First count elements in any existing group */
- if (indio_dev->info->attrs) {
- attr = indio_dev->info->attrs->attrs;
- while (*attr++ != NULL)
- attrcount_orig++;
- }
- attrcount = attrcount_orig;
- /*
- * New channel registration method - relies on the fact a group does
- * not need to be initialized if it is name is NULL.
- */
- INIT_LIST_HEAD(&indio_dev->channel_attr_list);
- if (indio_dev->channels)
- for (i = 0; i < indio_dev->num_channels; i++) {
- ret = iio_device_add_channel_sysfs(indio_dev,
- &indio_dev
- ->channels[i]);
- if (ret < 0)
- goto error_clear_attrs;
- attrcount += ret;
- }
-
- if (indio_dev->name)
- attrcount++;
-
- indio_dev->chan_attr_group.attrs = kcalloc(attrcount + 1,
- sizeof(indio_dev->chan_attr_group.attrs[0]),
- GFP_KERNEL);
- if (indio_dev->chan_attr_group.attrs == NULL) {
- ret = -ENOMEM;
- goto error_clear_attrs;
- }
- /* Copy across original attributes */
- if (indio_dev->info->attrs)
- memcpy(indio_dev->chan_attr_group.attrs,
- indio_dev->info->attrs->attrs,
- sizeof(indio_dev->chan_attr_group.attrs[0])
- *attrcount_orig);
- attrn = attrcount_orig;
- /* Add all elements from the list. */
- list_for_each_entry(p, &indio_dev->channel_attr_list, l)
- indio_dev->chan_attr_group.attrs[attrn++] = &p->dev_attr.attr;
- if (indio_dev->name)
- indio_dev->chan_attr_group.attrs[attrn++] = &dev_attr_name.attr;
-
- indio_dev->groups[indio_dev->groupcounter++] =
- &indio_dev->chan_attr_group;
-
- return 0;
-
-error_clear_attrs:
- list_for_each_entry_safe(p, n,
- &indio_dev->channel_attr_list, l) {
- list_del(&p->l);
- iio_device_remove_and_free_read_attr(indio_dev, p);
- }
-
- return ret;
-}
-
-static void iio_device_unregister_sysfs(struct iio_dev *indio_dev)
-{
-
- struct iio_dev_attr *p, *n;
-
- list_for_each_entry_safe(p, n, &indio_dev->channel_attr_list, l) {
- list_del(&p->l);
- iio_device_remove_and_free_read_attr(indio_dev, p);
- }
- kfree(indio_dev->chan_attr_group.attrs);
-}
-
-static void iio_dev_release(struct device *device)
-{
- struct iio_dev *indio_dev = container_of(device, struct iio_dev, dev);
- cdev_del(&indio_dev->chrdev);
- if (indio_dev->modes & INDIO_BUFFER_TRIGGERED)
- iio_device_unregister_trigger_consumer(indio_dev);
- iio_device_unregister_eventset(indio_dev);
- iio_device_unregister_sysfs(indio_dev);
- iio_device_unregister_debugfs(indio_dev);
-}
-
-static struct device_type iio_dev_type = {
- .name = "iio_device",
- .release = iio_dev_release,
-};
-
-struct iio_dev *iio_allocate_device(int sizeof_priv)
-{
- struct iio_dev *dev;
- size_t alloc_size;
-
- alloc_size = sizeof(struct iio_dev);
- if (sizeof_priv) {
- alloc_size = ALIGN(alloc_size, IIO_ALIGN);
- alloc_size += sizeof_priv;
- }
- /* ensure 32-byte alignment of whole construct ? */
- alloc_size += IIO_ALIGN - 1;
-
- dev = kzalloc(alloc_size, GFP_KERNEL);
-
- if (dev) {
- dev->dev.groups = dev->groups;
- dev->dev.type = &iio_dev_type;
- dev->dev.bus = &iio_bus_type;
- device_initialize(&dev->dev);
- dev_set_drvdata(&dev->dev, (void *)dev);
- mutex_init(&dev->mlock);
- mutex_init(&dev->info_exist_lock);
-
- dev->id = ida_simple_get(&iio_ida, 0, 0, GFP_KERNEL);
- if (dev->id < 0) {
- /* cannot use a dev_err as the name isn't available */
- printk(KERN_ERR "Failed to get id\n");
- kfree(dev);
- return NULL;
- }
- dev_set_name(&dev->dev, "iio:device%d", dev->id);
- }
-
- return dev;
-}
-EXPORT_SYMBOL(iio_allocate_device);
-
-void iio_free_device(struct iio_dev *dev)
-{
- if (dev) {
- ida_simple_remove(&iio_ida, dev->id);
- kfree(dev);
- }
-}
-EXPORT_SYMBOL(iio_free_device);
-
-/**
- * iio_chrdev_open() - chrdev file open for buffer access and ioctls
- **/
-static int iio_chrdev_open(struct inode *inode, struct file *filp)
-{
- struct iio_dev *indio_dev = container_of(inode->i_cdev,
- struct iio_dev, chrdev);
-
- if (test_and_set_bit(IIO_BUSY_BIT_POS, &indio_dev->flags))
- return -EBUSY;
-
- filp->private_data = indio_dev;
-
- return 0;
-}
-
-/**
- * iio_chrdev_release() - chrdev file close buffer access and ioctls
- **/
-static int iio_chrdev_release(struct inode *inode, struct file *filp)
-{
- struct iio_dev *indio_dev = container_of(inode->i_cdev,
- struct iio_dev, chrdev);
- clear_bit(IIO_BUSY_BIT_POS, &indio_dev->flags);
- return 0;
-}
-
-/* Somewhat of a cross file organization violation - ioctls here are actually
- * event related */
-static long iio_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
-{
- struct iio_dev *indio_dev = filp->private_data;
- int __user *ip = (int __user *)arg;
- int fd;
-
- if (cmd == IIO_GET_EVENT_FD_IOCTL) {
- fd = iio_event_getfd(indio_dev);
- if (copy_to_user(ip, &fd, sizeof(fd)))
- return -EFAULT;
- return 0;
- }
- return -EINVAL;
-}
-
-static const struct file_operations iio_buffer_fileops = {
- .read = iio_buffer_read_first_n_outer_addr,
- .release = iio_chrdev_release,
- .open = iio_chrdev_open,
- .poll = iio_buffer_poll_addr,
- .owner = THIS_MODULE,
- .llseek = noop_llseek,
- .unlocked_ioctl = iio_ioctl,
- .compat_ioctl = iio_ioctl,
-};
-
-static const struct iio_buffer_setup_ops noop_ring_setup_ops;
-
-int iio_device_register(struct iio_dev *indio_dev)
-{
- int ret;
-
- /* configure elements for the chrdev */
- indio_dev->dev.devt = MKDEV(MAJOR(iio_devt), indio_dev->id);
-
- ret = iio_device_register_debugfs(indio_dev);
- if (ret) {
- dev_err(indio_dev->dev.parent,
- "Failed to register debugfs interfaces\n");
- goto error_ret;
- }
- ret = iio_device_register_sysfs(indio_dev);
- if (ret) {
- dev_err(indio_dev->dev.parent,
- "Failed to register sysfs interfaces\n");
- goto error_unreg_debugfs;
- }
- ret = iio_device_register_eventset(indio_dev);
- if (ret) {
- dev_err(indio_dev->dev.parent,
- "Failed to register event set\n");
- goto error_free_sysfs;
- }
- if (indio_dev->modes & INDIO_BUFFER_TRIGGERED)
- iio_device_register_trigger_consumer(indio_dev);
-
- if ((indio_dev->modes & INDIO_ALL_BUFFER_MODES) &&
- indio_dev->setup_ops == NULL)
- indio_dev->setup_ops = &noop_ring_setup_ops;
-
- ret = device_add(&indio_dev->dev);
- if (ret < 0)
- goto error_unreg_eventset;
- cdev_init(&indio_dev->chrdev, &iio_buffer_fileops);
- indio_dev->chrdev.owner = indio_dev->info->driver_module;
- ret = cdev_add(&indio_dev->chrdev, indio_dev->dev.devt, 1);
- if (ret < 0)
- goto error_del_device;
- return 0;
-
-error_del_device:
- device_del(&indio_dev->dev);
-error_unreg_eventset:
- iio_device_unregister_eventset(indio_dev);
-error_free_sysfs:
- iio_device_unregister_sysfs(indio_dev);
-error_unreg_debugfs:
- iio_device_unregister_debugfs(indio_dev);
-error_ret:
- return ret;
-}
-EXPORT_SYMBOL(iio_device_register);
-
-void iio_device_unregister(struct iio_dev *indio_dev)
-{
- mutex_lock(&indio_dev->info_exist_lock);
- indio_dev->info = NULL;
- mutex_unlock(&indio_dev->info_exist_lock);
- device_unregister(&indio_dev->dev);
-}
-EXPORT_SYMBOL(iio_device_unregister);
-subsys_initcall(iio_init);
-module_exit(iio_exit);
-
-MODULE_AUTHOR("Jonathan Cameron <jic23@cam.ac.uk>");
-MODULE_DESCRIPTION("Industrial I/O core");
-MODULE_LICENSE("GPL");
diff --git a/drivers/staging/iio/industrialio-event.c b/drivers/staging/iio/industrialio-event.c
deleted file mode 100644
index 5fdf739e38f9..000000000000
--- a/drivers/staging/iio/industrialio-event.c
+++ /dev/null
@@ -1,453 +0,0 @@
-/* Industrial I/O event handling
- *
- * Copyright (c) 2008 Jonathan Cameron
- *
- * 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.
- *
- * Based on elements of hwmon and input subsystems.
- */
-
-#include <linux/anon_inodes.h>
-#include <linux/device.h>
-#include <linux/fs.h>
-#include <linux/kernel.h>
-#include <linux/kfifo.h>
-#include <linux/module.h>
-#include <linux/poll.h>
-#include <linux/sched.h>
-#include <linux/slab.h>
-#include <linux/uaccess.h>
-#include <linux/wait.h>
-#include "iio.h"
-#include "iio_core.h"
-#include "sysfs.h"
-#include "events.h"
-
-/**
- * struct iio_event_interface - chrdev interface for an event line
- * @wait: wait queue to allow blocking reads of events
- * @det_events: list of detected events
- * @dev_attr_list: list of event interface sysfs attribute
- * @flags: file operations related flags including busy flag.
- * @group: event interface sysfs attribute group
- */
-struct iio_event_interface {
- wait_queue_head_t wait;
- DECLARE_KFIFO(det_events, struct iio_event_data, 16);
-
- struct list_head dev_attr_list;
- unsigned long flags;
- struct attribute_group group;
-};
-
-int iio_push_event(struct iio_dev *indio_dev, u64 ev_code, s64 timestamp)
-{
- struct iio_event_interface *ev_int = indio_dev->event_interface;
- struct iio_event_data ev;
- int copied;
-
- /* Does anyone care? */
- spin_lock(&ev_int->wait.lock);
- if (test_bit(IIO_BUSY_BIT_POS, &ev_int->flags)) {
-
- ev.id = ev_code;
- ev.timestamp = timestamp;
-
- copied = kfifo_put(&ev_int->det_events, &ev);
- if (copied != 0)
- wake_up_locked_poll(&ev_int->wait, POLLIN);
- }
- spin_unlock(&ev_int->wait.lock);
-
- return 0;
-}
-EXPORT_SYMBOL(iio_push_event);
-
-/**
- * iio_event_poll() - poll the event queue to find out if it has data
- */
-static unsigned int iio_event_poll(struct file *filep,
- struct poll_table_struct *wait)
-{
- struct iio_event_interface *ev_int = filep->private_data;
- unsigned int events = 0;
-
- poll_wait(filep, &ev_int->wait, wait);
-
- spin_lock(&ev_int->wait.lock);
- if (!kfifo_is_empty(&ev_int->det_events))
- events = POLLIN | POLLRDNORM;
- spin_unlock(&ev_int->wait.lock);
-
- return events;
-}
-
-static ssize_t iio_event_chrdev_read(struct file *filep,
- char __user *buf,
- size_t count,
- loff_t *f_ps)
-{
- struct iio_event_interface *ev_int = filep->private_data;
- unsigned int copied;
- int ret;
-
- if (count < sizeof(struct iio_event_data))
- return -EINVAL;
-
- spin_lock(&ev_int->wait.lock);
- if (kfifo_is_empty(&ev_int->det_events)) {
- if (filep->f_flags & O_NONBLOCK) {
- ret = -EAGAIN;
- goto error_unlock;
- }
- /* Blocking on device; waiting for something to be there */
- ret = wait_event_interruptible_locked(ev_int->wait,
- !kfifo_is_empty(&ev_int->det_events));
- if (ret)
- goto error_unlock;
- /* Single access device so no one else can get the data */
- }
-
- ret = kfifo_to_user(&ev_int->det_events, buf, count, &copied);
-
-error_unlock:
- spin_unlock(&ev_int->wait.lock);
-
- return ret ? ret : copied;
-}
-
-static int iio_event_chrdev_release(struct inode *inode, struct file *filep)
-{
- struct iio_event_interface *ev_int = filep->private_data;
-
- spin_lock(&ev_int->wait.lock);
- __clear_bit(IIO_BUSY_BIT_POS, &ev_int->flags);
- /*
- * In order to maintain a clean state for reopening,
- * clear out any awaiting events. The mask will prevent
- * any new __iio_push_event calls running.
- */
- kfifo_reset_out(&ev_int->det_events);
- spin_unlock(&ev_int->wait.lock);
-
- return 0;
-}
-
-static const struct file_operations iio_event_chrdev_fileops = {
- .read = iio_event_chrdev_read,
- .poll = iio_event_poll,
- .release = iio_event_chrdev_release,
- .owner = THIS_MODULE,
- .llseek = noop_llseek,
-};
-
-int iio_event_getfd(struct iio_dev *indio_dev)
-{
- struct iio_event_interface *ev_int = indio_dev->event_interface;
- int fd;
-
- if (ev_int == NULL)
- return -ENODEV;
-
- spin_lock(&ev_int->wait.lock);
- if (__test_and_set_bit(IIO_BUSY_BIT_POS, &ev_int->flags)) {
- spin_unlock(&ev_int->wait.lock);
- return -EBUSY;
- }
- spin_unlock(&ev_int->wait.lock);
- fd = anon_inode_getfd("iio:event",
- &iio_event_chrdev_fileops, ev_int, O_RDONLY);
- if (fd < 0) {
- spin_lock(&ev_int->wait.lock);
- __clear_bit(IIO_BUSY_BIT_POS, &ev_int->flags);
- spin_unlock(&ev_int->wait.lock);
- }
- return fd;
-}
-
-static const char * const iio_ev_type_text[] = {
- [IIO_EV_TYPE_THRESH] = "thresh",
- [IIO_EV_TYPE_MAG] = "mag",
- [IIO_EV_TYPE_ROC] = "roc",
- [IIO_EV_TYPE_THRESH_ADAPTIVE] = "thresh_adaptive",
- [IIO_EV_TYPE_MAG_ADAPTIVE] = "mag_adaptive",
-};
-
-static const char * const iio_ev_dir_text[] = {
- [IIO_EV_DIR_EITHER] = "either",
- [IIO_EV_DIR_RISING] = "rising",
- [IIO_EV_DIR_FALLING] = "falling"
-};
-
-static ssize_t iio_ev_state_store(struct device *dev,
- struct device_attribute *attr,
- const char *buf,
- size_t len)
-{
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
- struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
- int ret;
- bool val;
-
- ret = strtobool(buf, &val);
- if (ret < 0)
- return ret;
-
- ret = indio_dev->info->write_event_config(indio_dev,
- this_attr->address,
- val);
- return (ret < 0) ? ret : len;
-}
-
-static ssize_t iio_ev_state_show(struct device *dev,
- struct device_attribute *attr,
- char *buf)
-{
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
- struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
- int val = indio_dev->info->read_event_config(indio_dev,
- this_attr->address);
-
- if (val < 0)
- return val;
- else
- return sprintf(buf, "%d\n", val);
-}
-
-static ssize_t iio_ev_value_show(struct device *dev,
- struct device_attribute *attr,
- char *buf)
-{
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
- struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
- int val, ret;
-
- ret = indio_dev->info->read_event_value(indio_dev,
- this_attr->address, &val);
- if (ret < 0)
- return ret;
-
- return sprintf(buf, "%d\n", val);
-}
-
-static ssize_t iio_ev_value_store(struct device *dev,
- struct device_attribute *attr,
- const char *buf,
- size_t len)
-{
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
- struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
- unsigned long val;
- int ret;
-
- if (!indio_dev->info->write_event_value)
- return -EINVAL;
-
- ret = strict_strtoul(buf, 10, &val);
- if (ret)
- return ret;
-
- ret = indio_dev->info->write_event_value(indio_dev, this_attr->address,
- val);
- if (ret < 0)
- return ret;
-
- return len;
-}
-
-static int iio_device_add_event_sysfs(struct iio_dev *indio_dev,
- struct iio_chan_spec const *chan)
-{
- int ret = 0, i, attrcount = 0;
- u64 mask = 0;
- char *postfix;
- if (!chan->event_mask)
- return 0;
-
- for_each_set_bit(i, &chan->event_mask, sizeof(chan->event_mask)*8) {
- postfix = kasprintf(GFP_KERNEL, "%s_%s_en",
- iio_ev_type_text[i/IIO_EV_DIR_MAX],
- iio_ev_dir_text[i%IIO_EV_DIR_MAX]);
- if (postfix == NULL) {
- ret = -ENOMEM;
- goto error_ret;
- }
- if (chan->modified)
- mask = IIO_MOD_EVENT_CODE(chan->type, 0, chan->channel,
- i/IIO_EV_DIR_MAX,
- i%IIO_EV_DIR_MAX);
- else if (chan->differential)
- mask = IIO_EVENT_CODE(chan->type,
- 0, 0,
- i%IIO_EV_DIR_MAX,
- i/IIO_EV_DIR_MAX,
- 0,
- chan->channel,
- chan->channel2);
- else
- mask = IIO_UNMOD_EVENT_CODE(chan->type,
- chan->channel,
- i/IIO_EV_DIR_MAX,
- i%IIO_EV_DIR_MAX);
-
- ret = __iio_add_chan_devattr(postfix,
- chan,
- &iio_ev_state_show,
- iio_ev_state_store,
- mask,
- 0,
- &indio_dev->dev,
- &indio_dev->event_interface->
- dev_attr_list);
- kfree(postfix);
- if (ret)
- goto error_ret;
- attrcount++;
- postfix = kasprintf(GFP_KERNEL, "%s_%s_value",
- iio_ev_type_text[i/IIO_EV_DIR_MAX],
- iio_ev_dir_text[i%IIO_EV_DIR_MAX]);
- if (postfix == NULL) {
- ret = -ENOMEM;
- goto error_ret;
- }
- ret = __iio_add_chan_devattr(postfix, chan,
- iio_ev_value_show,
- iio_ev_value_store,
- mask,
- 0,
- &indio_dev->dev,
- &indio_dev->event_interface->
- dev_attr_list);
- kfree(postfix);
- if (ret)
- goto error_ret;
- attrcount++;
- }
- ret = attrcount;
-error_ret:
- return ret;
-}
-
-static inline void __iio_remove_event_config_attrs(struct iio_dev *indio_dev)
-{
- struct iio_dev_attr *p, *n;
- list_for_each_entry_safe(p, n,
- &indio_dev->event_interface->
- dev_attr_list, l) {
- kfree(p->dev_attr.attr.name);
- kfree(p);
- }
-}
-
-static inline int __iio_add_event_config_attrs(struct iio_dev *indio_dev)
-{
- int j, ret, attrcount = 0;
-
- INIT_LIST_HEAD(&indio_dev->event_interface->dev_attr_list);
- /* Dynically created from the channels array */
- for (j = 0; j < indio_dev->num_channels; j++) {
- ret = iio_device_add_event_sysfs(indio_dev,
- &indio_dev->channels[j]);
- if (ret < 0)
- goto error_clear_attrs;
- attrcount += ret;
- }
- return attrcount;
-
-error_clear_attrs:
- __iio_remove_event_config_attrs(indio_dev);
-
- return ret;
-}
-
-static bool iio_check_for_dynamic_events(struct iio_dev *indio_dev)
-{
- int j;
-
- for (j = 0; j < indio_dev->num_channels; j++)
- if (indio_dev->channels[j].event_mask != 0)
- return true;
- return false;
-}
-
-static void iio_setup_ev_int(struct iio_event_interface *ev_int)
-{
- INIT_KFIFO(ev_int->det_events);
- init_waitqueue_head(&ev_int->wait);
-}
-
-static const char *iio_event_group_name = "events";
-int iio_device_register_eventset(struct iio_dev *indio_dev)
-{
- struct iio_dev_attr *p;
- int ret = 0, attrcount_orig = 0, attrcount, attrn;
- struct attribute **attr;
-
- if (!(indio_dev->info->event_attrs ||
- iio_check_for_dynamic_events(indio_dev)))
- return 0;
-
- indio_dev->event_interface =
- kzalloc(sizeof(struct iio_event_interface), GFP_KERNEL);
- if (indio_dev->event_interface == NULL) {
- ret = -ENOMEM;
- goto error_ret;
- }
-
- iio_setup_ev_int(indio_dev->event_interface);
- if (indio_dev->info->event_attrs != NULL) {
- attr = indio_dev->info->event_attrs->attrs;
- while (*attr++ != NULL)
- attrcount_orig++;
- }
- attrcount = attrcount_orig;
- if (indio_dev->channels) {
- ret = __iio_add_event_config_attrs(indio_dev);
- if (ret < 0)
- goto error_free_setup_event_lines;
- attrcount += ret;
- }
-
- indio_dev->event_interface->group.name = iio_event_group_name;
- indio_dev->event_interface->group.attrs = kcalloc(attrcount + 1,
- sizeof(indio_dev->event_interface->group.attrs[0]),
- GFP_KERNEL);
- if (indio_dev->event_interface->group.attrs == NULL) {
- ret = -ENOMEM;
- goto error_free_setup_event_lines;
- }
- if (indio_dev->info->event_attrs)
- memcpy(indio_dev->event_interface->group.attrs,
- indio_dev->info->event_attrs->attrs,
- sizeof(indio_dev->event_interface->group.attrs[0])
- *attrcount_orig);
- attrn = attrcount_orig;
- /* Add all elements from the list. */
- list_for_each_entry(p,
- &indio_dev->event_interface->dev_attr_list,
- l)
- indio_dev->event_interface->group.attrs[attrn++] =
- &p->dev_attr.attr;
- indio_dev->groups[indio_dev->groupcounter++] =
- &indio_dev->event_interface->group;
-
- return 0;
-
-error_free_setup_event_lines:
- __iio_remove_event_config_attrs(indio_dev);
- kfree(indio_dev->event_interface);
-error_ret:
-
- return ret;
-}
-
-void iio_device_unregister_eventset(struct iio_dev *indio_dev)
-{
- if (indio_dev->event_interface == NULL)
- return;
- __iio_remove_event_config_attrs(indio_dev);
- kfree(indio_dev->event_interface->group.attrs);
- kfree(indio_dev->event_interface);
-}
diff --git a/drivers/staging/iio/industrialio-trigger.c b/drivers/staging/iio/industrialio-trigger.c
deleted file mode 100644
index 47ecadd4818d..000000000000
--- a/drivers/staging/iio/industrialio-trigger.c
+++ /dev/null
@@ -1,509 +0,0 @@
-/* The industrial I/O core, trigger handling functions
- *
- * Copyright (c) 2008 Jonathan Cameron
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 as published by
- * the Free Software Foundation.
- */
-
-#include <linux/kernel.h>
-#include <linux/idr.h>
-#include <linux/err.h>
-#include <linux/device.h>
-#include <linux/interrupt.h>
-#include <linux/list.h>
-#include <linux/slab.h>
-
-#include "iio.h"
-#include "trigger.h"
-#include "iio_core.h"
-#include "iio_core_trigger.h"
-#include "trigger_consumer.h"
-
-/* RFC - Question of approach
- * Make the common case (single sensor single trigger)
- * simple by starting trigger capture from when first sensors
- * is added.
- *
- * Complex simultaneous start requires use of 'hold' functionality
- * of the trigger. (not implemented)
- *
- * Any other suggestions?
- */
-
-static DEFINE_IDA(iio_trigger_ida);
-
-/* Single list of all available triggers */
-static LIST_HEAD(iio_trigger_list);
-static DEFINE_MUTEX(iio_trigger_list_lock);
-
-/**
- * iio_trigger_read_name() - retrieve useful identifying name
- **/
-static ssize_t iio_trigger_read_name(struct device *dev,
- struct device_attribute *attr,
- char *buf)
-{
- struct iio_trigger *trig = dev_get_drvdata(dev);
- return sprintf(buf, "%s\n", trig->name);
-}
-
-static DEVICE_ATTR(name, S_IRUGO, iio_trigger_read_name, NULL);
-
-/**
- * iio_trigger_register_sysfs() - create a device for this trigger
- * @trig_info: the trigger
- *
- * Also adds any control attribute registered by the trigger driver
- **/
-static int iio_trigger_register_sysfs(struct iio_trigger *trig_info)
-{
- return sysfs_add_file_to_group(&trig_info->dev.kobj,
- &dev_attr_name.attr,
- NULL);
-}
-
-static void iio_trigger_unregister_sysfs(struct iio_trigger *trig_info)
-{
- sysfs_remove_file_from_group(&trig_info->dev.kobj,
- &dev_attr_name.attr,
- NULL);
-}
-
-int iio_trigger_register(struct iio_trigger *trig_info)
-{
- int ret;
-
- trig_info->id = ida_simple_get(&iio_trigger_ida, 0, 0, GFP_KERNEL);
- if (trig_info->id < 0) {
- ret = trig_info->id;
- goto error_ret;
- }
- /* Set the name used for the sysfs directory etc */
- dev_set_name(&trig_info->dev, "trigger%ld",
- (unsigned long) trig_info->id);
-
- ret = device_add(&trig_info->dev);
- if (ret)
- goto error_unregister_id;
-
- ret = iio_trigger_register_sysfs(trig_info);
- if (ret)
- goto error_device_del;
-
- /* Add to list of available triggers held by the IIO core */
- mutex_lock(&iio_trigger_list_lock);
- list_add_tail(&trig_info->list, &iio_trigger_list);
- mutex_unlock(&iio_trigger_list_lock);
-
- return 0;
-
-error_device_del:
- device_del(&trig_info->dev);
-error_unregister_id:
- ida_simple_remove(&iio_trigger_ida, trig_info->id);
-error_ret:
- return ret;
-}
-EXPORT_SYMBOL(iio_trigger_register);
-
-void iio_trigger_unregister(struct iio_trigger *trig_info)
-{
- mutex_lock(&iio_trigger_list_lock);
- list_del(&trig_info->list);
- mutex_unlock(&iio_trigger_list_lock);
-
- iio_trigger_unregister_sysfs(trig_info);
- ida_simple_remove(&iio_trigger_ida, trig_info->id);
- /* Possible issue in here */
- device_unregister(&trig_info->dev);
-}
-EXPORT_SYMBOL(iio_trigger_unregister);
-
-static struct iio_trigger *iio_trigger_find_by_name(const char *name,
- size_t len)
-{
- struct iio_trigger *trig = NULL, *iter;
-
- mutex_lock(&iio_trigger_list_lock);
- list_for_each_entry(iter, &iio_trigger_list, list)
- if (sysfs_streq(iter->name, name)) {
- trig = iter;
- break;
- }
- mutex_unlock(&iio_trigger_list_lock);
-
- return trig;
-}
-
-void iio_trigger_poll(struct iio_trigger *trig, s64 time)
-{
- int i;
- if (!trig->use_count)
- for (i = 0; i < CONFIG_IIO_CONSUMERS_PER_TRIGGER; i++)
- if (trig->subirqs[i].enabled) {
- trig->use_count++;
- generic_handle_irq(trig->subirq_base + i);
- }
-}
-EXPORT_SYMBOL(iio_trigger_poll);
-
-irqreturn_t iio_trigger_generic_data_rdy_poll(int irq, void *private)
-{
- iio_trigger_poll(private, iio_get_time_ns());
- return IRQ_HANDLED;
-}
-EXPORT_SYMBOL(iio_trigger_generic_data_rdy_poll);
-
-void iio_trigger_poll_chained(struct iio_trigger *trig, s64 time)
-{
- int i;
- if (!trig->use_count)
- for (i = 0; i < CONFIG_IIO_CONSUMERS_PER_TRIGGER; i++)
- if (trig->subirqs[i].enabled) {
- trig->use_count++;
- handle_nested_irq(trig->subirq_base + i);
- }
-}
-EXPORT_SYMBOL(iio_trigger_poll_chained);
-
-void iio_trigger_notify_done(struct iio_trigger *trig)
-{
- trig->use_count--;
- if (trig->use_count == 0 && trig->ops && trig->ops->try_reenable)
- if (trig->ops->try_reenable(trig))
- /* Missed and interrupt so launch new poll now */
- iio_trigger_poll(trig, 0);
-}
-EXPORT_SYMBOL(iio_trigger_notify_done);
-
-/* Trigger Consumer related functions */
-static int iio_trigger_get_irq(struct iio_trigger *trig)
-{
- int ret;
- mutex_lock(&trig->pool_lock);
- ret = bitmap_find_free_region(trig->pool,
- CONFIG_IIO_CONSUMERS_PER_TRIGGER,
- ilog2(1));
- mutex_unlock(&trig->pool_lock);
- if (ret >= 0)
- ret += trig->subirq_base;
-
- return ret;
-}
-
-static void iio_trigger_put_irq(struct iio_trigger *trig, int irq)
-{
- mutex_lock(&trig->pool_lock);
- clear_bit(irq - trig->subirq_base, trig->pool);
- mutex_unlock(&trig->pool_lock);
-}
-
-/* Complexity in here. With certain triggers (datardy) an acknowledgement
- * may be needed if the pollfuncs do not include the data read for the
- * triggering device.
- * This is not currently handled. Alternative of not enabling trigger unless
- * the relevant function is in there may be the best option.
- */
-/* Worth protecting against double additions?*/
-static int iio_trigger_attach_poll_func(struct iio_trigger *trig,
- struct iio_poll_func *pf)
-{
- int ret = 0;
- bool notinuse
- = bitmap_empty(trig->pool, CONFIG_IIO_CONSUMERS_PER_TRIGGER);
-
- /* Prevent the module being removed whilst attached to a trigger */
- __module_get(pf->indio_dev->info->driver_module);
- pf->irq = iio_trigger_get_irq(trig);
- ret = request_threaded_irq(pf->irq, pf->h, pf->thread,
- pf->type, pf->name,
- pf);
- if (ret < 0) {
- module_put(pf->indio_dev->info->driver_module);
- return ret;
- }
-
- if (trig->ops && trig->ops->set_trigger_state && notinuse) {
- ret = trig->ops->set_trigger_state(trig, true);
- if (ret < 0)
- module_put(pf->indio_dev->info->driver_module);
- }
-
- return ret;
-}
-
-static int iio_trigger_dettach_poll_func(struct iio_trigger *trig,
- struct iio_poll_func *pf)
-{
- int ret = 0;
- bool no_other_users
- = (bitmap_weight(trig->pool,
- CONFIG_IIO_CONSUMERS_PER_TRIGGER)
- == 1);
- if (trig->ops && trig->ops->set_trigger_state && no_other_users) {
- ret = trig->ops->set_trigger_state(trig, false);
- if (ret)
- goto error_ret;
- }
- iio_trigger_put_irq(trig, pf->irq);
- free_irq(pf->irq, pf);
- module_put(pf->indio_dev->info->driver_module);
-
-error_ret:
- return ret;
-}
-
-irqreturn_t iio_pollfunc_store_time(int irq, void *p)
-{
- struct iio_poll_func *pf = p;
- pf->timestamp = iio_get_time_ns();
- return IRQ_WAKE_THREAD;
-}
-EXPORT_SYMBOL(iio_pollfunc_store_time);
-
-struct iio_poll_func
-*iio_alloc_pollfunc(irqreturn_t (*h)(int irq, void *p),
- irqreturn_t (*thread)(int irq, void *p),
- int type,
- struct iio_dev *indio_dev,
- const char *fmt,
- ...)
-{
- va_list vargs;
- struct iio_poll_func *pf;
-
- pf = kmalloc(sizeof *pf, GFP_KERNEL);
- if (pf == NULL)
- return NULL;
- va_start(vargs, fmt);
- pf->name = kvasprintf(GFP_KERNEL, fmt, vargs);
- va_end(vargs);
- if (pf->name == NULL) {
- kfree(pf);
- return NULL;
- }
- pf->h = h;
- pf->thread = thread;
- pf->type = type;
- pf->indio_dev = indio_dev;
-
- return pf;
-}
-EXPORT_SYMBOL_GPL(iio_alloc_pollfunc);
-
-void iio_dealloc_pollfunc(struct iio_poll_func *pf)
-{
- kfree(pf->name);
- kfree(pf);
-}
-EXPORT_SYMBOL_GPL(iio_dealloc_pollfunc);
-
-/**
- * iio_trigger_read_current() - trigger consumer sysfs query which trigger
- *
- * For trigger consumers the current_trigger interface allows the trigger
- * used by the device to be queried.
- **/
-static ssize_t iio_trigger_read_current(struct device *dev,
- struct device_attribute *attr,
- char *buf)
-{
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
-
- if (indio_dev->trig)
- return sprintf(buf, "%s\n", indio_dev->trig->name);
- return 0;
-}
-
-/**
- * iio_trigger_write_current() trigger consumer sysfs set current trigger
- *
- * For trigger consumers the current_trigger interface allows the trigger
- * used for this device to be specified at run time based on the triggers
- * name.
- **/
-static ssize_t iio_trigger_write_current(struct device *dev,
- struct device_attribute *attr,
- const char *buf,
- size_t len)
-{
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
- struct iio_trigger *oldtrig = indio_dev->trig;
- struct iio_trigger *trig;
- int ret;
-
- mutex_lock(&indio_dev->mlock);
- if (indio_dev->currentmode == INDIO_BUFFER_TRIGGERED) {
- mutex_unlock(&indio_dev->mlock);
- return -EBUSY;
- }
- mutex_unlock(&indio_dev->mlock);
-
- trig = iio_trigger_find_by_name(buf, len);
- if (oldtrig == trig)
- return len;
-
- if (trig && indio_dev->info->validate_trigger) {
- ret = indio_dev->info->validate_trigger(indio_dev, trig);
- if (ret)
- return ret;
- }
-
- if (trig && trig->ops && trig->ops->validate_device) {
- ret = trig->ops->validate_device(trig, indio_dev);
- if (ret)
- return ret;
- }
-
- indio_dev->trig = trig;
-
- if (oldtrig && indio_dev->trig != oldtrig)
- iio_put_trigger(oldtrig);
- if (indio_dev->trig)
- iio_get_trigger(indio_dev->trig);
-
- return len;
-}
-
-static DEVICE_ATTR(current_trigger, S_IRUGO | S_IWUSR,
- iio_trigger_read_current,
- iio_trigger_write_current);
-
-static struct attribute *iio_trigger_consumer_attrs[] = {
- &dev_attr_current_trigger.attr,
- NULL,
-};
-
-static const struct attribute_group iio_trigger_consumer_attr_group = {
- .name = "trigger",
- .attrs = iio_trigger_consumer_attrs,
-};
-
-static void iio_trig_release(struct device *device)
-{
- struct iio_trigger *trig = to_iio_trigger(device);
- int i;
-
- if (trig->subirq_base) {
- for (i = 0; i < CONFIG_IIO_CONSUMERS_PER_TRIGGER; i++) {
- irq_modify_status(trig->subirq_base + i,
- IRQ_NOAUTOEN,
- IRQ_NOREQUEST | IRQ_NOPROBE);
- irq_set_chip(trig->subirq_base + i,
- NULL);
- irq_set_handler(trig->subirq_base + i,
- NULL);
- }
-
- irq_free_descs(trig->subirq_base,
- CONFIG_IIO_CONSUMERS_PER_TRIGGER);
- }
- kfree(trig->name);
- kfree(trig);
-}
-
-static struct device_type iio_trig_type = {
- .release = iio_trig_release,
-};
-
-static void iio_trig_subirqmask(struct irq_data *d)
-{
- struct irq_chip *chip = irq_data_get_irq_chip(d);
- struct iio_trigger *trig
- = container_of(chip,
- struct iio_trigger, subirq_chip);
- trig->subirqs[d->irq - trig->subirq_base].enabled = false;
-}
-
-static void iio_trig_subirqunmask(struct irq_data *d)
-{
- struct irq_chip *chip = irq_data_get_irq_chip(d);
- struct iio_trigger *trig
- = container_of(chip,
- struct iio_trigger, subirq_chip);
- trig->subirqs[d->irq - trig->subirq_base].enabled = true;
-}
-
-struct iio_trigger *iio_allocate_trigger(const char *fmt, ...)
-{
- va_list vargs;
- struct iio_trigger *trig;
- trig = kzalloc(sizeof *trig, GFP_KERNEL);
- if (trig) {
- int i;
- trig->dev.type = &iio_trig_type;
- trig->dev.bus = &iio_bus_type;
- device_initialize(&trig->dev);
- dev_set_drvdata(&trig->dev, (void *)trig);
-
- mutex_init(&trig->pool_lock);
- trig->subirq_base
- = irq_alloc_descs(-1, 0,
- CONFIG_IIO_CONSUMERS_PER_TRIGGER,
- 0);
- if (trig->subirq_base < 0) {
- kfree(trig);
- return NULL;
- }
- va_start(vargs, fmt);
- trig->name = kvasprintf(GFP_KERNEL, fmt, vargs);
- va_end(vargs);
- if (trig->name == NULL) {
- irq_free_descs(trig->subirq_base,
- CONFIG_IIO_CONSUMERS_PER_TRIGGER);
- kfree(trig);
- return NULL;
- }
- trig->subirq_chip.name = trig->name;
- trig->subirq_chip.irq_mask = &iio_trig_subirqmask;
- trig->subirq_chip.irq_unmask = &iio_trig_subirqunmask;
- for (i = 0; i < CONFIG_IIO_CONSUMERS_PER_TRIGGER; i++) {
- irq_set_chip(trig->subirq_base + i,
- &trig->subirq_chip);
- irq_set_handler(trig->subirq_base + i,
- &handle_simple_irq);
- irq_modify_status(trig->subirq_base + i,
- IRQ_NOREQUEST | IRQ_NOAUTOEN,
- IRQ_NOPROBE);
- }
- get_device(&trig->dev);
- }
- return trig;
-}
-EXPORT_SYMBOL(iio_allocate_trigger);
-
-void iio_free_trigger(struct iio_trigger *trig)
-{
- if (trig)
- put_device(&trig->dev);
-}
-EXPORT_SYMBOL(iio_free_trigger);
-
-void iio_device_register_trigger_consumer(struct iio_dev *indio_dev)
-{
- indio_dev->groups[indio_dev->groupcounter++] =
- &iio_trigger_consumer_attr_group;
-}
-
-void iio_device_unregister_trigger_consumer(struct iio_dev *indio_dev)
-{
- /* Clean up and associated but not attached triggers references */
- if (indio_dev->trig)
- iio_put_trigger(indio_dev->trig);
-}
-
-int iio_triggered_buffer_postenable(struct iio_dev *indio_dev)
-{
- return iio_trigger_attach_poll_func(indio_dev->trig,
- indio_dev->pollfunc);
-}
-EXPORT_SYMBOL(iio_triggered_buffer_postenable);
-
-int iio_triggered_buffer_predisable(struct iio_dev *indio_dev)
-{
- return iio_trigger_dettach_poll_func(indio_dev->trig,
- indio_dev->pollfunc);
-}
-EXPORT_SYMBOL(iio_triggered_buffer_predisable);
diff --git a/drivers/staging/iio/inkern.c b/drivers/staging/iio/inkern.c
deleted file mode 100644
index ef07a02bf542..000000000000
--- a/drivers/staging/iio/inkern.c
+++ /dev/null
@@ -1,293 +0,0 @@
-/* The industrial I/O core in kernel channel mapping
- *
- * Copyright (c) 2011 Jonathan Cameron
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 as published by
- * the Free Software Foundation.
- */
-#include <linux/err.h>
-#include <linux/export.h>
-#include <linux/slab.h>
-#include <linux/mutex.h>
-
-#include "iio.h"
-#include "iio_core.h"
-#include "machine.h"
-#include "driver.h"
-#include "consumer.h"
-
-struct iio_map_internal {
- struct iio_dev *indio_dev;
- struct iio_map *map;
- struct list_head l;
-};
-
-static LIST_HEAD(iio_map_list);
-static DEFINE_MUTEX(iio_map_list_lock);
-
-int iio_map_array_register(struct iio_dev *indio_dev, struct iio_map *maps)
-{
- int i = 0, ret = 0;
- struct iio_map_internal *mapi;
-
- if (maps == NULL)
- return 0;
-
- mutex_lock(&iio_map_list_lock);
- while (maps[i].consumer_dev_name != NULL) {
- mapi = kzalloc(sizeof(*mapi), GFP_KERNEL);
- if (mapi == NULL) {
- ret = -ENOMEM;
- goto error_ret;
- }
- mapi->map = &maps[i];
- mapi->indio_dev = indio_dev;
- list_add(&mapi->l, &iio_map_list);
- i++;
- }
-error_ret:
- mutex_unlock(&iio_map_list_lock);
-
- return ret;
-}
-EXPORT_SYMBOL_GPL(iio_map_array_register);
-
-
-/* Assumes the exact same array (e.g. memory locations)
- * used at unregistration as used at registration rather than
- * more complex checking of contents.
- */
-int iio_map_array_unregister(struct iio_dev *indio_dev,
- struct iio_map *maps)
-{
- int i = 0, ret = 0;
- bool found_it;
- struct iio_map_internal *mapi;
-
- if (maps == NULL)
- return 0;
-
- mutex_lock(&iio_map_list_lock);
- while (maps[i].consumer_dev_name != NULL) {
- found_it = false;
- list_for_each_entry(mapi, &iio_map_list, l)
- if (&maps[i] == mapi->map) {
- list_del(&mapi->l);
- kfree(mapi);
- found_it = true;
- break;
- }
- if (found_it == false) {
- ret = -ENODEV;
- goto error_ret;
- }
- i++;
- }
-error_ret:
- mutex_unlock(&iio_map_list_lock);
-
- return ret;
-}
-EXPORT_SYMBOL_GPL(iio_map_array_unregister);
-
-static const struct iio_chan_spec
-*iio_chan_spec_from_name(const struct iio_dev *indio_dev,
- const char *name)
-{
- int i;
- const struct iio_chan_spec *chan = NULL;
-
- for (i = 0; i < indio_dev->num_channels; i++)
- if (indio_dev->channels[i].datasheet_name &&
- strcmp(name, indio_dev->channels[i].datasheet_name) == 0) {
- chan = &indio_dev->channels[i];
- break;
- }
- return chan;
-}
-
-
-struct iio_channel *iio_st_channel_get(const char *name,
- const char *channel_name)
-{
- struct iio_map_internal *c_i = NULL, *c = NULL;
- struct iio_channel *channel;
-
- if (name == NULL && channel_name == NULL)
- return ERR_PTR(-ENODEV);
-
- /* first find matching entry the channel map */
- mutex_lock(&iio_map_list_lock);
- list_for_each_entry(c_i, &iio_map_list, l) {
- if ((name && strcmp(name, c_i->map->consumer_dev_name) != 0) ||
- (channel_name &&
- strcmp(channel_name, c_i->map->consumer_channel) != 0))
- continue;
- c = c_i;
- get_device(&c->indio_dev->dev);
- break;
- }
- mutex_unlock(&iio_map_list_lock);
- if (c == NULL)
- return ERR_PTR(-ENODEV);
-
- channel = kmalloc(sizeof(*channel), GFP_KERNEL);
- if (channel == NULL)
- return ERR_PTR(-ENOMEM);
-
- channel->indio_dev = c->indio_dev;
-
- if (c->map->adc_channel_label)
- channel->channel =
- iio_chan_spec_from_name(channel->indio_dev,
- c->map->adc_channel_label);
-
- return channel;
-}
-EXPORT_SYMBOL_GPL(iio_st_channel_get);
-
-void iio_st_channel_release(struct iio_channel *channel)
-{
- put_device(&channel->indio_dev->dev);
- kfree(channel);
-}
-EXPORT_SYMBOL_GPL(iio_st_channel_release);
-
-struct iio_channel *iio_st_channel_get_all(const char *name)
-{
- struct iio_channel *chans;
- struct iio_map_internal *c = NULL;
- int nummaps = 0;
- int mapind = 0;
- int i, ret;
-
- if (name == NULL)
- return ERR_PTR(-EINVAL);
-
- mutex_lock(&iio_map_list_lock);
- /* first count the matching maps */
- list_for_each_entry(c, &iio_map_list, l)
- if (name && strcmp(name, c->map->consumer_dev_name) != 0)
- continue;
- else
- nummaps++;
-
- if (nummaps == 0) {
- ret = -ENODEV;
- goto error_ret;
- }
-
- /* NULL terminated array to save passing size */
- chans = kzalloc(sizeof(*chans)*(nummaps + 1), GFP_KERNEL);
- if (chans == NULL) {
- ret = -ENOMEM;
- goto error_ret;
- }
-
- /* for each map fill in the chans element */
- list_for_each_entry(c, &iio_map_list, l) {
- if (name && strcmp(name, c->map->consumer_dev_name) != 0)
- continue;
- chans[mapind].indio_dev = c->indio_dev;
- chans[mapind].channel =
- iio_chan_spec_from_name(chans[mapind].indio_dev,
- c->map->adc_channel_label);
- if (chans[mapind].channel == NULL) {
- ret = -EINVAL;
- put_device(&chans[mapind].indio_dev->dev);
- goto error_free_chans;
- }
- get_device(&chans[mapind].indio_dev->dev);
- mapind++;
- }
- mutex_unlock(&iio_map_list_lock);
- if (mapind == 0) {
- ret = -ENODEV;
- goto error_free_chans;
- }
- return chans;
-
-error_free_chans:
- for (i = 0; i < nummaps; i++)
- if (chans[i].indio_dev)
- put_device(&chans[i].indio_dev->dev);
- kfree(chans);
-error_ret:
- mutex_unlock(&iio_map_list_lock);
-
- return ERR_PTR(ret);
-}
-EXPORT_SYMBOL_GPL(iio_st_channel_get_all);
-
-void iio_st_channel_release_all(struct iio_channel *channels)
-{
- struct iio_channel *chan = &channels[0];
-
- while (chan->indio_dev) {
- put_device(&chan->indio_dev->dev);
- chan++;
- }
- kfree(channels);
-}
-EXPORT_SYMBOL_GPL(iio_st_channel_release_all);
-
-int iio_st_read_channel_raw(struct iio_channel *chan, int *val)
-{
- int val2, ret;
-
- mutex_lock(&chan->indio_dev->info_exist_lock);
- if (chan->indio_dev->info == NULL) {
- ret = -ENODEV;
- goto err_unlock;
- }
-
- ret = chan->indio_dev->info->read_raw(chan->indio_dev, chan->channel,
- val, &val2, 0);
-err_unlock:
- mutex_unlock(&chan->indio_dev->info_exist_lock);
-
- return ret;
-}
-EXPORT_SYMBOL_GPL(iio_st_read_channel_raw);
-
-int iio_st_read_channel_scale(struct iio_channel *chan, int *val, int *val2)
-{
- int ret;
-
- mutex_lock(&chan->indio_dev->info_exist_lock);
- if (chan->indio_dev->info == NULL) {
- ret = -ENODEV;
- goto err_unlock;
- }
-
- ret = chan->indio_dev->info->read_raw(chan->indio_dev,
- chan->channel,
- val, val2,
- IIO_CHAN_INFO_SCALE);
-err_unlock:
- mutex_unlock(&chan->indio_dev->info_exist_lock);
-
- return ret;
-}
-EXPORT_SYMBOL_GPL(iio_st_read_channel_scale);
-
-int iio_st_get_channel_type(struct iio_channel *chan,
- enum iio_chan_type *type)
-{
- int ret = 0;
- /* Need to verify underlying driver has not gone away */
-
- mutex_lock(&chan->indio_dev->info_exist_lock);
- if (chan->indio_dev->info == NULL) {
- ret = -ENODEV;
- goto err_unlock;
- }
-
- *type = chan->channel->type;
-err_unlock:
- mutex_unlock(&chan->indio_dev->info_exist_lock);
-
- return ret;
-}
-EXPORT_SYMBOL_GPL(iio_st_get_channel_type);
diff --git a/drivers/staging/iio/kfifo_buf.c b/drivers/staging/iio/kfifo_buf.c
deleted file mode 100644
index 9f3bd59c0e72..000000000000
--- a/drivers/staging/iio/kfifo_buf.c
+++ /dev/null
@@ -1,151 +0,0 @@
-#include <linux/slab.h>
-#include <linux/kernel.h>
-#include <linux/module.h>
-#include <linux/device.h>
-#include <linux/workqueue.h>
-#include <linux/kfifo.h>
-#include <linux/mutex.h>
-
-#include "kfifo_buf.h"
-
-struct iio_kfifo {
- struct iio_buffer buffer;
- struct kfifo kf;
- int update_needed;
-};
-
-#define iio_to_kfifo(r) container_of(r, struct iio_kfifo, buffer)
-
-static inline int __iio_allocate_kfifo(struct iio_kfifo *buf,
- int bytes_per_datum, int length)
-{
- if ((length == 0) || (bytes_per_datum == 0))
- return -EINVAL;
-
- __iio_update_buffer(&buf->buffer, bytes_per_datum, length);
- return kfifo_alloc(&buf->kf, bytes_per_datum*length, GFP_KERNEL);
-}
-
-static int iio_request_update_kfifo(struct iio_buffer *r)
-{
- int ret = 0;
- struct iio_kfifo *buf = iio_to_kfifo(r);
-
- if (!buf->update_needed)
- goto error_ret;
- kfifo_free(&buf->kf);
- ret = __iio_allocate_kfifo(buf, buf->buffer.bytes_per_datum,
- buf->buffer.length);
-error_ret:
- return ret;
-}
-
-static int iio_get_length_kfifo(struct iio_buffer *r)
-{
- return r->length;
-}
-
-static IIO_BUFFER_ENABLE_ATTR;
-static IIO_BUFFER_LENGTH_ATTR;
-
-static struct attribute *iio_kfifo_attributes[] = {
- &dev_attr_length.attr,
- &dev_attr_enable.attr,
- NULL,
-};
-
-static struct attribute_group iio_kfifo_attribute_group = {
- .attrs = iio_kfifo_attributes,
- .name = "buffer",
-};
-
-static int iio_get_bytes_per_datum_kfifo(struct iio_buffer *r)
-{
- return r->bytes_per_datum;
-}
-
-static int iio_mark_update_needed_kfifo(struct iio_buffer *r)
-{
- struct iio_kfifo *kf = iio_to_kfifo(r);
- kf->update_needed = true;
- return 0;
-}
-
-static int iio_set_bytes_per_datum_kfifo(struct iio_buffer *r, size_t bpd)
-{
- if (r->bytes_per_datum != bpd) {
- r->bytes_per_datum = bpd;
- iio_mark_update_needed_kfifo(r);
- }
- return 0;
-}
-
-static int iio_set_length_kfifo(struct iio_buffer *r, int length)
-{
- if (r->length != length) {
- r->length = length;
- iio_mark_update_needed_kfifo(r);
- }
- return 0;
-}
-
-static int iio_store_to_kfifo(struct iio_buffer *r,
- u8 *data,
- s64 timestamp)
-{
- int ret;
- struct iio_kfifo *kf = iio_to_kfifo(r);
- ret = kfifo_in(&kf->kf, data, r->bytes_per_datum);
- if (ret != r->bytes_per_datum)
- return -EBUSY;
- return 0;
-}
-
-static int iio_read_first_n_kfifo(struct iio_buffer *r,
- size_t n, char __user *buf)
-{
- int ret, copied;
- struct iio_kfifo *kf = iio_to_kfifo(r);
-
- if (n < r->bytes_per_datum)
- return -EINVAL;
-
- n = rounddown(n, r->bytes_per_datum);
- ret = kfifo_to_user(&kf->kf, buf, n, &copied);
-
- return copied;
-}
-
-static const struct iio_buffer_access_funcs kfifo_access_funcs = {
- .store_to = &iio_store_to_kfifo,
- .read_first_n = &iio_read_first_n_kfifo,
- .request_update = &iio_request_update_kfifo,
- .get_bytes_per_datum = &iio_get_bytes_per_datum_kfifo,
- .set_bytes_per_datum = &iio_set_bytes_per_datum_kfifo,
- .get_length = &iio_get_length_kfifo,
- .set_length = &iio_set_length_kfifo,
-};
-
-struct iio_buffer *iio_kfifo_allocate(struct iio_dev *indio_dev)
-{
- struct iio_kfifo *kf;
-
- kf = kzalloc(sizeof *kf, GFP_KERNEL);
- if (!kf)
- return NULL;
- kf->update_needed = true;
- iio_buffer_init(&kf->buffer);
- kf->buffer.attrs = &iio_kfifo_attribute_group;
- kf->buffer.access = &kfifo_access_funcs;
-
- return &kf->buffer;
-}
-EXPORT_SYMBOL(iio_kfifo_allocate);
-
-void iio_kfifo_free(struct iio_buffer *r)
-{
- kfree(iio_to_kfifo(r));
-}
-EXPORT_SYMBOL(iio_kfifo_free);
-
-MODULE_LICENSE("GPL");
diff --git a/drivers/staging/iio/kfifo_buf.h b/drivers/staging/iio/kfifo_buf.h
deleted file mode 100644
index 9f7da016af04..000000000000
--- a/drivers/staging/iio/kfifo_buf.h
+++ /dev/null
@@ -1,8 +0,0 @@
-
-#include <linux/kfifo.h>
-#include "iio.h"
-#include "buffer.h"
-
-struct iio_buffer *iio_kfifo_allocate(struct iio_dev *indio_dev);
-void iio_kfifo_free(struct iio_buffer *r);
-
diff --git a/drivers/staging/iio/light/Kconfig b/drivers/staging/iio/light/Kconfig
index e7e9159d9895..4bed30eac3ed 100644
--- a/drivers/staging/iio/light/Kconfig
+++ b/drivers/staging/iio/light/Kconfig
@@ -4,15 +4,26 @@
menu "Light sensors"
config SENSORS_ISL29018
- tristate "ISL 29018 light and proximity sensor"
- depends on I2C
- default n
- help
- If you say yes here you get support for ambient light sensing and
- proximity infrared sensing from Intersil ISL29018.
- This driver will provide the measurements of ambient light intensity
- in lux, proximity infrared sensing and normal infrared sensing.
- Data from sensor is accessible via sysfs.
+ tristate "ISL 29018 light and proximity sensor"
+ depends on I2C
+ select REGMAP_I2C
+ default n
+ help
+ If you say yes here you get support for ambient light sensing and
+ proximity infrared sensing from Intersil ISL29018.
+ This driver will provide the measurements of ambient light intensity
+ in lux, proximity infrared sensing and normal infrared sensing.
+ Data from sensor is accessible via sysfs.
+
+config SENSORS_ISL29028
+ tristate "Intersil ISL29028 Concurrent Light and Proximity Sensor"
+ depends on I2C
+ select REGMAP_I2C
+ help
+ Provides driver for the Intersil's ISL29028 device.
+ This driver supports the sysfs interface to get the ALS, IR intensity,
+ Proximity value via iio. The ISL29028 provides the concurrent sensing
+ of ambient light and proximity.
config SENSORS_TSL2563
tristate "TAOS TSL2560, TSL2561, TSL2562 and TSL2563 ambient light sensors"
@@ -31,4 +42,12 @@ config TSL2583
Provides support for the TAOS tsl2580, tsl2581 and tsl2583 devices.
Access ALS data via iio, sysfs.
+config TSL2x7x
+ tristate "TAOS TSL/TMD2x71 and TSL/TMD2x72 Family of light and proximity sensors"
+ depends on I2C
+ help
+ Support for: tsl2571, tsl2671, tmd2671, tsl2771, tmd2771, tsl2572, tsl2672,
+ tmd2672, tsl2772, tmd2772 devices.
+ Provides iio_events and direct access via sysfs.
+
endmenu
diff --git a/drivers/staging/iio/light/Makefile b/drivers/staging/iio/light/Makefile
index 3011fbfa8dc2..141af1eb164c 100644
--- a/drivers/staging/iio/light/Makefile
+++ b/drivers/staging/iio/light/Makefile
@@ -4,4 +4,6 @@
obj-$(CONFIG_SENSORS_TSL2563) += tsl2563.o
obj-$(CONFIG_SENSORS_ISL29018) += isl29018.o
+obj-$(CONFIG_SENSORS_ISL29028) += isl29028.o
obj-$(CONFIG_TSL2583) += tsl2583.o
+obj-$(CONFIG_TSL2x7x) += tsl2x7x_core.o
diff --git a/drivers/staging/iio/light/isl29018.c b/drivers/staging/iio/light/isl29018.c
index 38ec52b65dfa..31d22f5591ca 100644
--- a/drivers/staging/iio/light/isl29018.c
+++ b/drivers/staging/iio/light/isl29018.c
@@ -26,9 +26,11 @@
#include <linux/err.h>
#include <linux/mutex.h>
#include <linux/delay.h>
+#include <linux/regmap.h>
#include <linux/slab.h>
-#include "../iio.h"
-#include "../sysfs.h"
+#include <linux/iio/iio.h>
+#include <linux/iio/sysfs.h>
+
#define CONVERSION_TIME_MS 100
#define ISL29018_REG_ADD_COMMAND1 0x00
@@ -51,49 +53,22 @@
#define ISL29018_REG_ADD_DATA_LSB 0x02
#define ISL29018_REG_ADD_DATA_MSB 0x03
-#define ISL29018_MAX_REGS (ISL29018_REG_ADD_DATA_MSB+1)
#define ISL29018_REG_TEST 0x08
#define ISL29018_TEST_SHIFT 0
#define ISL29018_TEST_MASK (0xFF << ISL29018_TEST_SHIFT)
struct isl29018_chip {
- struct i2c_client *client;
+ struct device *dev;
+ struct regmap *regmap;
struct mutex lock;
unsigned int lux_scale;
unsigned int range;
unsigned int adc_bit;
int prox_scheme;
- u8 reg_cache[ISL29018_MAX_REGS];
};
-static int isl29018_write_data(struct i2c_client *client, u8 reg,
- u8 val, u8 mask, u8 shift)
-{
- u8 regval = val;
- int ret;
- struct isl29018_chip *chip = iio_priv(i2c_get_clientdata(client));
-
- /* don't cache or mask REG_TEST */
- if (reg < ISL29018_MAX_REGS) {
- regval = chip->reg_cache[reg];
- regval &= ~mask;
- regval |= val << shift;
- }
-
- ret = i2c_smbus_write_byte_data(client, reg, regval);
- if (ret) {
- dev_err(&client->dev, "Write to device fails status %x\n", ret);
- } else {
- /* don't update cache on err */
- if (reg < ISL29018_MAX_REGS)
- chip->reg_cache[reg] = regval;
- }
-
- return ret;
-}
-
-static int isl29018_set_range(struct i2c_client *client, unsigned long range,
+static int isl29018_set_range(struct isl29018_chip *chip, unsigned long range,
unsigned int *new_range)
{
static const unsigned long supp_ranges[] = {1000, 4000, 16000, 64000};
@@ -109,11 +84,11 @@ static int isl29018_set_range(struct i2c_client *client, unsigned long range,
if (i >= ARRAY_SIZE(supp_ranges))
return -EINVAL;
- return isl29018_write_data(client, ISL29018_REG_ADD_COMMANDII,
- i, COMMANDII_RANGE_MASK, COMMANDII_RANGE_SHIFT);
+ return regmap_update_bits(chip->regmap, ISL29018_REG_ADD_COMMANDII,
+ COMMANDII_RANGE_MASK, i << COMMANDII_RANGE_SHIFT);
}
-static int isl29018_set_resolution(struct i2c_client *client,
+static int isl29018_set_resolution(struct isl29018_chip *chip,
unsigned long adcbit, unsigned int *conf_adc_bit)
{
static const unsigned long supp_adcbit[] = {16, 12, 8, 4};
@@ -129,48 +104,49 @@ static int isl29018_set_resolution(struct i2c_client *client,
if (i >= ARRAY_SIZE(supp_adcbit))
return -EINVAL;
- return isl29018_write_data(client, ISL29018_REG_ADD_COMMANDII,
- i, COMMANDII_RESOLUTION_MASK,
- COMMANDII_RESOLUTION_SHIFT);
+ return regmap_update_bits(chip->regmap, ISL29018_REG_ADD_COMMANDII,
+ COMMANDII_RESOLUTION_MASK,
+ i << COMMANDII_RESOLUTION_SHIFT);
}
-static int isl29018_read_sensor_input(struct i2c_client *client, int mode)
+static int isl29018_read_sensor_input(struct isl29018_chip *chip, int mode)
{
int status;
- int lsb;
- int msb;
+ unsigned int lsb;
+ unsigned int msb;
/* Set mode */
- status = isl29018_write_data(client, ISL29018_REG_ADD_COMMAND1,
- mode, COMMMAND1_OPMODE_MASK, COMMMAND1_OPMODE_SHIFT);
+ status = regmap_write(chip->regmap, ISL29018_REG_ADD_COMMAND1,
+ mode << COMMMAND1_OPMODE_SHIFT);
if (status) {
- dev_err(&client->dev, "Error in setting operating mode\n");
+ dev_err(chip->dev,
+ "Error in setting operating mode err %d\n", status);
return status;
}
msleep(CONVERSION_TIME_MS);
- lsb = i2c_smbus_read_byte_data(client, ISL29018_REG_ADD_DATA_LSB);
- if (lsb < 0) {
- dev_err(&client->dev, "Error in reading LSB DATA\n");
- return lsb;
+ status = regmap_read(chip->regmap, ISL29018_REG_ADD_DATA_LSB, &lsb);
+ if (status < 0) {
+ dev_err(chip->dev,
+ "Error in reading LSB DATA with err %d\n", status);
+ return status;
}
- msb = i2c_smbus_read_byte_data(client, ISL29018_REG_ADD_DATA_MSB);
- if (msb < 0) {
- dev_err(&client->dev, "Error in reading MSB DATA\n");
- return msb;
+ status = regmap_read(chip->regmap, ISL29018_REG_ADD_DATA_MSB, &msb);
+ if (status < 0) {
+ dev_err(chip->dev,
+ "Error in reading MSB DATA with error %d\n", status);
+ return status;
}
- dev_vdbg(&client->dev, "MSB 0x%x and LSB 0x%x\n", msb, lsb);
+ dev_vdbg(chip->dev, "MSB 0x%x and LSB 0x%x\n", msb, lsb);
return (msb << 8) | lsb;
}
-static int isl29018_read_lux(struct i2c_client *client, int *lux)
+static int isl29018_read_lux(struct isl29018_chip *chip, int *lux)
{
int lux_data;
- struct isl29018_chip *chip = iio_priv(i2c_get_clientdata(client));
- lux_data = isl29018_read_sensor_input(client,
- COMMMAND1_OPMODE_ALS_ONCE);
+ lux_data = isl29018_read_sensor_input(chip, COMMMAND1_OPMODE_ALS_ONCE);
if (lux_data < 0)
return lux_data;
@@ -180,11 +156,11 @@ static int isl29018_read_lux(struct i2c_client *client, int *lux)
return 0;
}
-static int isl29018_read_ir(struct i2c_client *client, int *ir)
+static int isl29018_read_ir(struct isl29018_chip *chip, int *ir)
{
int ir_data;
- ir_data = isl29018_read_sensor_input(client, COMMMAND1_OPMODE_IR_ONCE);
+ ir_data = isl29018_read_sensor_input(chip, COMMMAND1_OPMODE_IR_ONCE);
if (ir_data < 0)
return ir_data;
@@ -194,7 +170,7 @@ static int isl29018_read_ir(struct i2c_client *client, int *ir)
return 0;
}
-static int isl29018_read_proximity_ir(struct i2c_client *client, int scheme,
+static int isl29018_read_proximity_ir(struct isl29018_chip *chip, int scheme,
int *near_ir)
{
int status;
@@ -202,14 +178,15 @@ static int isl29018_read_proximity_ir(struct i2c_client *client, int scheme,
int ir_data = -1;
/* Do proximity sensing with required scheme */
- status = isl29018_write_data(client, ISL29018_REG_ADD_COMMANDII,
- scheme, COMMANDII_SCHEME_MASK, COMMANDII_SCHEME_SHIFT);
+ status = regmap_update_bits(chip->regmap, ISL29018_REG_ADD_COMMANDII,
+ COMMANDII_SCHEME_MASK,
+ scheme << COMMANDII_SCHEME_SHIFT);
if (status) {
- dev_err(&client->dev, "Error in setting operating mode\n");
+ dev_err(chip->dev, "Error in setting operating mode\n");
return status;
}
- prox_data = isl29018_read_sensor_input(client,
+ prox_data = isl29018_read_sensor_input(chip,
COMMMAND1_OPMODE_PROX_ONCE);
if (prox_data < 0)
return prox_data;
@@ -219,8 +196,7 @@ static int isl29018_read_proximity_ir(struct i2c_client *client, int scheme,
return 0;
}
- ir_data = isl29018_read_sensor_input(client,
- COMMMAND1_OPMODE_IR_ONCE);
+ ir_data = isl29018_read_sensor_input(chip, COMMMAND1_OPMODE_IR_ONCE);
if (ir_data < 0)
return ir_data;
@@ -238,7 +214,7 @@ static int isl29018_read_proximity_ir(struct i2c_client *client, int scheme,
static ssize_t show_range(struct device *dev,
struct device_attribute *attr, char *buf)
{
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct isl29018_chip *chip = iio_priv(indio_dev);
return sprintf(buf, "%u\n", chip->range);
@@ -247,9 +223,8 @@ static ssize_t show_range(struct device *dev,
static ssize_t store_range(struct device *dev,
struct device_attribute *attr, const char *buf, size_t count)
{
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct isl29018_chip *chip = iio_priv(indio_dev);
- struct i2c_client *client = chip->client;
int status;
unsigned long lval;
unsigned int new_range;
@@ -264,10 +239,11 @@ static ssize_t store_range(struct device *dev,
}
mutex_lock(&chip->lock);
- status = isl29018_set_range(client, lval, &new_range);
+ status = isl29018_set_range(chip, lval, &new_range);
if (status < 0) {
mutex_unlock(&chip->lock);
- dev_err(dev, "Error in setting max range\n");
+ dev_err(dev,
+ "Error in setting max range with err %d\n", status);
return status;
}
chip->range = new_range;
@@ -280,7 +256,7 @@ static ssize_t store_range(struct device *dev,
static ssize_t show_resolution(struct device *dev,
struct device_attribute *attr, char *buf)
{
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct isl29018_chip *chip = iio_priv(indio_dev);
return sprintf(buf, "%u\n", chip->adc_bit);
@@ -289,9 +265,8 @@ static ssize_t show_resolution(struct device *dev,
static ssize_t store_resolution(struct device *dev,
struct device_attribute *attr, const char *buf, size_t count)
{
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct isl29018_chip *chip = iio_priv(indio_dev);
- struct i2c_client *client = chip->client;
int status;
unsigned long lval;
unsigned int new_adc_bit;
@@ -304,7 +279,7 @@ static ssize_t store_resolution(struct device *dev,
}
mutex_lock(&chip->lock);
- status = isl29018_set_resolution(client, lval, &new_adc_bit);
+ status = isl29018_set_resolution(chip, lval, &new_adc_bit);
if (status < 0) {
mutex_unlock(&chip->lock);
dev_err(dev, "Error in setting resolution\n");
@@ -317,21 +292,21 @@ static ssize_t store_resolution(struct device *dev,
}
/* proximity scheme */
-static ssize_t show_prox_infrared_supression(struct device *dev,
+static ssize_t show_prox_infrared_suppression(struct device *dev,
struct device_attribute *attr, char *buf)
{
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct isl29018_chip *chip = iio_priv(indio_dev);
/* return the "proximity scheme" i.e. if the chip does on chip
- infrared supression (1 means perform on chip supression) */
+ infrared suppression (1 means perform on chip suppression) */
return sprintf(buf, "%d\n", chip->prox_scheme);
}
-static ssize_t store_prox_infrared_supression(struct device *dev,
+static ssize_t store_prox_infrared_suppression(struct device *dev,
struct device_attribute *attr, const char *buf, size_t count)
{
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct isl29018_chip *chip = iio_priv(indio_dev);
unsigned long lval;
@@ -343,7 +318,7 @@ static ssize_t store_prox_infrared_supression(struct device *dev,
}
/* get the "proximity scheme" i.e. if the chip does on chip
- infrared supression (1 means perform on chip supression) */
+ infrared suppression (1 means perform on chip suppression) */
mutex_lock(&chip->lock);
chip->prox_scheme = (int)lval;
mutex_unlock(&chip->lock);
@@ -379,20 +354,20 @@ static int isl29018_read_raw(struct iio_dev *indio_dev,
{
int ret = -EINVAL;
struct isl29018_chip *chip = iio_priv(indio_dev);
- struct i2c_client *client = chip->client;
mutex_lock(&chip->lock);
switch (mask) {
- case 0:
+ case IIO_CHAN_INFO_RAW:
+ case IIO_CHAN_INFO_PROCESSED:
switch (chan->type) {
case IIO_LIGHT:
- ret = isl29018_read_lux(client, val);
+ ret = isl29018_read_lux(chip, val);
break;
case IIO_INTENSITY:
- ret = isl29018_read_ir(client, val);
+ ret = isl29018_read_ir(chip, val);
break;
case IIO_PROXIMITY:
- ret = isl29018_read_proximity_ir(client,
+ ret = isl29018_read_proximity_ir(chip,
chip->prox_scheme, val);
break;
default:
@@ -419,15 +394,17 @@ static const struct iio_chan_spec isl29018_channels[] = {
.type = IIO_LIGHT,
.indexed = 1,
.channel = 0,
- .processed_val = IIO_PROCESSED,
- .info_mask = IIO_CHAN_INFO_CALIBSCALE_SEPARATE_BIT,
+ .info_mask = IIO_CHAN_INFO_PROCESSED_SEPARATE_BIT |
+ IIO_CHAN_INFO_CALIBSCALE_SEPARATE_BIT,
}, {
.type = IIO_INTENSITY,
.modified = 1,
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT,
.channel2 = IIO_MOD_LIGHT_IR,
}, {
/* Unindexed in current ABI. But perhaps it should be. */
.type = IIO_PROXIMITY,
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT,
}
};
@@ -436,10 +413,10 @@ static IIO_CONST_ATTR(range_available, "1000 4000 16000 64000");
static IIO_CONST_ATTR(adc_resolution_available, "4 8 12 16");
static IIO_DEVICE_ATTR(adc_resolution, S_IRUGO | S_IWUSR,
show_resolution, store_resolution, 0);
-static IIO_DEVICE_ATTR(proximity_on_chip_ambient_infrared_supression,
+static IIO_DEVICE_ATTR(proximity_on_chip_ambient_infrared_suppression,
S_IRUGO | S_IWUSR,
- show_prox_infrared_supression,
- store_prox_infrared_supression, 0);
+ show_prox_infrared_suppression,
+ store_prox_infrared_suppression, 0);
#define ISL29018_DEV_ATTR(name) (&iio_dev_attr_##name.dev_attr.attr)
#define ISL29018_CONST_ATTR(name) (&iio_const_attr_##name.dev_attr.attr)
@@ -448,7 +425,7 @@ static struct attribute *isl29018_attributes[] = {
ISL29018_CONST_ATTR(range_available),
ISL29018_DEV_ATTR(adc_resolution),
ISL29018_CONST_ATTR(adc_resolution_available),
- ISL29018_DEV_ATTR(proximity_on_chip_ambient_infrared_supression),
+ ISL29018_DEV_ATTR(proximity_on_chip_ambient_infrared_suppression),
NULL
};
@@ -456,15 +433,12 @@ static const struct attribute_group isl29108_group = {
.attrs = isl29018_attributes,
};
-static int isl29018_chip_init(struct i2c_client *client)
+static int isl29018_chip_init(struct isl29018_chip *chip)
{
- struct isl29018_chip *chip = iio_priv(i2c_get_clientdata(client));
int status;
int new_adc_bit;
unsigned int new_range;
- memset(chip->reg_cache, 0, sizeof(chip->reg_cache));
-
/* Code added per Intersil Application Note 1534:
* When VDD sinks to approximately 1.8V or below, some of
* the part's registers may change their state. When VDD
@@ -485,10 +459,9 @@ static int isl29018_chip_init(struct i2c_client *client)
* the same thing EXCEPT the data sheet asks for a 1ms delay after
* writing the CMD1 register.
*/
- status = isl29018_write_data(client, ISL29018_REG_TEST, 0,
- ISL29018_TEST_MASK, ISL29018_TEST_SHIFT);
+ status = regmap_write(chip->regmap, ISL29018_REG_TEST, 0x0);
if (status < 0) {
- dev_err(&client->dev, "Failed to clear isl29018 TEST reg."
+ dev_err(chip->dev, "Failed to clear isl29018 TEST reg."
"(%d)\n", status);
return status;
}
@@ -497,10 +470,9 @@ static int isl29018_chip_init(struct i2c_client *client)
* "Operating Mode" (COMMAND1) register is reprogrammed when
* data is read from the device.
*/
- status = isl29018_write_data(client, ISL29018_REG_ADD_COMMAND1, 0,
- 0xff, 0);
+ status = regmap_write(chip->regmap, ISL29018_REG_ADD_COMMAND1, 0);
if (status < 0) {
- dev_err(&client->dev, "Failed to clear isl29018 CMD1 reg."
+ dev_err(chip->dev, "Failed to clear isl29018 CMD1 reg."
"(%d)\n", status);
return status;
}
@@ -508,13 +480,13 @@ static int isl29018_chip_init(struct i2c_client *client)
msleep(1); /* per data sheet, page 10 */
/* set defaults */
- status = isl29018_set_range(client, chip->range, &new_range);
+ status = isl29018_set_range(chip, chip->range, &new_range);
if (status < 0) {
- dev_err(&client->dev, "Init of isl29018 fails\n");
+ dev_err(chip->dev, "Init of isl29018 fails\n");
return status;
}
- status = isl29018_set_resolution(client, chip->adc_bit,
+ status = isl29018_set_resolution(chip, chip->adc_bit,
&new_adc_bit);
return 0;
@@ -527,6 +499,32 @@ static const struct iio_info isl29108_info = {
.write_raw = &isl29018_write_raw,
};
+static bool is_volatile_reg(struct device *dev, unsigned int reg)
+{
+ switch (reg) {
+ case ISL29018_REG_ADD_DATA_LSB:
+ case ISL29018_REG_ADD_DATA_MSB:
+ case ISL29018_REG_ADD_COMMAND1:
+ case ISL29018_REG_TEST:
+ return true;
+ default:
+ return false;
+ }
+}
+
+/*
+ * isl29018_regmap_config: regmap configuration.
+ * Use RBTREE mechanism for caching.
+ */
+static const struct regmap_config isl29018_regmap_config = {
+ .reg_bits = 8,
+ .val_bits = 8,
+ .volatile_reg = is_volatile_reg,
+ .max_register = ISL29018_REG_TEST,
+ .num_reg_defaults_raw = ISL29018_REG_TEST + 1,
+ .cache_type = REGCACHE_RBTREE,
+};
+
static int __devinit isl29018_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{
@@ -534,7 +532,7 @@ static int __devinit isl29018_probe(struct i2c_client *client,
struct iio_dev *indio_dev;
int err;
- indio_dev = iio_allocate_device(sizeof(*chip));
+ indio_dev = iio_device_alloc(sizeof(*chip));
if (indio_dev == NULL) {
dev_err(&client->dev, "iio allocation fails\n");
err = -ENOMEM;
@@ -543,7 +541,7 @@ static int __devinit isl29018_probe(struct i2c_client *client,
chip = iio_priv(indio_dev);
i2c_set_clientdata(client, indio_dev);
- chip->client = client;
+ chip->dev = &client->dev;
mutex_init(&chip->lock);
@@ -551,7 +549,14 @@ static int __devinit isl29018_probe(struct i2c_client *client,
chip->range = 1000;
chip->adc_bit = 16;
- err = isl29018_chip_init(client);
+ chip->regmap = devm_regmap_init_i2c(client, &isl29018_regmap_config);
+ if (IS_ERR(chip->regmap)) {
+ err = PTR_ERR(chip->regmap);
+ dev_err(chip->dev, "regmap initialization failed: %d\n", err);
+ goto exit;
+ }
+
+ err = isl29018_chip_init(chip);
if (err)
goto exit_iio_free;
@@ -569,7 +574,7 @@ static int __devinit isl29018_probe(struct i2c_client *client,
return 0;
exit_iio_free:
- iio_free_device(indio_dev);
+ iio_device_free(indio_dev);
exit:
return err;
}
@@ -580,7 +585,7 @@ static int __devexit isl29018_remove(struct i2c_client *client)
dev_dbg(&client->dev, "%s()\n", __func__);
iio_device_unregister(indio_dev);
- iio_free_device(indio_dev);
+ iio_device_free(indio_dev);
return 0;
}
@@ -593,7 +598,7 @@ static const struct i2c_device_id isl29018_id[] = {
MODULE_DEVICE_TABLE(i2c, isl29018_id);
static const struct of_device_id isl29018_of_match[] = {
- { .compatible = "invn,isl29018", },
+ { .compatible = "isil,isl29018", },
{ },
};
MODULE_DEVICE_TABLE(of, isl29018_of_match);
diff --git a/drivers/staging/iio/light/isl29028.c b/drivers/staging/iio/light/isl29028.c
new file mode 100644
index 000000000000..33a4c3f94a14
--- /dev/null
+++ b/drivers/staging/iio/light/isl29028.c
@@ -0,0 +1,566 @@
+/*
+ * IIO driver for the light sensor ISL29028.
+ * ISL29028 is Concurrent Ambient Light and Proximity Sensor
+ *
+ * Copyright (c) 2012, NVIDIA CORPORATION. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <linux/module.h>
+#include <linux/i2c.h>
+#include <linux/err.h>
+#include <linux/mutex.h>
+#include <linux/delay.h>
+#include <linux/slab.h>
+#include <linux/regmap.h>
+#include <linux/iio/iio.h>
+#include <linux/iio/sysfs.h>
+
+#define CONVERSION_TIME_MS 100
+
+#define ISL29028_REG_CONFIGURE 0x01
+
+#define CONFIGURE_ALS_IR_MODE_ALS 0
+#define CONFIGURE_ALS_IR_MODE_IR BIT(0)
+#define CONFIGURE_ALS_IR_MODE_MASK BIT(0)
+
+#define CONFIGURE_ALS_RANGE_LOW_LUX 0
+#define CONFIGURE_ALS_RANGE_HIGH_LUX BIT(1)
+#define CONFIGURE_ALS_RANGE_MASK BIT(1)
+
+#define CONFIGURE_ALS_DIS 0
+#define CONFIGURE_ALS_EN BIT(2)
+#define CONFIGURE_ALS_EN_MASK BIT(2)
+
+#define CONFIGURE_PROX_DRIVE BIT(3)
+
+#define CONFIGURE_PROX_SLP_SH 4
+#define CONFIGURE_PROX_SLP_MASK (7 << CONFIGURE_PROX_SLP_SH)
+
+#define CONFIGURE_PROX_EN BIT(7)
+#define CONFIGURE_PROX_EN_MASK BIT(7)
+
+#define ISL29028_REG_INTERRUPT 0x02
+
+#define ISL29028_REG_PROX_DATA 0x08
+#define ISL29028_REG_ALSIR_L 0x09
+#define ISL29028_REG_ALSIR_U 0x0A
+
+#define ISL29028_REG_TEST1_MODE 0x0E
+#define ISL29028_REG_TEST2_MODE 0x0F
+
+#define ISL29028_NUM_REGS (ISL29028_REG_TEST2_MODE + 1)
+
+enum als_ir_mode {
+ MODE_NONE = 0,
+ MODE_ALS,
+ MODE_IR
+};
+
+struct isl29028_chip {
+ struct device *dev;
+ struct mutex lock;
+ struct regmap *regmap;
+
+ unsigned int prox_sampling;
+ bool enable_prox;
+
+ int lux_scale;
+ int als_ir_mode;
+};
+
+static int isl29028_set_proxim_sampling(struct isl29028_chip *chip,
+ unsigned int sampling)
+{
+ static unsigned int prox_period[] = {800, 400, 200, 100, 75, 50, 12, 0};
+ int sel;
+ unsigned int period = DIV_ROUND_UP(1000, sampling);
+
+ for (sel = 0; sel < ARRAY_SIZE(prox_period); ++sel) {
+ if (period >= prox_period[sel])
+ break;
+ }
+ return regmap_update_bits(chip->regmap, ISL29028_REG_CONFIGURE,
+ CONFIGURE_PROX_SLP_MASK, sel << CONFIGURE_PROX_SLP_SH);
+}
+
+static int isl29028_enable_proximity(struct isl29028_chip *chip, bool enable)
+{
+ int ret;
+ int val = 0;
+
+ if (enable)
+ val = CONFIGURE_PROX_EN;
+ ret = regmap_update_bits(chip->regmap, ISL29028_REG_CONFIGURE,
+ CONFIGURE_PROX_EN_MASK, val);
+ if (ret < 0)
+ return ret;
+
+ /* Wait for conversion to be complete for first sample */
+ mdelay(DIV_ROUND_UP(1000, chip->prox_sampling));
+ return 0;
+}
+
+static int isl29028_set_als_scale(struct isl29028_chip *chip, int lux_scale)
+{
+ int val = (lux_scale == 2000) ? CONFIGURE_ALS_RANGE_HIGH_LUX :
+ CONFIGURE_ALS_RANGE_LOW_LUX;
+
+ return regmap_update_bits(chip->regmap, ISL29028_REG_CONFIGURE,
+ CONFIGURE_ALS_RANGE_MASK, val);
+}
+
+static int isl29028_set_als_ir_mode(struct isl29028_chip *chip,
+ enum als_ir_mode mode)
+{
+ int ret = 0;
+
+ switch (mode) {
+ case MODE_ALS:
+ ret = regmap_update_bits(chip->regmap, ISL29028_REG_CONFIGURE,
+ CONFIGURE_ALS_IR_MODE_MASK, CONFIGURE_ALS_IR_MODE_ALS);
+ if (ret < 0)
+ return ret;
+
+ ret = regmap_update_bits(chip->regmap, ISL29028_REG_CONFIGURE,
+ CONFIGURE_ALS_RANGE_MASK, CONFIGURE_ALS_RANGE_HIGH_LUX);
+ break;
+
+ case MODE_IR:
+ ret = regmap_update_bits(chip->regmap, ISL29028_REG_CONFIGURE,
+ CONFIGURE_ALS_IR_MODE_MASK, CONFIGURE_ALS_IR_MODE_IR);
+ break;
+
+ case MODE_NONE:
+ return regmap_update_bits(chip->regmap, ISL29028_REG_CONFIGURE,
+ CONFIGURE_ALS_EN_MASK, CONFIGURE_ALS_DIS);
+ }
+
+ if (ret < 0)
+ return ret;
+
+ /* Enable the ALS/IR */
+ ret = regmap_update_bits(chip->regmap, ISL29028_REG_CONFIGURE,
+ CONFIGURE_ALS_EN_MASK, CONFIGURE_ALS_EN);
+ if (ret < 0)
+ return ret;
+
+ /* Need to wait for conversion time if ALS/IR mode enabled */
+ mdelay(CONVERSION_TIME_MS);
+ return 0;
+}
+
+static int isl29028_read_als_ir(struct isl29028_chip *chip, int *als_ir)
+{
+ unsigned int lsb;
+ unsigned int msb;
+ int ret;
+
+ ret = regmap_read(chip->regmap, ISL29028_REG_ALSIR_L, &lsb);
+ if (ret < 0) {
+ dev_err(chip->dev,
+ "Error in reading register ALSIR_L err %d\n", ret);
+ return ret;
+ }
+
+ ret = regmap_read(chip->regmap, ISL29028_REG_ALSIR_U, &msb);
+ if (ret < 0) {
+ dev_err(chip->dev,
+ "Error in reading register ALSIR_U err %d\n", ret);
+ return ret;
+ }
+
+ *als_ir = ((msb & 0xF) << 8) | (lsb & 0xFF);
+ return 0;
+}
+
+static int isl29028_read_proxim(struct isl29028_chip *chip, int *prox)
+{
+ unsigned int data;
+ int ret;
+
+ ret = regmap_read(chip->regmap, ISL29028_REG_PROX_DATA, &data);
+ if (ret < 0) {
+ dev_err(chip->dev, "Error in reading register %d, error %d\n",
+ ISL29028_REG_PROX_DATA, ret);
+ return ret;
+ }
+ *prox = data;
+ return 0;
+}
+
+static int isl29028_proxim_get(struct isl29028_chip *chip, int *prox_data)
+{
+ int ret;
+
+ if (!chip->enable_prox) {
+ ret = isl29028_enable_proximity(chip, true);
+ if (ret < 0)
+ return ret;
+ chip->enable_prox = true;
+ }
+ return isl29028_read_proxim(chip, prox_data);
+}
+
+static int isl29028_als_get(struct isl29028_chip *chip, int *als_data)
+{
+ int ret;
+ int als_ir_data;
+
+ if (chip->als_ir_mode != MODE_ALS) {
+ ret = isl29028_set_als_ir_mode(chip, MODE_ALS);
+ if (ret < 0) {
+ dev_err(chip->dev,
+ "Error in enabling ALS mode err %d\n", ret);
+ return ret;
+ }
+ chip->als_ir_mode = MODE_ALS;
+ }
+
+ ret = isl29028_read_als_ir(chip, &als_ir_data);
+ if (ret < 0)
+ return ret;
+
+ /*
+ * convert als data count to lux.
+ * if lux_scale = 125, lux = count * 0.031
+ * if lux_scale = 2000, lux = count * 0.49
+ */
+ if (chip->lux_scale == 125)
+ als_ir_data = (als_ir_data * 31) / 1000;
+ else
+ als_ir_data = (als_ir_data * 49) / 100;
+
+ *als_data = als_ir_data;
+ return 0;
+}
+
+static int isl29028_ir_get(struct isl29028_chip *chip, int *ir_data)
+{
+ int ret;
+
+ if (chip->als_ir_mode != MODE_IR) {
+ ret = isl29028_set_als_ir_mode(chip, MODE_IR);
+ if (ret < 0) {
+ dev_err(chip->dev,
+ "Error in enabling IR mode err %d\n", ret);
+ return ret;
+ }
+ chip->als_ir_mode = MODE_IR;
+ }
+ return isl29028_read_als_ir(chip, ir_data);
+}
+
+/* Channel IO */
+static int isl29028_write_raw(struct iio_dev *indio_dev,
+ struct iio_chan_spec const *chan, int val, int val2, long mask)
+{
+ struct isl29028_chip *chip = iio_priv(indio_dev);
+ int ret = -EINVAL;
+
+ mutex_lock(&chip->lock);
+ switch (chan->type) {
+ case IIO_PROXIMITY:
+ if (mask != IIO_CHAN_INFO_SAMP_FREQ) {
+ dev_err(chip->dev,
+ "proximity: mask value 0x%08lx not supported\n",
+ mask);
+ break;
+ }
+ if (val < 1 || val > 100) {
+ dev_err(chip->dev,
+ "Samp_freq %d is not in range[1:100]\n", val);
+ break;
+ }
+ ret = isl29028_set_proxim_sampling(chip, val);
+ if (ret < 0) {
+ dev_err(chip->dev,
+ "Setting proximity samp_freq fail, err %d\n",
+ ret);
+ break;
+ }
+ chip->prox_sampling = val;
+ break;
+
+ case IIO_LIGHT:
+ if (mask != IIO_CHAN_INFO_SCALE) {
+ dev_err(chip->dev,
+ "light: mask value 0x%08lx not supported\n",
+ mask);
+ break;
+ }
+ if ((val != 125) && (val != 2000)) {
+ dev_err(chip->dev,
+ "lux scale %d is invalid [125, 2000]\n", val);
+ break;
+ }
+ ret = isl29028_set_als_scale(chip, val);
+ if (ret < 0) {
+ dev_err(chip->dev,
+ "Setting lux scale fail with error %d\n", ret);
+ break;
+ }
+ chip->lux_scale = val;
+ break;
+
+ default:
+ dev_err(chip->dev, "Unsupported channel type\n");
+ break;
+ }
+ mutex_unlock(&chip->lock);
+ return ret;
+}
+
+static int isl29028_read_raw(struct iio_dev *indio_dev,
+ struct iio_chan_spec const *chan, int *val, int *val2, long mask)
+{
+ struct isl29028_chip *chip = iio_priv(indio_dev);
+ int ret = -EINVAL;
+
+ mutex_lock(&chip->lock);
+ switch (mask) {
+ case IIO_CHAN_INFO_RAW:
+ case IIO_CHAN_INFO_PROCESSED:
+ switch (chan->type) {
+ case IIO_LIGHT:
+ ret = isl29028_als_get(chip, val);
+ break;
+ case IIO_INTENSITY:
+ ret = isl29028_ir_get(chip, val);
+ break;
+ case IIO_PROXIMITY:
+ ret = isl29028_proxim_get(chip, val);
+ break;
+ default:
+ break;
+ }
+ if (ret < 0)
+ break;
+ ret = IIO_VAL_INT;
+ break;
+
+ case IIO_CHAN_INFO_SAMP_FREQ:
+ if (chan->type != IIO_PROXIMITY)
+ break;
+ *val = chip->prox_sampling;
+ ret = IIO_VAL_INT;
+ break;
+
+ case IIO_CHAN_INFO_SCALE:
+ if (chan->type != IIO_LIGHT)
+ break;
+ *val = chip->lux_scale;
+ ret = IIO_VAL_INT;
+ break;
+
+ default:
+ dev_err(chip->dev, "mask value 0x%08lx not supported\n", mask);
+ break;
+ }
+ mutex_unlock(&chip->lock);
+ return ret;
+}
+
+static IIO_CONST_ATTR(in_proximity_sampling_frequency_available,
+ "1, 3, 5, 10, 13, 20, 83, 100");
+static IIO_CONST_ATTR(in_illuminance_scale_available, "125, 2000");
+
+#define ISL29028_DEV_ATTR(name) (&iio_dev_attr_##name.dev_attr.attr)
+#define ISL29028_CONST_ATTR(name) (&iio_const_attr_##name.dev_attr.attr)
+static struct attribute *isl29028_attributes[] = {
+ ISL29028_CONST_ATTR(in_proximity_sampling_frequency_available),
+ ISL29028_CONST_ATTR(in_illuminance_scale_available),
+ NULL,
+};
+
+static const struct attribute_group isl29108_group = {
+ .attrs = isl29028_attributes,
+};
+
+static const struct iio_chan_spec isl29028_channels[] = {
+ {
+ .type = IIO_LIGHT,
+ .info_mask = IIO_CHAN_INFO_PROCESSED_SEPARATE_BIT |
+ IIO_CHAN_INFO_SCALE_SEPARATE_BIT,
+ }, {
+ .type = IIO_INTENSITY,
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT,
+ }, {
+ .type = IIO_PROXIMITY,
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
+ IIO_CHAN_INFO_SAMP_FREQ_SEPARATE_BIT,
+ }
+};
+
+static const struct iio_info isl29028_info = {
+ .attrs = &isl29108_group,
+ .driver_module = THIS_MODULE,
+ .read_raw = &isl29028_read_raw,
+ .write_raw = &isl29028_write_raw,
+};
+
+static int isl29028_chip_init(struct isl29028_chip *chip)
+{
+ int ret;
+
+ chip->enable_prox = false;
+ chip->prox_sampling = 20;
+ chip->lux_scale = 2000;
+ chip->als_ir_mode = MODE_NONE;
+
+ ret = regmap_write(chip->regmap, ISL29028_REG_TEST1_MODE, 0x0);
+ if (ret < 0) {
+ dev_err(chip->dev, "%s(): write to reg %d failed, err = %d\n",
+ __func__, ISL29028_REG_TEST1_MODE, ret);
+ return ret;
+ }
+ ret = regmap_write(chip->regmap, ISL29028_REG_TEST2_MODE, 0x0);
+ if (ret < 0) {
+ dev_err(chip->dev, "%s(): write to reg %d failed, err = %d\n",
+ __func__, ISL29028_REG_TEST2_MODE, ret);
+ return ret;
+ }
+
+ ret = regmap_write(chip->regmap, ISL29028_REG_CONFIGURE, 0x0);
+ if (ret < 0) {
+ dev_err(chip->dev, "%s(): write to reg %d failed, err = %d\n",
+ __func__, ISL29028_REG_CONFIGURE, ret);
+ return ret;
+ }
+
+ ret = isl29028_set_proxim_sampling(chip, chip->prox_sampling);
+ if (ret < 0) {
+ dev_err(chip->dev, "%s(): setting the proximity, err = %d\n",
+ __func__, ret);
+ return ret;
+ }
+
+ ret = isl29028_set_als_scale(chip, chip->lux_scale);
+ if (ret < 0)
+ dev_err(chip->dev, "%s(): setting als scale failed, err = %d\n",
+ __func__, ret);
+ return ret;
+}
+
+static bool is_volatile_reg(struct device *dev, unsigned int reg)
+{
+ switch (reg) {
+ case ISL29028_REG_INTERRUPT:
+ case ISL29028_REG_PROX_DATA:
+ case ISL29028_REG_ALSIR_L:
+ case ISL29028_REG_ALSIR_U:
+ return true;
+ default:
+ return false;
+ }
+}
+
+static const struct regmap_config isl29028_regmap_config = {
+ .reg_bits = 8,
+ .val_bits = 8,
+ .volatile_reg = is_volatile_reg,
+ .max_register = ISL29028_NUM_REGS - 1,
+ .num_reg_defaults_raw = ISL29028_NUM_REGS,
+ .cache_type = REGCACHE_RBTREE,
+};
+
+static int __devinit isl29028_probe(struct i2c_client *client,
+ const struct i2c_device_id *id)
+{
+ struct isl29028_chip *chip;
+ struct iio_dev *indio_dev;
+ int ret;
+
+ indio_dev = iio_device_alloc(sizeof(*chip));
+ if (!indio_dev) {
+ dev_err(&client->dev, "iio allocation fails\n");
+ return -ENOMEM;
+ }
+
+ chip = iio_priv(indio_dev);
+
+ i2c_set_clientdata(client, indio_dev);
+ chip->dev = &client->dev;
+ mutex_init(&chip->lock);
+
+ chip->regmap = devm_regmap_init_i2c(client, &isl29028_regmap_config);
+ if (IS_ERR(chip->regmap)) {
+ ret = PTR_ERR(chip->regmap);
+ dev_err(chip->dev, "regmap initialization failed: %d\n", ret);
+ goto exit_iio_free;
+ }
+
+ ret = isl29028_chip_init(chip);
+ if (ret < 0) {
+ dev_err(chip->dev, "chip initialization failed: %d\n", ret);
+ goto exit_iio_free;
+ }
+
+ indio_dev->info = &isl29028_info;
+ indio_dev->channels = isl29028_channels;
+ indio_dev->num_channels = ARRAY_SIZE(isl29028_channels);
+ indio_dev->name = id->name;
+ indio_dev->dev.parent = &client->dev;
+ indio_dev->modes = INDIO_DIRECT_MODE;
+ ret = iio_device_register(indio_dev);
+ if (ret < 0) {
+ dev_err(chip->dev, "iio registration fails with error %d\n",
+ ret);
+ goto exit_iio_free;
+ }
+ return 0;
+
+exit_iio_free:
+ iio_device_free(indio_dev);
+ return ret;
+}
+
+static int __devexit isl29028_remove(struct i2c_client *client)
+{
+ struct iio_dev *indio_dev = i2c_get_clientdata(client);
+
+ iio_device_unregister(indio_dev);
+ iio_device_free(indio_dev);
+ return 0;
+}
+
+static const struct i2c_device_id isl29028_id[] = {
+ {"isl29028", 0},
+ {}
+};
+MODULE_DEVICE_TABLE(i2c, isl29028_id);
+
+static const struct of_device_id isl29028_of_match[] = {
+ { .compatible = "isil,isl29028", },
+ { },
+};
+MODULE_DEVICE_TABLE(of, isl29028_of_match);
+
+static struct i2c_driver isl29028_driver = {
+ .class = I2C_CLASS_HWMON,
+ .driver = {
+ .name = "isl29028",
+ .owner = THIS_MODULE,
+ .of_match_table = isl29028_of_match,
+ },
+ .probe = isl29028_probe,
+ .remove = __devexit_p(isl29028_remove),
+ .id_table = isl29028_id,
+};
+
+module_i2c_driver(isl29028_driver);
+
+MODULE_DESCRIPTION("ISL29028 Ambient Light and Proximity Sensor driver");
+MODULE_LICENSE("GPL v2");
+MODULE_AUTHOR("Laxman Dewangan <ldewangan@nvidia.com>");
diff --git a/drivers/staging/iio/light/tsl2563.c b/drivers/staging/iio/light/tsl2563.c
index 546c95a4ea9e..9d740be43a82 100644
--- a/drivers/staging/iio/light/tsl2563.c
+++ b/drivers/staging/iio/light/tsl2563.c
@@ -35,9 +35,9 @@
#include <linux/err.h>
#include <linux/slab.h>
-#include "../iio.h"
-#include "../sysfs.h"
-#include "../events.h"
+#include <linux/iio/iio.h>
+#include <linux/iio/sysfs.h>
+#include <linux/iio/events.h>
#include "tsl2563.h"
/* Use this many bits for fraction part. */
@@ -465,7 +465,7 @@ static int tsl2563_write_raw(struct iio_dev *indio_dev,
{
struct tsl2563_chip *chip = iio_priv(indio_dev);
- if (chan->channel == 0)
+ if (chan->channel == IIO_MOD_LIGHT_BOTH)
chip->calib0 = calib_from_sysfs(val);
else
chip->calib1 = calib_from_sysfs(val);
@@ -485,7 +485,8 @@ static int tsl2563_read_raw(struct iio_dev *indio_dev,
mutex_lock(&chip->lock);
switch (m) {
- case 0:
+ case IIO_CHAN_INFO_RAW:
+ case IIO_CHAN_INFO_PROCESSED:
switch (chan->type) {
case IIO_LIGHT:
ret = tsl2563_get_adc(chip);
@@ -534,12 +535,14 @@ static const struct iio_chan_spec tsl2563_channels[] = {
{
.type = IIO_LIGHT,
.indexed = 1,
+ .info_mask = IIO_CHAN_INFO_PROCESSED_SEPARATE_BIT,
.channel = 0,
}, {
.type = IIO_INTENSITY,
.modified = 1,
.channel2 = IIO_MOD_LIGHT_BOTH,
- .info_mask = IIO_CHAN_INFO_CALIBSCALE_SEPARATE_BIT,
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
+ IIO_CHAN_INFO_CALIBSCALE_SEPARATE_BIT,
.event_mask = (IIO_EV_BIT(IIO_EV_TYPE_THRESH,
IIO_EV_DIR_RISING) |
IIO_EV_BIT(IIO_EV_TYPE_THRESH,
@@ -548,7 +551,8 @@ static const struct iio_chan_spec tsl2563_channels[] = {
.type = IIO_INTENSITY,
.modified = 1,
.channel2 = IIO_MOD_LIGHT_IR,
- .info_mask = IIO_CHAN_INFO_CALIBSCALE_SEPARATE_BIT,
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
+ IIO_CHAN_INFO_CALIBSCALE_SEPARATE_BIT,
}
};
@@ -710,7 +714,7 @@ static int __devinit tsl2563_probe(struct i2c_client *client,
int err = 0;
u8 id = 0;
- indio_dev = iio_allocate_device(sizeof(*chip));
+ indio_dev = iio_device_alloc(sizeof(*chip));
if (!indio_dev)
return -ENOMEM;
@@ -797,7 +801,7 @@ fail2:
if (client->irq)
free_irq(client->irq, indio_dev);
fail1:
- iio_free_device(indio_dev);
+ iio_device_free(indio_dev);
return err;
}
@@ -818,7 +822,7 @@ static int tsl2563_remove(struct i2c_client *client)
if (client->irq)
free_irq(client->irq, indio_dev);
- iio_free_device(indio_dev);
+ iio_device_free(indio_dev);
return 0;
}
diff --git a/drivers/staging/iio/light/tsl2583.c b/drivers/staging/iio/light/tsl2583.c
index 8671d98e0448..6d2f4c659e56 100644
--- a/drivers/staging/iio/light/tsl2583.c
+++ b/drivers/staging/iio/light/tsl2583.c
@@ -28,7 +28,7 @@
#include <linux/unistd.h>
#include <linux/slab.h>
#include <linux/module.h>
-#include "../iio.h"
+#include <linux/iio/iio.h>
#define TSL258X_MAX_DEVICE_REGS 32
@@ -410,7 +410,7 @@ static int taos_chip_on(struct iio_dev *indio_dev)
return -EINVAL;
}
- /* determine als integration regster */
+ /* determine als integration register */
als_count = (chip->taos_settings.als_time * 100 + 135) / 270;
if (als_count == 0)
als_count = 1; /* ensure at least one cycle */
@@ -483,7 +483,7 @@ static int taos_chip_off(struct iio_dev *indio_dev)
static ssize_t taos_power_state_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct tsl2583_chip *chip = iio_priv(indio_dev);
return sprintf(buf, "%d\n", chip->taos_chip_status);
@@ -492,7 +492,7 @@ static ssize_t taos_power_state_show(struct device *dev,
static ssize_t taos_power_state_store(struct device *dev,
struct device_attribute *attr, const char *buf, size_t len)
{
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
unsigned long value;
if (strict_strtoul(buf, 0, &value))
@@ -509,7 +509,7 @@ static ssize_t taos_power_state_store(struct device *dev,
static ssize_t taos_gain_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct tsl2583_chip *chip = iio_priv(indio_dev);
char gain[4] = {0};
@@ -534,7 +534,7 @@ static ssize_t taos_gain_show(struct device *dev,
static ssize_t taos_gain_store(struct device *dev,
struct device_attribute *attr, const char *buf, size_t len)
{
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct tsl2583_chip *chip = iio_priv(indio_dev);
unsigned long value;
@@ -571,7 +571,7 @@ static ssize_t taos_gain_available_show(struct device *dev,
static ssize_t taos_als_time_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct tsl2583_chip *chip = iio_priv(indio_dev);
return sprintf(buf, "%d\n", chip->taos_settings.als_time);
@@ -580,7 +580,7 @@ static ssize_t taos_als_time_show(struct device *dev,
static ssize_t taos_als_time_store(struct device *dev,
struct device_attribute *attr, const char *buf, size_t len)
{
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct tsl2583_chip *chip = iio_priv(indio_dev);
unsigned long value;
@@ -608,7 +608,7 @@ static ssize_t taos_als_time_available_show(struct device *dev,
static ssize_t taos_als_trim_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct tsl2583_chip *chip = iio_priv(indio_dev);
return sprintf(buf, "%d\n", chip->taos_settings.als_gain_trim);
@@ -617,7 +617,7 @@ static ssize_t taos_als_trim_show(struct device *dev,
static ssize_t taos_als_trim_store(struct device *dev,
struct device_attribute *attr, const char *buf, size_t len)
{
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct tsl2583_chip *chip = iio_priv(indio_dev);
unsigned long value;
@@ -633,7 +633,7 @@ static ssize_t taos_als_trim_store(struct device *dev,
static ssize_t taos_als_cal_target_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct tsl2583_chip *chip = iio_priv(indio_dev);
return sprintf(buf, "%d\n", chip->taos_settings.als_cal_target);
@@ -642,7 +642,7 @@ static ssize_t taos_als_cal_target_show(struct device *dev,
static ssize_t taos_als_cal_target_store(struct device *dev,
struct device_attribute *attr, const char *buf, size_t len)
{
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct tsl2583_chip *chip = iio_priv(indio_dev);
unsigned long value;
@@ -660,7 +660,7 @@ static ssize_t taos_lux_show(struct device *dev, struct device_attribute *attr,
{
int ret;
- ret = taos_get_lux(dev_get_drvdata(dev));
+ ret = taos_get_lux(dev_to_iio_dev(dev));
if (ret < 0)
return ret;
@@ -670,7 +670,7 @@ static ssize_t taos_lux_show(struct device *dev, struct device_attribute *attr,
static ssize_t taos_do_calibrate(struct device *dev,
struct device_attribute *attr, const char *buf, size_t len)
{
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
unsigned long value;
if (strict_strtoul(buf, 0, &value))
@@ -708,7 +708,7 @@ static ssize_t taos_luxtable_show(struct device *dev,
static ssize_t taos_luxtable_store(struct device *dev,
struct device_attribute *attr, const char *buf, size_t len)
{
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct tsl2583_chip *chip = iio_priv(indio_dev);
int value[ARRAY_SIZE(taos_device_lux)*3 + 1];
int n;
@@ -815,7 +815,7 @@ static int __devinit taos_probe(struct i2c_client *clientp,
return -EOPNOTSUPP;
}
- indio_dev = iio_allocate_device(sizeof(*chip));
+ indio_dev = iio_device_alloc(sizeof(*chip));
if (indio_dev == NULL) {
ret = -ENOMEM;
dev_err(&clientp->dev, "iio allocation failed\n");
@@ -879,7 +879,7 @@ static int __devinit taos_probe(struct i2c_client *clientp,
dev_info(&clientp->dev, "Light sensor found.\n");
return 0;
fail1:
- iio_free_device(indio_dev);
+ iio_device_free(indio_dev);
fail2:
return ret;
}
@@ -926,7 +926,7 @@ static SIMPLE_DEV_PM_OPS(taos_pm_ops, taos_suspend, taos_resume);
static int __devexit taos_remove(struct i2c_client *client)
{
iio_device_unregister(i2c_get_clientdata(client));
- iio_free_device(i2c_get_clientdata(client));
+ iio_device_free(i2c_get_clientdata(client));
return 0;
}
diff --git a/drivers/staging/iio/light/tsl2x7x.h b/drivers/staging/iio/light/tsl2x7x.h
new file mode 100644
index 000000000000..c4acf5ff1794
--- /dev/null
+++ b/drivers/staging/iio/light/tsl2x7x.h
@@ -0,0 +1,100 @@
+/*
+ * Device driver for monitoring ambient light intensity (lux)
+ * and proximity (prox) within the TAOS TSL2X7X family of devices.
+ *
+ * Copyright (c) 2012, TAOS Corporation.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#ifndef __TSL2X7X_H
+#define __TSL2X7X_H
+#include <linux/pm.h>
+
+/* Max number of segments allowable in LUX table */
+#define TSL2X7X_MAX_LUX_TABLE_SIZE 9
+#define MAX_DEFAULT_TABLE_BYTES (sizeof(int) * TSL2X7X_MAX_LUX_TABLE_SIZE)
+
+struct iio_dev;
+
+struct tsl2x7x_lux {
+ unsigned int ratio;
+ unsigned int ch0;
+ unsigned int ch1;
+};
+
+/**
+ * struct tsl2x7x_default_settings - power on defaults unless
+ * overridden by platform data.
+ * @als_time: ALS Integration time - multiple of 50mS
+ * @als_gain: Index into the ALS gain table.
+ * @als_gain_trim: default gain trim to account for
+ * aperture effects.
+ * @wait_time: Time between PRX and ALS cycles
+ * in 2.7 periods
+ * @prx_time: 5.2ms prox integration time -
+ * decrease in 2.7ms periods
+ * @prx_gain: Proximity gain index
+ * @prox_config: Prox configuration filters.
+ * @als_cal_target: Known external ALS reading for
+ * calibration.
+ * @interrupts_en: Enable/Disable - 0x00 = none, 0x10 = als,
+ * 0x20 = prx, 0x30 = bth
+ * @persistence: H/W Filters, Number of 'out of limits'
+ * ADC readings PRX/ALS.
+ * @als_thresh_low: CH0 'low' count to trigger interrupt.
+ * @als_thresh_high: CH0 'high' count to trigger interrupt.
+ * @prox_thres_low: Low threshold proximity detection.
+ * @prox_thres_high: High threshold proximity detection
+ * @prox_pulse_count: Number if proximity emitter pulses
+ * @prox_max_samples_cal: Used for prox cal.
+ */
+struct tsl2x7x_settings {
+ int als_time;
+ int als_gain;
+ int als_gain_trim;
+ int wait_time;
+ int prx_time;
+ int prox_gain;
+ int prox_config;
+ int als_cal_target;
+ u8 interrupts_en;
+ u8 persistence;
+ int als_thresh_low;
+ int als_thresh_high;
+ int prox_thres_low;
+ int prox_thres_high;
+ int prox_pulse_count;
+ int prox_max_samples_cal;
+};
+
+/**
+ * struct tsl2X7X_platform_data - Platform callback, glass and defaults
+ * @platform_power: Suspend/resume platform callback
+ * @power_on: Power on callback
+ * @power_off: Power off callback
+ * @platform_lux_table: Device specific glass coefficents
+ * @platform_default_settings: Device specific power on defaults
+ *
+ */
+struct tsl2X7X_platform_data {
+ int (*platform_power)(struct device *dev, pm_message_t);
+ int (*power_on) (struct iio_dev *indio_dev);
+ int (*power_off) (struct i2c_client *dev);
+ struct tsl2x7x_lux platform_lux_table[TSL2X7X_MAX_LUX_TABLE_SIZE];
+ struct tsl2x7x_settings *platform_default_settings;
+};
+
+#endif /* __TSL2X7X_H */
diff --git a/drivers/staging/iio/light/tsl2x7x_core.c b/drivers/staging/iio/light/tsl2x7x_core.c
new file mode 100644
index 000000000000..497a977ae411
--- /dev/null
+++ b/drivers/staging/iio/light/tsl2x7x_core.c
@@ -0,0 +1,2080 @@
+/*
+ * Device driver for monitoring ambient light intensity in (lux)
+ * and proximity detection (prox) within the TAOS TSL2X7X family of devices.
+ *
+ * Copyright (c) 2012, TAOS Corporation.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#include <linux/kernel.h>
+#include <linux/i2c.h>
+#include <linux/errno.h>
+#include <linux/delay.h>
+#include <linux/mutex.h>
+#include <linux/interrupt.h>
+#include <linux/slab.h>
+#include <linux/module.h>
+#include <linux/iio/events.h>
+#include <linux/iio/iio.h>
+#include <linux/iio/sysfs.h>
+#include "tsl2x7x.h"
+
+/* Cal defs*/
+#define PROX_STAT_CAL 0
+#define PROX_STAT_SAMP 1
+#define MAX_SAMPLES_CAL 200
+
+/* TSL2X7X Device ID */
+#define TRITON_ID 0x00
+#define SWORDFISH_ID 0x30
+#define HALIBUT_ID 0x20
+
+/* Lux calculation constants */
+#define TSL2X7X_LUX_CALC_OVER_FLOW 65535
+
+/* TAOS Register definitions - note:
+ * depending on device, some of these register are not used and the
+ * register address is benign.
+ */
+/* 2X7X register offsets */
+#define TSL2X7X_MAX_CONFIG_REG 16
+
+/* Device Registers and Masks */
+#define TSL2X7X_CNTRL 0x00
+#define TSL2X7X_ALS_TIME 0X01
+#define TSL2X7X_PRX_TIME 0x02
+#define TSL2X7X_WAIT_TIME 0x03
+#define TSL2X7X_ALS_MINTHRESHLO 0X04
+#define TSL2X7X_ALS_MINTHRESHHI 0X05
+#define TSL2X7X_ALS_MAXTHRESHLO 0X06
+#define TSL2X7X_ALS_MAXTHRESHHI 0X07
+#define TSL2X7X_PRX_MINTHRESHLO 0X08
+#define TSL2X7X_PRX_MINTHRESHHI 0X09
+#define TSL2X7X_PRX_MAXTHRESHLO 0X0A
+#define TSL2X7X_PRX_MAXTHRESHHI 0X0B
+#define TSL2X7X_PERSISTENCE 0x0C
+#define TSL2X7X_PRX_CONFIG 0x0D
+#define TSL2X7X_PRX_COUNT 0x0E
+#define TSL2X7X_GAIN 0x0F
+#define TSL2X7X_NOTUSED 0x10
+#define TSL2X7X_REVID 0x11
+#define TSL2X7X_CHIPID 0x12
+#define TSL2X7X_STATUS 0x13
+#define TSL2X7X_ALS_CHAN0LO 0x14
+#define TSL2X7X_ALS_CHAN0HI 0x15
+#define TSL2X7X_ALS_CHAN1LO 0x16
+#define TSL2X7X_ALS_CHAN1HI 0x17
+#define TSL2X7X_PRX_LO 0x18
+#define TSL2X7X_PRX_HI 0x19
+
+/* tsl2X7X cmd reg masks */
+#define TSL2X7X_CMD_REG 0x80
+#define TSL2X7X_CMD_SPL_FN 0x60
+
+#define TSL2X7X_CMD_PROX_INT_CLR 0X05
+#define TSL2X7X_CMD_ALS_INT_CLR 0x06
+#define TSL2X7X_CMD_PROXALS_INT_CLR 0X07
+
+/* tsl2X7X cntrl reg masks */
+#define TSL2X7X_CNTL_ADC_ENBL 0x02
+#define TSL2X7X_CNTL_PWR_ON 0x01
+
+/* tsl2X7X status reg masks */
+#define TSL2X7X_STA_ADC_VALID 0x01
+#define TSL2X7X_STA_PRX_VALID 0x02
+#define TSL2X7X_STA_ADC_PRX_VALID (TSL2X7X_STA_ADC_VALID |\
+ TSL2X7X_STA_PRX_VALID)
+#define TSL2X7X_STA_ALS_INTR 0x10
+#define TSL2X7X_STA_PRX_INTR 0x20
+
+/* tsl2X7X cntrl reg masks */
+#define TSL2X7X_CNTL_REG_CLEAR 0x00
+#define TSL2X7X_CNTL_PROX_INT_ENBL 0X20
+#define TSL2X7X_CNTL_ALS_INT_ENBL 0X10
+#define TSL2X7X_CNTL_WAIT_TMR_ENBL 0X08
+#define TSL2X7X_CNTL_PROX_DET_ENBL 0X04
+#define TSL2X7X_CNTL_PWRON 0x01
+#define TSL2X7X_CNTL_ALSPON_ENBL 0x03
+#define TSL2X7X_CNTL_INTALSPON_ENBL 0x13
+#define TSL2X7X_CNTL_PROXPON_ENBL 0x0F
+#define TSL2X7X_CNTL_INTPROXPON_ENBL 0x2F
+
+/*Prox diode to use */
+#define TSL2X7X_DIODE0 0x10
+#define TSL2X7X_DIODE1 0x20
+#define TSL2X7X_DIODE_BOTH 0x30
+
+/* LED Power */
+#define TSL2X7X_mA100 0x00
+#define TSL2X7X_mA50 0x40
+#define TSL2X7X_mA25 0x80
+#define TSL2X7X_mA13 0xD0
+#define TSL2X7X_MAX_TIMER_CNT (0xFF)
+
+/*Common device IIO EventMask */
+#define TSL2X7X_EVENT_MASK \
+ (IIO_EV_BIT(IIO_EV_TYPE_THRESH, IIO_EV_DIR_RISING) | \
+ IIO_EV_BIT(IIO_EV_TYPE_THRESH, IIO_EV_DIR_FALLING)),
+
+#define TSL2X7X_MIN_ITIME 3
+
+/* TAOS txx2x7x Device family members */
+enum {
+ tsl2571,
+ tsl2671,
+ tmd2671,
+ tsl2771,
+ tmd2771,
+ tsl2572,
+ tsl2672,
+ tmd2672,
+ tsl2772,
+ tmd2772
+};
+
+enum {
+ TSL2X7X_CHIP_UNKNOWN = 0,
+ TSL2X7X_CHIP_WORKING = 1,
+ TSL2X7X_CHIP_SUSPENDED = 2
+};
+
+struct tsl2x7x_parse_result {
+ int integer;
+ int fract;
+};
+
+/* Per-device data */
+struct tsl2x7x_als_info {
+ u16 als_ch0;
+ u16 als_ch1;
+ u16 lux;
+};
+
+struct tsl2x7x_prox_stat {
+ int min;
+ int max;
+ int mean;
+ unsigned long stddev;
+};
+
+struct tsl2x7x_chip_info {
+ int chan_table_elements;
+ struct iio_chan_spec channel[4];
+ const struct iio_info *info;
+};
+
+struct tsl2X7X_chip {
+ kernel_ulong_t id;
+ struct mutex prox_mutex;
+ struct mutex als_mutex;
+ struct i2c_client *client;
+ u16 prox_data;
+ struct tsl2x7x_als_info als_cur_info;
+ struct tsl2x7x_settings tsl2x7x_settings;
+ struct tsl2X7X_platform_data *pdata;
+ int als_time_scale;
+ int als_saturation;
+ int tsl2x7x_chip_status;
+ u8 tsl2x7x_config[TSL2X7X_MAX_CONFIG_REG];
+ const struct tsl2x7x_chip_info *chip_info;
+ const struct iio_info *info;
+ s64 event_timestamp;
+ /* This structure is intentionally large to accommodate
+ * updates via sysfs. */
+ /* Sized to 9 = max 8 segments + 1 termination segment */
+ struct tsl2x7x_lux tsl2x7x_device_lux[TSL2X7X_MAX_LUX_TABLE_SIZE];
+};
+
+/* Different devices require different coefficents */
+static const struct tsl2x7x_lux tsl2x71_lux_table[] = {
+ { 14461, 611, 1211 },
+ { 18540, 352, 623 },
+ { 0, 0, 0 },
+};
+
+static const struct tsl2x7x_lux tmd2x71_lux_table[] = {
+ { 11635, 115, 256 },
+ { 15536, 87, 179 },
+ { 0, 0, 0 },
+};
+
+static const struct tsl2x7x_lux tsl2x72_lux_table[] = {
+ { 14013, 466, 917 },
+ { 18222, 310, 552 },
+ { 0, 0, 0 },
+};
+
+static const struct tsl2x7x_lux tmd2x72_lux_table[] = {
+ { 13218, 130, 262 },
+ { 17592, 92, 169 },
+ { 0, 0, 0 },
+};
+
+static const struct tsl2x7x_lux *tsl2x7x_default_lux_table_group[] = {
+ [tsl2571] = tsl2x71_lux_table,
+ [tsl2671] = tsl2x71_lux_table,
+ [tmd2671] = tmd2x71_lux_table,
+ [tsl2771] = tsl2x71_lux_table,
+ [tmd2771] = tmd2x71_lux_table,
+ [tsl2572] = tsl2x72_lux_table,
+ [tsl2672] = tsl2x72_lux_table,
+ [tmd2672] = tmd2x72_lux_table,
+ [tsl2772] = tsl2x72_lux_table,
+ [tmd2772] = tmd2x72_lux_table,
+};
+
+static const struct tsl2x7x_settings tsl2x7x_default_settings = {
+ .als_time = 219, /* 101 ms */
+ .als_gain = 0,
+ .prx_time = 254, /* 5.4 ms */
+ .prox_gain = 1,
+ .wait_time = 245,
+ .prox_config = 0,
+ .als_gain_trim = 1000,
+ .als_cal_target = 150,
+ .als_thresh_low = 200,
+ .als_thresh_high = 256,
+ .persistence = 255,
+ .interrupts_en = 0,
+ .prox_thres_low = 0,
+ .prox_thres_high = 512,
+ .prox_max_samples_cal = 30,
+ .prox_pulse_count = 8
+};
+
+static const s16 tsl2X7X_als_gainadj[] = {
+ 1,
+ 8,
+ 16,
+ 120
+};
+
+static const s16 tsl2X7X_prx_gainadj[] = {
+ 1,
+ 2,
+ 4,
+ 8
+};
+
+/* Channel variations */
+enum {
+ ALS,
+ PRX,
+ ALSPRX,
+ PRX2,
+ ALSPRX2,
+};
+
+static const u8 device_channel_config[] = {
+ ALS,
+ PRX,
+ PRX,
+ ALSPRX,
+ ALSPRX,
+ ALS,
+ PRX2,
+ PRX2,
+ ALSPRX2,
+ ALSPRX2
+};
+
+/**
+ * tsl2x7x_parse_buffer() - parse a decimal result from a buffer.
+ * @*buf: pointer to char buffer to parse
+ * @*result: pointer to buffer to contain
+ * resulting interger / decimal as ints.
+ *
+ */
+static int
+tsl2x7x_parse_buffer(const char *buf, struct tsl2x7x_parse_result *result)
+{
+ int integer = 0, fract = 0, fract_mult = 100000;
+ bool integer_part = true, negative = false;
+
+ if (buf[0] == '-') {
+ negative = true;
+ buf++;
+ }
+
+ while (*buf) {
+ if ('0' <= *buf && *buf <= '9') {
+ if (integer_part)
+ integer = integer*10 + *buf - '0';
+ else {
+ fract += fract_mult*(*buf - '0');
+ if (fract_mult == 1)
+ break;
+ fract_mult /= 10;
+ }
+ } else if (*buf == '\n') {
+ if (*(buf + 1) == '\0')
+ break;
+ else
+ return -EINVAL;
+ } else if (*buf == '.') {
+ integer_part = false;
+ } else {
+ return -EINVAL;
+ }
+ buf++;
+ }
+ if (negative) {
+ if (integer)
+ integer = -integer;
+ else
+ fract = -fract;
+ }
+
+ result->integer = integer;
+ result->fract = fract;
+
+ return 0;
+}
+
+/**
+ * tsl2x7x_i2c_read() - Read a byte from a register.
+ * @client: i2c client
+ * @reg: device register to read from
+ * @*val: pointer to location to store register contents.
+ *
+ */
+static int
+tsl2x7x_i2c_read(struct i2c_client *client, u8 reg, u8 *val)
+{
+ int ret = 0;
+
+ /* select register to write */
+ ret = i2c_smbus_write_byte(client, (TSL2X7X_CMD_REG | reg));
+ if (ret < 0) {
+ dev_err(&client->dev, "%s: failed to write register %x\n"
+ , __func__, reg);
+ return ret;
+ }
+
+ /* read the data */
+ ret = i2c_smbus_read_byte(client);
+ if (ret >= 0)
+ *val = (u8)ret;
+ else
+ dev_err(&client->dev, "%s: failed to read register %x\n"
+ , __func__, reg);
+
+ return ret;
+}
+
+/**
+ * tsl2x7x_get_lux() - Reads and calculates current lux value.
+ * @indio_dev: pointer to IIO device
+ *
+ * The raw ch0 and ch1 values of the ambient light sensed in the last
+ * integration cycle are read from the device.
+ * Time scale factor array values are adjusted based on the integration time.
+ * The raw values are multiplied by a scale factor, and device gain is obtained
+ * using gain index. Limit checks are done next, then the ratio of a multiple
+ * of ch1 value, to the ch0 value, is calculated. Array tsl2x7x_device_lux[]
+ * is then scanned to find the first ratio value that is just above the ratio
+ * we just calculated. The ch0 and ch1 multiplier constants in the array are
+ * then used along with the time scale factor array values, to calculate the
+ * lux.
+ */
+static int tsl2x7x_get_lux(struct iio_dev *indio_dev)
+{
+ u16 ch0, ch1; /* separated ch0/ch1 data from device */
+ u32 lux; /* raw lux calculated from device data */
+ u64 lux64;
+ u32 ratio;
+ u8 buf[4];
+ struct tsl2x7x_lux *p;
+ struct tsl2X7X_chip *chip = iio_priv(indio_dev);
+ int i, ret;
+ u32 ch0lux = 0;
+ u32 ch1lux = 0;
+
+ if (mutex_trylock(&chip->als_mutex) == 0)
+ return chip->als_cur_info.lux; /* busy, so return LAST VALUE */
+
+ if (chip->tsl2x7x_chip_status != TSL2X7X_CHIP_WORKING) {
+ /* device is not enabled */
+ dev_err(&chip->client->dev, "%s: device is not enabled\n",
+ __func__);
+ ret = -EBUSY ;
+ goto out_unlock;
+ }
+
+ ret = tsl2x7x_i2c_read(chip->client,
+ (TSL2X7X_CMD_REG | TSL2X7X_STATUS), &buf[0]);
+ if (ret < 0) {
+ dev_err(&chip->client->dev,
+ "%s: Failed to read STATUS Reg\n", __func__);
+ goto out_unlock;
+ }
+ /* is data new & valid */
+ if (!(buf[0] & TSL2X7X_STA_ADC_VALID)) {
+ dev_err(&chip->client->dev,
+ "%s: data not valid yet\n", __func__);
+ ret = chip->als_cur_info.lux; /* return LAST VALUE */
+ goto out_unlock;
+ }
+
+ for (i = 0; i < 4; i++) {
+ ret = tsl2x7x_i2c_read(chip->client,
+ (TSL2X7X_CMD_REG | (TSL2X7X_ALS_CHAN0LO + i)),
+ &buf[i]);
+ if (ret < 0) {
+ dev_err(&chip->client->dev,
+ "%s: failed to read. err=%x\n", __func__, ret);
+ goto out_unlock;
+ }
+ }
+
+ /* clear any existing interrupt status */
+ ret = i2c_smbus_write_byte(chip->client,
+ (TSL2X7X_CMD_REG |
+ TSL2X7X_CMD_SPL_FN |
+ TSL2X7X_CMD_ALS_INT_CLR));
+ if (ret < 0) {
+ dev_err(&chip->client->dev,
+ "%s: i2c_write_command failed - err = %d\n",
+ __func__, ret);
+ goto out_unlock; /* have no data, so return failure */
+ }
+
+ /* extract ALS/lux data */
+ ch0 = le16_to_cpup((const __le16 *)&buf[0]);
+ ch1 = le16_to_cpup((const __le16 *)&buf[2]);
+
+ chip->als_cur_info.als_ch0 = ch0;
+ chip->als_cur_info.als_ch1 = ch1;
+
+ if ((ch0 >= chip->als_saturation) || (ch1 >= chip->als_saturation)) {
+ lux = TSL2X7X_LUX_CALC_OVER_FLOW;
+ goto return_max;
+ }
+
+ if (ch0 == 0) {
+ /* have no data, so return LAST VALUE */
+ ret = chip->als_cur_info.lux;
+ goto out_unlock;
+ }
+ /* calculate ratio */
+ ratio = (ch1 << 15) / ch0;
+ /* convert to unscaled lux using the pointer to the table */
+ p = (struct tsl2x7x_lux *) chip->tsl2x7x_device_lux;
+ while (p->ratio != 0 && p->ratio < ratio)
+ p++;
+
+ if (p->ratio == 0) {
+ lux = 0;
+ } else {
+ ch0lux = DIV_ROUND_UP((ch0 * p->ch0),
+ tsl2X7X_als_gainadj[chip->tsl2x7x_settings.als_gain]);
+ ch1lux = DIV_ROUND_UP((ch1 * p->ch1),
+ tsl2X7X_als_gainadj[chip->tsl2x7x_settings.als_gain]);
+ lux = ch0lux - ch1lux;
+ }
+
+ /* note: lux is 31 bit max at this point */
+ if (ch1lux > ch0lux) {
+ dev_dbg(&chip->client->dev, "ch1lux > ch0lux-return last value\n");
+ ret = chip->als_cur_info.lux;
+ goto out_unlock;
+ }
+
+ /* adjust for active time scale */
+ if (chip->als_time_scale == 0)
+ lux = 0;
+ else
+ lux = (lux + (chip->als_time_scale >> 1)) /
+ chip->als_time_scale;
+
+ /* adjust for active gain scale
+ * The tsl2x7x_device_lux tables have a factor of 256 built-in.
+ * User-specified gain provides a multiplier.
+ * Apply user-specified gain before shifting right to retain precision.
+ * Use 64 bits to avoid overflow on multiplication.
+ * Then go back to 32 bits before division to avoid using div_u64().
+ */
+
+ lux64 = lux;
+ lux64 = lux64 * chip->tsl2x7x_settings.als_gain_trim;
+ lux64 >>= 8;
+ lux = lux64;
+ lux = (lux + 500) / 1000;
+
+ if (lux > TSL2X7X_LUX_CALC_OVER_FLOW) /* check for overflow */
+ lux = TSL2X7X_LUX_CALC_OVER_FLOW;
+
+ /* Update the structure with the latest lux. */
+return_max:
+ chip->als_cur_info.lux = lux;
+ ret = lux;
+
+out_unlock:
+ mutex_unlock(&chip->als_mutex);
+
+ return ret;
+}
+
+/**
+ * tsl2x7x_get_prox() - Reads proximity data registers and updates
+ * chip->prox_data.
+ *
+ * @indio_dev: pointer to IIO device
+ */
+static int tsl2x7x_get_prox(struct iio_dev *indio_dev)
+{
+ int i;
+ int ret;
+ u8 status;
+ u8 chdata[2];
+ struct tsl2X7X_chip *chip = iio_priv(indio_dev);
+
+ if (mutex_trylock(&chip->prox_mutex) == 0) {
+ dev_err(&chip->client->dev,
+ "%s: Can't get prox mutex\n", __func__);
+ return -EBUSY;
+ }
+
+ ret = tsl2x7x_i2c_read(chip->client,
+ (TSL2X7X_CMD_REG | TSL2X7X_STATUS), &status);
+ if (ret < 0) {
+ dev_err(&chip->client->dev,
+ "%s: i2c err=%d\n", __func__, ret);
+ goto prox_poll_err;
+ }
+
+ switch (chip->id) {
+ case tsl2571:
+ case tsl2671:
+ case tmd2671:
+ case tsl2771:
+ case tmd2771:
+ if (!(status & TSL2X7X_STA_ADC_VALID))
+ goto prox_poll_err;
+ break;
+ case tsl2572:
+ case tsl2672:
+ case tmd2672:
+ case tsl2772:
+ case tmd2772:
+ if (!(status & TSL2X7X_STA_PRX_VALID))
+ goto prox_poll_err;
+ break;
+ }
+
+ for (i = 0; i < 2; i++) {
+ ret = tsl2x7x_i2c_read(chip->client,
+ (TSL2X7X_CMD_REG |
+ (TSL2X7X_PRX_LO + i)), &chdata[i]);
+ if (ret < 0)
+ goto prox_poll_err;
+ }
+
+ chip->prox_data =
+ le16_to_cpup((const __le16 *)&chdata[0]);
+
+prox_poll_err:
+
+ mutex_unlock(&chip->prox_mutex);
+
+ return chip->prox_data;
+}
+
+/**
+ * tsl2x7x_defaults() - Populates the device nominal operating parameters
+ * with those provided by a 'platform' data struct or
+ * with prefined defaults.
+ *
+ * @chip: pointer to device structure.
+ */
+static void tsl2x7x_defaults(struct tsl2X7X_chip *chip)
+{
+ /* If Operational settings defined elsewhere.. */
+ if (chip->pdata && chip->pdata->platform_default_settings != 0)
+ memcpy(&(chip->tsl2x7x_settings),
+ chip->pdata->platform_default_settings,
+ sizeof(tsl2x7x_default_settings));
+ else
+ memcpy(&(chip->tsl2x7x_settings),
+ &tsl2x7x_default_settings,
+ sizeof(tsl2x7x_default_settings));
+
+ /* Load up the proper lux table. */
+ if (chip->pdata && chip->pdata->platform_lux_table[0].ratio != 0)
+ memcpy(chip->tsl2x7x_device_lux,
+ chip->pdata->platform_lux_table,
+ sizeof(chip->pdata->platform_lux_table));
+ else
+ memcpy(chip->tsl2x7x_device_lux,
+ (struct tsl2x7x_lux *)tsl2x7x_default_lux_table_group[chip->id],
+ MAX_DEFAULT_TABLE_BYTES);
+}
+
+/**
+ * tsl2x7x_als_calibrate() - Obtain single reading and calculate
+ * the als_gain_trim.
+ *
+ * @indio_dev: pointer to IIO device
+ */
+static int tsl2x7x_als_calibrate(struct iio_dev *indio_dev)
+{
+ struct tsl2X7X_chip *chip = iio_priv(indio_dev);
+ u8 reg_val;
+ int gain_trim_val;
+ int ret;
+ int lux_val;
+
+ ret = i2c_smbus_write_byte(chip->client,
+ (TSL2X7X_CMD_REG | TSL2X7X_CNTRL));
+ if (ret < 0) {
+ dev_err(&chip->client->dev,
+ "%s: failed to write CNTRL register, ret=%d\n",
+ __func__, ret);
+ return ret;
+ }
+
+ reg_val = i2c_smbus_read_byte(chip->client);
+ if ((reg_val & (TSL2X7X_CNTL_ADC_ENBL | TSL2X7X_CNTL_PWR_ON))
+ != (TSL2X7X_CNTL_ADC_ENBL | TSL2X7X_CNTL_PWR_ON)) {
+ dev_err(&chip->client->dev,
+ "%s: failed: ADC not enabled\n", __func__);
+ return -1;
+ }
+
+ ret = i2c_smbus_write_byte(chip->client,
+ (TSL2X7X_CMD_REG | TSL2X7X_CNTRL));
+ if (ret < 0) {
+ dev_err(&chip->client->dev,
+ "%s: failed to write ctrl reg: ret=%d\n",
+ __func__, ret);
+ return ret;
+ }
+
+ reg_val = i2c_smbus_read_byte(chip->client);
+ if ((reg_val & TSL2X7X_STA_ADC_VALID) != TSL2X7X_STA_ADC_VALID) {
+ dev_err(&chip->client->dev,
+ "%s: failed: STATUS - ADC not valid.\n", __func__);
+ return -ENODATA;
+ }
+
+ lux_val = tsl2x7x_get_lux(indio_dev);
+ if (lux_val < 0) {
+ dev_err(&chip->client->dev,
+ "%s: failed to get lux\n", __func__);
+ return lux_val;
+ }
+
+ gain_trim_val = (((chip->tsl2x7x_settings.als_cal_target)
+ * chip->tsl2x7x_settings.als_gain_trim) / lux_val);
+ if ((gain_trim_val < 250) || (gain_trim_val > 4000))
+ return -ERANGE;
+
+ chip->tsl2x7x_settings.als_gain_trim = gain_trim_val;
+ dev_info(&chip->client->dev,
+ "%s als_calibrate completed\n", chip->client->name);
+
+ return (int) gain_trim_val;
+}
+
+static int tsl2x7x_chip_on(struct iio_dev *indio_dev)
+{
+ int i;
+ int ret = 0;
+ u8 *dev_reg;
+ u8 utmp;
+ int als_count;
+ int als_time;
+ struct tsl2X7X_chip *chip = iio_priv(indio_dev);
+ u8 reg_val = 0;
+
+ if (chip->pdata && chip->pdata->power_on)
+ chip->pdata->power_on(indio_dev);
+
+ /* Non calculated parameters */
+ chip->tsl2x7x_config[TSL2X7X_PRX_TIME] =
+ chip->tsl2x7x_settings.prx_time;
+ chip->tsl2x7x_config[TSL2X7X_WAIT_TIME] =
+ chip->tsl2x7x_settings.wait_time;
+ chip->tsl2x7x_config[TSL2X7X_PRX_CONFIG] =
+ chip->tsl2x7x_settings.prox_config;
+
+ chip->tsl2x7x_config[TSL2X7X_ALS_MINTHRESHLO] =
+ (chip->tsl2x7x_settings.als_thresh_low) & 0xFF;
+ chip->tsl2x7x_config[TSL2X7X_ALS_MINTHRESHHI] =
+ (chip->tsl2x7x_settings.als_thresh_low >> 8) & 0xFF;
+ chip->tsl2x7x_config[TSL2X7X_ALS_MAXTHRESHLO] =
+ (chip->tsl2x7x_settings.als_thresh_high) & 0xFF;
+ chip->tsl2x7x_config[TSL2X7X_ALS_MAXTHRESHHI] =
+ (chip->tsl2x7x_settings.als_thresh_high >> 8) & 0xFF;
+ chip->tsl2x7x_config[TSL2X7X_PERSISTENCE] =
+ chip->tsl2x7x_settings.persistence;
+
+ chip->tsl2x7x_config[TSL2X7X_PRX_COUNT] =
+ chip->tsl2x7x_settings.prox_pulse_count;
+ chip->tsl2x7x_config[TSL2X7X_PRX_MINTHRESHLO] =
+ chip->tsl2x7x_settings.prox_thres_low;
+ chip->tsl2x7x_config[TSL2X7X_PRX_MAXTHRESHLO] =
+ chip->tsl2x7x_settings.prox_thres_high;
+
+ /* and make sure we're not already on */
+ if (chip->tsl2x7x_chip_status == TSL2X7X_CHIP_WORKING) {
+ /* if forcing a register update - turn off, then on */
+ dev_info(&chip->client->dev, "device is already enabled\n");
+ return -EINVAL;
+ }
+
+ /* determine als integration register */
+ als_count = (chip->tsl2x7x_settings.als_time * 100 + 135) / 270;
+ if (als_count == 0)
+ als_count = 1; /* ensure at least one cycle */
+
+ /* convert back to time (encompasses overrides) */
+ als_time = (als_count * 27 + 5) / 10;
+ chip->tsl2x7x_config[TSL2X7X_ALS_TIME] = 256 - als_count;
+
+ /* Set the gain based on tsl2x7x_settings struct */
+ chip->tsl2x7x_config[TSL2X7X_GAIN] =
+ (chip->tsl2x7x_settings.als_gain |
+ (TSL2X7X_mA100 | TSL2X7X_DIODE1)
+ | ((chip->tsl2x7x_settings.prox_gain) << 2));
+
+ /* set chip struct re scaling and saturation */
+ chip->als_saturation = als_count * 922; /* 90% of full scale */
+ chip->als_time_scale = (als_time + 25) / 50;
+
+ /* TSL2X7X Specific power-on / adc enable sequence
+ * Power on the device 1st. */
+ utmp = TSL2X7X_CNTL_PWR_ON;
+ ret = i2c_smbus_write_byte_data(chip->client,
+ TSL2X7X_CMD_REG | TSL2X7X_CNTRL, utmp);
+ if (ret < 0) {
+ dev_err(&chip->client->dev,
+ "%s: failed on CNTRL reg.\n", __func__);
+ return ret;
+ }
+
+ /* Use the following shadow copy for our delay before enabling ADC.
+ * Write all the registers. */
+ for (i = 0, dev_reg = chip->tsl2x7x_config;
+ i < TSL2X7X_MAX_CONFIG_REG; i++) {
+ ret = i2c_smbus_write_byte_data(chip->client,
+ TSL2X7X_CMD_REG + i, *dev_reg++);
+ if (ret < 0) {
+ dev_err(&chip->client->dev,
+ "%s: failed on write to reg %d.\n", __func__, i);
+ return ret;
+ }
+ }
+
+ mdelay(3); /* Power-on settling time */
+
+ /* NOW enable the ADC
+ * initialize the desired mode of operation */
+ utmp = TSL2X7X_CNTL_PWR_ON |
+ TSL2X7X_CNTL_ADC_ENBL |
+ TSL2X7X_CNTL_PROX_DET_ENBL;
+ ret = i2c_smbus_write_byte_data(chip->client,
+ TSL2X7X_CMD_REG | TSL2X7X_CNTRL, utmp);
+ if (ret < 0) {
+ dev_err(&chip->client->dev,
+ "%s: failed on 2nd CTRL reg.\n", __func__);
+ return ret;
+ }
+
+ chip->tsl2x7x_chip_status = TSL2X7X_CHIP_WORKING;
+
+ if (chip->tsl2x7x_settings.interrupts_en != 0) {
+ dev_info(&chip->client->dev, "Setting Up Interrupt(s)\n");
+
+ reg_val = TSL2X7X_CNTL_PWR_ON | TSL2X7X_CNTL_ADC_ENBL;
+ if ((chip->tsl2x7x_settings.interrupts_en == 0x20) ||
+ (chip->tsl2x7x_settings.interrupts_en == 0x30))
+ reg_val |= TSL2X7X_CNTL_PROX_DET_ENBL;
+
+ reg_val |= chip->tsl2x7x_settings.interrupts_en;
+ ret = i2c_smbus_write_byte_data(chip->client,
+ (TSL2X7X_CMD_REG | TSL2X7X_CNTRL), reg_val);
+ if (ret < 0)
+ dev_err(&chip->client->dev,
+ "%s: failed in tsl2x7x_IOCTL_INT_SET.\n",
+ __func__);
+
+ /* Clear out any initial interrupts */
+ ret = i2c_smbus_write_byte(chip->client,
+ TSL2X7X_CMD_REG | TSL2X7X_CMD_SPL_FN |
+ TSL2X7X_CMD_PROXALS_INT_CLR);
+ if (ret < 0) {
+ dev_err(&chip->client->dev,
+ "%s: Failed to clear Int status\n",
+ __func__);
+ return ret;
+ }
+ }
+
+ return ret;
+}
+
+static int tsl2x7x_chip_off(struct iio_dev *indio_dev)
+{
+ int ret;
+ struct tsl2X7X_chip *chip = iio_priv(indio_dev);
+
+ /* turn device off */
+ chip->tsl2x7x_chip_status = TSL2X7X_CHIP_SUSPENDED;
+
+ ret = i2c_smbus_write_byte_data(chip->client,
+ TSL2X7X_CMD_REG | TSL2X7X_CNTRL, 0x00);
+
+ if (chip->pdata && chip->pdata->power_off)
+ chip->pdata->power_off(chip->client);
+
+ return ret;
+}
+
+/**
+ * tsl2x7x_invoke_change
+ * @indio_dev: pointer to IIO device
+ *
+ * Obtain and lock both ALS and PROX resources,
+ * determine and save device state (On/Off),
+ * cycle device to implement updated parameter,
+ * put device back into proper state, and unlock
+ * resource.
+ */
+static
+int tsl2x7x_invoke_change(struct iio_dev *indio_dev)
+{
+ struct tsl2X7X_chip *chip = iio_priv(indio_dev);
+ int device_status = chip->tsl2x7x_chip_status;
+
+ mutex_lock(&chip->als_mutex);
+ mutex_lock(&chip->prox_mutex);
+
+ if (device_status == TSL2X7X_CHIP_WORKING)
+ tsl2x7x_chip_off(indio_dev);
+
+ tsl2x7x_chip_on(indio_dev);
+
+ if (device_status != TSL2X7X_CHIP_WORKING)
+ tsl2x7x_chip_off(indio_dev);
+
+ mutex_unlock(&chip->prox_mutex);
+ mutex_unlock(&chip->als_mutex);
+
+ return 0;
+}
+
+static
+void tsl2x7x_prox_calculate(int *data, int length,
+ struct tsl2x7x_prox_stat *statP)
+{
+ int i;
+ int sample_sum;
+ int tmp;
+
+ if (length == 0)
+ length = 1;
+
+ sample_sum = 0;
+ statP->min = INT_MAX;
+ statP->max = INT_MIN;
+ for (i = 0; i < length; i++) {
+ sample_sum += data[i];
+ statP->min = min(statP->min, data[i]);
+ statP->max = max(statP->max, data[i]);
+ }
+
+ statP->mean = sample_sum / length;
+ sample_sum = 0;
+ for (i = 0; i < length; i++) {
+ tmp = data[i] - statP->mean;
+ sample_sum += tmp * tmp;
+ }
+ statP->stddev = int_sqrt((long)sample_sum)/length;
+}
+
+/**
+ * tsl2x7x_prox_cal() - Calculates std. and sets thresholds.
+ * @indio_dev: pointer to IIO device
+ *
+ * Calculates a standard deviation based on the samples,
+ * and sets the threshold accordingly.
+ */
+static void tsl2x7x_prox_cal(struct iio_dev *indio_dev)
+{
+ int prox_history[MAX_SAMPLES_CAL + 1];
+ int i;
+ struct tsl2x7x_prox_stat prox_stat_data[2];
+ struct tsl2x7x_prox_stat *calP;
+ struct tsl2X7X_chip *chip = iio_priv(indio_dev);
+ u8 tmp_irq_settings;
+ u8 current_state = chip->tsl2x7x_chip_status;
+
+ if (chip->tsl2x7x_settings.prox_max_samples_cal > MAX_SAMPLES_CAL) {
+ dev_err(&chip->client->dev,
+ "%s: max prox samples cal is too big: %d\n",
+ __func__, chip->tsl2x7x_settings.prox_max_samples_cal);
+ chip->tsl2x7x_settings.prox_max_samples_cal = MAX_SAMPLES_CAL;
+ }
+
+ /* have to stop to change settings */
+ tsl2x7x_chip_off(indio_dev);
+
+ /* Enable proximity detection save just in case prox not wanted yet*/
+ tmp_irq_settings = chip->tsl2x7x_settings.interrupts_en;
+ chip->tsl2x7x_settings.interrupts_en |= TSL2X7X_CNTL_PROX_INT_ENBL;
+
+ /*turn on device if not already on*/
+ tsl2x7x_chip_on(indio_dev);
+
+ /*gather the samples*/
+ for (i = 0; i < chip->tsl2x7x_settings.prox_max_samples_cal; i++) {
+ mdelay(15);
+ tsl2x7x_get_prox(indio_dev);
+ prox_history[i] = chip->prox_data;
+ dev_info(&chip->client->dev, "2 i=%d prox data= %d\n",
+ i, chip->prox_data);
+ }
+
+ tsl2x7x_chip_off(indio_dev);
+ calP = &prox_stat_data[PROX_STAT_CAL];
+ tsl2x7x_prox_calculate(prox_history,
+ chip->tsl2x7x_settings.prox_max_samples_cal, calP);
+ chip->tsl2x7x_settings.prox_thres_high = (calP->max << 1) - calP->mean;
+
+ dev_info(&chip->client->dev, " cal min=%d mean=%d max=%d\n",
+ calP->min, calP->mean, calP->max);
+ dev_info(&chip->client->dev,
+ "%s proximity threshold set to %d\n",
+ chip->client->name, chip->tsl2x7x_settings.prox_thres_high);
+
+ /* back to the way they were */
+ chip->tsl2x7x_settings.interrupts_en = tmp_irq_settings;
+ if (current_state == TSL2X7X_CHIP_WORKING)
+ tsl2x7x_chip_on(indio_dev);
+}
+
+static ssize_t tsl2x7x_power_state_show(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+ struct tsl2X7X_chip *chip = iio_priv(dev_to_iio_dev(dev));
+
+ return snprintf(buf, PAGE_SIZE, "%d\n", chip->tsl2x7x_chip_status);
+}
+
+static ssize_t tsl2x7x_power_state_store(struct device *dev,
+ struct device_attribute *attr, const char *buf, size_t len)
+{
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
+ bool value;
+
+ if (strtobool(buf, &value))
+ return -EINVAL;
+
+ if (value)
+ tsl2x7x_chip_on(indio_dev);
+ else
+ tsl2x7x_chip_off(indio_dev);
+
+ return len;
+}
+
+static ssize_t tsl2x7x_gain_available_show(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+ struct tsl2X7X_chip *chip = iio_priv(dev_to_iio_dev(dev));
+
+ switch (chip->id) {
+ case tsl2571:
+ case tsl2671:
+ case tmd2671:
+ case tsl2771:
+ case tmd2771:
+ return snprintf(buf, PAGE_SIZE, "%s\n", "1 8 16 128");
+ break;
+ }
+
+ return snprintf(buf, PAGE_SIZE, "%s\n", "1 8 16 120");
+}
+
+static ssize_t tsl2x7x_prox_gain_available_show(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+ return snprintf(buf, PAGE_SIZE, "%s\n", "1 2 4 8");
+}
+
+static ssize_t tsl2x7x_als_time_show(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+ struct tsl2X7X_chip *chip = iio_priv(dev_to_iio_dev(dev));
+ int y, z;
+
+ y = (TSL2X7X_MAX_TIMER_CNT - (u8)chip->tsl2x7x_settings.als_time) + 1;
+ z = y * TSL2X7X_MIN_ITIME;
+ y /= 1000;
+ z %= 1000;
+
+ return snprintf(buf, PAGE_SIZE, "%d.%03d\n", y, z);
+}
+
+static ssize_t tsl2x7x_als_time_store(struct device *dev,
+ struct device_attribute *attr, const char *buf, size_t len)
+{
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
+ struct tsl2X7X_chip *chip = iio_priv(indio_dev);
+ struct tsl2x7x_parse_result result;
+
+ result.integer = 0;
+ result.fract = 0;
+
+ tsl2x7x_parse_buffer(buf, &result);
+
+ result.fract /= 1000;
+ result.fract /= 3;
+ chip->tsl2x7x_settings.als_time =
+ (TSL2X7X_MAX_TIMER_CNT - (u8)result.fract);
+
+ dev_info(&chip->client->dev, "%s: als time = %d",
+ __func__, chip->tsl2x7x_settings.als_time);
+
+ tsl2x7x_invoke_change(indio_dev);
+
+ return IIO_VAL_INT_PLUS_MICRO;
+}
+
+static IIO_CONST_ATTR(in_illuminance0_integration_time_available,
+ ".00272 - .696");
+
+static ssize_t tsl2x7x_als_cal_target_show(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+ struct tsl2X7X_chip *chip = iio_priv(dev_to_iio_dev(dev));
+
+ return snprintf(buf, PAGE_SIZE, "%d\n",
+ chip->tsl2x7x_settings.als_cal_target);
+}
+
+static ssize_t tsl2x7x_als_cal_target_store(struct device *dev,
+ struct device_attribute *attr, const char *buf, size_t len)
+{
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
+ struct tsl2X7X_chip *chip = iio_priv(indio_dev);
+ unsigned long value;
+
+ if (kstrtoul(buf, 0, &value))
+ return -EINVAL;
+
+ if (value)
+ chip->tsl2x7x_settings.als_cal_target = value;
+
+ tsl2x7x_invoke_change(indio_dev);
+
+ return len;
+}
+
+/* persistence settings */
+static ssize_t tsl2x7x_als_persistence_show(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+ struct tsl2X7X_chip *chip = iio_priv(dev_to_iio_dev(dev));
+ int y, z, filter_delay;
+
+ /* Determine integration time */
+ y = (TSL2X7X_MAX_TIMER_CNT - (u8)chip->tsl2x7x_settings.als_time) + 1;
+ z = y * TSL2X7X_MIN_ITIME;
+ filter_delay = z * (chip->tsl2x7x_settings.persistence & 0x0F);
+ y = (filter_delay / 1000);
+ z = (filter_delay % 1000);
+
+ return snprintf(buf, PAGE_SIZE, "%d.%03d\n", y, z);
+}
+
+static ssize_t tsl2x7x_als_persistence_store(struct device *dev,
+ struct device_attribute *attr, const char *buf, size_t len)
+{
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
+ struct tsl2X7X_chip *chip = iio_priv(indio_dev);
+ struct tsl2x7x_parse_result result;
+ int y, z, filter_delay;
+
+ result.integer = 0;
+ result.fract = 0;
+ tsl2x7x_parse_buffer(buf, &result);
+
+ result.fract /= 1000;
+ y = (TSL2X7X_MAX_TIMER_CNT - (u8)chip->tsl2x7x_settings.als_time) + 1;
+ z = y * TSL2X7X_MIN_ITIME;
+
+ filter_delay =
+ DIV_ROUND_UP(((result.integer * 1000) + result.fract), z);
+
+ chip->tsl2x7x_settings.persistence &= 0xF0;
+ chip->tsl2x7x_settings.persistence |= (filter_delay & 0x0F);
+
+ dev_info(&chip->client->dev, "%s: als persistence = %d",
+ __func__, filter_delay);
+
+ tsl2x7x_invoke_change(indio_dev);
+
+ return IIO_VAL_INT_PLUS_MICRO;
+}
+
+static ssize_t tsl2x7x_prox_persistence_show(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+ struct tsl2X7X_chip *chip = iio_priv(dev_to_iio_dev(dev));
+ int y, z, filter_delay;
+
+ /* Determine integration time */
+ y = (TSL2X7X_MAX_TIMER_CNT - (u8)chip->tsl2x7x_settings.prx_time) + 1;
+ z = y * TSL2X7X_MIN_ITIME;
+ filter_delay = z * ((chip->tsl2x7x_settings.persistence & 0xF0) >> 4);
+ y = (filter_delay / 1000);
+ z = (filter_delay % 1000);
+
+ return snprintf(buf, PAGE_SIZE, "%d.%03d\n", y, z);
+}
+
+static ssize_t tsl2x7x_prox_persistence_store(struct device *dev,
+ struct device_attribute *attr, const char *buf, size_t len)
+{
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
+ struct tsl2X7X_chip *chip = iio_priv(indio_dev);
+ struct tsl2x7x_parse_result result;
+ int y, z, filter_delay;
+
+ result.integer = 0;
+ result.fract = 0;
+ tsl2x7x_parse_buffer(buf, &result);
+
+ result.fract /= 1000;
+ y = (TSL2X7X_MAX_TIMER_CNT - (u8)chip->tsl2x7x_settings.prx_time) + 1;
+ z = y * TSL2X7X_MIN_ITIME;
+
+ filter_delay =
+ DIV_ROUND_UP(((result.integer * 1000) + result.fract), z);
+
+ chip->tsl2x7x_settings.persistence &= 0x0F;
+ chip->tsl2x7x_settings.persistence |= ((filter_delay << 4) & 0xF0);
+
+ dev_info(&chip->client->dev, "%s: prox persistence = %d",
+ __func__, filter_delay);
+
+ tsl2x7x_invoke_change(indio_dev);
+
+ return IIO_VAL_INT_PLUS_MICRO;
+}
+
+static ssize_t tsl2x7x_do_calibrate(struct device *dev,
+ struct device_attribute *attr, const char *buf, size_t len)
+{
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
+ bool value;
+
+ if (strtobool(buf, &value))
+ return -EINVAL;
+
+ if (value)
+ tsl2x7x_als_calibrate(indio_dev);
+
+ tsl2x7x_invoke_change(indio_dev);
+
+ return len;
+}
+
+static ssize_t tsl2x7x_luxtable_show(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+ struct tsl2X7X_chip *chip = iio_priv(dev_to_iio_dev(dev));
+ int i = 0;
+ int offset = 0;
+
+ while (i < (TSL2X7X_MAX_LUX_TABLE_SIZE * 3)) {
+ offset += snprintf(buf + offset, PAGE_SIZE, "%d,%d,%d,",
+ chip->tsl2x7x_device_lux[i].ratio,
+ chip->tsl2x7x_device_lux[i].ch0,
+ chip->tsl2x7x_device_lux[i].ch1);
+ if (chip->tsl2x7x_device_lux[i].ratio == 0) {
+ /* We just printed the first "0" entry.
+ * Now get rid of the extra "," and break. */
+ offset--;
+ break;
+ }
+ i++;
+ }
+
+ offset += snprintf(buf + offset, PAGE_SIZE, "\n");
+ return offset;
+}
+
+static ssize_t tsl2x7x_luxtable_store(struct device *dev,
+ struct device_attribute *attr, const char *buf, size_t len)
+{
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
+ struct tsl2X7X_chip *chip = iio_priv(indio_dev);
+ int value[ARRAY_SIZE(chip->tsl2x7x_device_lux)*3 + 1];
+ int n;
+
+ get_options(buf, ARRAY_SIZE(value), value);
+
+ /* We now have an array of ints starting at value[1], and
+ * enumerated by value[0].
+ * We expect each group of three ints is one table entry,
+ * and the last table entry is all 0.
+ */
+ n = value[0];
+ if ((n % 3) || n < 6 ||
+ n > ((ARRAY_SIZE(chip->tsl2x7x_device_lux) - 1) * 3)) {
+ dev_info(dev, "LUX TABLE INPUT ERROR 1 Value[0]=%d\n", n);
+ return -EINVAL;
+ }
+
+ if ((value[(n - 2)] | value[(n - 1)] | value[n]) != 0) {
+ dev_info(dev, "LUX TABLE INPUT ERROR 2 Value[0]=%d\n", n);
+ return -EINVAL;
+ }
+
+ if (chip->tsl2x7x_chip_status == TSL2X7X_CHIP_WORKING)
+ tsl2x7x_chip_off(indio_dev);
+
+ /* Zero out the table */
+ memset(chip->tsl2x7x_device_lux, 0, sizeof(chip->tsl2x7x_device_lux));
+ memcpy(chip->tsl2x7x_device_lux, &value[1], (value[0] * 4));
+
+ tsl2x7x_invoke_change(indio_dev);
+
+ return len;
+}
+
+static ssize_t tsl2x7x_do_prox_calibrate(struct device *dev,
+ struct device_attribute *attr, const char *buf, size_t len)
+{
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
+ bool value;
+
+ if (strtobool(buf, &value))
+ return -EINVAL;
+
+ if (value)
+ tsl2x7x_prox_cal(indio_dev);
+
+ tsl2x7x_invoke_change(indio_dev);
+
+ return len;
+}
+
+static int tsl2x7x_read_interrupt_config(struct iio_dev *indio_dev,
+ u64 event_code)
+{
+ struct tsl2X7X_chip *chip = iio_priv(indio_dev);
+ int ret;
+
+ if (IIO_EVENT_CODE_EXTRACT_CHAN_TYPE(event_code) == IIO_INTENSITY)
+ ret = !!(chip->tsl2x7x_settings.interrupts_en & 0x10);
+ else
+ ret = !!(chip->tsl2x7x_settings.interrupts_en & 0x20);
+
+ return ret;
+}
+
+static int tsl2x7x_write_interrupt_config(struct iio_dev *indio_dev,
+ u64 event_code,
+ int val)
+{
+ struct tsl2X7X_chip *chip = iio_priv(indio_dev);
+
+ if (IIO_EVENT_CODE_EXTRACT_CHAN_TYPE(event_code) == IIO_INTENSITY) {
+ if (val)
+ chip->tsl2x7x_settings.interrupts_en |= 0x10;
+ else
+ chip->tsl2x7x_settings.interrupts_en &= 0x20;
+ } else {
+ if (val)
+ chip->tsl2x7x_settings.interrupts_en |= 0x20;
+ else
+ chip->tsl2x7x_settings.interrupts_en &= 0x10;
+ }
+
+ tsl2x7x_invoke_change(indio_dev);
+
+ return 0;
+}
+
+static int tsl2x7x_write_thresh(struct iio_dev *indio_dev,
+ u64 event_code,
+ int val)
+{
+ struct tsl2X7X_chip *chip = iio_priv(indio_dev);
+
+ if (IIO_EVENT_CODE_EXTRACT_CHAN_TYPE(event_code) == IIO_INTENSITY) {
+ switch (IIO_EVENT_CODE_EXTRACT_DIR(event_code)) {
+ case IIO_EV_DIR_RISING:
+ chip->tsl2x7x_settings.als_thresh_high = val;
+ break;
+ case IIO_EV_DIR_FALLING:
+ chip->tsl2x7x_settings.als_thresh_low = val;
+ break;
+ default:
+ return -EINVAL;
+ }
+ } else {
+ switch (IIO_EVENT_CODE_EXTRACT_DIR(event_code)) {
+ case IIO_EV_DIR_RISING:
+ chip->tsl2x7x_settings.prox_thres_high = val;
+ break;
+ case IIO_EV_DIR_FALLING:
+ chip->tsl2x7x_settings.prox_thres_low = val;
+ break;
+ default:
+ return -EINVAL;
+ }
+ }
+
+ tsl2x7x_invoke_change(indio_dev);
+
+ return 0;
+}
+
+static int tsl2x7x_read_thresh(struct iio_dev *indio_dev,
+ u64 event_code,
+ int *val)
+{
+ struct tsl2X7X_chip *chip = iio_priv(indio_dev);
+
+ if (IIO_EVENT_CODE_EXTRACT_CHAN_TYPE(event_code) == IIO_INTENSITY) {
+ switch (IIO_EVENT_CODE_EXTRACT_DIR(event_code)) {
+ case IIO_EV_DIR_RISING:
+ *val = chip->tsl2x7x_settings.als_thresh_high;
+ break;
+ case IIO_EV_DIR_FALLING:
+ *val = chip->tsl2x7x_settings.als_thresh_low;
+ break;
+ default:
+ return -EINVAL;
+ }
+ } else {
+ switch (IIO_EVENT_CODE_EXTRACT_DIR(event_code)) {
+ case IIO_EV_DIR_RISING:
+ *val = chip->tsl2x7x_settings.prox_thres_high;
+ break;
+ case IIO_EV_DIR_FALLING:
+ *val = chip->tsl2x7x_settings.prox_thres_low;
+ break;
+ default:
+ return -EINVAL;
+ }
+ }
+
+ return 0;
+}
+
+static int tsl2x7x_read_raw(struct iio_dev *indio_dev,
+ struct iio_chan_spec const *chan,
+ int *val,
+ int *val2,
+ long mask)
+{
+ int ret = -EINVAL;
+ struct tsl2X7X_chip *chip = iio_priv(indio_dev);
+
+ switch (mask) {
+ case IIO_CHAN_INFO_PROCESSED:
+ switch (chan->type) {
+ case IIO_LIGHT:
+ tsl2x7x_get_lux(indio_dev);
+ *val = chip->als_cur_info.lux;
+ ret = IIO_VAL_INT;
+ break;
+ default:
+ return -EINVAL;
+ break;
+ }
+ break;
+ case IIO_CHAN_INFO_RAW:
+ switch (chan->type) {
+ case IIO_INTENSITY:
+ tsl2x7x_get_lux(indio_dev);
+ if (chan->channel == 0)
+ *val = chip->als_cur_info.als_ch0;
+ else
+ *val = chip->als_cur_info.als_ch1;
+ ret = IIO_VAL_INT;
+ break;
+ case IIO_PROXIMITY:
+ tsl2x7x_get_prox(indio_dev);
+ *val = chip->prox_data;
+ ret = IIO_VAL_INT;
+ break;
+ default:
+ return -EINVAL;
+ break;
+ }
+ break;
+ case IIO_CHAN_INFO_CALIBSCALE:
+ if (chan->type == IIO_LIGHT)
+ *val =
+ tsl2X7X_als_gainadj[chip->tsl2x7x_settings.als_gain];
+ else
+ *val =
+ tsl2X7X_prx_gainadj[chip->tsl2x7x_settings.prox_gain];
+ ret = IIO_VAL_INT;
+ break;
+ case IIO_CHAN_INFO_CALIBBIAS:
+ *val = chip->tsl2x7x_settings.als_gain_trim;
+ ret = IIO_VAL_INT;
+ break;
+
+ default:
+ ret = -EINVAL;
+ }
+
+ return ret;
+}
+
+static int tsl2x7x_write_raw(struct iio_dev *indio_dev,
+ struct iio_chan_spec const *chan,
+ int val,
+ int val2,
+ long mask)
+{
+ struct tsl2X7X_chip *chip = iio_priv(indio_dev);
+
+ switch (mask) {
+ case IIO_CHAN_INFO_CALIBSCALE:
+ if (chan->type == IIO_INTENSITY) {
+ switch (val) {
+ case 1:
+ chip->tsl2x7x_settings.als_gain = 0;
+ break;
+ case 8:
+ chip->tsl2x7x_settings.als_gain = 1;
+ break;
+ case 16:
+ chip->tsl2x7x_settings.als_gain = 2;
+ break;
+ case 120:
+ switch (chip->id) {
+ case tsl2572:
+ case tsl2672:
+ case tmd2672:
+ case tsl2772:
+ case tmd2772:
+ return -EINVAL;
+ break;
+ }
+ chip->tsl2x7x_settings.als_gain = 3;
+ break;
+ case 128:
+ switch (chip->id) {
+ case tsl2571:
+ case tsl2671:
+ case tmd2671:
+ case tsl2771:
+ case tmd2771:
+ return -EINVAL;
+ break;
+ }
+ chip->tsl2x7x_settings.als_gain = 3;
+ break;
+ default:
+ return -EINVAL;
+ }
+ } else {
+ switch (val) {
+ case 1:
+ chip->tsl2x7x_settings.prox_gain = 0;
+ break;
+ case 2:
+ chip->tsl2x7x_settings.prox_gain = 1;
+ break;
+ case 4:
+ chip->tsl2x7x_settings.prox_gain = 2;
+ break;
+ case 8:
+ chip->tsl2x7x_settings.prox_gain = 3;
+ break;
+ default:
+ return -EINVAL;
+ }
+ }
+ break;
+ case IIO_CHAN_INFO_CALIBBIAS:
+ chip->tsl2x7x_settings.als_gain_trim = val;
+ break;
+
+ default:
+ return -EINVAL;
+ }
+
+ tsl2x7x_invoke_change(indio_dev);
+
+ return 0;
+}
+
+static DEVICE_ATTR(power_state, S_IRUGO | S_IWUSR,
+ tsl2x7x_power_state_show, tsl2x7x_power_state_store);
+
+static DEVICE_ATTR(in_proximity0_calibscale_available, S_IRUGO,
+ tsl2x7x_prox_gain_available_show, NULL);
+
+static DEVICE_ATTR(in_illuminance0_calibscale_available, S_IRUGO,
+ tsl2x7x_gain_available_show, NULL);
+
+static DEVICE_ATTR(in_illuminance0_integration_time, S_IRUGO | S_IWUSR,
+ tsl2x7x_als_time_show, tsl2x7x_als_time_store);
+
+static DEVICE_ATTR(in_illuminance0_target_input, S_IRUGO | S_IWUSR,
+ tsl2x7x_als_cal_target_show, tsl2x7x_als_cal_target_store);
+
+static DEVICE_ATTR(in_illuminance0_calibrate, S_IWUSR, NULL,
+ tsl2x7x_do_calibrate);
+
+static DEVICE_ATTR(in_proximity0_calibrate, S_IWUSR, NULL,
+ tsl2x7x_do_prox_calibrate);
+
+static DEVICE_ATTR(in_illuminance0_lux_table, S_IRUGO | S_IWUSR,
+ tsl2x7x_luxtable_show, tsl2x7x_luxtable_store);
+
+static DEVICE_ATTR(in_intensity0_thresh_period, S_IRUGO | S_IWUSR,
+ tsl2x7x_als_persistence_show, tsl2x7x_als_persistence_store);
+
+static DEVICE_ATTR(in_proximity0_thresh_period, S_IRUGO | S_IWUSR,
+ tsl2x7x_prox_persistence_show, tsl2x7x_prox_persistence_store);
+
+/* Use the default register values to identify the Taos device */
+static int tsl2x7x_device_id(unsigned char *id, int target)
+{
+ switch (target) {
+ case tsl2571:
+ case tsl2671:
+ case tsl2771:
+ return ((*id & 0xf0) == TRITON_ID);
+ break;
+ case tmd2671:
+ case tmd2771:
+ return ((*id & 0xf0) == HALIBUT_ID);
+ break;
+ case tsl2572:
+ case tsl2672:
+ case tmd2672:
+ case tsl2772:
+ case tmd2772:
+ return ((*id & 0xf0) == SWORDFISH_ID);
+ break;
+ }
+
+ return -EINVAL;
+}
+
+static irqreturn_t tsl2x7x_event_handler(int irq, void *private)
+{
+ struct iio_dev *indio_dev = private;
+ struct tsl2X7X_chip *chip = iio_priv(indio_dev);
+ s64 timestamp = iio_get_time_ns();
+ int ret;
+ u8 value;
+
+ value = i2c_smbus_read_byte_data(chip->client,
+ TSL2X7X_CMD_REG | TSL2X7X_STATUS);
+
+ /* What type of interrupt do we need to process */
+ if (value & TSL2X7X_STA_PRX_INTR) {
+ tsl2x7x_get_prox(indio_dev); /* freshen data for ABI */
+ iio_push_event(indio_dev,
+ IIO_UNMOD_EVENT_CODE(IIO_PROXIMITY,
+ 0,
+ IIO_EV_TYPE_THRESH,
+ IIO_EV_DIR_EITHER),
+ timestamp);
+ }
+
+ if (value & TSL2X7X_STA_ALS_INTR) {
+ tsl2x7x_get_lux(indio_dev); /* freshen data for ABI */
+ iio_push_event(indio_dev,
+ IIO_UNMOD_EVENT_CODE(IIO_LIGHT,
+ 0,
+ IIO_EV_TYPE_THRESH,
+ IIO_EV_DIR_EITHER),
+ timestamp);
+ }
+ /* Clear interrupt now that we have handled it. */
+ ret = i2c_smbus_write_byte(chip->client,
+ TSL2X7X_CMD_REG | TSL2X7X_CMD_SPL_FN |
+ TSL2X7X_CMD_PROXALS_INT_CLR);
+ if (ret < 0)
+ dev_err(&chip->client->dev,
+ "%s: Failed to clear irq from event handler. err = %d\n",
+ __func__, ret);
+
+ return IRQ_HANDLED;
+}
+
+static struct attribute *tsl2x7x_ALS_device_attrs[] = {
+ &dev_attr_power_state.attr,
+ &dev_attr_in_illuminance0_calibscale_available.attr,
+ &dev_attr_in_illuminance0_integration_time.attr,
+ &iio_const_attr_in_illuminance0_integration_time_available\
+ .dev_attr.attr,
+ &dev_attr_in_illuminance0_target_input.attr,
+ &dev_attr_in_illuminance0_calibrate.attr,
+ &dev_attr_in_illuminance0_lux_table.attr,
+ NULL
+};
+
+static struct attribute *tsl2x7x_PRX_device_attrs[] = {
+ &dev_attr_power_state.attr,
+ &dev_attr_in_proximity0_calibrate.attr,
+ NULL
+};
+
+static struct attribute *tsl2x7x_ALSPRX_device_attrs[] = {
+ &dev_attr_power_state.attr,
+ &dev_attr_in_illuminance0_calibscale_available.attr,
+ &dev_attr_in_illuminance0_integration_time.attr,
+ &iio_const_attr_in_illuminance0_integration_time_available\
+ .dev_attr.attr,
+ &dev_attr_in_illuminance0_target_input.attr,
+ &dev_attr_in_illuminance0_calibrate.attr,
+ &dev_attr_in_illuminance0_lux_table.attr,
+ &dev_attr_in_proximity0_calibrate.attr,
+ NULL
+};
+
+static struct attribute *tsl2x7x_PRX2_device_attrs[] = {
+ &dev_attr_power_state.attr,
+ &dev_attr_in_proximity0_calibrate.attr,
+ &dev_attr_in_proximity0_calibscale_available.attr,
+ NULL
+};
+
+static struct attribute *tsl2x7x_ALSPRX2_device_attrs[] = {
+ &dev_attr_power_state.attr,
+ &dev_attr_in_illuminance0_calibscale_available.attr,
+ &dev_attr_in_illuminance0_integration_time.attr,
+ &iio_const_attr_in_illuminance0_integration_time_available\
+ .dev_attr.attr,
+ &dev_attr_in_illuminance0_target_input.attr,
+ &dev_attr_in_illuminance0_calibrate.attr,
+ &dev_attr_in_illuminance0_lux_table.attr,
+ &dev_attr_in_proximity0_calibrate.attr,
+ &dev_attr_in_proximity0_calibscale_available.attr,
+ NULL
+};
+
+static struct attribute *tsl2X7X_ALS_event_attrs[] = {
+ &dev_attr_in_intensity0_thresh_period.attr,
+ NULL,
+};
+static struct attribute *tsl2X7X_PRX_event_attrs[] = {
+ &dev_attr_in_proximity0_thresh_period.attr,
+ NULL,
+};
+
+static struct attribute *tsl2X7X_ALSPRX_event_attrs[] = {
+ &dev_attr_in_intensity0_thresh_period.attr,
+ &dev_attr_in_proximity0_thresh_period.attr,
+ NULL,
+};
+
+static const struct attribute_group tsl2X7X_device_attr_group_tbl[] = {
+ [ALS] = {
+ .attrs = tsl2x7x_ALS_device_attrs,
+ },
+ [PRX] = {
+ .attrs = tsl2x7x_PRX_device_attrs,
+ },
+ [ALSPRX] = {
+ .attrs = tsl2x7x_ALSPRX_device_attrs,
+ },
+ [PRX2] = {
+ .attrs = tsl2x7x_PRX2_device_attrs,
+ },
+ [ALSPRX2] = {
+ .attrs = tsl2x7x_ALSPRX2_device_attrs,
+ },
+};
+
+static struct attribute_group tsl2X7X_event_attr_group_tbl[] = {
+ [ALS] = {
+ .attrs = tsl2X7X_ALS_event_attrs,
+ .name = "events",
+ },
+ [PRX] = {
+ .attrs = tsl2X7X_PRX_event_attrs,
+ .name = "events",
+ },
+ [ALSPRX] = {
+ .attrs = tsl2X7X_ALSPRX_event_attrs,
+ .name = "events",
+ },
+};
+
+static const struct iio_info tsl2X7X_device_info[] = {
+ [ALS] = {
+ .attrs = &tsl2X7X_device_attr_group_tbl[ALS],
+ .event_attrs = &tsl2X7X_event_attr_group_tbl[ALS],
+ .driver_module = THIS_MODULE,
+ .read_raw = &tsl2x7x_read_raw,
+ .write_raw = &tsl2x7x_write_raw,
+ .read_event_value = &tsl2x7x_read_thresh,
+ .write_event_value = &tsl2x7x_write_thresh,
+ .read_event_config = &tsl2x7x_read_interrupt_config,
+ .write_event_config = &tsl2x7x_write_interrupt_config,
+ },
+ [PRX] = {
+ .attrs = &tsl2X7X_device_attr_group_tbl[PRX],
+ .event_attrs = &tsl2X7X_event_attr_group_tbl[PRX],
+ .driver_module = THIS_MODULE,
+ .read_raw = &tsl2x7x_read_raw,
+ .write_raw = &tsl2x7x_write_raw,
+ .read_event_value = &tsl2x7x_read_thresh,
+ .write_event_value = &tsl2x7x_write_thresh,
+ .read_event_config = &tsl2x7x_read_interrupt_config,
+ .write_event_config = &tsl2x7x_write_interrupt_config,
+ },
+ [ALSPRX] = {
+ .attrs = &tsl2X7X_device_attr_group_tbl[ALSPRX],
+ .event_attrs = &tsl2X7X_event_attr_group_tbl[ALSPRX],
+ .driver_module = THIS_MODULE,
+ .read_raw = &tsl2x7x_read_raw,
+ .write_raw = &tsl2x7x_write_raw,
+ .read_event_value = &tsl2x7x_read_thresh,
+ .write_event_value = &tsl2x7x_write_thresh,
+ .read_event_config = &tsl2x7x_read_interrupt_config,
+ .write_event_config = &tsl2x7x_write_interrupt_config,
+ },
+ [PRX2] = {
+ .attrs = &tsl2X7X_device_attr_group_tbl[PRX2],
+ .event_attrs = &tsl2X7X_event_attr_group_tbl[PRX],
+ .driver_module = THIS_MODULE,
+ .read_raw = &tsl2x7x_read_raw,
+ .write_raw = &tsl2x7x_write_raw,
+ .read_event_value = &tsl2x7x_read_thresh,
+ .write_event_value = &tsl2x7x_write_thresh,
+ .read_event_config = &tsl2x7x_read_interrupt_config,
+ .write_event_config = &tsl2x7x_write_interrupt_config,
+ },
+ [ALSPRX2] = {
+ .attrs = &tsl2X7X_device_attr_group_tbl[ALSPRX2],
+ .event_attrs = &tsl2X7X_event_attr_group_tbl[ALSPRX],
+ .driver_module = THIS_MODULE,
+ .read_raw = &tsl2x7x_read_raw,
+ .write_raw = &tsl2x7x_write_raw,
+ .read_event_value = &tsl2x7x_read_thresh,
+ .write_event_value = &tsl2x7x_write_thresh,
+ .read_event_config = &tsl2x7x_read_interrupt_config,
+ .write_event_config = &tsl2x7x_write_interrupt_config,
+ },
+};
+
+static const struct tsl2x7x_chip_info tsl2x7x_chip_info_tbl[] = {
+ [ALS] = {
+ .channel = {
+ {
+ .type = IIO_LIGHT,
+ .indexed = 1,
+ .channel = 0,
+ .info_mask = IIO_CHAN_INFO_PROCESSED_SEPARATE_BIT,
+ }, {
+ .type = IIO_INTENSITY,
+ .indexed = 1,
+ .channel = 0,
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
+ IIO_CHAN_INFO_CALIBSCALE_SEPARATE_BIT |
+ IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT,
+ .event_mask = TSL2X7X_EVENT_MASK
+ }, {
+ .type = IIO_INTENSITY,
+ .indexed = 1,
+ .channel = 1,
+ },
+ },
+ .chan_table_elements = 3,
+ .info = &tsl2X7X_device_info[ALS],
+ },
+ [PRX] = {
+ .channel = {
+ {
+ .type = IIO_PROXIMITY,
+ .indexed = 1,
+ .channel = 0,
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT,
+ .event_mask = TSL2X7X_EVENT_MASK
+ },
+ },
+ .chan_table_elements = 1,
+ .info = &tsl2X7X_device_info[PRX],
+ },
+ [ALSPRX] = {
+ .channel = {
+ {
+ .type = IIO_LIGHT,
+ .indexed = 1,
+ .channel = 0,
+ .info_mask = IIO_CHAN_INFO_PROCESSED_SEPARATE_BIT
+ }, {
+ .type = IIO_INTENSITY,
+ .indexed = 1,
+ .channel = 0,
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
+ IIO_CHAN_INFO_CALIBSCALE_SEPARATE_BIT |
+ IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT,
+ .event_mask = TSL2X7X_EVENT_MASK
+ }, {
+ .type = IIO_INTENSITY,
+ .indexed = 1,
+ .channel = 1,
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT,
+ }, {
+ .type = IIO_PROXIMITY,
+ .indexed = 1,
+ .channel = 0,
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT,
+ .event_mask = TSL2X7X_EVENT_MASK
+ },
+ },
+ .chan_table_elements = 4,
+ .info = &tsl2X7X_device_info[ALSPRX],
+ },
+ [PRX2] = {
+ .channel = {
+ {
+ .type = IIO_PROXIMITY,
+ .indexed = 1,
+ .channel = 0,
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
+ IIO_CHAN_INFO_CALIBSCALE_SEPARATE_BIT,
+ .event_mask = TSL2X7X_EVENT_MASK
+ },
+ },
+ .chan_table_elements = 1,
+ .info = &tsl2X7X_device_info[PRX2],
+ },
+ [ALSPRX2] = {
+ .channel = {
+ {
+ .type = IIO_LIGHT,
+ .indexed = 1,
+ .channel = 0,
+ .info_mask = IIO_CHAN_INFO_PROCESSED_SEPARATE_BIT,
+ }, {
+ .type = IIO_INTENSITY,
+ .indexed = 1,
+ .channel = 0,
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
+ IIO_CHAN_INFO_CALIBSCALE_SEPARATE_BIT |
+ IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT,
+ .event_mask = TSL2X7X_EVENT_MASK
+ }, {
+ .type = IIO_INTENSITY,
+ .indexed = 1,
+ .channel = 1,
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT,
+ }, {
+ .type = IIO_PROXIMITY,
+ .indexed = 1,
+ .channel = 0,
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
+ IIO_CHAN_INFO_CALIBSCALE_SEPARATE_BIT,
+ .event_mask = TSL2X7X_EVENT_MASK
+ },
+ },
+ .chan_table_elements = 4,
+ .info = &tsl2X7X_device_info[ALSPRX2],
+ },
+};
+
+static int __devinit tsl2x7x_probe(struct i2c_client *clientp,
+ const struct i2c_device_id *id)
+{
+ int ret;
+ unsigned char device_id;
+ struct iio_dev *indio_dev;
+ struct tsl2X7X_chip *chip;
+
+ indio_dev = iio_device_alloc(sizeof(*chip));
+ if (!indio_dev)
+ return -ENOMEM;
+
+ chip = iio_priv(indio_dev);
+ chip->client = clientp;
+ i2c_set_clientdata(clientp, indio_dev);
+
+ ret = tsl2x7x_i2c_read(chip->client,
+ TSL2X7X_CHIPID, &device_id);
+ if (ret < 0)
+ goto fail1;
+
+ if ((!tsl2x7x_device_id(&device_id, id->driver_data)) ||
+ (tsl2x7x_device_id(&device_id, id->driver_data) == -EINVAL)) {
+ dev_info(&chip->client->dev,
+ "%s: i2c device found does not match expected id\n",
+ __func__);
+ goto fail1;
+ }
+
+ ret = i2c_smbus_write_byte(clientp, (TSL2X7X_CMD_REG | TSL2X7X_CNTRL));
+ if (ret < 0) {
+ dev_err(&clientp->dev, "%s: write to cmd reg failed. err = %d\n",
+ __func__, ret);
+ goto fail1;
+ }
+
+ /* ALS and PROX functions can be invoked via user space poll
+ * or H/W interrupt. If busy return last sample. */
+ mutex_init(&chip->als_mutex);
+ mutex_init(&chip->prox_mutex);
+
+ chip->tsl2x7x_chip_status = TSL2X7X_CHIP_UNKNOWN;
+ chip->pdata = clientp->dev.platform_data;
+ chip->id = id->driver_data;
+ chip->chip_info =
+ &tsl2x7x_chip_info_tbl[device_channel_config[id->driver_data]];
+
+ indio_dev->info = chip->chip_info->info;
+ indio_dev->dev.parent = &clientp->dev;
+ indio_dev->modes = INDIO_DIRECT_MODE;
+ indio_dev->name = chip->client->name;
+ indio_dev->channels = chip->chip_info->channel;
+ indio_dev->num_channels = chip->chip_info->chan_table_elements;
+
+ if (clientp->irq) {
+ ret = request_threaded_irq(clientp->irq,
+ NULL,
+ &tsl2x7x_event_handler,
+ IRQF_TRIGGER_RISING | IRQF_ONESHOT,
+ "TSL2X7X_event",
+ indio_dev);
+ if (ret) {
+ dev_err(&clientp->dev,
+ "%s: irq request failed", __func__);
+ goto fail2;
+ }
+ }
+
+ /* Load up the defaults */
+ tsl2x7x_defaults(chip);
+ /* Make sure the chip is on */
+ tsl2x7x_chip_on(indio_dev);
+
+ ret = iio_device_register(indio_dev);
+ if (ret) {
+ dev_err(&clientp->dev,
+ "%s: iio registration failed\n", __func__);
+ goto fail1;
+ }
+
+ dev_info(&clientp->dev, "%s Light sensor found.\n", id->name);
+
+ return 0;
+
+fail1:
+ if (clientp->irq)
+ free_irq(clientp->irq, indio_dev);
+fail2:
+ iio_device_free(indio_dev);
+
+ return ret;
+}
+
+static int tsl2x7x_suspend(struct device *dev)
+{
+ struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct tsl2X7X_chip *chip = iio_priv(indio_dev);
+ int ret = 0;
+
+ if (chip->tsl2x7x_chip_status == TSL2X7X_CHIP_WORKING) {
+ ret = tsl2x7x_chip_off(indio_dev);
+ chip->tsl2x7x_chip_status = TSL2X7X_CHIP_SUSPENDED;
+ }
+
+ if (chip->pdata && chip->pdata->platform_power) {
+ pm_message_t pmm = {PM_EVENT_SUSPEND};
+ chip->pdata->platform_power(dev, pmm);
+ }
+
+ return ret;
+}
+
+static int tsl2x7x_resume(struct device *dev)
+{
+ struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct tsl2X7X_chip *chip = iio_priv(indio_dev);
+ int ret = 0;
+
+ if (chip->pdata && chip->pdata->platform_power) {
+ pm_message_t pmm = {PM_EVENT_RESUME};
+ chip->pdata->platform_power(dev, pmm);
+ }
+
+ if (chip->tsl2x7x_chip_status == TSL2X7X_CHIP_SUSPENDED)
+ ret = tsl2x7x_chip_on(indio_dev);
+
+ return ret;
+}
+
+static int __devexit tsl2x7x_remove(struct i2c_client *client)
+{
+ struct iio_dev *indio_dev = i2c_get_clientdata(client);
+
+ tsl2x7x_chip_off(indio_dev);
+
+ iio_device_unregister(indio_dev);
+ if (client->irq)
+ free_irq(client->irq, indio_dev);
+
+ iio_device_free(indio_dev);
+
+ return 0;
+}
+
+static struct i2c_device_id tsl2x7x_idtable[] = {
+ { "tsl2571", tsl2571 },
+ { "tsl2671", tsl2671 },
+ { "tmd2671", tmd2671 },
+ { "tsl2771", tsl2771 },
+ { "tmd2771", tmd2771 },
+ { "tsl2572", tsl2572 },
+ { "tsl2672", tsl2672 },
+ { "tmd2672", tmd2672 },
+ { "tsl2772", tsl2772 },
+ { "tmd2772", tmd2772 },
+ {}
+};
+
+MODULE_DEVICE_TABLE(i2c, tsl2x7x_idtable);
+
+static const struct dev_pm_ops tsl2x7x_pm_ops = {
+ .suspend = tsl2x7x_suspend,
+ .resume = tsl2x7x_resume,
+};
+
+/* Driver definition */
+static struct i2c_driver tsl2x7x_driver = {
+ .driver = {
+ .name = "tsl2x7x",
+ .pm = &tsl2x7x_pm_ops,
+ },
+ .id_table = tsl2x7x_idtable,
+ .probe = tsl2x7x_probe,
+ .remove = __devexit_p(tsl2x7x_remove),
+};
+
+module_i2c_driver(tsl2x7x_driver);
+
+MODULE_AUTHOR("J. August Brenner<jbrenner@taosinc.com>");
+MODULE_DESCRIPTION("TAOS tsl2x7x ambient and proximity light sensor driver");
+MODULE_LICENSE("GPL");
diff --git a/drivers/staging/iio/machine.h b/drivers/staging/iio/machine.h
deleted file mode 100644
index 0b1f19bfdc44..000000000000
--- a/drivers/staging/iio/machine.h
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * Industrial I/O in kernel access map definitions for board files.
- *
- * Copyright (c) 2011 Jonathan Cameron
- *
- * 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.
- */
-
-/**
- * struct iio_map - description of link between consumer and device channels
- * @adc_channel_label: Label used to identify the channel on the provider.
- * This is matched against the datasheet_name element
- * of struct iio_chan_spec.
- * @consumer_dev_name: Name to uniquely identify the consumer device.
- * @consumer_channel: Unique name used to idenitify the channel on the
- * consumer side.
- */
-struct iio_map {
- const char *adc_channel_label;
- const char *consumer_dev_name;
- const char *consumer_channel;
-};
diff --git a/drivers/staging/iio/magnetometer/Kconfig b/drivers/staging/iio/magnetometer/Kconfig
index 722c4e13f713..df5e0d4ea295 100644
--- a/drivers/staging/iio/magnetometer/Kconfig
+++ b/drivers/staging/iio/magnetometer/Kconfig
@@ -6,7 +6,7 @@ menu "Magnetometer sensors"
config SENSORS_AK8975
tristate "Asahi Kasei AK8975 3-Axis Magnetometer"
depends on I2C
- depends on GENERIC_GPIO
+ depends on GPIOLIB
help
Say yes here to build support for Asahi Kasei AK8975 3-Axis
Magnetometer.
@@ -15,13 +15,13 @@ config SENSORS_AK8975
will be called ak8975.
config SENSORS_HMC5843
- tristate "Honeywell HMC5843 3-Axis Magnetometer"
+ tristate "Honeywell HMC5843/5883/5883L 3-Axis Magnetometer"
depends on I2C
help
- Say Y here to add support for the Honeywell HMC 5843 3-Axis
- Magnetometer (digital compass).
+ Say Y here to add support for the Honeywell HMC5843, HMC5883 and
+ HMC5883L 3-Axis Magnetometer (digital compass).
To compile this driver as a module, choose M here: the module
- will be called hmc5843
+ will be called hmc5843.
endmenu
diff --git a/drivers/staging/iio/magnetometer/ak8975.c b/drivers/staging/iio/magnetometer/ak8975.c
index ebc2d0840caf..01b4b07c227b 100644
--- a/drivers/staging/iio/magnetometer/ak8975.c
+++ b/drivers/staging/iio/magnetometer/ak8975.c
@@ -30,8 +30,8 @@
#include <linux/gpio.h>
-#include "../iio.h"
-#include "../sysfs.h"
+#include <linux/iio/iio.h>
+#include <linux/iio/sysfs.h>
/*
* Register definitions, as well as various shifts and masks to get at the
* individual fields of the registers.
@@ -92,7 +92,6 @@ struct ak8975_data {
struct mutex lock;
u8 asa[3];
long raw_to_gauss[3];
- bool mode;
u8 reg_cache[AK8975_MAX_REGS];
int eoc_gpio;
int eoc_irq;
@@ -194,6 +193,17 @@ static int ak8975_setup(struct i2c_client *client)
return ret;
}
+ /* After reading fuse ROM data set power-down mode */
+ ret = ak8975_write_data(client,
+ AK8975_REG_CNTL,
+ AK8975_REG_CNTL_MODE_POWER_DOWN,
+ AK8975_REG_CNTL_MODE_MASK,
+ AK8975_REG_CNTL_MODE_SHIFT);
+ if (ret < 0) {
+ dev_err(&client->dev, "Error in setting power-down mode\n");
+ return ret;
+ }
+
/*
* Precalculate scale factor (in Gauss units) for each axis and
* store in the device data.
@@ -236,60 +246,6 @@ static int ak8975_setup(struct i2c_client *client)
return 0;
}
-/*
- * Shows the device's mode. 0 = off, 1 = on.
- */
-static ssize_t show_mode(struct device *dev, struct device_attribute *devattr,
- char *buf)
-{
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
- struct ak8975_data *data = iio_priv(indio_dev);
-
- return sprintf(buf, "%u\n", data->mode);
-}
-
-/*
- * Sets the device's mode. 0 = off, 1 = on. The device's mode must be on
- * for the magn raw attributes to be available.
- */
-static ssize_t store_mode(struct device *dev, struct device_attribute *devattr,
- const char *buf, size_t count)
-{
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
- struct ak8975_data *data = iio_priv(indio_dev);
- struct i2c_client *client = data->client;
- bool value;
- int ret;
-
- /* Convert mode string and do some basic sanity checking on it.
- only 0 or 1 are valid. */
- ret = strtobool(buf, &value);
- if (ret < 0)
- return ret;
-
- mutex_lock(&data->lock);
-
- /* Write the mode to the device. */
- if (data->mode != value) {
- ret = ak8975_write_data(client,
- AK8975_REG_CNTL,
- (u8)value,
- AK8975_REG_CNTL_MODE_MASK,
- AK8975_REG_CNTL_MODE_SHIFT);
-
- if (ret < 0) {
- dev_err(&client->dev, "Error in setting mode\n");
- mutex_unlock(&data->lock);
- return ret;
- }
- data->mode = value;
- }
-
- mutex_unlock(&data->lock);
-
- return count;
-}
-
static int wait_conversion_complete_gpio(struct ak8975_data *data)
{
struct i2c_client *client = data->client;
@@ -357,12 +313,6 @@ static int ak8975_read_axis(struct iio_dev *indio_dev, int index, int *val)
mutex_lock(&data->lock);
- if (data->mode == 0) {
- dev_err(&client->dev, "Operating mode is in power down mode\n");
- ret = -EBUSY;
- goto exit;
- }
-
/* Set up the device for taking a sample. */
ret = ak8975_write_data(client,
AK8975_REG_CNTL,
@@ -431,7 +381,7 @@ static int ak8975_read_raw(struct iio_dev *indio_dev,
struct ak8975_data *data = iio_priv(indio_dev);
switch (mask) {
- case 0:
+ case IIO_CHAN_INFO_RAW:
return ak8975_read_axis(indio_dev, chan->address, val);
case IIO_CHAN_INFO_SCALE:
*val = data->raw_to_gauss[chan->address];
@@ -445,7 +395,8 @@ static int ak8975_read_raw(struct iio_dev *indio_dev,
.type = IIO_MAGN, \
.modified = 1, \
.channel2 = IIO_MOD_##axis, \
- .info_mask = IIO_CHAN_INFO_SCALE_SEPARATE_BIT, \
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT | \
+ IIO_CHAN_INFO_SCALE_SEPARATE_BIT, \
.address = index, \
}
@@ -453,24 +404,12 @@ static const struct iio_chan_spec ak8975_channels[] = {
AK8975_CHANNEL(X, 0), AK8975_CHANNEL(Y, 1), AK8975_CHANNEL(Z, 2),
};
-static IIO_DEVICE_ATTR(mode, S_IRUGO | S_IWUSR, show_mode, store_mode, 0);
-
-static struct attribute *ak8975_attr[] = {
- &iio_dev_attr_mode.dev_attr.attr,
- NULL
-};
-
-static struct attribute_group ak8975_attr_group = {
- .attrs = ak8975_attr,
-};
-
static const struct iio_info ak8975_info = {
- .attrs = &ak8975_attr_group,
.read_raw = &ak8975_read_raw,
.driver_module = THIS_MODULE,
};
-static int ak8975_probe(struct i2c_client *client,
+static int __devinit ak8975_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{
struct ak8975_data *data;
@@ -487,25 +426,17 @@ static int ak8975_probe(struct i2c_client *client,
/* We may not have a GPIO based IRQ to scan, that is fine, we will
poll if so */
if (gpio_is_valid(eoc_gpio)) {
- err = gpio_request(eoc_gpio, "ak_8975");
+ err = gpio_request_one(eoc_gpio, GPIOF_IN, "ak_8975");
if (err < 0) {
dev_err(&client->dev,
"failed to request GPIO %d, error %d\n",
eoc_gpio, err);
goto exit;
}
-
- err = gpio_direction_input(eoc_gpio);
- if (err < 0) {
- dev_err(&client->dev,
- "Failed to configure input direction for GPIO %d, error %d\n",
- eoc_gpio, err);
- goto exit_gpio;
- }
}
/* Register with IIO */
- indio_dev = iio_allocate_device(sizeof(*data));
+ indio_dev = iio_device_alloc(sizeof(*data));
if (indio_dev == NULL) {
err = -ENOMEM;
goto exit_gpio;
@@ -536,7 +467,7 @@ static int ak8975_probe(struct i2c_client *client,
return 0;
exit_free_iio:
- iio_free_device(indio_dev);
+ iio_device_free(indio_dev);
exit_gpio:
if (gpio_is_valid(eoc_gpio))
gpio_free(eoc_gpio);
@@ -544,7 +475,7 @@ exit:
return err;
}
-static int ak8975_remove(struct i2c_client *client)
+static int __devexit ak8975_remove(struct i2c_client *client)
{
struct iio_dev *indio_dev = i2c_get_clientdata(client);
struct ak8975_data *data = iio_priv(indio_dev);
@@ -554,7 +485,7 @@ static int ak8975_remove(struct i2c_client *client)
if (gpio_is_valid(data->eoc_gpio))
gpio_free(data->eoc_gpio);
- iio_free_device(indio_dev);
+ iio_device_free(indio_dev);
return 0;
}
diff --git a/drivers/staging/iio/magnetometer/hmc5843.c b/drivers/staging/iio/magnetometer/hmc5843.c
index e00b416c4d33..6c3e50f7c0d8 100644
--- a/drivers/staging/iio/magnetometer/hmc5843.c
+++ b/drivers/staging/iio/magnetometer/hmc5843.c
@@ -2,6 +2,8 @@
Author: Shubhrajyoti Datta <shubhrajyoti@ti.com>
Acknowledgement: Jonathan Cameron <jic23@cam.ac.uk> for valuable inputs.
+ Support for HMC5883 and HMC5883L by Peter Meerwald <pmeerw@pmeerw.net>.
+
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
@@ -22,10 +24,8 @@
#include <linux/i2c.h>
#include <linux/slab.h>
#include <linux/types.h>
-#include "../iio.h"
-#include "../sysfs.h"
-
-#define HMC5843_I2C_ADDRESS 0x1E
+#include <linux/iio/iio.h>
+#include <linux/iio/sysfs.h>
#define HMC5843_CONFIG_REG_A 0x00
#define HMC5843_CONFIG_REG_B 0x01
@@ -36,110 +36,185 @@
#define HMC5843_DATA_OUT_Y_LSB_REG 0x06
#define HMC5843_DATA_OUT_Z_MSB_REG 0x07
#define HMC5843_DATA_OUT_Z_LSB_REG 0x08
+/* Beware: Y and Z are exchanged on HMC5883 */
+#define HMC5883_DATA_OUT_Z_MSB_REG 0x05
+#define HMC5883_DATA_OUT_Z_LSB_REG 0x06
+#define HMC5883_DATA_OUT_Y_MSB_REG 0x07
+#define HMC5883_DATA_OUT_Y_LSB_REG 0x08
#define HMC5843_STATUS_REG 0x09
#define HMC5843_ID_REG_A 0x0A
#define HMC5843_ID_REG_B 0x0B
#define HMC5843_ID_REG_C 0x0C
+enum hmc5843_ids {
+ HMC5843_ID,
+ HMC5883_ID,
+ HMC5883L_ID,
+};
+
+/*
+ * Beware: identification of the HMC5883 is still "H43";
+ * I2C address is also unchanged
+ */
#define HMC5843_ID_REG_LENGTH 0x03
#define HMC5843_ID_STRING "H43"
+#define HMC5843_I2C_ADDRESS 0x1E
/*
- * Range settings in (+-)Ga
- * */
-#define RANGE_GAIN_OFFSET 0x05
-
-#define RANGE_0_7 0x00
-#define RANGE_1_0 0x01 /* default */
-#define RANGE_1_5 0x02
-#define RANGE_2_0 0x03
-#define RANGE_3_2 0x04
-#define RANGE_3_8 0x05
-#define RANGE_4_5 0x06
-#define RANGE_6_5 0x07 /* Not recommended */
+ * Range gain settings in (+-)Ga
+ * Beware: HMC5843 and HMC5883 have different recommended sensor field
+ * ranges; default corresponds to +-1.0 Ga and +-1.3 Ga, respectively
+ */
+#define HMC5843_RANGE_GAIN_OFFSET 0x05
+#define HMC5843_RANGE_GAIN_DEFAULT 0x01
+#define HMC5843_RANGE_GAIN_MAX 0x07
/*
* Device status
*/
-#define DATA_READY 0x01
-#define DATA_OUTPUT_LOCK 0x02
-#define VOLTAGE_REGULATOR_ENABLED 0x04
+#define HMC5843_DATA_READY 0x01
+#define HMC5843_DATA_OUTPUT_LOCK 0x02
+/* Does not exist on HMC5883, not used */
+#define HMC5843_VOLTAGE_REGULATOR_ENABLED 0x04
/*
* Mode register configuration
*/
-#define MODE_CONVERSION_CONTINUOUS 0x00
-#define MODE_CONVERSION_SINGLE 0x01
-#define MODE_IDLE 0x02
-#define MODE_SLEEP 0x03
-
-/* Minimum Data Output Rate in 1/10 Hz */
-#define RATE_OFFSET 0x02
-#define RATE_BITMASK 0x1C
-#define RATE_5 0x00
-#define RATE_10 0x01
-#define RATE_20 0x02
-#define RATE_50 0x03
-#define RATE_100 0x04
-#define RATE_200 0x05
-#define RATE_500 0x06
-#define RATE_NOT_USED 0x07
+#define HMC5843_MODE_CONVERSION_CONTINUOUS 0x00
+#define HMC5843_MODE_CONVERSION_SINGLE 0x01
+#define HMC5843_MODE_IDLE 0x02
+#define HMC5843_MODE_SLEEP 0x03
+#define HMC5843_MODE_MASK 0x03
+
+/*
+ * HMC5843: Minimum data output rate
+ * HMC5883: Typical data output rate
+ */
+#define HMC5843_RATE_OFFSET 0x02
+#define HMC5843_RATE_BITMASK 0x1C
+#define HMC5843_RATE_NOT_USED 0x07
/*
- * Device Configuration
+ * Device measurement configuration
*/
-#define CONF_NORMAL 0x00
-#define CONF_POSITIVE_BIAS 0x01
-#define CONF_NEGATIVE_BIAS 0x02
-#define CONF_NOT_USED 0x03
-#define MEAS_CONF_MASK 0x03
+#define HMC5843_MEAS_CONF_NORMAL 0x00
+#define HMC5843_MEAS_CONF_POSITIVE_BIAS 0x01
+#define HMC5843_MEAS_CONF_NEGATIVE_BIAS 0x02
+#define HMC5843_MEAS_CONF_NOT_USED 0x03
+#define HMC5843_MEAS_CONF_MASK 0x03
-static int hmc5843_regval_to_nanoscale[] = {
+/*
+ * Scaling factors: 10000000/Gain
+ */
+static const int hmc5843_regval_to_nanoscale[] = {
6173, 7692, 10309, 12821, 18868, 21739, 25641, 35714
};
-static const int regval_to_input_field_mg[] = {
- 700,
- 1000,
- 1500,
- 2000,
- 3200,
- 3800,
- 4500,
- 6500
+static const int hmc5883_regval_to_nanoscale[] = {
+ 7812, 9766, 13021, 16287, 24096, 27701, 32573, 45662
};
-static const char * const regval_to_samp_freq[] = {
- "0.5",
- "1",
- "2",
- "5",
- "10",
- "20",
- "50",
+
+static const int hmc5883l_regval_to_nanoscale[] = {
+ 7299, 9174, 12195, 15152, 22727, 25641, 30303, 43478
+};
+
+/*
+ * From the HMC5843 datasheet:
+ * Value | Sensor input field range (Ga) | Gain (counts/milli-Gauss)
+ * 0 | (+-)0.7 | 1620
+ * 1 | (+-)1.0 | 1300
+ * 2 | (+-)1.5 | 970
+ * 3 | (+-)2.0 | 780
+ * 4 | (+-)3.2 | 530
+ * 5 | (+-)3.8 | 460
+ * 6 | (+-)4.5 | 390
+ * 7 | (+-)6.5 | 280
+ *
+ * From the HMC5883 datasheet:
+ * Value | Recommended sensor field range (Ga) | Gain (counts/Gauss)
+ * 0 | (+-)0.9 | 1280
+ * 1 | (+-)1.2 | 1024
+ * 2 | (+-)1.9 | 768
+ * 3 | (+-)2.5 | 614
+ * 4 | (+-)4.0 | 415
+ * 5 | (+-)4.6 | 361
+ * 6 | (+-)5.5 | 307
+ * 7 | (+-)7.9 | 219
+ *
+ * From the HMC5883L datasheet:
+ * Value | Recommended sensor field range (Ga) | Gain (LSB/Gauss)
+ * 0 | (+-)0.88 | 1370
+ * 1 | (+-)1.3 | 1090
+ * 2 | (+-)1.9 | 820
+ * 3 | (+-)2.5 | 660
+ * 4 | (+-)4.0 | 440
+ * 5 | (+-)4.7 | 390
+ * 6 | (+-)5.6 | 330
+ * 7 | (+-)8.1 | 230
+ */
+static const int hmc5843_regval_to_input_field_mga[] = {
+ 700, 1000, 1500, 2000, 3200, 3800, 4500, 6500
+};
+
+static const int hmc5883_regval_to_input_field_mga[] = {
+ 900, 1200, 1900, 2500, 4000, 4600, 5500, 7900
+};
+
+static const int hmc5883l_regval_to_input_field_mga[] = {
+ 880, 1300, 1900, 2500, 4000, 4700, 5600, 8100
+};
+
+/*
+ * From the datasheet:
+ * Value | HMC5843 | HMC5883/HMC5883L
+ * | Data output rate (Hz) | Data output rate (Hz)
+ * 0 | 0.5 | 0.75
+ * 1 | 1 | 1.5
+ * 2 | 2 | 3
+ * 3 | 5 | 7.5
+ * 4 | 10 (default) | 15
+ * 5 | 20 | 30
+ * 6 | 50 | 75
+ * 7 | Not used | Not used
+ */
+static const char * const hmc5843_regval_to_sample_freq[] = {
+ "0.5", "1", "2", "5", "10", "20", "50",
+};
+
+static const char * const hmc5883_regval_to_sample_freq[] = {
+ "0.75", "1.5", "3", "7.5", "15", "30", "75",
};
/* Addresses to scan: 0x1E */
static const unsigned short normal_i2c[] = { HMC5843_I2C_ADDRESS,
- I2C_CLIENT_END };
+ I2C_CLIENT_END };
+
+/* Describe chip variants */
+struct hmc5843_chip_info {
+ const struct iio_chan_spec *channels;
+ int num_channels;
+ const char * const *regval_to_sample_freq;
+ const int *regval_to_input_field_mga;
+ const int *regval_to_nanoscale;
+};
/* Each client has this additional data */
struct hmc5843_data {
struct mutex lock;
- u8 rate;
- u8 meas_conf;
- u8 operating_mode;
- u8 range;
+ u8 rate;
+ u8 meas_conf;
+ u8 operating_mode;
+ u8 range;
+ const struct hmc5843_chip_info *variant;
};
-static void hmc5843_init_client(struct i2c_client *client);
-
+/* The lower two bits contain the current conversion mode */
static s32 hmc5843_configure(struct i2c_client *client,
u8 operating_mode)
{
- /* The lower two bits contain the current conversion mode */
return i2c_smbus_write_byte_data(client,
HMC5843_MODE_REG,
- (operating_mode & 0x03));
+ operating_mode & HMC5843_MODE_MASK);
}
/* Return the measurement value from the specified channel */
@@ -153,7 +228,7 @@ static int hmc5843_read_measurement(struct iio_dev *indio_dev,
mutex_lock(&data->lock);
result = i2c_smbus_read_byte_data(client, HMC5843_STATUS_REG);
- while (!(result & DATA_READY))
+ while (!(result & HMC5843_DATA_READY))
result = i2c_smbus_read_byte_data(client, HMC5843_STATUS_REG);
result = i2c_smbus_read_word_data(client, address);
@@ -161,30 +236,29 @@ static int hmc5843_read_measurement(struct iio_dev *indio_dev,
if (result < 0)
return -EINVAL;
- *val = (s16)swab16((u16)result);
+ *val = (s16)swab16((u16)result);
return IIO_VAL_INT;
}
-
/*
- * From the datasheet
+ * From the datasheet:
* 0 - Continuous-Conversion Mode: In continuous-conversion mode, the
- * device continuously performs conversions and places the result in the
- * data register.
+ * device continuously performs conversions and places the result in
+ * the data register.
*
- * 1 - Single-Conversion Mode : device performs a single measurement,
- * sets RDY high and returned to sleep mode
+ * 1 - Single-Conversion Mode : Device performs a single measurement,
+ * sets RDY high and returns to sleep mode.
*
- * 2 - Idle Mode : Device is placed in idle mode.
+ * 2 - Idle Mode : Device is placed in idle mode.
*
- * 3 - Sleep Mode. Device is placed in sleep mode.
+ * 3 - Sleep Mode : Device is placed in sleep mode.
*
*/
static ssize_t hmc5843_show_operating_mode(struct device *dev,
struct device_attribute *attr,
char *buf)
{
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct hmc5843_data *data = iio_priv(indio_dev);
return sprintf(buf, "%d\n", data->operating_mode);
}
@@ -194,21 +268,22 @@ static ssize_t hmc5843_set_operating_mode(struct device *dev,
const char *buf,
size_t count)
{
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct i2c_client *client = to_i2c_client(indio_dev->dev.parent);
struct hmc5843_data *data = iio_priv(indio_dev);
struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
unsigned long operating_mode = 0;
s32 status;
int error;
+
mutex_lock(&data->lock);
- error = strict_strtoul(buf, 10, &operating_mode);
+ error = kstrtoul(buf, 10, &operating_mode);
if (error) {
count = error;
goto exit;
}
- dev_dbg(dev, "set Conversion mode to %lu\n", operating_mode);
- if (operating_mode > MODE_SLEEP) {
+ dev_dbg(dev, "set conversion mode to %lu\n", operating_mode);
+ if (operating_mode > HMC5843_MODE_SLEEP) {
count = -EINVAL;
goto exit;
}
@@ -225,6 +300,7 @@ exit:
mutex_unlock(&data->lock);
return count;
}
+
static IIO_DEVICE_ATTR(operating_mode,
S_IWUSR | S_IRUGO,
hmc5843_show_operating_mode,
@@ -234,25 +310,29 @@ static IIO_DEVICE_ATTR(operating_mode,
/*
* API for setting the measurement configuration to
* Normal, Positive bias and Negative bias
- * From the datasheet
*
- * Normal measurement configuration (default): In normal measurement
- * configuration the device follows normal measurement flow. Pins BP and BN
- * are left floating and high impedance.
+ * From the datasheet:
+ * 0 - Normal measurement configuration (default): In normal measurement
+ * configuration the device follows normal measurement flow. Pins BP
+ * and BN are left floating and high impedance.
*
- * Positive bias configuration: In positive bias configuration, a positive
- * current is forced across the resistive load on pins BP and BN.
+ * 1 - Positive bias configuration: In positive bias configuration, a
+ * positive current is forced across the resistive load on pins BP
+ * and BN.
*
- * Negative bias configuration. In negative bias configuration, a negative
- * current is forced across the resistive load on pins BP and BN.
+ * 2 - Negative bias configuration. In negative bias configuration, a
+ * negative current is forced across the resistive load on pins BP
+ * and BN.
*
*/
static s32 hmc5843_set_meas_conf(struct i2c_client *client,
u8 meas_conf)
{
- struct hmc5843_data *data = i2c_get_clientdata(client);
+ struct iio_dev *indio_dev = i2c_get_clientdata(client);
+ struct hmc5843_data *data = iio_priv(indio_dev);
u8 reg_val;
- reg_val = (meas_conf & MEAS_CONF_MASK) | (data->rate << RATE_OFFSET);
+ reg_val = (meas_conf & HMC5843_MEAS_CONF_MASK) |
+ (data->rate << HMC5843_RATE_OFFSET);
return i2c_smbus_write_byte_data(client, HMC5843_CONFIG_REG_A, reg_val);
}
@@ -260,7 +340,7 @@ static ssize_t hmc5843_show_measurement_configuration(struct device *dev,
struct device_attribute *attr,
char *buf)
{
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct hmc5843_data *data = iio_priv(indio_dev);
return sprintf(buf, "%d\n", data->meas_conf);
}
@@ -270,16 +350,20 @@ static ssize_t hmc5843_set_measurement_configuration(struct device *dev,
const char *buf,
size_t count)
{
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct i2c_client *client = to_i2c_client(indio_dev->dev.parent);
- struct hmc5843_data *data = i2c_get_clientdata(client);
+ struct hmc5843_data *data = iio_priv(indio_dev);
unsigned long meas_conf = 0;
- int error = strict_strtoul(buf, 10, &meas_conf);
+ int error;
+
+ error = kstrtoul(buf, 10, &meas_conf);
if (error)
return error;
- mutex_lock(&data->lock);
+ if (meas_conf >= HMC5843_MEAS_CONF_NOT_USED)
+ return -EINVAL;
- dev_dbg(dev, "set mode to %lu\n", meas_conf);
+ mutex_lock(&data->lock);
+ dev_dbg(dev, "set measurement configuration to %lu\n", meas_conf);
if (hmc5843_set_meas_conf(client, meas_conf)) {
count = -EINVAL;
goto exit;
@@ -290,71 +374,85 @@ exit:
mutex_unlock(&data->lock);
return count;
}
+
static IIO_DEVICE_ATTR(meas_conf,
S_IWUSR | S_IRUGO,
hmc5843_show_measurement_configuration,
hmc5843_set_measurement_configuration,
0);
-/*
- * From Datasheet
- * The table shows the minimum data output
- * Value | Minimum data output rate(Hz)
- * 0 | 0.5
- * 1 | 1
- * 2 | 2
- * 3 | 5
- * 4 | 10 (default)
- * 5 | 20
- * 6 | 50
- * 7 | Not used
- */
-static IIO_CONST_ATTR_SAMP_FREQ_AVAIL("0.5 1 2 5 10 20 50");
+static ssize_t hmc5843_show_sampling_frequencies_available(struct device *dev,
+ struct device_attribute *attr,
+ char *buf)
+{
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
+ struct hmc5843_data *data = iio_priv(indio_dev);
+ ssize_t total_n = 0;
+ int i;
+
+ for (i = 0; i < HMC5843_RATE_NOT_USED; i++) {
+ ssize_t n = sprintf(buf, "%s ", data->variant->regval_to_sample_freq[i]);
+ buf += n;
+ total_n += n;
+ }
+ /* replace trailing space by newline */
+ buf[-1] = '\n';
+
+ return total_n;
+}
+
+static IIO_DEV_ATTR_SAMP_FREQ_AVAIL(hmc5843_show_sampling_frequencies_available);
static s32 hmc5843_set_rate(struct i2c_client *client,
u8 rate)
{
- struct hmc5843_data *data = i2c_get_clientdata(client);
+ struct iio_dev *indio_dev = i2c_get_clientdata(client);
+ struct hmc5843_data *data = iio_priv(indio_dev);
u8 reg_val;
- reg_val = (data->meas_conf) | (rate << RATE_OFFSET);
- if (rate >= RATE_NOT_USED) {
+ if (rate >= HMC5843_RATE_NOT_USED) {
dev_err(&client->dev,
- "This data output rate is not supported\n");
+ "data output rate is not supported\n");
return -EINVAL;
}
+
+ reg_val = data->meas_conf | (rate << HMC5843_RATE_OFFSET);
return i2c_smbus_write_byte_data(client, HMC5843_CONFIG_REG_A, reg_val);
}
-static ssize_t set_sampling_frequency(struct device *dev,
+static int hmc5843_check_sampling_frequency(struct hmc5843_data *data,
+ const char *buf)
+{
+ const char * const *samp_freq = data->variant->regval_to_sample_freq;
+ int i;
+
+ for (i = 0; i < HMC5843_RATE_NOT_USED; i++) {
+ if (sysfs_streq(buf, samp_freq[i]))
+ return i;
+ }
+
+ return -EINVAL;
+}
+
+static ssize_t hmc5843_set_sampling_frequency(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count)
{
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct i2c_client *client = to_i2c_client(indio_dev->dev.parent);
struct hmc5843_data *data = iio_priv(indio_dev);
- unsigned long rate = 0;
-
- if (strncmp(buf, "0.5" , 3) == 0)
- rate = RATE_5;
- else if (strncmp(buf, "1" , 1) == 0)
- rate = RATE_10;
- else if (strncmp(buf, "2", 1) == 0)
- rate = RATE_20;
- else if (strncmp(buf, "5", 1) == 0)
- rate = RATE_50;
- else if (strncmp(buf, "10", 2) == 0)
- rate = RATE_100;
- else if (strncmp(buf, "20" , 2) == 0)
- rate = RATE_200;
- else if (strncmp(buf, "50" , 2) == 0)
- rate = RATE_500;
- else
- return -EINVAL;
+ int rate;
+
+ rate = hmc5843_check_sampling_frequency(data, buf);
+ if (rate < 0) {
+ dev_err(&client->dev,
+ "sampling frequency is not supported\n");
+ return rate;
+ }
mutex_lock(&data->lock);
- dev_dbg(dev, "set rate to %lu\n", rate);
+ dev_dbg(dev, "set rate to %d\n", rate);
if (hmc5843_set_rate(client, rate)) {
count = -EINVAL;
goto exit;
@@ -366,89 +464,79 @@ exit:
return count;
}
-static ssize_t show_sampling_frequency(struct device *dev,
+static ssize_t hmc5843_show_sampling_frequency(struct device *dev,
struct device_attribute *attr, char *buf)
{
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct i2c_client *client = to_i2c_client(indio_dev->dev.parent);
struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
+ struct hmc5843_data *data = iio_priv(indio_dev);
s32 rate;
- rate = i2c_smbus_read_byte_data(client, this_attr->address);
+ rate = i2c_smbus_read_byte_data(client, this_attr->address);
if (rate < 0)
return rate;
- rate = (rate & RATE_BITMASK) >> RATE_OFFSET;
- return sprintf(buf, "%s\n", regval_to_samp_freq[rate]);
+ rate = (rate & HMC5843_RATE_BITMASK) >> HMC5843_RATE_OFFSET;
+ return sprintf(buf, "%s\n", data->variant->regval_to_sample_freq[rate]);
}
+
static IIO_DEVICE_ATTR(sampling_frequency,
S_IWUSR | S_IRUGO,
- show_sampling_frequency,
- set_sampling_frequency,
+ hmc5843_show_sampling_frequency,
+ hmc5843_set_sampling_frequency,
HMC5843_CONFIG_REG_A);
-/*
- * From Datasheet
- * Nominal gain settings
- * Value | Sensor Input Field Range(Ga) | Gain(counts/ milli-gauss)
- *0 |(+-)0.7 |1620
- *1 |(+-)1.0 |1300
- *2 |(+-)1.5 |970
- *3 |(+-)2.0 |780
- *4 |(+-)3.2 |530
- *5 |(+-)3.8 |460
- *6 |(+-)4.5 |390
- *7 |(+-)6.5 |280
- */
-static ssize_t show_range(struct device *dev,
+static ssize_t hmc5843_show_range_gain(struct device *dev,
struct device_attribute *attr,
char *buf)
{
u8 range;
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct hmc5843_data *data = iio_priv(indio_dev);
range = data->range;
- return sprintf(buf, "%d\n", regval_to_input_field_mg[range]);
+ return sprintf(buf, "%d\n", data->variant->regval_to_input_field_mga[range]);
}
-static ssize_t set_range(struct device *dev,
+static ssize_t hmc5843_set_range_gain(struct device *dev,
struct device_attribute *attr,
const char *buf,
size_t count)
{
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct i2c_client *client = to_i2c_client(indio_dev->dev.parent);
struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
struct hmc5843_data *data = iio_priv(indio_dev);
unsigned long range = 0;
int error;
+
mutex_lock(&data->lock);
- error = strict_strtoul(buf, 10, &range);
+ error = kstrtoul(buf, 10, &range);
if (error) {
count = error;
goto exit;
}
dev_dbg(dev, "set range to %lu\n", range);
- if (range > RANGE_6_5) {
+ if (range > HMC5843_RANGE_GAIN_MAX) {
count = -EINVAL;
goto exit;
}
data->range = range;
- range = range << RANGE_GAIN_OFFSET;
+ range = range << HMC5843_RANGE_GAIN_OFFSET;
if (i2c_smbus_write_byte_data(client, this_attr->address, range))
count = -EINVAL;
exit:
mutex_unlock(&data->lock);
return count;
-
}
+
static IIO_DEVICE_ATTR(in_magn_range,
S_IWUSR | S_IRUGO,
- show_range,
- set_range,
+ hmc5843_show_range_gain,
+ hmc5843_set_range_gain,
HMC5843_CONFIG_REG_B);
static int hmc5843_read_raw(struct iio_dev *indio_dev,
@@ -459,13 +547,13 @@ static int hmc5843_read_raw(struct iio_dev *indio_dev,
struct hmc5843_data *data = iio_priv(indio_dev);
switch (mask) {
- case 0:
+ case IIO_CHAN_INFO_RAW:
return hmc5843_read_measurement(indio_dev,
chan->address,
val);
case IIO_CHAN_INFO_SCALE:
*val = 0;
- *val2 = hmc5843_regval_to_nanoscale[data->range];
+ *val2 = data->variant->regval_to_nanoscale[data->range];
return IIO_VAL_INT_PLUS_NANO;
};
return -EINVAL;
@@ -476,7 +564,8 @@ static int hmc5843_read_raw(struct iio_dev *indio_dev,
.type = IIO_MAGN, \
.modified = 1, \
.channel2 = IIO_MOD_##axis, \
- .info_mask = IIO_CHAN_INFO_SCALE_SHARED_BIT, \
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT | \
+ IIO_CHAN_INFO_SCALE_SHARED_BIT, \
.address = add \
}
@@ -486,12 +575,18 @@ static const struct iio_chan_spec hmc5843_channels[] = {
HMC5843_CHANNEL(Z, HMC5843_DATA_OUT_Z_MSB_REG),
};
+static const struct iio_chan_spec hmc5883_channels[] = {
+ HMC5843_CHANNEL(X, HMC5843_DATA_OUT_X_MSB_REG),
+ HMC5843_CHANNEL(Y, HMC5883_DATA_OUT_Y_MSB_REG),
+ HMC5843_CHANNEL(Z, HMC5883_DATA_OUT_Z_MSB_REG),
+};
+
static struct attribute *hmc5843_attributes[] = {
&iio_dev_attr_meas_conf.dev_attr.attr,
&iio_dev_attr_operating_mode.dev_attr.attr,
&iio_dev_attr_sampling_frequency.dev_attr.attr,
&iio_dev_attr_in_magn_range.dev_attr.attr,
- &iio_const_attr_sampling_frequency_available.dev_attr.attr,
+ &iio_dev_attr_sampling_frequency_available.dev_attr.attr,
NULL
};
@@ -499,6 +594,33 @@ static const struct attribute_group hmc5843_group = {
.attrs = hmc5843_attributes,
};
+static const struct hmc5843_chip_info hmc5843_chip_info_tbl[] = {
+ [HMC5843_ID] = {
+ .channels = hmc5843_channels,
+ .num_channels = ARRAY_SIZE(hmc5843_channels),
+ .regval_to_sample_freq = hmc5843_regval_to_sample_freq,
+ .regval_to_input_field_mga =
+ hmc5843_regval_to_input_field_mga,
+ .regval_to_nanoscale = hmc5843_regval_to_nanoscale,
+ },
+ [HMC5883_ID] = {
+ .channels = hmc5883_channels,
+ .num_channels = ARRAY_SIZE(hmc5883_channels),
+ .regval_to_sample_freq = hmc5883_regval_to_sample_freq,
+ .regval_to_input_field_mga =
+ hmc5883_regval_to_input_field_mga,
+ .regval_to_nanoscale = hmc5883_regval_to_nanoscale,
+ },
+ [HMC5883L_ID] = {
+ .channels = hmc5883_channels,
+ .num_channels = ARRAY_SIZE(hmc5883_channels),
+ .regval_to_sample_freq = hmc5883_regval_to_sample_freq,
+ .regval_to_input_field_mga =
+ hmc5883l_regval_to_input_field_mga,
+ .regval_to_nanoscale = hmc5883l_regval_to_nanoscale,
+ },
+};
+
static int hmc5843_detect(struct i2c_client *client,
struct i2c_board_info *info)
{
@@ -518,18 +640,23 @@ static int hmc5843_detect(struct i2c_client *client,
return 0;
}
-/* Called when we have found a new HMC5843. */
-static void hmc5843_init_client(struct i2c_client *client)
+/* Called when we have found a new HMC58X3 */
+static void hmc5843_init_client(struct i2c_client *client,
+ const struct i2c_device_id *id)
{
struct iio_dev *indio_dev = i2c_get_clientdata(client);
struct hmc5843_data *data = iio_priv(indio_dev);
+ data->variant = &hmc5843_chip_info_tbl[id->driver_data];
+ indio_dev->channels = data->variant->channels;
+ indio_dev->num_channels = data->variant->num_channels;
hmc5843_set_meas_conf(client, data->meas_conf);
hmc5843_set_rate(client, data->rate);
hmc5843_configure(client, data->operating_mode);
i2c_smbus_write_byte_data(client, HMC5843_CONFIG_REG_B, data->range);
mutex_init(&data->lock);
- pr_info("HMC5843 initialized\n");
+
+ pr_info("%s initialized\n", id->name);
}
static const struct iio_info hmc5843_info = {
@@ -538,54 +665,53 @@ static const struct iio_info hmc5843_info = {
.driver_module = THIS_MODULE,
};
-static int hmc5843_probe(struct i2c_client *client,
+static int __devinit hmc5843_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{
struct hmc5843_data *data;
struct iio_dev *indio_dev;
int err = 0;
- indio_dev = iio_allocate_device(sizeof(*data));
+ indio_dev = iio_device_alloc(sizeof(*data));
if (indio_dev == NULL) {
err = -ENOMEM;
goto exit;
}
- data = iio_priv(indio_dev);
- /* default settings at probe */
- data->meas_conf = CONF_NORMAL;
- data->range = RANGE_1_0;
- data->operating_mode = MODE_CONVERSION_CONTINUOUS;
+ /* default settings at probe */
+ data = iio_priv(indio_dev);
+ data->meas_conf = HMC5843_MEAS_CONF_NORMAL;
+ data->range = HMC5843_RANGE_GAIN_DEFAULT;
+ data->operating_mode = HMC5843_MODE_CONVERSION_CONTINUOUS;
i2c_set_clientdata(client, indio_dev);
-
- /* Initialize the HMC5843 chip */
- hmc5843_init_client(client);
+ hmc5843_init_client(client, id);
indio_dev->info = &hmc5843_info;
indio_dev->name = id->name;
- indio_dev->channels = hmc5843_channels;
- indio_dev->num_channels = ARRAY_SIZE(hmc5843_channels);
indio_dev->dev.parent = &client->dev;
indio_dev->modes = INDIO_DIRECT_MODE;
+
err = iio_device_register(indio_dev);
if (err)
goto exit_free2;
+
return 0;
+
exit_free2:
- iio_free_device(indio_dev);
+ iio_device_free(indio_dev);
exit:
return err;
}
-static int hmc5843_remove(struct i2c_client *client)
+static int __devexit hmc5843_remove(struct i2c_client *client)
{
struct iio_dev *indio_dev = i2c_get_clientdata(client);
iio_device_unregister(indio_dev);
/* sleep mode to save power */
- hmc5843_configure(client, MODE_SLEEP);
- iio_free_device(indio_dev);
+ hmc5843_configure(client, HMC5843_MODE_SLEEP);
+ iio_device_free(indio_dev);
return 0;
}
@@ -593,14 +719,18 @@ static int hmc5843_remove(struct i2c_client *client)
#ifdef CONFIG_PM_SLEEP
static int hmc5843_suspend(struct device *dev)
{
- hmc5843_configure(to_i2c_client(dev), MODE_SLEEP);
+ hmc5843_configure(to_i2c_client(dev), HMC5843_MODE_SLEEP);
return 0;
}
static int hmc5843_resume(struct device *dev)
{
- struct hmc5843_data *data = i2c_get_clientdata(to_i2c_client(dev));
- hmc5843_configure(to_i2c_client(dev), data->operating_mode);
+ struct i2c_client *client = to_i2c_client(dev);
+ struct iio_dev *indio_dev = i2c_get_clientdata(client);
+ struct hmc5843_data *data = iio_priv(indio_dev);
+
+ hmc5843_configure(client, data->operating_mode);
+
return 0;
}
@@ -611,7 +741,9 @@ static SIMPLE_DEV_PM_OPS(hmc5843_pm_ops, hmc5843_suspend, hmc5843_resume);
#endif
static const struct i2c_device_id hmc5843_id[] = {
- { "hmc5843", 0 },
+ { "hmc5843", HMC5843_ID },
+ { "hmc5883", HMC5883_ID },
+ { "hmc5883l", HMC5883L_ID },
{ }
};
MODULE_DEVICE_TABLE(i2c, hmc5843_id);
@@ -623,12 +755,12 @@ static struct i2c_driver hmc5843_driver = {
},
.id_table = hmc5843_id,
.probe = hmc5843_probe,
- .remove = hmc5843_remove,
+ .remove = __devexit_p(hmc5843_remove),
.detect = hmc5843_detect,
.address_list = normal_i2c,
};
module_i2c_driver(hmc5843_driver);
MODULE_AUTHOR("Shubhrajyoti Datta <shubhrajyoti@ti.com");
-MODULE_DESCRIPTION("HMC5843 driver");
+MODULE_DESCRIPTION("HMC5843/5883/5883L driver");
MODULE_LICENSE("GPL");
diff --git a/drivers/staging/iio/meter/ade7753.c b/drivers/staging/iio/meter/ade7753.c
index 57baac6c0d40..f04ece7fbc2f 100644
--- a/drivers/staging/iio/meter/ade7753.c
+++ b/drivers/staging/iio/meter/ade7753.c
@@ -18,8 +18,8 @@
#include <linux/list.h>
#include <linux/module.h>
-#include "../iio.h"
-#include "../sysfs.h"
+#include <linux/iio/iio.h>
+#include <linux/iio/sysfs.h>
#include "meter.h"
#include "ade7753.h"
@@ -28,7 +28,7 @@ static int ade7753_spi_write_reg_8(struct device *dev,
u8 val)
{
int ret;
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct ade7753_state *st = iio_priv(indio_dev);
mutex_lock(&st->buf_lock);
@@ -46,7 +46,7 @@ static int ade7753_spi_write_reg_16(struct device *dev,
u16 value)
{
int ret;
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct ade7753_state *st = iio_priv(indio_dev);
mutex_lock(&st->buf_lock);
@@ -63,7 +63,7 @@ static int ade7753_spi_read_reg_8(struct device *dev,
u8 reg_address,
u8 *val)
{
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct ade7753_state *st = iio_priv(indio_dev);
ssize_t ret;
@@ -82,7 +82,7 @@ static int ade7753_spi_read_reg_16(struct device *dev,
u8 reg_address,
u16 *val)
{
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct ade7753_state *st = iio_priv(indio_dev);
ssize_t ret;
@@ -104,7 +104,7 @@ static int ade7753_spi_read_reg_24(struct device *dev,
u32 *val)
{
struct spi_message msg;
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct ade7753_state *st = iio_priv(indio_dev);
int ret;
struct spi_transfer xfers[] = {
@@ -416,7 +416,7 @@ static ssize_t ade7753_write_frequency(struct device *dev,
const char *buf,
size_t len)
{
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct ade7753_state *st = iio_priv(indio_dev);
unsigned long val;
int ret;
@@ -517,7 +517,7 @@ static int __devinit ade7753_probe(struct spi_device *spi)
struct iio_dev *indio_dev;
/* setup the industrialio driver allocated elements */
- indio_dev = iio_allocate_device(sizeof(*st));
+ indio_dev = iio_device_alloc(sizeof(*st));
if (indio_dev == NULL) {
ret = -ENOMEM;
goto error_ret;
@@ -546,7 +546,7 @@ static int __devinit ade7753_probe(struct spi_device *spi)
return 0;
error_free_dev:
- iio_free_device(indio_dev);
+ iio_device_free(indio_dev);
error_ret:
return ret;
@@ -564,7 +564,7 @@ static int ade7753_remove(struct spi_device *spi)
if (ret)
goto err_ret;
- iio_free_device(indio_dev);
+ iio_device_free(indio_dev);
err_ret:
return ret;
}
diff --git a/drivers/staging/iio/meter/ade7754.c b/drivers/staging/iio/meter/ade7754.c
index 8d81c92007e9..6cee28a5e877 100644
--- a/drivers/staging/iio/meter/ade7754.c
+++ b/drivers/staging/iio/meter/ade7754.c
@@ -18,8 +18,8 @@
#include <linux/list.h>
#include <linux/module.h>
-#include "../iio.h"
-#include "../sysfs.h"
+#include <linux/iio/iio.h>
+#include <linux/iio/sysfs.h>
#include "meter.h"
#include "ade7754.h"
@@ -28,7 +28,7 @@ static int ade7754_spi_write_reg_8(struct device *dev,
u8 val)
{
int ret;
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct ade7754_state *st = iio_priv(indio_dev);
mutex_lock(&st->buf_lock);
@@ -46,7 +46,7 @@ static int ade7754_spi_write_reg_16(struct device *dev,
u16 value)
{
int ret;
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct ade7754_state *st = iio_priv(indio_dev);
mutex_lock(&st->buf_lock);
@@ -63,7 +63,7 @@ static int ade7754_spi_read_reg_8(struct device *dev,
u8 reg_address,
u8 *val)
{
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct ade7754_state *st = iio_priv(indio_dev);
int ret;
@@ -82,7 +82,7 @@ static int ade7754_spi_read_reg_16(struct device *dev,
u8 reg_address,
u16 *val)
{
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct ade7754_state *st = iio_priv(indio_dev);
int ret;
@@ -104,7 +104,7 @@ static int ade7754_spi_read_reg_24(struct device *dev,
u32 *val)
{
struct spi_message msg;
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct ade7754_state *st = iio_priv(indio_dev);
int ret;
struct spi_transfer xfers[] = {
@@ -436,7 +436,7 @@ static ssize_t ade7754_write_frequency(struct device *dev,
const char *buf,
size_t len)
{
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct ade7754_state *st = iio_priv(indio_dev);
unsigned long val;
int ret;
@@ -540,7 +540,7 @@ static int __devinit ade7754_probe(struct spi_device *spi)
struct iio_dev *indio_dev;
/* setup the industrialio driver allocated elements */
- indio_dev = iio_allocate_device(sizeof(*st));
+ indio_dev = iio_device_alloc(sizeof(*st));
if (indio_dev == NULL) {
ret = -ENOMEM;
goto error_ret;
@@ -568,7 +568,7 @@ static int __devinit ade7754_probe(struct spi_device *spi)
return 0;
error_free_dev:
- iio_free_device(indio_dev);
+ iio_device_free(indio_dev);
error_ret:
return ret;
@@ -585,7 +585,7 @@ static int ade7754_remove(struct spi_device *spi)
if (ret)
goto err_ret;
- iio_free_device(indio_dev);
+ iio_device_free(indio_dev);
err_ret:
return ret;
diff --git a/drivers/staging/iio/meter/ade7758.h b/drivers/staging/iio/meter/ade7758.h
index bdd1b05bf7a5..ec202b4ecfb2 100644
--- a/drivers/staging/iio/meter/ade7758.h
+++ b/drivers/staging/iio/meter/ade7758.h
@@ -122,7 +122,6 @@ struct ade7758_state {
u8 *tx;
u8 *rx;
struct mutex buf_lock;
- unsigned long available_scan_masks[AD7758_NUM_WAVESRC];
struct iio_chan_spec *ade7758_ring_channels;
struct spi_transfer ring_xfer[4];
struct spi_message ring_msg;
diff --git a/drivers/staging/iio/meter/ade7758_core.c b/drivers/staging/iio/meter/ade7758_core.c
index dcb20294dfe8..7014a0078446 100644
--- a/drivers/staging/iio/meter/ade7758_core.c
+++ b/drivers/staging/iio/meter/ade7758_core.c
@@ -18,9 +18,9 @@
#include <linux/list.h>
#include <linux/module.h>
-#include "../iio.h"
-#include "../sysfs.h"
-#include "../buffer.h"
+#include <linux/iio/iio.h>
+#include <linux/iio/sysfs.h>
+#include <linux/iio/buffer.h>
#include "meter.h"
#include "ade7758.h"
@@ -29,7 +29,7 @@ int ade7758_spi_write_reg_8(struct device *dev,
u8 val)
{
int ret;
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct ade7758_state *st = iio_priv(indio_dev);
mutex_lock(&st->buf_lock);
@@ -48,7 +48,7 @@ static int ade7758_spi_write_reg_16(struct device *dev,
{
int ret;
struct spi_message msg;
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct ade7758_state *st = iio_priv(indio_dev);
struct spi_transfer xfers[] = {
{
@@ -77,7 +77,7 @@ static int ade7758_spi_write_reg_24(struct device *dev,
{
int ret;
struct spi_message msg;
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct ade7758_state *st = iio_priv(indio_dev);
struct spi_transfer xfers[] = {
{
@@ -106,7 +106,7 @@ int ade7758_spi_read_reg_8(struct device *dev,
u8 *val)
{
struct spi_message msg;
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct ade7758_state *st = iio_priv(indio_dev);
int ret;
struct spi_transfer xfers[] = {
@@ -149,7 +149,7 @@ static int ade7758_spi_read_reg_16(struct device *dev,
u16 *val)
{
struct spi_message msg;
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct ade7758_state *st = iio_priv(indio_dev);
int ret;
struct spi_transfer xfers[] = {
@@ -195,7 +195,7 @@ static int ade7758_spi_read_reg_24(struct device *dev,
u32 *val)
{
struct spi_message msg;
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct ade7758_state *st = iio_priv(indio_dev);
int ret;
struct spi_transfer xfers[] = {
@@ -534,7 +534,7 @@ static ssize_t ade7758_write_frequency(struct device *dev,
const char *buf,
size_t len)
{
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
unsigned long val;
int ret;
u8 reg, t;
@@ -662,66 +662,217 @@ static const struct attribute_group ade7758_attribute_group = {
};
static struct iio_chan_spec ade7758_channels[] = {
- IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, "raw", 0, 0,
- IIO_CHAN_INFO_SCALE_SHARED_BIT,
- AD7758_WT(AD7758_PHASE_A, AD7758_VOLTAGE),
- 0, IIO_ST('s', 24, 32, 0), 0),
- IIO_CHAN(IIO_CURRENT, 0, 1, 0, "raw", 0, 0,
- IIO_CHAN_INFO_SCALE_SHARED_BIT,
- AD7758_WT(AD7758_PHASE_A, AD7758_CURRENT),
- 1, IIO_ST('s', 24, 32, 0), 0),
- IIO_CHAN(IIO_POWER, 0, 1, 0, "apparent_raw", 0, 0,
- IIO_CHAN_INFO_SCALE_SHARED_BIT,
- AD7758_WT(AD7758_PHASE_A, AD7758_APP_PWR),
- 2, IIO_ST('s', 24, 32, 0), 0),
- IIO_CHAN(IIO_POWER, 0, 1, 0, "active_raw", 0, 0,
- IIO_CHAN_INFO_SCALE_SHARED_BIT,
- AD7758_WT(AD7758_PHASE_A, AD7758_ACT_PWR),
- 3, IIO_ST('s', 24, 32, 0), 0),
- IIO_CHAN(IIO_POWER, 0, 1, 0, "reactive_raw", 0, 0,
- IIO_CHAN_INFO_SCALE_SHARED_BIT,
- AD7758_WT(AD7758_PHASE_A, AD7758_REACT_PWR),
- 4, IIO_ST('s', 24, 32, 0), 0),
- IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, "raw", 1, 0,
- IIO_CHAN_INFO_SCALE_SHARED_BIT,
- AD7758_WT(AD7758_PHASE_B, AD7758_VOLTAGE),
- 5, IIO_ST('s', 24, 32, 0), 0),
- IIO_CHAN(IIO_CURRENT, 0, 1, 0, "raw", 1, 0,
- IIO_CHAN_INFO_SCALE_SHARED_BIT,
- AD7758_WT(AD7758_PHASE_B, AD7758_CURRENT),
- 6, IIO_ST('s', 24, 32, 0), 0),
- IIO_CHAN(IIO_POWER, 0, 1, 0, "apparent_raw", 1, 0,
- IIO_CHAN_INFO_SCALE_SHARED_BIT,
- AD7758_WT(AD7758_PHASE_B, AD7758_APP_PWR),
- 7, IIO_ST('s', 24, 32, 0), 0),
- IIO_CHAN(IIO_POWER, 0, 1, 0, "active_raw", 1, 0,
- IIO_CHAN_INFO_SCALE_SHARED_BIT,
- AD7758_WT(AD7758_PHASE_B, AD7758_ACT_PWR),
- 8, IIO_ST('s', 24, 32, 0), 0),
- IIO_CHAN(IIO_POWER, 0, 1, 0, "reactive_raw", 1, 0,
- IIO_CHAN_INFO_SCALE_SHARED_BIT,
- AD7758_WT(AD7758_PHASE_B, AD7758_REACT_PWR),
- 9, IIO_ST('s', 24, 32, 0), 0),
- IIO_CHAN(IIO_VOLTAGE, 0, 1, 0, "raw", 2, 0,
- IIO_CHAN_INFO_SCALE_SHARED_BIT,
- AD7758_WT(AD7758_PHASE_C, AD7758_VOLTAGE),
- 10, IIO_ST('s', 24, 32, 0), 0),
- IIO_CHAN(IIO_CURRENT, 0, 1, 0, "raw", 2, 0,
- IIO_CHAN_INFO_SCALE_SHARED_BIT,
- AD7758_WT(AD7758_PHASE_C, AD7758_CURRENT),
- 11, IIO_ST('s', 24, 32, 0), 0),
- IIO_CHAN(IIO_POWER, 0, 1, 0, "apparent_raw", 2, 0,
- IIO_CHAN_INFO_SCALE_SHARED_BIT,
- AD7758_WT(AD7758_PHASE_C, AD7758_APP_PWR),
- 12, IIO_ST('s', 24, 32, 0), 0),
- IIO_CHAN(IIO_POWER, 0, 1, 0, "active_raw", 2, 0,
- IIO_CHAN_INFO_SCALE_SHARED_BIT,
- AD7758_WT(AD7758_PHASE_C, AD7758_ACT_PWR),
- 13, IIO_ST('s', 24, 32, 0), 0),
- IIO_CHAN(IIO_POWER, 0, 1, 0, "reactive_raw", 2, 0,
- IIO_CHAN_INFO_SCALE_SHARED_BIT,
- AD7758_WT(AD7758_PHASE_C, AD7758_REACT_PWR),
- 14, IIO_ST('s', 24, 32, 0), 0),
+ {
+ .type = IIO_VOLTAGE,
+ .indexed = 1,
+ .channel = 0,
+ .extend_name = "raw",
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
+ IIO_CHAN_INFO_SCALE_SHARED_BIT,
+ .address = AD7758_WT(AD7758_PHASE_A, AD7758_VOLTAGE),
+ .scan_index = 0,
+ .scan_type = {
+ .sign = 's',
+ .realbits = 24,
+ .storagebits = 32,
+ },
+ }, {
+ .type = IIO_CURRENT,
+ .indexed = 1,
+ .channel = 0,
+ .extend_name = "raw",
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
+ IIO_CHAN_INFO_SCALE_SHARED_BIT,
+ .address = AD7758_WT(AD7758_PHASE_A, AD7758_CURRENT),
+ .scan_index = 1,
+ .scan_type = {
+ .sign = 's',
+ .realbits = 24,
+ .storagebits = 32,
+ },
+ }, {
+ .type = IIO_POWER,
+ .indexed = 1,
+ .channel = 0,
+ .extend_name = "apparent_raw",
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
+ IIO_CHAN_INFO_SCALE_SHARED_BIT,
+ .address = AD7758_WT(AD7758_PHASE_A, AD7758_APP_PWR),
+ .scan_index = 2,
+ .scan_type = {
+ .sign = 's',
+ .realbits = 24,
+ .storagebits = 32,
+ },
+ }, {
+ .type = IIO_POWER,
+ .indexed = 1,
+ .channel = 0,
+ .extend_name = "active_raw",
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
+ IIO_CHAN_INFO_SCALE_SHARED_BIT,
+ .address = AD7758_WT(AD7758_PHASE_A, AD7758_ACT_PWR),
+ .scan_index = 3,
+ .scan_type = {
+ .sign = 's',
+ .realbits = 24,
+ .storagebits = 32,
+ },
+ }, {
+ .type = IIO_POWER,
+ .indexed = 1,
+ .channel = 0,
+ .extend_name = "reactive_raw",
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
+ IIO_CHAN_INFO_SCALE_SHARED_BIT,
+ .address = AD7758_WT(AD7758_PHASE_A, AD7758_REACT_PWR),
+ .scan_index = 4,
+ .scan_type = {
+ .sign = 's',
+ .realbits = 24,
+ .storagebits = 32,
+ },
+ }, {
+ .type = IIO_VOLTAGE,
+ .indexed = 1,
+ .channel = 1,
+ .extend_name = "raw",
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
+ IIO_CHAN_INFO_SCALE_SHARED_BIT,
+ .address = AD7758_WT(AD7758_PHASE_B, AD7758_VOLTAGE),
+ .scan_index = 5,
+ .scan_type = {
+ .sign = 's',
+ .realbits = 24,
+ .storagebits = 32,
+ },
+ }, {
+ .type = IIO_CURRENT,
+ .indexed = 1,
+ .channel = 1,
+ .extend_name = "raw",
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
+ IIO_CHAN_INFO_SCALE_SHARED_BIT,
+ .address = AD7758_WT(AD7758_PHASE_B, AD7758_CURRENT),
+ .scan_index = 6,
+ .scan_type = {
+ .sign = 's',
+ .realbits = 24,
+ .storagebits = 32,
+ },
+ }, {
+ .type = IIO_POWER,
+ .indexed = 1,
+ .channel = 1,
+ .extend_name = "apparent_raw",
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
+ IIO_CHAN_INFO_SCALE_SHARED_BIT,
+ .address = AD7758_WT(AD7758_PHASE_B, AD7758_APP_PWR),
+ .scan_index = 7,
+ .scan_type = {
+ .sign = 's',
+ .realbits = 24,
+ .storagebits = 32,
+ },
+ }, {
+ .type = IIO_POWER,
+ .indexed = 1,
+ .channel = 1,
+ .extend_name = "active_raw",
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
+ IIO_CHAN_INFO_SCALE_SHARED_BIT,
+ .address = AD7758_WT(AD7758_PHASE_B, AD7758_ACT_PWR),
+ .scan_index = 8,
+ .scan_type = {
+ .sign = 's',
+ .realbits = 24,
+ .storagebits = 32,
+ },
+ }, {
+ .type = IIO_POWER,
+ .indexed = 1,
+ .channel = 1,
+ .extend_name = "reactive_raw",
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
+ IIO_CHAN_INFO_SCALE_SHARED_BIT,
+ .address = AD7758_WT(AD7758_PHASE_B, AD7758_REACT_PWR),
+ .scan_index = 9,
+ .scan_type = {
+ .sign = 's',
+ .realbits = 24,
+ .storagebits = 32,
+ },
+ }, {
+ .type = IIO_VOLTAGE,
+ .indexed = 1,
+ .channel = 2,
+ .extend_name = "raw",
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
+ IIO_CHAN_INFO_SCALE_SHARED_BIT,
+ .address = AD7758_WT(AD7758_PHASE_C, AD7758_VOLTAGE),
+ .scan_index = 10,
+ .scan_type = {
+ .sign = 's',
+ .realbits = 24,
+ .storagebits = 32,
+ },
+ }, {
+ .type = IIO_CURRENT,
+ .indexed = 1,
+ .channel = 2,
+ .extend_name = "raw",
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
+ IIO_CHAN_INFO_SCALE_SHARED_BIT,
+ .address = AD7758_WT(AD7758_PHASE_C, AD7758_CURRENT),
+ .scan_index = 11,
+ .scan_type = {
+ .sign = 's',
+ .realbits = 24,
+ .storagebits = 32,
+ },
+ }, {
+ .type = IIO_POWER,
+ .indexed = 1,
+ .channel = 2,
+ .extend_name = "apparent_raw",
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
+ IIO_CHAN_INFO_SCALE_SHARED_BIT,
+ .address = AD7758_WT(AD7758_PHASE_C, AD7758_APP_PWR),
+ .scan_index = 12,
+ .scan_type = {
+ .sign = 's',
+ .realbits = 24,
+ .storagebits = 32,
+ },
+ }, {
+ .type = IIO_POWER,
+ .indexed = 1,
+ .channel = 2,
+ .extend_name = "active_raw",
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
+ IIO_CHAN_INFO_SCALE_SHARED_BIT,
+ .address = AD7758_WT(AD7758_PHASE_C, AD7758_ACT_PWR),
+ .scan_index = 13,
+ .scan_type = {
+ .sign = 's',
+ .realbits = 24,
+ .storagebits = 32,
+ },
+ }, {
+ .type = IIO_POWER,
+ .indexed = 1,
+ .channel = 2,
+ .extend_name = "reactive_raw",
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
+ IIO_CHAN_INFO_SCALE_SHARED_BIT,
+ .address = AD7758_WT(AD7758_PHASE_C, AD7758_REACT_PWR),
+ .scan_index = 14,
+ .scan_type = {
+ .sign = 's',
+ .realbits = 24,
+ .storagebits = 32,
+ },
+ },
IIO_CHAN_SOFT_TIMESTAMP(15),
};
@@ -732,9 +883,9 @@ static const struct iio_info ade7758_info = {
static int __devinit ade7758_probe(struct spi_device *spi)
{
- int i, ret;
+ int ret;
struct ade7758_state *st;
- struct iio_dev *indio_dev = iio_allocate_device(sizeof(*st));
+ struct iio_dev *indio_dev = iio_device_alloc(sizeof(*st));
if (indio_dev == NULL) {
ret = -ENOMEM;
@@ -765,11 +916,6 @@ static int __devinit ade7758_probe(struct spi_device *spi)
indio_dev->info = &ade7758_info;
indio_dev->modes = INDIO_DIRECT_MODE;
- for (i = 0; i < AD7758_NUM_WAVESRC; i++)
- set_bit(i, &st->available_scan_masks[i]);
-
- indio_dev->available_scan_masks = st->available_scan_masks;
-
ret = ade7758_configure_ring(indio_dev);
if (ret)
goto error_free_tx;
@@ -800,7 +946,7 @@ static int __devinit ade7758_probe(struct spi_device *spi)
return 0;
error_remove_trigger:
- if (indio_dev->modes & INDIO_BUFFER_TRIGGERED)
+ if (spi->irq)
ade7758_remove_trigger(indio_dev);
error_uninitialize_ring:
ade7758_uninitialize_ring(indio_dev);
@@ -811,7 +957,7 @@ error_free_tx:
error_free_rx:
kfree(st->rx);
error_free_dev:
- iio_free_device(indio_dev);
+ iio_device_free(indio_dev);
error_ret:
return ret;
}
@@ -833,7 +979,7 @@ static int ade7758_remove(struct spi_device *spi)
kfree(st->tx);
kfree(st->rx);
- iio_free_device(indio_dev);
+ iio_device_free(indio_dev);
err_ret:
return ret;
diff --git a/drivers/staging/iio/meter/ade7758_ring.c b/drivers/staging/iio/meter/ade7758_ring.c
index c45b23bb1229..1ce10b21f4d6 100644
--- a/drivers/staging/iio/meter/ade7758_ring.c
+++ b/drivers/staging/iio/meter/ade7758_ring.c
@@ -12,18 +12,17 @@
#include <linux/slab.h>
#include <asm/unaligned.h>
-#include "../iio.h"
+#include <linux/iio/iio.h>
#include "../ring_sw.h"
-#include "../trigger_consumer.h"
+#include <linux/iio/trigger_consumer.h>
#include "ade7758.h"
/**
* ade7758_spi_read_burst() - read data registers
- * @dev: device associated with child of actual device (iio_dev or iio_trig)
+ * @indio_dev: the IIO device
**/
-static int ade7758_spi_read_burst(struct device *dev)
+static int ade7758_spi_read_burst(struct iio_dev *indio_dev)
{
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
struct ade7758_state *st = iio_priv(indio_dev);
int ret;
@@ -68,11 +67,11 @@ static irqreturn_t ade7758_trigger_handler(int irq, void *p)
u32 *dat32 = (u32 *)dat64;
if (!bitmap_empty(indio_dev->active_scan_mask, indio_dev->masklength))
- if (ade7758_spi_read_burst(&indio_dev->dev) >= 0)
+ if (ade7758_spi_read_burst(indio_dev) >= 0)
*dat32 = get_unaligned_be32(&st->rx_buf[5]) & 0xFFFFFF;
/* Guaranteed to be aligned with 8 byte boundary */
- if (ring->scan_timestamp)
+ if (indio_dev->scan_timestamp)
dat64[1] = pf->timestamp;
ring->access->store_to(ring, (u8 *)dat64, pf->timestamp);
@@ -92,29 +91,19 @@ static irqreturn_t ade7758_trigger_handler(int irq, void *p)
static int ade7758_ring_preenable(struct iio_dev *indio_dev)
{
struct ade7758_state *st = iio_priv(indio_dev);
- struct iio_buffer *ring = indio_dev->buffer;
- size_t d_size;
unsigned channel;
+ int ret;
if (!bitmap_empty(indio_dev->active_scan_mask, indio_dev->masklength))
return -EINVAL;
+ ret = iio_sw_buffer_preenable(indio_dev);
+ if (ret < 0)
+ return ret;
+
channel = find_first_bit(indio_dev->active_scan_mask,
indio_dev->masklength);
- d_size = st->ade7758_ring_channels[channel].scan_type.storagebits / 8;
-
- if (ring->scan_timestamp) {
- d_size += sizeof(s64);
-
- if (d_size % sizeof(s64))
- d_size += sizeof(s64) - (d_size % sizeof(s64));
- }
-
- if (indio_dev->buffer->access->set_bytes_per_datum)
- indio_dev->buffer->access->
- set_bytes_per_datum(indio_dev->buffer, d_size);
-
ade7758_write_waveform_type(&indio_dev->dev,
st->ade7758_ring_channels[channel].address);
@@ -125,6 +114,7 @@ static const struct iio_buffer_setup_ops ade7758_ring_setup_ops = {
.preenable = &ade7758_ring_preenable,
.postenable = &iio_triggered_buffer_postenable,
.predisable = &iio_triggered_buffer_predisable,
+ .validate_scan_mask = &iio_validate_scan_mask_onehot,
};
void ade7758_unconfigure_ring(struct iio_dev *indio_dev)
diff --git a/drivers/staging/iio/meter/ade7758_trigger.c b/drivers/staging/iio/meter/ade7758_trigger.c
index b6569c706651..f9c6a340092b 100644
--- a/drivers/staging/iio/meter/ade7758_trigger.c
+++ b/drivers/staging/iio/meter/ade7758_trigger.c
@@ -11,8 +11,8 @@
#include <linux/spi/spi.h>
#include <linux/export.h>
-#include "../iio.h"
-#include "../trigger.h"
+#include <linux/iio/iio.h>
+#include <linux/iio/trigger.h>
#include "ade7758.h"
/**
@@ -63,7 +63,7 @@ int ade7758_probe_trigger(struct iio_dev *indio_dev)
struct ade7758_state *st = iio_priv(indio_dev);
int ret;
- st->trig = iio_allocate_trigger("%s-dev%d",
+ st->trig = iio_trigger_alloc("%s-dev%d",
spi_get_device_id(st->us)->name,
indio_dev->id);
if (st->trig == NULL) {
@@ -94,7 +94,7 @@ int ade7758_probe_trigger(struct iio_dev *indio_dev)
error_free_irq:
free_irq(st->us->irq, st->trig);
error_free_trig:
- iio_free_trigger(st->trig);
+ iio_trigger_free(st->trig);
error_ret:
return ret;
}
@@ -105,5 +105,5 @@ void ade7758_remove_trigger(struct iio_dev *indio_dev)
iio_trigger_unregister(st->trig);
free_irq(st->us->irq, st->trig);
- iio_free_trigger(st->trig);
+ iio_trigger_free(st->trig);
}
diff --git a/drivers/staging/iio/meter/ade7759.c b/drivers/staging/iio/meter/ade7759.c
index 0beab478dcd9..b3f7e0fa9612 100644
--- a/drivers/staging/iio/meter/ade7759.c
+++ b/drivers/staging/iio/meter/ade7759.c
@@ -18,8 +18,8 @@
#include <linux/list.h>
#include <linux/module.h>
-#include "../iio.h"
-#include "../sysfs.h"
+#include <linux/iio/iio.h>
+#include <linux/iio/sysfs.h>
#include "meter.h"
#include "ade7759.h"
@@ -28,7 +28,7 @@ static int ade7759_spi_write_reg_8(struct device *dev,
u8 val)
{
int ret;
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct ade7759_state *st = iio_priv(indio_dev);
mutex_lock(&st->buf_lock);
@@ -46,7 +46,7 @@ static int ade7759_spi_write_reg_16(struct device *dev,
u16 value)
{
int ret;
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct ade7759_state *st = iio_priv(indio_dev);
mutex_lock(&st->buf_lock);
@@ -63,7 +63,7 @@ static int ade7759_spi_read_reg_8(struct device *dev,
u8 reg_address,
u8 *val)
{
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct ade7759_state *st = iio_priv(indio_dev);
int ret;
@@ -82,7 +82,7 @@ static int ade7759_spi_read_reg_16(struct device *dev,
u8 reg_address,
u16 *val)
{
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct ade7759_state *st = iio_priv(indio_dev);
int ret;
@@ -104,7 +104,7 @@ static int ade7759_spi_read_reg_40(struct device *dev,
u64 *val)
{
struct spi_message msg;
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct ade7759_state *st = iio_priv(indio_dev);
int ret;
struct spi_transfer xfers[] = {
@@ -376,7 +376,7 @@ static ssize_t ade7759_write_frequency(struct device *dev,
const char *buf,
size_t len)
{
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct ade7759_state *st = iio_priv(indio_dev);
unsigned long val;
int ret;
@@ -463,7 +463,7 @@ static int __devinit ade7759_probe(struct spi_device *spi)
struct iio_dev *indio_dev;
/* setup the industrialio driver allocated elements */
- indio_dev = iio_allocate_device(sizeof(*st));
+ indio_dev = iio_device_alloc(sizeof(*st));
if (indio_dev == NULL) {
ret = -ENOMEM;
goto error_ret;
@@ -491,7 +491,7 @@ static int __devinit ade7759_probe(struct spi_device *spi)
return 0;
error_free_dev:
- iio_free_device(indio_dev);
+ iio_device_free(indio_dev);
error_ret:
return ret;
}
@@ -507,7 +507,7 @@ static int ade7759_remove(struct spi_device *spi)
if (ret)
goto err_ret;
- iio_free_device(indio_dev);
+ iio_device_free(indio_dev);
err_ret:
return ret;
diff --git a/drivers/staging/iio/meter/ade7854-i2c.c b/drivers/staging/iio/meter/ade7854-i2c.c
index 1e1faa0479d3..06090465fa5f 100644
--- a/drivers/staging/iio/meter/ade7854-i2c.c
+++ b/drivers/staging/iio/meter/ade7854-i2c.c
@@ -12,7 +12,7 @@
#include <linux/slab.h>
#include <linux/module.h>
-#include "../iio.h"
+#include <linux/iio/iio.h>
#include "ade7854.h"
static int ade7854_i2c_write_reg_8(struct device *dev,
@@ -20,7 +20,7 @@ static int ade7854_i2c_write_reg_8(struct device *dev,
u8 value)
{
int ret;
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct ade7854_state *st = iio_priv(indio_dev);
mutex_lock(&st->buf_lock);
@@ -39,7 +39,7 @@ static int ade7854_i2c_write_reg_16(struct device *dev,
u16 value)
{
int ret;
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct ade7854_state *st = iio_priv(indio_dev);
mutex_lock(&st->buf_lock);
@@ -59,7 +59,7 @@ static int ade7854_i2c_write_reg_24(struct device *dev,
u32 value)
{
int ret;
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct ade7854_state *st = iio_priv(indio_dev);
mutex_lock(&st->buf_lock);
@@ -80,7 +80,7 @@ static int ade7854_i2c_write_reg_32(struct device *dev,
u32 value)
{
int ret;
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct ade7854_state *st = iio_priv(indio_dev);
mutex_lock(&st->buf_lock);
@@ -101,7 +101,7 @@ static int ade7854_i2c_read_reg_8(struct device *dev,
u16 reg_address,
u8 *val)
{
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct ade7854_state *st = iio_priv(indio_dev);
int ret;
@@ -127,7 +127,7 @@ static int ade7854_i2c_read_reg_16(struct device *dev,
u16 reg_address,
u16 *val)
{
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct ade7854_state *st = iio_priv(indio_dev);
int ret;
@@ -153,7 +153,7 @@ static int ade7854_i2c_read_reg_24(struct device *dev,
u16 reg_address,
u32 *val)
{
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct ade7854_state *st = iio_priv(indio_dev);
int ret;
@@ -179,7 +179,7 @@ static int ade7854_i2c_read_reg_32(struct device *dev,
u16 reg_address,
u32 *val)
{
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct ade7854_state *st = iio_priv(indio_dev);
int ret;
@@ -208,7 +208,7 @@ static int __devinit ade7854_i2c_probe(struct i2c_client *client,
struct ade7854_state *st;
struct iio_dev *indio_dev;
- indio_dev = iio_allocate_device(sizeof(*st));
+ indio_dev = iio_device_alloc(sizeof(*st));
if (indio_dev == NULL)
return -ENOMEM;
st = iio_priv(indio_dev);
@@ -226,7 +226,7 @@ static int __devinit ade7854_i2c_probe(struct i2c_client *client,
ret = ade7854_probe(indio_dev, &client->dev);
if (ret)
- iio_free_device(indio_dev);
+ iio_device_free(indio_dev);
return ret;
}
diff --git a/drivers/staging/iio/meter/ade7854-spi.c b/drivers/staging/iio/meter/ade7854-spi.c
index 81121862c1bd..9fb2f8bfca81 100644
--- a/drivers/staging/iio/meter/ade7854-spi.c
+++ b/drivers/staging/iio/meter/ade7854-spi.c
@@ -12,7 +12,7 @@
#include <linux/slab.h>
#include <linux/module.h>
-#include "../iio.h"
+#include <linux/iio/iio.h>
#include "ade7854.h"
static int ade7854_spi_write_reg_8(struct device *dev,
@@ -21,7 +21,7 @@ static int ade7854_spi_write_reg_8(struct device *dev,
{
int ret;
struct spi_message msg;
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct ade7854_state *st = iio_priv(indio_dev);
struct spi_transfer xfer = {
.tx_buf = st->tx,
@@ -49,7 +49,7 @@ static int ade7854_spi_write_reg_16(struct device *dev,
{
int ret;
struct spi_message msg;
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct ade7854_state *st = iio_priv(indio_dev);
struct spi_transfer xfer = {
.tx_buf = st->tx,
@@ -78,7 +78,7 @@ static int ade7854_spi_write_reg_24(struct device *dev,
{
int ret;
struct spi_message msg;
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct ade7854_state *st = iio_priv(indio_dev);
struct spi_transfer xfer = {
.tx_buf = st->tx,
@@ -108,7 +108,7 @@ static int ade7854_spi_write_reg_32(struct device *dev,
{
int ret;
struct spi_message msg;
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct ade7854_state *st = iio_priv(indio_dev);
struct spi_transfer xfer = {
.tx_buf = st->tx,
@@ -138,7 +138,7 @@ static int ade7854_spi_read_reg_8(struct device *dev,
u8 *val)
{
struct spi_message msg;
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct ade7854_state *st = iio_priv(indio_dev);
int ret;
struct spi_transfer xfers[] = {
@@ -180,7 +180,7 @@ static int ade7854_spi_read_reg_16(struct device *dev,
u16 *val)
{
struct spi_message msg;
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct ade7854_state *st = iio_priv(indio_dev);
int ret;
struct spi_transfer xfers[] = {
@@ -221,7 +221,7 @@ static int ade7854_spi_read_reg_24(struct device *dev,
u32 *val)
{
struct spi_message msg;
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct ade7854_state *st = iio_priv(indio_dev);
int ret;
struct spi_transfer xfers[] = {
@@ -263,7 +263,7 @@ static int ade7854_spi_read_reg_32(struct device *dev,
u32 *val)
{
struct spi_message msg;
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct ade7854_state *st = iio_priv(indio_dev);
int ret;
struct spi_transfer xfers[] = {
@@ -306,7 +306,7 @@ static int __devinit ade7854_spi_probe(struct spi_device *spi)
struct ade7854_state *st;
struct iio_dev *indio_dev;
- indio_dev = iio_allocate_device(sizeof(*st));
+ indio_dev = iio_device_alloc(sizeof(*st));
if (indio_dev == NULL)
return -ENOMEM;
st = iio_priv(indio_dev);
@@ -325,7 +325,7 @@ static int __devinit ade7854_spi_probe(struct spi_device *spi)
ret = ade7854_probe(indio_dev, &spi->dev);
if (ret)
- iio_free_device(indio_dev);
+ iio_device_free(indio_dev);
return 0;
}
diff --git a/drivers/staging/iio/meter/ade7854.c b/drivers/staging/iio/meter/ade7854.c
index 49c01c5c1b59..c642da84842a 100644
--- a/drivers/staging/iio/meter/ade7854.c
+++ b/drivers/staging/iio/meter/ade7854.c
@@ -17,8 +17,8 @@
#include <linux/list.h>
#include <linux/module.h>
-#include "../iio.h"
-#include "../sysfs.h"
+#include <linux/iio/iio.h>
+#include <linux/iio/sysfs.h>
#include "meter.h"
#include "ade7854.h"
@@ -28,7 +28,7 @@ static ssize_t ade7854_read_8bit(struct device *dev,
{
int ret;
u8 val = 0;
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct ade7854_state *st = iio_priv(indio_dev);
struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
@@ -45,7 +45,7 @@ static ssize_t ade7854_read_16bit(struct device *dev,
{
int ret;
u16 val = 0;
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct ade7854_state *st = iio_priv(indio_dev);
struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
@@ -62,7 +62,7 @@ static ssize_t ade7854_read_24bit(struct device *dev,
{
int ret;
u32 val;
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct ade7854_state *st = iio_priv(indio_dev);
struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
@@ -80,7 +80,7 @@ static ssize_t ade7854_read_32bit(struct device *dev,
int ret;
u32 val = 0;
struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct ade7854_state *st = iio_priv(indio_dev);
ret = st->read_reg_32(dev, this_attr->address, &val);
@@ -96,7 +96,7 @@ static ssize_t ade7854_write_8bit(struct device *dev,
size_t len)
{
struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct ade7854_state *st = iio_priv(indio_dev);
int ret;
@@ -117,7 +117,7 @@ static ssize_t ade7854_write_16bit(struct device *dev,
size_t len)
{
struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct ade7854_state *st = iio_priv(indio_dev);
int ret;
@@ -138,7 +138,7 @@ static ssize_t ade7854_write_24bit(struct device *dev,
size_t len)
{
struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct ade7854_state *st = iio_priv(indio_dev);
int ret;
@@ -159,7 +159,7 @@ static ssize_t ade7854_write_32bit(struct device *dev,
size_t len)
{
struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct ade7854_state *st = iio_priv(indio_dev);
int ret;
@@ -176,7 +176,7 @@ error_ret:
static int ade7854_reset(struct device *dev)
{
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct ade7854_state *st = iio_priv(indio_dev);
u16 val;
@@ -425,7 +425,7 @@ static IIO_DEV_ATTR_CVAHR(ade7854_read_32bit,
static int ade7854_set_irq(struct device *dev, bool enable)
{
- struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct ade7854_state *st = iio_priv(indio_dev);
int ret;
@@ -581,7 +581,7 @@ int ade7854_probe(struct iio_dev *indio_dev, struct device *dev)
error_unreg_dev:
iio_device_unregister(indio_dev);
error_free_dev:
- iio_free_device(indio_dev);
+ iio_device_free(indio_dev);
return ret;
}
@@ -590,7 +590,7 @@ EXPORT_SYMBOL(ade7854_probe);
int ade7854_remove(struct iio_dev *indio_dev)
{
iio_device_unregister(indio_dev);
- iio_free_device(indio_dev);
+ iio_device_free(indio_dev);
return 0;
}
diff --git a/drivers/staging/iio/meter/meter.h b/drivers/staging/iio/meter/meter.h
index 6a3db1423631..23e1b5f480a9 100644
--- a/drivers/staging/iio/meter/meter.h
+++ b/drivers/staging/iio/meter/meter.h
@@ -1,4 +1,4 @@
-#include "../sysfs.h"
+#include <linux/iio/sysfs.h>
/* metering ic types of attribute */
diff --git a/drivers/staging/iio/resolver/ad2s1200.c b/drivers/staging/iio/resolver/ad2s1200.c
index d8ce854c1897..8b71eb0e16f5 100644
--- a/drivers/staging/iio/resolver/ad2s1200.c
+++ b/drivers/staging/iio/resolver/ad2s1200.c
@@ -19,8 +19,8 @@
#include <linux/gpio.h>
#include <linux/module.h>
-#include "../iio.h"
-#include "../sysfs.h"
+#include <linux/iio/iio.h>
+#include <linux/iio/sysfs.h>
#define DRV_NAME "ad2s1200"
@@ -85,10 +85,12 @@ static const struct iio_chan_spec ad2s1200_channels[] = {
.type = IIO_ANGL,
.indexed = 1,
.channel = 0,
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT,
}, {
.type = IIO_ANGL_VEL,
.indexed = 1,
.channel = 0,
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT,
}
};
@@ -110,7 +112,7 @@ static int __devinit ad2s1200_probe(struct spi_device *spi)
DRV_NAME, pins[pn]);
goto error_ret;
}
- indio_dev = iio_allocate_device(sizeof(*st));
+ indio_dev = iio_device_alloc(sizeof(*st));
if (indio_dev == NULL) {
ret = -ENOMEM;
goto error_ret;
@@ -140,7 +142,7 @@ static int __devinit ad2s1200_probe(struct spi_device *spi)
return 0;
error_free_dev:
- iio_free_device(indio_dev);
+ iio_device_free(indio_dev);
error_ret:
for (--pn; pn >= 0; pn--)
gpio_free(pins[pn]);
@@ -150,7 +152,7 @@ error_ret:
static int __devexit ad2s1200_remove(struct spi_device *spi)
{
iio_device_unregister(spi_get_drvdata(spi));
- iio_free_device(spi_get_drvdata(spi));
+ iio_device_free(spi_get_drvdata(spi));
return 0;
}
diff --git a/drivers/staging/iio/resolver/ad2s1210.c b/drivers/staging/iio/resolver/ad2s1210.c
index c439fcf72be7..f313859476c1 100644
--- a/drivers/staging/iio/resolver/ad2s1210.c
+++ b/drivers/staging/iio/resolver/ad2s1210.c
@@ -18,8 +18,8 @@
#include <linux/gpio.h>
#include <linux/module.h>
-#include "../iio.h"
-#include "../sysfs.h"
+#include <linux/iio/iio.h>
+#include <linux/iio/sysfs.h>
#include "ad2s1210.h"
#define DRV_NAME "ad2s1210"
@@ -200,7 +200,7 @@ static ssize_t ad2s1210_store_softreset(struct device *dev,
const char *buf,
size_t len)
{
- struct ad2s1210_state *st = iio_priv(dev_get_drvdata(dev));
+ struct ad2s1210_state *st = iio_priv(dev_to_iio_dev(dev));
int ret;
mutex_lock(&st->lock);
@@ -214,7 +214,7 @@ static ssize_t ad2s1210_show_fclkin(struct device *dev,
struct device_attribute *attr,
char *buf)
{
- struct ad2s1210_state *st = iio_priv(dev_get_drvdata(dev));
+ struct ad2s1210_state *st = iio_priv(dev_to_iio_dev(dev));
return sprintf(buf, "%d\n", st->fclkin);
}
@@ -223,7 +223,7 @@ static ssize_t ad2s1210_store_fclkin(struct device *dev,
const char *buf,
size_t len)
{
- struct ad2s1210_state *st = iio_priv(dev_get_drvdata(dev));
+ struct ad2s1210_state *st = iio_priv(dev_to_iio_dev(dev));
unsigned long fclkin;
int ret;
@@ -252,7 +252,7 @@ static ssize_t ad2s1210_show_fexcit(struct device *dev,
struct device_attribute *attr,
char *buf)
{
- struct ad2s1210_state *st = iio_priv(dev_get_drvdata(dev));
+ struct ad2s1210_state *st = iio_priv(dev_to_iio_dev(dev));
return sprintf(buf, "%d\n", st->fexcit);
}
@@ -260,7 +260,7 @@ static ssize_t ad2s1210_store_fexcit(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t len)
{
- struct ad2s1210_state *st = iio_priv(dev_get_drvdata(dev));
+ struct ad2s1210_state *st = iio_priv(dev_to_iio_dev(dev));
unsigned long fexcit;
int ret;
@@ -287,7 +287,7 @@ static ssize_t ad2s1210_show_control(struct device *dev,
struct device_attribute *attr,
char *buf)
{
- struct ad2s1210_state *st = iio_priv(dev_get_drvdata(dev));
+ struct ad2s1210_state *st = iio_priv(dev_to_iio_dev(dev));
int ret;
mutex_lock(&st->lock);
ret = ad2s1210_config_read(st, AD2S1210_REG_CONTROL);
@@ -299,7 +299,7 @@ static ssize_t ad2s1210_store_control(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t len)
{
- struct ad2s1210_state *st = iio_priv(dev_get_drvdata(dev));
+ struct ad2s1210_state *st = iio_priv(dev_to_iio_dev(dev));
unsigned long udata;
unsigned char data;
int ret;
@@ -345,7 +345,7 @@ error_ret:
static ssize_t ad2s1210_show_resolution(struct device *dev,
struct device_attribute *attr, char *buf)
{
- struct ad2s1210_state *st = iio_priv(dev_get_drvdata(dev));
+ struct ad2s1210_state *st = iio_priv(dev_to_iio_dev(dev));
return sprintf(buf, "%d\n", st->resolution);
}
@@ -353,7 +353,7 @@ static ssize_t ad2s1210_store_resolution(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t len)
{
- struct ad2s1210_state *st = iio_priv(dev_get_drvdata(dev));
+ struct ad2s1210_state *st = iio_priv(dev_to_iio_dev(dev));
unsigned char data;
unsigned long udata;
int ret;
@@ -403,7 +403,7 @@ error_ret:
static ssize_t ad2s1210_show_fault(struct device *dev,
struct device_attribute *attr, char *buf)
{
- struct ad2s1210_state *st = iio_priv(dev_get_drvdata(dev));
+ struct ad2s1210_state *st = iio_priv(dev_to_iio_dev(dev));
int ret;
mutex_lock(&st->lock);
@@ -418,7 +418,7 @@ static ssize_t ad2s1210_clear_fault(struct device *dev,
const char *buf,
size_t len)
{
- struct ad2s1210_state *st = iio_priv(dev_get_drvdata(dev));
+ struct ad2s1210_state *st = iio_priv(dev_to_iio_dev(dev));
int ret;
mutex_lock(&st->lock);
@@ -441,7 +441,7 @@ static ssize_t ad2s1210_show_reg(struct device *dev,
struct device_attribute *attr,
char *buf)
{
- struct ad2s1210_state *st = iio_priv(dev_get_drvdata(dev));
+ struct ad2s1210_state *st = iio_priv(dev_to_iio_dev(dev));
struct iio_dev_attr *iattr = to_iio_dev_attr(attr);
int ret;
@@ -455,7 +455,7 @@ static ssize_t ad2s1210_show_reg(struct device *dev,
static ssize_t ad2s1210_store_reg(struct device *dev,
struct device_attribute *attr, const char *buf, size_t len)
{
- struct ad2s1210_state *st = iio_priv(dev_get_drvdata(dev));
+ struct ad2s1210_state *st = iio_priv(dev_to_iio_dev(dev));
unsigned long data;
int ret;
struct iio_dev_attr *iattr = to_iio_dev_attr(attr);
@@ -580,10 +580,12 @@ static struct iio_chan_spec ad2s1210_channels[] = {
.type = IIO_ANGL,
.indexed = 1,
.channel = 0,
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT,
}, {
.type = IIO_ANGL_VEL,
.indexed = 1,
.channel = 0,
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT,
}
};
@@ -688,7 +690,7 @@ static int __devinit ad2s1210_probe(struct spi_device *spi)
if (spi->dev.platform_data == NULL)
return -EINVAL;
- indio_dev = iio_allocate_device(sizeof(*st));
+ indio_dev = iio_device_alloc(sizeof(*st));
if (indio_dev == NULL) {
ret = -ENOMEM;
goto error_ret;
@@ -729,7 +731,7 @@ static int __devinit ad2s1210_probe(struct spi_device *spi)
error_free_gpios:
ad2s1210_free_gpios(st);
error_free_dev:
- iio_free_device(indio_dev);
+ iio_device_free(indio_dev);
error_ret:
return ret;
}
@@ -740,7 +742,7 @@ static int __devexit ad2s1210_remove(struct spi_device *spi)
iio_device_unregister(indio_dev);
ad2s1210_free_gpios(iio_priv(indio_dev));
- iio_free_device(indio_dev);
+ iio_device_free(indio_dev);
return 0;
}
diff --git a/drivers/staging/iio/resolver/ad2s90.c b/drivers/staging/iio/resolver/ad2s90.c
index 2a86f582ddf1..a8057228dca1 100644
--- a/drivers/staging/iio/resolver/ad2s90.c
+++ b/drivers/staging/iio/resolver/ad2s90.c
@@ -16,8 +16,8 @@
#include <linux/sysfs.h>
#include <linux/module.h>
-#include "../iio.h"
-#include "../sysfs.h"
+#include <linux/iio/iio.h>
+#include <linux/iio/sysfs.h>
struct ad2s90_state {
struct mutex lock;
@@ -55,6 +55,7 @@ static const struct iio_chan_spec ad2s90_chan = {
.type = IIO_ANGL,
.indexed = 1,
.channel = 0,
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT,
};
static int __devinit ad2s90_probe(struct spi_device *spi)
@@ -63,7 +64,7 @@ static int __devinit ad2s90_probe(struct spi_device *spi)
struct ad2s90_state *st;
int ret = 0;
- indio_dev = iio_allocate_device(sizeof(*st));
+ indio_dev = iio_device_alloc(sizeof(*st));
if (indio_dev == NULL) {
ret = -ENOMEM;
goto error_ret;
@@ -92,7 +93,7 @@ static int __devinit ad2s90_probe(struct spi_device *spi)
return 0;
error_free_dev:
- iio_free_device(indio_dev);
+ iio_device_free(indio_dev);
error_ret:
return ret;
}
@@ -100,7 +101,7 @@ error_ret:
static int __devexit ad2s90_remove(struct spi_device *spi)
{
iio_device_unregister(spi_get_drvdata(spi));
- iio_free_device(spi_get_drvdata(spi));
+ iio_device_free(spi_get_drvdata(spi));
return 0;
}
diff --git a/drivers/staging/iio/ring_sw.c b/drivers/staging/iio/ring_sw.c
index b9945ec44faa..f61c8fdaab06 100644
--- a/drivers/staging/iio/ring_sw.c
+++ b/drivers/staging/iio/ring_sw.c
@@ -15,7 +15,7 @@
#include <linux/sched.h>
#include <linux/poll.h>
#include "ring_sw.h"
-#include "trigger.h"
+#include <linux/iio/trigger.h>
/**
* struct iio_sw_ring_buffer - software ring buffer
@@ -24,7 +24,7 @@
* @read_p: read pointer (oldest available)
* @write_p: write pointer
* @half_p: half buffer length behind write_p (event generation)
- * @update_needed: flag to indicated change in size requested
+ * @update_needed: flag to indicate change in size requested
*
* Note that the first element of all ring buffers must be a
* struct iio_buffer.
@@ -363,5 +363,5 @@ void iio_sw_rb_free(struct iio_buffer *r)
}
EXPORT_SYMBOL(iio_sw_rb_free);
-MODULE_DESCRIPTION("Industrialio I/O software ring buffer");
+MODULE_DESCRIPTION("Industrial I/O software ring buffer");
MODULE_LICENSE("GPL");
diff --git a/drivers/staging/iio/ring_sw.h b/drivers/staging/iio/ring_sw.h
index 7556e2122367..a5857aa7aefa 100644
--- a/drivers/staging/iio/ring_sw.h
+++ b/drivers/staging/iio/ring_sw.h
@@ -23,7 +23,7 @@
#ifndef _IIO_RING_SW_H_
#define _IIO_RING_SW_H_
-#include "buffer.h"
+#include <linux/iio/buffer.h>
struct iio_buffer *iio_sw_rb_allocate(struct iio_dev *indio_dev);
void iio_sw_rb_free(struct iio_buffer *ring);
diff --git a/drivers/staging/iio/sysfs.h b/drivers/staging/iio/sysfs.h
deleted file mode 100644
index bfedb73b850e..000000000000
--- a/drivers/staging/iio/sysfs.h
+++ /dev/null
@@ -1,117 +0,0 @@
-/* The industrial I/O core
- *
- *Copyright (c) 2008 Jonathan Cameron
- *
- * 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.
- *
- * General attributes
- */
-
-#ifndef _INDUSTRIAL_IO_SYSFS_H_
-#define _INDUSTRIAL_IO_SYSFS_H_
-
-struct iio_chan_spec;
-
-/**
- * struct iio_dev_attr - iio specific device attribute
- * @dev_attr: underlying device attribute
- * @address: associated register address
- * @l: list head for maintaining list of dynamically created attrs.
- */
-struct iio_dev_attr {
- struct device_attribute dev_attr;
- u64 address;
- struct list_head l;
- struct iio_chan_spec const *c;
-};
-
-#define to_iio_dev_attr(_dev_attr) \
- container_of(_dev_attr, struct iio_dev_attr, dev_attr)
-
-ssize_t iio_read_const_attr(struct device *dev,
- struct device_attribute *attr,
- char *len);
-
-/**
- * struct iio_const_attr - constant device specific attribute
- * often used for things like available modes
- * @string: attribute string
- * @dev_attr: underlying device attribute
- */
-struct iio_const_attr {
- const char *string;
- struct device_attribute dev_attr;
-};
-
-#define to_iio_const_attr(_dev_attr) \
- container_of(_dev_attr, struct iio_const_attr, dev_attr)
-
-/* Some attributes will be hard coded (device dependent) and not require an
- address, in these cases pass a negative */
-#define IIO_ATTR(_name, _mode, _show, _store, _addr) \
- { .dev_attr = __ATTR(_name, _mode, _show, _store), \
- .address = _addr }
-
-#define IIO_DEVICE_ATTR(_name, _mode, _show, _store, _addr) \
- struct iio_dev_attr iio_dev_attr_##_name \
- = IIO_ATTR(_name, _mode, _show, _store, _addr)
-
-#define IIO_DEVICE_ATTR_NAMED(_vname, _name, _mode, _show, _store, _addr) \
- struct iio_dev_attr iio_dev_attr_##_vname \
- = IIO_ATTR(_name, _mode, _show, _store, _addr)
-
-#define IIO_CONST_ATTR(_name, _string) \
- struct iio_const_attr iio_const_attr_##_name \
- = { .string = _string, \
- .dev_attr = __ATTR(_name, S_IRUGO, iio_read_const_attr, NULL)}
-
-#define IIO_CONST_ATTR_NAMED(_vname, _name, _string) \
- struct iio_const_attr iio_const_attr_##_vname \
- = { .string = _string, \
- .dev_attr = __ATTR(_name, S_IRUGO, iio_read_const_attr, NULL)}
-
-/* Generic attributes of onetype or another */
-/**
- * IIO_DEV_ATTR_RESET: resets the device
- **/
-#define IIO_DEV_ATTR_RESET(_store) \
- IIO_DEVICE_ATTR(reset, S_IWUSR, NULL, _store, 0)
-
-/**
- * IIO_DEV_ATTR_SAMP_FREQ - sets any internal clock frequency
- * @_mode: sysfs file mode/permissions
- * @_show: output method for the attribute
- * @_store: input method for the attribute
- **/
-#define IIO_DEV_ATTR_SAMP_FREQ(_mode, _show, _store) \
- IIO_DEVICE_ATTR(sampling_frequency, _mode, _show, _store, 0)
-
-/**
- * IIO_DEV_ATTR_SAMP_FREQ_AVAIL - list available sampling frequencies
- * @_show: output method for the attribute
- *
- * May be mode dependent on some devices
- **/
-#define IIO_DEV_ATTR_SAMP_FREQ_AVAIL(_show) \
- IIO_DEVICE_ATTR(sampling_frequency_available, S_IRUGO, _show, NULL, 0)
-/**
- * IIO_CONST_ATTR_AVAIL_SAMP_FREQ - list available sampling frequencies
- * @_string: frequency string for the attribute
- *
- * Constant version
- **/
-#define IIO_CONST_ATTR_SAMP_FREQ_AVAIL(_string) \
- IIO_CONST_ATTR(sampling_frequency_available, _string)
-
-#define IIO_DEV_ATTR_TEMP_RAW(_show) \
- IIO_DEVICE_ATTR(in_temp_raw, S_IRUGO, _show, NULL, 0)
-
-#define IIO_CONST_ATTR_TEMP_OFFSET(_string) \
- IIO_CONST_ATTR(in_temp_offset, _string)
-
-#define IIO_CONST_ATTR_TEMP_SCALE(_string) \
- IIO_CONST_ATTR(in_temp_scale, _string)
-
-#endif /* _INDUSTRIAL_IO_SYSFS_H_ */
diff --git a/drivers/staging/iio/trigger.h b/drivers/staging/iio/trigger.h
deleted file mode 100644
index 1cfca231db8f..000000000000
--- a/drivers/staging/iio/trigger.h
+++ /dev/null
@@ -1,119 +0,0 @@
-/* The industrial I/O core, trigger handling functions
- *
- * Copyright (c) 2008 Jonathan Cameron
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 as published by
- * the Free Software Foundation.
- */
-#include <linux/irq.h>
-#include <linux/module.h>
-
-#ifndef _IIO_TRIGGER_H_
-#define _IIO_TRIGGER_H_
-
-struct iio_subirq {
- bool enabled;
-};
-
-/**
- * struct iio_trigger_ops - operations structure for an iio_trigger.
- * @owner: used to monitor usage count of the trigger.
- * @set_trigger_state: switch on/off the trigger on demand
- * @try_reenable: function to reenable the trigger when the
- * use count is zero (may be NULL)
- * @validate_device: function to validate the device when the
- * current trigger gets changed.
- *
- * This is typically static const within a driver and shared by
- * instances of a given device.
- **/
-struct iio_trigger_ops {
- struct module *owner;
- int (*set_trigger_state)(struct iio_trigger *trig, bool state);
- int (*try_reenable)(struct iio_trigger *trig);
- int (*validate_device)(struct iio_trigger *trig,
- struct iio_dev *indio_dev);
-};
-
-
-/**
- * struct iio_trigger - industrial I/O trigger device
- *
- * @id: [INTERN] unique id number
- * @name: [DRIVER] unique name
- * @dev: [DRIVER] associated device (if relevant)
- * @private_data: [DRIVER] device specific data
- * @list: [INTERN] used in maintenance of global trigger list
- * @alloc_list: [DRIVER] used for driver specific trigger list
- * @use_count: use count for the trigger
- * @subirq_chip: [INTERN] associate 'virtual' irq chip.
- * @subirq_base: [INTERN] base number for irqs provided by trigger.
- * @subirqs: [INTERN] information about the 'child' irqs.
- * @pool: [INTERN] bitmap of irqs currently in use.
- * @pool_lock: [INTERN] protection of the irq pool.
- **/
-struct iio_trigger {
- const struct iio_trigger_ops *ops;
- int id;
- const char *name;
- struct device dev;
-
- void *private_data;
- struct list_head list;
- struct list_head alloc_list;
- int use_count;
-
- struct irq_chip subirq_chip;
- int subirq_base;
-
- struct iio_subirq subirqs[CONFIG_IIO_CONSUMERS_PER_TRIGGER];
- unsigned long pool[BITS_TO_LONGS(CONFIG_IIO_CONSUMERS_PER_TRIGGER)];
- struct mutex pool_lock;
-};
-
-
-static inline struct iio_trigger *to_iio_trigger(struct device *d)
-{
- return container_of(d, struct iio_trigger, dev);
-};
-
-static inline void iio_put_trigger(struct iio_trigger *trig)
-{
- module_put(trig->ops->owner);
- put_device(&trig->dev);
-};
-
-static inline void iio_get_trigger(struct iio_trigger *trig)
-{
- get_device(&trig->dev);
- __module_get(trig->ops->owner);
-};
-
-/**
- * iio_trigger_register() - register a trigger with the IIO core
- * @trig_info: trigger to be registered
- **/
-int iio_trigger_register(struct iio_trigger *trig_info);
-
-/**
- * iio_trigger_unregister() - unregister a trigger from the core
- * @trig_info: trigger to be unregistered
- **/
-void iio_trigger_unregister(struct iio_trigger *trig_info);
-
-/**
- * iio_trigger_poll() - called on a trigger occurring
- * @trig: trigger which occurred
- *
- * Typically called in relevant hardware interrupt handler.
- **/
-void iio_trigger_poll(struct iio_trigger *trig, s64 time);
-void iio_trigger_poll_chained(struct iio_trigger *trig, s64 time);
-
-irqreturn_t iio_trigger_generic_data_rdy_poll(int irq, void *private);
-
-__printf(1, 2) struct iio_trigger *iio_allocate_trigger(const char *fmt, ...);
-void iio_free_trigger(struct iio_trigger *trig);
-
-#endif /* _IIO_TRIGGER_H_ */
diff --git a/drivers/staging/iio/trigger/iio-trig-bfin-timer.c b/drivers/staging/iio/trigger/iio-trig-bfin-timer.c
index 665653d79f02..ce6a7b1b8860 100644
--- a/drivers/staging/iio/trigger/iio-trig-bfin-timer.c
+++ b/drivers/staging/iio/trigger/iio-trig-bfin-timer.c
@@ -15,8 +15,8 @@
#include <asm/gptimers.h>
-#include "../iio.h"
-#include "../trigger.h"
+#include <linux/iio/iio.h>
+#include <linux/iio/trigger.h>
struct bfin_timer {
unsigned short id, bit;
@@ -60,7 +60,7 @@ struct bfin_tmr_state {
static ssize_t iio_bfin_tmr_frequency_store(struct device *dev,
struct device_attribute *attr, const char *buf, size_t count)
{
- struct iio_trigger *trig = dev_get_drvdata(dev);
+ struct iio_trigger *trig = to_iio_trigger(dev);
struct bfin_tmr_state *st = trig->private_data;
long val;
int ret;
@@ -97,7 +97,7 @@ static ssize_t iio_bfin_tmr_frequency_show(struct device *dev,
struct device_attribute *attr,
char *buf)
{
- struct iio_trigger *trig = dev_get_drvdata(dev);
+ struct iio_trigger *trig = to_iio_trigger(dev);
struct bfin_tmr_state *st = trig->private_data;
return sprintf(buf, "%lu\n",
@@ -172,7 +172,7 @@ static int __devinit iio_bfin_tmr_trigger_probe(struct platform_device *pdev)
st->timer_num = ret;
st->t = &iio_bfin_timer_code[st->timer_num];
- st->trig = iio_allocate_trigger("bfintmr%d", st->timer_num);
+ st->trig = iio_trigger_alloc("bfintmr%d", st->timer_num);
if (!st->trig) {
ret = -ENOMEM;
goto out1;
@@ -203,7 +203,7 @@ static int __devinit iio_bfin_tmr_trigger_probe(struct platform_device *pdev)
out4:
iio_trigger_unregister(st->trig);
out2:
- iio_put_trigger(st->trig);
+ iio_trigger_put(st->trig);
out1:
kfree(st);
out:
@@ -217,7 +217,7 @@ static int __devexit iio_bfin_tmr_trigger_remove(struct platform_device *pdev)
disable_gptimers(st->t->bit);
free_irq(st->irq, st);
iio_trigger_unregister(st->trig);
- iio_put_trigger(st->trig);
+ iio_trigger_put(st->trig);
kfree(st);
return 0;
diff --git a/drivers/staging/iio/trigger/iio-trig-gpio.c b/drivers/staging/iio/trigger/iio-trig-gpio.c
index a3465947235e..90b26846fc6b 100644
--- a/drivers/staging/iio/trigger/iio-trig-gpio.c
+++ b/drivers/staging/iio/trigger/iio-trig-gpio.c
@@ -22,8 +22,8 @@
#include <linux/gpio.h>
#include <linux/slab.h>
-#include "../iio.h"
-#include "../trigger.h"
+#include <linux/iio/iio.h>
+#include <linux/iio/trigger.h>
static LIST_HEAD(iio_gpio_trigger_list);
static DEFINE_MUTEX(iio_gpio_trigger_list_lock);
@@ -72,7 +72,7 @@ static int iio_gpio_trigger_probe(struct platform_device *pdev)
for (irq = irq_res->start; irq <= irq_res->end; irq++) {
- trig = iio_allocate_trigger("irqtrig%d", irq);
+ trig = iio_trigger_alloc("irqtrig%d", irq);
if (!trig) {
ret = -ENOMEM;
goto error_free_completed_registrations;
@@ -114,7 +114,7 @@ error_release_irq:
error_free_trig_info:
kfree(trig_info);
error_put_trigger:
- iio_put_trigger(trig);
+ iio_trigger_put(trig);
error_free_completed_registrations:
/* The rest should have been added to the iio_gpio_trigger_list */
list_for_each_entry_safe(trig,
@@ -144,7 +144,7 @@ static int iio_gpio_trigger_remove(struct platform_device *pdev)
iio_trigger_unregister(trig);
free_irq(trig_info->irq, trig);
kfree(trig_info);
- iio_put_trigger(trig);
+ iio_trigger_put(trig);
}
mutex_unlock(&iio_gpio_trigger_list_lock);
diff --git a/drivers/staging/iio/trigger/iio-trig-periodic-rtc.c b/drivers/staging/iio/trigger/iio-trig-periodic-rtc.c
index a80cf67bf84d..4ceaa18ef9f4 100644
--- a/drivers/staging/iio/trigger/iio-trig-periodic-rtc.c
+++ b/drivers/staging/iio/trigger/iio-trig-periodic-rtc.c
@@ -16,8 +16,8 @@
#include <linux/module.h>
#include <linux/slab.h>
#include <linux/rtc.h>
-#include "../iio.h"
-#include "../trigger.h"
+#include <linux/iio/iio.h>
+#include <linux/iio/trigger.h>
static LIST_HEAD(iio_prtc_trigger_list);
static DEFINE_MUTEX(iio_prtc_trigger_list_lock);
@@ -41,7 +41,7 @@ static ssize_t iio_trig_periodic_read_freq(struct device *dev,
struct device_attribute *attr,
char *buf)
{
- struct iio_trigger *trig = dev_get_drvdata(dev);
+ struct iio_trigger *trig = to_iio_trigger(dev);
struct iio_prtc_trigger_info *trig_info = trig->private_data;
return sprintf(buf, "%u\n", trig_info->frequency);
}
@@ -51,7 +51,7 @@ static ssize_t iio_trig_periodic_write_freq(struct device *dev,
const char *buf,
size_t len)
{
- struct iio_trigger *trig = dev_get_drvdata(dev);
+ struct iio_trigger *trig = to_iio_trigger(dev);
struct iio_prtc_trigger_info *trig_info = trig->private_data;
unsigned long val;
int ret;
@@ -112,7 +112,7 @@ static int iio_trig_periodic_rtc_probe(struct platform_device *dev)
for (i = 0;; i++) {
if (pdata[i] == NULL)
break;
- trig = iio_allocate_trigger("periodic%s", pdata[i]);
+ trig = iio_trigger_alloc("periodic%s", pdata[i]);
if (!trig) {
ret = -ENOMEM;
goto error_free_completed_registrations;
@@ -152,7 +152,7 @@ error_free_trig_info:
kfree(trig_info);
error_put_trigger_and_remove_from_list:
list_del(&trig->alloc_list);
- iio_put_trigger(trig);
+ iio_trigger_put(trig);
error_free_completed_registrations:
list_for_each_entry_safe(trig,
trig2,
diff --git a/drivers/staging/iio/trigger/iio-trig-sysfs.c b/drivers/staging/iio/trigger/iio-trig-sysfs.c
index 174dc65709d5..fee474648108 100644
--- a/drivers/staging/iio/trigger/iio-trig-sysfs.c
+++ b/drivers/staging/iio/trigger/iio-trig-sysfs.c
@@ -11,8 +11,8 @@
#include <linux/slab.h>
#include <linux/list.h>
-#include "../iio.h"
-#include "../trigger.h"
+#include <linux/iio/iio.h>
+#include <linux/iio/trigger.h>
struct iio_sysfs_trig {
struct iio_trigger *trig;
@@ -92,7 +92,7 @@ static struct device iio_sysfs_trig_dev = {
static ssize_t iio_sysfs_trigger_poll(struct device *dev,
struct device_attribute *attr, const char *buf, size_t count)
{
- struct iio_trigger *trig = dev_get_drvdata(dev);
+ struct iio_trigger *trig = to_iio_trigger(dev);
iio_trigger_poll_chained(trig, 0);
return count;
@@ -139,7 +139,7 @@ static int iio_sysfs_trigger_probe(int id)
goto out1;
}
t->id = id;
- t->trig = iio_allocate_trigger("sysfstrig%d", id);
+ t->trig = iio_trigger_alloc("sysfstrig%d", id);
if (!t->trig) {
ret = -ENOMEM;
goto free_t;
@@ -158,7 +158,7 @@ static int iio_sysfs_trigger_probe(int id)
return 0;
out2:
- iio_put_trigger(t->trig);
+ iio_trigger_put(t->trig);
free_t:
kfree(t);
out1:
@@ -182,7 +182,7 @@ static int iio_sysfs_trigger_remove(int id)
}
iio_trigger_unregister(t->trig);
- iio_free_trigger(t->trig);
+ iio_trigger_free(t->trig);
list_del(&t->l);
kfree(t);
diff --git a/drivers/staging/iio/trigger_consumer.h b/drivers/staging/iio/trigger_consumer.h
deleted file mode 100644
index 60d64b356945..000000000000
--- a/drivers/staging/iio/trigger_consumer.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/* The industrial I/O core, trigger consumer functions
- *
- * Copyright (c) 2008-2011 Jonathan Cameron
- *
- * 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.
- */
-
-/**
- * struct iio_poll_func - poll function pair
- *
- * @indio_dev: data specific to device (passed into poll func)
- * @h: the function that is actually run on trigger
- * @thread: threaded interrupt part
- * @type: the type of interrupt (basically if oneshot)
- * @name: name used to identify the trigger consumer.
- * @irq: the corresponding irq as allocated from the
- * trigger pool
- * @timestamp: some devices need a timestamp grabbed as soon
- * as possible after the trigger - hence handler
- * passes it via here.
- **/
-struct iio_poll_func {
- struct iio_dev *indio_dev;
- irqreturn_t (*h)(int irq, void *p);
- irqreturn_t (*thread)(int irq, void *p);
- int type;
- char *name;
- int irq;
- s64 timestamp;
-};
-
-
-struct iio_poll_func
-*iio_alloc_pollfunc(irqreturn_t (*h)(int irq, void *p),
- irqreturn_t (*thread)(int irq, void *p),
- int type,
- struct iio_dev *indio_dev,
- const char *fmt,
- ...);
-void iio_dealloc_pollfunc(struct iio_poll_func *pf);
-irqreturn_t iio_pollfunc_store_time(int irq, void *p);
-
-void iio_trigger_notify_done(struct iio_trigger *trig);
-
-/*
- * Two functions for common case where all that happens is a pollfunc
- * is attached and detached from a trigger
- */
-int iio_triggered_buffer_postenable(struct iio_dev *indio_dev);
-int iio_triggered_buffer_predisable(struct iio_dev *indio_dev);
diff --git a/drivers/staging/iio/types.h b/drivers/staging/iio/types.h
deleted file mode 100644
index 0c3213666901..000000000000
--- a/drivers/staging/iio/types.h
+++ /dev/null
@@ -1,53 +0,0 @@
-/* industrial I/O data types needed both in and out of kernel
- *
- * Copyright (c) 2008 Jonathan Cameron
- *
- * 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 _IIO_TYPES_H_
-#define _IIO_TYPES_H_
-
-enum iio_chan_type {
- /* real channel types */
- IIO_VOLTAGE,
- IIO_CURRENT,
- IIO_POWER,
- IIO_ACCEL,
- IIO_ANGL_VEL,
- IIO_MAGN,
- IIO_LIGHT,
- IIO_INTENSITY,
- IIO_PROXIMITY,
- IIO_TEMP,
- IIO_INCLI,
- IIO_ROT,
- IIO_ANGL,
- IIO_TIMESTAMP,
- IIO_CAPACITANCE,
-};
-
-enum iio_modifier {
- IIO_NO_MOD,
- IIO_MOD_X,
- IIO_MOD_Y,
- IIO_MOD_Z,
- IIO_MOD_X_AND_Y,
- IIO_MOD_X_AND_Z,
- IIO_MOD_Y_AND_Z,
- IIO_MOD_X_AND_Y_AND_Z,
- IIO_MOD_X_OR_Y,
- IIO_MOD_X_OR_Z,
- IIO_MOD_Y_OR_Z,
- IIO_MOD_X_OR_Y_OR_Z,
- IIO_MOD_LIGHT_BOTH,
- IIO_MOD_LIGHT_IR,
-};
-
-#define IIO_VAL_INT 1
-#define IIO_VAL_INT_PLUS_MICRO 2
-#define IIO_VAL_INT_PLUS_NANO 3
-
-#endif /* _IIO_TYPES_H_ */
diff --git a/drivers/staging/ipack/Kconfig b/drivers/staging/ipack/Kconfig
new file mode 100644
index 000000000000..af321789dddb
--- /dev/null
+++ b/drivers/staging/ipack/Kconfig
@@ -0,0 +1,20 @@
+#
+# IPACK configuration.
+#
+
+menuconfig IPACK_BUS
+ tristate "IndustryPack bus support"
+ ---help---
+ If you say Y here you get support for the IndustryPack Framework
+ for drivers for many types of boards that support this industrial
+ bus. The IndustryPack Framework is a virtual bus allowing to
+ communicate between carrier and mezzanine cards connected through
+ this bus.
+
+if IPACK_BUS
+
+source "drivers/staging/ipack/bridges/Kconfig"
+
+source "drivers/staging/ipack/devices/Kconfig"
+
+endif # IPACK
diff --git a/drivers/staging/ipack/Makefile b/drivers/staging/ipack/Makefile
new file mode 100644
index 000000000000..85ff223616fd
--- /dev/null
+++ b/drivers/staging/ipack/Makefile
@@ -0,0 +1,6 @@
+#
+# Makefile for the IPACK bridge device drivers.
+#
+obj-$(CONFIG_IPACK_BUS) += ipack.o
+obj-y += devices/
+obj-y += bridges/
diff --git a/drivers/staging/ipack/TODO b/drivers/staging/ipack/TODO
new file mode 100644
index 000000000000..b21d33ab144a
--- /dev/null
+++ b/drivers/staging/ipack/TODO
@@ -0,0 +1,43 @@
+ TODO
+ ====
+Introduction
+============
+
+These drivers add support for IndustryPack devices: carrier and IP module
+boards.
+
+The ipack driver is just an abstraction of the bus providing the common
+operations between the two kind of boards.
+
+TODO
+====
+
+TPCI-200
+--------
+
+* It has a linked list with the tpci200 devices it is managing. Get rid of it
+ and use driver_for_each_device() instead.
+
+IP-OCTAL
+--------
+
+* It has a linked list which saves the devices it is currently
+ managing. It should use the driver_for_each_device() function. It is not there
+ due to the impossibility of using container_of macro to recover the
+ corresponding "struct ipoctal" because the attribute "struct ipack_device" is
+ a pointer. This code should be refactored.
+
+Ipack
+-----
+
+* The structures and API exported can be improved a lot. For example, the
+ way to unregistering IP module devices, doing the IP module driver a call to
+ remove_device() to notify the carrier driver, or the opposite with the call to
+ the ipack_driver_ops' remove() function could be improved.
+
+
+Contact
+=======
+
+Contact: Samuel Iglesias Gonsalvez <siglesias@igalia.com>
+Mailing List: industrypack-devel@lists.sourceforge.net
diff --git a/drivers/staging/ipack/bridges/Kconfig b/drivers/staging/ipack/bridges/Kconfig
new file mode 100644
index 000000000000..97c837ea7a03
--- /dev/null
+++ b/drivers/staging/ipack/bridges/Kconfig
@@ -0,0 +1,8 @@
+config BOARD_TPCI200
+ tristate "TEWS TPCI-200 support for IndustryPack bus"
+ depends on IPACK_BUS
+ depends on PCI
+ help
+ This driver supports the TEWS TPCI200 device for the IndustryPack bus.
+ default n
+
diff --git a/drivers/staging/ipack/bridges/Makefile b/drivers/staging/ipack/bridges/Makefile
new file mode 100644
index 000000000000..d8b76459300f
--- /dev/null
+++ b/drivers/staging/ipack/bridges/Makefile
@@ -0,0 +1 @@
+obj-$(CONFIG_BOARD_TPCI200) += tpci200.o
diff --git a/drivers/staging/ipack/bridges/tpci200.c b/drivers/staging/ipack/bridges/tpci200.c
new file mode 100644
index 000000000000..2b83fa8e550a
--- /dev/null
+++ b/drivers/staging/ipack/bridges/tpci200.c
@@ -0,0 +1,902 @@
+/**
+ * tpci200.c
+ *
+ * driver for the TEWS TPCI-200 device
+ * Copyright (c) 2009 Nicolas Serafini, EIC2 SA
+ * Copyright (c) 2010,2011 Samuel Iglesias Gonsalvez <siglesia@cern.ch>, CERN
+ * Copyright (c) 2012 Samuel Iglesias Gonsalvez <siglesias@igalia.com>, Igalia
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation; version 2 of the License.
+ */
+
+#include <linux/module.h>
+#include "tpci200.h"
+
+static struct ipack_bus_ops tpci200_bus_ops;
+
+/* TPCI200 controls registers */
+static int control_reg[] = {
+ TPCI200_CONTROL_A_REG,
+ TPCI200_CONTROL_B_REG,
+ TPCI200_CONTROL_C_REG,
+ TPCI200_CONTROL_D_REG
+};
+
+/* Linked list to save the registered devices */
+static LIST_HEAD(tpci200_list);
+
+static int tpci200_slot_unregister(struct ipack_device *dev);
+
+static struct tpci200_board *check_slot(struct ipack_device *dev)
+{
+ struct tpci200_board *tpci200;
+ int found = 0;
+
+ if (dev == NULL)
+ return NULL;
+
+ list_for_each_entry(tpci200, &tpci200_list, list) {
+ if (tpci200->number == dev->bus_nr) {
+ found = 1;
+ break;
+ }
+ }
+
+ if (!found) {
+ dev_err(&dev->dev, "Carrier not found\n");
+ return NULL;
+ }
+
+ if (dev->slot >= TPCI200_NB_SLOT) {
+ dev_info(&dev->dev,
+ "Slot [%d:%d] doesn't exist! Last tpci200 slot is %d.\n",
+ dev->bus_nr, dev->slot, TPCI200_NB_SLOT-1);
+ return NULL;
+ }
+
+ return tpci200;
+}
+
+static inline unsigned char __tpci200_read8(void __iomem *address,
+ unsigned long offset)
+{
+ return ioread8(address + (offset^1));
+}
+
+static inline unsigned short __tpci200_read16(void __iomem *address,
+ unsigned long offset)
+{
+ return ioread16(address + offset);
+}
+
+static inline unsigned int __tpci200_read32(void __iomem *address,
+ unsigned long offset)
+{
+ return swahw32(ioread32(address + offset));
+}
+
+static inline void __tpci200_write8(unsigned char value,
+ void __iomem *address, unsigned long offset)
+{
+ iowrite8(value, address+(offset^1));
+}
+
+static inline void __tpci200_write16(unsigned short value,
+ void __iomem *address,
+ unsigned long offset)
+{
+ iowrite16(value, address+offset);
+}
+
+static inline void __tpci200_write32(unsigned int value,
+ void __iomem *address,
+ unsigned long offset)
+{
+ iowrite32(swahw32(value), address+offset);
+}
+
+static struct ipack_addr_space *get_slot_address_space(struct ipack_device *dev,
+ int space)
+{
+ struct ipack_addr_space *addr;
+
+ switch (space) {
+ case IPACK_IO_SPACE:
+ addr = &dev->io_space;
+ break;
+ case IPACK_ID_SPACE:
+ addr = &dev->id_space;
+ break;
+ case IPACK_MEM_SPACE:
+ addr = &dev->mem_space;
+ break;
+ default:
+ dev_err(&dev->dev,
+ "Slot [%d:%d] space number %d doesn't exist !\n",
+ dev->bus_nr, dev->slot, space);
+ return NULL;
+ break;
+ }
+
+ if ((addr->size == 0) || (addr->address == NULL)) {
+ dev_err(&dev->dev, "Error, slot space not mapped !\n");
+ return NULL;
+ }
+
+ return addr;
+}
+
+static int tpci200_read8(struct ipack_device *dev, int space,
+ unsigned long offset, unsigned char *value)
+{
+ struct ipack_addr_space *addr;
+ struct tpci200_board *tpci200;
+
+ tpci200 = check_slot(dev);
+ if (tpci200 == NULL)
+ return -EINVAL;
+
+ addr = get_slot_address_space(dev, space);
+ if (addr == NULL)
+ return -EINVAL;
+
+ if (offset >= addr->size) {
+ dev_err(&dev->dev, "Error, slot space offset error !\n");
+ return -EFAULT;
+ }
+
+ *value = __tpci200_read8(addr->address, offset);
+
+ return 0;
+}
+
+static int tpci200_read16(struct ipack_device *dev, int space,
+ unsigned long offset, unsigned short *value)
+{
+ struct ipack_addr_space *addr;
+ struct tpci200_board *tpci200;
+
+ tpci200 = check_slot(dev);
+ if (tpci200 == NULL)
+ return -EINVAL;
+
+ addr = get_slot_address_space(dev, space);
+ if (addr == NULL)
+ return -EINVAL;
+
+ if ((offset+2) >= addr->size) {
+ dev_err(&dev->dev, "Error, slot space offset error !\n");
+ return -EFAULT;
+ }
+ *value = __tpci200_read16(addr->address, offset);
+
+ return 0;
+}
+
+static int tpci200_read32(struct ipack_device *dev, int space,
+ unsigned long offset, unsigned int *value)
+{
+ struct ipack_addr_space *addr;
+ struct tpci200_board *tpci200;
+
+ tpci200 = check_slot(dev);
+ if (tpci200 == NULL)
+ return -EINVAL;
+
+ addr = get_slot_address_space(dev, space);
+ if (addr == NULL)
+ return -EINVAL;
+
+ if ((offset+4) >= addr->size) {
+ dev_err(&dev->dev, "Error, slot space offset error !\n");
+ return -EFAULT;
+ }
+
+ *value = __tpci200_read32(addr->address, offset);
+
+ return 0;
+}
+
+static int tpci200_write8(struct ipack_device *dev, int space,
+ unsigned long offset, unsigned char value)
+{
+ struct ipack_addr_space *addr;
+ struct tpci200_board *tpci200;
+
+ tpci200 = check_slot(dev);
+ if (tpci200 == NULL)
+ return -EINVAL;
+
+ addr = get_slot_address_space(dev, space);
+ if (addr == NULL)
+ return -EINVAL;
+
+ if (offset >= addr->size) {
+ dev_err(&dev->dev, "Error, slot space offset error !\n");
+ return -EFAULT;
+ }
+
+ __tpci200_write8(value, addr->address, offset);
+
+ return 0;
+}
+
+static int tpci200_write16(struct ipack_device *dev, int space,
+ unsigned long offset, unsigned short value)
+{
+ struct ipack_addr_space *addr;
+ struct tpci200_board *tpci200;
+
+ tpci200 = check_slot(dev);
+ if (tpci200 == NULL)
+ return -EINVAL;
+
+ addr = get_slot_address_space(dev, space);
+ if (addr == NULL)
+ return -EINVAL;
+
+ if ((offset+2) >= addr->size) {
+ dev_err(&dev->dev, "Error, slot space offset error !\n");
+ return -EFAULT;
+ }
+
+ __tpci200_write16(value, addr->address, offset);
+
+ return 0;
+}
+
+static int tpci200_write32(struct ipack_device *dev, int space,
+ unsigned long offset, unsigned int value)
+{
+ struct ipack_addr_space *addr;
+ struct tpci200_board *tpci200;
+
+ tpci200 = check_slot(dev);
+ if (tpci200 == NULL)
+ return -EINVAL;
+
+ addr = get_slot_address_space(dev, space);
+ if (addr == NULL)
+ return -EINVAL;
+
+ if ((offset+4) >= addr->size) {
+ dev_err(&dev->dev, "Error, slot space offset error !\n");
+ return -EFAULT;
+ }
+
+ __tpci200_write32(value, addr->address, offset);
+
+ return 0;
+}
+
+static void tpci200_unregister(struct tpci200_board *tpci200)
+{
+ int i;
+
+ free_irq(tpci200->info->pdev->irq, (void *) tpci200);
+
+ pci_iounmap(tpci200->info->pdev, tpci200->info->interface_regs);
+ pci_iounmap(tpci200->info->pdev, tpci200->info->ioidint_space);
+ pci_iounmap(tpci200->info->pdev, tpci200->info->mem8_space);
+
+ pci_release_region(tpci200->info->pdev, TPCI200_IP_INTERFACE_BAR);
+ pci_release_region(tpci200->info->pdev, TPCI200_IO_ID_INT_SPACES_BAR);
+ pci_release_region(tpci200->info->pdev, TPCI200_MEM8_SPACE_BAR);
+
+ pci_disable_device(tpci200->info->pdev);
+ pci_dev_put(tpci200->info->pdev);
+
+ for (i = 0; i < TPCI200_NB_SLOT; i++) {
+ tpci200->slots[i].io_phys.address = NULL;
+ tpci200->slots[i].io_phys.size = 0;
+ tpci200->slots[i].id_phys.address = NULL;
+ tpci200->slots[i].id_phys.size = 0;
+ tpci200->slots[i].mem_phys.address = NULL;
+ tpci200->slots[i].mem_phys.size = 0;
+ }
+}
+
+static irqreturn_t tpci200_interrupt(int irq, void *dev_id)
+{
+ struct tpci200_board *tpci200 = (struct tpci200_board *) dev_id;
+ int i;
+ unsigned short status_reg, reg_value;
+ unsigned short unhandled_ints = 0;
+ irqreturn_t ret = IRQ_NONE;
+
+ /* Read status register */
+ status_reg = readw(tpci200->info->interface_regs +
+ TPCI200_STATUS_REG);
+
+ if (status_reg & TPCI200_SLOT_INT_MASK) {
+ unhandled_ints = status_reg & TPCI200_SLOT_INT_MASK;
+ /* callback to the IRQ handler for the corresponding slot */
+ for (i = 0; i < TPCI200_NB_SLOT; i++) {
+ if ((tpci200->slots[i].irq != NULL) &&
+ (status_reg & ((TPCI200_A_INT0 | TPCI200_A_INT1) << (2*i)))) {
+
+ ret = tpci200->slots[i].irq->handler(tpci200->slots[i].irq->arg);
+
+ /* Dummy reads */
+ readw(tpci200->slots[i].dev->io_space.address +
+ 0xC0);
+ readw(tpci200->slots[i].dev->io_space.address +
+ 0xC2);
+
+ unhandled_ints &= ~(((TPCI200_A_INT0 | TPCI200_A_INT1) << (2*i)));
+ }
+ }
+ }
+ /* Interrupt not handled are disabled */
+ if (unhandled_ints) {
+ for (i = 0; i < TPCI200_NB_SLOT; i++) {
+ if (unhandled_ints & ((TPCI200_INT0_EN | TPCI200_INT1_EN) << (2*i))) {
+ dev_info(&tpci200->slots[i].dev->dev,
+ "No registered ISR for slot [%d:%d]!. IRQ will be disabled.\n",
+ tpci200->number, i);
+ reg_value = readw(
+ tpci200->info->interface_regs +
+ control_reg[i]);
+ reg_value &=
+ ~(TPCI200_INT0_EN | TPCI200_INT1_EN);
+ writew(reg_value,
+ (tpci200->info->interface_regs +
+ control_reg[i]));
+ }
+ }
+ }
+
+ return ret;
+}
+
+static int tpci200_register(struct tpci200_board *tpci200)
+{
+ int i;
+ int res;
+ unsigned long ioidint_base;
+ unsigned long mem_base;
+ unsigned short slot_ctrl;
+
+ if (pci_enable_device(tpci200->info->pdev) < 0)
+ return -ENODEV;
+
+ /* Request IP interface register (Bar 2) */
+ res = pci_request_region(tpci200->info->pdev, TPCI200_IP_INTERFACE_BAR,
+ "Carrier IP interface registers");
+ if (res) {
+ dev_err(&tpci200->info->pdev->dev,
+ "(bn 0x%X, sn 0x%X) failed to allocate PCI resource for BAR 2 !",
+ tpci200->info->pdev->bus->number,
+ tpci200->info->pdev->devfn);
+ goto out_disable_pci;
+ }
+
+ /* Request IO ID INT space (Bar 3) */
+ res = pci_request_region(tpci200->info->pdev,
+ TPCI200_IO_ID_INT_SPACES_BAR,
+ "Carrier IO ID INT space");
+ if (res) {
+ dev_err(&tpci200->info->pdev->dev,
+ "(bn 0x%X, sn 0x%X) failed to allocate PCI resource for BAR 3 !",
+ tpci200->info->pdev->bus->number,
+ tpci200->info->pdev->devfn);
+ goto out_release_ip_space;
+ }
+
+ /* Request MEM space (Bar 4) */
+ res = pci_request_region(tpci200->info->pdev, TPCI200_MEM8_SPACE_BAR,
+ "Carrier MEM space");
+ if (res) {
+ dev_err(&tpci200->info->pdev->dev,
+ "(bn 0x%X, sn 0x%X) failed to allocate PCI resource for BAR 4!",
+ tpci200->info->pdev->bus->number,
+ tpci200->info->pdev->devfn);
+ goto out_release_ioid_int_space;
+ }
+
+ /* Map internal tpci200 driver user space */
+ tpci200->info->interface_regs =
+ ioremap(pci_resource_start(tpci200->info->pdev,
+ TPCI200_IP_INTERFACE_BAR),
+ TPCI200_IFACE_SIZE);
+ tpci200->info->ioidint_space =
+ ioremap(pci_resource_start(tpci200->info->pdev,
+ TPCI200_IO_ID_INT_SPACES_BAR),
+ TPCI200_IOIDINT_SIZE);
+ tpci200->info->mem8_space =
+ ioremap(pci_resource_start(tpci200->info->pdev,
+ TPCI200_MEM8_SPACE_BAR),
+ TPCI200_MEM8_SIZE);
+
+ ioidint_base = pci_resource_start(tpci200->info->pdev,
+ TPCI200_IO_ID_INT_SPACES_BAR);
+ mem_base = pci_resource_start(tpci200->info->pdev,
+ TPCI200_MEM8_SPACE_BAR);
+
+ /* Set the default parameters of the slot
+ * INT0 disabled, level sensitive
+ * INT1 disabled, level sensitive
+ * error interrupt disabled
+ * timeout interrupt disabled
+ * recover time disabled
+ * clock rate 8 MHz
+ */
+ slot_ctrl = 0;
+
+ /* Set all slot physical address space */
+ for (i = 0; i < TPCI200_NB_SLOT; i++) {
+ tpci200->slots[i].io_phys.address =
+ (void __iomem *)ioidint_base +
+ TPCI200_IO_SPACE_OFF + TPCI200_IO_SPACE_GAP*i;
+ tpci200->slots[i].io_phys.size = TPCI200_IO_SPACE_SIZE;
+
+ tpci200->slots[i].id_phys.address =
+ (void __iomem *)ioidint_base +
+ TPCI200_ID_SPACE_OFF + TPCI200_ID_SPACE_GAP*i;
+ tpci200->slots[i].id_phys.size = TPCI200_ID_SPACE_SIZE;
+
+ tpci200->slots[i].mem_phys.address =
+ (void __iomem *)mem_base + TPCI200_MEM8_GAP*i;
+ tpci200->slots[i].mem_phys.size = TPCI200_MEM8_SIZE;
+
+ writew(slot_ctrl, (tpci200->info->interface_regs +
+ control_reg[i]));
+ }
+
+ res = request_irq(tpci200->info->pdev->irq,
+ tpci200_interrupt, IRQF_SHARED,
+ KBUILD_MODNAME, (void *) tpci200);
+ if (res) {
+ dev_err(&tpci200->info->pdev->dev,
+ "(bn 0x%X, sn 0x%X) unable to register IRQ !",
+ tpci200->info->pdev->bus->number,
+ tpci200->info->pdev->devfn);
+ goto out_release_ioid_int_space;
+ }
+
+ return 0;
+
+out_release_ioid_int_space:
+ pci_release_region(tpci200->info->pdev, TPCI200_IO_ID_INT_SPACES_BAR);
+out_release_ip_space:
+ pci_release_region(tpci200->info->pdev, TPCI200_IP_INTERFACE_BAR);
+out_disable_pci:
+ pci_disable_device(tpci200->info->pdev);
+ return res;
+}
+
+static int __tpci200_request_irq(struct tpci200_board *tpci200,
+ struct ipack_device *dev)
+{
+ unsigned short slot_ctrl;
+
+ /* Set the default parameters of the slot
+ * INT0 enabled, level sensitive
+ * INT1 enabled, level sensitive
+ * error interrupt disabled
+ * timeout interrupt disabled
+ * recover time disabled
+ * clock rate 8 MHz
+ */
+ slot_ctrl = TPCI200_INT0_EN | TPCI200_INT1_EN;
+ writew(slot_ctrl, (tpci200->info->interface_regs +
+ control_reg[dev->slot]));
+
+ return 0;
+}
+
+static void __tpci200_free_irq(struct tpci200_board *tpci200,
+ struct ipack_device *dev)
+{
+ unsigned short slot_ctrl;
+
+ /* Set the default parameters of the slot
+ * INT0 disabled, level sensitive
+ * INT1 disabled, level sensitive
+ * error interrupt disabled
+ * timeout interrupt disabled
+ * recover time disabled
+ * clock rate 8 MHz
+ */
+ slot_ctrl = 0;
+ writew(slot_ctrl, (tpci200->info->interface_regs +
+ control_reg[dev->slot]));
+}
+
+static int tpci200_free_irq(struct ipack_device *dev)
+{
+ struct slot_irq *slot_irq;
+ struct tpci200_board *tpci200;
+
+ tpci200 = check_slot(dev);
+ if (tpci200 == NULL)
+ return -EINVAL;
+
+ if (mutex_lock_interruptible(&tpci200->mutex))
+ return -ERESTARTSYS;
+
+ if (tpci200->slots[dev->slot].irq == NULL) {
+ mutex_unlock(&tpci200->mutex);
+ return -EINVAL;
+ }
+
+ __tpci200_free_irq(tpci200, dev);
+ slot_irq = tpci200->slots[dev->slot].irq;
+ tpci200->slots[dev->slot].irq = NULL;
+ kfree(slot_irq);
+
+ mutex_unlock(&tpci200->mutex);
+ return 0;
+}
+
+static int tpci200_slot_unmap_space(struct ipack_device *dev, int space)
+{
+ struct ipack_addr_space *virt_addr_space;
+ struct tpci200_board *tpci200;
+
+ tpci200 = check_slot(dev);
+ if (tpci200 == NULL)
+ return -EINVAL;
+
+ if (mutex_lock_interruptible(&tpci200->mutex))
+ return -ERESTARTSYS;
+
+ switch (space) {
+ case IPACK_IO_SPACE:
+ if (dev->io_space.address == NULL) {
+ dev_info(&dev->dev,
+ "Slot [%d:%d] IO space not mapped !\n",
+ dev->bus_nr, dev->slot);
+ goto out_unlock;
+ }
+ virt_addr_space = &dev->io_space;
+ break;
+ case IPACK_ID_SPACE:
+ if (dev->id_space.address == NULL) {
+ dev_info(&dev->dev,
+ "Slot [%d:%d] ID space not mapped !\n",
+ dev->bus_nr, dev->slot);
+ goto out_unlock;
+ }
+ virt_addr_space = &dev->id_space;
+ break;
+ case IPACK_MEM_SPACE:
+ if (dev->mem_space.address == NULL) {
+ dev_info(&dev->dev,
+ "Slot [%d:%d] MEM space not mapped !\n",
+ dev->bus_nr, dev->slot);
+ goto out_unlock;
+ }
+ virt_addr_space = &dev->mem_space;
+ break;
+ default:
+ dev_err(&dev->dev,
+ "Slot [%d:%d] space number %d doesn't exist !\n",
+ dev->bus_nr, dev->slot, space);
+ mutex_unlock(&tpci200->mutex);
+ return -EINVAL;
+ }
+
+ iounmap(virt_addr_space->address);
+
+ virt_addr_space->address = NULL;
+ virt_addr_space->size = 0;
+out_unlock:
+ mutex_unlock(&tpci200->mutex);
+ return 0;
+}
+
+static int tpci200_slot_unregister(struct ipack_device *dev)
+{
+ struct tpci200_board *tpci200;
+
+ if (dev == NULL)
+ return -ENODEV;
+
+ tpci200 = check_slot(dev);
+ if (tpci200 == NULL)
+ return -EINVAL;
+
+ tpci200_free_irq(dev);
+
+ if (mutex_lock_interruptible(&tpci200->mutex))
+ return -ERESTARTSYS;
+
+ ipack_device_unregister(dev);
+ tpci200->slots[dev->slot].dev = NULL;
+ mutex_unlock(&tpci200->mutex);
+
+ return 0;
+}
+
+static int tpci200_slot_map_space(struct ipack_device *dev,
+ unsigned int memory_size, int space)
+{
+ int res = 0;
+ unsigned int size_to_map;
+ void __iomem *phys_address;
+ struct ipack_addr_space *virt_addr_space;
+ struct tpci200_board *tpci200;
+
+ tpci200 = check_slot(dev);
+ if (tpci200 == NULL)
+ return -EINVAL;
+
+ if (mutex_lock_interruptible(&tpci200->mutex))
+ return -ERESTARTSYS;
+
+ switch (space) {
+ case IPACK_IO_SPACE:
+ if (dev->io_space.address != NULL) {
+ dev_err(&dev->dev,
+ "Slot [%d:%d] IO space already mapped !\n",
+ tpci200->number, dev->slot);
+ res = -EINVAL;
+ goto out_unlock;
+ }
+ virt_addr_space = &dev->io_space;
+
+ phys_address = tpci200->slots[dev->slot].io_phys.address;
+ size_to_map = tpci200->slots[dev->slot].io_phys.size;
+ break;
+ case IPACK_ID_SPACE:
+ if (dev->id_space.address != NULL) {
+ dev_err(&dev->dev,
+ "Slot [%d:%d] ID space already mapped !\n",
+ tpci200->number, dev->slot);
+ res = -EINVAL;
+ goto out_unlock;
+ }
+ virt_addr_space = &dev->id_space;
+
+ phys_address = tpci200->slots[dev->slot].id_phys.address;
+ size_to_map = tpci200->slots[dev->slot].id_phys.size;
+ break;
+ case IPACK_MEM_SPACE:
+ if (dev->mem_space.address != NULL) {
+ dev_err(&dev->dev,
+ "Slot [%d:%d] MEM space already mapped !\n",
+ tpci200->number, dev->slot);
+ res = -EINVAL;
+ goto out_unlock;
+ }
+ virt_addr_space = &dev->mem_space;
+
+ if (memory_size > tpci200->slots[dev->slot].mem_phys.size) {
+ dev_err(&dev->dev,
+ "Slot [%d:%d] request is 0x%X memory, only 0x%X available !\n",
+ dev->bus_nr, dev->slot, memory_size,
+ tpci200->slots[dev->slot].mem_phys.size);
+ res = -EINVAL;
+ goto out_unlock;
+ }
+
+ phys_address = tpci200->slots[dev->slot].mem_phys.address;
+ size_to_map = memory_size;
+ break;
+ default:
+ dev_err(&dev->dev, "Slot [%d:%d] space %d doesn't exist !\n",
+ tpci200->number, dev->slot, space);
+ res = -EINVAL;
+ goto out_unlock;
+ }
+
+ virt_addr_space->size = size_to_map;
+ virt_addr_space->address =
+ ioremap((unsigned long)phys_address, size_to_map);
+
+out_unlock:
+ mutex_unlock(&tpci200->mutex);
+ return res;
+}
+
+static int tpci200_request_irq(struct ipack_device *dev, int vector,
+ int (*handler)(void *), void *arg)
+{
+ int res;
+ struct slot_irq *slot_irq;
+ struct tpci200_board *tpci200;
+
+ tpci200 = check_slot(dev);
+ if (tpci200 == NULL)
+ return -EINVAL;
+
+ if (mutex_lock_interruptible(&tpci200->mutex))
+ return -ERESTARTSYS;
+
+ if (tpci200->slots[dev->slot].irq != NULL) {
+ dev_err(&dev->dev,
+ "Slot [%d:%d] IRQ already registered !\n", dev->bus_nr,
+ dev->slot);
+ res = -EINVAL;
+ goto out_unlock;
+ }
+
+ slot_irq = kzalloc(sizeof(struct slot_irq), GFP_KERNEL);
+ if (slot_irq == NULL) {
+ dev_err(&dev->dev,
+ "Slot [%d:%d] unable to allocate memory for IRQ !\n",
+ dev->bus_nr, dev->slot);
+ res = -ENOMEM;
+ goto out_unlock;
+ }
+
+ /*
+ * WARNING: Setup Interrupt Vector in the IndustryPack device
+ * before an IRQ request.
+ * Read the User Manual of your IndustryPack device to know
+ * where to write the vector in memory.
+ */
+ slot_irq->vector = vector;
+ slot_irq->handler = handler;
+ slot_irq->arg = arg;
+
+ tpci200->slots[dev->slot].irq = slot_irq;
+ res = __tpci200_request_irq(tpci200, dev);
+
+out_unlock:
+ mutex_unlock(&tpci200->mutex);
+ return res;
+}
+
+static void tpci200_uninstall(struct tpci200_board *tpci200)
+{
+ int i;
+
+ for (i = 0; i < TPCI200_NB_SLOT; i++)
+ tpci200_slot_unregister(tpci200->slots[i].dev);
+
+ tpci200_unregister(tpci200);
+ kfree(tpci200->slots);
+}
+
+static struct ipack_bus_ops tpci200_bus_ops = {
+ .map_space = tpci200_slot_map_space,
+ .unmap_space = tpci200_slot_unmap_space,
+ .request_irq = tpci200_request_irq,
+ .free_irq = tpci200_free_irq,
+ .read8 = tpci200_read8,
+ .read16 = tpci200_read16,
+ .read32 = tpci200_read32,
+ .write8 = tpci200_write8,
+ .write16 = tpci200_write16,
+ .write32 = tpci200_write32,
+ .remove_device = tpci200_slot_unregister,
+};
+
+static int tpci200_install(struct tpci200_board *tpci200)
+{
+ int res;
+
+ tpci200->slots = kzalloc(
+ TPCI200_NB_SLOT * sizeof(struct tpci200_slot), GFP_KERNEL);
+ if (tpci200->slots == NULL)
+ return -ENOMEM;
+
+ res = tpci200_register(tpci200);
+ if (res) {
+ kfree(tpci200->slots);
+ tpci200->slots = NULL;
+ return res;
+ }
+
+ mutex_init(&tpci200->mutex);
+ return 0;
+}
+
+static int tpci200_pciprobe(struct pci_dev *pdev,
+ const struct pci_device_id *id)
+{
+ int ret, i;
+ struct tpci200_board *tpci200;
+
+ tpci200 = kzalloc(sizeof(struct tpci200_board), GFP_KERNEL);
+ if (!tpci200)
+ return -ENOMEM;
+
+ tpci200->info = kzalloc(sizeof(struct tpci200_infos), GFP_KERNEL);
+ if (!tpci200->info) {
+ kfree(tpci200);
+ return -ENOMEM;
+ }
+
+ /* Save struct pci_dev pointer */
+ tpci200->info->pdev = pdev;
+ tpci200->info->id_table = (struct pci_device_id *)id;
+
+ /* register the device and initialize it */
+ ret = tpci200_install(tpci200);
+ if (ret) {
+ dev_err(&pdev->dev, "Error during tpci200 install !\n");
+ kfree(tpci200->info);
+ kfree(tpci200);
+ return -ENODEV;
+ }
+
+ /* Register the carrier in the industry pack bus driver */
+ tpci200->info->ipack_bus = ipack_bus_register(&pdev->dev,
+ TPCI200_NB_SLOT,
+ &tpci200_bus_ops);
+ if (!tpci200->info->ipack_bus) {
+ dev_err(&pdev->dev,
+ "error registering the carrier on ipack driver\n");
+ tpci200_uninstall(tpci200);
+ kfree(tpci200->info);
+ kfree(tpci200);
+ return -EFAULT;
+ }
+
+ /* save the bus number given by ipack to logging purpose */
+ tpci200->number = tpci200->info->ipack_bus->bus_nr;
+ dev_set_drvdata(&pdev->dev, tpci200);
+ /* add the registered device in an internal linked list */
+ list_add_tail(&tpci200->list, &tpci200_list);
+
+ /*
+ * Give the same IRQ number as the slot number.
+ * The TPCI200 has assigned his own two IRQ by PCI bus driver
+ */
+ for (i = 0; i < TPCI200_NB_SLOT; i++)
+ tpci200->slots[i].dev =
+ ipack_device_register(tpci200->info->ipack_bus, i, i);
+ return ret;
+}
+
+static void __tpci200_pci_remove(struct tpci200_board *tpci200)
+{
+ tpci200_uninstall(tpci200);
+ list_del(&tpci200->list);
+ ipack_bus_unregister(tpci200->info->ipack_bus);
+ kfree(tpci200->info);
+ kfree(tpci200);
+}
+
+static void __devexit tpci200_pci_remove(struct pci_dev *dev)
+{
+ struct tpci200_board *tpci200, *next;
+
+ /* Search the registered device to uninstall it */
+ list_for_each_entry_safe(tpci200, next, &tpci200_list, list) {
+ if (tpci200->info->pdev == dev) {
+ __tpci200_pci_remove(tpci200);
+ break;
+ }
+ }
+}
+
+static DEFINE_PCI_DEVICE_TABLE(tpci200_idtable) = {
+ { TPCI200_VENDOR_ID, TPCI200_DEVICE_ID, TPCI200_SUBVENDOR_ID,
+ TPCI200_SUBDEVICE_ID },
+ { 0, },
+};
+
+MODULE_DEVICE_TABLE(pci, tpci200_idtable);
+
+static struct pci_driver tpci200_pci_drv = {
+ .name = "tpci200",
+ .id_table = tpci200_idtable,
+ .probe = tpci200_pciprobe,
+ .remove = __devexit_p(tpci200_pci_remove),
+};
+
+static int __init tpci200_drvr_init_module(void)
+{
+ return pci_register_driver(&tpci200_pci_drv);
+}
+
+static void __exit tpci200_drvr_exit_module(void)
+{
+ struct tpci200_board *tpci200, *next;
+
+ list_for_each_entry_safe(tpci200, next, &tpci200_list, list)
+ __tpci200_pci_remove(tpci200);
+
+ pci_unregister_driver(&tpci200_pci_drv);
+}
+
+MODULE_DESCRIPTION("TEWS TPCI-200 device driver");
+MODULE_LICENSE("GPL");
+module_init(tpci200_drvr_init_module);
+module_exit(tpci200_drvr_exit_module);
diff --git a/drivers/staging/ipack/bridges/tpci200.h b/drivers/staging/ipack/bridges/tpci200.h
new file mode 100644
index 000000000000..d04510a89be4
--- /dev/null
+++ b/drivers/staging/ipack/bridges/tpci200.h
@@ -0,0 +1,157 @@
+/**
+ * tpci200.h
+ *
+ * driver for the carrier TEWS TPCI-200
+ * Copyright (c) 2009 Nicolas Serafini, EIC2 SA
+ * Copyright (c) 2010,2011 Samuel Iglesias Gonsalvez <siglesia@cern.ch>, CERN
+ * Copyright (c) 2012 Samuel Iglesias Gonsalvez <siglesias@igalia.com>, Igalia
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation; version 2 of the License.
+ */
+
+#ifndef _TPCI200_H_
+#define _TPCI200_H_
+
+#include <linux/limits.h>
+#include <linux/pci.h>
+#include <linux/spinlock.h>
+#include <linux/interrupt.h>
+#include <linux/swab.h>
+#include <linux/io.h>
+
+#include "../ipack.h"
+
+#define TPCI200_NB_SLOT 0x4
+#define TPCI200_NB_BAR 0x6
+
+#define TPCI200_VENDOR_ID 0x1498
+#define TPCI200_DEVICE_ID 0x30C8
+#define TPCI200_SUBVENDOR_ID 0x1498
+#define TPCI200_SUBDEVICE_ID 0x300A
+
+#define TPCI200_IP_INTERFACE_BAR 2
+#define TPCI200_IO_ID_INT_SPACES_BAR 3
+#define TPCI200_MEM16_SPACE_BAR 4
+#define TPCI200_MEM8_SPACE_BAR 5
+
+#define TPCI200_REVISION_REG 0x00
+#define TPCI200_CONTROL_A_REG 0x02
+#define TPCI200_CONTROL_B_REG 0x04
+#define TPCI200_CONTROL_C_REG 0x06
+#define TPCI200_CONTROL_D_REG 0x08
+#define TPCI200_RESET_REG 0x0A
+#define TPCI200_STATUS_REG 0x0C
+
+#define TPCI200_IFACE_SIZE 0x100
+
+#define TPCI200_IO_SPACE_OFF 0x0000
+#define TPCI200_IO_SPACE_GAP 0x0100
+#define TPCI200_IO_SPACE_SIZE 0x0080
+#define TPCI200_ID_SPACE_OFF 0x0080
+#define TPCI200_ID_SPACE_GAP 0x0100
+#define TPCI200_ID_SPACE_SIZE 0x0040
+#define TPCI200_INT_SPACE_OFF 0x00C0
+#define TPCI200_INT_SPACE_GAP 0x0100
+#define TPCI200_INT_SPACE_SIZE 0x0040
+#define TPCI200_IOIDINT_SIZE 0x0400
+
+#define TPCI200_MEM8_GAP 0x00400000
+#define TPCI200_MEM8_SIZE 0x00400000
+#define TPCI200_MEM16_GAP 0x00800000
+#define TPCI200_MEM16_SIZE 0x00800000
+
+#define TPCI200_INT0_EN 0x0040
+#define TPCI200_INT1_EN 0x0080
+#define TPCI200_INT0_EDGE 0x0010
+#define TPCI200_INT1_EDGE 0x0020
+#define TPCI200_ERR_INT_EN 0x0008
+#define TPCI200_TIME_INT_EN 0x0004
+#define TPCI200_RECOVER_EN 0x0002
+#define TPCI200_CLK32 0x0001
+
+#define TPCI200_A_RESET 0x0001
+#define TPCI200_B_RESET 0x0002
+#define TPCI200_C_RESET 0x0004
+#define TPCI200_D_RESET 0x0008
+
+#define TPCI200_A_TIMEOUT 0x1000
+#define TPCI200_B_TIMEOUT 0x2000
+#define TPCI200_C_TIMEOUT 0x4000
+#define TPCI200_D_TIMEOUT 0x8000
+
+#define TPCI200_A_ERROR 0x0100
+#define TPCI200_B_ERROR 0x0200
+#define TPCI200_C_ERROR 0x0400
+#define TPCI200_D_ERROR 0x0800
+
+#define TPCI200_A_INT0 0x0001
+#define TPCI200_A_INT1 0x0002
+#define TPCI200_B_INT0 0x0004
+#define TPCI200_B_INT1 0x0008
+#define TPCI200_C_INT0 0x0010
+#define TPCI200_C_INT1 0x0020
+#define TPCI200_D_INT0 0x0040
+#define TPCI200_D_INT1 0x0080
+
+#define TPCI200_SLOT_INT_MASK 0x00FF
+
+#define VME_IOID_SPACE "IOID"
+#define VME_MEM_SPACE "MEM"
+
+/**
+ * struct slot_irq - slot IRQ definition.
+ * @vector Vector number
+ * @handler Handler called when IRQ arrives
+ * @arg Handler argument
+ *
+ */
+struct slot_irq {
+ int vector;
+ int (*handler)(void *);
+ void *arg;
+};
+
+/**
+ * struct tpci200_slot - data specific to the tpci200 slot.
+ * @slot_id Slot identification gived to external interface
+ * @irq Slot IRQ infos
+ * @io_phys IO physical base address register of the slot
+ * @id_phys ID physical base address register of the slot
+ * @mem_phys MEM physical base address register of the slot
+ *
+ */
+struct tpci200_slot {
+ struct ipack_device *dev;
+ struct slot_irq *irq;
+ struct ipack_addr_space io_phys;
+ struct ipack_addr_space id_phys;
+ struct ipack_addr_space mem_phys;
+};
+
+/**
+ * struct tpci200_infos - informations specific of the TPCI200 tpci200.
+ * @pci_dev PCI device
+ * @interface_regs Pointer to IP interface space (Bar 2)
+ * @ioidint_space Pointer to IP ID, IO and INT space (Bar 3)
+ * @mem8_space Pointer to MEM space (Bar 4)
+ *
+ */
+struct tpci200_infos {
+ struct pci_dev *pdev;
+ struct pci_device_id *id_table;
+ void __iomem *interface_regs;
+ void __iomem *ioidint_space;
+ void __iomem *mem8_space;
+ struct ipack_bus_device *ipack_bus;
+};
+struct tpci200_board {
+ struct list_head list;
+ unsigned int number;
+ struct mutex mutex;
+ struct tpci200_slot *slots;
+ struct tpci200_infos *info;
+};
+
+#endif /* _TPCI200_H_ */
diff --git a/drivers/staging/ipack/devices/Kconfig b/drivers/staging/ipack/devices/Kconfig
new file mode 100644
index 000000000000..39f71888a584
--- /dev/null
+++ b/drivers/staging/ipack/devices/Kconfig
@@ -0,0 +1,7 @@
+config SERIAL_IPOCTAL
+ tristate "IndustryPack IP-OCTAL uart support"
+ depends on IPACK_BUS
+ help
+ This driver supports the IPOCTAL serial port device for the IndustryPack bus.
+ default n
+
diff --git a/drivers/staging/ipack/devices/Makefile b/drivers/staging/ipack/devices/Makefile
new file mode 100644
index 000000000000..6de18bda4a9a
--- /dev/null
+++ b/drivers/staging/ipack/devices/Makefile
@@ -0,0 +1 @@
+obj-$(CONFIG_SERIAL_IPOCTAL) += ipoctal.o
diff --git a/drivers/staging/ipack/devices/ipoctal.c b/drivers/staging/ipack/devices/ipoctal.c
new file mode 100644
index 000000000000..fd0e30132ca2
--- /dev/null
+++ b/drivers/staging/ipack/devices/ipoctal.c
@@ -0,0 +1,892 @@
+/**
+ * ipoctal.c
+ *
+ * driver for the GE IP-OCTAL boards
+ * Copyright (c) 2009 Nicolas Serafini, EIC2 SA
+ * Copyright (c) 2010,2011 Samuel Iglesias Gonsalvez <siglesia@cern.ch>, CERN
+ * Copyright (c) 2012 Samuel Iglesias Gonsalvez <siglesias@igalia.com>, Igalia
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation; version 2 of the License.
+ */
+
+#include <linux/device.h>
+#include <linux/module.h>
+#include <linux/interrupt.h>
+#include <linux/sched.h>
+#include <linux/tty.h>
+#include <linux/serial.h>
+#include <linux/tty_flip.h>
+#include <linux/slab.h>
+#include <linux/atomic.h>
+#include "../ipack.h"
+#include "ipoctal.h"
+#include "scc2698.h"
+
+#define IP_OCTAL_MANUFACTURER_ID 0xF0
+#define IP_OCTAL_232_ID 0x22
+#define IP_OCTAL_422_ID 0x2A
+#define IP_OCTAL_485_ID 0x48
+
+#define IP_OCTAL_ID_SPACE_VECTOR 0x41
+#define IP_OCTAL_NB_BLOCKS 4
+
+static struct ipack_driver driver;
+static const struct tty_operations ipoctal_fops;
+
+struct ipoctal {
+ struct list_head list;
+ struct ipack_device *dev;
+ unsigned int board_id;
+ struct scc2698_channel *chan_regs;
+ struct scc2698_block *block_regs;
+ struct ipoctal_stats chan_stats[NR_CHANNELS];
+ unsigned int nb_bytes[NR_CHANNELS];
+ unsigned int count_wr[NR_CHANNELS];
+ wait_queue_head_t queue[NR_CHANNELS];
+ spinlock_t lock[NR_CHANNELS];
+ unsigned int pointer_read[NR_CHANNELS];
+ unsigned int pointer_write[NR_CHANNELS];
+ atomic_t open[NR_CHANNELS];
+ unsigned char write;
+ struct tty_port tty_port[NR_CHANNELS];
+ struct tty_driver *tty_drv;
+};
+
+/* Linked list to save the registered devices */
+static LIST_HEAD(ipoctal_list);
+
+static inline void ipoctal_write_io_reg(struct ipoctal *ipoctal,
+ unsigned char *dest,
+ unsigned char value)
+{
+ unsigned long offset;
+
+ offset = ((void __iomem *) dest) - ipoctal->dev->io_space.address;
+ ipoctal->dev->bus->ops->write8(ipoctal->dev, IPACK_IO_SPACE, offset,
+ value);
+}
+
+static inline void ipoctal_write_cr_cmd(struct ipoctal *ipoctal,
+ unsigned char *dest,
+ unsigned char value)
+{
+ ipoctal_write_io_reg(ipoctal, dest, value);
+}
+
+static inline unsigned char ipoctal_read_io_reg(struct ipoctal *ipoctal,
+ unsigned char *src)
+{
+ unsigned long offset;
+ unsigned char value;
+
+ offset = ((void __iomem *) src) - ipoctal->dev->io_space.address;
+ ipoctal->dev->bus->ops->read8(ipoctal->dev, IPACK_IO_SPACE, offset,
+ &value);
+ return value;
+}
+
+static struct ipoctal *ipoctal_find_board(struct tty_struct *tty)
+{
+ struct ipoctal *p;
+
+ list_for_each_entry(p, &ipoctal_list, list) {
+ if (tty->driver->major == p->tty_drv->major)
+ return p;
+ }
+
+ return NULL;
+}
+
+static int ipoctal_port_activate(struct tty_port *port, struct tty_struct *tty)
+{
+ struct ipoctal *ipoctal;
+ int channel = tty->index;
+
+ ipoctal = ipoctal_find_board(tty);
+
+ if (ipoctal == NULL) {
+ dev_err(tty->dev, "Device not found. Major %d\n",
+ tty->driver->major);
+ return -ENODEV;
+ }
+
+ ipoctal_write_io_reg(ipoctal, &ipoctal->chan_regs[channel].u.w.cr,
+ CR_ENABLE_RX);
+ return 0;
+}
+
+static int ipoctal_open(struct tty_struct *tty, struct file *file)
+{
+ int channel = tty->index;
+ int res;
+ struct ipoctal *ipoctal;
+
+ ipoctal = ipoctal_find_board(tty);
+
+ if (ipoctal == NULL) {
+ dev_err(tty->dev, "Device not found. Major %d\n",
+ tty->driver->major);
+ return -ENODEV;
+ }
+
+ if (atomic_read(&ipoctal->open[channel]))
+ return -EBUSY;
+
+ tty->driver_data = ipoctal;
+
+ res = tty_port_open(&ipoctal->tty_port[channel], tty, file);
+ if (res)
+ return res;
+
+ atomic_inc(&ipoctal->open[channel]);
+ return 0;
+}
+
+static void ipoctal_reset_stats(struct ipoctal_stats *stats)
+{
+ stats->tx = 0;
+ stats->rx = 0;
+ stats->rcv_break = 0;
+ stats->framing_err = 0;
+ stats->overrun_err = 0;
+ stats->parity_err = 0;
+}
+
+static void ipoctal_free_channel(struct tty_struct *tty)
+{
+ int channel = tty->index;
+ struct ipoctal *ipoctal = tty->driver_data;
+
+ if (ipoctal == NULL)
+ return;
+
+ ipoctal_reset_stats(&ipoctal->chan_stats[channel]);
+ ipoctal->pointer_read[channel] = 0;
+ ipoctal->pointer_write[channel] = 0;
+ ipoctal->nb_bytes[channel] = 0;
+}
+
+static void ipoctal_close(struct tty_struct *tty, struct file *filp)
+{
+ int channel = tty->index;
+ struct ipoctal *ipoctal = tty->driver_data;
+
+ tty_port_close(&ipoctal->tty_port[channel], tty, filp);
+
+ if (atomic_dec_and_test(&ipoctal->open[channel]))
+ ipoctal_free_channel(tty);
+}
+
+static int ipoctal_get_icount(struct tty_struct *tty,
+ struct serial_icounter_struct *icount)
+{
+ struct ipoctal *ipoctal = tty->driver_data;
+ int channel = tty->index;
+
+ icount->cts = 0;
+ icount->dsr = 0;
+ icount->rng = 0;
+ icount->dcd = 0;
+ icount->rx = ipoctal->chan_stats[channel].rx;
+ icount->tx = ipoctal->chan_stats[channel].tx;
+ icount->frame = ipoctal->chan_stats[channel].framing_err;
+ icount->parity = ipoctal->chan_stats[channel].parity_err;
+ icount->brk = ipoctal->chan_stats[channel].rcv_break;
+ return 0;
+}
+
+static int ipoctal_irq_handler(void *arg)
+{
+ unsigned int channel;
+ unsigned int block;
+ unsigned char isr;
+ unsigned char sr;
+ unsigned char isr_tx_rdy, isr_rx_rdy;
+ unsigned char value;
+ unsigned char flag;
+ struct tty_struct *tty;
+ struct ipoctal *ipoctal = (struct ipoctal *) arg;
+
+ /* Check all channels */
+ for (channel = 0; channel < NR_CHANNELS; channel++) {
+ /* If there is no client, skip the check */
+ if (!atomic_read(&ipoctal->open[channel]))
+ continue;
+
+ tty = tty_port_tty_get(&ipoctal->tty_port[channel]);
+ if (!tty)
+ continue;
+
+ /*
+ * The HW is organized in pair of channels.
+ * See which register we need to read from
+ */
+ block = channel / 2;
+ isr = ipoctal_read_io_reg(ipoctal,
+ &ipoctal->block_regs[block].u.r.isr);
+ sr = ipoctal_read_io_reg(ipoctal,
+ &ipoctal->chan_regs[channel].u.r.sr);
+
+ if ((channel % 2) == 1) {
+ isr_tx_rdy = isr & ISR_TxRDY_B;
+ isr_rx_rdy = isr & ISR_RxRDY_FFULL_B;
+ } else {
+ isr_tx_rdy = isr & ISR_TxRDY_A;
+ isr_rx_rdy = isr & ISR_RxRDY_FFULL_A;
+ }
+
+ /* In case of RS-485, change from TX to RX when finishing TX.
+ * Half-duplex.
+ */
+ if ((ipoctal->board_id == IP_OCTAL_485_ID) &&
+ (sr & SR_TX_EMPTY) &&
+ (ipoctal->nb_bytes[channel] == 0)) {
+ ipoctal_write_io_reg(ipoctal,
+ &ipoctal->chan_regs[channel].u.w.cr,
+ CR_DISABLE_TX);
+ ipoctal_write_cr_cmd(ipoctal,
+ &ipoctal->chan_regs[channel].u.w.cr,
+ CR_CMD_NEGATE_RTSN);
+ ipoctal_write_io_reg(ipoctal,
+ &ipoctal->chan_regs[channel].u.w.cr,
+ CR_ENABLE_RX);
+ ipoctal->write = 1;
+ wake_up_interruptible(&ipoctal->queue[channel]);
+ }
+
+ /* RX data */
+ if (isr_rx_rdy && (sr & SR_RX_READY)) {
+ value = ipoctal_read_io_reg(ipoctal,
+ &ipoctal->chan_regs[channel].u.r.rhr);
+ flag = TTY_NORMAL;
+
+ /* Error: count statistics */
+ if (sr & SR_ERROR) {
+ ipoctal_write_cr_cmd(ipoctal,
+ &ipoctal->chan_regs[channel].u.w.cr,
+ CR_CMD_RESET_ERR_STATUS);
+
+ if (sr & SR_OVERRUN_ERROR) {
+ ipoctal->chan_stats[channel].overrun_err++;
+ /* Overrun doesn't affect the current character*/
+ tty_insert_flip_char(tty, 0, TTY_OVERRUN);
+ }
+ if (sr & SR_PARITY_ERROR) {
+ ipoctal->chan_stats[channel].parity_err++;
+ flag = TTY_PARITY;
+ }
+ if (sr & SR_FRAMING_ERROR) {
+ ipoctal->chan_stats[channel].framing_err++;
+ flag = TTY_FRAME;
+ }
+ if (sr & SR_RECEIVED_BREAK) {
+ ipoctal->chan_stats[channel].rcv_break++;
+ flag = TTY_BREAK;
+ }
+ }
+
+ tty_insert_flip_char(tty, value, flag);
+ }
+
+ /* TX of each character */
+ if (isr_tx_rdy && (sr & SR_TX_READY)) {
+ unsigned int *pointer_write =
+ &ipoctal->pointer_write[channel];
+
+ if (ipoctal->nb_bytes[channel] <= 0) {
+ ipoctal->nb_bytes[channel] = 0;
+ continue;
+ }
+
+ value = ipoctal->tty_port[channel].xmit_buf[*pointer_write];
+ ipoctal_write_io_reg(ipoctal,
+ &ipoctal->chan_regs[channel].u.w.thr,
+ value);
+ ipoctal->chan_stats[channel].tx++;
+ ipoctal->count_wr[channel]++;
+ (*pointer_write)++;
+ *pointer_write = *pointer_write % PAGE_SIZE;
+ ipoctal->nb_bytes[channel]--;
+
+ if ((ipoctal->nb_bytes[channel] == 0) &&
+ (waitqueue_active(&ipoctal->queue[channel]))) {
+
+ if (ipoctal->board_id != IP_OCTAL_485_ID) {
+ ipoctal->write = 1;
+ wake_up_interruptible(&ipoctal->queue[channel]);
+ }
+ }
+ }
+
+ tty_flip_buffer_push(tty);
+ tty_kref_put(tty);
+ }
+ return IRQ_HANDLED;
+}
+
+static int ipoctal_check_model(struct ipack_device *dev, unsigned char *id)
+{
+ unsigned char manufacturerID;
+ unsigned char board_id;
+
+ dev->bus->ops->read8(dev, IPACK_ID_SPACE,
+ IPACK_IDPROM_OFFSET_MANUFACTURER_ID, &manufacturerID);
+ if (manufacturerID != IP_OCTAL_MANUFACTURER_ID)
+ return -ENODEV;
+
+ dev->bus->ops->read8(dev, IPACK_ID_SPACE,
+ IPACK_IDPROM_OFFSET_MODEL, (unsigned char *)&board_id);
+
+ switch (board_id) {
+ case IP_OCTAL_232_ID:
+ case IP_OCTAL_422_ID:
+ case IP_OCTAL_485_ID:
+ *id = board_id;
+ break;
+ default:
+ return -ENODEV;
+ }
+
+ return 0;
+}
+
+static const struct tty_port_operations ipoctal_tty_port_ops = {
+ .dtr_rts = NULL,
+ .activate = ipoctal_port_activate,
+};
+
+static int ipoctal_inst_slot(struct ipoctal *ipoctal, unsigned int bus_nr,
+ unsigned int slot, unsigned int vector)
+{
+ int res = 0;
+ int i;
+ struct tty_driver *tty;
+ char name[20];
+ unsigned char board_id;
+
+ res = ipoctal->dev->bus->ops->map_space(ipoctal->dev, 0,
+ IPACK_ID_SPACE);
+ if (res) {
+ dev_err(&ipoctal->dev->dev,
+ "Unable to map slot [%d:%d] ID space!\n",
+ bus_nr, slot);
+ return res;
+ }
+
+ res = ipoctal_check_model(ipoctal->dev, &board_id);
+ if (res) {
+ ipoctal->dev->bus->ops->unmap_space(ipoctal->dev,
+ IPACK_ID_SPACE);
+ goto out_unregister_id_space;
+ }
+ ipoctal->board_id = board_id;
+
+ res = ipoctal->dev->bus->ops->map_space(ipoctal->dev, 0,
+ IPACK_IO_SPACE);
+ if (res) {
+ dev_err(&ipoctal->dev->dev,
+ "Unable to map slot [%d:%d] IO space!\n",
+ bus_nr, slot);
+ goto out_unregister_id_space;
+ }
+
+ res = ipoctal->dev->bus->ops->map_space(ipoctal->dev,
+ 0x8000, IPACK_MEM_SPACE);
+ if (res) {
+ dev_err(&ipoctal->dev->dev,
+ "Unable to map slot [%d:%d] MEM space!\n",
+ bus_nr, slot);
+ goto out_unregister_io_space;
+ }
+
+ /* Save the virtual address to access the registers easily */
+ ipoctal->chan_regs =
+ (struct scc2698_channel *) ipoctal->dev->io_space.address;
+ ipoctal->block_regs =
+ (struct scc2698_block *) ipoctal->dev->io_space.address;
+
+ /* Disable RX and TX before touching anything */
+ for (i = 0; i < NR_CHANNELS ; i++) {
+ ipoctal_write_io_reg(ipoctal, &ipoctal->chan_regs[i].u.w.cr,
+ CR_DISABLE_RX | CR_DISABLE_TX);
+ ipoctal_write_cr_cmd(ipoctal, &ipoctal->chan_regs[i].u.w.cr,
+ CR_CMD_RESET_RX);
+ ipoctal_write_cr_cmd(ipoctal, &ipoctal->chan_regs[i].u.w.cr,
+ CR_CMD_RESET_TX);
+ ipoctal_write_io_reg(ipoctal,
+ &ipoctal->chan_regs[i].u.w.mr,
+ MR1_CHRL_8_BITS | MR1_ERROR_CHAR |
+ MR1_RxINT_RxRDY); /* mr1 */
+ ipoctal_write_io_reg(ipoctal,
+ &ipoctal->chan_regs[i].u.w.mr,
+ 0); /* mr2 */
+ ipoctal_write_io_reg(ipoctal,
+ &ipoctal->chan_regs[i].u.w.csr,
+ TX_CLK_9600 | RX_CLK_9600);
+ }
+
+ for (i = 0; i < IP_OCTAL_NB_BLOCKS; i++) {
+ ipoctal_write_io_reg(ipoctal,
+ &ipoctal->block_regs[i].u.w.acr,
+ ACR_BRG_SET2);
+ ipoctal_write_io_reg(ipoctal,
+ &ipoctal->block_regs[i].u.w.opcr,
+ OPCR_MPP_OUTPUT | OPCR_MPOa_RTSN |
+ OPCR_MPOb_RTSN);
+ ipoctal_write_io_reg(ipoctal,
+ &ipoctal->block_regs[i].u.w.imr,
+ IMR_TxRDY_A | IMR_RxRDY_FFULL_A |
+ IMR_DELTA_BREAK_A | IMR_TxRDY_B |
+ IMR_RxRDY_FFULL_B | IMR_DELTA_BREAK_B);
+ }
+
+ /*
+ * IP-OCTAL has different addresses to copy its IRQ vector.
+ * Depending of the carrier these addresses are accesible or not.
+ * More info in the datasheet.
+ */
+ ipoctal->dev->bus->ops->request_irq(ipoctal->dev, vector,
+ ipoctal_irq_handler, ipoctal);
+ ipoctal->dev->bus->ops->write8(ipoctal->dev, IPACK_MEM_SPACE, 0,
+ vector);
+
+ /* Register the TTY device */
+
+ /* Each IP-OCTAL channel is a TTY port */
+ tty = alloc_tty_driver(NR_CHANNELS);
+
+ if (!tty) {
+ res = -ENOMEM;
+ goto out_unregister_slot_unmap;
+ }
+
+ /* Fill struct tty_driver with ipoctal data */
+ tty->owner = THIS_MODULE;
+ tty->driver_name = "ipoctal";
+ sprintf(name, "ipoctal.%d.%d.", bus_nr, slot);
+ tty->name = name;
+ tty->major = 0;
+
+ tty->minor_start = 0;
+ tty->type = TTY_DRIVER_TYPE_SERIAL;
+ tty->subtype = SERIAL_TYPE_NORMAL;
+ tty->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV;
+ tty->init_termios = tty_std_termios;
+ tty->init_termios.c_cflag = B9600 | CS8 | CREAD | HUPCL | CLOCAL;
+ tty->init_termios.c_ispeed = 9600;
+ tty->init_termios.c_ospeed = 9600;
+
+ tty_set_operations(tty, &ipoctal_fops);
+ res = tty_register_driver(tty);
+ if (res) {
+ dev_err(&ipoctal->dev->dev, "Can't register tty driver.\n");
+ put_tty_driver(tty);
+ goto out_unregister_slot_unmap;
+ }
+
+ /* Save struct tty_driver for use it when uninstalling the device */
+ ipoctal->tty_drv = tty;
+
+ for (i = 0; i < NR_CHANNELS; i++) {
+ tty_port_init(&ipoctal->tty_port[i]);
+ tty_port_alloc_xmit_buf(&ipoctal->tty_port[i]);
+ ipoctal->tty_port[i].ops = &ipoctal_tty_port_ops;
+
+ ipoctal_reset_stats(&ipoctal->chan_stats[i]);
+ ipoctal->nb_bytes[i] = 0;
+ init_waitqueue_head(&ipoctal->queue[i]);
+
+ spin_lock_init(&ipoctal->lock[i]);
+ ipoctal->pointer_read[i] = 0;
+ ipoctal->pointer_write[i] = 0;
+ ipoctal->nb_bytes[i] = 0;
+ tty_register_device(tty, i, NULL);
+
+ /*
+ * Enable again the RX. TX will be enabled when
+ * there is something to send
+ */
+ ipoctal_write_io_reg(ipoctal, &ipoctal->chan_regs[i].u.w.cr,
+ CR_ENABLE_RX);
+ }
+
+ return 0;
+
+out_unregister_slot_unmap:
+ ipoctal->dev->bus->ops->unmap_space(ipoctal->dev, IPACK_ID_SPACE);
+out_unregister_io_space:
+ ipoctal->dev->bus->ops->unmap_space(ipoctal->dev, IPACK_IO_SPACE);
+out_unregister_id_space:
+ ipoctal->dev->bus->ops->unmap_space(ipoctal->dev, IPACK_MEM_SPACE);
+ return res;
+}
+
+static inline int ipoctal_copy_write_buffer(struct ipoctal *ipoctal,
+ unsigned int channel,
+ const unsigned char *buf,
+ int count)
+{
+ unsigned long flags;
+ int i;
+ unsigned int *pointer_read = &ipoctal->pointer_read[channel];
+
+ /* Copy the bytes from the user buffer to the internal one */
+ for (i = 0; i < count; i++) {
+ if (i <= (PAGE_SIZE - ipoctal->nb_bytes[channel])) {
+ spin_lock_irqsave(&ipoctal->lock[channel], flags);
+ ipoctal->tty_port[channel].xmit_buf[*pointer_read] = buf[i];
+ *pointer_read = (*pointer_read + 1) % PAGE_SIZE;
+ ipoctal->nb_bytes[channel]++;
+ spin_unlock_irqrestore(&ipoctal->lock[channel], flags);
+ } else {
+ break;
+ }
+ }
+ return i;
+}
+
+static int ipoctal_write(struct ipoctal *ipoctal, unsigned int channel,
+ const unsigned char *buf, int count)
+{
+ ipoctal->nb_bytes[channel] = 0;
+ ipoctal->count_wr[channel] = 0;
+
+ ipoctal_copy_write_buffer(ipoctal, channel, buf, count);
+
+ /* As the IP-OCTAL 485 only supports half duplex, do it manually */
+ if (ipoctal->board_id == IP_OCTAL_485_ID) {
+ ipoctal_write_io_reg(ipoctal,
+ &ipoctal->chan_regs[channel].u.w.cr,
+ CR_DISABLE_RX);
+ ipoctal_write_cr_cmd(ipoctal,
+ &ipoctal->chan_regs[channel].u.w.cr,
+ CR_CMD_ASSERT_RTSN);
+ }
+
+ /*
+ * Send a packet and then disable TX to avoid failure after several send
+ * operations
+ */
+ ipoctal_write_io_reg(ipoctal,
+ &ipoctal->chan_regs[channel].u.w.cr,
+ CR_ENABLE_TX);
+ wait_event_interruptible(ipoctal->queue[channel], ipoctal->write);
+ ipoctal_write_io_reg(ipoctal,
+ &ipoctal->chan_regs[channel].u.w.cr,
+ CR_DISABLE_TX);
+
+ ipoctal->write = 0;
+ return ipoctal->count_wr[channel];
+}
+
+static int ipoctal_write_tty(struct tty_struct *tty,
+ const unsigned char *buf, int count)
+{
+ unsigned int channel = tty->index;
+ struct ipoctal *ipoctal = tty->driver_data;
+
+ return ipoctal_write(ipoctal, channel, buf, count);
+}
+
+static int ipoctal_write_room(struct tty_struct *tty)
+{
+ int channel = tty->index;
+ struct ipoctal *ipoctal = tty->driver_data;
+
+ return PAGE_SIZE - ipoctal->nb_bytes[channel];
+}
+
+static int ipoctal_chars_in_buffer(struct tty_struct *tty)
+{
+ int channel = tty->index;
+ struct ipoctal *ipoctal = tty->driver_data;
+
+ return ipoctal->nb_bytes[channel];
+}
+
+static void ipoctal_set_termios(struct tty_struct *tty,
+ struct ktermios *old_termios)
+{
+ unsigned int cflag;
+ unsigned char mr1 = 0;
+ unsigned char mr2 = 0;
+ unsigned char csr = 0;
+ unsigned int channel = tty->index;
+ struct ipoctal *ipoctal = tty->driver_data;
+ speed_t baud;
+
+ cflag = tty->termios->c_cflag;
+
+ /* Disable and reset everything before change the setup */
+ ipoctal_write_io_reg(ipoctal, &ipoctal->chan_regs[channel].u.w.cr,
+ CR_DISABLE_RX | CR_DISABLE_TX);
+ ipoctal_write_cr_cmd(ipoctal, &ipoctal->chan_regs[channel].u.w.cr,
+ CR_CMD_RESET_RX);
+ ipoctal_write_cr_cmd(ipoctal, &ipoctal->chan_regs[channel].u.w.cr,
+ CR_CMD_RESET_TX);
+ ipoctal_write_cr_cmd(ipoctal, &ipoctal->chan_regs[channel].u.w.cr,
+ CR_CMD_RESET_ERR_STATUS);
+ ipoctal_write_cr_cmd(ipoctal, &ipoctal->chan_regs[channel].u.w.cr,
+ CR_CMD_RESET_MR);
+
+ /* Set Bits per chars */
+ switch (cflag & CSIZE) {
+ case CS6:
+ mr1 |= MR1_CHRL_6_BITS;
+ break;
+ case CS7:
+ mr1 |= MR1_CHRL_7_BITS;
+ break;
+ case CS8:
+ default:
+ mr1 |= MR1_CHRL_8_BITS;
+ /* By default, select CS8 */
+ tty->termios->c_cflag = (cflag & ~CSIZE) | CS8;
+ break;
+ }
+
+ /* Set Parity */
+ if (cflag & PARENB)
+ if (cflag & PARODD)
+ mr1 |= MR1_PARITY_ON | MR1_PARITY_ODD;
+ else
+ mr1 |= MR1_PARITY_ON | MR1_PARITY_EVEN;
+ else
+ mr1 |= MR1_PARITY_OFF;
+
+ /* Mark or space parity is not supported */
+ tty->termios->c_cflag &= ~CMSPAR;
+
+ /* Set stop bits */
+ if (cflag & CSTOPB)
+ mr2 |= MR2_STOP_BITS_LENGTH_2;
+ else
+ mr2 |= MR2_STOP_BITS_LENGTH_1;
+
+ /* Set the flow control */
+ switch (ipoctal->board_id) {
+ case IP_OCTAL_232_ID:
+ if (cflag & CRTSCTS) {
+ mr1 |= MR1_RxRTS_CONTROL_ON;
+ mr2 |= MR2_TxRTS_CONTROL_OFF | MR2_CTS_ENABLE_TX_ON;
+ } else {
+ mr1 |= MR1_RxRTS_CONTROL_OFF;
+ mr2 |= MR2_TxRTS_CONTROL_OFF | MR2_CTS_ENABLE_TX_OFF;
+ }
+ break;
+ case IP_OCTAL_422_ID:
+ mr1 |= MR1_RxRTS_CONTROL_OFF;
+ mr2 |= MR2_TxRTS_CONTROL_OFF | MR2_CTS_ENABLE_TX_OFF;
+ break;
+ case IP_OCTAL_485_ID:
+ mr1 |= MR1_RxRTS_CONTROL_OFF;
+ mr2 |= MR2_TxRTS_CONTROL_ON | MR2_CTS_ENABLE_TX_OFF;
+ break;
+ default:
+ return;
+ break;
+ }
+
+ baud = tty_get_baud_rate(tty);
+ tty_termios_encode_baud_rate(tty->termios, baud, baud);
+
+ /* Set baud rate */
+ switch (tty->termios->c_ospeed) {
+ case 75:
+ csr |= TX_CLK_75 | RX_CLK_75;
+ break;
+ case 110:
+ csr |= TX_CLK_110 | RX_CLK_110;
+ break;
+ case 150:
+ csr |= TX_CLK_150 | RX_CLK_150;
+ break;
+ case 300:
+ csr |= TX_CLK_300 | RX_CLK_300;
+ break;
+ case 600:
+ csr |= TX_CLK_600 | RX_CLK_600;
+ break;
+ case 1200:
+ csr |= TX_CLK_1200 | RX_CLK_1200;
+ break;
+ case 1800:
+ csr |= TX_CLK_1800 | RX_CLK_1800;
+ break;
+ case 2000:
+ csr |= TX_CLK_2000 | RX_CLK_2000;
+ break;
+ case 2400:
+ csr |= TX_CLK_2400 | RX_CLK_2400;
+ break;
+ case 4800:
+ csr |= TX_CLK_4800 | RX_CLK_4800;
+ break;
+ case 9600:
+ csr |= TX_CLK_9600 | RX_CLK_9600;
+ break;
+ case 19200:
+ csr |= TX_CLK_19200 | RX_CLK_19200;
+ break;
+ case 38400:
+ default:
+ csr |= TX_CLK_38400 | RX_CLK_38400;
+ /* In case of default, we establish 38400 bps */
+ tty_termios_encode_baud_rate(tty->termios, 38400, 38400);
+ break;
+ }
+
+ mr1 |= MR1_ERROR_CHAR;
+ mr1 |= MR1_RxINT_RxRDY;
+
+ /* Write the control registers */
+ ipoctal_write_io_reg(ipoctal, &ipoctal->chan_regs[channel].u.w.mr, mr1);
+ ipoctal_write_io_reg(ipoctal, &ipoctal->chan_regs[channel].u.w.mr, mr2);
+ ipoctal_write_io_reg(ipoctal, &ipoctal->chan_regs[channel].u.w.csr, csr);
+
+ /* Enable again the RX */
+ ipoctal_write_io_reg(ipoctal, &ipoctal->chan_regs[channel].u.w.cr,
+ CR_ENABLE_RX);
+}
+
+static void ipoctal_hangup(struct tty_struct *tty)
+{
+ unsigned long flags;
+ int channel = tty->index;
+ struct ipoctal *ipoctal = tty->driver_data;
+
+ if (ipoctal == NULL)
+ return;
+
+ spin_lock_irqsave(&ipoctal->lock[channel], flags);
+ ipoctal->nb_bytes[channel] = 0;
+ ipoctal->pointer_read[channel] = 0;
+ ipoctal->pointer_write[channel] = 0;
+ spin_unlock_irqrestore(&ipoctal->lock[channel], flags);
+
+ tty_port_hangup(&ipoctal->tty_port[channel]);
+
+ ipoctal_write_io_reg(ipoctal, &ipoctal->chan_regs[channel].u.w.cr,
+ CR_DISABLE_RX | CR_DISABLE_TX);
+ ipoctal_write_cr_cmd(ipoctal, &ipoctal->chan_regs[channel].u.w.cr,
+ CR_CMD_RESET_RX);
+ ipoctal_write_cr_cmd(ipoctal, &ipoctal->chan_regs[channel].u.w.cr,
+ CR_CMD_RESET_TX);
+ ipoctal_write_cr_cmd(ipoctal, &ipoctal->chan_regs[channel].u.w.cr,
+ CR_CMD_RESET_ERR_STATUS);
+ ipoctal_write_cr_cmd(ipoctal, &ipoctal->chan_regs[channel].u.w.cr,
+ CR_CMD_RESET_MR);
+
+ clear_bit(ASYNCB_INITIALIZED, &ipoctal->tty_port[channel].flags);
+ wake_up_interruptible(&ipoctal->tty_port[channel].open_wait);
+}
+
+static const struct tty_operations ipoctal_fops = {
+ .ioctl = NULL,
+ .open = ipoctal_open,
+ .close = ipoctal_close,
+ .write = ipoctal_write_tty,
+ .set_termios = ipoctal_set_termios,
+ .write_room = ipoctal_write_room,
+ .chars_in_buffer = ipoctal_chars_in_buffer,
+ .get_icount = ipoctal_get_icount,
+ .hangup = ipoctal_hangup,
+};
+
+static int ipoctal_match(struct ipack_device *dev)
+{
+ int res;
+ unsigned char board_id;
+
+ if ((!dev->bus->ops) || (!dev->bus->ops->map_space) ||
+ (!dev->bus->ops->unmap_space))
+ return 0;
+
+ res = dev->bus->ops->map_space(dev, 0, IPACK_ID_SPACE);
+ if (res)
+ return 0;
+
+ res = ipoctal_check_model(dev, &board_id);
+ dev->bus->ops->unmap_space(dev, IPACK_ID_SPACE);
+ if (!res)
+ return 1;
+
+ return 0;
+}
+
+static int ipoctal_probe(struct ipack_device *dev)
+{
+ int res;
+ struct ipoctal *ipoctal;
+
+ ipoctal = kzalloc(sizeof(struct ipoctal), GFP_KERNEL);
+ if (ipoctal == NULL)
+ return -ENOMEM;
+
+ ipoctal->dev = dev;
+ res = ipoctal_inst_slot(ipoctal, dev->bus_nr, dev->slot, dev->irq);
+ if (res)
+ goto out_uninst;
+
+ list_add_tail(&ipoctal->list, &ipoctal_list);
+ return 0;
+
+out_uninst:
+ kfree(ipoctal);
+ return res;
+}
+
+static void __ipoctal_remove(struct ipoctal *ipoctal)
+{
+ int i;
+
+ for (i = 0; i < NR_CHANNELS; i++) {
+ tty_unregister_device(ipoctal->tty_drv, i);
+ tty_port_free_xmit_buf(&ipoctal->tty_port[i]);
+ }
+
+ tty_unregister_driver(ipoctal->tty_drv);
+ put_tty_driver(ipoctal->tty_drv);
+ list_del(&ipoctal->list);
+ kfree(ipoctal);
+}
+
+static void ipoctal_remove(struct ipack_device *device)
+{
+ struct ipoctal *ipoctal, *next;
+
+ list_for_each_entry_safe(ipoctal, next, &ipoctal_list, list) {
+ if (ipoctal->dev == device)
+ __ipoctal_remove(ipoctal);
+ }
+}
+
+static struct ipack_driver_ops ipoctal_drv_ops = {
+ .match = ipoctal_match,
+ .probe = ipoctal_probe,
+ .remove = ipoctal_remove,
+};
+
+static int __init ipoctal_init(void)
+{
+ driver.ops = &ipoctal_drv_ops;
+ return ipack_driver_register(&driver, THIS_MODULE, KBUILD_MODNAME);
+}
+
+static void __exit ipoctal_exit(void)
+{
+ struct ipoctal *p, *next;
+
+ list_for_each_entry_safe(p, next, &ipoctal_list, list)
+ p->dev->bus->ops->remove_device(p->dev);
+
+ ipack_driver_unregister(&driver);
+}
+
+MODULE_DESCRIPTION("IP-Octal 232, 422 and 485 device driver");
+MODULE_LICENSE("GPL");
+
+module_init(ipoctal_init);
+module_exit(ipoctal_exit);
diff --git a/drivers/staging/ipack/devices/ipoctal.h b/drivers/staging/ipack/devices/ipoctal.h
new file mode 100644
index 000000000000..c5b4ed46516f
--- /dev/null
+++ b/drivers/staging/ipack/devices/ipoctal.h
@@ -0,0 +1,41 @@
+/**
+ * ipoctal.h
+ *
+ * driver for the IPOCTAL boards
+ * Copyright (c) 2009 Nicolas Serafini, EIC2 SA
+ * Copyright (c) 2010,2011 Samuel Iglesias Gonsalvez <siglesia@cern.ch>, CERN
+ * Copyright (c) 2012 Samuel Iglesias Gonsalvez <siglesias@igalia.com>, Igalia
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation; version 2 of the License.
+ */
+
+#ifndef _IPOCTAL_H
+#define _IPOCTAL_H_
+
+#define NR_CHANNELS 8
+#define IPOCTAL_MAX_BOARDS 16
+#define MAX_DEVICES (NR_CHANNELS * IPOCTAL_MAX_BOARDS)
+#define RELEVANT_IFLAG(iflag) ((iflag) & (IGNBRK|BRKINT|IGNPAR|PARMRK|INPCK))
+
+/**
+ * struct ipoctal_stats -- Stats since last reset
+ *
+ * @tx: Number of transmitted bytes
+ * @rx: Number of received bytes
+ * @overrun: Number of overrun errors
+ * @parity_err: Number of parity errors
+ * @framing_err: Number of framing errors
+ * @rcv_break: Number of break received
+ */
+struct ipoctal_stats {
+ unsigned long tx;
+ unsigned long rx;
+ unsigned long overrun_err;
+ unsigned long parity_err;
+ unsigned long framing_err;
+ unsigned long rcv_break;
+};
+
+#endif /* _IPOCTAL_H_ */
diff --git a/drivers/staging/ipack/devices/scc2698.h b/drivers/staging/ipack/devices/scc2698.h
new file mode 100644
index 000000000000..47f6269985fd
--- /dev/null
+++ b/drivers/staging/ipack/devices/scc2698.h
@@ -0,0 +1,228 @@
+/*
+ * scc2698.h
+ *
+ * driver for the IPOCTAL boards
+ * Copyright (c) 2009 Nicolas Serafini, EIC2 SA
+ * Copyright (c) 2010,2011 Samuel Iglesias Gonsalvez <siglesia@cern.ch>, CERN
+ * Copyright (c) 2012 Samuel Iglesias Gonsalvez <siglesias@igalia.com>, Igalia
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation; version 2 of the License.
+ */
+
+#ifndef SCC2698_H_
+#define SCC2698_H_
+
+/*
+ * struct scc2698_channel - Channel access to scc2698 IO
+ *
+ * dn value are only spacer.
+ *
+ */
+struct scc2698_channel {
+ union {
+ struct {
+ unsigned char d0, mr; /* Mode register 1/2*/
+ unsigned char d1, sr; /* Status register */
+ unsigned char d2, r1; /* reserved */
+ unsigned char d3, rhr; /* Receive holding register (R) */
+ unsigned char junk[8]; /* other crap for block control */
+ } r; /* Read access */
+ struct {
+ unsigned char d0, mr; /* Mode register 1/2 */
+ unsigned char d1, csr; /* Clock select register */
+ unsigned char d2, cr; /* Command register */
+ unsigned char d3, thr; /* Transmit holding register */
+ unsigned char junk[8]; /* other crap for block control */
+ } w; /* Write access */
+ } u;
+};
+
+/*
+ * struct scc2698_block - Block access to scc2698 IO
+ *
+ * The scc2698 contain 4 block.
+ * Each block containt two channel a and b.
+ * dn value are only spacer.
+ *
+ */
+struct scc2698_block {
+ union {
+ struct {
+ unsigned char d0, mra; /* Mode register 1/2 (a) */
+ unsigned char d1, sra; /* Status register (a) */
+ unsigned char d2, r1; /* reserved */
+ unsigned char d3, rhra; /* Receive holding register (a) */
+ unsigned char d4, ipcr; /* Input port change register of block */
+ unsigned char d5, isr; /* Interrupt status register of block */
+ unsigned char d6, ctur; /* Counter timer upper register of block */
+ unsigned char d7, ctlr; /* Counter timer lower register of block */
+ unsigned char d8, mrb; /* Mode register 1/2 (b) */
+ unsigned char d9, srb; /* Status register (b) */
+ unsigned char da, r2; /* reserved */
+ unsigned char db, rhrb; /* Receive holding register (b) */
+ unsigned char dc, r3; /* reserved */
+ unsigned char dd, ip; /* Input port register of block */
+ unsigned char de, ctg; /* Start counter timer of block */
+ unsigned char df, cts; /* Stop counter timer of block */
+ } r; /* Read access */
+ struct {
+ unsigned char d0, mra; /* Mode register 1/2 (a) */
+ unsigned char d1, csra; /* Clock select register (a) */
+ unsigned char d2, cra; /* Command register (a) */
+ unsigned char d3, thra; /* Transmit holding register (a) */
+ unsigned char d4, acr; /* Auxiliary control register of block */
+ unsigned char d5, imr; /* Interrupt mask register of block */
+ unsigned char d6, ctu; /* Counter timer upper register of block */
+ unsigned char d7, ctl; /* Counter timer lower register of block */
+ unsigned char d8, mrb; /* Mode register 1/2 (b) */
+ unsigned char d9, csrb; /* Clock select register (a) */
+ unsigned char da, crb; /* Command register (b) */
+ unsigned char db, thrb; /* Transmit holding register (b) */
+ unsigned char dc, r1; /* reserved */
+ unsigned char dd, opcr; /* Output port configuration register of block */
+ unsigned char de, r2; /* reserved */
+ unsigned char df, r3; /* reserved */
+ } w; /* Write access */
+ } u;
+} ;
+
+#define MR1_CHRL_5_BITS (0x0 << 0)
+#define MR1_CHRL_6_BITS (0x1 << 0)
+#define MR1_CHRL_7_BITS (0x2 << 0)
+#define MR1_CHRL_8_BITS (0x3 << 0)
+#define MR1_PARITY_EVEN (0x1 << 2)
+#define MR1_PARITY_ODD (0x0 << 2)
+#define MR1_PARITY_ON (0x0 << 3)
+#define MR1_PARITY_FORCE (0x1 << 3)
+#define MR1_PARITY_OFF (0x2 << 3)
+#define MR1_PARITY_SPECIAL (0x3 << 3)
+#define MR1_ERROR_CHAR (0x0 << 5)
+#define MR1_ERROR_BLOCK (0x1 << 5)
+#define MR1_RxINT_RxRDY (0x0 << 6)
+#define MR1_RxINT_FFULL (0x1 << 6)
+#define MR1_RxRTS_CONTROL_ON (0x1 << 7)
+#define MR1_RxRTS_CONTROL_OFF (0x0 << 7)
+
+#define MR2_STOP_BITS_LENGTH_1 (0x7 << 0)
+#define MR2_STOP_BITS_LENGTH_2 (0xF << 0)
+#define MR2_CTS_ENABLE_TX_ON (0x1 << 4)
+#define MR2_CTS_ENABLE_TX_OFF (0x0 << 4)
+#define MR2_TxRTS_CONTROL_ON (0x1 << 5)
+#define MR2_TxRTS_CONTROL_OFF (0x0 << 5)
+#define MR2_CH_MODE_NORMAL (0x0 << 6)
+#define MR2_CH_MODE_ECHO (0x1 << 6)
+#define MR2_CH_MODE_LOCAL (0x2 << 6)
+#define MR2_CH_MODE_REMOTE (0x3 << 6)
+
+#define CR_ENABLE_RX (0x1 << 0)
+#define CR_DISABLE_RX (0x1 << 1)
+#define CR_ENABLE_TX (0x1 << 2)
+#define CR_DISABLE_TX (0x1 << 3)
+#define CR_CMD_RESET_MR (0x1 << 4)
+#define CR_CMD_RESET_RX (0x2 << 4)
+#define CR_CMD_RESET_TX (0x3 << 4)
+#define CR_CMD_RESET_ERR_STATUS (0x4 << 4)
+#define CR_CMD_RESET_BREAK_CHANGE (0x5 << 4)
+#define CR_CMD_START_BREAK (0x6 << 4)
+#define CR_CMD_STOP_BREAK (0x7 << 4)
+#define CR_CMD_ASSERT_RTSN (0x8 << 4)
+#define CR_CMD_NEGATE_RTSN (0x9 << 4)
+#define CR_CMD_SET_TIMEOUT_MODE (0xA << 4)
+#define CR_CMD_DISABLE_TIMEOUT_MODE (0xC << 4)
+
+#define SR_RX_READY (0x1 << 0)
+#define SR_FIFO_FULL (0x1 << 1)
+#define SR_TX_READY (0x1 << 2)
+#define SR_TX_EMPTY (0x1 << 3)
+#define SR_OVERRUN_ERROR (0x1 << 4)
+#define SR_PARITY_ERROR (0x1 << 5)
+#define SR_FRAMING_ERROR (0x1 << 6)
+#define SR_RECEIVED_BREAK (0x1 << 7)
+
+#define SR_ERROR (0xF0)
+
+#define ACR_DELTA_IP0_IRQ_EN (0x1 << 0)
+#define ACR_DELTA_IP1_IRQ_EN (0x1 << 1)
+#define ACR_DELTA_IP2_IRQ_EN (0x1 << 2)
+#define ACR_DELTA_IP3_IRQ_EN (0x1 << 3)
+#define ACR_CT_Mask (0x7 << 4)
+#define ACR_CExt (0x0 << 4)
+#define ACR_CTxCA (0x1 << 4)
+#define ACR_CTxCB (0x2 << 4)
+#define ACR_CClk16 (0x3 << 4)
+#define ACR_TExt (0x4 << 4)
+#define ACR_TExt16 (0x5 << 4)
+#define ACR_TClk (0x6 << 4)
+#define ACR_TClk16 (0x7 << 4)
+#define ACR_BRG_SET1 (0x0 << 7)
+#define ACR_BRG_SET2 (0x1 << 7)
+
+#define TX_CLK_75 (0x0 << 0)
+#define TX_CLK_110 (0x1 << 0)
+#define TX_CLK_38400 (0x2 << 0)
+#define TX_CLK_150 (0x3 << 0)
+#define TX_CLK_300 (0x4 << 0)
+#define TX_CLK_600 (0x5 << 0)
+#define TX_CLK_1200 (0x6 << 0)
+#define TX_CLK_2000 (0x7 << 0)
+#define TX_CLK_2400 (0x8 << 0)
+#define TX_CLK_4800 (0x9 << 0)
+#define TX_CLK_1800 (0xA << 0)
+#define TX_CLK_9600 (0xB << 0)
+#define TX_CLK_19200 (0xC << 0)
+#define RX_CLK_75 (0x0 << 4)
+#define RX_CLK_110 (0x1 << 4)
+#define RX_CLK_38400 (0x2 << 4)
+#define RX_CLK_150 (0x3 << 4)
+#define RX_CLK_300 (0x4 << 4)
+#define RX_CLK_600 (0x5 << 4)
+#define RX_CLK_1200 (0x6 << 4)
+#define RX_CLK_2000 (0x7 << 4)
+#define RX_CLK_2400 (0x8 << 4)
+#define RX_CLK_4800 (0x9 << 4)
+#define RX_CLK_1800 (0xA << 4)
+#define RX_CLK_9600 (0xB << 4)
+#define RX_CLK_19200 (0xC << 4)
+
+#define OPCR_MPOa_RTSN (0x0 << 0)
+#define OPCR_MPOa_C_TO (0x1 << 0)
+#define OPCR_MPOa_TxC1X (0x2 << 0)
+#define OPCR_MPOa_TxC16X (0x3 << 0)
+#define OPCR_MPOa_RxC1X (0x4 << 0)
+#define OPCR_MPOa_RxC16X (0x5 << 0)
+#define OPCR_MPOa_TxRDY (0x6 << 0)
+#define OPCR_MPOa_RxRDY_FF (0x7 << 0)
+
+#define OPCR_MPOb_RTSN (0x0 << 4)
+#define OPCR_MPOb_C_TO (0x1 << 4)
+#define OPCR_MPOb_TxC1X (0x2 << 4)
+#define OPCR_MPOb_TxC16X (0x3 << 4)
+#define OPCR_MPOb_RxC1X (0x4 << 4)
+#define OPCR_MPOb_RxC16X (0x5 << 4)
+#define OPCR_MPOb_TxRDY (0x6 << 4)
+#define OPCR_MPOb_RxRDY_FF (0x7 << 4)
+
+#define OPCR_MPP_INPUT (0x0 << 7)
+#define OPCR_MPP_OUTPUT (0x1 << 7)
+
+#define IMR_TxRDY_A (0x1 << 0)
+#define IMR_RxRDY_FFULL_A (0x1 << 1)
+#define IMR_DELTA_BREAK_A (0x1 << 2)
+#define IMR_COUNTER_READY (0x1 << 3)
+#define IMR_TxRDY_B (0x1 << 4)
+#define IMR_RxRDY_FFULL_B (0x1 << 5)
+#define IMR_DELTA_BREAK_B (0x1 << 6)
+#define IMR_INPUT_PORT_CHANGE (0x1 << 7)
+
+#define ISR_TxRDY_A (0x1 << 0)
+#define ISR_RxRDY_FFULL_A (0x1 << 1)
+#define ISR_DELTA_BREAK_A (0x1 << 2)
+#define ISR_COUNTER_READY (0x1 << 3)
+#define ISR_TxRDY_B (0x1 << 4)
+#define ISR_RxRDY_FFULL_B (0x1 << 5)
+#define ISR_DELTA_BREAK_B (0x1 << 6)
+#define ISR_INPUT_PORT_CHANGE (0x1 << 7)
+
+#endif /* SCC2698_H_ */
diff --git a/drivers/staging/ipack/ipack.c b/drivers/staging/ipack/ipack.c
new file mode 100644
index 000000000000..c1cd97a4d9ce
--- /dev/null
+++ b/drivers/staging/ipack/ipack.c
@@ -0,0 +1,173 @@
+/*
+ * Industry-pack bus support functions.
+ *
+ * (C) 2011 Samuel Iglesias Gonsalvez <siglesia@cern.ch>, CERN
+ * (C) 2012 Samuel Iglesias Gonsalvez <siglesias@igalia.com>, Igalia
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation; version 2 of the License.
+ */
+
+#include <linux/module.h>
+#include <linux/slab.h>
+#include <linux/idr.h>
+#include "ipack.h"
+
+#define to_ipack_dev(device) container_of(device, struct ipack_device, dev)
+#define to_ipack_driver(drv) container_of(drv, struct ipack_driver, driver)
+
+static DEFINE_IDA(ipack_ida);
+
+static void ipack_device_release(struct device *dev)
+{
+ struct ipack_device *device = to_ipack_dev(dev);
+ kfree(device);
+}
+
+static int ipack_bus_match(struct device *device, struct device_driver *driver)
+{
+ int ret;
+ struct ipack_device *dev = to_ipack_dev(device);
+ struct ipack_driver *drv = to_ipack_driver(driver);
+
+ if ((!drv->ops) || (!drv->ops->match))
+ return -EINVAL;
+
+ ret = drv->ops->match(dev);
+ if (ret)
+ dev->driver = drv;
+
+ return ret;
+}
+
+static int ipack_bus_probe(struct device *device)
+{
+ struct ipack_device *dev = to_ipack_dev(device);
+
+ if (!dev->driver->ops->probe)
+ return -EINVAL;
+
+ return dev->driver->ops->probe(dev);
+}
+
+static int ipack_bus_remove(struct device *device)
+{
+ struct ipack_device *dev = to_ipack_dev(device);
+
+ if (!dev->driver->ops->remove)
+ return -EINVAL;
+
+ dev->driver->ops->remove(dev);
+ return 0;
+}
+
+static struct bus_type ipack_bus_type = {
+ .name = "ipack",
+ .probe = ipack_bus_probe,
+ .match = ipack_bus_match,
+ .remove = ipack_bus_remove,
+};
+
+struct ipack_bus_device *ipack_bus_register(struct device *parent, int slots,
+ struct ipack_bus_ops *ops)
+{
+ int bus_nr;
+ struct ipack_bus_device *bus;
+
+ bus = kzalloc(sizeof(struct ipack_bus_device), GFP_KERNEL);
+ if (!bus)
+ return NULL;
+
+ bus_nr = ida_simple_get(&ipack_ida, 0, 0, GFP_KERNEL);
+ if (bus_nr < 0) {
+ kfree(bus);
+ return NULL;
+ }
+
+ bus->bus_nr = bus_nr;
+ bus->parent = parent;
+ bus->slots = slots;
+ bus->ops = ops;
+ return bus;
+}
+EXPORT_SYMBOL_GPL(ipack_bus_register);
+
+int ipack_bus_unregister(struct ipack_bus_device *bus)
+{
+ ida_simple_remove(&ipack_ida, bus->bus_nr);
+ kfree(bus);
+ return 0;
+}
+EXPORT_SYMBOL_GPL(ipack_bus_unregister);
+
+int ipack_driver_register(struct ipack_driver *edrv, struct module *owner,
+ char *name)
+{
+ edrv->driver.owner = owner;
+ edrv->driver.name = name;
+ edrv->driver.bus = &ipack_bus_type;
+ return driver_register(&edrv->driver);
+}
+EXPORT_SYMBOL_GPL(ipack_driver_register);
+
+void ipack_driver_unregister(struct ipack_driver *edrv)
+{
+ driver_unregister(&edrv->driver);
+}
+EXPORT_SYMBOL_GPL(ipack_driver_unregister);
+
+struct ipack_device *ipack_device_register(struct ipack_bus_device *bus,
+ int slot, int irqv)
+{
+ int ret;
+ struct ipack_device *dev;
+
+ dev = kzalloc(sizeof(struct ipack_device), GFP_KERNEL);
+ if (!dev)
+ return NULL;
+
+ dev->dev.bus = &ipack_bus_type;
+ dev->dev.release = ipack_device_release;
+ dev->dev.parent = bus->parent;
+ dev->slot = slot;
+ dev->bus_nr = bus->bus_nr;
+ dev->irq = irqv;
+ dev->bus = bus;
+ dev_set_name(&dev->dev,
+ "ipack-dev.%u.%u", dev->bus_nr, dev->slot);
+
+ ret = device_register(&dev->dev);
+ if (ret < 0) {
+ kfree(dev);
+ return NULL;
+ }
+
+ return dev;
+}
+EXPORT_SYMBOL_GPL(ipack_device_register);
+
+void ipack_device_unregister(struct ipack_device *dev)
+{
+ device_unregister(&dev->dev);
+}
+EXPORT_SYMBOL_GPL(ipack_device_unregister);
+
+static int __init ipack_init(void)
+{
+ ida_init(&ipack_ida);
+ return bus_register(&ipack_bus_type);
+}
+
+static void __exit ipack_exit(void)
+{
+ bus_unregister(&ipack_bus_type);
+ ida_destroy(&ipack_ida);
+}
+
+module_init(ipack_init);
+module_exit(ipack_exit);
+
+MODULE_AUTHOR("Samuel Iglesias Gonsalvez <siglesias@igalia.com>");
+MODULE_LICENSE("GPL");
+MODULE_DESCRIPTION("Industry-pack bus core");
diff --git a/drivers/staging/ipack/ipack.h b/drivers/staging/ipack/ipack.h
new file mode 100644
index 000000000000..8bc001e3ca4e
--- /dev/null
+++ b/drivers/staging/ipack/ipack.h
@@ -0,0 +1,183 @@
+/*
+ * Industry-pack bus.
+ *
+ * (C) 2011 Samuel Iglesias Gonsalvez <siglesia@cern.ch>, CERN
+ * (C) 2012 Samuel Iglesias Gonsalvez <siglesias@igalia.com>, Igalia
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation; version 2 of the License.
+ */
+
+#include <linux/device.h>
+
+#define IPACK_IDPROM_OFFSET_I 0x01
+#define IPACK_IDPROM_OFFSET_P 0x03
+#define IPACK_IDPROM_OFFSET_A 0x05
+#define IPACK_IDPROM_OFFSET_C 0x07
+#define IPACK_IDPROM_OFFSET_MANUFACTURER_ID 0x09
+#define IPACK_IDPROM_OFFSET_MODEL 0x0B
+#define IPACK_IDPROM_OFFSET_REVISION 0x0D
+#define IPACK_IDPROM_OFFSET_RESERVED 0x0F
+#define IPACK_IDPROM_OFFSET_DRIVER_ID_L 0x11
+#define IPACK_IDPROM_OFFSET_DRIVER_ID_H 0x13
+#define IPACK_IDPROM_OFFSET_NUM_BYTES 0x15
+#define IPACK_IDPROM_OFFSET_CRC 0x17
+
+struct ipack_bus_ops;
+struct ipack_driver;
+
+enum ipack_space {
+ IPACK_IO_SPACE = 0,
+ IPACK_ID_SPACE = 1,
+ IPACK_MEM_SPACE = 2,
+};
+
+/**
+ * struct ipack_addr_space - Virtual address space mapped for a specified type.
+ *
+ * @address: virtual address
+ * @size: size of the mapped space
+ */
+struct ipack_addr_space {
+ void __iomem *address;
+ unsigned int size;
+};
+
+/**
+ * struct ipack_device
+ *
+ * @bus_nr: IP bus number where the device is plugged
+ * @slot: Slot where the device is plugged in the carrier board
+ * @irq: IRQ vector
+ * @driver: Pointer to the ipack_driver that manages the device
+ * @bus: ipack_bus_device where the device is plugged to.
+ * @id_space: Virtual address to ID space.
+ * @io_space: Virtual address to IO space.
+ * @mem_space: Virtual address to MEM space.
+ * @dev: device in kernel representation.
+ *
+ * Warning: Direct access to mapped memory is possible but the endianness
+ * is not the same with PCI carrier or VME carrier. The endianness is managed
+ * by the carrier board throught bus->ops.
+ */
+struct ipack_device {
+ unsigned int bus_nr;
+ unsigned int slot;
+ unsigned int irq;
+ struct ipack_driver *driver;
+ struct ipack_bus_device *bus;
+ struct ipack_addr_space id_space;
+ struct ipack_addr_space io_space;
+ struct ipack_addr_space mem_space;
+ struct device dev;
+};
+
+/**
+ * struct ipack_driver_ops -- callbacks to mezzanine driver for installing/removing one device
+ *
+ * @match: Match function
+ * @probe: Probe function
+ * @remove: tell the driver that the carrier board wants to remove one device
+ */
+
+struct ipack_driver_ops {
+ int (*match) (struct ipack_device *dev);
+ int (*probe) (struct ipack_device *dev);
+ void (*remove) (struct ipack_device *dev);
+};
+
+/**
+ * struct ipack_driver -- Specific data to each ipack board driver
+ *
+ * @driver: Device driver kernel representation
+ * @ops: Mezzanine driver operations specific for the ipack bus.
+ */
+struct ipack_driver {
+ struct device_driver driver;
+ struct ipack_driver_ops *ops;
+};
+
+/**
+ * struct ipack_bus_ops - available operations on a bridge module
+ *
+ * @map_space: map IP address space
+ * @unmap_space: unmap IP address space
+ * @request_irq: request IRQ
+ * @free_irq: free IRQ
+ * @read8: read unsigned char
+ * @read16: read unsigned short
+ * @read32: read unsigned int
+ * @write8: read unsigned char
+ * @write16: read unsigned short
+ * @write32: read unsigned int
+ * @remove_device: tell the bridge module that the device has been removed
+ */
+struct ipack_bus_ops {
+ int (*map_space) (struct ipack_device *dev, unsigned int memory_size, int space);
+ int (*unmap_space) (struct ipack_device *dev, int space);
+ int (*request_irq) (struct ipack_device *dev, int vector, int (*handler)(void *), void *arg);
+ int (*free_irq) (struct ipack_device *dev);
+ int (*read8) (struct ipack_device *dev, int space, unsigned long offset, unsigned char *value);
+ int (*read16) (struct ipack_device *dev, int space, unsigned long offset, unsigned short *value);
+ int (*read32) (struct ipack_device *dev, int space, unsigned long offset, unsigned int *value);
+ int (*write8) (struct ipack_device *dev, int space, unsigned long offset, unsigned char value);
+ int (*write16) (struct ipack_device *dev, int space, unsigned long offset, unsigned short value);
+ int (*write32) (struct ipack_device *dev, int space, unsigned long offset, unsigned int value);
+ int (*remove_device) (struct ipack_device *dev);
+};
+
+/**
+ * struct ipack_bus_device
+ *
+ * @dev: pointer to carrier device
+ * @slots: number of slots available
+ * @bus_nr: ipack bus number
+ * @ops: bus operations for the mezzanine drivers
+ */
+struct ipack_bus_device {
+ struct device *parent;
+ int slots;
+ int bus_nr;
+ struct ipack_bus_ops *ops;
+};
+
+/**
+ * ipack_bus_register -- register a new ipack bus
+ *
+ * @parent: pointer to the parent device, if any.
+ * @slots: number of slots available in the bus device.
+ * @ops: bus operations for the mezzanine drivers.
+ *
+ * The carrier board device should call this function to register itself as
+ * available bus device in ipack.
+ */
+struct ipack_bus_device *ipack_bus_register(struct device *parent, int slots,
+ struct ipack_bus_ops *ops);
+
+/**
+ * ipack_bus_unregister -- unregister an ipack bus
+ */
+int ipack_bus_unregister(struct ipack_bus_device *bus);
+
+/**
+ * ipack_driver_register -- Register a new driver
+ *
+ * Called by a ipack driver to register itself as a driver
+ * that can manage ipack devices.
+ */
+int ipack_driver_register(struct ipack_driver *edrv, struct module *owner, char *name);
+void ipack_driver_unregister(struct ipack_driver *edrv);
+
+/**
+ * ipack_device_register -- register a new mezzanine device
+ *
+ * @bus: ipack bus device it is plugged to.
+ * @slot: slot position in the bus device.
+ * @irqv: IRQ vector for the mezzanine.
+ *
+ * Register a new ipack device (mezzanine device). The call is done by
+ * the carrier device driver.
+ */
+struct ipack_device *ipack_device_register(struct ipack_bus_device *bus, int slot, int irqv);
+void ipack_device_unregister(struct ipack_device *dev);
diff --git a/drivers/staging/keucr/init.c b/drivers/staging/keucr/init.c
index 071bdc238786..231611dc0f74 100644
--- a/drivers/staging/keucr/init.c
+++ b/drivers/staging/keucr/init.c
@@ -30,9 +30,8 @@ int ENE_InitMedia(struct us_data *us)
if (MiscReg03 & 0x02) {
if (!us->SM_Status.Ready && !us->MS_Status.Ready) {
result = ENE_SMInit(us);
- if (result != USB_STOR_XFER_GOOD) {
+ if (result != USB_STOR_XFER_GOOD)
return USB_STOR_TRANSPORT_ERROR;
- }
}
}
diff --git a/drivers/staging/keucr/scsiglue.c b/drivers/staging/keucr/scsiglue.c
index e1f3931d41e0..083b20e6253e 100644
--- a/drivers/staging/keucr/scsiglue.c
+++ b/drivers/staging/keucr/scsiglue.c
@@ -230,7 +230,10 @@ void usb_stor_report_bus_reset(struct us_data *us)
/* we use this macro to help us write into the buffer */
#undef SPRINTF
#define SPRINTF(args...) \
- do { if (pos < buffer+length) pos += sprintf(pos, ## args); } while (0)
+ do { \
+ if (pos < buffer+length) \
+ pos += sprintf(pos, ## args); \
+ } while (0)
/*
* proc_info()
@@ -279,8 +282,10 @@ static int proc_info(struct Scsi_Host *host, char *buffer, char **start,
pos += sprintf(pos, " Quirks:");
#define US_FLAG(name, value) \
- if (us->fflags & value)\
- pos += sprintf(pos, " " #name);
+ do { \
+ if (us->fflags & value) \
+ pos += sprintf(pos, " " #name); \
+ } while (0);
US_DO_ALL_FLAGS
#undef US_FLAG
diff --git a/drivers/staging/line6/config.h b/drivers/staging/line6/config.h
deleted file mode 100644
index f8a5149e3dad..000000000000
--- a/drivers/staging/line6/config.h
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Line6 Linux USB driver - 0.8.0
- *
- * Copyright (C) 2004-2009 Markus Grabner (grabner@icg.tugraz.at)
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation, version 2.
- *
- */
-
-#ifndef CONFIG_H
-#define CONFIG_H
-
-
-#ifdef CONFIG_USB_DEBUG
-#define DEBUG 1
-#endif
-
-
-/*
- * Development tools.
- */
-#define DO_DEBUG_MESSAGES 0
-#define DO_DUMP_URB_SEND DO_DEBUG_MESSAGES
-#define DO_DUMP_URB_RECEIVE DO_DEBUG_MESSAGES
-#define DO_DUMP_PCM_SEND 0
-#define DO_DUMP_PCM_RECEIVE 0
-#define DO_DUMP_MIDI_SEND DO_DEBUG_MESSAGES
-#define DO_DUMP_MIDI_RECEIVE DO_DEBUG_MESSAGES
-#define DO_DUMP_ANY (DO_DUMP_URB_SEND || DO_DUMP_URB_RECEIVE || \
- DO_DUMP_PCM_SEND || DO_DUMP_PCM_RECEIVE || \
- DO_DUMP_MIDI_SEND || DO_DUMP_MIDI_RECEIVE)
-#define CREATE_RAW_FILE 0
-
-#if DO_DEBUG_MESSAGES
-#define CHECKPOINT printk(KERN_INFO "line6usb: %s (%s:%d)\n", \
- __func__, __FILE__, __LINE__)
-#endif
-
-#if DO_DEBUG_MESSAGES
-#define DEBUG_MESSAGES(x) (x)
-#else
-#define DEBUG_MESSAGES(x)
-#endif
-
-
-#endif
diff --git a/drivers/staging/line6/control.c b/drivers/staging/line6/control.c
index 67e23b6e2d35..f8326f587e38 100644
--- a/drivers/staging/line6/control.c
+++ b/drivers/staging/line6/control.c
@@ -55,10 +55,10 @@ static ssize_t pod_set_param_int(struct device *dev, const char *buf,
{
struct usb_interface *interface = to_usb_interface(dev);
struct usb_line6_pod *pod = usb_get_intfdata(interface);
- unsigned long value;
+ u8 value;
int retval;
- retval = strict_strtoul(buf, 10, &value);
+ retval = kstrtou8(buf, 10, &value);
if (retval)
return retval;
diff --git a/drivers/staging/line6/driver.c b/drivers/staging/line6/driver.c
index e8023afd3656..b8358ca71bdd 100644
--- a/drivers/staging/line6/driver.c
+++ b/drivers/staging/line6/driver.c
@@ -92,15 +92,10 @@ const unsigned char line6_midi_id[] = {
Code to request version of POD, Variax interface
(and maybe other devices).
*/
-static const char line6_request_version0[] = {
+static const char line6_request_version[] = {
0xf0, 0x7e, 0x7f, 0x06, 0x01, 0xf7
};
-/*
- Copy of version request code with GFP_KERNEL flag for use in URB.
-*/
-static const char *line6_request_version;
-
struct usb_line6 *line6_devices[LINE6_MAX_DEVICES];
/**
@@ -336,8 +331,21 @@ int line6_send_raw_message_async(struct usb_line6 *line6, const char *buffer,
*/
int line6_version_request_async(struct usb_line6 *line6)
{
- return line6_send_raw_message_async(line6, line6_request_version,
- sizeof(line6_request_version0));
+ char *buffer;
+ int retval;
+
+ buffer = kmalloc(sizeof(line6_request_version), GFP_ATOMIC);
+ if (buffer == NULL) {
+ dev_err(line6->ifcdev, "Out of memory");
+ return -ENOMEM;
+ }
+
+ memcpy(buffer, line6_request_version, sizeof(line6_request_version));
+
+ retval = line6_send_raw_message_async(line6, buffer,
+ sizeof(line6_request_version));
+ kfree(buffer);
+ return retval;
}
/*
@@ -482,7 +490,7 @@ static void line6_data_received(struct urb *urb)
/*
Send channel number (i.e., switch to a different sound).
*/
-int line6_send_program(struct usb_line6 *line6, int value)
+int line6_send_program(struct usb_line6 *line6, u8 value)
{
int retval;
unsigned char *buffer;
@@ -518,7 +526,7 @@ int line6_send_program(struct usb_line6 *line6, int value)
/*
Transmit Line6 control parameter.
*/
-int line6_transmit_parameter(struct usb_line6 *line6, int param, int value)
+int line6_transmit_parameter(struct usb_line6 *line6, int param, u8 value)
{
int retval;
unsigned char *buffer;
@@ -1292,69 +1300,7 @@ static struct usb_driver line6_driver = {
.id_table = line6_id_table,
};
-/*
- Module initialization.
-*/
-static int __init line6_init(void)
-{
- int i, retval;
-
- printk(KERN_INFO "%s driver version %s\n", DRIVER_NAME, DRIVER_VERSION);
-
- for (i = LINE6_MAX_DEVICES; i--;)
- line6_devices[i] = NULL;
-
- retval = usb_register(&line6_driver);
-
- if (retval) {
- err("usb_register failed. Error number %d", retval);
- return retval;
- }
-
- line6_request_version = kmalloc(sizeof(line6_request_version0),
- GFP_KERNEL);
-
- if (line6_request_version == NULL) {
- err("Out of memory");
- return -ENOMEM;
- }
-
- memcpy((char *)line6_request_version, line6_request_version0,
- sizeof(line6_request_version0));
-
- return retval;
-}
-
-/*
- Module cleanup.
-*/
-static void __exit line6_exit(void)
-{
- int i;
- struct usb_line6 *line6;
- struct snd_line6_pcm *line6pcm;
-
- /* stop all PCM channels */
- for (i = LINE6_MAX_DEVICES; i--;) {
- line6 = line6_devices[i];
-
- if (line6 == NULL)
- continue;
-
- line6pcm = line6->line6pcm;
-
- if (line6pcm == NULL)
- continue;
-
- line6_pcm_release(line6pcm, ~0);
- }
-
- usb_deregister(&line6_driver);
- kfree(line6_request_version);
-}
-
-module_init(line6_init);
-module_exit(line6_exit);
+module_usb_driver(line6_driver);
MODULE_AUTHOR(DRIVER_AUTHOR);
MODULE_DESCRIPTION(DRIVER_DESC);
diff --git a/drivers/staging/line6/driver.h b/drivers/staging/line6/driver.h
index 117bf9943568..a3029eb223d6 100644
--- a/drivers/staging/line6/driver.h
+++ b/drivers/staging/line6/driver.h
@@ -209,7 +209,7 @@ extern int line6_read_data(struct usb_line6 *line6, int address, void *data,
size_t datalen);
extern int line6_read_serial_number(struct usb_line6 *line6,
int *serial_number);
-extern int line6_send_program(struct usb_line6 *line6, int value);
+extern int line6_send_program(struct usb_line6 *line6, u8 value);
extern int line6_send_raw_message(struct usb_line6 *line6, const char *buffer,
int size);
extern int line6_send_raw_message_async(struct usb_line6 *line6,
@@ -224,7 +224,7 @@ extern void line6_start_timer(struct timer_list *timer, unsigned int msecs,
void (*function) (unsigned long),
unsigned long data);
extern int line6_transmit_parameter(struct usb_line6 *line6, int param,
- int value);
+ u8 value);
extern int line6_version_request_async(struct usb_line6 *line6);
extern int line6_write_data(struct usb_line6 *line6, int address, void *data,
size_t datalen);
diff --git a/drivers/staging/line6/midi.c b/drivers/staging/line6/midi.c
index 13d02939c3cb..50407294fbd4 100644
--- a/drivers/staging/line6/midi.c
+++ b/drivers/staging/line6/midi.c
@@ -406,7 +406,7 @@ int line6_init_midi(struct usb_line6 *line6)
line6midi->line6 = line6;
- switch(line6->product) {
+ switch (line6->product) {
case LINE6_DEVID_PODHD300:
case LINE6_DEVID_PODHD500:
line6midi->midi_mask_transmit = 1;
diff --git a/drivers/staging/line6/midibuf.c b/drivers/staging/line6/midibuf.c
index 7b532e5ce8b4..836e8c847c52 100644
--- a/drivers/staging/line6/midibuf.c
+++ b/drivers/staging/line6/midibuf.c
@@ -64,7 +64,7 @@ int line6_midibuf_init(struct MidiBuffer *this, int size, int split)
void line6_midibuf_status(struct MidiBuffer *this)
{
- printk(KERN_DEBUG "midibuf size=%d split=%d pos_read=%d pos_write=%d "
+ pr_debug("midibuf size=%d split=%d pos_read=%d pos_write=%d "
"full=%d command_prev=%02x\n", this->size, this->split,
this->pos_read, this->pos_write, this->full, this->command_prev);
}
diff --git a/drivers/staging/line6/pcm.c b/drivers/staging/line6/pcm.c
index 90d2d4475cb4..5e319e3ce685 100644
--- a/drivers/staging/line6/pcm.c
+++ b/drivers/staging/line6/pcm.c
@@ -99,7 +99,7 @@ int line6_pcm_acquire(struct snd_line6_pcm *line6pcm, int channels)
unsigned long flags_new = flags_old | channels;
unsigned long flags_final = flags_old;
int err = 0;
-
+
line6pcm->prev_fbuf = NULL;
if (test_flags(flags_old, flags_new, LINE6_BITS_CAPTURE_BUFFER)) {
diff --git a/drivers/staging/line6/pod.c b/drivers/staging/line6/pod.c
index 4dadc571d961..9edd053fb9ae 100644
--- a/drivers/staging/line6/pod.c
+++ b/drivers/staging/line6/pod.c
@@ -405,7 +405,7 @@ void line6_pod_midi_postprocess(struct usb_line6_pod *pod, unsigned char *data,
/*
Send channel number (i.e., switch to a different sound).
*/
-static void pod_send_channel(struct usb_line6_pod *pod, int value)
+static void pod_send_channel(struct usb_line6_pod *pod, u8 value)
{
line6_invalidate_current(&pod->dumpreq);
@@ -419,7 +419,7 @@ static void pod_send_channel(struct usb_line6_pod *pod, int value)
Transmit PODxt Pro control parameter.
*/
void line6_pod_transmit_parameter(struct usb_line6_pod *pod, int param,
- int value)
+ u8 value)
{
if (line6_transmit_parameter(&pod->line6, param, value) == 0)
pod_store_parameter(pod, param, value);
@@ -434,11 +434,11 @@ void line6_pod_transmit_parameter(struct usb_line6_pod *pod, int param,
static int pod_resolve(const char *buf, short block0, short block1,
unsigned char *location)
{
- unsigned long value;
+ u8 value;
short block;
int ret;
- ret = strict_strtoul(buf, 10, &value);
+ ret = kstrtou8(buf, 10, &value);
if (ret)
return ret;
@@ -560,10 +560,10 @@ static ssize_t pod_set_channel(struct device *dev,
{
struct usb_interface *interface = to_usb_interface(dev);
struct usb_line6_pod *pod = usb_get_intfdata(interface);
- unsigned long value;
+ u8 value;
int ret;
- ret = strict_strtoul(buf, 10, &value);
+ ret = kstrtou8(buf, 10, &value);
if (ret)
return ret;
@@ -892,10 +892,10 @@ static ssize_t pod_set_midi_postprocess(struct device *dev,
{
struct usb_interface *interface = to_usb_interface(dev);
struct usb_line6_pod *pod = usb_get_intfdata(interface);
- unsigned long value;
+ u8 value;
int ret;
- ret = strict_strtoul(buf, 10, &value);
+ ret = kstrtou8(buf, 10, &value);
if (ret)
return ret;
diff --git a/drivers/staging/line6/pod.h b/drivers/staging/line6/pod.h
index 18b9d08c3288..47e0d1a1c4b9 100644
--- a/drivers/staging/line6/pod.h
+++ b/drivers/staging/line6/pod.h
@@ -200,6 +200,6 @@ extern void line6_pod_midi_postprocess(struct usb_line6_pod *pod,
unsigned char *data, int length);
extern void line6_pod_process_message(struct usb_line6_pod *pod);
extern void line6_pod_transmit_parameter(struct usb_line6_pod *pod, int param,
- int value);
+ u8 value);
#endif
diff --git a/drivers/staging/line6/toneport.c b/drivers/staging/line6/toneport.c
index b754f69a29c4..31b624b63425 100644
--- a/drivers/staging/line6/toneport.c
+++ b/drivers/staging/line6/toneport.c
@@ -168,7 +168,7 @@ static int toneport_send_cmd(struct usb_device *usbdev, int cmd1, int cmd2)
cmd1, cmd2, NULL, 0, LINE6_TIMEOUT * HZ);
if (ret < 0) {
- err("send failed (error %d)\n", ret);
+ dev_err(&usbdev->dev, "send failed (error %d)\n", ret);
return ret;
}
diff --git a/drivers/staging/line6/variax.c b/drivers/staging/line6/variax.c
index d36622228b2d..bb99ee4919e7 100644
--- a/drivers/staging/line6/variax.c
+++ b/drivers/staging/line6/variax.c
@@ -319,10 +319,10 @@ static ssize_t variax_set_volume(struct device *dev,
{
struct usb_line6_variax *variax =
usb_get_intfdata(to_usb_interface(dev));
- unsigned long value;
+ u8 value;
int ret;
- ret = strict_strtoul(buf, 10, &value);
+ ret = kstrtou8(buf, 10, &value);
if (ret)
return ret;
@@ -418,10 +418,10 @@ static ssize_t variax_set_tone(struct device *dev,
{
struct usb_line6_variax *variax =
usb_get_intfdata(to_usb_interface(dev));
- unsigned long value;
+ u8 value;
int ret;
- ret = strict_strtoul(buf, 10, &value);
+ ret = kstrtou8(buf, 10, &value);
if (ret)
return ret;
diff --git a/drivers/staging/media/as102/as102_drv.c b/drivers/staging/media/as102/as102_drv.c
index ea4f992de235..ac92eaf6c74b 100644
--- a/drivers/staging/media/as102/as102_drv.c
+++ b/drivers/staging/media/as102/as102_drv.c
@@ -279,40 +279,8 @@ void as102_dvb_unregister(struct as102_dev_t *as102_dev)
pr_info("Unregistered device %s", as102_dev->name);
}
-static int __init as102_driver_init(void)
-{
- int ret;
-
- /* register this driver with the low level subsystem */
- ret = usb_register(&as102_usb_driver);
- if (ret)
- err("usb_register failed (ret = %d)", ret);
-
- return ret;
-}
-
-/*
- * Mandatory function : Adds a special section to the module indicating
- * where initialisation function is defined
- */
-module_init(as102_driver_init);
-
-/**
- * as102_driver_exit - as102 driver exit point
- *
- * This function is called when device has to be removed.
- */
-static void __exit as102_driver_exit(void)
-{
- /* deregister this driver with the low level bus subsystem */
- usb_deregister(&as102_usb_driver);
-}
+module_usb_driver(as102_usb_driver);
-/*
- * required function for unload: Adds a special section to the module
- * indicating where unload function is defined
- */
-module_exit(as102_driver_exit);
/* modinfo details */
MODULE_DESCRIPTION(DRIVER_FULL_NAME);
MODULE_LICENSE("GPL");
diff --git a/drivers/staging/media/as102/as102_usb_drv.c b/drivers/staging/media/as102/as102_usb_drv.c
index 0f6bfe7eccba..aaf1bc2ad1b2 100644
--- a/drivers/staging/media/as102/as102_usb_drv.c
+++ b/drivers/staging/media/as102/as102_usb_drv.c
@@ -367,7 +367,7 @@ static int as102_usb_probe(struct usb_interface *intf,
ENTER();
/* This should never actually happen */
- if ((sizeof(as102_usb_id_table) / sizeof(struct usb_device_id)) !=
+ if (ARRAY_SIZE(as102_usb_id_table) !=
(sizeof(as102_device_names) / sizeof(const char *))) {
pr_err("Device names table invalid size");
return -EINVAL;
@@ -375,13 +375,12 @@ static int as102_usb_probe(struct usb_interface *intf,
as102_dev = kzalloc(sizeof(struct as102_dev_t), GFP_KERNEL);
if (as102_dev == NULL) {
- err("%s: kzalloc failed", __func__);
+ dev_err(&intf->dev, "%s: kzalloc failed\n", __func__);
return -ENOMEM;
}
/* Assign the user-friendly device name */
- for (i = 0; i < (sizeof(as102_usb_id_table) /
- sizeof(struct usb_device_id)); i++) {
+ for (i = 0; i < ARRAY_SIZE(as102_usb_id_table); i++) {
if (id == &as102_usb_id_table[i]) {
as102_dev->name = as102_device_names[i];
as102_dev->elna_cfg = as102_elna_cfg[i];
@@ -411,8 +410,9 @@ static int as102_usb_probe(struct usb_interface *intf,
ret = usb_register_dev(intf, &as102_usb_class_driver);
if (ret < 0) {
/* something prevented us from registering this driver */
- err("%s: usb_register_dev() failed (errno = %d)",
- __func__, ret);
+ dev_err(&intf->dev,
+ "%s: usb_register_dev() failed (errno = %d)\n",
+ __func__, ret);
goto failed;
}
diff --git a/drivers/staging/media/as102/as102_usb_drv.h b/drivers/staging/media/as102/as102_usb_drv.h
index fc2884ab02a2..1ad1ec52b11e 100644
--- a/drivers/staging/media/as102/as102_usb_drv.h
+++ b/drivers/staging/media/as102/as102_usb_drv.h
@@ -17,8 +17,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-#include <linux/version.h>
-
#ifndef _AS102_USB_DRV_H_
#define _AS102_USB_DRV_H_
diff --git a/drivers/staging/media/easycap/easycap_ioctl.c b/drivers/staging/media/easycap/easycap_ioctl.c
index 9413b37490c2..3cee3cd986d2 100644
--- a/drivers/staging/media/easycap/easycap_ioctl.c
+++ b/drivers/staging/media/easycap/easycap_ioctl.c
@@ -26,6 +26,7 @@
/*****************************************************************************/
#include "easycap.h"
+#include <linux/version.h>
/*--------------------------------------------------------------------------*/
/*
diff --git a/drivers/staging/media/easycap/easycap_main.c b/drivers/staging/media/easycap/easycap_main.c
index 19d2d9d64236..8269c77dbf7d 100644
--- a/drivers/staging/media/easycap/easycap_main.c
+++ b/drivers/staging/media/easycap/easycap_main.c
@@ -3468,7 +3468,6 @@ static int easycap_register_video(struct easycap *peasycap)
if (0 != (video_register_device(&(peasycap->video_device),
VFL_TYPE_GRABBER, -1))) {
- err("Not able to register with videodev");
videodev_release(&(peasycap->video_device));
return -ENODEV;
}
@@ -3856,8 +3855,11 @@ static int easycap_usb_probe(struct usb_interface *intf,
peasycap->v4l2_device.name);
rc = easycap_register_video(peasycap);
- if (rc < 0)
+ if (rc < 0) {
+ dev_err(&intf->dev,
+ "Not able to register with videodev\n");
return -ENODEV;
+ }
break;
}
/* 1: Audio control */
@@ -3997,7 +3999,8 @@ static int easycap_usb_probe(struct usb_interface *intf,
rc = easycap_alsa_probe(peasycap);
if (rc) {
- err("easycap_alsa_probe() rc = %i\n", rc);
+ dev_err(&intf->dev, "easycap_alsa_probe() rc = %i\n",
+ rc);
return -ENODEV;
}
diff --git a/drivers/staging/media/go7007/README b/drivers/staging/media/go7007/README
index 48f447637817..aeba1324a9c5 100644
--- a/drivers/staging/media/go7007/README
+++ b/drivers/staging/media/go7007/README
@@ -6,6 +6,6 @@ Todo:
- testing?
- handle churn in v4l layer.
-Please send patchs to Greg Kroah-Hartman <greg@kroah.com> and Cc: Ross
+Please send patches to Greg Kroah-Hartman <greg@linuxfoundation.org> and Cc: Ross
Cohen <rcohen@snurgle.org> as well.
diff --git a/drivers/staging/media/go7007/go7007.txt b/drivers/staging/media/go7007/go7007.txt
index 9db1f3952fd2..fcb3e235abbf 100644
--- a/drivers/staging/media/go7007/go7007.txt
+++ b/drivers/staging/media/go7007/go7007.txt
@@ -87,7 +87,6 @@ kernel as built-in or modules:
CONFIG_SOUND - Sound card support
CONFIG_SND - Advanced Linux Sound Architecture
CONFIG_USB - Support for Host-side USB
- CONFIG_USB_DEVICEFS - USB device filesystem
CONFIG_USB_EHCI_HCD - EHCI HCD (USB 2.0) support
Additionally, to use the example application, the following options need to
diff --git a/drivers/staging/media/go7007/s2250-loader.c b/drivers/staging/media/go7007/s2250-loader.c
index 829c248350f8..f1bd159ac195 100644
--- a/drivers/staging/media/go7007/s2250-loader.c
+++ b/drivers/staging/media/go7007/s2250-loader.c
@@ -160,31 +160,7 @@ static struct usb_driver s2250loader_driver = {
.id_table = s2250loader_ids,
};
-static int __init s2250loader_init(void)
-{
- int r;
- unsigned i = 0;
-
- for (i = 0; i < MAX_DEVICES; i++)
- s2250_dev_table[i] = NULL;
-
- r = usb_register(&s2250loader_driver);
- if (r) {
- printk(KERN_ERR "usb_register failed. Error number %d\n", r);
- return -1;
- }
-
- printk(KERN_INFO "s2250loader_init: driver registered\n");
- return 0;
-}
-module_init(s2250loader_init);
-
-static void __exit s2250loader_cleanup(void)
-{
- printk(KERN_INFO "s2250loader_cleanup\n");
- usb_deregister(&s2250loader_driver);
-}
-module_exit(s2250loader_cleanup);
+module_usb_driver(s2250loader_driver);
MODULE_AUTHOR("");
MODULE_DESCRIPTION("firmware loader for Sensoray 2250/2251");
diff --git a/drivers/staging/media/go7007/wis-i2c.h b/drivers/staging/media/go7007/wis-i2c.h
index 3c2b9be455df..6d09c06c8560 100644
--- a/drivers/staging/media/go7007/wis-i2c.h
+++ b/drivers/staging/media/go7007/wis-i2c.h
@@ -25,11 +25,6 @@
#define I2C_DRIVERID_WIS_TW2804 0xf0f6
#define I2C_DRIVERID_S2250 0xf0f7
-/* Flag to indicate that the client needs to be accessed with SCCB semantics */
-/* We re-use the I2C_M_TEN value so the flag passes through the masks in the
- * core I2C code. Major kludge, but the I2C layer ain't exactly flexible. */
-#define I2C_CLIENT_SCCB 0x10
-
/* Definitions for new video decoder commands */
struct video_decoder_resolution {
diff --git a/drivers/staging/media/lirc/lirc_imon.c b/drivers/staging/media/lirc/lirc_imon.c
index 083219da3a39..2944fde89f44 100644
--- a/drivers/staging/media/lirc/lirc_imon.c
+++ b/drivers/staging/media/lirc/lirc_imon.c
@@ -205,8 +205,9 @@ static void deregister_from_lirc(struct imon_context *context)
retval = lirc_unregister_driver(minor);
if (retval)
- err("%s: unable to deregister from lirc(%d)",
- __func__, retval);
+ printk(KERN_ERR KBUILD_MODNAME
+ ": %s: unable to deregister from lirc(%d)",
+ __func__, retval);
else
printk(KERN_INFO MOD_NAME ": Deregistered iMON driver "
"(minor:%d)\n", minor);
@@ -230,16 +231,18 @@ static int display_open(struct inode *inode, struct file *file)
subminor = iminor(inode);
interface = usb_find_interface(&imon_driver, subminor);
if (!interface) {
- err("%s: could not find interface for minor %d",
- __func__, subminor);
+ printk(KERN_ERR KBUILD_MODNAME
+ ": %s: could not find interface for minor %d\n",
+ __func__, subminor);
retval = -ENODEV;
goto exit;
}
context = usb_get_intfdata(interface);
if (!context) {
- err("%s: no context found for minor %d",
- __func__, subminor);
+ dev_err(&interface->dev,
+ "%s: no context found for minor %d\n",
+ __func__, subminor);
retval = -ENODEV;
goto exit;
}
@@ -247,10 +250,12 @@ static int display_open(struct inode *inode, struct file *file)
mutex_lock(&context->ctx_lock);
if (!context->display) {
- err("%s: display not supported by device", __func__);
+ dev_err(&interface->dev,
+ "%s: display not supported by device\n", __func__);
retval = -ENODEV;
} else if (context->display_isopen) {
- err("%s: display port is already open", __func__);
+ dev_err(&interface->dev,
+ "%s: display port is already open\n", __func__);
retval = -EBUSY;
} else {
context->display_isopen = 1;
@@ -277,17 +282,20 @@ static int display_close(struct inode *inode, struct file *file)
context = file->private_data;
if (!context) {
- err("%s: no context for device", __func__);
+ printk(KERN_ERR KBUILD_MODNAME
+ "%s: no context for device\n", __func__);
return -ENODEV;
}
mutex_lock(&context->ctx_lock);
if (!context->display) {
- err("%s: display not supported by device", __func__);
+ dev_err(&context->usbdev->dev,
+ "%s: display not supported by device\n", __func__);
retval = -ENODEV;
} else if (!context->display_isopen) {
- err("%s: display is not open", __func__);
+ dev_err(&context->usbdev->dev,
+ "%s: display is not open\n", __func__);
retval = -EIO;
} else {
context->display_isopen = 0;
@@ -336,19 +344,23 @@ static int send_packet(struct imon_context *context)
retval = usb_submit_urb(context->tx_urb, GFP_KERNEL);
if (retval) {
atomic_set(&(context->tx.busy), 0);
- err("%s: error submitting urb(%d)", __func__, retval);
+ dev_err(&context->usbdev->dev,
+ "%s: error submitting urb(%d)\n", __func__, retval);
} else {
/* Wait for transmission to complete (or abort) */
mutex_unlock(&context->ctx_lock);
retval = wait_for_completion_interruptible(
&context->tx.finished);
if (retval)
- err("%s: task interrupted", __func__);
+ dev_err(&context->usbdev->dev,
+ "%s: task interrupted\n", __func__);
mutex_lock(&context->ctx_lock);
retval = context->tx.status;
if (retval)
- err("%s: packet tx failed (%d)", __func__, retval);
+ dev_err(&context->usbdev->dev,
+ "%s: packet tx failed (%d)\n",
+ __func__, retval);
}
return retval;
@@ -379,20 +391,23 @@ static ssize_t vfd_write(struct file *file, const char __user *buf,
context = file->private_data;
if (!context) {
- err("%s: no context for device", __func__);
+ printk(KERN_ERR KBUILD_MODNAME
+ "%s: no context for device\n", __func__);
return -ENODEV;
}
mutex_lock(&context->ctx_lock);
if (!context->dev_present) {
- err("%s: no iMON device present", __func__);
+ dev_err(&context->usbdev->dev,
+ "%s: no iMON device present\n", __func__);
retval = -ENODEV;
goto exit;
}
if (n_bytes <= 0 || n_bytes > IMON_DATA_BUF_SZ - 3) {
- err("%s: invalid payload size", __func__);
+ dev_err(&context->usbdev->dev,
+ "%s: invalid payload size\n", __func__);
retval = -EINVAL;
goto exit;
}
@@ -421,8 +436,9 @@ static ssize_t vfd_write(struct file *file, const char __user *buf,
retval = send_packet(context);
if (retval) {
- err("%s: send packet failed for packet #%d",
- __func__, seq/2);
+ dev_err(&context->usbdev->dev,
+ "%s: send packet failed for packet #%d\n",
+ __func__, seq/2);
goto exit;
} else {
seq += 2;
@@ -437,7 +453,8 @@ static ssize_t vfd_write(struct file *file, const char __user *buf,
context->usb_tx_buf[7] = (unsigned char) seq;
retval = send_packet(context);
if (retval)
- err("%s: send packet failed for packet #%d",
+ dev_err(&context->usbdev->dev,
+ "%s: send packet failed for packet #%d\n",
__func__, seq/2);
}
@@ -504,7 +521,8 @@ static void ir_close(void *data)
context = (struct imon_context *)data;
if (!context) {
- err("%s: no context for device", __func__);
+ printk(KERN_ERR KBUILD_MODNAME
+ "%s: no context for device\n", __func__);
return;
}
@@ -728,7 +746,7 @@ static int imon_probe(struct usb_interface *interface,
context = kzalloc(sizeof(struct imon_context), GFP_KERNEL);
if (!context) {
- err("%s: kzalloc failed for context", __func__);
+ dev_err(dev, "%s: kzalloc failed for context\n", __func__);
alloc_status = 1;
goto alloc_status_switch;
}
@@ -793,7 +811,7 @@ static int imon_probe(struct usb_interface *interface,
/* Input endpoint is mandatory */
if (!ir_ep_found) {
- err("%s: no valid input (IR) endpoint found.", __func__);
+ dev_err(dev, "%s: no valid input (IR) endpoint found.\n", __func__);
retval = -ENODEV;
alloc_status = 2;
goto alloc_status_switch;
@@ -810,30 +828,30 @@ static int imon_probe(struct usb_interface *interface,
driver = kzalloc(sizeof(struct lirc_driver), GFP_KERNEL);
if (!driver) {
- err("%s: kzalloc failed for lirc_driver", __func__);
+ dev_err(dev, "%s: kzalloc failed for lirc_driver\n", __func__);
alloc_status = 2;
goto alloc_status_switch;
}
rbuf = kmalloc(sizeof(struct lirc_buffer), GFP_KERNEL);
if (!rbuf) {
- err("%s: kmalloc failed for lirc_buffer", __func__);
+ dev_err(dev, "%s: kmalloc failed for lirc_buffer\n", __func__);
alloc_status = 3;
goto alloc_status_switch;
}
if (lirc_buffer_init(rbuf, BUF_CHUNK_SIZE, BUF_SIZE)) {
- err("%s: lirc_buffer_init failed", __func__);
+ dev_err(dev, "%s: lirc_buffer_init failed\n", __func__);
alloc_status = 4;
goto alloc_status_switch;
}
rx_urb = usb_alloc_urb(0, GFP_KERNEL);
if (!rx_urb) {
- err("%s: usb_alloc_urb failed for IR urb", __func__);
+ dev_err(dev, "%s: usb_alloc_urb failed for IR urb\n", __func__);
alloc_status = 5;
goto alloc_status_switch;
}
tx_urb = usb_alloc_urb(0, GFP_KERNEL);
if (!tx_urb) {
- err("%s: usb_alloc_urb failed for display urb",
+ dev_err(dev, "%s: usb_alloc_urb failed for display urb\n",
__func__);
alloc_status = 6;
goto alloc_status_switch;
@@ -861,7 +879,7 @@ static int imon_probe(struct usb_interface *interface,
lirc_minor = lirc_register_driver(driver);
if (lirc_minor < 0) {
- err("%s: lirc_register_driver failed", __func__);
+ dev_err(dev, "%s: lirc_register_driver failed\n", __func__);
alloc_status = 7;
goto unlock;
} else
@@ -896,8 +914,8 @@ static int imon_probe(struct usb_interface *interface,
retval = usb_submit_urb(context->rx_urb, GFP_KERNEL);
if (retval) {
- err("%s: usb_submit_urb failed for intf0 (%d)",
- __func__, retval);
+ dev_err(dev, "%s: usb_submit_urb failed for intf0 (%d)\n",
+ __func__, retval);
mutex_unlock(&context->ctx_lock);
goto exit;
}
diff --git a/drivers/staging/media/lirc/lirc_sasem.c b/drivers/staging/media/lirc/lirc_sasem.c
index d5bc35aea1c1..f4e4d9003f38 100644
--- a/drivers/staging/media/lirc/lirc_sasem.c
+++ b/drivers/staging/media/lirc/lirc_sasem.c
@@ -181,7 +181,7 @@ static void deregister_from_lirc(struct sasem_context *context)
retval = lirc_unregister_driver(minor);
if (retval)
- err("%s: unable to deregister from lirc (%d)",
+ printk(KERN_ERR "%s: unable to deregister from lirc (%d)\n",
__func__, retval);
else
printk(KERN_INFO "Deregistered Sasem driver (minor:%d)\n",
@@ -206,16 +206,18 @@ static int vfd_open(struct inode *inode, struct file *file)
subminor = iminor(inode);
interface = usb_find_interface(&sasem_driver, subminor);
if (!interface) {
- err("%s: could not find interface for minor %d",
- __func__, subminor);
+ printk(KERN_ERR KBUILD_MODNAME
+ ": %s: could not find interface for minor %d\n",
+ __func__, subminor);
retval = -ENODEV;
goto exit;
}
context = usb_get_intfdata(interface);
if (!context) {
- err("%s: no context found for minor %d",
- __func__, subminor);
+ dev_err(&interface->dev,
+ "%s: no context found for minor %d\n",
+ __func__, subminor);
retval = -ENODEV;
goto exit;
}
@@ -223,12 +225,13 @@ static int vfd_open(struct inode *inode, struct file *file)
mutex_lock(&context->ctx_lock);
if (context->vfd_isopen) {
- err("%s: VFD port is already open", __func__);
+ dev_err(&interface->dev,
+ "%s: VFD port is already open", __func__);
retval = -EBUSY;
} else {
context->vfd_isopen = 1;
file->private_data = context;
- printk(KERN_INFO "VFD port opened\n");
+ dev_info(&interface->dev, "VFD port opened\n");
}
mutex_unlock(&context->ctx_lock);
@@ -249,7 +252,8 @@ static long vfd_ioctl(struct file *file, unsigned cmd, unsigned long arg)
context = (struct sasem_context *) file->private_data;
if (!context) {
- err("%s: no context for device", __func__);
+ printk(KERN_ERR KBUILD_MODNAME
+ ": %s: no context for device\n", __func__);
return -ENODEV;
}
@@ -283,14 +287,15 @@ static int vfd_close(struct inode *inode, struct file *file)
context = (struct sasem_context *) file->private_data;
if (!context) {
- err("%s: no context for device", __func__);
+ printk(KERN_ERR KBUILD_MODNAME
+ ": %s: no context for device\n", __func__);
return -ENODEV;
}
mutex_lock(&context->ctx_lock);
if (!context->vfd_isopen) {
- err("%s: VFD is not open", __func__);
+ dev_err(&context->dev->dev, "%s: VFD is not open\n", __func__);
retval = -EIO;
} else {
context->vfd_isopen = 0;
@@ -335,7 +340,8 @@ static int send_packet(struct sasem_context *context)
retval = usb_submit_urb(context->tx_urb, GFP_KERNEL);
if (retval) {
atomic_set(&(context->tx.busy), 0);
- err("%s: error submitting urb (%d)", __func__, retval);
+ dev_err(&context->dev->dev, "%s: error submitting urb (%d)\n",
+ __func__, retval);
} else {
/* Wait for transmission to complete (or abort) */
mutex_unlock(&context->ctx_lock);
@@ -344,7 +350,9 @@ static int send_packet(struct sasem_context *context)
retval = context->tx.status;
if (retval)
- err("%s: packet tx failed (%d)", __func__, retval);
+ dev_err(&context->dev->dev,
+ "%s: packet tx failed (%d)\n",
+ __func__, retval);
}
return retval;
@@ -365,20 +373,23 @@ static ssize_t vfd_write(struct file *file, const char *buf,
context = (struct sasem_context *) file->private_data;
if (!context) {
- err("%s: no context for device", __func__);
+ printk(KERN_ERR KBUILD_MODNAME
+ ": %s: no context for device\n", __func__);
return -ENODEV;
}
mutex_lock(&context->ctx_lock);
if (!context->dev_present) {
- err("%s: no Sasem device present", __func__);
+ printk(KERN_ERR KBUILD_MODNAME
+ ": %s: no Sasem device present\n", __func__);
retval = -ENODEV;
goto exit;
}
if (n_bytes <= 0 || n_bytes > SASEM_DATA_BUF_SZ) {
- err("%s: invalid payload size", __func__);
+ dev_err(&context->dev->dev, "%s: invalid payload size\n",
+ __func__);
retval = -EINVAL;
goto exit;
}
@@ -436,9 +447,9 @@ static ssize_t vfd_write(struct file *file, const char *buf,
}
retval = send_packet(context);
if (retval) {
-
- err("%s: send packet failed for packet #%d",
- __func__, i);
+ dev_err(&context->dev->dev,
+ "%s: send packet failed for packet #%d\n",
+ __func__, i);
goto exit;
}
}
@@ -488,7 +499,8 @@ static int ir_open(void *data)
mutex_lock(&context->ctx_lock);
if (context->ir_isopen) {
- err("%s: IR port is already open", __func__);
+ dev_err(&context->dev->dev, "%s: IR port is already open\n",
+ __func__);
retval = -EBUSY;
goto exit;
}
@@ -502,8 +514,9 @@ static int ir_open(void *data)
retval = usb_submit_urb(context->rx_urb, GFP_KERNEL);
if (retval)
- err("%s: usb_submit_urb failed for ir_open (%d)",
- __func__, retval);
+ dev_err(&context->dev->dev,
+ "%s: usb_submit_urb failed for ir_open (%d)\n",
+ __func__, retval);
else {
context->ir_isopen = 1;
printk(KERN_INFO "IR port opened\n");
@@ -525,7 +538,8 @@ static void ir_close(void *data)
context = (struct sasem_context *)data;
if (!context) {
- err("%s: no context for device", __func__);
+ printk(KERN_ERR KBUILD_MODNAME
+ ": %s: no context for device\n", __func__);
return;
}
@@ -683,7 +697,7 @@ static int sasem_probe(struct usb_interface *interface,
struct sasem_context *context = NULL;
int i;
- printk(KERN_INFO "%s: found Sasem device\n", __func__);
+ dev_info(&interface->dev, "%s: found Sasem device\n", __func__);
dev = usb_get_dev(interface_to_usbdev(interface));
@@ -715,8 +729,8 @@ static int sasem_probe(struct usb_interface *interface,
rx_endpoint = ep;
ir_ep_found = 1;
if (debug)
- printk(KERN_INFO "%s: found IR endpoint\n",
- __func__);
+ dev_info(&interface->dev,
+ "%s: found IR endpoint\n", __func__);
} else if (!vfd_ep_found &&
ep_dir == USB_DIR_OUT &&
@@ -725,22 +739,23 @@ static int sasem_probe(struct usb_interface *interface,
tx_endpoint = ep;
vfd_ep_found = 1;
if (debug)
- printk(KERN_INFO "%s: found VFD endpoint\n",
- __func__);
+ dev_info(&interface->dev,
+ "%s: found VFD endpoint\n", __func__);
}
}
/* Input endpoint is mandatory */
if (!ir_ep_found) {
-
- err("%s: no valid input (IR) endpoint found.", __func__);
+ dev_err(&interface->dev,
+ "%s: no valid input (IR) endpoint found.\n", __func__);
retval = -ENODEV;
goto exit;
}
if (!vfd_ep_found)
- printk(KERN_INFO "%s: no valid output (VFD) endpoint found.\n",
- __func__);
+ dev_info(&interface->dev,
+ "%s: no valid output (VFD) endpoint found.\n",
+ __func__);
/* Allocate memory */
@@ -748,38 +763,44 @@ static int sasem_probe(struct usb_interface *interface,
context = kzalloc(sizeof(struct sasem_context), GFP_KERNEL);
if (!context) {
- err("%s: kzalloc failed for context", __func__);
+ dev_err(&interface->dev,
+ "%s: kzalloc failed for context\n", __func__);
alloc_status = 1;
goto alloc_status_switch;
}
driver = kzalloc(sizeof(struct lirc_driver), GFP_KERNEL);
if (!driver) {
- err("%s: kzalloc failed for lirc_driver", __func__);
+ dev_err(&interface->dev,
+ "%s: kzalloc failed for lirc_driver\n", __func__);
alloc_status = 2;
goto alloc_status_switch;
}
rbuf = kmalloc(sizeof(struct lirc_buffer), GFP_KERNEL);
if (!rbuf) {
- err("%s: kmalloc failed for lirc_buffer", __func__);
+ dev_err(&interface->dev,
+ "%s: kmalloc failed for lirc_buffer\n", __func__);
alloc_status = 3;
goto alloc_status_switch;
}
if (lirc_buffer_init(rbuf, BUF_CHUNK_SIZE, BUF_SIZE)) {
- err("%s: lirc_buffer_init failed", __func__);
+ dev_err(&interface->dev,
+ "%s: lirc_buffer_init failed\n", __func__);
alloc_status = 4;
goto alloc_status_switch;
}
rx_urb = usb_alloc_urb(0, GFP_KERNEL);
if (!rx_urb) {
- err("%s: usb_alloc_urb failed for IR urb", __func__);
+ dev_err(&interface->dev,
+ "%s: usb_alloc_urb failed for IR urb\n", __func__);
alloc_status = 5;
goto alloc_status_switch;
}
if (vfd_ep_found) {
tx_urb = usb_alloc_urb(0, GFP_KERNEL);
if (!tx_urb) {
- err("%s: usb_alloc_urb failed for VFD urb",
- __func__);
+ dev_err(&interface->dev,
+ "%s: usb_alloc_urb failed for VFD urb",
+ __func__);
alloc_status = 6;
goto alloc_status_switch;
}
@@ -803,7 +824,8 @@ static int sasem_probe(struct usb_interface *interface,
lirc_minor = lirc_register_driver(driver);
if (lirc_minor < 0) {
- err("%s: lirc_register_driver failed", __func__);
+ dev_err(&interface->dev,
+ "%s: lirc_register_driver failed\n", __func__);
alloc_status = 7;
retval = lirc_minor;
goto unlock;
diff --git a/drivers/staging/media/lirc/lirc_ttusbir.c b/drivers/staging/media/lirc/lirc_ttusbir.c
index 7950887ff113..3bb865c02173 100644
--- a/drivers/staging/media/lirc/lirc_ttusbir.c
+++ b/drivers/staging/media/lirc/lirc_ttusbir.c
@@ -113,8 +113,9 @@ static int set_use_inc(void *data)
for (i = 0; i < num_urbs; i++) {
retval = usb_submit_urb(ttusbir->urb[i], GFP_KERNEL);
if (retval) {
- err("%s: usb_submit_urb failed on urb %d",
- __func__, i);
+ dev_err(&ttusbir->interf->dev,
+ "%s: usb_submit_urb failed on urb %d\n",
+ __func__, i);
return retval;
}
}
@@ -278,7 +279,7 @@ static int probe(struct usb_interface *intf, const struct usb_device_id *id)
if (ttusbir->alt_setting != -1)
DPRINTK("alt setting: %d\n", ttusbir->alt_setting);
else {
- err("Could not find alternate setting\n");
+ dev_err(&intf->dev, "Could not find alternate setting\n");
kfree(ttusbir);
return -EINVAL;
}
@@ -291,7 +292,7 @@ static int probe(struct usb_interface *intf, const struct usb_device_id *id)
/* Register as a LIRC driver */
if (lirc_buffer_init(&ttusbir->rbuf, sizeof(int), 256) < 0) {
- err("Could not get memory for LIRC data buffer\n");
+ dev_err(&intf->dev, "Could not get memory for LIRC data buffer\n");
usb_set_intfdata(intf, NULL);
kfree(ttusbir);
return -ENOMEM;
@@ -310,7 +311,7 @@ static int probe(struct usb_interface *intf, const struct usb_device_id *id)
ttusbir->driver.features = LIRC_CAN_REC_MODE2;
ttusbir->minor = lirc_register_driver(&ttusbir->driver);
if (ttusbir->minor < 0) {
- err("Error registering as LIRC driver\n");
+ dev_err(&intf->dev, "Error registering as LIRC driver\n");
usb_set_intfdata(intf, NULL);
lirc_buffer_free(&ttusbir->rbuf);
kfree(ttusbir);
@@ -321,7 +322,7 @@ static int probe(struct usb_interface *intf, const struct usb_device_id *id)
for (i = 0; i < num_urbs; i++) {
ttusbir->urb[i] = usb_alloc_urb(8, GFP_KERNEL);
if (!ttusbir->urb[i]) {
- err("Could not allocate memory for the URB\n");
+ dev_err(&intf->dev, "Could not allocate memory for the URB\n");
for (j = i - 1; j >= 0; j--)
kfree(ttusbir->urb[j]);
lirc_buffer_free(&ttusbir->rbuf);
diff --git a/drivers/staging/mei/Kconfig b/drivers/staging/mei/Kconfig
deleted file mode 100644
index 47d78a72db2e..000000000000
--- a/drivers/staging/mei/Kconfig
+++ /dev/null
@@ -1,28 +0,0 @@
-config INTEL_MEI
- tristate "Intel Management Engine Interface (Intel MEI)"
- depends on X86 && PCI && EXPERIMENTAL && WATCHDOG_CORE
- help
- The Intel Management Engine (Intel ME) provides Manageability,
- Security and Media services for system containing Intel chipsets.
- if selected /dev/mei misc device will be created.
-
- Supported Chipsets are:
- 7 Series Chipset Family
- 6 Series Chipset Family
- 5 Series Chipset Family
- 4 Series Chipset Family
- Mobile 4 Series Chipset Family
- ICH9
- 82946GZ/GL
- 82G35 Express
- 82Q963/Q965
- 82P965/G965
- Mobile PM965/GM965
- Mobile GME965/GLE960
- 82Q35 Express
- 82G33/G31/P35/P31 Express
- 82Q33 Express
- 82X38/X48 Express
-
- For more information see
- <http://software.intel.com/en-us/manageability/>
diff --git a/drivers/staging/mei/Makefile b/drivers/staging/mei/Makefile
deleted file mode 100644
index 57168db6c7e5..000000000000
--- a/drivers/staging/mei/Makefile
+++ /dev/null
@@ -1,11 +0,0 @@
-#
-# Makefile - Intel Management Engine Interface (Intel MEI) Linux driver
-# Copyright (c) 2010-2011, Intel Corporation.
-#
-obj-$(CONFIG_INTEL_MEI) += mei.o
-mei-objs := init.o
-mei-objs += interrupt.o
-mei-objs += interface.o
-mei-objs += iorw.o
-mei-objs += main.o
-mei-objs += wd.o
diff --git a/drivers/staging/mei/TODO b/drivers/staging/mei/TODO
deleted file mode 100644
index fc266018355e..000000000000
--- a/drivers/staging/mei/TODO
+++ /dev/null
@@ -1,10 +0,0 @@
-TODO:
- - Cleanup and split the timer function
-Upon Unstaging:
- - move mei.h to include/linux/mei.h
- - Documentation/ioctl/ioctl-number.txt
- - move mei.txt under Documentation/mei/
- - move mei-amt-version.c under Documentation/mei
- - add hostprogs-y for mei-amt-version.c
- - drop mei_version.h
- - Updated MAINTAINERS
diff --git a/drivers/staging/mei/hw.h b/drivers/staging/mei/hw.h
deleted file mode 100644
index 24c4c962819e..000000000000
--- a/drivers/staging/mei/hw.h
+++ /dev/null
@@ -1,332 +0,0 @@
-/*
- *
- * Intel Management Engine Interface (Intel MEI) Linux driver
- * Copyright (c) 2003-2012, Intel Corporation.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms and conditions of the GNU General Public License,
- * version 2, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- */
-
-#ifndef _MEI_HW_TYPES_H_
-#define _MEI_HW_TYPES_H_
-
-#include <linux/uuid.h>
-
-/*
- * Timeouts
- */
-#define MEI_INTEROP_TIMEOUT (HZ * 7)
-#define MEI_CONNECT_TIMEOUT 3 /* at least 2 seconds */
-
-#define CONNECT_TIMEOUT 15 /* HPS definition */
-#define INIT_CLIENTS_TIMEOUT 15 /* HPS definition */
-
-#define IAMTHIF_STALL_TIMER 12 /* seconds */
-#define IAMTHIF_READ_TIMER 10000 /* ms */
-
-/*
- * Internal Clients Number
- */
-#define MEI_WD_HOST_CLIENT_ID 1
-#define MEI_IAMTHIF_HOST_CLIENT_ID 2
-
-/*
- * MEI device IDs
- */
-#define MEI_DEV_ID_82946GZ 0x2974 /* 82946GZ/GL */
-#define MEI_DEV_ID_82G35 0x2984 /* 82G35 Express */
-#define MEI_DEV_ID_82Q965 0x2994 /* 82Q963/Q965 */
-#define MEI_DEV_ID_82G965 0x29A4 /* 82P965/G965 */
-
-#define MEI_DEV_ID_82GM965 0x2A04 /* Mobile PM965/GM965 */
-#define MEI_DEV_ID_82GME965 0x2A14 /* Mobile GME965/GLE960 */
-
-#define MEI_DEV_ID_ICH9_82Q35 0x29B4 /* 82Q35 Express */
-#define MEI_DEV_ID_ICH9_82G33 0x29C4 /* 82G33/G31/P35/P31 Express */
-#define MEI_DEV_ID_ICH9_82Q33 0x29D4 /* 82Q33 Express */
-#define MEI_DEV_ID_ICH9_82X38 0x29E4 /* 82X38/X48 Express */
-#define MEI_DEV_ID_ICH9_3200 0x29F4 /* 3200/3210 Server */
-
-#define MEI_DEV_ID_ICH9_6 0x28B4 /* Bearlake */
-#define MEI_DEV_ID_ICH9_7 0x28C4 /* Bearlake */
-#define MEI_DEV_ID_ICH9_8 0x28D4 /* Bearlake */
-#define MEI_DEV_ID_ICH9_9 0x28E4 /* Bearlake */
-#define MEI_DEV_ID_ICH9_10 0x28F4 /* Bearlake */
-
-#define MEI_DEV_ID_ICH9M_1 0x2A44 /* Cantiga */
-#define MEI_DEV_ID_ICH9M_2 0x2A54 /* Cantiga */
-#define MEI_DEV_ID_ICH9M_3 0x2A64 /* Cantiga */
-#define MEI_DEV_ID_ICH9M_4 0x2A74 /* Cantiga */
-
-#define MEI_DEV_ID_ICH10_1 0x2E04 /* Eaglelake */
-#define MEI_DEV_ID_ICH10_2 0x2E14 /* Eaglelake */
-#define MEI_DEV_ID_ICH10_3 0x2E24 /* Eaglelake */
-#define MEI_DEV_ID_ICH10_4 0x2E34 /* Eaglelake */
-
-#define MEI_DEV_ID_IBXPK_1 0x3B64 /* Calpella */
-#define MEI_DEV_ID_IBXPK_2 0x3B65 /* Calpella */
-
-#define MEI_DEV_ID_CPT_1 0x1C3A /* Cougerpoint */
-#define MEI_DEV_ID_PBG_1 0x1D3A /* PBG */
-
-#define MEI_DEV_ID_PPT_1 0x1E3A /* Pantherpoint PPT */
-#define MEI_DEV_ID_PPT_2 0x1CBA /* Pantherpoint PPT */
-#define MEI_DEV_ID_PPT_3 0x1DBA /* Pantherpoint PPT */
-
-
-/*
- * MEI HW Section
- */
-
-/* MEI registers */
-/* H_CB_WW - Host Circular Buffer (CB) Write Window register */
-#define H_CB_WW 0
-/* H_CSR - Host Control Status register */
-#define H_CSR 4
-/* ME_CB_RW - ME Circular Buffer Read Window register (read only) */
-#define ME_CB_RW 8
-/* ME_CSR_HA - ME Control Status Host Access register (read only) */
-#define ME_CSR_HA 0xC
-
-
-/* register bits of H_CSR (Host Control Status register) */
-/* Host Circular Buffer Depth - maximum number of 32-bit entries in CB */
-#define H_CBD 0xFF000000
-/* Host Circular Buffer Write Pointer */
-#define H_CBWP 0x00FF0000
-/* Host Circular Buffer Read Pointer */
-#define H_CBRP 0x0000FF00
-/* Host Reset */
-#define H_RST 0x00000010
-/* Host Ready */
-#define H_RDY 0x00000008
-/* Host Interrupt Generate */
-#define H_IG 0x00000004
-/* Host Interrupt Status */
-#define H_IS 0x00000002
-/* Host Interrupt Enable */
-#define H_IE 0x00000001
-
-
-/* register bits of ME_CSR_HA (ME Control Status Host Access register) */
-/* ME CB (Circular Buffer) Depth HRA (Host Read Access) - host read only
-access to ME_CBD */
-#define ME_CBD_HRA 0xFF000000
-/* ME CB Write Pointer HRA - host read only access to ME_CBWP */
-#define ME_CBWP_HRA 0x00FF0000
-/* ME CB Read Pointer HRA - host read only access to ME_CBRP */
-#define ME_CBRP_HRA 0x0000FF00
-/* ME Reset HRA - host read only access to ME_RST */
-#define ME_RST_HRA 0x00000010
-/* ME Ready HRA - host read only access to ME_RDY */
-#define ME_RDY_HRA 0x00000008
-/* ME Interrupt Generate HRA - host read only access to ME_IG */
-#define ME_IG_HRA 0x00000004
-/* ME Interrupt Status HRA - host read only access to ME_IS */
-#define ME_IS_HRA 0x00000002
-/* ME Interrupt Enable HRA - host read only access to ME_IE */
-#define ME_IE_HRA 0x00000001
-
-/*
- * MEI Version
- */
-#define HBM_MINOR_VERSION 0
-#define HBM_MAJOR_VERSION 1
-#define HBM_TIMEOUT 1 /* 1 second */
-
-/* Host bus message command opcode */
-#define MEI_HBM_CMD_OP_MSK 0x7f
-/* Host bus message command RESPONSE */
-#define MEI_HBM_CMD_RES_MSK 0x80
-
-/*
- * MEI Bus Message Command IDs
- */
-#define HOST_START_REQ_CMD 0x01
-#define HOST_START_RES_CMD 0x81
-
-#define HOST_STOP_REQ_CMD 0x02
-#define HOST_STOP_RES_CMD 0x82
-
-#define ME_STOP_REQ_CMD 0x03
-
-#define HOST_ENUM_REQ_CMD 0x04
-#define HOST_ENUM_RES_CMD 0x84
-
-#define HOST_CLIENT_PROPERTIES_REQ_CMD 0x05
-#define HOST_CLIENT_PROPERTIES_RES_CMD 0x85
-
-#define CLIENT_CONNECT_REQ_CMD 0x06
-#define CLIENT_CONNECT_RES_CMD 0x86
-
-#define CLIENT_DISCONNECT_REQ_CMD 0x07
-#define CLIENT_DISCONNECT_RES_CMD 0x87
-
-#define MEI_FLOW_CONTROL_CMD 0x08
-
-/*
- * MEI Stop Reason
- * used by hbm_host_stop_request.reason
- */
-enum mei_stop_reason_types {
- DRIVER_STOP_REQUEST = 0x00,
- DEVICE_D1_ENTRY = 0x01,
- DEVICE_D2_ENTRY = 0x02,
- DEVICE_D3_ENTRY = 0x03,
- SYSTEM_S1_ENTRY = 0x04,
- SYSTEM_S2_ENTRY = 0x05,
- SYSTEM_S3_ENTRY = 0x06,
- SYSTEM_S4_ENTRY = 0x07,
- SYSTEM_S5_ENTRY = 0x08
-};
-
-/*
- * Client Connect Status
- * used by hbm_client_connect_response.status
- */
-enum client_connect_status_types {
- CCS_SUCCESS = 0x00,
- CCS_NOT_FOUND = 0x01,
- CCS_ALREADY_STARTED = 0x02,
- CCS_OUT_OF_RESOURCES = 0x03,
- CCS_MESSAGE_SMALL = 0x04
-};
-
-/*
- * Client Disconnect Status
- */
-enum client_disconnect_status_types {
- CDS_SUCCESS = 0x00
-};
-
-/*
- * MEI BUS Interface Section
- */
-struct mei_msg_hdr {
- u32 me_addr:8;
- u32 host_addr:8;
- u32 length:9;
- u32 reserved:6;
- u32 msg_complete:1;
-} __packed;
-
-
-struct mei_bus_message {
- u8 hbm_cmd;
- u8 data[0];
-} __packed;
-
-struct hbm_version {
- u8 minor_version;
- u8 major_version;
-} __packed;
-
-struct hbm_host_version_request {
- u8 hbm_cmd;
- u8 reserved;
- struct hbm_version host_version;
-} __packed;
-
-struct hbm_host_version_response {
- u8 hbm_cmd;
- u8 host_version_supported;
- struct hbm_version me_max_version;
-} __packed;
-
-struct hbm_host_stop_request {
- u8 hbm_cmd;
- u8 reason;
- u8 reserved[2];
-} __packed;
-
-struct hbm_host_stop_response {
- u8 hbm_cmd;
- u8 reserved[3];
-} __packed;
-
-struct hbm_me_stop_request {
- u8 hbm_cmd;
- u8 reason;
- u8 reserved[2];
-} __packed;
-
-struct hbm_host_enum_request {
- u8 hbm_cmd;
- u8 reserved[3];
-} __packed;
-
-struct hbm_host_enum_response {
- u8 hbm_cmd;
- u8 reserved[3];
- u8 valid_addresses[32];
-} __packed;
-
-struct mei_client_properties {
- uuid_le protocol_name;
- u8 protocol_version;
- u8 max_number_of_connections;
- u8 fixed_address;
- u8 single_recv_buf;
- u32 max_msg_length;
-} __packed;
-
-struct hbm_props_request {
- u8 hbm_cmd;
- u8 address;
- u8 reserved[2];
-} __packed;
-
-
-struct hbm_props_response {
- u8 hbm_cmd;
- u8 address;
- u8 status;
- u8 reserved[1];
- struct mei_client_properties client_properties;
-} __packed;
-
-struct hbm_client_connect_request {
- u8 hbm_cmd;
- u8 me_addr;
- u8 host_addr;
- u8 reserved;
-} __packed;
-
-struct hbm_client_connect_response {
- u8 hbm_cmd;
- u8 me_addr;
- u8 host_addr;
- u8 status;
-} __packed;
-
-struct hbm_client_disconnect_request {
- u8 hbm_cmd;
- u8 me_addr;
- u8 host_addr;
- u8 reserved[1];
-} __packed;
-
-#define MEI_FC_MESSAGE_RESERVED_LENGTH 5
-
-struct hbm_flow_control {
- u8 hbm_cmd;
- u8 me_addr;
- u8 host_addr;
- u8 reserved[MEI_FC_MESSAGE_RESERVED_LENGTH];
-} __packed;
-
-struct mei_me_client {
- struct mei_client_properties props;
- u8 client_id;
- u8 mei_flow_ctrl_creds;
-} __packed;
-
-
-#endif
diff --git a/drivers/staging/mei/init.c b/drivers/staging/mei/init.c
deleted file mode 100644
index eab711fb5fc4..000000000000
--- a/drivers/staging/mei/init.c
+++ /dev/null
@@ -1,735 +0,0 @@
-/*
- *
- * Intel Management Engine Interface (Intel MEI) Linux driver
- * Copyright (c) 2003-2012, Intel Corporation.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms and conditions of the GNU General Public License,
- * version 2, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- */
-
-#include <linux/pci.h>
-#include <linux/sched.h>
-#include <linux/wait.h>
-#include <linux/delay.h>
-
-#include "mei_dev.h"
-#include "hw.h"
-#include "interface.h"
-#include "mei.h"
-
-const uuid_le mei_amthi_guid = UUID_LE(0x12f80028, 0xb4b7, 0x4b2d, 0xac,
- 0xa8, 0x46, 0xe0, 0xff, 0x65,
- 0x81, 0x4c);
-
-/**
- * mei_io_list_init - Sets up a queue list.
- *
- * @list: An instance io list structure
- * @dev: the device structure
- */
-void mei_io_list_init(struct mei_io_list *list)
-{
- /* initialize our queue list */
- INIT_LIST_HEAD(&list->mei_cb.cb_list);
-}
-
-/**
- * mei_io_list_flush - removes list entry belonging to cl.
- *
- * @list: An instance of our list structure
- * @cl: private data of the file object
- */
-void mei_io_list_flush(struct mei_io_list *list, struct mei_cl *cl)
-{
- struct mei_cl_cb *pos;
- struct mei_cl_cb *next;
-
- list_for_each_entry_safe(pos, next, &list->mei_cb.cb_list, cb_list) {
- if (pos->file_private) {
- struct mei_cl *cl_tmp;
- cl_tmp = (struct mei_cl *)pos->file_private;
- if (mei_cl_cmp_id(cl, cl_tmp))
- list_del(&pos->cb_list);
- }
- }
-}
-/**
- * mei_cl_flush_queues - flushes queue lists belonging to cl.
- *
- * @dev: the device structure
- * @cl: private data of the file object
- */
-int mei_cl_flush_queues(struct mei_cl *cl)
-{
- if (!cl || !cl->dev)
- return -EINVAL;
-
- dev_dbg(&cl->dev->pdev->dev, "remove list entry belonging to cl\n");
- mei_io_list_flush(&cl->dev->read_list, cl);
- mei_io_list_flush(&cl->dev->write_list, cl);
- mei_io_list_flush(&cl->dev->write_waiting_list, cl);
- mei_io_list_flush(&cl->dev->ctrl_wr_list, cl);
- mei_io_list_flush(&cl->dev->ctrl_rd_list, cl);
- mei_io_list_flush(&cl->dev->amthi_cmd_list, cl);
- mei_io_list_flush(&cl->dev->amthi_read_complete_list, cl);
- return 0;
-}
-
-
-
-/**
- * mei_reset_iamthif_params - initializes mei device iamthif
- *
- * @dev: the device structure
- */
-static void mei_reset_iamthif_params(struct mei_device *dev)
-{
- /* reset iamthif parameters. */
- dev->iamthif_current_cb = NULL;
- dev->iamthif_msg_buf_size = 0;
- dev->iamthif_msg_buf_index = 0;
- dev->iamthif_canceled = false;
- dev->iamthif_ioctl = false;
- dev->iamthif_state = MEI_IAMTHIF_IDLE;
- dev->iamthif_timer = 0;
-}
-
-/**
- * init_mei_device - allocates and initializes the mei device structure
- *
- * @pdev: The pci device structure
- *
- * returns The mei_device_device pointer on success, NULL on failure.
- */
-struct mei_device *mei_device_init(struct pci_dev *pdev)
-{
- struct mei_device *dev;
-
- dev = kzalloc(sizeof(struct mei_device), GFP_KERNEL);
- if (!dev)
- return NULL;
-
- /* setup our list array */
- INIT_LIST_HEAD(&dev->file_list);
- INIT_LIST_HEAD(&dev->wd_cl.link);
- INIT_LIST_HEAD(&dev->iamthif_cl.link);
- mutex_init(&dev->device_lock);
- init_waitqueue_head(&dev->wait_recvd_msg);
- init_waitqueue_head(&dev->wait_stop_wd);
- dev->mei_state = MEI_INITIALIZING;
- dev->iamthif_state = MEI_IAMTHIF_IDLE;
- dev->wd_interface_reg = false;
-
-
- mei_io_list_init(&dev->read_list);
- mei_io_list_init(&dev->write_list);
- mei_io_list_init(&dev->write_waiting_list);
- mei_io_list_init(&dev->ctrl_wr_list);
- mei_io_list_init(&dev->ctrl_rd_list);
- mei_io_list_init(&dev->amthi_cmd_list);
- mei_io_list_init(&dev->amthi_read_complete_list);
- dev->pdev = pdev;
- return dev;
-}
-
-/**
- * mei_hw_init - initializes host and fw to start work.
- *
- * @dev: the device structure
- *
- * returns 0 on success, <0 on failure.
- */
-int mei_hw_init(struct mei_device *dev)
-{
- int err = 0;
- int ret;
-
- mutex_lock(&dev->device_lock);
-
- dev->host_hw_state = mei_hcsr_read(dev);
- dev->me_hw_state = mei_mecsr_read(dev);
- dev_dbg(&dev->pdev->dev, "host_hw_state = 0x%08x, mestate = 0x%08x.\n",
- dev->host_hw_state, dev->me_hw_state);
-
- /* acknowledge interrupt and stop interupts */
- if ((dev->host_hw_state & H_IS) == H_IS)
- mei_reg_write(dev, H_CSR, dev->host_hw_state);
-
- dev->recvd_msg = false;
- dev_dbg(&dev->pdev->dev, "reset in start the mei device.\n");
-
- mei_reset(dev, 1);
-
- dev_dbg(&dev->pdev->dev, "host_hw_state = 0x%08x, me_hw_state = 0x%08x.\n",
- dev->host_hw_state, dev->me_hw_state);
-
- /* wait for ME to turn on ME_RDY */
- if (!dev->recvd_msg) {
- mutex_unlock(&dev->device_lock);
- err = wait_event_interruptible_timeout(dev->wait_recvd_msg,
- dev->recvd_msg, MEI_INTEROP_TIMEOUT);
- mutex_lock(&dev->device_lock);
- }
-
- if (err <= 0 && !dev->recvd_msg) {
- dev->mei_state = MEI_DISABLED;
- dev_dbg(&dev->pdev->dev,
- "wait_event_interruptible_timeout failed"
- "on wait for ME to turn on ME_RDY.\n");
- ret = -ENODEV;
- goto out;
- }
-
- if (!(((dev->host_hw_state & H_RDY) == H_RDY) &&
- ((dev->me_hw_state & ME_RDY_HRA) == ME_RDY_HRA))) {
- dev->mei_state = MEI_DISABLED;
- dev_dbg(&dev->pdev->dev,
- "host_hw_state = 0x%08x, me_hw_state = 0x%08x.\n",
- dev->host_hw_state, dev->me_hw_state);
-
- if (!(dev->host_hw_state & H_RDY))
- dev_dbg(&dev->pdev->dev, "host turn off H_RDY.\n");
-
- if (!(dev->me_hw_state & ME_RDY_HRA))
- dev_dbg(&dev->pdev->dev, "ME turn off ME_RDY.\n");
-
- printk(KERN_ERR "mei: link layer initialization failed.\n");
- ret = -ENODEV;
- goto out;
- }
-
- if (dev->version.major_version != HBM_MAJOR_VERSION ||
- dev->version.minor_version != HBM_MINOR_VERSION) {
- dev_dbg(&dev->pdev->dev, "MEI start failed.\n");
- ret = -ENODEV;
- goto out;
- }
-
- dev->recvd_msg = false;
- dev_dbg(&dev->pdev->dev, "host_hw_state = 0x%08x, me_hw_state = 0x%08x.\n",
- dev->host_hw_state, dev->me_hw_state);
- dev_dbg(&dev->pdev->dev, "ME turn on ME_RDY and host turn on H_RDY.\n");
- dev_dbg(&dev->pdev->dev, "link layer has been established.\n");
- dev_dbg(&dev->pdev->dev, "MEI start success.\n");
- ret = 0;
-
-out:
- mutex_unlock(&dev->device_lock);
- return ret;
-}
-
-/**
- * mei_hw_reset - resets fw via mei csr register.
- *
- * @dev: the device structure
- * @interrupts_enabled: if interrupt should be enabled after reset.
- */
-static void mei_hw_reset(struct mei_device *dev, int interrupts_enabled)
-{
- dev->host_hw_state |= (H_RST | H_IG);
-
- if (interrupts_enabled)
- mei_enable_interrupts(dev);
- else
- mei_disable_interrupts(dev);
-}
-
-/**
- * mei_reset - resets host and fw.
- *
- * @dev: the device structure
- * @interrupts_enabled: if interrupt should be enabled after reset.
- */
-void mei_reset(struct mei_device *dev, int interrupts_enabled)
-{
- struct mei_cl *cl_pos = NULL;
- struct mei_cl *cl_next = NULL;
- struct mei_cl_cb *cb_pos = NULL;
- struct mei_cl_cb *cb_next = NULL;
- bool unexpected;
-
- if (dev->mei_state == MEI_RECOVERING_FROM_RESET) {
- dev->need_reset = true;
- return;
- }
-
- unexpected = (dev->mei_state != MEI_INITIALIZING &&
- dev->mei_state != MEI_DISABLED &&
- dev->mei_state != MEI_POWER_DOWN &&
- dev->mei_state != MEI_POWER_UP);
-
- dev->host_hw_state = mei_hcsr_read(dev);
-
- dev_dbg(&dev->pdev->dev, "before reset host_hw_state = 0x%08x.\n",
- dev->host_hw_state);
-
- mei_hw_reset(dev, interrupts_enabled);
-
- dev->host_hw_state &= ~H_RST;
- dev->host_hw_state |= H_IG;
-
- mei_hcsr_set(dev);
-
- dev_dbg(&dev->pdev->dev, "currently saved host_hw_state = 0x%08x.\n",
- dev->host_hw_state);
-
- dev->need_reset = false;
-
- if (dev->mei_state != MEI_INITIALIZING) {
- if (dev->mei_state != MEI_DISABLED &&
- dev->mei_state != MEI_POWER_DOWN)
- dev->mei_state = MEI_RESETING;
-
- list_for_each_entry_safe(cl_pos,
- cl_next, &dev->file_list, link) {
- cl_pos->state = MEI_FILE_DISCONNECTED;
- cl_pos->mei_flow_ctrl_creds = 0;
- cl_pos->read_cb = NULL;
- cl_pos->timer_count = 0;
- }
- /* remove entry if already in list */
- dev_dbg(&dev->pdev->dev, "list del iamthif and wd file list.\n");
- mei_remove_client_from_file_list(dev,
- dev->wd_cl.host_client_id);
-
- mei_remove_client_from_file_list(dev,
- dev->iamthif_cl.host_client_id);
-
- mei_reset_iamthif_params(dev);
- dev->wd_due_counter = 0;
- dev->extra_write_index = 0;
- }
-
- dev->me_clients_num = 0;
- dev->rd_msg_hdr = 0;
- dev->stop = false;
- dev->wd_pending = false;
-
- /* update the state of the registers after reset */
- dev->host_hw_state = mei_hcsr_read(dev);
- dev->me_hw_state = mei_mecsr_read(dev);
-
- dev_dbg(&dev->pdev->dev, "after reset host_hw_state = 0x%08x, me_hw_state = 0x%08x.\n",
- dev->host_hw_state, dev->me_hw_state);
-
- if (unexpected)
- dev_warn(&dev->pdev->dev, "unexpected reset.\n");
-
- /* Wake up all readings so they can be interrupted */
- list_for_each_entry_safe(cl_pos, cl_next, &dev->file_list, link) {
- if (waitqueue_active(&cl_pos->rx_wait)) {
- dev_dbg(&dev->pdev->dev, "Waking up client!\n");
- wake_up_interruptible(&cl_pos->rx_wait);
- }
- }
- /* remove all waiting requests */
- list_for_each_entry_safe(cb_pos, cb_next,
- &dev->write_list.mei_cb.cb_list, cb_list) {
- list_del(&cb_pos->cb_list);
- mei_free_cb_private(cb_pos);
- }
-}
-
-
-
-/**
- * host_start_message - mei host sends start message.
- *
- * @dev: the device structure
- *
- * returns none.
- */
-void mei_host_start_message(struct mei_device *dev)
-{
- struct mei_msg_hdr *mei_hdr;
- struct hbm_host_version_request *host_start_req;
-
- /* host start message */
- mei_hdr = (struct mei_msg_hdr *) &dev->wr_msg_buf[0];
- mei_hdr->host_addr = 0;
- mei_hdr->me_addr = 0;
- mei_hdr->length = sizeof(struct hbm_host_version_request);
- mei_hdr->msg_complete = 1;
- mei_hdr->reserved = 0;
-
- host_start_req =
- (struct hbm_host_version_request *) &dev->wr_msg_buf[1];
- memset(host_start_req, 0, sizeof(struct hbm_host_version_request));
- host_start_req->hbm_cmd = HOST_START_REQ_CMD;
- host_start_req->host_version.major_version = HBM_MAJOR_VERSION;
- host_start_req->host_version.minor_version = HBM_MINOR_VERSION;
- dev->recvd_msg = false;
- if (mei_write_message(dev, mei_hdr, (unsigned char *)host_start_req,
- mei_hdr->length)) {
- dev_dbg(&dev->pdev->dev, "write send version message to FW fail.\n");
- dev->mei_state = MEI_RESETING;
- mei_reset(dev, 1);
- }
- dev->init_clients_state = MEI_START_MESSAGE;
- dev->init_clients_timer = INIT_CLIENTS_TIMEOUT;
- return ;
-}
-
-/**
- * host_enum_clients_message - host sends enumeration client request message.
- *
- * @dev: the device structure
- *
- * returns none.
- */
-void mei_host_enum_clients_message(struct mei_device *dev)
-{
- struct mei_msg_hdr *mei_hdr;
- struct hbm_host_enum_request *host_enum_req;
- mei_hdr = (struct mei_msg_hdr *) &dev->wr_msg_buf[0];
- /* enumerate clients */
- mei_hdr->host_addr = 0;
- mei_hdr->me_addr = 0;
- mei_hdr->length = sizeof(struct hbm_host_enum_request);
- mei_hdr->msg_complete = 1;
- mei_hdr->reserved = 0;
-
- host_enum_req = (struct hbm_host_enum_request *) &dev->wr_msg_buf[1];
- memset(host_enum_req, 0, sizeof(struct hbm_host_enum_request));
- host_enum_req->hbm_cmd = HOST_ENUM_REQ_CMD;
- if (mei_write_message(dev, mei_hdr, (unsigned char *)host_enum_req,
- mei_hdr->length)) {
- dev->mei_state = MEI_RESETING;
- dev_dbg(&dev->pdev->dev, "write send enumeration request message to FW fail.\n");
- mei_reset(dev, 1);
- }
- dev->init_clients_state = MEI_ENUM_CLIENTS_MESSAGE;
- dev->init_clients_timer = INIT_CLIENTS_TIMEOUT;
- return;
-}
-
-
-/**
- * allocate_me_clients_storage - allocates storage for me clients
- *
- * @dev: the device structure
- *
- * returns none.
- */
-void mei_allocate_me_clients_storage(struct mei_device *dev)
-{
- struct mei_me_client *clients;
- int b;
-
- /* count how many ME clients we have */
- for_each_set_bit(b, dev->me_clients_map, MEI_CLIENTS_MAX)
- dev->me_clients_num++;
-
- if (dev->me_clients_num <= 0)
- return ;
-
-
- if (dev->me_clients != NULL) {
- kfree(dev->me_clients);
- dev->me_clients = NULL;
- }
- dev_dbg(&dev->pdev->dev, "memory allocation for ME clients size=%zd.\n",
- dev->me_clients_num * sizeof(struct mei_me_client));
- /* allocate storage for ME clients representation */
- clients = kcalloc(dev->me_clients_num,
- sizeof(struct mei_me_client), GFP_KERNEL);
- if (!clients) {
- dev_dbg(&dev->pdev->dev, "memory allocation for ME clients failed.\n");
- dev->mei_state = MEI_RESETING;
- mei_reset(dev, 1);
- return ;
- }
- dev->me_clients = clients;
- return ;
-}
-/**
- * host_client_properties - reads properties for client
- *
- * @dev: the device structure
- *
- * returns:
- * < 0 - Error.
- * = 0 - no more clients.
- * = 1 - still have clients to send properties request.
- */
-int mei_host_client_properties(struct mei_device *dev)
-{
- struct mei_msg_hdr *mei_header;
- struct hbm_props_request *host_cli_req;
- int b;
- u8 client_num = dev->me_client_presentation_num;
-
- b = dev->me_client_index;
- b = find_next_bit(dev->me_clients_map, MEI_CLIENTS_MAX, b);
- if (b < MEI_CLIENTS_MAX) {
- dev->me_clients[client_num].client_id = b;
- dev->me_clients[client_num].mei_flow_ctrl_creds = 0;
- mei_header = (struct mei_msg_hdr *)&dev->wr_msg_buf[0];
- mei_header->host_addr = 0;
- mei_header->me_addr = 0;
- mei_header->length = sizeof(struct hbm_props_request);
- mei_header->msg_complete = 1;
- mei_header->reserved = 0;
-
- host_cli_req = (struct hbm_props_request *)&dev->wr_msg_buf[1];
-
- memset(host_cli_req, 0, sizeof(struct hbm_props_request));
-
- host_cli_req->hbm_cmd = HOST_CLIENT_PROPERTIES_REQ_CMD;
- host_cli_req->address = b;
-
- if (mei_write_message(dev, mei_header,
- (unsigned char *)host_cli_req,
- mei_header->length)) {
- dev->mei_state = MEI_RESETING;
- dev_dbg(&dev->pdev->dev, "write send enumeration request message to FW fail.\n");
- mei_reset(dev, 1);
- return -EIO;
- }
-
- dev->init_clients_timer = INIT_CLIENTS_TIMEOUT;
- dev->me_client_index = b;
- return 1;
- }
-
- return 0;
-}
-
-/**
- * mei_init_file_private - initializes private file structure.
- *
- * @priv: private file structure to be initialized
- * @file: the file structure
- */
-void mei_cl_init(struct mei_cl *priv, struct mei_device *dev)
-{
- memset(priv, 0, sizeof(struct mei_cl));
- init_waitqueue_head(&priv->wait);
- init_waitqueue_head(&priv->rx_wait);
- init_waitqueue_head(&priv->tx_wait);
- INIT_LIST_HEAD(&priv->link);
- priv->reading_state = MEI_IDLE;
- priv->writing_state = MEI_IDLE;
- priv->dev = dev;
-}
-
-int mei_find_me_client_index(const struct mei_device *dev, uuid_le cuuid)
-{
- int i, res = -1;
-
- for (i = 0; i < dev->me_clients_num; ++i)
- if (uuid_le_cmp(cuuid,
- dev->me_clients[i].props.protocol_name) == 0) {
- res = i;
- break;
- }
-
- return res;
-}
-
-
-/**
- * mei_find_me_client_update_filext - searches for ME client guid
- * sets client_id in mei_file_private if found
- * @dev: the device structure
- * @priv: private file structure to set client_id in
- * @cguid: searched guid of ME client
- * @client_id: id of host client to be set in file private structure
- *
- * returns ME client index
- */
-u8 mei_find_me_client_update_filext(struct mei_device *dev, struct mei_cl *priv,
- const uuid_le *cguid, u8 client_id)
-{
- int i;
-
- if (!dev || !priv || !cguid)
- return 0;
-
- /* check for valid client id */
- i = mei_find_me_client_index(dev, *cguid);
- if (i >= 0) {
- priv->me_client_id = dev->me_clients[i].client_id;
- priv->state = MEI_FILE_CONNECTING;
- priv->host_client_id = client_id;
-
- list_add_tail(&priv->link, &dev->file_list);
- return (u8)i;
- }
-
- return 0;
-}
-
-/**
- * host_init_iamthif - mei initialization iamthif client.
- *
- * @dev: the device structure
- *
- */
-void mei_host_init_iamthif(struct mei_device *dev)
-{
- u8 i;
- unsigned char *msg_buf;
-
- mei_cl_init(&dev->iamthif_cl, dev);
- dev->iamthif_cl.state = MEI_FILE_DISCONNECTED;
-
- /* find ME amthi client */
- i = mei_find_me_client_update_filext(dev, &dev->iamthif_cl,
- &mei_amthi_guid, MEI_IAMTHIF_HOST_CLIENT_ID);
- if (dev->iamthif_cl.state != MEI_FILE_CONNECTING) {
- dev_dbg(&dev->pdev->dev, "failed to find iamthif client.\n");
- return;
- }
-
- /* Assign iamthif_mtu to the value received from ME */
-
- dev->iamthif_mtu = dev->me_clients[i].props.max_msg_length;
- dev_dbg(&dev->pdev->dev, "IAMTHIF_MTU = %d\n",
- dev->me_clients[i].props.max_msg_length);
-
- kfree(dev->iamthif_msg_buf);
- dev->iamthif_msg_buf = NULL;
-
- /* allocate storage for ME message buffer */
- msg_buf = kcalloc(dev->iamthif_mtu,
- sizeof(unsigned char), GFP_KERNEL);
- if (!msg_buf) {
- dev_dbg(&dev->pdev->dev, "memory allocation for ME message buffer failed.\n");
- return;
- }
-
- dev->iamthif_msg_buf = msg_buf;
-
- if (mei_connect(dev, &dev->iamthif_cl)) {
- dev_dbg(&dev->pdev->dev, "Failed to connect to AMTHI client\n");
- dev->iamthif_cl.state = MEI_FILE_DISCONNECTED;
- dev->iamthif_cl.host_client_id = 0;
- } else {
- dev->iamthif_cl.timer_count = CONNECT_TIMEOUT;
- }
-}
-
-/**
- * mei_alloc_file_private - allocates a private file structure and sets it up.
- * @file: the file structure
- *
- * returns The allocated file or NULL on failure
- */
-struct mei_cl *mei_cl_allocate(struct mei_device *dev)
-{
- struct mei_cl *cl;
-
- cl = kmalloc(sizeof(struct mei_cl), GFP_KERNEL);
- if (!cl)
- return NULL;
-
- mei_cl_init(cl, dev);
-
- return cl;
-}
-
-
-
-/**
- * mei_disconnect_host_client - sends disconnect message to fw from host client.
- *
- * @dev: the device structure
- * @cl: private data of the file object
- *
- * Locking: called under "dev->device_lock" lock
- *
- * returns 0 on success, <0 on failure.
- */
-int mei_disconnect_host_client(struct mei_device *dev, struct mei_cl *cl)
-{
- int rets, err;
- long timeout = 15; /* 15 seconds */
- struct mei_cl_cb *cb;
-
- if (!dev || !cl)
- return -ENODEV;
-
- if (cl->state != MEI_FILE_DISCONNECTING)
- return 0;
-
- cb = kzalloc(sizeof(struct mei_cl_cb), GFP_KERNEL);
- if (!cb)
- return -ENOMEM;
-
- INIT_LIST_HEAD(&cb->cb_list);
- cb->file_private = cl;
- cb->major_file_operations = MEI_CLOSE;
- if (dev->mei_host_buffer_is_empty) {
- dev->mei_host_buffer_is_empty = false;
- if (mei_disconnect(dev, cl)) {
- rets = -ENODEV;
- dev_dbg(&dev->pdev->dev, "failed to call mei_disconnect.\n");
- goto free;
- }
- mdelay(10); /* Wait for hardware disconnection ready */
- list_add_tail(&cb->cb_list, &dev->ctrl_rd_list.mei_cb.cb_list);
- } else {
- dev_dbg(&dev->pdev->dev, "add disconnect cb to control write list\n");
- list_add_tail(&cb->cb_list,
- &dev->ctrl_wr_list.mei_cb.cb_list);
- }
- mutex_unlock(&dev->device_lock);
-
- err = wait_event_timeout(dev->wait_recvd_msg,
- (MEI_FILE_DISCONNECTED == cl->state),
- timeout * HZ);
-
- mutex_lock(&dev->device_lock);
- if (MEI_FILE_DISCONNECTED == cl->state) {
- rets = 0;
- dev_dbg(&dev->pdev->dev, "successfully disconnected from FW client.\n");
- } else {
- rets = -ENODEV;
- if (MEI_FILE_DISCONNECTED != cl->state)
- dev_dbg(&dev->pdev->dev, "wrong status client disconnect.\n");
-
- if (err)
- dev_dbg(&dev->pdev->dev,
- "wait failed disconnect err=%08x\n",
- err);
-
- dev_dbg(&dev->pdev->dev, "failed to disconnect from FW client.\n");
- }
-
- mei_io_list_flush(&dev->ctrl_rd_list, cl);
- mei_io_list_flush(&dev->ctrl_wr_list, cl);
-free:
- mei_free_cb_private(cb);
- return rets;
-}
-
-/**
- * mei_remove_client_from_file_list -
- * removes file private data from device file list
- *
- * @dev: the device structure
- * @host_client_id: host client id to be removed
- */
-void mei_remove_client_from_file_list(struct mei_device *dev,
- u8 host_client_id)
-{
- struct mei_cl *cl_pos = NULL;
- struct mei_cl *cl_next = NULL;
- list_for_each_entry_safe(cl_pos, cl_next, &dev->file_list, link) {
- if (host_client_id == cl_pos->host_client_id) {
- dev_dbg(&dev->pdev->dev, "remove host client = %d, ME client = %d\n",
- cl_pos->host_client_id,
- cl_pos->me_client_id);
- list_del_init(&cl_pos->link);
- break;
- }
- }
-}
diff --git a/drivers/staging/mei/interface.c b/drivers/staging/mei/interface.c
deleted file mode 100644
index 9a2cfafc52a6..000000000000
--- a/drivers/staging/mei/interface.c
+++ /dev/null
@@ -1,428 +0,0 @@
-/*
- *
- * Intel Management Engine Interface (Intel MEI) Linux driver
- * Copyright (c) 2003-2012, Intel Corporation.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms and conditions of the GNU General Public License,
- * version 2, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- */
-
-#include <linux/pci.h>
-#include "mei_dev.h"
-#include "mei.h"
-#include "interface.h"
-
-
-
-/**
- * mei_set_csr_register - writes H_CSR register to the mei device,
- * and ignores the H_IS bit for it is write-one-to-zero.
- *
- * @dev: the device structure
- */
-void mei_hcsr_set(struct mei_device *dev)
-{
- if ((dev->host_hw_state & H_IS) == H_IS)
- dev->host_hw_state &= ~H_IS;
- mei_reg_write(dev, H_CSR, dev->host_hw_state);
- dev->host_hw_state = mei_hcsr_read(dev);
-}
-
-/**
- * mei_csr_enable_interrupts - enables mei device interrupts
- *
- * @dev: the device structure
- */
-void mei_enable_interrupts(struct mei_device *dev)
-{
- dev->host_hw_state |= H_IE;
- mei_hcsr_set(dev);
-}
-
-/**
- * mei_csr_disable_interrupts - disables mei device interrupts
- *
- * @dev: the device structure
- */
-void mei_disable_interrupts(struct mei_device *dev)
-{
- dev->host_hw_state &= ~H_IE;
- mei_hcsr_set(dev);
-}
-
-/**
- * _host_get_filled_slots - gets number of device filled buffer slots
- *
- * @device: the device structure
- *
- * returns number of filled slots
- */
-static unsigned char _host_get_filled_slots(const struct mei_device *dev)
-{
- char read_ptr, write_ptr;
-
- read_ptr = (char) ((dev->host_hw_state & H_CBRP) >> 8);
- write_ptr = (char) ((dev->host_hw_state & H_CBWP) >> 16);
-
- return (unsigned char) (write_ptr - read_ptr);
-}
-
-/**
- * mei_host_buffer_is_empty - checks if host buffer is empty.
- *
- * @dev: the device structure
- *
- * returns 1 if empty, 0 - otherwise.
- */
-int mei_host_buffer_is_empty(struct mei_device *dev)
-{
- unsigned char filled_slots;
-
- dev->host_hw_state = mei_hcsr_read(dev);
- filled_slots = _host_get_filled_slots(dev);
-
- if (filled_slots == 0)
- return 1;
-
- return 0;
-}
-
-/**
- * mei_count_empty_write_slots - counts write empty slots.
- *
- * @dev: the device structure
- *
- * returns -1(ESLOTS_OVERFLOW) if overflow, otherwise empty slots count
- */
-int mei_count_empty_write_slots(struct mei_device *dev)
-{
- unsigned char buffer_depth, filled_slots, empty_slots;
-
- dev->host_hw_state = mei_hcsr_read(dev);
- buffer_depth = (unsigned char) ((dev->host_hw_state & H_CBD) >> 24);
- filled_slots = _host_get_filled_slots(dev);
- empty_slots = buffer_depth - filled_slots;
-
- /* check for overflow */
- if (filled_slots > buffer_depth)
- return -EOVERFLOW;
-
- return empty_slots;
-}
-
-/**
- * mei_write_message - writes a message to mei device.
- *
- * @dev: the device structure
- * @header: header of message
- * @write_buffer: message buffer will be written
- * @write_length: message size will be written
- *
- * This function returns -EIO if write has failed
- */
-int mei_write_message(struct mei_device *dev,
- struct mei_msg_hdr *header,
- unsigned char *write_buffer,
- unsigned long write_length)
-{
- u32 temp_msg = 0;
- unsigned long bytes_written = 0;
- unsigned char buffer_depth, filled_slots, empty_slots;
- unsigned long dw_to_write;
-
- dev->host_hw_state = mei_hcsr_read(dev);
-
- dev_dbg(&dev->pdev->dev,
- "host_hw_state = 0x%08x.\n",
- dev->host_hw_state);
-
- dev_dbg(&dev->pdev->dev,
- "mei_write_message header=%08x.\n",
- *((u32 *) header));
-
- buffer_depth = (unsigned char) ((dev->host_hw_state & H_CBD) >> 24);
- filled_slots = _host_get_filled_slots(dev);
- empty_slots = buffer_depth - filled_slots;
- dev_dbg(&dev->pdev->dev,
- "filled = %hu, empty = %hu.\n",
- filled_slots, empty_slots);
-
- dw_to_write = ((write_length + 3) / 4);
-
- if (dw_to_write > empty_slots)
- return -EIO;
-
- mei_reg_write(dev, H_CB_WW, *((u32 *) header));
-
- while (write_length >= 4) {
- mei_reg_write(dev, H_CB_WW,
- *(u32 *) (write_buffer + bytes_written));
- bytes_written += 4;
- write_length -= 4;
- }
-
- if (write_length > 0) {
- memcpy(&temp_msg, &write_buffer[bytes_written], write_length);
- mei_reg_write(dev, H_CB_WW, temp_msg);
- }
-
- dev->host_hw_state |= H_IG;
- mei_hcsr_set(dev);
- dev->me_hw_state = mei_mecsr_read(dev);
- if ((dev->me_hw_state & ME_RDY_HRA) != ME_RDY_HRA)
- return -EIO;
-
- return 0;
-}
-
-/**
- * mei_count_full_read_slots - counts read full slots.
- *
- * @dev: the device structure
- *
- * returns -1(ESLOTS_OVERFLOW) if overflow, otherwise filled slots count
- */
-int mei_count_full_read_slots(struct mei_device *dev)
-{
- char read_ptr, write_ptr;
- unsigned char buffer_depth, filled_slots;
-
- dev->me_hw_state = mei_mecsr_read(dev);
- buffer_depth = (unsigned char)((dev->me_hw_state & ME_CBD_HRA) >> 24);
- read_ptr = (char) ((dev->me_hw_state & ME_CBRP_HRA) >> 8);
- write_ptr = (char) ((dev->me_hw_state & ME_CBWP_HRA) >> 16);
- filled_slots = (unsigned char) (write_ptr - read_ptr);
-
- /* check for overflow */
- if (filled_slots > buffer_depth)
- return -EOVERFLOW;
-
- dev_dbg(&dev->pdev->dev, "filled_slots =%08x\n", filled_slots);
- return (int)filled_slots;
-}
-
-/**
- * mei_read_slots - reads a message from mei device.
- *
- * @dev: the device structure
- * @buffer: message buffer will be written
- * @buffer_length: message size will be read
- */
-void mei_read_slots(struct mei_device *dev, unsigned char *buffer,
- unsigned long buffer_length)
-{
- u32 *reg_buf = (u32 *)buffer;
-
- for (; buffer_length >= sizeof(u32); buffer_length -= sizeof(u32))
- *reg_buf++ = mei_mecbrw_read(dev);
-
- if (buffer_length > 0) {
- u32 reg = mei_mecbrw_read(dev);
- memcpy(reg_buf, &reg, buffer_length);
- }
-
- dev->host_hw_state |= H_IG;
- mei_hcsr_set(dev);
-}
-
-/**
- * mei_flow_ctrl_creds - checks flow_control credentials.
- *
- * @dev: the device structure
- * @cl: private data of the file object
- *
- * returns 1 if mei_flow_ctrl_creds >0, 0 - otherwise.
- * -ENOENT if mei_cl is not present
- * -EINVAL if single_recv_buf == 0
- */
-int mei_flow_ctrl_creds(struct mei_device *dev, struct mei_cl *cl)
-{
- int i;
-
- if (!dev->me_clients_num)
- return 0;
-
- if (cl->mei_flow_ctrl_creds > 0)
- return 1;
-
- for (i = 0; i < dev->me_clients_num; i++) {
- struct mei_me_client *me_cl = &dev->me_clients[i];
- if (me_cl->client_id == cl->me_client_id) {
- if (me_cl->mei_flow_ctrl_creds) {
- if (WARN_ON(me_cl->props.single_recv_buf == 0))
- return -EINVAL;
- return 1;
- } else {
- return 0;
- }
- }
- }
- return -ENOENT;
-}
-
-/**
- * mei_flow_ctrl_reduce - reduces flow_control.
- *
- * @dev: the device structure
- * @cl: private data of the file object
- * @returns
- * 0 on success
- * -ENOENT when me client is not found
- * -EINVAL when ctrl credits are <= 0
- */
-int mei_flow_ctrl_reduce(struct mei_device *dev, struct mei_cl *cl)
-{
- int i;
-
- if (!dev->me_clients_num)
- return -ENOENT;
-
- for (i = 0; i < dev->me_clients_num; i++) {
- struct mei_me_client *me_cl = &dev->me_clients[i];
- if (me_cl->client_id == cl->me_client_id) {
- if (me_cl->props.single_recv_buf != 0) {
- if (WARN_ON(me_cl->mei_flow_ctrl_creds <= 0))
- return -EINVAL;
- dev->me_clients[i].mei_flow_ctrl_creds--;
- } else {
- if (WARN_ON(cl->mei_flow_ctrl_creds <= 0))
- return -EINVAL;
- cl->mei_flow_ctrl_creds--;
- }
- return 0;
- }
- }
- return -ENOENT;
-}
-
-/**
- * mei_send_flow_control - sends flow control to fw.
- *
- * @dev: the device structure
- * @cl: private data of the file object
- *
- * This function returns -EIO on write failure
- */
-int mei_send_flow_control(struct mei_device *dev, struct mei_cl *cl)
-{
- struct mei_msg_hdr *mei_hdr;
- struct hbm_flow_control *mei_flow_control;
-
- mei_hdr = (struct mei_msg_hdr *) &dev->wr_msg_buf[0];
- mei_hdr->host_addr = 0;
- mei_hdr->me_addr = 0;
- mei_hdr->length = sizeof(struct hbm_flow_control);
- mei_hdr->msg_complete = 1;
- mei_hdr->reserved = 0;
-
- mei_flow_control = (struct hbm_flow_control *) &dev->wr_msg_buf[1];
- memset(mei_flow_control, 0, sizeof(*mei_flow_control));
- mei_flow_control->host_addr = cl->host_client_id;
- mei_flow_control->me_addr = cl->me_client_id;
- mei_flow_control->hbm_cmd = MEI_FLOW_CONTROL_CMD;
- memset(mei_flow_control->reserved, 0,
- sizeof(mei_flow_control->reserved));
- dev_dbg(&dev->pdev->dev, "sending flow control host client = %d, ME client = %d\n",
- cl->host_client_id, cl->me_client_id);
-
- return mei_write_message(dev, mei_hdr,
- (unsigned char *) mei_flow_control,
- sizeof(struct hbm_flow_control));
-}
-
-/**
- * mei_other_client_is_connecting - checks if other
- * client with the same client id is connected.
- *
- * @dev: the device structure
- * @cl: private data of the file object
- *
- * returns 1 if other client is connected, 0 - otherwise.
- */
-int mei_other_client_is_connecting(struct mei_device *dev,
- struct mei_cl *cl)
-{
- struct mei_cl *cl_pos = NULL;
- struct mei_cl *cl_next = NULL;
-
- list_for_each_entry_safe(cl_pos, cl_next, &dev->file_list, link) {
- if ((cl_pos->state == MEI_FILE_CONNECTING) &&
- (cl_pos != cl) &&
- cl->me_client_id == cl_pos->me_client_id)
- return 1;
-
- }
- return 0;
-}
-
-/**
- * mei_disconnect - sends disconnect message to fw.
- *
- * @dev: the device structure
- * @cl: private data of the file object
- *
- * This function returns -EIO on write failure
- */
-int mei_disconnect(struct mei_device *dev, struct mei_cl *cl)
-{
- struct mei_msg_hdr *mei_hdr;
- struct hbm_client_disconnect_request *mei_cli_disconnect;
-
- mei_hdr = (struct mei_msg_hdr *) &dev->wr_msg_buf[0];
- mei_hdr->host_addr = 0;
- mei_hdr->me_addr = 0;
- mei_hdr->length = sizeof(struct hbm_client_disconnect_request);
- mei_hdr->msg_complete = 1;
- mei_hdr->reserved = 0;
-
- mei_cli_disconnect =
- (struct hbm_client_disconnect_request *) &dev->wr_msg_buf[1];
- memset(mei_cli_disconnect, 0, sizeof(*mei_cli_disconnect));
- mei_cli_disconnect->host_addr = cl->host_client_id;
- mei_cli_disconnect->me_addr = cl->me_client_id;
- mei_cli_disconnect->hbm_cmd = CLIENT_DISCONNECT_REQ_CMD;
- mei_cli_disconnect->reserved[0] = 0;
-
- return mei_write_message(dev, mei_hdr,
- (unsigned char *) mei_cli_disconnect,
- sizeof(struct hbm_client_disconnect_request));
-}
-
-/**
- * mei_connect - sends connect message to fw.
- *
- * @dev: the device structure
- * @cl: private data of the file object
- *
- * This function returns -EIO on write failure
- */
-int mei_connect(struct mei_device *dev, struct mei_cl *cl)
-{
- struct mei_msg_hdr *mei_hdr;
- struct hbm_client_connect_request *mei_cli_connect;
-
- mei_hdr = (struct mei_msg_hdr *) &dev->wr_msg_buf[0];
- mei_hdr->host_addr = 0;
- mei_hdr->me_addr = 0;
- mei_hdr->length = sizeof(struct hbm_client_connect_request);
- mei_hdr->msg_complete = 1;
- mei_hdr->reserved = 0;
-
- mei_cli_connect =
- (struct hbm_client_connect_request *) &dev->wr_msg_buf[1];
- mei_cli_connect->host_addr = cl->host_client_id;
- mei_cli_connect->me_addr = cl->me_client_id;
- mei_cli_connect->hbm_cmd = CLIENT_CONNECT_REQ_CMD;
- mei_cli_connect->reserved = 0;
-
- return mei_write_message(dev, mei_hdr,
- (unsigned char *) mei_cli_connect,
- sizeof(struct hbm_client_connect_request));
-}
diff --git a/drivers/staging/mei/interface.h b/drivers/staging/mei/interface.h
deleted file mode 100644
index fb90c6f8a759..000000000000
--- a/drivers/staging/mei/interface.h
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- *
- * Intel Management Engine Interface (Intel MEI) Linux driver
- * Copyright (c) 2003-2012, Intel Corporation.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms and conditions of the GNU General Public License,
- * version 2, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- */
-
-
-
-#ifndef _MEI_INTERFACE_H_
-#define _MEI_INTERFACE_H_
-
-#include "mei.h"
-#include "mei_dev.h"
-
-
-#define AMT_WD_DEFAULT_TIMEOUT 120 /* seconds */
-#define AMT_WD_MIN_TIMEOUT 120 /* seconds */
-#define AMT_WD_MAX_TIMEOUT 65535 /* seconds */
-
-#define MEI_WATCHDOG_DATA_SIZE 16
-#define MEI_START_WD_DATA_SIZE 20
-#define MEI_WD_PARAMS_SIZE 4
-
-
-void mei_read_slots(struct mei_device *dev,
- unsigned char *buffer,
- unsigned long buffer_length);
-
-int mei_write_message(struct mei_device *dev,
- struct mei_msg_hdr *header,
- unsigned char *write_buffer,
- unsigned long write_length);
-
-int mei_host_buffer_is_empty(struct mei_device *dev);
-
-int mei_count_full_read_slots(struct mei_device *dev);
-
-int mei_count_empty_write_slots(struct mei_device *dev);
-
-int mei_flow_ctrl_creds(struct mei_device *dev, struct mei_cl *cl);
-
-int mei_wd_send(struct mei_device *dev);
-int mei_wd_stop(struct mei_device *dev, bool preserve);
-bool mei_wd_host_init(struct mei_device *dev);
-void mei_wd_set_start_timeout(struct mei_device *dev, u16 timeout);
-/*
- * mei_watchdog_register - Registering watchdog interface
- * once we got connection to the WD Client
- * @dev - mei device
- */
-void mei_watchdog_register(struct mei_device *dev);
-/*
- * mei_watchdog_unregister - Unregistering watchdog interface
- * @dev - mei device
- */
-void mei_watchdog_unregister(struct mei_device *dev);
-
-int mei_flow_ctrl_reduce(struct mei_device *dev, struct mei_cl *cl);
-
-int mei_send_flow_control(struct mei_device *dev, struct mei_cl *cl);
-
-int mei_disconnect(struct mei_device *dev, struct mei_cl *cl);
-int mei_other_client_is_connecting(struct mei_device *dev, struct mei_cl *cl);
-int mei_connect(struct mei_device *dev, struct mei_cl *cl);
-
-#endif /* _MEI_INTERFACE_H_ */
diff --git a/drivers/staging/mei/interrupt.c b/drivers/staging/mei/interrupt.c
deleted file mode 100644
index 2007d2447b1c..000000000000
--- a/drivers/staging/mei/interrupt.c
+++ /dev/null
@@ -1,1590 +0,0 @@
-/*
- *
- * Intel Management Engine Interface (Intel MEI) Linux driver
- * Copyright (c) 2003-2012, Intel Corporation.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms and conditions of the GNU General Public License,
- * version 2, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- */
-
-
-#include <linux/pci.h>
-#include <linux/kthread.h>
-#include <linux/interrupt.h>
-#include <linux/fs.h>
-#include <linux/jiffies.h>
-
-#include "mei_dev.h"
-#include "mei.h"
-#include "hw.h"
-#include "interface.h"
-
-
-/**
- * mei_interrupt_quick_handler - The ISR of the MEI device
- *
- * @irq: The irq number
- * @dev_id: pointer to the device structure
- *
- * returns irqreturn_t
- */
-irqreturn_t mei_interrupt_quick_handler(int irq, void *dev_id)
-{
- struct mei_device *dev = (struct mei_device *) dev_id;
- u32 csr_reg = mei_hcsr_read(dev);
-
- if ((csr_reg & H_IS) != H_IS)
- return IRQ_NONE;
-
- /* clear H_IS bit in H_CSR */
- mei_reg_write(dev, H_CSR, csr_reg);
-
- return IRQ_WAKE_THREAD;
-}
-
-/**
- * _mei_cmpl - processes completed operation.
- *
- * @cl: private data of the file object.
- * @cb_pos: callback block.
- */
-static void _mei_cmpl(struct mei_cl *cl, struct mei_cl_cb *cb_pos)
-{
- if (cb_pos->major_file_operations == MEI_WRITE) {
- mei_free_cb_private(cb_pos);
- cb_pos = NULL;
- cl->writing_state = MEI_WRITE_COMPLETE;
- if (waitqueue_active(&cl->tx_wait))
- wake_up_interruptible(&cl->tx_wait);
-
- } else if (cb_pos->major_file_operations == MEI_READ &&
- MEI_READING == cl->reading_state) {
- cl->reading_state = MEI_READ_COMPLETE;
- if (waitqueue_active(&cl->rx_wait))
- wake_up_interruptible(&cl->rx_wait);
-
- }
-}
-
-/**
- * _mei_cmpl_iamthif - processes completed iamthif operation.
- *
- * @dev: the device structure.
- * @cb_pos: callback block.
- */
-static void _mei_cmpl_iamthif(struct mei_device *dev, struct mei_cl_cb *cb_pos)
-{
- if (dev->iamthif_canceled != 1) {
- dev->iamthif_state = MEI_IAMTHIF_READ_COMPLETE;
- dev->iamthif_stall_timer = 0;
- memcpy(cb_pos->response_buffer.data,
- dev->iamthif_msg_buf,
- dev->iamthif_msg_buf_index);
- list_add_tail(&cb_pos->cb_list,
- &dev->amthi_read_complete_list.mei_cb.cb_list);
- dev_dbg(&dev->pdev->dev, "amthi read completed.\n");
- dev->iamthif_timer = jiffies;
- dev_dbg(&dev->pdev->dev, "dev->iamthif_timer = %ld\n",
- dev->iamthif_timer);
- } else {
- mei_run_next_iamthif_cmd(dev);
- }
-
- dev_dbg(&dev->pdev->dev, "completing amthi call back.\n");
- wake_up_interruptible(&dev->iamthif_cl.wait);
-}
-
-
-/**
- * mei_irq_thread_read_amthi_message - bottom half read routine after ISR to
- * handle the read amthi message data processing.
- *
- * @complete_list: An instance of our list structure
- * @dev: the device structure
- * @mei_hdr: header of amthi message
- *
- * returns 0 on success, <0 on failure.
- */
-static int mei_irq_thread_read_amthi_message(struct mei_io_list *complete_list,
- struct mei_device *dev,
- struct mei_msg_hdr *mei_hdr)
-{
- struct mei_cl *cl;
- struct mei_cl_cb *cb;
- unsigned char *buffer;
-
- BUG_ON(mei_hdr->me_addr != dev->iamthif_cl.me_client_id);
- BUG_ON(dev->iamthif_state != MEI_IAMTHIF_READING);
-
- buffer = dev->iamthif_msg_buf + dev->iamthif_msg_buf_index;
- BUG_ON(dev->iamthif_mtu < dev->iamthif_msg_buf_index + mei_hdr->length);
-
- mei_read_slots(dev, buffer, mei_hdr->length);
-
- dev->iamthif_msg_buf_index += mei_hdr->length;
-
- if (!mei_hdr->msg_complete)
- return 0;
-
- dev_dbg(&dev->pdev->dev,
- "amthi_message_buffer_index =%d\n",
- mei_hdr->length);
-
- dev_dbg(&dev->pdev->dev, "completed amthi read.\n ");
- if (!dev->iamthif_current_cb)
- return -ENODEV;
-
- cb = dev->iamthif_current_cb;
- dev->iamthif_current_cb = NULL;
-
- cl = (struct mei_cl *)cb->file_private;
- if (!cl)
- return -ENODEV;
-
- dev->iamthif_stall_timer = 0;
- cb->information = dev->iamthif_msg_buf_index;
- cb->read_time = jiffies;
- if (dev->iamthif_ioctl && cl == &dev->iamthif_cl) {
- /* found the iamthif cb */
- dev_dbg(&dev->pdev->dev, "complete the amthi read cb.\n ");
- dev_dbg(&dev->pdev->dev, "add the amthi read cb to complete.\n ");
- list_add_tail(&cb->cb_list,
- &complete_list->mei_cb.cb_list);
- }
- return 0;
-}
-
-/**
- * _mei_irq_thread_state_ok - checks if mei header matches file private data
- *
- * @cl: private data of the file object
- * @mei_hdr: header of mei client message
- *
- * returns !=0 if matches, 0 if no match.
- */
-static int _mei_irq_thread_state_ok(struct mei_cl *cl,
- struct mei_msg_hdr *mei_hdr)
-{
- return (cl->host_client_id == mei_hdr->host_addr &&
- cl->me_client_id == mei_hdr->me_addr &&
- cl->state == MEI_FILE_CONNECTED &&
- MEI_READ_COMPLETE != cl->reading_state);
-}
-
-/**
- * mei_irq_thread_read_client_message - bottom half read routine after ISR to
- * handle the read mei client message data processing.
- *
- * @complete_list: An instance of our list structure
- * @dev: the device structure
- * @mei_hdr: header of mei client message
- *
- * returns 0 on success, <0 on failure.
- */
-static int mei_irq_thread_read_client_message(struct mei_io_list *complete_list,
- struct mei_device *dev,
- struct mei_msg_hdr *mei_hdr)
-{
- struct mei_cl *cl;
- struct mei_cl_cb *cb_pos = NULL, *cb_next = NULL;
- unsigned char *buffer = NULL;
-
- dev_dbg(&dev->pdev->dev, "start client msg\n");
- if (list_empty(&dev->read_list.mei_cb.cb_list))
- goto quit;
-
- list_for_each_entry_safe(cb_pos, cb_next,
- &dev->read_list.mei_cb.cb_list, cb_list) {
- cl = (struct mei_cl *)cb_pos->file_private;
- if (cl && _mei_irq_thread_state_ok(cl, mei_hdr)) {
- cl->reading_state = MEI_READING;
- buffer = cb_pos->response_buffer.data + cb_pos->information;
-
- if (cb_pos->response_buffer.size <
- mei_hdr->length + cb_pos->information) {
- dev_dbg(&dev->pdev->dev, "message overflow.\n");
- list_del(&cb_pos->cb_list);
- return -ENOMEM;
- }
- if (buffer)
- mei_read_slots(dev, buffer, mei_hdr->length);
-
- cb_pos->information += mei_hdr->length;
- if (mei_hdr->msg_complete) {
- cl->status = 0;
- list_del(&cb_pos->cb_list);
- dev_dbg(&dev->pdev->dev,
- "completed read host client = %d,"
- "ME client = %d, "
- "data length = %lu\n",
- cl->host_client_id,
- cl->me_client_id,
- cb_pos->information);
-
- *(cb_pos->response_buffer.data +
- cb_pos->information) = '\0';
- dev_dbg(&dev->pdev->dev, "cb_pos->res_buffer - %s\n",
- cb_pos->response_buffer.data);
- list_add_tail(&cb_pos->cb_list,
- &complete_list->mei_cb.cb_list);
- }
-
- break;
- }
-
- }
-
-quit:
- dev_dbg(&dev->pdev->dev, "message read\n");
- if (!buffer) {
- mei_read_slots(dev, dev->rd_msg_buf, mei_hdr->length);
- dev_dbg(&dev->pdev->dev, "discarding message, header =%08x.\n",
- *(u32 *) dev->rd_msg_buf);
- }
-
- return 0;
-}
-
-/**
- * _mei_irq_thread_iamthif_read - prepares to read iamthif data.
- *
- * @dev: the device structure.
- * @slots: free slots.
- *
- * returns 0, OK; otherwise, error.
- */
-static int _mei_irq_thread_iamthif_read(struct mei_device *dev, s32 *slots)
-{
-
- if (((*slots) * sizeof(u32)) < (sizeof(struct mei_msg_hdr)
- + sizeof(struct hbm_flow_control))) {
- return -EMSGSIZE;
- }
- *slots -= (sizeof(struct mei_msg_hdr) +
- sizeof(struct hbm_flow_control) + 3) / 4;
- if (mei_send_flow_control(dev, &dev->iamthif_cl)) {
- dev_dbg(&dev->pdev->dev, "iamthif flow control failed\n");
- return -EIO;
- }
-
- dev_dbg(&dev->pdev->dev, "iamthif flow control success\n");
- dev->iamthif_state = MEI_IAMTHIF_READING;
- dev->iamthif_flow_control_pending = false;
- dev->iamthif_msg_buf_index = 0;
- dev->iamthif_msg_buf_size = 0;
- dev->iamthif_stall_timer = IAMTHIF_STALL_TIMER;
- dev->mei_host_buffer_is_empty = mei_host_buffer_is_empty(dev);
- return 0;
-}
-
-/**
- * _mei_irq_thread_close - processes close related operation.
- *
- * @dev: the device structure.
- * @slots: free slots.
- * @cb_pos: callback block.
- * @cl: private data of the file object.
- * @cmpl_list: complete list.
- *
- * returns 0, OK; otherwise, error.
- */
-static int _mei_irq_thread_close(struct mei_device *dev, s32 *slots,
- struct mei_cl_cb *cb_pos,
- struct mei_cl *cl,
- struct mei_io_list *cmpl_list)
-{
- if ((*slots * sizeof(u32)) >= (sizeof(struct mei_msg_hdr) +
- sizeof(struct hbm_client_disconnect_request))) {
- *slots -= (sizeof(struct mei_msg_hdr) +
- sizeof(struct hbm_client_disconnect_request) + 3) / 4;
-
- if (mei_disconnect(dev, cl)) {
- cl->status = 0;
- cb_pos->information = 0;
- list_move_tail(&cb_pos->cb_list,
- &cmpl_list->mei_cb.cb_list);
- return -EMSGSIZE;
- } else {
- cl->state = MEI_FILE_DISCONNECTING;
- cl->status = 0;
- cb_pos->information = 0;
- list_move_tail(&cb_pos->cb_list,
- &dev->ctrl_rd_list.mei_cb.cb_list);
- cl->timer_count = MEI_CONNECT_TIMEOUT;
- }
- } else {
- /* return the cancel routine */
- return -EBADMSG;
- }
-
- return 0;
-}
-
-/**
- * is_treat_specially_client - checks if the message belongs
- * to the file private data.
- *
- * @cl: private data of the file object
- * @rs: connect response bus message
- *
- */
-static bool is_treat_specially_client(struct mei_cl *cl,
- struct hbm_client_connect_response *rs)
-{
-
- if (cl->host_client_id == rs->host_addr &&
- cl->me_client_id == rs->me_addr) {
- if (!rs->status) {
- cl->state = MEI_FILE_CONNECTED;
- cl->status = 0;
-
- } else {
- cl->state = MEI_FILE_DISCONNECTED;
- cl->status = -ENODEV;
- }
- cl->timer_count = 0;
-
- return true;
- }
- return false;
-}
-
-/**
- * mei_client_connect_response - connects to response irq routine
- *
- * @dev: the device structure
- * @rs: connect response bus message
- */
-static void mei_client_connect_response(struct mei_device *dev,
- struct hbm_client_connect_response *rs)
-{
-
- struct mei_cl *cl;
- struct mei_cl_cb *cb_pos = NULL, *cb_next = NULL;
-
- dev_dbg(&dev->pdev->dev,
- "connect_response:\n"
- "ME Client = %d\n"
- "Host Client = %d\n"
- "Status = %d\n",
- rs->me_addr,
- rs->host_addr,
- rs->status);
-
- /* if WD or iamthif client treat specially */
-
- if (is_treat_specially_client(&(dev->wd_cl), rs)) {
- dev_dbg(&dev->pdev->dev, "successfully connected to WD client.\n");
- mei_watchdog_register(dev);
-
- /* next step in the state maching */
- mei_host_init_iamthif(dev);
- return;
- }
-
- if (is_treat_specially_client(&(dev->iamthif_cl), rs)) {
- dev->iamthif_state = MEI_IAMTHIF_IDLE;
- return;
- }
- list_for_each_entry_safe(cb_pos, cb_next,
- &dev->ctrl_rd_list.mei_cb.cb_list, cb_list) {
-
- cl = (struct mei_cl *)cb_pos->file_private;
- if (!cl) {
- list_del(&cb_pos->cb_list);
- return;
- }
- if (MEI_IOCTL == cb_pos->major_file_operations) {
- if (is_treat_specially_client(cl, rs)) {
- list_del(&cb_pos->cb_list);
- cl->status = 0;
- cl->timer_count = 0;
- break;
- }
- }
- }
-}
-
-/**
- * mei_client_disconnect_response - disconnects from response irq routine
- *
- * @dev: the device structure
- * @rs: disconnect response bus message
- */
-static void mei_client_disconnect_response(struct mei_device *dev,
- struct hbm_client_connect_response *rs)
-{
- struct mei_cl *cl;
- struct mei_cl_cb *cb_pos = NULL, *cb_next = NULL;
-
- dev_dbg(&dev->pdev->dev,
- "disconnect_response:\n"
- "ME Client = %d\n"
- "Host Client = %d\n"
- "Status = %d\n",
- rs->me_addr,
- rs->host_addr,
- rs->status);
-
- list_for_each_entry_safe(cb_pos, cb_next,
- &dev->ctrl_rd_list.mei_cb.cb_list, cb_list) {
- cl = (struct mei_cl *)cb_pos->file_private;
-
- if (!cl) {
- list_del(&cb_pos->cb_list);
- return;
- }
-
- dev_dbg(&dev->pdev->dev, "list_for_each_entry_safe in ctrl_rd_list.\n");
- if (cl->host_client_id == rs->host_addr &&
- cl->me_client_id == rs->me_addr) {
-
- list_del(&cb_pos->cb_list);
- if (!rs->status)
- cl->state = MEI_FILE_DISCONNECTED;
-
- cl->status = 0;
- cl->timer_count = 0;
- break;
- }
- }
-}
-
-/**
- * same_flow_addr - tells if they have the same address.
- *
- * @file: private data of the file object.
- * @flow: flow control.
- *
- * returns !=0, same; 0,not.
- */
-static int same_flow_addr(struct mei_cl *cl, struct hbm_flow_control *flow)
-{
- return (cl->host_client_id == flow->host_addr &&
- cl->me_client_id == flow->me_addr);
-}
-
-/**
- * add_single_flow_creds - adds single buffer credentials.
- *
- * @file: private data ot the file object.
- * @flow: flow control.
- */
-static void add_single_flow_creds(struct mei_device *dev,
- struct hbm_flow_control *flow)
-{
- struct mei_me_client *client;
- int i;
-
- for (i = 0; i < dev->me_clients_num; i++) {
- client = &dev->me_clients[i];
- if (client && flow->me_addr == client->client_id) {
- if (client->props.single_recv_buf) {
- client->mei_flow_ctrl_creds++;
- dev_dbg(&dev->pdev->dev, "recv flow ctrl msg ME %d (single).\n",
- flow->me_addr);
- dev_dbg(&dev->pdev->dev, "flow control credentials =%d.\n",
- client->mei_flow_ctrl_creds);
- } else {
- BUG(); /* error in flow control */
- }
- }
- }
-}
-
-/**
- * mei_client_flow_control_response - flow control response irq routine
- *
- * @dev: the device structure
- * @flow_control: flow control response bus message
- */
-static void mei_client_flow_control_response(struct mei_device *dev,
- struct hbm_flow_control *flow_control)
-{
- struct mei_cl *cl_pos = NULL;
- struct mei_cl *cl_next = NULL;
-
- if (!flow_control->host_addr) {
- /* single receive buffer */
- add_single_flow_creds(dev, flow_control);
- } else {
- /* normal connection */
- list_for_each_entry_safe(cl_pos, cl_next,
- &dev->file_list, link) {
- dev_dbg(&dev->pdev->dev, "list_for_each_entry_safe in file_list\n");
-
- dev_dbg(&dev->pdev->dev, "cl of host client %d ME client %d.\n",
- cl_pos->host_client_id,
- cl_pos->me_client_id);
- dev_dbg(&dev->pdev->dev, "flow ctrl msg for host %d ME %d.\n",
- flow_control->host_addr,
- flow_control->me_addr);
- if (same_flow_addr(cl_pos, flow_control)) {
- dev_dbg(&dev->pdev->dev, "recv ctrl msg for host %d ME %d.\n",
- flow_control->host_addr,
- flow_control->me_addr);
- cl_pos->mei_flow_ctrl_creds++;
- dev_dbg(&dev->pdev->dev, "flow control credentials = %d.\n",
- cl_pos->mei_flow_ctrl_creds);
- break;
- }
- }
- }
-}
-
-/**
- * same_disconn_addr - tells if they have the same address
- *
- * @file: private data of the file object.
- * @disconn: disconnection request.
- *
- * returns !=0, same; 0,not.
- */
-static int same_disconn_addr(struct mei_cl *cl,
- struct hbm_client_disconnect_request *disconn)
-{
- return (cl->host_client_id == disconn->host_addr &&
- cl->me_client_id == disconn->me_addr);
-}
-
-/**
- * mei_client_disconnect_request - disconnects from request irq routine
- *
- * @dev: the device structure.
- * @disconnect_req: disconnect request bus message.
- */
-static void mei_client_disconnect_request(struct mei_device *dev,
- struct hbm_client_disconnect_request *disconnect_req)
-{
- struct mei_msg_hdr *mei_hdr;
- struct hbm_client_connect_response *disconnect_res;
- struct mei_cl *cl_pos = NULL;
- struct mei_cl *cl_next = NULL;
-
- list_for_each_entry_safe(cl_pos, cl_next, &dev->file_list, link) {
- if (same_disconn_addr(cl_pos, disconnect_req)) {
- dev_dbg(&dev->pdev->dev, "disconnect request host client %d ME client %d.\n",
- disconnect_req->host_addr,
- disconnect_req->me_addr);
- cl_pos->state = MEI_FILE_DISCONNECTED;
- cl_pos->timer_count = 0;
- if (cl_pos == &dev->wd_cl) {
- dev->wd_due_counter = 0;
- dev->wd_pending = false;
- } else if (cl_pos == &dev->iamthif_cl)
- dev->iamthif_timer = 0;
-
- /* prepare disconnect response */
- mei_hdr =
- (struct mei_msg_hdr *) &dev->ext_msg_buf[0];
- mei_hdr->host_addr = 0;
- mei_hdr->me_addr = 0;
- mei_hdr->length =
- sizeof(struct hbm_client_connect_response);
- mei_hdr->msg_complete = 1;
- mei_hdr->reserved = 0;
-
- disconnect_res =
- (struct hbm_client_connect_response *)
- &dev->ext_msg_buf[1];
- disconnect_res->host_addr = cl_pos->host_client_id;
- disconnect_res->me_addr = cl_pos->me_client_id;
- disconnect_res->hbm_cmd = CLIENT_DISCONNECT_RES_CMD;
- disconnect_res->status = 0;
- dev->extra_write_index = 2;
- break;
- }
- }
-}
-
-
-/**
- * mei_irq_thread_read_bus_message - bottom half read routine after ISR to
- * handle the read bus message cmd processing.
- *
- * @dev: the device structure
- * @mei_hdr: header of bus message
- */
-static void mei_irq_thread_read_bus_message(struct mei_device *dev,
- struct mei_msg_hdr *mei_hdr)
-{
- struct mei_bus_message *mei_msg;
- struct hbm_host_version_response *version_res;
- struct hbm_client_connect_response *connect_res;
- struct hbm_client_connect_response *disconnect_res;
- struct hbm_flow_control *flow_control;
- struct hbm_props_response *props_res;
- struct hbm_host_enum_response *enum_res;
- struct hbm_client_disconnect_request *disconnect_req;
- struct hbm_host_stop_request *host_stop_req;
- int res;
-
-
- /* read the message to our buffer */
- BUG_ON(mei_hdr->length >= sizeof(dev->rd_msg_buf));
- mei_read_slots(dev, dev->rd_msg_buf, mei_hdr->length);
- mei_msg = (struct mei_bus_message *)dev->rd_msg_buf;
-
- switch (mei_msg->hbm_cmd) {
- case HOST_START_RES_CMD:
- version_res = (struct hbm_host_version_response *) mei_msg;
- if (version_res->host_version_supported) {
- dev->version.major_version = HBM_MAJOR_VERSION;
- dev->version.minor_version = HBM_MINOR_VERSION;
- if (dev->mei_state == MEI_INIT_CLIENTS &&
- dev->init_clients_state == MEI_START_MESSAGE) {
- dev->init_clients_timer = 0;
- mei_host_enum_clients_message(dev);
- } else {
- dev->recvd_msg = false;
- dev_dbg(&dev->pdev->dev, "IMEI reset due to received host start response bus message.\n");
- mei_reset(dev, 1);
- return;
- }
- } else {
- dev->version = version_res->me_max_version;
- /* send stop message */
- mei_hdr = (struct mei_msg_hdr *)&dev->wr_msg_buf[0];
- mei_hdr->host_addr = 0;
- mei_hdr->me_addr = 0;
- mei_hdr->length = sizeof(struct hbm_host_stop_request);
- mei_hdr->msg_complete = 1;
- mei_hdr->reserved = 0;
-
- host_stop_req = (struct hbm_host_stop_request *)
- &dev->wr_msg_buf[1];
-
- memset(host_stop_req,
- 0,
- sizeof(struct hbm_host_stop_request));
- host_stop_req->hbm_cmd = HOST_STOP_REQ_CMD;
- host_stop_req->reason = DRIVER_STOP_REQUEST;
- mei_write_message(dev, mei_hdr,
- (unsigned char *) (host_stop_req),
- mei_hdr->length);
- dev_dbg(&dev->pdev->dev, "version mismatch.\n");
- return;
- }
-
- dev->recvd_msg = true;
- dev_dbg(&dev->pdev->dev, "host start response message received.\n");
- break;
-
- case CLIENT_CONNECT_RES_CMD:
- connect_res =
- (struct hbm_client_connect_response *) mei_msg;
- mei_client_connect_response(dev, connect_res);
- dev_dbg(&dev->pdev->dev, "client connect response message received.\n");
- wake_up(&dev->wait_recvd_msg);
- break;
-
- case CLIENT_DISCONNECT_RES_CMD:
- disconnect_res =
- (struct hbm_client_connect_response *) mei_msg;
- mei_client_disconnect_response(dev, disconnect_res);
- dev_dbg(&dev->pdev->dev, "client disconnect response message received.\n");
- wake_up(&dev->wait_recvd_msg);
- break;
-
- case MEI_FLOW_CONTROL_CMD:
- flow_control = (struct hbm_flow_control *) mei_msg;
- mei_client_flow_control_response(dev, flow_control);
- dev_dbg(&dev->pdev->dev, "client flow control response message received.\n");
- break;
-
- case HOST_CLIENT_PROPERTIES_RES_CMD:
- props_res = (struct hbm_props_response *)mei_msg;
- if (props_res->status || !dev->me_clients) {
- dev_dbg(&dev->pdev->dev, "reset due to received host client properties response bus message wrong status.\n");
- mei_reset(dev, 1);
- return;
- }
- if (dev->me_clients[dev->me_client_presentation_num]
- .client_id == props_res->address) {
-
- dev->me_clients[dev->me_client_presentation_num].props
- = props_res->client_properties;
-
- if (dev->mei_state == MEI_INIT_CLIENTS &&
- dev->init_clients_state ==
- MEI_CLIENT_PROPERTIES_MESSAGE) {
- dev->me_client_index++;
- dev->me_client_presentation_num++;
-
- /** Send Client Properties request **/
- res = mei_host_client_properties(dev);
- if (res < 0) {
- dev_dbg(&dev->pdev->dev, "mei_host_client_properties() failed");
- return;
- } else if (!res) {
- /*
- * No more clients to send to.
- * Clear Map for indicating now ME clients
- * with associated host client
- */
- bitmap_zero(dev->host_clients_map, MEI_CLIENTS_MAX);
- dev->open_handle_count = 0;
-
- /*
- * Reserving the first three client IDs
- * Client Id 0 - Reserved for MEI Bus Message communications
- * Client Id 1 - Reserved for Watchdog
- * Client ID 2 - Reserved for AMTHI
- */
- bitmap_set(dev->host_clients_map, 0, 3);
- dev->mei_state = MEI_ENABLED;
-
- /* if wd initialization fails, initialization the AMTHI client,
- * otherwise the AMTHI client will be initialized after the WD client connect response
- * will be received
- */
- if (mei_wd_host_init(dev))
- mei_host_init_iamthif(dev);
- }
-
- } else {
- dev_dbg(&dev->pdev->dev, "reset due to received host client properties response bus message");
- mei_reset(dev, 1);
- return;
- }
- } else {
- dev_dbg(&dev->pdev->dev, "reset due to received host client properties response bus message for wrong client ID\n");
- mei_reset(dev, 1);
- return;
- }
- break;
-
- case HOST_ENUM_RES_CMD:
- enum_res = (struct hbm_host_enum_response *) mei_msg;
- memcpy(dev->me_clients_map, enum_res->valid_addresses, 32);
- if (dev->mei_state == MEI_INIT_CLIENTS &&
- dev->init_clients_state == MEI_ENUM_CLIENTS_MESSAGE) {
- dev->init_clients_timer = 0;
- dev->me_client_presentation_num = 0;
- dev->me_client_index = 0;
- mei_allocate_me_clients_storage(dev);
- dev->init_clients_state =
- MEI_CLIENT_PROPERTIES_MESSAGE;
- mei_host_client_properties(dev);
- } else {
- dev_dbg(&dev->pdev->dev, "reset due to received host enumeration clients response bus message.\n");
- mei_reset(dev, 1);
- return;
- }
- break;
-
- case HOST_STOP_RES_CMD:
- dev->mei_state = MEI_DISABLED;
- dev_dbg(&dev->pdev->dev, "resetting because of FW stop response.\n");
- mei_reset(dev, 1);
- break;
-
- case CLIENT_DISCONNECT_REQ_CMD:
- /* search for client */
- disconnect_req =
- (struct hbm_client_disconnect_request *) mei_msg;
- mei_client_disconnect_request(dev, disconnect_req);
- break;
-
- case ME_STOP_REQ_CMD:
- /* prepare stop request */
- mei_hdr = (struct mei_msg_hdr *) &dev->ext_msg_buf[0];
- mei_hdr->host_addr = 0;
- mei_hdr->me_addr = 0;
- mei_hdr->length = sizeof(struct hbm_host_stop_request);
- mei_hdr->msg_complete = 1;
- mei_hdr->reserved = 0;
- host_stop_req =
- (struct hbm_host_stop_request *) &dev->ext_msg_buf[1];
- memset(host_stop_req, 0, sizeof(struct hbm_host_stop_request));
- host_stop_req->hbm_cmd = HOST_STOP_REQ_CMD;
- host_stop_req->reason = DRIVER_STOP_REQUEST;
- host_stop_req->reserved[0] = 0;
- host_stop_req->reserved[1] = 0;
- dev->extra_write_index = 2;
- break;
-
- default:
- BUG();
- break;
-
- }
-}
-
-
-/**
- * _mei_hb_read - processes read related operation.
- *
- * @dev: the device structure.
- * @slots: free slots.
- * @cb_pos: callback block.
- * @cl: private data of the file object.
- * @cmpl_list: complete list.
- *
- * returns 0, OK; otherwise, error.
- */
-static int _mei_irq_thread_read(struct mei_device *dev, s32 *slots,
- struct mei_cl_cb *cb_pos,
- struct mei_cl *cl,
- struct mei_io_list *cmpl_list)
-{
- if ((*slots * sizeof(u32)) >= (sizeof(struct mei_msg_hdr) +
- sizeof(struct hbm_flow_control))) {
- /* return the cancel routine */
- list_del(&cb_pos->cb_list);
- return -EBADMSG;
- }
-
- *slots -= (sizeof(struct mei_msg_hdr) +
- sizeof(struct hbm_flow_control) + 3) / 4;
- if (mei_send_flow_control(dev, cl)) {
- cl->status = -ENODEV;
- cb_pos->information = 0;
- list_move_tail(&cb_pos->cb_list, &cmpl_list->mei_cb.cb_list);
- return -ENODEV;
- }
- list_move_tail(&cb_pos->cb_list, &dev->read_list.mei_cb.cb_list);
-
- return 0;
-}
-
-
-/**
- * _mei_irq_thread_ioctl - processes ioctl related operation.
- *
- * @dev: the device structure.
- * @slots: free slots.
- * @cb_pos: callback block.
- * @cl: private data of the file object.
- * @cmpl_list: complete list.
- *
- * returns 0, OK; otherwise, error.
- */
-static int _mei_irq_thread_ioctl(struct mei_device *dev, s32 *slots,
- struct mei_cl_cb *cb_pos,
- struct mei_cl *cl,
- struct mei_io_list *cmpl_list)
-{
- if ((*slots * sizeof(u32)) >= (sizeof(struct mei_msg_hdr) +
- sizeof(struct hbm_client_connect_request))) {
- cl->state = MEI_FILE_CONNECTING;
- *slots -= (sizeof(struct mei_msg_hdr) +
- sizeof(struct hbm_client_connect_request) + 3) / 4;
- if (mei_connect(dev, cl)) {
- cl->status = -ENODEV;
- cb_pos->information = 0;
- list_del(&cb_pos->cb_list);
- return -ENODEV;
- } else {
- list_move_tail(&cb_pos->cb_list,
- &dev->ctrl_rd_list.mei_cb.cb_list);
- cl->timer_count = MEI_CONNECT_TIMEOUT;
- }
- } else {
- /* return the cancel routine */
- list_del(&cb_pos->cb_list);
- return -EBADMSG;
- }
-
- return 0;
-}
-
-/**
- * _mei_irq_thread_cmpl - processes completed and no-iamthif operation.
- *
- * @dev: the device structure.
- * @slots: free slots.
- * @cb_pos: callback block.
- * @cl: private data of the file object.
- * @cmpl_list: complete list.
- *
- * returns 0, OK; otherwise, error.
- */
-static int _mei_irq_thread_cmpl(struct mei_device *dev, s32 *slots,
- struct mei_cl_cb *cb_pos,
- struct mei_cl *cl,
- struct mei_io_list *cmpl_list)
-{
- struct mei_msg_hdr *mei_hdr;
-
- if ((*slots * sizeof(u32)) >= (sizeof(struct mei_msg_hdr) +
- (cb_pos->request_buffer.size -
- cb_pos->information))) {
- mei_hdr = (struct mei_msg_hdr *) &dev->wr_msg_buf[0];
- mei_hdr->host_addr = cl->host_client_id;
- mei_hdr->me_addr = cl->me_client_id;
- mei_hdr->length = cb_pos->request_buffer.size -
- cb_pos->information;
- mei_hdr->msg_complete = 1;
- mei_hdr->reserved = 0;
- dev_dbg(&dev->pdev->dev, "cb_pos->request_buffer.size =%d"
- "mei_hdr->msg_complete = %d\n",
- cb_pos->request_buffer.size,
- mei_hdr->msg_complete);
- dev_dbg(&dev->pdev->dev, "cb_pos->information =%lu\n",
- cb_pos->information);
- dev_dbg(&dev->pdev->dev, "mei_hdr->length =%d\n",
- mei_hdr->length);
- *slots -= (sizeof(struct mei_msg_hdr) +
- mei_hdr->length + 3) / 4;
- if (mei_write_message(dev, mei_hdr,
- (unsigned char *)
- (cb_pos->request_buffer.data +
- cb_pos->information),
- mei_hdr->length)) {
- cl->status = -ENODEV;
- list_move_tail(&cb_pos->cb_list,
- &cmpl_list->mei_cb.cb_list);
- return -ENODEV;
- } else {
- if (mei_flow_ctrl_reduce(dev, cl))
- return -ENODEV;
- cl->status = 0;
- cb_pos->information += mei_hdr->length;
- list_move_tail(&cb_pos->cb_list,
- &dev->write_waiting_list.mei_cb.cb_list);
- }
- } else if (*slots == ((dev->host_hw_state & H_CBD) >> 24)) {
- /* buffer is still empty */
- mei_hdr = (struct mei_msg_hdr *) &dev->wr_msg_buf[0];
- mei_hdr->host_addr = cl->host_client_id;
- mei_hdr->me_addr = cl->me_client_id;
- mei_hdr->length =
- (*slots * sizeof(u32)) - sizeof(struct mei_msg_hdr);
- mei_hdr->msg_complete = 0;
- mei_hdr->reserved = 0;
-
- (*slots) -= (sizeof(struct mei_msg_hdr) +
- mei_hdr->length + 3) / 4;
- if (mei_write_message(dev, mei_hdr,
- (unsigned char *)
- (cb_pos->request_buffer.data +
- cb_pos->information),
- mei_hdr->length)) {
- cl->status = -ENODEV;
- list_move_tail(&cb_pos->cb_list,
- &cmpl_list->mei_cb.cb_list);
- return -ENODEV;
- } else {
- cb_pos->information += mei_hdr->length;
- dev_dbg(&dev->pdev->dev,
- "cb_pos->request_buffer.size =%d"
- " mei_hdr->msg_complete = %d\n",
- cb_pos->request_buffer.size,
- mei_hdr->msg_complete);
- dev_dbg(&dev->pdev->dev, "cb_pos->information =%lu\n",
- cb_pos->information);
- dev_dbg(&dev->pdev->dev, "mei_hdr->length =%d\n",
- mei_hdr->length);
- }
- return -EMSGSIZE;
- } else {
- return -EBADMSG;
- }
-
- return 0;
-}
-
-/**
- * _mei_irq_thread_cmpl_iamthif - processes completed iamthif operation.
- *
- * @dev: the device structure.
- * @slots: free slots.
- * @cb_pos: callback block.
- * @cl: private data of the file object.
- * @cmpl_list: complete list.
- *
- * returns 0, OK; otherwise, error.
- */
-static int _mei_irq_thread_cmpl_iamthif(struct mei_device *dev, s32 *slots,
- struct mei_cl_cb *cb_pos,
- struct mei_cl *cl,
- struct mei_io_list *cmpl_list)
-{
- struct mei_msg_hdr *mei_hdr;
-
- if ((*slots * sizeof(u32)) >= (sizeof(struct mei_msg_hdr) +
- dev->iamthif_msg_buf_size -
- dev->iamthif_msg_buf_index)) {
- mei_hdr = (struct mei_msg_hdr *) &dev->wr_msg_buf[0];
- mei_hdr->host_addr = cl->host_client_id;
- mei_hdr->me_addr = cl->me_client_id;
- mei_hdr->length = dev->iamthif_msg_buf_size -
- dev->iamthif_msg_buf_index;
- mei_hdr->msg_complete = 1;
- mei_hdr->reserved = 0;
-
- *slots -= (sizeof(struct mei_msg_hdr) +
- mei_hdr->length + 3) / 4;
-
- if (mei_write_message(dev, mei_hdr,
- (dev->iamthif_msg_buf +
- dev->iamthif_msg_buf_index),
- mei_hdr->length)) {
- dev->iamthif_state = MEI_IAMTHIF_IDLE;
- cl->status = -ENODEV;
- list_del(&cb_pos->cb_list);
- return -ENODEV;
- } else {
- if (mei_flow_ctrl_reduce(dev, cl))
- return -ENODEV;
- dev->iamthif_msg_buf_index += mei_hdr->length;
- cb_pos->information = dev->iamthif_msg_buf_index;
- cl->status = 0;
- dev->iamthif_state = MEI_IAMTHIF_FLOW_CONTROL;
- dev->iamthif_flow_control_pending = true;
- /* save iamthif cb sent to amthi client */
- dev->iamthif_current_cb = cb_pos;
- list_move_tail(&cb_pos->cb_list,
- &dev->write_waiting_list.mei_cb.cb_list);
-
- }
- } else if (*slots == ((dev->host_hw_state & H_CBD) >> 24)) {
- /* buffer is still empty */
- mei_hdr = (struct mei_msg_hdr *) &dev->wr_msg_buf[0];
- mei_hdr->host_addr = cl->host_client_id;
- mei_hdr->me_addr = cl->me_client_id;
- mei_hdr->length =
- (*slots * sizeof(u32)) - sizeof(struct mei_msg_hdr);
- mei_hdr->msg_complete = 0;
- mei_hdr->reserved = 0;
-
- *slots -= (sizeof(struct mei_msg_hdr) +
- mei_hdr->length + 3) / 4;
-
- if (mei_write_message(dev, mei_hdr,
- (dev->iamthif_msg_buf +
- dev->iamthif_msg_buf_index),
- mei_hdr->length)) {
- cl->status = -ENODEV;
- list_del(&cb_pos->cb_list);
- } else {
- dev->iamthif_msg_buf_index += mei_hdr->length;
- }
- return -EMSGSIZE;
- } else {
- return -EBADMSG;
- }
-
- return 0;
-}
-
-/**
- * mei_irq_thread_read_handler - bottom half read routine after ISR to
- * handle the read processing.
- *
- * @cmpl_list: An instance of our list structure
- * @dev: the device structure
- * @slots: slots to read.
- *
- * returns 0 on success, <0 on failure.
- */
-static int mei_irq_thread_read_handler(struct mei_io_list *cmpl_list,
- struct mei_device *dev,
- s32 *slots)
-{
- struct mei_msg_hdr *mei_hdr;
- struct mei_cl *cl_pos = NULL;
- struct mei_cl *cl_next = NULL;
- int ret = 0;
-
- if (!dev->rd_msg_hdr) {
- dev->rd_msg_hdr = mei_mecbrw_read(dev);
- dev_dbg(&dev->pdev->dev, "slots =%08x.\n", *slots);
- (*slots)--;
- dev_dbg(&dev->pdev->dev, "slots =%08x.\n", *slots);
- }
- mei_hdr = (struct mei_msg_hdr *) &dev->rd_msg_hdr;
- dev_dbg(&dev->pdev->dev, "mei_hdr->length =%d\n", mei_hdr->length);
-
- if (mei_hdr->reserved || !dev->rd_msg_hdr) {
- dev_dbg(&dev->pdev->dev, "corrupted message header.\n");
- ret = -EBADMSG;
- goto end;
- }
-
- if (mei_hdr->host_addr || mei_hdr->me_addr) {
- list_for_each_entry_safe(cl_pos, cl_next,
- &dev->file_list, link) {
- dev_dbg(&dev->pdev->dev,
- "list_for_each_entry_safe read host"
- " client = %d, ME client = %d\n",
- cl_pos->host_client_id,
- cl_pos->me_client_id);
- if (cl_pos->host_client_id == mei_hdr->host_addr &&
- cl_pos->me_client_id == mei_hdr->me_addr)
- break;
- }
-
- if (&cl_pos->link == &dev->file_list) {
- dev_dbg(&dev->pdev->dev, "corrupted message header\n");
- ret = -EBADMSG;
- goto end;
- }
- }
- if (((*slots) * sizeof(u32)) < mei_hdr->length) {
- dev_dbg(&dev->pdev->dev,
- "we can't read the message slots =%08x.\n",
- *slots);
- /* we can't read the message */
- ret = -ERANGE;
- goto end;
- }
-
- /* decide where to read the message too */
- if (!mei_hdr->host_addr) {
- dev_dbg(&dev->pdev->dev, "call mei_irq_thread_read_bus_message.\n");
- mei_irq_thread_read_bus_message(dev, mei_hdr);
- dev_dbg(&dev->pdev->dev, "end mei_irq_thread_read_bus_message.\n");
- } else if (mei_hdr->host_addr == dev->iamthif_cl.host_client_id &&
- (MEI_FILE_CONNECTED == dev->iamthif_cl.state) &&
- (dev->iamthif_state == MEI_IAMTHIF_READING)) {
- dev_dbg(&dev->pdev->dev, "call mei_irq_thread_read_iamthif_message.\n");
- dev_dbg(&dev->pdev->dev, "mei_hdr->length =%d\n",
- mei_hdr->length);
- ret = mei_irq_thread_read_amthi_message(cmpl_list,
- dev, mei_hdr);
- if (ret)
- goto end;
-
- } else {
- dev_dbg(&dev->pdev->dev, "call mei_irq_thread_read_client_message.\n");
- ret = mei_irq_thread_read_client_message(cmpl_list,
- dev, mei_hdr);
- if (ret)
- goto end;
-
- }
-
- /* reset the number of slots and header */
- *slots = mei_count_full_read_slots(dev);
- dev->rd_msg_hdr = 0;
-
- if (*slots == -EOVERFLOW) {
- /* overflow - reset */
- dev_dbg(&dev->pdev->dev, "resetting due to slots overflow.\n");
- /* set the event since message has been read */
- ret = -ERANGE;
- goto end;
- }
-end:
- return ret;
-}
-
-
-/**
- * mei_irq_thread_write_handler - bottom half write routine after
- * ISR to handle the write processing.
- *
- * @cmpl_list: An instance of our list structure
- * @dev: the device structure
- * @slots: slots to write.
- *
- * returns 0 on success, <0 on failure.
- */
-static int mei_irq_thread_write_handler(struct mei_io_list *cmpl_list,
- struct mei_device *dev,
- s32 *slots)
-{
-
- struct mei_cl *cl;
- struct mei_cl_cb *pos = NULL, *next = NULL;
- struct mei_io_list *list;
- int ret;
-
- if (!mei_host_buffer_is_empty(dev)) {
- dev_dbg(&dev->pdev->dev, "host buffer is not empty.\n");
- return 0;
- }
- *slots = mei_count_empty_write_slots(dev);
- /* complete all waiting for write CB */
- dev_dbg(&dev->pdev->dev, "complete all waiting for write cb.\n");
-
- list = &dev->write_waiting_list;
- list_for_each_entry_safe(pos, next,
- &list->mei_cb.cb_list, cb_list) {
- cl = (struct mei_cl *)pos->file_private;
- if (cl == NULL)
- continue;
-
- cl->status = 0;
- list_del(&pos->cb_list);
- if (MEI_WRITING == cl->writing_state &&
- (pos->major_file_operations == MEI_WRITE) &&
- (cl != &dev->iamthif_cl)) {
- dev_dbg(&dev->pdev->dev,
- "MEI WRITE COMPLETE\n");
- cl->writing_state = MEI_WRITE_COMPLETE;
- list_add_tail(&pos->cb_list,
- &cmpl_list->mei_cb.cb_list);
- }
- if (cl == &dev->iamthif_cl) {
- dev_dbg(&dev->pdev->dev, "check iamthif flow control.\n");
- if (dev->iamthif_flow_control_pending) {
- ret = _mei_irq_thread_iamthif_read(
- dev, slots);
- if (ret)
- return ret;
- }
- }
- }
-
- if (dev->stop && !dev->wd_pending) {
- dev->wd_stopped = true;
- wake_up_interruptible(&dev->wait_stop_wd);
- return 0;
- }
-
- if (dev->extra_write_index) {
- dev_dbg(&dev->pdev->dev, "extra_write_index =%d.\n",
- dev->extra_write_index);
- mei_write_message(dev,
- (struct mei_msg_hdr *) &dev->ext_msg_buf[0],
- (unsigned char *) &dev->ext_msg_buf[1],
- (dev->extra_write_index - 1) * sizeof(u32));
- *slots -= dev->extra_write_index;
- dev->extra_write_index = 0;
- }
- if (dev->mei_state == MEI_ENABLED) {
- if (dev->wd_pending &&
- mei_flow_ctrl_creds(dev, &dev->wd_cl) > 0) {
- if (mei_wd_send(dev))
- dev_dbg(&dev->pdev->dev, "wd send failed.\n");
- else
- if (mei_flow_ctrl_reduce(dev, &dev->wd_cl))
- return -ENODEV;
-
- dev->wd_pending = false;
-
- if (dev->wd_timeout) {
- *slots -= (sizeof(struct mei_msg_hdr) +
- MEI_START_WD_DATA_SIZE + 3) / 4;
- dev->wd_due_counter = 2;
- } else {
- *slots -= (sizeof(struct mei_msg_hdr) +
- MEI_WD_PARAMS_SIZE + 3) / 4;
- dev->wd_due_counter = 0;
- }
-
- }
- }
- if (dev->stop)
- return -ENODEV;
-
- /* complete control write list CB */
- dev_dbg(&dev->pdev->dev, "complete control write list cb.\n");
- list_for_each_entry_safe(pos, next,
- &dev->ctrl_wr_list.mei_cb.cb_list, cb_list) {
- cl = (struct mei_cl *) pos->file_private;
- if (!cl) {
- list_del(&pos->cb_list);
- return -ENODEV;
- }
- switch (pos->major_file_operations) {
- case MEI_CLOSE:
- /* send disconnect message */
- ret = _mei_irq_thread_close(dev, slots, pos, cl, cmpl_list);
- if (ret)
- return ret;
-
- break;
- case MEI_READ:
- /* send flow control message */
- ret = _mei_irq_thread_read(dev, slots, pos, cl, cmpl_list);
- if (ret)
- return ret;
-
- break;
- case MEI_IOCTL:
- /* connect message */
- if (mei_other_client_is_connecting(dev, cl))
- continue;
- ret = _mei_irq_thread_ioctl(dev, slots, pos, cl, cmpl_list);
- if (ret)
- return ret;
-
- break;
-
- default:
- BUG();
- }
-
- }
- /* complete write list CB */
- dev_dbg(&dev->pdev->dev, "complete write list cb.\n");
- list_for_each_entry_safe(pos, next,
- &dev->write_list.mei_cb.cb_list, cb_list) {
- cl = (struct mei_cl *)pos->file_private;
- if (cl == NULL)
- continue;
-
- if (cl != &dev->iamthif_cl) {
- if (!mei_flow_ctrl_creds(dev, cl)) {
- dev_dbg(&dev->pdev->dev,
- "No flow control"
- " credentials for client"
- " %d, not sending.\n",
- cl->host_client_id);
- continue;
- }
- ret = _mei_irq_thread_cmpl(dev, slots,
- pos,
- cl, cmpl_list);
- if (ret)
- return ret;
-
- } else if (cl == &dev->iamthif_cl) {
- /* IAMTHIF IOCTL */
- dev_dbg(&dev->pdev->dev, "complete amthi write cb.\n");
- if (!mei_flow_ctrl_creds(dev, cl)) {
- dev_dbg(&dev->pdev->dev,
- "No flow control"
- " credentials for amthi"
- " client %d.\n",
- cl->host_client_id);
- continue;
- }
- ret = _mei_irq_thread_cmpl_iamthif(dev,
- slots,
- pos,
- cl,
- cmpl_list);
- if (ret)
- return ret;
-
- }
-
- }
- return 0;
-}
-
-
-
-/**
- * mei_timer - timer function.
- *
- * @work: pointer to the work_struct structure
- *
- * NOTE: This function is called by timer interrupt work
- */
-void mei_timer(struct work_struct *work)
-{
- unsigned long timeout;
- struct mei_cl *cl_pos = NULL;
- struct mei_cl *cl_next = NULL;
- struct list_head *amthi_complete_list = NULL;
- struct mei_cl_cb *cb_pos = NULL;
- struct mei_cl_cb *cb_next = NULL;
-
- struct mei_device *dev = container_of(work,
- struct mei_device, timer_work.work);
-
-
- mutex_lock(&dev->device_lock);
- if (dev->mei_state != MEI_ENABLED) {
- if (dev->mei_state == MEI_INIT_CLIENTS) {
- if (dev->init_clients_timer) {
- if (--dev->init_clients_timer == 0) {
- dev_dbg(&dev->pdev->dev, "IMEI reset due to init clients timeout ,init clients state = %d.\n",
- dev->init_clients_state);
- mei_reset(dev, 1);
- }
- }
- }
- goto out;
- }
- /*** connect/disconnect timeouts ***/
- list_for_each_entry_safe(cl_pos, cl_next, &dev->file_list, link) {
- if (cl_pos->timer_count) {
- if (--cl_pos->timer_count == 0) {
- dev_dbg(&dev->pdev->dev, "HECI reset due to connect/disconnect timeout.\n");
- mei_reset(dev, 1);
- goto out;
- }
- }
- }
-
- if (dev->iamthif_stall_timer) {
- if (--dev->iamthif_stall_timer == 0) {
- dev_dbg(&dev->pdev->dev, "resetting because of hang to amthi.\n");
- mei_reset(dev, 1);
- dev->iamthif_msg_buf_size = 0;
- dev->iamthif_msg_buf_index = 0;
- dev->iamthif_canceled = false;
- dev->iamthif_ioctl = true;
- dev->iamthif_state = MEI_IAMTHIF_IDLE;
- dev->iamthif_timer = 0;
-
- if (dev->iamthif_current_cb)
- mei_free_cb_private(dev->iamthif_current_cb);
-
- dev->iamthif_file_object = NULL;
- dev->iamthif_current_cb = NULL;
- mei_run_next_iamthif_cmd(dev);
- }
- }
-
- if (dev->iamthif_timer) {
-
- timeout = dev->iamthif_timer +
- msecs_to_jiffies(IAMTHIF_READ_TIMER);
-
- dev_dbg(&dev->pdev->dev, "dev->iamthif_timer = %ld\n",
- dev->iamthif_timer);
- dev_dbg(&dev->pdev->dev, "timeout = %ld\n", timeout);
- dev_dbg(&dev->pdev->dev, "jiffies = %ld\n", jiffies);
- if (time_after(jiffies, timeout)) {
- /*
- * User didn't read the AMTHI data on time (15sec)
- * freeing AMTHI for other requests
- */
-
- dev_dbg(&dev->pdev->dev, "freeing AMTHI for other requests\n");
-
- amthi_complete_list = &dev->amthi_read_complete_list.
- mei_cb.cb_list;
-
- list_for_each_entry_safe(cb_pos, cb_next, amthi_complete_list, cb_list) {
-
- cl_pos = cb_pos->file_object->private_data;
-
- /* Finding the AMTHI entry. */
- if (cl_pos == &dev->iamthif_cl)
- list_del(&cb_pos->cb_list);
- }
- if (dev->iamthif_current_cb)
- mei_free_cb_private(dev->iamthif_current_cb);
-
- dev->iamthif_file_object->private_data = NULL;
- dev->iamthif_file_object = NULL;
- dev->iamthif_current_cb = NULL;
- dev->iamthif_timer = 0;
- mei_run_next_iamthif_cmd(dev);
-
- }
- }
-out:
- schedule_delayed_work(&dev->timer_work, 2 * HZ);
- mutex_unlock(&dev->device_lock);
-}
-
-/**
- * mei_interrupt_thread_handler - function called after ISR to handle the interrupt
- * processing.
- *
- * @irq: The irq number
- * @dev_id: pointer to the device structure
- *
- * returns irqreturn_t
- *
- */
-irqreturn_t mei_interrupt_thread_handler(int irq, void *dev_id)
-{
- struct mei_device *dev = (struct mei_device *) dev_id;
- struct mei_io_list complete_list;
- struct mei_cl_cb *cb_pos = NULL, *cb_next = NULL;
- struct mei_cl *cl;
- s32 slots;
- int rets;
- bool bus_message_received;
-
-
- dev_dbg(&dev->pdev->dev, "function called after ISR to handle the interrupt processing.\n");
- /* initialize our complete list */
- mutex_lock(&dev->device_lock);
- mei_io_list_init(&complete_list);
- dev->host_hw_state = mei_hcsr_read(dev);
-
- /* Ack the interrupt here
- * In case of MSI we don't go through the quick handler */
- if (pci_dev_msi_enabled(dev->pdev))
- mei_reg_write(dev, H_CSR, dev->host_hw_state);
-
- dev->me_hw_state = mei_mecsr_read(dev);
-
- /* check if ME wants a reset */
- if ((dev->me_hw_state & ME_RDY_HRA) == 0 &&
- dev->mei_state != MEI_RESETING &&
- dev->mei_state != MEI_INITIALIZING) {
- dev_dbg(&dev->pdev->dev, "FW not ready.\n");
- mei_reset(dev, 1);
- mutex_unlock(&dev->device_lock);
- return IRQ_HANDLED;
- }
-
- /* check if we need to start the dev */
- if ((dev->host_hw_state & H_RDY) == 0) {
- if ((dev->me_hw_state & ME_RDY_HRA) == ME_RDY_HRA) {
- dev_dbg(&dev->pdev->dev, "we need to start the dev.\n");
- dev->host_hw_state |= (H_IE | H_IG | H_RDY);
- mei_hcsr_set(dev);
- dev->mei_state = MEI_INIT_CLIENTS;
- dev_dbg(&dev->pdev->dev, "link is established start sending messages.\n");
- /* link is established
- * start sending messages.
- */
- mei_host_start_message(dev);
- mutex_unlock(&dev->device_lock);
- return IRQ_HANDLED;
- } else {
- dev_dbg(&dev->pdev->dev, "FW not ready.\n");
- mutex_unlock(&dev->device_lock);
- return IRQ_HANDLED;
- }
- }
- /* check slots available for reading */
- slots = mei_count_full_read_slots(dev);
- dev_dbg(&dev->pdev->dev, "slots =%08x extra_write_index =%08x.\n",
- slots, dev->extra_write_index);
- while (slots > 0 && !dev->extra_write_index) {
- dev_dbg(&dev->pdev->dev, "slots =%08x extra_write_index =%08x.\n",
- slots, dev->extra_write_index);
- dev_dbg(&dev->pdev->dev, "call mei_irq_thread_read_handler.\n");
- rets = mei_irq_thread_read_handler(&complete_list, dev, &slots);
- if (rets)
- goto end;
- }
- rets = mei_irq_thread_write_handler(&complete_list, dev, &slots);
-end:
- dev_dbg(&dev->pdev->dev, "end of bottom half function.\n");
- dev->host_hw_state = mei_hcsr_read(dev);
- dev->mei_host_buffer_is_empty = mei_host_buffer_is_empty(dev);
-
- bus_message_received = false;
- if (dev->recvd_msg && waitqueue_active(&dev->wait_recvd_msg)) {
- dev_dbg(&dev->pdev->dev, "received waiting bus message\n");
- bus_message_received = true;
- }
- mutex_unlock(&dev->device_lock);
- if (bus_message_received) {
- dev_dbg(&dev->pdev->dev, "wake up dev->wait_recvd_msg\n");
- wake_up_interruptible(&dev->wait_recvd_msg);
- bus_message_received = false;
- }
- if (list_empty(&complete_list.mei_cb.cb_list))
- return IRQ_HANDLED;
-
-
- list_for_each_entry_safe(cb_pos, cb_next,
- &complete_list.mei_cb.cb_list, cb_list) {
- cl = (struct mei_cl *)cb_pos->file_private;
- list_del(&cb_pos->cb_list);
- if (cl) {
- if (cl != &dev->iamthif_cl) {
- dev_dbg(&dev->pdev->dev, "completing call back.\n");
- _mei_cmpl(cl, cb_pos);
- cb_pos = NULL;
- } else if (cl == &dev->iamthif_cl) {
- _mei_cmpl_iamthif(dev, cb_pos);
- }
- }
- }
- return IRQ_HANDLED;
-}
diff --git a/drivers/staging/mei/iorw.c b/drivers/staging/mei/iorw.c
deleted file mode 100644
index 0a80dc4e62f3..000000000000
--- a/drivers/staging/mei/iorw.c
+++ /dev/null
@@ -1,590 +0,0 @@
-/*
- *
- * Intel Management Engine Interface (Intel MEI) Linux driver
- * Copyright (c) 2003-2012, Intel Corporation.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms and conditions of the GNU General Public License,
- * version 2, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- */
-
-
-#include <linux/kernel.h>
-#include <linux/fs.h>
-#include <linux/errno.h>
-#include <linux/types.h>
-#include <linux/fcntl.h>
-#include <linux/aio.h>
-#include <linux/pci.h>
-#include <linux/init.h>
-#include <linux/ioctl.h>
-#include <linux/cdev.h>
-#include <linux/list.h>
-#include <linux/delay.h>
-#include <linux/sched.h>
-#include <linux/uuid.h>
-#include <linux/jiffies.h>
-#include <linux/uaccess.h>
-
-
-#include "mei_dev.h"
-#include "hw.h"
-#include "mei.h"
-#include "interface.h"
-
-
-
-/**
- * mei_ioctl_connect_client - the connect to fw client IOCTL function
- *
- * @dev: the device structure
- * @data: IOCTL connect data, input and output parameters
- * @file: private data of the file object
- *
- * Locking: called under "dev->device_lock" lock
- *
- * returns 0 on success, <0 on failure.
- */
-int mei_ioctl_connect_client(struct file *file,
- struct mei_connect_client_data *data)
-{
- struct mei_device *dev;
- struct mei_cl_cb *cb;
- struct mei_client *client;
- struct mei_cl *cl;
- struct mei_cl *cl_pos = NULL;
- struct mei_cl *cl_next = NULL;
- long timeout = CONNECT_TIMEOUT;
- int i;
- int err;
- int rets;
-
- cl = file->private_data;
- if (WARN_ON(!cl || !cl->dev))
- return -ENODEV;
-
- dev = cl->dev;
-
- dev_dbg(&dev->pdev->dev, "mei_ioctl_connect_client() Entry\n");
-
-
- /* buffered ioctl cb */
- cb = kzalloc(sizeof(struct mei_cl_cb), GFP_KERNEL);
- if (!cb) {
- rets = -ENOMEM;
- goto end;
- }
- INIT_LIST_HEAD(&cb->cb_list);
-
- cb->major_file_operations = MEI_IOCTL;
-
- if (dev->mei_state != MEI_ENABLED) {
- rets = -ENODEV;
- goto end;
- }
- if (cl->state != MEI_FILE_INITIALIZING &&
- cl->state != MEI_FILE_DISCONNECTED) {
- rets = -EBUSY;
- goto end;
- }
-
- /* find ME client we're trying to connect to */
- i = mei_find_me_client_index(dev, data->in_client_uuid);
- if (i >= 0 && !dev->me_clients[i].props.fixed_address) {
- cl->me_client_id = dev->me_clients[i].client_id;
- cl->state = MEI_FILE_CONNECTING;
- }
-
- dev_dbg(&dev->pdev->dev, "Connect to FW Client ID = %d\n",
- cl->me_client_id);
- dev_dbg(&dev->pdev->dev, "FW Client - Protocol Version = %d\n",
- dev->me_clients[i].props.protocol_version);
- dev_dbg(&dev->pdev->dev, "FW Client - Max Msg Len = %d\n",
- dev->me_clients[i].props.max_msg_length);
-
- /* if we're connecting to amthi client then we will use the
- * existing connection
- */
- if (uuid_le_cmp(data->in_client_uuid, mei_amthi_guid) == 0) {
- dev_dbg(&dev->pdev->dev, "FW Client is amthi\n");
- if (dev->iamthif_cl.state != MEI_FILE_CONNECTED) {
- rets = -ENODEV;
- goto end;
- }
- clear_bit(cl->host_client_id, dev->host_clients_map);
- list_for_each_entry_safe(cl_pos, cl_next,
- &dev->file_list, link) {
- if (mei_cl_cmp_id(cl, cl_pos)) {
- dev_dbg(&dev->pdev->dev,
- "remove file private data node host"
- " client = %d, ME client = %d.\n",
- cl_pos->host_client_id,
- cl_pos->me_client_id);
- list_del(&cl_pos->link);
- }
-
- }
- dev_dbg(&dev->pdev->dev, "free file private data memory.\n");
- kfree(cl);
-
- cl = NULL;
- file->private_data = &dev->iamthif_cl;
-
- client = &data->out_client_properties;
- client->max_msg_length =
- dev->me_clients[i].props.max_msg_length;
- client->protocol_version =
- dev->me_clients[i].props.protocol_version;
- rets = dev->iamthif_cl.status;
-
- goto end;
- }
-
- if (cl->state != MEI_FILE_CONNECTING) {
- rets = -ENODEV;
- goto end;
- }
-
-
- /* prepare the output buffer */
- client = &data->out_client_properties;
- client->max_msg_length = dev->me_clients[i].props.max_msg_length;
- client->protocol_version = dev->me_clients[i].props.protocol_version;
- dev_dbg(&dev->pdev->dev, "Can connect?\n");
- if (dev->mei_host_buffer_is_empty
- && !mei_other_client_is_connecting(dev, cl)) {
- dev_dbg(&dev->pdev->dev, "Sending Connect Message\n");
- dev->mei_host_buffer_is_empty = false;
- if (mei_connect(dev, cl)) {
- dev_dbg(&dev->pdev->dev, "Sending connect message - failed\n");
- rets = -ENODEV;
- goto end;
- } else {
- dev_dbg(&dev->pdev->dev, "Sending connect message - succeeded\n");
- cl->timer_count = MEI_CONNECT_TIMEOUT;
- cb->file_private = cl;
- list_add_tail(&cb->cb_list,
- &dev->ctrl_rd_list.mei_cb.
- cb_list);
- }
-
-
- } else {
- dev_dbg(&dev->pdev->dev, "Queuing the connect request due to device busy\n");
- cb->file_private = cl;
- dev_dbg(&dev->pdev->dev, "add connect cb to control write list.\n");
- list_add_tail(&cb->cb_list,
- &dev->ctrl_wr_list.mei_cb.cb_list);
- }
- mutex_unlock(&dev->device_lock);
- err = wait_event_timeout(dev->wait_recvd_msg,
- (MEI_FILE_CONNECTED == cl->state ||
- MEI_FILE_DISCONNECTED == cl->state),
- timeout * HZ);
-
- mutex_lock(&dev->device_lock);
- if (MEI_FILE_CONNECTED == cl->state) {
- dev_dbg(&dev->pdev->dev, "successfully connected to FW client.\n");
- rets = cl->status;
- goto end;
- } else {
- dev_dbg(&dev->pdev->dev, "failed to connect to FW client.cl->state = %d.\n",
- cl->state);
- if (!err) {
- dev_dbg(&dev->pdev->dev,
- "wait_event_interruptible_timeout failed on client"
- " connect message fw response message.\n");
- }
- rets = -EFAULT;
-
- mei_io_list_flush(&dev->ctrl_rd_list, cl);
- mei_io_list_flush(&dev->ctrl_wr_list, cl);
- goto end;
- }
- rets = 0;
-end:
- dev_dbg(&dev->pdev->dev, "free connect cb memory.");
- kfree(cb);
- return rets;
-}
-
-/**
- * find_amthi_read_list_entry - finds a amthilist entry for current file
- *
- * @dev: the device structure
- * @file: pointer to file object
- *
- * returns returned a list entry on success, NULL on failure.
- */
-struct mei_cl_cb *find_amthi_read_list_entry(
- struct mei_device *dev,
- struct file *file)
-{
- struct mei_cl *cl_temp;
- struct mei_cl_cb *pos = NULL;
- struct mei_cl_cb *next = NULL;
-
- list_for_each_entry_safe(pos, next,
- &dev->amthi_read_complete_list.mei_cb.cb_list, cb_list) {
- cl_temp = (struct mei_cl *)pos->file_private;
- if (cl_temp && cl_temp == &dev->iamthif_cl &&
- pos->file_object == file)
- return pos;
- }
- return NULL;
-}
-
-/**
- * amthi_read - read data from AMTHI client
- *
- * @dev: the device structure
- * @if_num: minor number
- * @file: pointer to file object
- * @*ubuf: pointer to user data in user space
- * @length: data length to read
- * @offset: data read offset
- *
- * Locking: called under "dev->device_lock" lock
- *
- * returns
- * returned data length on success,
- * zero if no data to read,
- * negative on failure.
- */
-int amthi_read(struct mei_device *dev, struct file *file,
- char __user *ubuf, size_t length, loff_t *offset)
-{
- int rets;
- int wait_ret;
- struct mei_cl_cb *cb = NULL;
- struct mei_cl *cl = file->private_data;
- unsigned long timeout;
- int i;
-
- /* Only Posible if we are in timeout */
- if (!cl || cl != &dev->iamthif_cl) {
- dev_dbg(&dev->pdev->dev, "bad file ext.\n");
- return -ETIMEDOUT;
- }
-
- for (i = 0; i < dev->me_clients_num; i++) {
- if (dev->me_clients[i].client_id ==
- dev->iamthif_cl.me_client_id)
- break;
- }
-
- if (i == dev->me_clients_num) {
- dev_dbg(&dev->pdev->dev, "amthi client not found.\n");
- return -ENODEV;
- }
- if (WARN_ON(dev->me_clients[i].client_id != cl->me_client_id))
- return -ENODEV;
-
- dev_dbg(&dev->pdev->dev, "checking amthi data\n");
- cb = find_amthi_read_list_entry(dev, file);
-
- /* Check for if we can block or not*/
- if (cb == NULL && file->f_flags & O_NONBLOCK)
- return -EAGAIN;
-
-
- dev_dbg(&dev->pdev->dev, "waiting for amthi data\n");
- while (cb == NULL) {
- /* unlock the Mutex */
- mutex_unlock(&dev->device_lock);
-
- wait_ret = wait_event_interruptible(dev->iamthif_cl.wait,
- (cb = find_amthi_read_list_entry(dev, file)));
-
- if (wait_ret)
- return -ERESTARTSYS;
-
- dev_dbg(&dev->pdev->dev, "woke up from sleep\n");
-
- /* Locking again the Mutex */
- mutex_lock(&dev->device_lock);
- }
-
-
- dev_dbg(&dev->pdev->dev, "Got amthi data\n");
- dev->iamthif_timer = 0;
-
- if (cb) {
- timeout = cb->read_time +
- msecs_to_jiffies(IAMTHIF_READ_TIMER);
- dev_dbg(&dev->pdev->dev, "amthi timeout = %lud\n",
- timeout);
-
- if (time_after(jiffies, timeout)) {
- dev_dbg(&dev->pdev->dev, "amthi Time out\n");
- /* 15 sec for the message has expired */
- list_del(&cb->cb_list);
- rets = -ETIMEDOUT;
- goto free;
- }
- }
- /* if the whole message will fit remove it from the list */
- if (cb->information >= *offset && length >= (cb->information - *offset))
- list_del(&cb->cb_list);
- else if (cb->information > 0 && cb->information <= *offset) {
- /* end of the message has been reached */
- list_del(&cb->cb_list);
- rets = 0;
- goto free;
- }
- /* else means that not full buffer will be read and do not
- * remove message from deletion list
- */
-
- dev_dbg(&dev->pdev->dev, "amthi cb->response_buffer size - %d\n",
- cb->response_buffer.size);
- dev_dbg(&dev->pdev->dev, "amthi cb->information - %lu\n",
- cb->information);
-
- /* length is being turncated to PAGE_SIZE, however,
- * the information may be longer */
- length = min_t(size_t, length, (cb->information - *offset));
-
- if (copy_to_user(ubuf, cb->response_buffer.data + *offset, length))
- rets = -EFAULT;
- else {
- rets = length;
- if ((*offset + length) < cb->information) {
- *offset += length;
- goto out;
- }
- }
-free:
- dev_dbg(&dev->pdev->dev, "free amthi cb memory.\n");
- *offset = 0;
- mei_free_cb_private(cb);
-out:
- return rets;
-}
-
-/**
- * mei_start_read - the start read client message function.
- *
- * @dev: the device structure
- * @if_num: minor number
- * @cl: private data of the file object
- *
- * returns 0 on success, <0 on failure.
- */
-int mei_start_read(struct mei_device *dev, struct mei_cl *cl)
-{
- struct mei_cl_cb *cb;
- int rets = 0;
- int i;
-
- if (cl->state != MEI_FILE_CONNECTED)
- return -ENODEV;
-
- if (dev->mei_state != MEI_ENABLED)
- return -ENODEV;
-
- dev_dbg(&dev->pdev->dev, "check if read is pending.\n");
- if (cl->read_pending || cl->read_cb) {
- dev_dbg(&dev->pdev->dev, "read is pending.\n");
- return -EBUSY;
- }
-
- cb = kzalloc(sizeof(struct mei_cl_cb), GFP_KERNEL);
- if (!cb)
- return -ENOMEM;
-
- dev_dbg(&dev->pdev->dev, "allocation call back successful. host client = %d, ME client = %d\n",
- cl->host_client_id, cl->me_client_id);
-
- for (i = 0; i < dev->me_clients_num; i++) {
- if (dev->me_clients[i].client_id == cl->me_client_id)
- break;
-
- }
-
- if (WARN_ON(dev->me_clients[i].client_id != cl->me_client_id)) {
- rets = -ENODEV;
- goto unlock;
- }
-
- if (i == dev->me_clients_num) {
- rets = -ENODEV;
- goto unlock;
- }
-
- cb->response_buffer.size = dev->me_clients[i].props.max_msg_length;
- cb->response_buffer.data =
- kmalloc(cb->response_buffer.size, GFP_KERNEL);
- if (!cb->response_buffer.data) {
- rets = -ENOMEM;
- goto unlock;
- }
- dev_dbg(&dev->pdev->dev, "allocation call back data success.\n");
- cb->major_file_operations = MEI_READ;
- /* make sure information is zero before we start */
- cb->information = 0;
- cb->file_private = (void *) cl;
- cl->read_cb = cb;
- if (dev->mei_host_buffer_is_empty) {
- dev->mei_host_buffer_is_empty = false;
- if (mei_send_flow_control(dev, cl)) {
- rets = -ENODEV;
- goto unlock;
- }
- list_add_tail(&cb->cb_list, &dev->read_list.mei_cb.cb_list);
- } else {
- list_add_tail(&cb->cb_list, &dev->ctrl_wr_list.mei_cb.cb_list);
- }
- return rets;
-unlock:
- mei_free_cb_private(cb);
- return rets;
-}
-
-/**
- * amthi_write - write iamthif data to amthi client
- *
- * @dev: the device structure
- * @cb: mei call back struct
- *
- * returns 0 on success, <0 on failure.
- */
-int amthi_write(struct mei_device *dev, struct mei_cl_cb *cb)
-{
- struct mei_msg_hdr mei_hdr;
- int ret;
-
- if (!dev || !cb)
- return -ENODEV;
-
- dev_dbg(&dev->pdev->dev, "write data to amthi client.\n");
-
- dev->iamthif_state = MEI_IAMTHIF_WRITING;
- dev->iamthif_current_cb = cb;
- dev->iamthif_file_object = cb->file_object;
- dev->iamthif_canceled = false;
- dev->iamthif_ioctl = true;
- dev->iamthif_msg_buf_size = cb->request_buffer.size;
- memcpy(dev->iamthif_msg_buf, cb->request_buffer.data,
- cb->request_buffer.size);
-
- ret = mei_flow_ctrl_creds(dev, &dev->iamthif_cl);
- if (ret < 0)
- return ret;
-
- if (ret && dev->mei_host_buffer_is_empty) {
- ret = 0;
- dev->mei_host_buffer_is_empty = false;
- if (cb->request_buffer.size >
- (((dev->host_hw_state & H_CBD) >> 24) * sizeof(u32))
- -sizeof(struct mei_msg_hdr)) {
- mei_hdr.length =
- (((dev->host_hw_state & H_CBD) >> 24) *
- sizeof(u32)) - sizeof(struct mei_msg_hdr);
- mei_hdr.msg_complete = 0;
- } else {
- mei_hdr.length = cb->request_buffer.size;
- mei_hdr.msg_complete = 1;
- }
-
- mei_hdr.host_addr = dev->iamthif_cl.host_client_id;
- mei_hdr.me_addr = dev->iamthif_cl.me_client_id;
- mei_hdr.reserved = 0;
- dev->iamthif_msg_buf_index += mei_hdr.length;
- if (mei_write_message(dev, &mei_hdr,
- (unsigned char *)(dev->iamthif_msg_buf),
- mei_hdr.length))
- return -ENODEV;
-
- if (mei_hdr.msg_complete) {
- if (mei_flow_ctrl_reduce(dev, &dev->iamthif_cl))
- return -ENODEV;
- dev->iamthif_flow_control_pending = true;
- dev->iamthif_state = MEI_IAMTHIF_FLOW_CONTROL;
- dev_dbg(&dev->pdev->dev, "add amthi cb to write waiting list\n");
- dev->iamthif_current_cb = cb;
- dev->iamthif_file_object = cb->file_object;
- list_add_tail(&cb->cb_list,
- &dev->write_waiting_list.mei_cb.cb_list);
- } else {
- dev_dbg(&dev->pdev->dev, "message does not complete, "
- "so add amthi cb to write list.\n");
- list_add_tail(&cb->cb_list,
- &dev->write_list.mei_cb.cb_list);
- }
- } else {
- if (!(dev->mei_host_buffer_is_empty))
- dev_dbg(&dev->pdev->dev, "host buffer is not empty");
-
- dev_dbg(&dev->pdev->dev, "No flow control credentials, "
- "so add iamthif cb to write list.\n");
- list_add_tail(&cb->cb_list, &dev->write_list.mei_cb.cb_list);
- }
- return 0;
-}
-
-/**
- * iamthif_ioctl_send_msg - send cmd data to amthi client
- *
- * @dev: the device structure
- *
- * returns 0 on success, <0 on failure.
- */
-void mei_run_next_iamthif_cmd(struct mei_device *dev)
-{
- struct mei_cl *cl_tmp;
- struct mei_cl_cb *pos = NULL;
- struct mei_cl_cb *next = NULL;
- int status;
-
- if (!dev)
- return;
-
- dev->iamthif_msg_buf_size = 0;
- dev->iamthif_msg_buf_index = 0;
- dev->iamthif_canceled = false;
- dev->iamthif_ioctl = true;
- dev->iamthif_state = MEI_IAMTHIF_IDLE;
- dev->iamthif_timer = 0;
- dev->iamthif_file_object = NULL;
-
- dev_dbg(&dev->pdev->dev, "complete amthi cmd_list cb.\n");
-
- list_for_each_entry_safe(pos, next,
- &dev->amthi_cmd_list.mei_cb.cb_list, cb_list) {
- list_del(&pos->cb_list);
- cl_tmp = (struct mei_cl *)pos->file_private;
-
- if (cl_tmp && cl_tmp == &dev->iamthif_cl) {
- status = amthi_write(dev, pos);
- if (status) {
- dev_dbg(&dev->pdev->dev,
- "amthi write failed status = %d\n",
- status);
- return;
- }
- break;
- }
- }
-}
-
-/**
- * mei_free_cb_private - free mei_cb_private related memory
- *
- * @cb: mei callback struct
- */
-void mei_free_cb_private(struct mei_cl_cb *cb)
-{
- if (cb == NULL)
- return;
-
- kfree(cb->request_buffer.data);
- kfree(cb->response_buffer.data);
- kfree(cb);
-}
diff --git a/drivers/staging/mei/main.c b/drivers/staging/mei/main.c
deleted file mode 100644
index 7c9321fa7bb1..000000000000
--- a/drivers/staging/mei/main.c
+++ /dev/null
@@ -1,1237 +0,0 @@
-/*
- *
- * Intel Management Engine Interface (Intel MEI) Linux driver
- * Copyright (c) 2003-2012, Intel Corporation.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms and conditions of the GNU General Public License,
- * version 2, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- */
-
-#include <linux/module.h>
-#include <linux/moduleparam.h>
-#include <linux/kernel.h>
-#include <linux/device.h>
-#include <linux/fs.h>
-#include <linux/errno.h>
-#include <linux/types.h>
-#include <linux/fcntl.h>
-#include <linux/aio.h>
-#include <linux/pci.h>
-#include <linux/poll.h>
-#include <linux/init.h>
-#include <linux/ioctl.h>
-#include <linux/cdev.h>
-#include <linux/sched.h>
-#include <linux/uuid.h>
-#include <linux/compat.h>
-#include <linux/jiffies.h>
-#include <linux/interrupt.h>
-#include <linux/miscdevice.h>
-
-#include "mei_dev.h"
-#include "mei.h"
-#include "interface.h"
-
-
-#define MEI_READ_TIMEOUT 45
-#define MEI_DRIVER_NAME "mei"
-#define MEI_DEV_NAME "mei"
-
-/*
- * mei driver strings
- */
-static char mei_driver_name[] = MEI_DRIVER_NAME;
-static const char mei_driver_string[] = "Intel(R) Management Engine Interface";
-
-/* The device pointer */
-/* Currently this driver works as long as there is only a single AMT device. */
-struct pci_dev *mei_device;
-
-/* mei_pci_tbl - PCI Device ID Table */
-static DEFINE_PCI_DEVICE_TABLE(mei_pci_tbl) = {
- {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_82946GZ)},
- {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_82G35)},
- {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_82Q965)},
- {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_82G965)},
- {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_82GM965)},
- {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_82GME965)},
- {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_ICH9_82Q35)},
- {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_ICH9_82G33)},
- {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_ICH9_82Q33)},
- {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_ICH9_82X38)},
- {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_ICH9_3200)},
- {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_ICH9_6)},
- {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_ICH9_7)},
- {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_ICH9_8)},
- {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_ICH9_9)},
- {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_ICH9_10)},
- {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_ICH9M_1)},
- {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_ICH9M_2)},
- {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_ICH9M_3)},
- {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_ICH9M_4)},
- {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_ICH10_1)},
- {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_ICH10_2)},
- {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_ICH10_3)},
- {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_ICH10_4)},
- {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_IBXPK_1)},
- {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_IBXPK_2)},
- {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_CPT_1)},
- {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_PBG_1)},
- {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_PPT_1)},
- {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_PPT_2)},
- {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_PPT_3)},
-
- /* required last entry */
- {0, }
-};
-
-MODULE_DEVICE_TABLE(pci, mei_pci_tbl);
-
-static DEFINE_MUTEX(mei_mutex);
-
-
-/**
- * mei_clear_list - removes all callbacks associated with file
- * from mei_cb_list
- *
- * @dev: device structure.
- * @file: file structure
- * @mei_cb_list: callbacks list
- *
- * mei_clear_list is called to clear resources associated with file
- * when application calls close function or Ctrl-C was pressed
- *
- * returns true if callback removed from the list, false otherwise
- */
-static bool mei_clear_list(struct mei_device *dev,
- struct file *file, struct list_head *mei_cb_list)
-{
- struct mei_cl_cb *cb_pos = NULL;
- struct mei_cl_cb *cb_next = NULL;
- struct file *file_temp;
- bool removed = false;
-
- /* list all list member */
- list_for_each_entry_safe(cb_pos, cb_next, mei_cb_list, cb_list) {
- file_temp = (struct file *)cb_pos->file_object;
- /* check if list member associated with a file */
- if (file_temp == file) {
- /* remove member from the list */
- list_del(&cb_pos->cb_list);
- /* check if cb equal to current iamthif cb */
- if (dev->iamthif_current_cb == cb_pos) {
- dev->iamthif_current_cb = NULL;
- /* send flow control to iamthif client */
- mei_send_flow_control(dev, &dev->iamthif_cl);
- }
- /* free all allocated buffers */
- mei_free_cb_private(cb_pos);
- cb_pos = NULL;
- removed = true;
- }
- }
- return removed;
-}
-
-/**
- * mei_clear_lists - removes all callbacks associated with file
- *
- * @dev: device structure
- * @file: file structure
- *
- * mei_clear_lists is called to clear resources associated with file
- * when application calls close function or Ctrl-C was pressed
- *
- * returns true if callback removed from the list, false otherwise
- */
-static bool mei_clear_lists(struct mei_device *dev, struct file *file)
-{
- bool removed = false;
-
- /* remove callbacks associated with a file */
- mei_clear_list(dev, file, &dev->amthi_cmd_list.mei_cb.cb_list);
- if (mei_clear_list(dev, file,
- &dev->amthi_read_complete_list.mei_cb.cb_list))
- removed = true;
-
- mei_clear_list(dev, file, &dev->ctrl_rd_list.mei_cb.cb_list);
-
- if (mei_clear_list(dev, file, &dev->ctrl_wr_list.mei_cb.cb_list))
- removed = true;
-
- if (mei_clear_list(dev, file, &dev->write_waiting_list.mei_cb.cb_list))
- removed = true;
-
- if (mei_clear_list(dev, file, &dev->write_list.mei_cb.cb_list))
- removed = true;
-
- /* check if iamthif_current_cb not NULL */
- if (dev->iamthif_current_cb && !removed) {
- /* check file and iamthif current cb association */
- if (dev->iamthif_current_cb->file_object == file) {
- /* remove cb */
- mei_free_cb_private(dev->iamthif_current_cb);
- dev->iamthif_current_cb = NULL;
- removed = true;
- }
- }
- return removed;
-}
-/**
- * find_read_list_entry - find read list entry
- *
- * @dev: device structure
- * @file: pointer to file structure
- *
- * returns cb on success, NULL on error
- */
-static struct mei_cl_cb *find_read_list_entry(
- struct mei_device *dev,
- struct mei_cl *cl)
-{
- struct mei_cl_cb *pos = NULL;
- struct mei_cl_cb *next = NULL;
-
- dev_dbg(&dev->pdev->dev, "remove read_list CB\n");
- list_for_each_entry_safe(pos, next,
- &dev->read_list.mei_cb.cb_list, cb_list) {
- struct mei_cl *cl_temp;
- cl_temp = (struct mei_cl *)pos->file_private;
-
- if (mei_cl_cmp_id(cl, cl_temp))
- return pos;
- }
- return NULL;
-}
-
-/**
- * mei_open - the open function
- *
- * @inode: pointer to inode structure
- * @file: pointer to file structure
- *
- * returns 0 on success, <0 on error
- */
-static int mei_open(struct inode *inode, struct file *file)
-{
- struct mei_cl *cl;
- struct mei_device *dev;
- unsigned long cl_id;
- int err;
-
- err = -ENODEV;
- if (!mei_device)
- goto out;
-
- dev = pci_get_drvdata(mei_device);
- if (!dev)
- goto out;
-
- mutex_lock(&dev->device_lock);
- err = -ENOMEM;
- cl = mei_cl_allocate(dev);
- if (!cl)
- goto out_unlock;
-
- err = -ENODEV;
- if (dev->mei_state != MEI_ENABLED) {
- dev_dbg(&dev->pdev->dev, "mei_state != MEI_ENABLED mei_state= %d\n",
- dev->mei_state);
- goto out_unlock;
- }
- err = -EMFILE;
- if (dev->open_handle_count >= MEI_MAX_OPEN_HANDLE_COUNT)
- goto out_unlock;
-
- cl_id = find_first_zero_bit(dev->host_clients_map, MEI_CLIENTS_MAX);
- if (cl_id >= MEI_CLIENTS_MAX)
- goto out_unlock;
-
- cl->host_client_id = cl_id;
-
- dev_dbg(&dev->pdev->dev, "client_id = %d\n", cl->host_client_id);
-
- dev->open_handle_count++;
-
- list_add_tail(&cl->link, &dev->file_list);
-
- set_bit(cl->host_client_id, dev->host_clients_map);
- cl->state = MEI_FILE_INITIALIZING;
- cl->sm_state = 0;
-
- file->private_data = cl;
- mutex_unlock(&dev->device_lock);
-
- return nonseekable_open(inode, file);
-
-out_unlock:
- mutex_unlock(&dev->device_lock);
- kfree(cl);
-out:
- return err;
-}
-
-/**
- * mei_release - the release function
- *
- * @inode: pointer to inode structure
- * @file: pointer to file structure
- *
- * returns 0 on success, <0 on error
- */
-static int mei_release(struct inode *inode, struct file *file)
-{
- struct mei_cl *cl = file->private_data;
- struct mei_cl_cb *cb;
- struct mei_device *dev;
- int rets = 0;
-
- if (WARN_ON(!cl || !cl->dev))
- return -ENODEV;
-
- dev = cl->dev;
-
- mutex_lock(&dev->device_lock);
- if (cl != &dev->iamthif_cl) {
- if (cl->state == MEI_FILE_CONNECTED) {
- cl->state = MEI_FILE_DISCONNECTING;
- dev_dbg(&dev->pdev->dev,
- "disconnecting client host client = %d, "
- "ME client = %d\n",
- cl->host_client_id,
- cl->me_client_id);
- rets = mei_disconnect_host_client(dev, cl);
- }
- mei_cl_flush_queues(cl);
- dev_dbg(&dev->pdev->dev, "remove client host client = %d, ME client = %d\n",
- cl->host_client_id,
- cl->me_client_id);
-
- if (dev->open_handle_count > 0) {
- clear_bit(cl->host_client_id, dev->host_clients_map);
- dev->open_handle_count--;
- }
- mei_remove_client_from_file_list(dev, cl->host_client_id);
-
- /* free read cb */
- cb = NULL;
- if (cl->read_cb) {
- cb = find_read_list_entry(dev, cl);
- /* Remove entry from read list */
- if (cb)
- list_del(&cb->cb_list);
-
- cb = cl->read_cb;
- cl->read_cb = NULL;
- }
-
- file->private_data = NULL;
-
- if (cb) {
- mei_free_cb_private(cb);
- cb = NULL;
- }
-
- kfree(cl);
- } else {
- if (dev->open_handle_count > 0)
- dev->open_handle_count--;
-
- if (dev->iamthif_file_object == file &&
- dev->iamthif_state != MEI_IAMTHIF_IDLE) {
-
- dev_dbg(&dev->pdev->dev, "amthi canceled iamthif state %d\n",
- dev->iamthif_state);
- dev->iamthif_canceled = true;
- if (dev->iamthif_state == MEI_IAMTHIF_READ_COMPLETE) {
- dev_dbg(&dev->pdev->dev, "run next amthi iamthif cb\n");
- mei_run_next_iamthif_cmd(dev);
- }
- }
-
- if (mei_clear_lists(dev, file))
- dev->iamthif_state = MEI_IAMTHIF_IDLE;
-
- }
- mutex_unlock(&dev->device_lock);
- return rets;
-}
-
-
-/**
- * mei_read - the read function.
- *
- * @file: pointer to file structure
- * @ubuf: pointer to user buffer
- * @length: buffer length
- * @offset: data offset in buffer
- *
- * returns >=0 data length on success , <0 on error
- */
-static ssize_t mei_read(struct file *file, char __user *ubuf,
- size_t length, loff_t *offset)
-{
- struct mei_cl *cl = file->private_data;
- struct mei_cl_cb *cb_pos = NULL;
- struct mei_cl_cb *cb = NULL;
- struct mei_device *dev;
- int i;
- int rets;
- int err;
-
-
- if (WARN_ON(!cl || !cl->dev))
- return -ENODEV;
-
- dev = cl->dev;
-
- mutex_lock(&dev->device_lock);
- if (dev->mei_state != MEI_ENABLED) {
- rets = -ENODEV;
- goto out;
- }
-
- if ((cl->sm_state & MEI_WD_STATE_INDEPENDENCE_MSG_SENT) == 0) {
- /* Do not allow to read watchdog client */
- i = mei_find_me_client_index(dev, mei_wd_guid);
- if (i >= 0) {
- struct mei_me_client *me_client = &dev->me_clients[i];
-
- if (cl->me_client_id == me_client->client_id) {
- rets = -EBADF;
- goto out;
- }
- }
- } else {
- cl->sm_state &= ~MEI_WD_STATE_INDEPENDENCE_MSG_SENT;
- }
-
- if (cl == &dev->iamthif_cl) {
- rets = amthi_read(dev, file, ubuf, length, offset);
- goto out;
- }
-
- if (cl->read_cb && cl->read_cb->information > *offset) {
- cb = cl->read_cb;
- goto copy_buffer;
- } else if (cl->read_cb && cl->read_cb->information > 0 &&
- cl->read_cb->information <= *offset) {
- cb = cl->read_cb;
- rets = 0;
- goto free;
- } else if ((!cl->read_cb || !cl->read_cb->information) &&
- *offset > 0) {
- /*Offset needs to be cleaned for contiguous reads*/
- *offset = 0;
- rets = 0;
- goto out;
- }
-
- err = mei_start_read(dev, cl);
- if (err && err != -EBUSY) {
- dev_dbg(&dev->pdev->dev,
- "mei start read failure with status = %d\n", err);
- rets = err;
- goto out;
- }
-
- if (MEI_READ_COMPLETE != cl->reading_state &&
- !waitqueue_active(&cl->rx_wait)) {
- if (file->f_flags & O_NONBLOCK) {
- rets = -EAGAIN;
- goto out;
- }
-
- mutex_unlock(&dev->device_lock);
-
- if (wait_event_interruptible(cl->rx_wait,
- (MEI_READ_COMPLETE == cl->reading_state ||
- MEI_FILE_INITIALIZING == cl->state ||
- MEI_FILE_DISCONNECTED == cl->state ||
- MEI_FILE_DISCONNECTING == cl->state))) {
- if (signal_pending(current))
- return -EINTR;
- return -ERESTARTSYS;
- }
-
- mutex_lock(&dev->device_lock);
- if (MEI_FILE_INITIALIZING == cl->state ||
- MEI_FILE_DISCONNECTED == cl->state ||
- MEI_FILE_DISCONNECTING == cl->state) {
- rets = -EBUSY;
- goto out;
- }
- }
-
- cb = cl->read_cb;
-
- if (!cb) {
- rets = -ENODEV;
- goto out;
- }
- if (cl->reading_state != MEI_READ_COMPLETE) {
- rets = 0;
- goto out;
- }
- /* now copy the data to user space */
-copy_buffer:
- dev_dbg(&dev->pdev->dev, "cb->response_buffer size - %d\n",
- cb->response_buffer.size);
- dev_dbg(&dev->pdev->dev, "cb->information - %lu\n",
- cb->information);
- if (length == 0 || ubuf == NULL || *offset > cb->information) {
- rets = -EMSGSIZE;
- goto free;
- }
-
- /* length is being truncated to PAGE_SIZE, however, */
- /* information size may be longer */
- length = min_t(size_t, length, (cb->information - *offset));
-
- if (copy_to_user(ubuf, cb->response_buffer.data + *offset, length)) {
- rets = -EFAULT;
- goto free;
- }
-
- rets = length;
- *offset += length;
- if ((unsigned long)*offset < cb->information)
- goto out;
-
-free:
- cb_pos = find_read_list_entry(dev, cl);
- /* Remove entry from read list */
- if (cb_pos)
- list_del(&cb_pos->cb_list);
- mei_free_cb_private(cb);
- cl->reading_state = MEI_IDLE;
- cl->read_cb = NULL;
- cl->read_pending = 0;
-out:
- dev_dbg(&dev->pdev->dev, "end mei read rets= %d\n", rets);
- mutex_unlock(&dev->device_lock);
- return rets;
-}
-
-/**
- * mei_write - the write function.
- *
- * @file: pointer to file structure
- * @ubuf: pointer to user buffer
- * @length: buffer length
- * @offset: data offset in buffer
- *
- * returns >=0 data length on success , <0 on error
- */
-static ssize_t mei_write(struct file *file, const char __user *ubuf,
- size_t length, loff_t *offset)
-{
- struct mei_cl *cl = file->private_data;
- struct mei_cl_cb *write_cb = NULL;
- struct mei_msg_hdr mei_hdr;
- struct mei_device *dev;
- unsigned long timeout = 0;
- int rets;
- int i;
-
- if (WARN_ON(!cl || !cl->dev))
- return -ENODEV;
-
- dev = cl->dev;
-
- mutex_lock(&dev->device_lock);
-
- if (dev->mei_state != MEI_ENABLED) {
- mutex_unlock(&dev->device_lock);
- return -ENODEV;
- }
-
- if (cl == &dev->iamthif_cl) {
- write_cb = find_amthi_read_list_entry(dev, file);
-
- if (write_cb) {
- timeout = write_cb->read_time +
- msecs_to_jiffies(IAMTHIF_READ_TIMER);
-
- if (time_after(jiffies, timeout) ||
- cl->reading_state == MEI_READ_COMPLETE) {
- *offset = 0;
- list_del(&write_cb->cb_list);
- mei_free_cb_private(write_cb);
- write_cb = NULL;
- }
- }
- }
-
- /* free entry used in read */
- if (cl->reading_state == MEI_READ_COMPLETE) {
- *offset = 0;
- write_cb = find_read_list_entry(dev, cl);
- if (write_cb) {
- list_del(&write_cb->cb_list);
- mei_free_cb_private(write_cb);
- write_cb = NULL;
- cl->reading_state = MEI_IDLE;
- cl->read_cb = NULL;
- cl->read_pending = 0;
- }
- } else if (cl->reading_state == MEI_IDLE && !cl->read_pending)
- *offset = 0;
-
-
- write_cb = kzalloc(sizeof(struct mei_cl_cb), GFP_KERNEL);
- if (!write_cb) {
- mutex_unlock(&dev->device_lock);
- return -ENOMEM;
- }
-
- write_cb->file_object = file;
- write_cb->file_private = cl;
- write_cb->request_buffer.data = kmalloc(length, GFP_KERNEL);
- rets = -ENOMEM;
- if (!write_cb->request_buffer.data)
- goto unlock_dev;
-
- dev_dbg(&dev->pdev->dev, "length =%d\n", (int) length);
-
- rets = -EFAULT;
- if (copy_from_user(write_cb->request_buffer.data, ubuf, length))
- goto unlock_dev;
-
- cl->sm_state = 0;
- if (length == 4 &&
- ((memcmp(mei_wd_state_independence_msg[0],
- write_cb->request_buffer.data, 4) == 0) ||
- (memcmp(mei_wd_state_independence_msg[1],
- write_cb->request_buffer.data, 4) == 0) ||
- (memcmp(mei_wd_state_independence_msg[2],
- write_cb->request_buffer.data, 4) == 0)))
- cl->sm_state |= MEI_WD_STATE_INDEPENDENCE_MSG_SENT;
-
- INIT_LIST_HEAD(&write_cb->cb_list);
- if (cl == &dev->iamthif_cl) {
- write_cb->response_buffer.data =
- kmalloc(dev->iamthif_mtu, GFP_KERNEL);
- if (!write_cb->response_buffer.data) {
- rets = -ENOMEM;
- goto unlock_dev;
- }
- if (dev->mei_state != MEI_ENABLED) {
- rets = -ENODEV;
- goto unlock_dev;
- }
- for (i = 0; i < dev->me_clients_num; i++) {
- if (dev->me_clients[i].client_id ==
- dev->iamthif_cl.me_client_id)
- break;
- }
-
- if (WARN_ON(dev->me_clients[i].client_id != cl->me_client_id)) {
- rets = -ENODEV;
- goto unlock_dev;
- }
- if (i == dev->me_clients_num ||
- (dev->me_clients[i].client_id !=
- dev->iamthif_cl.me_client_id)) {
- rets = -ENODEV;
- goto unlock_dev;
- } else if (length > dev->me_clients[i].props.max_msg_length ||
- length <= 0) {
- rets = -EMSGSIZE;
- goto unlock_dev;
- }
-
- write_cb->response_buffer.size = dev->iamthif_mtu;
- write_cb->major_file_operations = MEI_IOCTL;
- write_cb->information = 0;
- write_cb->request_buffer.size = length;
- if (dev->iamthif_cl.state != MEI_FILE_CONNECTED) {
- rets = -ENODEV;
- goto unlock_dev;
- }
-
- if (!list_empty(&dev->amthi_cmd_list.mei_cb.cb_list) ||
- dev->iamthif_state != MEI_IAMTHIF_IDLE) {
- dev_dbg(&dev->pdev->dev, "amthi_state = %d\n",
- (int) dev->iamthif_state);
- dev_dbg(&dev->pdev->dev, "add amthi cb to amthi cmd waiting list\n");
- list_add_tail(&write_cb->cb_list,
- &dev->amthi_cmd_list.mei_cb.cb_list);
- rets = length;
- } else {
- dev_dbg(&dev->pdev->dev, "call amthi write\n");
- rets = amthi_write(dev, write_cb);
-
- if (rets) {
- dev_dbg(&dev->pdev->dev, "amthi write failed with status = %d\n",
- rets);
- goto unlock_dev;
- }
- rets = length;
- }
- mutex_unlock(&dev->device_lock);
- return rets;
- }
-
- write_cb->major_file_operations = MEI_WRITE;
- /* make sure information is zero before we start */
-
- write_cb->information = 0;
- write_cb->request_buffer.size = length;
-
- dev_dbg(&dev->pdev->dev, "host client = %d, ME client = %d\n",
- cl->host_client_id, cl->me_client_id);
- if (cl->state != MEI_FILE_CONNECTED) {
- rets = -ENODEV;
- dev_dbg(&dev->pdev->dev, "host client = %d, is not connected to ME client = %d",
- cl->host_client_id,
- cl->me_client_id);
- goto unlock_dev;
- }
- for (i = 0; i < dev->me_clients_num; i++) {
- if (dev->me_clients[i].client_id ==
- cl->me_client_id)
- break;
- }
- if (WARN_ON(dev->me_clients[i].client_id != cl->me_client_id)) {
- rets = -ENODEV;
- goto unlock_dev;
- }
- if (i == dev->me_clients_num) {
- rets = -ENODEV;
- goto unlock_dev;
- }
- if (length > dev->me_clients[i].props.max_msg_length || length <= 0) {
- rets = -EINVAL;
- goto unlock_dev;
- }
- write_cb->file_private = cl;
-
- rets = mei_flow_ctrl_creds(dev, cl);
- if (rets < 0)
- goto unlock_dev;
-
- if (rets && dev->mei_host_buffer_is_empty) {
- rets = 0;
- dev->mei_host_buffer_is_empty = false;
- if (length > ((((dev->host_hw_state & H_CBD) >> 24) *
- sizeof(u32)) - sizeof(struct mei_msg_hdr))) {
-
- mei_hdr.length =
- (((dev->host_hw_state & H_CBD) >> 24) *
- sizeof(u32)) -
- sizeof(struct mei_msg_hdr);
- mei_hdr.msg_complete = 0;
- } else {
- mei_hdr.length = length;
- mei_hdr.msg_complete = 1;
- }
- mei_hdr.host_addr = cl->host_client_id;
- mei_hdr.me_addr = cl->me_client_id;
- mei_hdr.reserved = 0;
- dev_dbg(&dev->pdev->dev, "call mei_write_message header=%08x.\n",
- *((u32 *) &mei_hdr));
- if (mei_write_message(dev, &mei_hdr,
- (unsigned char *) (write_cb->request_buffer.data),
- mei_hdr.length)) {
- rets = -ENODEV;
- goto unlock_dev;
- }
- cl->writing_state = MEI_WRITING;
- write_cb->information = mei_hdr.length;
- if (mei_hdr.msg_complete) {
- if (mei_flow_ctrl_reduce(dev, cl)) {
- rets = -ENODEV;
- goto unlock_dev;
- }
- list_add_tail(&write_cb->cb_list,
- &dev->write_waiting_list.mei_cb.cb_list);
- } else {
- list_add_tail(&write_cb->cb_list,
- &dev->write_list.mei_cb.cb_list);
- }
-
- } else {
-
- write_cb->information = 0;
- cl->writing_state = MEI_WRITING;
- list_add_tail(&write_cb->cb_list,
- &dev->write_list.mei_cb.cb_list);
- }
- mutex_unlock(&dev->device_lock);
- return length;
-
-unlock_dev:
- mutex_unlock(&dev->device_lock);
- mei_free_cb_private(write_cb);
- return rets;
-}
-
-
-/**
- * mei_ioctl - the IOCTL function
- *
- * @file: pointer to file structure
- * @cmd: ioctl command
- * @data: pointer to mei message structure
- *
- * returns 0 on success , <0 on error
- */
-static long mei_ioctl(struct file *file, unsigned int cmd, unsigned long data)
-{
- struct mei_device *dev;
- struct mei_cl *cl = file->private_data;
- struct mei_connect_client_data *connect_data = NULL;
- int rets;
-
- if (cmd != IOCTL_MEI_CONNECT_CLIENT)
- return -EINVAL;
-
- if (WARN_ON(!cl || !cl->dev))
- return -ENODEV;
-
- dev = cl->dev;
-
- dev_dbg(&dev->pdev->dev, "IOCTL cmd = 0x%x", cmd);
-
- mutex_lock(&dev->device_lock);
- if (dev->mei_state != MEI_ENABLED) {
- rets = -ENODEV;
- goto out;
- }
-
- dev_dbg(&dev->pdev->dev, ": IOCTL_MEI_CONNECT_CLIENT.\n");
-
- connect_data = kzalloc(sizeof(struct mei_connect_client_data),
- GFP_KERNEL);
- if (!connect_data) {
- rets = -ENOMEM;
- goto out;
- }
- dev_dbg(&dev->pdev->dev, "copy connect data from user\n");
- if (copy_from_user(connect_data, (char __user *)data,
- sizeof(struct mei_connect_client_data))) {
- dev_dbg(&dev->pdev->dev, "failed to copy data from userland\n");
- rets = -EFAULT;
- goto out;
- }
- rets = mei_ioctl_connect_client(file, connect_data);
-
- /* if all is ok, copying the data back to user. */
- if (rets)
- goto out;
-
- dev_dbg(&dev->pdev->dev, "copy connect data to user\n");
- if (copy_to_user((char __user *)data, connect_data,
- sizeof(struct mei_connect_client_data))) {
- dev_dbg(&dev->pdev->dev, "failed to copy data to userland\n");
- rets = -EFAULT;
- goto out;
- }
-
-out:
- kfree(connect_data);
- mutex_unlock(&dev->device_lock);
- return rets;
-}
-
-/**
- * mei_compat_ioctl - the compat IOCTL function
- *
- * @file: pointer to file structure
- * @cmd: ioctl command
- * @data: pointer to mei message structure
- *
- * returns 0 on success , <0 on error
- */
-#ifdef CONFIG_COMPAT
-static long mei_compat_ioctl(struct file *file,
- unsigned int cmd, unsigned long data)
-{
- return mei_ioctl(file, cmd, (unsigned long)compat_ptr(data));
-}
-#endif
-
-
-/**
- * mei_poll - the poll function
- *
- * @file: pointer to file structure
- * @wait: pointer to poll_table structure
- *
- * returns poll mask
- */
-static unsigned int mei_poll(struct file *file, poll_table *wait)
-{
- struct mei_cl *cl = file->private_data;
- struct mei_device *dev;
- unsigned int mask = 0;
-
- if (WARN_ON(!cl || !cl->dev))
- return mask;
-
- dev = cl->dev;
-
- mutex_lock(&dev->device_lock);
-
- if (dev->mei_state != MEI_ENABLED)
- goto out;
-
-
- if (cl == &dev->iamthif_cl) {
- mutex_unlock(&dev->device_lock);
- poll_wait(file, &dev->iamthif_cl.wait, wait);
- mutex_lock(&dev->device_lock);
- if (dev->iamthif_state == MEI_IAMTHIF_READ_COMPLETE &&
- dev->iamthif_file_object == file) {
- mask |= (POLLIN | POLLRDNORM);
- dev_dbg(&dev->pdev->dev, "run next amthi cb\n");
- mei_run_next_iamthif_cmd(dev);
- }
- goto out;
- }
-
- mutex_unlock(&dev->device_lock);
- poll_wait(file, &cl->tx_wait, wait);
- mutex_lock(&dev->device_lock);
- if (MEI_WRITE_COMPLETE == cl->writing_state)
- mask |= (POLLIN | POLLRDNORM);
-
-out:
- mutex_unlock(&dev->device_lock);
- return mask;
-}
-
-/*
- * file operations structure will be used for mei char device.
- */
-static const struct file_operations mei_fops = {
- .owner = THIS_MODULE,
- .read = mei_read,
- .unlocked_ioctl = mei_ioctl,
-#ifdef CONFIG_COMPAT
- .compat_ioctl = mei_compat_ioctl,
-#endif
- .open = mei_open,
- .release = mei_release,
- .write = mei_write,
- .poll = mei_poll,
- .llseek = no_llseek
-};
-
-
-/*
- * Misc Device Struct
- */
-static struct miscdevice mei_misc_device = {
- .name = MEI_DRIVER_NAME,
- .fops = &mei_fops,
- .minor = MISC_DYNAMIC_MINOR,
-};
-
-/**
- * mei_probe - Device Initialization Routine
- *
- * @pdev: PCI device structure
- * @ent: entry in kcs_pci_tbl
- *
- * returns 0 on success, <0 on failure.
- */
-static int __devinit mei_probe(struct pci_dev *pdev,
- const struct pci_device_id *ent)
-{
- struct mei_device *dev;
- int err;
-
- mutex_lock(&mei_mutex);
- if (mei_device) {
- err = -EEXIST;
- goto end;
- }
- /* enable pci dev */
- err = pci_enable_device(pdev);
- if (err) {
- printk(KERN_ERR "mei: Failed to enable pci device.\n");
- goto end;
- }
- /* set PCI host mastering */
- pci_set_master(pdev);
- /* pci request regions for mei driver */
- err = pci_request_regions(pdev, mei_driver_name);
- if (err) {
- printk(KERN_ERR "mei: Failed to get pci regions.\n");
- goto disable_device;
- }
- /* allocates and initializes the mei dev structure */
- dev = mei_device_init(pdev);
- if (!dev) {
- err = -ENOMEM;
- goto release_regions;
- }
- /* mapping IO device memory */
- dev->mem_addr = pci_iomap(pdev, 0, 0);
- if (!dev->mem_addr) {
- printk(KERN_ERR "mei: mapping I/O device memory failure.\n");
- err = -ENOMEM;
- goto free_device;
- }
- pci_enable_msi(pdev);
-
- /* request and enable interrupt */
- if (pci_dev_msi_enabled(pdev))
- err = request_threaded_irq(pdev->irq,
- NULL,
- mei_interrupt_thread_handler,
- 0, mei_driver_name, dev);
- else
- err = request_threaded_irq(pdev->irq,
- mei_interrupt_quick_handler,
- mei_interrupt_thread_handler,
- IRQF_SHARED, mei_driver_name, dev);
-
- if (err) {
- printk(KERN_ERR "mei: request_threaded_irq failure. irq = %d\n",
- pdev->irq);
- goto unmap_memory;
- }
- INIT_DELAYED_WORK(&dev->timer_work, mei_timer);
- if (mei_hw_init(dev)) {
- printk(KERN_ERR "mei: Init hw failure.\n");
- err = -ENODEV;
- goto release_irq;
- }
-
- err = misc_register(&mei_misc_device);
- if (err)
- goto release_irq;
-
- mei_device = pdev;
- pci_set_drvdata(pdev, dev);
-
-
- schedule_delayed_work(&dev->timer_work, HZ);
-
- mutex_unlock(&mei_mutex);
-
- pr_debug("mei: Driver initialization successful.\n");
-
- return 0;
-
-release_irq:
- /* disable interrupts */
- dev->host_hw_state = mei_hcsr_read(dev);
- mei_disable_interrupts(dev);
- flush_scheduled_work();
- free_irq(pdev->irq, dev);
- pci_disable_msi(pdev);
-unmap_memory:
- pci_iounmap(pdev, dev->mem_addr);
-free_device:
- kfree(dev);
-release_regions:
- pci_release_regions(pdev);
-disable_device:
- pci_disable_device(pdev);
-end:
- mutex_unlock(&mei_mutex);
- printk(KERN_ERR "mei: Driver initialization failed.\n");
- return err;
-}
-
-/**
- * mei_remove - Device Removal Routine
- *
- * @pdev: PCI device structure
- *
- * mei_remove is called by the PCI subsystem to alert the driver
- * that it should release a PCI device.
- */
-static void __devexit mei_remove(struct pci_dev *pdev)
-{
- struct mei_device *dev;
-
- if (mei_device != pdev)
- return;
-
- dev = pci_get_drvdata(pdev);
- if (!dev)
- return;
-
- mutex_lock(&dev->device_lock);
-
- mei_wd_stop(dev, false);
-
- mei_device = NULL;
-
- if (dev->iamthif_cl.state == MEI_FILE_CONNECTED) {
- dev->iamthif_cl.state = MEI_FILE_DISCONNECTING;
- mei_disconnect_host_client(dev, &dev->iamthif_cl);
- }
- if (dev->wd_cl.state == MEI_FILE_CONNECTED) {
- dev->wd_cl.state = MEI_FILE_DISCONNECTING;
- mei_disconnect_host_client(dev, &dev->wd_cl);
- }
-
- /* Unregistering watchdog device */
- mei_watchdog_unregister(dev);
-
- /* remove entry if already in list */
- dev_dbg(&pdev->dev, "list del iamthif and wd file list.\n");
- mei_remove_client_from_file_list(dev, dev->wd_cl.host_client_id);
- mei_remove_client_from_file_list(dev, dev->iamthif_cl.host_client_id);
-
- dev->iamthif_current_cb = NULL;
- dev->me_clients_num = 0;
-
- mutex_unlock(&dev->device_lock);
-
- flush_scheduled_work();
-
- /* disable interrupts */
- mei_disable_interrupts(dev);
-
- free_irq(pdev->irq, dev);
- pci_disable_msi(pdev);
- pci_set_drvdata(pdev, NULL);
-
- if (dev->mem_addr)
- pci_iounmap(pdev, dev->mem_addr);
-
- kfree(dev);
-
- pci_release_regions(pdev);
- pci_disable_device(pdev);
-}
-#ifdef CONFIG_PM
-static int mei_pci_suspend(struct device *device)
-{
- struct pci_dev *pdev = to_pci_dev(device);
- struct mei_device *dev = pci_get_drvdata(pdev);
- int err;
-
- if (!dev)
- return -ENODEV;
- mutex_lock(&dev->device_lock);
- /* Stop watchdog if exists */
- err = mei_wd_stop(dev, true);
- /* Set new mei state */
- if (dev->mei_state == MEI_ENABLED ||
- dev->mei_state == MEI_RECOVERING_FROM_RESET) {
- dev->mei_state = MEI_POWER_DOWN;
- mei_reset(dev, 0);
- }
- mutex_unlock(&dev->device_lock);
-
- free_irq(pdev->irq, dev);
- pci_disable_msi(pdev);
-
- return err;
-}
-
-static int mei_pci_resume(struct device *device)
-{
- struct pci_dev *pdev = to_pci_dev(device);
- struct mei_device *dev;
- int err;
-
- dev = pci_get_drvdata(pdev);
- if (!dev)
- return -ENODEV;
-
- pci_enable_msi(pdev);
-
- /* request and enable interrupt */
- if (pci_dev_msi_enabled(pdev))
- err = request_threaded_irq(pdev->irq,
- NULL,
- mei_interrupt_thread_handler,
- 0, mei_driver_name, dev);
- else
- err = request_threaded_irq(pdev->irq,
- mei_interrupt_quick_handler,
- mei_interrupt_thread_handler,
- IRQF_SHARED, mei_driver_name, dev);
-
- if (err) {
- printk(KERN_ERR "mei: Request_irq failure. irq = %d\n",
- pdev->irq);
- return err;
- }
-
- mutex_lock(&dev->device_lock);
- dev->mei_state = MEI_POWER_UP;
- mei_reset(dev, 1);
- mutex_unlock(&dev->device_lock);
-
- /* Start timer if stopped in suspend */
- schedule_delayed_work(&dev->timer_work, HZ);
-
- return err;
-}
-static SIMPLE_DEV_PM_OPS(mei_pm_ops, mei_pci_suspend, mei_pci_resume);
-#define MEI_PM_OPS (&mei_pm_ops)
-#else
-#define MEI_PM_OPS NULL
-#endif /* CONFIG_PM */
-/*
- * PCI driver structure
- */
-static struct pci_driver mei_driver = {
- .name = mei_driver_name,
- .id_table = mei_pci_tbl,
- .probe = mei_probe,
- .remove = __devexit_p(mei_remove),
- .shutdown = __devexit_p(mei_remove),
- .driver.pm = MEI_PM_OPS,
-};
-
-/**
- * mei_init_module - Driver Registration Routine
- *
- * mei_init_module is the first routine called when the driver is
- * loaded. All it does is to register with the PCI subsystem.
- *
- * returns 0 on success, <0 on failure.
- */
-static int __init mei_init_module(void)
-{
- int ret;
-
- pr_debug("mei: %s\n", mei_driver_string);
- /* init pci module */
- ret = pci_register_driver(&mei_driver);
- if (ret < 0)
- printk(KERN_ERR "mei: Error registering driver.\n");
-
- return ret;
-}
-
-module_init(mei_init_module);
-
-/**
- * mei_exit_module - Driver Exit Cleanup Routine
- *
- * mei_exit_module is called just before the driver is removed
- * from memory.
- */
-static void __exit mei_exit_module(void)
-{
- misc_deregister(&mei_misc_device);
- pci_unregister_driver(&mei_driver);
-
- pr_debug("mei: Driver unloaded successfully.\n");
-}
-
-module_exit(mei_exit_module);
-
-
-MODULE_AUTHOR("Intel Corporation");
-MODULE_DESCRIPTION("Intel(R) Management Engine Interface");
-MODULE_LICENSE("GPL v2");
diff --git a/drivers/staging/mei/mei-amt-version.c b/drivers/staging/mei/mei-amt-version.c
deleted file mode 100644
index ac2a507be253..000000000000
--- a/drivers/staging/mei/mei-amt-version.c
+++ /dev/null
@@ -1,481 +0,0 @@
-/******************************************************************************
- * Intel Management Engine Interface (Intel MEI) Linux driver
- * Intel MEI Interface Header
- *
- * This file is provided under a dual BSD/GPLv2 license. When using or
- * redistributing this file, you may do so under either license.
- *
- * GPL LICENSE SUMMARY
- *
- * Copyright(c) 2012 Intel Corporation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110,
- * USA
- *
- * The full GNU General Public License is included in this distribution
- * in the file called LICENSE.GPL.
- *
- * Contact Information:
- * Intel Corporation.
- * linux-mei@linux.intel.com
- * http://www.intel.com
- *
- * BSD LICENSE
- *
- * Copyright(c) 2003 - 2012 Intel Corporation. All rights reserved.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * * Neither the name Intel Corporation nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- *****************************************************************************/
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <fcntl.h>
-#include <sys/ioctl.h>
-#include <unistd.h>
-#include <errno.h>
-#include <stdint.h>
-#include <stdbool.h>
-#include <bits/wordsize.h>
-#include "mei.h"
-
-/*****************************************************************************
- * Intel Management Engine Interface
- *****************************************************************************/
-
-#define mei_msg(_me, fmt, ARGS...) do { \
- if (_me->verbose) \
- fprintf(stderr, fmt, ##ARGS); \
-} while (0)
-
-#define mei_err(_me, fmt, ARGS...) do { \
- fprintf(stderr, "Error: " fmt, ##ARGS); \
-} while (0)
-
-struct mei {
- uuid_le guid;
- bool initialized;
- bool verbose;
- unsigned int buf_size;
- unsigned char prot_ver;
- int fd;
-};
-
-static void mei_deinit(struct mei *cl)
-{
- if (cl->fd != -1)
- close(cl->fd);
- cl->fd = -1;
- cl->buf_size = 0;
- cl->prot_ver = 0;
- cl->initialized = false;
-}
-
-static bool mei_init(struct mei *me, const uuid_le *guid,
- unsigned char req_protocol_version, bool verbose)
-{
- int result;
- struct mei_client *cl;
- struct mei_connect_client_data data;
-
- mei_deinit(me);
-
- me->verbose = verbose;
-
- me->fd = open("/dev/mei", O_RDWR);
- if (me->fd == -1) {
- mei_err(me, "Cannot establish a handle to the Intel MEI driver\n");
- goto err;
- }
- memcpy(&me->guid, guid, sizeof(*guid));
- memset(&data, 0, sizeof(data));
- me->initialized = true;
-
- memcpy(&data.in_client_uuid, &me->guid, sizeof(me->guid));
- result = ioctl(me->fd, IOCTL_MEI_CONNECT_CLIENT, &data);
- if (result) {
- mei_err(me, "IOCTL_MEI_CONNECT_CLIENT receive message. err=%d\n", result);
- goto err;
- }
- cl = &data.out_client_properties;
- mei_msg(me, "max_message_length %d\n", cl->max_msg_length);
- mei_msg(me, "protocol_version %d\n", cl->protocol_version);
-
- if ((req_protocol_version > 0) &&
- (cl->protocol_version != req_protocol_version)) {
- mei_err(me, "Intel MEI protocol version not supported\n");
- goto err;
- }
-
- me->buf_size = cl->max_msg_length;
- me->prot_ver = cl->protocol_version;
-
- return true;
-err:
- mei_deinit(me);
- return false;
-}
-
-static ssize_t mei_recv_msg(struct mei *me, unsigned char *buffer,
- ssize_t len, unsigned long timeout)
-{
- ssize_t rc;
-
- mei_msg(me, "call read length = %zd\n", len);
-
- rc = read(me->fd, buffer, len);
- if (rc < 0) {
- mei_err(me, "read failed with status %zd %s\n",
- rc, strerror(errno));
- mei_deinit(me);
- } else {
- mei_msg(me, "read succeeded with result %zd\n", rc);
- }
- return rc;
-}
-
-static ssize_t mei_send_msg(struct mei *me, const unsigned char *buffer,
- ssize_t len, unsigned long timeout)
-{
- struct timeval tv;
- ssize_t written;
- ssize_t rc;
- fd_set set;
-
- tv.tv_sec = timeout / 1000;
- tv.tv_usec = (timeout % 1000) * 1000000;
-
- mei_msg(me, "call write length = %zd\n", len);
-
- written = write(me->fd, buffer, len);
- if (written < 0) {
- rc = -errno;
- mei_err(me, "write failed with status %zd %s\n",
- written, strerror(errno));
- goto out;
- }
-
- FD_ZERO(&set);
- FD_SET(me->fd, &set);
- rc = select(me->fd + 1 , &set, NULL, NULL, &tv);
- if (rc > 0 && FD_ISSET(me->fd, &set)) {
- mei_msg(me, "write success\n");
- } else if (rc == 0) {
- mei_err(me, "write failed on timeout with status\n");
- goto out;
- } else { /* rc < 0 */
- mei_err(me, "write failed on select with status %zd\n", rc);
- goto out;
- }
-
- rc = written;
-out:
- if (rc < 0)
- mei_deinit(me);
-
- return rc;
-}
-
-/***************************************************************************
- * Intel Advanced Management Technolgy ME Client
- ***************************************************************************/
-
-#define AMT_MAJOR_VERSION 1
-#define AMT_MINOR_VERSION 1
-
-#define AMT_STATUS_SUCCESS 0x0
-#define AMT_STATUS_INTERNAL_ERROR 0x1
-#define AMT_STATUS_NOT_READY 0x2
-#define AMT_STATUS_INVALID_AMT_MODE 0x3
-#define AMT_STATUS_INVALID_MESSAGE_LENGTH 0x4
-
-#define AMT_STATUS_HOST_IF_EMPTY_RESPONSE 0x4000
-#define AMT_STATUS_SDK_RESOURCES 0x1004
-
-
-#define AMT_BIOS_VERSION_LEN 65
-#define AMT_VERSIONS_NUMBER 50
-#define AMT_UNICODE_STRING_LEN 20
-
-struct amt_unicode_string {
- uint16_t length;
- char string[AMT_UNICODE_STRING_LEN];
-} __attribute__((packed));
-
-struct amt_version_type {
- struct amt_unicode_string description;
- struct amt_unicode_string version;
-} __attribute__((packed));
-
-struct amt_version {
- uint8_t major;
- uint8_t minor;
-} __attribute__((packed));
-
-struct amt_code_versions {
- uint8_t bios[AMT_BIOS_VERSION_LEN];
- uint32_t count;
- struct amt_version_type versions[AMT_VERSIONS_NUMBER];
-} __attribute__((packed));
-
-/***************************************************************************
- * Intel Advanced Management Technolgy Host Interface
- ***************************************************************************/
-
-struct amt_host_if_msg_header {
- struct amt_version version;
- uint16_t _reserved;
- uint32_t command;
- uint32_t length;
-} __attribute__((packed));
-
-struct amt_host_if_resp_header {
- struct amt_host_if_msg_header header;
- uint32_t status;
- unsigned char data[0];
-} __attribute__((packed));
-
-const uuid_le MEI_IAMTHIF = UUID_LE(0x12f80028, 0xb4b7, 0x4b2d, \
- 0xac, 0xa8, 0x46, 0xe0, 0xff, 0x65, 0x81, 0x4c);
-
-#define AMT_HOST_IF_CODE_VERSIONS_REQUEST 0x0400001A
-#define AMT_HOST_IF_CODE_VERSIONS_RESPONSE 0x0480001A
-
-const struct amt_host_if_msg_header CODE_VERSION_REQ = {
- .version = {AMT_MAJOR_VERSION, AMT_MINOR_VERSION},
- ._reserved = 0,
- .command = AMT_HOST_IF_CODE_VERSIONS_REQUEST,
- .length = 0
-};
-
-
-struct amt_host_if {
- struct mei mei_cl;
- unsigned long send_timeout;
- bool initialized;
-};
-
-
-static bool amt_host_if_init(struct amt_host_if *acmd,
- unsigned long send_timeout, bool verbose)
-{
- acmd->send_timeout = (send_timeout) ? send_timeout : 20000;
- acmd->initialized = mei_init(&acmd->mei_cl, &MEI_IAMTHIF, 0, verbose);
- return acmd->initialized;
-}
-
-static void amt_host_if_deinit(struct amt_host_if *acmd)
-{
- mei_deinit(&acmd->mei_cl);
- acmd->initialized = false;
-}
-
-static uint32_t amt_verify_code_versions(const struct amt_host_if_resp_header *resp)
-{
- uint32_t status = AMT_STATUS_SUCCESS;
- struct amt_code_versions *code_ver;
- size_t code_ver_len;
- uint32_t ver_type_cnt;
- uint32_t len;
- uint32_t i;
-
- code_ver = (struct amt_code_versions *)resp->data;
- /* length - sizeof(status) */
- code_ver_len = resp->header.length - sizeof(uint32_t);
- ver_type_cnt = code_ver_len -
- sizeof(code_ver->bios) -
- sizeof(code_ver->count);
- if (code_ver->count != ver_type_cnt / sizeof(struct amt_version_type)) {
- status = AMT_STATUS_INTERNAL_ERROR;
- goto out;
- }
-
- for (i = 0; i < code_ver->count; i++) {
- len = code_ver->versions[i].description.length;
-
- if (len > AMT_UNICODE_STRING_LEN) {
- status = AMT_STATUS_INTERNAL_ERROR;
- goto out;
- }
-
- len = code_ver->versions[i].version.length;
- if (code_ver->versions[i].version.string[len] != '\0' ||
- len != strlen(code_ver->versions[i].version.string)) {
- status = AMT_STATUS_INTERNAL_ERROR;
- goto out;
- }
- }
-out:
- return status;
-}
-
-static uint32_t amt_verify_response_header(uint32_t command,
- const struct amt_host_if_msg_header *resp_hdr,
- uint32_t response_size)
-{
- if (response_size < sizeof(struct amt_host_if_resp_header)) {
- return AMT_STATUS_INTERNAL_ERROR;
- } else if (response_size != (resp_hdr->length +
- sizeof(struct amt_host_if_msg_header))) {
- return AMT_STATUS_INTERNAL_ERROR;
- } else if (resp_hdr->command != command) {
- return AMT_STATUS_INTERNAL_ERROR;
- } else if (resp_hdr->_reserved != 0) {
- return AMT_STATUS_INTERNAL_ERROR;
- } else if (resp_hdr->version.major != AMT_MAJOR_VERSION ||
- resp_hdr->version.minor < AMT_MINOR_VERSION) {
- return AMT_STATUS_INTERNAL_ERROR;
- }
- return AMT_STATUS_SUCCESS;
-}
-
-static uint32_t amt_host_if_call(struct amt_host_if *acmd,
- const unsigned char *command, ssize_t command_sz,
- uint8_t **read_buf, uint32_t rcmd,
- unsigned int expected_sz)
-{
- uint32_t in_buf_sz;
- uint32_t out_buf_sz;
- ssize_t written;
- uint32_t status;
- struct amt_host_if_resp_header *msg_hdr;
-
- in_buf_sz = acmd->mei_cl.buf_size;
- *read_buf = (uint8_t *)malloc(sizeof(uint8_t) * in_buf_sz);
- if (*read_buf == NULL)
- return AMT_STATUS_SDK_RESOURCES;
- memset(*read_buf, 0, in_buf_sz);
- msg_hdr = (struct amt_host_if_resp_header *)*read_buf;
-
- written = mei_send_msg(&acmd->mei_cl,
- command, command_sz, acmd->send_timeout);
- if (written != command_sz)
- return AMT_STATUS_INTERNAL_ERROR;
-
- out_buf_sz = mei_recv_msg(&acmd->mei_cl, *read_buf, in_buf_sz, 2000);
- if (out_buf_sz <= 0)
- return AMT_STATUS_HOST_IF_EMPTY_RESPONSE;
-
- status = msg_hdr->status;
- if (status != AMT_STATUS_SUCCESS)
- return status;
-
- status = amt_verify_response_header(rcmd,
- &msg_hdr->header, out_buf_sz);
- if (status != AMT_STATUS_SUCCESS)
- return status;
-
- if (expected_sz && expected_sz != out_buf_sz)
- return AMT_STATUS_INTERNAL_ERROR;
-
- return AMT_STATUS_SUCCESS;
-}
-
-
-static uint32_t amt_get_code_versions(struct amt_host_if *cmd,
- struct amt_code_versions *versions)
-{
- struct amt_host_if_resp_header *response = NULL;
- uint32_t status;
-
- status = amt_host_if_call(cmd,
- (const unsigned char *)&CODE_VERSION_REQ,
- sizeof(CODE_VERSION_REQ),
- (uint8_t **)&response,
- AMT_HOST_IF_CODE_VERSIONS_RESPONSE, 0);
-
- if (status != AMT_STATUS_SUCCESS)
- goto out;
-
- status = amt_verify_code_versions(response);
- if (status != AMT_STATUS_SUCCESS)
- goto out;
-
- memcpy(versions, response->data, sizeof(struct amt_code_versions));
-out:
- if (response != NULL)
- free(response);
-
- return status;
-}
-
-/************************** end of amt_host_if_command ***********************/
-int main(int argc, char **argv)
-{
- struct amt_code_versions ver;
- struct amt_host_if acmd;
- unsigned int i;
- uint32_t status;
- int ret;
- bool verbose;
-
- verbose = (argc > 1 && strcmp(argv[1], "-v") == 0);
-
- if (!amt_host_if_init(&acmd, 5000, verbose)) {
- ret = 1;
- goto out;
- }
-
- status = amt_get_code_versions(&acmd, &ver);
-
- amt_host_if_deinit(&acmd);
-
- switch (status) {
- case AMT_STATUS_HOST_IF_EMPTY_RESPONSE:
- printf("Intel AMT: DISABLED\n");
- ret = 0;
- break;
- case AMT_STATUS_SUCCESS:
- printf("Intel AMT: ENABLED\n");
- for (i = 0; i < ver.count; i++) {
- printf("%s:\t%s\n", ver.versions[i].description.string,
- ver.versions[i].version.string);
- }
- ret = 0;
- break;
- default:
- printf("An error has occurred\n");
- ret = 1;
- break;
- }
-
-out:
- return ret;
-}
diff --git a/drivers/staging/mei/mei.h b/drivers/staging/mei/mei.h
deleted file mode 100644
index bc0d8b69c49e..000000000000
--- a/drivers/staging/mei/mei.h
+++ /dev/null
@@ -1,110 +0,0 @@
-/******************************************************************************
- * Intel Management Engine Interface (Intel MEI) Linux driver
- * Intel MEI Interface Header
- *
- * This file is provided under a dual BSD/GPLv2 license. When using or
- * redistributing this file, you may do so under either license.
- *
- * GPL LICENSE SUMMARY
- *
- * Copyright(c) 2003 - 2012 Intel Corporation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110,
- * USA
- *
- * The full GNU General Public License is included in this distribution
- * in the file called LICENSE.GPL.
- *
- * Contact Information:
- * Intel Corporation.
- * linux-mei@linux.intel.com
- * http://www.intel.com
- *
- * BSD LICENSE
- *
- * Copyright(c) 2003 - 2012 Intel Corporation. All rights reserved.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * * Neither the name Intel Corporation nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- *****************************************************************************/
-
-#ifndef _LINUX_MEI_H
-#define _LINUX_MEI_H
-
-#include <linux/uuid.h>
-
-/*
- * This IOCTL is used to associate the current file descriptor with a
- * FW Client (given by UUID). This opens a communication channel
- * between a host client and a FW client. From this point every read and write
- * will communicate with the associated FW client.
- * Only in close() (file_operation release()) the communication between
- * the clients is disconnected
- *
- * The IOCTL argument is a struct with a union that contains
- * the input parameter and the output parameter for this IOCTL.
- *
- * The input parameter is UUID of the FW Client.
- * The output parameter is the properties of the FW client
- * (FW protocol version and max message size).
- *
- */
-#define IOCTL_MEI_CONNECT_CLIENT \
- _IOWR('H' , 0x01, struct mei_connect_client_data)
-
-/*
- * Intel MEI client information struct
- */
-struct mei_client {
- __u32 max_msg_length;
- __u8 protocol_version;
- __u8 reserved[3];
-};
-
-/*
- * IOCTL Connect Client Data structure
- */
-struct mei_connect_client_data {
- union {
- uuid_le in_client_uuid;
- struct mei_client out_client_properties;
- };
-};
-
-#endif /* _LINUX_MEI_H */
diff --git a/drivers/staging/mei/mei.txt b/drivers/staging/mei/mei.txt
deleted file mode 100644
index 2785697da59d..000000000000
--- a/drivers/staging/mei/mei.txt
+++ /dev/null
@@ -1,215 +0,0 @@
-Intel(R) Management Engine Interface (Intel(R) MEI)
-=======================
-
-Introduction
-=======================
-
-The Intel Management Engine (Intel ME) is an isolated and protected computing
-resource (Co-processor) residing inside certain Intel chipsets. The Intel ME
-provides support for computer/IT management features. The feature set
-depends on the Intel chipset SKU.
-
-The Intel Management Engine Interface (Intel MEI, previously known as HECI)
-is the interface between the Host and Intel ME. This interface is exposed
-to the host as a PCI device. The Intel MEI Driver is in charge of the
-communication channel between a host application and the Intel ME feature.
-
-Each Intel ME feature (Intel ME Client) is addressed by a GUID/UUID and
-each client has its own protocol. The protocol is message-based with a
-header and payload up to 512 bytes.
-
-Prominent usage of the Intel ME Interface is to communicate with Intel(R)
-Active Management Technology (Intel AMT)implemented in firmware running on
-the Intel ME.
-
-Intel AMT provides the ability to manage a host remotely out-of-band (OOB)
-even when the operating system running on the host processor has crashed or
-is in a sleep state.
-
-Some examples of Intel AMT usage are:
- - Monitoring hardware state and platform components
- - Remote power off/on (useful for green computing or overnight IT
- maintenance)
- - OS updates
- - Storage of useful platform information such as software assets
- - Built-in hardware KVM
- - Selective network isolation of Ethernet and IP protocol flows based
- on policies set by a remote management console
- - IDE device redirection from remote management console
-
-Intel AMT (OOB) communication is based on SOAP (deprecated
-starting with Release 6.0) over HTTP/S or WS-Management protocol over
-HTTP/S that are received from a remote management console application.
-
-For more information about Intel AMT:
-http://software.intel.com/sites/manageability/AMT_Implementation_and_Reference_Guide
-
-Intel MEI Driver
-=======================
-
-The driver exposes a misc device called /dev/mei.
-
-An application maintains communication with an Intel ME feature while
-/dev/mei is open. The binding to a specific features is performed by calling
-MEI_CONNECT_CLIENT_IOCTL, which passes the desired UUID.
-The number of instances of an Intel ME feature that can be opened
-at the same time depends on the Intel ME feature, but most of the
-features allow only a single instance.
-
-The Intel AMT Host Interface (Intel AMTHI) feature supports multiple
-simultaneous user applications. Therefore, the Intel MEI driver handles
-this internally by maintaining request queues for the applications.
-
-The driver is oblivious to data that is passed between firmware feature
-and host application.
-
-Because some of the Intel ME features can change the system
-configuration, the driver by default allows only a privileged
-user to access it.
-
-A code snippet for an application communicating with
-Intel AMTHI client:
- struct mei_connect_client_data data;
- fd = open(MEI_DEVICE);
-
- data.d.in_client_uuid = AMTHI_UUID;
-
- ioctl(fd, IOCTL_MEI_CONNECT_CLIENT, &data);
-
- printf("Ver=%d, MaxLen=%ld\n",
- data.d.in_client_uuid.protocol_version,
- data.d.in_client_uuid.max_msg_length);
-
- [...]
-
- write(fd, amthi_req_data, amthi_req_data_len);
-
- [...]
-
- read(fd, &amthi_res_data, amthi_res_data_len);
-
- [...]
- close(fd);
-
-IOCTL:
-======
-The Intel MEI Driver supports the following IOCTL command:
- IOCTL_MEI_CONNECT_CLIENT Connect to firmware Feature (client).
-
- usage:
- struct mei_connect_client_data clientData;
- ioctl(fd, IOCTL_MEI_CONNECT_CLIENT, &clientData);
-
- inputs:
- mei_connect_client_data struct contain the following
- input field:
-
- in_client_uuid - UUID of the FW Feature that needs
- to connect to.
- outputs:
- out_client_properties - Client Properties: MTU and Protocol Version.
-
- error returns:
- EINVAL Wrong IOCTL Number
- ENODEV Device or Connection is not initialized or ready.
- (e.g. Wrong UUID)
- ENOMEM Unable to allocate memory to client internal data.
- EFAULT Fatal Error (e.g. Unable to access user input data)
- EBUSY Connection Already Open
-
- Notes:
- max_msg_length (MTU) in client properties describes the maximum
- data that can be sent or received. (e.g. if MTU=2K, can send
- requests up to bytes 2k and received responses upto 2k bytes).
-
-Intel ME Applications:
-==============
-
-1) Intel Local Management Service (Intel LMS)
-
- Applications running locally on the platform communicate with Intel AMT Release
- 2.0 and later releases in the same way that network applications do via SOAP
- over HTTP (deprecated starting with Release 6.0) or with WS-Management over
- SOAP over HTTP. This means that some Intel AMT features can be accessed from a
- local application using the same network interface as a remote application
- communicating with Intel AMT over the network.
-
- When a local application sends a message addressed to the local Intel AMT host
- name, the Intel LMS, which listens for traffic directed to the host name,
- intercepts the message and routes it to the Intel MEI.
- For more information:
- http://software.intel.com/sites/manageability/AMT_Implementation_and_Reference_Guide
- Under "About Intel AMT" => "Local Access"
-
- For downloading Intel LMS:
- http://software.intel.com/en-us/articles/download-the-latest-intel-amt-open-source-drivers/
-
- The Intel LMS opens a connection using the Intel MEI driver to the Intel LMS
- firmware feature using a defined UUID and then communicates with the feature
- using a protocol called Intel AMT Port Forwarding Protocol(Intel APF protocol).
- The protocol is used to maintain multiple sessions with Intel AMT from a
- single application.
-
- See the protocol specification in the Intel AMT Software Development Kit(SDK)
- http://software.intel.com/sites/manageability/AMT_Implementation_and_Reference_Guide
- Under "SDK Resources" => "Intel(R) vPro(TM) Gateway(MPS)"
- => "Information for Intel(R) vPro(TM) Gateway Developers"
- => "Description of the Intel AMT Port Forwarding (APF)Protocol"
-
- 2) Intel AMT Remote configuration using a Local Agent
- A Local Agent enables IT personnel to configure Intel AMT out-of-the-box
- without requiring installing additional data to enable setup. The remote
- configuration process may involve an ISV-developed remote configuration
- agent that runs on the host.
- For more information:
- http://software.intel.com/sites/manageability/AMT_Implementation_and_Reference_Guide
- Under "Setup and Configuration of Intel AMT" =>
- "SDK Tools Supporting Setup and Configuration" =>
- "Using the Local Agent Sample"
-
- An open source Intel AMT configuration utility, implementing a local agent
- that accesses the Intel MEI driver, can be found here:
- http://software.intel.com/en-us/articles/download-the-latest-intel-amt-open-source-drivers/
-
-
-Intel AMT OS Health Watchdog:
-=============================
-The Intel AMT Watchdog is an OS Health (Hang/Crash) watchdog.
-Whenever the OS hangs or crashes, Intel AMT will send an event
-to any subscriber to this event. This mechanism means that
-IT knows when a platform crashes even when there is a hard failure on the host.
-
-The Intel AMT Watchdog is composed of two parts:
- 1) Firmware feature - receives the heartbeats
- and sends an event when the heartbeats stop.
- 2) Intel MEI driver - connects to the watchdog feature, configures the
- watchdog and sends the heartbeats.
-
-The Intel MEI driver uses the kernel watchdog to configure the Intel AMT
-Watchdog and to send heartbeats to it. The default timeout of the
-watchdog is 120 seconds.
-
-If the Intel AMT Watchdog feature does not exist (i.e. the connection failed),
-the Intel MEI driver will disable the sending of heartbeats.
-
-Supported Chipsets:
-==================
-7 Series Chipset Family
-6 Series Chipset Family
-5 Series Chipset Family
-4 Series Chipset Family
-Mobile 4 Series Chipset Family
-ICH9
-82946GZ/GL
-82G35 Express
-82Q963/Q965
-82P965/G965
-Mobile PM965/GM965
-Mobile GME965/GLE960
-82Q35 Express
-82G33/G31/P35/P31 Express
-82Q33 Express
-82X38/X48 Express
-
----
-linux-mei@linux.intel.com
diff --git a/drivers/staging/mei/mei_dev.h b/drivers/staging/mei/mei_dev.h
deleted file mode 100644
index 10b1b4e2f8ac..000000000000
--- a/drivers/staging/mei/mei_dev.h
+++ /dev/null
@@ -1,428 +0,0 @@
-/*
- *
- * Intel Management Engine Interface (Intel MEI) Linux driver
- * Copyright (c) 2003-2012, Intel Corporation.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms and conditions of the GNU General Public License,
- * version 2, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- */
-
-#ifndef _MEI_DEV_H_
-#define _MEI_DEV_H_
-
-#include <linux/types.h>
-#include <linux/watchdog.h>
-#include "mei.h"
-#include "hw.h"
-
-/*
- * watch dog definition
- */
-#define MEI_WATCHDOG_DATA_SIZE 16
-#define MEI_START_WD_DATA_SIZE 20
-#define MEI_WD_PARAMS_SIZE 4
-#define MEI_WD_STATE_INDEPENDENCE_MSG_SENT (1 << 0)
-
-#define MEI_RD_MSG_BUF_SIZE (128 * sizeof(u32))
-
-/*
- * MEI PCI Device object
- */
-extern struct pci_dev *mei_device;
-
-
-/*
- * AMTHI Client UUID
- */
-extern const uuid_le mei_amthi_guid;
-
-/*
- * Watchdog Client UUID
- */
-extern const uuid_le mei_wd_guid;
-
-/*
- * Watchdog independence state message
- */
-extern const u8 mei_wd_state_independence_msg[3][4];
-
-/*
- * Number of File descriptors/handles
- * that can be opened to the driver.
- *
- * Limit to 253: 255 Total Clients
- * minus internal client for AMTHI
- * minus internal client for Watchdog
- */
-#define MEI_MAX_OPEN_HANDLE_COUNT 253
-
-/*
- * Number of Maximum MEI Clients
- */
-#define MEI_CLIENTS_MAX 255
-
-/* File state */
-enum file_state {
- MEI_FILE_INITIALIZING = 0,
- MEI_FILE_CONNECTING,
- MEI_FILE_CONNECTED,
- MEI_FILE_DISCONNECTING,
- MEI_FILE_DISCONNECTED
-};
-
-/* MEI device states */
-enum mei_states {
- MEI_INITIALIZING = 0,
- MEI_INIT_CLIENTS,
- MEI_ENABLED,
- MEI_RESETING,
- MEI_DISABLED,
- MEI_RECOVERING_FROM_RESET,
- MEI_POWER_DOWN,
- MEI_POWER_UP
-};
-
-/* init clients states*/
-enum mei_init_clients_states {
- MEI_START_MESSAGE = 0,
- MEI_ENUM_CLIENTS_MESSAGE,
- MEI_CLIENT_PROPERTIES_MESSAGE
-};
-
-enum iamthif_states {
- MEI_IAMTHIF_IDLE,
- MEI_IAMTHIF_WRITING,
- MEI_IAMTHIF_FLOW_CONTROL,
- MEI_IAMTHIF_READING,
- MEI_IAMTHIF_READ_COMPLETE
-};
-
-enum mei_file_transaction_states {
- MEI_IDLE,
- MEI_WRITING,
- MEI_WRITE_COMPLETE,
- MEI_FLOW_CONTROL,
- MEI_READING,
- MEI_READ_COMPLETE
-};
-
-/* MEI CB */
-enum mei_cb_major_types {
- MEI_READ = 0,
- MEI_WRITE,
- MEI_IOCTL,
- MEI_OPEN,
- MEI_CLOSE
-};
-
-/*
- * Intel MEI message data struct
- */
-struct mei_message_data {
- u32 size;
- unsigned char *data;
-} __packed;
-
-
-struct mei_cl_cb {
- struct list_head cb_list;
- enum mei_cb_major_types major_file_operations;
- void *file_private;
- struct mei_message_data request_buffer;
- struct mei_message_data response_buffer;
- unsigned long information;
- unsigned long read_time;
- struct file *file_object;
-};
-
-/* MEI client instance carried as file->pirvate_data*/
-struct mei_cl {
- struct list_head link;
- struct mei_device *dev;
- enum file_state state;
- wait_queue_head_t tx_wait;
- wait_queue_head_t rx_wait;
- wait_queue_head_t wait;
- int read_pending;
- int status;
- /* ID of client connected */
- u8 host_client_id;
- u8 me_client_id;
- u8 mei_flow_ctrl_creds;
- u8 timer_count;
- enum mei_file_transaction_states reading_state;
- enum mei_file_transaction_states writing_state;
- int sm_state;
- struct mei_cl_cb *read_cb;
-};
-
-struct mei_io_list {
- struct mei_cl_cb mei_cb;
-};
-
-/* MEI private device struct */
-struct mei_device {
- struct pci_dev *pdev; /* pointer to pci device struct */
- /*
- * lists of queues
- */
- /* array of pointers to aio lists */
- struct mei_io_list read_list; /* driver read queue */
- struct mei_io_list write_list; /* driver write queue */
- struct mei_io_list write_waiting_list; /* write waiting queue */
- struct mei_io_list ctrl_wr_list; /* managed write IOCTL list */
- struct mei_io_list ctrl_rd_list; /* managed read IOCTL list */
- struct mei_io_list amthi_cmd_list; /* amthi list for cmd waiting */
-
- /* driver managed amthi list for reading completed amthi cmd data */
- struct mei_io_list amthi_read_complete_list;
- /*
- * list of files
- */
- struct list_head file_list;
- long open_handle_count;
- /*
- * memory of device
- */
- unsigned int mem_base;
- unsigned int mem_length;
- void __iomem *mem_addr;
- /*
- * lock for the device
- */
- struct mutex device_lock; /* device lock */
- struct delayed_work timer_work; /* MEI timer delayed work (timeouts) */
- bool recvd_msg;
- /*
- * hw states of host and fw(ME)
- */
- u32 host_hw_state;
- u32 me_hw_state;
- /*
- * waiting queue for receive message from FW
- */
- wait_queue_head_t wait_recvd_msg;
- wait_queue_head_t wait_stop_wd;
-
- /*
- * mei device states
- */
- enum mei_states mei_state;
- enum mei_init_clients_states init_clients_state;
- u16 init_clients_timer;
- bool stop;
- bool need_reset;
-
- u32 extra_write_index;
- unsigned char rd_msg_buf[MEI_RD_MSG_BUF_SIZE]; /* control messages */
- u32 wr_msg_buf[128]; /* used for control messages */
- u32 ext_msg_buf[8]; /* for control responses */
- u32 rd_msg_hdr;
-
- struct hbm_version version;
-
- struct mei_me_client *me_clients; /* Note: memory has to be allocated */
- DECLARE_BITMAP(me_clients_map, MEI_CLIENTS_MAX);
- DECLARE_BITMAP(host_clients_map, MEI_CLIENTS_MAX);
- u8 me_clients_num;
- u8 me_client_presentation_num;
- u8 me_client_index;
- bool mei_host_buffer_is_empty;
-
- struct mei_cl wd_cl;
- bool wd_pending;
- bool wd_stopped;
- bool wd_bypass; /* if false, don't refresh watchdog ME client */
- u16 wd_timeout; /* seconds ((wd_data[1] << 8) + wd_data[0]) */
- u16 wd_due_counter;
- unsigned char wd_data[MEI_START_WD_DATA_SIZE];
-
-
-
- struct file *iamthif_file_object;
- struct mei_cl iamthif_cl;
- struct mei_cl_cb *iamthif_current_cb;
- int iamthif_mtu;
- unsigned long iamthif_timer;
- u32 iamthif_stall_timer;
- unsigned char *iamthif_msg_buf; /* Note: memory has to be allocated */
- u32 iamthif_msg_buf_size;
- u32 iamthif_msg_buf_index;
- enum iamthif_states iamthif_state;
- bool iamthif_flow_control_pending;
- bool iamthif_ioctl;
- bool iamthif_canceled;
-
- bool wd_interface_reg;
-};
-
-
-/*
- * mei init function prototypes
- */
-struct mei_device *mei_device_init(struct pci_dev *pdev);
-void mei_reset(struct mei_device *dev, int interrupts);
-int mei_hw_init(struct mei_device *dev);
-int mei_task_initialize_clients(void *data);
-int mei_initialize_clients(struct mei_device *dev);
-int mei_disconnect_host_client(struct mei_device *dev, struct mei_cl *cl);
-void mei_remove_client_from_file_list(struct mei_device *dev, u8 host_client_id);
-void mei_host_init_iamthif(struct mei_device *dev);
-void mei_allocate_me_clients_storage(struct mei_device *dev);
-
-
-u8 mei_find_me_client_update_filext(struct mei_device *dev,
- struct mei_cl *priv,
- const uuid_le *cguid, u8 client_id);
-
-/*
- * MEI IO List Functions
- */
-void mei_io_list_init(struct mei_io_list *list);
-void mei_io_list_flush(struct mei_io_list *list, struct mei_cl *cl);
-
-/*
- * MEI ME Client Functions
- */
-
-struct mei_cl *mei_cl_allocate(struct mei_device *dev);
-void mei_cl_init(struct mei_cl *cl, struct mei_device *dev);
-int mei_cl_flush_queues(struct mei_cl *cl);
-/**
- * mei_cl_cmp_id - tells if file private data have same id
- *
- * @fe1: private data of 1. file object
- * @fe2: private data of 2. file object
- *
- * returns true - if ids are the same and not NULL
- */
-static inline bool mei_cl_cmp_id(const struct mei_cl *cl1,
- const struct mei_cl *cl2)
-{
- return cl1 && cl2 &&
- (cl1->host_client_id == cl2->host_client_id) &&
- (cl1->me_client_id == cl2->me_client_id);
-}
-
-
-
-/*
- * MEI Host Client Functions
- */
-void mei_host_start_message(struct mei_device *dev);
-void mei_host_enum_clients_message(struct mei_device *dev);
-int mei_host_client_properties(struct mei_device *dev);
-
-/*
- * MEI interrupt functions prototype
- */
-irqreturn_t mei_interrupt_quick_handler(int irq, void *dev_id);
-irqreturn_t mei_interrupt_thread_handler(int irq, void *dev_id);
-void mei_timer(struct work_struct *work);
-
-/*
- * MEI input output function prototype
- */
-int mei_ioctl_connect_client(struct file *file,
- struct mei_connect_client_data *data);
-
-int mei_start_read(struct mei_device *dev, struct mei_cl *cl);
-
-int amthi_write(struct mei_device *dev, struct mei_cl_cb *priv_cb);
-
-int amthi_read(struct mei_device *dev, struct file *file,
- char __user *ubuf, size_t length, loff_t *offset);
-
-struct mei_cl_cb *find_amthi_read_list_entry(struct mei_device *dev,
- struct file *file);
-
-void mei_run_next_iamthif_cmd(struct mei_device *dev);
-
-void mei_free_cb_private(struct mei_cl_cb *priv_cb);
-
-int mei_find_me_client_index(const struct mei_device *dev, uuid_le cuuid);
-
-/*
- * Register Access Function
- */
-
-/**
- * mei_reg_read - Reads 32bit data from the mei device
- *
- * @dev: the device structure
- * @offset: offset from which to read the data
- *
- * returns register value (u32)
- */
-static inline u32 mei_reg_read(struct mei_device *dev, unsigned long offset)
-{
- return ioread32(dev->mem_addr + offset);
-}
-
-/**
- * mei_reg_write - Writes 32bit data to the mei device
- *
- * @dev: the device structure
- * @offset: offset from which to write the data
- * @value: register value to write (u32)
- */
-static inline void mei_reg_write(struct mei_device *dev,
- unsigned long offset, u32 value)
-{
- iowrite32(value, dev->mem_addr + offset);
-}
-
-/**
- * mei_hcsr_read - Reads 32bit data from the host CSR
- *
- * @dev: the device structure
- *
- * returns the byte read.
- */
-static inline u32 mei_hcsr_read(struct mei_device *dev)
-{
- return mei_reg_read(dev, H_CSR);
-}
-
-/**
- * mei_mecsr_read - Reads 32bit data from the ME CSR
- *
- * @dev: the device structure
- *
- * returns ME_CSR_HA register value (u32)
- */
-static inline u32 mei_mecsr_read(struct mei_device *dev)
-{
- return mei_reg_read(dev, ME_CSR_HA);
-}
-
-/**
- * get_me_cb_rw - Reads 32bit data from the mei ME_CB_RW register
- *
- * @dev: the device structure
- *
- * returns ME_CB_RW register value (u32)
- */
-static inline u32 mei_mecbrw_read(struct mei_device *dev)
-{
- return mei_reg_read(dev, ME_CB_RW);
-}
-
-
-/*
- * mei interface function prototypes
- */
-void mei_hcsr_set(struct mei_device *dev);
-void mei_csr_clear_his(struct mei_device *dev);
-
-void mei_enable_interrupts(struct mei_device *dev);
-void mei_disable_interrupts(struct mei_device *dev);
-
-#endif
diff --git a/drivers/staging/mei/wd.c b/drivers/staging/mei/wd.c
deleted file mode 100644
index cf4c29d10e7f..000000000000
--- a/drivers/staging/mei/wd.c
+++ /dev/null
@@ -1,379 +0,0 @@
-/*
- *
- * Intel Management Engine Interface (Intel MEI) Linux driver
- * Copyright (c) 2003-2012, Intel Corporation.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms and conditions of the GNU General Public License,
- * version 2, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- */
-#include <linux/kernel.h>
-#include <linux/module.h>
-#include <linux/moduleparam.h>
-#include <linux/device.h>
-#include <linux/pci.h>
-#include <linux/sched.h>
-#include <linux/watchdog.h>
-
-#include "mei_dev.h"
-#include "hw.h"
-#include "interface.h"
-#include "mei.h"
-
-static const u8 mei_start_wd_params[] = { 0x02, 0x12, 0x13, 0x10 };
-static const u8 mei_stop_wd_params[] = { 0x02, 0x02, 0x14, 0x10 };
-
-const u8 mei_wd_state_independence_msg[3][4] = {
- {0x05, 0x02, 0x51, 0x10},
- {0x05, 0x02, 0x52, 0x10},
- {0x07, 0x02, 0x01, 0x10}
-};
-
-/*
- * AMT Watchdog Device
- */
-#define INTEL_AMT_WATCHDOG_ID "INTCAMT"
-
-/* UUIDs for AMT F/W clients */
-const uuid_le mei_wd_guid = UUID_LE(0x05B79A6F, 0x4628, 0x4D7F, 0x89,
- 0x9D, 0xA9, 0x15, 0x14, 0xCB,
- 0x32, 0xAB);
-
-void mei_wd_set_start_timeout(struct mei_device *dev, u16 timeout)
-{
- dev_dbg(&dev->pdev->dev, "timeout=%d.\n", timeout);
- memcpy(dev->wd_data, mei_start_wd_params, MEI_WD_PARAMS_SIZE);
- memcpy(dev->wd_data + MEI_WD_PARAMS_SIZE,
- &timeout, sizeof(u16));
-}
-
-/**
- * host_init_wd - mei initialization wd.
- *
- * @dev: the device structure
- */
-bool mei_wd_host_init(struct mei_device *dev)
-{
- bool ret = false;
-
- mei_cl_init(&dev->wd_cl, dev);
-
- /* look for WD client and connect to it */
- dev->wd_cl.state = MEI_FILE_DISCONNECTED;
- dev->wd_timeout = AMT_WD_DEFAULT_TIMEOUT;
-
- /* find ME WD client */
- mei_find_me_client_update_filext(dev, &dev->wd_cl,
- &mei_wd_guid, MEI_WD_HOST_CLIENT_ID);
-
- dev_dbg(&dev->pdev->dev, "check wd_cl\n");
- if (MEI_FILE_CONNECTING == dev->wd_cl.state) {
- if (mei_connect(dev, &dev->wd_cl)) {
- dev_dbg(&dev->pdev->dev, "Failed to connect to WD client\n");
- dev->wd_cl.state = MEI_FILE_DISCONNECTED;
- dev->wd_cl.host_client_id = 0;
- ret = false;
- goto end;
- } else {
- dev->wd_cl.timer_count = CONNECT_TIMEOUT;
- }
- } else {
- dev_dbg(&dev->pdev->dev, "Failed to find WD client\n");
- ret = false;
- goto end;
- }
-
-end:
- return ret;
-}
-
-/**
- * mei_wd_send - sends watch dog message to fw.
- *
- * @dev: the device structure
- *
- * returns 0 if success,
- * -EIO when message send fails
- * -EINVAL when invalid message is to be sent
- */
-int mei_wd_send(struct mei_device *dev)
-{
- struct mei_msg_hdr *mei_hdr;
-
- mei_hdr = (struct mei_msg_hdr *) &dev->wr_msg_buf[0];
- mei_hdr->host_addr = dev->wd_cl.host_client_id;
- mei_hdr->me_addr = dev->wd_cl.me_client_id;
- mei_hdr->msg_complete = 1;
- mei_hdr->reserved = 0;
-
- if (!memcmp(dev->wd_data, mei_start_wd_params, MEI_WD_PARAMS_SIZE))
- mei_hdr->length = MEI_START_WD_DATA_SIZE;
- else if (!memcmp(dev->wd_data, mei_stop_wd_params, MEI_WD_PARAMS_SIZE))
- mei_hdr->length = MEI_WD_PARAMS_SIZE;
- else
- return -EINVAL;
-
- return mei_write_message(dev, mei_hdr, dev->wd_data, mei_hdr->length);
-}
-
-/**
- * mei_wd_stop - sends watchdog stop message to fw.
- *
- * @dev: the device structure
- * @preserve: indicate if to keep the timeout value
- *
- * returns 0 if success,
- * -EIO when message send fails
- * -EINVAL when invalid message is to be sent
- */
-int mei_wd_stop(struct mei_device *dev, bool preserve)
-{
- int ret;
- u16 wd_timeout = dev->wd_timeout;
-
- cancel_delayed_work(&dev->timer_work);
- if (dev->wd_cl.state != MEI_FILE_CONNECTED || !dev->wd_timeout)
- return 0;
-
- dev->wd_timeout = 0;
- dev->wd_due_counter = 0;
- memcpy(dev->wd_data, mei_stop_wd_params, MEI_WD_PARAMS_SIZE);
- dev->stop = true;
-
- ret = mei_flow_ctrl_creds(dev, &dev->wd_cl);
- if (ret < 0)
- goto out;
-
- if (ret && dev->mei_host_buffer_is_empty) {
- ret = 0;
- dev->mei_host_buffer_is_empty = false;
-
- if (!mei_wd_send(dev)) {
- ret = mei_flow_ctrl_reduce(dev, &dev->wd_cl);
- if (ret)
- goto out;
- } else {
- dev_dbg(&dev->pdev->dev, "send stop WD failed\n");
- }
-
- dev->wd_pending = false;
- } else {
- dev->wd_pending = true;
- }
- dev->wd_stopped = false;
- mutex_unlock(&dev->device_lock);
-
- ret = wait_event_interruptible_timeout(dev->wait_stop_wd,
- dev->wd_stopped, 10 * HZ);
- mutex_lock(&dev->device_lock);
- if (dev->wd_stopped) {
- dev_dbg(&dev->pdev->dev, "stop wd complete ret=%d.\n", ret);
- ret = 0;
- } else {
- if (!ret)
- ret = -ETIMEDOUT;
- dev_warn(&dev->pdev->dev,
- "stop wd failed to complete ret=%d.\n", ret);
- }
-
- if (preserve)
- dev->wd_timeout = wd_timeout;
-
-out:
- return ret;
-}
-
-/*
- * mei_wd_ops_start - wd start command from the watchdog core.
- *
- * @wd_dev - watchdog device struct
- *
- * returns 0 if success, negative errno code for failure
- */
-static int mei_wd_ops_start(struct watchdog_device *wd_dev)
-{
- int err = -ENODEV;
- struct mei_device *dev;
-
- dev = pci_get_drvdata(mei_device);
- if (!dev)
- return -ENODEV;
-
- mutex_lock(&dev->device_lock);
-
- if (dev->mei_state != MEI_ENABLED) {
- dev_dbg(&dev->pdev->dev, "mei_state != MEI_ENABLED mei_state= %d\n",
- dev->mei_state);
- goto end_unlock;
- }
-
- if (dev->wd_cl.state != MEI_FILE_CONNECTED) {
- dev_dbg(&dev->pdev->dev, "MEI Driver is not connected to Watchdog Client\n");
- goto end_unlock;
- }
-
- mei_wd_set_start_timeout(dev, dev->wd_timeout);
-
- err = 0;
-end_unlock:
- mutex_unlock(&dev->device_lock);
- return err;
-}
-
-/*
- * mei_wd_ops_stop - wd stop command from the watchdog core.
- *
- * @wd_dev - watchdog device struct
- *
- * returns 0 if success, negative errno code for failure
- */
-static int mei_wd_ops_stop(struct watchdog_device *wd_dev)
-{
- struct mei_device *dev;
- dev = pci_get_drvdata(mei_device);
-
- if (!dev)
- return -ENODEV;
-
- mutex_lock(&dev->device_lock);
- mei_wd_stop(dev, false);
- mutex_unlock(&dev->device_lock);
-
- return 0;
-}
-
-/*
- * mei_wd_ops_ping - wd ping command from the watchdog core.
- *
- * @wd_dev - watchdog device struct
- *
- * returns 0 if success, negative errno code for failure
- */
-static int mei_wd_ops_ping(struct watchdog_device *wd_dev)
-{
- int ret = 0;
- struct mei_device *dev;
- dev = pci_get_drvdata(mei_device);
-
- if (!dev)
- return -ENODEV;
-
- mutex_lock(&dev->device_lock);
-
- if (dev->wd_cl.state != MEI_FILE_CONNECTED) {
- dev_dbg(&dev->pdev->dev, "wd is not connected.\n");
- ret = -ENODEV;
- goto end;
- }
-
- /* Check if we can send the ping to HW*/
- if (dev->mei_host_buffer_is_empty &&
- mei_flow_ctrl_creds(dev, &dev->wd_cl) > 0) {
-
- dev->mei_host_buffer_is_empty = false;
- dev_dbg(&dev->pdev->dev, "sending watchdog ping\n");
-
- if (mei_wd_send(dev)) {
- dev_dbg(&dev->pdev->dev, "wd send failed.\n");
- ret = -EIO;
- goto end;
- }
-
- if (mei_flow_ctrl_reduce(dev, &dev->wd_cl)) {
- dev_dbg(&dev->pdev->dev, "mei_flow_ctrl_reduce() failed.\n");
- ret = -EIO;
- goto end;
- }
-
- } else {
- dev->wd_pending = true;
- }
-
-end:
- mutex_unlock(&dev->device_lock);
- return ret;
-}
-
-/*
- * mei_wd_ops_set_timeout - wd set timeout command from the watchdog core.
- *
- * @wd_dev - watchdog device struct
- * @timeout - timeout value to set
- *
- * returns 0 if success, negative errno code for failure
- */
-static int mei_wd_ops_set_timeout(struct watchdog_device *wd_dev, unsigned int timeout)
-{
- struct mei_device *dev;
- dev = pci_get_drvdata(mei_device);
-
- if (!dev)
- return -ENODEV;
-
- /* Check Timeout value */
- if (timeout < AMT_WD_MIN_TIMEOUT || timeout > AMT_WD_MAX_TIMEOUT)
- return -EINVAL;
-
- mutex_lock(&dev->device_lock);
-
- dev->wd_timeout = timeout;
- wd_dev->timeout = timeout;
- mei_wd_set_start_timeout(dev, dev->wd_timeout);
-
- mutex_unlock(&dev->device_lock);
-
- return 0;
-}
-
-/*
- * Watchdog Device structs
- */
-static const struct watchdog_ops wd_ops = {
- .owner = THIS_MODULE,
- .start = mei_wd_ops_start,
- .stop = mei_wd_ops_stop,
- .ping = mei_wd_ops_ping,
- .set_timeout = mei_wd_ops_set_timeout,
-};
-static const struct watchdog_info wd_info = {
- .identity = INTEL_AMT_WATCHDOG_ID,
- .options = WDIOF_KEEPALIVEPING,
-};
-
-struct watchdog_device amt_wd_dev = {
- .info = &wd_info,
- .ops = &wd_ops,
- .timeout = AMT_WD_DEFAULT_TIMEOUT,
- .min_timeout = AMT_WD_MIN_TIMEOUT,
- .max_timeout = AMT_WD_MAX_TIMEOUT,
-};
-
-
-void mei_watchdog_register(struct mei_device *dev)
-{
- dev_dbg(&dev->pdev->dev, "dev->wd_timeout =%d.\n", dev->wd_timeout);
-
- dev->wd_due_counter = !!dev->wd_timeout;
-
- if (watchdog_register_device(&amt_wd_dev)) {
- dev_err(&dev->pdev->dev, "unable to register watchdog device.\n");
- dev->wd_interface_reg = false;
- } else {
- dev_dbg(&dev->pdev->dev, "successfully register watchdog interface.\n");
- dev->wd_interface_reg = true;
- }
-}
-
-void mei_watchdog_unregister(struct mei_device *dev)
-{
- if (dev->wd_interface_reg)
- watchdog_unregister_device(&amt_wd_dev);
- dev->wd_interface_reg = false;
-}
-
diff --git a/drivers/staging/net/Kconfig b/drivers/staging/net/Kconfig
new file mode 100644
index 000000000000..a64e56b1898a
--- /dev/null
+++ b/drivers/staging/net/Kconfig
@@ -0,0 +1,38 @@
+if NETDEVICES
+
+if WAN
+
+config PC300
+ tristate "Cyclades-PC300 support (RS-232/V.35, X.21, T1/E1 boards)"
+ depends on HDLC && PCI && BROKEN
+ ---help---
+ This driver is broken because of struct tty_driver change.
+
+ Driver for the Cyclades-PC300 synchronous communication boards.
+
+ These boards provide synchronous serial interfaces to your
+ Linux box (interfaces currently available are RS-232/V.35, X.21 and
+ T1/E1). If you wish to support Multilink PPP, please select the
+ option later and read the file README.mlppp provided by PC300
+ package.
+
+ To compile this as a module, choose M here: the module
+ will be called pc300.
+
+ If unsure, say N.
+
+config PC300_MLPPP
+ bool "Cyclades-PC300 MLPPP support"
+ depends on PC300 && PPP_MULTILINK && PPP_SYNC_TTY && HDLC_PPP
+ help
+ Multilink PPP over the PC300 synchronous communication boards.
+
+comment "Cyclades-PC300 MLPPP support is disabled."
+ depends on HDLC && PC300 && (PPP=n || !PPP_MULTILINK || PPP_SYNC_TTY=n || !HDLC_PPP)
+
+comment "Refer to the file README.mlppp, provided by PC300 package."
+ depends on HDLC && PC300 && (PPP=n || !PPP_MULTILINK || PPP_SYNC_TTY=n || !HDLC_PPP)
+
+endif # WAN
+
+endif # NETDEVICES
diff --git a/drivers/staging/net/Makefile b/drivers/staging/net/Makefile
new file mode 100644
index 000000000000..0799c43d5114
--- /dev/null
+++ b/drivers/staging/net/Makefile
@@ -0,0 +1,5 @@
+pc300-y := pc300_drv.o
+pc300-$(CONFIG_PC300_MLPPP) += pc300_tty.o
+pc300-objs := $(pc300-y)
+
+obj-$(CONFIG_PC300) += pc300.o
diff --git a/drivers/staging/net/TODO b/drivers/staging/net/TODO
new file mode 100644
index 000000000000..e3446f2ad7c7
--- /dev/null
+++ b/drivers/staging/net/TODO
@@ -0,0 +1,5 @@
+PC300
+The driver is very broken and cannot work with the current TTY layer. It is
+inevitable to convert it to the new TTY API.
+
+If no one steps in to adopt the driver, it will be removed in the 3.7 release.
diff --git a/drivers/staging/net/pc300-falc-lh.h b/drivers/staging/net/pc300-falc-lh.h
new file mode 100644
index 000000000000..01ed23ca76c7
--- /dev/null
+++ b/drivers/staging/net/pc300-falc-lh.h
@@ -0,0 +1,1238 @@
+/*
+ * falc.h Description of the Siemens FALC T1/E1 framer.
+ *
+ * Author: Ivan Passos <ivan@cyclades.com>
+ *
+ * Copyright: (c) 2000-2001 Cyclades Corp.
+ *
+ * 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.
+ *
+ * $Log: falc-lh.h,v $
+ * Revision 3.1 2001/06/15 12:41:10 regina
+ * upping major version number
+ *
+ * Revision 1.1.1.1 2001/06/13 20:24:47 daniela
+ * PC300 initial CVS version (3.4.0-pre1)
+ *
+ * Revision 1.1 2000/05/15 ivan
+ * Included DJA bits for the LIM2 register.
+ *
+ * Revision 1.0 2000/02/22 ivan
+ * Initial version.
+ *
+ */
+
+#ifndef _FALC_LH_H
+#define _FALC_LH_H
+
+#define NUM_OF_T1_CHANNELS 24
+#define NUM_OF_E1_CHANNELS 32
+
+/*>>>>>>>>>>>>>>>>> FALC Register Bits (Transmit Mode) <<<<<<<<<<<<<<<<<<< */
+
+/* CMDR (Command Register)
+ ---------------- E1 & T1 ------------------------------ */
+#define CMDR_RMC 0x80
+#define CMDR_RRES 0x40
+#define CMDR_XREP 0x20
+#define CMDR_XRES 0x10
+#define CMDR_XHF 0x08
+#define CMDR_XTF 0x04
+#define CMDR_XME 0x02
+#define CMDR_SRES 0x01
+
+/* MODE (Mode Register)
+ ----------------- E1 & T1 ----------------------------- */
+#define MODE_MDS2 0x80
+#define MODE_MDS1 0x40
+#define MODE_MDS0 0x20
+#define MODE_BRAC 0x10
+#define MODE_HRAC 0x08
+
+/* IPC (Interrupt Port Configuration)
+ ----------------- E1 & T1 ----------------------------- */
+#define IPC_VIS 0x80
+#define IPC_SCI 0x04
+#define IPC_IC1 0x02
+#define IPC_IC0 0x01
+
+/* CCR1 (Common Configuration Register 1)
+ ----------------- E1 & T1 ----------------------------- */
+#define CCR1_SFLG 0x80
+#define CCR1_XTS16RA 0x40
+#define CCR1_BRM 0x40
+#define CCR1_CASSYM 0x20
+#define CCR1_EDLX 0x20
+#define CCR1_EITS 0x10
+#define CCR1_ITF 0x08
+#define CCR1_RFT1 0x02
+#define CCR1_RFT0 0x01
+
+/* CCR3 (Common Configuration Register 3)
+ ---------------- E1 & T1 ------------------------------ */
+
+#define CCR3_PRE1 0x80
+#define CCR3_PRE0 0x40
+#define CCR3_EPT 0x20
+#define CCR3_RADD 0x10
+#define CCR3_RCRC 0x04
+#define CCR3_XCRC 0x02
+
+
+/* RTR1-4 (Receive Timeslot Register 1-4)
+ ---------------- E1 & T1 ------------------------------ */
+
+#define RTR1_TS0 0x80
+#define RTR1_TS1 0x40
+#define RTR1_TS2 0x20
+#define RTR1_TS3 0x10
+#define RTR1_TS4 0x08
+#define RTR1_TS5 0x04
+#define RTR1_TS6 0x02
+#define RTR1_TS7 0x01
+
+#define RTR2_TS8 0x80
+#define RTR2_TS9 0x40
+#define RTR2_TS10 0x20
+#define RTR2_TS11 0x10
+#define RTR2_TS12 0x08
+#define RTR2_TS13 0x04
+#define RTR2_TS14 0x02
+#define RTR2_TS15 0x01
+
+#define RTR3_TS16 0x80
+#define RTR3_TS17 0x40
+#define RTR3_TS18 0x20
+#define RTR3_TS19 0x10
+#define RTR3_TS20 0x08
+#define RTR3_TS21 0x04
+#define RTR3_TS22 0x02
+#define RTR3_TS23 0x01
+
+#define RTR4_TS24 0x80
+#define RTR4_TS25 0x40
+#define RTR4_TS26 0x20
+#define RTR4_TS27 0x10
+#define RTR4_TS28 0x08
+#define RTR4_TS29 0x04
+#define RTR4_TS30 0x02
+#define RTR4_TS31 0x01
+
+
+/* TTR1-4 (Transmit Timeslot Register 1-4)
+ ---------------- E1 & T1 ------------------------------ */
+
+#define TTR1_TS0 0x80
+#define TTR1_TS1 0x40
+#define TTR1_TS2 0x20
+#define TTR1_TS3 0x10
+#define TTR1_TS4 0x08
+#define TTR1_TS5 0x04
+#define TTR1_TS6 0x02
+#define TTR1_TS7 0x01
+
+#define TTR2_TS8 0x80
+#define TTR2_TS9 0x40
+#define TTR2_TS10 0x20
+#define TTR2_TS11 0x10
+#define TTR2_TS12 0x08
+#define TTR2_TS13 0x04
+#define TTR2_TS14 0x02
+#define TTR2_TS15 0x01
+
+#define TTR3_TS16 0x80
+#define TTR3_TS17 0x40
+#define TTR3_TS18 0x20
+#define TTR3_TS19 0x10
+#define TTR3_TS20 0x08
+#define TTR3_TS21 0x04
+#define TTR3_TS22 0x02
+#define TTR3_TS23 0x01
+
+#define TTR4_TS24 0x80
+#define TTR4_TS25 0x40
+#define TTR4_TS26 0x20
+#define TTR4_TS27 0x10
+#define TTR4_TS28 0x08
+#define TTR4_TS29 0x04
+#define TTR4_TS30 0x02
+#define TTR4_TS31 0x01
+
+
+
+/* IMR0-4 (Interrupt Mask Register 0-4)
+
+ ----------------- E1 & T1 ----------------------------- */
+
+#define IMR0_RME 0x80
+#define IMR0_RFS 0x40
+#define IMR0_T8MS 0x20
+#define IMR0_ISF 0x20
+#define IMR0_RMB 0x10
+#define IMR0_CASC 0x08
+#define IMR0_RSC 0x08
+#define IMR0_CRC6 0x04
+#define IMR0_CRC4 0x04
+#define IMR0_PDEN 0x02
+#define IMR0_RPF 0x01
+
+#define IMR1_CASE 0x80
+#define IMR1_RDO 0x40
+#define IMR1_ALLS 0x20
+#define IMR1_XDU 0x10
+#define IMR1_XMB 0x08
+#define IMR1_XLSC 0x02
+#define IMR1_XPR 0x01
+#define IMR1_LLBSC 0x80
+
+#define IMR2_FAR 0x80
+#define IMR2_LFA 0x40
+#define IMR2_MFAR 0x20
+#define IMR2_T400MS 0x10
+#define IMR2_LMFA 0x10
+#define IMR2_AIS 0x08
+#define IMR2_LOS 0x04
+#define IMR2_RAR 0x02
+#define IMR2_RA 0x01
+
+#define IMR3_ES 0x80
+#define IMR3_SEC 0x40
+#define IMR3_LMFA16 0x20
+#define IMR3_AIS16 0x10
+#define IMR3_RA16 0x08
+#define IMR3_API 0x04
+#define IMR3_XSLP 0x20
+#define IMR3_XSLN 0x10
+#define IMR3_LLBSC 0x08
+#define IMR3_XRS 0x04
+#define IMR3_SLN 0x02
+#define IMR3_SLP 0x01
+
+#define IMR4_LFA 0x80
+#define IMR4_FER 0x40
+#define IMR4_CER 0x20
+#define IMR4_AIS 0x10
+#define IMR4_LOS 0x08
+#define IMR4_CVE 0x04
+#define IMR4_SLIP 0x02
+#define IMR4_EBE 0x01
+
+/* FMR0-5 for E1 and T1 (Framer Mode Register ) */
+
+#define FMR0_XC1 0x80
+#define FMR0_XC0 0x40
+#define FMR0_RC1 0x20
+#define FMR0_RC0 0x10
+#define FMR0_EXTD 0x08
+#define FMR0_ALM 0x04
+#define E1_FMR0_FRS 0x02
+#define T1_FMR0_FRS 0x08
+#define FMR0_SRAF 0x04
+#define FMR0_EXLS 0x02
+#define FMR0_SIM 0x01
+
+#define FMR1_MFCS 0x80
+#define FMR1_AFR 0x40
+#define FMR1_ENSA 0x20
+#define FMR1_CTM 0x80
+#define FMR1_SIGM 0x40
+#define FMR1_EDL 0x20
+#define FMR1_PMOD 0x10
+#define FMR1_XFS 0x08
+#define FMR1_CRC 0x08
+#define FMR1_ECM 0x04
+#define FMR1_IMOD 0x02
+#define FMR1_XAIS 0x01
+
+#define FMR2_RFS1 0x80
+#define FMR2_RFS0 0x40
+#define FMR2_MCSP 0x40
+#define FMR2_RTM 0x20
+#define FMR2_SSP 0x20
+#define FMR2_DAIS 0x10
+#define FMR2_SAIS 0x08
+#define FMR2_PLB 0x04
+#define FMR2_AXRA 0x02
+#define FMR2_ALMF 0x01
+#define FMR2_EXZE 0x01
+
+#define LOOP_RTM 0x40
+#define LOOP_SFM 0x40
+#define LOOP_ECLB 0x20
+#define LOOP_CLA 0x1f
+
+/*--------------------- E1 ----------------------------*/
+#define FMR3_XLD 0x20
+#define FMR3_XLU 0x10
+
+/*--------------------- T1 ----------------------------*/
+#define FMR4_AIS3 0x80
+#define FMR4_TM 0x40
+#define FMR4_XRA 0x20
+#define FMR4_SSC1 0x10
+#define FMR4_SSC0 0x08
+#define FMR4_AUTO 0x04
+#define FMR4_FM1 0x02
+#define FMR4_FM0 0x01
+
+#define FMR5_SRS 0x80
+#define FMR5_EIBR 0x40
+#define FMR5_XLD 0x20
+#define FMR5_XLU 0x10
+
+
+/* LOOP (Channel Loop Back)
+
+ ------------------ E1 & T1 ---------------------------- */
+
+#define LOOP_SFM 0x40
+#define LOOP_ECLB 0x20
+#define LOOP_CLA4 0x10
+#define LOOP_CLA3 0x08
+#define LOOP_CLA2 0x04
+#define LOOP_CLA1 0x02
+#define LOOP_CLA0 0x01
+
+
+
+/* XSW (Transmit Service Word Pulseframe)
+
+ ------------------- E1 --------------------------- */
+
+#define XSW_XSIS 0x80
+#define XSW_XTM 0x40
+#define XSW_XRA 0x20
+#define XSW_XY0 0x10
+#define XSW_XY1 0x08
+#define XSW_XY2 0x04
+#define XSW_XY3 0x02
+#define XSW_XY4 0x01
+
+
+/* XSP (Transmit Spare Bits)
+
+ ------------------- E1 --------------------------- */
+
+#define XSP_XAP 0x80
+#define XSP_CASEN 0x40
+#define XSP_TT0 0x20
+#define XSP_EBP 0x10
+#define XSP_AXS 0x08
+#define XSP_XSIF 0x04
+#define XSP_XS13 0x02
+#define XSP_XS15 0x01
+
+
+/* XC0/1 (Transmit Control 0/1)
+ ------------------ E1 & T1 ---------------------------- */
+
+#define XC0_SA8E 0x80
+#define XC0_SA7E 0x40
+#define XC0_SA6E 0x20
+#define XC0_SA5E 0x10
+#define XC0_SA4E 0x08
+#define XC0_BRM 0x80
+#define XC0_MFBS 0x40
+#define XC0_SFRZ 0x10
+#define XC0_XCO2 0x04
+#define XC0_XCO1 0x02
+#define XC0_XCO0 0x01
+
+#define XC1_XTO5 0x20
+#define XC1_XTO4 0x10
+#define XC1_XTO3 0x08
+#define XC1_XTO2 0x04
+#define XC1_XTO1 0x02
+#define XC1_XTO0 0x01
+
+
+/* RC0/1 (Receive Control 0/1)
+ ------------------ E1 & T1 ---------------------------- */
+
+#define RC0_SICS 0x40
+#define RC0_CRCI 0x20
+#define RC0_XCRCI 0x10
+#define RC0_RDIS 0x08
+#define RC0_RCO2 0x04
+#define RC0_RCO1 0x02
+#define RC0_RCO0 0x01
+
+#define RC1_SWD 0x80
+#define RC1_ASY4 0x40
+#define RC1_RRAM 0x40
+#define RC1_RTO5 0x20
+#define RC1_RTO4 0x10
+#define RC1_RTO3 0x08
+#define RC1_RTO2 0x04
+#define RC1_RTO1 0x02
+#define RC1_RTO0 0x01
+
+
+
+/* XPM0-2 (Transmit Pulse Mask 0-2)
+ --------------------- E1 & T1 ------------------------- */
+
+#define XPM0_XP12 0x80
+#define XPM0_XP11 0x40
+#define XPM0_XP10 0x20
+#define XPM0_XP04 0x10
+#define XPM0_XP03 0x08
+#define XPM0_XP02 0x04
+#define XPM0_XP01 0x02
+#define XPM0_XP00 0x01
+
+#define XPM1_XP30 0x80
+#define XPM1_XP24 0x40
+#define XPM1_XP23 0x20
+#define XPM1_XP22 0x10
+#define XPM1_XP21 0x08
+#define XPM1_XP20 0x04
+#define XPM1_XP14 0x02
+#define XPM1_XP13 0x01
+
+#define XPM2_XLHP 0x80
+#define XPM2_XLT 0x40
+#define XPM2_DAXLT 0x20
+#define XPM2_XP34 0x08
+#define XPM2_XP33 0x04
+#define XPM2_XP32 0x02
+#define XPM2_XP31 0x01
+
+
+/* TSWM (Transparent Service Word Mask)
+ ------------------ E1 ---------------------------- */
+
+#define TSWM_TSIS 0x80
+#define TSWM_TSIF 0x40
+#define TSWM_TRA 0x20
+#define TSWM_TSA4 0x10
+#define TSWM_TSA5 0x08
+#define TSWM_TSA6 0x04
+#define TSWM_TSA7 0x02
+#define TSWM_TSA8 0x01
+
+/* IDLE <Idle Channel Code Register>
+
+ ------------------ E1 & T1 ----------------------- */
+
+#define IDLE_IDL7 0x80
+#define IDLE_IDL6 0x40
+#define IDLE_IDL5 0x20
+#define IDLE_IDL4 0x10
+#define IDLE_IDL3 0x08
+#define IDLE_IDL2 0x04
+#define IDLE_IDL1 0x02
+#define IDLE_IDL0 0x01
+
+
+/* XSA4-8 <Transmit SA4-8 Register(Read/Write) >
+ -------------------E1 ----------------------------- */
+
+#define XSA4_XS47 0x80
+#define XSA4_XS46 0x40
+#define XSA4_XS45 0x20
+#define XSA4_XS44 0x10
+#define XSA4_XS43 0x08
+#define XSA4_XS42 0x04
+#define XSA4_XS41 0x02
+#define XSA4_XS40 0x01
+
+#define XSA5_XS57 0x80
+#define XSA5_XS56 0x40
+#define XSA5_XS55 0x20
+#define XSA5_XS54 0x10
+#define XSA5_XS53 0x08
+#define XSA5_XS52 0x04
+#define XSA5_XS51 0x02
+#define XSA5_XS50 0x01
+
+#define XSA6_XS67 0x80
+#define XSA6_XS66 0x40
+#define XSA6_XS65 0x20
+#define XSA6_XS64 0x10
+#define XSA6_XS63 0x08
+#define XSA6_XS62 0x04
+#define XSA6_XS61 0x02
+#define XSA6_XS60 0x01
+
+#define XSA7_XS77 0x80
+#define XSA7_XS76 0x40
+#define XSA7_XS75 0x20
+#define XSA7_XS74 0x10
+#define XSA7_XS73 0x08
+#define XSA7_XS72 0x04
+#define XSA7_XS71 0x02
+#define XSA7_XS70 0x01
+
+#define XSA8_XS87 0x80
+#define XSA8_XS86 0x40
+#define XSA8_XS85 0x20
+#define XSA8_XS84 0x10
+#define XSA8_XS83 0x08
+#define XSA8_XS82 0x04
+#define XSA8_XS81 0x02
+#define XSA8_XS80 0x01
+
+
+/* XDL1-3 (Transmit DL-Bit Register1-3 (read/write))
+ ----------------------- T1 --------------------- */
+
+#define XDL1_XDL17 0x80
+#define XDL1_XDL16 0x40
+#define XDL1_XDL15 0x20
+#define XDL1_XDL14 0x10
+#define XDL1_XDL13 0x08
+#define XDL1_XDL12 0x04
+#define XDL1_XDL11 0x02
+#define XDL1_XDL10 0x01
+
+#define XDL2_XDL27 0x80
+#define XDL2_XDL26 0x40
+#define XDL2_XDL25 0x20
+#define XDL2_XDL24 0x10
+#define XDL2_XDL23 0x08
+#define XDL2_XDL22 0x04
+#define XDL2_XDL21 0x02
+#define XDL2_XDL20 0x01
+
+#define XDL3_XDL37 0x80
+#define XDL3_XDL36 0x40
+#define XDL3_XDL35 0x20
+#define XDL3_XDL34 0x10
+#define XDL3_XDL33 0x08
+#define XDL3_XDL32 0x04
+#define XDL3_XDL31 0x02
+#define XDL3_XDL30 0x01
+
+
+/* ICB1-4 (Idle Channel Register 1-4)
+ ------------------ E1 ---------------------------- */
+
+#define E1_ICB1_IC0 0x80
+#define E1_ICB1_IC1 0x40
+#define E1_ICB1_IC2 0x20
+#define E1_ICB1_IC3 0x10
+#define E1_ICB1_IC4 0x08
+#define E1_ICB1_IC5 0x04
+#define E1_ICB1_IC6 0x02
+#define E1_ICB1_IC7 0x01
+
+#define E1_ICB2_IC8 0x80
+#define E1_ICB2_IC9 0x40
+#define E1_ICB2_IC10 0x20
+#define E1_ICB2_IC11 0x10
+#define E1_ICB2_IC12 0x08
+#define E1_ICB2_IC13 0x04
+#define E1_ICB2_IC14 0x02
+#define E1_ICB2_IC15 0x01
+
+#define E1_ICB3_IC16 0x80
+#define E1_ICB3_IC17 0x40
+#define E1_ICB3_IC18 0x20
+#define E1_ICB3_IC19 0x10
+#define E1_ICB3_IC20 0x08
+#define E1_ICB3_IC21 0x04
+#define E1_ICB3_IC22 0x02
+#define E1_ICB3_IC23 0x01
+
+#define E1_ICB4_IC24 0x80
+#define E1_ICB4_IC25 0x40
+#define E1_ICB4_IC26 0x20
+#define E1_ICB4_IC27 0x10
+#define E1_ICB4_IC28 0x08
+#define E1_ICB4_IC29 0x04
+#define E1_ICB4_IC30 0x02
+#define E1_ICB4_IC31 0x01
+
+/* ICB1-4 (Idle Channel Register 1-4)
+ ------------------ T1 ---------------------------- */
+
+#define T1_ICB1_IC1 0x80
+#define T1_ICB1_IC2 0x40
+#define T1_ICB1_IC3 0x20
+#define T1_ICB1_IC4 0x10
+#define T1_ICB1_IC5 0x08
+#define T1_ICB1_IC6 0x04
+#define T1_ICB1_IC7 0x02
+#define T1_ICB1_IC8 0x01
+
+#define T1_ICB2_IC9 0x80
+#define T1_ICB2_IC10 0x40
+#define T1_ICB2_IC11 0x20
+#define T1_ICB2_IC12 0x10
+#define T1_ICB2_IC13 0x08
+#define T1_ICB2_IC14 0x04
+#define T1_ICB2_IC15 0x02
+#define T1_ICB2_IC16 0x01
+
+#define T1_ICB3_IC17 0x80
+#define T1_ICB3_IC18 0x40
+#define T1_ICB3_IC19 0x20
+#define T1_ICB3_IC20 0x10
+#define T1_ICB3_IC21 0x08
+#define T1_ICB3_IC22 0x04
+#define T1_ICB3_IC23 0x02
+#define T1_ICB3_IC24 0x01
+
+/* FMR3 (Framer Mode Register 3)
+ --------------------E1------------------------ */
+
+#define FMR3_CMI 0x08
+#define FMR3_SYNSA 0x04
+#define FMR3_CFRZ 0x02
+#define FMR3_EXTIW 0x01
+
+
+
+/* CCB1-3 (Clear Channel Register)
+ ------------------- T1 ----------------------- */
+
+#define CCB1_CH1 0x80
+#define CCB1_CH2 0x40
+#define CCB1_CH3 0x20
+#define CCB1_CH4 0x10
+#define CCB1_CH5 0x08
+#define CCB1_CH6 0x04
+#define CCB1_CH7 0x02
+#define CCB1_CH8 0x01
+
+#define CCB2_CH9 0x80
+#define CCB2_CH10 0x40
+#define CCB2_CH11 0x20
+#define CCB2_CH12 0x10
+#define CCB2_CH13 0x08
+#define CCB2_CH14 0x04
+#define CCB2_CH15 0x02
+#define CCB2_CH16 0x01
+
+#define CCB3_CH17 0x80
+#define CCB3_CH18 0x40
+#define CCB3_CH19 0x20
+#define CCB3_CH20 0x10
+#define CCB3_CH21 0x08
+#define CCB3_CH22 0x04
+#define CCB3_CH23 0x02
+#define CCB3_CH24 0x01
+
+
+/* LIM0/1 (Line Interface Mode 0/1)
+ ------------------- E1 & T1 --------------------------- */
+
+#define LIM0_XFB 0x80
+#define LIM0_XDOS 0x40
+#define LIM0_SCL1 0x20
+#define LIM0_SCL0 0x10
+#define LIM0_EQON 0x08
+#define LIM0_ELOS 0x04
+#define LIM0_LL 0x02
+#define LIM0_MAS 0x01
+
+#define LIM1_EFSC 0x80
+#define LIM1_RIL2 0x40
+#define LIM1_RIL1 0x20
+#define LIM1_RIL0 0x10
+#define LIM1_DCOC 0x08
+#define LIM1_JATT 0x04
+#define LIM1_RL 0x02
+#define LIM1_DRS 0x01
+
+
+/* PCDR (Pulse Count Detection Register(Read/Write))
+ ------------------ E1 & T1 ------------------------- */
+
+#define PCDR_PCD7 0x80
+#define PCDR_PCD6 0x40
+#define PCDR_PCD5 0x20
+#define PCDR_PCD4 0x10
+#define PCDR_PCD3 0x08
+#define PCDR_PCD2 0x04
+#define PCDR_PCD1 0x02
+#define PCDR_PCD0 0x01
+
+#define PCRR_PCR7 0x80
+#define PCRR_PCR6 0x40
+#define PCRR_PCR5 0x20
+#define PCRR_PCR4 0x10
+#define PCRR_PCR3 0x08
+#define PCRR_PCR2 0x04
+#define PCRR_PCR1 0x02
+#define PCRR_PCR0 0x01
+
+
+/* LIM2 (Line Interface Mode 2)
+
+ ------------------ E1 & T1 ---------------------------- */
+
+#define LIM2_DJA2 0x20
+#define LIM2_DJA1 0x10
+#define LIM2_LOS2 0x02
+#define LIM2_LOS1 0x01
+
+/* LCR1 (Loop Code Register 1) */
+
+#define LCR1_EPRM 0x80
+#define LCR1_XPRBS 0x40
+
+/* SIC1 (System Interface Control 1) */
+#define SIC1_SRSC 0x80
+#define SIC1_RBS1 0x20
+#define SIC1_RBS0 0x10
+#define SIC1_SXSC 0x08
+#define SIC1_XBS1 0x02
+#define SIC1_XBS0 0x01
+
+/* DEC (Disable Error Counter)
+ ------------------ E1 & T1 ---------------------------- */
+
+#define DEC_DCEC3 0x20
+#define DEC_DBEC 0x10
+#define DEC_DCEC1 0x08
+#define DEC_DCEC 0x08
+#define DEC_DEBC 0x04
+#define DEC_DCVC 0x02
+#define DEC_DFEC 0x01
+
+
+/* FALC Register Bits (Receive Mode)
+ ---------------------------------------------------------------------------- */
+
+
+/* FRS0/1 (Framer Receive Status Register 0/1)
+ ----------------- E1 & T1 ---------------------------------- */
+
+#define FRS0_LOS 0x80
+#define FRS0_AIS 0x40
+#define FRS0_LFA 0x20
+#define FRS0_RRA 0x10
+#define FRS0_API 0x08
+#define FRS0_NMF 0x04
+#define FRS0_LMFA 0x02
+#define FRS0_FSRF 0x01
+
+#define FRS1_TS16RA 0x40
+#define FRS1_TS16LOS 0x20
+#define FRS1_TS16AIS 0x10
+#define FRS1_TS16LFA 0x08
+#define FRS1_EXZD 0x80
+#define FRS1_LLBDD 0x10
+#define FRS1_LLBAD 0x08
+#define FRS1_XLS 0x02
+#define FRS1_XLO 0x01
+#define FRS1_PDEN 0x40
+
+/* FRS2/3 (Framer Receive Status Register 2/3)
+ ----------------- T1 ---------------------------------- */
+
+#define FRS2_ESC2 0x80
+#define FRS2_ESC1 0x40
+#define FRS2_ESC0 0x20
+
+#define FRS3_FEH5 0x20
+#define FRS3_FEH4 0x10
+#define FRS3_FEH3 0x08
+#define FRS3_FEH2 0x04
+#define FRS3_FEH1 0x02
+#define FRS3_FEH0 0x01
+
+
+/* RSW (Receive Service Word Pulseframe)
+ ----------------- E1 ------------------------------ */
+
+#define RSW_RSI 0x80
+#define RSW_RRA 0x20
+#define RSW_RYO 0x10
+#define RSW_RY1 0x08
+#define RSW_RY2 0x04
+#define RSW_RY3 0x02
+#define RSW_RY4 0x01
+
+
+/* RSP (Receive Spare Bits / Additional Status)
+ ---------------- E1 ------------------------------- */
+
+#define RSP_SI1 0x80
+#define RSP_SI2 0x40
+#define RSP_LLBDD 0x10
+#define RSP_LLBAD 0x08
+#define RSP_RSIF 0x04
+#define RSP_RS13 0x02
+#define RSP_RS15 0x01
+
+
+/* FECL (Framing Error Counter)
+ ---------------- E1 & T1 -------------------------- */
+
+#define FECL_FE7 0x80
+#define FECL_FE6 0x40
+#define FECL_FE5 0x20
+#define FECL_FE4 0x10
+#define FECL_FE3 0x08
+#define FECL_FE2 0x04
+#define FECL_FE1 0x02
+#define FECL_FE0 0x01
+
+#define FECH_FE15 0x80
+#define FECH_FE14 0x40
+#define FECH_FE13 0x20
+#define FECH_FE12 0x10
+#define FECH_FE11 0x08
+#define FECH_FE10 0x04
+#define FECH_FE9 0x02
+#define FECH_FE8 0x01
+
+
+/* CVCl (Code Violation Counter)
+ ----------------- E1 ------------------------- */
+
+#define CVCL_CV7 0x80
+#define CVCL_CV6 0x40
+#define CVCL_CV5 0x20
+#define CVCL_CV4 0x10
+#define CVCL_CV3 0x08
+#define CVCL_CV2 0x04
+#define CVCL_CV1 0x02
+#define CVCL_CV0 0x01
+
+#define CVCH_CV15 0x80
+#define CVCH_CV14 0x40
+#define CVCH_CV13 0x20
+#define CVCH_CV12 0x10
+#define CVCH_CV11 0x08
+#define CVCH_CV10 0x04
+#define CVCH_CV9 0x02
+#define CVCH_CV8 0x01
+
+
+/* CEC1-3L (CRC Error Counter)
+ ------------------ E1 ----------------------------- */
+
+#define CEC1L_CR7 0x80
+#define CEC1L_CR6 0x40
+#define CEC1L_CR5 0x20
+#define CEC1L_CR4 0x10
+#define CEC1L_CR3 0x08
+#define CEC1L_CR2 0x04
+#define CEC1L_CR1 0x02
+#define CEC1L_CR0 0x01
+
+#define CEC1H_CR15 0x80
+#define CEC1H_CR14 0x40
+#define CEC1H_CR13 0x20
+#define CEC1H_CR12 0x10
+#define CEC1H_CR11 0x08
+#define CEC1H_CR10 0x04
+#define CEC1H_CR9 0x02
+#define CEC1H_CR8 0x01
+
+#define CEC2L_CR7 0x80
+#define CEC2L_CR6 0x40
+#define CEC2L_CR5 0x20
+#define CEC2L_CR4 0x10
+#define CEC2L_CR3 0x08
+#define CEC2L_CR2 0x04
+#define CEC2L_CR1 0x02
+#define CEC2L_CR0 0x01
+
+#define CEC2H_CR15 0x80
+#define CEC2H_CR14 0x40
+#define CEC2H_CR13 0x20
+#define CEC2H_CR12 0x10
+#define CEC2H_CR11 0x08
+#define CEC2H_CR10 0x04
+#define CEC2H_CR9 0x02
+#define CEC2H_CR8 0x01
+
+#define CEC3L_CR7 0x80
+#define CEC3L_CR6 0x40
+#define CEC3L_CR5 0x20
+#define CEC3L_CR4 0x10
+#define CEC3L_CR3 0x08
+#define CEC3L_CR2 0x04
+#define CEC3L_CR1 0x02
+#define CEC3L_CR0 0x01
+
+#define CEC3H_CR15 0x80
+#define CEC3H_CR14 0x40
+#define CEC3H_CR13 0x20
+#define CEC3H_CR12 0x10
+#define CEC3H_CR11 0x08
+#define CEC3H_CR10 0x04
+#define CEC3H_CR9 0x02
+#define CEC3H_CR8 0x01
+
+
+/* CECL (CRC Error Counter)
+
+ ------------------ T1 ----------------------------- */
+
+#define CECL_CR7 0x80
+#define CECL_CR6 0x40
+#define CECL_CR5 0x20
+#define CECL_CR4 0x10
+#define CECL_CR3 0x08
+#define CECL_CR2 0x04
+#define CECL_CR1 0x02
+#define CECL_CR0 0x01
+
+#define CECH_CR15 0x80
+#define CECH_CR14 0x40
+#define CECH_CR13 0x20
+#define CECH_CR12 0x10
+#define CECH_CR11 0x08
+#define CECH_CR10 0x04
+#define CECH_CR9 0x02
+#define CECH_CR8 0x01
+
+/* EBCL (E Bit Error Counter)
+ ------------------- E1 & T1 ------------------------- */
+
+#define EBCL_EB7 0x80
+#define EBCL_EB6 0x40
+#define EBCL_EB5 0x20
+#define EBCL_EB4 0x10
+#define EBCL_EB3 0x08
+#define EBCL_EB2 0x04
+#define EBCL_EB1 0x02
+#define EBCL_EB0 0x01
+
+#define EBCH_EB15 0x80
+#define EBCH_EB14 0x40
+#define EBCH_EB13 0x20
+#define EBCH_EB12 0x10
+#define EBCH_EB11 0x08
+#define EBCH_EB10 0x04
+#define EBCH_EB9 0x02
+#define EBCH_EB8 0x01
+
+
+/* RSA4-8 (Receive Sa4-8-Bit Register)
+ -------------------- E1 --------------------------- */
+
+#define RSA4_RS47 0x80
+#define RSA4_RS46 0x40
+#define RSA4_RS45 0x20
+#define RSA4_RS44 0x10
+#define RSA4_RS43 0x08
+#define RSA4_RS42 0x04
+#define RSA4_RS41 0x02
+#define RSA4_RS40 0x01
+
+#define RSA5_RS57 0x80
+#define RSA5_RS56 0x40
+#define RSA5_RS55 0x20
+#define RSA5_RS54 0x10
+#define RSA5_RS53 0x08
+#define RSA5_RS52 0x04
+#define RSA5_RS51 0x02
+#define RSA5_RS50 0x01
+
+#define RSA6_RS67 0x80
+#define RSA6_RS66 0x40
+#define RSA6_RS65 0x20
+#define RSA6_RS64 0x10
+#define RSA6_RS63 0x08
+#define RSA6_RS62 0x04
+#define RSA6_RS61 0x02
+#define RSA6_RS60 0x01
+
+#define RSA7_RS77 0x80
+#define RSA7_RS76 0x40
+#define RSA7_RS75 0x20
+#define RSA7_RS74 0x10
+#define RSA7_RS73 0x08
+#define RSA7_RS72 0x04
+#define RSA7_RS71 0x02
+#define RSA7_RS70 0x01
+
+#define RSA8_RS87 0x80
+#define RSA8_RS86 0x40
+#define RSA8_RS85 0x20
+#define RSA8_RS84 0x10
+#define RSA8_RS83 0x08
+#define RSA8_RS82 0x04
+#define RSA8_RS81 0x02
+#define RSA8_RS80 0x01
+
+/* RSA6S (Receive Sa6 Bit Status Register)
+ ------------------------ T1 ------------------------- */
+
+#define RSA6S_SX 0x20
+#define RSA6S_SF 0x10
+#define RSA6S_SE 0x08
+#define RSA6S_SC 0x04
+#define RSA6S_SA 0x02
+#define RSA6S_S8 0x01
+
+
+/* RDL1-3 Receive DL-Bit Register1-3)
+ ------------------------ T1 ------------------------- */
+
+#define RDL1_RDL17 0x80
+#define RDL1_RDL16 0x40
+#define RDL1_RDL15 0x20
+#define RDL1_RDL14 0x10
+#define RDL1_RDL13 0x08
+#define RDL1_RDL12 0x04
+#define RDL1_RDL11 0x02
+#define RDL1_RDL10 0x01
+
+#define RDL2_RDL27 0x80
+#define RDL2_RDL26 0x40
+#define RDL2_RDL25 0x20
+#define RDL2_RDL24 0x10
+#define RDL2_RDL23 0x08
+#define RDL2_RDL22 0x04
+#define RDL2_RDL21 0x02
+#define RDL2_RDL20 0x01
+
+#define RDL3_RDL37 0x80
+#define RDL3_RDL36 0x40
+#define RDL3_RDL35 0x20
+#define RDL3_RDL34 0x10
+#define RDL3_RDL33 0x08
+#define RDL3_RDL32 0x04
+#define RDL3_RDL31 0x02
+#define RDL3_RDL30 0x01
+
+
+/* SIS (Signaling Status Register)
+
+ -------------------- E1 & T1 -------------------------- */
+
+#define SIS_XDOV 0x80
+#define SIS_XFW 0x40
+#define SIS_XREP 0x20
+#define SIS_RLI 0x08
+#define SIS_CEC 0x04
+#define SIS_BOM 0x01
+
+
+/* RSIS (Receive Signaling Status Register)
+
+ -------------------- E1 & T1 --------------------------- */
+
+#define RSIS_VFR 0x80
+#define RSIS_RDO 0x40
+#define RSIS_CRC16 0x20
+#define RSIS_RAB 0x10
+#define RSIS_HA1 0x08
+#define RSIS_HA0 0x04
+#define RSIS_HFR 0x02
+#define RSIS_LA 0x01
+
+
+/* RBCL/H (Receive Byte Count Low/High)
+
+ ------------------- E1 & T1 ----------------------- */
+
+#define RBCL_RBC7 0x80
+#define RBCL_RBC6 0x40
+#define RBCL_RBC5 0x20
+#define RBCL_RBC4 0x10
+#define RBCL_RBC3 0x08
+#define RBCL_RBC2 0x04
+#define RBCL_RBC1 0x02
+#define RBCL_RBC0 0x01
+
+#define RBCH_OV 0x10
+#define RBCH_RBC11 0x08
+#define RBCH_RBC10 0x04
+#define RBCH_RBC9 0x02
+#define RBCH_RBC8 0x01
+
+
+/* ISR1-3 (Interrupt Status Register 1-3)
+
+ ------------------ E1 & T1 ------------------------------ */
+
+#define FISR0_RME 0x80
+#define FISR0_RFS 0x40
+#define FISR0_T8MS 0x20
+#define FISR0_ISF 0x20
+#define FISR0_RMB 0x10
+#define FISR0_CASC 0x08
+#define FISR0_RSC 0x08
+#define FISR0_CRC6 0x04
+#define FISR0_CRC4 0x04
+#define FISR0_PDEN 0x02
+#define FISR0_RPF 0x01
+
+#define FISR1_CASE 0x80
+#define FISR1_LLBSC 0x80
+#define FISR1_RDO 0x40
+#define FISR1_ALLS 0x20
+#define FISR1_XDU 0x10
+#define FISR1_XMB 0x08
+#define FISR1_XLSC 0x02
+#define FISR1_XPR 0x01
+
+#define FISR2_FAR 0x80
+#define FISR2_LFA 0x40
+#define FISR2_MFAR 0x20
+#define FISR2_T400MS 0x10
+#define FISR2_LMFA 0x10
+#define FISR2_AIS 0x08
+#define FISR2_LOS 0x04
+#define FISR2_RAR 0x02
+#define FISR2_RA 0x01
+
+#define FISR3_ES 0x80
+#define FISR3_SEC 0x40
+#define FISR3_LMFA16 0x20
+#define FISR3_AIS16 0x10
+#define FISR3_RA16 0x08
+#define FISR3_API 0x04
+#define FISR3_XSLP 0x20
+#define FISR3_XSLN 0x10
+#define FISR3_LLBSC 0x08
+#define FISR3_XRS 0x04
+#define FISR3_SLN 0x02
+#define FISR3_SLP 0x01
+
+
+/* GIS (Global Interrupt Status Register)
+
+ --------------------- E1 & T1 --------------------- */
+
+#define GIS_ISR3 0x08
+#define GIS_ISR2 0x04
+#define GIS_ISR1 0x02
+#define GIS_ISR0 0x01
+
+
+/* VSTR (Version Status Register)
+
+ --------------------- E1 & T1 --------------------- */
+
+#define VSTR_VN3 0x08
+#define VSTR_VN2 0x04
+#define VSTR_VN1 0x02
+#define VSTR_VN0 0x01
+
+
+/*>>>>>>>>>>>>>>>>>>>>> Local Control Structures <<<<<<<<<<<<<<<<<<<<<<<<< */
+
+/* Write-only Registers (E1/T1 control mode write registers) */
+#define XFIFOH 0x00 /* Tx FIFO High Byte */
+#define XFIFOL 0x01 /* Tx FIFO Low Byte */
+#define CMDR 0x02 /* Command Reg */
+#define DEC 0x60 /* Disable Error Counter */
+#define TEST2 0x62 /* Manuf. Test Reg 2 */
+#define XS(nbr) (0x70 + (nbr)) /* Tx CAS Reg (0 to 15) */
+
+/* Read-write Registers (E1/T1 status mode read registers) */
+#define MODE 0x03 /* Mode Reg */
+#define RAH1 0x04 /* Receive Address High 1 */
+#define RAH2 0x05 /* Receive Address High 2 */
+#define RAL1 0x06 /* Receive Address Low 1 */
+#define RAL2 0x07 /* Receive Address Low 2 */
+#define IPC 0x08 /* Interrupt Port Configuration */
+#define CCR1 0x09 /* Common Configuration Reg 1 */
+#define CCR3 0x0A /* Common Configuration Reg 3 */
+#define PRE 0x0B /* Preamble Reg */
+#define RTR1 0x0C /* Receive Timeslot Reg 1 */
+#define RTR2 0x0D /* Receive Timeslot Reg 2 */
+#define RTR3 0x0E /* Receive Timeslot Reg 3 */
+#define RTR4 0x0F /* Receive Timeslot Reg 4 */
+#define TTR1 0x10 /* Transmit Timeslot Reg 1 */
+#define TTR2 0x11 /* Transmit Timeslot Reg 2 */
+#define TTR3 0x12 /* Transmit Timeslot Reg 3 */
+#define TTR4 0x13 /* Transmit Timeslot Reg 4 */
+#define IMR0 0x14 /* Interrupt Mask Reg 0 */
+#define IMR1 0x15 /* Interrupt Mask Reg 1 */
+#define IMR2 0x16 /* Interrupt Mask Reg 2 */
+#define IMR3 0x17 /* Interrupt Mask Reg 3 */
+#define IMR4 0x18 /* Interrupt Mask Reg 4 */
+#define IMR5 0x19 /* Interrupt Mask Reg 5 */
+#define FMR0 0x1A /* Framer Mode Reigster 0 */
+#define FMR1 0x1B /* Framer Mode Reigster 1 */
+#define FMR2 0x1C /* Framer Mode Reigster 2 */
+#define LOOP 0x1D /* Channel Loop Back */
+#define XSW 0x1E /* Transmit Service Word */
+#define FMR4 0x1E /* Framer Mode Reg 4 */
+#define XSP 0x1F /* Transmit Spare Bits */
+#define FMR5 0x1F /* Framer Mode Reg 5 */
+#define XC0 0x20 /* Transmit Control 0 */
+#define XC1 0x21 /* Transmit Control 1 */
+#define RC0 0x22 /* Receive Control 0 */
+#define RC1 0x23 /* Receive Control 1 */
+#define XPM0 0x24 /* Transmit Pulse Mask 0 */
+#define XPM1 0x25 /* Transmit Pulse Mask 1 */
+#define XPM2 0x26 /* Transmit Pulse Mask 2 */
+#define TSWM 0x27 /* Transparent Service Word Mask */
+#define TEST1 0x28 /* Manuf. Test Reg 1 */
+#define IDLE 0x29 /* Idle Channel Code */
+#define XSA4 0x2A /* Transmit SA4 Bit Reg */
+#define XDL1 0x2A /* Transmit DL-Bit Reg 2 */
+#define XSA5 0x2B /* Transmit SA4 Bit Reg */
+#define XDL2 0x2B /* Transmit DL-Bit Reg 2 */
+#define XSA6 0x2C /* Transmit SA4 Bit Reg */
+#define XDL3 0x2C /* Transmit DL-Bit Reg 2 */
+#define XSA7 0x2D /* Transmit SA4 Bit Reg */
+#define CCB1 0x2D /* Clear Channel Reg 1 */
+#define XSA8 0x2E /* Transmit SA4 Bit Reg */
+#define CCB2 0x2E /* Clear Channel Reg 2 */
+#define FMR3 0x2F /* Framer Mode Reg. 3 */
+#define CCB3 0x2F /* Clear Channel Reg 3 */
+#define ICB1 0x30 /* Idle Channel Reg 1 */
+#define ICB2 0x31 /* Idle Channel Reg 2 */
+#define ICB3 0x32 /* Idle Channel Reg 3 */
+#define ICB4 0x33 /* Idle Channel Reg 4 */
+#define LIM0 0x34 /* Line Interface Mode 0 */
+#define LIM1 0x35 /* Line Interface Mode 1 */
+#define PCDR 0x36 /* Pulse Count Detection */
+#define PCRR 0x37 /* Pulse Count Recovery */
+#define LIM2 0x38 /* Line Interface Mode Reg 2 */
+#define LCR1 0x39 /* Loop Code Reg 1 */
+#define LCR2 0x3A /* Loop Code Reg 2 */
+#define LCR3 0x3B /* Loop Code Reg 3 */
+#define SIC1 0x3C /* System Interface Control 1 */
+
+/* Read-only Registers (E1/T1 control mode read registers) */
+#define RFIFOH 0x00 /* Receive FIFO */
+#define RFIFOL 0x01 /* Receive FIFO */
+#define FRS0 0x4C /* Framer Receive Status 0 */
+#define FRS1 0x4D /* Framer Receive Status 1 */
+#define RSW 0x4E /* Receive Service Word */
+#define FRS2 0x4E /* Framer Receive Status 2 */
+#define RSP 0x4F /* Receive Spare Bits */
+#define FRS3 0x4F /* Framer Receive Status 3 */
+#define FECL 0x50 /* Framing Error Counter */
+#define FECH 0x51 /* Framing Error Counter */
+#define CVCL 0x52 /* Code Violation Counter */
+#define CVCH 0x53 /* Code Violation Counter */
+#define CECL 0x54 /* CRC Error Counter 1 */
+#define CECH 0x55 /* CRC Error Counter 1 */
+#define EBCL 0x56 /* E-Bit Error Counter */
+#define EBCH 0x57 /* E-Bit Error Counter */
+#define BECL 0x58 /* Bit Error Counter Low */
+#define BECH 0x59 /* Bit Error Counter Low */
+#define CEC3 0x5A /* CRC Error Counter 3 (16-bit) */
+#define RSA4 0x5C /* Receive SA4 Bit Reg */
+#define RDL1 0x5C /* Receive DL-Bit Reg 1 */
+#define RSA5 0x5D /* Receive SA5 Bit Reg */
+#define RDL2 0x5D /* Receive DL-Bit Reg 2 */
+#define RSA6 0x5E /* Receive SA6 Bit Reg */
+#define RDL3 0x5E /* Receive DL-Bit Reg 3 */
+#define RSA7 0x5F /* Receive SA7 Bit Reg */
+#define RSA8 0x60 /* Receive SA8 Bit Reg */
+#define RSA6S 0x61 /* Receive SA6 Bit Status Reg */
+#define TSR0 0x62 /* Manuf. Test Reg 0 */
+#define TSR1 0x63 /* Manuf. Test Reg 1 */
+#define SIS 0x64 /* Signaling Status Reg */
+#define RSIS 0x65 /* Receive Signaling Status Reg */
+#define RBCL 0x66 /* Receive Byte Control */
+#define RBCH 0x67 /* Receive Byte Control */
+#define FISR0 0x68 /* Interrupt Status Reg 0 */
+#define FISR1 0x69 /* Interrupt Status Reg 1 */
+#define FISR2 0x6A /* Interrupt Status Reg 2 */
+#define FISR3 0x6B /* Interrupt Status Reg 3 */
+#define GIS 0x6E /* Global Interrupt Status */
+#define VSTR 0x6F /* Version Status */
+#define RS(nbr) (0x70 + (nbr)) /* Rx CAS Reg (0 to 15) */
+
+#endif /* _FALC_LH_H */
+
diff --git a/drivers/staging/net/pc300.h b/drivers/staging/net/pc300.h
new file mode 100644
index 000000000000..2e4f84f6cad4
--- /dev/null
+++ b/drivers/staging/net/pc300.h
@@ -0,0 +1,436 @@
+/*
+ * pc300.h Cyclades-PC300(tm) Kernel API Definitions.
+ *
+ * Author: Ivan Passos <ivan@cyclades.com>
+ *
+ * Copyright: (c) 1999-2002 Cyclades Corp.
+ *
+ * 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.
+ *
+ * $Log: pc300.h,v $
+ * Revision 3.12 2002/03/07 14:17:09 henrique
+ * License data fixed
+ *
+ * Revision 3.11 2002/01/28 21:09:39 daniela
+ * Included ';' after pc300hw.bus.
+ *
+ * Revision 3.10 2002/01/17 17:58:52 ivan
+ * Support for PC300-TE/M (PMC).
+ *
+ * Revision 3.9 2001/09/28 13:30:53 daniela
+ * Renamed dma_start routine to rx_dma_start.
+ *
+ * Revision 3.8 2001/09/24 13:03:45 daniela
+ * Fixed BOF interrupt treatment. Created dma_start routine.
+ *
+ * Revision 3.7 2001/08/10 17:19:58 daniela
+ * Fixed IOCTLs defines.
+ *
+ * Revision 3.6 2001/07/18 19:24:42 daniela
+ * Included kernel version.
+ *
+ * Revision 3.5 2001/07/05 18:38:08 daniela
+ * DMA transmission bug fix.
+ *
+ * Revision 3.4 2001/06/26 17:10:40 daniela
+ * New configuration parameters (line code, CRC calculation and clock).
+ *
+ * Revision 3.3 2001/06/22 13:13:02 regina
+ * MLPPP implementation
+ *
+ * Revision 3.2 2001/06/18 17:56:09 daniela
+ * Increased DEF_MTU and TX_QUEUE_LEN.
+ *
+ * Revision 3.1 2001/06/15 12:41:10 regina
+ * upping major version number
+ *
+ * Revision 1.1.1.1 2001/06/13 20:25:06 daniela
+ * PC300 initial CVS version (3.4.0-pre1)
+ *
+ * Revision 2.3 2001/03/05 daniela
+ * Created struct pc300conf, to provide the hardware information to pc300util.
+ * Inclusion of 'alloc_ramsize' field on structure 'pc300hw'.
+ *
+ * Revision 2.2 2000/12/22 daniela
+ * Structures and defines to support pc300util: statistics, status,
+ * loopback tests, trace.
+ *
+ * Revision 2.1 2000/09/28 ivan
+ * Inclusion of 'iophys' and 'iosize' fields on structure 'pc300hw', to
+ * allow release of I/O region at module unload.
+ * Changed location of include files.
+ *
+ * Revision 2.0 2000/03/27 ivan
+ * Added support for the PC300/TE cards.
+ *
+ * Revision 1.1 2000/01/31 ivan
+ * Replaced 'pc300[drv|sca].h' former PC300 driver include files.
+ *
+ * Revision 1.0 1999/12/16 ivan
+ * First official release.
+ * Inclusion of 'nchan' field on structure 'pc300hw', to allow variable
+ * number of ports per card.
+ * Inclusion of 'if_ptr' field on structure 'pc300dev'.
+ *
+ * Revision 0.6 1999/11/17 ivan
+ * Changed X.25-specific function names to comply with adopted convention.
+ *
+ * Revision 0.5 1999/11/16 Daniela Squassoni
+ * X.25 support.
+ *
+ * Revision 0.4 1999/11/15 ivan
+ * Inclusion of 'clock' field on structure 'pc300hw'.
+ *
+ * Revision 0.3 1999/11/10 ivan
+ * IOCTL name changing.
+ * Inclusion of driver function prototypes.
+ *
+ * Revision 0.2 1999/11/03 ivan
+ * Inclusion of 'tx_skb' and union 'ifu' on structure 'pc300dev'.
+ *
+ * Revision 0.1 1999/01/15 ivan
+ * Initial version.
+ *
+ */
+
+#ifndef _PC300_H
+#define _PC300_H
+
+#include <linux/hdlc.h>
+#include "hd64572.h"
+#include "pc300-falc-lh.h"
+
+#define PC300_PROTO_MLPPP 1
+
+#define PC300_MAXCHAN 2 /* Number of channels per card */
+
+#define PC300_RAMSIZE 0x40000 /* RAM window size (256Kb) */
+#define PC300_FALCSIZE 0x400 /* FALC window size (1Kb) */
+
+#define PC300_OSC_CLOCK 24576000
+#define PC300_PCI_CLOCK 33000000
+
+#define BD_DEF_LEN 0x0800 /* DMA buffer length (2KB) */
+#define DMA_TX_MEMSZ 0x8000 /* Total DMA Tx memory size (32KB/ch) */
+#define DMA_RX_MEMSZ 0x10000 /* Total DMA Rx memory size (64KB/ch) */
+
+#define N_DMA_TX_BUF (DMA_TX_MEMSZ / BD_DEF_LEN) /* DMA Tx buffers */
+#define N_DMA_RX_BUF (DMA_RX_MEMSZ / BD_DEF_LEN) /* DMA Rx buffers */
+
+/* DMA Buffer Offsets */
+#define DMA_TX_BASE ((N_DMA_TX_BUF + N_DMA_RX_BUF) * \
+ PC300_MAXCHAN * sizeof(pcsca_bd_t))
+#define DMA_RX_BASE (DMA_TX_BASE + PC300_MAXCHAN*DMA_TX_MEMSZ)
+
+/* DMA Descriptor Offsets */
+#define DMA_TX_BD_BASE 0x0000
+#define DMA_RX_BD_BASE (DMA_TX_BD_BASE + ((PC300_MAXCHAN*DMA_TX_MEMSZ / \
+ BD_DEF_LEN) * sizeof(pcsca_bd_t)))
+
+/* DMA Descriptor Macros */
+#define TX_BD_ADDR(chan, n) (DMA_TX_BD_BASE + \
+ ((N_DMA_TX_BUF*chan) + n) * sizeof(pcsca_bd_t))
+#define RX_BD_ADDR(chan, n) (DMA_RX_BD_BASE + \
+ ((N_DMA_RX_BUF*chan) + n) * sizeof(pcsca_bd_t))
+
+/* Macro to access the FALC registers (TE only) */
+#define F_REG(reg, chan) (0x200*(chan) + ((reg)<<2))
+
+/***************************************
+ * Memory access functions/macros *
+ * (required to support Alpha systems) *
+ ***************************************/
+#define cpc_writeb(port,val) {writeb((u8)(val),(port)); mb();}
+#define cpc_writew(port,val) {writew((ushort)(val),(port)); mb();}
+#define cpc_writel(port,val) {writel((u32)(val),(port)); mb();}
+
+#define cpc_readb(port) readb(port)
+#define cpc_readw(port) readw(port)
+#define cpc_readl(port) readl(port)
+
+/****** Data Structures *****************************************************/
+
+/*
+ * RUNTIME_9050 - PLX PCI9050-1 local configuration and shared runtime
+ * registers. This structure can be used to access the 9050 registers
+ * (memory mapped).
+ */
+struct RUNTIME_9050 {
+ u32 loc_addr_range[4]; /* 00-0Ch : Local Address Ranges */
+ u32 loc_rom_range; /* 10h : Local ROM Range */
+ u32 loc_addr_base[4]; /* 14-20h : Local Address Base Addrs */
+ u32 loc_rom_base; /* 24h : Local ROM Base */
+ u32 loc_bus_descr[4]; /* 28-34h : Local Bus Descriptors */
+ u32 rom_bus_descr; /* 38h : ROM Bus Descriptor */
+ u32 cs_base[4]; /* 3C-48h : Chip Select Base Addrs */
+ u32 intr_ctrl_stat; /* 4Ch : Interrupt Control/Status */
+ u32 init_ctrl; /* 50h : EEPROM ctrl, Init Ctrl, etc */
+};
+
+#define PLX_9050_LINT1_ENABLE 0x01
+#define PLX_9050_LINT1_POL 0x02
+#define PLX_9050_LINT1_STATUS 0x04
+#define PLX_9050_LINT2_ENABLE 0x08
+#define PLX_9050_LINT2_POL 0x10
+#define PLX_9050_LINT2_STATUS 0x20
+#define PLX_9050_INTR_ENABLE 0x40
+#define PLX_9050_SW_INTR 0x80
+
+/* Masks to access the init_ctrl PLX register */
+#define PC300_CLKSEL_MASK (0x00000004UL)
+#define PC300_CHMEDIA_MASK(chan) (0x00000020UL<<(chan*3))
+#define PC300_CTYPE_MASK (0x00000800UL)
+
+/* CPLD Registers (base addr = falcbase, TE only) */
+/* CPLD v. 0 */
+#define CPLD_REG1 0x140 /* Chip resets, DCD/CTS status */
+#define CPLD_REG2 0x144 /* Clock enable , LED control */
+/* CPLD v. 2 or higher */
+#define CPLD_V2_REG1 0x100 /* Chip resets, DCD/CTS status */
+#define CPLD_V2_REG2 0x104 /* Clock enable , LED control */
+#define CPLD_ID_REG 0x108 /* CPLD version */
+
+/* CPLD Register bit description: for the FALC bits, they should always be
+ set based on the channel (use (bit<<(2*ch)) to access the correct bit for
+ that channel) */
+#define CPLD_REG1_FALC_RESET 0x01
+#define CPLD_REG1_SCA_RESET 0x02
+#define CPLD_REG1_GLOBAL_CLK 0x08
+#define CPLD_REG1_FALC_DCD 0x10
+#define CPLD_REG1_FALC_CTS 0x20
+
+#define CPLD_REG2_FALC_TX_CLK 0x01
+#define CPLD_REG2_FALC_RX_CLK 0x02
+#define CPLD_REG2_FALC_LED1 0x10
+#define CPLD_REG2_FALC_LED2 0x20
+
+/* Structure with FALC-related fields (TE only) */
+#define PC300_FALC_MAXLOOP 0x0000ffff /* for falc_issue_cmd() */
+
+typedef struct falc {
+ u8 sync; /* If true FALC is synchronized */
+ u8 active; /* if TRUE then already active */
+ u8 loop_active; /* if TRUE a line loopback UP was received */
+ u8 loop_gen; /* if TRUE a line loopback UP was issued */
+
+ u8 num_channels;
+ u8 offset; /* 1 for T1, 0 for E1 */
+ u8 full_bandwidth;
+
+ u8 xmb_cause;
+ u8 multiframe_mode;
+
+ /* Statistics */
+ u16 pden; /* Pulse Density violation count */
+ u16 los; /* Loss of Signal count */
+ u16 losr; /* Loss of Signal recovery count */
+ u16 lfa; /* Loss of frame alignment count */
+ u16 farec; /* Frame Alignment Recovery count */
+ u16 lmfa; /* Loss of multiframe alignment count */
+ u16 ais; /* Remote Alarm indication Signal count */
+ u16 sec; /* One-second timer */
+ u16 es; /* Errored second */
+ u16 rai; /* remote alarm received */
+ u16 bec;
+ u16 fec;
+ u16 cvc;
+ u16 cec;
+ u16 ebc;
+
+ /* Status */
+ u8 red_alarm;
+ u8 blue_alarm;
+ u8 loss_fa;
+ u8 yellow_alarm;
+ u8 loss_mfa;
+ u8 prbs;
+} falc_t;
+
+typedef struct falc_status {
+ u8 sync; /* If true FALC is synchronized */
+ u8 red_alarm;
+ u8 blue_alarm;
+ u8 loss_fa;
+ u8 yellow_alarm;
+ u8 loss_mfa;
+ u8 prbs;
+} falc_status_t;
+
+typedef struct rsv_x21_status {
+ u8 dcd;
+ u8 dsr;
+ u8 cts;
+ u8 rts;
+ u8 dtr;
+} rsv_x21_status_t;
+
+typedef struct pc300stats {
+ int hw_type;
+ u32 line_on;
+ u32 line_off;
+ struct net_device_stats gen_stats;
+ falc_t te_stats;
+} pc300stats_t;
+
+typedef struct pc300status {
+ int hw_type;
+ rsv_x21_status_t gen_status;
+ falc_status_t te_status;
+} pc300status_t;
+
+typedef struct pc300loopback {
+ char loop_type;
+ char loop_on;
+} pc300loopback_t;
+
+typedef struct pc300patterntst {
+ char patrntst_on; /* 0 - off; 1 - on; 2 - read num_errors */
+ u16 num_errors;
+} pc300patterntst_t;
+
+typedef struct pc300dev {
+ struct pc300ch *chan;
+ u8 trace_on;
+ u32 line_on; /* DCD(X.21, RSV) / sync(TE) change counters */
+ u32 line_off;
+ char name[16];
+ struct net_device *dev;
+#ifdef CONFIG_PC300_MLPPP
+ void *cpc_tty; /* information to PC300 TTY driver */
+#endif
+}pc300dev_t;
+
+typedef struct pc300hw {
+ int type; /* RSV, X21, etc. */
+ int bus; /* Bus (PCI, PMC, etc.) */
+ int nchan; /* number of channels */
+ int irq; /* interrupt request level */
+ u32 clock; /* Board clock */
+ u8 cpld_id; /* CPLD ID (TE only) */
+ u16 cpld_reg1; /* CPLD reg 1 (TE only) */
+ u16 cpld_reg2; /* CPLD reg 2 (TE only) */
+ u16 gpioc_reg; /* PLX GPIOC reg */
+ u16 intctl_reg; /* PLX Int Ctrl/Status reg */
+ u32 iophys; /* PLX registers I/O base */
+ u32 iosize; /* PLX registers I/O size */
+ u32 plxphys; /* PLX registers MMIO base (physical) */
+ void __iomem * plxbase; /* PLX registers MMIO base (virtual) */
+ u32 plxsize; /* PLX registers MMIO size */
+ u32 scaphys; /* SCA registers MMIO base (physical) */
+ void __iomem * scabase; /* SCA registers MMIO base (virtual) */
+ u32 scasize; /* SCA registers MMIO size */
+ u32 ramphys; /* On-board RAM MMIO base (physical) */
+ void __iomem * rambase; /* On-board RAM MMIO base (virtual) */
+ u32 alloc_ramsize; /* RAM MMIO size allocated by the PCI bridge */
+ u32 ramsize; /* On-board RAM MMIO size */
+ u32 falcphys; /* FALC registers MMIO base (physical) */
+ void __iomem * falcbase;/* FALC registers MMIO base (virtual) */
+ u32 falcsize; /* FALC registers MMIO size */
+} pc300hw_t;
+
+typedef struct pc300chconf {
+ sync_serial_settings phys_settings; /* Clock type/rate (in bps),
+ loopback mode */
+ raw_hdlc_proto proto_settings; /* Encoding, parity (CRC) */
+ u32 media; /* HW media (RS232, V.35, etc.) */
+ u32 proto; /* Protocol (PPP, X.25, etc.) */
+
+ /* TE-specific parameters */
+ u8 lcode; /* Line Code (AMI, B8ZS, etc.) */
+ u8 fr_mode; /* Frame Mode (ESF, D4, etc.) */
+ u8 lbo; /* Line Build Out */
+ u8 rx_sens; /* Rx Sensitivity (long- or short-haul) */
+ u32 tslot_bitmap; /* bit[i]=1 => timeslot _i_ is active */
+} pc300chconf_t;
+
+typedef struct pc300ch {
+ struct pc300 *card;
+ int channel;
+ pc300dev_t d;
+ pc300chconf_t conf;
+ u8 tx_first_bd; /* First TX DMA block descr. w/ data */
+ u8 tx_next_bd; /* Next free TX DMA block descriptor */
+ u8 rx_first_bd; /* First free RX DMA block descriptor */
+ u8 rx_last_bd; /* Last free RX DMA block descriptor */
+ u8 nfree_tx_bd; /* Number of free TX DMA block descriptors */
+ falc_t falc; /* FALC structure (TE only) */
+} pc300ch_t;
+
+typedef struct pc300 {
+ pc300hw_t hw; /* hardware config. */
+ pc300ch_t chan[PC300_MAXCHAN];
+ spinlock_t card_lock;
+} pc300_t;
+
+typedef struct pc300conf {
+ pc300hw_t hw;
+ pc300chconf_t conf;
+} pc300conf_t;
+
+/* DEV ioctl() commands */
+#define N_SPPP_IOCTLS 2
+
+enum pc300_ioctl_cmds {
+ SIOCCPCRESERVED = (SIOCDEVPRIVATE + N_SPPP_IOCTLS),
+ SIOCGPC300CONF,
+ SIOCSPC300CONF,
+ SIOCGPC300STATUS,
+ SIOCGPC300FALCSTATUS,
+ SIOCGPC300UTILSTATS,
+ SIOCGPC300UTILSTATUS,
+ SIOCSPC300TRACE,
+ SIOCSPC300LOOPBACK,
+ SIOCSPC300PATTERNTEST,
+};
+
+/* Loopback types - PC300/TE boards */
+enum pc300_loopback_cmds {
+ PC300LOCLOOP = 1,
+ PC300REMLOOP,
+ PC300PAYLOADLOOP,
+ PC300GENLOOPUP,
+ PC300GENLOOPDOWN,
+};
+
+/* Control Constant Definitions */
+#define PC300_RSV 0x01
+#define PC300_X21 0x02
+#define PC300_TE 0x03
+
+#define PC300_PCI 0x00
+#define PC300_PMC 0x01
+
+#define PC300_LC_AMI 0x01
+#define PC300_LC_B8ZS 0x02
+#define PC300_LC_NRZ 0x03
+#define PC300_LC_HDB3 0x04
+
+/* Framing (T1) */
+#define PC300_FR_ESF 0x01
+#define PC300_FR_D4 0x02
+#define PC300_FR_ESF_JAPAN 0x03
+
+/* Framing (E1) */
+#define PC300_FR_MF_CRC4 0x04
+#define PC300_FR_MF_NON_CRC4 0x05
+#define PC300_FR_UNFRAMED 0x06
+
+#define PC300_LBO_0_DB 0x00
+#define PC300_LBO_7_5_DB 0x01
+#define PC300_LBO_15_DB 0x02
+#define PC300_LBO_22_5_DB 0x03
+
+#define PC300_RX_SENS_SH 0x01
+#define PC300_RX_SENS_LH 0x02
+
+#define PC300_TX_TIMEOUT (2*HZ)
+#define PC300_TX_QUEUE_LEN 100
+#define PC300_DEF_MTU 1600
+
+/* Function Prototypes */
+int cpc_open(struct net_device *dev);
+
+#endif /* _PC300_H */
diff --git a/drivers/staging/net/pc300_drv.c b/drivers/staging/net/pc300_drv.c
new file mode 100644
index 000000000000..cb0f8d932b0c
--- /dev/null
+++ b/drivers/staging/net/pc300_drv.c
@@ -0,0 +1,3670 @@
+#define USE_PCI_CLOCK
+static const char rcsid[] =
+"Revision: 3.4.5 Date: 2002/03/07 ";
+
+/*
+ * pc300.c Cyclades-PC300(tm) Driver.
+ *
+ * Author: Ivan Passos <ivan@cyclades.com>
+ * Maintainer: PC300 Maintainer <pc300@cyclades.com>
+ *
+ * Copyright: (c) 1999-2003 Cyclades Corp.
+ *
+ * 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.
+ *
+ * Using tabstop = 4.
+ *
+ * $Log: pc300_drv.c,v $
+ * Revision 3.23 2002/03/20 13:58:40 henrique
+ * Fixed ortographic mistakes
+ *
+ * Revision 3.22 2002/03/13 16:56:56 henrique
+ * Take out the debug messages
+ *
+ * Revision 3.21 2002/03/07 14:17:09 henrique
+ * License data fixed
+ *
+ * Revision 3.20 2002/01/17 17:58:52 ivan
+ * Support for PC300-TE/M (PMC).
+ *
+ * Revision 3.19 2002/01/03 17:08:47 daniela
+ * Enables DMA reception when the SCA-II disables it improperly.
+ *
+ * Revision 3.18 2001/12/03 18:47:50 daniela
+ * Esthetic changes.
+ *
+ * Revision 3.17 2001/10/19 16:50:13 henrique
+ * Patch to kernel 2.4.12 and new generic hdlc.
+ *
+ * Revision 3.16 2001/10/16 15:12:31 regina
+ * clear statistics
+ *
+ * Revision 3.11 to 3.15 2001/10/11 20:26:04 daniela
+ * More DMA fixes for noisy lines.
+ * Return the size of bad frames in dma_get_rx_frame_size, so that the Rx buffer
+ * descriptors can be cleaned by dma_buf_read (called in cpc_net_rx).
+ * Renamed dma_start routine to rx_dma_start. Improved Rx statistics.
+ * Fixed BOF interrupt treatment. Created dma_start routine.
+ * Changed min and max to cpc_min and cpc_max.
+ *
+ * Revision 3.10 2001/08/06 12:01:51 regina
+ * Fixed problem in DSR_DE bit.
+ *
+ * Revision 3.9 2001/07/18 19:27:26 daniela
+ * Added some history comments.
+ *
+ * Revision 3.8 2001/07/12 13:11:19 regina
+ * bug fix - DCD-OFF in pc300 tty driver
+ *
+ * Revision 3.3 to 3.7 2001/07/06 15:00:20 daniela
+ * Removing kernel 2.4.3 and previous support.
+ * DMA transmission bug fix.
+ * MTU check in cpc_net_rx fixed.
+ * Boot messages reviewed.
+ * New configuration parameters (line code, CRC calculation and clock).
+ *
+ * Revision 3.2 2001/06/22 13:13:02 regina
+ * MLPPP implementation. Changed the header of message trace to include
+ * the device name. New format : "hdlcX[R/T]: ".
+ * Default configuration changed.
+ *
+ * Revision 3.1 2001/06/15 regina
+ * in cpc_queue_xmit, netif_stop_queue is called if don't have free descriptor
+ * upping major version number
+ *
+ * Revision 1.1.1.1 2001/06/13 20:25:04 daniela
+ * PC300 initial CVS version (3.4.0-pre1)
+ *
+ * Revision 3.0.1.2 2001/06/08 daniela
+ * Did some changes in the DMA programming implementation to avoid the
+ * occurrence of a SCA-II bug when CDA is accessed during a DMA transfer.
+ *
+ * Revision 3.0.1.1 2001/05/02 daniela
+ * Added kernel 2.4.3 support.
+ *
+ * Revision 3.0.1.0 2001/03/13 daniela, henrique
+ * Added Frame Relay Support.
+ * Driver now uses HDLC generic driver to provide protocol support.
+ *
+ * Revision 3.0.0.8 2001/03/02 daniela
+ * Fixed ram size detection.
+ * Changed SIOCGPC300CONF ioctl, to give hw information to pc300util.
+ *
+ * Revision 3.0.0.7 2001/02/23 daniela
+ * netif_stop_queue called before the SCA-II transmition commands in
+ * cpc_queue_xmit, and with interrupts disabled to avoid race conditions with
+ * transmition interrupts.
+ * Fixed falc_check_status for Unframed E1.
+ *
+ * Revision 3.0.0.6 2000/12/13 daniela
+ * Implemented pc300util support: trace, statistics, status and loopback
+ * tests for the PC300 TE boards.
+ *
+ * Revision 3.0.0.5 2000/12/12 ivan
+ * Added support for Unframed E1.
+ * Implemented monitor mode.
+ * Fixed DCD sensitivity on the second channel.
+ * Driver now complies with new PCI kernel architecture.
+ *
+ * Revision 3.0.0.4 2000/09/28 ivan
+ * Implemented DCD sensitivity.
+ * Moved hardware-specific open to the end of cpc_open, to avoid race
+ * conditions with early reception interrupts.
+ * Included code for [request|release]_mem_region().
+ * Changed location of pc300.h .
+ * Minor code revision (contrib. of Jeff Garzik).
+ *
+ * Revision 3.0.0.3 2000/07/03 ivan
+ * Previous bugfix for the framing errors with external clock made X21
+ * boards stop working. This version fixes it.
+ *
+ * Revision 3.0.0.2 2000/06/23 ivan
+ * Revisited cpc_queue_xmit to prevent race conditions on Tx DMA buffer
+ * handling when Tx timeouts occur.
+ * Revisited Rx statistics.
+ * Fixed a bug in the SCA-II programming that would cause framing errors
+ * when external clock was configured.
+ *
+ * Revision 3.0.0.1 2000/05/26 ivan
+ * Added logic in the SCA interrupt handler so that no board can monopolize
+ * the driver.
+ * Request PLX I/O region, although driver doesn't use it, to avoid
+ * problems with other drivers accessing it.
+ *
+ * Revision 3.0.0.0 2000/05/15 ivan
+ * Did some changes in the DMA programming implementation to avoid the
+ * occurrence of a SCA-II bug in the second channel.
+ * Implemented workaround for PLX9050 bug that would cause a system lockup
+ * in certain systems, depending on the MMIO addresses allocated to the
+ * board.
+ * Fixed the FALC chip programming to avoid synchronization problems in the
+ * second channel (TE only).
+ * Implemented a cleaner and faster Tx DMA descriptor cleanup procedure in
+ * cpc_queue_xmit().
+ * Changed the built-in driver implementation so that the driver can use the
+ * general 'hdlcN' naming convention instead of proprietary device names.
+ * Driver load messages are now device-centric, instead of board-centric.
+ * Dynamic allocation of net_device structures.
+ * Code is now compliant with the new module interface (module_[init|exit]).
+ * Make use of the PCI helper functions to access PCI resources.
+ *
+ * Revision 2.0.0.0 2000/04/15 ivan
+ * Added support for the PC300/TE boards (T1/FT1/E1/FE1).
+ *
+ * Revision 1.1.0.0 2000/02/28 ivan
+ * Major changes in the driver architecture.
+ * Softnet compliancy implemented.
+ * Driver now reports physical instead of virtual memory addresses.
+ * Added cpc_change_mtu function.
+ *
+ * Revision 1.0.0.0 1999/12/16 ivan
+ * First official release.
+ * Support for 1- and 2-channel boards (which use distinct PCI Device ID's).
+ * Support for monolythic installation (i.e., drv built into the kernel).
+ * X.25 additional checking when lapb_[dis]connect_request returns an error.
+ * SCA programming now covers X.21 as well.
+ *
+ * Revision 0.3.1.0 1999/11/18 ivan
+ * Made X.25 support configuration-dependent (as it depends on external
+ * modules to work).
+ * Changed X.25-specific function names to comply with adopted convention.
+ * Fixed typos in X.25 functions that would cause compile errors (Daniela).
+ * Fixed bug in ch_config that would disable interrupts on a previously
+ * enabled channel if the other channel on the same board was enabled later.
+ *
+ * Revision 0.3.0.0 1999/11/16 daniela
+ * X.25 support.
+ *
+ * Revision 0.2.3.0 1999/11/15 ivan
+ * Function cpc_ch_status now provides more detailed information.
+ * Added support for X.21 clock configuration.
+ * Changed TNR1 setting in order to prevent Tx FIFO overaccesses by the SCA.
+ * Now using PCI clock instead of internal oscillator clock for the SCA.
+ *
+ * Revision 0.2.2.0 1999/11/10 ivan
+ * Changed the *_dma_buf_check functions so that they would print only
+ * the useful info instead of the whole buffer descriptor bank.
+ * Fixed bug in cpc_queue_xmit that would eventually crash the system
+ * in case of a packet drop.
+ * Implemented TX underrun handling.
+ * Improved SCA fine tuning to boost up its performance.
+ *
+ * Revision 0.2.1.0 1999/11/03 ivan
+ * Added functions *dma_buf_pt_init to allow independent initialization
+ * of the next-descr. and DMA buffer pointers on the DMA descriptors.
+ * Kernel buffer release and tbusy clearing is now done in the interrupt
+ * handler.
+ * Fixed bug in cpc_open that would cause an interface reopen to fail.
+ * Added a protocol-specific code section in cpc_net_rx.
+ * Removed printk level defs (they might be added back after the beta phase).
+ *
+ * Revision 0.2.0.0 1999/10/28 ivan
+ * Revisited the code so that new protocols can be easily added / supported.
+ *
+ * Revision 0.1.0.1 1999/10/20 ivan
+ * Mostly "esthetic" changes.
+ *
+ * Revision 0.1.0.0 1999/10/11 ivan
+ * Initial version.
+ *
+ */
+
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/mm.h>
+#include <linux/ioport.h>
+#include <linux/pci.h>
+#include <linux/errno.h>
+#include <linux/string.h>
+#include <linux/init.h>
+#include <linux/delay.h>
+#include <linux/net.h>
+#include <linux/skbuff.h>
+#include <linux/if_arp.h>
+#include <linux/netdevice.h>
+#include <linux/etherdevice.h>
+#include <linux/spinlock.h>
+#include <linux/if.h>
+#include <linux/slab.h>
+#include <net/arp.h>
+
+#include <asm/io.h>
+#include <asm/uaccess.h>
+
+#include "pc300.h"
+
+#define CPC_LOCK(card,flags) \
+ do { \
+ spin_lock_irqsave(&card->card_lock, flags); \
+ } while (0)
+
+#define CPC_UNLOCK(card,flags) \
+ do { \
+ spin_unlock_irqrestore(&card->card_lock, flags); \
+ } while (0)
+
+#undef PC300_DEBUG_PCI
+#undef PC300_DEBUG_INTR
+#undef PC300_DEBUG_TX
+#undef PC300_DEBUG_RX
+#undef PC300_DEBUG_OTHER
+
+static DEFINE_PCI_DEVICE_TABLE(cpc_pci_dev_id) = {
+ /* PC300/RSV or PC300/X21, 2 chan */
+ {0x120e, 0x300, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0x300},
+ /* PC300/RSV or PC300/X21, 1 chan */
+ {0x120e, 0x301, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0x301},
+ /* PC300/TE, 2 chan */
+ {0x120e, 0x310, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0x310},
+ /* PC300/TE, 1 chan */
+ {0x120e, 0x311, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0x311},
+ /* PC300/TE-M, 2 chan */
+ {0x120e, 0x320, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0x320},
+ /* PC300/TE-M, 1 chan */
+ {0x120e, 0x321, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0x321},
+ /* End of table */
+ {0,},
+};
+MODULE_DEVICE_TABLE(pci, cpc_pci_dev_id);
+
+#ifndef cpc_min
+#define cpc_min(a,b) (((a)<(b))?(a):(b))
+#endif
+#ifndef cpc_max
+#define cpc_max(a,b) (((a)>(b))?(a):(b))
+#endif
+
+/* prototypes */
+static void tx_dma_buf_pt_init(pc300_t *, int);
+static void tx_dma_buf_init(pc300_t *, int);
+static void rx_dma_buf_pt_init(pc300_t *, int);
+static void rx_dma_buf_init(pc300_t *, int);
+static void tx_dma_buf_check(pc300_t *, int);
+static void rx_dma_buf_check(pc300_t *, int);
+static irqreturn_t cpc_intr(int, void *);
+static int clock_rate_calc(u32, u32, int *);
+static u32 detect_ram(pc300_t *);
+static void plx_init(pc300_t *);
+static void cpc_trace(struct net_device *, struct sk_buff *, char);
+static int cpc_attach(struct net_device *, unsigned short, unsigned short);
+static int cpc_close(struct net_device *dev);
+
+#ifdef CONFIG_PC300_MLPPP
+void cpc_tty_init(pc300dev_t * dev);
+void cpc_tty_unregister_service(pc300dev_t * pc300dev);
+void cpc_tty_receive(pc300dev_t * pc300dev);
+void cpc_tty_trigger_poll(pc300dev_t * pc300dev);
+#endif
+
+/************************/
+/*** DMA Routines ***/
+/************************/
+static void tx_dma_buf_pt_init(pc300_t * card, int ch)
+{
+ int i;
+ int ch_factor = ch * N_DMA_TX_BUF;
+ volatile pcsca_bd_t __iomem *ptdescr = (card->hw.rambase
+ + DMA_TX_BD_BASE + ch_factor * sizeof(pcsca_bd_t));
+
+ for (i = 0; i < N_DMA_TX_BUF; i++, ptdescr++) {
+ cpc_writel(&ptdescr->next, (u32)(DMA_TX_BD_BASE +
+ (ch_factor + ((i + 1) & (N_DMA_TX_BUF - 1))) * sizeof(pcsca_bd_t)));
+ cpc_writel(&ptdescr->ptbuf,
+ (u32)(DMA_TX_BASE + (ch_factor + i) * BD_DEF_LEN));
+ }
+}
+
+static void tx_dma_buf_init(pc300_t * card, int ch)
+{
+ int i;
+ int ch_factor = ch * N_DMA_TX_BUF;
+ volatile pcsca_bd_t __iomem *ptdescr = (card->hw.rambase
+ + DMA_TX_BD_BASE + ch_factor * sizeof(pcsca_bd_t));
+
+ for (i = 0; i < N_DMA_TX_BUF; i++, ptdescr++) {
+ memset_io(ptdescr, 0, sizeof(pcsca_bd_t));
+ cpc_writew(&ptdescr->len, 0);
+ cpc_writeb(&ptdescr->status, DST_OSB);
+ }
+ tx_dma_buf_pt_init(card, ch);
+}
+
+static void rx_dma_buf_pt_init(pc300_t * card, int ch)
+{
+ int i;
+ int ch_factor = ch * N_DMA_RX_BUF;
+ volatile pcsca_bd_t __iomem *ptdescr = (card->hw.rambase
+ + DMA_RX_BD_BASE + ch_factor * sizeof(pcsca_bd_t));
+
+ for (i = 0; i < N_DMA_RX_BUF; i++, ptdescr++) {
+ cpc_writel(&ptdescr->next, (u32)(DMA_RX_BD_BASE +
+ (ch_factor + ((i + 1) & (N_DMA_RX_BUF - 1))) * sizeof(pcsca_bd_t)));
+ cpc_writel(&ptdescr->ptbuf,
+ (u32)(DMA_RX_BASE + (ch_factor + i) * BD_DEF_LEN));
+ }
+}
+
+static void rx_dma_buf_init(pc300_t * card, int ch)
+{
+ int i;
+ int ch_factor = ch * N_DMA_RX_BUF;
+ volatile pcsca_bd_t __iomem *ptdescr = (card->hw.rambase
+ + DMA_RX_BD_BASE + ch_factor * sizeof(pcsca_bd_t));
+
+ for (i = 0; i < N_DMA_RX_BUF; i++, ptdescr++) {
+ memset_io(ptdescr, 0, sizeof(pcsca_bd_t));
+ cpc_writew(&ptdescr->len, 0);
+ cpc_writeb(&ptdescr->status, 0);
+ }
+ rx_dma_buf_pt_init(card, ch);
+}
+
+static void tx_dma_buf_check(pc300_t * card, int ch)
+{
+ volatile pcsca_bd_t __iomem *ptdescr;
+ int i;
+ u16 first_bd = card->chan[ch].tx_first_bd;
+ u16 next_bd = card->chan[ch].tx_next_bd;
+
+ printk("#CH%d: f_bd = %d(0x%08zx), n_bd = %d(0x%08zx)\n", ch,
+ first_bd, TX_BD_ADDR(ch, first_bd),
+ next_bd, TX_BD_ADDR(ch, next_bd));
+ for (i = first_bd,
+ ptdescr = (card->hw.rambase + TX_BD_ADDR(ch, first_bd));
+ i != ((next_bd + 1) & (N_DMA_TX_BUF - 1));
+ i = (i + 1) & (N_DMA_TX_BUF - 1),
+ ptdescr = (card->hw.rambase + TX_BD_ADDR(ch, i))) {
+ printk("\n CH%d TX%d: next=0x%x, ptbuf=0x%x, ST=0x%x, len=%d",
+ ch, i, cpc_readl(&ptdescr->next),
+ cpc_readl(&ptdescr->ptbuf),
+ cpc_readb(&ptdescr->status), cpc_readw(&ptdescr->len));
+ }
+ printk("\n");
+}
+
+#ifdef PC300_DEBUG_OTHER
+/* Show all TX buffer descriptors */
+static void tx1_dma_buf_check(pc300_t * card, int ch)
+{
+ volatile pcsca_bd_t __iomem *ptdescr;
+ int i;
+ u16 first_bd = card->chan[ch].tx_first_bd;
+ u16 next_bd = card->chan[ch].tx_next_bd;
+ u32 scabase = card->hw.scabase;
+
+ printk ("\nnfree_tx_bd = %d\n", card->chan[ch].nfree_tx_bd);
+ printk("#CH%d: f_bd = %d(0x%08x), n_bd = %d(0x%08x)\n", ch,
+ first_bd, TX_BD_ADDR(ch, first_bd),
+ next_bd, TX_BD_ADDR(ch, next_bd));
+ printk("TX_CDA=0x%08x, TX_EDA=0x%08x\n",
+ cpc_readl(scabase + DTX_REG(CDAL, ch)),
+ cpc_readl(scabase + DTX_REG(EDAL, ch)));
+ for (i = 0; i < N_DMA_TX_BUF; i++) {
+ ptdescr = (card->hw.rambase + TX_BD_ADDR(ch, i));
+ printk("\n CH%d TX%d: next=0x%x, ptbuf=0x%x, ST=0x%x, len=%d",
+ ch, i, cpc_readl(&ptdescr->next),
+ cpc_readl(&ptdescr->ptbuf),
+ cpc_readb(&ptdescr->status), cpc_readw(&ptdescr->len));
+ }
+ printk("\n");
+}
+#endif
+
+static void rx_dma_buf_check(pc300_t * card, int ch)
+{
+ volatile pcsca_bd_t __iomem *ptdescr;
+ int i;
+ u16 first_bd = card->chan[ch].rx_first_bd;
+ u16 last_bd = card->chan[ch].rx_last_bd;
+ int ch_factor;
+
+ ch_factor = ch * N_DMA_RX_BUF;
+ printk("#CH%d: f_bd = %d, l_bd = %d\n", ch, first_bd, last_bd);
+ for (i = 0, ptdescr = (card->hw.rambase +
+ DMA_RX_BD_BASE + ch_factor * sizeof(pcsca_bd_t));
+ i < N_DMA_RX_BUF; i++, ptdescr++) {
+ if (cpc_readb(&ptdescr->status) & DST_OSB)
+ printk ("\n CH%d RX%d: next=0x%x, ptbuf=0x%x, ST=0x%x, len=%d",
+ ch, i, cpc_readl(&ptdescr->next),
+ cpc_readl(&ptdescr->ptbuf),
+ cpc_readb(&ptdescr->status),
+ cpc_readw(&ptdescr->len));
+ }
+ printk("\n");
+}
+
+static int dma_get_rx_frame_size(pc300_t * card, int ch)
+{
+ volatile pcsca_bd_t __iomem *ptdescr;
+ u16 first_bd = card->chan[ch].rx_first_bd;
+ int rcvd = 0;
+ volatile u8 status;
+
+ ptdescr = (card->hw.rambase + RX_BD_ADDR(ch, first_bd));
+ while ((status = cpc_readb(&ptdescr->status)) & DST_OSB) {
+ rcvd += cpc_readw(&ptdescr->len);
+ first_bd = (first_bd + 1) & (N_DMA_RX_BUF - 1);
+ if ((status & DST_EOM) || (first_bd == card->chan[ch].rx_last_bd)) {
+ /* Return the size of a good frame or incomplete bad frame
+ * (dma_buf_read will clean the buffer descriptors in this case). */
+ return rcvd;
+ }
+ ptdescr = (card->hw.rambase + cpc_readl(&ptdescr->next));
+ }
+ return -1;
+}
+
+/*
+ * dma_buf_write: writes a frame to the Tx DMA buffers
+ * NOTE: this function writes one frame at a time.
+ */
+static int dma_buf_write(pc300_t *card, int ch, u8 *ptdata, int len)
+{
+ int i, nchar;
+ volatile pcsca_bd_t __iomem *ptdescr;
+ int tosend = len;
+ u8 nbuf = ((len - 1) / BD_DEF_LEN) + 1;
+
+ if (nbuf >= card->chan[ch].nfree_tx_bd) {
+ return -ENOMEM;
+ }
+
+ for (i = 0; i < nbuf; i++) {
+ ptdescr = (card->hw.rambase +
+ TX_BD_ADDR(ch, card->chan[ch].tx_next_bd));
+ nchar = cpc_min(BD_DEF_LEN, tosend);
+ if (cpc_readb(&ptdescr->status) & DST_OSB) {
+ memcpy_toio((card->hw.rambase + cpc_readl(&ptdescr->ptbuf)),
+ &ptdata[len - tosend], nchar);
+ cpc_writew(&ptdescr->len, nchar);
+ card->chan[ch].nfree_tx_bd--;
+ if ((i + 1) == nbuf) {
+ /* This must be the last BD to be used */
+ cpc_writeb(&ptdescr->status, DST_EOM);
+ } else {
+ cpc_writeb(&ptdescr->status, 0);
+ }
+ } else {
+ return -ENOMEM;
+ }
+ tosend -= nchar;
+ card->chan[ch].tx_next_bd =
+ (card->chan[ch].tx_next_bd + 1) & (N_DMA_TX_BUF - 1);
+ }
+ /* If it gets to here, it means we have sent the whole frame */
+ return 0;
+}
+
+/*
+ * dma_buf_read: reads a frame from the Rx DMA buffers
+ * NOTE: this function reads one frame at a time.
+ */
+static int dma_buf_read(pc300_t * card, int ch, struct sk_buff *skb)
+{
+ int nchar;
+ pc300ch_t *chan = (pc300ch_t *) & card->chan[ch];
+ volatile pcsca_bd_t __iomem *ptdescr;
+ int rcvd = 0;
+ volatile u8 status;
+
+ ptdescr = (card->hw.rambase +
+ RX_BD_ADDR(ch, chan->rx_first_bd));
+ while ((status = cpc_readb(&ptdescr->status)) & DST_OSB) {
+ nchar = cpc_readw(&ptdescr->len);
+ if ((status & (DST_OVR | DST_CRC | DST_RBIT | DST_SHRT | DST_ABT)) ||
+ (nchar > BD_DEF_LEN)) {
+
+ if (nchar > BD_DEF_LEN)
+ status |= DST_RBIT;
+ rcvd = -status;
+ /* Discard remaining descriptors used by the bad frame */
+ while (chan->rx_first_bd != chan->rx_last_bd) {
+ cpc_writeb(&ptdescr->status, 0);
+ chan->rx_first_bd = (chan->rx_first_bd+1) & (N_DMA_RX_BUF-1);
+ if (status & DST_EOM)
+ break;
+ ptdescr = (card->hw.rambase +
+ cpc_readl(&ptdescr->next));
+ status = cpc_readb(&ptdescr->status);
+ }
+ break;
+ }
+ if (nchar != 0) {
+ if (skb) {
+ memcpy_fromio(skb_put(skb, nchar),
+ (card->hw.rambase+cpc_readl(&ptdescr->ptbuf)),nchar);
+ }
+ rcvd += nchar;
+ }
+ cpc_writeb(&ptdescr->status, 0);
+ cpc_writeb(&ptdescr->len, 0);
+ chan->rx_first_bd = (chan->rx_first_bd + 1) & (N_DMA_RX_BUF - 1);
+
+ if (status & DST_EOM)
+ break;
+
+ ptdescr = (card->hw.rambase + cpc_readl(&ptdescr->next));
+ }
+
+ if (rcvd != 0) {
+ /* Update pointer */
+ chan->rx_last_bd = (chan->rx_first_bd - 1) & (N_DMA_RX_BUF - 1);
+ /* Update EDA */
+ cpc_writel(card->hw.scabase + DRX_REG(EDAL, ch),
+ RX_BD_ADDR(ch, chan->rx_last_bd));
+ }
+ return rcvd;
+}
+
+static void tx_dma_stop(pc300_t * card, int ch)
+{
+ void __iomem *scabase = card->hw.scabase;
+ u8 drr_ena_bit = 1 << (5 + 2 * ch);
+ u8 drr_rst_bit = 1 << (1 + 2 * ch);
+
+ /* Disable DMA */
+ cpc_writeb(scabase + DRR, drr_ena_bit);
+ cpc_writeb(scabase + DRR, drr_rst_bit & ~drr_ena_bit);
+}
+
+static void rx_dma_stop(pc300_t * card, int ch)
+{
+ void __iomem *scabase = card->hw.scabase;
+ u8 drr_ena_bit = 1 << (4 + 2 * ch);
+ u8 drr_rst_bit = 1 << (2 * ch);
+
+ /* Disable DMA */
+ cpc_writeb(scabase + DRR, drr_ena_bit);
+ cpc_writeb(scabase + DRR, drr_rst_bit & ~drr_ena_bit);
+}
+
+static void rx_dma_start(pc300_t * card, int ch)
+{
+ void __iomem *scabase = card->hw.scabase;
+ pc300ch_t *chan = (pc300ch_t *) & card->chan[ch];
+
+ /* Start DMA */
+ cpc_writel(scabase + DRX_REG(CDAL, ch),
+ RX_BD_ADDR(ch, chan->rx_first_bd));
+ if (cpc_readl(scabase + DRX_REG(CDAL,ch)) !=
+ RX_BD_ADDR(ch, chan->rx_first_bd)) {
+ cpc_writel(scabase + DRX_REG(CDAL, ch),
+ RX_BD_ADDR(ch, chan->rx_first_bd));
+ }
+ cpc_writel(scabase + DRX_REG(EDAL, ch),
+ RX_BD_ADDR(ch, chan->rx_last_bd));
+ cpc_writew(scabase + DRX_REG(BFLL, ch), BD_DEF_LEN);
+ cpc_writeb(scabase + DSR_RX(ch), DSR_DE);
+ if (!(cpc_readb(scabase + DSR_RX(ch)) & DSR_DE)) {
+ cpc_writeb(scabase + DSR_RX(ch), DSR_DE);
+ }
+}
+
+/*************************/
+/*** FALC Routines ***/
+/*************************/
+static void falc_issue_cmd(pc300_t *card, int ch, u8 cmd)
+{
+ void __iomem *falcbase = card->hw.falcbase;
+ unsigned long i = 0;
+
+ while (cpc_readb(falcbase + F_REG(SIS, ch)) & SIS_CEC) {
+ if (i++ >= PC300_FALC_MAXLOOP) {
+ printk("%s: FALC command locked(cmd=0x%x).\n",
+ card->chan[ch].d.name, cmd);
+ break;
+ }
+ }
+ cpc_writeb(falcbase + F_REG(CMDR, ch), cmd);
+}
+
+static void falc_intr_enable(pc300_t * card, int ch)
+{
+ pc300ch_t *chan = (pc300ch_t *) & card->chan[ch];
+ pc300chconf_t *conf = (pc300chconf_t *) & chan->conf;
+ falc_t *pfalc = (falc_t *) & chan->falc;
+ void __iomem *falcbase = card->hw.falcbase;
+
+ /* Interrupt pins are open-drain */
+ cpc_writeb(falcbase + F_REG(IPC, ch),
+ cpc_readb(falcbase + F_REG(IPC, ch)) & ~IPC_IC0);
+ /* Conters updated each second */
+ cpc_writeb(falcbase + F_REG(FMR1, ch),
+ cpc_readb(falcbase + F_REG(FMR1, ch)) | FMR1_ECM);
+ /* Enable SEC and ES interrupts */
+ cpc_writeb(falcbase + F_REG(IMR3, ch),
+ cpc_readb(falcbase + F_REG(IMR3, ch)) & ~(IMR3_SEC | IMR3_ES));
+ if (conf->fr_mode == PC300_FR_UNFRAMED) {
+ cpc_writeb(falcbase + F_REG(IMR4, ch),
+ cpc_readb(falcbase + F_REG(IMR4, ch)) & ~(IMR4_LOS));
+ } else {
+ cpc_writeb(falcbase + F_REG(IMR4, ch),
+ cpc_readb(falcbase + F_REG(IMR4, ch)) &
+ ~(IMR4_LFA | IMR4_AIS | IMR4_LOS | IMR4_SLIP));
+ }
+ if (conf->media == IF_IFACE_T1) {
+ cpc_writeb(falcbase + F_REG(IMR3, ch),
+ cpc_readb(falcbase + F_REG(IMR3, ch)) & ~IMR3_LLBSC);
+ } else {
+ cpc_writeb(falcbase + F_REG(IPC, ch),
+ cpc_readb(falcbase + F_REG(IPC, ch)) | IPC_SCI);
+ if (conf->fr_mode == PC300_FR_UNFRAMED) {
+ cpc_writeb(falcbase + F_REG(IMR2, ch),
+ cpc_readb(falcbase + F_REG(IMR2, ch)) & ~(IMR2_LOS));
+ } else {
+ cpc_writeb(falcbase + F_REG(IMR2, ch),
+ cpc_readb(falcbase + F_REG(IMR2, ch)) &
+ ~(IMR2_FAR | IMR2_LFA | IMR2_AIS | IMR2_LOS));
+ if (pfalc->multiframe_mode) {
+ cpc_writeb(falcbase + F_REG(IMR2, ch),
+ cpc_readb(falcbase + F_REG(IMR2, ch)) &
+ ~(IMR2_T400MS | IMR2_MFAR));
+ } else {
+ cpc_writeb(falcbase + F_REG(IMR2, ch),
+ cpc_readb(falcbase + F_REG(IMR2, ch)) |
+ IMR2_T400MS | IMR2_MFAR);
+ }
+ }
+ }
+}
+
+static void falc_open_timeslot(pc300_t * card, int ch, int timeslot)
+{
+ void __iomem *falcbase = card->hw.falcbase;
+ u8 tshf = card->chan[ch].falc.offset;
+
+ cpc_writeb(falcbase + F_REG((ICB1 + (timeslot - tshf) / 8), ch),
+ cpc_readb(falcbase + F_REG((ICB1 + (timeslot - tshf) / 8), ch)) &
+ ~(0x80 >> ((timeslot - tshf) & 0x07)));
+ cpc_writeb(falcbase + F_REG((TTR1 + timeslot / 8), ch),
+ cpc_readb(falcbase + F_REG((TTR1 + timeslot / 8), ch)) |
+ (0x80 >> (timeslot & 0x07)));
+ cpc_writeb(falcbase + F_REG((RTR1 + timeslot / 8), ch),
+ cpc_readb(falcbase + F_REG((RTR1 + timeslot / 8), ch)) |
+ (0x80 >> (timeslot & 0x07)));
+}
+
+static void falc_close_timeslot(pc300_t * card, int ch, int timeslot)
+{
+ void __iomem *falcbase = card->hw.falcbase;
+ u8 tshf = card->chan[ch].falc.offset;
+
+ cpc_writeb(falcbase + F_REG((ICB1 + (timeslot - tshf) / 8), ch),
+ cpc_readb(falcbase + F_REG((ICB1 + (timeslot - tshf) / 8), ch)) |
+ (0x80 >> ((timeslot - tshf) & 0x07)));
+ cpc_writeb(falcbase + F_REG((TTR1 + timeslot / 8), ch),
+ cpc_readb(falcbase + F_REG((TTR1 + timeslot / 8), ch)) &
+ ~(0x80 >> (timeslot & 0x07)));
+ cpc_writeb(falcbase + F_REG((RTR1 + timeslot / 8), ch),
+ cpc_readb(falcbase + F_REG((RTR1 + timeslot / 8), ch)) &
+ ~(0x80 >> (timeslot & 0x07)));
+}
+
+static void falc_close_all_timeslots(pc300_t * card, int ch)
+{
+ pc300ch_t *chan = (pc300ch_t *) & card->chan[ch];
+ pc300chconf_t *conf = (pc300chconf_t *) & chan->conf;
+ void __iomem *falcbase = card->hw.falcbase;
+
+ cpc_writeb(falcbase + F_REG(ICB1, ch), 0xff);
+ cpc_writeb(falcbase + F_REG(TTR1, ch), 0);
+ cpc_writeb(falcbase + F_REG(RTR1, ch), 0);
+ cpc_writeb(falcbase + F_REG(ICB2, ch), 0xff);
+ cpc_writeb(falcbase + F_REG(TTR2, ch), 0);
+ cpc_writeb(falcbase + F_REG(RTR2, ch), 0);
+ cpc_writeb(falcbase + F_REG(ICB3, ch), 0xff);
+ cpc_writeb(falcbase + F_REG(TTR3, ch), 0);
+ cpc_writeb(falcbase + F_REG(RTR3, ch), 0);
+ if (conf->media == IF_IFACE_E1) {
+ cpc_writeb(falcbase + F_REG(ICB4, ch), 0xff);
+ cpc_writeb(falcbase + F_REG(TTR4, ch), 0);
+ cpc_writeb(falcbase + F_REG(RTR4, ch), 0);
+ }
+}
+
+static void falc_open_all_timeslots(pc300_t * card, int ch)
+{
+ pc300ch_t *chan = (pc300ch_t *) & card->chan[ch];
+ pc300chconf_t *conf = (pc300chconf_t *) & chan->conf;
+ void __iomem *falcbase = card->hw.falcbase;
+
+ cpc_writeb(falcbase + F_REG(ICB1, ch), 0);
+ if (conf->fr_mode == PC300_FR_UNFRAMED) {
+ cpc_writeb(falcbase + F_REG(TTR1, ch), 0xff);
+ cpc_writeb(falcbase + F_REG(RTR1, ch), 0xff);
+ } else {
+ /* Timeslot 0 is never enabled */
+ cpc_writeb(falcbase + F_REG(TTR1, ch), 0x7f);
+ cpc_writeb(falcbase + F_REG(RTR1, ch), 0x7f);
+ }
+ cpc_writeb(falcbase + F_REG(ICB2, ch), 0);
+ cpc_writeb(falcbase + F_REG(TTR2, ch), 0xff);
+ cpc_writeb(falcbase + F_REG(RTR2, ch), 0xff);
+ cpc_writeb(falcbase + F_REG(ICB3, ch), 0);
+ cpc_writeb(falcbase + F_REG(TTR3, ch), 0xff);
+ cpc_writeb(falcbase + F_REG(RTR3, ch), 0xff);
+ if (conf->media == IF_IFACE_E1) {
+ cpc_writeb(falcbase + F_REG(ICB4, ch), 0);
+ cpc_writeb(falcbase + F_REG(TTR4, ch), 0xff);
+ cpc_writeb(falcbase + F_REG(RTR4, ch), 0xff);
+ } else {
+ cpc_writeb(falcbase + F_REG(ICB4, ch), 0xff);
+ cpc_writeb(falcbase + F_REG(TTR4, ch), 0x80);
+ cpc_writeb(falcbase + F_REG(RTR4, ch), 0x80);
+ }
+}
+
+static void falc_init_timeslot(pc300_t * card, int ch)
+{
+ pc300ch_t *chan = (pc300ch_t *) & card->chan[ch];
+ pc300chconf_t *conf = (pc300chconf_t *) & chan->conf;
+ falc_t *pfalc = (falc_t *) & chan->falc;
+ int tslot;
+
+ for (tslot = 0; tslot < pfalc->num_channels; tslot++) {
+ if (conf->tslot_bitmap & (1 << tslot)) {
+ // Channel enabled
+ falc_open_timeslot(card, ch, tslot + 1);
+ } else {
+ // Channel disabled
+ falc_close_timeslot(card, ch, tslot + 1);
+ }
+ }
+}
+
+static void falc_enable_comm(pc300_t * card, int ch)
+{
+ pc300ch_t *chan = (pc300ch_t *) & card->chan[ch];
+ falc_t *pfalc = (falc_t *) & chan->falc;
+
+ if (pfalc->full_bandwidth) {
+ falc_open_all_timeslots(card, ch);
+ } else {
+ falc_init_timeslot(card, ch);
+ }
+ // CTS/DCD ON
+ cpc_writeb(card->hw.falcbase + card->hw.cpld_reg1,
+ cpc_readb(card->hw.falcbase + card->hw.cpld_reg1) &
+ ~((CPLD_REG1_FALC_DCD | CPLD_REG1_FALC_CTS) << (2 * ch)));
+}
+
+static void falc_disable_comm(pc300_t * card, int ch)
+{
+ pc300ch_t *chan = (pc300ch_t *) & card->chan[ch];
+ falc_t *pfalc = (falc_t *) & chan->falc;
+
+ if (pfalc->loop_active != 2) {
+ falc_close_all_timeslots(card, ch);
+ }
+ // CTS/DCD OFF
+ cpc_writeb(card->hw.falcbase + card->hw.cpld_reg1,
+ cpc_readb(card->hw.falcbase + card->hw.cpld_reg1) |
+ ((CPLD_REG1_FALC_DCD | CPLD_REG1_FALC_CTS) << (2 * ch)));
+}
+
+static void falc_init_t1(pc300_t * card, int ch)
+{
+ pc300ch_t *chan = (pc300ch_t *) & card->chan[ch];
+ pc300chconf_t *conf = (pc300chconf_t *) & chan->conf;
+ falc_t *pfalc = (falc_t *) & chan->falc;
+ void __iomem *falcbase = card->hw.falcbase;
+ u8 dja = (ch ? (LIM2_DJA2 | LIM2_DJA1) : 0);
+
+ /* Switch to T1 mode (PCM 24) */
+ cpc_writeb(falcbase + F_REG(FMR1, ch), FMR1_PMOD);
+
+ /* Wait 20 us for setup */
+ udelay(20);
+
+ /* Transmit Buffer Size (1 frame) */
+ cpc_writeb(falcbase + F_REG(SIC1, ch), SIC1_XBS0);
+
+ /* Clock mode */
+ if (conf->phys_settings.clock_type == CLOCK_INT) { /* Master mode */
+ cpc_writeb(falcbase + F_REG(LIM0, ch),
+ cpc_readb(falcbase + F_REG(LIM0, ch)) | LIM0_MAS);
+ } else { /* Slave mode */
+ cpc_writeb(falcbase + F_REG(LIM0, ch),
+ cpc_readb(falcbase + F_REG(LIM0, ch)) & ~LIM0_MAS);
+ cpc_writeb(falcbase + F_REG(LOOP, ch),
+ cpc_readb(falcbase + F_REG(LOOP, ch)) & ~LOOP_RTM);
+ }
+
+ cpc_writeb(falcbase + F_REG(IPC, ch), IPC_SCI);
+ cpc_writeb(falcbase + F_REG(FMR0, ch),
+ cpc_readb(falcbase + F_REG(FMR0, ch)) &
+ ~(FMR0_XC0 | FMR0_XC1 | FMR0_RC0 | FMR0_RC1));
+
+ switch (conf->lcode) {
+ case PC300_LC_AMI:
+ cpc_writeb(falcbase + F_REG(FMR0, ch),
+ cpc_readb(falcbase + F_REG(FMR0, ch)) |
+ FMR0_XC1 | FMR0_RC1);
+ /* Clear Channel register to ON for all channels */
+ cpc_writeb(falcbase + F_REG(CCB1, ch), 0xff);
+ cpc_writeb(falcbase + F_REG(CCB2, ch), 0xff);
+ cpc_writeb(falcbase + F_REG(CCB3, ch), 0xff);
+ break;
+
+ case PC300_LC_B8ZS:
+ cpc_writeb(falcbase + F_REG(FMR0, ch),
+ cpc_readb(falcbase + F_REG(FMR0, ch)) |
+ FMR0_XC0 | FMR0_XC1 | FMR0_RC0 | FMR0_RC1);
+ break;
+
+ case PC300_LC_NRZ:
+ cpc_writeb(falcbase + F_REG(FMR0, ch),
+ cpc_readb(falcbase + F_REG(FMR0, ch)) | 0x00);
+ break;
+ }
+
+ cpc_writeb(falcbase + F_REG(LIM0, ch),
+ cpc_readb(falcbase + F_REG(LIM0, ch)) | LIM0_ELOS);
+ cpc_writeb(falcbase + F_REG(LIM0, ch),
+ cpc_readb(falcbase + F_REG(LIM0, ch)) & ~(LIM0_SCL1 | LIM0_SCL0));
+ /* Set interface mode to 2 MBPS */
+ cpc_writeb(falcbase + F_REG(FMR1, ch),
+ cpc_readb(falcbase + F_REG(FMR1, ch)) | FMR1_IMOD);
+
+ switch (conf->fr_mode) {
+ case PC300_FR_ESF:
+ pfalc->multiframe_mode = 0;
+ cpc_writeb(falcbase + F_REG(FMR4, ch),
+ cpc_readb(falcbase + F_REG(FMR4, ch)) | FMR4_FM1);
+ cpc_writeb(falcbase + F_REG(FMR1, ch),
+ cpc_readb(falcbase + F_REG(FMR1, ch)) |
+ FMR1_CRC | FMR1_EDL);
+ cpc_writeb(falcbase + F_REG(XDL1, ch), 0);
+ cpc_writeb(falcbase + F_REG(XDL2, ch), 0);
+ cpc_writeb(falcbase + F_REG(XDL3, ch), 0);
+ cpc_writeb(falcbase + F_REG(FMR0, ch),
+ cpc_readb(falcbase + F_REG(FMR0, ch)) & ~FMR0_SRAF);
+ cpc_writeb(falcbase + F_REG(FMR2, ch),
+ cpc_readb(falcbase + F_REG(FMR2,ch)) | FMR2_MCSP | FMR2_SSP);
+ break;
+
+ case PC300_FR_D4:
+ pfalc->multiframe_mode = 1;
+ cpc_writeb(falcbase + F_REG(FMR4, ch),
+ cpc_readb(falcbase + F_REG(FMR4, ch)) &
+ ~(FMR4_FM1 | FMR4_FM0));
+ cpc_writeb(falcbase + F_REG(FMR0, ch),
+ cpc_readb(falcbase + F_REG(FMR0, ch)) | FMR0_SRAF);
+ cpc_writeb(falcbase + F_REG(FMR2, ch),
+ cpc_readb(falcbase + F_REG(FMR2, ch)) & ~FMR2_SSP);
+ break;
+ }
+
+ /* Enable Automatic Resynchronization */
+ cpc_writeb(falcbase + F_REG(FMR4, ch),
+ cpc_readb(falcbase + F_REG(FMR4, ch)) | FMR4_AUTO);
+
+ /* Transmit Automatic Remote Alarm */
+ cpc_writeb(falcbase + F_REG(FMR2, ch),
+ cpc_readb(falcbase + F_REG(FMR2, ch)) | FMR2_AXRA);
+
+ /* Channel translation mode 1 : one to one */
+ cpc_writeb(falcbase + F_REG(FMR1, ch),
+ cpc_readb(falcbase + F_REG(FMR1, ch)) | FMR1_CTM);
+
+ /* No signaling */
+ cpc_writeb(falcbase + F_REG(FMR1, ch),
+ cpc_readb(falcbase + F_REG(FMR1, ch)) & ~FMR1_SIGM);
+ cpc_writeb(falcbase + F_REG(FMR5, ch),
+ cpc_readb(falcbase + F_REG(FMR5, ch)) &
+ ~(FMR5_EIBR | FMR5_SRS));
+ cpc_writeb(falcbase + F_REG(CCR1, ch), 0);
+
+ cpc_writeb(falcbase + F_REG(LIM1, ch),
+ cpc_readb(falcbase + F_REG(LIM1, ch)) | LIM1_RIL0 | LIM1_RIL1);
+
+ switch (conf->lbo) {
+ /* Provides proper Line Build Out */
+ case PC300_LBO_0_DB:
+ cpc_writeb(falcbase + F_REG(LIM2, ch), (LIM2_LOS1 | dja));
+ cpc_writeb(falcbase + F_REG(XPM0, ch), 0x5a);
+ cpc_writeb(falcbase + F_REG(XPM1, ch), 0x8f);
+ cpc_writeb(falcbase + F_REG(XPM2, ch), 0x20);
+ break;
+ case PC300_LBO_7_5_DB:
+ cpc_writeb(falcbase + F_REG(LIM2, ch), (0x40 | LIM2_LOS1 | dja));
+ cpc_writeb(falcbase + F_REG(XPM0, ch), 0x11);
+ cpc_writeb(falcbase + F_REG(XPM1, ch), 0x02);
+ cpc_writeb(falcbase + F_REG(XPM2, ch), 0x20);
+ break;
+ case PC300_LBO_15_DB:
+ cpc_writeb(falcbase + F_REG(LIM2, ch), (0x80 | LIM2_LOS1 | dja));
+ cpc_writeb(falcbase + F_REG(XPM0, ch), 0x8e);
+ cpc_writeb(falcbase + F_REG(XPM1, ch), 0x01);
+ cpc_writeb(falcbase + F_REG(XPM2, ch), 0x20);
+ break;
+ case PC300_LBO_22_5_DB:
+ cpc_writeb(falcbase + F_REG(LIM2, ch), (0xc0 | LIM2_LOS1 | dja));
+ cpc_writeb(falcbase + F_REG(XPM0, ch), 0x09);
+ cpc_writeb(falcbase + F_REG(XPM1, ch), 0x01);
+ cpc_writeb(falcbase + F_REG(XPM2, ch), 0x20);
+ break;
+ }
+
+ /* Transmit Clock-Slot Offset */
+ cpc_writeb(falcbase + F_REG(XC0, ch),
+ cpc_readb(falcbase + F_REG(XC0, ch)) | 0x01);
+ /* Transmit Time-slot Offset */
+ cpc_writeb(falcbase + F_REG(XC1, ch), 0x3e);
+ /* Receive Clock-Slot offset */
+ cpc_writeb(falcbase + F_REG(RC0, ch), 0x05);
+ /* Receive Time-slot offset */
+ cpc_writeb(falcbase + F_REG(RC1, ch), 0x00);
+
+ /* LOS Detection after 176 consecutive 0s */
+ cpc_writeb(falcbase + F_REG(PCDR, ch), 0x0a);
+ /* LOS Recovery after 22 ones in the time window of PCD */
+ cpc_writeb(falcbase + F_REG(PCRR, ch), 0x15);
+
+ cpc_writeb(falcbase + F_REG(IDLE, ch), 0x7f);
+
+ if (conf->fr_mode == PC300_FR_ESF_JAPAN) {
+ cpc_writeb(falcbase + F_REG(RC1, ch),
+ cpc_readb(falcbase + F_REG(RC1, ch)) | 0x80);
+ }
+
+ falc_close_all_timeslots(card, ch);
+}
+
+static void falc_init_e1(pc300_t * card, int ch)
+{
+ pc300ch_t *chan = (pc300ch_t *) & card->chan[ch];
+ pc300chconf_t *conf = (pc300chconf_t *) & chan->conf;
+ falc_t *pfalc = (falc_t *) & chan->falc;
+ void __iomem *falcbase = card->hw.falcbase;
+ u8 dja = (ch ? (LIM2_DJA2 | LIM2_DJA1) : 0);
+
+ /* Switch to E1 mode (PCM 30) */
+ cpc_writeb(falcbase + F_REG(FMR1, ch),
+ cpc_readb(falcbase + F_REG(FMR1, ch)) & ~FMR1_PMOD);
+
+ /* Clock mode */
+ if (conf->phys_settings.clock_type == CLOCK_INT) { /* Master mode */
+ cpc_writeb(falcbase + F_REG(LIM0, ch),
+ cpc_readb(falcbase + F_REG(LIM0, ch)) | LIM0_MAS);
+ } else { /* Slave mode */
+ cpc_writeb(falcbase + F_REG(LIM0, ch),
+ cpc_readb(falcbase + F_REG(LIM0, ch)) & ~LIM0_MAS);
+ }
+ cpc_writeb(falcbase + F_REG(LOOP, ch),
+ cpc_readb(falcbase + F_REG(LOOP, ch)) & ~LOOP_SFM);
+
+ cpc_writeb(falcbase + F_REG(IPC, ch), IPC_SCI);
+ cpc_writeb(falcbase + F_REG(FMR0, ch),
+ cpc_readb(falcbase + F_REG(FMR0, ch)) &
+ ~(FMR0_XC0 | FMR0_XC1 | FMR0_RC0 | FMR0_RC1));
+
+ switch (conf->lcode) {
+ case PC300_LC_AMI:
+ cpc_writeb(falcbase + F_REG(FMR0, ch),
+ cpc_readb(falcbase + F_REG(FMR0, ch)) |
+ FMR0_XC1 | FMR0_RC1);
+ break;
+
+ case PC300_LC_HDB3:
+ cpc_writeb(falcbase + F_REG(FMR0, ch),
+ cpc_readb(falcbase + F_REG(FMR0, ch)) |
+ FMR0_XC0 | FMR0_XC1 | FMR0_RC0 | FMR0_RC1);
+ break;
+
+ case PC300_LC_NRZ:
+ break;
+ }
+
+ cpc_writeb(falcbase + F_REG(LIM0, ch),
+ cpc_readb(falcbase + F_REG(LIM0, ch)) & ~(LIM0_SCL1 | LIM0_SCL0));
+ /* Set interface mode to 2 MBPS */
+ cpc_writeb(falcbase + F_REG(FMR1, ch),
+ cpc_readb(falcbase + F_REG(FMR1, ch)) | FMR1_IMOD);
+
+ cpc_writeb(falcbase + F_REG(XPM0, ch), 0x18);
+ cpc_writeb(falcbase + F_REG(XPM1, ch), 0x03);
+ cpc_writeb(falcbase + F_REG(XPM2, ch), 0x00);
+
+ switch (conf->fr_mode) {
+ case PC300_FR_MF_CRC4:
+ pfalc->multiframe_mode = 1;
+ cpc_writeb(falcbase + F_REG(FMR1, ch),
+ cpc_readb(falcbase + F_REG(FMR1, ch)) | FMR1_XFS);
+ cpc_writeb(falcbase + F_REG(FMR2, ch),
+ cpc_readb(falcbase + F_REG(FMR2, ch)) | FMR2_RFS1);
+ cpc_writeb(falcbase + F_REG(FMR2, ch),
+ cpc_readb(falcbase + F_REG(FMR2, ch)) & ~FMR2_RFS0);
+ cpc_writeb(falcbase + F_REG(FMR3, ch),
+ cpc_readb(falcbase + F_REG(FMR3, ch)) & ~FMR3_EXTIW);
+
+ /* MultiFrame Resynchronization */
+ cpc_writeb(falcbase + F_REG(FMR1, ch),
+ cpc_readb(falcbase + F_REG(FMR1, ch)) | FMR1_MFCS);
+
+ /* Automatic Loss of Multiframe > 914 CRC errors */
+ cpc_writeb(falcbase + F_REG(FMR2, ch),
+ cpc_readb(falcbase + F_REG(FMR2, ch)) | FMR2_ALMF);
+
+ /* S1 and SI1/SI2 spare Bits set to 1 */
+ cpc_writeb(falcbase + F_REG(XSP, ch),
+ cpc_readb(falcbase + F_REG(XSP, ch)) & ~XSP_AXS);
+ cpc_writeb(falcbase + F_REG(XSP, ch),
+ cpc_readb(falcbase + F_REG(XSP, ch)) | XSP_EBP);
+ cpc_writeb(falcbase + F_REG(XSP, ch),
+ cpc_readb(falcbase + F_REG(XSP, ch)) | XSP_XS13 | XSP_XS15);
+
+ /* Automatic Force Resynchronization */
+ cpc_writeb(falcbase + F_REG(FMR1, ch),
+ cpc_readb(falcbase + F_REG(FMR1, ch)) | FMR1_AFR);
+
+ /* Transmit Automatic Remote Alarm */
+ cpc_writeb(falcbase + F_REG(FMR2, ch),
+ cpc_readb(falcbase + F_REG(FMR2, ch)) | FMR2_AXRA);
+
+ /* Transmit Spare Bits for National Use (Y, Sn, Sa) */
+ cpc_writeb(falcbase + F_REG(XSW, ch),
+ cpc_readb(falcbase + F_REG(XSW, ch)) |
+ XSW_XY0 | XSW_XY1 | XSW_XY2 | XSW_XY3 | XSW_XY4);
+ break;
+
+ case PC300_FR_MF_NON_CRC4:
+ case PC300_FR_D4:
+ pfalc->multiframe_mode = 0;
+ cpc_writeb(falcbase + F_REG(FMR1, ch),
+ cpc_readb(falcbase + F_REG(FMR1, ch)) & ~FMR1_XFS);
+ cpc_writeb(falcbase + F_REG(FMR2, ch),
+ cpc_readb(falcbase + F_REG(FMR2, ch)) &
+ ~(FMR2_RFS1 | FMR2_RFS0));
+ cpc_writeb(falcbase + F_REG(XSW, ch),
+ cpc_readb(falcbase + F_REG(XSW, ch)) | XSW_XSIS);
+ cpc_writeb(falcbase + F_REG(XSP, ch),
+ cpc_readb(falcbase + F_REG(XSP, ch)) | XSP_XSIF);
+
+ /* Automatic Force Resynchronization */
+ cpc_writeb(falcbase + F_REG(FMR1, ch),
+ cpc_readb(falcbase + F_REG(FMR1, ch)) | FMR1_AFR);
+
+ /* Transmit Automatic Remote Alarm */
+ cpc_writeb(falcbase + F_REG(FMR2, ch),
+ cpc_readb(falcbase + F_REG(FMR2, ch)) | FMR2_AXRA);
+
+ /* Transmit Spare Bits for National Use (Y, Sn, Sa) */
+ cpc_writeb(falcbase + F_REG(XSW, ch),
+ cpc_readb(falcbase + F_REG(XSW, ch)) |
+ XSW_XY0 | XSW_XY1 | XSW_XY2 | XSW_XY3 | XSW_XY4);
+ break;
+
+ case PC300_FR_UNFRAMED:
+ pfalc->multiframe_mode = 0;
+ cpc_writeb(falcbase + F_REG(FMR1, ch),
+ cpc_readb(falcbase + F_REG(FMR1, ch)) & ~FMR1_XFS);
+ cpc_writeb(falcbase + F_REG(FMR2, ch),
+ cpc_readb(falcbase + F_REG(FMR2, ch)) &
+ ~(FMR2_RFS1 | FMR2_RFS0));
+ cpc_writeb(falcbase + F_REG(XSP, ch),
+ cpc_readb(falcbase + F_REG(XSP, ch)) | XSP_TT0);
+ cpc_writeb(falcbase + F_REG(XSW, ch),
+ cpc_readb(falcbase + F_REG(XSW, ch)) &
+ ~(XSW_XTM|XSW_XY0|XSW_XY1|XSW_XY2|XSW_XY3|XSW_XY4));
+ cpc_writeb(falcbase + F_REG(TSWM, ch), 0xff);
+ cpc_writeb(falcbase + F_REG(FMR2, ch),
+ cpc_readb(falcbase + F_REG(FMR2, ch)) |
+ (FMR2_RTM | FMR2_DAIS));
+ cpc_writeb(falcbase + F_REG(FMR2, ch),
+ cpc_readb(falcbase + F_REG(FMR2, ch)) & ~FMR2_AXRA);
+ cpc_writeb(falcbase + F_REG(FMR1, ch),
+ cpc_readb(falcbase + F_REG(FMR1, ch)) & ~FMR1_AFR);
+ pfalc->sync = 1;
+ cpc_writeb(falcbase + card->hw.cpld_reg2,
+ cpc_readb(falcbase + card->hw.cpld_reg2) |
+ (CPLD_REG2_FALC_LED2 << (2 * ch)));
+ break;
+ }
+
+ /* No signaling */
+ cpc_writeb(falcbase + F_REG(XSP, ch),
+ cpc_readb(falcbase + F_REG(XSP, ch)) & ~XSP_CASEN);
+ cpc_writeb(falcbase + F_REG(CCR1, ch), 0);
+
+ cpc_writeb(falcbase + F_REG(LIM1, ch),
+ cpc_readb(falcbase + F_REG(LIM1, ch)) | LIM1_RIL0 | LIM1_RIL1);
+ cpc_writeb(falcbase + F_REG(LIM2, ch), (LIM2_LOS1 | dja));
+
+ /* Transmit Clock-Slot Offset */
+ cpc_writeb(falcbase + F_REG(XC0, ch),
+ cpc_readb(falcbase + F_REG(XC0, ch)) | 0x01);
+ /* Transmit Time-slot Offset */
+ cpc_writeb(falcbase + F_REG(XC1, ch), 0x3e);
+ /* Receive Clock-Slot offset */
+ cpc_writeb(falcbase + F_REG(RC0, ch), 0x05);
+ /* Receive Time-slot offset */
+ cpc_writeb(falcbase + F_REG(RC1, ch), 0x00);
+
+ /* LOS Detection after 176 consecutive 0s */
+ cpc_writeb(falcbase + F_REG(PCDR, ch), 0x0a);
+ /* LOS Recovery after 22 ones in the time window of PCD */
+ cpc_writeb(falcbase + F_REG(PCRR, ch), 0x15);
+
+ cpc_writeb(falcbase + F_REG(IDLE, ch), 0x7f);
+
+ falc_close_all_timeslots(card, ch);
+}
+
+static void falc_init_hdlc(pc300_t * card, int ch)
+{
+ void __iomem *falcbase = card->hw.falcbase;
+ pc300ch_t *chan = (pc300ch_t *) & card->chan[ch];
+ pc300chconf_t *conf = (pc300chconf_t *) & chan->conf;
+
+ /* Enable transparent data transfer */
+ if (conf->fr_mode == PC300_FR_UNFRAMED) {
+ cpc_writeb(falcbase + F_REG(MODE, ch), 0);
+ } else {
+ cpc_writeb(falcbase + F_REG(MODE, ch),
+ cpc_readb(falcbase + F_REG(MODE, ch)) |
+ (MODE_HRAC | MODE_MDS2));
+ cpc_writeb(falcbase + F_REG(RAH2, ch), 0xff);
+ cpc_writeb(falcbase + F_REG(RAH1, ch), 0xff);
+ cpc_writeb(falcbase + F_REG(RAL2, ch), 0xff);
+ cpc_writeb(falcbase + F_REG(RAL1, ch), 0xff);
+ }
+
+ /* Tx/Rx reset */
+ falc_issue_cmd(card, ch, CMDR_RRES | CMDR_XRES | CMDR_SRES);
+
+ /* Enable interrupt sources */
+ falc_intr_enable(card, ch);
+}
+
+static void te_config(pc300_t * card, int ch)
+{
+ pc300ch_t *chan = (pc300ch_t *) & card->chan[ch];
+ pc300chconf_t *conf = (pc300chconf_t *) & chan->conf;
+ falc_t *pfalc = (falc_t *) & chan->falc;
+ void __iomem *falcbase = card->hw.falcbase;
+ u8 dummy;
+ unsigned long flags;
+
+ memset(pfalc, 0, sizeof(falc_t));
+ switch (conf->media) {
+ case IF_IFACE_T1:
+ pfalc->num_channels = NUM_OF_T1_CHANNELS;
+ pfalc->offset = 1;
+ break;
+ case IF_IFACE_E1:
+ pfalc->num_channels = NUM_OF_E1_CHANNELS;
+ pfalc->offset = 0;
+ break;
+ }
+ if (conf->tslot_bitmap == 0xffffffffUL)
+ pfalc->full_bandwidth = 1;
+ else
+ pfalc->full_bandwidth = 0;
+
+ CPC_LOCK(card, flags);
+ /* Reset the FALC chip */
+ cpc_writeb(card->hw.falcbase + card->hw.cpld_reg1,
+ cpc_readb(card->hw.falcbase + card->hw.cpld_reg1) |
+ (CPLD_REG1_FALC_RESET << (2 * ch)));
+ udelay(10000);
+ cpc_writeb(card->hw.falcbase + card->hw.cpld_reg1,
+ cpc_readb(card->hw.falcbase + card->hw.cpld_reg1) &
+ ~(CPLD_REG1_FALC_RESET << (2 * ch)));
+
+ if (conf->media == IF_IFACE_T1) {
+ falc_init_t1(card, ch);
+ } else {
+ falc_init_e1(card, ch);
+ }
+ falc_init_hdlc(card, ch);
+ if (conf->rx_sens == PC300_RX_SENS_SH) {
+ cpc_writeb(falcbase + F_REG(LIM0, ch),
+ cpc_readb(falcbase + F_REG(LIM0, ch)) & ~LIM0_EQON);
+ } else {
+ cpc_writeb(falcbase + F_REG(LIM0, ch),
+ cpc_readb(falcbase + F_REG(LIM0, ch)) | LIM0_EQON);
+ }
+ cpc_writeb(card->hw.falcbase + card->hw.cpld_reg2,
+ cpc_readb(card->hw.falcbase + card->hw.cpld_reg2) |
+ ((CPLD_REG2_FALC_TX_CLK | CPLD_REG2_FALC_RX_CLK) << (2 * ch)));
+
+ /* Clear all interrupt registers */
+ dummy = cpc_readb(falcbase + F_REG(FISR0, ch)) +
+ cpc_readb(falcbase + F_REG(FISR1, ch)) +
+ cpc_readb(falcbase + F_REG(FISR2, ch)) +
+ cpc_readb(falcbase + F_REG(FISR3, ch));
+ CPC_UNLOCK(card, flags);
+}
+
+static void falc_check_status(pc300_t * card, int ch, unsigned char frs0)
+{
+ pc300ch_t *chan = (pc300ch_t *) & card->chan[ch];
+ pc300chconf_t *conf = (pc300chconf_t *) & chan->conf;
+ falc_t *pfalc = (falc_t *) & chan->falc;
+ void __iomem *falcbase = card->hw.falcbase;
+
+ /* Verify LOS */
+ if (frs0 & FRS0_LOS) {
+ if (!pfalc->red_alarm) {
+ pfalc->red_alarm = 1;
+ pfalc->los++;
+ if (!pfalc->blue_alarm) {
+ // EVENT_FALC_ABNORMAL
+ if (conf->media == IF_IFACE_T1) {
+ /* Disable this interrupt as it may otherwise interfere
+ * with other working boards. */
+ cpc_writeb(falcbase + F_REG(IMR0, ch),
+ cpc_readb(falcbase + F_REG(IMR0, ch))
+ | IMR0_PDEN);
+ }
+ falc_disable_comm(card, ch);
+ // EVENT_FALC_ABNORMAL
+ }
+ }
+ } else {
+ if (pfalc->red_alarm) {
+ pfalc->red_alarm = 0;
+ pfalc->losr++;
+ }
+ }
+
+ if (conf->fr_mode != PC300_FR_UNFRAMED) {
+ /* Verify AIS alarm */
+ if (frs0 & FRS0_AIS) {
+ if (!pfalc->blue_alarm) {
+ pfalc->blue_alarm = 1;
+ pfalc->ais++;
+ // EVENT_AIS
+ if (conf->media == IF_IFACE_T1) {
+ /* Disable this interrupt as it may otherwise interfere with other working boards. */
+ cpc_writeb(falcbase + F_REG(IMR0, ch),
+ cpc_readb(falcbase + F_REG(IMR0, ch)) | IMR0_PDEN);
+ }
+ falc_disable_comm(card, ch);
+ // EVENT_AIS
+ }
+ } else {
+ pfalc->blue_alarm = 0;
+ }
+
+ /* Verify LFA */
+ if (frs0 & FRS0_LFA) {
+ if (!pfalc->loss_fa) {
+ pfalc->loss_fa = 1;
+ pfalc->lfa++;
+ if (!pfalc->blue_alarm && !pfalc->red_alarm) {
+ // EVENT_FALC_ABNORMAL
+ if (conf->media == IF_IFACE_T1) {
+ /* Disable this interrupt as it may otherwise
+ * interfere with other working boards. */
+ cpc_writeb(falcbase + F_REG(IMR0, ch),
+ cpc_readb(falcbase + F_REG(IMR0, ch))
+ | IMR0_PDEN);
+ }
+ falc_disable_comm(card, ch);
+ // EVENT_FALC_ABNORMAL
+ }
+ }
+ } else {
+ if (pfalc->loss_fa) {
+ pfalc->loss_fa = 0;
+ pfalc->farec++;
+ }
+ }
+
+ /* Verify LMFA */
+ if (pfalc->multiframe_mode && (frs0 & FRS0_LMFA)) {
+ /* D4 or CRC4 frame mode */
+ if (!pfalc->loss_mfa) {
+ pfalc->loss_mfa = 1;
+ pfalc->lmfa++;
+ if (!pfalc->blue_alarm && !pfalc->red_alarm &&
+ !pfalc->loss_fa) {
+ // EVENT_FALC_ABNORMAL
+ if (conf->media == IF_IFACE_T1) {
+ /* Disable this interrupt as it may otherwise
+ * interfere with other working boards. */
+ cpc_writeb(falcbase + F_REG(IMR0, ch),
+ cpc_readb(falcbase + F_REG(IMR0, ch))
+ | IMR0_PDEN);
+ }
+ falc_disable_comm(card, ch);
+ // EVENT_FALC_ABNORMAL
+ }
+ }
+ } else {
+ pfalc->loss_mfa = 0;
+ }
+
+ /* Verify Remote Alarm */
+ if (frs0 & FRS0_RRA) {
+ if (!pfalc->yellow_alarm) {
+ pfalc->yellow_alarm = 1;
+ pfalc->rai++;
+ if (pfalc->sync) {
+ // EVENT_RAI
+ falc_disable_comm(card, ch);
+ // EVENT_RAI
+ }
+ }
+ } else {
+ pfalc->yellow_alarm = 0;
+ }
+ } /* if !PC300_UNFRAMED */
+
+ if (pfalc->red_alarm || pfalc->loss_fa ||
+ pfalc->loss_mfa || pfalc->blue_alarm) {
+ if (pfalc->sync) {
+ pfalc->sync = 0;
+ chan->d.line_off++;
+ cpc_writeb(falcbase + card->hw.cpld_reg2,
+ cpc_readb(falcbase + card->hw.cpld_reg2) &
+ ~(CPLD_REG2_FALC_LED2 << (2 * ch)));
+ }
+ } else {
+ if (!pfalc->sync) {
+ pfalc->sync = 1;
+ chan->d.line_on++;
+ cpc_writeb(falcbase + card->hw.cpld_reg2,
+ cpc_readb(falcbase + card->hw.cpld_reg2) |
+ (CPLD_REG2_FALC_LED2 << (2 * ch)));
+ }
+ }
+
+ if (pfalc->sync && !pfalc->yellow_alarm) {
+ if (!pfalc->active) {
+ // EVENT_FALC_NORMAL
+ if (pfalc->loop_active) {
+ return;
+ }
+ if (conf->media == IF_IFACE_T1) {
+ cpc_writeb(falcbase + F_REG(IMR0, ch),
+ cpc_readb(falcbase + F_REG(IMR0, ch)) & ~IMR0_PDEN);
+ }
+ falc_enable_comm(card, ch);
+ // EVENT_FALC_NORMAL
+ pfalc->active = 1;
+ }
+ } else {
+ if (pfalc->active) {
+ pfalc->active = 0;
+ }
+ }
+}
+
+static void falc_update_stats(pc300_t * card, int ch)
+{
+ pc300ch_t *chan = (pc300ch_t *) & card->chan[ch];
+ pc300chconf_t *conf = (pc300chconf_t *) & chan->conf;
+ falc_t *pfalc = (falc_t *) & chan->falc;
+ void __iomem *falcbase = card->hw.falcbase;
+ u16 counter;
+
+ counter = cpc_readb(falcbase + F_REG(FECL, ch));
+ counter |= cpc_readb(falcbase + F_REG(FECH, ch)) << 8;
+ pfalc->fec += counter;
+
+ counter = cpc_readb(falcbase + F_REG(CVCL, ch));
+ counter |= cpc_readb(falcbase + F_REG(CVCH, ch)) << 8;
+ pfalc->cvc += counter;
+
+ counter = cpc_readb(falcbase + F_REG(CECL, ch));
+ counter |= cpc_readb(falcbase + F_REG(CECH, ch)) << 8;
+ pfalc->cec += counter;
+
+ counter = cpc_readb(falcbase + F_REG(EBCL, ch));
+ counter |= cpc_readb(falcbase + F_REG(EBCH, ch)) << 8;
+ pfalc->ebc += counter;
+
+ if (cpc_readb(falcbase + F_REG(LCR1, ch)) & LCR1_EPRM) {
+ mdelay(10);
+ counter = cpc_readb(falcbase + F_REG(BECL, ch));
+ counter |= cpc_readb(falcbase + F_REG(BECH, ch)) << 8;
+ pfalc->bec += counter;
+
+ if (((conf->media == IF_IFACE_T1) &&
+ (cpc_readb(falcbase + F_REG(FRS1, ch)) & FRS1_LLBAD) &&
+ (!(cpc_readb(falcbase + F_REG(FRS1, ch)) & FRS1_PDEN))) ||
+ ((conf->media == IF_IFACE_E1) &&
+ (cpc_readb(falcbase + F_REG(RSP, ch)) & RSP_LLBAD))) {
+ pfalc->prbs = 2;
+ } else {
+ pfalc->prbs = 1;
+ }
+ }
+}
+
+/*----------------------------------------------------------------------------
+ * falc_remote_loop
+ *----------------------------------------------------------------------------
+ * Description: In the remote loopback mode the clock and data recovered
+ * from the line inputs RL1/2 or RDIP/RDIN are routed back
+ * to the line outputs XL1/2 or XDOP/XDON via the analog
+ * transmitter. As in normal mode they are processed by
+ * the synchronizer and then sent to the system interface.
+ *----------------------------------------------------------------------------
+ */
+static void falc_remote_loop(pc300_t * card, int ch, int loop_on)
+{
+ pc300ch_t *chan = (pc300ch_t *) & card->chan[ch];
+ pc300chconf_t *conf = (pc300chconf_t *) & chan->conf;
+ falc_t *pfalc = (falc_t *) & chan->falc;
+ void __iomem *falcbase = card->hw.falcbase;
+
+ if (loop_on) {
+ // EVENT_FALC_ABNORMAL
+ if (conf->media == IF_IFACE_T1) {
+ /* Disable this interrupt as it may otherwise interfere with
+ * other working boards. */
+ cpc_writeb(falcbase + F_REG(IMR0, ch),
+ cpc_readb(falcbase + F_REG(IMR0, ch)) | IMR0_PDEN);
+ }
+ falc_disable_comm(card, ch);
+ // EVENT_FALC_ABNORMAL
+ cpc_writeb(falcbase + F_REG(LIM1, ch),
+ cpc_readb(falcbase + F_REG(LIM1, ch)) | LIM1_RL);
+ pfalc->loop_active = 1;
+ } else {
+ cpc_writeb(falcbase + F_REG(LIM1, ch),
+ cpc_readb(falcbase + F_REG(LIM1, ch)) & ~LIM1_RL);
+ pfalc->sync = 0;
+ cpc_writeb(falcbase + card->hw.cpld_reg2,
+ cpc_readb(falcbase + card->hw.cpld_reg2) &
+ ~(CPLD_REG2_FALC_LED2 << (2 * ch)));
+ pfalc->active = 0;
+ falc_issue_cmd(card, ch, CMDR_XRES);
+ pfalc->loop_active = 0;
+ }
+}
+
+/*----------------------------------------------------------------------------
+ * falc_local_loop
+ *----------------------------------------------------------------------------
+ * Description: The local loopback mode disconnects the receive lines
+ * RL1/RL2 resp. RDIP/RDIN from the receiver. Instead of the
+ * signals coming from the line the data provided by system
+ * interface are routed through the analog receiver back to
+ * the system interface. The unipolar bit stream will be
+ * undisturbed transmitted on the line. Receiver and transmitter
+ * coding must be identical.
+ *----------------------------------------------------------------------------
+ */
+static void falc_local_loop(pc300_t * card, int ch, int loop_on)
+{
+ pc300ch_t *chan = (pc300ch_t *) & card->chan[ch];
+ falc_t *pfalc = (falc_t *) & chan->falc;
+ void __iomem *falcbase = card->hw.falcbase;
+
+ if (loop_on) {
+ cpc_writeb(falcbase + F_REG(LIM0, ch),
+ cpc_readb(falcbase + F_REG(LIM0, ch)) | LIM0_LL);
+ pfalc->loop_active = 1;
+ } else {
+ cpc_writeb(falcbase + F_REG(LIM0, ch),
+ cpc_readb(falcbase + F_REG(LIM0, ch)) & ~LIM0_LL);
+ pfalc->loop_active = 0;
+ }
+}
+
+/*----------------------------------------------------------------------------
+ * falc_payload_loop
+ *----------------------------------------------------------------------------
+ * Description: This routine allows to enable/disable payload loopback.
+ * When the payload loop is activated, the received 192 bits
+ * of payload data will be looped back to the transmit
+ * direction. The framing bits, CRC6 and DL bits are not
+ * looped. They are originated by the FALC-LH transmitter.
+ *----------------------------------------------------------------------------
+ */
+static void falc_payload_loop(pc300_t * card, int ch, int loop_on)
+{
+ pc300ch_t *chan = (pc300ch_t *) & card->chan[ch];
+ pc300chconf_t *conf = (pc300chconf_t *) & chan->conf;
+ falc_t *pfalc = (falc_t *) & chan->falc;
+ void __iomem *falcbase = card->hw.falcbase;
+
+ if (loop_on) {
+ // EVENT_FALC_ABNORMAL
+ if (conf->media == IF_IFACE_T1) {
+ /* Disable this interrupt as it may otherwise interfere with
+ * other working boards. */
+ cpc_writeb(falcbase + F_REG(IMR0, ch),
+ cpc_readb(falcbase + F_REG(IMR0, ch)) | IMR0_PDEN);
+ }
+ falc_disable_comm(card, ch);
+ // EVENT_FALC_ABNORMAL
+ cpc_writeb(falcbase + F_REG(FMR2, ch),
+ cpc_readb(falcbase + F_REG(FMR2, ch)) | FMR2_PLB);
+ if (conf->media == IF_IFACE_T1) {
+ cpc_writeb(falcbase + F_REG(FMR4, ch),
+ cpc_readb(falcbase + F_REG(FMR4, ch)) | FMR4_TM);
+ } else {
+ cpc_writeb(falcbase + F_REG(FMR5, ch),
+ cpc_readb(falcbase + F_REG(FMR5, ch)) | XSP_TT0);
+ }
+ falc_open_all_timeslots(card, ch);
+ pfalc->loop_active = 2;
+ } else {
+ cpc_writeb(falcbase + F_REG(FMR2, ch),
+ cpc_readb(falcbase + F_REG(FMR2, ch)) & ~FMR2_PLB);
+ if (conf->media == IF_IFACE_T1) {
+ cpc_writeb(falcbase + F_REG(FMR4, ch),
+ cpc_readb(falcbase + F_REG(FMR4, ch)) & ~FMR4_TM);
+ } else {
+ cpc_writeb(falcbase + F_REG(FMR5, ch),
+ cpc_readb(falcbase + F_REG(FMR5, ch)) & ~XSP_TT0);
+ }
+ pfalc->sync = 0;
+ cpc_writeb(falcbase + card->hw.cpld_reg2,
+ cpc_readb(falcbase + card->hw.cpld_reg2) &
+ ~(CPLD_REG2_FALC_LED2 << (2 * ch)));
+ pfalc->active = 0;
+ falc_issue_cmd(card, ch, CMDR_XRES);
+ pfalc->loop_active = 0;
+ }
+}
+
+/*----------------------------------------------------------------------------
+ * turn_off_xlu
+ *----------------------------------------------------------------------------
+ * Description: Turns XLU bit off in the proper register
+ *----------------------------------------------------------------------------
+ */
+static void turn_off_xlu(pc300_t * card, int ch)
+{
+ pc300ch_t *chan = (pc300ch_t *) & card->chan[ch];
+ pc300chconf_t *conf = (pc300chconf_t *) & chan->conf;
+ void __iomem *falcbase = card->hw.falcbase;
+
+ if (conf->media == IF_IFACE_T1) {
+ cpc_writeb(falcbase + F_REG(FMR5, ch),
+ cpc_readb(falcbase + F_REG(FMR5, ch)) & ~FMR5_XLU);
+ } else {
+ cpc_writeb(falcbase + F_REG(FMR3, ch),
+ cpc_readb(falcbase + F_REG(FMR3, ch)) & ~FMR3_XLU);
+ }
+}
+
+/*----------------------------------------------------------------------------
+ * turn_off_xld
+ *----------------------------------------------------------------------------
+ * Description: Turns XLD bit off in the proper register
+ *----------------------------------------------------------------------------
+ */
+static void turn_off_xld(pc300_t * card, int ch)
+{
+ pc300ch_t *chan = (pc300ch_t *) & card->chan[ch];
+ pc300chconf_t *conf = (pc300chconf_t *) & chan->conf;
+ void __iomem *falcbase = card->hw.falcbase;
+
+ if (conf->media == IF_IFACE_T1) {
+ cpc_writeb(falcbase + F_REG(FMR5, ch),
+ cpc_readb(falcbase + F_REG(FMR5, ch)) & ~FMR5_XLD);
+ } else {
+ cpc_writeb(falcbase + F_REG(FMR3, ch),
+ cpc_readb(falcbase + F_REG(FMR3, ch)) & ~FMR3_XLD);
+ }
+}
+
+/*----------------------------------------------------------------------------
+ * falc_generate_loop_up_code
+ *----------------------------------------------------------------------------
+ * Description: This routine writes the proper FALC chip register in order
+ * to generate a LOOP activation code over a T1/E1 line.
+ *----------------------------------------------------------------------------
+ */
+static void falc_generate_loop_up_code(pc300_t * card, int ch)
+{
+ pc300ch_t *chan = (pc300ch_t *) & card->chan[ch];
+ pc300chconf_t *conf = (pc300chconf_t *) & chan->conf;
+ falc_t *pfalc = (falc_t *) & chan->falc;
+ void __iomem *falcbase = card->hw.falcbase;
+
+ if (conf->media == IF_IFACE_T1) {
+ cpc_writeb(falcbase + F_REG(FMR5, ch),
+ cpc_readb(falcbase + F_REG(FMR5, ch)) | FMR5_XLU);
+ } else {
+ cpc_writeb(falcbase + F_REG(FMR3, ch),
+ cpc_readb(falcbase + F_REG(FMR3, ch)) | FMR3_XLU);
+ }
+ // EVENT_FALC_ABNORMAL
+ if (conf->media == IF_IFACE_T1) {
+ /* Disable this interrupt as it may otherwise interfere with
+ * other working boards. */
+ cpc_writeb(falcbase + F_REG(IMR0, ch),
+ cpc_readb(falcbase + F_REG(IMR0, ch)) | IMR0_PDEN);
+ }
+ falc_disable_comm(card, ch);
+ // EVENT_FALC_ABNORMAL
+ pfalc->loop_gen = 1;
+}
+
+/*----------------------------------------------------------------------------
+ * falc_generate_loop_down_code
+ *----------------------------------------------------------------------------
+ * Description: This routine writes the proper FALC chip register in order
+ * to generate a LOOP deactivation code over a T1/E1 line.
+ *----------------------------------------------------------------------------
+ */
+static void falc_generate_loop_down_code(pc300_t * card, int ch)
+{
+ pc300ch_t *chan = (pc300ch_t *) & card->chan[ch];
+ pc300chconf_t *conf = (pc300chconf_t *) & chan->conf;
+ falc_t *pfalc = (falc_t *) & chan->falc;
+ void __iomem *falcbase = card->hw.falcbase;
+
+ if (conf->media == IF_IFACE_T1) {
+ cpc_writeb(falcbase + F_REG(FMR5, ch),
+ cpc_readb(falcbase + F_REG(FMR5, ch)) | FMR5_XLD);
+ } else {
+ cpc_writeb(falcbase + F_REG(FMR3, ch),
+ cpc_readb(falcbase + F_REG(FMR3, ch)) | FMR3_XLD);
+ }
+ pfalc->sync = 0;
+ cpc_writeb(falcbase + card->hw.cpld_reg2,
+ cpc_readb(falcbase + card->hw.cpld_reg2) &
+ ~(CPLD_REG2_FALC_LED2 << (2 * ch)));
+ pfalc->active = 0;
+//? falc_issue_cmd(card, ch, CMDR_XRES);
+ pfalc->loop_gen = 0;
+}
+
+/*----------------------------------------------------------------------------
+ * falc_pattern_test
+ *----------------------------------------------------------------------------
+ * Description: This routine generates a pattern code and checks
+ * it on the reception side.
+ *----------------------------------------------------------------------------
+ */
+static void falc_pattern_test(pc300_t * card, int ch, unsigned int activate)
+{
+ pc300ch_t *chan = (pc300ch_t *) & card->chan[ch];
+ pc300chconf_t *conf = (pc300chconf_t *) & chan->conf;
+ falc_t *pfalc = (falc_t *) & chan->falc;
+ void __iomem *falcbase = card->hw.falcbase;
+
+ if (activate) {
+ pfalc->prbs = 1;
+ pfalc->bec = 0;
+ if (conf->media == IF_IFACE_T1) {
+ /* Disable local loop activation/deactivation detect */
+ cpc_writeb(falcbase + F_REG(IMR3, ch),
+ cpc_readb(falcbase + F_REG(IMR3, ch)) | IMR3_LLBSC);
+ } else {
+ /* Disable local loop activation/deactivation detect */
+ cpc_writeb(falcbase + F_REG(IMR1, ch),
+ cpc_readb(falcbase + F_REG(IMR1, ch)) | IMR1_LLBSC);
+ }
+ /* Activates generation and monitoring of PRBS
+ * (Pseudo Random Bit Sequence) */
+ cpc_writeb(falcbase + F_REG(LCR1, ch),
+ cpc_readb(falcbase + F_REG(LCR1, ch)) | LCR1_EPRM | LCR1_XPRBS);
+ } else {
+ pfalc->prbs = 0;
+ /* Deactivates generation and monitoring of PRBS
+ * (Pseudo Random Bit Sequence) */
+ cpc_writeb(falcbase + F_REG(LCR1, ch),
+ cpc_readb(falcbase+F_REG(LCR1,ch)) & ~(LCR1_EPRM | LCR1_XPRBS));
+ if (conf->media == IF_IFACE_T1) {
+ /* Enable local loop activation/deactivation detect */
+ cpc_writeb(falcbase + F_REG(IMR3, ch),
+ cpc_readb(falcbase + F_REG(IMR3, ch)) & ~IMR3_LLBSC);
+ } else {
+ /* Enable local loop activation/deactivation detect */
+ cpc_writeb(falcbase + F_REG(IMR1, ch),
+ cpc_readb(falcbase + F_REG(IMR1, ch)) & ~IMR1_LLBSC);
+ }
+ }
+}
+
+/*----------------------------------------------------------------------------
+ * falc_pattern_test_error
+ *----------------------------------------------------------------------------
+ * Description: This routine returns the bit error counter value
+ *----------------------------------------------------------------------------
+ */
+static u16 falc_pattern_test_error(pc300_t * card, int ch)
+{
+ pc300ch_t *chan = (pc300ch_t *) & card->chan[ch];
+ falc_t *pfalc = (falc_t *) & chan->falc;
+
+ return pfalc->bec;
+}
+
+/**********************************/
+/*** Net Interface Routines ***/
+/**********************************/
+
+static void
+cpc_trace(struct net_device *dev, struct sk_buff *skb_main, char rx_tx)
+{
+ struct sk_buff *skb;
+
+ if ((skb = dev_alloc_skb(10 + skb_main->len)) == NULL) {
+ printk("%s: out of memory\n", dev->name);
+ return;
+ }
+ skb_put(skb, 10 + skb_main->len);
+
+ skb->dev = dev;
+ skb->protocol = htons(ETH_P_CUST);
+ skb_reset_mac_header(skb);
+ skb->pkt_type = PACKET_HOST;
+ skb->len = 10 + skb_main->len;
+
+ skb_copy_to_linear_data(skb, dev->name, 5);
+ skb->data[5] = '[';
+ skb->data[6] = rx_tx;
+ skb->data[7] = ']';
+ skb->data[8] = ':';
+ skb->data[9] = ' ';
+ skb_copy_from_linear_data(skb_main, &skb->data[10], skb_main->len);
+
+ netif_rx(skb);
+}
+
+static void cpc_tx_timeout(struct net_device *dev)
+{
+ pc300dev_t *d = (pc300dev_t *) dev_to_hdlc(dev)->priv;
+ pc300ch_t *chan = (pc300ch_t *) d->chan;
+ pc300_t *card = (pc300_t *) chan->card;
+ int ch = chan->channel;
+ unsigned long flags;
+ u8 ilar;
+
+ dev->stats.tx_errors++;
+ dev->stats.tx_aborted_errors++;
+ CPC_LOCK(card, flags);
+ if ((ilar = cpc_readb(card->hw.scabase + ILAR)) != 0) {
+ printk("%s: ILAR=0x%x\n", dev->name, ilar);
+ cpc_writeb(card->hw.scabase + ILAR, ilar);
+ cpc_writeb(card->hw.scabase + DMER, 0x80);
+ }
+ if (card->hw.type == PC300_TE) {
+ cpc_writeb(card->hw.falcbase + card->hw.cpld_reg2,
+ cpc_readb(card->hw.falcbase + card->hw.cpld_reg2) &
+ ~(CPLD_REG2_FALC_LED1 << (2 * ch)));
+ }
+ dev->trans_start = jiffies; /* prevent tx timeout */
+ CPC_UNLOCK(card, flags);
+ netif_wake_queue(dev);
+}
+
+static int cpc_queue_xmit(struct sk_buff *skb, struct net_device *dev)
+{
+ pc300dev_t *d = (pc300dev_t *) dev_to_hdlc(dev)->priv;
+ pc300ch_t *chan = (pc300ch_t *) d->chan;
+ pc300_t *card = (pc300_t *) chan->card;
+ int ch = chan->channel;
+ unsigned long flags;
+#ifdef PC300_DEBUG_TX
+ int i;
+#endif
+
+ if (!netif_carrier_ok(dev)) {
+ /* DCD must be OFF: drop packet */
+ dev_kfree_skb(skb);
+ dev->stats.tx_errors++;
+ dev->stats.tx_carrier_errors++;
+ return 0;
+ } else if (cpc_readb(card->hw.scabase + M_REG(ST3, ch)) & ST3_DCD) {
+ printk("%s: DCD is OFF. Going administrative down.\n", dev->name);
+ dev->stats.tx_errors++;
+ dev->stats.tx_carrier_errors++;
+ dev_kfree_skb(skb);
+ netif_carrier_off(dev);
+ CPC_LOCK(card, flags);
+ cpc_writeb(card->hw.scabase + M_REG(CMD, ch), CMD_TX_BUF_CLR);
+ if (card->hw.type == PC300_TE) {
+ cpc_writeb(card->hw.falcbase + card->hw.cpld_reg2,
+ cpc_readb(card->hw.falcbase + card->hw.cpld_reg2) &
+ ~(CPLD_REG2_FALC_LED1 << (2 * ch)));
+ }
+ CPC_UNLOCK(card, flags);
+ netif_wake_queue(dev);
+ return 0;
+ }
+
+ /* Write buffer to DMA buffers */
+ if (dma_buf_write(card, ch, (u8 *)skb->data, skb->len) != 0) {
+// printk("%s: write error. Dropping TX packet.\n", dev->name);
+ netif_stop_queue(dev);
+ dev_kfree_skb(skb);
+ dev->stats.tx_errors++;
+ dev->stats.tx_dropped++;
+ return 0;
+ }
+#ifdef PC300_DEBUG_TX
+ printk("%s T:", dev->name);
+ for (i = 0; i < skb->len; i++)
+ printk(" %02x", *(skb->data + i));
+ printk("\n");
+#endif
+
+ if (d->trace_on) {
+ cpc_trace(dev, skb, 'T');
+ }
+
+ /* Start transmission */
+ CPC_LOCK(card, flags);
+ /* verify if it has more than one free descriptor */
+ if (card->chan[ch].nfree_tx_bd <= 1) {
+ /* don't have so stop the queue */
+ netif_stop_queue(dev);
+ }
+ cpc_writel(card->hw.scabase + DTX_REG(EDAL, ch),
+ TX_BD_ADDR(ch, chan->tx_next_bd));
+ cpc_writeb(card->hw.scabase + M_REG(CMD, ch), CMD_TX_ENA);
+ cpc_writeb(card->hw.scabase + DSR_TX(ch), DSR_DE);
+ if (card->hw.type == PC300_TE) {
+ cpc_writeb(card->hw.falcbase + card->hw.cpld_reg2,
+ cpc_readb(card->hw.falcbase + card->hw.cpld_reg2) |
+ (CPLD_REG2_FALC_LED1 << (2 * ch)));
+ }
+ CPC_UNLOCK(card, flags);
+ dev_kfree_skb(skb);
+
+ return 0;
+}
+
+static void cpc_net_rx(struct net_device *dev)
+{
+ pc300dev_t *d = (pc300dev_t *) dev_to_hdlc(dev)->priv;
+ pc300ch_t *chan = (pc300ch_t *) d->chan;
+ pc300_t *card = (pc300_t *) chan->card;
+ int ch = chan->channel;
+#ifdef PC300_DEBUG_RX
+ int i;
+#endif
+ int rxb;
+ struct sk_buff *skb;
+
+ while (1) {
+ if ((rxb = dma_get_rx_frame_size(card, ch)) == -1)
+ return;
+
+ if (!netif_carrier_ok(dev)) {
+ /* DCD must be OFF: drop packet */
+ printk("%s : DCD is OFF - drop %d rx bytes\n", dev->name, rxb);
+ skb = NULL;
+ } else {
+ if (rxb > (dev->mtu + 40)) { /* add headers */
+ printk("%s : MTU exceeded %d\n", dev->name, rxb);
+ skb = NULL;
+ } else {
+ skb = dev_alloc_skb(rxb);
+ if (skb == NULL) {
+ printk("%s: Memory squeeze!!\n", dev->name);
+ return;
+ }
+ skb->dev = dev;
+ }
+ }
+
+ if (((rxb = dma_buf_read(card, ch, skb)) <= 0) || (skb == NULL)) {
+#ifdef PC300_DEBUG_RX
+ printk("%s: rxb = %x\n", dev->name, rxb);
+#endif
+ if ((skb == NULL) && (rxb > 0)) {
+ /* rxb > dev->mtu */
+ dev->stats.rx_errors++;
+ dev->stats.rx_length_errors++;
+ continue;
+ }
+
+ if (rxb < 0) { /* Invalid frame */
+ rxb = -rxb;
+ if (rxb & DST_OVR) {
+ dev->stats.rx_errors++;
+ dev->stats.rx_fifo_errors++;
+ }
+ if (rxb & DST_CRC) {
+ dev->stats.rx_errors++;
+ dev->stats.rx_crc_errors++;
+ }
+ if (rxb & (DST_RBIT | DST_SHRT | DST_ABT)) {
+ dev->stats.rx_errors++;
+ dev->stats.rx_frame_errors++;
+ }
+ }
+ if (skb) {
+ dev_kfree_skb_irq(skb);
+ }
+ continue;
+ }
+
+ dev->stats.rx_bytes += rxb;
+
+#ifdef PC300_DEBUG_RX
+ printk("%s R:", dev->name);
+ for (i = 0; i < skb->len; i++)
+ printk(" %02x", *(skb->data + i));
+ printk("\n");
+#endif
+ if (d->trace_on) {
+ cpc_trace(dev, skb, 'R');
+ }
+ dev->stats.rx_packets++;
+ skb->protocol = hdlc_type_trans(skb, dev);
+ netif_rx(skb);
+ }
+}
+
+/************************************/
+/*** PC300 Interrupt Routines ***/
+/************************************/
+static void sca_tx_intr(pc300dev_t *dev)
+{
+ pc300ch_t *chan = (pc300ch_t *)dev->chan;
+ pc300_t *card = (pc300_t *)chan->card;
+ int ch = chan->channel;
+ volatile pcsca_bd_t __iomem * ptdescr;
+
+ /* Clean up descriptors from previous transmission */
+ ptdescr = (card->hw.rambase +
+ TX_BD_ADDR(ch,chan->tx_first_bd));
+ while ((cpc_readl(card->hw.scabase + DTX_REG(CDAL,ch)) !=
+ TX_BD_ADDR(ch,chan->tx_first_bd)) &&
+ (cpc_readb(&ptdescr->status) & DST_OSB)) {
+ dev->dev->stats.tx_packets++;
+ dev->dev->stats.tx_bytes += cpc_readw(&ptdescr->len);
+ cpc_writeb(&ptdescr->status, DST_OSB);
+ cpc_writew(&ptdescr->len, 0);
+ chan->nfree_tx_bd++;
+ chan->tx_first_bd = (chan->tx_first_bd + 1) & (N_DMA_TX_BUF - 1);
+ ptdescr = (card->hw.rambase + TX_BD_ADDR(ch,chan->tx_first_bd));
+ }
+
+#ifdef CONFIG_PC300_MLPPP
+ if (chan->conf.proto == PC300_PROTO_MLPPP) {
+ cpc_tty_trigger_poll(dev);
+ } else {
+#endif
+ /* Tell the upper layer we are ready to transmit more packets */
+ netif_wake_queue(dev->dev);
+#ifdef CONFIG_PC300_MLPPP
+ }
+#endif
+}
+
+static void sca_intr(pc300_t * card)
+{
+ void __iomem *scabase = card->hw.scabase;
+ volatile u32 status;
+ int ch;
+ int intr_count = 0;
+ unsigned char dsr_rx;
+
+ while ((status = cpc_readl(scabase + ISR0)) != 0) {
+ for (ch = 0; ch < card->hw.nchan; ch++) {
+ pc300ch_t *chan = &card->chan[ch];
+ pc300dev_t *d = &chan->d;
+ struct net_device *dev = d->dev;
+
+ spin_lock(&card->card_lock);
+
+ /**** Reception ****/
+ if (status & IR0_DRX((IR0_DMIA | IR0_DMIB), ch)) {
+ u8 drx_stat = cpc_readb(scabase + DSR_RX(ch));
+
+ /* Clear RX interrupts */
+ cpc_writeb(scabase + DSR_RX(ch), drx_stat | DSR_DWE);
+
+#ifdef PC300_DEBUG_INTR
+ printk ("sca_intr: RX intr chan[%d] (st=0x%08lx, dsr=0x%02x)\n",
+ ch, status, drx_stat);
+#endif
+ if (status & IR0_DRX(IR0_DMIA, ch)) {
+ if (drx_stat & DSR_BOF) {
+#ifdef CONFIG_PC300_MLPPP
+ if (chan->conf.proto == PC300_PROTO_MLPPP) {
+ /* verify if driver is TTY */
+ if ((cpc_readb(scabase + DSR_RX(ch)) & DSR_DE)) {
+ rx_dma_stop(card, ch);
+ }
+ cpc_tty_receive(d);
+ rx_dma_start(card, ch);
+ } else
+#endif
+ {
+ if ((cpc_readb(scabase + DSR_RX(ch)) & DSR_DE)) {
+ rx_dma_stop(card, ch);
+ }
+ cpc_net_rx(dev);
+ /* Discard invalid frames */
+ dev->stats.rx_errors++;
+ dev->stats.rx_over_errors++;
+ chan->rx_first_bd = 0;
+ chan->rx_last_bd = N_DMA_RX_BUF - 1;
+ rx_dma_start(card, ch);
+ }
+ }
+ }
+ if (status & IR0_DRX(IR0_DMIB, ch)) {
+ if (drx_stat & DSR_EOM) {
+ if (card->hw.type == PC300_TE) {
+ cpc_writeb(card->hw.falcbase +
+ card->hw.cpld_reg2,
+ cpc_readb (card->hw.falcbase +
+ card->hw.cpld_reg2) |
+ (CPLD_REG2_FALC_LED1 << (2 * ch)));
+ }
+#ifdef CONFIG_PC300_MLPPP
+ if (chan->conf.proto == PC300_PROTO_MLPPP) {
+ /* verify if driver is TTY */
+ cpc_tty_receive(d);
+ } else {
+ cpc_net_rx(dev);
+ }
+#else
+ cpc_net_rx(dev);
+#endif
+ if (card->hw.type == PC300_TE) {
+ cpc_writeb(card->hw.falcbase +
+ card->hw.cpld_reg2,
+ cpc_readb (card->hw.falcbase +
+ card->hw.cpld_reg2) &
+ ~ (CPLD_REG2_FALC_LED1 << (2 * ch)));
+ }
+ }
+ }
+ if (!(dsr_rx = cpc_readb(scabase + DSR_RX(ch)) & DSR_DE)) {
+#ifdef PC300_DEBUG_INTR
+ printk("%s: RX intr chan[%d] (st=0x%08lx, dsr=0x%02x, dsr2=0x%02x)\n",
+ dev->name, ch, status, drx_stat, dsr_rx);
+#endif
+ cpc_writeb(scabase + DSR_RX(ch), (dsr_rx | DSR_DE) & 0xfe);
+ }
+ }
+
+ /**** Transmission ****/
+ if (status & IR0_DTX((IR0_EFT | IR0_DMIA | IR0_DMIB), ch)) {
+ u8 dtx_stat = cpc_readb(scabase + DSR_TX(ch));
+
+ /* Clear TX interrupts */
+ cpc_writeb(scabase + DSR_TX(ch), dtx_stat | DSR_DWE);
+
+#ifdef PC300_DEBUG_INTR
+ printk ("sca_intr: TX intr chan[%d] (st=0x%08lx, dsr=0x%02x)\n",
+ ch, status, dtx_stat);
+#endif
+ if (status & IR0_DTX(IR0_EFT, ch)) {
+ if (dtx_stat & DSR_UDRF) {
+ if (cpc_readb (scabase + M_REG(TBN, ch)) != 0) {
+ cpc_writeb(scabase + M_REG(CMD,ch), CMD_TX_BUF_CLR);
+ }
+ if (card->hw.type == PC300_TE) {
+ cpc_writeb(card->hw.falcbase + card->hw.cpld_reg2,
+ cpc_readb (card->hw.falcbase +
+ card->hw.cpld_reg2) &
+ ~ (CPLD_REG2_FALC_LED1 << (2 * ch)));
+ }
+ dev->stats.tx_errors++;
+ dev->stats.tx_fifo_errors++;
+ sca_tx_intr(d);
+ }
+ }
+ if (status & IR0_DTX(IR0_DMIA, ch)) {
+ if (dtx_stat & DSR_BOF) {
+ }
+ }
+ if (status & IR0_DTX(IR0_DMIB, ch)) {
+ if (dtx_stat & DSR_EOM) {
+ if (card->hw.type == PC300_TE) {
+ cpc_writeb(card->hw.falcbase + card->hw.cpld_reg2,
+ cpc_readb (card->hw.falcbase +
+ card->hw.cpld_reg2) &
+ ~ (CPLD_REG2_FALC_LED1 << (2 * ch)));
+ }
+ sca_tx_intr(d);
+ }
+ }
+ }
+
+ /**** MSCI ****/
+ if (status & IR0_M(IR0_RXINTA, ch)) {
+ u8 st1 = cpc_readb(scabase + M_REG(ST1, ch));
+
+ /* Clear MSCI interrupts */
+ cpc_writeb(scabase + M_REG(ST1, ch), st1);
+
+#ifdef PC300_DEBUG_INTR
+ printk("sca_intr: MSCI intr chan[%d] (st=0x%08lx, st1=0x%02x)\n",
+ ch, status, st1);
+#endif
+ if (st1 & ST1_CDCD) { /* DCD changed */
+ if (cpc_readb(scabase + M_REG(ST3, ch)) & ST3_DCD) {
+ printk ("%s: DCD is OFF. Going administrative down.\n",
+ dev->name);
+#ifdef CONFIG_PC300_MLPPP
+ if (chan->conf.proto != PC300_PROTO_MLPPP) {
+ netif_carrier_off(dev);
+ }
+#else
+ netif_carrier_off(dev);
+
+#endif
+ card->chan[ch].d.line_off++;
+ } else { /* DCD = 1 */
+ printk ("%s: DCD is ON. Going administrative up.\n",
+ dev->name);
+#ifdef CONFIG_PC300_MLPPP
+ if (chan->conf.proto != PC300_PROTO_MLPPP)
+ /* verify if driver is not TTY */
+#endif
+ netif_carrier_on(dev);
+ card->chan[ch].d.line_on++;
+ }
+ }
+ }
+ spin_unlock(&card->card_lock);
+ }
+ if (++intr_count == 10)
+ /* Too much work at this board. Force exit */
+ break;
+ }
+}
+
+static void falc_t1_loop_detection(pc300_t *card, int ch, u8 frs1)
+{
+ pc300ch_t *chan = (pc300ch_t *) & card->chan[ch];
+ falc_t *pfalc = (falc_t *) & chan->falc;
+ void __iomem *falcbase = card->hw.falcbase;
+
+ if (((cpc_readb(falcbase + F_REG(LCR1, ch)) & LCR1_XPRBS) == 0) &&
+ !pfalc->loop_gen) {
+ if (frs1 & FRS1_LLBDD) {
+ // A Line Loop Back Deactivation signal detected
+ if (pfalc->loop_active) {
+ falc_remote_loop(card, ch, 0);
+ }
+ } else {
+ if ((frs1 & FRS1_LLBAD) &&
+ ((cpc_readb(falcbase + F_REG(LCR1, ch)) & LCR1_EPRM) == 0)) {
+ // A Line Loop Back Activation signal detected
+ if (!pfalc->loop_active) {
+ falc_remote_loop(card, ch, 1);
+ }
+ }
+ }
+ }
+}
+
+static void falc_e1_loop_detection(pc300_t *card, int ch, u8 rsp)
+{
+ pc300ch_t *chan = (pc300ch_t *) & card->chan[ch];
+ falc_t *pfalc = (falc_t *) & chan->falc;
+ void __iomem *falcbase = card->hw.falcbase;
+
+ if (((cpc_readb(falcbase + F_REG(LCR1, ch)) & LCR1_XPRBS) == 0) &&
+ !pfalc->loop_gen) {
+ if (rsp & RSP_LLBDD) {
+ // A Line Loop Back Deactivation signal detected
+ if (pfalc->loop_active) {
+ falc_remote_loop(card, ch, 0);
+ }
+ } else {
+ if ((rsp & RSP_LLBAD) &&
+ ((cpc_readb(falcbase + F_REG(LCR1, ch)) & LCR1_EPRM) == 0)) {
+ // A Line Loop Back Activation signal detected
+ if (!pfalc->loop_active) {
+ falc_remote_loop(card, ch, 1);
+ }
+ }
+ }
+ }
+}
+
+static void falc_t1_intr(pc300_t * card, int ch)
+{
+ pc300ch_t *chan = (pc300ch_t *) & card->chan[ch];
+ falc_t *pfalc = (falc_t *) & chan->falc;
+ void __iomem *falcbase = card->hw.falcbase;
+ u8 isr0, isr3, gis;
+ u8 dummy;
+
+ while ((gis = cpc_readb(falcbase + F_REG(GIS, ch))) != 0) {
+ if (gis & GIS_ISR0) {
+ isr0 = cpc_readb(falcbase + F_REG(FISR0, ch));
+ if (isr0 & FISR0_PDEN) {
+ /* Read the bit to clear the situation */
+ if (cpc_readb(falcbase + F_REG(FRS1, ch)) &
+ FRS1_PDEN) {
+ pfalc->pden++;
+ }
+ }
+ }
+
+ if (gis & GIS_ISR1) {
+ dummy = cpc_readb(falcbase + F_REG(FISR1, ch));
+ }
+
+ if (gis & GIS_ISR2) {
+ dummy = cpc_readb(falcbase + F_REG(FISR2, ch));
+ }
+
+ if (gis & GIS_ISR3) {
+ isr3 = cpc_readb(falcbase + F_REG(FISR3, ch));
+ if (isr3 & FISR3_SEC) {
+ pfalc->sec++;
+ falc_update_stats(card, ch);
+ falc_check_status(card, ch,
+ cpc_readb(falcbase + F_REG(FRS0, ch)));
+ }
+ if (isr3 & FISR3_ES) {
+ pfalc->es++;
+ }
+ if (isr3 & FISR3_LLBSC) {
+ falc_t1_loop_detection(card, ch,
+ cpc_readb(falcbase + F_REG(FRS1, ch)));
+ }
+ }
+ }
+}
+
+static void falc_e1_intr(pc300_t * card, int ch)
+{
+ pc300ch_t *chan = (pc300ch_t *) & card->chan[ch];
+ falc_t *pfalc = (falc_t *) & chan->falc;
+ void __iomem *falcbase = card->hw.falcbase;
+ u8 isr1, isr2, isr3, gis, rsp;
+ u8 dummy;
+
+ while ((gis = cpc_readb(falcbase + F_REG(GIS, ch))) != 0) {
+ rsp = cpc_readb(falcbase + F_REG(RSP, ch));
+
+ if (gis & GIS_ISR0) {
+ dummy = cpc_readb(falcbase + F_REG(FISR0, ch));
+ }
+ if (gis & GIS_ISR1) {
+ isr1 = cpc_readb(falcbase + F_REG(FISR1, ch));
+ if (isr1 & FISR1_XMB) {
+ if ((pfalc->xmb_cause & 2) &&
+ pfalc->multiframe_mode) {
+ if (cpc_readb (falcbase + F_REG(FRS0, ch)) &
+ (FRS0_LOS | FRS0_AIS | FRS0_LFA)) {
+ cpc_writeb(falcbase + F_REG(XSP, ch),
+ cpc_readb(falcbase + F_REG(XSP, ch))
+ & ~XSP_AXS);
+ } else {
+ cpc_writeb(falcbase + F_REG(XSP, ch),
+ cpc_readb(falcbase + F_REG(XSP, ch))
+ | XSP_AXS);
+ }
+ }
+ pfalc->xmb_cause = 0;
+ cpc_writeb(falcbase + F_REG(IMR1, ch),
+ cpc_readb(falcbase + F_REG(IMR1, ch)) | IMR1_XMB);
+ }
+ if (isr1 & FISR1_LLBSC) {
+ falc_e1_loop_detection(card, ch, rsp);
+ }
+ }
+ if (gis & GIS_ISR2) {
+ isr2 = cpc_readb(falcbase + F_REG(FISR2, ch));
+ if (isr2 & FISR2_T400MS) {
+ cpc_writeb(falcbase + F_REG(XSW, ch),
+ cpc_readb(falcbase + F_REG(XSW, ch)) | XSW_XRA);
+ }
+ if (isr2 & FISR2_MFAR) {
+ cpc_writeb(falcbase + F_REG(XSW, ch),
+ cpc_readb(falcbase + F_REG(XSW, ch)) & ~XSW_XRA);
+ }
+ if (isr2 & (FISR2_FAR | FISR2_LFA | FISR2_AIS | FISR2_LOS)) {
+ pfalc->xmb_cause |= 2;
+ cpc_writeb(falcbase + F_REG(IMR1, ch),
+ cpc_readb(falcbase + F_REG(IMR1, ch)) & ~IMR1_XMB);
+ }
+ }
+ if (gis & GIS_ISR3) {
+ isr3 = cpc_readb(falcbase + F_REG(FISR3, ch));
+ if (isr3 & FISR3_SEC) {
+ pfalc->sec++;
+ falc_update_stats(card, ch);
+ falc_check_status(card, ch,
+ cpc_readb(falcbase + F_REG(FRS0, ch)));
+ }
+ if (isr3 & FISR3_ES) {
+ pfalc->es++;
+ }
+ }
+ }
+}
+
+static void falc_intr(pc300_t * card)
+{
+ int ch;
+
+ for (ch = 0; ch < card->hw.nchan; ch++) {
+ pc300ch_t *chan = &card->chan[ch];
+ pc300chconf_t *conf = (pc300chconf_t *) & chan->conf;
+
+ if (conf->media == IF_IFACE_T1) {
+ falc_t1_intr(card, ch);
+ } else {
+ falc_e1_intr(card, ch);
+ }
+ }
+}
+
+static irqreturn_t cpc_intr(int irq, void *dev_id)
+{
+ pc300_t *card = dev_id;
+ volatile u8 plx_status;
+
+ if (!card) {
+#ifdef PC300_DEBUG_INTR
+ printk("cpc_intr: spurious intr %d\n", irq);
+#endif
+ return IRQ_NONE; /* spurious intr */
+ }
+
+ if (!card->hw.rambase) {
+#ifdef PC300_DEBUG_INTR
+ printk("cpc_intr: spurious intr2 %d\n", irq);
+#endif
+ return IRQ_NONE; /* spurious intr */
+ }
+
+ switch (card->hw.type) {
+ case PC300_RSV:
+ case PC300_X21:
+ sca_intr(card);
+ break;
+
+ case PC300_TE:
+ while ( (plx_status = (cpc_readb(card->hw.plxbase + card->hw.intctl_reg) &
+ (PLX_9050_LINT1_STATUS | PLX_9050_LINT2_STATUS))) != 0) {
+ if (plx_status & PLX_9050_LINT1_STATUS) { /* SCA Interrupt */
+ sca_intr(card);
+ }
+ if (plx_status & PLX_9050_LINT2_STATUS) { /* FALC Interrupt */
+ falc_intr(card);
+ }
+ }
+ break;
+ }
+ return IRQ_HANDLED;
+}
+
+static void cpc_sca_status(pc300_t * card, int ch)
+{
+ u8 ilar;
+ void __iomem *scabase = card->hw.scabase;
+ unsigned long flags;
+
+ tx_dma_buf_check(card, ch);
+ rx_dma_buf_check(card, ch);
+ ilar = cpc_readb(scabase + ILAR);
+ printk ("ILAR=0x%02x, WCRL=0x%02x, PCR=0x%02x, BTCR=0x%02x, BOLR=0x%02x\n",
+ ilar, cpc_readb(scabase + WCRL), cpc_readb(scabase + PCR),
+ cpc_readb(scabase + BTCR), cpc_readb(scabase + BOLR));
+ printk("TX_CDA=0x%08x, TX_EDA=0x%08x\n",
+ cpc_readl(scabase + DTX_REG(CDAL, ch)),
+ cpc_readl(scabase + DTX_REG(EDAL, ch)));
+ printk("RX_CDA=0x%08x, RX_EDA=0x%08x, BFL=0x%04x\n",
+ cpc_readl(scabase + DRX_REG(CDAL, ch)),
+ cpc_readl(scabase + DRX_REG(EDAL, ch)),
+ cpc_readw(scabase + DRX_REG(BFLL, ch)));
+ printk("DMER=0x%02x, DSR_TX=0x%02x, DSR_RX=0x%02x\n",
+ cpc_readb(scabase + DMER), cpc_readb(scabase + DSR_TX(ch)),
+ cpc_readb(scabase + DSR_RX(ch)));
+ printk("DMR_TX=0x%02x, DMR_RX=0x%02x, DIR_TX=0x%02x, DIR_RX=0x%02x\n",
+ cpc_readb(scabase + DMR_TX(ch)), cpc_readb(scabase + DMR_RX(ch)),
+ cpc_readb(scabase + DIR_TX(ch)),
+ cpc_readb(scabase + DIR_RX(ch)));
+ printk("DCR_TX=0x%02x, DCR_RX=0x%02x, FCT_TX=0x%02x, FCT_RX=0x%02x\n",
+ cpc_readb(scabase + DCR_TX(ch)), cpc_readb(scabase + DCR_RX(ch)),
+ cpc_readb(scabase + FCT_TX(ch)),
+ cpc_readb(scabase + FCT_RX(ch)));
+ printk("MD0=0x%02x, MD1=0x%02x, MD2=0x%02x, MD3=0x%02x, IDL=0x%02x\n",
+ cpc_readb(scabase + M_REG(MD0, ch)),
+ cpc_readb(scabase + M_REG(MD1, ch)),
+ cpc_readb(scabase + M_REG(MD2, ch)),
+ cpc_readb(scabase + M_REG(MD3, ch)),
+ cpc_readb(scabase + M_REG(IDL, ch)));
+ printk("CMD=0x%02x, SA0=0x%02x, SA1=0x%02x, TFN=0x%02x, CTL=0x%02x\n",
+ cpc_readb(scabase + M_REG(CMD, ch)),
+ cpc_readb(scabase + M_REG(SA0, ch)),
+ cpc_readb(scabase + M_REG(SA1, ch)),
+ cpc_readb(scabase + M_REG(TFN, ch)),
+ cpc_readb(scabase + M_REG(CTL, ch)));
+ printk("ST0=0x%02x, ST1=0x%02x, ST2=0x%02x, ST3=0x%02x, ST4=0x%02x\n",
+ cpc_readb(scabase + M_REG(ST0, ch)),
+ cpc_readb(scabase + M_REG(ST1, ch)),
+ cpc_readb(scabase + M_REG(ST2, ch)),
+ cpc_readb(scabase + M_REG(ST3, ch)),
+ cpc_readb(scabase + M_REG(ST4, ch)));
+ printk ("CST0=0x%02x, CST1=0x%02x, CST2=0x%02x, CST3=0x%02x, FST=0x%02x\n",
+ cpc_readb(scabase + M_REG(CST0, ch)),
+ cpc_readb(scabase + M_REG(CST1, ch)),
+ cpc_readb(scabase + M_REG(CST2, ch)),
+ cpc_readb(scabase + M_REG(CST3, ch)),
+ cpc_readb(scabase + M_REG(FST, ch)));
+ printk("TRC0=0x%02x, TRC1=0x%02x, RRC=0x%02x, TBN=0x%02x, RBN=0x%02x\n",
+ cpc_readb(scabase + M_REG(TRC0, ch)),
+ cpc_readb(scabase + M_REG(TRC1, ch)),
+ cpc_readb(scabase + M_REG(RRC, ch)),
+ cpc_readb(scabase + M_REG(TBN, ch)),
+ cpc_readb(scabase + M_REG(RBN, ch)));
+ printk("TFS=0x%02x, TNR0=0x%02x, TNR1=0x%02x, RNR=0x%02x\n",
+ cpc_readb(scabase + M_REG(TFS, ch)),
+ cpc_readb(scabase + M_REG(TNR0, ch)),
+ cpc_readb(scabase + M_REG(TNR1, ch)),
+ cpc_readb(scabase + M_REG(RNR, ch)));
+ printk("TCR=0x%02x, RCR=0x%02x, TNR1=0x%02x, RNR=0x%02x\n",
+ cpc_readb(scabase + M_REG(TCR, ch)),
+ cpc_readb(scabase + M_REG(RCR, ch)),
+ cpc_readb(scabase + M_REG(TNR1, ch)),
+ cpc_readb(scabase + M_REG(RNR, ch)));
+ printk("TXS=0x%02x, RXS=0x%02x, EXS=0x%02x, TMCT=0x%02x, TMCR=0x%02x\n",
+ cpc_readb(scabase + M_REG(TXS, ch)),
+ cpc_readb(scabase + M_REG(RXS, ch)),
+ cpc_readb(scabase + M_REG(EXS, ch)),
+ cpc_readb(scabase + M_REG(TMCT, ch)),
+ cpc_readb(scabase + M_REG(TMCR, ch)));
+ printk("IE0=0x%02x, IE1=0x%02x, IE2=0x%02x, IE4=0x%02x, FIE=0x%02x\n",
+ cpc_readb(scabase + M_REG(IE0, ch)),
+ cpc_readb(scabase + M_REG(IE1, ch)),
+ cpc_readb(scabase + M_REG(IE2, ch)),
+ cpc_readb(scabase + M_REG(IE4, ch)),
+ cpc_readb(scabase + M_REG(FIE, ch)));
+ printk("IER0=0x%08x\n", cpc_readl(scabase + IER0));
+
+ if (ilar != 0) {
+ CPC_LOCK(card, flags);
+ cpc_writeb(scabase + ILAR, ilar);
+ cpc_writeb(scabase + DMER, 0x80);
+ CPC_UNLOCK(card, flags);
+ }
+}
+
+static void cpc_falc_status(pc300_t * card, int ch)
+{
+ pc300ch_t *chan = &card->chan[ch];
+ falc_t *pfalc = (falc_t *) & chan->falc;
+ unsigned long flags;
+
+ CPC_LOCK(card, flags);
+ printk("CH%d: %s %s %d channels\n",
+ ch, (pfalc->sync ? "SYNC" : ""), (pfalc->active ? "ACTIVE" : ""),
+ pfalc->num_channels);
+
+ printk(" pden=%d, los=%d, losr=%d, lfa=%d, farec=%d\n",
+ pfalc->pden, pfalc->los, pfalc->losr, pfalc->lfa, pfalc->farec);
+ printk(" lmfa=%d, ais=%d, sec=%d, es=%d, rai=%d\n",
+ pfalc->lmfa, pfalc->ais, pfalc->sec, pfalc->es, pfalc->rai);
+ printk(" bec=%d, fec=%d, cvc=%d, cec=%d, ebc=%d\n",
+ pfalc->bec, pfalc->fec, pfalc->cvc, pfalc->cec, pfalc->ebc);
+
+ printk("\n");
+ printk(" STATUS: %s %s %s %s %s %s\n",
+ (pfalc->red_alarm ? "RED" : ""),
+ (pfalc->blue_alarm ? "BLU" : ""),
+ (pfalc->yellow_alarm ? "YEL" : ""),
+ (pfalc->loss_fa ? "LFA" : ""),
+ (pfalc->loss_mfa ? "LMF" : ""), (pfalc->prbs ? "PRB" : ""));
+ CPC_UNLOCK(card, flags);
+}
+
+static int cpc_change_mtu(struct net_device *dev, int new_mtu)
+{
+ if ((new_mtu < 128) || (new_mtu > PC300_DEF_MTU))
+ return -EINVAL;
+ dev->mtu = new_mtu;
+ return 0;
+}
+
+static int cpc_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
+{
+ pc300dev_t *d = (pc300dev_t *) dev_to_hdlc(dev)->priv;
+ pc300ch_t *chan = (pc300ch_t *) d->chan;
+ pc300_t *card = (pc300_t *) chan->card;
+ pc300conf_t conf_aux;
+ pc300chconf_t *conf = (pc300chconf_t *) & chan->conf;
+ int ch = chan->channel;
+ void __user *arg = ifr->ifr_data;
+ struct if_settings *settings = &ifr->ifr_settings;
+ void __iomem *scabase = card->hw.scabase;
+
+ if (!capable(CAP_NET_ADMIN))
+ return -EPERM;
+
+ switch (cmd) {
+ case SIOCGPC300CONF:
+#ifdef CONFIG_PC300_MLPPP
+ if (conf->proto != PC300_PROTO_MLPPP) {
+ conf->proto = /* FIXME hdlc->proto.id */ 0;
+ }
+#else
+ conf->proto = /* FIXME hdlc->proto.id */ 0;
+#endif
+ memcpy(&conf_aux.conf, conf, sizeof(pc300chconf_t));
+ memcpy(&conf_aux.hw, &card->hw, sizeof(pc300hw_t));
+ if (!arg ||
+ copy_to_user(arg, &conf_aux, sizeof(pc300conf_t)))
+ return -EINVAL;
+ return 0;
+ case SIOCSPC300CONF:
+ if (!capable(CAP_NET_ADMIN))
+ return -EPERM;
+ if (!arg ||
+ copy_from_user(&conf_aux.conf, arg, sizeof(pc300chconf_t)))
+ return -EINVAL;
+ if (card->hw.cpld_id < 0x02 &&
+ conf_aux.conf.fr_mode == PC300_FR_UNFRAMED) {
+ /* CPLD_ID < 0x02 doesn't support Unframed E1 */
+ return -EINVAL;
+ }
+#ifdef CONFIG_PC300_MLPPP
+ if (conf_aux.conf.proto == PC300_PROTO_MLPPP) {
+ if (conf->proto != PC300_PROTO_MLPPP) {
+ memcpy(conf, &conf_aux.conf, sizeof(pc300chconf_t));
+ cpc_tty_init(d); /* init TTY driver */
+ }
+ } else {
+ if (conf_aux.conf.proto == 0xffff) {
+ if (conf->proto == PC300_PROTO_MLPPP){
+ /* ifdown interface */
+ cpc_close(dev);
+ }
+ } else {
+ memcpy(conf, &conf_aux.conf, sizeof(pc300chconf_t));
+ /* FIXME hdlc->proto.id = conf->proto; */
+ }
+ }
+#else
+ memcpy(conf, &conf_aux.conf, sizeof(pc300chconf_t));
+ /* FIXME hdlc->proto.id = conf->proto; */
+#endif
+ return 0;
+ case SIOCGPC300STATUS:
+ cpc_sca_status(card, ch);
+ return 0;
+ case SIOCGPC300FALCSTATUS:
+ cpc_falc_status(card, ch);
+ return 0;
+
+ case SIOCGPC300UTILSTATS:
+ {
+ if (!arg) { /* clear statistics */
+ memset(&dev->stats, 0, sizeof(dev->stats));
+ if (card->hw.type == PC300_TE) {
+ memset(&chan->falc, 0, sizeof(falc_t));
+ }
+ } else {
+ pc300stats_t pc300stats;
+
+ memset(&pc300stats, 0, sizeof(pc300stats_t));
+ pc300stats.hw_type = card->hw.type;
+ pc300stats.line_on = card->chan[ch].d.line_on;
+ pc300stats.line_off = card->chan[ch].d.line_off;
+ memcpy(&pc300stats.gen_stats, &dev->stats,
+ sizeof(dev->stats));
+ if (card->hw.type == PC300_TE)
+ memcpy(&pc300stats.te_stats,&chan->falc,sizeof(falc_t));
+ if (copy_to_user(arg, &pc300stats, sizeof(pc300stats_t)))
+ return -EFAULT;
+ }
+ return 0;
+ }
+
+ case SIOCGPC300UTILSTATUS:
+ {
+ struct pc300status pc300status;
+
+ pc300status.hw_type = card->hw.type;
+ if (card->hw.type == PC300_TE) {
+ pc300status.te_status.sync = chan->falc.sync;
+ pc300status.te_status.red_alarm = chan->falc.red_alarm;
+ pc300status.te_status.blue_alarm = chan->falc.blue_alarm;
+ pc300status.te_status.loss_fa = chan->falc.loss_fa;
+ pc300status.te_status.yellow_alarm =chan->falc.yellow_alarm;
+ pc300status.te_status.loss_mfa = chan->falc.loss_mfa;
+ pc300status.te_status.prbs = chan->falc.prbs;
+ } else {
+ pc300status.gen_status.dcd =
+ !(cpc_readb (scabase + M_REG(ST3, ch)) & ST3_DCD);
+ pc300status.gen_status.cts =
+ !(cpc_readb (scabase + M_REG(ST3, ch)) & ST3_CTS);
+ pc300status.gen_status.rts =
+ !(cpc_readb (scabase + M_REG(CTL, ch)) & CTL_RTS);
+ pc300status.gen_status.dtr =
+ !(cpc_readb (scabase + M_REG(CTL, ch)) & CTL_DTR);
+ /* There is no DSR in HD64572 */
+ }
+ if (!arg ||
+ copy_to_user(arg, &pc300status, sizeof(pc300status_t)))
+ return -EINVAL;
+ return 0;
+ }
+
+ case SIOCSPC300TRACE:
+ /* Sets/resets a trace_flag for the respective device */
+ if (!arg || copy_from_user(&d->trace_on, arg,sizeof(unsigned char)))
+ return -EINVAL;
+ return 0;
+
+ case SIOCSPC300LOOPBACK:
+ {
+ struct pc300loopback pc300loop;
+
+ /* TE boards only */
+ if (card->hw.type != PC300_TE)
+ return -EINVAL;
+
+ if (!arg ||
+ copy_from_user(&pc300loop, arg, sizeof(pc300loopback_t)))
+ return -EINVAL;
+ switch (pc300loop.loop_type) {
+ case PC300LOCLOOP: /* Turn the local loop on/off */
+ falc_local_loop(card, ch, pc300loop.loop_on);
+ return 0;
+
+ case PC300REMLOOP: /* Turn the remote loop on/off */
+ falc_remote_loop(card, ch, pc300loop.loop_on);
+ return 0;
+
+ case PC300PAYLOADLOOP: /* Turn the payload loop on/off */
+ falc_payload_loop(card, ch, pc300loop.loop_on);
+ return 0;
+
+ case PC300GENLOOPUP: /* Generate loop UP */
+ if (pc300loop.loop_on) {
+ falc_generate_loop_up_code (card, ch);
+ } else {
+ turn_off_xlu(card, ch);
+ }
+ return 0;
+
+ case PC300GENLOOPDOWN: /* Generate loop DOWN */
+ if (pc300loop.loop_on) {
+ falc_generate_loop_down_code (card, ch);
+ } else {
+ turn_off_xld(card, ch);
+ }
+ return 0;
+
+ default:
+ return -EINVAL;
+ }
+ }
+
+ case SIOCSPC300PATTERNTEST:
+ /* Turn the pattern test on/off and show the errors counter */
+ {
+ struct pc300patterntst pc300patrntst;
+
+ /* TE boards only */
+ if (card->hw.type != PC300_TE)
+ return -EINVAL;
+
+ if (card->hw.cpld_id < 0x02) {
+ /* CPLD_ID < 0x02 doesn't support pattern test */
+ return -EINVAL;
+ }
+
+ if (!arg ||
+ copy_from_user(&pc300patrntst,arg,sizeof(pc300patterntst_t)))
+ return -EINVAL;
+ if (pc300patrntst.patrntst_on == 2) {
+ if (chan->falc.prbs == 0) {
+ falc_pattern_test(card, ch, 1);
+ }
+ pc300patrntst.num_errors =
+ falc_pattern_test_error(card, ch);
+ if (copy_to_user(arg, &pc300patrntst,
+ sizeof(pc300patterntst_t)))
+ return -EINVAL;
+ } else {
+ falc_pattern_test(card, ch, pc300patrntst.patrntst_on);
+ }
+ return 0;
+ }
+
+ case SIOCWANDEV:
+ switch (ifr->ifr_settings.type) {
+ case IF_GET_IFACE:
+ {
+ const size_t size = sizeof(sync_serial_settings);
+ ifr->ifr_settings.type = conf->media;
+ if (ifr->ifr_settings.size < size) {
+ /* data size wanted */
+ ifr->ifr_settings.size = size;
+ return -ENOBUFS;
+ }
+
+ if (copy_to_user(settings->ifs_ifsu.sync,
+ &conf->phys_settings, size)) {
+ return -EFAULT;
+ }
+ return 0;
+ }
+
+ case IF_IFACE_V35:
+ case IF_IFACE_V24:
+ case IF_IFACE_X21:
+ {
+ const size_t size = sizeof(sync_serial_settings);
+
+ if (!capable(CAP_NET_ADMIN)) {
+ return -EPERM;
+ }
+ /* incorrect data len? */
+ if (ifr->ifr_settings.size != size) {
+ return -ENOBUFS;
+ }
+
+ if (copy_from_user(&conf->phys_settings,
+ settings->ifs_ifsu.sync, size)) {
+ return -EFAULT;
+ }
+
+ if (conf->phys_settings.loopback) {
+ cpc_writeb(card->hw.scabase + M_REG(MD2, ch),
+ cpc_readb(card->hw.scabase + M_REG(MD2, ch)) |
+ MD2_LOOP_MIR);
+ }
+ conf->media = ifr->ifr_settings.type;
+ return 0;
+ }
+
+ case IF_IFACE_T1:
+ case IF_IFACE_E1:
+ {
+ const size_t te_size = sizeof(te1_settings);
+ const size_t size = sizeof(sync_serial_settings);
+
+ if (!capable(CAP_NET_ADMIN)) {
+ return -EPERM;
+ }
+
+ /* incorrect data len? */
+ if (ifr->ifr_settings.size != te_size) {
+ return -ENOBUFS;
+ }
+
+ if (copy_from_user(&conf->phys_settings,
+ settings->ifs_ifsu.te1, size)) {
+ return -EFAULT;
+ }/* Ignoring HDLC slot_map for a while */
+
+ if (conf->phys_settings.loopback) {
+ cpc_writeb(card->hw.scabase + M_REG(MD2, ch),
+ cpc_readb(card->hw.scabase + M_REG(MD2, ch)) |
+ MD2_LOOP_MIR);
+ }
+ conf->media = ifr->ifr_settings.type;
+ return 0;
+ }
+ default:
+ return hdlc_ioctl(dev, ifr, cmd);
+ }
+
+ default:
+ return hdlc_ioctl(dev, ifr, cmd);
+ }
+}
+
+static int clock_rate_calc(u32 rate, u32 clock, int *br_io)
+{
+ int br, tc;
+ int br_pwr, error;
+
+ *br_io = 0;
+
+ if (rate == 0)
+ return 0;
+
+ for (br = 0, br_pwr = 1; br <= 9; br++, br_pwr <<= 1) {
+ if ((tc = clock / br_pwr / rate) <= 0xff) {
+ *br_io = br;
+ break;
+ }
+ }
+
+ if (tc <= 0xff) {
+ error = ((rate - (clock / br_pwr / rate)) / rate) * 1000;
+ /* Errors bigger than +/- 1% won't be tolerated */
+ if (error < -10 || error > 10)
+ return -1;
+ else
+ return tc;
+ } else {
+ return -1;
+ }
+}
+
+static int ch_config(pc300dev_t * d)
+{
+ pc300ch_t *chan = (pc300ch_t *) d->chan;
+ pc300chconf_t *conf = (pc300chconf_t *) & chan->conf;
+ pc300_t *card = (pc300_t *) chan->card;
+ void __iomem *scabase = card->hw.scabase;
+ void __iomem *plxbase = card->hw.plxbase;
+ int ch = chan->channel;
+ u32 clkrate = chan->conf.phys_settings.clock_rate;
+ u32 clktype = chan->conf.phys_settings.clock_type;
+ u16 encoding = chan->conf.proto_settings.encoding;
+ u16 parity = chan->conf.proto_settings.parity;
+ u8 md0, md2;
+
+ /* Reset the channel */
+ cpc_writeb(scabase + M_REG(CMD, ch), CMD_CH_RST);
+
+ /* Configure the SCA registers */
+ switch (parity) {
+ case PARITY_NONE:
+ md0 = MD0_BIT_SYNC;
+ break;
+ case PARITY_CRC16_PR0:
+ md0 = MD0_CRC16_0|MD0_CRCC0|MD0_BIT_SYNC;
+ break;
+ case PARITY_CRC16_PR1:
+ md0 = MD0_CRC16_1|MD0_CRCC0|MD0_BIT_SYNC;
+ break;
+ case PARITY_CRC32_PR1_CCITT:
+ md0 = MD0_CRC32|MD0_CRCC0|MD0_BIT_SYNC;
+ break;
+ case PARITY_CRC16_PR1_CCITT:
+ default:
+ md0 = MD0_CRC_CCITT|MD0_CRCC0|MD0_BIT_SYNC;
+ break;
+ }
+ switch (encoding) {
+ case ENCODING_NRZI:
+ md2 = MD2_F_DUPLEX|MD2_ADPLL_X8|MD2_NRZI;
+ break;
+ case ENCODING_FM_MARK: /* FM1 */
+ md2 = MD2_F_DUPLEX|MD2_ADPLL_X8|MD2_FM|MD2_FM1;
+ break;
+ case ENCODING_FM_SPACE: /* FM0 */
+ md2 = MD2_F_DUPLEX|MD2_ADPLL_X8|MD2_FM|MD2_FM0;
+ break;
+ case ENCODING_MANCHESTER: /* It's not working... */
+ md2 = MD2_F_DUPLEX|MD2_ADPLL_X8|MD2_FM|MD2_MANCH;
+ break;
+ case ENCODING_NRZ:
+ default:
+ md2 = MD2_F_DUPLEX|MD2_ADPLL_X8|MD2_NRZ;
+ break;
+ }
+ cpc_writeb(scabase + M_REG(MD0, ch), md0);
+ cpc_writeb(scabase + M_REG(MD1, ch), 0);
+ cpc_writeb(scabase + M_REG(MD2, ch), md2);
+ cpc_writeb(scabase + M_REG(IDL, ch), 0x7e);
+ cpc_writeb(scabase + M_REG(CTL, ch), CTL_URSKP | CTL_IDLC);
+
+ /* Configure HW media */
+ switch (card->hw.type) {
+ case PC300_RSV:
+ if (conf->media == IF_IFACE_V35) {
+ cpc_writel((plxbase + card->hw.gpioc_reg),
+ cpc_readl(plxbase + card->hw.gpioc_reg) | PC300_CHMEDIA_MASK(ch));
+ } else {
+ cpc_writel((plxbase + card->hw.gpioc_reg),
+ cpc_readl(plxbase + card->hw.gpioc_reg) & ~PC300_CHMEDIA_MASK(ch));
+ }
+ break;
+
+ case PC300_X21:
+ break;
+
+ case PC300_TE:
+ te_config(card, ch);
+ break;
+ }
+
+ switch (card->hw.type) {
+ case PC300_RSV:
+ case PC300_X21:
+ if (clktype == CLOCK_INT || clktype == CLOCK_TXINT) {
+ int tmc, br;
+
+ /* Calculate the clkrate parameters */
+ tmc = clock_rate_calc(clkrate, card->hw.clock, &br);
+ if (tmc < 0)
+ return -EIO;
+ cpc_writeb(scabase + M_REG(TMCT, ch), tmc);
+ cpc_writeb(scabase + M_REG(TXS, ch),
+ (TXS_DTRXC | TXS_IBRG | br));
+ if (clktype == CLOCK_INT) {
+ cpc_writeb(scabase + M_REG(TMCR, ch), tmc);
+ cpc_writeb(scabase + M_REG(RXS, ch),
+ (RXS_IBRG | br));
+ } else {
+ cpc_writeb(scabase + M_REG(TMCR, ch), 1);
+ cpc_writeb(scabase + M_REG(RXS, ch), 0);
+ }
+ if (card->hw.type == PC300_X21) {
+ cpc_writeb(scabase + M_REG(GPO, ch), 1);
+ cpc_writeb(scabase + M_REG(EXS, ch), EXS_TES1 | EXS_RES1);
+ } else {
+ cpc_writeb(scabase + M_REG(EXS, ch), EXS_TES1);
+ }
+ } else {
+ cpc_writeb(scabase + M_REG(TMCT, ch), 1);
+ if (clktype == CLOCK_EXT) {
+ cpc_writeb(scabase + M_REG(TXS, ch),
+ TXS_DTRXC);
+ } else {
+ cpc_writeb(scabase + M_REG(TXS, ch),
+ TXS_DTRXC|TXS_RCLK);
+ }
+ cpc_writeb(scabase + M_REG(TMCR, ch), 1);
+ cpc_writeb(scabase + M_REG(RXS, ch), 0);
+ if (card->hw.type == PC300_X21) {
+ cpc_writeb(scabase + M_REG(GPO, ch), 0);
+ cpc_writeb(scabase + M_REG(EXS, ch), EXS_TES1 | EXS_RES1);
+ } else {
+ cpc_writeb(scabase + M_REG(EXS, ch), EXS_TES1);
+ }
+ }
+ break;
+
+ case PC300_TE:
+ /* SCA always receives clock from the FALC chip */
+ cpc_writeb(scabase + M_REG(TMCT, ch), 1);
+ cpc_writeb(scabase + M_REG(TXS, ch), 0);
+ cpc_writeb(scabase + M_REG(TMCR, ch), 1);
+ cpc_writeb(scabase + M_REG(RXS, ch), 0);
+ cpc_writeb(scabase + M_REG(EXS, ch), 0);
+ break;
+ }
+
+ /* Enable Interrupts */
+ cpc_writel(scabase + IER0,
+ cpc_readl(scabase + IER0) |
+ IR0_M(IR0_RXINTA, ch) |
+ IR0_DRX(IR0_EFT | IR0_DMIA | IR0_DMIB, ch) |
+ IR0_DTX(IR0_EFT | IR0_DMIA | IR0_DMIB, ch));
+ cpc_writeb(scabase + M_REG(IE0, ch),
+ cpc_readl(scabase + M_REG(IE0, ch)) | IE0_RXINTA);
+ cpc_writeb(scabase + M_REG(IE1, ch),
+ cpc_readl(scabase + M_REG(IE1, ch)) | IE1_CDCD);
+
+ return 0;
+}
+
+static int rx_config(pc300dev_t * d)
+{
+ pc300ch_t *chan = (pc300ch_t *) d->chan;
+ pc300_t *card = (pc300_t *) chan->card;
+ void __iomem *scabase = card->hw.scabase;
+ int ch = chan->channel;
+
+ cpc_writeb(scabase + DSR_RX(ch), 0);
+
+ /* General RX settings */
+ cpc_writeb(scabase + M_REG(RRC, ch), 0);
+ cpc_writeb(scabase + M_REG(RNR, ch), 16);
+
+ /* Enable reception */
+ cpc_writeb(scabase + M_REG(CMD, ch), CMD_RX_CRC_INIT);
+ cpc_writeb(scabase + M_REG(CMD, ch), CMD_RX_ENA);
+
+ /* Initialize DMA stuff */
+ chan->rx_first_bd = 0;
+ chan->rx_last_bd = N_DMA_RX_BUF - 1;
+ rx_dma_buf_init(card, ch);
+ cpc_writeb(scabase + DCR_RX(ch), DCR_FCT_CLR);
+ cpc_writeb(scabase + DMR_RX(ch), (DMR_TMOD | DMR_NF));
+ cpc_writeb(scabase + DIR_RX(ch), (DIR_EOM | DIR_BOF));
+
+ /* Start DMA */
+ rx_dma_start(card, ch);
+
+ return 0;
+}
+
+static int tx_config(pc300dev_t * d)
+{
+ pc300ch_t *chan = (pc300ch_t *) d->chan;
+ pc300_t *card = (pc300_t *) chan->card;
+ void __iomem *scabase = card->hw.scabase;
+ int ch = chan->channel;
+
+ cpc_writeb(scabase + DSR_TX(ch), 0);
+
+ /* General TX settings */
+ cpc_writeb(scabase + M_REG(TRC0, ch), 0);
+ cpc_writeb(scabase + M_REG(TFS, ch), 32);
+ cpc_writeb(scabase + M_REG(TNR0, ch), 20);
+ cpc_writeb(scabase + M_REG(TNR1, ch), 48);
+ cpc_writeb(scabase + M_REG(TCR, ch), 8);
+
+ /* Enable transmission */
+ cpc_writeb(scabase + M_REG(CMD, ch), CMD_TX_CRC_INIT);
+
+ /* Initialize DMA stuff */
+ chan->tx_first_bd = 0;
+ chan->tx_next_bd = 0;
+ tx_dma_buf_init(card, ch);
+ cpc_writeb(scabase + DCR_TX(ch), DCR_FCT_CLR);
+ cpc_writeb(scabase + DMR_TX(ch), (DMR_TMOD | DMR_NF));
+ cpc_writeb(scabase + DIR_TX(ch), (DIR_EOM | DIR_BOF | DIR_UDRF));
+ cpc_writel(scabase + DTX_REG(CDAL, ch), TX_BD_ADDR(ch, chan->tx_first_bd));
+ cpc_writel(scabase + DTX_REG(EDAL, ch), TX_BD_ADDR(ch, chan->tx_next_bd));
+
+ return 0;
+}
+
+static int cpc_attach(struct net_device *dev, unsigned short encoding,
+ unsigned short parity)
+{
+ pc300dev_t *d = (pc300dev_t *)dev_to_hdlc(dev)->priv;
+ pc300ch_t *chan = (pc300ch_t *)d->chan;
+ pc300_t *card = (pc300_t *)chan->card;
+ pc300chconf_t *conf = (pc300chconf_t *)&chan->conf;
+
+ if (card->hw.type == PC300_TE) {
+ if (encoding != ENCODING_NRZ && encoding != ENCODING_NRZI) {
+ return -EINVAL;
+ }
+ } else {
+ if (encoding != ENCODING_NRZ && encoding != ENCODING_NRZI &&
+ encoding != ENCODING_FM_MARK && encoding != ENCODING_FM_SPACE) {
+ /* Driver doesn't support ENCODING_MANCHESTER yet */
+ return -EINVAL;
+ }
+ }
+
+ if (parity != PARITY_NONE && parity != PARITY_CRC16_PR0 &&
+ parity != PARITY_CRC16_PR1 && parity != PARITY_CRC32_PR1_CCITT &&
+ parity != PARITY_CRC16_PR1_CCITT) {
+ return -EINVAL;
+ }
+
+ conf->proto_settings.encoding = encoding;
+ conf->proto_settings.parity = parity;
+ return 0;
+}
+
+static int cpc_opench(pc300dev_t * d)
+{
+ pc300ch_t *chan = (pc300ch_t *) d->chan;
+ pc300_t *card = (pc300_t *) chan->card;
+ int ch = chan->channel, rc;
+ void __iomem *scabase = card->hw.scabase;
+
+ rc = ch_config(d);
+ if (rc)
+ return rc;
+
+ rx_config(d);
+
+ tx_config(d);
+
+ /* Assert RTS and DTR */
+ cpc_writeb(scabase + M_REG(CTL, ch),
+ cpc_readb(scabase + M_REG(CTL, ch)) & ~(CTL_RTS | CTL_DTR));
+
+ return 0;
+}
+
+static void cpc_closech(pc300dev_t * d)
+{
+ pc300ch_t *chan = (pc300ch_t *) d->chan;
+ pc300_t *card = (pc300_t *) chan->card;
+ falc_t *pfalc = (falc_t *) & chan->falc;
+ int ch = chan->channel;
+
+ cpc_writeb(card->hw.scabase + M_REG(CMD, ch), CMD_CH_RST);
+ rx_dma_stop(card, ch);
+ tx_dma_stop(card, ch);
+
+ if (card->hw.type == PC300_TE) {
+ memset(pfalc, 0, sizeof(falc_t));
+ cpc_writeb(card->hw.falcbase + card->hw.cpld_reg2,
+ cpc_readb(card->hw.falcbase + card->hw.cpld_reg2) &
+ ~((CPLD_REG2_FALC_TX_CLK | CPLD_REG2_FALC_RX_CLK |
+ CPLD_REG2_FALC_LED2) << (2 * ch)));
+ /* Reset the FALC chip */
+ cpc_writeb(card->hw.falcbase + card->hw.cpld_reg1,
+ cpc_readb(card->hw.falcbase + card->hw.cpld_reg1) |
+ (CPLD_REG1_FALC_RESET << (2 * ch)));
+ udelay(10000);
+ cpc_writeb(card->hw.falcbase + card->hw.cpld_reg1,
+ cpc_readb(card->hw.falcbase + card->hw.cpld_reg1) &
+ ~(CPLD_REG1_FALC_RESET << (2 * ch)));
+ }
+}
+
+int cpc_open(struct net_device *dev)
+{
+ pc300dev_t *d = (pc300dev_t *) dev_to_hdlc(dev)->priv;
+ struct ifreq ifr;
+ int result;
+
+#ifdef PC300_DEBUG_OTHER
+ printk("pc300: cpc_open");
+#endif
+
+ result = hdlc_open(dev);
+
+ if (result)
+ return result;
+
+ sprintf(ifr.ifr_name, "%s", dev->name);
+ result = cpc_opench(d);
+ if (result)
+ goto err_out;
+
+ netif_start_queue(dev);
+ return 0;
+
+err_out:
+ hdlc_close(dev);
+ return result;
+}
+
+static int cpc_close(struct net_device *dev)
+{
+ pc300dev_t *d = (pc300dev_t *) dev_to_hdlc(dev)->priv;
+ pc300ch_t *chan = (pc300ch_t *) d->chan;
+ pc300_t *card = (pc300_t *) chan->card;
+ unsigned long flags;
+
+#ifdef PC300_DEBUG_OTHER
+ printk("pc300: cpc_close");
+#endif
+
+ netif_stop_queue(dev);
+
+ CPC_LOCK(card, flags);
+ cpc_closech(d);
+ CPC_UNLOCK(card, flags);
+
+ hdlc_close(dev);
+
+#ifdef CONFIG_PC300_MLPPP
+ if (chan->conf.proto == PC300_PROTO_MLPPP) {
+ cpc_tty_unregister_service(d);
+ chan->conf.proto = 0xffff;
+ }
+#endif
+
+ return 0;
+}
+
+static u32 detect_ram(pc300_t * card)
+{
+ u32 i;
+ u8 data;
+ void __iomem *rambase = card->hw.rambase;
+
+ card->hw.ramsize = PC300_RAMSIZE;
+ /* Let's find out how much RAM is present on this board */
+ for (i = 0; i < card->hw.ramsize; i++) {
+ data = (u8)(i & 0xff);
+ cpc_writeb(rambase + i, data);
+ if (cpc_readb(rambase + i) != data) {
+ break;
+ }
+ }
+ return i;
+}
+
+static void plx_init(pc300_t * card)
+{
+ struct RUNTIME_9050 __iomem *plx_ctl = card->hw.plxbase;
+
+ /* Reset PLX */
+ cpc_writel(&plx_ctl->init_ctrl,
+ cpc_readl(&plx_ctl->init_ctrl) | 0x40000000);
+ udelay(10000L);
+ cpc_writel(&plx_ctl->init_ctrl,
+ cpc_readl(&plx_ctl->init_ctrl) & ~0x40000000);
+
+ /* Reload Config. Registers from EEPROM */
+ cpc_writel(&plx_ctl->init_ctrl,
+ cpc_readl(&plx_ctl->init_ctrl) | 0x20000000);
+ udelay(10000L);
+ cpc_writel(&plx_ctl->init_ctrl,
+ cpc_readl(&plx_ctl->init_ctrl) & ~0x20000000);
+
+}
+
+static void show_version(void)
+{
+ char *rcsvers, *rcsdate, *tmp;
+
+ rcsvers = strchr(rcsid, ' ');
+ rcsvers++;
+ tmp = strchr(rcsvers, ' ');
+ *tmp++ = '\0';
+ rcsdate = strchr(tmp, ' ');
+ rcsdate++;
+ tmp = strrchr(rcsdate, ' ');
+ *tmp = '\0';
+ pr_info("Cyclades-PC300 driver %s %s\n", rcsvers, rcsdate);
+} /* show_version */
+
+static const struct net_device_ops cpc_netdev_ops = {
+ .ndo_open = cpc_open,
+ .ndo_stop = cpc_close,
+ .ndo_tx_timeout = cpc_tx_timeout,
+ .ndo_set_mac_address = NULL,
+ .ndo_change_mtu = cpc_change_mtu,
+ .ndo_do_ioctl = cpc_ioctl,
+ .ndo_validate_addr = eth_validate_addr,
+};
+
+static void cpc_init_card(pc300_t * card)
+{
+ int i, devcount = 0;
+ static int board_nbr = 1;
+
+ /* Enable interrupts on the PCI bridge */
+ plx_init(card);
+ cpc_writew(card->hw.plxbase + card->hw.intctl_reg,
+ cpc_readw(card->hw.plxbase + card->hw.intctl_reg) | 0x0040);
+
+#ifdef USE_PCI_CLOCK
+ /* Set board clock to PCI clock */
+ cpc_writel(card->hw.plxbase + card->hw.gpioc_reg,
+ cpc_readl(card->hw.plxbase + card->hw.gpioc_reg) | 0x00000004UL);
+ card->hw.clock = PC300_PCI_CLOCK;
+#else
+ /* Set board clock to internal oscillator clock */
+ cpc_writel(card->hw.plxbase + card->hw.gpioc_reg,
+ cpc_readl(card->hw.plxbase + card->hw.gpioc_reg) & ~0x00000004UL);
+ card->hw.clock = PC300_OSC_CLOCK;
+#endif
+
+ /* Detect actual on-board RAM size */
+ card->hw.ramsize = detect_ram(card);
+
+ /* Set Global SCA-II registers */
+ cpc_writeb(card->hw.scabase + PCR, PCR_PR2);
+ cpc_writeb(card->hw.scabase + BTCR, 0x10);
+ cpc_writeb(card->hw.scabase + WCRL, 0);
+ cpc_writeb(card->hw.scabase + DMER, 0x80);
+
+ if (card->hw.type == PC300_TE) {
+ u8 reg1;
+
+ /* Check CPLD version */
+ reg1 = cpc_readb(card->hw.falcbase + CPLD_REG1);
+ cpc_writeb(card->hw.falcbase + CPLD_REG1, (reg1 + 0x5a));
+ if (cpc_readb(card->hw.falcbase + CPLD_REG1) == reg1) {
+ /* New CPLD */
+ card->hw.cpld_id = cpc_readb(card->hw.falcbase + CPLD_ID_REG);
+ card->hw.cpld_reg1 = CPLD_V2_REG1;
+ card->hw.cpld_reg2 = CPLD_V2_REG2;
+ } else {
+ /* old CPLD */
+ card->hw.cpld_id = 0;
+ card->hw.cpld_reg1 = CPLD_REG1;
+ card->hw.cpld_reg2 = CPLD_REG2;
+ cpc_writeb(card->hw.falcbase + CPLD_REG1, reg1);
+ }
+
+ /* Enable the board's global clock */
+ cpc_writeb(card->hw.falcbase + card->hw.cpld_reg1,
+ cpc_readb(card->hw.falcbase + card->hw.cpld_reg1) |
+ CPLD_REG1_GLOBAL_CLK);
+
+ }
+
+ for (i = 0; i < card->hw.nchan; i++) {
+ pc300ch_t *chan = &card->chan[i];
+ pc300dev_t *d = &chan->d;
+ hdlc_device *hdlc;
+ struct net_device *dev;
+
+ chan->card = card;
+ chan->channel = i;
+ chan->conf.phys_settings.clock_rate = 0;
+ chan->conf.phys_settings.clock_type = CLOCK_EXT;
+ chan->conf.proto_settings.encoding = ENCODING_NRZ;
+ chan->conf.proto_settings.parity = PARITY_CRC16_PR1_CCITT;
+ switch (card->hw.type) {
+ case PC300_TE:
+ chan->conf.media = IF_IFACE_T1;
+ chan->conf.lcode = PC300_LC_B8ZS;
+ chan->conf.fr_mode = PC300_FR_ESF;
+ chan->conf.lbo = PC300_LBO_0_DB;
+ chan->conf.rx_sens = PC300_RX_SENS_SH;
+ chan->conf.tslot_bitmap = 0xffffffffUL;
+ break;
+
+ case PC300_X21:
+ chan->conf.media = IF_IFACE_X21;
+ break;
+
+ case PC300_RSV:
+ default:
+ chan->conf.media = IF_IFACE_V35;
+ break;
+ }
+ chan->conf.proto = IF_PROTO_PPP;
+ chan->tx_first_bd = 0;
+ chan->tx_next_bd = 0;
+ chan->rx_first_bd = 0;
+ chan->rx_last_bd = N_DMA_RX_BUF - 1;
+ chan->nfree_tx_bd = N_DMA_TX_BUF;
+
+ d->chan = chan;
+ d->trace_on = 0;
+ d->line_on = 0;
+ d->line_off = 0;
+
+ dev = alloc_hdlcdev(d);
+ if (dev == NULL)
+ continue;
+
+ hdlc = dev_to_hdlc(dev);
+ hdlc->xmit = cpc_queue_xmit;
+ hdlc->attach = cpc_attach;
+ d->dev = dev;
+ dev->mem_start = card->hw.ramphys;
+ dev->mem_end = card->hw.ramphys + card->hw.ramsize - 1;
+ dev->irq = card->hw.irq;
+ dev->tx_queue_len = PC300_TX_QUEUE_LEN;
+ dev->mtu = PC300_DEF_MTU;
+
+ dev->netdev_ops = &cpc_netdev_ops;
+ dev->watchdog_timeo = PC300_TX_TIMEOUT;
+
+ if (register_hdlc_device(dev) == 0) {
+ printk("%s: Cyclades-PC300/", dev->name);
+ switch (card->hw.type) {
+ case PC300_TE:
+ if (card->hw.bus == PC300_PMC) {
+ printk("TE-M");
+ } else {
+ printk("TE ");
+ }
+ break;
+
+ case PC300_X21:
+ printk("X21 ");
+ break;
+
+ case PC300_RSV:
+ default:
+ printk("RSV ");
+ break;
+ }
+ printk (" #%d, %dKB of RAM at 0x%08x, IRQ%d, channel %d.\n",
+ board_nbr, card->hw.ramsize / 1024,
+ card->hw.ramphys, card->hw.irq, i + 1);
+ devcount++;
+ } else {
+ printk ("Dev%d on card(0x%08x): unable to allocate i/f name.\n",
+ i + 1, card->hw.ramphys);
+ free_netdev(dev);
+ continue;
+ }
+ }
+ spin_lock_init(&card->card_lock);
+
+ board_nbr++;
+}
+
+static int __devinit
+cpc_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
+{
+ int err, eeprom_outdated = 0;
+ u16 device_id;
+ pc300_t *card;
+
+ if ((err = pci_enable_device(pdev)) < 0)
+ return err;
+
+ card = kzalloc(sizeof(pc300_t), GFP_KERNEL);
+ if (card == NULL) {
+ printk("PC300 found at RAM 0x%016llx, "
+ "but could not allocate card structure.\n",
+ (unsigned long long)pci_resource_start(pdev, 3));
+ err = -ENOMEM;
+ goto err_disable_dev;
+ }
+
+ err = -ENODEV;
+
+ /* read PCI configuration area */
+ device_id = ent->device;
+ card->hw.irq = pdev->irq;
+ card->hw.iophys = pci_resource_start(pdev, 1);
+ card->hw.iosize = pci_resource_len(pdev, 1);
+ card->hw.scaphys = pci_resource_start(pdev, 2);
+ card->hw.scasize = pci_resource_len(pdev, 2);
+ card->hw.ramphys = pci_resource_start(pdev, 3);
+ card->hw.alloc_ramsize = pci_resource_len(pdev, 3);
+ card->hw.falcphys = pci_resource_start(pdev, 4);
+ card->hw.falcsize = pci_resource_len(pdev, 4);
+ card->hw.plxphys = pci_resource_start(pdev, 5);
+ card->hw.plxsize = pci_resource_len(pdev, 5);
+
+ switch (device_id) {
+ case PCI_DEVICE_ID_PC300_RX_1:
+ case PCI_DEVICE_ID_PC300_TE_1:
+ case PCI_DEVICE_ID_PC300_TE_M_1:
+ card->hw.nchan = 1;
+ break;
+
+ case PCI_DEVICE_ID_PC300_RX_2:
+ case PCI_DEVICE_ID_PC300_TE_2:
+ case PCI_DEVICE_ID_PC300_TE_M_2:
+ default:
+ card->hw.nchan = PC300_MAXCHAN;
+ break;
+ }
+#ifdef PC300_DEBUG_PCI
+ printk("cpc (bus=0x0%x,pci_id=0x%x,", pdev->bus->number, pdev->devfn);
+ printk("rev_id=%d) IRQ%d\n", pdev->revision, card->hw.irq);
+ printk("cpc:found ramaddr=0x%08lx plxaddr=0x%08lx "
+ "ctladdr=0x%08lx falcaddr=0x%08lx\n",
+ card->hw.ramphys, card->hw.plxphys, card->hw.scaphys,
+ card->hw.falcphys);
+#endif
+ /* Although we don't use this I/O region, we should
+ * request it from the kernel anyway, to avoid problems
+ * with other drivers accessing it. */
+ if (!request_region(card->hw.iophys, card->hw.iosize, "PLX Registers")) {
+ /* In case we can't allocate it, warn user */
+ printk("WARNING: couldn't allocate I/O region for PC300 board "
+ "at 0x%08x!\n", card->hw.ramphys);
+ }
+
+ if (card->hw.plxphys) {
+ pci_write_config_dword(pdev, PCI_BASE_ADDRESS_0, card->hw.plxphys);
+ } else {
+ eeprom_outdated = 1;
+ card->hw.plxphys = pci_resource_start(pdev, 0);
+ card->hw.plxsize = pci_resource_len(pdev, 0);
+ }
+
+ if (!request_mem_region(card->hw.plxphys, card->hw.plxsize,
+ "PLX Registers")) {
+ printk("PC300 found at RAM 0x%08x, "
+ "but could not allocate PLX mem region.\n",
+ card->hw.ramphys);
+ goto err_release_io;
+ }
+ if (!request_mem_region(card->hw.ramphys, card->hw.alloc_ramsize,
+ "On-board RAM")) {
+ printk("PC300 found at RAM 0x%08x, "
+ "but could not allocate RAM mem region.\n",
+ card->hw.ramphys);
+ goto err_release_plx;
+ }
+ if (!request_mem_region(card->hw.scaphys, card->hw.scasize,
+ "SCA-II Registers")) {
+ printk("PC300 found at RAM 0x%08x, "
+ "but could not allocate SCA mem region.\n",
+ card->hw.ramphys);
+ goto err_release_ram;
+ }
+
+ card->hw.plxbase = ioremap(card->hw.plxphys, card->hw.plxsize);
+ card->hw.rambase = ioremap(card->hw.ramphys, card->hw.alloc_ramsize);
+ card->hw.scabase = ioremap(card->hw.scaphys, card->hw.scasize);
+ switch (device_id) {
+ case PCI_DEVICE_ID_PC300_TE_1:
+ case PCI_DEVICE_ID_PC300_TE_2:
+ case PCI_DEVICE_ID_PC300_TE_M_1:
+ case PCI_DEVICE_ID_PC300_TE_M_2:
+ request_mem_region(card->hw.falcphys, card->hw.falcsize,
+ "FALC Registers");
+ card->hw.falcbase = ioremap(card->hw.falcphys, card->hw.falcsize);
+ break;
+
+ case PCI_DEVICE_ID_PC300_RX_1:
+ case PCI_DEVICE_ID_PC300_RX_2:
+ default:
+ card->hw.falcbase = NULL;
+ break;
+ }
+
+#ifdef PC300_DEBUG_PCI
+ printk("cpc: relocate ramaddr=0x%08lx plxaddr=0x%08lx "
+ "ctladdr=0x%08lx falcaddr=0x%08lx\n",
+ card->hw.rambase, card->hw.plxbase, card->hw.scabase,
+ card->hw.falcbase);
+#endif
+
+ /* Set PCI drv pointer to the card structure */
+ pci_set_drvdata(pdev, card);
+
+ /* Set board type */
+ switch (device_id) {
+ case PCI_DEVICE_ID_PC300_TE_1:
+ case PCI_DEVICE_ID_PC300_TE_2:
+ case PCI_DEVICE_ID_PC300_TE_M_1:
+ case PCI_DEVICE_ID_PC300_TE_M_2:
+ card->hw.type = PC300_TE;
+
+ if ((device_id == PCI_DEVICE_ID_PC300_TE_M_1) ||
+ (device_id == PCI_DEVICE_ID_PC300_TE_M_2)) {
+ card->hw.bus = PC300_PMC;
+ /* Set PLX register offsets */
+ card->hw.gpioc_reg = 0x54;
+ card->hw.intctl_reg = 0x4c;
+ } else {
+ card->hw.bus = PC300_PCI;
+ /* Set PLX register offsets */
+ card->hw.gpioc_reg = 0x50;
+ card->hw.intctl_reg = 0x4c;
+ }
+ break;
+
+ case PCI_DEVICE_ID_PC300_RX_1:
+ case PCI_DEVICE_ID_PC300_RX_2:
+ default:
+ card->hw.bus = PC300_PCI;
+ /* Set PLX register offsets */
+ card->hw.gpioc_reg = 0x50;
+ card->hw.intctl_reg = 0x4c;
+
+ if ((cpc_readl(card->hw.plxbase + card->hw.gpioc_reg) & PC300_CTYPE_MASK)) {
+ card->hw.type = PC300_X21;
+ } else {
+ card->hw.type = PC300_RSV;
+ }
+ break;
+ }
+
+ /* Allocate IRQ */
+ if (request_irq(card->hw.irq, cpc_intr, IRQF_SHARED, "Cyclades-PC300", card)) {
+ printk ("PC300 found at RAM 0x%08x, but could not allocate IRQ%d.\n",
+ card->hw.ramphys, card->hw.irq);
+ goto err_io_unmap;
+ }
+
+ cpc_init_card(card);
+
+ if (eeprom_outdated)
+ printk("WARNING: PC300 with outdated EEPROM.\n");
+ return 0;
+
+err_io_unmap:
+ iounmap(card->hw.plxbase);
+ iounmap(card->hw.scabase);
+ iounmap(card->hw.rambase);
+ if (card->hw.type == PC300_TE) {
+ iounmap(card->hw.falcbase);
+ release_mem_region(card->hw.falcphys, card->hw.falcsize);
+ }
+ release_mem_region(card->hw.scaphys, card->hw.scasize);
+err_release_ram:
+ release_mem_region(card->hw.ramphys, card->hw.alloc_ramsize);
+err_release_plx:
+ release_mem_region(card->hw.plxphys, card->hw.plxsize);
+err_release_io:
+ release_region(card->hw.iophys, card->hw.iosize);
+ kfree(card);
+err_disable_dev:
+ pci_disable_device(pdev);
+ return err;
+}
+
+static void __devexit cpc_remove_one(struct pci_dev *pdev)
+{
+ pc300_t *card = pci_get_drvdata(pdev);
+
+ if (card->hw.rambase) {
+ int i;
+
+ /* Disable interrupts on the PCI bridge */
+ cpc_writew(card->hw.plxbase + card->hw.intctl_reg,
+ cpc_readw(card->hw.plxbase + card->hw.intctl_reg) & ~(0x0040));
+
+ for (i = 0; i < card->hw.nchan; i++) {
+ unregister_hdlc_device(card->chan[i].d.dev);
+ }
+ iounmap(card->hw.plxbase);
+ iounmap(card->hw.scabase);
+ iounmap(card->hw.rambase);
+ release_mem_region(card->hw.plxphys, card->hw.plxsize);
+ release_mem_region(card->hw.ramphys, card->hw.alloc_ramsize);
+ release_mem_region(card->hw.scaphys, card->hw.scasize);
+ release_region(card->hw.iophys, card->hw.iosize);
+ if (card->hw.type == PC300_TE) {
+ iounmap(card->hw.falcbase);
+ release_mem_region(card->hw.falcphys, card->hw.falcsize);
+ }
+ for (i = 0; i < card->hw.nchan; i++)
+ if (card->chan[i].d.dev)
+ free_netdev(card->chan[i].d.dev);
+ if (card->hw.irq)
+ free_irq(card->hw.irq, card);
+ kfree(card);
+ pci_disable_device(pdev);
+ }
+}
+
+static struct pci_driver cpc_driver = {
+ .name = "pc300",
+ .id_table = cpc_pci_dev_id,
+ .probe = cpc_init_one,
+ .remove = __devexit_p(cpc_remove_one),
+};
+
+static int __init cpc_init(void)
+{
+ show_version();
+ return pci_register_driver(&cpc_driver);
+}
+
+static void __exit cpc_cleanup_module(void)
+{
+ pci_unregister_driver(&cpc_driver);
+}
+
+module_init(cpc_init);
+module_exit(cpc_cleanup_module);
+
+MODULE_DESCRIPTION("Cyclades-PC300 cards driver");
+MODULE_AUTHOR( "Author: Ivan Passos <ivan@cyclades.com>\r\n"
+ "Maintainer: PC300 Maintainer <pc300@cyclades.com");
+MODULE_LICENSE("GPL");
+
diff --git a/drivers/staging/net/pc300_tty.c b/drivers/staging/net/pc300_tty.c
new file mode 100644
index 000000000000..4709f4228561
--- /dev/null
+++ b/drivers/staging/net/pc300_tty.c
@@ -0,0 +1,1079 @@
+/*
+ * pc300_tty.c Cyclades-PC300(tm) TTY Driver.
+ *
+ * Author: Regina Kodato <reginak@cyclades.com>
+ *
+ * Copyright: (c) 1999-2002 Cyclades Corp.
+ *
+ * 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.
+ *
+ * $Log: pc300_tty.c,v $
+ * Revision 3.7 2002/03/07 14:17:09 henrique
+ * License data fixed
+ *
+ * Revision 3.6 2001/12/10 12:29:42 regina
+ * Fix the MLPPP bug
+ *
+ * Revision 3.5 2001/10/31 11:20:05 regina
+ * automatic pppd starts
+ *
+ * Revision 3.4 2001/08/06 12:01:51 regina
+ * problem in DSR_DE bit
+ *
+ * Revision 3.3 2001/07/26 22:58:41 regina
+ * update EDA value
+ *
+ * Revision 3.2 2001/07/12 13:11:20 regina
+ * bug fix - DCD-OFF in pc300 tty driver
+ *
+ * DMA transmission bug fix
+ *
+ * Revision 3.1 2001/06/22 13:13:02 regina
+ * MLPPP implementation
+ *
+ */
+
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/errno.h>
+#include <linux/string.h>
+#include <linux/init.h>
+#include <linux/netdevice.h>
+#include <linux/spinlock.h>
+#include <linux/slab.h>
+#include <linux/if.h>
+#include <linux/skbuff.h>
+/* TTY includes */
+#include <linux/tty.h>
+#include <linux/tty_flip.h>
+#include <linux/serial.h>
+
+#include <asm/io.h>
+#include <asm/uaccess.h>
+
+#include "pc300.h"
+
+/* defines and macros */
+/* TTY Global definitions */
+#define CPC_TTY_NPORTS 8 /* maximum number of the sync tty connections */
+#define CPC_TTY_MAJOR CYCLADES_MAJOR
+#define CPC_TTY_MINOR_START 240 /* minor of the first PC300 interface */
+
+#define CPC_TTY_MAX_MTU 2000
+
+/* tty interface state */
+#define CPC_TTY_ST_IDLE 0
+#define CPC_TTY_ST_INIT 1 /* configured with MLPPP and up */
+#define CPC_TTY_ST_OPEN 2 /* opened by application */
+
+#define CPC_TTY_LOCK(card,flags)\
+ do {\
+ spin_lock_irqsave(&card->card_lock, flags); \
+ } while (0)
+
+#define CPC_TTY_UNLOCK(card,flags) \
+ do {\
+ spin_unlock_irqrestore(&card->card_lock, flags); \
+ } while (0)
+
+//#define CPC_TTY_DBG(format,a...) printk(format,##a)
+#define CPC_TTY_DBG(format,a...)
+
+/* data structures */
+typedef struct _st_cpc_rx_buf {
+ struct _st_cpc_rx_buf *next;
+ int size;
+ unsigned char data[1];
+} st_cpc_rx_buf;
+
+struct st_cpc_rx_list {
+ st_cpc_rx_buf *first;
+ st_cpc_rx_buf *last;
+};
+
+typedef struct _st_cpc_tty_area {
+ int state; /* state of the TTY interface */
+ int num_open;
+ unsigned int tty_minor; /* minor this interface */
+ volatile struct st_cpc_rx_list buf_rx; /* ptr. to reception buffer */
+ unsigned char* buf_tx; /* ptr. to transmission buffer */
+ pc300dev_t* pc300dev; /* ptr. to info struct in PC300 driver */
+ unsigned char name[20]; /* interf. name + "-tty" */
+ struct tty_struct *tty;
+ struct work_struct tty_tx_work; /* tx work - tx interrupt */
+ struct work_struct tty_rx_work; /* rx work - rx interrupt */
+ } st_cpc_tty_area;
+
+/* TTY data structures */
+static struct tty_driver serial_drv;
+
+/* local variables */
+static st_cpc_tty_area cpc_tty_area[CPC_TTY_NPORTS];
+
+static int cpc_tty_cnt = 0; /* number of intrfaces configured with MLPPP */
+static int cpc_tty_unreg_flag = 0;
+
+/* TTY functions prototype */
+static int cpc_tty_open(struct tty_struct *tty, struct file *flip);
+static void cpc_tty_close(struct tty_struct *tty, struct file *flip);
+static int cpc_tty_write(struct tty_struct *tty, const unsigned char *buf, int count);
+static int cpc_tty_write_room(struct tty_struct *tty);
+static int cpc_tty_chars_in_buffer(struct tty_struct *tty);
+static void cpc_tty_flush_buffer(struct tty_struct *tty);
+static void cpc_tty_hangup(struct tty_struct *tty);
+static void cpc_tty_rx_work(struct work_struct *work);
+static void cpc_tty_tx_work(struct work_struct *work);
+static int cpc_tty_send_to_card(pc300dev_t *dev,void *buf, int len);
+static void cpc_tty_trace(pc300dev_t *dev, char* buf, int len, char rxtx);
+static void cpc_tty_signal_off(pc300dev_t *pc300dev, unsigned char);
+static void cpc_tty_signal_on(pc300dev_t *pc300dev, unsigned char);
+
+static int pc300_tiocmset(struct tty_struct *, unsigned int, unsigned int);
+static int pc300_tiocmget(struct tty_struct *);
+
+/* functions called by PC300 driver */
+void cpc_tty_init(pc300dev_t *dev);
+void cpc_tty_unregister_service(pc300dev_t *pc300dev);
+void cpc_tty_receive(pc300dev_t *pc300dev);
+void cpc_tty_trigger_poll(pc300dev_t *pc300dev);
+
+/*
+ * PC300 TTY clear "signal"
+ */
+static void cpc_tty_signal_off(pc300dev_t *pc300dev, unsigned char signal)
+{
+ pc300ch_t *pc300chan = (pc300ch_t *)pc300dev->chan;
+ pc300_t *card = (pc300_t *) pc300chan->card;
+ int ch = pc300chan->channel;
+ unsigned long flags;
+
+ CPC_TTY_DBG("%s-tty: Clear signal %x\n",
+ pc300dev->dev->name, signal);
+ CPC_TTY_LOCK(card, flags);
+ cpc_writeb(card->hw.scabase + M_REG(CTL,ch),
+ cpc_readb(card->hw.scabase+M_REG(CTL,ch))& signal);
+ CPC_TTY_UNLOCK(card,flags);
+}
+
+/*
+ * PC300 TTY set "signal" to ON
+ */
+static void cpc_tty_signal_on(pc300dev_t *pc300dev, unsigned char signal)
+{
+ pc300ch_t *pc300chan = (pc300ch_t *)pc300dev->chan;
+ pc300_t *card = (pc300_t *) pc300chan->card;
+ int ch = pc300chan->channel;
+ unsigned long flags;
+
+ CPC_TTY_DBG("%s-tty: Set signal %x\n",
+ pc300dev->dev->name, signal);
+ CPC_TTY_LOCK(card, flags);
+ cpc_writeb(card->hw.scabase + M_REG(CTL,ch),
+ cpc_readb(card->hw.scabase+M_REG(CTL,ch))& ~signal);
+ CPC_TTY_UNLOCK(card,flags);
+}
+
+
+static const struct tty_operations pc300_ops = {
+ .open = cpc_tty_open,
+ .close = cpc_tty_close,
+ .write = cpc_tty_write,
+ .write_room = cpc_tty_write_room,
+ .chars_in_buffer = cpc_tty_chars_in_buffer,
+ .tiocmset = pc300_tiocmset,
+ .tiocmget = pc300_tiocmget,
+ .flush_buffer = cpc_tty_flush_buffer,
+ .hangup = cpc_tty_hangup,
+};
+
+
+/*
+ * PC300 TTY initialization routine
+ *
+ * This routine is called by the PC300 driver during board configuration
+ * (ioctl=SIOCSP300CONF). At this point the adapter is completely
+ * initialized.
+ * o verify kernel version (only 2.4.x)
+ * o register TTY driver
+ * o init cpc_tty_area struct
+ */
+void cpc_tty_init(pc300dev_t *pc300dev)
+{
+ unsigned long port;
+ int aux;
+ st_cpc_tty_area * cpc_tty;
+
+ /* hdlcX - X=interface number */
+ port = pc300dev->dev->name[4] - '0';
+ if (port >= CPC_TTY_NPORTS) {
+ printk("%s-tty: invalid interface selected (0-%i): %li",
+ pc300dev->dev->name,
+ CPC_TTY_NPORTS-1,port);
+ return;
+ }
+
+ if (cpc_tty_cnt == 0) { /* first TTY connection -> register driver */
+ CPC_TTY_DBG("%s-tty: driver init, major:%i, minor range:%i=%i\n",
+ pc300dev->dev->name,
+ CPC_TTY_MAJOR, CPC_TTY_MINOR_START,
+ CPC_TTY_MINOR_START+CPC_TTY_NPORTS);
+ /* initialize tty driver struct */
+ memset(&serial_drv,0,sizeof(struct tty_driver));
+ serial_drv.magic = TTY_DRIVER_MAGIC;
+ serial_drv.owner = THIS_MODULE;
+ serial_drv.driver_name = "pc300_tty";
+ serial_drv.name = "ttyCP";
+ serial_drv.major = CPC_TTY_MAJOR;
+ serial_drv.minor_start = CPC_TTY_MINOR_START;
+ serial_drv.num = CPC_TTY_NPORTS;
+ serial_drv.type = TTY_DRIVER_TYPE_SERIAL;
+ serial_drv.subtype = SERIAL_TYPE_NORMAL;
+
+ serial_drv.init_termios = tty_std_termios;
+ serial_drv.init_termios.c_cflag = B9600|CS8|CREAD|HUPCL|CLOCAL;
+ serial_drv.flags = TTY_DRIVER_REAL_RAW;
+
+ /* interface routines from the upper tty layer to the tty driver */
+ tty_set_operations(&serial_drv, &pc300_ops);
+
+ /* register the TTY driver */
+ if (tty_register_driver(&serial_drv)) {
+ printk("%s-tty: Failed to register serial driver! ",
+ pc300dev->dev->name);
+ return;
+ }
+
+ memset((void *)cpc_tty_area, 0,
+ sizeof(st_cpc_tty_area) * CPC_TTY_NPORTS);
+ }
+
+ cpc_tty = &cpc_tty_area[port];
+
+ if (cpc_tty->state != CPC_TTY_ST_IDLE) {
+ CPC_TTY_DBG("%s-tty: TTY port %i, already in use.\n",
+ pc300dev->dev->name, port);
+ return;
+ }
+
+ cpc_tty_cnt++;
+ cpc_tty->state = CPC_TTY_ST_INIT;
+ cpc_tty->num_open= 0;
+ cpc_tty->tty_minor = port + CPC_TTY_MINOR_START;
+ cpc_tty->pc300dev = pc300dev;
+
+ INIT_WORK(&cpc_tty->tty_tx_work, cpc_tty_tx_work);
+ INIT_WORK(&cpc_tty->tty_rx_work, cpc_tty_rx_work);
+
+ cpc_tty->buf_rx.first = cpc_tty->buf_rx.last = NULL;
+
+ pc300dev->cpc_tty = (void *)cpc_tty;
+
+ aux = strlen(pc300dev->dev->name);
+ memcpy(cpc_tty->name, pc300dev->dev->name, aux);
+ memcpy(&cpc_tty->name[aux], "-tty", 5);
+
+ cpc_open(pc300dev->dev);
+ cpc_tty_signal_off(pc300dev, CTL_DTR);
+
+ CPC_TTY_DBG("%s: Initializing TTY Sync Driver, tty major#%d minor#%i\n",
+ cpc_tty->name,CPC_TTY_MAJOR,cpc_tty->tty_minor);
+ return;
+}
+
+/*
+ * PC300 TTY OPEN routine
+ *
+ * This routine is called by the tty driver to open the interface
+ * o verify minor
+ * o allocate buffer to Rx and Tx
+ */
+static int cpc_tty_open(struct tty_struct *tty, struct file *flip)
+{
+ int port ;
+ st_cpc_tty_area *cpc_tty;
+
+ if (!tty) {
+ return -ENODEV;
+ }
+
+ port = tty->index;
+
+ if ((port < 0) || (port >= CPC_TTY_NPORTS)){
+ CPC_TTY_DBG("pc300_tty: open invalid port %d\n", port);
+ return -ENODEV;
+ }
+
+ cpc_tty = &cpc_tty_area[port];
+
+ if (cpc_tty->state == CPC_TTY_ST_IDLE){
+ CPC_TTY_DBG("%s: open - invalid interface, port=%d\n",
+ cpc_tty->name, tty->index);
+ return -ENODEV;
+ }
+
+ if (cpc_tty->num_open == 0) { /* first open of this tty */
+ if (!cpc_tty_area[port].buf_tx){
+ cpc_tty_area[port].buf_tx = kmalloc(CPC_TTY_MAX_MTU,GFP_KERNEL);
+ if (!cpc_tty_area[port].buf_tx) {
+ CPC_TTY_DBG("%s: error in memory allocation\n",cpc_tty->name);
+ return -ENOMEM;
+ }
+ }
+
+ if (cpc_tty_area[port].buf_rx.first) {
+ unsigned char * aux;
+ while (cpc_tty_area[port].buf_rx.first) {
+ aux = (unsigned char *)cpc_tty_area[port].buf_rx.first;
+ cpc_tty_area[port].buf_rx.first = cpc_tty_area[port].buf_rx.first->next;
+ kfree(aux);
+ }
+ cpc_tty_area[port].buf_rx.first = NULL;
+ cpc_tty_area[port].buf_rx.last = NULL;
+ }
+
+ cpc_tty_area[port].state = CPC_TTY_ST_OPEN;
+ cpc_tty_area[port].tty = tty;
+ tty->driver_data = &cpc_tty_area[port];
+
+ cpc_tty_signal_on(cpc_tty->pc300dev, CTL_DTR);
+ }
+
+ cpc_tty->num_open++;
+
+ CPC_TTY_DBG("%s: opening TTY driver\n", cpc_tty->name);
+
+ /* avisar driver PC300 */
+ return 0;
+}
+
+/*
+ * PC300 TTY CLOSE routine
+ *
+ * This routine is called by the tty driver to close the interface
+ * o call close channel in PC300 driver (cpc_closech)
+ * o free Rx and Tx buffers
+ */
+
+static void cpc_tty_close(struct tty_struct *tty, struct file *flip)
+{
+ st_cpc_tty_area *cpc_tty;
+ unsigned long flags;
+ int res;
+
+ if (!tty || !tty->driver_data ) {
+ CPC_TTY_DBG("hdlx-tty: no TTY in close\n");
+ return;
+ }
+
+ cpc_tty = (st_cpc_tty_area *) tty->driver_data;
+
+ if ((cpc_tty->tty != tty)|| (cpc_tty->state != CPC_TTY_ST_OPEN)) {
+ CPC_TTY_DBG("%s: TTY is not opened\n",cpc_tty->name);
+ return;
+ }
+
+ if (!cpc_tty->num_open) {
+ CPC_TTY_DBG("%s: TTY is closed\n",cpc_tty->name);
+ return;
+ }
+
+ if (--cpc_tty->num_open > 0) {
+ CPC_TTY_DBG("%s: TTY closed\n",cpc_tty->name);
+ return;
+ }
+
+ cpc_tty_signal_off(cpc_tty->pc300dev, CTL_DTR);
+
+ CPC_TTY_LOCK(cpc_tty->pc300dev->chan->card, flags); /* lock irq */
+ cpc_tty->tty = NULL;
+ cpc_tty->state = CPC_TTY_ST_INIT;
+ CPC_TTY_UNLOCK(cpc_tty->pc300dev->chan->card, flags); /* unlock irq */
+
+ if (cpc_tty->buf_rx.first) {
+ unsigned char * aux;
+ while (cpc_tty->buf_rx.first) {
+ aux = (unsigned char *)cpc_tty->buf_rx.first;
+ cpc_tty->buf_rx.first = cpc_tty->buf_rx.first->next;
+ kfree(aux);
+ }
+ cpc_tty->buf_rx.first = NULL;
+ cpc_tty->buf_rx.last = NULL;
+ }
+
+ kfree(cpc_tty->buf_tx);
+ cpc_tty->buf_tx = NULL;
+
+ CPC_TTY_DBG("%s: TTY closed\n",cpc_tty->name);
+
+ if (!serial_drv.refcount && cpc_tty_unreg_flag) {
+ cpc_tty_unreg_flag = 0;
+ CPC_TTY_DBG("%s: unregister the tty driver\n", cpc_tty->name);
+ if ((res=tty_unregister_driver(&serial_drv))) {
+ CPC_TTY_DBG("%s: ERROR ->unregister the tty driver error=%d\n",
+ cpc_tty->name,res);
+ }
+ }
+ return;
+}
+
+/*
+ * PC300 TTY WRITE routine
+ *
+ * This routine is called by the tty driver to write a series of characters
+ * to the tty device. The characters may come from user or kernel space.
+ * o verify the DCD signal
+ * o send characters to board and start the transmission
+ */
+static int cpc_tty_write(struct tty_struct *tty, const unsigned char *buf, int count)
+{
+ st_cpc_tty_area *cpc_tty;
+ pc300ch_t *pc300chan;
+ pc300_t *card;
+ int ch;
+ unsigned long flags;
+ struct net_device_stats *stats;
+
+ if (!tty || !tty->driver_data ) {
+ CPC_TTY_DBG("hdlcX-tty: no TTY in write\n");
+ return -ENODEV;
+ }
+
+ cpc_tty = (st_cpc_tty_area *) tty->driver_data;
+
+ if ((cpc_tty->tty != tty) || (cpc_tty->state != CPC_TTY_ST_OPEN)) {
+ CPC_TTY_DBG("%s: TTY is not opened\n", cpc_tty->name);
+ return -ENODEV;
+ }
+
+ if (count > CPC_TTY_MAX_MTU) {
+ CPC_TTY_DBG("%s: count is invalid\n",cpc_tty->name);
+ return -EINVAL; /* frame too big */
+ }
+
+ CPC_TTY_DBG("%s: cpc_tty_write data len=%i\n",cpc_tty->name,count);
+
+ pc300chan = (pc300ch_t *)((pc300dev_t*)cpc_tty->pc300dev)->chan;
+ stats = &cpc_tty->pc300dev->dev->stats;
+ card = (pc300_t *) pc300chan->card;
+ ch = pc300chan->channel;
+
+ /* verify DCD signal*/
+ if (cpc_readb(card->hw.scabase + M_REG(ST3,ch)) & ST3_DCD) {
+ /* DCD is OFF */
+ CPC_TTY_DBG("%s : DCD is OFF\n", cpc_tty->name);
+ stats->tx_errors++;
+ stats->tx_carrier_errors++;
+ CPC_TTY_LOCK(card, flags);
+ cpc_writeb(card->hw.scabase + M_REG(CMD, ch), CMD_TX_BUF_CLR);
+
+ if (card->hw.type == PC300_TE) {
+ cpc_writeb(card->hw.falcbase + card->hw.cpld_reg2,
+ cpc_readb(card->hw.falcbase + card->hw.cpld_reg2) &
+ ~(CPLD_REG2_FALC_LED1 << (2 *ch)));
+ }
+
+ CPC_TTY_UNLOCK(card, flags);
+
+ return -EINVAL;
+ }
+
+ if (cpc_tty_send_to_card(cpc_tty->pc300dev, (void*)buf, count)) {
+ /* failed to send */
+ CPC_TTY_DBG("%s: trasmition error\n", cpc_tty->name);
+ return 0;
+ }
+ return count;
+}
+
+/*
+ * PC300 TTY Write Room routine
+ *
+ * This routine returns the numbers of characteres the tty driver will accept
+ * for queuing to be written.
+ * o return MTU
+ */
+static int cpc_tty_write_room(struct tty_struct *tty)
+{
+ st_cpc_tty_area *cpc_tty;
+
+ if (!tty || !tty->driver_data ) {
+ CPC_TTY_DBG("hdlcX-tty: no TTY to write room\n");
+ return -ENODEV;
+ }
+
+ cpc_tty = (st_cpc_tty_area *) tty->driver_data;
+
+ if ((cpc_tty->tty != tty) || (cpc_tty->state != CPC_TTY_ST_OPEN)) {
+ CPC_TTY_DBG("%s: TTY is not opened\n",cpc_tty->name);
+ return -ENODEV;
+ }
+
+ CPC_TTY_DBG("%s: write room\n",cpc_tty->name);
+
+ return CPC_TTY_MAX_MTU;
+}
+
+/*
+ * PC300 TTY chars in buffer routine
+ *
+ * This routine returns the chars number in the transmission buffer
+ * o returns 0
+ */
+static int cpc_tty_chars_in_buffer(struct tty_struct *tty)
+{
+ st_cpc_tty_area *cpc_tty;
+
+ if (!tty || !tty->driver_data ) {
+ CPC_TTY_DBG("hdlcX-tty: no TTY to chars in buffer\n");
+ return -ENODEV;
+ }
+
+ cpc_tty = (st_cpc_tty_area *) tty->driver_data;
+
+ if ((cpc_tty->tty != tty) || (cpc_tty->state != CPC_TTY_ST_OPEN)) {
+ CPC_TTY_DBG("%s: TTY is not opened\n",cpc_tty->name);
+ return -ENODEV;
+ }
+
+ return 0;
+}
+
+static int pc300_tiocmset(struct tty_struct *tty,
+ unsigned int set, unsigned int clear)
+{
+ st_cpc_tty_area *cpc_tty;
+
+ CPC_TTY_DBG("%s: set:%x clear:%x\n", __func__, set, clear);
+
+ if (!tty || !tty->driver_data ) {
+ CPC_TTY_DBG("hdlcX-tty: no TTY to chars in buffer\n");
+ return -ENODEV;
+ }
+
+ cpc_tty = (st_cpc_tty_area *) tty->driver_data;
+
+ if (set & TIOCM_RTS)
+ cpc_tty_signal_on(cpc_tty->pc300dev, CTL_RTS);
+ if (set & TIOCM_DTR)
+ cpc_tty_signal_on(cpc_tty->pc300dev, CTL_DTR);
+
+ if (clear & TIOCM_RTS)
+ cpc_tty_signal_off(cpc_tty->pc300dev, CTL_RTS);
+ if (clear & TIOCM_DTR)
+ cpc_tty_signal_off(cpc_tty->pc300dev, CTL_DTR);
+
+ return 0;
+}
+
+static int pc300_tiocmget(struct tty_struct *tty)
+{
+ unsigned int result;
+ unsigned char status;
+ unsigned long flags;
+ st_cpc_tty_area *cpc_tty = (st_cpc_tty_area *) tty->driver_data;
+ pc300dev_t *pc300dev = cpc_tty->pc300dev;
+ pc300ch_t *pc300chan = (pc300ch_t *)pc300dev->chan;
+ pc300_t *card = (pc300_t *) pc300chan->card;
+ int ch = pc300chan->channel;
+
+ cpc_tty = (st_cpc_tty_area *) tty->driver_data;
+
+ CPC_TTY_DBG("%s-tty: tiocmget\n",
+ ((struct net_device*)(pc300dev->hdlc))->name);
+
+ CPC_TTY_LOCK(card, flags);
+ status = cpc_readb(card->hw.scabase+M_REG(CTL,ch));
+ CPC_TTY_UNLOCK(card,flags);
+
+ result = ((status & CTL_DTR) ? TIOCM_DTR : 0) |
+ ((status & CTL_RTS) ? TIOCM_RTS : 0);
+
+ return result;
+}
+
+/*
+ * PC300 TTY Flush Buffer routine
+ *
+ * This routine resets the transmission buffer
+ */
+static void cpc_tty_flush_buffer(struct tty_struct *tty)
+{
+ st_cpc_tty_area *cpc_tty;
+
+ if (!tty || !tty->driver_data ) {
+ CPC_TTY_DBG("hdlcX-tty: no TTY to flush buffer\n");
+ return;
+ }
+
+ cpc_tty = (st_cpc_tty_area *) tty->driver_data;
+
+ if ((cpc_tty->tty != tty) || (cpc_tty->state != CPC_TTY_ST_OPEN)) {
+ CPC_TTY_DBG("%s: TTY is not opened\n",cpc_tty->name);
+ return;
+ }
+
+ CPC_TTY_DBG("%s: call wake_up_interruptible\n",cpc_tty->name);
+
+ tty_wakeup(tty);
+ return;
+}
+
+/*
+ * PC300 TTY Hangup routine
+ *
+ * This routine is called by the tty driver to hangup the interface
+ * o clear DTR signal
+ */
+
+static void cpc_tty_hangup(struct tty_struct *tty)
+{
+ st_cpc_tty_area *cpc_tty;
+ int res;
+
+ if (!tty || !tty->driver_data ) {
+ CPC_TTY_DBG("hdlcX-tty: no TTY to hangup\n");
+ return ;
+ }
+
+ cpc_tty = (st_cpc_tty_area *) tty->driver_data;
+
+ if ((cpc_tty->tty != tty) || (cpc_tty->state != CPC_TTY_ST_OPEN)) {
+ CPC_TTY_DBG("%s: TTY is not opened\n",cpc_tty->name);
+ return ;
+ }
+ if (!serial_drv.refcount && cpc_tty_unreg_flag) {
+ cpc_tty_unreg_flag = 0;
+ CPC_TTY_DBG("%s: unregister the tty driver\n", cpc_tty->name);
+ if ((res=tty_unregister_driver(&serial_drv))) {
+ CPC_TTY_DBG("%s: ERROR ->unregister the tty driver error=%d\n",
+ cpc_tty->name,res);
+ }
+ }
+ cpc_tty_signal_off(cpc_tty->pc300dev, CTL_DTR);
+}
+
+/*
+ * PC300 TTY RX work routine
+ * This routine treats RX work
+ * o verify read buffer
+ * o call the line disc. read
+ * o free memory
+ */
+static void cpc_tty_rx_work(struct work_struct *work)
+{
+ st_cpc_tty_area *cpc_tty;
+ unsigned long port;
+ int i, j;
+ volatile st_cpc_rx_buf *buf;
+ char flags=0,flg_rx=1;
+ struct tty_ldisc *ld;
+
+ if (cpc_tty_cnt == 0) return;
+
+ for (i=0; (i < 4) && flg_rx ; i++) {
+ flg_rx = 0;
+
+ cpc_tty = container_of(work, st_cpc_tty_area, tty_rx_work);
+ port = cpc_tty - cpc_tty_area;
+
+ for (j=0; j < CPC_TTY_NPORTS; j++) {
+ cpc_tty = &cpc_tty_area[port];
+
+ if ((buf=cpc_tty->buf_rx.first) != NULL) {
+ if (cpc_tty->tty) {
+ ld = tty_ldisc_ref(cpc_tty->tty);
+ if (ld) {
+ if (ld->ops->receive_buf) {
+ CPC_TTY_DBG("%s: call line disc. receive_buf\n",cpc_tty->name);
+ ld->ops->receive_buf(cpc_tty->tty, (char *)(buf->data), &flags, buf->size);
+ }
+ tty_ldisc_deref(ld);
+ }
+ }
+ cpc_tty->buf_rx.first = cpc_tty->buf_rx.first->next;
+ kfree((void *)buf);
+ buf = cpc_tty->buf_rx.first;
+ flg_rx = 1;
+ }
+ if (++port == CPC_TTY_NPORTS) port = 0;
+ }
+ }
+}
+
+/*
+ * PC300 TTY RX work routine
+ *
+ * This routine treats RX interrupt.
+ * o read all frames in card
+ * o verify the frame size
+ * o read the frame in rx buffer
+ */
+static void cpc_tty_rx_disc_frame(pc300ch_t *pc300chan)
+{
+ volatile pcsca_bd_t __iomem * ptdescr;
+ volatile unsigned char status;
+ pc300_t *card = (pc300_t *)pc300chan->card;
+ int ch = pc300chan->channel;
+
+ /* dma buf read */
+ ptdescr = (pcsca_bd_t __iomem *)(card->hw.rambase +
+ RX_BD_ADDR(ch, pc300chan->rx_first_bd));
+ while (pc300chan->rx_first_bd != pc300chan->rx_last_bd) {
+ status = cpc_readb(&ptdescr->status);
+ cpc_writeb(&ptdescr->status, 0);
+ cpc_writeb(&ptdescr->len, 0);
+ pc300chan->rx_first_bd = (pc300chan->rx_first_bd + 1) &
+ (N_DMA_RX_BUF - 1);
+ if (status & DST_EOM) {
+ break; /* end of message */
+ }
+ ptdescr = (pcsca_bd_t __iomem *)(card->hw.rambase + cpc_readl(&ptdescr->next));
+ }
+}
+
+void cpc_tty_receive(pc300dev_t *pc300dev)
+{
+ st_cpc_tty_area *cpc_tty;
+ pc300ch_t *pc300chan = (pc300ch_t *)pc300dev->chan;
+ pc300_t *card = (pc300_t *)pc300chan->card;
+ int ch = pc300chan->channel;
+ volatile pcsca_bd_t __iomem * ptdescr;
+ struct net_device_stats *stats = &pc300dev->dev->stats;
+ int rx_len, rx_aux;
+ volatile unsigned char status;
+ unsigned short first_bd = pc300chan->rx_first_bd;
+ st_cpc_rx_buf *new = NULL;
+ unsigned char dsr_rx;
+
+ if (pc300dev->cpc_tty == NULL) {
+ return;
+ }
+
+ dsr_rx = cpc_readb(card->hw.scabase + DSR_RX(ch));
+
+ cpc_tty = pc300dev->cpc_tty;
+
+ while (1) {
+ rx_len = 0;
+ ptdescr = (pcsca_bd_t __iomem *)(card->hw.rambase + RX_BD_ADDR(ch, first_bd));
+ while ((status = cpc_readb(&ptdescr->status)) & DST_OSB) {
+ rx_len += cpc_readw(&ptdescr->len);
+ first_bd = (first_bd + 1) & (N_DMA_RX_BUF - 1);
+ if (status & DST_EOM) {
+ break;
+ }
+ ptdescr = (pcsca_bd_t __iomem *)(card->hw.rambase+cpc_readl(&ptdescr->next));
+ }
+
+ if (!rx_len) {
+ if (dsr_rx & DSR_BOF) {
+ /* update EDA */
+ cpc_writel(card->hw.scabase + DRX_REG(EDAL, ch),
+ RX_BD_ADDR(ch, pc300chan->rx_last_bd));
+ }
+ kfree(new);
+ return;
+ }
+
+ if (rx_len > CPC_TTY_MAX_MTU) {
+ /* Free RX descriptors */
+ CPC_TTY_DBG("%s: frame size is invalid.\n",cpc_tty->name);
+ stats->rx_errors++;
+ stats->rx_frame_errors++;
+ cpc_tty_rx_disc_frame(pc300chan);
+ continue;
+ }
+
+ new = kmalloc(rx_len + sizeof(st_cpc_rx_buf), GFP_ATOMIC);
+ if (!new) {
+ cpc_tty_rx_disc_frame(pc300chan);
+ continue;
+ }
+
+ /* dma buf read */
+ ptdescr = (pcsca_bd_t __iomem *)(card->hw.rambase +
+ RX_BD_ADDR(ch, pc300chan->rx_first_bd));
+
+ rx_len = 0; /* counter frame size */
+
+ while ((status = cpc_readb(&ptdescr->status)) & DST_OSB) {
+ rx_aux = cpc_readw(&ptdescr->len);
+ if ((status & (DST_OVR | DST_CRC | DST_RBIT | DST_SHRT | DST_ABT))
+ || (rx_aux > BD_DEF_LEN)) {
+ CPC_TTY_DBG("%s: reception error\n", cpc_tty->name);
+ stats->rx_errors++;
+ if (status & DST_OVR) {
+ stats->rx_fifo_errors++;
+ }
+ if (status & DST_CRC) {
+ stats->rx_crc_errors++;
+ }
+ if ((status & (DST_RBIT | DST_SHRT | DST_ABT)) ||
+ (rx_aux > BD_DEF_LEN)) {
+ stats->rx_frame_errors++;
+ }
+ /* discard remainig descriptors used by the bad frame */
+ CPC_TTY_DBG("%s: reception error - discard descriptors",
+ cpc_tty->name);
+ cpc_tty_rx_disc_frame(pc300chan);
+ rx_len = 0;
+ kfree(new);
+ new = NULL;
+ break; /* read next frame - while(1) */
+ }
+
+ if (cpc_tty->state != CPC_TTY_ST_OPEN) {
+ /* Free RX descriptors */
+ cpc_tty_rx_disc_frame(pc300chan);
+ stats->rx_dropped++;
+ rx_len = 0;
+ kfree(new);
+ new = NULL;
+ break; /* read next frame - while(1) */
+ }
+
+ /* read the segment of the frame */
+ if (rx_aux != 0) {
+ memcpy_fromio((new->data + rx_len),
+ (void __iomem *)(card->hw.rambase +
+ cpc_readl(&ptdescr->ptbuf)), rx_aux);
+ rx_len += rx_aux;
+ }
+ cpc_writeb(&ptdescr->status,0);
+ cpc_writeb(&ptdescr->len, 0);
+ pc300chan->rx_first_bd = (pc300chan->rx_first_bd + 1) &
+ (N_DMA_RX_BUF -1);
+ if (status & DST_EOM)break;
+
+ ptdescr = (pcsca_bd_t __iomem *) (card->hw.rambase +
+ cpc_readl(&ptdescr->next));
+ }
+ /* update pointer */
+ pc300chan->rx_last_bd = (pc300chan->rx_first_bd - 1) &
+ (N_DMA_RX_BUF - 1) ;
+ if (!(dsr_rx & DSR_BOF)) {
+ /* update EDA */
+ cpc_writel(card->hw.scabase + DRX_REG(EDAL, ch),
+ RX_BD_ADDR(ch, pc300chan->rx_last_bd));
+ }
+ if (rx_len != 0) {
+ stats->rx_bytes += rx_len;
+
+ if (pc300dev->trace_on) {
+ cpc_tty_trace(pc300dev, new->data,rx_len, 'R');
+ }
+ new->size = rx_len;
+ new->next = NULL;
+ if (cpc_tty->buf_rx.first == NULL) {
+ cpc_tty->buf_rx.first = new;
+ cpc_tty->buf_rx.last = new;
+ } else {
+ cpc_tty->buf_rx.last->next = new;
+ cpc_tty->buf_rx.last = new;
+ }
+ schedule_work(&(cpc_tty->tty_rx_work));
+ stats->rx_packets++;
+ }
+ }
+}
+
+/*
+ * PC300 TTY TX work routine
+ *
+ * This routine treats TX interrupt.
+ * o if need call line discipline wakeup
+ * o call wake_up_interruptible
+ */
+static void cpc_tty_tx_work(struct work_struct *work)
+{
+ st_cpc_tty_area *cpc_tty =
+ container_of(work, st_cpc_tty_area, tty_tx_work);
+ struct tty_struct *tty;
+
+ CPC_TTY_DBG("%s: cpc_tty_tx_work init\n",cpc_tty->name);
+
+ if ((tty = cpc_tty->tty) == NULL) {
+ CPC_TTY_DBG("%s: the interface is not opened\n",cpc_tty->name);
+ return;
+ }
+ tty_wakeup(tty);
+}
+
+/*
+ * PC300 TTY send to card routine
+ *
+ * This routine send data to card.
+ * o clear descriptors
+ * o write data to DMA buffers
+ * o start the transmission
+ */
+static int cpc_tty_send_to_card(pc300dev_t *dev,void* buf, int len)
+{
+ pc300ch_t *chan = (pc300ch_t *)dev->chan;
+ pc300_t *card = (pc300_t *)chan->card;
+ int ch = chan->channel;
+ struct net_device_stats *stats = &dev->dev->stats;
+ unsigned long flags;
+ volatile pcsca_bd_t __iomem *ptdescr;
+ int i, nchar;
+ int tosend = len;
+ int nbuf = ((len - 1)/BD_DEF_LEN) + 1;
+ unsigned char *pdata=buf;
+
+ CPC_TTY_DBG("%s:cpc_tty_send_to_cars len=%i",
+ (st_cpc_tty_area *)dev->cpc_tty->name,len);
+
+ if (nbuf >= card->chan[ch].nfree_tx_bd) {
+ return 1;
+ }
+
+ /* write buffer to DMA buffers */
+ CPC_TTY_DBG("%s: call dma_buf_write\n",
+ (st_cpc_tty_area *)dev->cpc_tty->name);
+ for (i = 0 ; i < nbuf ; i++) {
+ ptdescr = (pcsca_bd_t __iomem *)(card->hw.rambase +
+ TX_BD_ADDR(ch, card->chan[ch].tx_next_bd));
+ nchar = (BD_DEF_LEN > tosend) ? tosend : BD_DEF_LEN;
+ if (cpc_readb(&ptdescr->status) & DST_OSB) {
+ memcpy_toio((void __iomem *)(card->hw.rambase +
+ cpc_readl(&ptdescr->ptbuf)),
+ &pdata[len - tosend],
+ nchar);
+ card->chan[ch].nfree_tx_bd--;
+ if ((i + 1) == nbuf) {
+ /* This must be the last BD to be used */
+ cpc_writeb(&ptdescr->status, DST_EOM);
+ } else {
+ cpc_writeb(&ptdescr->status, 0);
+ }
+ cpc_writew(&ptdescr->len, nchar);
+ } else {
+ CPC_TTY_DBG("%s: error in dma_buf_write\n",
+ (st_cpc_tty_area *)dev->cpc_tty->name);
+ stats->tx_dropped++;
+ return 1;
+ }
+ tosend -= nchar;
+ card->chan[ch].tx_next_bd =
+ (card->chan[ch].tx_next_bd + 1) & (N_DMA_TX_BUF - 1);
+ }
+
+ if (dev->trace_on) {
+ cpc_tty_trace(dev, buf, len,'T');
+ }
+
+ /* start transmission */
+ CPC_TTY_DBG("%s: start transmission\n",
+ (st_cpc_tty_area *)dev->cpc_tty->name);
+
+ CPC_TTY_LOCK(card, flags);
+ cpc_writeb(card->hw.scabase + DTX_REG(EDAL, ch),
+ TX_BD_ADDR(ch, chan->tx_next_bd));
+ cpc_writeb(card->hw.scabase + M_REG(CMD, ch), CMD_TX_ENA);
+ cpc_writeb(card->hw.scabase + DSR_TX(ch), DSR_DE);
+
+ if (card->hw.type == PC300_TE) {
+ cpc_writeb(card->hw.falcbase + card->hw.cpld_reg2,
+ cpc_readb(card->hw.falcbase + card->hw.cpld_reg2) |
+ (CPLD_REG2_FALC_LED1 << (2 * ch)));
+ }
+ CPC_TTY_UNLOCK(card, flags);
+ return 0;
+}
+
+/*
+ * PC300 TTY trace routine
+ *
+ * This routine send trace of connection to application.
+ * o clear descriptors
+ * o write data to DMA buffers
+ * o start the transmission
+ */
+
+static void cpc_tty_trace(pc300dev_t *dev, char* buf, int len, char rxtx)
+{
+ struct sk_buff *skb;
+
+ if ((skb = dev_alloc_skb(10 + len)) == NULL) {
+ /* out of memory */
+ CPC_TTY_DBG("%s: tty_trace - out of memory\n", dev->dev->name);
+ return;
+ }
+
+ skb_put (skb, 10 + len);
+ skb->dev = dev->dev;
+ skb->protocol = htons(ETH_P_CUST);
+ skb_reset_mac_header(skb);
+ skb->pkt_type = PACKET_HOST;
+ skb->len = 10 + len;
+
+ skb_copy_to_linear_data(skb, dev->dev->name, 5);
+ skb->data[5] = '[';
+ skb->data[6] = rxtx;
+ skb->data[7] = ']';
+ skb->data[8] = ':';
+ skb->data[9] = ' ';
+ skb_copy_to_linear_data_offset(skb, 10, buf, len);
+ netif_rx(skb);
+}
+
+/*
+ * PC300 TTY unregister service routine
+ *
+ * This routine unregister one interface.
+ */
+void cpc_tty_unregister_service(pc300dev_t *pc300dev)
+{
+ st_cpc_tty_area *cpc_tty;
+ ulong flags;
+ int res;
+
+ if ((cpc_tty= (st_cpc_tty_area *) pc300dev->cpc_tty) == NULL) {
+ CPC_TTY_DBG("%s: interface is not TTY\n", pc300dev->dev->name);
+ return;
+ }
+ CPC_TTY_DBG("%s: cpc_tty_unregister_service", cpc_tty->name);
+
+ if (cpc_tty->pc300dev != pc300dev) {
+ CPC_TTY_DBG("%s: invalid tty ptr=%s\n",
+ pc300dev->dev->name, cpc_tty->name);
+ return;
+ }
+
+ if (--cpc_tty_cnt == 0) {
+ if (serial_drv.refcount) {
+ CPC_TTY_DBG("%s: unregister is not possible, refcount=%d",
+ cpc_tty->name, serial_drv.refcount);
+ cpc_tty_cnt++;
+ cpc_tty_unreg_flag = 1;
+ return;
+ } else {
+ CPC_TTY_DBG("%s: unregister the tty driver\n", cpc_tty->name);
+ if ((res=tty_unregister_driver(&serial_drv))) {
+ CPC_TTY_DBG("%s: ERROR ->unregister the tty driver error=%d\n",
+ cpc_tty->name,res);
+ }
+ }
+ }
+ CPC_TTY_LOCK(pc300dev->chan->card,flags);
+ cpc_tty->tty = NULL;
+ CPC_TTY_UNLOCK(pc300dev->chan->card, flags);
+ cpc_tty->tty_minor = 0;
+ cpc_tty->state = CPC_TTY_ST_IDLE;
+}
+
+/*
+ * PC300 TTY trigger poll routine
+ * This routine is called by pc300driver to treats Tx interrupt.
+ */
+void cpc_tty_trigger_poll(pc300dev_t *pc300dev)
+{
+ st_cpc_tty_area *cpc_tty = (st_cpc_tty_area *)pc300dev->cpc_tty;
+ if (!cpc_tty) {
+ return;
+ }
+ schedule_work(&(cpc_tty->tty_tx_work));
+}
diff --git a/drivers/staging/nvec/Kconfig b/drivers/staging/nvec/Kconfig
index 731301f524a6..43048e9ba0d4 100644
--- a/drivers/staging/nvec/Kconfig
+++ b/drivers/staging/nvec/Kconfig
@@ -26,8 +26,9 @@ config NVEC_POWER
Say Y to enable support for battery and charger interface for
nVidia compliant embedded controllers.
-config NVEC_LEDS
- bool "NVEC leds"
- depends on MFD_NVEC && LEDS_CLASS
+config NVEC_PAZ00
+ bool "Support for OEM specific functions on Compal PAZ00 based devices"
+ depends on MFD_NVEC && LEDS_CLASS && MACH_PAZ00
help
- Say Y to enable yellow side leds on AC100 or other nVidia tegra nvec leds
+ Say Y to enable control of the yellow side leds on Compal PAZ00 based
+ devices, e.g. Toshbia AC100 and Dynabooks AZ netbooks.
diff --git a/drivers/staging/nvec/Makefile b/drivers/staging/nvec/Makefile
index b844d604e3ac..0db0e1f43337 100644
--- a/drivers/staging/nvec/Makefile
+++ b/drivers/staging/nvec/Makefile
@@ -2,4 +2,4 @@ obj-$(CONFIG_SERIO_NVEC_PS2) += nvec_ps2.o
obj-$(CONFIG_MFD_NVEC) += nvec.o
obj-$(CONFIG_NVEC_POWER) += nvec_power.o
obj-$(CONFIG_KEYBOARD_NVEC) += nvec_kbd.o
-obj-$(CONFIG_NVEC_LEDS) += nvec_leds.o
+obj-$(CONFIG_NVEC_PAZ00) += nvec_paz00.o
diff --git a/drivers/staging/nvec/nvec.c b/drivers/staging/nvec/nvec.c
index 3c60088871e0..695ea35f75b0 100644
--- a/drivers/staging/nvec/nvec.c
+++ b/drivers/staging/nvec/nvec.c
@@ -97,7 +97,7 @@ static struct mfd_cell nvec_devices[] = {
.id = 2,
},
{
- .name = "nvec-leds",
+ .name = "nvec-paz00",
.id = 1,
},
};
@@ -127,12 +127,14 @@ EXPORT_SYMBOL_GPL(nvec_register_notifier);
static int nvec_status_notifier(struct notifier_block *nb,
unsigned long event_type, void *data)
{
+ struct nvec_chip *nvec = container_of(nb, struct nvec_chip,
+ nvec_status_notifier);
unsigned char *msg = (unsigned char *)data;
if (event_type != NVEC_CNTL)
return NOTIFY_DONE;
- printk(KERN_WARNING "unhandled msg type %ld\n", event_type);
+ dev_warn(nvec->dev, "unhandled msg type %ld\n", event_type);
print_hex_dump(KERN_WARNING, "payload: ", DUMP_PREFIX_NONE, 16, 1,
msg, msg[1] + 2, true);
@@ -675,7 +677,7 @@ static void tegra_init_i2c_slave(struct nvec_chip *nvec)
{
u32 val;
- clk_enable(nvec->i2c_clk);
+ clk_prepare_enable(nvec->i2c_clk);
tegra_periph_reset_assert(nvec->i2c_clk);
udelay(2);
@@ -695,15 +697,17 @@ static void tegra_init_i2c_slave(struct nvec_chip *nvec)
enable_irq(nvec->irq);
- clk_disable(nvec->i2c_clk);
+ clk_disable_unprepare(nvec->i2c_clk);
}
+#ifdef CONFIG_PM_SLEEP
static void nvec_disable_i2c_slave(struct nvec_chip *nvec)
{
disable_irq(nvec->irq);
writel(I2C_SL_NEWSL | I2C_SL_NACK, nvec->base + I2C_SL_CNFG);
- clk_disable(nvec->i2c_clk);
+ clk_disable_unprepare(nvec->i2c_clk);
}
+#endif
static void nvec_power_off(void)
{
@@ -719,10 +723,9 @@ static int __devinit tegra_nvec_probe(struct platform_device *pdev)
struct nvec_chip *nvec;
struct nvec_msg *msg;
struct resource *res;
- struct resource *iomem;
void __iomem *base;
- nvec = kzalloc(sizeof(struct nvec_chip), GFP_KERNEL);
+ nvec = devm_kzalloc(&pdev->dev, sizeof(struct nvec_chip), GFP_KERNEL);
if (nvec == NULL) {
dev_err(&pdev->dev, "failed to reserve memory\n");
return -ENOMEM;
@@ -737,15 +740,15 @@ static int __devinit tegra_nvec_probe(struct platform_device *pdev)
nvec->gpio = of_get_named_gpio(nvec->dev->of_node, "request-gpios", 0);
if (nvec->gpio < 0) {
dev_err(&pdev->dev, "no gpio specified");
- goto failed;
+ return -ENODEV;
}
if (of_property_read_u32(nvec->dev->of_node, "slave-addr", &nvec->i2c_addr)) {
dev_err(&pdev->dev, "no i2c address specified");
- goto failed;
+ return -ENODEV;
}
} else {
dev_err(&pdev->dev, "no platform data\n");
- goto failed;
+ return -ENODEV;
}
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
@@ -754,13 +757,7 @@ static int __devinit tegra_nvec_probe(struct platform_device *pdev)
return -ENODEV;
}
- iomem = request_mem_region(res->start, resource_size(res), pdev->name);
- if (!iomem) {
- dev_err(&pdev->dev, "I2C region already claimed\n");
- return -EBUSY;
- }
-
- base = ioremap(iomem->start, resource_size(iomem));
+ base = devm_request_and_ioremap(&pdev->dev, res);
if (!base) {
dev_err(&pdev->dev, "Can't ioremap I2C region\n");
return -ENOMEM;
@@ -769,14 +766,13 @@ static int __devinit tegra_nvec_probe(struct platform_device *pdev)
res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
if (!res) {
dev_err(&pdev->dev, "no irq resource?\n");
- ret = -ENODEV;
- goto err_iounmap;
+ return -ENODEV;
}
i2c_clk = clk_get_sys("tegra-i2c.2", NULL);
if (IS_ERR(i2c_clk)) {
dev_err(nvec->dev, "failed to get controller clock\n");
- goto err_iounmap;
+ return -ENODEV;
}
nvec->base = base;
@@ -797,22 +793,26 @@ static int __devinit tegra_nvec_probe(struct platform_device *pdev)
INIT_WORK(&nvec->tx_work, nvec_request_master);
nvec->wq = alloc_workqueue("nvec", WQ_NON_REENTRANT, 2);
- err = gpio_request_one(nvec->gpio, GPIOF_OUT_INIT_HIGH, "nvec gpio");
+ err = devm_gpio_request_one(&pdev->dev, nvec->gpio, GPIOF_OUT_INIT_HIGH,
+ "nvec gpio");
if (err < 0) {
dev_err(nvec->dev, "couldn't request gpio\n");
- goto failed;
+ destroy_workqueue(nvec->wq);
+ return -ENODEV;
}
- err = request_irq(nvec->irq, nvec_interrupt, 0, "nvec", nvec);
+ err = devm_request_irq(&pdev->dev, nvec->irq, nvec_interrupt, 0,
+ "nvec", nvec);
if (err) {
dev_err(nvec->dev, "couldn't request irq\n");
- goto failed;
+ destroy_workqueue(nvec->wq);
+ return -ENODEV;
}
disable_irq(nvec->irq);
tegra_init_i2c_slave(nvec);
- clk_enable(i2c_clk);
+ clk_prepare_enable(i2c_clk);
/* enable event reporting */
@@ -851,12 +851,6 @@ static int __devinit tegra_nvec_probe(struct platform_device *pdev)
nvec_write_async(nvec, "\x01\x01\x01\x00\x00\x80\x00", 7);
return 0;
-
-err_iounmap:
- iounmap(base);
-failed:
- kfree(nvec);
- return -ENOMEM;
}
static int __devexit tegra_nvec_remove(struct platform_device *pdev)
@@ -865,19 +859,15 @@ static int __devexit tegra_nvec_remove(struct platform_device *pdev)
nvec_write_async(nvec, EC_DISABLE_EVENT_REPORTING, 3);
mfd_remove_devices(nvec->dev);
- free_irq(nvec->irq, &nvec_interrupt);
- iounmap(nvec->base);
- gpio_free(nvec->gpio);
destroy_workqueue(nvec->wq);
- kfree(nvec);
return 0;
}
-#ifdef CONFIG_PM
-
-static int tegra_nvec_suspend(struct platform_device *pdev, pm_message_t state)
+#ifdef CONFIG_PM_SLEEP
+static int nvec_suspend(struct device *dev)
{
+ struct platform_device *pdev = to_platform_device(dev);
struct nvec_chip *nvec = platform_get_drvdata(pdev);
struct nvec_msg *msg;
@@ -894,8 +884,9 @@ static int tegra_nvec_suspend(struct platform_device *pdev, pm_message_t state)
return 0;
}
-static int tegra_nvec_resume(struct platform_device *pdev)
+static int nvec_resume(struct device *dev)
{
+ struct platform_device *pdev = to_platform_device(dev);
struct nvec_chip *nvec = platform_get_drvdata(pdev);
dev_dbg(nvec->dev, "resuming\n");
@@ -904,12 +895,10 @@ static int tegra_nvec_resume(struct platform_device *pdev)
return 0;
}
-
-#else
-#define tegra_nvec_suspend NULL
-#define tegra_nvec_resume NULL
#endif
+static const SIMPLE_DEV_PM_OPS(nvec_pm_ops, nvec_suspend, nvec_resume);
+
/* Match table for of_platform binding */
static const struct of_device_id nvidia_nvec_of_match[] __devinitconst = {
{ .compatible = "nvidia,nvec", },
@@ -920,21 +909,15 @@ MODULE_DEVICE_TABLE(of, nvidia_nvec_of_match);
static struct platform_driver nvec_device_driver = {
.probe = tegra_nvec_probe,
.remove = __devexit_p(tegra_nvec_remove),
- .suspend = tegra_nvec_suspend,
- .resume = tegra_nvec_resume,
.driver = {
.name = "nvec",
.owner = THIS_MODULE,
+ .pm = &nvec_pm_ops,
.of_match_table = nvidia_nvec_of_match,
}
};
-static int __init tegra_nvec_init(void)
-{
- return platform_driver_register(&nvec_device_driver);
-}
-
-module_init(tegra_nvec_init);
+module_platform_driver(nvec_device_driver);
MODULE_ALIAS("platform:nvec");
MODULE_DESCRIPTION("NVIDIA compliant embedded controller interface");
diff --git a/drivers/staging/nvec/nvec.h b/drivers/staging/nvec/nvec.h
index a4c17b0e10cf..ba6ed8f4e8a3 100644
--- a/drivers/staging/nvec/nvec.h
+++ b/drivers/staging/nvec/nvec.h
@@ -42,7 +42,7 @@
* enum nvec_event_size - The size of an event message
* @NVEC_2BYTES: The message has one command byte and one data byte
* @NVEC_3BYTES: The message has one command byte and two data bytes
- * @NVEC_VAR_SIZE: The message has one command byte, one count byte, and as
+ * @NVEC_VAR_SIZE: The message has one command byte, one count byte, and has
* up to as many bytes as the number in the count byte. The
* maximum is 32
*
diff --git a/drivers/staging/nvec/nvec_kbd.c b/drivers/staging/nvec/nvec_kbd.c
index a4ce5a740e2b..6cc30dcd8306 100644
--- a/drivers/staging/nvec/nvec_kbd.c
+++ b/drivers/staging/nvec/nvec_kbd.c
@@ -159,20 +159,24 @@ fail:
return err;
}
+static int __devexit nvec_kbd_remove(struct platform_device *pdev)
+{
+ input_unregister_device(keys_dev.input);
+ input_free_device(keys_dev.input);
+
+ return 0;
+}
+
static struct platform_driver nvec_kbd_driver = {
.probe = nvec_kbd_probe,
+ .remove = __devexit_p(nvec_kbd_remove),
.driver = {
.name = "nvec-kbd",
.owner = THIS_MODULE,
},
};
-static int __init nvec_kbd_init(void)
-{
- return platform_driver_register(&nvec_kbd_driver);
-}
-
-module_init(nvec_kbd_init);
+module_platform_driver(nvec_kbd_driver);
MODULE_AUTHOR("Marc Dietrich <marvin24@gmx.de>");
MODULE_DESCRIPTION("NVEC keyboard driver");
diff --git a/drivers/staging/nvec/nvec_leds.c b/drivers/staging/nvec/nvec_paz00.c
index f4cbcd625001..b747e39ff94d 100644
--- a/drivers/staging/nvec/nvec_leds.c
+++ b/drivers/staging/nvec/nvec_paz00.c
@@ -1,5 +1,5 @@
/*
- * nvec_leds: LED driver for a NVIDIA compliant embedded controller
+ * nvec_paz00: OEM specific driver for Compal PAZ00 based devices
*
* Copyright (C) 2011 The AC100 Kernel Team <ac100@lists.launchpad.net>
*
@@ -43,20 +43,20 @@ static void nvec_led_brightness_set(struct led_classdev *led_cdev,
}
-static int __devinit nvec_led_probe(struct platform_device *pdev)
+static int __devinit nvec_paz00_probe(struct platform_device *pdev)
{
struct nvec_chip *nvec = dev_get_drvdata(pdev->dev.parent);
struct nvec_led *led;
int ret = 0;
- led = kzalloc(sizeof(*led), GFP_KERNEL);
+ led = devm_kzalloc(&pdev->dev, sizeof(*led), GFP_KERNEL);
if (led == NULL)
return -ENOMEM;
led->cdev.max_brightness = NVEC_LED_MAX;
led->cdev.brightness_set = nvec_led_brightness_set;
- led->cdev.name = "nvec-led";
+ led->cdev.name = "paz00-led";
led->cdev.flags |= LED_CORE_SUSPENDRESUME;
led->nvec = nvec;
@@ -64,51 +64,35 @@ static int __devinit nvec_led_probe(struct platform_device *pdev)
ret = led_classdev_register(&pdev->dev, &led->cdev);
if (ret < 0)
- goto err_led;
+ return ret;
/* to expose the default value to userspace */
led->cdev.brightness = 0;
return 0;
-
-err_led:
- kfree(led);
- return ret;
}
-static int __devexit nvec_led_remove(struct platform_device *pdev)
+static int __devexit nvec_paz00_remove(struct platform_device *pdev)
{
struct nvec_led *led = platform_get_drvdata(pdev);
led_classdev_unregister(&led->cdev);
- kfree(led);
+
return 0;
}
-static struct platform_driver nvec_led_driver = {
- .probe = nvec_led_probe,
- .remove = __devexit_p(nvec_led_remove),
+static struct platform_driver nvec_paz00_driver = {
+ .probe = nvec_paz00_probe,
+ .remove = __devexit_p(nvec_paz00_remove),
.driver = {
- .name = "nvec-leds",
- .owner = THIS_MODULE,
+ .name = "nvec-paz00",
+ .owner = THIS_MODULE,
},
};
-static int __init nvec_led_init(void)
-{
- return platform_driver_register(&nvec_led_driver);
-}
-
-module_init(nvec_led_init);
-
-static void __exit nvec_led_exit(void)
-{
- platform_driver_unregister(&nvec_led_driver);
-}
-
-module_exit(nvec_led_exit);
+module_platform_driver(nvec_paz00_driver);
MODULE_AUTHOR("Ilya Petrov <ilya.muromec@gmail.com>");
-MODULE_DESCRIPTION("Tegra NVEC LED driver");
+MODULE_DESCRIPTION("Tegra NVEC PAZ00 driver");
MODULE_LICENSE("GPL");
-MODULE_ALIAS("platform:nvec-leds");
+MODULE_ALIAS("platform:nvec-paz00");
diff --git a/drivers/staging/nvec/nvec_power.c b/drivers/staging/nvec/nvec_power.c
index dfa966f6189d..cc8ccd75e7f4 100644
--- a/drivers/staging/nvec/nvec_power.c
+++ b/drivers/staging/nvec/nvec_power.c
@@ -371,10 +371,13 @@ static void nvec_power_poll(struct work_struct *work)
static int __devinit nvec_power_probe(struct platform_device *pdev)
{
struct power_supply *psy;
- struct nvec_power *power =
- kzalloc(sizeof(struct nvec_power), GFP_NOWAIT);
+ struct nvec_power *power;
struct nvec_chip *nvec = dev_get_drvdata(pdev->dev.parent);
+ power = devm_kzalloc(&pdev->dev, sizeof(struct nvec_power), GFP_NOWAIT);
+ if (power == NULL)
+ return -ENOMEM;
+
dev_set_drvdata(&pdev->dev, power);
power->nvec = nvec;
@@ -393,7 +396,6 @@ static int __devinit nvec_power_probe(struct platform_device *pdev)
power->notifier.notifier_call = nvec_power_bat_notifier;
break;
default:
- kfree(power);
return -ENODEV;
}
@@ -405,20 +407,32 @@ static int __devinit nvec_power_probe(struct platform_device *pdev)
return power_supply_register(&pdev->dev, psy);
}
+static int __devexit nvec_power_remove(struct platform_device *pdev)
+{
+ struct nvec_power *power = platform_get_drvdata(pdev);
+
+ cancel_delayed_work_sync(&power->poller);
+ switch (pdev->id) {
+ case AC:
+ power_supply_unregister(&nvec_psy);
+ break;
+ case BAT:
+ power_supply_unregister(&nvec_bat_psy);
+ }
+
+ return 0;
+}
+
static struct platform_driver nvec_power_driver = {
.probe = nvec_power_probe,
+ .remove = __devexit_p(nvec_power_remove),
.driver = {
.name = "nvec-power",
.owner = THIS_MODULE,
}
};
-static int __init nvec_power_init(void)
-{
- return platform_driver_register(&nvec_power_driver);
-}
-
-module_init(nvec_power_init);
+module_platform_driver(nvec_power_driver);
MODULE_AUTHOR("Ilya Petrov <ilya.muromec@gmail.com>");
MODULE_LICENSE("GPL");
diff --git a/drivers/staging/nvec/nvec_ps2.c b/drivers/staging/nvec/nvec_ps2.c
index 14a6f687cf75..d7c651102131 100644
--- a/drivers/staging/nvec/nvec_ps2.c
+++ b/drivers/staging/nvec/nvec_ps2.c
@@ -96,7 +96,11 @@ static int nvec_ps2_notifier(struct notifier_block *nb,
static int __devinit nvec_mouse_probe(struct platform_device *pdev)
{
struct nvec_chip *nvec = dev_get_drvdata(pdev->dev.parent);
- struct serio *ser_dev = kzalloc(sizeof(struct serio), GFP_KERNEL);
+ struct serio *ser_dev;
+
+ ser_dev = devm_kzalloc(&pdev->dev, sizeof(struct serio), GFP_KERNEL);
+ if (ser_dev == NULL)
+ return -ENOMEM;
ser_dev->id.type = SERIO_PS_PSTHRU;
ser_dev->write = ps2_sendcommand;
@@ -119,8 +123,17 @@ static int __devinit nvec_mouse_probe(struct platform_device *pdev)
return 0;
}
-static int nvec_mouse_suspend(struct platform_device *pdev, pm_message_t state)
+static int __devexit nvec_mouse_remove(struct platform_device *pdev)
+{
+ serio_unregister_port(ps2_dev.ser_dev);
+
+ return 0;
+}
+
+#ifdef CONFIG_PM_SLEEP
+static int nvec_mouse_suspend(struct device *dev)
{
+ struct platform_device *pdev = to_platform_device(dev);
struct nvec_chip *nvec = dev_get_drvdata(pdev->dev.parent);
/* disable mouse */
@@ -132,8 +145,9 @@ static int nvec_mouse_suspend(struct platform_device *pdev, pm_message_t state)
return 0;
}
-static int nvec_mouse_resume(struct platform_device *pdev)
+static int nvec_mouse_resume(struct device *dev)
{
+ struct platform_device *pdev = to_platform_device(dev);
struct nvec_chip *nvec = dev_get_drvdata(pdev->dev.parent);
ps2_startstreaming(ps2_dev.ser_dev);
@@ -143,23 +157,22 @@ static int nvec_mouse_resume(struct platform_device *pdev)
return 0;
}
+#endif
+
+static const SIMPLE_DEV_PM_OPS(nvec_mouse_pm_ops, nvec_mouse_suspend,
+ nvec_mouse_resume);
static struct platform_driver nvec_mouse_driver = {
.probe = nvec_mouse_probe,
- .suspend = nvec_mouse_suspend,
- .resume = nvec_mouse_resume,
+ .remove = __devexit_p(nvec_mouse_remove),
.driver = {
.name = "nvec-mouse",
.owner = THIS_MODULE,
+ .pm = &nvec_mouse_pm_ops,
},
};
-static int __init nvec_mouse_init(void)
-{
- return platform_driver_register(&nvec_mouse_driver);
-}
-
-module_init(nvec_mouse_init);
+module_platform_driver(nvec_mouse_driver);
MODULE_DESCRIPTION("NVEC mouse driver");
MODULE_AUTHOR("Marc Dietrich <marvin24@gmx.de>");
diff --git a/drivers/staging/octeon/ethernet-mdio.c b/drivers/staging/octeon/ethernet-mdio.c
index e31949c9c87e..f15b31b37ca5 100644
--- a/drivers/staging/octeon/ethernet-mdio.c
+++ b/drivers/staging/octeon/ethernet-mdio.c
@@ -28,6 +28,7 @@
#include <linux/ethtool.h>
#include <linux/phy.h>
#include <linux/ratelimit.h>
+#include <linux/of_mdio.h>
#include <net/dst.h>
@@ -161,22 +162,23 @@ static void cvm_oct_adjust_link(struct net_device *dev)
int cvm_oct_phy_setup_device(struct net_device *dev)
{
struct octeon_ethernet *priv = netdev_priv(dev);
+ struct device_node *phy_node;
- int phy_addr = cvmx_helper_board_get_mii_address(priv->port);
- if (phy_addr != -1) {
- char phy_id[MII_BUS_ID_SIZE + 3];
+ if (!priv->of_node)
+ return 0;
- snprintf(phy_id, sizeof(phy_id), PHY_ID_FMT, "mdio-octeon-0", phy_addr);
+ phy_node = of_parse_phandle(priv->of_node, "phy-handle", 0);
+ if (!phy_node)
+ return 0;
- priv->phydev = phy_connect(dev, phy_id, cvm_oct_adjust_link, 0,
- PHY_INTERFACE_MODE_GMII);
+ priv->phydev = of_phy_connect(dev, phy_node, cvm_oct_adjust_link, 0,
+ PHY_INTERFACE_MODE_GMII);
+
+ if (priv->phydev == NULL)
+ return -ENODEV;
+
+ priv->last_link = 0;
+ phy_start_aneg(priv->phydev);
- if (IS_ERR(priv->phydev)) {
- priv->phydev = NULL;
- return -1;
- }
- priv->last_link = 0;
- phy_start_aneg(priv->phydev);
- }
return 0;
}
diff --git a/drivers/staging/octeon/ethernet-rx.c b/drivers/staging/octeon/ethernet-rx.c
index d91751f9ffe8..34afc16bc493 100644
--- a/drivers/staging/octeon/ethernet-rx.c
+++ b/drivers/staging/octeon/ethernet-rx.c
@@ -163,7 +163,7 @@ static inline int cvm_oct_check_rcv_error(cvmx_wqe_t *work)
/*
* We received a packet with either an alignment error
* or a FCS error. This may be signalling that we are
- * running 10Mbps with GMXX_RXX_FRM_CTL[PRE_CHK}
+ * running 10Mbps with GMXX_RXX_FRM_CTL[PRE_CHK]
* off. If this is the case we need to parse the
* packet to determine if we can remove a non spec
* preamble and generate a correct packet.
diff --git a/drivers/staging/octeon/ethernet-tx.c b/drivers/staging/octeon/ethernet-tx.c
index 91a97b3e45c6..5631dd9f8201 100644
--- a/drivers/staging/octeon/ethernet-tx.c
+++ b/drivers/staging/octeon/ethernet-tx.c
@@ -62,7 +62,7 @@
* You can define GET_SKBUFF_QOS() to override how the skbuff output
* function determines which output queue is used. The default
* implementation always uses the base queue for the port. If, for
- * example, you wanted to use the skb->priority fieid, define
+ * example, you wanted to use the skb->priority field, define
* GET_SKBUFF_QOS as: #define GET_SKBUFF_QOS(skb) ((skb)->priority)
*/
#ifndef GET_SKBUFF_QOS
@@ -165,8 +165,8 @@ int cvm_oct_xmit(struct sk_buff *skb, struct net_device *dev)
#endif
/*
- * Prefetch the private data structure. It is larger that one
- * cache line.
+ * Prefetch the private data structure. It is larger than the
+ * one cache line.
*/
prefetch(priv);
@@ -291,8 +291,8 @@ int cvm_oct_xmit(struct sk_buff *skb, struct net_device *dev)
* See if we can put this skb in the FPA pool. Any strange
* behavior from the Linux networking stack will most likely
* be caused by a bug in the following code. If some field is
- * in use by the network stack and get carried over when a
- * buffer is reused, bad thing may happen. If in doubt and
+ * in use by the network stack and gets carried over when a
+ * buffer is reused, bad things may happen. If in doubt and
* you dont need the absolute best performance, disable the
* define REUSE_SKBUFFS_WITHOUT_FREE. The reuse of buffers has
* shown a 25% increase in performance under some loads.
@@ -345,7 +345,7 @@ int cvm_oct_xmit(struct sk_buff *skb, struct net_device *dev)
}
if (unlikely
(skb->truesize !=
- sizeof(*skb) + skb_end_pointer(skb) - skb->head)) {
+ sizeof(*skb) + skb_end_offset(skb))) {
/*
printk("TX buffer truesize has been changed\n");
*/
diff --git a/drivers/staging/octeon/ethernet-util.h b/drivers/staging/octeon/ethernet-util.h
index 144fb99bf50c..2da5ce17ead0 100644
--- a/drivers/staging/octeon/ethernet-util.h
+++ b/drivers/staging/octeon/ethernet-util.h
@@ -38,7 +38,7 @@ static inline void *cvm_oct_get_buffer_ptr(union cvmx_buf_ptr packet_ptr)
}
/**
- * INTERFACE - convert IPD port to locgical interface
+ * INTERFACE - convert IPD port to logical interface
* @ipd_port: Port to check
*
* Returns Logical interface
diff --git a/drivers/staging/octeon/ethernet.c b/drivers/staging/octeon/ethernet.c
index 60cba8194de3..683bedc74dde 100644
--- a/drivers/staging/octeon/ethernet.c
+++ b/drivers/staging/octeon/ethernet.c
@@ -24,6 +24,7 @@
* This file may also be available under a different license from Cavium.
* Contact Cavium Networks for more information
**********************************************************************/
+#include <linux/platform_device.h>
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/module.h>
@@ -32,6 +33,7 @@
#include <linux/phy.h>
#include <linux/slab.h>
#include <linux/interrupt.h>
+#include <linux/of_net.h>
#include <net/dst.h>
@@ -113,15 +115,6 @@ int rx_napi_weight = 32;
module_param(rx_napi_weight, int, 0444);
MODULE_PARM_DESC(rx_napi_weight, "The NAPI WEIGHT parameter.");
-/*
- * The offset from mac_addr_base that should be used for the next port
- * that is configured. By convention, if any mgmt ports exist on the
- * chip, they get the first mac addresses, The ports controlled by
- * this driver are numbered sequencially following any mgmt addresses
- * that may exist.
- */
-static unsigned int cvm_oct_mac_addr_offset;
-
/**
* cvm_oct_poll_queue - Workqueue for polling operations.
*/
@@ -176,7 +169,7 @@ static void cvm_oct_periodic_worker(struct work_struct *work)
queue_delayed_work(cvm_oct_poll_queue, &priv->port_periodic_work, HZ);
}
-static __init void cvm_oct_configure_common_hw(void)
+static __devinit void cvm_oct_configure_common_hw(void)
{
/* Setup the FPA */
cvmx_fpa_enable();
@@ -357,7 +350,7 @@ static void cvm_oct_common_set_multicast_list(struct net_device *dev)
/* Force accept multicast packets */
control.s.mcst = 2;
else
- /* Force reject multicat packets */
+ /* Force reject multicast packets */
control.s.mcst = 1;
if (dev->flags & IFF_PROMISC)
@@ -396,23 +389,21 @@ static void cvm_oct_common_set_multicast_list(struct net_device *dev)
* Returns Zero on success
*/
-static int cvm_oct_common_set_mac_address(struct net_device *dev, void *addr)
+static int cvm_oct_set_mac_filter(struct net_device *dev)
{
struct octeon_ethernet *priv = netdev_priv(dev);
union cvmx_gmxx_prtx_cfg gmx_cfg;
int interface = INTERFACE(priv->port);
int index = INDEX(priv->port);
- memcpy(dev->dev_addr, addr + 2, 6);
-
if ((interface < 2)
&& (cvmx_helper_interface_get_mode(interface) !=
CVMX_HELPER_INTERFACE_MODE_SPI)) {
int i;
- uint8_t *ptr = addr;
+ uint8_t *ptr = dev->dev_addr;
uint64_t mac = 0;
for (i = 0; i < 6; i++)
- mac = (mac << 8) | (uint64_t) (ptr[i + 2]);
+ mac = (mac << 8) | (uint64_t)ptr[i];
gmx_cfg.u64 =
cvmx_read_csr(CVMX_GMXX_PRTX_CFG(index, interface));
@@ -421,17 +412,17 @@ static int cvm_oct_common_set_mac_address(struct net_device *dev, void *addr)
cvmx_write_csr(CVMX_GMXX_SMACX(index, interface), mac);
cvmx_write_csr(CVMX_GMXX_RXX_ADR_CAM0(index, interface),
- ptr[2]);
+ ptr[0]);
cvmx_write_csr(CVMX_GMXX_RXX_ADR_CAM1(index, interface),
- ptr[3]);
+ ptr[1]);
cvmx_write_csr(CVMX_GMXX_RXX_ADR_CAM2(index, interface),
- ptr[4]);
+ ptr[2]);
cvmx_write_csr(CVMX_GMXX_RXX_ADR_CAM3(index, interface),
- ptr[5]);
+ ptr[3]);
cvmx_write_csr(CVMX_GMXX_RXX_ADR_CAM4(index, interface),
- ptr[6]);
+ ptr[4]);
cvmx_write_csr(CVMX_GMXX_RXX_ADR_CAM5(index, interface),
- ptr[7]);
+ ptr[5]);
cvm_oct_common_set_multicast_list(dev);
cvmx_write_csr(CVMX_GMXX_PRTX_CFG(index, interface),
gmx_cfg.u64);
@@ -439,6 +430,15 @@ static int cvm_oct_common_set_mac_address(struct net_device *dev, void *addr)
return 0;
}
+static int cvm_oct_common_set_mac_address(struct net_device *dev, void *addr)
+{
+ int r = eth_mac_addr(dev, addr);
+
+ if (r)
+ return r;
+ return cvm_oct_set_mac_filter(dev);
+}
+
/**
* cvm_oct_common_init - per network device initialization
* @dev: Device to initialize
@@ -448,26 +448,17 @@ static int cvm_oct_common_set_mac_address(struct net_device *dev, void *addr)
int cvm_oct_common_init(struct net_device *dev)
{
struct octeon_ethernet *priv = netdev_priv(dev);
- struct sockaddr sa;
- u64 mac = ((u64)(octeon_bootinfo->mac_addr_base[0] & 0xff) << 40) |
- ((u64)(octeon_bootinfo->mac_addr_base[1] & 0xff) << 32) |
- ((u64)(octeon_bootinfo->mac_addr_base[2] & 0xff) << 24) |
- ((u64)(octeon_bootinfo->mac_addr_base[3] & 0xff) << 16) |
- ((u64)(octeon_bootinfo->mac_addr_base[4] & 0xff) << 8) |
- (u64)(octeon_bootinfo->mac_addr_base[5] & 0xff);
-
- mac += cvm_oct_mac_addr_offset;
- sa.sa_data[0] = (mac >> 40) & 0xff;
- sa.sa_data[1] = (mac >> 32) & 0xff;
- sa.sa_data[2] = (mac >> 24) & 0xff;
- sa.sa_data[3] = (mac >> 16) & 0xff;
- sa.sa_data[4] = (mac >> 8) & 0xff;
- sa.sa_data[5] = mac & 0xff;
-
- if (cvm_oct_mac_addr_offset >= octeon_bootinfo->mac_addr_count)
- printk(KERN_DEBUG "%s: Using MAC outside of the assigned range:"
- " %pM\n", dev->name, sa.sa_data);
- cvm_oct_mac_addr_offset++;
+ const u8 *mac = NULL;
+
+ if (priv->of_node)
+ mac = of_get_mac_address(priv->of_node);
+
+ if (mac && is_valid_ether_addr(mac)) {
+ memcpy(dev->dev_addr, mac, ETH_ALEN);
+ dev->addr_assign_type &= ~NET_ADDR_RANDOM;
+ } else {
+ eth_hw_addr_random(dev);
+ }
/*
* Force the interface to use the POW send if always_use_pow
@@ -488,7 +479,7 @@ int cvm_oct_common_init(struct net_device *dev)
SET_ETHTOOL_OPS(dev, &cvm_oct_ethtool_ops);
cvm_oct_phy_setup_device(dev);
- dev->netdev_ops->ndo_set_mac_address(dev, &sa);
+ cvm_oct_set_mac_filter(dev);
dev->netdev_ops->ndo_change_mtu(dev, dev->mtu);
/*
@@ -595,22 +586,55 @@ static const struct net_device_ops cvm_oct_pow_netdev_ops = {
extern void octeon_mdiobus_force_mod_depencency(void);
-static int __init cvm_oct_init_module(void)
+static struct device_node * __devinit cvm_oct_of_get_child(const struct device_node *parent,
+ int reg_val)
+{
+ struct device_node *node = NULL;
+ int size;
+ const __be32 *addr;
+
+ for (;;) {
+ node = of_get_next_child(parent, node);
+ if (!node)
+ break;
+ addr = of_get_property(node, "reg", &size);
+ if (addr && (be32_to_cpu(*addr) == reg_val))
+ break;
+ }
+ return node;
+}
+
+static struct device_node * __devinit cvm_oct_node_for_port(struct device_node *pip,
+ int interface, int port)
+{
+ struct device_node *ni, *np;
+
+ ni = cvm_oct_of_get_child(pip, interface);
+ if (!ni)
+ return NULL;
+
+ np = cvm_oct_of_get_child(ni, port);
+ of_node_put(ni);
+
+ return np;
+}
+
+static int __devinit cvm_oct_probe(struct platform_device *pdev)
{
int num_interfaces;
int interface;
int fau = FAU_NUM_PACKET_BUFFERS_TO_FREE;
int qos;
+ struct device_node *pip;
octeon_mdiobus_force_mod_depencency();
pr_notice("cavium-ethernet %s\n", OCTEON_ETHERNET_VERSION);
- if (OCTEON_IS_MODEL(OCTEON_CN52XX))
- cvm_oct_mac_addr_offset = 2; /* First two are the mgmt ports. */
- else if (OCTEON_IS_MODEL(OCTEON_CN56XX))
- cvm_oct_mac_addr_offset = 1; /* First one is the mgmt port. */
- else
- cvm_oct_mac_addr_offset = 0;
+ pip = pdev->dev.of_node;
+ if (!pip) {
+ pr_err("Error: No 'pip' in /aliases\n");
+ return -EINVAL;
+ }
cvm_oct_poll_queue = create_singlethread_workqueue("octeon-ethernet");
if (cvm_oct_poll_queue == NULL) {
@@ -689,10 +713,11 @@ static int __init cvm_oct_init_module(void)
cvmx_helper_interface_get_mode(interface);
int num_ports = cvmx_helper_ports_on_interface(interface);
int port;
+ int port_index;
- for (port = cvmx_helper_get_ipd_port(interface, 0);
+ for (port_index = 0, port = cvmx_helper_get_ipd_port(interface, 0);
port < cvmx_helper_get_ipd_port(interface, num_ports);
- port++) {
+ port_index++, port++) {
struct octeon_ethernet *priv;
struct net_device *dev =
alloc_etherdev(sizeof(struct octeon_ethernet));
@@ -703,6 +728,7 @@ static int __init cvm_oct_init_module(void)
/* Initialize the device private structure. */
priv = netdev_priv(dev);
+ priv->of_node = cvm_oct_node_for_port(pip, interface, port_index);
INIT_DELAYED_WORK(&priv->port_periodic_work,
cvm_oct_periodic_worker);
@@ -787,7 +813,7 @@ static int __init cvm_oct_init_module(void)
return 0;
}
-static void __exit cvm_oct_cleanup_module(void)
+static int __devexit cvm_oct_remove(struct platform_device *pdev)
{
int port;
@@ -835,10 +861,29 @@ static void __exit cvm_oct_cleanup_module(void)
if (CVMX_FPA_OUTPUT_BUFFER_POOL != CVMX_FPA_PACKET_POOL)
cvm_oct_mem_empty_fpa(CVMX_FPA_OUTPUT_BUFFER_POOL,
CVMX_FPA_OUTPUT_BUFFER_POOL_SIZE, 128);
+ return 0;
}
+static struct of_device_id cvm_oct_match[] = {
+ {
+ .compatible = "cavium,octeon-3860-pip",
+ },
+ {},
+};
+MODULE_DEVICE_TABLE(of, cvm_oct_match);
+
+static struct platform_driver cvm_oct_driver = {
+ .probe = cvm_oct_probe,
+ .remove = __devexit_p(cvm_oct_remove),
+ .driver = {
+ .owner = THIS_MODULE,
+ .name = KBUILD_MODNAME,
+ .of_match_table = cvm_oct_match,
+ },
+};
+
+module_platform_driver(cvm_oct_driver);
+
MODULE_LICENSE("GPL");
MODULE_AUTHOR("Cavium Networks <support@caviumnetworks.com>");
MODULE_DESCRIPTION("Cavium Networks Octeon ethernet driver.");
-module_init(cvm_oct_init_module);
-module_exit(cvm_oct_cleanup_module);
diff --git a/drivers/staging/octeon/octeon-ethernet.h b/drivers/staging/octeon/octeon-ethernet.h
index d58192563552..9360e22e0739 100644
--- a/drivers/staging/octeon/octeon-ethernet.h
+++ b/drivers/staging/octeon/octeon-ethernet.h
@@ -31,6 +31,8 @@
#ifndef OCTEON_ETHERNET_H
#define OCTEON_ETHERNET_H
+#include <linux/of.h>
+
/**
* This is the definition of the Ethernet driver's private
* driver state stored in netdev_priv(dev).
@@ -59,6 +61,7 @@ struct octeon_ethernet {
void (*poll) (struct net_device *dev);
struct delayed_work port_periodic_work;
struct work_struct port_work; /* may be unused. */
+ struct device_node *of_node;
};
int cvm_oct_free_work(void *work_queue_entry);
diff --git a/drivers/staging/olpc_dcon/olpc_dcon.c b/drivers/staging/olpc_dcon/olpc_dcon.c
index 3d9199320d86..992275c0d87c 100644
--- a/drivers/staging/olpc_dcon/olpc_dcon.c
+++ b/drivers/staging/olpc_dcon/olpc_dcon.c
@@ -71,8 +71,8 @@ static int dcon_hw_init(struct dcon_priv *dcon, int is_init)
ver = dcon_read(dcon, DCON_REG_ID);
if ((ver >> 8) != 0xDC) {
- printk(KERN_ERR "olpc-dcon: DCON ID not 0xDCxx: 0x%04x "
- "instead.\n", ver);
+ printk(KERN_ERR "olpc-dcon: DCON ID not 0xDCxx: 0x%04x instead.\n",
+ ver);
rc = -ENXIO;
goto err;
}
@@ -134,10 +134,10 @@ static int dcon_bus_stabilize(struct dcon_priv *dcon, int is_powered_down)
power_up:
if (is_powered_down) {
x = 1;
- x = olpc_ec_cmd(0x26, (unsigned char *) &x, 1, NULL, 0);
+ x = olpc_ec_cmd(0x26, (unsigned char *)&x, 1, NULL, 0);
if (x) {
- printk(KERN_WARNING "olpc-dcon: unable to force dcon "
- "to power up: %d!\n", x);
+ printk(KERN_WARNING "olpc-dcon: unable to force dcon to power up: %d!\n",
+ x);
return x;
}
msleep(10); /* we'll be conservative */
@@ -150,11 +150,10 @@ power_up:
x = dcon_read(dcon, DCON_REG_ID);
}
if (x < 0) {
- printk(KERN_ERR "olpc-dcon: unable to stabilize dcon's "
- "smbus, reasserting power and praying.\n");
+ printk(KERN_ERR "olpc-dcon: unable to stabilize dcon's smbus, reasserting power and praying.\n");
BUG_ON(olpc_board_at_least(olpc_board(0xc2)));
x = 0;
- olpc_ec_cmd(0x26, (unsigned char *) &x, 1, NULL, 0);
+ olpc_ec_cmd(0x26, (unsigned char *)&x, 1, NULL, 0);
msleep(100);
is_powered_down = 1;
goto power_up; /* argh, stupid hardware.. */
@@ -220,10 +219,10 @@ static void dcon_sleep(struct dcon_priv *dcon, bool sleep)
if (sleep) {
x = 0;
- x = olpc_ec_cmd(0x26, (unsigned char *) &x, 1, NULL, 0);
+ x = olpc_ec_cmd(0x26, (unsigned char *)&x, 1, NULL, 0);
if (x)
- printk(KERN_WARNING "olpc-dcon: unable to force dcon "
- "to power down: %d!\n", x);
+ printk(KERN_WARNING "olpc-dcon: unable to force dcon to power down: %d!\n",
+ x);
else
dcon->asleep = sleep;
} else {
@@ -232,8 +231,8 @@ static void dcon_sleep(struct dcon_priv *dcon, bool sleep)
dcon->disp_mode |= MODE_BL_ENABLE;
x = dcon_bus_stabilize(dcon, 1);
if (x)
- printk(KERN_WARNING "olpc-dcon: unable to reinit dcon"
- " hardware: %d!\n", x);
+ printk(KERN_WARNING "olpc-dcon: unable to reinit dcon hardware: %d!\n",
+ x);
else
dcon->asleep = sleep;
@@ -304,7 +303,7 @@ static void dcon_source_switch(struct work_struct *work)
switch (source) {
case DCON_SOURCE_CPU:
- printk("dcon_source_switch to CPU\n");
+ printk(KERN_INFO "dcon_source_switch to CPU\n");
/* Enable the scanline interrupt bit */
if (dcon_write(dcon, DCON_REG_MODE,
dcon->disp_mode | MODE_SCAN_INT))
@@ -599,7 +598,7 @@ static int dcon_fb_notifier(struct notifier_block *self,
struct fb_event *evdata = data;
struct dcon_priv *dcon = container_of(self, struct dcon_priv,
fbevent_nb);
- int *blank = (int *) evdata->data;
+ int *blank = (int *)evdata->data;
if (((event != FB_EVENT_BLANK) && (event != FB_EVENT_CONBLANK)) ||
dcon->ignore_fb_events)
return 0;
diff --git a/drivers/staging/olpc_dcon/olpc_dcon_xo_1.c b/drivers/staging/olpc_dcon/olpc_dcon_xo_1.c
index cb6ce0cf92a0..c87fdfac4855 100644
--- a/drivers/staging/olpc_dcon/olpc_dcon_xo_1.c
+++ b/drivers/staging/olpc_dcon/olpc_dcon_xo_1.c
@@ -116,7 +116,7 @@ static int dcon_init_xo_1(struct dcon_priv *dcon)
cs5535_gpio_set(OLPC_GPIO_DCON_IRQ, GPIO_NEGATIVE_EDGE_STS);
cs5535_gpio_set(OLPC_GPIO_DCON_BLANK, GPIO_NEGATIVE_EDGE_STS);
- /* FIXME: Clear the posiitive status as well, just to be sure */
+ /* FIXME: Clear the positive status as well, just to be sure */
cs5535_gpio_set(OLPC_GPIO_DCON_IRQ, GPIO_POSITIVE_EDGE_STS);
cs5535_gpio_set(OLPC_GPIO_DCON_BLANK, GPIO_POSITIVE_EDGE_STS);
diff --git a/drivers/staging/omap-thermal/Kconfig b/drivers/staging/omap-thermal/Kconfig
new file mode 100644
index 000000000000..30cbc3bc8dfa
--- /dev/null
+++ b/drivers/staging/omap-thermal/Kconfig
@@ -0,0 +1,46 @@
+config OMAP_BANDGAP
+ tristate "Texas Instruments OMAP4+ temperature sensor driver"
+ depends on THERMAL
+ depends on ARCH_OMAP4 || SOC_OMAP5
+ help
+ If you say yes here you get support for the Texas Instruments
+ OMAP4460+ on die bandgap temperature sensor support. The register
+ set is part of system control module.
+
+ This includes alert interrupts generation and also the TSHUT
+ support.
+
+config OMAP_THERMAL
+ bool "Texas Instruments OMAP4+ thermal framework support"
+ depends on OMAP_BANDGAP
+ depends on CPU_THERMAL
+ help
+ If you say yes here you want to get support for generic thermal
+ framework for the Texas Instruments OMAP4460+ on die bandgap
+ temperature sensor.
+
+config OMAP4_THERMAL
+ bool "Texas Instruments OMAP4 thermal support"
+ depends on OMAP_BANDGAP
+ depends on ARCH_OMAP4
+ help
+ If you say yes here you get thermal support for the Texas Instruments
+ OMAP4 SoC family. The current chip supported are:
+ - OMAP4430
+ - OMAP4460
+ - OMAP4470
+
+ This includes alert interrupts generation and also the TSHUT
+ support.
+
+config OMAP5_THERMAL
+ bool "Texas Instruments OMAP5 thermal support"
+ depends on OMAP_BANDGAP
+ depends on SOC_OMAP5
+ help
+ If you say yes here you get thermal support for the Texas Instruments
+ OMAP5 SoC family. The current chip supported are:
+ - OMAP5430
+
+ This includes alert interrupts generation and also the TSHUT
+ support.
diff --git a/drivers/staging/omap-thermal/Makefile b/drivers/staging/omap-thermal/Makefile
new file mode 100644
index 000000000000..091c4d20b14d
--- /dev/null
+++ b/drivers/staging/omap-thermal/Makefile
@@ -0,0 +1,5 @@
+obj-$(CONFIG_OMAP_BANDGAP) += omap-thermal.o
+omap-thermal-y := omap-bandgap.o
+omap-thermal-$(CONFIG_OMAP_THERMAL) += omap-thermal-common.o
+omap-thermal-$(CONFIG_OMAP4_THERMAL) += omap4-thermal.o
+omap-thermal-$(CONFIG_OMAP5_THERMAL) += omap5-thermal.o
diff --git a/drivers/staging/omap-thermal/TODO b/drivers/staging/omap-thermal/TODO
new file mode 100644
index 000000000000..9e23cc4d551b
--- /dev/null
+++ b/drivers/staging/omap-thermal/TODO
@@ -0,0 +1,28 @@
+List of TODOs (by Eduardo Valentin)
+
+on omap-bandgap.c:
+- Rework locking
+- Improve driver code by adding usage of regmap-mmio
+- Test every exposed API to userland
+- Add support to hwmon
+- Review and revisit all API exposed
+- Revisit PM support
+- Revisit data structures and simplify them
+- Once SCM-core api settles, update this driver accordingly
+
+on omap-thermal-common.c/omap-thermal.h:
+- Revisit extrapolation constants for O4/O5
+- Revisit need for locking
+- Revisit trips and its definitions
+- Revisit trending
+
+on omap5-thermal.c
+- Add support for GPU cooling
+
+generally:
+- write Kconfig dependencies so that omap variants are covered
+- make checkpatch.pl and sparse happy
+- make sure this code works on OMAP4430, OMAP4460 and OMAP5430
+- update documentation
+
+Copy patches to Eduardo Valentin <eduardo.valentin@ti.com>
diff --git a/drivers/staging/omap-thermal/omap-bandgap.c b/drivers/staging/omap-thermal/omap-bandgap.c
new file mode 100644
index 000000000000..c556abb63a17
--- /dev/null
+++ b/drivers/staging/omap-thermal/omap-bandgap.c
@@ -0,0 +1,1187 @@
+/*
+ * OMAP4 Bandgap temperature sensor driver
+ *
+ * Copyright (C) 2011-2012 Texas Instruments Incorporated - http://www.ti.com/
+ * Author: J Keerthy <j-keerthy@ti.com>
+ * Author: Moiz Sonasath <m-sonasath@ti.com>
+ * Couple of fixes, DT and MFD adaptation:
+ * Eduardo Valentin <eduardo.valentin@ti.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ *
+ */
+
+#include <linux/module.h>
+#include <linux/export.h>
+#include <linux/init.h>
+#include <linux/kernel.h>
+#include <linux/interrupt.h>
+#include <linux/clk.h>
+#include <linux/gpio.h>
+#include <linux/platform_device.h>
+#include <linux/err.h>
+#include <linux/types.h>
+#include <linux/mutex.h>
+#include <linux/reboot.h>
+#include <linux/of_device.h>
+#include <linux/of_platform.h>
+#include <linux/of_irq.h>
+
+#include "omap-bandgap.h"
+
+static u32 omap_bandgap_readl(struct omap_bandgap *bg_ptr, u32 reg)
+{
+ return readl(bg_ptr->base + reg);
+}
+
+static void omap_bandgap_writel(struct omap_bandgap *bg_ptr, u32 val, u32 reg)
+{
+ writel(val, bg_ptr->base + reg);
+}
+
+static int omap_bandgap_power(struct omap_bandgap *bg_ptr, bool on)
+{
+ struct temp_sensor_registers *tsr;
+ int i;
+ u32 ctrl;
+
+ if (!OMAP_BANDGAP_HAS(bg_ptr, POWER_SWITCH))
+ return 0;
+
+ for (i = 0; i < bg_ptr->conf->sensor_count; i++) {
+ tsr = bg_ptr->conf->sensors[i].registers;
+ ctrl = omap_bandgap_readl(bg_ptr, tsr->temp_sensor_ctrl);
+ ctrl &= ~tsr->bgap_tempsoff_mask;
+ /* active on 0 */
+ ctrl |= !on << __ffs(tsr->bgap_tempsoff_mask);
+
+ /* write BGAP_TEMPSOFF should be reset to 0 */
+ omap_bandgap_writel(bg_ptr, ctrl, tsr->temp_sensor_ctrl);
+ }
+
+ return 0;
+}
+
+/* This is the Talert handler. Call it only if HAS(TALERT) is set */
+static irqreturn_t talert_irq_handler(int irq, void *data)
+{
+ struct omap_bandgap *bg_ptr = data;
+ struct temp_sensor_registers *tsr;
+ u32 t_hot = 0, t_cold = 0, temp, ctrl;
+ int i;
+
+ bg_ptr = data;
+ /* Read the status of t_hot */
+ for (i = 0; i < bg_ptr->conf->sensor_count; i++) {
+ tsr = bg_ptr->conf->sensors[i].registers;
+ t_hot = omap_bandgap_readl(bg_ptr, tsr->bgap_status);
+ t_hot &= tsr->status_hot_mask;
+
+ /* Read the status of t_cold */
+ t_cold = omap_bandgap_readl(bg_ptr, tsr->bgap_status);
+ t_cold &= tsr->status_cold_mask;
+
+ if (!t_cold && !t_hot)
+ continue;
+
+ ctrl = omap_bandgap_readl(bg_ptr, tsr->bgap_mask_ctrl);
+ /*
+ * One TALERT interrupt: Two sources
+ * If the interrupt is due to t_hot then mask t_hot and
+ * and unmask t_cold else mask t_cold and unmask t_hot
+ */
+ if (t_hot) {
+ ctrl &= ~tsr->mask_hot_mask;
+ ctrl |= tsr->mask_cold_mask;
+ } else if (t_cold) {
+ ctrl &= ~tsr->mask_cold_mask;
+ ctrl |= tsr->mask_hot_mask;
+ }
+
+ omap_bandgap_writel(bg_ptr, ctrl, tsr->bgap_mask_ctrl);
+
+ /* read temperature */
+ temp = omap_bandgap_readl(bg_ptr, tsr->temp_sensor_ctrl);
+ temp &= tsr->bgap_dtemp_mask;
+
+ /* report temperature to whom may concern */
+ if (bg_ptr->conf->report_temperature)
+ bg_ptr->conf->report_temperature(bg_ptr, i);
+ }
+
+ return IRQ_HANDLED;
+}
+
+/* This is the Tshut handler. Call it only if HAS(TSHUT) is set */
+static irqreturn_t omap_bandgap_tshut_irq_handler(int irq, void *data)
+{
+ orderly_poweroff(true);
+
+ return IRQ_HANDLED;
+}
+
+static
+int adc_to_temp_conversion(struct omap_bandgap *bg_ptr, int id, int adc_val,
+ int *t)
+{
+ struct temp_sensor_data *ts_data = bg_ptr->conf->sensors[id].ts_data;
+
+ /* look up for temperature in the table and return the temperature */
+ if (adc_val < ts_data->adc_start_val || adc_val > ts_data->adc_end_val)
+ return -ERANGE;
+
+ *t = bg_ptr->conv_table[adc_val - ts_data->adc_start_val];
+
+ return 0;
+}
+
+static int temp_to_adc_conversion(long temp, struct omap_bandgap *bg_ptr, int i,
+ int *adc)
+{
+ struct temp_sensor_data *ts_data = bg_ptr->conf->sensors[i].ts_data;
+ int high, low, mid;
+
+ low = 0;
+ high = ts_data->adc_end_val - ts_data->adc_start_val;
+ mid = (high + low) / 2;
+
+ if (temp < bg_ptr->conv_table[high] || temp > bg_ptr->conv_table[high])
+ return -EINVAL;
+
+ while (low < high) {
+ if (temp < bg_ptr->conv_table[mid])
+ high = mid - 1;
+ else
+ low = mid + 1;
+ mid = (low + high) / 2;
+ }
+
+ *adc = ts_data->adc_start_val + low;
+
+ return 0;
+}
+
+/* Talert masks. Call it only if HAS(TALERT) is set */
+static int temp_sensor_unmask_interrupts(struct omap_bandgap *bg_ptr, int id,
+ u32 t_hot, u32 t_cold)
+{
+ struct temp_sensor_registers *tsr;
+ u32 temp, reg_val;
+
+ /* Read the current on die temperature */
+ tsr = bg_ptr->conf->sensors[id].registers;
+ temp = omap_bandgap_readl(bg_ptr, tsr->temp_sensor_ctrl);
+ temp &= tsr->bgap_dtemp_mask;
+
+ reg_val = omap_bandgap_readl(bg_ptr, tsr->bgap_mask_ctrl);
+ if (temp < t_hot)
+ reg_val |= tsr->mask_hot_mask;
+ else
+ reg_val &= ~tsr->mask_hot_mask;
+
+ if (t_cold < temp)
+ reg_val |= tsr->mask_cold_mask;
+ else
+ reg_val &= ~tsr->mask_cold_mask;
+ omap_bandgap_writel(bg_ptr, reg_val, tsr->bgap_mask_ctrl);
+
+ return 0;
+}
+
+static
+int add_hyst(int adc_val, int hyst_val, struct omap_bandgap *bg_ptr, int i,
+ u32 *sum)
+{
+ int temp, ret;
+
+ ret = adc_to_temp_conversion(bg_ptr, i, adc_val, &temp);
+ if (ret < 0)
+ return ret;
+
+ temp += hyst_val;
+
+ return temp_to_adc_conversion(temp, bg_ptr, i, sum);
+}
+
+/* Talert Thot threshold. Call it only if HAS(TALERT) is set */
+static
+int temp_sensor_configure_thot(struct omap_bandgap *bg_ptr, int id, int t_hot)
+{
+ struct temp_sensor_data *ts_data = bg_ptr->conf->sensors[id].ts_data;
+ struct temp_sensor_registers *tsr;
+ u32 thresh_val, reg_val;
+ int cold, err = 0;
+
+ tsr = bg_ptr->conf->sensors[id].registers;
+
+ /* obtain the T cold value */
+ thresh_val = omap_bandgap_readl(bg_ptr, tsr->bgap_threshold);
+ cold = (thresh_val & tsr->threshold_tcold_mask) >>
+ __ffs(tsr->threshold_tcold_mask);
+ if (t_hot <= cold) {
+ /* change the t_cold to t_hot - 5000 millidegrees */
+ err |= add_hyst(t_hot, -ts_data->hyst_val, bg_ptr, id, &cold);
+ /* write the new t_cold value */
+ reg_val = thresh_val & (~tsr->threshold_tcold_mask);
+ reg_val |= cold << __ffs(tsr->threshold_tcold_mask);
+ omap_bandgap_writel(bg_ptr, reg_val, tsr->bgap_threshold);
+ thresh_val = reg_val;
+ }
+
+ /* write the new t_hot value */
+ reg_val = thresh_val & ~tsr->threshold_thot_mask;
+ reg_val |= (t_hot << __ffs(tsr->threshold_thot_mask));
+ omap_bandgap_writel(bg_ptr, reg_val, tsr->bgap_threshold);
+ if (err) {
+ dev_err(bg_ptr->dev, "failed to reprogram thot threshold\n");
+ return -EIO;
+ }
+
+ return temp_sensor_unmask_interrupts(bg_ptr, id, t_hot, cold);
+}
+
+/* Talert Thot and Tcold thresholds. Call it only if HAS(TALERT) is set */
+static
+int temp_sensor_init_talert_thresholds(struct omap_bandgap *bg_ptr, int id,
+ int t_hot, int t_cold)
+{
+ struct temp_sensor_registers *tsr;
+ u32 reg_val, thresh_val;
+
+ tsr = bg_ptr->conf->sensors[id].registers;
+ thresh_val = omap_bandgap_readl(bg_ptr, tsr->bgap_threshold);
+
+ /* write the new t_cold value */
+ reg_val = thresh_val & ~tsr->threshold_tcold_mask;
+ reg_val |= (t_cold << __ffs(tsr->threshold_tcold_mask));
+ omap_bandgap_writel(bg_ptr, reg_val, tsr->bgap_threshold);
+
+ thresh_val = omap_bandgap_readl(bg_ptr, tsr->bgap_threshold);
+
+ /* write the new t_hot value */
+ reg_val = thresh_val & ~tsr->threshold_thot_mask;
+ reg_val |= (t_hot << __ffs(tsr->threshold_thot_mask));
+ omap_bandgap_writel(bg_ptr, reg_val, tsr->bgap_threshold);
+
+ reg_val = omap_bandgap_readl(bg_ptr, tsr->bgap_mask_ctrl);
+ reg_val |= tsr->mask_hot_mask;
+ reg_val |= tsr->mask_cold_mask;
+ omap_bandgap_writel(bg_ptr, reg_val, tsr->bgap_mask_ctrl);
+
+ return 0;
+}
+
+/* Talert Tcold threshold. Call it only if HAS(TALERT) is set */
+static
+int temp_sensor_configure_tcold(struct omap_bandgap *bg_ptr, int id,
+ int t_cold)
+{
+ struct temp_sensor_data *ts_data = bg_ptr->conf->sensors[id].ts_data;
+ struct temp_sensor_registers *tsr;
+ u32 thresh_val, reg_val;
+ int hot, err = 0;
+
+ tsr = bg_ptr->conf->sensors[id].registers;
+ /* obtain the T cold value */
+ thresh_val = omap_bandgap_readl(bg_ptr, tsr->bgap_threshold);
+ hot = (thresh_val & tsr->threshold_thot_mask) >>
+ __ffs(tsr->threshold_thot_mask);
+
+ if (t_cold >= hot) {
+ /* change the t_hot to t_cold + 5000 millidegrees */
+ err |= add_hyst(t_cold, ts_data->hyst_val, bg_ptr, id, &hot);
+ /* write the new t_hot value */
+ reg_val = thresh_val & (~tsr->threshold_thot_mask);
+ reg_val |= hot << __ffs(tsr->threshold_thot_mask);
+ omap_bandgap_writel(bg_ptr, reg_val, tsr->bgap_threshold);
+ thresh_val = reg_val;
+ }
+
+ /* write the new t_cold value */
+ reg_val = thresh_val & ~tsr->threshold_tcold_mask;
+ reg_val |= (t_cold << __ffs(tsr->threshold_tcold_mask));
+ omap_bandgap_writel(bg_ptr, reg_val, tsr->bgap_threshold);
+ if (err) {
+ dev_err(bg_ptr->dev, "failed to reprogram tcold threshold\n");
+ return -EIO;
+ }
+
+ return temp_sensor_unmask_interrupts(bg_ptr, id, hot, t_cold);
+}
+
+/* This is Tshut Thot config. Call it only if HAS(TSHUT_CONFIG) is set */
+static int temp_sensor_configure_tshut_hot(struct omap_bandgap *bg_ptr,
+ int id, int tshut_hot)
+{
+ struct temp_sensor_registers *tsr;
+ u32 reg_val;
+
+ tsr = bg_ptr->conf->sensors[id].registers;
+ reg_val = omap_bandgap_readl(bg_ptr, tsr->tshut_threshold);
+ reg_val &= ~tsr->tshut_hot_mask;
+ reg_val |= tshut_hot << __ffs(tsr->tshut_hot_mask);
+ omap_bandgap_writel(bg_ptr, reg_val, tsr->tshut_threshold);
+
+ return 0;
+}
+
+/* This is Tshut Tcold config. Call it only if HAS(TSHUT_CONFIG) is set */
+static int temp_sensor_configure_tshut_cold(struct omap_bandgap *bg_ptr,
+ int id, int tshut_cold)
+{
+ struct temp_sensor_registers *tsr;
+ u32 reg_val;
+
+ tsr = bg_ptr->conf->sensors[id].registers;
+ reg_val = omap_bandgap_readl(bg_ptr, tsr->tshut_threshold);
+ reg_val &= ~tsr->tshut_cold_mask;
+ reg_val |= tshut_cold << __ffs(tsr->tshut_cold_mask);
+ omap_bandgap_writel(bg_ptr, reg_val, tsr->tshut_threshold);
+
+ return 0;
+}
+
+/* This is counter config. Call it only if HAS(COUNTER) is set */
+static int configure_temp_sensor_counter(struct omap_bandgap *bg_ptr, int id,
+ u32 counter)
+{
+ struct temp_sensor_registers *tsr;
+ u32 val;
+
+ tsr = bg_ptr->conf->sensors[id].registers;
+ val = omap_bandgap_readl(bg_ptr, tsr->bgap_counter);
+ val &= ~tsr->counter_mask;
+ val |= counter << __ffs(tsr->counter_mask);
+ omap_bandgap_writel(bg_ptr, val, tsr->bgap_counter);
+
+ return 0;
+}
+
+#define bandgap_is_valid(b) \
+ (!IS_ERR_OR_NULL(b))
+#define bandgap_is_valid_sensor_id(b, i) \
+ ((i) >= 0 && (i) < (b)->conf->sensor_count)
+static inline int omap_bandgap_validate(struct omap_bandgap *bg_ptr, int id)
+{
+ if (!bandgap_is_valid(bg_ptr)) {
+ pr_err("%s: invalid bandgap pointer\n", __func__);
+ return -EINVAL;
+ }
+
+ if (!bandgap_is_valid_sensor_id(bg_ptr, id)) {
+ dev_err(bg_ptr->dev, "%s: sensor id out of range (%d)\n",
+ __func__, id);
+ return -ERANGE;
+ }
+
+ return 0;
+}
+
+/* Exposed APIs */
+/**
+ * omap_bandgap_read_thot() - reads sensor current thot
+ * @bg_ptr - pointer to bandgap instance
+ * @id - sensor id
+ * @thot - resulting current thot value
+ *
+ * returns 0 on success or the proper error code
+ */
+int omap_bandgap_read_thot(struct omap_bandgap *bg_ptr, int id,
+ int *thot)
+{
+ struct temp_sensor_registers *tsr;
+ u32 temp;
+ int ret;
+
+ ret = omap_bandgap_validate(bg_ptr, id);
+ if (ret)
+ return ret;
+
+ if (!OMAP_BANDGAP_HAS(bg_ptr, TALERT))
+ return -ENOTSUPP;
+
+ tsr = bg_ptr->conf->sensors[id].registers;
+ temp = omap_bandgap_readl(bg_ptr, tsr->bgap_threshold);
+ temp = (temp & tsr->threshold_thot_mask) >>
+ __ffs(tsr->threshold_thot_mask);
+ ret |= adc_to_temp_conversion(bg_ptr, id, temp, &temp);
+ if (ret) {
+ dev_err(bg_ptr->dev, "failed to read thot\n");
+ return -EIO;
+ }
+
+ *thot = temp;
+
+ return 0;
+}
+
+/**
+ * omap_bandgap_write_thot() - sets sensor current thot
+ * @bg_ptr - pointer to bandgap instance
+ * @id - sensor id
+ * @val - desired thot value
+ *
+ * returns 0 on success or the proper error code
+ */
+int omap_bandgap_write_thot(struct omap_bandgap *bg_ptr, int id, int val)
+{
+ struct temp_sensor_data *ts_data;
+ struct temp_sensor_registers *tsr;
+ u32 t_hot;
+ int ret;
+
+ ret = omap_bandgap_validate(bg_ptr, id);
+ if (ret)
+ return ret;
+
+ if (!OMAP_BANDGAP_HAS(bg_ptr, TALERT))
+ return -ENOTSUPP;
+
+ ts_data = bg_ptr->conf->sensors[id].ts_data;
+ tsr = bg_ptr->conf->sensors[id].registers;
+
+ if (val < ts_data->min_temp + ts_data->hyst_val)
+ return -EINVAL;
+ ret = temp_to_adc_conversion(val, bg_ptr, id, &t_hot);
+ if (ret < 0)
+ return ret;
+
+ mutex_lock(&bg_ptr->bg_mutex);
+ temp_sensor_configure_thot(bg_ptr, id, t_hot);
+ mutex_unlock(&bg_ptr->bg_mutex);
+
+ return 0;
+}
+
+/**
+ * omap_bandgap_read_tcold() - reads sensor current tcold
+ * @bg_ptr - pointer to bandgap instance
+ * @id - sensor id
+ * @tcold - resulting current tcold value
+ *
+ * returns 0 on success or the proper error code
+ */
+int omap_bandgap_read_tcold(struct omap_bandgap *bg_ptr, int id,
+ int *tcold)
+{
+ struct temp_sensor_registers *tsr;
+ u32 temp;
+ int ret;
+
+ ret = omap_bandgap_validate(bg_ptr, id);
+ if (ret)
+ return ret;
+
+ if (!OMAP_BANDGAP_HAS(bg_ptr, TALERT))
+ return -ENOTSUPP;
+
+ tsr = bg_ptr->conf->sensors[id].registers;
+ temp = omap_bandgap_readl(bg_ptr, tsr->bgap_threshold);
+ temp = (temp & tsr->threshold_tcold_mask)
+ >> __ffs(tsr->threshold_tcold_mask);
+ ret |= adc_to_temp_conversion(bg_ptr, id, temp, &temp);
+ if (ret)
+ return -EIO;
+
+ *tcold = temp;
+
+ return 0;
+}
+
+/**
+ * omap_bandgap_write_tcold() - sets the sensor tcold
+ * @bg_ptr - pointer to bandgap instance
+ * @id - sensor id
+ * @val - desired tcold value
+ *
+ * returns 0 on success or the proper error code
+ */
+int omap_bandgap_write_tcold(struct omap_bandgap *bg_ptr, int id, int val)
+{
+ struct temp_sensor_data *ts_data;
+ struct temp_sensor_registers *tsr;
+ u32 t_cold;
+ int ret;
+
+ ret = omap_bandgap_validate(bg_ptr, id);
+ if (ret)
+ return ret;
+
+ if (!OMAP_BANDGAP_HAS(bg_ptr, TALERT))
+ return -ENOTSUPP;
+
+ ts_data = bg_ptr->conf->sensors[id].ts_data;
+ tsr = bg_ptr->conf->sensors[id].registers;
+ if (val > ts_data->max_temp + ts_data->hyst_val)
+ return -EINVAL;
+
+ ret = temp_to_adc_conversion(val, bg_ptr, id, &t_cold);
+ if (ret < 0)
+ return ret;
+
+ mutex_lock(&bg_ptr->bg_mutex);
+ temp_sensor_configure_tcold(bg_ptr, id, t_cold);
+ mutex_unlock(&bg_ptr->bg_mutex);
+
+ return 0;
+}
+
+/**
+ * omap_bandgap_read_update_interval() - read the sensor update interval
+ * @bg_ptr - pointer to bandgap instance
+ * @id - sensor id
+ * @interval - resulting update interval in miliseconds
+ *
+ * returns 0 on success or the proper error code
+ */
+int omap_bandgap_read_update_interval(struct omap_bandgap *bg_ptr, int id,
+ int *interval)
+{
+ struct temp_sensor_registers *tsr;
+ u32 time;
+ int ret;
+
+ ret = omap_bandgap_validate(bg_ptr, id);
+ if (ret)
+ return ret;
+
+ if (!OMAP_BANDGAP_HAS(bg_ptr, COUNTER))
+ return -ENOTSUPP;
+
+ tsr = bg_ptr->conf->sensors[id].registers;
+ time = omap_bandgap_readl(bg_ptr, tsr->bgap_counter);
+ if (ret)
+ return ret;
+ time = (time & tsr->counter_mask) >> __ffs(tsr->counter_mask);
+ time = time * 1000 / bg_ptr->clk_rate;
+
+ *interval = time;
+
+ return 0;
+}
+
+/**
+ * omap_bandgap_write_update_interval() - set the update interval
+ * @bg_ptr - pointer to bandgap instance
+ * @id - sensor id
+ * @interval - desired update interval in miliseconds
+ *
+ * returns 0 on success or the proper error code
+ */
+int omap_bandgap_write_update_interval(struct omap_bandgap *bg_ptr,
+ int id, u32 interval)
+{
+ int ret = omap_bandgap_validate(bg_ptr, id);
+ if (ret)
+ return ret;
+
+ if (!OMAP_BANDGAP_HAS(bg_ptr, COUNTER))
+ return -ENOTSUPP;
+
+ interval = interval * bg_ptr->clk_rate / 1000;
+ mutex_lock(&bg_ptr->bg_mutex);
+ configure_temp_sensor_counter(bg_ptr, id, interval);
+ mutex_unlock(&bg_ptr->bg_mutex);
+
+ return 0;
+}
+
+/**
+ * omap_bandgap_read_temperature() - report current temperature
+ * @bg_ptr - pointer to bandgap instance
+ * @id - sensor id
+ * @temperature - resulting temperature
+ *
+ * returns 0 on success or the proper error code
+ */
+int omap_bandgap_read_temperature(struct omap_bandgap *bg_ptr, int id,
+ int *temperature)
+{
+ struct temp_sensor_registers *tsr;
+ u32 temp;
+ int ret;
+
+ ret = omap_bandgap_validate(bg_ptr, id);
+ if (ret)
+ return ret;
+
+ tsr = bg_ptr->conf->sensors[id].registers;
+ temp = omap_bandgap_readl(bg_ptr, tsr->temp_sensor_ctrl);
+ temp &= tsr->bgap_dtemp_mask;
+
+ ret |= adc_to_temp_conversion(bg_ptr, id, temp, &temp);
+ if (ret)
+ return -EIO;
+
+ *temperature = temp;
+
+ return 0;
+}
+
+/**
+ * omap_bandgap_set_sensor_data() - helper function to store thermal
+ * framework related data.
+ * @bg_ptr - pointer to bandgap instance
+ * @id - sensor id
+ * @data - thermal framework related data to be stored
+ *
+ * returns 0 on success or the proper error code
+ */
+int omap_bandgap_set_sensor_data(struct omap_bandgap *bg_ptr, int id,
+ void *data)
+{
+ int ret = omap_bandgap_validate(bg_ptr, id);
+ if (ret)
+ return ret;
+
+ bg_ptr->conf->sensors[id].data = data;
+
+ return 0;
+}
+
+/**
+ * omap_bandgap_get_sensor_data() - helper function to get thermal
+ * framework related data.
+ * @bg_ptr - pointer to bandgap instance
+ * @id - sensor id
+ *
+ * returns data stored by set function with sensor id on success or NULL
+ */
+void *omap_bandgap_get_sensor_data(struct omap_bandgap *bg_ptr, int id)
+{
+ int ret = omap_bandgap_validate(bg_ptr, id);
+ if (ret)
+ return ERR_PTR(ret);
+
+ return bg_ptr->conf->sensors[id].data;
+}
+
+static int
+omap_bandgap_force_single_read(struct omap_bandgap *bg_ptr, int id)
+{
+ struct temp_sensor_registers *tsr;
+ u32 temp = 0, counter = 1000;
+
+ tsr = bg_ptr->conf->sensors[id].registers;
+ /* Select single conversion mode */
+ if (OMAP_BANDGAP_HAS(bg_ptr, MODE_CONFIG)) {
+ temp = omap_bandgap_readl(bg_ptr, tsr->bgap_mode_ctrl);
+ temp &= ~(1 << __ffs(tsr->mode_ctrl_mask));
+ omap_bandgap_writel(bg_ptr, temp, tsr->bgap_mode_ctrl);
+ }
+
+ /* Start of Conversion = 1 */
+ temp = omap_bandgap_readl(bg_ptr, tsr->temp_sensor_ctrl);
+ temp |= 1 << __ffs(tsr->bgap_soc_mask);
+ omap_bandgap_writel(bg_ptr, temp, tsr->temp_sensor_ctrl);
+ /* Wait until DTEMP is updated */
+ temp = omap_bandgap_readl(bg_ptr, tsr->temp_sensor_ctrl);
+ temp &= (tsr->bgap_dtemp_mask);
+ while ((temp == 0) && --counter) {
+ temp = omap_bandgap_readl(bg_ptr, tsr->temp_sensor_ctrl);
+ temp &= (tsr->bgap_dtemp_mask);
+ }
+ /* Start of Conversion = 0 */
+ temp = omap_bandgap_readl(bg_ptr, tsr->temp_sensor_ctrl);
+ temp &= ~(1 << __ffs(tsr->bgap_soc_mask));
+ omap_bandgap_writel(bg_ptr, temp, tsr->temp_sensor_ctrl);
+
+ return 0;
+}
+
+/**
+ * enable_continuous_mode() - One time enabling of continuous conversion mode
+ * @bg_ptr - pointer to scm instance
+ *
+ * Call this function only if HAS(MODE_CONFIG) is set
+ */
+static int enable_continuous_mode(struct omap_bandgap *bg_ptr)
+{
+ struct temp_sensor_registers *tsr;
+ int i;
+ u32 val;
+
+ for (i = 0; i < bg_ptr->conf->sensor_count; i++) {
+ /* Perform a single read just before enabling continuous */
+ omap_bandgap_force_single_read(bg_ptr, i);
+ tsr = bg_ptr->conf->sensors[i].registers;
+ val = omap_bandgap_readl(bg_ptr, tsr->bgap_mode_ctrl);
+ val |= 1 << __ffs(tsr->mode_ctrl_mask);
+ omap_bandgap_writel(bg_ptr, val, tsr->bgap_mode_ctrl);
+ }
+
+ return 0;
+}
+
+static int omap_bandgap_tshut_init(struct omap_bandgap *bg_ptr,
+ struct platform_device *pdev)
+{
+ int gpio_nr = bg_ptr->tshut_gpio;
+ int status;
+
+ /* Request for gpio_86 line */
+ status = gpio_request(gpio_nr, "tshut");
+ if (status < 0) {
+ dev_err(bg_ptr->dev,
+ "Could not request for TSHUT GPIO:%i\n", 86);
+ return status;
+ }
+ status = gpio_direction_input(gpio_nr);
+ if (status) {
+ dev_err(bg_ptr->dev,
+ "Cannot set input TSHUT GPIO %d\n", gpio_nr);
+ return status;
+ }
+
+ status = request_irq(gpio_to_irq(gpio_nr),
+ omap_bandgap_tshut_irq_handler,
+ IRQF_TRIGGER_RISING, "tshut",
+ NULL);
+ if (status) {
+ gpio_free(gpio_nr);
+ dev_err(bg_ptr->dev, "request irq failed for TSHUT");
+ }
+
+ return 0;
+}
+
+/* Initialization of Talert. Call it only if HAS(TALERT) is set */
+static int omap_bandgap_talert_init(struct omap_bandgap *bg_ptr,
+ struct platform_device *pdev)
+{
+ int ret;
+
+ bg_ptr->irq = platform_get_irq(pdev, 0);
+ if (bg_ptr->irq < 0) {
+ dev_err(&pdev->dev, "get_irq failed\n");
+ return bg_ptr->irq;
+ }
+ ret = request_threaded_irq(bg_ptr->irq, NULL,
+ talert_irq_handler,
+ IRQF_TRIGGER_HIGH | IRQF_ONESHOT,
+ "talert", bg_ptr);
+ if (ret) {
+ dev_err(&pdev->dev, "Request threaded irq failed.\n");
+ return ret;
+ }
+
+ return 0;
+}
+
+static const struct of_device_id of_omap_bandgap_match[];
+static struct omap_bandgap *omap_bandgap_build(struct platform_device *pdev)
+{
+ struct device_node *node = pdev->dev.of_node;
+ const struct of_device_id *of_id;
+ struct omap_bandgap *bg_ptr;
+ struct resource *res;
+ u32 prop;
+ int i;
+
+ /* just for the sake */
+ if (!node) {
+ dev_err(&pdev->dev, "no platform information available\n");
+ return ERR_PTR(-EINVAL);
+ }
+
+ bg_ptr = devm_kzalloc(&pdev->dev, sizeof(struct omap_bandgap),
+ GFP_KERNEL);
+ if (!bg_ptr) {
+ dev_err(&pdev->dev, "Unable to allocate mem for driver ref\n");
+ return ERR_PTR(-ENOMEM);
+ }
+
+ of_id = of_match_device(of_omap_bandgap_match, &pdev->dev);
+ if (of_id)
+ bg_ptr->conf = of_id->data;
+
+ i = 0;
+ do {
+ void __iomem *chunk;
+
+ res = platform_get_resource(pdev, IORESOURCE_MEM, i);
+ if (!res)
+ break;
+ chunk = devm_request_and_ioremap(&pdev->dev, res);
+ if (i == 0)
+ bg_ptr->base = chunk;
+ if (!chunk) {
+ dev_err(&pdev->dev,
+ "failed to request the IO (%d:%pR).\n",
+ i, res);
+ return ERR_PTR(-EADDRNOTAVAIL);
+ }
+ i++;
+ } while (res);
+
+ if (OMAP_BANDGAP_HAS(bg_ptr, TSHUT)) {
+ if (of_property_read_u32(node, "ti,tshut-gpio", &prop) < 0) {
+ dev_err(&pdev->dev, "missing tshut gpio in device tree\n");
+ return ERR_PTR(-EINVAL);
+ }
+ bg_ptr->tshut_gpio = prop;
+ if (!gpio_is_valid(bg_ptr->tshut_gpio)) {
+ dev_err(&pdev->dev, "invalid gpio for tshut (%d)\n",
+ bg_ptr->tshut_gpio);
+ return ERR_PTR(-EINVAL);
+ }
+ }
+
+ return bg_ptr;
+}
+
+static
+int __devinit omap_bandgap_probe(struct platform_device *pdev)
+{
+ struct omap_bandgap *bg_ptr;
+ int clk_rate, ret = 0, i;
+
+ bg_ptr = omap_bandgap_build(pdev);
+ if (IS_ERR_OR_NULL(bg_ptr)) {
+ dev_err(&pdev->dev, "failed to fetch platform data\n");
+ return PTR_ERR(bg_ptr);
+ }
+ bg_ptr->dev = &pdev->dev;
+
+ if (OMAP_BANDGAP_HAS(bg_ptr, TSHUT)) {
+ ret = omap_bandgap_tshut_init(bg_ptr, pdev);
+ if (ret) {
+ dev_err(&pdev->dev,
+ "failed to initialize system tshut IRQ\n");
+ return ret;
+ }
+ }
+
+ bg_ptr->fclock = clk_get(NULL, bg_ptr->conf->fclock_name);
+ ret = IS_ERR_OR_NULL(bg_ptr->fclock);
+ if (ret) {
+ dev_err(&pdev->dev, "failed to request fclock reference\n");
+ goto free_irqs;
+ }
+
+ bg_ptr->div_clk = clk_get(NULL, bg_ptr->conf->div_ck_name);
+ ret = IS_ERR_OR_NULL(bg_ptr->div_clk);
+ if (ret) {
+ dev_err(&pdev->dev,
+ "failed to request div_ts_ck clock ref\n");
+ goto free_irqs;
+ }
+
+ bg_ptr->conv_table = bg_ptr->conf->conv_table;
+ for (i = 0; i < bg_ptr->conf->sensor_count; i++) {
+ struct temp_sensor_registers *tsr;
+ u32 val;
+
+ tsr = bg_ptr->conf->sensors[i].registers;
+ /*
+ * check if the efuse has a non-zero value if not
+ * it is an untrimmed sample and the temperatures
+ * may not be accurate
+ */
+ val = omap_bandgap_readl(bg_ptr, tsr->bgap_efuse);
+ if (ret || !val)
+ dev_info(&pdev->dev,
+ "Non-trimmed BGAP, Temp not accurate\n");
+ }
+
+ clk_rate = clk_round_rate(bg_ptr->div_clk,
+ bg_ptr->conf->sensors[0].ts_data->max_freq);
+ if (clk_rate < bg_ptr->conf->sensors[0].ts_data->min_freq ||
+ clk_rate == 0xffffffff) {
+ ret = -ENODEV;
+ dev_err(&pdev->dev, "wrong clock rate (%d)\n", clk_rate);
+ goto put_clks;
+ }
+
+ ret = clk_set_rate(bg_ptr->div_clk, clk_rate);
+ if (ret)
+ dev_err(&pdev->dev, "Cannot re-set clock rate. Continuing\n");
+
+ bg_ptr->clk_rate = clk_rate;
+ clk_enable(bg_ptr->fclock);
+
+ mutex_init(&bg_ptr->bg_mutex);
+ bg_ptr->dev = &pdev->dev;
+ platform_set_drvdata(pdev, bg_ptr);
+
+ omap_bandgap_power(bg_ptr, true);
+
+ /* Set default counter to 1 for now */
+ if (OMAP_BANDGAP_HAS(bg_ptr, COUNTER))
+ for (i = 0; i < bg_ptr->conf->sensor_count; i++)
+ configure_temp_sensor_counter(bg_ptr, i, 1);
+
+ for (i = 0; i < bg_ptr->conf->sensor_count; i++) {
+ struct temp_sensor_data *ts_data;
+
+ ts_data = bg_ptr->conf->sensors[i].ts_data;
+
+ if (OMAP_BANDGAP_HAS(bg_ptr, TALERT))
+ temp_sensor_init_talert_thresholds(bg_ptr, i,
+ ts_data->t_hot,
+ ts_data->t_cold);
+ if (OMAP_BANDGAP_HAS(bg_ptr, TSHUT_CONFIG)) {
+ temp_sensor_configure_tshut_hot(bg_ptr, i,
+ ts_data->tshut_hot);
+ temp_sensor_configure_tshut_cold(bg_ptr, i,
+ ts_data->tshut_cold);
+ }
+ }
+
+ if (OMAP_BANDGAP_HAS(bg_ptr, MODE_CONFIG))
+ enable_continuous_mode(bg_ptr);
+
+ /* Set .250 seconds time as default counter */
+ if (OMAP_BANDGAP_HAS(bg_ptr, COUNTER))
+ for (i = 0; i < bg_ptr->conf->sensor_count; i++)
+ configure_temp_sensor_counter(bg_ptr, i,
+ bg_ptr->clk_rate / 4);
+
+ /* Every thing is good? Then expose the sensors */
+ for (i = 0; i < bg_ptr->conf->sensor_count; i++) {
+ char *domain;
+
+ domain = bg_ptr->conf->sensors[i].domain;
+ if (bg_ptr->conf->expose_sensor)
+ bg_ptr->conf->expose_sensor(bg_ptr, i, domain);
+
+ if (bg_ptr->conf->sensors[i].register_cooling)
+ bg_ptr->conf->sensors[i].register_cooling(bg_ptr, i);
+ }
+
+ /*
+ * Enable the Interrupts once everything is set. Otherwise irq handler
+ * might be called as soon as it is enabled where as rest of framework
+ * is still getting initialised.
+ */
+ if (OMAP_BANDGAP_HAS(bg_ptr, TALERT)) {
+ ret = omap_bandgap_talert_init(bg_ptr, pdev);
+ if (ret) {
+ dev_err(&pdev->dev, "failed to initialize Talert IRQ\n");
+ i = bg_ptr->conf->sensor_count;
+ goto disable_clk;
+ }
+ }
+
+ return 0;
+
+disable_clk:
+ clk_disable(bg_ptr->fclock);
+put_clks:
+ clk_put(bg_ptr->fclock);
+ clk_put(bg_ptr->div_clk);
+free_irqs:
+ if (OMAP_BANDGAP_HAS(bg_ptr, TSHUT)) {
+ free_irq(gpio_to_irq(bg_ptr->tshut_gpio), NULL);
+ gpio_free(bg_ptr->tshut_gpio);
+ }
+
+ return ret;
+}
+
+static
+int __devexit omap_bandgap_remove(struct platform_device *pdev)
+{
+ struct omap_bandgap *bg_ptr = platform_get_drvdata(pdev);
+ int i;
+
+ /* First thing is to remove sensor interfaces */
+ for (i = 0; i < bg_ptr->conf->sensor_count; i++) {
+ if (bg_ptr->conf->sensors[i].register_cooling)
+ bg_ptr->conf->sensors[i].unregister_cooling(bg_ptr, i);
+
+ if (bg_ptr->conf->remove_sensor)
+ bg_ptr->conf->remove_sensor(bg_ptr, i);
+ }
+
+ omap_bandgap_power(bg_ptr, false);
+
+ clk_disable(bg_ptr->fclock);
+ clk_put(bg_ptr->fclock);
+ clk_put(bg_ptr->div_clk);
+
+ if (OMAP_BANDGAP_HAS(bg_ptr, TALERT))
+ free_irq(bg_ptr->irq, bg_ptr);
+
+ if (OMAP_BANDGAP_HAS(bg_ptr, TSHUT)) {
+ free_irq(gpio_to_irq(bg_ptr->tshut_gpio), NULL);
+ gpio_free(bg_ptr->tshut_gpio);
+ }
+
+ return 0;
+}
+
+#ifdef CONFIG_PM
+static int omap_bandgap_save_ctxt(struct omap_bandgap *bg_ptr)
+{
+ int i;
+
+ for (i = 0; i < bg_ptr->conf->sensor_count; i++) {
+ struct temp_sensor_registers *tsr;
+ struct temp_sensor_regval *rval;
+
+ rval = &bg_ptr->conf->sensors[i].regval;
+ tsr = bg_ptr->conf->sensors[i].registers;
+
+ if (OMAP_BANDGAP_HAS(bg_ptr, MODE_CONFIG))
+ rval->bg_mode_ctrl = omap_bandgap_readl(bg_ptr,
+ tsr->bgap_mode_ctrl);
+ if (OMAP_BANDGAP_HAS(bg_ptr, COUNTER))
+ rval->bg_counter = omap_bandgap_readl(bg_ptr,
+ tsr->bgap_counter);
+ if (OMAP_BANDGAP_HAS(bg_ptr, TALERT)) {
+ rval->bg_threshold = omap_bandgap_readl(bg_ptr,
+ tsr->bgap_threshold);
+ rval->bg_ctrl = omap_bandgap_readl(bg_ptr,
+ tsr->bgap_mask_ctrl);
+ }
+
+ if (OMAP_BANDGAP_HAS(bg_ptr, TSHUT_CONFIG))
+ rval->tshut_threshold = omap_bandgap_readl(bg_ptr,
+ tsr->tshut_threshold);
+ }
+
+ return 0;
+}
+
+static int omap_bandgap_restore_ctxt(struct omap_bandgap *bg_ptr)
+{
+ int i;
+ u32 temp = 0;
+
+ for (i = 0; i < bg_ptr->conf->sensor_count; i++) {
+ struct temp_sensor_registers *tsr;
+ struct temp_sensor_regval *rval;
+ u32 val = 0;
+
+ rval = &bg_ptr->conf->sensors[i].regval;
+ tsr = bg_ptr->conf->sensors[i].registers;
+
+ if (OMAP_BANDGAP_HAS(bg_ptr, COUNTER))
+ val = omap_bandgap_readl(bg_ptr, tsr->bgap_counter);
+
+ if (val == 0) {
+ if (OMAP_BANDGAP_HAS(bg_ptr, TSHUT_CONFIG))
+ omap_bandgap_writel(bg_ptr, rval->tshut_threshold,
+ tsr->tshut_threshold);
+ /* Force immediate temperature measurement and update
+ * of the DTEMP field
+ */
+ omap_bandgap_force_single_read(bg_ptr, i);
+
+ if (OMAP_BANDGAP_HAS(bg_ptr, COUNTER))
+ omap_bandgap_writel(bg_ptr, rval->bg_counter,
+ tsr->bgap_counter);
+ if (OMAP_BANDGAP_HAS(bg_ptr, MODE_CONFIG))
+ omap_bandgap_writel(bg_ptr, rval->bg_mode_ctrl,
+ tsr->bgap_mode_ctrl);
+ if (OMAP_BANDGAP_HAS(bg_ptr, TALERT)) {
+ omap_bandgap_writel(bg_ptr,
+ rval->bg_threshold,
+ tsr->bgap_threshold);
+ omap_bandgap_writel(bg_ptr, rval->bg_ctrl,
+ tsr->bgap_mask_ctrl);
+ }
+ } else {
+ temp = omap_bandgap_readl(bg_ptr,
+ tsr->temp_sensor_ctrl);
+ temp &= (tsr->bgap_dtemp_mask);
+ omap_bandgap_force_single_read(bg_ptr, i);
+ if (temp == 0 && OMAP_BANDGAP_HAS(bg_ptr, TALERT)) {
+ temp = omap_bandgap_readl(bg_ptr,
+ tsr->bgap_mask_ctrl);
+ temp |= 1 << __ffs(tsr->mode_ctrl_mask);
+ omap_bandgap_writel(bg_ptr, temp,
+ tsr->bgap_mask_ctrl);
+ }
+ }
+ }
+
+ return 0;
+}
+
+static int omap_bandgap_suspend(struct device *dev)
+{
+ struct omap_bandgap *bg_ptr = dev_get_drvdata(dev);
+ int err;
+
+ err = omap_bandgap_save_ctxt(bg_ptr);
+ omap_bandgap_power(bg_ptr, false);
+ clk_disable(bg_ptr->fclock);
+
+ return err;
+}
+
+static int omap_bandgap_resume(struct device *dev)
+{
+ struct omap_bandgap *bg_ptr = dev_get_drvdata(dev);
+
+ clk_enable(bg_ptr->fclock);
+ omap_bandgap_power(bg_ptr, true);
+
+ return omap_bandgap_restore_ctxt(bg_ptr);
+}
+static const struct dev_pm_ops omap_bandgap_dev_pm_ops = {
+ SET_SYSTEM_SLEEP_PM_OPS(omap_bandgap_suspend,
+ omap_bandgap_resume)
+};
+
+#define DEV_PM_OPS (&omap_bandgap_dev_pm_ops)
+#else
+#define DEV_PM_OPS NULL
+#endif
+
+static const struct of_device_id of_omap_bandgap_match[] = {
+#ifdef CONFIG_OMAP4_THERMAL
+ {
+ .compatible = "ti,omap4430-bandgap",
+ .data = (void *)&omap4430_data,
+ },
+ {
+ .compatible = "ti,omap4460-bandgap",
+ .data = (void *)&omap4460_data,
+ },
+ {
+ .compatible = "ti,omap4470-bandgap",
+ .data = (void *)&omap4470_data,
+ },
+#endif
+#ifdef CONFIG_OMAP5_THERMAL
+ {
+ .compatible = "ti,omap5430-bandgap",
+ .data = (void *)&omap5430_data,
+ },
+#endif
+ /* Sentinel */
+ { },
+};
+MODULE_DEVICE_TABLE(of, of_omap_bandgap_match);
+
+static struct platform_driver omap_bandgap_sensor_driver = {
+ .probe = omap_bandgap_probe,
+ .remove = omap_bandgap_remove,
+ .driver = {
+ .name = "omap-bandgap",
+ .pm = DEV_PM_OPS,
+ .of_match_table = of_omap_bandgap_match,
+ },
+};
+
+module_platform_driver(omap_bandgap_sensor_driver);
+
+MODULE_DESCRIPTION("OMAP4+ bandgap temperature sensor driver");
+MODULE_LICENSE("GPL v2");
+MODULE_ALIAS("platform:omap-bandgap");
+MODULE_AUTHOR("Texas Instrument Inc.");
diff --git a/drivers/staging/omap-thermal/omap-bandgap.h b/drivers/staging/omap-thermal/omap-bandgap.h
new file mode 100644
index 000000000000..78aed7535f47
--- /dev/null
+++ b/drivers/staging/omap-thermal/omap-bandgap.h
@@ -0,0 +1,441 @@
+/*
+ * OMAP4 Bandgap temperature sensor driver
+ *
+ * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
+ * Contact:
+ * Eduardo Valentin <eduardo.valentin@ti.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ *
+ */
+#ifndef __OMAP_BANDGAP_H
+#define __OMAP_BANDGAP_H
+
+#include <linux/mutex.h>
+#include <linux/types.h>
+#include <linux/err.h>
+
+/* TEMP_SENSOR OMAP4430 */
+#define OMAP4430_BGAP_TSHUT_SHIFT 11
+#define OMAP4430_BGAP_TSHUT_MASK (1 << 11)
+
+/* TEMP_SENSOR OMAP4430 */
+#define OMAP4430_BGAP_TEMPSOFF_SHIFT 12
+#define OMAP4430_BGAP_TEMPSOFF_MASK (1 << 12)
+#define OMAP4430_SINGLE_MODE_SHIFT 10
+#define OMAP4430_SINGLE_MODE_MASK (1 << 10)
+#define OMAP4430_BGAP_TEMP_SENSOR_SOC_SHIFT 9
+#define OMAP4430_BGAP_TEMP_SENSOR_SOC_MASK (1 << 9)
+#define OMAP4430_BGAP_TEMP_SENSOR_EOCZ_SHIFT 8
+#define OMAP4430_BGAP_TEMP_SENSOR_EOCZ_MASK (1 << 8)
+#define OMAP4430_BGAP_TEMP_SENSOR_DTEMP_SHIFT 0
+#define OMAP4430_BGAP_TEMP_SENSOR_DTEMP_MASK (0xff << 0)
+
+#define OMAP4430_ADC_START_VALUE 0
+#define OMAP4430_ADC_END_VALUE 127
+#define OMAP4430_MAX_FREQ 32768
+#define OMAP4430_MIN_FREQ 32768
+#define OMAP4430_MIN_TEMP -40000
+#define OMAP4430_MAX_TEMP 125000
+#define OMAP4430_HYST_VAL 5000
+
+/* TEMP_SENSOR OMAP4460 */
+#define OMAP4460_BGAP_TEMPSOFF_SHIFT 13
+#define OMAP4460_BGAP_TEMPSOFF_MASK (1 << 13)
+#define OMAP4460_BGAP_TEMP_SENSOR_SOC_SHIFT 11
+#define OMAP4460_BGAP_TEMP_SENSOR_SOC_MASK (1 << 11)
+#define OMAP4460_BGAP_TEMP_SENSOR_EOCZ_SHIFT 10
+#define OMAP4460_BGAP_TEMP_SENSOR_EOCZ_MASK (1 << 10)
+#define OMAP4460_BGAP_TEMP_SENSOR_DTEMP_SHIFT 0
+#define OMAP4460_BGAP_TEMP_SENSOR_DTEMP_MASK (0x3ff << 0)
+
+/* BANDGAP_CTRL */
+#define OMAP4460_SINGLE_MODE_SHIFT 31
+#define OMAP4460_SINGLE_MODE_MASK (1 << 31)
+#define OMAP4460_MASK_HOT_SHIFT 1
+#define OMAP4460_MASK_HOT_MASK (1 << 1)
+#define OMAP4460_MASK_COLD_SHIFT 0
+#define OMAP4460_MASK_COLD_MASK (1 << 0)
+
+/* BANDGAP_COUNTER */
+#define OMAP4460_COUNTER_SHIFT 0
+#define OMAP4460_COUNTER_MASK (0xffffff << 0)
+
+/* BANDGAP_THRESHOLD */
+#define OMAP4460_T_HOT_SHIFT 16
+#define OMAP4460_T_HOT_MASK (0x3ff << 16)
+#define OMAP4460_T_COLD_SHIFT 0
+#define OMAP4460_T_COLD_MASK (0x3ff << 0)
+
+/* TSHUT_THRESHOLD */
+#define OMAP4460_TSHUT_HOT_SHIFT 16
+#define OMAP4460_TSHUT_HOT_MASK (0x3ff << 16)
+#define OMAP4460_TSHUT_COLD_SHIFT 0
+#define OMAP4460_TSHUT_COLD_MASK (0x3ff << 0)
+
+/* BANDGAP_STATUS */
+#define OMAP4460_CLEAN_STOP_SHIFT 3
+#define OMAP4460_CLEAN_STOP_MASK (1 << 3)
+#define OMAP4460_BGAP_ALERT_SHIFT 2
+#define OMAP4460_BGAP_ALERT_MASK (1 << 2)
+#define OMAP4460_HOT_FLAG_SHIFT 1
+#define OMAP4460_HOT_FLAG_MASK (1 << 1)
+#define OMAP4460_COLD_FLAG_SHIFT 0
+#define OMAP4460_COLD_FLAG_MASK (1 << 0)
+
+/* TEMP_SENSOR OMAP5430 */
+#define OMAP5430_BGAP_TEMP_SENSOR_SOC_SHIFT 12
+#define OMAP5430_BGAP_TEMP_SENSOR_SOC_MASK (1 << 12)
+#define OMAP5430_BGAP_TEMPSOFF_SHIFT 11
+#define OMAP5430_BGAP_TEMPSOFF_MASK (1 << 11)
+#define OMAP5430_BGAP_TEMP_SENSOR_EOCZ_SHIFT 10
+#define OMAP5430_BGAP_TEMP_SENSOR_EOCZ_MASK (1 << 10)
+#define OMAP5430_BGAP_TEMP_SENSOR_DTEMP_SHIFT 0
+#define OMAP5430_BGAP_TEMP_SENSOR_DTEMP_MASK (0x3ff << 0)
+
+/* BANDGAP_CTRL */
+#define OMAP5430_MASK_HOT_CORE_SHIFT 5
+#define OMAP5430_MASK_HOT_CORE_MASK (1 << 5)
+#define OMAP5430_MASK_COLD_CORE_SHIFT 4
+#define OMAP5430_MASK_COLD_CORE_MASK (1 << 4)
+#define OMAP5430_MASK_HOT_MM_SHIFT 3
+#define OMAP5430_MASK_HOT_MM_MASK (1 << 3)
+#define OMAP5430_MASK_COLD_MM_SHIFT 2
+#define OMAP5430_MASK_COLD_MM_MASK (1 << 2)
+#define OMAP5430_MASK_HOT_MPU_SHIFT 1
+#define OMAP5430_MASK_HOT_MPU_MASK (1 << 1)
+#define OMAP5430_MASK_COLD_MPU_SHIFT 0
+#define OMAP5430_MASK_COLD_MPU_MASK (1 << 0)
+
+/* BANDGAP_COUNTER */
+#define OMAP5430_REPEAT_MODE_SHIFT 31
+#define OMAP5430_REPEAT_MODE_MASK (1 << 31)
+#define OMAP5430_COUNTER_SHIFT 0
+#define OMAP5430_COUNTER_MASK (0xffffff << 0)
+
+/* BANDGAP_THRESHOLD */
+#define OMAP5430_T_HOT_SHIFT 16
+#define OMAP5430_T_HOT_MASK (0x3ff << 16)
+#define OMAP5430_T_COLD_SHIFT 0
+#define OMAP5430_T_COLD_MASK (0x3ff << 0)
+
+/* TSHUT_THRESHOLD */
+#define OMAP5430_TSHUT_HOT_SHIFT 16
+#define OMAP5430_TSHUT_HOT_MASK (0x3ff << 16)
+#define OMAP5430_TSHUT_COLD_SHIFT 0
+#define OMAP5430_TSHUT_COLD_MASK (0x3ff << 0)
+
+/* BANDGAP_STATUS */
+#define OMAP5430_BGAP_ALERT_SHIFT 31
+#define OMAP5430_BGAP_ALERT_MASK (1 << 31)
+#define OMAP5430_HOT_CORE_FLAG_SHIFT 5
+#define OMAP5430_HOT_CORE_FLAG_MASK (1 << 5)
+#define OMAP5430_COLD_CORE_FLAG_SHIFT 4
+#define OMAP5430_COLD_CORE_FLAG_MASK (1 << 4)
+#define OMAP5430_HOT_MM_FLAG_SHIFT 3
+#define OMAP5430_HOT_MM_FLAG_MASK (1 << 3)
+#define OMAP5430_COLD_MM_FLAG_SHIFT 2
+#define OMAP5430_COLD_MM_FLAG_MASK (1 << 2)
+#define OMAP5430_HOT_MPU_FLAG_SHIFT 1
+#define OMAP5430_HOT_MPU_FLAG_MASK (1 << 1)
+#define OMAP5430_COLD_MPU_FLAG_SHIFT 0
+#define OMAP5430_COLD_MPU_FLAG_MASK (1 << 0)
+
+/* Offsets from the base of temperature sensor registers */
+
+/* 4430 - All goes relative to OPP_BGAP */
+#define OMAP4430_FUSE_OPP_BGAP 0x0
+#define OMAP4430_TEMP_SENSOR_CTRL_OFFSET 0xCC
+
+/* 4460 - All goes relative to OPP_BGAP */
+#define OMAP4460_FUSE_OPP_BGAP 0x0
+#define OMAP4460_TEMP_SENSOR_CTRL_OFFSET 0xCC
+#define OMAP4460_BGAP_CTRL_OFFSET 0x118
+#define OMAP4460_BGAP_COUNTER_OFFSET 0x11C
+#define OMAP4460_BGAP_THRESHOLD_OFFSET 0x120
+#define OMAP4460_BGAP_TSHUT_OFFSET 0x124
+#define OMAP4460_BGAP_STATUS_OFFSET 0x128
+
+/* 5430 - All goes relative to OPP_BGAP_GPU */
+#define OMAP5430_FUSE_OPP_BGAP_GPU 0x0
+#define OMAP5430_TEMP_SENSOR_GPU_OFFSET 0x150
+#define OMAP5430_BGAP_COUNTER_GPU_OFFSET 0x1C0
+#define OMAP5430_BGAP_THRESHOLD_GPU_OFFSET 0x1A8
+#define OMAP5430_BGAP_TSHUT_GPU_OFFSET 0x1B4
+
+#define OMAP5430_FUSE_OPP_BGAP_MPU 0x4
+#define OMAP5430_TEMP_SENSOR_MPU_OFFSET 0x14C
+#define OMAP5430_BGAP_CTRL_OFFSET 0x1A0
+#define OMAP5430_BGAP_COUNTER_MPU_OFFSET 0x1BC
+#define OMAP5430_BGAP_THRESHOLD_MPU_OFFSET 0x1A4
+#define OMAP5430_BGAP_TSHUT_MPU_OFFSET 0x1B0
+#define OMAP5430_BGAP_STATUS_OFFSET 0x1C8
+
+#define OMAP5430_FUSE_OPP_BGAP_CORE 0x8
+#define OMAP5430_TEMP_SENSOR_CORE_OFFSET 0x154
+#define OMAP5430_BGAP_COUNTER_CORE_OFFSET 0x1C4
+#define OMAP5430_BGAP_THRESHOLD_CORE_OFFSET 0x1AC
+#define OMAP5430_BGAP_TSHUT_CORE_OFFSET 0x1B8
+
+#define OMAP4460_TSHUT_HOT 900 /* 122 deg C */
+#define OMAP4460_TSHUT_COLD 895 /* 100 deg C */
+#define OMAP4460_T_HOT 800 /* 73 deg C */
+#define OMAP4460_T_COLD 795 /* 71 deg C */
+#define OMAP4460_MAX_FREQ 1500000
+#define OMAP4460_MIN_FREQ 1000000
+#define OMAP4460_MIN_TEMP -40000
+#define OMAP4460_MAX_TEMP 123000
+#define OMAP4460_HYST_VAL 5000
+#define OMAP4460_ADC_START_VALUE 530
+#define OMAP4460_ADC_END_VALUE 932
+
+#define OMAP5430_MPU_TSHUT_HOT 915
+#define OMAP5430_MPU_TSHUT_COLD 900
+#define OMAP5430_MPU_T_HOT 800
+#define OMAP5430_MPU_T_COLD 795
+#define OMAP5430_MPU_MAX_FREQ 1500000
+#define OMAP5430_MPU_MIN_FREQ 1000000
+#define OMAP5430_MPU_MIN_TEMP -40000
+#define OMAP5430_MPU_MAX_TEMP 125000
+#define OMAP5430_MPU_HYST_VAL 5000
+#define OMAP5430_ADC_START_VALUE 532
+#define OMAP5430_ADC_END_VALUE 934
+
+
+#define OMAP5430_GPU_TSHUT_HOT 915
+#define OMAP5430_GPU_TSHUT_COLD 900
+#define OMAP5430_GPU_T_HOT 800
+#define OMAP5430_GPU_T_COLD 795
+#define OMAP5430_GPU_MAX_FREQ 1500000
+#define OMAP5430_GPU_MIN_FREQ 1000000
+#define OMAP5430_GPU_MIN_TEMP -40000
+#define OMAP5430_GPU_MAX_TEMP 125000
+#define OMAP5430_GPU_HYST_VAL 5000
+
+#define OMAP5430_CORE_TSHUT_HOT 915
+#define OMAP5430_CORE_TSHUT_COLD 900
+#define OMAP5430_CORE_T_HOT 800
+#define OMAP5430_CORE_T_COLD 795
+#define OMAP5430_CORE_MAX_FREQ 1500000
+#define OMAP5430_CORE_MIN_FREQ 1000000
+#define OMAP5430_CORE_MIN_TEMP -40000
+#define OMAP5430_CORE_MAX_TEMP 125000
+#define OMAP5430_CORE_HYST_VAL 5000
+
+/**
+ * The register offsets and bit fields might change across
+ * OMAP versions hence populating them in this structure.
+ */
+
+struct temp_sensor_registers {
+ u32 temp_sensor_ctrl;
+ u32 bgap_tempsoff_mask;
+ u32 bgap_soc_mask;
+ u32 bgap_eocz_mask;
+ u32 bgap_dtemp_mask;
+
+ u32 bgap_mask_ctrl;
+ u32 mask_hot_mask;
+ u32 mask_cold_mask;
+
+ u32 bgap_mode_ctrl;
+ u32 mode_ctrl_mask;
+
+ u32 bgap_counter;
+ u32 counter_mask;
+
+ u32 bgap_threshold;
+ u32 threshold_thot_mask;
+ u32 threshold_tcold_mask;
+
+ u32 tshut_threshold;
+ u32 tshut_hot_mask;
+ u32 tshut_cold_mask;
+
+ u32 bgap_status;
+ u32 status_clean_stop_mask;
+ u32 status_bgap_alert_mask;
+ u32 status_hot_mask;
+ u32 status_cold_mask;
+
+ u32 bgap_efuse;
+};
+
+/**
+ * The thresholds and limits for temperature sensors.
+ */
+struct temp_sensor_data {
+ u32 tshut_hot;
+ u32 tshut_cold;
+ u32 t_hot;
+ u32 t_cold;
+ u32 min_freq;
+ u32 max_freq;
+ int max_temp;
+ int min_temp;
+ int hyst_val;
+ u32 adc_start_val;
+ u32 adc_end_val;
+ u32 update_int1;
+ u32 update_int2;
+};
+
+struct omap_bandgap_data;
+
+/**
+ * struct omap_bandgap - bandgap device structure
+ * @dev: device pointer
+ * @conf: platform data with sensor data
+ * @fclock: pointer to functional clock of temperature sensor
+ * @div_clk: pointer to parent clock of temperature sensor fclk
+ * @conv_table: Pointer to adc to temperature conversion table
+ * @bg_mutex: Mutex for sysfs, irq and PM
+ * @irq: MPU Irq number for thermal alert
+ * @tshut_gpio: GPIO where Tshut signal is routed
+ * @clk_rate: Holds current clock rate
+ */
+struct omap_bandgap {
+ struct device *dev;
+ void __iomem *base;
+ struct omap_bandgap_data *conf;
+ struct clk *fclock;
+ struct clk *div_clk;
+ const int *conv_table;
+ struct mutex bg_mutex; /* Mutex for irq and PM */
+ int irq;
+ int tshut_gpio;
+ u32 clk_rate;
+};
+
+/**
+ * struct temp_sensor_regval - temperature sensor register values
+ * @bg_mode_ctrl: temp sensor control register value
+ * @bg_ctrl: bandgap ctrl register value
+ * @bg_counter: bandgap counter value
+ * @bg_threshold: bandgap threshold register value
+ * @tshut_threshold: bandgap tshut register value
+ */
+struct temp_sensor_regval {
+ u32 bg_mode_ctrl;
+ u32 bg_ctrl;
+ u32 bg_counter;
+ u32 bg_threshold;
+ u32 tshut_threshold;
+};
+
+/**
+ * struct thermal_cooling_conf - description on how to cool a thermal zone
+ * @freq_clip_count: size of freq_data
+ */
+struct thermal_cooling_conf {
+ int freq_clip_count;
+};
+
+/**
+ * struct omap_temp_sensor - bandgap temperature sensor platform data
+ * @ts_data: pointer to struct with thresholds, limits of temperature sensor
+ * @registers: pointer to the list of register offsets and bitfields
+ * @regval: temperature sensor register values
+ * @domain: the name of the domain where the sensor is located
+ * @cooling_data: description on how the zone should be cooled off.
+ * @slope: sensor gradient slope info for hotspot extrapolation
+ * @const: sensor gradient const info for hotspot extrapolation
+ * @slope_pcb: sensor gradient slope info for hotspot extrapolation
+ * with no external influence
+ * @const_pcb: sensor gradient const info for hotspot extrapolation
+ * with no external influence
+ * @data: private data
+ * @register_cooling: function to describe how this sensor is going to be cooled
+ * @unregister_cooling: function to release cooling data
+ */
+struct omap_temp_sensor {
+ struct temp_sensor_data *ts_data;
+ struct temp_sensor_registers *registers;
+ struct temp_sensor_regval regval;
+ char *domain;
+ struct thermal_cooling_conf cooling_data;
+ /* for hotspot extrapolation */
+ const int slope;
+ const int constant;
+ const int slope_pcb;
+ const int constant_pcb;
+ void *data;
+ int (*register_cooling)(struct omap_bandgap *bg_ptr, int id);
+ int (*unregister_cooling)(struct omap_bandgap *bg_ptr, int id);
+};
+
+/**
+ * struct omap_bandgap_data - bandgap platform data structure
+ * @features: a bitwise flag set to describe the device features
+ * @conv_table: Pointer to adc to temperature conversion table
+ * @fclock_name: clock name of the functional clock
+ * @div_ck_nme: clock name of the clock divisor
+ * @sensor_count: count of temperature sensor device in scm
+ * @sensors: array of sensors present in this bandgap instance
+ * @expose_sensor: callback to export sensor to thermal API
+ */
+struct omap_bandgap_data {
+#define OMAP_BANDGAP_FEATURE_TSHUT (1 << 0)
+#define OMAP_BANDGAP_FEATURE_TSHUT_CONFIG (1 << 1)
+#define OMAP_BANDGAP_FEATURE_TALERT (1 << 2)
+#define OMAP_BANDGAP_FEATURE_MODE_CONFIG (1 << 3)
+#define OMAP_BANDGAP_FEATURE_COUNTER (1 << 4)
+#define OMAP_BANDGAP_FEATURE_POWER_SWITCH (1 << 5)
+#define OMAP_BANDGAP_HAS(b, f) \
+ ((b)->conf->features & OMAP_BANDGAP_FEATURE_ ## f)
+ unsigned int features;
+ const int *conv_table;
+ char *fclock_name;
+ char *div_ck_name;
+ int sensor_count;
+ int (*report_temperature)(struct omap_bandgap *bg_ptr, int id);
+ int (*expose_sensor)(struct omap_bandgap *bg_ptr, int id, char *domain);
+ int (*remove_sensor)(struct omap_bandgap *bg_ptr, int id);
+
+ /* this needs to be at the end */
+ struct omap_temp_sensor sensors[];
+};
+
+int omap_bandgap_read_thot(struct omap_bandgap *bg_ptr, int id, int *thot);
+int omap_bandgap_write_thot(struct omap_bandgap *bg_ptr, int id, int val);
+int omap_bandgap_read_tcold(struct omap_bandgap *bg_ptr, int id, int *tcold);
+int omap_bandgap_write_tcold(struct omap_bandgap *bg_ptr, int id, int val);
+int omap_bandgap_read_update_interval(struct omap_bandgap *bg_ptr, int id,
+ int *interval);
+int omap_bandgap_write_update_interval(struct omap_bandgap *bg_ptr, int id,
+ u32 interval);
+int omap_bandgap_read_temperature(struct omap_bandgap *bg_ptr, int id,
+ int *temperature);
+int omap_bandgap_set_sensor_data(struct omap_bandgap *bg_ptr, int id,
+ void *data);
+void *omap_bandgap_get_sensor_data(struct omap_bandgap *bg_ptr, int id);
+
+#ifdef CONFIG_OMAP4_THERMAL
+extern const struct omap_bandgap_data omap4430_data;
+extern const struct omap_bandgap_data omap4460_data;
+extern const struct omap_bandgap_data omap4470_data;
+#else
+#define omap4430_data NULL
+#define omap4460_data NULL
+#define omap4470_data NULL
+#endif
+
+#ifdef CONFIG_OMAP5_THERMAL
+extern const struct omap_bandgap_data omap5430_data;
+#else
+#define omap5430_data NULL
+#endif
+
+#endif
diff --git a/drivers/staging/omap-thermal/omap-thermal-common.c b/drivers/staging/omap-thermal/omap-thermal-common.c
new file mode 100644
index 000000000000..0675a5e2f7c8
--- /dev/null
+++ b/drivers/staging/omap-thermal/omap-thermal-common.c
@@ -0,0 +1,364 @@
+/*
+ * OMAP thermal driver interface
+ *
+ * Copyright (C) 2012 Texas Instruments Incorporated - http://www.ti.com/
+ * Contact:
+ * Eduardo Valentin <eduardo.valentin@ti.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ *
+ */
+
+#include <linux/device.h>
+#include <linux/err.h>
+#include <linux/mutex.h>
+#include <linux/gfp.h>
+#include <linux/kernel.h>
+#include <linux/workqueue.h>
+#include <linux/thermal.h>
+#include <linux/cpufreq.h>
+#include <linux/cpu_cooling.h>
+
+#include "omap-thermal.h"
+#include "omap-bandgap.h"
+
+/* common data structures */
+struct omap_thermal_data {
+ struct thermal_zone_device *omap_thermal;
+ struct thermal_cooling_device *cool_dev;
+ struct omap_bandgap *bg_ptr;
+ enum thermal_device_mode mode;
+ struct work_struct thermal_wq;
+ int sensor_id;
+};
+
+static void omap_thermal_work(struct work_struct *work)
+{
+ struct omap_thermal_data *data = container_of(work,
+ struct omap_thermal_data, thermal_wq);
+
+ thermal_zone_device_update(data->omap_thermal);
+
+ dev_dbg(&data->omap_thermal->device, "updated thermal zone %s\n",
+ data->omap_thermal->type);
+}
+
+/**
+ * omap_thermal_hotspot_temperature - returns sensor extrapolated temperature
+ * @t: omap sensor temperature
+ * @s: omap sensor slope value
+ * @c: omap sensor const value
+ */
+static inline int omap_thermal_hotspot_temperature(int t, int s, int c)
+{
+ int delta = t * s / 1000 + c;
+
+ if (delta < 0)
+ delta = 0;
+
+ return t + delta;
+}
+
+/* thermal zone ops */
+/* Get temperature callback function for thermal zone*/
+static inline int omap_thermal_get_temp(struct thermal_zone_device *thermal,
+ unsigned long *temp)
+{
+ struct omap_thermal_data *data = thermal->devdata;
+ struct omap_bandgap *bg_ptr = data->bg_ptr;
+ struct omap_temp_sensor *s = &bg_ptr->conf->sensors[data->sensor_id];
+ int ret, tmp, pcb_temp, slope, constant;
+
+ ret = omap_bandgap_read_temperature(bg_ptr, data->sensor_id, &tmp);
+ if (ret)
+ return ret;
+
+ pcb_temp = 0;
+ /* TODO: Introduce pcb temperature lookup */
+ /* In case pcb zone is available, use the extrapolation rule with it */
+ if (pcb_temp) {
+ tmp -= pcb_temp;
+ slope = s->slope_pcb;
+ constant = s->constant_pcb;
+ } else {
+ slope = s->slope;
+ constant = s->constant;
+ }
+ *temp = omap_thermal_hotspot_temperature(tmp, slope, constant);
+
+ return ret;
+}
+
+/* Bind callback functions for thermal zone */
+static int omap_thermal_bind(struct thermal_zone_device *thermal,
+ struct thermal_cooling_device *cdev)
+{
+ struct omap_thermal_data *data = thermal->devdata;
+ int max, id;
+
+ if (IS_ERR_OR_NULL(data))
+ return -ENODEV;
+
+ /* check if this is the cooling device we registered */
+ if (data->cool_dev != cdev)
+ return 0;
+
+ id = data->sensor_id;
+ max = data->bg_ptr->conf->sensors[id].cooling_data.freq_clip_count;
+
+ /* TODO: bind with min and max states */
+ /* Simple thing, two trips, one passive another critical */
+ return thermal_zone_bind_cooling_device(thermal, 0, cdev);
+}
+
+/* Unbind callback functions for thermal zone */
+static int omap_thermal_unbind(struct thermal_zone_device *thermal,
+ struct thermal_cooling_device *cdev)
+{
+ struct omap_thermal_data *data = thermal->devdata;
+
+ if (IS_ERR_OR_NULL(data))
+ return -ENODEV;
+
+ /* check if this is the cooling device we registered */
+ if (data->cool_dev != cdev)
+ return 0;
+
+ /* Simple thing, two trips, one passive another critical */
+ return thermal_zone_unbind_cooling_device(thermal, 0, cdev);
+}
+
+/* Get mode callback functions for thermal zone */
+static int omap_thermal_get_mode(struct thermal_zone_device *thermal,
+ enum thermal_device_mode *mode)
+{
+ struct omap_thermal_data *data = thermal->devdata;
+
+ if (data)
+ *mode = data->mode;
+
+ return 0;
+}
+
+/* Set mode callback functions for thermal zone */
+static int omap_thermal_set_mode(struct thermal_zone_device *thermal,
+ enum thermal_device_mode mode)
+{
+ struct omap_thermal_data *data = thermal->devdata;
+
+ if (!data->omap_thermal) {
+ dev_notice(&thermal->device, "thermal zone not registered\n");
+ return 0;
+ }
+
+ mutex_lock(&data->omap_thermal->lock);
+
+ if (mode == THERMAL_DEVICE_ENABLED)
+ data->omap_thermal->polling_delay = FAST_TEMP_MONITORING_RATE;
+ else
+ data->omap_thermal->polling_delay = 0;
+
+ mutex_unlock(&data->omap_thermal->lock);
+
+ data->mode = mode;
+ thermal_zone_device_update(data->omap_thermal);
+ dev_dbg(&thermal->device, "thermal polling set for duration=%d msec\n",
+ data->omap_thermal->polling_delay);
+
+ return 0;
+}
+
+/* Get trip type callback functions for thermal zone */
+static int omap_thermal_get_trip_type(struct thermal_zone_device *thermal,
+ int trip, enum thermal_trip_type *type)
+{
+ if (!omap_thermal_is_valid_trip(trip))
+ return -EINVAL;
+
+ if (trip + 1 == OMAP_TRIP_NUMBER)
+ *type = THERMAL_TRIP_CRITICAL;
+ else
+ *type = THERMAL_TRIP_PASSIVE;
+
+ return 0;
+}
+
+/* Get trip temperature callback functions for thermal zone */
+static int omap_thermal_get_trip_temp(struct thermal_zone_device *thermal,
+ int trip, unsigned long *temp)
+{
+ if (!omap_thermal_is_valid_trip(trip))
+ return -EINVAL;
+
+ *temp = omap_thermal_get_trip_value(trip);
+
+ return 0;
+}
+
+/* Get critical temperature callback functions for thermal zone */
+static int omap_thermal_get_crit_temp(struct thermal_zone_device *thermal,
+ unsigned long *temp)
+{
+ /* shutdown zone */
+ return omap_thermal_get_trip_temp(thermal, OMAP_TRIP_NUMBER - 1, temp);
+}
+
+static struct thermal_zone_device_ops omap_thermal_ops = {
+ .get_temp = omap_thermal_get_temp,
+ /* TODO: add .get_trend */
+ .bind = omap_thermal_bind,
+ .unbind = omap_thermal_unbind,
+ .get_mode = omap_thermal_get_mode,
+ .set_mode = omap_thermal_set_mode,
+ .get_trip_type = omap_thermal_get_trip_type,
+ .get_trip_temp = omap_thermal_get_trip_temp,
+ .get_crit_temp = omap_thermal_get_crit_temp,
+};
+
+int omap_thermal_expose_sensor(struct omap_bandgap *bg_ptr, int id,
+ char *domain)
+{
+ struct omap_thermal_data *data;
+
+ data = devm_kzalloc(bg_ptr->dev, sizeof(*data), GFP_KERNEL);
+ if (!data) {
+ dev_err(bg_ptr->dev, "kzalloc fail\n");
+ return -ENOMEM;
+ }
+ data->sensor_id = id;
+ data->bg_ptr = bg_ptr;
+ data->mode = THERMAL_DEVICE_ENABLED;
+ INIT_WORK(&data->thermal_wq, omap_thermal_work);
+
+ /* TODO: remove TC1 TC2 */
+ /* Create thermal zone */
+ data->omap_thermal = thermal_zone_device_register(domain,
+ OMAP_TRIP_NUMBER, 0, data, &omap_thermal_ops,
+ 0, FAST_TEMP_MONITORING_RATE, 0, 0);
+ if (IS_ERR_OR_NULL(data->omap_thermal)) {
+ dev_err(bg_ptr->dev, "thermal zone device is NULL\n");
+ return PTR_ERR(data->omap_thermal);
+ }
+ data->omap_thermal->polling_delay = FAST_TEMP_MONITORING_RATE;
+ omap_bandgap_set_sensor_data(bg_ptr, id, data);
+
+ return 0;
+}
+
+int omap_thermal_remove_sensor(struct omap_bandgap *bg_ptr, int id)
+{
+ struct omap_thermal_data *data;
+
+ data = omap_bandgap_get_sensor_data(bg_ptr, id);
+
+ thermal_zone_device_unregister(data->omap_thermal);
+
+ return 0;
+}
+
+int omap_thermal_report_sensor_temperature(struct omap_bandgap *bg_ptr, int id)
+{
+ struct omap_thermal_data *data;
+
+ data = omap_bandgap_get_sensor_data(bg_ptr, id);
+
+ schedule_work(&data->thermal_wq);
+
+ return 0;
+}
+
+static int omap_thermal_build_cpufreq_clip(struct omap_bandgap *bg_ptr,
+ struct freq_clip_table **tab_ptr,
+ int *tab_size)
+{
+ struct cpufreq_frequency_table *freq_table;
+ struct freq_clip_table *tab;
+ int i, count = 0;
+
+ freq_table = cpufreq_frequency_get_table(0);
+ if (IS_ERR_OR_NULL(freq_table)) {
+ dev_err(bg_ptr->dev,
+ "%s: failed to get cpufreq table (%p)\n",
+ __func__, freq_table);
+ return -EINVAL;
+ }
+
+ for (i = 0; freq_table[i].frequency != CPUFREQ_TABLE_END; i++) {
+ unsigned int freq = freq_table[i].frequency;
+ if (freq == CPUFREQ_ENTRY_INVALID)
+ continue;
+ count++;
+ }
+
+ tab = devm_kzalloc(bg_ptr->dev, sizeof(*tab) * count, GFP_KERNEL);
+ if (!tab) {
+ dev_err(bg_ptr->dev,
+ "%s: no memory available\n", __func__);
+ return -ENOMEM;
+ }
+
+ for (i = 0; freq_table[i].frequency != CPUFREQ_TABLE_END; i++) {
+ unsigned int freq = freq_table[i].frequency;
+
+ if (freq == CPUFREQ_ENTRY_INVALID)
+ continue;
+
+ tab[count - i - 1].freq_clip_max = freq;
+ tab[count - i - 1].temp_level = OMAP_TRIP_HOT;
+ tab[count - i - 1].mask_val = cpumask_of(0);
+ }
+
+ *tab_ptr = tab;
+ *tab_size = count;
+
+ return 0;
+}
+
+int omap_thermal_register_cpu_cooling(struct omap_bandgap *bg_ptr, int id)
+{
+ struct omap_thermal_data *data;
+ struct freq_clip_table *tab_ptr;
+ int tab_size, ret;
+
+ data = omap_bandgap_get_sensor_data(bg_ptr, id);
+
+ ret = omap_thermal_build_cpufreq_clip(bg_ptr, &tab_ptr, &tab_size);
+ if (ret < 0) {
+ dev_err(bg_ptr->dev,
+ "%s: failed to build cpufreq clip table\n", __func__);
+ return ret;
+ }
+
+ /* Register cooling device */
+ data->cool_dev = cpufreq_cooling_register(tab_ptr, tab_size);
+ if (IS_ERR_OR_NULL(data->cool_dev)) {
+ dev_err(bg_ptr->dev,
+ "Failed to register cpufreq cooling device\n");
+ return PTR_ERR(data->cool_dev);
+ }
+ bg_ptr->conf->sensors[id].cooling_data.freq_clip_count = tab_size;
+
+ return 0;
+}
+
+int omap_thermal_unregister_cpu_cooling(struct omap_bandgap *bg_ptr, int id)
+{
+ struct omap_thermal_data *data;
+
+ data = omap_bandgap_get_sensor_data(bg_ptr, id);
+ cpufreq_cooling_unregister(data->cool_dev);
+
+ return 0;
+}
diff --git a/drivers/staging/omap-thermal/omap-thermal.h b/drivers/staging/omap-thermal/omap-thermal.h
new file mode 100644
index 000000000000..0dd2184b9663
--- /dev/null
+++ b/drivers/staging/omap-thermal/omap-thermal.h
@@ -0,0 +1,108 @@
+/*
+ * OMAP thermal definitions
+ *
+ * Copyright (C) 2012 Texas Instruments Incorporated - http://www.ti.com/
+ * Contact:
+ * Eduardo Valentin <eduardo.valentin@ti.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ *
+ */
+#ifndef __OMAP_THERMAL_H
+#define __OMAP_THERMAL_H
+
+#include "omap-bandgap.h"
+
+/* sensors gradient and offsets */
+#define OMAP_GRADIENT_SLOPE_4460 348
+#define OMAP_GRADIENT_CONST_4460 -9301
+#define OMAP_GRADIENT_SLOPE_4470 308
+#define OMAP_GRADIENT_CONST_4470 -7896
+
+#define OMAP_GRADIENT_SLOPE_5430_CPU 196
+#define OMAP_GRADIENT_CONST_5430_CPU -6822
+#define OMAP_GRADIENT_SLOPE_5430_GPU 64
+#define OMAP_GRADIENT_CONST_5430_GPU 978
+
+/* PCB sensor calculation constants */
+#define OMAP_GRADIENT_SLOPE_W_PCB_4460 1142
+#define OMAP_GRADIENT_CONST_W_PCB_4460 -393
+#define OMAP_GRADIENT_SLOPE_W_PCB_4470 1063
+#define OMAP_GRADIENT_CONST_W_PCB_4470 -477
+
+#define OMAP_GRADIENT_SLOPE_W_PCB_5430_CPU 469
+#define OMAP_GRADIENT_CONST_W_PCB_5430_CPU -1272
+#define OMAP_GRADIENT_SLOPE_W_PCB_5430_GPU 378
+#define OMAP_GRADIENT_CONST_W_PCB_5430_GPU 154
+
+/* trip points of interest in milicelsius (at hotspot level) */
+#define OMAP_TRIP_COLD 100000
+#define OMAP_TRIP_HOT 110000
+#define OMAP_TRIP_SHUTDOWN 125000
+#define OMAP_TRIP_NUMBER 2
+#define OMAP_TRIP_STEP \
+ ((OMAP_TRIP_SHUTDOWN - OMAP_TRIP_HOT) / (OMAP_TRIP_NUMBER - 1))
+
+/* Update rates */
+#define FAST_TEMP_MONITORING_RATE 250
+
+/* helper macros */
+/**
+ * omap_thermal_get_trip_value - returns trip temperature based on index
+ * @i: trip index
+ */
+#define omap_thermal_get_trip_value(i) \
+ (OMAP_TRIP_HOT + ((i) * OMAP_TRIP_STEP))
+
+/**
+ * omap_thermal_is_valid_trip - check for trip index
+ * @i: trip index
+ */
+#define omap_thermal_is_valid_trip(trip) \
+ ((trip) >= 0 && (trip) < OMAP_TRIP_NUMBER)
+
+#ifdef CONFIG_OMAP_THERMAL
+int omap_thermal_expose_sensor(struct omap_bandgap *bg_ptr, int id,
+ char *domain);
+int omap_thermal_remove_sensor(struct omap_bandgap *bg_ptr, int id);
+int omap_thermal_register_cpu_cooling(struct omap_bandgap *bg_ptr, int id);
+int omap_thermal_unregister_cpu_cooling(struct omap_bandgap *bg_ptr, int id);
+#else
+static inline
+int omap_thermal_expose_sensor(struct omap_bandgap *bg_ptr, int id,
+ char *domain)
+{
+ return 0;
+}
+
+static inline
+int omap_thermal_remove_sensor(struct omap_bandgap *bg_ptr, int id)
+{
+ return 0;
+}
+
+static inline
+int omap_thermal_register_cpu_cooling(struct omap_bandgap *bg_ptr, int id)
+{
+ return 0;
+}
+
+static inline
+int omap_thermal_unregister_cpu_cooling(struct omap_bandgap *bg_ptr, int id)
+{
+ return 0;
+}
+#endif
+#endif
diff --git a/drivers/staging/omap-thermal/omap4-thermal.c b/drivers/staging/omap-thermal/omap4-thermal.c
new file mode 100644
index 000000000000..fa9dbcd71830
--- /dev/null
+++ b/drivers/staging/omap-thermal/omap4-thermal.c
@@ -0,0 +1,259 @@
+/*
+ * OMAP4 thermal driver.
+ *
+ * Copyright (C) 2011-2012 Texas Instruments Inc.
+ * Contact:
+ * Eduardo Valentin <eduardo.valentin@ti.com>
+ *
+ * This software is licensed under the terms of the GNU General Public
+ * License version 2, as published by the Free Software Foundation, and
+ * may be copied, distributed, and modified under those terms.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ */
+
+#include "omap-thermal.h"
+#include "omap-bandgap.h"
+
+/*
+ * OMAP4430 has one instance of thermal sensor for MPU
+ * need to describe the individual bit fields
+ */
+static struct temp_sensor_registers
+omap4430_mpu_temp_sensor_registers = {
+ .temp_sensor_ctrl = OMAP4430_TEMP_SENSOR_CTRL_OFFSET,
+ .bgap_tempsoff_mask = OMAP4430_BGAP_TEMPSOFF_MASK,
+ .bgap_soc_mask = OMAP4430_BGAP_TEMP_SENSOR_SOC_MASK,
+ .bgap_eocz_mask = OMAP4430_BGAP_TEMP_SENSOR_EOCZ_MASK,
+ .bgap_dtemp_mask = OMAP4430_BGAP_TEMP_SENSOR_DTEMP_MASK,
+
+ .bgap_mode_ctrl = OMAP4430_TEMP_SENSOR_CTRL_OFFSET,
+ .mode_ctrl_mask = OMAP4430_SINGLE_MODE_MASK,
+
+ .bgap_efuse = OMAP4430_FUSE_OPP_BGAP,
+};
+
+/* Thresholds and limits for OMAP4430 MPU temperature sensor */
+static struct temp_sensor_data omap4430_mpu_temp_sensor_data = {
+ .min_freq = OMAP4430_MIN_FREQ,
+ .max_freq = OMAP4430_MAX_FREQ,
+ .max_temp = OMAP4430_MAX_TEMP,
+ .min_temp = OMAP4430_MIN_TEMP,
+ .hyst_val = OMAP4430_HYST_VAL,
+ .adc_start_val = OMAP4430_ADC_START_VALUE,
+ .adc_end_val = OMAP4430_ADC_END_VALUE,
+};
+
+/*
+ * Temperature values in milli degree celsius
+ * ADC code values from 530 to 923
+ */
+static const int
+omap4430_adc_to_temp[OMAP4430_ADC_END_VALUE - OMAP4430_ADC_START_VALUE + 1] = {
+ -38000, -35000, -34000, -32000, -30000, -28000, -26000, -24000, -22000,
+ -20000, -18000, -17000, -15000, -13000, -12000, -10000, -8000, -6000,
+ -5000, -3000, -1000, 0, 2000, 3000, 5000, 6000, 8000, 10000, 12000,
+ 13000, 15000, 17000, 19000, 21000, 23000, 25000, 27000, 28000, 30000,
+ 32000, 33000, 35000, 37000, 38000, 40000, 42000, 43000, 45000, 47000,
+ 48000, 50000, 52000, 53000, 55000, 57000, 58000, 60000, 62000, 64000,
+ 66000, 68000, 70000, 71000, 73000, 75000, 77000, 78000, 80000, 82000,
+ 83000, 85000, 87000, 88000, 90000, 92000, 93000, 95000, 97000, 98000,
+ 100000, 102000, 103000, 105000, 107000, 109000, 111000, 113000, 115000,
+ 117000, 118000, 120000, 122000, 123000,
+};
+
+/* OMAP4430 data */
+const struct omap_bandgap_data omap4430_data = {
+ .features = OMAP_BANDGAP_FEATURE_MODE_CONFIG |
+ OMAP_BANDGAP_FEATURE_POWER_SWITCH,
+ .fclock_name = "bandgap_fclk",
+ .div_ck_name = "bandgap_fclk",
+ .conv_table = omap4430_adc_to_temp,
+ .expose_sensor = omap_thermal_expose_sensor,
+ .remove_sensor = omap_thermal_remove_sensor,
+ .sensors = {
+ {
+ .registers = &omap4430_mpu_temp_sensor_registers,
+ .ts_data = &omap4430_mpu_temp_sensor_data,
+ .domain = "cpu",
+ .slope = 0,
+ .constant = 20000,
+ .slope_pcb = 0,
+ .constant_pcb = 20000,
+ .register_cooling = omap_thermal_register_cpu_cooling,
+ .unregister_cooling = omap_thermal_unregister_cpu_cooling,
+ },
+ },
+ .sensor_count = 1,
+};
+/*
+ * OMAP4460 has one instance of thermal sensor for MPU
+ * need to describe the individual bit fields
+ */
+static struct temp_sensor_registers
+omap4460_mpu_temp_sensor_registers = {
+ .temp_sensor_ctrl = OMAP4460_TEMP_SENSOR_CTRL_OFFSET,
+ .bgap_tempsoff_mask = OMAP4460_BGAP_TEMPSOFF_MASK,
+ .bgap_soc_mask = OMAP4460_BGAP_TEMP_SENSOR_SOC_MASK,
+ .bgap_eocz_mask = OMAP4460_BGAP_TEMP_SENSOR_EOCZ_MASK,
+ .bgap_dtemp_mask = OMAP4460_BGAP_TEMP_SENSOR_DTEMP_MASK,
+
+ .bgap_mask_ctrl = OMAP4460_BGAP_CTRL_OFFSET,
+ .mask_hot_mask = OMAP4460_MASK_HOT_MASK,
+ .mask_cold_mask = OMAP4460_MASK_COLD_MASK,
+
+ .bgap_mode_ctrl = OMAP4460_BGAP_CTRL_OFFSET,
+ .mode_ctrl_mask = OMAP4460_SINGLE_MODE_MASK,
+
+ .bgap_counter = OMAP4460_BGAP_COUNTER_OFFSET,
+ .counter_mask = OMAP4460_COUNTER_MASK,
+
+ .bgap_threshold = OMAP4460_BGAP_THRESHOLD_OFFSET,
+ .threshold_thot_mask = OMAP4460_T_HOT_MASK,
+ .threshold_tcold_mask = OMAP4460_T_COLD_MASK,
+
+ .tshut_threshold = OMAP4460_BGAP_TSHUT_OFFSET,
+ .tshut_hot_mask = OMAP4460_TSHUT_HOT_MASK,
+ .tshut_cold_mask = OMAP4460_TSHUT_COLD_MASK,
+
+ .bgap_status = OMAP4460_BGAP_STATUS_OFFSET,
+ .status_clean_stop_mask = OMAP4460_CLEAN_STOP_MASK,
+ .status_bgap_alert_mask = OMAP4460_BGAP_ALERT_MASK,
+ .status_hot_mask = OMAP4460_HOT_FLAG_MASK,
+ .status_cold_mask = OMAP4460_COLD_FLAG_MASK,
+
+ .bgap_efuse = OMAP4460_FUSE_OPP_BGAP,
+};
+
+/* Thresholds and limits for OMAP4460 MPU temperature sensor */
+static struct temp_sensor_data omap4460_mpu_temp_sensor_data = {
+ .tshut_hot = OMAP4460_TSHUT_HOT,
+ .tshut_cold = OMAP4460_TSHUT_COLD,
+ .t_hot = OMAP4460_T_HOT,
+ .t_cold = OMAP4460_T_COLD,
+ .min_freq = OMAP4460_MIN_FREQ,
+ .max_freq = OMAP4460_MAX_FREQ,
+ .max_temp = OMAP4460_MAX_TEMP,
+ .min_temp = OMAP4460_MIN_TEMP,
+ .hyst_val = OMAP4460_HYST_VAL,
+ .adc_start_val = OMAP4460_ADC_START_VALUE,
+ .adc_end_val = OMAP4460_ADC_END_VALUE,
+ .update_int1 = 1000,
+ .update_int2 = 2000,
+};
+
+/*
+ * Temperature values in milli degree celsius
+ * ADC code values from 530 to 923
+ */
+static const int
+omap4460_adc_to_temp[OMAP4460_ADC_END_VALUE - OMAP4460_ADC_START_VALUE + 1] = {
+ -40000, -40000, -40000, -40000, -39800, -39400, -39000, -38600, -38200,
+ -37800, -37300, -36800, -36400, -36000, -35600, -35200, -34800,
+ -34300, -33800, -33400, -33000, -32600, -32200, -31800, -31300,
+ -30800, -30400, -30000, -29600, -29200, -28700, -28200, -27800,
+ -27400, -27000, -26600, -26200, -25700, -25200, -24800, -24400,
+ -24000, -23600, -23200, -22700, -22200, -21800, -21400, -21000,
+ -20600, -20200, -19700, -19200, -18800, -18400, -18000, -17600,
+ -17200, -16700, -16200, -15800, -15400, -15000, -14600, -14200,
+ -13700, -13200, -12800, -12400, -12000, -11600, -11200, -10700,
+ -10200, -9800, -9400, -9000, -8600, -8200, -7700, -7200, -6800,
+ -6400, -6000, -5600, -5200, -4800, -4300, -3800, -3400, -3000,
+ -2600, -2200, -1800, -1300, -800, -400, 0, 400, 800, 1200, 1600,
+ 2100, 2600, 3000, 3400, 3800, 4200, 4600, 5100, 5600, 6000, 6400,
+ 6800, 7200, 7600, 8000, 8500, 9000, 9400, 9800, 10200, 10600, 11000,
+ 11400, 11900, 12400, 12800, 13200, 13600, 14000, 14400, 14800,
+ 15300, 15800, 16200, 16600, 17000, 17400, 17800, 18200, 18700,
+ 19200, 19600, 20000, 20400, 20800, 21200, 21600, 22100, 22600,
+ 23000, 23400, 23800, 24200, 24600, 25000, 25400, 25900, 26400,
+ 26800, 27200, 27600, 28000, 28400, 28800, 29300, 29800, 30200,
+ 30600, 31000, 31400, 31800, 32200, 32600, 33100, 33600, 34000,
+ 34400, 34800, 35200, 35600, 36000, 36400, 36800, 37300, 37800,
+ 38200, 38600, 39000, 39400, 39800, 40200, 40600, 41100, 41600,
+ 42000, 42400, 42800, 43200, 43600, 44000, 44400, 44800, 45300,
+ 45800, 46200, 46600, 47000, 47400, 47800, 48200, 48600, 49000,
+ 49500, 50000, 50400, 50800, 51200, 51600, 52000, 52400, 52800,
+ 53200, 53700, 54200, 54600, 55000, 55400, 55800, 56200, 56600,
+ 57000, 57400, 57800, 58200, 58700, 59200, 59600, 60000, 60400,
+ 60800, 61200, 61600, 62000, 62400, 62800, 63300, 63800, 64200,
+ 64600, 65000, 65400, 65800, 66200, 66600, 67000, 67400, 67800,
+ 68200, 68700, 69200, 69600, 70000, 70400, 70800, 71200, 71600,
+ 72000, 72400, 72800, 73200, 73600, 74100, 74600, 75000, 75400,
+ 75800, 76200, 76600, 77000, 77400, 77800, 78200, 78600, 79000,
+ 79400, 79800, 80300, 80800, 81200, 81600, 82000, 82400, 82800,
+ 83200, 83600, 84000, 84400, 84800, 85200, 85600, 86000, 86400,
+ 86800, 87300, 87800, 88200, 88600, 89000, 89400, 89800, 90200,
+ 90600, 91000, 91400, 91800, 92200, 92600, 93000, 93400, 93800,
+ 94200, 94600, 95000, 95500, 96000, 96400, 96800, 97200, 97600,
+ 98000, 98400, 98800, 99200, 99600, 100000, 100400, 100800, 101200,
+ 101600, 102000, 102400, 102800, 103200, 103600, 104000, 104400,
+ 104800, 105200, 105600, 106100, 106600, 107000, 107400, 107800,
+ 108200, 108600, 109000, 109400, 109800, 110200, 110600, 111000,
+ 111400, 111800, 112200, 112600, 113000, 113400, 113800, 114200,
+ 114600, 115000, 115400, 115800, 116200, 116600, 117000, 117400,
+ 117800, 118200, 118600, 119000, 119400, 119800, 120200, 120600,
+ 121000, 121400, 121800, 122200, 122600, 123000, 123400, 123800, 124200,
+ 124600, 124900, 125000, 125000, 125000, 125000
+};
+
+/* OMAP4460 data */
+const struct omap_bandgap_data omap4460_data = {
+ .features = OMAP_BANDGAP_FEATURE_TSHUT |
+ OMAP_BANDGAP_FEATURE_TSHUT_CONFIG |
+ OMAP_BANDGAP_FEATURE_TALERT |
+ OMAP_BANDGAP_FEATURE_MODE_CONFIG |
+ OMAP_BANDGAP_FEATURE_POWER_SWITCH |
+ OMAP_BANDGAP_FEATURE_COUNTER,
+ .fclock_name = "bandgap_ts_fclk",
+ .div_ck_name = "div_ts_ck",
+ .conv_table = omap4460_adc_to_temp,
+ .expose_sensor = omap_thermal_expose_sensor,
+ .remove_sensor = omap_thermal_remove_sensor,
+ .sensors = {
+ {
+ .registers = &omap4460_mpu_temp_sensor_registers,
+ .ts_data = &omap4460_mpu_temp_sensor_data,
+ .domain = "cpu",
+ .slope = OMAP_GRADIENT_SLOPE_4460,
+ .constant = OMAP_GRADIENT_CONST_4460,
+ .slope_pcb = OMAP_GRADIENT_SLOPE_W_PCB_4460,
+ .constant_pcb = OMAP_GRADIENT_CONST_W_PCB_4460,
+ .register_cooling = omap_thermal_register_cpu_cooling,
+ .unregister_cooling = omap_thermal_unregister_cpu_cooling,
+ },
+ },
+ .sensor_count = 1,
+};
+
+/* OMAP4470 data */
+const struct omap_bandgap_data omap4470_data = {
+ .features = OMAP_BANDGAP_FEATURE_TSHUT |
+ OMAP_BANDGAP_FEATURE_TSHUT_CONFIG |
+ OMAP_BANDGAP_FEATURE_TALERT |
+ OMAP_BANDGAP_FEATURE_MODE_CONFIG |
+ OMAP_BANDGAP_FEATURE_POWER_SWITCH |
+ OMAP_BANDGAP_FEATURE_COUNTER,
+ .fclock_name = "bandgap_ts_fclk",
+ .div_ck_name = "div_ts_ck",
+ .conv_table = omap4460_adc_to_temp,
+ .expose_sensor = omap_thermal_expose_sensor,
+ .remove_sensor = omap_thermal_remove_sensor,
+ .sensors = {
+ {
+ .registers = &omap4460_mpu_temp_sensor_registers,
+ .ts_data = &omap4460_mpu_temp_sensor_data,
+ .domain = "cpu",
+ .slope = OMAP_GRADIENT_SLOPE_4470,
+ .constant = OMAP_GRADIENT_CONST_4470,
+ .slope_pcb = OMAP_GRADIENT_SLOPE_W_PCB_4470,
+ .constant_pcb = OMAP_GRADIENT_CONST_W_PCB_4470,
+ .register_cooling = omap_thermal_register_cpu_cooling,
+ .unregister_cooling = omap_thermal_unregister_cpu_cooling,
+ },
+ },
+ .sensor_count = 1,
+};
diff --git a/drivers/staging/omap-thermal/omap5-thermal.c b/drivers/staging/omap-thermal/omap5-thermal.c
new file mode 100644
index 000000000000..0658af24a5c7
--- /dev/null
+++ b/drivers/staging/omap-thermal/omap5-thermal.c
@@ -0,0 +1,297 @@
+/*
+ * OMAP5 thermal driver.
+ *
+ * Copyright (C) 2011-2012 Texas Instruments Inc.
+ * Contact:
+ * Eduardo Valentin <eduardo.valentin@ti.com>
+ *
+ * This software is licensed under the terms of the GNU General Public
+ * License version 2, as published by the Free Software Foundation, and
+ * may be copied, distributed, and modified under those terms.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ */
+
+#include "omap-bandgap.h"
+#include "omap-thermal.h"
+
+/*
+ * omap5430 has one instance of thermal sensor for MPU
+ * need to describe the individual bit fields
+ */
+static struct temp_sensor_registers
+omap5430_mpu_temp_sensor_registers = {
+ .temp_sensor_ctrl = OMAP5430_TEMP_SENSOR_MPU_OFFSET,
+ .bgap_tempsoff_mask = OMAP5430_BGAP_TEMPSOFF_MASK,
+ .bgap_soc_mask = OMAP5430_BGAP_TEMP_SENSOR_SOC_MASK,
+ .bgap_eocz_mask = OMAP5430_BGAP_TEMP_SENSOR_EOCZ_MASK,
+ .bgap_dtemp_mask = OMAP5430_BGAP_TEMP_SENSOR_DTEMP_MASK,
+
+ .bgap_mask_ctrl = OMAP5430_BGAP_CTRL_OFFSET,
+ .mask_hot_mask = OMAP5430_MASK_HOT_MPU_MASK,
+ .mask_cold_mask = OMAP5430_MASK_COLD_MPU_MASK,
+
+ .bgap_mode_ctrl = OMAP5430_BGAP_COUNTER_MPU_OFFSET,
+ .mode_ctrl_mask = OMAP5430_REPEAT_MODE_MASK,
+
+ .bgap_counter = OMAP5430_BGAP_COUNTER_MPU_OFFSET,
+ .counter_mask = OMAP5430_COUNTER_MASK,
+
+ .bgap_threshold = OMAP5430_BGAP_THRESHOLD_MPU_OFFSET,
+ .threshold_thot_mask = OMAP5430_T_HOT_MASK,
+ .threshold_tcold_mask = OMAP5430_T_COLD_MASK,
+
+ .tshut_threshold = OMAP5430_BGAP_TSHUT_MPU_OFFSET,
+ .tshut_hot_mask = OMAP5430_TSHUT_HOT_MASK,
+ .tshut_cold_mask = OMAP5430_TSHUT_COLD_MASK,
+
+ .bgap_status = OMAP5430_BGAP_STATUS_OFFSET,
+ .status_clean_stop_mask = 0x0,
+ .status_bgap_alert_mask = OMAP5430_BGAP_ALERT_MASK,
+ .status_hot_mask = OMAP5430_HOT_MPU_FLAG_MASK,
+ .status_cold_mask = OMAP5430_COLD_MPU_FLAG_MASK,
+
+ .bgap_efuse = OMAP5430_FUSE_OPP_BGAP_MPU,
+};
+
+/*
+ * omap5430 has one instance of thermal sensor for GPU
+ * need to describe the individual bit fields
+ */
+static struct temp_sensor_registers
+omap5430_gpu_temp_sensor_registers = {
+ .temp_sensor_ctrl = OMAP5430_TEMP_SENSOR_GPU_OFFSET,
+ .bgap_tempsoff_mask = OMAP5430_BGAP_TEMPSOFF_MASK,
+ .bgap_soc_mask = OMAP5430_BGAP_TEMP_SENSOR_SOC_MASK,
+ .bgap_eocz_mask = OMAP5430_BGAP_TEMP_SENSOR_EOCZ_MASK,
+ .bgap_dtemp_mask = OMAP5430_BGAP_TEMP_SENSOR_DTEMP_MASK,
+
+ .bgap_mask_ctrl = OMAP5430_BGAP_CTRL_OFFSET,
+ .mask_hot_mask = OMAP5430_MASK_HOT_MM_MASK,
+ .mask_cold_mask = OMAP5430_MASK_COLD_MM_MASK,
+
+ .bgap_mode_ctrl = OMAP5430_BGAP_COUNTER_GPU_OFFSET,
+ .mode_ctrl_mask = OMAP5430_REPEAT_MODE_MASK,
+
+ .bgap_counter = OMAP5430_BGAP_COUNTER_GPU_OFFSET,
+ .counter_mask = OMAP5430_COUNTER_MASK,
+
+ .bgap_threshold = OMAP5430_BGAP_THRESHOLD_GPU_OFFSET,
+ .threshold_thot_mask = OMAP5430_T_HOT_MASK,
+ .threshold_tcold_mask = OMAP5430_T_COLD_MASK,
+
+ .tshut_threshold = OMAP5430_BGAP_TSHUT_GPU_OFFSET,
+ .tshut_hot_mask = OMAP5430_TSHUT_HOT_MASK,
+ .tshut_cold_mask = OMAP5430_TSHUT_COLD_MASK,
+
+ .bgap_status = OMAP5430_BGAP_STATUS_OFFSET,
+ .status_clean_stop_mask = 0x0,
+ .status_bgap_alert_mask = OMAP5430_BGAP_ALERT_MASK,
+ .status_hot_mask = OMAP5430_HOT_MM_FLAG_MASK,
+ .status_cold_mask = OMAP5430_COLD_MM_FLAG_MASK,
+
+ .bgap_efuse = OMAP5430_FUSE_OPP_BGAP_GPU,
+};
+
+/*
+ * omap5430 has one instance of thermal sensor for CORE
+ * need to describe the individual bit fields
+ */
+static struct temp_sensor_registers
+omap5430_core_temp_sensor_registers = {
+ .temp_sensor_ctrl = OMAP5430_TEMP_SENSOR_CORE_OFFSET,
+ .bgap_tempsoff_mask = OMAP5430_BGAP_TEMPSOFF_MASK,
+ .bgap_soc_mask = OMAP5430_BGAP_TEMP_SENSOR_SOC_MASK,
+ .bgap_eocz_mask = OMAP5430_BGAP_TEMP_SENSOR_EOCZ_MASK,
+ .bgap_dtemp_mask = OMAP5430_BGAP_TEMP_SENSOR_DTEMP_MASK,
+
+ .bgap_mask_ctrl = OMAP5430_BGAP_CTRL_OFFSET,
+ .mask_hot_mask = OMAP5430_MASK_HOT_CORE_MASK,
+ .mask_cold_mask = OMAP5430_MASK_COLD_CORE_MASK,
+
+ .bgap_mode_ctrl = OMAP5430_BGAP_COUNTER_CORE_OFFSET,
+ .mode_ctrl_mask = OMAP5430_REPEAT_MODE_MASK,
+
+ .bgap_counter = OMAP5430_BGAP_COUNTER_CORE_OFFSET,
+ .counter_mask = OMAP5430_COUNTER_MASK,
+
+ .bgap_threshold = OMAP5430_BGAP_THRESHOLD_CORE_OFFSET,
+ .threshold_thot_mask = OMAP5430_T_HOT_MASK,
+ .threshold_tcold_mask = OMAP5430_T_COLD_MASK,
+
+ .tshut_threshold = OMAP5430_BGAP_TSHUT_CORE_OFFSET,
+ .tshut_hot_mask = OMAP5430_TSHUT_HOT_MASK,
+ .tshut_cold_mask = OMAP5430_TSHUT_COLD_MASK,
+
+ .bgap_status = OMAP5430_BGAP_STATUS_OFFSET,
+ .status_clean_stop_mask = 0x0,
+ .status_bgap_alert_mask = OMAP5430_BGAP_ALERT_MASK,
+ .status_hot_mask = OMAP5430_HOT_CORE_FLAG_MASK,
+ .status_cold_mask = OMAP5430_COLD_CORE_FLAG_MASK,
+
+ .bgap_efuse = OMAP5430_FUSE_OPP_BGAP_CORE,
+};
+
+/* Thresholds and limits for OMAP5430 MPU temperature sensor */
+static struct temp_sensor_data omap5430_mpu_temp_sensor_data = {
+ .tshut_hot = OMAP5430_MPU_TSHUT_HOT,
+ .tshut_cold = OMAP5430_MPU_TSHUT_COLD,
+ .t_hot = OMAP5430_MPU_T_HOT,
+ .t_cold = OMAP5430_MPU_T_COLD,
+ .min_freq = OMAP5430_MPU_MIN_FREQ,
+ .max_freq = OMAP5430_MPU_MAX_FREQ,
+ .max_temp = OMAP5430_MPU_MAX_TEMP,
+ .min_temp = OMAP5430_MPU_MIN_TEMP,
+ .hyst_val = OMAP5430_MPU_HYST_VAL,
+ .adc_start_val = OMAP5430_ADC_START_VALUE,
+ .adc_end_val = OMAP5430_ADC_END_VALUE,
+ .update_int1 = 1000,
+ .update_int2 = 2000,
+};
+
+/* Thresholds and limits for OMAP5430 GPU temperature sensor */
+static struct temp_sensor_data omap5430_gpu_temp_sensor_data = {
+ .tshut_hot = OMAP5430_GPU_TSHUT_HOT,
+ .tshut_cold = OMAP5430_GPU_TSHUT_COLD,
+ .t_hot = OMAP5430_GPU_T_HOT,
+ .t_cold = OMAP5430_GPU_T_COLD,
+ .min_freq = OMAP5430_GPU_MIN_FREQ,
+ .max_freq = OMAP5430_GPU_MAX_FREQ,
+ .max_temp = OMAP5430_GPU_MAX_TEMP,
+ .min_temp = OMAP5430_GPU_MIN_TEMP,
+ .hyst_val = OMAP5430_GPU_HYST_VAL,
+ .adc_start_val = OMAP5430_ADC_START_VALUE,
+ .adc_end_val = OMAP5430_ADC_END_VALUE,
+ .update_int1 = 1000,
+ .update_int2 = 2000,
+};
+
+/* Thresholds and limits for OMAP5430 CORE temperature sensor */
+static struct temp_sensor_data omap5430_core_temp_sensor_data = {
+ .tshut_hot = OMAP5430_CORE_TSHUT_HOT,
+ .tshut_cold = OMAP5430_CORE_TSHUT_COLD,
+ .t_hot = OMAP5430_CORE_T_HOT,
+ .t_cold = OMAP5430_CORE_T_COLD,
+ .min_freq = OMAP5430_CORE_MIN_FREQ,
+ .max_freq = OMAP5430_CORE_MAX_FREQ,
+ .max_temp = OMAP5430_CORE_MAX_TEMP,
+ .min_temp = OMAP5430_CORE_MIN_TEMP,
+ .hyst_val = OMAP5430_CORE_HYST_VAL,
+ .adc_start_val = OMAP5430_ADC_START_VALUE,
+ .adc_end_val = OMAP5430_ADC_END_VALUE,
+ .update_int1 = 1000,
+ .update_int2 = 2000,
+};
+
+static const int
+omap5430_adc_to_temp[OMAP5430_ADC_END_VALUE - OMAP5430_ADC_START_VALUE + 1] = {
+ -40000, -40000, -40000, -40000, -39800, -39400, -39000, -38600,
+ -38200, -37800, -37300, -36800,
+ -36400, -36000, -35600, -35200, -34800, -34300, -33800, -33400, -33000,
+ -32600,
+ -32200, -31800, -31300, -30800, -30400, -30000, -29600, -29200, -28700,
+ -28200, -27800, -27400, -27000, -26600, -26200, -25700, -25200, -24800,
+ -24400, -24000, -23600, -23200, -22700, -22200, -21800, -21400, -21000,
+ -20600, -20200, -19700, -19200, -9300, -18400, -18000, -17600, -17200,
+ -16700, -16200, -15800, -15400, -15000, -14600, -14200, -13700, -13200,
+ -12800, -12400, -12000, -11600, -11200, -10700, -10200, -9800, -9400,
+ -9000,
+ -8600, -8200, -7700, -7200, -6800, -6400, -6000, -5600, -5200, -4800,
+ -4300,
+ -3800, -3400, -3000, -2600, -2200, -1800, -1300, -800, -400, 0, 400,
+ 800,
+ 1200, 1600, 2100, 2600, 3000, 3400, 3800, 4200, 4600, 5100, 5600, 6000,
+ 6400, 6800, 7200, 7600, 8000, 8500, 9000, 9400, 9800, 10200, 10800,
+ 11100,
+ 11400, 11900, 12400, 12800, 13200, 13600, 14000, 14400, 14800, 15300,
+ 15800,
+ 16200, 16600, 17000, 17400, 17800, 18200, 18700, 19200, 19600, 20000,
+ 20400,
+ 20800, 21200, 21600, 22100, 22600, 23000, 23400, 23800, 24200, 24600,
+ 25000,
+ 25400, 25900, 26400, 26800, 27200, 27600, 28000, 28400, 28800, 29300,
+ 29800,
+ 30200, 30600, 31000, 31400, 31800, 32200, 32600, 33100, 33600, 34000,
+ 34400,
+ 34800, 35200, 35600, 36000, 36400, 36800, 37300, 37800, 38200, 38600,
+ 39000,
+ 39400, 39800, 40200, 40600, 41100, 41600, 42000, 42400, 42800, 43200,
+ 43600,
+ 44000, 44400, 44800, 45300, 45800, 46200, 46600, 47000, 47400, 47800,
+ 48200,
+ 48600, 49000, 49500, 50000, 50400, 50800, 51200, 51600, 52000, 52400,
+ 52800,
+ 53200, 53700, 54200, 54600, 55000, 55400, 55800, 56200, 56600, 57000,
+ 57400,
+ 57800, 58200, 58700, 59200, 59600, 60000, 60400, 60800, 61200, 61600,
+ 62000,
+ 62400, 62800, 63300, 63800, 64200, 64600, 65000, 65400, 65800, 66200,
+ 66600,
+ 67000, 67400, 67800, 68200, 68700, 69200, 69600, 70000, 70400, 70800,
+ 71200,
+ 71600, 72000, 72400, 72800, 73200, 73600, 74100, 74600, 75000, 75400,
+ 75800,
+ 76200, 76600, 77000, 77400, 77800, 78200, 78600, 79000, 79400, 79800,
+ 80300,
+ 80800, 81200, 81600, 82000, 82400, 82800, 83200, 83600, 84000, 84400,
+ 84800,
+ 85200, 85600, 86000, 86400, 86800, 87300, 87800, 88200, 88600, 89000,
+ 89400,
+ 89800, 90200, 90600, 91000, 91400, 91800, 92200, 92600, 93000, 93400,
+ 93800,
+ 94200, 94600, 95000, 95500, 96000, 96400, 96800, 97200, 97600, 98000,
+ 98400,
+ 98800, 99200, 99600, 100000, 100400, 100800, 101200, 101600, 102000,
+ 102400,
+ 102800, 103200, 103600, 104000, 104400, 104800, 105200, 105600, 106100,
+ 106600, 107000, 107400, 107800, 108200, 108600, 109000, 109400, 109800,
+ 110200, 110600, 111000, 111400, 111800, 112200, 112600, 113000, 113400,
+ 113800, 114200, 114600, 115000, 115400, 115800, 116200, 116600, 117000,
+ 117400, 117800, 118200, 118600, 119000, 119400, 119800, 120200, 120600,
+ 121000, 121400, 121800, 122200, 122600, 123000, 123400, 123800, 124200,
+ 124600, 124900, 125000, 125000, 125000, 125000,
+};
+
+const struct omap_bandgap_data omap5430_data = {
+ .features = OMAP_BANDGAP_FEATURE_TSHUT_CONFIG |
+ OMAP_BANDGAP_FEATURE_TALERT |
+ OMAP_BANDGAP_FEATURE_MODE_CONFIG |
+ OMAP_BANDGAP_FEATURE_COUNTER,
+ .fclock_name = "ts_clk_div_ck",
+ .div_ck_name = "ts_clk_div_ck",
+ .conv_table = omap5430_adc_to_temp,
+ .expose_sensor = omap_thermal_expose_sensor,
+ .remove_sensor = omap_thermal_remove_sensor,
+ .sensors = {
+ {
+ .registers = &omap5430_mpu_temp_sensor_registers,
+ .ts_data = &omap5430_mpu_temp_sensor_data,
+ .domain = "cpu",
+ .register_cooling = omap_thermal_register_cpu_cooling,
+ .unregister_cooling = omap_thermal_unregister_cpu_cooling,
+ .slope = OMAP_GRADIENT_SLOPE_5430_CPU,
+ .constant = OMAP_GRADIENT_CONST_5430_CPU,
+ .slope_pcb = OMAP_GRADIENT_SLOPE_W_PCB_5430_CPU,
+ .constant_pcb = OMAP_GRADIENT_CONST_W_PCB_5430_CPU,
+ },
+ {
+ .registers = &omap5430_gpu_temp_sensor_registers,
+ .ts_data = &omap5430_gpu_temp_sensor_data,
+ .domain = "gpu",
+ .slope = OMAP_GRADIENT_SLOPE_5430_GPU,
+ .constant = OMAP_GRADIENT_CONST_5430_GPU,
+ .slope_pcb = OMAP_GRADIENT_SLOPE_W_PCB_5430_GPU,
+ .constant_pcb = OMAP_GRADIENT_CONST_W_PCB_5430_GPU,
+ },
+ {
+ .registers = &omap5430_core_temp_sensor_registers,
+ .ts_data = &omap5430_core_temp_sensor_data,
+ .domain = "core",
+ },
+ },
+ .sensor_count = 3,
+};
diff --git a/drivers/staging/omap-thermal/omap_bandgap.txt b/drivers/staging/omap-thermal/omap_bandgap.txt
new file mode 100644
index 000000000000..6008a1452fde
--- /dev/null
+++ b/drivers/staging/omap-thermal/omap_bandgap.txt
@@ -0,0 +1,30 @@
+* Texas Instrument OMAP SCM bandgap bindings
+
+In the System Control Module, OMAP supplies a voltage reference
+and a temperature sensor feature that are gathered in the band
+gap voltage and temperature sensor (VBGAPTS) module. The band
+gap provides current and voltage reference for its internal
+circuits and other analog IP blocks. The analog-to-digital
+converter (ADC) produces an output value that is proportional
+to the silicon temperature.
+
+Required properties:
+- compatible : Should be:
+ - "ti,omap4460-control-bandgap" : for OMAP4460 bandgap
+ - "ti,omap5430-control-bandgap" : for OMAP5430 bandgap
+- interrupts : this entry should indicate which interrupt line
+the talert signal is routed to;
+Specific:
+- ti,tshut-gpio : this entry should be used to inform which GPIO
+line the tshut signal is routed to;
+
+Example:
+
+bandgap {
+ reg = <0x4a002260 0x4
+ 0x4a00232C 0x4
+ 0x4a002378 0x18>;
+ compatible = "ti,omap4460-control-bandgap";
+ interrupts = <0 126 4>; /* talert */
+ ti,tshut-gpio = <86>;
+};
diff --git a/drivers/staging/omapdrm/Makefile b/drivers/staging/omapdrm/Makefile
index d9cdc120d122..1ca0e0016de4 100644
--- a/drivers/staging/omapdrm/Makefile
+++ b/drivers/staging/omapdrm/Makefile
@@ -13,6 +13,7 @@ omapdrm-y := omap_drv.o \
omap_fb.o \
omap_fbdev.o \
omap_gem.o \
+ omap_gem_dmabuf.o \
omap_dmm_tiler.o \
tcm-sita.o
diff --git a/drivers/staging/omapdrm/TODO b/drivers/staging/omapdrm/TODO
index 55b18377ac4f..938c7888ca31 100644
--- a/drivers/staging/omapdrm/TODO
+++ b/drivers/staging/omapdrm/TODO
@@ -1,9 +1,7 @@
TODO
-. check error handling/cleanup paths
-. add drm_plane / overlay support
. add video decode/encode support (via syslink3 + codec-engine)
-. still some rough edges with flipping.. event back to userspace should
- really come after VSYNC interrupt
+ . NOTE: with dmabuf this probably could be split into different driver
+ so perhaps this TODO doesn't belong here
. where should we do eviction (detatch_pages())? We aren't necessarily
accessing the pages via a GART, so maybe we need some other threshold
to put a cap on the # of pages that can be pin'd. (It is mostly only
@@ -27,7 +25,6 @@ TODO
CRTC's should be disabled, and on resume the LUT should be reprogrammed
before CRTC's are re-enabled, to prevent DSS from trying to DMA from a
buffer mapped in DMM/TILER before LUT is reloaded.
-. Add debugfs information for DMM/TILER
Userspace:
. git://github.com/robclark/xf86-video-omap.git
diff --git a/drivers/staging/omapdrm/omap_crtc.c b/drivers/staging/omapdrm/omap_crtc.c
index 490a7f15604b..62e0022561bc 100644
--- a/drivers/staging/omapdrm/omap_crtc.c
+++ b/drivers/staging/omapdrm/omap_crtc.c
@@ -36,12 +36,6 @@ struct omap_crtc {
struct drm_framebuffer *old_fb;
};
-static void omap_crtc_gamma_set(struct drm_crtc *crtc,
- u16 *red, u16 *green, u16 *blue, uint32_t start, uint32_t size)
-{
- /* not supported.. at least not yet */
-}
-
static void omap_crtc_destroy(struct drm_crtc *crtc)
{
struct omap_crtc *omap_crtc = to_omap_crtc(crtc);
@@ -66,7 +60,7 @@ static void omap_crtc_dpms(struct drm_crtc *crtc, int mode)
}
static bool omap_crtc_mode_fixup(struct drm_crtc *crtc,
- struct drm_display_mode *mode,
+ const struct drm_display_mode *mode,
struct drm_display_mode *adjusted_mode)
{
return true;
@@ -198,7 +192,6 @@ static int omap_crtc_page_flip_locked(struct drm_crtc *crtc,
}
static const struct drm_crtc_funcs omap_crtc_funcs = {
- .gamma_set = omap_crtc_gamma_set,
.set_config = drm_crtc_helper_set_config,
.destroy = omap_crtc_destroy,
.page_flip = omap_crtc_page_flip_locked,
diff --git a/drivers/staging/omapdrm/omap_dmm_priv.h b/drivers/staging/omapdrm/omap_dmm_priv.h
index 2f529ab4b7c7..08b22e9f0ed7 100644
--- a/drivers/staging/omapdrm/omap_dmm_priv.h
+++ b/drivers/staging/omapdrm/omap_dmm_priv.h
@@ -181,7 +181,6 @@ struct dmm {
/* allocation list and lock */
struct list_head alloc_head;
- spinlock_t list_lock;
};
#endif
diff --git a/drivers/staging/omapdrm/omap_dmm_tiler.c b/drivers/staging/omapdrm/omap_dmm_tiler.c
index 1ecb6a73d790..86197831f63e 100644
--- a/drivers/staging/omapdrm/omap_dmm_tiler.c
+++ b/drivers/staging/omapdrm/omap_dmm_tiler.c
@@ -40,6 +40,9 @@
static struct tcm *containers[TILFMT_NFORMATS];
static struct dmm *omap_dmm;
+/* global spinlock for protecting lists */
+static DEFINE_SPINLOCK(list_lock);
+
/* Geometry table */
#define GEOM(xshift, yshift, bytes_per_pixel) { \
.x_shft = (xshift), \
@@ -147,13 +150,13 @@ static struct dmm_txn *dmm_txn_init(struct dmm *dmm, struct tcm *tcm)
down(&dmm->engine_sem);
/* grab an idle engine */
- spin_lock(&dmm->list_lock);
+ spin_lock(&list_lock);
if (!list_empty(&dmm->idle_head)) {
engine = list_entry(dmm->idle_head.next, struct refill_engine,
idle_node);
list_del(&engine->idle_node);
}
- spin_unlock(&dmm->list_lock);
+ spin_unlock(&list_lock);
BUG_ON(!engine);
@@ -256,9 +259,9 @@ static int dmm_txn_commit(struct dmm_txn *txn, bool wait)
}
cleanup:
- spin_lock(&dmm->list_lock);
+ spin_lock(&list_lock);
list_add(&engine->idle_node, &dmm->idle_head);
- spin_unlock(&dmm->list_lock);
+ spin_unlock(&list_lock);
up(&omap_dmm->engine_sem);
return ret;
@@ -347,13 +350,13 @@ struct tiler_block *tiler_reserve_2d(enum tiler_fmt fmt, uint16_t w,
ret = tcm_reserve_2d(containers[fmt], w, h, align, &block->area);
if (ret) {
kfree(block);
- return 0;
+ return ERR_PTR(-ENOMEM);
}
/* add to allocation list */
- spin_lock(&omap_dmm->list_lock);
+ spin_lock(&list_lock);
list_add(&block->alloc_node, &omap_dmm->alloc_head);
- spin_unlock(&omap_dmm->list_lock);
+ spin_unlock(&list_lock);
return block;
}
@@ -371,12 +374,12 @@ struct tiler_block *tiler_reserve_1d(size_t size)
if (tcm_reserve_1d(containers[TILFMT_PAGE], num_pages,
&block->area)) {
kfree(block);
- return 0;
+ return ERR_PTR(-ENOMEM);
}
- spin_lock(&omap_dmm->list_lock);
+ spin_lock(&list_lock);
list_add(&block->alloc_node, &omap_dmm->alloc_head);
- spin_unlock(&omap_dmm->list_lock);
+ spin_unlock(&list_lock);
return block;
}
@@ -389,9 +392,9 @@ int tiler_release(struct tiler_block *block)
if (block->area.tcm)
dev_err(omap_dmm->dev, "failed to release block\n");
- spin_lock(&omap_dmm->list_lock);
+ spin_lock(&list_lock);
list_del(&block->alloc_node);
- spin_unlock(&omap_dmm->list_lock);
+ spin_unlock(&list_lock);
kfree(block);
return ret;
@@ -479,13 +482,13 @@ static int omap_dmm_remove(struct platform_device *dev)
if (omap_dmm) {
/* free all area regions */
- spin_lock(&omap_dmm->list_lock);
+ spin_lock(&list_lock);
list_for_each_entry_safe(block, _block, &omap_dmm->alloc_head,
alloc_node) {
list_del(&block->alloc_node);
kfree(block);
}
- spin_unlock(&omap_dmm->list_lock);
+ spin_unlock(&list_lock);
for (i = 0; i < omap_dmm->num_lut; i++)
if (omap_dmm->tcm && omap_dmm->tcm[i])
@@ -503,7 +506,7 @@ static int omap_dmm_remove(struct platform_device *dev)
vfree(omap_dmm->lut);
- if (omap_dmm->irq != -1)
+ if (omap_dmm->irq > 0)
free_irq(omap_dmm->irq, omap_dmm);
iounmap(omap_dmm->base);
@@ -527,6 +530,10 @@ static int omap_dmm_probe(struct platform_device *dev)
goto fail;
}
+ /* initialize lists */
+ INIT_LIST_HEAD(&omap_dmm->alloc_head);
+ INIT_LIST_HEAD(&omap_dmm->idle_head);
+
/* lookup hwmod data - base address and irq */
mem = platform_get_resource(dev, IORESOURCE_MEM, 0);
if (!mem) {
@@ -629,7 +636,6 @@ static int omap_dmm_probe(struct platform_device *dev)
}
sema_init(&omap_dmm->engine_sem, omap_dmm->num_engines);
- INIT_LIST_HEAD(&omap_dmm->idle_head);
for (i = 0; i < omap_dmm->num_engines; i++) {
omap_dmm->engines[i].id = i;
omap_dmm->engines[i].dmm = omap_dmm;
@@ -672,9 +678,6 @@ static int omap_dmm_probe(struct platform_device *dev)
containers[TILFMT_32BIT] = omap_dmm->tcm[0];
containers[TILFMT_PAGE] = omap_dmm->tcm[0];
- INIT_LIST_HEAD(&omap_dmm->alloc_head);
- spin_lock_init(&omap_dmm->list_lock);
-
area = (struct tcm_area) {
.is2d = true,
.tcm = NULL,
@@ -697,7 +700,8 @@ static int omap_dmm_probe(struct platform_device *dev)
return 0;
fail:
- omap_dmm_remove(dev);
+ if (omap_dmm_remove(dev))
+ dev_err(&dev->dev, "cleanup failed\n");
return ret;
}
@@ -810,7 +814,7 @@ int tiler_map_show(struct seq_file *s, void *arg)
map[i] = global_map + i * (w_adj + 1);
map[i][w_adj] = 0;
}
- spin_lock_irqsave(&omap_dmm->list_lock, flags);
+ spin_lock_irqsave(&list_lock, flags);
list_for_each_entry(block, &omap_dmm->alloc_head, alloc_node) {
if (block->fmt != TILFMT_PAGE) {
@@ -836,7 +840,7 @@ int tiler_map_show(struct seq_file *s, void *arg)
}
}
- spin_unlock_irqrestore(&omap_dmm->list_lock, flags);
+ spin_unlock_irqrestore(&list_lock, flags);
if (s) {
seq_printf(s, "BEGIN DMM TILER MAP\n");
diff --git a/drivers/staging/omapdrm/omap_drv.c b/drivers/staging/omapdrm/omap_drv.c
index 620b8d54223d..4beab9447ceb 100644
--- a/drivers/staging/omapdrm/omap_drv.c
+++ b/drivers/staging/omapdrm/omap_drv.c
@@ -58,7 +58,7 @@ static void omap_fb_output_poll_changed(struct drm_device *dev)
}
}
-static struct drm_mode_config_funcs omap_mode_config_funcs = {
+static const struct drm_mode_config_funcs omap_mode_config_funcs = {
.fb_create = omap_framebuffer_create,
.output_poll_changed = omap_fb_output_poll_changed,
};
@@ -726,7 +726,7 @@ static void dev_irq_uninstall(struct drm_device *dev)
DBG("irq_uninstall: dev=%p", dev);
}
-static struct vm_operations_struct omap_gem_vm_ops = {
+static const struct vm_operations_struct omap_gem_vm_ops = {
.fault = omap_gem_fault,
.open = drm_gem_vm_open,
.close = drm_gem_vm_close,
@@ -746,7 +746,7 @@ static const struct file_operations omapdriver_fops = {
static struct drm_driver omap_drm_driver = {
.driver_features =
- DRIVER_HAVE_IRQ | DRIVER_MODESET | DRIVER_GEM,
+ DRIVER_HAVE_IRQ | DRIVER_MODESET | DRIVER_GEM | DRIVER_PRIME,
.load = dev_load,
.unload = dev_unload,
.open = dev_open,
@@ -766,6 +766,10 @@ static struct drm_driver omap_drm_driver = {
.debugfs_init = omap_debugfs_init,
.debugfs_cleanup = omap_debugfs_cleanup,
#endif
+ .prime_handle_to_fd = drm_gem_prime_handle_to_fd,
+ .prime_fd_to_handle = drm_gem_prime_fd_to_handle,
+ .gem_prime_export = omap_gem_prime_export,
+ .gem_prime_import = omap_gem_prime_import,
.gem_init_object = omap_gem_init_object,
.gem_free_object = omap_gem_free_object,
.gem_vm_ops = &omap_gem_vm_ops,
diff --git a/drivers/staging/omapdrm/omap_drv.h b/drivers/staging/omapdrm/omap_drv.h
index b7e0f0773003..2092a9167d29 100644
--- a/drivers/staging/omapdrm/omap_drv.h
+++ b/drivers/staging/omapdrm/omap_drv.h
@@ -25,8 +25,8 @@
#include <linux/types.h>
#include <drm/drmP.h>
#include <drm/drm_crtc_helper.h>
+#include <linux/platform_data/omap_drm.h>
#include "omap_drm.h"
-#include "omap_priv.h"
#define DBG(fmt, ...) DRM_DEBUG(fmt"\n", ##__VA_ARGS__)
#define VERB(fmt, ...) if (0) DRM_DEBUG(fmt, ##__VA_ARGS__) /* verbose debug */
@@ -138,6 +138,8 @@ int omap_gem_dumb_destroy(struct drm_file *file, struct drm_device *dev,
int omap_gem_dumb_create(struct drm_file *file, struct drm_device *dev,
struct drm_mode_create_dumb *args);
int omap_gem_mmap(struct file *filp, struct vm_area_struct *vma);
+int omap_gem_mmap_obj(struct drm_gem_object *obj,
+ struct vm_area_struct *vma);
int omap_gem_fault(struct vm_area_struct *vma, struct vm_fault *vmf);
int omap_gem_op_start(struct drm_gem_object *obj, enum omap_gem_op op);
int omap_gem_op_finish(struct drm_gem_object *obj, enum omap_gem_op op);
@@ -145,12 +147,24 @@ int omap_gem_op_sync(struct drm_gem_object *obj, enum omap_gem_op op);
int omap_gem_op_async(struct drm_gem_object *obj, enum omap_gem_op op,
void (*fxn)(void *arg), void *arg);
int omap_gem_roll(struct drm_gem_object *obj, uint32_t roll);
+void omap_gem_cpu_sync(struct drm_gem_object *obj, int pgoff);
+void omap_gem_dma_sync(struct drm_gem_object *obj,
+ enum dma_data_direction dir);
int omap_gem_get_paddr(struct drm_gem_object *obj,
dma_addr_t *paddr, bool remap);
int omap_gem_put_paddr(struct drm_gem_object *obj);
+int omap_gem_get_pages(struct drm_gem_object *obj, struct page ***pages,
+ bool remap);
+int omap_gem_put_pages(struct drm_gem_object *obj);
+uint32_t omap_gem_flags(struct drm_gem_object *obj);
uint64_t omap_gem_mmap_offset(struct drm_gem_object *obj);
size_t omap_gem_mmap_size(struct drm_gem_object *obj);
+struct dma_buf * omap_gem_prime_export(struct drm_device *dev,
+ struct drm_gem_object *obj, int flags);
+struct drm_gem_object * omap_gem_prime_import(struct drm_device *dev,
+ struct dma_buf *buffer);
+
static inline int align_pitch(int pitch, int width, int bpp)
{
int bytespp = (bpp + 7) / 8;
diff --git a/drivers/staging/omapdrm/omap_encoder.c b/drivers/staging/omapdrm/omap_encoder.c
index 06c52cb62d2f..31c735d39217 100644
--- a/drivers/staging/omapdrm/omap_encoder.c
+++ b/drivers/staging/omapdrm/omap_encoder.c
@@ -48,7 +48,7 @@ static void omap_encoder_dpms(struct drm_encoder *encoder, int mode)
}
static bool omap_encoder_mode_fixup(struct drm_encoder *encoder,
- struct drm_display_mode *mode,
+ const struct drm_display_mode *mode,
struct drm_display_mode *adjusted_mode)
{
struct omap_encoder *omap_encoder = to_omap_encoder(encoder);
diff --git a/drivers/staging/omapdrm/omap_fb.c b/drivers/staging/omapdrm/omap_fb.c
index 04b235b6724a..74260f043ab1 100644
--- a/drivers/staging/omapdrm/omap_fb.c
+++ b/drivers/staging/omapdrm/omap_fb.c
@@ -167,7 +167,7 @@ void omap_framebuffer_update_scanout(struct drm_framebuffer *fb, int x, int y,
}
/* Call for unpin 'a' (if not NULL), and pin 'b' (if not NULL). Although
- * buffers to unpin are just just pushed to the unpin fifo so that the
+ * buffers to unpin are just pushed to the unpin fifo so that the
* caller can defer unpin until vblank.
*
* Note if this fails (ie. something went very wrong!), all buffers are
@@ -197,8 +197,11 @@ int omap_framebuffer_replace(struct drm_framebuffer *a,
pa->paddr = 0;
}
- if (pb && !ret)
+ if (pb && !ret) {
ret = omap_gem_get_paddr(pb->bo, &pb->paddr, true);
+ if (!ret)
+ omap_gem_dma_sync(pb->bo, DMA_TO_DEVICE);
+ }
}
if (ret) {
diff --git a/drivers/staging/omapdrm/omap_fbdev.c b/drivers/staging/omapdrm/omap_fbdev.c
index 11acd4c35ed2..8c6ed3b0c6f6 100644
--- a/drivers/staging/omapdrm/omap_fbdev.c
+++ b/drivers/staging/omapdrm/omap_fbdev.c
@@ -208,7 +208,8 @@ static int omap_fbdev_create(struct drm_fb_helper *helper,
*/
ret = omap_gem_get_paddr(fbdev->bo, &paddr, true);
if (ret) {
- dev_err(dev->dev, "could not map (paddr)!\n");
+ dev_err(dev->dev,
+ "could not map (paddr)! Skipping framebuffer alloc\n");
ret = -ENOMEM;
goto fail;
}
@@ -388,8 +389,11 @@ void omap_fbdev_free(struct drm_device *dev)
fbi = helper->fbdev;
- unregister_framebuffer(fbi);
- framebuffer_release(fbi);
+ /* only cleanup framebuffer if it is present */
+ if (fbi) {
+ unregister_framebuffer(fbi);
+ framebuffer_release(fbi);
+ }
drm_fb_helper_fini(helper);
diff --git a/drivers/staging/omapdrm/omap_gem.c b/drivers/staging/omapdrm/omap_gem.c
index 921f058cc6a4..3a0d035a9e03 100644
--- a/drivers/staging/omapdrm/omap_gem.c
+++ b/drivers/staging/omapdrm/omap_gem.c
@@ -207,13 +207,27 @@ static inline bool is_shmem(struct drm_gem_object *obj)
return obj->filp != NULL;
}
+/**
+ * shmem buffers that are mapped cached can simulate coherency via using
+ * page faulting to keep track of dirty pages
+ */
+static inline bool is_cached_coherent(struct drm_gem_object *obj)
+{
+ struct omap_gem_object *omap_obj = to_omap_bo(obj);
+ return is_shmem(obj) &&
+ ((omap_obj->flags & OMAP_BO_CACHE_MASK) == OMAP_BO_CACHED);
+}
+
static DEFINE_SPINLOCK(sync_lock);
/** ensure backing pages are allocated */
static int omap_gem_attach_pages(struct drm_gem_object *obj)
{
+ struct drm_device *dev = obj->dev;
struct omap_gem_object *omap_obj = to_omap_bo(obj);
struct page **pages;
+ int i, npages = obj->size >> PAGE_SHIFT;
+ dma_addr_t *addrs;
WARN_ON(omap_obj->pages);
@@ -231,16 +245,18 @@ static int omap_gem_attach_pages(struct drm_gem_object *obj)
* DSS, GPU, etc. are not cache coherent:
*/
if (omap_obj->flags & (OMAP_BO_WC|OMAP_BO_UNCACHED)) {
- int i, npages = obj->size >> PAGE_SHIFT;
- dma_addr_t *addrs = kmalloc(npages * sizeof(addrs), GFP_KERNEL);
+ addrs = kmalloc(npages * sizeof(addrs), GFP_KERNEL);
for (i = 0; i < npages; i++) {
- addrs[i] = dma_map_page(obj->dev->dev, pages[i],
+ addrs[i] = dma_map_page(dev->dev, pages[i],
0, PAGE_SIZE, DMA_BIDIRECTIONAL);
}
- omap_obj->addrs = addrs;
+ } else {
+ addrs = kzalloc(npages * sizeof(addrs), GFP_KERNEL);
}
+ omap_obj->addrs = addrs;
omap_obj->pages = pages;
+
return 0;
}
@@ -258,14 +274,21 @@ static void omap_gem_detach_pages(struct drm_gem_object *obj)
dma_unmap_page(obj->dev->dev, omap_obj->addrs[i],
PAGE_SIZE, DMA_BIDIRECTIONAL);
}
- kfree(omap_obj->addrs);
- omap_obj->addrs = NULL;
}
+ kfree(omap_obj->addrs);
+ omap_obj->addrs = NULL;
+
_drm_gem_put_pages(obj, omap_obj->pages, true, false);
omap_obj->pages = NULL;
}
+/* get buffer flags */
+uint32_t omap_gem_flags(struct drm_gem_object *obj)
+{
+ return to_omap_bo(obj)->flags;
+}
+
/** get mmap offset */
static uint64_t mmap_offset(struct drm_gem_object *obj)
{
@@ -330,6 +353,7 @@ static int fault_1d(struct drm_gem_object *obj,
vma->vm_start) >> PAGE_SHIFT;
if (omap_obj->pages) {
+ omap_gem_cpu_sync(obj, pgoff);
pfn = page_to_pfn(omap_obj->pages[pgoff]);
} else {
BUG_ON(!(omap_obj->flags & OMAP_BO_DMA));
@@ -504,7 +528,6 @@ fail:
/** We override mainly to fix up some of the vm mapping flags.. */
int omap_gem_mmap(struct file *filp, struct vm_area_struct *vma)
{
- struct omap_gem_object *omap_obj;
int ret;
ret = drm_gem_mmap(filp, vma);
@@ -513,8 +536,13 @@ int omap_gem_mmap(struct file *filp, struct vm_area_struct *vma)
return ret;
}
- /* after drm_gem_mmap(), it is safe to access the obj */
- omap_obj = to_omap_bo(vma->vm_private_data);
+ return omap_gem_mmap_obj(vma->vm_private_data, vma);
+}
+
+int omap_gem_mmap_obj(struct drm_gem_object *obj,
+ struct vm_area_struct *vma)
+{
+ struct omap_gem_object *omap_obj = to_omap_bo(obj);
vma->vm_flags &= ~VM_PFNMAP;
vma->vm_flags |= VM_MIXEDMAP;
@@ -524,12 +552,31 @@ int omap_gem_mmap(struct file *filp, struct vm_area_struct *vma)
} else if (omap_obj->flags & OMAP_BO_UNCACHED) {
vma->vm_page_prot = pgprot_noncached(vm_get_page_prot(vma->vm_flags));
} else {
+ /*
+ * We do have some private objects, at least for scanout buffers
+ * on hardware without DMM/TILER. But these are allocated write-
+ * combine
+ */
+ if (WARN_ON(!obj->filp))
+ return -EINVAL;
+
+ /*
+ * Shunt off cached objs to shmem file so they have their own
+ * address_space (so unmap_mapping_range does what we want,
+ * in particular in the case of mmap'd dmabufs)
+ */
+ fput(vma->vm_file);
+ get_file(obj->filp);
+ vma->vm_pgoff = 0;
+ vma->vm_file = obj->filp;
+
vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
}
- return ret;
+ return 0;
}
+
/**
* omap_gem_dumb_create - create a dumb buffer
* @drm_file: our client file
@@ -639,6 +686,48 @@ fail:
return ret;
}
+/* Sync the buffer for CPU access.. note pages should already be
+ * attached, ie. omap_gem_get_pages()
+ */
+void omap_gem_cpu_sync(struct drm_gem_object *obj, int pgoff)
+{
+ struct drm_device *dev = obj->dev;
+ struct omap_gem_object *omap_obj = to_omap_bo(obj);
+
+ if (is_cached_coherent(obj) && omap_obj->addrs[pgoff]) {
+ dma_unmap_page(dev->dev, omap_obj->addrs[pgoff],
+ PAGE_SIZE, DMA_BIDIRECTIONAL);
+ omap_obj->addrs[pgoff] = 0;
+ }
+}
+
+/* sync the buffer for DMA access */
+void omap_gem_dma_sync(struct drm_gem_object *obj,
+ enum dma_data_direction dir)
+{
+ struct drm_device *dev = obj->dev;
+ struct omap_gem_object *omap_obj = to_omap_bo(obj);
+
+ if (is_cached_coherent(obj)) {
+ int i, npages = obj->size >> PAGE_SHIFT;
+ struct page **pages = omap_obj->pages;
+ bool dirty = false;
+
+ for (i = 0; i < npages; i++) {
+ if (!omap_obj->addrs[i]) {
+ omap_obj->addrs[i] = dma_map_page(dev->dev, pages[i], 0,
+ PAGE_SIZE, DMA_BIDIRECTIONAL);
+ dirty = true;
+ }
+ }
+
+ if (dirty) {
+ unmap_mapping_range(obj->filp->f_mapping, 0,
+ omap_gem_mmap_size(obj), 1);
+ }
+ }
+}
+
/* Get physical address for DMA.. if 'remap' is true, and the buffer is not
* already contiguous, remap it to pin in physically contiguous memory.. (ie.
* map in TILER)
@@ -703,6 +792,7 @@ int omap_gem_get_paddr(struct drm_gem_object *obj,
*paddr = omap_obj->paddr;
} else {
ret = -EINVAL;
+ goto fail;
}
fail:
@@ -764,9 +854,27 @@ static int get_pages(struct drm_gem_object *obj, struct page ***pages)
return 0;
}
-int omap_gem_get_pages(struct drm_gem_object *obj, struct page ***pages)
+/* if !remap, and we don't have pages backing, then fail, rather than
+ * increasing the pin count (which we don't really do yet anyways,
+ * because we don't support swapping pages back out). And 'remap'
+ * might not be quite the right name, but I wanted to keep it working
+ * similarly to omap_gem_get_paddr(). Note though that mutex is not
+ * aquired if !remap (because this can be called in atomic ctxt),
+ * but probably omap_gem_get_paddr() should be changed to work in the
+ * same way. If !remap, a matching omap_gem_put_pages() call is not
+ * required (and should not be made).
+ */
+int omap_gem_get_pages(struct drm_gem_object *obj, struct page ***pages,
+ bool remap)
{
int ret;
+ if (!remap) {
+ struct omap_gem_object *omap_obj = to_omap_bo(obj);
+ if (!omap_obj->pages)
+ return -ENOMEM;
+ *pages = omap_obj->pages;
+ return 0;
+ }
mutex_lock(&obj->dev->struct_mutex);
ret = get_pages(obj, pages);
mutex_unlock(&obj->dev->struct_mutex);
diff --git a/drivers/staging/omapdrm/omap_gem_dmabuf.c b/drivers/staging/omapdrm/omap_gem_dmabuf.c
new file mode 100644
index 000000000000..42728e0cc194
--- /dev/null
+++ b/drivers/staging/omapdrm/omap_gem_dmabuf.c
@@ -0,0 +1,220 @@
+/*
+ * drivers/staging/omapdrm/omap_gem_dmabuf.c
+ *
+ * Copyright (C) 2011 Texas Instruments
+ * Author: Rob Clark <rob.clark@linaro.org>
+ *
+ * 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.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "omap_drv.h"
+
+#include <linux/dma-buf.h>
+
+static struct sg_table *omap_gem_map_dma_buf(
+ struct dma_buf_attachment *attachment,
+ enum dma_data_direction dir)
+{
+ struct drm_gem_object *obj = attachment->dmabuf->priv;
+ struct sg_table *sg;
+ dma_addr_t paddr;
+ int ret;
+
+ sg = kzalloc(sizeof(*sg), GFP_KERNEL);
+ if (!sg)
+ return ERR_PTR(-ENOMEM);
+
+ /* camera, etc, need physically contiguous.. but we need a
+ * better way to know this..
+ */
+ ret = omap_gem_get_paddr(obj, &paddr, true);
+ if (ret)
+ goto out;
+
+ ret = sg_alloc_table(sg, 1, GFP_KERNEL);
+ if (ret)
+ goto out;
+
+ sg_init_table(sg->sgl, 1);
+ sg_dma_len(sg->sgl) = obj->size;
+ sg_set_page(sg->sgl, pfn_to_page(PFN_DOWN(paddr)), obj->size, 0);
+ sg_dma_address(sg->sgl) = paddr;
+
+ /* this should be after _get_paddr() to ensure we have pages attached */
+ omap_gem_dma_sync(obj, dir);
+
+out:
+ if (ret)
+ return ERR_PTR(ret);
+ return sg;
+}
+
+static void omap_gem_unmap_dma_buf(struct dma_buf_attachment *attachment,
+ struct sg_table *sg, enum dma_data_direction dir)
+{
+ struct drm_gem_object *obj = attachment->dmabuf->priv;
+ omap_gem_put_paddr(obj);
+ sg_free_table(sg);
+ kfree(sg);
+}
+
+static void omap_gem_dmabuf_release(struct dma_buf *buffer)
+{
+ struct drm_gem_object *obj = buffer->priv;
+ /* release reference that was taken when dmabuf was exported
+ * in omap_gem_prime_set()..
+ */
+ drm_gem_object_unreference_unlocked(obj);
+}
+
+
+static int omap_gem_dmabuf_begin_cpu_access(struct dma_buf *buffer,
+ size_t start, size_t len, enum dma_data_direction dir)
+{
+ struct drm_gem_object *obj = buffer->priv;
+ struct page **pages;
+ if (omap_gem_flags(obj) & OMAP_BO_TILED) {
+ /* TODO we would need to pin at least part of the buffer to
+ * get de-tiled view. For now just reject it.
+ */
+ return -ENOMEM;
+ }
+ /* make sure we have the pages: */
+ return omap_gem_get_pages(obj, &pages, true);
+}
+
+static void omap_gem_dmabuf_end_cpu_access(struct dma_buf *buffer,
+ size_t start, size_t len, enum dma_data_direction dir)
+{
+ struct drm_gem_object *obj = buffer->priv;
+ omap_gem_put_pages(obj);
+}
+
+
+static void *omap_gem_dmabuf_kmap_atomic(struct dma_buf *buffer,
+ unsigned long page_num)
+{
+ struct drm_gem_object *obj = buffer->priv;
+ struct page **pages;
+ omap_gem_get_pages(obj, &pages, false);
+ omap_gem_cpu_sync(obj, page_num);
+ return kmap_atomic(pages[page_num]);
+}
+
+static void omap_gem_dmabuf_kunmap_atomic(struct dma_buf *buffer,
+ unsigned long page_num, void *addr)
+{
+ kunmap_atomic(addr);
+}
+
+static void *omap_gem_dmabuf_kmap(struct dma_buf *buffer,
+ unsigned long page_num)
+{
+ struct drm_gem_object *obj = buffer->priv;
+ struct page **pages;
+ omap_gem_get_pages(obj, &pages, false);
+ omap_gem_cpu_sync(obj, page_num);
+ return kmap(pages[page_num]);
+}
+
+static void omap_gem_dmabuf_kunmap(struct dma_buf *buffer,
+ unsigned long page_num, void *addr)
+{
+ struct drm_gem_object *obj = buffer->priv;
+ struct page **pages;
+ omap_gem_get_pages(obj, &pages, false);
+ kunmap(pages[page_num]);
+}
+
+/*
+ * TODO maybe we can split up drm_gem_mmap to avoid duplicating
+ * some here.. or at least have a drm_dmabuf_mmap helper.
+ */
+static int omap_gem_dmabuf_mmap(struct dma_buf *buffer,
+ struct vm_area_struct *vma)
+{
+ struct drm_gem_object *obj = buffer->priv;
+ int ret = 0;
+
+ if (WARN_ON(!obj->filp))
+ return -EINVAL;
+
+ /* Check for valid size. */
+ if (omap_gem_mmap_size(obj) < vma->vm_end - vma->vm_start) {
+ ret = -EINVAL;
+ goto out_unlock;
+ }
+
+ if (!obj->dev->driver->gem_vm_ops) {
+ ret = -EINVAL;
+ goto out_unlock;
+ }
+
+ vma->vm_flags |= VM_RESERVED | VM_IO | VM_PFNMAP | VM_DONTEXPAND;
+ vma->vm_ops = obj->dev->driver->gem_vm_ops;
+ vma->vm_private_data = obj;
+ vma->vm_page_prot = pgprot_writecombine(vm_get_page_prot(vma->vm_flags));
+
+ /* Take a ref for this mapping of the object, so that the fault
+ * handler can dereference the mmap offset's pointer to the object.
+ * This reference is cleaned up by the corresponding vm_close
+ * (which should happen whether the vma was created by this call, or
+ * by a vm_open due to mremap or partial unmap or whatever).
+ */
+ vma->vm_ops->open(vma);
+
+out_unlock:
+
+ return omap_gem_mmap_obj(obj, vma);
+}
+
+struct dma_buf_ops omap_dmabuf_ops = {
+ .map_dma_buf = omap_gem_map_dma_buf,
+ .unmap_dma_buf = omap_gem_unmap_dma_buf,
+ .release = omap_gem_dmabuf_release,
+ .begin_cpu_access = omap_gem_dmabuf_begin_cpu_access,
+ .end_cpu_access = omap_gem_dmabuf_end_cpu_access,
+ .kmap_atomic = omap_gem_dmabuf_kmap_atomic,
+ .kunmap_atomic = omap_gem_dmabuf_kunmap_atomic,
+ .kmap = omap_gem_dmabuf_kmap,
+ .kunmap = omap_gem_dmabuf_kunmap,
+ .mmap = omap_gem_dmabuf_mmap,
+};
+
+struct dma_buf * omap_gem_prime_export(struct drm_device *dev,
+ struct drm_gem_object *obj, int flags)
+{
+ return dma_buf_export(obj, &omap_dmabuf_ops, obj->size, 0600);
+}
+
+struct drm_gem_object * omap_gem_prime_import(struct drm_device *dev,
+ struct dma_buf *buffer)
+{
+ struct drm_gem_object *obj;
+
+ /* is this one of own objects? */
+ if (buffer->ops == &omap_dmabuf_ops) {
+ obj = buffer->priv;
+ /* is it from our device? */
+ if (obj->dev == dev) {
+ drm_gem_object_reference(obj);
+ return obj;
+ }
+ }
+
+ /*
+ * TODO add support for importing buffers from other devices..
+ * for now we don't need this but would be nice to add eventually
+ */
+ return ERR_PTR(-EINVAL);
+}
diff --git a/drivers/staging/omapdrm/omap_priv.h b/drivers/staging/omapdrm/omap_priv.h
deleted file mode 100644
index ef6441447147..000000000000
--- a/drivers/staging/omapdrm/omap_priv.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * include/drm/omap_priv.h
- *
- * Copyright (C) 2011 Texas Instruments
- * Author: Rob Clark <rob@ti.com>
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 as published by
- * the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef __OMAP_PRIV_H__
-#define __OMAP_PRIV_H__
-
-/* Non-userspace facing APIs
- */
-
-/* optional platform data to configure the default configuration of which
- * pipes/overlays/CRTCs are used.. if this is not provided, then instead the
- * first CONFIG_DRM_OMAP_NUM_CRTCS are used, and they are each connected to
- * one manager, with priority given to managers that are connected to
- * detected devices. Remaining overlays are used as video planes. This
- * should be a good default behavior for most cases, but yet there still
- * might be times when you wish to do something different.
- */
-struct omap_kms_platform_data {
- /* overlays to use as CRTCs: */
- int ovl_cnt;
- const int *ovl_ids;
-
- /* overlays to use as video planes: */
- int pln_cnt;
- const int *pln_ids;
-
- int mgr_cnt;
- const int *mgr_ids;
-
- int dev_cnt;
- const char **dev_names;
-};
-
-struct omap_drm_platform_data {
- struct omap_kms_platform_data *kms_pdata;
- struct omap_dmm_platform_data *dmm_pdata;
-};
-
-#endif /* __OMAP_DRM_H__ */
diff --git a/drivers/staging/omapdrm/tcm-sita.c b/drivers/staging/omapdrm/tcm-sita.c
index 10d5ac3dae4b..efb609510540 100644
--- a/drivers/staging/omapdrm/tcm-sita.c
+++ b/drivers/staging/omapdrm/tcm-sita.c
@@ -200,7 +200,7 @@ static s32 sita_reserve_1d(struct tcm *tcm, u32 num_slots,
*
* @param w width
* @param h height
- * @param area pointer to the area that will be populated with the reesrved
+ * @param area pointer to the area that will be populated with the reserved
* area
*
* @return 0 on success, non-0 error value on failure.
diff --git a/drivers/staging/ozwpan/README b/drivers/staging/ozwpan/README
index bb1a69b94541..7c055ec99544 100644
--- a/drivers/staging/ozwpan/README
+++ b/drivers/staging/ozwpan/README
@@ -9,7 +9,7 @@ technology.
To operate the driver must be bound to a suitable network interface. This can
be done when the module is loaded (specifying the name of the network interface
-as a paramter - e.g. 'insmod ozwpan g_net_dev=go0') or can be bound after
+as a parameter - e.g. 'insmod ozwpan g_net_dev=go0') or can be bound after
loading using an ioctl call. See the ozappif.h file and the ioctls
OZ_IOCTL_ADD_BINDING and OZ_IOCTL_REMOVE_BINDING.
diff --git a/drivers/staging/ozwpan/TODO b/drivers/staging/ozwpan/TODO
index c2d30a7112f3..b5db2456bffa 100644
--- a/drivers/staging/ozwpan/TODO
+++ b/drivers/staging/ozwpan/TODO
@@ -1,10 +1,11 @@
TODO:
- - review user mode interface and determine if ioctls can be replaced
- with something better. correctly export data structures to user mode
- if ioctls are still required and allocate ioctl numbers from
- ioctl-number.txt.
+ - Convert event tracing code to in-kernel tracing infrastructure
+ - Check for remaining ioctl & check if that can be converted into
+ sysfs entries
+ - Convert debug prints to appropriate dev_debug or something better
+ - Modify Kconfig to add CONFIG option for enabling/disabling event
+ tracing.
- check USB HCD implementation is complete and correct.
- - remove any debug and trace code.
- code review by USB developer community.
- testing with as many devices as possible.
diff --git a/drivers/staging/ozwpan/ozappif.h b/drivers/staging/ozwpan/ozappif.h
index af0273293872..449a6ba82337 100644
--- a/drivers/staging/ozwpan/ozappif.h
+++ b/drivers/staging/ozwpan/ozappif.h
@@ -11,13 +11,13 @@
#define OZ_IOCTL_MAGIC 0xf4
struct oz_mac_addr {
- unsigned char a[6];
+ __u8 a[6];
};
#define OZ_MAX_PDS 8
struct oz_pd_list {
- int count;
+ __u32 count;
struct oz_mac_addr addr[OZ_MAX_PDS];
};
@@ -27,20 +27,12 @@ struct oz_binding_info {
char name[OZ_MAX_BINDING_LEN];
};
-struct oz_test {
- int action;
-};
-
#define OZ_IOCTL_GET_PD_LIST _IOR(OZ_IOCTL_MAGIC, 0, struct oz_pd_list)
#define OZ_IOCTL_SET_ACTIVE_PD _IOW(OZ_IOCTL_MAGIC, 1, struct oz_mac_addr)
#define OZ_IOCTL_GET_ACTIVE_PD _IOR(OZ_IOCTL_MAGIC, 2, struct oz_mac_addr)
-#define OZ_IOCTL_CLEAR_EVENTS _IO(OZ_IOCTL_MAGIC, 3)
-#define OZ_IOCTL_GET_EVENTS _IOR(OZ_IOCTL_MAGIC, 4, struct oz_evtlist)
-#define OZ_IOCTL_ADD_BINDING _IOW(OZ_IOCTL_MAGIC, 5, struct oz_binding_info)
-#define OZ_IOCTL_TEST _IOWR(OZ_IOCTL_MAGIC, 6, struct oz_test)
-#define OZ_IOCTL_SET_EVENT_MASK _IOW(OZ_IOCTL_MAGIC, 7, unsigned long)
-#define OZ_IOCTL_REMOVE_BINDING _IOW(OZ_IOCTL_MAGIC, 8, struct oz_binding_info)
-#define OZ_IOCTL_MAX 9
+#define OZ_IOCTL_ADD_BINDING _IOW(OZ_IOCTL_MAGIC, 3, struct oz_binding_info)
+#define OZ_IOCTL_REMOVE_BINDING _IOW(OZ_IOCTL_MAGIC, 4, struct oz_binding_info)
+#define OZ_IOCTL_MAX 5
#endif /* _OZAPPIF_H */
diff --git a/drivers/staging/ozwpan/ozcdev.c b/drivers/staging/ozwpan/ozcdev.c
index 1c380d687963..d98321945802 100644
--- a/drivers/staging/ozwpan/ozcdev.c
+++ b/drivers/staging/ozwpan/ozcdev.c
@@ -41,10 +41,8 @@ struct oz_serial_ctx {
};
/*------------------------------------------------------------------------------
*/
-int g_taction;
-/*------------------------------------------------------------------------------
- */
static struct oz_cdev g_cdev;
+struct class *g_oz_class;
/*------------------------------------------------------------------------------
* Context: process and softirq
*/
@@ -276,20 +274,6 @@ long oz_cdev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
return -EFAULT;
}
break;
-#ifdef WANT_EVENT_TRACE
- case OZ_IOCTL_CLEAR_EVENTS:
- oz_events_clear();
- break;
- case OZ_IOCTL_GET_EVENTS:
- rc = oz_events_copy((void __user *)arg);
- break;
- case OZ_IOCTL_SET_EVENT_MASK:
- if (copy_from_user(&g_evt_mask, (void __user *)arg,
- sizeof(unsigned long))) {
- return -EFAULT;
- }
- break;
-#endif /* WANT_EVENT_TRACE */
case OZ_IOCTL_ADD_BINDING:
case OZ_IOCTL_REMOVE_BINDING: {
struct oz_binding_info b;
@@ -347,10 +331,11 @@ const struct file_operations oz_fops = {
int oz_cdev_register(void)
{
int err;
+ struct device *dev;
memset(&g_cdev, 0, sizeof(g_cdev));
err = alloc_chrdev_region(&g_cdev.devnum, 0, 1, "ozwpan");
if (err < 0)
- return err;
+ goto out3;
oz_trace("Alloc dev number %d:%d\n", MAJOR(g_cdev.devnum),
MINOR(g_cdev.devnum));
cdev_init(&g_cdev.cdev, &oz_fops);
@@ -359,7 +344,27 @@ int oz_cdev_register(void)
spin_lock_init(&g_cdev.lock);
init_waitqueue_head(&g_cdev.rdq);
err = cdev_add(&g_cdev.cdev, g_cdev.devnum, 1);
+ if (err < 0) {
+ oz_trace("Failed to add cdev\n");
+ goto out2;
+ }
+ g_oz_class = class_create(THIS_MODULE, "ozmo_wpan");
+ if (IS_ERR(g_oz_class)) {
+ oz_trace("Failed to register ozmo_wpan class\n");
+ goto out1;
+ }
+ dev = device_create(g_oz_class, NULL, g_cdev.devnum, NULL, "ozwpan");
+ if (IS_ERR(dev)) {
+ oz_trace("Failed to create sysfs entry for cdev\n");
+ goto out1;
+ }
return 0;
+out1:
+ cdev_del(&g_cdev.cdev);
+out2:
+ unregister_chrdev_region(g_cdev.devnum, 1);
+out3:
+ return err;
}
/*------------------------------------------------------------------------------
* Context: process
@@ -368,6 +373,10 @@ int oz_cdev_deregister(void)
{
cdev_del(&g_cdev.cdev);
unregister_chrdev_region(g_cdev.devnum, 1);
+ if (g_oz_class) {
+ device_destroy(g_oz_class, g_cdev.devnum);
+ class_destroy(g_oz_class);
+ }
return 0;
}
/*------------------------------------------------------------------------------
diff --git a/drivers/staging/ozwpan/ozevent.c b/drivers/staging/ozwpan/ozevent.c
index 73703d3e96bd..7f66b4f19b01 100644
--- a/drivers/staging/ozwpan/ozevent.c
+++ b/drivers/staging/ozwpan/ozevent.c
@@ -5,29 +5,46 @@
*/
#include "ozconfig.h"
#ifdef WANT_EVENT_TRACE
+#include <linux/module.h>
+#include <linux/debugfs.h>
#include <linux/jiffies.h>
#include <linux/uaccess.h>
#include "oztrace.h"
#include "ozevent.h"
+#include "ozappif.h"
/*------------------------------------------------------------------------------
+ * Although the event mask is logically part of the oz_evtdev structure, it is
+ * needed outside of this file so define it seperately to avoid the need to
+ * export definition of struct oz_evtdev.
*/
-unsigned long g_evt_mask = 0xffffffff;
+u32 g_evt_mask;
/*------------------------------------------------------------------------------
*/
#define OZ_MAX_EVTS 2048 /* Must be power of 2 */
-DEFINE_SPINLOCK(g_eventlock);
-static int g_evt_in;
-static int g_evt_out;
-static int g_missed_events;
-static struct oz_event g_events[OZ_MAX_EVTS];
+struct oz_evtdev {
+ struct dentry *root_dir;
+ int evt_in;
+ int evt_out;
+ int missed_events;
+ int present;
+ atomic_t users;
+ spinlock_t lock;
+ struct oz_event evts[OZ_MAX_EVTS];
+};
+
+static struct oz_evtdev g_evtdev;
+
/*------------------------------------------------------------------------------
* Context: process
*/
void oz_event_init(void)
{
+ /* Because g_evtdev is static external all fields initally zero so no
+ * need to reinitialised those.
+ */
oz_trace("Event tracing initialized\n");
- g_evt_in = g_evt_out = 0;
- g_missed_events = 0;
+ spin_lock_init(&g_evtdev.lock);
+ atomic_set(&g_evtdev.users, 0);
}
/*------------------------------------------------------------------------------
* Context: process
@@ -43,74 +60,136 @@ void oz_event_log2(u8 evt, u8 ctx1, u16 ctx2, void *ctx3, unsigned ctx4)
{
unsigned long irqstate;
int ix;
- spin_lock_irqsave(&g_eventlock, irqstate);
- ix = (g_evt_in + 1) & (OZ_MAX_EVTS - 1);
- if (ix != g_evt_out) {
- struct oz_event *e = &g_events[g_evt_in];
+ spin_lock_irqsave(&g_evtdev.lock, irqstate);
+ ix = (g_evtdev.evt_in + 1) & (OZ_MAX_EVTS - 1);
+ if (ix != g_evtdev.evt_out) {
+ struct oz_event *e = &g_evtdev.evts[g_evtdev.evt_in];
e->jiffies = jiffies;
e->evt = evt;
e->ctx1 = ctx1;
e->ctx2 = ctx2;
- e->ctx3 = ctx3;
+ e->ctx3 = (__u32)(unsigned long)ctx3;
e->ctx4 = ctx4;
- g_evt_in = ix;
+ g_evtdev.evt_in = ix;
} else {
- g_missed_events++;
+ g_evtdev.missed_events++;
}
- spin_unlock_irqrestore(&g_eventlock, irqstate);
+ spin_unlock_irqrestore(&g_evtdev.lock, irqstate);
}
/*------------------------------------------------------------------------------
* Context: process
*/
-int oz_events_copy(struct oz_evtlist __user *lst)
+static void oz_events_clear(struct oz_evtdev *dev)
{
- int first;
- int ix;
- struct hdr {
- int count;
- int missed;
- } hdr;
- ix = g_evt_out;
- hdr.count = g_evt_in - ix;
- if (hdr.count < 0)
- hdr.count += OZ_MAX_EVTS;
- if (hdr.count > OZ_EVT_LIST_SZ)
- hdr.count = OZ_EVT_LIST_SZ;
- hdr.missed = g_missed_events;
- g_missed_events = 0;
- if (copy_to_user((void __user *)lst, &hdr, sizeof(hdr)))
- return -EFAULT;
- first = OZ_MAX_EVTS - ix;
- if (first > hdr.count)
- first = hdr.count;
- if (first) {
- int sz = first*sizeof(struct oz_event);
- void __user *p = (void __user *)lst->evts;
- if (copy_to_user(p, &g_events[ix], sz))
- return -EFAULT;
- if (hdr.count > first) {
- p = (void __user *)&lst->evts[first];
- sz = (hdr.count-first)*sizeof(struct oz_event);
- if (copy_to_user(p, g_events, sz))
- return -EFAULT;
- }
+ unsigned long irqstate;
+ oz_trace("Clearing events\n");
+ spin_lock_irqsave(&dev->lock, irqstate);
+ dev->evt_in = dev->evt_out = 0;
+ dev->missed_events = 0;
+ spin_unlock_irqrestore(&dev->lock, irqstate);
+}
+#ifdef CONFIG_DEBUG_FS
+/*------------------------------------------------------------------------------
+ * Context: process
+ */
+int oz_events_open(struct inode *inode, struct file *filp)
+{
+ oz_trace("oz_evt_open()\n");
+ oz_trace("Open flags: 0x%x\n", filp->f_flags);
+ if (atomic_add_return(1, &g_evtdev.users) == 1) {
+ oz_events_clear(&g_evtdev);
+ return nonseekable_open(inode, filp);
+ } else {
+ atomic_dec(&g_evtdev.users);
+ return -EBUSY;
}
- ix += hdr.count;
- if (ix >= OZ_MAX_EVTS)
- ix -= OZ_MAX_EVTS;
- g_evt_out = ix;
+}
+/*------------------------------------------------------------------------------
+ * Context: process
+ */
+int oz_events_release(struct inode *inode, struct file *filp)
+{
+ oz_events_clear(&g_evtdev);
+ atomic_dec(&g_evtdev.users);
+ g_evt_mask = 0;
+ oz_trace("oz_evt_release()\n");
return 0;
}
/*------------------------------------------------------------------------------
* Context: process
*/
-void oz_events_clear(void)
+ssize_t oz_events_read(struct file *filp, char __user *buf, size_t count,
+ loff_t *fpos)
{
- unsigned long irqstate;
- spin_lock_irqsave(&g_eventlock, irqstate);
- g_evt_in = g_evt_out = 0;
- g_missed_events = 0;
- spin_unlock_irqrestore(&g_eventlock, irqstate);
+ struct oz_evtdev *dev = &g_evtdev;
+ int rc = 0;
+ int nb_evts = count / sizeof(struct oz_event);
+ int n;
+ int sz;
+
+ n = dev->evt_in - dev->evt_out;
+ if (n < 0)
+ n += OZ_MAX_EVTS;
+ if (nb_evts > n)
+ nb_evts = n;
+ if (nb_evts == 0)
+ goto out;
+ n = OZ_MAX_EVTS - dev->evt_out;
+ if (n > nb_evts)
+ n = nb_evts;
+ sz = n * sizeof(struct oz_event);
+ if (copy_to_user(buf, &dev->evts[dev->evt_out], sz)) {
+ rc = -EFAULT;
+ goto out;
+ }
+ if (n == nb_evts)
+ goto out2;
+ n = nb_evts - n;
+ if (copy_to_user(buf + sz, dev->evts, n * sizeof(struct oz_event))) {
+ rc = -EFAULT;
+ goto out;
+ }
+out2:
+ dev->evt_out = (dev->evt_out + nb_evts) & (OZ_MAX_EVTS - 1);
+ rc = nb_evts * sizeof(struct oz_event);
+out:
+ return rc;
}
-#endif /* WANT_EVENT_TRACE */
+/*------------------------------------------------------------------------------
+ */
+const struct file_operations oz_events_fops = {
+ .owner = THIS_MODULE,
+ .open = oz_events_open,
+ .release = oz_events_release,
+ .read = oz_events_read,
+};
+/*------------------------------------------------------------------------------
+ * Context: process
+ */
+void oz_debugfs_init(void)
+{
+ struct dentry *parent;
+ parent = debugfs_create_dir("ozwpan", NULL);
+ if (parent == NULL) {
+ oz_trace("Failed to create debugfs directory ozmo\n");
+ return;
+ } else {
+ g_evtdev.root_dir = parent;
+ if (debugfs_create_file("events", S_IRUSR, parent, NULL,
+ &oz_events_fops) == NULL)
+ oz_trace("Failed to create file ozmo/events\n");
+ if (debugfs_create_x32("event_mask", S_IRUSR | S_IWUSR, parent,
+ &g_evt_mask) == NULL)
+ oz_trace("Failed to create file ozmo/event_mask\n");
+ }
+}
+/*------------------------------------------------------------------------------
+ * Context: process
+ */
+void oz_debugfs_remove(void)
+{
+ debugfs_remove_recursive(g_evtdev.root_dir);
+}
+#endif /* CONFIG_DEBUG_FS */
+#endif /* WANT_EVENT_TRACE */
diff --git a/drivers/staging/ozwpan/ozevent.h b/drivers/staging/ozwpan/ozevent.h
index f033d014c6f3..32f6f9859c41 100644
--- a/drivers/staging/ozwpan/ozevent.h
+++ b/drivers/staging/ozwpan/ozevent.h
@@ -9,23 +9,24 @@
#include "ozeventdef.h"
#ifdef WANT_EVENT_TRACE
-extern unsigned long g_evt_mask;
+extern u32 g_evt_mask;
void oz_event_init(void);
void oz_event_term(void);
void oz_event_log2(u8 evt, u8 ctx1, u16 ctx2, void *ctx3, unsigned ctx4);
+void oz_debugfs_init(void);
+void oz_debugfs_remove(void);
#define oz_event_log(__evt, __ctx1, __ctx2, __ctx3, __ctx4) \
do { \
if ((1<<(__evt)) & g_evt_mask) \
oz_event_log2(__evt, __ctx1, __ctx2, __ctx3, __ctx4); \
} while (0)
-int oz_events_copy(struct oz_evtlist __user *lst);
-void oz_events_clear(void);
+
#else
#define oz_event_init()
#define oz_event_term()
#define oz_event_log(__evt, __ctx1, __ctx2, __ctx3, __ctx4)
-#define oz_events_copy(__lst)
-#define oz_events_clear()
+#define oz_debugfs_init()
+#define oz_debugfs_remove()
#endif /* WANT_EVENT_TRACE */
#endif /* _OZEVENT_H */
diff --git a/drivers/staging/ozwpan/ozeventdef.h b/drivers/staging/ozwpan/ozeventdef.h
index a880288bab11..4b938981671a 100644
--- a/drivers/staging/ozwpan/ozeventdef.h
+++ b/drivers/staging/ozwpan/ozeventdef.h
@@ -29,19 +29,12 @@
#define OZ_EVT_DEBUG 20
struct oz_event {
- unsigned long jiffies;
- unsigned char evt;
- unsigned char ctx1;
- unsigned short ctx2;
- void *ctx3;
- unsigned ctx4;
-};
-
-#define OZ_EVT_LIST_SZ 64
-struct oz_evtlist {
- int count;
- int missed;
- struct oz_event evts[OZ_EVT_LIST_SZ];
+ __u32 jiffies;
+ __u8 evt;
+ __u8 ctx1;
+ __u16 ctx2;
+ __u32 ctx3;
+ __u32 ctx4;
};
#endif /* _OZEVENTDEF_H */
diff --git a/drivers/staging/ozwpan/ozhcd.c b/drivers/staging/ozwpan/ozhcd.c
index 750b14eb505e..251f07c39a6b 100644
--- a/drivers/staging/ozwpan/ozhcd.c
+++ b/drivers/staging/ozwpan/ozhcd.c
@@ -1416,7 +1416,7 @@ static void oz_process_ep0_urb(struct oz_hcd *ozhcd, struct urb *urb,
oz_trace("USB_REQ_SET_CONFIGURATION - req\n");
break;
case USB_REQ_GET_CONFIGURATION:
- /* We short curcuit this case and reply directly since
+ /* We short circuit this case and reply directly since
* we have the selected configuration number cached.
*/
oz_event_log(OZ_EVT_CTRL_LOCAL, setup->bRequest, 0, 0,
@@ -1432,7 +1432,7 @@ static void oz_process_ep0_urb(struct oz_hcd *ozhcd, struct urb *urb,
}
break;
case USB_REQ_GET_INTERFACE:
- /* We short curcuit this case and reply directly since
+ /* We short circuit this case and reply directly since
* we have the selected interface alternative cached.
*/
oz_event_log(OZ_EVT_CTRL_LOCAL, setup->bRequest, 0, 0,
@@ -1463,7 +1463,7 @@ static void oz_process_ep0_urb(struct oz_hcd *ozhcd, struct urb *urb,
rc = -ENOMEM;
} else {
/* Note: we are queuing the request after we have
- * submitted it to be tranmitted. If the request were
+ * submitted it to be transmitted. If the request were
* to complete before we queued it then it would not
* be found in the queue. It seems impossible for
* this to happen but if it did the request would
diff --git a/drivers/staging/ozwpan/ozmain.c b/drivers/staging/ozwpan/ozmain.c
index aaf2ccc0bcfb..c1ed6b2522ec 100644
--- a/drivers/staging/ozwpan/ozmain.c
+++ b/drivers/staging/ozwpan/ozmain.c
@@ -33,6 +33,9 @@ static int __init ozwpan_init(void)
oz_protocol_init(g_net_dev);
oz_app_enable(OZ_APPID_USB, 1);
oz_apps_init();
+#ifdef CONFIG_DEBUG_FS
+ oz_debugfs_init();
+#endif
return 0;
}
/*------------------------------------------------------------------------------
@@ -44,6 +47,9 @@ static void __exit ozwpan_exit(void)
oz_apps_term();
oz_cdev_deregister();
oz_event_term();
+#ifdef CONFIG_DEBUG_FS
+ oz_debugfs_remove();
+#endif
}
/*------------------------------------------------------------------------------
*/
@@ -53,6 +59,6 @@ module_exit(ozwpan_exit);
MODULE_AUTHOR("Chris Kelly");
MODULE_DESCRIPTION("Ozmo Devices USB over WiFi hcd driver");
-MODULE_VERSION("1.0.8");
+MODULE_VERSION("1.0.10");
MODULE_LICENSE("GPL");
diff --git a/drivers/staging/ozwpan/ozpd.c b/drivers/staging/ozwpan/ozpd.c
index 04cd57f2a6da..6c287ac6eaea 100644
--- a/drivers/staging/ozwpan/ozpd.c
+++ b/drivers/staging/ozwpan/ozpd.c
@@ -24,18 +24,22 @@
/*------------------------------------------------------------------------------
*/
#define OZ_MAX_TX_POOL_SIZE 6
-/* Maximum number of uncompleted isoc frames that can be pending.
+/* Maximum number of uncompleted isoc frames that can be pending in network.
*/
#define OZ_MAX_SUBMITTED_ISOC 16
+/* Maximum number of uncompleted isoc frames that can be pending in Tx Queue.
+ */
+#define OZ_MAX_TX_QUEUE_ISOC 32
/*------------------------------------------------------------------------------
*/
static struct oz_tx_frame *oz_tx_frame_alloc(struct oz_pd *pd);
static void oz_tx_frame_free(struct oz_pd *pd, struct oz_tx_frame *f);
+static void oz_tx_isoc_free(struct oz_pd *pd, struct oz_tx_frame *f);
static struct sk_buff *oz_build_frame(struct oz_pd *pd, struct oz_tx_frame *f);
static int oz_send_isoc_frame(struct oz_pd *pd);
static void oz_retire_frame(struct oz_pd *pd, struct oz_tx_frame *f);
static void oz_isoc_stream_free(struct oz_isoc_stream *st);
-static int oz_send_next_queued_frame(struct oz_pd *pd, int *more_data);
+static int oz_send_next_queued_frame(struct oz_pd *pd, int more_data);
static void oz_isoc_destructor(struct sk_buff *skb);
static int oz_def_app_init(void);
static void oz_def_app_term(void);
@@ -208,6 +212,8 @@ void oz_pd_destroy(struct oz_pd *pd)
while (e != &pd->tx_queue) {
f = container_of(e, struct oz_tx_frame, link);
e = e->next;
+ if (f->skb != NULL)
+ kfree_skb(f->skb);
oz_retire_frame(pd, f);
}
oz_elt_buf_term(&pd->elt_buff);
@@ -375,6 +381,23 @@ static struct oz_tx_frame *oz_tx_frame_alloc(struct oz_pd *pd)
/*------------------------------------------------------------------------------
* Context: softirq or process
*/
+static void oz_tx_isoc_free(struct oz_pd *pd, struct oz_tx_frame *f)
+{
+ pd->nb_queued_isoc_frames--;
+ list_del_init(&f->link);
+ if (pd->tx_pool_count < OZ_MAX_TX_POOL_SIZE) {
+ f->link.next = pd->tx_pool;
+ pd->tx_pool = &f->link;
+ pd->tx_pool_count++;
+ } else {
+ kfree(f);
+ }
+ oz_trace2(OZ_TRACE_TX_FRAMES, "Releasing ISOC Frame isoc_nb= %d\n",
+ pd->nb_queued_isoc_frames);
+}
+/*------------------------------------------------------------------------------
+ * Context: softirq or process
+ */
static void oz_tx_frame_free(struct oz_pd *pd, struct oz_tx_frame *f)
{
spin_lock_bh(&pd->tx_frame_lock);
@@ -389,6 +412,22 @@ static void oz_tx_frame_free(struct oz_pd *pd, struct oz_tx_frame *f)
kfree(f);
}
/*------------------------------------------------------------------------------
+ * Context: softirq-serialized
+ */
+void oz_set_more_bit(struct sk_buff *skb)
+{
+ struct oz_hdr *oz_hdr = (struct oz_hdr *)skb_network_header(skb);
+ oz_hdr->control |= OZ_F_MORE_DATA;
+}
+/*------------------------------------------------------------------------------
+ * Context: softirq-serialized
+ */
+void oz_set_last_pkt_nb(struct oz_pd *pd, struct sk_buff *skb)
+{
+ struct oz_hdr *oz_hdr = (struct oz_hdr *)skb_network_header(skb);
+ oz_hdr->last_pkt_num = pd->trigger_pkt_num & OZ_LAST_PN_MASK;
+}
+/*------------------------------------------------------------------------------
* Context: softirq
*/
int oz_prepare_frame(struct oz_pd *pd, int empty)
@@ -403,6 +442,7 @@ int oz_prepare_frame(struct oz_pd *pd, int empty)
f = oz_tx_frame_alloc(pd);
if (f == 0)
return -1;
+ f->skb = NULL;
f->hdr.control =
(OZ_PROTOCOL_VERSION<<OZ_VERSION_SHIFT) | OZ_F_ACK_REQUESTED;
++pd->last_tx_pkt_num;
@@ -486,24 +526,52 @@ static void oz_retire_frame(struct oz_pd *pd, struct oz_tx_frame *f)
/*------------------------------------------------------------------------------
* Context: softirq-serialized
*/
-static int oz_send_next_queued_frame(struct oz_pd *pd, int *more_data)
+static int oz_send_next_queued_frame(struct oz_pd *pd, int more_data)
{
struct sk_buff *skb;
struct oz_tx_frame *f;
struct list_head *e;
- *more_data = 0;
spin_lock(&pd->tx_frame_lock);
e = pd->last_sent_frame->next;
if (e == &pd->tx_queue) {
spin_unlock(&pd->tx_frame_lock);
return -1;
}
- pd->last_sent_frame = e;
- if (e->next != &pd->tx_queue)
- *more_data = 1;
f = container_of(e, struct oz_tx_frame, link);
+
+ if (f->skb != NULL) {
+ skb = f->skb;
+ oz_tx_isoc_free(pd, f);
+ spin_unlock(&pd->tx_frame_lock);
+ if (more_data)
+ oz_set_more_bit(skb);
+ oz_set_last_pkt_nb(pd, skb);
+ if ((int)atomic_read(&g_submitted_isoc) <
+ OZ_MAX_SUBMITTED_ISOC) {
+ if (dev_queue_xmit(skb) < 0) {
+ oz_trace2(OZ_TRACE_TX_FRAMES,
+ "Dropping ISOC Frame\n");
+ oz_event_log(OZ_EVT_TX_ISOC_DROP, 0, 0, 0, 0);
+ return -1;
+ }
+ atomic_inc(&g_submitted_isoc);
+ oz_trace2(OZ_TRACE_TX_FRAMES,
+ "Sending ISOC Frame, nb_isoc= %d\n",
+ pd->nb_queued_isoc_frames);
+ return 0;
+ } else {
+ kfree_skb(skb);
+ oz_trace2(OZ_TRACE_TX_FRAMES, "Dropping ISOC Frame>\n");
+ oz_event_log(OZ_EVT_TX_ISOC_DROP, 0, 0, 0, 0);
+ return -1;
+ }
+ }
+
+ pd->last_sent_frame = e;
skb = oz_build_frame(pd, f);
spin_unlock(&pd->tx_frame_lock);
+ if (more_data)
+ oz_set_more_bit(skb);
oz_trace2(OZ_TRACE_TX_FRAMES, "TX frame PN=0x%x\n", f->hdr.pkt_num);
if (skb) {
oz_event_log(OZ_EVT_TX_FRAME,
@@ -512,6 +580,7 @@ static int oz_send_next_queued_frame(struct oz_pd *pd, int *more_data)
0, f->hdr.pkt_num);
if (dev_queue_xmit(skb) < 0)
return -1;
+
}
return 0;
}
@@ -520,21 +589,38 @@ static int oz_send_next_queued_frame(struct oz_pd *pd, int *more_data)
*/
void oz_send_queued_frames(struct oz_pd *pd, int backlog)
{
- int more;
- if (backlog < OZ_MAX_QUEUED_FRAMES) {
- if (oz_send_next_queued_frame(pd, &more) >= 0) {
- while (more && oz_send_next_queued_frame(pd, &more))
- ;
- } else {
- if (((pd->mode & OZ_F_ISOC_ANYTIME) == 0)
- || (pd->isoc_sent == 0)) {
- if (oz_prepare_frame(pd, 1) >= 0)
- oz_send_next_queued_frame(pd, &more);
- }
+ while (oz_prepare_frame(pd, 0) >= 0)
+ backlog++;
+
+ switch (pd->mode & (OZ_F_ISOC_NO_ELTS | OZ_F_ISOC_ANYTIME)) {
+
+ case OZ_F_ISOC_NO_ELTS: {
+ backlog += pd->nb_queued_isoc_frames;
+ if (backlog <= 0)
+ goto out;
+ if (backlog > OZ_MAX_SUBMITTED_ISOC)
+ backlog = OZ_MAX_SUBMITTED_ISOC;
+ break;
+ }
+ case OZ_NO_ELTS_ANYTIME: {
+ if ((backlog <= 0) && (pd->isoc_sent == 0))
+ goto out;
+ break;
+ }
+ default: {
+ if (backlog <= 0)
+ goto out;
+ break;
}
- } else {
- oz_send_next_queued_frame(pd, &more);
}
+ while (backlog--) {
+ if (oz_send_next_queued_frame(pd, backlog) < 0)
+ break;
+ }
+ return;
+
+out: oz_prepare_frame(pd, 1);
+ oz_send_next_queued_frame(pd, 0);
}
/*------------------------------------------------------------------------------
* Context: softirq
@@ -603,8 +689,10 @@ void oz_retire_tx_frames(struct oz_pd *pd, u8 lpn)
f = container_of(e, struct oz_tx_frame, link);
pkt_num = le32_to_cpu(get_unaligned(&f->hdr.pkt_num));
diff = (lpn - (pkt_num & OZ_LAST_PN_MASK)) & OZ_LAST_PN_MASK;
- if (diff > OZ_LAST_PN_HALF_CYCLE)
+ if ((diff > OZ_LAST_PN_HALF_CYCLE) || (pkt_num == 0))
break;
+ oz_trace2(OZ_TRACE_TX_FRAMES, "Releasing pkt_num= %u, nb= %d\n",
+ pkt_num, pd->nb_queued_frames);
if (first == 0)
first = e;
last = e;
@@ -727,6 +815,8 @@ int oz_send_isoc_unit(struct oz_pd *pd, u8 ep_num, u8 *data, int len)
skb_reset_network_header(skb);
skb->dev = dev;
skb->protocol = htons(OZ_ETHERTYPE);
+ /* For audio packet set priority to AC_VO */
+ skb->priority = 0x7;
size = sizeof(struct oz_hdr) + sizeof(struct oz_isoc_large);
oz_hdr = (struct oz_hdr *)skb_put(skb, size);
}
@@ -756,21 +846,53 @@ int oz_send_isoc_unit(struct oz_pd *pd, u8 ep_num, u8 *data, int len)
memcpy(oz_hdr, &oz, sizeof(oz));
memcpy(oz_hdr+1, &iso, sizeof(iso));
if (dev_hard_header(skb, dev, OZ_ETHERTYPE, pd->mac_addr,
- dev->dev_addr, skb->len) < 0) {
- kfree_skb(skb);
- return -1;
+ dev->dev_addr, skb->len) < 0)
+ goto out;
+
+ skb->destructor = oz_isoc_destructor;
+ /*Queue for Xmit if mode is not ANYTIME*/
+ if (!(pd->mode & OZ_F_ISOC_ANYTIME)) {
+ struct oz_tx_frame *isoc_unit = NULL;
+ int nb = pd->nb_queued_isoc_frames;
+ if (nb >= OZ_MAX_TX_QUEUE_ISOC) {
+ oz_trace2(OZ_TRACE_TX_FRAMES,
+ "Dropping ISOC Unit nb= %d\n",
+ nb);
+ goto out;
+ }
+ isoc_unit = oz_tx_frame_alloc(pd);
+ if (isoc_unit == NULL)
+ goto out;
+ isoc_unit->hdr = oz;
+ isoc_unit->skb = skb;
+ spin_lock_bh(&pd->tx_frame_lock);
+ list_add_tail(&isoc_unit->link, &pd->tx_queue);
+ pd->nb_queued_isoc_frames++;
+ spin_unlock_bh(&pd->tx_frame_lock);
+ oz_trace2(OZ_TRACE_TX_FRAMES,
+ "Added ISOC Frame to Tx Queue isoc_nb= %d, nb= %d\n",
+ pd->nb_queued_isoc_frames, pd->nb_queued_frames);
+ oz_event_log(OZ_EVT_TX_ISOC, nb_units, iso.frame_number,
+ skb, atomic_read(&g_submitted_isoc));
+ return 0;
}
+
+ /*In ANYTIME mode Xmit unit immediately*/
if (atomic_read(&g_submitted_isoc) < OZ_MAX_SUBMITTED_ISOC) {
- skb->destructor = oz_isoc_destructor;
atomic_inc(&g_submitted_isoc);
oz_event_log(OZ_EVT_TX_ISOC, nb_units, iso.frame_number,
- skb, atomic_read(&g_submitted_isoc));
- if (dev_queue_xmit(skb) < 0)
+ skb, atomic_read(&g_submitted_isoc));
+ if (dev_queue_xmit(skb) < 0) {
+ oz_event_log(OZ_EVT_TX_ISOC_DROP, 0, 0, 0, 0);
return -1;
- } else {
- oz_event_log(OZ_EVT_TX_ISOC_DROP, 0, 0, 0, 0);
- kfree_skb(skb);
+ } else
+ return 0;
}
+
+out: oz_event_log(OZ_EVT_TX_ISOC_DROP, 0, 0, 0, 0);
+ kfree_skb(skb);
+ return -1;
+
}
return 0;
}
diff --git a/drivers/staging/ozwpan/ozpd.h b/drivers/staging/ozwpan/ozpd.h
index afc77f0260f0..ddf1341b4e67 100644
--- a/drivers/staging/ozwpan/ozpd.h
+++ b/drivers/staging/ozwpan/ozpd.h
@@ -29,6 +29,7 @@ struct oz_tx_frame {
struct list_head link;
struct list_head elt_list;
struct oz_hdr hdr;
+ struct sk_buff *skb;
int total_size;
};
@@ -83,6 +84,7 @@ struct oz_pd {
u8 ms_per_isoc;
unsigned max_stream_buffering;
int nb_queued_frames;
+ int nb_queued_isoc_frames;
struct list_head *tx_pool;
int tx_pool_count;
spinlock_t tx_frame_lock;
@@ -118,4 +120,3 @@ void oz_apps_init(void);
void oz_apps_term(void);
#endif /* Sentry */
-
diff --git a/drivers/staging/ozwpan/ozproto.c b/drivers/staging/ozwpan/ozproto.c
index ad857eeabbb7..a50ab18a5987 100644
--- a/drivers/staging/ozwpan/ozproto.c
+++ b/drivers/staging/ozwpan/ozproto.c
@@ -217,7 +217,6 @@ static struct oz_pd *oz_connect_req(struct oz_pd *cur_pd, struct oz_elt *elt,
pd->mode = body->mode;
pd->pd_info = body->pd_info;
if (pd->mode & OZ_F_ISOC_NO_ELTS) {
- pd->mode |= OZ_F_ISOC_ANYTIME;
pd->ms_per_isoc = body->ms_per_isoc;
if (!pd->ms_per_isoc)
pd->ms_per_isoc = 4;
@@ -366,6 +365,7 @@ static void oz_rx_frame(struct sk_buff *skb)
}
if (pd && !dup && ((pd->mode & OZ_MODE_MASK) == OZ_MODE_TRIGGERED)) {
+ oz_trace2(OZ_TRACE_RX_FRAMES, "Received TRIGGER Frame\n");
pd->last_sent_frame = &pd->tx_queue;
if (oz_hdr->control & OZ_F_ACK) {
/* Retire completed frames */
@@ -376,8 +376,6 @@ static void oz_rx_frame(struct sk_buff *skb)
int backlog = pd->nb_queued_frames;
pd->trigger_pkt_num = pkt_num;
/* Send queued frames */
- while (oz_prepare_frame(pd, 0) >= 0)
- ;
oz_send_queued_frames(pd, backlog);
}
}
@@ -796,7 +794,7 @@ void oz_binding_add(char *net_dev)
{
struct oz_binding *binding;
- binding = kmalloc(sizeof(struct oz_binding), GFP_ATOMIC);
+ binding = kmalloc(sizeof(struct oz_binding), GFP_KERNEL);
if (binding) {
binding->ptype.type = __constant_htons(OZ_ETHERTYPE);
binding->ptype.func = oz_pkt_recv;
diff --git a/drivers/staging/ozwpan/ozprotocol.h b/drivers/staging/ozwpan/ozprotocol.h
index b3e7d77f3fff..1e4edbeb61cd 100644
--- a/drivers/staging/ozwpan/ozprotocol.h
+++ b/drivers/staging/ozwpan/ozprotocol.h
@@ -89,6 +89,7 @@ struct oz_elt_connect_req {
#define OZ_MODE_MASK 0xf
#define OZ_F_ISOC_NO_ELTS 0x40
#define OZ_F_ISOC_ANYTIME 0x80
+#define OZ_NO_ELTS_ANYTIME 0xc0
/* Keep alive field.
*/
diff --git a/drivers/staging/ozwpan/ozusbsvc.c b/drivers/staging/ozwpan/ozusbsvc.c
index 9e74f9602384..8fa7f256ad8c 100644
--- a/drivers/staging/ozwpan/ozusbsvc.c
+++ b/drivers/staging/ozwpan/ozusbsvc.c
@@ -7,7 +7,7 @@
* The implementation of this service is split into two parts the first of which
* is protocol independent and the second contains protocol specific details.
* This split is to allow alternative protocols to be defined.
- * The implemenation of this service uses ozhcd.c to implement a USB HCD.
+ * The implementation of this service uses ozhcd.c to implement a USB HCD.
* -----------------------------------------------------------------------------
*/
#include <linux/init.h>
diff --git a/drivers/staging/panel/panel.c b/drivers/staging/panel/panel.c
index 6183573f112f..39f9982c2708 100644
--- a/drivers/staging/panel/panel.c
+++ b/drivers/staging/panel/panel.c
@@ -34,6 +34,8 @@
*
*/
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
#include <linux/module.h>
#include <linux/types.h>
@@ -754,7 +756,7 @@ static void lcd_backlight(int on)
if (lcd_bl_pin == PIN_NONE)
return;
- /* The backlight is activated by seting the AUTOFEED line to +5V */
+ /* The backlight is activated by setting the AUTOFEED line to +5V */
spin_lock(&pprt_lock);
bits.bl = on;
panel_set_bits();
@@ -1837,12 +1839,6 @@ static void panel_process_inputs(void)
struct list_head *item;
struct logical_input *input;
-#if 0
- printk(KERN_DEBUG
- "entering panel_process_inputs with pp=%016Lx & pc=%016Lx\n",
- phys_prev, phys_curr);
-#endif
-
keypressed = 0;
inputs_stable = 1;
list_for_each(item, &logical_inputs) {
@@ -1987,10 +1983,9 @@ static struct logical_input *panel_bind_key(char *name, char *press,
struct logical_input *key;
key = kzalloc(sizeof(struct logical_input), GFP_KERNEL);
- if (!key) {
- printk(KERN_ERR "panel: not enough memory\n");
+ if (!key)
return NULL;
- }
+
if (!input_name2mask(name, &key->mask, &key->value, &scan_mask_i,
&scan_mask_o)) {
kfree(key);
@@ -2002,10 +1997,6 @@ static struct logical_input *panel_bind_key(char *name, char *press,
key->rise_time = 1;
key->fall_time = 1;
-#if 0
- printk(KERN_DEBUG "bind: <%s> : m=%016Lx v=%016Lx\n", name, key->mask,
- key->value);
-#endif
strncpy(key->u.kbd.press_str, press, sizeof(key->u.kbd.press_str));
strncpy(key->u.kbd.repeat_str, repeat, sizeof(key->u.kbd.repeat_str));
strncpy(key->u.kbd.release_str, release,
@@ -2030,10 +2021,9 @@ static struct logical_input *panel_bind_callback(char *name,
struct logical_input *callback;
callback = kmalloc(sizeof(struct logical_input), GFP_KERNEL);
- if (!callback) {
- printk(KERN_ERR "panel: not enough memory\n");
+ if (!callback)
return NULL;
- }
+
memset(callback, 0, sizeof(struct logical_input));
if (!input_name2mask(name, &callback->mask, &callback->value,
&scan_mask_i, &scan_mask_o))
@@ -2110,10 +2100,8 @@ static void panel_attach(struct parport *port)
return;
if (pprt) {
- printk(KERN_ERR
- "panel_attach(): port->number=%d parport=%d, "
- "already registered !\n",
- port->number, parport);
+ pr_err("%s: port->number=%d parport=%d, already registered!\n",
+ __func__, port->number, parport);
return;
}
@@ -2122,16 +2110,14 @@ static void panel_attach(struct parport *port)
/*PARPORT_DEV_EXCL */
0, (void *)&pprt);
if (pprt == NULL) {
- pr_err("panel_attach(): port->number=%d parport=%d, "
- "parport_register_device() failed\n",
- port->number, parport);
+ pr_err("%s: port->number=%d parport=%d, parport_register_device() failed\n",
+ __func__, port->number, parport);
return;
}
if (parport_claim(pprt)) {
- printk(KERN_ERR
- "Panel: could not claim access to parport%d. "
- "Aborting.\n", parport);
+ pr_err("could not claim access to parport%d. Aborting.\n",
+ parport);
goto err_unreg_device;
}
@@ -2165,10 +2151,8 @@ static void panel_detach(struct parport *port)
return;
if (!pprt) {
- printk(KERN_ERR
- "panel_detach(): port->number=%d parport=%d, "
- "nothing to unregister.\n",
- port->number, parport);
+ pr_err("%s: port->number=%d parport=%d, nothing to unregister.\n",
+ __func__, port->number, parport);
return;
}
@@ -2278,8 +2262,7 @@ int panel_init(void)
init_in_progress = 1;
if (parport_register_driver(&panel_driver)) {
- printk(KERN_ERR
- "Panel: could not register with parport. Aborting.\n");
+ pr_err("could not register with parport. Aborting.\n");
return -EIO;
}
@@ -2291,20 +2274,19 @@ int panel_init(void)
pprt = NULL;
}
parport_unregister_driver(&panel_driver);
- printk(KERN_ERR "Panel driver version " PANEL_VERSION
- " disabled.\n");
+ pr_err("driver version " PANEL_VERSION " disabled.\n");
return -ENODEV;
}
register_reboot_notifier(&panel_notifier);
if (pprt)
- printk(KERN_INFO "Panel driver version " PANEL_VERSION
- " registered on parport%d (io=0x%lx).\n", parport,
- pprt->port->base);
+ pr_info("driver version " PANEL_VERSION
+ " registered on parport%d (io=0x%lx).\n", parport,
+ pprt->port->base);
else
- printk(KERN_INFO "Panel driver version " PANEL_VERSION
- " not yet registered\n");
+ pr_info("driver version " PANEL_VERSION
+ " not yet registered\n");
/* tells various subsystems about the fact that initialization
is finished */
init_in_progress = 0;
diff --git a/drivers/staging/phison/phison.c b/drivers/staging/phison/phison.c
index d77b21f1eb2d..919cb95236fc 100644
--- a/drivers/staging/phison/phison.c
+++ b/drivers/staging/phison/phison.c
@@ -87,18 +87,7 @@ static struct pci_driver phison_pci_driver = {
#endif
};
-static int __init phison_ide_init(void)
-{
- return pci_register_driver(&phison_pci_driver);
-}
-
-static void __exit phison_ide_exit(void)
-{
- pci_unregister_driver(&phison_pci_driver);
-}
-
-module_init(phison_ide_init);
-module_exit(phison_ide_exit);
+module_pci_driver(phison_pci_driver);
MODULE_AUTHOR("Evan Ko");
MODULE_DESCRIPTION("PCIE driver module for PHISON PS5000 E-BOX");
diff --git a/drivers/staging/quatech_usb2/Kconfig b/drivers/staging/quatech_usb2/Kconfig
deleted file mode 100644
index 1494f42f3da0..000000000000
--- a/drivers/staging/quatech_usb2/Kconfig
+++ /dev/null
@@ -1,15 +0,0 @@
-config USB_SERIAL_QUATECH_USB2
- tristate "USB Quatech xSU2-[14]00 USB Serial Driver"
- depends on USB_SERIAL
- help
- Say Y here if you want to use a Quatech USB2.0 to serial adaptor. This
- driver supports the SSU2-100, DSU2-100, DSU2-400, QSU2-100, QSU2-400,
- ESU2-400 and ESU2-100 USB2.0 to RS232 / 485 / 422 serial adaptors.
-
- Some hardware has an incorrect product string and announces itself as
- ESU-100 (which uses the serqt driver) even though it is an ESU2-100.
- Check the label on the bottom of your device.
-
- To compile this driver as a module, choose M here: the module will be
- called quatech_usb2 .
-
diff --git a/drivers/staging/quatech_usb2/Makefile b/drivers/staging/quatech_usb2/Makefile
deleted file mode 100644
index bcd1f890d163..000000000000
--- a/drivers/staging/quatech_usb2/Makefile
+++ /dev/null
@@ -1 +0,0 @@
-obj-$(CONFIG_USB_SERIAL_QUATECH_USB2) += quatech_usb2.o
diff --git a/drivers/staging/quatech_usb2/TODO b/drivers/staging/quatech_usb2/TODO
deleted file mode 100644
index 67f61dbe14ac..000000000000
--- a/drivers/staging/quatech_usb2/TODO
+++ /dev/null
@@ -1,8 +0,0 @@
-Incomplete list of things that this driver does not yet implement completely or
-at all. some of these may not be possible to implement because the hardware
-support does not exist. Others may be possible, but the magic control codes to
-make them happen are unknown, and some may just need the driver support to
-implement them writing.
-
-* Mark/Space parity is not implemented (reported back correctly)
-* IXANY flow control mode is not implemented (flag ignored completely)
diff --git a/drivers/staging/quatech_usb2/quatech_usb2.c b/drivers/staging/quatech_usb2/quatech_usb2.c
deleted file mode 100644
index bb977e00cc86..000000000000
--- a/drivers/staging/quatech_usb2/quatech_usb2.c
+++ /dev/null
@@ -1,1976 +0,0 @@
-/*
- * Driver for Quatech Inc USB2.0 to serial adaptors. Largely unrelated to the
- * serqt_usb driver, based on a re-write of the vendor supplied serqt_usb2 code,
- * which is unrelated to the serqt_usb2 in the staging kernel
- */
-
-#include <linux/errno.h>
-#include <linux/init.h>
-#include <linux/slab.h>
-#include <linux/tty.h>
-#include <linux/tty_driver.h>
-#include <linux/tty_flip.h>
-#include <linux/module.h>
-#include <linux/serial.h>
-#include <linux/usb.h>
-#include <linux/usb/serial.h>
-#include <linux/uaccess.h>
-
-static bool debug;
-
-/* Version Information */
-#define DRIVER_VERSION "v2.00"
-#define DRIVER_AUTHOR "Tim Gobeli, Quatech, Inc"
-#define DRIVER_DESC "Quatech USB 2.0 to Serial Driver"
-
-/* vendor and device IDs */
-#define USB_VENDOR_ID_QUATECH 0x061d /* Quatech VID */
-#define QUATECH_SSU2_100 0xC120 /* RS232 single port */
-#define QUATECH_DSU2_100 0xC140 /* RS232 dual port */
-#define QUATECH_DSU2_400 0xC150 /* RS232/422/485 dual port */
-#define QUATECH_QSU2_100 0xC160 /* RS232 four port */
-#define QUATECH_QSU2_400 0xC170 /* RS232/422/485 four port */
-#define QUATECH_ESU2_100 0xC1A0 /* RS232 eight port */
-#define QUATECH_ESU2_400 0xC180 /* RS232/422/485 eight port */
-
-/* magic numbers go here, when we find out which ones are needed */
-
-#define QU2BOXPWRON 0x8000 /* magic number to turn FPGA power on */
-#define QU2BOX232 0x40 /* RS232 mode on MEI devices */
-#define QU2BOXSPD9600 0x60 /* set speed to 9600 baud */
-#define QT2_FIFO_DEPTH 1024 /* size of hardware fifos */
-#define QT2_TX_HEADER_LENGTH 5
-/* length of the header sent to the box with each write URB */
-
-/* directions for USB transfers */
-#define USBD_TRANSFER_DIRECTION_IN 0xc0
-#define USBD_TRANSFER_DIRECTION_OUT 0x40
-
-/* special Quatech command IDs. These are pushed down the
- USB control pipe to get the box on the end to do things */
-#define QT_SET_GET_DEVICE 0xc2
-#define QT_OPEN_CLOSE_CHANNEL 0xca
-/*#define QT_GET_SET_PREBUF_TRIG_LVL 0xcc
-#define QT_SET_ATF 0xcd*/
-#define QT2_GET_SET_REGISTER 0xc0
-#define QT2_GET_SET_UART 0xc1
-#define QT2_HW_FLOW_CONTROL_MASK 0xc5
-#define QT2_SW_FLOW_CONTROL_MASK 0xc6
-#define QT2_SW_FLOW_CONTROL_DISABLE 0xc7
-#define QT2_BREAK_CONTROL 0xc8
-#define QT2_STOP_RECEIVE 0xe0
-#define QT2_FLUSH_DEVICE 0xc4
-#define QT2_GET_SET_QMCR 0xe1
-
-/* sorts of flush we can do on */
-#define QT2_FLUSH_RX 0x00
-#define QT2_FLUSH_TX 0x01
-
-/* port setting constants, used to set up serial port speeds, flow
- * control and so on */
-#define QT2_SERIAL_MCR_DTR 0x01
-#define QT2_SERIAL_MCR_RTS 0x02
-#define QT2_SERIAL_MCR_LOOP 0x10
-
-#define QT2_SERIAL_MSR_CTS 0x10
-#define QT2_SERIAL_MSR_CD 0x80
-#define QT2_SERIAL_MSR_RI 0x40
-#define QT2_SERIAL_MSR_DSR 0x20
-#define QT2_SERIAL_MSR_MASK 0xf0
-
-#define QT2_SERIAL_8_DATA 0x03
-#define QT2_SERIAL_7_DATA 0x02
-#define QT2_SERIAL_6_DATA 0x01
-#define QT2_SERIAL_5_DATA 0x00
-
-#define QT2_SERIAL_ODD_PARITY 0x08
-#define QT2_SERIAL_EVEN_PARITY 0x18
-#define QT2_SERIAL_TWO_STOPB 0x04
-#define QT2_SERIAL_ONE_STOPB 0x00
-
-#define QT2_MAX_BAUD_RATE 921600
-#define QT2_MAX_BAUD_REMAINDER 4608
-
-#define QT2_SERIAL_LSR_OE 0x02
-#define QT2_SERIAL_LSR_PE 0x04
-#define QT2_SERIAL_LSR_FE 0x08
-#define QT2_SERIAL_LSR_BI 0x10
-
-/* value of Line Status Register when UART has completed
- * emptying data out on the line */
-#define QT2_LSR_TEMT 0x40
-
-/* register numbers on each UART, for use with qt2_box_[get|set]_register*/
-#define QT2_XMT_HOLD_REGISTER 0x00
-#define QT2_XVR_BUFFER_REGISTER 0x00
-#define QT2_FIFO_CONTROL_REGISTER 0x02
-#define QT2_LINE_CONTROL_REGISTER 0x03
-#define QT2_MODEM_CONTROL_REGISTER 0x04
-#define QT2_LINE_STATUS_REGISTER 0x05
-#define QT2_MODEM_STATUS_REGISTER 0x06
-
-/* handy macros for doing escape sequence parsing on data reads */
-#define THISCHAR ((unsigned char *)(urb->transfer_buffer))[i]
-#define NEXTCHAR ((unsigned char *)(urb->transfer_buffer))[i + 1]
-#define THIRDCHAR ((unsigned char *)(urb->transfer_buffer))[i + 2]
-#define FOURTHCHAR ((unsigned char *)(urb->transfer_buffer))[i + 3]
-#define FIFTHCHAR ((unsigned char *)(urb->transfer_buffer))[i + 4]
-
-static const struct usb_device_id quausb2_id_table[] = {
- {USB_DEVICE(USB_VENDOR_ID_QUATECH, QUATECH_SSU2_100)},
- {USB_DEVICE(USB_VENDOR_ID_QUATECH, QUATECH_DSU2_100)},
- {USB_DEVICE(USB_VENDOR_ID_QUATECH, QUATECH_DSU2_400)},
- {USB_DEVICE(USB_VENDOR_ID_QUATECH, QUATECH_QSU2_100)},
- {USB_DEVICE(USB_VENDOR_ID_QUATECH, QUATECH_QSU2_400)},
- {USB_DEVICE(USB_VENDOR_ID_QUATECH, QUATECH_ESU2_100)},
- {USB_DEVICE(USB_VENDOR_ID_QUATECH, QUATECH_ESU2_400)},
- {} /* Terminating entry */
-};
-
-MODULE_DEVICE_TABLE(usb, quausb2_id_table);
-
-/* custom structures we need go here */
-static struct usb_driver quausb2_usb_driver = {
- .name = "quatech-usb2-serial",
- .probe = usb_serial_probe,
- .disconnect = usb_serial_disconnect,
- .id_table = quausb2_id_table,
-};
-
-/**
- * quatech2_port: Structure in which to keep all the messy stuff that this
- * driver needs alongside the usb_serial_port structure
- * @read_urb_busy: Flag indicating that port->read_urb is in use
- * @close_pending: flag indicating that this port is in the process of
- * being closed (and so no new reads / writes should be started).
- * @shadowLSR: Last received state of the line status register, holds the
- * value of the line status flags from the port
- * @shadowMSR: Last received state of the modem status register, holds
- * the value of the modem status received from the port
- * @rcv_flush: Flag indicating that a receive flush has occurred on
- * the hardware.
- * @xmit_flush: Flag indicating that a transmit flush has been processed by
- * the hardware.
- * @tx_pending_bytes: Number of bytes waiting to be sent. This total
- * includes the size (excluding header) of URBs that have been submitted but
- * have not yet been sent to to the device, and bytes that have been sent out
- * of the port but not yet reported sent by the "xmit_empty" messages (which
- * indicate the number of bytes sent each time they are received, despite the
- * misleading name).
- * - Starts at zero when port is initialised.
- * - is incremented by the size of the data to be written (no headers)
- * each time a write urb is dispatched.
- * - is decremented each time a "transmit empty" message is received
- * by the driver in the data stream.
- * @lock: Mutex to lock access to this structure when we need to ensure that
- * races don't occur to access bits of it.
- * @open_count: The number of uses of the port currently having
- * it open, i.e. the reference count.
- */
-struct quatech2_port {
- int magic;
- bool read_urb_busy;
- bool close_pending;
- __u8 shadowLSR;
- __u8 shadowMSR;
- bool rcv_flush;
- bool xmit_flush;
- int tx_pending_bytes;
- struct mutex modelock;
- int open_count;
-
- char active; /* someone has this device open */
- unsigned char *xfer_to_tty_buffer;
- wait_queue_head_t wait;
- __u8 shadowLCR; /* last LCR value received */
- __u8 shadowMCR; /* last MCR value received */
- char RxHolding;
- struct semaphore pend_xmit_sem; /* locks this structure */
- spinlock_t lock;
-};
-
-/**
- * Structure to hold device-wide internal status information
- * @param ReadBulkStopped The last bulk read attempt ended in tears
- * @param open_ports The number of serial ports currently in use on the box
- * @param current_port Pointer to the serial port structure of the port which
- * the read stream is currently directed to. Escape sequences in the read
- * stream will change this around as data arrives from different ports on the
- * box
- * @buffer_size: The max size buffer each URB can take, used to set the size of
- * the buffers allocated for writing to each port on the device (we need to
- * store this because it is known only to the endpoint, but used each time a
- * port is opened and a new buffer is allocated.
- */
-struct quatech2_dev {
- bool ReadBulkStopped;
- char open_ports;
- struct usb_serial_port *current_port;
- int buffer_size;
-};
-
-/* structure which holds line and modem status flags */
-struct qt2_status_data {
- __u8 line_status;
- __u8 modem_status;
-};
-
-/* Function prototypes */
-static int qt2_boxpoweron(struct usb_serial *serial);
-static int qt2_boxsetQMCR(struct usb_serial *serial, __u16 Uart_Number,
- __u8 QMCR_Value);
-static int port_paranoia_check(struct usb_serial_port *port,
- const char *function);
-static int serial_paranoia_check(struct usb_serial *serial,
- const char *function);
-static inline struct quatech2_port *qt2_get_port_private(struct usb_serial_port
- *port);
-static inline void qt2_set_port_private(struct usb_serial_port *port,
- struct quatech2_port *data);
-static inline struct quatech2_dev *qt2_get_dev_private(struct usb_serial
- *serial);
-static inline void qt2_set_dev_private(struct usb_serial *serial,
- struct quatech2_dev *data);
-static int qt2_openboxchannel(struct usb_serial *serial, __u16
- Uart_Number, struct qt2_status_data *pDeviceData);
-static int qt2_closeboxchannel(struct usb_serial *serial, __u16
- Uart_Number);
-static int qt2_conf_uart(struct usb_serial *serial, unsigned short Uart_Number,
- unsigned short divisor, unsigned char LCR);
-static void qt2_read_bulk_callback(struct urb *urb);
-static void qt2_write_bulk_callback(struct urb *urb);
-static void qt2_process_line_status(struct usb_serial_port *port,
- unsigned char LineStatus);
-static void qt2_process_modem_status(struct usb_serial_port *port,
- unsigned char ModemStatus);
-static void qt2_process_xmit_empty(struct usb_serial_port *port,
- unsigned char fourth_char, unsigned char fifth_char);
-static void qt2_process_port_change(struct usb_serial_port *port,
- unsigned char New_Current_Port);
-static void qt2_process_rcv_flush(struct usb_serial_port *port);
-static void qt2_process_xmit_flush(struct usb_serial_port *port);
-static void qt2_process_rx_char(struct usb_serial_port *port,
- unsigned char data);
-static int qt2_box_get_register(struct usb_serial *serial,
- unsigned char uart_number, unsigned short register_num,
- __u8 *pValue);
-static int qt2_box_set_register(struct usb_serial *serial,
- unsigned short Uart_Number, unsigned short Register_Num,
- unsigned short Value);
-static int qt2_boxsetuart(struct usb_serial *serial, unsigned short Uart_Number,
- unsigned short default_divisor, unsigned char default_LCR);
-static int qt2_boxsethw_flowctl(struct usb_serial *serial,
- unsigned int UartNumber, bool bSet);
-static int qt2_boxsetsw_flowctl(struct usb_serial *serial, __u16 UartNumber,
- unsigned char stop_char, unsigned char start_char);
-static int qt2_boxunsetsw_flowctl(struct usb_serial *serial, __u16 UartNumber);
-static int qt2_boxstoprx(struct usb_serial *serial, unsigned short uart_number,
- unsigned short stop);
-
-/* implementation functions, roughly in order of use, are here */
-static int qt2_calc_num_ports(struct usb_serial *serial)
-{
- int num_ports;
- int flag_as_400;
- switch (serial->dev->descriptor.idProduct) {
- case QUATECH_SSU2_100:
- num_ports = 1;
- break;
-
- case QUATECH_DSU2_400:
- flag_as_400 = true;
- case QUATECH_DSU2_100:
- num_ports = 2;
- break;
-
- case QUATECH_QSU2_400:
- flag_as_400 = true;
- case QUATECH_QSU2_100:
- num_ports = 4;
- break;
-
- case QUATECH_ESU2_400:
- flag_as_400 = true;
- case QUATECH_ESU2_100:
- num_ports = 8;
- break;
- default:
- num_ports = 1;
- break;
- }
- return num_ports;
-}
-
-static int qt2_attach(struct usb_serial *serial)
-{
- struct usb_serial_port *port;
- struct quatech2_port *qt2_port; /* port-specific private data pointer */
- struct quatech2_dev *qt2_dev; /* dev-specific private data pointer */
- int i;
- /* stuff for storing endpoint addresses now */
- struct usb_endpoint_descriptor *endpoint;
- struct usb_host_interface *iface_desc;
- struct usb_serial_port *port0; /* first port structure on device */
-
- /* check how many endpoints there are on the device, for
- * sanity's sake */
- dbg("%s(): Endpoints: %d bulk in, %d bulk out, %d interrupt in",
- __func__, serial->num_bulk_in,
- serial->num_bulk_out, serial->num_interrupt_in);
- if ((serial->num_bulk_in != 1) || (serial->num_bulk_out != 1)) {
- dbg("Device has wrong number of bulk endpoints!");
- return -ENODEV;
- }
- iface_desc = serial->interface->cur_altsetting;
-
- /* Set up per-device private data, storing extra data alongside
- * struct usb_serial */
- qt2_dev = kzalloc(sizeof(*qt2_dev), GFP_KERNEL);
- if (!qt2_dev) {
- dbg("%s: kmalloc for quatech2_dev failed!",
- __func__);
- return -ENOMEM;
- }
- qt2_dev->open_ports = 0; /* no ports open */
- qt2_set_dev_private(serial, qt2_dev); /* store private data */
-
- /* Now setup per port private data, which replaces all the things
- * that quatech added to standard kernel structures in their driver */
- for (i = 0; i < serial->num_ports; i++) {
- port = serial->port[i];
- qt2_port = kzalloc(sizeof(*qt2_port), GFP_KERNEL);
- if (!qt2_port) {
- dbg("%s: kmalloc for quatech2_port (%d) failed!.",
- __func__, i);
- return -ENOMEM;
- }
- /* initialise stuff in the structure */
- qt2_port->open_count = 0; /* port is not open */
- spin_lock_init(&qt2_port->lock);
- mutex_init(&qt2_port->modelock);
- qt2_set_port_private(port, qt2_port);
- }
-
- /* gain access to port[0]'s structure because we want to store
- * device-level stuff in it */
- if (serial_paranoia_check(serial, __func__))
- return -ENODEV;
- port0 = serial->port[0]; /* get the first port's device structure */
-
- /* print endpoint addresses so we can check them later
- * by hand */
- for (i = 0; i < iface_desc->desc.bNumEndpoints; ++i) {
- endpoint = &iface_desc->endpoint[i].desc;
- if ((endpoint->bEndpointAddress & 0x80) &&
- ((endpoint->bmAttributes & 3) == 0x02)) {
- /* we found a bulk in endpoint */
- dbg("found bulk in at %#.2x",
- endpoint->bEndpointAddress);
- }
-
- if (((endpoint->bEndpointAddress & 0x80) == 0x00) &&
- ((endpoint->bmAttributes & 3) == 0x02)) {
- /* we found a bulk out endpoint */
- dbg("found bulk out at %#.2x",
- endpoint->bEndpointAddress);
- qt2_dev->buffer_size = endpoint->wMaxPacketSize;
- /* max size of URB needs recording for the device */
- }
- } /* end printing endpoint addresses */
-
- /* switch on power to the hardware */
- if (qt2_boxpoweron(serial) < 0) {
- dbg("qt2_boxpoweron() failed");
- goto startup_error;
- }
- /* set all ports to RS232 mode */
- for (i = 0; i < serial->num_ports; ++i) {
- if (qt2_boxsetQMCR(serial, i, QU2BOX232) < 0) {
- dbg("qt2_boxsetQMCR() on port %d failed",
- i);
- goto startup_error;
- }
- }
-
- return 0;
-
-startup_error:
- for (i = 0; i < serial->num_ports; i++) {
- port = serial->port[i];
- qt2_port = qt2_get_port_private(port);
- kfree(qt2_port);
- qt2_set_port_private(port, NULL);
- }
- qt2_dev = qt2_get_dev_private(serial);
- kfree(qt2_dev);
- qt2_set_dev_private(serial, NULL);
-
- dbg("Exit fail %s\n", __func__);
- return -EIO;
-}
-
-static void qt2_release(struct usb_serial *serial)
-{
- struct usb_serial_port *port;
- struct quatech2_port *qt_port;
- int i;
-
- dbg("enterting %s", __func__);
-
- for (i = 0; i < serial->num_ports; i++) {
- port = serial->port[i];
- if (!port)
- continue;
-
- qt_port = usb_get_serial_port_data(port);
- kfree(qt_port);
- usb_set_serial_port_data(port, NULL);
- }
-}
-/* This function is called once per serial port on the device, when
- * that port is opened by a userspace application.
- * The tty_struct and the usb_serial_port belong to this port,
- * i.e. there are multiple ones for a multi-port device.
- * However the usb_serial_port structure has a back-pointer
- * to the parent usb_serial structure which belongs to the device,
- * so we can access either the device-wide information or
- * any other port's information (because there are also forward
- * pointers) via that pointer.
- * This is most helpful if the device shares resources (e.g. end
- * points) between different ports
- */
-int qt2_open(struct tty_struct *tty, struct usb_serial_port *port)
-{
- struct usb_serial *serial; /* device structure */
- struct usb_serial_port *port0; /* first port structure on device */
- struct quatech2_port *port_extra; /* extra data for this port */
- struct quatech2_port *port0_extra; /* extra data for first port */
- struct quatech2_dev *dev_extra; /* extra data for the device */
- struct qt2_status_data ChannelData;
- unsigned short default_divisor = QU2BOXSPD9600;
- unsigned char default_LCR = QT2_SERIAL_8_DATA;
- int status;
- int result;
-
- if (port_paranoia_check(port, __func__))
- return -ENODEV;
-
- dbg("%s(): port %d", __func__, port->number);
-
- serial = port->serial; /* get the parent device structure */
- if (serial_paranoia_check(serial, __func__)) {
- dbg("usb_serial struct failed sanity check");
- return -ENODEV;
- }
- dev_extra = qt2_get_dev_private(serial);
- /* get the device private data */
- if (dev_extra == NULL) {
- dbg("device extra data pointer is null");
- return -ENODEV;
- }
- port0 = serial->port[0]; /* get the first port's device structure */
- if (port_paranoia_check(port0, __func__)) {
- dbg("port0 usb_serial_port struct failed sanity check");
- return -ENODEV;
- }
-
- port_extra = qt2_get_port_private(port);
- port0_extra = qt2_get_port_private(port0);
- if (port_extra == NULL || port0_extra == NULL) {
- dbg("failed to get private data for port or port0");
- return -ENODEV;
- }
-
- /* FIXME: are these needed? Does it even do anything useful? */
- /* get the modem and line status values from the UART */
- status = qt2_openboxchannel(serial, port->number,
- &ChannelData);
- if (status < 0) {
- dbg("qt2_openboxchannel on channel %d failed",
- port->number);
- return status;
- }
- port_extra->shadowLSR = ChannelData.line_status &
- (QT2_SERIAL_LSR_OE | QT2_SERIAL_LSR_PE |
- QT2_SERIAL_LSR_FE | QT2_SERIAL_LSR_BI);
- port_extra->shadowMSR = ChannelData.modem_status &
- (QT2_SERIAL_MSR_CTS | QT2_SERIAL_MSR_DSR |
- QT2_SERIAL_MSR_RI | QT2_SERIAL_MSR_CD);
-
-/* port_extra->fifo_empty_flag = true;*/
- dbg("qt2_openboxchannel on channel %d completed.",
- port->number);
-
- /* Set Baud rate to default and turn off flow control here */
- status = qt2_conf_uart(serial, port->number, default_divisor,
- default_LCR);
- if (status < 0) {
- dbg("qt2_conf_uart() failed on channel %d",
- port->number);
- return status;
- }
- dbg("qt2_conf_uart() completed on channel %d",
- port->number);
-
- /*
- * At this point we will need some end points to make further progress.
- * Handlily, the correct endpoint addresses have been filled out into
- * the usb_serial_port structure for us by the driver core, so we
- * already have access to them.
- * As there is only one bulk in and one bulk out end-point, these are in
- * port[0]'s structure, and the rest are uninitialised. Handily,
- * when we do a write to a port, we will use the same endpoint
- * regardless of the port, with a 5-byte header added on to
- * tell the box which port it should eventually come out of, so we only
- * need the one set of endpoints. We will have one URB per port for
- * writing, so that multiple ports can be writing at once.
- * Finally we need a bulk in URB to use for background reads from the
- * device, which will deal with uplink data from the box to host.
- */
- dbg("port0 bulk in endpoint is %#.2x", port0->bulk_in_endpointAddress);
- dbg("port0 bulk out endpoint is %#.2x",
- port0->bulk_out_endpointAddress);
-
- /* set up write_urb for bulk out transfers on this port. The USB
- * serial framework will have allocated a blank URB, buffer etc for
- * port0 when it put the endpoints there, but not for any of the other
- * ports on the device because there are no more endpoints. Thus we
- * have to allocate our own URBs for ports 1-7
- */
- if (port->write_urb == NULL) {
- dbg("port->write_urb == NULL, allocating one");
- port->write_urb = usb_alloc_urb(0, GFP_KERNEL);
- if (!port->write_urb) {
- err("Allocating write URB failed");
- return -ENOMEM;
- }
- /* buffer same size as port0 */
- port->bulk_out_size = dev_extra->buffer_size;
- port->bulk_out_buffer = kmalloc(port->bulk_out_size,
- GFP_KERNEL);
- if (!port->bulk_out_buffer) {
- err("Couldn't allocate bulk_out_buffer");
- return -ENOMEM;
- }
- }
- if (serial->dev == NULL)
- dbg("serial->dev == NULL");
- dbg("port->bulk_out_size is %d", port->bulk_out_size);
-
- usb_fill_bulk_urb(port->write_urb, serial->dev,
- usb_sndbulkpipe(serial->dev,
- port0->bulk_out_endpointAddress),
- port->bulk_out_buffer,
- port->bulk_out_size,
- qt2_write_bulk_callback,
- port);
- port_extra->tx_pending_bytes = 0;
-
- if (dev_extra->open_ports == 0) {
- /* this is first port to be opened, so need the read URB
- * initialised for bulk in transfers (this is shared amongst
- * all the ports on the device) */
- usb_fill_bulk_urb(port0->read_urb, serial->dev,
- usb_rcvbulkpipe(serial->dev,
- port0->bulk_in_endpointAddress),
- port0->bulk_in_buffer,
- port0->bulk_in_size,
- qt2_read_bulk_callback, serial);
- dbg("port0 bulk in URB initialised");
-
- /* submit URB, i.e. start reading from device (async) */
- dev_extra->ReadBulkStopped = false;
- port_extra->read_urb_busy = true;
- result = usb_submit_urb(port->read_urb, GFP_KERNEL);
- if (result) {
- dev_err(&port->dev,
- "%s(): Error %d submitting bulk in urb",
- __func__, result);
- port_extra->read_urb_busy = false;
- dev_extra->ReadBulkStopped = true;
- }
-
- /* When the first port is opened, initialise the value of
- * current_port in dev_extra to this port, so it is set
- * to something. Once the box sends data it will send the
- * relevant escape sequences to get it to the right port anyway
- */
- dev_extra->current_port = port;
- }
-
- /* initialize our wait queues */
- init_waitqueue_head(&port_extra->wait);
- /* increment the count of openings of this port by one */
- port_extra->open_count++;
-
- /* remember to store dev_extra, port_extra and port0_extra back again at
- * end !*/
- qt2_set_port_private(port, port_extra);
- qt2_set_port_private(serial->port[0], port0_extra);
- qt2_set_dev_private(serial, dev_extra);
-
- dev_extra->open_ports++; /* one more port opened */
-
- return 0;
-}
-
-/* called when a port is closed by userspace. It won't be called, however,
- * until calls to chars_in_buffer() reveal that the port has completed
- * sending buffered data, and there is nothing else to do. Thus we don't have
- * to rely on forcing data through in this function. */
-/* Setting close_pending should keep new data from being written out,
- * once all the data in the enpoint buffers is moved out we won't get
- * any more. */
-/* BoxStopReceive would keep any more data from coming from a given
- * port, but isn't called by the vendor driver, although their comments
- * mention it. Should it be used here to stop the inbound data
- * flow?
- */
-static void qt2_close(struct usb_serial_port *port)
-{
- /* time out value for flush loops */
- unsigned long jift;
- struct quatech2_port *port_extra; /* extra data for this port */
- struct usb_serial *serial; /* device structure */
- struct quatech2_dev *dev_extra; /* extra data for the device */
- __u8 lsr_value = 0; /* value of Line Status Register */
- int status; /* result of last USB comms function */
-
- dbg("%s(): port %d", __func__, port->number);
- serial = port->serial; /* get the parent device structure */
- dev_extra = qt2_get_dev_private(serial);
- /* get the device private data */
- port_extra = qt2_get_port_private(port); /* port private data */
-
- /* we can now (and only now) stop reading data */
- port_extra->close_pending = true;
- dbg("%s(): port_extra->close_pending = true", __func__);
- /* although the USB side is now empty, the UART itself may
- * still be pushing characters out over the line, so we have to
- * wait testing the actual line status until the lines change
- * indicating that the data is done transferring. */
- /* FIXME: slow this polling down so it doesn't run the USB bus flat out
- * if it actually has to spend any time in this loop (which it normally
- * doesn't because the buffer is nearly empty) */
- jift = jiffies + (10 * HZ); /* 10 sec timeout */
- do {
- status = qt2_box_get_register(serial, port->number,
- QT2_LINE_STATUS_REGISTER, &lsr_value);
- if (status < 0) {
- dbg("%s(): qt2_box_get_register failed", __func__);
- break;
- }
- if ((lsr_value & QT2_LSR_TEMT)) {
- dbg("UART done sending");
- break;
- }
- schedule();
- } while (jiffies <= jift);
-
- status = qt2_closeboxchannel(serial, port->number);
- if (status < 0)
- dbg("%s(): port %d qt2_box_open_close_channel failed",
- __func__, port->number);
- /* to avoid leaking URBs, we should now free the write_urb for this
- * port and set the pointer to null so that next time the port is opened
- * a new URB is allocated. This avoids leaking URBs when the device is
- * removed */
- usb_free_urb(port->write_urb);
- kfree(port->bulk_out_buffer);
- port->bulk_out_buffer = NULL;
- port->bulk_out_size = 0;
-
- /* decrement the count of openings of this port by one */
- port_extra->open_count--;
- /* one less overall open as well */
- dev_extra->open_ports--;
- dbg("%s(): Exit, dev_extra->open_ports = %d", __func__,
- dev_extra->open_ports);
-}
-
-/**
- * qt2_write - write bytes from the tty layer out to the USB device.
- * @buf: The data to be written, size at least count.
- * @count: The number of bytes requested for transmission.
- * @return The number of bytes actually accepted for transmission to the device.
- */
-static int qt2_write(struct tty_struct *tty, struct usb_serial_port *port,
- const unsigned char *buf, int count)
-{
- struct usb_serial *serial; /* parent device struct */
- __u8 header_array[5]; /* header used to direct writes to the correct
- port on the device */
- struct quatech2_port *port_extra; /* extra data for this port */
- int result;
-
- serial = port->serial; /* get the parent device of the port */
- port_extra = qt2_get_port_private(port); /* port extra info */
- if (serial == NULL)
- return -ENODEV;
- dbg("%s(): port %d, requested to write %d bytes, %d already pending",
- __func__, port->number, count, port_extra->tx_pending_bytes);
-
- if (count <= 0) {
- dbg("%s(): write request of <= 0 bytes", __func__);
- return 0; /* no bytes written */
- }
-
- /* check if the write urb is already in use, i.e. data already being
- * sent to this port */
- if ((port->write_urb->status == -EINPROGRESS)) {
- /* Fifo hasn't been emptied since last write to this port */
- dbg("%s(): already writing, port->write_urb->status == "
- "-EINPROGRESS", __func__);
- /* schedule_work(&port->work); commented in vendor driver */
- return 0;
- } else if (port_extra->tx_pending_bytes >= QT2_FIFO_DEPTH) {
- /* buffer is full (==). > should not occur, but would indicate
- * that an overflow had occurred */
- dbg("%s(): port transmit buffer is full!", __func__);
- /* schedule_work(&port->work); commented in vendor driver */
- return 0;
- }
-
- /* We must fill the first 5 bytes of anything we sent with a transmit
- * header which directes the data to the correct port. The maximum
- * size we can send out in one URB is port->bulk_out_size, which caps
- * the number of bytes of real data we can send in each write. As the
- * semantics of write allow us to write less than we were give, we cap
- * the maximum we will ever write to the device as 5 bytes less than
- * one URB's worth, by reducing the value of the count argument
- * appropriately*/
- if (count > port->bulk_out_size - QT2_TX_HEADER_LENGTH) {
- count = port->bulk_out_size - QT2_TX_HEADER_LENGTH;
- dbg("%s(): write request bigger than urb, only accepting "
- "%d bytes", __func__, count);
- }
- /* we must also ensure that the FIFO at the other end can cope with the
- * URB we send it, otherwise it will have problems. As above, we can
- * restrict the write size by just shrinking count.*/
- if (count > (QT2_FIFO_DEPTH - port_extra->tx_pending_bytes)) {
- count = QT2_FIFO_DEPTH - port_extra->tx_pending_bytes;
- dbg("%s(): not enough room in buffer, only accepting %d bytes",
- __func__, count);
- }
- /* now build the header for transmission */
- header_array[0] = 0x1b;
- header_array[1] = 0x1b;
- header_array[2] = (__u8)port->number;
- header_array[3] = (__u8)count;
- header_array[4] = (__u8)count >> 8;
- /* copy header into URB */
- memcpy(port->write_urb->transfer_buffer, header_array,
- QT2_TX_HEADER_LENGTH);
- /* and actual data to write */
- memcpy(port->write_urb->transfer_buffer + 5, buf, count);
-
- dbg("%s(): first data byte to send = %#.2x", __func__, *buf);
-
- /* set up our urb */
- usb_fill_bulk_urb(port->write_urb, serial->dev,
- usb_sndbulkpipe(serial->dev,
- port->bulk_out_endpointAddress),
- port->write_urb->transfer_buffer, count + 5,
- (qt2_write_bulk_callback), port);
- /* send the data out the bulk port */
- result = usb_submit_urb(port->write_urb, GFP_ATOMIC);
- if (result) {
- /* error couldn't submit urb */
- result = 0; /* return 0 as nothing got written */
- dbg("%s(): failed submitting write urb, error %d",
- __func__, result);
- } else {
- port_extra->tx_pending_bytes += count;
- result = count; /* return number of bytes written, i.e. count */
- dbg("%s(): submitted write urb, wrote %d bytes, "
- "total pending bytes %d",
- __func__, result, port_extra->tx_pending_bytes);
- }
- return result;
-}
-
-/* This is used by the next layer up to know how much space is available
- * in the buffer on the device. It is used on a device closure to avoid
- * calling close() until the buffer is reported to be empty.
- * The returned value must never go down by more than the number of bytes
- * written for correct behaviour further up the driver stack, i.e. if I call
- * it, then write 6 bytes, then call again I should get 6 less, or possibly
- * only 5 less if one was written in the meantime, etc. I should never get 7
- * less (or any bigger number) because I only wrote 6 bytes.
- */
-static int qt2_write_room(struct tty_struct *tty)
-{
- struct usb_serial_port *port = tty->driver_data;
- /* parent usb_serial_port pointer */
- struct quatech2_port *port_extra; /* extra data for this port */
- int room = 0;
- port_extra = qt2_get_port_private(port);
-
- if (port_extra->close_pending == true) {
- dbg("%s(): port_extra->close_pending == true", __func__);
- return -ENODEV;
- }
- /* Q: how many bytes would a write() call actually succeed in writing
- * if it happened now?
- * A: one QT2_FIFO_DEPTH, less the number of bytes waiting to be sent
- * out of the port, unless this is more than the size of the
- * write_urb output buffer less the header, which is the maximum
- * size write we can do.
-
- * Most of the implementation of this is done when writes to the device
- * are started or terminate. When we send a write to the device, we
- * reduce the free space count by the size of the dispatched write.
- * When a "transmit empty" message comes back up the USB read stream,
- * we decrement the count by the number of bytes reported sent, thus
- * keeping track of the difference between sent and received bytes.
- */
-
- room = (QT2_FIFO_DEPTH - port_extra->tx_pending_bytes);
- /* space in FIFO */
- if (room > port->bulk_out_size - QT2_TX_HEADER_LENGTH)
- room = port->bulk_out_size - QT2_TX_HEADER_LENGTH;
- /* if more than the URB can hold, then cap to that limit */
-
- dbg("%s(): port %d: write room is %d", __func__, port->number, room);
- return room;
-}
-
-static int qt2_chars_in_buffer(struct tty_struct *tty)
-{
- struct usb_serial_port *port = tty->driver_data;
- /* parent usb_serial_port pointer */
- struct quatech2_port *port_extra; /* extra data for this port */
- port_extra = qt2_get_port_private(port);
-
- dbg("%s(): port %d: chars_in_buffer = %d", __func__,
- port->number, port_extra->tx_pending_bytes);
- return port_extra->tx_pending_bytes;
-}
-
-/* called when userspace does an ioctl() on the device. Note that
- * TIOCMGET and TIOCMSET are filtered off to their own methods before they get
- * here, so we don't have to handle them.
- */
-static int qt2_ioctl(struct tty_struct *tty,
- unsigned int cmd, unsigned long arg)
-{
- struct usb_serial_port *port = tty->driver_data;
- struct usb_serial *serial = port->serial;
- __u8 mcr_value; /* Modem Control Register value */
- __u8 msr_value; /* Modem Status Register value */
- unsigned short prev_msr_value; /* Previous value of Modem Status
- * Register used to implement waiting for a line status change to
- * occur */
- struct quatech2_port *port_extra; /* extra data for this port */
- DECLARE_WAITQUEUE(wait, current);
- /* Declare a wait queue named "wait" */
-
- unsigned int value;
- unsigned int UartNumber;
-
- if (serial == NULL)
- return -ENODEV;
- UartNumber = tty->index - serial->minor;
- port_extra = qt2_get_port_private(port);
-
- dbg("%s(): port %d, UartNumber %d, tty =0x%p", __func__,
- port->number, UartNumber, tty);
-
- if (cmd == TIOCMBIS || cmd == TIOCMBIC) {
- if (qt2_box_get_register(port->serial, UartNumber,
- QT2_MODEM_CONTROL_REGISTER, &mcr_value) < 0)
- return -ESPIPE;
- if (copy_from_user(&value, (unsigned int *)arg,
- sizeof(value)))
- return -EFAULT;
-
- switch (cmd) {
- case TIOCMBIS:
- if (value & TIOCM_RTS)
- mcr_value |= QT2_SERIAL_MCR_RTS;
- if (value & TIOCM_DTR)
- mcr_value |= QT2_SERIAL_MCR_DTR;
- if (value & TIOCM_LOOP)
- mcr_value |= QT2_SERIAL_MCR_LOOP;
- break;
- case TIOCMBIC:
- if (value & TIOCM_RTS)
- mcr_value &= ~QT2_SERIAL_MCR_RTS;
- if (value & TIOCM_DTR)
- mcr_value &= ~QT2_SERIAL_MCR_DTR;
- if (value & TIOCM_LOOP)
- mcr_value &= ~QT2_SERIAL_MCR_LOOP;
- break;
- default:
- break;
- } /* end of local switch on cmd */
- if (qt2_box_set_register(port->serial, UartNumber,
- QT2_MODEM_CONTROL_REGISTER, mcr_value) < 0) {
- return -ESPIPE;
- } else {
- port_extra->shadowMCR = mcr_value;
- return 0;
- }
- } else if (cmd == TIOCMIWAIT) {
- dbg("%s() port %d, cmd == TIOCMIWAIT enter",
- __func__, port->number);
- prev_msr_value = port_extra->shadowMSR & QT2_SERIAL_MSR_MASK;
- barrier();
- __set_current_state(TASK_INTERRUPTIBLE);
- while (1) {
- add_wait_queue(&port_extra->wait, &wait);
- schedule();
- dbg("%s(): port %d, cmd == TIOCMIWAIT here\n",
- __func__, port->number);
- remove_wait_queue(&port_extra->wait, &wait);
- /* see if a signal woke us up */
- if (signal_pending(current))
- return -ERESTARTSYS;
- set_current_state(TASK_INTERRUPTIBLE);
- msr_value = port_extra->shadowMSR & QT2_SERIAL_MSR_MASK;
- if (msr_value == prev_msr_value) {
- __set_current_state(TASK_RUNNING);
- return -EIO; /* no change - error */
- }
- if ((arg & TIOCM_RNG &&
- ((prev_msr_value & QT2_SERIAL_MSR_RI) ==
- (msr_value & QT2_SERIAL_MSR_RI))) ||
- (arg & TIOCM_DSR &&
- ((prev_msr_value & QT2_SERIAL_MSR_DSR) ==
- (msr_value & QT2_SERIAL_MSR_DSR))) ||
- (arg & TIOCM_CD &&
- ((prev_msr_value & QT2_SERIAL_MSR_CD) ==
- (msr_value & QT2_SERIAL_MSR_CD))) ||
- (arg & TIOCM_CTS &&
- ((prev_msr_value & QT2_SERIAL_MSR_CTS) ==
- (msr_value & QT2_SERIAL_MSR_CTS)))) {
- __set_current_state(TASK_RUNNING);
- return 0;
- }
- } /* end inifinite while */
- /* FIXME: This while loop needs a way to break out if the device
- * is disconnected while a process is waiting for the MSR to
- * change, because once it's disconnected, it isn't going to
- * change state ... */
- } else {
- /* any other ioctls we don't know about come here */
- dbg("%s(): No ioctl for that one. port = %d", __func__,
- port->number);
- return -ENOIOCTLCMD;
- }
-}
-
-/* Called when the user wishes to change the port settings using the termios
- * userspace interface */
-static void qt2_set_termios(struct tty_struct *tty,
- struct usb_serial_port *port, struct ktermios *old_termios)
-{
- struct usb_serial *serial; /* parent serial device */
- int baud, divisor, remainder;
- unsigned char LCR_change_to = 0;
- int status;
- __u16 UartNumber;
-
- dbg("%s(): port %d", __func__, port->number);
-
- serial = port->serial;
-
- UartNumber = port->number;
-
- if (old_termios && !tty_termios_hw_change(old_termios, tty->termios))
- return;
-
- switch (tty->termios->c_cflag) {
- case CS5:
- LCR_change_to |= QT2_SERIAL_5_DATA;
- break;
- case CS6:
- LCR_change_to |= QT2_SERIAL_6_DATA;
- break;
- case CS7:
- LCR_change_to |= QT2_SERIAL_7_DATA;
- break;
- default:
- case CS8:
- LCR_change_to |= QT2_SERIAL_8_DATA;
- break;
- }
-
- /* Parity stuff */
- if (tty->termios->c_cflag & PARENB) {
- if (tty->termios->c_cflag & PARODD)
- LCR_change_to |= QT2_SERIAL_ODD_PARITY;
- else
- LCR_change_to |= QT2_SERIAL_EVEN_PARITY;
- }
- /* Because LCR_change_to is initialised to zero, we don't have to worry
- * about the case where PARENB is not set or clearing bits, because by
- * default all of them are cleared, turning parity off.
- * as we don't support mark/space parity, we should clear the
- * mark/space parity bit in c_cflag, so the caller can tell we have
- * ignored the request */
- tty->termios->c_cflag &= ~CMSPAR;
-
- if (tty->termios->c_cflag & CSTOPB)
- LCR_change_to |= QT2_SERIAL_TWO_STOPB;
- else
- LCR_change_to |= QT2_SERIAL_ONE_STOPB;
-
- /* Thats the LCR stuff, next we need to work out the divisor as the
- * LCR and the divisor are set together */
- baud = tty_get_baud_rate(tty);
- if (!baud) {
- /* pick a default, any default... */
- baud = 9600;
- }
- dbg("%s(): got baud = %d", __func__, baud);
-
- divisor = QT2_MAX_BAUD_RATE / baud;
- remainder = QT2_MAX_BAUD_RATE % baud;
- /* Round to nearest divisor */
- if (((remainder * 2) >= baud) && (baud != 110))
- divisor++;
- dbg("%s(): setting divisor = %d, QT2_MAX_BAUD_RATE = %d , LCR = %#.2x",
- __func__, divisor, QT2_MAX_BAUD_RATE, LCR_change_to);
-
- status = qt2_boxsetuart(serial, UartNumber, (unsigned short) divisor,
- LCR_change_to);
- if (status < 0) {
- dbg("qt2_boxsetuart() failed");
- return;
- } else {
- /* now encode the baud rate we actually set, which may be
- * different to the request */
- baud = QT2_MAX_BAUD_RATE / divisor;
- tty_encode_baud_rate(tty, baud, baud);
- }
-
- /* Now determine flow control */
- if (tty->termios->c_cflag & CRTSCTS) {
- dbg("%s(): Enabling HW flow control port %d", __func__,
- port->number);
- /* Enable RTS/CTS flow control */
- status = qt2_boxsethw_flowctl(serial, UartNumber, true);
- if (status < 0) {
- dbg("qt2_boxsethw_flowctl() failed");
- return;
- }
- } else {
- /* Disable RTS/CTS flow control */
- dbg("%s(): disabling HW flow control port %d", __func__,
- port->number);
- status = qt2_boxsethw_flowctl(serial, UartNumber, false);
- if (status < 0) {
- dbg("qt2_boxsethw_flowctl failed");
- return;
- }
- }
- /* if we are implementing XON/XOFF, set the start and stop character
- * in the device */
- if (I_IXOFF(tty) || I_IXON(tty)) {
- unsigned char stop_char = STOP_CHAR(tty);
- unsigned char start_char = START_CHAR(tty);
- status = qt2_boxsetsw_flowctl(serial, UartNumber, stop_char,
- start_char);
- if (status < 0)
- dbg("qt2_boxsetsw_flowctl (enabled) failed");
- } else {
- /* disable SW flow control */
- status = qt2_boxunsetsw_flowctl(serial, UartNumber);
- if (status < 0)
- dbg("qt2_boxunsetsw_flowctl (disabling) failed");
- }
-}
-
-static int qt2_tiocmget(struct tty_struct *tty)
-{
- struct usb_serial_port *port = tty->driver_data;
- struct usb_serial *serial = port->serial;
-
- __u8 mcr_value; /* Modem Control Register value */
- __u8 msr_value; /* Modem Status Register value */
- unsigned int result = 0;
- int status;
- unsigned int UartNumber;
-
- if (serial == NULL)
- return -ENODEV;
-
- dbg("%s(): port %d, tty =0x%p", __func__, port->number, tty);
- UartNumber = tty->index - serial->minor;
- dbg("UartNumber is %d", UartNumber);
-
- status = qt2_box_get_register(port->serial, UartNumber,
- QT2_MODEM_CONTROL_REGISTER, &mcr_value);
- if (status >= 0) {
- status = qt2_box_get_register(port->serial, UartNumber,
- QT2_MODEM_STATUS_REGISTER, &msr_value);
- }
- if (status >= 0) {
- result = ((mcr_value & QT2_SERIAL_MCR_DTR) ? TIOCM_DTR : 0)
- /*DTR set */
- | ((mcr_value & QT2_SERIAL_MCR_RTS) ? TIOCM_RTS : 0)
- /*RTS set */
- | ((msr_value & QT2_SERIAL_MSR_CTS) ? TIOCM_CTS : 0)
- /* CTS set */
- | ((msr_value & QT2_SERIAL_MSR_CD) ? TIOCM_CAR : 0)
- /*Carrier detect set */
- | ((msr_value & QT2_SERIAL_MSR_RI) ? TIOCM_RI : 0)
- /* Ring indicator set */
- | ((msr_value & QT2_SERIAL_MSR_DSR) ? TIOCM_DSR : 0);
- /* DSR set */
- return result;
- } else {
- return -ESPIPE;
- }
-}
-
-static int qt2_tiocmset(struct tty_struct *tty,
- unsigned int set, unsigned int clear)
-{
- struct usb_serial_port *port = tty->driver_data;
- struct usb_serial *serial = port->serial;
- __u8 mcr_value; /* Modem Control Register value */
- int status;
- unsigned int UartNumber;
-
- if (serial == NULL)
- return -ENODEV;
-
- UartNumber = tty->index - serial->minor;
- dbg("%s(): port %d, UartNumber %d", __func__, port->number, UartNumber);
-
- status = qt2_box_get_register(port->serial, UartNumber,
- QT2_MODEM_CONTROL_REGISTER, &mcr_value);
- if (status < 0)
- return -ESPIPE;
-
- /* Turn off RTS, DTR and loopback, then only turn on what was asked
- * for */
- mcr_value &= ~(QT2_SERIAL_MCR_RTS | QT2_SERIAL_MCR_DTR |
- QT2_SERIAL_MCR_LOOP);
- if (set & TIOCM_RTS)
- mcr_value |= QT2_SERIAL_MCR_RTS;
- if (set & TIOCM_DTR)
- mcr_value |= QT2_SERIAL_MCR_DTR;
- if (set & TIOCM_LOOP)
- mcr_value |= QT2_SERIAL_MCR_LOOP;
-
- status = qt2_box_set_register(port->serial, UartNumber,
- QT2_MODEM_CONTROL_REGISTER, mcr_value);
- if (status < 0)
- return -ESPIPE;
- else
- return 0;
-}
-
-/** qt2_break - Turn BREAK on and off on the UARTs
- */
-static void qt2_break(struct tty_struct *tty, int break_state)
-{
- struct usb_serial_port *port = tty->driver_data; /* parent port */
- struct usb_serial *serial = port->serial; /* parent device */
- struct quatech2_port *port_extra; /* extra data for this port */
- __u16 break_value;
- unsigned int result;
-
- port_extra = qt2_get_port_private(port);
- if (!serial) {
- dbg("%s(): port %d: no serial object", __func__, port->number);
- return;
- }
-
- if (break_state == -1)
- break_value = 1;
- else
- break_value = 0;
- dbg("%s(): port %d, break_value %d", __func__, port->number,
- break_value);
-
- mutex_lock(&port_extra->modelock);
- if (!port_extra->open_count) {
- dbg("%s(): port not open", __func__);
- goto exit;
- }
-
- result = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0),
- QT2_BREAK_CONTROL, 0x40, break_value,
- port->number, NULL, 0, 300);
-exit:
- mutex_unlock(&port_extra->modelock);
- dbg("%s(): exit port %d", __func__, port->number);
-
-}
-/**
- * qt2_throttle: - stop reading new data from the port
- */
-static void qt2_throttle(struct tty_struct *tty)
-{
- struct usb_serial_port *port = tty->driver_data;
- struct usb_serial *serial = port->serial;
- struct quatech2_port *port_extra; /* extra data for this port */
- dbg("%s(): port %d", __func__, port->number);
-
- port_extra = qt2_get_port_private(port);
- if (!serial) {
- dbg("%s(): enter port %d no serial object", __func__,
- port->number);
- return;
- }
-
- mutex_lock(&port_extra->modelock); /* lock structure */
- if (!port_extra->open_count) {
- dbg("%s(): port not open", __func__);
- goto exit;
- }
- /* Send command to box to stop receiving stuff. This will stop this
- * particular UART from filling the endpoint - in the multiport case the
- * FPGA UART will handle any flow control implemented, but for the single
- * port it's handed differently and we just quit submitting urbs
- */
- if (serial->dev->descriptor.idProduct != QUATECH_SSU2_100)
- qt2_boxstoprx(serial, port->number, 1);
-
- port->throttled = 1;
-exit:
- mutex_unlock(&port_extra->modelock);
- dbg("%s(): port %d: setting port->throttled", __func__, port->number);
- return;
-}
-
-/**
- * qt2_unthrottle: - start receiving data through the port again after being
- * throttled
- */
-static void qt2_unthrottle(struct tty_struct *tty)
-{
- struct usb_serial_port *port = tty->driver_data;
- struct usb_serial *serial = port->serial;
- struct quatech2_port *port_extra; /* extra data for this port */
- struct usb_serial_port *port0; /* first port structure on device */
- struct quatech2_dev *dev_extra; /* extra data for the device */
-
- if (!serial) {
- dbg("%s() enter port %d no serial object!", __func__,
- port->number);
- return;
- }
- dbg("%s(): enter port %d", __func__, port->number);
- dev_extra = qt2_get_dev_private(serial);
- port_extra = qt2_get_port_private(port);
- port0 = serial->port[0]; /* get the first port's device structure */
-
- mutex_lock(&port_extra->modelock);
- if (!port_extra->open_count) {
- dbg("%s(): port %d not open", __func__, port->number);
- goto exit;
- }
-
- if (port->throttled != 0) {
- dbg("%s(): port %d: unsetting port->throttled", __func__,
- port->number);
- port->throttled = 0;
- /* Send command to box to start receiving stuff */
- if (serial->dev->descriptor.idProduct != QUATECH_SSU2_100) {
- qt2_boxstoprx(serial, port->number, 0);
- } else if (dev_extra->ReadBulkStopped == true) {
- usb_fill_bulk_urb(port0->read_urb, serial->dev,
- usb_rcvbulkpipe(serial->dev,
- port0->bulk_in_endpointAddress),
- port0->bulk_in_buffer,
- port0->bulk_in_size,
- qt2_read_bulk_callback,
- serial);
- }
- }
-exit:
- mutex_unlock(&port_extra->modelock);
- dbg("%s(): exit port %d", __func__, port->number);
- return;
-}
-
-/* internal, private helper functions for the driver */
-
-/* Power up the FPGA in the box to get it working */
-static int qt2_boxpoweron(struct usb_serial *serial)
-{
- int result;
- __u8 Direcion;
- unsigned int pipe;
- Direcion = USBD_TRANSFER_DIRECTION_OUT;
- pipe = usb_rcvctrlpipe(serial->dev, 0);
- result = usb_control_msg(serial->dev, pipe, QT_SET_GET_DEVICE,
- Direcion, QU2BOXPWRON, 0x00, NULL, 0x00,
- 5000);
- return result;
-}
-
-/*
- * qt2_boxsetQMCR Issue a QT2_GET_SET_QMCR vendor-spcific request on the
- * default control pipe. If successful return the number of bytes written,
- * otherwise return a negative error number of the problem.
- */
-static int qt2_boxsetQMCR(struct usb_serial *serial, __u16 Uart_Number,
- __u8 QMCR_Value)
-{
- int result;
- __u16 PortSettings;
-
- PortSettings = (__u16)(QMCR_Value);
-
- dbg("%s(): Port = %d, PortSettings = 0x%x", __func__,
- Uart_Number, PortSettings);
-
- result = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0),
- QT2_GET_SET_QMCR, 0x40, PortSettings,
- (__u16)Uart_Number, NULL, 0, 5000);
- return result;
-}
-
-static int port_paranoia_check(struct usb_serial_port *port,
- const char *function)
-{
- if (!port) {
- dbg("%s - port == NULL", function);
- return -1;
- }
- if (!port->serial) {
- dbg("%s - port->serial == NULL\n", function);
- return -1;
- }
- return 0;
-}
-
-static int serial_paranoia_check(struct usb_serial *serial,
- const char *function)
-{
- if (!serial) {
- dbg("%s - serial == NULL\n", function);
- return -1;
- }
-
- if (!serial->type) {
- dbg("%s - serial->type == NULL!", function);
- return -1;
- }
-
- return 0;
-}
-
-static inline struct quatech2_port *qt2_get_port_private(struct usb_serial_port
- *port)
-{
- return (struct quatech2_port *)usb_get_serial_port_data(port);
-}
-
-static inline void qt2_set_port_private(struct usb_serial_port *port,
- struct quatech2_port *data)
-{
- usb_set_serial_port_data(port, (void *)data);
-}
-
-static inline struct quatech2_dev *qt2_get_dev_private(struct usb_serial
- *serial)
-{
- return (struct quatech2_dev *)usb_get_serial_data(serial);
-}
-static inline void qt2_set_dev_private(struct usb_serial *serial,
- struct quatech2_dev *data)
-{
- usb_set_serial_data(serial, (void *)data);
-}
-
-static int qt2_openboxchannel(struct usb_serial *serial, __u16
- Uart_Number, struct qt2_status_data *status)
-{
- int result;
- __u16 length;
- __u8 Direcion;
- unsigned int pipe;
- length = sizeof(struct qt2_status_data);
- Direcion = USBD_TRANSFER_DIRECTION_IN;
- pipe = usb_rcvctrlpipe(serial->dev, 0);
- result = usb_control_msg(serial->dev, pipe, QT_OPEN_CLOSE_CHANNEL,
- Direcion, 0x00, Uart_Number, status, length, 5000);
- return result;
-}
-static int qt2_closeboxchannel(struct usb_serial *serial, __u16 Uart_Number)
-{
- int result;
- __u8 direcion;
- unsigned int pipe;
- direcion = USBD_TRANSFER_DIRECTION_OUT;
- pipe = usb_sndctrlpipe(serial->dev, 0);
- result = usb_control_msg(serial->dev, pipe, QT_OPEN_CLOSE_CHANNEL,
- direcion, 0, Uart_Number, NULL, 0, 5000);
- return result;
-}
-
-/* qt2_conf_uart Issue a SET_UART vendor-spcific request on the default
- * control pipe. If successful sets baud rate divisor and LCR value
- */
-static int qt2_conf_uart(struct usb_serial *serial, unsigned short Uart_Number,
- unsigned short divisor, unsigned char LCR)
-{
- int result;
- unsigned short UartNumandLCR;
-
- UartNumandLCR = (LCR << 8) + Uart_Number;
-
- result = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0),
- QT2_GET_SET_UART, 0x40, divisor, UartNumandLCR,
- NULL, 0, 300);
- return result;
-}
-
-/** @brief Callback for asynchronous submission of read URBs on bulk in
- * endpoints
- *
- * Registered in qt2_open_port(), used to deal with incomming data
- * from the box.
- */
-static void qt2_read_bulk_callback(struct urb *urb)
-{
- /* Get the device pointer (struct usb_serial) back out of the URB */
- struct usb_serial *serial = urb->context;
- /* get the extra struct for the device */
- struct quatech2_dev *dev_extra = qt2_get_dev_private(serial);
- /* Get first port structure from the device */
- struct usb_serial_port *port0 = serial->port[0];
- /* Get the currently active port structure from serial struct */
- struct usb_serial_port *active = dev_extra->current_port;
- /* get the extra struct for port 0 */
- struct quatech2_port *port0_extra = qt2_get_port_private(port0);
- /* and for the currently active port */
- struct quatech2_port *active_extra = qt2_get_port_private(active);
- /* When we finally get to doing some tty stuff, we will need this */
- struct tty_struct *tty_st;
- unsigned int RxCount; /* the length of the data to process */
- unsigned int i; /* loop counter over the data to process */
- int result; /* return value cache variable */
- bool escapeflag; /* flag set to true if this loop iteration is
- * parsing an escape sequence, rather than
- * ordinary data */
- dbg("%s(): callback running, active port is %d", __func__,
- active->number);
-
- if (urb->status) {
- /* read didn't go well */
- dev_extra->ReadBulkStopped = true;
- dbg("%s(): nonzero bulk read status received: %d",
- __func__, urb->status);
- return;
- }
-
- /* inline port_sofrint() here */
- if (port_paranoia_check(port0, __func__) != 0) {
- dbg("%s - port_paranoia_check on port0 failed, exiting\n",
-__func__);
- return;
- }
- if (port_paranoia_check(active, __func__) != 0) {
- dbg("%s - port_paranoia_check on current_port "
- "failed, exiting", __func__);
- return;
- }
-
-/* This single callback function has to do for all the ports on
- * the device. Data being read up the USB can contain certain
- * escape sequences which are used to communicate out-of-band
- * information from the serial port in-band over the USB.
- * These escapes include sending modem and flow control line
- * status, and switching the port. The concept of a "Current Port"
- * is used, which is where data is going until a port change
- * escape seqence is received. This Current Port is kept between
- * callbacks so that when this function enters we know which the
- * currently active port is and can get to work right away without
- * the box having to send repeat escape sequences (anyway, how
- * would it know to do so?).
- */
-
- if (active_extra->close_pending == true) {
- /* We are closing , stop reading */
- dbg("%s - (active->close_pending == true", __func__);
- if (dev_extra->open_ports <= 0) {
- /* If this is the only port left open - stop the
- * bulk read */
- dev_extra->ReadBulkStopped = true;
- dbg("%s - (ReadBulkStopped == true;", __func__);
- return;
- }
- }
-
- /*
- * RxHolding is asserted by throttle, if we assert it, we're not
- * receiving any more characters and let the box handle the flow
- * control
- */
- if ((port0_extra->RxHolding == true) &&
- (serial->dev->descriptor.idProduct == QUATECH_SSU2_100)) {
- /* single port device, input is already stopped, so we don't
- * need any more input data */
- dev_extra->ReadBulkStopped = true;
- return;
- }
- /* finally, we are in a situation where we might consider the data
- * that is contained within the URB, and what to do about it.
- * This is likely to involved communicating up to the TTY layer, so
- * we will need to get hold of the tty for the port we are currently
- * dealing with */
-
- /* active is a usb_serial_port. It has a member port which is a
- * tty_port. From this we get a tty_struct pointer which is what we
- * actually wanted, and keep it on tty_st */
- tty_st = tty_port_tty_get(&active->port);
- if (!tty_st) {
- dbg("%s - bad tty pointer - exiting", __func__);
- return;
- }
- RxCount = urb->actual_length; /* grab length of data handy */
-
- if (RxCount) {
- /* skip all this if no data to process */
- for (i = 0; i < RxCount ; ++i) {
- /* Look ahead code here -works on several bytes at onc*/
- if ((i <= (RxCount - 3)) && (THISCHAR == 0x1b)
- && (NEXTCHAR == 0x1b)) {
- /* we are in an escape sequence, type
- * determined by the 3rd char */
- escapeflag = false;
- switch (THIRDCHAR) {
- case 0x00:
- /* Line status change 4th byte must
- * follow */
- if (i > (RxCount - 4)) {
- dbg("Illegal escape sequences "
- "in received data");
- break;
- }
- qt2_process_line_status(active,
- FOURTHCHAR);
- i += 3;
- escapeflag = true;
- break;
- case 0x01:
- /* Modem status status change 4th byte
- * must follow */
- if (i > (RxCount - 4)) {
- dbg("Illegal escape sequences "
- "in received data");
- break;
- }
- qt2_process_modem_status(active,
- FOURTHCHAR);
- i += 3;
- escapeflag = true;
- break;
- case 0x02:
- /* xmit hold empty 4th byte
- * must follow */
- if (i > (RxCount - 4)) {
- dbg("Illegal escape sequences "
- "in received data");
- break;
- }
- qt2_process_xmit_empty(active,
- FOURTHCHAR, FIFTHCHAR);
- i += 4;
- escapeflag = true;
- break;
- case 0x03:
- /* Port number change 4th byte
- * must follow */
- if (i > (RxCount - 4)) {
- dbg("Illegal escape sequences "
- "in received data");
- break;
- }
- /* Port change. If port open push
- * current data up to tty layer */
- if (active_extra->open_count > 0)
- tty_flip_buffer_push(tty_st);
-
- dbg("Port Change: new port = %d",
- FOURTHCHAR);
- qt2_process_port_change(active,
- FOURTHCHAR);
- i += 3;
- escapeflag = true;
- /* having changed port, the pointers for
- * the currently active port are all out
- * of date and need updating */
- active = dev_extra->current_port;
- active_extra =
- qt2_get_port_private(active);
- tty_st = tty_port_tty_get(
- &active->port);
- break;
- case 0x04:
- /* Recv flush 3rd byte must
- * follow */
- if (i > (RxCount - 3)) {
- dbg("Illegal escape sequences "
- "in received data");
- break;
- }
- qt2_process_rcv_flush(active);
- i += 2;
- escapeflag = true;
- break;
- case 0x05:
- /* xmit flush 3rd byte must follow */
- if (i > (RxCount - 3)) {
- dbg("Illegal escape sequences "
- "in received data");
- break;
- }
- qt2_process_xmit_flush(active);
- i += 2;
- escapeflag = true;
- break;
- case 0xff:
- dbg("No status sequence");
- qt2_process_rx_char(active, THISCHAR);
- qt2_process_rx_char(active, NEXTCHAR);
- i += 2;
- break;
- default:
- qt2_process_rx_char(active, THISCHAR);
- i += 1;
- break;
- } /*end switch*/
- if (escapeflag == true)
- continue;
- /* if we did an escape char, we don't need
- * to mess around pushing data through the
- * tty layer, and can go round again */
- } /*endif*/
- if (tty_st && urb->actual_length) {
- tty_buffer_request_room(tty_st, 1);
- tty_insert_flip_string(tty_st, &(
- (unsigned char *)
- (urb->transfer_buffer)
- )[i], 1);
- }
- } /*endfor*/
- tty_flip_buffer_push(tty_st);
- } /*endif*/
-
- /* at this point we have complete dealing with the data for this
- * callback. All we have to do now is to start the async read process
- * back off again. */
-
- usb_fill_bulk_urb(port0->read_urb, serial->dev,
- usb_rcvbulkpipe(serial->dev, port0->bulk_in_endpointAddress),
- port0->bulk_in_buffer, port0->bulk_in_size,
- qt2_read_bulk_callback, serial);
- result = usb_submit_urb(port0->read_urb, GFP_ATOMIC);
- if (result) {
- dbg("%s(): failed resubmitting read urb, error %d",
- __func__, result);
- } else {
- dbg("%s() successfully resubmitted read urb", __func__);
- if (tty_st && RxCount) {
- /* if some inbound data was processed, then
- * we need to push that through the tty layer
- */
- tty_flip_buffer_push(tty_st);
- tty_schedule_flip(tty_st);
- }
- }
-
- /* cribbed from serqt_usb2 driver, but not sure which work needs
- * scheduling - port0 or currently active port? */
- /* schedule_work(&port->work); */
- dbg("%s() completed", __func__);
- return;
-}
-
-/** @brief Callback for asynchronous submission of write URBs on bulk in
- * endpoints
- *
- * Registered in qt2_write(), used to deal with outgoing data
- * to the box.
- */
-static void qt2_write_bulk_callback(struct urb *urb)
-{
- struct usb_serial_port *port = (struct usb_serial_port *)urb->context;
- struct usb_serial *serial = port->serial;
- dbg("%s(): port %d", __func__, port->number);
- if (!serial) {
- dbg("%s(): bad serial pointer, exiting", __func__);
- return;
- }
- if (urb->status) {
- dbg("%s(): nonzero write bulk status received: %d",
- __func__, urb->status);
- return;
- }
- /* FIXME What is supposed to be going on here?
- * does this actually do anything useful, and should it?
- */
- /*port_softint((void *) serial); commented in vendor driver */
- schedule_work(&port->work);
- dbg("%s(): port %d exit", __func__, port->number);
- return;
-}
-
-static void qt2_process_line_status(struct usb_serial_port *port,
- unsigned char LineStatus)
-{
- /* obtain the private structure for the port */
- struct quatech2_port *port_extra = qt2_get_port_private(port);
- port_extra->shadowLSR = LineStatus & (QT2_SERIAL_LSR_OE |
- QT2_SERIAL_LSR_PE | QT2_SERIAL_LSR_FE | QT2_SERIAL_LSR_BI);
-}
-static void qt2_process_modem_status(struct usb_serial_port *port,
- unsigned char ModemStatus)
-{
- /* obtain the private structure for the port */
- struct quatech2_port *port_extra = qt2_get_port_private(port);
- port_extra->shadowMSR = ModemStatus;
- wake_up_interruptible(&port_extra->wait);
- /* this wakes up the otherwise indefinitely waiting code for
- * the TIOCMIWAIT ioctl, so that it can notice that
- * port_extra->shadowMSR has changed and the ioctl needs to return.
- */
-}
-
-static void qt2_process_xmit_empty(struct usb_serial_port *port,
- unsigned char fourth_char, unsigned char fifth_char)
-{
- int byte_count;
- /* obtain the private structure for the port */
- struct quatech2_port *port_extra = qt2_get_port_private(port);
-
- byte_count = (int)(fifth_char * 16);
- byte_count += (int)fourth_char;
- /* byte_count indicates how many bytes the device has written out. This
- * message appears to occur regularly, and is used in the vendor driver
- * to keep track of the fill state of the port transmit buffer */
- port_extra->tx_pending_bytes -= byte_count;
- /* reduce the stored data queue length by the known number of bytes
- * sent */
- dbg("port %d: %d bytes reported sent, %d still pending", port->number,
- byte_count, port_extra->tx_pending_bytes);
-
- /*port_extra->xmit_fifo_room_bytes = FIFO_DEPTH; ???*/
-}
-
-static void qt2_process_port_change(struct usb_serial_port *port,
- unsigned char New_Current_Port)
-{
- /* obtain the parent usb serial device structure */
- struct usb_serial *serial = port->serial;
- /* obtain the private structure for the device */
- struct quatech2_dev *dev_extra = qt2_get_dev_private(serial);
- dev_extra->current_port = serial->port[New_Current_Port];
- /* what should I do with this? commented out in upstream
- * driver */
- /*schedule_work(&port->work);*/
-}
-
-static void qt2_process_rcv_flush(struct usb_serial_port *port)
-{
- /* obtain the private structure for the port */
- struct quatech2_port *port_extra = qt2_get_port_private(port);
- port_extra->rcv_flush = true;
-}
-static void qt2_process_xmit_flush(struct usb_serial_port *port)
-{
- /* obtain the private structure for the port */
- struct quatech2_port *port_extra = qt2_get_port_private(port);
- port_extra->xmit_flush = true;
-}
-
-static void qt2_process_rx_char(struct usb_serial_port *port,
- unsigned char data)
-{
- /* get the tty_struct for this port */
- struct tty_struct *tty = tty_port_tty_get(&(port->port));
- /* get the URB with the data in to push */
- struct urb *urb = port->serial->port[0]->read_urb;
-
- if (tty && urb->actual_length) {
- tty_buffer_request_room(tty, 1);
- tty_insert_flip_string(tty, &data, 1);
- /* should this be commented out here? */
- /*tty_flip_buffer_push(tty);*/
- }
-}
-
-/** @brief Retrieve the value of a register from the device
- *
- * Issues a GET_REGISTER vendor-spcific request over the USB control
- * pipe to obtain a value back from a specific register on a specific
- * UART
- * @param serial Serial device handle to access the device through
- * @param uart_number Which UART the value is wanted from
- * @param register_num Which register to read the value from
- * @param pValue Pointer to somewhere to put the retrieved value
- */
-static int qt2_box_get_register(struct usb_serial *serial,
- unsigned char uart_number, unsigned short register_num,
- __u8 *pValue)
-{
- int result;
- result = usb_control_msg(serial->dev, usb_rcvctrlpipe(serial->dev, 0),
- QT2_GET_SET_REGISTER, 0xC0, register_num,
- uart_number, (void *)pValue, sizeof(*pValue), 300);
- return result;
-}
-
-/** qt2_box_set_register
- * Issue a SET_REGISTER vendor-specific request on the default control pipe
- */
-static int qt2_box_set_register(struct usb_serial *serial,
- unsigned short Uart_Number, unsigned short Register_Num,
- unsigned short Value)
-{
- int result;
- unsigned short reg_and_byte;
-
- reg_and_byte = Value;
- reg_and_byte = reg_and_byte << 8;
- reg_and_byte = reg_and_byte + Register_Num;
-
- result = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0),
- QT2_GET_SET_REGISTER, 0x40, reg_and_byte,
- Uart_Number, NULL, 0, 300);
- return result;
-}
-
-/** qt2_boxsetuart - Issue a SET_UART vendor-spcific request on the default
- * control pipe. If successful sets baud rate divisor and LCR value.
- */
-static int qt2_boxsetuart(struct usb_serial *serial, unsigned short Uart_Number,
- unsigned short default_divisor, unsigned char default_LCR)
-{
- unsigned short UartNumandLCR;
-
- UartNumandLCR = (default_LCR << 8) + Uart_Number;
-
- return usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0),
- QT2_GET_SET_UART, 0x40, default_divisor, UartNumandLCR,
- NULL, 0, 300);
-}
-
-/** qt2_boxsethw_flowctl - Turn hardware (RTS/CTS) flow control on and off for
- * a hardware UART.
- */
-static int qt2_boxsethw_flowctl(struct usb_serial *serial,
- unsigned int UartNumber, bool bSet)
-{
- __u8 MCR_Value = 0;
- __u8 MSR_Value = 0;
- __u16 MOUT_Value = 0;
-
- if (bSet == true) {
- MCR_Value = QT2_SERIAL_MCR_RTS;
- /* flow control, box will clear RTS line to prevent remote
- * device from transmitting more chars */
- } else {
- /* no flow control to remote device */
- MCR_Value = 0;
- }
- MOUT_Value = MCR_Value << 8;
-
- if (bSet == true) {
- MSR_Value = QT2_SERIAL_MSR_CTS;
- /* flow control on, box will inhibit tx data if CTS line is
- * asserted */
- } else {
- /* Box will not inhibit tx data due to CTS line */
- MSR_Value = 0;
- }
- MOUT_Value |= MSR_Value;
- return usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0),
- QT2_HW_FLOW_CONTROL_MASK, 0x40, MOUT_Value, UartNumber,
- NULL, 0, 300);
-}
-
-/** qt2_boxsetsw_flowctl - Turn software (XON/XOFF) flow control on for
- * a hardware UART, and set the XON and XOFF characters.
- */
-static int qt2_boxsetsw_flowctl(struct usb_serial *serial, __u16 UartNumber,
- unsigned char stop_char, unsigned char start_char)
-{
- __u16 nSWflowout;
-
- nSWflowout = start_char << 8;
- nSWflowout = (unsigned short)stop_char;
- return usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0),
- QT2_SW_FLOW_CONTROL_MASK, 0x40, nSWflowout, UartNumber,
- NULL, 0, 300);
-}
-
-/** qt2_boxunsetsw_flowctl - Turn software (XON/XOFF) flow control off for
- * a hardware UART.
- */
-static int qt2_boxunsetsw_flowctl(struct usb_serial *serial, __u16 UartNumber)
-{
- return usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0),
- QT2_SW_FLOW_CONTROL_DISABLE, 0x40, 0, UartNumber, NULL,
- 0, 300);
-}
-
-/**
- * qt2_boxstoprx - Start and stop reception of data by the FPGA UART in
- * response to requests from the tty layer
- * @serial: pointer to the usb_serial structure for the parent device
- * @uart_number: which UART on the device we are addressing
- * @stop: Whether to start or stop data reception. Set to 1 to stop data being
- * received, and to 0 to start it being received.
- */
-static int qt2_boxstoprx(struct usb_serial *serial, unsigned short uart_number,
- unsigned short stop)
-{
- return usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0),
- QT2_STOP_RECEIVE, 0x40, stop, uart_number, NULL, 0, 300);
-}
-
-
-/*
- * last things in file: stuff to register this driver into the generic
- * USB serial framework.
- */
-
-static struct usb_serial_driver quatech2_device = {
- .driver = {
- .owner = THIS_MODULE,
- .name = "quatech_usb2",
- },
- .description = DRIVER_DESC,
- .id_table = quausb2_id_table,
- .num_ports = 8,
- .open = qt2_open,
- .close = qt2_close,
- .write = qt2_write,
- .write_room = qt2_write_room,
- .chars_in_buffer = qt2_chars_in_buffer,
- .throttle = qt2_throttle,
- .unthrottle = qt2_unthrottle,
- .calc_num_ports = qt2_calc_num_ports,
- .ioctl = qt2_ioctl,
- .set_termios = qt2_set_termios,
- .break_ctl = qt2_break,
- .tiocmget = qt2_tiocmget,
- .tiocmset = qt2_tiocmset,
- .attach = qt2_attach,
- .release = qt2_release,
- .read_bulk_callback = qt2_read_bulk_callback,
- .write_bulk_callback = qt2_write_bulk_callback,
-};
-
-static struct usb_serial_driver * const serial_drivers[] = {
- &quatech2_device, NULL
-};
-
-module_usb_serial_driver(quausb2_usb_driver, serial_drivers);
-
-MODULE_AUTHOR(DRIVER_AUTHOR);
-MODULE_DESCRIPTION(DRIVER_DESC);
-MODULE_LICENSE("GPL");
-
-module_param(debug, bool, S_IRUGO | S_IWUSR);
-MODULE_PARM_DESC(debug, "Debug enabled or not");
diff --git a/drivers/staging/ramster/Kconfig b/drivers/staging/ramster/Kconfig
index 4af1f8d4b953..8349887827dc 100644
--- a/drivers/staging/ramster/Kconfig
+++ b/drivers/staging/ramster/Kconfig
@@ -1,6 +1,6 @@
config RAMSTER
bool "Cross-machine RAM capacity sharing, aka peer-to-peer tmem"
- depends on (CLEANCACHE || FRONTSWAP) && CONFIGFS_FS=y && !ZCACHE && !XVMALLOC && !HIGHMEM
+ depends on (CLEANCACHE || FRONTSWAP) && CONFIGFS_FS=y && !ZCACHE && !XVMALLOC && !HIGHMEM && NET
select LZO_COMPRESS
select LZO_DECOMPRESS
default n
diff --git a/drivers/staging/ramster/cluster/tcp.c b/drivers/staging/ramster/cluster/tcp.c
index 3af1b2c51b78..d0a07d722b61 100644
--- a/drivers/staging/ramster/cluster/tcp.c
+++ b/drivers/staging/ramster/cluster/tcp.c
@@ -111,7 +111,7 @@ static struct socket *r2net_listen_sock;
* r2net_wq. teardown detaches the callbacks before destroying the workqueue.
* quorum work is queued as sock containers are shutdown.. stop_listening
* tears down all the node's sock containers, preventing future shutdowns
- * and queued quroum work, before canceling delayed quorum work and
+ * and queued quorum work, before canceling delayed quorum work and
* destroying the work queue.
*/
static struct workqueue_struct *r2net_wq;
@@ -660,7 +660,7 @@ out:
/*
* we register callbacks so we can queue work on events before calling
- * the original callbacks. our callbacks our careful to test user_data
+ * the original callbacks. our callbacks are careful to test user_data
* to discover when they've reaced with r2net_unregister_callbacks().
*/
static void r2net_register_callbacks(struct sock *sk,
@@ -2106,7 +2106,7 @@ static int r2net_open_listening_sock(__be32 addr, __be16 port)
r2net_listen_sock = sock;
INIT_WORK(&r2net_listen_work, r2net_accept_many);
- sock->sk->sk_reuse = 1;
+ sock->sk->sk_reuse = SK_CAN_REUSE;
ret = sock->ops->bind(sock, (struct sockaddr *)&sin, sizeof(sin));
if (ret < 0) {
printk(KERN_ERR "ramster: Error %d while binding socket at "
diff --git a/drivers/staging/ramster/r2net.c b/drivers/staging/ramster/r2net.c
index 2ee02204c43d..fc830c3ac74b 100644
--- a/drivers/staging/ramster/r2net.c
+++ b/drivers/staging/ramster/r2net.c
@@ -266,8 +266,8 @@ int ramster_remote_put(struct tmem_xhandle *xh, char *data, size_t size,
static unsigned long cnt;
cnt++;
if (!(cnt&(cnt-1)))
- pr_err("ramster_remote_put: message failed, "
- "ret=%d, cnt=%lu\n", ret, cnt);
+ pr_err("ramster_remote_put: message failed, ret=%d, cnt=%lu\n",
+ ret, cnt);
ret = -1;
}
#endif
diff --git a/drivers/staging/ramster/xvmalloc.c b/drivers/staging/ramster/xvmalloc.c
index 93ba8e9407aa..44ceb0b823a9 100644
--- a/drivers/staging/ramster/xvmalloc.c
+++ b/drivers/staging/ramster/xvmalloc.c
@@ -132,7 +132,7 @@ static u32 find_block(struct xv_pool *pool, u32 size,
if (!pool->flbitmap)
return 0;
- /* Get freelist index correspoding to this size */
+ /* Get freelist index corresponding to this size */
slindex = get_index(size);
slbitmap = pool->slbitmap[slindex / BITS_PER_LONG];
slbitstart = slindex % BITS_PER_LONG;
diff --git a/drivers/staging/ramster/zcache-main.c b/drivers/staging/ramster/zcache-main.c
index 68b2e053a0e6..d46764b5aaba 100644
--- a/drivers/staging/ramster/zcache-main.c
+++ b/drivers/staging/ramster/zcache-main.c
@@ -1331,7 +1331,7 @@ static ssize_t zv_max_mean_zsize_store(struct kobject *kobj,
* when that limit is reached, further puts will be rejected (until
* some pages have been flushed). Note that, due to compression,
* this number may exceed 100; it defaults to 75 and we set an
- * arbitary limit of 150. A poor choice will almost certainly result
+ * arbitrary limit of 150. A poor choice will almost certainly result
* in OOM's, so this value should only be changed prudently.
*/
static ssize_t zv_page_count_policy_percent_show(struct kobject *kobj,
@@ -2004,7 +2004,7 @@ int zcache_pampd_replace_in_obj(void *new_pampd, struct tmem_obj *obj)
* Called by the message handler after a (still compressed) page has been
* fetched from the remote machine in response to an "is_remote" tmem_get
* or persistent tmem_localify. For a tmem_get, "extra" is the address of
- * the page that is to be filled to succesfully resolve the tmem_get; for
+ * the page that is to be filled to successfully resolve the tmem_get; for
* a (persistent) tmem_localify, "extra" is NULL (as the data is placed only
* in the local zcache). "data" points to "size" bytes of (compressed) data
* passed in the message. In the case of a persistent remote get, if
@@ -2095,7 +2095,7 @@ out:
/*
* Called on a remote persistent tmem_get to attempt to preallocate
* local storage for the data contained in the remote persistent page.
- * If succesfully preallocated, returns the pampd, marked as remote and
+ * If successfully preallocated, returns the pampd, marked as remote and
* in_transit. Else returns NULL. Note that the appropriate tmem data
* structure must be locked.
*/
@@ -3002,7 +3002,7 @@ static inline struct tmem_oid oswiz(unsigned type, u32 ind)
return oid;
}
-static int zcache_frontswap_put_page(unsigned type, pgoff_t offset,
+static int zcache_frontswap_store(unsigned type, pgoff_t offset,
struct page *page)
{
u64 ind64 = (u64)offset;
@@ -3025,7 +3025,7 @@ static int zcache_frontswap_put_page(unsigned type, pgoff_t offset,
/* returns 0 if the page was successfully gotten from frontswap, -1 if
* was not present (should never happen!) */
-static int zcache_frontswap_get_page(unsigned type, pgoff_t offset,
+static int zcache_frontswap_load(unsigned type, pgoff_t offset,
struct page *page)
{
u64 ind64 = (u64)offset;
@@ -3080,8 +3080,8 @@ static void zcache_frontswap_init(unsigned ignored)
}
static struct frontswap_ops zcache_frontswap_ops = {
- .put_page = zcache_frontswap_put_page,
- .get_page = zcache_frontswap_get_page,
+ .store = zcache_frontswap_store,
+ .load = zcache_frontswap_load,
.invalidate_page = zcache_frontswap_flush_page,
.invalidate_area = zcache_frontswap_flush_area,
.init = zcache_frontswap_init
diff --git a/drivers/staging/rtl8187se/Makefile b/drivers/staging/rtl8187se/Makefile
index 72db504b23b4..91d1aa2830c9 100644
--- a/drivers/staging/rtl8187se/Makefile
+++ b/drivers/staging/rtl8187se/Makefile
@@ -10,7 +10,7 @@ ccflags-y += -DHIGH_POWER
ccflags-y += -DSW_DIG
ccflags-y += -DRATE_ADAPT
-#enable it for legacy power save, disable it for leisure power save
+#enable it for legacy power save, disable it for leisure power save
ccflags-y += -DENABLE_LPS
diff --git a/drivers/staging/rtl8187se/ieee80211/dot11d.c b/drivers/staging/rtl8187se/ieee80211/dot11d.c
index 309bb8bf287e..0e93eb0735a7 100644
--- a/drivers/staging/rtl8187se/ieee80211/dot11d.c
+++ b/drivers/staging/rtl8187se/ieee80211/dot11d.c
@@ -55,7 +55,7 @@ Dot11d_Reset(struct ieee80211_device *ieee)
//
// Description:
-// Update country IE from Beacon or Probe Resopnse
+// Update country IE from Beacon or Probe Response
// and configure PHY for operation in the regulatory domain.
//
// TODO:
diff --git a/drivers/staging/rtl8187se/ieee80211/ieee80211.h b/drivers/staging/rtl8187se/ieee80211/ieee80211.h
index 40dd715d9df7..b94c48b29302 100644
--- a/drivers/staging/rtl8187se/ieee80211/ieee80211.h
+++ b/drivers/staging/rtl8187se/ieee80211/ieee80211.h
@@ -834,7 +834,7 @@ enum ieee80211_state {
/* the association procedure is sending AUTH request*/
IEEE80211_ASSOCIATING_AUTHENTICATING,
- /* the association procedure has successfully authentcated
+ /* the association procedure has successfully authenticated
* and is sending association request
*/
IEEE80211_ASSOCIATING_AUTHENTICATED,
@@ -934,7 +934,7 @@ struct ieee80211_device {
* with RX of broad/multicast frames */
/* Fragmentation structures */
- // each streaming contain a entry
+ /* each stream contains an entry */
struct ieee80211_frag_entry frag_cache[17][IEEE80211_FRAG_CACHE_LEN];
unsigned int frag_next_idx[17];
u16 fts; /* Fragmentation Threshold */
@@ -972,7 +972,7 @@ struct ieee80211_device {
int rate; /* current rate */
int basic_rate;
- //FIXME: pleace callback, see if redundant with softmac_features
+ //FIXME: please callback, see if redundant with softmac_features
short active_scan;
/* this contains flags for selectively enable softmac support */
@@ -1106,7 +1106,7 @@ struct ieee80211_device {
/* used instead of hard_start_xmit (not softmac_hard_start_xmit)
* if the IEEE_SOFTMAC_TX_QUEUE feature is used to TX data
- * frames. I the option IEEE_SOFTMAC_SINGLE_QUEUE is also set
+ * frames. If the option IEEE_SOFTMAC_SINGLE_QUEUE is also set
* then also management frames are sent via this callback.
* This function can't sleep.
*/
@@ -1124,7 +1124,7 @@ struct ieee80211_device {
/* ask to the driver to retune the radio .
* This function can sleep. the driver should ensure
- * the radio has been swithced before return.
+ * the radio has been switched before return.
*/
void (*set_chan)(struct net_device *dev,short ch);
@@ -1135,7 +1135,7 @@ struct ieee80211_device {
* The syncro version is similar to the start_scan but
* does not return until all channels has been scanned.
* this is called in user context and should sleep,
- * it is called in a work_queue when swithcing to ad-hoc mode
+ * it is called in a work_queue when switching to ad-hoc mode
* or in behalf of iwlist scan when the card is associated
* and root user ask for a scan.
* the function stop_scan should stop both the syncro and
@@ -1196,7 +1196,7 @@ struct ieee80211_device {
/* Generate probe requests */
#define IEEE_SOFTMAC_PROBERQ (1<<4)
-/* Generate respones to probe requests */
+/* Generate response to probe requests */
#define IEEE_SOFTMAC_PROBERS (1<<5)
/* The ieee802.11 stack will manages the netif queue
diff --git a/drivers/staging/rtl8187se/ieee80211/ieee80211_softmac.c b/drivers/staging/rtl8187se/ieee80211/ieee80211_softmac.c
index 26bacb96d247..8173240dcf7a 100644
--- a/drivers/staging/rtl8187se/ieee80211/ieee80211_softmac.c
+++ b/drivers/staging/rtl8187se/ieee80211/ieee80211_softmac.c
@@ -42,7 +42,7 @@ short ieee80211_is_shortslot(const struct ieee80211_network *net)
return net->capability & WLAN_CAPABILITY_SHORT_SLOT;
}
-/* returns the total length needed for pleacing the RATE MFIE
+/* returns the total length needed for placing the RATE MFIE
* tag and the EXTENDED RATE MFIE tag if needed.
* It encludes two bytes per tag for the tag itself and its len
*/
@@ -60,7 +60,7 @@ unsigned int ieee80211_MFIE_rate_len(struct ieee80211_device *ieee)
return rate_len;
}
-/* pleace the MFIE rate, tag to the memory (double) poined.
+/* place the MFIE rate, tag to the memory (double) poised.
* Then it updates the pointer so that
* it points after the new MFIE tag added.
*/
@@ -467,7 +467,7 @@ void ieee80211_softmac_scan_syncro(struct ieee80211_device *ieee)
* So we switch to IEEE80211_LINKED_SCANNING to remember
* that we are still logically linked (not interested in
* new network events, despite for updating the net list,
- * but we are temporarly 'unlinked' as the driver shall
+ * but we are temporarily 'unlinked' as the driver shall
* not filter RX frames and the channel is changing.
* So the only situation in witch are interested is to check
* if the state become LINKED because of the #1 situation
@@ -530,7 +530,7 @@ void ieee80211_softmac_ips_scan_syncro(struct ieee80211_device *ieee)
* So we switch to IEEE80211_LINKED_SCANNING to remember
* that we are still logically linked (not interested in
* new network events, despite for updating the net list,
- * but we are temporarly 'unlinked' as the driver shall
+ * but we are temporarily 'unlinked' as the driver shall
* not filter RX frames and the channel is changing.
* So the only situation in witch are interested is to check
* if the state become LINKED because of the #1 situation
@@ -1140,7 +1140,7 @@ void ieee80211_associate_abort(struct ieee80211_device *ieee)
ieee->associate_seq++;
- /* don't scan, and avoid to have the RX path possibily
+ /* don't scan, and avoid to have the RX path possibly
* try again to associate. Even do not react to AUTH or
* ASSOC response. Just wait for the retry wq to be scheduled.
* Here we will check if there are good nets to associate
@@ -1346,14 +1346,14 @@ inline void ieee80211_softmac_new_net(struct ieee80211_device *ieee, struct ieee
//printk("apset=%d apmatch=%d ssidset=%d ssidbroad=%d ssidmatch=%d\n",apset,apmatch,ssidset,ssidbroad,ssidmatch);
if ( /* if the user set the AP check if match.
- * if the network does not broadcast essid we check the user supplyed ANY essid
+ * if the network does not broadcast essid we check the user supplied ANY essid
* if the network does broadcast and the user does not set essid it is OK
* if the network does broadcast and the user did set essid chech if essid match
*/
( apset && apmatch &&
((ssidset && ssidbroad && ssidmatch) || (ssidbroad && !ssidset) || (!ssidbroad && ssidset)) ) ||
/* if the ap is not set, check that the user set the bssid
- * and the network does bradcast and that those two bssid matches
+ * and the network does broadcast and that those two bssid matches
*/
(!apset && ssidset && ssidbroad && ssidmatch)
){
@@ -1821,7 +1821,7 @@ ieee80211_rx_frame_softmac(struct ieee80211_device *ieee, struct sk_buff *skb,
while (left >= sizeof(struct ieee80211_info_element_hdr)) {
if (sizeof(struct ieee80211_info_element_hdr) + info_element->len > left) {
- printk(KERN_WARNING "[re]associate reeponse error!");
+ printk(KERN_WARNING "[re]associate response error!");
return 1;
}
switch (info_element->id) {
@@ -1905,7 +1905,7 @@ associate_complete:
}
}else{
ieee->softmac_stats.rx_auth_rs_err++;
- IEEE80211_DEBUG_MGMT("Authentication respose status code 0x%x",errcode);
+ IEEE80211_DEBUG_MGMT("Authentication response status code 0x%x",errcode);
ieee80211_associate_abort(ieee);
}
@@ -2184,15 +2184,15 @@ void ieee80211_start_ibss_wq(struct work_struct *work)
if(ieee->state == IEEE80211_NOLINK)
ieee->current_network.channel = 10;
- /* if not then the state is not linked. Maybe the user swithced to
+ /* if not then the state is not linked. Maybe the user switched to
* ad-hoc mode just after being in monitor mode, or just after
* being very few time in managed mode (so the card have had no
* time to scan all the chans..) or we have just run up the iface
* after setting ad-hoc mode. So we have to give another try..
* Here, in ibss mode, should be safe to do this without extra care
- * (in bss mode we had to make sure no-one tryed to associate when
+ * (in bss mode we had to make sure no-one tried to associate when
* we had just checked the ieee->state and we was going to start the
- * scan) beacause in ibss mode the ieee80211_new_net function, when
+ * scan) because in ibss mode the ieee80211_new_net function, when
* finds a good net, just set the ieee->state to IEEE80211_LINKED,
* so, at worst, we waste a bit of time to initiate an unneeded syncro
* scan, that will stop at the first round because it sees the state
@@ -2342,7 +2342,7 @@ void ieee80211_associate_retry_wq(struct work_struct *work)
goto exit;
/* until we do not set the state to IEEE80211_NOLINK
* there are no possibility to have someone else trying
- * to start an association procdure (we get here with
+ * to start an association procedure (we get here with
* ieee->state = IEEE80211_ASSOCIATING).
* When we set the state to IEEE80211_NOLINK it is possible
* that the RX path run an attempt to associate, but
diff --git a/drivers/staging/rtl8187se/ieee80211/ieee80211_softmac_wx.c b/drivers/staging/rtl8187se/ieee80211/ieee80211_softmac_wx.c
index e46ff2ffa09b..5d204906baf7 100644
--- a/drivers/staging/rtl8187se/ieee80211/ieee80211_softmac_wx.c
+++ b/drivers/staging/rtl8187se/ieee80211/ieee80211_softmac_wx.c
@@ -362,7 +362,7 @@ int ieee80211_wx_set_essid(struct ieee80211_device *ieee,
ieee80211_stop_protocol(ieee);
/* this is just to be sure that the GET wx callback
- * has consisten infos. not needed otherwise
+ * has consistent infos. not needed otherwise
*/
spin_lock_irqsave(&ieee->lock, flags);
diff --git a/drivers/staging/rtl8187se/ieee80211/ieee80211_tx.c b/drivers/staging/rtl8187se/ieee80211/ieee80211_tx.c
index 552115cd760e..89ed86ef0d15 100644
--- a/drivers/staging/rtl8187se/ieee80211/ieee80211_tx.c
+++ b/drivers/staging/rtl8187se/ieee80211/ieee80211_tx.c
@@ -328,7 +328,7 @@ int ieee80211_rtl_xmit(struct sk_buff *skb,
//printk(KERN_WARNING "upper layer packet!\n");
spin_lock_irqsave(&ieee->lock, flags);
- /* If there is no driver handler to take the TXB, dont' bother
+ /* If there is no driver handler to take the TXB, don't bother
* creating it... */
if ((!ieee->hard_start_xmit && !(ieee->softmac_features & IEEE_SOFTMAC_TX_QUEUE))||
((!ieee->softmac_data_hard_start_xmit && (ieee->softmac_features & IEEE_SOFTMAC_TX_QUEUE)))) {
@@ -413,10 +413,7 @@ int ieee80211_rtl_xmit(struct sk_buff *skb,
/* Determine fragmentation size based on destination (multicast
* and broadcast are not fragmented) */
-// if (is_multicast_ether_addr(dest) ||
-// is_broadcast_ether_addr(dest)) {
- if (is_multicast_ether_addr(header.addr1) ||
- is_broadcast_ether_addr(header.addr1)) {
+ if (is_multicast_ether_addr(header.addr1)) {
frag_size = MAX_FRAG_THRESHOLD;
qos_ctl = QOS_CTL_NOTCONTAIN_ACK;
}
diff --git a/drivers/staging/rtl8187se/ieee80211/ieee80211_wx.c b/drivers/staging/rtl8187se/ieee80211/ieee80211_wx.c
index ca414a915a4e..c7917b24425c 100644
--- a/drivers/staging/rtl8187se/ieee80211/ieee80211_wx.c
+++ b/drivers/staging/rtl8187se/ieee80211/ieee80211_wx.c
@@ -363,7 +363,7 @@ int ieee80211_wx_set_encode(struct ieee80211_device *ieee,
(*crypt)->priv);
sec.flags |= (1 << key);
/* This ensures a key will be activated if no key is
- * explicitely set */
+ * explicitly set */
if (key == sec.active_key)
sec.flags |= SEC_ACTIVE_KEY;
ieee->tx_keyidx = key;//by wb 080312
diff --git a/drivers/staging/rtl8187se/r8180.h b/drivers/staging/rtl8187se/r8180.h
index a2c46ae4a400..2682afbac4ff 100644
--- a/drivers/staging/rtl8187se/r8180.h
+++ b/drivers/staging/rtl8187se/r8180.h
@@ -11,7 +11,7 @@
Parts of this driver are based on the Intel Pro Wireless 2100 GPL driver
- We want to tanks the Authors of those projects and the Ndiswrapper
+ We want to thanks the Authors of those projects and the Ndiswrapper
project Authors.
*/
@@ -514,12 +514,12 @@ typedef struct r8180_priv
bool bDefaultAntenna1;
u8 SignalStrength;
long Stats_SignalStrength;
- long LastSignalStrengthInPercent; // In percentange, used for smoothing, e.g. Moving Average.
+ long LastSignalStrengthInPercent; // In percentage, used for smoothing, e.g. Moving Average.
u8 SignalQuality; // in 0-100 index.
long Stats_SignalQuality;
long RecvSignalPower; // in dBm.
long Stats_RecvSignalPower;
- u8 LastRxPktAntenna; // +by amy 080312 Antenn which received the lasted packet. 0: Aux, 1:Main. Added by Roger, 2008.01.25.
+ u8 LastRxPktAntenna; // +by amy 080312 Antenna which received the lasted packet. 0: Aux, 1:Main. Added by Roger, 2008.01.25.
u32 AdRxOkCnt;
long AdRxSignalStrength;
u8 CurrAntennaIndex; // Index to current Antenna (both Tx and Rx).
@@ -530,7 +530,7 @@ typedef struct r8180_priv
long AdRxSsThreshold; // Signal strength threshold to switch antenna.
long AdMaxRxSsThreshold; // Max value of AdRxSsThreshold.
bool bAdSwitchedChecking; // TRUE if we shall shall check Rx signal strength for last time switching antenna.
- long AdRxSsBeforeSwitched; // Rx signal strength before we swithed antenna.
+ long AdRxSsBeforeSwitched; // Rx signal strength before we switched antenna.
struct timer_list SwAntennaDiversityTimer;
//by amy for antenna
//{by amy 080312
@@ -553,7 +553,7 @@ typedef struct r8180_priv
bool bDigMechanism; // TRUE if DIG is enabled, FALSE ow.
bool bRegHighPowerMechanism; // For High Power Mechanism. 061010, by rcnjko.
u32 FalseAlarmRegValue;
- u8 RegDigOfdmFaUpTh; // Upper threhold of OFDM false alarm, which is used in DIG.
+ u8 RegDigOfdmFaUpTh; // Upper threshold of OFDM false alarm, which is used in DIG.
u8 DIG_NumberFallbackVote;
u8 DIG_NumberUpgradeVote;
// For HW antenna diversity, added by Roger, 2008.01.30.
diff --git a/drivers/staging/rtl8187se/r8180_core.c b/drivers/staging/rtl8187se/r8180_core.c
index 4fe52f6b0034..fd22b75aea4f 100644
--- a/drivers/staging/rtl8187se/r8180_core.c
+++ b/drivers/staging/rtl8187se/r8180_core.c
@@ -1329,7 +1329,7 @@ u16 N_DBPSOfRate(u16 DataRate)
}
/*
- * For Netgear case, they want good-looking singal strength.
+ * For Netgear case, they want good-looking signal strength.
*/
long NetgearSignalStrengthTranslate(long LastSS, long CurrSS)
{
@@ -1380,7 +1380,7 @@ long TranslateToDbm8185(u8 SignalStrengthIndex)
/*
* Perform signal smoothing for dynamic mechanism.
- * This is different with PerformSignalSmoothing8185 in smoothing fomula.
+ * This is different with PerformSignalSmoothing8185 in smoothing formula.
* No dramatic adjustion is apply because dynamic mechanism need some degree
* of correctness. Ported from 8187B.
*/
@@ -1535,7 +1535,7 @@ void rtl8180_rx(struct net_device *dev)
/* HW is probably passing several buggy frames
* without FD or LD flag set.
* Throw this garbage away to prevent skb
- * memory exausting
+ * memory exhausting
*/
if (!priv->rx_skb_complete)
dev_kfree_skb_any(priv->rx_skb);
@@ -1648,14 +1648,14 @@ void rtl8180_rx(struct net_device *dev)
priv->Stats_SignalQuality = (long)(priv->Stats_SignalQuality * 5 + (long)priv->SignalQuality + 5) / 6;
priv->Stats_RecvSignalPower = (long)(priv->Stats_RecvSignalPower * 5 + priv->RecvSignalPower - 1) / 6;
- /* Figure out which antenna that received the lasted packet. */
+ /* Figure out which antenna that received the last packet. */
priv->LastRxPktAntenna = Antenna ? 1 : 0; /* 0: aux, 1: main. */
SwAntennaDiversityRxOk8185(dev, priv->SignalStrength);
}
if (first) {
if (!priv->rx_skb_complete) {
- /* seems that HW sometimes fails to reiceve and
+ /* seems that HW sometimes fails to receive and
doesn't provide the last descriptor */
dev_kfree_skb_any(priv->rx_skb);
priv->stats.rxnolast++;
@@ -1672,7 +1672,7 @@ void rtl8180_rx(struct net_device *dev)
priv->rx_skb_complete = 0;
priv->rx_skb->dev = dev;
} else {
- /* if we are here we should have already RXed
+ /* if we are here we should have already RXed
* the first frame.
* If we get here and the skb is not allocated then
* we have just throw out garbage (skb not allocated)
@@ -1821,15 +1821,15 @@ rate) {
/*
* This is a rough attempt to TX a frame
* This is called by the ieee 80211 stack to TX management frames.
- * If the ring is full packet are dropped (for data frame the queue
+ * If the ring is full packets are dropped (for data frame the queue
* is stopped before this can happen). For this reason it is better
* if the descriptors are larger than the largest management frame
- * we intend to TX: i'm unsure what the HW does if it will not found
+ * we intend to TX: i'm unsure what the HW does if it will not find
* the last fragment of a frame because it has been dropped...
* Since queues for Management and Data frames are different we
* might use a different lock than tx_lock (for example mgmt_tx_lock)
*/
-/* these function may loops if invoked with 0 descriptors or 0 len buffer */
+/* these function may loop if invoked with 0 descriptors or 0 len buffer */
int rtl8180_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
{
struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
@@ -2003,8 +2003,7 @@ short rtl8180_tx(struct net_device *dev, u8* txbuf, int len, int priority,
}
memcpy(&dest, frag_hdr->addr1, ETH_ALEN);
- if (is_multicast_ether_addr(dest) ||
- is_broadcast_ether_addr(dest)) {
+ if (is_multicast_ether_addr(dest)) {
Duration = 0;
RtsDur = 0;
bRTSEnable = 0;
@@ -2378,7 +2377,7 @@ void rtl8180_wmm_param_update(struct work_struct *work)
u8 u1bAIFS;
u32 u4bAcParam;
pAcParam = (PAC_PARAM)(&AcParam);
- /* Retrive paramters to udpate. */
+ /* Retrieve paramters to update. */
u1bAIFS = pAcParam->f.AciAifsn.f.AIFSN * (((mode&IEEE_G) == IEEE_G) ? 9 : 20) + aSifsTime;
u4bAcParam = ((((u32)(pAcParam->f.TXOPLimit))<<AC_PARAM_TXOP_LIMIT_OFFSET)|
(((u32)(pAcParam->f.Ecw.f.ECWmax))<<AC_PARAM_ECW_MAX_OFFSET)|
@@ -2414,7 +2413,7 @@ void rtl8180_wmm_param_update(struct work_struct *work)
u8 u1bAIFS;
u32 u4bAcParam;
- /* Retrive paramters to udpate. */
+ /* Retrieve paramters to update. */
eACI = pAcParam->f.AciAifsn.f.ACI;
/* Mode G/A: slotTimeTimer = 9; Mode B: 20 */
u1bAIFS = pAcParam->f.AciAifsn.f.AIFSN * (((mode&IEEE_G) == IEEE_G) ? 9 : 20) + aSifsTime;
@@ -2700,7 +2699,7 @@ short rtl8180_init(struct net_device *dev)
priv->bTxPowerTrack = false;
priv->ThermalMeter = 0;
priv->FalseAlarmRegValue = 0;
- priv->RegDigOfdmFaUpTh = 0xc; /* Upper threhold of OFDM false alarm, which is used in DIG. */
+ priv->RegDigOfdmFaUpTh = 0xc; /* Upper threshold of OFDM false alarm, which is used in DIG. */
priv->DIG_NumberFallbackVote = 0;
priv->DIG_NumberUpgradeVote = 0;
priv->LastSignalStrengthInPercent = 0;
@@ -2896,7 +2895,7 @@ short rtl8180_init(struct net_device *dev)
priv->chtxpwr_ofdm[i+1] = (word & 0xff00) >> 8;
}
- /* 3Read crystal calibtration and thermal meter indication on 87SE. */
+ /* 3Read crystal calibration and thermal meter indication on 87SE. */
eeprom_93cx6_read(&eeprom, EEPROM_RSV>>1, &tmpu16);
/* Crystal calibration for Xin and Xout resp. */
@@ -3140,7 +3139,7 @@ void rtl8180_adapter_start(struct net_device *dev)
/*
* The following is very strange. seems to be that 1 means test mode,
- * but we need to acknolwledges the nic when a packet is ready
+ * but we need to acknowledges the nic when a packet is ready
* although we set it to 0
*/
@@ -3971,7 +3970,7 @@ irqreturn_t rtl8180_interrupt(int irq, void *netdev, struct pt_regs *regs)
}
if (inta == 0xffff) {
- /* HW disappared */
+ /* HW disappeared */
spin_unlock_irqrestore(&priv->irq_th_lock, flags);
return IRQ_HANDLED;
}
diff --git a/drivers/staging/rtl8187se/r8180_dm.c b/drivers/staging/rtl8187se/r8180_dm.c
index 4d7a5951486e..b8f2ba010a04 100644
--- a/drivers/staging/rtl8187se/r8180_dm.c
+++ b/drivers/staging/rtl8187se/r8180_dm.c
@@ -2,7 +2,7 @@
#include "r8180_hw.h"
#include "r8180_93cx6.h"
- /* Return TRUE if we shall perform High Power Mecahnism, FALSE otherwise. */
+ /* Return TRUE if we shall perform High Power Mechanism, FALSE otherwise. */
#define RATE_ADAPTIVE_TIMER_PERIOD 300
bool CheckHighPower(struct net_device *dev)
@@ -105,7 +105,7 @@ void rtl8180_tx_pw_wq(struct work_struct *work)
/*
- * Return TRUE if we shall perform DIG Mecahnism, FALSE otherwise.
+ * Return TRUE if we shall perform DIG Mechanism, FALSE otherwise.
*/
bool CheckDig(struct net_device *dev)
{
@@ -507,7 +507,7 @@ void StaRateAdaptive87SE(struct net_device *dev)
* and retry rate.
* (3) Remove all Initial Gain Updates over OFDM rate. To avoid the complicated
* situation, Initial Gain Update is upon on DIG mechanism except CCK rate.
- * (4) Add the mehanism of trying to upgrade tx rate.
+ * (4) Add the mechanism of trying to upgrade tx rate.
* (5) Record the information of upping tx rate to avoid trying upping tx rate constantly.
*
*/
@@ -528,7 +528,7 @@ void StaRateAdaptive87SE(struct net_device *dev)
if (priv->bTryuping == true) {
/* 2 For Test Upgrading mechanism
* Note:
- * Sometimes the throughput is upon on the capability bwtween the AP and NIC,
+ * Sometimes the throughput is upon on the capability between the AP and NIC,
* thus the low data rate does not improve the performance.
* We randomly upgrade the data rate and check if the retry rate is improved.
*/
@@ -704,7 +704,7 @@ void StaRateAdaptive87SE(struct net_device *dev)
/*
* The difference in throughput between 48Mbps and 36Mbps is 8M.
- * So, we must be carefully in this rate scale. Isaiah 2008-02-15.
+ * So, we must be careful in this rate scale. Isaiah 2008-02-15.
*/
if (((priv->CurrentOperaRate == 72) || (priv->CurrentOperaRate == 48) || (priv->CurrentOperaRate == 36)) &&
(priv->FailTxRateCount > 2))
@@ -1009,7 +1009,7 @@ void SwAntennaDiversity(struct net_device *dev)
if (priv->AdCheckPeriod > priv->AdMaxCheckPeriod)
priv->AdCheckPeriod = priv->AdMaxCheckPeriod;
- /* Wrong deceision => switch back. */
+ /* Wrong decision => switch back. */
SwitchAntenna(dev);
} else {
/* Rx Signal Strength is improved. */
@@ -1057,7 +1057,7 @@ void SwAntennaDiversity(struct net_device *dev)
}
/*
* <Roger_Notes> We evaluate Rx signal strength ONLY when default antenna
- * didn't changed by HW evaluation.
+ * didn't change by HW evaluation.
* 2008.02.27.
*
* [TRC Dell Lab] SignalStrength is inaccuracy. Isaiah 2008-03-05
@@ -1098,7 +1098,7 @@ void SwAntennaDiversity(struct net_device *dev)
priv->AdAuxAntennaRxOkCnt = 0;
}
- /* Return TRUE if we shall perform Tx Power Tracking Mecahnism, FALSE otherwise. */
+ /* Return TRUE if we shall perform Tx Power Tracking Mechanism, FALSE otherwise. */
bool CheckTxPwrTracking(struct net_device *dev)
{
struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
diff --git a/drivers/staging/rtl8187se/r8180_rtl8225z2.c b/drivers/staging/rtl8187se/r8180_rtl8225z2.c
index ee5b867fd0d4..d28c1d996084 100644
--- a/drivers/staging/rtl8187se/r8180_rtl8225z2.c
+++ b/drivers/staging/rtl8187se/r8180_rtl8225z2.c
@@ -190,7 +190,7 @@ static void rtl8225_SetTXPowerLevel(struct net_device *dev, short ch)
write_phy_cck(dev, 0x44 + i, power);
}
- /* FIXME Is this delay really needeed ? */
+ /* FIXME Is this delay really needed ? */
force_pci_posting(dev);
mdelay(1);
@@ -479,7 +479,7 @@ s8 DbmToTxPwrIdx(struct r8180_priv *priv, WIRELESS_MODE WirelessMode,
/*
* TRUE if we want to use a default implementation.
- * We shall set it to FALSE when we have exact translation formular
+ * We shall set it to FALSE when we have exact translation formula
* for target IC. 070622, by rcnjko.
*/
if (bUseDefault) {
diff --git a/drivers/staging/rtl8187se/r8180_wx.c b/drivers/staging/rtl8187se/r8180_wx.c
index 303ec691262a..52f63d75d248 100644
--- a/drivers/staging/rtl8187se/r8180_wx.c
+++ b/drivers/staging/rtl8187se/r8180_wx.c
@@ -13,7 +13,7 @@
Parts of this driver are based on the Intel Pro Wireless 2100 GPL driver.
- We want to tanks the Authors of those projects and the Ndiswrapper
+ We want to thanks the Authors of those projects and the Ndiswrapper
project Authors.
*/
@@ -615,10 +615,10 @@ static int r8180_wx_get_retry(struct net_device *dev,
return -EINVAL;
if (wrqu->retry.flags & IW_RETRY_MAX) {
- wrqu->retry.flags = IW_RETRY_LIMIT & IW_RETRY_MAX;
+ wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_MAX;
wrqu->retry.value = priv->retry_rts;
} else {
- wrqu->retry.flags = IW_RETRY_LIMIT & IW_RETRY_MIN;
+ wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_MIN;
wrqu->retry.value = priv->retry_data;
}
@@ -1181,7 +1181,7 @@ static iw_handler r8180_wx_handlers[] = {
r8180_wx_set_wap, /* SIOCSIWAP */
r8180_wx_get_wap, /* SIOCGIWAP */
r8180_wx_set_mlme, /* SIOCSIWMLME*/
- dummy, /* SIOCGIWAPLIST -- depricated */
+ dummy, /* SIOCGIWAPLIST -- deprecated */
r8180_wx_set_scan, /* SIOCSIWSCAN */
r8180_wx_get_scan, /* SIOCGIWSCAN */
r8180_wx_set_essid, /* SIOCSIWESSID */
@@ -1369,7 +1369,7 @@ static inline int is_same_network(struct ieee80211_network *src,
(dst->capability & WLAN_CAPABILITY_BSS)));
}
-/* WB modefied to show signal to GUI on 18-01-2008 */
+/* WB modified to show signal to GUI on 18-01-2008 */
static struct iw_statistics *r8180_get_wireless_stats(struct net_device *dev)
{
struct r8180_priv *priv = ieee80211_priv(dev);
diff --git a/drivers/staging/rtl8187se/r8180_wx.h b/drivers/staging/rtl8187se/r8180_wx.h
index 735d03dceed3..408191403112 100644
--- a/drivers/staging/rtl8187se/r8180_wx.h
+++ b/drivers/staging/rtl8187se/r8180_wx.h
@@ -7,7 +7,7 @@
Parts of this driver are based on the rtl8180 driver skeleton from Patric Schenke & Andres Salomon
Parts of this driver are based on the Intel Pro Wireless 2100 GPL driver
- We want to tanks the Authors of such projects and the Ndiswrapper project Authors.
+ We want to thanks the Authors of such projects and the Ndiswrapper project Authors.
*/
/* this file (will) contains wireless extension handlers*/
diff --git a/drivers/staging/rtl8187se/r8185b_init.c b/drivers/staging/rtl8187se/r8185b_init.c
index 4b0b830f9ab6..914495783c06 100644
--- a/drivers/staging/rtl8187se/r8185b_init.c
+++ b/drivers/staging/rtl8187se/r8185b_init.c
@@ -1,22 +1,22 @@
-/*++
-Copyright (c) Realtek Semiconductor Corp. All rights reserved.
-
-Module Name:
- r8185b_init.c
-
-Abstract:
- Hardware Initialization and Hardware IO for RTL8185B
-
-Major Change History:
- When Who What
- ---------- --------------- -------------------------------
- 2006-11-15 Xiong Created
-
-Notes:
- This file is ported from RTL8185B Windows driver.
-
-
---*/
+/*
+ * Copyright (c) Realtek Semiconductor Corp. All rights reserved.
+ *
+ * Module Name:
+ * r8185b_init.c
+ *
+ * Abstract:
+ * Hardware Initialization and Hardware IO for RTL8185B
+ *
+ * Major Change History:
+ * When Who What
+ * ---------- --------------- -------------------------------
+ * 2006-11-15 Xiong Created
+ *
+ * Notes:
+ * This file is ported from RTL8185B Windows driver.
+ *
+ *
+ */
/*--------------------------Include File------------------------------------*/
#include <linux/spinlock.h>
@@ -25,155 +25,134 @@ Notes:
#include "r8180_rtl8225.h" /* RTL8225 Radio frontend */
#include "r8180_93cx6.h" /* Card EEPROM */
#include "r8180_wx.h"
-
#include "ieee80211/dot11d.h"
-
-
/* #define CONFIG_RTL8180_IO_MAP */
-
#define TC_3W_POLL_MAX_TRY_CNT 5
+
static u8 MAC_REG_TABLE[][2] = {
- /*PAGA 0: */
- /* 0x34(BRSR), 0xBE(RATE_FALLBACK_CTL), 0x1E0(ARFR) would set in HwConfigureRTL8185() */
- /* 0x272(RFSW_CTRL), 0x1CE(AESMSK_QC) set in InitializeAdapter8185(). */
- /* 0x1F0~0x1F8 set in MacConfig_85BASIC() */
- {0x08, 0xae}, {0x0a, 0x72}, {0x5b, 0x42},
- {0x84, 0x88}, {0x85, 0x24}, {0x88, 0x54}, {0x8b, 0xb8}, {0x8c, 0x03},
- {0x8d, 0x40}, {0x8e, 0x00}, {0x8f, 0x00}, {0x5b, 0x18}, {0x91, 0x03},
- {0x94, 0x0F}, {0x95, 0x32},
- {0x96, 0x00}, {0x97, 0x07}, {0xb4, 0x22}, {0xdb, 0x00},
- {0xf0, 0x32}, {0xf1, 0x32}, {0xf2, 0x00}, {0xf3, 0x00}, {0xf4, 0x32},
- {0xf5, 0x43}, {0xf6, 0x00}, {0xf7, 0x00}, {0xf8, 0x46}, {0xf9, 0xa4},
- {0xfa, 0x00}, {0xfb, 0x00}, {0xfc, 0x96}, {0xfd, 0xa4}, {0xfe, 0x00},
- {0xff, 0x00},
-
- /*PAGE 1: */
- /* For Flextronics system Logo PCIHCT failure: */
- /* 0x1C4~0x1CD set no-zero value to avoid PCI configuration space 0x45[7]=1 */
- {0x5e, 0x01},
- {0x58, 0x00}, {0x59, 0x00}, {0x5a, 0x04}, {0x5b, 0x00}, {0x60, 0x24},
- {0x61, 0x97}, {0x62, 0xF0}, {0x63, 0x09}, {0x80, 0x0F}, {0x81, 0xFF},
- {0x82, 0xFF}, {0x83, 0x03},
- {0xC4, 0x22}, {0xC5, 0x22}, {0xC6, 0x22}, {0xC7, 0x22}, {0xC8, 0x22}, /* lzm add 080826 */
- {0xC9, 0x22}, {0xCA, 0x22}, {0xCB, 0x22}, {0xCC, 0x22}, {0xCD, 0x22},/* lzm add 080826 */
- {0xe2, 0x00},
-
-
- /* PAGE 2: */
- {0x5e, 0x02},
- {0x0c, 0x04}, {0x4c, 0x30}, {0x4d, 0x08}, {0x50, 0x05}, {0x51, 0xf5},
- {0x52, 0x04}, {0x53, 0xa0}, {0x54, 0xff}, {0x55, 0xff}, {0x56, 0xff},
- {0x57, 0xff}, {0x58, 0x08}, {0x59, 0x08}, {0x5a, 0x08}, {0x5b, 0x08},
- {0x60, 0x08}, {0x61, 0x08}, {0x62, 0x08}, {0x63, 0x08}, {0x64, 0x2f},
- {0x8c, 0x3f}, {0x8d, 0x3f}, {0x8e, 0x3f},
- {0x8f, 0x3f}, {0xc4, 0xff}, {0xc5, 0xff}, {0xc6, 0xff}, {0xc7, 0xff},
- {0xc8, 0x00}, {0xc9, 0x00}, {0xca, 0x80}, {0xcb, 0x00},
-
- /* PAGA 0: */
- {0x5e, 0x00}, {0x9f, 0x03}
- };
-
-
-static u8 ZEBRA_AGC[] = {
- 0,
- 0x7E, 0x7E, 0x7E, 0x7E, 0x7D, 0x7C, 0x7B, 0x7A, 0x79, 0x78, 0x77, 0x76, 0x75, 0x74, 0x73, 0x72,
- 0x71, 0x70, 0x6F, 0x6E, 0x6D, 0x6C, 0x6B, 0x6A, 0x69, 0x68, 0x67, 0x66, 0x65, 0x64, 0x63, 0x62,
- 0x48, 0x47, 0x46, 0x45, 0x44, 0x29, 0x28, 0x27, 0x26, 0x25, 0x24, 0x23, 0x22, 0x21, 0x08, 0x07,
- 0x06, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x15, 0x16,
- 0x17, 0x17, 0x18, 0x18, 0x19, 0x1a, 0x1a, 0x1b, 0x1b, 0x1c, 0x1c, 0x1d, 0x1d, 0x1d, 0x1e, 0x1e,
- 0x1f, 0x1f, 0x1f, 0x20, 0x20, 0x20, 0x20, 0x21, 0x21, 0x21, 0x22, 0x22, 0x22, 0x23, 0x23, 0x24,
- 0x24, 0x25, 0x25, 0x25, 0x26, 0x26, 0x27, 0x27, 0x2F, 0x2F, 0x2F, 0x2F, 0x2F, 0x2F, 0x2F, 0x2F
- };
-
-static u32 ZEBRA_RF_RX_GAIN_TABLE[] = {
- 0x0096, 0x0076, 0x0056, 0x0036, 0x0016, 0x01f6, 0x01d6, 0x01b6,
- 0x0196, 0x0176, 0x00F7, 0x00D7, 0x00B7, 0x0097, 0x0077, 0x0057,
- 0x0037, 0x00FB, 0x00DB, 0x00BB, 0x00FF, 0x00E3, 0x00C3, 0x00A3,
- 0x0083, 0x0063, 0x0043, 0x0023, 0x0003, 0x01E3, 0x01C3, 0x01A3,
- 0x0183, 0x0163, 0x0143, 0x0123, 0x0103
+ /*PAGA 0: */
+ /* 0x34(BRSR), 0xBE(RATE_FALLBACK_CTL), 0x1E0(ARFR) would set in HwConfigureRTL8185() */
+ /* 0x272(RFSW_CTRL), 0x1CE(AESMSK_QC) set in InitializeAdapter8185(). */
+ /* 0x1F0~0x1F8 set in MacConfig_85BASIC() */
+ {0x08, 0xae}, {0x0a, 0x72}, {0x5b, 0x42},
+ {0x84, 0x88}, {0x85, 0x24}, {0x88, 0x54}, {0x8b, 0xb8}, {0x8c, 0x03},
+ {0x8d, 0x40}, {0x8e, 0x00}, {0x8f, 0x00}, {0x5b, 0x18}, {0x91, 0x03},
+ {0x94, 0x0F}, {0x95, 0x32},
+ {0x96, 0x00}, {0x97, 0x07}, {0xb4, 0x22}, {0xdb, 0x00},
+ {0xf0, 0x32}, {0xf1, 0x32}, {0xf2, 0x00}, {0xf3, 0x00}, {0xf4, 0x32},
+ {0xf5, 0x43}, {0xf6, 0x00}, {0xf7, 0x00}, {0xf8, 0x46}, {0xf9, 0xa4},
+ {0xfa, 0x00}, {0xfb, 0x00}, {0xfc, 0x96}, {0xfd, 0xa4}, {0xfe, 0x00},
+ {0xff, 0x00},
+
+ /*PAGE 1: */
+ /* For Flextronics system Logo PCIHCT failure: */
+ /* 0x1C4~0x1CD set no-zero value to avoid PCI configuration space 0x45[7]=1 */
+ {0x5e, 0x01},
+ {0x58, 0x00}, {0x59, 0x00}, {0x5a, 0x04}, {0x5b, 0x00}, {0x60, 0x24},
+ {0x61, 0x97}, {0x62, 0xF0}, {0x63, 0x09}, {0x80, 0x0F}, {0x81, 0xFF},
+ {0x82, 0xFF}, {0x83, 0x03},
+ {0xC4, 0x22}, {0xC5, 0x22}, {0xC6, 0x22}, {0xC7, 0x22}, {0xC8, 0x22}, /* lzm add 080826 */
+ {0xC9, 0x22}, {0xCA, 0x22}, {0xCB, 0x22}, {0xCC, 0x22}, {0xCD, 0x22}, /* lzm add 080826 */
+ {0xe2, 0x00},
+
+
+ /* PAGE 2: */
+ {0x5e, 0x02},
+ {0x0c, 0x04}, {0x4c, 0x30}, {0x4d, 0x08}, {0x50, 0x05}, {0x51, 0xf5},
+ {0x52, 0x04}, {0x53, 0xa0}, {0x54, 0xff}, {0x55, 0xff}, {0x56, 0xff},
+ {0x57, 0xff}, {0x58, 0x08}, {0x59, 0x08}, {0x5a, 0x08}, {0x5b, 0x08},
+ {0x60, 0x08}, {0x61, 0x08}, {0x62, 0x08}, {0x63, 0x08}, {0x64, 0x2f},
+ {0x8c, 0x3f}, {0x8d, 0x3f}, {0x8e, 0x3f},
+ {0x8f, 0x3f}, {0xc4, 0xff}, {0xc5, 0xff}, {0xc6, 0xff}, {0xc7, 0xff},
+ {0xc8, 0x00}, {0xc9, 0x00}, {0xca, 0x80}, {0xcb, 0x00},
+
+ /* PAGA 0: */
+ {0x5e, 0x00}, {0x9f, 0x03}
+ };
+
+
+static u8 ZEBRA_AGC[] = {
+ 0,
+ 0x7E, 0x7E, 0x7E, 0x7E, 0x7D, 0x7C, 0x7B, 0x7A, 0x79, 0x78, 0x77, 0x76, 0x75, 0x74, 0x73, 0x72,
+ 0x71, 0x70, 0x6F, 0x6E, 0x6D, 0x6C, 0x6B, 0x6A, 0x69, 0x68, 0x67, 0x66, 0x65, 0x64, 0x63, 0x62,
+ 0x48, 0x47, 0x46, 0x45, 0x44, 0x29, 0x28, 0x27, 0x26, 0x25, 0x24, 0x23, 0x22, 0x21, 0x08, 0x07,
+ 0x06, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x15, 0x16,
+ 0x17, 0x17, 0x18, 0x18, 0x19, 0x1a, 0x1a, 0x1b, 0x1b, 0x1c, 0x1c, 0x1d, 0x1d, 0x1d, 0x1e, 0x1e,
+ 0x1f, 0x1f, 0x1f, 0x20, 0x20, 0x20, 0x20, 0x21, 0x21, 0x21, 0x22, 0x22, 0x22, 0x23, 0x23, 0x24,
+ 0x24, 0x25, 0x25, 0x25, 0x26, 0x26, 0x27, 0x27, 0x2F, 0x2F, 0x2F, 0x2F, 0x2F, 0x2F, 0x2F, 0x2F
+ };
+
+static u32 ZEBRA_RF_RX_GAIN_TABLE[] = {
+ 0x0096, 0x0076, 0x0056, 0x0036, 0x0016, 0x01f6, 0x01d6, 0x01b6,
+ 0x0196, 0x0176, 0x00F7, 0x00D7, 0x00B7, 0x0097, 0x0077, 0x0057,
+ 0x0037, 0x00FB, 0x00DB, 0x00BB, 0x00FF, 0x00E3, 0x00C3, 0x00A3,
+ 0x0083, 0x0063, 0x0043, 0x0023, 0x0003, 0x01E3, 0x01C3, 0x01A3,
+ 0x0183, 0x0163, 0x0143, 0x0123, 0x0103
};
-static u8 OFDM_CONFIG[] = {
- /* OFDM reg0x06[7:0]=0xFF: Enable power saving mode in RX */
- /* OFDM reg0x3C[4]=1'b1: Enable RX power saving mode */
- /* ofdm 0x3a = 0x7b ,(original : 0xfb) For ECS shielding room TP test */
-
- /* 0x00 */
- 0x10, 0x0F, 0x0A, 0x0C, 0x14, 0xFA, 0xFF, 0x50,
- 0x00, 0x50, 0x00, 0x00, 0x00, 0x5C, 0x00, 0x00,
- /* 0x10 */
- 0x40, 0x00, 0x40, 0x00, 0x00, 0x00, 0xA8, 0x26,
- 0x32, 0x33, 0x06, 0xA5, 0x6F, 0x55, 0xC8, 0xBB,
- /* 0x20 */
- 0x0A, 0xE1, 0x2C, 0x4A, 0x86, 0x83, 0x34, 0x00,
- 0x4F, 0x24, 0x6F, 0xC2, 0x03, 0x40, 0x80, 0x00,
- /* 0x30 */
- 0xC0, 0xC1, 0x58, 0xF1, 0x00, 0xC4, 0x90, 0x3e,
- 0xD8, 0x3C, 0x7B, 0x10, 0x10
- };
-
-/* ---------------------------------------------------------------
- * Hardware IO
- * the code is ported from Windows source code
- ----------------------------------------------------------------*/
-
-void
-PlatformIOWrite1Byte(
- struct net_device *dev,
- u32 offset,
- u8 data
- )
+static u8 OFDM_CONFIG[] = {
+ /* OFDM reg0x06[7:0]=0xFF: Enable power saving mode in RX */
+ /* OFDM reg0x3C[4]=1'b1: Enable RX power saving mode */
+ /* ofdm 0x3a = 0x7b ,(original : 0xfb) For ECS shielding room TP test */
+ /* 0x00 */
+ 0x10, 0x0F, 0x0A, 0x0C, 0x14, 0xFA, 0xFF, 0x50,
+ 0x00, 0x50, 0x00, 0x00, 0x00, 0x5C, 0x00, 0x00,
+ /* 0x10 */
+ 0x40, 0x00, 0x40, 0x00, 0x00, 0x00, 0xA8, 0x26,
+ 0x32, 0x33, 0x06, 0xA5, 0x6F, 0x55, 0xC8, 0xBB,
+ /* 0x20 */
+ 0x0A, 0xE1, 0x2C, 0x4A, 0x86, 0x83, 0x34, 0x00,
+ 0x4F, 0x24, 0x6F, 0xC2, 0x03, 0x40, 0x80, 0x00,
+ /* 0x30 */
+ 0xC0, 0xC1, 0x58, 0xF1, 0x00, 0xC4, 0x90, 0x3e,
+ 0xD8, 0x3C, 0x7B, 0x10, 0x10
+ };
+
+ /*---------------------------------------------------------------
+ * Hardware IO
+ * the code is ported from Windows source code
+ *---------------------------------------------------------------
+ */
+
+void PlatformIOWrite1Byte(struct net_device *dev, u32 offset, u8 data)
{
write_nic_byte(dev, offset, data);
- read_nic_byte(dev, offset); /* To make sure write operation is completed, 2005.11.09, by rcnjko. */
-
+ read_nic_byte(dev, offset); /* To make sure write operation is completed, 2005.11.09, by rcnjko. */
}
-void
-PlatformIOWrite2Byte(
- struct net_device *dev,
- u32 offset,
- u16 data
- )
+void PlatformIOWrite2Byte(struct net_device *dev, u32 offset, u16 data)
{
write_nic_word(dev, offset, data);
read_nic_word(dev, offset); /* To make sure write operation is completed, 2005.11.09, by rcnjko. */
-
-
}
+
u8 PlatformIORead1Byte(struct net_device *dev, u32 offset);
-void
-PlatformIOWrite4Byte(
- struct net_device *dev,
- u32 offset,
- u32 data
- )
+void PlatformIOWrite4Byte(struct net_device *dev, u32 offset, u32 data)
{
-/* {by amy 080312 */
-if (offset == PhyAddr) {
-/* For Base Band configuration. */
+ if (offset == PhyAddr) {
+ /* For Base Band configuration. */
unsigned char cmdByte;
unsigned long dataBytes;
unsigned char idx;
- u8 u1bTmp;
+ u8 u1bTmp;
cmdByte = (u8)(data & 0x000000ff);
dataBytes = data>>8;
/*
- 071010, rcnjko:
- The critical section is only BB read/write race condition.
- Assumption:
- 1. We assume NO one will access BB at DIRQL, otherwise, system will crash for
- acquiring the spinlock in such context.
- 2. PlatformIOWrite4Byte() MUST NOT be recursive.
- */
-/* NdisAcquireSpinLock( &(pDevice->IoSpinLock) ); */
-
- for (idx = 0; idx < 30; idx++) {
- /* Make sure command bit is clear before access it. */
+ * 071010, rcnjko:
+ * The critical section is only BB read/write race condition.
+ * Assumption:
+ * 1. We assume NO one will access BB at DIRQL, otherwise, system will crash for
+ * acquiring the spinlock in such context.
+ * 2. PlatformIOWrite4Byte() MUST NOT be recursive.
+ */
+ /* NdisAcquireSpinLock( &(pDevice->IoSpinLock) ); */
+
+ for (idx = 0; idx < 30; idx++) {
+ /* Make sure command bit is clear before access it. */
u1bTmp = PlatformIORead1Byte(dev, PhyAddr);
if ((u1bTmp & BIT7) == 0)
break;
@@ -186,20 +165,14 @@ if (offset == PhyAddr) {
write_nic_byte(dev, offset, cmdByte);
-/* NdisReleaseSpinLock( &(pDevice->IoSpinLock) ); */
- }
-/* by amy 080312} */
- else {
+ /* NdisReleaseSpinLock( &(pDevice->IoSpinLock) ); */
+ } else {
write_nic_dword(dev, offset, data);
read_nic_dword(dev, offset); /* To make sure write operation is completed, 2005.11.09, by rcnjko. */
}
}
-u8
-PlatformIORead1Byte(
- struct net_device *dev,
- u32 offset
- )
+u8 PlatformIORead1Byte(struct net_device *dev, u32 offset)
{
u8 data = 0;
@@ -209,11 +182,7 @@ PlatformIORead1Byte(
return data;
}
-u16
-PlatformIORead2Byte(
- struct net_device *dev,
- u32 offset
- )
+u16 PlatformIORead2Byte(struct net_device *dev, u32 offset)
{
u16 data = 0;
@@ -223,11 +192,7 @@ PlatformIORead2Byte(
return data;
}
-u32
-PlatformIORead4Byte(
- struct net_device *dev,
- u32 offset
- )
+u32 PlatformIORead4Byte(struct net_device *dev, u32 offset)
{
u32 data = 0;
@@ -242,22 +207,19 @@ void SetOutputEnableOfRfPins(struct net_device *dev)
write_nic_word(dev, RFPinsEnable, 0x1bff);
}
-static int
-HwHSSIThreeWire(
- struct net_device *dev,
- u8 *pDataBuf,
- u8 nDataBufBitCnt,
- int bSI,
- int bWrite
- )
+static int HwHSSIThreeWire(struct net_device *dev,
+ u8 *pDataBuf,
+ u8 nDataBufBitCnt,
+ int bSI,
+ int bWrite)
{
int bResult = 1;
u8 TryCnt;
u8 u1bTmp;
- do {
+ do {
/* Check if WE and RE are cleared. */
- for (TryCnt = 0; TryCnt < TC_3W_POLL_MAX_TRY_CNT; TryCnt++) {
+ for (TryCnt = 0; TryCnt < TC_3W_POLL_MAX_TRY_CNT; TryCnt++) {
u1bTmp = read_nic_byte(dev, SW_3W_CMD1);
if ((u1bTmp & (SW_3W_CMD1_RE|SW_3W_CMD1_WE)) == 0)
break;
@@ -275,15 +237,15 @@ HwHSSIThreeWire(
u1bTmp = read_nic_byte(dev, RF_SW_CONFIG);
if (bSI)
- u1bTmp |= RF_SW_CFG_SI; /* reg08[1]=1 Serial Interface(SI) */
+ u1bTmp |= RF_SW_CFG_SI; /* reg08[1]=1 Serial Interface(SI) */
else
- u1bTmp &= ~RF_SW_CFG_SI; /* reg08[1]=0 Parallel Interface(PI) */
+ u1bTmp &= ~RF_SW_CFG_SI; /* reg08[1]=0 Parallel Interface(PI) */
write_nic_byte(dev, RF_SW_CONFIG, u1bTmp);
- if (bSI) {
+ if (bSI) {
/* jong: HW SI read must set reg84[3]=0. */
u1bTmp = read_nic_byte(dev, RFPinsSelect);
u1bTmp &= ~BIT3;
@@ -291,14 +253,14 @@ HwHSSIThreeWire(
}
/* Fill up data buffer for write operation. */
- if (bWrite) {
- if (nDataBufBitCnt == 16) {
+ if (bWrite) {
+ if (nDataBufBitCnt == 16) {
write_nic_word(dev, SW_3W_DB0, *((u16 *)pDataBuf));
- } else if (nDataBufBitCnt == 64) {
+ } else if (nDataBufBitCnt == 64) {
/* RTL8187S shouldn't enter this case */
write_nic_dword(dev, SW_3W_DB0, *((u32 *)pDataBuf));
write_nic_dword(dev, SW_3W_DB1, *((u32 *)(pDataBuf + 4)));
- } else {
+ } else {
int idx;
int ByteCnt = nDataBufBitCnt / 8;
/* printk("%d\n",nDataBufBitCnt); */
@@ -324,11 +286,11 @@ HwHSSIThreeWire(
write_nic_byte(dev, (SW_3W_DB0+idx), *(pDataBuf+idx));
}
- } else { /* read */
- if (bSI) {
- /* SI - reg274[3:0] : RF register's Address */
+ } else { /* read */
+ if (bSI) {
+ /* SI - reg274[3:0] : RF register's Address */
write_nic_word(dev, SW_3W_DB0, *((u16 *)pDataBuf));
- } else {
+ } else {
/* PI - reg274[15:12] : RF register's Address */
write_nic_word(dev, SW_3W_DB0, (*((u16 *)pDataBuf)) << 12);
}
@@ -343,7 +305,7 @@ HwHSSIThreeWire(
/* Check if DONE is set. */
- for (TryCnt = 0; TryCnt < TC_3W_POLL_MAX_TRY_CNT; TryCnt++) {
+ for (TryCnt = 0; TryCnt < TC_3W_POLL_MAX_TRY_CNT; TryCnt++) {
u1bTmp = read_nic_byte(dev, SW_3W_CMD1);
if ((u1bTmp & SW_3W_CMD1_DONE) != 0)
break;
@@ -353,12 +315,12 @@ HwHSSIThreeWire(
write_nic_byte(dev, SW_3W_CMD1, 0);
- /* Read back data for read operation. */
- if (bWrite == 0) {
- if (bSI) {
+ /* Read back data for read operation. */
+ if (bWrite == 0) {
+ if (bSI) {
/* Serial Interface : reg363_362[11:0] */
*((u16 *)pDataBuf) = read_nic_word(dev, SI_DATA_READ) ;
- } else {
+ } else {
/* Parallel Interface : reg361_360[11:0] */
*((u16 *)pDataBuf) = read_nic_word(dev, PI_DATA_READ);
}
@@ -366,13 +328,12 @@ HwHSSIThreeWire(
*((u16 *)pDataBuf) &= 0x0FFF;
}
- } while (0);
+ } while (0);
return bResult;
}
-void
-RF_WriteReg(struct net_device *dev, u8 offset, u32 data)
+void RF_WriteReg(struct net_device *dev, u8 offset, u32 data)
{
u32 data2Write;
u8 len;
@@ -400,11 +361,7 @@ u32 RF_ReadReg(struct net_device *dev, u8 offset)
/* by Owen on 04/07/14 for writing BB register successfully */
-void
-WriteBBPortUchar(
- struct net_device *dev,
- u32 Data
- )
+void WriteBBPortUchar(struct net_device *dev, u32 Data)
{
/* u8 TimeoutCounter; */
u8 RegisterContent;
@@ -421,11 +378,7 @@ WriteBBPortUchar(
}
}
-u8
-ReadBBPortUchar(
- struct net_device *dev,
- u32 addr
- )
+u8 ReadBBPortUchar(struct net_device *dev, u32 addr)
{
/*u8 TimeoutCounter; */
u8 RegisterContent;
@@ -435,66 +388,62 @@ ReadBBPortUchar(
return RegisterContent;
}
-/* {by amy 080312 */
/*
- Description:
- Perform Antenna settings with antenna diversity on 87SE.
- Created by Roger, 2008.01.25.
-*/
-bool
-SetAntennaConfig87SE(
- struct net_device *dev,
- u8 DefaultAnt, /* 0: Main, 1: Aux. */
- bool bAntDiversity /* 1:Enable, 0: Disable. */
-)
+ * Description:
+ * Perform Antenna settings with antenna diversity on 87SE.
+ * Created by Roger, 2008.01.25.
+ */
+bool SetAntennaConfig87SE(struct net_device *dev,
+ u8 DefaultAnt, /* 0: Main, 1: Aux. */
+ bool bAntDiversity) /* 1:Enable, 0: Disable. */
{
struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
bool bAntennaSwitched = true;
/* printk("SetAntennaConfig87SE(): DefaultAnt(%d), bAntDiversity(%d)\n", DefaultAnt, bAntDiversity); */
- /* Threshold for antenna diversity. */
+ /* Threshold for antenna diversity. */
write_phy_cck(dev, 0x0c, 0x09); /* Reg0c : 09 */
- if (bAntDiversity) { /* Enable Antenna Diversity. */
- if (DefaultAnt == 1) { /* aux antenna */
+ if (bAntDiversity) { /* Enable Antenna Diversity. */
+ if (DefaultAnt == 1) { /* aux antenna */
- /* Mac register, aux antenna */
+ /* Mac register, aux antenna */
write_nic_byte(dev, ANTSEL, 0x00);
- /* Config CCK RX antenna. */
+ /* Config CCK RX antenna. */
write_phy_cck(dev, 0x11, 0xbb); /* Reg11 : bb */
write_phy_cck(dev, 0x01, 0xc7); /* Reg01 : c7 */
- /* Config OFDM RX antenna. */
- write_phy_ofdm(dev, 0x0D, 0x54); /* Reg0d : 54 */
- write_phy_ofdm(dev, 0x18, 0xb2); /* Reg18 : b2 */
- } else { /* use main antenna */
- /* Mac register, main antenna */
+ /* Config OFDM RX antenna. */
+ write_phy_ofdm(dev, 0x0D, 0x54); /* Reg0d : 54 */
+ write_phy_ofdm(dev, 0x18, 0xb2); /* Reg18 : b2 */
+ } else { /* use main antenna */
+ /* Mac register, main antenna */
write_nic_byte(dev, ANTSEL, 0x03);
- /* base band */
- /* Config CCK RX antenna. */
- write_phy_cck(dev, 0x11, 0x9b); /* Reg11 : 9b */
- write_phy_cck(dev, 0x01, 0xc7); /* Reg01 : c7 */
+ /* base band */
+ /* Config CCK RX antenna. */
+ write_phy_cck(dev, 0x11, 0x9b); /* Reg11 : 9b */
+ write_phy_cck(dev, 0x01, 0xc7); /* Reg01 : c7 */
/* Config OFDM RX antenna. */
write_phy_ofdm(dev, 0x0d, 0x5c); /* Reg0d : 5c */
write_phy_ofdm(dev, 0x18, 0xb2); /* Reg18 : b2 */
}
- } else {
+ } else {
/* Disable Antenna Diversity. */
- if (DefaultAnt == 1) { /* aux Antenna */
+ if (DefaultAnt == 1) { /* aux Antenna */
/* Mac register, aux antenna */
write_nic_byte(dev, ANTSEL, 0x00);
/* Config CCK RX antenna. */
- write_phy_cck(dev, 0x11, 0xbb); /* Reg11 : bb */
- write_phy_cck(dev, 0x01, 0x47); /* Reg01 : 47 */
+ write_phy_cck(dev, 0x11, 0xbb); /* Reg11 : bb */
+ write_phy_cck(dev, 0x01, 0x47); /* Reg01 : 47 */
/* Config OFDM RX antenna. */
- write_phy_ofdm(dev, 0x0D, 0x54); /* Reg0d : 54 */
- write_phy_ofdm(dev, 0x18, 0x32); /* Reg18 : 32 */
- } else { /* main Antenna */
+ write_phy_ofdm(dev, 0x0D, 0x54); /* Reg0d : 54 */
+ write_phy_ofdm(dev, 0x18, 0x32); /* Reg18 : 32 */
+ } else { /* main Antenna */
/* Mac register, main antenna */
write_nic_byte(dev, ANTSEL, 0x03);
@@ -502,25 +451,22 @@ SetAntennaConfig87SE(
write_phy_cck(dev, 0x11, 0x9b); /* Reg11 : 9b */
write_phy_cck(dev, 0x01, 0x47); /* Reg01 : 47 */
- /* Config OFDM RX antenna. */
- write_phy_ofdm(dev, 0x0D, 0x5c); /* Reg0d : 5c */
- write_phy_ofdm(dev, 0x18, 0x32); /*Reg18 : 32 */
+ /* Config OFDM RX antenna. */
+ write_phy_ofdm(dev, 0x0D, 0x5c); /* Reg0d : 5c */
+ write_phy_ofdm(dev, 0x18, 0x32); /*Reg18 : 32 */
}
}
priv->CurrAntennaIndex = DefaultAnt; /* Update default settings. */
return bAntennaSwitched;
}
-/* by amy 080312 */
/*
----------------------------------------------------------------
- * Hardware Initialization.
- * the code is ported from Windows source code
-----------------------------------------------------------------*/
-
-void
-ZEBRA_Config_85BASIC_HardCode(
- struct net_device *dev
- )
+ *--------------------------------------------------------------
+ * Hardware Initialization.
+ * the code is ported from Windows source code
+ *--------------------------------------------------------------
+ */
+
+void ZEBRA_Config_85BASIC_HardCode(struct net_device *dev)
{
struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
@@ -532,163 +478,151 @@ ZEBRA_Config_85BASIC_HardCode(
/*
-=============================================================================
- 87S_PCIE :: RADIOCFG.TXT
-=============================================================================
-*/
+ *===========================================================================
+ * 87S_PCIE :: RADIOCFG.TXT
+ *===========================================================================
+ */
/* Page1 : reg16-reg30 */
- RF_WriteReg(dev, 0x00, 0x013f); mdelay(1); /* switch to page1 */
- u4bRF23 = RF_ReadReg(dev, 0x08); mdelay(1);
- u4bRF24 = RF_ReadReg(dev, 0x09); mdelay(1);
+ RF_WriteReg(dev, 0x00, 0x013f); mdelay(1); /* switch to page1 */
+ u4bRF23 = RF_ReadReg(dev, 0x08); mdelay(1);
+ u4bRF24 = RF_ReadReg(dev, 0x09); mdelay(1);
if (u4bRF23 == 0x818 && u4bRF24 == 0x70C) {
d_cut = 1;
printk(KERN_INFO "rtl8187se: card type changed from C- to D-cut\n");
}
- /* Page0 : reg0-reg15 */
-
- RF_WriteReg(dev, 0x00, 0x009f); mdelay(1);/* 1 */
-
- RF_WriteReg(dev, 0x01, 0x06e0); mdelay(1);
-
- RF_WriteReg(dev, 0x02, 0x004d); mdelay(1);/* 2 */
-
- RF_WriteReg(dev, 0x03, 0x07f1); mdelay(1);/* 3 */
-
- RF_WriteReg(dev, 0x04, 0x0975); mdelay(1);
- RF_WriteReg(dev, 0x05, 0x0c72); mdelay(1);
- RF_WriteReg(dev, 0x06, 0x0ae6); mdelay(1);
- RF_WriteReg(dev, 0x07, 0x00ca); mdelay(1);
- RF_WriteReg(dev, 0x08, 0x0e1c); mdelay(1);
- RF_WriteReg(dev, 0x09, 0x02f0); mdelay(1);
- RF_WriteReg(dev, 0x0a, 0x09d0); mdelay(1);
- RF_WriteReg(dev, 0x0b, 0x01ba); mdelay(1);
- RF_WriteReg(dev, 0x0c, 0x0640); mdelay(1);
- RF_WriteReg(dev, 0x0d, 0x08df); mdelay(1);
- RF_WriteReg(dev, 0x0e, 0x0020); mdelay(1);
- RF_WriteReg(dev, 0x0f, 0x0990); mdelay(1);
-
+ /* Page0 : reg0-reg15 */
+
+ RF_WriteReg(dev, 0x00, 0x009f); mdelay(1);/* 1 */
+ RF_WriteReg(dev, 0x01, 0x06e0); mdelay(1);
+ RF_WriteReg(dev, 0x02, 0x004d); mdelay(1);/* 2 */
+ RF_WriteReg(dev, 0x03, 0x07f1); mdelay(1);/* 3 */
+ RF_WriteReg(dev, 0x04, 0x0975); mdelay(1);
+ RF_WriteReg(dev, 0x05, 0x0c72); mdelay(1);
+ RF_WriteReg(dev, 0x06, 0x0ae6); mdelay(1);
+ RF_WriteReg(dev, 0x07, 0x00ca); mdelay(1);
+ RF_WriteReg(dev, 0x08, 0x0e1c); mdelay(1);
+ RF_WriteReg(dev, 0x09, 0x02f0); mdelay(1);
+ RF_WriteReg(dev, 0x0a, 0x09d0); mdelay(1);
+ RF_WriteReg(dev, 0x0b, 0x01ba); mdelay(1);
+ RF_WriteReg(dev, 0x0c, 0x0640); mdelay(1);
+ RF_WriteReg(dev, 0x0d, 0x08df); mdelay(1);
+ RF_WriteReg(dev, 0x0e, 0x0020); mdelay(1);
+ RF_WriteReg(dev, 0x0f, 0x0990); mdelay(1);
/* Page1 : reg16-reg30 */
- RF_WriteReg(dev, 0x00, 0x013f); mdelay(1);
-
- RF_WriteReg(dev, 0x03, 0x0806); mdelay(1);
-
- RF_WriteReg(dev, 0x04, 0x03a7); mdelay(1);
- RF_WriteReg(dev, 0x05, 0x059b); mdelay(1);
- RF_WriteReg(dev, 0x06, 0x0081); mdelay(1);
-
-
- RF_WriteReg(dev, 0x07, 0x01A0); mdelay(1);
+ RF_WriteReg(dev, 0x00, 0x013f); mdelay(1);
+ RF_WriteReg(dev, 0x03, 0x0806); mdelay(1);
+ RF_WriteReg(dev, 0x04, 0x03a7); mdelay(1);
+ RF_WriteReg(dev, 0x05, 0x059b); mdelay(1);
+ RF_WriteReg(dev, 0x06, 0x0081); mdelay(1);
+ RF_WriteReg(dev, 0x07, 0x01A0); mdelay(1);
/* Don't write RF23/RF24 to make a difference between 87S C cut and D cut. asked by SD3 stevenl. */
- RF_WriteReg(dev, 0x0a, 0x0001); mdelay(1);
- RF_WriteReg(dev, 0x0b, 0x0418); mdelay(1);
+ RF_WriteReg(dev, 0x0a, 0x0001); mdelay(1);
+ RF_WriteReg(dev, 0x0b, 0x0418); mdelay(1);
if (d_cut) {
- RF_WriteReg(dev, 0x0c, 0x0fbe); mdelay(1);
- RF_WriteReg(dev, 0x0d, 0x0008); mdelay(1);
- RF_WriteReg(dev, 0x0e, 0x0807); mdelay(1); /* RX LO buffer */
- } else {
- RF_WriteReg(dev, 0x0c, 0x0fbe); mdelay(1);
- RF_WriteReg(dev, 0x0d, 0x0008); mdelay(1);
- RF_WriteReg(dev, 0x0e, 0x0806); mdelay(1); /* RX LO buffer */
+ RF_WriteReg(dev, 0x0c, 0x0fbe); mdelay(1);
+ RF_WriteReg(dev, 0x0d, 0x0008); mdelay(1);
+ RF_WriteReg(dev, 0x0e, 0x0807); mdelay(1); /* RX LO buffer */
+ } else {
+ RF_WriteReg(dev, 0x0c, 0x0fbe); mdelay(1);
+ RF_WriteReg(dev, 0x0d, 0x0008); mdelay(1);
+ RF_WriteReg(dev, 0x0e, 0x0806); mdelay(1); /* RX LO buffer */
}
- RF_WriteReg(dev, 0x0f, 0x0acc); mdelay(1);
-
- RF_WriteReg(dev, 0x00, 0x01d7); mdelay(1); /* 6 */
+ RF_WriteReg(dev, 0x0f, 0x0acc); mdelay(1);
+ RF_WriteReg(dev, 0x00, 0x01d7); mdelay(1); /* 6 */
+ RF_WriteReg(dev, 0x03, 0x0e00); mdelay(1);
+ RF_WriteReg(dev, 0x04, 0x0e50); mdelay(1);
- RF_WriteReg(dev, 0x03, 0x0e00); mdelay(1);
- RF_WriteReg(dev, 0x04, 0x0e50); mdelay(1);
- for (i = 0; i <= 36; i++) {
- RF_WriteReg(dev, 0x01, i); mdelay(1);
+ for (i = 0; i <= 36; i++) {
+ RF_WriteReg(dev, 0x01, i); mdelay(1);
RF_WriteReg(dev, 0x02, ZEBRA_RF_RX_GAIN_TABLE[i]); mdelay(1);
}
- RF_WriteReg(dev, 0x05, 0x0203); mdelay(1); /* 203, 343 */
- RF_WriteReg(dev, 0x06, 0x0200); mdelay(1); /* 400 */
+ RF_WriteReg(dev, 0x05, 0x0203); mdelay(1); /* 203, 343 */
+ RF_WriteReg(dev, 0x06, 0x0200); mdelay(1); /* 400 */
+ RF_WriteReg(dev, 0x00, 0x0137); mdelay(1); /* switch to reg16-reg30, and HSSI disable 137 */
+ mdelay(10); /* Deay 10 ms. */ /* 0xfd */
- RF_WriteReg(dev, 0x00, 0x0137); mdelay(1); /* switch to reg16-reg30, and HSSI disable 137 */
- mdelay(10); /* Deay 10 ms. */ /* 0xfd */
+ RF_WriteReg(dev, 0x0d, 0x0008); mdelay(1); /* Z4 synthesizer loop filter setting, 392 */
+ mdelay(10); /* Deay 10 ms. */ /* 0xfd */
- RF_WriteReg(dev, 0x0d, 0x0008); mdelay(1); /* Z4 synthesizer loop filter setting, 392 */
- mdelay(10); /* Deay 10 ms. */ /* 0xfd */
+ RF_WriteReg(dev, 0x00, 0x0037); mdelay(1); /* switch to reg0-reg15, and HSSI disable */
+ mdelay(10); /* Deay 10 ms. */ /* 0xfd */
- RF_WriteReg(dev, 0x00, 0x0037); mdelay(1); /* switch to reg0-reg15, and HSSI disable */
- mdelay(10); /* Deay 10 ms. */ /* 0xfd */
+ RF_WriteReg(dev, 0x04, 0x0160); mdelay(1); /* CBC on, Tx Rx disable, High gain */
+ mdelay(10); /* Deay 10 ms. */ /* 0xfd */
- RF_WriteReg(dev, 0x04, 0x0160); mdelay(1); /* CBC on, Tx Rx disable, High gain */
- mdelay(10); /* Deay 10 ms. */ /* 0xfd */
+ RF_WriteReg(dev, 0x07, 0x0080); mdelay(1); /* Z4 setted channel 1 */
+ mdelay(10); /* Deay 10 ms. */ /* 0xfd */
- RF_WriteReg(dev, 0x07, 0x0080); mdelay(1); /* Z4 setted channel 1 */
- mdelay(10); /* Deay 10 ms. */ /* 0xfd */
+ RF_WriteReg(dev, 0x02, 0x088D); mdelay(1); /* LC calibration */
+ mdelay(200); /* Deay 200 ms. */ /* 0xfd */
+ mdelay(10); /* Deay 10 ms. */ /* 0xfd */
+ mdelay(10); /* Deay 10 ms. */ /* 0xfd */
- RF_WriteReg(dev, 0x02, 0x088D); mdelay(1); /* LC calibration */
- mdelay(200); /* Deay 200 ms. */ /* 0xfd */
- mdelay(10); /* Deay 10 ms. */ /* 0xfd */
- mdelay(10); /* Deay 10 ms. */ /* 0xfd */
+ RF_WriteReg(dev, 0x00, 0x0137); mdelay(1); /* switch to reg16-reg30 137, and HSSI disable 137 */
+ mdelay(10); /* Deay 10 ms. */ /* 0xfd */
- RF_WriteReg(dev, 0x00, 0x0137); mdelay(1); /* switch to reg16-reg30 137, and HSSI disable 137 */
- mdelay(10); /* Deay 10 ms. */ /* 0xfd */
-
- RF_WriteReg(dev, 0x07, 0x0000); mdelay(1);
- RF_WriteReg(dev, 0x07, 0x0180); mdelay(1);
- RF_WriteReg(dev, 0x07, 0x0220); mdelay(1);
- RF_WriteReg(dev, 0x07, 0x03E0); mdelay(1);
+ RF_WriteReg(dev, 0x07, 0x0000); mdelay(1);
+ RF_WriteReg(dev, 0x07, 0x0180); mdelay(1);
+ RF_WriteReg(dev, 0x07, 0x0220); mdelay(1);
+ RF_WriteReg(dev, 0x07, 0x03E0); mdelay(1);
/* DAC calibration off 20070702 */
- RF_WriteReg(dev, 0x06, 0x00c1); mdelay(1);
- RF_WriteReg(dev, 0x0a, 0x0001); mdelay(1);
-/* {by amy 080312 */
+ RF_WriteReg(dev, 0x06, 0x00c1); mdelay(1);
+ RF_WriteReg(dev, 0x0a, 0x0001); mdelay(1);
/* For crystal calibration, added by Roger, 2007.12.11. */
- if (priv->bXtalCalibration) { /* reg 30. */
- /* enable crystal calibration.
- RF Reg[30], (1)Xin:[12:9], Xout:[8:5], addr[4:0].
- (2)PA Pwr delay timer[15:14], default: 2.4us, set BIT15=0
- (3)RF signal on/off when calibration[13], default: on, set BIT13=0.
- So we should minus 4 BITs offset. */
- RF_WriteReg(dev, 0x0f, (priv->XtalCal_Xin<<5) | (priv->XtalCal_Xout<<1) | BIT11 | BIT9); mdelay(1);
+ if (priv->bXtalCalibration) { /* reg 30. */
+ /*
+ * enable crystal calibration.
+ * RF Reg[30], (1)Xin:[12:9], Xout:[8:5], addr[4:0].
+ * (2)PA Pwr delay timer[15:14], default: 2.4us, set BIT15=0
+ * (3)RF signal on/off when calibration[13], default: on, set BIT13=0.
+ * So we should minus 4 BITs offset.
+ */
+ RF_WriteReg(dev, 0x0f, (priv->XtalCal_Xin<<5) | (priv->XtalCal_Xout<<1) | BIT11 | BIT9); mdelay(1);
printk("ZEBRA_Config_85BASIC_HardCode(): (%02x)\n",
- (priv->XtalCal_Xin<<5) | (priv->XtalCal_Xout<<1) | BIT11 | BIT9);
- } else {
+ (priv->XtalCal_Xin<<5) | (priv->XtalCal_Xout<<1) | BIT11 | BIT9);
+ } else {
/* using default value. Xin=6, Xout=6. */
- RF_WriteReg(dev, 0x0f, 0x0acc); mdelay(1);
+ RF_WriteReg(dev, 0x0f, 0x0acc); mdelay(1);
}
-/* by amy 080312 */
- RF_WriteReg(dev, 0x00, 0x00bf); mdelay(1); /* switch to reg0-reg15, and HSSI enable */
- RF_WriteReg(dev, 0x0d, 0x08df); mdelay(1); /* Rx BB start calibration, 00c//+edward */
- RF_WriteReg(dev, 0x02, 0x004d); mdelay(1); /* temperature meter off */
- RF_WriteReg(dev, 0x04, 0x0975); mdelay(1); /* Rx mode */
+ RF_WriteReg(dev, 0x00, 0x00bf); mdelay(1); /* switch to reg0-reg15, and HSSI enable */
+ RF_WriteReg(dev, 0x0d, 0x08df); mdelay(1); /* Rx BB start calibration, 00c//+edward */
+ RF_WriteReg(dev, 0x02, 0x004d); mdelay(1); /* temperature meter off */
+ RF_WriteReg(dev, 0x04, 0x0975); mdelay(1); /* Rx mode */
mdelay(10); /* Deay 10 ms.*/ /* 0xfe */
mdelay(10); /* Deay 10 ms.*/ /* 0xfe */
mdelay(10); /* Deay 10 ms.*/ /* 0xfe */
- RF_WriteReg(dev, 0x00, 0x0197); mdelay(1); /* Rx mode*/ /*+edward */
- RF_WriteReg(dev, 0x05, 0x05ab); mdelay(1); /* Rx mode*/ /*+edward */
- RF_WriteReg(dev, 0x00, 0x009f); mdelay(1); /* Rx mode*/ /*+edward */
-
- RF_WriteReg(dev, 0x01, 0x0000); mdelay(1); /* Rx mode*/ /*+edward */
- RF_WriteReg(dev, 0x02, 0x0000); mdelay(1); /* Rx mode*/ /*+edward */
- /* power save parameters. */
+ RF_WriteReg(dev, 0x00, 0x0197); mdelay(1); /* Rx mode*/ /*+edward */
+ RF_WriteReg(dev, 0x05, 0x05ab); mdelay(1); /* Rx mode*/ /*+edward */
+ RF_WriteReg(dev, 0x00, 0x009f); mdelay(1); /* Rx mode*/ /*+edward */
+ RF_WriteReg(dev, 0x01, 0x0000); mdelay(1); /* Rx mode*/ /*+edward */
+ RF_WriteReg(dev, 0x02, 0x0000); mdelay(1); /* Rx mode*/ /*+edward */
+ /* power save parameters. */
u1b24E = read_nic_byte(dev, 0x24E);
write_nic_byte(dev, 0x24E, (u1b24E & (~(BIT5|BIT6))));
/*=============================================================================
-
- =============================================================================
- CCKCONF.TXT
- =============================================================================
- */
- /* [POWER SAVE] Power Saving Parameters by jong. 2007-11-27
- CCK reg0x00[7]=1'b1 :power saving for TX (default)
- CCK reg0x00[6]=1'b1: power saving for RX (default)
- CCK reg0x06[4]=1'b1: turn off channel estimation related circuits if not doing channel estimation.
- CCK reg0x06[3]=1'b1: turn off unused circuits before cca = 1
- CCK reg0x06[2]=1'b1: turn off cck's circuit if macrst =0
- */
+ *
+ *===========================================================================
+ * CCKCONF.TXT
+ *===========================================================================
+ *
+ * [POWER SAVE] Power Saving Parameters by jong. 2007-11-27
+ * CCK reg0x00[7]=1'b1 :power saving for TX (default)
+ * CCK reg0x00[6]=1'b1: power saving for RX (default)
+ * CCK reg0x06[4]=1'b1: turn off channel estimation related circuits if not doing channel estimation.
+ * CCK reg0x06[3]=1'b1: turn off unused circuits before cca = 1
+ * CCK reg0x06[2]=1'b1: turn off cck's circuit if macrst =0
+ */
write_phy_cck(dev, 0x00, 0xc8);
write_phy_cck(dev, 0x06, 0x1c);
@@ -697,7 +631,7 @@ ZEBRA_Config_85BASIC_HardCode(
write_phy_cck(dev, 0x2f, 0x06);
write_phy_cck(dev, 0x01, 0x46);
- /* power control */
+ /* power control */
write_nic_byte(dev, CCK_TXAGC, 0x10);
write_nic_byte(dev, OFDM_TXAGC, 0x1B);
write_nic_byte(dev, ANTSEL, 0x03);
@@ -705,14 +639,14 @@ ZEBRA_Config_85BASIC_HardCode(
/*
- =============================================================================
- AGC.txt
- =============================================================================
- */
+ *===========================================================================
+ * AGC.txt
+ *===========================================================================
+ */
write_phy_ofdm(dev, 0x00, 0x12);
- for (i = 0; i < 128; i++) {
+ for (i = 0; i < 128; i++) {
data = ZEBRA_AGC[i+1];
data = data << 8;
@@ -730,49 +664,43 @@ ZEBRA_Config_85BASIC_HardCode(
PlatformIOWrite4Byte(dev, PhyAddr, 0x00001080); /* Annie, 2006-05-05 */
/*
- =============================================================================
-
- =============================================================================
- OFDMCONF.TXT
- =============================================================================
- */
-
- for (i = 0; i < 60; i++) {
+ *===========================================================================
+ *
+ *===========================================================================
+ * OFDMCONF.TXT
+ *===========================================================================
+ */
+
+ for (i = 0; i < 60; i++) {
u4bRegOffset = i;
u4bRegValue = OFDM_CONFIG[i];
WriteBBPortUchar(dev,
- (0x00000080 |
- (u4bRegOffset & 0x7f) |
- ((u4bRegValue & 0xff) << 8)));
+ (0x00000080 |
+ (u4bRegOffset & 0x7f) |
+ ((u4bRegValue & 0xff) << 8)));
}
/*
- =============================================================================
- by amy for antenna
- =============================================================================
- */
-/* {by amy 080312 */
+ *===========================================================================
+ * by amy for antenna
+ *===========================================================================
+ */
/* Config Sw/Hw Combinational Antenna Diversity. Added by Roger, 2008.02.26. */
SetAntennaConfig87SE(dev, priv->bDefaultAntenna1, priv->bSwAntennaDiverity);
-/* by amy 080312} */
-/* by amy for antenna */
}
-void
-UpdateInitialGain(
- struct net_device *dev
- )
+void UpdateInitialGain(struct net_device *dev)
{
struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
/* lzm add 080826 */
- if (priv->eRFPowerState != eRfOn) {
+ if (priv->eRFPowerState != eRfOn) {
/* Don't access BB/RF under disable PLL situation.
- RT_TRACE(COMP_DIG, DBG_LOUD, ("UpdateInitialGain - pHalData->eRFPowerState!=eRfOn\n"));
- Back to the original state
- */
+ * RT_TRACE(COMP_DIG, DBG_LOUD, ("UpdateInitialGain - pHalData->eRFPowerState!=eRfOn\n"));
+ * Back to the original state
+ */
priv->InitialGain = priv->InitialGainBackUp;
return;
}
@@ -826,7 +754,7 @@ UpdateInitialGain(
write_phy_ofdm(dev, 0x05, 0xfc); mdelay(1);
break;
- default: /* MP */
+ default: /* MP */
write_phy_ofdm(dev, 0x17, 0x26); mdelay(1);
write_phy_ofdm(dev, 0x24, 0x86); mdelay(1);
write_phy_ofdm(dev, 0x05, 0xfa); mdelay(1);
@@ -834,14 +762,11 @@ UpdateInitialGain(
}
}
/*
- Description:
- Tx Power tracking mechanism routine on 87SE.
- Created by Roger, 2007.12.11.
-*/
-void
-InitTxPwrTracking87SE(
- struct net_device *dev
-)
+ * Description:
+ * Tx Power tracking mechanism routine on 87SE.
+ * Created by Roger, 2007.12.11.
+ */
+void InitTxPwrTracking87SE(struct net_device *dev)
{
u32 u4bRfReg;
@@ -851,49 +776,41 @@ InitTxPwrTracking87SE(
RF_WriteReg(dev, 0x02, u4bRfReg|PWR_METER_EN); mdelay(1);
}
-void
-PhyConfig8185(
- struct net_device *dev
- )
+void PhyConfig8185(struct net_device *dev)
{
struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
write_nic_dword(dev, RCR, priv->ReceiveConfig);
priv->RFProgType = read_nic_byte(dev, CONFIG4) & 0x03;
/* RF config */
ZEBRA_Config_85BASIC_HardCode(dev);
-/* {by amy 080312 */
/* Set default initial gain state to 4, approved by SD3 DZ, by Bruce, 2007-06-06. */
- if (priv->bDigMechanism) {
+ if (priv->bDigMechanism) {
if (priv->InitialGain == 0)
priv->InitialGain = 4;
}
/*
- Enable thermal meter indication to implement TxPower tracking on 87SE.
- We initialize thermal meter here to avoid unsuccessful configuration.
- Added by Roger, 2007.12.11.
- */
+ * Enable thermal meter indication to implement TxPower tracking on 87SE.
+ * We initialize thermal meter here to avoid unsuccessful configuration.
+ * Added by Roger, 2007.12.11.
+ */
if (priv->bTxPowerTrack)
InitTxPwrTracking87SE(dev);
-/* by amy 080312} */
priv->InitialGainBackUp = priv->InitialGain;
UpdateInitialGain(dev);
return;
}
-void
-HwConfigureRTL8185(
- struct net_device *dev
- )
+void HwConfigureRTL8185(struct net_device *dev)
{
/* RTL8185_TODO: Determine Retrylimit, TxAGC, AutoRateFallback control. */
- u8 bUNIVERSAL_CONTROL_RL = 0;
- u8 bUNIVERSAL_CONTROL_AGC = 1;
- u8 bUNIVERSAL_CONTROL_ANT = 1;
- u8 bAUTO_RATE_FALLBACK_CTL = 1;
- u8 val8;
+ u8 bUNIVERSAL_CONTROL_RL = 0;
+ u8 bUNIVERSAL_CONTROL_AGC = 1;
+ u8 bUNIVERSAL_CONTROL_ANT = 1;
+ u8 bAUTO_RATE_FALLBACK_CTL = 1;
+ u8 val8;
write_nic_word(dev, BRSR, 0x0fff);
/* Retry limit */
val8 = read_nic_byte(dev, CW_CONF);
@@ -907,24 +824,24 @@ HwConfigureRTL8185(
/* Tx AGC */
val8 = read_nic_byte(dev, TXAGC_CTL);
- if (bUNIVERSAL_CONTROL_AGC) {
+ if (bUNIVERSAL_CONTROL_AGC) {
write_nic_byte(dev, CCK_TXAGC, 128);
write_nic_byte(dev, OFDM_TXAGC, 128);
val8 = val8 & 0xfe;
- } else {
+ } else {
val8 = val8 | 0x01 ;
}
write_nic_byte(dev, TXAGC_CTL, val8);
- /* Tx Antenna including Feedback control */
+ /* Tx Antenna including Feedback control */
val8 = read_nic_byte(dev, TXAGC_CTL);
- if (bUNIVERSAL_CONTROL_ANT) {
+ if (bUNIVERSAL_CONTROL_ANT) {
write_nic_byte(dev, ANTSEL, 0x00);
val8 = val8 & 0xfd;
- } else {
+ } else {
val8 = val8 & (val8|0x02); /* xiong-2006-11-15 */
}
@@ -933,7 +850,7 @@ HwConfigureRTL8185(
/* Auto Rate fallback control */
val8 = read_nic_byte(dev, RATE_FALLBACK);
val8 &= 0x7c;
- if (bAUTO_RATE_FALLBACK_CTL) {
+ if (bAUTO_RATE_FALLBACK_CTL) {
val8 |= RATE_FALLBACK_CTL_ENABLE | RATE_FALLBACK_CTL_AUTO_STEP1;
/* <RJ_TODO_8185B> We shall set up the ARFR according to user's setting. */
@@ -942,40 +859,34 @@ HwConfigureRTL8185(
write_nic_byte(dev, RATE_FALLBACK, val8);
}
-static void
-MacConfig_85BASIC_HardCode(
- struct net_device *dev)
+static void MacConfig_85BASIC_HardCode(struct net_device *dev)
{
/*
- ============================================================================
- MACREG.TXT
- ============================================================================
- */
- int nLinesRead = 0;
-
- u32 u4bRegOffset, u4bRegValue, u4bPageIndex = 0;
- int i;
+ *==========================================================================
+ * MACREG.TXT
+ *==========================================================================
+ */
+ int nLinesRead = 0;
+ u32 u4bRegOffset, u4bRegValue, u4bPageIndex = 0;
+ int i;
nLinesRead = sizeof(MAC_REG_TABLE)/2;
- for (i = 0; i < nLinesRead; i++) { /* nLinesRead=101 */
+ for (i = 0; i < nLinesRead; i++) { /* nLinesRead=101 */
u4bRegOffset = MAC_REG_TABLE[i][0];
u4bRegValue = MAC_REG_TABLE[i][1];
if (u4bRegOffset == 0x5e)
u4bPageIndex = u4bRegValue;
-
else
- u4bRegOffset |= (u4bPageIndex << 8);
+ u4bRegOffset |= (u4bPageIndex << 8);
write_nic_byte(dev, u4bRegOffset, (u8)u4bRegValue);
}
/* ============================================================================ */
}
-static void
-MacConfig_85BASIC(
- struct net_device *dev)
+static void MacConfig_85BASIC(struct net_device *dev)
{
u8 u1DA;
@@ -994,18 +905,18 @@ MacConfig_85BASIC(
PlatformIOWrite4Byte(dev, 0x1F4, 0x00000000);
PlatformIOWrite1Byte(dev, 0x1F8, 0x00);
- /* Asked for by SD3 CM Lin, 2006.06.27, by rcnjko. */
- /* power save parameter based on "87SE power save parameters 20071127.doc", as follow. */
+ /* Asked for by SD3 CM Lin, 2006.06.27, by rcnjko. */
+ /* power save parameter based on "87SE power save parameters 20071127.doc", as follow. */
/* Enable DA10 TX power saving */
u1DA = read_nic_byte(dev, PHYPR);
write_nic_byte(dev, PHYPR, (u1DA | BIT2));
- /* POWER: */
+ /* POWER: */
write_nic_word(dev, 0x360, 0x1000);
write_nic_word(dev, 0x362, 0x1000);
- /* AFE. */
+ /* AFE. */
write_nic_word(dev, 0x370, 0x0560);
write_nic_word(dev, 0x372, 0x0560);
write_nic_word(dev, 0x374, 0x0DA4);
@@ -1013,54 +924,48 @@ MacConfig_85BASIC(
write_nic_word(dev, 0x378, 0x0560);
write_nic_word(dev, 0x37A, 0x0560);
write_nic_word(dev, 0x37C, 0x00EC);
- write_nic_word(dev, 0x37E, 0x00EC); /*+edward */
+ write_nic_word(dev, 0x37E, 0x00EC); /* +edward */
write_nic_byte(dev, 0x24E, 0x01);
}
-u8
-GetSupportedWirelessMode8185(
- struct net_device *dev
-)
+u8 GetSupportedWirelessMode8185(struct net_device *dev)
{
- u8 btSupportedWirelessMode = 0;
+ u8 btSupportedWirelessMode = 0;
btSupportedWirelessMode = (WIRELESS_MODE_B | WIRELESS_MODE_G);
return btSupportedWirelessMode;
}
-void
-ActUpdateChannelAccessSetting(
- struct net_device *dev,
- WIRELESS_MODE WirelessMode,
- PCHANNEL_ACCESS_SETTING ChnlAccessSetting
- )
+void ActUpdateChannelAccessSetting(struct net_device *dev,
+ WIRELESS_MODE WirelessMode,
+ PCHANNEL_ACCESS_SETTING ChnlAccessSetting)
{
- struct r8180_priv *priv = ieee80211_priv(dev);
- struct ieee80211_device *ieee = priv->ieee80211;
+ struct r8180_priv *priv = ieee80211_priv(dev);
+ struct ieee80211_device *ieee = priv->ieee80211;
AC_CODING eACI;
AC_PARAM AcParam;
- u8 bFollowLegacySetting = 0;
- u8 u1bAIFS;
+ u8 bFollowLegacySetting = 0;
+ u8 u1bAIFS;
/*
- <RJ_TODO_8185B>
- TODO: We still don't know how to set up these registers, just follow WMAC to
- verify 8185B FPAG.
-
- <RJ_TODO_8185B>
- Jong said CWmin/CWmax register are not functional in 8185B,
- so we shall fill channel access realted register into AC parameter registers,
- even in nQBss.
- */
+ * <RJ_TODO_8185B>
+ * TODO: We still don't know how to set up these registers, just follow WMAC to
+ * verify 8185B FPAG.
+ *
+ * <RJ_TODO_8185B>
+ * Jong said CWmin/CWmax register are not functional in 8185B,
+ * so we shall fill channel access realted register into AC parameter registers,
+ * even in nQBss.
+ */
ChnlAccessSetting->SIFS_Timer = 0x22; /* Suggested by Jong, 2005.12.08. */
- ChnlAccessSetting->DIFS_Timer = 0x1C; /* 2006.06.02, by rcnjko. */
- ChnlAccessSetting->SlotTimeTimer = 9; /* 2006.06.02, by rcnjko. */
- ChnlAccessSetting->EIFS_Timer = 0x5B; /* Suggested by wcchu, it is the default value of EIFS register, 2005.12.08. */
- ChnlAccessSetting->CWminIndex = 3; /* 2006.06.02, by rcnjko. */
- ChnlAccessSetting->CWmaxIndex = 7; /* 2006.06.02, by rcnjko. */
+ ChnlAccessSetting->DIFS_Timer = 0x1C; /* 2006.06.02, by rcnjko. */
+ ChnlAccessSetting->SlotTimeTimer = 9; /* 2006.06.02, by rcnjko. */
+ ChnlAccessSetting->EIFS_Timer = 0x5B; /* Suggested by wcchu, it is the default value of EIFS register, 2005.12.08. */
+ ChnlAccessSetting->CWminIndex = 3; /* 2006.06.02, by rcnjko. */
+ ChnlAccessSetting->CWmaxIndex = 7; /* 2006.06.02, by rcnjko. */
write_nic_byte(dev, SIFS, ChnlAccessSetting->SIFS_Timer);
- write_nic_byte(dev, SLOT, ChnlAccessSetting->SlotTimeTimer); /* Rewrited from directly use PlatformEFIOWrite1Byte(), by Annie, 2006-03-29. */
+ write_nic_byte(dev, SLOT, ChnlAccessSetting->SlotTimeTimer); /* Rewrited from directly use PlatformEFIOWrite1Byte(), by Annie, 2006-03-29. */
u1bAIFS = aSifsTime + (2 * ChnlAccessSetting->SlotTimeTimer);
@@ -1074,17 +979,17 @@ ActUpdateChannelAccessSetting(
}
/* this setting is copied from rtl8187B. xiong-2006-11-13 */
- if (bFollowLegacySetting) {
+ if (bFollowLegacySetting) {
/*
- Follow 802.11 seeting to AC parameter, all AC shall use the same parameter.
- 2005.12.01, by rcnjko.
- */
+ * Follow 802.11 seeting to AC parameter, all AC shall use the same parameter.
+ * 2005.12.01, by rcnjko.
+ */
AcParam.longData = 0;
AcParam.f.AciAifsn.f.AIFSN = 2; /* Follow 802.11 DIFS. */
AcParam.f.AciAifsn.f.ACM = 0;
- AcParam.f.Ecw.f.ECWmin = ChnlAccessSetting->CWminIndex; /* Follow 802.11 CWmin. */
- AcParam.f.Ecw.f.ECWmax = ChnlAccessSetting->CWmaxIndex; /* Follow 802.11 CWmax. */
+ AcParam.f.Ecw.f.ECWmin = ChnlAccessSetting->CWminIndex; /* Follow 802.11 CWmin. */
+ AcParam.f.Ecw.f.ECWmax = ChnlAccessSetting->CWmaxIndex; /* Follow 802.11 CWmax. */
AcParam.f.TXOPLimit = 0;
/* lzm reserved 080826 */
@@ -1095,7 +1000,7 @@ ActUpdateChannelAccessSetting(
if (ieee->iw_mode == IW_MODE_ADHOC)
AcParam.f.TXOPLimit = 0x0020;
- for (eACI = 0; eACI < AC_MAX; eACI++) {
+ for (eACI = 0; eACI < AC_MAX; eACI++) {
AcParam.f.AciAifsn.f.ACI = (u8)eACI;
{
PAC_PARAM pAcParam = (PAC_PARAM)(&AcParam);
@@ -1103,7 +1008,7 @@ ActUpdateChannelAccessSetting(
u8 u1bAIFS;
u32 u4bAcParam;
- /* Retrive paramters to udpate. */
+ /* Retrieve paramters to update. */
eACI = pAcParam->f.AciAifsn.f.ACI;
u1bAIFS = pAcParam->f.AciAifsn.f.AIFSN * ChnlAccessSetting->SlotTimeTimer + aSifsTime;
u4bAcParam = ((((u32)(pAcParam->f.TXOPLimit)) << AC_PARAM_TXOP_LIMIT_OFFSET) |
@@ -1111,7 +1016,7 @@ ActUpdateChannelAccessSetting(
(((u32)(pAcParam->f.Ecw.f.ECWmin)) << AC_PARAM_ECW_MIN_OFFSET) |
(((u32)u1bAIFS) << AC_PARAM_AIFS_OFFSET));
- switch (eACI) {
+ switch (eACI) {
case AC1_BK:
/* write_nic_dword(dev, AC_BK_PARAM, u4bAcParam); */
break;
@@ -1133,47 +1038,46 @@ ActUpdateChannelAccessSetting(
break;
}
- /* Cehck ACM bit. */
+ /* Cehck ACM bit. */
/* If it is set, immediately set ACM control bit to downgrading AC for passing WMM testplan. Annie, 2005-12-13. */
{
PACI_AIFSN pAciAifsn = (PACI_AIFSN)(&pAcParam->f.AciAifsn);
AC_CODING eACI = pAciAifsn->f.ACI;
- /*modified Joseph */
- /*for 8187B AsynIORead issue */
+ /*for 8187B AsynIORead issue */
u8 AcmCtrl = 0;
- if (pAciAifsn->f.ACM) {
+ if (pAciAifsn->f.ACM) {
/* ACM bit is 1. */
- switch (eACI) {
+ switch (eACI) {
case AC0_BE:
- AcmCtrl |= (BEQ_ACM_EN|BEQ_ACM_CTL|ACM_HW_EN); /* or 0x21 */
+ AcmCtrl |= (BEQ_ACM_EN|BEQ_ACM_CTL|ACM_HW_EN); /* or 0x21 */
break;
case AC2_VI:
- AcmCtrl |= (VIQ_ACM_EN|VIQ_ACM_CTL|ACM_HW_EN); /* or 0x42 */
+ AcmCtrl |= (VIQ_ACM_EN|VIQ_ACM_CTL|ACM_HW_EN); /* or 0x42 */
break;
case AC3_VO:
- AcmCtrl |= (VOQ_ACM_EN|VOQ_ACM_CTL|ACM_HW_EN); /* or 0x84 */
+ AcmCtrl |= (VOQ_ACM_EN|VOQ_ACM_CTL|ACM_HW_EN); /* or 0x84 */
break;
default:
DMESGW("SetHwReg8185(): [HW_VAR_ACM_CTRL] ACM set failed: eACI is %d\n", eACI);
break;
}
- } else {
+ } else {
/* ACM bit is 0. */
- switch (eACI) {
+ switch (eACI) {
case AC0_BE:
- AcmCtrl &= ((~BEQ_ACM_EN) & (~BEQ_ACM_CTL) & (~ACM_HW_EN)); /* and 0xDE */
+ AcmCtrl &= ((~BEQ_ACM_EN) & (~BEQ_ACM_CTL) & (~ACM_HW_EN)); /* and 0xDE */
break;
case AC2_VI:
- AcmCtrl &= ((~VIQ_ACM_EN) & (~VIQ_ACM_CTL) & (~ACM_HW_EN)); /* and 0xBD */
+ AcmCtrl &= ((~VIQ_ACM_EN) & (~VIQ_ACM_CTL) & (~ACM_HW_EN)); /* and 0xBD */
break;
case AC3_VO:
- AcmCtrl &= ((~VOQ_ACM_EN) & (~VOQ_ACM_CTL) & (~ACM_HW_EN)); /* and 0x7B */
+ AcmCtrl &= ((~VOQ_ACM_EN) & (~VOQ_ACM_CTL) & (~ACM_HW_EN)); /* and 0x7B */
break;
default:
@@ -1187,53 +1091,51 @@ ActUpdateChannelAccessSetting(
}
}
-void
-ActSetWirelessMode8185(
- struct net_device *dev,
- u8 btWirelessMode
- )
+void ActSetWirelessMode8185(struct net_device *dev, u8 btWirelessMode)
{
- struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
- struct ieee80211_device *ieee = priv->ieee80211;
+ struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
+ struct ieee80211_device *ieee = priv->ieee80211;
u8 btSupportedWirelessMode = GetSupportedWirelessMode8185(dev);
if ((btWirelessMode & btSupportedWirelessMode) == 0) {
- /* Don't switch to unsupported wireless mode, 2006.02.15, by rcnjko. */
+ /* Don't switch to unsupported wireless mode, 2006.02.15, by rcnjko. */
DMESGW("ActSetWirelessMode8185(): WirelessMode(%d) is not supported (%d)!\n",
btWirelessMode, btSupportedWirelessMode);
return;
}
- /* 1. Assign wireless mode to swtich if necessary. */
- if (btWirelessMode == WIRELESS_MODE_AUTO) {
- if ((btSupportedWirelessMode & WIRELESS_MODE_A)) {
+ /* 1. Assign wireless mode to switch if necessary. */
+ if (btWirelessMode == WIRELESS_MODE_AUTO) {
+ if ((btSupportedWirelessMode & WIRELESS_MODE_A)) {
btWirelessMode = WIRELESS_MODE_A;
- } else if (btSupportedWirelessMode & WIRELESS_MODE_G) {
+ } else if (btSupportedWirelessMode & WIRELESS_MODE_G) {
btWirelessMode = WIRELESS_MODE_G;
- } else if ((btSupportedWirelessMode & WIRELESS_MODE_B)) {
- btWirelessMode = WIRELESS_MODE_B;
- } else {
- DMESGW("ActSetWirelessMode8185(): No valid wireless mode supported, btSupportedWirelessMode(%x)!!!\n",
- btSupportedWirelessMode);
+ } else if ((btSupportedWirelessMode & WIRELESS_MODE_B)) {
btWirelessMode = WIRELESS_MODE_B;
+ } else {
+ DMESGW("ActSetWirelessMode8185(): No valid wireless mode supported, btSupportedWirelessMode(%x)!!!\n",
+ btSupportedWirelessMode);
+ btWirelessMode = WIRELESS_MODE_B;
}
}
- /* 2. Swtich band: RF or BB specific actions,
+ /*
+ * 2. Swtich band: RF or BB specific actions,
* for example, refresh tables in omc8255, or change initial gain if necessary.
* Nothing to do for Zebra to switch band.
- * Update current wireless mode if we swtich to specified band successfully. */
+ * Update current wireless mode if we switch to specified band successfully.
+ */
ieee->mode = (WIRELESS_MODE)btWirelessMode;
- /* 3. Change related setting. */
- if( ieee->mode == WIRELESS_MODE_A ) {
+ /* 3. Change related setting. */
+ if( ieee->mode == WIRELESS_MODE_A ) {
DMESG("WIRELESS_MODE_A\n");
- } else if( ieee->mode == WIRELESS_MODE_B ) {
- DMESG("WIRELESS_MODE_B\n");
- } else if( ieee->mode == WIRELESS_MODE_G ) {
- DMESG("WIRELESS_MODE_G\n");
+ } else if( ieee->mode == WIRELESS_MODE_B ) {
+ DMESG("WIRELESS_MODE_B\n");
+ } else if( ieee->mode == WIRELESS_MODE_G ) {
+ DMESG("WIRELESS_MODE_G\n");
}
ActUpdateChannelAccessSetting( dev, ieee->mode, &priv->ChannelAccessSetting);
}
@@ -1245,22 +1147,16 @@ void rtl8185b_irq_enable(struct net_device *dev)
priv->irq_enabled = 1;
write_nic_dword(dev, IMR, priv->IntrMask);
}
-/* by amy for power save */
-void
-DrvIFIndicateDisassociation(
- struct net_device *dev,
- u16 reason
- )
+
+void DrvIFIndicateDisassociation(struct net_device *dev, u16 reason)
{
/* nothing is needed after disassociation request. */
- }
-void
-MgntDisconnectIBSS(
- struct net_device *dev
-)
+}
+
+void MgntDisconnectIBSS(struct net_device *dev)
{
struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
- u8 i;
+ u8 i;
DrvIFIndicateDisassociation(dev, unspec_reason);
@@ -1271,166 +1167,143 @@ MgntDisconnectIBSS(
priv->ieee80211->state = IEEE80211_NOLINK;
/*
- Stop Beacon.
-
- Vista add a Adhoc profile, HW radio off until OID_DOT11_RESET_REQUEST
- Driver would set MSR=NO_LINK, then HW Radio ON, MgntQueue Stuck.
- Because Bcn DMA isn't complete, mgnt queue would stuck until Bcn packet send.
-
- Disable Beacon Queue Own bit, suggested by jong */
+ * Stop Beacon.
+ *
+ * Vista add a Adhoc profile, HW radio off until OID_DOT11_RESET_REQUEST
+ * Driver would set MSR=NO_LINK, then HW Radio ON, MgntQueue Stuck.
+ * Because Bcn DMA isn't complete, mgnt queue would stuck until Bcn packet send.
+ *
+ * Disable Beacon Queue Own bit, suggested by jong
+ */
ieee80211_stop_send_beacons(priv->ieee80211);
priv->ieee80211->link_change(dev);
notify_wx_assoc_event(priv->ieee80211);
}
-void
-MlmeDisassociateRequest(
- struct net_device *dev,
- u8 *asSta,
- u8 asRsn
- )
+
+void MlmeDisassociateRequest(struct net_device *dev, u8 *asSta, u8 asRsn)
{
struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
u8 i;
SendDisassociation(priv->ieee80211, asSta, asRsn);
- if (memcmp(priv->ieee80211->current_network.bssid, asSta, 6) == 0) {
- /*ShuChen TODO: change media status. */
- /*ShuChen TODO: What to do when disassociate. */
+ if (memcmp(priv->ieee80211->current_network.bssid, asSta, 6) == 0) {
+ /* ShuChen TODO: change media status. */
+ /* ShuChen TODO: What to do when disassociate. */
DrvIFIndicateDisassociation(dev, unspec_reason);
-
-
for (i = 0; i < 6; i++)
priv->ieee80211->current_network.bssid[i] = 0x22;
ieee80211_disassociate(priv->ieee80211);
}
-
}
-void
-MgntDisconnectAP(
- struct net_device *dev,
- u8 asRsn
-)
+void MgntDisconnectAP(struct net_device *dev, u8 asRsn)
{
struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
/*
- Commented out by rcnjko, 2005.01.27:
- I move SecClearAllKeys() to MgntActSet_802_11_DISASSOCIATE().
-
- 2004/09/15, kcwu, the key should be cleared, or the new handshaking will not success
-
- In WPA WPA2 need to Clear all key ... because new key will set after new handshaking.
- 2004.10.11, by rcnjko. */
+ * Commented out by rcnjko, 2005.01.27:
+ * I move SecClearAllKeys() to MgntActSet_802_11_DISASSOCIATE().
+ *
+ * 2004/09/15, kcwu, the key should be cleared, or the new handshaking will not success
+ *
+ * In WPA WPA2 need to Clear all key ... because new key will set after new handshaking.
+ * 2004.10.11, by rcnjko.
+ */
MlmeDisassociateRequest(dev, priv->ieee80211->current_network.bssid, asRsn);
priv->ieee80211->state = IEEE80211_NOLINK;
}
-bool
-MgntDisconnect(
- struct net_device *dev,
- u8 asRsn
-)
+
+bool MgntDisconnect(struct net_device *dev, u8 asRsn)
{
struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
/*
- Schedule an workitem to wake up for ps mode, 070109, by rcnjko.
- */
+ * Schedule an workitem to wake up for ps mode, 070109, by rcnjko.
+ */
if (IS_DOT11D_ENABLE(priv->ieee80211))
Dot11d_Reset(priv->ieee80211);
- /* In adhoc mode, update beacon frame. */
+ /* In adhoc mode, update beacon frame. */
if (priv->ieee80211->state == IEEE80211_LINKED) {
if (priv->ieee80211->iw_mode == IW_MODE_ADHOC)
MgntDisconnectIBSS(dev);
- if (priv->ieee80211->iw_mode == IW_MODE_INFRA) {
- /* We clear key here instead of MgntDisconnectAP() because that
- MgntActSet_802_11_DISASSOCIATE() is an interface called by OS,
- e.g. OID_802_11_DISASSOCIATE in Windows while as MgntDisconnectAP() is
- used to handle disassociation related things to AP, e.g. send Disassoc
- frame to AP. 2005.01.27, by rcnjko. */
+ if (priv->ieee80211->iw_mode == IW_MODE_INFRA) {
+ /*
+ * We clear key here instead of MgntDisconnectAP() because that
+ * MgntActSet_802_11_DISASSOCIATE() is an interface called by OS,
+ * e.g. OID_802_11_DISASSOCIATE in Windows while as MgntDisconnectAP() is
+ * used to handle disassociation related things to AP, e.g. send Disassoc
+ * frame to AP. 2005.01.27, by rcnjko.
+ */
MgntDisconnectAP(dev, asRsn);
}
- /* Inidicate Disconnect, 2005.02.23, by rcnjko. */
+ /* Indicate Disconnect, 2005.02.23, by rcnjko. */
}
return true;
}
/*
- Description:
- Chang RF Power State.
- Note that, only MgntActSet_RF_State() is allowed to set HW_VAR_RF_STATE.
-
- Assumption:
- PASSIVE LEVEL.
-*/
-bool
-SetRFPowerState(
- struct net_device *dev,
- RT_RF_POWER_STATE eRFPowerState
- )
+ * Description:
+ * Chang RF Power State.
+ * Note that, only MgntActSet_RF_State() is allowed to set HW_VAR_RF_STATE.
+ *
+ * Assumption:
+ * PASSIVE LEVEL.
+ */
+bool SetRFPowerState(struct net_device *dev, RT_RF_POWER_STATE eRFPowerState)
{
- struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
- bool bResult = false;
+ struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
+ bool bResult = false;
if (eRFPowerState == priv->eRFPowerState)
return bResult;
- bResult = SetZebraRFPowerState8185(dev, eRFPowerState);
+ bResult = SetZebraRFPowerState8185(dev, eRFPowerState);
return bResult;
}
-void
-HalEnableRx8185Dummy(
- struct net_device *dev
- )
+
+void HalEnableRx8185Dummy(struct net_device *dev)
{
}
-void
-HalDisableRx8185Dummy(
- struct net_device *dev
- )
+
+void HalDisableRx8185Dummy(struct net_device *dev)
{
}
-bool
-MgntActSet_RF_State(
- struct net_device *dev,
- RT_RF_POWER_STATE StateToSet,
- u32 ChangeSource
- )
+bool MgntActSet_RF_State(struct net_device *dev, RT_RF_POWER_STATE StateToSet, u32 ChangeSource)
{
- struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
- bool bActionAllowed = false;
- bool bConnectBySSID = false;
- RT_RF_POWER_STATE rtState;
- u16 RFWaitCounter = 0;
+ struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
+ bool bActionAllowed = false;
+ bool bConnectBySSID = false;
+ RT_RF_POWER_STATE rtState;
+ u16 RFWaitCounter = 0;
unsigned long flag;
/*
- Prevent the race condition of RF state change. By Bruce, 2007-11-28.
- Only one thread can change the RF state at one time, and others should wait to be executed.
- */
- while (true) {
+ * Prevent the race condition of RF state change. By Bruce, 2007-11-28.
+ * Only one thread can change the RF state at one time, and others should wait to be executed.
+ */
+ while (true) {
spin_lock_irqsave(&priv->rf_ps_lock, flag);
- if (priv->RFChangeInProgress) {
+ if (priv->RFChangeInProgress) {
spin_unlock_irqrestore(&priv->rf_ps_lock, flag);
/* Set RF after the previous action is done. */
- while (priv->RFChangeInProgress) {
+ while (priv->RFChangeInProgress) {
RFWaitCounter++;
udelay(1000); /* 1 ms */
- /* Wait too long, return FALSE to avoid to be stuck here. */
- if (RFWaitCounter > 1000) { /* 1sec */
+ /* Wait too long, return FALSE to avoid to be stuck here. */
+ if (RFWaitCounter > 1000) { /* 1sec */
printk("MgntActSet_RF_State(): Wait too long to set RF\n");
- /* TODO: Reset RF state? */
+ /* TODO: Reset RF state? */
return false;
}
}
- } else {
+ } else {
priv->RFChangeInProgress = true;
spin_unlock_irqrestore(&priv->rf_ps_lock, flag);
break;
@@ -1438,12 +1311,12 @@ MgntActSet_RF_State(
}
rtState = priv->eRFPowerState;
- switch (StateToSet) {
+ switch (StateToSet) {
case eRfOn:
/*
- Turn On RF no matter the IPS setting because we need to update the RF state to Ndis under Vista, or
- the Windows does not allow the driver to perform site survey any more. By Bruce, 2007-10-02.
- */
+ * Turn On RF no matter the IPS setting because we need to update the RF state to Ndis under Vista, or
+ * the Windows does not allow the driver to perform site survey any more. By Bruce, 2007-10-02.
+ */
priv->RfOffReason &= (~ChangeSource);
if (!priv->RfOffReason) {
@@ -1453,25 +1326,24 @@ MgntActSet_RF_State(
if (rtState == eRfOff && ChangeSource >= RF_CHANGE_BY_HW && !priv->bInHctTest)
bConnectBySSID = true;
- } else
- ;
+ } else
+ ;
break;
case eRfOff:
- /* 070125, rcnjko: we always keep connected in AP mode. */
-
- if (priv->RfOffReason > RF_CHANGE_BY_IPS) {
- /*
- 060808, Annie:
- Disconnect to current BSS when radio off. Asked by QuanTa.
-
- Calling MgntDisconnect() instead of MgntActSet_802_11_DISASSOCIATE(),
- because we do NOT need to set ssid to dummy ones.
- */
- MgntDisconnect(dev, disas_lv_ss);
-
- /* Clear content of bssDesc[] and bssDesc4Query[] to avoid reporting old bss to UI. */
- }
+ /* 070125, rcnjko: we always keep connected in AP mode. */
+
+ if (priv->RfOffReason > RF_CHANGE_BY_IPS) {
+ /*
+ * 060808, Annie:
+ * Disconnect to current BSS when radio off. Asked by QuanTa.
+ *
+ * Calling MgntDisconnect() instead of MgntActSet_802_11_DISASSOCIATE(),
+ * because we do NOT need to set ssid to dummy ones.
+ */
+ MgntDisconnect(dev, disas_lv_ss);
+ /* Clear content of bssDesc[] and bssDesc4Query[] to avoid reporting old bss to UI. */
+ }
priv->RfOffReason |= ChangeSource;
bActionAllowed = true;
@@ -1484,14 +1356,14 @@ MgntActSet_RF_State(
break;
}
- if (bActionAllowed) {
- /* Config HW to the specified mode. */
+ if (bActionAllowed) {
+ /* Config HW to the specified mode. */
SetRFPowerState(dev, StateToSet);
/* Turn on RF. */
- if (StateToSet == eRfOn) {
+ if (StateToSet == eRfOn) {
HalEnableRx8185Dummy(dev);
- if (bConnectBySSID) {
+ if (bConnectBySSID) {
/* by amy not supported */
}
}
@@ -1507,69 +1379,61 @@ MgntActSet_RF_State(
spin_unlock_irqrestore(&priv->rf_ps_lock, flag);
return bActionAllowed;
}
-void
-InactivePowerSave(
- struct net_device *dev
- )
+
+void InactivePowerSave(struct net_device *dev)
{
struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
/*
- This flag "bSwRfProcessing", indicates the status of IPS procedure, should be set if the IPS workitem
- is really scheduled.
- The old code, sets this flag before scheduling the IPS workitem and however, at the same time the
- previous IPS workitem did not end yet, fails to schedule the current workitem. Thus, bSwRfProcessing
- blocks the IPS procedure of switching RF.
- */
+ * This flag "bSwRfProcessing", indicates the status of IPS procedure, should be set if the IPS workitem
+ * is really scheduled.
+ * The old code, sets this flag before scheduling the IPS workitem and however, at the same time the
+ * previous IPS workitem did not end yet, fails to schedule the current workitem. Thus, bSwRfProcessing
+ * blocks the IPS procedure of switching RF.
+ */
priv->bSwRfProcessing = true;
MgntActSet_RF_State(dev, priv->eInactivePowerState, RF_CHANGE_BY_IPS);
/*
- To solve CAM values miss in RF OFF, rewrite CAM values after RF ON. By Bruce, 2007-09-20.
- */
+ * To solve CAM values miss in RF OFF, rewrite CAM values after RF ON. By Bruce, 2007-09-20.
+ */
priv->bSwRfProcessing = false;
}
/*
- Description:
- Enter the inactive power save mode. RF will be off
-*/
-void
-IPSEnter(
- struct net_device *dev
- )
+ * Description:
+ * Enter the inactive power save mode. RF will be off
+ */
+void IPSEnter(struct net_device *dev)
{
struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
RT_RF_POWER_STATE rtState;
- if (priv->bInactivePs) {
+ if (priv->bInactivePs) {
rtState = priv->eRFPowerState;
/*
- Do not enter IPS in the following conditions:
- (1) RF is already OFF or Sleep
- (2) bSwRfProcessing (indicates the IPS is still under going)
- (3) Connectted (only disconnected can trigger IPS)
- (4) IBSS (send Beacon)
- (5) AP mode (send Beacon)
- */
+ * Do not enter IPS in the following conditions:
+ * (1) RF is already OFF or Sleep
+ * (2) bSwRfProcessing (indicates the IPS is still under going)
+ * (3) Connected (only disconnected can trigger IPS)
+ * (4) IBSS (send Beacon)
+ * (5) AP mode (send Beacon)
+ */
if (rtState == eRfOn && !priv->bSwRfProcessing
- && (priv->ieee80211->state != IEEE80211_LINKED)) {
+ && (priv->ieee80211->state != IEEE80211_LINKED)) {
priv->eInactivePowerState = eRfOff;
InactivePowerSave(dev);
}
}
}
-void
-IPSLeave(
- struct net_device *dev
- )
+void IPSLeave(struct net_device *dev)
{
struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
RT_RF_POWER_STATE rtState;
- if (priv->bInactivePs) {
+ if (priv->bInactivePs) {
rtState = priv->eRFPowerState;
- if ((rtState == eRfOff || rtState == eRfSleep) && (!priv->bSwRfProcessing) && priv->RfOffReason <= RF_CHANGE_BY_IPS) {
+ if ((rtState == eRfOff || rtState == eRfSleep) && (!priv->bSwRfProcessing) && priv->RfOffReason <= RF_CHANGE_BY_IPS) {
priv->eInactivePowerState = eRfOn;
InactivePowerSave(dev);
}
@@ -1582,8 +1446,8 @@ void rtl8185b_adapter_start(struct net_device *dev)
struct ieee80211_device *ieee = priv->ieee80211;
u8 SupportedWirelessMode;
- u8 InitWirelessMode;
- u8 bInvalidWirelessMode = 0;
+ u8 InitWirelessMode;
+ u8 bInvalidWirelessMode = 0;
u8 tmpu8;
u8 btCR9346;
u8 TmpU1b;
@@ -1598,89 +1462,89 @@ void rtl8185b_adapter_start(struct net_device *dev)
HwConfigureRTL8185(dev);
write_nic_dword(dev, MAC0, ((u32 *)dev->dev_addr)[0]);
write_nic_word(dev, MAC4, ((u32 *)dev->dev_addr)[1] & 0xffff);
- write_nic_byte(dev, MSR, read_nic_byte(dev, MSR) & 0xf3); /* default network type to 'No Link' */
+ write_nic_byte(dev, MSR, read_nic_byte(dev, MSR) & 0xf3); /* default network type to 'No Link' */
write_nic_word(dev, BcnItv, 100);
write_nic_word(dev, AtimWnd, 2);
PlatformIOWrite2Byte(dev, FEMR, 0xFFFF);
write_nic_byte(dev, WPA_CONFIG, 0);
MacConfig_85BASIC(dev);
- /* Override the RFSW_CTRL (MAC offset 0x272-0x273), 2006.06.07, by rcnjko. */
- /* BT_DEMO_BOARD type */
+ /* Override the RFSW_CTRL (MAC offset 0x272-0x273), 2006.06.07, by rcnjko. */
+ /* BT_DEMO_BOARD type */
PlatformIOWrite2Byte(dev, RFSW_CTRL, 0x569a);
/*
- -----------------------------------------------------------------------------
- Set up PHY related.
- -----------------------------------------------------------------------------
- */
- /* Enable Config3.PARAM_En to revise AnaaParm. */
- write_nic_byte(dev, CR9346, 0xc0); /* enable config register write */
+ *---------------------------------------------------------------------------
+ * Set up PHY related.
+ *---------------------------------------------------------------------------
+ */
+ /* Enable Config3.PARAM_En to revise AnaaParm. */
+ write_nic_byte(dev, CR9346, 0xc0); /* enable config register write */
tmpu8 = read_nic_byte(dev, CONFIG3);
write_nic_byte(dev, CONFIG3, (tmpu8 | CONFIG3_PARM_En));
- /* Turn on Analog power. */
- /* Asked for by William, otherwise, MAC 3-wire can't work, 2006.06.27, by rcnjko. */
+ /* Turn on Analog power. */
+ /* Asked for by William, otherwise, MAC 3-wire can't work, 2006.06.27, by rcnjko. */
write_nic_dword(dev, ANAPARAM2, ANAPARM2_ASIC_ON);
write_nic_dword(dev, ANAPARAM, ANAPARM_ASIC_ON);
write_nic_word(dev, ANAPARAM3, 0x0010);
write_nic_byte(dev, CONFIG3, tmpu8);
write_nic_byte(dev, CR9346, 0x00);
- /* enable EEM0 and EEM1 in 9346CR */
+ /* enable EEM0 and EEM1 in 9346CR */
btCR9346 = read_nic_byte(dev, CR9346);
write_nic_byte(dev, CR9346, (btCR9346 | 0xC0));
- /* B cut use LED1 to control HW RF on/off */
+ /* B cut use LED1 to control HW RF on/off */
TmpU1b = read_nic_byte(dev, CONFIG5);
TmpU1b = TmpU1b & ~BIT3;
write_nic_byte(dev, CONFIG5, TmpU1b);
- /* disable EEM0 and EEM1 in 9346CR */
+ /* disable EEM0 and EEM1 in 9346CR */
btCR9346 &= ~(0xC0);
write_nic_byte(dev, CR9346, btCR9346);
- /* Enable Led (suggested by Jong) */
- /* B-cut RF Radio on/off 5e[3]=0 */
+ /* Enable Led (suggested by Jong) */
+ /* B-cut RF Radio on/off 5e[3]=0 */
btPSR = read_nic_byte(dev, PSR);
write_nic_byte(dev, PSR, (btPSR | BIT3));
- /* setup initial timing for RFE. */
+ /* setup initial timing for RFE. */
write_nic_word(dev, RFPinsOutput, 0x0480);
SetOutputEnableOfRfPins(dev);
write_nic_word(dev, RFPinsSelect, 0x2488);
- /* PHY config. */
+ /* PHY config. */
PhyConfig8185(dev);
/*
- We assume RegWirelessMode has already been initialized before,
- however, we has to validate the wireless mode here and provide a
- reasonable initialized value if necessary. 2005.01.13, by rcnjko.
- */
+ * We assume RegWirelessMode has already been initialized before,
+ * however, we has to validate the wireless mode here and provide a
+ * reasonable initialized value if necessary. 2005.01.13, by rcnjko.
+ */
SupportedWirelessMode = GetSupportedWirelessMode8185(dev);
if ((ieee->mode != WIRELESS_MODE_B) &&
(ieee->mode != WIRELESS_MODE_G) &&
(ieee->mode != WIRELESS_MODE_A) &&
- (ieee->mode != WIRELESS_MODE_AUTO)) {
- /* It should be one of B, G, A, or AUTO. */
+ (ieee->mode != WIRELESS_MODE_AUTO)) {
+ /* It should be one of B, G, A, or AUTO. */
bInvalidWirelessMode = 1;
- } else {
- /* One of B, G, A, or AUTO. */
- /* Check if the wireless mode is supported by RF. */
+ } else {
+ /* One of B, G, A, or AUTO. */
+ /* Check if the wireless mode is supported by RF. */
if ((ieee->mode != WIRELESS_MODE_AUTO) &&
- (ieee->mode & SupportedWirelessMode) == 0) {
+ (ieee->mode & SupportedWirelessMode) == 0) {
bInvalidWirelessMode = 1;
}
}
- if (bInvalidWirelessMode || ieee->mode == WIRELESS_MODE_AUTO) {
- /* Auto or other invalid value. */
- /* Assigne a wireless mode to initialize. */
- if ((SupportedWirelessMode & WIRELESS_MODE_A)) {
+ if (bInvalidWirelessMode || ieee->mode == WIRELESS_MODE_AUTO) {
+ /* Auto or other invalid value. */
+ /* Assigne a wireless mode to initialize. */
+ if ((SupportedWirelessMode & WIRELESS_MODE_A)) {
InitWirelessMode = WIRELESS_MODE_A;
- } else if ((SupportedWirelessMode & WIRELESS_MODE_G)) {
+ } else if ((SupportedWirelessMode & WIRELESS_MODE_G)) {
InitWirelessMode = WIRELESS_MODE_G;
- } else if ((SupportedWirelessMode & WIRELESS_MODE_B)) {
+ } else if ((SupportedWirelessMode & WIRELESS_MODE_B)) {
InitWirelessMode = WIRELESS_MODE_B;
- } else {
+ } else {
DMESGW("InitializeAdapter8185(): No valid wireless mode supported, SupportedWirelessMode(%x)!!!\n",
SupportedWirelessMode);
InitWirelessMode = WIRELESS_MODE_B;
@@ -1690,24 +1554,21 @@ void rtl8185b_adapter_start(struct net_device *dev)
if (bInvalidWirelessMode)
ieee->mode = (WIRELESS_MODE)InitWirelessMode;
- } else {
- /* One of B, G, A. */
+ } else {
+ /* One of B, G, A. */
InitWirelessMode = ieee->mode;
}
-/* by amy for power save */
priv->eRFPowerState = eRfOff;
priv->RfOffReason = 0;
{
MgntActSet_RF_State(dev, eRfOn, 0);
}
/*
- If inactive power mode is enabled, disable rf while in disconnected state.
- */
+ * If inactive power mode is enabled, disable rf while in disconnected state.
+ */
if (priv->bInactivePs)
MgntActSet_RF_State(dev , eRfOff, RF_CHANGE_BY_IPS);
-/* by amy for power save */
-
ActSetWirelessMode8185(dev, (u8)(InitWirelessMode));
/* ----------------------------------------------------------------------------- */
@@ -1715,7 +1576,7 @@ void rtl8185b_adapter_start(struct net_device *dev)
rtl8185b_irq_enable(dev);
netif_start_queue(dev);
- }
+}
void rtl8185b_rx_enable(struct net_device *dev)
{
@@ -1728,7 +1589,7 @@ void rtl8185b_rx_enable(struct net_device *dev)
DMESG("NIC in promisc mode");
if (priv->ieee80211->iw_mode == IW_MODE_MONITOR || \
- dev->flags & IFF_PROMISC) {
+ dev->flags & IFF_PROMISC) {
priv->ReceiveConfig = priv->ReceiveConfig & (~RCR_APM);
priv->ReceiveConfig = priv->ReceiveConfig | RCR_AAP;
}
diff --git a/drivers/staging/rtl8192e/Kconfig b/drivers/staging/rtl8192e/Kconfig
index f87e21101857..4602a47cdb4a 100644
--- a/drivers/staging/rtl8192e/Kconfig
+++ b/drivers/staging/rtl8192e/Kconfig
@@ -14,6 +14,7 @@ if RTLLIB
config RTLLIB_CRYPTO_CCMP
tristate "Support for rtllib CCMP crypto"
depends on RTLLIB
+ select CRYPTO_AES
default y
---help---
CCMP crypto driver for rtllib.
@@ -23,6 +24,8 @@ config RTLLIB_CRYPTO_CCMP
config RTLLIB_CRYPTO_TKIP
tristate "Support for rtllib TKIP crypto"
depends on RTLLIB
+ select CRYPTO_ARC4
+ select CRYPTO_MICHAEL_MIC
default y
---help---
TKIP crypto driver for rtllib.
@@ -31,6 +34,7 @@ config RTLLIB_CRYPTO_TKIP
config RTLLIB_CRYPTO_WEP
tristate "Support for rtllib WEP crypto"
+ select CRYPTO_ARC4
depends on RTLLIB
default y
---help---
diff --git a/drivers/staging/rtl8192e/rtl8192e/r8192E_cmdpkt.c b/drivers/staging/rtl8192e/rtl8192e/r8192E_cmdpkt.c
index 58d044ea5524..ea91744f7ccf 100644
--- a/drivers/staging/rtl8192e/rtl8192e/r8192E_cmdpkt.c
+++ b/drivers/staging/rtl8192e/rtl8192e/r8192E_cmdpkt.c
@@ -342,7 +342,6 @@ static void cmpk_handle_tx_rate_history(struct net_device *dev, u8 *pmsg)
u32 cmpk_message_handle_rx(struct net_device *dev,
struct rtllib_rx_stats *pstats)
{
- struct r8192_priv *priv = rtllib_priv(dev);
int total_length;
u8 cmd_length, exe_cnt = 0;
u8 element_id;
@@ -409,8 +408,6 @@ u32 cmpk_message_handle_rx(struct net_device *dev,
return 1;
}
- priv->stats.rxcmdpkt[element_id]++;
-
total_length -= cmd_length;
pcmd_buff += cmd_length;
}
diff --git a/drivers/staging/rtl8192e/rtl8192e/r8192E_firmware.c b/drivers/staging/rtl8192e/rtl8192e/r8192E_firmware.c
index 37719859bdae..b526fa428679 100644
--- a/drivers/staging/rtl8192e/rtl8192e/r8192E_firmware.c
+++ b/drivers/staging/rtl8192e/rtl8192e/r8192E_firmware.c
@@ -216,7 +216,7 @@ static bool firmware_check_ready(struct net_device *dev,
break;
default:
rt_status = false;
- RT_TRACE(COMP_FIRMWARE, "Unknown firware status");
+ RT_TRACE(COMP_FIRMWARE, "Unknown firmware status");
break;
}
diff --git a/drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c b/drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c
index 3e705efaaf22..9676c591c859 100644
--- a/drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c
+++ b/drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c
@@ -689,7 +689,7 @@ void rtl8192_phy_setTxPower(struct net_device *dev, u8 channel)
case RF_8258:
break;
default:
- RT_TRACE(COMP_ERR, "unknown rf chip in funtion %s()\n",
+ RT_TRACE(COMP_ERR, "unknown rf chip in function %s()\n",
__func__);
break;
}
diff --git a/drivers/staging/rtl8192e/rtl8192e/r819xE_phyreg.h b/drivers/staging/rtl8192e/rtl8192e/r819xE_phyreg.h
index d5de279f6644..970298b07af7 100644
--- a/drivers/staging/rtl8192e/rtl8192e/r819xE_phyreg.h
+++ b/drivers/staging/rtl8192e/rtl8192e/r819xE_phyreg.h
@@ -306,7 +306,7 @@
#define bRFStart 0x0000f000
#define bBBStart 0x000000f0
#define bBBCCKStart 0x0000000f
-/* Reg)x814 */
+/* Reg x814 */
#define bPAEnd 0xf
#define bTREnd 0x0f000000
#define bRFEnd 0x000f0000
@@ -844,7 +844,7 @@
#define bRTL8258_RxLPFBW 0xc00
#define bRTL8258_RSSILPFBW 0xc0
-/* byte endable for sb_write */
+/* byte enable for sb_write */
#define bByte0 0x1
#define bByte1 0x2
#define bByte2 0x4
diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_core.c b/drivers/staging/rtl8192e/rtl8192e/rtl_core.c
index 71adb6b3344d..4f602b227b50 100644
--- a/drivers/staging/rtl8192e/rtl8192e/rtl_core.c
+++ b/drivers/staging/rtl8192e/rtl8192e/rtl_core.c
@@ -1025,7 +1025,7 @@ static int rtl8192_sta_down(struct net_device *dev, bool shutdownrf)
break;
}
RT_TRACE(COMP_DBG, "===>%s():RF is in progress, need to wait "
- "until rf chang is done.\n", __func__);
+ "until rf change is done.\n", __func__);
mdelay(1);
RFInProgressTimeOut++;
spin_lock_irqsave(&priv->rf_ps_lock, flags);
@@ -1211,7 +1211,7 @@ static void rtl8192_init_priv_variable(struct net_device *dev)
priv->AcmControl = 0;
priv->pFirmware = vzalloc(sizeof(struct rt_firmware));
if (!priv->pFirmware)
- printk(KERN_ERR "rtl8193e: Unable to allocate space "
+ printk(KERN_ERR "rtl8192e: Unable to allocate space "
"for firmware\n");
skb_queue_head_init(&priv->rx_queue);
@@ -2024,10 +2024,10 @@ short rtl8192_tx(struct net_device *dev, struct sk_buff *skb)
stype = WLAN_FC_GET_STYPE(fc);
pda_addr = header->addr1;
- if (is_multicast_ether_addr(pda_addr))
- multi_addr = true;
- else if (is_broadcast_ether_addr(pda_addr))
+ if (is_broadcast_ether_addr(pda_addr))
broad_addr = true;
+ else if (is_multicast_ether_addr(pda_addr))
+ multi_addr = true;
else
uni_addr = true;
@@ -2358,8 +2358,7 @@ static void rtl8192_rx_normal(struct net_device *dev)
stats.RxBufShift);
skb_trim(skb, skb->len - 4/*sCrcLng*/);
rtllib_hdr = (struct rtllib_hdr_1addr *)skb->data;
- if (!is_broadcast_ether_addr(rtllib_hdr->addr1) &&
- !is_multicast_ether_addr(rtllib_hdr->addr1)) {
+ if (!is_multicast_ether_addr(rtllib_hdr->addr1)) {
/* unicast packet */
unicast_packet = true;
}
diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_core.h b/drivers/staging/rtl8192e/rtl8192e/rtl_core.h
index 2a2519cc284d..320d5fc026b4 100644
--- a/drivers/staging/rtl8192e/rtl8192e/rtl_core.h
+++ b/drivers/staging/rtl8192e/rtl8192e/rtl_core.h
@@ -353,7 +353,6 @@ struct rt_stats {
unsigned long rxrdu;
unsigned long rxok;
unsigned long rxframgment;
- unsigned long rxcmdpkt[8];
unsigned long rxurberr;
unsigned long rxstaterr;
unsigned long rxdatacrcerr;
@@ -944,7 +943,7 @@ struct r8192_priv {
bool bfsync_processing;
u32 rate_record;
u32 rateCountDiffRecord;
- u32 ContiuneDiffCount;
+ u32 ContinueDiffCount;
bool bswitch_fsync;
u8 framesync;
u32 framesyncC34;
diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_dm.c b/drivers/staging/rtl8192e/rtl8192e/rtl_dm.c
index f026b7171f62..481b1e4d4913 100644
--- a/drivers/staging/rtl8192e/rtl8192e/rtl_dm.c
+++ b/drivers/staging/rtl8192e/rtl8192e/rtl_dm.c
@@ -493,7 +493,7 @@ static void dm_TXPowerTrackingCallback_TSSI(struct net_device *dev)
if (priv->bResetInProgress) {
RT_TRACE(COMP_POWER_TRACKING,
- "we are in slient reset progress, so return\n");
+ "we are in silent reset progress, so return\n");
write_nic_byte(dev, Pw_Track_Flag, 0);
write_nic_byte(dev, FW_Busy_Flag, 0);
return;
@@ -2615,22 +2615,22 @@ void dm_fsync_timer_callback(unsigned long data)
rate_count_diff;
if (DiffNum >=
priv->rtllib->fsync_seconddiff_ratethreshold)
- priv->ContiuneDiffCount++;
+ priv->ContinueDiffCount++;
else
- priv->ContiuneDiffCount = 0;
+ priv->ContinueDiffCount = 0;
- if (priv->ContiuneDiffCount >= 2) {
+ if (priv->ContinueDiffCount >= 2) {
bSwitchFromCountDiff = true;
- priv->ContiuneDiffCount = 0;
+ priv->ContinueDiffCount = 0;
}
} else {
- priv->ContiuneDiffCount = 0;
+ priv->ContinueDiffCount = 0;
}
if (rate_count_diff <=
priv->rtllib->fsync_firstdiff_ratethreshold) {
bSwitchFromCountDiff = true;
- priv->ContiuneDiffCount = 0;
+ priv->ContinueDiffCount = 0;
}
priv->rate_record = rate_count;
priv->rateCountDiffRecord = rate_count_diff;
@@ -2677,10 +2677,10 @@ void dm_fsync_timer_callback(unsigned long data)
write_nic_byte(dev, 0xC36, 0x5c);
write_nic_byte(dev, 0xC3e, 0x96);
}
- priv->ContiuneDiffCount = 0;
+ priv->ContinueDiffCount = 0;
write_nic_dword(dev, rOFDM0_RxDetector2, 0x465c52cd);
}
- RT_TRACE(COMP_HALDM, "ContiuneDiffCount %d\n", priv->ContiuneDiffCount);
+ RT_TRACE(COMP_HALDM, "ContinueDiffCount %d\n", priv->ContinueDiffCount);
RT_TRACE(COMP_HALDM, "rateRecord %d rateCount %d, rateCountdiff %d "
"bSwitchFsync %d\n", priv->rate_record, rate_count,
rate_count_diff, priv->bswitch_fsync);
@@ -2723,7 +2723,7 @@ static void dm_EndSWFsync(struct net_device *dev)
write_nic_byte(dev, 0xC3e, 0x96);
}
- priv->ContiuneDiffCount = 0;
+ priv->ContinueDiffCount = 0;
write_nic_dword(dev, rOFDM0_RxDetector2, 0x465c52cd);
}
@@ -2735,7 +2735,7 @@ static void dm_StartSWFsync(struct net_device *dev)
RT_TRACE(COMP_HALDM, "%s\n", __func__);
priv->rate_record = 0;
- priv->ContiuneDiffCount = 0;
+ priv->ContinueDiffCount = 0;
priv->rateCountDiffRecord = 0;
priv->bswitch_fsync = false;
diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_wx.c b/drivers/staging/rtl8192e/rtl8192e/rtl_wx.c
index 4e93669210af..6202358c2984 100644
--- a/drivers/staging/rtl8192e/rtl8192e/rtl_wx.c
+++ b/drivers/staging/rtl8192e/rtl8192e/rtl_wx.c
@@ -919,10 +919,10 @@ static int r8192_wx_get_retry(struct net_device *dev,
return -EINVAL;
if (wrqu->retry.flags & IW_RETRY_MAX) {
- wrqu->retry.flags = IW_RETRY_LIMIT & IW_RETRY_MAX;
+ wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_MAX;
wrqu->retry.value = priv->retry_rts;
} else {
- wrqu->retry.flags = IW_RETRY_LIMIT & IW_RETRY_MIN;
+ wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_MIN;
wrqu->retry.value = priv->retry_data;
}
return 0;
@@ -1322,9 +1322,9 @@ static struct iw_statistics *r8192_get_wireless_stats(struct net_device *dev)
struct iw_handler_def r8192_wx_handlers_def = {
.standard = r8192_wx_handlers,
- .num_standard = sizeof(r8192_wx_handlers) / sizeof(iw_handler),
+ .num_standard = ARRAY_SIZE(r8192_wx_handlers),
.private = r8192_private_handler,
- .num_private = sizeof(r8192_private_handler) / sizeof(iw_handler),
+ .num_private = ARRAY_SIZE(r8192_private_handler),
.num_private_args = sizeof(r8192_private_args) /
sizeof(struct iw_priv_args),
.get_wireless_stats = r8192_get_wireless_stats,
diff --git a/drivers/staging/rtl8192e/rtl819x_TSProc.c b/drivers/staging/rtl8192e/rtl819x_TSProc.c
index 711a096be7a7..658e875232aa 100644
--- a/drivers/staging/rtl8192e/rtl819x_TSProc.c
+++ b/drivers/staging/rtl8192e/rtl819x_TSProc.c
@@ -310,7 +310,7 @@ bool GetTs(struct rtllib_device *ieee, struct ts_common_info **ppTS,
u8 *Addr, u8 TID, enum tr_select TxRxSelect, bool bAddNewTs)
{
u8 UP = 0;
- if (is_broadcast_ether_addr(Addr) || is_multicast_ether_addr(Addr)) {
+ if (is_multicast_ether_addr(Addr)) {
RTLLIB_DEBUG(RTLLIB_DL_ERR, "ERR! get TS for Broadcast or "
"Multicast\n");
return false;
diff --git a/drivers/staging/rtl8192e/rtllib.h b/drivers/staging/rtl8192e/rtllib.h
index e26aec86a5c8..d7460ae3a765 100644
--- a/drivers/staging/rtl8192e/rtllib.h
+++ b/drivers/staging/rtl8192e/rtllib.h
@@ -169,7 +169,7 @@ struct cb_desc {
u8 nStuckCount;
- /* Tx Firmware Relaged flags (10-11)*/
+ /* Tx Firmware Related flags (10-11)*/
u8 bCTSEnable:1;
u8 bRTSEnable:1;
u8 bUseShortGI:1;
@@ -1690,7 +1690,7 @@ enum rtllib_state {
/* the association procedure is sending AUTH request*/
RTLLIB_ASSOCIATING_AUTHENTICATING,
- /* the association procedure has successfully authentcated
+ /* the association procedure has successfully authenticated
* and is sending association request
*/
RTLLIB_ASSOCIATING_AUTHENTICATED,
@@ -2409,7 +2409,7 @@ struct rtllib_device {
/* used instead of hard_start_xmit (not softmac_hard_start_xmit)
* if the IEEE_SOFTMAC_TX_QUEUE feature is used to TX data
- * frames. I the option IEEE_SOFTMAC_SINGLE_QUEUE is also set
+ * frames. If the option IEEE_SOFTMAC_SINGLE_QUEUE is also set
* then also management frames are sent via this callback.
* This function can't sleep.
*/
@@ -2422,12 +2422,12 @@ struct rtllib_device {
*/
void (*data_hard_stop)(struct net_device *dev);
- /* OK this is complementar to data_poll_hard_stop */
+ /* OK this is complementing to data_poll_hard_stop */
void (*data_hard_resume)(struct net_device *dev);
/* ask to the driver to retune the radio .
* This function can sleep. the driver should ensure
- * the radio has been swithced before return.
+ * the radio has been switched before return.
*/
void (*set_chan)(struct net_device *dev, short ch);
@@ -2438,7 +2438,7 @@ struct rtllib_device {
* The syncro version is similar to the start_scan but
* does not return until all channels has been scanned.
* this is called in user context and should sleep,
- * it is called in a work_queue when swithcing to ad-hoc mode
+ * it is called in a work_queue when switching to ad-hoc mode
* or in behalf of iwlist scan when the card is associated
* and root user ask for a scan.
* the fucntion stop_scan should stop both the syncro and
@@ -2481,7 +2481,7 @@ struct rtllib_device {
struct rtllib_network *network);
- /* check whether Tx hw resouce available */
+ /* check whether Tx hw resource available */
short (*check_nic_enough_desc)(struct net_device *dev, int queue_index);
short (*get_nic_desc_num)(struct net_device *dev, int queue_index);
void (*SetBWModeHandler)(struct net_device *dev,
@@ -2543,10 +2543,10 @@ struct rtllib_device {
/* Generate probe requests */
#define IEEE_SOFTMAC_PROBERQ (1<<4)
-/* Generate respones to probe requests */
+/* Generate response to probe requests */
#define IEEE_SOFTMAC_PROBERS (1<<5)
-/* The ieee802.11 stack will manages the netif queue
+/* The ieee802.11 stack will manage the netif queue
* wake/stop for the driver, taking care of 802.11
* fragmentation. See softmac.c for details. */
#define IEEE_SOFTMAC_TX_QUEUE (1<<7)
diff --git a/drivers/staging/rtl8192e/rtllib_rx.c b/drivers/staging/rtl8192e/rtllib_rx.c
index 13979b5ea32a..8b8a5c661a26 100644
--- a/drivers/staging/rtl8192e/rtllib_rx.c
+++ b/drivers/staging/rtl8192e/rtllib_rx.c
@@ -496,7 +496,7 @@ void rtllib_indicate_packets(struct rtllib_device *ieee, struct rtllib_rxb **prx
memcpy(skb_push(sub_skb, ETH_ALEN), prxb->dst, ETH_ALEN);
}
- /* Indicat the packets to upper layer */
+ /* Indicate the packets to upper layer */
if (sub_skb) {
stats->rx_packets++;
stats->rx_bytes += sub_skb->len;
@@ -1000,7 +1000,7 @@ static int rtllib_rx_data_filter(struct rtllib_device *ieee, u16 fc,
return -1;
/* {broad,multi}cast packets to our BSS go through */
- if (is_multicast_ether_addr(dst) || is_broadcast_ether_addr(dst)) {
+ if (is_multicast_ether_addr(dst)) {
if (memcmp(bssid, ieee->current_network.bssid, ETH_ALEN))
return -1;
}
@@ -1233,7 +1233,7 @@ static void rtllib_rx_indicate_pkt_legacy(struct rtllib_device *ieee,
if (is_multicast_ether_addr(dst))
ieee->stats.multicast++;
- /* Indicat the packets to upper layer */
+ /* Indicate the packets to upper layer */
memset(sub_skb->cb, 0, sizeof(sub_skb->cb));
sub_skb->protocol = eth_type_trans(sub_skb, dev);
sub_skb->dev = dev;
@@ -1269,7 +1269,7 @@ static int rtllib_rx_InfraAdhoc(struct rtllib_device *ieee, struct sk_buff *skb,
sc = le16_to_cpu(hdr->seq_ctl);
/*Filter pkt not to me*/
- multicast = is_multicast_ether_addr(hdr->addr1)|is_broadcast_ether_addr(hdr->addr1);
+ multicast = is_multicast_ether_addr(hdr->addr1);
unicast = !multicast;
if (unicast && (compare_ether_addr(dev->dev_addr, hdr->addr1) != 0)) {
if (ieee->bNetPromiscuousMode)
@@ -1350,7 +1350,7 @@ static int rtllib_rx_InfraAdhoc(struct rtllib_device *ieee, struct sk_buff *skb,
/* Get TS for Rx Reorder */
hdr = (struct rtllib_hdr_4addr *) skb->data;
if (ieee->current_network.qos_data.active && IsQoSDataFrame(skb->data)
- && !is_multicast_ether_addr(hdr->addr1) && !is_broadcast_ether_addr(hdr->addr1)
+ && !is_multicast_ether_addr(hdr->addr1)
&& (!bToOtherSTA)) {
TID = Frame_QoSTID(skb->data);
SeqNum = WLAN_GET_SEQ_SEQ(sc);
diff --git a/drivers/staging/rtl8192e/rtllib_softmac.c b/drivers/staging/rtl8192e/rtllib_softmac.c
index c5a15dba1bf5..a21b4d91a596 100644
--- a/drivers/staging/rtl8192e/rtllib_softmac.c
+++ b/drivers/staging/rtl8192e/rtllib_softmac.c
@@ -31,7 +31,7 @@ short rtllib_is_shortslot(const struct rtllib_network *net)
return net->capability & WLAN_CAPABILITY_SHORT_SLOT_TIME;
}
-/* returns the total length needed for pleacing the RATE MFIE
+/* returns the total length needed for placing the RATE MFIE
* tag and the EXTENDED RATE MFIE tag if needed.
* It encludes two bytes per tag for the tag itself and its len
*/
@@ -49,7 +49,7 @@ static unsigned int rtllib_MFIE_rate_len(struct rtllib_device *ieee)
return rate_len;
}
-/* pleace the MFIE rate, tag to the memory (double) poined.
+/* place the MFIE rate, tag to the memory (double) pointed.
* Then it updates the pointer so that
* it points after the new MFIE tag added.
*/
@@ -557,7 +557,7 @@ void rtllib_softmac_scan_syncro(struct rtllib_device *ieee, u8 is_mesh)
* new network events, despite for updating the net list,
* but we are temporarly 'unlinked' as the driver shall
* not filter RX frames and the channel is changing.
- * So the only situation in witch are interested is to check
+ * So the only situation in which are interested is to check
* if the state become LINKED because of the #1 situation
*/
@@ -1681,7 +1681,7 @@ inline void rtllib_softmac_new_net(struct rtllib_device *ieee,
/* if the user set the AP check if match.
* if the network does not broadcast essid we check the
- * user supplyed ANY essid
+ * user supplied ANY essid
* if the network does broadcast and the user does not set
* essid it is OK
* if the network does broadcast and the user did set essid
@@ -2444,16 +2444,16 @@ inline int rtllib_rx_frame_softmac(struct rtllib_device *ieee,
/* following are for a simplier TX queue management.
* Instead of using netif_[stop/wake]_queue the driver
- * will uses these two function (plus a reset one), that
- * will internally uses the kernel netif_* and takes
+ * will use these two functions (plus a reset one), that
+ * will internally use the kernel netif_* and takes
* care of the ieee802.11 fragmentation.
* So the driver receives a fragment per time and might
- * call the stop function when it want without take care
- * to have enought room to TX an entire packet.
- * This might be useful if each fragment need it's own
+ * call the stop function when it wants to not
+ * have enough room to TX an entire packet.
+ * This might be useful if each fragment needs it's own
* descriptor, thus just keep a total free memory > than
- * the max fragmentation treshold is not enought.. If the
- * ieee802.11 stack passed a TXB struct then you needed
+ * the max fragmentation threshold is not enough.. If the
+ * ieee802.11 stack passed a TXB struct then you need
* to keep N free descriptors where
* N = MAX_PACKET_SIZE / MIN_FRAG_TRESHOLD
* In this way you need just one and the 802.11 stack
@@ -2696,15 +2696,15 @@ static void rtllib_start_ibss_wq(void *data)
rtllib_softmac_check_all_nets(ieee);
- /* if not then the state is not linked. Maybe the user swithced to
+ /* if not then the state is not linked. Maybe the user switched to
* ad-hoc mode just after being in monitor mode, or just after
* being very few time in managed mode (so the card have had no
* time to scan all the chans..) or we have just run up the iface
* after setting ad-hoc mode. So we have to give another try..
* Here, in ibss mode, should be safe to do this without extra care
- * (in bss mode we had to make sure no-one tryed to associate when
+ * (in bss mode we had to make sure no-one tried to associate when
* we had just checked the ieee->state and we was going to start the
- * scan) beacause in ibss mode the rtllib_new_net function, when
+ * scan) because in ibss mode the rtllib_new_net function, when
* finds a good net, just set the ieee->state to RTLLIB_LINKED,
* so, at worst, we waste a bit of time to initiate an unneeded syncro
* scan, that will stop at the first round because it sees the state
@@ -2819,7 +2819,7 @@ void rtllib_start_bss(struct rtllib_device *ieee)
/* ensure no-one start an associating process (thus setting
* the ieee->state to rtllib_ASSOCIATING) while we
- * have just cheked it and we are going to enable scan.
+ * have just checked it and we are going to enable scan.
* The rtllib_new_net function is always called with
* lock held (from both rtllib_softmac_check_all_nets and
* the rx path), so we cannot be in the middle of such function
@@ -2872,7 +2872,7 @@ static void rtllib_associate_retry_wq(void *data)
/* until we do not set the state to RTLLIB_NOLINK
* there are no possibility to have someone else trying
- * to start an association procdure (we get here with
+ * to start an association procedure (we get here with
* ieee->state = RTLLIB_ASSOCIATING).
* When we set the state to RTLLIB_NOLINK it is possible
* that the RX path run an attempt to associate, but
@@ -3679,8 +3679,7 @@ void rtllib_MlmeDisassociateRequest(struct rtllib_device *rtllib, u8 *asSta,
RemovePeerTS(rtllib, asSta);
-
- if (memcpy(rtllib->current_network.bssid, asSta, 6) == NULL) {
+ if (memcmp(rtllib->current_network.bssid, asSta, 6) == 0) {
rtllib->state = RTLLIB_NOLINK;
for (i = 0; i < 6; i++)
diff --git a/drivers/staging/rtl8192e/rtllib_softmac_wx.c b/drivers/staging/rtl8192e/rtllib_softmac_wx.c
index 1523bc7a2105..1bb6b52e0f24 100644
--- a/drivers/staging/rtl8192e/rtllib_softmac_wx.c
+++ b/drivers/staging/rtl8192e/rtllib_softmac_wx.c
@@ -479,7 +479,7 @@ int rtllib_wx_set_essid(struct rtllib_device *ieee,
/* this is just to be sure that the GET wx callback
- * has consisten infos. not needed otherwise
+ * has consistent infos. not needed otherwise
*/
spin_lock_irqsave(&ieee->lock, flags);
@@ -575,7 +575,7 @@ int rtllib_wx_set_power(struct rtllib_device *ieee,
if ((!ieee->sta_wake_up) ||
(!ieee->enter_sleep_state) ||
(!ieee->ps_is_queue_empty)) {
- RTLLIB_DEBUG(RTLLIB_DL_ERR, "%s(): PS mode is tryied to be use "
+ RTLLIB_DEBUG(RTLLIB_DL_ERR, "%s(): PS mode is tried to be use "
"but driver missed a callback\n\n", __func__);
return -1;
}
diff --git a/drivers/staging/rtl8192e/rtllib_tx.c b/drivers/staging/rtl8192e/rtllib_tx.c
index f451bfc27a86..42900ee4825b 100644
--- a/drivers/staging/rtl8192e/rtllib_tx.c
+++ b/drivers/staging/rtl8192e/rtllib_tx.c
@@ -59,7 +59,7 @@
802.11 Data Frame
-802.11 frame_contorl for data frames - 2 bytes
+802.11 frame_control for data frames - 2 bytes
,-----------------------------------------------------------------------------------------.
bits | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | a | b | c | d | e |
|----|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|------|
@@ -296,8 +296,7 @@ static void rtllib_tx_query_agg_cap(struct rtllib_device *ieee,
return;
if (!IsQoSDataFrame(skb->data))
return;
- if (is_multicast_ether_addr(hdr->addr1) ||
- is_broadcast_ether_addr(hdr->addr1))
+ if (is_multicast_ether_addr(hdr->addr1))
return;
if (tcb_desc->bdhcp || ieee->CntAfterLink < 2)
@@ -515,7 +514,7 @@ u16 rtllib_query_seqnum(struct rtllib_device *ieee, struct sk_buff *skb,
{
u16 seqnum = 0;
- if (is_multicast_ether_addr(dst) || is_broadcast_ether_addr(dst))
+ if (is_multicast_ether_addr(dst))
return 0;
if (IsQoSDataFrame(skb->data)) {
struct tx_ts_record *pTS = NULL;
@@ -576,7 +575,7 @@ int rtllib_xmit_inter(struct sk_buff *skb, struct net_device *dev)
spin_lock_irqsave(&ieee->lock, flags);
- /* If there is no driver handler to take the TXB, dont' bother
+ /* If there is no driver handler to take the TXB, don't bother
* creating it... */
if ((!ieee->hard_start_xmit && !(ieee->softmac_features &
IEEE_SOFTMAC_TX_QUEUE)) ||
@@ -698,8 +697,7 @@ int rtllib_xmit_inter(struct sk_buff *skb, struct net_device *dev)
ETH_ALEN);
}
- bIsMulticast = is_broadcast_ether_addr(header.addr1) ||
- is_multicast_ether_addr(header.addr1);
+ bIsMulticast = is_multicast_ether_addr(header.addr1);
header.frame_ctl = cpu_to_le16(fc);
@@ -738,7 +736,7 @@ int rtllib_xmit_inter(struct sk_buff *skb, struct net_device *dev)
(CFG_RTLLIB_COMPUTE_FCS | CFG_RTLLIB_RESERVE_FCS))
bytes_per_frag -= RTLLIB_FCS_LEN;
- /* Each fragment may need to have room for encryptiong
+ /* Each fragment may need to have room for encrypting
* pre/postfix */
if (encrypt) {
bytes_per_frag -= crypt->ops->extra_mpdu_prefix_len +
diff --git a/drivers/staging/rtl8192e/rtllib_wx.c b/drivers/staging/rtl8192e/rtllib_wx.c
index c27ff7edbaf2..c7e8d4d8ec2b 100644
--- a/drivers/staging/rtl8192e/rtllib_wx.c
+++ b/drivers/staging/rtl8192e/rtllib_wx.c
@@ -88,7 +88,7 @@ static inline char *rtl819x_translate_scan(struct rtllib_device *ieee,
}
/* Add the protocol name */
iwe.cmd = SIOCGIWNAME;
- for (i = 0; i < (sizeof(rtllib_modes)/sizeof(rtllib_modes[0])); i++) {
+ for (i = 0; i < ARRAY_SIZE(rtllib_modes); i++) {
if (network->mode&(1<<i)) {
sprintf(pname, rtllib_modes[i].mode_string,
rtllib_modes[i].mode_size);
@@ -408,7 +408,7 @@ int rtllib_wx_set_encode(struct rtllib_device *ieee,
(*crypt)->priv);
sec.flags |= (1 << key);
/* This ensures a key will be activated if no key is
- * explicitely set */
+ * explicitly set */
if (key == sec.active_key)
sec.flags |= SEC_ACTIVE_KEY;
ieee->crypt_info.tx_keyidx = key;
diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_module.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_module.c
index e3d47bcf4cab..82d4bf6a86a5 100644
--- a/drivers/staging/rtl8192u/ieee80211/ieee80211_module.c
+++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_module.c
@@ -161,7 +161,7 @@ struct net_device *alloc_ieee80211(int sizeof_priv)
if (ieee->pHTInfo == NULL)
{
IEEE80211_DEBUG(IEEE80211_DL_ERR, "can't alloc memory for HTInfo\n");
- return NULL;
+ goto failed;
}
HTUpdateDefaultSetting(ieee);
HTInitializeHTInfo(ieee); //may move to other place.
diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c
index be2a28cf8edd..e3cf7a45b900 100644
--- a/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c
+++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c
@@ -671,7 +671,7 @@ void RxReorderIndicatePacket( struct ieee80211_device *ieee,
index = 1;
} else {
/* Current packet is going to be inserted into pending list.*/
- //IEEE80211_DEBUG(IEEE80211_DL_REORDER,"%s(): We RX no ordered packed, insert to orderd list\n",__FUNCTION__);
+ //IEEE80211_DEBUG(IEEE80211_DL_REORDER,"%s(): We RX no ordered packed, insert to ordered list\n",__FUNCTION__);
if(!list_empty(&ieee->RxReorder_Unused_List)) {
pReorderEntry = (PRX_REORDER_ENTRY)list_entry(ieee->RxReorder_Unused_List.next,RX_REORDER_ENTRY,List);
list_del_init(&pReorderEntry->List);
@@ -1285,7 +1285,7 @@ int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb,
*/
//added by amy for reorder
if(ieee->current_network.qos_data.active && IsQoSDataFrame(skb->data)
- && !is_multicast_ether_addr(hdr->addr1) && !is_broadcast_ether_addr(hdr->addr1))
+ && !is_multicast_ether_addr(hdr->addr1))
{
TID = Frame_QoSTID(skb->data);
SeqNum = WLAN_GET_SEQ_SEQ(sc);
diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c
index c2ab5fa15465..f6ff8cff313a 100644
--- a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c
+++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c
@@ -2062,7 +2062,7 @@ ieee80211_rx_frame_softmac(struct ieee80211_device *ieee, struct sk_buff *skb,
}
}else{
ieee->softmac_stats.rx_auth_rs_err++;
- IEEE80211_DEBUG_MGMT("Authentication respose status code 0x%x",errcode);
+ IEEE80211_DEBUG_MGMT("Authentication response status code 0x%x",errcode);
ieee80211_associate_abort(ieee);
}
diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_tx.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_tx.c
index 59c45a510efb..3f5ceeb88b6c 100644
--- a/drivers/staging/rtl8192u/ieee80211/ieee80211_tx.c
+++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_tx.c
@@ -314,7 +314,7 @@ void ieee80211_tx_query_agg_cap(struct ieee80211_device* ieee, struct sk_buff* s
if (!IsQoSDataFrame(skb->data))
return;
- if (is_multicast_ether_addr(hdr->addr1) || is_broadcast_ether_addr(hdr->addr1))
+ if (is_multicast_ether_addr(hdr->addr1))
return;
//check packet and mode later
#ifdef TO_DO_LIST
@@ -575,7 +575,7 @@ void ieee80211_txrate_selectmode(struct ieee80211_device* ieee, cb_desc* tcb_des
void ieee80211_query_seqnum(struct ieee80211_device*ieee, struct sk_buff* skb, u8* dst)
{
- if (is_multicast_ether_addr(dst) || is_broadcast_ether_addr(dst))
+ if (is_multicast_ether_addr(dst))
return;
if (IsQoSDataFrame(skb->data)) //we deal qos data only
{
@@ -693,8 +693,7 @@ int ieee80211_xmit(struct sk_buff *skb, struct net_device *dev)
/* Determine fragmentation size based on destination (multicast
* and broadcast are not fragmented) */
- if (is_multicast_ether_addr(header.addr1) ||
- is_broadcast_ether_addr(header.addr1)) {
+ if (is_multicast_ether_addr(header.addr1)) {
frag_size = MAX_FRAG_THRESHOLD;
qos_ctl |= QOS_CTL_NOTCONTAIN_ACK;
}
diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c b/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c
index 957ce4ef48b5..06a9824bbff1 100644
--- a/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c
+++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c
@@ -350,7 +350,7 @@ bool GetTs(
// We do not build any TS for Broadcast or Multicast stream.
// So reject these kinds of search here.
//
- if(is_broadcast_ether_addr(Addr) || is_multicast_ether_addr(Addr))
+ if (is_multicast_ether_addr(Addr))
{
IEEE80211_DEBUG(IEEE80211_DL_ERR, "get TS for Broadcast or Multicast\n");
return false;
diff --git a/drivers/staging/rtl8192u/r8180_93cx6.c b/drivers/staging/rtl8192u/r8180_93cx6.c
index 8878cfeb0fbb..3c515b7bc542 100644
--- a/drivers/staging/rtl8192u/r8180_93cx6.c
+++ b/drivers/staging/rtl8192u/r8180_93cx6.c
@@ -14,7 +14,7 @@
Parts of this driver are based on the Intel Pro Wireless 2100 GPL driver.
- We want to tanks the Authors of those projects and the Ndiswrapper
+ We want to thank the Authors of those projects and the Ndiswrapper
project Authors.
*/
diff --git a/drivers/staging/rtl8192u/r8180_93cx6.h b/drivers/staging/rtl8192u/r8180_93cx6.h
index fb3ac9766ea5..5cea51e1142e 100644
--- a/drivers/staging/rtl8192u/r8180_93cx6.h
+++ b/drivers/staging/rtl8192u/r8180_93cx6.h
@@ -7,7 +7,7 @@
Parts of this driver are based on the rtl8180 driver skeleton from Patric Schenke & Andres Salomon
Parts of this driver are based on the Intel Pro Wireless 2100 GPL driver
- We want to tanks the Authors of such projects and the Ndiswrapper project Authors.
+ We want to thank the Authors of such projects and the Ndiswrapper project Authors.
*/
/*This files contains card eeprom (93c46 or 93c56) programming routines*/
diff --git a/drivers/staging/rtl8192u/r8192U.h b/drivers/staging/rtl8192u/r8192U.h
index 9b81f26d40fe..57e3383cc935 100644
--- a/drivers/staging/rtl8192u/r8192U.h
+++ b/drivers/staging/rtl8192u/r8192U.h
@@ -11,7 +11,7 @@
Parts of this driver are based on the Intel Pro Wireless 2100 GPL driver
- We want to tanks the Authors of those projects and the Ndiswrapper
+ We want to thank the Authors of those projects and the Ndiswrapper
project Authors.
*/
@@ -98,7 +98,7 @@ do { if(rt_global_debug_component & component) \
#define COMP_INIT BIT2 // during driver initialization / halt / reset.
-#define COMP_RECV BIT3 // Reveive part data path.
+#define COMP_RECV BIT3 // Receive data path.
#define COMP_SEND BIT4 // Send part path.
#define COMP_IO BIT5 // I/O Related. Added by Annie, 2006-03-02.
#define COMP_POWER BIT6 // 802.11 Power Save mode or System/Device Power state related.
@@ -322,7 +322,7 @@ typedef struct _tx_fwinfo_819x_usb {
u8 TxSubCarrier:2; // This is used for legacy OFDM rate only.
u8 STBC:2;
u8 AllowAggregation:1;
- u8 RtsHT:1; //Interpre RtsRate field as high throughput data rate
+ u8 RtsHT:1; //Interpret RtsRate field as high throughput data rate
u8 RtsShort:1; //Short PLCP for CCK, or short GI for 11n MCS
u8 RtsBandwidth:1; // This is used for HT MCS rate only.
u8 RtsSubcarrier:2; // This is used for legacy OFDM rate only.
@@ -610,7 +610,6 @@ typedef struct Stats
// unsigned long rxnopointer;
unsigned long rxok;
unsigned long rxframgment;
- unsigned long rxcmdpkt[4]; //08/05/08 amy rx cmd element txfeedback/bcn report/cfg set/query
unsigned long rxurberr;
unsigned long rxstaterr;
unsigned long received_rate_histogram[4][32]; //0: Total, 1:OK, 2:CRC, 3:ICV, 2007 07 03 cosa
@@ -1117,7 +1116,7 @@ typedef struct r8192_priv
bool bfsync_processing; // 500ms Fsync timer is active or not
u32 rate_record;
u32 rateCountDiffRecord;
- u32 ContiuneDiffCount;
+ u32 ContinueDiffCount;
bool bswitch_fsync;
u8 framesync;
diff --git a/drivers/staging/rtl8192u/r8192U_core.c b/drivers/staging/rtl8192u/r8192U_core.c
index 9c00865f302a..5981d6658320 100644
--- a/drivers/staging/rtl8192u/r8192U_core.c
+++ b/drivers/staging/rtl8192u/r8192U_core.c
@@ -203,7 +203,7 @@ static void rtl819x_set_channel_map(u8 channel_plan, struct r8192_priv* priv)
{
Dot11d_Init(ieee);
ieee->bGlobalDomain = false;
- //acturally 8225 & 8256 rf chip only support B,G,24N mode
+ //actually 8225 & 8256 rf chips only support B,G,24N mode
if ((priv->rf_chip == RF_8225) || (priv->rf_chip == RF_8256))
{
min_chan = 1;
@@ -1103,7 +1103,7 @@ inline u16 rtl8192_rate2rate(short rate)
}
-/* The protype of rx_isr has changed since one verion of Linux Kernel */
+/* The prototype of rx_isr has changed since one version of Linux Kernel */
static void rtl8192_rx_isr(struct urb *urb)
{
struct sk_buff *skb = (struct sk_buff *) urb->context;
@@ -1476,7 +1476,7 @@ static void rtl8192_tx_isr(struct urb *tx_urb)
if(tcb_desc->queue_index != TXCMD_QUEUE) {
if(tx_urb->status == 0) {
dev->trans_start = jiffies;
- // As act as station mode, destion shall be unicast address.
+ // Act as station mode, destination shall be unicast address.
//priv->ieee80211->stats.tx_bytes+=(skb->len - priv->ieee80211->tx_headroom);
//priv->ieee80211->stats.tx_packets++;
priv->stats.txoktotal++;
@@ -1522,13 +1522,13 @@ static void rtl8192_tx_isr(struct urb *tx_urb)
else if ((skb_queue_len(&priv->ieee80211->skb_drv_aggQ[queue_index])!= 0)&&\
(!(priv->ieee80211->queue_stop))) {
// Tx Driver Aggregation process
- /* The driver will aggregation the packets according to the following stets
+ /* The driver will aggregation the packets according to the following stats
* 1. check whether there's tx irq available, for it's a completion return
* function, it should contain enough tx irq;
- * 2. check pakcet type;
+ * 2. check packet type;
* 3. initialize sendlist, check whether the to-be send packet no greater than 1
- * 4. aggregation the packets, and fill firmware info and tx desc to it, etc.
- * 5. check whehter the packet could be sent, otherwise just insert to wait head
+ * 4. aggregates the packets, and fill firmware info and tx desc into it, etc.
+ * 5. check whether the packet could be sent, otherwise just insert into wait head
* */
skb = skb_dequeue(&priv->ieee80211->skb_drv_aggQ[queue_index]);
if(!check_nic_enough_desc(dev, queue_index)) {
@@ -2447,7 +2447,7 @@ static int rtl8192_qos_handle_probe_response(struct r8192_priv *priv,
return 0;
}
-/* handle manage frame frame beacon and probe response */
+/* handle and manage frame from beacon and probe response */
static int rtl8192_handle_beacon(struct net_device * dev,
struct ieee80211_beacon * beacon,
struct ieee80211_network * network)
@@ -2625,7 +2625,7 @@ bool GetHalfNmodeSupportByAPs819xUsb(struct net_device* dev)
void rtl8192_refresh_supportrate(struct r8192_priv* priv)
{
struct ieee80211_device* ieee = priv->ieee80211;
- //we donot consider set support rate for ABG mode, only HT MCS rate is set here.
+ //we do not consider set support rate for ABG mode, only HT MCS rate is set here.
if (ieee->mode == WIRELESS_MODE_N_24G || ieee->mode == WIRELESS_MODE_N_5G)
{
memcpy(ieee->Regdot11HTOperationalRateSet, ieee->RegHTSuppRateSet, 16);
@@ -2780,10 +2780,10 @@ static void rtl8192_init_priv_variable(struct net_device* dev)
priv->TransmitConfig =
// TCR_DurProcMode | //for RTL8185B, duration setting by HW
//? TCR_DISReqQsize |
- (TCR_MXDMA_2048<<TCR_MXDMA_OFFSET)| // Max DMA Burst Size per Tx DMA Burst, 7: reservied.
+ (TCR_MXDMA_2048<<TCR_MXDMA_OFFSET)| // Max DMA Burst Size per Tx DMA Burst, 7: reserved.
(priv->ShortRetryLimit<<TCR_SRL_OFFSET)| // Short retry limit
(priv->LongRetryLimit<<TCR_LRL_OFFSET) | // Long retry limit
- (false ? TCR_SAT: 0); // FALSE: HW provies PLCP length and LENGEXT, TURE: SW proiveds them
+ (false ? TCR_SAT: 0); // FALSE: HW provides PLCP length and LENGEXT, TRUE: SW provides them
#ifdef TO_DO_LIST
if(Adapter->bInHctTest)
pHalData->ReceiveConfig = pHalData->CSMethod |
@@ -3437,7 +3437,7 @@ if(Adapter->ResetProgress == RESET_TYPE_NORESET)
{ // User disable RF via registry.
RT_TRACE((COMP_INIT|COMP_RF), DBG_LOUD, ("InitializeAdapter819xUsb(): Turn off RF for RegRfOff ----------\n"));
MgntActSet_RF_State(Adapter, eRfOff, RF_CHANGE_BY_SW);
- // Those action will be discard in MgntActSet_RF_State because off the same state
+ // Those actions will be discard in MgntActSet_RF_State because of the same state
for(eRFPath = 0; eRFPath <pHalData->NumTotalRFPath; eRFPath++)
PHY_SetRFReg(Adapter, (RF90_RADIO_PATH_E)eRFPath, 0x4, 0xC00, 0x0);
}
@@ -3458,7 +3458,7 @@ if(Adapter->ResetProgress == RESET_TYPE_NORESET)
if(pHalData->eRFPowerState == eRfOff)
{
MgntActSet_RF_State(Adapter, eRfOff, pMgntInfo->RfOffReason);
- // Those action will be discard in MgntActSet_RF_State because off the same state
+ // Those actions will be discard in MgntActSet_RF_State because of the same state
for(eRFPath = 0; eRFPath <pHalData->NumTotalRFPath; eRFPath++)
PHY_SetRFReg(Adapter, (RF90_RADIO_PATH_E)eRFPath, 0x4, 0xC00, 0x0);
}
@@ -3586,7 +3586,7 @@ TxCheckStuck(struct net_device *dev)
//unsigned long flags;
//
- // Decide Stuch threshold according to current power save mode
+ // Decide such threshold according to current power save mode
//
// RT_TRACE(COMP_RESET, " ==> TxCheckStuck()\n");
@@ -3745,7 +3745,7 @@ rtl819x_ifcheck_resetornot(struct net_device *dev)
// Driver should not check RX stuck in IBSS mode because it is required to
// set Check BSSID in order to send beacon, however, if check BSSID is
- // set, STA cannot hear any packet a all. Emily, 2008.04.12
+ // set, STA cannot hear any packet at all. Emily, 2008.04.12
RxResetType = RxCheckStuck(dev);
}
if(TxResetType==RESET_TYPE_NORMAL || RxResetType==RESET_TYPE_NORMAL)
@@ -3962,7 +3962,7 @@ RESET_START:
up(&priv->wx_sem);
RT_TRACE(COMP_RESET,"%s():<==========down process is finished\n",__FUNCTION__);
//rtl8192_irq_disable(dev);
- RT_TRACE(COMP_RESET,"%s():===========>start to up the driver\n",__FUNCTION__);
+ RT_TRACE(COMP_RESET,"%s():===========>start up the driver\n",__FUNCTION__);
reset_status = _rtl8192_up(dev);
RT_TRACE(COMP_RESET,"%s():<===========up process is finished\n",__FUNCTION__);
@@ -4155,7 +4155,7 @@ extern void rtl819x_watchdog_wqcallback(struct work_struct *work)
void watch_dog_timer_callback(unsigned long data)
{
struct r8192_priv *priv = ieee80211_priv((struct net_device *) data);
- //printk("===============>watch_dog timer\n");
+ //printk("===============>watch_dog timer\n");
queue_delayed_work(priv->priv_wq,&priv->watch_dog_wq, 0);
mod_timer(&priv->watch_dog_timer, jiffies + MSECS(IEEE80211_WATCH_DOG_TIME));
}
@@ -4170,7 +4170,7 @@ int _rtl8192_up(struct net_device *dev)
init_status = rtl8192_adapter_start(dev);
if(!init_status)
{
- RT_TRACE(COMP_ERR,"ERR!!! %s(): initialization is failed!\n", __FUNCTION__);
+ RT_TRACE(COMP_ERR,"ERR!!! %s(): initialization failed!\n", __FUNCTION__);
priv->up=priv->ieee80211->ieee_up = 0;
return -EAGAIN;
}
@@ -4256,7 +4256,7 @@ int rtl8192_down(struct net_device *dev)
skb_queue_purge(&priv->ieee80211->skb_drv_aggQ [i]);
}
- //as cancel_delayed_work will del work->timer, so if work is not definedas struct delayed_work, it will corrupt
+ //as cancel_delayed_work will del work->timer, so if work is not defined as struct delayed_work, it will corrupt
// flush_scheduled_work();
rtl8192_cancel_deferred_work(priv);
deinit_hal_dm(dev);
@@ -4516,7 +4516,7 @@ u8 HwRateToMRate90(bool bIsHT, u8 rate)
/**
* Function: UpdateRxPktTimeStamp
- * Overview: Recored down the TSF time stamp when receiving a packet
+ * Overview: Record the TSF time stamp when receiving a packet
*
* Input:
* PADAPTER Adapter
@@ -4556,10 +4556,10 @@ long rtl819x_translate_todbm(u8 signal_strength_index )// 0-100 index.
}
-/* 2008/01/22 MH We can not delcare RSSI/EVM total value of sliding window to
+/* 2008/01/22 MH We can not declare RSSI/EVM total value of sliding window to
be a local static. Otherwise, it may increase when we return from S3/S4. The
- value will be kept in memory or disk. We must delcare the value in adapter
- and it will be reinitialized when return from S3/S4. */
+ value will be kept in memory or disk. Declare the value in the adaptor
+ and it will be reinitialized when returned from S3/S4. */
void rtl8192_process_phyinfo(struct r8192_priv * priv,u8* buffer, struct ieee80211_rx_stats * pprevious_stats, struct ieee80211_rx_stats * pcurrent_stats)
{
bool bcheck = false;
@@ -5091,8 +5091,8 @@ static void rtl8192_query_rxphystatus(
tmp_rxevm = pofdm_buf->rxevm_X[i];
rx_evmX = (char)(tmp_rxevm);
- // Do not use shift operation like "rx_evmX >>= 1" because the compilor of free build environment
- // fill most significant bit to "zero" when doing shifting operation which may change a negative
+ // Do not use shift operation like "rx_evmX >>= 1" because the compiler of free build environment
+ // will set the most significant bit to "zero" when doing shifting operation which may change a negative
// value to positive one, then the dbm value (which is supposed to be negative) is not correct anymore.
rx_evmX /= 2; //dbm
@@ -5171,7 +5171,7 @@ void TranslateRxSignalStuff819xUsb(struct sk_buff *skb,
type = WLAN_FC_GET_TYPE(fc);
praddr = hdr->addr1;
- /* Check if the received packet is acceptabe. */
+ /* Check if the received packet is acceptable. */
bpacket_match_bssid = ((IEEE80211_FTYPE_CTL != type) &&
(eqMacAddr(priv->ieee80211->current_network.bssid, (fc & IEEE80211_FCTL_TODS)? hdr->addr1 : (fc & IEEE80211_FCTL_FROMDS )? hdr->addr2 : hdr->addr3))
&& (!pstats->bHwError) && (!pstats->bCRC)&& (!pstats->bICV));
@@ -5211,7 +5211,7 @@ void TranslateRxSignalStuff819xUsb(struct sk_buff *skb,
/**
* Function: UpdateReceivedRateHistogramStatistics
-* Overview: Recored down the received data rate
+* Overview: Record the received data rate
*
* Input:
* struct net_device *dev
@@ -5401,7 +5401,7 @@ void query_rxdesc_status(struct sk_buff *skb, struct ieee80211_rx_stats *stats,
}
#ifdef USB_RX_AGGREGATION_SUPPORT
- /* for the rx aggregated sub frame, the redundant space truelly contained in the packet */
+ /* for the rx aggregated sub frame, the redundant space truly contained in the packet */
if(bIsRxAggrSubframe) {
skb_pull(skb, 8);
}
@@ -5480,7 +5480,7 @@ void rtl8192_rx_nomal(struct sk_buff* skb)
PacketShiftBytes = GetRxPacketShiftBytes819xUsb(&stats, false);
}
#endif
- /* Process the MPDU recevied */
+ /* Process the MPDU received */
skb_trim(skb, skb->len - 4/*sCrcLng*/);
rx_pkt_len = skb->len;
@@ -5538,7 +5538,7 @@ void rtl8192_rx_nomal(struct sk_buff* skb)
if(PacketLength > agg_skb->len) {
break;
}
- /* Process the MPDU recevied */
+ /* Process the MPDU received */
skb = dev_alloc_skb(PacketLength);
memcpy(skb_put(skb,PacketLength),agg_skb->data, PacketLength);
skb_trim(skb, skb->len - 4/*sCrcLng*/);
diff --git a/drivers/staging/rtl8192u/r8192U_dm.c b/drivers/staging/rtl8192u/r8192U_dm.c
index 2dde9fa5c21e..cd8dc85e9c0f 100644
--- a/drivers/staging/rtl8192u/r8192U_dm.c
+++ b/drivers/staging/rtl8192u/r8192U_dm.c
@@ -38,7 +38,7 @@ static u32 edca_setting_UL[HT_IOT_PEER_MAX] =
/*------------------------Define global variable-----------------------------*/
// Debug variable ?
dig_t dm_digtable;
-// Store current shoftware write register content for MAC PHY.
+// Store current software write register content for MAC PHY.
u8 dm_shadow[16][256] = {{0}};
// For Dynamic Rx Path Selection by Signal Strength
DRxPathSel DM_RxPathSelTable;
@@ -119,7 +119,7 @@ static void dm_pd_th(struct net_device *dev);
static void dm_cs_ratio(struct net_device *dev);
static void dm_init_ctstoself(struct net_device *dev);
-// DM --> EDCA turboe mode control
+// DM --> EDCA turbo mode control
static void dm_check_edca_turbo(struct net_device *dev);
// DM --> HW RF control
@@ -348,7 +348,7 @@ extern void init_rate_adaptive(struct net_device * dev)
*
* Revised History:
* When Who Remark
- * 05/26/08 amy Create version 0 proting from windows code.
+ * 05/26/08 amy Create version 0 porting from windows code.
*
*---------------------------------------------------------------------------*/
static void dm_check_rate_adaptive(struct net_device * dev)
@@ -543,7 +543,7 @@ static u32 OFDMSwingTable[OFDM_Table_Length] = {
0x5a400169, // 3, +3db
0x50800142, // 4, +2db
0x47c0011f, // 5, +1db
- 0x40000100, // 6, +0db ===> default, upper for higher temprature, lower for low temprature
+ 0x40000100, // 6, +0db ===> default, upper for higher temperature, lower for low temperature
0x390000e4, // 7, -1db
0x32c000cb, // 8, -2db
0x2d4000b5, // 9, -3db
@@ -678,7 +678,7 @@ static void dm_TXPowerTrackingCallback_TSSI(struct net_device * dev)
{
write_nic_byte(dev, 0x1ba, 0);
viviflag = FALSE;
- RT_TRACE(COMP_POWER_TRACKING, "we filted this data\n");
+ RT_TRACE(COMP_POWER_TRACKING, "we filtered the data\n");
for(k = 0;k < 5; k++)
tmp_report[k] = 0;
break;
@@ -864,14 +864,14 @@ static void dm_TXPowerTrackingCallback_ThermalMeter(struct net_device * dev)
RT_TRACE(COMP_POWER_TRACKING, "Readback ThermalMeterA = %d \n", tmpRegA);
if(tmpRegA < 3 || tmpRegA > 13)
return;
- if(tmpRegA >= 12) // if over 12, TP will be bad when high temprature
+ if(tmpRegA >= 12) // if over 12, TP will be bad when high temperature
tmpRegA = 12;
RT_TRACE(COMP_POWER_TRACKING, "Valid ThermalMeterA = %d \n", tmpRegA);
priv->ThermalMeter[0] = ThermalMeterVal; //We use fixed value by Bryant's suggestion
priv->ThermalMeter[1] = ThermalMeterVal; //We use fixed value by Bryant's suggestion
- //Get current RF-A temprature index
- if(priv->ThermalMeter[0] >= (u8)tmpRegA) //lower temprature
+ //Get current RF-A temperature index
+ if(priv->ThermalMeter[0] >= (u8)tmpRegA) //lower temperature
{
tmpOFDMindex = tmpCCK20Mindex = 6+(priv->ThermalMeter[0]-(u8)tmpRegA);
tmpCCK40Mindex = tmpCCK20Mindex - 6;
@@ -885,7 +885,7 @@ static void dm_TXPowerTrackingCallback_ThermalMeter(struct net_device * dev)
else
{
tmpval = ((u8)tmpRegA - priv->ThermalMeter[0]);
- if(tmpval >= 6) // higher temprature
+ if(tmpval >= 6) // higher temperature
tmpOFDMindex = tmpCCK20Mindex = 0; // max to +6dB
else
tmpOFDMindex = tmpCCK20Mindex = 6 - tmpval;
@@ -1457,9 +1457,9 @@ static void dm_InitializeTXPowerTracking_ThermalMeter(struct net_device *dev)
{
struct r8192_priv *priv = ieee80211_priv(dev);
- // Tx Power tracking by Theremal Meter require Firmware R/W 3-wire. This mechanism
+ // Tx Power tracking by Thermal Meter requires Firmware R/W 3-wire. This mechanism
// can be enabled only when Firmware R/W 3-wire is enabled. Otherwise, frequent r/w
- // 3-wire by driver cause RF goes into wrong state.
+ // 3-wire by driver causes RF to go into a wrong state.
if(priv->ieee80211->FwRWRF)
priv->btxpower_tracking = TRUE;
else
@@ -1520,7 +1520,7 @@ static void dm_CheckTXPowerTracking_ThermalMeter(struct net_device *dev)
if(!TM_Trigger)
{
- //Attention!! You have to wirte all 12bits data to RF, or it may cause RF to crash
+ //Attention!! You have to write all 12bits of data to RF, or it may cause RF to crash
//actually write reg0x02 bit1=0, then bit1=1.
//DbgPrint("Trigger ThermalMeter, write RF reg0x2 = 0x4d to 0x4f\n");
rtl8192_phy_SetRFReg(dev, RF90_PATH_A, 0x02, bMask12Bits, 0x4d);
@@ -1744,7 +1744,7 @@ extern void dm_restore_dynamic_mechanism_state(struct net_device *dev)
write_nic_dword(dev, RATR0, ratr_value);
write_nic_byte(dev, UFWP, 1);
}
- //Resore TX Power Tracking Index
+ //Restore TX Power Tracking Index
if(priv->btxpower_trackingInit && priv->btxpower_tracking){
dm_txpower_reset_recovery(dev);
}
@@ -2031,7 +2031,7 @@ static void dm_dig_init(struct net_device *dev)
dm_digtable.dbg_mode = DM_DBG_OFF; //off=by real rssi value, on=by DM_DigTable.Rssi_val for new dig
dm_digtable.dig_algorithm_switch = 0;
- /* 2007/10/04 MH Define init gain threshol. */
+ /* 2007/10/04 MH Define init gain threshold. */
dm_digtable.dig_state = DM_STA_DIG_MAX;
dm_digtable.dig_highpwr_state = DM_STA_DIG_MAX;
dm_digtable.initialgain_lowerbound_state = false;
@@ -2097,7 +2097,7 @@ static void dm_ctrl_initgain_byrssi_by_driverrssi(
return;
//DbgPrint("Dig by Sw Rssi \n");
- if(dm_digtable.dig_algorithm_switch) // if swithed algorithm, we have to disable FW Dig.
+ if(dm_digtable.dig_algorithm_switch) // if switched algorithm, we have to disable FW Dig.
fw_dig = 0;
if(fw_dig <= 3) // execute several times to make sure the FW Dig is disabled
{// FW DIG Off
@@ -2160,8 +2160,8 @@ static void dm_ctrl_initgain_byrssi_by_fwfalse_alarm(
/*DbgPrint("DIG Check\n\r RSSI=%d LOW=%d HIGH=%d STATE=%d",
pHalData->UndecoratedSmoothedPWDB, DM_DigTable.RssiLowThresh,
DM_DigTable.RssiHighThresh, DM_DigTable.Dig_State);*/
- /* 1. When RSSI decrease, We have to judge if it is smaller than a treshold
- and then execute below step. */
+ /* 1. When RSSI decrease, We have to judge if it is smaller than a threshold
+ and then execute the step below. */
if ((priv->undecorated_smoothed_pwdb <= dm_digtable.rssi_low_thresh))
{
/* 2008/02/05 MH When we execute silent reset, the DIG PHY parameters
@@ -2220,8 +2220,8 @@ static void dm_ctrl_initgain_byrssi_by_fwfalse_alarm(
}
- /* 2. When RSSI increase, We have to judge if it is larger than a treshold
- and then execute below step. */
+ /* 2. When RSSI increase, We have to judge if it is larger than a threshold
+ and then execute the step below. */
if ((priv->undecorated_smoothed_pwdb >= dm_digtable.rssi_high_thresh) )
{
u8 reset_flag = 0;
@@ -2329,7 +2329,7 @@ static void dm_ctrl_initgain_byrssi_highpwr(
}
/* 3. When RSSI >75% or <70%, it is a high power issue. We have to judge if
- it is larger than a treshold and then execute below step. */
+ it is larger than a threshold and then execute the step below. */
// 2008/02/05 MH SD3-Jerry Modify PD_TH for high power issue.
if (priv->undecorated_smoothed_pwdb >= dm_digtable.rssi_high_power_highthresh)
{
@@ -2841,8 +2841,8 @@ static void dm_check_rfctrl_gpio(struct net_device * dev)
{
//struct r8192_priv *priv = ieee80211_priv(dev);
- // Walk around for DTM test, we will not enable HW - radio on/off because r/w
- // page 1 register before Lextra bus is enabled cause system fails when resuming
+ // Work around for DTM test, we will not enable HW - radio on/off because r/w
+ // page 1 register before extra bus is enabled causing system failures when resuming
// from S4. 20080218, Emily
// Stop to execute workitem to prevent S3/S4 bug.
@@ -3377,30 +3377,30 @@ extern void dm_fsync_timer_callback(unsigned long data)
{
u32 DiffNum = priv->rateCountDiffRecord - rate_count_diff;
- // Contiune count
+ // Continue count
if(DiffNum >= priv->ieee80211->fsync_seconddiff_ratethreshold)
- priv->ContiuneDiffCount++;
+ priv->ContinueDiffCount++;
else
- priv->ContiuneDiffCount = 0;
+ priv->ContinueDiffCount = 0;
- // Contiune count over
- if(priv->ContiuneDiffCount >=2)
+ // Continue count over
+ if(priv->ContinueDiffCount >=2)
{
bSwitchFromCountDiff = true;
- priv->ContiuneDiffCount = 0;
+ priv->ContinueDiffCount = 0;
}
}
else
{
- // Stop contiune count
- priv->ContiuneDiffCount = 0;
+ // Stop the continued count
+ priv->ContinueDiffCount = 0;
}
//If Count diff <= FsyncRateCountThreshold
if(rate_count_diff <= priv->ieee80211->fsync_firstdiff_ratethreshold)
{
bSwitchFromCountDiff = true;
- priv->ContiuneDiffCount = 0;
+ priv->ContinueDiffCount = 0;
}
priv->rate_record = rate_count;
priv->rateCountDiffRecord = rate_count_diff;
@@ -3468,14 +3468,14 @@ extern void dm_fsync_timer_callback(unsigned long data)
#endif
write_nic_byte(dev, 0xC3e, 0x96);
}
- priv->ContiuneDiffCount = 0;
+ priv->ContinueDiffCount = 0;
#ifdef RTL8190P
write_nic_dword(dev, rOFDM0_RxDetector2, 0x164052cd);
#else
write_nic_dword(dev, rOFDM0_RxDetector2, 0x465c52cd);
#endif
}
- RT_TRACE(COMP_HALDM, "ContiuneDiffCount %d\n", priv->ContiuneDiffCount);
+ RT_TRACE(COMP_HALDM, "ContinueDiffCount %d\n", priv->ContinueDiffCount);
RT_TRACE(COMP_HALDM, "rateRecord %d rateCount %d, rateCountdiff %d bSwitchFsync %d\n", priv->rate_record, rate_count, rate_count_diff , priv->bswitch_fsync);
}
@@ -3507,7 +3507,7 @@ static void dm_EndSWFsync(struct net_device *dev)
write_nic_byte(dev, 0xC3e, 0x96);
}
- priv->ContiuneDiffCount = 0;
+ priv->ContinueDiffCount = 0;
#ifndef RTL8190P
write_nic_dword(dev, rOFDM0_RxDetector2, 0x465c52cd);
#endif
@@ -3523,8 +3523,8 @@ static void dm_StartSWFsync(struct net_device *dev)
RT_TRACE(COMP_HALDM,"%s\n", __FUNCTION__);
// Initial rate record to zero, start to record.
priv->rate_record = 0;
- // Initial contiune diff count to zero, start to record.
- priv->ContiuneDiffCount = 0;
+ // Initialize continue diff count to zero, start to record.
+ priv->ContinueDiffCount = 0;
priv->rateCountDiffRecord = 0;
priv->bswitch_fsync = false;
@@ -3875,7 +3875,7 @@ static void dm_send_rssi_tofw(struct net_device *dev)
// If we test chariot, we should stop the TX command ?
// Because 92E will always silent reset when we send tx command. We use register
- // 0x1e0(byte) to botify driver.
+ // 0x1e0(byte) to notify driver.
write_nic_byte(dev, DRIVER_RSSI, (u8)priv->undecorated_smoothed_pwdb);
return;
tx_cmd.Op = TXCMD_SET_RX_RSSI;
diff --git a/drivers/staging/rtl8192u/r8192U_hw.h b/drivers/staging/rtl8192u/r8192U_hw.h
index e89aaf70143b..1bfe871dcfb2 100644
--- a/drivers/staging/rtl8192u/r8192U_hw.h
+++ b/drivers/staging/rtl8192u/r8192U_hw.h
@@ -10,7 +10,7 @@
Parts of this driver are based on the Intel Pro Wireless
2100 GPL driver.
- We want to tanks the Authors of those projects
+ We want to thank the Authors of those projects
and the Ndiswrapper project Authors.
*/
diff --git a/drivers/staging/rtl8192u/r8192U_wx.c b/drivers/staging/rtl8192u/r8192U_wx.c
index f6408f98ede6..71f2d2349c38 100644
--- a/drivers/staging/rtl8192u/r8192U_wx.c
+++ b/drivers/staging/rtl8192u/r8192U_wx.c
@@ -13,7 +13,7 @@
Parts of this driver are based on the Intel Pro Wireless 2100 GPL driver.
- We want to tanks the Authors of those projects and the Ndiswrapper
+ We want to thank the Authors of those projects and the Ndiswrapper
project Authors.
*/
@@ -256,7 +256,7 @@ static int r8192_wx_get_ap_status(struct net_device *dev,
//count the length of input ssid
for(name_len=0 ; ((char*)wrqu->data.pointer)[name_len]!='\0' ; name_len++);
- //search for the correspoding info which is received
+ //search for the corresponding info which is received
list_for_each_entry(target, &ieee->network_list, list) {
if ( (target->ssid_len == name_len) &&
(strncmp(target->ssid, (char*)wrqu->data.pointer, name_len)==0)){
@@ -419,7 +419,7 @@ static int rtl8180_wx_get_range(struct net_device *dev,
range->max_qual.updated = 7; /* Updated all three */
range->avg_qual.qual = 92; /* > 8% missed beacons is 'bad' */
- /* TODO: Find real 'good' to 'bad' threshol value for RSSI */
+ /* TODO: Find real 'good' to 'bad' threshold value for RSSI */
range->avg_qual.level = 20 + -98;
range->avg_qual.noise = 0;
range->avg_qual.updated = 7; /* Updated all three */
@@ -1047,7 +1047,7 @@ static iw_handler r8192_wx_handlers[] =
#else
NULL,
#endif
- dummy, /* SIOCGIWAPLIST -- depricated */
+ dummy, /* SIOCGIWAPLIST -- deprecated */
r8192_wx_set_scan, /* SIOCSIWSCAN */
r8192_wx_get_scan, /* SIOCGIWSCAN */
r8192_wx_set_essid, /* SIOCSIWESSID */
@@ -1211,9 +1211,9 @@ struct iw_statistics *r8192_get_wireless_stats(struct net_device *dev)
struct iw_handler_def r8192_wx_handlers_def={
.standard = r8192_wx_handlers,
- .num_standard = sizeof(r8192_wx_handlers) / sizeof(iw_handler),
+ .num_standard = ARRAY_SIZE(r8192_wx_handlers),
.private = r8192_private_handler,
- .num_private = sizeof(r8192_private_handler) / sizeof(iw_handler),
+ .num_private = ARRAY_SIZE(r8192_private_handler),
.num_private_args = sizeof(r8192_private_args) / sizeof(struct iw_priv_args),
#if WIRELESS_EXT >= 17
.get_wireless_stats = r8192_get_wireless_stats,
diff --git a/drivers/staging/rtl8192u/r8192U_wx.h b/drivers/staging/rtl8192u/r8192U_wx.h
index f4cf2801136a..9f6b10505426 100644
--- a/drivers/staging/rtl8192u/r8192U_wx.h
+++ b/drivers/staging/rtl8192u/r8192U_wx.h
@@ -7,7 +7,7 @@
Parts of this driver are based on the rtl8180 driver skeleton from Patric Schenke & Andres Salomon
Parts of this driver are based on the Intel Pro Wireless 2100 GPL driver
- We want to tanks the Authors of such projects and the Ndiswrapper project Authors.
+ We want to thank the Authors of such projects and the Ndiswrapper project Authors.
*/
/* this file (will) contains wireless extension handlers*/
diff --git a/drivers/staging/rtl8192u/r819xU_HTType.h b/drivers/staging/rtl8192u/r819xU_HTType.h
index 2ac421626e7c..e07f8b17a0d6 100644
--- a/drivers/staging/rtl8192u/r819xU_HTType.h
+++ b/drivers/staging/rtl8192u/r819xU_HTType.h
@@ -211,7 +211,7 @@ typedef struct _RT_HIGH_THROUGHPUT{
u8 bEnableHT;
u8 bCurrentHTSupport;
- u8 bRegBW40MHz; // Tx 40MHz channel capablity
+ u8 bRegBW40MHz; // Tx 40MHz channel capability
u8 bCurBW40MHz; // Tx 40MHz channel capability
u8 bRegShortGI40MHz; // Tx Short GI for 40Mhz
diff --git a/drivers/staging/rtl8192u/r819xU_cmdpkt.c b/drivers/staging/rtl8192u/r819xU_cmdpkt.c
index 0cb28c776c49..a8a6dc2c365f 100644
--- a/drivers/staging/rtl8192u/r819xU_cmdpkt.c
+++ b/drivers/staging/rtl8192u/r819xU_cmdpkt.c
@@ -157,7 +157,7 @@ SendTxCommandPacket(
seg_ptr = skb_put(skb, buffer_len);
/*
* Transform from little endian to big endian
- * and pending zero
+ * and pending zero
*/
memcpy(seg_ptr,codevirtualaddress,buffer_len);
tcb_desc->txbuf_size= (u16)buffer_len;
@@ -697,7 +697,6 @@ cmpk_message_handle_rx(
struct ieee80211_rx_stats *pstats)
{
// u32 debug_level = DBG_LOUD;
- struct r8192_priv *priv = ieee80211_priv(dev);
int total_length;
u8 cmd_length, exe_cnt = 0;
u8 element_id;
@@ -719,15 +718,15 @@ cmpk_message_handle_rx(
/* 2. Read virtual address from RFD. */
pcmd_buff = pstats->virtual_address;
- /* 3. Read command pakcet element id and length. */
+ /* 3. Read command packet element id and length. */
element_id = pcmd_buff[0];
/*RT_TRACE(COMP_SEND, DebugLevel,
("\n\r[CMPK]-->element ID=%d Len=%d", element_id, total_length));*/
- /* 4. Check every received command packet conent according to different
+ /* 4. Check every received command packet content according to different
element type. Because FW may aggregate RX command packet to minimize
transmit time between DRV and FW.*/
- // Add a counter to prevent to locked in the loop too long
+ // Add a counter to prevent the lock in the loop from being held too long
while (total_length > 0 || exe_cnt++ >100)
{
/* 2007/01/17 MH We support aggregation of different cmd in the same packet. */
@@ -779,9 +778,6 @@ cmpk_message_handle_rx(
// 2007/01/22 MH Add to display tx statistic.
//cmpk_DisplayTxStatistic(pAdapter);
- /* 2007/03/09 MH Collect sidderent cmd element pkt num. */
- priv->stats.rxcmdpkt[element_id]++;
-
total_length -= cmd_length;
pcmd_buff += cmd_length;
} /* while (total_length > 0) */
diff --git a/drivers/staging/rtl8192u/r819xU_firmware.c b/drivers/staging/rtl8192u/r819xU_firmware.c
index 4bb5fffca5b9..b12d19079798 100644
--- a/drivers/staging/rtl8192u/r819xU_firmware.c
+++ b/drivers/staging/rtl8192u/r819xU_firmware.c
@@ -275,11 +275,11 @@ bool init_firmware(struct net_device *dev)
/*
* Download boot, main, and data image for System reset.
- * Download data image for firmware reseta
+ * Download data image for firmware reset
*/
for(init_step = starting_state; init_step <= FW_INIT_STEP2_DATA; init_step++) {
/*
- * Open Image file, and map file to contineous memory if open file success.
+ * Open image file, and map file to continuous memory if open file success.
* or read image file from array. Default load from IMG file
*/
if(rst_opt == OPT_SYSTEM_RESET) {
diff --git a/drivers/staging/rtl8192u/r819xU_phy.c b/drivers/staging/rtl8192u/r819xU_phy.c
index c4586b0817d1..dd1954daea2d 100644
--- a/drivers/staging/rtl8192u/r819xU_phy.c
+++ b/drivers/staging/rtl8192u/r819xU_phy.c
@@ -40,7 +40,7 @@ static u32 RF_CHANNEL_TABLE_ZEBRA[] = {
* and do register read/write
* input: u32 dwBitMask //taget bit pos in the addr to be modified
* output: none
- * return: u32 return the shift bit bit position of the mask
+ * return: u32 return the shift bit position of the mask
* ****************************************************************************/
u32 rtl8192_CalculateBitShift(u32 dwBitMask)
{
@@ -176,7 +176,7 @@ u32 rtl8192_phy_RFSerialRead(struct net_device* dev, RF90_RADIO_PATH_E eRFPath,
rtl8192_setBBreg(dev, pPhyReg->rfHSSIPara2, bLSSIReadEdge, 0x1);
- // TODO: we should not delay such a long time. Ask help from SD3
+ // TODO: we should not delay such a long time. Ask for help from SD3
msleep(1);
ret = rtl8192_QueryBBReg(dev, pPhyReg->rfLSSIReadBack, bLSSIReadBackData);
@@ -252,7 +252,7 @@ void rtl8192_phy_RFSerialWrite(struct net_device* dev, RF90_RADIO_PATH_E eRFPath
NewOffset = Offset;
}
- // Put write addr in [5:0] and write data in [31:16]
+ // Put write addr in [5:0] and write data in [31:16]
DataAndAddr = (Data<<16) | (NewOffset&0x3f);
// Write Operation
@@ -525,7 +525,7 @@ void rtl8192_phy_configmac(struct net_device* dev)
}
/******************************************************************************
- *function: This function do dirty work
+ *function: This function does dirty work
* input: dev
* output: none
* return: none
@@ -578,7 +578,7 @@ void rtl8192_phyConfigBB(struct net_device* dev, u8 ConfigType)
void rtl8192_InitBBRFRegDef(struct net_device* dev)
{
struct r8192_priv *priv = ieee80211_priv(dev);
-// RF Interface Sowrtware Control
+// RF Interface Software Control
priv->PHYRegDef[RF90_PATH_A].rfintfs = rFPGA0_XAB_RFInterfaceSW; // 16 LSBs if read 32-bit from 0x870
priv->PHYRegDef[RF90_PATH_B].rfintfs = rFPGA0_XAB_RFInterfaceSW; // 16 MSBs if read 32-bit from 0x870 (16-bit for 0x872)
priv->PHYRegDef[RF90_PATH_C].rfintfs = rFPGA0_XCD_RFInterfaceSW;// 16 LSBs if read 32-bit from 0x874
@@ -602,7 +602,7 @@ void rtl8192_InitBBRFRegDef(struct net_device* dev)
priv->PHYRegDef[RF90_PATH_C].rfintfe = rFPGA0_XC_RFInterfaceOE;// 16 MSBs if read 32-bit from 0x86A (16-bit for 0x86A)
priv->PHYRegDef[RF90_PATH_D].rfintfe = rFPGA0_XD_RFInterfaceOE;// 16 MSBs if read 32-bit from 0x86C (16-bit for 0x86E)
- //Addr of LSSI. Wirte RF register by driver
+ //Addr of LSSI. Write RF register by driver
priv->PHYRegDef[RF90_PATH_A].rf3wireOffset = rFPGA0_XA_LSSIParameter; //LSSI Parameter
priv->PHYRegDef[RF90_PATH_B].rf3wireOffset = rFPGA0_XB_LSSIParameter;
priv->PHYRegDef[RF90_PATH_C].rf3wireOffset = rFPGA0_XC_LSSIParameter;
@@ -1384,7 +1384,7 @@ u8 rtl8192_phy_SwChnlStepByStep(struct net_device *dev, u8 channel, u8* stage, u
}
/******************************************************************************
- *function: This function does acturally set channel work
+ *function: This function does actually set channel work
* input: struct net_device *dev
* u8 channel
* output: none
@@ -1425,7 +1425,7 @@ void rtl8192_SwChnl_WorkItem(struct net_device *dev)
}
/******************************************************************************
- *function: This function scheduled actural workitem to set channel
+ *function: This function scheduled actual work item to set channel
* input: net_device dev
* u8 channel //channel to set
* output: none
diff --git a/drivers/staging/rtl8192u/r819xU_phyreg.h b/drivers/staging/rtl8192u/r819xU_phyreg.h
index 06b0b539e1bc..50f24dce8b16 100644
--- a/drivers/staging/rtl8192u/r819xU_phyreg.h
+++ b/drivers/staging/rtl8192u/r819xU_phyreg.h
@@ -443,7 +443,7 @@
#define bCCKRxIG 0x7f00
#define bCCKLNAPolarity 0x800000
#define bCCKRx1stGain 0x7f0000
-#define bCCKRFExtend 0x20000000 //CCK Rx Iinital gain polarity
+#define bCCKRFExtend 0x20000000 //CCK Rx inital gain polarity
#define bCCKRxAGCSatLevel 0x1f000000
#define bCCKRxAGCSatCount 0xe0
#define bCCKRxRFSettle 0x1f //AGCsamp_dly
diff --git a/drivers/staging/rtl8712/big_endian.h b/drivers/staging/rtl8712/big_endian.h
deleted file mode 100644
index b16f8ecf99c6..000000000000
--- a/drivers/staging/rtl8712/big_endian.h
+++ /dev/null
@@ -1,94 +0,0 @@
-/******************************************************************************
- *
- * Copyright(c) 2007 - 2010 Realtek Corporation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
- *
- * Modifications for inclusion into the Linux staging tree are
- * Copyright(c) 2010 Larry Finger. All rights reserved.
- *
- * Contact information:
- * WLAN FAE <wlanfae@realtek.com>
- * Larry Finger <Larry.Finger@lwfinger.net>
- *
- ******************************************************************************/
-#ifndef _LINUX_BYTEORDER_BIG_ENDIAN_H
-#define _LINUX_BYTEORDER_BIG_ENDIAN_H
-
-#ifndef __BIG_ENDIAN
-#define __BIG_ENDIAN 4321
-#endif
-#ifndef __BIG_ENDIAN_BITFIELD
-#define __BIG_ENDIAN_BITFIELD
-#endif
-
-#include "swab.h"
-
-#define __constant_htonl(x) ((__u32)(x))
-#define __constant_ntohl(x) ((__u32)(x))
-#define __constant_htons(x) ((__u16)(x))
-#define __constant_ntohs(x) ((__u16)(x))
-#define __constant_cpu_to_le64(x) ___constant_swab64((x))
-#define __constant_le64_to_cpu(x) ___constant_swab64((x))
-#define __constant_cpu_to_le32(x) ___constant_swab32((x))
-#define __constant_le32_to_cpu(x) ___constant_swab32((x))
-#define __constant_cpu_to_le16(x) ___constant_swab16((x))
-#define __constant_le16_to_cpu(x) ___constant_swab16((x))
-#define __constant_cpu_to_be64(x) ((__u64)(x))
-#define __constant_be64_to_cpu(x) ((__u64)(x))
-#define __constant_cpu_to_be32(x) ((__u32)(x))
-#define __constant_be32_to_cpu(x) ((__u32)(x))
-#define __constant_cpu_to_be16(x) ((__u16)(x))
-#define __constant_be16_to_cpu(x) ((__u16)(x))
-#define __cpu_to_le64(x) __swab64((x))
-#define __le64_to_cpu(x) __swab64((x))
-#define __cpu_to_le32(x) __swab32((x))
-#define __le32_to_cpu(x) __swab32((x))
-#define __cpu_to_le16(x) __swab16((x))
-#define __le16_to_cpu(x) __swab16((x))
-#define __cpu_to_be64(x) ((__u64)(x))
-#define __be64_to_cpu(x) ((__u64)(x))
-#define __cpu_to_be32(x) ((__u32)(x))
-#define __be32_to_cpu(x) ((__u32)(x))
-#define __cpu_to_be16(x) ((__u16)(x))
-#define __be16_to_cpu(x) ((__u16)(x))
-#define __cpu_to_le64p(x) __swab64p((x))
-#define __le64_to_cpup(x) __swab64p((x))
-#define __cpu_to_le32p(x) __swab32p((x))
-#define __le32_to_cpup(x) __swab32p((x))
-#define __cpu_to_le16p(x) __swab16p((x))
-#define __le16_to_cpup(x) __swab16p((x))
-#define __cpu_to_be64p(x) (*(__u64 *)(x))
-#define __be64_to_cpup(x) (*(__u64 *)(x))
-#define __cpu_to_be32p(x) (*(__u32 *)(x))
-#define __be32_to_cpup(x) (*(__u32 *)(x))
-#define __cpu_to_be16p(x) (*(__u16 *)(x))
-#define __be16_to_cpup(x) (*(__u16 *)(x))
-#define __cpu_to_le64s(x) __swab64s((x))
-#define __le64_to_cpus(x) __swab64s((x))
-#define __cpu_to_le32s(x) __swab32s((x))
-#define __le32_to_cpus(x) __swab32s((x))
-#define __cpu_to_le16s(x) __swab16s((x))
-#define __le16_to_cpus(x) __swab16s((x))
-#define __cpu_to_be64s(x) do {} while (0)
-#define __be64_to_cpus(x) do {} while (0)
-#define __cpu_to_be32s(x) do {} while (0)
-#define __be32_to_cpus(x) do {} while (0)
-#define __cpu_to_be16s(x) do {} while (0)
-#define __be16_to_cpus(x) do {} while (0)
-
-#include "generic.h"
-
-#endif /* _LINUX_BYTEORDER_BIG_ENDIAN_H */
-
diff --git a/drivers/staging/rtl8712/drv_types.h b/drivers/staging/rtl8712/drv_types.h
index e83665d06020..62b55663c63a 100644
--- a/drivers/staging/rtl8712/drv_types.h
+++ b/drivers/staging/rtl8712/drv_types.h
@@ -146,7 +146,7 @@ struct dvobj_priv {
/**
* struct _adapter - the main adapter structure for this device.
*
- * bup: True indicates that the interface is Up.
+ * bup: True indicates that the interface is up.
*/
struct _adapter {
struct dvobj_priv dvobjpriv;
diff --git a/drivers/staging/rtl8712/generic.h b/drivers/staging/rtl8712/generic.h
deleted file mode 100644
index 8868c9f4adf8..000000000000
--- a/drivers/staging/rtl8712/generic.h
+++ /dev/null
@@ -1,178 +0,0 @@
-/******************************************************************************
- *
- * Copyright(c) 2007 - 2010 Realtek Corporation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
- *
- * Modifications for inclusion into the Linux staging tree are
- * Copyright(c) 2010 Larry Finger. All rights reserved.
- *
- * Contact information:
- * WLAN FAE <wlanfae@realtek.com>
- * Larry Finger <Larry.Finger@lwfinger.net>
- *
- ******************************************************************************/
-#ifndef _LINUX_BYTEORDER_GENERIC_H
-#define _LINUX_BYTEORDER_GENERIC_H
-
-/*
- * linux/byteorder_generic.h
- * Generic Byte-reordering support
- *
- * Francois-Rene Rideau <fare@tunes.org> 19970707
- * gathered all the good ideas from all asm-foo/byteorder.h into one file,
- * cleaned them up.
- * I hope it is compliant with non-GCC compilers.
- * I decided to put __BYTEORDER_HAS_U64__ in byteorder.h,
- * because I wasn't sure it would be ok to put it in types.h
- * Upgraded it to 2.1.43
- * Francois-Rene Rideau <fare@tunes.org> 19971012
- * Upgraded it to 2.1.57
- * to please Linus T., replaced huge #ifdef's between little/big endian
- * by nestedly #include'd files.
- * Francois-Rene Rideau <fare@tunes.org> 19971205
- * Made it to 2.1.71; now a facelift:
- * Put files under include/linux/byteorder/
- * Split swab from generic support.
- *
- * TODO:
- * = Regular kernel maintainers could also replace all these manual
- * byteswap macros that remain, disseminated among drivers,
- * after some grep or the sources...
- * = Linus might want to rename all these macros and files to fit his taste,
- * to fit his personal naming scheme.
- * = it seems that a few drivers would also appreciate
- * nybble swapping support...
- * = every architecture could add their byteswap macro in asm/byteorder.h
- * see how some architectures already do (i386, alpha, ppc, etc)
- * = cpu_to_beXX and beXX_to_cpu might some day need to be well
- * distinguished throughout the kernel. This is not the case currently,
- * since little endian, big endian, and pdp endian machines needn't it.
- * But this might be the case for, say, a port of Linux to 20/21 bit
- * architectures (and F21 Linux addict around?).
- */
-
-/*
- * The following macros are to be defined by <asm/byteorder.h>:
- *
- * Conversion of long and short int between network and host format
- * ntohl(__u32 x)
- * ntohs(__u16 x)
- * htonl(__u32 x)
- * htons(__u16 x)
- * It seems that some programs (which? where? or perhaps a standard? POSIX?)
- * might like the above to be functions, not macros (why?).
- * if that's true, then detect them, and take measures.
- * Anyway, the measure is: define only ___ntohl as a macro instead,
- * and in a separate file, have
- * unsigned long inline ntohl(x){return ___ntohl(x);}
- *
- * The same for constant arguments
- * __constant_ntohl(__u32 x)
- * __constant_ntohs(__u16 x)
- * __constant_htonl(__u32 x)
- * __constant_htons(__u16 x)
- *
- * Conversion of XX-bit integers (16- 32- or 64-)
- * between native CPU format and little/big endian format
- * 64-bit stuff only defined for proper architectures
- * cpu_to_[bl]eXX(__uXX x)
- * [bl]eXX_to_cpu(__uXX x)
- *
- * The same, but takes a pointer to the value to convert
- * cpu_to_[bl]eXXp(__uXX x)
- * [bl]eXX_to_cpup(__uXX x)
- *
- * The same, but change in situ
- * cpu_to_[bl]eXXs(__uXX x)
- * [bl]eXX_to_cpus(__uXX x)
- *
- * See asm-foo/byteorder.h for examples of how to provide
- * architecture-optimized versions
- *
- */
-
-
-/*
- * inside the kernel, we can use nicknames;
- * outside of it, we must avoid POSIX namespace pollution...
- */
-#define cpu_to_le64 __cpu_to_le64
-#define le64_to_cpu __le64_to_cpu
-#define cpu_to_le32 __cpu_to_le32
-#define le32_to_cpu __le32_to_cpu
-#define cpu_to_le16 __cpu_to_le16
-#define le16_to_cpu __le16_to_cpu
-#define cpu_to_be64 __cpu_to_be64
-#define be64_to_cpu __be64_to_cpu
-#define cpu_to_be32 __cpu_to_be32
-#define be32_to_cpu __be32_to_cpu
-#define cpu_to_be16 __cpu_to_be16
-#define be16_to_cpu __be16_to_cpu
-#define cpu_to_le64p __cpu_to_le64p
-#define le64_to_cpup __le64_to_cpup
-#define cpu_to_le32p __cpu_to_le32p
-#define le32_to_cpup __le32_to_cpup
-#define cpu_to_le16p __cpu_to_le16p
-#define le16_to_cpup __le16_to_cpup
-#define cpu_to_be64p __cpu_to_be64p
-#define be64_to_cpup __be64_to_cpup
-#define cpu_to_be32p __cpu_to_be32p
-#define be32_to_cpup __be32_to_cpup
-#define cpu_to_be16p __cpu_to_be16p
-#define be16_to_cpup __be16_to_cpup
-#define cpu_to_le64s __cpu_to_le64s
-#define le64_to_cpus __le64_to_cpus
-#define cpu_to_le32s __cpu_to_le32s
-#define le32_to_cpus __le32_to_cpus
-#define cpu_to_le16s __cpu_to_le16s
-#define le16_to_cpus __le16_to_cpus
-#define cpu_to_be64s __cpu_to_be64s
-#define be64_to_cpus __be64_to_cpus
-#define cpu_to_be32s __cpu_to_be32s
-#define be32_to_cpus __be32_to_cpus
-#define cpu_to_be16s __cpu_to_be16s
-#define be16_to_cpus __be16_to_cpus
-
-
-/*
- * Handle ntohl and suches. These have various compatibility
- * issues - like we want to give the prototype even though we
- * also have a macro for them in case some strange program
- * wants to take the address of the thing or something..
- *
- * Note that these used to return a "long" in libc5, even though
- * long is often 64-bit these days.. Thus the casts.
- *
- * They have to be macros in order to do the constant folding
- * correctly - if the argument passed into a inline function
- * it is no longer constant according to gcc..
- */
-
-#undef ntohl
-#undef ntohs
-#undef htonl
-#undef htons
-
-/*
- * Do the prototypes. Somebody might want to take the
- * address or some such sick thing..
- */
-extern __u32 ntohl(__u32);
-extern __u32 htonl(__u32);
-extern unsigned short int ntohs(unsigned short int);
-extern unsigned short int htons(unsigned short int);
-
-#endif /* _LINUX_BYTEORDER_GENERIC_H */
-
diff --git a/drivers/staging/rtl8712/hal_init.c b/drivers/staging/rtl8712/hal_init.c
index cc893c0f5ad3..cb9d4cfe8fe4 100644
--- a/drivers/staging/rtl8712/hal_init.c
+++ b/drivers/staging/rtl8712/hal_init.c
@@ -36,7 +36,6 @@
#include "osdep_service.h"
#include "drv_types.h"
-#include "rtl871x_byteorder.h"
#include "usb_osintf.h"
#define FWBUFF_ALIGN_SZ 512
diff --git a/drivers/staging/rtl8712/ieee80211.h b/drivers/staging/rtl8712/ieee80211.h
index 3c0092b7de09..21515c31b373 100644
--- a/drivers/staging/rtl8712/ieee80211.h
+++ b/drivers/staging/rtl8712/ieee80211.h
@@ -705,7 +705,7 @@ enum ieee80211_state {
IEEE80211_ASSOCIATING_RETRY,
/* the association procedure is sending AUTH request*/
IEEE80211_ASSOCIATING_AUTHENTICATING,
- /* the association procedure has successfully authentcated
+ /* the association procedure has successfully authenticated
* and is sending association request
*/
IEEE80211_ASSOCIATING_AUTHENTICATED,
diff --git a/drivers/staging/rtl8712/if_ether.h b/drivers/staging/rtl8712/if_ether.h
deleted file mode 100644
index 2bbe527bcd5c..000000000000
--- a/drivers/staging/rtl8712/if_ether.h
+++ /dev/null
@@ -1,141 +0,0 @@
-/******************************************************************************
- *
- * Copyright(c) 2007 - 2010 Realtek Corporation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
- *
- * Modifications for inclusion into the Linux staging tree are
- * Copyright(c) 2010 Larry Finger. All rights reserved.
- *
- * Contact information:
- * WLAN FAE <wlanfae@realtek.com>
- * Larry Finger <Larry.Finger@lwfinger.net>
- *
- ******************************************************************************/
-/*
- * INET An implementation of the TCP/IP protocol suite for the LINUX
- * operating system. INET is implemented using the BSD Socket
- * interface as the means of communication with the user level.
- *
- * Global definitions for the Ethernet IEEE 802.3 interface.
- *
- * Version: @(#)if_ether.h 1.0.1a 02/08/94
- *
- * Author: Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
- * Donald Becker, <becker@super.org>
- * Alan Cox, <alan@redhat.com>
- * Steve Whitehouse, <gw7rrm@eeshack3.swan.ac.uk>
- *
- * 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.
- */
-
-#ifndef _LINUX_IF_ETHER_H
-#define _LINUX_IF_ETHER_H
-
-/*
- * IEEE 802.3 Ethernet magic constants. The frame sizes omit the preamble
- * and FCS/CRC (frame check sequence).
- */
-
-#define ETH_ALEN 6 /* Octets in one ethernet addr */
-#define ETH_HLEN 14 /* Total octets in header. */
-#define ETH_ZLEN 60 /* Min. octets in frame sans FCS */
-#define ETH_DATA_LEN 1500 /* Max. octets in payload */
-#define ETH_FRAME_LEN 1514 /* Max. octets in frame sans FCS */
-
-/*
- * These are the defined Ethernet Protocol ID's.
- */
-
-#define ETH_P_LOOP 0x0060 /* Ethernet Loopback packet */
-#define ETH_P_PUP 0x0200 /* Xerox PUP packet */
-#define ETH_P_PUPAT 0x0201 /* Xerox PUP Addr Trans packet */
-#define ETH_P_IP 0x0800 /* Internet Protocol packet */
-#define ETH_P_X25 0x0805 /* CCITT X.25 */
-#define ETH_P_ARP 0x0806 /* Address Resolution packet */
-#define ETH_P_BPQ 0x08FF /* G8BPQ AX.25 Ethernet Packet
- * [ NOT AN OFFICIAL ID ] */
-#define ETH_P_IEEEPUP 0x0a00 /* Xerox IEEE802.3 PUP packet */
-#define ETH_P_IEEEPUPAT 0x0a01 /* Xerox IEEE802.3 PUP Addr
- * Trans packet */
-#define ETH_P_DEC 0x6000 /* DEC Assigned proto */
-#define ETH_P_DNA_DL 0x6001 /* DEC DNA Dump/Load */
-#define ETH_P_DNA_RC 0x6002 /* DEC DNA Remote Console */
-#define ETH_P_DNA_RT 0x6003 /* DEC DNA Routing */
-#define ETH_P_LAT 0x6004 /* DEC LAT */
-#define ETH_P_DIAG 0x6005 /* DEC Diagnostics */
-#define ETH_P_CUST 0x6006 /* DEC Customer use */
-#define ETH_P_SCA 0x6007 /* DEC Systems Comms Arch */
-#define ETH_P_RARP 0x8035 /* Reverse Addr Res packet */
-#define ETH_P_ATALK 0x809B /* Appletalk DDP */
-#define ETH_P_AARP 0x80F3 /* Appletalk AARP */
-#define ETH_P_8021Q 0x8100 /* 802.1Q VLAN Extended Header */
-#define ETH_P_IPX 0x8137 /* IPX over DIX */
-#define ETH_P_IPV6 0x86DD /* IPv6 over bluebook */
-#define ETH_P_PPP_DISC 0x8863 /* PPPoE discovery messages */
-#define ETH_P_PPP_SES 0x8864 /* PPPoE session messages */
-#define ETH_P_ATMMPOA 0x884c /* MultiProtocol Over ATM */
-#define ETH_P_ATMFATE 0x8884 /* Frame-based ATM Transport
- * over Ethernet
- */
-
-/*
- * Non DIX types. Won't clash for 1500 types.
- */
-
-#define ETH_P_802_3 0x0001 /* Dummy type for 802.3 frames */
-#define ETH_P_AX25 0x0002 /* Dummy protocol id for AX.25 */
-#define ETH_P_ALL 0x0003 /* Every packet (be careful!!!) */
-#define ETH_P_802_2 0x0004 /* 802.2 frames */
-#define ETH_P_SNAP 0x0005 /* Internal only */
-#define ETH_P_DDCMP 0x0006 /* DEC DDCMP: Internal only */
-#define ETH_P_WAN_PPP 0x0007 /* Dummy type for WAN PPP frames*/
-#define ETH_P_PPP_MP 0x0008 /* Dummy type for PPP MP frames */
-#define ETH_P_LOCALTALK 0x0009 /* Localtalk pseudo type */
-#define ETH_P_PPPTALK 0x0010 /* Dummy type for Atalk over PPP*/
-#define ETH_P_TR_802_2 0x0011i /* 802.2 frames */
-#define ETH_P_MOBITEX 0x0015 /* Mobitex (kaz@cafe.net) */
-#define ETH_P_CONTROL 0x0016 /* Card specific control frames */
-#define ETH_P_IRDA 0x0017 /* Linux-IrDA */
-#define ETH_P_ECONET 0x0018 /* Acorn Econet */
-
-/*
- * This is an Ethernet frame header.
- */
-
-struct ethhdr {
- unsigned char h_dest[ETH_ALEN]; /* destination eth addr */
- unsigned char h_source[ETH_ALEN]; /* source ether addr */
- unsigned short h_proto; /* packet type ID field */
-};
-
-struct _vlan {
- unsigned short h_vlan_TCI; /* Encapsulates priority and VLAN ID*/
- unsigned short h_vlan_encapsulated_proto;
-};
-
-
-
-#define get_vlan_id(pvlan) ((ntohs((unsigned short)pvlan->h_vlan_TCI)) & 0xfff)
-#define get_vlan_priority(pvlan) ((ntohs((unsigned short)\
- pvlan->h_vlan_TCI)) >> 13)
-#define get_vlan_encap_proto(pvlan) (ntohs((unsigned short)\
- pvlan->h_vlan_encapsulated_proto))
-
-
-#endif /* _LINUX_IF_ETHER_H */
-
diff --git a/drivers/staging/rtl8712/ip.h b/drivers/staging/rtl8712/ip.h
deleted file mode 100644
index f37b0f8d14d4..000000000000
--- a/drivers/staging/rtl8712/ip.h
+++ /dev/null
@@ -1,137 +0,0 @@
-/*
- * INET An implementation of the TCP/IP protocol suite for the LINUX
- * operating system. INET is implemented using the BSD Socket
- * interface as the means of communication with the user level.
- *
- * Definitions for the IP protocol.
- *
- * Version: @(#)ip.h 1.0.2 04/28/93
- *
- * Authors: Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
- *
- * 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.
- */
-#ifndef _LINUX_IP_H
-#define _LINUX_IP_H
-
-#include "rtl871x_byteorder.h"
-
-/* SOL_IP socket options */
-
-#define IPTOS_TOS_MASK 0x1E
-#define IPTOS_TOS(tos) ((tos)&IPTOS_TOS_MASK)
-#define IPTOS_LOWDELAY 0x10
-#define IPTOS_THROUGHPUT 0x08
-#define IPTOS_RELIABILITY 0x04
-#define IPTOS_MINCOST 0x02
-
-#define IPTOS_PREC_MASK 0xE0
-#define IPTOS_PREC(tos) ((tos)&IPTOS_PREC_MASK)
-#define IPTOS_PREC_NETCONTROL 0xe0
-#define IPTOS_PREC_INTERNETCONTROL 0xc0
-#define IPTOS_PREC_CRITIC_ECP 0xa0
-#define IPTOS_PREC_FLASHOVERRIDE 0x80
-#define IPTOS_PREC_FLASH 0x60
-#define IPTOS_PREC_IMMEDIATE 0x40
-#define IPTOS_PREC_PRIORITY 0x20
-#define IPTOS_PREC_ROUTINE 0x00
-
-/* IP options */
-#define IPOPT_COPY 0x80
-#define IPOPT_CLASS_MASK 0x60
-#define IPOPT_NUMBER_MASK 0x1f
-
-#define IPOPT_COPIED(o) ((o)&IPOPT_COPY)
-#define IPOPT_CLASS(o) ((o)&IPOPT_CLASS_MASK)
-#define IPOPT_NUMBER(o) ((o)&IPOPT_NUMBER_MASK)
-
-#define IPOPT_CONTROL 0x00
-#define IPOPT_RESERVED1 0x20
-#define IPOPT_MEASUREMENT 0x40
-#define IPOPT_RESERVED2 0x60
-
-#define IPOPT_END (0 | IPOPT_CONTROL)
-#define IPOPT_NOOP (1 | IPOPT_CONTROL)
-#define IPOPT_SEC (2 | IPOPT_CONTROL|IPOPT_COPY)
-#define IPOPT_LSRR (3 | IPOPT_CONTROL|IPOPT_COPY)
-#define IPOPT_TIMESTAMP (4 | IPOPT_MEASUREMENT)
-#define IPOPT_RR (7 | IPOPT_CONTROL)
-#define IPOPT_SID (8 | IPOPT_CONTROL | IPOPT_COPY)
-#define IPOPT_SSRR (9 | IPOPT_CONTROL | IPOPT_COPY)
-#define IPOPT_RA (20 | IPOPT_CONTROL | IPOPT_COPY)
-
-#define IPVERSION 4
-#define MAXTTL 255
-#define IPDEFTTL 64
-
-/* struct timestamp, struct route and MAX_ROUTES are removed.
- *
- * REASONS: it is clear that nobody used them because:
- * - MAX_ROUTES value was wrong.
- * - "struct route" was wrong.
- * - "struct timestamp" had fatally misaligned bitfields and was completely
- * unusable.
- */
-
-#define IPOPT_OPTVAL 0
-#define IPOPT_OLEN 1
-#define IPOPT_OFFSET 2
-#define IPOPT_MINOFF 4
-#define MAX_IPOPTLEN 40
-#define IPOPT_NOP IPOPT_NOOP
-#define IPOPT_EOL IPOPT_END
-#define IPOPT_TS IPOPT_TIMESTAMP
-
-#define IPOPT_TS_TSONLY 0 /* timestamps only */
-#define IPOPT_TS_TSANDADDR 1 /* timestamps and addresses */
-#define IPOPT_TS_PRESPEC 3 /* specified modules only */
-
-struct ip_options {
- __u32 faddr; /* Saved first hop address */
- unsigned char optlen;
- unsigned char srr;
- unsigned char rr;
- unsigned char ts;
- unsigned char is_setbyuser:1, /* Set by setsockopt? */
- is_data:1, /* Options in __data, rather than skb */
- is_strictroute:1, /* Strict source route */
- srr_is_hit:1, /* Packet destination addr was our one*/
- is_changed:1, /* IP checksum more not valid */
- rr_needaddr:1, /* Need to record addr of outgoing dev*/
- ts_needtime:1, /* Need to record timestamp */
- ts_needaddr:1; /* Need to record addr of outgoing dev*/
- unsigned char router_alert;
- unsigned char __pad1;
- unsigned char __pad2;
- unsigned char __data[0];
-};
-
-#define optlength(opt) (sizeof(struct ip_options) + opt->optlen)
-
-struct iphdr {
-#if defined(__LITTLE_ENDIAN_BITFIELD)
- __u8 ihl:4,
- version:4;
-#elif defined(__BIG_ENDIAN_BITFIELD)
- __u8 version:4,
- ihl:4;
-#else
-#error "Please fix <asm/byteorder.h>"
-#endif
- __u8 tos;
- __u16 tot_len;
- __u16 id;
- __u16 frag_off;
- __u8 ttl;
- __u8 protocol;
- __u16 check;
- __u32 saddr;
- __u32 daddr;
- /*The options start here. */
-};
-
-#endif /* _LINUX_IP_H */
-
diff --git a/drivers/staging/rtl8712/little_endian.h b/drivers/staging/rtl8712/little_endian.h
deleted file mode 100644
index cd57d6c2850f..000000000000
--- a/drivers/staging/rtl8712/little_endian.h
+++ /dev/null
@@ -1,94 +0,0 @@
-/******************************************************************************
- *
- * Copyright(c) 2007 - 2010 Realtek Corporation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
- *
- * Modifications for inclusion into the Linux staging tree are
- * Copyright(c) 2010 Larry Finger. All rights reserved.
- *
- * Contact information:
- * WLAN FAE <wlanfae@realtek.com>
- * Larry Finger <Larry.Finger@lwfinger.net>
- *
- ******************************************************************************/
-#ifndef _LINUX_BYTEORDER_LITTLE_ENDIAN_H
-#define _LINUX_BYTEORDER_LITTLE_ENDIAN_H
-
-#ifndef __LITTLE_ENDIAN
-#define __LITTLE_ENDIAN 1234
-#endif
-#ifndef __LITTLE_ENDIAN_BITFIELD
-#define __LITTLE_ENDIAN_BITFIELD
-#endif
-
-#include "swab.h"
-
-#define __constant_htonl(x) ___constant_swab32((x))
-#define __constant_ntohl(x) ___constant_swab32((x))
-#define __constant_htons(x) ___constant_swab16((x))
-#define __constant_ntohs(x) ___constant_swab16((x))
-#define __constant_cpu_to_le64(x) ((__u64)(x))
-#define __constant_le64_to_cpu(x) ((__u64)(x))
-#define __constant_cpu_to_le32(x) ((__u32)(x))
-#define __constant_le32_to_cpu(x) ((__u32)(x))
-#define __constant_cpu_to_le16(x) ((__u16)(x))
-#define __constant_le16_to_cpu(x) ((__u16)(x))
-#define __constant_cpu_to_be64(x) ___constant_swab64((x))
-#define __constant_be64_to_cpu(x) ___constant_swab64((x))
-#define __constant_cpu_to_be32(x) ___constant_swab32((x))
-#define __constant_be32_to_cpu(x) ___constant_swab32((x))
-#define __constant_cpu_to_be16(x) ___constant_swab16((x))
-#define __constant_be16_to_cpu(x) ___constant_swab16((x))
-#define __cpu_to_le64(x) ((__u64)(x))
-#define __le64_to_cpu(x) ((__u64)(x))
-#define __cpu_to_le32(x) ((__u32)(x))
-#define __le32_to_cpu(x) ((__u32)(x))
-#define __cpu_to_le16(x) ((__u16)(x))
-#define __le16_to_cpu(x) ((__u16)(x))
-#define __cpu_to_be64(x) __swab64((x))
-#define __be64_to_cpu(x) __swab64((x))
-#define __cpu_to_be32(x) __swab32((x))
-#define __be32_to_cpu(x) __swab32((x))
-#define __cpu_to_be16(x) __swab16((x))
-#define __be16_to_cpu(x) __swab16((x))
-#define __cpu_to_le64p(x) (*(__u64 *)(x))
-#define __le64_to_cpup(x) (*(__u64 *)(x))
-#define __cpu_to_le32p(x) (*(__u32 *)(x))
-#define __le32_to_cpup(x) (*(__u32 *)(x))
-#define __cpu_to_le16p(x) (*(__u16 *)(x))
-#define __le16_to_cpup(x) (*(__u16 *)(x))
-#define __cpu_to_be64p(x) __swab64p((x))
-#define __be64_to_cpup(x) __swab64p((x))
-#define __cpu_to_be32p(x) __swab32p((x))
-#define __be32_to_cpup(x) __swab32p((x))
-#define __cpu_to_be16p(x) __swab16p((x))
-#define __be16_to_cpup(x) __swab16p((x))
-#define __cpu_to_le64s(x) do {} while (0)
-#define __le64_to_cpus(x) do {} while (0)
-#define __cpu_to_le32s(x) do {} while (0)
-#define __le32_to_cpus(x) do {} while (0)
-#define __cpu_to_le16s(x) do {} while (0)
-#define __le16_to_cpus(x) do {} while (0)
-#define __cpu_to_be64s(x) __swab64s((x))
-#define __be64_to_cpus(x) __swab64s((x))
-#define __cpu_to_be32s(x) __swab32s((x))
-#define __be32_to_cpus(x) __swab32s((x))
-#define __cpu_to_be16s(x) __swab16s((x))
-#define __be16_to_cpus(x) __swab16s((x))
-
-#include "generic.h"
-
-#endif /* _LINUX_BYTEORDER_LITTLE_ENDIAN_H */
-
diff --git a/drivers/staging/rtl8712/os_intfs.c b/drivers/staging/rtl8712/os_intfs.c
index 7bbd53a410e3..448f00dd68fe 100644
--- a/drivers/staging/rtl8712/os_intfs.c
+++ b/drivers/staging/rtl8712/os_intfs.c
@@ -52,7 +52,7 @@ static int lbkmode = RTL8712_AIR_TRX;
static int hci = RTL8712_USB;
static int ampdu_enable = 1;/*for enable tx_ampdu*/
-/* The video_mode variable is for vedio mode.*/
+/* The video_mode variable is for video mode.*/
/* It may be specify when inserting module with video_mode=1 parameter.*/
static int video_mode = 1; /* enable video mode*/
@@ -248,7 +248,7 @@ static u32 start_drv_threads(struct _adapter *padapter)
void r8712_stop_drv_threads(struct _adapter *padapter)
{
- /*Below is to termindate r8712_cmd_thread & event_thread...*/
+ /*Below is to terminate r8712_cmd_thread & event_thread...*/
up(&padapter->cmdpriv.cmd_queue_sema);
if (padapter->cmdThread)
_down_sema(&padapter->cmdpriv.terminate_cmdthread_sema);
diff --git a/drivers/staging/rtl8712/osdep_service.h b/drivers/staging/rtl8712/osdep_service.h
index 9ba603310fdc..f1ccc7ebbda7 100644
--- a/drivers/staging/rtl8712/osdep_service.h
+++ b/drivers/staging/rtl8712/osdep_service.h
@@ -29,7 +29,6 @@
#define _SUCCESS 1
#define _FAIL 0
-#include <linux/version.h>
#include <linux/spinlock.h>
#include <linux/interrupt.h>
@@ -107,8 +106,6 @@ static inline void _set_workitem(_workitem *pwork)
schedule_work(pwork);
}
-#include "rtl871x_byteorder.h"
-
#ifndef BIT
#define BIT(x) (1 << (x))
#endif
diff --git a/drivers/staging/rtl8712/rtl8712_cmd.c b/drivers/staging/rtl8712/rtl8712_cmd.c
index 9f6ebc419b0b..088647cdca99 100644
--- a/drivers/staging/rtl8712/rtl8712_cmd.c
+++ b/drivers/staging/rtl8712/rtl8712_cmd.c
@@ -50,7 +50,6 @@
#include "drv_types.h"
#include "recv_osdep.h"
#include "mlme_osdep.h"
-#include "rtl871x_byteorder.h"
#include "rtl871x_ioctl_set.h"
static void check_hw_pbc(struct _adapter *padapter)
@@ -69,7 +68,7 @@ static void check_hw_pbc(struct _adapter *padapter)
* After trigger PBC, the variable will be set to false */
DBG_8712("CheckPbcGPIO - PBC is pressed !!!!\n");
/* 0 is the default value and it means the application monitors
- * the HW PBC doesn't privde its pid to driver. */
+ * the HW PBC doesn't provide its pid to driver. */
if (padapter->pid == 0)
return;
kill_pid(find_vpid(padapter->pid), SIGUSR1, 1);
@@ -382,7 +381,7 @@ _next:
*pcmdbuf = cpu_to_le32((cmdsz & 0x0000ffff) |
(pcmd->cmdcode << 16) |
(pcmdpriv->cmd_seq << 24));
- pcmdbuf += 2 ; /* 8 bytes aligment */
+ pcmdbuf += 2 ; /* 8 bytes alignment */
memcpy((u8 *)pcmdbuf, pcmd->parmbuf, pcmd->cmdsz);
while (check_cmd_fifo(padapter, wr_sz) == _FAIL) {
if ((padapter->bDriverStopped == true) ||
@@ -471,7 +470,7 @@ void r8712_event_handle(struct _adapter *padapter, uint *peventbuf)
pevt_priv->event_seq++; /* update evt_seq */
if (pevt_priv->event_seq > 127)
pevt_priv->event_seq = 0;
- peventbuf = peventbuf + 2; /* move to event content, 8 bytes aligment */
+ peventbuf = peventbuf + 2; /* move to event content, 8 bytes alignment */
if (peventbuf) {
event_callback = wlanevents[evt_code].event_callback;
if (event_callback)
diff --git a/drivers/staging/rtl8712/rtl8712_cmd.h b/drivers/staging/rtl8712/rtl8712_cmd.h
index 766a6463266a..039ab3e97172 100644
--- a/drivers/staging/rtl8712/rtl8712_cmd.h
+++ b/drivers/staging/rtl8712/rtl8712_cmd.h
@@ -121,7 +121,7 @@ enum rtl8712_h2c_cmd {
GEN_CMD_CODE(_GetCurDataRate) ,
GEN_CMD_CODE(_GetTxRetrycnt), /* to record times that Tx retry to
- * transmmit packet after association
+ * transmit packet after association
*/
GEN_CMD_CODE(_GetRxRetrycnt), /* to record total number of the
* received frame with ReTry bit set in
diff --git a/drivers/staging/rtl8712/rtl8712_efuse.c b/drivers/staging/rtl8712/rtl8712_efuse.c
index b08e9a25c9c5..377fca905801 100644
--- a/drivers/staging/rtl8712/rtl8712_efuse.c
+++ b/drivers/staging/rtl8712/rtl8712_efuse.c
@@ -417,7 +417,7 @@ u8 r8712_efuse_pg_packet_write(struct _adapter *padapter, const u8 offset,
} else { /* write header fail */
bResult = false;
if (0xFF == efuse_data)
- return bResult; /* not thing damaged. */
+ return bResult; /* nothing damaged. */
/* call rescue procedure */
if (fix_header(padapter, efuse_data, efuse_addr) ==
false)
diff --git a/drivers/staging/rtl8712/rtl8712_gp_bitdef.h b/drivers/staging/rtl8712/rtl8712_gp_bitdef.h
index 884a8212176d..138ea453d9df 100644
--- a/drivers/staging/rtl8712/rtl8712_gp_bitdef.h
+++ b/drivers/staging/rtl8712/rtl8712_gp_bitdef.h
@@ -70,7 +70,7 @@
#define GPIOSEL_BT 2 /* BT_coex*/
#define GPIOSEL_WLANDBG 3 /* WLANDBG*/
#define GPIOSEL_GPIO_MASK (~(BIT(0)|BIT(1)))
-/* HW Readio OFF switch (GPIO BIT) */
+/* HW Radio OFF switch (GPIO BIT) */
#define HAL_8192S_HW_GPIO_OFF_BIT BIT(3)
#define HAL_8192S_HW_GPIO_OFF_MASK 0xF7
#define HAL_8192S_HW_GPIO_WPS_BIT BIT(4)
diff --git a/drivers/staging/rtl8712/rtl8712_hal.h b/drivers/staging/rtl8712/rtl8712_hal.h
index d19865a5a50c..4c51fa373b54 100644
--- a/drivers/staging/rtl8712/rtl8712_hal.h
+++ b/drivers/staging/rtl8712/rtl8712_hal.h
@@ -83,7 +83,7 @@ struct fw_priv { /*8-bytes alignment required*/
unsigned char rfintfs; /* 0:SWSI, 1:HWSI, 2:HWPI*/
unsigned char def_nettype;
unsigned char turboMode;
- unsigned char lowPowerMode;/* 0: noral mode, 1: low power mode*/
+ unsigned char lowPowerMode;/* 0: normal mode, 1: low power mode*/
/*--- long word 2 ----*/
unsigned char lbk_mode; /*0x00: normal, 0x03: MACLBK, 0x01: PHYLBK*/
unsigned char mp_mode; /* 1: for MP use, 0: for normal driver */
@@ -123,7 +123,7 @@ struct fw_priv { /*8-bytes alignment required*/
unsigned char rsvd053;
};
-struct fw_hdr {/*8-byte alinment required*/
+struct fw_hdr {/*8-byte alignment required*/
unsigned short signature;
unsigned short version; /*0x8000 ~ 0x8FFF for FPGA version,
*0x0000 ~ 0x7FFF for ASIC version,*/
diff --git a/drivers/staging/rtl8712/rtl8712_led.c b/drivers/staging/rtl8712/rtl8712_led.c
index bac56e5caf12..c9eb4b74799b 100644
--- a/drivers/staging/rtl8712/rtl8712_led.c
+++ b/drivers/staging/rtl8712/rtl8712_led.c
@@ -60,7 +60,7 @@ enum _LED_STATE_871x {
* the # of times to blink is depend on time
* for scanning. */
LED_NO_LINK_BLINK = 7, /* LED is blinking during no link state. */
- LED_BLINK_StartToBlink = 8,/* Customzied for Sercomm Printer
+ LED_BLINK_StartToBlink = 8,/* Customized for Sercomm Printer
* Server case */
LED_BLINK_WPS = 9, /* LED is blinkg during WPS communication */
LED_TXRX_BLINK = 10,
@@ -826,7 +826,7 @@ static void BlinkTimerCallback(unsigned long data)
{
struct LED_871x *pLed = (struct LED_871x *)data;
- /* This fixed the crash problem on Fedora 12 when trying to do thei
+ /* This fixed the crash problem on Fedora 12 when trying to do the
* insmod;ifconfig up;rmmod commands. */
if ((pLed->padapter->bSurpriseRemoved == true) ||
(pLed->padapter->bDriverStopped == true))
@@ -836,7 +836,7 @@ static void BlinkTimerCallback(unsigned long data)
/* Description:
* Callback function of LED BlinkWorkItem.
- * We dispatch acture LED blink action according to LedStrategy.
+ * We dispatch actual LED blink action according to LedStrategy.
*/
static void BlinkWorkItemCallback(struct work_struct *work)
{
diff --git a/drivers/staging/rtl8712/rtl8712_recv.c b/drivers/staging/rtl8712/rtl8712_recv.c
index fa6dc9c09b3f..8e82ce2fee38 100644
--- a/drivers/staging/rtl8712/rtl8712_recv.c
+++ b/drivers/staging/rtl8712/rtl8712_recv.c
@@ -28,12 +28,13 @@
#define _RTL8712_RECV_C_
+#include <linux/if_ether.h>
+#include <linux/ip.h>
+
#include "osdep_service.h"
#include "drv_types.h"
#include "recv_osdep.h"
#include "mlme_osdep.h"
-#include "ip.h"
-#include "if_ether.h"
#include "ethernet.h"
#include "usb_ops.h"
#include "wifi.h"
@@ -459,7 +460,7 @@ void r8712_rxcmd_event_hdl(struct _adapter *padapter, void *prxcmdbuf)
cmd_seq = (u8)((le32_to_cpu(voffset) >> 24) & 0x7f);
eid = (u8)((le32_to_cpu(voffset) >> 16) & 0xff);
r8712_event_handle(padapter, (uint *)poffset);
- poffset += (cmd_len + 8);/*8 bytes aligment*/
+ poffset += (cmd_len + 8);/*8 bytes alignment*/
} while (le32_to_cpu(voffset) & BIT(31));
}
@@ -603,7 +604,7 @@ static int recv_indicatepkt_reorder(struct _adapter *padapter,
}
}
spin_lock_irqsave(&ppending_recvframe_queue->lock, irql);
- /*s2. check if winstart_b(indicate_seq) needs to been updated*/
+ /*s2. check if winstart_b(indicate_seq) needs to be updated*/
if (!check_indicate_seq(preorder_ctrl, pattrib->seq_num))
goto _err_exit;
/*s3. Insert all packet into Reorder Queue to maintain its ordering.*/
diff --git a/drivers/staging/rtl8712/rtl8712_xmit.c b/drivers/staging/rtl8712/rtl8712_xmit.c
index 693331955d67..3d23514c0222 100644
--- a/drivers/staging/rtl8712/rtl8712_xmit.c
+++ b/drivers/staging/rtl8712/rtl8712_xmit.c
@@ -30,7 +30,6 @@
#include "osdep_service.h"
#include "drv_types.h"
-#include "rtl871x_byteorder.h"
#include "wifi.h"
#include "osdep_intf.h"
#include "usb_ops.h"
diff --git a/drivers/staging/rtl8712/rtl871x_byteorder.h b/drivers/staging/rtl8712/rtl871x_byteorder.h
deleted file mode 100644
index bd3703b98bce..000000000000
--- a/drivers/staging/rtl8712/rtl871x_byteorder.h
+++ /dev/null
@@ -1,32 +0,0 @@
-/******************************************************************************
- *
- * Copyright(c) 2007 - 2010 Realtek Corporation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
- *
- *
- ******************************************************************************/
-#ifndef _RTL871X_BYTEORDER_H_
-#define _RTL871X_BYTEORDER_H_
-
-#if defined(__LITTLE_ENDIAN)
-# include "little_endian.h"
-#elif defined(__BIG_ENDIAN)
-# include "big_endian.h"
-#else
-# error "Must be LITTLE/BIG Endian Host"
-#endif
-
-#endif /* _RTL871X_BYTEORDER_H_ */
-
diff --git a/drivers/staging/rtl8712/rtl871x_cmd.c b/drivers/staging/rtl8712/rtl871x_cmd.c
index d77388bdba7b..659683e022b9 100644
--- a/drivers/staging/rtl8712/rtl871x_cmd.c
+++ b/drivers/staging/rtl8712/rtl871x_cmd.c
@@ -50,7 +50,6 @@
#include "drv_types.h"
#include "recv_osdep.h"
#include "mlme_osdep.h"
-#include "rtl871x_byteorder.h"
/*
Caller and the r8712_cmd_thread can protect cmd_q by spin_lock.
diff --git a/drivers/staging/rtl8712/rtl871x_cmd.h b/drivers/staging/rtl8712/rtl871x_cmd.h
index 757ebf77e9d6..9d93189d8700 100644
--- a/drivers/staging/rtl8712/rtl871x_cmd.h
+++ b/drivers/staging/rtl8712/rtl871x_cmd.h
@@ -720,7 +720,7 @@ struct DisconnectCtrlEx_param {
* Result:
* 0x00: success
* 0x01: success, and check Response.
- * 0x02: cmd ignored due to duplicated sequcne number
+ * 0x02: cmd ignored due to duplicated sequence number
* 0x03: cmd dropped due to invalid cmd code
* 0x04: reserved.
*/
diff --git a/drivers/staging/rtl8712/rtl871x_io.h b/drivers/staging/rtl8712/rtl871x_io.h
index d3d8727c2ec5..dc23395fec3b 100644
--- a/drivers/staging/rtl8712/rtl871x_io.h
+++ b/drivers/staging/rtl8712/rtl871x_io.h
@@ -117,7 +117,7 @@ struct io_req {
u32 command;
u32 status;
u8 *pbuf;
- void (*_async_io_callback)(struct _adapter *padater,
+ void (*_async_io_callback)(struct _adapter *padapter,
struct io_req *pio_req, u8 *cnxt);
u8 *cnxt;
};
diff --git a/drivers/staging/rtl8712/rtl871x_ioctl_linux.c b/drivers/staging/rtl8712/rtl871x_ioctl_linux.c
index ef35bc29a3fa..35e781fca4a0 100644
--- a/drivers/staging/rtl8712/rtl871x_ioctl_linux.c
+++ b/drivers/staging/rtl8712/rtl871x_ioctl_linux.c
@@ -43,7 +43,6 @@
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/init.h>
-#include <linux/version.h>
#include <linux/io.h>
#include <linux/semaphore.h>
#include <net/iw_handler.h>
@@ -242,7 +241,7 @@ static inline char *translate_scan(struct _adapter *padapter,
/* Add frequency/channel */
iwe.cmd = SIOCGIWFREQ;
{
- /* check legel index */
+ /* check legal index */
u8 dsconfig = pnetwork->network.Configuration.DSConfig;
if (dsconfig >= 1 && dsconfig <= sizeof(
ieee80211_wlan_frequencies) / sizeof(long))
@@ -810,11 +809,11 @@ static int r871x_wx_set_pmkid(struct net_device *dev,
/*
There are the BSSID information in the bssid.sa_data array.
- If cmd is IW_PMKSA_FLUSH, it means the wpa_suppplicant wants to clear
- all the PMKID information. If cmd is IW_PMKSA_ADD, it means the
- wpa_supplicant wants to add a PMKID/BSSID to driver.
+ If cmd is IW_PMKSA_FLUSH, it means the wpa_supplicant wants to clear
+ all the PMKID information. If cmd is IW_PMKSA_ADD, it means the
+ wpa_supplicant wants to add a PMKID/BSSID to driver.
If cmd is IW_PMKSA_REMOVE, it means the wpa_supplicant wants to
- remove a PMKID/BSSID from driver.
+ remove a PMKID/BSSID from driver.
*/
if (pPMK == NULL)
return -EINVAL;
@@ -924,7 +923,7 @@ static int r8711_wx_get_range(struct net_device *dev,
range->max_qual.noise = 100;
range->max_qual.updated = 7; /* Updated all three */
range->avg_qual.qual = 92; /* > 8% missed beacons is 'bad' */
- /* TODO: Find real 'good' to 'bad' threshol value for RSSI */
+ /* TODO: Find real 'good' to 'bad' threshold value for RSSI */
range->avg_qual.level = 20 + -98;
range->avg_qual.noise = 0;
range->avg_qual.updated = 7; /* Updated all three */
@@ -1071,7 +1070,7 @@ FREE_EXT:
* MAC# of a preferred Access Point.
* Currently, the request comes via Wireless Extensions' SIOCSIWAP ioctl.
*
- * For this operation to succeed, there is no need for the interface to be Up.
+ * For this operation to succeed, there is no need for the interface to be up.
*
*/
static int r8711_wx_set_wap(struct net_device *dev,
@@ -2389,10 +2388,10 @@ static struct iw_statistics *r871x_get_wireless_stats(struct net_device *dev)
struct iw_handler_def r871x_handlers_def = {
.standard = r8711_handlers,
- .num_standard = sizeof(r8711_handlers) / sizeof(iw_handler),
+ .num_standard = ARRAY_SIZE(r8711_handlers),
.private = r8711_private_handler,
.private_args = (struct iw_priv_args *)r8711_private_args,
- .num_private = sizeof(r8711_private_handler) / sizeof(iw_handler),
+ .num_private = ARRAY_SIZE(r8711_private_handler),
.num_private_args = sizeof(r8711_private_args) /
sizeof(struct iw_priv_args),
.get_wireless_stats = r871x_get_wireless_stats
diff --git a/drivers/staging/rtl8712/rtl871x_ioctl_set.c b/drivers/staging/rtl8712/rtl871x_ioctl_set.c
index fb29b423752f..f352b32355a0 100644
--- a/drivers/staging/rtl8712/rtl871x_ioctl_set.c
+++ b/drivers/staging/rtl8712/rtl871x_ioctl_set.c
@@ -264,7 +264,7 @@ void r8712_set_802_11_infrastructure_mode(struct _adapter *padapter,
(*pold_state == Ndis802_11Infrastructure) ||
(*pold_state == Ndis802_11IBSS)) {
/* will clr Linked_state before this function,
- * we must have chked whether issue dis-assoc_cmd or
+ * we must have checked whether issue dis-assoc_cmd or
* not */
r8712_ind_disconnect(padapter);
}
diff --git a/drivers/staging/rtl8712/rtl871x_mlme.c b/drivers/staging/rtl8712/rtl871x_mlme.c
index 4277d0304b7a..dc7adc132d12 100644
--- a/drivers/staging/rtl8712/rtl871x_mlme.c
+++ b/drivers/staging/rtl8712/rtl871x_mlme.c
@@ -137,7 +137,7 @@ static void _free_network_nolock(struct mlme_priv *pmlmepriv,
/*
return the wlan_network with the matching addr
- Shall be calle under atomic context...
+ Shall be called under atomic context...
to avoid possible racing condition...
*/
static struct wlan_network *_r8712_find_network(struct __queue *scanned_queue,
@@ -255,7 +255,7 @@ void r8712_free_network_queue(struct _adapter *dev)
/*
return the wlan_network with the matching addr
- Shall be calle under atomic context...
+ Shall be called under atomic context...
to avoid possible racing condition...
*/
static struct wlan_network *r8712_find_network(struct __queue *scanned_queue,
@@ -1037,7 +1037,7 @@ void r8712_cpwm_event_callback(struct _adapter *adapter, u8 *pbuf)
* and the WiFi client will drop the data with seq number 0.
* So, the 8712 firmware has to inform driver with receiving the
* ADDBA-Req frame so that the driver can reset the
- * sequence value of Rx reorder contorl.
+ * sequence value of Rx reorder control.
*/
void r8712_got_addbareq_event_callback(struct _adapter *adapter, u8 *pbuf)
{
@@ -1775,7 +1775,7 @@ static void update_ht_cap(struct _adapter *padapter, u8 *pie, uint ie_len)
phtpriv->rx_ampdu_maxlen = max_ampdu_sz;
}
/* for A-MPDU Rx reordering buffer control for bmc_sta & sta_info
- * if A-MPDU Rx is enabled, reseting rx_ordering_ctrl
+ * if A-MPDU Rx is enabled, resetting rx_ordering_ctrl
* wstart_b(indicate_seq) to default value=0xffff
* todo: check if AP can send A-MPDU packets
*/
diff --git a/drivers/staging/rtl8712/rtl871x_mlme.h b/drivers/staging/rtl8712/rtl871x_mlme.h
index 71ca01350b5e..42bd0bf8a816 100644
--- a/drivers/staging/rtl8712/rtl871x_mlme.h
+++ b/drivers/staging/rtl8712/rtl871x_mlme.h
@@ -69,8 +69,8 @@ since mlme_priv is a shared resource between many threads,
like ISR/Call-Back functions, the OID handlers, and even timer functions.
Each _queue has its own locks, already.
Other items are protected by mlme_priv.lock.
-To avoid possible dead lock, any thread trying to modifiying mlme_priv
-SHALL not lock up more than one locks at a time!
+To avoid possible dead lock, any thread trying to modify mlme_priv
+SHALL not lock up more than one lock at a time!
*/
#define traffic_threshold 10
@@ -132,7 +132,7 @@ static inline sint get_fwstate(struct mlme_priv *pmlmepriv)
* therefore set it to be the critical section...
*
* ### NOTE:#### (!!!!)
- * TAKE CARE THAT BEFORE CALLING THIS FUNC, LOCK pmlmepriv->lock
+ * TAKE CARE BEFORE CALLING THIS FUNC, LOCK pmlmepriv->lock
*/
static inline void set_fwstate(struct mlme_priv *pmlmepriv, sint state)
{
diff --git a/drivers/staging/rtl8712/rtl871x_mp_phy_regdef.h b/drivers/staging/rtl8712/rtl871x_mp_phy_regdef.h
index 23532a793859..8e2586231ffd 100644
--- a/drivers/staging/rtl8712/rtl871x_mp_phy_regdef.h
+++ b/drivers/staging/rtl8712/rtl871x_mp_phy_regdef.h
@@ -184,7 +184,7 @@
/*RxIQ DC offset, Rx digital filter, DC notch filter */
#define rOFDM0_XARxAFE 0xc10
-#define rOFDM0_XARxIQImbalance 0xc14 /* RxIQ imblance matrix */
+#define rOFDM0_XARxIQImbalance 0xc14 /* RxIQ imbalance matrix */
#define rOFDM0_XBRxAFE 0xc18
#define rOFDM0_XBRxIQImbalance 0xc1c
#define rOFDM0_XCRxAFE 0xc20
@@ -603,7 +603,7 @@
#define bCCKRxIG 0x7f00
#define bCCKLNAPolarity 0x800000
#define bCCKRx1stGain 0x7f0000
-#define bCCKRFExtend 0x20000000 /* CCK Rx Iinital gain polarity */
+#define bCCKRFExtend 0x20000000 /* CCK Rx inital gain polarity */
#define bCCKRxAGCSatLevel 0x1f000000
#define bCCKRxAGCSatCount 0xe0
#define bCCKRxRFSettle 0x1f /* AGCsamp_dly */
diff --git a/drivers/staging/rtl8712/rtl871x_recv.c b/drivers/staging/rtl8712/rtl871x_recv.c
index 5b03b405883e..c9d1743e5c5d 100644
--- a/drivers/staging/rtl8712/rtl871x_recv.c
+++ b/drivers/staging/rtl8712/rtl871x_recv.c
@@ -28,15 +28,15 @@
#define _RTL871X_RECV_C_
+#include <linux/ip.h>
#include <linux/slab.h>
+#include <linux/if_ether.h>
#include <linux/kmemleak.h>
#include "osdep_service.h"
#include "drv_types.h"
#include "recv_osdep.h"
#include "mlme_osdep.h"
-#include "ip.h"
-#include "if_ether.h"
#include "ethernet.h"
#include "usb_ops.h"
#include "wifi.h"
diff --git a/drivers/staging/rtl8712/rtl871x_xmit.c b/drivers/staging/rtl8712/rtl871x_xmit.c
index aa57e7754f04..78f570b571a7 100644
--- a/drivers/staging/rtl8712/rtl871x_xmit.c
+++ b/drivers/staging/rtl8712/rtl871x_xmit.c
@@ -30,7 +30,6 @@
#include "osdep_service.h"
#include "drv_types.h"
-#include "rtl871x_byteorder.h"
#include "wifi.h"
#include "osdep_intf.h"
#include "usb_ops.h"
@@ -72,7 +71,7 @@ sint _r8712_init_xmit_priv(struct xmit_priv *pxmitpriv,
memset((unsigned char *)pxmitpriv, 0, sizeof(struct xmit_priv));
spin_lock_init(&pxmitpriv->lock);
/*
- Please insert all the queue initializaiton using _init_queue below
+ Please insert all the queue initialization using _init_queue below
*/
pxmitpriv->adapter = padapter;
_init_queue(&pxmitpriv->be_pending);
diff --git a/drivers/staging/rtl8712/rtl871x_xmit.h b/drivers/staging/rtl8712/rtl871x_xmit.h
index 638b79b4c5a8..ee906987735a 100644
--- a/drivers/staging/rtl8712/rtl871x_xmit.h
+++ b/drivers/staging/rtl8712/rtl871x_xmit.h
@@ -119,7 +119,7 @@ struct pkt_attrib {
u8 priority;
u8 encrypt; /* when 0 indicate no encrypt. when non-zero,
- * indicate the encrypt algorith*/
+ * indicate the encrypt algorithm*/
u8 iv_len;
u8 icv_len;
unsigned char iv[8];
diff --git a/drivers/staging/rtl8712/swab.h b/drivers/staging/rtl8712/swab.h
deleted file mode 100644
index f12781829c1b..000000000000
--- a/drivers/staging/rtl8712/swab.h
+++ /dev/null
@@ -1,131 +0,0 @@
-/******************************************************************************
- *
- * Copyright(c) 2007 - 2010 Realtek Corporation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
- *
- * Modifications for inclusion into the Linux staging tree are
- * Copyright(c) 2010 Larry Finger. All rights reserved.
- *
- * Contact information:
- * WLAN FAE <wlanfae@realtek.com>
- * Larry Finger <Larry.Finger@lwfinger.net>
- *
- ******************************************************************************/
-#ifndef _LINUX_BYTEORDER_SWAB_H
-#define _LINUX_BYTEORDER_SWAB_H
-
-#ifndef __u16
- #define __u16 unsigned short
-#endif
-
-#ifndef __u32
- #define __u32 unsigned int
-#endif
-
-#ifndef __u8
- #define __u8 unsigned char
-#endif
-
-#ifndef __u64
- #define __u64 unsigned long long
-#endif
-
-
-static inline __u16 ___swab16(__u16 x)
-{
- __u16 __x = x;
- return (__u16)(
- (((__u16)(__x) & (__u16)0x00ffU) << 8) |
- (((__u16)(__x) & (__u16)0xff00U) >> 8));
-
-}
-
-static inline __u32 ___swab32(__u32 x)
-{
- __u32 __x = (x);
- return (__u32)(
- (((__u32)(__x) & (__u32)0x000000ffUL) << 24) |
- (((__u32)(__x) & (__u32)0x0000ff00UL) << 8) |
- (((__u32)(__x) & (__u32)0x00ff0000UL) >> 8) |
- (((__u32)(__x) & (__u32)0xff000000UL) >> 24));
-}
-
-static inline __u64 ___swab64(__u64 x)
-{
- __u64 __x = (x);
-
- return (__u64)( \
- (__u64)(((__u64)(__x) & (__u64)0x00000000000000ffULL) << 56) | \
- (__u64)(((__u64)(__x) & (__u64)0x000000000000ff00ULL) << 40) | \
- (__u64)(((__u64)(__x) & (__u64)0x0000000000ff0000ULL) << 24) | \
- (__u64)(((__u64)(__x) & (__u64)0x00000000ff000000ULL) << 8) | \
- (__u64)(((__u64)(__x) & (__u64)0x000000ff00000000ULL) >> 8) | \
- (__u64)(((__u64)(__x) & (__u64)0x0000ff0000000000ULL) >> 24) | \
- (__u64)(((__u64)(__x) & (__u64)0x00ff000000000000ULL) >> 40) | \
- (__u64)(((__u64)(__x) & (__u64)0xff00000000000000ULL) >> 56));
-}
-
-#ifndef __arch__swab16
-static inline __u16 __arch__swab16(__u16 x)
-{
- return ___swab16(x);
-}
-
-#endif
-
-#ifndef __arch__swab32
-static inline __u32 __arch__swab32(__u32 x)
-{
- __u32 __tmp = (x) ;
- return ___swab32(__tmp);
-}
-#endif
-
-#ifndef __arch__swab64
-
-static inline __u64 __arch__swab64(__u64 x)
-{
- __u64 __tmp = (x) ;
- return ___swab64(__tmp);
-}
-
-
-#endif
-
-#define __swab16(x) __fswab16(x)
-#define __swab32(x) __fswab32(x)
-#define __swab64(x) __fswab64(x)
-
-static inline const __u16 __fswab16(__u16 x)
-{
- return __arch__swab16(x);
-}
-static inline const __u32 __fswab32(__u32 x)
-{
- return __arch__swab32(x);
-}
-
-#define swab16 __swab16
-#define swab32 __swab32
-#define swab64 __swab64
-#define swab16p __swab16p
-#define swab32p __swab32p
-#define swab64p __swab64p
-#define swab16s __swab16s
-#define swab32s __swab32s
-#define swab64s __swab64s
-
-#endif /* _LINUX_BYTEORDER_SWAB_H */
-
diff --git a/drivers/staging/rtl8712/usb_halinit.c b/drivers/staging/rtl8712/usb_halinit.c
index 46287c17a417..b4ae11a78b46 100644
--- a/drivers/staging/rtl8712/usb_halinit.c
+++ b/drivers/staging/rtl8712/usb_halinit.c
@@ -141,7 +141,7 @@ u8 r8712_usb_hal_bus_init(struct _adapter *padapter)
/* Enable AFE PLL Macro Block */
val8 = r8712_read8(padapter, AFE_PLL_CTRL);
r8712_write8(padapter, AFE_PLL_CTRL, (val8 | 0x11));
- /* Attatch AFE PLL to MACTOP/BB/PCIe Digital */
+ /* Attach AFE PLL to MACTOP/BB/PCIe Digital */
val8 = r8712_read8(padapter, SYS_ISO_CTRL);
r8712_write8(padapter, SYS_ISO_CTRL, (val8 & 0xEE));
/* Switch to 40M clock */
@@ -234,7 +234,7 @@ u8 r8712_usb_hal_bus_init(struct _adapter *padapter)
udelay(500);
r8712_write8(padapter, AFE_PLL_CTRL, (val8 | 0x11));
udelay(500);
- /* Attatch AFE PLL to MACTOP/BB/PCIe Digital */
+ /* Attach AFE PLL to MACTOP/BB/PCIe Digital */
val8 = r8712_read8(padapter, SYS_ISO_CTRL);
r8712_write8(padapter, SYS_ISO_CTRL, (val8 & 0xEE));
/* Switch to 40M clock */
diff --git a/drivers/staging/rtl8712/usb_intf.c b/drivers/staging/rtl8712/usb_intf.c
index e419b4fd82b9..c758c40e0c85 100644
--- a/drivers/staging/rtl8712/usb_intf.c
+++ b/drivers/staging/rtl8712/usb_intf.c
@@ -41,8 +41,6 @@
#include "usb_ops.h"
#include "usb_osintf.h"
-#define DRVER "v7_0.20100831"
-
static struct usb_interface *pintf;
static int r871xu_drv_init(struct usb_interface *pusb_intf,
@@ -102,6 +100,8 @@ static struct usb_device_id rtl871x_usb_id_tbl[] = {
/* - */
{USB_DEVICE(0x20F4, 0x646B)},
{USB_DEVICE(0x083A, 0xC512)},
+ {USB_DEVICE(0x25D4, 0x4CA1)},
+ {USB_DEVICE(0x25D4, 0x4CAB)},
/* RTL8191SU */
/* Realtek */
@@ -372,7 +372,7 @@ static int r871xu_drv_init(struct usb_interface *pusb_intf,
struct net_device *pnetdev;
struct usb_device *udev;
- printk(KERN_INFO "r8712u: DriverVersion: %s\n", DRVER);
+ printk(KERN_INFO "r8712u: Staging version\n");
/* In this probe function, O.S. will provide the usb interface pointer
* to driver. We have to increase the reference count of the usb device
* structure by using the usb_get_dev function.
@@ -621,30 +621,28 @@ static void r871xu_dev_remove(struct usb_interface *pusb_intf)
struct usb_device *udev = interface_to_usbdev(pusb_intf);
usb_set_intfdata(pusb_intf, NULL);
- if (padapter) {
- if (padapter->fw_found)
- release_firmware(padapter->fw);
- /* never exit with a firmware callback pending */
- wait_for_completion(&padapter->rtl8712_fw_ready);
- if (drvpriv.drv_registered == true)
- padapter->bSurpriseRemoved = true;
- if (pnetdev != NULL) {
- /* will call netdev_close() */
- unregister_netdev(pnetdev);
- }
- flush_scheduled_work();
- udelay(1);
- /*Stop driver mlme relation timer */
- if (padapter->fw_found)
- r8712_stop_drv_timers(padapter);
- r871x_dev_unload(padapter);
- r8712_free_drv_sw(padapter);
+ if (padapter->fw_found)
+ release_firmware(padapter->fw);
+ /* never exit with a firmware callback pending */
+ wait_for_completion(&padapter->rtl8712_fw_ready);
+ if (drvpriv.drv_registered == true)
+ padapter->bSurpriseRemoved = true;
+ if (pnetdev != NULL) {
+ /* will call netdev_close() */
+ unregister_netdev(pnetdev);
}
+ flush_scheduled_work();
+ udelay(1);
+ /*Stop driver mlme relation timer */
+ if (padapter->fw_found)
+ r8712_stop_drv_timers(padapter);
+ r871x_dev_unload(padapter);
+ r8712_free_drv_sw(padapter);
usb_set_intfdata(pusb_intf, NULL);
/* decrease the reference count of the usb device structure
* when disconnect */
usb_put_dev(udev);
- /* If we didn't unplug usb dongle and remove/insert modlue, driver
+ /* If we didn't unplug usb dongle and remove/insert module, driver
* fails on sitesurvey for the first time when device is up.
* Reset usb port for sitesurvey fail issue. */
if (udev->state != USB_STATE_NOTATTACHED)
diff --git a/drivers/staging/rtl8712/usb_ops.c b/drivers/staging/rtl8712/usb_ops.c
index 5a8b0ebd0b79..c03508d935f2 100644
--- a/drivers/staging/rtl8712/usb_ops.c
+++ b/drivers/staging/rtl8712/usb_ops.c
@@ -33,7 +33,6 @@
#include "osdep_intf.h"
#include "usb_ops.h"
#include "recv_osdep.h"
-#include "rtl871x_byteorder.h"
static u8 usb_read8(struct intf_hdl *pintfhdl, u32 addr)
{
diff --git a/drivers/staging/rtl8712/wifi.h b/drivers/staging/rtl8712/wifi.h
index 277398cff0a7..793443e758ac 100644
--- a/drivers/staging/rtl8712/wifi.h
+++ b/drivers/staging/rtl8712/wifi.h
@@ -26,7 +26,6 @@
#ifndef _WIFI_H_
#define _WIFI_H_
-#include "rtl871x_byteorder.h"
#include <linux/compiler.h>
#ifdef BIT
diff --git a/drivers/staging/rtl8712/xmit_linux.c b/drivers/staging/rtl8712/xmit_linux.c
index c9703627c8f5..65542cb7168f 100644
--- a/drivers/staging/rtl8712/xmit_linux.c
+++ b/drivers/staging/rtl8712/xmit_linux.c
@@ -29,14 +29,12 @@
#define _XMIT_OSDEP_C_
#include <linux/usb.h>
+#include <linux/ip.h>
+#include <linux/if_ether.h>
#include "osdep_service.h"
#include "drv_types.h"
-
-#include "if_ether.h"
-#include "ip.h"
-#include "rtl871x_byteorder.h"
#include "wifi.h"
#include "mlme_osdep.h"
#include "xmit_osdep.h"
diff --git a/drivers/staging/rts5139/ms.c b/drivers/staging/rts5139/ms.c
index b0e9071c8e52..6eef33b03f55 100644
--- a/drivers/staging/rts5139/ms.c
+++ b/drivers/staging/rts5139/ms.c
@@ -2680,7 +2680,7 @@ static int mspro_set_rw_cmd(struct rts51x_chip *chip, u32 start_sec,
return STATUS_SUCCESS;
}
-void mspro_stop_seq_mode(struct rts51x_chip *chip)
+static void mspro_stop_seq_mode(struct rts51x_chip *chip)
{
struct ms_info *ms_card = &(chip->ms_card);
int retval;
@@ -3149,7 +3149,7 @@ Fail:
TRACE_RET(chip, STATUS_FAIL);
sec_cnt = chip->rsp_buf[0];
- RTS51X_DEBUGP("%d pages need be trasferred, %d pages remained\n",
+ RTS51X_DEBUGP("%d pages need be transferred, %d pages remained\n",
(int)page_cnt, (int)sec_cnt);
page_addr = start_page + (page_cnt - sec_cnt);
@@ -3864,7 +3864,7 @@ static int ms_rw_multi_sector(struct scsi_cmnd *srb, struct rts51x_chip *chip,
log_blk = (u16) (start_sector >> ms_card->block_shift);
start_page = (u8) (start_sector & ms_card->page_off);
- for (seg_no = 0; seg_no < sizeof(ms_start_idx) / 2; seg_no++) {
+ for (seg_no = 0; seg_no < ARRAY_SIZE(ms_start_idx) - 1; seg_no++) {
if (log_blk < ms_start_idx[seg_no + 1])
break;
}
@@ -4020,7 +4020,8 @@ static int ms_rw_multi_sector(struct scsi_cmnd *srb, struct rts51x_chip *chip,
log_blk++;
- for (seg_no = 0; seg_no < sizeof(ms_start_idx) / 2; seg_no++) {
+ for (seg_no = 0; seg_no < ARRAY_SIZE(ms_start_idx) - 1;
+ seg_no++) {
if (log_blk < ms_start_idx[seg_no + 1])
break;
}
@@ -4134,7 +4135,7 @@ void ms_cleanup_work(struct rts51x_chip *chip)
}
}
-int ms_power_off_card3v3(struct rts51x_chip *chip)
+static int ms_power_off_card3v3(struct rts51x_chip *chip)
{
int retval;
diff --git a/drivers/staging/rts5139/ms.h b/drivers/staging/rts5139/ms.h
index 3ce1dc90f19d..0321d06e776d 100644
--- a/drivers/staging/rts5139/ms.h
+++ b/drivers/staging/rts5139/ms.h
@@ -234,7 +234,6 @@
void mspro_polling_format_status(struct rts51x_chip *chip);
void mspro_format_sense(struct rts51x_chip *chip, unsigned int lun);
-void mspro_stop_seq_mode(struct rts51x_chip *chip);
int reset_ms_card(struct rts51x_chip *chip);
int ms_rw(struct scsi_cmnd *srb, struct rts51x_chip *chip, u32 start_sector,
u16 sector_cnt);
@@ -242,7 +241,6 @@ int mspro_format(struct scsi_cmnd *srb, struct rts51x_chip *chip,
int short_data_len, int quick_format);
void ms_free_l2p_tbl(struct rts51x_chip *chip);
void ms_cleanup_work(struct rts51x_chip *chip);
-int ms_power_off_card3v3(struct rts51x_chip *chip);
int release_ms_card(struct rts51x_chip *chip);
int ms_delay_write(struct rts51x_chip *chip);
diff --git a/drivers/staging/rts5139/ms_mg.c b/drivers/staging/rts5139/ms_mg.c
index 154b5230aa5e..057d96c1a937 100644
--- a/drivers/staging/rts5139/ms_mg.c
+++ b/drivers/staging/rts5139/ms_mg.c
@@ -38,7 +38,7 @@
#ifdef SUPPORT_MAGIC_GATE
-int mg_check_int_error(struct rts51x_chip *chip)
+static int mg_check_int_error(struct rts51x_chip *chip)
{
u8 value;
@@ -444,7 +444,7 @@ int mg_rsp(struct scsi_cmnd *srb, struct rts51x_chip *chip)
*
* Since the extra 4 bytes data is just only a prefix to original data
* that read from medium, so that the 4-byte data pushed into Ring buffer
- * precedes data tramsinssion from medium to Ring buffer by DMA mechanisim
+ * precedes data transmission from medium to Ring buffer by DMA mechanism
* in order to get maximum performance and minimum code size simultaneously.
*/
int mg_get_ICV(struct scsi_cmnd *srb, struct rts51x_chip *chip)
diff --git a/drivers/staging/rts5139/rts51x.c b/drivers/staging/rts5139/rts51x.c
index 2b9f785954df..c3fe7dda1f4e 100644
--- a/drivers/staging/rts5139/rts51x.c
+++ b/drivers/staging/rts5139/rts51x.c
@@ -56,12 +56,6 @@ MODULE_DESCRIPTION(RTS51X_DESC);
MODULE_LICENSE("GPL");
MODULE_VERSION(DRIVER_VERSION);
-#ifdef SCSI_SCAN_DELAY
-static unsigned int delay_use = 5;
-module_param(delay_use, uint, S_IRUGO | S_IWUSR);
-MODULE_PARM_DESC(delay_use, "seconds to delay before using a new device");
-#endif
-
static int auto_delink_en;
module_param(auto_delink_en, int, S_IRUGO | S_IWUSR);
MODULE_PARM_DESC(auto_delink_en, "enable auto delink");
@@ -114,7 +108,7 @@ static inline void usb_autopm_disable(struct usb_interface *intf)
usb_autopm_get_interface(intf);
}
-void rts51x_try_to_enter_ss(struct rts51x_chip *chip)
+static void rts51x_try_to_enter_ss(struct rts51x_chip *chip)
{
RTS51X_DEBUGP("Ready to enter SS state\n");
usb_autopm_enable(chip->usb->pusb_intf);
@@ -207,7 +201,7 @@ int rts51x_reset_resume(struct usb_interface *iface)
#else /* CONFIG_PM */
-void rts51x_try_to_enter_ss(struct rts51x_chip *chip)
+static void rts51x_try_to_enter_ss(struct rts51x_chip *chip)
{
}
@@ -364,11 +358,6 @@ static int rts51x_polling_thread(void *__chip)
{
struct rts51x_chip *chip = (struct rts51x_chip *)__chip;
-#ifdef SCSI_SCAN_DELAY
- /* Wait until SCSI scan finished */
- wait_timeout((delay_use + 5) * HZ);
-#endif
-
for (;;) {
wait_timeout(POLLING_INTERVAL);
@@ -432,38 +421,6 @@ static int rts51x_polling_thread(void *__chip)
return 0;
}
-#ifdef SCSI_SCAN_DELAY
-/* Thread to carry out delayed SCSI-device scanning */
-static int rts51x_scan_thread(void *__chip)
-{
- struct rts51x_chip *chip = (struct rts51x_chip *)__chip;
-
- printk(KERN_DEBUG
- "rts51x: device found at %d\n", chip->usb->pusb_dev->devnum);
-
- set_freezable();
- /* Wait for the timeout to expire or for a disconnect */
- if (delay_use > 0) {
- printk(KERN_DEBUG "rts51x: waiting for device "
- "to settle before scanning\n");
- wait_event_freezable_timeout(chip->usb->delay_wait,
- test_bit(FLIDX_DONT_SCAN,
- &chip->usb->dflags),
- delay_use * HZ);
- }
-
- /* If the device is still connected, perform the scanning */
- if (!test_bit(FLIDX_DONT_SCAN, &chip->usb->dflags)) {
- scsi_scan_host(rts51x_to_host(chip));
- printk(KERN_DEBUG "rts51x: device scan complete\n");
-
- /* Should we unbind if no devices were detected? */
- }
-
- complete_and_exit(&chip->usb->scanning_done, 0);
-}
-#endif
-
/* Associate our private data with the USB device */
static int associate_dev(struct rts51x_chip *chip, struct usb_interface *intf)
{
@@ -521,7 +478,6 @@ static void rts51x_init_options(struct rts51x_chip *chip)
{
struct rts51x_option *option = &(chip->option);
- option->led_blink_speed = 7;
option->mspro_formatter_enable = 1;
option->fpga_sd_sdr104_clk = CLK_100;
@@ -549,7 +505,6 @@ static void rts51x_init_options(struct rts51x_chip *chip)
option->ss_en = ss_en;
option->ss_delay = ss_delay;
- option->needs_remote_wakeup = needs_remote_wakeup;
option->auto_delink_en = auto_delink_en;
@@ -561,10 +516,7 @@ static void rts51x_init_options(struct rts51x_chip *chip)
option->rts5129_D3318_off_enable = 0;
option->sd20_pad_drive = 0;
option->reset_or_rw_fail_set_pad_drive = 1;
- option->rcc_fail_flag = 0;
- option->rcc_bug_fix_en = 1;
option->debounce_num = 2;
- option->polling_time = 100;
option->led_toggle_interval = 6;
option->xd_rwn_step = 0;
option->sd_send_status_en = 0;
@@ -737,15 +689,6 @@ static void quiesce_and_remove_host(struct rts51x_chip *chip)
if (rts51x->pusb_dev->state == USB_STATE_NOTATTACHED)
set_bit(FLIDX_DISCONNECTING, &rts51x->dflags);
-#ifdef SCSI_SCAN_DELAY
- /* Prevent SCSI-scanning (if it hasn't started yet)
- * and wait for the SCSI-scanning thread to stop.
- */
- set_bit(FLIDX_DONT_SCAN, &rts51x->dflags);
- wake_up(&rts51x->delay_wait);
- wait_for_completion(&rts51x->scanning_done);
-#endif
-
/* Removing the host will perform an orderly shutdown: caches
* synchronized, disks spun down, etc.
*/
@@ -757,9 +700,6 @@ static void quiesce_and_remove_host(struct rts51x_chip *chip)
scsi_lock(host);
set_bit(FLIDX_DISCONNECTING, &rts51x->dflags);
scsi_unlock(host);
-#ifdef SCSI_SCAN_DELAY
- wake_up(&rts51x->delay_wait);
-#endif
}
/* Second stage of disconnect processing: deallocate all resources */
@@ -818,10 +758,6 @@ static int rts51x_probe(struct usb_interface *intf,
init_completion(&rts51x->control_exit);
init_completion(&rts51x->polling_exit);
init_completion(&(rts51x->notify));
-#ifdef SCSI_SCAN_DELAY
- init_waitqueue_head(&rts51x->delay_wait);
- init_completion(&rts51x->scanning_done);
-#endif
chip->usb = rts51x;
@@ -855,22 +791,7 @@ static int rts51x_probe(struct usb_interface *intf,
printk(KERN_WARNING RTS51X_TIP "Unable to add the scsi host\n");
goto BadDevice;
}
-#ifdef SCSI_SCAN_DELAY
- /* Start up the thread for delayed SCSI-device scanning */
- th = kthread_create(rts51x_scan_thread, chip, RTS51X_SCAN_THREAD);
- if (IS_ERR(th)) {
- printk(KERN_WARNING RTS51X_TIP
- "Unable to start the device-scanning thread\n");
- complete(&rts51x->scanning_done);
- quiesce_and_remove_host(chip);
- result = PTR_ERR(th);
- goto BadDevice;
- }
-
- wake_up_process(th);
-#else
scsi_scan_host(rts51x_to_host(chip));
-#endif
/* Start up our polling thread */
th = kthread_run(rts51x_polling_thread, chip, RTS51X_POLLING_THREAD);
diff --git a/drivers/staging/rts5139/rts51x.h b/drivers/staging/rts5139/rts51x.h
index b2c58390bfc5..ecc0109a5b1a 100644
--- a/drivers/staging/rts5139/rts51x.h
+++ b/drivers/staging/rts5139/rts51x.h
@@ -47,11 +47,9 @@
#define RTS51X_DESC "Realtek RTS5139/29 USB card reader driver"
#define RTS51X_NAME "rts5139"
#define RTS51X_CTL_THREAD "rts5139-control"
-#define RTS51X_SCAN_THREAD "rts5139-scan"
#define RTS51X_POLLING_THREAD "rts5139-polling"
#define POLLING_IN_THREAD
-/* #define SCSI_SCAN_DELAY */
#define SUPPORT_FILE_OP
#define wait_timeout_x(task_state, msecs) \
@@ -66,8 +64,6 @@ do { \
/* Size of the DMA-mapped I/O buffer */
#define RTS51X_IOBUF_SIZE 1024
-/* Size of the autosense data buffer */
-#define RTS51X_SENSE_SIZE 18
/* Dynamic bitflag definitions (dflags): used in set_bit() etc. */
#define FLIDX_URB_ACTIVE 0 /* current_urb is in use */
@@ -76,7 +72,6 @@ do { \
#define FLIDX_DISCONNECTING 3 /* disconnect in progress */
#define FLIDX_RESETTING 4 /* device reset in progress */
#define FLIDX_TIMED_OUT 5 /* SCSI midlayer timed out */
-#define FLIDX_DONT_SCAN 6 /* don't scan (disconnect) */
struct rts51x_chip;
@@ -116,10 +111,6 @@ struct rts51x_usb {
struct completion control_exit; /* control thread exit */
struct completion polling_exit; /* polling thread exit */
struct completion notify; /* thread begin/end */
-#ifdef SCSI_SCAN_DELAY
- wait_queue_head_t delay_wait; /* wait during scan, reset */
- struct completion scanning_done; /* wait for scan thread */
-#endif
};
extern struct usb_driver rts51x_driver;
@@ -188,7 +179,6 @@ enum xfer_buf_dir { TO_XFER_BUF, FROM_XFER_BUF };
/* General routines provided by the usb-storage standard core */
#ifdef CONFIG_PM
-void rts51x_try_to_enter_ss(struct rts51x_chip *chip);
void rts51x_try_to_exit_ss(struct rts51x_chip *chip);
int rts51x_suspend(struct usb_interface *iface, pm_message_t message);
int rts51x_resume(struct usb_interface *iface);
diff --git a/drivers/staging/rts5139/rts51x_card.c b/drivers/staging/rts5139/rts51x_card.c
index 424a84581b86..50be42ac592b 100644
--- a/drivers/staging/rts5139/rts51x_card.c
+++ b/drivers/staging/rts5139/rts51x_card.c
@@ -37,7 +37,6 @@
#include "rts51x_chip.h"
#include "rts51x_card.h"
#include "rts51x_transport.h"
-#include "rts51x_sys.h"
#include "xd.h"
#include "sd.h"
#include "ms.h"
@@ -94,7 +93,7 @@ void do_remaining_work(struct rts51x_chip *chip)
ms_cleanup_work(chip);
}
-void do_reset_xd_card(struct rts51x_chip *chip)
+static void do_reset_xd_card(struct rts51x_chip *chip)
{
int retval;
@@ -148,7 +147,7 @@ void do_reset_sd_card(struct rts51x_chip *chip)
}
}
-void do_reset_ms_card(struct rts51x_chip *chip)
+static void do_reset_ms_card(struct rts51x_chip *chip)
{
int retval;
@@ -175,7 +174,7 @@ void do_reset_ms_card(struct rts51x_chip *chip)
}
}
-void card_cd_debounce(struct rts51x_chip *chip, u8 *need_reset,
+static void card_cd_debounce(struct rts51x_chip *chip, u8 *need_reset,
u8 *need_release)
{
int retval;
@@ -191,7 +190,6 @@ void card_cd_debounce(struct rts51x_chip *chip, u8 *need_reset,
goto Exit_Debounce;
if (chip->card_exist) {
- rts51x_clear_start_time(chip);
retval = rts51x_read_register(chip, CARD_INT_PEND, &value);
if (retval != STATUS_SUCCESS) {
rts51x_ep0_write_register(chip, MC_FIFO_CTL, FIFO_FLUSH,
@@ -213,19 +211,12 @@ void card_cd_debounce(struct rts51x_chip *chip, u8 *need_reset,
release_map |= MS_CARD;
}
} else {
- if (chip->card_status & XD_CD) {
- rts51x_clear_start_time(chip);
+ if (chip->card_status & XD_CD)
reset_map |= XD_CARD;
- } else if (chip->card_status & SD_CD) {
- rts51x_clear_start_time(chip);
+ else if (chip->card_status & SD_CD)
reset_map |= SD_CARD;
- } else if (chip->card_status & MS_CD) {
- rts51x_clear_start_time(chip);
+ else if (chip->card_status & MS_CD)
reset_map |= MS_CARD;
- } else {
- if (rts51x_check_start_time(chip))
- rts51x_set_start_time(chip);
- }
}
if (CHECK_PKG(chip, QFN24) && reset_map) {
@@ -709,7 +700,7 @@ u8 get_lun_card(struct rts51x_chip *chip, unsigned int lun)
return 0;
}
-int card_share_mode(struct rts51x_chip *chip, int card)
+static int card_share_mode(struct rts51x_chip *chip, int card)
{
u8 value;
@@ -823,22 +814,6 @@ int enable_card_clock(struct rts51x_chip *chip, u8 card)
return STATUS_SUCCESS;
}
-int disable_card_clock(struct rts51x_chip *chip, u8 card)
-{
- u8 clk_en = 0;
-
- if (card & XD_CARD)
- clk_en |= XD_CLK_EN;
- if (card & SD_CARD)
- clk_en |= SD_CLK_EN;
- if (card & MS_CARD)
- clk_en |= MS_CLK_EN;
-
- RTS51X_WRITE_REG(chip, CARD_CLK_EN, clk_en, 0);
-
- return STATUS_SUCCESS;
-}
-
int card_power_on(struct rts51x_chip *chip, u8 card)
{
u8 mask, val1, val2;
@@ -851,17 +826,7 @@ int card_power_on(struct rts51x_chip *chip, u8 card)
if ((card == SD_CARD) || (card == XD_CARD)) {
RTS51X_WRITE_REG(chip, CARD_PWR_CTL, mask | LDO3318_PWR_MASK,
val1 | LDO_SUSPEND);
- /* RTS51X_WRITE_REG(chip, CARD_PWR_CTL,
- LDO3318_PWR_MASK, LDO_SUSPEND); */
- }
- /* else if(card==XD_CARD)
- {
- RTS51X_WRITE_REG(chip, CARD_PWR_CTL,
- mask|LDO3318_PWR_MASK, val1|LDO_SUSPEND);
- //RTS51X_WRITE_REG(chip, CARD_PWR_CTL,
- // LDO3318_PWR_MASK, LDO_SUSPEND);
- } */
- else {
+ } else {
#endif
RTS51X_WRITE_REG(chip, CARD_PWR_CTL, mask, val1);
#ifdef SD_XD_IO_FOLLOW_PWR
@@ -879,17 +844,6 @@ int card_power_on(struct rts51x_chip *chip, u8 card)
return STATUS_SUCCESS;
}
-int card_power_off(struct rts51x_chip *chip, u8 card)
-{
- u8 mask, val;
-
- mask = POWER_MASK;
- val = POWER_OFF;
- RTS51X_WRITE_REG(chip, CARD_PWR_CTL, mask, val);
-
- return STATUS_SUCCESS;
-}
-
int monitor_card_cd(struct rts51x_chip *chip, u8 card)
{
int retval;
diff --git a/drivers/staging/rts5139/rts51x_card.h b/drivers/staging/rts5139/rts51x_card.h
index ac3c1e741ab9..c5c03cce98bd 100644
--- a/drivers/staging/rts5139/rts51x_card.h
+++ b/drivers/staging/rts5139/rts51x_card.h
@@ -204,13 +204,7 @@
/* LDO_POWER_CFG */
#define TUNE_SD18_MASK 0x1C
-#define TUNE_SD18_1V7 0x00
#define TUNE_SD18_1V8 (0x01 << 2)
-#define TUNE_SD18_1V9 (0x02 << 2)
-#define TUNE_SD18_2V0 (0x03 << 2)
-#define TUNE_SD18_2V7 (0x04 << 2)
-#define TUNE_SD18_2V8 (0x05 << 2)
-#define TUNE_SD18_2V9 (0x06 << 2)
#define TUNE_SD18_3V3 (0x07 << 2)
/* XD_CP_WAITTIME */
@@ -744,9 +738,7 @@
int monitor_card_cd(struct rts51x_chip *chip, u8 card);
void do_remaining_work(struct rts51x_chip *chip);
-void do_reset_xd_card(struct rts51x_chip *chip);
void do_reset_sd_card(struct rts51x_chip *chip);
-void do_reset_ms_card(struct rts51x_chip *chip);
void rts51x_init_cards(struct rts51x_chip *chip);
void rts51x_release_cards(struct rts51x_chip *chip);
int switch_ssc_clock(struct rts51x_chip *chip, int clk);
@@ -754,15 +746,12 @@ int switch_normal_clock(struct rts51x_chip *chip, int clk);
int card_rw(struct scsi_cmnd *srb, struct rts51x_chip *chip, u32 sec_addr,
u16 sec_cnt);
u8 get_lun_card(struct rts51x_chip *chip, unsigned int lun);
-int card_share_mode(struct rts51x_chip *chip, int card);
int rts51x_select_card(struct rts51x_chip *chip, int card);
void eject_card(struct rts51x_chip *chip, unsigned int lun);
void trans_dma_enable(enum dma_data_direction dir, struct rts51x_chip *chip,
u32 byte_cnt, u8 pack_size);
int enable_card_clock(struct rts51x_chip *chip, u8 card);
-int disable_card_clock(struct rts51x_chip *chip, u8 card);
int card_power_on(struct rts51x_chip *chip, u8 card);
-int card_power_off(struct rts51x_chip *chip, u8 card);
int toggle_gpio(struct rts51x_chip *chip, u8 gpio);
int turn_on_led(struct rts51x_chip *chip, u8 gpio);
int turn_off_led(struct rts51x_chip *chip, u8 gpio);
diff --git a/drivers/staging/rts5139/rts51x_chip.c b/drivers/staging/rts5139/rts51x_chip.c
index b3e0bb22b0ff..08dcae8db63e 100644
--- a/drivers/staging/rts5139/rts51x_chip.c
+++ b/drivers/staging/rts5139/rts51x_chip.c
@@ -34,7 +34,6 @@
#include "rts51x_chip.h"
#include "rts51x_card.h"
#include "rts51x_transport.h"
-#include "rts51x_sys.h"
#include "xd.h"
#include "ms.h"
#include "sd.h"
@@ -79,20 +78,18 @@ int rts51x_reset_chip(struct rts51x_chip *chip)
chip->option.sd20_pad_drive);
if (chip->rts5179)
rts51x_write_register(chip, CARD_PULL_CTL5, 0x03, 0x01);
- if (!chip->option.ww_enable) {
- if (CHECK_PKG(chip, LQFP48)) {
- rts51x_write_register(chip, CARD_PULL_CTL3,
- 0x80, 0x80);
- rts51x_write_register(chip, CARD_PULL_CTL6,
- 0xf0, 0xA0);
- } else {
- rts51x_write_register(chip, CARD_PULL_CTL1,
- 0x30, 0x20);
- rts51x_write_register(chip, CARD_PULL_CTL3,
- 0x80, 0x80);
- rts51x_write_register(chip, CARD_PULL_CTL6,
- 0x0c, 0x08);
- }
+ if (CHECK_PKG(chip, LQFP48)) {
+ rts51x_write_register(chip, CARD_PULL_CTL3,
+ 0x80, 0x80);
+ rts51x_write_register(chip, CARD_PULL_CTL6,
+ 0xf0, 0xA0);
+ } else {
+ rts51x_write_register(chip, CARD_PULL_CTL1,
+ 0x30, 0x20);
+ rts51x_write_register(chip, CARD_PULL_CTL3,
+ 0x80, 0x80);
+ rts51x_write_register(chip, CARD_PULL_CTL6,
+ 0x0c, 0x08);
}
}
if (chip->option.sd_ctl & SUPPORT_UHS50_MMC44) {
@@ -121,12 +118,6 @@ int rts51x_reset_chip(struct rts51x_chip *chip)
/* GPIO OE */
rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_GPIO, GPIO_OE, GPIO_OE);
-#ifdef LED_AUTO_BLINK
- /* LED autoblink */
- rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_AUTO_BLINK,
- BLINK_ENABLE | BLINK_SPEED_MASK,
- BLINK_ENABLE | chip->option.led_blink_speed);
-#endif
rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_DMA1_CTL,
EXTEND_DMA1_ASYNC_SIGNAL, EXTEND_DMA1_ASYNC_SIGNAL);
@@ -144,7 +135,6 @@ int rts51x_reset_chip(struct rts51x_chip *chip)
card_power_on(chip, SD_CARD | MS_CARD | XD_CARD);
wait_timeout(10);
}
- rts51x_clear_start_time(chip);
return STATUS_SUCCESS;
}
@@ -164,12 +154,6 @@ int rts51x_init_chip(struct rts51x_chip *chip)
chip->card_ejected = 0;
chip->lun2card[0] = XD_CARD | SD_CARD | MS_CARD;
-#if 0
- chip->option.sdr50_tx_phase = 0x01;
- chip->option.sdr50_rx_phase = 0x05;
- chip->option.ddr50_tx_phase = 0x09;
- chip->option.ddr50_rx_phase = 0x06; /* add for debug */
-#endif
#ifdef CLOSE_SSC_POWER
rts51x_write_register(chip, FPDCTL, SSC_POWER_MASK, SSC_POWER_ON);
udelay(100);
@@ -178,9 +162,6 @@ int rts51x_init_chip(struct rts51x_chip *chip)
RTS51X_SET_STAT(chip, STAT_RUN);
RTS51X_READ_REG(chip, HW_VERSION, &val);
- if ((val & 0x0f) >= 2)
- chip->option.rcc_bug_fix_en = 0;
- RTS51X_DEBUGP("rcc bug fix enable:%d\n", chip->option.rcc_bug_fix_en);
RTS51X_DEBUGP("HW_VERSION: 0x%x\n", val);
if (val & FPGA_VER) {
chip->asic_code = 0;
@@ -237,7 +218,6 @@ int rts51x_release_chip(struct rts51x_chip *chip)
return STATUS_SUCCESS;
}
-#ifndef LED_AUTO_BLINK
static inline void rts51x_blink_led(struct rts51x_chip *chip)
{
/* Read/Write */
@@ -251,20 +231,6 @@ static inline void rts51x_blink_led(struct rts51x_chip *chip)
}
}
}
-#endif
-
-int rts51x_check_start_time(struct rts51x_chip *chip)
-{
- return 0;
-}
-
-void rts51x_set_start_time(struct rts51x_chip *chip)
-{
-}
-
-void rts51x_clear_start_time(struct rts51x_chip *chip)
-{
-}
static void rts51x_auto_delink_cmd(struct rts51x_chip *chip)
{
@@ -287,7 +253,6 @@ static void rts51x_auto_delink_polling_cycle(struct rts51x_chip *chip)
chip->option.delink_delay * 2) {
if (chip->auto_delink_counter ==
chip->option.delink_delay) {
- clear_first_install_mark(chip);
if (chip->card_exist) {
/* False card */
if (!chip->card_ejected) {
@@ -321,91 +286,13 @@ static void rts51x_auto_delink(struct rts51x_chip *chip)
}
#else
/* some of called funcs are not implemented, so comment it out */
-#if 0
-/* using precise time as delink time */
-static void rts51x_auto_delink_precise_time(struct rts51x_chip *chip)
-{
- int retvalue = 0;
-
- retvalue = rts51x_get_card_status(chip, &chip->card_status);
- /* get card CD status success and card CD not exist,
- * then check whether delink */
- if ((retvalue == STATUS_SUCCESS)
- && (!(chip->card_status & (SD_CD | MS_CD | XD_CD)))) {
- if (rts51x_count_delink_time(chip) >=
- chip->option.delink_delay) {
- clear_first_install_mark(chip);
- RTS51X_DEBUGP("No card inserted, do delink\n");
- /* sangdy2010-05-17:disable because there is error
- * after SSC clock closed and card power
- * has been closed before */
- /* rts51x_write_register(chip, CARD_PWR_CTL,
- DV3318_AUTO_PWR_OFF, 0); */
- rts51x_auto_delink_cmd(chip);
- }
- /* card CD exist and not ready, then do force delink */
- if ((retvalue == STATUS_SUCCESS)
- && (chip->card_status & (SD_CD | MS_CD | XD_CD))) {
- /* if card is not ejected or safely remove,
- * then do force delink */
- if (!chip->card_ejected) {
- /* sangdy2010-11-16:polling at least 2 cycles
- * then do force delink for card may force delink
- * if card is extracted and insert quickly
- * after ready. */
- if (chip->auto_delink_counter > 1) {
- if (rts51x_count_delink_time(chip) >
- chip->option.delink_delay * 2) {
- RTS51X_DEBUGP("Try to do force"
- "delink\n");
- rts51x_auto_delink_force_cmd(chip);
- }
- }
- }
- }
- chip->auto_delink_counter++;
-}
-#else
-static void rts51x_auto_delink_precise_time(struct rts51x_chip *chip)
-{
-}
-#endif
-
static void rts51x_auto_delink(struct rts51x_chip *chip)
{
- rts51x_auto_delink_precise_time(chip);
}
#endif
void rts51x_polling_func(struct rts51x_chip *chip)
{
-#ifdef SUPPORT_SD_LOCK
- struct sd_info *sd_card = &(chip->sd_card);
-
- if (sd_card->sd_erase_status) {
- if (chip->card_exist & SD_CARD) {
- u8 val;
- rts51x_read_register(chip, SD_BUS_STAT, &val);
- if (val & SD_DAT0_STATUS) {
- /* Erase completed */
- sd_card->sd_erase_status = SD_NOT_ERASE;
- sd_card->sd_lock_notify = 1;
-
- /* SD card should be reinited,
- * so we release it here. */
- sd_cleanup_work(chip);
- release_sd_card(chip);
- chip->card_ready &= ~SD_CARD;
- chip->card_exist &= ~SD_CARD;
- chip->rw_card[chip->card2lun[SD_CARD]] = NULL;
- clear_bit(chip->card2lun[SD_CARD],
- &(chip->lun_mc));
- }
- } else {
- sd_card->sd_erase_status = SD_NOT_ERASE;
- }
- }
-#endif
rts51x_init_cards(chip);
@@ -431,9 +318,7 @@ void rts51x_polling_func(struct rts51x_chip *chip)
if (!RTS51X_CHK_STAT(chip, STAT_IDLE)) {
RTS51X_DEBUGP("Idle state!\n");
RTS51X_SET_STAT(chip, STAT_IDLE);
-#ifndef LED_AUTO_BLINK
chip->led_toggle_counter = 0;
-#endif
/* Idle state, turn off LED
* to reduce power consumption */
if (chip->option.led_always_on
@@ -467,9 +352,7 @@ void rts51x_polling_func(struct rts51x_chip *chip)
switch (RTS51X_GET_STAT(chip)) {
case STAT_RUN:
-#ifndef LED_AUTO_BLINK
rts51x_blink_led(chip);
-#endif
do_remaining_work(chip);
break;
@@ -480,12 +363,10 @@ void rts51x_polling_func(struct rts51x_chip *chip)
break;
}
- if (chip->option.auto_delink_en && !chip->card_ready) {
+ if (chip->option.auto_delink_en && !chip->card_ready)
rts51x_auto_delink(chip);
- } else {
+ else
chip->auto_delink_counter = 0;
- rts51x_clear_start_time(chip);
- }
}
void rts51x_add_cmd(struct rts51x_chip *chip,
@@ -831,7 +712,7 @@ void rts51x_do_before_power_down(struct rts51x_chip *chip)
chip->cur_clk = 0;
chip->card_exist = 0;
chip->cur_card = 0;
- if (chip->asic_code && !chip->option.ww_enable) {
+ if (chip->asic_code) {
if (CHECK_PKG(chip, LQFP48)) {
rts51x_write_register(chip, CARD_PULL_CTL3, 0x80, 0x00);
rts51x_write_register(chip, CARD_PULL_CTL6, 0xf0, 0x50);
@@ -863,16 +744,6 @@ void rts51x_prepare_run(struct rts51x_chip *chip)
rts51x_write_register(chip, CLK_DIV, CLK_CHANGE, 0x00);
}
#endif
-#if 0
- if (chip->option.ss_en && RTS51X_CHK_STAT(chip, STAT_SS)) {
- rts51x_try_to_exit_ss(chip);
- wait_timeout(100);
- rts51x_init_chip(chip);
- rts51x_init_cards(chip);
- }
-
- RTS51X_SET_STAT(chip, STAT_RUN);
-#endif
}
#ifdef _MSG_TRACE
@@ -1017,24 +888,6 @@ void rts51x_pp_status(struct rts51x_chip *chip, unsigned int lun, u8 *status,
status[0x0F] = 0x00;
}
}
-#ifdef SUPPORT_SD_LOCK
- /* SD Lock/Unlock */
- if (card == SD_CARD) {
- status[0x17] = 0x80;
- if (sd_card->sd_erase_status)
- status[0x17] |= 0x01; /* Under erasing */
- if (sd_card->sd_lock_status & SD_LOCKED) {
- status[0x17] |= 0x02; /* Locked */
- status[0x07] |= 0x40; /* Read protected */
- }
- if (sd_card->sd_lock_status & SD_PWD_EXIST)
- status[0x17] |= 0x04; /* Contain PWD */
- } else {
- status[0x17] = 0x00;
- }
-
- RTS51X_DEBUGP("status[0x17] = 0x%x\n", status[0x17]);
-#endif
/* Function 0
* Support Magic Gate, CPRM and PhyRegister R/W */
@@ -1044,12 +897,6 @@ void rts51x_pp_status(struct rts51x_chip *chip, unsigned int lun, u8 *status,
* Support OC LUN status & WP LUN status */
status[0x1A] = 0x28;
- /* Function 7 */
-#ifdef SUPPORT_SD_LOCK
- /* Support SD Lock/Unlock */
- status[0x1F] = 0x01;
-#endif
-
/* Function 2
* Support OC LUN status & WP LUN status */
status[0x1A] = 0x28;
diff --git a/drivers/staging/rts5139/rts51x_chip.h b/drivers/staging/rts5139/rts51x_chip.h
index 13fc2a410d90..64257caf2f30 100644
--- a/drivers/staging/rts5139/rts51x_chip.h
+++ b/drivers/staging/rts5139/rts51x_chip.h
@@ -39,12 +39,7 @@
#define SUPPORT_CPRM
#define SUPPORT_MAGIC_GATE
#define SUPPORT_MSXC
-/* #define LED_AUTO_BLINK */
-
-/* { wwang, 2010-07-26
- * Add support for SD lock/unlock */
-/* #define SUPPORT_SD_LOCK */
-/* } wwang, 2010-07-26 */
+#define USING_POLLING_CYCLE_DELINK
#ifdef SUPPORT_MAGIC_GA
/* Using NORMAL_WRITE instead of AUTO_WRITE to set ICVTE */
@@ -63,7 +58,6 @@
#define SUPPORT_OCP
#define MS_SPEEDUP
-/* #define XD_SPEEDUP */
#define SD_XD_IO_FOLLOW_PWR
@@ -81,7 +75,6 @@
#define MAX_ALLOWED_LUN_CNT 8
#define CMD_BUF_LEN 1024
-#define RSP_BUF_LEN 1024
#define POLLING_INTERVAL 50 /* 50ms */
#define XD_FREE_TABLE_CNT 1200
@@ -128,8 +121,6 @@
#endif
#define STATUS_FAIL 1
-#define STATUS_READ_FAIL 2
-#define STATUS_WRITE_FAIL 3
#define STATUS_TIMEDOUT 4
#define STATUS_NOMEM 5
#define STATUS_TRANS_SHORT 6
@@ -139,8 +130,6 @@
#define IDLE_MAX_COUNT 10
#define POLLING_WAIT_CNT 1
-#define DELINK_DELAY 100
-#define LED_TOGGLE_INTERVAL 6
#define LED_GPIO 0
/* package */
@@ -157,8 +146,6 @@
#define TRANSPORT_GOOD 0
/* Transport good, command failed */
#define TRANSPORT_FAILED 1
-/* Command failed, no auto-sense */
-#define TRANSPORT_NO_SENSE 2
/* Transport bad (i.e. device dead) */
#define TRANSPORT_ERROR 3
@@ -195,7 +182,6 @@ struct trace_msg_t {
#define SENSE_TYPE_MEDIA_INVALID_CMD_FIELD 6
#define SENSE_TYPE_MEDIA_UNRECOVER_READ_ERR 7
#define SENSE_TYPE_MEDIA_WRITE_ERR 8
-#define SENSE_TYPE_FORMAT_IN_PROGRESS 9
#define SENSE_TYPE_FORMAT_CMD_FAILED 10
#ifdef SUPPORT_MAGIC_GATE
/* COPY PROTECTION KEY EXCHANGE FAILURE - KEY NOT ESTABLISHED */
@@ -207,83 +193,27 @@ struct trace_msg_t {
/* WRITE ERROR */
#define SENSE_TYPE_MG_WRITE_ERR 0x0e
#endif
-#ifdef SUPPORT_SD_LOCK
-/* FOR Locked SD card */
-#define SENSE_TYPE_MEDIA_READ_FORBIDDEN 0x10
-#endif
/*---- sense key ----*/
-#define ILI 0x20 /* ILI bit is on */
-
-#define NO_SENSE 0x00 /* not exist sense key */
-#define RECOVER_ERR 0x01 /* Target/Logical unit is recoverd */
-#define NOT_READY 0x02 /* Logical unit is not ready */
-#define MEDIA_ERR 0x03 /* medium/data error */
-#define HARDWARE_ERR 0x04 /* hardware error */
#define ILGAL_REQ 0x05 /* CDB/parameter/identify msg error */
-#define UNIT_ATTENTION 0x06 /* unit attention condition occur */
-#define DAT_PRTCT 0x07 /* read/write is desable */
-#define BLNC_CHK 0x08 /* find blank/DOF in read */
- /* write to unblank area */
-#define CPY_ABRT 0x0a /* Copy/Compare/Copy&Verify illgal */
-#define ABRT_CMD 0x0b /* Target make the command in error */
-#define EQUAL 0x0c /* Search Data end with Equal */
-#define VLM_OVRFLW 0x0d /* Some data are left in buffer */
-#define MISCMP 0x0e /* find inequality */
/*-----------------------------------
SENSE_DATA
-----------------------------------*/
-/*---- valid ----*/
-#define SENSE_VALID 0x80 /* Sense data is valid as SCSI2 */
-#define SENSE_INVALID 0x00 /* Sense data is invalid as SCSI2 */
/*---- error code ----*/
#define CUR_ERR 0x70 /* current error */
-#define DEF_ERR 0x71 /* specific command error */
-/*---- sense key Infomation ----*/
-#define SNSKEYINFO_LEN 3 /* length of sense key infomation */
+/*---- sense key Information ----*/
#define SKSV 0x80
#define CDB_ILLEGAL 0x40
-#define DAT_ILLEGAL 0x00
-#define BPV 0x08
-#define BIT_ILLEGAL0 0 /* bit0 is illegal */
-#define BIT_ILLEGAL1 1 /* bit1 is illegal */
-#define BIT_ILLEGAL2 2 /* bit2 is illegal */
-#define BIT_ILLEGAL3 3 /* bit3 is illegal */
-#define BIT_ILLEGAL4 4 /* bit4 is illegal */
-#define BIT_ILLEGAL5 5 /* bit5 is illegal */
-#define BIT_ILLEGAL6 6 /* bit6 is illegal */
-#define BIT_ILLEGAL7 7 /* bit7 is illegal */
/*---- ASC ----*/
-#define ASC_NO_INFO 0x00
-#define ASC_MISCMP 0x1d
#define ASC_INVLD_CDB 0x24
-#define ASC_INVLD_PARA 0x26
-#define ASC_LU_NOT_READY 0x04
-#define ASC_WRITE_ERR 0x0c
-#define ASC_READ_ERR 0x11
-#define ASC_LOAD_EJCT_ERR 0x53
-#define ASC_MEDIA_NOT_PRESENT 0x3A
-#define ASC_MEDIA_CHANGED 0x28
-#define ASC_MEDIA_IN_PROCESS 0x04
-#define ASC_WRITE_PROTECT 0x27
-#define ASC_LUN_NOT_SUPPORTED 0x25
/*---- ASQC ----*/
-#define ASCQ_NO_INFO 0x00
-#define ASCQ_MEDIA_IN_PROCESS 0x01
-#define ASCQ_MISCMP 0x00
#define ASCQ_INVLD_CDB 0x00
-#define ASCQ_INVLD_PARA 0x02
-#define ASCQ_LU_NOT_READY 0x02
-#define ASCQ_WRITE_ERR 0x02
-#define ASCQ_READ_ERR 0x00
-#define ASCQ_LOAD_EJCT_ERR 0x00
-#define ASCQ_WRITE_PROTECT 0x00
struct sense_data_t {
unsigned char err_code; /* error code */
@@ -296,13 +226,13 @@ struct sense_data_t {
unsigned char seg_no; /* segment No. */
unsigned char sense_key; /* byte5 : ILI */
/* bit3-0 : sense key */
- unsigned char info[4]; /* infomation */
+ unsigned char info[4]; /* information */
unsigned char ad_sense_len; /* additional sense data length */
- unsigned char cmd_info[4]; /* command specific infomation */
+ unsigned char cmd_info[4]; /* command specific information */
unsigned char asc; /* ASC */
unsigned char ascq; /* ASCQ */
unsigned char rfu; /* FRU */
- unsigned char sns_key_info[3]; /* sense key specific infomation */
+ unsigned char sns_key_info[3]; /* sense key specific information */
};
/* sd_ctl bit map */
@@ -323,8 +253,6 @@ struct sense_data_t {
#define SUPPORT_UHS50_MMC44 0x40
struct rts51x_option {
- u8 led_blink_speed;
-
int mspro_formatter_enable;
/* card clock expected by user for fpga platform */
@@ -368,8 +296,6 @@ struct rts51x_option {
int ss_en;
/* Interval to enter SS from IDLE state (second) */
int ss_delay;
- int needs_remote_wakeup;
- u8 ww_enable; /* sangdy2010-08-03:add for remote wakeup */
/* Enable SSC clock */
int ssc_en;
@@ -392,10 +318,7 @@ struct rts51x_option {
/*if reset or rw fail,then set SD20 pad drive again */
u8 reset_or_rw_fail_set_pad_drive;
- u8 rcc_fail_flag; /* add to indicate whether rcc bug happen */
- u8 rcc_bug_fix_en; /* if set,then support fixing rcc bug */
u8 debounce_num; /* debounce number */
- int polling_time; /* polling delay time */
u8 led_toggle_interval; /* used to control led toggle speed */
int xd_rwn_step;
u8 sd_send_status_en;
@@ -405,7 +328,7 @@ struct rts51x_option {
u8 ddr50_rx_phase;
u8 sdr50_tx_phase;
u8 sdr50_rx_phase;
- /* used to enable select sdr50 tx phase according to proportion. */
+ /* used to enable select sdr50 tx phase according to proportion. */
u8 sdr50_phase_sel;
u8 ms_errreg_fix;
u8 reset_mmc_first;
@@ -614,11 +537,6 @@ struct sd_info {
u8 sd_reset_fail; /* sangdy2010-07-01 */
u8 sd_send_status_en;
-#ifdef SUPPORT_SD_LOCK
- u8 sd_lock_status;
- u8 sd_erase_status;
- u8 sd_lock_notify;
-#endif
};
#define MODE_512_SEQ 0x01
@@ -720,9 +638,8 @@ struct rts51x_chip {
struct scsi_cmnd *srb;
struct sense_data_t sense_buffer[MAX_ALLOWED_LUN_CNT];
-#ifndef LED_AUTO_BLINK
int led_toggle_counter;
-#endif
+
int ss_counter;
int idle_counter;
int auto_delink_counter;
diff --git a/drivers/staging/rts5139/rts51x_fop.c b/drivers/staging/rts5139/rts51x_fop.c
index 6eaebb6223c9..e1200fe89579 100644
--- a/drivers/staging/rts5139/rts51x_fop.c
+++ b/drivers/staging/rts5139/rts51x_fop.c
@@ -36,7 +36,6 @@
#include "rts51x_card.h"
#include "rts51x_fop.h"
#include "sd_cprm.h"
-#include "rts51x.h"
#define RTS5139_IOC_MAGIC 0x39
@@ -234,12 +233,7 @@ ssize_t rts51x_write(struct file *filp, const char __user *buf, size_t count,
return 0;
}
-#if 0 /* LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 36) */
-int rts51x_ioctl(struct inode *inode, struct file *filp, unsigned int cmd,
- unsigned long arg)
-#else
long rts51x_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
-#endif
{
struct rts51x_chip *chip;
struct sd_direct_cmnd cmnd;
diff --git a/drivers/staging/rts5139/rts51x_fop.h b/drivers/staging/rts5139/rts51x_fop.h
index 94d75f08d255..eb45acf50d1a 100644
--- a/drivers/staging/rts5139/rts51x_fop.h
+++ b/drivers/staging/rts5139/rts51x_fop.h
@@ -50,12 +50,7 @@ ssize_t rts51x_read(struct file *filp, char __user *buf, size_t count,
loff_t *f_pos);
ssize_t rts51x_write(struct file *filp, const char __user *buf, size_t count,
loff_t *f_pos);
-#if 0 /* LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 36) */
-int rts51x_ioctl(struct inode *inode, struct file *filp, unsigned int cmd,
- unsigned long arg);
-#else
long rts51x_ioctl(struct file *filp, unsigned int cmd, unsigned long arg);
-#endif
#endif
diff --git a/drivers/staging/rts5139/rts51x_scsi.c b/drivers/staging/rts5139/rts51x_scsi.c
index 87c9cdc8bd29..e07a1f4f58cf 100644
--- a/drivers/staging/rts5139/rts51x_scsi.c
+++ b/drivers/staging/rts5139/rts51x_scsi.c
@@ -40,7 +40,6 @@
#include "rts51x_scsi.h"
#include "rts51x_card.h"
#include "rts51x_transport.h"
-#include "rts51x_sys.h"
#include "sd_cprm.h"
#include "ms_mg.h"
#include "trace.h"
@@ -370,10 +369,6 @@ void set_sense_type(struct rts51x_chip *chip, unsigned int lun, int sense_type)
ASC_INVLD_CDB, ASCQ_INVLD_CDB, CDB_ILLEGAL, 1);
break;
- case SENSE_TYPE_FORMAT_IN_PROGRESS:
- set_sense_data(chip, lun, CUR_ERR, 0x02, 0, 0x04, 0x04, 0, 0);
- break;
-
case SENSE_TYPE_FORMAT_CMD_FAILED:
set_sense_data(chip, lun, CUR_ERR, 0x03, 0, 0x31, 0x01, 0, 0);
break;
@@ -396,12 +391,6 @@ void set_sense_type(struct rts51x_chip *chip, unsigned int lun, int sense_type)
break;
#endif
-#ifdef SUPPORT_SD_LOCK
- case SENSE_TYPE_MEDIA_READ_FORBIDDEN:
- set_sense_data(chip, lun, CUR_ERR, 0x07, 0, 0x11, 0x13, 0, 0);
- break;
-#endif
-
case SENSE_TYPE_NO_SENSE:
default:
set_sense_data(chip, lun, CUR_ERR, 0, 0, 0, 0, 0, 0);
@@ -448,20 +437,6 @@ static int test_unit_ready(struct scsi_cmnd *srb, struct rts51x_chip *chip)
set_sense_type(chip, lun, SENSE_TYPE_MEDIA_CHANGE);
return TRANSPORT_FAILED;
}
-#ifdef SUPPORT_SD_LOCK
- if (get_lun_card(chip, SCSI_LUN(srb)) == SD_CARD) {
- struct sd_info *sd_card = &(chip->sd_card);
- if (sd_card->sd_lock_notify) {
- sd_card->sd_lock_notify = 0;
- set_sense_type(chip, lun, SENSE_TYPE_MEDIA_CHANGE);
- return TRANSPORT_FAILED;
- } else if (sd_card->sd_lock_status & SD_LOCKED) {
- set_sense_type(chip, lun,
- SENSE_TYPE_MEDIA_READ_FORBIDDEN);
- return TRANSPORT_FAILED;
- }
- }
-#endif
return TRANSPORT_GOOD;
}
@@ -797,9 +772,6 @@ static int request_sense(struct scsi_cmnd *srb, struct rts51x_chip *chip)
static int read_write(struct scsi_cmnd *srb, struct rts51x_chip *chip)
{
-#ifdef SUPPORT_SD_LOCK
- struct sd_info *sd_card = &(chip->sd_card);
-#endif
unsigned int lun = SCSI_LUN(srb);
int retval;
u32 start_sec;
@@ -819,25 +791,6 @@ static int read_write(struct scsi_cmnd *srb, struct rts51x_chip *chip)
rts51x_prepare_run(chip);
RTS51X_SET_STAT(chip, STAT_RUN);
-#ifdef SUPPORT_SD_LOCK
- if (sd_card->sd_erase_status) {
- /* Accessing to any card is forbidden
- * until the erase procedure of SD is completed */
- RTS51X_DEBUGP("SD card being erased!\n");
- set_sense_type(chip, lun, SENSE_TYPE_MEDIA_READ_FORBIDDEN);
- TRACE_RET(chip, TRANSPORT_FAILED);
- }
-
- if (get_lun_card(chip, lun) == SD_CARD) {
- if (sd_card->sd_lock_status & SD_LOCKED) {
- RTS51X_DEBUGP("SD card locked!\n");
- set_sense_type(chip, lun,
- SENSE_TYPE_MEDIA_READ_FORBIDDEN);
- TRACE_RET(chip, TRANSPORT_FAILED);
- }
- }
-#endif
-
if ((srb->cmnd[0] == READ_10) || (srb->cmnd[0] == WRITE_10)) {
start_sec =
((u32) srb->cmnd[2] << 24) |
@@ -883,20 +836,12 @@ static int read_write(struct scsi_cmnd *srb, struct rts51x_chip *chip)
retval = card_rw(srb, chip, start_sec, sec_cnt);
if (retval != STATUS_SUCCESS) {
-#if 0
- if (chip->need_release & chip->lun2card[lun]) {
- set_sense_type(chip, lun, SENSE_TYPE_MEDIA_NOT_PRESENT);
- } else {
-#endif
if (srb->sc_data_direction == DMA_FROM_DEVICE) {
set_sense_type(chip, lun,
SENSE_TYPE_MEDIA_UNRECOVER_READ_ERR);
} else {
set_sense_type(chip, lun, SENSE_TYPE_MEDIA_WRITE_ERR);
}
-#if 0
- }
-#endif
TRACE_RET(chip, TRANSPORT_FAILED);
}
@@ -1516,7 +1461,7 @@ static int ms_format_cmnd(struct scsi_cmnd *srb, struct rts51x_chip *chip)
}
#ifdef SUPPORT_PCGL_1P18
-int get_ms_information(struct scsi_cmnd *srb, struct rts51x_chip *chip)
+static int get_ms_information(struct scsi_cmnd *srb, struct rts51x_chip *chip)
{
struct ms_info *ms_card = &(chip->ms_card);
unsigned int lun = SCSI_LUN(srb);
@@ -1677,7 +1622,7 @@ static int sd_extention_cmnd(struct scsi_cmnd *srb, struct rts51x_chip *chip)
#endif
#ifdef SUPPORT_MAGIC_GATE
-int mg_report_key(struct scsi_cmnd *srb, struct rts51x_chip *chip)
+static int mg_report_key(struct scsi_cmnd *srb, struct rts51x_chip *chip)
{
struct ms_info *ms_card = &(chip->ms_card);
unsigned int lun = SCSI_LUN(srb);
@@ -1764,7 +1709,7 @@ int mg_report_key(struct scsi_cmnd *srb, struct rts51x_chip *chip)
return TRANSPORT_GOOD;
}
-int mg_send_key(struct scsi_cmnd *srb, struct rts51x_chip *chip)
+static int mg_send_key(struct scsi_cmnd *srb, struct rts51x_chip *chip)
{
struct ms_info *ms_card = &(chip->ms_card);
unsigned int lun = SCSI_LUN(srb);
@@ -1871,30 +1816,10 @@ int mg_send_key(struct scsi_cmnd *srb, struct rts51x_chip *chip)
int rts51x_scsi_handler(struct scsi_cmnd *srb, struct rts51x_chip *chip)
{
-#ifdef SUPPORT_SD_LOCK
- struct sd_info *sd_card = &(chip->sd_card);
-#endif
struct ms_info *ms_card = &(chip->ms_card);
unsigned int lun = SCSI_LUN(srb);
int result = TRANSPORT_GOOD;
-#ifdef SUPPORT_SD_LOCK
- if (sd_card->sd_erase_status) {
- /* Block all SCSI command except for REQUEST_SENSE
- * and rs_ppstatus */
- if (!
- ((srb->cmnd[0] == VENDOR_CMND)
- && (srb->cmnd[1] == SCSI_APP_CMD)
- && (srb->cmnd[2] == GET_DEV_STATUS))
- && (srb->cmnd[0] != REQUEST_SENSE)) {
- /* Logical Unit Not Ready Format in Progress */
- set_sense_data(chip, lun, CUR_ERR, 0x02, 0, 0x04, 0x04,
- 0, 0);
- TRACE_RET(chip, TRANSPORT_FAILED);
- }
- }
-#endif
-
if ((get_lun_card(chip, lun) == MS_CARD) &&
(ms_card->format_status == FORMAT_IN_PROGRESS)) {
if ((srb->cmnd[0] != REQUEST_SENSE)
@@ -1994,11 +1919,6 @@ int rts51x_scsi_handler(struct scsi_cmnd *srb, struct rts51x_chip *chip)
* Host functions
***********************************************************************/
-const char *host_info(struct Scsi_Host *host)
-{
- return "SCSI emulation for RTS51xx USB driver-based card reader";
-}
-
int slave_alloc(struct scsi_device *sdev)
{
/*
@@ -2111,14 +2031,7 @@ int queuecommand_lck(struct scsi_cmnd *srb, void (*done) (struct scsi_cmnd *))
return 0;
}
-#if 0 /* LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 37) */
-int queuecommand(struct scsi_cmnd *srb, void (*done) (struct scsi_cmnd *))
-{
- return queuecommand_lck(srb, done);
-}
-#else
DEF_SCSI_QCMD(queuecommand)
-#endif
/***********************************************************************
* Error handling functions
***********************************************************************/
diff --git a/drivers/staging/rts5139/rts51x_scsi.h b/drivers/staging/rts5139/rts51x_scsi.h
index 3a8ca069b278..9042bc98a9a0 100644
--- a/drivers/staging/rts5139/rts51x_scsi.h
+++ b/drivers/staging/rts5139/rts51x_scsi.h
@@ -73,7 +73,7 @@
#define GET_BATCHRSP 0x44
#ifdef SUPPORT_CPRM
-/* SD Pass Through Command Extention */
+/* SD Pass Through Command Extension */
#define SD_PASS_THRU_MODE 0xD0
#define SD_EXECUTE_NO_DATA 0xD1
#define SD_EXECUTE_READ 0xD2
@@ -145,16 +145,11 @@ struct Scsi_Host;
struct scsi_device;
struct scsi_cmnd;
-const char *host_info(struct Scsi_Host *host);
int slave_alloc(struct scsi_device *sdev);
int slave_configure(struct scsi_device *sdev);
int proc_info(struct Scsi_Host *host, char *buffer,
char **start, off_t offset, int length, int inout);
-#if 0 /* LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 37) */
-int queuecommand(struct scsi_cmnd *srb, void (*done) (struct scsi_cmnd *));
-#else
int queuecommand(struct Scsi_Host *, struct scsi_cmnd *);
-#endif
int command_abort(struct scsi_cmnd *srb);
int device_reset(struct scsi_cmnd *srb);
int bus_reset(struct scsi_cmnd *srb);
diff --git a/drivers/staging/rts5139/rts51x_sys.h b/drivers/staging/rts5139/rts51x_sys.h
deleted file mode 100644
index b09cd34a6c02..000000000000
--- a/drivers/staging/rts5139/rts51x_sys.h
+++ /dev/null
@@ -1,54 +0,0 @@
-/* Driver for Realtek USB RTS51xx card reader
- * Header file
- *
- * Copyright(c) 2009 Realtek Semiconductor Corp. All rights reserved.
- *
- * 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, or (at your option) any
- * later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, see <http://www.gnu.org/licenses/>.
- *
- * Author:
- * wwang (wei_wang@realsil.com.cn)
- * No. 450, Shenhu Road, Suzhou Industry Park, Suzhou, China
- * Maintainer:
- * Edwin Rong (edwin_rong@realsil.com.cn)
- * No. 450, Shenhu Road, Suzhou Industry Park, Suzhou, China
- */
-
-#ifndef __RTS51X_SYS_H
-#define __RTS51X_SYS_H
-
-#include "rts51x.h"
-#include "rts51x_chip.h"
-#include "rts51x_card.h"
-
-#define USING_POLLING_CYCLE_DELINK
-
-extern int rts51x_check_start_time(struct rts51x_chip *chip);
-extern void rts51x_set_start_time(struct rts51x_chip *chip);
-extern void rts51x_clear_start_time(struct rts51x_chip *chip);
-
-/* typedef dma_addr_t ULONG_PTR; */
-
-static inline void rts51x_reset_detected_cards(struct rts51x_chip *chip)
-{
-/* rts51x_reset_cards(chip); */
-}
-
-static inline void clear_first_install_mark(struct rts51x_chip *chip)
-{
-}
-
-void rts51x_enter_ss(struct rts51x_chip *chip);
-void rts51x_exit_ss(struct rts51x_chip *chip);
-
-#endif /* __RTS51X_SYS_H */
diff --git a/drivers/staging/rts5139/rts51x_transport.c b/drivers/staging/rts5139/rts51x_transport.c
index da9c83b49426..89e4d805a345 100644
--- a/drivers/staging/rts5139/rts51x_transport.c
+++ b/drivers/staging/rts5139/rts51x_transport.c
@@ -120,7 +120,7 @@ unsigned int rts51x_access_sglist(unsigned char *buffer,
return cnt;
}
-unsigned int rts51x_access_xfer_buf(unsigned char *buffer,
+static unsigned int rts51x_access_xfer_buf(unsigned char *buffer,
unsigned int buflen, struct scsi_cmnd *srb,
struct scatterlist **sgptr,
unsigned int *offset, enum xfer_buf_dir dir)
@@ -252,6 +252,8 @@ static int rts51x_msg_common(struct rts51x_chip *chip, struct urb *urb,
return status;
}
+static int rts51x_clear_halt(struct rts51x_chip *chip, unsigned int pipe);
+
/*
* Interpret the results of a URB transfer
*/
@@ -359,7 +361,7 @@ int rts51x_ctrl_transfer(struct rts51x_chip *chip, unsigned int pipe,
rts51x->current_urb->actual_length);
}
-int rts51x_clear_halt(struct rts51x_chip *chip, unsigned int pipe)
+static int rts51x_clear_halt(struct rts51x_chip *chip, unsigned int pipe)
{
int result;
int endp = usb_pipeendpoint(pipe);
@@ -378,11 +380,6 @@ int rts51x_clear_halt(struct rts51x_chip *chip, unsigned int pipe)
return STATUS_SUCCESS;
}
-int rts51x_reset_pipe(struct rts51x_chip *chip, char pipe)
-{
- return rts51x_clear_halt(chip, pipe);
-}
-
static void rts51x_sg_clean(struct usb_sg_request *io)
{
if (io->urbs) {
@@ -391,226 +388,17 @@ static void rts51x_sg_clean(struct usb_sg_request *io)
kfree(io->urbs);
io->urbs = NULL;
}
-#if 0 /* LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 35) */
- if (io->dev->dev.dma_mask != NULL)
- usb_buffer_unmap_sg(io->dev, usb_pipein(io->pipe),
- io->sg, io->nents);
-#endif
io->dev = NULL;
}
-#if 0
-static void rts51x_sg_complete(struct urb *urb)
-{
- struct usb_sg_request *io = urb->context;
- int status = urb->status;
-
- spin_lock(&io->lock);
-
- /* In 2.5 we require hcds' endpoint queues not to progress after fault
- * reports, until the completion callback (this!) returns. That lets
- * device driver code (like this routine) unlink queued urbs first,
- * if it needs to, since the HC won't work on them at all. So it's
- * not possible for page N+1 to overwrite page N, and so on.
- *
- * That's only for "hard" faults; "soft" faults (unlinks) sometimes
- * complete before the HCD can get requests away from hardware,
- * though never during cleanup after a hard fault.
- */
- if (io->status
- && (io->status != -ECONNRESET
- || status != -ECONNRESET)
- && urb->actual_length) {
- dev_err(io->dev->bus->controller,
- "dev %s ep%d%s scatterlist error %d/%d\n",
- io->dev->devpath,
- usb_endpoint_num(&urb->ep->desc),
- usb_urb_dir_in(urb) ? "in" : "out",
- status, io->status);
- /* BUG (); */
- }
-
- if (io->status == 0 && status && status != -ECONNRESET) {
- int i, found, retval;
-
- io->status = status;
-
- /* the previous urbs, and this one, completed already.
- * unlink pending urbs so they won't rx/tx bad data.
- * careful: unlink can sometimes be synchronous...
- */
- spin_unlock(&io->lock);
- for (i = 0, found = 0; i < io->entries; i++) {
- if (!io->urbs[i] || !io->urbs[i]->dev)
- continue;
- if (found) {
- retval = usb_unlink_urb(io->urbs[i]);
- if (retval != -EINPROGRESS &&
- retval != -ENODEV &&
- retval != -EBUSY)
- dev_err(&io->dev->dev,
- "%s, unlink --> %d\n",
- __func__, retval);
- } else if (urb == io->urbs[i])
- found = 1;
- }
- spin_lock(&io->lock);
- }
- urb->dev = NULL;
-
- /* on the last completion, signal usb_sg_wait() */
- io->bytes += urb->actual_length;
- io->count--;
- if (!io->count)
- complete(&io->complete);
-
- spin_unlock(&io->lock);
-}
-
-/* This function is ported from usb_sg_init, which can transfer
- * sg list partially */
-int rts51x_sg_init_partial(struct usb_sg_request *io, struct usb_device *dev,
- unsigned pipe, unsigned period, void *buf, struct scatterlist **sgptr,
- unsigned int *offset, int nents, size_t length, gfp_t mem_flags)
-{
- int i;
- int urb_flags;
- int dma;
- struct scatterlist *sg = *sgptr, *first_sg;
-
- first_sg = (struct scatterlist *)buf;
- if (!sg)
- sg = first_sg;
-
- if (!io || !dev || !sg
- || usb_pipecontrol(pipe)
- || usb_pipeisoc(pipe)
- || (nents <= 0))
- return -EINVAL;
-
- spin_lock_init(&io->lock);
- io->dev = dev;
- io->pipe = pipe;
- io->sg = first_sg; /* used by unmap */
- io->nents = nents;
-
- RTS51X_DEBUGP("Before map, sg address: 0x%x\n", (unsigned int)sg);
- RTS51X_DEBUGP("Before map, dev address: 0x%x\n", (unsigned int)dev);
-
- /* not all host controllers use DMA (like the mainstream pci ones);
- * they can use PIO (sl811) or be software over another transport.
- */
- dma = (dev->dev.dma_mask != NULL);
- if (dma) {
- /* map the whole sg list, because here we only know the
- * total nents */
- io->entries = usb_buffer_map_sg(dev, usb_pipein(pipe),
- first_sg, nents);
- } else {
- io->entries = nents;
- }
-
- /* initialize all the urbs we'll use */
- if (io->entries <= 0)
- return io->entries;
-
- io->urbs = kmalloc(io->entries * sizeof *io->urbs, mem_flags);
- if (!io->urbs)
- goto nomem;
-
- urb_flags = URB_NO_INTERRUPT;
- if (dma)
- urb_flags |= URB_NO_TRANSFER_DMA_MAP;
- if (usb_pipein(pipe))
- urb_flags |= URB_SHORT_NOT_OK;
-
- RTS51X_DEBUGP("io->entries = %d\n", io->entries);
-
- for (i = 0; (sg != NULL) && (length > 0); i++) {
- unsigned len;
-
- RTS51X_DEBUGP("sg address: 0x%x\n", (unsigned int)sg);
- RTS51X_DEBUGP("length = %d, *offset = %d\n", length, *offset);
-
- io->urbs[i] = usb_alloc_urb(0, mem_flags);
- if (!io->urbs[i]) {
- io->entries = i;
- goto nomem;
- }
-
- io->urbs[i]->dev = NULL;
- io->urbs[i]->pipe = pipe;
- io->urbs[i]->interval = period;
- io->urbs[i]->transfer_flags = urb_flags;
-
- io->urbs[i]->complete = rts51x_sg_complete;
- io->urbs[i]->context = io;
-
- if (dma) {
- io->urbs[i]->transfer_dma =
- sg_dma_address(sg) + *offset;
- len = sg_dma_len(sg) - *offset;
- io->urbs[i]->transfer_buffer = NULL;
- RTS51X_DEBUGP(" -- sg entry dma length = %d\n",
- sg_dma_len(sg));
- } else {
- /* hc may use _only_ transfer_buffer */
- io->urbs[i]->transfer_buffer = sg_virt(sg) + *offset;
- len = sg->length - *offset;
- RTS51X_DEBUGP(" -- sg entry length = %d\n",
- sg->length);
- }
-
- if (length >= len) {
- *offset = 0;
- io->urbs[i]->transfer_buffer_length = len;
- length -= len;
- sg = sg_next(sg);
- } else {
- *offset += length;
- io->urbs[i]->transfer_buffer_length = length;
- length = 0;
- }
- if (length == 0)
- io->entries = i + 1;
-#if 0
- if (length) {
- len = min_t(unsigned, len, length);
- length -= len;
- if (length == 0) {
- io->entries = i + 1;
- *offset += len;
- } else {
- *offset = 0;
- }
- }
-#endif
- }
- RTS51X_DEBUGP("In %s, urb count: %d\n", __func__, i);
- io->urbs[--i]->transfer_flags &= ~URB_NO_INTERRUPT;
-
- RTS51X_DEBUGP("sg address stored in sgptr: 0x%x\n", (unsigned int)sg);
- *sgptr = sg;
-
- /* transaction state */
- io->count = io->entries;
- io->status = 0;
- io->bytes = 0;
- init_completion(&io->complete);
- return 0;
-nomem:
- rts51x_sg_clean(io);
- return -ENOMEM;
-}
-#endif
-int rts51x_sg_init(struct usb_sg_request *io, struct usb_device *dev,
+static int rts51x_sg_init(struct usb_sg_request *io, struct usb_device *dev,
unsigned pipe, unsigned period, struct scatterlist *sg,
int nents, size_t length, gfp_t mem_flags)
{
return usb_sg_init(io, dev, pipe, period, sg, nents, length, mem_flags);
}
-int rts51x_sg_wait(struct usb_sg_request *io, int timeout)
+static int rts51x_sg_wait(struct usb_sg_request *io, int timeout)
{
long timeleft;
int i;
@@ -630,7 +418,7 @@ int rts51x_sg_wait(struct usb_sg_request *io, int timeout)
*/
spin_unlock_irq(&io->lock);
switch (retval) {
- /* maybe we retrying will recover */
+ /* maybe the retry will recover */
case -ENXIO: /* hc didn't queue this one */
case -EAGAIN:
case -ENOMEM:
@@ -740,56 +528,9 @@ static int rts51x_bulk_transfer_sglist(struct rts51x_chip *chip,
return interpret_urb_result(chip, pipe, length, result,
chip->usb->current_sg.bytes);
}
-#if 0
-static int rts51x_bulk_transfer_sglist_partial(struct rts51x_chip *chip,
- unsigned int pipe, void *buf, struct scatterlist **sgptr,
- unsigned int *offset, int num_sg, unsigned int length,
- unsigned int *act_len, int timeout)
-{
- int result;
-
- /* don't submit s-g requests during abort processing */
- if (test_bit(FLIDX_ABORTING, &chip->usb->dflags))
- TRACE_RET(chip, STATUS_ERROR);
- /* initialize the scatter-gather request block */
- RTS51X_DEBUGP("%s: xfer %u bytes, %d entries\n", __func__,
- length, num_sg);
- result = rts51x_sg_init_partial(&chip->usb->current_sg,
- chip->usb->pusb_dev, pipe, 0, buf, sgptr, offset,
- num_sg, length, GFP_NOIO);
- if (result) {
- RTS51X_DEBUGP("rts51x_sg_init_partial returned %d\n", result);
- TRACE_RET(chip, STATUS_ERROR);
- }
-
- /* since the block has been initialized successfully, it's now
- * okay to cancel it */
- set_bit(FLIDX_SG_ACTIVE, &chip->usb->dflags);
-
- /* did an abort occur during the submission? */
- if (test_bit(FLIDX_ABORTING, &chip->usb->dflags)) {
-
- /* cancel the request, if it hasn't been cancelled already */
- if (test_and_clear_bit(FLIDX_SG_ACTIVE, &chip->usb->dflags)) {
- RTS51X_DEBUGP("-- cancelling sg request\n");
- usb_sg_cancel(&chip->usb->current_sg);
- }
- }
-
- /* wait for the completion of the transfer */
- result = rts51x_sg_wait(&chip->usb->current_sg, timeout);
-
- clear_bit(FLIDX_SG_ACTIVE, &chip->usb->dflags);
-
- /* result = us->current_sg.status; */
- if (act_len)
- *act_len = chip->usb->current_sg.bytes;
- return interpret_urb_result(chip, pipe, length, result,
- chip->usb->current_sg.bytes);
-}
-#endif
-int rts51x_bulk_transfer_buf(struct rts51x_chip *chip, unsigned int pipe,
+static int rts51x_bulk_transfer_buf(struct rts51x_chip *chip,
+ unsigned int pipe,
void *buf, unsigned int length,
unsigned int *act_len, int timeout)
{
@@ -860,11 +601,6 @@ int rts51x_transfer_data_partial(struct rts51x_chip *chip, unsigned int pipe,
}
kfree(tmp_buf);
-#if 0
- result = rts51x_bulk_transfer_sglist_partial(chip, pipe, buf,
- (struct scatterlist **)ptr, offset,
- use_sg, len, act_len, timeout);
-#endif
} else {
unsigned int step = 0;
if (offset)
diff --git a/drivers/staging/rts5139/rts51x_transport.h b/drivers/staging/rts5139/rts51x_transport.h
index 9dd556ea9c08..024f115540a6 100644
--- a/drivers/staging/rts5139/rts51x_transport.h
+++ b/drivers/staging/rts5139/rts51x_transport.h
@@ -40,11 +40,6 @@ unsigned int rts51x_access_sglist(unsigned char *buffer,
unsigned int buflen, void *sglist,
void **sgptr, unsigned int *offset,
enum xfer_buf_dir dir);
-unsigned int rts51x_access_xfer_buf(unsigned char *buffer, unsigned int buflen,
- struct scsi_cmnd *srb,
- struct scatterlist **sgptr,
- unsigned int *offset,
- enum xfer_buf_dir dir);
void rts51x_set_xfer_buf(unsigned char *buffer, unsigned int buflen,
struct scsi_cmnd *srb);
void rts51x_get_xfer_buf(unsigned char *buffer, unsigned int buflen,
@@ -53,7 +48,6 @@ void rts51x_get_xfer_buf(unsigned char *buffer, unsigned int buflen,
int rts51x_ctrl_transfer(struct rts51x_chip *chip, unsigned int pipe,
u8 request, u8 requesttype, u16 value, u16 index,
void *data, u16 size, int timeout);
-int rts51x_clear_halt(struct rts51x_chip *chip, unsigned int pipe);
int rts51x_transfer_data(struct rts51x_chip *chip, unsigned int pipe,
void *buf, unsigned int len, int use_sg,
unsigned int *act_len, int timeout);
@@ -62,12 +56,6 @@ int rts51x_transfer_data_partial(struct rts51x_chip *chip, unsigned int pipe,
unsigned int len, int use_sg,
unsigned int *act_len, int timeout);
-/* whichPipe:
- * 0: bulk in pipe
- * 1: bulk out pipe
- * 2: intr in pipe */
-int rts51x_reset_pipe(struct rts51x_chip *chip, char pipe);
-
#ifndef POLLING_IN_THREAD
int rts51x_start_epc_transfer(struct rts51x_chip *chip);
void rts51x_cancel_epc_transfer(struct rts51x_chip *chip);
diff --git a/drivers/staging/rts5139/sd.c b/drivers/staging/rts5139/sd.c
index d5dd2f926d1d..b739f26f78cc 100644
--- a/drivers/staging/rts5139/sd.c
+++ b/drivers/staging/rts5139/sd.c
@@ -246,12 +246,7 @@ RTY_SEND_CMD:
if (buf[1] & 0x80)
TRACE_RET(chip, STATUS_FAIL);
}
-#ifdef SUPPORT_SD_LOCK
- /* exclude bit25 CARD_IS_LOCKED */
- if (buf[1] & 0x7D) {
-#else
if (buf[1] & 0x7F) {
-#endif
RTS51X_DEBUGP("buf[1]: 0x%02x\n", buf[1]);
TRACE_RET(chip, STATUS_FAIL);
}
@@ -709,37 +704,7 @@ int sd_select_card(struct rts51x_chip *chip, int select)
return STATUS_SUCCESS;
}
-#ifdef SUPPORT_SD_LOCK
-int sd_update_lock_status(struct rts51x_chip *chip)
-{
- struct sd_info *sd_card = &(chip->sd_card);
- int retval;
- u8 rsp[5];
-
- retval =
- sd_send_cmd_get_rsp(chip, SEND_STATUS, sd_card->sd_addr,
- SD_RSP_TYPE_R1, rsp, 5);
- if (retval != STATUS_SUCCESS)
- TRACE_RET(chip, STATUS_FAIL);
-
- if (rsp[1] & 0x02)
- sd_card->sd_lock_status |= SD_LOCKED;
- else
- sd_card->sd_lock_status &= ~SD_LOCKED;
-
- RTS51X_DEBUGP("sd_card->sd_lock_status = 0x%x\n",
- sd_card->sd_lock_status);
-
- if (rsp[1] & 0x01) {
- /* LOCK_UNLOCK_FAILED */
- TRACE_RET(chip, STATUS_FAIL);
- }
-
- return STATUS_SUCCESS;
-}
-#endif
-
-int sd_wait_currentstate_dataready(struct rts51x_chip *chip, u8 statechk,
+static int sd_wait_currentstate_dataready(struct rts51x_chip *chip, u8 statechk,
u8 rdychk, u16 pollingcnt)
{
struct sd_info *sd_card = &(chip->sd_card);
@@ -1197,15 +1162,6 @@ static int sd_switch_function(struct rts51x_chip *chip, u8 bus_width)
RTS51X_DEBUGP("SD_FUNC_GROUP_1: func_to_switch = 0x%02x",
func_to_switch);
-#ifdef SUPPORT_SD_LOCK
- if ((sd_card->sd_lock_status & SD_SDR_RST)
- && (DDR50_SUPPORT == func_to_switch)
- && (sd_card->func_group1_mask & SDR50_SUPPORT_MASK)) {
- func_to_switch = SDR50_SUPPORT;
- RTS51X_DEBUGP("Using SDR50 instead of DDR50 for SD Lock\n");
- }
-#endif
-
if (func_to_switch) {
retval =
sd_check_switch(chip, SD_FUNC_GROUP_1, func_to_switch,
@@ -1562,7 +1518,7 @@ static u8 sd_search_final_phase(struct rts51x_chip *chip, u32 phase_map,
}
Search_Finish:
- RTS51X_DEBUGP("Final choosen phase: %d\n", final_phase);
+ RTS51X_DEBUGP("Final chosen phase: %d\n", final_phase);
return final_phase;
}
@@ -2024,10 +1980,6 @@ Switch_Fail:
k = 0;
hi_cap_flow = 0;
support_1v8 = 0;
-#ifdef SUPPORT_SD_LOCK
- if (sd_card->sd_lock_status & SD_UNLOCK_POW_ON)
- goto SD_UNLOCK_ENTRY;
-#endif
retval = sd_prepare_reset(chip);
if (retval != STATUS_SUCCESS)
@@ -2182,7 +2134,7 @@ RTY_CMD55:
sd_card->sd_addr += (u32) rsp[2] << 16;
/* Get CSD register for Calculating Timing,Capacity,
- * Check CSD to determaine as if this is the SD ROM card */
+ * Check CSD to determine as if this is the SD ROM card */
retval = sd_check_csd(chip, 1);
if (retval != STATUS_SUCCESS)
TRACE_RET(chip, retval);
@@ -2190,20 +2142,6 @@ RTY_CMD55:
retval = sd_select_card(chip, 1);
if (retval != STATUS_SUCCESS)
TRACE_RET(chip, retval);
-#ifdef SUPPORT_SD_LOCK
-SD_UNLOCK_ENTRY:
- /* Get SD lock status */
- retval = sd_update_lock_status(chip);
- if (retval != STATUS_SUCCESS)
- TRACE_RET(chip, STATUS_FAIL);
-
- if (sd_card->sd_lock_status & SD_LOCKED) {
- sd_card->sd_lock_status |= (SD_LOCK_1BIT_MODE | SD_PWD_EXIST);
- return STATUS_SUCCESS;
- } else if (!(sd_card->sd_lock_status & SD_UNLOCK_POW_ON)) {
- sd_card->sd_lock_status &= ~SD_PWD_EXIST;
- }
-#endif
/* ACMD42 */
retval =
@@ -2294,10 +2232,6 @@ SD_UNLOCK_ENTRY:
if (retval != STATUS_SUCCESS)
TRACE_RET(chip, retval);
}
-#ifdef SUPPORT_SD_LOCK
- /* clear 1 bit mode status */
- sd_card->sd_lock_status &= ~SD_LOCK_1BIT_MODE;
-#endif
if (CHK_SD30_SPEED(sd_card)) {
rts51x_write_register(chip, SD30_DRIVE_SEL, SD30_DRIVE_MASK,
@@ -2380,19 +2314,6 @@ SD_UNLOCK_ENTRY:
chip->card_bus_width[chip->card2lun[SD_CARD]] = 4;
-#ifdef SUPPORT_SD_LOCK
- if (sd_card->sd_lock_status & SD_UNLOCK_POW_ON) {
- rts51x_init_cmd(chip);
-
- rts51x_add_cmd(chip, WRITE_REG_CMD, SD_BLOCK_CNT_H, 0xFF, 0x02);
- rts51x_add_cmd(chip, WRITE_REG_CMD, SD_BLOCK_CNT_L, 0xFF, 0x00);
-
- retval = rts51x_send_cmd(chip, MODE_C, 100);
- if (retval != STATUS_SUCCESS)
- TRACE_RET(chip, retval);
- }
-#endif
-
return STATUS_SUCCESS;
}
@@ -2587,17 +2508,10 @@ static int mmc_switch_timing_bus(struct rts51x_chip *chip)
sd_card->capacity =
((u32) buf[5] << 24) | ((u32) buf[4] << 16) |
((u32) buf[3] << 8) | ((u32) buf[2]);
-#ifdef SUPPORT_SD_LOCK
- if (!(sd_card->sd_lock_status & SD_SDR_RST) && CHECK_UHS50(chip))
- card_type_mask = 0x07;
- else
- card_type_mask = 0x03;
-#else
if (CHECK_UHS50(chip))
card_type_mask = 0x07;
else
card_type_mask = 0x03;
-#endif
card_type = buf[1] & card_type_mask;
if (card_type) {
@@ -2626,15 +2540,9 @@ static int mmc_switch_timing_bus(struct rts51x_chip *chip)
if (mmc_test_switch_bus(chip, MMC_8BIT_BUS) == STATUS_SUCCESS) {
SET_MMC_8BIT(sd_card);
chip->card_bus_width[chip->card2lun[SD_CARD]] = 8;
-#ifdef SUPPORT_SD_LOCK
- sd_card->sd_lock_status &= ~SD_LOCK_1BIT_MODE;
-#endif
} else if (mmc_test_switch_bus(chip, MMC_4BIT_BUS) == STATUS_SUCCESS) {
SET_MMC_4BIT(sd_card);
chip->card_bus_width[chip->card2lun[SD_CARD]] = 4;
-#ifdef SUPPORT_SD_LOCK
- sd_card->sd_lock_status &= ~SD_LOCK_1BIT_MODE;
-#endif
} else {
CLR_MMC_8BIT(sd_card);
CLR_MMC_4BIT(sd_card);
@@ -2652,11 +2560,6 @@ static int reset_mmc(struct rts51x_chip *chip)
u8 change_to_ddr52 = 1;
u8 cmd[5];
-#ifdef SUPPORT_SD_LOCK
- if (sd_card->sd_lock_status & SD_UNLOCK_POW_ON)
- goto MMC_UNLOCK_ENTRY;
-#endif
-
MMC_DDR_FAIL:
retval = sd_prepare_reset(chip);
@@ -2745,7 +2648,7 @@ RTY_MMC_RST:
TRACE_RET(chip, retval);
/* Get CSD register for Calculating Timing,Capacity
- * Check CSD to determaine as if this is the SD ROM card */
+ * Check CSD to determine as if this is the SD ROM card */
retval = sd_check_csd(chip, 1);
if (retval != STATUS_SUCCESS)
TRACE_RET(chip, retval);
@@ -2763,13 +2666,6 @@ RTY_MMC_RST:
0);
if (retval != STATUS_SUCCESS)
TRACE_RET(chip, retval);
-#ifdef SUPPORT_SD_LOCK
-MMC_UNLOCK_ENTRY:
- /* Get SD lock status */
- retval = sd_update_lock_status(chip);
- if (retval != STATUS_SUCCESS)
- TRACE_RET(chip, STATUS_FAIL);
-#endif
RTS51X_WRITE_REG(chip, SD_CFG1, SD_CLK_DIVIDE_MASK, SD_CLK_DIVIDE_0);
@@ -2842,18 +2738,6 @@ MMC_UNLOCK_ENTRY:
}
}
}
-#ifdef SUPPORT_SD_LOCK
- if (sd_card->sd_lock_status & SD_UNLOCK_POW_ON) {
- rts51x_init_cmd(chip);
-
- rts51x_add_cmd(chip, WRITE_REG_CMD, SD_BLOCK_CNT_H, 0xFF, 0x02);
- rts51x_add_cmd(chip, WRITE_REG_CMD, SD_BLOCK_CNT_L, 0xFF, 0x00);
-
- retval = rts51x_send_cmd(chip, MODE_C, 100);
- if (retval != STATUS_SUCCESS)
- TRACE_RET(chip, retval);
- }
-#endif
retval = rts51x_get_card_status(chip, &(chip->card_status));
if (retval != STATUS_SUCCESS)
@@ -2879,11 +2763,6 @@ int reset_sd_card(struct rts51x_chip *chip)
sd_card->capacity = 0;
sd_card->sd_switch_fail = 0;
-#ifdef SUPPORT_SD_LOCK
- sd_card->sd_lock_status = 0;
- sd_card->sd_erase_status = 0;
-#endif
-
sd_clear_reset_fail(chip);
enable_card_clock(chip, SD_CARD);
@@ -3006,7 +2885,7 @@ static int wait_data_buf_ready(struct rts51x_chip *chip)
TRACE_RET(chip, STATUS_FAIL);
}
-void sd_stop_seq_mode(struct rts51x_chip *chip)
+static void sd_stop_seq_mode(struct rts51x_chip *chip)
{
struct sd_info *sd_card = &(chip->sd_card);
int retval;
@@ -3300,7 +3179,7 @@ void sd_cleanup_work(struct rts51x_chip *chip)
}
}
-inline void sd_fill_power_off_card3v3(struct rts51x_chip *chip)
+static inline void sd_fill_power_off_card3v3(struct rts51x_chip *chip)
{
rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_CLK_EN, SD_CLK_EN, 0);
@@ -3322,7 +3201,7 @@ inline void sd_fill_power_off_card3v3(struct rts51x_chip *chip)
}
}
-int sd_power_off_card3v3(struct rts51x_chip *chip)
+static int sd_power_off_card3v3(struct rts51x_chip *chip)
{
int retval;
@@ -3346,17 +3225,12 @@ int release_sd_card(struct rts51x_chip *chip)
struct sd_info *sd_card = &(chip->sd_card);
int retval;
- RTS51X_DEBUGP("elease_sd_card\n");
+ RTS51X_DEBUGP("release_sd_card\n");
chip->card_ready &= ~SD_CARD;
chip->card_fail &= ~SD_CARD;
chip->card_wp &= ~SD_CARD;
-#ifdef SUPPORT_SD_LOCK
- sd_card->sd_lock_status = 0;
- sd_card->sd_erase_status = 0;
-#endif
-
memset(sd_card->raw_csd, 0, 16);
memset(sd_card->raw_scr, 0, 8);
diff --git a/drivers/staging/rts5139/sd.h b/drivers/staging/rts5139/sd.h
index 0805edcaea86..de155d8e682d 100644
--- a/drivers/staging/rts5139/sd.h
+++ b/drivers/staging/rts5139/sd.h
@@ -141,29 +141,6 @@
#define SWITCH_MODE_ERR 0x06
#define SWITCH_PASS 0x07
-#ifdef SUPPORT_SD_LOCK
-/* CMD42 Parameter */
-#define SD_ERASE 0x08
-#define SD_LOCK 0x04
-#define SD_UNLOCK 0x00
-#define SD_CLR_PWD 0x02
-#define SD_SET_PWD 0x01
-
-#define SD_PWD_LEN 0x10
-
-/* SD lock unlock Status */
-#define SD_LOCKED 0x80 /* Global lock status */
-#define SD_LOCK_1BIT_MODE 0x40 /**/
-#define SD_PWD_EXIST 0x20
-#define SD_UNLOCK_POW_ON 0x01 /**/
-#define SD_SDR_RST 0x02 /* Reset SD30 card with current DDR mode to SDR mode. */
-/* g_bySDEraseStatus */
-#define SD_NOT_ERASE 0x00
-#define SD_UNDER_ERASING 0x01
-#define SD_COMPLETE_ERASE 0x02
-/* SD_RW FAIL status */
-#define SD_RW_FORBIDDEN 0x0F /* read/write is forbidden (SD card) */
-#endif
/* Function Group Definition */
/* Function Group 1 */
#define HS_SUPPORT 0x01
@@ -282,17 +259,11 @@ struct timing_phase_path {
int sd_select_card(struct rts51x_chip *chip, int select);
int reset_sd_card(struct rts51x_chip *chip);
int sd_switch_clock(struct rts51x_chip *chip);
-void sd_stop_seq_mode(struct rts51x_chip *chip);
int sd_rw(struct scsi_cmnd *srb, struct rts51x_chip *chip, u32 start_sector,
u16 sector_cnt);
void sd_cleanup_work(struct rts51x_chip *chip);
-int sd_power_off_card3v3(struct rts51x_chip *chip);
int release_sd_card(struct rts51x_chip *chip);
-#ifdef SUPPORT_SD_LOCK
-int sd_update_lock_status(struct rts51x_chip *chip);
-#endif
-
#ifdef SUPPORT_CPRM
extern int reset_sd(struct rts51x_chip *chip);
extern int sd_check_data0_status(struct rts51x_chip *chip);
diff --git a/drivers/staging/rts5139/sd_cprm.c b/drivers/staging/rts5139/sd_cprm.c
index d5969d992d84..0167f7f35c20 100644
--- a/drivers/staging/rts5139/sd_cprm.c
+++ b/drivers/staging/rts5139/sd_cprm.c
@@ -77,12 +77,7 @@ static inline int get_rsp_type(u8 rsp_code, u8 *rsp_type, int *rsp_len)
return STATUS_SUCCESS;
}
-int soft_reset_sd_card(struct rts51x_chip *chip)
-{
- return reset_sd(chip);
-}
-
-int ext_sd_send_cmd_get_rsp(struct rts51x_chip *chip, u8 cmd_idx,
+static int ext_sd_send_cmd_get_rsp(struct rts51x_chip *chip, u8 cmd_idx,
u32 arg, u8 rsp_type, u8 *rsp, int rsp_len,
int special_check)
{
@@ -206,13 +201,8 @@ RTY_SEND_CMD:
if (buf[1] & 0x80)
TRACE_RET(chip, STATUS_FAIL);
}
-#ifdef SUPPORT_SD_LOCK
- if (buf[1] & 0x7D) {
-#else
- if (buf[1] & 0x7F) {
-#endif
+ if (buf[1] & 0x7F)
TRACE_RET(chip, STATUS_FAIL);
- }
if (buf[2] & 0xF8)
TRACE_RET(chip, STATUS_FAIL);
@@ -233,7 +223,8 @@ RTY_SEND_CMD:
return STATUS_SUCCESS;
}
-int ext_sd_get_rsp(struct rts51x_chip *chip, int len, u8 *rsp, u8 rsp_type)
+static int ext_sd_get_rsp(struct rts51x_chip *chip, int len,
+ u8 *rsp, u8 rsp_type)
{
int retval, rsp_len;
u16 reg_addr;
@@ -305,26 +296,8 @@ int ext_sd_execute_no_data(struct rts51x_chip *chip, unsigned int lun,
retval = sd_switch_clock(chip);
if (retval != STATUS_SUCCESS)
TRACE_RET(chip, TRANSPORT_FAILED);
-#ifdef SUPPORT_SD_LOCK
- if ((sd_card->sd_lock_status & SD_LOCK_1BIT_MODE) == 0) {
- if (CHK_MMC_8BIT(sd_card)) {
- retval =
- rts51x_write_register(chip, SD_CFG1, 0x03,
- SD_BUS_WIDTH_8);
- if (retval != STATUS_SUCCESS)
- TRACE_RET(chip, TRANSPORT_FAILED);
- } else if (CHK_SD(sd_card) || CHK_MMC_4BIT(sd_card)) {
- retval =
- rts51x_write_register(chip, SD_CFG1, 0x03,
- SD_BUS_WIDTH_4);
- if (retval != STATUS_SUCCESS)
- TRACE_RET(chip, TRANSPORT_FAILED);
- }
- }
-#else
/* Set H/W SD/MMC Bus Width */
rts51x_write_register(chip, SD_CFG1, 0x03, SD_BUS_WIDTH_4);
-#endif
if (standby) {
retval = sd_select_card(chip, 0);
@@ -350,12 +323,6 @@ int ext_sd_execute_no_data(struct rts51x_chip *chip, unsigned int lun,
if (retval != STATUS_SUCCESS)
TRACE_GOTO(chip, SD_Execute_Cmd_Failed);
}
-#ifdef SUPPORT_SD_LOCK
- /* Get SD lock status */
- retval = sd_update_lock_status(chip);
- if (retval != STATUS_SUCCESS)
- TRACE_GOTO(chip, SD_Execute_Cmd_Failed);
-#endif
return TRANSPORT_GOOD;
@@ -399,21 +366,7 @@ int ext_sd_execute_read_data(struct rts51x_chip *chip, unsigned int lun,
retval = sd_switch_clock(chip);
if (retval != STATUS_SUCCESS)
TRACE_RET(chip, TRANSPORT_FAILED);
-#ifdef SUPPORT_SD_LOCK
- if ((sd_card->sd_lock_status & SD_LOCK_1BIT_MODE) == 0) {
- if (CHK_MMC_8BIT(sd_card))
- bus_width = SD_BUS_WIDTH_8;
- else if (CHK_SD(sd_card) || CHK_MMC_4BIT(sd_card))
- bus_width = SD_BUS_WIDTH_4;
- else
- bus_width = SD_BUS_WIDTH_1;
- } else {
- bus_width = SD_BUS_WIDTH_4;
- }
- RTS51X_DEBUGP("bus_width = %d\n", bus_width);
-#else
bus_width = SD_BUS_WIDTH_4;
-#endif
if (data_len < 512) {
retval = ext_sd_send_cmd_get_rsp(chip, SET_BLOCKLEN, data_len,
@@ -599,11 +552,6 @@ int ext_sd_execute_write_data(struct rts51x_chip *chip, unsigned int lun,
int cmd13_checkbit = 0, write_err = 0;
u8 rsp_type;
u32 i;
-#ifdef SUPPORT_SD_LOCK
- int lock_cmd_fail = 0;
- u8 sd_lock_state = 0;
- u8 lock_cmd_type = 0;
-#endif
if (sd_card->pre_cmd_err) {
sd_card->pre_cmd_err = 0;
@@ -614,12 +562,6 @@ int ext_sd_execute_write_data(struct rts51x_chip *chip, unsigned int lun,
retval = sd_switch_clock(chip);
if (retval != STATUS_SUCCESS)
TRACE_RET(chip, STATUS_FAIL);
-#ifdef SUPPORT_SD_LOCK
- if (cmd_idx == LOCK_UNLOCK) {
- sd_lock_state = sd_card->sd_lock_status;
- sd_lock_state &= SD_LOCKED;
- }
-#endif
retval = get_rsp_type(rsp_code, &rsp_type, &rsp_len);
if (retval != STATUS_SUCCESS) {
@@ -631,25 +573,7 @@ int ext_sd_execute_write_data(struct rts51x_chip *chip, unsigned int lun,
retval = sd_switch_clock(chip);
if (retval != STATUS_SUCCESS)
TRACE_RET(chip, TRANSPORT_FAILED);
-#ifdef SUPPORT_SD_LOCK
- if ((sd_card->sd_lock_status & SD_LOCK_1BIT_MODE) == 0) {
- if (CHK_MMC_8BIT(sd_card)) {
- retval =
- rts51x_write_register(chip, SD_CFG1, 0x03,
- SD_BUS_WIDTH_8);
- if (retval != STATUS_SUCCESS)
- TRACE_RET(chip, TRANSPORT_FAILED);
- } else if (CHK_SD(sd_card) || CHK_MMC_4BIT(sd_card)) {
- retval =
- rts51x_write_register(chip, SD_CFG1, 0x03,
- SD_BUS_WIDTH_4);
- if (retval != STATUS_SUCCESS)
- TRACE_RET(chip, TRANSPORT_FAILED);
- }
- }
-#else
rts51x_write_register(chip, SD_CFG1, 0x03, SD_BUS_WIDTH_4);
-#endif
if (data_len < 512) {
retval = ext_sd_send_cmd_get_rsp(chip, SET_BLOCKLEN, data_len,
@@ -692,10 +616,6 @@ int ext_sd_execute_write_data(struct rts51x_chip *chip, unsigned int lun,
else
memcpy(buf, data_buf, data_len);
-#ifdef SUPPORT_SD_LOCK
- if (cmd_idx == LOCK_UNLOCK)
- lock_cmd_type = buf[0] & 0x0F;
-#endif
if (data_len > 256) {
rts51x_init_cmd(chip);
@@ -802,29 +722,6 @@ int ext_sd_execute_write_data(struct rts51x_chip *chip, unsigned int lun,
SD_STOP | SD_CLR_ERR);
TRACE_GOTO(chip, SD_Execute_Write_Cmd_Failed);
}
-#ifdef SUPPORT_SD_LOCK
- if (cmd_idx == LOCK_UNLOCK) {
- if (lock_cmd_type == SD_ERASE) {
- sd_card->sd_erase_status = SD_UNDER_ERASING;
- scsi_set_resid(srb, 0);
- return TRANSPORT_GOOD;
- }
-
- rts51x_init_cmd(chip);
- rts51x_add_cmd(chip, CHECK_REG_CMD, SD_BUS_STAT, SD_DAT0_STATUS,
- SD_DAT0_STATUS);
- retval = rts51x_send_cmd(chip, MODE_CR, 250);
- if (retval != STATUS_SUCCESS)
- TRACE_GOTO(chip, SD_Execute_Write_Cmd_Failed);
- rts51x_get_rsp(chip, 1, 200); /* Don't care return value */
-
- retval = sd_update_lock_status(chip);
- if (retval != STATUS_SUCCESS) {
- RTS51X_DEBUGP("Lock command fail!\n");
- lock_cmd_fail = 1;
- }
- }
-#endif /* SUPPORT_SD_LOCK */
if (standby) {
retval = sd_select_card(chip, 1);
@@ -865,51 +762,6 @@ int ext_sd_execute_write_data(struct rts51x_chip *chip, unsigned int lun,
}
if (retval != STATUS_SUCCESS)
TRACE_GOTO(chip, SD_Execute_Write_Cmd_Failed);
-#ifdef SUPPORT_SD_LOCK
- if (cmd_idx == LOCK_UNLOCK) {
- if (!lock_cmd_fail) {
- RTS51X_DEBUGP("lock_cmd_type = 0x%x\n",
- lock_cmd_type);
- if (lock_cmd_type & SD_CLR_PWD)
- sd_card->sd_lock_status &= ~SD_PWD_EXIST;
- if (lock_cmd_type & SD_SET_PWD)
- sd_card->sd_lock_status |= SD_PWD_EXIST;
- }
-
- RTS51X_DEBUGP("sd_lock_state = 0x%x,"
- "sd_card->sd_lock_status = 0x%x\n",
- sd_lock_state, sd_card->sd_lock_status);
- if (sd_lock_state ^ (sd_card->sd_lock_status & SD_LOCKED)) {
- sd_card->sd_lock_notify = 1;
- if (sd_lock_state) {
- if (sd_card->sd_lock_status &
- SD_LOCK_1BIT_MODE) {
- sd_card->sd_lock_status |=
- (SD_UNLOCK_POW_ON | SD_SDR_RST);
- if (CHK_SD(sd_card)) {
- retval = reset_sd(chip);
- if (retval != STATUS_SUCCESS) {
- sd_card->sd_lock_status
- &= ~(SD_UNLOCK_POW_ON |
- SD_SDR_RST);
- TRACE_GOTO(chip,
- SD_Execute_Write_Cmd_Failed);
- }
- }
-
- sd_card->sd_lock_status &=
- ~(SD_UNLOCK_POW_ON | SD_SDR_RST);
- }
- }
- }
- }
-
- if (lock_cmd_fail) {
- scsi_set_resid(srb, 0);
- set_sense_type(chip, lun, SENSE_TYPE_NO_SENSE);
- TRACE_RET(chip, TRANSPORT_FAILED);
- }
-#endif /* SUPPORT_SD_LOCK */
return TRANSPORT_GOOD;
@@ -992,7 +844,7 @@ int sd_pass_thru_mode(struct scsi_cmnd *srb, struct rts51x_chip *chip)
buf[15] = chip->max_lun;
- len = min(18, (int)scsi_bufflen(srb));
+ len = min_t(unsigned, 18, scsi_bufflen(srb));
rts51x_set_xfer_buf(buf, len, srb);
return TRANSPORT_GOOD;
@@ -1173,30 +1025,18 @@ int sd_hw_rst(struct scsi_cmnd *srb, struct rts51x_chip *chip)
switch (srb->cmnd[1] & 0x0F) {
case 0:
/* SD Card Power Off -> ON and Initialization */
-#ifdef SUPPORT_SD_LOCK
- if (0x64 == srb->cmnd[9]) {
- /* Command Mode */
- sd_card->sd_lock_status |= SD_SDR_RST;
- }
-#endif /* SUPPORT_SD_LOCK */
retval = reset_sd_card(chip);
if (retval != STATUS_SUCCESS) {
-#ifdef SUPPORT_SD_LOCK
- sd_card->sd_lock_status &= ~SD_SDR_RST;
-#endif
set_sense_type(chip, lun, SENSE_TYPE_MEDIA_NOT_PRESENT);
sd_card->pre_cmd_err = 1;
TRACE_RET(chip, TRANSPORT_FAILED);
}
-#ifdef SUPPORT_SD_LOCK
- sd_card->sd_lock_status &= ~SD_SDR_RST;
-#endif
break;
case 1:
/* reset CMD(CMD0) and Initialization
* (without SD Card Power Off -> ON) */
- retval = soft_reset_sd_card(chip);
+ retval = reset_sd(chip);
if (retval != STATUS_SUCCESS) {
set_sense_type(chip, lun, SENSE_TYPE_MEDIA_NOT_PRESENT);
sd_card->pre_cmd_err = 1;
diff --git a/drivers/staging/rts5139/xd.c b/drivers/staging/rts5139/xd.c
index 5820605d1806..58f8ba24caed 100644
--- a/drivers/staging/rts5139/xd.c
+++ b/drivers/staging/rts5139/xd.c
@@ -47,13 +47,6 @@ static inline void xd_set_err_code(struct rts51x_chip *chip, u8 err_code)
xd_card->err_code = err_code;
}
-static inline int xd_check_err_code(struct rts51x_chip *chip, u8 err_code)
-{
- struct xd_info *xd_card = &(chip->xd_card);
-
- return (xd_card->err_code == err_code);
-}
-
static int xd_set_init_para(struct rts51x_chip *chip)
{
struct xd_info *xd_card = &(chip->xd_card);
@@ -862,6 +855,8 @@ static void xd_set_l2p_tbl(struct rts51x_chip *chip, int zone_no, u16 log_off,
zone->l2p_table[log_off] = phy_off;
}
+static int xd_delay_write(struct rts51x_chip *chip);
+
static u32 xd_get_l2p_tbl(struct rts51x_chip *chip, int zone_no, u16 log_off)
{
struct xd_info *xd_card = &(chip->xd_card);
@@ -1182,91 +1177,6 @@ static int xd_copy_page(struct rts51x_chip *chip,
return STATUS_SUCCESS;
}
-#ifdef XD_SPEEDUP
-static int xd_auto_copy_page(struct rts51x_chip *chip,
- u32 old_blk, u32 new_blk,
- u8 start_page, u8 end_page)
-{
- struct xd_info *xd_card = &(chip->xd_card);
- u32 old_page, new_page;
- int retval;
- u8 page_count;
-
- RTS51X_DEBUGP("Auto copy page from block 0x%x to block 0x%x\n",
- old_blk, new_blk);
-
- if (start_page > end_page)
- TRACE_RET(chip, STATUS_FAIL);
-
- page_count = end_page - start_page;
-
- if ((old_blk == BLK_NOT_FOUND) || (new_blk == BLK_NOT_FOUND))
- TRACE_RET(chip, STATUS_FAIL);
-
- old_page = (old_blk << xd_card->block_shift) + start_page;
- new_page = (new_blk << xd_card->block_shift) + start_page;
-
- XD_CLR_BAD_NEWBLK(xd_card);
-
- rts51x_init_cmd(chip);
-
- rts51x_add_cmd(chip, WRITE_REG_CMD, XD_CP_WAITTIME, 0x03, WAIT_FF);
- rts51x_add_cmd(chip, WRITE_REG_CMD, XD_CP_PAGELEN, 0xFF, page_count);
-
- rts51x_add_cmd(chip, WRITE_REG_CMD, XD_CP_READADDR0, 0xFF, 0);
- rts51x_add_cmd(chip, WRITE_REG_CMD, XD_CP_READADDR1, 0xFF,
- (u8) old_page);
- rts51x_add_cmd(chip, WRITE_REG_CMD, XD_CP_READADDR2, 0xFF,
- (u8) (old_page >> 8));
- rts51x_add_cmd(chip, WRITE_REG_CMD, XD_CP_READADDR3, 0xFF,
- (u8) (old_page >> 16));
- rts51x_add_cmd(chip, WRITE_REG_CMD, XD_CP_READADDR4, 0xFF, 0);
-
- rts51x_add_cmd(chip, WRITE_REG_CMD, XD_CP_WRITEADDR0, 0xFF, 0);
- rts51x_add_cmd(chip, WRITE_REG_CMD, XD_CP_WRITEADDR1, 0xFF,
- (u8) new_page);
- rts51x_add_cmd(chip, WRITE_REG_CMD, XD_CP_WRITEADDR2, 0xFF,
- (u8) (new_page >> 8));
- rts51x_add_cmd(chip, WRITE_REG_CMD, XD_CP_WRITEADDR3, 0xFF,
- (u8) (new_page >> 16));
- rts51x_add_cmd(chip, WRITE_REG_CMD, XD_CP_WRITEADDR4, 0xFF, 0);
-
- rts51x_add_cmd(chip, WRITE_REG_CMD, CARD_DATA_SOURCE, 0x01,
- PINGPONG_BUFFER);
-
- rts51x_add_cmd(chip, WRITE_REG_CMD, XD_CFG,
- XD_BA_TRANSFORM | XD_ADDR_MASK, 0 | xd_card->addr_cycle);
-
- rts51x_add_cmd(chip, WRITE_REG_CMD, XD_CHK_DATA_STATUS,
- XD_AUTO_CHK_DATA_STATUS, 0);
- rts51x_add_cmd(chip, WRITE_REG_CMD, XD_TRANSFER, 0xFF,
- XD_TRANSFER_START | XD_COPY_PAGES);
- rts51x_add_cmd(chip, CHECK_REG_CMD, XD_TRANSFER, XD_TRANSFER_END,
- XD_TRANSFER_END);
-
- retval = rts51x_send_cmd(chip, MODE_CR, 100);
- if (retval != STATUS_SUCCESS) {
- rts51x_clear_xd_error(chip);
- TRACE_GOTO(chip, Copy_Fail);
- }
-
- retval = rts51x_get_rsp(chip, 1, 800);
- if (retval != STATUS_SUCCESS) {
- rts51x_clear_xd_error(chip);
- TRACE_GOTO(chip, Copy_Fail);
- }
-
- return STATUS_SUCCESS;
-
-Copy_Fail:
- retval = xd_copy_page(chip, old_blk, new_blk, start_page, end_page);
- if (retval != STATUS_SUCCESS)
- TRACE_RET(chip, retval);
-
- return STATUS_SUCCESS;
-}
-#endif
-
static int xd_reset_cmd(struct rts51x_chip *chip)
{
int retval;
@@ -1686,15 +1596,9 @@ Fail:
XD_CLR_BAD_OLDBLK(xd_card);
TRACE_RET(chip, STATUS_FAIL);
}
-#ifdef XD_SPEEDUP
- retval =
- xd_auto_copy_page(chip, phy_blk, new_blk, 0,
- xd_card->page_off + 1);
-#else
retval =
xd_copy_page(chip, phy_blk, new_blk, 0,
xd_card->page_off + 1);
-#endif
if (retval != STATUS_SUCCESS) {
if (!XD_CHK_BAD_NEWBLK(xd_card)) {
retval = xd_erase_block(chip, new_blk);
@@ -1741,13 +1645,8 @@ static int xd_finish_write(struct rts51x_chip *chip,
TRACE_RET(chip, STATUS_FAIL);
}
} else {
-#ifdef XD_SPEEDUP
- retval = xd_auto_copy_page(chip, old_blk, new_blk,
- page_off, xd_card->page_off + 1);
-#else
retval = xd_copy_page(chip, old_blk, new_blk,
page_off, xd_card->page_off + 1);
-#endif
if (retval != STATUS_SUCCESS) {
if (!XD_CHK_BAD_NEWBLK(xd_card)) {
retval = xd_erase_block(chip, new_blk);
@@ -1789,11 +1688,7 @@ static int xd_prepare_write(struct rts51x_chip *chip,
old_blk, new_blk, log_blk, (int)page_off);
if (page_off) {
-#ifdef XD_SPEEDUP
- retval = xd_auto_copy_page(chip, old_blk, new_blk, 0, page_off);
-#else
retval = xd_copy_page(chip, old_blk, new_blk, 0, page_off);
-#endif
if (retval != STATUS_SUCCESS)
TRACE_RET(chip, retval);
}
@@ -1922,7 +1817,7 @@ Fail:
TRACE_RET(chip, STATUS_FAIL);
}
-int xd_delay_write(struct rts51x_chip *chip)
+static int xd_delay_write(struct rts51x_chip *chip)
{
struct xd_info *xd_card = &(chip->xd_card);
struct xd_delay_write_tag *delay_write = &(xd_card->delay_write);
@@ -1999,18 +1894,11 @@ int xd_rw(struct scsi_cmnd *srb, struct rts51x_chip *chip, u32 start_sector,
(start_page > delay_write->pageoff)) {
delay_write->delay_write_flag = 0;
if (delay_write->old_phyblock != BLK_NOT_FOUND) {
-#ifdef XD_SPEEDUP
- retval = xd_auto_copy_page(chip,
- delay_write->old_phyblock,
- delay_write->new_phyblock,
- delay_write->pageoff, start_page);
-#else
retval = xd_copy_page(chip,
delay_write->old_phyblock,
delay_write->new_phyblock,
delay_write->pageoff,
start_page);
-#endif
if (retval != STATUS_SUCCESS) {
set_sense_type(chip, lun,
SENSE_TYPE_MEDIA_WRITE_ERR);
@@ -2198,7 +2086,7 @@ void xd_cleanup_work(struct rts51x_chip *chip)
}
}
-int xd_power_off_card3v3(struct rts51x_chip *chip)
+static int xd_power_off_card3v3(struct rts51x_chip *chip)
{
int retval;
@@ -2232,7 +2120,7 @@ int release_xd_card(struct rts51x_chip *chip)
struct xd_info *xd_card = &(chip->xd_card);
int retval;
- RTS51X_DEBUGP("elease_xd_card\n");
+ RTS51X_DEBUGP("release_xd_card\n");
chip->card_ready &= ~XD_CARD;
chip->card_fail &= ~XD_CARD;
diff --git a/drivers/staging/rts5139/xd.h b/drivers/staging/rts5139/xd.h
index fa695903ba65..55e4205e23fa 100644
--- a/drivers/staging/rts5139/xd.h
+++ b/drivers/staging/rts5139/xd.h
@@ -182,12 +182,10 @@
#define CIS1_9 (256 + 9)
int reset_xd_card(struct rts51x_chip *chip);
-int xd_delay_write(struct rts51x_chip *chip);
int xd_rw(struct scsi_cmnd *srb, struct rts51x_chip *chip, u32 start_sector,
u16 sector_cnt);
void xd_free_l2p_tbl(struct rts51x_chip *chip);
void xd_cleanup_work(struct rts51x_chip *chip);
-int xd_power_off_card3v3(struct rts51x_chip *chip);
int release_xd_card(struct rts51x_chip *chip);
#endif /* __RTS51X_XD_H */
diff --git a/drivers/staging/rts_pstor/ms.c b/drivers/staging/rts_pstor/ms.c
index f9a4498984cc..7cc2b53f20d0 100644
--- a/drivers/staging/rts_pstor/ms.c
+++ b/drivers/staging/rts_pstor/ms.c
@@ -2488,7 +2488,7 @@ int reset_ms_card(struct rtsx_chip *chip)
if (!CHK_MSPRO(ms_card)) {
/* Build table for the last segment,
- * to check if L2P talbe block exist,erasing it
+ * to check if L2P table block exists, erasing it
*/
retval = ms_build_l2p_tbl(chip, ms_card->total_block / 512 - 1);
if (retval != STATUS_SUCCESS) {
@@ -4136,7 +4136,7 @@ int mg_set_ICV(struct scsi_cmnd *srb, struct rtsx_chip *chip)
#else
retval = ms_transfer_data(chip, MS_TM_AUTO_WRITE, PRO_WRITE_LONG_DATA,
2, WAIT_INT, 0, 0, buf + 4, 1024);
- if ((retval != STATUS_SUCCESS) || check_ms_err(chip) {
+ if ((retval != STATUS_SUCCESS) || check_ms_err(chip)) {
rtsx_clear_ms_error(chip);
if (ms_card->mg_auth == 0) {
if ((buf[5] & 0xC0) != 0) {
diff --git a/drivers/staging/rts_pstor/rtsx.c b/drivers/staging/rts_pstor/rtsx.c
index 1dccd933a7e4..5fb05a2edebb 100644
--- a/drivers/staging/rts_pstor/rtsx.c
+++ b/drivers/staging/rts_pstor/rtsx.c
@@ -1021,7 +1021,7 @@ static int __devinit rtsx_probe(struct pci_dev *pci,
}
/* Start up the thread for delayed SCSI-device scanning */
- th = kthread_create(rtsx_scan_thread, dev, "rtsx-scan");
+ th = kthread_run(rtsx_scan_thread, dev, "rtsx-scan");
if (IS_ERR(th)) {
printk(KERN_ERR "Unable to start the device-scanning thread\n");
complete(&dev->scanning_done);
@@ -1030,8 +1030,6 @@ static int __devinit rtsx_probe(struct pci_dev *pci,
goto errout;
}
- wake_up_process(th);
-
/* Start up the thread for polling thread */
th = kthread_run(rtsx_polling_thread, dev, "rtsx-polling");
if (IS_ERR(th)) {
diff --git a/drivers/staging/rts_pstor/rtsx_transport.c b/drivers/staging/rts_pstor/rtsx_transport.c
index 9b2e5c99870f..54a474235f26 100644
--- a/drivers/staging/rts_pstor/rtsx_transport.c
+++ b/drivers/staging/rts_pstor/rtsx_transport.c
@@ -130,7 +130,7 @@ unsigned int rtsx_stor_access_xfer_buf(unsigned char *buffer,
/* Store the contents of buffer into srb's transfer buffer and set the
* SCSI residue. */
void rtsx_stor_set_xfer_buf(unsigned char *buffer,
- unsigned int buflen, struct scsi_cmnd *srb)
+ unsigned int buflen, struct scsi_cmnd *srb)
{
unsigned int index = 0, offset = 0;
@@ -141,7 +141,7 @@ void rtsx_stor_set_xfer_buf(unsigned char *buffer,
}
void rtsx_stor_get_xfer_buf(unsigned char *buffer,
- unsigned int buflen, struct scsi_cmnd *srb)
+ unsigned int buflen, struct scsi_cmnd *srb)
{
unsigned int index = 0, offset = 0;
diff --git a/drivers/staging/rts_pstor/sd.c b/drivers/staging/rts_pstor/sd.c
index aab690932eae..3cc9a489e4e8 100644
--- a/drivers/staging/rts_pstor/sd.c
+++ b/drivers/staging/rts_pstor/sd.c
@@ -137,11 +137,10 @@ static int sd_check_data0_status(struct rtsx_chip *chip)
{
u8 stat;
- if (CHECK_PID(chip, 0x5209)) {
+ if (CHECK_PID(chip, 0x5209))
RTSX_READ_REG(chip, REG_SD_BUS_STAT, &stat);
- } else {
+ else
RTSX_READ_REG(chip, REG_SD_STAT1, &stat);
- }
if (!(stat & SD_DAT0_STATUS)) {
sd_set_err_code(chip, SD_BUSY);
@@ -188,9 +187,9 @@ RTY_SEND_CMD:
SD_TRANSFER_END | SD_STAT_IDLE, SD_TRANSFER_END | SD_STAT_IDLE);
if (rsp_type == SD_RSP_TYPE_R2) {
- for (reg_addr = PPBUF_BASE2; reg_addr < PPBUF_BASE2 + 16; reg_addr++) {
+ for (reg_addr = PPBUF_BASE2; reg_addr < PPBUF_BASE2 + 16; reg_addr++)
rtsx_add_cmd(chip, READ_REG_CMD, reg_addr, 0, 0);
- }
+
stat_idx = 16;
} else if (rsp_type != SD_RSP_TYPE_R0) {
for (reg_addr = REG_SD_CMD0; reg_addr <= REG_SD_CMD4; reg_addr++) {
@@ -1169,7 +1168,7 @@ static int sd_check_switch_mode(struct rtsx_chip *chip, u8 mode,
RTSX_DEBUGP("func_group4_mask = 0x%02x\n", buf[0x07]);
} else {
/* Maximum current consumption, check whether current is acceptable;
- * bit[511:496] = 0x0000 means some error happaned.
+ * bit[511:496] = 0x0000 means some error happened.
*/
u16 cc = ((u16)buf[0] << 8) | buf[1];
RTSX_DEBUGP("Maximum current consumption: %dmA\n", cc);
diff --git a/drivers/staging/sbe-2t3e3/2t3e3.h b/drivers/staging/sbe-2t3e3/2t3e3.h
index fe9f086b6e7a..383f2cfc1ad2 100644
--- a/drivers/staging/sbe-2t3e3/2t3e3.h
+++ b/drivers/staging/sbe-2t3e3/2t3e3.h
@@ -801,9 +801,6 @@ u32 cpld_read(struct channel *sc, u32 reg);
void cpld_set_crc(struct channel *, u32);
void cpld_start_intr(struct channel *);
void cpld_stop_intr(struct channel *);
-#if 0
-void cpld_led_onoff(struct channel *, u32, u32, u32, u32);
-#endif
void cpld_set_clock(struct channel *sc, u32 mode);
void cpld_set_scrambler(struct channel *, u32);
void cpld_select_panel(struct channel *, u32);
diff --git a/drivers/staging/sbe-2t3e3/cpld.c b/drivers/staging/sbe-2t3e3/cpld.c
index b0fc2ddad329..cc2b54d52b1b 100644
--- a/drivers/staging/sbe-2t3e3/cpld.c
+++ b/drivers/staging/sbe-2t3e3/cpld.c
@@ -41,14 +41,6 @@ static inline void cpld_clear_bit(struct channel *channel, unsigned reg, u32 bit
void cpld_init(struct channel *sc)
{
u32 val;
-#if 0
- /* reset LIU and Framer */
- val = cpld_val_map[SBE_2T3E3_CPLD_VAL_LIU_FRAMER_RESET][sc->h.slot];
- cpld_write(sc, SBE_2T3E3_CPLD_REG_STATIC_RESET, val);
- udelay(10000); /* TODO - how long? */
- val = 0;
- cpld_write(sc, SBE_2T3E3_CPLD_REG_STATIC_RESET, val);
-#endif
/* PCRA */
val = SBE_2T3E3_CPLD_VAL_CRC32 |
@@ -109,13 +101,6 @@ void cpld_start_intr(struct channel *sc)
val = SBE_2T3E3_CPLD_VAL_INTERRUPT_FROM_ETHERNET_ENABLE |
SBE_2T3E3_CPLD_VAL_INTERRUPT_FROM_FRAMER_ENABLE;
cpld_write(sc, SBE_2T3E3_CPLD_REG_PIER, val);
-#if 0
- /*
- do you want to hang up your computer?
- ENABLE REST OF INTERRUPTS !!!
- you have been warned :).
- */
-#endif
}
void cpld_stop_intr(struct channel *sc)
diff --git a/drivers/staging/sbe-2t3e3/ctrl.c b/drivers/staging/sbe-2t3e3/ctrl.c
index d9dd216e9ae0..a5825d7f1bbf 100644
--- a/drivers/staging/sbe-2t3e3/ctrl.c
+++ b/drivers/staging/sbe-2t3e3/ctrl.c
@@ -230,11 +230,9 @@ void t3e3_port_get_stats(struct channel *sc,
result = exar7250_read(sc, SBE_2T3E3_FRAMER_REG_E3_RX_CONFIGURATION_STATUS_2);
sc->s.LOF = result & SBE_2T3E3_FRAMER_VAL_E3_RX_LOF ? 1 : 0;
sc->s.OOF = result & SBE_2T3E3_FRAMER_VAL_E3_RX_OOF ? 1 : 0;
-#if 0
- sc->s.LOS = result & SBE_2T3E3_FRAMER_VAL_E3_RX_LOS ? 1 : 0;
-#else
+
cpld_LOS_update(sc);
-#endif
+
sc->s.AIS = result & SBE_2T3E3_FRAMER_VAL_E3_RX_AIS ? 1 : 0;
sc->s.FERF = result & SBE_2T3E3_FRAMER_VAL_E3_RX_FERF ? 1 : 0;
break;
@@ -243,11 +241,9 @@ void t3e3_port_get_stats(struct channel *sc,
case SBE_2T3E3_FRAME_TYPE_T3_M13:
result = exar7250_read(sc, SBE_2T3E3_FRAMER_REG_T3_RX_CONFIGURATION_STATUS);
sc->s.AIS = result & SBE_2T3E3_FRAMER_VAL_T3_RX_AIS ? 1 : 0;
-#if 0
- sc->s.LOS = result & SBE_2T3E3_FRAMER_VAL_T3_RX_LOS ? 1 : 0;
-#else
+
cpld_LOS_update(sc);
-#endif
+
sc->s.IDLE = result & SBE_2T3E3_FRAMER_VAL_T3_RX_IDLE ? 1 : 0;
sc->s.OOF = result & SBE_2T3E3_FRAMER_VAL_T3_RX_OOF ? 1 : 0;
@@ -322,10 +318,6 @@ void t3e3_if_config(struct channel *sc, u32 cmd, char *set,
*rlen = sizeof(ret->u.data);
break;
case SBE_2T3E3_PORT_WRITE_REGS:
-#if 0
- printk(KERN_DEBUG "SBE_2T3E3_PORT_WRITE_REGS, 0x%x, 0x%x, 0x%x\n",
- ((int*)data)[0], ((int*)data)[1], ((int*)data)[2]);
-#endif
t3e3_reg_write(sc, data);
*rlen = 0;
break;
@@ -336,9 +328,6 @@ void t3e3_if_config(struct channel *sc, u32 cmd, char *set,
*rlen = 0;
break;
}
-
- /* turn on interrupt */
- /* cpld_start_intr(sc); */
}
void t3e3_sc_init(struct channel *sc)
diff --git a/drivers/staging/sbe-2t3e3/dc.c b/drivers/staging/sbe-2t3e3/dc.c
index 9dc4ec2109eb..9e81d9036a33 100644
--- a/drivers/staging/sbe-2t3e3/dc.c
+++ b/drivers/staging/sbe-2t3e3/dc.c
@@ -63,14 +63,6 @@ void dc_init(struct channel *sc)
if (sc->p.loopback == SBE_2T3E3_LOOPBACK_ETHERNET)
sc->p.loopback = SBE_2T3E3_LOOPBACK_NONE;
-#if 0 /* No need to clear this register - and it may be in use */
- /*
- * BOOT_ROM_SERIAL_ROM_AND_MII_MANAGEMENT (CSR9)
- */
- val = 0;
- dc_write(sc->addr, SBE_2T3E3_21143_REG_BOOT_ROM_SERIAL_ROM_AND_MII_MANAGEMENT, val);
-#endif
-
/*
* GENERAL_PURPOSE_TIMER_AND_INTERRUPT_MITIGATION_CONTROL (CSR11)
*/
@@ -81,7 +73,7 @@ void dc_init(struct channel *sc)
SBE_2T3E3_21143_VAL_NUMBER_OF_RECEIVE_PACKETS;
dc_write(sc->addr, SBE_2T3E3_21143_REG_GENERAL_PURPOSE_TIMER_AND_INTERRUPT_MITIGATION_CONTROL, val);
- /* prepare descriptors and data for receive and transmit procecsses */
+ /* prepare descriptors and data for receive and transmit processes */
if (dc_init_descriptor_list(sc) != 0)
return;
@@ -301,15 +293,6 @@ void dc_set_loopback(struct channel *sc, u32 mode)
return;
}
-#if 0
- /* restart SIA */
- dc_clear_bits(sc->addr, SBE_2T3E3_21143_REG_SIA_CONNECTIVITY,
- SBE_2T3E3_21143_VAL_SIA_RESET);
- udelay(1000);
- dc_set_bits(sc->addr, SBE_2T3E3_21143_REG_SIA_CONNECTIVITY,
- SBE_2T3E3_21143_VAL_SIA_RESET);
-#endif
-
/* select loopback mode */
val = dc_read(sc->addr, SBE_2T3E3_21143_REG_OPERATION_MODE) &
~SBE_2T3E3_21143_VAL_OPERATING_MODE;
diff --git a/drivers/staging/sbe-2t3e3/exar7250.c b/drivers/staging/sbe-2t3e3/exar7250.c
index 809f446bdc3a..e3ddd140207e 100644
--- a/drivers/staging/sbe-2t3e3/exar7250.c
+++ b/drivers/staging/sbe-2t3e3/exar7250.c
@@ -78,64 +78,32 @@ void exar7250_start_intr(struct channel *sc, u32 type)
case SBE_2T3E3_FRAME_TYPE_E3_G751:
case SBE_2T3E3_FRAME_TYPE_E3_G832:
val = exar7250_read(sc, SBE_2T3E3_FRAMER_REG_E3_RX_CONFIGURATION_STATUS_2);
-#if 0
- sc->s.LOS = val & SBE_2T3E3_FRAMER_VAL_E3_RX_LOS ? 1 : 0;
-#else
+
cpld_LOS_update(sc);
-#endif
+
sc->s.OOF = val & SBE_2T3E3_FRAMER_VAL_E3_RX_OOF ? 1 : 0;
exar7250_read(sc, SBE_2T3E3_FRAMER_REG_E3_RX_INTERRUPT_STATUS_1);
exar7250_write(sc, SBE_2T3E3_FRAMER_REG_E3_RX_INTERRUPT_ENABLE_1,
SBE_2T3E3_FRAMER_VAL_E3_RX_OOF_INTERRUPT_ENABLE |
SBE_2T3E3_FRAMER_VAL_E3_RX_LOS_INTERRUPT_ENABLE);
-#if 0
- /*SBE_2T3E3_FRAMER_VAL_E3_RX_COFA_INTERRUPT_ENABLE |
- SBE_2T3E3_FRAMER_VAL_E3_RX_OOF_INTERRUPT_ENABLE |
- SBE_2T3E3_FRAMER_VAL_E3_RX_LOF_INTERRUPT_ENABLE |
- SBE_2T3E3_FRAMER_VAL_E3_RX_LOS_INTERRUPT_ENABLE |
- SBE_2T3E3_FRAMER_VAL_E3_RX_AIS_INTERRUPT_ENABLE);*/
-#endif
exar7250_read(sc, SBE_2T3E3_FRAMER_REG_E3_RX_INTERRUPT_STATUS_2);
-#if 0
- exar7250_write(sc, SBE_2T3E3_FRAMER_REG_E3_RX_INTERRUPT_ENABLE_2,
- SBE_2T3E3_FRAMER_VAL_E3_RX_FEBE_INTERRUPT_ENABLE |
- SBE_2T3E3_FRAMER_VAL_E3_RX_FERF_INTERRUPT_ENABLE |
- SBE_2T3E3_FRAMER_VAL_E3_RX_FRAMING_BYTE_ERROR_INTERRUPT_ENABLE);
-#endif
break;
case SBE_2T3E3_FRAME_TYPE_T3_CBIT:
case SBE_2T3E3_FRAME_TYPE_T3_M13:
val = exar7250_read(sc, SBE_2T3E3_FRAMER_REG_T3_RX_CONFIGURATION_STATUS);
-#if 0
- sc->s.LOS = val & SBE_2T3E3_FRAMER_VAL_T3_RX_LOS ? 1 : 0;
-#else
+
cpld_LOS_update(sc);
-#endif
+
sc->s.OOF = val & SBE_2T3E3_FRAMER_VAL_T3_RX_OOF ? 1 : 0;
exar7250_read(sc, SBE_2T3E3_FRAMER_REG_T3_RX_INTERRUPT_STATUS);
exar7250_write(sc, SBE_2T3E3_FRAMER_REG_T3_RX_INTERRUPT_ENABLE,
SBE_2T3E3_FRAMER_VAL_T3_RX_LOS_INTERRUPT_ENABLE |
SBE_2T3E3_FRAMER_VAL_T3_RX_OOF_INTERRUPT_ENABLE);
-#if 0
- /* SBE_2T3E3_FRAMER_VAL_T3_RX_CP_BIT_ERROR_INTERRUPT_ENABLE |
- SBE_2T3E3_FRAMER_VAL_T3_RX_LOS_INTERRUPT_ENABLE |
- SBE_2T3E3_FRAMER_VAL_T3_RX_AIS_INTERRUPT_ENABLE |
- SBE_2T3E3_FRAMER_VAL_T3_RX_IDLE_INTERRUPT_ENABLE |
- SBE_2T3E3_FRAMER_VAL_T3_RX_FERF_INTERRUPT_ENABLE |
- SBE_2T3E3_FRAMER_VAL_T3_RX_AIC_INTERRUPT_ENABLE |
- SBE_2T3E3_FRAMER_VAL_T3_RX_OOF_INTERRUPT_ENABLE |
- SBE_2T3E3_FRAMER_VAL_T3_RX_P_BIT_INTERRUPT_ENABLE);*/
-#endif
exar7250_read(sc, SBE_2T3E3_FRAMER_REG_T3_RX_FEAC_INTERRUPT_ENABLE_STATUS);
-#if 0
- exar7250_write(sc, SBE_2T3E3_FRAMER_REG_T3_RX_FEAC_INTERRUPT_ENABLE_STATUS,
- SBE_2T3E3_FRAMER_VAL_T3_RX_FEAC_REMOVE_INTERRUPT_ENABLE |
- SBE_2T3E3_FRAMER_VAL_T3_RX_FEAC_VALID_INTERRUPT_ENABLE);
-#endif
exar7250_write(sc, SBE_2T3E3_FRAMER_REG_T3_RX_LAPD_CONTROL, 0);
break;
diff --git a/drivers/staging/sbe-2t3e3/exar7300.c b/drivers/staging/sbe-2t3e3/exar7300.c
index d10d696cf6fb..cd229998a62e 100644
--- a/drivers/staging/sbe-2t3e3/exar7300.c
+++ b/drivers/staging/sbe-2t3e3/exar7300.c
@@ -43,23 +43,6 @@ void exar7300_set_loopback(struct channel *sc, u32 mode)
val &= ~(SBE_2T3E3_LIU_VAL_LOCAL_LOOPBACK | SBE_2T3E3_LIU_VAL_REMOTE_LOOPBACK);
val |= mode;
exar7300_write(sc, SBE_2T3E3_LIU_REG_REG4, val);
-
-#if 0
- /* TODO - is it necessary? idea from 2T3E3_HW_Test_code */
- switch (mode) {
- case SBE_2T3E3_LIU_VAL_LOOPBACK_OFF:
- break;
- case SBE_2T3E3_LIU_VAL_LOOPBACK_REMOTE:
- exar7300_receive_equalization_onoff(sc, SBE_2T3E3_ON);
- break;
- case SBE_2T3E3_LIU_VAL_LOOPBACK_ANALOG:
- exar7300_receive_equalization_onoff(sc, SBE_2T3E3_OFF);
- break;
- case SBE_2T3E3_LIU_VAL_LOOPBACK_DIGITAL:
- exar7300_receive_equalization_onoff(sc, SBE_2T3E3_ON);
- break;
- }
-#endif
}
void exar7300_set_frame_type(struct channel *sc, u32 type)
diff --git a/drivers/staging/sbe-2t3e3/intr.c b/drivers/staging/sbe-2t3e3/intr.c
index 1336aab11bdd..efdeb7510047 100644
--- a/drivers/staging/sbe-2t3e3/intr.c
+++ b/drivers/staging/sbe-2t3e3/intr.c
@@ -434,11 +434,6 @@ void exar7250_intr(struct channel *sc)
{
u32 status, old_OOF;
-#if 0
- /* disable interrupts */
- exar7250_write(sc, SBE_2T3E3_FRAMER_REG_BLOCK_INTERRUPT_ENABLE, 0);
-#endif
-
old_OOF = sc->s.OOF;
status = exar7250_read(sc, SBE_2T3E3_FRAMER_REG_BLOCK_INTERRUPT_STATUS);
@@ -479,13 +474,6 @@ void exar7250_intr(struct channel *sc)
dc_start_intr(sc);
}
}
-#if 0
- /* reenable interrupts */
- exar7250_write(sc, SBE_2T3E3_FRAMER_REG_BLOCK_INTERRUPT_ENABLE,
- SBE_2T3E3_FRAMER_VAL_RX_INTERRUPT_ENABLE |
- SBE_2T3E3_FRAMER_VAL_TX_INTERRUPT_ENABLE
- );
-#endif
}
@@ -503,16 +491,8 @@ void exar7250_T3_intr(struct channel *sc, u32 block_status)
result = exar7250_read(sc, SBE_2T3E3_FRAMER_REG_T3_RX_CONFIGURATION_STATUS);
-#if 0
- if (status & SBE_2T3E3_FRAMER_VAL_T3_RX_LOS_INTERRUPT_STATUS) {
- dev_dbg(&sc->pdev->dev,
- "Framer interrupt T3: LOS\n");
- sc->s.LOS = result & SBE_2T3E3_FRAMER_VAL_T3_RX_LOS ? 1 : 0;
-
- }
-#else
cpld_LOS_update(sc);
-#endif
+
if (status & SBE_2T3E3_FRAMER_VAL_T3_RX_OOF_INTERRUPT_STATUS) {
sc->s.OOF = result & SBE_2T3E3_FRAMER_VAL_T3_RX_OOF ? 1 : 0;
dev_dbg(&sc->pdev->dev,
@@ -523,16 +503,6 @@ void exar7250_T3_intr(struct channel *sc, u32 block_status)
exar7250_write(sc, SBE_2T3E3_FRAMER_REG_T3_RX_INTERRUPT_ENABLE,
SBE_2T3E3_FRAMER_VAL_T3_RX_LOS_INTERRUPT_ENABLE |
SBE_2T3E3_FRAMER_VAL_T3_RX_OOF_INTERRUPT_ENABLE);
-#if 0
- SBE_2T3E3_FRAMER_VAL_T3_RX_CP_BIT_ERROR_INTERRUPT_ENABLE |
- SBE_2T3E3_FRAMER_VAL_T3_RX_LOS_INTERRUPT_ENABLE |
- SBE_2T3E3_FRAMER_VAL_T3_RX_AIS_INTERRUPT_ENABLE |
- SBE_2T3E3_FRAMER_VAL_T3_RX_IDLE_INTERRUPT_ENABLE |
- SBE_2T3E3_FRAMER_VAL_T3_RX_FERF_INTERRUPT_ENABLE |
- SBE_2T3E3_FRAMER_VAL_T3_RX_AIC_INTERRUPT_ENABLE |
- SBE_2T3E3_FRAMER_VAL_T3_RX_OOF_INTERRUPT_ENABLE |
- SBE_2T3E3_FRAMER_VAL_T3_RX_P_BIT_INTERRUPT_ENABLE
-#endif
}
status = exar7250_read(sc, SBE_2T3E3_FRAMER_REG_T3_RX_FEAC_INTERRUPT_ENABLE_STATUS);
@@ -540,12 +510,6 @@ void exar7250_T3_intr(struct channel *sc, u32 block_status)
dev_dbg(&sc->pdev->dev,
"Framer interrupt T3 RX (REG[0x17] = %02X)\n",
status);
-#if 0
- exar7250_write(sc, SBE_2T3E3_FRAMER_REG_T3_RX_FEAC_INTERRUPT_ENABLE_STATUS,
- SBE_2T3E3_FRAMER_VAL_T3_RX_FEAC_REMOVE_INTERRUPT_ENABLE |
- SBE_2T3E3_FRAMER_VAL_T3_RX_FEAC_VALID_INTERRUPT_ENABLE
- );
-#endif
}
status = exar7250_read(sc, SBE_2T3E3_FRAMER_REG_T3_RX_LAPD_CONTROL);
@@ -582,15 +546,8 @@ void exar7250_E3_intr(struct channel *sc, u32 block_status)
result = exar7250_read(sc, SBE_2T3E3_FRAMER_REG_E3_RX_CONFIGURATION_STATUS_2);
-#if 0
- if (status & SBE_2T3E3_FRAMER_VAL_E3_RX_LOS_INTERRUPT_STATUS) {
- dev_dbg(&sc->pdev->dev,
- "Framer interrupt E3: LOS\n");
- sc->s.LOS = result & SBE_2T3E3_FRAMER_VAL_E3_RX_LOS ? 1 : 0;
- }
-#else
cpld_LOS_update(sc);
-#endif
+
if (status & SBE_2T3E3_FRAMER_VAL_E3_RX_OOF_INTERRUPT_STATUS) {
sc->s.OOF = result & SBE_2T3E3_FRAMER_VAL_E3_RX_OOF ? 1 : 0;
dev_dbg(&sc->pdev->dev,
@@ -602,13 +559,6 @@ void exar7250_E3_intr(struct channel *sc, u32 block_status)
SBE_2T3E3_FRAMER_VAL_E3_RX_OOF_INTERRUPT_ENABLE |
SBE_2T3E3_FRAMER_VAL_E3_RX_LOS_INTERRUPT_ENABLE
);
-#if 0
- SBE_2T3E3_FRAMER_VAL_E3_RX_COFA_INTERRUPT_ENABLE |
- SBE_2T3E3_FRAMER_VAL_E3_RX_OOF_INTERRUPT_ENABLE |
- SBE_2T3E3_FRAMER_VAL_E3_RX_LOF_INTERRUPT_ENABLE |
- SBE_2T3E3_FRAMER_VAL_E3_RX_LOS_INTERRUPT_ENABLE |
- SBE_2T3E3_FRAMER_VAL_E3_RX_AIS_INTERRUPT_ENABLE
-#endif
}
status = exar7250_read(sc, SBE_2T3E3_FRAMER_REG_E3_RX_INTERRUPT_STATUS_2);
@@ -617,12 +567,6 @@ void exar7250_E3_intr(struct channel *sc, u32 block_status)
"Framer interrupt E3 RX (REG[0x15] = %02X)\n",
status);
-#if 0
- exar7250_write(sc, SBE_2T3E3_FRAMER_REG_E3_RX_INTERRUPT_ENABLE_2,
- SBE_2T3E3_FRAMER_VAL_E3_RX_FEBE_INTERRUPT_ENABLE |
- SBE_2T3E3_FRAMER_VAL_E3_RX_FERF_INTERRUPT_ENABLE |
- SBE_2T3E3_FRAMER_VAL_E3_RX_FRAMING_BYTE_ERROR_INTERRUPT_ENABLE);
-#endif
}
}
diff --git a/drivers/staging/sbe-2t3e3/io.c b/drivers/staging/sbe-2t3e3/io.c
index 9a50bcc59594..c9947b165b31 100644
--- a/drivers/staging/sbe-2t3e3/io.c
+++ b/drivers/staging/sbe-2t3e3/io.c
@@ -17,7 +17,7 @@
/* All access to registers done via the 21143 on port 0 must be
* protected via the card->bootrom_lock. */
-/* priviate define to be used here only - must be protected by card->bootrom_lock */
+/* private define to be used here only - must be protected by card->bootrom_lock */
#define cpld_write_nolock(channel, reg, val) \
bootrom_write((channel), CPLD_MAP_REG(reg, channel), val)
@@ -199,15 +199,6 @@ u32 exar7250_read(struct channel *channel, u32 reg)
u32 result;
unsigned long flags;
-#if 0
- switch (reg) {
- case SBE_2T3E3_FRAMER_REG_OPERATING_MODE:
- return channel->framer_regs[reg];
- break;
- default:
- }
-#endif
-
spin_lock_irqsave(&channel->card->bootrom_lock, flags);
result = bootrom_read(channel, cpld_reg_map[SBE_2T3E3_CPLD_REG_FRAMER_BASE_ADDRESS]
@@ -243,18 +234,6 @@ u32 exar7300_read(struct channel *channel, u32 reg)
unsigned long addr = channel->card->bootrom_addr, flags;
u32 i, val;
-#if 0
- switch (reg) {
- case SBE_2T3E3_LIU_REG_REG1:
- case SBE_2T3E3_LIU_REG_REG2:
- case SBE_2T3E3_LIU_REG_REG3:
- case SBE_2T3E3_LIU_REG_REG4:
- return channel->liu_regs[reg];
- break;
- default:
- }
-#endif
-
/* select correct Serial Chip */
spin_lock_irqsave(&channel->card->bootrom_lock, flags);
diff --git a/drivers/staging/sbe-2t3e3/module.c b/drivers/staging/sbe-2t3e3/module.c
index e87fe81f6bb3..cd778b3a02b2 100644
--- a/drivers/staging/sbe-2t3e3/module.c
+++ b/drivers/staging/sbe-2t3e3/module.c
@@ -194,17 +194,6 @@ static struct pci_driver t3e3_pci_driver = {
.remove = t3e3_remove_card,
};
-static int __init t3e3_init_module(void)
-{
- return pci_register_driver(&t3e3_pci_driver);
-}
-
-static void __exit t3e3_cleanup_module(void)
-{
- pci_unregister_driver(&t3e3_pci_driver);
-}
-
-module_init(t3e3_init_module);
-module_exit(t3e3_cleanup_module);
+module_pci_driver(t3e3_pci_driver);
MODULE_LICENSE("GPL");
MODULE_DEVICE_TABLE(pci, t3e3_pci_tbl);
diff --git a/drivers/staging/sep/sep_crypto.c b/drivers/staging/sep/sep_crypto.c
index 1cc790e9fa07..34710ce56004 100644
--- a/drivers/staging/sep/sep_crypto.c
+++ b/drivers/staging/sep/sep_crypto.c
@@ -44,7 +44,6 @@
#include <linux/poll.h>
#include <linux/wait.h>
#include <linux/pci.h>
-#include <linux/pci.h>
#include <linux/pm_runtime.h>
#include <linux/err.h>
#include <linux/device.h>
@@ -85,28 +84,6 @@ static void sep_dequeuer(void *data);
/* TESTING */
/**
- * crypto_sep_dump_message - dump the message that is pending
- * @sep: SEP device
- * This will only print dump if DEBUG is set; it does
- * follow kernel debug print enabling
- */
-static void crypto_sep_dump_message(struct sep_device *sep, void *msg)
-{
-#if 0
- u32 *p;
- u32 *i;
- int count;
-
- p = sep->shared_addr;
- i = (u32 *)msg;
- for (count = 0; count < 10 * 4; count += 4)
- dev_dbg(&sep->pdev->dev,
- "[PID%d] Word %d of the message is %x (local)%x\n",
- current->pid, count/4, *p++, *i++);
-#endif
-}
-
-/**
* sep_do_callback
* @work: pointer to work_struct
* This is what is called by the queue; it is generic so that it
@@ -487,55 +464,6 @@ static int partial_overlap(void *src_ptr, void *dst_ptr, u32 nbytes)
return 0;
}
-/* Debug - prints only if DEBUG is defined; follows kernel debug model */
-static void sep_dump(struct sep_device *sep, char *stg, void *start, int len)
-{
-#if 0
- int ct1;
- u8 *ptt;
-
- dev_dbg(&sep->pdev->dev,
- "Dump of %s starting at %08lx for %08x bytes\n",
- stg, (unsigned long)start, len);
- for (ct1 = 0; ct1 < len; ct1 += 1) {
- ptt = (u8 *)(start + ct1);
- dev_dbg(&sep->pdev->dev, "%02x ", *ptt);
- if (ct1 % 16 == 15)
- dev_dbg(&sep->pdev->dev, "\n");
- }
- dev_dbg(&sep->pdev->dev, "\n");
-#endif
-}
-
-/* Debug - prints only if DEBUG is defined; follows kernel debug model */
-static void sep_dump_sg(struct sep_device *sep, char *stg,
- struct scatterlist *sg)
-{
-#if 0
- int ct1, ct2;
- u8 *ptt;
-
- dev_dbg(&sep->pdev->dev, "Dump of scatterlist %s\n", stg);
-
- ct1 = 0;
- while (sg) {
- dev_dbg(&sep->pdev->dev, "page %x\n size %x", ct1,
- sg->length);
- dev_dbg(&sep->pdev->dev, "phys addr is %lx",
- (unsigned long)sg_phys(sg));
- ptt = sg_virt(sg);
- for (ct2 = 0; ct2 < sg->length; ct2 += 1) {
- dev_dbg(&sep->pdev->dev, "byte %x is %02x\n",
- ct2, (unsigned char)*(ptt + ct2));
- }
-
- ct1 += 1;
- sg = sg_next(sg);
- }
- dev_dbg(&sep->pdev->dev, "\n");
-#endif
-}
-
/* Debug - prints only if DEBUG is defined */
static void sep_dump_ivs(struct ablkcipher_request *req, char *reason)
@@ -807,7 +735,7 @@ end_function:
* @size: size of parameter to copy (in bytes)
* @max_size: size to move up offset; SEP mesg is in word sizes
* @msg_offset: pointer to current offset (is updated)
- * @byte_array: flag ti indicate wheter endian must be changed
+ * @byte_array: flag ti indicate whether endian must be changed
* Copies data into the message area from caller
*/
static void sep_write_msg(struct this_task_ctx *ta_ctx, void *in_addr,
@@ -855,7 +783,7 @@ static void sep_make_header(struct this_task_ctx *ta_ctx, u32 *msg_offset,
* @size: size of parameter to copy (in bytes)
* @max_size: size to move up offset; SEP mesg is in word sizes
* @msg_offset: pointer to current offset (is updated)
- * @byte_array: flag ti indicate wheter endian must be changed
+ * @byte_array: flag ti indicate whether endian must be changed
* Copies data out of the message area to caller
*/
static void sep_read_msg(struct this_task_ctx *ta_ctx, void *in_addr,
@@ -990,7 +918,7 @@ static void sep_clear_out(struct this_task_ctx *ta_ctx)
/**
* The following unlocks the sep and makes it available
* to any other application
- * First, null out crypto entries in sep before relesing it
+ * First, null out crypto entries in sep before releasing it
*/
ta_ctx->sep_used->current_hash_req = NULL;
ta_ctx->sep_used->current_cypher_req = NULL;
@@ -1001,7 +929,7 @@ static void sep_clear_out(struct this_task_ctx *ta_ctx)
ta_ctx->call_status.status = 0;
- /* Remove anything confidentail */
+ /* Remove anything confidential */
memset(ta_ctx->sep_used->shared_addr, 0,
SEP_DRIVER_MESSAGE_SHARED_AREA_SIZE_IN_BYTES);
@@ -1095,8 +1023,8 @@ static int sep_crypto_take_sep(struct this_task_ctx *ta_ctx)
current->comm, sizeof(current->comm));
if (!ta_ctx->queue_elem) {
- dev_dbg(&sep->pdev->dev, "[PID%d] updating queue"
- " status error\n", current->pid);
+ dev_dbg(&sep->pdev->dev,
+ "[PID%d] updating queue status error\n", current->pid);
return -EINVAL;
}
@@ -1207,7 +1135,7 @@ static int sep_crypto_block_data(struct ablkcipher_request *req)
req->nbytes, ta_ctx->walk.blocksize, &new_sg, 1);
if (int_error < 0) {
- dev_warn(&ta_ctx->sep_used->pdev->dev, "oddball page eerror\n");
+ dev_warn(&ta_ctx->sep_used->pdev->dev, "oddball page error\n");
return -ENOMEM;
} else if (int_error == 1) {
ta_ctx->src_sg = new_sg;
@@ -1238,9 +1166,6 @@ static int sep_crypto_block_data(struct ablkcipher_request *req)
/* Key already done; this is for data */
dev_dbg(&ta_ctx->sep_used->pdev->dev, "sending data\n");
- sep_dump_sg(ta_ctx->sep_used,
- "block sg in", ta_ctx->src_sg);
-
/* check for valid data and proper spacing */
src_ptr = sg_virt(ta_ctx->src_sg);
dst_ptr = sg_virt(ta_ctx->dst_sg);
@@ -1362,14 +1287,10 @@ static int sep_crypto_block_data(struct ablkcipher_request *req)
sep_write_context(ta_ctx, &msg_offset,
&sctx->des_private_ctx,
sizeof(struct sep_des_private_context));
- sep_dump(ta_ctx->sep_used, "ctx to block des",
- &sctx->des_private_ctx, 40);
} else {
sep_write_context(ta_ctx, &msg_offset,
&sctx->aes_private_ctx,
sizeof(struct sep_aes_private_context));
- sep_dump(ta_ctx->sep_used, "ctx to block aes",
- &sctx->aes_private_ctx, 20);
}
/* conclude message */
@@ -1426,8 +1347,6 @@ static int sep_crypto_send_key(struct ablkcipher_request *req)
}
memcpy(ta_ctx->iv, ta_ctx->walk.iv, SEP_DES_IV_SIZE_BYTES);
- sep_dump(ta_ctx->sep_used, "iv",
- ta_ctx->iv, SEP_DES_IV_SIZE_BYTES);
}
if ((ta_ctx->current_request == AES_CBC) &&
@@ -1438,8 +1357,6 @@ static int sep_crypto_send_key(struct ablkcipher_request *req)
}
memcpy(ta_ctx->iv, ta_ctx->walk.iv, SEP_AES_IV_SIZE_BYTES);
- sep_dump(ta_ctx->sep_used, "iv",
- ta_ctx->iv, SEP_AES_IV_SIZE_BYTES);
}
/* put together message to SEP */
@@ -1452,8 +1369,6 @@ static int sep_crypto_send_key(struct ablkcipher_request *req)
sep_write_msg(ta_ctx, ta_ctx->iv,
SEP_DES_IV_SIZE_BYTES, sizeof(u32) * 4,
&msg_offset, 1);
- sep_dump(ta_ctx->sep_used, "initial IV",
- ta_ctx->walk.iv, SEP_DES_IV_SIZE_BYTES);
} else {
/* Skip if ECB */
msg_offset += 4 * sizeof(u32);
@@ -1465,8 +1380,6 @@ static int sep_crypto_send_key(struct ablkcipher_request *req)
sep_write_msg(ta_ctx, ta_ctx->iv,
SEP_AES_IV_SIZE_BYTES, max_length,
&msg_offset, 1);
- sep_dump(ta_ctx->sep_used, "initial IV",
- ta_ctx->walk.iv, SEP_AES_IV_SIZE_BYTES);
} else {
/* Skip if ECB */
msg_offset += max_length;
@@ -1646,7 +1559,6 @@ static u32 crypto_post_op(struct sep_device *sep)
dev_dbg(&ta_ctx->sep_used->pdev->dev, "crypto post_op\n");
dev_dbg(&ta_ctx->sep_used->pdev->dev, "crypto post_op message dump\n");
- crypto_sep_dump_message(ta_ctx->sep_used, ta_ctx->msg);
/* first bring msg from shared area to local area */
memcpy(ta_ctx->msg, sep->shared_addr,
@@ -1670,16 +1582,10 @@ static u32 crypto_post_op(struct sep_device *sep)
sep_read_context(ta_ctx, &msg_offset,
&sctx->des_private_ctx,
sizeof(struct sep_des_private_context));
-
- sep_dump(ta_ctx->sep_used, "ctx init des",
- &sctx->des_private_ctx, 40);
} else {
sep_read_context(ta_ctx, &msg_offset,
&sctx->aes_private_ctx,
sizeof(struct sep_aes_private_context));
-
- sep_dump(ta_ctx->sep_used, "ctx init aes",
- &sctx->aes_private_ctx, 20);
}
sep_dump_ivs(req, "after sending key to sep\n");
@@ -1758,9 +1664,6 @@ static u32 crypto_post_op(struct sep_device *sep)
sizeof(struct sep_aes_private_context));
}
- sep_dump_sg(ta_ctx->sep_used,
- "block sg out", ta_ctx->dst_sg);
-
/* Copy to correct sg if this block had oddball pages */
if (ta_ctx->dst_sg_hold)
sep_copy_sg(ta_ctx->sep_used,
@@ -1870,7 +1773,7 @@ static u32 hash_update_post_op(struct sep_device *sep)
sizeof(struct sep_hash_private_context));
/**
- * Following is only for finup; if we just completd the
+ * Following is only for finup; if we just completed the
* data portion of finup, we now need to kick off the
* finish portion of finup.
*/
@@ -2011,7 +1914,7 @@ static u32 hash_digest_post_op(struct sep_device *sep)
}
/**
- * The sep_finish function is the function that is schedule (via tasket)
+ * The sep_finish function is the function that is scheduled (via tasklet)
* by the interrupt service routine when the SEP sends and interrupt
* This is only called by the interrupt handler as a tasklet.
*/
@@ -2249,7 +2152,7 @@ static void sep_hash_update(void *data)
head_len = (block_size - int_ctx->prev_update_bytes) % block_size;
tail_len = (req->nbytes - head_len) % block_size;
- /* Make sure all pages are even block */
+ /* Make sure all pages are an even block */
int_error = sep_oddball_pages(ta_ctx->sep_used, req->src,
req->nbytes,
block_size, &new_sg, 1);
@@ -2274,8 +2177,6 @@ static void sep_hash_update(void *data)
src_ptr = NULL;
}
- sep_dump_sg(ta_ctx->sep_used, "hash block sg in", ta_ctx->src_sg);
-
ta_ctx->dcb_input_data.app_in_address = src_ptr;
ta_ctx->dcb_input_data.data_in_size =
req->nbytes - (head_len + tail_len);
@@ -2482,7 +2383,7 @@ static void sep_hash_digest(void *data)
dev_dbg(&ta_ctx->sep_used->pdev->dev, "block_size is %x\n", block_size);
dev_dbg(&ta_ctx->sep_used->pdev->dev, "tail len is %x\n", tail_len);
- /* Make sure all pages are even block */
+ /* Make sure all pages are an even block */
int_error = sep_oddball_pages(ta_ctx->sep_used, req->src,
req->nbytes,
block_size, &new_sg, 1);
@@ -2507,8 +2408,6 @@ static void sep_hash_digest(void *data)
src_ptr = NULL;
}
- sep_dump_sg(ta_ctx->sep_used, "hash block sg in", ta_ctx->src_sg);
-
ta_ctx->dcb_input_data.app_in_address = src_ptr;
ta_ctx->dcb_input_data.data_in_size = req->nbytes - tail_len;
ta_ctx->dcb_input_data.app_out_address = NULL;
diff --git a/drivers/staging/sep/sep_driver_api.h b/drivers/staging/sep/sep_driver_api.h
index 8b797d5388bb..7ee1c3bf17d7 100644
--- a/drivers/staging/sep/sep_driver_api.h
+++ b/drivers/staging/sep/sep_driver_api.h
@@ -91,7 +91,7 @@ struct sep_dcblock {
};
/*
- command structure for building dcb block (currently for ext app only
+ command structure for building dcb block (currently for ext app only)
*/
struct build_dcb_struct {
/* address value of the data in */
@@ -234,7 +234,7 @@ struct sep_dma_context {
u32 dmatables_len;
/* size of input data */
u32 input_data_len;
- /* secure dma use (for imr memory restriced area in output */
+ /* secure dma use (for imr memory restricted area in output) */
bool secure_dma;
struct sep_dma_resource dma_res_arr[SEP_MAX_NUM_SYNC_DMA_OPS];
/* Scatter gather for kernel crypto */
@@ -347,10 +347,10 @@ int sep_prepare_input_output_dma_table_in_dcb(struct sep_device *sep,
/**
* sep_free_dma_table_data_handler - free DMA table
- * @sep: pointere to struct sep_device
+ * @sep: pointer to struct sep_device
* @dma_ctx: dma context
*
- * Handles the request to free DMA table for synchronic actions
+ * Handles the request to free DMA table for synchronic actions
*/
int sep_free_dma_table_data_handler(struct sep_device *sep,
struct sep_dma_context **dma_ctx);
diff --git a/drivers/staging/sep/sep_driver_config.h b/drivers/staging/sep/sep_driver_config.h
index fa7c0d09bfa5..7d7c7ab610b7 100644
--- a/drivers/staging/sep/sep_driver_config.h
+++ b/drivers/staging/sep/sep_driver_config.h
@@ -43,7 +43,7 @@
#define SEP_DRIVER_POLLING_MODE 0
/* flag which defines if the shared area address should be
- reconfiged (send to SEP anew) during init of the driver */
+ reconfigured (send to SEP anew) during init of the driver */
#define SEP_DRIVER_RECONFIG_MESSAGE_AREA 0
/* the mode for running on the ARM1172 Evaluation platform (flag is 1) */
@@ -68,11 +68,11 @@
#define SEP_DRIVER_MIN_DATA_SIZE_PER_TABLE 16
/* flag that signifies tah the lock is
-currently held by the proccess (struct file) */
+currently held by the process (struct file) */
#define SEP_DRIVER_OWN_LOCK_FLAG 1
/* flag that signifies tah the lock is currently NOT
-held by the proccess (struct file) */
+held by the process (struct file) */
#define SEP_DRIVER_DISOWN_LOCK_FLAG 0
/* indicates whether driver has mapped/unmapped shared area */
@@ -166,7 +166,7 @@ held by the proccess (struct file) */
(SEP_DRIVER_STATIC_AREA_OFFSET_IN_BYTES + \
SEP_DRIVER_STATIC_AREA_SIZE_IN_BYTES)
-/* synhronic dma tables area offset */
+/* synchronic dma tables area offset */
#define SYNCHRONIC_DMA_TABLES_AREA_OFFSET_BYTES \
(SEP_DRIVER_DATA_POOL_AREA_OFFSET_IN_BYTES + \
SEP_DRIVER_DATA_POOL_SHARED_AREA_SIZE_IN_BYTES)
@@ -280,7 +280,7 @@ held by the proccess (struct file) */
/*
* Used to limit number of concurrent processes
- * allowed to allocte dynamic buffers in fastcall
+ * allowed to allocate dynamic buffers in fastcall
* interface.
*/
#define SEP_DOUBLEBUF_USERS_LIMIT 3
diff --git a/drivers/staging/sep/sep_main.c b/drivers/staging/sep/sep_main.c
index f1701bc6e312..ca8946acba60 100644
--- a/drivers/staging/sep/sep_main.c
+++ b/drivers/staging/sep/sep_main.c
@@ -61,7 +61,6 @@
#include <linux/interrupt.h>
#include <linux/pagemap.h>
#include <asm/cacheflush.h>
-#include <linux/sched.h>
#include <linux/delay.h>
#include <linux/jiffies.h>
#include <linux/async.h>
@@ -94,7 +93,7 @@
#endif
/**
- * Currenlty, there is only one SEP device per platform;
+ * Currently, there is only one SEP device per platform;
* In event platforms in the future have more than one SEP
* device, this will be a linked list
*/
@@ -106,7 +105,7 @@ struct sep_device *sep_dev;
* @sep: SEP device
* @sep_queue_info: pointer to status queue
*
- * This function will removes information about transaction from the queue.
+ * This function will remove information about transaction from the queue.
*/
void sep_queue_status_remove(struct sep_device *sep,
struct sep_queue_info **queue_elem)
@@ -294,7 +293,7 @@ int sep_wait_transaction(struct sep_device *sep)
end_function_setpid:
/*
* The pid_doing_transaction indicates that this process
- * now owns the facilities to performa a transaction with
+ * now owns the facilities to perform a transaction with
* the SEP. While this process is performing a transaction,
* no other process who has the SEP device open can perform
* any transactions. This method allows more than one process
@@ -447,10 +446,10 @@ static int sep_open(struct inode *inode, struct file *filp)
/**
* sep_free_dma_table_data_handler - free DMA table
- * @sep: pointere to struct sep_device
+ * @sep: pointer to struct sep_device
* @dma_ctx: dma context
*
- * Handles the request to free DMA table for synchronic actions
+ * Handles the request to free DMA table for synchronic actions
*/
int sep_free_dma_table_data_handler(struct sep_device *sep,
struct sep_dma_context **dma_ctx)
@@ -540,7 +539,7 @@ int sep_free_dma_table_data_handler(struct sep_device *sep,
* don't have a page array; the page array is generated
* only in the lock_user_pages, which is not called
* for kernel crypto, which is what the sg (scatter gather
- * is used for exclusively
+ * is used for exclusively)
*/
if (dma->src_sg) {
dma_unmap_sg(&sep->pdev->dev, dma->src_sg,
@@ -786,7 +785,7 @@ static unsigned int sep_poll(struct file *filp, poll_table *wait)
"[PID%d] poll: send_ct is %lx reply ct is %lx\n",
current->pid, sep->send_ct, sep->reply_ct);
- /* Check if error occured during poll */
+ /* Check if error occurred during poll */
retval2 = sep_read_reg(sep, HW_HOST_SEP_HOST_GPR3_REG_ADDR);
if ((retval2 != 0x0) && (retval2 != 0x8)) {
dev_dbg(&sep->pdev->dev, "[PID%d] poll; poll error %x\n",
@@ -1160,7 +1159,7 @@ static int sep_lock_kernel_pages(struct sep_device *sep,
/* Put mapped kernel sg into kernel resource array */
- /* Set output params acording to the in_out flag */
+ /* Set output params according to the in_out flag */
if (in_out_flag == SEP_DRIVER_IN_FLAG) {
*lli_array_ptr = lli_array;
dma_ctx->dma_res_arr[dma_ctx->nr_dcb_creat].in_num_pages =
@@ -1227,7 +1226,7 @@ static int sep_lock_user_pages(struct sep_device *sep,
/* Map array */
struct sep_dma_map *map_array;
- /* Set start and end pages and num pages */
+ /* Set start and end pages and num pages */
end_page = (app_virt_addr + data_size - 1) >> PAGE_SHIFT;
start_page = app_virt_addr >> PAGE_SHIFT;
num_pages = end_page - start_page + 1;
@@ -1358,7 +1357,7 @@ static int sep_lock_user_pages(struct sep_device *sep,
lli_array[num_pages - 1].block_size);
}
- /* Set output params acording to the in_out flag */
+ /* Set output params according to the in_out flag */
if (in_out_flag == SEP_DRIVER_IN_FLAG) {
*lli_array_ptr = lli_array;
dma_ctx->dma_res_arr[dma_ctx->nr_dcb_creat].in_num_pages =
@@ -1431,13 +1430,14 @@ static int sep_lli_table_secure_dma(struct sep_device *sep,
/* Array of lli */
struct sep_lli_entry *lli_array;
- /* Set start and end pages and num pages */
+ /* Set start and end pages and num pages */
end_page = (app_virt_addr + data_size - 1) >> PAGE_SHIFT;
start_page = app_virt_addr >> PAGE_SHIFT;
num_pages = end_page - start_page + 1;
- dev_dbg(&sep->pdev->dev, "[PID%d] lock user pages"
- " app_virt_addr is %x\n", current->pid, app_virt_addr);
+ dev_dbg(&sep->pdev->dev,
+ "[PID%d] lock user pages app_virt_addr is %x\n",
+ current->pid, app_virt_addr);
dev_dbg(&sep->pdev->dev, "[PID%d] data_size is (hex) %x\n",
current->pid, data_size);
@@ -1601,7 +1601,7 @@ end_function:
* @num_table_entries_ptr: pointer to number of tables
* @table_data_size: total data size
*
- * Builds ant lli table from the lli_array according to
+ * Builds an lli table from the lli_array according to
* the given size of data
*/
static void sep_build_lli_table(struct sep_device *sep,
@@ -1700,7 +1700,7 @@ static void sep_build_lli_table(struct sep_device *sep,
* @virt_address: virtual address to convert
*
* This functions returns the physical address inside shared area according
- * to the virtual address. It can be either on the externa RAM device
+ * to the virtual address. It can be either on the external RAM device
* (ioremapped), or on the system RAM
* This implementation is for the external RAM
*/
@@ -1724,7 +1724,7 @@ static dma_addr_t sep_shared_area_virt_to_bus(struct sep_device *sep,
*
* This functions returns the virtual address inside shared area
* according to the physical address. It can be either on the
- * externa RAM device (ioremapped), or on the system RAM
+ * external RAM device (ioremapped), or on the system RAM
* This implementation is for the external RAM
*/
static void *sep_shared_area_bus_to_virt(struct sep_device *sep,
@@ -1890,9 +1890,9 @@ static void sep_prepare_empty_lli_table(struct sep_device *sep,
* @lli_table_ptr:
* @num_entries_ptr:
* @table_data_size_ptr:
- * @is_kva: set for kernel data (kernel cryptio call)
+ * @is_kva: set for kernel data (kernel crypt io call)
*
- * This function prepares only input DMA table for synhronic symmetric
+ * This function prepares only input DMA table for synchronic symmetric
* operations (HASH)
* Note that all bus addresses that are passed to the SEP
* are in 32 bit format; the SEP is a 32 bit device
@@ -1931,9 +1931,9 @@ static int sep_prepare_input_dma_table(struct sep_device *sep,
void *dma_lli_table_alloc_addr = NULL;
void *dma_in_lli_table_ptr = NULL;
- dev_dbg(&sep->pdev->dev, "[PID%d] prepare intput dma "
- "tbl data size: (hex) %x\n",
- current->pid, data_size);
+ dev_dbg(&sep->pdev->dev,
+ "[PID%d] prepare intput dma tbl data size: (hex) %x\n",
+ current->pid, data_size);
dev_dbg(&sep->pdev->dev, "[PID%d] block_size is (hex) %x\n",
current->pid, block_size);
@@ -2038,7 +2038,7 @@ static int sep_prepare_input_dma_table(struct sep_device *sep,
/*
* If this is not the last table -
- * then allign it to the block size
+ * then align it to the block size
*/
if (!last_table_flag)
table_data_size =
@@ -2173,9 +2173,9 @@ static int sep_construct_dma_tables_from_lli(
u32 last_table_flag = 0;
/* The data size that should be in table */
u32 table_data_size = 0;
- /* Number of etnries in the input table */
+ /* Number of entries in the input table */
u32 num_entries_in_table = 0;
- /* Number of etnries in the output table */
+ /* Number of entries in the output table */
u32 num_entries_out_table = 0;
if (!dma_ctx) {
@@ -2400,7 +2400,7 @@ static int sep_construct_dma_tables_from_lli(
* @table_data_size_ptr:
* @is_kva: set for kernel data; used only for kernel crypto module
*
- * This function builds input and output DMA tables for synhronic
+ * This function builds input and output DMA tables for synchronic
* symmetric operations (AES, DES, HASH). It also checks that each table
* is of the modular block size
* Note that all bus addresses that are passed to the SEP
@@ -2542,19 +2542,20 @@ static int sep_prepare_input_output_dma_table(struct sep_device *sep,
}
}
- dev_dbg(&sep->pdev->dev, "[PID%d] After lock; prep input output dma "
- "table sep_in_num_pages is (hex) %x\n", current->pid,
+ dev_dbg(&sep->pdev->dev,
+ "[PID%d] After lock; prep input output dma table sep_in_num_pages is (hex) %x\n",
+ current->pid,
dma_ctx->dma_res_arr[dma_ctx->nr_dcb_creat].in_num_pages);
dev_dbg(&sep->pdev->dev, "[PID%d] sep_out_num_pages is (hex) %x\n",
current->pid,
dma_ctx->dma_res_arr[dma_ctx->nr_dcb_creat].out_num_pages);
- dev_dbg(&sep->pdev->dev, "[PID%d] SEP_DRIVER_ENTRIES_PER_TABLE_IN_SEP"
- " is (hex) %x\n", current->pid,
- SEP_DRIVER_ENTRIES_PER_TABLE_IN_SEP);
+ dev_dbg(&sep->pdev->dev,
+ "[PID%d] SEP_DRIVER_ENTRIES_PER_TABLE_IN_SEP is (hex) %x\n",
+ current->pid, SEP_DRIVER_ENTRIES_PER_TABLE_IN_SEP);
- /* Call the fucntion that creates table from the lli arrays */
+ /* Call the function that creates table from the lli arrays */
dev_dbg(&sep->pdev->dev, "[PID%d] calling create table from lli\n",
current->pid);
error = sep_construct_dma_tables_from_lli(
@@ -3033,7 +3034,7 @@ static int sep_free_dcb_handler(struct sep_device *sep,
* @cmd: command
* @arg: pointer to argument structure
*
- * Implement the ioctl methods availble on the SEP device.
+ * Implement the ioctl methods available on the SEP device.
*/
static long sep_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
{
@@ -3661,7 +3662,7 @@ static ssize_t sep_read(struct file *filp,
goto end_function;
}
- /* Checks that user has called necessarry apis */
+ /* Checks that user has called necessary apis */
if (0 == test_bit(SEP_FASTCALL_WRITE_DONE_OFFSET,
&call_status->status)) {
dev_warn(&sep->pdev->dev,
@@ -3844,8 +3845,9 @@ static ssize_t sep_write(struct file *filp,
* buffers created. Only SEP_DOUBLEBUF_USERS_LIMIT number
* of threads can progress further at a time
*/
- dev_dbg(&sep->pdev->dev, "[PID%d] waiting for double buffering "
- "region access\n", current->pid);
+ dev_dbg(&sep->pdev->dev,
+ "[PID%d] waiting for double buffering region access\n",
+ current->pid);
error = down_interruptible(&sep->sep_doublebuf);
dev_dbg(&sep->pdev->dev, "[PID%d] double buffering region start\n",
current->pid);
@@ -3889,8 +3891,8 @@ static ssize_t sep_write(struct file *filp,
current->comm, sizeof(current->comm));
if (!my_queue_elem) {
- dev_dbg(&sep->pdev->dev, "[PID%d] updating queue"
- "status error\n", current->pid);
+ dev_dbg(&sep->pdev->dev,
+ "[PID%d] updating queue status error\n", current->pid);
error = -ENOMEM;
goto end_function_error_doublebuf;
}
@@ -4155,8 +4157,8 @@ static int __devinit sep_probe(struct pci_dev *pdev,
INIT_LIST_HEAD(&sep->sep_queue_status);
- dev_dbg(&sep->pdev->dev, "sep probe: PCI obtained, "
- "device being prepared\n");
+ dev_dbg(&sep->pdev->dev,
+ "sep probe: PCI obtained, device being prepared\n");
/* Set up our register area */
sep->reg_physical_addr = pci_resource_start(sep->pdev, 0);
@@ -4318,7 +4320,7 @@ static void sep_remove(struct pci_dev *pdev)
static DEFINE_PCI_DEVICE_TABLE(sep_pci_id_tbl) = {
{PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x0826)},
{PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x08e9)},
- {0}
+ {0}
};
/* Export our pci_device_id structure to user space */
@@ -4460,7 +4462,7 @@ static int sep_pm_runtime_suspend(struct device *dev)
* @sep_pm_runtime_resume: resume- no communication with cpu & main memory
* @sep_pm_runtime_suspend: suspend- no communication with cpu & main memory
* @sep_pci_suspend: suspend - main memory is still ON
- * @sep_pci_resume: resume - main meory is still ON
+ * @sep_pci_resume: resume - main memory is still ON
*/
static const struct dev_pm_ops sep_pm = {
.runtime_resume = sep_pm_runtime_resume,
@@ -4489,30 +4491,5 @@ static struct pci_driver sep_pci_driver = {
.remove = sep_remove
};
-/**
- * sep_init - init function
- *
- * Module load time. Register the PCI device driver.
- */
-
-static int __init sep_init(void)
-{
- return pci_register_driver(&sep_pci_driver);
-}
-
-
-/**
- * sep_exit - called to unload driver
- *
- * Unregister the driver The device will perform all the cleanup required.
- */
-static void __exit sep_exit(void)
-{
- pci_unregister_driver(&sep_pci_driver);
-}
-
-
-module_init(sep_init);
-module_exit(sep_exit);
-
+module_pci_driver(sep_pci_driver);
MODULE_LICENSE("GPL");
diff --git a/drivers/staging/serial/68360serial.c b/drivers/staging/serial/68360serial.c
deleted file mode 100644
index daf0b1d0dc28..000000000000
--- a/drivers/staging/serial/68360serial.c
+++ /dev/null
@@ -1,2979 +0,0 @@
-/*
- * UART driver for 68360 CPM SCC or SMC
- * Copyright (c) 2000 D. Jeff Dionne <jeff@uclinux.org>,
- * Copyright (c) 2000 Michael Leslie <mleslie@lineo.ca>
- * Copyright (c) 1997 Dan Malek <dmalek@jlc.net>
- *
- * I used the serial.c driver as the framework for this driver.
- * Give credit to those guys.
- * The original code was written for the MBX860 board. I tried to make
- * it generic, but there may be some assumptions in the structures that
- * have to be fixed later.
- * To save porting time, I did not bother to change any object names
- * that are not accessed outside of this file.
- * It still needs lots of work........When it was easy, I included code
- * to support the SCCs, but this has never been tested, nor is it complete.
- * Only the SCCs support modem control, so that is not complete either.
- *
- * This module exports the following rs232 io functions:
- *
- * int rs_360_init(void);
- */
-
-#include <linux/module.h>
-#include <linux/errno.h>
-#include <linux/signal.h>
-#include <linux/sched.h>
-#include <linux/timer.h>
-#include <linux/interrupt.h>
-#include <linux/tty.h>
-#include <linux/tty_flip.h>
-#include <linux/serial.h>
-#include <linux/serialP.h>
-#include <linux/major.h>
-#include <linux/string.h>
-#include <linux/fcntl.h>
-#include <linux/ptrace.h>
-#include <linux/mm.h>
-#include <linux/init.h>
-#include <linux/delay.h>
-#include <asm/irq.h>
-#include <asm/m68360.h>
-#include <asm/commproc.h>
-
-
-#ifdef CONFIG_KGDB
-extern void breakpoint(void);
-extern void set_debug_traps(void);
-extern int kgdb_output_string (const char* s, unsigned int count);
-#endif
-
-
-/* #ifdef CONFIG_SERIAL_CONSOLE */ /* This seems to be a post 2.0 thing - mles */
-#include <linux/console.h>
-#include <linux/jiffies.h>
-
-/* this defines the index into rs_table for the port to use
- */
-#ifndef CONFIG_SERIAL_CONSOLE_PORT
-#define CONFIG_SERIAL_CONSOLE_PORT 1 /* ie SMC2 - note USE_SMC2 must be defined */
-#endif
-/* #endif */
-
-#if 0
-/* SCC2 for console
- */
-#undef CONFIG_SERIAL_CONSOLE_PORT
-#define CONFIG_SERIAL_CONSOLE_PORT 2
-#endif
-
-
-#define TX_WAKEUP ASYNC_SHARE_IRQ
-
-static char *serial_name = "CPM UART driver";
-static char *serial_version = "0.03";
-
-static struct tty_driver *serial_driver;
-int serial_console_setup(struct console *co, char *options);
-
-/*
- * Serial driver configuration section. Here are the various options:
- */
-#define SERIAL_PARANOIA_CHECK
-#define CONFIG_SERIAL_NOPAUSE_IO
-#define SERIAL_DO_RESTART
-
-/* Set of debugging defines */
-
-#undef SERIAL_DEBUG_INTR
-#undef SERIAL_DEBUG_OPEN
-#undef SERIAL_DEBUG_FLOW
-#undef SERIAL_DEBUG_RS_WAIT_UNTIL_SENT
-
-#define _INLINE_ inline
-
-#define DBG_CNT(s)
-
-/* We overload some of the items in the data structure to meet our
- * needs. For example, the port address is the CPM parameter ram
- * offset for the SCC or SMC. The maximum number of ports is 4 SCCs and
- * 2 SMCs. The "hub6" field is used to indicate the channel number, with
- * a flag indicating SCC or SMC, and the number is used as an index into
- * the CPM parameter area for this device.
- * The "type" field is currently set to 0, for PORT_UNKNOWN. It is
- * not currently used. I should probably use it to indicate the port
- * type of SMC or SCC.
- * The SMCs do not support any modem control signals.
- */
-#define smc_scc_num hub6
-#define NUM_IS_SCC ((int)0x00010000)
-#define PORT_NUM(P) ((P) & 0x0000ffff)
-
-
-#if defined (CONFIG_UCQUICC)
-
-volatile extern void *_periph_base;
-/* sipex transceiver
- * mode bits for are on pins
- *
- * SCC2 d16..19
- * SCC3 d20..23
- * SCC4 d24..27
- */
-#define SIPEX_MODE(n,m) ((m & 0x0f)<<(16+4*(n-1)))
-
-static uint sipex_mode_bits = 0x00000000;
-
-#endif
-
-/* There is no `serial_state' defined back here in 2.0.
- * Try to get by with serial_struct
- */
-/* #define serial_state serial_struct */
-
-/* 2.4 -> 2.0 portability problem: async_icount in 2.4 has a few
- * extras: */
-
-#if 0
-struct async_icount_24 {
- __u32 cts, dsr, rng, dcd, tx, rx;
- __u32 frame, parity, overrun, brk;
- __u32 buf_overrun;
-} icount;
-#endif
-
-#if 0
-
-struct serial_state {
- int magic;
- int baud_base;
- unsigned long port;
- int irq;
- int flags;
- int hub6;
- int type;
- int line;
- int revision; /* Chip revision (950) */
- int xmit_fifo_size;
- int custom_divisor;
- int count;
- u8 *iomem_base;
- u16 iomem_reg_shift;
- unsigned short close_delay;
- unsigned short closing_wait; /* time to wait before closing */
- struct async_icount_24 icount;
- int io_type;
- struct async_struct *info;
-};
-#endif
-
-#define SSTATE_MAGIC 0x5302
-
-
-
-/* SMC2 is sometimes used for low performance TDM interfaces. Define
- * this as 1 if you want SMC2 as a serial port UART managed by this driver.
- * Define this as 0 if you wish to use SMC2 for something else.
- */
-#define USE_SMC2 1
-
-#if 0
-/* Define SCC to ttySx mapping. */
-#define SCC_NUM_BASE (USE_SMC2 + 1) /* SCC base tty "number" */
-
-/* Define which SCC is the first one to use for a serial port. These
- * are 0-based numbers, i.e. this assumes the first SCC (SCC1) is used
- * for Ethernet, and the first available SCC for serial UART is SCC2.
- * NOTE: IF YOU CHANGE THIS, you have to change the PROFF_xxx and
- * interrupt vectors in the table below to match.
- */
-#define SCC_IDX_BASE 1 /* table index */
-#endif
-
-
-/* Processors other than the 860 only get SMCs configured by default.
- * Either they don't have SCCs or they are allocated somewhere else.
- * Of course, there are now 860s without some SCCs, so we will need to
- * address that someday.
- * The Embedded Planet Multimedia I/O cards use TDM interfaces to the
- * stereo codec parts, and we use SMC2 to help support that.
- */
-static struct serial_state rs_table[] = {
-/* type line PORT IRQ FLAGS smc_scc_num (F.K.A. hub6) */
- { 0, 0, PRSLOT_SMC1, CPMVEC_SMC1, 0, 0 } /* SMC1 ttyS0 */
-#if USE_SMC2
- ,{ 0, 0, PRSLOT_SMC2, CPMVEC_SMC2, 0, 1 } /* SMC2 ttyS1 */
-#endif
-
-#if defined(CONFIG_SERIAL_68360_SCC)
- ,{ 0, 0, PRSLOT_SCC2, CPMVEC_SCC2, 0, (NUM_IS_SCC | 1) } /* SCC2 ttyS2 */
- ,{ 0, 0, PRSLOT_SCC3, CPMVEC_SCC3, 0, (NUM_IS_SCC | 2) } /* SCC3 ttyS3 */
- ,{ 0, 0, PRSLOT_SCC4, CPMVEC_SCC4, 0, (NUM_IS_SCC | 3) } /* SCC4 ttyS4 */
-#endif
-};
-
-#define NR_PORTS (sizeof(rs_table)/sizeof(struct serial_state))
-
-/* The number of buffer descriptors and their sizes.
- */
-#define RX_NUM_FIFO 4
-#define RX_BUF_SIZE 32
-#define TX_NUM_FIFO 4
-#define TX_BUF_SIZE 32
-
-#define CONSOLE_NUM_FIFO 2
-#define CONSOLE_BUF_SIZE 4
-
-char *console_fifos[CONSOLE_NUM_FIFO * CONSOLE_BUF_SIZE];
-
-/* The async_struct in serial.h does not really give us what we
- * need, so define our own here.
- */
-typedef struct serial_info {
- int magic;
- int flags;
-
- struct serial_state *state;
- /* struct serial_struct *state; */
- /* struct async_struct *state; */
-
- struct tty_struct *tty;
- int read_status_mask;
- int ignore_status_mask;
- int timeout;
- int line;
- int x_char; /* xon/xoff character */
- int close_delay;
- unsigned short closing_wait;
- unsigned short closing_wait2;
- unsigned long event;
- unsigned long last_active;
- int blocked_open; /* # of blocked opens */
- struct work_struct tqueue;
- struct work_struct tqueue_hangup;
- wait_queue_head_t open_wait;
- wait_queue_head_t close_wait;
-
-
-/* CPM Buffer Descriptor pointers.
- */
- QUICC_BD *rx_bd_base;
- QUICC_BD *rx_cur;
- QUICC_BD *tx_bd_base;
- QUICC_BD *tx_cur;
-} ser_info_t;
-
-
-/* since kmalloc_init() does not get called until much after this initialization: */
-static ser_info_t quicc_ser_info[NR_PORTS];
-static char rx_buf_pool[NR_PORTS * RX_NUM_FIFO * RX_BUF_SIZE];
-static char tx_buf_pool[NR_PORTS * TX_NUM_FIFO * TX_BUF_SIZE];
-
-static void change_speed(ser_info_t *info);
-static void rs_360_wait_until_sent(struct tty_struct *tty, int timeout);
-
-static inline int serial_paranoia_check(ser_info_t *info,
- char *name, const char *routine)
-{
-#ifdef SERIAL_PARANOIA_CHECK
- static const char *badmagic =
- "Warning: bad magic number for serial struct (%s) in %s\n";
- static const char *badinfo =
- "Warning: null async_struct for (%s) in %s\n";
-
- if (!info) {
- printk(badinfo, name, routine);
- return 1;
- }
- if (info->magic != SERIAL_MAGIC) {
- printk(badmagic, name, routine);
- return 1;
- }
-#endif
- return 0;
-}
-
-/*
- * This is used to figure out the divisor speeds and the timeouts,
- * indexed by the termio value. The generic CPM functions are responsible
- * for setting and assigning baud rate generators for us.
- */
-static int baud_table[] = {
- 0, 50, 75, 110, 134, 150, 200, 300, 600, 1200, 1800, 2400, 4800,
- 9600, 19200, 38400, 57600, 115200, 230400, 460800, 0 };
-
-/* This sucks. There is a better way: */
-#if defined(CONFIG_CONSOLE_9600)
- #define CONSOLE_BAUDRATE 9600
-#elif defined(CONFIG_CONSOLE_19200)
- #define CONSOLE_BAUDRATE 19200
-#elif defined(CONFIG_CONSOLE_115200)
- #define CONSOLE_BAUDRATE 115200
-#else
- #warning "console baud rate undefined"
- #define CONSOLE_BAUDRATE 9600
-#endif
-
-/*
- * ------------------------------------------------------------
- * rs_stop() and rs_start()
- *
- * This routines are called before setting or resetting tty->stopped.
- * They enable or disable transmitter interrupts, as necessary.
- * ------------------------------------------------------------
- */
-static void rs_360_stop(struct tty_struct *tty)
-{
- ser_info_t *info = (ser_info_t *)tty->driver_data;
- int idx;
- unsigned long flags;
- volatile struct scc_regs *sccp;
- volatile struct smc_regs *smcp;
-
- if (serial_paranoia_check(info, tty->name, "rs_stop"))
- return;
-
- local_irq_save(flags);
- idx = PORT_NUM(info->state->smc_scc_num);
- if (info->state->smc_scc_num & NUM_IS_SCC) {
- sccp = &pquicc->scc_regs[idx];
- sccp->scc_sccm &= ~UART_SCCM_TX;
- } else {
- /* smcp = &cpmp->cp_smc[idx]; */
- smcp = &pquicc->smc_regs[idx];
- smcp->smc_smcm &= ~SMCM_TX;
- }
- local_irq_restore(flags);
-}
-
-
-static void rs_360_start(struct tty_struct *tty)
-{
- ser_info_t *info = (ser_info_t *)tty->driver_data;
- int idx;
- unsigned long flags;
- volatile struct scc_regs *sccp;
- volatile struct smc_regs *smcp;
-
- if (serial_paranoia_check(info, tty->name, "rs_stop"))
- return;
-
- local_irq_save(flags);
- idx = PORT_NUM(info->state->smc_scc_num);
- if (info->state->smc_scc_num & NUM_IS_SCC) {
- sccp = &pquicc->scc_regs[idx];
- sccp->scc_sccm |= UART_SCCM_TX;
- } else {
- smcp = &pquicc->smc_regs[idx];
- smcp->smc_smcm |= SMCM_TX;
- }
- local_irq_restore(flags);
-}
-
-/*
- * ----------------------------------------------------------------------
- *
- * Here starts the interrupt handling routines. All of the following
- * subroutines are declared as inline and are folded into
- * rs_interrupt(). They were separated out for readability's sake.
- *
- * Note: rs_interrupt() is a "fast" interrupt, which means that it
- * runs with interrupts turned off. People who may want to modify
- * rs_interrupt() should try to keep the interrupt handler as fast as
- * possible. After you are done making modifications, it is not a bad
- * idea to do:
- *
- * gcc -S -DKERNEL -Wall -Wstrict-prototypes -O6 -fomit-frame-pointer serial.c
- *
- * and look at the resulting assemble code in serial.s.
- *
- * - Ted Ts'o (tytso@mit.edu), 7-Mar-93
- * -----------------------------------------------------------------------
- */
-
-static _INLINE_ void receive_chars(ser_info_t *info)
-{
- struct tty_struct *tty = info->port.tty;
- unsigned char ch, flag, *cp;
- /*int ignored = 0;*/
- int i;
- ushort status;
- struct async_icount *icount;
- /* struct async_icount_24 *icount; */
- volatile QUICC_BD *bdp;
-
- icount = &info->state->icount;
-
- /* Just loop through the closed BDs and copy the characters into
- * the buffer.
- */
- bdp = info->rx_cur;
- for (;;) {
- if (bdp->status & BD_SC_EMPTY) /* If this one is empty */
- break; /* we are all done */
-
- /* The read status mask tell us what we should do with
- * incoming characters, especially if errors occur.
- * One special case is the use of BD_SC_EMPTY. If
- * this is not set, we are supposed to be ignoring
- * inputs. In this case, just mark the buffer empty and
- * continue.
- */
- if (!(info->read_status_mask & BD_SC_EMPTY)) {
- bdp->status |= BD_SC_EMPTY;
- bdp->status &=
- ~(BD_SC_BR | BD_SC_FR | BD_SC_PR | BD_SC_OV);
-
- if (bdp->status & BD_SC_WRAP)
- bdp = info->rx_bd_base;
- else
- bdp++;
- continue;
- }
-
- /* Get the number of characters and the buffer pointer.
- */
- i = bdp->length;
- /* cp = (unsigned char *)__va(bdp->buf); */
- cp = (char *)bdp->buf;
- status = bdp->status;
-
- while (i-- > 0) {
- ch = *cp++;
- icount->rx++;
-
-#ifdef SERIAL_DEBUG_INTR
- printk("DR%02x:%02x...", ch, status);
-#endif
- flag = TTY_NORMAL;
-
- if (status & (BD_SC_BR | BD_SC_FR |
- BD_SC_PR | BD_SC_OV)) {
- /*
- * For statistics only
- */
- if (status & BD_SC_BR)
- icount->brk++;
- else if (status & BD_SC_PR)
- icount->parity++;
- else if (status & BD_SC_FR)
- icount->frame++;
- if (status & BD_SC_OV)
- icount->overrun++;
-
- /*
- * Now check to see if character should be
- * ignored, and mask off conditions which
- * should be ignored.
- if (status & info->ignore_status_mask) {
- if (++ignored > 100)
- break;
- continue;
- }
- */
- status &= info->read_status_mask;
-
- if (status & (BD_SC_BR)) {
-#ifdef SERIAL_DEBUG_INTR
- printk("handling break....");
-#endif
- *tty->flip.flag_buf_ptr = TTY_BREAK;
- if (info->flags & ASYNC_SAK)
- do_SAK(tty);
- } else if (status & BD_SC_PR)
- flag = TTY_PARITY;
- else if (status & BD_SC_FR)
- flag = TTY_FRAME;
- }
- tty_insert_flip_char(tty, ch, flag);
- if (status & BD_SC_OV)
- /*
- * Overrun is special, since it's
- * reported immediately, and doesn't
- * affect the current character
- */
- tty_insert_flip_char(tty, 0, TTY_OVERRUN);
- }
-
- /* This BD is ready to be used again. Clear status.
- * Get next BD.
- */
- bdp->status |= BD_SC_EMPTY;
- bdp->status &= ~(BD_SC_BR | BD_SC_FR | BD_SC_PR | BD_SC_OV);
-
- if (bdp->status & BD_SC_WRAP)
- bdp = info->rx_bd_base;
- else
- bdp++;
- }
-
- info->rx_cur = (QUICC_BD *)bdp;
-
- tty_schedule_flip(tty);
-}
-
-static _INLINE_ void receive_break(ser_info_t *info)
-{
- struct tty_struct *tty = info->port.tty;
-
- info->state->icount.brk++;
- /* Check to see if there is room in the tty buffer for
- * the break. If not, we exit now, losing the break. FIXME
- */
- tty_insert_flip_char(tty, 0, TTY_BREAK);
- tty_schedule_flip(tty);
-}
-
-static _INLINE_ void transmit_chars(ser_info_t *info)
-{
-
- if ((info->flags & TX_WAKEUP) ||
- (info->port.tty->flags & (1 << TTY_DO_WRITE_WAKEUP))) {
- schedule_work(&info->tqueue);
- }
-
-#ifdef SERIAL_DEBUG_INTR
- printk("THRE...");
-#endif
-}
-
-#ifdef notdef
- /* I need to do this for the SCCs, so it is left as a reminder.
- */
-static _INLINE_ void check_modem_status(struct async_struct *info)
-{
- int status;
- /* struct async_icount *icount; */
- struct async_icount_24 *icount;
-
- status = serial_in(info, UART_MSR);
-
- if (status & UART_MSR_ANY_DELTA) {
- icount = &info->state->icount;
- /* update input line counters */
- if (status & UART_MSR_TERI)
- icount->rng++;
- if (status & UART_MSR_DDSR)
- icount->dsr++;
- if (status & UART_MSR_DDCD) {
- icount->dcd++;
-#ifdef CONFIG_HARD_PPS
- if ((info->flags & ASYNC_HARDPPS_CD) &&
- (status & UART_MSR_DCD))
- hardpps();
-#endif
- }
- if (status & UART_MSR_DCTS)
- icount->cts++;
- wake_up_interruptible(&info->delta_msr_wait);
- }
-
- if ((info->flags & ASYNC_CHECK_CD) && (status & UART_MSR_DDCD)) {
-#if (defined(SERIAL_DEBUG_OPEN) || defined(SERIAL_DEBUG_INTR))
- printk("ttys%d CD now %s...", info->line,
- (status & UART_MSR_DCD) ? "on" : "off");
-#endif
- if (status & UART_MSR_DCD)
- wake_up_interruptible(&info->open_wait);
- else {
-#ifdef SERIAL_DEBUG_OPEN
- printk("scheduling hangup...");
-#endif
- queue_task(&info->tqueue_hangup,
- &tq_scheduler);
- }
- }
- if (info->flags & ASYNC_CTS_FLOW) {
- if (info->port.tty->hw_stopped) {
- if (status & UART_MSR_CTS) {
-#if (defined(SERIAL_DEBUG_INTR) || defined(SERIAL_DEBUG_FLOW))
- printk("CTS tx start...");
-#endif
- info->port.tty->hw_stopped = 0;
- info->IER |= UART_IER_THRI;
- serial_out(info, UART_IER, info->IER);
- rs_sched_event(info, RS_EVENT_WRITE_WAKEUP);
- return;
- }
- } else {
- if (!(status & UART_MSR_CTS)) {
-#if (defined(SERIAL_DEBUG_INTR) || defined(SERIAL_DEBUG_FLOW))
- printk("CTS tx stop...");
-#endif
- info->port.tty->hw_stopped = 1;
- info->IER &= ~UART_IER_THRI;
- serial_out(info, UART_IER, info->IER);
- }
- }
- }
-}
-#endif
-
-/*
- * This is the serial driver's interrupt routine for a single port
- */
-/* static void rs_360_interrupt(void *dev_id) */ /* until and if we start servicing irqs here */
-static void rs_360_interrupt(int vec, void *dev_id)
-{
- u_char events;
- int idx;
- ser_info_t *info;
- volatile struct smc_regs *smcp;
- volatile struct scc_regs *sccp;
-
- info = dev_id;
-
- idx = PORT_NUM(info->state->smc_scc_num);
- if (info->state->smc_scc_num & NUM_IS_SCC) {
- sccp = &pquicc->scc_regs[idx];
- events = sccp->scc_scce;
- if (events & SCCM_RX)
- receive_chars(info);
- if (events & SCCM_TX)
- transmit_chars(info);
- sccp->scc_scce = events;
- } else {
- smcp = &pquicc->smc_regs[idx];
- events = smcp->smc_smce;
- if (events & SMCM_BRKE)
- receive_break(info);
- if (events & SMCM_RX)
- receive_chars(info);
- if (events & SMCM_TX)
- transmit_chars(info);
- smcp->smc_smce = events;
- }
-
-#ifdef SERIAL_DEBUG_INTR
- printk("rs_interrupt_single(%d, %x)...",
- info->state->smc_scc_num, events);
-#endif
-#ifdef modem_control
- check_modem_status(info);
-#endif
- info->last_active = jiffies;
-#ifdef SERIAL_DEBUG_INTR
- printk("end.\n");
-#endif
-}
-
-
-/*
- * -------------------------------------------------------------------
- * Here ends the serial interrupt routines.
- * -------------------------------------------------------------------
- */
-
-
-static void do_softint(void *private_)
-{
- ser_info_t *info = (ser_info_t *) private_;
- struct tty_struct *tty;
-
- tty = info->port.tty;
- if (!tty)
- return;
-
- if (test_and_clear_bit(RS_EVENT_WRITE_WAKEUP, &info->event))
- tty_wakeup(tty);
-}
-
-
-/*
- * This routine is called from the scheduler tqueue when the interrupt
- * routine has signalled that a hangup has occurred. The path of
- * hangup processing is:
- *
- * serial interrupt routine -> (scheduler tqueue) ->
- * do_serial_hangup() -> tty->hangup() -> rs_hangup()
- *
- */
-static void do_serial_hangup(void *private_)
-{
- struct async_struct *info = (struct async_struct *) private_;
- struct tty_struct *tty;
-
- tty = info->port.tty;
- if (!tty)
- return;
-
- tty_hangup(tty);
-}
-
-
-static int startup(ser_info_t *info)
-{
- unsigned long flags;
- int retval=0;
- int idx;
- /*struct serial_state *state = info->state;*/
- volatile struct smc_regs *smcp;
- volatile struct scc_regs *sccp;
- volatile struct smc_uart_pram *up;
- volatile struct uart_pram *scup;
-
-
- local_irq_save(flags);
-
- if (info->flags & ASYNC_INITIALIZED) {
- goto errout;
- }
-
-#ifdef maybe
- if (!state->port || !state->type) {
- if (info->port.tty)
- set_bit(TTY_IO_ERROR, &info->port.tty->flags);
- goto errout;
- }
-#endif
-
-#ifdef SERIAL_DEBUG_OPEN
- printk("starting up ttys%d (irq %d)...", info->line, state->irq);
-#endif
-
-
-#ifdef modem_control
- info->MCR = 0;
- if (info->port.tty->termios->c_cflag & CBAUD)
- info->MCR = UART_MCR_DTR | UART_MCR_RTS;
-#endif
-
- if (info->port.tty)
- clear_bit(TTY_IO_ERROR, &info->port.tty->flags);
-
- /*
- * and set the speed of the serial port
- */
- change_speed(info);
-
- idx = PORT_NUM(info->state->smc_scc_num);
- if (info->state->smc_scc_num & NUM_IS_SCC) {
- sccp = &pquicc->scc_regs[idx];
- scup = &pquicc->pram[info->state->port].scc.pscc.u;
-
- scup->mrblr = RX_BUF_SIZE;
- scup->max_idl = RX_BUF_SIZE;
-
- sccp->scc_sccm |= (UART_SCCM_TX | UART_SCCM_RX);
- sccp->scc_gsmr.w.low |= (SCC_GSMRL_ENR | SCC_GSMRL_ENT);
-
- } else {
- smcp = &pquicc->smc_regs[idx];
-
- /* Enable interrupts and I/O.
- */
- smcp->smc_smcm |= (SMCM_RX | SMCM_TX);
- smcp->smc_smcmr |= (SMCMR_REN | SMCMR_TEN);
-
- /* We can tune the buffer length and idle characters
- * to take advantage of the entire incoming buffer size.
- * If mrblr is something other than 1, maxidl has to be
- * non-zero or we never get an interrupt. The maxidl
- * is the number of character times we wait after reception
- * of the last character before we decide no more characters
- * are coming.
- */
- /* up = (smc_uart_t *)&pquicc->cp_dparam[state->port]; */
- /* holy unionized structures, Batman: */
- up = &pquicc->pram[info->state->port].scc.pothers.idma_smc.psmc.u;
-
- up->mrblr = RX_BUF_SIZE;
- up->max_idl = RX_BUF_SIZE;
-
- up->brkcr = 1; /* number of break chars */
- }
-
- info->flags |= ASYNC_INITIALIZED;
- local_irq_restore(flags);
- return 0;
-
-errout:
- local_irq_restore(flags);
- return retval;
-}
-
-/*
- * This routine will shutdown a serial port; interrupts are disabled, and
- * DTR is dropped if the hangup on close termio flag is on.
- */
-static void shutdown(ser_info_t *info)
-{
- unsigned long flags;
- struct serial_state *state;
- int idx;
- volatile struct smc_regs *smcp;
- volatile struct scc_regs *sccp;
-
- if (!(info->flags & ASYNC_INITIALIZED))
- return;
-
- state = info->state;
-
-#ifdef SERIAL_DEBUG_OPEN
- printk("Shutting down serial port %d (irq %d)....", info->line,
- state->irq);
-#endif
-
- local_irq_save(flags);
-
- idx = PORT_NUM(state->smc_scc_num);
- if (state->smc_scc_num & NUM_IS_SCC) {
- sccp = &pquicc->scc_regs[idx];
- sccp->scc_gsmr.w.low &= ~(SCC_GSMRL_ENR | SCC_GSMRL_ENT);
-#ifdef CONFIG_SERIAL_CONSOLE
- /* We can't disable the transmitter if this is the
- * system console.
- */
- if ((state - rs_table) != CONFIG_SERIAL_CONSOLE_PORT)
-#endif
- sccp->scc_sccm &= ~(UART_SCCM_TX | UART_SCCM_RX);
- } else {
- smcp = &pquicc->smc_regs[idx];
-
- /* Disable interrupts and I/O.
- */
- smcp->smc_smcm &= ~(SMCM_RX | SMCM_TX);
-#ifdef CONFIG_SERIAL_CONSOLE
- /* We can't disable the transmitter if this is the
- * system console.
- */
- if ((state - rs_table) != CONFIG_SERIAL_CONSOLE_PORT)
-#endif
- smcp->smc_smcmr &= ~(SMCMR_REN | SMCMR_TEN);
- }
-
- if (info->port.tty)
- set_bit(TTY_IO_ERROR, &info->port.tty->flags);
-
- info->flags &= ~ASYNC_INITIALIZED;
- local_irq_restore(flags);
-}
-
-/*
- * This routine is called to set the UART divisor registers to match
- * the specified baud rate for a serial port.
- */
-static void change_speed(ser_info_t *info)
-{
- int baud_rate;
- unsigned cflag, cval, scval, prev_mode;
- int i, bits, sbits, idx;
- unsigned long flags;
- struct serial_state *state;
- volatile struct smc_regs *smcp;
- volatile struct scc_regs *sccp;
-
- if (!info->port.tty || !info->port.tty->termios)
- return;
- cflag = info->port.tty->termios->c_cflag;
-
- state = info->state;
-
- /* Character length programmed into the mode register is the
- * sum of: 1 start bit, number of data bits, 0 or 1 parity bit,
- * 1 or 2 stop bits, minus 1.
- * The value 'bits' counts this for us.
- */
- cval = 0;
- scval = 0;
-
- /* byte size and parity */
- switch (cflag & CSIZE) {
- case CS5: bits = 5; break;
- case CS6: bits = 6; break;
- case CS7: bits = 7; break;
- case CS8: bits = 8; break;
- /* Never happens, but GCC is too dumb to figure it out */
- default: bits = 8; break;
- }
- sbits = bits - 5;
-
- if (cflag & CSTOPB) {
- cval |= SMCMR_SL; /* Two stops */
- scval |= SCU_PMSR_SL;
- bits++;
- }
- if (cflag & PARENB) {
- cval |= SMCMR_PEN;
- scval |= SCU_PMSR_PEN;
- bits++;
- }
- if (!(cflag & PARODD)) {
- cval |= SMCMR_PM_EVEN;
- scval |= (SCU_PMSR_REVP | SCU_PMSR_TEVP);
- }
-
- /* Determine divisor based on baud rate */
- i = cflag & CBAUD;
- if (i >= (sizeof(baud_table)/sizeof(int)))
- baud_rate = 9600;
- else
- baud_rate = baud_table[i];
-
- info->timeout = (TX_BUF_SIZE*HZ*bits);
- info->timeout += HZ/50; /* Add .02 seconds of slop */
-
-#ifdef modem_control
- /* CTS flow control flag and modem status interrupts */
- info->IER &= ~UART_IER_MSI;
- if (info->flags & ASYNC_HARDPPS_CD)
- info->IER |= UART_IER_MSI;
- if (cflag & CRTSCTS) {
- info->flags |= ASYNC_CTS_FLOW;
- info->IER |= UART_IER_MSI;
- } else
- info->flags &= ~ASYNC_CTS_FLOW;
- if (cflag & CLOCAL)
- info->flags &= ~ASYNC_CHECK_CD;
- else {
- info->flags |= ASYNC_CHECK_CD;
- info->IER |= UART_IER_MSI;
- }
- serial_out(info, UART_IER, info->IER);
-#endif
-
- /*
- * Set up parity check flag
- */
- info->read_status_mask = (BD_SC_EMPTY | BD_SC_OV);
- if (I_INPCK(info->port.tty))
- info->read_status_mask |= BD_SC_FR | BD_SC_PR;
- if (I_BRKINT(info->port.tty) || I_PARMRK(info->port.tty))
- info->read_status_mask |= BD_SC_BR;
-
- /*
- * Characters to ignore
- */
- info->ignore_status_mask = 0;
- if (I_IGNPAR(info->port.tty))
- info->ignore_status_mask |= BD_SC_PR | BD_SC_FR;
- if (I_IGNBRK(info->port.tty)) {
- info->ignore_status_mask |= BD_SC_BR;
- /*
- * If we're ignore parity and break indicators, ignore
- * overruns too. (For real raw support).
- */
- if (I_IGNPAR(info->port.tty))
- info->ignore_status_mask |= BD_SC_OV;
- }
- /*
- * !!! ignore all characters if CREAD is not set
- */
- if ((cflag & CREAD) == 0)
- info->read_status_mask &= ~BD_SC_EMPTY;
- local_irq_save(flags);
-
- /* Start bit has not been added (so don't, because we would just
- * subtract it later), and we need to add one for the number of
- * stops bits (there is always at least one).
- */
- bits++;
- idx = PORT_NUM(state->smc_scc_num);
- if (state->smc_scc_num & NUM_IS_SCC) {
- sccp = &pquicc->scc_regs[idx];
- sccp->scc_psmr = (sbits << 12) | scval;
- } else {
- smcp = &pquicc->smc_regs[idx];
-
- /* Set the mode register. We want to keep a copy of the
- * enables, because we want to put them back if they were
- * present.
- */
- prev_mode = smcp->smc_smcmr;
- smcp->smc_smcmr = smcr_mk_clen(bits) | cval | SMCMR_SM_UART;
- smcp->smc_smcmr |= (prev_mode & (SMCMR_REN | SMCMR_TEN));
- }
-
- m360_cpm_setbrg((state - rs_table), baud_rate);
-
- local_irq_restore(flags);
-}
-
-static void rs_360_put_char(struct tty_struct *tty, unsigned char ch)
-{
- ser_info_t *info = (ser_info_t *)tty->driver_data;
- volatile QUICC_BD *bdp;
-
- if (serial_paranoia_check(info, tty->name, "rs_put_char"))
- return 0;
-
- if (!tty)
- return 0;
-
- bdp = info->tx_cur;
- while (bdp->status & BD_SC_READY);
-
- /* *((char *)__va(bdp->buf)) = ch; */
- *((char *)bdp->buf) = ch;
- bdp->length = 1;
- bdp->status |= BD_SC_READY;
-
- /* Get next BD.
- */
- if (bdp->status & BD_SC_WRAP)
- bdp = info->tx_bd_base;
- else
- bdp++;
-
- info->tx_cur = (QUICC_BD *)bdp;
- return 1;
-
-}
-
-static int rs_360_write(struct tty_struct * tty,
- const unsigned char *buf, int count)
-{
- int c, ret = 0;
- ser_info_t *info = (ser_info_t *)tty->driver_data;
- volatile QUICC_BD *bdp;
-
-#ifdef CONFIG_KGDB
- /* Try to let stub handle output. Returns true if it did. */
- if (kgdb_output_string(buf, count))
- return ret;
-#endif
-
- if (serial_paranoia_check(info, tty->name, "rs_write"))
- return 0;
-
- if (!tty)
- return 0;
-
- bdp = info->tx_cur;
-
- while (1) {
- c = min(count, TX_BUF_SIZE);
-
- if (c <= 0)
- break;
-
- if (bdp->status & BD_SC_READY) {
- info->flags |= TX_WAKEUP;
- break;
- }
-
- /* memcpy(__va(bdp->buf), buf, c); */
- memcpy((void *)bdp->buf, buf, c);
-
- bdp->length = c;
- bdp->status |= BD_SC_READY;
-
- buf += c;
- count -= c;
- ret += c;
-
- /* Get next BD.
- */
- if (bdp->status & BD_SC_WRAP)
- bdp = info->tx_bd_base;
- else
- bdp++;
- info->tx_cur = (QUICC_BD *)bdp;
- }
- return ret;
-}
-
-static int rs_360_write_room(struct tty_struct *tty)
-{
- ser_info_t *info = (ser_info_t *)tty->driver_data;
- int ret;
-
- if (serial_paranoia_check(info, tty->name, "rs_write_room"))
- return 0;
-
- if ((info->tx_cur->status & BD_SC_READY) == 0) {
- info->flags &= ~TX_WAKEUP;
- ret = TX_BUF_SIZE;
- }
- else {
- info->flags |= TX_WAKEUP;
- ret = 0;
- }
- return ret;
-}
-
-/* I could track this with transmit counters....maybe later.
-*/
-static int rs_360_chars_in_buffer(struct tty_struct *tty)
-{
- ser_info_t *info = (ser_info_t *)tty->driver_data;
-
- if (serial_paranoia_check(info, tty->name, "rs_chars_in_buffer"))
- return 0;
- return 0;
-}
-
-static void rs_360_flush_buffer(struct tty_struct *tty)
-{
- ser_info_t *info = (ser_info_t *)tty->driver_data;
-
- if (serial_paranoia_check(info, tty->name, "rs_flush_buffer"))
- return;
-
- /* There is nothing to "flush", whatever we gave the CPM
- * is on its way out.
- */
- tty_wakeup(tty);
- info->flags &= ~TX_WAKEUP;
-}
-
-/*
- * This function is used to send a high-priority XON/XOFF character to
- * the device
- */
-static void rs_360_send_xchar(struct tty_struct *tty, char ch)
-{
- volatile QUICC_BD *bdp;
-
- ser_info_t *info = (ser_info_t *)tty->driver_data;
-
- if (serial_paranoia_check(info, tty->name, "rs_send_char"))
- return;
-
- bdp = info->tx_cur;
- while (bdp->status & BD_SC_READY);
-
- /* *((char *)__va(bdp->buf)) = ch; */
- *((char *)bdp->buf) = ch;
- bdp->length = 1;
- bdp->status |= BD_SC_READY;
-
- /* Get next BD.
- */
- if (bdp->status & BD_SC_WRAP)
- bdp = info->tx_bd_base;
- else
- bdp++;
-
- info->tx_cur = (QUICC_BD *)bdp;
-}
-
-/*
- * ------------------------------------------------------------
- * rs_throttle()
- *
- * This routine is called by the upper-layer tty layer to signal that
- * incoming characters should be throttled.
- * ------------------------------------------------------------
- */
-static void rs_360_throttle(struct tty_struct * tty)
-{
- ser_info_t *info = (ser_info_t *)tty->driver_data;
-#ifdef SERIAL_DEBUG_THROTTLE
- char buf[64];
-
- printk("throttle %s: %d....\n", _tty_name(tty, buf),
- tty->ldisc.chars_in_buffer(tty));
-#endif
-
- if (serial_paranoia_check(info, tty->name, "rs_throttle"))
- return;
-
- if (I_IXOFF(tty))
- rs_360_send_xchar(tty, STOP_CHAR(tty));
-
-#ifdef modem_control
- if (tty->termios->c_cflag & CRTSCTS)
- info->MCR &= ~UART_MCR_RTS;
-
- local_irq_disable();
- serial_out(info, UART_MCR, info->MCR);
- local_irq_enable();
-#endif
-}
-
-static void rs_360_unthrottle(struct tty_struct * tty)
-{
- ser_info_t *info = (ser_info_t *)tty->driver_data;
-#ifdef SERIAL_DEBUG_THROTTLE
- char buf[64];
-
- printk("unthrottle %s: %d....\n", _tty_name(tty, buf),
- tty->ldisc.chars_in_buffer(tty));
-#endif
-
- if (serial_paranoia_check(info, tty->name, "rs_unthrottle"))
- return;
-
- if (I_IXOFF(tty)) {
- if (info->x_char)
- info->x_char = 0;
- else
- rs_360_send_xchar(tty, START_CHAR(tty));
- }
-#ifdef modem_control
- if (tty->termios->c_cflag & CRTSCTS)
- info->MCR |= UART_MCR_RTS;
- local_irq_disable();
- serial_out(info, UART_MCR, info->MCR);
- local_irq_enable();
-#endif
-}
-
-/*
- * ------------------------------------------------------------
- * rs_ioctl() and friends
- * ------------------------------------------------------------
- */
-
-#ifdef maybe
-/*
- * get_lsr_info - get line status register info
- *
- * Purpose: Let user call ioctl() to get info when the UART physically
- * is emptied. On bus types like RS485, the transmitter must
- * release the bus after transmitting. This must be done when
- * the transmit shift register is empty, not be done when the
- * transmit holding register is empty. This functionality
- * allows an RS485 driver to be written in user space.
- */
-static int get_lsr_info(struct async_struct * info, unsigned int *value)
-{
- unsigned char status;
- unsigned int result;
-
- local_irq_disable();
- status = serial_in(info, UART_LSR);
- local_irq_enable();
- result = ((status & UART_LSR_TEMT) ? TIOCSER_TEMT : 0);
- return put_user(result,value);
-}
-#endif
-
-static int rs_360_tiocmget(struct tty_struct *tty)
-{
- ser_info_t *info = (ser_info_t *)tty->driver_data;
- unsigned int result = 0;
-#ifdef modem_control
- unsigned char control, status;
-
- if (serial_paranoia_check(info, tty->name, __func__))
- return -ENODEV;
-
- if (tty->flags & (1 << TTY_IO_ERROR))
- return -EIO;
-
- control = info->MCR;
- local_irq_disable();
- status = serial_in(info, UART_MSR);
- local_irq_enable();
- result = ((control & UART_MCR_RTS) ? TIOCM_RTS : 0)
- | ((control & UART_MCR_DTR) ? TIOCM_DTR : 0)
-#ifdef TIOCM_OUT1
- | ((control & UART_MCR_OUT1) ? TIOCM_OUT1 : 0)
- | ((control & UART_MCR_OUT2) ? TIOCM_OUT2 : 0)
-#endif
- | ((status & UART_MSR_DCD) ? TIOCM_CAR : 0)
- | ((status & UART_MSR_RI) ? TIOCM_RNG : 0)
- | ((status & UART_MSR_DSR) ? TIOCM_DSR : 0)
- | ((status & UART_MSR_CTS) ? TIOCM_CTS : 0);
-#endif
- return result;
-}
-
-static int rs_360_tiocmset(struct tty_struct *tty,
- unsigned int set, unsigned int clear)
-{
-#ifdef modem_control
- ser_info_t *info = (ser_info_t *)tty->driver_data;
- unsigned int arg;
-
- if (serial_paranoia_check(info, tty->name, __func__))
- return -ENODEV;
-
- if (tty->flags & (1 << TTY_IO_ERROR))
- return -EIO;
- /* FIXME: locking on info->mcr */
- if (set & TIOCM_RTS)
- info->mcr |= UART_MCR_RTS;
- if (set & TIOCM_DTR)
- info->mcr |= UART_MCR_DTR;
- if (clear & TIOCM_RTS)
- info->MCR &= ~UART_MCR_RTS;
- if (clear & TIOCM_DTR)
- info->MCR &= ~UART_MCR_DTR;
-
-#ifdef TIOCM_OUT1
- if (set & TIOCM_OUT1)
- info->MCR |= UART_MCR_OUT1;
- if (set & TIOCM_OUT2)
- info->MCR |= UART_MCR_OUT2;
- if (clear & TIOCM_OUT1)
- info->MCR &= ~UART_MCR_OUT1;
- if (clear & TIOCM_OUT2)
- info->MCR &= ~UART_MCR_OUT2;
-#endif
-
- local_irq_disable();
- serial_out(info, UART_MCR, info->MCR);
- local_irq_enable();
-#endif
- return 0;
-}
-
-/* Sending a break is a two step process on the SMC/SCC. It is accomplished
- * by sending a STOP TRANSMIT command followed by a RESTART TRANSMIT
- * command. We take advantage of the begin/end functions to make this
- * happen.
- */
-static ushort smc_chan_map[] = {
- CPM_CR_CH_SMC1,
- CPM_CR_CH_SMC2
-};
-
-static ushort scc_chan_map[] = {
- CPM_CR_CH_SCC1,
- CPM_CR_CH_SCC2,
- CPM_CR_CH_SCC3,
- CPM_CR_CH_SCC4
-};
-
-static void begin_break(ser_info_t *info)
-{
- volatile QUICC *cp;
- ushort chan;
- int idx;
-
- cp = pquicc;
-
- idx = PORT_NUM(info->state->smc_scc_num);
- if (info->state->smc_scc_num & NUM_IS_SCC)
- chan = scc_chan_map[idx];
- else
- chan = smc_chan_map[idx];
-
- cp->cp_cr = mk_cr_cmd(chan, CPM_CR_STOP_TX) | CPM_CR_FLG;
- while (cp->cp_cr & CPM_CR_FLG);
-}
-
-static void end_break(ser_info_t *info)
-{
- volatile QUICC *cp;
- ushort chan;
- int idx;
-
- cp = pquicc;
-
- idx = PORT_NUM(info->state->smc_scc_num);
- if (info->state->smc_scc_num & NUM_IS_SCC)
- chan = scc_chan_map[idx];
- else
- chan = smc_chan_map[idx];
-
- cp->cp_cr = mk_cr_cmd(chan, CPM_CR_RESTART_TX) | CPM_CR_FLG;
- while (cp->cp_cr & CPM_CR_FLG);
-}
-
-/*
- * This routine sends a break character out the serial port.
- */
-static void send_break(ser_info_t *info, unsigned int duration)
-{
-#ifdef SERIAL_DEBUG_SEND_BREAK
- printk("rs_send_break(%d) jiff=%lu...", duration, jiffies);
-#endif
- begin_break(info);
- msleep_interruptible(duration);
- end_break(info);
-#ifdef SERIAL_DEBUG_SEND_BREAK
- printk("done jiffies=%lu\n", jiffies);
-#endif
-}
-
-
-/*
- * Get counter of input serial line interrupts (DCD,RI,DSR,CTS)
- * Return: write counters to the user passed counter struct
- * NB: both 1->0 and 0->1 transitions are counted except for
- * RI where only 0->1 is counted.
- */
-static int rs_360_get_icount(struct tty_struct *tty,
- struct serial_icounter_struct *icount)
-{
- ser_info_t *info = (ser_info_t *)tty->driver_data;
- struct async_icount cnow;
-
- local_irq_disable();
- cnow = info->state->icount;
- local_irq_enable();
-
- icount->cts = cnow.cts;
- icount->dsr = cnow.dsr;
- icount->rng = cnow.rng;
- icount->dcd = cnow.dcd;
-
- return 0;
-}
-
-static int rs_360_ioctl(struct tty_struct *tty,
- unsigned int cmd, unsigned long arg)
-{
- int error;
- ser_info_t *info = (ser_info_t *)tty->driver_data;
- int retval;
- struct async_icount cnow;
- /* struct async_icount_24 cnow;*/ /* kernel counter temps */
- struct serial_icounter_struct *p_cuser; /* user space */
-
- if (serial_paranoia_check(info, tty->name, "rs_ioctl"))
- return -ENODEV;
-
- if (cmd != TIOCMIWAIT) {
- if (tty->flags & (1 << TTY_IO_ERROR))
- return -EIO;
- }
-
- switch (cmd) {
- case TCSBRK: /* SVID version: non-zero arg --> no break */
- retval = tty_check_change(tty);
- if (retval)
- return retval;
- tty_wait_until_sent(tty, 0);
- if (signal_pending(current))
- return -EINTR;
- if (!arg) {
- send_break(info, 250); /* 1/4 second */
- if (signal_pending(current))
- return -EINTR;
- }
- return 0;
- case TCSBRKP: /* support for POSIX tcsendbreak() */
- retval = tty_check_change(tty);
- if (retval)
- return retval;
- tty_wait_until_sent(tty, 0);
- if (signal_pending(current))
- return -EINTR;
- send_break(info, arg ? arg*100 : 250);
- if (signal_pending(current))
- return -EINTR;
- return 0;
- case TIOCSBRK:
- retval = tty_check_change(tty);
- if (retval)
- return retval;
- tty_wait_until_sent(tty, 0);
- begin_break(info);
- return 0;
- case TIOCCBRK:
- retval = tty_check_change(tty);
- if (retval)
- return retval;
- end_break(info);
- return 0;
-#ifdef maybe
- case TIOCSERGETLSR: /* Get line status register */
- return get_lsr_info(info, (unsigned int *) arg);
-#endif
- /*
- * Wait for any of the 4 modem inputs (DCD,RI,DSR,CTS) to change
- * - mask passed in arg for lines of interest
- * (use |'ed TIOCM_RNG/DSR/CD/CTS for masking)
- * Caller should use TIOCGICOUNT to see which one it was
- */
- case TIOCMIWAIT:
-#ifdef modem_control
- local_irq_disable();
- /* note the counters on entry */
- cprev = info->state->icount;
- local_irq_enable();
- while (1) {
- interruptible_sleep_on(&info->delta_msr_wait);
- /* see if a signal did it */
- if (signal_pending(current))
- return -ERESTARTSYS;
- local_irq_disable();
- cnow = info->state->icount; /* atomic copy */
- local_irq_enable();
- if (cnow.rng == cprev.rng && cnow.dsr == cprev.dsr &&
- cnow.dcd == cprev.dcd && cnow.cts == cprev.cts)
- return -EIO; /* no change => error */
- if ( ((arg & TIOCM_RNG) && (cnow.rng != cprev.rng)) ||
- ((arg & TIOCM_DSR) && (cnow.dsr != cprev.dsr)) ||
- ((arg & TIOCM_CD) && (cnow.dcd != cprev.dcd)) ||
- ((arg & TIOCM_CTS) && (cnow.cts != cprev.cts)) ) {
- return 0;
- }
- cprev = cnow;
- }
- /* NOTREACHED */
-#else
- return 0;
-#endif
-
-
- default:
- return -ENOIOCTLCMD;
- }
- return 0;
-}
-
-/* FIX UP modem control here someday......
-*/
-static void rs_360_set_termios(struct tty_struct *tty, struct ktermios *old_termios)
-{
- ser_info_t *info = (ser_info_t *)tty->driver_data;
-
- change_speed(info);
-
-#ifdef modem_control
- /* Handle transition to B0 status */
- if ((old_termios->c_cflag & CBAUD) &&
- !(tty->termios->c_cflag & CBAUD)) {
- info->MCR &= ~(UART_MCR_DTR|UART_MCR_RTS);
- local_irq_disable();
- serial_out(info, UART_MCR, info->MCR);
- local_irq_enable();
- }
-
- /* Handle transition away from B0 status */
- if (!(old_termios->c_cflag & CBAUD) &&
- (tty->termios->c_cflag & CBAUD)) {
- info->MCR |= UART_MCR_DTR;
- if (!tty->hw_stopped ||
- !(tty->termios->c_cflag & CRTSCTS)) {
- info->MCR |= UART_MCR_RTS;
- }
- local_irq_disable();
- serial_out(info, UART_MCR, info->MCR);
- local_irq_enable();
- }
-
- /* Handle turning off CRTSCTS */
- if ((old_termios->c_cflag & CRTSCTS) &&
- !(tty->termios->c_cflag & CRTSCTS)) {
- tty->hw_stopped = 0;
- rs_360_start(tty);
- }
-#endif
-
-#if 0
- /*
- * No need to wake up processes in open wait, since they
- * sample the CLOCAL flag once, and don't recheck it.
- * XXX It's not clear whether the current behavior is correct
- * or not. Hence, this may change.....
- */
- if (!(old_termios->c_cflag & CLOCAL) &&
- (tty->termios->c_cflag & CLOCAL))
- wake_up_interruptible(&info->open_wait);
-#endif
-}
-
-/*
- * ------------------------------------------------------------
- * rs_close()
- *
- * This routine is called when the serial port gets closed. First, we
- * wait for the last remaining data to be sent. Then, we unlink its
- * async structure from the interrupt chain if necessary, and we free
- * that IRQ if nothing is left in the chain.
- * ------------------------------------------------------------
- */
-static void rs_360_close(struct tty_struct *tty, struct file * filp)
-{
- ser_info_t *info = (ser_info_t *)tty->driver_data;
- /* struct async_state *state; */
- struct serial_state *state;
- unsigned long flags;
- int idx;
- volatile struct smc_regs *smcp;
- volatile struct scc_regs *sccp;
-
- if (!info || serial_paranoia_check(info, tty->name, "rs_close"))
- return;
-
- state = info->state;
-
- local_irq_save(flags);
-
- if (tty_hung_up_p(filp)) {
- DBG_CNT("before DEC-hung");
- local_irq_restore(flags);
- return;
- }
-
-#ifdef SERIAL_DEBUG_OPEN
- printk("rs_close ttys%d, count = %d\n", info->line, state->count);
-#endif
- if ((tty->count == 1) && (state->count != 1)) {
- /*
- * Uh, oh. tty->count is 1, which means that the tty
- * structure will be freed. state->count should always
- * be one in these conditions. If it's greater than
- * one, we've got real problems, since it means the
- * serial port won't be shutdown.
- */
- printk("rs_close: bad serial port count; tty->count is 1, "
- "state->count is %d\n", state->count);
- state->count = 1;
- }
- if (--state->count < 0) {
- printk("rs_close: bad serial port count for ttys%d: %d\n",
- info->line, state->count);
- state->count = 0;
- }
- if (state->count) {
- DBG_CNT("before DEC-2");
- local_irq_restore(flags);
- return;
- }
- info->flags |= ASYNC_CLOSING;
- /*
- * Now we wait for the transmit buffer to clear; and we notify
- * the line discipline to only process XON/XOFF characters.
- */
- tty->closing = 1;
- if (info->closing_wait != ASYNC_CLOSING_WAIT_NONE)
- tty_wait_until_sent(tty, info->closing_wait);
- /*
- * At this point we stop accepting input. To do this, we
- * disable the receive line status interrupts, and tell the
- * interrupt driver to stop checking the data ready bit in the
- * line status register.
- */
- info->read_status_mask &= ~BD_SC_EMPTY;
- if (info->flags & ASYNC_INITIALIZED) {
-
- idx = PORT_NUM(info->state->smc_scc_num);
- if (info->state->smc_scc_num & NUM_IS_SCC) {
- sccp = &pquicc->scc_regs[idx];
- sccp->scc_sccm &= ~UART_SCCM_RX;
- sccp->scc_gsmr.w.low &= ~SCC_GSMRL_ENR;
- } else {
- smcp = &pquicc->smc_regs[idx];
- smcp->smc_smcm &= ~SMCM_RX;
- smcp->smc_smcmr &= ~SMCMR_REN;
- }
- /*
- * Before we drop DTR, make sure the UART transmitter
- * has completely drained; this is especially
- * important if there is a transmit FIFO!
- */
- rs_360_wait_until_sent(tty, info->timeout);
- }
- shutdown(info);
- rs_360_flush_buffer(tty);
- tty_ldisc_flush(tty);
- tty->closing = 0;
- info->event = 0;
- info->port.tty = NULL;
- if (info->blocked_open) {
- if (info->close_delay) {
- msleep_interruptible(jiffies_to_msecs(info->close_delay));
- }
- wake_up_interruptible(&info->open_wait);
- }
- info->flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING);
- wake_up_interruptible(&info->close_wait);
- local_irq_restore(flags);
-}
-
-/*
- * rs_wait_until_sent() --- wait until the transmitter is empty
- */
-static void rs_360_wait_until_sent(struct tty_struct *tty, int timeout)
-{
- ser_info_t *info = (ser_info_t *)tty->driver_data;
- unsigned long orig_jiffies, char_time;
- /*int lsr;*/
- volatile QUICC_BD *bdp;
-
- if (serial_paranoia_check(info, tty->name, "rs_wait_until_sent"))
- return;
-
-#ifdef maybe
- if (info->state->type == PORT_UNKNOWN)
- return;
-#endif
-
- orig_jiffies = jiffies;
- /*
- * Set the check interval to be 1/5 of the estimated time to
- * send a single character, and make it at least 1. The check
- * interval should also be less than the timeout.
- *
- * Note: we have to use pretty tight timings here to satisfy
- * the NIST-PCTS.
- */
- char_time = 1;
- if (timeout)
- char_time = min(char_time, (unsigned long)timeout);
-#ifdef SERIAL_DEBUG_RS_WAIT_UNTIL_SENT
- printk("In rs_wait_until_sent(%d) check=%lu...", timeout, char_time);
- printk("jiff=%lu...", jiffies);
-#endif
-
- /* We go through the loop at least once because we can't tell
- * exactly when the last character exits the shifter. There can
- * be at least two characters waiting to be sent after the buffers
- * are empty.
- */
- do {
-#ifdef SERIAL_DEBUG_RS_WAIT_UNTIL_SENT
- printk("lsr = %d (jiff=%lu)...", lsr, jiffies);
-#endif
-/* current->counter = 0; make us low-priority */
- msleep_interruptible(jiffies_to_msecs(char_time));
- if (signal_pending(current))
- break;
- if (timeout && (time_after(jiffies, orig_jiffies + timeout)))
- break;
- /* The 'tx_cur' is really the next buffer to send. We
- * have to back up to the previous BD and wait for it
- * to go. This isn't perfect, because all this indicates
- * is the buffer is available. There are still characters
- * in the CPM FIFO.
- */
- bdp = info->tx_cur;
- if (bdp == info->tx_bd_base)
- bdp += (TX_NUM_FIFO-1);
- else
- bdp--;
- } while (bdp->status & BD_SC_READY);
- current->state = TASK_RUNNING;
-#ifdef SERIAL_DEBUG_RS_WAIT_UNTIL_SENT
- printk("lsr = %d (jiff=%lu)...done\n", lsr, jiffies);
-#endif
-}
-
-/*
- * rs_hangup() --- called by tty_hangup() when a hangup is signaled.
- */
-static void rs_360_hangup(struct tty_struct *tty)
-{
- ser_info_t *info = (ser_info_t *)tty->driver_data;
- struct serial_state *state = info->state;
-
- if (serial_paranoia_check(info, tty->name, "rs_hangup"))
- return;
-
- state = info->state;
-
- rs_360_flush_buffer(tty);
- shutdown(info);
- info->event = 0;
- state->count = 0;
- info->flags &= ~ASYNC_NORMAL_ACTIVE;
- info->port.tty = NULL;
- wake_up_interruptible(&info->open_wait);
-}
-
-/*
- * ------------------------------------------------------------
- * rs_open() and friends
- * ------------------------------------------------------------
- */
-static int block_til_ready(struct tty_struct *tty, struct file * filp,
- ser_info_t *info)
-{
-#ifdef DO_THIS_LATER
- DECLARE_WAITQUEUE(wait, current);
-#endif
- struct serial_state *state = info->state;
- int retval;
- int do_clocal = 0;
-
- /*
- * If the device is in the middle of being closed, then block
- * until it's done, and then try again.
- */
- if (tty_hung_up_p(filp) ||
- (info->flags & ASYNC_CLOSING)) {
- if (info->flags & ASYNC_CLOSING)
- interruptible_sleep_on(&info->close_wait);
-#ifdef SERIAL_DO_RESTART
- if (info->flags & ASYNC_HUP_NOTIFY)
- return -EAGAIN;
- else
- return -ERESTARTSYS;
-#else
- return -EAGAIN;
-#endif
- }
-
- /*
- * If non-blocking mode is set, or the port is not enabled,
- * then make the check up front and then exit.
- * If this is an SMC port, we don't have modem control to wait
- * for, so just get out here.
- */
- if ((filp->f_flags & O_NONBLOCK) ||
- (tty->flags & (1 << TTY_IO_ERROR)) ||
- !(info->state->smc_scc_num & NUM_IS_SCC)) {
- info->flags |= ASYNC_NORMAL_ACTIVE;
- return 0;
- }
-
- if (tty->termios->c_cflag & CLOCAL)
- do_clocal = 1;
-
- /*
- * Block waiting for the carrier detect and the line to become
- * free (i.e., not in use by the callout). While we are in
- * this loop, state->count is dropped by one, so that
- * rs_close() knows when to free things. We restore it upon
- * exit, either normal or abnormal.
- */
- retval = 0;
-#ifdef DO_THIS_LATER
- add_wait_queue(&info->open_wait, &wait);
-#ifdef SERIAL_DEBUG_OPEN
- printk("block_til_ready before block: ttys%d, count = %d\n",
- state->line, state->count);
-#endif
- local_irq_disable();
- if (!tty_hung_up_p(filp))
- state->count--;
- local_irq_enable();
- info->blocked_open++;
- while (1) {
- local_irq_disable();
- if (tty->termios->c_cflag & CBAUD)
- serial_out(info, UART_MCR,
- serial_inp(info, UART_MCR) |
- (UART_MCR_DTR | UART_MCR_RTS));
- local_irq_enable();
- set_current_state(TASK_INTERRUPTIBLE);
- if (tty_hung_up_p(filp) ||
- !(info->flags & ASYNC_INITIALIZED)) {
-#ifdef SERIAL_DO_RESTART
- if (info->flags & ASYNC_HUP_NOTIFY)
- retval = -EAGAIN;
- else
- retval = -ERESTARTSYS;
-#else
- retval = -EAGAIN;
-#endif
- break;
- }
- if (!(info->flags & ASYNC_CLOSING) &&
- (do_clocal || (serial_in(info, UART_MSR) &
- UART_MSR_DCD)))
- break;
- if (signal_pending(current)) {
- retval = -ERESTARTSYS;
- break;
- }
-#ifdef SERIAL_DEBUG_OPEN
- printk("block_til_ready blocking: ttys%d, count = %d\n",
- info->line, state->count);
-#endif
- tty_unlock();
- schedule();
- tty_lock();
- }
- current->state = TASK_RUNNING;
- remove_wait_queue(&info->open_wait, &wait);
- if (!tty_hung_up_p(filp))
- state->count++;
- info->blocked_open--;
-#ifdef SERIAL_DEBUG_OPEN
- printk("block_til_ready after blocking: ttys%d, count = %d\n",
- info->line, state->count);
-#endif
-#endif /* DO_THIS_LATER */
- if (retval)
- return retval;
- info->flags |= ASYNC_NORMAL_ACTIVE;
- return 0;
-}
-
-static int get_async_struct(int line, ser_info_t **ret_info)
-{
- struct serial_state *sstate;
-
- sstate = rs_table + line;
- if (sstate->info) {
- sstate->count++;
- *ret_info = (ser_info_t *)sstate->info;
- return 0;
- }
- else {
- return -ENOMEM;
- }
-}
-
-/*
- * This routine is called whenever a serial port is opened. It
- * enables interrupts for a serial port, linking in its async structure into
- * the IRQ chain. It also performs the serial-specific
- * initialization for the tty structure.
- */
-static int rs_360_open(struct tty_struct *tty, struct file * filp)
-{
- ser_info_t *info;
- int retval, line;
-
- line = tty->index;
- if ((line < 0) || (line >= NR_PORTS))
- return -ENODEV;
- retval = get_async_struct(line, &info);
- if (retval)
- return retval;
- if (serial_paranoia_check(info, tty->name, "rs_open"))
- return -ENODEV;
-
-#ifdef SERIAL_DEBUG_OPEN
- printk("rs_open %s, count = %d\n", tty->name, info->state->count);
-#endif
- tty->driver_data = info;
- info->port.tty = tty;
-
- /*
- * Start up serial port
- */
- retval = startup(info);
- if (retval)
- return retval;
-
- retval = block_til_ready(tty, filp, info);
- if (retval) {
-#ifdef SERIAL_DEBUG_OPEN
- printk("rs_open returning after block_til_ready with %d\n",
- retval);
-#endif
- return retval;
- }
-
-#ifdef SERIAL_DEBUG_OPEN
- printk("rs_open %s successful...", tty->name);
-#endif
- return 0;
-}
-
-/*
- * /proc fs routines....
- */
-
-static inline int line_info(char *buf, struct serial_state *state)
-{
-#ifdef notdef
- struct async_struct *info = state->info, scr_info;
- char stat_buf[30], control, status;
-#endif
- int ret;
-
- ret = sprintf(buf, "%d: uart:%s port:%X irq:%d",
- state->line,
- (state->smc_scc_num & NUM_IS_SCC) ? "SCC" : "SMC",
- (unsigned int)(state->port), state->irq);
-
- if (!state->port || (state->type == PORT_UNKNOWN)) {
- ret += sprintf(buf+ret, "\n");
- return ret;
- }
-
-#ifdef notdef
- /*
- * Figure out the current RS-232 lines
- */
- if (!info) {
- info = &scr_info; /* This is just for serial_{in,out} */
-
- info->magic = SERIAL_MAGIC;
- info->port = state->port;
- info->flags = state->flags;
- info->quot = 0;
- info->port.tty = NULL;
- }
- local_irq_disable();
- status = serial_in(info, UART_MSR);
- control = info ? info->MCR : serial_in(info, UART_MCR);
- local_irq_enable();
-
- stat_buf[0] = 0;
- stat_buf[1] = 0;
- if (control & UART_MCR_RTS)
- strcat(stat_buf, "|RTS");
- if (status & UART_MSR_CTS)
- strcat(stat_buf, "|CTS");
- if (control & UART_MCR_DTR)
- strcat(stat_buf, "|DTR");
- if (status & UART_MSR_DSR)
- strcat(stat_buf, "|DSR");
- if (status & UART_MSR_DCD)
- strcat(stat_buf, "|CD");
- if (status & UART_MSR_RI)
- strcat(stat_buf, "|RI");
-
- if (info->quot) {
- ret += sprintf(buf+ret, " baud:%d",
- state->baud_base / info->quot);
- }
-
- ret += sprintf(buf+ret, " tx:%d rx:%d",
- state->icount.tx, state->icount.rx);
-
- if (state->icount.frame)
- ret += sprintf(buf+ret, " fe:%d", state->icount.frame);
-
- if (state->icount.parity)
- ret += sprintf(buf+ret, " pe:%d", state->icount.parity);
-
- if (state->icount.brk)
- ret += sprintf(buf+ret, " brk:%d", state->icount.brk);
-
- if (state->icount.overrun)
- ret += sprintf(buf+ret, " oe:%d", state->icount.overrun);
-
- /*
- * Last thing is the RS-232 status lines
- */
- ret += sprintf(buf+ret, " %s\n", stat_buf+1);
-#endif
- return ret;
-}
-
-int rs_360_read_proc(char *page, char **start, off_t off, int count,
- int *eof, void *data)
-{
- int i, len = 0;
- off_t begin = 0;
-
- len += sprintf(page, "serinfo:1.0 driver:%s\n", serial_version);
- for (i = 0; i < NR_PORTS && len < 4000; i++) {
- len += line_info(page + len, &rs_table[i]);
- if (len+begin > off+count)
- goto done;
- if (len+begin < off) {
- begin += len;
- len = 0;
- }
- }
- *eof = 1;
-done:
- if (off >= len+begin)
- return 0;
- *start = page + (begin-off);
- return ((count < begin+len-off) ? count : begin+len-off);
-}
-
-/*
- * ---------------------------------------------------------------------
- * rs_init() and friends
- *
- * rs_init() is called at boot-time to initialize the serial driver.
- * ---------------------------------------------------------------------
- */
-
-/*
- * This routine prints out the appropriate serial driver version
- * number, and identifies which options were configured into this
- * driver.
- */
-static _INLINE_ void show_serial_version(void)
-{
- printk(KERN_INFO "%s version %s\n", serial_name, serial_version);
-}
-
-
-/*
- * The serial console driver used during boot. Note that these names
- * clash with those found in "serial.c", so we currently can't support
- * the 16xxx uarts and these at the same time. I will fix this to become
- * an indirect function call from tty_io.c (or something).
- */
-
-#ifdef CONFIG_SERIAL_CONSOLE
-
-/*
- * Print a string to the serial port trying not to disturb any possible
- * real use of the port...
- */
-static void my_console_write(int idx, const char *s,
- unsigned count)
-{
- struct serial_state *ser;
- ser_info_t *info;
- unsigned i;
- QUICC_BD *bdp, *bdbase;
- volatile struct smc_uart_pram *up;
- volatile u_char *cp;
-
- ser = rs_table + idx;
-
-
- /* If the port has been initialized for general use, we have
- * to use the buffer descriptors allocated there. Otherwise,
- * we simply use the single buffer allocated.
- */
- if ((info = (ser_info_t *)ser->info) != NULL) {
- bdp = info->tx_cur;
- bdbase = info->tx_bd_base;
- }
- else {
- /* Pointer to UART in parameter ram.
- */
- /* up = (smc_uart_t *)&cpmp->cp_dparam[ser->port]; */
- up = &pquicc->pram[ser->port].scc.pothers.idma_smc.psmc.u;
-
- /* Get the address of the host memory buffer.
- */
- bdp = bdbase = (QUICC_BD *)((uint)pquicc + (uint)up->tbase);
- }
-
- /*
- * We need to gracefully shut down the transmitter, disable
- * interrupts, then send our bytes out.
- */
-
- /*
- * Now, do each character. This is not as bad as it looks
- * since this is a holding FIFO and not a transmitting FIFO.
- * We could add the complexity of filling the entire transmit
- * buffer, but we would just wait longer between accesses......
- */
- for (i = 0; i < count; i++, s++) {
- /* Wait for transmitter fifo to empty.
- * Ready indicates output is ready, and xmt is doing
- * that, not that it is ready for us to send.
- */
- while (bdp->status & BD_SC_READY);
-
- /* Send the character out.
- */
- cp = bdp->buf;
- *cp = *s;
-
- bdp->length = 1;
- bdp->status |= BD_SC_READY;
-
- if (bdp->status & BD_SC_WRAP)
- bdp = bdbase;
- else
- bdp++;
-
- /* if a LF, also do CR... */
- if (*s == 10) {
- while (bdp->status & BD_SC_READY);
- /* cp = __va(bdp->buf); */
- cp = bdp->buf;
- *cp = 13;
- bdp->length = 1;
- bdp->status |= BD_SC_READY;
-
- if (bdp->status & BD_SC_WRAP) {
- bdp = bdbase;
- }
- else {
- bdp++;
- }
- }
- }
-
- /*
- * Finally, Wait for transmitter & holding register to empty
- * and restore the IER
- */
- while (bdp->status & BD_SC_READY);
-
- if (info)
- info->tx_cur = (QUICC_BD *)bdp;
-}
-
-static void serial_console_write(struct console *c, const char *s,
- unsigned count)
-{
-#ifdef CONFIG_KGDB
- /* Try to let stub handle output. Returns true if it did. */
- if (kgdb_output_string(s, count))
- return;
-#endif
- my_console_write(c->index, s, count);
-}
-
-
-
-/*void console_print_68360(const char *p)
-{
- const char *cp = p;
- int i;
-
- for (i=0;cp[i]!=0;i++);
-
- serial_console_write (p, i);
-
- //Comment this if you want to have a strict interrupt-driven output
- //rs_fair_output();
-
- return;
-}*/
-
-
-
-
-
-
-#ifdef CONFIG_XMON
-int
-xmon_360_write(const char *s, unsigned count)
-{
- my_console_write(0, s, count);
- return(count);
-}
-#endif
-
-#ifdef CONFIG_KGDB
-void
-putDebugChar(char ch)
-{
- my_console_write(0, &ch, 1);
-}
-#endif
-
-/*
- * Receive character from the serial port. This only works well
- * before the port is initialized for real use.
- */
-static int my_console_wait_key(int idx, int xmon, char *obuf)
-{
- struct serial_state *ser;
- u_char c, *cp;
- ser_info_t *info;
- QUICC_BD *bdp;
- volatile struct smc_uart_pram *up;
- int i;
-
- ser = rs_table + idx;
-
- /* Get the address of the host memory buffer.
- * If the port has been initialized for general use, we must
- * use information from the port structure.
- */
- if ((info = (ser_info_t *)ser->info))
- bdp = info->rx_cur;
- else
- /* bdp = (QUICC_BD *)&cpmp->cp_dpmem[up->smc_rbase]; */
- bdp = (QUICC_BD *)((uint)pquicc + (uint)up->tbase);
-
- /* Pointer to UART in parameter ram.
- */
- /* up = (smc_uart_t *)&cpmp->cp_dparam[ser->port]; */
- up = &pquicc->pram[info->state->port].scc.pothers.idma_smc.psmc.u;
-
- /*
- * We need to gracefully shut down the receiver, disable
- * interrupts, then read the input.
- * XMON just wants a poll. If no character, return -1, else
- * return the character.
- */
- if (!xmon) {
- while (bdp->status & BD_SC_EMPTY);
- }
- else {
- if (bdp->status & BD_SC_EMPTY)
- return -1;
- }
-
- cp = (char *)bdp->buf;
-
- if (obuf) {
- i = c = bdp->length;
- while (i-- > 0)
- *obuf++ = *cp++;
- }
- else {
- c = *cp;
- }
- bdp->status |= BD_SC_EMPTY;
-
- if (info) {
- if (bdp->status & BD_SC_WRAP) {
- bdp = info->rx_bd_base;
- }
- else {
- bdp++;
- }
- info->rx_cur = (QUICC_BD *)bdp;
- }
-
- return((int)c);
-}
-
-static int serial_console_wait_key(struct console *co)
-{
- return(my_console_wait_key(co->index, 0, NULL));
-}
-
-#ifdef CONFIG_XMON
-int
-xmon_360_read_poll(void)
-{
- return(my_console_wait_key(0, 1, NULL));
-}
-
-int
-xmon_360_read_char(void)
-{
- return(my_console_wait_key(0, 0, NULL));
-}
-#endif
-
-#ifdef CONFIG_KGDB
-static char kgdb_buf[RX_BUF_SIZE], *kgdp;
-static int kgdb_chars;
-
-unsigned char
-getDebugChar(void)
-{
- if (kgdb_chars <= 0) {
- kgdb_chars = my_console_wait_key(0, 0, kgdb_buf);
- kgdp = kgdb_buf;
- }
- kgdb_chars--;
-
- return(*kgdp++);
-}
-
-void kgdb_interruptible(int state)
-{
-}
-void kgdb_map_scc(void)
-{
- struct serial_state *ser;
- uint mem_addr;
- volatile QUICC_BD *bdp;
- volatile smc_uart_t *up;
-
- cpmp = (cpm360_t *)&(((immap_t *)IMAP_ADDR)->im_cpm);
-
- /* To avoid data cache CPM DMA coherency problems, allocate a
- * buffer in the CPM DPRAM. This will work until the CPM and
- * serial ports are initialized. At that time a memory buffer
- * will be allocated.
- * The port is already initialized from the boot procedure, all
- * we do here is give it a different buffer and make it a FIFO.
- */
-
- ser = rs_table;
-
- /* Right now, assume we are using SMCs.
- */
- up = (smc_uart_t *)&cpmp->cp_dparam[ser->port];
-
- /* Allocate space for an input FIFO, plus a few bytes for output.
- * Allocate bytes to maintain word alignment.
- */
- mem_addr = (uint)(&cpmp->cp_dpmem[0x1000]);
-
- /* Set the physical address of the host memory buffers in
- * the buffer descriptors.
- */
- bdp = (QUICC_BD *)&cpmp->cp_dpmem[up->smc_rbase];
- bdp->buf = mem_addr;
-
- bdp = (QUICC_BD *)&cpmp->cp_dpmem[up->smc_tbase];
- bdp->buf = mem_addr+RX_BUF_SIZE;
-
- up->smc_mrblr = RX_BUF_SIZE; /* receive buffer length */
- up->smc_maxidl = RX_BUF_SIZE;
-}
-#endif
-
-static struct tty_struct *serial_console_device(struct console *c, int *index)
-{
- *index = c->index;
- return serial_driver;
-}
-
-
-struct console sercons = {
- .name = "ttyS",
- .write = serial_console_write,
- .device = serial_console_device,
- .wait_key = serial_console_wait_key,
- .setup = serial_console_setup,
- .flags = CON_PRINTBUFFER,
- .index = CONFIG_SERIAL_CONSOLE_PORT,
-};
-
-
-
-/*
- * Register console.
- */
-long console_360_init(long kmem_start, long kmem_end)
-{
- register_console(&sercons);
- /*register_console (console_print_68360); - 2.0.38 only required a write
- function pointer. */
- return kmem_start;
-}
-
-#endif
-
-/* Index in baud rate table of the default console baud rate.
-*/
-static int baud_idx;
-
-static const struct tty_operations rs_360_ops = {
- .owner = THIS_MODULE,
- .open = rs_360_open,
- .close = rs_360_close,
- .write = rs_360_write,
- .put_char = rs_360_put_char,
- .write_room = rs_360_write_room,
- .chars_in_buffer = rs_360_chars_in_buffer,
- .flush_buffer = rs_360_flush_buffer,
- .ioctl = rs_360_ioctl,
- .throttle = rs_360_throttle,
- .unthrottle = rs_360_unthrottle,
- /* .send_xchar = rs_360_send_xchar, */
- .set_termios = rs_360_set_termios,
- .stop = rs_360_stop,
- .start = rs_360_start,
- .hangup = rs_360_hangup,
- /* .wait_until_sent = rs_360_wait_until_sent, */
- /* .read_proc = rs_360_read_proc, */
- .tiocmget = rs_360_tiocmget,
- .tiocmset = rs_360_tiocmset,
- .get_icount = rs_360_get_icount,
-};
-
-static int __init rs_360_init(void)
-{
- struct serial_state * state;
- ser_info_t *info;
- void *mem_addr;
- uint dp_addr, iobits;
- int i, j, idx;
- ushort chan;
- QUICC_BD *bdp;
- volatile QUICC *cp;
- volatile struct smc_regs *sp;
- volatile struct smc_uart_pram *up;
- volatile struct scc_regs *scp;
- volatile struct uart_pram *sup;
- /* volatile immap_t *immap; */
-
- serial_driver = alloc_tty_driver(NR_PORTS);
- if (!serial_driver)
- return -1;
-
- show_serial_version();
-
- serial_driver->name = "ttyS";
- serial_driver->major = TTY_MAJOR;
- serial_driver->minor_start = 64;
- serial_driver->type = TTY_DRIVER_TYPE_SERIAL;
- serial_driver->subtype = SERIAL_TYPE_NORMAL;
- serial_driver->init_termios = tty_std_termios;
- serial_driver->init_termios.c_cflag =
- baud_idx | CS8 | CREAD | HUPCL | CLOCAL;
- serial_driver->flags = TTY_DRIVER_REAL_RAW;
- tty_set_operations(serial_driver, &rs_360_ops);
-
- if (tty_register_driver(serial_driver))
- panic("Couldn't register serial driver\n");
-
- cp = pquicc; /* Get pointer to Communication Processor */
- /* immap = (immap_t *)IMAP_ADDR; */ /* and to internal registers */
-
-
- /* Configure SCC2, SCC3, and SCC4 instead of port A parallel I/O.
- */
- /* The "standard" configuration through the 860.
- */
-/* immap->im_ioport.iop_papar |= 0x00fc; */
-/* immap->im_ioport.iop_padir &= ~0x00fc; */
-/* immap->im_ioport.iop_paodr &= ~0x00fc; */
- cp->pio_papar |= 0x00fc;
- cp->pio_padir &= ~0x00fc;
- /* cp->pio_paodr &= ~0x00fc; */
-
-
- /* Since we don't yet do modem control, connect the port C pins
- * as general purpose I/O. This will assert CTS and CD for the
- * SCC ports.
- */
- /* FIXME: see 360um p.7-365 and 860um p.34-12
- * I can't make sense of these bits - mleslie*/
-/* immap->im_ioport.iop_pcdir |= 0x03c6; */
-/* immap->im_ioport.iop_pcpar &= ~0x03c6; */
-
-/* cp->pio_pcdir |= 0x03c6; */
-/* cp->pio_pcpar &= ~0x03c6; */
-
-
-
- /* Connect SCC2 and SCC3 to NMSI. Connect BRG3 to SCC2 and
- * BRG4 to SCC3.
- */
- cp->si_sicr &= ~0x00ffff00;
- cp->si_sicr |= 0x001b1200;
-
-#ifdef CONFIG_PP04
- /* Frequentis PP04 forced to RS-232 until we know better.
- * Port C 12 and 13 low enables RS-232 on SCC3 and SCC4.
- */
- immap->im_ioport.iop_pcdir |= 0x000c;
- immap->im_ioport.iop_pcpar &= ~0x000c;
- immap->im_ioport.iop_pcdat &= ~0x000c;
-
- /* This enables the TX driver.
- */
- cp->cp_pbpar &= ~0x6000;
- cp->cp_pbdat &= ~0x6000;
-#endif
-
- for (i = 0, state = rs_table; i < NR_PORTS; i++,state++) {
- state->magic = SSTATE_MAGIC;
- state->line = i;
- state->type = PORT_UNKNOWN;
- state->custom_divisor = 0;
- state->close_delay = 5*HZ/10;
- state->closing_wait = 30*HZ;
- state->icount.cts = state->icount.dsr =
- state->icount.rng = state->icount.dcd = 0;
- state->icount.rx = state->icount.tx = 0;
- state->icount.frame = state->icount.parity = 0;
- state->icount.overrun = state->icount.brk = 0;
- printk(KERN_INFO "ttyS%d at irq 0x%02x is an %s\n",
- i, (unsigned int)(state->irq),
- (state->smc_scc_num & NUM_IS_SCC) ? "SCC" : "SMC");
-
-#ifdef CONFIG_SERIAL_CONSOLE
- /* If we just printed the message on the console port, and
- * we are about to initialize it for general use, we have
- * to wait a couple of character times for the CR/NL to
- * make it out of the transmit buffer.
- */
- if (i == CONFIG_SERIAL_CONSOLE_PORT)
- mdelay(8);
-
-
-/* idx = PORT_NUM(info->state->smc_scc_num); */
-/* if (info->state->smc_scc_num & NUM_IS_SCC) */
-/* chan = scc_chan_map[idx]; */
-/* else */
-/* chan = smc_chan_map[idx]; */
-
-/* cp->cp_cr = mk_cr_cmd(chan, CPM_CR_STOP_TX) | CPM_CR_FLG; */
-/* while (cp->cp_cr & CPM_CR_FLG); */
-
-#endif
- /* info = kmalloc(sizeof(ser_info_t), GFP_KERNEL); */
- info = &quicc_ser_info[i];
- if (info) {
- memset (info, 0, sizeof(ser_info_t));
- info->magic = SERIAL_MAGIC;
- info->line = i;
- info->flags = state->flags;
- INIT_WORK(&info->tqueue, do_softint, info);
- INIT_WORK(&info->tqueue_hangup, do_serial_hangup, info);
- init_waitqueue_head(&info->open_wait);
- init_waitqueue_head(&info->close_wait);
- info->state = state;
- state->info = (struct async_struct *)info;
-
- /* We need to allocate a transmit and receive buffer
- * descriptors from dual port ram, and a character
- * buffer area from host mem.
- */
- dp_addr = m360_cpm_dpalloc(sizeof(QUICC_BD) * RX_NUM_FIFO);
-
- /* Allocate space for FIFOs in the host memory.
- * (for now this is from a static array of buffers :(
- */
- /* mem_addr = m360_cpm_hostalloc(RX_NUM_FIFO * RX_BUF_SIZE); */
- /* mem_addr = kmalloc (RX_NUM_FIFO * RX_BUF_SIZE, GFP_BUFFER); */
- mem_addr = &rx_buf_pool[i * RX_NUM_FIFO * RX_BUF_SIZE];
-
- /* Set the physical address of the host memory
- * buffers in the buffer descriptors, and the
- * virtual address for us to work with.
- */
- bdp = (QUICC_BD *)((uint)pquicc + dp_addr);
- info->rx_cur = info->rx_bd_base = bdp;
-
- /* initialize rx buffer descriptors */
- for (j=0; j<(RX_NUM_FIFO-1); j++) {
- bdp->buf = &rx_buf_pool[(i * RX_NUM_FIFO + j ) * RX_BUF_SIZE];
- bdp->status = BD_SC_EMPTY | BD_SC_INTRPT;
- mem_addr += RX_BUF_SIZE;
- bdp++;
- }
- bdp->buf = &rx_buf_pool[(i * RX_NUM_FIFO + j ) * RX_BUF_SIZE];
- bdp->status = BD_SC_WRAP | BD_SC_EMPTY | BD_SC_INTRPT;
-
-
- idx = PORT_NUM(info->state->smc_scc_num);
- if (info->state->smc_scc_num & NUM_IS_SCC) {
-
-#if defined (CONFIG_UCQUICC) && 1
- /* set the transceiver mode to RS232 */
- sipex_mode_bits &= ~(uint)SIPEX_MODE(idx,0x0f); /* clear current mode */
- sipex_mode_bits |= (uint)SIPEX_MODE(idx,0x02);
- *(uint *)_periph_base = sipex_mode_bits;
- /* printk ("sipex bits = 0x%08x\n", sipex_mode_bits); */
-#endif
- }
-
- dp_addr = m360_cpm_dpalloc(sizeof(QUICC_BD) * TX_NUM_FIFO);
-
- /* Allocate space for FIFOs in the host memory.
- */
- /* mem_addr = m360_cpm_hostalloc(TX_NUM_FIFO * TX_BUF_SIZE); */
- /* mem_addr = kmalloc (TX_NUM_FIFO * TX_BUF_SIZE, GFP_BUFFER); */
- mem_addr = &tx_buf_pool[i * TX_NUM_FIFO * TX_BUF_SIZE];
-
- /* Set the physical address of the host memory
- * buffers in the buffer descriptors, and the
- * virtual address for us to work with.
- */
- /* bdp = (QUICC_BD *)&cp->cp_dpmem[dp_addr]; */
- bdp = (QUICC_BD *)((uint)pquicc + dp_addr);
- info->tx_cur = info->tx_bd_base = (QUICC_BD *)bdp;
-
- /* initialize tx buffer descriptors */
- for (j=0; j<(TX_NUM_FIFO-1); j++) {
- bdp->buf = &tx_buf_pool[(i * TX_NUM_FIFO + j ) * TX_BUF_SIZE];
- bdp->status = BD_SC_INTRPT;
- mem_addr += TX_BUF_SIZE;
- bdp++;
- }
- bdp->buf = &tx_buf_pool[(i * TX_NUM_FIFO + j ) * TX_BUF_SIZE];
- bdp->status = (BD_SC_WRAP | BD_SC_INTRPT);
-
- if (info->state->smc_scc_num & NUM_IS_SCC) {
- scp = &pquicc->scc_regs[idx];
- sup = &pquicc->pram[info->state->port].scc.pscc.u;
- sup->rbase = dp_addr;
- sup->tbase = dp_addr;
-
- /* Set up the uart parameters in the
- * parameter ram.
- */
- sup->rfcr = SMC_EB;
- sup->tfcr = SMC_EB;
-
- /* Set this to 1 for now, so we get single
- * character interrupts. Using idle character
- * time requires some additional tuning.
- */
- sup->mrblr = 1;
- sup->max_idl = 0;
- sup->brkcr = 1;
- sup->parec = 0;
- sup->frmer = 0;
- sup->nosec = 0;
- sup->brkec = 0;
- sup->uaddr1 = 0;
- sup->uaddr2 = 0;
- sup->toseq = 0;
- {
- int i;
- for (i=0;i<8;i++)
- sup->cc[i] = 0x8000;
- }
- sup->rccm = 0xc0ff;
-
- /* Send the CPM an initialize command.
- */
- chan = scc_chan_map[idx];
-
- /* execute the INIT RX & TX PARAMS command for this channel. */
- cp->cp_cr = mk_cr_cmd(chan, CPM_CR_INIT_TRX) | CPM_CR_FLG;
- while (cp->cp_cr & CPM_CR_FLG);
-
- /* Set UART mode, 8 bit, no parity, one stop.
- * Enable receive and transmit.
- */
- scp->scc_gsmr.w.high = 0;
- scp->scc_gsmr.w.low =
- (SCC_GSMRL_MODE_UART | SCC_GSMRL_TDCR_16 | SCC_GSMRL_RDCR_16);
-
- /* Disable all interrupts and clear all pending
- * events.
- */
- scp->scc_sccm = 0;
- scp->scc_scce = 0xffff;
- scp->scc_dsr = 0x7e7e;
- scp->scc_psmr = 0x3000;
-
- /* If the port is the console, enable Rx and Tx.
- */
-#ifdef CONFIG_SERIAL_CONSOLE
- if (i == CONFIG_SERIAL_CONSOLE_PORT)
- scp->scc_gsmr.w.low |= (SCC_GSMRL_ENR | SCC_GSMRL_ENT);
-#endif
- }
- else {
- /* Configure SMCs Tx/Rx instead of port B
- * parallel I/O.
- */
- up = &pquicc->pram[info->state->port].scc.pothers.idma_smc.psmc.u;
- up->rbase = dp_addr;
-
- iobits = 0xc0 << (idx * 4);
- cp->pip_pbpar |= iobits;
- cp->pip_pbdir &= ~iobits;
- cp->pip_pbodr &= ~iobits;
-
-
- /* Connect the baud rate generator to the
- * SMC based upon index in rs_table. Also
- * make sure it is connected to NMSI.
- */
- cp->si_simode &= ~(0xffff << (idx * 16));
- cp->si_simode |= (i << ((idx * 16) + 12));
-
- up->tbase = dp_addr;
-
- /* Set up the uart parameters in the
- * parameter ram.
- */
- up->rfcr = SMC_EB;
- up->tfcr = SMC_EB;
-
- /* Set this to 1 for now, so we get single
- * character interrupts. Using idle character
- * time requires some additional tuning.
- */
- up->mrblr = 1;
- up->max_idl = 0;
- up->brkcr = 1;
-
- /* Send the CPM an initialize command.
- */
- chan = smc_chan_map[idx];
-
- cp->cp_cr = mk_cr_cmd(chan,
- CPM_CR_INIT_TRX) | CPM_CR_FLG;
-#ifdef CONFIG_SERIAL_CONSOLE
- if (i == CONFIG_SERIAL_CONSOLE_PORT)
- printk("");
-#endif
- while (cp->cp_cr & CPM_CR_FLG);
-
- /* Set UART mode, 8 bit, no parity, one stop.
- * Enable receive and transmit.
- */
- sp = &cp->smc_regs[idx];
- sp->smc_smcmr = smcr_mk_clen(9) | SMCMR_SM_UART;
-
- /* Disable all interrupts and clear all pending
- * events.
- */
- sp->smc_smcm = 0;
- sp->smc_smce = 0xff;
-
- /* If the port is the console, enable Rx and Tx.
- */
-#ifdef CONFIG_SERIAL_CONSOLE
- if (i == CONFIG_SERIAL_CONSOLE_PORT)
- sp->smc_smcmr |= SMCMR_REN | SMCMR_TEN;
-#endif
- }
-
- /* Install interrupt handler.
- */
- /* cpm_install_handler(IRQ_MACHSPEC | state->irq, rs_360_interrupt, info); */
- /*request_irq(IRQ_MACHSPEC | state->irq, rs_360_interrupt, */
- request_irq(state->irq, rs_360_interrupt, 0, "ttyS",
- (void *)info);
-
- /* Set up the baud rate generator.
- */
- m360_cpm_setbrg(i, baud_table[baud_idx]);
-
- }
- }
-
- return 0;
-}
-module_init(rs_360_init);
-
-/* This must always be called before the rs_360_init() function, otherwise
- * it blows away the port control information.
- */
-//static int __init serial_console_setup( struct console *co, char *options)
-int serial_console_setup( struct console *co, char *options)
-{
- struct serial_state *ser;
- uint mem_addr, dp_addr, bidx, idx, iobits;
- ushort chan;
- QUICC_BD *bdp;
- volatile QUICC *cp;
- volatile struct smc_regs *sp;
- volatile struct scc_regs *scp;
- volatile struct smc_uart_pram *up;
- volatile struct uart_pram *sup;
-
-/* mleslie TODO:
- * add something to the 68k bootloader to store a desired initial console baud rate */
-
-/* bd_t *bd; */ /* a board info struct used by EPPC-bug */
-/* bd = (bd_t *)__res; */
-
- for (bidx = 0; bidx < (sizeof(baud_table) / sizeof(int)); bidx++)
- /* if (bd->bi_baudrate == baud_table[bidx]) */
- if (CONSOLE_BAUDRATE == baud_table[bidx])
- break;
-
- /* co->cflag = CREAD|CLOCAL|bidx|CS8; */
- baud_idx = bidx;
-
- ser = rs_table + CONFIG_SERIAL_CONSOLE_PORT;
-
- cp = pquicc; /* Get pointer to Communication Processor */
-
- idx = PORT_NUM(ser->smc_scc_num);
- if (ser->smc_scc_num & NUM_IS_SCC) {
-
- /* TODO: need to set up SCC pin assignment etc. here */
-
- }
- else {
- iobits = 0xc0 << (idx * 4);
- cp->pip_pbpar |= iobits;
- cp->pip_pbdir &= ~iobits;
- cp->pip_pbodr &= ~iobits;
-
- /* Connect the baud rate generator to the
- * SMC based upon index in rs_table. Also
- * make sure it is connected to NMSI.
- */
- cp->si_simode &= ~(0xffff << (idx * 16));
- cp->si_simode |= (idx << ((idx * 16) + 12));
- }
-
- /* When we get here, the CPM has been reset, so we need
- * to configure the port.
- * We need to allocate a transmit and receive buffer descriptor
- * from dual port ram, and a character buffer area from host mem.
- */
-
- /* Allocate space for two buffer descriptors in the DP ram.
- */
- dp_addr = m360_cpm_dpalloc(sizeof(QUICC_BD) * CONSOLE_NUM_FIFO);
-
- /* Allocate space for two 2 byte FIFOs in the host memory.
- */
- /* mem_addr = m360_cpm_hostalloc(8); */
- mem_addr = (uint)console_fifos;
-
-
- /* Set the physical address of the host memory buffers in
- * the buffer descriptors.
- */
- /* bdp = (QUICC_BD *)&cp->cp_dpmem[dp_addr]; */
- bdp = (QUICC_BD *)((uint)pquicc + dp_addr);
- bdp->buf = (char *)mem_addr;
- (bdp+1)->buf = (char *)(mem_addr+4);
-
- /* For the receive, set empty and wrap.
- * For transmit, set wrap.
- */
- bdp->status = BD_SC_EMPTY | BD_SC_WRAP;
- (bdp+1)->status = BD_SC_WRAP;
-
- /* Set up the uart parameters in the parameter ram.
- */
- if (ser->smc_scc_num & NUM_IS_SCC) {
- scp = &cp->scc_regs[idx];
- /* sup = (scc_uart_t *)&cp->cp_dparam[ser->port]; */
- sup = &pquicc->pram[ser->port].scc.pscc.u;
-
- sup->rbase = dp_addr;
- sup->tbase = dp_addr + sizeof(QUICC_BD);
-
- /* Set up the uart parameters in the
- * parameter ram.
- */
- sup->rfcr = SMC_EB;
- sup->tfcr = SMC_EB;
-
- /* Set this to 1 for now, so we get single
- * character interrupts. Using idle character
- * time requires some additional tuning.
- */
- sup->mrblr = 1;
- sup->max_idl = 0;
- sup->brkcr = 1;
- sup->parec = 0;
- sup->frmer = 0;
- sup->nosec = 0;
- sup->brkec = 0;
- sup->uaddr1 = 0;
- sup->uaddr2 = 0;
- sup->toseq = 0;
- {
- int i;
- for (i=0;i<8;i++)
- sup->cc[i] = 0x8000;
- }
- sup->rccm = 0xc0ff;
-
- /* Send the CPM an initialize command.
- */
- chan = scc_chan_map[idx];
-
- cp->cp_cr = mk_cr_cmd(chan, CPM_CR_INIT_TRX) | CPM_CR_FLG;
- while (cp->cp_cr & CPM_CR_FLG);
-
- /* Set UART mode, 8 bit, no parity, one stop.
- * Enable receive and transmit.
- */
- scp->scc_gsmr.w.high = 0;
- scp->scc_gsmr.w.low =
- (SCC_GSMRL_MODE_UART | SCC_GSMRL_TDCR_16 | SCC_GSMRL_RDCR_16);
-
- /* Disable all interrupts and clear all pending
- * events.
- */
- scp->scc_sccm = 0;
- scp->scc_scce = 0xffff;
- scp->scc_dsr = 0x7e7e;
- scp->scc_psmr = 0x3000;
-
- scp->scc_gsmr.w.low |= (SCC_GSMRL_ENR | SCC_GSMRL_ENT);
-
- }
- else {
- /* up = (smc_uart_t *)&cp->cp_dparam[ser->port]; */
- up = &pquicc->pram[ser->port].scc.pothers.idma_smc.psmc.u;
-
- up->rbase = dp_addr; /* Base of receive buffer desc. */
- up->tbase = dp_addr+sizeof(QUICC_BD); /* Base of xmt buffer desc. */
- up->rfcr = SMC_EB;
- up->tfcr = SMC_EB;
-
- /* Set this to 1 for now, so we get single character interrupts.
- */
- up->mrblr = 1; /* receive buffer length */
- up->max_idl = 0; /* wait forever for next char */
-
- /* Send the CPM an initialize command.
- */
- chan = smc_chan_map[idx];
- cp->cp_cr = mk_cr_cmd(chan, CPM_CR_INIT_TRX) | CPM_CR_FLG;
- while (cp->cp_cr & CPM_CR_FLG);
-
- /* Set UART mode, 8 bit, no parity, one stop.
- * Enable receive and transmit.
- */
- sp = &cp->smc_regs[idx];
- sp->smc_smcmr = smcr_mk_clen(9) | SMCMR_SM_UART;
-
- /* And finally, enable Rx and Tx.
- */
- sp->smc_smcmr |= SMCMR_REN | SMCMR_TEN;
- }
-
- /* Set up the baud rate generator.
- */
- /* m360_cpm_setbrg((ser - rs_table), bd->bi_baudrate); */
- m360_cpm_setbrg((ser - rs_table), CONSOLE_BAUDRATE);
-
- return 0;
-}
-
-/*
- * Local variables:
- * c-indent-level: 4
- * c-basic-offset: 4
- * tab-width: 4
- * End:
- */
diff --git a/drivers/staging/serial/Kconfig b/drivers/staging/serial/Kconfig
deleted file mode 100644
index 9489688397e0..000000000000
--- a/drivers/staging/serial/Kconfig
+++ /dev/null
@@ -1,16 +0,0 @@
-config SERIAL_68360_SMC
- bool "68360 SMC uart support"
- depends on M68360
- help
- This driver supports the SMC serial ports of the Motorola 68360 CPU.
-
-config SERIAL_68360_SCC
- bool "68360 SCC uart support"
- depends on M68360
- help
- This driver supports the SCC serial ports of the Motorola 68360 CPU.
-
-config SERIAL_68360
- bool
- depends on SERIAL_68360_SMC || SERIAL_68360_SCC
- default y
diff --git a/drivers/staging/serial/Makefile b/drivers/staging/serial/Makefile
deleted file mode 100644
index 37a6a0b35fba..000000000000
--- a/drivers/staging/serial/Makefile
+++ /dev/null
@@ -1 +0,0 @@
-obj-$(CONFIG_SERIAL_68360) += 68360serial.o
diff --git a/drivers/staging/serial/TODO b/drivers/staging/serial/TODO
deleted file mode 100644
index a19cda81dab4..000000000000
--- a/drivers/staging/serial/TODO
+++ /dev/null
@@ -1,6 +0,0 @@
-These are a few serial drivers that either do not build, or do not work if they
-do build, or if they seem to work, are for obsolete hardware, or are full of
-unfixable races and no one uses them anymore.
-
-If no one steps up to adopt any of these drivers, they will be removed
-in the 3.4 release.
diff --git a/drivers/staging/serqt_usb2/serqt_usb2.c b/drivers/staging/serqt_usb2/serqt_usb2.c
index ae1d815e2a53..8a362f7af379 100644
--- a/drivers/staging/serqt_usb2/serqt_usb2.c
+++ b/drivers/staging/serqt_usb2/serqt_usb2.c
@@ -41,13 +41,6 @@ static bool debug;
#define QUATECH_HSU200B 0xC0B1 /* HSU200B */
#define QUATECH_HSU200C 0xC0B2 /* HSU200C */
#define QUATECH_HSU200D 0xC0B3 /* HSU200D */
-#define QUATECH_SSU100_2 0xC120 /* SSU100_2 */
-#define QUATECH_DSU100_2 0xC140 /* DSU100_2 */
-#define QUATECH_DSU400_2 0xC150 /* DSU400_2 */
-#define QUATECH_QSU100_2 0xC160 /* QSU100_2 */
-#define QUATECH_QSU400_2 0xC170 /* QSU400_2 */
-#define QUATECH_ESU400_2 0xC180 /* ESU400_2 */
-#define QUATECH_ESU100_2 0xC1A0 /* ESU100_2 */
#define QT_SET_GET_DEVICE 0xc2
#define QT_OPEN_CLOSE_CHANNEL 0xca
@@ -125,7 +118,7 @@ static bool debug;
#define MODEM_CTRL 0x40
#define RS232_MODE 0x00
-static const struct usb_device_id serqt_id_table[] = {
+static const struct usb_device_id id_table[] = {
{USB_DEVICE(USB_VENDOR_ID_QUATECH, QUATECH_SSU200)},
{USB_DEVICE(USB_VENDOR_ID_QUATECH, QUATECH_DSU100)},
{USB_DEVICE(USB_VENDOR_ID_QUATECH, QUATECH_DSU200)},
@@ -143,17 +136,9 @@ static const struct usb_device_id serqt_id_table[] = {
{USB_DEVICE(USB_VENDOR_ID_QUATECH, QUATECH_HSU200B)},
{USB_DEVICE(USB_VENDOR_ID_QUATECH, QUATECH_HSU200C)},
{USB_DEVICE(USB_VENDOR_ID_QUATECH, QUATECH_HSU200D)},
- {USB_DEVICE(USB_VENDOR_ID_QUATECH, QUATECH_SSU100_2)},
- {USB_DEVICE(USB_VENDOR_ID_QUATECH, QUATECH_DSU100_2)},
- {USB_DEVICE(USB_VENDOR_ID_QUATECH, QUATECH_DSU400_2)},
- {USB_DEVICE(USB_VENDOR_ID_QUATECH, QUATECH_QSU100_2)},
- {USB_DEVICE(USB_VENDOR_ID_QUATECH, QUATECH_QSU400_2)},
- {USB_DEVICE(USB_VENDOR_ID_QUATECH, QUATECH_ESU400_2)},
- {USB_DEVICE(USB_VENDOR_ID_QUATECH, QUATECH_ESU100_2)},
{} /* Terminating entry */
};
-
-MODULE_DEVICE_TABLE(usb, serqt_id_table);
+MODULE_DEVICE_TABLE(usb, id_table);
struct qt_get_device_data {
__u8 porta;
@@ -195,13 +180,6 @@ struct quatech_port {
char closePending;
};
-static struct usb_driver serqt_usb_driver = {
- .name = "quatech-usb-serial",
- .probe = usb_serial_probe,
- .disconnect = usb_serial_disconnect,
- .id_table = serqt_id_table,
-};
-
static int port_paranoia_check(struct usb_serial_port *port,
const char *function)
{
@@ -304,8 +282,6 @@ static void qt_write_bulk_callback(struct urb *urb)
quatech_port = urb->context;
- dbg("%s - port %d\n", __func__, quatech_port->port_num);
-
tty = tty_port_tty_get(&quatech_port->port->port);
if (tty)
@@ -351,7 +327,6 @@ static void qt_read_bulk_callback(struct urb *urb)
/* index = MINOR(port->tty->device) - serial->minor; */
index = tty->index - serial->minor;
- dbg("%s - port %d\n", __func__, port->number);
dbg("%s - port->RxHolding = %d\n", __func__, qt_port->RxHolding);
if (port_paranoia_check(port, __func__) != 0) {
@@ -634,7 +609,7 @@ static int BoxSetRegister(struct usb_serial *serial, unsigned short Uart_Number,
/*
* qt_setuart
- * issuse a SET_UART vendor-spcific request on the default control pipe
+ * issues a SET_UART vendor-specific request on the default control pipe
* If successful sets baud rate divisor and LCR value
*/
static int qt_setuart(struct usb_serial *serial, unsigned short Uart_Number,
@@ -726,8 +701,6 @@ static int qt_startup(struct usb_serial *serial)
int i;
int status;
- dbg("enterting %s", __func__);
-
/* Now setup per port private data */
for (i = 0; i < serial->num_ports; i++) {
port = serial->port[i];
@@ -855,8 +828,6 @@ static void qt_release(struct usb_serial *serial)
struct quatech_port *qt_port;
int i;
- dbg("enterting %s", __func__);
-
for (i = 0; i < serial->num_ports; i++) {
port = serial->port[i];
if (!port)
@@ -882,8 +853,6 @@ static int qt_open(struct tty_struct *tty,
if (port_paranoia_check(port, __func__))
return -ENODEV;
- dbg("%s - port %d\n", __func__, port->number);
-
serial = port->serial;
if (serial_paranoia_check(serial, __func__))
@@ -1006,8 +975,6 @@ static int qt_chars_in_buffer(struct tty_struct *tty)
serial = get_usb_serial(port, __func__);
- dbg("%s - port %d\n", __func__, port->number);
-
if (serial->num_bulk_out) {
if (port->write_urb->status == -EINPROGRESS)
chars = port->write_urb->transfer_buffer_length;
@@ -1054,8 +1021,6 @@ static void qt_close(struct usb_serial_port *port)
unsigned int index;
status = 0;
- dbg("%s - port %d\n", __func__, port->number);
-
tty = tty_port_tty_get(&port->port);
index = tty->index - serial->minor;
@@ -1109,8 +1074,6 @@ static int qt_write(struct tty_struct *tty, struct usb_serial_port *port,
if (serial == NULL)
return -ENODEV;
- dbg("%s - port %d\n", __func__, port->number);
-
if (count == 0) {
dbg("%s - write request of 0 bytes\n", __func__);
return 0;
@@ -1173,8 +1136,6 @@ static int qt_write_room(struct tty_struct *tty)
mutex_lock(&qt_port->lock);
- dbg("%s - port %d\n", __func__, port->number);
-
if (serial->num_bulk_out) {
if (port->write_urb->status != -EINPROGRESS)
retval = port->bulk_out_size;
@@ -1241,8 +1202,6 @@ static void qt_set_termios(struct tty_struct *tty,
int baud, divisor, remainder;
int status;
- dbg("%s", __func__);
-
index = tty->index - port->serial->minor;
switch (cflag) {
@@ -1365,8 +1324,6 @@ static void qt_break(struct tty_struct *tty, int break_state)
mutex_lock(&qt_port->lock);
- dbg("%s - port %d\n", __func__, port->number);
-
result =
usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0),
QT_BREAK_CONTROL, 0x40, onoff, index, NULL, 0, 300);
@@ -1385,8 +1342,6 @@ static inline int qt_real_tiocmget(struct tty_struct *tty,
int status;
unsigned int index;
- dbg("%s - port %d, tty =0x%p\n", __func__, port->number, tty);
-
index = tty->index - serial->minor;
status =
BoxGetRegister(port->serial, index, MODEM_CONTROL_REGISTER, &mcr);
@@ -1426,8 +1381,6 @@ static inline int qt_real_tiocmset(struct tty_struct *tty,
int status;
unsigned int index;
- dbg("%s - port %d\n", __func__, port->number);
-
index = tty->index - serial->minor;
status =
BoxGetRegister(port->serial, index, MODEM_CONTROL_REGISTER, &mcr);
@@ -1435,7 +1388,7 @@ static inline int qt_real_tiocmset(struct tty_struct *tty,
return -ESPIPE;
/*
- * Turn off the RTS and DTR and loopbcck and then only turn on what was
+ * Turn off the RTS and DTR and loopback and then only turn on what was
* asked for
*/
mcr &= ~(SERIAL_MCR_RTS | SERIAL_MCR_DTR | SERIAL_MCR_LOOP);
@@ -1461,18 +1414,11 @@ static int qt_tiocmget(struct tty_struct *tty)
struct quatech_port *qt_port = qt_get_port_private(port);
int retval = -ENODEV;
- dbg("In %s\n", __func__);
-
if (!serial)
return -ENODEV;
mutex_lock(&qt_port->lock);
-
- dbg("%s - port %d\n", __func__, port->number);
- dbg("%s - port->RxHolding = %d\n", __func__, qt_port->RxHolding);
-
retval = qt_real_tiocmget(tty, port, serial);
-
mutex_unlock(&qt_port->lock);
return retval;
}
@@ -1486,18 +1432,11 @@ static int qt_tiocmset(struct tty_struct *tty,
struct quatech_port *qt_port = qt_get_port_private(port);
int retval = -ENODEV;
- dbg("In %s\n", __func__);
-
if (!serial)
return -ENODEV;
mutex_lock(&qt_port->lock);
-
- dbg("%s - port %d\n", __func__, port->number);
- dbg("%s - qt_port->RxHolding = %d\n", __func__, qt_port->RxHolding);
-
retval = qt_real_tiocmset(tty, port, serial, set);
-
mutex_unlock(&qt_port->lock);
return retval;
}
@@ -1508,8 +1447,6 @@ static void qt_throttle(struct tty_struct *tty)
struct usb_serial *serial = get_usb_serial(port, __func__);
struct quatech_port *qt_port;
- dbg("%s - port %d\n", __func__, port->number);
-
if (!serial)
return;
@@ -1519,7 +1456,6 @@ static void qt_throttle(struct tty_struct *tty)
/* pass on to the driver specific version of this function */
qt_port->RxHolding = 1;
- dbg("%s - port->RxHolding = 1\n", __func__);
mutex_unlock(&qt_port->lock);
return;
@@ -1539,8 +1475,6 @@ static void qt_unthrottle(struct tty_struct *tty)
mutex_lock(&qt_port->lock);
- dbg("%s - port %d\n", __func__, port->number);
-
if (qt_port->RxHolding == 1) {
dbg("%s -qt_port->RxHolding == 1\n", __func__);
@@ -1559,8 +1493,9 @@ static void qt_unthrottle(struct tty_struct *tty)
qt_read_bulk_callback, port);
result = usb_submit_urb(port->read_urb, GFP_ATOMIC);
if (result)
- err("%s - failed restarting read urb, error %d",
- __func__, result);
+ dev_err(&port->dev,
+ "%s - failed restarting read urb, error %d\n",
+ __func__, result);
}
}
mutex_unlock(&qt_port->lock);
@@ -1589,7 +1524,7 @@ static struct usb_serial_driver quatech_device = {
.name = "serqt",
},
.description = DRIVER_DESC,
- .id_table = serqt_id_table,
+ .id_table = id_table,
.num_ports = 8,
.open = qt_open,
.close = qt_close,
@@ -1612,7 +1547,7 @@ static struct usb_serial_driver * const serial_drivers[] = {
&quatech_device, NULL
};
-module_usb_serial_driver(serqt_usb_driver, serial_drivers);
+module_usb_serial_driver(serial_drivers, id_table);
MODULE_AUTHOR(DRIVER_AUTHOR);
MODULE_DESCRIPTION(DRIVER_DESC);
diff --git a/drivers/staging/slicoss/slicoss.c b/drivers/staging/slicoss/slicoss.c
index 77a0751a31ad..56829fc032ff 100644
--- a/drivers/staging/slicoss/slicoss.c
+++ b/drivers/staging/slicoss/slicoss.c
@@ -47,7 +47,7 @@
* Oasis cards (single and dual port PCI-x Gigabit) copper and fiber
* Kalahari cards (dual and quad port PCI-e Gigabit) copper and fiber
*
- * The driver was acutally tested on Oasis and Kalahari cards.
+ * The driver was actually tested on Oasis and Kalahari cards.
*
*
* NOTE: This is the standard, non-accelerated version of Alacritech's
@@ -3196,7 +3196,6 @@ static void __devexit slic_entry_remove(struct pci_dev *pcidev)
struct sliccard *card;
struct mcast_address *mcaddr, *mlist;
- ASSERT(adapter);
slic_adapter_freeresources(adapter);
slic_unmap_mmio_space(adapter);
unregister_netdev(dev);
@@ -3235,6 +3234,7 @@ static void __devexit slic_entry_remove(struct pci_dev *pcidev)
}
free_netdev(dev);
pci_release_regions(pcidev);
+ pci_disable_device(pcidev);
}
static int slic_entry_halt(struct net_device *dev)
@@ -3746,8 +3746,7 @@ static u32 slic_card_locate(struct adapter *adapter)
rdhostid_offset = SLIC_RDHOSTID_1GB;
break;
default:
- ASSERT(0);
- break;
+ return -ENODEV;
}
hostid_reg =
diff --git a/drivers/staging/sm7xx/Kconfig b/drivers/staging/sm7xx/Kconfig
deleted file mode 100644
index 315102c7fed1..000000000000
--- a/drivers/staging/sm7xx/Kconfig
+++ /dev/null
@@ -1,8 +0,0 @@
-config FB_SM7XX
- tristate "Silicon Motion SM7XX Frame Buffer Support"
- depends on FB
- select FB_CFB_FILLRECT
- select FB_CFB_COPYAREA
- select FB_CFB_IMAGEBLIT
- help
- Frame Buffer driver for the Silicon Motion SM7XX serial graphic card.
diff --git a/drivers/staging/sm7xx/Makefile b/drivers/staging/sm7xx/Makefile
deleted file mode 100644
index f43cb9106305..000000000000
--- a/drivers/staging/sm7xx/Makefile
+++ /dev/null
@@ -1,3 +0,0 @@
-obj-$(CONFIG_FB_SM7XX) += sm7xx.o
-
-sm7xx-y := smtcfb.o
diff --git a/drivers/staging/sm7xxfb/Kconfig b/drivers/staging/sm7xxfb/Kconfig
new file mode 100644
index 000000000000..e2922ae3a3ee
--- /dev/null
+++ b/drivers/staging/sm7xxfb/Kconfig
@@ -0,0 +1,13 @@
+config FB_SM7XX
+ tristate "Silicon Motion SM7XX framebuffer support"
+ depends on FB && PCI
+ select FB_CFB_FILLRECT
+ select FB_CFB_COPYAREA
+ select FB_CFB_IMAGEBLIT
+ help
+ Frame buffer driver for the Silicon Motion SM710, SM712, SM721
+ and SM722 chips.
+
+ This driver is also available as a module. The module will be
+ called sm7xxfb. If you want to compile it as a module, say M
+ here and read <file:Documentation/kbuild/modules.txt>.
diff --git a/drivers/staging/sm7xxfb/Makefile b/drivers/staging/sm7xxfb/Makefile
new file mode 100644
index 000000000000..48f471cf9f36
--- /dev/null
+++ b/drivers/staging/sm7xxfb/Makefile
@@ -0,0 +1 @@
+obj-$(CONFIG_FB_SM7XX) += sm7xxfb.o
diff --git a/drivers/staging/sm7xx/TODO b/drivers/staging/sm7xxfb/TODO
index 7304021368c3..1fcead591c16 100644
--- a/drivers/staging/sm7xx/TODO
+++ b/drivers/staging/sm7xxfb/TODO
@@ -3,7 +3,7 @@ TODO:
- 2D acceleration support
- use kernel coding style
- refine the code and remove unused code
-- move it to drivers/video/sm7xx/ or make it be drivers/video/sm7xxfb.c
+- move it to drivers/video/sm7xxfb.c
Please send any patches to Greg Kroah-Hartman <greg@kroah.com> and
Teddy Wang <teddy.wang@siliconmotion.com.cn>.
diff --git a/drivers/staging/sm7xx/smtcfb.h b/drivers/staging/sm7xxfb/sm7xx.h
index ab95af2b9c07..333f33c3dc66 100644
--- a/drivers/staging/sm7xx/smtcfb.h
+++ b/drivers/staging/sm7xxfb/sm7xx.h
@@ -13,19 +13,10 @@
* more details.
*/
-#define SMTC_LINUX_FB_VERSION "version 0.11.2619.21.01 July 27, 2008"
-
#define NR_PALETTE 256
-#define NR_RGB 2
#define FB_ACCEL_SMI_LYNX 88
-#ifdef __BIG_ENDIAN
-#define PC_VGA 0
-#else
-#define PC_VGA 1
-#endif
-
#define SCREEN_X_RES 1024
#define SCREEN_Y_RES 600
#define SCREEN_BPP 16
diff --git a/drivers/staging/sm7xx/smtcfb.c b/drivers/staging/sm7xxfb/sm7xxfb.c
index 83c582ed12e5..1c1780c70fbb 100644
--- a/drivers/staging/sm7xx/smtcfb.c
+++ b/drivers/staging/sm7xxfb/sm7xxfb.c
@@ -2,31 +2,20 @@
* Silicon Motion SM7XX frame buffer device
*
* Copyright (C) 2006 Silicon Motion Technology Corp.
- * Authors: Ge Wang, gewang@siliconmotion.com
- * Boyod boyod.yang@siliconmotion.com.cn
+ * Authors: Ge Wang, gewang@siliconmotion.com
+ * Boyod boyod.yang@siliconmotion.com.cn
*
* Copyright (C) 2009 Lemote, Inc.
- * Author: Wu Zhangjin, wuzhangjin@gmail.com
+ * Author: Wu Zhangjin, wuzhangjin@gmail.com
*
* Copyright (C) 2011 Igalia, S.L.
- * Author: Javier M. Mellid <jmunhoz@igalia.com>
+ * Author: Javier M. Mellid <jmunhoz@igalia.com>
*
- * This file is subject to the terms and conditions of the GNU General Public
- * License. See the file COPYING in the main directory of this archive for
- * more details.
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License. See the file COPYING in the main directory of this archive for
+ * more details.
*
- * Version 0.10.26192.21.01
- * - Add PowerPC/Big endian support
- * - Verified on 2.6.19.2
- * Boyod.yang <boyod.yang@siliconmotion.com.cn>
- *
- * Version 0.09.2621.00.01
- * - Only support Linux Kernel's version 2.6.21
- * Boyod.yang <boyod.yang@siliconmotion.com.cn>
- *
- * Version 0.09
- * - Only support Linux Kernel's version 2.6.12
- * Boyod.yang <boyod.yang@siliconmotion.com.cn>
+ * Framebuffer driver for Silicon Motion SM710, SM712, SM721 and SM722 chips
*/
#include <linux/io.h>
@@ -43,43 +32,17 @@
#include <linux/pm.h>
#endif
-#include "smtcfb.h"
-
-#ifdef DEBUG
-#define smdbg(format, arg...) printk(KERN_DEBUG format , ## arg)
-#else
-#define smdbg(format, arg...)
-#endif
-
-struct screen_info smtc_screen_info;
+#include "sm7xx.h"
/*
* Private structure
*/
struct smtcfb_info {
- /*
- * The following is a pointer to be passed into the
- * functions below. The modules outside the main
- * voyager.c driver have no knowledge as to what
- * is within this structure.
- */
+ struct pci_dev *pdev;
struct fb_info fb;
- struct display_switch *dispsw;
- struct pci_dev *dev;
- signed int currcon;
-
- struct {
- u8 red, green, blue;
- } palette[NR_RGB];
-
- u_int palette_size;
-};
+ u16 chip_id;
+ u8 chip_rev_id;
-struct par_info {
- /*
- * Hardware
- */
- u16 chipID;
unsigned char __iomem *m_pMMIO;
char __iomem *m_pLFB;
char *m_pDPR;
@@ -89,48 +52,13 @@ struct par_info {
u_int width;
u_int height;
u_int hz;
- u_long BaseAddressInVRAM;
- u8 chipRevID;
-};
-
-struct vesa_mode_table {
- char mode_index[6];
- u16 lfb_width;
- u16 lfb_height;
- u16 lfb_depth;
-};
-
-static struct vesa_mode_table vesa_mode[] = {
- {"0x301", 640, 480, 8},
- {"0x303", 800, 600, 8},
- {"0x305", 1024, 768, 8},
- {"0x307", 1280, 1024, 8},
- {"0x311", 640, 480, 16},
- {"0x314", 800, 600, 16},
- {"0x317", 1024, 768, 16},
- {"0x31A", 1280, 1024, 16},
-
- {"0x312", 640, 480, 24},
- {"0x315", 800, 600, 24},
- {"0x318", 1024, 768, 24},
- {"0x31B", 1280, 1024, 24},
+ u32 colreg[17];
};
char __iomem *smtc_RegBaseAddress; /* Memory Map IO starting address */
char __iomem *smtc_VRAMBaseAddress; /* video memory starting address */
-static u32 colreg[17];
-static struct par_info hw; /* hardware information */
-
-u16 smtc_ChipIDs[] = {
- 0x710,
- 0x712,
- 0x720
-};
-
-#define numSMTCchipIDs ARRAY_SIZE(smtc_ChipIDs)
-
static struct fb_var_screeninfo smtcfb_var = {
.xres = 1024,
.yres = 600,
@@ -154,147 +82,71 @@ static struct fb_fix_screeninfo smtcfb_fix = {
.accel = FB_ACCEL_SMI_LYNX,
};
-static void sm712_set_timing(struct smtcfb_info *sfb,
- struct par_info *ppar_info)
-{
- int i = 0, j = 0;
- u32 m_nScreenStride;
-
- smdbg("\nppar_info->width = %d ppar_info->height = %d"
- "sfb->fb.var.bits_per_pixel = %d ppar_info->hz = %d\n",
- ppar_info->width, ppar_info->height,
- sfb->fb.var.bits_per_pixel, ppar_info->hz);
-
- for (j = 0; j < numVGAModes; j++) {
- if (VGAMode[j].mmSizeX == ppar_info->width &&
- VGAMode[j].mmSizeY == ppar_info->height &&
- VGAMode[j].bpp == sfb->fb.var.bits_per_pixel &&
- VGAMode[j].hz == ppar_info->hz) {
-
- smdbg("\nVGAMode[j].mmSizeX = %d VGAMode[j].mmSizeY ="
- "%d VGAMode[j].bpp = %d"
- "VGAMode[j].hz=%d\n",
- VGAMode[j].mmSizeX, VGAMode[j].mmSizeY,
- VGAMode[j].bpp, VGAMode[j].hz);
-
- smdbg("VGAMode index=%d\n", j);
-
- smtc_mmiowb(0x0, 0x3c6);
-
- smtc_seqw(0, 0x1);
-
- smtc_mmiowb(VGAMode[j].Init_MISC, 0x3c2);
-
- /* init SEQ register SR00 - SR04 */
- for (i = 0; i < SIZE_SR00_SR04; i++)
- smtc_seqw(i, VGAMode[j].Init_SR00_SR04[i]);
+struct vesa_mode {
+ char index[6];
+ u16 lfb_width;
+ u16 lfb_height;
+ u16 lfb_depth;
+};
- /* init SEQ register SR10 - SR24 */
- for (i = 0; i < SIZE_SR10_SR24; i++)
- smtc_seqw(i + 0x10,
- VGAMode[j].Init_SR10_SR24[i]);
+static struct vesa_mode vesa_mode_table[] = {
+ {"0x301", 640, 480, 8},
+ {"0x303", 800, 600, 8},
+ {"0x305", 1024, 768, 8},
+ {"0x307", 1280, 1024, 8},
- /* init SEQ register SR30 - SR75 */
- for (i = 0; i < SIZE_SR30_SR75; i++)
- if (((i + 0x30) != 0x62) \
- && ((i + 0x30) != 0x6a) \
- && ((i + 0x30) != 0x6b))
- smtc_seqw(i + 0x30,
- VGAMode[j].Init_SR30_SR75[i]);
+ {"0x311", 640, 480, 16},
+ {"0x314", 800, 600, 16},
+ {"0x317", 1024, 768, 16},
+ {"0x31A", 1280, 1024, 16},
- /* init SEQ register SR80 - SR93 */
- for (i = 0; i < SIZE_SR80_SR93; i++)
- smtc_seqw(i + 0x80,
- VGAMode[j].Init_SR80_SR93[i]);
+ {"0x312", 640, 480, 24},
+ {"0x315", 800, 600, 24},
+ {"0x318", 1024, 768, 24},
+ {"0x31B", 1280, 1024, 24},
+};
- /* init SEQ register SRA0 - SRAF */
- for (i = 0; i < SIZE_SRA0_SRAF; i++)
- smtc_seqw(i + 0xa0,
- VGAMode[j].Init_SRA0_SRAF[i]);
+struct screen_info smtc_scr_info;
- /* init Graphic register GR00 - GR08 */
- for (i = 0; i < SIZE_GR00_GR08; i++)
- smtc_grphw(i, VGAMode[j].Init_GR00_GR08[i]);
+/* process command line options, get vga parameter */
+static int __init sm7xx_vga_setup(char *options)
+{
+ int i;
- /* init Attribute register AR00 - AR14 */
- for (i = 0; i < SIZE_AR00_AR14; i++)
- smtc_attrw(i, VGAMode[j].Init_AR00_AR14[i]);
+ if (!options || !*options)
+ return -EINVAL;
- /* init CRTC register CR00 - CR18 */
- for (i = 0; i < SIZE_CR00_CR18; i++)
- smtc_crtcw(i, VGAMode[j].Init_CR00_CR18[i]);
+ smtc_scr_info.lfb_width = 0;
+ smtc_scr_info.lfb_height = 0;
+ smtc_scr_info.lfb_depth = 0;
- /* init CRTC register CR30 - CR4D */
- for (i = 0; i < SIZE_CR30_CR4D; i++)
- smtc_crtcw(i + 0x30,
- VGAMode[j].Init_CR30_CR4D[i]);
+ pr_debug("sm7xx_vga_setup = %s\n", options);
- /* init CRTC register CR90 - CRA7 */
- for (i = 0; i < SIZE_CR90_CRA7; i++)
- smtc_crtcw(i + 0x90,
- VGAMode[j].Init_CR90_CRA7[i]);
+ for (i = 0; i < ARRAY_SIZE(vesa_mode_table); i++) {
+ if (strstr(options, vesa_mode_table[i].index)) {
+ smtc_scr_info.lfb_width = vesa_mode_table[i].lfb_width;
+ smtc_scr_info.lfb_height = vesa_mode_table[i].lfb_height;
+ smtc_scr_info.lfb_depth = vesa_mode_table[i].lfb_depth;
+ return 0;
}
}
- smtc_mmiowb(0x67, 0x3c2);
-
- /* set VPR registers */
- writel(0x0, ppar_info->m_pVPR + 0x0C);
- writel(0x0, ppar_info->m_pVPR + 0x40);
-
- /* set data width */
- m_nScreenStride =
- (ppar_info->width * sfb->fb.var.bits_per_pixel) / 64;
- switch (sfb->fb.var.bits_per_pixel) {
- case 8:
- writel(0x0, ppar_info->m_pVPR + 0x0);
- break;
- case 16:
- writel(0x00020000, ppar_info->m_pVPR + 0x0);
- break;
- case 24:
- writel(0x00040000, ppar_info->m_pVPR + 0x0);
- break;
- case 32:
- writel(0x00030000, ppar_info->m_pVPR + 0x0);
- break;
- }
- writel((u32) (((m_nScreenStride + 2) << 16) | m_nScreenStride),
- ppar_info->m_pVPR + 0x10);
+ return -1;
}
+__setup("vga=", sm7xx_vga_setup);
static void sm712_setpalette(int regno, unsigned red, unsigned green,
unsigned blue, struct fb_info *info)
{
- struct par_info *cur_par = (struct par_info *)info->par;
+ /* set bit 5:4 = 01 (write LCD RAM only) */
+ smtc_seqw(0x66, (smtc_seqr(0x66) & 0xC3) | 0x10);
- if (cur_par->BaseAddressInVRAM)
- /*
- * second display palette for dual head. Enable CRT RAM, 6-bit
- * RAM
- */
- smtc_seqw(0x66, (smtc_seqr(0x66) & 0xC3) | 0x20);
- else
- /* primary display palette. Enable LCD RAM only, 6-bit RAM */
- smtc_seqw(0x66, (smtc_seqr(0x66) & 0xC3) | 0x10);
smtc_mmiowb(regno, dac_reg);
smtc_mmiowb(red >> 10, dac_val);
smtc_mmiowb(green >> 10, dac_val);
smtc_mmiowb(blue >> 10, dac_val);
}
-static void smtc_set_timing(struct smtcfb_info *sfb, struct par_info
- *ppar_info)
-{
- switch (ppar_info->chipID) {
- case 0x710:
- case 0x712:
- case 0x720:
- sm712_set_timing(sfb, ppar_info);
- break;
- }
-}
-
/* chan_to_field
*
* convert a colour value into a field position
@@ -310,7 +162,7 @@ static inline unsigned int chan_to_field(unsigned int chan,
return chan << bf->offset;
}
-static int cfb_blank(int blank_mode, struct fb_info *info)
+static int smtc_blank(int blank_mode, struct fb_info *info)
{
/* clear DPMS setting */
switch (blank_mode) {
@@ -384,9 +236,11 @@ static int cfb_blank(int blank_mode, struct fb_info *info)
static int smtc_setcolreg(unsigned regno, unsigned red, unsigned green,
unsigned blue, unsigned trans, struct fb_info *info)
{
- struct smtcfb_info *sfb = (struct smtcfb_info *)info;
+ struct smtcfb_info *sfb;
u32 val;
+ sfb = info->par;
+
if (regno > 255)
return 1;
@@ -394,7 +248,7 @@ static int smtc_setcolreg(unsigned regno, unsigned red, unsigned green,
case FB_VISUAL_DIRECTCOLOR:
case FB_VISUAL_TRUECOLOR:
/*
- * 16/32 bit true-colour, use pseuo-palette for 16 base color
+ * 16/32 bit true-colour, use pseudo-palette for 16 base color
*/
if (regno < 16) {
if (sfb->fb.var.bits_per_pixel == 16) {
@@ -608,62 +462,175 @@ smtcfb_write(struct fb_info *info, const char __user *buf, size_t count,
}
#endif /* ! __BIG_ENDIAN */
+static void sm7xx_set_timing(struct smtcfb_info *sfb)
+{
+ int i = 0, j = 0;
+ u32 m_nScreenStride;
+
+ dev_dbg(&sfb->pdev->dev,
+ "sfb->width=%d sfb->height=%d "
+ "sfb->fb.var.bits_per_pixel=%d sfb->hz=%d\n",
+ sfb->width, sfb->height, sfb->fb.var.bits_per_pixel, sfb->hz);
+
+ for (j = 0; j < numVGAModes; j++) {
+ if (VGAMode[j].mmSizeX == sfb->width &&
+ VGAMode[j].mmSizeY == sfb->height &&
+ VGAMode[j].bpp == sfb->fb.var.bits_per_pixel &&
+ VGAMode[j].hz == sfb->hz) {
+
+ dev_dbg(&sfb->pdev->dev,
+ "VGAMode[j].mmSizeX=%d VGAMode[j].mmSizeY=%d "
+ "VGAMode[j].bpp=%d VGAMode[j].hz=%d\n",
+ VGAMode[j].mmSizeX, VGAMode[j].mmSizeY,
+ VGAMode[j].bpp, VGAMode[j].hz);
+
+ dev_dbg(&sfb->pdev->dev, "VGAMode index=%d\n", j);
+
+ smtc_mmiowb(0x0, 0x3c6);
+
+ smtc_seqw(0, 0x1);
+
+ smtc_mmiowb(VGAMode[j].Init_MISC, 0x3c2);
+
+ /* init SEQ register SR00 - SR04 */
+ for (i = 0; i < SIZE_SR00_SR04; i++)
+ smtc_seqw(i, VGAMode[j].Init_SR00_SR04[i]);
+
+ /* init SEQ register SR10 - SR24 */
+ for (i = 0; i < SIZE_SR10_SR24; i++)
+ smtc_seqw(i + 0x10,
+ VGAMode[j].Init_SR10_SR24[i]);
+
+ /* init SEQ register SR30 - SR75 */
+ for (i = 0; i < SIZE_SR30_SR75; i++)
+ if (((i + 0x30) != 0x62) \
+ && ((i + 0x30) != 0x6a) \
+ && ((i + 0x30) != 0x6b))
+ smtc_seqw(i + 0x30,
+ VGAMode[j].Init_SR30_SR75[i]);
+
+ /* init SEQ register SR80 - SR93 */
+ for (i = 0; i < SIZE_SR80_SR93; i++)
+ smtc_seqw(i + 0x80,
+ VGAMode[j].Init_SR80_SR93[i]);
+
+ /* init SEQ register SRA0 - SRAF */
+ for (i = 0; i < SIZE_SRA0_SRAF; i++)
+ smtc_seqw(i + 0xa0,
+ VGAMode[j].Init_SRA0_SRAF[i]);
+
+ /* init Graphic register GR00 - GR08 */
+ for (i = 0; i < SIZE_GR00_GR08; i++)
+ smtc_grphw(i, VGAMode[j].Init_GR00_GR08[i]);
+
+ /* init Attribute register AR00 - AR14 */
+ for (i = 0; i < SIZE_AR00_AR14; i++)
+ smtc_attrw(i, VGAMode[j].Init_AR00_AR14[i]);
+
+ /* init CRTC register CR00 - CR18 */
+ for (i = 0; i < SIZE_CR00_CR18; i++)
+ smtc_crtcw(i, VGAMode[j].Init_CR00_CR18[i]);
+
+ /* init CRTC register CR30 - CR4D */
+ for (i = 0; i < SIZE_CR30_CR4D; i++)
+ smtc_crtcw(i + 0x30,
+ VGAMode[j].Init_CR30_CR4D[i]);
+
+ /* init CRTC register CR90 - CRA7 */
+ for (i = 0; i < SIZE_CR90_CRA7; i++)
+ smtc_crtcw(i + 0x90,
+ VGAMode[j].Init_CR90_CRA7[i]);
+ }
+ }
+ smtc_mmiowb(0x67, 0x3c2);
+
+ /* set VPR registers */
+ writel(0x0, sfb->m_pVPR + 0x0C);
+ writel(0x0, sfb->m_pVPR + 0x40);
+
+ /* set data width */
+ m_nScreenStride =
+ (sfb->width * sfb->fb.var.bits_per_pixel) / 64;
+ switch (sfb->fb.var.bits_per_pixel) {
+ case 8:
+ writel(0x0, sfb->m_pVPR + 0x0);
+ break;
+ case 16:
+ writel(0x00020000, sfb->m_pVPR + 0x0);
+ break;
+ case 24:
+ writel(0x00040000, sfb->m_pVPR + 0x0);
+ break;
+ case 32:
+ writel(0x00030000, sfb->m_pVPR + 0x0);
+ break;
+ }
+ writel((u32) (((m_nScreenStride + 2) << 16) | m_nScreenStride),
+ sfb->m_pVPR + 0x10);
+
+}
+
+static void smtc_set_timing(struct smtcfb_info *sfb)
+{
+ switch (sfb->chip_id) {
+ case 0x710:
+ case 0x712:
+ case 0x720:
+ sm7xx_set_timing(sfb);
+ break;
+ }
+}
+
void smtcfb_setmode(struct smtcfb_info *sfb)
{
switch (sfb->fb.var.bits_per_pixel) {
case 32:
- sfb->fb.fix.visual = FB_VISUAL_TRUECOLOR;
- sfb->fb.fix.line_length = sfb->fb.var.xres * 4;
- sfb->fb.var.red.length = 8;
+ sfb->fb.fix.visual = FB_VISUAL_TRUECOLOR;
+ sfb->fb.fix.line_length = sfb->fb.var.xres * 4;
+ sfb->fb.var.red.length = 8;
sfb->fb.var.green.length = 8;
- sfb->fb.var.blue.length = 8;
- sfb->fb.var.red.offset = 16;
+ sfb->fb.var.blue.length = 8;
+ sfb->fb.var.red.offset = 16;
sfb->fb.var.green.offset = 8;
- sfb->fb.var.blue.offset = 0;
-
- break;
- case 8:
- sfb->fb.fix.visual = FB_VISUAL_PSEUDOCOLOR;
- sfb->fb.fix.line_length = sfb->fb.var.xres;
- sfb->fb.var.red.offset = 5;
- sfb->fb.var.red.length = 3;
- sfb->fb.var.green.offset = 2;
- sfb->fb.var.green.length = 3;
- sfb->fb.var.blue.offset = 0;
- sfb->fb.var.blue.length = 2;
+ sfb->fb.var.blue.offset = 0;
break;
case 24:
- sfb->fb.fix.visual = FB_VISUAL_TRUECOLOR;
- sfb->fb.fix.line_length = sfb->fb.var.xres * 3;
- sfb->fb.var.red.length = 8;
+ sfb->fb.fix.visual = FB_VISUAL_TRUECOLOR;
+ sfb->fb.fix.line_length = sfb->fb.var.xres * 3;
+ sfb->fb.var.red.length = 8;
sfb->fb.var.green.length = 8;
- sfb->fb.var.blue.length = 8;
-
- sfb->fb.var.red.offset = 16;
+ sfb->fb.var.blue.length = 8;
+ sfb->fb.var.red.offset = 16;
sfb->fb.var.green.offset = 8;
- sfb->fb.var.blue.offset = 0;
-
+ sfb->fb.var.blue.offset = 0;
+ break;
+ case 8:
+ sfb->fb.fix.visual = FB_VISUAL_PSEUDOCOLOR;
+ sfb->fb.fix.line_length = sfb->fb.var.xres;
+ sfb->fb.var.red.length = 3;
+ sfb->fb.var.green.length = 3;
+ sfb->fb.var.blue.length = 2;
+ sfb->fb.var.red.offset = 5;
+ sfb->fb.var.green.offset = 2;
+ sfb->fb.var.blue.offset = 0;
break;
case 16:
default:
- sfb->fb.fix.visual = FB_VISUAL_TRUECOLOR;
- sfb->fb.fix.line_length = sfb->fb.var.xres * 2;
-
- sfb->fb.var.red.length = 5;
+ sfb->fb.fix.visual = FB_VISUAL_TRUECOLOR;
+ sfb->fb.fix.line_length = sfb->fb.var.xres * 2;
+ sfb->fb.var.red.length = 5;
sfb->fb.var.green.length = 6;
- sfb->fb.var.blue.length = 5;
-
- sfb->fb.var.red.offset = 11;
+ sfb->fb.var.blue.length = 5;
+ sfb->fb.var.red.offset = 11;
sfb->fb.var.green.offset = 5;
- sfb->fb.var.blue.offset = 0;
-
+ sfb->fb.var.blue.offset = 0;
break;
}
- hw.width = sfb->fb.var.xres;
- hw.height = sfb->fb.var.yres;
- hw.hz = 60;
- smtc_set_timing(sfb, &hw);
+ sfb->width = sfb->fb.var.xres;
+ sfb->height = sfb->fb.var.yres;
+ sfb->hz = 60;
+ smtc_set_timing(sfb);
}
static int smtc_check_var(struct fb_var_screeninfo *var, struct fb_info *info)
@@ -685,9 +652,7 @@ static int smtc_check_var(struct fb_var_screeninfo *var, struct fb_info *info)
static int smtc_set_par(struct fb_info *info)
{
- struct smtcfb_info *sfb = (struct smtcfb_info *)info;
-
- smtcfb_setmode(sfb);
+ smtcfb_setmode(info->par);
return 0;
}
@@ -697,7 +662,7 @@ static struct fb_ops smtcfb_ops = {
.fb_check_var = smtc_check_var,
.fb_set_par = smtc_set_par,
.fb_setcolreg = smtc_setcolreg,
- .fb_blank = cfb_blank,
+ .fb_blank = smtc_blank,
.fb_fillrect = cfb_fillrect,
.fb_imageblit = cfb_imageblit,
.fb_copyarea = cfb_copyarea,
@@ -708,10 +673,9 @@ static struct fb_ops smtcfb_ops = {
};
/*
- * Alloc struct smtcfb_info and assign the default value
+ * alloc struct smtcfb_info and assign the default value
*/
-static struct smtcfb_info *smtc_alloc_fb_info(struct pci_dev *dev,
- char *name)
+static struct smtcfb_info *smtc_alloc_fb_info(struct pci_dev *pdev, char *name)
{
struct smtcfb_info *sfb;
@@ -720,38 +684,47 @@ static struct smtcfb_info *smtc_alloc_fb_info(struct pci_dev *dev,
if (!sfb)
return NULL;
- sfb->currcon = -1;
- sfb->dev = dev;
+ sfb->pdev = pdev;
+
+ /* init sfb->fb with default value */
- /*** Init sfb->fb with default value ***/
sfb->fb.flags = FBINFO_FLAG_DEFAULT;
sfb->fb.fbops = &smtcfb_ops;
- sfb->fb.var = smtcfb_var;
- sfb->fb.fix = smtcfb_fix;
+ sfb->fb.fix = smtcfb_fix;
strcpy(sfb->fb.fix.id, name);
- sfb->fb.fix.type = FB_TYPE_PACKED_PIXELS;
- sfb->fb.fix.type_aux = 0;
- sfb->fb.fix.xpanstep = 0;
- sfb->fb.fix.ypanstep = 0;
- sfb->fb.fix.ywrapstep = 0;
- sfb->fb.fix.accel = FB_ACCEL_SMI_LYNX;
-
- sfb->fb.var.nonstd = 0;
- sfb->fb.var.activate = FB_ACTIVATE_NOW;
- sfb->fb.var.height = -1;
- sfb->fb.var.width = -1;
- /* text mode acceleration */
+ sfb->fb.fix.type = FB_TYPE_PACKED_PIXELS;
+ sfb->fb.fix.type_aux = 0;
+ sfb->fb.fix.xpanstep = 0;
+ sfb->fb.fix.ypanstep = 0;
+ sfb->fb.fix.ywrapstep = 0;
+ sfb->fb.fix.accel = FB_ACCEL_SMI_LYNX;
+
+ sfb->fb.var = smtcfb_var;
+ sfb->fb.var.nonstd = 0;
+ sfb->fb.var.activate = FB_ACTIVATE_NOW;
+ sfb->fb.var.height = -1;
+ sfb->fb.var.width = -1;
sfb->fb.var.accel_flags = FB_ACCELF_TEXT;
- sfb->fb.var.vmode = FB_VMODE_NONINTERLACED;
- sfb->fb.par = &hw;
- sfb->fb.pseudo_palette = colreg;
+ sfb->fb.var.vmode = FB_VMODE_NONINTERLACED;
+
+ sfb->fb.pseudo_palette = sfb->colreg;
+
+ sfb->fb.par = sfb;
return sfb;
}
/*
+ * free struct smtcfb_info
+ */
+static void smtc_free_fb_info(struct smtcfb_info *sfb)
+{
+ kfree(sfb);
+}
+
+/*
* Unmap in the memory mapped IO registers
*/
@@ -766,26 +739,23 @@ static void smtc_unmap_mmio(struct smtcfb_info *sfb)
*/
static int smtc_map_smem(struct smtcfb_info *sfb,
- struct pci_dev *dev, u_long smem_len)
+ struct pci_dev *pdev, u_long smem_len)
{
- if (sfb->fb.var.bits_per_pixel == 32) {
+
+ sfb->fb.fix.smem_start = pci_resource_start(pdev, 0);
+
#ifdef __BIG_ENDIAN
- sfb->fb.fix.smem_start = pci_resource_start(dev, 0)
- + 0x800000;
-#else
- sfb->fb.fix.smem_start = pci_resource_start(dev, 0);
+ if (sfb->fb.var.bits_per_pixel == 32)
+ sfb->fb.fix.smem_start += 0x800000;
#endif
- } else {
- sfb->fb.fix.smem_start = pci_resource_start(dev, 0);
- }
sfb->fb.fix.smem_len = smem_len;
sfb->fb.screen_base = smtc_VRAMBaseAddress;
if (!sfb->fb.screen_base) {
- printk(KERN_ERR "%s: unable to map screen memory\n",
- sfb->fb.fix.id);
+ dev_err(&pdev->dev,
+ "%s: unable to map screen memory\n", sfb->fb.fix.id);
return -ENOMEM;
}
@@ -805,7 +775,7 @@ static void smtc_unmap_smem(struct smtcfb_info *sfb)
}
/*
- * We need to wake up the LynxEM+, and make sure its in linear memory mode.
+ * We need to wake up the device and make sure its in linear memory mode.
*/
static inline void sm7xx_init_hw(void)
{
@@ -813,55 +783,6 @@ static inline void sm7xx_init_hw(void)
outb_p(0x11, 0x3c5);
}
-static void smtc_free_fb_info(struct smtcfb_info *sfb)
-{
- if (sfb) {
- fb_alloc_cmap(&sfb->fb.cmap, 0, 0);
- kfree(sfb);
- }
-}
-
-/*
- * sm712vga_setup - process command line options, get vga parameter
- * @options: string of options
- * Returns zero.
- *
- */
-static int __init sm712vga_setup(char *options)
-{
- int index;
-
- if (!options || !*options) {
- smdbg("\n No vga parameter\n");
- return -EINVAL;
- }
-
- smtc_screen_info.lfb_width = 0;
- smtc_screen_info.lfb_height = 0;
- smtc_screen_info.lfb_depth = 0;
-
- smdbg("\nsm712vga_setup = %s\n", options);
-
- for (index = 0;
- index < ARRAY_SIZE(vesa_mode);
- index++) {
- if (strstr(options, vesa_mode[index].mode_index)) {
- smtc_screen_info.lfb_width = vesa_mode[index].lfb_width;
- smtc_screen_info.lfb_height =
- vesa_mode[index].lfb_height;
- smtc_screen_info.lfb_depth = vesa_mode[index].lfb_depth;
- return 0;
- }
- }
-
- return -1;
-}
-__setup("vga=", sm712vga_setup);
-
-/* Jason (08/13/2009)
- * Original init function changed to probe method to be used by pci_drv
- * process used to detect chips replaced with kernel process in pci_drv
- */
static int __devinit smtcfb_pci_probe(struct pci_dev *pdev,
const struct pci_device_id *ent)
{
@@ -871,32 +792,31 @@ static int __devinit smtcfb_pci_probe(struct pci_dev *pdev,
int err;
unsigned long pFramebufferPhysical;
- printk(KERN_INFO
- "Silicon Motion display driver " SMTC_LINUX_FB_VERSION "\n");
+ dev_info(&pdev->dev, "Silicon Motion display driver.");
err = pci_enable_device(pdev); /* enable SMTC chip */
if (err)
return err;
- hw.chipID = ent->device;
- sprintf(name, "sm%Xfb", hw.chipID);
-
sfb = smtc_alloc_fb_info(pdev, name);
- if (!sfb)
+ if (!sfb) {
+ err = -ENOMEM;
goto failed_free;
- /* Jason (08/13/2009)
- * Store fb_info to be further used when suspending and resuming
- */
+ }
+
+ sfb->chip_id = ent->device;
+ sprintf(name, "sm%Xfb", sfb->chip_id);
+
pci_set_drvdata(pdev, sfb);
sm7xx_init_hw();
- /*get mode parameter from smtc_screen_info */
- if (smtc_screen_info.lfb_width != 0) {
- sfb->fb.var.xres = smtc_screen_info.lfb_width;
- sfb->fb.var.yres = smtc_screen_info.lfb_height;
- sfb->fb.var.bits_per_pixel = smtc_screen_info.lfb_depth;
+ /* get mode parameter from smtc_scr_info */
+ if (smtc_scr_info.lfb_width != 0) {
+ sfb->fb.var.xres = smtc_scr_info.lfb_width;
+ sfb->fb.var.yres = smtc_scr_info.lfb_height;
+ sfb->fb.var.bits_per_pixel = smtc_scr_info.lfb_depth;
} else {
/* default resolution 1024x600 16bit mode */
sfb->fb.var.xres = SCREEN_X_RES;
@@ -906,41 +826,41 @@ static int __devinit smtcfb_pci_probe(struct pci_dev *pdev,
#ifdef __BIG_ENDIAN
if (sfb->fb.var.bits_per_pixel == 24)
- sfb->fb.var.bits_per_pixel = (smtc_screen_info.lfb_depth = 32);
+ sfb->fb.var.bits_per_pixel = (smtc_scr_info.lfb_depth = 32);
#endif
/* Map address and memory detection */
pFramebufferPhysical = pci_resource_start(pdev, 0);
- pci_read_config_byte(pdev, PCI_REVISION_ID, &hw.chipRevID);
+ pci_read_config_byte(pdev, PCI_REVISION_ID, &sfb->chip_rev_id);
- switch (hw.chipID) {
+ switch (sfb->chip_id) {
case 0x710:
case 0x712:
sfb->fb.fix.mmio_start = pFramebufferPhysical + 0x00400000;
sfb->fb.fix.mmio_len = 0x00400000;
smem_size = SM712_VIDEOMEMORYSIZE;
#ifdef __BIG_ENDIAN
- hw.m_pLFB = (smtc_VRAMBaseAddress =
+ sfb->m_pLFB = (smtc_VRAMBaseAddress =
ioremap(pFramebufferPhysical, 0x00c00000));
#else
- hw.m_pLFB = (smtc_VRAMBaseAddress =
+ sfb->m_pLFB = (smtc_VRAMBaseAddress =
ioremap(pFramebufferPhysical, 0x00800000));
#endif
- hw.m_pMMIO = (smtc_RegBaseAddress =
+ sfb->m_pMMIO = (smtc_RegBaseAddress =
smtc_VRAMBaseAddress + 0x00700000);
- hw.m_pDPR = smtc_VRAMBaseAddress + 0x00408000;
- hw.m_pVPR = hw.m_pLFB + 0x0040c000;
+ sfb->m_pDPR = smtc_VRAMBaseAddress + 0x00408000;
+ sfb->m_pVPR = sfb->m_pLFB + 0x0040c000;
#ifdef __BIG_ENDIAN
if (sfb->fb.var.bits_per_pixel == 32) {
smtc_VRAMBaseAddress += 0x800000;
- hw.m_pLFB += 0x800000;
- printk(KERN_INFO
- "\nsmtc_VRAMBaseAddress=%p hw.m_pLFB=%p\n",
- smtc_VRAMBaseAddress, hw.m_pLFB);
+ sfb->m_pLFB += 0x800000;
+ dev_info(&pdev->dev,
+ "smtc_VRAMBaseAddress=%p sfb->m_pLFB=%p",
+ smtc_VRAMBaseAddress, sfb->m_pLFB);
}
#endif
if (!smtc_RegBaseAddress) {
- printk(KERN_ERR
- "%s: unable to map memory mapped IO\n",
+ dev_err(&pdev->dev,
+ "%s: unable to map memory mapped IO!",
sfb->fb.fix.id);
err = -ENOMEM;
goto failed_fb;
@@ -962,20 +882,20 @@ static int __devinit smtcfb_pci_probe(struct pci_dev *pdev,
sfb->fb.fix.mmio_start = pFramebufferPhysical;
sfb->fb.fix.mmio_len = 0x00200000;
smem_size = SM722_VIDEOMEMORYSIZE;
- hw.m_pDPR = ioremap(pFramebufferPhysical, 0x00a00000);
- hw.m_pLFB = (smtc_VRAMBaseAddress =
- hw.m_pDPR + 0x00200000);
- hw.m_pMMIO = (smtc_RegBaseAddress =
- hw.m_pDPR + 0x000c0000);
- hw.m_pVPR = hw.m_pDPR + 0x800;
+ sfb->m_pDPR = ioremap(pFramebufferPhysical, 0x00a00000);
+ sfb->m_pLFB = (smtc_VRAMBaseAddress =
+ sfb->m_pDPR + 0x00200000);
+ sfb->m_pMMIO = (smtc_RegBaseAddress =
+ sfb->m_pDPR + 0x000c0000);
+ sfb->m_pVPR = sfb->m_pDPR + 0x800;
smtc_seqw(0x62, 0xff);
smtc_seqw(0x6a, 0x0d);
smtc_seqw(0x6b, 0x02);
break;
default:
- printk(KERN_ERR
- "No valid Silicon Motion display chip was detected!\n");
+ dev_err(&pdev->dev,
+ "No valid Silicon Motion display chip was detected!");
goto failed_fb;
}
@@ -991,23 +911,20 @@ static int __devinit smtcfb_pci_probe(struct pci_dev *pdev,
goto failed;
smtcfb_setmode(sfb);
- /* Primary display starting from 0 position */
- hw.BaseAddressInVRAM = 0;
- sfb->fb.par = &hw;
err = register_framebuffer(&sfb->fb);
if (err < 0)
goto failed;
- printk(KERN_INFO "Silicon Motion SM%X Rev%X primary display mode"
- "%dx%d-%d Init Complete.\n", hw.chipID, hw.chipRevID,
- sfb->fb.var.xres, sfb->fb.var.yres,
- sfb->fb.var.bits_per_pixel);
+ dev_info(&pdev->dev,
+ "Silicon Motion SM%X Rev%X primary display mode %dx%d-%d Init Complete.",
+ sfb->chip_id, sfb->chip_rev_id, sfb->fb.var.xres,
+ sfb->fb.var.yres, sfb->fb.var.bits_per_pixel);
return 0;
failed:
- printk(KERN_ERR "Silicon Motion, Inc. primary display init fail\n");
+ dev_err(&pdev->dev, "Silicon Motion, Inc. primary display init fail.");
smtc_unmap_smem(sfb);
smtc_unmap_mmio(sfb);
@@ -1020,8 +937,11 @@ failed_free:
return err;
}
-
-/* Jason (08/11/2009) PCI_DRV wrapper essential structs */
+/*
+ * 0x710 (LynxEM)
+ * 0x712 (LynxEM+)
+ * 0x720 (Lynx3DM, Lynx3DM+)
+ */
static DEFINE_PCI_DEVICE_TABLE(smtcfb_pci_table) = {
{ PCI_DEVICE(0x126f, 0x710), },
{ PCI_DEVICE(0x126f, 0x712), },
@@ -1029,10 +949,6 @@ static DEFINE_PCI_DEVICE_TABLE(smtcfb_pci_table) = {
{0,}
};
-
-/* Jason (08/14/2009)
- * do some clean up when the driver module is removed
- */
static void __devexit smtcfb_pci_remove(struct pci_dev *pdev)
{
struct smtcfb_info *sfb;
@@ -1053,7 +969,7 @@ static int smtcfb_pci_suspend(struct device *device)
sfb = pci_get_drvdata(pdev);
- /* set the hw in sleep mode use externel clock and self memory refresh
+ /* set the hw in sleep mode use external clock and self memory refresh
* so that we can turn off internal PLLs later on
*/
smtc_seqw(0x20, (smtc_seqr(0x20) | 0xc0));
@@ -1078,7 +994,7 @@ static int smtcfb_pci_resume(struct device *device)
/* reinit hardware */
sm7xx_init_hw();
- switch (hw.chipID) {
+ switch (sfb->chip_id) {
case 0x710:
case 0x712:
/* set MCLK = 14.31818 * (0x16 / 0x2) */
@@ -1136,18 +1052,7 @@ static struct pci_driver smtcfb_driver = {
.driver.pm = SM7XX_PM_OPS,
};
-static int __init smtcfb_init(void)
-{
- return pci_register_driver(&smtcfb_driver);
-}
-
-static void __exit smtcfb_exit(void)
-{
- pci_unregister_driver(&smtcfb_driver);
-}
-
-module_init(smtcfb_init);
-module_exit(smtcfb_exit);
+module_pci_driver(smtcfb_driver);
MODULE_AUTHOR("Siliconmotion ");
MODULE_DESCRIPTION("Framebuffer driver for SMI Graphic Cards");
diff --git a/drivers/staging/speakup/i18n.c b/drivers/staging/speakup/i18n.c
index c2119433f333..ca01734d13c5 100644
--- a/drivers/staging/speakup/i18n.c
+++ b/drivers/staging/speakup/i18n.c
@@ -71,7 +71,7 @@ static char *speakup_default_msgs[MSG_LAST_INDEX] = {
[MSG_CTL_SHIFT] = "shift",
[MSG_CTL_ALTGR] = "altgr",
[MSG_CTL_CONTROL] = "control",
- [MSG_CTL_ALT] = "ault",
+ [MSG_CTL_ALT] = "alt",
[MSG_CTL_LSHIFT] = "l shift",
[MSG_CTL_SPEAKUP] = "speakup",
[MSG_CTL_LCONTROL] = "l control",
diff --git a/drivers/staging/speakup/main.c b/drivers/staging/speakup/main.c
index 92b34e29ad06..40e2488b9679 100644
--- a/drivers/staging/speakup/main.c
+++ b/drivers/staging/speakup/main.c
@@ -1854,7 +1854,7 @@ static void speakup_bits(struct vc_data *vc)
static int handle_goto(struct vc_data *vc, u_char type, u_char ch, u_short key)
{
- static u_char *goto_buf = "\0\0\0\0\0\0";
+ static u_char goto_buf[8];
static int num;
int maxlen, go_pos;
char *cp;
diff --git a/drivers/staging/speakup/selection.c b/drivers/staging/speakup/selection.c
index fe1f405d5d70..0612df06a4bf 100644
--- a/drivers/staging/speakup/selection.c
+++ b/drivers/staging/speakup/selection.c
@@ -68,7 +68,7 @@ int speakup_set_selection(struct tty_struct *tty)
if (spk_sel_cons != vc_cons[fg_console].d) {
speakup_clear_selection();
spk_sel_cons = vc_cons[fg_console].d;
- printk(KERN_WARNING
+ dev_warn(tty->dev,
"Selection: mark console not the same as cut\n");
return -EINVAL;
}
@@ -95,7 +95,7 @@ int speakup_set_selection(struct tty_struct *tty)
/* Allocate a new buffer before freeing the old one ... */
bp = kmalloc((sel_end-sel_start)/2+1, GFP_ATOMIC);
if (!bp) {
- printk(KERN_WARNING "selection: kmalloc() failed\n");
+ dev_warn(tty->dev, "selection: kmalloc() failed\n");
speakup_clear_selection();
return -ENOMEM;
}
@@ -141,7 +141,7 @@ int speakup_paste_selection(struct tty_struct *tty)
count = sel_buffer_lth - pasted;
count = min_t(int, count, tty->receive_room);
tty->ldisc->ops->receive_buf(tty, sel_buffer + pasted,
- 0, count);
+ NULL, count);
pasted += count;
}
remove_wait_queue(&vc->paste_wait, &wait);
diff --git a/drivers/staging/speakup/speakup_acnt.h b/drivers/staging/speakup/speakup_acnt.h
index 2d883654ffcc..6376fca9e0e1 100644
--- a/drivers/staging/speakup/speakup_acnt.h
+++ b/drivers/staging/speakup/speakup_acnt.h
@@ -12,5 +12,5 @@
to accept a byte of data. */
#define SYNTH_QUIET 'S' /* synth is not speaking */
#define SYNTH_FULL 'F' /* synth is full. */
-#define SYNTH_ALMOST_EMPTY 'M' /* synth has les than 2 seconds of text left */
+#define SYNTH_ALMOST_EMPTY 'M' /* synth has less than 2 seconds of text left */
#define SYNTH_SPEAKING 's' /* synth is speaking and has a fare way to go */
diff --git a/drivers/staging/speakup/speakup_decpc.c b/drivers/staging/speakup/speakup_decpc.c
index de25527decf6..a09a0c9975df 100644
--- a/drivers/staging/speakup/speakup_decpc.c
+++ b/drivers/staging/speakup/speakup_decpc.c
@@ -66,7 +66,7 @@
#define CMD_null 0x0000 /* post status */
#define CMD_control 0x1000 /* hard control command */
#define CTRL_mask 0x0F00 /* mask off control nibble */
-#define CTRL_data 0x00FF /* madk to get data byte */
+#define CTRL_data 0x00FF /* mask to get data byte */
#define CTRL_null 0x0000 /* null control */
#define CTRL_vol_up 0x0100 /* increase volume */
#define CTRL_vol_down 0x0200 /* decrease volume */
diff --git a/drivers/staging/speakup/synth.c b/drivers/staging/speakup/synth.c
index 331eae788700..df9533798095 100644
--- a/drivers/staging/speakup/synth.c
+++ b/drivers/staging/speakup/synth.c
@@ -64,7 +64,7 @@ EXPORT_SYMBOL_GPL(serial_synth_probe);
/* Main loop of the progression thread: keep eating from the buffer
* and push to the serial port, waiting as needed
*
- * For devices that have a "full" notification mecanism, the driver can
+ * For devices that have a "full" notification mechanism, the driver can
* adapt the loop the way they prefer.
*/
void spk_do_catch_up(struct spk_synth *synth)
diff --git a/drivers/staging/ste_rmi4/synaptics_i2c_rmi4.c b/drivers/staging/ste_rmi4/synaptics_i2c_rmi4.c
index 11728a03f8a0..277491a877ea 100644
--- a/drivers/staging/ste_rmi4/synaptics_i2c_rmi4.c
+++ b/drivers/staging/ste_rmi4/synaptics_i2c_rmi4.c
@@ -655,13 +655,13 @@ static int synpatics_rmi4_touchpad_detect(struct synaptics_rmi4_data *pdata,
}
/**
- * synpatics_rmi4_touchpad_config() - confiures the rmi4 touchpad device
+ * synaptics_rmi4_touchpad_config() - configures the rmi4 touchpad device
* @pdata: pointer to synaptics_rmi4_data structure
* @rfi: pointer to synaptics_rmi4_fn structure
*
- * This function calls to confiures the rmi4 touchpad device
+ * This function calls to configures the rmi4 touchpad device
*/
-int synpatics_rmi4_touchpad_config(struct synaptics_rmi4_data *pdata,
+int synaptics_rmi4_touchpad_config(struct synaptics_rmi4_data *pdata,
struct synaptics_rmi4_fn *rfi)
{
/*
@@ -855,7 +855,7 @@ static int synaptics_rmi4_i2c_query_device(struct synaptics_rmi4_data *pdata)
if (rfi->num_of_data_sources) {
if (rfi->fn_number ==
SYNAPTICS_RMI4_TOUCHPAD_FUNC_NUM) {
- retval = synpatics_rmi4_touchpad_config
+ retval = synaptics_rmi4_touchpad_config
(pdata, rfi);
if (retval < 0)
return retval;
diff --git a/drivers/staging/telephony/ixj.c b/drivers/staging/telephony/ixj.c
index f96027921f60..b303c9192e17 100644
--- a/drivers/staging/telephony/ixj.c
+++ b/drivers/staging/telephony/ixj.c
@@ -19,20 +19,20 @@
* David W. Erhart, <derhart@quicknet.net>
* John Sellers, <jsellers@quicknet.net>
* Mike Preston, <mpreston@quicknet.net>
- *
+ *
* Fixes: David Huggins-Daines, <dhd@cepstral.com>
* Fabio Ferrari, <fabio.ferrari@digitro.com.br>
* Artis Kugevics, <artis@mt.lv>
* Daniele Bellucci, <bellucda@tiscali.it>
*
- * More information about the hardware related to this driver can be found
+ * More information about the hardware related to this driver can be found
* at our website: http://www.quicknet.net
*
* IN NO EVENT SHALL QUICKNET TECHNOLOGIES, INC. BE LIABLE TO ANY PARTY FOR
* DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
* OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF QUICKNET
* TECHNOLOGIES, INC. HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
+ *
* QUICKNET TECHNOLOGIES, INC. SPECIFICALLY DISCLAIMS ANY WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
@@ -317,7 +317,7 @@ static IXJ *ixj[IXJMAX];
/*
* Allocate a free IXJ device
*/
-
+
static IXJ *ixj_alloc()
{
for(cnt=0; cnt<IXJMAX; cnt++)
@@ -366,7 +366,7 @@ static IXJ ixj[IXJMAX];
/*
* Allocate a free IXJ device
*/
-
+
static IXJ *ixj_alloc(void)
{
int cnt;
@@ -1084,7 +1084,7 @@ static void ixj_pstn_state(IXJ *j)
printk(KERN_INFO "IXJ /dev/phone%d Next Ring Cadence state at %u min %ld - %ld - max %ld\n", j->board,
j->cadence_f[4].on3, j->cadence_f[4].on3min, j->cadence_f[4].on3dot, j->cadence_f[4].on3max);
break;
- case 6:
+ case 6:
printk(KERN_INFO "IXJ /dev/phone%d Next Ring Cadence state at %u min %ld - %ld - max %ld\n", j->board,
j->cadence_f[4].off3, j->cadence_f[4].off3min, j->cadence_f[4].off3dot, j->cadence_f[4].off3max);
break;
@@ -1109,7 +1109,7 @@ static void ixj_pstn_state(IXJ *j)
}
j->pstn_ring_stop = j->pstn_ring_int = 0;
daa_set_mode(j, SOP_PU_SLEEP);
- }
+ }
outb_p(j->pld_scrw.byte, j->XILINXbase);
if (j->pstn_cid_intr && time_after(jiffies, j->pstn_cid_received + hertz)) {
ixj_daa_cid_read(j);
@@ -1133,7 +1133,7 @@ static void ixj_pstn_state(IXJ *j)
printk("IXJ DAA possible wink /dev/phone%d %ld\n", j->board, jiffies);
}
j->pstn_winkstart = jiffies;
- }
+ }
} else {
if (j->pstn_winkstart) {
if(ixjdebug & 0x0008) {
@@ -1524,7 +1524,7 @@ static inline void LED_SetState(int state, IXJ *j)
/*********************************************************************
* GPIO Pins are configured as follows on the Quicknet Internet
* PhoneJACK Telephony Cards
-*
+*
* POTS Select GPIO_6=0 GPIO_7=0
* Mic/Speaker Select GPIO_6=0 GPIO_7=1
* Handset Select GPIO_6=1 GPIO_7=0
@@ -1932,7 +1932,7 @@ static int ixj_hookstate(IXJ *j)
if(fOffHook != j->p_hook) {
if(!j->checkwait) {
j->checkwait = jiffies;
- }
+ }
if(time_before(jiffies, j->checkwait + 2)) {
fOffHook ^= 1;
} else {
@@ -2342,8 +2342,8 @@ static int ixj_release(struct inode *inode, struct file *file_p)
j->ixj_signals[cnt] = SIGIO;
/* Set the excetion signal enable flags */
- j->ex_sig.bits.dtmf_ready = j->ex_sig.bits.hookstate = j->ex_sig.bits.flash = j->ex_sig.bits.pstn_ring =
- j->ex_sig.bits.caller_id = j->ex_sig.bits.pstn_wink = j->ex_sig.bits.f0 = j->ex_sig.bits.f1 = j->ex_sig.bits.f2 =
+ j->ex_sig.bits.dtmf_ready = j->ex_sig.bits.hookstate = j->ex_sig.bits.flash = j->ex_sig.bits.pstn_ring =
+ j->ex_sig.bits.caller_id = j->ex_sig.bits.pstn_wink = j->ex_sig.bits.f0 = j->ex_sig.bits.f1 = j->ex_sig.bits.f2 =
j->ex_sig.bits.f3 = j->ex_sig.bits.fc0 = j->ex_sig.bits.fc1 = j->ex_sig.bits.fc2 = j->ex_sig.bits.fc3 = 1;
file_p->private_data = NULL;
@@ -2506,7 +2506,7 @@ static int read_filters(IXJ *j)
j->cadence_f[cnt].on1, j->cadence_f[cnt].on1min, j->cadence_f[cnt].on1dot, j->cadence_f[cnt].on1max);
break;
case 2:
- printk(KERN_INFO "IXJ /dev/phone%d Next Tone Cadence state at %ld - %ld\n", j->board, j->cadence_f[cnt].off1min,
+ printk(KERN_INFO "IXJ /dev/phone%d Next Tone Cadence state at %ld - %ld\n", j->board, j->cadence_f[cnt].off1min,
j->cadence_f[cnt].off1max);
break;
case 3:
@@ -2521,12 +2521,12 @@ static int read_filters(IXJ *j)
printk(KERN_INFO "IXJ /dev/phone%d Next Tone Cadence state at %ld - %ld\n", j->board, j->cadence_f[cnt].on3min,
j->cadence_f[cnt].on3max);
break;
- case 6:
+ case 6:
printk(KERN_INFO "IXJ /dev/phone%d Next Tone Cadence state at %ld - %ld\n", j->board, j->cadence_f[cnt].off3min,
j->cadence_f[cnt].off3max);
break;
}
- }
+ }
}
if (j->cadence_f[cnt].state == 7) {
j->cadence_f[cnt].state = 0;
@@ -2656,37 +2656,37 @@ static void ulaw2alaw(unsigned char *buff, unsigned long len)
{
static unsigned char table_ulaw2alaw[] =
{
- 0x2A, 0x2B, 0x28, 0x29, 0x2E, 0x2F, 0x2C, 0x2D,
- 0x22, 0x23, 0x20, 0x21, 0x26, 0x27, 0x24, 0x25,
- 0x3A, 0x3B, 0x38, 0x39, 0x3E, 0x3F, 0x3C, 0x3D,
- 0x32, 0x33, 0x30, 0x31, 0x36, 0x37, 0x34, 0x35,
- 0x0B, 0x08, 0x09, 0x0E, 0x0F, 0x0C, 0x0D, 0x02,
- 0x03, 0x00, 0x01, 0x06, 0x07, 0x04, 0x05, 0x1A,
- 0x1B, 0x18, 0x19, 0x1E, 0x1F, 0x1C, 0x1D, 0x12,
- 0x13, 0x10, 0x11, 0x16, 0x17, 0x14, 0x15, 0x6B,
- 0x68, 0x69, 0x6E, 0x6F, 0x6C, 0x6D, 0x62, 0x63,
- 0x60, 0x61, 0x66, 0x67, 0x64, 0x65, 0x7B, 0x79,
- 0x7E, 0x7F, 0x7C, 0x7D, 0x72, 0x73, 0x70, 0x71,
- 0x76, 0x77, 0x74, 0x75, 0x4B, 0x49, 0x4F, 0x4D,
- 0x42, 0x43, 0x40, 0x41, 0x46, 0x47, 0x44, 0x45,
- 0x5A, 0x5B, 0x58, 0x59, 0x5E, 0x5F, 0x5C, 0x5D,
- 0x52, 0x52, 0x53, 0x53, 0x50, 0x50, 0x51, 0x51,
- 0x56, 0x56, 0x57, 0x57, 0x54, 0x54, 0x55, 0xD5,
- 0xAA, 0xAB, 0xA8, 0xA9, 0xAE, 0xAF, 0xAC, 0xAD,
- 0xA2, 0xA3, 0xA0, 0xA1, 0xA6, 0xA7, 0xA4, 0xA5,
- 0xBA, 0xBB, 0xB8, 0xB9, 0xBE, 0xBF, 0xBC, 0xBD,
- 0xB2, 0xB3, 0xB0, 0xB1, 0xB6, 0xB7, 0xB4, 0xB5,
- 0x8B, 0x88, 0x89, 0x8E, 0x8F, 0x8C, 0x8D, 0x82,
- 0x83, 0x80, 0x81, 0x86, 0x87, 0x84, 0x85, 0x9A,
- 0x9B, 0x98, 0x99, 0x9E, 0x9F, 0x9C, 0x9D, 0x92,
- 0x93, 0x90, 0x91, 0x96, 0x97, 0x94, 0x95, 0xEB,
- 0xE8, 0xE9, 0xEE, 0xEF, 0xEC, 0xED, 0xE2, 0xE3,
- 0xE0, 0xE1, 0xE6, 0xE7, 0xE4, 0xE5, 0xFB, 0xF9,
- 0xFE, 0xFF, 0xFC, 0xFD, 0xF2, 0xF3, 0xF0, 0xF1,
- 0xF6, 0xF7, 0xF4, 0xF5, 0xCB, 0xC9, 0xCF, 0xCD,
- 0xC2, 0xC3, 0xC0, 0xC1, 0xC6, 0xC7, 0xC4, 0xC5,
- 0xDA, 0xDB, 0xD8, 0xD9, 0xDE, 0xDF, 0xDC, 0xDD,
- 0xD2, 0xD2, 0xD3, 0xD3, 0xD0, 0xD0, 0xD1, 0xD1,
+ 0x2A, 0x2B, 0x28, 0x29, 0x2E, 0x2F, 0x2C, 0x2D,
+ 0x22, 0x23, 0x20, 0x21, 0x26, 0x27, 0x24, 0x25,
+ 0x3A, 0x3B, 0x38, 0x39, 0x3E, 0x3F, 0x3C, 0x3D,
+ 0x32, 0x33, 0x30, 0x31, 0x36, 0x37, 0x34, 0x35,
+ 0x0B, 0x08, 0x09, 0x0E, 0x0F, 0x0C, 0x0D, 0x02,
+ 0x03, 0x00, 0x01, 0x06, 0x07, 0x04, 0x05, 0x1A,
+ 0x1B, 0x18, 0x19, 0x1E, 0x1F, 0x1C, 0x1D, 0x12,
+ 0x13, 0x10, 0x11, 0x16, 0x17, 0x14, 0x15, 0x6B,
+ 0x68, 0x69, 0x6E, 0x6F, 0x6C, 0x6D, 0x62, 0x63,
+ 0x60, 0x61, 0x66, 0x67, 0x64, 0x65, 0x7B, 0x79,
+ 0x7E, 0x7F, 0x7C, 0x7D, 0x72, 0x73, 0x70, 0x71,
+ 0x76, 0x77, 0x74, 0x75, 0x4B, 0x49, 0x4F, 0x4D,
+ 0x42, 0x43, 0x40, 0x41, 0x46, 0x47, 0x44, 0x45,
+ 0x5A, 0x5B, 0x58, 0x59, 0x5E, 0x5F, 0x5C, 0x5D,
+ 0x52, 0x52, 0x53, 0x53, 0x50, 0x50, 0x51, 0x51,
+ 0x56, 0x56, 0x57, 0x57, 0x54, 0x54, 0x55, 0xD5,
+ 0xAA, 0xAB, 0xA8, 0xA9, 0xAE, 0xAF, 0xAC, 0xAD,
+ 0xA2, 0xA3, 0xA0, 0xA1, 0xA6, 0xA7, 0xA4, 0xA5,
+ 0xBA, 0xBB, 0xB8, 0xB9, 0xBE, 0xBF, 0xBC, 0xBD,
+ 0xB2, 0xB3, 0xB0, 0xB1, 0xB6, 0xB7, 0xB4, 0xB5,
+ 0x8B, 0x88, 0x89, 0x8E, 0x8F, 0x8C, 0x8D, 0x82,
+ 0x83, 0x80, 0x81, 0x86, 0x87, 0x84, 0x85, 0x9A,
+ 0x9B, 0x98, 0x99, 0x9E, 0x9F, 0x9C, 0x9D, 0x92,
+ 0x93, 0x90, 0x91, 0x96, 0x97, 0x94, 0x95, 0xEB,
+ 0xE8, 0xE9, 0xEE, 0xEF, 0xEC, 0xED, 0xE2, 0xE3,
+ 0xE0, 0xE1, 0xE6, 0xE7, 0xE4, 0xE5, 0xFB, 0xF9,
+ 0xFE, 0xFF, 0xFC, 0xFD, 0xF2, 0xF3, 0xF0, 0xF1,
+ 0xF6, 0xF7, 0xF4, 0xF5, 0xCB, 0xC9, 0xCF, 0xCD,
+ 0xC2, 0xC3, 0xC0, 0xC1, 0xC6, 0xC7, 0xC4, 0xC5,
+ 0xDA, 0xDB, 0xD8, 0xD9, 0xDE, 0xDF, 0xDC, 0xDD,
+ 0xD2, 0xD2, 0xD3, 0xD3, 0xD0, 0xD0, 0xD1, 0xD1,
0xD6, 0xD6, 0xD7, 0xD7, 0xD4, 0xD4, 0xD5, 0xD5
};
@@ -2701,37 +2701,37 @@ static void alaw2ulaw(unsigned char *buff, unsigned long len)
{
static unsigned char table_alaw2ulaw[] =
{
- 0x29, 0x2A, 0x27, 0x28, 0x2D, 0x2E, 0x2B, 0x2C,
- 0x21, 0x22, 0x1F, 0x20, 0x25, 0x26, 0x23, 0x24,
- 0x39, 0x3A, 0x37, 0x38, 0x3D, 0x3E, 0x3B, 0x3C,
- 0x31, 0x32, 0x2F, 0x30, 0x35, 0x36, 0x33, 0x34,
- 0x0A, 0x0B, 0x08, 0x09, 0x0E, 0x0F, 0x0C, 0x0D,
- 0x02, 0x03, 0x00, 0x01, 0x06, 0x07, 0x04, 0x05,
- 0x1A, 0x1B, 0x18, 0x19, 0x1E, 0x1F, 0x1C, 0x1D,
- 0x12, 0x13, 0x10, 0x11, 0x16, 0x17, 0x14, 0x15,
- 0x62, 0x63, 0x60, 0x61, 0x66, 0x67, 0x64, 0x65,
- 0x5D, 0x5D, 0x5C, 0x5C, 0x5F, 0x5F, 0x5E, 0x5E,
- 0x74, 0x76, 0x70, 0x72, 0x7C, 0x7E, 0x78, 0x7A,
- 0x6A, 0x6B, 0x68, 0x69, 0x6E, 0x6F, 0x6C, 0x6D,
- 0x48, 0x49, 0x46, 0x47, 0x4C, 0x4D, 0x4A, 0x4B,
- 0x40, 0x41, 0x3F, 0x3F, 0x44, 0x45, 0x42, 0x43,
- 0x56, 0x57, 0x54, 0x55, 0x5A, 0x5B, 0x58, 0x59,
- 0x4F, 0x4F, 0x4E, 0x4E, 0x52, 0x53, 0x50, 0x51,
- 0xA9, 0xAA, 0xA7, 0xA8, 0xAD, 0xAE, 0xAB, 0xAC,
- 0xA1, 0xA2, 0x9F, 0xA0, 0xA5, 0xA6, 0xA3, 0xA4,
- 0xB9, 0xBA, 0xB7, 0xB8, 0xBD, 0xBE, 0xBB, 0xBC,
- 0xB1, 0xB2, 0xAF, 0xB0, 0xB5, 0xB6, 0xB3, 0xB4,
- 0x8A, 0x8B, 0x88, 0x89, 0x8E, 0x8F, 0x8C, 0x8D,
- 0x82, 0x83, 0x80, 0x81, 0x86, 0x87, 0x84, 0x85,
- 0x9A, 0x9B, 0x98, 0x99, 0x9E, 0x9F, 0x9C, 0x9D,
- 0x92, 0x93, 0x90, 0x91, 0x96, 0x97, 0x94, 0x95,
- 0xE2, 0xE3, 0xE0, 0xE1, 0xE6, 0xE7, 0xE4, 0xE5,
- 0xDD, 0xDD, 0xDC, 0xDC, 0xDF, 0xDF, 0xDE, 0xDE,
- 0xF4, 0xF6, 0xF0, 0xF2, 0xFC, 0xFE, 0xF8, 0xFA,
- 0xEA, 0xEB, 0xE8, 0xE9, 0xEE, 0xEF, 0xEC, 0xED,
- 0xC8, 0xC9, 0xC6, 0xC7, 0xCC, 0xCD, 0xCA, 0xCB,
- 0xC0, 0xC1, 0xBF, 0xBF, 0xC4, 0xC5, 0xC2, 0xC3,
- 0xD6, 0xD7, 0xD4, 0xD5, 0xDA, 0xDB, 0xD8, 0xD9,
+ 0x29, 0x2A, 0x27, 0x28, 0x2D, 0x2E, 0x2B, 0x2C,
+ 0x21, 0x22, 0x1F, 0x20, 0x25, 0x26, 0x23, 0x24,
+ 0x39, 0x3A, 0x37, 0x38, 0x3D, 0x3E, 0x3B, 0x3C,
+ 0x31, 0x32, 0x2F, 0x30, 0x35, 0x36, 0x33, 0x34,
+ 0x0A, 0x0B, 0x08, 0x09, 0x0E, 0x0F, 0x0C, 0x0D,
+ 0x02, 0x03, 0x00, 0x01, 0x06, 0x07, 0x04, 0x05,
+ 0x1A, 0x1B, 0x18, 0x19, 0x1E, 0x1F, 0x1C, 0x1D,
+ 0x12, 0x13, 0x10, 0x11, 0x16, 0x17, 0x14, 0x15,
+ 0x62, 0x63, 0x60, 0x61, 0x66, 0x67, 0x64, 0x65,
+ 0x5D, 0x5D, 0x5C, 0x5C, 0x5F, 0x5F, 0x5E, 0x5E,
+ 0x74, 0x76, 0x70, 0x72, 0x7C, 0x7E, 0x78, 0x7A,
+ 0x6A, 0x6B, 0x68, 0x69, 0x6E, 0x6F, 0x6C, 0x6D,
+ 0x48, 0x49, 0x46, 0x47, 0x4C, 0x4D, 0x4A, 0x4B,
+ 0x40, 0x41, 0x3F, 0x3F, 0x44, 0x45, 0x42, 0x43,
+ 0x56, 0x57, 0x54, 0x55, 0x5A, 0x5B, 0x58, 0x59,
+ 0x4F, 0x4F, 0x4E, 0x4E, 0x52, 0x53, 0x50, 0x51,
+ 0xA9, 0xAA, 0xA7, 0xA8, 0xAD, 0xAE, 0xAB, 0xAC,
+ 0xA1, 0xA2, 0x9F, 0xA0, 0xA5, 0xA6, 0xA3, 0xA4,
+ 0xB9, 0xBA, 0xB7, 0xB8, 0xBD, 0xBE, 0xBB, 0xBC,
+ 0xB1, 0xB2, 0xAF, 0xB0, 0xB5, 0xB6, 0xB3, 0xB4,
+ 0x8A, 0x8B, 0x88, 0x89, 0x8E, 0x8F, 0x8C, 0x8D,
+ 0x82, 0x83, 0x80, 0x81, 0x86, 0x87, 0x84, 0x85,
+ 0x9A, 0x9B, 0x98, 0x99, 0x9E, 0x9F, 0x9C, 0x9D,
+ 0x92, 0x93, 0x90, 0x91, 0x96, 0x97, 0x94, 0x95,
+ 0xE2, 0xE3, 0xE0, 0xE1, 0xE6, 0xE7, 0xE4, 0xE5,
+ 0xDD, 0xDD, 0xDC, 0xDC, 0xDF, 0xDF, 0xDE, 0xDE,
+ 0xF4, 0xF6, 0xF0, 0xF2, 0xFC, 0xFE, 0xF8, 0xFA,
+ 0xEA, 0xEB, 0xE8, 0xE9, 0xEE, 0xEF, 0xEC, 0xED,
+ 0xC8, 0xC9, 0xC6, 0xC7, 0xCC, 0xCD, 0xCA, 0xCB,
+ 0xC0, 0xC1, 0xBF, 0xBF, 0xC4, 0xC5, 0xC2, 0xC3,
+ 0xD6, 0xD7, 0xD4, 0xD5, 0xDA, 0xDB, 0xD8, 0xD9,
0xCF, 0xCF, 0xCE, 0xCE, 0xD2, 0xD3, 0xD0, 0xD1
};
@@ -3090,7 +3090,7 @@ static int ixj_write_cid_string(IXJ *j, char *s, int checksum)
static void ixj_pad_fsk(IXJ *j, int pad)
{
- int cnt;
+ int cnt;
for (cnt = 0; cnt < pad; cnt++) {
if(j->fskdcnt < (j->fsksize - 1))
@@ -3474,7 +3474,7 @@ static void ixj_write_frame(IXJ *j)
ixj_post_cid(j);
}
/* This may seem rude, but if we just played one frame of FSK data for CallerID
- and there is real audio data in the buffer, we need to throw it away because
+ and there is real audio data in the buffer, we need to throw it away because
we just used it's time slot */
if (j->write_buffer_rp > j->write_buffer_wp) {
j->write_buffer_rp += j->cid_play_frame_size * 2;
@@ -3486,7 +3486,7 @@ static void ixj_write_frame(IXJ *j)
wake_up_interruptible(&j->poll_q); /* Wake any blocked selects */
}
- } else if (j->write_buffer && j->write_buffers_empty < 1) {
+ } else if (j->write_buffer && j->write_buffers_empty < 1) {
if (j->write_buffer_wp > j->write_buffer_rp) {
frame_count =
(j->write_buffer_wp - j->write_buffer_rp) / (j->play_frame_size * 2);
@@ -4150,7 +4150,7 @@ static void ixj_aec_start(IXJ *j, int level)
ixj_WriteDSPCommand(0xCF97, j); /* Set AGC Enable */
ixj_WriteDSPCommand(0x0000, j); /* to off */
-
+
break;
case AEC_MED:
@@ -4161,7 +4161,7 @@ static void ixj_aec_start(IXJ *j, int level)
ixj_WriteDSPCommand(0xCF97, j); /* Set AGC Enable */
ixj_WriteDSPCommand(0x0000, j); /* to off */
-
+
break;
case AEC_HIGH:
@@ -4172,7 +4172,7 @@ static void ixj_aec_start(IXJ *j, int level)
ixj_WriteDSPCommand(0xCF97, j); /* Set AGC Enable */
ixj_WriteDSPCommand(0x0000, j); /* to off */
-
+
break;
case AEC_AGC:
@@ -4197,28 +4197,28 @@ static void ixj_aec_start(IXJ *j, int level)
/* Now we can set the AGC initial parameters and turn it on */
ixj_WriteDSPCommand(0xCF90, j); /* Set AGC Minimum gain */
ixj_WriteDSPCommand(0x0020, j); /* to 0.125 (-18dB) */
-
+
ixj_WriteDSPCommand(0xCF91, j); /* Set AGC Maximum gain */
ixj_WriteDSPCommand(0x1000, j); /* to 16 (24dB) */
-
+
ixj_WriteDSPCommand(0xCF92, j); /* Set AGC start gain */
ixj_WriteDSPCommand(0x0800, j); /* to 8 (+18dB) */
-
+
ixj_WriteDSPCommand(0xCF93, j); /* Set AGC hold time */
ixj_WriteDSPCommand(0x1F40, j); /* to 2 seconds (units are 250us) */
-
+
ixj_WriteDSPCommand(0xCF94, j); /* Set AGC Attack Time Constant */
ixj_WriteDSPCommand(0x0005, j); /* to 8ms */
-
+
ixj_WriteDSPCommand(0xCF95, j); /* Set AGC Decay Time Constant */
ixj_WriteDSPCommand(0x000D, j); /* to 4096ms */
-
+
ixj_WriteDSPCommand(0xCF96, j); /* Set AGC Attack Threshold */
ixj_WriteDSPCommand(0x1200, j); /* to 25% */
-
+
ixj_WriteDSPCommand(0xCF97, j); /* Set AGC Enable */
ixj_WriteDSPCommand(0x0001, j); /* to on */
-
+
break;
case AEC_AUTO:
@@ -4495,7 +4495,7 @@ static int ixj_play_start(IXJ *j)
return -ENOMEM;
}
/* j->write_buffers_empty = 2; */
- j->write_buffers_empty = 1;
+ j->write_buffers_empty = 1;
j->write_buffer_size = j->play_frame_size * 2;
j->write_buffer_end = j->write_buffer + j->play_frame_size * 2;
j->write_buffer_rp = j->write_buffer_wp = j->write_buffer;
@@ -6465,9 +6465,9 @@ static long do_ixj_ioctl(struct file *file_p, unsigned int cmd, unsigned long ar
ixj_ringback(j);
break;
case PHONE_WINK:
- if(j->cardtype == QTI_PHONEJACK)
+ if(j->cardtype == QTI_PHONEJACK)
retval = -1;
- else
+ else
retval = ixj_wink(j);
break;
case PHONE_CPT_STOP:
@@ -6553,7 +6553,7 @@ static long do_ixj_ioctl(struct file *file_p, unsigned int cmd, unsigned long ar
ixj_write_vmwi(j, arg);
break;
case IXJCTL_CID:
- if (copy_to_user(argp, &j->cid, sizeof(PHONE_CID)))
+ if (copy_to_user(argp, &j->cid, sizeof(PHONE_CID)))
retval = -EFAULT;
j->ex.bits.caller_id = 0;
break;
@@ -6575,13 +6575,13 @@ static long do_ixj_ioctl(struct file *file_p, unsigned int cmd, unsigned long ar
break;
case PHONE_CAPABILITIES_LIST:
add_caps(j);
- if (copy_to_user(argp, j->caplist, sizeof(struct phone_capability) * j->caps))
+ if (copy_to_user(argp, j->caplist, sizeof(struct phone_capability) * j->caps))
retval = -EFAULT;
break;
case PHONE_CAPABILITIES_CHECK:
{
struct phone_capability cap;
- if (copy_from_user(&cap, argp, sizeof(cap)))
+ if (copy_from_user(&cap, argp, sizeof(cap)))
retval = -EFAULT;
else {
add_caps(j);
@@ -6597,13 +6597,13 @@ static long do_ixj_ioctl(struct file *file_p, unsigned int cmd, unsigned long ar
j->ex.bits.pstn_ring = 0;
break;
case IXJCTL_SET_FILTER:
- if (copy_from_user(&jf, argp, sizeof(jf)))
+ if (copy_from_user(&jf, argp, sizeof(jf)))
retval = -EFAULT;
else
retval = ixj_init_filter(j, &jf);
break;
case IXJCTL_SET_FILTER_RAW:
- if (copy_from_user(&jfr, argp, sizeof(jfr)))
+ if (copy_from_user(&jfr, argp, sizeof(jfr)))
retval = -EFAULT;
else
retval = ixj_init_filter_raw(j, &jfr);
@@ -6638,9 +6638,9 @@ static long do_ixj_ioctl(struct file *file_p, unsigned int cmd, unsigned long ar
raise *= 2;
}
if(j->sigdef.signal)
- j->ex_sig.bytes |= raise;
+ j->ex_sig.bytes |= raise;
else
- j->ex_sig.bytes &= (raise^0xffff);
+ j->ex_sig.bytes &= (raise^0xffff);
}
break;
case IXJCTL_INTERCOM_STOP:
@@ -7040,9 +7040,9 @@ static int ixj_selfprobe(IXJ *j)
/* initialise the DTMF prescale to a sensible value */
if (j->cardtype == QTI_LINEJACK) {
- set_dtmf_prescale(j, 0x10);
+ set_dtmf_prescale(j, 0x10);
} else {
- set_dtmf_prescale(j, 0x40);
+ set_dtmf_prescale(j, 0x40);
}
set_play_volume(j, 0x100);
set_rec_volume(j, 0x100);
@@ -7094,16 +7094,16 @@ static int ixj_selfprobe(IXJ *j)
for (cnt = 0; cnt < 35; cnt++)
j->ixj_signals[cnt] = SIGIO;
- /* Set the excetion signal enable flags */
- j->ex_sig.bits.dtmf_ready = j->ex_sig.bits.hookstate = j->ex_sig.bits.flash = j->ex_sig.bits.pstn_ring =
- j->ex_sig.bits.caller_id = j->ex_sig.bits.pstn_wink = j->ex_sig.bits.f0 = j->ex_sig.bits.f1 = j->ex_sig.bits.f2 =
+ /* Set the exception signal enable flags */
+ j->ex_sig.bits.dtmf_ready = j->ex_sig.bits.hookstate = j->ex_sig.bits.flash = j->ex_sig.bits.pstn_ring =
+ j->ex_sig.bits.caller_id = j->ex_sig.bits.pstn_wink = j->ex_sig.bits.f0 = j->ex_sig.bits.f1 = j->ex_sig.bits.f2 =
j->ex_sig.bits.f3 = j->ex_sig.bits.fc0 = j->ex_sig.bits.fc1 = j->ex_sig.bits.fc2 = j->ex_sig.bits.fc3 = 1;
#ifdef IXJ_DYN_ALLOC
j->fskdata = NULL;
#endif
j->fskdcnt = 0;
j->cidcw_wait = 0;
-
+
/* Register with the Telephony for Linux subsystem */
j->p.f_op = &ixj_fops;
j->p.open = ixj_open;
@@ -7118,7 +7118,7 @@ static int ixj_selfprobe(IXJ *j)
/*
* Exported service for pcmcia card handling
*/
-
+
IXJ *ixj_pcmcia_probe(unsigned long dsp, unsigned long xilinx)
{
IXJ *j = ixj_alloc();
@@ -7132,7 +7132,7 @@ IXJ *ixj_pcmcia_probe(unsigned long dsp, unsigned long xilinx)
return j;
}
-EXPORT_SYMBOL(ixj_pcmcia_probe); /* Fpr PCMCIA */
+EXPORT_SYMBOL(ixj_pcmcia_probe); /* For PCMCIA */
static int ixj_get_status_proc(char *buf)
{
@@ -7320,7 +7320,7 @@ static int ixj_get_status_proc(char *buf)
len += sprintf(buf + len, "\nRec volume 0x%x", get_rec_volume(j));
len += sprintf(buf + len, "\nPlay volume 0x%x", get_play_volume(j));
len += sprintf(buf + len, "\nDTMF prescale 0x%x", get_dtmf_prescale(j));
-
+
len += sprintf(buf + len, "\nHook state %d", j->hookstate); /* j->r_hook); */
if (j->cardtype == QTI_LINEJACK) {
@@ -7417,7 +7417,7 @@ static int ixj_get_status_proc(char *buf)
len += sprintf(buf + len, "\nPControl Wait Fails %ld", j->pcontrolwaitfail);
len += sprintf(buf + len, "\nIs Control Ready Checks %ld", j->iscontrolready);
len += sprintf(buf + len, "\nIs Control Ready Check failures %ld", j->iscontrolreadyfail);
-
+
#endif
len += sprintf(buf + len, "\n");
}
@@ -7608,7 +7608,7 @@ static IXJ *new_ixj(unsigned long port)
}
static int __init ixj_probe_isapnp(int *cnt)
-{
+{
int probe = 0;
int func = 0x110;
struct pnp_dev *dev = NULL, *old_dev = NULL;
@@ -7686,7 +7686,7 @@ static int __init ixj_probe_isapnp(int *cnt)
}
return probe;
}
-
+
static int __init ixj_probe_isa(int *cnt)
{
int i, probe;
@@ -7713,7 +7713,7 @@ static int __init ixj_probe_isa(int *cnt)
static int __init ixj_probe_pci(int *cnt)
{
- struct pci_dev *pci = NULL;
+ struct pci_dev *pci = NULL;
int i, probe = 0;
IXJ *j = NULL;
@@ -7745,7 +7745,7 @@ static int __init ixj_probe_pci(int *cnt)
static int __init ixj_init(void)
{
int cnt = 0;
- int probe = 0;
+ int probe = 0;
cnt = 0;
@@ -7887,7 +7887,7 @@ static void DAA_Coeff_US(IXJ *j)
/* j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[2] = 0x2D; */
/* j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[1] = 0x62; */
/* j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_1[0] = 0x2D; */
- /* Bytes for Ringing part 2 (06):13,42,A6,BA,D4,73,CA,D5 */
+ /* Bytes for Ringing part 2 (06):13,42,A6,BA,D4,73,CA,D5 */
/* j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[7] = 0x2D; */
/* j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[6] = 0x62; */
/* j->m_DAAShadowRegs.COP_REGS.COP.RingerImpendance_2[5] = 0xA6; */
diff --git a/drivers/staging/tidspbridge/core/io_sm.c b/drivers/staging/tidspbridge/core/io_sm.c
index 9b50b5bd4edb..480a3845a24c 100644
--- a/drivers/staging/tidspbridge/core/io_sm.c
+++ b/drivers/staging/tidspbridge/core/io_sm.c
@@ -128,6 +128,16 @@ struct io_mgr {
};
+struct shm_symbol_val {
+ u32 shm_base;
+ u32 shm_lim;
+ u32 msg_base;
+ u32 msg_lim;
+ u32 shm0_end;
+ u32 dyn_ext;
+ u32 ext_end;
+};
+
/* Function Prototypes */
static void io_dispatch_pm(struct io_mgr *pio_mgr);
static void notify_chnl_complete(struct chnl_object *pchnl,
@@ -256,6 +266,75 @@ int bridge_io_destroy(struct io_mgr *hio_mgr)
return status;
}
+struct shm_symbol_val *_get_shm_symbol_values(struct io_mgr *hio_mgr)
+{
+ struct shm_symbol_val *s;
+ struct cod_manager *cod_man;
+ int status;
+
+ s = kzalloc(sizeof(*s), GFP_KERNEL);
+ if (!s)
+ return ERR_PTR(-ENOMEM);
+
+ status = dev_get_cod_mgr(hio_mgr->dev_obj, &cod_man);
+ if (status)
+ goto free_symbol;
+
+ /* Get start and length of channel part of shared memory */
+ status = cod_get_sym_value(cod_man, CHNL_SHARED_BUFFER_BASE_SYM,
+ &s->shm_base);
+ if (status)
+ goto free_symbol;
+
+ status = cod_get_sym_value(cod_man, CHNL_SHARED_BUFFER_LIMIT_SYM,
+ &s->shm_lim);
+ if (status)
+ goto free_symbol;
+
+ if (s->shm_lim <= s->shm_base) {
+ status = -EINVAL;
+ goto free_symbol;
+ }
+
+ /* Get start and length of message part of shared memory */
+ status = cod_get_sym_value(cod_man, MSG_SHARED_BUFFER_BASE_SYM,
+ &s->msg_base);
+ if (status)
+ goto free_symbol;
+
+ status = cod_get_sym_value(cod_man, MSG_SHARED_BUFFER_LIMIT_SYM,
+ &s->msg_lim);
+ if (status)
+ goto free_symbol;
+
+ if (s->msg_lim <= s->msg_base) {
+ status = -EINVAL;
+ goto free_symbol;
+ }
+
+#ifdef CONFIG_TIDSPBRIDGE_BACKTRACE
+ status = cod_get_sym_value(cod_man, DSP_TRACESEC_END, &s->shm0_end);
+#else
+ status = cod_get_sym_value(cod_man, SHM0_SHARED_END_SYM, &s->shm0_end);
+#endif
+ if (status)
+ goto free_symbol;
+
+ status = cod_get_sym_value(cod_man, DYNEXTBASE, &s->dyn_ext);
+ if (status)
+ goto free_symbol;
+
+ status = cod_get_sym_value(cod_man, EXTEND, &s->ext_end);
+ if (status)
+ goto free_symbol;
+
+ return s;
+
+free_symbol:
+ kfree(s);
+ return ERR_PTR(status);
+}
+
/*
* ======== bridge_io_on_loaded ========
* Purpose:
@@ -265,193 +344,112 @@ int bridge_io_destroy(struct io_mgr *hio_mgr)
*/
int bridge_io_on_loaded(struct io_mgr *hio_mgr)
{
+ struct bridge_dev_context *dc = hio_mgr->bridge_context;
+ struct cfg_hostres *cfg_res = dc->resources;
+ struct bridge_ioctl_extproc *eproc;
struct cod_manager *cod_man;
struct chnl_mgr *hchnl_mgr;
struct msg_mgr *hmsg_mgr;
- u32 ul_shm_base;
- u32 ul_shm_base_offset;
- u32 ul_shm_limit;
- u32 ul_shm_length = -1;
- u32 ul_mem_length = -1;
- u32 ul_msg_base;
- u32 ul_msg_limit;
- u32 ul_msg_length = -1;
- u32 ul_ext_end;
- u32 ul_gpp_pa = 0;
- u32 ul_gpp_va = 0;
- u32 ul_dsp_va = 0;
- u32 ul_seg_size = 0;
- u32 ul_pad_size = 0;
+ struct shm_symbol_val *s;
+ int status;
+ u8 num_procs;
+ s32 ndx;
u32 i;
- int status = 0;
- u8 num_procs = 0;
- s32 ndx = 0;
- /* DSP MMU setup table */
- struct bridge_ioctl_extproc ae_proc[BRDIOCTL_NUMOFMMUTLB];
- struct cfg_hostres *host_res;
- struct bridge_dev_context *pbridge_context;
- u32 map_attrs;
- u32 shm0_end;
- u32 ul_dyn_ext_base;
- u32 ul_seg1_size = 0;
- u32 pa_curr = 0;
- u32 va_curr = 0;
- u32 gpp_va_curr = 0;
- u32 num_bytes = 0;
+ u32 mem_sz, msg_sz, pad_sz, shm_sz, shm_base_offs;
+ u32 seg0_sz, seg1_sz;
+ u32 pa, va, da;
+ u32 pa_curr, va_curr, da_curr;
+ u32 bytes;
u32 all_bits = 0;
- u32 page_size[] = { HW_PAGE_SIZE16MB, HW_PAGE_SIZE1MB,
+ u32 page_size[] = {
+ HW_PAGE_SIZE16MB, HW_PAGE_SIZE1MB,
HW_PAGE_SIZE64KB, HW_PAGE_SIZE4KB
};
+ u32 map_attrs = DSP_MAPLITTLEENDIAN | DSP_MAPPHYSICALADDR |
+ DSP_MAPELEMSIZE32 | DSP_MAPDONOTLOCK;
- status = dev_get_bridge_context(hio_mgr->dev_obj, &pbridge_context);
- if (!pbridge_context) {
- status = -EFAULT;
- goto func_end;
- }
-
- host_res = pbridge_context->resources;
- if (!host_res) {
- status = -EFAULT;
- goto func_end;
- }
status = dev_get_cod_mgr(hio_mgr->dev_obj, &cod_man);
- if (!cod_man) {
- status = -EFAULT;
- goto func_end;
- }
+ if (status)
+ return status;
+
hchnl_mgr = hio_mgr->chnl_mgr;
- /* The message manager is destroyed when the board is stopped. */
+
+ /* The message manager is destroyed when the board is stopped */
dev_get_msg_mgr(hio_mgr->dev_obj, &hio_mgr->msg_mgr);
hmsg_mgr = hio_mgr->msg_mgr;
- if (!hchnl_mgr || !hmsg_mgr) {
- status = -EFAULT;
- goto func_end;
- }
+ if (!hchnl_mgr || !hmsg_mgr)
+ return -EFAULT;
+
if (hio_mgr->shared_mem)
hio_mgr->shared_mem = NULL;
- /* Get start and length of channel part of shared memory */
- status = cod_get_sym_value(cod_man, CHNL_SHARED_BUFFER_BASE_SYM,
- &ul_shm_base);
- if (status) {
- status = -EFAULT;
- goto func_end;
- }
- status = cod_get_sym_value(cod_man, CHNL_SHARED_BUFFER_LIMIT_SYM,
- &ul_shm_limit);
- if (status) {
- status = -EFAULT;
- goto func_end;
- }
- if (ul_shm_limit <= ul_shm_base) {
- status = -EINVAL;
- goto func_end;
- }
+ s = _get_shm_symbol_values(hio_mgr);
+ if (IS_ERR(s))
+ return PTR_ERR(s);
+
/* Get total length in bytes */
- ul_shm_length = (ul_shm_limit - ul_shm_base + 1) * hio_mgr->word_size;
+ shm_sz = (s->shm_lim - s->shm_base + 1) * hio_mgr->word_size;
+
/* Calculate size of a PROCCOPY shared memory region */
dev_dbg(bridge, "%s: (proc)proccopy shmmem size: 0x%x bytes\n",
- __func__, (ul_shm_length - sizeof(struct shm)));
+ __func__, shm_sz - sizeof(struct shm));
- /* Get start and length of message part of shared memory */
- status = cod_get_sym_value(cod_man, MSG_SHARED_BUFFER_BASE_SYM,
- &ul_msg_base);
- if (!status) {
- status = cod_get_sym_value(cod_man, MSG_SHARED_BUFFER_LIMIT_SYM,
- &ul_msg_limit);
- if (!status) {
- if (ul_msg_limit <= ul_msg_base) {
- status = -EINVAL;
- } else {
- /*
- * Length (bytes) of messaging part of shared
- * memory.
- */
- ul_msg_length =
- (ul_msg_limit - ul_msg_base +
- 1) * hio_mgr->word_size;
- /*
- * Total length (bytes) of shared memory:
- * chnl + msg.
- */
- ul_mem_length = ul_shm_length + ul_msg_length;
- }
- } else {
- status = -EFAULT;
- }
- } else {
- status = -EFAULT;
- }
- if (!status) {
-#if defined(CONFIG_TIDSPBRIDGE_BACKTRACE)
- status =
- cod_get_sym_value(cod_man, DSP_TRACESEC_END, &shm0_end);
-#else
- status = cod_get_sym_value(cod_man, SHM0_SHARED_END_SYM,
- &shm0_end);
-#endif
- if (status)
- status = -EFAULT;
- }
- if (!status) {
- status =
- cod_get_sym_value(cod_man, DYNEXTBASE, &ul_dyn_ext_base);
- if (status)
- status = -EFAULT;
- }
- if (!status) {
- status = cod_get_sym_value(cod_man, EXTEND, &ul_ext_end);
- if (status)
- status = -EFAULT;
+ /* Length (bytes) of messaging part of shared memory */
+ msg_sz = (s->msg_lim - s->msg_base + 1) * hio_mgr->word_size;
+
+ /* Total length (bytes) of shared memory: chnl + msg */
+ mem_sz = shm_sz + msg_sz;
+
+ /* Get memory reserved in host resources */
+ (void)mgr_enum_processor_info(0,
+ (struct dsp_processorinfo *)
+ &hio_mgr->ext_proc_info,
+ sizeof(struct mgr_processorextinfo),
+ &num_procs);
+
+ /* IO supports only one DSP for now */
+ if (num_procs != 1) {
+ status = -EINVAL;
+ goto free_symbol;
}
- if (!status) {
- /* Get memory reserved in host resources */
- (void)mgr_enum_processor_info(0, (struct dsp_processorinfo *)
- &hio_mgr->ext_proc_info,
- sizeof(struct
- mgr_processorextinfo),
- &num_procs);
-
- /* The first MMU TLB entry(TLB_0) in DCD is ShmBase. */
- ndx = 0;
- ul_gpp_pa = host_res->mem_phys[1];
- ul_gpp_va = host_res->mem_base[1];
- /* This is the virtual uncached ioremapped address!!! */
- /* Why can't we directly take the DSPVA from the symbols? */
- ul_dsp_va = hio_mgr->ext_proc_info.ty_tlb[0].dsp_virt;
- ul_seg_size = (shm0_end - ul_dsp_va) * hio_mgr->word_size;
- ul_seg1_size =
- (ul_ext_end - ul_dyn_ext_base) * hio_mgr->word_size;
- /* 4K align */
- ul_seg1_size = (ul_seg1_size + 0xFFF) & (~0xFFFUL);
- /* 64K align */
- ul_seg_size = (ul_seg_size + 0xFFFF) & (~0xFFFFUL);
- ul_pad_size = UL_PAGE_ALIGN_SIZE - ((ul_gpp_pa + ul_seg1_size) %
- UL_PAGE_ALIGN_SIZE);
- if (ul_pad_size == UL_PAGE_ALIGN_SIZE)
- ul_pad_size = 0x0;
-
- dev_dbg(bridge, "%s: ul_gpp_pa %x, ul_gpp_va %x, ul_dsp_va %x, "
- "shm0_end %x, ul_dyn_ext_base %x, ul_ext_end %x, "
- "ul_seg_size %x ul_seg1_size %x \n", __func__,
- ul_gpp_pa, ul_gpp_va, ul_dsp_va, shm0_end,
- ul_dyn_ext_base, ul_ext_end, ul_seg_size, ul_seg1_size);
-
- if ((ul_seg_size + ul_seg1_size + ul_pad_size) >
- host_res->mem_length[1]) {
- pr_err("%s: shm Error, reserved 0x%x required 0x%x\n",
- __func__, host_res->mem_length[1],
- ul_seg_size + ul_seg1_size + ul_pad_size);
- status = -ENOMEM;
- }
+
+ /* The first MMU TLB entry(TLB_0) in DCD is ShmBase */
+ pa = cfg_res->mem_phys[1];
+ va = cfg_res->mem_base[1];
+
+ /* This is the virtual uncached ioremapped address!!! */
+ /* Why can't we directly take the DSPVA from the symbols? */
+ da = hio_mgr->ext_proc_info.ty_tlb[0].dsp_virt;
+ seg0_sz = (s->shm0_end - da) * hio_mgr->word_size;
+ seg1_sz = (s->ext_end - s->dyn_ext) * hio_mgr->word_size;
+
+ /* 4K align */
+ seg1_sz = (seg1_sz + 0xFFF) & (~0xFFFUL);
+
+ /* 64K align */
+ seg0_sz = (seg0_sz + 0xFFFF) & (~0xFFFFUL);
+
+ pad_sz = UL_PAGE_ALIGN_SIZE - ((pa + seg1_sz) % UL_PAGE_ALIGN_SIZE);
+ if (pad_sz == UL_PAGE_ALIGN_SIZE)
+ pad_sz = 0x0;
+
+ dev_dbg(bridge, "%s: pa %x, va %x, da %x\n", __func__, pa, va, da);
+ dev_dbg(bridge,
+ "shm0_end %x, dyn_ext %x, ext_end %x, seg0_sz %x seg1_sz %x\n",
+ s->shm0_end, s->dyn_ext, s->ext_end, seg0_sz, seg1_sz);
+
+ if ((seg0_sz + seg1_sz + pad_sz) > cfg_res->mem_length[1]) {
+ pr_err("%s: shm Error, reserved 0x%x required 0x%x\n",
+ __func__, cfg_res->mem_length[1],
+ seg0_sz + seg1_sz + pad_sz);
+ status = -ENOMEM;
+ goto free_symbol;
}
- if (status)
- goto func_end;
- pa_curr = ul_gpp_pa;
- va_curr = ul_dyn_ext_base * hio_mgr->word_size;
- gpp_va_curr = ul_gpp_va;
- num_bytes = ul_seg1_size;
+ pa_curr = pa;
+ va_curr = s->dyn_ext * hio_mgr->word_size;
+ da_curr = va;
+ bytes = seg1_sz;
/*
* Try to fit into TLB entries. If not possible, push them to page
@@ -459,37 +457,30 @@ int bridge_io_on_loaded(struct io_mgr *hio_mgr)
* bigger page boundary, we may end up making several small pages.
* So, push them onto page tables, if that is the case.
*/
- map_attrs = 0x00000000;
- map_attrs = DSP_MAPLITTLEENDIAN;
- map_attrs |= DSP_MAPPHYSICALADDR;
- map_attrs |= DSP_MAPELEMSIZE32;
- map_attrs |= DSP_MAPDONOTLOCK;
-
- while (num_bytes) {
+ while (bytes) {
/*
* To find the max. page size with which both PA & VA are
* aligned.
*/
all_bits = pa_curr | va_curr;
- dev_dbg(bridge, "all_bits %x, pa_curr %x, va_curr %x, "
- "num_bytes %x\n", all_bits, pa_curr, va_curr,
- num_bytes);
+ dev_dbg(bridge,
+ "seg all_bits %x, pa_curr %x, va_curr %x, bytes %x\n",
+ all_bits, pa_curr, va_curr, bytes);
+
for (i = 0; i < 4; i++) {
- if ((num_bytes >= page_size[i]) && ((all_bits &
- (page_size[i] -
- 1)) == 0)) {
- status =
- hio_mgr->intf_fxns->
- brd_mem_map(hio_mgr->bridge_context,
- pa_curr, va_curr,
- page_size[i], map_attrs,
- NULL);
+ if ((bytes >= page_size[i]) &&
+ ((all_bits & (page_size[i] - 1)) == 0)) {
+ status = hio_mgr->intf_fxns->brd_mem_map(dc,
+ pa_curr, va_curr,
+ page_size[i], map_attrs,
+ NULL);
if (status)
- goto func_end;
+ goto free_symbol;
+
pa_curr += page_size[i];
va_curr += page_size[i];
- gpp_va_curr += page_size[i];
- num_bytes -= page_size[i];
+ da_curr += page_size[i];
+ bytes -= page_size[i];
/*
* Don't try smaller sizes. Hopefully we have
* reached an address aligned to a bigger page
@@ -499,71 +490,75 @@ int bridge_io_on_loaded(struct io_mgr *hio_mgr)
}
}
}
- pa_curr += ul_pad_size;
- va_curr += ul_pad_size;
- gpp_va_curr += ul_pad_size;
+ pa_curr += pad_sz;
+ va_curr += pad_sz;
+ da_curr += pad_sz;
+ bytes = seg0_sz;
+ va_curr = da * hio_mgr->word_size;
+
+ eproc = kzalloc(sizeof(*eproc) * BRDIOCTL_NUMOFMMUTLB, GFP_KERNEL);
+ if (!eproc) {
+ status = -ENOMEM;
+ goto free_symbol;
+ }
+
+ ndx = 0;
/* Configure the TLB entries for the next cacheable segment */
- num_bytes = ul_seg_size;
- va_curr = ul_dsp_va * hio_mgr->word_size;
- while (num_bytes) {
+ while (bytes) {
/*
* To find the max. page size with which both PA & VA are
* aligned.
*/
all_bits = pa_curr | va_curr;
- dev_dbg(bridge, "all_bits for Seg1 %x, pa_curr %x, "
- "va_curr %x, num_bytes %x\n", all_bits, pa_curr,
- va_curr, num_bytes);
+ dev_dbg(bridge,
+ "seg1 all_bits %x, pa_curr %x, va_curr %x, bytes %x\n",
+ all_bits, pa_curr, va_curr, bytes);
+
for (i = 0; i < 4; i++) {
- if (!(num_bytes >= page_size[i]) ||
+ if (!(bytes >= page_size[i]) ||
!((all_bits & (page_size[i] - 1)) == 0))
continue;
- if (ndx < MAX_LOCK_TLB_ENTRIES) {
- /*
- * This is the physical address written to
- * DSP MMU.
- */
- ae_proc[ndx].gpp_pa = pa_curr;
- /*
- * This is the virtual uncached ioremapped
- * address!!!
- */
- ae_proc[ndx].gpp_va = gpp_va_curr;
- ae_proc[ndx].dsp_va =
- va_curr / hio_mgr->word_size;
- ae_proc[ndx].size = page_size[i];
- ae_proc[ndx].endianism = HW_LITTLE_ENDIAN;
- ae_proc[ndx].elem_size = HW_ELEM_SIZE16BIT;
- ae_proc[ndx].mixed_mode = HW_MMU_CPUES;
- dev_dbg(bridge, "shm MMU TLB entry PA %x"
- " VA %x DSP_VA %x Size %x\n",
- ae_proc[ndx].gpp_pa,
- ae_proc[ndx].gpp_va,
- ae_proc[ndx].dsp_va *
- hio_mgr->word_size, page_size[i]);
- ndx++;
- } else {
- status =
- hio_mgr->intf_fxns->
- brd_mem_map(hio_mgr->bridge_context,
- pa_curr, va_curr,
- page_size[i], map_attrs,
- NULL);
+
+ if (ndx >= MAX_LOCK_TLB_ENTRIES) {
+ status = hio_mgr->intf_fxns->brd_mem_map(dc,
+ pa_curr, va_curr,
+ page_size[i], map_attrs,
+ NULL);
dev_dbg(bridge,
- "shm MMU PTE entry PA %x"
- " VA %x DSP_VA %x Size %x\n",
- ae_proc[ndx].gpp_pa,
- ae_proc[ndx].gpp_va,
- ae_proc[ndx].dsp_va *
+ "PTE pa %x va %x dsp_va %x sz %x\n",
+ eproc[ndx].gpp_pa,
+ eproc[ndx].gpp_va,
+ eproc[ndx].dsp_va *
hio_mgr->word_size, page_size[i]);
if (status)
- goto func_end;
+ goto free_eproc;
}
+
+ /* This is the physical address written to DSP MMU */
+ eproc[ndx].gpp_pa = pa_curr;
+
+ /*
+ * This is the virtual uncached ioremapped
+ * address!!!
+ */
+ eproc[ndx].gpp_va = da_curr;
+ eproc[ndx].dsp_va = va_curr / hio_mgr->word_size;
+ eproc[ndx].size = page_size[i];
+ eproc[ndx].endianism = HW_LITTLE_ENDIAN;
+ eproc[ndx].elem_size = HW_ELEM_SIZE16BIT;
+ eproc[ndx].mixed_mode = HW_MMU_CPUES;
+ dev_dbg(bridge, "%s: tlb pa %x va %x dsp_va %x sz %x\n",
+ __func__, eproc[ndx].gpp_pa,
+ eproc[ndx].gpp_va,
+ eproc[ndx].dsp_va * hio_mgr->word_size,
+ page_size[i]);
+ ndx++;
+
pa_curr += page_size[i];
va_curr += page_size[i];
- gpp_va_curr += page_size[i];
- num_bytes -= page_size[i];
+ da_curr += page_size[i];
+ bytes -= page_size[i];
/*
* Don't try smaller sizes. Hopefully we have reached
* an address aligned to a bigger page size.
@@ -577,146 +572,127 @@ int bridge_io_on_loaded(struct io_mgr *hio_mgr)
* should not conflict with shm entries on MPU or DSP side.
*/
for (i = 3; i < 7 && ndx < BRDIOCTL_NUMOFMMUTLB; i++) {
- if (hio_mgr->ext_proc_info.ty_tlb[i].gpp_phys == 0)
+ struct mgr_processorextinfo *ep = &hio_mgr->ext_proc_info;
+ u32 word_sz = hio_mgr->word_size;
+
+ if (ep->ty_tlb[i].gpp_phys == 0)
continue;
- if ((hio_mgr->ext_proc_info.ty_tlb[i].gpp_phys >
- ul_gpp_pa - 0x100000
- && hio_mgr->ext_proc_info.ty_tlb[i].gpp_phys <=
- ul_gpp_pa + ul_seg_size)
- || (hio_mgr->ext_proc_info.ty_tlb[i].dsp_virt >
- ul_dsp_va - 0x100000 / hio_mgr->word_size
- && hio_mgr->ext_proc_info.ty_tlb[i].dsp_virt <=
- ul_dsp_va + ul_seg_size / hio_mgr->word_size)) {
+ if ((ep->ty_tlb[i].gpp_phys > pa - 0x100000 &&
+ ep->ty_tlb[i].gpp_phys <= pa + seg0_sz) ||
+ (ep->ty_tlb[i].dsp_virt > da - 0x100000 / word_sz &&
+ ep->ty_tlb[i].dsp_virt <= da + seg0_sz / word_sz)) {
dev_dbg(bridge,
- "CDB MMU entry %d conflicts with "
- "shm.\n\tCDB: GppPa %x, DspVa %x.\n\tSHM: "
- "GppPa %x, DspVa %x, Bytes %x.\n", i,
- hio_mgr->ext_proc_info.ty_tlb[i].gpp_phys,
- hio_mgr->ext_proc_info.ty_tlb[i].dsp_virt,
- ul_gpp_pa, ul_dsp_va, ul_seg_size);
+ "err cdb%d pa %x da %x shm pa %x da %x sz %x\n",
+ i, ep->ty_tlb[i].gpp_phys,
+ ep->ty_tlb[i].dsp_virt, pa, da, seg0_sz);
status = -EPERM;
- } else {
- if (ndx < MAX_LOCK_TLB_ENTRIES) {
- ae_proc[ndx].dsp_va =
- hio_mgr->ext_proc_info.ty_tlb[i].
- dsp_virt;
- ae_proc[ndx].gpp_pa =
- hio_mgr->ext_proc_info.ty_tlb[i].
- gpp_phys;
- ae_proc[ndx].gpp_va = 0;
- /* 1 MB */
- ae_proc[ndx].size = 0x100000;
- dev_dbg(bridge, "shm MMU entry PA %x "
- "DSP_VA 0x%x\n", ae_proc[ndx].gpp_pa,
- ae_proc[ndx].dsp_va);
- ndx++;
- } else {
- status = hio_mgr->intf_fxns->brd_mem_map
- (hio_mgr->bridge_context,
- hio_mgr->ext_proc_info.ty_tlb[i].
- gpp_phys,
- hio_mgr->ext_proc_info.ty_tlb[i].
- dsp_virt, 0x100000, map_attrs,
- NULL);
- }
+ goto free_eproc;
+ }
+
+ if (ndx >= MAX_LOCK_TLB_ENTRIES) {
+ status = hio_mgr->intf_fxns->brd_mem_map(dc,
+ ep->ty_tlb[i].gpp_phys,
+ ep->ty_tlb[i].dsp_virt,
+ 0x100000, map_attrs, NULL);
+ if (status)
+ goto free_eproc;
}
- if (status)
- goto func_end;
- }
- map_attrs = 0x00000000;
- map_attrs = DSP_MAPLITTLEENDIAN;
- map_attrs |= DSP_MAPPHYSICALADDR;
- map_attrs |= DSP_MAPELEMSIZE32;
- map_attrs |= DSP_MAPDONOTLOCK;
+ eproc[ndx].dsp_va = ep->ty_tlb[i].dsp_virt;
+ eproc[ndx].gpp_pa = ep->ty_tlb[i].gpp_phys;
+ eproc[ndx].gpp_va = 0;
+
+ /* 1 MB */
+ eproc[ndx].size = 0x100000;
+ dev_dbg(bridge, "shm MMU entry pa %x da 0x%x\n",
+ eproc[ndx].gpp_pa, eproc[ndx].dsp_va);
+ ndx++;
+ }
/* Map the L4 peripherals */
i = 0;
while (l4_peripheral_table[i].phys_addr) {
- status = hio_mgr->intf_fxns->brd_mem_map
- (hio_mgr->bridge_context, l4_peripheral_table[i].phys_addr,
- l4_peripheral_table[i].dsp_virt_addr, HW_PAGE_SIZE4KB,
- map_attrs, NULL);
+ status = hio_mgr->intf_fxns->brd_mem_map(dc,
+ l4_peripheral_table[i].phys_addr,
+ l4_peripheral_table[i].dsp_virt_addr,
+ HW_PAGE_SIZE4KB, map_attrs, NULL);
if (status)
- goto func_end;
+ goto free_eproc;
i++;
}
for (i = ndx; i < BRDIOCTL_NUMOFMMUTLB; i++) {
- ae_proc[i].dsp_va = 0;
- ae_proc[i].gpp_pa = 0;
- ae_proc[i].gpp_va = 0;
- ae_proc[i].size = 0;
+ eproc[i].dsp_va = 0;
+ eproc[i].gpp_pa = 0;
+ eproc[i].gpp_va = 0;
+ eproc[i].size = 0;
}
+
/*
* Set the shm physical address entry (grayed out in CDB file)
* to the virtual uncached ioremapped address of shm reserved
* on MPU.
*/
hio_mgr->ext_proc_info.ty_tlb[0].gpp_phys =
- (ul_gpp_va + ul_seg1_size + ul_pad_size);
+ (va + seg1_sz + pad_sz);
/*
* Need shm Phys addr. IO supports only one DSP for now:
* num_procs = 1.
*/
- if (!hio_mgr->ext_proc_info.ty_tlb[0].gpp_phys || num_procs != 1) {
- status = -EFAULT;
- goto func_end;
- } else {
- if (ae_proc[0].dsp_va > ul_shm_base) {
- status = -EPERM;
- goto func_end;
- }
- /* ul_shm_base may not be at ul_dsp_va address */
- ul_shm_base_offset = (ul_shm_base - ae_proc[0].dsp_va) *
+ if (!hio_mgr->ext_proc_info.ty_tlb[0].gpp_phys)
+ return -EFAULT;
+
+ if (eproc[0].dsp_va > s->shm_base)
+ return -EPERM;
+
+ /* shm_base may not be at ul_dsp_va address */
+ shm_base_offs = (s->shm_base - eproc[0].dsp_va) *
hio_mgr->word_size;
- /*
- * bridge_dev_ctrl() will set dev context dsp-mmu info. In
- * bridge_brd_start() the MMU will be re-programed with MMU
- * DSPVa-GPPPa pair info while DSP is in a known
- * (reset) state.
- */
+ /*
+ * bridge_dev_ctrl() will set dev context dsp-mmu info. In
+ * bridge_brd_start() the MMU will be re-programed with MMU
+ * DSPVa-GPPPa pair info while DSP is in a known
+ * (reset) state.
+ */
+ status = hio_mgr->intf_fxns->dev_cntrl(hio_mgr->bridge_context,
+ BRDIOCTL_SETMMUCONFIG, eproc);
+ if (status)
+ goto free_eproc;
- status =
- hio_mgr->intf_fxns->dev_cntrl(hio_mgr->bridge_context,
- BRDIOCTL_SETMMUCONFIG,
- ae_proc);
- if (status)
- goto func_end;
- ul_shm_base = hio_mgr->ext_proc_info.ty_tlb[0].gpp_phys;
- ul_shm_base += ul_shm_base_offset;
- ul_shm_base = (u32) MEM_LINEAR_ADDRESS((void *)ul_shm_base,
- ul_mem_length);
- if (ul_shm_base == 0) {
- status = -EFAULT;
- goto func_end;
- }
- /* Register SM */
- status =
- register_shm_segs(hio_mgr, cod_man, ae_proc[0].gpp_pa);
+ s->shm_base = hio_mgr->ext_proc_info.ty_tlb[0].gpp_phys;
+ s->shm_base += shm_base_offs;
+ s->shm_base = (u32) MEM_LINEAR_ADDRESS((void *)s->shm_base,
+ mem_sz);
+ if (!s->shm_base) {
+ status = -EFAULT;
+ goto free_eproc;
}
- hio_mgr->shared_mem = (struct shm *)ul_shm_base;
+ /* Register SM */
+ status = register_shm_segs(hio_mgr, cod_man, eproc[0].gpp_pa);
+
+ hio_mgr->shared_mem = (struct shm *)s->shm_base;
hio_mgr->input = (u8 *) hio_mgr->shared_mem + sizeof(struct shm);
- hio_mgr->output = hio_mgr->input + (ul_shm_length -
+ hio_mgr->output = hio_mgr->input + (shm_sz -
sizeof(struct shm)) / 2;
hio_mgr->sm_buf_size = hio_mgr->output - hio_mgr->input;
- /* Set up Shared memory addresses for messaging. */
- hio_mgr->msg_input_ctrl = (struct msg_ctrl *)((u8 *) hio_mgr->shared_mem
- + ul_shm_length);
+ /* Set up Shared memory addresses for messaging */
+ hio_mgr->msg_input_ctrl =
+ (struct msg_ctrl *)((u8 *) hio_mgr->shared_mem + shm_sz);
hio_mgr->msg_input =
- (u8 *) hio_mgr->msg_input_ctrl + sizeof(struct msg_ctrl);
+ (u8 *) hio_mgr->msg_input_ctrl + sizeof(struct msg_ctrl);
hio_mgr->msg_output_ctrl =
- (struct msg_ctrl *)((u8 *) hio_mgr->msg_input_ctrl +
- ul_msg_length / 2);
+ (struct msg_ctrl *)((u8 *) hio_mgr->msg_input_ctrl +
+ msg_sz / 2);
hio_mgr->msg_output =
- (u8 *) hio_mgr->msg_output_ctrl + sizeof(struct msg_ctrl);
+ (u8 *) hio_mgr->msg_output_ctrl + sizeof(struct msg_ctrl);
hmsg_mgr->max_msgs =
- ((u8 *) hio_mgr->msg_output_ctrl - hio_mgr->msg_input)
- / sizeof(struct msg_dspmsg);
+ ((u8 *) hio_mgr->msg_output_ctrl - hio_mgr->msg_input) /
+ sizeof(struct msg_dspmsg);
+
dev_dbg(bridge, "IO MGR shm details: shared_mem %p, input %p, "
"output %p, msg_input_ctrl %p, msg_input %p, "
"msg_output_ctrl %p, msg_output %p\n",
@@ -732,47 +708,53 @@ int bridge_io_on_loaded(struct io_mgr *hio_mgr)
/* Get the start address of trace buffer */
status = cod_get_sym_value(cod_man, SYS_PUTCBEG,
&hio_mgr->trace_buffer_begin);
- if (status) {
- status = -EFAULT;
- goto func_end;
- }
+ if (status)
+ goto free_eproc;
+
+ hio_mgr->gpp_read_pointer =
+ hio_mgr->trace_buffer_begin =
+ (va + seg1_sz + pad_sz) +
+ (hio_mgr->trace_buffer_begin - da);
- hio_mgr->gpp_read_pointer = hio_mgr->trace_buffer_begin =
- (ul_gpp_va + ul_seg1_size + ul_pad_size) +
- (hio_mgr->trace_buffer_begin - ul_dsp_va);
/* Get the end address of trace buffer */
status = cod_get_sym_value(cod_man, SYS_PUTCEND,
&hio_mgr->trace_buffer_end);
- if (status) {
- status = -EFAULT;
- goto func_end;
- }
+ if (status)
+ goto free_eproc;
+
hio_mgr->trace_buffer_end =
- (ul_gpp_va + ul_seg1_size + ul_pad_size) +
- (hio_mgr->trace_buffer_end - ul_dsp_va);
+ (va + seg1_sz + pad_sz) +
+ (hio_mgr->trace_buffer_end - da);
+
/* Get the current address of DSP write pointer */
status = cod_get_sym_value(cod_man, BRIDGE_SYS_PUTC_CURRENT,
&hio_mgr->trace_buffer_current);
- if (status) {
- status = -EFAULT;
- goto func_end;
- }
+ if (status)
+ goto free_eproc;
+
hio_mgr->trace_buffer_current =
- (ul_gpp_va + ul_seg1_size + ul_pad_size) +
- (hio_mgr->trace_buffer_current - ul_dsp_va);
+ (va + seg1_sz + pad_sz) +
+ (hio_mgr->trace_buffer_current - da);
+
/* Calculate the size of trace buffer */
kfree(hio_mgr->msg);
hio_mgr->msg = kmalloc(((hio_mgr->trace_buffer_end -
hio_mgr->trace_buffer_begin) *
hio_mgr->word_size) + 2, GFP_KERNEL);
- if (!hio_mgr->msg)
+ if (!hio_mgr->msg) {
status = -ENOMEM;
+ goto free_eproc;
+ }
- hio_mgr->dsp_va = ul_dsp_va;
- hio_mgr->gpp_va = (ul_gpp_va + ul_seg1_size + ul_pad_size);
-
+ hio_mgr->dsp_va = da;
+ hio_mgr->gpp_va = (va + seg1_sz + pad_sz);
#endif
-func_end:
+
+free_eproc:
+ kfree(eproc);
+free_symbol:
+ kfree(s);
+
return status;
}
@@ -2212,7 +2194,7 @@ void dump_dl_modules(struct bridge_dev_context *bridge_context)
if (status) {
pr_debug(
- "%s: Failed to read dll_module stuct for 0x%x.\n",
+ "%s: Failed to read dll_module struct for 0x%x.\n",
__func__, module_dsp_addr);
break;
}
diff --git a/drivers/staging/tidspbridge/core/tiomap3430.c b/drivers/staging/tidspbridge/core/tiomap3430.c
index 9cf29fcea11e..f9609ce2c163 100644
--- a/drivers/staging/tidspbridge/core/tiomap3430.c
+++ b/drivers/staging/tidspbridge/core/tiomap3430.c
@@ -1547,20 +1547,27 @@ EXIT_LOOP:
static u32 user_va2_pa(struct mm_struct *mm, u32 address)
{
pgd_t *pgd;
+ pud_t *pud;
pmd_t *pmd;
pte_t *ptep, pte;
pgd = pgd_offset(mm, address);
- if (!(pgd_none(*pgd) || pgd_bad(*pgd))) {
- pmd = pmd_offset(pgd, address);
- if (!(pmd_none(*pmd) || pmd_bad(*pmd))) {
- ptep = pte_offset_map(pmd, address);
- if (ptep) {
- pte = *ptep;
- if (pte_present(pte))
- return pte & PAGE_MASK;
- }
- }
+ if (pgd_none(*pgd) || pgd_bad(*pgd))
+ return 0;
+
+ pud = pud_offset(pgd, address);
+ if (pud_none(*pud) || pud_bad(*pud))
+ return 0;
+
+ pmd = pmd_offset(pud, address);
+ if (pmd_none(*pmd) || pmd_bad(*pmd))
+ return 0;
+
+ ptep = pte_offset_map(pmd, address);
+ if (ptep) {
+ pte = *ptep;
+ if (pte_present(pte))
+ return pte & PAGE_MASK;
}
return 0;
diff --git a/drivers/staging/tidspbridge/core/ue_deh.c b/drivers/staging/tidspbridge/core/ue_deh.c
index 006ffd752895..3d28b2345fbd 100644
--- a/drivers/staging/tidspbridge/core/ue_deh.c
+++ b/drivers/staging/tidspbridge/core/ue_deh.c
@@ -215,7 +215,7 @@ static inline const char *event_to_string(int event)
case DSP_MMUFAULT: return "DSP_MMUFAULT"; break;
case DSP_PWRERROR: return "DSP_PWRERROR"; break;
case DSP_WDTOVERFLOW: return "DSP_WDTOVERFLOW"; break;
- default: return "unkown event"; break;
+ default: return "unknown event"; break;
}
}
diff --git a/drivers/staging/tidspbridge/dynload/cload.c b/drivers/staging/tidspbridge/dynload/cload.c
index fe1ef0addb09..9d54744805b8 100644
--- a/drivers/staging/tidspbridge/dynload/cload.c
+++ b/drivers/staging/tidspbridge/dynload/cload.c
@@ -14,6 +14,8 @@
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
+#include <linux/slab.h>
+
#include "header.h"
#include "module_list.h"
@@ -706,6 +708,7 @@ static void dload_symbols(struct dload_state *dlthis)
struct local_symbol *sp;
struct dynload_symbol *symp;
struct dynload_symbol *newsym;
+ struct doff_syment_t *my_sym_buf;
sym_count = dlthis->dfile_hdr.df_no_syms;
if (sym_count == 0)
@@ -739,13 +742,18 @@ static void dload_symbols(struct dload_state *dlthis)
become defined from the global symbol table */
checks = dlthis->verify.dv_sym_tab_checksum;
symbols_left = sym_count;
+
+ my_sym_buf = kzalloc(sizeof(*my_sym_buf) * MY_SYM_BUF_SIZ, GFP_KERNEL);
+ if (!my_sym_buf)
+ return;
+
do { /* read all symbols */
char *sname;
u32 val;
s32 delta;
struct doff_syment_t *input_sym;
unsigned syms_in_buf;
- struct doff_syment_t my_sym_buf[MY_SYM_BUF_SIZ];
+
input_sym = my_sym_buf;
syms_in_buf = symbols_left > MY_SYM_BUF_SIZ ?
MY_SYM_BUF_SIZ : symbols_left;
@@ -753,7 +761,7 @@ static void dload_symbols(struct dload_state *dlthis)
if (dlthis->strm->read_buffer(dlthis->strm, input_sym, siz) !=
siz) {
DL_ERROR(readstrm, sym_errid);
- return;
+ goto free_sym_buf;
}
if (dlthis->reorder_map)
dload_reorder(input_sym, siz, dlthis->reorder_map);
@@ -856,7 +864,7 @@ static void dload_symbols(struct dload_state *dlthis)
DL_ERROR("Absolute symbol %s is "
"defined multiple times with "
"different values", sname);
- return;
+ goto free_sym_buf;
}
}
loop_itr:
@@ -887,6 +895,9 @@ loop_cont:
if (~checks)
dload_error(dlthis, "Checksum of symbols failed");
+free_sym_buf:
+ kfree(my_sym_buf);
+ return;
} /* dload_symbols */
/*****************************************************************************
@@ -1116,6 +1127,11 @@ static int relocate_packet(struct dload_state *dlthis,
/* VERY dangerous */
static const char imagepak[] = { "image packet" };
+struct img_buffer {
+ struct image_packet_t ipacket;
+ u8 bufr[BYTE_TO_HOST(IMAGE_PACKET_SIZE)];
+};
+
/*************************************************************************
* Procedure dload_data
*
@@ -1131,16 +1147,16 @@ static void dload_data(struct dload_state *dlthis)
u16 curr_sect;
struct doff_scnhdr_t *sptr = dlthis->sect_hdrs;
struct ldr_section_info *lptr = dlthis->ldr_sections;
+ struct img_buffer *ibuf;
u8 *dest;
- struct {
- struct image_packet_t ipacket;
- u8 bufr[BYTE_TO_HOST(IMAGE_PACKET_SIZE)];
- } ibuf;
-
/* Indicates whether CINIT processing has occurred */
bool cinit_processed = false;
+ ibuf = kzalloc(sizeof(*ibuf), GFP_KERNEL);
+ if (!ibuf)
+ return;
+
/* Loop through the sections and load them one at a time.
*/
for (curr_sect = 0; curr_sect < dlthis->dfile_hdr.df_no_scns;
@@ -1168,37 +1184,37 @@ static void dload_data(struct dload_state *dlthis)
/* get the fixed header bits */
if (dlthis->strm->read_buffer(dlthis->strm,
- &ibuf.ipacket,
+ &ibuf->ipacket,
IPH_SIZE) !=
IPH_SIZE) {
DL_ERROR(readstrm, imagepak);
- return;
+ goto free_ibuf;
}
/* reorder the header if need be */
if (dlthis->reorder_map) {
- dload_reorder(&ibuf.ipacket, IPH_SIZE,
+ dload_reorder(&ibuf->ipacket, IPH_SIZE,
dlthis->reorder_map);
}
/* now read the rest of the packet */
ipsize =
BYTE_TO_HOST(DOFF_ALIGN
- (ibuf.ipacket.packet_size));
+ (ibuf->ipacket.packet_size));
if (ipsize > BYTE_TO_HOST(IMAGE_PACKET_SIZE)) {
DL_ERROR("Bad image packet size %d",
ipsize);
- return;
+ goto free_ibuf;
}
- dest = ibuf.bufr;
+ dest = ibuf->bufr;
/* End of determination */
if (dlthis->strm->read_buffer(dlthis->strm,
- ibuf.bufr,
+ ibuf->bufr,
ipsize) !=
ipsize) {
DL_ERROR(readstrm, imagepak);
- return;
+ goto free_ibuf;
}
- ibuf.ipacket.img_data = dest;
+ ibuf->ipacket.img_data = dest;
/* reorder the bytes if need be */
#if !defined(_BIG_ENDIAN) || (TARGET_AU_BITS > 16)
@@ -1225,16 +1241,16 @@ static void dload_data(struct dload_state *dlthis)
#endif
#endif
- checks += dload_checksum(&ibuf.ipacket,
+ checks += dload_checksum(&ibuf->ipacket,
IPH_SIZE);
/* relocate the image bits as needed */
- if (ibuf.ipacket.num_relocs) {
+ if (ibuf->ipacket.num_relocs) {
dlthis->image_offset = image_offset;
if (!relocate_packet(dlthis,
- &ibuf.ipacket,
+ &ibuf->ipacket,
&checks,
&tramp_generated))
- return; /* serious error */
+ goto free_ibuf; /* error */
}
if (~checks)
DL_ERROR(err_checksum, imagepak);
@@ -1249,20 +1265,20 @@ static void dload_data(struct dload_state *dlthis)
if (dload_check_type(sptr,
DLOAD_CINIT)) {
cload_cinit(dlthis,
- &ibuf.ipacket);
+ &ibuf->ipacket);
cinit_processed = true;
} else {
/* FIXME */
if (!dlthis->myio->
writemem(dlthis->
myio,
- ibuf.bufr,
+ ibuf->bufr,
lptr->
load_addr +
image_offset,
lptr,
BYTE_TO_HOST
- (ibuf.
+ (ibuf->
ipacket.
packet_size))) {
DL_ERROR
@@ -1276,7 +1292,7 @@ static void dload_data(struct dload_state *dlthis)
}
}
image_offset +=
- BYTE_TO_TADDR(ibuf.ipacket.packet_size);
+ BYTE_TO_TADDR(ibuf->ipacket.packet_size);
} /* process packets */
/* if this is a BSS section, we may want to fill it */
if (!dload_check_type(sptr, DLOAD_BSS))
@@ -1334,6 +1350,9 @@ loop_cont:
DL_ERROR("Finalization of auto-trampolines (size = " FMT_UI32
") failed", dlthis->tramp.tramp_sect_next_addr);
}
+free_ibuf:
+ kfree(ibuf);
+ return;
} /* dload_data */
/*************************************************************************
diff --git a/drivers/staging/usbip/stub_dev.c b/drivers/staging/usbip/stub_dev.c
index fa870e3f7f6a..92ced35e6b7f 100644
--- a/drivers/staging/usbip/stub_dev.c
+++ b/drivers/staging/usbip/stub_dev.c
@@ -113,8 +113,8 @@ static ssize_t store_sockfd(struct device *dev, struct device_attribute *attr,
spin_unlock(&sdev->ud.lock);
- sdev->ud.tcp_rx = kthread_run(stub_rx_loop, &sdev->ud, "stub_rx");
- sdev->ud.tcp_tx = kthread_run(stub_tx_loop, &sdev->ud, "stub_tx");
+ sdev->ud.tcp_rx = kthread_get_run(stub_rx_loop, &sdev->ud, "stub_rx");
+ sdev->ud.tcp_tx = kthread_get_run(stub_tx_loop, &sdev->ud, "stub_tx");
spin_lock(&sdev->ud.lock);
sdev->ud.status = SDEV_ST_USED;
@@ -187,10 +187,10 @@ static void stub_shutdown_connection(struct usbip_device *ud)
}
/* 1. stop threads */
- if (ud->tcp_rx && !task_is_dead(ud->tcp_rx))
- kthread_stop(ud->tcp_rx);
- if (ud->tcp_tx && !task_is_dead(ud->tcp_tx))
- kthread_stop(ud->tcp_tx);
+ if (ud->tcp_rx)
+ kthread_stop_put(ud->tcp_rx);
+ if (ud->tcp_tx)
+ kthread_stop_put(ud->tcp_tx);
/*
* 2. close the socket
diff --git a/drivers/staging/usbip/usbip_common.h b/drivers/staging/usbip/usbip_common.h
index c7b888ca54f5..5d89c0fd6f7b 100644
--- a/drivers/staging/usbip/usbip_common.h
+++ b/drivers/staging/usbip/usbip_common.h
@@ -292,6 +292,23 @@ struct usbip_device {
} eh_ops;
};
+#define kthread_get_run(threadfn, data, namefmt, ...) \
+({ \
+ struct task_struct *__k \
+ = kthread_create(threadfn, data, namefmt, ## __VA_ARGS__); \
+ if (!IS_ERR(__k)) { \
+ get_task_struct(__k); \
+ wake_up_process(__k); \
+ } \
+ __k; \
+})
+
+#define kthread_stop_put(k) \
+ do { \
+ kthread_stop(k); \
+ put_task_struct(k); \
+ } while (0)
+
/* usbip_common.c */
void usbip_dump_urb(struct urb *purb);
void usbip_dump_header(struct usbip_header *pdu);
diff --git a/drivers/staging/usbip/usbip_protocol.txt b/drivers/staging/usbip/usbip_protocol.txt
index 0f102081e86c..16b6fe27284c 100644
--- a/drivers/staging/usbip/usbip_protocol.txt
+++ b/drivers/staging/usbip/usbip_protocol.txt
@@ -27,7 +27,7 @@ Once the client knows the list of exported USB devices it may decide to use one
of them. First the client opens a TCP/IP connection towards the server and
sends an OP_REQ_IMPORT packet. The server replies with OP_REP_IMPORT. If the
import was successful the TCP/IP connection remains open and will be used
-to trasfer the URB traffic between the client and the server. The client may
+to transfer the URB traffic between the client and the server. The client may
send two types of packets: the USBIP_CMD_SUBMIT to submit an URB, and
USBIP_CMD_UNLINK to unlink a previously submitted URB. The answers of the
server may be USBIP_RET_SUBMIT and USBIP_RET_UNLINK respectively.
diff --git a/drivers/staging/usbip/userspace/libsrc/vhci_driver.c b/drivers/staging/usbip/userspace/libsrc/vhci_driver.c
index 269787751b20..0958ba53e94a 100644
--- a/drivers/staging/usbip/userspace/libsrc/vhci_driver.c
+++ b/drivers/staging/usbip/userspace/libsrc/vhci_driver.c
@@ -59,7 +59,10 @@ static int parse_status(char *value)
/* skip a header line */
- c = strchr(value, '\n') + 1;
+ c = strchr(value, '\n');
+ if (!c)
+ return -1;
+ c++;
while (*c != '\0') {
int port, status, speed, devid;
@@ -109,7 +112,10 @@ static int parse_status(char *value)
/* go to the next line */
- c = strchr(c, '\n') + 1;
+ c = strchr(c, '\n');
+ if (!c)
+ break;
+ c++;
}
dbg("exit");
@@ -264,11 +270,17 @@ static int get_nports(void)
attr_status->method, attr_status->value);
/* skip a header line */
- c = strchr(attr_status->value, '\n') + 1;
+ c = strchr(attr_status->value, '\n');
+ if (!c)
+ return 0;
+ c++;
while (*c != '\0') {
/* go to the next line */
- c = strchr(c, '\n') + 1;
+ c = strchr(c, '\n');
+ if (!c)
+ return nports;
+ c++;
nports += 1;
}
diff --git a/drivers/staging/usbip/userspace/src/Makefile.am b/drivers/staging/usbip/userspace/src/Makefile.am
index 3f09f6ad39f7..c365a3fada90 100644
--- a/drivers/staging/usbip/userspace/src/Makefile.am
+++ b/drivers/staging/usbip/userspace/src/Makefile.am
@@ -4,8 +4,9 @@ LDADD = $(top_builddir)/libsrc/libusbip.la @PACKAGE_LIBS@
sbin_PROGRAMS := usbip usbipd
-usbip_SOURCES := usbip.c utils.c usbip_network.c \
+usbip_SOURCES := usbip.h utils.h usbip.c utils.c usbip_network.c \
usbip_attach.c usbip_detach.c usbip_list.c \
usbip_bind.c usbip_unbind.c
-usbipd_SOURCES := usbipd.c usbip_network.c
+
+usbipd_SOURCES := usbip_network.h usbipd.c usbip_network.c
diff --git a/drivers/staging/usbip/vhci.h b/drivers/staging/usbip/vhci.h
index 88b32981cf1f..c66b8b3f97b4 100644
--- a/drivers/staging/usbip/vhci.h
+++ b/drivers/staging/usbip/vhci.h
@@ -71,12 +71,7 @@ struct vhci_unlink {
unsigned long unlink_seqnum;
};
-/*
- * The number of ports is less than 16 ?
- * USB_MAXCHILDREN is statically defined to 16 in usb.h. Its maximum value
- * would be 31 because the event_bits[1] of struct usb_hub is defined as
- * unsigned long in hub.h
- */
+/* Number of supported ports. Value has an upperbound of USB_MAXCHILDREN */
#define VHCI_NPORTS 8
/* for usb_bus.hcpriv */
diff --git a/drivers/staging/usbip/vhci_hcd.c b/drivers/staging/usbip/vhci_hcd.c
index dca9bf11f0c2..12a9a5fbc797 100644
--- a/drivers/staging/usbip/vhci_hcd.c
+++ b/drivers/staging/usbip/vhci_hcd.c
@@ -178,44 +178,32 @@ void rh_port_disconnect(int rhport)
| USB_PORT_STAT_C_RESET) << 16)
/*
- * This function is almostly the same as dummy_hcd.c:dummy_hub_status() without
- * suspend/resume support. But, it is modified to provide multiple ports.
+ * Returns 0 if the status hasn't changed, or the number of bytes in buf.
+ * Ports are 0-indexed from the HCD point of view,
+ * and 1-indexed from the USB core pointer of view.
*
* @buf: a bitmap to show which port status has been changed.
- * bit 0: reserved or used for another purpose?
+ * bit 0: reserved
* bit 1: the status of port 0 has been changed.
* bit 2: the status of port 1 has been changed.
* ...
- * bit 7: the status of port 6 has been changed.
- * bit 8: the status of port 7 has been changed.
- * ...
- * bit 15: the status of port 14 has been changed.
- *
- * So, the maximum number of ports is 31 ( port 0 to port 30) ?
- *
- * The return value is the actual transferred length in byte. If nothing has
- * been changed, return 0. In the case that the number of ports is less than or
- * equal to 6 (VHCI_NPORTS==7), return 1.
- *
*/
static int vhci_hub_status(struct usb_hcd *hcd, char *buf)
{
struct vhci_hcd *vhci;
unsigned long flags;
- int retval = 0;
-
- /* the enough buffer is allocated according to USB_MAXCHILDREN */
- unsigned long *event_bits = (unsigned long *) buf;
+ int retval;
int rhport;
int changed = 0;
- *event_bits = 0;
+ retval = DIV_ROUND_UP(VHCI_NPORTS + 1, 8);
+ memset(buf, 0, retval);
vhci = hcd_to_vhci(hcd);
spin_lock_irqsave(&vhci->lock, flags);
if (!HCD_HW_ACCESSIBLE(hcd)) {
- usbip_dbg_vhci_rh("hw accessible flag in on?\n");
+ usbip_dbg_vhci_rh("hw accessible flag not on?\n");
goto done;
}
@@ -223,9 +211,9 @@ static int vhci_hub_status(struct usb_hcd *hcd, char *buf)
for (rhport = 0; rhport < VHCI_NPORTS; rhport++) {
if ((vhci->port_status[rhport] & PORT_C_MASK)) {
/* The status of a port has been changed, */
- usbip_dbg_vhci_rh("port %d is changed\n", rhport);
+ usbip_dbg_vhci_rh("port %d status changed\n", rhport);
- *event_bits |= 1 << (rhport + 1);
+ buf[(rhport + 1) / 8] |= 1 << (rhport + 1) % 8;
changed = 1;
}
}
@@ -235,14 +223,9 @@ static int vhci_hub_status(struct usb_hcd *hcd, char *buf)
if (hcd->state == HC_STATE_SUSPENDED)
usb_hcd_resume_root_hub(hcd);
- if (changed)
- retval = 1 + (VHCI_NPORTS / 8);
- else
- retval = 0;
-
done:
spin_unlock_irqrestore(&vhci->lock, flags);
- return retval;
+ return changed ? retval : 0;
}
/* See hub_configure in hub.c */
@@ -821,10 +804,10 @@ static void vhci_shutdown_connection(struct usbip_device *ud)
}
/* kill threads related to this sdev, if v.c. exists */
- if (vdev->ud.tcp_rx && !task_is_dead(vdev->ud.tcp_rx))
- kthread_stop(vdev->ud.tcp_rx);
- if (vdev->ud.tcp_tx && !task_is_dead(vdev->ud.tcp_tx))
- kthread_stop(vdev->ud.tcp_tx);
+ if (vdev->ud.tcp_rx)
+ kthread_stop_put(vdev->ud.tcp_rx);
+ if (vdev->ud.tcp_tx)
+ kthread_stop_put(vdev->ud.tcp_tx);
pr_info("stop threads\n");
diff --git a/drivers/staging/usbip/vhci_rx.c b/drivers/staging/usbip/vhci_rx.c
index f5fba7320c5a..f0eaf04fa25b 100644
--- a/drivers/staging/usbip/vhci_rx.c
+++ b/drivers/staging/usbip/vhci_rx.c
@@ -162,7 +162,7 @@ static void vhci_recv_ret_unlink(struct vhci_device *vdev,
* already received the result of its submit result and gave
* back the URB.
*/
- pr_info("the urb (seqnum %d) was already given backed\n",
+ pr_info("the urb (seqnum %d) was already given back\n",
pdu->base.seqnum);
} else {
usbip_dbg_vhci_rx("now giveback urb %p\n", urb);
diff --git a/drivers/staging/usbip/vhci_sysfs.c b/drivers/staging/usbip/vhci_sysfs.c
index 0cd039bb5fd6..7ce9c2f7e442 100644
--- a/drivers/staging/usbip/vhci_sysfs.c
+++ b/drivers/staging/usbip/vhci_sysfs.c
@@ -222,8 +222,8 @@ static ssize_t store_attach(struct device *dev, struct device_attribute *attr,
spin_unlock(&the_controller->lock);
/* end the lock */
- vdev->ud.tcp_rx = kthread_run(vhci_rx_loop, &vdev->ud, "vhci_rx");
- vdev->ud.tcp_tx = kthread_run(vhci_tx_loop, &vdev->ud, "vhci_tx");
+ vdev->ud.tcp_rx = kthread_get_run(vhci_rx_loop, &vdev->ud, "vhci_rx");
+ vdev->ud.tcp_tx = kthread_get_run(vhci_tx_loop, &vdev->ud, "vhci_tx");
rh_port_connect(rhport, speed);
diff --git a/drivers/staging/vme/Kconfig b/drivers/staging/vme/Kconfig
deleted file mode 100644
index 6411ae51ed3f..000000000000
--- a/drivers/staging/vme/Kconfig
+++ /dev/null
@@ -1,19 +0,0 @@
-#
-# VME configuration.
-#
-
-menuconfig VME_BUS
- tristate "VME bridge support"
- depends on PCI
- ---help---
- If you say Y here you get support for the VME bridge Framework.
-
-if VME_BUS
-
-source "drivers/staging/vme/bridges/Kconfig"
-
-source "drivers/staging/vme/devices/Kconfig"
-
-source "drivers/staging/vme/boards/Kconfig"
-
-endif # VME
diff --git a/drivers/staging/vme/Makefile b/drivers/staging/vme/Makefile
index b4ea3f8d0a50..accdb72e39e2 100644
--- a/drivers/staging/vme/Makefile
+++ b/drivers/staging/vme/Makefile
@@ -1,8 +1 @@
-#
-# Makefile for the VME bridge device drivers.
-#
-obj-$(CONFIG_VME_BUS) += vme.o
-
-obj-y += bridges/
obj-y += devices/
-obj-y += boards/
diff --git a/drivers/staging/vme/TODO b/drivers/staging/vme/TODO
deleted file mode 100644
index 79f00333e7ef..000000000000
--- a/drivers/staging/vme/TODO
+++ /dev/null
@@ -1,5 +0,0 @@
- TODO
- ====
-
-- Add one or more device drivers which use the VME framework.
-
diff --git a/drivers/staging/vme/boards/Kconfig b/drivers/staging/vme/boards/Kconfig
deleted file mode 100644
index 761631353527..000000000000
--- a/drivers/staging/vme/boards/Kconfig
+++ /dev/null
@@ -1,9 +0,0 @@
-comment "VME Board Drivers"
-
-config VMIVME_7805
- tristate "VMIVME-7805"
- help
- If you say Y here you get support for the VMIVME-7805 board.
- This board has an additional control interface to the Universe II
- chip. This driver has to be included if you want to access VME bus
- with VMIVME-7805 board.
diff --git a/drivers/staging/vme/boards/Makefile b/drivers/staging/vme/boards/Makefile
deleted file mode 100644
index 43658340885d..000000000000
--- a/drivers/staging/vme/boards/Makefile
+++ /dev/null
@@ -1,5 +0,0 @@
-#
-# Makefile for the VME board drivers.
-#
-
-obj-$(CONFIG_VMIVME_7805) += vme_vmivme7805.o
diff --git a/drivers/staging/vme/boards/vme_vmivme7805.c b/drivers/staging/vme/boards/vme_vmivme7805.c
deleted file mode 100644
index 8e05bb4e135a..000000000000
--- a/drivers/staging/vme/boards/vme_vmivme7805.c
+++ /dev/null
@@ -1,123 +0,0 @@
-/*
- * Support for the VMIVME-7805 board access to the Universe II bridge.
- *
- * Author: Arthur Benilov <arthur.benilov@iba-group.com>
- * Copyright 2010 Ion Beam Application, 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.
- */
-
-#include <linux/module.h>
-#include <linux/types.h>
-#include <linux/errno.h>
-#include <linux/pci.h>
-#include <linux/poll.h>
-#include <linux/io.h>
-
-#include "vme_vmivme7805.h"
-
-static int __init vmic_init(void);
-static int vmic_probe(struct pci_dev *, const struct pci_device_id *);
-static void vmic_remove(struct pci_dev *);
-static void __exit vmic_exit(void);
-
-/** Base address to access FPGA register */
-static void *vmic_base;
-
-static const char driver_name[] = "vmivme_7805";
-
-static DEFINE_PCI_DEVICE_TABLE(vmic_ids) = {
- { PCI_DEVICE(PCI_VENDOR_ID_VMIC, PCI_DEVICE_ID_VTIMR) },
- { },
-};
-
-static struct pci_driver vmic_driver = {
- .name = driver_name,
- .id_table = vmic_ids,
- .probe = vmic_probe,
- .remove = vmic_remove,
-};
-
-static int __init vmic_init(void)
-{
- return pci_register_driver(&vmic_driver);
-}
-
-static int vmic_probe(struct pci_dev *pdev, const struct pci_device_id *id)
-{
- int retval;
- u32 data;
-
- /* Enable the device */
- retval = pci_enable_device(pdev);
- if (retval) {
- dev_err(&pdev->dev, "Unable to enable device\n");
- goto err;
- }
-
- /* Map Registers */
- retval = pci_request_regions(pdev, driver_name);
- if (retval) {
- dev_err(&pdev->dev, "Unable to reserve resources\n");
- goto err_resource;
- }
-
- /* Map registers in BAR 0 */
- vmic_base = ioremap_nocache(pci_resource_start(pdev, 0), 16);
- if (!vmic_base) {
- dev_err(&pdev->dev, "Unable to remap CRG region\n");
- retval = -EIO;
- goto err_remap;
- }
-
- /* Clear the FPGA VME IF contents */
- iowrite32(0, vmic_base + VME_CONTROL);
-
- /* Clear any initial BERR */
- data = ioread32(vmic_base + VME_CONTROL) & 0x00000FFF;
- data |= BM_VME_CONTROL_BERRST;
- iowrite32(data, vmic_base + VME_CONTROL);
-
- /* Enable the vme interface and byte swapping */
- data = ioread32(vmic_base + VME_CONTROL) & 0x00000FFF;
- data = data | BM_VME_CONTROL_MASTER_ENDIAN |
- BM_VME_CONTROL_SLAVE_ENDIAN |
- BM_VME_CONTROL_ABLE |
- BM_VME_CONTROL_BERRI |
- BM_VME_CONTROL_BPENA |
- BM_VME_CONTROL_VBENA;
- iowrite32(data, vmic_base + VME_CONTROL);
-
- return 0;
-
-err_remap:
- pci_release_regions(pdev);
-err_resource:
- pci_disable_device(pdev);
-err:
- return retval;
-}
-
-static void vmic_remove(struct pci_dev *pdev)
-{
- iounmap(vmic_base);
- pci_release_regions(pdev);
- pci_disable_device(pdev);
-
-}
-
-static void __exit vmic_exit(void)
-{
- pci_unregister_driver(&vmic_driver);
-}
-
-MODULE_DESCRIPTION("VMIVME-7805 board support driver");
-MODULE_AUTHOR("Arthur Benilov <arthur.benilov@iba-group.com>");
-MODULE_LICENSE("GPL");
-
-module_init(vmic_init);
-module_exit(vmic_exit);
-
diff --git a/drivers/staging/vme/boards/vme_vmivme7805.h b/drivers/staging/vme/boards/vme_vmivme7805.h
deleted file mode 100644
index 44c2c449808c..000000000000
--- a/drivers/staging/vme/boards/vme_vmivme7805.h
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * vmivme_7805.h
- *
- * Support for the VMIVME-7805 board access to the Universe II bridge.
- *
- * Author: Arthur Benilov <arthur.benilov@iba-group.com>
- * Copyright 2010 Ion Beam Application, 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.
- */
-
-
-#ifndef _VMIVME_7805_H
-#define _VMIVME_7805_H
-
-#ifndef PCI_VENDOR_ID_VMIC
-#define PCI_VENDOR_ID_VMIC 0x114A
-#endif
-
-#ifndef PCI_DEVICE_ID_VTIMR
-#define PCI_DEVICE_ID_VTIMR 0x0004
-#endif
-
-#define VME_CONTROL 0x0000
-#define BM_VME_CONTROL_MASTER_ENDIAN 0x0001
-#define BM_VME_CONTROL_SLAVE_ENDIAN 0x0002
-#define BM_VME_CONTROL_ABLE 0x0004
-#define BM_VME_CONTROL_BERRI 0x0040
-#define BM_VME_CONTROL_BERRST 0x0080
-#define BM_VME_CONTROL_BPENA 0x0400
-#define BM_VME_CONTROL_VBENA 0x0800
-
-#endif /* _VMIVME_7805_H */
-
diff --git a/drivers/staging/vme/bridges/Kconfig b/drivers/staging/vme/bridges/Kconfig
deleted file mode 100644
index 9331064e0476..000000000000
--- a/drivers/staging/vme/bridges/Kconfig
+++ /dev/null
@@ -1,15 +0,0 @@
-comment "VME Bridge Drivers"
-
-config VME_CA91CX42
- tristate "Universe II"
- depends on VIRT_TO_BUS
- help
- If you say Y here you get support for the Tundra CA91C142
- (Universe II) VME bridge chip.
-
-config VME_TSI148
- tristate "Tempe"
- depends on VIRT_TO_BUS
- help
- If you say Y here you get support for the Tundra TSI148 VME bridge
- chip.
diff --git a/drivers/staging/vme/bridges/Makefile b/drivers/staging/vme/bridges/Makefile
deleted file mode 100644
index 59638afcd502..000000000000
--- a/drivers/staging/vme/bridges/Makefile
+++ /dev/null
@@ -1,2 +0,0 @@
-obj-$(CONFIG_VME_CA91CX42) += vme_ca91cx42.o
-obj-$(CONFIG_VME_TSI148) += vme_tsi148.o
diff --git a/drivers/staging/vme/bridges/vme_ca91cx42.c b/drivers/staging/vme/bridges/vme_ca91cx42.c
deleted file mode 100644
index 515b8b8e32a8..000000000000
--- a/drivers/staging/vme/bridges/vme_ca91cx42.c
+++ /dev/null
@@ -1,1959 +0,0 @@
-/*
- * Support for the Tundra Universe I/II VME-PCI Bridge Chips
- *
- * Author: Martyn Welch <martyn.welch@ge.com>
- * Copyright 2008 GE Intelligent Platforms Embedded Systems, Inc.
- *
- * Based on work by Tom Armistead and Ajit Prem
- * Copyright 2004 Motorola Inc.
- *
- * Derived from ca91c042.c by Michael Wyrick
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version.
- */
-
-#include <linux/module.h>
-#include <linux/mm.h>
-#include <linux/types.h>
-#include <linux/errno.h>
-#include <linux/pci.h>
-#include <linux/dma-mapping.h>
-#include <linux/poll.h>
-#include <linux/interrupt.h>
-#include <linux/spinlock.h>
-#include <linux/sched.h>
-#include <linux/slab.h>
-#include <linux/time.h>
-#include <linux/io.h>
-#include <linux/uaccess.h>
-
-#include "../vme.h"
-#include "../vme_bridge.h"
-#include "vme_ca91cx42.h"
-
-static int __init ca91cx42_init(void);
-static int ca91cx42_probe(struct pci_dev *, const struct pci_device_id *);
-static void ca91cx42_remove(struct pci_dev *);
-static void __exit ca91cx42_exit(void);
-
-/* Module parameters */
-static int geoid;
-
-static const char driver_name[] = "vme_ca91cx42";
-
-static DEFINE_PCI_DEVICE_TABLE(ca91cx42_ids) = {
- { PCI_DEVICE(PCI_VENDOR_ID_TUNDRA, PCI_DEVICE_ID_TUNDRA_CA91C142) },
- { },
-};
-
-static struct pci_driver ca91cx42_driver = {
- .name = driver_name,
- .id_table = ca91cx42_ids,
- .probe = ca91cx42_probe,
- .remove = ca91cx42_remove,
-};
-
-static u32 ca91cx42_DMA_irqhandler(struct ca91cx42_driver *bridge)
-{
- wake_up(&bridge->dma_queue);
-
- return CA91CX42_LINT_DMA;
-}
-
-static u32 ca91cx42_LM_irqhandler(struct ca91cx42_driver *bridge, u32 stat)
-{
- int i;
- u32 serviced = 0;
-
- for (i = 0; i < 4; i++) {
- if (stat & CA91CX42_LINT_LM[i]) {
- /* We only enable interrupts if the callback is set */
- bridge->lm_callback[i](i);
- serviced |= CA91CX42_LINT_LM[i];
- }
- }
-
- return serviced;
-}
-
-/* XXX This needs to be split into 4 queues */
-static u32 ca91cx42_MB_irqhandler(struct ca91cx42_driver *bridge, int mbox_mask)
-{
- wake_up(&bridge->mbox_queue);
-
- return CA91CX42_LINT_MBOX;
-}
-
-static u32 ca91cx42_IACK_irqhandler(struct ca91cx42_driver *bridge)
-{
- wake_up(&bridge->iack_queue);
-
- return CA91CX42_LINT_SW_IACK;
-}
-
-static u32 ca91cx42_VERR_irqhandler(struct vme_bridge *ca91cx42_bridge)
-{
- int val;
- struct ca91cx42_driver *bridge;
-
- bridge = ca91cx42_bridge->driver_priv;
-
- val = ioread32(bridge->base + DGCS);
-
- if (!(val & 0x00000800)) {
- dev_err(ca91cx42_bridge->parent, "ca91cx42_VERR_irqhandler DMA "
- "Read Error DGCS=%08X\n", val);
- }
-
- return CA91CX42_LINT_VERR;
-}
-
-static u32 ca91cx42_LERR_irqhandler(struct vme_bridge *ca91cx42_bridge)
-{
- int val;
- struct ca91cx42_driver *bridge;
-
- bridge = ca91cx42_bridge->driver_priv;
-
- val = ioread32(bridge->base + DGCS);
-
- if (!(val & 0x00000800))
- dev_err(ca91cx42_bridge->parent, "ca91cx42_LERR_irqhandler DMA "
- "Read Error DGCS=%08X\n", val);
-
- return CA91CX42_LINT_LERR;
-}
-
-
-static u32 ca91cx42_VIRQ_irqhandler(struct vme_bridge *ca91cx42_bridge,
- int stat)
-{
- int vec, i, serviced = 0;
- struct ca91cx42_driver *bridge;
-
- bridge = ca91cx42_bridge->driver_priv;
-
-
- for (i = 7; i > 0; i--) {
- if (stat & (1 << i)) {
- vec = ioread32(bridge->base +
- CA91CX42_V_STATID[i]) & 0xff;
-
- vme_irq_handler(ca91cx42_bridge, i, vec);
-
- serviced |= (1 << i);
- }
- }
-
- return serviced;
-}
-
-static irqreturn_t ca91cx42_irqhandler(int irq, void *ptr)
-{
- u32 stat, enable, serviced = 0;
- struct vme_bridge *ca91cx42_bridge;
- struct ca91cx42_driver *bridge;
-
- ca91cx42_bridge = ptr;
-
- bridge = ca91cx42_bridge->driver_priv;
-
- enable = ioread32(bridge->base + LINT_EN);
- stat = ioread32(bridge->base + LINT_STAT);
-
- /* Only look at unmasked interrupts */
- stat &= enable;
-
- if (unlikely(!stat))
- return IRQ_NONE;
-
- if (stat & CA91CX42_LINT_DMA)
- serviced |= ca91cx42_DMA_irqhandler(bridge);
- if (stat & (CA91CX42_LINT_LM0 | CA91CX42_LINT_LM1 | CA91CX42_LINT_LM2 |
- CA91CX42_LINT_LM3))
- serviced |= ca91cx42_LM_irqhandler(bridge, stat);
- if (stat & CA91CX42_LINT_MBOX)
- serviced |= ca91cx42_MB_irqhandler(bridge, stat);
- if (stat & CA91CX42_LINT_SW_IACK)
- serviced |= ca91cx42_IACK_irqhandler(bridge);
- if (stat & CA91CX42_LINT_VERR)
- serviced |= ca91cx42_VERR_irqhandler(ca91cx42_bridge);
- if (stat & CA91CX42_LINT_LERR)
- serviced |= ca91cx42_LERR_irqhandler(ca91cx42_bridge);
- if (stat & (CA91CX42_LINT_VIRQ1 | CA91CX42_LINT_VIRQ2 |
- CA91CX42_LINT_VIRQ3 | CA91CX42_LINT_VIRQ4 |
- CA91CX42_LINT_VIRQ5 | CA91CX42_LINT_VIRQ6 |
- CA91CX42_LINT_VIRQ7))
- serviced |= ca91cx42_VIRQ_irqhandler(ca91cx42_bridge, stat);
-
- /* Clear serviced interrupts */
- iowrite32(serviced, bridge->base + LINT_STAT);
-
- return IRQ_HANDLED;
-}
-
-static int ca91cx42_irq_init(struct vme_bridge *ca91cx42_bridge)
-{
- int result, tmp;
- struct pci_dev *pdev;
- struct ca91cx42_driver *bridge;
-
- bridge = ca91cx42_bridge->driver_priv;
-
- /* Need pdev */
- pdev = container_of(ca91cx42_bridge->parent, struct pci_dev, dev);
-
- /* Initialise list for VME bus errors */
- INIT_LIST_HEAD(&ca91cx42_bridge->vme_errors);
-
- mutex_init(&ca91cx42_bridge->irq_mtx);
-
- /* Disable interrupts from PCI to VME */
- iowrite32(0, bridge->base + VINT_EN);
-
- /* Disable PCI interrupts */
- iowrite32(0, bridge->base + LINT_EN);
- /* Clear Any Pending PCI Interrupts */
- iowrite32(0x00FFFFFF, bridge->base + LINT_STAT);
-
- result = request_irq(pdev->irq, ca91cx42_irqhandler, IRQF_SHARED,
- driver_name, ca91cx42_bridge);
- if (result) {
- dev_err(&pdev->dev, "Can't get assigned pci irq vector %02X\n",
- pdev->irq);
- return result;
- }
-
- /* Ensure all interrupts are mapped to PCI Interrupt 0 */
- iowrite32(0, bridge->base + LINT_MAP0);
- iowrite32(0, bridge->base + LINT_MAP1);
- iowrite32(0, bridge->base + LINT_MAP2);
-
- /* Enable DMA, mailbox & LM Interrupts */
- tmp = CA91CX42_LINT_MBOX3 | CA91CX42_LINT_MBOX2 | CA91CX42_LINT_MBOX1 |
- CA91CX42_LINT_MBOX0 | CA91CX42_LINT_SW_IACK |
- CA91CX42_LINT_VERR | CA91CX42_LINT_LERR | CA91CX42_LINT_DMA;
-
- iowrite32(tmp, bridge->base + LINT_EN);
-
- return 0;
-}
-
-static void ca91cx42_irq_exit(struct ca91cx42_driver *bridge,
- struct pci_dev *pdev)
-{
- /* Disable interrupts from PCI to VME */
- iowrite32(0, bridge->base + VINT_EN);
-
- /* Disable PCI interrupts */
- iowrite32(0, bridge->base + LINT_EN);
- /* Clear Any Pending PCI Interrupts */
- iowrite32(0x00FFFFFF, bridge->base + LINT_STAT);
-
- free_irq(pdev->irq, pdev);
-}
-
-static int ca91cx42_iack_received(struct ca91cx42_driver *bridge, int level)
-{
- u32 tmp;
-
- tmp = ioread32(bridge->base + LINT_STAT);
-
- if (tmp & (1 << level))
- return 0;
- else
- return 1;
-}
-
-/*
- * Set up an VME interrupt
- */
-static void ca91cx42_irq_set(struct vme_bridge *ca91cx42_bridge, int level,
- int state, int sync)
-
-{
- struct pci_dev *pdev;
- u32 tmp;
- struct ca91cx42_driver *bridge;
-
- bridge = ca91cx42_bridge->driver_priv;
-
- /* Enable IRQ level */
- tmp = ioread32(bridge->base + LINT_EN);
-
- if (state == 0)
- tmp &= ~CA91CX42_LINT_VIRQ[level];
- else
- tmp |= CA91CX42_LINT_VIRQ[level];
-
- iowrite32(tmp, bridge->base + LINT_EN);
-
- if ((state == 0) && (sync != 0)) {
- pdev = container_of(ca91cx42_bridge->parent, struct pci_dev,
- dev);
-
- synchronize_irq(pdev->irq);
- }
-}
-
-static int ca91cx42_irq_generate(struct vme_bridge *ca91cx42_bridge, int level,
- int statid)
-{
- u32 tmp;
- struct ca91cx42_driver *bridge;
-
- bridge = ca91cx42_bridge->driver_priv;
-
- /* Universe can only generate even vectors */
- if (statid & 1)
- return -EINVAL;
-
- mutex_lock(&bridge->vme_int);
-
- tmp = ioread32(bridge->base + VINT_EN);
-
- /* Set Status/ID */
- iowrite32(statid << 24, bridge->base + STATID);
-
- /* Assert VMEbus IRQ */
- tmp = tmp | (1 << (level + 24));
- iowrite32(tmp, bridge->base + VINT_EN);
-
- /* Wait for IACK */
- wait_event_interruptible(bridge->iack_queue,
- ca91cx42_iack_received(bridge, level));
-
- /* Return interrupt to low state */
- tmp = ioread32(bridge->base + VINT_EN);
- tmp = tmp & ~(1 << (level + 24));
- iowrite32(tmp, bridge->base + VINT_EN);
-
- mutex_unlock(&bridge->vme_int);
-
- return 0;
-}
-
-static int ca91cx42_slave_set(struct vme_slave_resource *image, int enabled,
- unsigned long long vme_base, unsigned long long size,
- dma_addr_t pci_base, u32 aspace, u32 cycle)
-{
- unsigned int i, addr = 0, granularity;
- unsigned int temp_ctl = 0;
- unsigned int vme_bound, pci_offset;
- struct vme_bridge *ca91cx42_bridge;
- struct ca91cx42_driver *bridge;
-
- ca91cx42_bridge = image->parent;
-
- bridge = ca91cx42_bridge->driver_priv;
-
- i = image->number;
-
- switch (aspace) {
- case VME_A16:
- addr |= CA91CX42_VSI_CTL_VAS_A16;
- break;
- case VME_A24:
- addr |= CA91CX42_VSI_CTL_VAS_A24;
- break;
- case VME_A32:
- addr |= CA91CX42_VSI_CTL_VAS_A32;
- break;
- case VME_USER1:
- addr |= CA91CX42_VSI_CTL_VAS_USER1;
- break;
- case VME_USER2:
- addr |= CA91CX42_VSI_CTL_VAS_USER2;
- break;
- case VME_A64:
- case VME_CRCSR:
- case VME_USER3:
- case VME_USER4:
- default:
- dev_err(ca91cx42_bridge->parent, "Invalid address space\n");
- return -EINVAL;
- break;
- }
-
- /*
- * Bound address is a valid address for the window, adjust
- * accordingly
- */
- vme_bound = vme_base + size;
- pci_offset = pci_base - vme_base;
-
- if ((i == 0) || (i == 4))
- granularity = 0x1000;
- else
- granularity = 0x10000;
-
- if (vme_base & (granularity - 1)) {
- dev_err(ca91cx42_bridge->parent, "Invalid VME base "
- "alignment\n");
- return -EINVAL;
- }
- if (vme_bound & (granularity - 1)) {
- dev_err(ca91cx42_bridge->parent, "Invalid VME bound "
- "alignment\n");
- return -EINVAL;
- }
- if (pci_offset & (granularity - 1)) {
- dev_err(ca91cx42_bridge->parent, "Invalid PCI Offset "
- "alignment\n");
- return -EINVAL;
- }
-
- /* Disable while we are mucking around */
- temp_ctl = ioread32(bridge->base + CA91CX42_VSI_CTL[i]);
- temp_ctl &= ~CA91CX42_VSI_CTL_EN;
- iowrite32(temp_ctl, bridge->base + CA91CX42_VSI_CTL[i]);
-
- /* Setup mapping */
- iowrite32(vme_base, bridge->base + CA91CX42_VSI_BS[i]);
- iowrite32(vme_bound, bridge->base + CA91CX42_VSI_BD[i]);
- iowrite32(pci_offset, bridge->base + CA91CX42_VSI_TO[i]);
-
- /* Setup address space */
- temp_ctl &= ~CA91CX42_VSI_CTL_VAS_M;
- temp_ctl |= addr;
-
- /* Setup cycle types */
- temp_ctl &= ~(CA91CX42_VSI_CTL_PGM_M | CA91CX42_VSI_CTL_SUPER_M);
- if (cycle & VME_SUPER)
- temp_ctl |= CA91CX42_VSI_CTL_SUPER_SUPR;
- if (cycle & VME_USER)
- temp_ctl |= CA91CX42_VSI_CTL_SUPER_NPRIV;
- if (cycle & VME_PROG)
- temp_ctl |= CA91CX42_VSI_CTL_PGM_PGM;
- if (cycle & VME_DATA)
- temp_ctl |= CA91CX42_VSI_CTL_PGM_DATA;
-
- /* Write ctl reg without enable */
- iowrite32(temp_ctl, bridge->base + CA91CX42_VSI_CTL[i]);
-
- if (enabled)
- temp_ctl |= CA91CX42_VSI_CTL_EN;
-
- iowrite32(temp_ctl, bridge->base + CA91CX42_VSI_CTL[i]);
-
- return 0;
-}
-
-static int ca91cx42_slave_get(struct vme_slave_resource *image, int *enabled,
- unsigned long long *vme_base, unsigned long long *size,
- dma_addr_t *pci_base, u32 *aspace, u32 *cycle)
-{
- unsigned int i, granularity = 0, ctl = 0;
- unsigned long long vme_bound, pci_offset;
- struct ca91cx42_driver *bridge;
-
- bridge = image->parent->driver_priv;
-
- i = image->number;
-
- if ((i == 0) || (i == 4))
- granularity = 0x1000;
- else
- granularity = 0x10000;
-
- /* Read Registers */
- ctl = ioread32(bridge->base + CA91CX42_VSI_CTL[i]);
-
- *vme_base = ioread32(bridge->base + CA91CX42_VSI_BS[i]);
- vme_bound = ioread32(bridge->base + CA91CX42_VSI_BD[i]);
- pci_offset = ioread32(bridge->base + CA91CX42_VSI_TO[i]);
-
- *pci_base = (dma_addr_t)vme_base + pci_offset;
- *size = (unsigned long long)((vme_bound - *vme_base) + granularity);
-
- *enabled = 0;
- *aspace = 0;
- *cycle = 0;
-
- if (ctl & CA91CX42_VSI_CTL_EN)
- *enabled = 1;
-
- if ((ctl & CA91CX42_VSI_CTL_VAS_M) == CA91CX42_VSI_CTL_VAS_A16)
- *aspace = VME_A16;
- if ((ctl & CA91CX42_VSI_CTL_VAS_M) == CA91CX42_VSI_CTL_VAS_A24)
- *aspace = VME_A24;
- if ((ctl & CA91CX42_VSI_CTL_VAS_M) == CA91CX42_VSI_CTL_VAS_A32)
- *aspace = VME_A32;
- if ((ctl & CA91CX42_VSI_CTL_VAS_M) == CA91CX42_VSI_CTL_VAS_USER1)
- *aspace = VME_USER1;
- if ((ctl & CA91CX42_VSI_CTL_VAS_M) == CA91CX42_VSI_CTL_VAS_USER2)
- *aspace = VME_USER2;
-
- if (ctl & CA91CX42_VSI_CTL_SUPER_SUPR)
- *cycle |= VME_SUPER;
- if (ctl & CA91CX42_VSI_CTL_SUPER_NPRIV)
- *cycle |= VME_USER;
- if (ctl & CA91CX42_VSI_CTL_PGM_PGM)
- *cycle |= VME_PROG;
- if (ctl & CA91CX42_VSI_CTL_PGM_DATA)
- *cycle |= VME_DATA;
-
- return 0;
-}
-
-/*
- * Allocate and map PCI Resource
- */
-static int ca91cx42_alloc_resource(struct vme_master_resource *image,
- unsigned long long size)
-{
- unsigned long long existing_size;
- int retval = 0;
- struct pci_dev *pdev;
- struct vme_bridge *ca91cx42_bridge;
-
- ca91cx42_bridge = image->parent;
-
- /* Find pci_dev container of dev */
- if (ca91cx42_bridge->parent == NULL) {
- dev_err(ca91cx42_bridge->parent, "Dev entry NULL\n");
- return -EINVAL;
- }
- pdev = container_of(ca91cx42_bridge->parent, struct pci_dev, dev);
-
- existing_size = (unsigned long long)(image->bus_resource.end -
- image->bus_resource.start);
-
- /* If the existing size is OK, return */
- if (existing_size == (size - 1))
- return 0;
-
- if (existing_size != 0) {
- iounmap(image->kern_base);
- image->kern_base = NULL;
- kfree(image->bus_resource.name);
- release_resource(&image->bus_resource);
- memset(&image->bus_resource, 0, sizeof(struct resource));
- }
-
- if (image->bus_resource.name == NULL) {
- image->bus_resource.name = kmalloc(VMENAMSIZ+3, GFP_ATOMIC);
- if (image->bus_resource.name == NULL) {
- dev_err(ca91cx42_bridge->parent, "Unable to allocate "
- "memory for resource name\n");
- retval = -ENOMEM;
- goto err_name;
- }
- }
-
- sprintf((char *)image->bus_resource.name, "%s.%d",
- ca91cx42_bridge->name, image->number);
-
- image->bus_resource.start = 0;
- image->bus_resource.end = (unsigned long)size;
- image->bus_resource.flags = IORESOURCE_MEM;
-
- retval = pci_bus_alloc_resource(pdev->bus,
- &image->bus_resource, size, size, PCIBIOS_MIN_MEM,
- 0, NULL, NULL);
- if (retval) {
- dev_err(ca91cx42_bridge->parent, "Failed to allocate mem "
- "resource for window %d size 0x%lx start 0x%lx\n",
- image->number, (unsigned long)size,
- (unsigned long)image->bus_resource.start);
- goto err_resource;
- }
-
- image->kern_base = ioremap_nocache(
- image->bus_resource.start, size);
- if (image->kern_base == NULL) {
- dev_err(ca91cx42_bridge->parent, "Failed to remap resource\n");
- retval = -ENOMEM;
- goto err_remap;
- }
-
- return 0;
-
-err_remap:
- release_resource(&image->bus_resource);
-err_resource:
- kfree(image->bus_resource.name);
- memset(&image->bus_resource, 0, sizeof(struct resource));
-err_name:
- return retval;
-}
-
-/*
- * Free and unmap PCI Resource
- */
-static void ca91cx42_free_resource(struct vme_master_resource *image)
-{
- iounmap(image->kern_base);
- image->kern_base = NULL;
- release_resource(&image->bus_resource);
- kfree(image->bus_resource.name);
- memset(&image->bus_resource, 0, sizeof(struct resource));
-}
-
-
-static int ca91cx42_master_set(struct vme_master_resource *image, int enabled,
- unsigned long long vme_base, unsigned long long size, u32 aspace,
- u32 cycle, u32 dwidth)
-{
- int retval = 0;
- unsigned int i, granularity = 0;
- unsigned int temp_ctl = 0;
- unsigned long long pci_bound, vme_offset, pci_base;
- struct vme_bridge *ca91cx42_bridge;
- struct ca91cx42_driver *bridge;
-
- ca91cx42_bridge = image->parent;
-
- bridge = ca91cx42_bridge->driver_priv;
-
- i = image->number;
-
- if ((i == 0) || (i == 4))
- granularity = 0x1000;
- else
- granularity = 0x10000;
-
- /* Verify input data */
- if (vme_base & (granularity - 1)) {
- dev_err(ca91cx42_bridge->parent, "Invalid VME Window "
- "alignment\n");
- retval = -EINVAL;
- goto err_window;
- }
- if (size & (granularity - 1)) {
- dev_err(ca91cx42_bridge->parent, "Invalid VME Window "
- "alignment\n");
- retval = -EINVAL;
- goto err_window;
- }
-
- spin_lock(&image->lock);
-
- /*
- * Let's allocate the resource here rather than further up the stack as
- * it avoids pushing loads of bus dependent stuff up the stack
- */
- retval = ca91cx42_alloc_resource(image, size);
- if (retval) {
- spin_unlock(&image->lock);
- dev_err(ca91cx42_bridge->parent, "Unable to allocate memory "
- "for resource name\n");
- retval = -ENOMEM;
- goto err_res;
- }
-
- pci_base = (unsigned long long)image->bus_resource.start;
-
- /*
- * Bound address is a valid address for the window, adjust
- * according to window granularity.
- */
- pci_bound = pci_base + size;
- vme_offset = vme_base - pci_base;
-
- /* Disable while we are mucking around */
- temp_ctl = ioread32(bridge->base + CA91CX42_LSI_CTL[i]);
- temp_ctl &= ~CA91CX42_LSI_CTL_EN;
- iowrite32(temp_ctl, bridge->base + CA91CX42_LSI_CTL[i]);
-
- /* Setup cycle types */
- temp_ctl &= ~CA91CX42_LSI_CTL_VCT_M;
- if (cycle & VME_BLT)
- temp_ctl |= CA91CX42_LSI_CTL_VCT_BLT;
- if (cycle & VME_MBLT)
- temp_ctl |= CA91CX42_LSI_CTL_VCT_MBLT;
-
- /* Setup data width */
- temp_ctl &= ~CA91CX42_LSI_CTL_VDW_M;
- switch (dwidth) {
- case VME_D8:
- temp_ctl |= CA91CX42_LSI_CTL_VDW_D8;
- break;
- case VME_D16:
- temp_ctl |= CA91CX42_LSI_CTL_VDW_D16;
- break;
- case VME_D32:
- temp_ctl |= CA91CX42_LSI_CTL_VDW_D32;
- break;
- case VME_D64:
- temp_ctl |= CA91CX42_LSI_CTL_VDW_D64;
- break;
- default:
- spin_unlock(&image->lock);
- dev_err(ca91cx42_bridge->parent, "Invalid data width\n");
- retval = -EINVAL;
- goto err_dwidth;
- break;
- }
-
- /* Setup address space */
- temp_ctl &= ~CA91CX42_LSI_CTL_VAS_M;
- switch (aspace) {
- case VME_A16:
- temp_ctl |= CA91CX42_LSI_CTL_VAS_A16;
- break;
- case VME_A24:
- temp_ctl |= CA91CX42_LSI_CTL_VAS_A24;
- break;
- case VME_A32:
- temp_ctl |= CA91CX42_LSI_CTL_VAS_A32;
- break;
- case VME_CRCSR:
- temp_ctl |= CA91CX42_LSI_CTL_VAS_CRCSR;
- break;
- case VME_USER1:
- temp_ctl |= CA91CX42_LSI_CTL_VAS_USER1;
- break;
- case VME_USER2:
- temp_ctl |= CA91CX42_LSI_CTL_VAS_USER2;
- break;
- case VME_A64:
- case VME_USER3:
- case VME_USER4:
- default:
- spin_unlock(&image->lock);
- dev_err(ca91cx42_bridge->parent, "Invalid address space\n");
- retval = -EINVAL;
- goto err_aspace;
- break;
- }
-
- temp_ctl &= ~(CA91CX42_LSI_CTL_PGM_M | CA91CX42_LSI_CTL_SUPER_M);
- if (cycle & VME_SUPER)
- temp_ctl |= CA91CX42_LSI_CTL_SUPER_SUPR;
- if (cycle & VME_PROG)
- temp_ctl |= CA91CX42_LSI_CTL_PGM_PGM;
-
- /* Setup mapping */
- iowrite32(pci_base, bridge->base + CA91CX42_LSI_BS[i]);
- iowrite32(pci_bound, bridge->base + CA91CX42_LSI_BD[i]);
- iowrite32(vme_offset, bridge->base + CA91CX42_LSI_TO[i]);
-
- /* Write ctl reg without enable */
- iowrite32(temp_ctl, bridge->base + CA91CX42_LSI_CTL[i]);
-
- if (enabled)
- temp_ctl |= CA91CX42_LSI_CTL_EN;
-
- iowrite32(temp_ctl, bridge->base + CA91CX42_LSI_CTL[i]);
-
- spin_unlock(&image->lock);
- return 0;
-
-err_aspace:
-err_dwidth:
- ca91cx42_free_resource(image);
-err_res:
-err_window:
- return retval;
-}
-
-static int __ca91cx42_master_get(struct vme_master_resource *image,
- int *enabled, unsigned long long *vme_base, unsigned long long *size,
- u32 *aspace, u32 *cycle, u32 *dwidth)
-{
- unsigned int i, ctl;
- unsigned long long pci_base, pci_bound, vme_offset;
- struct ca91cx42_driver *bridge;
-
- bridge = image->parent->driver_priv;
-
- i = image->number;
-
- ctl = ioread32(bridge->base + CA91CX42_LSI_CTL[i]);
-
- pci_base = ioread32(bridge->base + CA91CX42_LSI_BS[i]);
- vme_offset = ioread32(bridge->base + CA91CX42_LSI_TO[i]);
- pci_bound = ioread32(bridge->base + CA91CX42_LSI_BD[i]);
-
- *vme_base = pci_base + vme_offset;
- *size = (unsigned long long)(pci_bound - pci_base);
-
- *enabled = 0;
- *aspace = 0;
- *cycle = 0;
- *dwidth = 0;
-
- if (ctl & CA91CX42_LSI_CTL_EN)
- *enabled = 1;
-
- /* Setup address space */
- switch (ctl & CA91CX42_LSI_CTL_VAS_M) {
- case CA91CX42_LSI_CTL_VAS_A16:
- *aspace = VME_A16;
- break;
- case CA91CX42_LSI_CTL_VAS_A24:
- *aspace = VME_A24;
- break;
- case CA91CX42_LSI_CTL_VAS_A32:
- *aspace = VME_A32;
- break;
- case CA91CX42_LSI_CTL_VAS_CRCSR:
- *aspace = VME_CRCSR;
- break;
- case CA91CX42_LSI_CTL_VAS_USER1:
- *aspace = VME_USER1;
- break;
- case CA91CX42_LSI_CTL_VAS_USER2:
- *aspace = VME_USER2;
- break;
- }
-
- /* XXX Not sure howto check for MBLT */
- /* Setup cycle types */
- if (ctl & CA91CX42_LSI_CTL_VCT_BLT)
- *cycle |= VME_BLT;
- else
- *cycle |= VME_SCT;
-
- if (ctl & CA91CX42_LSI_CTL_SUPER_SUPR)
- *cycle |= VME_SUPER;
- else
- *cycle |= VME_USER;
-
- if (ctl & CA91CX42_LSI_CTL_PGM_PGM)
- *cycle = VME_PROG;
- else
- *cycle = VME_DATA;
-
- /* Setup data width */
- switch (ctl & CA91CX42_LSI_CTL_VDW_M) {
- case CA91CX42_LSI_CTL_VDW_D8:
- *dwidth = VME_D8;
- break;
- case CA91CX42_LSI_CTL_VDW_D16:
- *dwidth = VME_D16;
- break;
- case CA91CX42_LSI_CTL_VDW_D32:
- *dwidth = VME_D32;
- break;
- case CA91CX42_LSI_CTL_VDW_D64:
- *dwidth = VME_D64;
- break;
- }
-
- return 0;
-}
-
-static int ca91cx42_master_get(struct vme_master_resource *image, int *enabled,
- unsigned long long *vme_base, unsigned long long *size, u32 *aspace,
- u32 *cycle, u32 *dwidth)
-{
- int retval;
-
- spin_lock(&image->lock);
-
- retval = __ca91cx42_master_get(image, enabled, vme_base, size, aspace,
- cycle, dwidth);
-
- spin_unlock(&image->lock);
-
- return retval;
-}
-
-static ssize_t ca91cx42_master_read(struct vme_master_resource *image,
- void *buf, size_t count, loff_t offset)
-{
- ssize_t retval;
- void *addr = image->kern_base + offset;
- unsigned int done = 0;
- unsigned int count32;
-
- if (count == 0)
- return 0;
-
- spin_lock(&image->lock);
-
- /* The following code handles VME address alignment problem
- * in order to assure the maximal data width cycle.
- * We cannot use memcpy_xxx directly here because it
- * may cut data transfer in 8-bits cycles, thus making
- * D16 cycle impossible.
- * From the other hand, the bridge itself assures that
- * maximal configured data cycle is used and splits it
- * automatically for non-aligned addresses.
- */
- if ((uintptr_t)addr & 0x1) {
- *(u8 *)buf = ioread8(addr);
- done += 1;
- if (done == count)
- goto out;
- }
- if ((uintptr_t)addr & 0x2) {
- if ((count - done) < 2) {
- *(u8 *)(buf + done) = ioread8(addr + done);
- done += 1;
- goto out;
- } else {
- *(u16 *)(buf + done) = ioread16(addr + done);
- done += 2;
- }
- }
-
- count32 = (count - done) & ~0x3;
- if (count32 > 0) {
- memcpy_fromio(buf + done, addr + done, (unsigned int)count);
- done += count32;
- }
-
- if ((count - done) & 0x2) {
- *(u16 *)(buf + done) = ioread16(addr + done);
- done += 2;
- }
- if ((count - done) & 0x1) {
- *(u8 *)(buf + done) = ioread8(addr + done);
- done += 1;
- }
-out:
- retval = count;
- spin_unlock(&image->lock);
-
- return retval;
-}
-
-static ssize_t ca91cx42_master_write(struct vme_master_resource *image,
- void *buf, size_t count, loff_t offset)
-{
- ssize_t retval;
- void *addr = image->kern_base + offset;
- unsigned int done = 0;
- unsigned int count32;
-
- if (count == 0)
- return 0;
-
- spin_lock(&image->lock);
-
- /* Here we apply for the same strategy we do in master_read
- * function in order to assure D16 cycle when required.
- */
- if ((uintptr_t)addr & 0x1) {
- iowrite8(*(u8 *)buf, addr);
- done += 1;
- if (done == count)
- goto out;
- }
- if ((uintptr_t)addr & 0x2) {
- if ((count - done) < 2) {
- iowrite8(*(u8 *)(buf + done), addr + done);
- done += 1;
- goto out;
- } else {
- iowrite16(*(u16 *)(buf + done), addr + done);
- done += 2;
- }
- }
-
- count32 = (count - done) & ~0x3;
- if (count32 > 0) {
- memcpy_toio(addr + done, buf + done, count32);
- done += count32;
- }
-
- if ((count - done) & 0x2) {
- iowrite16(*(u16 *)(buf + done), addr + done);
- done += 2;
- }
- if ((count - done) & 0x1) {
- iowrite8(*(u8 *)(buf + done), addr + done);
- done += 1;
- }
-out:
- retval = count;
-
- spin_unlock(&image->lock);
-
- return retval;
-}
-
-static unsigned int ca91cx42_master_rmw(struct vme_master_resource *image,
- unsigned int mask, unsigned int compare, unsigned int swap,
- loff_t offset)
-{
- u32 result;
- uintptr_t pci_addr;
- int i;
- struct ca91cx42_driver *bridge;
- struct device *dev;
-
- bridge = image->parent->driver_priv;
- dev = image->parent->parent;
-
- /* Find the PCI address that maps to the desired VME address */
- i = image->number;
-
- /* Locking as we can only do one of these at a time */
- mutex_lock(&bridge->vme_rmw);
-
- /* Lock image */
- spin_lock(&image->lock);
-
- pci_addr = (uintptr_t)image->kern_base + offset;
-
- /* Address must be 4-byte aligned */
- if (pci_addr & 0x3) {
- dev_err(dev, "RMW Address not 4-byte aligned\n");
- result = -EINVAL;
- goto out;
- }
-
- /* Ensure RMW Disabled whilst configuring */
- iowrite32(0, bridge->base + SCYC_CTL);
-
- /* Configure registers */
- iowrite32(mask, bridge->base + SCYC_EN);
- iowrite32(compare, bridge->base + SCYC_CMP);
- iowrite32(swap, bridge->base + SCYC_SWP);
- iowrite32(pci_addr, bridge->base + SCYC_ADDR);
-
- /* Enable RMW */
- iowrite32(CA91CX42_SCYC_CTL_CYC_RMW, bridge->base + SCYC_CTL);
-
- /* Kick process off with a read to the required address. */
- result = ioread32(image->kern_base + offset);
-
- /* Disable RMW */
- iowrite32(0, bridge->base + SCYC_CTL);
-
-out:
- spin_unlock(&image->lock);
-
- mutex_unlock(&bridge->vme_rmw);
-
- return result;
-}
-
-static int ca91cx42_dma_list_add(struct vme_dma_list *list,
- struct vme_dma_attr *src, struct vme_dma_attr *dest, size_t count)
-{
- struct ca91cx42_dma_entry *entry, *prev;
- struct vme_dma_pci *pci_attr;
- struct vme_dma_vme *vme_attr;
- dma_addr_t desc_ptr;
- int retval = 0;
- struct device *dev;
-
- dev = list->parent->parent->parent;
-
- /* XXX descriptor must be aligned on 64-bit boundaries */
- entry = kmalloc(sizeof(struct ca91cx42_dma_entry), GFP_KERNEL);
- if (entry == NULL) {
- dev_err(dev, "Failed to allocate memory for dma resource "
- "structure\n");
- retval = -ENOMEM;
- goto err_mem;
- }
-
- /* Test descriptor alignment */
- if ((unsigned long)&entry->descriptor & CA91CX42_DCPP_M) {
- dev_err(dev, "Descriptor not aligned to 16 byte boundary as "
- "required: %p\n", &entry->descriptor);
- retval = -EINVAL;
- goto err_align;
- }
-
- memset(&entry->descriptor, 0, sizeof(struct ca91cx42_dma_descriptor));
-
- if (dest->type == VME_DMA_VME) {
- entry->descriptor.dctl |= CA91CX42_DCTL_L2V;
- vme_attr = dest->private;
- pci_attr = src->private;
- } else {
- vme_attr = src->private;
- pci_attr = dest->private;
- }
-
- /* Check we can do fulfill required attributes */
- if ((vme_attr->aspace & ~(VME_A16 | VME_A24 | VME_A32 | VME_USER1 |
- VME_USER2)) != 0) {
-
- dev_err(dev, "Unsupported cycle type\n");
- retval = -EINVAL;
- goto err_aspace;
- }
-
- if ((vme_attr->cycle & ~(VME_SCT | VME_BLT | VME_SUPER | VME_USER |
- VME_PROG | VME_DATA)) != 0) {
-
- dev_err(dev, "Unsupported cycle type\n");
- retval = -EINVAL;
- goto err_cycle;
- }
-
- /* Check to see if we can fulfill source and destination */
- if (!(((src->type == VME_DMA_PCI) && (dest->type == VME_DMA_VME)) ||
- ((src->type == VME_DMA_VME) && (dest->type == VME_DMA_PCI)))) {
-
- dev_err(dev, "Cannot perform transfer with this "
- "source-destination combination\n");
- retval = -EINVAL;
- goto err_direct;
- }
-
- /* Setup cycle types */
- if (vme_attr->cycle & VME_BLT)
- entry->descriptor.dctl |= CA91CX42_DCTL_VCT_BLT;
-
- /* Setup data width */
- switch (vme_attr->dwidth) {
- case VME_D8:
- entry->descriptor.dctl |= CA91CX42_DCTL_VDW_D8;
- break;
- case VME_D16:
- entry->descriptor.dctl |= CA91CX42_DCTL_VDW_D16;
- break;
- case VME_D32:
- entry->descriptor.dctl |= CA91CX42_DCTL_VDW_D32;
- break;
- case VME_D64:
- entry->descriptor.dctl |= CA91CX42_DCTL_VDW_D64;
- break;
- default:
- dev_err(dev, "Invalid data width\n");
- return -EINVAL;
- }
-
- /* Setup address space */
- switch (vme_attr->aspace) {
- case VME_A16:
- entry->descriptor.dctl |= CA91CX42_DCTL_VAS_A16;
- break;
- case VME_A24:
- entry->descriptor.dctl |= CA91CX42_DCTL_VAS_A24;
- break;
- case VME_A32:
- entry->descriptor.dctl |= CA91CX42_DCTL_VAS_A32;
- break;
- case VME_USER1:
- entry->descriptor.dctl |= CA91CX42_DCTL_VAS_USER1;
- break;
- case VME_USER2:
- entry->descriptor.dctl |= CA91CX42_DCTL_VAS_USER2;
- break;
- default:
- dev_err(dev, "Invalid address space\n");
- return -EINVAL;
- break;
- }
-
- if (vme_attr->cycle & VME_SUPER)
- entry->descriptor.dctl |= CA91CX42_DCTL_SUPER_SUPR;
- if (vme_attr->cycle & VME_PROG)
- entry->descriptor.dctl |= CA91CX42_DCTL_PGM_PGM;
-
- entry->descriptor.dtbc = count;
- entry->descriptor.dla = pci_attr->address;
- entry->descriptor.dva = vme_attr->address;
- entry->descriptor.dcpp = CA91CX42_DCPP_NULL;
-
- /* Add to list */
- list_add_tail(&entry->list, &list->entries);
-
- /* Fill out previous descriptors "Next Address" */
- if (entry->list.prev != &list->entries) {
- prev = list_entry(entry->list.prev, struct ca91cx42_dma_entry,
- list);
- /* We need the bus address for the pointer */
- desc_ptr = virt_to_bus(&entry->descriptor);
- prev->descriptor.dcpp = desc_ptr & ~CA91CX42_DCPP_M;
- }
-
- return 0;
-
-err_cycle:
-err_aspace:
-err_direct:
-err_align:
- kfree(entry);
-err_mem:
- return retval;
-}
-
-static int ca91cx42_dma_busy(struct vme_bridge *ca91cx42_bridge)
-{
- u32 tmp;
- struct ca91cx42_driver *bridge;
-
- bridge = ca91cx42_bridge->driver_priv;
-
- tmp = ioread32(bridge->base + DGCS);
-
- if (tmp & CA91CX42_DGCS_ACT)
- return 0;
- else
- return 1;
-}
-
-static int ca91cx42_dma_list_exec(struct vme_dma_list *list)
-{
- struct vme_dma_resource *ctrlr;
- struct ca91cx42_dma_entry *entry;
- int retval = 0;
- dma_addr_t bus_addr;
- u32 val;
- struct device *dev;
- struct ca91cx42_driver *bridge;
-
- ctrlr = list->parent;
-
- bridge = ctrlr->parent->driver_priv;
- dev = ctrlr->parent->parent;
-
- mutex_lock(&ctrlr->mtx);
-
- if (!(list_empty(&ctrlr->running))) {
- /*
- * XXX We have an active DMA transfer and currently haven't
- * sorted out the mechanism for "pending" DMA transfers.
- * Return busy.
- */
- /* Need to add to pending here */
- mutex_unlock(&ctrlr->mtx);
- return -EBUSY;
- } else {
- list_add(&list->list, &ctrlr->running);
- }
-
- /* Get first bus address and write into registers */
- entry = list_first_entry(&list->entries, struct ca91cx42_dma_entry,
- list);
-
- bus_addr = virt_to_bus(&entry->descriptor);
-
- mutex_unlock(&ctrlr->mtx);
-
- iowrite32(0, bridge->base + DTBC);
- iowrite32(bus_addr & ~CA91CX42_DCPP_M, bridge->base + DCPP);
-
- /* Start the operation */
- val = ioread32(bridge->base + DGCS);
-
- /* XXX Could set VMEbus On and Off Counters here */
- val &= (CA91CX42_DGCS_VON_M | CA91CX42_DGCS_VOFF_M);
-
- val |= (CA91CX42_DGCS_CHAIN | CA91CX42_DGCS_STOP | CA91CX42_DGCS_HALT |
- CA91CX42_DGCS_DONE | CA91CX42_DGCS_LERR | CA91CX42_DGCS_VERR |
- CA91CX42_DGCS_PERR);
-
- iowrite32(val, bridge->base + DGCS);
-
- val |= CA91CX42_DGCS_GO;
-
- iowrite32(val, bridge->base + DGCS);
-
- wait_event_interruptible(bridge->dma_queue,
- ca91cx42_dma_busy(ctrlr->parent));
-
- /*
- * Read status register, this register is valid until we kick off a
- * new transfer.
- */
- val = ioread32(bridge->base + DGCS);
-
- if (val & (CA91CX42_DGCS_LERR | CA91CX42_DGCS_VERR |
- CA91CX42_DGCS_PERR)) {
-
- dev_err(dev, "ca91c042: DMA Error. DGCS=%08X\n", val);
- val = ioread32(bridge->base + DCTL);
- }
-
- /* Remove list from running list */
- mutex_lock(&ctrlr->mtx);
- list_del(&list->list);
- mutex_unlock(&ctrlr->mtx);
-
- return retval;
-
-}
-
-static int ca91cx42_dma_list_empty(struct vme_dma_list *list)
-{
- struct list_head *pos, *temp;
- struct ca91cx42_dma_entry *entry;
-
- /* detach and free each entry */
- list_for_each_safe(pos, temp, &list->entries) {
- list_del(pos);
- entry = list_entry(pos, struct ca91cx42_dma_entry, list);
- kfree(entry);
- }
-
- return 0;
-}
-
-/*
- * All 4 location monitors reside at the same base - this is therefore a
- * system wide configuration.
- *
- * This does not enable the LM monitor - that should be done when the first
- * callback is attached and disabled when the last callback is removed.
- */
-static int ca91cx42_lm_set(struct vme_lm_resource *lm,
- unsigned long long lm_base, u32 aspace, u32 cycle)
-{
- u32 temp_base, lm_ctl = 0;
- int i;
- struct ca91cx42_driver *bridge;
- struct device *dev;
-
- bridge = lm->parent->driver_priv;
- dev = lm->parent->parent;
-
- /* Check the alignment of the location monitor */
- temp_base = (u32)lm_base;
- if (temp_base & 0xffff) {
- dev_err(dev, "Location monitor must be aligned to 64KB "
- "boundary");
- return -EINVAL;
- }
-
- mutex_lock(&lm->mtx);
-
- /* If we already have a callback attached, we can't move it! */
- for (i = 0; i < lm->monitors; i++) {
- if (bridge->lm_callback[i] != NULL) {
- mutex_unlock(&lm->mtx);
- dev_err(dev, "Location monitor callback attached, "
- "can't reset\n");
- return -EBUSY;
- }
- }
-
- switch (aspace) {
- case VME_A16:
- lm_ctl |= CA91CX42_LM_CTL_AS_A16;
- break;
- case VME_A24:
- lm_ctl |= CA91CX42_LM_CTL_AS_A24;
- break;
- case VME_A32:
- lm_ctl |= CA91CX42_LM_CTL_AS_A32;
- break;
- default:
- mutex_unlock(&lm->mtx);
- dev_err(dev, "Invalid address space\n");
- return -EINVAL;
- break;
- }
-
- if (cycle & VME_SUPER)
- lm_ctl |= CA91CX42_LM_CTL_SUPR;
- if (cycle & VME_USER)
- lm_ctl |= CA91CX42_LM_CTL_NPRIV;
- if (cycle & VME_PROG)
- lm_ctl |= CA91CX42_LM_CTL_PGM;
- if (cycle & VME_DATA)
- lm_ctl |= CA91CX42_LM_CTL_DATA;
-
- iowrite32(lm_base, bridge->base + LM_BS);
- iowrite32(lm_ctl, bridge->base + LM_CTL);
-
- mutex_unlock(&lm->mtx);
-
- return 0;
-}
-
-/* Get configuration of the callback monitor and return whether it is enabled
- * or disabled.
- */
-static int ca91cx42_lm_get(struct vme_lm_resource *lm,
- unsigned long long *lm_base, u32 *aspace, u32 *cycle)
-{
- u32 lm_ctl, enabled = 0;
- struct ca91cx42_driver *bridge;
-
- bridge = lm->parent->driver_priv;
-
- mutex_lock(&lm->mtx);
-
- *lm_base = (unsigned long long)ioread32(bridge->base + LM_BS);
- lm_ctl = ioread32(bridge->base + LM_CTL);
-
- if (lm_ctl & CA91CX42_LM_CTL_EN)
- enabled = 1;
-
- if ((lm_ctl & CA91CX42_LM_CTL_AS_M) == CA91CX42_LM_CTL_AS_A16)
- *aspace = VME_A16;
- if ((lm_ctl & CA91CX42_LM_CTL_AS_M) == CA91CX42_LM_CTL_AS_A24)
- *aspace = VME_A24;
- if ((lm_ctl & CA91CX42_LM_CTL_AS_M) == CA91CX42_LM_CTL_AS_A32)
- *aspace = VME_A32;
-
- *cycle = 0;
- if (lm_ctl & CA91CX42_LM_CTL_SUPR)
- *cycle |= VME_SUPER;
- if (lm_ctl & CA91CX42_LM_CTL_NPRIV)
- *cycle |= VME_USER;
- if (lm_ctl & CA91CX42_LM_CTL_PGM)
- *cycle |= VME_PROG;
- if (lm_ctl & CA91CX42_LM_CTL_DATA)
- *cycle |= VME_DATA;
-
- mutex_unlock(&lm->mtx);
-
- return enabled;
-}
-
-/*
- * Attach a callback to a specific location monitor.
- *
- * Callback will be passed the monitor triggered.
- */
-static int ca91cx42_lm_attach(struct vme_lm_resource *lm, int monitor,
- void (*callback)(int))
-{
- u32 lm_ctl, tmp;
- struct ca91cx42_driver *bridge;
- struct device *dev;
-
- bridge = lm->parent->driver_priv;
- dev = lm->parent->parent;
-
- mutex_lock(&lm->mtx);
-
- /* Ensure that the location monitor is configured - need PGM or DATA */
- lm_ctl = ioread32(bridge->base + LM_CTL);
- if ((lm_ctl & (CA91CX42_LM_CTL_PGM | CA91CX42_LM_CTL_DATA)) == 0) {
- mutex_unlock(&lm->mtx);
- dev_err(dev, "Location monitor not properly configured\n");
- return -EINVAL;
- }
-
- /* Check that a callback isn't already attached */
- if (bridge->lm_callback[monitor] != NULL) {
- mutex_unlock(&lm->mtx);
- dev_err(dev, "Existing callback attached\n");
- return -EBUSY;
- }
-
- /* Attach callback */
- bridge->lm_callback[monitor] = callback;
-
- /* Enable Location Monitor interrupt */
- tmp = ioread32(bridge->base + LINT_EN);
- tmp |= CA91CX42_LINT_LM[monitor];
- iowrite32(tmp, bridge->base + LINT_EN);
-
- /* Ensure that global Location Monitor Enable set */
- if ((lm_ctl & CA91CX42_LM_CTL_EN) == 0) {
- lm_ctl |= CA91CX42_LM_CTL_EN;
- iowrite32(lm_ctl, bridge->base + LM_CTL);
- }
-
- mutex_unlock(&lm->mtx);
-
- return 0;
-}
-
-/*
- * Detach a callback function forn a specific location monitor.
- */
-static int ca91cx42_lm_detach(struct vme_lm_resource *lm, int monitor)
-{
- u32 tmp;
- struct ca91cx42_driver *bridge;
-
- bridge = lm->parent->driver_priv;
-
- mutex_lock(&lm->mtx);
-
- /* Disable Location Monitor and ensure previous interrupts are clear */
- tmp = ioread32(bridge->base + LINT_EN);
- tmp &= ~CA91CX42_LINT_LM[monitor];
- iowrite32(tmp, bridge->base + LINT_EN);
-
- iowrite32(CA91CX42_LINT_LM[monitor],
- bridge->base + LINT_STAT);
-
- /* Detach callback */
- bridge->lm_callback[monitor] = NULL;
-
- /* If all location monitors disabled, disable global Location Monitor */
- if ((tmp & (CA91CX42_LINT_LM0 | CA91CX42_LINT_LM1 | CA91CX42_LINT_LM2 |
- CA91CX42_LINT_LM3)) == 0) {
- tmp = ioread32(bridge->base + LM_CTL);
- tmp &= ~CA91CX42_LM_CTL_EN;
- iowrite32(tmp, bridge->base + LM_CTL);
- }
-
- mutex_unlock(&lm->mtx);
-
- return 0;
-}
-
-static int ca91cx42_slot_get(struct vme_bridge *ca91cx42_bridge)
-{
- u32 slot = 0;
- struct ca91cx42_driver *bridge;
-
- bridge = ca91cx42_bridge->driver_priv;
-
- if (!geoid) {
- slot = ioread32(bridge->base + VCSR_BS);
- slot = ((slot & CA91CX42_VCSR_BS_SLOT_M) >> 27);
- } else
- slot = geoid;
-
- return (int)slot;
-
-}
-
-void *ca91cx42_alloc_consistent(struct device *parent, size_t size,
- dma_addr_t *dma)
-{
- struct pci_dev *pdev;
-
- /* Find pci_dev container of dev */
- pdev = container_of(parent, struct pci_dev, dev);
-
- return pci_alloc_consistent(pdev, size, dma);
-}
-
-void ca91cx42_free_consistent(struct device *parent, size_t size, void *vaddr,
- dma_addr_t dma)
-{
- struct pci_dev *pdev;
-
- /* Find pci_dev container of dev */
- pdev = container_of(parent, struct pci_dev, dev);
-
- pci_free_consistent(pdev, size, vaddr, dma);
-}
-
-static int __init ca91cx42_init(void)
-{
- return pci_register_driver(&ca91cx42_driver);
-}
-
-/*
- * Configure CR/CSR space
- *
- * Access to the CR/CSR can be configured at power-up. The location of the
- * CR/CSR registers in the CR/CSR address space is determined by the boards
- * Auto-ID or Geographic address. This function ensures that the window is
- * enabled at an offset consistent with the boards geopgraphic address.
- */
-static int ca91cx42_crcsr_init(struct vme_bridge *ca91cx42_bridge,
- struct pci_dev *pdev)
-{
- unsigned int crcsr_addr;
- int tmp, slot;
- struct ca91cx42_driver *bridge;
-
- bridge = ca91cx42_bridge->driver_priv;
-
- slot = ca91cx42_slot_get(ca91cx42_bridge);
-
- /* Write CSR Base Address if slot ID is supplied as a module param */
- if (geoid)
- iowrite32(geoid << 27, bridge->base + VCSR_BS);
-
- dev_info(&pdev->dev, "CR/CSR Offset: %d\n", slot);
- if (slot == 0) {
- dev_err(&pdev->dev, "Slot number is unset, not configuring "
- "CR/CSR space\n");
- return -EINVAL;
- }
-
- /* Allocate mem for CR/CSR image */
- bridge->crcsr_kernel = pci_alloc_consistent(pdev, VME_CRCSR_BUF_SIZE,
- &bridge->crcsr_bus);
- if (bridge->crcsr_kernel == NULL) {
- dev_err(&pdev->dev, "Failed to allocate memory for CR/CSR "
- "image\n");
- return -ENOMEM;
- }
-
- memset(bridge->crcsr_kernel, 0, VME_CRCSR_BUF_SIZE);
-
- crcsr_addr = slot * (512 * 1024);
- iowrite32(bridge->crcsr_bus - crcsr_addr, bridge->base + VCSR_TO);
-
- tmp = ioread32(bridge->base + VCSR_CTL);
- tmp |= CA91CX42_VCSR_CTL_EN;
- iowrite32(tmp, bridge->base + VCSR_CTL);
-
- return 0;
-}
-
-static void ca91cx42_crcsr_exit(struct vme_bridge *ca91cx42_bridge,
- struct pci_dev *pdev)
-{
- u32 tmp;
- struct ca91cx42_driver *bridge;
-
- bridge = ca91cx42_bridge->driver_priv;
-
- /* Turn off CR/CSR space */
- tmp = ioread32(bridge->base + VCSR_CTL);
- tmp &= ~CA91CX42_VCSR_CTL_EN;
- iowrite32(tmp, bridge->base + VCSR_CTL);
-
- /* Free image */
- iowrite32(0, bridge->base + VCSR_TO);
-
- pci_free_consistent(pdev, VME_CRCSR_BUF_SIZE, bridge->crcsr_kernel,
- bridge->crcsr_bus);
-}
-
-static int ca91cx42_probe(struct pci_dev *pdev, const struct pci_device_id *id)
-{
- int retval, i;
- u32 data;
- struct list_head *pos = NULL;
- struct vme_bridge *ca91cx42_bridge;
- struct ca91cx42_driver *ca91cx42_device;
- struct vme_master_resource *master_image;
- struct vme_slave_resource *slave_image;
- struct vme_dma_resource *dma_ctrlr;
- struct vme_lm_resource *lm;
-
- /* We want to support more than one of each bridge so we need to
- * dynamically allocate the bridge structure
- */
- ca91cx42_bridge = kzalloc(sizeof(struct vme_bridge), GFP_KERNEL);
-
- if (ca91cx42_bridge == NULL) {
- dev_err(&pdev->dev, "Failed to allocate memory for device "
- "structure\n");
- retval = -ENOMEM;
- goto err_struct;
- }
-
- ca91cx42_device = kzalloc(sizeof(struct ca91cx42_driver), GFP_KERNEL);
-
- if (ca91cx42_device == NULL) {
- dev_err(&pdev->dev, "Failed to allocate memory for device "
- "structure\n");
- retval = -ENOMEM;
- goto err_driver;
- }
-
- ca91cx42_bridge->driver_priv = ca91cx42_device;
-
- /* Enable the device */
- retval = pci_enable_device(pdev);
- if (retval) {
- dev_err(&pdev->dev, "Unable to enable device\n");
- goto err_enable;
- }
-
- /* Map Registers */
- retval = pci_request_regions(pdev, driver_name);
- if (retval) {
- dev_err(&pdev->dev, "Unable to reserve resources\n");
- goto err_resource;
- }
-
- /* map registers in BAR 0 */
- ca91cx42_device->base = ioremap_nocache(pci_resource_start(pdev, 0),
- 4096);
- if (!ca91cx42_device->base) {
- dev_err(&pdev->dev, "Unable to remap CRG region\n");
- retval = -EIO;
- goto err_remap;
- }
-
- /* Check to see if the mapping worked out */
- data = ioread32(ca91cx42_device->base + CA91CX42_PCI_ID) & 0x0000FFFF;
- if (data != PCI_VENDOR_ID_TUNDRA) {
- dev_err(&pdev->dev, "PCI_ID check failed\n");
- retval = -EIO;
- goto err_test;
- }
-
- /* Initialize wait queues & mutual exclusion flags */
- init_waitqueue_head(&ca91cx42_device->dma_queue);
- init_waitqueue_head(&ca91cx42_device->iack_queue);
- mutex_init(&ca91cx42_device->vme_int);
- mutex_init(&ca91cx42_device->vme_rmw);
-
- ca91cx42_bridge->parent = &pdev->dev;
- strcpy(ca91cx42_bridge->name, driver_name);
-
- /* Setup IRQ */
- retval = ca91cx42_irq_init(ca91cx42_bridge);
- if (retval != 0) {
- dev_err(&pdev->dev, "Chip Initialization failed.\n");
- goto err_irq;
- }
-
- /* Add master windows to list */
- INIT_LIST_HEAD(&ca91cx42_bridge->master_resources);
- for (i = 0; i < CA91C142_MAX_MASTER; i++) {
- master_image = kmalloc(sizeof(struct vme_master_resource),
- GFP_KERNEL);
- if (master_image == NULL) {
- dev_err(&pdev->dev, "Failed to allocate memory for "
- "master resource structure\n");
- retval = -ENOMEM;
- goto err_master;
- }
- master_image->parent = ca91cx42_bridge;
- spin_lock_init(&master_image->lock);
- master_image->locked = 0;
- master_image->number = i;
- master_image->address_attr = VME_A16 | VME_A24 | VME_A32 |
- VME_CRCSR | VME_USER1 | VME_USER2;
- master_image->cycle_attr = VME_SCT | VME_BLT | VME_MBLT |
- VME_SUPER | VME_USER | VME_PROG | VME_DATA;
- master_image->width_attr = VME_D8 | VME_D16 | VME_D32 | VME_D64;
- memset(&master_image->bus_resource, 0,
- sizeof(struct resource));
- master_image->kern_base = NULL;
- list_add_tail(&master_image->list,
- &ca91cx42_bridge->master_resources);
- }
-
- /* Add slave windows to list */
- INIT_LIST_HEAD(&ca91cx42_bridge->slave_resources);
- for (i = 0; i < CA91C142_MAX_SLAVE; i++) {
- slave_image = kmalloc(sizeof(struct vme_slave_resource),
- GFP_KERNEL);
- if (slave_image == NULL) {
- dev_err(&pdev->dev, "Failed to allocate memory for "
- "slave resource structure\n");
- retval = -ENOMEM;
- goto err_slave;
- }
- slave_image->parent = ca91cx42_bridge;
- mutex_init(&slave_image->mtx);
- slave_image->locked = 0;
- slave_image->number = i;
- slave_image->address_attr = VME_A24 | VME_A32 | VME_USER1 |
- VME_USER2;
-
- /* Only windows 0 and 4 support A16 */
- if (i == 0 || i == 4)
- slave_image->address_attr |= VME_A16;
-
- slave_image->cycle_attr = VME_SCT | VME_BLT | VME_MBLT |
- VME_SUPER | VME_USER | VME_PROG | VME_DATA;
- list_add_tail(&slave_image->list,
- &ca91cx42_bridge->slave_resources);
- }
-
- /* Add dma engines to list */
- INIT_LIST_HEAD(&ca91cx42_bridge->dma_resources);
- for (i = 0; i < CA91C142_MAX_DMA; i++) {
- dma_ctrlr = kmalloc(sizeof(struct vme_dma_resource),
- GFP_KERNEL);
- if (dma_ctrlr == NULL) {
- dev_err(&pdev->dev, "Failed to allocate memory for "
- "dma resource structure\n");
- retval = -ENOMEM;
- goto err_dma;
- }
- dma_ctrlr->parent = ca91cx42_bridge;
- mutex_init(&dma_ctrlr->mtx);
- dma_ctrlr->locked = 0;
- dma_ctrlr->number = i;
- dma_ctrlr->route_attr = VME_DMA_VME_TO_MEM |
- VME_DMA_MEM_TO_VME;
- INIT_LIST_HEAD(&dma_ctrlr->pending);
- INIT_LIST_HEAD(&dma_ctrlr->running);
- list_add_tail(&dma_ctrlr->list,
- &ca91cx42_bridge->dma_resources);
- }
-
- /* Add location monitor to list */
- INIT_LIST_HEAD(&ca91cx42_bridge->lm_resources);
- lm = kmalloc(sizeof(struct vme_lm_resource), GFP_KERNEL);
- if (lm == NULL) {
- dev_err(&pdev->dev, "Failed to allocate memory for "
- "location monitor resource structure\n");
- retval = -ENOMEM;
- goto err_lm;
- }
- lm->parent = ca91cx42_bridge;
- mutex_init(&lm->mtx);
- lm->locked = 0;
- lm->number = 1;
- lm->monitors = 4;
- list_add_tail(&lm->list, &ca91cx42_bridge->lm_resources);
-
- ca91cx42_bridge->slave_get = ca91cx42_slave_get;
- ca91cx42_bridge->slave_set = ca91cx42_slave_set;
- ca91cx42_bridge->master_get = ca91cx42_master_get;
- ca91cx42_bridge->master_set = ca91cx42_master_set;
- ca91cx42_bridge->master_read = ca91cx42_master_read;
- ca91cx42_bridge->master_write = ca91cx42_master_write;
- ca91cx42_bridge->master_rmw = ca91cx42_master_rmw;
- ca91cx42_bridge->dma_list_add = ca91cx42_dma_list_add;
- ca91cx42_bridge->dma_list_exec = ca91cx42_dma_list_exec;
- ca91cx42_bridge->dma_list_empty = ca91cx42_dma_list_empty;
- ca91cx42_bridge->irq_set = ca91cx42_irq_set;
- ca91cx42_bridge->irq_generate = ca91cx42_irq_generate;
- ca91cx42_bridge->lm_set = ca91cx42_lm_set;
- ca91cx42_bridge->lm_get = ca91cx42_lm_get;
- ca91cx42_bridge->lm_attach = ca91cx42_lm_attach;
- ca91cx42_bridge->lm_detach = ca91cx42_lm_detach;
- ca91cx42_bridge->slot_get = ca91cx42_slot_get;
- ca91cx42_bridge->alloc_consistent = ca91cx42_alloc_consistent;
- ca91cx42_bridge->free_consistent = ca91cx42_free_consistent;
-
- data = ioread32(ca91cx42_device->base + MISC_CTL);
- dev_info(&pdev->dev, "Board is%s the VME system controller\n",
- (data & CA91CX42_MISC_CTL_SYSCON) ? "" : " not");
- dev_info(&pdev->dev, "Slot ID is %d\n",
- ca91cx42_slot_get(ca91cx42_bridge));
-
- if (ca91cx42_crcsr_init(ca91cx42_bridge, pdev))
- dev_err(&pdev->dev, "CR/CSR configuration failed.\n");
-
- /* Need to save ca91cx42_bridge pointer locally in link list for use in
- * ca91cx42_remove()
- */
- retval = vme_register_bridge(ca91cx42_bridge);
- if (retval != 0) {
- dev_err(&pdev->dev, "Chip Registration failed.\n");
- goto err_reg;
- }
-
- pci_set_drvdata(pdev, ca91cx42_bridge);
-
- return 0;
-
-err_reg:
- ca91cx42_crcsr_exit(ca91cx42_bridge, pdev);
-err_lm:
- /* resources are stored in link list */
- list_for_each(pos, &ca91cx42_bridge->lm_resources) {
- lm = list_entry(pos, struct vme_lm_resource, list);
- list_del(pos);
- kfree(lm);
- }
-err_dma:
- /* resources are stored in link list */
- list_for_each(pos, &ca91cx42_bridge->dma_resources) {
- dma_ctrlr = list_entry(pos, struct vme_dma_resource, list);
- list_del(pos);
- kfree(dma_ctrlr);
- }
-err_slave:
- /* resources are stored in link list */
- list_for_each(pos, &ca91cx42_bridge->slave_resources) {
- slave_image = list_entry(pos, struct vme_slave_resource, list);
- list_del(pos);
- kfree(slave_image);
- }
-err_master:
- /* resources are stored in link list */
- list_for_each(pos, &ca91cx42_bridge->master_resources) {
- master_image = list_entry(pos, struct vme_master_resource,
- list);
- list_del(pos);
- kfree(master_image);
- }
-
- ca91cx42_irq_exit(ca91cx42_device, pdev);
-err_irq:
-err_test:
- iounmap(ca91cx42_device->base);
-err_remap:
- pci_release_regions(pdev);
-err_resource:
- pci_disable_device(pdev);
-err_enable:
- kfree(ca91cx42_device);
-err_driver:
- kfree(ca91cx42_bridge);
-err_struct:
- return retval;
-
-}
-
-static void ca91cx42_remove(struct pci_dev *pdev)
-{
- struct list_head *pos = NULL;
- struct vme_master_resource *master_image;
- struct vme_slave_resource *slave_image;
- struct vme_dma_resource *dma_ctrlr;
- struct vme_lm_resource *lm;
- struct ca91cx42_driver *bridge;
- struct vme_bridge *ca91cx42_bridge = pci_get_drvdata(pdev);
-
- bridge = ca91cx42_bridge->driver_priv;
-
-
- /* Turn off Ints */
- iowrite32(0, bridge->base + LINT_EN);
-
- /* Turn off the windows */
- iowrite32(0x00800000, bridge->base + LSI0_CTL);
- iowrite32(0x00800000, bridge->base + LSI1_CTL);
- iowrite32(0x00800000, bridge->base + LSI2_CTL);
- iowrite32(0x00800000, bridge->base + LSI3_CTL);
- iowrite32(0x00800000, bridge->base + LSI4_CTL);
- iowrite32(0x00800000, bridge->base + LSI5_CTL);
- iowrite32(0x00800000, bridge->base + LSI6_CTL);
- iowrite32(0x00800000, bridge->base + LSI7_CTL);
- iowrite32(0x00F00000, bridge->base + VSI0_CTL);
- iowrite32(0x00F00000, bridge->base + VSI1_CTL);
- iowrite32(0x00F00000, bridge->base + VSI2_CTL);
- iowrite32(0x00F00000, bridge->base + VSI3_CTL);
- iowrite32(0x00F00000, bridge->base + VSI4_CTL);
- iowrite32(0x00F00000, bridge->base + VSI5_CTL);
- iowrite32(0x00F00000, bridge->base + VSI6_CTL);
- iowrite32(0x00F00000, bridge->base + VSI7_CTL);
-
- vme_unregister_bridge(ca91cx42_bridge);
-
- ca91cx42_crcsr_exit(ca91cx42_bridge, pdev);
-
- /* resources are stored in link list */
- list_for_each(pos, &ca91cx42_bridge->lm_resources) {
- lm = list_entry(pos, struct vme_lm_resource, list);
- list_del(pos);
- kfree(lm);
- }
-
- /* resources are stored in link list */
- list_for_each(pos, &ca91cx42_bridge->dma_resources) {
- dma_ctrlr = list_entry(pos, struct vme_dma_resource, list);
- list_del(pos);
- kfree(dma_ctrlr);
- }
-
- /* resources are stored in link list */
- list_for_each(pos, &ca91cx42_bridge->slave_resources) {
- slave_image = list_entry(pos, struct vme_slave_resource, list);
- list_del(pos);
- kfree(slave_image);
- }
-
- /* resources are stored in link list */
- list_for_each(pos, &ca91cx42_bridge->master_resources) {
- master_image = list_entry(pos, struct vme_master_resource,
- list);
- list_del(pos);
- kfree(master_image);
- }
-
- ca91cx42_irq_exit(bridge, pdev);
-
- iounmap(bridge->base);
-
- pci_release_regions(pdev);
-
- pci_disable_device(pdev);
-
- kfree(ca91cx42_bridge);
-}
-
-static void __exit ca91cx42_exit(void)
-{
- pci_unregister_driver(&ca91cx42_driver);
-}
-
-MODULE_PARM_DESC(geoid, "Override geographical addressing");
-module_param(geoid, int, 0);
-
-MODULE_DESCRIPTION("VME driver for the Tundra Universe II VME bridge");
-MODULE_LICENSE("GPL");
-
-module_init(ca91cx42_init);
-module_exit(ca91cx42_exit);
diff --git a/drivers/staging/vme/bridges/vme_ca91cx42.h b/drivers/staging/vme/bridges/vme_ca91cx42.h
deleted file mode 100644
index 02a7c794db05..000000000000
--- a/drivers/staging/vme/bridges/vme_ca91cx42.h
+++ /dev/null
@@ -1,583 +0,0 @@
-/*
- * ca91c042.h
- *
- * Support for the Tundra Universe 1 and Universe II VME bridge chips
- *
- * Author: Tom Armistead
- * Updated by Ajit Prem
- * Copyright 2004 Motorola Inc.
- *
- * Further updated by Martyn Welch <martyn.welch@ge.com>
- * Copyright 2009 GE Intelligent Platforms Embedded Systems, Inc.
- *
- * Derived from ca91c042.h by Michael Wyrick
- *
- * 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.
- */
-
-#ifndef _CA91CX42_H
-#define _CA91CX42_H
-
-#ifndef PCI_VENDOR_ID_TUNDRA
-#define PCI_VENDOR_ID_TUNDRA 0x10e3
-#endif
-
-#ifndef PCI_DEVICE_ID_TUNDRA_CA91C142
-#define PCI_DEVICE_ID_TUNDRA_CA91C142 0x0000
-#endif
-
-/*
- * Define the number of each that the CA91C142 supports.
- */
-#define CA91C142_MAX_MASTER 8 /* Max Master Windows */
-#define CA91C142_MAX_SLAVE 8 /* Max Slave Windows */
-#define CA91C142_MAX_DMA 1 /* Max DMA Controllers */
-#define CA91C142_MAX_MAILBOX 4 /* Max Mail Box registers */
-
-/* Structure used to hold driver specific information */
-struct ca91cx42_driver {
- void __iomem *base; /* Base Address of device registers */
- wait_queue_head_t dma_queue;
- wait_queue_head_t iack_queue;
- wait_queue_head_t mbox_queue;
- void (*lm_callback[4])(int); /* Called in interrupt handler */
- void *crcsr_kernel;
- dma_addr_t crcsr_bus;
- struct mutex vme_rmw; /* Only one RMW cycle at a time */
- struct mutex vme_int; /*
- * Only one VME interrupt can be
- * generated at a time, provide locking
- */
-};
-
-/* See Page 2-77 in the Universe User Manual */
-struct ca91cx42_dma_descriptor {
- unsigned int dctl; /* DMA Control */
- unsigned int dtbc; /* Transfer Byte Count */
- unsigned int dla; /* PCI Address */
- unsigned int res1; /* Reserved */
- unsigned int dva; /* Vme Address */
- unsigned int res2; /* Reserved */
- unsigned int dcpp; /* Pointer to Numed Cmd Packet with rPN */
- unsigned int res3; /* Reserved */
-};
-
-struct ca91cx42_dma_entry {
- struct ca91cx42_dma_descriptor descriptor;
- struct list_head list;
-};
-
-/* Universe Register Offsets */
-/* general PCI configuration registers */
-#define CA91CX42_PCI_ID 0x000
-#define CA91CX42_PCI_CSR 0x004
-#define CA91CX42_PCI_CLASS 0x008
-#define CA91CX42_PCI_MISC0 0x00C
-#define CA91CX42_PCI_BS 0x010
-#define CA91CX42_PCI_MISC1 0x03C
-
-#define LSI0_CTL 0x0100
-#define LSI0_BS 0x0104
-#define LSI0_BD 0x0108
-#define LSI0_TO 0x010C
-
-#define LSI1_CTL 0x0114
-#define LSI1_BS 0x0118
-#define LSI1_BD 0x011C
-#define LSI1_TO 0x0120
-
-#define LSI2_CTL 0x0128
-#define LSI2_BS 0x012C
-#define LSI2_BD 0x0130
-#define LSI2_TO 0x0134
-
-#define LSI3_CTL 0x013C
-#define LSI3_BS 0x0140
-#define LSI3_BD 0x0144
-#define LSI3_TO 0x0148
-
-#define LSI4_CTL 0x01A0
-#define LSI4_BS 0x01A4
-#define LSI4_BD 0x01A8
-#define LSI4_TO 0x01AC
-
-#define LSI5_CTL 0x01B4
-#define LSI5_BS 0x01B8
-#define LSI5_BD 0x01BC
-#define LSI5_TO 0x01C0
-
-#define LSI6_CTL 0x01C8
-#define LSI6_BS 0x01CC
-#define LSI6_BD 0x01D0
-#define LSI6_TO 0x01D4
-
-#define LSI7_CTL 0x01DC
-#define LSI7_BS 0x01E0
-#define LSI7_BD 0x01E4
-#define LSI7_TO 0x01E8
-
-static const int CA91CX42_LSI_CTL[] = { LSI0_CTL, LSI1_CTL, LSI2_CTL, LSI3_CTL,
- LSI4_CTL, LSI5_CTL, LSI6_CTL, LSI7_CTL };
-
-static const int CA91CX42_LSI_BS[] = { LSI0_BS, LSI1_BS, LSI2_BS, LSI3_BS,
- LSI4_BS, LSI5_BS, LSI6_BS, LSI7_BS };
-
-static const int CA91CX42_LSI_BD[] = { LSI0_BD, LSI1_BD, LSI2_BD, LSI3_BD,
- LSI4_BD, LSI5_BD, LSI6_BD, LSI7_BD };
-
-static const int CA91CX42_LSI_TO[] = { LSI0_TO, LSI1_TO, LSI2_TO, LSI3_TO,
- LSI4_TO, LSI5_TO, LSI6_TO, LSI7_TO };
-
-#define SCYC_CTL 0x0170
-#define SCYC_ADDR 0x0174
-#define SCYC_EN 0x0178
-#define SCYC_CMP 0x017C
-#define SCYC_SWP 0x0180
-#define LMISC 0x0184
-#define SLSI 0x0188
-#define L_CMDERR 0x018C
-#define LAERR 0x0190
-
-#define DCTL 0x0200
-#define DTBC 0x0204
-#define DLA 0x0208
-#define DVA 0x0210
-#define DCPP 0x0218
-#define DGCS 0x0220
-#define D_LLUE 0x0224
-
-#define LINT_EN 0x0300
-#define LINT_STAT 0x0304
-#define LINT_MAP0 0x0308
-#define LINT_MAP1 0x030C
-#define VINT_EN 0x0310
-#define VINT_STAT 0x0314
-#define VINT_MAP0 0x0318
-#define VINT_MAP1 0x031C
-#define STATID 0x0320
-
-#define V1_STATID 0x0324
-#define V2_STATID 0x0328
-#define V3_STATID 0x032C
-#define V4_STATID 0x0330
-#define V5_STATID 0x0334
-#define V6_STATID 0x0338
-#define V7_STATID 0x033C
-
-static const int CA91CX42_V_STATID[8] = { 0, V1_STATID, V2_STATID, V3_STATID,
- V4_STATID, V5_STATID, V6_STATID,
- V7_STATID };
-
-#define LINT_MAP2 0x0340
-#define VINT_MAP2 0x0344
-
-#define MBOX0 0x0348
-#define MBOX1 0x034C
-#define MBOX2 0x0350
-#define MBOX3 0x0354
-#define SEMA0 0x0358
-#define SEMA1 0x035C
-
-#define MAST_CTL 0x0400
-#define MISC_CTL 0x0404
-#define MISC_STAT 0x0408
-#define USER_AM 0x040C
-
-#define VSI0_CTL 0x0F00
-#define VSI0_BS 0x0F04
-#define VSI0_BD 0x0F08
-#define VSI0_TO 0x0F0C
-
-#define VSI1_CTL 0x0F14
-#define VSI1_BS 0x0F18
-#define VSI1_BD 0x0F1C
-#define VSI1_TO 0x0F20
-
-#define VSI2_CTL 0x0F28
-#define VSI2_BS 0x0F2C
-#define VSI2_BD 0x0F30
-#define VSI2_TO 0x0F34
-
-#define VSI3_CTL 0x0F3C
-#define VSI3_BS 0x0F40
-#define VSI3_BD 0x0F44
-#define VSI3_TO 0x0F48
-
-#define LM_CTL 0x0F64
-#define LM_BS 0x0F68
-
-#define VRAI_CTL 0x0F70
-
-#define VRAI_BS 0x0F74
-#define VCSR_CTL 0x0F80
-#define VCSR_TO 0x0F84
-#define V_AMERR 0x0F88
-#define VAERR 0x0F8C
-
-#define VSI4_CTL 0x0F90
-#define VSI4_BS 0x0F94
-#define VSI4_BD 0x0F98
-#define VSI4_TO 0x0F9C
-
-#define VSI5_CTL 0x0FA4
-#define VSI5_BS 0x0FA8
-#define VSI5_BD 0x0FAC
-#define VSI5_TO 0x0FB0
-
-#define VSI6_CTL 0x0FB8
-#define VSI6_BS 0x0FBC
-#define VSI6_BD 0x0FC0
-#define VSI6_TO 0x0FC4
-
-#define VSI7_CTL 0x0FCC
-#define VSI7_BS 0x0FD0
-#define VSI7_BD 0x0FD4
-#define VSI7_TO 0x0FD8
-
-static const int CA91CX42_VSI_CTL[] = { VSI0_CTL, VSI1_CTL, VSI2_CTL, VSI3_CTL,
- VSI4_CTL, VSI5_CTL, VSI6_CTL, VSI7_CTL };
-
-static const int CA91CX42_VSI_BS[] = { VSI0_BS, VSI1_BS, VSI2_BS, VSI3_BS,
- VSI4_BS, VSI5_BS, VSI6_BS, VSI7_BS };
-
-static const int CA91CX42_VSI_BD[] = { VSI0_BD, VSI1_BD, VSI2_BD, VSI3_BD,
- VSI4_BD, VSI5_BD, VSI6_BD, VSI7_BD };
-
-static const int CA91CX42_VSI_TO[] = { VSI0_TO, VSI1_TO, VSI2_TO, VSI3_TO,
- VSI4_TO, VSI5_TO, VSI6_TO, VSI7_TO };
-
-#define VCSR_CLR 0x0FF4
-#define VCSR_SET 0x0FF8
-#define VCSR_BS 0x0FFC
-
-/*
- * PCI Class Register
- * offset 008
- */
-#define CA91CX42_BM_PCI_CLASS_BASE 0xFF000000
-#define CA91CX42_OF_PCI_CLASS_BASE 24
-#define CA91CX42_BM_PCI_CLASS_SUB 0x00FF0000
-#define CA91CX42_OF_PCI_CLASS_SUB 16
-#define CA91CX42_BM_PCI_CLASS_PROG 0x0000FF00
-#define CA91CX42_OF_PCI_CLASS_PROG 8
-#define CA91CX42_BM_PCI_CLASS_RID 0x000000FF
-#define CA91CX42_OF_PCI_CLASS_RID 0
-
-#define CA91CX42_OF_PCI_CLASS_RID_UNIVERSE_I 0
-#define CA91CX42_OF_PCI_CLASS_RID_UNIVERSE_II 1
-
-/*
- * PCI Misc Register
- * offset 00C
- */
-#define CA91CX42_BM_PCI_MISC0_BISTC 0x80000000
-#define CA91CX42_BM_PCI_MISC0_SBIST 0x60000000
-#define CA91CX42_BM_PCI_MISC0_CCODE 0x0F000000
-#define CA91CX42_BM_PCI_MISC0_MFUNCT 0x00800000
-#define CA91CX42_BM_PCI_MISC0_LAYOUT 0x007F0000
-#define CA91CX42_BM_PCI_MISC0_LTIMER 0x0000FF00
-#define CA91CX42_OF_PCI_MISC0_LTIMER 8
-
-
-/*
- * LSI Control Register
- * offset 100
- */
-#define CA91CX42_LSI_CTL_EN (1<<31)
-#define CA91CX42_LSI_CTL_PWEN (1<<30)
-
-#define CA91CX42_LSI_CTL_VDW_M (3<<22)
-#define CA91CX42_LSI_CTL_VDW_D8 0
-#define CA91CX42_LSI_CTL_VDW_D16 (1<<22)
-#define CA91CX42_LSI_CTL_VDW_D32 (1<<23)
-#define CA91CX42_LSI_CTL_VDW_D64 (3<<22)
-
-#define CA91CX42_LSI_CTL_VAS_M (7<<16)
-#define CA91CX42_LSI_CTL_VAS_A16 0
-#define CA91CX42_LSI_CTL_VAS_A24 (1<<16)
-#define CA91CX42_LSI_CTL_VAS_A32 (1<<17)
-#define CA91CX42_LSI_CTL_VAS_CRCSR (5<<16)
-#define CA91CX42_LSI_CTL_VAS_USER1 (3<<17)
-#define CA91CX42_LSI_CTL_VAS_USER2 (7<<16)
-
-#define CA91CX42_LSI_CTL_PGM_M (1<<14)
-#define CA91CX42_LSI_CTL_PGM_DATA 0
-#define CA91CX42_LSI_CTL_PGM_PGM (1<<14)
-
-#define CA91CX42_LSI_CTL_SUPER_M (1<<12)
-#define CA91CX42_LSI_CTL_SUPER_NPRIV 0
-#define CA91CX42_LSI_CTL_SUPER_SUPR (1<<12)
-
-#define CA91CX42_LSI_CTL_VCT_M (1<<8)
-#define CA91CX42_LSI_CTL_VCT_BLT (1<<8)
-#define CA91CX42_LSI_CTL_VCT_MBLT (1<<8)
-#define CA91CX42_LSI_CTL_LAS (1<<0)
-
-/*
- * SCYC_CTL Register
- * offset 178
- */
-#define CA91CX42_SCYC_CTL_LAS_PCIMEM 0
-#define CA91CX42_SCYC_CTL_LAS_PCIIO (1<<2)
-
-#define CA91CX42_SCYC_CTL_CYC_M (3<<0)
-#define CA91CX42_SCYC_CTL_CYC_RMW (1<<0)
-#define CA91CX42_SCYC_CTL_CYC_ADOH (1<<1)
-
-/*
- * LMISC Register
- * offset 184
- */
-#define CA91CX42_BM_LMISC_CRT 0xF0000000
-#define CA91CX42_OF_LMISC_CRT 28
-#define CA91CX42_BM_LMISC_CWT 0x0F000000
-#define CA91CX42_OF_LMISC_CWT 24
-
-/*
- * SLSI Register
- * offset 188
- */
-#define CA91CX42_BM_SLSI_EN 0x80000000
-#define CA91CX42_BM_SLSI_PWEN 0x40000000
-#define CA91CX42_BM_SLSI_VDW 0x00F00000
-#define CA91CX42_OF_SLSI_VDW 20
-#define CA91CX42_BM_SLSI_PGM 0x0000F000
-#define CA91CX42_OF_SLSI_PGM 12
-#define CA91CX42_BM_SLSI_SUPER 0x00000F00
-#define CA91CX42_OF_SLSI_SUPER 8
-#define CA91CX42_BM_SLSI_BS 0x000000F6
-#define CA91CX42_OF_SLSI_BS 2
-#define CA91CX42_BM_SLSI_LAS 0x00000003
-#define CA91CX42_OF_SLSI_LAS 0
-#define CA91CX42_BM_SLSI_RESERVED 0x3F0F0000
-
-/*
- * DCTL Register
- * offset 200
- */
-#define CA91CX42_DCTL_L2V (1<<31)
-#define CA91CX42_DCTL_VDW_M (3<<22)
-#define CA91CX42_DCTL_VDW_M (3<<22)
-#define CA91CX42_DCTL_VDW_D8 0
-#define CA91CX42_DCTL_VDW_D16 (1<<22)
-#define CA91CX42_DCTL_VDW_D32 (1<<23)
-#define CA91CX42_DCTL_VDW_D64 (3<<22)
-
-#define CA91CX42_DCTL_VAS_M (7<<16)
-#define CA91CX42_DCTL_VAS_A16 0
-#define CA91CX42_DCTL_VAS_A24 (1<<16)
-#define CA91CX42_DCTL_VAS_A32 (1<<17)
-#define CA91CX42_DCTL_VAS_USER1 (3<<17)
-#define CA91CX42_DCTL_VAS_USER2 (7<<16)
-
-#define CA91CX42_DCTL_PGM_M (1<<14)
-#define CA91CX42_DCTL_PGM_DATA 0
-#define CA91CX42_DCTL_PGM_PGM (1<<14)
-
-#define CA91CX42_DCTL_SUPER_M (1<<12)
-#define CA91CX42_DCTL_SUPER_NPRIV 0
-#define CA91CX42_DCTL_SUPER_SUPR (1<<12)
-
-#define CA91CX42_DCTL_VCT_M (1<<8)
-#define CA91CX42_DCTL_VCT_BLT (1<<8)
-#define CA91CX42_DCTL_LD64EN (1<<7)
-
-/*
- * DCPP Register
- * offset 218
- */
-#define CA91CX42_DCPP_M 0xf
-#define CA91CX42_DCPP_NULL (1<<0)
-
-/*
- * DMA General Control/Status Register (DGCS)
- * offset 220
- */
-#define CA91CX42_DGCS_GO (1<<31)
-#define CA91CX42_DGCS_STOP_REQ (1<<30)
-#define CA91CX42_DGCS_HALT_REQ (1<<29)
-#define CA91CX42_DGCS_CHAIN (1<<27)
-
-#define CA91CX42_DGCS_VON_M (7<<20)
-
-#define CA91CX42_DGCS_VOFF_M (0xf<<16)
-
-#define CA91CX42_DGCS_ACT (1<<15)
-#define CA91CX42_DGCS_STOP (1<<14)
-#define CA91CX42_DGCS_HALT (1<<13)
-#define CA91CX42_DGCS_DONE (1<<11)
-#define CA91CX42_DGCS_LERR (1<<10)
-#define CA91CX42_DGCS_VERR (1<<9)
-#define CA91CX42_DGCS_PERR (1<<8)
-#define CA91CX42_DGCS_INT_STOP (1<<6)
-#define CA91CX42_DGCS_INT_HALT (1<<5)
-#define CA91CX42_DGCS_INT_DONE (1<<3)
-#define CA91CX42_DGCS_INT_LERR (1<<2)
-#define CA91CX42_DGCS_INT_VERR (1<<1)
-#define CA91CX42_DGCS_INT_PERR (1<<0)
-
-/*
- * PCI Interrupt Enable Register
- * offset 300
- */
-#define CA91CX42_LINT_LM3 0x00800000
-#define CA91CX42_LINT_LM2 0x00400000
-#define CA91CX42_LINT_LM1 0x00200000
-#define CA91CX42_LINT_LM0 0x00100000
-#define CA91CX42_LINT_MBOX3 0x00080000
-#define CA91CX42_LINT_MBOX2 0x00040000
-#define CA91CX42_LINT_MBOX1 0x00020000
-#define CA91CX42_LINT_MBOX0 0x00010000
-#define CA91CX42_LINT_ACFAIL 0x00008000
-#define CA91CX42_LINT_SYSFAIL 0x00004000
-#define CA91CX42_LINT_SW_INT 0x00002000
-#define CA91CX42_LINT_SW_IACK 0x00001000
-
-#define CA91CX42_LINT_VERR 0x00000400
-#define CA91CX42_LINT_LERR 0x00000200
-#define CA91CX42_LINT_DMA 0x00000100
-#define CA91CX42_LINT_VIRQ7 0x00000080
-#define CA91CX42_LINT_VIRQ6 0x00000040
-#define CA91CX42_LINT_VIRQ5 0x00000020
-#define CA91CX42_LINT_VIRQ4 0x00000010
-#define CA91CX42_LINT_VIRQ3 0x00000008
-#define CA91CX42_LINT_VIRQ2 0x00000004
-#define CA91CX42_LINT_VIRQ1 0x00000002
-#define CA91CX42_LINT_VOWN 0x00000001
-
-static const int CA91CX42_LINT_VIRQ[] = { 0, CA91CX42_LINT_VIRQ1,
- CA91CX42_LINT_VIRQ2, CA91CX42_LINT_VIRQ3,
- CA91CX42_LINT_VIRQ4, CA91CX42_LINT_VIRQ5,
- CA91CX42_LINT_VIRQ6, CA91CX42_LINT_VIRQ7 };
-
-#define CA91CX42_LINT_MBOX 0x000F0000
-
-static const int CA91CX42_LINT_LM[] = { CA91CX42_LINT_LM0, CA91CX42_LINT_LM1,
- CA91CX42_LINT_LM2, CA91CX42_LINT_LM3 };
-
-/*
- * MAST_CTL Register
- * offset 400
- */
-#define CA91CX42_BM_MAST_CTL_MAXRTRY 0xF0000000
-#define CA91CX42_OF_MAST_CTL_MAXRTRY 28
-#define CA91CX42_BM_MAST_CTL_PWON 0x0F000000
-#define CA91CX42_OF_MAST_CTL_PWON 24
-#define CA91CX42_BM_MAST_CTL_VRL 0x00C00000
-#define CA91CX42_OF_MAST_CTL_VRL 22
-#define CA91CX42_BM_MAST_CTL_VRM 0x00200000
-#define CA91CX42_BM_MAST_CTL_VREL 0x00100000
-#define CA91CX42_BM_MAST_CTL_VOWN 0x00080000
-#define CA91CX42_BM_MAST_CTL_VOWN_ACK 0x00040000
-#define CA91CX42_BM_MAST_CTL_PABS 0x00001000
-#define CA91CX42_BM_MAST_CTL_BUS_NO 0x0000000F
-#define CA91CX42_OF_MAST_CTL_BUS_NO 0
-
-/*
- * MISC_CTL Register
- * offset 404
- */
-#define CA91CX42_MISC_CTL_VBTO 0xF0000000
-#define CA91CX42_MISC_CTL_VARB 0x04000000
-#define CA91CX42_MISC_CTL_VARBTO 0x03000000
-#define CA91CX42_MISC_CTL_SW_LRST 0x00800000
-#define CA91CX42_MISC_CTL_SW_SRST 0x00400000
-#define CA91CX42_MISC_CTL_BI 0x00100000
-#define CA91CX42_MISC_CTL_ENGBI 0x00080000
-#define CA91CX42_MISC_CTL_RESCIND 0x00040000
-#define CA91CX42_MISC_CTL_SYSCON 0x00020000
-#define CA91CX42_MISC_CTL_V64AUTO 0x00010000
-#define CA91CX42_MISC_CTL_RESERVED 0x0820FFFF
-
-#define CA91CX42_OF_MISC_CTL_VARBTO 24
-#define CA91CX42_OF_MISC_CTL_VBTO 28
-
-/*
- * MISC_STAT Register
- * offset 408
- */
-#define CA91CX42_BM_MISC_STAT_ENDIAN 0x80000000
-#define CA91CX42_BM_MISC_STAT_LCLSIZE 0x40000000
-#define CA91CX42_BM_MISC_STAT_DY4AUTO 0x08000000
-#define CA91CX42_BM_MISC_STAT_MYBBSY 0x00200000
-#define CA91CX42_BM_MISC_STAT_DY4DONE 0x00080000
-#define CA91CX42_BM_MISC_STAT_TXFE 0x00040000
-#define CA91CX42_BM_MISC_STAT_RXFE 0x00020000
-#define CA91CX42_BM_MISC_STAT_DY4AUTOID 0x0000FF00
-#define CA91CX42_OF_MISC_STAT_DY4AUTOID 8
-
-/*
- * VSI Control Register
- * offset F00
- */
-#define CA91CX42_VSI_CTL_EN (1<<31)
-#define CA91CX42_VSI_CTL_PWEN (1<<30)
-#define CA91CX42_VSI_CTL_PREN (1<<29)
-
-#define CA91CX42_VSI_CTL_PGM_M (3<<22)
-#define CA91CX42_VSI_CTL_PGM_DATA (1<<22)
-#define CA91CX42_VSI_CTL_PGM_PGM (1<<23)
-
-#define CA91CX42_VSI_CTL_SUPER_M (3<<20)
-#define CA91CX42_VSI_CTL_SUPER_NPRIV (1<<20)
-#define CA91CX42_VSI_CTL_SUPER_SUPR (1<<21)
-
-#define CA91CX42_VSI_CTL_VAS_M (7<<16)
-#define CA91CX42_VSI_CTL_VAS_A16 0
-#define CA91CX42_VSI_CTL_VAS_A24 (1<<16)
-#define CA91CX42_VSI_CTL_VAS_A32 (1<<17)
-#define CA91CX42_VSI_CTL_VAS_USER1 (3<<17)
-#define CA91CX42_VSI_CTL_VAS_USER2 (7<<16)
-
-#define CA91CX42_VSI_CTL_LD64EN (1<<7)
-#define CA91CX42_VSI_CTL_LLRMW (1<<6)
-
-#define CA91CX42_VSI_CTL_LAS_M (3<<0)
-#define CA91CX42_VSI_CTL_LAS_PCI_MS 0
-#define CA91CX42_VSI_CTL_LAS_PCI_IO (1<<0)
-#define CA91CX42_VSI_CTL_LAS_PCI_CONF (1<<1)
-
-/* LM_CTL Register
- * offset F64
- */
-#define CA91CX42_LM_CTL_EN (1<<31)
-#define CA91CX42_LM_CTL_PGM (1<<23)
-#define CA91CX42_LM_CTL_DATA (1<<22)
-#define CA91CX42_LM_CTL_SUPR (1<<21)
-#define CA91CX42_LM_CTL_NPRIV (1<<20)
-#define CA91CX42_LM_CTL_AS_M (5<<16)
-#define CA91CX42_LM_CTL_AS_A16 0
-#define CA91CX42_LM_CTL_AS_A24 (1<<16)
-#define CA91CX42_LM_CTL_AS_A32 (1<<17)
-
-/*
- * VRAI_CTL Register
- * offset F70
- */
-#define CA91CX42_BM_VRAI_CTL_EN 0x80000000
-#define CA91CX42_BM_VRAI_CTL_PGM 0x00C00000
-#define CA91CX42_OF_VRAI_CTL_PGM 22
-#define CA91CX42_BM_VRAI_CTL_SUPER 0x00300000
-#define CA91CX42_OF_VRAI_CTL_SUPER 20
-#define CA91CX42_BM_VRAI_CTL_VAS 0x00030000
-#define CA91CX42_OF_VRAI_CTL_VAS 16
-
-/* VCSR_CTL Register
- * offset F80
- */
-#define CA91CX42_VCSR_CTL_EN (1<<31)
-
-#define CA91CX42_VCSR_CTL_LAS_M (3<<0)
-#define CA91CX42_VCSR_CTL_LAS_PCI_MS 0
-#define CA91CX42_VCSR_CTL_LAS_PCI_IO (1<<0)
-#define CA91CX42_VCSR_CTL_LAS_PCI_CONF (1<<1)
-
-/* VCSR_BS Register
- * offset FFC
- */
-#define CA91CX42_VCSR_BS_SLOT_M (0x1F<<27)
-
-#endif /* _CA91CX42_H */
diff --git a/drivers/staging/vme/bridges/vme_tsi148.c b/drivers/staging/vme/bridges/vme_tsi148.c
deleted file mode 100644
index f50582169b24..000000000000
--- a/drivers/staging/vme/bridges/vme_tsi148.c
+++ /dev/null
@@ -1,2660 +0,0 @@
-/*
- * Support for the Tundra TSI148 VME-PCI Bridge Chip
- *
- * Author: Martyn Welch <martyn.welch@ge.com>
- * Copyright 2008 GE Intelligent Platforms Embedded Systems, Inc.
- *
- * Based on work by Tom Armistead and Ajit Prem
- * Copyright 2004 Motorola 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.
- */
-
-#include <linux/module.h>
-#include <linux/moduleparam.h>
-#include <linux/mm.h>
-#include <linux/types.h>
-#include <linux/errno.h>
-#include <linux/proc_fs.h>
-#include <linux/pci.h>
-#include <linux/poll.h>
-#include <linux/dma-mapping.h>
-#include <linux/interrupt.h>
-#include <linux/spinlock.h>
-#include <linux/sched.h>
-#include <linux/slab.h>
-#include <linux/time.h>
-#include <linux/io.h>
-#include <linux/uaccess.h>
-
-#include "../vme.h"
-#include "../vme_bridge.h"
-#include "vme_tsi148.h"
-
-static int __init tsi148_init(void);
-static int tsi148_probe(struct pci_dev *, const struct pci_device_id *);
-static void tsi148_remove(struct pci_dev *);
-static void __exit tsi148_exit(void);
-
-
-/* Module parameter */
-static bool err_chk;
-static int geoid;
-
-static const char driver_name[] = "vme_tsi148";
-
-static DEFINE_PCI_DEVICE_TABLE(tsi148_ids) = {
- { PCI_DEVICE(PCI_VENDOR_ID_TUNDRA, PCI_DEVICE_ID_TUNDRA_TSI148) },
- { },
-};
-
-static struct pci_driver tsi148_driver = {
- .name = driver_name,
- .id_table = tsi148_ids,
- .probe = tsi148_probe,
- .remove = tsi148_remove,
-};
-
-static void reg_join(unsigned int high, unsigned int low,
- unsigned long long *variable)
-{
- *variable = (unsigned long long)high << 32;
- *variable |= (unsigned long long)low;
-}
-
-static void reg_split(unsigned long long variable, unsigned int *high,
- unsigned int *low)
-{
- *low = (unsigned int)variable & 0xFFFFFFFF;
- *high = (unsigned int)(variable >> 32);
-}
-
-/*
- * Wakes up DMA queue.
- */
-static u32 tsi148_DMA_irqhandler(struct tsi148_driver *bridge,
- int channel_mask)
-{
- u32 serviced = 0;
-
- if (channel_mask & TSI148_LCSR_INTS_DMA0S) {
- wake_up(&bridge->dma_queue[0]);
- serviced |= TSI148_LCSR_INTC_DMA0C;
- }
- if (channel_mask & TSI148_LCSR_INTS_DMA1S) {
- wake_up(&bridge->dma_queue[1]);
- serviced |= TSI148_LCSR_INTC_DMA1C;
- }
-
- return serviced;
-}
-
-/*
- * Wake up location monitor queue
- */
-static u32 tsi148_LM_irqhandler(struct tsi148_driver *bridge, u32 stat)
-{
- int i;
- u32 serviced = 0;
-
- for (i = 0; i < 4; i++) {
- if (stat & TSI148_LCSR_INTS_LMS[i]) {
- /* We only enable interrupts if the callback is set */
- bridge->lm_callback[i](i);
- serviced |= TSI148_LCSR_INTC_LMC[i];
- }
- }
-
- return serviced;
-}
-
-/*
- * Wake up mail box queue.
- *
- * XXX This functionality is not exposed up though API.
- */
-static u32 tsi148_MB_irqhandler(struct vme_bridge *tsi148_bridge, u32 stat)
-{
- int i;
- u32 val;
- u32 serviced = 0;
- struct tsi148_driver *bridge;
-
- bridge = tsi148_bridge->driver_priv;
-
- for (i = 0; i < 4; i++) {
- if (stat & TSI148_LCSR_INTS_MBS[i]) {
- val = ioread32be(bridge->base + TSI148_GCSR_MBOX[i]);
- dev_err(tsi148_bridge->parent, "VME Mailbox %d received"
- ": 0x%x\n", i, val);
- serviced |= TSI148_LCSR_INTC_MBC[i];
- }
- }
-
- return serviced;
-}
-
-/*
- * Display error & status message when PERR (PCI) exception interrupt occurs.
- */
-static u32 tsi148_PERR_irqhandler(struct vme_bridge *tsi148_bridge)
-{
- struct tsi148_driver *bridge;
-
- bridge = tsi148_bridge->driver_priv;
-
- dev_err(tsi148_bridge->parent, "PCI Exception at address: 0x%08x:%08x, "
- "attributes: %08x\n",
- ioread32be(bridge->base + TSI148_LCSR_EDPAU),
- ioread32be(bridge->base + TSI148_LCSR_EDPAL),
- ioread32be(bridge->base + TSI148_LCSR_EDPAT));
-
- dev_err(tsi148_bridge->parent, "PCI-X attribute reg: %08x, PCI-X split "
- "completion reg: %08x\n",
- ioread32be(bridge->base + TSI148_LCSR_EDPXA),
- ioread32be(bridge->base + TSI148_LCSR_EDPXS));
-
- iowrite32be(TSI148_LCSR_EDPAT_EDPCL, bridge->base + TSI148_LCSR_EDPAT);
-
- return TSI148_LCSR_INTC_PERRC;
-}
-
-/*
- * Save address and status when VME error interrupt occurs.
- */
-static u32 tsi148_VERR_irqhandler(struct vme_bridge *tsi148_bridge)
-{
- unsigned int error_addr_high, error_addr_low;
- unsigned long long error_addr;
- u32 error_attrib;
- struct vme_bus_error *error;
- struct tsi148_driver *bridge;
-
- bridge = tsi148_bridge->driver_priv;
-
- error_addr_high = ioread32be(bridge->base + TSI148_LCSR_VEAU);
- error_addr_low = ioread32be(bridge->base + TSI148_LCSR_VEAL);
- error_attrib = ioread32be(bridge->base + TSI148_LCSR_VEAT);
-
- reg_join(error_addr_high, error_addr_low, &error_addr);
-
- /* Check for exception register overflow (we have lost error data) */
- if (error_attrib & TSI148_LCSR_VEAT_VEOF) {
- dev_err(tsi148_bridge->parent, "VME Bus Exception Overflow "
- "Occurred\n");
- }
-
- error = kmalloc(sizeof(struct vme_bus_error), GFP_ATOMIC);
- if (error) {
- error->address = error_addr;
- error->attributes = error_attrib;
- list_add_tail(&error->list, &tsi148_bridge->vme_errors);
- } else {
- dev_err(tsi148_bridge->parent, "Unable to alloc memory for "
- "VMEbus Error reporting\n");
- dev_err(tsi148_bridge->parent, "VME Bus Error at address: "
- "0x%llx, attributes: %08x\n", error_addr, error_attrib);
- }
-
- /* Clear Status */
- iowrite32be(TSI148_LCSR_VEAT_VESCL, bridge->base + TSI148_LCSR_VEAT);
-
- return TSI148_LCSR_INTC_VERRC;
-}
-
-/*
- * Wake up IACK queue.
- */
-static u32 tsi148_IACK_irqhandler(struct tsi148_driver *bridge)
-{
- wake_up(&bridge->iack_queue);
-
- return TSI148_LCSR_INTC_IACKC;
-}
-
-/*
- * Calling VME bus interrupt callback if provided.
- */
-static u32 tsi148_VIRQ_irqhandler(struct vme_bridge *tsi148_bridge,
- u32 stat)
-{
- int vec, i, serviced = 0;
- struct tsi148_driver *bridge;
-
- bridge = tsi148_bridge->driver_priv;
-
- for (i = 7; i > 0; i--) {
- if (stat & (1 << i)) {
- /*
- * Note: Even though the registers are defined as
- * 32-bits in the spec, we only want to issue 8-bit
- * IACK cycles on the bus, read from offset 3.
- */
- vec = ioread8(bridge->base + TSI148_LCSR_VIACK[i] + 3);
-
- vme_irq_handler(tsi148_bridge, i, vec);
-
- serviced |= (1 << i);
- }
- }
-
- return serviced;
-}
-
-/*
- * Top level interrupt handler. Clears appropriate interrupt status bits and
- * then calls appropriate sub handler(s).
- */
-static irqreturn_t tsi148_irqhandler(int irq, void *ptr)
-{
- u32 stat, enable, serviced = 0;
- struct vme_bridge *tsi148_bridge;
- struct tsi148_driver *bridge;
-
- tsi148_bridge = ptr;
-
- bridge = tsi148_bridge->driver_priv;
-
- /* Determine which interrupts are unmasked and set */
- enable = ioread32be(bridge->base + TSI148_LCSR_INTEO);
- stat = ioread32be(bridge->base + TSI148_LCSR_INTS);
-
- /* Only look at unmasked interrupts */
- stat &= enable;
-
- if (unlikely(!stat))
- return IRQ_NONE;
-
- /* Call subhandlers as appropriate */
- /* DMA irqs */
- if (stat & (TSI148_LCSR_INTS_DMA1S | TSI148_LCSR_INTS_DMA0S))
- serviced |= tsi148_DMA_irqhandler(bridge, stat);
-
- /* Location monitor irqs */
- if (stat & (TSI148_LCSR_INTS_LM3S | TSI148_LCSR_INTS_LM2S |
- TSI148_LCSR_INTS_LM1S | TSI148_LCSR_INTS_LM0S))
- serviced |= tsi148_LM_irqhandler(bridge, stat);
-
- /* Mail box irqs */
- if (stat & (TSI148_LCSR_INTS_MB3S | TSI148_LCSR_INTS_MB2S |
- TSI148_LCSR_INTS_MB1S | TSI148_LCSR_INTS_MB0S))
- serviced |= tsi148_MB_irqhandler(tsi148_bridge, stat);
-
- /* PCI bus error */
- if (stat & TSI148_LCSR_INTS_PERRS)
- serviced |= tsi148_PERR_irqhandler(tsi148_bridge);
-
- /* VME bus error */
- if (stat & TSI148_LCSR_INTS_VERRS)
- serviced |= tsi148_VERR_irqhandler(tsi148_bridge);
-
- /* IACK irq */
- if (stat & TSI148_LCSR_INTS_IACKS)
- serviced |= tsi148_IACK_irqhandler(bridge);
-
- /* VME bus irqs */
- if (stat & (TSI148_LCSR_INTS_IRQ7S | TSI148_LCSR_INTS_IRQ6S |
- TSI148_LCSR_INTS_IRQ5S | TSI148_LCSR_INTS_IRQ4S |
- TSI148_LCSR_INTS_IRQ3S | TSI148_LCSR_INTS_IRQ2S |
- TSI148_LCSR_INTS_IRQ1S))
- serviced |= tsi148_VIRQ_irqhandler(tsi148_bridge, stat);
-
- /* Clear serviced interrupts */
- iowrite32be(serviced, bridge->base + TSI148_LCSR_INTC);
-
- return IRQ_HANDLED;
-}
-
-static int tsi148_irq_init(struct vme_bridge *tsi148_bridge)
-{
- int result;
- unsigned int tmp;
- struct pci_dev *pdev;
- struct tsi148_driver *bridge;
-
- pdev = container_of(tsi148_bridge->parent, struct pci_dev, dev);
-
- bridge = tsi148_bridge->driver_priv;
-
- /* Initialise list for VME bus errors */
- INIT_LIST_HEAD(&tsi148_bridge->vme_errors);
-
- mutex_init(&tsi148_bridge->irq_mtx);
-
- result = request_irq(pdev->irq,
- tsi148_irqhandler,
- IRQF_SHARED,
- driver_name, tsi148_bridge);
- if (result) {
- dev_err(tsi148_bridge->parent, "Can't get assigned pci irq "
- "vector %02X\n", pdev->irq);
- return result;
- }
-
- /* Enable and unmask interrupts */
- tmp = TSI148_LCSR_INTEO_DMA1EO | TSI148_LCSR_INTEO_DMA0EO |
- TSI148_LCSR_INTEO_MB3EO | TSI148_LCSR_INTEO_MB2EO |
- TSI148_LCSR_INTEO_MB1EO | TSI148_LCSR_INTEO_MB0EO |
- TSI148_LCSR_INTEO_PERREO | TSI148_LCSR_INTEO_VERREO |
- TSI148_LCSR_INTEO_IACKEO;
-
- /* This leaves the following interrupts masked.
- * TSI148_LCSR_INTEO_VIEEO
- * TSI148_LCSR_INTEO_SYSFLEO
- * TSI148_LCSR_INTEO_ACFLEO
- */
-
- /* Don't enable Location Monitor interrupts here - they will be
- * enabled when the location monitors are properly configured and
- * a callback has been attached.
- * TSI148_LCSR_INTEO_LM0EO
- * TSI148_LCSR_INTEO_LM1EO
- * TSI148_LCSR_INTEO_LM2EO
- * TSI148_LCSR_INTEO_LM3EO
- */
-
- /* Don't enable VME interrupts until we add a handler, else the board
- * will respond to it and we don't want that unless it knows how to
- * properly deal with it.
- * TSI148_LCSR_INTEO_IRQ7EO
- * TSI148_LCSR_INTEO_IRQ6EO
- * TSI148_LCSR_INTEO_IRQ5EO
- * TSI148_LCSR_INTEO_IRQ4EO
- * TSI148_LCSR_INTEO_IRQ3EO
- * TSI148_LCSR_INTEO_IRQ2EO
- * TSI148_LCSR_INTEO_IRQ1EO
- */
-
- iowrite32be(tmp, bridge->base + TSI148_LCSR_INTEO);
- iowrite32be(tmp, bridge->base + TSI148_LCSR_INTEN);
-
- return 0;
-}
-
-static void tsi148_irq_exit(struct vme_bridge *tsi148_bridge,
- struct pci_dev *pdev)
-{
- struct tsi148_driver *bridge = tsi148_bridge->driver_priv;
-
- /* Turn off interrupts */
- iowrite32be(0x0, bridge->base + TSI148_LCSR_INTEO);
- iowrite32be(0x0, bridge->base + TSI148_LCSR_INTEN);
-
- /* Clear all interrupts */
- iowrite32be(0xFFFFFFFF, bridge->base + TSI148_LCSR_INTC);
-
- /* Detach interrupt handler */
- free_irq(pdev->irq, tsi148_bridge);
-}
-
-/*
- * Check to see if an IACk has been received, return true (1) or false (0).
- */
-static int tsi148_iack_received(struct tsi148_driver *bridge)
-{
- u32 tmp;
-
- tmp = ioread32be(bridge->base + TSI148_LCSR_VICR);
-
- if (tmp & TSI148_LCSR_VICR_IRQS)
- return 0;
- else
- return 1;
-}
-
-/*
- * Configure VME interrupt
- */
-static void tsi148_irq_set(struct vme_bridge *tsi148_bridge, int level,
- int state, int sync)
-{
- struct pci_dev *pdev;
- u32 tmp;
- struct tsi148_driver *bridge;
-
- bridge = tsi148_bridge->driver_priv;
-
- /* We need to do the ordering differently for enabling and disabling */
- if (state == 0) {
- tmp = ioread32be(bridge->base + TSI148_LCSR_INTEN);
- tmp &= ~TSI148_LCSR_INTEN_IRQEN[level - 1];
- iowrite32be(tmp, bridge->base + TSI148_LCSR_INTEN);
-
- tmp = ioread32be(bridge->base + TSI148_LCSR_INTEO);
- tmp &= ~TSI148_LCSR_INTEO_IRQEO[level - 1];
- iowrite32be(tmp, bridge->base + TSI148_LCSR_INTEO);
-
- if (sync != 0) {
- pdev = container_of(tsi148_bridge->parent,
- struct pci_dev, dev);
-
- synchronize_irq(pdev->irq);
- }
- } else {
- tmp = ioread32be(bridge->base + TSI148_LCSR_INTEO);
- tmp |= TSI148_LCSR_INTEO_IRQEO[level - 1];
- iowrite32be(tmp, bridge->base + TSI148_LCSR_INTEO);
-
- tmp = ioread32be(bridge->base + TSI148_LCSR_INTEN);
- tmp |= TSI148_LCSR_INTEN_IRQEN[level - 1];
- iowrite32be(tmp, bridge->base + TSI148_LCSR_INTEN);
- }
-}
-
-/*
- * Generate a VME bus interrupt at the requested level & vector. Wait for
- * interrupt to be acked.
- */
-static int tsi148_irq_generate(struct vme_bridge *tsi148_bridge, int level,
- int statid)
-{
- u32 tmp;
- struct tsi148_driver *bridge;
-
- bridge = tsi148_bridge->driver_priv;
-
- mutex_lock(&bridge->vme_int);
-
- /* Read VICR register */
- tmp = ioread32be(bridge->base + TSI148_LCSR_VICR);
-
- /* Set Status/ID */
- tmp = (tmp & ~TSI148_LCSR_VICR_STID_M) |
- (statid & TSI148_LCSR_VICR_STID_M);
- iowrite32be(tmp, bridge->base + TSI148_LCSR_VICR);
-
- /* Assert VMEbus IRQ */
- tmp = tmp | TSI148_LCSR_VICR_IRQL[level];
- iowrite32be(tmp, bridge->base + TSI148_LCSR_VICR);
-
- /* XXX Consider implementing a timeout? */
- wait_event_interruptible(bridge->iack_queue,
- tsi148_iack_received(bridge));
-
- mutex_unlock(&bridge->vme_int);
-
- return 0;
-}
-
-/*
- * Find the first error in this address range
- */
-static struct vme_bus_error *tsi148_find_error(struct vme_bridge *tsi148_bridge,
- u32 aspace, unsigned long long address, size_t count)
-{
- struct list_head *err_pos;
- struct vme_bus_error *vme_err, *valid = NULL;
- unsigned long long bound;
-
- bound = address + count;
-
- /*
- * XXX We are currently not looking at the address space when parsing
- * for errors. This is because parsing the Address Modifier Codes
- * is going to be quite resource intensive to do properly. We
- * should be OK just looking at the addresses and this is certainly
- * much better than what we had before.
- */
- err_pos = NULL;
- /* Iterate through errors */
- list_for_each(err_pos, &tsi148_bridge->vme_errors) {
- vme_err = list_entry(err_pos, struct vme_bus_error, list);
- if ((vme_err->address >= address) &&
- (vme_err->address < bound)) {
-
- valid = vme_err;
- break;
- }
- }
-
- return valid;
-}
-
-/*
- * Clear errors in the provided address range.
- */
-static void tsi148_clear_errors(struct vme_bridge *tsi148_bridge,
- u32 aspace, unsigned long long address, size_t count)
-{
- struct list_head *err_pos, *temp;
- struct vme_bus_error *vme_err;
- unsigned long long bound;
-
- bound = address + count;
-
- /*
- * XXX We are currently not looking at the address space when parsing
- * for errors. This is because parsing the Address Modifier Codes
- * is going to be quite resource intensive to do properly. We
- * should be OK just looking at the addresses and this is certainly
- * much better than what we had before.
- */
- err_pos = NULL;
- /* Iterate through errors */
- list_for_each_safe(err_pos, temp, &tsi148_bridge->vme_errors) {
- vme_err = list_entry(err_pos, struct vme_bus_error, list);
-
- if ((vme_err->address >= address) &&
- (vme_err->address < bound)) {
-
- list_del(err_pos);
- kfree(vme_err);
- }
- }
-}
-
-/*
- * Initialize a slave window with the requested attributes.
- */
-static int tsi148_slave_set(struct vme_slave_resource *image, int enabled,
- unsigned long long vme_base, unsigned long long size,
- dma_addr_t pci_base, u32 aspace, u32 cycle)
-{
- unsigned int i, addr = 0, granularity = 0;
- unsigned int temp_ctl = 0;
- unsigned int vme_base_low, vme_base_high;
- unsigned int vme_bound_low, vme_bound_high;
- unsigned int pci_offset_low, pci_offset_high;
- unsigned long long vme_bound, pci_offset;
- struct vme_bridge *tsi148_bridge;
- struct tsi148_driver *bridge;
-
- tsi148_bridge = image->parent;
- bridge = tsi148_bridge->driver_priv;
-
- i = image->number;
-
- switch (aspace) {
- case VME_A16:
- granularity = 0x10;
- addr |= TSI148_LCSR_ITAT_AS_A16;
- break;
- case VME_A24:
- granularity = 0x1000;
- addr |= TSI148_LCSR_ITAT_AS_A24;
- break;
- case VME_A32:
- granularity = 0x10000;
- addr |= TSI148_LCSR_ITAT_AS_A32;
- break;
- case VME_A64:
- granularity = 0x10000;
- addr |= TSI148_LCSR_ITAT_AS_A64;
- break;
- case VME_CRCSR:
- case VME_USER1:
- case VME_USER2:
- case VME_USER3:
- case VME_USER4:
- default:
- dev_err(tsi148_bridge->parent, "Invalid address space\n");
- return -EINVAL;
- break;
- }
-
- /* Convert 64-bit variables to 2x 32-bit variables */
- reg_split(vme_base, &vme_base_high, &vme_base_low);
-
- /*
- * Bound address is a valid address for the window, adjust
- * accordingly
- */
- vme_bound = vme_base + size - granularity;
- reg_split(vme_bound, &vme_bound_high, &vme_bound_low);
- pci_offset = (unsigned long long)pci_base - vme_base;
- reg_split(pci_offset, &pci_offset_high, &pci_offset_low);
-
- if (vme_base_low & (granularity - 1)) {
- dev_err(tsi148_bridge->parent, "Invalid VME base alignment\n");
- return -EINVAL;
- }
- if (vme_bound_low & (granularity - 1)) {
- dev_err(tsi148_bridge->parent, "Invalid VME bound alignment\n");
- return -EINVAL;
- }
- if (pci_offset_low & (granularity - 1)) {
- dev_err(tsi148_bridge->parent, "Invalid PCI Offset "
- "alignment\n");
- return -EINVAL;
- }
-
- /* Disable while we are mucking around */
- temp_ctl = ioread32be(bridge->base + TSI148_LCSR_IT[i] +
- TSI148_LCSR_OFFSET_ITAT);
- temp_ctl &= ~TSI148_LCSR_ITAT_EN;
- iowrite32be(temp_ctl, bridge->base + TSI148_LCSR_IT[i] +
- TSI148_LCSR_OFFSET_ITAT);
-
- /* Setup mapping */
- iowrite32be(vme_base_high, bridge->base + TSI148_LCSR_IT[i] +
- TSI148_LCSR_OFFSET_ITSAU);
- iowrite32be(vme_base_low, bridge->base + TSI148_LCSR_IT[i] +
- TSI148_LCSR_OFFSET_ITSAL);
- iowrite32be(vme_bound_high, bridge->base + TSI148_LCSR_IT[i] +
- TSI148_LCSR_OFFSET_ITEAU);
- iowrite32be(vme_bound_low, bridge->base + TSI148_LCSR_IT[i] +
- TSI148_LCSR_OFFSET_ITEAL);
- iowrite32be(pci_offset_high, bridge->base + TSI148_LCSR_IT[i] +
- TSI148_LCSR_OFFSET_ITOFU);
- iowrite32be(pci_offset_low, bridge->base + TSI148_LCSR_IT[i] +
- TSI148_LCSR_OFFSET_ITOFL);
-
- /* Setup 2eSST speeds */
- temp_ctl &= ~TSI148_LCSR_ITAT_2eSSTM_M;
- switch (cycle & (VME_2eSST160 | VME_2eSST267 | VME_2eSST320)) {
- case VME_2eSST160:
- temp_ctl |= TSI148_LCSR_ITAT_2eSSTM_160;
- break;
- case VME_2eSST267:
- temp_ctl |= TSI148_LCSR_ITAT_2eSSTM_267;
- break;
- case VME_2eSST320:
- temp_ctl |= TSI148_LCSR_ITAT_2eSSTM_320;
- break;
- }
-
- /* Setup cycle types */
- temp_ctl &= ~(0x1F << 7);
- if (cycle & VME_BLT)
- temp_ctl |= TSI148_LCSR_ITAT_BLT;
- if (cycle & VME_MBLT)
- temp_ctl |= TSI148_LCSR_ITAT_MBLT;
- if (cycle & VME_2eVME)
- temp_ctl |= TSI148_LCSR_ITAT_2eVME;
- if (cycle & VME_2eSST)
- temp_ctl |= TSI148_LCSR_ITAT_2eSST;
- if (cycle & VME_2eSSTB)
- temp_ctl |= TSI148_LCSR_ITAT_2eSSTB;
-
- /* Setup address space */
- temp_ctl &= ~TSI148_LCSR_ITAT_AS_M;
- temp_ctl |= addr;
-
- temp_ctl &= ~0xF;
- if (cycle & VME_SUPER)
- temp_ctl |= TSI148_LCSR_ITAT_SUPR ;
- if (cycle & VME_USER)
- temp_ctl |= TSI148_LCSR_ITAT_NPRIV;
- if (cycle & VME_PROG)
- temp_ctl |= TSI148_LCSR_ITAT_PGM;
- if (cycle & VME_DATA)
- temp_ctl |= TSI148_LCSR_ITAT_DATA;
-
- /* Write ctl reg without enable */
- iowrite32be(temp_ctl, bridge->base + TSI148_LCSR_IT[i] +
- TSI148_LCSR_OFFSET_ITAT);
-
- if (enabled)
- temp_ctl |= TSI148_LCSR_ITAT_EN;
-
- iowrite32be(temp_ctl, bridge->base + TSI148_LCSR_IT[i] +
- TSI148_LCSR_OFFSET_ITAT);
-
- return 0;
-}
-
-/*
- * Get slave window configuration.
- */
-static int tsi148_slave_get(struct vme_slave_resource *image, int *enabled,
- unsigned long long *vme_base, unsigned long long *size,
- dma_addr_t *pci_base, u32 *aspace, u32 *cycle)
-{
- unsigned int i, granularity = 0, ctl = 0;
- unsigned int vme_base_low, vme_base_high;
- unsigned int vme_bound_low, vme_bound_high;
- unsigned int pci_offset_low, pci_offset_high;
- unsigned long long vme_bound, pci_offset;
- struct tsi148_driver *bridge;
-
- bridge = image->parent->driver_priv;
-
- i = image->number;
-
- /* Read registers */
- ctl = ioread32be(bridge->base + TSI148_LCSR_IT[i] +
- TSI148_LCSR_OFFSET_ITAT);
-
- vme_base_high = ioread32be(bridge->base + TSI148_LCSR_IT[i] +
- TSI148_LCSR_OFFSET_ITSAU);
- vme_base_low = ioread32be(bridge->base + TSI148_LCSR_IT[i] +
- TSI148_LCSR_OFFSET_ITSAL);
- vme_bound_high = ioread32be(bridge->base + TSI148_LCSR_IT[i] +
- TSI148_LCSR_OFFSET_ITEAU);
- vme_bound_low = ioread32be(bridge->base + TSI148_LCSR_IT[i] +
- TSI148_LCSR_OFFSET_ITEAL);
- pci_offset_high = ioread32be(bridge->base + TSI148_LCSR_IT[i] +
- TSI148_LCSR_OFFSET_ITOFU);
- pci_offset_low = ioread32be(bridge->base + TSI148_LCSR_IT[i] +
- TSI148_LCSR_OFFSET_ITOFL);
-
- /* Convert 64-bit variables to 2x 32-bit variables */
- reg_join(vme_base_high, vme_base_low, vme_base);
- reg_join(vme_bound_high, vme_bound_low, &vme_bound);
- reg_join(pci_offset_high, pci_offset_low, &pci_offset);
-
- *pci_base = (dma_addr_t)vme_base + pci_offset;
-
- *enabled = 0;
- *aspace = 0;
- *cycle = 0;
-
- if (ctl & TSI148_LCSR_ITAT_EN)
- *enabled = 1;
-
- if ((ctl & TSI148_LCSR_ITAT_AS_M) == TSI148_LCSR_ITAT_AS_A16) {
- granularity = 0x10;
- *aspace |= VME_A16;
- }
- if ((ctl & TSI148_LCSR_ITAT_AS_M) == TSI148_LCSR_ITAT_AS_A24) {
- granularity = 0x1000;
- *aspace |= VME_A24;
- }
- if ((ctl & TSI148_LCSR_ITAT_AS_M) == TSI148_LCSR_ITAT_AS_A32) {
- granularity = 0x10000;
- *aspace |= VME_A32;
- }
- if ((ctl & TSI148_LCSR_ITAT_AS_M) == TSI148_LCSR_ITAT_AS_A64) {
- granularity = 0x10000;
- *aspace |= VME_A64;
- }
-
- /* Need granularity before we set the size */
- *size = (unsigned long long)((vme_bound - *vme_base) + granularity);
-
-
- if ((ctl & TSI148_LCSR_ITAT_2eSSTM_M) == TSI148_LCSR_ITAT_2eSSTM_160)
- *cycle |= VME_2eSST160;
- if ((ctl & TSI148_LCSR_ITAT_2eSSTM_M) == TSI148_LCSR_ITAT_2eSSTM_267)
- *cycle |= VME_2eSST267;
- if ((ctl & TSI148_LCSR_ITAT_2eSSTM_M) == TSI148_LCSR_ITAT_2eSSTM_320)
- *cycle |= VME_2eSST320;
-
- if (ctl & TSI148_LCSR_ITAT_BLT)
- *cycle |= VME_BLT;
- if (ctl & TSI148_LCSR_ITAT_MBLT)
- *cycle |= VME_MBLT;
- if (ctl & TSI148_LCSR_ITAT_2eVME)
- *cycle |= VME_2eVME;
- if (ctl & TSI148_LCSR_ITAT_2eSST)
- *cycle |= VME_2eSST;
- if (ctl & TSI148_LCSR_ITAT_2eSSTB)
- *cycle |= VME_2eSSTB;
-
- if (ctl & TSI148_LCSR_ITAT_SUPR)
- *cycle |= VME_SUPER;
- if (ctl & TSI148_LCSR_ITAT_NPRIV)
- *cycle |= VME_USER;
- if (ctl & TSI148_LCSR_ITAT_PGM)
- *cycle |= VME_PROG;
- if (ctl & TSI148_LCSR_ITAT_DATA)
- *cycle |= VME_DATA;
-
- return 0;
-}
-
-/*
- * Allocate and map PCI Resource
- */
-static int tsi148_alloc_resource(struct vme_master_resource *image,
- unsigned long long size)
-{
- unsigned long long existing_size;
- int retval = 0;
- struct pci_dev *pdev;
- struct vme_bridge *tsi148_bridge;
-
- tsi148_bridge = image->parent;
-
- pdev = container_of(tsi148_bridge->parent, struct pci_dev, dev);
-
- existing_size = (unsigned long long)(image->bus_resource.end -
- image->bus_resource.start);
-
- /* If the existing size is OK, return */
- if ((size != 0) && (existing_size == (size - 1)))
- return 0;
-
- if (existing_size != 0) {
- iounmap(image->kern_base);
- image->kern_base = NULL;
- kfree(image->bus_resource.name);
- release_resource(&image->bus_resource);
- memset(&image->bus_resource, 0, sizeof(struct resource));
- }
-
- /* Exit here if size is zero */
- if (size == 0)
- return 0;
-
- if (image->bus_resource.name == NULL) {
- image->bus_resource.name = kmalloc(VMENAMSIZ+3, GFP_ATOMIC);
- if (image->bus_resource.name == NULL) {
- dev_err(tsi148_bridge->parent, "Unable to allocate "
- "memory for resource name\n");
- retval = -ENOMEM;
- goto err_name;
- }
- }
-
- sprintf((char *)image->bus_resource.name, "%s.%d", tsi148_bridge->name,
- image->number);
-
- image->bus_resource.start = 0;
- image->bus_resource.end = (unsigned long)size;
- image->bus_resource.flags = IORESOURCE_MEM;
-
- retval = pci_bus_alloc_resource(pdev->bus,
- &image->bus_resource, size, size, PCIBIOS_MIN_MEM,
- 0, NULL, NULL);
- if (retval) {
- dev_err(tsi148_bridge->parent, "Failed to allocate mem "
- "resource for window %d size 0x%lx start 0x%lx\n",
- image->number, (unsigned long)size,
- (unsigned long)image->bus_resource.start);
- goto err_resource;
- }
-
- image->kern_base = ioremap_nocache(
- image->bus_resource.start, size);
- if (image->kern_base == NULL) {
- dev_err(tsi148_bridge->parent, "Failed to remap resource\n");
- retval = -ENOMEM;
- goto err_remap;
- }
-
- return 0;
-
-err_remap:
- release_resource(&image->bus_resource);
-err_resource:
- kfree(image->bus_resource.name);
- memset(&image->bus_resource, 0, sizeof(struct resource));
-err_name:
- return retval;
-}
-
-/*
- * Free and unmap PCI Resource
- */
-static void tsi148_free_resource(struct vme_master_resource *image)
-{
- iounmap(image->kern_base);
- image->kern_base = NULL;
- release_resource(&image->bus_resource);
- kfree(image->bus_resource.name);
- memset(&image->bus_resource, 0, sizeof(struct resource));
-}
-
-/*
- * Set the attributes of an outbound window.
- */
-static int tsi148_master_set(struct vme_master_resource *image, int enabled,
- unsigned long long vme_base, unsigned long long size, u32 aspace,
- u32 cycle, u32 dwidth)
-{
- int retval = 0;
- unsigned int i;
- unsigned int temp_ctl = 0;
- unsigned int pci_base_low, pci_base_high;
- unsigned int pci_bound_low, pci_bound_high;
- unsigned int vme_offset_low, vme_offset_high;
- unsigned long long pci_bound, vme_offset, pci_base;
- struct vme_bridge *tsi148_bridge;
- struct tsi148_driver *bridge;
-
- tsi148_bridge = image->parent;
-
- bridge = tsi148_bridge->driver_priv;
-
- /* Verify input data */
- if (vme_base & 0xFFFF) {
- dev_err(tsi148_bridge->parent, "Invalid VME Window "
- "alignment\n");
- retval = -EINVAL;
- goto err_window;
- }
-
- if ((size == 0) && (enabled != 0)) {
- dev_err(tsi148_bridge->parent, "Size must be non-zero for "
- "enabled windows\n");
- retval = -EINVAL;
- goto err_window;
- }
-
- spin_lock(&image->lock);
-
- /* Let's allocate the resource here rather than further up the stack as
- * it avoids pushing loads of bus dependent stuff up the stack. If size
- * is zero, any existing resource will be freed.
- */
- retval = tsi148_alloc_resource(image, size);
- if (retval) {
- spin_unlock(&image->lock);
- dev_err(tsi148_bridge->parent, "Unable to allocate memory for "
- "resource\n");
- goto err_res;
- }
-
- if (size == 0) {
- pci_base = 0;
- pci_bound = 0;
- vme_offset = 0;
- } else {
- pci_base = (unsigned long long)image->bus_resource.start;
-
- /*
- * Bound address is a valid address for the window, adjust
- * according to window granularity.
- */
- pci_bound = pci_base + (size - 0x10000);
- vme_offset = vme_base - pci_base;
- }
-
- /* Convert 64-bit variables to 2x 32-bit variables */
- reg_split(pci_base, &pci_base_high, &pci_base_low);
- reg_split(pci_bound, &pci_bound_high, &pci_bound_low);
- reg_split(vme_offset, &vme_offset_high, &vme_offset_low);
-
- if (pci_base_low & 0xFFFF) {
- spin_unlock(&image->lock);
- dev_err(tsi148_bridge->parent, "Invalid PCI base alignment\n");
- retval = -EINVAL;
- goto err_gran;
- }
- if (pci_bound_low & 0xFFFF) {
- spin_unlock(&image->lock);
- dev_err(tsi148_bridge->parent, "Invalid PCI bound alignment\n");
- retval = -EINVAL;
- goto err_gran;
- }
- if (vme_offset_low & 0xFFFF) {
- spin_unlock(&image->lock);
- dev_err(tsi148_bridge->parent, "Invalid VME Offset "
- "alignment\n");
- retval = -EINVAL;
- goto err_gran;
- }
-
- i = image->number;
-
- /* Disable while we are mucking around */
- temp_ctl = ioread32be(bridge->base + TSI148_LCSR_OT[i] +
- TSI148_LCSR_OFFSET_OTAT);
- temp_ctl &= ~TSI148_LCSR_OTAT_EN;
- iowrite32be(temp_ctl, bridge->base + TSI148_LCSR_OT[i] +
- TSI148_LCSR_OFFSET_OTAT);
-
- /* Setup 2eSST speeds */
- temp_ctl &= ~TSI148_LCSR_OTAT_2eSSTM_M;
- switch (cycle & (VME_2eSST160 | VME_2eSST267 | VME_2eSST320)) {
- case VME_2eSST160:
- temp_ctl |= TSI148_LCSR_OTAT_2eSSTM_160;
- break;
- case VME_2eSST267:
- temp_ctl |= TSI148_LCSR_OTAT_2eSSTM_267;
- break;
- case VME_2eSST320:
- temp_ctl |= TSI148_LCSR_OTAT_2eSSTM_320;
- break;
- }
-
- /* Setup cycle types */
- if (cycle & VME_BLT) {
- temp_ctl &= ~TSI148_LCSR_OTAT_TM_M;
- temp_ctl |= TSI148_LCSR_OTAT_TM_BLT;
- }
- if (cycle & VME_MBLT) {
- temp_ctl &= ~TSI148_LCSR_OTAT_TM_M;
- temp_ctl |= TSI148_LCSR_OTAT_TM_MBLT;
- }
- if (cycle & VME_2eVME) {
- temp_ctl &= ~TSI148_LCSR_OTAT_TM_M;
- temp_ctl |= TSI148_LCSR_OTAT_TM_2eVME;
- }
- if (cycle & VME_2eSST) {
- temp_ctl &= ~TSI148_LCSR_OTAT_TM_M;
- temp_ctl |= TSI148_LCSR_OTAT_TM_2eSST;
- }
- if (cycle & VME_2eSSTB) {
- dev_warn(tsi148_bridge->parent, "Currently not setting "
- "Broadcast Select Registers\n");
- temp_ctl &= ~TSI148_LCSR_OTAT_TM_M;
- temp_ctl |= TSI148_LCSR_OTAT_TM_2eSSTB;
- }
-
- /* Setup data width */
- temp_ctl &= ~TSI148_LCSR_OTAT_DBW_M;
- switch (dwidth) {
- case VME_D16:
- temp_ctl |= TSI148_LCSR_OTAT_DBW_16;
- break;
- case VME_D32:
- temp_ctl |= TSI148_LCSR_OTAT_DBW_32;
- break;
- default:
- spin_unlock(&image->lock);
- dev_err(tsi148_bridge->parent, "Invalid data width\n");
- retval = -EINVAL;
- goto err_dwidth;
- }
-
- /* Setup address space */
- temp_ctl &= ~TSI148_LCSR_OTAT_AMODE_M;
- switch (aspace) {
- case VME_A16:
- temp_ctl |= TSI148_LCSR_OTAT_AMODE_A16;
- break;
- case VME_A24:
- temp_ctl |= TSI148_LCSR_OTAT_AMODE_A24;
- break;
- case VME_A32:
- temp_ctl |= TSI148_LCSR_OTAT_AMODE_A32;
- break;
- case VME_A64:
- temp_ctl |= TSI148_LCSR_OTAT_AMODE_A64;
- break;
- case VME_CRCSR:
- temp_ctl |= TSI148_LCSR_OTAT_AMODE_CRCSR;
- break;
- case VME_USER1:
- temp_ctl |= TSI148_LCSR_OTAT_AMODE_USER1;
- break;
- case VME_USER2:
- temp_ctl |= TSI148_LCSR_OTAT_AMODE_USER2;
- break;
- case VME_USER3:
- temp_ctl |= TSI148_LCSR_OTAT_AMODE_USER3;
- break;
- case VME_USER4:
- temp_ctl |= TSI148_LCSR_OTAT_AMODE_USER4;
- break;
- default:
- spin_unlock(&image->lock);
- dev_err(tsi148_bridge->parent, "Invalid address space\n");
- retval = -EINVAL;
- goto err_aspace;
- break;
- }
-
- temp_ctl &= ~(3<<4);
- if (cycle & VME_SUPER)
- temp_ctl |= TSI148_LCSR_OTAT_SUP;
- if (cycle & VME_PROG)
- temp_ctl |= TSI148_LCSR_OTAT_PGM;
-
- /* Setup mapping */
- iowrite32be(pci_base_high, bridge->base + TSI148_LCSR_OT[i] +
- TSI148_LCSR_OFFSET_OTSAU);
- iowrite32be(pci_base_low, bridge->base + TSI148_LCSR_OT[i] +
- TSI148_LCSR_OFFSET_OTSAL);
- iowrite32be(pci_bound_high, bridge->base + TSI148_LCSR_OT[i] +
- TSI148_LCSR_OFFSET_OTEAU);
- iowrite32be(pci_bound_low, bridge->base + TSI148_LCSR_OT[i] +
- TSI148_LCSR_OFFSET_OTEAL);
- iowrite32be(vme_offset_high, bridge->base + TSI148_LCSR_OT[i] +
- TSI148_LCSR_OFFSET_OTOFU);
- iowrite32be(vme_offset_low, bridge->base + TSI148_LCSR_OT[i] +
- TSI148_LCSR_OFFSET_OTOFL);
-
- /* Write ctl reg without enable */
- iowrite32be(temp_ctl, bridge->base + TSI148_LCSR_OT[i] +
- TSI148_LCSR_OFFSET_OTAT);
-
- if (enabled)
- temp_ctl |= TSI148_LCSR_OTAT_EN;
-
- iowrite32be(temp_ctl, bridge->base + TSI148_LCSR_OT[i] +
- TSI148_LCSR_OFFSET_OTAT);
-
- spin_unlock(&image->lock);
- return 0;
-
-err_aspace:
-err_dwidth:
-err_gran:
- tsi148_free_resource(image);
-err_res:
-err_window:
- return retval;
-
-}
-
-/*
- * Set the attributes of an outbound window.
- *
- * XXX Not parsing prefetch information.
- */
-static int __tsi148_master_get(struct vme_master_resource *image, int *enabled,
- unsigned long long *vme_base, unsigned long long *size, u32 *aspace,
- u32 *cycle, u32 *dwidth)
-{
- unsigned int i, ctl;
- unsigned int pci_base_low, pci_base_high;
- unsigned int pci_bound_low, pci_bound_high;
- unsigned int vme_offset_low, vme_offset_high;
-
- unsigned long long pci_base, pci_bound, vme_offset;
- struct tsi148_driver *bridge;
-
- bridge = image->parent->driver_priv;
-
- i = image->number;
-
- ctl = ioread32be(bridge->base + TSI148_LCSR_OT[i] +
- TSI148_LCSR_OFFSET_OTAT);
-
- pci_base_high = ioread32be(bridge->base + TSI148_LCSR_OT[i] +
- TSI148_LCSR_OFFSET_OTSAU);
- pci_base_low = ioread32be(bridge->base + TSI148_LCSR_OT[i] +
- TSI148_LCSR_OFFSET_OTSAL);
- pci_bound_high = ioread32be(bridge->base + TSI148_LCSR_OT[i] +
- TSI148_LCSR_OFFSET_OTEAU);
- pci_bound_low = ioread32be(bridge->base + TSI148_LCSR_OT[i] +
- TSI148_LCSR_OFFSET_OTEAL);
- vme_offset_high = ioread32be(bridge->base + TSI148_LCSR_OT[i] +
- TSI148_LCSR_OFFSET_OTOFU);
- vme_offset_low = ioread32be(bridge->base + TSI148_LCSR_OT[i] +
- TSI148_LCSR_OFFSET_OTOFL);
-
- /* Convert 64-bit variables to 2x 32-bit variables */
- reg_join(pci_base_high, pci_base_low, &pci_base);
- reg_join(pci_bound_high, pci_bound_low, &pci_bound);
- reg_join(vme_offset_high, vme_offset_low, &vme_offset);
-
- *vme_base = pci_base + vme_offset;
- *size = (unsigned long long)(pci_bound - pci_base) + 0x10000;
-
- *enabled = 0;
- *aspace = 0;
- *cycle = 0;
- *dwidth = 0;
-
- if (ctl & TSI148_LCSR_OTAT_EN)
- *enabled = 1;
-
- /* Setup address space */
- if ((ctl & TSI148_LCSR_OTAT_AMODE_M) == TSI148_LCSR_OTAT_AMODE_A16)
- *aspace |= VME_A16;
- if ((ctl & TSI148_LCSR_OTAT_AMODE_M) == TSI148_LCSR_OTAT_AMODE_A24)
- *aspace |= VME_A24;
- if ((ctl & TSI148_LCSR_OTAT_AMODE_M) == TSI148_LCSR_OTAT_AMODE_A32)
- *aspace |= VME_A32;
- if ((ctl & TSI148_LCSR_OTAT_AMODE_M) == TSI148_LCSR_OTAT_AMODE_A64)
- *aspace |= VME_A64;
- if ((ctl & TSI148_LCSR_OTAT_AMODE_M) == TSI148_LCSR_OTAT_AMODE_CRCSR)
- *aspace |= VME_CRCSR;
- if ((ctl & TSI148_LCSR_OTAT_AMODE_M) == TSI148_LCSR_OTAT_AMODE_USER1)
- *aspace |= VME_USER1;
- if ((ctl & TSI148_LCSR_OTAT_AMODE_M) == TSI148_LCSR_OTAT_AMODE_USER2)
- *aspace |= VME_USER2;
- if ((ctl & TSI148_LCSR_OTAT_AMODE_M) == TSI148_LCSR_OTAT_AMODE_USER3)
- *aspace |= VME_USER3;
- if ((ctl & TSI148_LCSR_OTAT_AMODE_M) == TSI148_LCSR_OTAT_AMODE_USER4)
- *aspace |= VME_USER4;
-
- /* Setup 2eSST speeds */
- if ((ctl & TSI148_LCSR_OTAT_2eSSTM_M) == TSI148_LCSR_OTAT_2eSSTM_160)
- *cycle |= VME_2eSST160;
- if ((ctl & TSI148_LCSR_OTAT_2eSSTM_M) == TSI148_LCSR_OTAT_2eSSTM_267)
- *cycle |= VME_2eSST267;
- if ((ctl & TSI148_LCSR_OTAT_2eSSTM_M) == TSI148_LCSR_OTAT_2eSSTM_320)
- *cycle |= VME_2eSST320;
-
- /* Setup cycle types */
- if ((ctl & TSI148_LCSR_OTAT_TM_M) == TSI148_LCSR_OTAT_TM_SCT)
- *cycle |= VME_SCT;
- if ((ctl & TSI148_LCSR_OTAT_TM_M) == TSI148_LCSR_OTAT_TM_BLT)
- *cycle |= VME_BLT;
- if ((ctl & TSI148_LCSR_OTAT_TM_M) == TSI148_LCSR_OTAT_TM_MBLT)
- *cycle |= VME_MBLT;
- if ((ctl & TSI148_LCSR_OTAT_TM_M) == TSI148_LCSR_OTAT_TM_2eVME)
- *cycle |= VME_2eVME;
- if ((ctl & TSI148_LCSR_OTAT_TM_M) == TSI148_LCSR_OTAT_TM_2eSST)
- *cycle |= VME_2eSST;
- if ((ctl & TSI148_LCSR_OTAT_TM_M) == TSI148_LCSR_OTAT_TM_2eSSTB)
- *cycle |= VME_2eSSTB;
-
- if (ctl & TSI148_LCSR_OTAT_SUP)
- *cycle |= VME_SUPER;
- else
- *cycle |= VME_USER;
-
- if (ctl & TSI148_LCSR_OTAT_PGM)
- *cycle |= VME_PROG;
- else
- *cycle |= VME_DATA;
-
- /* Setup data width */
- if ((ctl & TSI148_LCSR_OTAT_DBW_M) == TSI148_LCSR_OTAT_DBW_16)
- *dwidth = VME_D16;
- if ((ctl & TSI148_LCSR_OTAT_DBW_M) == TSI148_LCSR_OTAT_DBW_32)
- *dwidth = VME_D32;
-
- return 0;
-}
-
-
-static int tsi148_master_get(struct vme_master_resource *image, int *enabled,
- unsigned long long *vme_base, unsigned long long *size, u32 *aspace,
- u32 *cycle, u32 *dwidth)
-{
- int retval;
-
- spin_lock(&image->lock);
-
- retval = __tsi148_master_get(image, enabled, vme_base, size, aspace,
- cycle, dwidth);
-
- spin_unlock(&image->lock);
-
- return retval;
-}
-
-static ssize_t tsi148_master_read(struct vme_master_resource *image, void *buf,
- size_t count, loff_t offset)
-{
- int retval, enabled;
- unsigned long long vme_base, size;
- u32 aspace, cycle, dwidth;
- struct vme_bus_error *vme_err = NULL;
- struct vme_bridge *tsi148_bridge;
-
- tsi148_bridge = image->parent;
-
- spin_lock(&image->lock);
-
- memcpy_fromio(buf, image->kern_base + offset, (unsigned int)count);
- retval = count;
-
- if (!err_chk)
- goto skip_chk;
-
- __tsi148_master_get(image, &enabled, &vme_base, &size, &aspace, &cycle,
- &dwidth);
-
- vme_err = tsi148_find_error(tsi148_bridge, aspace, vme_base + offset,
- count);
- if (vme_err != NULL) {
- dev_err(image->parent->parent, "First VME read error detected "
- "an at address 0x%llx\n", vme_err->address);
- retval = vme_err->address - (vme_base + offset);
- /* Clear down save errors in this address range */
- tsi148_clear_errors(tsi148_bridge, aspace, vme_base + offset,
- count);
- }
-
-skip_chk:
- spin_unlock(&image->lock);
-
- return retval;
-}
-
-
-static ssize_t tsi148_master_write(struct vme_master_resource *image, void *buf,
- size_t count, loff_t offset)
-{
- int retval = 0, enabled;
- unsigned long long vme_base, size;
- u32 aspace, cycle, dwidth;
-
- struct vme_bus_error *vme_err = NULL;
- struct vme_bridge *tsi148_bridge;
- struct tsi148_driver *bridge;
-
- tsi148_bridge = image->parent;
-
- bridge = tsi148_bridge->driver_priv;
-
- spin_lock(&image->lock);
-
- memcpy_toio(image->kern_base + offset, buf, (unsigned int)count);
- retval = count;
-
- /*
- * Writes are posted. We need to do a read on the VME bus to flush out
- * all of the writes before we check for errors. We can't guarantee
- * that reading the data we have just written is safe. It is believed
- * that there isn't any read, write re-ordering, so we can read any
- * location in VME space, so lets read the Device ID from the tsi148's
- * own registers as mapped into CR/CSR space.
- *
- * We check for saved errors in the written address range/space.
- */
-
- if (!err_chk)
- goto skip_chk;
-
- /*
- * Get window info first, to maximise the time that the buffers may
- * fluch on their own
- */
- __tsi148_master_get(image, &enabled, &vme_base, &size, &aspace, &cycle,
- &dwidth);
-
- ioread16(bridge->flush_image->kern_base + 0x7F000);
-
- vme_err = tsi148_find_error(tsi148_bridge, aspace, vme_base + offset,
- count);
- if (vme_err != NULL) {
- dev_warn(tsi148_bridge->parent, "First VME write error detected"
- " an at address 0x%llx\n", vme_err->address);
- retval = vme_err->address - (vme_base + offset);
- /* Clear down save errors in this address range */
- tsi148_clear_errors(tsi148_bridge, aspace, vme_base + offset,
- count);
- }
-
-skip_chk:
- spin_unlock(&image->lock);
-
- return retval;
-}
-
-/*
- * Perform an RMW cycle on the VME bus.
- *
- * Requires a previously configured master window, returns final value.
- */
-static unsigned int tsi148_master_rmw(struct vme_master_resource *image,
- unsigned int mask, unsigned int compare, unsigned int swap,
- loff_t offset)
-{
- unsigned long long pci_addr;
- unsigned int pci_addr_high, pci_addr_low;
- u32 tmp, result;
- int i;
- struct tsi148_driver *bridge;
-
- bridge = image->parent->driver_priv;
-
- /* Find the PCI address that maps to the desired VME address */
- i = image->number;
-
- /* Locking as we can only do one of these at a time */
- mutex_lock(&bridge->vme_rmw);
-
- /* Lock image */
- spin_lock(&image->lock);
-
- pci_addr_high = ioread32be(bridge->base + TSI148_LCSR_OT[i] +
- TSI148_LCSR_OFFSET_OTSAU);
- pci_addr_low = ioread32be(bridge->base + TSI148_LCSR_OT[i] +
- TSI148_LCSR_OFFSET_OTSAL);
-
- reg_join(pci_addr_high, pci_addr_low, &pci_addr);
- reg_split(pci_addr + offset, &pci_addr_high, &pci_addr_low);
-
- /* Configure registers */
- iowrite32be(mask, bridge->base + TSI148_LCSR_RMWEN);
- iowrite32be(compare, bridge->base + TSI148_LCSR_RMWC);
- iowrite32be(swap, bridge->base + TSI148_LCSR_RMWS);
- iowrite32be(pci_addr_high, bridge->base + TSI148_LCSR_RMWAU);
- iowrite32be(pci_addr_low, bridge->base + TSI148_LCSR_RMWAL);
-
- /* Enable RMW */
- tmp = ioread32be(bridge->base + TSI148_LCSR_VMCTRL);
- tmp |= TSI148_LCSR_VMCTRL_RMWEN;
- iowrite32be(tmp, bridge->base + TSI148_LCSR_VMCTRL);
-
- /* Kick process off with a read to the required address. */
- result = ioread32be(image->kern_base + offset);
-
- /* Disable RMW */
- tmp = ioread32be(bridge->base + TSI148_LCSR_VMCTRL);
- tmp &= ~TSI148_LCSR_VMCTRL_RMWEN;
- iowrite32be(tmp, bridge->base + TSI148_LCSR_VMCTRL);
-
- spin_unlock(&image->lock);
-
- mutex_unlock(&bridge->vme_rmw);
-
- return result;
-}
-
-static int tsi148_dma_set_vme_src_attributes(struct device *dev, u32 *attr,
- u32 aspace, u32 cycle, u32 dwidth)
-{
- /* Setup 2eSST speeds */
- switch (cycle & (VME_2eSST160 | VME_2eSST267 | VME_2eSST320)) {
- case VME_2eSST160:
- *attr |= TSI148_LCSR_DSAT_2eSSTM_160;
- break;
- case VME_2eSST267:
- *attr |= TSI148_LCSR_DSAT_2eSSTM_267;
- break;
- case VME_2eSST320:
- *attr |= TSI148_LCSR_DSAT_2eSSTM_320;
- break;
- }
-
- /* Setup cycle types */
- if (cycle & VME_SCT)
- *attr |= TSI148_LCSR_DSAT_TM_SCT;
-
- if (cycle & VME_BLT)
- *attr |= TSI148_LCSR_DSAT_TM_BLT;
-
- if (cycle & VME_MBLT)
- *attr |= TSI148_LCSR_DSAT_TM_MBLT;
-
- if (cycle & VME_2eVME)
- *attr |= TSI148_LCSR_DSAT_TM_2eVME;
-
- if (cycle & VME_2eSST)
- *attr |= TSI148_LCSR_DSAT_TM_2eSST;
-
- if (cycle & VME_2eSSTB) {
- dev_err(dev, "Currently not setting Broadcast Select "
- "Registers\n");
- *attr |= TSI148_LCSR_DSAT_TM_2eSSTB;
- }
-
- /* Setup data width */
- switch (dwidth) {
- case VME_D16:
- *attr |= TSI148_LCSR_DSAT_DBW_16;
- break;
- case VME_D32:
- *attr |= TSI148_LCSR_DSAT_DBW_32;
- break;
- default:
- dev_err(dev, "Invalid data width\n");
- return -EINVAL;
- }
-
- /* Setup address space */
- switch (aspace) {
- case VME_A16:
- *attr |= TSI148_LCSR_DSAT_AMODE_A16;
- break;
- case VME_A24:
- *attr |= TSI148_LCSR_DSAT_AMODE_A24;
- break;
- case VME_A32:
- *attr |= TSI148_LCSR_DSAT_AMODE_A32;
- break;
- case VME_A64:
- *attr |= TSI148_LCSR_DSAT_AMODE_A64;
- break;
- case VME_CRCSR:
- *attr |= TSI148_LCSR_DSAT_AMODE_CRCSR;
- break;
- case VME_USER1:
- *attr |= TSI148_LCSR_DSAT_AMODE_USER1;
- break;
- case VME_USER2:
- *attr |= TSI148_LCSR_DSAT_AMODE_USER2;
- break;
- case VME_USER3:
- *attr |= TSI148_LCSR_DSAT_AMODE_USER3;
- break;
- case VME_USER4:
- *attr |= TSI148_LCSR_DSAT_AMODE_USER4;
- break;
- default:
- dev_err(dev, "Invalid address space\n");
- return -EINVAL;
- break;
- }
-
- if (cycle & VME_SUPER)
- *attr |= TSI148_LCSR_DSAT_SUP;
- if (cycle & VME_PROG)
- *attr |= TSI148_LCSR_DSAT_PGM;
-
- return 0;
-}
-
-static int tsi148_dma_set_vme_dest_attributes(struct device *dev, u32 *attr,
- u32 aspace, u32 cycle, u32 dwidth)
-{
- /* Setup 2eSST speeds */
- switch (cycle & (VME_2eSST160 | VME_2eSST267 | VME_2eSST320)) {
- case VME_2eSST160:
- *attr |= TSI148_LCSR_DDAT_2eSSTM_160;
- break;
- case VME_2eSST267:
- *attr |= TSI148_LCSR_DDAT_2eSSTM_267;
- break;
- case VME_2eSST320:
- *attr |= TSI148_LCSR_DDAT_2eSSTM_320;
- break;
- }
-
- /* Setup cycle types */
- if (cycle & VME_SCT)
- *attr |= TSI148_LCSR_DDAT_TM_SCT;
-
- if (cycle & VME_BLT)
- *attr |= TSI148_LCSR_DDAT_TM_BLT;
-
- if (cycle & VME_MBLT)
- *attr |= TSI148_LCSR_DDAT_TM_MBLT;
-
- if (cycle & VME_2eVME)
- *attr |= TSI148_LCSR_DDAT_TM_2eVME;
-
- if (cycle & VME_2eSST)
- *attr |= TSI148_LCSR_DDAT_TM_2eSST;
-
- if (cycle & VME_2eSSTB) {
- dev_err(dev, "Currently not setting Broadcast Select "
- "Registers\n");
- *attr |= TSI148_LCSR_DDAT_TM_2eSSTB;
- }
-
- /* Setup data width */
- switch (dwidth) {
- case VME_D16:
- *attr |= TSI148_LCSR_DDAT_DBW_16;
- break;
- case VME_D32:
- *attr |= TSI148_LCSR_DDAT_DBW_32;
- break;
- default:
- dev_err(dev, "Invalid data width\n");
- return -EINVAL;
- }
-
- /* Setup address space */
- switch (aspace) {
- case VME_A16:
- *attr |= TSI148_LCSR_DDAT_AMODE_A16;
- break;
- case VME_A24:
- *attr |= TSI148_LCSR_DDAT_AMODE_A24;
- break;
- case VME_A32:
- *attr |= TSI148_LCSR_DDAT_AMODE_A32;
- break;
- case VME_A64:
- *attr |= TSI148_LCSR_DDAT_AMODE_A64;
- break;
- case VME_CRCSR:
- *attr |= TSI148_LCSR_DDAT_AMODE_CRCSR;
- break;
- case VME_USER1:
- *attr |= TSI148_LCSR_DDAT_AMODE_USER1;
- break;
- case VME_USER2:
- *attr |= TSI148_LCSR_DDAT_AMODE_USER2;
- break;
- case VME_USER3:
- *attr |= TSI148_LCSR_DDAT_AMODE_USER3;
- break;
- case VME_USER4:
- *attr |= TSI148_LCSR_DDAT_AMODE_USER4;
- break;
- default:
- dev_err(dev, "Invalid address space\n");
- return -EINVAL;
- break;
- }
-
- if (cycle & VME_SUPER)
- *attr |= TSI148_LCSR_DDAT_SUP;
- if (cycle & VME_PROG)
- *attr |= TSI148_LCSR_DDAT_PGM;
-
- return 0;
-}
-
-/*
- * Add a link list descriptor to the list
- */
-static int tsi148_dma_list_add(struct vme_dma_list *list,
- struct vme_dma_attr *src, struct vme_dma_attr *dest, size_t count)
-{
- struct tsi148_dma_entry *entry, *prev;
- u32 address_high, address_low;
- struct vme_dma_pattern *pattern_attr;
- struct vme_dma_pci *pci_attr;
- struct vme_dma_vme *vme_attr;
- dma_addr_t desc_ptr;
- int retval = 0;
- struct vme_bridge *tsi148_bridge;
-
- tsi148_bridge = list->parent->parent;
-
- /* Descriptor must be aligned on 64-bit boundaries */
- entry = kmalloc(sizeof(struct tsi148_dma_entry), GFP_KERNEL);
- if (entry == NULL) {
- dev_err(tsi148_bridge->parent, "Failed to allocate memory for "
- "dma resource structure\n");
- retval = -ENOMEM;
- goto err_mem;
- }
-
- /* Test descriptor alignment */
- if ((unsigned long)&entry->descriptor & 0x7) {
- dev_err(tsi148_bridge->parent, "Descriptor not aligned to 8 "
- "byte boundary as required: %p\n",
- &entry->descriptor);
- retval = -EINVAL;
- goto err_align;
- }
-
- /* Given we are going to fill out the structure, we probably don't
- * need to zero it, but better safe than sorry for now.
- */
- memset(&entry->descriptor, 0, sizeof(struct tsi148_dma_descriptor));
-
- /* Fill out source part */
- switch (src->type) {
- case VME_DMA_PATTERN:
- pattern_attr = src->private;
-
- entry->descriptor.dsal = pattern_attr->pattern;
- entry->descriptor.dsat = TSI148_LCSR_DSAT_TYP_PAT;
- /* Default behaviour is 32 bit pattern */
- if (pattern_attr->type & VME_DMA_PATTERN_BYTE)
- entry->descriptor.dsat |= TSI148_LCSR_DSAT_PSZ;
-
- /* It seems that the default behaviour is to increment */
- if ((pattern_attr->type & VME_DMA_PATTERN_INCREMENT) == 0)
- entry->descriptor.dsat |= TSI148_LCSR_DSAT_NIN;
-
- break;
- case VME_DMA_PCI:
- pci_attr = src->private;
-
- reg_split((unsigned long long)pci_attr->address, &address_high,
- &address_low);
- entry->descriptor.dsau = address_high;
- entry->descriptor.dsal = address_low;
- entry->descriptor.dsat = TSI148_LCSR_DSAT_TYP_PCI;
- break;
- case VME_DMA_VME:
- vme_attr = src->private;
-
- reg_split((unsigned long long)vme_attr->address, &address_high,
- &address_low);
- entry->descriptor.dsau = address_high;
- entry->descriptor.dsal = address_low;
- entry->descriptor.dsat = TSI148_LCSR_DSAT_TYP_VME;
-
- retval = tsi148_dma_set_vme_src_attributes(
- tsi148_bridge->parent, &entry->descriptor.dsat,
- vme_attr->aspace, vme_attr->cycle, vme_attr->dwidth);
- if (retval < 0)
- goto err_source;
- break;
- default:
- dev_err(tsi148_bridge->parent, "Invalid source type\n");
- retval = -EINVAL;
- goto err_source;
- break;
- }
-
- /* Assume last link - this will be over-written by adding another */
- entry->descriptor.dnlau = 0;
- entry->descriptor.dnlal = TSI148_LCSR_DNLAL_LLA;
-
-
- /* Fill out destination part */
- switch (dest->type) {
- case VME_DMA_PCI:
- pci_attr = dest->private;
-
- reg_split((unsigned long long)pci_attr->address, &address_high,
- &address_low);
- entry->descriptor.ddau = address_high;
- entry->descriptor.ddal = address_low;
- entry->descriptor.ddat = TSI148_LCSR_DDAT_TYP_PCI;
- break;
- case VME_DMA_VME:
- vme_attr = dest->private;
-
- reg_split((unsigned long long)vme_attr->address, &address_high,
- &address_low);
- entry->descriptor.ddau = address_high;
- entry->descriptor.ddal = address_low;
- entry->descriptor.ddat = TSI148_LCSR_DDAT_TYP_VME;
-
- retval = tsi148_dma_set_vme_dest_attributes(
- tsi148_bridge->parent, &entry->descriptor.ddat,
- vme_attr->aspace, vme_attr->cycle, vme_attr->dwidth);
- if (retval < 0)
- goto err_dest;
- break;
- default:
- dev_err(tsi148_bridge->parent, "Invalid destination type\n");
- retval = -EINVAL;
- goto err_dest;
- break;
- }
-
- /* Fill out count */
- entry->descriptor.dcnt = (u32)count;
-
- /* Add to list */
- list_add_tail(&entry->list, &list->entries);
-
- /* Fill out previous descriptors "Next Address" */
- if (entry->list.prev != &list->entries) {
- prev = list_entry(entry->list.prev, struct tsi148_dma_entry,
- list);
- /* We need the bus address for the pointer */
- desc_ptr = virt_to_bus(&entry->descriptor);
- reg_split(desc_ptr, &prev->descriptor.dnlau,
- &prev->descriptor.dnlal);
- }
-
- return 0;
-
-err_dest:
-err_source:
-err_align:
- kfree(entry);
-err_mem:
- return retval;
-}
-
-/*
- * Check to see if the provided DMA channel is busy.
- */
-static int tsi148_dma_busy(struct vme_bridge *tsi148_bridge, int channel)
-{
- u32 tmp;
- struct tsi148_driver *bridge;
-
- bridge = tsi148_bridge->driver_priv;
-
- tmp = ioread32be(bridge->base + TSI148_LCSR_DMA[channel] +
- TSI148_LCSR_OFFSET_DSTA);
-
- if (tmp & TSI148_LCSR_DSTA_BSY)
- return 0;
- else
- return 1;
-
-}
-
-/*
- * Execute a previously generated link list
- *
- * XXX Need to provide control register configuration.
- */
-static int tsi148_dma_list_exec(struct vme_dma_list *list)
-{
- struct vme_dma_resource *ctrlr;
- int channel, retval = 0;
- struct tsi148_dma_entry *entry;
- dma_addr_t bus_addr;
- u32 bus_addr_high, bus_addr_low;
- u32 val, dctlreg = 0;
- struct vme_bridge *tsi148_bridge;
- struct tsi148_driver *bridge;
-
- ctrlr = list->parent;
-
- tsi148_bridge = ctrlr->parent;
-
- bridge = tsi148_bridge->driver_priv;
-
- mutex_lock(&ctrlr->mtx);
-
- channel = ctrlr->number;
-
- if (!list_empty(&ctrlr->running)) {
- /*
- * XXX We have an active DMA transfer and currently haven't
- * sorted out the mechanism for "pending" DMA transfers.
- * Return busy.
- */
- /* Need to add to pending here */
- mutex_unlock(&ctrlr->mtx);
- return -EBUSY;
- } else {
- list_add(&list->list, &ctrlr->running);
- }
-
- /* Get first bus address and write into registers */
- entry = list_first_entry(&list->entries, struct tsi148_dma_entry,
- list);
-
- bus_addr = virt_to_bus(&entry->descriptor);
-
- mutex_unlock(&ctrlr->mtx);
-
- reg_split(bus_addr, &bus_addr_high, &bus_addr_low);
-
- iowrite32be(bus_addr_high, bridge->base +
- TSI148_LCSR_DMA[channel] + TSI148_LCSR_OFFSET_DNLAU);
- iowrite32be(bus_addr_low, bridge->base +
- TSI148_LCSR_DMA[channel] + TSI148_LCSR_OFFSET_DNLAL);
-
- /* Start the operation */
- iowrite32be(dctlreg | TSI148_LCSR_DCTL_DGO, bridge->base +
- TSI148_LCSR_DMA[channel] + TSI148_LCSR_OFFSET_DCTL);
-
- wait_event_interruptible(bridge->dma_queue[channel],
- tsi148_dma_busy(ctrlr->parent, channel));
- /*
- * Read status register, this register is valid until we kick off a
- * new transfer.
- */
- val = ioread32be(bridge->base + TSI148_LCSR_DMA[channel] +
- TSI148_LCSR_OFFSET_DSTA);
-
- if (val & TSI148_LCSR_DSTA_VBE) {
- dev_err(tsi148_bridge->parent, "DMA Error. DSTA=%08X\n", val);
- retval = -EIO;
- }
-
- /* Remove list from running list */
- mutex_lock(&ctrlr->mtx);
- list_del(&list->list);
- mutex_unlock(&ctrlr->mtx);
-
- return retval;
-}
-
-/*
- * Clean up a previously generated link list
- *
- * We have a separate function, don't assume that the chain can't be reused.
- */
-static int tsi148_dma_list_empty(struct vme_dma_list *list)
-{
- struct list_head *pos, *temp;
- struct tsi148_dma_entry *entry;
-
- /* detach and free each entry */
- list_for_each_safe(pos, temp, &list->entries) {
- list_del(pos);
- entry = list_entry(pos, struct tsi148_dma_entry, list);
- kfree(entry);
- }
-
- return 0;
-}
-
-/*
- * All 4 location monitors reside at the same base - this is therefore a
- * system wide configuration.
- *
- * This does not enable the LM monitor - that should be done when the first
- * callback is attached and disabled when the last callback is removed.
- */
-static int tsi148_lm_set(struct vme_lm_resource *lm, unsigned long long lm_base,
- u32 aspace, u32 cycle)
-{
- u32 lm_base_high, lm_base_low, lm_ctl = 0;
- int i;
- struct vme_bridge *tsi148_bridge;
- struct tsi148_driver *bridge;
-
- tsi148_bridge = lm->parent;
-
- bridge = tsi148_bridge->driver_priv;
-
- mutex_lock(&lm->mtx);
-
- /* If we already have a callback attached, we can't move it! */
- for (i = 0; i < lm->monitors; i++) {
- if (bridge->lm_callback[i] != NULL) {
- mutex_unlock(&lm->mtx);
- dev_err(tsi148_bridge->parent, "Location monitor "
- "callback attached, can't reset\n");
- return -EBUSY;
- }
- }
-
- switch (aspace) {
- case VME_A16:
- lm_ctl |= TSI148_LCSR_LMAT_AS_A16;
- break;
- case VME_A24:
- lm_ctl |= TSI148_LCSR_LMAT_AS_A24;
- break;
- case VME_A32:
- lm_ctl |= TSI148_LCSR_LMAT_AS_A32;
- break;
- case VME_A64:
- lm_ctl |= TSI148_LCSR_LMAT_AS_A64;
- break;
- default:
- mutex_unlock(&lm->mtx);
- dev_err(tsi148_bridge->parent, "Invalid address space\n");
- return -EINVAL;
- break;
- }
-
- if (cycle & VME_SUPER)
- lm_ctl |= TSI148_LCSR_LMAT_SUPR ;
- if (cycle & VME_USER)
- lm_ctl |= TSI148_LCSR_LMAT_NPRIV;
- if (cycle & VME_PROG)
- lm_ctl |= TSI148_LCSR_LMAT_PGM;
- if (cycle & VME_DATA)
- lm_ctl |= TSI148_LCSR_LMAT_DATA;
-
- reg_split(lm_base, &lm_base_high, &lm_base_low);
-
- iowrite32be(lm_base_high, bridge->base + TSI148_LCSR_LMBAU);
- iowrite32be(lm_base_low, bridge->base + TSI148_LCSR_LMBAL);
- iowrite32be(lm_ctl, bridge->base + TSI148_LCSR_LMAT);
-
- mutex_unlock(&lm->mtx);
-
- return 0;
-}
-
-/* Get configuration of the callback monitor and return whether it is enabled
- * or disabled.
- */
-static int tsi148_lm_get(struct vme_lm_resource *lm,
- unsigned long long *lm_base, u32 *aspace, u32 *cycle)
-{
- u32 lm_base_high, lm_base_low, lm_ctl, enabled = 0;
- struct tsi148_driver *bridge;
-
- bridge = lm->parent->driver_priv;
-
- mutex_lock(&lm->mtx);
-
- lm_base_high = ioread32be(bridge->base + TSI148_LCSR_LMBAU);
- lm_base_low = ioread32be(bridge->base + TSI148_LCSR_LMBAL);
- lm_ctl = ioread32be(bridge->base + TSI148_LCSR_LMAT);
-
- reg_join(lm_base_high, lm_base_low, lm_base);
-
- if (lm_ctl & TSI148_LCSR_LMAT_EN)
- enabled = 1;
-
- if ((lm_ctl & TSI148_LCSR_LMAT_AS_M) == TSI148_LCSR_LMAT_AS_A16)
- *aspace |= VME_A16;
-
- if ((lm_ctl & TSI148_LCSR_LMAT_AS_M) == TSI148_LCSR_LMAT_AS_A24)
- *aspace |= VME_A24;
-
- if ((lm_ctl & TSI148_LCSR_LMAT_AS_M) == TSI148_LCSR_LMAT_AS_A32)
- *aspace |= VME_A32;
-
- if ((lm_ctl & TSI148_LCSR_LMAT_AS_M) == TSI148_LCSR_LMAT_AS_A64)
- *aspace |= VME_A64;
-
-
- if (lm_ctl & TSI148_LCSR_LMAT_SUPR)
- *cycle |= VME_SUPER;
- if (lm_ctl & TSI148_LCSR_LMAT_NPRIV)
- *cycle |= VME_USER;
- if (lm_ctl & TSI148_LCSR_LMAT_PGM)
- *cycle |= VME_PROG;
- if (lm_ctl & TSI148_LCSR_LMAT_DATA)
- *cycle |= VME_DATA;
-
- mutex_unlock(&lm->mtx);
-
- return enabled;
-}
-
-/*
- * Attach a callback to a specific location monitor.
- *
- * Callback will be passed the monitor triggered.
- */
-static int tsi148_lm_attach(struct vme_lm_resource *lm, int monitor,
- void (*callback)(int))
-{
- u32 lm_ctl, tmp;
- struct vme_bridge *tsi148_bridge;
- struct tsi148_driver *bridge;
-
- tsi148_bridge = lm->parent;
-
- bridge = tsi148_bridge->driver_priv;
-
- mutex_lock(&lm->mtx);
-
- /* Ensure that the location monitor is configured - need PGM or DATA */
- lm_ctl = ioread32be(bridge->base + TSI148_LCSR_LMAT);
- if ((lm_ctl & (TSI148_LCSR_LMAT_PGM | TSI148_LCSR_LMAT_DATA)) == 0) {
- mutex_unlock(&lm->mtx);
- dev_err(tsi148_bridge->parent, "Location monitor not properly "
- "configured\n");
- return -EINVAL;
- }
-
- /* Check that a callback isn't already attached */
- if (bridge->lm_callback[monitor] != NULL) {
- mutex_unlock(&lm->mtx);
- dev_err(tsi148_bridge->parent, "Existing callback attached\n");
- return -EBUSY;
- }
-
- /* Attach callback */
- bridge->lm_callback[monitor] = callback;
-
- /* Enable Location Monitor interrupt */
- tmp = ioread32be(bridge->base + TSI148_LCSR_INTEN);
- tmp |= TSI148_LCSR_INTEN_LMEN[monitor];
- iowrite32be(tmp, bridge->base + TSI148_LCSR_INTEN);
-
- tmp = ioread32be(bridge->base + TSI148_LCSR_INTEO);
- tmp |= TSI148_LCSR_INTEO_LMEO[monitor];
- iowrite32be(tmp, bridge->base + TSI148_LCSR_INTEO);
-
- /* Ensure that global Location Monitor Enable set */
- if ((lm_ctl & TSI148_LCSR_LMAT_EN) == 0) {
- lm_ctl |= TSI148_LCSR_LMAT_EN;
- iowrite32be(lm_ctl, bridge->base + TSI148_LCSR_LMAT);
- }
-
- mutex_unlock(&lm->mtx);
-
- return 0;
-}
-
-/*
- * Detach a callback function forn a specific location monitor.
- */
-static int tsi148_lm_detach(struct vme_lm_resource *lm, int monitor)
-{
- u32 lm_en, tmp;
- struct tsi148_driver *bridge;
-
- bridge = lm->parent->driver_priv;
-
- mutex_lock(&lm->mtx);
-
- /* Disable Location Monitor and ensure previous interrupts are clear */
- lm_en = ioread32be(bridge->base + TSI148_LCSR_INTEN);
- lm_en &= ~TSI148_LCSR_INTEN_LMEN[monitor];
- iowrite32be(lm_en, bridge->base + TSI148_LCSR_INTEN);
-
- tmp = ioread32be(bridge->base + TSI148_LCSR_INTEO);
- tmp &= ~TSI148_LCSR_INTEO_LMEO[monitor];
- iowrite32be(tmp, bridge->base + TSI148_LCSR_INTEO);
-
- iowrite32be(TSI148_LCSR_INTC_LMC[monitor],
- bridge->base + TSI148_LCSR_INTC);
-
- /* Detach callback */
- bridge->lm_callback[monitor] = NULL;
-
- /* If all location monitors disabled, disable global Location Monitor */
- if ((lm_en & (TSI148_LCSR_INTS_LM0S | TSI148_LCSR_INTS_LM1S |
- TSI148_LCSR_INTS_LM2S | TSI148_LCSR_INTS_LM3S)) == 0) {
- tmp = ioread32be(bridge->base + TSI148_LCSR_LMAT);
- tmp &= ~TSI148_LCSR_LMAT_EN;
- iowrite32be(tmp, bridge->base + TSI148_LCSR_LMAT);
- }
-
- mutex_unlock(&lm->mtx);
-
- return 0;
-}
-
-/*
- * Determine Geographical Addressing
- */
-static int tsi148_slot_get(struct vme_bridge *tsi148_bridge)
-{
- u32 slot = 0;
- struct tsi148_driver *bridge;
-
- bridge = tsi148_bridge->driver_priv;
-
- if (!geoid) {
- slot = ioread32be(bridge->base + TSI148_LCSR_VSTAT);
- slot = slot & TSI148_LCSR_VSTAT_GA_M;
- } else
- slot = geoid;
-
- return (int)slot;
-}
-
-void *tsi148_alloc_consistent(struct device *parent, size_t size,
- dma_addr_t *dma)
-{
- struct pci_dev *pdev;
-
- /* Find pci_dev container of dev */
- pdev = container_of(parent, struct pci_dev, dev);
-
- return pci_alloc_consistent(pdev, size, dma);
-}
-
-void tsi148_free_consistent(struct device *parent, size_t size, void *vaddr,
- dma_addr_t dma)
-{
- struct pci_dev *pdev;
-
- /* Find pci_dev container of dev */
- pdev = container_of(parent, struct pci_dev, dev);
-
- pci_free_consistent(pdev, size, vaddr, dma);
-}
-
-static int __init tsi148_init(void)
-{
- return pci_register_driver(&tsi148_driver);
-}
-
-/*
- * Configure CR/CSR space
- *
- * Access to the CR/CSR can be configured at power-up. The location of the
- * CR/CSR registers in the CR/CSR address space is determined by the boards
- * Auto-ID or Geographic address. This function ensures that the window is
- * enabled at an offset consistent with the boards geopgraphic address.
- *
- * Each board has a 512kB window, with the highest 4kB being used for the
- * boards registers, this means there is a fix length 508kB window which must
- * be mapped onto PCI memory.
- */
-static int tsi148_crcsr_init(struct vme_bridge *tsi148_bridge,
- struct pci_dev *pdev)
-{
- u32 cbar, crat, vstat;
- u32 crcsr_bus_high, crcsr_bus_low;
- int retval;
- struct tsi148_driver *bridge;
-
- bridge = tsi148_bridge->driver_priv;
-
- /* Allocate mem for CR/CSR image */
- bridge->crcsr_kernel = pci_alloc_consistent(pdev, VME_CRCSR_BUF_SIZE,
- &bridge->crcsr_bus);
- if (bridge->crcsr_kernel == NULL) {
- dev_err(tsi148_bridge->parent, "Failed to allocate memory for "
- "CR/CSR image\n");
- return -ENOMEM;
- }
-
- memset(bridge->crcsr_kernel, 0, VME_CRCSR_BUF_SIZE);
-
- reg_split(bridge->crcsr_bus, &crcsr_bus_high, &crcsr_bus_low);
-
- iowrite32be(crcsr_bus_high, bridge->base + TSI148_LCSR_CROU);
- iowrite32be(crcsr_bus_low, bridge->base + TSI148_LCSR_CROL);
-
- /* Ensure that the CR/CSR is configured at the correct offset */
- cbar = ioread32be(bridge->base + TSI148_CBAR);
- cbar = (cbar & TSI148_CRCSR_CBAR_M)>>3;
-
- vstat = tsi148_slot_get(tsi148_bridge);
-
- if (cbar != vstat) {
- cbar = vstat;
- dev_info(tsi148_bridge->parent, "Setting CR/CSR offset\n");
- iowrite32be(cbar<<3, bridge->base + TSI148_CBAR);
- }
- dev_info(tsi148_bridge->parent, "CR/CSR Offset: %d\n", cbar);
-
- crat = ioread32be(bridge->base + TSI148_LCSR_CRAT);
- if (crat & TSI148_LCSR_CRAT_EN) {
- dev_info(tsi148_bridge->parent, "Enabling CR/CSR space\n");
- iowrite32be(crat | TSI148_LCSR_CRAT_EN,
- bridge->base + TSI148_LCSR_CRAT);
- } else
- dev_info(tsi148_bridge->parent, "CR/CSR already enabled\n");
-
- /* If we want flushed, error-checked writes, set up a window
- * over the CR/CSR registers. We read from here to safely flush
- * through VME writes.
- */
- if (err_chk) {
- retval = tsi148_master_set(bridge->flush_image, 1,
- (vstat * 0x80000), 0x80000, VME_CRCSR, VME_SCT,
- VME_D16);
- if (retval)
- dev_err(tsi148_bridge->parent, "Configuring flush image"
- " failed\n");
- }
-
- return 0;
-
-}
-
-static void tsi148_crcsr_exit(struct vme_bridge *tsi148_bridge,
- struct pci_dev *pdev)
-{
- u32 crat;
- struct tsi148_driver *bridge;
-
- bridge = tsi148_bridge->driver_priv;
-
- /* Turn off CR/CSR space */
- crat = ioread32be(bridge->base + TSI148_LCSR_CRAT);
- iowrite32be(crat & ~TSI148_LCSR_CRAT_EN,
- bridge->base + TSI148_LCSR_CRAT);
-
- /* Free image */
- iowrite32be(0, bridge->base + TSI148_LCSR_CROU);
- iowrite32be(0, bridge->base + TSI148_LCSR_CROL);
-
- pci_free_consistent(pdev, VME_CRCSR_BUF_SIZE, bridge->crcsr_kernel,
- bridge->crcsr_bus);
-}
-
-static int tsi148_probe(struct pci_dev *pdev, const struct pci_device_id *id)
-{
- int retval, i, master_num;
- u32 data;
- struct list_head *pos = NULL;
- struct vme_bridge *tsi148_bridge;
- struct tsi148_driver *tsi148_device;
- struct vme_master_resource *master_image;
- struct vme_slave_resource *slave_image;
- struct vme_dma_resource *dma_ctrlr;
- struct vme_lm_resource *lm;
-
- /* If we want to support more than one of each bridge, we need to
- * dynamically generate this so we get one per device
- */
- tsi148_bridge = kzalloc(sizeof(struct vme_bridge), GFP_KERNEL);
- if (tsi148_bridge == NULL) {
- dev_err(&pdev->dev, "Failed to allocate memory for device "
- "structure\n");
- retval = -ENOMEM;
- goto err_struct;
- }
-
- tsi148_device = kzalloc(sizeof(struct tsi148_driver), GFP_KERNEL);
- if (tsi148_device == NULL) {
- dev_err(&pdev->dev, "Failed to allocate memory for device "
- "structure\n");
- retval = -ENOMEM;
- goto err_driver;
- }
-
- tsi148_bridge->driver_priv = tsi148_device;
-
- /* Enable the device */
- retval = pci_enable_device(pdev);
- if (retval) {
- dev_err(&pdev->dev, "Unable to enable device\n");
- goto err_enable;
- }
-
- /* Map Registers */
- retval = pci_request_regions(pdev, driver_name);
- if (retval) {
- dev_err(&pdev->dev, "Unable to reserve resources\n");
- goto err_resource;
- }
-
- /* map registers in BAR 0 */
- tsi148_device->base = ioremap_nocache(pci_resource_start(pdev, 0),
- 4096);
- if (!tsi148_device->base) {
- dev_err(&pdev->dev, "Unable to remap CRG region\n");
- retval = -EIO;
- goto err_remap;
- }
-
- /* Check to see if the mapping worked out */
- data = ioread32(tsi148_device->base + TSI148_PCFS_ID) & 0x0000FFFF;
- if (data != PCI_VENDOR_ID_TUNDRA) {
- dev_err(&pdev->dev, "CRG region check failed\n");
- retval = -EIO;
- goto err_test;
- }
-
- /* Initialize wait queues & mutual exclusion flags */
- init_waitqueue_head(&tsi148_device->dma_queue[0]);
- init_waitqueue_head(&tsi148_device->dma_queue[1]);
- init_waitqueue_head(&tsi148_device->iack_queue);
- mutex_init(&tsi148_device->vme_int);
- mutex_init(&tsi148_device->vme_rmw);
-
- tsi148_bridge->parent = &pdev->dev;
- strcpy(tsi148_bridge->name, driver_name);
-
- /* Setup IRQ */
- retval = tsi148_irq_init(tsi148_bridge);
- if (retval != 0) {
- dev_err(&pdev->dev, "Chip Initialization failed.\n");
- goto err_irq;
- }
-
- /* If we are going to flush writes, we need to read from the VME bus.
- * We need to do this safely, thus we read the devices own CR/CSR
- * register. To do this we must set up a window in CR/CSR space and
- * hence have one less master window resource available.
- */
- master_num = TSI148_MAX_MASTER;
- if (err_chk) {
- master_num--;
-
- tsi148_device->flush_image =
- kmalloc(sizeof(struct vme_master_resource), GFP_KERNEL);
- if (tsi148_device->flush_image == NULL) {
- dev_err(&pdev->dev, "Failed to allocate memory for "
- "flush resource structure\n");
- retval = -ENOMEM;
- goto err_master;
- }
- tsi148_device->flush_image->parent = tsi148_bridge;
- spin_lock_init(&tsi148_device->flush_image->lock);
- tsi148_device->flush_image->locked = 1;
- tsi148_device->flush_image->number = master_num;
- tsi148_device->flush_image->address_attr = VME_A16 | VME_A24 |
- VME_A32 | VME_A64;
- tsi148_device->flush_image->cycle_attr = VME_SCT | VME_BLT |
- VME_MBLT | VME_2eVME | VME_2eSST | VME_2eSSTB |
- VME_2eSST160 | VME_2eSST267 | VME_2eSST320 | VME_SUPER |
- VME_USER | VME_PROG | VME_DATA;
- tsi148_device->flush_image->width_attr = VME_D16 | VME_D32;
- memset(&tsi148_device->flush_image->bus_resource, 0,
- sizeof(struct resource));
- tsi148_device->flush_image->kern_base = NULL;
- }
-
- /* Add master windows to list */
- INIT_LIST_HEAD(&tsi148_bridge->master_resources);
- for (i = 0; i < master_num; i++) {
- master_image = kmalloc(sizeof(struct vme_master_resource),
- GFP_KERNEL);
- if (master_image == NULL) {
- dev_err(&pdev->dev, "Failed to allocate memory for "
- "master resource structure\n");
- retval = -ENOMEM;
- goto err_master;
- }
- master_image->parent = tsi148_bridge;
- spin_lock_init(&master_image->lock);
- master_image->locked = 0;
- master_image->number = i;
- master_image->address_attr = VME_A16 | VME_A24 | VME_A32 |
- VME_A64;
- master_image->cycle_attr = VME_SCT | VME_BLT | VME_MBLT |
- VME_2eVME | VME_2eSST | VME_2eSSTB | VME_2eSST160 |
- VME_2eSST267 | VME_2eSST320 | VME_SUPER | VME_USER |
- VME_PROG | VME_DATA;
- master_image->width_attr = VME_D16 | VME_D32;
- memset(&master_image->bus_resource, 0,
- sizeof(struct resource));
- master_image->kern_base = NULL;
- list_add_tail(&master_image->list,
- &tsi148_bridge->master_resources);
- }
-
- /* Add slave windows to list */
- INIT_LIST_HEAD(&tsi148_bridge->slave_resources);
- for (i = 0; i < TSI148_MAX_SLAVE; i++) {
- slave_image = kmalloc(sizeof(struct vme_slave_resource),
- GFP_KERNEL);
- if (slave_image == NULL) {
- dev_err(&pdev->dev, "Failed to allocate memory for "
- "slave resource structure\n");
- retval = -ENOMEM;
- goto err_slave;
- }
- slave_image->parent = tsi148_bridge;
- mutex_init(&slave_image->mtx);
- slave_image->locked = 0;
- slave_image->number = i;
- slave_image->address_attr = VME_A16 | VME_A24 | VME_A32 |
- VME_A64 | VME_CRCSR | VME_USER1 | VME_USER2 |
- VME_USER3 | VME_USER4;
- slave_image->cycle_attr = VME_SCT | VME_BLT | VME_MBLT |
- VME_2eVME | VME_2eSST | VME_2eSSTB | VME_2eSST160 |
- VME_2eSST267 | VME_2eSST320 | VME_SUPER | VME_USER |
- VME_PROG | VME_DATA;
- list_add_tail(&slave_image->list,
- &tsi148_bridge->slave_resources);
- }
-
- /* Add dma engines to list */
- INIT_LIST_HEAD(&tsi148_bridge->dma_resources);
- for (i = 0; i < TSI148_MAX_DMA; i++) {
- dma_ctrlr = kmalloc(sizeof(struct vme_dma_resource),
- GFP_KERNEL);
- if (dma_ctrlr == NULL) {
- dev_err(&pdev->dev, "Failed to allocate memory for "
- "dma resource structure\n");
- retval = -ENOMEM;
- goto err_dma;
- }
- dma_ctrlr->parent = tsi148_bridge;
- mutex_init(&dma_ctrlr->mtx);
- dma_ctrlr->locked = 0;
- dma_ctrlr->number = i;
- dma_ctrlr->route_attr = VME_DMA_VME_TO_MEM |
- VME_DMA_MEM_TO_VME | VME_DMA_VME_TO_VME |
- VME_DMA_MEM_TO_MEM | VME_DMA_PATTERN_TO_VME |
- VME_DMA_PATTERN_TO_MEM;
- INIT_LIST_HEAD(&dma_ctrlr->pending);
- INIT_LIST_HEAD(&dma_ctrlr->running);
- list_add_tail(&dma_ctrlr->list,
- &tsi148_bridge->dma_resources);
- }
-
- /* Add location monitor to list */
- INIT_LIST_HEAD(&tsi148_bridge->lm_resources);
- lm = kmalloc(sizeof(struct vme_lm_resource), GFP_KERNEL);
- if (lm == NULL) {
- dev_err(&pdev->dev, "Failed to allocate memory for "
- "location monitor resource structure\n");
- retval = -ENOMEM;
- goto err_lm;
- }
- lm->parent = tsi148_bridge;
- mutex_init(&lm->mtx);
- lm->locked = 0;
- lm->number = 1;
- lm->monitors = 4;
- list_add_tail(&lm->list, &tsi148_bridge->lm_resources);
-
- tsi148_bridge->slave_get = tsi148_slave_get;
- tsi148_bridge->slave_set = tsi148_slave_set;
- tsi148_bridge->master_get = tsi148_master_get;
- tsi148_bridge->master_set = tsi148_master_set;
- tsi148_bridge->master_read = tsi148_master_read;
- tsi148_bridge->master_write = tsi148_master_write;
- tsi148_bridge->master_rmw = tsi148_master_rmw;
- tsi148_bridge->dma_list_add = tsi148_dma_list_add;
- tsi148_bridge->dma_list_exec = tsi148_dma_list_exec;
- tsi148_bridge->dma_list_empty = tsi148_dma_list_empty;
- tsi148_bridge->irq_set = tsi148_irq_set;
- tsi148_bridge->irq_generate = tsi148_irq_generate;
- tsi148_bridge->lm_set = tsi148_lm_set;
- tsi148_bridge->lm_get = tsi148_lm_get;
- tsi148_bridge->lm_attach = tsi148_lm_attach;
- tsi148_bridge->lm_detach = tsi148_lm_detach;
- tsi148_bridge->slot_get = tsi148_slot_get;
- tsi148_bridge->alloc_consistent = tsi148_alloc_consistent;
- tsi148_bridge->free_consistent = tsi148_free_consistent;
-
- data = ioread32be(tsi148_device->base + TSI148_LCSR_VSTAT);
- dev_info(&pdev->dev, "Board is%s the VME system controller\n",
- (data & TSI148_LCSR_VSTAT_SCONS) ? "" : " not");
- if (!geoid)
- dev_info(&pdev->dev, "VME geographical address is %d\n",
- data & TSI148_LCSR_VSTAT_GA_M);
- else
- dev_info(&pdev->dev, "VME geographical address is set to %d\n",
- geoid);
-
- dev_info(&pdev->dev, "VME Write and flush and error check is %s\n",
- err_chk ? "enabled" : "disabled");
-
- if (tsi148_crcsr_init(tsi148_bridge, pdev)) {
- dev_err(&pdev->dev, "CR/CSR configuration failed.\n");
- goto err_crcsr;
- }
-
- retval = vme_register_bridge(tsi148_bridge);
- if (retval != 0) {
- dev_err(&pdev->dev, "Chip Registration failed.\n");
- goto err_reg;
- }
-
- pci_set_drvdata(pdev, tsi148_bridge);
-
- /* Clear VME bus "board fail", and "power-up reset" lines */
- data = ioread32be(tsi148_device->base + TSI148_LCSR_VSTAT);
- data &= ~TSI148_LCSR_VSTAT_BRDFL;
- data |= TSI148_LCSR_VSTAT_CPURST;
- iowrite32be(data, tsi148_device->base + TSI148_LCSR_VSTAT);
-
- return 0;
-
-err_reg:
- tsi148_crcsr_exit(tsi148_bridge, pdev);
-err_crcsr:
-err_lm:
- /* resources are stored in link list */
- list_for_each(pos, &tsi148_bridge->lm_resources) {
- lm = list_entry(pos, struct vme_lm_resource, list);
- list_del(pos);
- kfree(lm);
- }
-err_dma:
- /* resources are stored in link list */
- list_for_each(pos, &tsi148_bridge->dma_resources) {
- dma_ctrlr = list_entry(pos, struct vme_dma_resource, list);
- list_del(pos);
- kfree(dma_ctrlr);
- }
-err_slave:
- /* resources are stored in link list */
- list_for_each(pos, &tsi148_bridge->slave_resources) {
- slave_image = list_entry(pos, struct vme_slave_resource, list);
- list_del(pos);
- kfree(slave_image);
- }
-err_master:
- /* resources are stored in link list */
- list_for_each(pos, &tsi148_bridge->master_resources) {
- master_image = list_entry(pos, struct vme_master_resource,
- list);
- list_del(pos);
- kfree(master_image);
- }
-
- tsi148_irq_exit(tsi148_bridge, pdev);
-err_irq:
-err_test:
- iounmap(tsi148_device->base);
-err_remap:
- pci_release_regions(pdev);
-err_resource:
- pci_disable_device(pdev);
-err_enable:
- kfree(tsi148_device);
-err_driver:
- kfree(tsi148_bridge);
-err_struct:
- return retval;
-
-}
-
-static void tsi148_remove(struct pci_dev *pdev)
-{
- struct list_head *pos = NULL;
- struct list_head *tmplist;
- struct vme_master_resource *master_image;
- struct vme_slave_resource *slave_image;
- struct vme_dma_resource *dma_ctrlr;
- int i;
- struct tsi148_driver *bridge;
- struct vme_bridge *tsi148_bridge = pci_get_drvdata(pdev);
-
- bridge = tsi148_bridge->driver_priv;
-
-
- dev_dbg(&pdev->dev, "Driver is being unloaded.\n");
-
- /*
- * Shutdown all inbound and outbound windows.
- */
- for (i = 0; i < 8; i++) {
- iowrite32be(0, bridge->base + TSI148_LCSR_IT[i] +
- TSI148_LCSR_OFFSET_ITAT);
- iowrite32be(0, bridge->base + TSI148_LCSR_OT[i] +
- TSI148_LCSR_OFFSET_OTAT);
- }
-
- /*
- * Shutdown Location monitor.
- */
- iowrite32be(0, bridge->base + TSI148_LCSR_LMAT);
-
- /*
- * Shutdown CRG map.
- */
- iowrite32be(0, bridge->base + TSI148_LCSR_CSRAT);
-
- /*
- * Clear error status.
- */
- iowrite32be(0xFFFFFFFF, bridge->base + TSI148_LCSR_EDPAT);
- iowrite32be(0xFFFFFFFF, bridge->base + TSI148_LCSR_VEAT);
- iowrite32be(0x07000700, bridge->base + TSI148_LCSR_PSTAT);
-
- /*
- * Remove VIRQ interrupt (if any)
- */
- if (ioread32be(bridge->base + TSI148_LCSR_VICR) & 0x800)
- iowrite32be(0x8000, bridge->base + TSI148_LCSR_VICR);
-
- /*
- * Map all Interrupts to PCI INTA
- */
- iowrite32be(0x0, bridge->base + TSI148_LCSR_INTM1);
- iowrite32be(0x0, bridge->base + TSI148_LCSR_INTM2);
-
- tsi148_irq_exit(tsi148_bridge, pdev);
-
- vme_unregister_bridge(tsi148_bridge);
-
- tsi148_crcsr_exit(tsi148_bridge, pdev);
-
- /* resources are stored in link list */
- list_for_each_safe(pos, tmplist, &tsi148_bridge->dma_resources) {
- dma_ctrlr = list_entry(pos, struct vme_dma_resource, list);
- list_del(pos);
- kfree(dma_ctrlr);
- }
-
- /* resources are stored in link list */
- list_for_each_safe(pos, tmplist, &tsi148_bridge->slave_resources) {
- slave_image = list_entry(pos, struct vme_slave_resource, list);
- list_del(pos);
- kfree(slave_image);
- }
-
- /* resources are stored in link list */
- list_for_each_safe(pos, tmplist, &tsi148_bridge->master_resources) {
- master_image = list_entry(pos, struct vme_master_resource,
- list);
- list_del(pos);
- kfree(master_image);
- }
-
- iounmap(bridge->base);
-
- pci_release_regions(pdev);
-
- pci_disable_device(pdev);
-
- kfree(tsi148_bridge->driver_priv);
-
- kfree(tsi148_bridge);
-}
-
-static void __exit tsi148_exit(void)
-{
- pci_unregister_driver(&tsi148_driver);
-}
-
-MODULE_PARM_DESC(err_chk, "Check for VME errors on reads and writes");
-module_param(err_chk, bool, 0);
-
-MODULE_PARM_DESC(geoid, "Override geographical addressing");
-module_param(geoid, int, 0);
-
-MODULE_DESCRIPTION("VME driver for the Tundra Tempe VME bridge");
-MODULE_LICENSE("GPL");
-
-module_init(tsi148_init);
-module_exit(tsi148_exit);
diff --git a/drivers/staging/vme/bridges/vme_tsi148.h b/drivers/staging/vme/bridges/vme_tsi148.h
deleted file mode 100644
index a3ac2fe98816..000000000000
--- a/drivers/staging/vme/bridges/vme_tsi148.h
+++ /dev/null
@@ -1,1409 +0,0 @@
-/*
- * tsi148.h
- *
- * Support for the Tundra TSI148 VME Bridge chip
- *
- * Author: Tom Armistead
- * Updated and maintained by Ajit Prem
- * Copyright 2004 Motorola 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.
- */
-
-#ifndef TSI148_H
-#define TSI148_H
-
-#ifndef PCI_VENDOR_ID_TUNDRA
-#define PCI_VENDOR_ID_TUNDRA 0x10e3
-#endif
-
-#ifndef PCI_DEVICE_ID_TUNDRA_TSI148
-#define PCI_DEVICE_ID_TUNDRA_TSI148 0x148
-#endif
-
-/*
- * Define the number of each that the Tsi148 supports.
- */
-#define TSI148_MAX_MASTER 8 /* Max Master Windows */
-#define TSI148_MAX_SLAVE 8 /* Max Slave Windows */
-#define TSI148_MAX_DMA 2 /* Max DMA Controllers */
-#define TSI148_MAX_MAILBOX 4 /* Max Mail Box registers */
-#define TSI148_MAX_SEMAPHORE 8 /* Max Semaphores */
-
-/* Structure used to hold driver specific information */
-struct tsi148_driver {
- void __iomem *base; /* Base Address of device registers */
- wait_queue_head_t dma_queue[2];
- wait_queue_head_t iack_queue;
- void (*lm_callback[4])(int); /* Called in interrupt handler */
- void *crcsr_kernel;
- dma_addr_t crcsr_bus;
- struct vme_master_resource *flush_image;
- struct mutex vme_rmw; /* Only one RMW cycle at a time */
- struct mutex vme_int; /*
- * Only one VME interrupt can be
- * generated at a time, provide locking
- */
-};
-
-/*
- * Layout of a DMAC Linked-List Descriptor
- *
- * Note: This structure is accessed via the chip and therefore must be
- * correctly laid out - It must also be aligned on 64-bit boundaries.
- */
-struct tsi148_dma_descriptor {
- u32 dsau; /* Source Address */
- u32 dsal;
- u32 ddau; /* Destination Address */
- u32 ddal;
- u32 dsat; /* Source attributes */
- u32 ddat; /* Destination attributes */
- u32 dnlau; /* Next link address */
- u32 dnlal;
- u32 dcnt; /* Byte count */
- u32 ddbs; /* 2eSST Broadcast select */
-};
-
-struct tsi148_dma_entry {
- /*
- * The descriptor needs to be aligned on a 64-bit boundary, we increase
- * the chance of this by putting it first in the structure.
- */
- struct tsi148_dma_descriptor descriptor;
- struct list_head list;
-};
-
-/*
- * TSI148 ASIC register structure overlays and bit field definitions.
- *
- * Note: Tsi148 Register Group (CRG) consists of the following
- * combination of registers:
- * PCFS - PCI Configuration Space Registers
- * LCSR - Local Control and Status Registers
- * GCSR - Global Control and Status Registers
- * CR/CSR - Subset of Configuration ROM /
- * Control and Status Registers
- */
-
-
-/*
- * Command/Status Registers (CRG + $004)
- */
-#define TSI148_PCFS_ID 0x0
-#define TSI148_PCFS_CSR 0x4
-#define TSI148_PCFS_CLASS 0x8
-#define TSI148_PCFS_MISC0 0xC
-#define TSI148_PCFS_MBARL 0x10
-#define TSI148_PCFS_MBARU 0x14
-
-#define TSI148_PCFS_SUBID 0x28
-
-#define TSI148_PCFS_CAPP 0x34
-
-#define TSI148_PCFS_MISC1 0x3C
-
-#define TSI148_PCFS_XCAPP 0x40
-#define TSI148_PCFS_XSTAT 0x44
-
-/*
- * LCSR definitions
- */
-
-/*
- * Outbound Translations
- */
-#define TSI148_LCSR_OT0_OTSAU 0x100
-#define TSI148_LCSR_OT0_OTSAL 0x104
-#define TSI148_LCSR_OT0_OTEAU 0x108
-#define TSI148_LCSR_OT0_OTEAL 0x10C
-#define TSI148_LCSR_OT0_OTOFU 0x110
-#define TSI148_LCSR_OT0_OTOFL 0x114
-#define TSI148_LCSR_OT0_OTBS 0x118
-#define TSI148_LCSR_OT0_OTAT 0x11C
-
-#define TSI148_LCSR_OT1_OTSAU 0x120
-#define TSI148_LCSR_OT1_OTSAL 0x124
-#define TSI148_LCSR_OT1_OTEAU 0x128
-#define TSI148_LCSR_OT1_OTEAL 0x12C
-#define TSI148_LCSR_OT1_OTOFU 0x130
-#define TSI148_LCSR_OT1_OTOFL 0x134
-#define TSI148_LCSR_OT1_OTBS 0x138
-#define TSI148_LCSR_OT1_OTAT 0x13C
-
-#define TSI148_LCSR_OT2_OTSAU 0x140
-#define TSI148_LCSR_OT2_OTSAL 0x144
-#define TSI148_LCSR_OT2_OTEAU 0x148
-#define TSI148_LCSR_OT2_OTEAL 0x14C
-#define TSI148_LCSR_OT2_OTOFU 0x150
-#define TSI148_LCSR_OT2_OTOFL 0x154
-#define TSI148_LCSR_OT2_OTBS 0x158
-#define TSI148_LCSR_OT2_OTAT 0x15C
-
-#define TSI148_LCSR_OT3_OTSAU 0x160
-#define TSI148_LCSR_OT3_OTSAL 0x164
-#define TSI148_LCSR_OT3_OTEAU 0x168
-#define TSI148_LCSR_OT3_OTEAL 0x16C
-#define TSI148_LCSR_OT3_OTOFU 0x170
-#define TSI148_LCSR_OT3_OTOFL 0x174
-#define TSI148_LCSR_OT3_OTBS 0x178
-#define TSI148_LCSR_OT3_OTAT 0x17C
-
-#define TSI148_LCSR_OT4_OTSAU 0x180
-#define TSI148_LCSR_OT4_OTSAL 0x184
-#define TSI148_LCSR_OT4_OTEAU 0x188
-#define TSI148_LCSR_OT4_OTEAL 0x18C
-#define TSI148_LCSR_OT4_OTOFU 0x190
-#define TSI148_LCSR_OT4_OTOFL 0x194
-#define TSI148_LCSR_OT4_OTBS 0x198
-#define TSI148_LCSR_OT4_OTAT 0x19C
-
-#define TSI148_LCSR_OT5_OTSAU 0x1A0
-#define TSI148_LCSR_OT5_OTSAL 0x1A4
-#define TSI148_LCSR_OT5_OTEAU 0x1A8
-#define TSI148_LCSR_OT5_OTEAL 0x1AC
-#define TSI148_LCSR_OT5_OTOFU 0x1B0
-#define TSI148_LCSR_OT5_OTOFL 0x1B4
-#define TSI148_LCSR_OT5_OTBS 0x1B8
-#define TSI148_LCSR_OT5_OTAT 0x1BC
-
-#define TSI148_LCSR_OT6_OTSAU 0x1C0
-#define TSI148_LCSR_OT6_OTSAL 0x1C4
-#define TSI148_LCSR_OT6_OTEAU 0x1C8
-#define TSI148_LCSR_OT6_OTEAL 0x1CC
-#define TSI148_LCSR_OT6_OTOFU 0x1D0
-#define TSI148_LCSR_OT6_OTOFL 0x1D4
-#define TSI148_LCSR_OT6_OTBS 0x1D8
-#define TSI148_LCSR_OT6_OTAT 0x1DC
-
-#define TSI148_LCSR_OT7_OTSAU 0x1E0
-#define TSI148_LCSR_OT7_OTSAL 0x1E4
-#define TSI148_LCSR_OT7_OTEAU 0x1E8
-#define TSI148_LCSR_OT7_OTEAL 0x1EC
-#define TSI148_LCSR_OT7_OTOFU 0x1F0
-#define TSI148_LCSR_OT7_OTOFL 0x1F4
-#define TSI148_LCSR_OT7_OTBS 0x1F8
-#define TSI148_LCSR_OT7_OTAT 0x1FC
-
-#define TSI148_LCSR_OT0 0x100
-#define TSI148_LCSR_OT1 0x120
-#define TSI148_LCSR_OT2 0x140
-#define TSI148_LCSR_OT3 0x160
-#define TSI148_LCSR_OT4 0x180
-#define TSI148_LCSR_OT5 0x1A0
-#define TSI148_LCSR_OT6 0x1C0
-#define TSI148_LCSR_OT7 0x1E0
-
-static const int TSI148_LCSR_OT[8] = { TSI148_LCSR_OT0, TSI148_LCSR_OT1,
- TSI148_LCSR_OT2, TSI148_LCSR_OT3,
- TSI148_LCSR_OT4, TSI148_LCSR_OT5,
- TSI148_LCSR_OT6, TSI148_LCSR_OT7 };
-
-#define TSI148_LCSR_OFFSET_OTSAU 0x0
-#define TSI148_LCSR_OFFSET_OTSAL 0x4
-#define TSI148_LCSR_OFFSET_OTEAU 0x8
-#define TSI148_LCSR_OFFSET_OTEAL 0xC
-#define TSI148_LCSR_OFFSET_OTOFU 0x10
-#define TSI148_LCSR_OFFSET_OTOFL 0x14
-#define TSI148_LCSR_OFFSET_OTBS 0x18
-#define TSI148_LCSR_OFFSET_OTAT 0x1C
-
-/*
- * VMEbus interrupt ack
- * offset 200
- */
-#define TSI148_LCSR_VIACK1 0x204
-#define TSI148_LCSR_VIACK2 0x208
-#define TSI148_LCSR_VIACK3 0x20C
-#define TSI148_LCSR_VIACK4 0x210
-#define TSI148_LCSR_VIACK5 0x214
-#define TSI148_LCSR_VIACK6 0x218
-#define TSI148_LCSR_VIACK7 0x21C
-
-static const int TSI148_LCSR_VIACK[8] = { 0, TSI148_LCSR_VIACK1,
- TSI148_LCSR_VIACK2, TSI148_LCSR_VIACK3,
- TSI148_LCSR_VIACK4, TSI148_LCSR_VIACK5,
- TSI148_LCSR_VIACK6, TSI148_LCSR_VIACK7 };
-
-/*
- * RMW
- * offset 220
- */
-#define TSI148_LCSR_RMWAU 0x220
-#define TSI148_LCSR_RMWAL 0x224
-#define TSI148_LCSR_RMWEN 0x228
-#define TSI148_LCSR_RMWC 0x22C
-#define TSI148_LCSR_RMWS 0x230
-
-/*
- * VMEbus control
- * offset 234
- */
-#define TSI148_LCSR_VMCTRL 0x234
-#define TSI148_LCSR_VCTRL 0x238
-#define TSI148_LCSR_VSTAT 0x23C
-
-/*
- * PCI status
- * offset 240
- */
-#define TSI148_LCSR_PSTAT 0x240
-
-/*
- * VME filter.
- * offset 250
- */
-#define TSI148_LCSR_VMEFL 0x250
-
- /*
- * VME exception.
- * offset 260
- */
-#define TSI148_LCSR_VEAU 0x260
-#define TSI148_LCSR_VEAL 0x264
-#define TSI148_LCSR_VEAT 0x268
-
- /*
- * PCI error
- * offset 270
- */
-#define TSI148_LCSR_EDPAU 0x270
-#define TSI148_LCSR_EDPAL 0x274
-#define TSI148_LCSR_EDPXA 0x278
-#define TSI148_LCSR_EDPXS 0x27C
-#define TSI148_LCSR_EDPAT 0x280
-
- /*
- * Inbound Translations
- * offset 300
- */
-#define TSI148_LCSR_IT0_ITSAU 0x300
-#define TSI148_LCSR_IT0_ITSAL 0x304
-#define TSI148_LCSR_IT0_ITEAU 0x308
-#define TSI148_LCSR_IT0_ITEAL 0x30C
-#define TSI148_LCSR_IT0_ITOFU 0x310
-#define TSI148_LCSR_IT0_ITOFL 0x314
-#define TSI148_LCSR_IT0_ITAT 0x318
-
-#define TSI148_LCSR_IT1_ITSAU 0x320
-#define TSI148_LCSR_IT1_ITSAL 0x324
-#define TSI148_LCSR_IT1_ITEAU 0x328
-#define TSI148_LCSR_IT1_ITEAL 0x32C
-#define TSI148_LCSR_IT1_ITOFU 0x330
-#define TSI148_LCSR_IT1_ITOFL 0x334
-#define TSI148_LCSR_IT1_ITAT 0x338
-
-#define TSI148_LCSR_IT2_ITSAU 0x340
-#define TSI148_LCSR_IT2_ITSAL 0x344
-#define TSI148_LCSR_IT2_ITEAU 0x348
-#define TSI148_LCSR_IT2_ITEAL 0x34C
-#define TSI148_LCSR_IT2_ITOFU 0x350
-#define TSI148_LCSR_IT2_ITOFL 0x354
-#define TSI148_LCSR_IT2_ITAT 0x358
-
-#define TSI148_LCSR_IT3_ITSAU 0x360
-#define TSI148_LCSR_IT3_ITSAL 0x364
-#define TSI148_LCSR_IT3_ITEAU 0x368
-#define TSI148_LCSR_IT3_ITEAL 0x36C
-#define TSI148_LCSR_IT3_ITOFU 0x370
-#define TSI148_LCSR_IT3_ITOFL 0x374
-#define TSI148_LCSR_IT3_ITAT 0x378
-
-#define TSI148_LCSR_IT4_ITSAU 0x380
-#define TSI148_LCSR_IT4_ITSAL 0x384
-#define TSI148_LCSR_IT4_ITEAU 0x388
-#define TSI148_LCSR_IT4_ITEAL 0x38C
-#define TSI148_LCSR_IT4_ITOFU 0x390
-#define TSI148_LCSR_IT4_ITOFL 0x394
-#define TSI148_LCSR_IT4_ITAT 0x398
-
-#define TSI148_LCSR_IT5_ITSAU 0x3A0
-#define TSI148_LCSR_IT5_ITSAL 0x3A4
-#define TSI148_LCSR_IT5_ITEAU 0x3A8
-#define TSI148_LCSR_IT5_ITEAL 0x3AC
-#define TSI148_LCSR_IT5_ITOFU 0x3B0
-#define TSI148_LCSR_IT5_ITOFL 0x3B4
-#define TSI148_LCSR_IT5_ITAT 0x3B8
-
-#define TSI148_LCSR_IT6_ITSAU 0x3C0
-#define TSI148_LCSR_IT6_ITSAL 0x3C4
-#define TSI148_LCSR_IT6_ITEAU 0x3C8
-#define TSI148_LCSR_IT6_ITEAL 0x3CC
-#define TSI148_LCSR_IT6_ITOFU 0x3D0
-#define TSI148_LCSR_IT6_ITOFL 0x3D4
-#define TSI148_LCSR_IT6_ITAT 0x3D8
-
-#define TSI148_LCSR_IT7_ITSAU 0x3E0
-#define TSI148_LCSR_IT7_ITSAL 0x3E4
-#define TSI148_LCSR_IT7_ITEAU 0x3E8
-#define TSI148_LCSR_IT7_ITEAL 0x3EC
-#define TSI148_LCSR_IT7_ITOFU 0x3F0
-#define TSI148_LCSR_IT7_ITOFL 0x3F4
-#define TSI148_LCSR_IT7_ITAT 0x3F8
-
-
-#define TSI148_LCSR_IT0 0x300
-#define TSI148_LCSR_IT1 0x320
-#define TSI148_LCSR_IT2 0x340
-#define TSI148_LCSR_IT3 0x360
-#define TSI148_LCSR_IT4 0x380
-#define TSI148_LCSR_IT5 0x3A0
-#define TSI148_LCSR_IT6 0x3C0
-#define TSI148_LCSR_IT7 0x3E0
-
-static const int TSI148_LCSR_IT[8] = { TSI148_LCSR_IT0, TSI148_LCSR_IT1,
- TSI148_LCSR_IT2, TSI148_LCSR_IT3,
- TSI148_LCSR_IT4, TSI148_LCSR_IT5,
- TSI148_LCSR_IT6, TSI148_LCSR_IT7 };
-
-#define TSI148_LCSR_OFFSET_ITSAU 0x0
-#define TSI148_LCSR_OFFSET_ITSAL 0x4
-#define TSI148_LCSR_OFFSET_ITEAU 0x8
-#define TSI148_LCSR_OFFSET_ITEAL 0xC
-#define TSI148_LCSR_OFFSET_ITOFU 0x10
-#define TSI148_LCSR_OFFSET_ITOFL 0x14
-#define TSI148_LCSR_OFFSET_ITAT 0x18
-
- /*
- * Inbound Translation GCSR
- * offset 400
- */
-#define TSI148_LCSR_GBAU 0x400
-#define TSI148_LCSR_GBAL 0x404
-#define TSI148_LCSR_GCSRAT 0x408
-
- /*
- * Inbound Translation CRG
- * offset 40C
- */
-#define TSI148_LCSR_CBAU 0x40C
-#define TSI148_LCSR_CBAL 0x410
-#define TSI148_LCSR_CSRAT 0x414
-
- /*
- * Inbound Translation CR/CSR
- * CRG
- * offset 418
- */
-#define TSI148_LCSR_CROU 0x418
-#define TSI148_LCSR_CROL 0x41C
-#define TSI148_LCSR_CRAT 0x420
-
- /*
- * Inbound Translation Location Monitor
- * offset 424
- */
-#define TSI148_LCSR_LMBAU 0x424
-#define TSI148_LCSR_LMBAL 0x428
-#define TSI148_LCSR_LMAT 0x42C
-
- /*
- * VMEbus Interrupt Control.
- * offset 430
- */
-#define TSI148_LCSR_BCU 0x430
-#define TSI148_LCSR_BCL 0x434
-#define TSI148_LCSR_BPGTR 0x438
-#define TSI148_LCSR_BPCTR 0x43C
-#define TSI148_LCSR_VICR 0x440
-
- /*
- * Local Bus Interrupt Control.
- * offset 448
- */
-#define TSI148_LCSR_INTEN 0x448
-#define TSI148_LCSR_INTEO 0x44C
-#define TSI148_LCSR_INTS 0x450
-#define TSI148_LCSR_INTC 0x454
-#define TSI148_LCSR_INTM1 0x458
-#define TSI148_LCSR_INTM2 0x45C
-
- /*
- * DMA Controllers
- * offset 500
- */
-#define TSI148_LCSR_DCTL0 0x500
-#define TSI148_LCSR_DSTA0 0x504
-#define TSI148_LCSR_DCSAU0 0x508
-#define TSI148_LCSR_DCSAL0 0x50C
-#define TSI148_LCSR_DCDAU0 0x510
-#define TSI148_LCSR_DCDAL0 0x514
-#define TSI148_LCSR_DCLAU0 0x518
-#define TSI148_LCSR_DCLAL0 0x51C
-#define TSI148_LCSR_DSAU0 0x520
-#define TSI148_LCSR_DSAL0 0x524
-#define TSI148_LCSR_DDAU0 0x528
-#define TSI148_LCSR_DDAL0 0x52C
-#define TSI148_LCSR_DSAT0 0x530
-#define TSI148_LCSR_DDAT0 0x534
-#define TSI148_LCSR_DNLAU0 0x538
-#define TSI148_LCSR_DNLAL0 0x53C
-#define TSI148_LCSR_DCNT0 0x540
-#define TSI148_LCSR_DDBS0 0x544
-
-#define TSI148_LCSR_DCTL1 0x580
-#define TSI148_LCSR_DSTA1 0x584
-#define TSI148_LCSR_DCSAU1 0x588
-#define TSI148_LCSR_DCSAL1 0x58C
-#define TSI148_LCSR_DCDAU1 0x590
-#define TSI148_LCSR_DCDAL1 0x594
-#define TSI148_LCSR_DCLAU1 0x598
-#define TSI148_LCSR_DCLAL1 0x59C
-#define TSI148_LCSR_DSAU1 0x5A0
-#define TSI148_LCSR_DSAL1 0x5A4
-#define TSI148_LCSR_DDAU1 0x5A8
-#define TSI148_LCSR_DDAL1 0x5AC
-#define TSI148_LCSR_DSAT1 0x5B0
-#define TSI148_LCSR_DDAT1 0x5B4
-#define TSI148_LCSR_DNLAU1 0x5B8
-#define TSI148_LCSR_DNLAL1 0x5BC
-#define TSI148_LCSR_DCNT1 0x5C0
-#define TSI148_LCSR_DDBS1 0x5C4
-
-#define TSI148_LCSR_DMA0 0x500
-#define TSI148_LCSR_DMA1 0x580
-
-
-static const int TSI148_LCSR_DMA[TSI148_MAX_DMA] = { TSI148_LCSR_DMA0,
- TSI148_LCSR_DMA1 };
-
-#define TSI148_LCSR_OFFSET_DCTL 0x0
-#define TSI148_LCSR_OFFSET_DSTA 0x4
-#define TSI148_LCSR_OFFSET_DCSAU 0x8
-#define TSI148_LCSR_OFFSET_DCSAL 0xC
-#define TSI148_LCSR_OFFSET_DCDAU 0x10
-#define TSI148_LCSR_OFFSET_DCDAL 0x14
-#define TSI148_LCSR_OFFSET_DCLAU 0x18
-#define TSI148_LCSR_OFFSET_DCLAL 0x1C
-#define TSI148_LCSR_OFFSET_DSAU 0x20
-#define TSI148_LCSR_OFFSET_DSAL 0x24
-#define TSI148_LCSR_OFFSET_DDAU 0x28
-#define TSI148_LCSR_OFFSET_DDAL 0x2C
-#define TSI148_LCSR_OFFSET_DSAT 0x30
-#define TSI148_LCSR_OFFSET_DDAT 0x34
-#define TSI148_LCSR_OFFSET_DNLAU 0x38
-#define TSI148_LCSR_OFFSET_DNLAL 0x3C
-#define TSI148_LCSR_OFFSET_DCNT 0x40
-#define TSI148_LCSR_OFFSET_DDBS 0x44
-
- /*
- * GCSR Register Group
- */
-
- /*
- * GCSR CRG
- * offset 00 600 - DEVI/VENI
- * offset 04 604 - CTRL/GA/REVID
- * offset 08 608 - Semaphore3/2/1/0
- * offset 0C 60C - Seamphore7/6/5/4
- */
-#define TSI148_GCSR_ID 0x600
-#define TSI148_GCSR_CSR 0x604
-#define TSI148_GCSR_SEMA0 0x608
-#define TSI148_GCSR_SEMA1 0x60C
-
- /*
- * Mail Box
- * GCSR CRG
- * offset 10 610 - Mailbox0
- */
-#define TSI148_GCSR_MBOX0 0x610
-#define TSI148_GCSR_MBOX1 0x614
-#define TSI148_GCSR_MBOX2 0x618
-#define TSI148_GCSR_MBOX3 0x61C
-
-static const int TSI148_GCSR_MBOX[4] = { TSI148_GCSR_MBOX0,
- TSI148_GCSR_MBOX1,
- TSI148_GCSR_MBOX2,
- TSI148_GCSR_MBOX3 };
-
- /*
- * CR/CSR
- */
-
- /*
- * CR/CSR CRG
- * offset 7FFF4 FF4 - CSRBCR
- * offset 7FFF8 FF8 - CSRBSR
- * offset 7FFFC FFC - CBAR
- */
-#define TSI148_CSRBCR 0xFF4
-#define TSI148_CSRBSR 0xFF8
-#define TSI148_CBAR 0xFFC
-
-
-
-
- /*
- * TSI148 Register Bit Definitions
- */
-
- /*
- * PFCS Register Set
- */
-#define TSI148_PCFS_CMMD_SERR (1<<8) /* SERR_L out pin ssys err */
-#define TSI148_PCFS_CMMD_PERR (1<<6) /* PERR_L out pin parity */
-#define TSI148_PCFS_CMMD_MSTR (1<<2) /* PCI bus master */
-#define TSI148_PCFS_CMMD_MEMSP (1<<1) /* PCI mem space access */
-#define TSI148_PCFS_CMMD_IOSP (1<<0) /* PCI I/O space enable */
-
-#define TSI148_PCFS_STAT_RCPVE (1<<15) /* Detected Parity Error */
-#define TSI148_PCFS_STAT_SIGSE (1<<14) /* Signalled System Error */
-#define TSI148_PCFS_STAT_RCVMA (1<<13) /* Received Master Abort */
-#define TSI148_PCFS_STAT_RCVTA (1<<12) /* Received Target Abort */
-#define TSI148_PCFS_STAT_SIGTA (1<<11) /* Signalled Target Abort */
-#define TSI148_PCFS_STAT_SELTIM (3<<9) /* DELSEL Timing */
-#define TSI148_PCFS_STAT_DPAR (1<<8) /* Data Parity Err Reported */
-#define TSI148_PCFS_STAT_FAST (1<<7) /* Fast back-to-back Cap */
-#define TSI148_PCFS_STAT_P66M (1<<5) /* 66 MHz Capable */
-#define TSI148_PCFS_STAT_CAPL (1<<4) /* Capab List - address $34 */
-
-/*
- * Revision ID/Class Code Registers (CRG +$008)
- */
-#define TSI148_PCFS_CLAS_M (0xFF<<24) /* Class ID */
-#define TSI148_PCFS_SUBCLAS_M (0xFF<<16) /* Sub-Class ID */
-#define TSI148_PCFS_PROGIF_M (0xFF<<8) /* Sub-Class ID */
-#define TSI148_PCFS_REVID_M (0xFF<<0) /* Rev ID */
-
-/*
- * Cache Line Size/ Master Latency Timer/ Header Type Registers (CRG + $00C)
- */
-#define TSI148_PCFS_HEAD_M (0xFF<<16) /* Master Lat Timer */
-#define TSI148_PCFS_MLAT_M (0xFF<<8) /* Master Lat Timer */
-#define TSI148_PCFS_CLSZ_M (0xFF<<0) /* Cache Line Size */
-
-/*
- * Memory Base Address Lower Reg (CRG + $010)
- */
-#define TSI148_PCFS_MBARL_BASEL_M (0xFFFFF<<12) /* Base Addr Lower Mask */
-#define TSI148_PCFS_MBARL_PRE (1<<3) /* Prefetch */
-#define TSI148_PCFS_MBARL_MTYPE_M (3<<1) /* Memory Type Mask */
-#define TSI148_PCFS_MBARL_IOMEM (1<<0) /* I/O Space Indicator */
-
-/*
- * Message Signaled Interrupt Capabilities Register (CRG + $040)
- */
-#define TSI148_PCFS_MSICAP_64BAC (1<<7) /* 64-bit Address Capable */
-#define TSI148_PCFS_MSICAP_MME_M (7<<4) /* Multiple Msg Enable Mask */
-#define TSI148_PCFS_MSICAP_MMC_M (7<<1) /* Multiple Msg Capable Mask */
-#define TSI148_PCFS_MSICAP_MSIEN (1<<0) /* Msg signaled INT Enable */
-
-/*
- * Message Address Lower Register (CRG +$044)
- */
-#define TSI148_PCFS_MSIAL_M (0x3FFFFFFF<<2) /* Mask */
-
-/*
- * Message Data Register (CRG + 4C)
- */
-#define TSI148_PCFS_MSIMD_M (0xFFFF<<0) /* Mask */
-
-/*
- * PCI-X Capabilities Register (CRG + $050)
- */
-#define TSI148_PCFS_PCIXCAP_MOST_M (7<<4) /* Max outstanding Split Tran */
-#define TSI148_PCFS_PCIXCAP_MMRBC_M (3<<2) /* Max Mem Read byte cnt */
-#define TSI148_PCFS_PCIXCAP_ERO (1<<1) /* Enable Relaxed Ordering */
-#define TSI148_PCFS_PCIXCAP_DPERE (1<<0) /* Data Parity Recover Enable */
-
-/*
- * PCI-X Status Register (CRG +$054)
- */
-#define TSI148_PCFS_PCIXSTAT_RSCEM (1<<29) /* Received Split Comp Error */
-#define TSI148_PCFS_PCIXSTAT_DMCRS_M (7<<26) /* max Cumulative Read Size */
-#define TSI148_PCFS_PCIXSTAT_DMOST_M (7<<23) /* max outstanding Split Trans
- */
-#define TSI148_PCFS_PCIXSTAT_DMMRC_M (3<<21) /* max mem read byte count */
-#define TSI148_PCFS_PCIXSTAT_DC (1<<20) /* Device Complexity */
-#define TSI148_PCFS_PCIXSTAT_USC (1<<19) /* Unexpected Split comp */
-#define TSI148_PCFS_PCIXSTAT_SCD (1<<18) /* Split completion discard */
-#define TSI148_PCFS_PCIXSTAT_133C (1<<17) /* 133MHz capable */
-#define TSI148_PCFS_PCIXSTAT_64D (1<<16) /* 64 bit device */
-#define TSI148_PCFS_PCIXSTAT_BN_M (0xFF<<8) /* Bus number */
-#define TSI148_PCFS_PCIXSTAT_DN_M (0x1F<<3) /* Device number */
-#define TSI148_PCFS_PCIXSTAT_FN_M (7<<0) /* Function Number */
-
-/*
- * LCSR Registers
- */
-
-/*
- * Outbound Translation Starting Address Lower
- */
-#define TSI148_LCSR_OTSAL_M (0xFFFF<<16) /* Mask */
-
-/*
- * Outbound Translation Ending Address Lower
- */
-#define TSI148_LCSR_OTEAL_M (0xFFFF<<16) /* Mask */
-
-/*
- * Outbound Translation Offset Lower
- */
-#define TSI148_LCSR_OTOFFL_M (0xFFFF<<16) /* Mask */
-
-/*
- * Outbound Translation 2eSST Broadcast Select
- */
-#define TSI148_LCSR_OTBS_M (0xFFFFF<<0) /* Mask */
-
-/*
- * Outbound Translation Attribute
- */
-#define TSI148_LCSR_OTAT_EN (1<<31) /* Window Enable */
-#define TSI148_LCSR_OTAT_MRPFD (1<<18) /* Prefetch Disable */
-
-#define TSI148_LCSR_OTAT_PFS_M (3<<16) /* Prefetch Size Mask */
-#define TSI148_LCSR_OTAT_PFS_2 (0<<16) /* 2 Cache Lines P Size */
-#define TSI148_LCSR_OTAT_PFS_4 (1<<16) /* 4 Cache Lines P Size */
-#define TSI148_LCSR_OTAT_PFS_8 (2<<16) /* 8 Cache Lines P Size */
-#define TSI148_LCSR_OTAT_PFS_16 (3<<16) /* 16 Cache Lines P Size */
-
-#define TSI148_LCSR_OTAT_2eSSTM_M (7<<11) /* 2eSST Xfer Rate Mask */
-#define TSI148_LCSR_OTAT_2eSSTM_160 (0<<11) /* 160MB/s 2eSST Xfer Rate */
-#define TSI148_LCSR_OTAT_2eSSTM_267 (1<<11) /* 267MB/s 2eSST Xfer Rate */
-#define TSI148_LCSR_OTAT_2eSSTM_320 (2<<11) /* 320MB/s 2eSST Xfer Rate */
-
-#define TSI148_LCSR_OTAT_TM_M (7<<8) /* Xfer Protocol Mask */
-#define TSI148_LCSR_OTAT_TM_SCT (0<<8) /* SCT Xfer Protocol */
-#define TSI148_LCSR_OTAT_TM_BLT (1<<8) /* BLT Xfer Protocol */
-#define TSI148_LCSR_OTAT_TM_MBLT (2<<8) /* MBLT Xfer Protocol */
-#define TSI148_LCSR_OTAT_TM_2eVME (3<<8) /* 2eVME Xfer Protocol */
-#define TSI148_LCSR_OTAT_TM_2eSST (4<<8) /* 2eSST Xfer Protocol */
-#define TSI148_LCSR_OTAT_TM_2eSSTB (5<<8) /* 2eSST Bcast Xfer Protocol */
-
-#define TSI148_LCSR_OTAT_DBW_M (3<<6) /* Max Data Width */
-#define TSI148_LCSR_OTAT_DBW_16 (0<<6) /* 16-bit Data Width */
-#define TSI148_LCSR_OTAT_DBW_32 (1<<6) /* 32-bit Data Width */
-
-#define TSI148_LCSR_OTAT_SUP (1<<5) /* Supervisory Access */
-#define TSI148_LCSR_OTAT_PGM (1<<4) /* Program Access */
-
-#define TSI148_LCSR_OTAT_AMODE_M (0xf<<0) /* Address Mode Mask */
-#define TSI148_LCSR_OTAT_AMODE_A16 (0<<0) /* A16 Address Space */
-#define TSI148_LCSR_OTAT_AMODE_A24 (1<<0) /* A24 Address Space */
-#define TSI148_LCSR_OTAT_AMODE_A32 (2<<0) /* A32 Address Space */
-#define TSI148_LCSR_OTAT_AMODE_A64 (4<<0) /* A32 Address Space */
-#define TSI148_LCSR_OTAT_AMODE_CRCSR (5<<0) /* CR/CSR Address Space */
-#define TSI148_LCSR_OTAT_AMODE_USER1 (8<<0) /* User1 Address Space */
-#define TSI148_LCSR_OTAT_AMODE_USER2 (9<<0) /* User2 Address Space */
-#define TSI148_LCSR_OTAT_AMODE_USER3 (10<<0) /* User3 Address Space */
-#define TSI148_LCSR_OTAT_AMODE_USER4 (11<<0) /* User4 Address Space */
-
-/*
- * VME Master Control Register CRG+$234
- */
-#define TSI148_LCSR_VMCTRL_VSA (1<<27) /* VMEbus Stop Ack */
-#define TSI148_LCSR_VMCTRL_VS (1<<26) /* VMEbus Stop */
-#define TSI148_LCSR_VMCTRL_DHB (1<<25) /* Device Has Bus */
-#define TSI148_LCSR_VMCTRL_DWB (1<<24) /* Device Wants Bus */
-
-#define TSI148_LCSR_VMCTRL_RMWEN (1<<20) /* RMW Enable */
-
-#define TSI148_LCSR_VMCTRL_ATO_M (7<<16) /* Master Access Time-out Mask
- */
-#define TSI148_LCSR_VMCTRL_ATO_32 (0<<16) /* 32 us */
-#define TSI148_LCSR_VMCTRL_ATO_128 (1<<16) /* 128 us */
-#define TSI148_LCSR_VMCTRL_ATO_512 (2<<16) /* 512 us */
-#define TSI148_LCSR_VMCTRL_ATO_2M (3<<16) /* 2 ms */
-#define TSI148_LCSR_VMCTRL_ATO_8M (4<<16) /* 8 ms */
-#define TSI148_LCSR_VMCTRL_ATO_32M (5<<16) /* 32 ms */
-#define TSI148_LCSR_VMCTRL_ATO_128M (6<<16) /* 128 ms */
-#define TSI148_LCSR_VMCTRL_ATO_DIS (7<<16) /* Disabled */
-
-#define TSI148_LCSR_VMCTRL_VTOFF_M (7<<12) /* VMEbus Master Time off */
-#define TSI148_LCSR_VMCTRL_VTOFF_0 (0<<12) /* 0us */
-#define TSI148_LCSR_VMCTRL_VTOFF_1 (1<<12) /* 1us */
-#define TSI148_LCSR_VMCTRL_VTOFF_2 (2<<12) /* 2us */
-#define TSI148_LCSR_VMCTRL_VTOFF_4 (3<<12) /* 4us */
-#define TSI148_LCSR_VMCTRL_VTOFF_8 (4<<12) /* 8us */
-#define TSI148_LCSR_VMCTRL_VTOFF_16 (5<<12) /* 16us */
-#define TSI148_LCSR_VMCTRL_VTOFF_32 (6<<12) /* 32us */
-#define TSI148_LCSR_VMCTRL_VTOFF_64 (7<<12) /* 64us */
-
-#define TSI148_LCSR_VMCTRL_VTON_M (7<<8) /* VMEbus Master Time On */
-#define TSI148_LCSR_VMCTRL_VTON_4 (0<<8) /* 8us */
-#define TSI148_LCSR_VMCTRL_VTON_8 (1<<8) /* 8us */
-#define TSI148_LCSR_VMCTRL_VTON_16 (2<<8) /* 16us */
-#define TSI148_LCSR_VMCTRL_VTON_32 (3<<8) /* 32us */
-#define TSI148_LCSR_VMCTRL_VTON_64 (4<<8) /* 64us */
-#define TSI148_LCSR_VMCTRL_VTON_128 (5<<8) /* 128us */
-#define TSI148_LCSR_VMCTRL_VTON_256 (6<<8) /* 256us */
-#define TSI148_LCSR_VMCTRL_VTON_512 (7<<8) /* 512us */
-
-#define TSI148_LCSR_VMCTRL_VREL_M (3<<3) /* VMEbus Master Rel Mode Mask
- */
-#define TSI148_LCSR_VMCTRL_VREL_T_D (0<<3) /* Time on or Done */
-#define TSI148_LCSR_VMCTRL_VREL_T_R_D (1<<3) /* Time on and REQ or Done */
-#define TSI148_LCSR_VMCTRL_VREL_T_B_D (2<<3) /* Time on and BCLR or Done */
-#define TSI148_LCSR_VMCTRL_VREL_T_D_R (3<<3) /* Time on or Done and REQ */
-
-#define TSI148_LCSR_VMCTRL_VFAIR (1<<2) /* VMEbus Master Fair Mode */
-#define TSI148_LCSR_VMCTRL_VREQL_M (3<<0) /* VMEbus Master Req Level Mask
- */
-
-/*
- * VMEbus Control Register CRG+$238
- */
-#define TSI148_LCSR_VCTRL_LRE (1<<31) /* Late Retry Enable */
-
-#define TSI148_LCSR_VCTRL_DLT_M (0xF<<24) /* Deadlock Timer */
-#define TSI148_LCSR_VCTRL_DLT_OFF (0<<24) /* Deadlock Timer Off */
-#define TSI148_LCSR_VCTRL_DLT_16 (1<<24) /* 16 VCLKS */
-#define TSI148_LCSR_VCTRL_DLT_32 (2<<24) /* 32 VCLKS */
-#define TSI148_LCSR_VCTRL_DLT_64 (3<<24) /* 64 VCLKS */
-#define TSI148_LCSR_VCTRL_DLT_128 (4<<24) /* 128 VCLKS */
-#define TSI148_LCSR_VCTRL_DLT_256 (5<<24) /* 256 VCLKS */
-#define TSI148_LCSR_VCTRL_DLT_512 (6<<24) /* 512 VCLKS */
-#define TSI148_LCSR_VCTRL_DLT_1024 (7<<24) /* 1024 VCLKS */
-#define TSI148_LCSR_VCTRL_DLT_2048 (8<<24) /* 2048 VCLKS */
-#define TSI148_LCSR_VCTRL_DLT_4096 (9<<24) /* 4096 VCLKS */
-#define TSI148_LCSR_VCTRL_DLT_8192 (0xA<<24) /* 8192 VCLKS */
-#define TSI148_LCSR_VCTRL_DLT_16384 (0xB<<24) /* 16384 VCLKS */
-#define TSI148_LCSR_VCTRL_DLT_32768 (0xC<<24) /* 32768 VCLKS */
-
-#define TSI148_LCSR_VCTRL_NERBB (1<<20) /* No Early Release of Bus Busy
- */
-
-#define TSI148_LCSR_VCTRL_SRESET (1<<17) /* System Reset */
-#define TSI148_LCSR_VCTRL_LRESET (1<<16) /* Local Reset */
-
-#define TSI148_LCSR_VCTRL_SFAILAI (1<<15) /* SYSFAIL Auto Slot ID */
-#define TSI148_LCSR_VCTRL_BID_M (0x1F<<8) /* Broadcast ID Mask */
-
-#define TSI148_LCSR_VCTRL_ATOEN (1<<7) /* Arbiter Time-out Enable */
-#define TSI148_LCSR_VCTRL_ROBIN (1<<6) /* VMEbus Round Robin */
-
-#define TSI148_LCSR_VCTRL_GTO_M (7<<0) /* VMEbus Global Time-out Mask
- */
-#define TSI148_LCSR_VCTRL_GTO_8 (0<<0) /* 8 us */
-#define TSI148_LCSR_VCTRL_GTO_16 (1<<0) /* 16 us */
-#define TSI148_LCSR_VCTRL_GTO_32 (2<<0) /* 32 us */
-#define TSI148_LCSR_VCTRL_GTO_64 (3<<0) /* 64 us */
-#define TSI148_LCSR_VCTRL_GTO_128 (4<<0) /* 128 us */
-#define TSI148_LCSR_VCTRL_GTO_256 (5<<0) /* 256 us */
-#define TSI148_LCSR_VCTRL_GTO_512 (6<<0) /* 512 us */
-#define TSI148_LCSR_VCTRL_GTO_DIS (7<<0) /* Disabled */
-
-/*
- * VMEbus Status Register CRG + $23C
- */
-#define TSI148_LCSR_VSTAT_CPURST (1<<15) /* Clear power up reset */
-#define TSI148_LCSR_VSTAT_BRDFL (1<<14) /* Board fail */
-#define TSI148_LCSR_VSTAT_PURSTS (1<<12) /* Power up reset status */
-#define TSI148_LCSR_VSTAT_BDFAILS (1<<11) /* Board Fail Status */
-#define TSI148_LCSR_VSTAT_SYSFAILS (1<<10) /* System Fail Status */
-#define TSI148_LCSR_VSTAT_ACFAILS (1<<9) /* AC fail status */
-#define TSI148_LCSR_VSTAT_SCONS (1<<8) /* System Cont Status */
-#define TSI148_LCSR_VSTAT_GAP (1<<5) /* Geographic Addr Parity */
-#define TSI148_LCSR_VSTAT_GA_M (0x1F<<0) /* Geographic Addr Mask */
-
-/*
- * PCI Configuration Status Register CRG+$240
- */
-#define TSI148_LCSR_PSTAT_REQ64S (1<<6) /* Request 64 status set */
-#define TSI148_LCSR_PSTAT_M66ENS (1<<5) /* M66ENS 66Mhz enable */
-#define TSI148_LCSR_PSTAT_FRAMES (1<<4) /* Frame Status */
-#define TSI148_LCSR_PSTAT_IRDYS (1<<3) /* IRDY status */
-#define TSI148_LCSR_PSTAT_DEVSELS (1<<2) /* DEVL status */
-#define TSI148_LCSR_PSTAT_STOPS (1<<1) /* STOP status */
-#define TSI148_LCSR_PSTAT_TRDYS (1<<0) /* TRDY status */
-
-/*
- * VMEbus Exception Attributes Register CRG + $268
- */
-#define TSI148_LCSR_VEAT_VES (1<<31) /* Status */
-#define TSI148_LCSR_VEAT_VEOF (1<<30) /* Overflow */
-#define TSI148_LCSR_VEAT_VESCL (1<<29) /* Status Clear */
-#define TSI148_LCSR_VEAT_2EOT (1<<21) /* 2e Odd Termination */
-#define TSI148_LCSR_VEAT_2EST (1<<20) /* 2e Slave terminated */
-#define TSI148_LCSR_VEAT_BERR (1<<19) /* Bus Error */
-#define TSI148_LCSR_VEAT_LWORD (1<<18) /* LWORD_ signal state */
-#define TSI148_LCSR_VEAT_WRITE (1<<17) /* WRITE_ signal state */
-#define TSI148_LCSR_VEAT_IACK (1<<16) /* IACK_ signal state */
-#define TSI148_LCSR_VEAT_DS1 (1<<15) /* DS1_ signal state */
-#define TSI148_LCSR_VEAT_DS0 (1<<14) /* DS0_ signal state */
-#define TSI148_LCSR_VEAT_AM_M (0x3F<<8) /* Address Mode Mask */
-#define TSI148_LCSR_VEAT_XAM_M (0xFF<<0) /* Master AMode Mask */
-
-
-/*
- * VMEbus PCI Error Diagnostics PCI/X Attributes Register CRG + $280
- */
-#define TSI148_LCSR_EDPAT_EDPCL (1<<29)
-
-/*
- * Inbound Translation Starting Address Lower
- */
-#define TSI148_LCSR_ITSAL6432_M (0xFFFF<<16) /* Mask */
-#define TSI148_LCSR_ITSAL24_M (0x00FFF<<12) /* Mask */
-#define TSI148_LCSR_ITSAL16_M (0x0000FFF<<4) /* Mask */
-
-/*
- * Inbound Translation Ending Address Lower
- */
-#define TSI148_LCSR_ITEAL6432_M (0xFFFF<<16) /* Mask */
-#define TSI148_LCSR_ITEAL24_M (0x00FFF<<12) /* Mask */
-#define TSI148_LCSR_ITEAL16_M (0x0000FFF<<4) /* Mask */
-
-/*
- * Inbound Translation Offset Lower
- */
-#define TSI148_LCSR_ITOFFL6432_M (0xFFFF<<16) /* Mask */
-#define TSI148_LCSR_ITOFFL24_M (0xFFFFF<<12) /* Mask */
-#define TSI148_LCSR_ITOFFL16_M (0xFFFFFFF<<4) /* Mask */
-
-/*
- * Inbound Translation Attribute
- */
-#define TSI148_LCSR_ITAT_EN (1<<31) /* Window Enable */
-#define TSI148_LCSR_ITAT_TH (1<<18) /* Prefetch Threshold */
-
-#define TSI148_LCSR_ITAT_VFS_M (3<<16) /* Virtual FIFO Size Mask */
-#define TSI148_LCSR_ITAT_VFS_64 (0<<16) /* 64 bytes Virtual FIFO Size */
-#define TSI148_LCSR_ITAT_VFS_128 (1<<16) /* 128 bytes Virtual FIFO Sz */
-#define TSI148_LCSR_ITAT_VFS_256 (2<<16) /* 256 bytes Virtual FIFO Sz */
-#define TSI148_LCSR_ITAT_VFS_512 (3<<16) /* 512 bytes Virtual FIFO Sz */
-
-#define TSI148_LCSR_ITAT_2eSSTM_M (7<<12) /* 2eSST Xfer Rate Mask */
-#define TSI148_LCSR_ITAT_2eSSTM_160 (0<<12) /* 160MB/s 2eSST Xfer Rate */
-#define TSI148_LCSR_ITAT_2eSSTM_267 (1<<12) /* 267MB/s 2eSST Xfer Rate */
-#define TSI148_LCSR_ITAT_2eSSTM_320 (2<<12) /* 320MB/s 2eSST Xfer Rate */
-
-#define TSI148_LCSR_ITAT_2eSSTB (1<<11) /* 2eSST Bcast Xfer Protocol */
-#define TSI148_LCSR_ITAT_2eSST (1<<10) /* 2eSST Xfer Protocol */
-#define TSI148_LCSR_ITAT_2eVME (1<<9) /* 2eVME Xfer Protocol */
-#define TSI148_LCSR_ITAT_MBLT (1<<8) /* MBLT Xfer Protocol */
-#define TSI148_LCSR_ITAT_BLT (1<<7) /* BLT Xfer Protocol */
-
-#define TSI148_LCSR_ITAT_AS_M (7<<4) /* Address Space Mask */
-#define TSI148_LCSR_ITAT_AS_A16 (0<<4) /* A16 Address Space */
-#define TSI148_LCSR_ITAT_AS_A24 (1<<4) /* A24 Address Space */
-#define TSI148_LCSR_ITAT_AS_A32 (2<<4) /* A32 Address Space */
-#define TSI148_LCSR_ITAT_AS_A64 (4<<4) /* A64 Address Space */
-
-#define TSI148_LCSR_ITAT_SUPR (1<<3) /* Supervisor Access */
-#define TSI148_LCSR_ITAT_NPRIV (1<<2) /* Non-Priv (User) Access */
-#define TSI148_LCSR_ITAT_PGM (1<<1) /* Program Access */
-#define TSI148_LCSR_ITAT_DATA (1<<0) /* Data Access */
-
-/*
- * GCSR Base Address Lower Address CRG +$404
- */
-#define TSI148_LCSR_GBAL_M (0x7FFFFFF<<5) /* Mask */
-
-/*
- * GCSR Attribute Register CRG + $408
- */
-#define TSI148_LCSR_GCSRAT_EN (1<<7) /* Enable access to GCSR */
-
-#define TSI148_LCSR_GCSRAT_AS_M (7<<4) /* Address Space Mask */
-#define TSI148_LCSR_GCSRAT_AS_A16 (0<<4) /* Address Space 16 */
-#define TSI148_LCSR_GCSRAT_AS_A24 (1<<4) /* Address Space 24 */
-#define TSI148_LCSR_GCSRAT_AS_A32 (2<<4) /* Address Space 32 */
-#define TSI148_LCSR_GCSRAT_AS_A64 (4<<4) /* Address Space 64 */
-
-#define TSI148_LCSR_GCSRAT_SUPR (1<<3) /* Sup set -GCSR decoder */
-#define TSI148_LCSR_GCSRAT_NPRIV (1<<2) /* Non-Privliged set - CGSR */
-#define TSI148_LCSR_GCSRAT_PGM (1<<1) /* Program set - GCSR decoder */
-#define TSI148_LCSR_GCSRAT_DATA (1<<0) /* DATA set GCSR decoder */
-
-/*
- * CRG Base Address Lower Address CRG + $410
- */
-#define TSI148_LCSR_CBAL_M (0xFFFFF<<12)
-
-/*
- * CRG Attribute Register CRG + $414
- */
-#define TSI148_LCSR_CRGAT_EN (1<<7) /* Enable PRG Access */
-
-#define TSI148_LCSR_CRGAT_AS_M (7<<4) /* Address Space */
-#define TSI148_LCSR_CRGAT_AS_A16 (0<<4) /* Address Space 16 */
-#define TSI148_LCSR_CRGAT_AS_A24 (1<<4) /* Address Space 24 */
-#define TSI148_LCSR_CRGAT_AS_A32 (2<<4) /* Address Space 32 */
-#define TSI148_LCSR_CRGAT_AS_A64 (4<<4) /* Address Space 64 */
-
-#define TSI148_LCSR_CRGAT_SUPR (1<<3) /* Supervisor Access */
-#define TSI148_LCSR_CRGAT_NPRIV (1<<2) /* Non-Privliged(User) Access */
-#define TSI148_LCSR_CRGAT_PGM (1<<1) /* Program Access */
-#define TSI148_LCSR_CRGAT_DATA (1<<0) /* Data Access */
-
-/*
- * CR/CSR Offset Lower Register CRG + $41C
- */
-#define TSI148_LCSR_CROL_M (0x1FFF<<19) /* Mask */
-
-/*
- * CR/CSR Attribute register CRG + $420
- */
-#define TSI148_LCSR_CRAT_EN (1<<7) /* Enable access to CR/CSR */
-
-/*
- * Location Monitor base address lower register CRG + $428
- */
-#define TSI148_LCSR_LMBAL_M (0x7FFFFFF<<5) /* Mask */
-
-/*
- * Location Monitor Attribute Register CRG + $42C
- */
-#define TSI148_LCSR_LMAT_EN (1<<7) /* Enable Location Monitor */
-
-#define TSI148_LCSR_LMAT_AS_M (7<<4) /* Address Space MASK */
-#define TSI148_LCSR_LMAT_AS_A16 (0<<4) /* A16 */
-#define TSI148_LCSR_LMAT_AS_A24 (1<<4) /* A24 */
-#define TSI148_LCSR_LMAT_AS_A32 (2<<4) /* A32 */
-#define TSI148_LCSR_LMAT_AS_A64 (4<<4) /* A64 */
-
-#define TSI148_LCSR_LMAT_SUPR (1<<3) /* Supervisor Access */
-#define TSI148_LCSR_LMAT_NPRIV (1<<2) /* Non-Priv (User) Access */
-#define TSI148_LCSR_LMAT_PGM (1<<1) /* Program Access */
-#define TSI148_LCSR_LMAT_DATA (1<<0) /* Data Access */
-
-/*
- * Broadcast Pulse Generator Timer Register CRG + $438
- */
-#define TSI148_LCSR_BPGTR_BPGT_M (0xFFFF<<0) /* Mask */
-
-/*
- * Broadcast Programmable Clock Timer Register CRG + $43C
- */
-#define TSI148_LCSR_BPCTR_BPCT_M (0xFFFFFF<<0) /* Mask */
-
-/*
- * VMEbus Interrupt Control Register CRG + $43C
- */
-#define TSI148_LCSR_VICR_CNTS_M (3<<22) /* Cntr Source MASK */
-#define TSI148_LCSR_VICR_CNTS_DIS (1<<22) /* Cntr Disable */
-#define TSI148_LCSR_VICR_CNTS_IRQ1 (2<<22) /* IRQ1 to Cntr */
-#define TSI148_LCSR_VICR_CNTS_IRQ2 (3<<22) /* IRQ2 to Cntr */
-
-#define TSI148_LCSR_VICR_EDGIS_M (3<<20) /* Edge interrupt MASK */
-#define TSI148_LCSR_VICR_EDGIS_DIS (1<<20) /* Edge interrupt Disable */
-#define TSI148_LCSR_VICR_EDGIS_IRQ1 (2<<20) /* IRQ1 to Edge */
-#define TSI148_LCSR_VICR_EDGIS_IRQ2 (3<<20) /* IRQ2 to Edge */
-
-#define TSI148_LCSR_VICR_IRQIF_M (3<<18) /* IRQ1* Function MASK */
-#define TSI148_LCSR_VICR_IRQIF_NORM (1<<18) /* Normal */
-#define TSI148_LCSR_VICR_IRQIF_PULSE (2<<18) /* Pulse Generator */
-#define TSI148_LCSR_VICR_IRQIF_PROG (3<<18) /* Programmable Clock */
-#define TSI148_LCSR_VICR_IRQIF_1U (4<<18) /* 1us Clock */
-
-#define TSI148_LCSR_VICR_IRQ2F_M (3<<16) /* IRQ2* Function MASK */
-#define TSI148_LCSR_VICR_IRQ2F_NORM (1<<16) /* Normal */
-#define TSI148_LCSR_VICR_IRQ2F_PULSE (2<<16) /* Pulse Generator */
-#define TSI148_LCSR_VICR_IRQ2F_PROG (3<<16) /* Programmable Clock */
-#define TSI148_LCSR_VICR_IRQ2F_1U (4<<16) /* 1us Clock */
-
-#define TSI148_LCSR_VICR_BIP (1<<15) /* Broadcast Interrupt Pulse */
-
-#define TSI148_LCSR_VICR_IRQC (1<<12) /* VMEbus IRQ Clear */
-#define TSI148_LCSR_VICR_IRQS (1<<11) /* VMEbus IRQ Status */
-
-#define TSI148_LCSR_VICR_IRQL_M (7<<8) /* VMEbus SW IRQ Level Mask */
-#define TSI148_LCSR_VICR_IRQL_1 (1<<8) /* VMEbus SW IRQ Level 1 */
-#define TSI148_LCSR_VICR_IRQL_2 (2<<8) /* VMEbus SW IRQ Level 2 */
-#define TSI148_LCSR_VICR_IRQL_3 (3<<8) /* VMEbus SW IRQ Level 3 */
-#define TSI148_LCSR_VICR_IRQL_4 (4<<8) /* VMEbus SW IRQ Level 4 */
-#define TSI148_LCSR_VICR_IRQL_5 (5<<8) /* VMEbus SW IRQ Level 5 */
-#define TSI148_LCSR_VICR_IRQL_6 (6<<8) /* VMEbus SW IRQ Level 6 */
-#define TSI148_LCSR_VICR_IRQL_7 (7<<8) /* VMEbus SW IRQ Level 7 */
-
-static const int TSI148_LCSR_VICR_IRQL[8] = { 0, TSI148_LCSR_VICR_IRQL_1,
- TSI148_LCSR_VICR_IRQL_2, TSI148_LCSR_VICR_IRQL_3,
- TSI148_LCSR_VICR_IRQL_4, TSI148_LCSR_VICR_IRQL_5,
- TSI148_LCSR_VICR_IRQL_6, TSI148_LCSR_VICR_IRQL_7 };
-
-#define TSI148_LCSR_VICR_STID_M (0xFF<<0) /* Status/ID Mask */
-
-/*
- * Interrupt Enable Register CRG + $440
- */
-#define TSI148_LCSR_INTEN_DMA1EN (1<<25) /* DMAC 1 */
-#define TSI148_LCSR_INTEN_DMA0EN (1<<24) /* DMAC 0 */
-#define TSI148_LCSR_INTEN_LM3EN (1<<23) /* Location Monitor 3 */
-#define TSI148_LCSR_INTEN_LM2EN (1<<22) /* Location Monitor 2 */
-#define TSI148_LCSR_INTEN_LM1EN (1<<21) /* Location Monitor 1 */
-#define TSI148_LCSR_INTEN_LM0EN (1<<20) /* Location Monitor 0 */
-#define TSI148_LCSR_INTEN_MB3EN (1<<19) /* Mail Box 3 */
-#define TSI148_LCSR_INTEN_MB2EN (1<<18) /* Mail Box 2 */
-#define TSI148_LCSR_INTEN_MB1EN (1<<17) /* Mail Box 1 */
-#define TSI148_LCSR_INTEN_MB0EN (1<<16) /* Mail Box 0 */
-#define TSI148_LCSR_INTEN_PERREN (1<<13) /* PCI/X Error */
-#define TSI148_LCSR_INTEN_VERREN (1<<12) /* VMEbus Error */
-#define TSI148_LCSR_INTEN_VIEEN (1<<11) /* VMEbus IRQ Edge */
-#define TSI148_LCSR_INTEN_IACKEN (1<<10) /* IACK */
-#define TSI148_LCSR_INTEN_SYSFLEN (1<<9) /* System Fail */
-#define TSI148_LCSR_INTEN_ACFLEN (1<<8) /* AC Fail */
-#define TSI148_LCSR_INTEN_IRQ7EN (1<<7) /* IRQ7 */
-#define TSI148_LCSR_INTEN_IRQ6EN (1<<6) /* IRQ6 */
-#define TSI148_LCSR_INTEN_IRQ5EN (1<<5) /* IRQ5 */
-#define TSI148_LCSR_INTEN_IRQ4EN (1<<4) /* IRQ4 */
-#define TSI148_LCSR_INTEN_IRQ3EN (1<<3) /* IRQ3 */
-#define TSI148_LCSR_INTEN_IRQ2EN (1<<2) /* IRQ2 */
-#define TSI148_LCSR_INTEN_IRQ1EN (1<<1) /* IRQ1 */
-
-static const int TSI148_LCSR_INTEN_LMEN[4] = { TSI148_LCSR_INTEN_LM0EN,
- TSI148_LCSR_INTEN_LM1EN,
- TSI148_LCSR_INTEN_LM2EN,
- TSI148_LCSR_INTEN_LM3EN };
-
-static const int TSI148_LCSR_INTEN_IRQEN[7] = { TSI148_LCSR_INTEN_IRQ1EN,
- TSI148_LCSR_INTEN_IRQ2EN,
- TSI148_LCSR_INTEN_IRQ3EN,
- TSI148_LCSR_INTEN_IRQ4EN,
- TSI148_LCSR_INTEN_IRQ5EN,
- TSI148_LCSR_INTEN_IRQ6EN,
- TSI148_LCSR_INTEN_IRQ7EN };
-
-/*
- * Interrupt Enable Out Register CRG + $444
- */
-#define TSI148_LCSR_INTEO_DMA1EO (1<<25) /* DMAC 1 */
-#define TSI148_LCSR_INTEO_DMA0EO (1<<24) /* DMAC 0 */
-#define TSI148_LCSR_INTEO_LM3EO (1<<23) /* Loc Monitor 3 */
-#define TSI148_LCSR_INTEO_LM2EO (1<<22) /* Loc Monitor 2 */
-#define TSI148_LCSR_INTEO_LM1EO (1<<21) /* Loc Monitor 1 */
-#define TSI148_LCSR_INTEO_LM0EO (1<<20) /* Location Monitor 0 */
-#define TSI148_LCSR_INTEO_MB3EO (1<<19) /* Mail Box 3 */
-#define TSI148_LCSR_INTEO_MB2EO (1<<18) /* Mail Box 2 */
-#define TSI148_LCSR_INTEO_MB1EO (1<<17) /* Mail Box 1 */
-#define TSI148_LCSR_INTEO_MB0EO (1<<16) /* Mail Box 0 */
-#define TSI148_LCSR_INTEO_PERREO (1<<13) /* PCI/X Error */
-#define TSI148_LCSR_INTEO_VERREO (1<<12) /* VMEbus Error */
-#define TSI148_LCSR_INTEO_VIEEO (1<<11) /* VMEbus IRQ Edge */
-#define TSI148_LCSR_INTEO_IACKEO (1<<10) /* IACK */
-#define TSI148_LCSR_INTEO_SYSFLEO (1<<9) /* System Fail */
-#define TSI148_LCSR_INTEO_ACFLEO (1<<8) /* AC Fail */
-#define TSI148_LCSR_INTEO_IRQ7EO (1<<7) /* IRQ7 */
-#define TSI148_LCSR_INTEO_IRQ6EO (1<<6) /* IRQ6 */
-#define TSI148_LCSR_INTEO_IRQ5EO (1<<5) /* IRQ5 */
-#define TSI148_LCSR_INTEO_IRQ4EO (1<<4) /* IRQ4 */
-#define TSI148_LCSR_INTEO_IRQ3EO (1<<3) /* IRQ3 */
-#define TSI148_LCSR_INTEO_IRQ2EO (1<<2) /* IRQ2 */
-#define TSI148_LCSR_INTEO_IRQ1EO (1<<1) /* IRQ1 */
-
-static const int TSI148_LCSR_INTEO_LMEO[4] = { TSI148_LCSR_INTEO_LM0EO,
- TSI148_LCSR_INTEO_LM1EO,
- TSI148_LCSR_INTEO_LM2EO,
- TSI148_LCSR_INTEO_LM3EO };
-
-static const int TSI148_LCSR_INTEO_IRQEO[7] = { TSI148_LCSR_INTEO_IRQ1EO,
- TSI148_LCSR_INTEO_IRQ2EO,
- TSI148_LCSR_INTEO_IRQ3EO,
- TSI148_LCSR_INTEO_IRQ4EO,
- TSI148_LCSR_INTEO_IRQ5EO,
- TSI148_LCSR_INTEO_IRQ6EO,
- TSI148_LCSR_INTEO_IRQ7EO };
-
-/*
- * Interrupt Status Register CRG + $448
- */
-#define TSI148_LCSR_INTS_DMA1S (1<<25) /* DMA 1 */
-#define TSI148_LCSR_INTS_DMA0S (1<<24) /* DMA 0 */
-#define TSI148_LCSR_INTS_LM3S (1<<23) /* Location Monitor 3 */
-#define TSI148_LCSR_INTS_LM2S (1<<22) /* Location Monitor 2 */
-#define TSI148_LCSR_INTS_LM1S (1<<21) /* Location Monitor 1 */
-#define TSI148_LCSR_INTS_LM0S (1<<20) /* Location Monitor 0 */
-#define TSI148_LCSR_INTS_MB3S (1<<19) /* Mail Box 3 */
-#define TSI148_LCSR_INTS_MB2S (1<<18) /* Mail Box 2 */
-#define TSI148_LCSR_INTS_MB1S (1<<17) /* Mail Box 1 */
-#define TSI148_LCSR_INTS_MB0S (1<<16) /* Mail Box 0 */
-#define TSI148_LCSR_INTS_PERRS (1<<13) /* PCI/X Error */
-#define TSI148_LCSR_INTS_VERRS (1<<12) /* VMEbus Error */
-#define TSI148_LCSR_INTS_VIES (1<<11) /* VMEbus IRQ Edge */
-#define TSI148_LCSR_INTS_IACKS (1<<10) /* IACK */
-#define TSI148_LCSR_INTS_SYSFLS (1<<9) /* System Fail */
-#define TSI148_LCSR_INTS_ACFLS (1<<8) /* AC Fail */
-#define TSI148_LCSR_INTS_IRQ7S (1<<7) /* IRQ7 */
-#define TSI148_LCSR_INTS_IRQ6S (1<<6) /* IRQ6 */
-#define TSI148_LCSR_INTS_IRQ5S (1<<5) /* IRQ5 */
-#define TSI148_LCSR_INTS_IRQ4S (1<<4) /* IRQ4 */
-#define TSI148_LCSR_INTS_IRQ3S (1<<3) /* IRQ3 */
-#define TSI148_LCSR_INTS_IRQ2S (1<<2) /* IRQ2 */
-#define TSI148_LCSR_INTS_IRQ1S (1<<1) /* IRQ1 */
-
-static const int TSI148_LCSR_INTS_LMS[4] = { TSI148_LCSR_INTS_LM0S,
- TSI148_LCSR_INTS_LM1S,
- TSI148_LCSR_INTS_LM2S,
- TSI148_LCSR_INTS_LM3S };
-
-static const int TSI148_LCSR_INTS_MBS[4] = { TSI148_LCSR_INTS_MB0S,
- TSI148_LCSR_INTS_MB1S,
- TSI148_LCSR_INTS_MB2S,
- TSI148_LCSR_INTS_MB3S };
-
-/*
- * Interrupt Clear Register CRG + $44C
- */
-#define TSI148_LCSR_INTC_DMA1C (1<<25) /* DMA 1 */
-#define TSI148_LCSR_INTC_DMA0C (1<<24) /* DMA 0 */
-#define TSI148_LCSR_INTC_LM3C (1<<23) /* Location Monitor 3 */
-#define TSI148_LCSR_INTC_LM2C (1<<22) /* Location Monitor 2 */
-#define TSI148_LCSR_INTC_LM1C (1<<21) /* Location Monitor 1 */
-#define TSI148_LCSR_INTC_LM0C (1<<20) /* Location Monitor 0 */
-#define TSI148_LCSR_INTC_MB3C (1<<19) /* Mail Box 3 */
-#define TSI148_LCSR_INTC_MB2C (1<<18) /* Mail Box 2 */
-#define TSI148_LCSR_INTC_MB1C (1<<17) /* Mail Box 1 */
-#define TSI148_LCSR_INTC_MB0C (1<<16) /* Mail Box 0 */
-#define TSI148_LCSR_INTC_PERRC (1<<13) /* VMEbus Error */
-#define TSI148_LCSR_INTC_VERRC (1<<12) /* VMEbus Access Time-out */
-#define TSI148_LCSR_INTC_VIEC (1<<11) /* VMEbus IRQ Edge */
-#define TSI148_LCSR_INTC_IACKC (1<<10) /* IACK */
-#define TSI148_LCSR_INTC_SYSFLC (1<<9) /* System Fail */
-#define TSI148_LCSR_INTC_ACFLC (1<<8) /* AC Fail */
-
-static const int TSI148_LCSR_INTC_LMC[4] = { TSI148_LCSR_INTC_LM0C,
- TSI148_LCSR_INTC_LM1C,
- TSI148_LCSR_INTC_LM2C,
- TSI148_LCSR_INTC_LM3C };
-
-static const int TSI148_LCSR_INTC_MBC[4] = { TSI148_LCSR_INTC_MB0C,
- TSI148_LCSR_INTC_MB1C,
- TSI148_LCSR_INTC_MB2C,
- TSI148_LCSR_INTC_MB3C };
-
-/*
- * Interrupt Map Register 1 CRG + $458
- */
-#define TSI148_LCSR_INTM1_DMA1M_M (3<<18) /* DMA 1 */
-#define TSI148_LCSR_INTM1_DMA0M_M (3<<16) /* DMA 0 */
-#define TSI148_LCSR_INTM1_LM3M_M (3<<14) /* Location Monitor 3 */
-#define TSI148_LCSR_INTM1_LM2M_M (3<<12) /* Location Monitor 2 */
-#define TSI148_LCSR_INTM1_LM1M_M (3<<10) /* Location Monitor 1 */
-#define TSI148_LCSR_INTM1_LM0M_M (3<<8) /* Location Monitor 0 */
-#define TSI148_LCSR_INTM1_MB3M_M (3<<6) /* Mail Box 3 */
-#define TSI148_LCSR_INTM1_MB2M_M (3<<4) /* Mail Box 2 */
-#define TSI148_LCSR_INTM1_MB1M_M (3<<2) /* Mail Box 1 */
-#define TSI148_LCSR_INTM1_MB0M_M (3<<0) /* Mail Box 0 */
-
-/*
- * Interrupt Map Register 2 CRG + $45C
- */
-#define TSI148_LCSR_INTM2_PERRM_M (3<<26) /* PCI Bus Error */
-#define TSI148_LCSR_INTM2_VERRM_M (3<<24) /* VMEbus Error */
-#define TSI148_LCSR_INTM2_VIEM_M (3<<22) /* VMEbus IRQ Edge */
-#define TSI148_LCSR_INTM2_IACKM_M (3<<20) /* IACK */
-#define TSI148_LCSR_INTM2_SYSFLM_M (3<<18) /* System Fail */
-#define TSI148_LCSR_INTM2_ACFLM_M (3<<16) /* AC Fail */
-#define TSI148_LCSR_INTM2_IRQ7M_M (3<<14) /* IRQ7 */
-#define TSI148_LCSR_INTM2_IRQ6M_M (3<<12) /* IRQ6 */
-#define TSI148_LCSR_INTM2_IRQ5M_M (3<<10) /* IRQ5 */
-#define TSI148_LCSR_INTM2_IRQ4M_M (3<<8) /* IRQ4 */
-#define TSI148_LCSR_INTM2_IRQ3M_M (3<<6) /* IRQ3 */
-#define TSI148_LCSR_INTM2_IRQ2M_M (3<<4) /* IRQ2 */
-#define TSI148_LCSR_INTM2_IRQ1M_M (3<<2) /* IRQ1 */
-
-/*
- * DMA Control (0-1) Registers CRG + $500
- */
-#define TSI148_LCSR_DCTL_ABT (1<<27) /* Abort */
-#define TSI148_LCSR_DCTL_PAU (1<<26) /* Pause */
-#define TSI148_LCSR_DCTL_DGO (1<<25) /* DMA Go */
-
-#define TSI148_LCSR_DCTL_MOD (1<<23) /* Mode */
-
-#define TSI148_LCSR_DCTL_VBKS_M (7<<12) /* VMEbus block Size MASK */
-#define TSI148_LCSR_DCTL_VBKS_32 (0<<12) /* VMEbus block Size 32 */
-#define TSI148_LCSR_DCTL_VBKS_64 (1<<12) /* VMEbus block Size 64 */
-#define TSI148_LCSR_DCTL_VBKS_128 (2<<12) /* VMEbus block Size 128 */
-#define TSI148_LCSR_DCTL_VBKS_256 (3<<12) /* VMEbus block Size 256 */
-#define TSI148_LCSR_DCTL_VBKS_512 (4<<12) /* VMEbus block Size 512 */
-#define TSI148_LCSR_DCTL_VBKS_1024 (5<<12) /* VMEbus block Size 1024 */
-#define TSI148_LCSR_DCTL_VBKS_2048 (6<<12) /* VMEbus block Size 2048 */
-#define TSI148_LCSR_DCTL_VBKS_4096 (7<<12) /* VMEbus block Size 4096 */
-
-#define TSI148_LCSR_DCTL_VBOT_M (7<<8) /* VMEbus back-off MASK */
-#define TSI148_LCSR_DCTL_VBOT_0 (0<<8) /* VMEbus back-off 0us */
-#define TSI148_LCSR_DCTL_VBOT_1 (1<<8) /* VMEbus back-off 1us */
-#define TSI148_LCSR_DCTL_VBOT_2 (2<<8) /* VMEbus back-off 2us */
-#define TSI148_LCSR_DCTL_VBOT_4 (3<<8) /* VMEbus back-off 4us */
-#define TSI148_LCSR_DCTL_VBOT_8 (4<<8) /* VMEbus back-off 8us */
-#define TSI148_LCSR_DCTL_VBOT_16 (5<<8) /* VMEbus back-off 16us */
-#define TSI148_LCSR_DCTL_VBOT_32 (6<<8) /* VMEbus back-off 32us */
-#define TSI148_LCSR_DCTL_VBOT_64 (7<<8) /* VMEbus back-off 64us */
-
-#define TSI148_LCSR_DCTL_PBKS_M (7<<4) /* PCI block size MASK */
-#define TSI148_LCSR_DCTL_PBKS_32 (0<<4) /* PCI block size 32 bytes */
-#define TSI148_LCSR_DCTL_PBKS_64 (1<<4) /* PCI block size 64 bytes */
-#define TSI148_LCSR_DCTL_PBKS_128 (2<<4) /* PCI block size 128 bytes */
-#define TSI148_LCSR_DCTL_PBKS_256 (3<<4) /* PCI block size 256 bytes */
-#define TSI148_LCSR_DCTL_PBKS_512 (4<<4) /* PCI block size 512 bytes */
-#define TSI148_LCSR_DCTL_PBKS_1024 (5<<4) /* PCI block size 1024 bytes */
-#define TSI148_LCSR_DCTL_PBKS_2048 (6<<4) /* PCI block size 2048 bytes */
-#define TSI148_LCSR_DCTL_PBKS_4096 (7<<4) /* PCI block size 4096 bytes */
-
-#define TSI148_LCSR_DCTL_PBOT_M (7<<0) /* PCI back off MASK */
-#define TSI148_LCSR_DCTL_PBOT_0 (0<<0) /* PCI back off 0us */
-#define TSI148_LCSR_DCTL_PBOT_1 (1<<0) /* PCI back off 1us */
-#define TSI148_LCSR_DCTL_PBOT_2 (2<<0) /* PCI back off 2us */
-#define TSI148_LCSR_DCTL_PBOT_4 (3<<0) /* PCI back off 3us */
-#define TSI148_LCSR_DCTL_PBOT_8 (4<<0) /* PCI back off 4us */
-#define TSI148_LCSR_DCTL_PBOT_16 (5<<0) /* PCI back off 8us */
-#define TSI148_LCSR_DCTL_PBOT_32 (6<<0) /* PCI back off 16us */
-#define TSI148_LCSR_DCTL_PBOT_64 (7<<0) /* PCI back off 32us */
-
-/*
- * DMA Status Registers (0-1) CRG + $504
- */
-#define TSI148_LCSR_DSTA_SMA (1<<31) /* PCI Signalled Master Abt */
-#define TSI148_LCSR_DSTA_RTA (1<<30) /* PCI Received Target Abt */
-#define TSI148_LCSR_DSTA_MRC (1<<29) /* PCI Max Retry Count */
-#define TSI148_LCSR_DSTA_VBE (1<<28) /* VMEbus error */
-#define TSI148_LCSR_DSTA_ABT (1<<27) /* Abort */
-#define TSI148_LCSR_DSTA_PAU (1<<26) /* Pause */
-#define TSI148_LCSR_DSTA_DON (1<<25) /* Done */
-#define TSI148_LCSR_DSTA_BSY (1<<24) /* Busy */
-
-/*
- * DMA Current Link Address Lower (0-1)
- */
-#define TSI148_LCSR_DCLAL_M (0x3FFFFFF<<6) /* Mask */
-
-/*
- * DMA Source Attribute (0-1) Reg
- */
-#define TSI148_LCSR_DSAT_TYP_M (3<<28) /* Source Bus Type */
-#define TSI148_LCSR_DSAT_TYP_PCI (0<<28) /* PCI Bus */
-#define TSI148_LCSR_DSAT_TYP_VME (1<<28) /* VMEbus */
-#define TSI148_LCSR_DSAT_TYP_PAT (2<<28) /* Data Pattern */
-
-#define TSI148_LCSR_DSAT_PSZ (1<<25) /* Pattern Size */
-#define TSI148_LCSR_DSAT_NIN (1<<24) /* No Increment */
-
-#define TSI148_LCSR_DSAT_2eSSTM_M (3<<11) /* 2eSST Trans Rate Mask */
-#define TSI148_LCSR_DSAT_2eSSTM_160 (0<<11) /* 160 MB/s */
-#define TSI148_LCSR_DSAT_2eSSTM_267 (1<<11) /* 267 MB/s */
-#define TSI148_LCSR_DSAT_2eSSTM_320 (2<<11) /* 320 MB/s */
-
-#define TSI148_LCSR_DSAT_TM_M (7<<8) /* Bus Transfer Protocol Mask */
-#define TSI148_LCSR_DSAT_TM_SCT (0<<8) /* SCT */
-#define TSI148_LCSR_DSAT_TM_BLT (1<<8) /* BLT */
-#define TSI148_LCSR_DSAT_TM_MBLT (2<<8) /* MBLT */
-#define TSI148_LCSR_DSAT_TM_2eVME (3<<8) /* 2eVME */
-#define TSI148_LCSR_DSAT_TM_2eSST (4<<8) /* 2eSST */
-#define TSI148_LCSR_DSAT_TM_2eSSTB (5<<8) /* 2eSST Broadcast */
-
-#define TSI148_LCSR_DSAT_DBW_M (3<<6) /* Max Data Width MASK */
-#define TSI148_LCSR_DSAT_DBW_16 (0<<6) /* 16 Bits */
-#define TSI148_LCSR_DSAT_DBW_32 (1<<6) /* 32 Bits */
-
-#define TSI148_LCSR_DSAT_SUP (1<<5) /* Supervisory Mode */
-#define TSI148_LCSR_DSAT_PGM (1<<4) /* Program Mode */
-
-#define TSI148_LCSR_DSAT_AMODE_M (0xf<<0) /* Address Space Mask */
-#define TSI148_LCSR_DSAT_AMODE_A16 (0<<0) /* A16 */
-#define TSI148_LCSR_DSAT_AMODE_A24 (1<<0) /* A24 */
-#define TSI148_LCSR_DSAT_AMODE_A32 (2<<0) /* A32 */
-#define TSI148_LCSR_DSAT_AMODE_A64 (4<<0) /* A64 */
-#define TSI148_LCSR_DSAT_AMODE_CRCSR (5<<0) /* CR/CSR */
-#define TSI148_LCSR_DSAT_AMODE_USER1 (8<<0) /* User1 */
-#define TSI148_LCSR_DSAT_AMODE_USER2 (9<<0) /* User2 */
-#define TSI148_LCSR_DSAT_AMODE_USER3 (0xa<<0) /* User3 */
-#define TSI148_LCSR_DSAT_AMODE_USER4 (0xb<<0) /* User4 */
-
-/*
- * DMA Destination Attribute Registers (0-1)
- */
-#define TSI148_LCSR_DDAT_TYP_PCI (0<<28) /* Destination PCI Bus */
-#define TSI148_LCSR_DDAT_TYP_VME (1<<28) /* Destination VMEbus */
-
-#define TSI148_LCSR_DDAT_2eSSTM_M (3<<11) /* 2eSST Transfer Rate Mask */
-#define TSI148_LCSR_DDAT_2eSSTM_160 (0<<11) /* 160 MB/s */
-#define TSI148_LCSR_DDAT_2eSSTM_267 (1<<11) /* 267 MB/s */
-#define TSI148_LCSR_DDAT_2eSSTM_320 (2<<11) /* 320 MB/s */
-
-#define TSI148_LCSR_DDAT_TM_M (7<<8) /* Bus Transfer Protocol Mask */
-#define TSI148_LCSR_DDAT_TM_SCT (0<<8) /* SCT */
-#define TSI148_LCSR_DDAT_TM_BLT (1<<8) /* BLT */
-#define TSI148_LCSR_DDAT_TM_MBLT (2<<8) /* MBLT */
-#define TSI148_LCSR_DDAT_TM_2eVME (3<<8) /* 2eVME */
-#define TSI148_LCSR_DDAT_TM_2eSST (4<<8) /* 2eSST */
-#define TSI148_LCSR_DDAT_TM_2eSSTB (5<<8) /* 2eSST Broadcast */
-
-#define TSI148_LCSR_DDAT_DBW_M (3<<6) /* Max Data Width MASK */
-#define TSI148_LCSR_DDAT_DBW_16 (0<<6) /* 16 Bits */
-#define TSI148_LCSR_DDAT_DBW_32 (1<<6) /* 32 Bits */
-
-#define TSI148_LCSR_DDAT_SUP (1<<5) /* Supervisory/User Access */
-#define TSI148_LCSR_DDAT_PGM (1<<4) /* Program/Data Access */
-
-#define TSI148_LCSR_DDAT_AMODE_M (0xf<<0) /* Address Space Mask */
-#define TSI148_LCSR_DDAT_AMODE_A16 (0<<0) /* A16 */
-#define TSI148_LCSR_DDAT_AMODE_A24 (1<<0) /* A24 */
-#define TSI148_LCSR_DDAT_AMODE_A32 (2<<0) /* A32 */
-#define TSI148_LCSR_DDAT_AMODE_A64 (4<<0) /* A64 */
-#define TSI148_LCSR_DDAT_AMODE_CRCSR (5<<0) /* CRC/SR */
-#define TSI148_LCSR_DDAT_AMODE_USER1 (8<<0) /* User1 */
-#define TSI148_LCSR_DDAT_AMODE_USER2 (9<<0) /* User2 */
-#define TSI148_LCSR_DDAT_AMODE_USER3 (0xa<<0) /* User3 */
-#define TSI148_LCSR_DDAT_AMODE_USER4 (0xb<<0) /* User4 */
-
-/*
- * DMA Next Link Address Lower
- */
-#define TSI148_LCSR_DNLAL_DNLAL_M (0x3FFFFFF<<6) /* Address Mask */
-#define TSI148_LCSR_DNLAL_LLA (1<<0) /* Last Link Address Indicator */
-
-/*
- * DMA 2eSST Broadcast Select
- */
-#define TSI148_LCSR_DBS_M (0x1FFFFF<<0) /* Mask */
-
-/*
- * GCSR Register Group
- */
-
-/*
- * GCSR Control and Status Register CRG + $604
- */
-#define TSI148_GCSR_GCTRL_LRST (1<<15) /* Local Reset */
-#define TSI148_GCSR_GCTRL_SFAILEN (1<<14) /* System Fail enable */
-#define TSI148_GCSR_GCTRL_BDFAILS (1<<13) /* Board Fail Status */
-#define TSI148_GCSR_GCTRL_SCON (1<<12) /* System Copntroller */
-#define TSI148_GCSR_GCTRL_MEN (1<<11) /* Module Enable (READY) */
-
-#define TSI148_GCSR_GCTRL_LMI3S (1<<7) /* Loc Monitor 3 Int Status */
-#define TSI148_GCSR_GCTRL_LMI2S (1<<6) /* Loc Monitor 2 Int Status */
-#define TSI148_GCSR_GCTRL_LMI1S (1<<5) /* Loc Monitor 1 Int Status */
-#define TSI148_GCSR_GCTRL_LMI0S (1<<4) /* Loc Monitor 0 Int Status */
-#define TSI148_GCSR_GCTRL_MBI3S (1<<3) /* Mail box 3 Int Status */
-#define TSI148_GCSR_GCTRL_MBI2S (1<<2) /* Mail box 2 Int Status */
-#define TSI148_GCSR_GCTRL_MBI1S (1<<1) /* Mail box 1 Int Status */
-#define TSI148_GCSR_GCTRL_MBI0S (1<<0) /* Mail box 0 Int Status */
-
-#define TSI148_GCSR_GAP (1<<5) /* Geographic Addr Parity */
-#define TSI148_GCSR_GA_M (0x1F<<0) /* Geographic Address Mask */
-
-/*
- * CR/CSR Register Group
- */
-
-/*
- * CR/CSR Bit Clear Register CRG + $FF4
- */
-#define TSI148_CRCSR_CSRBCR_LRSTC (1<<7) /* Local Reset Clear */
-#define TSI148_CRCSR_CSRBCR_SFAILC (1<<6) /* System Fail Enable Clear */
-#define TSI148_CRCSR_CSRBCR_BDFAILS (1<<5) /* Board Fail Status */
-#define TSI148_CRCSR_CSRBCR_MENC (1<<4) /* Module Enable Clear */
-#define TSI148_CRCSR_CSRBCR_BERRSC (1<<3) /* Bus Error Status Clear */
-
-/*
- * CR/CSR Bit Set Register CRG+$FF8
- */
-#define TSI148_CRCSR_CSRBSR_LISTS (1<<7) /* Local Reset Clear */
-#define TSI148_CRCSR_CSRBSR_SFAILS (1<<6) /* System Fail Enable Clear */
-#define TSI148_CRCSR_CSRBSR_BDFAILS (1<<5) /* Board Fail Status */
-#define TSI148_CRCSR_CSRBSR_MENS (1<<4) /* Module Enable Clear */
-#define TSI148_CRCSR_CSRBSR_BERRS (1<<3) /* Bus Error Status Clear */
-
-/*
- * CR/CSR Base Address Register CRG + FFC
- */
-#define TSI148_CRCSR_CBAR_M (0x1F<<3) /* Mask */
-
-#endif /* TSI148_H */
diff --git a/drivers/staging/vme/devices/Kconfig b/drivers/staging/vme/devices/Kconfig
index 55ec30cb1fa2..d0cab1766190 100644
--- a/drivers/staging/vme/devices/Kconfig
+++ b/drivers/staging/vme/devices/Kconfig
@@ -2,6 +2,7 @@ comment "VME Device Drivers"
config VME_USER
tristate "VME user space access driver"
+ depends on STAGING
help
If you say Y here you want to be able to access a limited number of
VME windows in a manner at least semi-compatible with the interface
@@ -9,7 +10,7 @@ config VME_USER
config VME_PIO2
tristate "GE PIO2 VME"
- depends on GPIOLIB
+ depends on STAGING && GPIOLIB
help
Say Y here to include support for the GE PIO2. The PIO2 is a 6U VME
slave card, implementing 32 solid-state relay switched IO lines, in
diff --git a/drivers/staging/vme/devices/vme_pio2_cntr.c b/drivers/staging/vme/devices/vme_pio2_cntr.c
index 08e0d59806ca..6335471faa36 100644
--- a/drivers/staging/vme/devices/vme_pio2_cntr.c
+++ b/drivers/staging/vme/devices/vme_pio2_cntr.c
@@ -17,8 +17,8 @@
#include <linux/device.h>
#include <linux/types.h>
#include <linux/gpio.h>
+#include <linux/vme.h>
-#include "../vme.h"
#include "vme_pio2.h"
static int pio2_cntr_irq_set(struct pio2_card *card, int id)
diff --git a/drivers/staging/vme/devices/vme_pio2_core.c b/drivers/staging/vme/devices/vme_pio2_core.c
index 573c80003f0c..4bf8e05ac312 100644
--- a/drivers/staging/vme/devices/vme_pio2_core.c
+++ b/drivers/staging/vme/devices/vme_pio2_core.c
@@ -10,7 +10,6 @@
* option) any later version.
*/
-#include <linux/version.h>
#include <linux/module.h>
#include <linux/moduleparam.h>
#include <linux/types.h>
@@ -20,8 +19,8 @@
#include <linux/ctype.h>
#include <linux/gpio.h>
#include <linux/slab.h>
+#include <linux/vme.h>
-#include "../vme.h"
#include "vme_pio2.h"
diff --git a/drivers/staging/vme/devices/vme_pio2_gpio.c b/drivers/staging/vme/devices/vme_pio2_gpio.c
index 858484915f08..ad76a477825b 100644
--- a/drivers/staging/vme/devices/vme_pio2_gpio.c
+++ b/drivers/staging/vme/devices/vme_pio2_gpio.c
@@ -10,7 +10,6 @@
* option) any later version.
*/
-#include <linux/version.h>
#include <linux/module.h>
#include <linux/moduleparam.h>
#include <linux/types.h>
@@ -21,8 +20,8 @@
#include <linux/ctype.h>
#include <linux/gpio.h>
#include <linux/slab.h>
+#include <linux/vme.h>
-#include "../vme.h"
#include "vme_pio2.h"
static const char driver_name[] = "pio2_gpio";
@@ -79,7 +78,7 @@ static void pio2_gpio_set(struct gpio_chip *chip, unsigned int offset,
if ((card->bank[PIO2_CHANNEL_BANK[offset]].config == INPUT) |
(card->bank[PIO2_CHANNEL_BANK[offset]].config == NOFIT)) {
- dev_err(&card->vdev->dev, "Channel not availabe as output\n");
+ dev_err(&card->vdev->dev, "Channel not available as output\n");
return;
}
diff --git a/drivers/staging/vme/devices/vme_user.c b/drivers/staging/vme/devices/vme_user.c
index 7dcd1622b5f5..e25645e226e3 100644
--- a/drivers/staging/vme/devices/vme_user.c
+++ b/drivers/staging/vme/devices/vme_user.c
@@ -27,17 +27,16 @@
#include <linux/module.h>
#include <linux/pagemap.h>
#include <linux/pci.h>
-#include <linux/semaphore.h>
+#include <linux/mutex.h>
#include <linux/slab.h>
#include <linux/spinlock.h>
#include <linux/syscalls.h>
-#include <linux/mutex.h>
#include <linux/types.h>
#include <linux/io.h>
#include <linux/uaccess.h>
+#include <linux/vme.h>
-#include "../vme.h"
#include "vme_user.h"
static DEFINE_MUTEX(vme_user_mutex);
@@ -95,7 +94,7 @@ struct image_desc {
void *kern_buf; /* Buffer address in kernel space */
dma_addr_t pci_buf; /* Buffer address in PCI address space */
unsigned long long size_buf; /* Buffer size */
- struct semaphore sem; /* Semaphore for locking image */
+ struct mutex mutex; /* Mutex for locking image */
struct device *device; /* Sysfs device */
struct vme_resource *resource; /* VME resource */
int users; /* Number of current users */
@@ -168,7 +167,7 @@ static int vme_user_open(struct inode *inode, struct file *file)
int err;
unsigned int minor = MINOR(inode->i_rdev);
- down(&image[minor].sem);
+ mutex_lock(&image[minor].mutex);
/* Allow device to be opened if a resource is needed and allocated. */
if (minor < CONTROL_MINOR && image[minor].resource == NULL) {
printk(KERN_ERR "No resources allocated for device\n");
@@ -179,12 +178,12 @@ static int vme_user_open(struct inode *inode, struct file *file)
/* Increment user count */
image[minor].users++;
- up(&image[minor].sem);
+ mutex_unlock(&image[minor].mutex);
return 0;
err_res:
- up(&image[minor].sem);
+ mutex_unlock(&image[minor].mutex);
return err;
}
@@ -193,12 +192,12 @@ static int vme_user_release(struct inode *inode, struct file *file)
{
unsigned int minor = MINOR(inode->i_rdev);
- down(&image[minor].sem);
+ mutex_lock(&image[minor].mutex);
/* Decrement user count */
image[minor].users--;
- up(&image[minor].sem);
+ mutex_unlock(&image[minor].mutex);
return 0;
}
@@ -325,14 +324,14 @@ static ssize_t vme_user_read(struct file *file, char __user *buf, size_t count,
if (minor == CONTROL_MINOR)
return 0;
- down(&image[minor].sem);
+ mutex_lock(&image[minor].mutex);
/* XXX Do we *really* want this helper - we can use vme_*_get ? */
image_size = vme_get_size(image[minor].resource);
/* Ensure we are starting at a valid location */
if ((*ppos < 0) || (*ppos > (image_size - 1))) {
- up(&image[minor].sem);
+ mutex_unlock(&image[minor].mutex);
return 0;
}
@@ -353,8 +352,7 @@ static ssize_t vme_user_read(struct file *file, char __user *buf, size_t count,
retval = -EINVAL;
}
- up(&image[minor].sem);
-
+ mutex_unlock(&image[minor].mutex);
if (retval > 0)
*ppos += retval;
@@ -372,13 +370,13 @@ static ssize_t vme_user_write(struct file *file, const char __user *buf,
if (minor == CONTROL_MINOR)
return 0;
- down(&image[minor].sem);
+ mutex_lock(&image[minor].mutex);
image_size = vme_get_size(image[minor].resource);
/* Ensure we are starting at a valid location */
if ((*ppos < 0) || (*ppos > (image_size - 1))) {
- up(&image[minor].sem);
+ mutex_unlock(&image[minor].mutex);
return 0;
}
@@ -398,8 +396,8 @@ static ssize_t vme_user_write(struct file *file, const char __user *buf,
default:
retval = -EINVAL;
}
-
- up(&image[minor].sem);
+
+ mutex_unlock(&image[minor].mutex);
if (retval > 0)
*ppos += retval;
@@ -416,7 +414,7 @@ static loff_t vme_user_llseek(struct file *file, loff_t off, int whence)
if (minor == CONTROL_MINOR)
return -EINVAL;
- down(&image[minor].sem);
+ mutex_lock(&image[minor].mutex);
image_size = vme_get_size(image[minor].resource);
switch (whence) {
@@ -430,19 +428,19 @@ static loff_t vme_user_llseek(struct file *file, loff_t off, int whence)
absolute = image_size + off;
break;
default:
- up(&image[minor].sem);
+ mutex_unlock(&image[minor].mutex);
return -EINVAL;
break;
}
if ((absolute < 0) || (absolute >= image_size)) {
- up(&image[minor].sem);
+ mutex_unlock(&image[minor].mutex);
return -EINVAL;
}
file->f_pos = absolute;
- up(&image[minor].sem);
+ mutex_unlock(&image[minor].mutex);
return absolute;
}
@@ -475,7 +473,7 @@ static int vme_user_ioctl(struct inode *inode, struct file *file,
case CONTROL_MINOR:
switch (cmd) {
case VME_IRQ_GEN:
- copied = copy_from_user(&irq_req, (char *)arg,
+ copied = copy_from_user(&irq_req, argp,
sizeof(struct vme_irq_id));
if (copied != 0) {
printk(KERN_WARNING "Partial copy from userspace\n");
@@ -696,7 +694,7 @@ static int __devinit vme_user_probe(struct vme_dev *vdev)
for (i = 0; i < VME_DEVS; i++) {
image[i].kern_buf = NULL;
image[i].pci_buf = 0;
- sema_init(&image[i].sem, 1);
+ mutex_init(&image[i].mutex);
image[i].device = NULL;
image[i].resource = NULL;
image[i].users = 0;
@@ -858,8 +856,10 @@ static int __devexit vme_user_remove(struct vme_dev *dev)
int i;
/* Remove sysfs Entries */
- for (i = 0; i < VME_DEVS; i++)
+ for (i = 0; i < VME_DEVS; i++) {
+ mutex_destroy(&image[i].mutex);
device_destroy(vme_user_sysfs_class, MKDEV(VME_MAJOR, i));
+ }
class_destroy(vme_user_sysfs_class);
for (i = MASTER_MINOR; i < (MASTER_MAX + 1); i++) {
diff --git a/drivers/staging/vme/vme.c b/drivers/staging/vme/vme.c
deleted file mode 100644
index 70722ae52321..000000000000
--- a/drivers/staging/vme/vme.c
+++ /dev/null
@@ -1,1526 +0,0 @@
-/*
- * VME Bridge Framework
- *
- * Author: Martyn Welch <martyn.welch@ge.com>
- * Copyright 2008 GE Intelligent Platforms Embedded Systems, Inc.
- *
- * Based on work by Tom Armistead and Ajit Prem
- * Copyright 2004 Motorola 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.
- */
-
-#include <linux/module.h>
-#include <linux/moduleparam.h>
-#include <linux/mm.h>
-#include <linux/types.h>
-#include <linux/kernel.h>
-#include <linux/errno.h>
-#include <linux/pci.h>
-#include <linux/poll.h>
-#include <linux/highmem.h>
-#include <linux/interrupt.h>
-#include <linux/pagemap.h>
-#include <linux/device.h>
-#include <linux/dma-mapping.h>
-#include <linux/syscalls.h>
-#include <linux/mutex.h>
-#include <linux/spinlock.h>
-#include <linux/slab.h>
-
-#include "vme.h"
-#include "vme_bridge.h"
-
-/* Bitmask and list of registered buses both protected by common mutex */
-static unsigned int vme_bus_numbers;
-static LIST_HEAD(vme_bus_list);
-static DEFINE_MUTEX(vme_buses_lock);
-
-static void __exit vme_exit(void);
-static int __init vme_init(void);
-
-static struct vme_dev *dev_to_vme_dev(struct device *dev)
-{
- return container_of(dev, struct vme_dev, dev);
-}
-
-/*
- * Find the bridge that the resource is associated with.
- */
-static struct vme_bridge *find_bridge(struct vme_resource *resource)
-{
- /* Get list to search */
- switch (resource->type) {
- case VME_MASTER:
- return list_entry(resource->entry, struct vme_master_resource,
- list)->parent;
- break;
- case VME_SLAVE:
- return list_entry(resource->entry, struct vme_slave_resource,
- list)->parent;
- break;
- case VME_DMA:
- return list_entry(resource->entry, struct vme_dma_resource,
- list)->parent;
- break;
- case VME_LM:
- return list_entry(resource->entry, struct vme_lm_resource,
- list)->parent;
- break;
- default:
- printk(KERN_ERR "Unknown resource type\n");
- return NULL;
- break;
- }
-}
-
-/*
- * Allocate a contiguous block of memory for use by the driver. This is used to
- * create the buffers for the slave windows.
- */
-void *vme_alloc_consistent(struct vme_resource *resource, size_t size,
- dma_addr_t *dma)
-{
- struct vme_bridge *bridge;
-
- if (resource == NULL) {
- printk(KERN_ERR "No resource\n");
- return NULL;
- }
-
- bridge = find_bridge(resource);
- if (bridge == NULL) {
- printk(KERN_ERR "Can't find bridge\n");
- return NULL;
- }
-
- if (bridge->parent == NULL) {
- printk(KERN_ERR "Dev entry NULL for"
- " bridge %s\n", bridge->name);
- return NULL;
- }
-
- if (bridge->alloc_consistent == NULL) {
- printk(KERN_ERR "alloc_consistent not supported by"
- " bridge %s\n", bridge->name);
- return NULL;
- }
-
- return bridge->alloc_consistent(bridge->parent, size, dma);
-}
-EXPORT_SYMBOL(vme_alloc_consistent);
-
-/*
- * Free previously allocated contiguous block of memory.
- */
-void vme_free_consistent(struct vme_resource *resource, size_t size,
- void *vaddr, dma_addr_t dma)
-{
- struct vme_bridge *bridge;
-
- if (resource == NULL) {
- printk(KERN_ERR "No resource\n");
- return;
- }
-
- bridge = find_bridge(resource);
- if (bridge == NULL) {
- printk(KERN_ERR "Can't find bridge\n");
- return;
- }
-
- if (bridge->parent == NULL) {
- printk(KERN_ERR "Dev entry NULL for"
- " bridge %s\n", bridge->name);
- return;
- }
-
- if (bridge->free_consistent == NULL) {
- printk(KERN_ERR "free_consistent not supported by"
- " bridge %s\n", bridge->name);
- return;
- }
-
- bridge->free_consistent(bridge->parent, size, vaddr, dma);
-}
-EXPORT_SYMBOL(vme_free_consistent);
-
-size_t vme_get_size(struct vme_resource *resource)
-{
- int enabled, retval;
- unsigned long long base, size;
- dma_addr_t buf_base;
- u32 aspace, cycle, dwidth;
-
- switch (resource->type) {
- case VME_MASTER:
- retval = vme_master_get(resource, &enabled, &base, &size,
- &aspace, &cycle, &dwidth);
-
- return size;
- break;
- case VME_SLAVE:
- retval = vme_slave_get(resource, &enabled, &base, &size,
- &buf_base, &aspace, &cycle);
-
- return size;
- break;
- case VME_DMA:
- return 0;
- break;
- default:
- printk(KERN_ERR "Unknown resource type\n");
- return 0;
- break;
- }
-}
-EXPORT_SYMBOL(vme_get_size);
-
-static int vme_check_window(u32 aspace, unsigned long long vme_base,
- unsigned long long size)
-{
- int retval = 0;
-
- switch (aspace) {
- case VME_A16:
- if (((vme_base + size) > VME_A16_MAX) ||
- (vme_base > VME_A16_MAX))
- retval = -EFAULT;
- break;
- case VME_A24:
- if (((vme_base + size) > VME_A24_MAX) ||
- (vme_base > VME_A24_MAX))
- retval = -EFAULT;
- break;
- case VME_A32:
- if (((vme_base + size) > VME_A32_MAX) ||
- (vme_base > VME_A32_MAX))
- retval = -EFAULT;
- break;
- case VME_A64:
- /*
- * Any value held in an unsigned long long can be used as the
- * base
- */
- break;
- case VME_CRCSR:
- if (((vme_base + size) > VME_CRCSR_MAX) ||
- (vme_base > VME_CRCSR_MAX))
- retval = -EFAULT;
- break;
- case VME_USER1:
- case VME_USER2:
- case VME_USER3:
- case VME_USER4:
- /* User Defined */
- break;
- default:
- printk(KERN_ERR "Invalid address space\n");
- retval = -EINVAL;
- break;
- }
-
- return retval;
-}
-
-/*
- * Request a slave image with specific attributes, return some unique
- * identifier.
- */
-struct vme_resource *vme_slave_request(struct vme_dev *vdev, u32 address,
- u32 cycle)
-{
- struct vme_bridge *bridge;
- struct list_head *slave_pos = NULL;
- struct vme_slave_resource *allocated_image = NULL;
- struct vme_slave_resource *slave_image = NULL;
- struct vme_resource *resource = NULL;
-
- bridge = vdev->bridge;
- if (bridge == NULL) {
- printk(KERN_ERR "Can't find VME bus\n");
- goto err_bus;
- }
-
- /* Loop through slave resources */
- list_for_each(slave_pos, &bridge->slave_resources) {
- slave_image = list_entry(slave_pos,
- struct vme_slave_resource, list);
-
- if (slave_image == NULL) {
- printk(KERN_ERR "Registered NULL Slave resource\n");
- continue;
- }
-
- /* Find an unlocked and compatible image */
- mutex_lock(&slave_image->mtx);
- if (((slave_image->address_attr & address) == address) &&
- ((slave_image->cycle_attr & cycle) == cycle) &&
- (slave_image->locked == 0)) {
-
- slave_image->locked = 1;
- mutex_unlock(&slave_image->mtx);
- allocated_image = slave_image;
- break;
- }
- mutex_unlock(&slave_image->mtx);
- }
-
- /* No free image */
- if (allocated_image == NULL)
- goto err_image;
-
- resource = kmalloc(sizeof(struct vme_resource), GFP_KERNEL);
- if (resource == NULL) {
- printk(KERN_WARNING "Unable to allocate resource structure\n");
- goto err_alloc;
- }
- resource->type = VME_SLAVE;
- resource->entry = &allocated_image->list;
-
- return resource;
-
-err_alloc:
- /* Unlock image */
- mutex_lock(&slave_image->mtx);
- slave_image->locked = 0;
- mutex_unlock(&slave_image->mtx);
-err_image:
-err_bus:
- return NULL;
-}
-EXPORT_SYMBOL(vme_slave_request);
-
-int vme_slave_set(struct vme_resource *resource, int enabled,
- unsigned long long vme_base, unsigned long long size,
- dma_addr_t buf_base, u32 aspace, u32 cycle)
-{
- struct vme_bridge *bridge = find_bridge(resource);
- struct vme_slave_resource *image;
- int retval;
-
- if (resource->type != VME_SLAVE) {
- printk(KERN_ERR "Not a slave resource\n");
- return -EINVAL;
- }
-
- image = list_entry(resource->entry, struct vme_slave_resource, list);
-
- if (bridge->slave_set == NULL) {
- printk(KERN_ERR "Function not supported\n");
- return -ENOSYS;
- }
-
- if (!(((image->address_attr & aspace) == aspace) &&
- ((image->cycle_attr & cycle) == cycle))) {
- printk(KERN_ERR "Invalid attributes\n");
- return -EINVAL;
- }
-
- retval = vme_check_window(aspace, vme_base, size);
- if (retval)
- return retval;
-
- return bridge->slave_set(image, enabled, vme_base, size, buf_base,
- aspace, cycle);
-}
-EXPORT_SYMBOL(vme_slave_set);
-
-int vme_slave_get(struct vme_resource *resource, int *enabled,
- unsigned long long *vme_base, unsigned long long *size,
- dma_addr_t *buf_base, u32 *aspace, u32 *cycle)
-{
- struct vme_bridge *bridge = find_bridge(resource);
- struct vme_slave_resource *image;
-
- if (resource->type != VME_SLAVE) {
- printk(KERN_ERR "Not a slave resource\n");
- return -EINVAL;
- }
-
- image = list_entry(resource->entry, struct vme_slave_resource, list);
-
- if (bridge->slave_get == NULL) {
- printk(KERN_ERR "vme_slave_get not supported\n");
- return -EINVAL;
- }
-
- return bridge->slave_get(image, enabled, vme_base, size, buf_base,
- aspace, cycle);
-}
-EXPORT_SYMBOL(vme_slave_get);
-
-void vme_slave_free(struct vme_resource *resource)
-{
- struct vme_slave_resource *slave_image;
-
- if (resource->type != VME_SLAVE) {
- printk(KERN_ERR "Not a slave resource\n");
- return;
- }
-
- slave_image = list_entry(resource->entry, struct vme_slave_resource,
- list);
- if (slave_image == NULL) {
- printk(KERN_ERR "Can't find slave resource\n");
- return;
- }
-
- /* Unlock image */
- mutex_lock(&slave_image->mtx);
- if (slave_image->locked == 0)
- printk(KERN_ERR "Image is already free\n");
-
- slave_image->locked = 0;
- mutex_unlock(&slave_image->mtx);
-
- /* Free up resource memory */
- kfree(resource);
-}
-EXPORT_SYMBOL(vme_slave_free);
-
-/*
- * Request a master image with specific attributes, return some unique
- * identifier.
- */
-struct vme_resource *vme_master_request(struct vme_dev *vdev, u32 address,
- u32 cycle, u32 dwidth)
-{
- struct vme_bridge *bridge;
- struct list_head *master_pos = NULL;
- struct vme_master_resource *allocated_image = NULL;
- struct vme_master_resource *master_image = NULL;
- struct vme_resource *resource = NULL;
-
- bridge = vdev->bridge;
- if (bridge == NULL) {
- printk(KERN_ERR "Can't find VME bus\n");
- goto err_bus;
- }
-
- /* Loop through master resources */
- list_for_each(master_pos, &bridge->master_resources) {
- master_image = list_entry(master_pos,
- struct vme_master_resource, list);
-
- if (master_image == NULL) {
- printk(KERN_WARNING "Registered NULL master resource\n");
- continue;
- }
-
- /* Find an unlocked and compatible image */
- spin_lock(&master_image->lock);
- if (((master_image->address_attr & address) == address) &&
- ((master_image->cycle_attr & cycle) == cycle) &&
- ((master_image->width_attr & dwidth) == dwidth) &&
- (master_image->locked == 0)) {
-
- master_image->locked = 1;
- spin_unlock(&master_image->lock);
- allocated_image = master_image;
- break;
- }
- spin_unlock(&master_image->lock);
- }
-
- /* Check to see if we found a resource */
- if (allocated_image == NULL) {
- printk(KERN_ERR "Can't find a suitable resource\n");
- goto err_image;
- }
-
- resource = kmalloc(sizeof(struct vme_resource), GFP_KERNEL);
- if (resource == NULL) {
- printk(KERN_ERR "Unable to allocate resource structure\n");
- goto err_alloc;
- }
- resource->type = VME_MASTER;
- resource->entry = &allocated_image->list;
-
- return resource;
-
-err_alloc:
- /* Unlock image */
- spin_lock(&master_image->lock);
- master_image->locked = 0;
- spin_unlock(&master_image->lock);
-err_image:
-err_bus:
- return NULL;
-}
-EXPORT_SYMBOL(vme_master_request);
-
-int vme_master_set(struct vme_resource *resource, int enabled,
- unsigned long long vme_base, unsigned long long size, u32 aspace,
- u32 cycle, u32 dwidth)
-{
- struct vme_bridge *bridge = find_bridge(resource);
- struct vme_master_resource *image;
- int retval;
-
- if (resource->type != VME_MASTER) {
- printk(KERN_ERR "Not a master resource\n");
- return -EINVAL;
- }
-
- image = list_entry(resource->entry, struct vme_master_resource, list);
-
- if (bridge->master_set == NULL) {
- printk(KERN_WARNING "vme_master_set not supported\n");
- return -EINVAL;
- }
-
- if (!(((image->address_attr & aspace) == aspace) &&
- ((image->cycle_attr & cycle) == cycle) &&
- ((image->width_attr & dwidth) == dwidth))) {
- printk(KERN_WARNING "Invalid attributes\n");
- return -EINVAL;
- }
-
- retval = vme_check_window(aspace, vme_base, size);
- if (retval)
- return retval;
-
- return bridge->master_set(image, enabled, vme_base, size, aspace,
- cycle, dwidth);
-}
-EXPORT_SYMBOL(vme_master_set);
-
-int vme_master_get(struct vme_resource *resource, int *enabled,
- unsigned long long *vme_base, unsigned long long *size, u32 *aspace,
- u32 *cycle, u32 *dwidth)
-{
- struct vme_bridge *bridge = find_bridge(resource);
- struct vme_master_resource *image;
-
- if (resource->type != VME_MASTER) {
- printk(KERN_ERR "Not a master resource\n");
- return -EINVAL;
- }
-
- image = list_entry(resource->entry, struct vme_master_resource, list);
-
- if (bridge->master_get == NULL) {
- printk(KERN_WARNING "vme_master_set not supported\n");
- return -EINVAL;
- }
-
- return bridge->master_get(image, enabled, vme_base, size, aspace,
- cycle, dwidth);
-}
-EXPORT_SYMBOL(vme_master_get);
-
-/*
- * Read data out of VME space into a buffer.
- */
-ssize_t vme_master_read(struct vme_resource *resource, void *buf, size_t count,
- loff_t offset)
-{
- struct vme_bridge *bridge = find_bridge(resource);
- struct vme_master_resource *image;
- size_t length;
-
- if (bridge->master_read == NULL) {
- printk(KERN_WARNING "Reading from resource not supported\n");
- return -EINVAL;
- }
-
- if (resource->type != VME_MASTER) {
- printk(KERN_ERR "Not a master resource\n");
- return -EINVAL;
- }
-
- image = list_entry(resource->entry, struct vme_master_resource, list);
-
- length = vme_get_size(resource);
-
- if (offset > length) {
- printk(KERN_WARNING "Invalid Offset\n");
- return -EFAULT;
- }
-
- if ((offset + count) > length)
- count = length - offset;
-
- return bridge->master_read(image, buf, count, offset);
-
-}
-EXPORT_SYMBOL(vme_master_read);
-
-/*
- * Write data out to VME space from a buffer.
- */
-ssize_t vme_master_write(struct vme_resource *resource, void *buf,
- size_t count, loff_t offset)
-{
- struct vme_bridge *bridge = find_bridge(resource);
- struct vme_master_resource *image;
- size_t length;
-
- if (bridge->master_write == NULL) {
- printk(KERN_WARNING "Writing to resource not supported\n");
- return -EINVAL;
- }
-
- if (resource->type != VME_MASTER) {
- printk(KERN_ERR "Not a master resource\n");
- return -EINVAL;
- }
-
- image = list_entry(resource->entry, struct vme_master_resource, list);
-
- length = vme_get_size(resource);
-
- if (offset > length) {
- printk(KERN_WARNING "Invalid Offset\n");
- return -EFAULT;
- }
-
- if ((offset + count) > length)
- count = length - offset;
-
- return bridge->master_write(image, buf, count, offset);
-}
-EXPORT_SYMBOL(vme_master_write);
-
-/*
- * Perform RMW cycle to provided location.
- */
-unsigned int vme_master_rmw(struct vme_resource *resource, unsigned int mask,
- unsigned int compare, unsigned int swap, loff_t offset)
-{
- struct vme_bridge *bridge = find_bridge(resource);
- struct vme_master_resource *image;
-
- if (bridge->master_rmw == NULL) {
- printk(KERN_WARNING "Writing to resource not supported\n");
- return -EINVAL;
- }
-
- if (resource->type != VME_MASTER) {
- printk(KERN_ERR "Not a master resource\n");
- return -EINVAL;
- }
-
- image = list_entry(resource->entry, struct vme_master_resource, list);
-
- return bridge->master_rmw(image, mask, compare, swap, offset);
-}
-EXPORT_SYMBOL(vme_master_rmw);
-
-void vme_master_free(struct vme_resource *resource)
-{
- struct vme_master_resource *master_image;
-
- if (resource->type != VME_MASTER) {
- printk(KERN_ERR "Not a master resource\n");
- return;
- }
-
- master_image = list_entry(resource->entry, struct vme_master_resource,
- list);
- if (master_image == NULL) {
- printk(KERN_ERR "Can't find master resource\n");
- return;
- }
-
- /* Unlock image */
- spin_lock(&master_image->lock);
- if (master_image->locked == 0)
- printk(KERN_ERR "Image is already free\n");
-
- master_image->locked = 0;
- spin_unlock(&master_image->lock);
-
- /* Free up resource memory */
- kfree(resource);
-}
-EXPORT_SYMBOL(vme_master_free);
-
-/*
- * Request a DMA controller with specific attributes, return some unique
- * identifier.
- */
-struct vme_resource *vme_dma_request(struct vme_dev *vdev, u32 route)
-{
- struct vme_bridge *bridge;
- struct list_head *dma_pos = NULL;
- struct vme_dma_resource *allocated_ctrlr = NULL;
- struct vme_dma_resource *dma_ctrlr = NULL;
- struct vme_resource *resource = NULL;
-
- /* XXX Not checking resource attributes */
- printk(KERN_ERR "No VME resource Attribute tests done\n");
-
- bridge = vdev->bridge;
- if (bridge == NULL) {
- printk(KERN_ERR "Can't find VME bus\n");
- goto err_bus;
- }
-
- /* Loop through DMA resources */
- list_for_each(dma_pos, &bridge->dma_resources) {
- dma_ctrlr = list_entry(dma_pos,
- struct vme_dma_resource, list);
-
- if (dma_ctrlr == NULL) {
- printk(KERN_ERR "Registered NULL DMA resource\n");
- continue;
- }
-
- /* Find an unlocked and compatible controller */
- mutex_lock(&dma_ctrlr->mtx);
- if (((dma_ctrlr->route_attr & route) == route) &&
- (dma_ctrlr->locked == 0)) {
-
- dma_ctrlr->locked = 1;
- mutex_unlock(&dma_ctrlr->mtx);
- allocated_ctrlr = dma_ctrlr;
- break;
- }
- mutex_unlock(&dma_ctrlr->mtx);
- }
-
- /* Check to see if we found a resource */
- if (allocated_ctrlr == NULL)
- goto err_ctrlr;
-
- resource = kmalloc(sizeof(struct vme_resource), GFP_KERNEL);
- if (resource == NULL) {
- printk(KERN_WARNING "Unable to allocate resource structure\n");
- goto err_alloc;
- }
- resource->type = VME_DMA;
- resource->entry = &allocated_ctrlr->list;
-
- return resource;
-
-err_alloc:
- /* Unlock image */
- mutex_lock(&dma_ctrlr->mtx);
- dma_ctrlr->locked = 0;
- mutex_unlock(&dma_ctrlr->mtx);
-err_ctrlr:
-err_bus:
- return NULL;
-}
-EXPORT_SYMBOL(vme_dma_request);
-
-/*
- * Start new list
- */
-struct vme_dma_list *vme_new_dma_list(struct vme_resource *resource)
-{
- struct vme_dma_resource *ctrlr;
- struct vme_dma_list *dma_list;
-
- if (resource->type != VME_DMA) {
- printk(KERN_ERR "Not a DMA resource\n");
- return NULL;
- }
-
- ctrlr = list_entry(resource->entry, struct vme_dma_resource, list);
-
- dma_list = kmalloc(sizeof(struct vme_dma_list), GFP_KERNEL);
- if (dma_list == NULL) {
- printk(KERN_ERR "Unable to allocate memory for new dma list\n");
- return NULL;
- }
- INIT_LIST_HEAD(&dma_list->entries);
- dma_list->parent = ctrlr;
- mutex_init(&dma_list->mtx);
-
- return dma_list;
-}
-EXPORT_SYMBOL(vme_new_dma_list);
-
-/*
- * Create "Pattern" type attributes
- */
-struct vme_dma_attr *vme_dma_pattern_attribute(u32 pattern, u32 type)
-{
- struct vme_dma_attr *attributes;
- struct vme_dma_pattern *pattern_attr;
-
- attributes = kmalloc(sizeof(struct vme_dma_attr), GFP_KERNEL);
- if (attributes == NULL) {
- printk(KERN_ERR "Unable to allocate memory for attributes "
- "structure\n");
- goto err_attr;
- }
-
- pattern_attr = kmalloc(sizeof(struct vme_dma_pattern), GFP_KERNEL);
- if (pattern_attr == NULL) {
- printk(KERN_ERR "Unable to allocate memory for pattern "
- "attributes\n");
- goto err_pat;
- }
-
- attributes->type = VME_DMA_PATTERN;
- attributes->private = (void *)pattern_attr;
-
- pattern_attr->pattern = pattern;
- pattern_attr->type = type;
-
- return attributes;
-
-err_pat:
- kfree(attributes);
-err_attr:
- return NULL;
-}
-EXPORT_SYMBOL(vme_dma_pattern_attribute);
-
-/*
- * Create "PCI" type attributes
- */
-struct vme_dma_attr *vme_dma_pci_attribute(dma_addr_t address)
-{
- struct vme_dma_attr *attributes;
- struct vme_dma_pci *pci_attr;
-
- /* XXX Run some sanity checks here */
-
- attributes = kmalloc(sizeof(struct vme_dma_attr), GFP_KERNEL);
- if (attributes == NULL) {
- printk(KERN_ERR "Unable to allocate memory for attributes "
- "structure\n");
- goto err_attr;
- }
-
- pci_attr = kmalloc(sizeof(struct vme_dma_pci), GFP_KERNEL);
- if (pci_attr == NULL) {
- printk(KERN_ERR "Unable to allocate memory for pci "
- "attributes\n");
- goto err_pci;
- }
-
-
-
- attributes->type = VME_DMA_PCI;
- attributes->private = (void *)pci_attr;
-
- pci_attr->address = address;
-
- return attributes;
-
-err_pci:
- kfree(attributes);
-err_attr:
- return NULL;
-}
-EXPORT_SYMBOL(vme_dma_pci_attribute);
-
-/*
- * Create "VME" type attributes
- */
-struct vme_dma_attr *vme_dma_vme_attribute(unsigned long long address,
- u32 aspace, u32 cycle, u32 dwidth)
-{
- struct vme_dma_attr *attributes;
- struct vme_dma_vme *vme_attr;
-
- attributes = kmalloc(
- sizeof(struct vme_dma_attr), GFP_KERNEL);
- if (attributes == NULL) {
- printk(KERN_ERR "Unable to allocate memory for attributes "
- "structure\n");
- goto err_attr;
- }
-
- vme_attr = kmalloc(sizeof(struct vme_dma_vme), GFP_KERNEL);
- if (vme_attr == NULL) {
- printk(KERN_ERR "Unable to allocate memory for vme "
- "attributes\n");
- goto err_vme;
- }
-
- attributes->type = VME_DMA_VME;
- attributes->private = (void *)vme_attr;
-
- vme_attr->address = address;
- vme_attr->aspace = aspace;
- vme_attr->cycle = cycle;
- vme_attr->dwidth = dwidth;
-
- return attributes;
-
-err_vme:
- kfree(attributes);
-err_attr:
- return NULL;
-}
-EXPORT_SYMBOL(vme_dma_vme_attribute);
-
-/*
- * Free attribute
- */
-void vme_dma_free_attribute(struct vme_dma_attr *attributes)
-{
- kfree(attributes->private);
- kfree(attributes);
-}
-EXPORT_SYMBOL(vme_dma_free_attribute);
-
-int vme_dma_list_add(struct vme_dma_list *list, struct vme_dma_attr *src,
- struct vme_dma_attr *dest, size_t count)
-{
- struct vme_bridge *bridge = list->parent->parent;
- int retval;
-
- if (bridge->dma_list_add == NULL) {
- printk(KERN_WARNING "Link List DMA generation not supported\n");
- return -EINVAL;
- }
-
- if (!mutex_trylock(&list->mtx)) {
- printk(KERN_ERR "Link List already submitted\n");
- return -EINVAL;
- }
-
- retval = bridge->dma_list_add(list, src, dest, count);
-
- mutex_unlock(&list->mtx);
-
- return retval;
-}
-EXPORT_SYMBOL(vme_dma_list_add);
-
-int vme_dma_list_exec(struct vme_dma_list *list)
-{
- struct vme_bridge *bridge = list->parent->parent;
- int retval;
-
- if (bridge->dma_list_exec == NULL) {
- printk(KERN_ERR "Link List DMA execution not supported\n");
- return -EINVAL;
- }
-
- mutex_lock(&list->mtx);
-
- retval = bridge->dma_list_exec(list);
-
- mutex_unlock(&list->mtx);
-
- return retval;
-}
-EXPORT_SYMBOL(vme_dma_list_exec);
-
-int vme_dma_list_free(struct vme_dma_list *list)
-{
- struct vme_bridge *bridge = list->parent->parent;
- int retval;
-
- if (bridge->dma_list_empty == NULL) {
- printk(KERN_WARNING "Emptying of Link Lists not supported\n");
- return -EINVAL;
- }
-
- if (!mutex_trylock(&list->mtx)) {
- printk(KERN_ERR "Link List in use\n");
- return -EINVAL;
- }
-
- /*
- * Empty out all of the entries from the dma list. We need to go to the
- * low level driver as dma entries are driver specific.
- */
- retval = bridge->dma_list_empty(list);
- if (retval) {
- printk(KERN_ERR "Unable to empty link-list entries\n");
- mutex_unlock(&list->mtx);
- return retval;
- }
- mutex_unlock(&list->mtx);
- kfree(list);
-
- return retval;
-}
-EXPORT_SYMBOL(vme_dma_list_free);
-
-int vme_dma_free(struct vme_resource *resource)
-{
- struct vme_dma_resource *ctrlr;
-
- if (resource->type != VME_DMA) {
- printk(KERN_ERR "Not a DMA resource\n");
- return -EINVAL;
- }
-
- ctrlr = list_entry(resource->entry, struct vme_dma_resource, list);
-
- if (!mutex_trylock(&ctrlr->mtx)) {
- printk(KERN_ERR "Resource busy, can't free\n");
- return -EBUSY;
- }
-
- if (!(list_empty(&ctrlr->pending) && list_empty(&ctrlr->running))) {
- printk(KERN_WARNING "Resource still processing transfers\n");
- mutex_unlock(&ctrlr->mtx);
- return -EBUSY;
- }
-
- ctrlr->locked = 0;
-
- mutex_unlock(&ctrlr->mtx);
-
- return 0;
-}
-EXPORT_SYMBOL(vme_dma_free);
-
-void vme_irq_handler(struct vme_bridge *bridge, int level, int statid)
-{
- void (*call)(int, int, void *);
- void *priv_data;
-
- call = bridge->irq[level - 1].callback[statid].func;
- priv_data = bridge->irq[level - 1].callback[statid].priv_data;
-
- if (call != NULL)
- call(level, statid, priv_data);
- else
- printk(KERN_WARNING "Spurilous VME interrupt, level:%x, "
- "vector:%x\n", level, statid);
-}
-EXPORT_SYMBOL(vme_irq_handler);
-
-int vme_irq_request(struct vme_dev *vdev, int level, int statid,
- void (*callback)(int, int, void *),
- void *priv_data)
-{
- struct vme_bridge *bridge;
-
- bridge = vdev->bridge;
- if (bridge == NULL) {
- printk(KERN_ERR "Can't find VME bus\n");
- return -EINVAL;
- }
-
- if ((level < 1) || (level > 7)) {
- printk(KERN_ERR "Invalid interrupt level\n");
- return -EINVAL;
- }
-
- if (bridge->irq_set == NULL) {
- printk(KERN_ERR "Configuring interrupts not supported\n");
- return -EINVAL;
- }
-
- mutex_lock(&bridge->irq_mtx);
-
- if (bridge->irq[level - 1].callback[statid].func) {
- mutex_unlock(&bridge->irq_mtx);
- printk(KERN_WARNING "VME Interrupt already taken\n");
- return -EBUSY;
- }
-
- bridge->irq[level - 1].count++;
- bridge->irq[level - 1].callback[statid].priv_data = priv_data;
- bridge->irq[level - 1].callback[statid].func = callback;
-
- /* Enable IRQ level */
- bridge->irq_set(bridge, level, 1, 1);
-
- mutex_unlock(&bridge->irq_mtx);
-
- return 0;
-}
-EXPORT_SYMBOL(vme_irq_request);
-
-void vme_irq_free(struct vme_dev *vdev, int level, int statid)
-{
- struct vme_bridge *bridge;
-
- bridge = vdev->bridge;
- if (bridge == NULL) {
- printk(KERN_ERR "Can't find VME bus\n");
- return;
- }
-
- if ((level < 1) || (level > 7)) {
- printk(KERN_ERR "Invalid interrupt level\n");
- return;
- }
-
- if (bridge->irq_set == NULL) {
- printk(KERN_ERR "Configuring interrupts not supported\n");
- return;
- }
-
- mutex_lock(&bridge->irq_mtx);
-
- bridge->irq[level - 1].count--;
-
- /* Disable IRQ level if no more interrupts attached at this level*/
- if (bridge->irq[level - 1].count == 0)
- bridge->irq_set(bridge, level, 0, 1);
-
- bridge->irq[level - 1].callback[statid].func = NULL;
- bridge->irq[level - 1].callback[statid].priv_data = NULL;
-
- mutex_unlock(&bridge->irq_mtx);
-}
-EXPORT_SYMBOL(vme_irq_free);
-
-int vme_irq_generate(struct vme_dev *vdev, int level, int statid)
-{
- struct vme_bridge *bridge;
-
- bridge = vdev->bridge;
- if (bridge == NULL) {
- printk(KERN_ERR "Can't find VME bus\n");
- return -EINVAL;
- }
-
- if ((level < 1) || (level > 7)) {
- printk(KERN_WARNING "Invalid interrupt level\n");
- return -EINVAL;
- }
-
- if (bridge->irq_generate == NULL) {
- printk(KERN_WARNING "Interrupt generation not supported\n");
- return -EINVAL;
- }
-
- return bridge->irq_generate(bridge, level, statid);
-}
-EXPORT_SYMBOL(vme_irq_generate);
-
-/*
- * Request the location monitor, return resource or NULL
- */
-struct vme_resource *vme_lm_request(struct vme_dev *vdev)
-{
- struct vme_bridge *bridge;
- struct list_head *lm_pos = NULL;
- struct vme_lm_resource *allocated_lm = NULL;
- struct vme_lm_resource *lm = NULL;
- struct vme_resource *resource = NULL;
-
- bridge = vdev->bridge;
- if (bridge == NULL) {
- printk(KERN_ERR "Can't find VME bus\n");
- goto err_bus;
- }
-
- /* Loop through DMA resources */
- list_for_each(lm_pos, &bridge->lm_resources) {
- lm = list_entry(lm_pos,
- struct vme_lm_resource, list);
-
- if (lm == NULL) {
- printk(KERN_ERR "Registered NULL Location Monitor "
- "resource\n");
- continue;
- }
-
- /* Find an unlocked controller */
- mutex_lock(&lm->mtx);
- if (lm->locked == 0) {
- lm->locked = 1;
- mutex_unlock(&lm->mtx);
- allocated_lm = lm;
- break;
- }
- mutex_unlock(&lm->mtx);
- }
-
- /* Check to see if we found a resource */
- if (allocated_lm == NULL)
- goto err_lm;
-
- resource = kmalloc(sizeof(struct vme_resource), GFP_KERNEL);
- if (resource == NULL) {
- printk(KERN_ERR "Unable to allocate resource structure\n");
- goto err_alloc;
- }
- resource->type = VME_LM;
- resource->entry = &allocated_lm->list;
-
- return resource;
-
-err_alloc:
- /* Unlock image */
- mutex_lock(&lm->mtx);
- lm->locked = 0;
- mutex_unlock(&lm->mtx);
-err_lm:
-err_bus:
- return NULL;
-}
-EXPORT_SYMBOL(vme_lm_request);
-
-int vme_lm_count(struct vme_resource *resource)
-{
- struct vme_lm_resource *lm;
-
- if (resource->type != VME_LM) {
- printk(KERN_ERR "Not a Location Monitor resource\n");
- return -EINVAL;
- }
-
- lm = list_entry(resource->entry, struct vme_lm_resource, list);
-
- return lm->monitors;
-}
-EXPORT_SYMBOL(vme_lm_count);
-
-int vme_lm_set(struct vme_resource *resource, unsigned long long lm_base,
- u32 aspace, u32 cycle)
-{
- struct vme_bridge *bridge = find_bridge(resource);
- struct vme_lm_resource *lm;
-
- if (resource->type != VME_LM) {
- printk(KERN_ERR "Not a Location Monitor resource\n");
- return -EINVAL;
- }
-
- lm = list_entry(resource->entry, struct vme_lm_resource, list);
-
- if (bridge->lm_set == NULL) {
- printk(KERN_ERR "vme_lm_set not supported\n");
- return -EINVAL;
- }
-
- return bridge->lm_set(lm, lm_base, aspace, cycle);
-}
-EXPORT_SYMBOL(vme_lm_set);
-
-int vme_lm_get(struct vme_resource *resource, unsigned long long *lm_base,
- u32 *aspace, u32 *cycle)
-{
- struct vme_bridge *bridge = find_bridge(resource);
- struct vme_lm_resource *lm;
-
- if (resource->type != VME_LM) {
- printk(KERN_ERR "Not a Location Monitor resource\n");
- return -EINVAL;
- }
-
- lm = list_entry(resource->entry, struct vme_lm_resource, list);
-
- if (bridge->lm_get == NULL) {
- printk(KERN_ERR "vme_lm_get not supported\n");
- return -EINVAL;
- }
-
- return bridge->lm_get(lm, lm_base, aspace, cycle);
-}
-EXPORT_SYMBOL(vme_lm_get);
-
-int vme_lm_attach(struct vme_resource *resource, int monitor,
- void (*callback)(int))
-{
- struct vme_bridge *bridge = find_bridge(resource);
- struct vme_lm_resource *lm;
-
- if (resource->type != VME_LM) {
- printk(KERN_ERR "Not a Location Monitor resource\n");
- return -EINVAL;
- }
-
- lm = list_entry(resource->entry, struct vme_lm_resource, list);
-
- if (bridge->lm_attach == NULL) {
- printk(KERN_ERR "vme_lm_attach not supported\n");
- return -EINVAL;
- }
-
- return bridge->lm_attach(lm, monitor, callback);
-}
-EXPORT_SYMBOL(vme_lm_attach);
-
-int vme_lm_detach(struct vme_resource *resource, int monitor)
-{
- struct vme_bridge *bridge = find_bridge(resource);
- struct vme_lm_resource *lm;
-
- if (resource->type != VME_LM) {
- printk(KERN_ERR "Not a Location Monitor resource\n");
- return -EINVAL;
- }
-
- lm = list_entry(resource->entry, struct vme_lm_resource, list);
-
- if (bridge->lm_detach == NULL) {
- printk(KERN_ERR "vme_lm_detach not supported\n");
- return -EINVAL;
- }
-
- return bridge->lm_detach(lm, monitor);
-}
-EXPORT_SYMBOL(vme_lm_detach);
-
-void vme_lm_free(struct vme_resource *resource)
-{
- struct vme_lm_resource *lm;
-
- if (resource->type != VME_LM) {
- printk(KERN_ERR "Not a Location Monitor resource\n");
- return;
- }
-
- lm = list_entry(resource->entry, struct vme_lm_resource, list);
-
- mutex_lock(&lm->mtx);
-
- /* XXX
- * Check to see that there aren't any callbacks still attached, if
- * there are we should probably be detaching them!
- */
-
- lm->locked = 0;
-
- mutex_unlock(&lm->mtx);
-
- kfree(resource);
-}
-EXPORT_SYMBOL(vme_lm_free);
-
-int vme_slot_get(struct vme_dev *vdev)
-{
- struct vme_bridge *bridge;
-
- bridge = vdev->bridge;
- if (bridge == NULL) {
- printk(KERN_ERR "Can't find VME bus\n");
- return -EINVAL;
- }
-
- if (bridge->slot_get == NULL) {
- printk(KERN_WARNING "vme_slot_get not supported\n");
- return -EINVAL;
- }
-
- return bridge->slot_get(bridge);
-}
-EXPORT_SYMBOL(vme_slot_get);
-
-
-/* - Bridge Registration --------------------------------------------------- */
-
-static void vme_dev_release(struct device *dev)
-{
- kfree(dev_to_vme_dev(dev));
-}
-
-int vme_register_bridge(struct vme_bridge *bridge)
-{
- int i;
- int ret = -1;
-
- mutex_lock(&vme_buses_lock);
- for (i = 0; i < sizeof(vme_bus_numbers) * 8; i++) {
- if ((vme_bus_numbers & (1 << i)) == 0) {
- vme_bus_numbers |= (1 << i);
- bridge->num = i;
- INIT_LIST_HEAD(&bridge->devices);
- list_add_tail(&bridge->bus_list, &vme_bus_list);
- ret = 0;
- break;
- }
- }
- mutex_unlock(&vme_buses_lock);
-
- return ret;
-}
-EXPORT_SYMBOL(vme_register_bridge);
-
-void vme_unregister_bridge(struct vme_bridge *bridge)
-{
- struct vme_dev *vdev;
- struct vme_dev *tmp;
-
- mutex_lock(&vme_buses_lock);
- vme_bus_numbers &= ~(1 << bridge->num);
- list_for_each_entry_safe(vdev, tmp, &bridge->devices, bridge_list) {
- list_del(&vdev->drv_list);
- list_del(&vdev->bridge_list);
- device_unregister(&vdev->dev);
- }
- list_del(&bridge->bus_list);
- mutex_unlock(&vme_buses_lock);
-}
-EXPORT_SYMBOL(vme_unregister_bridge);
-
-/* - Driver Registration --------------------------------------------------- */
-
-static int __vme_register_driver_bus(struct vme_driver *drv,
- struct vme_bridge *bridge, unsigned int ndevs)
-{
- int err;
- unsigned int i;
- struct vme_dev *vdev;
- struct vme_dev *tmp;
-
- for (i = 0; i < ndevs; i++) {
- vdev = kzalloc(sizeof(struct vme_dev), GFP_KERNEL);
- if (!vdev) {
- err = -ENOMEM;
- goto err_devalloc;
- }
- vdev->num = i;
- vdev->bridge = bridge;
- vdev->dev.platform_data = drv;
- vdev->dev.release = vme_dev_release;
- vdev->dev.parent = bridge->parent;
- vdev->dev.bus = &vme_bus_type;
- dev_set_name(&vdev->dev, "%s.%u-%u", drv->name, bridge->num,
- vdev->num);
-
- err = device_register(&vdev->dev);
- if (err)
- goto err_reg;
-
- if (vdev->dev.platform_data) {
- list_add_tail(&vdev->drv_list, &drv->devices);
- list_add_tail(&vdev->bridge_list, &bridge->devices);
- } else
- device_unregister(&vdev->dev);
- }
- return 0;
-
-err_reg:
- kfree(vdev);
-err_devalloc:
- list_for_each_entry_safe(vdev, tmp, &drv->devices, drv_list) {
- list_del(&vdev->drv_list);
- list_del(&vdev->bridge_list);
- device_unregister(&vdev->dev);
- }
- return err;
-}
-
-static int __vme_register_driver(struct vme_driver *drv, unsigned int ndevs)
-{
- struct vme_bridge *bridge;
- int err = 0;
-
- mutex_lock(&vme_buses_lock);
- list_for_each_entry(bridge, &vme_bus_list, bus_list) {
- /*
- * This cannot cause trouble as we already have vme_buses_lock
- * and if the bridge is removed, it will have to go through
- * vme_unregister_bridge() to do it (which calls remove() on
- * the bridge which in turn tries to acquire vme_buses_lock and
- * will have to wait).
- */
- err = __vme_register_driver_bus(drv, bridge, ndevs);
- if (err)
- break;
- }
- mutex_unlock(&vme_buses_lock);
- return err;
-}
-
-int vme_register_driver(struct vme_driver *drv, unsigned int ndevs)
-{
- int err;
-
- drv->driver.name = drv->name;
- drv->driver.bus = &vme_bus_type;
- INIT_LIST_HEAD(&drv->devices);
-
- err = driver_register(&drv->driver);
- if (err)
- return err;
-
- err = __vme_register_driver(drv, ndevs);
- if (err)
- driver_unregister(&drv->driver);
-
- return err;
-}
-EXPORT_SYMBOL(vme_register_driver);
-
-void vme_unregister_driver(struct vme_driver *drv)
-{
- struct vme_dev *dev, *dev_tmp;
-
- mutex_lock(&vme_buses_lock);
- list_for_each_entry_safe(dev, dev_tmp, &drv->devices, drv_list) {
- list_del(&dev->drv_list);
- list_del(&dev->bridge_list);
- device_unregister(&dev->dev);
- }
- mutex_unlock(&vme_buses_lock);
-
- driver_unregister(&drv->driver);
-}
-EXPORT_SYMBOL(vme_unregister_driver);
-
-/* - Bus Registration ------------------------------------------------------ */
-
-static int vme_bus_match(struct device *dev, struct device_driver *drv)
-{
- struct vme_driver *vme_drv;
-
- vme_drv = container_of(drv, struct vme_driver, driver);
-
- if (dev->platform_data == vme_drv) {
- struct vme_dev *vdev = dev_to_vme_dev(dev);
-
- if (vme_drv->match && vme_drv->match(vdev))
- return 1;
-
- dev->platform_data = NULL;
- }
- return 0;
-}
-
-static int vme_bus_probe(struct device *dev)
-{
- int retval = -ENODEV;
- struct vme_driver *driver;
- struct vme_dev *vdev = dev_to_vme_dev(dev);
-
- driver = dev->platform_data;
-
- if (driver->probe != NULL)
- retval = driver->probe(vdev);
-
- return retval;
-}
-
-static int vme_bus_remove(struct device *dev)
-{
- int retval = -ENODEV;
- struct vme_driver *driver;
- struct vme_dev *vdev = dev_to_vme_dev(dev);
-
- driver = dev->platform_data;
-
- if (driver->remove != NULL)
- retval = driver->remove(vdev);
-
- return retval;
-}
-
-struct bus_type vme_bus_type = {
- .name = "vme",
- .match = vme_bus_match,
- .probe = vme_bus_probe,
- .remove = vme_bus_remove,
-};
-EXPORT_SYMBOL(vme_bus_type);
-
-static int __init vme_init(void)
-{
- return bus_register(&vme_bus_type);
-}
-
-static void __exit vme_exit(void)
-{
- bus_unregister(&vme_bus_type);
-}
-
-MODULE_DESCRIPTION("VME bridge driver framework");
-MODULE_AUTHOR("Martyn Welch <martyn.welch@ge.com");
-MODULE_LICENSE("GPL");
-
-module_init(vme_init);
-module_exit(vme_exit);
diff --git a/drivers/staging/vme/vme.h b/drivers/staging/vme/vme.h
deleted file mode 100644
index c9d65bf14cec..000000000000
--- a/drivers/staging/vme/vme.h
+++ /dev/null
@@ -1,174 +0,0 @@
-#ifndef _VME_H_
-#define _VME_H_
-
-/* Resource Type */
-enum vme_resource_type {
- VME_MASTER,
- VME_SLAVE,
- VME_DMA,
- VME_LM
-};
-
-/* VME Address Spaces */
-#define VME_A16 0x1
-#define VME_A24 0x2
-#define VME_A32 0x4
-#define VME_A64 0x8
-#define VME_CRCSR 0x10
-#define VME_USER1 0x20
-#define VME_USER2 0x40
-#define VME_USER3 0x80
-#define VME_USER4 0x100
-
-#define VME_A16_MAX 0x10000ULL
-#define VME_A24_MAX 0x1000000ULL
-#define VME_A32_MAX 0x100000000ULL
-#define VME_A64_MAX 0x10000000000000000ULL
-#define VME_CRCSR_MAX 0x1000000ULL
-
-
-/* VME Cycle Types */
-#define VME_SCT 0x1
-#define VME_BLT 0x2
-#define VME_MBLT 0x4
-#define VME_2eVME 0x8
-#define VME_2eSST 0x10
-#define VME_2eSSTB 0x20
-
-#define VME_2eSST160 0x100
-#define VME_2eSST267 0x200
-#define VME_2eSST320 0x400
-
-#define VME_SUPER 0x1000
-#define VME_USER 0x2000
-#define VME_PROG 0x4000
-#define VME_DATA 0x8000
-
-/* VME Data Widths */
-#define VME_D8 0x1
-#define VME_D16 0x2
-#define VME_D32 0x4
-#define VME_D64 0x8
-
-/* Arbitration Scheduling Modes */
-#define VME_R_ROBIN_MODE 0x1
-#define VME_PRIORITY_MODE 0x2
-
-#define VME_DMA_PATTERN (1<<0)
-#define VME_DMA_PCI (1<<1)
-#define VME_DMA_VME (1<<2)
-
-#define VME_DMA_PATTERN_BYTE (1<<0)
-#define VME_DMA_PATTERN_WORD (1<<1)
-#define VME_DMA_PATTERN_INCREMENT (1<<2)
-
-#define VME_DMA_VME_TO_MEM (1<<0)
-#define VME_DMA_MEM_TO_VME (1<<1)
-#define VME_DMA_VME_TO_VME (1<<2)
-#define VME_DMA_MEM_TO_MEM (1<<3)
-#define VME_DMA_PATTERN_TO_VME (1<<4)
-#define VME_DMA_PATTERN_TO_MEM (1<<5)
-
-struct vme_dma_attr {
- u32 type;
- void *private;
-};
-
-struct vme_resource {
- enum vme_resource_type type;
- struct list_head *entry;
-};
-
-extern struct bus_type vme_bus_type;
-
-/* VME_MAX_BRIDGES comes from the type of vme_bus_numbers */
-#define VME_MAX_BRIDGES (sizeof(unsigned int)*8)
-#define VME_MAX_SLOTS 32
-
-#define VME_SLOT_CURRENT -1
-#define VME_SLOT_ALL -2
-
-/**
- * Structure representing a VME device
- * @num: The device number
- * @bridge: Pointer to the bridge device this device is on
- * @dev: Internal device structure
- * @drv_list: List of devices (per driver)
- * @bridge_list: List of devices (per bridge)
- */
-struct vme_dev {
- int num;
- struct vme_bridge *bridge;
- struct device dev;
- struct list_head drv_list;
- struct list_head bridge_list;
-};
-
-struct vme_driver {
- struct list_head node;
- const char *name;
- int (*match)(struct vme_dev *);
- int (*probe)(struct vme_dev *);
- int (*remove)(struct vme_dev *);
- void (*shutdown)(void);
- struct device_driver driver;
- struct list_head devices;
-};
-
-void *vme_alloc_consistent(struct vme_resource *, size_t, dma_addr_t *);
-void vme_free_consistent(struct vme_resource *, size_t, void *,
- dma_addr_t);
-
-size_t vme_get_size(struct vme_resource *);
-
-struct vme_resource *vme_slave_request(struct vme_dev *, u32, u32);
-int vme_slave_set(struct vme_resource *, int, unsigned long long,
- unsigned long long, dma_addr_t, u32, u32);
-int vme_slave_get(struct vme_resource *, int *, unsigned long long *,
- unsigned long long *, dma_addr_t *, u32 *, u32 *);
-void vme_slave_free(struct vme_resource *);
-
-struct vme_resource *vme_master_request(struct vme_dev *, u32, u32, u32);
-int vme_master_set(struct vme_resource *, int, unsigned long long,
- unsigned long long, u32, u32, u32);
-int vme_master_get(struct vme_resource *, int *, unsigned long long *,
- unsigned long long *, u32 *, u32 *, u32 *);
-ssize_t vme_master_read(struct vme_resource *, void *, size_t, loff_t);
-ssize_t vme_master_write(struct vme_resource *, void *, size_t, loff_t);
-unsigned int vme_master_rmw(struct vme_resource *, unsigned int, unsigned int,
- unsigned int, loff_t);
-void vme_master_free(struct vme_resource *);
-
-struct vme_resource *vme_dma_request(struct vme_dev *, u32);
-struct vme_dma_list *vme_new_dma_list(struct vme_resource *);
-struct vme_dma_attr *vme_dma_pattern_attribute(u32, u32);
-struct vme_dma_attr *vme_dma_pci_attribute(dma_addr_t);
-struct vme_dma_attr *vme_dma_vme_attribute(unsigned long long, u32, u32, u32);
-void vme_dma_free_attribute(struct vme_dma_attr *);
-int vme_dma_list_add(struct vme_dma_list *, struct vme_dma_attr *,
- struct vme_dma_attr *, size_t);
-int vme_dma_list_exec(struct vme_dma_list *);
-int vme_dma_list_free(struct vme_dma_list *);
-int vme_dma_free(struct vme_resource *);
-
-int vme_irq_request(struct vme_dev *, int, int,
- void (*callback)(int, int, void *), void *);
-void vme_irq_free(struct vme_dev *, int, int);
-int vme_irq_generate(struct vme_dev *, int, int);
-
-struct vme_resource *vme_lm_request(struct vme_dev *);
-int vme_lm_count(struct vme_resource *);
-int vme_lm_set(struct vme_resource *, unsigned long long, u32, u32);
-int vme_lm_get(struct vme_resource *, unsigned long long *, u32 *, u32 *);
-int vme_lm_attach(struct vme_resource *, int, void (*callback)(int));
-int vme_lm_detach(struct vme_resource *, int);
-void vme_lm_free(struct vme_resource *);
-
-int vme_slot_get(struct vme_dev *);
-
-int vme_register_driver(struct vme_driver *, unsigned int);
-void vme_unregister_driver(struct vme_driver *);
-
-
-#endif /* _VME_H_ */
-
diff --git a/drivers/staging/vme/vme_api.txt b/drivers/staging/vme/vme_api.txt
deleted file mode 100644
index 856efa35f6e3..000000000000
--- a/drivers/staging/vme/vme_api.txt
+++ /dev/null
@@ -1,396 +0,0 @@
- VME Device Driver API
- =====================
-
-Driver registration
-===================
-
-As with other subsystems within the Linux kernel, VME device drivers register
-with the VME subsystem, typically called from the devices init routine. This is
-achieved via a call to the following function:
-
- int vme_register_driver (struct vme_driver *driver);
-
-If driver registration is successful this function returns zero, if an error
-occurred a negative error code will be returned.
-
-A pointer to a structure of type 'vme_driver' must be provided to the
-registration function. The structure is as follows:
-
- struct vme_driver {
- struct list_head node;
- const char *name;
- int (*match)(struct vme_dev *);
- int (*probe)(struct vme_dev *);
- int (*remove)(struct vme_dev *);
- void (*shutdown)(void);
- struct device_driver driver;
- struct list_head devices;
- unsigned int ndev;
- };
-
-At the minimum, the '.name', '.match' and '.probe' elements of this structure
-should be correctly set. The '.name' element is a pointer to a string holding
-the device driver's name.
-
-The '.match' function allows controlling the number of devices that need to
-be registered. The match function should return 1 if a device should be
-probed and 0 otherwise. This example match function (from vme_user.c) limits
-the number of devices probed to one:
-
- #define USER_BUS_MAX 1
- ...
- static int vme_user_match(struct vme_dev *vdev)
- {
- if (vdev->id.num >= USER_BUS_MAX)
- return 0;
- return 1;
- }
-
-The '.probe' element should contain a pointer to the probe routine. The
-probe routine is passed a 'struct vme_dev' pointer as an argument. The
-'struct vme_dev' structure looks like the following:
-
- struct vme_dev {
- int num;
- struct vme_bridge *bridge;
- struct device dev;
- struct list_head drv_list;
- struct list_head bridge_list;
- };
-
-Here, the 'num' field refers to the sequential device ID for this specific
-driver. The bridge number (or bus number) can be accessed using
-dev->bridge->num.
-
-A function is also provided to unregister the driver from the VME core and is
-usually called from the device driver's exit routine:
-
- void vme_unregister_driver (struct vme_driver *driver);
-
-
-Resource management
-===================
-
-Once a driver has registered with the VME core the provided match routine will
-be called the number of times specified during the registration. If a match
-succeeds, a non-zero value should be returned. A zero return value indicates
-failure. For all successful matches, the probe routine of the corresponding
-driver is called. The probe routine is passed a pointer to the devices
-device structure. This pointer should be saved, it will be required for
-requesting VME resources.
-
-The driver can request ownership of one or more master windows, slave windows
-and/or dma channels. Rather than allowing the device driver to request a
-specific window or DMA channel (which may be used by a different driver) this
-driver allows a resource to be assigned based on the required attributes of the
-driver in question:
-
- struct vme_resource * vme_master_request(struct vme_dev *dev,
- u32 aspace, u32 cycle, u32 width);
-
- struct vme_resource * vme_slave_request(struct vme_dev *dev, u32 aspace,
- u32 cycle);
-
- struct vme_resource *vme_dma_request(struct vme_dev *dev, u32 route);
-
-For slave windows these attributes are split into the VME address spaces that
-need to be accessed in 'aspace' and VME bus cycle types required in 'cycle'.
-Master windows add a further set of attributes in 'width' specifying the
-required data transfer widths. These attributes are defined as bitmasks and as
-such any combination of the attributes can be requested for a single window,
-the core will assign a window that meets the requirements, returning a pointer
-of type vme_resource that should be used to identify the allocated resource
-when it is used. For DMA controllers, the request function requires the
-potential direction of any transfers to be provided in the route attributes.
-This is typically VME-to-MEM and/or MEM-to-VME, though some hardware can
-support VME-to-VME and MEM-to-MEM transfers as well as test pattern generation.
-If an unallocated window fitting the requirements can not be found a NULL
-pointer will be returned.
-
-Functions are also provided to free window allocations once they are no longer
-required. These functions should be passed the pointer to the resource provided
-during resource allocation:
-
- void vme_master_free(struct vme_resource *res);
-
- void vme_slave_free(struct vme_resource *res);
-
- void vme_dma_free(struct vme_resource *res);
-
-
-Master windows
-==============
-
-Master windows provide access from the local processor[s] out onto the VME bus.
-The number of windows available and the available access modes is dependent on
-the underlying chipset. A window must be configured before it can be used.
-
-
-Master window configuration
----------------------------
-
-Once a master window has been assigned the following functions can be used to
-configure it and retrieve the current settings:
-
- int vme_master_set (struct vme_resource *res, int enabled,
- unsigned long long base, unsigned long long size, u32 aspace,
- u32 cycle, u32 width);
-
- int vme_master_get (struct vme_resource *res, int *enabled,
- unsigned long long *base, unsigned long long *size, u32 *aspace,
- u32 *cycle, u32 *width);
-
-The address spaces, transfer widths and cycle types are the same as described
-under resource management, however some of the options are mutually exclusive.
-For example, only one address space may be specified.
-
-These functions return 0 on success or an error code should the call fail.
-
-
-Master window access
---------------------
-
-The following functions can be used to read from and write to configured master
-windows. These functions return the number of bytes copied:
-
- ssize_t vme_master_read(struct vme_resource *res, void *buf,
- size_t count, loff_t offset);
-
- ssize_t vme_master_write(struct vme_resource *res, void *buf,
- size_t count, loff_t offset);
-
-In addition to simple reads and writes, a function is provided to do a
-read-modify-write transaction. This function returns the original value of the
-VME bus location :
-
- unsigned int vme_master_rmw (struct vme_resource *res,
- unsigned int mask, unsigned int compare, unsigned int swap,
- loff_t offset);
-
-This functions by reading the offset, applying the mask. If the bits selected in
-the mask match with the values of the corresponding bits in the compare field,
-the value of swap is written the specified offset.
-
-
-Slave windows
-=============
-
-Slave windows provide devices on the VME bus access into mapped portions of the
-local memory. The number of windows available and the access modes that can be
-used is dependent on the underlying chipset. A window must be configured before
-it can be used.
-
-
-Slave window configuration
---------------------------
-
-Once a slave window has been assigned the following functions can be used to
-configure it and retrieve the current settings:
-
- int vme_slave_set (struct vme_resource *res, int enabled,
- unsigned long long base, unsigned long long size,
- dma_addr_t mem, u32 aspace, u32 cycle);
-
- int vme_slave_get (struct vme_resource *res, int *enabled,
- unsigned long long *base, unsigned long long *size,
- dma_addr_t *mem, u32 *aspace, u32 *cycle);
-
-The address spaces, transfer widths and cycle types are the same as described
-under resource management, however some of the options are mutually exclusive.
-For example, only one address space may be specified.
-
-These functions return 0 on success or an error code should the call fail.
-
-
-Slave window buffer allocation
-------------------------------
-
-Functions are provided to allow the user to allocate and free a contiguous
-buffers which will be accessible by the VME bridge. These functions do not have
-to be used, other methods can be used to allocate a buffer, though care must be
-taken to ensure that they are contiguous and accessible by the VME bridge:
-
- void * vme_alloc_consistent(struct vme_resource *res, size_t size,
- dma_addr_t *mem);
-
- void vme_free_consistent(struct vme_resource *res, size_t size,
- void *virt, dma_addr_t mem);
-
-
-Slave window access
--------------------
-
-Slave windows map local memory onto the VME bus, the standard methods for
-accessing memory should be used.
-
-
-DMA channels
-============
-
-The VME DMA transfer provides the ability to run link-list DMA transfers. The
-API introduces the concept of DMA lists. Each DMA list is a link-list which can
-be passed to a DMA controller. Multiple lists can be created, extended,
-executed, reused and destroyed.
-
-
-List Management
----------------
-
-The following functions are provided to create and destroy DMA lists. Execution
-of a list will not automatically destroy the list, thus enabling a list to be
-reused for repetitive tasks:
-
- struct vme_dma_list *vme_new_dma_list(struct vme_resource *res);
-
- int vme_dma_list_free(struct vme_dma_list *list);
-
-
-List Population
----------------
-
-An item can be added to a list using the following function ( the source and
-destination attributes need to be created before calling this function, this is
-covered under "Transfer Attributes"):
-
- int vme_dma_list_add(struct vme_dma_list *list,
- struct vme_dma_attr *src, struct vme_dma_attr *dest,
- size_t count);
-
-NOTE: The detailed attributes of the transfers source and destination
- are not checked until an entry is added to a DMA list, the request
- for a DMA channel purely checks the directions in which the
- controller is expected to transfer data. As a result it is
- possible for this call to return an error, for example if the
- source or destination is in an unsupported VME address space.
-
-Transfer Attributes
--------------------
-
-The attributes for the source and destination are handled separately from adding
-an item to a list. This is due to the diverse attributes required for each type
-of source and destination. There are functions to create attributes for PCI, VME
-and pattern sources and destinations (where appropriate):
-
-Pattern source:
-
- struct vme_dma_attr *vme_dma_pattern_attribute(u32 pattern, u32 type);
-
-PCI source or destination:
-
- struct vme_dma_attr *vme_dma_pci_attribute(dma_addr_t mem);
-
-VME source or destination:
-
- struct vme_dma_attr *vme_dma_vme_attribute(unsigned long long base,
- u32 aspace, u32 cycle, u32 width);
-
-The following function should be used to free an attribute:
-
- void vme_dma_free_attribute(struct vme_dma_attr *attr);
-
-
-List Execution
---------------
-
-The following function queues a list for execution. The function will return
-once the list has been executed:
-
- int vme_dma_list_exec(struct vme_dma_list *list);
-
-
-Interrupts
-==========
-
-The VME API provides functions to attach and detach callbacks to specific VME
-level and status ID combinations and for the generation of VME interrupts with
-specific VME level and status IDs.
-
-
-Attaching Interrupt Handlers
-----------------------------
-
-The following functions can be used to attach and free a specific VME level and
-status ID combination. Any given combination can only be assigned a single
-callback function. A void pointer parameter is provided, the value of which is
-passed to the callback function, the use of this pointer is user undefined:
-
- int vme_irq_request(struct vme_dev *dev, int level, int statid,
- void (*callback)(int, int, void *), void *priv);
-
- void vme_irq_free(struct vme_dev *dev, int level, int statid);
-
-The callback parameters are as follows. Care must be taken in writing a callback
-function, callback functions run in interrupt context:
-
- void callback(int level, int statid, void *priv);
-
-
-Interrupt Generation
---------------------
-
-The following function can be used to generate a VME interrupt at a given VME
-level and VME status ID:
-
- int vme_irq_generate(struct vme_dev *dev, int level, int statid);
-
-
-Location monitors
-=================
-
-The VME API provides the following functionality to configure the location
-monitor.
-
-
-Location Monitor Management
----------------------------
-
-The following functions are provided to request the use of a block of location
-monitors and to free them after they are no longer required:
-
- struct vme_resource * vme_lm_request(struct vme_dev *dev);
-
- void vme_lm_free(struct vme_resource * res);
-
-Each block may provide a number of location monitors, monitoring adjacent
-locations. The following function can be used to determine how many locations
-are provided:
-
- int vme_lm_count(struct vme_resource * res);
-
-
-Location Monitor Configuration
-------------------------------
-
-Once a bank of location monitors has been allocated, the following functions
-are provided to configure the location and mode of the location monitor:
-
- int vme_lm_set(struct vme_resource *res, unsigned long long base,
- u32 aspace, u32 cycle);
-
- int vme_lm_get(struct vme_resource *res, unsigned long long *base,
- u32 *aspace, u32 *cycle);
-
-
-Location Monitor Use
---------------------
-
-The following functions allow a callback to be attached and detached from each
-location monitor location. Each location monitor can monitor a number of
-adjacent locations:
-
- int vme_lm_attach(struct vme_resource *res, int num,
- void (*callback)(int));
-
- int vme_lm_detach(struct vme_resource *res, int num);
-
-The callback function is declared as follows.
-
- void callback(int num);
-
-
-Slot Detection
-==============
-
-This function returns the slot ID of the provided bridge.
-
- int vme_slot_get(struct vme_dev *dev);
diff --git a/drivers/staging/vme/vme_bridge.h b/drivers/staging/vme/vme_bridge.h
deleted file mode 100644
index 934949abd745..000000000000
--- a/drivers/staging/vme/vme_bridge.h
+++ /dev/null
@@ -1,174 +0,0 @@
-#ifndef _VME_BRIDGE_H_
-#define _VME_BRIDGE_H_
-
-#define VME_CRCSR_BUF_SIZE (508*1024)
-/*
- * Resource structures
- */
-struct vme_master_resource {
- struct list_head list;
- struct vme_bridge *parent;
- /*
- * We are likely to need to access the VME bus in interrupt context, so
- * protect master routines with a spinlock rather than a mutex.
- */
- spinlock_t lock;
- int locked;
- int number;
- u32 address_attr;
- u32 cycle_attr;
- u32 width_attr;
- struct resource bus_resource;
- void __iomem *kern_base;
-};
-
-struct vme_slave_resource {
- struct list_head list;
- struct vme_bridge *parent;
- struct mutex mtx;
- int locked;
- int number;
- u32 address_attr;
- u32 cycle_attr;
-};
-
-struct vme_dma_pattern {
- u32 pattern;
- u32 type;
-};
-
-struct vme_dma_pci {
- dma_addr_t address;
-};
-
-struct vme_dma_vme {
- unsigned long long address;
- u32 aspace;
- u32 cycle;
- u32 dwidth;
-};
-
-struct vme_dma_list {
- struct list_head list;
- struct vme_dma_resource *parent;
- struct list_head entries;
- struct mutex mtx;
-};
-
-struct vme_dma_resource {
- struct list_head list;
- struct vme_bridge *parent;
- struct mutex mtx;
- int locked;
- int number;
- struct list_head pending;
- struct list_head running;
- u32 route_attr;
-};
-
-struct vme_lm_resource {
- struct list_head list;
- struct vme_bridge *parent;
- struct mutex mtx;
- int locked;
- int number;
- int monitors;
-};
-
-struct vme_bus_error {
- struct list_head list;
- unsigned long long address;
- u32 attributes;
-};
-
-struct vme_callback {
- void (*func)(int, int, void*);
- void *priv_data;
-};
-
-struct vme_irq {
- int count;
- struct vme_callback callback[255];
-};
-
-/* Allow 16 characters for name (including null character) */
-#define VMENAMSIZ 16
-
-/* This structure stores all the information about one bridge
- * The structure should be dynamically allocated by the driver and one instance
- * of the structure should be present for each VME chip present in the system.
- */
-struct vme_bridge {
- char name[VMENAMSIZ];
- int num;
- struct list_head master_resources;
- struct list_head slave_resources;
- struct list_head dma_resources;
- struct list_head lm_resources;
-
- struct list_head vme_errors; /* List for errors generated on VME */
- struct list_head devices; /* List of devices on this bridge */
-
- /* Bridge Info - XXX Move to private structure? */
- struct device *parent; /* Parent device (eg. pdev->dev for PCI) */
- void *driver_priv; /* Private pointer for the bridge driver */
- struct list_head bus_list; /* list of VME buses */
-
- /* Interrupt callbacks */
- struct vme_irq irq[7];
- /* Locking for VME irq callback configuration */
- struct mutex irq_mtx;
-
- /* Slave Functions */
- int (*slave_get) (struct vme_slave_resource *, int *,
- unsigned long long *, unsigned long long *, dma_addr_t *,
- u32 *, u32 *);
- int (*slave_set) (struct vme_slave_resource *, int, unsigned long long,
- unsigned long long, dma_addr_t, u32, u32);
-
- /* Master Functions */
- int (*master_get) (struct vme_master_resource *, int *,
- unsigned long long *, unsigned long long *, u32 *, u32 *,
- u32 *);
- int (*master_set) (struct vme_master_resource *, int,
- unsigned long long, unsigned long long, u32, u32, u32);
- ssize_t (*master_read) (struct vme_master_resource *, void *, size_t,
- loff_t);
- ssize_t (*master_write) (struct vme_master_resource *, void *, size_t,
- loff_t);
- unsigned int (*master_rmw) (struct vme_master_resource *, unsigned int,
- unsigned int, unsigned int, loff_t);
-
- /* DMA Functions */
- int (*dma_list_add) (struct vme_dma_list *, struct vme_dma_attr *,
- struct vme_dma_attr *, size_t);
- int (*dma_list_exec) (struct vme_dma_list *);
- int (*dma_list_empty) (struct vme_dma_list *);
-
- /* Interrupt Functions */
- void (*irq_set) (struct vme_bridge *, int, int, int);
- int (*irq_generate) (struct vme_bridge *, int, int);
-
- /* Location monitor functions */
- int (*lm_set) (struct vme_lm_resource *, unsigned long long, u32, u32);
- int (*lm_get) (struct vme_lm_resource *, unsigned long long *, u32 *,
- u32 *);
- int (*lm_attach) (struct vme_lm_resource *, int, void (*callback)(int));
- int (*lm_detach) (struct vme_lm_resource *, int);
-
- /* CR/CSR space functions */
- int (*slot_get) (struct vme_bridge *);
-
- /* Bridge parent interface */
- void *(*alloc_consistent)(struct device *dev, size_t size,
- dma_addr_t *dma);
- void (*free_consistent)(struct device *dev, size_t size,
- void *vaddr, dma_addr_t dma);
-};
-
-void vme_irq_handler(struct vme_bridge *, int, int);
-
-int vme_register_bridge(struct vme_bridge *);
-void vme_unregister_bridge(struct vme_bridge *);
-
-#endif /* _VME_BRIDGE_H_ */
diff --git a/drivers/staging/vt6655/80211hdr.h b/drivers/staging/vt6655/80211hdr.h
index f55283b86410..c4d2349260ea 100644
--- a/drivers/staging/vt6655/80211hdr.h
+++ b/drivers/staging/vt6655/80211hdr.h
@@ -80,7 +80,6 @@
#define WLAN_HDR_ADDR4_LEN 30
#define WLAN_IEHDR_LEN 2
#define WLAN_SSID_MAXLEN 32
-/*#define WLAN_RATES_MAXLEN 255*/
#define WLAN_RATES_MAXLEN 16
#define WLAN_RATES_MAXLEN_11B 4
#define WLAN_RSN_MAXLEN 32
@@ -106,7 +105,6 @@
#define WLAN_WEP40_KEYLEN 5
#define WLAN_WEP104_KEYLEN 13
#define WLAN_WEP232_KEYLEN 29
-/*#define WLAN_WEPMAX_KEYLEN 29*/
#define WLAN_WEPMAX_KEYLEN 32
#define WLAN_CHALLENGE_IE_MAXLEN 255
#define WLAN_CHALLENGE_IE_LEN 130
diff --git a/drivers/staging/vt6655/baseband.c b/drivers/staging/vt6655/baseband.c
index 1e1c6e34f786..e7b93a21e3b2 100644
--- a/drivers/staging/vt6655/baseband.c
+++ b/drivers/staging/vt6655/baseband.c
@@ -60,8 +60,6 @@
//static int msglevel =MSG_LEVEL_DEBUG;
static int msglevel =MSG_LEVEL_INFO;
-//#define PLICE_DEBUG
-
/*--------------------- Static Classes ----------------------------*/
/*--------------------- Static Variables --------------------------*/
diff --git a/drivers/staging/vt6655/baseband.h b/drivers/staging/vt6655/baseband.h
index 8294bdbb7b51..be2d68909490 100644
--- a/drivers/staging/vt6655/baseband.h
+++ b/drivers/staging/vt6655/baseband.h
@@ -46,36 +46,6 @@
// Baseband RF pair definition in eeprom (Bits 6..0)
//
-/*
-#define RATE_1M 0
-#define RATE_2M 1
-#define RATE_5M 2
-#define RATE_11M 3
-#define RATE_6M 4
-#define RATE_9M 5
-#define RATE_12M 6
-#define RATE_18M 7
-#define RATE_24M 8
-#define RATE_36M 9
-#define RATE_48M 10
-#define RATE_54M 11
-#define RATE_AUTO 12
-#define MAX_RATE 12
-
-
-//0:11A 1:11B 2:11G
-#define BB_TYPE_11A 0
-#define BB_TYPE_11B 1
-#define BB_TYPE_11G 2
-
-//0:11a,1:11b,2:11gb(only CCK in BasicRate),3:11ga(OFDM in Basic Rate)
-#define PK_TYPE_11A 0
-#define PK_TYPE_11B 1
-#define PK_TYPE_11GB 2
-#define PK_TYPE_11GA 3
-*/
-
-
#define PREAMBLE_LONG 0
#define PREAMBLE_SHORT 1
diff --git a/drivers/staging/vt6655/bssdb.c b/drivers/staging/vt6655/bssdb.c
index 1368e8cc9add..fcffa4f0f4e3 100644
--- a/drivers/staging/vt6655/bssdb.c
+++ b/drivers/staging/vt6655/bssdb.c
@@ -58,7 +58,6 @@
#include "wpa2.h"
#include "iowpa.h"
-//#define PLICE_DEBUG
/*--------------------- Static Definitions -------------------------*/
@@ -142,9 +141,8 @@ BSSpSearchBSSList(
unsigned int ii = 0;
if (pbyDesireBSSID != NULL) {
- DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"BSSpSearchBSSList BSSID[%02X %02X %02X-%02X %02X %02X]\n",
- *pbyDesireBSSID,*(pbyDesireBSSID+1),*(pbyDesireBSSID+2),
- *(pbyDesireBSSID+3),*(pbyDesireBSSID+4),*(pbyDesireBSSID+5));
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO
+ "BSSpSearchBSSList BSSID[%pM]\n", pbyDesireBSSID);
if ((!is_broadcast_ether_addr(pbyDesireBSSID)) &&
(memcmp(pbyDesireBSSID, ZeroBSSID, 6)!= 0)){
pbyBSSID = pbyDesireBSSID;
diff --git a/drivers/staging/vt6655/desc.h b/drivers/staging/vt6655/desc.h
index 138897a79325..084a1a5566ad 100644
--- a/drivers/staging/vt6655/desc.h
+++ b/drivers/staging/vt6655/desc.h
@@ -152,10 +152,6 @@
#define FRAGCTL_TKIP 0x0002 // 0000 0010 0000 0000
#define FRAGCTL_LEGACY 0x0001 // 0000 0001 0000 0000
#define FRAGCTL_NONENCRYPT 0x0000 // 0000 0000 0000 0000
-//#define FRAGCTL_AC3 0x0C00 // 0000 0000 0000 1100
-//#define FRAGCTL_AC2 0x0800 // 0000 0000 0000 1000
-//#define FRAGCTL_AC1 0x0400 // 0000 0000 0000 0100
-//#define FRAGCTL_AC0 0x0000 // 0000 0000 0000 0000
#define FRAGCTL_ENDFRAG 0x0300 // 0000 0000 0000 0011
#define FRAGCTL_MIDFRAG 0x0200 // 0000 0000 0000 0010
#define FRAGCTL_STAFRAG 0x0100 // 0000 0000 0000 0001
@@ -184,10 +180,6 @@
#define FRAGCTL_TKIP 0x0200 // 0000 0010 0000 0000
#define FRAGCTL_LEGACY 0x0100 // 0000 0001 0000 0000
#define FRAGCTL_NONENCRYPT 0x0000 // 0000 0000 0000 0000
-//#define FRAGCTL_AC3 0x000C // 0000 0000 0000 1100
-//#define FRAGCTL_AC2 0x0008 // 0000 0000 0000 1000
-//#define FRAGCTL_AC1 0x0004 // 0000 0000 0000 0100
-//#define FRAGCTL_AC0 0x0000 // 0000 0000 0000 0000
#define FRAGCTL_ENDFRAG 0x0003 // 0000 0000 0000 0011
#define FRAGCTL_MIDFRAG 0x0002 // 0000 0000 0000 0010
#define FRAGCTL_STAFRAG 0x0001 // 0000 0000 0000 0001
@@ -195,8 +187,6 @@
#endif // #ifdef __BIG_ENDIAN
-//#define TYPE_AC0DMA 0
-//#define TYPE_TXDMA0 1
#define TYPE_TXDMA0 0
#define TYPE_AC0DMA 1
#define TYPE_ATIMDMA 2
@@ -215,7 +205,6 @@
#define TD_FLAGS_NETIF_SKB 0x01 // check if need release skb
#define TD_FLAGS_PRIV_SKB 0x02 // check if called from private skb(hostap)
#define TD_FLAGS_PS_RETRY 0x04 // check if PS STA frame re-transmit
-//#define TD_FLAGS_NETIF_SKB 0x04
/*--------------------- Export Types ------------------------------*/
diff --git a/drivers/staging/vt6655/device.h b/drivers/staging/vt6655/device.h
index 780205c0a88b..c5e6b98d3e4e 100644
--- a/drivers/staging/vt6655/device.h
+++ b/drivers/staging/vt6655/device.h
@@ -69,10 +69,6 @@
#ifndef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
#define WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
#endif
-//2008-4-14<add> by chester for led issue
-//#define FOR_LED_ON_NOTEBOOK
-//
-
//
// device specific
@@ -91,12 +87,6 @@
#include "key.h"
#include "mac.h"
-//PLICE_DEBUG->
-//#define THREAD
-
-//#define TASK_LET
-//PLICE_DEBUG<-
-
/*--------------------- Export Definitions -------------------------*/
@@ -105,11 +95,6 @@
#define MAX_MULTICAST_ADDRESS_NUM 32
#define MULTICAST_ADDRESS_LIST_SIZE (MAX_MULTICAST_ADDRESS_NUM * ETH_ALEN)
-
-//#define OP_MODE_INFRASTRUCTURE 0
-//#define OP_MODE_ADHOC 1
-//#define OP_MODE_AP 2
-
#define DUPLICATE_RX_CACHE_LENGTH 5
#define NUM_KEY_ENTRY 11
diff --git a/drivers/staging/vt6655/device_main.c b/drivers/staging/vt6655/device_main.c
index 3e8283c2dc73..89d1c22695a0 100644
--- a/drivers/staging/vt6655/device_main.c
+++ b/drivers/staging/vt6655/device_main.c
@@ -87,12 +87,10 @@
#include <linux/kthread.h>
#include <linux/slab.h>
-//#define DEBUG
/*--------------------- Static Definitions -------------------------*/
//static int msglevel =MSG_LEVEL_DEBUG;
static int msglevel = MSG_LEVEL_INFO;
-//#define PLICE_DEBUG
//
// Define module options
//
@@ -100,10 +98,8 @@ MODULE_AUTHOR("VIA Networking Technologies, Inc., <lyndonchen@vntek.com.tw>");
MODULE_LICENSE("GPL");
MODULE_DESCRIPTION("VIA Networking Solomon-A/B/G Wireless LAN Adapter Driver");
-//PLICE_DEBUG ->
static int mlme_kill;
//static struct task_struct * mlme_task;
-//PLICE_DEBUG <-
#define DEVICE_PARAM(N,D)
/*
@@ -1086,15 +1082,6 @@ vt6655_probe(struct pci_dev *pcid, const struct pci_device_id *ent)
device_free_info(pDevice);
return -ENODEV;
}
-//2008-07-21-01<Add>by MikeLiu
-//register wpadev
-#if 0
- if(wpa_set_wpadev(pDevice, 1)!=0) {
- printk("Fail to Register WPADEV?\n");
- unregister_netdev(pDevice->dev);
- free_netdev(dev);
- }
-#endif
device_print_info(pDevice);
pci_set_drvdata(pcid, pDevice);
return 0;
@@ -1948,15 +1935,6 @@ device_init_rd0_ring(pDevice);
-#if 0
- pDevice->MLMEThr_pid = kernel_thread(MlmeThread, pDevice, CLONE_VM);
- if (pDevice->MLMEThr_pid <0 )
- {
- printk("unable start thread MlmeThread\n");
- return -1;
- }
-#endif
-
//printk("thread id is %d\n",pDevice->MLMEThr_pid);
//printk("Create thread time is %x\n",jiffies);
//wait_for_completion(&pDevice->notify);
@@ -2493,21 +2471,6 @@ static int device_xmit(struct sk_buff *skb, struct net_device *dev) {
&(pDevice->byTopCCKBasicRate),
&(pDevice->byTopOFDMBasicRate));
-#if 0
-printk("auto rate:Rate : %d,AckRate:%d,TopCCKRate:%d,TopOFDMRate:%d\n",
-pDevice->wCurrentRate,pDevice->byACKRate,
-pDevice->byTopCCKBasicRate,pDevice->byTopOFDMBasicRate);
-
-#endif
-
-#if 0
-
- pDevice->wCurrentRate = 11;
- pDevice->byACKRate = 8;
- pDevice->byTopCCKBasicRate = 3;
- pDevice->byTopOFDMBasicRate = 8;
-#endif
-
}
}
diff --git a/drivers/staging/vt6655/dpc.c b/drivers/staging/vt6655/dpc.c
index c0fab4bc8702..e8a71ba4b92c 100644
--- a/drivers/staging/vt6655/dpc.c
+++ b/drivers/staging/vt6655/dpc.c
@@ -55,7 +55,6 @@
#include "iowpa.h"
#include "aes_ccmp.h"
-//#define PLICE_DEBUG
/*--------------------- Static Definitions -------------------------*/
diff --git a/drivers/staging/vt6655/hostap.c b/drivers/staging/vt6655/hostap.c
index 773502702203..6ac6f452b261 100644
--- a/drivers/staging/vt6655/hostap.c
+++ b/drivers/staging/vt6655/hostap.c
@@ -40,14 +40,8 @@
#define VIAWGET_HOSTAPD_MAX_BUF_SIZE 1024
#define HOSTAP_CRYPT_FLAG_SET_TX_KEY BIT0
-#define HOSTAP_CRYPT_FLAG_PERMANENT BIT1
-#define HOSTAP_CRYPT_ERR_UNKNOWN_ALG 2
#define HOSTAP_CRYPT_ERR_UNKNOWN_ADDR 3
-#define HOSTAP_CRYPT_ERR_CRYPT_INIT_FAILED 4
#define HOSTAP_CRYPT_ERR_KEY_SET_FAILED 5
-#define HOSTAP_CRYPT_ERR_TX_KEY_SET_FAILED 6
-#define HOSTAP_CRYPT_ERR_CARD_CONF_FAILED 7
-
/*--------------------- Static Definitions -------------------------*/
diff --git a/drivers/staging/vt6655/iwctl.c b/drivers/staging/vt6655/iwctl.c
index 87288db21785..77aad7f5ae76 100644
--- a/drivers/staging/vt6655/iwctl.c
+++ b/drivers/staging/vt6655/iwctl.c
@@ -84,24 +84,6 @@ struct iw_statistics *iwctl_get_wireless_stats(struct net_device *dev)
pDevice->wstats.status = pDevice->eOPMode;
#ifdef Calcu_LinkQual
- #if 0
- if(pDevice->byBBType == BB_TYPE_11B) {
- if(pDevice->byCurrSQ > 120)
- pDevice->scStatistic.LinkQuality = 100;
- else
- pDevice->scStatistic.LinkQuality = pDevice->byCurrSQ*100/120;
- }
- else if(pDevice->byBBType == BB_TYPE_11G) {
- if(pDevice->byCurrSQ < 20)
- pDevice->scStatistic.LinkQuality = 100;
- else if(pDevice->byCurrSQ >96)
- pDevice->scStatistic.LinkQuality = 0;
- else
- pDevice->scStatistic.LinkQuality = (96-pDevice->byCurrSQ)*100/76;
- }
- if(pDevice->bLinkPass !=true)
- pDevice->scStatistic.LinkQuality = 0;
- #endif
if(pDevice->scStatistic.LinkQuality > 100)
pDevice->scStatistic.LinkQuality = 100;
pDevice->wstats.qual.qual =(unsigned char) pDevice->scStatistic.LinkQuality;
@@ -2004,24 +1986,6 @@ param->u.wpa_key.key = (u8 *)key_array;
param->u.wpa_key.seq = (u8 *)seq;
param->u.wpa_key.seq_len = seq_len;
-#if 0
-printk("param->u.wpa_key.alg_name =%d\n",param->u.wpa_key.alg_name);
-printk(KERN_DEBUG "param->addr=%pM\n", param->addr);
-printk("param->u.wpa_key.set_tx =%d\n",param->u.wpa_key.set_tx);
-printk("param->u.wpa_key.key_index =%d\n",param->u.wpa_key.key_index);
-printk("param->u.wpa_key.key_len =%d\n",param->u.wpa_key.key_len);
-printk("param->u.wpa_key.key =");
-for(ii=0;ii<param->u.wpa_key.key_len;ii++)
- printk("%02x:",param->u.wpa_key.key[ii]);
- printk("\n");
-printk("param->u.wpa_key.seq_len =%d\n",param->u.wpa_key.seq_len);
-printk("param->u.wpa_key.seq =");
-for(ii=0;ii<param->u.wpa_key.seq_len;ii++)
- printk("%02x:",param->u.wpa_key.seq[ii]);
- printk("\n");
-
-printk("...........\n");
-#endif
//****set if current action is Network Manager count??
//****this method is so foolish,but there is no other way???
if(param->u.wpa_key.alg_name == WPA_ALG_NONE) {
diff --git a/drivers/staging/vt6655/mac.h b/drivers/staging/vt6655/mac.h
index b96d27ee2540..e3ccfee90268 100644
--- a/drivers/staging/vt6655/mac.h
+++ b/drivers/staging/vt6655/mac.h
@@ -292,19 +292,11 @@
//
#define EnCFG_BarkerPream 0x00020000
#define EnCFG_NXTBTTCFPSTR 0x00010000
-//#define EnCFG_TXLMT3UPDATE 0x00008000
-//#define EnCFG_TXLMT2UPDATE 0x00004000
-//#define EnCFG_TXLMT1UPDATE 0x00002000
-//#define EnCFG_TXLMT3EN 0x00001000
-//#define EnCFG_TXLMT2EN 0x00000800
-//#define EnCFG_TXLMT1EN 0x00000400
#define EnCFG_BcnSusClr 0x00000200
#define EnCFG_BcnSusInd 0x00000100
-//#define EnCFG_CWOFF1 0x00000080
#define EnCFG_CFP_ProtectEn 0x00000040
#define EnCFG_ProtectMd 0x00000020
#define EnCFG_HwParCFP 0x00000010
-//#define EnCFG_QOS 0x00000008
#define EnCFG_CFNULRSP 0x00000004
#define EnCFG_BBType_MASK 0x00000003
#define EnCFG_BBType_g 0x00000002
@@ -392,14 +384,6 @@
#define IMR_RADARDETECT 0x10000000 //
#define IMR_MEASUREEND 0x08000000 //
#define IMR_SOFTTIMER1 0x00200000 //
-//#define IMR_SYNCFLUSHOK 0x00100000 //
-//#define IMR_ATIMEND 0x00080000 //0000 1000 0000 0000 0000 0000
-//#define IMR_CFPEND 0x00040000 //0000 0100 0000 0000 0000 0000
-//#define IMR_AC3DMA 0x00020000 //0000 0010 0000 0000 0000 0000
-//#define IMR_AC2DMA 0x00010000 //0000 0001 0000 0000 0000 0000
-//#define IMR_AC1DMA 0x00008000 //0000 0000 1000 0000 0000 0000
-//#define IMR_SYNCTX 0x00004000 //0000 0000 0100 0000 0000 0000
-//#define IMR_ATIMTX 0x00002000 //0000 0000 0010 0000 0000 0000
#define IMR_RXDMA1 0x00001000 //0000 0000 0001 0000 0000 0000
#define IMR_RXNOBUF 0x00000800 //
#define IMR_MIBNEARFULL 0x00000400 //
@@ -424,14 +408,6 @@
#define ISR_RADARDETECT 0x10000000 //
#define ISR_MEASUREEND 0x08000000 //
#define ISR_SOFTTIMER1 0x00200000 //
-//#define ISR_SYNCFLUSHOK 0x00100000 //0001 0000 0000 0000 0000 0000
-//#define ISR_ATIMEND 0x00080000 //0000 1000 0000 0000 0000 0000
-//#define ISR_CFPEND 0x00040000 //0000 0100 0000 0000 0000 0000
-//#define ISR_AC3DMA 0x00020000 //0000 0010 0000 0000 0000 0000
-//#define ISR_AC2DMA 0x00010000 //0000 0001 0000 0000 0000 0000
-//#define ISR_AC1DMA 0x00008000 //0000 0000 1000 0000 0000 0000
-//#define ISR_SYNCTX 0x00004000 //0000 0000 0100 0000 0000 0000
-//#define ISR_ATIMTX 0x00002000 //0000 0000 0010 0000 0000 0000
#define ISR_RXDMA1 0x00001000 //0000 0000 0001 0000 0000 0000
#define ISR_RXNOBUF 0x00000800 //0000 0000 0000 1000 0000 0000
#define ISR_MIBNEARFULL 0x00000400 //0000 0000 0000 0100 0000 0000
diff --git a/drivers/staging/vt6655/mib.h b/drivers/staging/vt6655/mib.h
index 009f3a4d29f6..5cd697a2bc77 100644
--- a/drivers/staging/vt6655/mib.h
+++ b/drivers/staging/vt6655/mib.h
@@ -98,7 +98,6 @@ typedef struct tagSMib2Counter {
} SMib2Counter, *PSMib2Counter;
// Value in the ifType entry
-//#define ETHERNETCSMACD 6 //
#define WIRELESSLANIEEE80211b 6 //
// Value in the ifAdminStatus/ifOperStatus entry
@@ -210,7 +209,6 @@ typedef struct tagSISRCounters {
#define UNDER_CREATION 3 //
#define INVALID 4 //
-//#define MAX_RATE 12
//
// statistic counter
//
diff --git a/drivers/staging/vt6655/rf.c b/drivers/staging/vt6655/rf.c
index b8ec783e55e0..aa696650b86c 100644
--- a/drivers/staging/vt6655/rf.c
+++ b/drivers/staging/vt6655/rf.c
@@ -41,52 +41,16 @@
//static int msglevel =MSG_LEVEL_INFO;
-#define BY_RF2959_REG_LEN 23 //24bits
-#define CB_RF2959_INIT_SEQ 15
-#define SWITCH_CHANNEL_DELAY_RF2959 200 //us
-#define RF2959_PWR_IDX_LEN 32
-
-#define BY_MA2825_REG_LEN 23 //24bit
-#define CB_MA2825_INIT_SEQ 13
-#define SWITCH_CHANNEL_DELAY_MA2825 200 //us
-#define MA2825_PWR_IDX_LEN 31
-
#define BY_AL2230_REG_LEN 23 //24bit
#define CB_AL2230_INIT_SEQ 15
#define SWITCH_CHANNEL_DELAY_AL2230 200 //us
#define AL2230_PWR_IDX_LEN 64
-#define BY_UW2451_REG_LEN 23
-#define CB_UW2451_INIT_SEQ 6
-#define SWITCH_CHANNEL_DELAY_UW2451 200 //us
-#define UW2451_PWR_IDX_LEN 25
-
-//{{ RobertYu: 20041118
-#define BY_MA2829_REG_LEN 23 //24bit
-#define CB_MA2829_INIT_SEQ 13
-#define SWITCH_CHANNEL_DELAY_MA2829 200 //us
-#define MA2829_PWR_IDX_LEN 64
-//}} RobertYu
-
-//{{ RobertYu:20050103
#define BY_AL7230_REG_LEN 23 //24bit
#define CB_AL7230_INIT_SEQ 16
#define SWITCH_CHANNEL_DELAY_AL7230 200 //us
#define AL7230_PWR_IDX_LEN 64
-//}} RobertYu
-
-//{{ RobertYu: 20041210
-#define BY_UW2452_REG_LEN 23
-#define CB_UW2452_INIT_SEQ 5 //RoberYu:20050113, Rev0.2 Programming Guide(remove R3, so 6-->5)
-#define SWITCH_CHANNEL_DELAY_UW2452 100 //us
-#define UW2452_PWR_IDX_LEN 64
-//}} RobertYu
-
-#define BY_VT3226_REG_LEN 23
-#define CB_VT3226_INIT_SEQ 12
-#define SWITCH_CHANNEL_DELAY_VT3226 200 //us
-#define VT3226_PWR_IDX_LEN 16
/*--------------------- Static Classes ----------------------------*/
@@ -1067,48 +1031,6 @@ unsigned char byPwrdBm = 0;
break;
}
-#if 0
-
- // 802.11h TPC
- if (pDevice->bLinkPass == true) {
- // do not over local constraint
- if (byPwrdBm > pDevice->abyLocalPwr[uCH]) {
- pDevice->byCurPwrdBm = pDevice->abyLocalPwr[uCH];
- byDec = byPwrdBm - pDevice->abyLocalPwr[uCH];
- if (pDevice->byRFType == RF_UW2452) {
- byDec *= 3;
- } else {
- byDec <<= 1;
- }
- if (byPwr > byDec) {
- byPwr -= byDec;
- } else {
- byPwr = 0;
- }
- } else {
- pDevice->byCurPwrdBm = byPwrdBm;
- }
- } else {
- // do not over regulatory constraint
- if (byPwrdBm > pDevice->abyRegPwr[uCH]) {
- pDevice->byCurPwrdBm = pDevice->abyRegPwr[uCH];
- byDec = byPwrdBm - pDevice->abyRegPwr[uCH];
- if (pDevice->byRFType == RF_UW2452) {
- byDec *= 3;
- } else {
- byDec <<= 1;
- }
- if (byPwr > byDec) {
- byPwr -= byDec;
- } else {
- byPwr = 0;
- }
- } else {
- pDevice->byCurPwrdBm = byPwrdBm;
- }
- }
-#endif
-
// if (pDevice->byLocalID <= REV_ID_VT3253_B1) {
if (pDevice->byCurPwr == byPwr) {
return true;
diff --git a/drivers/staging/vt6655/rf.h b/drivers/staging/vt6655/rf.h
index 1f8d82e13041..73f09693ee7a 100644
--- a/drivers/staging/vt6655/rf.h
+++ b/drivers/staging/vt6655/rf.h
@@ -41,7 +41,6 @@
#define RF_MAXIMAG 0x02
#define RF_AIROHA 0x03
-//#define RF_GCT5103 0x04
#define RF_UW2451 0x05
#define RF_MAXIMG 0x06
#define RF_MAXIM2829 0x07 // RobertYu: 20041118
diff --git a/drivers/staging/vt6655/tether.h b/drivers/staging/vt6655/tether.h
index 787d885deee9..6a68f97d9a32 100644
--- a/drivers/staging/vt6655/tether.h
+++ b/drivers/staging/vt6655/tether.h
@@ -90,8 +90,6 @@
#define TYPE_CTL_ACK 0xd400
-//#define WEP_IV_MASK 0xFFFFFF00
-
#else //if LITTLE_ENDIAN
//
// wType field in the SEthernetHeader
@@ -143,7 +141,6 @@
#define TYPE_CTL_ACK 0x00d4
-//#define WEP_IV_MASK 0x00FFFFFF
#endif //#ifdef __BIG_ENDIAN
diff --git a/drivers/staging/vt6655/vntwifi.c b/drivers/staging/vt6655/vntwifi.c
index 0491d0b52c85..d645ecd89417 100644
--- a/drivers/staging/vt6655/vntwifi.c
+++ b/drivers/staging/vt6655/vntwifi.c
@@ -38,8 +38,6 @@
#include "wmgr.h"
#include "datarate.h"
-//#define PLICE_DEBUG
-
/*--------------------- Static Definitions -------------------------*/
//static int msglevel =MSG_LEVEL_DEBUG;
//static int msglevel =MSG_LEVEL_INFO;
diff --git a/drivers/staging/vt6655/wcmd.c b/drivers/staging/vt6655/wcmd.c
index bab3b0116ccc..7b5b99c8cf14 100644
--- a/drivers/staging/vt6655/wcmd.c
+++ b/drivers/staging/vt6655/wcmd.c
@@ -684,18 +684,6 @@ printk("chester-abyDesireSSID=%s\n",((PWLAN_IE_SSID)pMgmt->abyDesireSSID)->abySS
return;
}
pDevice->byLinkWaitCount = 0;
- #if 0
- #ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
- // if(pDevice->bWPASuppWextEnabled == true)
- {
- union iwreq_data wrqu;
- memset(&wrqu, 0, sizeof (wrqu));
- wrqu.ap_addr.sa_family = ARPHRD_ETHER;
- printk("wireless_send_event--->SIOCGIWAP(disassociated:AUTHENTICATE_WAIT_timeout)\n");
- wireless_send_event(pDevice->dev, SIOCGIWAP, &wrqu, NULL);
- }
- #endif
- #endif
s_bCommandComplete(pDevice);
break;
@@ -748,18 +736,6 @@ printk("chester-abyDesireSSID=%s\n",((PWLAN_IE_SSID)pMgmt->abyDesireSSID)->abySS
return;
}
pDevice->byLinkWaitCount = 0;
- #if 0
- #ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
- // if(pDevice->bWPASuppWextEnabled == true)
- {
- union iwreq_data wrqu;
- memset(&wrqu, 0, sizeof (wrqu));
- wrqu.ap_addr.sa_family = ARPHRD_ETHER;
- printk("wireless_send_event--->SIOCGIWAP(disassociated:ASSOCIATE_WAIT_timeout)\n");
- wireless_send_event(pDevice->dev, SIOCGIWAP, &wrqu, NULL);
- }
- #endif
- #endif
s_bCommandComplete(pDevice);
break;
diff --git a/drivers/staging/vt6655/wpa.c b/drivers/staging/vt6655/wpa.c
index 61ac46fa505e..0afb9fe0379a 100644
--- a/drivers/staging/vt6655/wpa.c
+++ b/drivers/staging/vt6655/wpa.c
@@ -148,7 +148,7 @@ WPA_ParseRSN (
{
j = 0;
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"wPKCount: %d, sizeof(pBSSList->abyPKType): %zu\n", pRSN->wPKCount, sizeof(pBSSList->abyPKType));
- for(i = 0; (i < pRSN->wPKCount) && (j < sizeof(pBSSList->abyPKType)/sizeof(unsigned char)); i++) {
+ for(i = 0; (i < pRSN->wPKCount) && (j < ARRAY_SIZE(pBSSList->abyPKType)); i++) {
if(pRSN->len >= 12+i*4+4) { //oui1(4)+ver(2)+GKS(4)+PKSCnt(2)+PKS(4*i)
if ( !memcmp(pRSN->PKSList[i].abyOUI, abyOUI00, 4))
pBSSList->abyPKType[j++] = WPA_NONE;
@@ -180,7 +180,7 @@ WPA_ParseRSN (
j = 0;
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"wAuthCount: %d, sizeof(pBSSList->abyAuthType): %zu\n",
pIE_RSN_Auth->wAuthCount, sizeof(pBSSList->abyAuthType));
- for(i = 0; (i < pIE_RSN_Auth->wAuthCount) && (j < sizeof(pBSSList->abyAuthType)/sizeof(unsigned char)); i++) {
+ for(i = 0; (i < pIE_RSN_Auth->wAuthCount) && (j < ARRAY_SIZE(pBSSList->abyAuthType)); i++) {
if(pRSN->len >= 14+4+(m+i)*4) { //oui1(4)+ver(2)+GKS(4)+PKSCnt(2)+PKS(4*m)+AKC(2)+AKS(4*i)
if ( !memcmp(pIE_RSN_Auth->AuthKSList[i].abyOUI, abyOUI01, 4))
pBSSList->abyAuthType[j++] = WPA_AUTH_IEEE802_1X;
diff --git a/drivers/staging/vt6656/80211hdr.h b/drivers/staging/vt6656/80211hdr.h
index 15c6ef1a635c..b87d5434077a 100644
--- a/drivers/staging/vt6656/80211hdr.h
+++ b/drivers/staging/vt6656/80211hdr.h
@@ -78,7 +78,6 @@
#define WLAN_HDR_ADDR4_LEN 30
#define WLAN_IEHDR_LEN 2
#define WLAN_SSID_MAXLEN 32
-/* #define WLAN_RATES_MAXLEN 255 */
#define WLAN_RATES_MAXLEN 16
#define WLAN_RATES_MAXLEN_11B 4
#define WLAN_RSN_MAXLEN 32
@@ -104,7 +103,6 @@
#define WLAN_WEP40_KEYLEN 5
#define WLAN_WEP104_KEYLEN 13
#define WLAN_WEP232_KEYLEN 29
-/* #define WLAN_WEPMAX_KEYLEN 29 */
#define WLAN_WEPMAX_KEYLEN 32
#define WLAN_CHALLENGE_IE_MAXLEN 255
#define WLAN_CHALLENGE_IE_LEN 130
diff --git a/drivers/staging/vt6656/bssdb.c b/drivers/staging/vt6656/bssdb.c
index 619c257e8773..099936771e69 100644
--- a/drivers/staging/vt6656/bssdb.c
+++ b/drivers/staging/vt6656/bssdb.c
@@ -129,9 +129,8 @@ PKnownBSS BSSpSearchBSSList(void *hDeviceContext,
unsigned int ii = 0;
unsigned int jj = 0;
if (pbyDesireBSSID != NULL) {
- DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"BSSpSearchBSSList BSSID[%02X %02X %02X-%02X %02X %02X]\n",
- *pbyDesireBSSID,*(pbyDesireBSSID+1),*(pbyDesireBSSID+2),
- *(pbyDesireBSSID+3),*(pbyDesireBSSID+4),*(pbyDesireBSSID+5));
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO
+ "BSSpSearchBSSList BSSID[%pM]\n", pbyDesireBSSID);
if ((!is_broadcast_ether_addr(pbyDesireBSSID)) &&
(memcmp(pbyDesireBSSID, ZeroBSSID, 6)!= 0)){
pbyBSSID = pbyDesireBSSID;
@@ -218,7 +217,9 @@ PKnownBSS BSSpSearchBSSList(void *hDeviceContext,
}
pMgmt->pSameBSS[jj].uChannel = pCurrBSS->uChannel;
- DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"BSSpSearchBSSList pSelect1[%02X %02X %02X-%02X %02X %02X]\n",*pCurrBSS->abyBSSID,*(pCurrBSS->abyBSSID+1),*(pCurrBSS->abyBSSID+2),*(pCurrBSS->abyBSSID+3),*(pCurrBSS->abyBSSID+4),*(pCurrBSS->abyBSSID+5));
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO
+ "BSSpSearchBSSList pSelect1[%pM]\n",
+ pCurrBSS->abyBSSID);
jj++;
diff --git a/drivers/staging/vt6656/bssdb.h b/drivers/staging/vt6656/bssdb.h
index a8f97ebb659b..6b2ec390e775 100644
--- a/drivers/staging/vt6656/bssdb.h
+++ b/drivers/staging/vt6656/bssdb.h
@@ -64,8 +64,6 @@
// send and receive non-IEEE 802.1X frames
#define WLAN_STA_AUTHORIZED BIT5
-//#define MAX_RATE 12
-
#define MAX_WPA_IE_LEN 64
diff --git a/drivers/staging/vt6656/card.c b/drivers/staging/vt6656/card.c
index 9d09e9fd8e18..e3ddc0b55317 100644
--- a/drivers/staging/vt6656/card.c
+++ b/drivers/staging/vt6656/card.c
@@ -66,7 +66,6 @@ static int msglevel =MSG_LEVEL_INFO;
/*--------------------- Static Definitions -------------------------*/
-#define CB_TXPOWER_LEVEL 6
/*--------------------- Static Classes ----------------------------*/
diff --git a/drivers/staging/vt6656/card.h b/drivers/staging/vt6656/card.h
index 9cf71a3d8801..55962b198831 100644
--- a/drivers/staging/vt6656/card.h
+++ b/drivers/staging/vt6656/card.h
@@ -52,7 +52,6 @@ typedef enum _CARD_OP_MODE {
} CARD_OP_MODE, *PCARD_OP_MODE;
#define CB_MAX_CHANNEL_24G 14
-/* #define CB_MAX_CHANNEL_5G 24 */
#define CB_MAX_CHANNEL_5G 42 /* add channel9(5045MHz), 41==>42 */
#define CB_MAX_CHANNEL (CB_MAX_CHANNEL_24G+CB_MAX_CHANNEL_5G)
diff --git a/drivers/staging/vt6656/channel.c b/drivers/staging/vt6656/channel.c
index 99e054d2d601..650217607858 100644
--- a/drivers/staging/vt6656/channel.c
+++ b/drivers/staging/vt6656/channel.c
@@ -368,8 +368,6 @@ static struct
/* 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 */
};
-#define NUM_RULES ARRAY_SIZE(ChannelRuleTab)
-
/*--------------------- Export function -------------------------*/
/************************************************************************
* Country Channel Valid
diff --git a/drivers/staging/vt6656/desc.h b/drivers/staging/vt6656/desc.h
index 767112b3c4a9..b68b2ec96eaa 100644
--- a/drivers/staging/vt6656/desc.h
+++ b/drivers/staging/vt6656/desc.h
@@ -36,8 +36,6 @@
#include "ttype.h"
#include "tether.h"
-/*--------------------- Export Definitions -------------------------*/
-
// max transmit or receive buffer size
#define CB_MAX_BUF_SIZE 2900U // max buffer size
// NOTE: must be multiple of 4
@@ -120,17 +118,11 @@
#define FRAGCTL_TKIP 0x0200 // 0000 0010 0000 0000
#define FRAGCTL_LEGACY 0x0100 // 0000 0001 0000 0000
#define FRAGCTL_NONENCRYPT 0x0000 // 0000 0000 0000 0000
-//#define FRAGCTL_AC3 0x000C // 0000 0000 0000 1100
-//#define FRAGCTL_AC2 0x0008 // 0000 0000 0000 1000
-//#define FRAGCTL_AC1 0x0004 // 0000 0000 0000 0100
-//#define FRAGCTL_AC0 0x0000 // 0000 0000 0000 0000
#define FRAGCTL_ENDFRAG 0x0003 // 0000 0000 0000 0011
#define FRAGCTL_MIDFRAG 0x0002 // 0000 0000 0000 0010
#define FRAGCTL_STAFRAG 0x0001 // 0000 0000 0000 0001
#define FRAGCTL_NONFRAG 0x0000 // 0000 0000 0000 0000
-//#define TYPE_AC0DMA 0
-//#define TYPE_TXDMA0 1
#define TYPE_TXDMA0 0
#define TYPE_AC0DMA 1
#define TYPE_ATIMDMA 2
@@ -147,9 +139,6 @@
#define TD_FLAGS_NETIF_SKB 0x01 // check if need release skb
#define TD_FLAGS_PRIV_SKB 0x02 // check if called from private skb(hostap)
#define TD_FLAGS_PS_RETRY 0x04 // check if PS STA frame re-transmit
-//#define TD_FLAGS_NETIF_SKB 0x04
-
-/*--------------------- Export Types ------------------------------*/
//
// RsvTime buffer header
@@ -268,7 +257,6 @@ SRTS_a_FB, *PSRTS_a_FB;
typedef const SRTS_a_FB *PCSRTS_a_FB;
-
//
// CTS buffer header
//
@@ -421,12 +409,5 @@ typedef struct tagSKeyEntry {
DWORD dwKey4[4];
} __attribute__ ((__packed__))
SKeyEntry;
-/*--------------------- Export Macros ------------------------------*/
-
-/*--------------------- Export Classes ----------------------------*/
-
-/*--------------------- Export Variables --------------------------*/
-
-/*--------------------- Export Functions --------------------------*/
#endif /* __DESC_H__ */
diff --git a/drivers/staging/vt6656/device.h b/drivers/staging/vt6656/device.h
index f1496ec5dc72..171dd68cf5b2 100644
--- a/drivers/staging/vt6656/device.h
+++ b/drivers/staging/vt6656/device.h
@@ -106,10 +106,6 @@
#define MAX_MULTICAST_ADDRESS_NUM 32
#define MULTICAST_ADDRESS_LIST_SIZE (MAX_MULTICAST_ADDRESS_NUM * ETH_ALEN)
-//#define OP_MODE_INFRASTRUCTURE 0
-//#define OP_MODE_ADHOC 1
-//#define OP_MODE_AP 2
-
#define DUPLICATE_RX_CACHE_LENGTH 5
#define NUM_KEY_ENTRY 11
diff --git a/drivers/staging/vt6656/dpc.c b/drivers/staging/vt6656/dpc.c
index c0edf97535dc..e4bdf2a2b582 100644
--- a/drivers/staging/vt6656/dpc.c
+++ b/drivers/staging/vt6656/dpc.c
@@ -452,7 +452,7 @@ RXbBulkInProcessData (
}
}
- if (!is_multicast_ether_addr(pMACHeader->abyAddr1) && !is_broadcast_ether_addr(pMACHeader->abyAddr1)) {
+ if (!is_multicast_ether_addr(pMACHeader->abyAddr1)) {
if ( WCTLbIsDuplicate(&(pDevice->sDupRxCache), (PS802_11Header) pbyFrame) ) {
pDevice->s802_11Counter.FrameDuplicateCount++;
return FALSE;
diff --git a/drivers/staging/vt6656/hostap.c b/drivers/staging/vt6656/hostap.c
index 51b5adf36577..682002a5b8d7 100644
--- a/drivers/staging/vt6656/hostap.c
+++ b/drivers/staging/vt6656/hostap.c
@@ -41,31 +41,11 @@
#define VIAWGET_HOSTAPD_MAX_BUF_SIZE 1024
#define HOSTAP_CRYPT_FLAG_SET_TX_KEY BIT0
-#define HOSTAP_CRYPT_FLAG_PERMANENT BIT1
-#define HOSTAP_CRYPT_ERR_UNKNOWN_ALG 2
#define HOSTAP_CRYPT_ERR_UNKNOWN_ADDR 3
-#define HOSTAP_CRYPT_ERR_CRYPT_INIT_FAILED 4
#define HOSTAP_CRYPT_ERR_KEY_SET_FAILED 5
-#define HOSTAP_CRYPT_ERR_TX_KEY_SET_FAILED 6
-#define HOSTAP_CRYPT_ERR_CARD_CONF_FAILED 7
-
-/*--------------------- Static Definitions -------------------------*/
-
-/*--------------------- Static Classes ----------------------------*/
-
-/*--------------------- Static Variables --------------------------*/
-//static int msglevel =MSG_LEVEL_DEBUG;
static int msglevel =MSG_LEVEL_INFO;
-/*--------------------- Static Functions --------------------------*/
-
-
-
-
-/*--------------------- Export Variables --------------------------*/
-
-
/*
* Description:
* register net_device (AP) for hostap deamon
@@ -314,37 +294,6 @@ static int hostap_get_info_sta(PSDevice pDevice,
return 0;
}
-/*
- * Description:
- * reset txexec
- *
- * Parameters:
- * In:
- * pDevice -
- * param -
- * Out:
- * TURE, FALSE
- *
- * Return Value:
- *
- */
-/*
-static int hostap_reset_txexc_sta(PSDevice pDevice,
- struct viawget_hostapd_param *param)
-{
- PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
- unsigned int uNodeIndex;
-
- if (BSSbIsSTAInNodeDB(pDevice, param->sta_addr, &uNodeIndex)) {
- pMgmt->sNodeDBTable[uNodeIndex].uTxAttempts = 0;
- }
- else {
- return -ENOENT;
- }
-
- return 0;
-}
-*/
/*
* Description:
@@ -479,12 +428,6 @@ static int hostap_set_encryption(PSDevice pDevice,
param->u.crypt.err = 0;
-/*
- if (param_len !=
- (int) ((char *) param->u.crypt.key - (char *) param) +
- param->u.crypt.key_len)
- return -EINVAL;
-*/
if (param->u.crypt.alg > WPA_ALG_CCMP)
return -EINVAL;
@@ -814,12 +757,6 @@ int vt6656_hostap_ioctl(PSDevice pDevice, struct iw_point *p)
ret = hostap_get_info_sta(pDevice, param);
ap_ioctl = 1;
break;
-/*
- case VIAWGET_HOSTAPD_RESET_TXEXC_STA:
- DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "VIAWGET_HOSTAPD_RESET_TXEXC_STA \n");
- ret = hostap_reset_txexc_sta(pDevice, param);
- break;
-*/
case VIAWGET_HOSTAPD_SET_FLAGS_STA:
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "VIAWGET_HOSTAPD_SET_FLAGS_STA \n");
ret = hostap_set_flags_sta(pDevice, param);
diff --git a/drivers/staging/vt6656/int.c b/drivers/staging/vt6656/int.c
index 0a114231145f..eba4b5061cf7 100644
--- a/drivers/staging/vt6656/int.c
+++ b/drivers/staging/vt6656/int.c
@@ -41,9 +41,7 @@
#include "usbpipe.h"
/*--------------------- Static Definitions -------------------------*/
-/* static int msglevel = MSG_LEVEL_DEBUG; */
-static int msglevel = MSG_LEVEL_INFO;
-
+static int msglevel = MSG_LEVEL_INFO; /* MSG_LEVEL_DEBUG */
/*--------------------- Static Classes ----------------------------*/
@@ -53,10 +51,8 @@ static int msglevel = MSG_LEVEL_INFO;
/*--------------------- Export Variables --------------------------*/
-
/*--------------------- Export Functions --------------------------*/
-
/*+
*
* Function: InterruptPollingThread
@@ -81,7 +77,7 @@ static int msglevel = MSG_LEVEL_INFO;
-*/
void INTvWorkItem(void *Context)
{
- PSDevice pDevice = (PSDevice) Context;
+ PSDevice pDevice = Context;
int ntStatus;
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"---->Interrupt Polling Thread\n");
@@ -94,8 +90,8 @@ void INTvWorkItem(void *Context)
void INTnsProcessData(PSDevice pDevice)
{
- PSINTData pINTData;
- PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
+ PSINTData pINTData;
+ PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
struct net_device_stats *pStats = &pDevice->stats;
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"---->s_nsInterruptProcessData\n");
@@ -103,8 +99,8 @@ void INTnsProcessData(PSDevice pDevice)
pINTData = (PSINTData) pDevice->intBuf.pDataBuf;
if (pINTData->byTSR0 & TSR_VALID) {
STAvUpdateTDStatCounter(&(pDevice->scStatistic),
- (BYTE) (pINTData->byPkt0 & 0x0F),
- (BYTE) (pINTData->byPkt0>>4),
+ (BYTE)(pINTData->byPkt0 & 0x0F),
+ (BYTE)(pINTData->byPkt0>>4),
pINTData->byTSR0);
BSSvUpdateNodeTxCounter(pDevice,
&(pDevice->scStatistic),
@@ -114,8 +110,8 @@ void INTnsProcessData(PSDevice pDevice)
}
if (pINTData->byTSR1 & TSR_VALID) {
STAvUpdateTDStatCounter(&(pDevice->scStatistic),
- (BYTE) (pINTData->byPkt1 & 0x0F),
- (BYTE) (pINTData->byPkt1>>4),
+ (BYTE)(pINTData->byPkt1 & 0x0F),
+ (BYTE)(pINTData->byPkt1>>4),
pINTData->byTSR1);
BSSvUpdateNodeTxCounter(pDevice,
&(pDevice->scStatistic),
@@ -125,8 +121,8 @@ void INTnsProcessData(PSDevice pDevice)
}
if (pINTData->byTSR2 & TSR_VALID) {
STAvUpdateTDStatCounter(&(pDevice->scStatistic),
- (BYTE) (pINTData->byPkt2 & 0x0F),
- (BYTE) (pINTData->byPkt2>>4),
+ (BYTE)(pINTData->byPkt2 & 0x0F),
+ (BYTE)(pINTData->byPkt2>>4),
pINTData->byTSR2);
BSSvUpdateNodeTxCounter(pDevice,
&(pDevice->scStatistic),
@@ -136,8 +132,8 @@ void INTnsProcessData(PSDevice pDevice)
}
if (pINTData->byTSR3 & TSR_VALID) {
STAvUpdateTDStatCounter(&(pDevice->scStatistic),
- (BYTE) (pINTData->byPkt3 & 0x0F),
- (BYTE) (pINTData->byPkt3>>4),
+ (BYTE)(pINTData->byPkt3 & 0x0F),
+ (BYTE)(pINTData->byPkt3>>4),
pINTData->byTSR3);
BSSvUpdateNodeTxCounter(pDevice,
&(pDevice->scStatistic),
@@ -186,11 +182,11 @@ void INTnsProcessData(PSDevice pDevice)
LODWORD(pDevice->qwCurrTSF) = pINTData->dwLoTSF;
HIDWORD(pDevice->qwCurrTSF) = pINTData->dwHiTSF;
/*DBG_PRN_GRP01(("ISR0 = %02x ,
- LoTsf = %08x,
- HiTsf = %08x\n",
- pINTData->byISR0,
- pINTData->dwLoTSF,
- pINTData->dwHiTSF)); */
+ LoTsf = %08x,
+ HiTsf = %08x\n",
+ pINTData->byISR0,
+ pINTData->dwLoTSF,
+ pINTData->dwHiTSF)); */
STAvUpdate802_11Counter(&pDevice->s802_11Counter,
&pDevice->scStatistic,
@@ -202,7 +198,6 @@ void INTnsProcessData(PSDevice pDevice)
pINTData->byISR0,
pINTData->byISR1);
}
-
if (pINTData->byISR1 != 0)
if (pINTData->byISR1 & ISR_GPIO3)
bScheduleCommand((void *) pDevice,
@@ -213,8 +208,8 @@ void INTnsProcessData(PSDevice pDevice)
pStats->tx_packets = pDevice->scStatistic.ullTsrOK;
pStats->tx_bytes = pDevice->scStatistic.ullTxDirectedBytes +
- pDevice->scStatistic.ullTxMulticastBytes +
- pDevice->scStatistic.ullTxBroadcastBytes;
+ pDevice->scStatistic.ullTxMulticastBytes +
+ pDevice->scStatistic.ullTxBroadcastBytes;
pStats->tx_errors = pDevice->scStatistic.dwTsrErr;
pStats->tx_dropped = pDevice->scStatistic.dwTsrErr;
}
diff --git a/drivers/staging/vt6656/int.h b/drivers/staging/vt6656/int.h
index a5d96b968176..3734e2c953d9 100644
--- a/drivers/staging/vt6656/int.h
+++ b/drivers/staging/vt6656/int.h
@@ -36,31 +36,30 @@
/*--------------------- Export Definitions -------------------------*/
#pragma pack(1)
typedef struct tagSINTData {
- BYTE byTSR0;
- BYTE byPkt0;
- WORD wTime0;
- BYTE byTSR1;
- BYTE byPkt1;
- WORD wTime1;
- BYTE byTSR2;
- BYTE byPkt2;
- WORD wTime2;
- BYTE byTSR3;
- BYTE byPkt3;
- WORD wTime3;
- DWORD dwLoTSF;
- DWORD dwHiTSF;
- BYTE byISR0;
- BYTE byISR1;
- BYTE byRTSSuccess;
- BYTE byRTSFail;
- BYTE byACKFail;
- BYTE byFCSErr;
- BYTE abySW[2];
+ BYTE byTSR0;
+ BYTE byPkt0;
+ WORD wTime0;
+ BYTE byTSR1;
+ BYTE byPkt1;
+ WORD wTime1;
+ BYTE byTSR2;
+ BYTE byPkt2;
+ WORD wTime2;
+ BYTE byTSR3;
+ BYTE byPkt3;
+ WORD wTime3;
+ DWORD dwLoTSF;
+ DWORD dwHiTSF;
+ BYTE byISR0;
+ BYTE byISR1;
+ BYTE byRTSSuccess;
+ BYTE byRTSFail;
+ BYTE byACKFail;
+ BYTE byFCSErr;
+ BYTE abySW[2];
} __attribute__ ((__packed__))
SINTData, *PSINTData;
-
/*--------------------- Export Classes ----------------------------*/
/*--------------------- Export Variables --------------------------*/
diff --git a/drivers/staging/vt6656/ioctl.c b/drivers/staging/vt6656/ioctl.c
index d59456c29df1..5b9a84f95185 100644
--- a/drivers/staging/vt6656/ioctl.c
+++ b/drivers/staging/vt6656/ioctl.c
@@ -90,18 +90,17 @@ int private_ioctl(PSDevice pDevice, struct ifreq *rq)
spin_lock_irq(&pDevice->lock);
if (memcmp(pMgmt->abyCurrBSSID, &abyNullAddr[0], 6) == 0)
- BSSvClearBSSList((void *)pDevice, FALSE);
+ BSSvClearBSSList(pDevice, FALSE);
else
- BSSvClearBSSList((void *)pDevice, pDevice->bLinkPass);
+ BSSvClearBSSList(pDevice, pDevice->bLinkPass);
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_BSS_SCAN..begin\n");
if (pItemSSID->len != 0)
- bScheduleCommand((void *)pDevice,
- WLAN_CMD_BSSID_SCAN,
+ bScheduleCommand(pDevice, WLAN_CMD_BSSID_SCAN,
abyScanSSID);
else
- bScheduleCommand((void *) pDevice, WLAN_CMD_BSSID_SCAN, NULL);
+ bScheduleCommand(pDevice, WLAN_CMD_BSSID_SCAN, NULL);
spin_unlock_irq(&pDevice->lock);
break;
@@ -150,6 +149,7 @@ int private_ioctl(PSDevice pDevice, struct ifreq *rq)
}
}
break;
+
case WLAN_CMD_BSS_JOIN:
if (copy_from_user(&sJoinCmd, pReq->data, sizeof(SCmdBSSJoin))) {
result = -EFAULT;
@@ -190,10 +190,9 @@ int private_ioctl(PSDevice pDevice, struct ifreq *rq)
netif_stop_queue(pDevice->dev);
spin_lock_irq(&pDevice->lock);
pMgmt->eCurrState = WMAC_STATE_IDLE;
- bScheduleCommand((void *) pDevice,
- WLAN_CMD_BSSID_SCAN,
+ bScheduleCommand(pDevice, WLAN_CMD_BSSID_SCAN,
pMgmt->abyDesireSSID);
- bScheduleCommand((void *) pDevice, WLAN_CMD_SSID, NULL);
+ bScheduleCommand(pDevice, WLAN_CMD_SSID, NULL);
spin_unlock_irq(&pDevice->lock);
break;
@@ -299,7 +298,7 @@ int private_ioctl(PSDevice pDevice, struct ifreq *rq)
result = -EINVAL;
break;
}
- pList = (PSBSSIDList)kmalloc(sizeof(SBSSIDList) + (sList.uItem * sizeof(SBSSIDItem)), (int)GFP_ATOMIC);
+ pList = kmalloc(sizeof(SBSSIDList) + (sList.uItem * sizeof(SBSSIDItem)), GFP_ATOMIC);
if (pList == NULL) {
result = -ENOMEM;
break;
@@ -313,7 +312,7 @@ int private_ioctl(PSDevice pDevice, struct ifreq *rq)
pList->sBSSIDList[ii].wBeaconInterval = pBSS->wBeaconInterval;
pList->sBSSIDList[ii].wCapInfo = pBSS->wCapInfo;
RFvRSSITodBm(pDevice, (BYTE)(pBSS->uRSSI), &ldBm);
- pList->sBSSIDList[ii].uRSSI = (unsigned int) ldBm;
+ pList->sBSSIDList[ii].uRSSI = (unsigned int)ldBm;
/* pList->sBSSIDList[ii].uRSSI = pBSS->uRSSI; */
memcpy(pList->sBSSIDList[ii].abyBSSID, pBSS->abyBSSID, WLAN_BSSID_LEN);
pItemSSID = (PWLAN_IE_SSID)pBSS->abySSID;
@@ -356,6 +355,7 @@ int private_ioctl(PSDevice pDevice, struct ifreq *rq)
break;
}
break;
+
case WLAN_CMD_STOP_MAC:
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WLAN_CMD_STOP_MAC\n");
/* Todo xxxxxx */
@@ -534,7 +534,7 @@ int private_ioctl(PSDevice pDevice, struct ifreq *rq)
netif_stop_queue(pDevice->dev);
spin_lock_irq(&pDevice->lock);
- bScheduleCommand((void *)pDevice, WLAN_CMD_RUN_AP, NULL);
+ bScheduleCommand(pDevice, WLAN_CMD_RUN_AP, NULL);
spin_unlock_irq(&pDevice->lock);
break;
@@ -565,7 +565,7 @@ int private_ioctl(PSDevice pDevice, struct ifreq *rq)
result = -ENOMEM;
break;
}
- pNodeList = kmalloc(sizeof(SNodeList) + (sNodeList.uItem * sizeof(SNodeItem)), (int)GFP_ATOMIC);
+ pNodeList = kmalloc(sizeof(SNodeList) + (sNodeList.uItem * sizeof(SNodeItem)), GFP_ATOMIC);
if (pNodeList == NULL) {
result = -ENOMEM;
break;
diff --git a/drivers/staging/vt6656/iwctl.c b/drivers/staging/vt6656/iwctl.c
index b24e5314a6af..8b9894b1146a 100644
--- a/drivers/staging/vt6656/iwctl.c
+++ b/drivers/staging/vt6656/iwctl.c
@@ -47,20 +47,20 @@
#include <net/iw_handler.h>
#ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
-#define SUPPORTED_WIRELESS_EXT 18
+#define SUPPORTED_WIRELESS_EXT 18
#else
-#define SUPPORTED_WIRELESS_EXT 17
+#define SUPPORTED_WIRELESS_EXT 17
#endif
static const long frequency_list[] = {
- 2412, 2417, 2422, 2427, 2432, 2437, 2442, 2447, 2452, 2457, 2462, 2467, 2472, 2484,
- 4915, 4920, 4925, 4935, 4940, 4945, 4960, 4980,
- 5035, 5040, 5045, 5055, 5060, 5080, 5170, 5180, 5190, 5200, 5210, 5220, 5230, 5240,
- 5260, 5280, 5300, 5320, 5500, 5520, 5540, 5560, 5580, 5600, 5620, 5640, 5660, 5680,
- 5700, 5745, 5765, 5785, 5805, 5825
- };
+ 2412, 2417, 2422, 2427, 2432, 2437, 2442, 2447, 2452, 2457, 2462, 2467, 2472, 2484,
+ 4915, 4920, 4925, 4935, 4940, 4945, 4960, 4980,
+ 5035, 5040, 5045, 5055, 5060, 5080, 5170, 5180, 5190, 5200, 5210, 5220, 5230, 5240,
+ 5260, 5280, 5300, 5320, 5500, 5520, 5540, 5560, 5580, 5600, 5620, 5640, 5660, 5680,
+ 5700, 5745, 5765, 5785, 5805, 5825
+};
-static int msglevel =MSG_LEVEL_INFO;
+static int msglevel = MSG_LEVEL_INFO;
struct iw_statistics *iwctl_get_wireless_stats(struct net_device *dev)
{
@@ -68,9 +68,9 @@ struct iw_statistics *iwctl_get_wireless_stats(struct net_device *dev)
long ldBm;
pDevice->wstats.status = pDevice->eOPMode;
- if(pDevice->scStatistic.LinkQuality > 100)
- pDevice->scStatistic.LinkQuality = 100;
- pDevice->wstats.qual.qual =(BYTE) pDevice->scStatistic.LinkQuality;
+ if (pDevice->scStatistic.LinkQuality > 100)
+ pDevice->scStatistic.LinkQuality = 100;
+ pDevice->wstats.qual.qual =(BYTE)pDevice->scStatistic.LinkQuality;
RFvRSSITodBm(pDevice, (BYTE)(pDevice->uCurrRSSI), &ldBm);
pDevice->wstats.qual.level = ldBm;
pDevice->wstats.qual.noise = 0;
@@ -81,93 +81,84 @@ struct iw_statistics *iwctl_get_wireless_stats(struct net_device *dev)
pDevice->wstats.discard.retries = pDevice->scStatistic.dwTsrErr;
pDevice->wstats.discard.misc = 0;
pDevice->wstats.miss.beacon = 0;
-
return &pDevice->wstats;
}
/*
- * Wireless Handler : get protocol name
+ * Wireless Handler: get protocol name
*/
-
-int iwctl_giwname(struct net_device *dev,
- struct iw_request_info *info,
- char *wrq,
- char *extra)
+int iwctl_giwname(struct net_device *dev, struct iw_request_info *info,
+ char *wrq, char *extra)
{
strcpy(wrq, "802.11-a/b/g");
return 0;
}
/*
- * Wireless Handler : set scan
+ * Wireless Handler: set scan
*/
-
-int iwctl_siwscan(struct net_device *dev,
- struct iw_request_info *info,
- struct iw_point *wrq,
- char *extra)
+int iwctl_siwscan(struct net_device *dev, struct iw_request_info *info,
+ struct iw_point *wrq, char *extra)
{
- PSDevice pDevice = (PSDevice)netdev_priv(dev);
- PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
- struct iw_scan_req *req = (struct iw_scan_req *)extra;
- BYTE abyScanSSID[WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1];
- PWLAN_IE_SSID pItemSSID=NULL;
-
- if (!(pDevice->flags & DEVICE_FLAGS_OPENED))
- return -EINVAL;
-
- PRINT_K(" SIOCSIWSCAN \n");
-
-if (pMgmt->eScanState == WMAC_IS_SCANNING) {
- // In scanning..
- PRINT_K("SIOCSIWSCAN(overlap??)-->In scanning...\n");
- return -EAGAIN;
- }
-
-if(pDevice->byReAssocCount > 0) { //reject scan when re-associating!
-//send scan event to wpa_Supplicant
- union iwreq_data wrqu;
- PRINT_K("wireless_send_event--->SIOCGIWSCAN(scan done)\n");
- memset(&wrqu, 0, sizeof(wrqu));
- wireless_send_event(pDevice->dev, SIOCGIWSCAN, &wrqu, NULL);
- return 0;
-}
+ PSDevice pDevice = netdev_priv(dev);
+ PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
+ struct iw_scan_req *req = (struct iw_scan_req *)extra;
+ BYTE abyScanSSID[WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1];
+ PWLAN_IE_SSID pItemSSID = NULL;
+
+ if (!(pDevice->flags & DEVICE_FLAGS_OPENED))
+ return -EINVAL;
+
+ PRINT_K(" SIOCSIWSCAN \n");
+
+ if (pMgmt->eScanState == WMAC_IS_SCANNING) {
+ // In scanning..
+ PRINT_K("SIOCSIWSCAN(overlap??)-->In scanning...\n");
+ return -EAGAIN;
+ }
+
+ if (pDevice->byReAssocCount > 0) { // reject scan when re-associating!
+ // send scan event to wpa_Supplicant
+ union iwreq_data wrqu;
+ PRINT_K("wireless_send_event--->SIOCGIWSCAN(scan done)\n");
+ memset(&wrqu, 0, sizeof(wrqu));
+ wireless_send_event(pDevice->dev, SIOCGIWSCAN, &wrqu, NULL);
+ return 0;
+ }
spin_lock_irq(&pDevice->lock);
- BSSvClearBSSList((void *) pDevice, pDevice->bLinkPass);
-
-//mike add: active scan OR passive scan OR desire_ssid scan
- if(wrq->length == sizeof(struct iw_scan_req)) {
- if (wrq->flags & IW_SCAN_THIS_ESSID) { //desire_ssid scan
- memset(abyScanSSID, 0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1);
- pItemSSID = (PWLAN_IE_SSID)abyScanSSID;
- pItemSSID->byElementID = WLAN_EID_SSID;
- memcpy(pItemSSID->abySSID, req->essid, (int)req->essid_len);
- if (pItemSSID->abySSID[req->essid_len - 1] == '\0') {
- if(req->essid_len>0)
- pItemSSID->len = req->essid_len - 1;
- }
- else
- pItemSSID->len = req->essid_len;
- pMgmt->eScanType = WMAC_SCAN_PASSIVE;
- PRINT_K("SIOCSIWSCAN:[desired_ssid=%s,len=%d]\n",((PWLAN_IE_SSID)abyScanSSID)->abySSID,
- ((PWLAN_IE_SSID)abyScanSSID)->len);
- bScheduleCommand((void *) pDevice, WLAN_CMD_BSSID_SCAN, abyScanSSID);
- spin_unlock_irq(&pDevice->lock);
+ BSSvClearBSSList((void *)pDevice, pDevice->bLinkPass);
+
+ // mike add: active scan OR passive scan OR desire_ssid scan
+ if (wrq->length == sizeof(struct iw_scan_req)) {
+ if (wrq->flags & IW_SCAN_THIS_ESSID) { // desire_ssid scan
+ memset(abyScanSSID, 0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1);
+ pItemSSID = (PWLAN_IE_SSID)abyScanSSID;
+ pItemSSID->byElementID = WLAN_EID_SSID;
+ memcpy(pItemSSID->abySSID, req->essid, (int)req->essid_len);
+ if (pItemSSID->abySSID[req->essid_len - 1] == '\0') {
+ if (req->essid_len > 0)
+ pItemSSID->len = req->essid_len - 1;
+ } else {
+ pItemSSID->len = req->essid_len;
+ }
+ pMgmt->eScanType = WMAC_SCAN_PASSIVE;
+ PRINT_K("SIOCSIWSCAN:[desired_ssid=%s,len=%d]\n", ((PWLAN_IE_SSID)abyScanSSID)->abySSID,
+ ((PWLAN_IE_SSID)abyScanSSID)->len);
+ bScheduleCommand((void *)pDevice, WLAN_CMD_BSSID_SCAN, abyScanSSID);
+ spin_unlock_irq(&pDevice->lock);
+
+ return 0;
+ } else if (req->scan_type == IW_SCAN_TYPE_PASSIVE) { // passive scan
+ pMgmt->eScanType = WMAC_SCAN_PASSIVE;
+ }
+ } else { // active scan
+ pMgmt->eScanType = WMAC_SCAN_ACTIVE;
+ }
- return 0;
- }
- else if(req->scan_type == IW_SCAN_TYPE_PASSIVE) { //passive scan
- pMgmt->eScanType = WMAC_SCAN_PASSIVE;
- }
- }
- else { //active scan
- pMgmt->eScanType = WMAC_SCAN_ACTIVE;
- }
-
- pMgmt->eScanType = WMAC_SCAN_PASSIVE;
- bScheduleCommand((void *) pDevice, WLAN_CMD_BSSID_SCAN, NULL);
+ pMgmt->eScanType = WMAC_SCAN_PASSIVE;
+ bScheduleCommand((void *)pDevice, WLAN_CMD_BSSID_SCAN, NULL);
spin_unlock_irq(&pDevice->lock);
return 0;
@@ -176,18 +167,18 @@ if(pDevice->byReAssocCount > 0) { //reject scan when re-associating!
/*
* Wireless Handler : get scan results
*/
-
-int iwctl_giwscan(struct net_device *dev,
- struct iw_request_info *info,
- struct iw_point *wrq,
- char *extra)
+int iwctl_giwscan(struct net_device *dev, struct iw_request_info *info,
+ struct iw_point *wrq, char *extra)
{
- int ii, jj, kk;
- PSDevice pDevice = (PSDevice)netdev_priv(dev);
- PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
- PKnownBSS pBSS;
- PWLAN_IE_SSID pItemSSID;
- PWLAN_IE_SUPP_RATES pSuppRates, pExtSuppRates;
+ int ii;
+ int jj;
+ int kk;
+ PSDevice pDevice = netdev_priv(dev);
+ PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
+ PKnownBSS pBSS;
+ PWLAN_IE_SSID pItemSSID;
+ PWLAN_IE_SUPP_RATES pSuppRates;
+ PWLAN_IE_SUPP_RATES pExtSuppRates;
char *current_ev = extra;
char *end_buf = extra + IW_SCAN_MAX_DATA;
char *current_val = NULL;
@@ -195,194 +186,179 @@ int iwctl_giwscan(struct net_device *dev,
long ldBm;
char buf[MAX_WPA_IE_LEN * 2 + 30];
- DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWSCAN\n");
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWSCAN\n");
- if (pMgmt->eScanState == WMAC_IS_SCANNING) {
- // In scanning..
+ if (pMgmt->eScanState == WMAC_IS_SCANNING) {
+ // In scanning..
return -EAGAIN;
}
pBSS = &(pMgmt->sBSSList[0]);
- for (ii = 0, jj = 0; jj < MAX_BSS_NUM ; jj++) {
+ for (ii = 0, jj = 0; jj < MAX_BSS_NUM ; jj++) {
if (current_ev >= end_buf)
break;
- pBSS = &(pMgmt->sBSSList[jj]);
- if (pBSS->bActive) {
- //ADD mac address
- memset(&iwe, 0, sizeof(iwe));
- iwe.cmd = SIOCGIWAP;
- iwe.u.ap_addr.sa_family = ARPHRD_ETHER;
+ pBSS = &(pMgmt->sBSSList[jj]);
+ if (pBSS->bActive) {
+ // ADD mac address
+ memset(&iwe, 0, sizeof(iwe));
+ iwe.cmd = SIOCGIWAP;
+ iwe.u.ap_addr.sa_family = ARPHRD_ETHER;
memcpy(iwe.u.ap_addr.sa_data, pBSS->abyBSSID, WLAN_BSSID_LEN);
- current_ev = iwe_stream_add_event(info,current_ev,end_buf, &iwe, IW_EV_ADDR_LEN);
- //ADD ssid
- memset(&iwe, 0, sizeof(iwe));
- iwe.cmd = SIOCGIWESSID;
- pItemSSID = (PWLAN_IE_SSID)pBSS->abySSID;
- iwe.u.data.length = pItemSSID->len;
- iwe.u.data.flags = 1;
- current_ev = iwe_stream_add_point(info,current_ev,end_buf, &iwe, pItemSSID->abySSID);
- //ADD mode
- memset(&iwe, 0, sizeof(iwe));
- iwe.cmd = SIOCGIWMODE;
- if (WLAN_GET_CAP_INFO_ESS(pBSS->wCapInfo)) {
- iwe.u.mode = IW_MODE_INFRA;
- }
- else {
- iwe.u.mode = IW_MODE_ADHOC;
- }
- iwe.len = IW_EV_UINT_LEN;
- current_ev = iwe_stream_add_event(info,current_ev, end_buf, &iwe, IW_EV_UINT_LEN);
- //ADD frequency
- pSuppRates = (PWLAN_IE_SUPP_RATES)pBSS->abySuppRates;
- pExtSuppRates = (PWLAN_IE_SUPP_RATES)pBSS->abyExtSuppRates;
- memset(&iwe, 0, sizeof(iwe));
- iwe.cmd = SIOCGIWFREQ;
- iwe.u.freq.m = pBSS->uChannel;
- iwe.u.freq.e = 0;
- iwe.u.freq.i = 0;
- current_ev = iwe_stream_add_event(info,current_ev,end_buf, &iwe, IW_EV_FREQ_LEN);
+ current_ev = iwe_stream_add_event(info, current_ev, end_buf, &iwe, IW_EV_ADDR_LEN);
+ // ADD ssid
+ memset(&iwe, 0, sizeof(iwe));
+ iwe.cmd = SIOCGIWESSID;
+ pItemSSID = (PWLAN_IE_SSID)pBSS->abySSID;
+ iwe.u.data.length = pItemSSID->len;
+ iwe.u.data.flags = 1;
+ current_ev = iwe_stream_add_point(info, current_ev, end_buf, &iwe, pItemSSID->abySSID);
+ // ADD mode
+ memset(&iwe, 0, sizeof(iwe));
+ iwe.cmd = SIOCGIWMODE;
+ if (WLAN_GET_CAP_INFO_ESS(pBSS->wCapInfo))
+ iwe.u.mode = IW_MODE_INFRA;
+ else
+ iwe.u.mode = IW_MODE_ADHOC;
+ iwe.len = IW_EV_UINT_LEN;
+ current_ev = iwe_stream_add_event(info, current_ev, end_buf, &iwe, IW_EV_UINT_LEN);
+ // ADD frequency
+ pSuppRates = (PWLAN_IE_SUPP_RATES)pBSS->abySuppRates;
+ pExtSuppRates = (PWLAN_IE_SUPP_RATES)pBSS->abyExtSuppRates;
+ memset(&iwe, 0, sizeof(iwe));
+ iwe.cmd = SIOCGIWFREQ;
+ iwe.u.freq.m = pBSS->uChannel;
+ iwe.u.freq.e = 0;
+ iwe.u.freq.i = 0;
+ current_ev = iwe_stream_add_event(info, current_ev,end_buf, &iwe, IW_EV_FREQ_LEN);
{
- int f = (int)pBSS->uChannel - 1;
- if(f < 0)f = 0;
- iwe.u.freq.m = frequency_list[f] * 100000;
- iwe.u.freq.e = 1;
+ int f = (int)pBSS->uChannel - 1;
+ if (f < 0)
+ f = 0;
+ iwe.u.freq.m = frequency_list[f] * 100000;
+ iwe.u.freq.e = 1;
}
- current_ev = iwe_stream_add_event(info,current_ev,end_buf, &iwe, IW_EV_FREQ_LEN);
- //ADD quality
- memset(&iwe, 0, sizeof(iwe));
- iwe.cmd = IWEVQUAL;
- RFvRSSITodBm(pDevice, (BYTE)(pBSS->uRSSI), &ldBm);
- iwe.u.qual.level = ldBm;
- iwe.u.qual.noise = 0;
-
- if(-ldBm<50){
+ current_ev = iwe_stream_add_event(info, current_ev, end_buf, &iwe, IW_EV_FREQ_LEN);
+ // ADD quality
+ memset(&iwe, 0, sizeof(iwe));
+ iwe.cmd = IWEVQUAL;
+ RFvRSSITodBm(pDevice, (BYTE)(pBSS->uRSSI), &ldBm);
+ iwe.u.qual.level = ldBm;
+ iwe.u.qual.noise = 0;
+
+ if (-ldBm < 50)
iwe.u.qual.qual = 100;
- }else if(-ldBm > 90) {
- iwe.u.qual.qual = 0;
- }else {
- iwe.u.qual.qual=(40-(-ldBm-50))*100/40;
+ else if (-ldBm > 90)
+ iwe.u.qual.qual = 0;
+ else
+ iwe.u.qual.qual = (40 - (-ldBm - 50)) * 100 / 40;
+ iwe.u.qual.updated = 7;
+
+ current_ev = iwe_stream_add_event(info, current_ev, end_buf, &iwe, IW_EV_QUAL_LEN);
+ // ADD encryption
+ memset(&iwe, 0, sizeof(iwe));
+ iwe.cmd = SIOCGIWENCODE;
+ iwe.u.data.length = 0;
+ if (WLAN_GET_CAP_INFO_PRIVACY(pBSS->wCapInfo))
+ iwe.u.data.flags = IW_ENCODE_ENABLED | IW_ENCODE_NOKEY;
+ else
+ iwe.u.data.flags = IW_ENCODE_DISABLED;
+ current_ev = iwe_stream_add_point(info, current_ev, end_buf, &iwe, pItemSSID->abySSID);
+
+ memset(&iwe, 0, sizeof(iwe));
+ iwe.cmd = SIOCGIWRATE;
+ iwe.u.bitrate.fixed = iwe.u.bitrate.disabled = 0;
+ current_val = current_ev + IW_EV_LCP_LEN;
+
+ for (kk = 0; kk < 12; kk++) {
+ if (pSuppRates->abyRates[kk] == 0)
+ break;
+ // Bit rate given in 500 kb/s units (+ 0x80)
+ iwe.u.bitrate.value = ((pSuppRates->abyRates[kk] & 0x7f) * 500000);
+ current_val = iwe_stream_add_value(info, current_ev, current_val, end_buf, &iwe, IW_EV_PARAM_LEN);
}
- iwe.u.qual.updated=7;
-
- current_ev = iwe_stream_add_event(info,current_ev, end_buf, &iwe, IW_EV_QUAL_LEN);
- //ADD encryption
- memset(&iwe, 0, sizeof(iwe));
- iwe.cmd = SIOCGIWENCODE;
- iwe.u.data.length = 0;
- if (WLAN_GET_CAP_INFO_PRIVACY(pBSS->wCapInfo)) {
- iwe.u.data.flags =IW_ENCODE_ENABLED | IW_ENCODE_NOKEY;
- }else {
- iwe.u.data.flags = IW_ENCODE_DISABLED;
- }
- current_ev = iwe_stream_add_point(info,current_ev,end_buf, &iwe, pItemSSID->abySSID);
-
- memset(&iwe, 0, sizeof(iwe));
- iwe.cmd = SIOCGIWRATE;
- iwe.u.bitrate.fixed = iwe.u.bitrate.disabled = 0;
- current_val = current_ev + IW_EV_LCP_LEN;
-
- for (kk = 0 ; kk < 12 ; kk++) {
- if (pSuppRates->abyRates[kk] == 0)
- break;
- // Bit rate given in 500 kb/s units (+ 0x80)
- iwe.u.bitrate.value = ((pSuppRates->abyRates[kk] & 0x7f) * 500000);
- current_val = iwe_stream_add_value(info,current_ev, current_val, end_buf, &iwe, IW_EV_PARAM_LEN);
- }
- for (kk = 0 ; kk < 8 ; kk++) {
- if (pExtSuppRates->abyRates[kk] == 0)
- break;
- // Bit rate given in 500 kb/s units (+ 0x80)
- iwe.u.bitrate.value = ((pExtSuppRates->abyRates[kk] & 0x7f) * 500000);
- current_val = iwe_stream_add_value(info,current_ev, current_val, end_buf, &iwe, IW_EV_PARAM_LEN);
- }
-
- if((current_val - current_ev) > IW_EV_LCP_LEN)
- current_ev = current_val;
-
- memset(&iwe, 0, sizeof(iwe));
- iwe.cmd = IWEVCUSTOM;
- sprintf(buf, "bcn_int=%d", pBSS->wBeaconInterval);
- iwe.u.data.length = strlen(buf);
- current_ev = iwe_stream_add_point(info,current_ev, end_buf, &iwe, buf);
-
- if ((pBSS->wWPALen > 0) && (pBSS->wWPALen <= MAX_WPA_IE_LEN)) {
- memset(&iwe, 0, sizeof(iwe));
- iwe.cmd = IWEVGENIE;
- iwe.u.data.length = pBSS->wWPALen;
- current_ev = iwe_stream_add_point(info,current_ev, end_buf, &iwe, pBSS->byWPAIE);
- }
-
- if ((pBSS->wRSNLen > 0) && (pBSS->wRSNLen <= MAX_WPA_IE_LEN)) {
- memset(&iwe, 0, sizeof(iwe));
- iwe.cmd = IWEVGENIE;
- iwe.u.data.length = pBSS->wRSNLen;
- current_ev = iwe_stream_add_point(info,current_ev, end_buf, &iwe, pBSS->byRSNIE);
- }
-
- }
- }// for
+ for (kk = 0; kk < 8; kk++) {
+ if (pExtSuppRates->abyRates[kk] == 0)
+ break;
+ // Bit rate given in 500 kb/s units (+ 0x80)
+ iwe.u.bitrate.value = ((pExtSuppRates->abyRates[kk] & 0x7f) * 500000);
+ current_val = iwe_stream_add_value(info, current_ev, current_val, end_buf, &iwe, IW_EV_PARAM_LEN);
+ }
+
+ if ((current_val - current_ev) > IW_EV_LCP_LEN)
+ current_ev = current_val;
+ memset(&iwe, 0, sizeof(iwe));
+ iwe.cmd = IWEVCUSTOM;
+ sprintf(buf, "bcn_int=%d", pBSS->wBeaconInterval);
+ iwe.u.data.length = strlen(buf);
+ current_ev = iwe_stream_add_point(info, current_ev, end_buf, &iwe, buf);
+
+ if ((pBSS->wWPALen > 0) && (pBSS->wWPALen <= MAX_WPA_IE_LEN)) {
+ memset(&iwe, 0, sizeof(iwe));
+ iwe.cmd = IWEVGENIE;
+ iwe.u.data.length = pBSS->wWPALen;
+ current_ev = iwe_stream_add_point(info, current_ev, end_buf, &iwe, pBSS->byWPAIE);
+ }
+
+ if ((pBSS->wRSNLen > 0) && (pBSS->wRSNLen <= MAX_WPA_IE_LEN)) {
+ memset(&iwe, 0, sizeof(iwe));
+ iwe.cmd = IWEVGENIE;
+ iwe.u.data.length = pBSS->wRSNLen;
+ current_ev = iwe_stream_add_point(info, current_ev, end_buf, &iwe, pBSS->byRSNIE);
+ }
+ }
+ } // for
wrq->length = current_ev - extra;
return 0;
-
}
-
/*
- * Wireless Handler : set frequence or channel
+ * Wireless Handler: set frequence or channel
*/
-
-int iwctl_siwfreq(struct net_device *dev,
- struct iw_request_info *info,
- struct iw_freq *wrq,
- char *extra)
+int iwctl_siwfreq(struct net_device *dev, struct iw_request_info *info,
+ struct iw_freq *wrq, char *extra)
{
- PSDevice pDevice = (PSDevice)netdev_priv(dev);
+ PSDevice pDevice = netdev_priv(dev);
int rc = 0;
- DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWFREQ \n");
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWFREQ \n");
// If setting by frequency, convert to a channel
- if((wrq->e == 1) &&
- (wrq->m >= (int) 2.412e8) &&
- (wrq->m <= (int) 2.487e8)) {
+ if ((wrq->e == 1) && (wrq->m >= (int)2.412e8) &&
+ (wrq->m <= (int)2.487e8)) {
int f = wrq->m / 100000;
int c = 0;
- while((c < 14) && (f != frequency_list[c]))
+ while ((c < 14) && (f != frequency_list[c]))
c++;
wrq->e = 0;
wrq->m = c + 1;
}
// Setting by channel number
- if((wrq->m > 14) || (wrq->e > 0))
+ if ((wrq->m > 14) || (wrq->e > 0)) {
rc = -EOPNOTSUPP;
- else {
+ } else {
int channel = wrq->m;
- if((channel < 1) || (channel > 14)) {
+ if ((channel < 1) || (channel > 14)) {
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%s: New channel value of %d is invalid!\n", dev->name, wrq->m);
rc = -EINVAL;
} else {
- // Yes ! We can set it !!!
- DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " Set to channel = %d\n", channel);
- pDevice->uChannel = channel;
+ // Yes ! We can set it !!!
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " Set to channel = %d\n", channel);
+ pDevice->uChannel = channel;
}
}
-
return rc;
}
/*
- * Wireless Handler : get frequence or channel
+ * Wireless Handler: get frequence or channel
*/
-
-int iwctl_giwfreq(struct net_device *dev,
- struct iw_request_info *info,
- struct iw_freq *wrq,
- char *extra)
+int iwctl_giwfreq(struct net_device *dev, struct iw_request_info *info,
+ struct iw_freq *wrq, char *extra)
{
- PSDevice pDevice = (PSDevice)netdev_priv(dev);
- PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
+ PSDevice pDevice = netdev_priv(dev);
+ PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
- DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWFREQ \n");
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWFREQ \n");
#ifdef WEXT_USECHANNELS
wrq->m = (int)pMgmt->uCurrChannel;
@@ -390,74 +366,66 @@ int iwctl_giwfreq(struct net_device *dev,
#else
{
int f = (int)pMgmt->uCurrChannel - 1;
- if(f < 0)
- f = 0;
+ if (f < 0)
+ f = 0;
wrq->m = frequency_list[f] * 100000;
wrq->e = 1;
}
#endif
-
return 0;
}
/*
- * Wireless Handler : set operation mode
+ * Wireless Handler: set operation mode
*/
-
-int iwctl_siwmode(struct net_device *dev,
- struct iw_request_info *info,
- __u32 *wmode,
- char *extra)
+int iwctl_siwmode(struct net_device *dev, struct iw_request_info *info,
+ __u32 *wmode, char *extra)
{
- PSDevice pDevice = (PSDevice)netdev_priv(dev);
- PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
- int rc = 0;
-
- DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWMODE \n");
+ PSDevice pDevice = netdev_priv(dev);
+ PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
+ int rc = 0;
- if (pMgmt->eCurrMode == WMAC_MODE_ESS_AP && pDevice->bEnableHostapd) {
- DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Can't set operation mode, hostapd is running \n");
- return rc;
- }
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWMODE \n");
- switch(*wmode) {
+ if (pMgmt->eCurrMode == WMAC_MODE_ESS_AP && pDevice->bEnableHostapd) {
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Can't set operation mode, hostapd is running \n");
+ return rc;
+ }
+ switch (*wmode) {
case IW_MODE_ADHOC:
- if (pMgmt->eConfigMode != WMAC_CONFIG_IBSS_STA) {
- pMgmt->eConfigMode = WMAC_CONFIG_IBSS_STA;
- if (pDevice->flags & DEVICE_FLAGS_OPENED) {
- pDevice->bCommit = TRUE;
- }
+ if (pMgmt->eConfigMode != WMAC_CONFIG_IBSS_STA) {
+ pMgmt->eConfigMode = WMAC_CONFIG_IBSS_STA;
+ if (pDevice->flags & DEVICE_FLAGS_OPENED)
+ pDevice->bCommit = TRUE;
}
- DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "set mode to ad-hoc \n");
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "set mode to ad-hoc \n");
break;
case IW_MODE_AUTO:
case IW_MODE_INFRA:
- if (pMgmt->eConfigMode != WMAC_CONFIG_ESS_STA) {
- pMgmt->eConfigMode = WMAC_CONFIG_ESS_STA;
- if (pDevice->flags & DEVICE_FLAGS_OPENED) {
- pDevice->bCommit = TRUE;
- }
+ if (pMgmt->eConfigMode != WMAC_CONFIG_ESS_STA) {
+ pMgmt->eConfigMode = WMAC_CONFIG_ESS_STA;
+ if (pDevice->flags & DEVICE_FLAGS_OPENED)
+ pDevice->bCommit = TRUE;
}
- DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "set mode to infrastructure \n");
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "set mode to infrastructure \n");
break;
case IW_MODE_MASTER:
- pMgmt->eConfigMode = WMAC_CONFIG_ESS_STA;
+ pMgmt->eConfigMode = WMAC_CONFIG_ESS_STA;
rc = -EOPNOTSUPP;
break;
- if (pMgmt->eConfigMode != WMAC_CONFIG_AP) {
- pMgmt->eConfigMode = WMAC_CONFIG_AP;
- if (pDevice->flags & DEVICE_FLAGS_OPENED) {
- pDevice->bCommit = TRUE;
- }
+ if (pMgmt->eConfigMode != WMAC_CONFIG_AP) {
+ pMgmt->eConfigMode = WMAC_CONFIG_AP;
+ if (pDevice->flags & DEVICE_FLAGS_OPENED)
+ pDevice->bCommit = TRUE;
}
- DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "set mode to Access Point \n");
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "set mode to Access Point \n");
break;
case IW_MODE_REPEAT:
- pMgmt->eConfigMode = WMAC_CONFIG_ESS_STA;
+ pMgmt->eConfigMode = WMAC_CONFIG_ESS_STA;
rc = -EOPNOTSUPP;
break;
default:
@@ -468,26 +436,22 @@ int iwctl_siwmode(struct net_device *dev,
}
/*
- * Wireless Handler : get operation mode
+ * Wireless Handler: get operation mode
*/
-
-void iwctl_giwmode(struct net_device *dev,
- struct iw_request_info *info,
- __u32 *wmode,
- char *extra)
+void iwctl_giwmode(struct net_device *dev, struct iw_request_info *info,
+ __u32 *wmode, char *extra)
{
- PSDevice pDevice = (PSDevice)netdev_priv(dev);
- PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
-
+ PSDevice pDevice = netdev_priv(dev);
+ PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
- DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWMODE \n");
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWMODE \n");
// If not managed, assume it's ad-hoc
switch (pMgmt->eConfigMode) {
case WMAC_CONFIG_ESS_STA:
*wmode = IW_MODE_INFRA;
break;
case WMAC_CONFIG_IBSS_STA:
- *wmode = IW_MODE_ADHOC;
+ *wmode = IW_MODE_ADHOC;
break;
case WMAC_CONFIG_AUTO:
*wmode = IW_MODE_INFRA;
@@ -500,21 +464,21 @@ void iwctl_giwmode(struct net_device *dev,
}
}
-
/*
- * Wireless Handler : get capability range
+ * Wireless Handler: get capability range
*/
-
-void iwctl_giwrange(struct net_device *dev,
- struct iw_request_info *info,
- struct iw_point *wrq,
- char *extra)
+void iwctl_giwrange(struct net_device *dev, struct iw_request_info *info,
+ struct iw_point *wrq, char *extra)
{
- struct iw_range *range = (struct iw_range *) extra;
- int i,k;
- BYTE abySupportedRates[13]= {0x02, 0x04, 0x0B, 0x16, 0x0c, 0x12, 0x18, 0x24, 0x30, 0x48, 0x60, 0x6C, 0x90};
+ struct iw_range *range = (struct iw_range *)extra;
+ int i;
+ int k;
+ BYTE abySupportedRates[13] = {
+ 0x02, 0x04, 0x0B, 0x16, 0x0c, 0x12, 0x18, 0x24, 0x30, 0x48,
+ 0x60, 0x6C, 0x90
+ };
- DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWRANGE\n");
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWRANGE\n");
if (wrq->pointer) {
wrq->length = sizeof(struct iw_range);
memset(range, 0, sizeof(struct iw_range));
@@ -522,7 +486,7 @@ void iwctl_giwrange(struct net_device *dev,
range->max_nwid = 0x0000;
range->num_channels = 14;
// Should be based on cap_rid.country to give only
- // what the current card support
+ // what the current card support
k = 0;
for (i = 0; i < 14; i++) {
range->freq[k].i = i + 1; // List index
@@ -531,14 +495,14 @@ void iwctl_giwrange(struct net_device *dev,
}
range->num_frequency = k;
// Hum... Should put the right values there
- range->max_qual.qual = 100;
+ range->max_qual.qual = 100;
range->max_qual.level = 0;
range->max_qual.noise = 0;
range->sensitivity = 255;
- for (i = 0 ; i < 13 ; i++) {
+ for (i = 0; i < 13; i++) {
range->bitrate[i] = abySupportedRates[i] * 500000;
- if(range->bitrate[i] == 0)
+ if (range->bitrate[i] == 0)
break;
}
range->num_bitrates = i;
@@ -546,7 +510,7 @@ void iwctl_giwrange(struct net_device *dev,
// Set an indication of the max TCP throughput
// in bit/s that we can expect using this interface.
// May be use for QoS stuff... Jean II
- if(i > 2)
+ if (i > 2)
range->throughput = 5 * 1000 * 1000;
else
range->throughput = 1.5 * 1000 * 1000;
@@ -556,32 +520,30 @@ void iwctl_giwrange(struct net_device *dev,
range->min_frag = 256;
range->max_frag = 2312;
+ // the encoding capabilities
+ range->num_encoding_sizes = 3;
+ // 64(40) bits WEP
+ range->encoding_size[0] = 5;
+ // 128(104) bits WEP
+ range->encoding_size[1] = 13;
+ // 256 bits for WPA-PSK
+ range->encoding_size[2] = 32;
+ // 4 keys are allowed
+ range->max_encoding_tokens = 4;
- // the encoding capabilities
- range->num_encoding_sizes = 3;
- // 64(40) bits WEP
- range->encoding_size[0] = 5;
- // 128(104) bits WEP
- range->encoding_size[1] = 13;
- // 256 bits for WPA-PSK
- range->encoding_size[2] = 32;
- // 4 keys are allowed
- range->max_encoding_tokens = 4;
-
- range->enc_capa = IW_ENC_CAPA_WPA | IW_ENC_CAPA_WPA2 |
- IW_ENC_CAPA_CIPHER_TKIP | IW_ENC_CAPA_CIPHER_CCMP;
+ range->enc_capa = IW_ENC_CAPA_WPA | IW_ENC_CAPA_WPA2 |
+ IW_ENC_CAPA_CIPHER_TKIP | IW_ENC_CAPA_CIPHER_CCMP;
range->min_pmp = 0;
- range->max_pmp = 1000000;// 1 secs
+ range->max_pmp = 1000000; // 1 secs
range->min_pmt = 0;
- range->max_pmt = 1000000;// 1 secs
+ range->max_pmt = 1000000; // 1 secs
range->pmp_flags = IW_POWER_PERIOD;
range->pmt_flags = IW_POWER_TIMEOUT;
range->pm_capa = IW_POWER_PERIOD | IW_POWER_TIMEOUT | IW_POWER_ALL_R;
// Transmit Power - values are in mW
-
- range->txpower[0] = 100;
+ range->txpower[0] = 100;
range->num_txpower = 1;
range->txpower_capa = IW_TXPOW_MWATT;
range->we_version_source = SUPPORTED_WIRELESS_EXT;
@@ -597,111 +559,97 @@ void iwctl_giwrange(struct net_device *dev,
// Note : with or without the (local->rssi), results
// are somewhat different. - Jean II
range->avg_qual.qual = 6;
- range->avg_qual.level = 176; // -80 dBm
+ range->avg_qual.level = 176; // -80 dBm
range->avg_qual.noise = 0;
}
}
-
/*
* Wireless Handler : set ap mac address
*/
-
-int iwctl_siwap(struct net_device *dev,
- struct iw_request_info *info,
- struct sockaddr *wrq,
- char *extra)
+int iwctl_siwap(struct net_device *dev, struct iw_request_info *info,
+ struct sockaddr *wrq, char *extra)
{
- PSDevice pDevice = (PSDevice)netdev_priv(dev);
- PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
- int rc = 0;
- BYTE ZeroBSSID[WLAN_BSSID_LEN]={0x00,0x00,0x00,0x00,0x00,0x00};
+ PSDevice pDevice = netdev_priv(dev);
+ PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
+ int rc = 0;
+ BYTE ZeroBSSID[WLAN_BSSID_LEN] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
- PRINT_K(" SIOCSIWAP \n");
+ PRINT_K(" SIOCSIWAP \n");
- if (wrq->sa_family != ARPHRD_ETHER)
+ if (wrq->sa_family != ARPHRD_ETHER) {
rc = -EINVAL;
- else {
+ } else {
memcpy(pMgmt->abyDesireBSSID, wrq->sa_data, 6);
+ // mike: add
+ if ((is_broadcast_ether_addr(pMgmt->abyDesireBSSID)) ||
+ (memcmp(pMgmt->abyDesireBSSID, ZeroBSSID, 6) == 0)) {
+ PRINT_K("SIOCSIWAP:invalid desired BSSID return!\n");
+ return rc;
+ }
+ // mike add: if desired AP is hidden ssid(there are
+ // two same BSSID in list), then ignore,because you
+ // don't known which one to be connect with??
+ {
+ unsigned ii;
+ unsigned uSameBssidNum = 0;
+ for (ii = 0; ii < MAX_BSS_NUM; ii++) {
+ if (pMgmt->sBSSList[ii].bActive &&
+ !compare_ether_addr(pMgmt->sBSSList[ii].abyBSSID,
+ pMgmt->abyDesireBSSID)) {
+ uSameBssidNum++;
+ }
+ }
+ if (uSameBssidNum >= 2) { //hit: desired AP is in hidden ssid mode!!!
+ PRINT_K("SIOCSIWAP:ignore for desired AP in hidden mode\n");
+ return rc;
+ }
+ }
- //mike :add
- if ((is_broadcast_ether_addr(pMgmt->abyDesireBSSID)) ||
- (memcmp(pMgmt->abyDesireBSSID, ZeroBSSID, 6) == 0)){
- PRINT_K("SIOCSIWAP:invalid desired BSSID return!\n");
- return rc;
- }
- //mike add: if desired AP is hidden ssid(there are two same BSSID in list),
- // then ignore,because you don't known which one to be connect with??
- {
- unsigned int ii, uSameBssidNum = 0;
- for (ii = 0; ii < MAX_BSS_NUM; ii++) {
- if (pMgmt->sBSSList[ii].bActive &&
- !compare_ether_addr(pMgmt->sBSSList[ii].abyBSSID,
- pMgmt->abyDesireBSSID)) {
- uSameBssidNum++;
- }
- }
- if(uSameBssidNum >= 2) { //hit: desired AP is in hidden ssid mode!!!
- PRINT_K("SIOCSIWAP:ignore for desired AP in hidden mode\n");
- return rc;
- }
- }
-
- if (pDevice->flags & DEVICE_FLAGS_OPENED) {
- pDevice->bCommit = TRUE;
- }
+ if (pDevice->flags & DEVICE_FLAGS_OPENED)
+ pDevice->bCommit = TRUE;
}
return rc;
}
/*
- * Wireless Handler : get ap mac address
+ * Wireless Handler: get ap mac address
*/
-
-int iwctl_giwap(struct net_device *dev,
- struct iw_request_info *info,
- struct sockaddr *wrq,
- char *extra)
+int iwctl_giwap(struct net_device *dev, struct iw_request_info *info,
+ struct sockaddr *wrq, char *extra)
{
- PSDevice pDevice = (PSDevice)netdev_priv(dev);
- PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
-
+ PSDevice pDevice = netdev_priv(dev);
+ PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
- DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWAP \n");
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWAP \n");
- memcpy(wrq->sa_data, pMgmt->abyCurrBSSID, 6);
+ memcpy(wrq->sa_data, pMgmt->abyCurrBSSID, 6);
- if ((pDevice->bLinkPass == FALSE) && (pMgmt->eCurrMode != WMAC_MODE_ESS_AP))
- memset(wrq->sa_data, 0, 6);
+ if ((pDevice->bLinkPass == FALSE) && (pMgmt->eCurrMode != WMAC_MODE_ESS_AP))
+ memset(wrq->sa_data, 0, 6);
- if (pMgmt->eCurrMode == WMAC_MODE_ESS_AP) {
- memcpy(wrq->sa_data, pMgmt->abyCurrBSSID, 6);
- }
+ if (pMgmt->eCurrMode == WMAC_MODE_ESS_AP)
+ memcpy(wrq->sa_data, pMgmt->abyCurrBSSID, 6);
wrq->sa_family = ARPHRD_ETHER;
-
return 0;
-
}
-
/*
- * Wireless Handler : get ap list
+ * Wireless Handler: get ap list
*/
-
-int iwctl_giwaplist(struct net_device *dev,
- struct iw_request_info *info,
- struct iw_point *wrq,
- char *extra)
+int iwctl_giwaplist(struct net_device *dev, struct iw_request_info *info,
+ struct iw_point *wrq, char *extra)
{
- int ii,jj, rc = 0;
+ int ii;
+ int jj;
+ int rc = 0;
struct sockaddr sock[IW_MAX_AP];
struct iw_quality qual[IW_MAX_AP];
- PSDevice pDevice = (PSDevice)netdev_priv(dev);
- PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
-
+ PSDevice pDevice = netdev_priv(dev);
+ PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
- DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWAPLIST \n");
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWAPLIST \n");
// Only super-user can see AP list
if (!capable(CAP_NET_ADMIN)) {
@@ -710,15 +658,14 @@ int iwctl_giwaplist(struct net_device *dev,
}
if (wrq->pointer) {
-
PKnownBSS pBSS = &(pMgmt->sBSSList[0]);
for (ii = 0, jj= 0; ii < MAX_BSS_NUM; ii++) {
- pBSS = &(pMgmt->sBSSList[ii]);
- if (!pBSS->bActive)
- continue;
- if ( jj >= IW_MAX_AP)
- break;
+ pBSS = &(pMgmt->sBSSList[ii]);
+ if (!pBSS->bActive)
+ continue;
+ if (jj >= IW_MAX_AP)
+ break;
memcpy(sock[jj].sa_data, pBSS->abyBSSID, 6);
sock[jj].sa_family = ARPHRD_ETHER;
qual[jj].level = pBSS->uRSSI;
@@ -729,151 +676,137 @@ int iwctl_giwaplist(struct net_device *dev,
wrq->flags = 1; // Should be define'd
wrq->length = jj;
- memcpy(extra, sock, sizeof(struct sockaddr)*jj);
- memcpy(extra + sizeof(struct sockaddr)*jj, qual, sizeof(struct iw_quality)*jj);
+ memcpy(extra, sock, sizeof(struct sockaddr) * jj);
+ memcpy(extra + sizeof(struct sockaddr) * jj, qual, sizeof(struct iw_quality) * jj);
}
-
return rc;
}
-
/*
- * Wireless Handler : set essid
+ * Wireless Handler: set essid
*/
-
-int iwctl_siwessid(struct net_device *dev,
- struct iw_request_info *info,
- struct iw_point *wrq,
- char *extra)
+int iwctl_siwessid(struct net_device *dev, struct iw_request_info *info,
+ struct iw_point *wrq, char *extra)
{
- PSDevice pDevice = (PSDevice)netdev_priv(dev);
- PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
- PWLAN_IE_SSID pItemSSID;
+ PSDevice pDevice = netdev_priv(dev);
+ PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
+ PWLAN_IE_SSID pItemSSID;
- if (!(pDevice->flags & DEVICE_FLAGS_OPENED))
- return -EINVAL;
+ if (!(pDevice->flags & DEVICE_FLAGS_OPENED))
+ return -EINVAL;
- DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWESSID :\n");
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWESSID :\n");
- pDevice->fWPA_Authened = FALSE;
+ pDevice->fWPA_Authened = FALSE;
// Check if we asked for `any'
- if(wrq->flags == 0) {
+ if (wrq->flags == 0) {
// Just send an empty SSID list
memset(pMgmt->abyDesireSSID, 0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1);
- memset(pMgmt->abyDesireBSSID, 0xFF,6);
- PRINT_K("set essid to 'any' \n");
- #ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
- //Unknown desired AP,so here need not associate??
- return 0;
- #endif
+ memset(pMgmt->abyDesireBSSID, 0xFF,6);
+ PRINT_K("set essid to 'any' \n");
+#ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
+ // Unknown desired AP, so here need not associate??
+ return 0;
+#endif
} else {
// Set the SSID
memset(pMgmt->abyDesireSSID, 0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1);
- pItemSSID = (PWLAN_IE_SSID)pMgmt->abyDesireSSID;
- pItemSSID->byElementID = WLAN_EID_SSID;
+ pItemSSID = (PWLAN_IE_SSID)pMgmt->abyDesireSSID;
+ pItemSSID->byElementID = WLAN_EID_SSID;
memcpy(pItemSSID->abySSID, extra, wrq->length);
- if (pItemSSID->abySSID[wrq->length - 1] == '\0') {
- if(wrq->length>0)
- pItemSSID->len = wrq->length - 1;
- }
- else
- pItemSSID->len = wrq->length;
- PRINT_K("set essid to %s \n",pItemSSID->abySSID);
+ if (pItemSSID->abySSID[wrq->length - 1] == '\0') {
+ if (wrq->length>0)
+ pItemSSID->len = wrq->length - 1;
+ } else {
+ pItemSSID->len = wrq->length;
+ }
+ PRINT_K("set essid to %s \n", pItemSSID->abySSID);
- //mike:need clear desiredBSSID
- if(pItemSSID->len==0) {
- memset(pMgmt->abyDesireBSSID, 0xFF,6);
- return 0;
- }
+ // mike: need clear desiredBSSID
+ if (pItemSSID->len==0) {
+ memset(pMgmt->abyDesireBSSID, 0xFF, 6);
+ return 0;
+ }
#ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
- //Wext wil order another command of siwap to link with desired AP,
- //so here need not associate??
- if(pDevice->bWPASuppWextEnabled == TRUE) {
- /*******search if in hidden ssid mode ****/
- {
- PKnownBSS pCurr = NULL;
- BYTE abyTmpDesireSSID[WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1];
- unsigned int ii, uSameBssidNum = 0;
-
- memcpy(abyTmpDesireSSID,pMgmt->abyDesireSSID,sizeof(abyTmpDesireSSID));
- pCurr = BSSpSearchBSSList(pDevice,
- NULL,
- abyTmpDesireSSID,
- pDevice->eConfigPHYMode
- );
-
- if (pCurr == NULL){
- PRINT_K("SIOCSIWESSID:hidden ssid site survey before associate.......\n");
- vResetCommandTimer((void *) pDevice);
- pMgmt->eScanType = WMAC_SCAN_ACTIVE;
- bScheduleCommand((void *) pDevice,
- WLAN_CMD_BSSID_SCAN,
- pMgmt->abyDesireSSID);
- bScheduleCommand((void *) pDevice,
- WLAN_CMD_SSID,
- pMgmt->abyDesireSSID);
- }
- else { //mike:to find out if that desired SSID is a hidden-ssid AP ,
- // by means of judging if there are two same BSSID exist in list ?
- for (ii = 0; ii < MAX_BSS_NUM; ii++) {
- if (pMgmt->sBSSList[ii].bActive &&
- !compare_ether_addr(pMgmt->sBSSList[ii].abyBSSID,
- pCurr->abyBSSID)) {
- uSameBssidNum++;
- }
- }
- if(uSameBssidNum >= 2) { //hit: desired AP is in hidden ssid mode!!!
- PRINT_K("SIOCSIWESSID:hidden ssid directly associate.......\n");
- vResetCommandTimer((void *) pDevice);
- pMgmt->eScanType = WMAC_SCAN_PASSIVE; //this scan type,you'll submit scan result!
- bScheduleCommand((void *) pDevice,
- WLAN_CMD_BSSID_SCAN,
- pMgmt->abyDesireSSID);
- bScheduleCommand((void *) pDevice,
- WLAN_CMD_SSID,
- pMgmt->abyDesireSSID);
- }
- }
- }
- return 0;
- }
- #endif
-
- DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "set essid = %s \n", pItemSSID->abySSID);
- }
+ // Wext wil order another command of siwap to link
+ // with desired AP, so here need not associate??
+ if (pDevice->bWPASuppWextEnabled == TRUE) {
+ /*******search if in hidden ssid mode ****/
+ PKnownBSS pCurr = NULL;
+ BYTE abyTmpDesireSSID[WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1];
+ unsigned ii;
+ unsigned uSameBssidNum = 0;
+
+ memcpy(abyTmpDesireSSID, pMgmt->abyDesireSSID, sizeof(abyTmpDesireSSID));
+ pCurr = BSSpSearchBSSList(pDevice, NULL,
+ abyTmpDesireSSID,
+ pDevice->eConfigPHYMode);
+
+ if (pCurr == NULL) {
+ PRINT_K("SIOCSIWESSID:hidden ssid site survey before associate.......\n");
+ vResetCommandTimer((void *)pDevice);
+ pMgmt->eScanType = WMAC_SCAN_ACTIVE;
+ bScheduleCommand((void *)pDevice,
+ WLAN_CMD_BSSID_SCAN,
+ pMgmt->abyDesireSSID);
+ bScheduleCommand((void *)pDevice,
+ WLAN_CMD_SSID,
+ pMgmt->abyDesireSSID);
+ } else { // mike: to find out if that desired SSID is a
+ // hidden-ssid AP, by means of judging if there
+ // are two same BSSID exist in list ?
+ for (ii = 0; ii < MAX_BSS_NUM; ii++) {
+ if (pMgmt->sBSSList[ii].bActive &&
+ !compare_ether_addr(pMgmt->sBSSList[ii].abyBSSID,
+ pCurr->abyBSSID)) {
+ uSameBssidNum++;
+ }
+ }
+ if (uSameBssidNum >= 2) { // hit: desired AP is in hidden ssid mode!!!
+ PRINT_K("SIOCSIWESSID:hidden ssid directly associate.......\n");
+ vResetCommandTimer((void *)pDevice);
+ pMgmt->eScanType = WMAC_SCAN_PASSIVE; // this scan type, you'll submit scan result!
+ bScheduleCommand((void *)pDevice,
+ WLAN_CMD_BSSID_SCAN,
+ pMgmt->abyDesireSSID);
+ bScheduleCommand((void *)pDevice,
+ WLAN_CMD_SSID,
+ pMgmt->abyDesireSSID);
+ }
+ }
+ return 0;
+ }
+#endif
- if (pDevice->flags & DEVICE_FLAGS_OPENED) {
- pDevice->bCommit = TRUE;
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "set essid = %s \n", pItemSSID->abySSID);
}
+ if (pDevice->flags & DEVICE_FLAGS_OPENED)
+ pDevice->bCommit = TRUE;
return 0;
}
-
/*
- * Wireless Handler : get essid
+ * Wireless Handler: get essid
*/
-void iwctl_giwessid(struct net_device *dev,
- struct iw_request_info *info,
- struct iw_point *wrq,
- char *extra)
+void iwctl_giwessid(struct net_device *dev, struct iw_request_info *info,
+ struct iw_point *wrq, char *extra)
{
+ PSDevice pDevice = netdev_priv(dev);
+ PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
+ PWLAN_IE_SSID pItemSSID;
- PSDevice pDevice = (PSDevice)netdev_priv(dev);
- PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
- PWLAN_IE_SSID pItemSSID;
-
- DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWESSID \n");
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWESSID \n");
- // Note : if wrq->u.data.flags != 0, we should
- // get the relevant SSID from the SSID list...
+ // Note: if wrq->u.data.flags != 0, we should get the relevant
+ // SSID from the SSID list...
// Get the current SSID
- pItemSSID = (PWLAN_IE_SSID)pMgmt->abyCurrSSID;
- memcpy(extra, pItemSSID->abySSID , pItemSSID->len);
+ pItemSSID = (PWLAN_IE_SSID)pMgmt->abyCurrSSID;
+ memcpy(extra, pItemSSID->abySSID, pItemSSID->len);
extra[pItemSSID->len] = '\0';
wrq->length = pItemSSID->len;
@@ -881,146 +814,138 @@ void iwctl_giwessid(struct net_device *dev,
}
/*
- * Wireless Handler : set data rate
+ * Wireless Handler: set data rate
*/
-
-int iwctl_siwrate(struct net_device *dev,
- struct iw_request_info *info,
- struct iw_param *wrq,
- char *extra)
+int iwctl_siwrate(struct net_device *dev, struct iw_request_info *info,
+ struct iw_param *wrq, char *extra)
{
- PSDevice pDevice = (PSDevice)netdev_priv(dev);
- int rc = 0;
- u8 brate = 0;
- int i;
- BYTE abySupportedRates[13]= {0x02, 0x04, 0x0B, 0x16, 0x0c, 0x12, 0x18, 0x24, 0x30, 0x48, 0x60, 0x6C, 0x90};
-
+ PSDevice pDevice = netdev_priv(dev);
+ int rc = 0;
+ u8 brate = 0;
+ int i;
+ BYTE abySupportedRates[13] = {
+ 0x02, 0x04, 0x0B, 0x16, 0x0c, 0x12, 0x18, 0x24, 0x30, 0x48,
+ 0x60, 0x6C, 0x90
+ };
- DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWRATE \n");
- if (!(pDevice->flags & DEVICE_FLAGS_OPENED)) {
- rc = -EINVAL;
- return rc;
- }
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWRATE \n");
+ if (!(pDevice->flags & DEVICE_FLAGS_OPENED)) {
+ rc = -EINVAL;
+ return rc;
+ }
- // First : get a valid bit rate value
+ // First: get a valid bit rate value
// Which type of value
- if((wrq->value < 13) &&
- (wrq->value >= 0)) {
+ if ((wrq->value < 13) && (wrq->value >= 0)) {
// Setting by rate index
// Find value in the magic rate table
brate = wrq->value;
} else {
// Setting by frequency value
- u8 normvalue = (u8) (wrq->value/500000);
+ u8 normvalue = (u8)(wrq->value/500000);
// Check if rate is valid
- for (i = 0 ; i < 13 ; i++) {
- if(normvalue == abySupportedRates[i]) {
+ for (i = 0; i < 13; i++) {
+ if (normvalue == abySupportedRates[i]) {
brate = i;
break;
}
}
}
// -1 designed the max rate (mostly auto mode)
- if(wrq->value == -1) {
+ if (wrq->value == -1) {
// Get the highest available rate
- for (i = 0 ; i < 13 ; i++) {
- if(abySupportedRates[i] == 0)
+ for (i = 0; i < 13; i++) {
+ if (abySupportedRates[i] == 0)
break;
}
- if(i != 0)
+ if (i != 0)
brate = i - 1;
}
// Check that it is valid
// brate is index of abySupportedRates[]
- if(brate > 13 ) {
+ if (brate > 13 ) {
rc = -EINVAL;
return rc;
}
// Now, check if we want a fixed or auto value
- if(wrq->fixed != 0) {
+ if (wrq->fixed != 0) {
// Fixed mode
// One rate, fixed
pDevice->bFixRate = TRUE;
- if ((pDevice->byBBType == BB_TYPE_11B)&& (brate > 3)) {
- pDevice->uConnectionRate = 3;
- }
- else {
- pDevice->uConnectionRate = brate;
- DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Fixed to Rate %d \n", pDevice->uConnectionRate);
- }
-
+ if ((pDevice->byBBType == BB_TYPE_11B) && (brate > 3)) {
+ pDevice->uConnectionRate = 3;
+ } else {
+ pDevice->uConnectionRate = brate;
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Fixed to Rate %d \n", pDevice->uConnectionRate);
+ }
+ } else {
+ pDevice->bFixRate = FALSE;
+ pDevice->uConnectionRate = 13;
}
- else {
- pDevice->bFixRate = FALSE;
- pDevice->uConnectionRate = 13;
- }
return rc;
}
/*
- * Wireless Handler : get data rate
+ * Wireless Handler: get data rate
*/
-void iwctl_giwrate(struct net_device *dev,
- struct iw_request_info *info,
- struct iw_param *wrq,
- char *extra)
+void iwctl_giwrate(struct net_device *dev, struct iw_request_info *info,
+ struct iw_param *wrq, char *extra)
{
- PSDevice pDevice = (PSDevice)netdev_priv(dev);
- PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
+ PSDevice pDevice = netdev_priv(dev);
+ PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
+
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWRATE \n");
+ {
+ BYTE abySupportedRates[13] = {
+ 0x02, 0x04, 0x0B, 0x16, 0x0c, 0x12, 0x18, 0x24, 0x30,
+ 0x48, 0x60, 0x6C, 0x90
+ };
+ int brate = 0;
- DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWRATE \n");
- {
- BYTE abySupportedRates[13]= {0x02, 0x04, 0x0B, 0x16, 0x0c, 0x12, 0x18, 0x24, 0x30, 0x48, 0x60, 0x6C, 0x90};
- int brate = 0;
if (pDevice->uConnectionRate < 13) {
- brate = abySupportedRates[pDevice->uConnectionRate];
- }else {
- if (pDevice->byBBType == BB_TYPE_11B)
- brate = 0x16;
- if (pDevice->byBBType == BB_TYPE_11G)
- brate = 0x6C;
- if (pDevice->byBBType == BB_TYPE_11A)
- brate = 0x6C;
- }
-
- if (pMgmt->eCurrMode == WMAC_MODE_ESS_AP) {
- if (pDevice->byBBType == BB_TYPE_11B)
- brate = 0x16;
- if (pDevice->byBBType == BB_TYPE_11G)
- brate = 0x6C;
- if (pDevice->byBBType == BB_TYPE_11A)
- brate = 0x6C;
- }
+ brate = abySupportedRates[pDevice->uConnectionRate];
+ } else {
+ if (pDevice->byBBType == BB_TYPE_11B)
+ brate = 0x16;
+ if (pDevice->byBBType == BB_TYPE_11G)
+ brate = 0x6C;
+ if (pDevice->byBBType == BB_TYPE_11A)
+ brate = 0x6C;
+ }
+ if (pMgmt->eCurrMode == WMAC_MODE_ESS_AP) {
+ if (pDevice->byBBType == BB_TYPE_11B)
+ brate = 0x16;
+ if (pDevice->byBBType == BB_TYPE_11G)
+ brate = 0x6C;
+ if (pDevice->byBBType == BB_TYPE_11A)
+ brate = 0x6C;
+ }
if (pDevice->uConnectionRate == 13)
- brate = abySupportedRates[pDevice->wCurrentRate];
- wrq->value = brate * 500000;
- // If more than one rate, set auto
- if (pDevice->bFixRate == TRUE)
- wrq->fixed = TRUE;
- }
+ brate = abySupportedRates[pDevice->wCurrentRate];
+ wrq->value = brate * 500000;
+ // If more than one rate, set auto
+ if (pDevice->bFixRate == TRUE)
+ wrq->fixed = TRUE;
+ }
}
-
-
/*
- * Wireless Handler : set rts threshold
+ * Wireless Handler: set rts threshold
*/
-int iwctl_siwrts(struct net_device *dev,
- struct iw_param *wrq)
+int iwctl_siwrts(struct net_device *dev, struct iw_param *wrq)
{
- PSDevice pDevice = (PSDevice)netdev_priv(dev);
+ PSDevice pDevice = netdev_priv(dev);
if ((wrq->value < 0 || wrq->value > 2312) && !wrq->disabled)
return -EINVAL;
else if (wrq->disabled)
pDevice->wRTSThreshold = 2312;
-
else
pDevice->wRTSThreshold = wrq->value;
@@ -1028,87 +953,68 @@ int iwctl_siwrts(struct net_device *dev,
}
/*
- * Wireless Handler : get rts
+ * Wireless Handler: get rts
*/
-
-int iwctl_giwrts(struct net_device *dev,
- struct iw_request_info *info,
- struct iw_param *wrq,
- char *extra)
+int iwctl_giwrts(struct net_device *dev, struct iw_request_info *info,
+ struct iw_param *wrq, char *extra)
{
- PSDevice pDevice = (PSDevice)netdev_priv(dev);
+ PSDevice pDevice = netdev_priv(dev);
- DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWRTS \n");
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWRTS \n");
wrq->value = pDevice->wRTSThreshold;
wrq->disabled = (wrq->value >= 2312);
wrq->fixed = 1;
-
return 0;
}
/*
- * Wireless Handler : set fragment threshold
+ * Wireless Handler: set fragment threshold
*/
-
-int iwctl_siwfrag(struct net_device *dev,
- struct iw_request_info *info,
- struct iw_param *wrq,
- char *extra)
+int iwctl_siwfrag(struct net_device *dev, struct iw_request_info *info,
+ struct iw_param *wrq, char *extra)
{
- PSDevice pDevice = (PSDevice)netdev_priv(dev);
- int rc = 0;
- int fthr = wrq->value;
-
-
- DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWFRAG \n");
+ PSDevice pDevice = netdev_priv(dev);
+ int rc = 0;
+ int fthr = wrq->value;
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWFRAG \n");
- if (wrq->disabled)
+ if (wrq->disabled)
fthr = 2312;
- if((fthr < 256) || (fthr > 2312)) {
+ if ((fthr < 256) || (fthr > 2312)) {
rc = -EINVAL;
- }else {
- fthr &= ~0x1; // Get an even value
- pDevice->wFragmentationThreshold = (u16)fthr;
- }
-
+ } else {
+ fthr &= ~0x1; // Get an even value
+ pDevice->wFragmentationThreshold = (u16)fthr;
+ }
return rc;
}
/*
- * Wireless Handler : get fragment threshold
+ * Wireless Handler: get fragment threshold
*/
-
-int iwctl_giwfrag(struct net_device *dev,
- struct iw_request_info *info,
- struct iw_param *wrq,
- char *extra)
+int iwctl_giwfrag(struct net_device *dev, struct iw_request_info *info,
+ struct iw_param *wrq, char *extra)
{
- PSDevice pDevice = (PSDevice)netdev_priv(dev);
+ PSDevice pDevice = netdev_priv(dev);
- DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWFRAG \n");
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWFRAG \n");
wrq->value = pDevice->wFragmentationThreshold;
wrq->disabled = (wrq->value >= 2312);
wrq->fixed = 1;
-
return 0;
}
-
-
/*
- * Wireless Handler : set retry threshold
+ * Wireless Handler: set retry threshold
*/
-int iwctl_siwretry(struct net_device *dev,
- struct iw_request_info *info,
- struct iw_param *wrq,
- char *extra)
+int iwctl_siwretry(struct net_device *dev, struct iw_request_info *info,
+ struct iw_param *wrq, char *extra)
{
- PSDevice pDevice = (PSDevice)netdev_priv(dev);
- int rc = 0;
-
+ PSDevice pDevice = netdev_priv(dev);
+ int rc = 0;
- DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWRETRY \n");
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWRETRY \n");
if (wrq->disabled) {
rc = -EINVAL;
@@ -1116,238 +1022,215 @@ int iwctl_siwretry(struct net_device *dev,
}
if (wrq->flags & IW_RETRY_LIMIT) {
- if(wrq->flags & IW_RETRY_MAX)
+ if (wrq->flags & IW_RETRY_MAX) {
pDevice->byLongRetryLimit = wrq->value;
- else if (wrq->flags & IW_RETRY_MIN)
+ } else if (wrq->flags & IW_RETRY_MIN) {
pDevice->byShortRetryLimit = wrq->value;
- else {
+ } else {
// No modifier : set both
pDevice->byShortRetryLimit = wrq->value;
pDevice->byLongRetryLimit = wrq->value;
}
}
- if (wrq->flags & IW_RETRY_LIFETIME) {
+ if (wrq->flags & IW_RETRY_LIFETIME)
pDevice->wMaxTransmitMSDULifetime = wrq->value;
- }
-
-
return rc;
}
/*
- * Wireless Handler : get retry threshold
+ * Wireless Handler: get retry threshold
*/
-int iwctl_giwretry(struct net_device *dev,
- struct iw_request_info *info,
- struct iw_param *wrq,
- char *extra)
+int iwctl_giwretry(struct net_device *dev, struct iw_request_info *info,
+ struct iw_param *wrq, char *extra)
{
- PSDevice pDevice = (PSDevice)netdev_priv(dev);
- DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWRETRY \n");
- wrq->disabled = 0; // Can't be disabled
+ PSDevice pDevice = netdev_priv(dev);
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWRETRY \n");
+ wrq->disabled = 0; // Can't be disabled
- // Note : by default, display the min retry number
- if((wrq->flags & IW_RETRY_TYPE) == IW_RETRY_LIFETIME) {
+ // Note: by default, display the min retry number
+ if ((wrq->flags & IW_RETRY_TYPE) == IW_RETRY_LIFETIME) {
wrq->flags = IW_RETRY_LIFETIME;
- wrq->value = (int)pDevice->wMaxTransmitMSDULifetime; //ms
- } else if((wrq->flags & IW_RETRY_MAX)) {
+ wrq->value = (int)pDevice->wMaxTransmitMSDULifetime; // ms
+ } else if ((wrq->flags & IW_RETRY_MAX)) {
wrq->flags = IW_RETRY_LIMIT | IW_RETRY_MAX;
wrq->value = (int)pDevice->byLongRetryLimit;
} else {
wrq->flags = IW_RETRY_LIMIT;
wrq->value = (int)pDevice->byShortRetryLimit;
- if((int)pDevice->byShortRetryLimit != (int)pDevice->byLongRetryLimit)
+ if ((int)pDevice->byShortRetryLimit != (int)pDevice->byLongRetryLimit)
wrq->flags |= IW_RETRY_MIN;
}
-
-
return 0;
}
-
/*
- * Wireless Handler : set encode mode
+ * Wireless Handler: set encode mode
*/
-int iwctl_siwencode(struct net_device *dev,
- struct iw_request_info *info,
- struct iw_point *wrq,
- char *extra)
+int iwctl_siwencode(struct net_device *dev, struct iw_request_info *info,
+ struct iw_point *wrq, char *extra)
{
- PSDevice pDevice = (PSDevice)netdev_priv(dev);
- PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
+ PSDevice pDevice = netdev_priv(dev);
+ PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
DWORD dwKeyIndex = (DWORD)(wrq->flags & IW_ENCODE_INDEX);
- int ii,uu, rc = 0;
+ int ii;
+ int uu;
+ int rc = 0;
int index = (wrq->flags & IW_ENCODE_INDEX);
-
- DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWENCODE \n");
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWENCODE \n");
// Check the size of the key
if (wrq->length > WLAN_WEP232_KEYLEN) {
rc = -EINVAL;
- return rc;
+ return rc;
}
if (dwKeyIndex > WLAN_WEP_NKEYS) {
rc = -EINVAL;
- return rc;
- }
+ return rc;
+ }
- if (dwKeyIndex > 0)
+ if (dwKeyIndex > 0)
dwKeyIndex--;
// Send the key to the card
if (wrq->length > 0) {
-
- if (wrq->length == WLAN_WEP232_KEYLEN) {
- DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Set 232 bit wep key\n");
- }
- else if (wrq->length == WLAN_WEP104_KEYLEN) {
- DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Set 104 bit wep key\n");
- }
- else if (wrq->length == WLAN_WEP40_KEYLEN) {
- DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Set 40 bit wep key, index= %d\n", (int)dwKeyIndex);
- }
- memset(pDevice->abyKey, 0, WLAN_WEP232_KEYLEN);
- memcpy(pDevice->abyKey, extra, wrq->length);
-
- DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"abyKey: ");
- for (ii = 0; ii < wrq->length; ii++) {
- DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%02x ", pDevice->abyKey[ii]);
- }
-
- if (pDevice->flags & DEVICE_FLAGS_OPENED) {
- spin_lock_irq(&pDevice->lock);
- KeybSetDefaultKey( pDevice,
- &(pDevice->sKey),
- dwKeyIndex | (1 << 31),
- wrq->length,
- NULL,
- pDevice->abyKey,
- KEY_CTL_WEP
- );
- spin_unlock_irq(&pDevice->lock);
- }
- pDevice->byKeyIndex = (BYTE)dwKeyIndex;
- pDevice->uKeyLength = wrq->length;
- pDevice->bTransmitKey = TRUE;
- pDevice->bEncryptionEnable = TRUE;
- pDevice->eEncryptionStatus = Ndis802_11Encryption1Enabled;
-
- // Do we want to just set the transmit key index ?
- if ( index < 4 ) {
- pDevice->byKeyIndex = index;
+ if (wrq->length == WLAN_WEP232_KEYLEN) {
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Set 232 bit wep key\n");
+ } else if (wrq->length == WLAN_WEP104_KEYLEN) {
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Set 104 bit wep key\n");
+ } else if (wrq->length == WLAN_WEP40_KEYLEN) {
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Set 40 bit wep key, index= %d\n", (int)dwKeyIndex);
+ }
+ memset(pDevice->abyKey, 0, WLAN_WEP232_KEYLEN);
+ memcpy(pDevice->abyKey, extra, wrq->length);
+
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"abyKey: ");
+ for (ii = 0; ii < wrq->length; ii++)
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%02x ", pDevice->abyKey[ii]);
+
+ if (pDevice->flags & DEVICE_FLAGS_OPENED) {
+ spin_lock_irq(&pDevice->lock);
+ KeybSetDefaultKey(pDevice,
+ &(pDevice->sKey),
+ dwKeyIndex | (1 << 31),
+ wrq->length, NULL,
+ pDevice->abyKey,
+ KEY_CTL_WEP);
+ spin_unlock_irq(&pDevice->lock);
+ }
+ pDevice->byKeyIndex = (BYTE)dwKeyIndex;
+ pDevice->uKeyLength = wrq->length;
+ pDevice->bTransmitKey = TRUE;
+ pDevice->bEncryptionEnable = TRUE;
+ pDevice->eEncryptionStatus = Ndis802_11Encryption1Enabled;
+
+ // Do we want to just set the transmit key index?
+ if (index < 4) {
+ pDevice->byKeyIndex = index;
} else if (!(wrq->flags & IW_ENCODE_MODE)) {
- rc = -EINVAL;
- return rc;
- }
+ rc = -EINVAL;
+ return rc;
+ }
}
// Read the flags
- if(wrq->flags & IW_ENCODE_DISABLED){
-
- DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Disable WEP function\n");
+ if (wrq->flags & IW_ENCODE_DISABLED) {
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Disable WEP function\n");
pMgmt->bShareKeyAlgorithm = FALSE;
- pDevice->bEncryptionEnable = FALSE;
- pDevice->eEncryptionStatus = Ndis802_11EncryptionDisabled;
- if (pDevice->flags & DEVICE_FLAGS_OPENED) {
- spin_lock_irq(&pDevice->lock);
- for (uu = 0; uu < MAX_KEY_TABLE; uu++)
- MACvDisableKeyEntry(pDevice, uu);
- spin_unlock_irq(&pDevice->lock);
- }
+ pDevice->bEncryptionEnable = FALSE;
+ pDevice->eEncryptionStatus = Ndis802_11EncryptionDisabled;
+ if (pDevice->flags & DEVICE_FLAGS_OPENED) {
+ spin_lock_irq(&pDevice->lock);
+ for (uu = 0; uu < MAX_KEY_TABLE; uu++)
+ MACvDisableKeyEntry(pDevice, uu);
+ spin_unlock_irq(&pDevice->lock);
+ }
}
- if(wrq->flags & IW_ENCODE_RESTRICTED) {
- DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Enable WEP & ShareKey System\n");
+ if (wrq->flags & IW_ENCODE_RESTRICTED) {
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Enable WEP & ShareKey System\n");
pMgmt->bShareKeyAlgorithm = TRUE;
}
- if(wrq->flags & IW_ENCODE_OPEN) {
- DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Enable WEP & Open System\n");
+ if (wrq->flags & IW_ENCODE_OPEN) {
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Enable WEP & Open System\n");
pMgmt->bShareKeyAlgorithm = FALSE;
}
#ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
- memset(pMgmt->abyDesireBSSID, 0xFF,6);
+ memset(pMgmt->abyDesireBSSID, 0xFF, 6);
#endif
-
return rc;
}
-int iwctl_giwencode(struct net_device *dev,
- struct iw_request_info *info,
- struct iw_point *wrq,
- char *extra)
+int iwctl_giwencode(struct net_device *dev, struct iw_request_info *info,
+ struct iw_point *wrq, char *extra)
{
- PSDevice pDevice = (PSDevice)netdev_priv(dev);
- PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
+ PSDevice pDevice = netdev_priv(dev);
+ PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
char abyKey[WLAN_WEP232_KEYLEN];
- unsigned int index = (unsigned int)(wrq->flags & IW_ENCODE_INDEX);
- PSKeyItem pKey = NULL;
+ unsigned index = (unsigned)(wrq->flags & IW_ENCODE_INDEX);
+ PSKeyItem pKey = NULL;
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWENCODE\n");
- if (index > WLAN_WEP_NKEYS) {
+ if (index > WLAN_WEP_NKEYS)
return -EINVAL;
+ if (index < 1) { // get default key
+ if (pDevice->byKeyIndex < WLAN_WEP_NKEYS)
+ index = pDevice->byKeyIndex;
+ else
+ index = 0;
+ } else {
+ index--;
}
- if(index<1){//get default key
- if(pDevice->byKeyIndex<WLAN_WEP_NKEYS){
- index=pDevice->byKeyIndex;
- } else
- index=0;
- }else
- index--;
memset(abyKey, 0, WLAN_WEP232_KEYLEN);
// Check encryption mode
wrq->flags = IW_ENCODE_NOKEY;
// Is WEP enabled ???
if (pDevice->bEncryptionEnable)
- wrq->flags |= IW_ENCODE_ENABLED;
+ wrq->flags |= IW_ENCODE_ENABLED;
else
- wrq->flags |= IW_ENCODE_DISABLED;
+ wrq->flags |= IW_ENCODE_DISABLED;
if (pMgmt->bShareKeyAlgorithm)
- wrq->flags |= IW_ENCODE_RESTRICTED;
+ wrq->flags |= IW_ENCODE_RESTRICTED;
else
- wrq->flags |= IW_ENCODE_OPEN;
- wrq->length=0;
-
- if((index==0)&&(pDevice->eEncryptionStatus == Ndis802_11Encryption2Enabled||
- pDevice->eEncryptionStatus == Ndis802_11Encryption3Enabled)){//get wpa pairwise key
- if (KeybGetKey(&(pDevice->sKey),pMgmt->abyCurrBSSID, 0xffffffff, &pKey)){
- wrq->length = pKey->uKeyLength;
- memcpy(abyKey, pKey->abyKey, pKey->uKeyLength);
- memcpy(extra, abyKey, WLAN_WEP232_KEYLEN);
- }
- }else if (KeybGetKey(&(pDevice->sKey), pDevice->abyBroadcastAddr, (BYTE)index , &pKey)){
+ wrq->flags |= IW_ENCODE_OPEN;
+ wrq->length = 0;
+
+ if ((index == 0) && (pDevice->eEncryptionStatus == Ndis802_11Encryption2Enabled ||
+ pDevice->eEncryptionStatus == Ndis802_11Encryption3Enabled)) { // get wpa pairwise key
+ if (KeybGetKey(&(pDevice->sKey), pMgmt->abyCurrBSSID, 0xffffffff, &pKey)) {
wrq->length = pKey->uKeyLength;
- memcpy(abyKey, pKey->abyKey, pKey->uKeyLength);
- memcpy(extra, abyKey, WLAN_WEP232_KEYLEN);
+ memcpy(abyKey, pKey->abyKey, pKey->uKeyLength);
+ memcpy(extra, abyKey, WLAN_WEP232_KEYLEN);
+ }
+ } else if (KeybGetKey(&(pDevice->sKey), pDevice->abyBroadcastAddr, (BYTE)index, &pKey)) {
+ wrq->length = pKey->uKeyLength;
+ memcpy(abyKey, pKey->abyKey, pKey->uKeyLength);
+ memcpy(extra, abyKey, WLAN_WEP232_KEYLEN);
}
- wrq->flags |= index+1;
-
+ wrq->flags |= index + 1;
return 0;
}
-
/*
- * Wireless Handler : set power mode
+ * Wireless Handler: set power mode
*/
-int iwctl_siwpower(struct net_device *dev,
- struct iw_request_info *info,
- struct iw_param *wrq,
- char *extra)
+int iwctl_siwpower(struct net_device *dev, struct iw_request_info *info,
+ struct iw_param *wrq, char *extra)
{
- PSDevice pDevice = (PSDevice)netdev_priv(dev);
- PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
- int rc = 0;
+ PSDevice pDevice = netdev_priv(dev);
+ PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
+ int rc = 0;
- DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWPOWER \n");
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWPOWER \n");
- if (!(pDevice->flags & DEVICE_FLAGS_OPENED)) {
- rc = -EINVAL;
- return rc;
+ if (!(pDevice->flags & DEVICE_FLAGS_OPENED)) {
+ rc = -EINVAL;
+ return rc;
}
if (wrq->disabled) {
@@ -1356,23 +1239,23 @@ int iwctl_siwpower(struct net_device *dev,
return rc;
}
if ((wrq->flags & IW_POWER_TYPE) == IW_POWER_TIMEOUT) {
- pDevice->ePSMode = WMAC_POWER_FAST;
- PSvEnablePowerSaving((void *) pDevice, pMgmt->wListenInterval);
+ pDevice->ePSMode = WMAC_POWER_FAST;
+ PSvEnablePowerSaving((void *)pDevice, pMgmt->wListenInterval);
} else if ((wrq->flags & IW_POWER_TYPE) == IW_POWER_PERIOD) {
- pDevice->ePSMode = WMAC_POWER_FAST;
- PSvEnablePowerSaving((void *) pDevice, pMgmt->wListenInterval);
+ pDevice->ePSMode = WMAC_POWER_FAST;
+ PSvEnablePowerSaving((void *)pDevice, pMgmt->wListenInterval);
}
switch (wrq->flags & IW_POWER_MODE) {
case IW_POWER_UNICAST_R:
- DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWPOWER: IW_POWER_UNICAST_R \n");
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWPOWER: IW_POWER_UNICAST_R \n");
rc = -EINVAL;
break;
case IW_POWER_ALL_R:
- DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWPOWER: IW_POWER_ALL_R \n");
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWPOWER: IW_POWER_ALL_R \n");
rc = -EINVAL;
case IW_POWER_ON:
- DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWPOWER: IW_POWER_ON \n");
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWPOWER: IW_POWER_ON \n");
break;
default:
rc = -EINVAL;
@@ -1382,23 +1265,19 @@ int iwctl_siwpower(struct net_device *dev,
}
/*
- * Wireless Handler : get power mode
+ * Wireless Handler: get power mode
*/
-int iwctl_giwpower(struct net_device *dev,
- struct iw_request_info *info,
- struct iw_param *wrq,
- char *extra)
+int iwctl_giwpower(struct net_device *dev, struct iw_request_info *info,
+ struct iw_param *wrq, char *extra)
{
- PSDevice pDevice = (PSDevice)netdev_priv(dev);
- PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
- int mode = pDevice->ePSMode;
-
-
- DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWPOWER \n");
+ PSDevice pDevice = netdev_priv(dev);
+ PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
+ int mode = pDevice->ePSMode;
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWPOWER \n");
if ((wrq->disabled = (mode == WMAC_POWER_CAM)))
- return 0;
+ return 0;
if ((wrq->flags & IW_POWER_TYPE) == IW_POWER_TIMEOUT) {
wrq->value = (int)((pMgmt->wListenInterval * pMgmt->wCurrBeaconPeriod) << 10);
@@ -1408,117 +1287,105 @@ int iwctl_giwpower(struct net_device *dev,
wrq->flags = IW_POWER_PERIOD;
}
wrq->flags |= IW_POWER_ALL_R;
-
return 0;
}
-
/*
- * Wireless Handler : get Sensitivity
+ * Wireless Handler: get Sensitivity
*/
-int iwctl_giwsens(struct net_device *dev,
- struct iw_request_info *info,
- struct iw_param *wrq,
- char *extra)
+int iwctl_giwsens(struct net_device *dev, struct iw_request_info *info,
+ struct iw_param *wrq, char *extra)
{
- PSDevice pDevice = (PSDevice)netdev_priv(dev);
- long ldBm;
+ PSDevice pDevice = netdev_priv(dev);
+ long ldBm;
- DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWSENS \n");
- if (pDevice->bLinkPass == TRUE) {
- RFvRSSITodBm(pDevice, (BYTE)(pDevice->uCurrRSSI), &ldBm);
- wrq->value = ldBm;
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWSENS \n");
+ if (pDevice->bLinkPass == TRUE) {
+ RFvRSSITodBm(pDevice, (BYTE)(pDevice->uCurrRSSI), &ldBm);
+ wrq->value = ldBm;
+ } else {
+ wrq->value = 0;
}
- else {
- wrq->value = 0;
- };
wrq->disabled = (wrq->value == 0);
wrq->fixed = 1;
-
-
return 0;
}
#ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
-int iwctl_siwauth(struct net_device *dev,
- struct iw_request_info *info,
- struct iw_param *wrq,
- char *extra)
+int iwctl_siwauth(struct net_device *dev, struct iw_request_info *info,
+ struct iw_param *wrq, char *extra)
{
- PSDevice pDevice = (PSDevice)netdev_priv(dev);
- PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
- int ret=0;
- static int wpa_version=0; //must be static to save the last value,einsn liu
- static int pairwise=0;
+ PSDevice pDevice = netdev_priv(dev);
+ PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
+ int ret = 0;
+ static int wpa_version = 0; // must be static to save the last value, einsn liu
+ static int pairwise = 0;
- DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWAUTH \n");
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWAUTH \n");
switch (wrq->flags & IW_AUTH_INDEX) {
case IW_AUTH_WPA_VERSION:
wpa_version = wrq->value;
- if(wrq->value == IW_AUTH_WPA_VERSION_DISABLED) {
- PRINT_K("iwctl_siwauth:set WPADEV to disable at 1??????\n");
- }
- else if(wrq->value == IW_AUTH_WPA_VERSION_WPA) {
- PRINT_K("iwctl_siwauth:set WPADEV to WPA1******\n");
- }
- else {
- PRINT_K("iwctl_siwauth:set WPADEV to WPA2******\n");
+ if (wrq->value == IW_AUTH_WPA_VERSION_DISABLED) {
+ PRINT_K("iwctl_siwauth:set WPADEV to disable at 1??????\n");
+ } else if (wrq->value == IW_AUTH_WPA_VERSION_WPA) {
+ PRINT_K("iwctl_siwauth:set WPADEV to WPA1******\n");
+ } else {
+ PRINT_K("iwctl_siwauth:set WPADEV to WPA2******\n");
}
break;
case IW_AUTH_CIPHER_PAIRWISE:
pairwise = wrq->value;
- PRINT_K("iwctl_siwauth:set pairwise=%d\n",pairwise);
- if(pairwise == IW_AUTH_CIPHER_CCMP){
+ PRINT_K("iwctl_siwauth:set pairwise=%d\n", pairwise);
+ if (pairwise == IW_AUTH_CIPHER_CCMP){
pDevice->eEncryptionStatus = Ndis802_11Encryption3Enabled;
- }else if(pairwise == IW_AUTH_CIPHER_TKIP){
+ } else if (pairwise == IW_AUTH_CIPHER_TKIP) {
pDevice->eEncryptionStatus = Ndis802_11Encryption2Enabled;
} else if (pairwise == IW_AUTH_CIPHER_WEP40 ||
- pairwise == IW_AUTH_CIPHER_WEP104) {
+ pairwise == IW_AUTH_CIPHER_WEP104) {
pDevice->eEncryptionStatus = Ndis802_11Encryption1Enabled;
- }else if(pairwise == IW_AUTH_CIPHER_NONE){
- //do nothing,einsn liu
- }else pDevice->eEncryptionStatus = Ndis802_11EncryptionDisabled;
-
+ } else if (pairwise == IW_AUTH_CIPHER_NONE) {
+ // do nothing, einsn liu
+ } else {
+ pDevice->eEncryptionStatus = Ndis802_11EncryptionDisabled;
+ }
break;
case IW_AUTH_CIPHER_GROUP:
- PRINT_K("iwctl_siwauth:set GROUP=%d\n",wrq->value);
- if(wpa_version == IW_AUTH_WPA_VERSION_DISABLED)
+ PRINT_K("iwctl_siwauth:set GROUP=%d\n", wrq->value);
+ if (wpa_version == IW_AUTH_WPA_VERSION_DISABLED)
break;
- if(pairwise == IW_AUTH_CIPHER_NONE){
- if(wrq->value == IW_AUTH_CIPHER_CCMP){
+ if (pairwise == IW_AUTH_CIPHER_NONE) {
+ if (wrq->value == IW_AUTH_CIPHER_CCMP)
pDevice->eEncryptionStatus = Ndis802_11Encryption3Enabled;
- }else {
+ else
pDevice->eEncryptionStatus = Ndis802_11Encryption2Enabled;
- }
}
break;
case IW_AUTH_KEY_MGMT:
- PRINT_K("iwctl_siwauth(wpa_version=%d):set KEY_MGMT=%d\n",wpa_version,wrq->value);
- if(wpa_version == IW_AUTH_WPA_VERSION_WPA2){
- if(wrq->value == IW_AUTH_KEY_MGMT_PSK)
+ PRINT_K("iwctl_siwauth(wpa_version=%d):set KEY_MGMT=%d\n", wpa_version,wrq->value);
+ if (wpa_version == IW_AUTH_WPA_VERSION_WPA2){
+ if (wrq->value == IW_AUTH_KEY_MGMT_PSK)
pMgmt->eAuthenMode = WMAC_AUTH_WPA2PSK;
else pMgmt->eAuthenMode = WMAC_AUTH_WPA2;
- }else if(wpa_version == IW_AUTH_WPA_VERSION_WPA){
- if(wrq->value == 0){
+ } else if (wpa_version == IW_AUTH_WPA_VERSION_WPA) {
+ if (wrq->value == 0){
pMgmt->eAuthenMode = WMAC_AUTH_WPANONE;
- }else if(wrq->value == IW_AUTH_KEY_MGMT_PSK)
+ } else if (wrq->value == IW_AUTH_KEY_MGMT_PSK)
pMgmt->eAuthenMode = WMAC_AUTH_WPAPSK;
- else pMgmt->eAuthenMode = WMAC_AUTH_WPA;
+ } else {
+ pMgmt->eAuthenMode = WMAC_AUTH_WPA;
}
-
break;
case IW_AUTH_TKIP_COUNTERMEASURES:
- break; /* FIXME */
+ break; /* FIXME */
case IW_AUTH_DROP_UNENCRYPTED:
break;
case IW_AUTH_80211_AUTH_ALG:
- PRINT_K("iwctl_siwauth:set AUTH_ALG=%d\n",wrq->value);
- if(wrq->value==IW_AUTH_ALG_OPEN_SYSTEM){
- pMgmt->bShareKeyAlgorithm=FALSE;
- }else if(wrq->value==IW_AUTH_ALG_SHARED_KEY){
- pMgmt->bShareKeyAlgorithm=TRUE;
- }
+ PRINT_K("iwctl_siwauth:set AUTH_ALG=%d\n", wrq->value);
+ if (wrq->value == IW_AUTH_ALG_OPEN_SYSTEM)
+ pMgmt->bShareKeyAlgorithm = FALSE;
+ else if (wrq->value == IW_AUTH_ALG_SHARED_KEY)
+ pMgmt->bShareKeyAlgorithm = TRUE;
break;
case IW_AUTH_WPA_ENABLED:
break;
@@ -1529,345 +1396,314 @@ int iwctl_siwauth(struct net_device *dev,
break;
case IW_AUTH_PRIVACY_INVOKED:
pDevice->bEncryptionEnable = !!wrq->value;
- if(pDevice->bEncryptionEnable == FALSE){
+ if (pDevice->bEncryptionEnable == FALSE) {
wpa_version = 0;
pairwise = 0;
pDevice->eEncryptionStatus = Ndis802_11EncryptionDisabled;
pMgmt->bShareKeyAlgorithm = FALSE;
pMgmt->eAuthenMode = WMAC_AUTH_OPEN;
- PRINT_K("iwctl_siwauth:set WPADEV to disaable at 2?????\n");
+ PRINT_K("iwctl_siwauth:set WPADEV to disaable at 2?????\n");
}
-
break;
default:
ret = -EOPNOTSUPP;
break;
}
- return ret;
+ return ret;
}
-
-int iwctl_giwauth(struct net_device *dev,
- struct iw_request_info *info,
- struct iw_param *wrq,
- char *extra)
+int iwctl_giwauth(struct net_device *dev, struct iw_request_info *info,
+ struct iw_param *wrq, char *extra)
{
return -EOPNOTSUPP;
}
-
-
-int iwctl_siwgenie(struct net_device *dev,
- struct iw_request_info *info,
- struct iw_point *wrq,
- char *extra)
+int iwctl_siwgenie(struct net_device *dev, struct iw_request_info *info,
+ struct iw_point *wrq, char *extra)
{
- PSDevice pDevice = (PSDevice)netdev_priv(dev);
- PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
- int ret=0;
+ PSDevice pDevice = netdev_priv(dev);
+ PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
+ int ret = 0;
- if(wrq->length){
- if ((wrq->length < 2) || (extra[1]+2 != wrq->length)) {
+ if (wrq->length){
+ if ((wrq->length < 2) || (extra[1] + 2 != wrq->length)) {
ret = -EINVAL;
goto out;
}
- if(wrq->length > MAX_WPA_IE_LEN){
+ if (wrq->length > MAX_WPA_IE_LEN){
ret = -ENOMEM;
goto out;
}
memset(pMgmt->abyWPAIE, 0, MAX_WPA_IE_LEN);
- if(copy_from_user(pMgmt->abyWPAIE, extra, wrq->length)){
+ if (copy_from_user(pMgmt->abyWPAIE, extra, wrq->length)){
ret = -EFAULT;
goto out;
}
pMgmt->wWPAIELen = wrq->length;
- }else {
+ } else {
memset(pMgmt->abyWPAIE, 0, MAX_WPA_IE_LEN);
pMgmt->wWPAIELen = 0;
}
- out://not completely ...not necessary in wpa_supplicant 0.5.8
+out: // not completely ...not necessary in wpa_supplicant 0.5.8
return ret;
}
-int iwctl_giwgenie(struct net_device *dev,
- struct iw_request_info *info,
- struct iw_point *wrq,
- char *extra)
+int iwctl_giwgenie(struct net_device *dev, struct iw_request_info *info,
+ struct iw_point *wrq, char *extra)
{
- PSDevice pDevice = (PSDevice)netdev_priv(dev);
- PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
- int ret=0;
+ PSDevice pDevice = netdev_priv(dev);
+ PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
+ int ret = 0;
int space = wrq->length;
wrq->length = 0;
- if(pMgmt->wWPAIELen > 0){
+ if (pMgmt->wWPAIELen > 0) {
wrq->length = pMgmt->wWPAIELen;
- if(pMgmt->wWPAIELen <= space){
- if(copy_to_user(extra, pMgmt->abyWPAIE, pMgmt->wWPAIELen)){
+ if (pMgmt->wWPAIELen <= space) {
+ if (copy_to_user(extra, pMgmt->abyWPAIE, pMgmt->wWPAIELen)) {
ret = -EFAULT;
}
- }else
+ } else {
ret = -E2BIG;
+ }
}
-
return ret;
}
-
-int iwctl_siwencodeext(struct net_device *dev,
- struct iw_request_info *info,
- struct iw_point *wrq,
- char *extra)
+int iwctl_siwencodeext(struct net_device *dev, struct iw_request_info *info,
+ struct iw_point *wrq, char *extra)
{
- PSDevice pDevice = (PSDevice)netdev_priv(dev);
- PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
+ PSDevice pDevice = netdev_priv(dev);
+ PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
struct iw_encode_ext *ext = (struct iw_encode_ext*)extra;
- struct viawget_wpa_param *param=NULL;
-//original member
- wpa_alg alg_name;
- u8 addr[6];
- int key_idx, set_tx=0;
- u8 seq[IW_ENCODE_SEQ_MAX_SIZE];
- u8 key[64];
- size_t seq_len=0,key_len=0;
- u8 *buf;
- size_t blen;
- u8 key_array[64];
- int ret=0;
-
-PRINT_K("SIOCSIWENCODEEXT...... \n");
-
-blen = sizeof(*param);
-buf = kmalloc((int)blen, (int)GFP_KERNEL);
-if (buf == NULL)
- return -ENOMEM;
-memset(buf, 0, blen);
-param = (struct viawget_wpa_param *) buf;
-
-//recover alg_name
-switch (ext->alg) {
- case IW_ENCODE_ALG_NONE:
- alg_name = WPA_ALG_NONE;
+ struct viawget_wpa_param *param=NULL;
+// original member
+ wpa_alg alg_name;
+ u8 addr[6];
+ int key_idx;
+ int set_tx = 0;
+ u8 seq[IW_ENCODE_SEQ_MAX_SIZE];
+ u8 key[64];
+ size_t seq_len = 0;
+ size_t key_len = 0;
+ u8 *buf;
+ size_t blen;
+ u8 key_array[64];
+ int ret = 0;
+
+ PRINT_K("SIOCSIWENCODEEXT...... \n");
+
+ blen = sizeof(*param);
+ buf = kmalloc((int)blen, (int)GFP_KERNEL);
+ if (buf == NULL)
+ return -ENOMEM;
+ memset(buf, 0, blen);
+ param = (struct viawget_wpa_param *)buf;
+
+// recover alg_name
+ switch (ext->alg) {
+ case IW_ENCODE_ALG_NONE:
+ alg_name = WPA_ALG_NONE;
break;
- case IW_ENCODE_ALG_WEP:
- alg_name = WPA_ALG_WEP;
+ case IW_ENCODE_ALG_WEP:
+ alg_name = WPA_ALG_WEP;
break;
- case IW_ENCODE_ALG_TKIP:
- alg_name = WPA_ALG_TKIP;
+ case IW_ENCODE_ALG_TKIP:
+ alg_name = WPA_ALG_TKIP;
break;
- case IW_ENCODE_ALG_CCMP:
- alg_name = WPA_ALG_CCMP;
+ case IW_ENCODE_ALG_CCMP:
+ alg_name = WPA_ALG_CCMP;
break;
- default:
+ default:
PRINT_K("Unknown alg = %d\n",ext->alg);
ret= -ENOMEM;
goto error;
- }
-//recover addr
- memcpy(addr, ext->addr.sa_data, ETH_ALEN);
-//recover key_idx
- key_idx = (wrq->flags&IW_ENCODE_INDEX) - 1;
-//recover set_tx
-if(ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
- set_tx = 1;
-//recover seq,seq_len
- if(ext->ext_flags & IW_ENCODE_EXT_RX_SEQ_VALID) {
- seq_len=IW_ENCODE_SEQ_MAX_SIZE;
- memcpy(seq, ext->rx_seq, seq_len);
- }
-//recover key,key_len
-if(ext->key_len) {
- key_len=ext->key_len;
- memcpy(key, &ext->key[0], key_len);
}
-
-memset(key_array, 0, 64);
-if ( key_len > 0) {
- memcpy(key_array, key, key_len);
- if (key_len == 32) {
- // notice ! the oder
- memcpy(&key_array[16], &key[24], 8);
- memcpy(&key_array[24], &key[16], 8);
+// recover addr
+ memcpy(addr, ext->addr.sa_data, ETH_ALEN);
+// recover key_idx
+ key_idx = (wrq->flags&IW_ENCODE_INDEX) - 1;
+// recover set_tx
+ if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
+ set_tx = 1;
+// recover seq,seq_len
+ if (ext->ext_flags & IW_ENCODE_EXT_RX_SEQ_VALID) {
+ seq_len=IW_ENCODE_SEQ_MAX_SIZE;
+ memcpy(seq, ext->rx_seq, seq_len);
}
+// recover key,key_len
+ if (ext->key_len) {
+ key_len = ext->key_len;
+ memcpy(key, &ext->key[0], key_len);
+ }
+ memset(key_array, 0, 64);
+ if (key_len > 0) {
+ memcpy(key_array, key, key_len);
+ if (key_len == 32) {
+ // notice ! the oder
+ memcpy(&key_array[16], &key[24], 8);
+ memcpy(&key_array[24], &key[16], 8);
+ }
}
/**************Translate iw_encode_ext to viawget_wpa_param****************/
-memcpy(param->addr, addr, ETH_ALEN);
-param->u.wpa_key.alg_name = (int)alg_name;
-param->u.wpa_key.set_tx = set_tx;
-param->u.wpa_key.key_index = key_idx;
-param->u.wpa_key.key_len = key_len;
-param->u.wpa_key.key = (u8 *)key_array;
-param->u.wpa_key.seq = (u8 *)seq;
-param->u.wpa_key.seq_len = seq_len;
-
-//****set if current action is Network Manager count??
-//****this method is so foolish,but there is no other way???
-if(param->u.wpa_key.alg_name == WPA_ALG_NONE) {
- if(param->u.wpa_key.key_index ==0) {
- pDevice->bwextstep0 = TRUE;
- }
- if((pDevice->bwextstep0 = TRUE)&&(param->u.wpa_key.key_index ==1)) {
- pDevice->bwextstep0 = FALSE;
- pDevice->bwextstep1 = TRUE;
- }
- if((pDevice->bwextstep1 = TRUE)&&(param->u.wpa_key.key_index ==2)) {
- pDevice->bwextstep1 = FALSE;
- pDevice->bwextstep2 = TRUE;
+ memcpy(param->addr, addr, ETH_ALEN);
+ param->u.wpa_key.alg_name = (int)alg_name;
+ param->u.wpa_key.set_tx = set_tx;
+ param->u.wpa_key.key_index = key_idx;
+ param->u.wpa_key.key_len = key_len;
+ param->u.wpa_key.key = (u8 *)key_array;
+ param->u.wpa_key.seq = (u8 *)seq;
+ param->u.wpa_key.seq_len = seq_len;
+
+/****set if current action is Network Manager count?? */
+/****this method is so foolish,but there is no other way??? */
+ if (param->u.wpa_key.alg_name == WPA_ALG_NONE) {
+ if (param->u.wpa_key.key_index ==0) {
+ pDevice->bwextstep0 = TRUE;
+ }
+ if ((pDevice->bwextstep0 == TRUE) && (param->u.wpa_key.key_index == 1)) {
+ pDevice->bwextstep0 = FALSE;
+ pDevice->bwextstep1 = TRUE;
+ }
+ if ((pDevice->bwextstep1 == TRUE) && (param->u.wpa_key.key_index == 2)) {
+ pDevice->bwextstep1 = FALSE;
+ pDevice->bwextstep2 = TRUE;
+ }
+ if ((pDevice->bwextstep2 == TRUE) && (param->u.wpa_key.key_index == 3)) {
+ pDevice->bwextstep2 = FALSE;
+ pDevice->bwextstep3 = TRUE;
+ }
+ }
+ if (pDevice->bwextstep3 == TRUE) {
+ PRINT_K("SIOCSIWENCODEEXT:Enable WPA WEXT SUPPORT!!!!!\n");
+ pDevice->bwextstep0 = FALSE;
+ pDevice->bwextstep1 = FALSE;
+ pDevice->bwextstep2 = FALSE;
+ pDevice->bwextstep3 = FALSE;
+ pDevice->bWPASuppWextEnabled = TRUE;
+ memset(pMgmt->abyDesireBSSID, 0xFF, 6);
+ KeyvInitTable(pDevice, &pDevice->sKey);
}
- if((pDevice->bwextstep2 = TRUE)&&(param->u.wpa_key.key_index ==3)) {
- pDevice->bwextstep2 = FALSE;
- pDevice->bwextstep3 = TRUE;
- }
- }
-if(pDevice->bwextstep3 == TRUE) {
- PRINT_K("SIOCSIWENCODEEXT:Enable WPA WEXT SUPPORT!!!!!\n");
- pDevice->bwextstep0 = FALSE;
- pDevice->bwextstep1 = FALSE;
- pDevice->bwextstep2 = FALSE;
- pDevice->bwextstep3 = FALSE;
- pDevice->bWPASuppWextEnabled = TRUE;
- memset(pMgmt->abyDesireBSSID, 0xFF,6);
- KeyvInitTable(pDevice,&pDevice->sKey);
- }
-//******
-
- spin_lock_irq(&pDevice->lock);
- ret = wpa_set_keys(pDevice, param, TRUE);
- spin_unlock_irq(&pDevice->lock);
+/*******/
+ spin_lock_irq(&pDevice->lock);
+ ret = wpa_set_keys(pDevice, param, TRUE);
+ spin_unlock_irq(&pDevice->lock);
error:
-kfree(param);
+ kfree(param);
return ret;
}
-
-
-int iwctl_giwencodeext(struct net_device *dev,
- struct iw_request_info *info,
- struct iw_point *wrq,
- char *extra)
+int iwctl_giwencodeext(struct net_device *dev, struct iw_request_info *info,
+ struct iw_point *wrq, char *extra)
{
- return -EOPNOTSUPP;
+ return -EOPNOTSUPP;
}
-int iwctl_siwmlme(struct net_device *dev,
- struct iw_request_info * info,
- struct iw_point *wrq,
- char *extra)
+int iwctl_siwmlme(struct net_device *dev, struct iw_request_info *info,
+ struct iw_point *wrq, char *extra)
{
- PSDevice pDevice = (PSDevice)netdev_priv(dev);
- PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
+ PSDevice pDevice = netdev_priv(dev);
+ PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
struct iw_mlme *mlme = (struct iw_mlme *)extra;
int ret = 0;
- if(memcmp(pMgmt->abyCurrBSSID, mlme->addr.sa_data, ETH_ALEN)){
+ if (memcmp(pMgmt->abyCurrBSSID, mlme->addr.sa_data, ETH_ALEN)) {
ret = -EINVAL;
return ret;
}
- switch(mlme->cmd){
+ switch (mlme->cmd){
case IW_MLME_DEAUTH:
case IW_MLME_DISASSOC:
- if(pDevice->bLinkPass == TRUE){
- PRINT_K("iwctl_siwmlme--->send DISASSOCIATE\n");
- bScheduleCommand((void *) pDevice,
- WLAN_CMD_DISASSOCIATE,
- NULL);
+ if (pDevice->bLinkPass == TRUE) {
+ PRINT_K("iwctl_siwmlme--->send DISASSOCIATE\n");
+ bScheduleCommand((void *)pDevice, WLAN_CMD_DISASSOCIATE,
+ NULL);
}
break;
default:
ret = -EOPNOTSUPP;
}
-
return ret;
-
}
#endif
-static const iw_handler iwctl_handler[] =
-{
- (iw_handler) NULL, /* SIOCSIWCOMMIT */
- (iw_handler) NULL, // SIOCGIWNAME
- (iw_handler) NULL, // SIOCSIWNWID
- (iw_handler) NULL, // SIOCGIWNWID
- (iw_handler) NULL, // SIOCSIWFREQ
- (iw_handler) NULL, // SIOCGIWFREQ
- (iw_handler) NULL, // SIOCSIWMODE
- (iw_handler) NULL, // SIOCGIWMODE
- (iw_handler) NULL, // SIOCSIWSENS
- (iw_handler) NULL, // SIOCGIWSENS
- (iw_handler) NULL, // SIOCSIWRANGE
- (iw_handler) iwctl_giwrange, // SIOCGIWRANGE
- (iw_handler) NULL, // SIOCSIWPRIV
- (iw_handler) NULL, // SIOCGIWPRIV
- (iw_handler) NULL, // SIOCSIWSTATS
- (iw_handler) NULL, // SIOCGIWSTATS
- (iw_handler) NULL, // SIOCSIWSPY
- (iw_handler) NULL, // SIOCGIWSPY
- (iw_handler) NULL, // -- hole --
- (iw_handler) NULL, // -- hole --
- (iw_handler) NULL, // SIOCSIWAP
- (iw_handler) NULL, // SIOCGIWAP
- (iw_handler) NULL, // -- hole -- 0x16
- (iw_handler) NULL, // SIOCGIWAPLIST
- (iw_handler) iwctl_siwscan, // SIOCSIWSCAN
- (iw_handler) iwctl_giwscan, // SIOCGIWSCAN
- (iw_handler) NULL, // SIOCSIWESSID
- (iw_handler) NULL, // SIOCGIWESSID
- (iw_handler) NULL, // SIOCSIWNICKN
- (iw_handler) NULL, // SIOCGIWNICKN
- (iw_handler) NULL, // -- hole --
- (iw_handler) NULL, // -- hole --
- (iw_handler) NULL, // SIOCSIWRATE 0x20
- (iw_handler) NULL, // SIOCGIWRATE
- (iw_handler) NULL, // SIOCSIWRTS
- (iw_handler) NULL, // SIOCGIWRTS
- (iw_handler) NULL, // SIOCSIWFRAG
- (iw_handler) NULL, // SIOCGIWFRAG
- (iw_handler) NULL, // SIOCSIWTXPOW
- (iw_handler) NULL, // SIOCGIWTXPOW
- (iw_handler) NULL, // SIOCSIWRETRY
- (iw_handler) NULL, // SIOCGIWRETRY
- (iw_handler) NULL, // SIOCSIWENCODE
- (iw_handler) NULL, // SIOCGIWENCODE
- (iw_handler) NULL, // SIOCSIWPOWER
- (iw_handler) NULL, // SIOCGIWPOWER
- (iw_handler) NULL, // -- hole --
- (iw_handler) NULL, // -- hole --
- (iw_handler) NULL, // SIOCSIWGENIE
- (iw_handler) NULL, // SIOCGIWGENIE
- (iw_handler) NULL, // SIOCSIWAUTH
- (iw_handler) NULL, // SIOCGIWAUTH
- (iw_handler) NULL, // SIOCSIWENCODEEXT
- (iw_handler) NULL, // SIOCGIWENCODEEXT
- (iw_handler) NULL, // SIOCSIWPMKSA
- (iw_handler) NULL, // -- hole --
+static const iw_handler iwctl_handler[] = {
+ (iw_handler)NULL, // SIOCSIWCOMMIT
+ (iw_handler)NULL, // SIOCGIWNAME
+ (iw_handler)NULL, // SIOCSIWNWID
+ (iw_handler)NULL, // SIOCGIWNWID
+ (iw_handler)NULL, // SIOCSIWFREQ
+ (iw_handler)NULL, // SIOCGIWFREQ
+ (iw_handler)NULL, // SIOCSIWMODE
+ (iw_handler)NULL, // SIOCGIWMODE
+ (iw_handler)NULL, // SIOCSIWSENS
+ (iw_handler)NULL, // SIOCGIWSENS
+ (iw_handler)NULL, // SIOCSIWRANGE
+ (iw_handler)iwctl_giwrange, // SIOCGIWRANGE
+ (iw_handler)NULL, // SIOCSIWPRIV
+ (iw_handler)NULL, // SIOCGIWPRIV
+ (iw_handler)NULL, // SIOCSIWSTATS
+ (iw_handler)NULL, // SIOCGIWSTATS
+ (iw_handler)NULL, // SIOCSIWSPY
+ (iw_handler)NULL, // SIOCGIWSPY
+ (iw_handler)NULL, // -- hole --
+ (iw_handler)NULL, // -- hole --
+ (iw_handler)NULL, // SIOCSIWAP
+ (iw_handler)NULL, // SIOCGIWAP
+ (iw_handler)NULL, // -- hole -- 0x16
+ (iw_handler)NULL, // SIOCGIWAPLIST
+ (iw_handler)iwctl_siwscan, // SIOCSIWSCAN
+ (iw_handler)iwctl_giwscan, // SIOCGIWSCAN
+ (iw_handler)NULL, // SIOCSIWESSID
+ (iw_handler)NULL, // SIOCGIWESSID
+ (iw_handler)NULL, // SIOCSIWNICKN
+ (iw_handler)NULL, // SIOCGIWNICKN
+ (iw_handler)NULL, // -- hole --
+ (iw_handler)NULL, // -- hole --
+ (iw_handler)NULL, // SIOCSIWRATE 0x20
+ (iw_handler)NULL, // SIOCGIWRATE
+ (iw_handler)NULL, // SIOCSIWRTS
+ (iw_handler)NULL, // SIOCGIWRTS
+ (iw_handler)NULL, // SIOCSIWFRAG
+ (iw_handler)NULL, // SIOCGIWFRAG
+ (iw_handler)NULL, // SIOCSIWTXPOW
+ (iw_handler)NULL, // SIOCGIWTXPOW
+ (iw_handler)NULL, // SIOCSIWRETRY
+ (iw_handler)NULL, // SIOCGIWRETRY
+ (iw_handler)NULL, // SIOCSIWENCODE
+ (iw_handler)NULL, // SIOCGIWENCODE
+ (iw_handler)NULL, // SIOCSIWPOWER
+ (iw_handler)NULL, // SIOCGIWPOWER
+ (iw_handler)NULL, // -- hole --
+ (iw_handler)NULL, // -- hole --
+ (iw_handler)NULL, // SIOCSIWGENIE
+ (iw_handler)NULL, // SIOCGIWGENIE
+ (iw_handler)NULL, // SIOCSIWAUTH
+ (iw_handler)NULL, // SIOCGIWAUTH
+ (iw_handler)NULL, // SIOCSIWENCODEEXT
+ (iw_handler)NULL, // SIOCGIWENCODEEXT
+ (iw_handler)NULL, // SIOCSIWPMKSA
+ (iw_handler)NULL, // -- hole --
};
-
-static const iw_handler iwctl_private_handler[] =
-{
- NULL, // SIOCIWFIRSTPRIV
+static const iw_handler iwctl_private_handler[] = {
+ NULL, // SIOCIWFIRSTPRIV
};
-
struct iw_priv_args iwctl_private_args[] = {
-{ IOCTL_CMD_SET,
- IW_PRIV_TYPE_CHAR | 1024, 0,
- "set"},
+ { IOCTL_CMD_SET, IW_PRIV_TYPE_CHAR | 1024, 0, "set" },
};
-
-
-const struct iw_handler_def iwctl_handler_def =
-{
- .get_wireless_stats = &iwctl_get_wireless_stats,
- .num_standard = sizeof(iwctl_handler)/sizeof(iw_handler),
- .num_private = 0,
- .num_private_args = 0,
- .standard = (iw_handler *) iwctl_handler,
- .private = NULL,
- .private_args = NULL,
+const struct iw_handler_def iwctl_handler_def = {
+ .get_wireless_stats = &iwctl_get_wireless_stats,
+ .num_standard = sizeof(iwctl_handler) / sizeof(iw_handler),
+ .num_private = 0,
+ .num_private_args = 0,
+ .standard = (iw_handler *)iwctl_handler,
+ .private = NULL,
+ .private_args = NULL,
};
diff --git a/drivers/staging/vt6656/iwctl.h b/drivers/staging/vt6656/iwctl.h
index 0c6e0496779b..d056f83a9158 100644
--- a/drivers/staging/vt6656/iwctl.h
+++ b/drivers/staging/vt6656/iwctl.h
@@ -41,173 +41,107 @@
struct iw_statistics *iwctl_get_wireless_stats(struct net_device *dev);
-int iwctl_siwap(struct net_device *dev,
- struct iw_request_info *info,
- struct sockaddr *wrq,
- char *extra);
-
-void iwctl_giwrange(struct net_device *dev,
- struct iw_request_info *info,
- struct iw_point *wrq,
- char *extra);
-
-
-void iwctl_giwmode(struct net_device *dev,
- struct iw_request_info *info,
- __u32 *wmode,
- char *extra);
-
-int iwctl_siwmode(struct net_device *dev,
- struct iw_request_info *info,
- __u32 *wmode,
- char *extra);
-
-int iwctl_giwfreq(struct net_device *dev,
- struct iw_request_info *info,
- struct iw_freq *wrq,
- char *extra);
-
-int iwctl_siwfreq(struct net_device *dev,
- struct iw_request_info *info,
- struct iw_freq *wrq,
- char *extra);
-
-int iwctl_giwname(struct net_device *dev,
- struct iw_request_info *info,
- char *wrq,
- char *extra);
-
-int iwctl_giwsens(struct net_device *dev,
- struct iw_request_info *info,
- struct iw_param *wrq,
- char *extra);
-
-int iwctl_giwap(struct net_device *dev,
- struct iw_request_info *info,
- struct sockaddr *wrq,
- char *extra);
-
-int iwctl_giwaplist(struct net_device *dev,
- struct iw_request_info *info,
- struct iw_point *wrq,
- char *extra);
-
-int iwctl_siwessid(struct net_device *dev,
- struct iw_request_info *info,
- struct iw_point *wrq,
- char *extra);
-
-void iwctl_giwessid(struct net_device *dev,
- struct iw_request_info *info,
- struct iw_point *wrq,
- char *extra);
-
-int iwctl_siwrate(struct net_device *dev,
- struct iw_request_info *info,
- struct iw_param *wrq,
- char *extra);
-
-void iwctl_giwrate(struct net_device *dev,
- struct iw_request_info *info,
- struct iw_param *wrq,
- char *extra);
-
-int iwctl_siwrts(struct net_device *dev,
- struct iw_param *wrq);
-
-int iwctl_giwrts(struct net_device *dev,
- struct iw_request_info *info,
- struct iw_param *wrq,
- char *extra);
-
-int iwctl_siwfrag(struct net_device *dev,
- struct iw_request_info *info,
- struct iw_param *wrq,
- char *extra);
-
-int iwctl_giwfrag(struct net_device *dev,
- struct iw_request_info *info,
- struct iw_param *wrq,
- char *extra);
-
-int iwctl_siwretry(struct net_device *dev,
- struct iw_request_info *info,
- struct iw_param *wrq,
- char *extra);
-
-int iwctl_giwretry(struct net_device *dev,
- struct iw_request_info *info,
- struct iw_param *wrq,
- char *extra);
-
-int iwctl_siwencode(struct net_device *dev,
- struct iw_request_info *info,
- struct iw_point *wrq,
- char *extra);
-
-int iwctl_giwencode(struct net_device *dev,
- struct iw_request_info *info,
- struct iw_point *wrq,
- char *extra);
-
-int iwctl_siwpower(struct net_device *dev,
- struct iw_request_info *info,
- struct iw_param *wrq,
- char *extra);
-
-int iwctl_giwpower(struct net_device *dev,
- struct iw_request_info *info,
- struct iw_param *wrq,
- char *extra);
-
-int iwctl_giwscan(struct net_device *dev,
- struct iw_request_info *info,
- struct iw_point *wrq,
- char *extra);
-
-int iwctl_siwscan(struct net_device *dev,
- struct iw_request_info *info,
- struct iw_param *wrq,
- char *extra);
+int iwctl_siwap(struct net_device *dev, struct iw_request_info *info,
+ struct sockaddr *wrq, char *extra);
+
+void iwctl_giwrange(struct net_device *dev, struct iw_request_info *info,
+ struct iw_point *wrq, char *extra);
+
+void iwctl_giwmode(struct net_device *dev, struct iw_request_info *info,
+ __u32 *wmode, char *extra);
+
+int iwctl_siwmode(struct net_device *dev, struct iw_request_info *info,
+ __u32 *wmode, char *extra);
+
+int iwctl_giwfreq(struct net_device *dev, struct iw_request_info *info,
+ struct iw_freq *wrq, char *extra);
+
+int iwctl_siwfreq(struct net_device *dev, struct iw_request_info *info,
+ struct iw_freq *wrq, char *extra);
+
+int iwctl_giwname(struct net_device *dev, struct iw_request_info *info,
+ char *wrq, char *extra);
+
+int iwctl_giwsens(struct net_device *dev, struct iw_request_info *info,
+ struct iw_param *wrq, char *extra);
+
+int iwctl_giwap(struct net_device *dev, struct iw_request_info *info,
+ struct sockaddr *wrq, char *extra);
+
+int iwctl_giwaplist(struct net_device *dev, struct iw_request_info *info,
+ struct iw_point *wrq, char *extra);
+
+int iwctl_siwessid(struct net_device *dev, struct iw_request_info *info,
+ struct iw_point *wrq, char *extra);
+
+void iwctl_giwessid(struct net_device *dev, struct iw_request_info *info,
+ struct iw_point *wrq, char *extra);
+
+int iwctl_siwrate(struct net_device *dev, struct iw_request_info *info,
+ struct iw_param *wrq, char *extra);
+
+void iwctl_giwrate(struct net_device *dev, struct iw_request_info *info,
+ struct iw_param *wrq, char *extra);
+
+int iwctl_siwrts(struct net_device *dev, struct iw_param *wrq);
+
+int iwctl_giwrts(struct net_device *dev, struct iw_request_info *info,
+ struct iw_param *wrq, char *extra);
+
+int iwctl_siwfrag(struct net_device *dev, struct iw_request_info *info,
+ struct iw_param *wrq, char *extra);
+
+int iwctl_giwfrag(struct net_device *dev, struct iw_request_info *info,
+ struct iw_param *wrq, char *extra);
+
+int iwctl_siwretry(struct net_device *dev, struct iw_request_info *info,
+ struct iw_param *wrq, char *extra);
+
+int iwctl_giwretry(struct net_device *dev, struct iw_request_info *info,
+ struct iw_param *wrq, char *extra);
+
+int iwctl_siwencode(struct net_device *dev, struct iw_request_info *info,
+ struct iw_point *wrq, char *extra);
+
+int iwctl_giwencode(struct net_device *dev, struct iw_request_info *info,
+ struct iw_point *wrq, char *extra);
+
+int iwctl_siwpower(struct net_device *dev, struct iw_request_info *info,
+ struct iw_param *wrq, char *extra);
+
+int iwctl_giwpower(struct net_device *dev, struct iw_request_info *info,
+ struct iw_param *wrq, char *extra);
+
+int iwctl_giwscan(struct net_device *dev, struct iw_request_info *info,
+ struct iw_point *wrq, char *extra);
+
+int iwctl_siwscan(struct net_device *dev, struct iw_request_info *info,
+ struct iw_param *wrq, char *extra);
#ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
-int iwctl_siwauth(struct net_device *dev,
- struct iw_request_info *info,
- struct iw_param *wrq,
- char *extra);
-
-int iwctl_giwauth(struct net_device *dev,
- struct iw_request_info *info,
- struct iw_param *wrq,
- char *extra);
-
-int iwctl_siwgenie(struct net_device *dev,
- struct iw_request_info *info,
- struct iw_point *wrq,
- char *extra);
-
-int iwctl_giwgenie(struct net_device *dev,
- struct iw_request_info *info,
- struct iw_point *wrq,
- char *extra);
-
-int iwctl_siwencodeext(struct net_device *dev,
- struct iw_request_info *info,
- struct iw_point *wrq,
- char *extra);
-
-int iwctl_giwencodeext(struct net_device *dev,
- struct iw_request_info *info,
- struct iw_point *wrq,
- char *extra);
-
-int iwctl_siwmlme(struct net_device *dev,
- struct iw_request_info * info,
- struct iw_point *wrq,
- char *extra);
+int iwctl_siwauth(struct net_device *dev, struct iw_request_info *info,
+ struct iw_param *wrq, char *extra);
+
+int iwctl_giwauth(struct net_device *dev, struct iw_request_info *info,
+ struct iw_param *wrq, char *extra);
+
+int iwctl_siwgenie(struct net_device *dev, struct iw_request_info *info,
+ struct iw_point *wrq, char *extra);
+
+int iwctl_giwgenie(struct net_device *dev, struct iw_request_info *info,
+ struct iw_point *wrq, char *extra);
+
+int iwctl_siwencodeext(struct net_device *dev, struct iw_request_info *info,
+ struct iw_point *wrq, char *extra);
+
+int iwctl_giwencodeext(struct net_device *dev, struct iw_request_info *info,
+ struct iw_point *wrq, char *extra);
+
+int iwctl_siwmlme(struct net_device *dev, struct iw_request_info *info,
+ struct iw_point *wrq, char *extra);
#endif // #ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
-extern const struct iw_handler_def iwctl_handler_def;
-extern const struct iw_priv_args iwctl_private_args;
+extern const struct iw_handler_def iwctl_handler_def;
+extern const struct iw_priv_args iwctl_private_args;
#endif /* __IWCTL_H__ */
diff --git a/drivers/staging/vt6656/main_usb.c b/drivers/staging/vt6656/main_usb.c
index 763e028a5cc5..b06fd5b723fa 100644
--- a/drivers/staging/vt6656/main_usb.c
+++ b/drivers/staging/vt6656/main_usb.c
@@ -92,22 +92,14 @@ MODULE_DESCRIPTION(DEVICE_FULL_DRV_NAM);
module_param_array(N, int, NULL, 0);\
MODULE_PARM_DESC(N, D);
-#define RX_DESC_MIN0 16
-#define RX_DESC_MAX0 128
#define RX_DESC_DEF0 64
DEVICE_PARAM(RxDescriptors0,"Number of receive usb desc buffer");
-#define TX_DESC_MIN0 16
-#define TX_DESC_MAX0 128
#define TX_DESC_DEF0 64
DEVICE_PARAM(TxDescriptors0,"Number of transmit usb desc buffer");
-
-#define CHANNEL_MIN 1
-#define CHANNEL_MAX 14
#define CHANNEL_DEF 6
-
DEVICE_PARAM(Channel, "Channel number");
@@ -120,23 +112,13 @@ DEVICE_PARAM(Channel, "Channel number");
DEVICE_PARAM(PreambleType, "Preamble Type");
-
-#define RTS_THRESH_MIN 512
-#define RTS_THRESH_MAX 2347
#define RTS_THRESH_DEF 2347
-
DEVICE_PARAM(RTSThreshold, "RTS threshold");
-
-#define FRAG_THRESH_MIN 256
-#define FRAG_THRESH_MAX 2346
#define FRAG_THRESH_DEF 2346
-
DEVICE_PARAM(FragThreshold, "Fragmentation threshold");
-#define DATA_RATE_MIN 0
-#define DATA_RATE_MAX 13
#define DATA_RATE_DEF 13
/* datarate[] index
0: indicate 1 Mbps 0x02
@@ -157,10 +139,7 @@ DEVICE_PARAM(FragThreshold, "Fragmentation threshold");
DEVICE_PARAM(ConnectionRate, "Connection data rate");
-#define OP_MODE_MAX 2
#define OP_MODE_DEF 0
-#define OP_MODE_MIN 0
-
DEVICE_PARAM(OPMode, "Infrastruct, adhoc, AP mode ");
/* OpMode[] is used for transmit.
@@ -176,34 +155,22 @@ DEVICE_PARAM(OPMode, "Infrastruct, adhoc, AP mode ");
*/
#define PS_MODE_DEF 0
-
DEVICE_PARAM(PSMode, "Power saving mode");
-#define SHORT_RETRY_MIN 0
-#define SHORT_RETRY_MAX 31
#define SHORT_RETRY_DEF 8
-
-
DEVICE_PARAM(ShortRetryLimit, "Short frame retry limits");
-#define LONG_RETRY_MIN 0
-#define LONG_RETRY_MAX 15
#define LONG_RETRY_DEF 4
-
-
DEVICE_PARAM(LongRetryLimit, "long frame retry limits");
-
/* BasebandType[] baseband type selected
0: indicate 802.11a type
1: indicate 802.11b type
2: indicate 802.11g type
*/
-#define BBP_TYPE_MIN 0
-#define BBP_TYPE_MAX 2
-#define BBP_TYPE_DEF 2
+#define BBP_TYPE_DEF 2
DEVICE_PARAM(BasebandType, "baseband type");
@@ -238,11 +205,6 @@ static const long frequency_list[] = {
};
-#ifndef IW_ENCODE_NOKEY
-#define IW_ENCODE_NOKEY 0x0800
-#define IW_ENCODE_MODE (IW_ENCODE_DISABLED | IW_ENCODE_RESTRICTED | IW_ENCODE_OPEN)
-#endif
-
static const struct iw_handler_def iwctl_handler_def;
*/
@@ -1257,9 +1219,7 @@ static void __devexit vt6656_disconnect(struct usb_interface *intf)
}
device_release_WPADEV(device);
-
- if (device->firmware)
- release_firmware(device->firmware);
+ release_firmware(device->firmware);
usb_set_intfdata(intf, NULL);
usb_put_dev(interface_to_usbdev(intf));
diff --git a/drivers/staging/vt6656/mib.h b/drivers/staging/vt6656/mib.h
index a89cca0c5ecf..82d69a9cc209 100644
--- a/drivers/staging/vt6656/mib.h
+++ b/drivers/staging/vt6656/mib.h
@@ -113,7 +113,6 @@ typedef struct tagSMib2Counter {
} SMib2Counter, *PSMib2Counter;
// Value in the ifType entry
-//#define ETHERNETCSMACD 6 //
#define WIRELESSLANIEEE80211b 6 //
// Value in the ifAdminStatus/ifOperStatus entry
diff --git a/drivers/staging/vt6656/rxtx.c b/drivers/staging/vt6656/rxtx.c
index 9b64b102f55c..bb464527fc1b 100644
--- a/drivers/staging/vt6656/rxtx.c
+++ b/drivers/staging/vt6656/rxtx.c
@@ -73,8 +73,6 @@ static int msglevel = MSG_LEVEL_INFO;
/*--------------------- Static Functions --------------------------*/
/*--------------------- Static Definitions -------------------------*/
-#define CRITICAL_PACKET_LEN 256 // if packet size < 256 -> in-direct send
- // packet size >= 256 -> direct send
const WORD wTimeStampOff[2][MAX_RATE] = {
{384, 288, 226, 209, 54, 43, 37, 31, 28, 25, 24, 23}, // Long Preamble
diff --git a/drivers/staging/vt6656/tether.h b/drivers/staging/vt6656/tether.h
index 4ec05237469b..8c1f5d253f88 100644
--- a/drivers/staging/vt6656/tether.h
+++ b/drivers/staging/vt6656/tether.h
@@ -72,7 +72,6 @@
#define TYPE_CTL_ACK 0xd400
-//#define WEP_IV_MASK 0xFFFFFF00
#else //if LITTLE_ENDIAN
//
@@ -111,7 +110,6 @@
#define TYPE_CTL_ACK 0x00d4
-//#define WEP_IV_MASK 0x00FFFFFF
#endif //#ifdef __BIG_ENDIAN
diff --git a/drivers/staging/vt6656/usbpipe.c b/drivers/staging/vt6656/usbpipe.c
index c612ab58f389..609e8fa10b98 100644
--- a/drivers/staging/vt6656/usbpipe.c
+++ b/drivers/staging/vt6656/usbpipe.c
@@ -52,9 +52,6 @@
//endpoint 2: read bulk
//endpoint 3: write bulk
-//RequestType:
-//#define REQUEST_OUT (USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE) // 0x40
-//#define REQUEST_IN (USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE ) //0xc0
//static int msglevel =MSG_LEVEL_DEBUG;
static int msglevel =MSG_LEVEL_INFO;
diff --git a/drivers/staging/vt6656/wcmd.c b/drivers/staging/vt6656/wcmd.c
index 78ea121b7e2e..9d2caa819f47 100644
--- a/drivers/staging/vt6656/wcmd.c
+++ b/drivers/staging/vt6656/wcmd.c
@@ -1254,51 +1254,50 @@ static BOOL s_bClearBSSID_SCAN(void *hDeviceContext)
//mike add:reset command timer
void vResetCommandTimer(void *hDeviceContext)
{
- PSDevice pDevice = (PSDevice)hDeviceContext;
-
- //delete timer
- del_timer(&pDevice->sTimerCommand);
- //init timer
- init_timer(&pDevice->sTimerCommand);
- pDevice->sTimerCommand.data = (unsigned long)pDevice;
- pDevice->sTimerCommand.function = (TimerFunction)vRunCommand;
- pDevice->sTimerCommand.expires = RUN_AT(HZ);
- pDevice->cbFreeCmdQueue = CMD_Q_SIZE;
- pDevice->uCmdDequeueIdx = 0;
- pDevice->uCmdEnqueueIdx = 0;
- pDevice->eCommandState = WLAN_CMD_IDLE;
- pDevice->bCmdRunning = FALSE;
- pDevice->bCmdClear = FALSE;
+ PSDevice pDevice = (PSDevice)hDeviceContext;
+
+ //delete timer
+ del_timer(&pDevice->sTimerCommand);
+ //init timer
+ init_timer(&pDevice->sTimerCommand);
+ pDevice->sTimerCommand.data = (unsigned long)pDevice;
+ pDevice->sTimerCommand.function = (TimerFunction)vRunCommand;
+ pDevice->sTimerCommand.expires = RUN_AT(HZ);
+ pDevice->cbFreeCmdQueue = CMD_Q_SIZE;
+ pDevice->uCmdDequeueIdx = 0;
+ pDevice->uCmdEnqueueIdx = 0;
+ pDevice->eCommandState = WLAN_CMD_IDLE;
+ pDevice->bCmdRunning = FALSE;
+ pDevice->bCmdClear = FALSE;
}
void BSSvSecondTxData(void *hDeviceContext)
{
- PSDevice pDevice = (PSDevice)hDeviceContext;
- PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
-
- pDevice->nTxDataTimeCout++;
-
- if(pDevice->nTxDataTimeCout<4) //don't tx data if timer less than 40s
- {
- // printk("mike:%s-->no data Tx not exceed the desired Time as %d\n",__FUNCTION__,
- // (int)pDevice->nTxDataTimeCout);
- pDevice->sTimerTxData.expires = RUN_AT(10*HZ); //10s callback
- add_timer(&pDevice->sTimerTxData);
- return;
- }
-
- spin_lock_irq(&pDevice->lock);
- //is wap_supplicant running successful OR only open && sharekey mode!
- if(((pDevice->bLinkPass ==TRUE)&&(pMgmt->eAuthenMode < WMAC_AUTH_WPA)) || //open && sharekey linking
- (pDevice->fWPA_Authened == TRUE)) { //wpa linking
- // printk("mike:%s-->InSleep Tx Data Procedure\n",__FUNCTION__);
- pDevice->fTxDataInSleep = TRUE;
- PSbSendNullPacket(pDevice); //send null packet
- pDevice->fTxDataInSleep = FALSE;
- }
- spin_unlock_irq(&pDevice->lock);
-
- pDevice->sTimerTxData.expires = RUN_AT(10*HZ); //10s callback
- add_timer(&pDevice->sTimerTxData);
- return;
+ PSDevice pDevice = (PSDevice)hDeviceContext;
+ PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
+
+ pDevice->nTxDataTimeCout++;
+
+ if (pDevice->nTxDataTimeCout < 4) { //don't tx data if timer less than 40s
+ // printk("mike:%s-->no data Tx not exceed the desired Time as %d\n",__FUNCTION__,
+ // (int)pDevice->nTxDataTimeCout);
+ pDevice->sTimerTxData.expires = RUN_AT(10 * HZ); //10s callback
+ add_timer(&pDevice->sTimerTxData);
+ return;
+ }
+
+ spin_lock_irq(&pDevice->lock);
+ //is wap_supplicant running successful OR only open && sharekey mode!
+ if (((pDevice->bLinkPass == TRUE) &&
+ (pMgmt->eAuthenMode < WMAC_AUTH_WPA)) || //open && sharekey linking
+ (pDevice->fWPA_Authened == TRUE)) { //wpa linking
+ // printk("mike:%s-->InSleep Tx Data Procedure\n",__FUNCTION__);
+ pDevice->fTxDataInSleep = TRUE;
+ PSbSendNullPacket(pDevice); //send null packet
+ pDevice->fTxDataInSleep = FALSE;
+ }
+ spin_unlock_irq(&pDevice->lock);
+
+ pDevice->sTimerTxData.expires = RUN_AT(10 * HZ); //10s callback
+ add_timer(&pDevice->sTimerTxData);
}
diff --git a/drivers/staging/vt6656/wpa.c b/drivers/staging/vt6656/wpa.c
index 7dde3d6941ab..b16d4ddc117b 100644
--- a/drivers/staging/vt6656/wpa.c
+++ b/drivers/staging/vt6656/wpa.c
@@ -149,7 +149,7 @@ WPA_ParseRSN(
j = 0;
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"wPKCount: %d, sizeof(pBSSList->abyPKType): %zu\n", pRSN->wPKCount, sizeof(pBSSList->abyPKType));
for (i = 0; (i < pRSN->wPKCount) &&
- (j < sizeof(pBSSList->abyPKType)/sizeof(BYTE)); i++) {
+ (j < ARRAY_SIZE(pBSSList->abyPKType)); i++) {
if(pRSN->len >= 12+i*4+4) { //oui1(4)+ver(2)+GKS(4)+PKSCnt(2)+PKS(4*i)
if ( !memcmp(pRSN->PKSList[i].abyOUI, abyOUI00, 4))
pBSSList->abyPKType[j++] = WPA_NONE;
@@ -182,7 +182,7 @@ WPA_ParseRSN(
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"wAuthCount: %d, sizeof(pBSSList->abyAuthType): %zu\n",
pIE_RSN_Auth->wAuthCount, sizeof(pBSSList->abyAuthType));
for (i = 0; (i < pIE_RSN_Auth->wAuthCount) &&
- (j < sizeof(pBSSList->abyAuthType)/sizeof(BYTE)); i++) {
+ (j < ARRAY_SIZE(pBSSList->abyAuthType)); i++) {
if(pRSN->len >= 14+4+(m+i)*4) { //oui1(4)+ver(2)+GKS(4)+PKSCnt(2)+PKS(4*m)+AKC(2)+AKS(4*i)
if ( !memcmp(pIE_RSN_Auth->AuthKSList[i].abyOUI, abyOUI01, 4))
pBSSList->abyAuthType[j++] = WPA_AUTH_IEEE802_1X;
diff --git a/drivers/staging/winbond/mds_s.h b/drivers/staging/winbond/mds_s.h
index 07d835b3b706..2972d66c9436 100644
--- a/drivers/staging/winbond/mds_s.h
+++ b/drivers/staging/winbond/mds_s.h
@@ -40,7 +40,7 @@ enum {
/*
* ================================================================
- * Configration default value
+ * Configuration default value
* ================================================================
*/
#define DEFAULT_MULTICASTLISTMAX 32 /* standard */
diff --git a/drivers/staging/winbond/mto.c b/drivers/staging/winbond/mto.c
index 5250217156a7..1b52ebd4b011 100644
--- a/drivers/staging/winbond/mto.c
+++ b/drivers/staging/winbond/mto.c
@@ -33,7 +33,7 @@ u16 MTO_Frag_Th_Tbl[MTO_MAX_FRAG_TH_LEVELS] = {
/*
* Declare data rate table:
- * The following table will be changed at anytime if the opration rate
+ * The following table will be changed at anytime if the operation rate
* supported by AP don't match the table
*/
static u8 MTO_Data_Rate_Tbl[MTO_MAX_DATA_RATE_LEVELS] = {
diff --git a/drivers/staging/winbond/wbusb.c b/drivers/staging/winbond/wbusb.c
index c3751a718384..ef360547ecec 100644
--- a/drivers/staging/winbond/wbusb.c
+++ b/drivers/staging/winbond/wbusb.c
@@ -747,20 +747,18 @@ static int wb35_probe(struct usb_interface *intf,
struct usb_host_interface *interface;
struct ieee80211_hw *dev;
struct wbsoft_priv *priv;
- int nr, err;
+ int err;
u32 ltmp;
usb_get_dev(udev);
/* Check the device if it already be opened */
- nr = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0),
+ err = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0),
0x01,
USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_IN,
0x0, 0x400, &ltmp, 4, HZ * 100);
- if (nr < 0) {
- err = nr;
+ if (err < 0)
goto error;
- }
/* Is already initialized? */
ltmp = cpu_to_le32(ltmp);
diff --git a/drivers/staging/wlags49_h2/README.ubuntu b/drivers/staging/wlags49_h2/README.ubuntu
index edee8b9385be..5f1cfb8fd427 100644
--- a/drivers/staging/wlags49_h2/README.ubuntu
+++ b/drivers/staging/wlags49_h2/README.ubuntu
@@ -87,7 +87,7 @@ The linux driver files (wl_xxxx.c) are changed in the following ways:
-- Recovery actions added
The major problem was the order in which calls can be made. The original
-looks like a traditonal UNIX driver. To call an "ioctl" function you
+looks like a traditional UNIX driver. To call an "ioctl" function you
have to "open" the device first to get a handle and after "close" no
"ioctl" function can be called anymore. With the 2.6 driver this all
changed; the former ioctl functions are now called before "open" and
diff --git a/drivers/staging/wlags49_h2/dhf.c b/drivers/staging/wlags49_h2/dhf.c
index bb80b547cc19..13d360fa58ec 100644
--- a/drivers/staging/wlags49_h2/dhf.c
+++ b/drivers/staging/wlags49_h2/dhf.c
@@ -1,5 +1,4 @@
-/* vim:tw=110:ts=4: */
/**************************************************************************************************************
*
* FILE : DHF.C
diff --git a/drivers/staging/wlags49_h2/dhf.h b/drivers/staging/wlags49_h2/dhf.h
index dbe0611fd032..1299b8256468 100644
--- a/drivers/staging/wlags49_h2/dhf.h
+++ b/drivers/staging/wlags49_h2/dhf.h
@@ -1,5 +1,4 @@
-/* vim:tw=110:ts=4: */
#ifndef DHF_H
#define DHF_H
diff --git a/drivers/staging/wlags49_h2/hcf.c b/drivers/staging/wlags49_h2/hcf.c
index 5957c3a439ac..423544634ae5 100644
--- a/drivers/staging/wlags49_h2/hcf.c
+++ b/drivers/staging/wlags49_h2/hcf.c
@@ -705,7 +705,7 @@ hcf_action( IFBP ifbp, hcf_16 action )
// 800 us latency before FW switches to high power
MSF_WAIT(800); // MSF-defined function to wait n microseconds.
//OOR if ( ifbp->IFB_DSLinkStat & CFG_LINK_STAT_DS_OOR ) { // OutOfRange
-// printk( "<5>ACT_INT_OFF: Deepsleep phase terminated, enable and go to AwaitConnection\n" ); //;?remove me 1 day
+// printk(KERN_NOTICE "ACT_INT_OFF: Deepsleep phase terminated, enable and go to AwaitConnection\n" ); //;?remove me 1 day
// hcf_cntl( ifbp, HCF_CNTL_ENABLE );
// }
// ifbp->IFB_DSLinkStat &= ~( CFG_LINK_STAT_DS_IR | CFG_LINK_STAT_DS_OOR); //clear IR/OOR state
@@ -2871,8 +2871,8 @@ or
* The Assert validates the HCF assumption about Hermes implementation upon which the range of
* Pseudo-RIDs is based.
* Then the control fields up to the start of the 802.3 frame are read from the NIC into the lookahead buffer.
-* The status field is converted to native Endianess.
-* The length is, after implicit Endianess conversion if needed, and adjustment for the 14 bytes of the
+* The status field is converted to native Endianness.
+* The length is, after implicit Endianness conversion if needed, and adjustment for the 14 bytes of the
* 802.3 MAC header, stored in IFB_RxLen.
* In MAC Monitor mode, 802.11 control frames with a TOTAL length of 14 are received, so without this
* length adjustment, IFB_RxLen could not be used to distinguish these frames from "no frame".
@@ -2894,7 +2894,7 @@ or
* - the Hermes reported Tunnel encapsulation or
* - the Hermes reported 1042 Encapsulation and hcf_encap reports that the HCF would not have used
* 1042 as the encapsulation mechanism
-* Note that the first field of the RxFS in bufp has Native Endianess due to the conversion done by the
+* Note that the first field of the RxFS in bufp has Native Endianness due to the conversion done by the
* BE_PAR in get_frag.
*36: The Type field is the only word kept (after moving) of the just read 8 bytes, it is moved to the
* L-field. The original L-field and 6 byte SNAP header are discarded, so IFB_RxLen and buf_addr must
@@ -2979,7 +2979,7 @@ hcf_service_nic( IFBP ifbp, wci_bufp bufp, unsigned int len )
ltv.typ = CFG_DDS_TICK_TIME;
ltv.tick_time = ( ( ifbp->IFB_DSLinkStat & CFG_LINK_STAT_TIMER ) + 0x10 ) *64; //78 is more right
hcf_put_info( ifbp, (LTVP)&ltv );
- printk( "<5>Preparing for sleep, link_status: %04X, timer : %d\n",
+ printk(KERN_NOTICE "Preparing for sleep, link_status: %04X, timer : %d\n",
ifbp->IFB_DSLinkStat, ltv.tick_time );//;?remove me 1 day
ifbp->IFB_TickCnt++; //;?just to make sure we do not keep on printing above message
if ( ltv.tick_time < 300 * 125 ) ifbp->IFB_DSLinkStat += 0x0010;
@@ -3831,7 +3831,7 @@ get_fid( IFBP ifbp )
*.DESCRIPTION
* process the single byte (if applicable) read by the previous get_frag and copy len (or len-1) bytes from
* NIC to bufp.
- * On a Big Endian platform, the parameter word_len controls the number of leading bytes whose endianess is
+ * On a Big Endian platform, the parameter word_len controls the number of leading bytes whose endianness is
* converted (i.e. byte swapped)
*
*
@@ -3980,7 +3980,7 @@ get_frag( IFBP ifbp, wci_bufp bufp, int len BE_PAR( int word_len ) )
* appropriate means on H-I: always
* and on H-II if F/W supplier reflects a primary (i.e. only after an Hermes Reset or Init
* command).
- * QUESTION ;? !!!!!! should, For each of the above RIDs the Endianess is converted to native Endianess.
+ * QUESTION ;? !!!!!! should, For each of the above RIDs the Endianness is converted to native Endianness.
* Only the return code of the first hcf_get_info is used. All hcf_get_info calls are made, regardless of
* the success or failure of the 1st hcf_get_info. The assumptions are:
* - if any call fails, they all fail, so remembering the result of the 1st call is adequate
@@ -4221,11 +4221,11 @@ isr_info( IFBP ifbp )
// /*4*/ if ( info[1] == CFG_LINK_STAT ) {
// ifbp->IFB_DSLinkStat = IPW( HREG_DATA_1 ) | CFG_LINK_STAT_CHANGE; //corrupts BAP !! ;?
// ifbp->IFB_LinkStat = ifbp->IFB_DSLinkStat & CFG_LINK_STAT_FW; //;? to be obsoleted
-// printk( "<4>linkstatus: %04x\n", ifbp->IFB_DSLinkStat ); //;?remove me 1 day
+// printk(KERN_ERR "linkstatus: %04x\n", ifbp->IFB_DSLinkStat ); //;?remove me 1 day
// #if (HCF_SLEEP) & HCF_DDS
// if ( ( ifbp->IFB_DSLinkStat & CFG_LINK_STAT_CONNECTED ) == 0 ) { //even values are disconnected etc.
// ifbp->IFB_TickCnt = 0; //start 2 second period (with 1 tick uncertanty)
-// printk( "<5>isr_info: AwaitConnection phase started, IFB_TickCnt = 0\n" ); //;?remove me 1 day
+// printk(KERN_NOTICE "isr_info: AwaitConnection phase started, IFB_TickCnt = 0\n" ); //;?remove me 1 day
// }
// #endif // HCF_DDS
// }
diff --git a/drivers/staging/wlags49_h2/hcf.h b/drivers/staging/wlags49_h2/hcf.h
index 95527b5cf863..2abeaa11d8ca 100644
--- a/drivers/staging/wlags49_h2/hcf.h
+++ b/drivers/staging/wlags49_h2/hcf.h
@@ -1,5 +1,4 @@
-// vim:tw=110:ts=4:
#ifndef HCF_H
#define HCF_H 1
@@ -90,7 +89,7 @@
#define LOF(x) (sizeof(x)/sizeof(hcf_16)-1)
-/* Endianess
+/* Endianness
* Little Endian (a.k.a. Intel), least significant byte first
* Big Endian (a.k.a. Motorola), most significant byte first
*
@@ -101,7 +100,7 @@
*/
/* To increase portability, use unsigned char and unsigned char * when accessing parts of larger
- * types to convert their Endianess
+ * types to convert their Endianness
*/
#define CNV_END_SHORT(w) (hcf_16)( ((hcf_16)(w) & 0x00FF) << 8 | ((hcf_16)(w) & 0xFF00) >> 8 )
@@ -109,14 +108,14 @@
#if HCF_BIG_ENDIAN
//******************************************** B I G E N D I A N *******************************************
-#define CNV_LITTLE_TO_SHORT(w) CNV_END_SHORT(w) // endianess conversion needed
-#define CNV_BIG_TO_SHORT(w) (w) // no endianess conversion needed
+#define CNV_LITTLE_TO_SHORT(w) CNV_END_SHORT(w) // endianness conversion needed
+#define CNV_BIG_TO_SHORT(w) (w) // no endianness conversion needed
#define CNV_LITTLE_TO_LONG(dw) CNV_END_LONG(dw)
#define CNV_LONG_TO_LITTLE(dw) CNV_END_LONG(dw)
#else
//****************************************** L I T T L E E N D I A N ****************************************
-#define CNV_LITTLE_TO_SHORT(w) (w) // no endianess conversion needed
-#define CNV_BIG_TO_SHORT(w) CNV_END_SHORT(w) // endianess conversion needed
+#define CNV_LITTLE_TO_SHORT(w) (w) // no endianness conversion needed
+#define CNV_BIG_TO_SHORT(w) CNV_END_SHORT(w) // endianness conversion needed
#define CNV_LITTLE_TO_LONG(dw) (dw)
#define CNV_LONG_TO_LITTLE(dw) (dw)
diff --git a/drivers/staging/wlags49_h2/hcfcfg.h b/drivers/staging/wlags49_h2/hcfcfg.h
index ef60da8c3ebc..39fb4d326f65 100644
--- a/drivers/staging/wlags49_h2/hcfcfg.h
+++ b/drivers/staging/wlags49_h2/hcfcfg.h
@@ -1,5 +1,4 @@
-// vim:tw=110:ts=4:
#ifndef HCFCFG_H
#define HCFCFG_H 1
diff --git a/drivers/staging/wlags49_h2/mdd.h b/drivers/staging/wlags49_h2/mdd.h
index 5f951efb9c07..5c3515f31a16 100644
--- a/drivers/staging/wlags49_h2/mdd.h
+++ b/drivers/staging/wlags49_h2/mdd.h
@@ -1,5 +1,4 @@
-// vim:tw=110:ts=4:
#ifndef MDD_H
#define MDD_H 1
diff --git a/drivers/staging/wlags49_h2/mmd.c b/drivers/staging/wlags49_h2/mmd.c
index c8f52107e6ca..3312348c3477 100644
--- a/drivers/staging/wlags49_h2/mmd.c
+++ b/drivers/staging/wlags49_h2/mmd.c
@@ -1,5 +1,4 @@
-// vim:tw=110:ts=4:
/************************************************************************************************************
*
* FILE : mmd.c
@@ -101,10 +100,10 @@
* supp address of the supplier specification
*
* Description: mmd_check_comp is a support routine to check the compatibility between an actor and a
-* supplier. mmd_check_comp is independent of the endianess of the actp and supp structures. This is
+* supplier. mmd_check_comp is independent of the endianness of the actp and supp structures. This is
* achieved by checking the "bottom" or "role" fields of these structures. Since these fields are restricted
* to a limited range, comparing the contents to a value with a known endian-ess gives a clue to their actual
-* endianess.
+* endianness.
*
*.DIAGRAM
*1a: The role-field of the actor structure has a known non-zero, not "byte symmetric" value (namely
@@ -114,16 +113,16 @@
* for a supplier. A supplier has always exactly 1 variant,top,bottom record with (officially, but see the
* note below) each of these 3 values in the range 1 through 99, so one byte of the word value of variant,
* top and bottom words is 0x00 and the other byte is non-zero. Whether the lowest address byte or the
-* highest address byte is non-zero depends on the Endianess of the LTV. If and only if the word value of
+* highest address byte is non-zero depends on the Endianness of the LTV. If and only if the word value of
* bottom is less than 0x0100, the supplier is Native Endian.
* NOTE: the variant field of the supplier structure can not be used for the Endian Detection Algorithm,
* because a a zero-valued variant has been used as Controlled Deployment indication in the past.
* Note: An actor may have multiple sets of variant,top,bottom records, including dummy sets with variant,
-* top and bottom fields with a zero-value. As a consequence the endianess of the actor can not be determined
+* top and bottom fields with a zero-value. As a consequence the endianness of the actor can not be determined
* based on its variant,top,bottom values.
*
* Note: the L and T field of the structures are always in Native Endian format, so you can not draw
-* conclusions concerning the Endianess of the structure based on these two fields.
+* conclusions concerning the Endianness of the structure based on these two fields.
*
*1b/2b
* The only purpose of the CFG_RANGE_SPEC_BYTE_STRCT is to give easy access to the non-zero byte of the word
@@ -149,7 +148,7 @@
*
* This is implemented as:
* #if HCF_BIG_ENDIAN == 0 //platform is LE
-* sup/act_endian becomes reverse of structure-endianess as determined in 1a/1b
+* sup/act_endian becomes reverse of structure-endianness as determined in 1a/1b
* #endif
*6: Each of the actor variant-bottom-top records is checked against the (single) supplier variant-bottom-top
* range till either an acceptable match is found or all actor records are tried. As explained above, due to
diff --git a/drivers/staging/wlags49_h2/mmd.h b/drivers/staging/wlags49_h2/mmd.h
index 914952513005..14458035d9e9 100644
--- a/drivers/staging/wlags49_h2/mmd.h
+++ b/drivers/staging/wlags49_h2/mmd.h
@@ -1,5 +1,4 @@
-// vim:tw=110:ts=4:
#ifndef MMD_H
#define MMD_H 1
diff --git a/drivers/staging/wlags49_h2/wl_cs.c b/drivers/staging/wlags49_h2/wl_cs.c
index 7084f414846e..7c7c77f9c862 100644
--- a/drivers/staging/wlags49_h2/wl_cs.c
+++ b/drivers/staging/wlags49_h2/wl_cs.c
@@ -177,10 +177,9 @@ static void wl_adapter_detach(struct pcmcia_device *link)
if (dev) {
unregister_wlags_sysfs(dev);
unregister_netdev(dev);
+ wl_device_dealloc(dev);
}
- wl_device_dealloc(dev);
-
DBG_LEAVE(DbgInfo);
} /* wl_adapter_detach */
/*============================================================================*/
diff --git a/drivers/staging/wlags49_h2/wl_main.c b/drivers/staging/wlags49_h2/wl_main.c
index d5bf0a7012f2..204107829577 100644
--- a/drivers/staging/wlags49_h2/wl_main.c
+++ b/drivers/staging/wlags49_h2/wl_main.c
@@ -3822,7 +3822,7 @@ static int write_int(struct file *file, const char *buffer, unsigned long count,
lp->timer_oor.data = (unsigned long)lp;
lp->timer_oor.expires = RUN_AT( 3 * HZ );
add_timer( &lp->timer_oor );
- printk( "<5>wl_enable: %ld\n", jiffies ); //;?remove me 1 day
+ printk(KERN_NOTICE "wl_enable: %ld\n", jiffies ); //;?remove me 1 day
#endif //DN554
#ifdef DN554
/*******************************************************************************
@@ -3852,7 +3852,7 @@ void timer_oor( u_long arg )
DBG_ENTER( DbgInfo );
DBG_PARAM( DbgInfo, "arg", "0x%08lx", arg );
- printk( "<5>timer_oor: %ld 0x%04X\n", jiffies, lp->timer_oor_cnt ); //;?remove me 1 day
+ printk(KERN_NOTICE "timer_oor: %ld 0x%04X\n", jiffies, lp->timer_oor_cnt ); //;?remove me 1 day
lp->timer_oor_cnt += 10;
if ( (lp->timer_oor_cnt & ~DS_OOR) > 300 ) {
lp->timer_oor_cnt = 300;
diff --git a/drivers/staging/wlags49_h2/wl_netdev.c b/drivers/staging/wlags49_h2/wl_netdev.c
index 90820ff1aced..824b85232353 100644
--- a/drivers/staging/wlags49_h2/wl_netdev.c
+++ b/drivers/staging/wlags49_h2/wl_netdev.c
@@ -1063,7 +1063,7 @@ void wl_multicast( struct net_device *dev )
#if DBG
if( DBG_FLAGS( DbgInfo ) & DBG_PARAM_ON ) {
DBG_PRINT(" flags: %s%s%s\n",
- ( dev->flags & IFF_PROMISC ) ? "Promiscous " : "",
+ ( dev->flags & IFF_PROMISC ) ? "Promiscuous " : "",
( dev->flags & IFF_MULTICAST ) ? "Multicast " : "",
( dev->flags & IFF_ALLMULTI ) ? "All-Multicast" : "" );
@@ -1510,8 +1510,11 @@ void wl_wds_device_alloc( struct wl_private *lp )
for( count = 0; count < NUM_WDS_PORTS; count++ ) {
struct net_device *dev_wds = NULL;
- dev_wds = kmalloc( sizeof( struct net_device ), GFP_KERNEL );
- memset( dev_wds, 0, sizeof( struct net_device ));
+ dev_wds = kzalloc(sizeof(struct net_device), GFP_KERNEL);
+ if (!dev_wds) {
+ DBG_LEAVE(DbgInfo);
+ return;
+ }
ether_setup( dev_wds );
diff --git a/drivers/staging/wlags49_h2/wl_pci.c b/drivers/staging/wlags49_h2/wl_pci.c
index 3df990c7306a..0b31b01bd490 100644
--- a/drivers/staging/wlags49_h2/wl_pci.c
+++ b/drivers/staging/wlags49_h2/wl_pci.c
@@ -524,6 +524,7 @@ int wl_pci_setup( struct pci_dev *pdev )
/* Make sure that space was allocated for our private adapter struct */
if( dev->priv == NULL ) {
DBG_ERROR( DbgInfo, "Private adapter struct was not allocated!!!\n" );
+ wl_device_dealloc(dev);
DBG_LEAVE( DbgInfo );
return -ENOMEM;
}
@@ -532,6 +533,7 @@ int wl_pci_setup( struct pci_dev *pdev )
/* Allocate DMA Descriptors */
if( wl_pci_dma_alloc( pdev, dev->priv ) < 0 ) {
DBG_ERROR( DbgInfo, "Could not allocate DMA descriptor memory!!!\n" );
+ wl_device_dealloc(dev);
DBG_LEAVE( DbgInfo );
return -ENOMEM;
}
@@ -561,6 +563,8 @@ int wl_pci_setup( struct pci_dev *pdev )
result = request_irq(dev->irq, wl_isr, SA_SHIRQ, dev->name, dev);
if( result ) {
DBG_WARNING( DbgInfo, "Could not register ISR!!!\n" );
+ wl_remove(dev);
+ wl_device_dealloc(dev);
DBG_LEAVE( DbgInfo );
return result;
}
diff --git a/drivers/staging/wlags49_h2/wl_profile.c b/drivers/staging/wlags49_h2/wl_profile.c
index b8c96cf18de5..0e49272bc7a8 100644
--- a/drivers/staging/wlags49_h2/wl_profile.c
+++ b/drivers/staging/wlags49_h2/wl_profile.c
@@ -401,7 +401,7 @@ void translate_option(char *buffer, struct wl_private *lp)
if ((value_convert >= PARM_MIN_BRSC) || (value_convert <= PARM_MAX_BRSC))
lp->brsc[0] = value_convert;
else
- DBG_WARNING(DbgInfo, "%s invaid; will be ignored\n", PARM_NAME_BRSC_2GHZ);
+ DBG_WARNING(DbgInfo, "%s invalid; will be ignored\n", PARM_NAME_BRSC_2GHZ);
} else if (strcmp(key, PARM_NAME_BRSC_5GHZ) == 0) {
DBG_TRACE(DbgInfo, "%s, value: %s\n", PARM_NAME_BRSC_5GHZ, value);
@@ -409,7 +409,7 @@ void translate_option(char *buffer, struct wl_private *lp)
if ((value_convert >= PARM_MIN_BRSC) || (value_convert <= PARM_MAX_BRSC))
lp->brsc[1] = value_convert;
else
- DBG_WARNING(DbgInfo, "%s invaid; will be ignored\n", PARM_NAME_BRSC_5GHZ);
+ DBG_WARNING(DbgInfo, "%s invalid; will be ignored\n", PARM_NAME_BRSC_5GHZ);
} else if ((strcmp(key, PARM_NAME_DESIRED_SSID) == 0) || (strcmp(key, PARM_NAME_OWN_SSID) == 0)) {
DBG_TRACE(DbgInfo, "SSID, value: %s\n", value);
@@ -556,7 +556,7 @@ void translate_option(char *buffer, struct wl_private *lp)
if ((value_convert >= PARM_MIN_SRSC) || (value_convert <= PARM_MAX_SRSC))
lp->srsc[0] = value_convert;
else
- DBG_WARNING(DbgInfo, "%s invaid; will be ignored\n", PARM_NAME_SRSC_2GHZ);
+ DBG_WARNING(DbgInfo, "%s invalid; will be ignored\n", PARM_NAME_SRSC_2GHZ);
} else if (strcmp(key, PARM_NAME_SRSC_5GHZ) == 0) {
DBG_TRACE(DbgInfo, "%s, value: %s\n", PARM_NAME_SRSC_5GHZ, value);
@@ -564,7 +564,7 @@ void translate_option(char *buffer, struct wl_private *lp)
if ((value_convert >= PARM_MIN_SRSC) || (value_convert <= PARM_MAX_SRSC))
lp->srsc[1] = value_convert;
else
- DBG_WARNING(DbgInfo, "%s invaid; will be ignored\n", PARM_NAME_SRSC_5GHZ);
+ DBG_WARNING(DbgInfo, "%s invalid; will be ignored\n", PARM_NAME_SRSC_5GHZ);
} else if (strcmp(key, PARM_NAME_SYSTEM_SCALE) == 0) {
DBG_TRACE(DbgInfo, "%s, value: %s\n", PARM_NAME_SYSTEM_SCALE, value);
diff --git a/drivers/staging/wlags49_h2/wl_util.c b/drivers/staging/wlags49_h2/wl_util.c
index f104e6f1e980..404ec7da0348 100644
--- a/drivers/staging/wlags49_h2/wl_util.c
+++ b/drivers/staging/wlags49_h2/wl_util.c
@@ -98,8 +98,7 @@
******************************************************************************/
/* A matrix which maps channels to frequencies */
-#define MAX_CHAN_FREQ_MAP_ENTRIES 50
-static const long chan_freq_list[][MAX_CHAN_FREQ_MAP_ENTRIES] =
+static const long chan_freq_list[][2] =
{
{1,2412},
{2,2417},
@@ -846,7 +845,7 @@ int wl_is_a_valid_chan( int channel )
}
/* Iterate through the matrix and retrieve the frequency */
- for( i = 0; i < MAX_CHAN_FREQ_MAP_ENTRIES; i++ ) {
+ for( i = 0; i < ARRAY_SIZE(chan_freq_list); i++ ) {
if( chan_freq_list[i][0] == channel ) {
return 1;
}
@@ -884,7 +883,7 @@ int wl_is_a_valid_freq( long frequency )
/* Iterate through the matrix and retrieve the channel */
- for( i = 0; i < MAX_CHAN_FREQ_MAP_ENTRIES; i++ ) {
+ for( i = 0; i < ARRAY_SIZE(chan_freq_list); i++ ) {
if( chan_freq_list[i][1] == frequency ) {
return 1;
}
@@ -927,7 +926,7 @@ long wl_get_freq_from_chan( int channel )
}
/* Iterate through the matrix and retrieve the frequency */
- for( i = 0; i < MAX_CHAN_FREQ_MAP_ENTRIES; i++ ) {
+ for( i = 0; i < ARRAY_SIZE(chan_freq_list); i++ ) {
if( chan_freq_list[i][0] == channel ) {
return chan_freq_list[i][1];
}
@@ -965,7 +964,7 @@ int wl_get_chan_from_freq( long frequency )
/* Iterate through the matrix and retrieve the channel */
- for( i = 0; i < MAX_CHAN_FREQ_MAP_ENTRIES; i++ ) {
+ for( i = 0; i < ARRAY_SIZE(chan_freq_list); i++ ) {
if( chan_freq_list[i][1] == frequency ) {
return chan_freq_list[i][0];
}
diff --git a/drivers/staging/wlan-ng/cfg80211.c b/drivers/staging/wlan-ng/cfg80211.c
index 4cd3ba5d5646..fabff4d650ef 100644
--- a/drivers/staging/wlan-ng/cfg80211.c
+++ b/drivers/staging/wlan-ng/cfg80211.c
@@ -127,7 +127,9 @@ int prism2_change_virtual_intf(struct wiphy *wiphy,
}
/* Set Operation mode to the PORT TYPE RID */
- result = prism2_domibset_uint32(wlandev, DIDmib_p2_p2Static_p2CnfPortType, data);
+ result = prism2_domibset_uint32(wlandev,
+ DIDmib_p2_p2Static_p2CnfPortType,
+ data);
if (result)
err = -EFAULT;
@@ -332,6 +334,7 @@ int prism2_scan(struct wiphy *wiphy, struct net_device *dev,
wlandevice_t *wlandev = dev->ml_priv;
struct p80211msg_dot11req_scan msg1;
struct p80211msg_dot11req_scan_results msg2;
+ struct cfg80211_bss *bss;
int result;
int err = 0;
int numbss = 0;
@@ -362,7 +365,8 @@ int prism2_scan(struct wiphy *wiphy, struct net_device *dev,
if (request->n_ssids > 0) {
msg1.scantype.data = P80211ENUM_scantype_active;
msg1.ssid.data.len = request->ssids->ssid_len;
- memcpy(msg1.ssid.data.data, request->ssids->ssid, request->ssids->ssid_len);
+ memcpy(msg1.ssid.data.data,
+ request->ssids->ssid, request->ssids->ssid_len);
} else {
msg1.scantype.data = 0;
}
@@ -401,7 +405,7 @@ int prism2_scan(struct wiphy *wiphy, struct net_device *dev,
ie_buf[1] = msg2.ssid.data.len;
ie_len = ie_buf[1] + 2;
memcpy(&ie_buf[2], &(msg2.ssid.data.data), msg2.ssid.data.len);
- cfg80211_inform_bss(wiphy,
+ bss = cfg80211_inform_bss(wiphy,
ieee80211_get_channel(wiphy, ieee80211_dsss_chan_to_freq(msg2.dschannel.data)),
(const u8 *) &(msg2.bssid.data.data),
msg2.timestamp.data, msg2.capinfo.data,
@@ -411,6 +415,13 @@ int prism2_scan(struct wiphy *wiphy, struct net_device *dev,
(msg2.signal.data - 65536) * 100, /* Conversion to signed type */
GFP_KERNEL
);
+
+ if (!bss) {
+ err = -ENOMEM;
+ goto exit;
+ }
+
+ cfg80211_put_bss(bss);
}
if (result)
@@ -532,7 +543,9 @@ int prism2_connect(struct wiphy *wiphy, struct net_device *dev,
goto exit;
}
- result = prism2_domibset_pstr32(wlandev, did, sme->key_len, (u8 *) sme->key);
+ result = prism2_domibset_pstr32(wlandev,
+ did, sme->key_len,
+ (u8 *)sme->key);
if (result)
goto exit;
@@ -654,10 +667,11 @@ int prism2_get_tx_power(struct wiphy *wiphy, int *dbm)
struct prism2_wiphy_private *priv = wiphy_priv(wiphy);
wlandevice_t *wlandev = priv->wlandev;
struct p80211msg_dot11req_mibget msg;
- p80211item_uint32_t *mibitem = (p80211item_uint32_t *) &msg.mibattribute.data;
+ p80211item_uint32_t *mibitem;
int result;
int err = 0;
+ mibitem = (p80211item_uint32_t *) &msg.mibattribute.data;
msg.msgcode = DIDmsg_dot11req_mibget;
mibitem->did =
DIDmib_dot11phy_dot11PhyTxPowerTable_dot11CurrentTxPowerLevel;
@@ -681,7 +695,8 @@ exit:
/* Interface callback functions, passing data back up to the cfg80211 layer */
void prism2_connect_result(wlandevice_t *wlandev, u8 failed)
{
- u16 status = failed ? WLAN_STATUS_UNSPECIFIED_FAILURE : WLAN_STATUS_SUCCESS;
+ u16 status = failed ?
+ WLAN_STATUS_UNSPECIFIED_FAILURE : WLAN_STATUS_SUCCESS;
cfg80211_connect_result(wlandev->netdev, wlandev->bssid,
NULL, 0, NULL, 0, status, GFP_KERNEL);
@@ -724,7 +739,8 @@ struct wiphy *wlan_create_wiphy(struct device *dev, wlandevice_t *wlandev)
{
struct wiphy *wiphy;
struct prism2_wiphy_private *priv;
- wiphy = wiphy_new(&prism2_usb_cfg_ops, sizeof(struct prism2_wiphy_private));
+
+ wiphy = wiphy_new(&prism2_usb_cfg_ops, sizeof(*priv));
if (!wiphy)
return NULL;
diff --git a/drivers/staging/wlan-ng/prism2fw.c b/drivers/staging/wlan-ng/prism2fw.c
index 3c40096f0c05..66c9aa972310 100644
--- a/drivers/staging/wlan-ng/prism2fw.c
+++ b/drivers/staging/wlan-ng/prism2fw.c
@@ -172,7 +172,7 @@ static int read_cardpda(struct pda *pda, wlandevice_t *wlandev);
static int mkpdrlist(struct pda *pda);
static int plugimage(struct imgchunk *fchunk, unsigned int nfchunks,
- struct s3plugrec *s3plug, unsigned int ns3plug, struct pda * pda);
+ struct s3plugrec *s3plug, unsigned int ns3plug, struct pda *pda);
static int crcimage(struct imgchunk *fchunk, unsigned int nfchunks,
struct s3crcrec *s3crc, unsigned int ns3crc);
@@ -207,7 +207,8 @@ int prism2_fwtry(struct usb_device *udev, wlandevice_t *wlandev)
printk(KERN_INFO "prism2_usb: Checking for firmware %s\n",
PRISM2_USB_FWFILE);
- if (request_ihex_firmware(&fw_entry, PRISM2_USB_FWFILE, &udev->dev) != 0) {
+ if (request_ihex_firmware(&fw_entry,
+ PRISM2_USB_FWFILE, &udev->dev) != 0) {
printk(KERN_INFO
"prism2_usb: Firmware not available, but not essential\n");
printk(KERN_INFO
@@ -593,7 +594,8 @@ int mkpdrlist(struct pda *pda)
le16_to_cpu(pda16[curroff + 1]) != HFA384x_PDR_END_OF_PDA) {
pda->rec[pda->nrec] = (hfa384x_pdrec_t *) &(pda16[curroff]);
- if (le16_to_cpu(pda->rec[pda->nrec]->code) == HFA384x_PDR_NICID) {
+ if (le16_to_cpu(pda->rec[pda->nrec]->code) ==
+ HFA384x_PDR_NICID) {
memcpy(&nicid, &pda->rec[pda->nrec]->data.nicid,
sizeof(nicid));
nicid.id = le16_to_cpu(nicid.id);
@@ -655,7 +657,7 @@ int mkpdrlist(struct pda *pda)
* ~0 failure
----------------------------------------------------------------*/
int plugimage(struct imgchunk *fchunk, unsigned int nfchunks,
- struct s3plugrec *s3plug, unsigned int ns3plug, struct pda * pda)
+ struct s3plugrec *s3plug, unsigned int ns3plug, struct pda *pda)
{
int result = 0;
int i; /* plug index */
@@ -980,9 +982,8 @@ int writeimage(wlandevice_t *wlandev, struct imgchunk *fchunk,
unsigned int nfchunks)
{
int result = 0;
- struct p80211msg_p2req_ramdl_state rstatemsg;
- struct p80211msg_p2req_ramdl_write rwritemsg;
- struct p80211msg *msgp;
+ struct p80211msg_p2req_ramdl_state *rstmsg;
+ struct p80211msg_p2req_ramdl_write *rwrmsg;
u32 resultcode;
int i;
int j;
@@ -991,57 +992,68 @@ int writeimage(wlandevice_t *wlandev, struct imgchunk *fchunk,
u32 currlen;
u32 currdaddr;
+ rstmsg = kmalloc(sizeof(*rstmsg), GFP_KERNEL);
+ rwrmsg = kmalloc(sizeof(*rwrmsg), GFP_KERNEL);
+ if (!rstmsg || !rwrmsg) {
+ kfree(rstmsg);
+ kfree(rwrmsg);
+ printk(KERN_ERR
+ "writeimage: no memory for firmware download, "
+ "aborting download\n");
+ return -ENOMEM;
+ }
+
/* Initialize the messages */
- memset(&rstatemsg, 0, sizeof(rstatemsg));
- strcpy(rstatemsg.devname, wlandev->name);
- rstatemsg.msgcode = DIDmsg_p2req_ramdl_state;
- rstatemsg.msglen = sizeof(rstatemsg);
- rstatemsg.enable.did = DIDmsg_p2req_ramdl_state_enable;
- rstatemsg.exeaddr.did = DIDmsg_p2req_ramdl_state_exeaddr;
- rstatemsg.resultcode.did = DIDmsg_p2req_ramdl_state_resultcode;
- rstatemsg.enable.status = P80211ENUM_msgitem_status_data_ok;
- rstatemsg.exeaddr.status = P80211ENUM_msgitem_status_data_ok;
- rstatemsg.resultcode.status = P80211ENUM_msgitem_status_no_value;
- rstatemsg.enable.len = sizeof(u32);
- rstatemsg.exeaddr.len = sizeof(u32);
- rstatemsg.resultcode.len = sizeof(u32);
-
- memset(&rwritemsg, 0, sizeof(rwritemsg));
- strcpy(rwritemsg.devname, wlandev->name);
- rwritemsg.msgcode = DIDmsg_p2req_ramdl_write;
- rwritemsg.msglen = sizeof(rwritemsg);
- rwritemsg.addr.did = DIDmsg_p2req_ramdl_write_addr;
- rwritemsg.len.did = DIDmsg_p2req_ramdl_write_len;
- rwritemsg.data.did = DIDmsg_p2req_ramdl_write_data;
- rwritemsg.resultcode.did = DIDmsg_p2req_ramdl_write_resultcode;
- rwritemsg.addr.status = P80211ENUM_msgitem_status_data_ok;
- rwritemsg.len.status = P80211ENUM_msgitem_status_data_ok;
- rwritemsg.data.status = P80211ENUM_msgitem_status_data_ok;
- rwritemsg.resultcode.status = P80211ENUM_msgitem_status_no_value;
- rwritemsg.addr.len = sizeof(u32);
- rwritemsg.len.len = sizeof(u32);
- rwritemsg.data.len = WRITESIZE_MAX;
- rwritemsg.resultcode.len = sizeof(u32);
+ memset(rstmsg, 0, sizeof(*rstmsg));
+ strcpy(rstmsg->devname, wlandev->name);
+ rstmsg->msgcode = DIDmsg_p2req_ramdl_state;
+ rstmsg->msglen = sizeof(*rstmsg);
+ rstmsg->enable.did = DIDmsg_p2req_ramdl_state_enable;
+ rstmsg->exeaddr.did = DIDmsg_p2req_ramdl_state_exeaddr;
+ rstmsg->resultcode.did = DIDmsg_p2req_ramdl_state_resultcode;
+ rstmsg->enable.status = P80211ENUM_msgitem_status_data_ok;
+ rstmsg->exeaddr.status = P80211ENUM_msgitem_status_data_ok;
+ rstmsg->resultcode.status = P80211ENUM_msgitem_status_no_value;
+ rstmsg->enable.len = sizeof(u32);
+ rstmsg->exeaddr.len = sizeof(u32);
+ rstmsg->resultcode.len = sizeof(u32);
+
+ memset(rwrmsg, 0, sizeof(*rwrmsg));
+ strcpy(rwrmsg->devname, wlandev->name);
+ rwrmsg->msgcode = DIDmsg_p2req_ramdl_write;
+ rwrmsg->msglen = sizeof(*rwrmsg);
+ rwrmsg->addr.did = DIDmsg_p2req_ramdl_write_addr;
+ rwrmsg->len.did = DIDmsg_p2req_ramdl_write_len;
+ rwrmsg->data.did = DIDmsg_p2req_ramdl_write_data;
+ rwrmsg->resultcode.did = DIDmsg_p2req_ramdl_write_resultcode;
+ rwrmsg->addr.status = P80211ENUM_msgitem_status_data_ok;
+ rwrmsg->len.status = P80211ENUM_msgitem_status_data_ok;
+ rwrmsg->data.status = P80211ENUM_msgitem_status_data_ok;
+ rwrmsg->resultcode.status = P80211ENUM_msgitem_status_no_value;
+ rwrmsg->addr.len = sizeof(u32);
+ rwrmsg->len.len = sizeof(u32);
+ rwrmsg->data.len = WRITESIZE_MAX;
+ rwrmsg->resultcode.len = sizeof(u32);
/* Send xxx_state(enable) */
pr_debug("Sending dl_state(enable) message.\n");
- rstatemsg.enable.data = P80211ENUM_truth_true;
- rstatemsg.exeaddr.data = startaddr;
+ rstmsg->enable.data = P80211ENUM_truth_true;
+ rstmsg->exeaddr.data = startaddr;
- msgp = (struct p80211msg *) &rstatemsg;
- result = prism2mgmt_ramdl_state(wlandev, msgp);
+ result = prism2mgmt_ramdl_state(wlandev, rstmsg);
if (result) {
printk(KERN_ERR
"writeimage state enable failed w/ result=%d, "
"aborting download\n", result);
- return result;
+ goto free_result;
}
- resultcode = rstatemsg.resultcode.data;
+ resultcode = rstmsg->resultcode.data;
if (resultcode != P80211ENUM_resultcode_success) {
printk(KERN_ERR
"writeimage()->xxxdl_state msg indicates failure, "
"w/ resultcode=%d, aborting download.\n", resultcode);
- return 1;
+ result = 1;
+ goto free_result;
}
/* Now, loop through the data chunks and send WRITESIZE_MAX data */
@@ -1059,9 +1071,9 @@ int writeimage(wlandevice_t *wlandev, struct imgchunk *fchunk,
curroff = j * WRITESIZE_MAX;
currdaddr = fchunk[i].addr + curroff;
/* Setup the message */
- rwritemsg.addr.data = currdaddr;
- rwritemsg.len.data = currlen;
- memcpy(rwritemsg.data.data,
+ rwrmsg->addr.data = currdaddr;
+ rwrmsg->len.data = currlen;
+ memcpy(rwrmsg->data.data,
fchunk[i].data + curroff, currlen);
/* Send flashdl_write(pda) */
@@ -1069,23 +1081,23 @@ int writeimage(wlandevice_t *wlandev, struct imgchunk *fchunk,
("Sending xxxdl_write message addr=%06x len=%d.\n",
currdaddr, currlen);
- msgp = (struct p80211msg *) &rwritemsg;
- result = prism2mgmt_ramdl_write(wlandev, msgp);
+ result = prism2mgmt_ramdl_write(wlandev, rwrmsg);
/* Check the results */
if (result) {
printk(KERN_ERR
"writeimage chunk write failed w/ result=%d, "
"aborting download\n", result);
- return result;
+ goto free_result;
}
- resultcode = rstatemsg.resultcode.data;
+ resultcode = rstmsg->resultcode.data;
if (resultcode != P80211ENUM_resultcode_success) {
printk(KERN_ERR
"writeimage()->xxxdl_write msg indicates failure, "
"w/ resultcode=%d, aborting download.\n",
resultcode);
- return 1;
+ result = 1;
+ goto free_result;
}
}
@@ -1093,24 +1105,28 @@ int writeimage(wlandevice_t *wlandev, struct imgchunk *fchunk,
/* Send xxx_state(disable) */
pr_debug("Sending dl_state(disable) message.\n");
- rstatemsg.enable.data = P80211ENUM_truth_false;
- rstatemsg.exeaddr.data = 0;
+ rstmsg->enable.data = P80211ENUM_truth_false;
+ rstmsg->exeaddr.data = 0;
- msgp = (struct p80211msg *) &rstatemsg;
- result = prism2mgmt_ramdl_state(wlandev, msgp);
+ result = prism2mgmt_ramdl_state(wlandev, rstmsg);
if (result) {
printk(KERN_ERR
"writeimage state disable failed w/ result=%d, "
"aborting download\n", result);
- return result;
+ goto free_result;
}
- resultcode = rstatemsg.resultcode.data;
+ resultcode = rstmsg->resultcode.data;
if (resultcode != P80211ENUM_resultcode_success) {
printk(KERN_ERR
"writeimage()->xxxdl_state msg indicates failure, "
"w/ resultcode=%d, aborting download.\n", resultcode);
- return 1;
+ result = 1;
+ goto free_result;
}
+
+free_result:
+ kfree(rstmsg);
+ kfree(rwrmsg);
return result;
}
diff --git a/drivers/staging/wlan-ng/prism2mgmt.c b/drivers/staging/wlan-ng/prism2mgmt.c
index c3bb05dd744f..4efa9bc0fcf0 100644
--- a/drivers/staging/wlan-ng/prism2mgmt.c
+++ b/drivers/staging/wlan-ng/prism2mgmt.c
@@ -380,8 +380,8 @@ int prism2mgmt_scan_results(wlandevice_t *wlandev, void *msgp)
}
count = (hw->scanresults->framelen - 3) / 32;
- if (count > 32)
- count = 32;
+ if (count > HFA384x_SCANRESULT_MAX)
+ count = HFA384x_SCANRESULT_MAX;
if (req->bssindex.data >= count) {
pr_debug("requested index (%d) out of range (%d)\n",
diff --git a/drivers/staging/wlan-ng/prism2sta.c b/drivers/staging/wlan-ng/prism2sta.c
index 417aea5e01cd..1dfd9aa5e9fe 100644
--- a/drivers/staging/wlan-ng/prism2sta.c
+++ b/drivers/staging/wlan-ng/prism2sta.c
@@ -1947,8 +1947,8 @@ static wlandevice_t *create_wlan(void)
hfa384x_t *hw = NULL;
/* Alloc our structures */
- wlandev = kmalloc(sizeof(wlandevice_t), GFP_KERNEL);
- hw = kmalloc(sizeof(hfa384x_t), GFP_KERNEL);
+ wlandev = kzalloc(sizeof(wlandevice_t), GFP_KERNEL);
+ hw = kzalloc(sizeof(hfa384x_t), GFP_KERNEL);
if (!wlandev || !hw) {
printk(KERN_ERR "%s: Memory allocation failure.\n", dev_info);
@@ -1957,10 +1957,6 @@ static wlandevice_t *create_wlan(void)
return NULL;
}
- /* Clear all the structs */
- memset(wlandev, 0, sizeof(wlandevice_t));
- memset(hw, 0, sizeof(hfa384x_t));
-
/* Initialize the network device object. */
wlandev->nsdname = dev_info;
wlandev->msdstate = WLAN_MSD_HWPRESENT_PENDING;
diff --git a/drivers/staging/xgifb/XGI_main.h b/drivers/staging/xgifb/XGI_main.h
index e828fd403c35..c033da408a58 100644
--- a/drivers/staging/xgifb/XGI_main.h
+++ b/drivers/staging/xgifb/XGI_main.h
@@ -1,20 +1,9 @@
#ifndef _XGIFB_MAIN
#define _XGIFB_MAIN
-
-
/* ------------------- Constant Definitions ------------------------- */
-
-
#include "XGIfb.h"
-#include "vb_struct.h"
-#include "../../video/sis/sis.h"
#include "vb_def.h"
-#define XGIFAIL(x) do { printk(x "\n"); return -EINVAL; } while (0)
-
-#ifndef PCI_DEVICE_ID_XGI_41
-#define PCI_DEVICE_ID_XGI_41 0x041
-#endif
#ifndef PCI_DEVICE_ID_XGI_42
#define PCI_DEVICE_ID_XGI_42 0x042
#endif
@@ -79,180 +68,79 @@ static int XGIfb_crt2type = -1;
/* PR: Tv plug type (for overriding autodetection) */
static int XGIfb_tvplug = -1;
-/* TW: For ioctl XGIFB_GET_INFO */
-/* XGIfb_info XGIfbinfo; */
-
-#define MD_XGI300 1
-#define MD_XGI315 2
+#define MD_XGI315 1
/* mode table */
static const struct _XGIbios_mode {
- char name[15];
u8 mode_no;
u16 vesa_mode_no_1; /* "XGI defined" VESA mode number */
u16 vesa_mode_no_2; /* Real VESA mode numbers */
u16 xres;
u16 yres;
u16 bpp;
- u16 rate_idx;
- u16 cols;
- u16 rows;
u8 chipset;
} XGIbios_mode[] = {
- {"320x240x16", 0x56, 0x0000, 0x0000, 320, 240, 16, 1, 40, 15,
- MD_XGI315},
- {"320x480x8", 0x5A, 0x0000, 0x0000, 320, 480, 8, 1, 40, 30,
- MD_XGI315}, /* TW: FSTN */
- {"320x480x16", 0x5B, 0x0000, 0x0000, 320, 480, 16, 1, 40, 30,
- MD_XGI315}, /* TW: FSTN */
- {"640x480x8", 0x2E, 0x0101, 0x0101, 640, 480, 8, 1, 80, 30,
- MD_XGI300|MD_XGI315},
- {"640x480x16", 0x44, 0x0111, 0x0111, 640, 480, 16, 1, 80, 30,
- MD_XGI300|MD_XGI315},
- {"640x480x24", 0x62, 0x013a, 0x0112, 640, 480, 32, 1, 80, 30,
- MD_XGI300|MD_XGI315}, /* TW: That's for people who mix up color-
- and fb depth */
- {"640x480x32", 0x62, 0x013a, 0x0112, 640, 480, 32, 1, 80, 30,
- MD_XGI300|MD_XGI315},
- {"720x480x8", 0x31, 0x0000, 0x0000, 720, 480, 8, 1, 90, 30,
- MD_XGI300|MD_XGI315},
- {"720x480x16", 0x33, 0x0000, 0x0000, 720, 480, 16, 1, 90, 30,
- MD_XGI300|MD_XGI315},
- {"720x480x24", 0x35, 0x0000, 0x0000, 720, 480, 32, 1, 90, 30,
- MD_XGI300|MD_XGI315},
- {"720x480x32", 0x35, 0x0000, 0x0000, 720, 480, 32, 1, 90, 30,
- MD_XGI300|MD_XGI315},
- {"720x576x8", 0x32, 0x0000, 0x0000, 720, 576, 8, 1, 90, 36,
- MD_XGI300|MD_XGI315},
- {"720x576x16", 0x34, 0x0000, 0x0000, 720, 576, 16, 1, 90, 36,
- MD_XGI300|MD_XGI315},
- {"720x576x24", 0x36, 0x0000, 0x0000, 720, 576, 32, 1, 90, 36,
- MD_XGI300|MD_XGI315},
- {"720x576x32", 0x36, 0x0000, 0x0000, 720, 576, 32, 1, 90, 36,
- MD_XGI300|MD_XGI315},
- {"800x480x8", 0x70, 0x0000, 0x0000, 800, 480, 8, 1, 100, 30,
- MD_XGI300|MD_XGI315},
- {"800x480x16", 0x7a, 0x0000, 0x0000, 800, 480, 16, 1, 100, 30,
- MD_XGI300|MD_XGI315},
- {"800x480x24", 0x76, 0x0000, 0x0000, 800, 480, 32, 1, 100, 30,
- MD_XGI300|MD_XGI315},
- {"800x480x32", 0x76, 0x0000, 0x0000, 800, 480, 32, 1, 100, 30,
- MD_XGI300|MD_XGI315},
- {"800x600x8", 0x30, 0x0103, 0x0103, 800, 600, 8, 1, 100, 37,
- MD_XGI300|MD_XGI315},
-#define DEFAULT_MODE 20 /* index for 800x600x16 */
- {"800x600x16", 0x47, 0x0114, 0x0114, 800, 600, 16, 1, 100, 37,
- MD_XGI300|MD_XGI315},
- {"800x600x24", 0x63, 0x013b, 0x0115, 800, 600, 32, 1, 100, 37,
- MD_XGI300|MD_XGI315},
- {"800x600x32", 0x63, 0x013b, 0x0115, 800, 600, 32, 1, 100, 37,
- MD_XGI300|MD_XGI315},
- {"1024x576x8", 0x71, 0x0000, 0x0000, 1024, 576, 8, 1, 128, 36,
- MD_XGI300|MD_XGI315},
- {"1024x576x16", 0x74, 0x0000, 0x0000, 1024, 576, 16, 1, 128, 36,
- MD_XGI300|MD_XGI315},
- {"1024x576x24", 0x77, 0x0000, 0x0000, 1024, 576, 32, 1, 128, 36,
- MD_XGI300|MD_XGI315},
- {"1024x576x32", 0x77, 0x0000, 0x0000, 1024, 576, 32, 1, 128, 36,
- MD_XGI300|MD_XGI315},
- {"1024x600x8", 0x20, 0x0000, 0x0000, 1024, 600, 8, 1, 128, 37,
- MD_XGI300 }, /* TW: 300 series only */
- {"1024x600x16", 0x21, 0x0000, 0x0000, 1024, 600, 16, 1, 128, 37,
- MD_XGI300 },
- {"1024x600x24", 0x22, 0x0000, 0x0000, 1024, 600, 32, 1, 128, 37,
- MD_XGI300 },
- {"1024x600x32", 0x22, 0x0000, 0x0000, 1024, 600, 32, 1, 128, 37,
- MD_XGI300 },
- {"1024x768x8", 0x38, 0x0105, 0x0105, 1024, 768, 8, 1, 128, 48,
- MD_XGI300|MD_XGI315},
- {"1024x768x16", 0x4A, 0x0117, 0x0117, 1024, 768, 16, 1, 128, 48,
- MD_XGI300|MD_XGI315},
- {"1024x768x24", 0x64, 0x013c, 0x0118, 1024, 768, 32, 1, 128, 48,
- MD_XGI300|MD_XGI315},
- {"1024x768x32", 0x64, 0x013c, 0x0118, 1024, 768, 32, 1, 128, 48,
- MD_XGI300|MD_XGI315},
- {"1152x768x8", 0x23, 0x0000, 0x0000, 1152, 768, 8, 1, 144, 48,
- MD_XGI300 }, /* TW: 300 series only */
- {"1152x768x16", 0x24, 0x0000, 0x0000, 1152, 768, 16, 1, 144, 48,
- MD_XGI300 },
- {"1152x768x24", 0x25, 0x0000, 0x0000, 1152, 768, 32, 1, 144, 48,
- MD_XGI300 },
- {"1152x768x32", 0x25, 0x0000, 0x0000, 1152, 768, 32, 1, 144, 48,
- MD_XGI300 },
- {"1280x720x8", 0x79, 0x0000, 0x0000, 1280, 720, 8, 1, 160, 45,
- MD_XGI300|MD_XGI315},
- {"1280x720x16", 0x75, 0x0000, 0x0000, 1280, 720, 16, 1, 160, 45,
- MD_XGI300|MD_XGI315},
- {"1280x720x24", 0x78, 0x0000, 0x0000, 1280, 720, 32, 1, 160, 45,
- MD_XGI300|MD_XGI315},
- {"1280x720x32", 0x78, 0x0000, 0x0000, 1280, 720, 32, 1, 160, 45,
- MD_XGI300|MD_XGI315},
- {"1280x768x8", 0x23, 0x0000, 0x0000, 1280, 768, 8, 1, 160, 48,
- MD_XGI315}, /* TW: 310/325 series only */
- {"1280x768x16", 0x24, 0x0000, 0x0000, 1280, 768, 16, 1, 160, 48,
- MD_XGI315},
- {"1280x768x24", 0x25, 0x0000, 0x0000, 1280, 768, 32, 1, 160, 48,
- MD_XGI315},
- {"1280x768x32", 0x25, 0x0000, 0x0000, 1280, 768, 32, 1, 160, 48,
- MD_XGI315},
- {"1280x960x8", 0x7C, 0x0000, 0x0000, 1280, 960, 8, 1, 160, 60,
- MD_XGI300|MD_XGI315},
- {"1280x960x16", 0x7D, 0x0000, 0x0000, 1280, 960, 16, 1, 160, 60,
- MD_XGI300|MD_XGI315},
- {"1280x960x24", 0x7E, 0x0000, 0x0000, 1280, 960, 32, 1, 160, 60,
- MD_XGI300|MD_XGI315},
- {"1280x960x32", 0x7E, 0x0000, 0x0000, 1280, 960, 32, 1, 160, 60,
- MD_XGI300|MD_XGI315},
- {"1280x1024x8", 0x3A, 0x0107, 0x0107, 1280, 1024, 8, 1, 160, 64,
- MD_XGI300|MD_XGI315},
- {"1280x1024x16", 0x4D, 0x011a, 0x011a, 1280, 1024, 16, 1, 160, 64,
- MD_XGI300|MD_XGI315},
- {"1280x1024x24", 0x65, 0x013d, 0x011b, 1280, 1024, 32, 1, 160, 64,
- MD_XGI300|MD_XGI315},
- {"1280x1024x32", 0x65, 0x013d, 0x011b, 1280, 1024, 32, 1, 160, 64,
- MD_XGI300|MD_XGI315},
- {"1400x1050x8", 0x26, 0x0000, 0x0000, 1400, 1050, 8, 1, 175, 65,
- MD_XGI315}, /* TW: 310/325 series only */
- {"1400x1050x16", 0x27, 0x0000, 0x0000, 1400, 1050, 16, 1, 175, 65,
- MD_XGI315},
- {"1400x1050x24", 0x28, 0x0000, 0x0000, 1400, 1050, 32, 1, 175, 65,
- MD_XGI315},
- {"1400x1050x32", 0x28, 0x0000, 0x0000, 1400, 1050, 32, 1, 175, 65,
- MD_XGI315},
- {"1600x1200x8", 0x3C, 0x0130, 0x011c, 1600, 1200, 8, 1, 200, 75,
- MD_XGI300|MD_XGI315},
- {"1600x1200x16", 0x3D, 0x0131, 0x011e, 1600, 1200, 16, 1, 200, 75,
- MD_XGI300|MD_XGI315},
- {"1600x1200x24", 0x66, 0x013e, 0x011f, 1600, 1200, 32, 1, 200, 75,
- MD_XGI300|MD_XGI315},
- {"1600x1200x32", 0x66, 0x013e, 0x011f, 1600, 1200, 32, 1, 200, 75,
- MD_XGI300|MD_XGI315},
- {"1920x1440x8", 0x68, 0x013f, 0x0000, 1920, 1440, 8, 1, 240, 75,
- MD_XGI300|MD_XGI315},
- {"1920x1440x16", 0x69, 0x0140, 0x0000, 1920, 1440, 16, 1, 240, 75,
- MD_XGI300|MD_XGI315},
- {"1920x1440x24", 0x6B, 0x0141, 0x0000, 1920, 1440, 32, 1, 240, 75,
- MD_XGI300|MD_XGI315},
- {"1920x1440x32", 0x6B, 0x0141, 0x0000, 1920, 1440, 32, 1, 240, 75,
- MD_XGI300|MD_XGI315},
- {"2048x1536x8", 0x6c, 0x0000, 0x0000, 2048, 1536, 8, 1, 256, 96,
- MD_XGI315}, /* TW: 310/325 series only */
- {"2048x1536x16", 0x6d, 0x0000, 0x0000, 2048, 1536, 16, 1, 256, 96,
- MD_XGI315},
- {"2048x1536x24", 0x6e, 0x0000, 0x0000, 2048, 1536, 32, 1, 256, 96,
- MD_XGI315},
- {"2048x1536x32", 0x6e, 0x0000, 0x0000, 2048, 1536, 32, 1, 256, 96,
- MD_XGI315},
- {"\0", 0x00, 0, 0, 0, 0, 0, 0, 0}
+ { 0x56, 0x0000, 0x0000, 320, 240, 16, MD_XGI315 },
+ { 0x5A, 0x0000, 0x0000, 320, 480, 8, MD_XGI315 },
+ { 0x5B, 0x0000, 0x0000, 320, 480, 16, MD_XGI315 },
+ { 0x2E, 0x0101, 0x0101, 640, 480, 8, MD_XGI315 },
+ { 0x44, 0x0111, 0x0111, 640, 480, 16, MD_XGI315 },
+ { 0x62, 0x013a, 0x0112, 640, 480, 32, MD_XGI315 },
+ { 0x31, 0x0000, 0x0000, 720, 480, 8, MD_XGI315 },
+ { 0x33, 0x0000, 0x0000, 720, 480, 16, MD_XGI315 },
+ { 0x35, 0x0000, 0x0000, 720, 480, 32, MD_XGI315 },
+ { 0x32, 0x0000, 0x0000, 720, 576, 8, MD_XGI315 },
+ { 0x34, 0x0000, 0x0000, 720, 576, 16, MD_XGI315 },
+ { 0x36, 0x0000, 0x0000, 720, 576, 32, MD_XGI315 },
+ { 0x36, 0x0000, 0x0000, 720, 576, 32, MD_XGI315 },
+ { 0x70, 0x0000, 0x0000, 800, 480, 8, MD_XGI315 },
+ { 0x7a, 0x0000, 0x0000, 800, 480, 16, MD_XGI315 },
+ { 0x76, 0x0000, 0x0000, 800, 480, 32, MD_XGI315 },
+ { 0x30, 0x0103, 0x0103, 800, 600, 8, MD_XGI315 },
+#define DEFAULT_MODE 17 /* index for 800x600x16 */
+ { 0x47, 0x0114, 0x0114, 800, 600, 16, MD_XGI315 },
+ { 0x63, 0x013b, 0x0115, 800, 600, 32, MD_XGI315 },
+ { 0x71, 0x0000, 0x0000, 1024, 576, 8, MD_XGI315 },
+ { 0x74, 0x0000, 0x0000, 1024, 576, 16, MD_XGI315 },
+ { 0x77, 0x0000, 0x0000, 1024, 576, 32, MD_XGI315 },
+ { 0x77, 0x0000, 0x0000, 1024, 576, 32, MD_XGI315 },
+ { 0x20, 0x0000, 0x0000, 1024, 600, 8, },
+ { 0x21, 0x0000, 0x0000, 1024, 600, 16, },
+ { 0x22, 0x0000, 0x0000, 1024, 600, 32, },
+ { 0x38, 0x0105, 0x0105, 1024, 768, 8, MD_XGI315 },
+ { 0x4A, 0x0117, 0x0117, 1024, 768, 16, MD_XGI315 },
+ { 0x64, 0x013c, 0x0118, 1024, 768, 32, MD_XGI315 },
+ { 0x64, 0x013c, 0x0118, 1024, 768, 32, MD_XGI315 },
+ { 0x23, 0x0000, 0x0000, 1152, 768, 8, },
+ { 0x24, 0x0000, 0x0000, 1152, 768, 16, },
+ { 0x25, 0x0000, 0x0000, 1152, 768, 32, },
+ { 0x79, 0x0000, 0x0000, 1280, 720, 8, MD_XGI315 },
+ { 0x75, 0x0000, 0x0000, 1280, 720, 16, MD_XGI315 },
+ { 0x78, 0x0000, 0x0000, 1280, 720, 32, MD_XGI315 },
+ { 0x23, 0x0000, 0x0000, 1280, 768, 8, MD_XGI315 },
+ { 0x24, 0x0000, 0x0000, 1280, 768, 16, MD_XGI315 },
+ { 0x25, 0x0000, 0x0000, 1280, 768, 32, MD_XGI315 },
+ { 0x7C, 0x0000, 0x0000, 1280, 960, 8, MD_XGI315 },
+ { 0x7D, 0x0000, 0x0000, 1280, 960, 16, MD_XGI315 },
+ { 0x7E, 0x0000, 0x0000, 1280, 960, 32, MD_XGI315 },
+ { 0x3A, 0x0107, 0x0107, 1280, 1024, 8, MD_XGI315 },
+ { 0x4D, 0x011a, 0x011a, 1280, 1024, 16, MD_XGI315 },
+ { 0x65, 0x013d, 0x011b, 1280, 1024, 32, MD_XGI315 },
+ { 0x26, 0x0000, 0x0000, 1400, 1050, 8, MD_XGI315 },
+ { 0x27, 0x0000, 0x0000, 1400, 1050, 16, MD_XGI315 },
+ { 0x28, 0x0000, 0x0000, 1400, 1050, 32, MD_XGI315 },
+ { 0x3C, 0x0130, 0x011c, 1600, 1200, 8, MD_XGI315 },
+ { 0x3D, 0x0131, 0x011e, 1600, 1200, 16, MD_XGI315 },
+ { 0x66, 0x013e, 0x011f, 1600, 1200, 32, MD_XGI315 },
+ { 0x68, 0x013f, 0x0000, 1920, 1440, 8, MD_XGI315 },
+ { 0x69, 0x0140, 0x0000, 1920, 1440, 16, MD_XGI315 },
+ { 0x6B, 0x0141, 0x0000, 1920, 1440, 32, MD_XGI315 },
+ { 0x6c, 0x0000, 0x0000, 2048, 1536, 8, MD_XGI315 },
+ { 0x6d, 0x0000, 0x0000, 2048, 1536, 16, MD_XGI315 },
+ { 0x6e, 0x0000, 0x0000, 2048, 1536, 32, MD_XGI315 },
+ { 0 },
};
-/* TW: CR36 evaluation */
-static const unsigned short XGI300paneltype[] = {
- LCD_UNKNOWN, LCD_800x600, LCD_1024x768, LCD_1280x1024,
- LCD_1280x960, LCD_640x480, LCD_1024x600, LCD_1152x768,
- LCD_1024x768, LCD_1024x768, LCD_1024x768,
- LCD_1024x768, LCD_1024x768, LCD_1024x768, LCD_1024x768};
-
static const unsigned short XGI310paneltype[] = {
LCD_UNKNOWN, LCD_800x600, LCD_1024x768, LCD_1280x1024,
LCD_640x480, LCD_1024x600, LCD_1152x864, LCD_1280x960,
@@ -339,17 +227,6 @@ static const struct _XGI_vrate {
{0, 0, 0, 0}
};
-static const struct _chswtable {
- int subsysVendor;
- int subsysCard;
- char *vendorName;
- char *cardName;
-} mychswtable[] = {
- { 0x1631, 0x1002, "Mitachi", "0x1002" },
- { 0, 0, "" , "" }
-};
-
-/* Eden Chen */
static const struct _XGI_TV_filter {
u8 filter[9][4];
} XGI_TV_filter[] = {
diff --git a/drivers/staging/xgifb/XGI_main_26.c b/drivers/staging/xgifb/XGI_main_26.c
index 21c037827de4..64ffd70eb7dc 100644
--- a/drivers/staging/xgifb/XGI_main_26.c
+++ b/drivers/staging/xgifb/XGI_main_26.c
@@ -6,36 +6,12 @@
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
-/* #include <linux/config.h> */
#include <linux/module.h>
-#include <linux/moduleparam.h>
-#include <linux/kernel.h>
-#include <linux/spinlock.h>
-#include <linux/errno.h>
-#include <linux/string.h>
-#include <linux/mm.h>
-#include <linux/tty.h>
-#include <linux/slab.h>
-#include <linux/delay.h>
-#include <linux/fb.h>
-#include <linux/console.h>
-#include <linux/selection.h>
-#include <linux/ioport.h>
-#include <linux/init.h>
-#include <linux/pci.h>
-#include <linux/vt_kern.h>
-#include <linux/capability.h>
-#include <linux/fs.h>
-#include <linux/types.h>
-#include <linux/proc_fs.h>
-
-#include <linux/io.h>
+
#ifdef CONFIG_MTRR
#include <asm/mtrr.h>
#endif
-#include "XGIfb.h"
-#include "vgatypes.h"
#include "XGI_main.h"
#include "vb_init.h"
#include "vb_util.h"
@@ -54,86 +30,24 @@ static unsigned int refresh_rate;
/* -------------------- Macro definitions ---------------------------- */
-#undef XGIFBDEBUG
-
-#ifdef XGIFBDEBUG
-#define DPRINTK(fmt, args...) pr_debug("%s: " fmt, __func__ , ## args)
-#else
-#define DPRINTK(fmt, args...)
-#endif
-
-#ifdef XGIFBDEBUG
+#ifdef DEBUG
static void dumpVGAReg(void)
{
u8 i, reg;
xgifb_reg_set(XGISR, 0x05, 0x86);
- /*
- xgifb_reg_set(XGISR, 0x08, 0x4f);
- xgifb_reg_set(XGISR, 0x0f, 0x20);
- xgifb_reg_set(XGISR, 0x11, 0x4f);
- xgifb_reg_set(XGISR, 0x13, 0x45);
- xgifb_reg_set(XGISR, 0x14, 0x51);
- xgifb_reg_set(XGISR, 0x1e, 0x41);
- xgifb_reg_set(XGISR, 0x1f, 0x0);
- xgifb_reg_set(XGISR, 0x20, 0xa1);
- xgifb_reg_set(XGISR, 0x22, 0xfb);
- xgifb_reg_set(XGISR, 0x26, 0x22);
- xgifb_reg_set(XGISR, 0x3e, 0x07);
- */
-
- /* xgifb_reg_set(XGICR, 0x19, 0x00); */
- /* xgifb_reg_set(XGICR, 0x1a, 0x3C); */
- /* xgifb_reg_set(XGICR, 0x22, 0xff); */
- /* xgifb_reg_set(XGICR, 0x3D, 0x10); */
-
- /* xgifb_reg_set(XGICR, 0x4a, 0xf3); */
-
- /* xgifb_reg_set(XGICR, 0x57, 0x0); */
- /* xgifb_reg_set(XGICR, 0x7a, 0x2c); */
-
- /* xgifb_reg_set(XGICR, 0x82, 0xcc); */
- /* xgifb_reg_set(XGICR, 0x8c, 0x0); */
- /*
- xgifb_reg_set(XGICR, 0x99, 0x1);
- xgifb_reg_set(XGICR, 0x41, 0x40);
- */
for (i = 0; i < 0x4f; i++) {
reg = xgifb_reg_get(XGISR, i);
- printk("\no 3c4 %x", i);
- printk("\ni 3c5 => %x", reg);
+ pr_debug("o 3c4 %x\n", i);
+ pr_debug("i 3c5 => %x\n", reg);
}
for (i = 0; i < 0xF0; i++) {
reg = xgifb_reg_get(XGICR, i);
- printk("\no 3d4 %x", i);
- printk("\ni 3d5 => %x", reg);
- }
- /*
- xgifb_reg_set(XGIPART1,0x2F,1);
- for (i=1; i < 0x50; i++) {
- reg = xgifb_reg_get(XGIPART1, i);
- printk("\no d004 %x", i);
- printk("\ni d005 => %x", reg);
- }
-
- for (i=0; i < 0x50; i++) {
- reg = xgifb_reg_get(XGIPART2, i);
- printk("\no d010 %x", i);
- printk("\ni d011 => %x", reg);
- }
- for (i=0; i < 0x50; i++) {
- reg = xgifb_reg_get(XGIPART3, i);
- printk("\no d012 %x",i);
- printk("\ni d013 => %x",reg);
+ pr_debug("o 3d4 %x\n", i);
+ pr_debug("i 3d5 => %x\n", reg);
}
- for (i=0; i < 0x50; i++) {
- reg = xgifb_reg_get(XGIPART4, i);
- printk("\no d014 %x",i);
- printk("\ni d015 => %x",reg);
- }
- */
}
#else
static inline void dumpVGAReg(void)
@@ -141,12 +55,6 @@ static inline void dumpVGAReg(void)
}
#endif
-#if 1
-#define DEBUGPRN(x)
-#else
-#define DEBUGPRN(x) pr_info(x "\n");
-#endif
-
/* --------------- Hardware Access Routines -------------------------- */
static int XGIfb_mode_rate_to_dclock(struct vb_device_info *XGI_Pr,
@@ -156,25 +64,14 @@ static int XGIfb_mode_rate_to_dclock(struct vb_device_info *XGI_Pr,
unsigned short ModeNo = modeno;
unsigned short ModeIdIndex = 0, ClockIndex = 0;
unsigned short RefreshRateTableIndex = 0;
-
- /* unsigned long temp = 0; */
int Clock;
InitTo330Pointer(HwDeviceExtension->jChipType, XGI_Pr);
+ XGI_SearchModeID(ModeNo, &ModeIdIndex, XGI_Pr);
+
RefreshRateTableIndex = XGI_GetRatePtrCRT2(HwDeviceExtension, ModeNo,
ModeIdIndex, XGI_Pr);
- /*
- temp = XGI_SearchModeID(ModeNo , &ModeIdIndex, XGI_Pr) ;
- if (!temp) {
- printk(KERN_ERR "Could not find mode %x\n", ModeNo);
- return 65000;
- }
-
- RefreshRateTableIndex = XGI_Pr->EModeIDTable[ModeIdIndex].REFindex;
- RefreshRateTableIndex += (rateindex - 1);
-
- */
ClockIndex = XGI_Pr->RefIndex[RefreshRateTableIndex].Ext_CRTVCLK;
Clock = XGI_Pr->VCLKData[ClockIndex].CLOCK * 1000;
@@ -190,7 +87,7 @@ static int XGIfb_mode_rate_to_ddata(struct vb_device_info *XGI_Pr,
u32 *vmode)
{
unsigned short ModeNo = modeno;
- unsigned short ModeIdIndex = 0, index = 0;
+ unsigned short ModeIdIndex, index = 0;
unsigned short RefreshRateTableIndex = 0;
unsigned short VRE, VBE, VRS, VBS, VDE, VT;
@@ -199,16 +96,10 @@ static int XGIfb_mode_rate_to_ddata(struct vb_device_info *XGI_Pr,
unsigned long cr_data3;
int A, B, C, D, E, F, temp, j;
InitTo330Pointer(HwDeviceExtension->jChipType, XGI_Pr);
+ if (!XGI_SearchModeID(ModeNo, &ModeIdIndex, XGI_Pr))
+ return 0;
RefreshRateTableIndex = XGI_GetRatePtrCRT2(HwDeviceExtension, ModeNo,
ModeIdIndex, XGI_Pr);
- /*
- temp = XGI_SearchModeID(ModeNo, &ModeIdIndex, XGI_Pr);
- if (!temp)
- return 0;
-
- RefreshRateTableIndex = XGI_Pr->EModeIDTable[ModeIdIndex].REFindex;
- RefreshRateTableIndex += (rateindex - 1);
- */
index = XGI_Pr->RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC;
sr_data = XGI_Pr->XGINEWUB_CRT1Table[index].CR[5];
@@ -219,12 +110,6 @@ static int XGIfb_mode_rate_to_ddata(struct vb_device_info *XGI_Pr,
HT = (cr_data & 0xff) | ((unsigned short) (sr_data & 0x03) << 8);
A = HT + 5;
- /*
- cr_data = XGI_Pr->XGINEWUB_CRT1Table[index].CR[1];
-
- Horizontal display enable end
- HDE = (cr_data & 0xff) | ((unsigned short) (sr_data & 0x0C) << 6);
- */
HDE = (XGI_Pr->RefIndex[RefreshRateTableIndex].XRes >> 3) - 1;
E = HDE + 1;
@@ -276,15 +161,6 @@ static int XGIfb_mode_rate_to_ddata(struct vb_device_info *XGI_Pr,
| ((unsigned short) (sr_data & 0x01) << 10);
A = VT + 2;
- /* cr_data = XGI_Pr->XGINEWUB_CRT1Table[index].CR[10]; */
-
- /* Vertical display enable end */
- /*
- VDE = (cr_data & 0xff) |
- ((unsigned short) (cr_data2 & 0x02) << 7) |
- ((unsigned short) (cr_data2 & 0x40) << 3) |
- ((unsigned short) (sr_data & 0x02) << 9);
- */
VDE = XGI_Pr->RefIndex[RefreshRateTableIndex].YRes - 1;
E = VDE + 1;
@@ -358,7 +234,6 @@ static int XGIfb_mode_rate_to_ddata(struct vb_device_info *XGI_Pr,
static void XGIRegInit(struct vb_device_info *XGI_Pr, unsigned long BaseAddr)
{
- XGI_Pr->RelIO = BaseAddr;
XGI_Pr->P3c4 = BaseAddr + 0x14;
XGI_Pr->P3d4 = BaseAddr + 0x24;
XGI_Pr->P3c0 = BaseAddr + 0x10;
@@ -387,52 +262,50 @@ static void XGIRegInit(struct vb_device_info *XGI_Pr, unsigned long BaseAddr)
static int XGIfb_GetXG21DefaultLVDSModeIdx(struct xgifb_video_info *xgifb_info)
{
+ int i = 0;
- int found_mode = 0;
- int XGIfb_mode_idx = 0;
-
- found_mode = 0;
- while ((XGIbios_mode[XGIfb_mode_idx].mode_no != 0)
- && (XGIbios_mode[XGIfb_mode_idx].xres
- <= xgifb_info->lvds_data.LVDSHDE)) {
- if ((XGIbios_mode[XGIfb_mode_idx].xres
- == xgifb_info->lvds_data.LVDSHDE)
- && (XGIbios_mode[XGIfb_mode_idx].yres
- == xgifb_info->lvds_data.LVDSVDE)
- && (XGIbios_mode[XGIfb_mode_idx].bpp == 8)) {
- found_mode = 1;
- break;
+ while ((XGIbios_mode[i].mode_no != 0)
+ && (XGIbios_mode[i].xres <= xgifb_info->lvds_data.LVDSHDE)) {
+ if ((XGIbios_mode[i].xres == xgifb_info->lvds_data.LVDSHDE)
+ && (XGIbios_mode[i].yres == xgifb_info->lvds_data.LVDSVDE)
+ && (XGIbios_mode[i].bpp == 8)) {
+ return i;
}
- XGIfb_mode_idx++;
+ i++;
}
- if (!found_mode)
- XGIfb_mode_idx = -1;
- return XGIfb_mode_idx;
+ return -1;
}
static void XGIfb_search_mode(struct xgifb_video_info *xgifb_info,
const char *name)
{
- int i = 0, j = 0, l;
+ unsigned int xres;
+ unsigned int yres;
+ unsigned int bpp;
+ int i;
- while (XGIbios_mode[i].mode_no != 0) {
- l = min(strlen(name), strlen(XGIbios_mode[i].name));
- if (!strncmp(name, XGIbios_mode[i].name, l)) {
+ if (sscanf(name, "%ux%ux%u", &xres, &yres, &bpp) != 3)
+ goto invalid_mode;
+
+ if (bpp == 24)
+ bpp = 32; /* That's for people who mix up color and fb depth. */
+
+ for (i = 0; XGIbios_mode[i].mode_no != 0; i++)
+ if (XGIbios_mode[i].xres == xres &&
+ XGIbios_mode[i].yres == yres &&
+ XGIbios_mode[i].bpp == bpp) {
xgifb_info->mode_idx = i;
- j = 1;
- break;
+ return;
}
- i++;
- }
- if (!j)
- pr_info("Invalid mode '%s'\n", name);
+invalid_mode:
+ pr_info("Invalid mode '%s'\n", name);
}
static void XGIfb_search_vesamode(struct xgifb_video_info *xgifb_info,
unsigned int vesamode)
{
- int i = 0, j = 0;
+ int i = 0;
if (vesamode == 0)
goto invalid;
@@ -443,15 +316,13 @@ static void XGIfb_search_vesamode(struct xgifb_video_info *xgifb_info,
if ((XGIbios_mode[i].vesa_mode_no_1 == vesamode) ||
(XGIbios_mode[i].vesa_mode_no_2 == vesamode)) {
xgifb_info->mode_idx = i;
- j = 1;
- break;
+ return;
}
i++;
}
invalid:
- if (!j)
- pr_info("Invalid VESA mode 0x%x'\n", vesamode);
+ pr_info("Invalid VESA mode 0x%x'\n", vesamode);
}
static int XGIfb_validate_mode(struct xgifb_video_info *xgifb_info, int myindex)
@@ -645,7 +516,7 @@ static int XGIfb_validate_mode(struct xgifb_video_info *xgifb_info, int myindex)
if (XGIbios_mode[myindex].yres != 576)
return -1;
}
- /* TW: LVDS/CHRONTEL does not support 720 */
+ /* LVDS/CHRONTEL does not support 720 */
if (xgifb_info->hasVB == HASVB_LVDS_CHRONTEL ||
xgifb_info->hasVB == HASVB_CHRONTEL) {
return -1;
@@ -709,8 +580,8 @@ static u8 XGIfb_search_refresh_rate(struct xgifb_video_info *xgifb_info,
break;
} else if (XGIfb_vrate[i].refresh > rate) {
if ((XGIfb_vrate[i].refresh - rate) <= 3) {
- DPRINTK("XGIfb: Adjusting rate from %d up to %d\n",
- rate, XGIfb_vrate[i].refresh);
+ pr_debug("Adjusting rate from %d up to %d\n",
+ rate, XGIfb_vrate[i].refresh);
xgifb_info->rate_idx =
XGIfb_vrate[i].idx;
xgifb_info->refresh_rate =
@@ -718,8 +589,9 @@ static u8 XGIfb_search_refresh_rate(struct xgifb_video_info *xgifb_info,
} else if (((rate - XGIfb_vrate[i - 1].refresh)
<= 2) && (XGIfb_vrate[i].idx
!= 1)) {
- DPRINTK("XGIfb: Adjusting rate from %d down to %d\n",
- rate, XGIfb_vrate[i-1].refresh);
+ pr_debug("Adjusting rate from %d down to %d\n",
+ rate,
+ XGIfb_vrate[i-1].refresh);
xgifb_info->rate_idx =
XGIfb_vrate[i - 1].idx;
xgifb_info->refresh_rate =
@@ -727,8 +599,8 @@ static u8 XGIfb_search_refresh_rate(struct xgifb_video_info *xgifb_info,
}
break;
} else if ((rate - XGIfb_vrate[i].refresh) <= 2) {
- DPRINTK("XGIfb: Adjusting rate from %d down to %d\n",
- rate, XGIfb_vrate[i].refresh);
+ pr_debug("Adjusting rate from %d down to %d\n",
+ rate, XGIfb_vrate[i].refresh);
xgifb_info->rate_idx = XGIfb_vrate[i].idx;
break;
}
@@ -849,26 +721,25 @@ static void XGIfb_post_setmode(struct xgifb_video_info *xgifb_info)
{
u8 reg;
unsigned char doit = 1;
- /*
- xgifb_reg_set(XGISR,IND_SIS_PASSWORD,SIS_PASSWORD);
- xgifb_reg_set(XGICR, 0x13, 0x00);
- xgifb_reg_and_or(XGISR,0x0E, 0xF0, 0x01);
- *test*
- */
+
if (xgifb_info->video_bpp == 8) {
- /* TW: We can't switch off CRT1 on LVDS/Chrontel
- * in 8bpp Modes */
+ /*
+ * We can't switch off CRT1 on LVDS/Chrontel
+ * in 8bpp Modes
+ */
if ((xgifb_info->hasVB == HASVB_LVDS) ||
(xgifb_info->hasVB == HASVB_LVDS_CHRONTEL)) {
doit = 0;
}
- /* TW: We can't switch off CRT1 on 301B-DH
- * in 8bpp Modes if using LCD */
+ /*
+ * We can't switch off CRT1 on 301B-DH
+ * in 8bpp Modes if using LCD
+ */
if (xgifb_info->display2 == XGIFB_DISP_LCD)
doit = 0;
}
- /* TW: We can't switch off CRT1 if bridge is in slave mode */
+ /* We can't switch off CRT1 if bridge is in slave mode */
if (xgifb_info->hasVB != HASVB_NONE) {
reg = xgifb_reg_get(XGIPART1, 0x00);
@@ -1042,15 +913,15 @@ static void XGIfb_post_setmode(struct xgifb_video_info *xgifb_info)
}
if ((filter >= 0) && (filter <= 7)) {
- DPRINTK("FilterTable[%d]-%d: %02x %02x %02x %02x\n",
- filter_tb, filter,
- XGI_TV_filter[filter_tb].
+ pr_debug("FilterTable[%d]-%d: %02x %02x %02x %02x\n",
+ filter_tb, filter,
+ XGI_TV_filter[filter_tb].
filter[filter][0],
- XGI_TV_filter[filter_tb].
+ XGI_TV_filter[filter_tb].
filter[filter][1],
- XGI_TV_filter[filter_tb].
+ XGI_TV_filter[filter_tb].
filter[filter][2],
- XGI_TV_filter[filter_tb].
+ XGI_TV_filter[filter_tb].
filter[filter][3]
);
xgifb_reg_set(
@@ -1088,15 +959,11 @@ static int XGIfb_do_set_var(struct fb_var_screeninfo *var, int isactive,
unsigned int vtotal = var->upper_margin + var->yres + var->lower_margin
+ var->vsync_len;
#if defined(__powerpc__)
- u8 sr_data, cr_data;
+ u8 cr_data;
#endif
unsigned int drate = 0, hrate = 0;
int found_mode = 0;
int old_mode;
- /* unsigned char reg, reg1; */
-
- DEBUGPRN("Inside do_set_var");
- /* printk(KERN_DEBUG "XGIfb:var->yres=%d, var->upper_margin=%d, var->lower_margin=%d, var->vsync_len=%d\n", var->yres, var->upper_margin, var->lower_margin, var->vsync_len); */
info->var.xres_virtual = var->xres_virtual;
info->var.yres_virtual = var->yres_virtual;
@@ -1106,13 +973,9 @@ static int XGIfb_do_set_var(struct fb_var_screeninfo *var, int isactive,
vtotal <<= 1;
else if ((var->vmode & FB_VMODE_MASK) == FB_VMODE_DOUBLE)
vtotal <<= 2;
- else if ((var->vmode & FB_VMODE_MASK) == FB_VMODE_INTERLACED) {
- /* vtotal <<= 1; */
- /* var->yres <<= 1; */
- }
if (!htotal || !vtotal) {
- DPRINTK("XGIfb: Invalid 'var' information\n");
+ pr_debug("Invalid 'var' information\n");
return -EINVAL;
} pr_debug("var->pixclock=%d, htotal=%d, vtotal=%d\n",
var->pixclock, htotal, vtotal);
@@ -1162,8 +1025,7 @@ static int XGIfb_do_set_var(struct fb_var_screeninfo *var, int isactive,
if (XGIfb_search_refresh_rate(xgifb_info,
xgifb_info->refresh_rate) == 0) {
- xgifb_info->rate_idx =
- XGIbios_mode[xgifb_info->mode_idx].rate_idx;
+ xgifb_info->rate_idx = 1;
xgifb_info->refresh_rate = 60;
}
@@ -1189,11 +1051,11 @@ static int XGIfb_do_set_var(struct fb_var_screeninfo *var, int isactive,
XGIfb_post_setmode(xgifb_info);
- DPRINTK("XGIfb: Set new mode: %dx%dx%d-%d\n",
- XGIbios_mode[xgifb_info->mode_idx].xres,
- XGIbios_mode[xgifb_info->mode_idx].yres,
- XGIbios_mode[xgifb_info->mode_idx].bpp,
- xgifb_info->refresh_rate);
+ pr_debug("Set new mode: %dx%dx%d-%d\n",
+ XGIbios_mode[xgifb_info->mode_idx].xres,
+ XGIbios_mode[xgifb_info->mode_idx].yres,
+ XGIbios_mode[xgifb_info->mode_idx].bpp,
+ xgifb_info->refresh_rate);
xgifb_info->video_bpp = XGIbios_mode[xgifb_info->mode_idx].bpp;
xgifb_info->video_vwidth = info->var.xres_virtual;
@@ -1235,13 +1097,12 @@ static int XGIfb_do_set_var(struct fb_var_screeninfo *var, int isactive,
break;
default:
xgifb_info->video_cmap_len = 16;
- pr_err("Unsupported depth %d",
+ pr_err("Unsupported depth %d\n",
xgifb_info->video_bpp);
break;
}
}
XGIfb_bpp_to_var(xgifb_info, var); /*update ARGB info*/
- DEBUGPRN("End of do_set_var");
dumpVGAReg();
return 0;
@@ -1252,8 +1113,6 @@ static int XGIfb_pan_var(struct fb_var_screeninfo *var, struct fb_info *info)
struct xgifb_video_info *xgifb_info = info->par;
unsigned int base;
- /* printk("Inside pan_var"); */
-
base = var->yoffset * info->var.xres_virtual + var->xoffset;
/* calculate base bpp dep. */
@@ -1287,7 +1146,6 @@ static int XGIfb_pan_var(struct fb_var_screeninfo *var, struct fb_info *info)
0x7F,
((base >> 24) & 0x01) << 7);
}
- /* printk("End of pan_var"); */
return 0;
}
@@ -1363,13 +1221,21 @@ static int XGIfb_get_fix(struct fb_fix_screeninfo *fix, int con,
{
struct xgifb_video_info *xgifb_info = info->par;
- DEBUGPRN("inside get_fix");
memset(fix, 0, sizeof(struct fb_fix_screeninfo));
- fix->smem_start = xgifb_info->video_base;
+ strncpy(fix->id, "XGI", sizeof(fix->id) - 1);
+ /* if register_framebuffer has been called, we must lock */
+ if (atomic_read(&info->count))
+ mutex_lock(&info->mm_lock);
+
+ fix->smem_start = xgifb_info->video_base;
fix->smem_len = xgifb_info->video_size;
+ /* if register_framebuffer has been called, we can unlock */
+ if (atomic_read(&info->count))
+ mutex_unlock(&info->mm_lock);
+
fix->type = FB_TYPE_PACKED_PIXELS;
fix->type_aux = 0;
if (xgifb_info->video_bpp == 8)
@@ -1385,7 +1251,6 @@ static int XGIfb_get_fix(struct fb_fix_screeninfo *fix, int con,
fix->mmio_len = xgifb_info->mmio_size;
fix->accel = FB_ACCEL_SIS_XABRE;
- DEBUGPRN("end of get_fix");
return 0;
}
@@ -1393,12 +1258,10 @@ static int XGIfb_set_par(struct fb_info *info)
{
int err;
- /* printk("XGIfb: inside set_par\n"); */
err = XGIfb_do_set_var(&info->var, 1, info);
if (err)
return err;
XGIfb_get_fix(&info->fix, -1, info);
- /* printk("XGIfb: end of set_par\n"); */
return 0;
}
@@ -1412,8 +1275,6 @@ static int XGIfb_check_var(struct fb_var_screeninfo *var, struct fb_info *info)
int found_mode = 0;
int refresh_rate, search_idx;
- DEBUGPRN("Inside check_var");
-
if ((var->vmode & FB_VMODE_MASK) == FB_VMODE_NONINTERLACED) {
vtotal = var->upper_margin + var->yres + var->lower_margin
+ var->vsync_len;
@@ -1429,8 +1290,10 @@ static int XGIfb_check_var(struct fb_var_screeninfo *var, struct fb_info *info)
vtotal = var->upper_margin + var->yres + var->lower_margin
+ var->vsync_len;
- if (!(htotal) || !(vtotal))
- XGIFAIL("XGIfb: no valid timing data");
+ if (!(htotal) || !(vtotal)) {
+ pr_debug("No valid timing data\n");
+ return -EINVAL;
+ }
if (var->pixclock && htotal && vtotal) {
drate = 1000000000 / var->pixclock;
@@ -1446,16 +1309,7 @@ static int XGIfb_check_var(struct fb_var_screeninfo *var, struct fb_info *info)
xgifb_info->refresh_rate = 60;
}
- /*
- if ((var->pixclock) && (htotal)) {
- drate = 1E12 / var->pixclock;
- hrate = drate / htotal;
- refresh_rate = (unsigned int) (hrate / vtotal * 2 + 0.5);
- } else {
- refresh_rate = 60;
- }
- */
- /* TW: Calculation wrong for 1024x600 - force it to 60Hz */
+ /* Calculation wrong for 1024x600 - force it to 60Hz */
if ((var->xres == 1024) && (var->yres == 600))
refresh_rate = 60;
@@ -1504,8 +1358,6 @@ static int XGIfb_check_var(struct fb_var_screeninfo *var, struct fb_info *info)
}
}
- /* TW: TODO: Check the refresh rate */
-
/* Adapt RGB settings */
XGIfb_bpp_to_var(xgifb_info, var);
@@ -1520,16 +1372,7 @@ static int XGIfb_check_var(struct fb_var_screeninfo *var, struct fb_info *info)
var->xres_virtual = var->xres;
if (var->yres != var->yres_virtual)
var->yres_virtual = var->yres;
- } /* else { */
- /* TW: Now patch yres_virtual if we use panning */
- /* May I do this? */
- /* var->yres_virtual = xgifb_info->heapstart /
- (var->xres * (var->bits_per_pixel >> 3)); */
- /* if (var->yres_virtual <= var->yres) { */
- /* TW: Paranoia check */
- /* var->yres_virtual = var->yres; */
- /* } */
- /* } */
+ }
/* Truncate offsets to maximum if too high */
if (var->xoffset > var->xres_virtual - var->xres)
@@ -1544,7 +1387,6 @@ static int XGIfb_check_var(struct fb_var_screeninfo *var, struct fb_info *info)
var->blue.msb_right =
var->transp.offset = var->transp.length = var->transp.msb_right = 0;
- DEBUGPRN("end of check_var");
return 0;
}
@@ -1553,8 +1395,6 @@ static int XGIfb_pan_display(struct fb_var_screeninfo *var,
{
int err;
- /* printk("\nInside pan_display:\n"); */
-
if (var->xoffset > (info->var.xres_virtual - info->var.xres))
return -EINVAL;
if (var->yoffset > (info->var.yres_virtual - info->var.yres))
@@ -1581,7 +1421,6 @@ static int XGIfb_pan_display(struct fb_var_screeninfo *var,
else
info->var.vmode &= ~FB_VMODE_YWRAP;
- /* printk("End of pan_display\n"); */
return 0;
}
@@ -1615,7 +1454,6 @@ static struct fb_ops XGIfb_ops = {
.fb_fillrect = cfb_fillrect,
.fb_copyarea = cfb_copyarea,
.fb_imageblit = cfb_imageblit,
- /* .fb_mmap = XGIfb_mmap, */
};
/* ---------------- Chip generation dependent routines ---------------- */
@@ -1680,17 +1518,6 @@ static int XGIfb_get_dram_size(struct xgifb_video_info *xgifb_info)
ChannelNum = 1;
break;
- case XG45:
- if (tmp == 1)
- ChannelNum = 2;
- else if (tmp == 2)
- ChannelNum = 3;
- else if (tmp == 3)
- ChannelNum = 4;
- else
- ChannelNum = 1;
- break;
-
case XG40:
default:
if (tmp == 2)
@@ -1703,9 +1530,6 @@ static int XGIfb_get_dram_size(struct xgifb_video_info *xgifb_info)
}
xgifb_info->video_size = xgifb_info->video_size * ChannelNum;
- /* PLiad fixed for benchmarking and fb set */
- /* xgifb_info->video_size = 0x200000; */ /* 1024x768x16 */
- /* xgifb_info->video_size = 0x1000000; */ /* benchmark */
pr_info("SR14=%x DramSzie %x ChannelNum %x\n",
reg,
@@ -1720,16 +1544,6 @@ static void XGIfb_detect_VB(struct xgifb_video_info *xgifb_info)
xgifb_info->TV_plug = xgifb_info->TV_type = 0;
- switch (xgifb_info->hasVB) {
- case HASVB_LVDS_CHRONTEL:
- case HASVB_CHRONTEL:
- break;
- case HASVB_301:
- case HASVB_302:
- /* XGI_Sense30x(); */ /* Yi-Lin TV Sense? */
- break;
- }
-
cr32 = xgifb_reg_get(XGICR, IND_XGI_SCRATCH_REG_CR32);
if ((cr32 & SIS_CRT1) && !XGIfb_crt1off)
@@ -1753,7 +1567,7 @@ static void XGIfb_detect_VB(struct xgifb_video_info *xgifb_info)
}
if (XGIfb_tvplug != -1)
- /* PR/TW: Override with option */
+ /* Override with option */
xgifb_info->TV_plug = XGIfb_tvplug;
else if (cr32 & SIS_VB_HIVISION) {
xgifb_info->TV_type = TVMODE_HIVISION;
@@ -1773,7 +1587,7 @@ static void XGIfb_detect_VB(struct xgifb_video_info *xgifb_info)
xgifb_info->TV_type = TVMODE_NTSC;
}
- /* TW: Copy forceCRT1 option to CRT1off if option is given */
+ /* Copy forceCRT1 option to CRT1off if option is given */
if (XGIfb_forcecrt1 != -1) {
if (XGIfb_forcecrt1)
XGIfb_crt1off = 0;
@@ -1825,7 +1639,7 @@ static int __init xgifb_optval(char *fullopt, int validx)
unsigned long lres;
if (kstrtoul(fullopt + validx, 0, &lres) < 0 || lres > INT_MAX) {
- pr_err("xgifb: invalid value for option: %s\n", fullopt);
+ pr_err("Invalid value for option: %s\n", fullopt);
return 0;
}
return lres;
@@ -1838,7 +1652,7 @@ static int __init XGIfb_setup(char *options)
if (!options || !*options)
return 0;
- pr_info("xgifb: options: %s\n", options);
+ pr_info("Options: %s\n", options);
while ((this_opt = strsep(&options, ",")) != NULL) {
@@ -1867,7 +1681,7 @@ static int __init XGIfb_setup(char *options)
XGIfb_search_tvstd(this_opt + 7);
} else if (!strncmp(this_opt, "dstn", 4)) {
enable_dstn = 1;
- /* TW: DSTN overrules forcecrt2type */
+ /* DSTN overrules forcecrt2type */
XGIfb_crt2type = XGIFB_DISP_LCD;
} else if (!strncmp(this_opt, "noypan", 6)) {
XGIfb_ypan = 0;
@@ -1911,11 +1725,9 @@ static int __devinit xgifb_probe(struct pci_dev *pdev,
xgifb_info->mmio_base = pci_resource_start(pdev, 1);
xgifb_info->mmio_size = pci_resource_len(pdev, 1);
xgifb_info->vga_base = pci_resource_start(pdev, 2) + 0x30;
- hw_info->pjIOAddress = (unsigned char *)xgifb_info->vga_base;
- /* XGI_Pr.RelIO = ioremap(pci_resource_start(pdev, 2), 128) + 0x30; */
- pr_info("Relocate IO address: %lx [%08lx]\n",
- (unsigned long)pci_resource_start(pdev, 2),
- xgifb_info->dev_info.RelIO);
+ dev_info(&pdev->dev, "Relocate IO address: %Lx [%08lx]\n",
+ (u64) pci_resource_start(pdev, 2),
+ xgifb_info->vga_base);
if (pci_enable_device(pdev)) {
ret = -EIO;
@@ -1927,15 +1739,15 @@ static int __devinit xgifb_probe(struct pci_dev *pdev,
xgifb_info->display2_force = true;
}
- XGIRegInit(&xgifb_info->dev_info, (unsigned long)hw_info->pjIOAddress);
+ XGIRegInit(&xgifb_info->dev_info, xgifb_info->vga_base);
xgifb_reg_set(XGISR, IND_SIS_PASSWORD, SIS_PASSWORD);
reg1 = xgifb_reg_get(XGISR, IND_SIS_PASSWORD);
if (reg1 != 0xa1) { /*I/O error */
- pr_err("I/O error!!!");
+ dev_err(&pdev->dev, "I/O error\n");
ret = -EIO;
- goto error;
+ goto error_disable;
}
switch (xgifb_info->chip_id) {
@@ -1950,9 +1762,6 @@ static int __devinit xgifb_probe(struct pci_dev *pdev,
case PCI_DEVICE_ID_XGI_40:
xgifb_info->chip = XG40;
break;
- case PCI_DEVICE_ID_XGI_41:
- xgifb_info->chip = XG41;
- break;
case PCI_DEVICE_ID_XGI_42:
xgifb_info->chip = XG42;
break;
@@ -1961,16 +1770,17 @@ static int __devinit xgifb_probe(struct pci_dev *pdev,
break;
default:
ret = -ENODEV;
- goto error;
+ goto error_disable;
}
- pr_info("chipid = %x\n", xgifb_info->chip);
+ dev_info(&pdev->dev, "chipid = %x\n", xgifb_info->chip);
hw_info->jChipType = xgifb_info->chip;
if (XGIfb_get_dram_size(xgifb_info)) {
- pr_err("Fatal error: Unable to determine RAM size.\n");
+ dev_err(&pdev->dev,
+ "Fatal error: Unable to determine RAM size.\n");
ret = -ENODEV;
- goto error;
+ goto error_disable;
}
/* Enable PCI_LINEAR_ADDRESSING and MMIO_ENABLE */
@@ -1985,18 +1795,20 @@ static int __devinit xgifb_probe(struct pci_dev *pdev,
if (!request_mem_region(xgifb_info->video_base,
xgifb_info->video_size,
"XGIfb FB")) {
- pr_err("unable request memory size %x\n",
+ dev_err(&pdev->dev, "Unable request memory size %x\n",
xgifb_info->video_size);
- pr_err("Fatal error: Unable to reserve frame buffer memory\n");
- pr_err("Is there another framebuffer driver active?\n");
+ dev_err(&pdev->dev,
+ "Fatal error: Unable to reserve frame buffer memory. "
+ "Is there another framebuffer driver active?\n");
ret = -ENODEV;
- goto error;
+ goto error_disable;
}
if (!request_mem_region(xgifb_info->mmio_base,
xgifb_info->mmio_size,
"XGIfb MMIO")) {
- pr_err("Fatal error: Unable to reserve MMIO region\n");
+ dev_err(&pdev->dev,
+ "Fatal error: Unable to reserve MMIO region\n");
ret = -ENODEV;
goto error_0;
}
@@ -2006,18 +1818,20 @@ static int __devinit xgifb_probe(struct pci_dev *pdev,
xgifb_info->mmio_vbase = ioremap(xgifb_info->mmio_base,
xgifb_info->mmio_size);
- pr_info("Framebuffer at 0x%lx, mapped to 0x%p, size %dk\n",
- xgifb_info->video_base,
- xgifb_info->video_vbase,
- xgifb_info->video_size / 1024);
+ dev_info(&pdev->dev,
+ "Framebuffer at 0x%Lx, mapped to 0x%p, size %dk\n",
+ (u64) xgifb_info->video_base,
+ xgifb_info->video_vbase,
+ xgifb_info->video_size / 1024);
- pr_info("MMIO at 0x%lx, mapped to 0x%p, size %ldk\n",
- xgifb_info->mmio_base, xgifb_info->mmio_vbase,
- xgifb_info->mmio_size / 1024);
+ dev_info(&pdev->dev,
+ "MMIO at 0x%Lx, mapped to 0x%p, size %ldk\n",
+ (u64) xgifb_info->mmio_base, xgifb_info->mmio_vbase,
+ xgifb_info->mmio_size / 1024);
pci_set_drvdata(pdev, xgifb_info);
if (!XGIInitNew(pdev))
- pr_err("XGIInitNew() failed!\n");
+ dev_err(&pdev->dev, "XGIInitNew() failed!\n");
xgifb_info->mtrr = (unsigned int) 0;
@@ -2046,29 +1860,31 @@ static int __devinit xgifb_probe(struct pci_dev *pdev,
reg = xgifb_reg_get(XGIPART4, 0x01);
if (reg >= 0xE0) {
hw_info->ujVBChipID = VB_CHIP_302LV;
- pr_info("XGI302LV bridge detected (revision 0x%02x)\n", reg);
+ dev_info(&pdev->dev,
+ "XGI302LV bridge detected (revision 0x%02x)\n",
+ reg);
} else if (reg >= 0xD0) {
hw_info->ujVBChipID = VB_CHIP_301LV;
- pr_info("XGI301LV bridge detected (revision 0x%02x)\n", reg);
- }
- /* else if (reg >= 0xB0) {
- hw_info->ujVBChipID = VB_CHIP_301B;
- reg1 = xgifb_reg_get(XGIPART4, 0x23);
- printk("XGIfb: XGI301B bridge detected\n");
- } */
- else {
+ dev_info(&pdev->dev,
+ "XGI301LV bridge detected (revision 0x%02x)\n",
+ reg);
+ } else {
hw_info->ujVBChipID = VB_CHIP_301;
- pr_info("XGI301 bridge detected\n");
+ dev_info(&pdev->dev, "XGI301 bridge detected\n");
}
break;
case HASVB_302:
reg = xgifb_reg_get(XGIPART4, 0x01);
if (reg >= 0xE0) {
hw_info->ujVBChipID = VB_CHIP_302LV;
- pr_info("XGI302LV bridge detected (revision 0x%02x)\n", reg);
+ dev_info(&pdev->dev,
+ "XGI302LV bridge detected (revision 0x%02x)\n",
+ reg);
} else if (reg >= 0xD0) {
hw_info->ujVBChipID = VB_CHIP_301LV;
- pr_info("XGI302LV bridge detected (revision 0x%02x)\n", reg);
+ dev_info(&pdev->dev,
+ "XGI302LV bridge detected (revision 0x%02x)\n",
+ reg);
} else if (reg >= 0xB0) {
reg1 = xgifb_reg_get(XGIPART4, 0x23);
@@ -2076,27 +1892,28 @@ static int __devinit xgifb_probe(struct pci_dev *pdev,
} else {
hw_info->ujVBChipID = VB_CHIP_302;
- pr_info("XGI302 bridge detected\n");
+ dev_info(&pdev->dev, "XGI302 bridge detected\n");
}
break;
case HASVB_LVDS:
hw_info->ulExternalChip = 0x1;
- pr_info("LVDS transmitter detected\n");
+ dev_info(&pdev->dev, "LVDS transmitter detected\n");
break;
case HASVB_TRUMPION:
hw_info->ulExternalChip = 0x2;
- pr_info("Trumpion Zurac LVDS scaler detected\n");
+ dev_info(&pdev->dev, "Trumpion Zurac LVDS scaler detected\n");
break;
case HASVB_CHRONTEL:
hw_info->ulExternalChip = 0x4;
- pr_info("Chrontel TV encoder detected\n");
+ dev_info(&pdev->dev, "Chrontel TV encoder detected\n");
break;
case HASVB_LVDS_CHRONTEL:
hw_info->ulExternalChip = 0x5;
- pr_info("LVDS transmitter and Chrontel TV encoder detected\n");
+ dev_info(&pdev->dev,
+ "LVDS transmitter and Chrontel TV encoder detected\n");
break;
default:
- pr_info("No or unknown bridge type detected\n");
+ dev_info(&pdev->dev, "No or unknown bridge type detected\n");
break;
}
@@ -2113,36 +1930,6 @@ static int __devinit xgifb_probe(struct pci_dev *pdev,
}
}
- if ((hw_info->ujVBChipID == VB_CHIP_302B) ||
- (hw_info->ujVBChipID == VB_CHIP_301LV) ||
- (hw_info->ujVBChipID == VB_CHIP_302LV)) {
- int tmp;
- tmp = xgifb_reg_get(XGICR, 0x34);
- if (tmp <= 0x13) {
- /* Currently on LCDA?
- *(Some BIOSes leave CR38) */
- tmp = xgifb_reg_get(XGICR, 0x38);
- if ((tmp & 0x03) == 0x03) {
- /* XGI_Pr.XGI_UseLCDA = 1; */
- } else {
- /* Currently on LCDA?
- *(Some newer BIOSes set D0 in CR35) */
- tmp = xgifb_reg_get(XGICR, 0x35);
- if (tmp & 0x01) {
- /* XGI_Pr.XGI_UseLCDA = 1; */
- } else {
- tmp = xgifb_reg_get(XGICR,
- 0x30);
- if (tmp & 0x20) {
- tmp = xgifb_reg_get(
- XGIPART1, 0x13);
- }
- }
- }
- }
-
- }
-
xgifb_info->mode_idx = -1;
if (mode)
@@ -2164,18 +1951,17 @@ static int __devinit xgifb_probe(struct pci_dev *pdev,
}
if (xgifb_info->mode_idx < 0) {
- dev_err(&pdev->dev, "no supported video mode found\n");
+ dev_err(&pdev->dev, "No supported video mode found\n");
goto error_1;
}
- /* yilin set default refresh rate */
+ /* set default refresh rate */
xgifb_info->refresh_rate = refresh_rate;
if (xgifb_info->refresh_rate == 0)
xgifb_info->refresh_rate = 60;
if (XGIfb_search_refresh_rate(xgifb_info,
xgifb_info->refresh_rate) == 0) {
- xgifb_info->rate_idx =
- XGIbios_mode[xgifb_info->mode_idx].rate_idx;
+ xgifb_info->rate_idx = 1;
xgifb_info->refresh_rate = 60;
}
@@ -2265,11 +2051,6 @@ static int __devinit xgifb_probe(struct pci_dev *pdev,
}
- strncpy(fb_info->fix.id, "XGI", sizeof(fb_info->fix.id) - 1);
- fb_info->fix.type = FB_TYPE_PACKED_PIXELS;
- fb_info->fix.xpanstep = 1;
- fb_info->fix.ypanstep = 1;
-
fb_info->flags = FBINFO_FLAG_DEFAULT;
fb_info->screen_base = xgifb_info->video_vbase;
fb_info->fbops = &XGIfb_ops;
@@ -2282,7 +2063,7 @@ static int __devinit xgifb_probe(struct pci_dev *pdev,
xgifb_info->mtrr = mtrr_add(xgifb_info->video_base,
xgifb_info->video_size, MTRR_TYPE_WRCOMB, 1);
if (xgifb_info->mtrr >= 0)
- dev_info(&pdev->dev, "added MTRR\n");
+ dev_info(&pdev->dev, "Added MTRR\n");
#endif
if (register_framebuffer(fb_info) < 0) {
@@ -2306,6 +2087,8 @@ error_1:
release_mem_region(xgifb_info->mmio_base, xgifb_info->mmio_size);
error_0:
release_mem_region(xgifb_info->video_base, xgifb_info->video_size);
+error_disable:
+ pci_disable_device(pdev);
error:
framebuffer_release(fb_info);
return ret;
@@ -2330,6 +2113,7 @@ static void __devexit xgifb_remove(struct pci_dev *pdev)
iounmap(xgifb_info->video_vbase);
release_mem_region(xgifb_info->mmio_base, xgifb_info->mmio_size);
release_mem_region(xgifb_info->video_base, xgifb_info->video_size);
+ pci_disable_device(pdev);
framebuffer_release(fb_info);
pci_set_drvdata(pdev, NULL);
}
@@ -2341,51 +2125,44 @@ static struct pci_driver xgifb_driver = {
.remove = __devexit_p(xgifb_remove)
};
-static int __init xgifb_init(void)
-{
- char *option = NULL;
-
- if (forcecrt2type != NULL)
- XGIfb_search_crt2type(forcecrt2type);
- if (fb_get_options("xgifb", &option))
- return -ENODEV;
- XGIfb_setup(option);
-
- return pci_register_driver(&xgifb_driver);
-}
-module_init(xgifb_init);
/*****************************************************/
/* MODULE */
/*****************************************************/
-#ifdef MODULE
-
-MODULE_DESCRIPTION("Z7 Z9 Z9S Z11 framebuffer device driver");
-MODULE_LICENSE("GPL");
-MODULE_AUTHOR("XGITECH , Others");
-
module_param(mode, charp, 0);
-module_param(vesa, int, 0);
-module_param(filter, int, 0);
-module_param(forcecrt2type, charp, 0);
+MODULE_PARM_DESC(mode,
+ "Selects the desired default display mode in the format XxYxDepth "
+ "(eg. 1024x768x16).");
+module_param(forcecrt2type, charp, 0);
MODULE_PARM_DESC(forcecrt2type,
- "\nForce the second display output type. Possible values are NONE,\n"
- "LCD, TV, VGA, SVIDEO or COMPOSITE.\n");
-
-MODULE_PARM_DESC(mode,
- "\nSelects the desired default display mode in the format XxYxDepth,\n"
- "eg. 1024x768x16.\n");
+ "Force the second display output type. Possible values are NONE, "
+ "LCD, TV, VGA, SVIDEO or COMPOSITE.");
+module_param(vesa, int, 0);
MODULE_PARM_DESC(vesa,
- "\nSelects the desired default display mode by VESA mode number, eg.\n"
- "0x117.\n");
+ "Selects the desired default display mode by VESA mode number "
+ "(eg. 0x117).");
+module_param(filter, int, 0);
MODULE_PARM_DESC(filter,
- "\nSelects TV flicker filter type (only for systems with a SiS301 video bridge).\n"
- "(Possible values 0-7, default: [no filter])\n");
+ "Selects TV flicker filter type (only for systems with a SiS301 video bridge). "
+ "Possible values 0-7. Default: [no filter]).");
+
+static int __init xgifb_init(void)
+{
+ char *option = NULL;
+
+ if (forcecrt2type != NULL)
+ XGIfb_search_crt2type(forcecrt2type);
+ if (fb_get_options("xgifb", &option))
+ return -ENODEV;
+ XGIfb_setup(option);
+
+ return pci_register_driver(&xgifb_driver);
+}
static void __exit xgifb_remove_module(void)
{
@@ -2393,6 +2170,8 @@ static void __exit xgifb_remove_module(void)
pr_debug("Module unloaded\n");
}
+MODULE_DESCRIPTION("Z7 Z9 Z9S Z11 framebuffer device driver");
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR("XGITECH , Others");
+module_init(xgifb_init);
module_exit(xgifb_remove_module);
-
-#endif /* /MODULE */
diff --git a/drivers/staging/xgifb/XGIfb.h b/drivers/staging/xgifb/XGIfb.h
index 37bb730de047..80547983759b 100644
--- a/drivers/staging/xgifb/XGIfb.h
+++ b/drivers/staging/xgifb/XGIfb.h
@@ -1,8 +1,5 @@
#ifndef _LINUX_XGIFB
#define _LINUX_XGIFB
-#include <linux/ioctl.h>
-#include <linux/types.h>
-
#include "vgatypes.h"
#include "vb_struct.h"
@@ -23,9 +20,7 @@ enum xgifb_display_type {
enum XGI_CHIP_TYPE {
XG40 = 32,
- XG41,
XG42,
- XG45,
XG20 = 48,
XG21,
XG27,
@@ -35,13 +30,13 @@ enum xgi_tvtype {
TVMODE_NTSC = 0,
TVMODE_PAL,
TVMODE_HIVISION,
- TVTYPE_PALM, /* vicki@030226 */
- TVTYPE_PALN, /* vicki@030226 */
- TVTYPE_NTSCJ, /* vicki@030226 */
+ TVTYPE_PALM,
+ TVTYPE_PALN,
+ TVTYPE_NTSCJ,
TVMODE_TOTAL
};
-enum xgi_tv_plug { /* vicki@030226 */
+enum xgi_tv_plug {
TVPLUG_UNKNOWN = 0,
TVPLUG_COMPOSITE = 1,
TVPLUG_SVIDEO = 2,
@@ -66,9 +61,9 @@ struct xgifb_video_info {
int chip_id;
unsigned int video_size;
- unsigned long video_base;
+ phys_addr_t video_base;
void __iomem *video_vbase;
- unsigned long mmio_base;
+ phys_addr_t mmio_base;
unsigned long mmio_size;
void __iomem *mmio_vbase;
unsigned long vga_base;
diff --git a/drivers/staging/xgifb/vb_def.h b/drivers/staging/xgifb/vb_def.h
index c7317931f671..69078d933a47 100644
--- a/drivers/staging/xgifb/vb_def.h
+++ b/drivers/staging/xgifb/vb_def.h
@@ -1,5 +1,3 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/xgi/initdef.h
- * ,v 1.4 2000/12/02 01:16:17 dawes Exp $*/
#ifndef _VB_DEF_
#define _VB_DEF_
#include "../../video/sis/initdef.h"
@@ -12,7 +10,6 @@
#define SetCHTVOverScan 0x8000
#define Panel_320x480 0x07 /*fstn*/
-/* [ycchen] 02/12/03 Modify for Multi-Sync. LCD Support */
#define PanelResInfo 0x1F /* CR36 Panel Type/LCDResInfo */
#define Panel_1024x768x75 0x22
#define Panel_1280x1024x75 0x23
@@ -264,4 +261,23 @@
#define RES1280x960x85 0x46
#define RES1280x960x120 0x47
+
+#define XG27_CR8F 0x0C
+#define XG27_SR36 0x30
+#define XG27_SR40 0x04
+#define XG27_SR41 0x00
+#define XG40_CRCF 0x13
+#define XGI330_CRT2Data_1_2 0
+#define XGI330_CRT2Data_4_D 0
+#define XGI330_CRT2Data_4_E 0
+#define XGI330_CRT2Data_4_10 0x80
+#define XGI330_SR07 0x18
+#define XGI330_SR1F 0
+#define XGI330_SR23 0xf6
+#define XGI330_SR24 0x0d
+#define XGI330_SR25 0
+#define XGI330_SR31 0xc0
+#define XGI330_SR32 0x11
+#define XGI330_SR33 0
+
#endif
diff --git a/drivers/staging/xgifb/vb_init.c b/drivers/staging/xgifb/vb_init.c
index 3650bbff7686..80dba6a425ba 100644
--- a/drivers/staging/xgifb/vb_init.c
+++ b/drivers/staging/xgifb/vb_init.c
@@ -1,39 +1,30 @@
-#include <linux/types.h>
-#include <linux/delay.h> /* udelay */
-#include <linux/pci.h>
+#include <linux/delay.h>
#include <linux/vmalloc.h>
#include "XGIfb.h"
-#include "vgatypes.h"
-
#include "vb_def.h"
-#include "vb_struct.h"
#include "vb_util.h"
#include "vb_setmode.h"
#include "vb_init.h"
-
-
-#include <linux/io.h>
-
-static const unsigned short XGINew_DDRDRAM_TYPE340[4][5] = {
- { 2, 13, 9, 64, 0x45},
- { 2, 12, 9, 32, 0x35},
- { 2, 12, 8, 16, 0x31},
- { 2, 11, 8, 8, 0x21} };
-
-static const unsigned short XGINew_DDRDRAM_TYPE20[12][5] = {
- { 2, 14, 11, 128, 0x5D},
- { 2, 14, 10, 64, 0x59},
- { 2, 13, 11, 64, 0x4D},
- { 2, 14, 9, 32, 0x55},
- { 2, 13, 10, 32, 0x49},
- { 2, 12, 11, 32, 0x3D},
- { 2, 14, 8, 16, 0x51},
- { 2, 13, 9, 16, 0x45},
- { 2, 12, 10, 16, 0x39},
- { 2, 13, 8, 8, 0x41},
- { 2, 12, 9, 8, 0x35},
- { 2, 12, 8, 4, 0x31} };
+static const unsigned short XGINew_DDRDRAM_TYPE340[4][2] = {
+ { 16, 0x45},
+ { 8, 0x35},
+ { 4, 0x31},
+ { 2, 0x21} };
+
+static const unsigned short XGINew_DDRDRAM_TYPE20[12][2] = {
+ { 128, 0x5D},
+ { 64, 0x59},
+ { 64, 0x4D},
+ { 32, 0x55},
+ { 32, 0x49},
+ { 32, 0x3D},
+ { 16, 0x51},
+ { 16, 0x45},
+ { 16, 0x39},
+ { 8, 0x41},
+ { 8, 0x35},
+ { 4, 0x31} };
#define XGIFB_ROM_SIZE 65536
@@ -44,21 +35,12 @@ XGINew_GetXG20DRAMType(struct xgi_hw_device_info *HwDeviceExtension,
unsigned char data, temp;
if (HwDeviceExtension->jChipType < XG20) {
- if (*pVBInfo->pSoftSetting & SoftDRAMType) {
- data = *pVBInfo->pSoftSetting & 0x07;
- return data;
- } else {
- data = xgifb_reg_get(pVBInfo->P3c4, 0x39) & 0x02;
- if (data == 0)
- data = (xgifb_reg_get(pVBInfo->P3c4, 0x3A) &
- 0x02) >> 1;
- return data;
- }
+ data = xgifb_reg_get(pVBInfo->P3c4, 0x39) & 0x02;
+ if (data == 0)
+ data = (xgifb_reg_get(pVBInfo->P3c4, 0x3A) &
+ 0x02) >> 1;
+ return data;
} else if (HwDeviceExtension->jChipType == XG27) {
- if (*pVBInfo->pSoftSetting & SoftDRAMType) {
- data = *pVBInfo->pSoftSetting & 0x07;
- return data;
- }
temp = xgifb_reg_get(pVBInfo->P3c4, 0x3B);
/* SR3B[7][3]MAA15 MAA11 (Power on Trapping) */
if (((temp & 0x88) == 0x80) || ((temp & 0x88) == 0x08))
@@ -101,13 +83,11 @@ static void XGINew_DDR1x_MRS_340(unsigned long P3c4,
xgifb_reg_set(P3c4, 0x16, 0x00);
xgifb_reg_set(P3c4, 0x16, 0x80);
- if (*pVBInfo->pXGINew_DRAMTypeDefinition != 0x0C) { /* Samsung F Die */
- mdelay(3);
- xgifb_reg_set(P3c4, 0x18, 0x00);
- xgifb_reg_set(P3c4, 0x19, 0x20);
- xgifb_reg_set(P3c4, 0x16, 0x00);
- xgifb_reg_set(P3c4, 0x16, 0x80);
- }
+ mdelay(3);
+ xgifb_reg_set(P3c4, 0x18, 0x00);
+ xgifb_reg_set(P3c4, 0x19, 0x20);
+ xgifb_reg_set(P3c4, 0x16, 0x00);
+ xgifb_reg_set(P3c4, 0x16, 0x80);
udelay(60);
xgifb_reg_set(P3c4,
@@ -152,10 +132,8 @@ static void XGINew_SetMemoryClock(struct xgi_hw_device_info *HwDeviceExtension,
0x30,
pVBInfo->ECLKData[pVBInfo->ram_type].SR30);
- /* [Vicent] 2004/07/07,
- * When XG42 ECLK = MCLK = 207MHz, Set SR32 D[1:0] = 10b */
- /* [Hsuan] 2004/08/20,
- * Modify SR32 value, when MCLK=207MHZ, ELCK=250MHz,
+ /* When XG42 ECLK = MCLK = 207MHz, Set SR32 D[1:0] = 10b */
+ /* Modify SR32 value, when MCLK=207MHZ, ELCK=250MHz,
* Set SR32 D[1:0] = 10b */
if (HwDeviceExtension->jChipType == XG42) {
if ((pVBInfo->MCLKData[pVBInfo->ram_type].SR28 == 0x1C) &&
@@ -180,8 +158,7 @@ static void XGINew_DDRII_Bootup_XG27(
XGINew_SetMemoryClock(HwDeviceExtension, pVBInfo);
/* Set Double Frequency */
- /* xgifb_reg_set(P3d4, 0x97, 0x11); *//* CR97 */
- xgifb_reg_set(P3d4, 0x97, *pVBInfo->pXGINew_CR97); /* CR97 */
+ xgifb_reg_set(P3d4, 0x97, pVBInfo->XGINew_CR97); /* CR97 */
udelay(200);
@@ -212,7 +189,6 @@ static void XGINew_DDRII_Bootup_XG27(
udelay(30);
xgifb_reg_set(P3c4, 0x16, 0x00); /* Set SR16 */
xgifb_reg_set(P3c4, 0x16, 0x80); /* Set SR16 */
- /* udelay(15); */
xgifb_reg_set(P3c4, 0x1B, 0x04); /* Set SR1B */
udelay(60);
@@ -272,7 +248,6 @@ static void XGINew_DDR2_MRS_XG20(struct xgi_hw_device_info *HwDeviceExtension,
xgifb_reg_set(P3c4, 0x16, 0x05);
xgifb_reg_set(P3c4, 0x16, 0x85);
- /* xgifb_reg_set(P3c4, 0x18, 0x52); */ /* MRS1 */
xgifb_reg_set(P3c4, 0x18, 0x42); /* MRS1 */
xgifb_reg_set(P3c4, 0x19, 0x02);
xgifb_reg_set(P3c4, 0x16, 0x05);
@@ -284,7 +259,6 @@ static void XGINew_DDR2_MRS_XG20(struct xgi_hw_device_info *HwDeviceExtension,
xgifb_reg_set(P3c4, 0x1B, 0x00); /* SR1B */
udelay(100);
- /* xgifb_reg_set(P3c4 ,0x18, 0x52); */ /* MRS2 */
xgifb_reg_set(P3c4, 0x18, 0x42); /* MRS1 */
xgifb_reg_set(P3c4, 0x19, 0x00);
xgifb_reg_set(P3c4, 0x16, 0x05);
@@ -310,14 +284,12 @@ static void XGINew_DDR1x_MRS_XG20(unsigned long P3c4,
xgifb_reg_set(P3c4,
0x18,
pVBInfo->SR15[2][pVBInfo->ram_type]); /* SR18 */
- /* xgifb_reg_set(P3c4, 0x18, 0x31); */
xgifb_reg_set(P3c4, 0x19, 0x01);
xgifb_reg_set(P3c4, 0x16, 0x03);
xgifb_reg_set(P3c4, 0x16, 0x83);
mdelay(1);
xgifb_reg_set(P3c4, 0x1B, 0x03);
udelay(500);
- /* xgifb_reg_set(P3c4, 0x18, 0x31); */
xgifb_reg_set(P3c4,
0x18,
pVBInfo->SR15[2][pVBInfo->ram_type]); /* SR18 */
@@ -353,7 +325,6 @@ static void XGINew_DDR1x_DefaultRegister(
XGINew_SetMemoryClock(HwDeviceExtension, pVBInfo);
switch (HwDeviceExtension->jChipType) {
- case XG41:
case XG42:
/* CR82 */
xgifb_reg_set(P3d4,
@@ -542,7 +513,7 @@ static void XGINew_SetDRAMDefaultRegister340(
pVBInfo->CR40[0][pVBInfo->ram_type]); /* CR41 */
if (HwDeviceExtension->jChipType == XG27)
- xgifb_reg_set(P3d4, 0x8F, *pVBInfo->pCR8F); /* CR8F */
+ xgifb_reg_set(P3d4, 0x8F, XG27_CR8F); /* CR8F */
for (j = 0; j <= 6; j++) /* CR90 - CR96 */
xgifb_reg_set(P3d4, (0x90 + j),
@@ -556,8 +527,7 @@ static void XGINew_SetDRAMDefaultRegister340(
xgifb_reg_set(P3d4, (0x8A + j),
pVBInfo->CR40[1 + j][pVBInfo->ram_type]);
- if ((HwDeviceExtension->jChipType == XG41) ||
- (HwDeviceExtension->jChipType == XG42))
+ if (HwDeviceExtension->jChipType == XG42)
xgifb_reg_set(P3d4, 0x8C, 0x87);
xgifb_reg_set(P3d4,
@@ -566,9 +536,8 @@ static void XGINew_SetDRAMDefaultRegister340(
xgifb_reg_set(P3d4, 0x83, 0x09); /* CR83 */
xgifb_reg_set(P3d4, 0x87, 0x00); /* CR87 */
- xgifb_reg_set(P3d4, 0xCF, *pVBInfo->pCRCF); /* CRCF */
+ xgifb_reg_set(P3d4, 0xCF, XG40_CRCF); /* CRCF */
if (pVBInfo->ram_type) {
- /* xgifb_reg_set(P3c4, 0x17, 0xC0); */ /* SR17 DDRII */
xgifb_reg_set(P3c4, 0x17, 0x80); /* SR17 DDRII */
if (HwDeviceExtension->jChipType == XG27)
xgifb_reg_set(P3c4, 0x17, 0x02); /* SR17 DDRII */
@@ -590,27 +559,16 @@ static void XGINew_SetDRAMDefaultRegister340(
pVBInfo->SR15[3][pVBInfo->ram_type]); /* SR1B */
}
-static void XGINew_SetDRAMSizingType(int index,
- const unsigned short DRAMTYPE_TABLE[][5],
- struct vb_device_info *pVBInfo)
-{
- unsigned short data;
-
- data = DRAMTYPE_TABLE[index][4];
- xgifb_reg_and_or(pVBInfo->P3c4, 0x13, 0x80, data);
- udelay(15);
- /* should delay 50 ns */
-}
-static unsigned short XGINew_SetDRAMSizeReg(int index,
- const unsigned short DRAMTYPE_TABLE[][5],
+static unsigned short XGINew_SetDRAMSize20Reg(
+ unsigned short dram_size,
struct vb_device_info *pVBInfo)
{
unsigned short data = 0, memsize = 0;
int RankSize;
unsigned char ChannelNo;
- RankSize = DRAMTYPE_TABLE[index][3] * pVBInfo->ram_bus / 32;
+ RankSize = dram_size * pVBInfo->ram_bus / 8;
data = xgifb_reg_get(pVBInfo->P3c4, 0x13);
data &= 0x80;
@@ -630,63 +588,12 @@ static unsigned short XGINew_SetDRAMSizeReg(int index,
memsize = data >> 4;
- /* [2004/03/25] Vicent, Fix DRAM Sizing Error */
- xgifb_reg_set(pVBInfo->P3c4,
- 0x14,
- (xgifb_reg_get(pVBInfo->P3c4, 0x14) & 0x0F) |
- (data & 0xF0));
-
- /* data |= pVBInfo->ram_channel << 2; */
- /* data |= (pVBInfo->ram_bus / 64) << 1; */
- /* xgifb_reg_set(pVBInfo->P3c4, 0x14, data); */
-
- /* should delay */
- /* XGINew_SetDRAMModeRegister340(pVBInfo); */
- }
- return memsize;
-}
-
-static unsigned short XGINew_SetDRAMSize20Reg(int index,
- const unsigned short DRAMTYPE_TABLE[][5],
- struct vb_device_info *pVBInfo)
-{
- unsigned short data = 0, memsize = 0;
- int RankSize;
- unsigned char ChannelNo;
-
- RankSize = DRAMTYPE_TABLE[index][3] * pVBInfo->ram_bus / 8;
- data = xgifb_reg_get(pVBInfo->P3c4, 0x13);
- data &= 0x80;
-
- if (data == 0x80)
- RankSize *= 2;
-
- data = 0;
-
- if (pVBInfo->ram_channel == 3)
- ChannelNo = 4;
- else
- ChannelNo = pVBInfo->ram_channel;
-
- if (ChannelNo * RankSize <= 256) {
- while ((RankSize >>= 1) > 0)
- data += 0x10;
-
- memsize = data >> 4;
-
- /* [2004/03/25] Vicent, Fix DRAM Sizing Error */
+ /* Fix DRAM Sizing Error */
xgifb_reg_set(pVBInfo->P3c4,
0x14,
(xgifb_reg_get(pVBInfo->P3c4, 0x14) & 0x0F) |
(data & 0xF0));
udelay(15);
-
- /* data |= pVBInfo->ram_channel << 2; */
- /* data |= (pVBInfo->ram_bus / 64) << 1; */
- /* xgifb_reg_set(pVBInfo->P3c4, 0x14, data); */
-
- /* should delay */
- /* XGINew_SetDRAMModeRegister340(pVBInfo); */
}
return memsize;
}
@@ -705,8 +612,7 @@ static int XGINew_ReadWriteRest(unsigned short StopAddr,
writel(Position, fbaddr + Position);
}
- udelay(500); /* [Vicent] 2004/04/16.
- Fix #1759 Memory Size error in Multi-Adapter. */
+ udelay(500); /* Fix #1759 Memory Size error in Multi-Adapter. */
Position = 0;
@@ -854,78 +760,6 @@ static void XGINew_CheckChannel(struct xgi_hw_device_info *HwDeviceExtension,
pVBInfo->ram_channel = 1; /* Single channel */
xgifb_reg_set(pVBInfo->P3c4, 0x14, 0x51); /* 32Mx16 bit*/
break;
- case XG41:
- if (XGINew_CheckFrequence(pVBInfo) == 1) {
- pVBInfo->ram_bus = 32; /* 32 bits */
- pVBInfo->ram_channel = 3; /* Quad Channel */
- xgifb_reg_set(pVBInfo->P3c4, 0x13, 0xA1);
- xgifb_reg_set(pVBInfo->P3c4, 0x14, 0x4C);
-
- if (XGINew_ReadWriteRest(25, 23, pVBInfo) == 1)
- return;
-
- pVBInfo->ram_channel = 2; /* Dual channels */
- xgifb_reg_set(pVBInfo->P3c4, 0x14, 0x48);
-
- if (XGINew_ReadWriteRest(24, 23, pVBInfo) == 1)
- return;
-
- xgifb_reg_set(pVBInfo->P3c4, 0x14, 0x49);
-
- if (XGINew_ReadWriteRest(24, 23, pVBInfo) == 1)
- return;
-
- pVBInfo->ram_channel = 3;
- xgifb_reg_set(pVBInfo->P3c4, 0x13, 0x21);
- xgifb_reg_set(pVBInfo->P3c4, 0x14, 0x3C);
-
- if (XGINew_ReadWriteRest(24, 23, pVBInfo) == 1)
- return;
-
- xgifb_reg_set(pVBInfo->P3c4, 0x14, 0x38);
-
- if (XGINew_ReadWriteRest(8, 4, pVBInfo) == 1)
- return;
- else
- xgifb_reg_set(pVBInfo->P3c4, 0x14, 0x39);
- } else { /* DDR */
- pVBInfo->ram_bus = 64; /* 64 bits */
- pVBInfo->ram_channel = 2; /* Dual channels */
- xgifb_reg_set(pVBInfo->P3c4, 0x13, 0xA1);
- xgifb_reg_set(pVBInfo->P3c4, 0x14, 0x5A);
-
- if (XGINew_ReadWriteRest(25, 24, pVBInfo) == 1)
- return;
-
- pVBInfo->ram_channel = 1; /* Single channels */
- xgifb_reg_set(pVBInfo->P3c4, 0x14, 0x52);
-
- if (XGINew_ReadWriteRest(24, 23, pVBInfo) == 1)
- return;
-
- xgifb_reg_set(pVBInfo->P3c4, 0x14, 0x53);
-
- if (XGINew_ReadWriteRest(24, 23, pVBInfo) == 1)
- return;
-
- pVBInfo->ram_channel = 2; /* Dual channels */
- xgifb_reg_set(pVBInfo->P3c4, 0x13, 0x21);
- xgifb_reg_set(pVBInfo->P3c4, 0x14, 0x4A);
-
- if (XGINew_ReadWriteRest(24, 23, pVBInfo) == 1)
- return;
-
- pVBInfo->ram_channel = 1; /* Single channels */
- xgifb_reg_set(pVBInfo->P3c4, 0x14, 0x42);
-
- if (XGINew_ReadWriteRest(8, 4, pVBInfo) == 1)
- return;
- else
- xgifb_reg_set(pVBInfo->P3c4, 0x14, 0x43);
- }
-
- break;
-
case XG42:
/*
XG42 SR14 D[3] Reserve
@@ -1020,52 +854,41 @@ static void XGINew_CheckChannel(struct xgi_hw_device_info *HwDeviceExtension,
static int XGINew_DDRSizing340(struct xgi_hw_device_info *HwDeviceExtension,
struct vb_device_info *pVBInfo)
{
- int i;
- unsigned short memsize, addr;
+ u8 i, size;
+ unsigned short memsize, start_addr;
+ const unsigned short (*dram_table)[2];
xgifb_reg_set(pVBInfo->P3c4, 0x15, 0x00); /* noninterleaving */
xgifb_reg_set(pVBInfo->P3c4, 0x1C, 0x00); /* nontiling */
XGINew_CheckChannel(HwDeviceExtension, pVBInfo);
if (HwDeviceExtension->jChipType >= XG20) {
- for (i = 0; i < 12; i++) {
- XGINew_SetDRAMSizingType(i,
- XGINew_DDRDRAM_TYPE20,
- pVBInfo);
- memsize = XGINew_SetDRAMSize20Reg(i,
- XGINew_DDRDRAM_TYPE20,
- pVBInfo);
- if (memsize == 0)
- continue;
-
- addr = memsize + (pVBInfo->ram_channel - 2) + 20;
- if ((HwDeviceExtension->ulVideoMemorySize - 1) <
- (unsigned long) (1 << addr))
- continue;
-
- if (XGINew_ReadWriteRest(addr, 5, pVBInfo) == 1)
- return 1;
- }
+ dram_table = XGINew_DDRDRAM_TYPE20;
+ size = ARRAY_SIZE(XGINew_DDRDRAM_TYPE20);
+ start_addr = 5;
} else {
- for (i = 0; i < 4; i++) {
- XGINew_SetDRAMSizingType(i,
- XGINew_DDRDRAM_TYPE340,
- pVBInfo);
- memsize = XGINew_SetDRAMSizeReg(i,
- XGINew_DDRDRAM_TYPE340,
- pVBInfo);
-
- if (memsize == 0)
- continue;
-
- addr = memsize + (pVBInfo->ram_channel - 2) + 20;
- if ((HwDeviceExtension->ulVideoMemorySize - 1) <
- (unsigned long) (1 << addr))
- continue;
-
- if (XGINew_ReadWriteRest(addr, 9, pVBInfo) == 1)
- return 1;
- }
+ dram_table = XGINew_DDRDRAM_TYPE340;
+ size = ARRAY_SIZE(XGINew_DDRDRAM_TYPE340);
+ start_addr = 9;
+ }
+
+ for (i = 0; i < size; i++) {
+ /* SetDRAMSizingType */
+ xgifb_reg_and_or(pVBInfo->P3c4, 0x13, 0x80, dram_table[i][1]);
+ udelay(15); /* should delay 50 ns */
+
+ memsize = XGINew_SetDRAMSize20Reg(dram_table[i][0], pVBInfo);
+
+ if (memsize == 0)
+ continue;
+
+ memsize += (pVBInfo->ram_channel - 2) + 20;
+ if ((HwDeviceExtension->ulVideoMemorySize - 1) <
+ (unsigned long) (1 << memsize))
+ continue;
+
+ if (XGINew_ReadWriteRest(memsize, start_addr, pVBInfo) == 1)
+ return 1;
}
return 0;
}
@@ -1085,9 +908,6 @@ static void XGINew_SetDRAMSize_340(struct xgifb_video_info *xgifb_info,
xgifb_reg_set(pVBInfo->P3c4, 0x21, (unsigned short) (data & 0xDF));
XGI_DisplayOff(xgifb_info, HwDeviceExtension, pVBInfo);
- /* data = xgifb_reg_get(pVBInfo->P3c4, 0x1); */
- /* data |= 0x20 ; */
- /* xgifb_reg_set(pVBInfo->P3c4, 0x01, data); *//* Turn OFF Display */
XGINew_DDRSizing340(HwDeviceExtension, pVBInfo);
data = xgifb_reg_get(pVBInfo->P3c4, 0x21);
/* enable read cache */
@@ -1131,7 +951,7 @@ static void xgifb_read_vbios(struct pci_dev *pdev,
pVBInfo->IF_DEF_LVDS = 0;
vbios = xgifb_copy_rom(pdev, &vbios_size);
if (vbios == NULL) {
- dev_err(&pdev->dev, "video BIOS not available\n");
+ dev_err(&pdev->dev, "Video BIOS not available\n");
return;
}
if (vbios_size <= 0x65)
@@ -1186,7 +1006,7 @@ static void xgifb_read_vbios(struct pci_dev *pdev,
pVBInfo->IF_DEF_LVDS = 1;
return;
error:
- dev_err(&pdev->dev, "video BIOS corrupted\n");
+ dev_err(&pdev->dev, "Video BIOS corrupted\n");
vfree(vbios);
}
@@ -1222,15 +1042,10 @@ static void XGINew_ChkSenseStatus(struct xgi_hw_device_info *HwDeviceExtension,
if (tempbx & tempcx) {
CR3CData = xgifb_reg_get(pVBInfo->P3d4, 0x3c);
- if (!(CR3CData & DisplayDeviceFromCMOS)) {
+ if (!(CR3CData & DisplayDeviceFromCMOS))
tempcx = 0x1FF0;
- if (*pVBInfo->pSoftSetting & ModeSoftSetting)
- tempbx = 0x1FF0;
- }
} else {
tempcx = 0x1FF0;
- if (*pVBInfo->pSoftSetting & ModeSoftSetting)
- tempbx = 0x1FF0;
}
tempbx &= tempcx;
@@ -1369,13 +1184,11 @@ static void XGINew_GetXG21Sense(struct xgi_hw_device_info *HwDeviceExtension,
{
unsigned char Temp;
-#if 1
if (pVBInfo->IF_DEF_LVDS) { /* For XG21 LVDS */
xgifb_reg_or(pVBInfo->P3d4, 0x32, LCDSense);
/* LVDS on chip */
xgifb_reg_and_or(pVBInfo->P3d4, 0x38, ~0xE0, 0xC0);
} else {
-#endif
/* Enable GPIOA/B read */
xgifb_reg_and_or(pVBInfo->P3d4, 0x4A, ~0x03, 0x03);
Temp = xgifb_reg_get(pVBInfo->P3d4, 0x48) & 0xC0;
@@ -1398,9 +1211,7 @@ static void XGINew_GetXG21Sense(struct xgi_hw_device_info *HwDeviceExtension,
/* Disable read GPIOF */
xgifb_reg_and(pVBInfo->P3d4, 0x4A, ~0x20);
}
-#if 1
}
-#endif
}
static void XGINew_GetXG27Sense(struct xgi_hw_device_info *HwDeviceExtension,
@@ -1472,37 +1283,23 @@ unsigned char XGIInitNew(struct pci_dev *pdev)
struct vb_device_info VBINF;
struct vb_device_info *pVBInfo = &VBINF;
unsigned char i, temp = 0, temp1;
- /* VBIOSVersion[5]; */
-
- /* unsigned long j, k; */
pVBInfo->FBAddr = HwDeviceExtension->pjVideoMemoryAddress;
- pVBInfo->BaseAddr = (unsigned long) HwDeviceExtension->pjIOAddress;
-
- /* Newdebugcode(0x99); */
+ pVBInfo->BaseAddr = xgifb_info->vga_base;
if (pVBInfo->FBAddr == NULL) {
- printk("\n pVBInfo->FBAddr == 0 ");
+ dev_dbg(&pdev->dev, "pVBInfo->FBAddr == 0\n");
return 0;
}
- printk("1");
if (pVBInfo->BaseAddr == 0) {
- printk("\npVBInfo->BaseAddr == 0 ");
+ dev_dbg(&pdev->dev, "pVBInfo->BaseAddr == 0\n");
return 0;
}
- printk("2");
outb(0x67, (pVBInfo->BaseAddr + 0x12)); /* 3c2 <- 67 ,ynlai */
pVBInfo->ISXPDOS = 0;
- printk("3");
-
- printk("4");
-
- /* VBIOSVersion[4] = 0x0; */
-
- /* 09/07/99 modify by domao */
pVBInfo->P3c4 = pVBInfo->BaseAddr + 0x14;
pVBInfo->P3d4 = pVBInfo->BaseAddr + 0x24;
@@ -1521,9 +1318,8 @@ unsigned char XGIInitNew(struct pci_dev *pdev)
pVBInfo->Part3Port = pVBInfo->BaseAddr + SIS_CRT2_PORT_12;
pVBInfo->Part4Port = pVBInfo->BaseAddr + SIS_CRT2_PORT_14;
pVBInfo->Part5Port = pVBInfo->BaseAddr + SIS_CRT2_PORT_14 + 2;
- printk("5");
- if (HwDeviceExtension->jChipType < XG20) /* kuku 2004/06/25 */
+ if (HwDeviceExtension->jChipType < XG20)
/* Run XGI_GetVBType before InitTo330Pointer */
XGI_GetVBType(pVBInfo);
@@ -1531,9 +1327,8 @@ unsigned char XGIInitNew(struct pci_dev *pdev)
xgifb_read_vbios(pdev, pVBInfo);
- /* 1.Openkey */
+ /* Openkey */
xgifb_reg_set(pVBInfo->P3c4, 0x05, 0x86);
- printk("6");
/* GetXG21Sense (GPIO) */
if (HwDeviceExtension->jChipType == XG21)
@@ -1542,9 +1337,7 @@ unsigned char XGIInitNew(struct pci_dev *pdev)
if (HwDeviceExtension->jChipType == XG27)
XGINew_GetXG27Sense(HwDeviceExtension, pVBInfo);
- printk("7");
-
- /* 2.Reset Extended register */
+ /* Reset Extended register */
for (i = 0x06; i < 0x20; i++)
xgifb_reg_set(pVBInfo->P3c4, i, 0);
@@ -1552,105 +1345,37 @@ unsigned char XGIInitNew(struct pci_dev *pdev)
for (i = 0x21; i <= 0x27; i++)
xgifb_reg_set(pVBInfo->P3c4, i, 0);
- /* for(i = 0x06; i <= 0x27; i++) */
- /* xgifb_reg_set(pVBInfo->P3c4, i, 0); */
-
- printk("8");
-
for (i = 0x31; i <= 0x3B; i++)
xgifb_reg_set(pVBInfo->P3c4, i, 0);
- printk("9");
- /* [Hsuan] 2004/08/20 Auto over driver for XG42 */
+ /* Auto over driver for XG42 */
if (HwDeviceExtension->jChipType == XG42)
xgifb_reg_set(pVBInfo->P3c4, 0x3B, 0xC0);
- /* for (i = 0x30; i <= 0x3F; i++) */
- /* xgifb_reg_set(pVBInfo->P3d4, i, 0); */
-
for (i = 0x79; i <= 0x7C; i++)
- xgifb_reg_set(pVBInfo->P3d4, i, 0); /* shampoo 0208 */
-
- printk("10");
+ xgifb_reg_set(pVBInfo->P3d4, i, 0);
if (HwDeviceExtension->jChipType >= XG20)
- xgifb_reg_set(pVBInfo->P3d4, 0x97, *pVBInfo->pXGINew_CR97);
+ xgifb_reg_set(pVBInfo->P3d4, 0x97, pVBInfo->XGINew_CR97);
- /* 3.SetMemoryClock
-
- pVBInfo->ram_type = XGINew_GetXG20DRAMType(HwDeviceExtension, pVBInfo);
- */
-
- printk("11");
-
- /* 4.SetDefExt1Regs begin */
- xgifb_reg_set(pVBInfo->P3c4, 0x07, *pVBInfo->pSR07);
+ /* SetDefExt1Regs begin */
+ xgifb_reg_set(pVBInfo->P3c4, 0x07, XGI330_SR07);
if (HwDeviceExtension->jChipType == XG27) {
- xgifb_reg_set(pVBInfo->P3c4, 0x40, *pVBInfo->pSR40);
- xgifb_reg_set(pVBInfo->P3c4, 0x41, *pVBInfo->pSR41);
+ xgifb_reg_set(pVBInfo->P3c4, 0x40, XG27_SR40);
+ xgifb_reg_set(pVBInfo->P3c4, 0x41, XG27_SR41);
}
xgifb_reg_set(pVBInfo->P3c4, 0x11, 0x0F);
- xgifb_reg_set(pVBInfo->P3c4, 0x1F, *pVBInfo->pSR1F);
- /* xgifb_reg_set(pVBInfo->P3c4, 0x20, 0x20); */
- /* alan, 2001/6/26 Frame buffer can read/write SR20 */
+ xgifb_reg_set(pVBInfo->P3c4, 0x1F, XGI330_SR1F);
+ /* Frame buffer can read/write SR20 */
xgifb_reg_set(pVBInfo->P3c4, 0x20, 0xA0);
- /* Hsuan, 2006/01/01 H/W request for slow corner chip */
+ /* H/W request for slow corner chip */
xgifb_reg_set(pVBInfo->P3c4, 0x36, 0x70);
- if (HwDeviceExtension->jChipType == XG27) /* Alan 12/07/2006 */
- xgifb_reg_set(pVBInfo->P3c4, 0x36, *pVBInfo->pSR36);
-
- /* SR11 = 0x0F; */
- /* xgifb_reg_set(pVBInfo->P3c4, 0x11, SR11); */
-
- printk("12");
+ if (HwDeviceExtension->jChipType == XG27)
+ xgifb_reg_set(pVBInfo->P3c4, 0x36, XG27_SR36);
- if (HwDeviceExtension->jChipType < XG20) { /* kuku 2004/06/25 */
+ if (HwDeviceExtension->jChipType < XG20) {
u32 Temp;
- /* Set AGP Rate */
- /*
- temp1 = xgifb_reg_get(pVBInfo->P3c4, 0x3B);
- temp1 &= 0x02;
- if (temp1 == 0x02) {
- outl(0x80000000, 0xcf8);
- ChipsetID = inl(0x0cfc);
- outl(0x8000002C, 0xcf8);
- VendorID = inl(0x0cfc);
- VendorID &= 0x0000FFFF;
- outl(0x8001002C, 0xcf8);
- GraphicVendorID = inl(0x0cfc);
- GraphicVendorID &= 0x0000FFFF;
-
- if (ChipsetID == 0x7301039)
- xgifb_reg_set(pVBInfo->P3d4, 0x5F, 0x09);
-
- ChipsetID &= 0x0000FFFF;
-
- if ((ChipsetID == 0x700E) ||
- (ChipsetID == 0x1022) ||
- (ChipsetID == 0x1106) ||
- (ChipsetID == 0x10DE)) {
- if (ChipsetID == 0x1106) {
- if ((VendorID == 0x1019) &&
- (GraphicVendorID == 0x1019))
- xgifb_reg_set(pVBInfo->P3d4,
- 0x5F,
- 0x0D);
- else
- xgifb_reg_set(pVBInfo->P3d4,
- 0x5F,
- 0x0B);
- } else {
- xgifb_reg_set(pVBInfo->P3d4,
- 0x5F,
- 0x0B);
- }
- }
- }
- */
-
- printk("13");
-
/* Set AGP customize registers (in SetDefAGPRegs) Start */
for (i = 0x47; i <= 0x4C; i++)
xgifb_reg_set(pVBInfo->P3d4,
@@ -1666,12 +1391,6 @@ unsigned char XGIInitNew(struct pci_dev *pdev)
xgifb_reg_set(pVBInfo->P3d4,
i,
pVBInfo->AGPReg[8 + i - 0x74]);
- /* Set AGP customize registers (in SetDefAGPRegs) End */
- /* [Hsuan]2004/12/14 AGP Input Delay Adjustment on 850 */
- /* outl(0x80000000, 0xcf8); */
- /* ChipsetID = inl(0x0cfc); */
- /* if (ChipsetID == 0x25308086) */
- /* xgifb_reg_set(pVBInfo->P3d4, 0x77, 0xF0); */
pci_read_config_dword(pdev, 0x50, &Temp);
Temp >>= 20;
@@ -1679,19 +1398,17 @@ unsigned char XGIInitNew(struct pci_dev *pdev)
if (Temp == 1)
xgifb_reg_set(pVBInfo->P3d4, 0x48, 0x20); /* CR48 */
- printk("14");
} /* != XG20 */
/* Set PCI */
- xgifb_reg_set(pVBInfo->P3c4, 0x23, *pVBInfo->pSR23);
- xgifb_reg_set(pVBInfo->P3c4, 0x24, *pVBInfo->pSR24);
- xgifb_reg_set(pVBInfo->P3c4, 0x25, pVBInfo->SR25[0]);
- printk("15");
+ xgifb_reg_set(pVBInfo->P3c4, 0x23, XGI330_SR23);
+ xgifb_reg_set(pVBInfo->P3c4, 0x24, XGI330_SR24);
+ xgifb_reg_set(pVBInfo->P3c4, 0x25, XGI330_SR25);
- if (HwDeviceExtension->jChipType < XG20) { /* kuku 2004/06/25 */
+ if (HwDeviceExtension->jChipType < XG20) {
/* Set VB */
XGI_UnLockCRT2(HwDeviceExtension, pVBInfo);
- /* alan, disable VideoCapture */
+ /* disable VideoCapture */
xgifb_reg_and_or(pVBInfo->Part0Port, 0x3F, 0xEF, 0x00);
xgifb_reg_set(pVBInfo->Part1Port, 0x00, 0x00);
/* chk if BCLK>=100MHz */
@@ -1699,10 +1416,7 @@ unsigned char XGIInitNew(struct pci_dev *pdev)
temp = (unsigned char) ((temp1 >> 4) & 0x0F);
xgifb_reg_set(pVBInfo->Part1Port,
- 0x02,
- (*pVBInfo->pCRT2Data_1_2));
-
- printk("16");
+ 0x02, XGI330_CRT2Data_1_2);
xgifb_reg_set(pVBInfo->Part1Port, 0x2E, 0x08); /* use VB */
} /* != XG20 */
@@ -1714,51 +1428,36 @@ unsigned char XGIInitNew(struct pci_dev *pdev)
/* Not DDR */
xgifb_reg_set(pVBInfo->P3c4,
0x31,
- (*pVBInfo->pSR31 & 0x3F) | 0x40);
+ (XGI330_SR31 & 0x3F) | 0x40);
xgifb_reg_set(pVBInfo->P3c4,
0x32,
- (*pVBInfo->pSR32 & 0xFC) | 0x01);
+ (XGI330_SR32 & 0xFC) | 0x01);
} else {
- xgifb_reg_set(pVBInfo->P3c4, 0x31, *pVBInfo->pSR31);
- xgifb_reg_set(pVBInfo->P3c4, 0x32, *pVBInfo->pSR32);
+ xgifb_reg_set(pVBInfo->P3c4, 0x31, XGI330_SR31);
+ xgifb_reg_set(pVBInfo->P3c4, 0x32, XGI330_SR32);
}
- xgifb_reg_set(pVBInfo->P3c4, 0x33, *pVBInfo->pSR33);
- printk("17");
+ xgifb_reg_set(pVBInfo->P3c4, 0x33, XGI330_SR33);
- /*
- SetPowerConsume (HwDeviceExtension, pVBInfo->P3c4); */
-
- if (HwDeviceExtension->jChipType < XG20) { /* kuku 2004/06/25 */
+ if (HwDeviceExtension->jChipType < XG20) {
if (XGI_BridgeIsOn(pVBInfo) == 1) {
if (pVBInfo->IF_DEF_LVDS == 0) {
xgifb_reg_set(pVBInfo->Part2Port, 0x00, 0x1C);
xgifb_reg_set(pVBInfo->Part4Port,
- 0x0D,
- *pVBInfo->pCRT2Data_4_D);
+ 0x0D, XGI330_CRT2Data_4_D);
xgifb_reg_set(pVBInfo->Part4Port,
- 0x0E,
- *pVBInfo->pCRT2Data_4_E);
+ 0x0E, XGI330_CRT2Data_4_E);
xgifb_reg_set(pVBInfo->Part4Port,
- 0x10,
- *pVBInfo->pCRT2Data_4_10);
+ 0x10, XGI330_CRT2Data_4_10);
xgifb_reg_set(pVBInfo->Part4Port, 0x0F, 0x3F);
}
XGI_LockCRT2(HwDeviceExtension, pVBInfo);
}
} /* != XG20 */
- printk("18");
-
- printk("181");
-
- printk("182");
XGI_SenseCRT1(pVBInfo);
- printk("183");
- /* XGINew_DetectMonitor(HwDeviceExtension); */
if (HwDeviceExtension->jChipType == XG21) {
- printk("186");
xgifb_reg_and_or(pVBInfo->P3d4,
0x32,
@@ -1766,7 +1465,6 @@ unsigned char XGIInitNew(struct pci_dev *pdev)
Monitor1Sense); /* Z9 default has CRT */
temp = GetXG21FPBits(pVBInfo);
xgifb_reg_and_or(pVBInfo->P3d4, 0x37, ~0x01, temp);
- printk("187");
}
if (HwDeviceExtension->jChipType == XG27) {
@@ -1777,7 +1475,6 @@ unsigned char XGIInitNew(struct pci_dev *pdev)
temp = GetXG27FPBits(pVBInfo);
xgifb_reg_and_or(pVBInfo->P3d4, 0x37, ~0x03, temp);
}
- printk("19");
pVBInfo->ram_type = XGINew_GetXG20DRAMType(HwDeviceExtension, pVBInfo);
@@ -1785,51 +1482,19 @@ unsigned char XGIInitNew(struct pci_dev *pdev)
pVBInfo->P3d4,
pVBInfo);
- printk("20");
XGINew_SetDRAMSize_340(xgifb_info, HwDeviceExtension, pVBInfo);
- printk("21");
- printk("22");
-
- /* SetDefExt2Regs begin */
- /*
- AGP = 1;
- temp = (unsigned char) xgifb_reg_get(pVBInfo->P3c4, 0x3A);
- temp &= 0x30;
- if (temp == 0x30)
- AGP = 0;
-
- if (AGP == 0)
- *pVBInfo->pSR21 &= 0xEF;
-
- xgifb_reg_set(pVBInfo->P3c4, 0x21, *pVBInfo->pSR21);
- if (AGP == 1)
- *pVBInfo->pSR22 &= 0x20;
- xgifb_reg_set(pVBInfo->P3c4, 0x22, *pVBInfo->pSR22);
- */
- /* base = 0x80000000; */
- /* OutPortLong(0xcf8, base); */
- /* Temp = (InPortLong(0xcfc) & 0xFFFF); */
- /* if (Temp == 0x1039) { */
xgifb_reg_set(pVBInfo->P3c4,
0x22,
- (unsigned char) ((*pVBInfo->pSR22) & 0xFE));
- /* } else { */
- /* xgifb_reg_set(pVBInfo->P3c4, 0x22, *pVBInfo->pSR22); */
- /* } */
+ (unsigned char) ((pVBInfo->SR22) & 0xFE));
- xgifb_reg_set(pVBInfo->P3c4, 0x21, *pVBInfo->pSR21);
-
- printk("23");
+ xgifb_reg_set(pVBInfo->P3c4, 0x21, pVBInfo->SR21);
XGINew_ChkSenseStatus(HwDeviceExtension, pVBInfo);
XGINew_SetModeScratch(HwDeviceExtension, pVBInfo);
- printk("24");
-
xgifb_reg_set(pVBInfo->P3d4, 0x8c, 0x87);
xgifb_reg_set(pVBInfo->P3c4, 0x14, 0x31);
- printk("25");
return 1;
} /* end of init */
diff --git a/drivers/staging/xgifb/vb_setmode.c b/drivers/staging/xgifb/vb_setmode.c
index 60d4adf99923..e81149fc66e3 100644
--- a/drivers/staging/xgifb/vb_setmode.c
+++ b/drivers/staging/xgifb/vb_setmode.c
@@ -1,50 +1,13 @@
-
-#include <linux/io.h>
#include <linux/delay.h>
-#include <linux/types.h>
#include "XGIfb.h"
-
#include "vb_def.h"
-#include "vgatypes.h"
-#include "vb_struct.h"
-#include "vb_init.h"
#include "vb_util.h"
#include "vb_table.h"
#include "vb_setmode.h"
-
#define IndexMask 0xff
-
-static const unsigned short XGINew_MDA_DAC[] = {
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15,
- 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15,
- 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15,
- 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15,
- 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F};
-
-static const unsigned short XGINew_CGA_DAC[] = {
- 0x00, 0x10, 0x04, 0x14, 0x01, 0x11, 0x09, 0x15,
- 0x00, 0x10, 0x04, 0x14, 0x01, 0x11, 0x09, 0x15,
- 0x2A, 0x3A, 0x2E, 0x3E, 0x2B, 0x3B, 0x2F, 0x3F,
- 0x2A, 0x3A, 0x2E, 0x3E, 0x2B, 0x3B, 0x2F, 0x3F,
- 0x00, 0x10, 0x04, 0x14, 0x01, 0x11, 0x09, 0x15,
- 0x00, 0x10, 0x04, 0x14, 0x01, 0x11, 0x09, 0x15,
- 0x2A, 0x3A, 0x2E, 0x3E, 0x2B, 0x3B, 0x2F, 0x3F,
- 0x2A, 0x3A, 0x2E, 0x3E, 0x2B, 0x3B, 0x2F, 0x3F};
-
-static const unsigned short XGINew_EGA_DAC[] = {
- 0x00, 0x10, 0x04, 0x14, 0x01, 0x11, 0x05, 0x15,
- 0x20, 0x30, 0x24, 0x34, 0x21, 0x31, 0x25, 0x35,
- 0x08, 0x18, 0x0C, 0x1C, 0x09, 0x19, 0x0D, 0x1D,
- 0x28, 0x38, 0x2C, 0x3C, 0x29, 0x39, 0x2D, 0x3D,
- 0x02, 0x12, 0x06, 0x16, 0x03, 0x13, 0x07, 0x17,
- 0x22, 0x32, 0x26, 0x36, 0x23, 0x33, 0x27, 0x37,
- 0x0A, 0x1A, 0x0E, 0x1E, 0x0B, 0x1B, 0x0F, 0x1F,
- 0x2A, 0x3A, 0x2E, 0x3E, 0x2B, 0x3B, 0x2F, 0x3F};
+#define TVCLKBASE_315_25 (TVCLKBASE_315 + 25)
static const unsigned short XGINew_VGA_DAC[] = {
0x00, 0x10, 0x04, 0x14, 0x01, 0x11, 0x09, 0x15,
@@ -60,8 +23,7 @@ static const unsigned short XGINew_VGA_DAC[] = {
void InitTo330Pointer(unsigned char ChipType, struct vb_device_info *pVBInfo)
{
- pVBInfo->SModeIDTable = (struct XGI_StStruct *) XGI330_SModeIDTable;
- pVBInfo->StandTable = (struct SiS_StandTable_S *) XGI330_StandTable;
+ pVBInfo->StandTable = (struct SiS_StandTable_S *) &XGI330_StandTable;
pVBInfo->EModeIDTable = (struct XGI_ExtStruct *) XGI330_EModeIDTable;
pVBInfo->RefIndex = (struct XGI_Ext2Struct *) XGI330_RefIndex;
pVBInfo->XGINEWUB_CRT1Table
@@ -76,9 +38,6 @@ void InitTo330Pointer(unsigned char ChipType, struct vb_device_info *pVBInfo)
pVBInfo->ModeResInfo
= (struct SiS_ModeResInfo_S *) XGI330_ModeResInfo;
- pVBInfo->pOutputSelect = &XGI330_OutputSelect;
- pVBInfo->pSoftSetting = &XGI330_SoftSetting;
- pVBInfo->pSR07 = &XGI330_SR07;
pVBInfo->LCDResInfo = 0;
pVBInfo->LCDTypeInfo = 0;
pVBInfo->LCDInfo = 0;
@@ -87,36 +46,15 @@ void InitTo330Pointer(unsigned char ChipType, struct vb_device_info *pVBInfo)
pVBInfo->SR15 = XGI340_SR13;
pVBInfo->CR40 = XGI340_cr41;
- pVBInfo->SR25 = XGI330_sr25;
- pVBInfo->pSR31 = &XGI330_sr31;
- pVBInfo->pSR32 = &XGI330_sr32;
pVBInfo->CR6B = XGI340_CR6B;
pVBInfo->CR6E = XGI340_CR6E;
pVBInfo->CR6F = XGI340_CR6F;
pVBInfo->CR89 = XGI340_CR89;
pVBInfo->AGPReg = XGI340_AGPReg;
pVBInfo->SR16 = XGI340_SR16;
- pVBInfo->pCRCF = &XG40_CRCF;
- pVBInfo->pXGINew_DRAMTypeDefinition = &XG40_DRAMTypeDefinition;
-
- pVBInfo->CR49 = XGI330_CR49;
- pVBInfo->pSR1F = &XGI330_SR1F;
- pVBInfo->pSR21 = &XGI330_SR21;
- pVBInfo->pSR22 = &XGI330_SR22;
- pVBInfo->pSR23 = &XGI330_SR23;
- pVBInfo->pSR24 = &XGI330_SR24;
- pVBInfo->pSR33 = &XGI330_SR33;
-
- pVBInfo->pCRT2Data_1_2 = &XGI330_CRT2Data_1_2;
- pVBInfo->pCRT2Data_4_D = &XGI330_CRT2Data_4_D;
- pVBInfo->pCRT2Data_4_E = &XGI330_CRT2Data_4_E;
- pVBInfo->pCRT2Data_4_10 = &XGI330_CRT2Data_4_10;
- pVBInfo->pRGBSenseData = &XGI330_RGBSenseData;
- pVBInfo->pVideoSenseData = &XGI330_VideoSenseData;
- pVBInfo->pYCSenseData = &XGI330_YCSenseData;
- pVBInfo->pRGBSenseData2 = &XGI330_RGBSenseData2;
- pVBInfo->pVideoSenseData2 = &XGI330_VideoSenseData2;
- pVBInfo->pYCSenseData2 = &XGI330_YCSenseData2;
+
+ pVBInfo->SR21 = 0xa3;
+ pVBInfo->SR22 = 0xfb;
pVBInfo->NTSCTiming = XGI330_NTSCTiming;
pVBInfo->PALTiming = XGI330_PALTiming;
@@ -143,77 +81,37 @@ void InitTo330Pointer(unsigned char ChipType, struct vb_device_info *pVBInfo)
else
pVBInfo->LCDCapList = XGI_LCDCapList;
- pVBInfo->XGI_TVDelayList = XGI301TVDelayList;
- pVBInfo->XGI_TVDelayList2 = XGI301TVDelayList2;
-
- pVBInfo->pXGINew_I2CDefinition = &XG40_I2CDefinition;
-
if (ChipType >= XG20)
- pVBInfo->pXGINew_CR97 = &XG20_CR97;
+ pVBInfo->XGINew_CR97 = 0x10;
if (ChipType == XG27) {
unsigned char temp;
pVBInfo->MCLKData
= (struct SiS_MCLKData *) XGI27New_MCLKData;
pVBInfo->CR40 = XGI27_cr41;
- pVBInfo->pXGINew_CR97 = &XG27_CR97;
- pVBInfo->pSR36 = &XG27_SR36;
- pVBInfo->pCR8F = &XG27_CR8F;
- pVBInfo->pCRD0 = XG27_CRD0;
- pVBInfo->pCRDE = XG27_CRDE;
- pVBInfo->pSR40 = &XG27_SR40;
- pVBInfo->pSR41 = &XG27_SR41;
+ pVBInfo->XGINew_CR97 = 0xc1;
pVBInfo->SR15 = XG27_SR13;
/*Z11m DDR*/
temp = xgifb_reg_get(pVBInfo->P3c4, 0x3B);
/* SR3B[7][3]MAA15 MAA11 (Power on Trapping) */
if (((temp & 0x88) == 0x80) || ((temp & 0x88) == 0x08))
- pVBInfo->pXGINew_CR97 = &Z11m_CR97;
- }
-
- if (ChipType >= XG20) {
- pVBInfo->pDVOSetting = &XG21_DVOSetting;
- pVBInfo->pCR2E = &XG21_CR2E;
- pVBInfo->pCR2F = &XG21_CR2F;
- pVBInfo->pCR46 = &XG21_CR46;
- pVBInfo->pCR47 = &XG21_CR47;
+ pVBInfo->XGINew_CR97 = 0x80;
}
}
-static unsigned char XGI_GetModePtr(unsigned short ModeNo,
- unsigned short ModeIdIndex,
- struct vb_device_info *pVBInfo)
-{
- unsigned char index;
-
- if (ModeNo <= 0x13)
- index = pVBInfo->SModeIDTable[ModeIdIndex].St_StTableIndex;
- else {
- if (pVBInfo->ModeType <= 0x02)
- index = 0x1B; /* 02 -> ModeEGA */
- else
- index = 0x0F;
- }
- return index; /* Get pVBInfo->StandTable index */
-}
-
static void XGI_SetSeqRegs(unsigned short ModeNo,
- unsigned short StandTableIndex,
unsigned short ModeIdIndex,
struct vb_device_info *pVBInfo)
{
unsigned char tempah, SRdata;
unsigned short i, modeflag;
- if (ModeNo <= 0x13)
- modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
- else
- modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
+ modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
xgifb_reg_set(pVBInfo->P3c4, 0x00, 0x03); /* Set SR0 */
- tempah = pVBInfo->StandTable[StandTableIndex].SR[0];
+ tempah = pVBInfo->StandTable->SR[0];
i = XGI_SetCRT2ToLCDA;
if (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) {
@@ -230,13 +128,12 @@ static void XGI_SetSeqRegs(unsigned short ModeNo,
for (i = 02; i <= 04; i++) {
/* Get SR2,3,4 from file */
- SRdata = pVBInfo->StandTable[StandTableIndex].SR[i - 1];
+ SRdata = pVBInfo->StandTable->SR[i - 1];
xgifb_reg_set(pVBInfo->P3c4, i, SRdata); /* Set SR2 3 4 */
}
}
static void XGI_SetCRTCRegs(struct xgi_hw_device_info *HwDeviceExtension,
- unsigned short StandTableIndex,
struct vb_device_info *pVBInfo)
{
unsigned char CRTCdata;
@@ -248,38 +145,31 @@ static void XGI_SetCRTCRegs(struct xgi_hw_device_info *HwDeviceExtension,
for (i = 0; i <= 0x18; i++) {
/* Get CRTC from file */
- CRTCdata = pVBInfo->StandTable[StandTableIndex].CRTC[i];
+ CRTCdata = pVBInfo->StandTable->CRTC[i];
xgifb_reg_set(pVBInfo->P3d4, i, CRTCdata); /* Set CRTC(3d4) */
}
}
static void XGI_SetATTRegs(unsigned short ModeNo,
- unsigned short StandTableIndex,
unsigned short ModeIdIndex,
struct vb_device_info *pVBInfo)
{
unsigned char ARdata;
unsigned short i, modeflag;
- if (ModeNo <= 0x13)
- modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
- else
- modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
+ modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
for (i = 0; i <= 0x13; i++) {
- ARdata = pVBInfo->StandTable[StandTableIndex].ATTR[i];
- if (modeflag & Charx8Dot) { /* ifndef Dot9 */
- if (i == 0x13) {
- if (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) {
+ ARdata = pVBInfo->StandTable->ATTR[i];
+
+ if ((modeflag & Charx8Dot) && i == 0x13) { /* ifndef Dot9 */
+ if (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) {
+ ARdata = 0;
+ } else {
+ if ((pVBInfo->VBInfo &
+ (SetCRT2ToTV | SetCRT2ToLCD)) &&
+ (pVBInfo->VBInfo & SetInSlaveMode))
ARdata = 0;
- } else {
- if (pVBInfo->VBInfo & (SetCRT2ToTV
- | SetCRT2ToLCD)) {
- if (pVBInfo->VBInfo &
- SetInSlaveMode)
- ARdata = 0;
- }
- }
}
}
@@ -295,15 +185,14 @@ static void XGI_SetATTRegs(unsigned short ModeNo,
outb(0x20, pVBInfo->P3c0);
}
-static void XGI_SetGRCRegs(unsigned short StandTableIndex,
- struct vb_device_info *pVBInfo)
+static void XGI_SetGRCRegs(struct vb_device_info *pVBInfo)
{
unsigned char GRdata;
unsigned short i;
for (i = 0; i <= 0x08; i++) {
/* Get GR from file */
- GRdata = pVBInfo->StandTable[StandTableIndex].GRC[i];
+ GRdata = pVBInfo->StandTable->GRC[i];
xgifb_reg_set(pVBInfo->P3ce, i, GRdata); /* Set GR(3ce) */
}
@@ -344,12 +233,7 @@ static unsigned char XGI_AjustCRT2Rate(unsigned short ModeNo,
{
unsigned short tempax, tempbx, resinfo, modeflag, infoflag;
- if (ModeNo <= 0x13)
- /* si+St_ModeFlag */
- modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
- else
- modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
-
+ modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO;
tempbx = pVBInfo->RefIndex[RefreshRateTableIndex + (*i)].ModeID;
tempax = 0;
@@ -366,48 +250,30 @@ static unsigned char XGI_AjustCRT2Rate(unsigned short ModeNo,
if (pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)) {
tempax |= SupportLCD;
- if (pVBInfo->LCDResInfo != Panel_1280x1024) {
- if (pVBInfo->LCDResInfo != Panel_1280x960) {
- if (pVBInfo->LCDInfo &
- LCDNonExpanding) {
- if (resinfo >= 9) {
- tempax = 0;
- return 0;
- }
- }
- }
- }
+ if (pVBInfo->LCDResInfo != Panel_1280x1024 &&
+ pVBInfo->LCDResInfo != Panel_1280x960 &&
+ (pVBInfo->LCDInfo & LCDNonExpanding) &&
+ resinfo >= 9)
+ return 0;
}
if (pVBInfo->VBInfo & SetCRT2ToHiVision) { /* for HiTV */
if ((pVBInfo->VBType & VB_SIS301LV) &&
(pVBInfo->VBExtInfo == VB_YPbPr1080i)) {
tempax |= SupportYPbPr750p;
- if (pVBInfo->VBInfo & SetInSlaveMode) {
- if (resinfo == 4)
- return 0;
-
- if (resinfo == 3)
- return 0;
-
- if (resinfo > 7)
- return 0;
- }
+ if ((pVBInfo->VBInfo & SetInSlaveMode) &&
+ ((resinfo == 3) ||
+ (resinfo == 4) ||
+ (resinfo > 7)))
+ return 0;
} else {
tempax |= SupportHiVision;
- if (pVBInfo->VBInfo & SetInSlaveMode) {
- if (resinfo == 4)
+ if ((pVBInfo->VBInfo & SetInSlaveMode) &&
+ ((resinfo == 4) ||
+ (resinfo == 3 &&
+ (pVBInfo->SetFlag & TVSimuMode)) ||
+ (resinfo > 7)))
return 0;
-
- if (resinfo == 3) {
- if (pVBInfo->SetFlag
- & TVSimuMode)
- return 0;
- }
-
- if (resinfo > 7)
- return 0;
- }
}
} else {
if (pVBInfo->VBInfo & (SetCRT2ToAVIDEO |
@@ -417,23 +283,18 @@ static unsigned char XGI_AjustCRT2Rate(unsigned short ModeNo,
SetCRT2ToHiVision)) {
tempax |= SupportTV;
- if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B
- | VB_SIS301LV | VB_SIS302LV
- | VB_XGI301C)) {
+ if (pVBInfo->VBType & (VB_SIS301B |
+ VB_SIS302B |
+ VB_SIS301LV |
+ VB_SIS302LV |
+ VB_XGI301C))
tempax |= SupportTV1024;
- }
- if (!(pVBInfo->VBInfo & TVSetPAL)) {
- if (modeflag & NoSupportSimuTV) {
- if (pVBInfo->VBInfo &
- SetInSlaveMode) {
- if (!(pVBInfo->VBInfo &
- SetNotSimuMode)) {
- return 0;
- }
- }
- }
- }
+ if (!(pVBInfo->VBInfo & TVSetPAL) &&
+ (modeflag & NoSupportSimuTV) &&
+ (pVBInfo->VBInfo & SetInSlaveMode) &&
+ (!(pVBInfo->VBInfo & SetNotSimuMode)))
+ return 0;
}
}
} else { /* for LVDS */
@@ -584,11 +445,7 @@ static void XGI_SetCRT1Timing_V(unsigned short ModeIdIndex,
data &= 0x80;
data = data >> 2;
- if (ModeNo <= 0x13)
- i = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
- else
- i = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
-
+ i = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
i &= DoubleScanMode;
if (i)
data |= 0x80;
@@ -641,158 +498,97 @@ static void XGI_SetXG21CRTC(unsigned short ModeNo, unsigned short ModeIdIndex,
unsigned short RefreshRateTableIndex,
struct vb_device_info *pVBInfo)
{
- unsigned char StandTableIndex, index, Tempax, Tempbx, Tempcx, Tempdx;
+ unsigned char index, Tempax, Tempbx, Tempcx, Tempdx;
unsigned short Temp1, Temp2, Temp3;
- if (ModeNo <= 0x13) {
- StandTableIndex = XGI_GetModePtr(ModeNo, ModeIdIndex, pVBInfo);
- /* CR04 HRS */
- Tempax = pVBInfo->StandTable[StandTableIndex].CRTC[4];
- /* SR2E [7:0]->HRS */
- xgifb_reg_set(pVBInfo->P3c4, 0x2E, Tempax);
- /* Tempbx: CR05 HRE */
- Tempbx = pVBInfo->StandTable[StandTableIndex].CRTC[5];
- Tempbx &= 0x1F; /* Tempbx: HRE[4:0] */
- Tempcx = Tempax;
- Tempcx &= 0xE0; /* Tempcx: HRS[7:5] */
- Tempdx = Tempcx | Tempbx; /* Tempdx(HRE): HRS[7:5]HRE[4:0] */
- if (Tempbx < (Tempax & 0x1F)) /* IF HRE < HRS */
- Tempdx |= 0x20; /* Tempdx: HRE = HRE + 0x20 */
- Tempdx <<= 2; /* Tempdx << 2 */
- /* SR2F [7:2]->HRE */
- xgifb_reg_set(pVBInfo->P3c4, 0x2F, Tempdx);
- xgifb_reg_and_or(pVBInfo->P3c4, 0x30, 0xE3, 00);
-
- /* Tempax: CR16 VRS */
- Tempax = pVBInfo->StandTable[StandTableIndex].CRTC[16];
- Tempbx = Tempax; /* Tempbx=Tempax */
- Tempax &= 0x01; /* Tempax: VRS[0] */
- xgifb_reg_or(pVBInfo->P3c4, 0x33, Tempax); /* SR33[0]->VRS */
-
- /* Tempax: CR7 VRS */
- Tempax = pVBInfo->StandTable[StandTableIndex].CRTC[7];
- Tempdx = Tempbx >> 1; /* Tempdx: VRS[7:1] */
- Tempcx = Tempax & 0x04; /* Tempcx: CR7[2] */
- Tempcx <<= 5; /* Tempcx[7]: VRS[8] */
- Tempdx |= Tempcx; /* Tempdx: VRS[8:1] */
- /* SR34[7:0]: VRS[8:1] */
- xgifb_reg_set(pVBInfo->P3c4, 0x34, Tempdx);
-
- /* Temp1[8]: VRS[8] unsigned char -> unsigned short */
- Temp1 = Tempcx << 1;
- Temp1 |= Tempbx; /* Temp1[8:0]: VRS[8:0] */
- Tempax &= 0x80; /* Tempax[7]: CR7[7] */
- Temp2 = Tempax << 2; /* Temp2[9]: VRS[9] */
- Temp1 |= Temp2; /* Temp1[9:0]: VRS[9:0] */
-
- /* CR16 VRE */
- Tempax = pVBInfo->StandTable[StandTableIndex].CRTC[17];
- Tempax &= 0x0F; /* Tempax[3:0]: VRE[3:0] */
- Temp2 = Temp1 & 0x3F0; /* Temp2[9:4]: VRS[9:4] */
- Temp2 |= Tempax; /* Temp2[9:0]: VRE[9:0] */
- Temp3 = Temp1 & 0x0F; /* Temp3[3:0]: VRS[3:0] */
- if (Tempax < Temp3) /* VRE[3:0]<VRS[3:0] */
- Temp2 |= 0x10; /* Temp2: VRE + 0x10 */
- Temp2 &= 0xFF; /* Temp2[7:0]: VRE[7:0] */
- Tempax = (unsigned char) Temp2; /* Tempax[7:0]: VRE[7:0] */
- Tempax <<= 2; /* Tempax << 2: VRE[5:0] */
- Temp1 &= 0x600; /* Temp1[10:9]: VRS[10:9] */
- Temp1 >>= 9; /* [10:9]->[1:0] */
- Tempbx = (unsigned char) Temp1; /* Tempbx[1:0]: VRS[10:9] */
- Tempax |= Tempbx; /* VRE[5:0]VRS[10:9] */
- Tempax &= 0x7F;
- /* SR3F D[7:2]->VRE D[1:0]->VRS */
- xgifb_reg_set(pVBInfo->P3c4, 0x3F, Tempax);
- } else {
- index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC;
- /* Tempax: CR4 HRS */
- Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[3];
- Tempcx = Tempax; /* Tempcx: HRS */
- /* SR2E[7:0]->HRS */
- xgifb_reg_set(pVBInfo->P3c4, 0x2E, Tempax);
-
- Tempdx = pVBInfo->XGINEWUB_CRT1Table[index].CR[5]; /* SRB */
- Tempdx &= 0xC0; /* Tempdx[7:6]: SRB[7:6] */
- Temp1 = Tempdx; /* Temp1[7:6]: HRS[9:8] */
- Temp1 <<= 2; /* Temp1[9:8]: HRS[9:8] */
- Temp1 |= Tempax; /* Temp1[9:0]: HRS[9:0] */
-
- Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[4]; /* CR5 HRE */
- Tempax &= 0x1F; /* Tempax[4:0]: HRE[4:0] */
-
- Tempbx = pVBInfo->XGINEWUB_CRT1Table[index].CR[6]; /* SRC */
- Tempbx &= 0x04; /* Tempbx[2]: HRE[5] */
- Tempbx <<= 3; /* Tempbx[5]: HRE[5] */
- Tempax |= Tempbx; /* Tempax[5:0]: HRE[5:0] */
-
- Temp2 = Temp1 & 0x3C0; /* Temp2[9:6]: HRS[9:6] */
- Temp2 |= Tempax; /* Temp2[9:0]: HRE[9:0] */
-
- Tempcx &= 0x3F; /* Tempcx[5:0]: HRS[5:0] */
- if (Tempax < Tempcx) /* HRE < HRS */
- Temp2 |= 0x40; /* Temp2 + 0x40 */
-
- Temp2 &= 0xFF;
- Tempax = (unsigned char) Temp2; /* Tempax: HRE[7:0] */
- Tempax <<= 2; /* Tempax[7:2]: HRE[5:0] */
- Tempdx >>= 6; /* Tempdx[7:6]->[1:0] HRS[9:8] */
- Tempax |= Tempdx; /* HRE[5:0]HRS[9:8] */
- /* SR2F D[7:2]->HRE, D[1:0]->HRS */
- xgifb_reg_set(pVBInfo->P3c4, 0x2F, Tempax);
- xgifb_reg_and_or(pVBInfo->P3c4, 0x30, 0xE3, 00);
-
- /* CR10 VRS */
- Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[10];
- Tempbx = Tempax; /* Tempbx: VRS */
- Tempax &= 0x01; /* Tempax[0]: VRS[0] */
- xgifb_reg_or(pVBInfo->P3c4, 0x33, Tempax); /* SR33[0]->VRS[0] */
- /* CR7[2][7] VRE */
- Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[9];
- Tempcx = Tempbx >> 1; /* Tempcx[6:0]: VRS[7:1] */
- Tempdx = Tempax & 0x04; /* Tempdx[2]: CR7[2] */
- Tempdx <<= 5; /* Tempdx[7]: VRS[8] */
- Tempcx |= Tempdx; /* Tempcx[7:0]: VRS[8:1] */
- xgifb_reg_set(pVBInfo->P3c4, 0x34, Tempcx); /* SR34[8:1]->VRS */
-
- Temp1 = Tempdx; /* Temp1[7]: Tempdx[7] */
- Temp1 <<= 1; /* Temp1[8]: VRS[8] */
- Temp1 |= Tempbx; /* Temp1[8:0]: VRS[8:0] */
- Tempax &= 0x80;
- Temp2 = Tempax << 2; /* Temp2[9]: VRS[9] */
- Temp1 |= Temp2; /* Temp1[9:0]: VRS[9:0] */
- /* Tempax: SRA */
- Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[14];
- Tempax &= 0x08; /* Tempax[3]: VRS[3] */
- Temp2 = Tempax;
- Temp2 <<= 7; /* Temp2[10]: VRS[10] */
- Temp1 |= Temp2; /* Temp1[10:0]: VRS[10:0] */
-
- /* Tempax: CR11 VRE */
- Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[11];
- Tempax &= 0x0F; /* Tempax[3:0]: VRE[3:0] */
- /* Tempbx: SRA */
- Tempbx = pVBInfo->XGINEWUB_CRT1Table[index].CR[14];
- Tempbx &= 0x20; /* Tempbx[5]: VRE[5] */
- Tempbx >>= 1; /* Tempbx[4]: VRE[4] */
- Tempax |= Tempbx; /* Tempax[4:0]: VRE[4:0] */
- Temp2 = Temp1 & 0x7E0; /* Temp2[10:5]: VRS[10:5] */
- Temp2 |= Tempax; /* Temp2[10:5]: VRE[10:5] */
-
- Temp3 = Temp1 & 0x1F; /* Temp3[4:0]: VRS[4:0] */
- if (Tempax < Temp3) /* VRE < VRS */
- Temp2 |= 0x20; /* VRE + 0x20 */
-
- Temp2 &= 0xFF;
- Tempax = (unsigned char) Temp2; /* Tempax: VRE[7:0] */
- Tempax <<= 2; /* Tempax[7:0]; VRE[5:0]00 */
- Temp1 &= 0x600; /* Temp1[10:9]: VRS[10:9] */
- Temp1 >>= 9; /* Temp1[1:0]: VRS[10:9] */
- Tempbx = (unsigned char) Temp1;
- Tempax |= Tempbx; /* Tempax[7:0]: VRE[5:0]VRS[10:9] */
- Tempax &= 0x7F;
- /* SR3F D[7:2]->VRE D[1:0]->VRS */
- xgifb_reg_set(pVBInfo->P3c4, 0x3F, Tempax);
- }
+ index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC;
+ /* Tempax: CR4 HRS */
+ Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[3];
+ Tempcx = Tempax; /* Tempcx: HRS */
+ /* SR2E[7:0]->HRS */
+ xgifb_reg_set(pVBInfo->P3c4, 0x2E, Tempax);
+
+ Tempdx = pVBInfo->XGINEWUB_CRT1Table[index].CR[5]; /* SRB */
+ Tempdx &= 0xC0; /* Tempdx[7:6]: SRB[7:6] */
+ Temp1 = Tempdx; /* Temp1[7:6]: HRS[9:8] */
+ Temp1 <<= 2; /* Temp1[9:8]: HRS[9:8] */
+ Temp1 |= Tempax; /* Temp1[9:0]: HRS[9:0] */
+
+ Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[4]; /* CR5 HRE */
+ Tempax &= 0x1F; /* Tempax[4:0]: HRE[4:0] */
+
+ Tempbx = pVBInfo->XGINEWUB_CRT1Table[index].CR[6]; /* SRC */
+ Tempbx &= 0x04; /* Tempbx[2]: HRE[5] */
+ Tempbx <<= 3; /* Tempbx[5]: HRE[5] */
+ Tempax |= Tempbx; /* Tempax[5:0]: HRE[5:0] */
+
+ Temp2 = Temp1 & 0x3C0; /* Temp2[9:6]: HRS[9:6] */
+ Temp2 |= Tempax; /* Temp2[9:0]: HRE[9:0] */
+
+ Tempcx &= 0x3F; /* Tempcx[5:0]: HRS[5:0] */
+ if (Tempax < Tempcx) /* HRE < HRS */
+ Temp2 |= 0x40; /* Temp2 + 0x40 */
+
+ Temp2 &= 0xFF;
+ Tempax = (unsigned char) Temp2; /* Tempax: HRE[7:0] */
+ Tempax <<= 2; /* Tempax[7:2]: HRE[5:0] */
+ Tempdx >>= 6; /* Tempdx[7:6]->[1:0] HRS[9:8] */
+ Tempax |= Tempdx; /* HRE[5:0]HRS[9:8] */
+ /* SR2F D[7:2]->HRE, D[1:0]->HRS */
+ xgifb_reg_set(pVBInfo->P3c4, 0x2F, Tempax);
+ xgifb_reg_and_or(pVBInfo->P3c4, 0x30, 0xE3, 00);
+
+ /* CR10 VRS */
+ Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[10];
+ Tempbx = Tempax; /* Tempbx: VRS */
+ Tempax &= 0x01; /* Tempax[0]: VRS[0] */
+ xgifb_reg_or(pVBInfo->P3c4, 0x33, Tempax); /* SR33[0]->VRS[0] */
+ /* CR7[2][7] VRE */
+ Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[9];
+ Tempcx = Tempbx >> 1; /* Tempcx[6:0]: VRS[7:1] */
+ Tempdx = Tempax & 0x04; /* Tempdx[2]: CR7[2] */
+ Tempdx <<= 5; /* Tempdx[7]: VRS[8] */
+ Tempcx |= Tempdx; /* Tempcx[7:0]: VRS[8:1] */
+ xgifb_reg_set(pVBInfo->P3c4, 0x34, Tempcx); /* SR34[8:1]->VRS */
+
+ Temp1 = Tempdx; /* Temp1[7]: Tempdx[7] */
+ Temp1 <<= 1; /* Temp1[8]: VRS[8] */
+ Temp1 |= Tempbx; /* Temp1[8:0]: VRS[8:0] */
+ Tempax &= 0x80;
+ Temp2 = Tempax << 2; /* Temp2[9]: VRS[9] */
+ Temp1 |= Temp2; /* Temp1[9:0]: VRS[9:0] */
+ /* Tempax: SRA */
+ Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[14];
+ Tempax &= 0x08; /* Tempax[3]: VRS[3] */
+ Temp2 = Tempax;
+ Temp2 <<= 7; /* Temp2[10]: VRS[10] */
+ Temp1 |= Temp2; /* Temp1[10:0]: VRS[10:0] */
+
+ /* Tempax: CR11 VRE */
+ Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[11];
+ Tempax &= 0x0F; /* Tempax[3:0]: VRE[3:0] */
+ /* Tempbx: SRA */
+ Tempbx = pVBInfo->XGINEWUB_CRT1Table[index].CR[14];
+ Tempbx &= 0x20; /* Tempbx[5]: VRE[5] */
+ Tempbx >>= 1; /* Tempbx[4]: VRE[4] */
+ Tempax |= Tempbx; /* Tempax[4:0]: VRE[4:0] */
+ Temp2 = Temp1 & 0x7E0; /* Temp2[10:5]: VRS[10:5] */
+ Temp2 |= Tempax; /* Temp2[10:5]: VRE[10:5] */
+
+ Temp3 = Temp1 & 0x1F; /* Temp3[4:0]: VRS[4:0] */
+ if (Tempax < Temp3) /* VRE < VRS */
+ Temp2 |= 0x20; /* VRE + 0x20 */
+
+ Temp2 &= 0xFF;
+ Tempax = (unsigned char) Temp2; /* Tempax: VRE[7:0] */
+ Tempax <<= 2; /* Tempax[7:0]; VRE[5:0]00 */
+ Temp1 &= 0x600; /* Temp1[10:9]: VRS[10:9] */
+ Temp1 >>= 9; /* Temp1[1:0]: VRS[10:9] */
+ Tempbx = (unsigned char) Temp1;
+ Tempax |= Tempbx; /* Tempax[7:0]: VRE[5:0]VRS[10:9] */
+ Tempax &= 0x7F;
+ /* SR3F D[7:2]->VRE D[1:0]->VRS */
+ xgifb_reg_set(pVBInfo->P3c4, 0x3F, Tempax);
}
static void XGI_SetXG27CRTC(unsigned short ModeNo,
@@ -800,139 +596,88 @@ static void XGI_SetXG27CRTC(unsigned short ModeNo,
unsigned short RefreshRateTableIndex,
struct vb_device_info *pVBInfo)
{
- unsigned short StandTableIndex, index, Tempax, Tempbx, Tempcx, Tempdx;
-
- if (ModeNo <= 0x13) {
- StandTableIndex = XGI_GetModePtr(ModeNo, ModeIdIndex, pVBInfo);
- /* CR04 HRS */
- Tempax = pVBInfo->StandTable[StandTableIndex].CRTC[4];
- /* SR2E [7:0]->HRS */
- xgifb_reg_set(pVBInfo->P3c4, 0x2E, Tempax);
- /* Tempbx: CR05 HRE */
- Tempbx = pVBInfo->StandTable[StandTableIndex].CRTC[5];
- Tempbx &= 0x1F; /* Tempbx: HRE[4:0] */
- Tempcx = Tempax;
- Tempcx &= 0xE0; /* Tempcx: HRS[7:5] */
- Tempdx = Tempcx | Tempbx; /* Tempdx(HRE): HRS[7:5]HRE[4:0] */
- if (Tempbx < (Tempax & 0x1F)) /* IF HRE < HRS */
- Tempdx |= 0x20; /* Tempdx: HRE = HRE + 0x20 */
- Tempdx <<= 2; /* Tempdx << 2 */
- /* SR2F [7:2]->HRE */
- xgifb_reg_set(pVBInfo->P3c4, 0x2F, Tempdx);
- xgifb_reg_and_or(pVBInfo->P3c4, 0x30, 0xE3, 00);
-
- /* Tempax: CR10 VRS */
- Tempax = pVBInfo->StandTable[StandTableIndex].CRTC[16];
- xgifb_reg_set(pVBInfo->P3c4, 0x34, Tempax); /* SR34[7:0]->VRS */
- Tempcx = Tempax; /* Tempcx=Tempax=VRS[7:0] */
- /* Tempax[7][2]: CR7[7][2] VRS[9][8] */
- Tempax = pVBInfo->StandTable[StandTableIndex].CRTC[7];
- Tempbx = Tempax; /* Tempbx=CR07 */
- Tempax &= 0x04; /* Tempax[2]: CR07[2] VRS[8] */
- Tempax >>= 2;
- /* SR35 D[0]->VRS D[8] */
- xgifb_reg_and_or(pVBInfo->P3c4, 0x35, ~0x01, Tempax);
- Tempcx |= (Tempax << 8); /* Tempcx[8] |= VRS[8] */
- Tempcx |= (Tempbx & 0x80) << 2; /* Tempcx[9] |= VRS[9] */
-
- /* CR11 VRE */
- Tempax = pVBInfo->StandTable[StandTableIndex].CRTC[17];
- Tempax &= 0x0F; /* Tempax: VRE[3:0] */
- Tempbx = Tempcx; /* Tempbx=Tempcx=VRS[9:0] */
- Tempbx &= 0x3F0; /* Tempbx[9:4]: VRS[9:4] */
- Tempbx |= Tempax; /* Tempbx[9:0]: VRE[9:0] */
- if (Tempax <= (Tempcx & 0x0F)) /* VRE[3:0]<=VRS[3:0] */
- Tempbx |= 0x10; /* Tempbx: VRE + 0x10 */
- /* Tempax[7:0]: VRE[7:0] */
- Tempax = (unsigned char) Tempbx & 0xFF;
- Tempax <<= 2; /* Tempax << 2: VRE[5:0] */
- Tempcx = (Tempcx & 0x600) >> 8; /* Tempcx VRS[10:9] */
- /* SR3F D[7:2]->VRE D[5:0] */
- xgifb_reg_and_or(pVBInfo->P3c4, 0x3F, ~0xFC, Tempax);
- /* SR35 D[2:1]->VRS[10:9] */
- xgifb_reg_and_or(pVBInfo->P3c4, 0x35, ~0x06, Tempcx);
- } else {
- index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC;
- /* Tempax: CR4 HRS */
- Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[3];
- Tempbx = Tempax; /* Tempbx: HRS[7:0] */
- /* SR2E[7:0]->HRS */
- xgifb_reg_set(pVBInfo->P3c4, 0x2E, Tempax);
-
- /* SR0B */
- Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[5];
- Tempax &= 0xC0; /* Tempax[7:6]: SR0B[7:6]: HRS[9:8]*/
- Tempbx |= (Tempax << 2); /* Tempbx: HRS[9:0] */
-
- Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[4]; /* CR5 HRE */
- Tempax &= 0x1F; /* Tempax[4:0]: HRE[4:0] */
- Tempcx = Tempax; /* Tempcx: HRE[4:0] */
-
- Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[6]; /* SRC */
- Tempax &= 0x04; /* Tempax[2]: HRE[5] */
- Tempax <<= 3; /* Tempax[5]: HRE[5] */
- Tempcx |= Tempax; /* Tempcx[5:0]: HRE[5:0] */
-
- Tempbx = Tempbx & 0x3C0; /* Tempbx[9:6]: HRS[9:6] */
- Tempbx |= Tempcx; /* Tempbx: HRS[9:6]HRE[5:0] */
-
- /* Tempax: CR4 HRS */
- Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[3];
- Tempax &= 0x3F; /* Tempax: HRS[5:0] */
- if (Tempcx <= Tempax) /* HRE[5:0] < HRS[5:0] */
- Tempbx += 0x40; /* Tempbx= Tempbx + 0x40 : HRE[9:0]*/
-
- Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[5]; /* SR0B */
- Tempax &= 0xC0; /* Tempax[7:6]: SR0B[7:6]: HRS[9:8]*/
- Tempax >>= 6; /* Tempax[1:0]: HRS[9:8]*/
- Tempax |= ((Tempbx << 2) & 0xFF); /* Tempax[7:2]: HRE[5:0] */
- /* SR2F [7:2][1:0]: HRE[5:0]HRS[9:8] */
- xgifb_reg_set(pVBInfo->P3c4, 0x2F, Tempax);
- xgifb_reg_and_or(pVBInfo->P3c4, 0x30, 0xE3, 00);
-
- /* CR10 VRS */
- Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[10];
- /* SR34[7:0]->VRS[7:0] */
- xgifb_reg_set(pVBInfo->P3c4, 0x34, Tempax);
-
- Tempcx = Tempax; /* Tempcx <= VRS[7:0] */
- /* CR7[7][2] VRS[9][8] */
- Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[9];
- Tempbx = Tempax; /* Tempbx <= CR07[7:0] */
- Tempax = Tempax & 0x04; /* Tempax[2]: CR7[2]: VRS[8] */
- Tempax >>= 2; /* Tempax[0]: VRS[8] */
- /* SR35[0]: VRS[8] */
- xgifb_reg_and_or(pVBInfo->P3c4, 0x35, ~0x01, Tempax);
- Tempcx |= (Tempax << 8); /* Tempcx <= VRS[8:0] */
- Tempcx |= ((Tempbx & 0x80) << 2); /* Tempcx <= VRS[9:0] */
- /* Tempax: SR0A */
- Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[14];
- Tempax &= 0x08; /* SR0A[3] VRS[10] */
- Tempcx |= (Tempax << 7); /* Tempcx <= VRS[10:0] */
-
- /* Tempax: CR11 VRE */
- Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[11];
- Tempax &= 0x0F; /* Tempax[3:0]: VRE[3:0] */
- /* Tempbx: SR0A */
- Tempbx = pVBInfo->XGINEWUB_CRT1Table[index].CR[14];
- Tempbx &= 0x20; /* Tempbx[5]: SR0A[5]: VRE[4] */
- Tempbx >>= 1; /* Tempbx[4]: VRE[4] */
- Tempax |= Tempbx; /* Tempax[4:0]: VRE[4:0] */
- Tempbx = Tempcx; /* Tempbx: VRS[10:0] */
- Tempbx &= 0x7E0; /* Tempbx[10:5]: VRS[10:5] */
- Tempbx |= Tempax; /* Tempbx: VRS[10:5]VRE[4:0] */
-
- if (Tempbx <= Tempcx) /* VRE <= VRS */
- Tempbx |= 0x20; /* VRE + 0x20 */
-
- /* Tempax: Tempax[7:0]; VRE[5:0]00 */
- Tempax = (Tempbx << 2) & 0xFF;
- /* SR3F[7:2]:VRE[5:0] */
- xgifb_reg_and_or(pVBInfo->P3c4, 0x3F, ~0xFC, Tempax);
- Tempax = Tempcx >> 8;
- /* SR35[2:0]:VRS[10:8] */
- xgifb_reg_and_or(pVBInfo->P3c4, 0x35, ~0x07, Tempax);
- }
+ unsigned short index, Tempax, Tempbx, Tempcx;
+
+ index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC;
+ /* Tempax: CR4 HRS */
+ Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[3];
+ Tempbx = Tempax; /* Tempbx: HRS[7:0] */
+ /* SR2E[7:0]->HRS */
+ xgifb_reg_set(pVBInfo->P3c4, 0x2E, Tempax);
+
+ /* SR0B */
+ Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[5];
+ Tempax &= 0xC0; /* Tempax[7:6]: SR0B[7:6]: HRS[9:8]*/
+ Tempbx |= (Tempax << 2); /* Tempbx: HRS[9:0] */
+
+ Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[4]; /* CR5 HRE */
+ Tempax &= 0x1F; /* Tempax[4:0]: HRE[4:0] */
+ Tempcx = Tempax; /* Tempcx: HRE[4:0] */
+
+ Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[6]; /* SRC */
+ Tempax &= 0x04; /* Tempax[2]: HRE[5] */
+ Tempax <<= 3; /* Tempax[5]: HRE[5] */
+ Tempcx |= Tempax; /* Tempcx[5:0]: HRE[5:0] */
+
+ Tempbx = Tempbx & 0x3C0; /* Tempbx[9:6]: HRS[9:6] */
+ Tempbx |= Tempcx; /* Tempbx: HRS[9:6]HRE[5:0] */
+
+ /* Tempax: CR4 HRS */
+ Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[3];
+ Tempax &= 0x3F; /* Tempax: HRS[5:0] */
+ if (Tempcx <= Tempax) /* HRE[5:0] < HRS[5:0] */
+ Tempbx += 0x40; /* Tempbx= Tempbx + 0x40 : HRE[9:0]*/
+
+ Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[5]; /* SR0B */
+ Tempax &= 0xC0; /* Tempax[7:6]: SR0B[7:6]: HRS[9:8]*/
+ Tempax >>= 6; /* Tempax[1:0]: HRS[9:8]*/
+ Tempax |= ((Tempbx << 2) & 0xFF); /* Tempax[7:2]: HRE[5:0] */
+ /* SR2F [7:2][1:0]: HRE[5:0]HRS[9:8] */
+ xgifb_reg_set(pVBInfo->P3c4, 0x2F, Tempax);
+ xgifb_reg_and_or(pVBInfo->P3c4, 0x30, 0xE3, 00);
+
+ /* CR10 VRS */
+ Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[10];
+ /* SR34[7:0]->VRS[7:0] */
+ xgifb_reg_set(pVBInfo->P3c4, 0x34, Tempax);
+
+ Tempcx = Tempax; /* Tempcx <= VRS[7:0] */
+ /* CR7[7][2] VRS[9][8] */
+ Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[9];
+ Tempbx = Tempax; /* Tempbx <= CR07[7:0] */
+ Tempax = Tempax & 0x04; /* Tempax[2]: CR7[2]: VRS[8] */
+ Tempax >>= 2; /* Tempax[0]: VRS[8] */
+ /* SR35[0]: VRS[8] */
+ xgifb_reg_and_or(pVBInfo->P3c4, 0x35, ~0x01, Tempax);
+ Tempcx |= (Tempax << 8); /* Tempcx <= VRS[8:0] */
+ Tempcx |= ((Tempbx & 0x80) << 2); /* Tempcx <= VRS[9:0] */
+ /* Tempax: SR0A */
+ Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[14];
+ Tempax &= 0x08; /* SR0A[3] VRS[10] */
+ Tempcx |= (Tempax << 7); /* Tempcx <= VRS[10:0] */
+
+ /* Tempax: CR11 VRE */
+ Tempax = pVBInfo->XGINEWUB_CRT1Table[index].CR[11];
+ Tempax &= 0x0F; /* Tempax[3:0]: VRE[3:0] */
+ /* Tempbx: SR0A */
+ Tempbx = pVBInfo->XGINEWUB_CRT1Table[index].CR[14];
+ Tempbx &= 0x20; /* Tempbx[5]: SR0A[5]: VRE[4] */
+ Tempbx >>= 1; /* Tempbx[4]: VRE[4] */
+ Tempax |= Tempbx; /* Tempax[4:0]: VRE[4:0] */
+ Tempbx = Tempcx; /* Tempbx: VRS[10:0] */
+ Tempbx &= 0x7E0; /* Tempbx[10:5]: VRS[10:5] */
+ Tempbx |= Tempax; /* Tempbx: VRS[10:5]VRE[4:0] */
+
+ if (Tempbx <= Tempcx) /* VRE <= VRS */
+ Tempbx |= 0x20; /* VRE + 0x20 */
+
+ /* Tempax: Tempax[7:0]; VRE[5:0]00 */
+ Tempax = (Tempbx << 2) & 0xFF;
+ /* SR3F[7:2]:VRE[5:0] */
+ xgifb_reg_and_or(pVBInfo->P3c4, 0x3F, ~0xFC, Tempax);
+ Tempax = Tempcx >> 8;
+ /* SR35[2:0]:VRS[10:8] */
+ xgifb_reg_and_or(pVBInfo->P3c4, 0x35, ~0x07, Tempax);
}
static void XGI_SetXG27FPBits(struct vb_device_info *pVBInfo)
@@ -954,7 +699,7 @@ static void xgifb_set_lcd(int chip_id,
unsigned short RefreshRateTableIndex,
unsigned short ModeNo)
{
- unsigned short Data, Temp, b3CC;
+ unsigned short Data, Temp;
unsigned short XGI_P3cc;
XGI_P3cc = pVBInfo->P3cc;
@@ -972,13 +717,6 @@ static void xgifb_set_lcd(int chip_id,
}
}
- if (((*pVBInfo->pDVOSetting) & 0xC0) == 0xC0) {
- xgifb_reg_set(pVBInfo->P3d4, 0x2E, *pVBInfo->pCR2E);
- xgifb_reg_set(pVBInfo->P3d4, 0x2F, *pVBInfo->pCR2F);
- xgifb_reg_set(pVBInfo->P3d4, 0x46, *pVBInfo->pCR46);
- xgifb_reg_set(pVBInfo->P3d4, 0x47, *pVBInfo->pCR47);
- }
-
if (chip_id == XG27) {
XGI_SetXG27FPBits(pVBInfo);
} else {
@@ -995,23 +733,13 @@ static void xgifb_set_lcd(int chip_id,
xgifb_reg_and(pVBInfo->P3c4, 0x30, ~0x20); /* Hsync polarity */
xgifb_reg_and(pVBInfo->P3c4, 0x35, ~0x80); /* Vsync polarity */
- if (ModeNo <= 0x13) {
- b3CC = (unsigned char) inb(XGI_P3cc);
- if (b3CC & 0x40)
- /* Hsync polarity */
- xgifb_reg_or(pVBInfo->P3c4, 0x30, 0x20);
- if (b3CC & 0x80)
- /* Vsync polarity */
- xgifb_reg_or(pVBInfo->P3c4, 0x35, 0x80);
- } else {
- Data = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_InfoFlag;
- if (Data & 0x4000)
- /* Hsync polarity */
- xgifb_reg_or(pVBInfo->P3c4, 0x30, 0x20);
- if (Data & 0x8000)
- /* Vsync polarity */
- xgifb_reg_or(pVBInfo->P3c4, 0x35, 0x80);
- }
+ Data = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_InfoFlag;
+ if (Data & 0x4000)
+ /* Hsync polarity */
+ xgifb_reg_or(pVBInfo->P3c4, 0x30, 0x20);
+ if (Data & 0x8000)
+ /* Vsync polarity */
+ xgifb_reg_or(pVBInfo->P3c4, 0x35, 0x80);
}
/* --------------------------------------------------------------------- */
@@ -1024,30 +752,22 @@ static void XGI_UpdateXG21CRTC(unsigned short ModeNo,
struct vb_device_info *pVBInfo,
unsigned short RefreshRateTableIndex)
{
- int i, index = -1;
+ int index = -1;
xgifb_reg_and(pVBInfo->P3d4, 0x11, 0x7F); /* Unlock CR0~7 */
- if (ModeNo <= 0x13) {
- for (i = 0; i < 12; i++) {
- if (ModeNo == pVBInfo->UpdateCRT1[i].ModeID)
- index = i;
- }
- } else {
- if (ModeNo == 0x2E &&
- (pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC ==
- RES640x480x60))
- index = 12;
- else if (ModeNo == 0x2E &&
- (pVBInfo->RefIndex[RefreshRateTableIndex].
+ if (ModeNo == 0x2E &&
+ (pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC ==
+ RES640x480x60))
+ index = 12;
+ else if (ModeNo == 0x2E && (pVBInfo->RefIndex[RefreshRateTableIndex].
Ext_CRT1CRTC == RES640x480x72))
- index = 13;
- else if (ModeNo == 0x2F)
- index = 14;
- else if (ModeNo == 0x50)
- index = 15;
- else if (ModeNo == 0x59)
- index = 16;
- }
+ index = 13;
+ else if (ModeNo == 0x2F)
+ index = 14;
+ else if (ModeNo == 0x50)
+ index = 15;
+ else if (ModeNo == 0x59)
+ index = 16;
if (index != -1) {
xgifb_reg_set(pVBInfo->P3d4, 0x02,
@@ -1061,20 +781,6 @@ static void XGI_UpdateXG21CRTC(unsigned short ModeNo,
}
}
-static unsigned short XGI_GetResInfo(unsigned short ModeNo,
- unsigned short ModeIdIndex, struct vb_device_info *pVBInfo)
-{
- unsigned short resindex;
-
- if (ModeNo <= 0x13)
- /* si+St_ResInfo */
- resindex = pVBInfo->SModeIDTable[ModeIdIndex].St_ResInfo;
- else
- /* si+Ext_ResInfo */
- resindex = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO;
- return resindex;
-}
-
static void XGI_SetCRT1DE(struct xgi_hw_device_info *HwDeviceExtension,
unsigned short ModeNo, unsigned short ModeIdIndex,
unsigned short RefreshRateTableIndex,
@@ -1084,33 +790,25 @@ static void XGI_SetCRT1DE(struct xgi_hw_device_info *HwDeviceExtension,
unsigned char data;
- resindex = XGI_GetResInfo(ModeNo, ModeIdIndex, pVBInfo);
+ resindex = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO;
- if (ModeNo <= 0x13) {
- modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
- tempax = pVBInfo->StResInfo[resindex].HTotal;
- tempbx = pVBInfo->StResInfo[resindex].VTotal;
- } else {
- modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
- tempax = pVBInfo->ModeResInfo[resindex].HTotal;
- tempbx = pVBInfo->ModeResInfo[resindex].VTotal;
- }
+ modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
+ tempax = pVBInfo->ModeResInfo[resindex].HTotal;
+ tempbx = pVBInfo->ModeResInfo[resindex].VTotal;
if (modeflag & HalfDCLK)
tempax = tempax >> 1;
- if (ModeNo > 0x13) {
- if (modeflag & HalfDCLK)
- tempax = tempax << 1;
+ if (modeflag & HalfDCLK)
+ tempax = tempax << 1;
- temp = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_InfoFlag;
+ temp = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_InfoFlag;
- if (temp & InterlaceMode)
- tempbx = tempbx >> 1;
+ if (temp & InterlaceMode)
+ tempbx = tempbx >> 1;
- if (modeflag & DoubleScanMode)
- tempbx = tempbx << 1;
- }
+ if (modeflag & DoubleScanMode)
+ tempbx = tempbx << 1;
tempcx = 8;
@@ -1237,63 +935,36 @@ static unsigned short XGI_GetVCLK2Ptr(unsigned short ModeNo,
struct xgi_hw_device_info *HwDeviceExtension,
struct vb_device_info *pVBInfo)
{
- unsigned short LCDXlat1VCLK[4] = { VCLK65_315 + 2,
- VCLK65_315 + 2,
- VCLK65_315 + 2,
- VCLK65_315 + 2 };
- unsigned short LCDXlat2VCLK[4] = { VCLK108_2_315 + 5,
- VCLK108_2_315 + 5,
- VCLK108_2_315 + 5,
- VCLK108_2_315 + 5 };
- unsigned short LVDSXlat1VCLK[4] = { VCLK40, VCLK40, VCLK40, VCLK40 };
- unsigned short LVDSXlat2VCLK[4] = { VCLK65_315 + 2,
- VCLK65_315 + 2,
- VCLK65_315 + 2,
- VCLK65_315 + 2 };
- unsigned short LVDSXlat3VCLK[4] = { VCLK65_315 + 2,
- VCLK65_315 + 2,
- VCLK65_315 + 2,
- VCLK65_315 + 2 };
-
unsigned short CRT2Index, VCLKIndex;
unsigned short modeflag, resinfo;
- if (ModeNo <= 0x13) {
- /* si+St_ResInfo */
- modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
- resinfo = pVBInfo->SModeIDTable[ModeIdIndex].St_ResInfo;
- CRT2Index = pVBInfo->SModeIDTable[ModeIdIndex].St_CRT2CRTC;
- } else {
- /* si+Ext_ResInfo */
- modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
- resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO;
- CRT2Index = pVBInfo->RefIndex[RefreshRateTableIndex].
- Ext_CRT2CRTC;
- }
+ /* si+Ext_ResInfo */
+ modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
+ resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO;
+ CRT2Index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC;
if (pVBInfo->IF_DEF_LVDS == 0) {
CRT2Index = CRT2Index >> 6; /* for LCD */
- if (pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)) { /*301b*/
+ if (pVBInfo->VBInfo &
+ (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)) { /*301b*/
if (pVBInfo->LCDResInfo != Panel_1024x768)
- VCLKIndex = LCDXlat2VCLK[CRT2Index];
+ /* LCDXlat2VCLK */
+ VCLKIndex = VCLK108_2_315 + 5;
else
- VCLKIndex = LCDXlat1VCLK[CRT2Index];
+ VCLKIndex = VCLK65_315 + 2; /* LCDXlat1VCLK */
} else if (pVBInfo->VBInfo & SetCRT2ToHiVision) {
- if (pVBInfo->SetFlag & RPLLDIV2XO) {
- VCLKIndex = TVCLKBASE_315 + HiTVVCLKDIV2;
- VCLKIndex += 25;
- } else {
- VCLKIndex = TVCLKBASE_315 + HiTVVCLK;
- VCLKIndex += 25;
- }
+ if (pVBInfo->SetFlag & RPLLDIV2XO)
+ VCLKIndex = TVCLKBASE_315_25 + HiTVVCLKDIV2;
+ else
+ VCLKIndex = TVCLKBASE_315_25 + HiTVVCLK;
if (pVBInfo->SetFlag & TVSimuMode) {
if (modeflag & Charx8Dot) {
- VCLKIndex = TVCLKBASE_315 + HiTVSimuVCLK;
- VCLKIndex += 25;
+ VCLKIndex = TVCLKBASE_315_25 +
+ HiTVSimuVCLK;
} else {
- VCLKIndex = TVCLKBASE_315 + HiTVTextVCLK;
- VCLKIndex += 25;
+ VCLKIndex = TVCLKBASE_315_25 +
+ HiTVTextVCLK;
}
}
@@ -1310,40 +981,23 @@ static unsigned short XGI_GetVCLK2Ptr(unsigned short ModeNo,
VCLKIndex = YPbPr525iVCLK;
}
} else if (pVBInfo->VBInfo & SetCRT2ToTV) {
- if (pVBInfo->SetFlag & RPLLDIV2XO) {
- VCLKIndex = TVCLKBASE_315 + TVVCLKDIV2;
- VCLKIndex += 25;
- } else {
- VCLKIndex = TVCLKBASE_315 + TVVCLK;
- VCLKIndex += 25;
- }
+ if (pVBInfo->SetFlag & RPLLDIV2XO)
+ VCLKIndex = TVCLKBASE_315_25 + TVVCLKDIV2;
+ else
+ VCLKIndex = TVCLKBASE_315_25 + TVVCLK;
} else { /* for CRT2 */
- /* Port 3cch */
- VCLKIndex = (unsigned char) inb((pVBInfo->P3ca + 0x02));
- VCLKIndex = ((VCLKIndex >> 2) & 0x03);
- if (ModeNo > 0x13) {
- /* di+Ext_CRTVCLK */
- VCLKIndex = pVBInfo->RefIndex[
- RefreshRateTableIndex].
+ /* di+Ext_CRTVCLK */
+ VCLKIndex = pVBInfo->RefIndex[RefreshRateTableIndex].
Ext_CRTVCLK;
- VCLKIndex &= IndexMask;
- }
+ VCLKIndex &= IndexMask;
}
} else { /* LVDS */
- if (ModeNo <= 0x13)
- VCLKIndex = CRT2Index;
- else
- VCLKIndex = CRT2Index;
-
- VCLKIndex = VCLKIndex >> 6;
if ((pVBInfo->LCDResInfo == Panel_800x600) ||
(pVBInfo->LCDResInfo == Panel_320x480))
- VCLKIndex = LVDSXlat1VCLK[VCLKIndex];
- else if ((pVBInfo->LCDResInfo == Panel_1024x768) ||
- (pVBInfo->LCDResInfo == Panel_1024x768x75))
- VCLKIndex = LVDSXlat2VCLK[VCLKIndex];
+ VCLKIndex = VCLK40; /* LVDSXlat1VCLK */
else
- VCLKIndex = LVDSXlat3VCLK[VCLKIndex];
+ VCLKIndex = VCLK65_315 + 2; /* LVDSXlat2VCLK,
+ LVDSXlat3VCLK */
}
return VCLKIndex;
@@ -1431,27 +1085,13 @@ static void XGI_SetCRT1FIFO(unsigned short ModeNo,
data &= 0xfe;
xgifb_reg_set(pVBInfo->P3c4, 0x3D, data); /* diable auto-threshold */
- if (ModeNo > 0x13) {
- xgifb_reg_set(pVBInfo->P3c4, 0x08, 0x34);
- data = xgifb_reg_get(pVBInfo->P3c4, 0x09);
- data &= 0xC0;
- xgifb_reg_set(pVBInfo->P3c4, 0x09, data | 0x30);
- data = xgifb_reg_get(pVBInfo->P3c4, 0x3D);
- data |= 0x01;
- xgifb_reg_set(pVBInfo->P3c4, 0x3D, data);
- } else {
- if (HwDeviceExtension->jChipType == XG27) {
- xgifb_reg_set(pVBInfo->P3c4, 0x08, 0x0E);
- data = xgifb_reg_get(pVBInfo->P3c4, 0x09);
- data &= 0xC0;
- xgifb_reg_set(pVBInfo->P3c4, 0x09, data | 0x20);
- } else {
- xgifb_reg_set(pVBInfo->P3c4, 0x08, 0xAE);
- data = xgifb_reg_get(pVBInfo->P3c4, 0x09);
- data &= 0xF0;
- xgifb_reg_set(pVBInfo->P3c4, 0x09, data);
- }
- }
+ xgifb_reg_set(pVBInfo->P3c4, 0x08, 0x34);
+ data = xgifb_reg_get(pVBInfo->P3c4, 0x09);
+ data &= 0xC0;
+ xgifb_reg_set(pVBInfo->P3c4, 0x09, data | 0x30);
+ data = xgifb_reg_get(pVBInfo->P3c4, 0x3D);
+ data |= 0x01;
+ xgifb_reg_set(pVBInfo->P3c4, 0x3D, data);
if (HwDeviceExtension->jChipType == XG21)
XGI_SetXG21FPBits(pVBInfo); /* Fix SR9[7:6] can't read back */
@@ -1466,13 +1106,9 @@ static void XGI_SetVCLKState(struct xgi_hw_device_info *HwDeviceExtension,
unsigned char index;
- if (ModeNo <= 0x13)
- VCLK = 0;
- else {
- index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRTVCLK;
- index &= IndexMask;
- VCLK = pVBInfo->VCLKData[index].CLOCK;
- }
+ index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRTVCLK;
+ index &= IndexMask;
+ VCLK = pVBInfo->VCLKData[index].CLOCK;
data = xgifb_reg_get(pVBInfo->P3c4, 0x32);
data &= 0xf3;
@@ -1508,44 +1144,26 @@ static void XGI_SetCRT1ModeRegs(struct xgi_hw_device_info *HwDeviceExtension,
unsigned short data, data2, data3, infoflag = 0, modeflag, resindex,
xres;
- if (ModeNo > 0x13) {
- modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
- infoflag = pVBInfo->RefIndex[RefreshRateTableIndex].
- Ext_InfoFlag;
- } else
- /* si+St_ModeFlag */
- modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
+ modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
+ infoflag = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_InfoFlag;
if (xgifb_reg_get(pVBInfo->P3d4, 0x31) & 0x01)
xgifb_reg_and_or(pVBInfo->P3c4, 0x1F, 0x3F, 0x00);
- if (ModeNo > 0x13)
- data = infoflag;
- else
- data = 0;
-
+ data = infoflag;
data2 = 0;
-
- if (ModeNo > 0x13) {
- if (pVBInfo->ModeType > 0x02) {
- data2 |= 0x02;
- data3 = pVBInfo->ModeType - ModeVGA;
- data3 = data3 << 2;
- data2 |= data3;
- }
- }
-
+ data2 |= 0x02;
+ data3 = pVBInfo->ModeType - ModeVGA;
+ data3 = data3 << 2;
+ data2 |= data3;
data &= InterlaceMode;
if (data)
data2 |= 0x20;
xgifb_reg_and_or(pVBInfo->P3c4, 0x06, ~0x3F, data2);
- resindex = XGI_GetResInfo(ModeNo, ModeIdIndex, pVBInfo);
- if (ModeNo <= 0x13)
- xres = pVBInfo->StResInfo[resindex].HTotal;
- else
- xres = pVBInfo->ModeResInfo[resindex].HTotal; /* xres->ax */
+ resindex = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO;
+ xres = pVBInfo->ModeResInfo[resindex].HTotal; /* xres->ax */
data = 0x0000;
if (infoflag & InterlaceMode) {
@@ -1568,18 +1186,10 @@ static void XGI_SetCRT1ModeRegs(struct xgi_hw_device_info *HwDeviceExtension,
if (modeflag & LineCompareOff)
data2 |= 0x08;
- if (ModeNo > 0x13) {
- if (pVBInfo->ModeType == ModeEGA)
- data2 |= 0x40;
- }
-
xgifb_reg_and_or(pVBInfo->P3c4, 0x0F, ~0x48, data2);
data = 0x60;
- if (pVBInfo->ModeType != ModeText) {
- data = data ^ 0x60;
- if (pVBInfo->ModeType != ModeEGA)
- data = data ^ 0xA0;
- }
+ data = data ^ 0x60;
+ data = data ^ 0xA0;
xgifb_reg_and_or(pVBInfo->P3c4, 0x21, 0x1F, data);
XGI_SetVCLKState(HwDeviceExtension, ModeNo, RefreshRateTableIndex,
@@ -1644,38 +1254,13 @@ static void XGI_WriteDAC(unsigned short dl,
static void XGI_LoadDAC(unsigned short ModeNo, unsigned short ModeIdIndex,
struct vb_device_info *pVBInfo)
{
- unsigned short data, data2, time, i, j, k, m, n, o, si, di, bx, dl, al,
- ah, dh;
- const unsigned short *table = NULL;
-
- if (ModeNo <= 0x13)
- data = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
- else
- data = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
-
- data &= DACInfoFlag;
- time = 64;
-
- if (data == 0x00)
- table = XGINew_MDA_DAC;
- else if (data == 0x08)
- table = XGINew_CGA_DAC;
- else if (data == 0x10)
- table = XGINew_EGA_DAC;
- else if (data == 0x18) {
- time = 256;
- table = XGINew_VGA_DAC;
- }
-
- if (time == 256)
- j = 16;
- else
- j = time;
+ unsigned short data, data2, i, k, m, n, o, si, di, bx, dl, al, ah, dh;
+ const unsigned short *table = XGINew_VGA_DAC;
outb(0xFF, pVBInfo->P3c6);
outb(0x00, pVBInfo->P3c8);
- for (i = 0; i < j; i++) {
+ for (i = 0; i < 16; i++) {
data = table[i];
for (k = 0; k < 3; k++) {
@@ -1692,45 +1277,43 @@ static void XGI_LoadDAC(unsigned short ModeNo, unsigned short ModeIdIndex,
}
}
- if (time == 256) {
- for (i = 16; i < 32; i++) {
- data = table[i];
-
- for (k = 0; k < 3; k++)
- outb(data, pVBInfo->P3c9);
- }
+ for (i = 16; i < 32; i++) {
+ data = table[i];
- si = 32;
+ for (k = 0; k < 3; k++)
+ outb(data, pVBInfo->P3c9);
+ }
- for (m = 0; m < 9; m++) {
- di = si;
- bx = si + 0x04;
- dl = 0;
+ si = 32;
- for (n = 0; n < 3; n++) {
- for (o = 0; o < 5; o++) {
- dh = table[si];
- ah = table[di];
- al = table[bx];
- si++;
- XGI_WriteDAC(dl, ah, al, dh, pVBInfo);
- }
+ for (m = 0; m < 9; m++) {
+ di = si;
+ bx = si + 0x04;
+ dl = 0;
- si -= 2;
+ for (n = 0; n < 3; n++) {
+ for (o = 0; o < 5; o++) {
+ dh = table[si];
+ ah = table[di];
+ al = table[bx];
+ si++;
+ XGI_WriteDAC(dl, ah, al, dh, pVBInfo);
+ }
- for (o = 0; o < 3; o++) {
- dh = table[bx];
- ah = table[di];
- al = table[si];
- si--;
- XGI_WriteDAC(dl, ah, al, dh, pVBInfo);
- }
+ si -= 2;
- dl++;
+ for (o = 0; o < 3; o++) {
+ dh = table[bx];
+ ah = table[di];
+ al = table[si];
+ si--;
+ XGI_WriteDAC(dl, ah, al, dh, pVBInfo);
}
- si += 5;
+ dl++;
}
+
+ si += 5;
}
}
@@ -1740,34 +1323,20 @@ static void XGI_GetLVDSResInfo(unsigned short ModeNo,
{
unsigned short resindex, xres, yres, modeflag;
- if (ModeNo <= 0x13)
- /* si+St_ResInfo */
- modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ResInfo;
- else
- /* si+Ext_ResInfo */
- modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO;
+ /* si+Ext_ResInfo */
+ modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO;
- if (ModeNo <= 0x13)
- /* si+St_ResInfo */
- resindex = pVBInfo->SModeIDTable[ModeIdIndex].St_ResInfo;
- else
- /* si+Ext_ResInfo */
- resindex = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO;
+ /* si+Ext_ResInfo */
+ resindex = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO;
- if (ModeNo <= 0x13) {
- xres = pVBInfo->StResInfo[resindex].HTotal;
- yres = pVBInfo->StResInfo[resindex].VTotal;
- } else {
- xres = pVBInfo->ModeResInfo[resindex].HTotal;
- yres = pVBInfo->ModeResInfo[resindex].VTotal;
- }
- if (ModeNo > 0x13) {
- if (modeflag & HalfDCLK)
- xres = xres << 1;
+ xres = pVBInfo->ModeResInfo[resindex].HTotal;
+ yres = pVBInfo->ModeResInfo[resindex].VTotal;
- if (modeflag & DoubleScanMode)
- yres = yres << 1;
- }
+ if (modeflag & HalfDCLK)
+ xres = xres << 1;
+
+ if (modeflag & DoubleScanMode)
+ yres = yres << 1;
if (xres == 720)
xres = 640;
@@ -1789,32 +1358,16 @@ static void *XGI_GetLcdPtr(unsigned short BX, unsigned short ModeNo,
tempbx = BX;
- if (ModeNo <= 0x13) {
- modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
- tempal = pVBInfo->SModeIDTable[ModeIdIndex].St_CRT2CRTC;
- } else {
- modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
- tempal = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC;
- }
+ modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
+ tempal = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC;
tempal = tempal & 0x0f;
if (tempbx <= 1) { /* ExpLink */
- if (ModeNo <= 0x13) {
- /* find no Ext_CRT2CRTC2 */
- tempal = pVBInfo->SModeIDTable[ModeIdIndex].St_CRT2CRTC;
- } else {
- tempal = pVBInfo->RefIndex[RefreshRateTableIndex].
- Ext_CRT2CRTC;
- }
+ tempal = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC;
if (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) {
- if (ModeNo <= 0x13)
- tempal = pVBInfo->SModeIDTable[ModeIdIndex].
- St_CRT2CRTC2;
- else
- tempal = pVBInfo->RefIndex[
- RefreshRateTableIndex].
+ tempal = pVBInfo->RefIndex[RefreshRateTableIndex].
Ext_CRT2CRTC2;
}
@@ -1882,9 +1435,6 @@ static void *XGI_GetLcdPtr(unsigned short BX, unsigned short ModeNo,
tempbx = tempdi[i].MASK;
tempdx = pVBInfo->LCDInfo;
- if (ModeNo <= 0x13) /* alan 09/10/2003 */
- tempdx |= SetLCDStdMode;
-
if (modeflag & HalfDCLK)
tempdx |= SetLCDLowResolution;
@@ -2238,15 +1788,8 @@ static void *XGI_GetTVPtr(unsigned short BX, unsigned short ModeNo,
struct XGI330_TVDataTablStruct *tempdi = NULL;
tempbx = BX;
-
- if (ModeNo <= 0x13) {
- modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
- tempal = pVBInfo->SModeIDTable[ModeIdIndex].St_CRT2CRTC;
- } else {
- modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
- tempal = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC;
- }
-
+ modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
+ tempal = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC;
tempal = tempal & 0x3f;
table = tempbx;
@@ -2293,7 +1836,6 @@ static void *XGI_GetTVPtr(unsigned short BX, unsigned short ModeNo,
i++;
}
- /* 07/05/22 */
if (table == 0x04) {
switch (tempdi[i].DATAPTR) {
case 0:
@@ -2367,12 +1909,12 @@ static void XGI_GetLVDSData(unsigned short ModeNo, unsigned short ModeIdIndex,
struct vb_device_info *pVBInfo)
{
unsigned short tempbx;
- struct XGI330_LVDSDataStruct *LCDPtr = NULL;
+ struct SiS_LVDSData *LCDPtr = NULL;
tempbx = 2;
if (pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)) {
- LCDPtr = (struct XGI330_LVDSDataStruct *) XGI_GetLcdPtr(tempbx,
+ LCDPtr = (struct SiS_LVDSData *)XGI_GetLcdPtr(tempbx,
ModeNo, ModeIdIndex, RefreshRateTableIndex,
pVBInfo);
pVBInfo->VGAHT = LCDPtr->VGAHT;
@@ -2389,7 +1931,8 @@ static void XGI_GetLVDSData(unsigned short ModeNo, unsigned short ModeIdIndex,
pVBInfo->HDE = 1024;
pVBInfo->VDE = 768;
} else if ((pVBInfo->LCDResInfo == Panel_1280x1024) ||
- (pVBInfo->LCDResInfo == Panel_1280x1024x75)) {
+ (pVBInfo->LCDResInfo ==
+ Panel_1280x1024x75)) {
pVBInfo->HDE = 1280;
pVBInfo->VDE = 1024;
} else if (pVBInfo->LCDResInfo == Panel_1400x1050) {
@@ -2413,11 +1956,7 @@ static void XGI_ModCRT1Regs(unsigned short ModeNo, unsigned short ModeIdIndex,
struct XGI_LVDSCRT1HDataStruct *LCDPtr = NULL;
struct XGI_LVDSCRT1VDataStruct *LCDPtr1 = NULL;
- if (ModeNo <= 0x13)
- index = pVBInfo->SModeIDTable[ModeIdIndex].St_CRT2CRTC;
- else
- index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC;
-
+ index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC;
index = index & IndexMask;
tempbx = 0;
@@ -2530,14 +2069,10 @@ static void XGI_SetLVDSRegs(unsigned short ModeNo, unsigned short ModeIdIndex,
{
unsigned short tempbx, tempax, tempcx, tempdx, push1, push2, modeflag;
unsigned long temp, temp1, temp2, temp3, push3;
- struct XGI330_LCDDataDesStruct *LCDPtr = NULL;
+ struct XGI_LCDDesStruct *LCDPtr = NULL;
struct XGI330_LCDDataDesStruct2 *LCDPtr1 = NULL;
- if (ModeNo > 0x13)
- modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
- else
- modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
-
+ modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
tempbx = 3;
if (pVBInfo->LCDInfo & EnableScalingLCD)
LCDPtr1 =
@@ -2550,7 +2085,7 @@ static void XGI_SetLVDSRegs(unsigned short ModeNo, unsigned short ModeIdIndex,
pVBInfo);
else
LCDPtr =
- (struct XGI330_LCDDataDesStruct *)
+ (struct XGI_LCDDesStruct *)
XGI_GetLcdPtr(
tempbx,
ModeNo,
@@ -2829,12 +2364,8 @@ static unsigned char XGI_GetVCLKPtr(unsigned short RefreshRateTableIndex,
unsigned short index, modeflag;
unsigned char tempal;
- if (ModeNo <= 0x13)
- /* si+St_ResInfo */
- modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
- else
- /* si+Ext_ResInfo */
- modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
+ /* si+Ext_ResInfo */
+ modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
if ((pVBInfo->SetFlag & ProgrammingCRT2) &&
(!(pVBInfo->LCDInfo & EnableScalingLCD))) { /* {LCDA/LCDB} */
@@ -2858,7 +2389,8 @@ static unsigned char XGI_GetVCLKPtr(unsigned short RefreshRateTableIndex,
if (pVBInfo->TVInfo & TVSimuMode) {
tempal = TVCLKBASE_315 + HiTVSimuVCLK;
if (!(modeflag & Charx8Dot))
- tempal = TVCLKBASE_315 + HiTVTextVCLK;
+ tempal = TVCLKBASE_315 +
+ HiTVTextVCLK;
}
return tempal;
@@ -2895,9 +2427,6 @@ static unsigned char XGI_GetVCLKPtr(unsigned short RefreshRateTableIndex,
if ((pVBInfo->LCDInfo & EnableScalingLCD) && (modeflag & Charx8Dot))
tempal = tempal ^ tempal; /* ; set to VCLK25MHz always */
- if (ModeNo <= 0x13)
- return tempal;
-
tempal = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRTVCLK;
return tempal;
}
@@ -2907,8 +2436,8 @@ static void XGI_GetVCLKLen(unsigned char tempal, unsigned char *di_0,
{
if (pVBInfo->VBType & (VB_SIS301 | VB_SIS301B | VB_SIS302B
| VB_SIS301LV | VB_SIS302LV | VB_XGI301C)) {
- if ((!(pVBInfo->VBInfo & XGI_SetCRT2ToLCDA)) && (pVBInfo->SetFlag
- & ProgrammingCRT2)) {
+ if ((!(pVBInfo->VBInfo & XGI_SetCRT2ToLCDA)) &&
+ (pVBInfo->SetFlag & ProgrammingCRT2)) {
*di_0 = (unsigned char) XGI_VBVCLKData[tempal].SR2B;
*di_1 = XGI_VBVCLKData[tempal].SR2C;
}
@@ -2968,7 +2497,7 @@ static void XGI_UpdateModeInfo(struct xgi_hw_device_info *HwDeviceExtension,
temp &= 0x0f;
if (!(temp == 0x08)) {
- /* Check ChannelA by Part1_13 [2003/10/03] */
+ /* Check ChannelA */
tempax = xgifb_reg_get(pVBInfo->Part1Port, 0x13);
if (tempax & 0x04)
tempcl = tempcl | ActiveLCD;
@@ -3035,42 +2564,45 @@ void XGI_GetVBType(struct vb_device_info *pVBInfo)
{
unsigned short flag, tempbx, tempah;
- if (pVBInfo->IF_DEF_LVDS == 0) {
- tempbx = VB_SIS302B;
- flag = xgifb_reg_get(pVBInfo->Part4Port, 0x00);
- if (flag != 0x02) {
- tempbx = VB_SIS301;
- flag = xgifb_reg_get(pVBInfo->Part4Port, 0x01);
- if (flag >= 0xB0) {
- tempbx = VB_SIS301B;
- if (flag >= 0xC0) {
- tempbx = VB_XGI301C;
- if (flag >= 0xD0) {
- tempbx = VB_SIS301LV;
- if (flag >= 0xE0) {
- tempbx = VB_SIS302LV;
- tempah = xgifb_reg_get(
- pVBInfo->Part4Port,
- 0x39);
- if (tempah != 0xFF)
- tempbx =
- VB_XGI301C;
- }
- }
- }
+ if (pVBInfo->IF_DEF_LVDS != 0)
+ return;
- if (tempbx & (VB_SIS301B | VB_SIS302B)) {
- flag = xgifb_reg_get(
- pVBInfo->Part4Port,
- 0x23);
+ tempbx = VB_SIS302B;
+ flag = xgifb_reg_get(pVBInfo->Part4Port, 0x00);
+ if (flag == 0x02)
+ goto finish;
- if (!(flag & 0x02))
- tempbx = tempbx | VB_NoLCD;
- }
- }
- }
- pVBInfo->VBType = tempbx;
+ tempbx = VB_SIS301;
+ flag = xgifb_reg_get(pVBInfo->Part4Port, 0x01);
+ if (flag < 0xB0)
+ goto finish;
+
+ tempbx = VB_SIS301B;
+ if (flag < 0xC0)
+ goto bigger_than_0xB0;
+
+ tempbx = VB_XGI301C;
+ if (flag < 0xD0)
+ goto bigger_than_0xB0;
+
+ tempbx = VB_SIS301LV;
+ if (flag < 0xE0)
+ goto bigger_than_0xB0;
+
+ tempbx = VB_SIS302LV;
+ tempah = xgifb_reg_get(pVBInfo->Part4Port, 0x39);
+ if (tempah != 0xFF)
+ tempbx = VB_XGI301C;
+
+bigger_than_0xB0:
+ if (tempbx & (VB_SIS301B | VB_SIS302B)) {
+ flag = xgifb_reg_get(pVBInfo->Part4Port, 0x23);
+ if (!(flag & 0x02))
+ tempbx = tempbx | VB_NoLCD;
}
+
+finish:
+ pVBInfo->VBType = tempbx;
}
static void XGI_GetVBInfo(unsigned short ModeNo, unsigned short ModeIdIndex,
@@ -3079,196 +2611,188 @@ static void XGI_GetVBInfo(unsigned short ModeNo, unsigned short ModeIdIndex,
{
unsigned short tempax, push, tempbx, temp, modeflag;
- if (ModeNo <= 0x13)
- modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
- else
- modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
-
+ modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
pVBInfo->SetFlag = 0;
pVBInfo->ModeType = modeflag & ModeTypeMask;
tempbx = 0;
- if (pVBInfo->VBType & 0xFFFF) {
- /* Check Display Device */
- temp = xgifb_reg_get(pVBInfo->P3d4, 0x30);
- tempbx = tempbx | temp;
- temp = xgifb_reg_get(pVBInfo->P3d4, 0x31);
- push = temp;
- push = push << 8;
- tempax = temp << 8;
- tempbx = tempbx | tempax;
- temp = (SetCRT2ToDualEdge | SetCRT2ToYPbPr525750 | XGI_SetCRT2ToLCDA
- | SetInSlaveMode | DisableCRT2Display);
- temp = 0xFFFF ^ temp;
- tempbx &= temp;
-
- temp = xgifb_reg_get(pVBInfo->P3d4, 0x38);
+ if (!(pVBInfo->VBType & 0xFFFF))
+ return;
- if (pVBInfo->IF_DEF_LCDA == 1) {
-
- if ((HwDeviceExtension->jChipType >= XG20) ||
- (HwDeviceExtension->jChipType >= XG40)) {
- if (pVBInfo->IF_DEF_LVDS == 0) {
- if (pVBInfo->VBType &
- (VB_SIS302B |
- VB_SIS301LV |
- VB_SIS302LV |
- VB_XGI301C)) {
- if (temp & EnableDualEdge) {
- tempbx |=
- SetCRT2ToDualEdge;
-
- if (temp & SetToLCDA)
- tempbx |=
- XGI_SetCRT2ToLCDA;
- }
- }
+ /* Check Display Device */
+ temp = xgifb_reg_get(pVBInfo->P3d4, 0x30);
+ tempbx = tempbx | temp;
+ temp = xgifb_reg_get(pVBInfo->P3d4, 0x31);
+ push = temp;
+ push = push << 8;
+ tempax = temp << 8;
+ tempbx = tempbx | tempax;
+ temp = (SetCRT2ToDualEdge | SetCRT2ToYPbPr525750 | XGI_SetCRT2ToLCDA
+ | SetInSlaveMode | DisableCRT2Display);
+ temp = 0xFFFF ^ temp;
+ tempbx &= temp;
+
+ temp = xgifb_reg_get(pVBInfo->P3d4, 0x38);
+
+ if (pVBInfo->IF_DEF_LCDA == 1) {
+
+ if (((HwDeviceExtension->jChipType >= XG20) ||
+ (HwDeviceExtension->jChipType >= XG40)) &&
+ (pVBInfo->IF_DEF_LVDS == 0)) {
+ if (pVBInfo->VBType &
+ (VB_SIS302B |
+ VB_SIS301LV |
+ VB_SIS302LV |
+ VB_XGI301C)) {
+ if (temp & EnableDualEdge) {
+ tempbx |= SetCRT2ToDualEdge;
+ if (temp & SetToLCDA)
+ tempbx |= XGI_SetCRT2ToLCDA;
}
}
}
+ }
- if (pVBInfo->IF_DEF_YPbPr == 1) {
- /* [Billy] 07/05/04 */
- if (((pVBInfo->IF_DEF_LVDS == 0) &&
- ((pVBInfo->VBType & VB_SIS301LV) ||
- (pVBInfo->VBType & VB_SIS302LV) ||
- (pVBInfo->VBType & VB_XGI301C)))) {
- if (temp & SetYPbPr) {
- if (pVBInfo->IF_DEF_HiVision == 1) {
- /* shampoo add for new
- * scratch */
- temp = xgifb_reg_get(
- pVBInfo->P3d4,
- 0x35);
- temp &= YPbPrMode;
- tempbx |= SetCRT2ToHiVision;
-
- if (temp != YPbPrMode1080i) {
- tempbx &=
- (~SetCRT2ToHiVision);
- tempbx |=
- SetCRT2ToYPbPr525750;
- }
+ if (pVBInfo->IF_DEF_YPbPr == 1) {
+ if (((pVBInfo->IF_DEF_LVDS == 0) &&
+ ((pVBInfo->VBType & VB_SIS301LV) ||
+ (pVBInfo->VBType & VB_SIS302LV) ||
+ (pVBInfo->VBType & VB_XGI301C)))) {
+ if (temp & SetYPbPr) {
+ if (pVBInfo->IF_DEF_HiVision == 1) {
+ /* shampoo add for new
+ * scratch */
+ temp = xgifb_reg_get(
+ pVBInfo->P3d4,
+ 0x35);
+ temp &= YPbPrMode;
+ tempbx |= SetCRT2ToHiVision;
+
+ if (temp != YPbPrMode1080i) {
+ tempbx &=
+ (~SetCRT2ToHiVision);
+ tempbx |=
+ SetCRT2ToYPbPr525750;
}
}
}
}
+ }
- tempax = push; /* restore CR31 */
+ tempax = push; /* restore CR31 */
- if (pVBInfo->IF_DEF_LVDS == 0) {
- if (pVBInfo->IF_DEF_YPbPr == 1) {
- if (pVBInfo->IF_DEF_HiVision == 1)
- temp = 0x09FC;
- else
- temp = 0x097C;
- } else {
- if (pVBInfo->IF_DEF_HiVision == 1)
- temp = 0x01FC;
- else
- temp = 0x017C;
- }
- } else { /* 3nd party chip */
- temp = SetCRT2ToLCD;
- }
-
- if (!(tempbx & temp)) {
- tempax |= DisableCRT2Display;
- tempbx = 0;
- }
-
- if (pVBInfo->IF_DEF_LCDA == 1) { /* Select Display Device */
- if (!(pVBInfo->VBType & VB_NoLCD)) {
- if (tempbx & XGI_SetCRT2ToLCDA) {
- if (tempbx & SetSimuScanMode)
- tempbx &= (~(SetCRT2ToLCD |
- SetCRT2ToRAMDAC |
- SwitchCRT2));
- else
- tempbx &= (~(SetCRT2ToLCD |
- SetCRT2ToRAMDAC |
- SetCRT2ToTV |
- SwitchCRT2));
- }
- }
+ if (pVBInfo->IF_DEF_LVDS == 0) {
+ if (pVBInfo->IF_DEF_YPbPr == 1) {
+ if (pVBInfo->IF_DEF_HiVision == 1)
+ temp = 0x09FC;
+ else
+ temp = 0x097C;
+ } else {
+ if (pVBInfo->IF_DEF_HiVision == 1)
+ temp = 0x01FC;
+ else
+ temp = 0x017C;
}
+ } else { /* 3nd party chip */
+ temp = SetCRT2ToLCD;
+ }
- /* shampoo add */
- /* for driver abnormal */
- if (!(tempbx & (SwitchCRT2 | SetSimuScanMode))) {
- if (pVBInfo->IF_DEF_CRT2Monitor == 1) {
- if (tempbx & SetCRT2ToRAMDAC) {
- tempbx &= (0xFF00 |
- SetCRT2ToRAMDAC |
- SwitchCRT2 |
- SetSimuScanMode);
- tempbx &= (0x00FF | (~SetCRT2ToYPbPr525750));
- }
- } else {
- tempbx &= (~(SetCRT2ToRAMDAC |
- SetCRT2ToLCD |
- SetCRT2ToTV));
+ if (!(tempbx & temp)) {
+ tempax |= DisableCRT2Display;
+ tempbx = 0;
+ }
+
+ if (pVBInfo->IF_DEF_LCDA == 1) { /* Select Display Device */
+ if (!(pVBInfo->VBType & VB_NoLCD)) {
+ if (tempbx & XGI_SetCRT2ToLCDA) {
+ if (tempbx & SetSimuScanMode)
+ tempbx &= (~(SetCRT2ToLCD |
+ SetCRT2ToRAMDAC |
+ SwitchCRT2));
+ else
+ tempbx &= (~(SetCRT2ToLCD |
+ SetCRT2ToRAMDAC |
+ SetCRT2ToTV |
+ SwitchCRT2));
}
}
+ }
- if (!(pVBInfo->VBType & VB_NoLCD)) {
- if (tempbx & SetCRT2ToLCD) {
+ /* shampoo add */
+ /* for driver abnormal */
+ if (!(tempbx & (SwitchCRT2 | SetSimuScanMode))) {
+ if (pVBInfo->IF_DEF_CRT2Monitor == 1) {
+ if (tempbx & SetCRT2ToRAMDAC) {
tempbx &= (0xFF00 |
- SetCRT2ToLCD |
+ SetCRT2ToRAMDAC |
SwitchCRT2 |
SetSimuScanMode);
tempbx &= (0x00FF | (~SetCRT2ToYPbPr525750));
}
+ } else {
+ tempbx &= (~(SetCRT2ToRAMDAC |
+ SetCRT2ToLCD |
+ SetCRT2ToTV));
}
+ }
- if (tempbx & SetCRT2ToSCART) {
+ if (!(pVBInfo->VBType & VB_NoLCD)) {
+ if (tempbx & SetCRT2ToLCD) {
tempbx &= (0xFF00 |
- SetCRT2ToSCART |
+ SetCRT2ToLCD |
SwitchCRT2 |
SetSimuScanMode);
tempbx &= (0x00FF | (~SetCRT2ToYPbPr525750));
}
+ }
- if (pVBInfo->IF_DEF_YPbPr == 1) {
- if (tempbx & SetCRT2ToYPbPr525750)
- tempbx &= (0xFF00 |
- SwitchCRT2 |
- SetSimuScanMode);
- }
+ if (tempbx & SetCRT2ToSCART) {
+ tempbx &= (0xFF00 |
+ SetCRT2ToSCART |
+ SwitchCRT2 |
+ SetSimuScanMode);
+ tempbx &= (0x00FF | (~SetCRT2ToYPbPr525750));
+ }
- if (pVBInfo->IF_DEF_HiVision == 1) {
- if (tempbx & SetCRT2ToHiVision)
- tempbx &= (0xFF00 |
- SetCRT2ToHiVision |
- SwitchCRT2 |
- SetSimuScanMode);
- }
+ if (pVBInfo->IF_DEF_YPbPr == 1) {
+ if (tempbx & SetCRT2ToYPbPr525750)
+ tempbx &= (0xFF00 |
+ SwitchCRT2 |
+ SetSimuScanMode);
+ }
- if (tempax & DisableCRT2Display) { /* Set Display Device Info */
- if (!(tempbx & (SwitchCRT2 | SetSimuScanMode)))
- tempbx = DisableCRT2Display;
- }
+ if (pVBInfo->IF_DEF_HiVision == 1) {
+ if (tempbx & SetCRT2ToHiVision)
+ tempbx &= (0xFF00 |
+ SetCRT2ToHiVision |
+ SwitchCRT2 |
+ SetSimuScanMode);
+ }
- if (!(tempbx & DisableCRT2Display)) {
- if ((!(tempbx & DriverMode)) ||
- (!(modeflag & CRT2Mode))) {
- if (pVBInfo->IF_DEF_LCDA == 1) {
- if (!(tempbx & XGI_SetCRT2ToLCDA))
- tempbx |= (SetInSlaveMode |
- SetSimuScanMode);
- }
- }
+ if (tempax & DisableCRT2Display) { /* Set Display Device Info */
+ if (!(tempbx & (SwitchCRT2 | SetSimuScanMode)))
+ tempbx = DisableCRT2Display;
+ }
- /* LCD+TV can't support in slave mode
- * (Force LCDA+TV->LCDB) */
- if ((tempbx & SetInSlaveMode) &&
- (tempbx & XGI_SetCRT2ToLCDA)) {
- tempbx ^= (SetCRT2ToLCD |
- XGI_SetCRT2ToLCDA |
- SetCRT2ToDualEdge);
- pVBInfo->SetFlag |= ReserveTVOption;
+ if (!(tempbx & DisableCRT2Display)) {
+ if ((!(tempbx & DriverMode)) ||
+ (!(modeflag & CRT2Mode))) {
+ if (pVBInfo->IF_DEF_LCDA == 1) {
+ if (!(tempbx & XGI_SetCRT2ToLCDA))
+ tempbx |= (SetInSlaveMode |
+ SetSimuScanMode);
}
}
+
+ /* LCD+TV can't support in slave mode
+ * (Force LCDA+TV->LCDB) */
+ if ((tempbx & SetInSlaveMode) &&
+ (tempbx & XGI_SetCRT2ToLCDA)) {
+ tempbx ^= (SetCRT2ToLCD |
+ XGI_SetCRT2ToLCDA |
+ SetCRT2ToDualEdge);
+ pVBInfo->SetFlag |= ReserveTVOption;
+ }
}
pVBInfo->VBInfo = tempbx;
@@ -3283,17 +2807,8 @@ static void XGI_GetTVInfo(unsigned short ModeNo, unsigned short ModeIdIndex,
resinfo = 0;
if (pVBInfo->VBInfo & SetCRT2ToTV) {
- if (ModeNo <= 0x13) {
- modeflag = pVBInfo->SModeIDTable[ModeIdIndex].
- St_ModeFlag; /* si+St_ModeFlag */
- resinfo = pVBInfo->SModeIDTable[ModeIdIndex].
- St_ResInfo; /* si+St_ResInfo */
- } else {
- modeflag = pVBInfo->EModeIDTable[ModeIdIndex].
- Ext_ModeFlag;
- resinfo = pVBInfo->EModeIDTable[ModeIdIndex].
- Ext_RESINFO; /* si+Ext_ResInfo */
- }
+ modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
+ resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO;
if (pVBInfo->VBInfo & SetCRT2ToTV) {
temp = xgifb_reg_get(pVBInfo->P3d4, 0x35);
@@ -3380,22 +2895,16 @@ static unsigned char XGI_GetLCDInfo(unsigned short ModeNo,
pVBInfo->LCDTypeInfo = 0;
pVBInfo->LCDInfo = 0;
- if (ModeNo <= 0x13) {
- /* si+St_ModeFlag // */
- modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
- } else {
- modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
- /* si+Ext_ResInfo // */
- resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO;
- }
-
+ modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
+ /* si+Ext_ResInfo // */
+ resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO;
temp = xgifb_reg_get(pVBInfo->P3d4, 0x36); /* Get LCD Res.Info */
tempbx = temp & 0x0F;
if (tempbx == 0)
tempbx = Panel_1024x768; /* default */
- /* LCD75 [2003/8/22] Vicent */
+ /* LCD75 */
if ((tempbx == Panel_1024x768) || (tempbx == Panel_1280x1024)) {
if (pVBInfo->VBInfo & DriverMode) {
tempax = xgifb_reg_get(pVBInfo->P3d4, 0x33);
@@ -3442,9 +2951,12 @@ static unsigned char XGI_GetLCDInfo(unsigned short ModeNo,
if (pVBInfo->IF_DEF_LVDS == 0) {
if ((pVBInfo->LCDResInfo == Panel_1400x1050) && (pVBInfo->VBInfo
- & SetCRT2ToLCD) && (ModeNo > 0x13) && (resinfo
- == 9) && (!(tempbx & EnableScalingLCD)))
- /* set to center in 1280x1024 LCDB for Panel_1400x1050 */
+ & SetCRT2ToLCD) && (resinfo == 9) &&
+ (!(tempbx & EnableScalingLCD)))
+ /*
+ * set to center in 1280x1024 LCDB
+ * for Panel_1400x1050
+ */
tempbx |= SetLCDtoNonExpanding;
}
@@ -3453,12 +2965,9 @@ static unsigned char XGI_GetLCDInfo(unsigned short ModeNo,
if (!(tempbx & SetLCDtoNonExpanding)) {
tempbx |= XGI_EnableLVDSDDA;
} else {
- if (ModeNo > 0x13) {
- if (pVBInfo->LCDResInfo
- == Panel_1024x768) {
- if (resinfo == 4) {/* 512x384 */
- tempbx |= XGI_EnableLVDSDDA;
- }
+ if (pVBInfo->LCDResInfo == Panel_1024x768) {
+ if (resinfo == 4) {/* 512x384 */
+ tempbx |= XGI_EnableLVDSDDA;
}
}
}
@@ -3474,56 +2983,17 @@ static unsigned char XGI_GetLCDInfo(unsigned short ModeNo,
pVBInfo->LCDInfo = tempbx;
- if (pVBInfo->IF_DEF_LVDS == 0) {
- if (tempax & (LockLCDBToA | StLCDBToA)) {
- if (pVBInfo->VBInfo & SetInSlaveMode) {
- if (!(tempax & LockLCDBToA)) {
- if (ModeNo <= 0x13) {
- pVBInfo->VBInfo &=
- ~(SetSimuScanMode |
- SetInSlaveMode |
- SetCRT2ToLCD);
- pVBInfo->VBInfo |=
- XGI_SetCRT2ToLCDA |
- SetCRT2ToDualEdge;
- }
- }
- }
- }
- }
-
return 1;
}
unsigned char XGI_SearchModeID(unsigned short ModeNo,
unsigned short *ModeIdIndex, struct vb_device_info *pVBInfo)
{
- if (ModeNo <= 5)
- ModeNo |= 1;
- if (ModeNo <= 0x13) {
- for (*ModeIdIndex = 0;; (*ModeIdIndex)++) {
- if (pVBInfo->SModeIDTable[*ModeIdIndex].St_ModeID ==
- ModeNo)
- break;
- if (pVBInfo->SModeIDTable[*ModeIdIndex].St_ModeID ==
- 0xFF)
- return 0;
- }
-
- if (ModeNo == 0x07)
- (*ModeIdIndex)++; /* 400 lines */
- if (ModeNo <= 3)
- (*ModeIdIndex) += 2; /* 400 lines */
- /* else 350 lines */
- } else {
- for (*ModeIdIndex = 0;; (*ModeIdIndex)++) {
- if (pVBInfo->EModeIDTable[*ModeIdIndex].Ext_ModeID ==
- ModeNo)
- break;
- if (pVBInfo->EModeIDTable[*ModeIdIndex].Ext_ModeID ==
- 0xFF)
- return 0;
- }
+ for (*ModeIdIndex = 0;; (*ModeIdIndex)++) {
+ if (pVBInfo->EModeIDTable[*ModeIdIndex].Ext_ModeID == ModeNo)
+ break;
+ if (pVBInfo->EModeIDTable[*ModeIdIndex].Ext_ModeID == 0xFF)
+ return 0;
}
return 1;
@@ -3789,63 +3259,59 @@ static void XGI_GetCRT2ResInfo(unsigned short ModeNo,
{
unsigned short xres, yres, modeflag, resindex;
- resindex = XGI_GetResInfo(ModeNo, ModeIdIndex, pVBInfo);
- if (ModeNo <= 0x13) {
- xres = pVBInfo->StResInfo[resindex].HTotal;
- yres = pVBInfo->StResInfo[resindex].VTotal;
- } else {
- xres = pVBInfo->ModeResInfo[resindex].HTotal; /* xres->ax */
- yres = pVBInfo->ModeResInfo[resindex].VTotal; /* yres->bx */
- /* si+St_ModeFlag */
- modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
+ resindex = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO;
+ xres = pVBInfo->ModeResInfo[resindex].HTotal; /* xres->ax */
+ yres = pVBInfo->ModeResInfo[resindex].VTotal; /* yres->bx */
+ /* si+St_ModeFlag */
+ modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
- if (modeflag & HalfDCLK)
- xres *= 2;
+ if (modeflag & HalfDCLK)
+ xres *= 2;
- if (modeflag & DoubleScanMode)
- yres *= 2;
- }
+ if (modeflag & DoubleScanMode)
+ yres *= 2;
- if (pVBInfo->VBInfo & SetCRT2ToLCD) {
- if (pVBInfo->IF_DEF_LVDS == 0) {
- if (pVBInfo->LCDResInfo == Panel_1600x1200) {
- if (!(pVBInfo->LCDInfo & XGI_LCDVESATiming)) {
- if (yres == 1024)
- yres = 1056;
- }
+ if (!(pVBInfo->VBInfo & SetCRT2ToLCD))
+ goto exit;
+
+ if (pVBInfo->IF_DEF_LVDS == 0) {
+ if (pVBInfo->LCDResInfo == Panel_1600x1200) {
+ if (!(pVBInfo->LCDInfo & XGI_LCDVESATiming)) {
+ if (yres == 1024)
+ yres = 1056;
}
+ }
- if (pVBInfo->LCDResInfo == Panel_1280x1024) {
- if (yres == 400)
- yres = 405;
- else if (yres == 350)
- yres = 360;
+ if (pVBInfo->LCDResInfo == Panel_1280x1024) {
+ if (yres == 400)
+ yres = 405;
+ else if (yres == 350)
+ yres = 360;
- if (pVBInfo->LCDInfo & XGI_LCDVESATiming) {
- if (yres == 360)
- yres = 375;
- }
+ if (pVBInfo->LCDInfo & XGI_LCDVESATiming) {
+ if (yres == 360)
+ yres = 375;
}
+ }
- if (pVBInfo->LCDResInfo == Panel_1024x768) {
- if (!(pVBInfo->LCDInfo & XGI_LCDVESATiming)) {
- if (!(pVBInfo->LCDInfo
- & LCDNonExpanding)) {
- if (yres == 350)
- yres = 357;
- else if (yres == 400)
- yres = 420;
- else if (yres == 480)
- yres = 525;
- }
+ if (pVBInfo->LCDResInfo == Panel_1024x768) {
+ if (!(pVBInfo->LCDInfo & XGI_LCDVESATiming)) {
+ if (!(pVBInfo->LCDInfo & LCDNonExpanding)) {
+ if (yres == 350)
+ yres = 357;
+ else if (yres == 400)
+ yres = 420;
+ else if (yres == 480)
+ yres = 525;
}
}
}
-
- if (xres == 720)
- xres = 640;
}
+ if (xres == 720)
+ xres = 640;
+
+exit:
pVBInfo->VGAHDE = xres;
pVBInfo->HDE = xres;
pVBInfo->VGAVDE = yres;
@@ -3868,37 +3334,23 @@ static void XGI_GetRAMDAC2DATA(unsigned short ModeNo,
struct vb_device_info *pVBInfo)
{
unsigned short tempax, tempbx, temp1, temp2, modeflag = 0, tempcx,
- StandTableIndex, CRT1Index;
+ CRT1Index;
pVBInfo->RVBHCMAX = 1;
pVBInfo->RVBHCFACT = 1;
-
- if (ModeNo <= 0x13) {
- modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
- StandTableIndex = XGI_GetModePtr(ModeNo, ModeIdIndex, pVBInfo);
- tempax = pVBInfo->StandTable[StandTableIndex].CRTC[0];
- tempbx = pVBInfo->StandTable[StandTableIndex].CRTC[6];
- temp1 = pVBInfo->StandTable[StandTableIndex].CRTC[7];
- } else {
- modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
- CRT1Index = pVBInfo->RefIndex[RefreshRateTableIndex].
- Ext_CRT1CRTC;
- CRT1Index &= IndexMask;
- temp1 = (unsigned short) pVBInfo->
- XGINEWUB_CRT1Table[CRT1Index].CR[0];
- temp2 = (unsigned short) pVBInfo->
- XGINEWUB_CRT1Table[CRT1Index].CR[5];
- tempax = (temp1 & 0xFF) | ((temp2 & 0x03) << 8);
- tempbx = (unsigned short) pVBInfo->
- XGINEWUB_CRT1Table[CRT1Index].CR[8];
- tempcx = (unsigned short) pVBInfo->
- XGINEWUB_CRT1Table[CRT1Index].CR[14] << 8;
- tempcx &= 0x0100;
- tempcx = tempcx << 2;
- tempbx |= tempcx;
- temp1 = (unsigned short) pVBInfo->
- XGINEWUB_CRT1Table[CRT1Index].CR[9];
- }
+ modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
+ CRT1Index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC;
+ CRT1Index &= IndexMask;
+ temp1 = (unsigned short) pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[0];
+ temp2 = (unsigned short) pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[5];
+ tempax = (temp1 & 0xFF) | ((temp2 & 0x03) << 8);
+ tempbx = (unsigned short) pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[8];
+ tempcx = (unsigned short)
+ pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[14] << 8;
+ tempcx &= 0x0100;
+ tempcx = tempcx << 2;
+ tempbx |= tempcx;
+ temp1 = (unsigned short) pVBInfo->XGINEWUB_CRT1Table[CRT1Index].CR[9];
if (temp1 & 0x01)
tempbx |= 0x0100;
@@ -3928,16 +3380,9 @@ static void XGI_GetCRT2Data(unsigned short ModeNo, unsigned short ModeIdIndex,
struct SiS_LCDData *LCDPtr = NULL;
struct SiS_TVData *TVPtr = NULL;
- if (ModeNo <= 0x13) {
- /* si+St_ResInfo */
- modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
- resinfo = pVBInfo->SModeIDTable[ModeIdIndex].St_ResInfo;
- } else {
- /* si+Ext_ResInfo */
- modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
- resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO;
- }
-
+ /* si+Ext_ResInfo */
+ modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
+ resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO;
pVBInfo->NewFlickerMode = 0;
pVBInfo->RVBHRS = 50;
@@ -4141,11 +3586,7 @@ static unsigned short XGI_GetColorDepth(unsigned short ModeNo,
short index;
unsigned short modeflag;
- if (ModeNo <= 0x13)
- modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
- else
- modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
-
+ modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
index = (modeflag & ModeTypeMask) - ModeEGA;
if (index < 0)
@@ -4164,11 +3605,7 @@ static unsigned short XGI_GetOffset(unsigned short ModeNo,
ColorDepth[] = { 0x01, 0x02, 0x04 };
modeinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeInfo;
- if (ModeNo <= 0x14)
- infoflag = 0;
- else
- infoflag = pVBInfo->
- RefIndex[RefreshRateTableIndex].Ext_InfoFlag;
+ infoflag = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_InfoFlag;
index = (modeinfo >> 8) & 0xFF;
@@ -4228,12 +3665,9 @@ static void XGI_PreSetGroup1(unsigned short ModeNo, unsigned short ModeIdIndex,
{
unsigned short tempcx = 0, CRT1Index = 0, resinfo = 0;
- if (ModeNo > 0x13) {
- CRT1Index = pVBInfo->
- RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC;
- CRT1Index &= IndexMask;
- resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO;
- }
+ CRT1Index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC;
+ CRT1Index &= IndexMask;
+ resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO;
XGI_SetCRT2Offset(ModeNo, ModeIdIndex, RefreshRateTableIndex,
HwDeviceExtension, pVBInfo);
@@ -4254,17 +3688,10 @@ static void XGI_SetGroup1(unsigned short ModeNo, unsigned short ModeIdIndex,
unsigned short temp = 0, tempax = 0, tempbx = 0, tempcx = 0,
pushbx = 0, CRT1Index = 0, modeflag, resinfo = 0;
- if (ModeNo > 0x13) {
- CRT1Index = pVBInfo->
- RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC;
- CRT1Index &= IndexMask;
- resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO;
- }
-
- if (ModeNo <= 0x13)
- modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
- else
- modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
+ CRT1Index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC;
+ CRT1Index &= IndexMask;
+ resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO;
+ modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
/* bainy change table name */
if (modeflag & HalfDCLK) {
@@ -4422,18 +3849,11 @@ static void XGI_SetLockRegs(unsigned short ModeNo, unsigned short ModeIdIndex,
unsigned short push1, push2, tempax, tempbx = 0, tempcx, temp, resinfo,
modeflag, CRT1Index;
- if (ModeNo <= 0x13) {
- /* si+St_ResInfo */
- modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
- resinfo = pVBInfo->SModeIDTable[ModeIdIndex].St_ResInfo;
- } else {
- /* si+Ext_ResInfo */
- modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
- resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO;
- CRT1Index = pVBInfo->
- RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC;
- CRT1Index &= IndexMask;
- }
+ /* si+Ext_ResInfo */
+ modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
+ resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO;
+ CRT1Index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC;
+ CRT1Index &= IndexMask;
if (!(pVBInfo->VBInfo & SetInSlaveMode))
return;
@@ -4500,8 +3920,7 @@ static void XGI_SetLockRegs(unsigned short ModeNo, unsigned short ModeIdIndex,
temp -= 6;
if (pVBInfo->TVInfo & TVSimuMode) {
temp -= 4;
- if (ModeNo > 0x13)
- temp -= 10;
+ temp -= 10;
}
}
} else {
@@ -4523,14 +3942,6 @@ static void XGI_SetLockRegs(unsigned short ModeNo, unsigned short ModeIdIndex,
if (pVBInfo->LCDResInfo != Panel_1280x960 &&
pVBInfo->VGAHDE >= 800) {
temp -= 7;
- if (pVBInfo->ModeType == ModeEGA &&
- pVBInfo->VGAVDE == 1024) {
- temp += 15;
- if (pVBInfo->LCDResInfo !=
- Panel_1280x1024)
- temp += 7;
- }
-
if (pVBInfo->VGAHDE >= 1280 &&
pVBInfo->LCDResInfo != Panel_1280x960 &&
(pVBInfo->LCDInfo & LCDNonExpanding))
@@ -4546,48 +3957,7 @@ static void XGI_SetLockRegs(unsigned short ModeNo, unsigned short ModeIdIndex,
if (pVBInfo->VBInfo & SetCRT2ToTV) {
if (pVBInfo->TVInfo & TVSimuMode) {
- if ((ModeNo == 0x06) || (ModeNo == 0x10) || (ModeNo
- == 0x11) || (ModeNo == 0x13) || (ModeNo
- == 0x0F)) {
- xgifb_reg_set(pVBInfo->Part1Port, 0x07, 0x5b);
- xgifb_reg_set(pVBInfo->Part1Port, 0x08, 0x03);
- }
-
- if ((ModeNo == 0x00) || (ModeNo == 0x01)) {
- if (pVBInfo->TVInfo & SetNTSCTV) {
- xgifb_reg_set(pVBInfo->Part1Port,
- 0x07, 0x2A);
- xgifb_reg_set(pVBInfo->Part1Port,
- 0x08, 0x61);
- } else {
- xgifb_reg_set(pVBInfo->Part1Port,
- 0x07, 0x2A);
- xgifb_reg_set(pVBInfo->Part1Port,
- 0x08, 0x41);
- xgifb_reg_set(pVBInfo->Part1Port,
- 0x0C, 0xF0);
- }
- }
-
- if ((ModeNo == 0x02) || (ModeNo == 0x03) || (ModeNo
- == 0x07)) {
- if (pVBInfo->TVInfo & SetNTSCTV) {
- xgifb_reg_set(pVBInfo->Part1Port,
- 0x07, 0x54);
- xgifb_reg_set(pVBInfo->Part1Port,
- 0x08, 0x00);
- } else {
- xgifb_reg_set(pVBInfo->Part1Port,
- 0x07, 0x55);
- xgifb_reg_set(pVBInfo->Part1Port,
- 0x08, 0x00);
- xgifb_reg_set(pVBInfo->Part1Port,
- 0x0C, 0xF0);
- }
- }
-
- if ((ModeNo == 0x04) || (ModeNo == 0x05) || (ModeNo
- == 0x0D) || (ModeNo == 0x50)) {
+ if (ModeNo == 0x50) {
if (pVBInfo->TVInfo & SetNTSCTV) {
xgifb_reg_set(pVBInfo->Part1Port,
0x07, 0x30);
@@ -4677,24 +4047,16 @@ static void XGI_SetLockRegs(unsigned short ModeNo, unsigned short ModeIdIndex,
}
if (pVBInfo->VBInfo & SetCRT2ToHiVision) {
- if (pVBInfo->VBType & VB_SIS301LV) {
- if (pVBInfo->TVInfo & TVSetHiVision) {
- tempbx -= 10;
- } else {
- if (pVBInfo->TVInfo & TVSimuMode) {
- if (pVBInfo->TVInfo & TVSetPAL) {
- if (pVBInfo->VBType &
- VB_SIS301LV) {
- if (!(pVBInfo->TVInfo &
- (TVSetYPbPr525p |
- TVSetYPbPr750p |
- TVSetHiVision)))
- tempbx += 40;
- } else {
- tempbx += 40;
- }
- }
- }
+ if ((pVBInfo->VBType & VB_SIS301LV) &&
+ !(pVBInfo->TVInfo & TVSetHiVision)) {
+ if ((pVBInfo->TVInfo & TVSimuMode) &&
+ (pVBInfo->TVInfo & TVSetPAL)) {
+ if (!(pVBInfo->VBType & VB_SIS301LV) ||
+ !(pVBInfo->TVInfo &
+ (TVSetYPbPr525p |
+ TVSetYPbPr750p |
+ TVSetHiVision)))
+ tempbx += 40;
}
} else {
tempbx -= 10;
@@ -4796,18 +4158,10 @@ static void XGI_SetGroup2(unsigned short ModeNo, unsigned short ModeIdIndex,
unsigned long longtemp, tempeax, tempebx, temp2, tempecx;
- if (ModeNo <= 0x13) {
- /* si+St_ResInfo */
- modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
- resinfo = pVBInfo->SModeIDTable[ModeIdIndex].St_ResInfo;
- crt2crtc = pVBInfo->SModeIDTable[ModeIdIndex].St_CRT2CRTC;
- } else {
- /* si+Ext_ResInfo */
- modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
- resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO;
- crt2crtc = pVBInfo->RefIndex[RefreshRateTableIndex].
- Ext_CRT2CRTC;
- }
+ /* si+Ext_ResInfo */
+ modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
+ resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO;
+ crt2crtc = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT2CRTC;
tempax = 0;
@@ -5210,7 +4564,7 @@ static void XGI_SetGroup2(unsigned short ModeNo, unsigned short ModeIdIndex,
}
}
- /* [ycchen] 01/14/03 Modify for 301C PALM Support */
+ /* Modify for 301C PALM Support */
if (pVBInfo->VBType & VB_XGI301C) {
if (pVBInfo->TVInfo & TVSetPALM)
xgifb_reg_and_or(pVBInfo->Part2Port, 0x4E, ~0x08,
@@ -5245,18 +4599,11 @@ static void XGI_SetLCDRegs(unsigned short ModeNo, unsigned short ModeIdIndex,
struct XGI_LCDDesStruct *LCDBDesPtr = NULL;
- if (ModeNo <= 0x13) {
- /* si+St_ResInfo */
- modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
- resinfo = pVBInfo->SModeIDTable[ModeIdIndex].St_ResInfo;
- } else {
- /* si+Ext_ResInfo */
- modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
- resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO;
- CRT1Index = pVBInfo->RefIndex[RefreshRateTableIndex].
- Ext_CRT1CRTC;
- CRT1Index &= IndexMask;
- }
+ /* si+Ext_ResInfo */
+ modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
+ resinfo = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO;
+ CRT1Index = pVBInfo->RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC;
+ CRT1Index &= IndexMask;
if (!(pVBInfo->VBInfo & SetCRT2ToLCD))
return;
@@ -5274,16 +4621,6 @@ static void XGI_SetLCDRegs(unsigned short ModeNo, unsigned short ModeIdIndex,
xgifb_reg_and_or(pVBInfo->Part2Port, 0x2B, 0x0F, temp);
temp = 0x01;
- if (pVBInfo->LCDResInfo == Panel_1280x1024) {
- if (pVBInfo->ModeType == ModeEGA) {
- if (pVBInfo->VGAHDE >= 1024) {
- temp = 0x02;
- if (pVBInfo->LCDInfo & XGI_LCDVESATiming)
- temp = 0x01;
- }
- }
- }
-
xgifb_reg_set(pVBInfo->Part2Port, 0x0B, temp);
tempbx = pVBInfo->VDE; /* RTVACTEO=(VDE-1)&0xFF */
push1 = tempbx;
@@ -5542,12 +4879,8 @@ static void XGI_SetGroup3(unsigned short ModeNo, unsigned short ModeIdIndex,
unsigned char *tempdi;
unsigned short modeflag;
- if (ModeNo <= 0x13)
- /* si+St_ResInfo */
- modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
- else
- /* si+Ext_ResInfo */
- modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
+ /* si+Ext_ResInfo */
+ modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
xgifb_reg_set(pVBInfo->Part3Port, 0x00, 0x00);
if (pVBInfo->TVInfo & TVSetPAL) {
@@ -5605,13 +4938,8 @@ static void XGI_SetGroup4(unsigned short ModeNo, unsigned short ModeIdIndex,
unsigned long tempebx, tempeax, templong;
- if (ModeNo <= 0x13)
- /* si+St_ResInfo */
- modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
- else
- /* si+Ext_ResInfo */
- modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
-
+ /* si+Ext_ResInfo */
+ modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
temp = pVBInfo->RVBHCFACT;
xgifb_reg_set(pVBInfo->Part4Port, 0x13, temp);
@@ -5818,32 +5146,22 @@ static unsigned char XGI_XG21CheckLVDSMode(struct xgifb_video_info *xgifb_info,
{
unsigned short xres, yres, colordepth, modeflag, resindex;
- resindex = XGI_GetResInfo(ModeNo, ModeIdIndex, pVBInfo);
- if (ModeNo <= 0x13) {
- xres = pVBInfo->StResInfo[resindex].HTotal;
- yres = pVBInfo->StResInfo[resindex].VTotal;
- /* si+St_ResInfo */
- modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
- } else {
- xres = pVBInfo->ModeResInfo[resindex].HTotal; /* xres->ax */
- yres = pVBInfo->ModeResInfo[resindex].VTotal; /* yres->bx */
- /* si+St_ModeFlag */
- modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
- }
+ resindex = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO;
+ xres = pVBInfo->ModeResInfo[resindex].HTotal; /* xres->ax */
+ yres = pVBInfo->ModeResInfo[resindex].VTotal; /* yres->bx */
+ /* si+St_ModeFlag */
+ modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
if (!(modeflag & Charx8Dot)) {
xres /= 9;
xres *= 8;
}
- if (ModeNo > 0x13) {
- if ((ModeNo > 0x13) && (modeflag & HalfDCLK))
- xres *= 2;
-
- if ((ModeNo > 0x13) && (modeflag & DoubleScanMode))
- yres *= 2;
+ if ((ModeNo > 0x13) && (modeflag & HalfDCLK))
+ xres *= 2;
- }
+ if ((ModeNo > 0x13) && (modeflag & DoubleScanMode))
+ yres *= 2;
if (xres > xgifb_info->lvds_data.LVDSHDE)
return 0;
@@ -5851,16 +5169,11 @@ static unsigned char XGI_XG21CheckLVDSMode(struct xgifb_video_info *xgifb_info,
if (yres > xgifb_info->lvds_data.LVDSVDE)
return 0;
- if (ModeNo > 0x13) {
- if (xres != xgifb_info->lvds_data.LVDSHDE ||
- yres != xgifb_info->lvds_data.LVDSVDE) {
- colordepth = XGI_GetColorDepth(ModeNo,
- ModeIdIndex,
- pVBInfo);
- if (colordepth > 2)
- return 0;
-
- }
+ if (xres != xgifb_info->lvds_data.LVDSHDE ||
+ yres != xgifb_info->lvds_data.LVDSVDE) {
+ colordepth = XGI_GetColorDepth(ModeNo, ModeIdIndex, pVBInfo);
+ if (colordepth > 2)
+ return 0;
}
return 1;
}
@@ -5895,18 +5208,11 @@ static void xgifb_set_lvds(struct xgifb_video_info *xgifb_info,
else
XGI_SetXG21FPBits(pVBInfo);
- resindex = XGI_GetResInfo(ModeNo, ModeIdIndex, pVBInfo);
- if (ModeNo <= 0x13) {
- xres = pVBInfo->StResInfo[resindex].HTotal;
- yres = pVBInfo->StResInfo[resindex].VTotal;
- /* si+St_ResInfo */
- modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
- } else {
- xres = pVBInfo->ModeResInfo[resindex].HTotal; /* xres->ax */
- yres = pVBInfo->ModeResInfo[resindex].VTotal; /* yres->bx */
- /* si+St_ModeFlag */
- modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
- }
+ resindex = pVBInfo->EModeIDTable[ModeIdIndex].Ext_RESINFO;
+ xres = pVBInfo->ModeResInfo[resindex].HTotal; /* xres->ax */
+ yres = pVBInfo->ModeResInfo[resindex].VTotal; /* yres->bx */
+ /* si+St_ModeFlag */
+ modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
if (!(modeflag & Charx8Dot))
xres = xres * 8 / 9;
@@ -5914,8 +5220,6 @@ static void xgifb_set_lvds(struct xgifb_video_info *xgifb_info,
LVDSHT = xgifb_info->lvds_data.LVDSHT;
LVDSHBS = xres + (xgifb_info->lvds_data.LVDSHDE - xres) / 2;
- if ((ModeNo <= 0x13) && (modeflag & HalfDCLK))
- LVDSHBS -= xres / 4;
if (LVDSHBS > LVDSHT)
LVDSHBS -= LVDSHT;
@@ -5933,7 +5237,7 @@ static void xgifb_set_lvds(struct xgifb_video_info *xgifb_info,
LVDSVT = xgifb_info->lvds_data.LVDSVT;
LVDSVBS = yres + (xgifb_info->lvds_data.LVDSVDE - yres) / 2;
- if ((ModeNo > 0x13) && (modeflag & DoubleScanMode))
+ if (modeflag & DoubleScanMode)
LVDSVBS += yres / 2;
if (LVDSVBS > LVDSVT)
@@ -6155,7 +5459,8 @@ static void XGI_DisableBridge(struct xgifb_video_info *xgifb_info,
if (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) {
if (pVBInfo->VBInfo & SetCRT2ToDualEdge) {
tempah = 0x7F; /* Disable Channel A */
- if (!(pVBInfo->VBInfo & XGI_SetCRT2ToLCDA))
+ if (!(pVBInfo->VBInfo &
+ XGI_SetCRT2ToLCDA))
/* Disable Channel B */
tempah = 0xBF;
@@ -6174,9 +5479,10 @@ static void XGI_DisableBridge(struct xgifb_video_info *xgifb_info,
xgifb_reg_and(pVBInfo->Part4Port, 0x1F, tempah);
if (pVBInfo->VBType & (VB_SIS302LV | VB_XGI301C)) {
- if (((pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)))
- || (XGI_DisableChISLCD(pVBInfo))
- || (XGI_IsLCDON(pVBInfo)))
+ if (((pVBInfo->VBInfo &
+ (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)))
+ || (XGI_DisableChISLCD(pVBInfo))
+ || (XGI_IsLCDON(pVBInfo)))
/* LVDS Driver power down */
xgifb_reg_or(pVBInfo->Part4Port, 0x30, 0x80);
}
@@ -6331,32 +5637,20 @@ static void XGI_GetTVPtrIndex2(unsigned short *tempbx, unsigned char *tempcl,
static void XGI_SetDelayComp(struct vb_device_info *pVBInfo)
{
- unsigned short index;
-
unsigned char tempah, tempbl, tempbh;
if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV
| VB_SIS302LV | VB_XGI301C)) {
if (pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA
| SetCRT2ToTV | SetCRT2ToRAMDAC)) {
- tempbl = 0;
tempbh = 0;
-
- index = XGI_GetTVPtrIndex(pVBInfo); /* Get TV Delay */
- tempbl = pVBInfo->XGI_TVDelayList[index];
-
- if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B
- | VB_SIS301LV | VB_SIS302LV
- | VB_XGI301C))
- tempbl = pVBInfo->XGI_TVDelayList2[index];
+ tempbl = XGI301TVDelay;
if (pVBInfo->VBInfo & SetCRT2ToDualEdge)
tempbl = tempbl >> 4;
- if (pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)) {
- /* Get LCD Delay */
- index = XGI_GetLCDCapPtr(pVBInfo);
- tempbh = pVBInfo->LCDCapList[index].
- LCD_DelayCompensation;
+ if (pVBInfo->VBInfo &
+ (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)) {
+ tempbh = XGI301LCDDelay;
if (!(pVBInfo->VBInfo & XGI_SetCRT2ToLCDA))
tempbl = tempbh;
@@ -6372,7 +5666,8 @@ static void XGI_SetDelayComp(struct vb_device_info *pVBInfo)
tempah |= tempbl;
}
- if (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) { /* Channel A */
+ if (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) {
+ /* Channel A */
tempah &= 0x0F;
tempah |= tempbh;
}
@@ -6382,10 +5677,7 @@ static void XGI_SetDelayComp(struct vb_device_info *pVBInfo)
tempbl = 0;
tempbh = 0;
if (pVBInfo->VBInfo & SetCRT2ToLCD) {
- /* / Get LCD Delay */
- tempah = pVBInfo->LCDCapList[
- XGI_GetLCDCapPtr(pVBInfo)].
- LCD_DelayCompensation;
+ tempah = XGI301LCDDelay;
tempah &= 0x0f;
tempah = tempah << 4;
xgifb_reg_and_or(pVBInfo->Part1Port, 0x2D, 0x0f,
@@ -6527,7 +5819,7 @@ static void XGI_SetAntiFlicker(unsigned short ModeNo,
unsigned short ModeIdIndex,
struct vb_device_info *pVBInfo)
{
- unsigned short tempbx, index;
+ unsigned short tempbx;
unsigned char tempah;
@@ -6536,13 +5828,6 @@ static void XGI_SetAntiFlicker(unsigned short ModeNo,
tempbx = XGI_GetTVPtrIndex(pVBInfo);
tempbx &= 0xFE;
-
- if (ModeNo <= 0x13)
- index = pVBInfo->SModeIDTable[ModeIdIndex].VB_StTVFlickerIndex;
- else
- index = pVBInfo->EModeIDTable[ModeIdIndex].VB_ExtTVFlickerIndex;
-
- tempbx += index;
tempah = TVAntiFlickList[tempbx];
tempah = tempah << 4;
@@ -6553,19 +5838,12 @@ static void XGI_SetEdgeEnhance(unsigned short ModeNo,
unsigned short ModeIdIndex,
struct vb_device_info *pVBInfo)
{
- unsigned short tempbx, index;
+ unsigned short tempbx;
unsigned char tempah;
tempbx = XGI_GetTVPtrIndex(pVBInfo);
tempbx &= 0xFE;
-
- if (ModeNo <= 0x13)
- index = pVBInfo->SModeIDTable[ModeIdIndex].VB_StTVEdgeIndex;
- else
- index = pVBInfo->EModeIDTable[ModeIdIndex].VB_ExtTVEdgeIndex;
-
- tempbx += index;
tempah = TVEdgeList[tempbx];
tempah = tempah << 5;
@@ -6631,13 +5909,7 @@ static void XGI_SetYFilter(unsigned short ModeNo, unsigned short ModeIdIndex,
return;
}
- if (ModeNo <= 0x13)
- tempal = pVBInfo->SModeIDTable[ModeIdIndex].
- VB_StTVYFilterIndex;
- else
- tempal = pVBInfo->EModeIDTable[ModeIdIndex].
- VB_ExtTVYFilterIndex;
-
+ tempal = pVBInfo->EModeIDTable[ModeIdIndex].VB_ExtTVYFilterIndex;
if (tempcl == 0)
index = tempal * 4;
else
@@ -6712,16 +5984,14 @@ static void XGI_SetCRT2ModeRegs(unsigned short ModeNo,
if (pVBInfo->VBInfo & (SetCRT2ToRAMDAC | SetCRT2ToTV
| SetCRT2ToLCD)) {
tempah = 0x40; /* BTDRAM */
- if (ModeNo > 0x13) {
- tempcl = pVBInfo->ModeType;
- tempcl -= ModeVGA;
- if (tempcl >= 0) {
- /* BT Color */
- tempah = (0x008 >> tempcl);
- if (tempah == 0)
- tempah = 1;
- tempah |= 0x040;
- }
+ tempcl = pVBInfo->ModeType;
+ tempcl -= ModeVGA;
+ if (tempcl >= 0) {
+ /* BT Color */
+ tempah = (0x008 >> tempcl);
+ if (tempah == 0)
+ tempah = 1;
+ tempah |= 0x040;
}
if (pVBInfo->VBInfo & SetInSlaveMode)
tempah ^= 0x50; /* BTDAC */
@@ -6732,60 +6002,49 @@ static void XGI_SetCRT2ModeRegs(unsigned short ModeNo,
tempah = 0x08;
tempbl = 0xf0;
- if (pVBInfo->VBInfo & DisableCRT2Display) {
- xgifb_reg_and_or(pVBInfo->Part1Port, 0x2e, tempbl, tempah);
- } else {
- tempah = 0x00;
- tempbl = 0xff;
+ if (pVBInfo->VBInfo & DisableCRT2Display)
+ goto reg_and_or;
- if (pVBInfo->VBInfo & (SetCRT2ToRAMDAC | SetCRT2ToTV
- | SetCRT2ToLCD | XGI_SetCRT2ToLCDA)) {
- if ((pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) &&
- (!(pVBInfo->VBInfo & SetSimuScanMode))) {
- tempbl &= 0xf7;
- tempah |= 0x01;
- xgifb_reg_and_or(pVBInfo->Part1Port, 0x2e,
- tempbl, tempah);
- } else {
- if (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) {
- tempbl &= 0xf7;
- tempah |= 0x01;
- }
+ tempah = 0x00;
+ tempbl = 0xff;
- if (pVBInfo->VBInfo &
- (SetCRT2ToRAMDAC |
- SetCRT2ToTV |
- SetCRT2ToLCD)) {
- tempbl &= 0xf8;
- tempah = 0x01;
+ if (!(pVBInfo->VBInfo & (SetCRT2ToRAMDAC | SetCRT2ToTV |
+ SetCRT2ToLCD | XGI_SetCRT2ToLCDA)))
+ goto reg_and_or;
- if (!(pVBInfo->VBInfo & SetInSlaveMode))
- tempah |= 0x02;
+ if ((pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) &&
+ (!(pVBInfo->VBInfo & SetSimuScanMode))) {
+ tempbl &= 0xf7;
+ tempah |= 0x01;
+ goto reg_and_or;
+ }
- if (!(pVBInfo->VBInfo &
- SetCRT2ToRAMDAC)) {
- tempah = tempah ^ 0x05;
- if (!(pVBInfo->VBInfo &
- SetCRT2ToLCD))
- tempah = tempah ^ 0x01;
- }
+ if (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) {
+ tempbl &= 0xf7;
+ tempah |= 0x01;
+ }
- if (!(pVBInfo->VBInfo &
- SetCRT2ToDualEdge))
- tempah |= 0x08;
- xgifb_reg_and_or(pVBInfo->Part1Port,
- 0x2e, tempbl, tempah);
- } else {
- xgifb_reg_and_or(pVBInfo->Part1Port,
- 0x2e, tempbl, tempah);
- }
- }
- } else {
- xgifb_reg_and_or(pVBInfo->Part1Port, 0x2e, tempbl,
- tempah);
- }
+ if (!(pVBInfo->VBInfo & (SetCRT2ToRAMDAC | SetCRT2ToTV | SetCRT2ToLCD)))
+ goto reg_and_or;
+
+ tempbl &= 0xf8;
+ tempah = 0x01;
+
+ if (!(pVBInfo->VBInfo & SetInSlaveMode))
+ tempah |= 0x02;
+
+ if (!(pVBInfo->VBInfo & SetCRT2ToRAMDAC)) {
+ tempah = tempah ^ 0x05;
+ if (!(pVBInfo->VBInfo & SetCRT2ToLCD))
+ tempah = tempah ^ 0x01;
}
+ if (!(pVBInfo->VBInfo & SetCRT2ToDualEdge))
+ tempah |= 0x08;
+
+reg_and_or:
+ xgifb_reg_and_or(pVBInfo->Part1Port, 0x2e, tempbl, tempah);
+
if (pVBInfo->VBInfo & (SetCRT2ToRAMDAC | SetCRT2ToTV | SetCRT2ToLCD
| XGI_SetCRT2ToLCDA)) {
tempah &= (~0x08);
@@ -6797,10 +6056,8 @@ static void XGI_SetCRT2ModeRegs(unsigned short ModeNo,
if (pVBInfo->VBInfo & SetCRT2ToTV) {
tempah |= 0x020;
- if (ModeNo > 0x13) {
- if (pVBInfo->VBInfo & DriverMode)
- tempah = tempah ^ 0x20;
- }
+ if (pVBInfo->VBInfo & DriverMode)
+ tempah = tempah ^ 0x20;
}
xgifb_reg_and_or(pVBInfo->Part4Port, 0x0D, ~0x0BF, tempah);
@@ -6872,17 +6129,6 @@ static void XGI_SetCRT2ModeRegs(unsigned short ModeNo,
}
}
-static void XGI_CloseCRTC(struct xgi_hw_device_info *HwDeviceExtension,
- struct vb_device_info *pVBInfo)
-{
- unsigned short tempbx;
-
- tempbx = 0;
-
- if (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA)
- tempbx = 0x08A0;
-
-}
void XGI_UnLockCRT2(struct xgi_hw_device_info *HwDeviceExtension,
struct vb_device_info *pVBInfo)
@@ -6925,13 +6171,7 @@ unsigned short XGI_GetRatePtrCRT2(struct xgi_hw_device_info *pXGIHWDE,
unsigned short RefreshRateTableIndex, i, modeflag, index, temp;
- if (ModeNo <= 0x13)
- modeflag = pVBInfo->SModeIDTable[ModeIdIndex].St_ModeFlag;
- else
- modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
-
- if (ModeNo < 0x14)
- return 0xFFFF;
+ modeflag = pVBInfo->EModeIDTable[ModeIdIndex].Ext_ModeFlag;
index = xgifb_reg_get(pVBInfo->P3d4, 0x33);
index = index >> pVBInfo->SelectCRT2Rate;
@@ -6971,8 +6211,7 @@ unsigned short XGI_GetRatePtrCRT2(struct xgi_hw_device_info *pXGIHWDE,
(pVBInfo->RefIndex[RefreshRateTableIndex].YRes == 600)) {
index++;
}
- /* Alan 10/19/2007;
- * do the similar adjustment like XGISearchCRT1Rate() */
+ /* do the similar adjustment like XGISearchCRT1Rate() */
if ((pVBInfo->RefIndex[RefreshRateTableIndex].XRes == 1024) &&
(pVBInfo->RefIndex[RefreshRateTableIndex].YRes == 768)) {
index++;
@@ -7080,7 +6319,7 @@ void XGI_SenseCRT1(struct vb_device_info *pVBInfo)
int i;
xgifb_reg_set(pVBInfo->P3c4, 0x05, 0x86);
- /* [2004/05/06] Vicent to fix XG42 single LCD sense to CRT+LCD */
+ /* to fix XG42 single LCD sense to CRT+LCD */
xgifb_reg_set(pVBInfo->P3d4, 0x57, 0x4A);
xgifb_reg_set(pVBInfo->P3d4, 0x53, (unsigned char) (xgifb_reg_get(
pVBInfo->P3d4, 0x53) | 0x02));
@@ -7145,7 +6384,7 @@ void XGI_SenseCRT1(struct vb_device_info *pVBInfo)
else
xgifb_reg_and_or(pVBInfo->P3d4, 0x32, 0xDF, 0x00);
- /* alan, avoid display something, set BLACK DAC if not restore DAC */
+ /* avoid display something, set BLACK DAC if not restore DAC */
outb(0x00, pVBInfo->P3c8);
for (i = 0; i < 256; i++) {
@@ -7158,7 +6397,6 @@ void XGI_SenseCRT1(struct vb_device_info *pVBInfo)
xgifb_reg_set(pVBInfo->P3d4, 0x63, CR63);
xgifb_reg_set(pVBInfo->P3c4, 0x31, SR31);
- /* [2004/05/11] Vicent */
xgifb_reg_set(pVBInfo->P3d4, 0x53, (unsigned char) (xgifb_reg_get(
pVBInfo->P3d4, 0x53) & 0xFD));
xgifb_reg_set(pVBInfo->P3c4, 0x1F, (unsigned char) SR1F);
@@ -7235,32 +6473,24 @@ static void XGI_EnableBridge(struct xgifb_video_info *xgifb_info,
if (!(pVBInfo->VBInfo & DisableCRT2Display)) {
tempah = 0xc0;
- if (!(pVBInfo->VBInfo & SetSimuScanMode)) {
- if (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) {
- if (pVBInfo->VBInfo &
- SetCRT2ToDualEdge) {
- tempah = tempah & 0x40;
- if (pVBInfo->VBInfo &
- XGI_SetCRT2ToLCDA)
- tempah = tempah ^ 0xC0;
-
- if (pVBInfo->SetFlag &
- DisableChB)
- tempah &= 0xBF;
-
- if (pVBInfo->SetFlag &
- DisableChA)
- tempah &= 0x7F;
-
- if (pVBInfo->SetFlag &
- EnableChB)
- tempah |= 0x40;
-
- if (pVBInfo->SetFlag &
- EnableChA)
- tempah |= 0x80;
- }
- }
+ if (!(pVBInfo->VBInfo & SetSimuScanMode) &&
+ (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) &&
+ (pVBInfo->VBInfo & SetCRT2ToDualEdge)) {
+ tempah = tempah & 0x40;
+ if (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA)
+ tempah = tempah ^ 0xC0;
+
+ if (pVBInfo->SetFlag & DisableChB)
+ tempah &= 0xBF;
+
+ if (pVBInfo->SetFlag & DisableChA)
+ tempah &= 0x7F;
+
+ if (pVBInfo->SetFlag & EnableChB)
+ tempah |= 0x40;
+
+ if (pVBInfo->SetFlag & EnableChA)
+ tempah |= 0x80;
}
}
@@ -7297,16 +6527,13 @@ static void XGI_SetCRT1Group(struct xgifb_video_info *xgifb_info,
unsigned short ModeNo, unsigned short ModeIdIndex,
struct vb_device_info *pVBInfo)
{
- unsigned short StandTableIndex, RefreshRateTableIndex, b3CC, temp;
-
- unsigned short XGINew_P3cc = pVBInfo->P3cc;
+ unsigned short RefreshRateTableIndex, temp;
- StandTableIndex = XGI_GetModePtr(ModeNo, ModeIdIndex, pVBInfo);
- XGI_SetSeqRegs(ModeNo, StandTableIndex, ModeIdIndex, pVBInfo);
- outb(pVBInfo->StandTable[StandTableIndex].MISC, pVBInfo->P3c2);
- XGI_SetCRTCRegs(HwDeviceExtension, StandTableIndex, pVBInfo);
- XGI_SetATTRegs(ModeNo, StandTableIndex, ModeIdIndex, pVBInfo);
- XGI_SetGRCRegs(StandTableIndex, pVBInfo);
+ XGI_SetSeqRegs(ModeNo, ModeIdIndex, pVBInfo);
+ outb(pVBInfo->StandTable->MISC, pVBInfo->P3c2);
+ XGI_SetCRTCRegs(HwDeviceExtension, pVBInfo);
+ XGI_SetATTRegs(ModeNo, ModeIdIndex, pVBInfo);
+ XGI_SetGRCRegs(pVBInfo);
XGI_ClearExt1Regs(pVBInfo);
if (HwDeviceExtension->jChipType == XG27) {
@@ -7340,22 +6567,6 @@ static void XGI_SetCRT1Group(struct xgifb_video_info *xgifb_info,
RefreshRateTableIndex, pVBInfo);
}
- if ((HwDeviceExtension->jChipType >= XG20) &&
- (HwDeviceExtension->jChipType < XG27)) { /* fix H/W DCLK/2 bug */
- if ((ModeNo == 0x00) | (ModeNo == 0x01)) {
- xgifb_reg_set(pVBInfo->P3c4, 0x2B, 0x4E);
- xgifb_reg_set(pVBInfo->P3c4, 0x2C, 0xE9);
- b3CC = (unsigned char) inb(XGINew_P3cc);
- outb((b3CC |= 0x0C), XGINew_P3cc);
- } else if ((ModeNo == 0x04) | (ModeNo == 0x05) | (ModeNo
- == 0x0D)) {
- xgifb_reg_set(pVBInfo->P3c4, 0x2B, 0x1B);
- xgifb_reg_set(pVBInfo->P3c4, 0x2C, 0xE3);
- b3CC = (unsigned char) inb(XGINew_P3cc);
- outb((b3CC |= 0x0C), XGINew_P3cc);
- }
- }
-
if (HwDeviceExtension->jChipType >= XG21) {
temp = xgifb_reg_get(pVBInfo->P3d4, 0x38);
if (temp & 0xA0) {
@@ -7394,11 +6605,11 @@ unsigned char XGISetModeNew(struct xgifb_video_info *xgifb_info,
unsigned short ModeIdIndex;
struct vb_device_info VBINF;
struct vb_device_info *pVBInfo = &VBINF;
- pVBInfo->BaseAddr = (unsigned long) HwDeviceExtension->pjIOAddress;
+ pVBInfo->BaseAddr = xgifb_info->vga_base;
pVBInfo->IF_DEF_LVDS = 0;
pVBInfo->IF_DEF_LCDA = 1;
- if (HwDeviceExtension->jChipType >= XG20) { /* kuku 2004/06/25 */
+ if (HwDeviceExtension->jChipType >= XG20) {
pVBInfo->IF_DEF_YPbPr = 0;
pVBInfo->IF_DEF_HiVision = 0;
pVBInfo->IF_DEF_CRT2Monitor = 0;
@@ -7440,7 +6651,7 @@ unsigned char XGISetModeNew(struct xgifb_video_info *xgifb_info,
}
}
- if (HwDeviceExtension->jChipType < XG20) /* kuku 2004/06/25 */
+ if (HwDeviceExtension->jChipType < XG20)
XGI_GetVBType(pVBInfo);
InitTo330Pointer(HwDeviceExtension->jChipType, pVBInfo);
@@ -7448,12 +6659,12 @@ unsigned char XGISetModeNew(struct xgifb_video_info *xgifb_info,
ModeNo = ModeNo & 0x7F;
xgifb_reg_set(pVBInfo->P3c4, 0x05, 0x86);
- if (HwDeviceExtension->jChipType < XG20) /* kuku 2004/06/25 1.Openkey */
+ if (HwDeviceExtension->jChipType < XG20)
XGI_UnLockCRT2(HwDeviceExtension, pVBInfo);
XGI_SearchModeID(ModeNo, &ModeIdIndex, pVBInfo);
- if (HwDeviceExtension->jChipType < XG20) { /* kuku 2004/06/25 */
+ if (HwDeviceExtension->jChipType < XG20) {
XGI_GetVBInfo(ModeNo, ModeIdIndex, HwDeviceExtension, pVBInfo);
XGI_GetTVInfo(ModeNo, ModeIdIndex, pVBInfo);
XGI_GetLCDInfo(ModeNo, ModeIdIndex, pVBInfo);
@@ -7499,7 +6710,6 @@ unsigned char XGISetModeNew(struct xgifb_video_info *xgifb_info,
XGI_SetCRT2ModeRegs(ModeNo, HwDeviceExtension, pVBInfo);
XGI_OEM310Setting(ModeNo, ModeIdIndex, pVBInfo); /*0212*/
- XGI_CloseCRTC(HwDeviceExtension, pVBInfo);
XGI_EnableBridge(xgifb_info, HwDeviceExtension, pVBInfo);
} /* !XG20 */
else {
@@ -7509,13 +6719,8 @@ unsigned char XGISetModeNew(struct xgifb_video_info *xgifb_info,
pVBInfo))
return 0;
- if (ModeNo <= 0x13) {
- pVBInfo->ModeType = pVBInfo->SModeIDTable[ModeIdIndex].
- St_ModeFlag & ModeTypeMask;
- } else {
- pVBInfo->ModeType = pVBInfo->EModeIDTable[ModeIdIndex].
+ pVBInfo->ModeType = pVBInfo->EModeIDTable[ModeIdIndex].
Ext_ModeFlag & ModeTypeMask;
- }
pVBInfo->SetFlag = 0;
pVBInfo->VBInfo = DisableCRT2Display;
@@ -7530,9 +6735,8 @@ unsigned char XGISetModeNew(struct xgifb_video_info *xgifb_info,
XGI_UpdateModeInfo(HwDeviceExtension, pVBInfo);
- if (HwDeviceExtension->jChipType < XG20) { /* kuku 2004/06/25 */
+ if (HwDeviceExtension->jChipType < XG20)
XGI_LockCRT2(HwDeviceExtension, pVBInfo);
- }
return 1;
}
diff --git a/drivers/staging/xgifb/vb_struct.h b/drivers/staging/xgifb/vb_struct.h
index a5bd56af92b1..22c8eb9810d6 100644
--- a/drivers/staging/xgifb/vb_struct.h
+++ b/drivers/staging/xgifb/vb_struct.h
@@ -10,28 +10,11 @@ struct XGI_LVDSCRT1VDataStruct {
unsigned char Reg[7];
};
-struct XGI_StStruct {
- unsigned char St_ModeID;
- unsigned short St_ModeFlag;
- unsigned char St_StTableIndex;
- unsigned char St_CRT2CRTC;
- unsigned char St_CRT2CRTC2;
- unsigned char St_ResInfo;
- unsigned char VB_StTVFlickerIndex;
- unsigned char VB_StTVEdgeIndex;
- unsigned char VB_StTVYFilterIndex;
-};
-
struct XGI_ExtStruct {
unsigned char Ext_ModeID;
unsigned short Ext_ModeFlag;
unsigned short Ext_ModeInfo;
- unsigned short Ext_Point;
- unsigned short Ext_VESAID;
- unsigned char Ext_VESAMEMSize;
unsigned char Ext_RESINFO;
- unsigned char VB_ExtTVFlickerIndex;
- unsigned char VB_ExtTVEdgeIndex;
unsigned char VB_ExtTVYFilterIndex;
unsigned char REFindex;
};
@@ -45,7 +28,6 @@ struct XGI_Ext2Struct {
unsigned char ModeID;
unsigned short XRes;
unsigned short YRes;
- /* unsigned short ROM_OFFSET; */
};
struct XGI_ECLKDataStruct {
@@ -68,21 +50,6 @@ struct XGI_LCDDataTablStruct {
unsigned short DATAPTR;
};
-struct XGI330_LCDDataDesStruct {
- unsigned short LCDHDES;
- unsigned short LCDHRS;
- unsigned short LCDVDES;
- unsigned short LCDVRS;
-};
-
-
-struct XGI330_LVDSDataStruct {
- unsigned short VGAHT;
- unsigned short VGAVT;
- unsigned short LCDHT;
- unsigned short LCDVT;
-};
-
struct XGI330_LCDDataDesStruct2 {
unsigned short LCDHDES;
unsigned short LCDHRS;
@@ -92,15 +59,6 @@ struct XGI330_LCDDataDesStruct2 {
unsigned short LCDVSync;
};
-struct XGI330_LCDDataStruct {
- unsigned short RVBHCMAX;
- unsigned short RVBHCFACT;
- unsigned short VGAHT;
- unsigned short VGAVT;
- unsigned short LCDHT;
- unsigned short LCDVT;
-};
-
struct XGI330_TVDataStruct {
unsigned short RVBHCMAX;
@@ -128,13 +86,6 @@ struct XGI330_TVDataTablStruct {
};
-struct XGI330_CHTVDataStruct {
- unsigned short VGAHT;
- unsigned short VGAVT;
- unsigned short LCDHT;
- unsigned short LCDVT;
-};
-
struct XGI_TimingHStruct {
unsigned char data[8];
};
@@ -151,7 +102,6 @@ struct XGI330_LCDCapStruct {
unsigned char LCD_ID;
unsigned short LCD_Capability;
unsigned char LCD_SetFlag;
- unsigned char LCD_DelayCompensation;
unsigned char LCD_HSyncWidth;
unsigned char LCD_VSyncWidth;
unsigned char LCD_VCLK;
@@ -199,11 +149,6 @@ struct XGI_CRT1TableStruct {
};
-struct XGI330_VCLKDataStruct {
- unsigned char SR2B, SR2C;
- unsigned short CLOCK;
-};
-
struct XGI301C_Tap4TimingStruct {
unsigned short DE;
unsigned char Reg[64]; /* C0-FF */
@@ -221,7 +166,6 @@ struct vb_device_info {
unsigned short LCDHRS, LCDVRS, LCDHDES, LCDVDES;
unsigned short ModeType;
- /* ,IF_DEF_FSTN; add for dstn */
unsigned short IF_DEF_LVDS, IF_DEF_TRUMPION, IF_DEF_DSTN;
unsigned short IF_DEF_CRT2Monitor;
unsigned short IF_DEF_LCDA, IF_DEF_YPbPr;
@@ -236,7 +180,6 @@ struct vb_device_info {
void __iomem *FBAddr;
unsigned long BaseAddr;
- unsigned long RelIO;
unsigned char (*CR6B)[4];
unsigned char (*CR6E)[4];
@@ -246,50 +189,14 @@ struct vb_device_info {
unsigned char (*SR15)[8];
unsigned char (*CR40)[8];
- unsigned char *pSoftSetting;
- unsigned char *pOutputSelect;
-
- unsigned short *pRGBSenseData;
- unsigned short *pRGBSenseData2; /*301b*/
- unsigned short *pVideoSenseData;
- unsigned short *pVideoSenseData2;
- unsigned short *pYCSenseData;
- unsigned short *pYCSenseData2;
-
- unsigned char *pSR07;
- unsigned char *CR49;
- unsigned char *pSR1F;
unsigned char *AGPReg;
unsigned char *SR16;
- unsigned char *pSR21;
- unsigned char *pSR22;
- unsigned char *pSR23;
- unsigned char *pSR24;
- unsigned char *SR25;
- unsigned char *pSR31;
- unsigned char *pSR32;
- unsigned char *pSR33;
- unsigned char *pSR36; /* alan 12/07/2006 */
- unsigned char *pCRCF;
- unsigned char *pCRD0; /* alan 12/07/2006 */
- unsigned char *pCRDE; /* alan 12/07/2006 */
- unsigned char *pCR8F; /* alan 12/07/2006 */
- unsigned char *pSR40; /* alan 12/07/2006 */
- unsigned char *pSR41; /* alan 12/07/2006 */
- unsigned char *pDVOSetting;
- unsigned char *pCR2E;
- unsigned char *pCR2F;
- unsigned char *pCR46;
- unsigned char *pCR47;
- unsigned char *pCRT2Data_1_2;
- unsigned char *pCRT2Data_4_D;
- unsigned char *pCRT2Data_4_E;
- unsigned char *pCRT2Data_4_10;
+ unsigned char SR21;
+ unsigned char SR22;
+ unsigned char SR25;
struct SiS_MCLKData *MCLKData;
struct XGI_ECLKDataStruct *ECLKData;
- unsigned char *XGI_TVDelayList;
- unsigned char *XGI_TVDelayList2;
unsigned char *NTSCTiming;
unsigned char *PALTiming;
unsigned char *HiTVExtTiming;
@@ -306,19 +213,16 @@ struct vb_device_info {
unsigned char *Ren750pGroup3;
unsigned char *ScreenOffset;
unsigned char *pXGINew_DRAMTypeDefinition;
- unsigned char *pXGINew_I2CDefinition ;
- unsigned char *pXGINew_CR97 ;
+ unsigned char XGINew_CR97;
struct XGI330_LCDCapStruct *LCDCapList;
struct XGI_TimingHStruct *TimingH;
struct XGI_TimingVStruct *TimingV;
- struct XGI_StStruct *SModeIDTable;
struct SiS_StandTable_S *StandTable;
struct XGI_ExtStruct *EModeIDTable;
struct XGI_Ext2Struct *RefIndex;
- /* XGINew_CRT1TableStruct *CRT1Table; */
struct XGI_CRT1TableStruct *XGINEWUB_CRT1Table;
struct SiS_VCLKData *VCLKData;
struct SiS_VBVCLKData *VBVCLKData;
diff --git a/drivers/staging/xgifb/vb_table.h b/drivers/staging/xgifb/vb_table.h
index e8d6f674b274..1c168461411d 100644
--- a/drivers/staging/xgifb/vb_table.h
+++ b/drivers/staging/xgifb/vb_table.h
@@ -1,4 +1,5 @@
-/* yilin modify for xgi20 */
+#ifndef _VB_TABLE_
+#define _VB_TABLE_
static struct SiS_MCLKData XGI340New_MCLKData[] = {
{0x16, 0x01, 0x01, 166},
{0x19, 0x02, 0x01, 124},
@@ -21,7 +22,6 @@ static struct SiS_MCLKData XGI27New_MCLKData[] = {
{0x5c, 0x23, 0x01, 166}
};
-/* yilin modify for xgi20 */
static struct XGI_ECLKDataStruct XGI340_ECLKData[] = {
{0x5c, 0x23, 0x01, 166},
{0x55, 0x84, 0x01, 123},
@@ -128,616 +128,92 @@ static unsigned char XGI340_AGPReg[12] = {
static unsigned char XGI340_SR16[4] = {0x03, 0x83, 0x03, 0x83};
-static unsigned char XGI330_sr25[2];
-static unsigned char XGI330_sr31 = 0xc0;
-static unsigned char XGI330_sr32 = 0x11;
-static unsigned char XGI330_SR33;
-static unsigned char XG40_CRCF = 0x13;
-static unsigned char XG40_DRAMTypeDefinition = 0xFF ;
-
-static struct XGI_StStruct XGI330_SModeIDTable[] = {
- {0x01, 0x9208, 0x01, 0x00, 0x10, 0x00, 0x00, 0x01, 0x00},
- {0x01, 0x1210, 0x14, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00},
- {0x01, 0x1010, 0x17, 0x02, 0x11, 0x00, 0x00, 0x01, 0x01},
- {0x03, 0x8208, 0x03, 0x00, 0x14, 0x00, 0x00, 0x01, 0x02},
- {0x03, 0x0210, 0x16, 0x01, 0x04, 0x01, 0x00, 0x01, 0x02},
- {0x03, 0x0010, 0x18, 0x02, 0x15, 0x00, 0x00, 0x01, 0x03},
- {0x05, 0x9209, 0x05, 0x00, 0x10, 0x00, 0x00, 0x00, 0x04},
- {0x06, 0x8209, 0x06, 0x00, 0x14, 0x00, 0x00, 0x00, 0x05},
- {0x07, 0x0000, 0x07, 0x03, 0x05, 0x03, 0x00, 0x01, 0x03},
- {0x07, 0x0000, 0x19, 0x02, 0x15, 0x02, 0x00, 0x01, 0x03},
- {0x0d, 0x920a, 0x0d, 0x00, 0x10, 0x00, 0x00, 0x00, 0x04},
- {0x0e, 0x820a, 0x0e, 0x00, 0x14, 0x00, 0x00, 0x00, 0x05},
- {0x0f, 0x0202, 0x11, 0x01, 0x04, 0x01, 0x00, 0x00, 0x05},
- {0x10, 0x0212, 0x12, 0x01, 0x04, 0x01, 0x00, 0x00, 0x05},
- {0x11, 0x0212, 0x1a, 0x04, 0x24, 0x04, 0x00, 0x00, 0x05},
- {0x12, 0x0212, 0x1b, 0x04, 0x24, 0x04, 0x00, 0x00, 0x05},
- {0x13, 0x021b, 0x1c, 0x00, 0x14, 0x00, 0x00, 0x00, 0x04},
- {0x12, 0x0010, 0x18, 0x02, 0x24, 0x02, 0x00, 0x00, 0x05},/* St_CRT2CRTC2
- not sure */
- {0x12, 0x0210, 0x18, 0x01, 0x24, 0x01, 0x00, 0x00, 0x05},/* St_CRT2CRTC2
- not sure */
- {0xff, 0x0000, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
-};
-
-
static struct XGI_ExtStruct XGI330_EModeIDTable[] = {
- {0x6a, 0x2212, 0x0407, 0x3a81, 0x0102, 0x08,
- 0x07, 0x00, 0x00, 0x07, 0x0e},
- {0x2e, 0x0a1b, 0x0306, 0x3a57, 0x0101, 0x08,
- 0x06, 0x00, 0x00, 0x05, 0x06},
- {0x2f, 0x0a1b, 0x0305, 0x3a50, 0x0100, 0x08,
- 0x05, 0x00, 0x00, 0x05, 0x05},
- {0x30, 0x2a1b, 0x0407, 0x3a81, 0x0103, 0x08,
- 0x07, 0x00, 0x00, 0x07, 0x0e},
- {0x31, 0x0a1b, 0x030d, 0x3b85, 0x0000, 0x08,
- 0x0d, 0x00, 0x00, 0x06, 0x3d},
- {0x32, 0x0a1b, 0x0a0e, 0x3b8c, 0x0000, 0x08,
- 0x0e, 0x00, 0x00, 0x06, 0x3e},
- {0x33, 0x0a1d, 0x0a0d, 0x3b85, 0x0000, 0x08,
- 0x0d, 0x00, 0x00, 0x06, 0x3d},
- {0x34, 0x2a1d, 0x0a0e, 0x3b8c, 0x0000, 0x08,
- 0x0e, 0x00, 0x00, 0x06, 0x3e},
- {0x35, 0x0a1f, 0x0a0d, 0x3b85, 0x0000, 0x08,
- 0x0d, 0x00, 0x00, 0x06, 0x3d},
- {0x36, 0x2a1f, 0x0a0e, 0x3b8c, 0x0000, 0x08,
- 0x0e, 0x00, 0x00, 0x06, 0x3e},
- {0x37, 0x0212, 0x0508, 0x3aab, 0x0104, 0x08,
- 0x08, 0x00, 0x00, 0x00, 0x16},
- {0x38, 0x0a1b, 0x0508, 0x3aab, 0x0105, 0x08,
- 0x08, 0x00, 0x00, 0x00, 0x16},
- {0x3a, 0x0e3b, 0x0609, 0x3adc, 0x0107, 0x08,
- 0x09, 0x00, 0x00, 0x00, 0x1e},
- {0x3c, 0x0e3b, 0x070a, 0x3af2, 0x0130, 0x08,
- 0x0a, 0x00, 0x00, 0x00, 0x22}, /* mode 1600x1200
+ {0x2e, 0x0a1b, 0x0306, 0x06, 0x05, 0x06},
+ {0x2f, 0x0a1b, 0x0305, 0x05, 0x05, 0x05},
+ {0x30, 0x2a1b, 0x0407, 0x07, 0x07, 0x0e},
+ {0x31, 0x0a1b, 0x030d, 0x0d, 0x06, 0x3d},
+ {0x32, 0x0a1b, 0x0a0e, 0x0e, 0x06, 0x3e},
+ {0x33, 0x0a1d, 0x0a0d, 0x0d, 0x06, 0x3d},
+ {0x34, 0x2a1d, 0x0a0e, 0x0e, 0x06, 0x3e},
+ {0x35, 0x0a1f, 0x0a0d, 0x0d, 0x06, 0x3d},
+ {0x36, 0x2a1f, 0x0a0e, 0x0e, 0x06, 0x3e},
+ {0x38, 0x0a1b, 0x0508, 0x08, 0x00, 0x16},
+ {0x3a, 0x0e3b, 0x0609, 0x09, 0x00, 0x1e},
+ {0x3c, 0x0e3b, 0x070a, 0x0a, 0x00, 0x22}, /* mode 1600x1200
add CRT2MODE [2003/10/07] */
- {0x3d, 0x0e7d, 0x070a, 0x3af2, 0x0131, 0x08,
- 0x0a, 0x00, 0x00, 0x00, 0x22}, /* mode 1600x1200
+ {0x3d, 0x0e7d, 0x070a, 0x0a, 0x00, 0x22}, /* mode 1600x1200
add CRT2MODE */
- {0x40, 0x9a1c, 0x0000, 0x3a34, 0x010d, 0x08,
- 0x00, 0x00, 0x00, 0x04, 0x00},
- {0x41, 0x9a1d, 0x0000, 0x3a34, 0x010e, 0x08,
- 0x00, 0x00, 0x00, 0x04, 0x00}, /* ModeIdIndex = 0x10 */
- {0x43, 0x0a1c, 0x0306, 0x3a57, 0x0110, 0x08,
- 0x06, 0x00, 0x00, 0x05, 0x06},
- {0x44, 0x0a1d, 0x0306, 0x3a57, 0x0111, 0x08,
- 0x06, 0x00, 0x00, 0x05, 0x06},
- {0x46, 0x2a1c, 0x0407, 0x3a81, 0x0113, 0x08,
- 0x07, 0x00, 0x00, 0x07, 0x0e},
- {0x47, 0x2a1d, 0x0407, 0x3a81, 0x0114, 0x08,
- 0x07, 0x00, 0x00, 0x07, 0x0e},
- {0x49, 0x0a3c, 0x0508, 0x3aab, 0x0116, 0x08,
- 0x08, 0x00, 0x00, 0x00, 0x16},
- {0x4a, 0x0a3d, 0x0508, 0x3aab, 0x0117, 0x08,
- 0x08, 0x00, 0x00, 0x00, 0x16},
- {0x4c, 0x0e7c, 0x0609, 0x3adc, 0x0119, 0x08,
- 0x09, 0x00, 0x00, 0x00, 0x1e},
- {0x4d, 0x0e7d, 0x0609, 0x3adc, 0x011a, 0x08,
- 0x09, 0x00, 0x00, 0x00, 0x1e},
- {0x50, 0x9a1b, 0x0001, 0x3a3b, 0x0132, 0x08,
- 0x01, 0x00, 0x00, 0x04, 0x02},
- {0x51, 0xba1b, 0x0103, 0x3a42, 0x0133, 0x08,
- 0x03, 0x00, 0x00, 0x07, 0x03},
- {0x52, 0x9a1b, 0x0204, 0x3a49, 0x0134, 0x08,
- 0x04, 0x00, 0x00, 0x00, 0x04},
- {0x56, 0x9a1d, 0x0001, 0x3a3b, 0x0135, 0x08,
- 0x01, 0x00, 0x00, 0x04, 0x02},
- {0x57, 0xba1d, 0x0103, 0x3a42, 0x0136, 0x08,
- 0x03, 0x00, 0x00, 0x07, 0x03},
- {0x58, 0x9a1d, 0x0204, 0x3a49, 0x0137, 0x08,
- 0x04, 0x00, 0x00, 0x00, 0x04},
- {0x59, 0x9a1b, 0x0000, 0x3a34, 0x0138, 0x08,
- 0x00, 0x00, 0x00, 0x04, 0x00},
- {0x5A, 0x021b, 0x0014, 0x3b83, 0x0138, 0x08,
- 0x01, 0x00, 0x00, 0x04, 0x3f}, /* ModeIdIndex = 0x20 */
- {0x5B, 0x0a1d, 0x0014, 0x3b83, 0x0135, 0x08,
- 0x01, 0x00, 0x00, 0x04, 0x3f},
- {0x5d, 0x0a1d, 0x0305, 0x3a50, 0x0139, 0x08,
- 0x05, 0x00, 0x00, 0x07, 0x05},
- {0x62, 0x0a3f, 0x0306, 0x3a57, 0x013a, 0x08,
- 0x06, 0x00, 0x00, 0x05, 0x06},
- {0x63, 0x2a3f, 0x0407, 0x3a81, 0x013b, 0x08,
- 0x07, 0x00, 0x00, 0x07, 0x0e},
- {0x64, 0x0a7f, 0x0508, 0x3aab, 0x013c, 0x08,
- 0x08, 0x00, 0x00, 0x00, 0x16},
- {0x65, 0x0eff, 0x0609, 0x3adc, 0x013d, 0x08,
- 0x09, 0x00, 0x00, 0x00, 0x1e},
- {0x66, 0x0eff, 0x070a, 0x3af2, 0x013e, 0x08,
- 0x0a, 0x00, 0x00, 0x00, 0x22}, /* mode 1600x1200
+ {0x40, 0x9a1c, 0x0000, 0x00, 0x04, 0x00},
+ {0x41, 0x9a1d, 0x0000, 0x00, 0x04, 0x00},
+ {0x43, 0x0a1c, 0x0306, 0x06, 0x05, 0x06},
+ {0x44, 0x0a1d, 0x0306, 0x06, 0x05, 0x06},
+ {0x46, 0x2a1c, 0x0407, 0x07, 0x07, 0x0e},
+ {0x47, 0x2a1d, 0x0407, 0x07, 0x07, 0x0e},
+ {0x49, 0x0a3c, 0x0508, 0x08, 0x00, 0x16},
+ {0x4a, 0x0a3d, 0x0508, 0x08, 0x00, 0x16},
+ {0x4c, 0x0e7c, 0x0609, 0x09, 0x00, 0x1e},
+ {0x4d, 0x0e7d, 0x0609, 0x09, 0x00, 0x1e},
+ {0x50, 0x9a1b, 0x0001, 0x01, 0x04, 0x02},
+ {0x51, 0xba1b, 0x0103, 0x03, 0x07, 0x03},
+ {0x52, 0x9a1b, 0x0204, 0x04, 0x00, 0x04},
+ {0x56, 0x9a1d, 0x0001, 0x01, 0x04, 0x02},
+ {0x57, 0xba1d, 0x0103, 0x03, 0x07, 0x03},
+ {0x58, 0x9a1d, 0x0204, 0x04, 0x00, 0x04},
+ {0x59, 0x9a1b, 0x0000, 0x00, 0x04, 0x00},
+ {0x5A, 0x021b, 0x0014, 0x01, 0x04, 0x3f},
+ {0x5B, 0x0a1d, 0x0014, 0x01, 0x04, 0x3f},
+ {0x5d, 0x0a1d, 0x0305, 0x05, 0x07, 0x05},
+ {0x62, 0x0a3f, 0x0306, 0x06, 0x05, 0x06},
+ {0x63, 0x2a3f, 0x0407, 0x07, 0x07, 0x0e},
+ {0x64, 0x0a7f, 0x0508, 0x08, 0x00, 0x16},
+ {0x65, 0x0eff, 0x0609, 0x09, 0x00, 0x1e},
+ {0x66, 0x0eff, 0x070a, 0x0a, 0x00, 0x22}, /* mode 1600x1200
add CRT2MODE */
- {0x68, 0x067b, 0x080b, 0x3b17, 0x013f, 0x08,
- 0x0b, 0x00, 0x00, 0x00, 0x29},
- {0x69, 0x06fd, 0x080b, 0x3b17, 0x0140, 0x08,
- 0x0b, 0x00, 0x00, 0x00, 0x29},
- {0x6b, 0x07ff, 0x080b, 0x3b17, 0x0141, 0x10,
- 0x0b, 0x00, 0x00, 0x00, 0x29},
- {0x6c, 0x067b, 0x090c, 0x3b37, 0x0000, 0x08,
- 0x0c, 0x00, 0x00, 0x00, 0x2f},
- {0x6d, 0x06fd, 0x090c, 0x3b37, 0x0000, 0x10,
- 0x0c, 0x00, 0x00, 0x00, 0x2f},
- {0x6e, 0x07ff, 0x090c, 0x3b37, 0x0000, 0x10,
- 0x0c, 0x00, 0x00, 0x00, 0x2f},
- {0x70, 0x2a1b, 0x0410, 0x3b52, 0x0000, 0x08,
- 0x10, 0x00, 0x00, 0x07, 0x34},
- {0x71, 0x0a1b, 0x0511, 0x3b63, 0x0000, 0x08,
- 0x11, 0x00, 0x00, 0x00, 0x37},
- {0x74, 0x0a1d, 0x0511, 0x3b63, 0x0000, 0x08,
- 0x11, 0x00, 0x00, 0x00, 0x37}, /* ModeIdIndex = 0x30 */
- {0x75, 0x0a3d, 0x0612, 0x3b74, 0x0000, 0x08,
- 0x12, 0x00, 0x00, 0x00, 0x3a},
- {0x76, 0x2a1f, 0x0410, 0x3b52, 0x0000, 0x08,
- 0x10, 0x00, 0x00, 0x07, 0x34},
- {0x77, 0x0a1f, 0x0511, 0x3b63, 0x0000, 0x08,
- 0x11, 0x00, 0x00, 0x00, 0x37},
- {0x78, 0x0a3f, 0x0612, 0x3b74, 0x0000, 0x08,
- 0x12, 0x00, 0x00, 0x00, 0x3a},
- {0x79, 0x0a3b, 0x0612, 0x3b74, 0x0000, 0x08,
- 0x12, 0x00, 0x00, 0x00, 0x3a},
- {0x7a, 0x2a1d, 0x0410, 0x3b52, 0x0000, 0x08,
- 0x10, 0x00, 0x00, 0x07, 0x34},
- {0x7b, 0x0e3b, 0x060f, 0x3ad0, 0x0000, 0x08,
- 0x0f, 0x00, 0x00, 0x00, 0x1d},
- {0x7c, 0x0e7d, 0x060f, 0x3ad0, 0x0000, 0x08,
- 0x0f, 0x00, 0x00, 0x00, 0x1d},
- {0x7d, 0x0eff, 0x060f, 0x3ad0, 0x0000, 0x08,
- 0x0f, 0x00, 0x00, 0x00, 0x1d},
- {0x20, 0x0e3b, 0x0D16, 0x49e0, 0x0000, 0x08,
- 0x16, 0x00, 0x00, 0x00, 0x43},
- {0x21, 0x0e7d, 0x0D16, 0x49e0, 0x0000, 0x08,
- 0x16, 0x00, 0x00, 0x00, 0x43},
- {0x22, 0x0eff, 0x0D16, 0x49e0, 0x0000, 0x08,
- 0x16, 0x00, 0x00, 0x00, 0x43},
- {0x23, 0x0e3b, 0x0614, 0x49d5, 0x0000, 0x08,
- 0x14, 0x00, 0x00, 0x00, 0x41},
- {0x24, 0x0e7d, 0x0614, 0x49d5, 0x0000, 0x08,
- 0x14, 0x00, 0x00, 0x00, 0x41},
- {0x25, 0x0eff, 0x0614, 0x49d5, 0x0000, 0x08,
- 0x14, 0x00, 0x00, 0x00, 0x41},
- {0x26, 0x063b, 0x0c15, 0x49dc, 0x0000, 0x08,
- 0x15, 0x00, 0x00, 0x00, 0x42}, /* ModeIdIndex = 0x40 */
- {0x27, 0x067d, 0x0c15, 0x49dc, 0x0000, 0x08,
- 0x15, 0x00, 0x00, 0x00, 0x42},
- {0x28, 0x06ff, 0x0c15, 0x49dc, 0x0000, 0x08,
- 0x15, 0x00, 0x00, 0x00, 0x42},
- {0xff, 0x0000, 0x0000, 0x0000, 0x0000, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00}
-};
-
-static struct SiS_StandTable_S XGI330_StandTable[] = {
-/* MD_0_200 */
- {
- 0x28, 0x18, 0x08, 0x0800,
- {0x09, 0x03, 0x00, 0x02},
- 0x63,
- {0x2d, 0x27, 0x28, 0x90, 0x2b, 0xa0, 0xbf, 0x1f,
- 0x00, 0xc7, 0x06, 0x07, 0x00, 0x00, 0x00, 0x00,
- 0x9c, 0x8e, 0x8f, 0x14, 0x1f, 0x96, 0xb9, 0xa3,
- 0xff},
- {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
- 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
- 0x08, 0x00, 0x0f, 0x00},
- {0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0e, 0x00,
- 0xff}
- },
-/* MD_1_200 */
- {
- 0x28, 0x18, 0x08, 0x0800,
- {0x09, 0x03, 0x00, 0x02},
- 0x63,
- {0x2d, 0x27, 0x28, 0x90, 0x2b, 0xa0, 0xbf, 0x1f,
- 0x00, 0xc7, 0x06, 0x07, 0x00, 0x00, 0x00, 0x00,
- 0x9c, 0x8e, 0x8f, 0x14, 0x1f, 0x96, 0xb9, 0xa3,
- 0xff},
- {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
- 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
- 0x08, 0x00, 0x0f, 0x00},
- {0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0e, 0x00,
- 0xff}
- },
-/* MD_2_200 */
- {
- 0x50, 0x18, 0x08, 0x1000,
- {0x01, 0x03, 0x00, 0x02},
- 0x63,
- {0x5f, 0x4f, 0x50, 0x82, 0x55, 0x81, 0xbf, 0x1f,
- 0x00, 0xc7, 0x06, 0x07, 0x00, 0x00, 0x00, 0x00,
- 0x9c, 0x8e, 0x8f, 0x28, 0x1f, 0x96, 0xb9, 0xa3,
- 0xff},
- {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
- 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
- 0x08, 0x00, 0x0f, 0x00},
- {0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0e, 0x00,
- 0xff}
- },
-/* MD_3_200 */
- {
- 0x50, 0x18, 0x08, 0x1000,
- {0x01, 0x03, 0x00, 0x02},
- 0x63,
- {0x5f, 0x4f, 0x50, 0x82, 0x55, 0x81, 0xbf, 0x1f,
- 0x00, 0xc7, 0x06, 0x07, 0x00, 0x00, 0x00, 0x00,
- 0x9c, 0x8e, 0x8f, 0x28, 0x1f, 0x96, 0xb9, 0xa3,
- 0xff},
- {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
- 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
- 0x08, 0x00, 0x0f, 0x00},
- {0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0e, 0x00,
- 0xff}
- },
-/* MD_4 */
- {
- 0x28, 0x18, 0x08, 0x4000,
- {0x09, 0x03, 0x00, 0x02},
- 0x63,
- {0x2d, 0x27, 0x28, 0x90, 0x2c, 0x80, 0xbf, 0x1f,
- 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x9c, 0x8e, 0x8f, 0x14, 0x00, 0x96, 0xb9, 0xa2,
- 0xff},
- {0x00, 0x13, 0x15, 0x17, 0x02, 0x04, 0x06, 0x07,
- 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
- 0x01, 0x00, 0x03, 0x00},
- {0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x0f, 0x00,
- 0xff}
- },
-/* MD_5 */
- {
- 0x28, 0x18, 0x08, 0x4000,
- {0x09, 0x03, 0x00, 0x02},
- 0x63,
- {0x2d, 0x27, 0x28, 0x90, 0x2c, 0x80, 0xbf, 0x1f,
- 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x9c, 0x8e, 0x8f, 0x14, 0x00, 0x96, 0xb9, 0xa2,
- 0xff},
- {0x00, 0x13, 0x15, 0x17, 0x02, 0x04, 0x06, 0x07,
- 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
- 0x01, 0x00, 0x03, 0x00},
- {0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x0f, 0x00,
- 0xff}
- },
-/* MD_6 */
- {
- 0x50, 0x18, 0x08, 0x4000,
- {0x01, 0x01, 0x00, 0x06},
- 0x63,
- {0x5f, 0x4f, 0x50, 0x82, 0x55, 0x81, 0xbf, 0x1f,
- 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x9c, 0x8e, 0x8f, 0x28, 0x00, 0x96, 0xb9, 0xc2,
- 0xff},
- {0x00, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17,
- 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17,
- 0x01, 0x00, 0x01, 0x00},
- {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0d, 0x00,
- 0xff}
- },
-/* MD_7 */
- {
- 0x50, 0x18, 0x0e, 0x1000,
- {0x00, 0x03, 0x00, 0x03},
- 0xa6,
- {0x5f, 0x4f, 0x50, 0x82, 0x55, 0x81, 0xbf, 0x1f,
- 0x00, 0x4d, 0x0b, 0x0c, 0x00, 0x00, 0x00, 0x00,
- 0x83, 0x85, 0x5d, 0x28, 0x0d, 0x63, 0xba, 0xa3,
- 0xff},
- {0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08,
- 0x10, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
- 0x0e, 0x00, 0x0f, 0x08},
- {0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0a, 0x00,
- 0xff}
- },
-/* MDA_DAC */
- {
- 0x00, 0x00, 0x00, 0x0000,
- {0x00, 0x00, 0x00, 0x15},
- 0x15,
- {0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15,
- 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x3f, 0x3f,
- 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x00, 0x00,
- 0x00},
- {0x00, 0x00, 0x00, 0x00, 0x00, 0x15, 0x15, 0x15,
- 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15,
- 0x15, 0x15, 0x15, 0x15},
- {0x15, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f,
- 0x3f}
- },
-/* CGA_DAC */
- {
- 0x00, 0x10, 0x04, 0x0114,
- {0x11, 0x09, 0x15, 0x00},
- 0x10,
- {0x04, 0x14, 0x01, 0x11, 0x09, 0x15, 0x2a, 0x3a,
- 0x2e, 0x3e, 0x2b, 0x3b, 0x2f, 0x3f, 0x2a, 0x3a,
- 0x2e, 0x3e, 0x2b, 0x3b, 0x2f, 0x3f, 0x00, 0x10,
- 0x04},
- {0x14, 0x01, 0x11, 0x09, 0x15, 0x00, 0x10, 0x04,
- 0x14, 0x01, 0x11, 0x09, 0x15, 0x2a, 0x3a, 0x2e,
- 0x3e, 0x2b, 0x3b, 0x2f},
- {0x3f, 0x2a, 0x3a, 0x2e, 0x3e, 0x2b, 0x3b, 0x2f,
- 0x3f}
- },
-/* EGA_DAC */
- {
- 0x00, 0x10, 0x04, 0x0114,
- {0x11, 0x05, 0x15, 0x20},
- 0x30,
- {0x24, 0x34, 0x21, 0x31, 0x25, 0x35, 0x08, 0x18,
- 0x0c, 0x1c, 0x09, 0x19, 0x0d, 0x1d, 0x28, 0x38,
- 0x2c, 0x3c, 0x29, 0x39, 0x2d, 0x3d, 0x02, 0x12,
- 0x06},
- {0x16, 0x03, 0x13, 0x07, 0x17, 0x22, 0x32, 0x26,
- 0x36, 0x23, 0x33, 0x27, 0x37, 0x0a, 0x1a, 0x0e,
- 0x1e, 0x0b, 0x1b, 0x0f},
- {0x1f, 0x2a, 0x3a, 0x2e, 0x3e, 0x2b, 0x3b, 0x2f,
- 0x3f}
- },
-/* VGA_DAC */
- {
- 0x00, 0x10, 0x04, 0x0114,
- {0x11, 0x09, 0x15, 0x2a},
- 0x3a,
- {0x2e, 0x3e, 0x2b, 0x3b, 0x2f, 0x3f, 0x00, 0x05,
- 0x08, 0x0b, 0x0e, 0x11, 0x14, 0x18, 0x1c, 0x20,
- 0x24, 0x28, 0x2d, 0x32, 0x38, 0x3f, 0x00, 0x10,
- 0x1f},
- {0x2f, 0x3f, 0x1f, 0x27, 0x2f, 0x37, 0x3f, 0x2d,
- 0x31, 0x36, 0x3a, 0x3f, 0x00, 0x07, 0x0e, 0x15,
- 0x1c, 0x0e, 0x11, 0x15},
- {0x18, 0x1c, 0x14, 0x16, 0x18, 0x1a, 0x1c, 0x00,
- 0x04}
- },
- {
- 0x08, 0x0c, 0x10, 0x0a08,
- {0x0c, 0x0e, 0x10, 0x0b},
- 0x0c,
- {0x0d, 0x0f, 0x10, 0x10, 0x01, 0x08, 0x00, 0x00,
- 0x00, 0x00, 0x01, 0x00, 0x02, 0x02, 0x01, 0x00,
- 0x04, 0x04, 0x01, 0x00, 0x05, 0x02, 0x05, 0x00,
- 0x06},
- {0x01, 0x06, 0x05, 0x06, 0x00, 0x08, 0x01, 0x08,
- 0x00, 0x07, 0x02, 0x07, 0x06, 0x07, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00},
- {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00}
- },
-/* MD_D */
- {
- 0x28, 0x18, 0x08, 0x2000,
- {0x09, 0x0f, 0x00, 0x06},
- 0x63,
- {0x2d, 0x27, 0x28, 0x90, 0x2c, 0x80, 0xbf, 0x1f,
- 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x9c, 0x8e, 0x8f, 0x14, 0x00, 0x96, 0xb9, 0xe3,
- 0xff},
- {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
- 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
- 0x01, 0x00, 0x0f, 0x00},
- {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f,
- 0xff}
- },
-/* MD_E */
- {
- 0x50, 0x18, 0x08, 0x4000,
- {0x01, 0x0f, 0x00, 0x06},
- 0x63,
- {0x5f, 0x4f, 0x50, 0x82, 0x55, 0x81, 0xbf, 0x1f,
- 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x9c, 0x8e, 0x8f, 0x28, 0x00, 0x96, 0xb9, 0xe3,
- 0xff},
- {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
- 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
- 0x01, 0x00, 0x0f, 0x00},
- {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f,
- 0xff}
- },
+ {0x68, 0x067b, 0x080b, 0x0b, 0x00, 0x29},
+ {0x69, 0x06fd, 0x080b, 0x0b, 0x00, 0x29},
+ {0x6b, 0x07ff, 0x080b, 0x0b, 0x00, 0x29},
+ {0x6c, 0x067b, 0x090c, 0x0c, 0x00, 0x2f},
+ {0x6d, 0x06fd, 0x090c, 0x0c, 0x00, 0x2f},
+ {0x6e, 0x07ff, 0x090c, 0x0c, 0x00, 0x2f},
+ {0x70, 0x2a1b, 0x0410, 0x10, 0x07, 0x34},
+ {0x71, 0x0a1b, 0x0511, 0x11, 0x00, 0x37},
+ {0x74, 0x0a1d, 0x0511, 0x11, 0x00, 0x37},
+ {0x75, 0x0a3d, 0x0612, 0x12, 0x00, 0x3a},
+ {0x76, 0x2a1f, 0x0410, 0x10, 0x07, 0x34},
+ {0x77, 0x0a1f, 0x0511, 0x11, 0x00, 0x37},
+ {0x78, 0x0a3f, 0x0612, 0x12, 0x00, 0x3a},
+ {0x79, 0x0a3b, 0x0612, 0x12, 0x00, 0x3a},
+ {0x7a, 0x2a1d, 0x0410, 0x10, 0x07, 0x34},
+ {0x7b, 0x0e3b, 0x060f, 0x0f, 0x00, 0x1d},
+ {0x7c, 0x0e7d, 0x060f, 0x0f, 0x00, 0x1d},
+ {0x7d, 0x0eff, 0x060f, 0x0f, 0x00, 0x1d},
+ {0x20, 0x0e3b, 0x0D16, 0x16, 0x00, 0x43},
+ {0x21, 0x0e7d, 0x0D16, 0x16, 0x00, 0x43},
+ {0x22, 0x0eff, 0x0D16, 0x16, 0x00, 0x43},
+ {0x23, 0x0e3b, 0x0614, 0x14, 0x00, 0x41},
+ {0x24, 0x0e7d, 0x0614, 0x14, 0x00, 0x41},
+ {0x25, 0x0eff, 0x0614, 0x14, 0x00, 0x41},
+ {0x26, 0x063b, 0x0c15, 0x15, 0x00, 0x42},
+ {0x27, 0x067d, 0x0c15, 0x15, 0x00, 0x42},
+ {0x28, 0x06ff, 0x0c15, 0x15, 0x00, 0x42},
+ {0xff, 0x0000, 0x0000, 0x00, 0x00, 0x00}
+};
+
+static struct SiS_StandTable_S XGI330_StandTable = {
/* ExtVGATable */
- {
- 0x00, 0x00, 0x00, 0x0000,
- {0x01, 0x0f, 0x00, 0x0e},
- 0x23,
- {0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0x0b, 0x3e,
- 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0xea, 0x8c, 0xdf, 0x28, 0x40, 0xe7, 0x04, 0xa3,
- 0xff},
- {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
- 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
- 0x01, 0x00, 0x00, 0x00},
- {0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x05, 0x0f,
- 0xff}
- },
-/* ROM_SAVEPTR */
- {
- 0x9f, 0x3b, 0x00, 0x00c0,
- {0x00, 0x00, 0x00, 0x00},
- 0x00,
- {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xbb, 0x3f,
- 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x1a, 0x00, 0xac, 0x3e, 0x00, 0xc0,
- 0x00},
- {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00},
- {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00}
- },
-/* MD_F */
- {
- 0x50, 0x18, 0x0e, 0x8000,
- {0x01, 0x0f, 0x00, 0x06},
- 0xa2,
- {0x5f, 0x4f, 0x50, 0x82, 0x55, 0x81, 0xbf, 0x1f,
- 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x82, 0x84, 0x5d, 0x28, 0x0f, 0x63, 0xba, 0xe3,
- 0xff},
- {0x00, 0x08, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00,
- 0x00, 0x08, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00,
- 0x0b, 0x00, 0x05, 0x00},
- {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x05,
- 0xff}
- },
-/* MD_10 */
- {
- 0x50, 0x18, 0x0e, 0x8000,
- {0x01, 0x0f, 0x00, 0x06},
- 0xa3,
- {0x5f, 0x4f, 0x50, 0x82, 0x55, 0x81, 0xbf, 0x1f,
- 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x82, 0x84, 0x5d, 0x28, 0x0f, 0x63, 0xba, 0xe3,
- 0xff},
- {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07,
- 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
- 0x01, 0x00, 0x0f, 0x00},
- {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f,
- 0xff}
- },
-/* MD_0_350 */
- {
- 0x28, 0x18, 0x0e, 0x0800,
- {0x09, 0x03, 0x00, 0x02},
- 0xa3,
- {0x2d, 0x27, 0x28, 0x90, 0x2b, 0xb1, 0xbf, 0x1f,
- 0x00, 0x4d, 0x0b, 0x0c, 0x00, 0x00, 0x00, 0x00,
- 0x83, 0x85, 0x5d, 0x14, 0x1f, 0x63, 0xba, 0xa3,
- 0xff},
- {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07,
- 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
- 0x08, 0x00, 0x0f, 0x00},
- {0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0e, 0x00,
- 0xff}
- },
-/* MD_1_350 */
- {
- 0x28, 0x18, 0x0e, 0x0800,
- {0x09, 0x03, 0x00, 0x02},
- 0xa3,
- {0x2d, 0x27, 0x28, 0x90, 0x2b, 0xa0, 0xbf, 0x1f,
- 0x00, 0x4d, 0x0b, 0x0c, 0x00, 0x00, 0x00, 0x00,
- 0x83, 0x85, 0x5d, 0x14, 0x1f, 0x63, 0xba, 0xa3,
- 0xff},
- {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07,
- 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
- 0x08, 0x00, 0x0f, 0x00},
- {0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0e, 0x00,
- 0xff}
- },
-/* MD_2_350 */
- {
- 0x50, 0x18, 0x0e, 0x1000,
- {0x01, 0x03, 0x00, 0x02},
- 0xa3,
- {0x5f, 0x4f, 0x50, 0x82, 0x55, 0x81, 0xbf, 0x1f,
- 0x00, 0x4d, 0x0b, 0x0c, 0x00, 0x00, 0x00, 0x00,
- 0x83, 0x85, 0x5d, 0x28, 0x1f, 0x63, 0xba, 0xa3,
- 0xff},
- {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07,
- 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
- 0x08, 0x00, 0x0f, 0x00},
- {0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0e, 0x00,
- 0xff}
- },
-/* MD_3_350 */
- {
- 0x50, 0x18, 0x0e, 0x1000,
- {0x01, 0x03, 0x00, 0x02},
- 0xa3,
- {0x5f, 0x4f, 0x50, 0x82, 0x55, 0x81, 0xbf, 0x1f,
- 0x00, 0x4d, 0x0b, 0x0c, 0x00, 0x00, 0x00, 0x00,
- 0x83, 0x85, 0x5d, 0x28, 0x1f, 0x63, 0xba, 0xa3,
- 0xff},
- {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07,
- 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
- 0x08, 0x00, 0x0f, 0x00},
- {0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0e, 0x00,
- 0xff}
- },
-/* MD_0_1_400 */
- {
- 0x28, 0x18, 0x10, 0x0800,
- {0x08, 0x03, 0x00, 0x02},
- 0x67,
- {0x2d, 0x27, 0x28, 0x90, 0x2b, 0xb1, 0xbf, 0x1f,
- 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, 0x00, 0x00,
- 0x9c, 0x8e, 0x8f, 0x14, 0x1f, 0x96, 0xb9, 0xa3,
- 0xff},
- {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07,
- 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
- 0x0c, 0x00, 0x0f, 0x08},
- {0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0e, 0x00,
- 0xff}
- },
-/* MD_2_3_400 */
- {
- 0x50, 0x18, 0x10, 0x1000,
- {0x00, 0x03, 0x00, 0x02},
- 0x67,
- {0x5f, 0x4f, 0x50, 0x82, 0x55, 0x81, 0xbf, 0x1f,
- 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, 0x00, 0x00,
- 0x9c, 0x8e, 0x8f, 0x28, 0x1f, 0x96, 0xb9, 0xa3,
- 0xff},
- {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07,
- 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
- 0x0c, 0x00, 0x0f, 0x08},
- {0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0e, 0x00,
- 0xff}
- },
-/* MD_7_400 */
- {
- 0x50, 0x18, 0x10, 0x1000,
- {0x00, 0x03, 0x00, 0x02},
- 0x66,
- {0x5f, 0x4f, 0x50, 0x82, 0x55, 0x81, 0xbf, 0x1f,
- 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, 0x00, 0x00,
- 0x9c, 0x8e, 0x8f, 0x28, 0x0f, 0x96, 0xb9, 0xa3,
- 0xff},
- {0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08,
- 0x10, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
- 0x0e, 0x00, 0x0f, 0x08},
- {0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0a, 0x00,
- 0xff}
- },
-/* MD_11 */
- {
- 0x50, 0x1d, 0x10, 0xa000,
- {0x01, 0x0f, 0x00, 0x06},
- 0xe3,
- {0x5f, 0x4f, 0x50, 0x82, 0x55, 0x81, 0x0b, 0x3e,
- 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0xe9, 0x8b, 0xdf, 0x28, 0x00, 0xe7, 0x04, 0xc3,
- 0xff},
- {0x00, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f,
- 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f,
- 0x01, 0x00, 0x0f, 0x00},
- {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x01,
- 0xff}
- },
-/* ExtEGATable */
- {
- 0x50, 0x1d, 0x10, 0xa000,
- {0x01, 0x0f, 0x00, 0x06},
- 0xe3,
- {0x5f, 0x4f, 0x50, 0x82, 0x55, 0x81, 0x0b, 0x3e,
- 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0xe9, 0x8b, 0xdf, 0x28, 0x00, 0xe7, 0x04, 0xe3,
- 0xff},
- {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07,
- 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
- 0x01, 0x00, 0x0f, 0x00},
- {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f,
- 0xff}
- },
-/* MD_13 */
- {
- 0x28, 0x18, 0x08, 0x2000,
- {0x01, 0x0f, 0x00, 0x0e},
- 0x63,
- {0x5f, 0x4f, 0x50, 0x82, 0x55, 0x81, 0xbf, 0x1f,
- 0x00, 0x41, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x9c, 0x8e, 0x8f, 0x28, 0x40, 0x96, 0xb9, 0xa3,
- 0xff},
- {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
- 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
- 0x41, 0x00, 0x0f, 0x00},
- {0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x05, 0x0f,
- 0xff}
- }
+ 0x00, 0x00, 0x00, 0x0000,
+ {0x01, 0x0f, 0x00, 0x0e},
+ 0x23,
+ {0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0x0b, 0x3e,
+ 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0xea, 0x8c, 0xdf, 0x28, 0x40, 0xe7, 0x04, 0xa3,
+ 0xff},
+ {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+ 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
+ 0x01, 0x00, 0x00, 0x00},
+ {0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x05, 0x0f,
+ 0xff}
};
static struct XGI_TimingHStruct XGI_TimingH[1];
@@ -935,7 +411,7 @@ static unsigned char XGI_CH7017LV1400x1050[] = {
0xAD, 0xDB, 0xF6, 0xAC, 0xE0, 0x02};
/*add for new UNIVGABIOS*/
-static struct XGI330_LCDDataStruct XGI_StLCD1024x768Data[] = {
+static struct SiS_LCDData XGI_StLCD1024x768Data[] = {
{62, 25, 800, 546, 1344, 806},
{32, 15, 930, 546, 1344, 806},
{62, 25, 800, 546, 1344, 806}, /*chiawenfordot9->dot8*/
@@ -945,14 +421,10 @@ static struct XGI330_LCDDataStruct XGI_StLCD1024x768Data[] = {
{1, 1, 1344, 806, 1344, 806}
};
-static struct XGI330_LCDDataStruct XGI_ExtLCD1024x768Data[] = {
- /* { 12, 5, 896, 512,1344, 806}, // alan 09/12/2003 */
+static struct SiS_LCDData XGI_ExtLCD1024x768Data[] = {
{42, 25, 1536, 419, 1344, 806},
- /* { 12, 5, 896, 510,1344, 806}, // alan 09/12/2003 */
{48, 25, 1536, 369, 1344, 806},
- /* { 32, 15,1008, 505,1344, 806}, // alan 09/12/2003 */
{42, 25, 1536, 419, 1344, 806},
- /* { 32, 15,1008, 514,1344, 806}, // alan 09/12/2003 */
{48, 25, 1536, 369, 1344, 806},
{12, 5, 896, 500, 1344, 806},
{42, 25, 1024, 625, 1344, 806},
@@ -965,7 +437,7 @@ static struct XGI330_LCDDataStruct XGI_ExtLCD1024x768Data[] = {
{1, 1, 1344, 806, 1344, 806}
};
-static struct XGI330_LCDDataStruct XGI_CetLCD1024x768Data[] = {
+static struct SiS_LCDData XGI_CetLCD1024x768Data[] = {
{1, 1, 1344, 806, 1344, 806}, /* ; 00 (320x200,320x400,
640x200,640x400) */
{1, 1, 1344, 806, 1344, 806}, /* 01 (320x350,640x350) */
@@ -976,7 +448,7 @@ static struct XGI330_LCDDataStruct XGI_CetLCD1024x768Data[] = {
{1, 1, 1344, 806, 1344, 806} /* 06 (1024x768x60Hz) */
};
-static struct XGI330_LCDDataStruct XGI_StLCD1280x1024Data[] = {
+static struct SiS_LCDData XGI_StLCD1280x1024Data[] = {
{22, 5, 800, 510, 1650, 1088},
{22, 5, 800, 510, 1650, 1088},
{176, 45, 900, 510, 1650, 1088},
@@ -987,7 +459,7 @@ static struct XGI330_LCDDataStruct XGI_StLCD1280x1024Data[] = {
{1, 1, 1688, 1066, 1688, 1066}
};
-static struct XGI330_LCDDataStruct XGI_ExtLCD1280x1024Data[] = {
+static struct SiS_LCDData XGI_ExtLCD1280x1024Data[] = {
{211, 60, 1024, 501, 1688, 1066},
{211, 60, 1024, 508, 1688, 1066},
{211, 60, 1024, 501, 1688, 1066},
@@ -998,7 +470,7 @@ static struct XGI330_LCDDataStruct XGI_ExtLCD1280x1024Data[] = {
{1, 1, 1688, 1066, 1688, 1066}
};
-static struct XGI330_LCDDataStruct XGI_CetLCD1280x1024Data[] = {
+static struct SiS_LCDData XGI_CetLCD1280x1024Data[] = {
{1, 1, 1688, 1066, 1688, 1066}, /* 00 (320x200,320x400,
640x200,640x400) */
{1, 1, 1688, 1066, 1688, 1066}, /* 01 (320x350,640x350) */
@@ -1011,7 +483,7 @@ static struct XGI330_LCDDataStruct XGI_CetLCD1280x1024Data[] = {
{1, 1, 1688, 1066, 1688, 1066} /* 08 (1400x1050x60Hz) */
};
-static struct XGI330_LCDDataStruct xgifb_lcd_1400x1050[] = {
+static struct SiS_LCDData xgifb_lcd_1400x1050[] = {
{211, 100, 2100, 408, 1688, 1066}, /* 00 (320x200,320x400,
640x200,640x400) */
{211, 64, 1536, 358, 1688, 1066}, /* 01 (320x350,640x350) */
@@ -1025,15 +497,11 @@ static struct XGI330_LCDDataStruct xgifb_lcd_1400x1050[] = {
{1, 1, 1688, 1066, 1688, 1066} /* 08 (1400x1050x60Hz) */
};
-static struct XGI330_LCDDataStruct XGI_ExtLCD1600x1200Data[] = {
- {4, 1, 1620, 420, 2160, 1250}, /* { 3,1,2160,425,2160,1250 },
- // 00 (320x200,320x400,
- // 640x200,640x400)
- // // alan 10/14/2003 */
+static struct SiS_LCDData XGI_ExtLCD1600x1200Data[] = {
+ {4, 1, 1620, 420, 2160, 1250}, /* 00 (320x200,320x400,
+ 640x200,640x400)*/
{27, 7, 1920, 375, 2160, 1250}, /* 01 (320x350,640x350) */
- {4, 1, 1620, 420, 2160, 1250}, /* { 3,1,2160,425,2160,1250 },
- // 02 (360x400,720x400)
- // // alan 10/14/2003 */
+ {4, 1, 1620, 420, 2160, 1250}, /* 02 (360x400,720x400)*/
{27, 7, 1920, 375, 2160, 1250}, /* 03 (720x350) */
{27, 4, 800, 500, 2160, 1250}, /* 04 (640x480x60Hz) */
{4, 1, 1080, 625, 2160, 1250}, /* 05 (800x600x60Hz) */
@@ -1043,7 +511,7 @@ static struct XGI330_LCDDataStruct XGI_ExtLCD1600x1200Data[] = {
{1, 1, 2160, 1250, 2160, 1250} /* 09 (1600x1200x60Hz) ;302lv */
};
-static struct XGI330_LCDDataStruct XGI_StLCD1600x1200Data[] = {
+static struct SiS_LCDData XGI_StLCD1600x1200Data[] = {
{27, 4, 800, 500, 2160, 1250}, /* 00 (320x200,320x400,
640x200,640x400) */
{27, 4, 800, 500, 2160, 1250}, /* 01 (320x350,640x350) */
@@ -1057,7 +525,7 @@ static struct XGI330_LCDDataStruct XGI_StLCD1600x1200Data[] = {
{1, 1, 2160, 1250, 2160, 1250} /* 09 (1600x1200) */
};
-static struct XGI330_LCDDataStruct XGI_CetLCD1400x1050Data[] = {
+static struct SiS_LCDData XGI_CetLCD1400x1050Data[] = {
{1, 1, 1688, 1066, 1688, 1066}, /* 00 (320x200,320x400,
640x200,640x400) */
{1, 1, 1688, 1066, 1688, 1066}, /* 01 (320x350,640x350) */
@@ -1070,7 +538,7 @@ static struct XGI330_LCDDataStruct XGI_CetLCD1400x1050Data[] = {
{1, 1, 1688, 1066, 1688, 1066} /* 08 (1400x1050x60Hz) */
};
-static struct XGI330_LCDDataStruct XGI_NoScalingData[] = {
+static struct SiS_LCDData XGI_NoScalingData[] = {
{1, 1, 800, 449, 800, 449},
{1, 1, 800, 449, 800, 449},
{1, 1, 900, 449, 900, 449},
@@ -1081,7 +549,7 @@ static struct XGI330_LCDDataStruct XGI_NoScalingData[] = {
{1, 1, 1688, 1066, 1688, 1066}
};
-static struct XGI330_LCDDataStruct XGI_ExtLCD1024x768x75Data[] = {
+static struct SiS_LCDData XGI_ExtLCD1024x768x75Data[] = {
{42, 25, 1536, 419, 1344, 806}, /* ; 00 (320x200,320x400,
640x200,640x400) */
{48, 25, 1536, 369, 1344, 806}, /* ; 01 (320x350,640x350) */
@@ -1092,7 +560,7 @@ static struct XGI330_LCDDataStruct XGI_ExtLCD1024x768x75Data[] = {
{1, 1, 1312, 800, 1312, 800} /* ; 06 (1024x768x75Hz) */
};
-static struct XGI330_LCDDataStruct XGI_CetLCD1024x768x75Data[] = {
+static struct SiS_LCDData XGI_CetLCD1024x768x75Data[] = {
{1, 1, 1312, 800, 1312, 800}, /* ; 00 (320x200,320x400,
640x200,640x400) */
{1, 1, 1312, 800, 1312, 800}, /* ; 01 (320x350,640x350) */
@@ -1103,7 +571,7 @@ static struct XGI330_LCDDataStruct XGI_CetLCD1024x768x75Data[] = {
{1, 1, 1312, 800, 1312, 800} /* ; 06 (1024x768x75Hz) */
};
-static struct XGI330_LCDDataStruct xgifb_lcd_1280x1024x75[] = {
+static struct SiS_LCDData xgifb_lcd_1280x1024x75[] = {
{211, 60, 1024, 501, 1688, 1066}, /* ; 00 (320x200,320x400,
640x200,640x400) */
{211, 60, 1024, 508, 1688, 1066}, /* ; 01 (320x350,640x350) */
@@ -1115,7 +583,7 @@ static struct XGI330_LCDDataStruct xgifb_lcd_1280x1024x75[] = {
{1, 1, 1688, 1066, 1688, 1066} /* ; 07 (1280x1024x75Hz) */
};
-static struct XGI330_LCDDataStruct XGI_CetLCD1280x1024x75Data[] = {
+static struct SiS_LCDData XGI_CetLCD1280x1024x75Data[] = {
{1, 1, 1688, 1066, 1688, 1066}, /* ; 00 (320x200,320x400,
640x200,640x400) */
{1, 1, 1688, 1066, 1688, 1066}, /* ; 01 (320x350,640x350) */
@@ -1127,7 +595,7 @@ static struct XGI330_LCDDataStruct XGI_CetLCD1280x1024x75Data[] = {
{1, 1, 1688, 1066, 1688, 1066} /* ; 07 (1280x1024x75Hz) */
};
-static struct XGI330_LCDDataStruct XGI_NoScalingDatax75[] = {
+static struct SiS_LCDData XGI_NoScalingDatax75[] = {
{1, 1, 800, 449, 800, 449}, /* ; 00 (320x200, 320x400,
640x200, 640x400) */
{1, 1, 800, 449, 800, 449}, /* ; 01 (320x350, 640x350) */
@@ -1137,13 +605,12 @@ static struct XGI330_LCDDataStruct XGI_NoScalingDatax75[] = {
{1, 1, 1056, 625, 1056, 625}, /* ; 05 (800x600x75Hz) */
{1, 1, 1312, 800, 1312, 800}, /* ; 06 (1024x768x75Hz) */
{1, 1, 1688, 1066, 1688, 1066}, /* ; 07 (1280x1024x75Hz) */
- {1, 1, 1688, 1066, 1688, 1066}, /* ; 08 (1400x1050x75Hz)
- ;;[ycchen] 12/19/02 */
+ {1, 1, 1688, 1066, 1688, 1066}, /* ; 08 (1400x1050x75Hz)*/
{1, 1, 2160, 1250, 2160, 1250}, /* ; 09 (1600x1200x75Hz) */
{1, 1, 1688, 806, 1688, 806} /* ; 0A (1280x768x75Hz) */
};
-static struct XGI330_LCDDataDesStruct XGI_ExtLCDDes1024x768Data[] = {
+static struct XGI_LCDDesStruct XGI_ExtLCDDes1024x768Data[] = {
{9, 1057, 0, 771}, /* ; 00 (320x200,320x400,640x200,640x400) */
{9, 1057, 0, 771}, /* ; 01 (320x350,640x350) */
{9, 1057, 0, 771}, /* ; 02 (360x400,720x400) */
@@ -1153,7 +620,7 @@ static struct XGI330_LCDDataDesStruct XGI_ExtLCDDes1024x768Data[] = {
{9, 1057, 805, 770} /* ; 06 (1024x768x60Hz) */
};
-static struct XGI330_LCDDataDesStruct XGI_StLCDDes1024x768Data[] = {
+static struct XGI_LCDDesStruct XGI_StLCDDes1024x768Data[] = {
{9, 1057, 737, 703}, /* ; 00 (320x200,320x400,640x200,640x400) */
{9, 1057, 686, 651}, /* ; 01 (320x350,640x350) */
{9, 1057, 737, 703}, /* ; 02 (360x400,720x400) */
@@ -1163,7 +630,7 @@ static struct XGI330_LCDDataDesStruct XGI_StLCDDes1024x768Data[] = {
{9, 1057, 805, 770} /* ; 06 (1024x768x60Hz) */
};
-static struct XGI330_LCDDataDesStruct XGI_CetLCDDes1024x768Data[] = {
+static struct XGI_LCDDesStruct XGI_CetLCDDes1024x768Data[] = {
{1152, 856, 622, 587}, /* ; 00 (320x200,320x400,640x200,640x400) */
{1152, 856, 597, 562}, /* ; 01 (320x350,640x350) */
{1152, 856, 622, 587}, /* ; 02 (360x400,720x400) */
@@ -1173,7 +640,7 @@ static struct XGI330_LCDDataDesStruct XGI_CetLCDDes1024x768Data[] = {
{0, 1048, 805, 770} /* ; 06 (1024x768x60Hz) */
};
-static struct XGI330_LCDDataDesStruct XGI_ExtLCDDLDes1280x1024Data[] = {
+static struct XGI_LCDDesStruct XGI_ExtLCDDLDes1280x1024Data[] = {
{18, 1346, 981, 940}, /* 00 (320x200,320x400,640x200,640x400) */
{18, 1346, 926, 865}, /* 01 (320x350,640x350) */
{18, 1346, 981, 940}, /* 02 (360x400,720x400) */
@@ -1184,7 +651,7 @@ static struct XGI330_LCDDataDesStruct XGI_ExtLCDDLDes1280x1024Data[] = {
{18, 1346, 1065, 1024} /* 07 (1280x1024x60Hz) */
};
-static struct XGI330_LCDDataDesStruct XGI_StLCDDLDes1280x1024Data[] = {
+static struct XGI_LCDDesStruct XGI_StLCDDLDes1280x1024Data[] = {
{18, 1346, 970, 907}, /* 00 (320x200,320x400,640x200,640x400) */
{18, 1346, 917, 854}, /* 01 (320x350,640x350) */
{18, 1346, 970, 907}, /* 02 (360x400,720x400) */
@@ -1195,7 +662,7 @@ static struct XGI330_LCDDataDesStruct XGI_StLCDDLDes1280x1024Data[] = {
{18, 1346, 1065, 1024} /* 07 (1280x1024x60Hz) */
};
-static struct XGI330_LCDDataDesStruct XGI_CetLCDDLDes1280x1024Data[] = {
+static struct XGI_LCDDesStruct XGI_CetLCDDLDes1280x1024Data[] = {
{1368, 1008, 752, 711}, /* 00 (320x200,320x400,640x200,640x400) */
{1368, 1008, 729, 688}, /* 01 (320x350,640x350) */
{1368, 1008, 752, 711}, /* 02 (360x400,720x400) */
@@ -1206,7 +673,7 @@ static struct XGI330_LCDDataDesStruct XGI_CetLCDDLDes1280x1024Data[] = {
{18, 1346, 1065, 1024} /* 07 (1280x1024x60Hz) */
};
-static struct XGI330_LCDDataDesStruct XGI_ExtLCDDes1280x1024Data[] = {
+static struct XGI_LCDDesStruct XGI_ExtLCDDes1280x1024Data[] = {
{9, 1337, 981, 940}, /* ; 00 (320x200,320x400,640x200,640x400) */
{9, 1337, 926, 884}, /* ; 01 (320x350,640x350) alan, 2003/09/30 */
{9, 1337, 981, 940}, /* ; 02 (360x400,720x400) */
@@ -1217,7 +684,7 @@ static struct XGI330_LCDDataDesStruct XGI_ExtLCDDes1280x1024Data[] = {
{9, 1337, 1065, 1024} /* ; 07 (1280x1024x60Hz) */
};
-static struct XGI330_LCDDataDesStruct XGI_StLCDDes1280x1024Data[] = {
+static struct XGI_LCDDesStruct XGI_StLCDDes1280x1024Data[] = {
{9, 1337, 970, 907}, /* ; 00 (320x200,320x400,640x200,640x400) */
{9, 1337, 917, 854}, /* ; 01 (320x350,640x350) */
{9, 1337, 970, 907}, /* ; 02 (360x400,720x400) */
@@ -1228,7 +695,7 @@ static struct XGI330_LCDDataDesStruct XGI_StLCDDes1280x1024Data[] = {
{9, 1337, 1065, 1024} /* ; 07 (1280x1024x60Hz) */
};
-static struct XGI330_LCDDataDesStruct XGI_CetLCDDes1280x1024Data[] = {
+static struct XGI_LCDDesStruct XGI_CetLCDDes1280x1024Data[] = {
{1368, 1008, 752, 711}, /* 00 (320x200,320x400,640x200,640x400) */
{1368, 1008, 729, 688}, /* 01 (320x350,640x350) */
{1368, 1008, 752, 711}, /* 02 (360x400,720x400) */
@@ -1239,7 +706,7 @@ static struct XGI330_LCDDataDesStruct XGI_CetLCDDes1280x1024Data[] = {
{9, 1337, 1065, 1024} /* 07 (1280x1024x60Hz) */
};
-static struct XGI330_LCDDataDesStruct xgifb_lcddldes_1400x1050[] = {
+static struct XGI_LCDDesStruct xgifb_lcddldes_1400x1050[] = {
{18, 1464, 0, 1051}, /* 00 (320x200,320x400,640x200,640x400) */
{18, 1464, 0, 1051}, /* 01 (320x350,640x350) */
{18, 1464, 0, 1051}, /* 02 (360x400,720x400) */
@@ -1251,7 +718,7 @@ static struct XGI330_LCDDataDesStruct xgifb_lcddldes_1400x1050[] = {
{18, 1464, 0, 1051} /* 08 (1400x1050x60Hz) */
};
-static struct XGI330_LCDDataDesStruct xgifb_lcddes_1400x1050[] = {
+static struct XGI_LCDDesStruct xgifb_lcddes_1400x1050[] = {
{9, 1455, 0, 1051}, /* 00 (320x200,320x400,640x200,640x400) */
{9, 1455, 0, 1051}, /* 01 (320x350,640x350) */
{9, 1455, 0, 1051}, /* 02 (360x400,720x400) */
@@ -1263,7 +730,7 @@ static struct XGI330_LCDDataDesStruct xgifb_lcddes_1400x1050[] = {
{9, 1455, 0, 1051} /* 08 (1400x1050x60Hz) */
};
-static struct XGI330_LCDDataDesStruct XGI_CetLCDDes1400x1050Data[] = {
+static struct XGI_LCDDesStruct XGI_CetLCDDes1400x1050Data[] = {
{1308, 1068, 781, 766}, /* 00 (320x200,320x400,640x200,640x400) */
{1308, 1068, 781, 766}, /* 01 (320x350,640x350) */
{1308, 1068, 781, 766}, /* 02 (360x400,720x400) */
@@ -1275,7 +742,7 @@ static struct XGI330_LCDDataDesStruct XGI_CetLCDDes1400x1050Data[] = {
{18, 1464, 0, 1051} /* 08 (1400x1050x60Hz) */
};
-static struct XGI330_LCDDataDesStruct XGI_CetLCDDes1400x1050Data2[] = {
+static struct XGI_LCDDesStruct XGI_CetLCDDes1400x1050Data2[] = {
{0, 1448, 0, 1051}, /* 00 (320x200,320x400,640x200,640x400) */
{0, 1448, 0, 1051}, /* 01 (320x350,640x350) */
{0, 1448, 0, 1051}, /* 02 (360x400,720x400) */
@@ -1283,7 +750,7 @@ static struct XGI330_LCDDataDesStruct XGI_CetLCDDes1400x1050Data2[] = {
{0, 1448, 0, 1051} /* 04 (640x480x60Hz) */
};
-static struct XGI330_LCDDataDesStruct XGI_ExtLCDDLDes1600x1200Data[] = {
+static struct XGI_LCDDesStruct XGI_ExtLCDDLDes1600x1200Data[] = {
{18, 1682, 0, 1201}, /* 00 (320x200,320x400,640x200,640x400) */
{18, 1682, 0, 1201}, /* 01 (320x350,640x350) */
{18, 1682, 0, 1201}, /* 02 (360x400,720x400) */
@@ -1296,7 +763,7 @@ static struct XGI330_LCDDataDesStruct XGI_ExtLCDDLDes1600x1200Data[] = {
{18, 1682, 0, 1201} /* 09 (1600x1200x60Hz) */
};
-static struct XGI330_LCDDataDesStruct XGI_StLCDDLDes1600x1200Data[] = {
+static struct XGI_LCDDesStruct XGI_StLCDDLDes1600x1200Data[] = {
{18, 1682, 1150, 1101}, /* 00 (320x200,320x400,640x200,640x400) */
{18, 1682, 1083, 1034}, /* 01 (320x350,640x350) */
{18, 1682, 1150, 1101}, /* 02 (360x400,720x400) */
@@ -1309,7 +776,7 @@ static struct XGI330_LCDDataDesStruct XGI_StLCDDLDes1600x1200Data[] = {
{18, 1682, 0, 1201} /* 09 (1600x1200x60Hz) */
};
-static struct XGI330_LCDDataDesStruct XGI_ExtLCDDes1600x1200Data[] = {
+static struct XGI_LCDDesStruct XGI_ExtLCDDes1600x1200Data[] = {
{9, 1673, 0, 1201}, /* 00 (320x200,320x400,640x200,640x400) */
{9, 1673, 0, 1201}, /* 01 (320x350,640x350) */
{9, 1673, 0, 1201}, /* 02 (360x400,720x400) */
@@ -1322,7 +789,7 @@ static struct XGI330_LCDDataDesStruct XGI_ExtLCDDes1600x1200Data[] = {
{9, 1673, 0, 1201} /* 09 (1600x1200x60Hz) */
};
-static struct XGI330_LCDDataDesStruct XGI_StLCDDes1600x1200Data[] = {
+static struct XGI_LCDDesStruct XGI_StLCDDes1600x1200Data[] = {
{9, 1673, 1150, 1101}, /* 00 (320x200,320x400,640x200,640x400) */
{9, 1673, 1083, 1034}, /* 01 (320x350,640x350) */
{9, 1673, 1150, 1101}, /* 02 (360x400,720x400) */
@@ -1345,14 +812,13 @@ static struct XGI330_LCDDataDesStruct2 XGI_NoScalingDesData[] = {
{9, 849, 627, 600, 128, 4}, /* 05 (800x600x60Hz) */
{9, 1057, 805, 770, 0136, 6}, /* 06 (1024x768x60Hz) */
{9, 1337, 0, 1025, 112, 3}, /* 07 (1280x1024x60Hz) */
- {9, 1457, 0, 1051, 112, 3}, /* 08 (1400x1050x60Hz) },
- //;[ycchen] 12/19/02 */
+ {9, 1457, 0, 1051, 112, 3}, /* 08 (1400x1050x60Hz)*/
{9, 1673, 0, 1201, 192, 3}, /* 09 (1600x1200x60Hz) */
{9, 1337, 0, 771, 112, 6} /* 0A (1280x768x60Hz) */
};
/* ;;1024x768x75Hz */
-static struct XGI330_LCDDataDesStruct xgifb_lcddes_1024x768x75[] = {
+static struct XGI_LCDDesStruct xgifb_lcddes_1024x768x75[] = {
{9, 1049, 0, 769}, /* ; 00 (320x200,320x400,640x200,640x400) */
{9, 1049, 0, 769}, /* ; 01 (320x350,640x350) */
{9, 1049, 0, 769}, /* ; 02 (360x400,720x400) */
@@ -1363,7 +829,7 @@ static struct XGI330_LCDDataDesStruct xgifb_lcddes_1024x768x75[] = {
};
/* ;;1024x768x75Hz */
-static struct XGI330_LCDDataDesStruct XGI_CetLCDDes1024x768x75Data[] = {
+static struct XGI_LCDDesStruct XGI_CetLCDDes1024x768x75Data[] = {
{1152, 856, 622, 587}, /* ; 00 (320x200,320x400,640x200,640x400) */
{1152, 856, 597, 562}, /* ; 01 (320x350,640x350) */
{1192, 896, 622, 587}, /* ; 02 (360x400,720x400) */
@@ -1374,7 +840,7 @@ static struct XGI330_LCDDataDesStruct XGI_CetLCDDes1024x768x75Data[] = {
};
/* ;;1280x1024x75Hz */
-static struct XGI330_LCDDataDesStruct xgifb_lcddldes_1280x1024x75[] = {
+static struct XGI_LCDDesStruct xgifb_lcddldes_1280x1024x75[] = {
{18, 1314, 0, 1025}, /* ; 00 (320x200,320x400,640x200,640x400) */
{18, 1314, 0, 1025}, /* ; 01 (320x350,640x350) */
{18, 1314, 0, 1025}, /* ; 02 (360x400,720x400) */
@@ -1386,7 +852,7 @@ static struct XGI330_LCDDataDesStruct xgifb_lcddldes_1280x1024x75[] = {
};
/* 1280x1024x75Hz */
-static struct XGI330_LCDDataDesStruct XGI_CetLCDDLDes1280x1024x75Data[] = {
+static struct XGI_LCDDesStruct XGI_CetLCDDLDes1280x1024x75Data[] = {
{1368, 1008, 752, 711}, /* ; 00 (320x200,320x400,640x200,640x400) */
{1368, 1008, 729, 688}, /* ; 01 (320x350,640x350) */
{1408, 1048, 752, 711}, /* ; 02 (360x400,720x400) */
@@ -1398,7 +864,7 @@ static struct XGI330_LCDDataDesStruct XGI_CetLCDDLDes1280x1024x75Data[] = {
};
/* ;;1280x1024x75Hz */
-static struct XGI330_LCDDataDesStruct xgifb_lcddes_1280x1024x75[] = {
+static struct XGI_LCDDesStruct xgifb_lcddes_1280x1024x75[] = {
{9, 1305, 0, 1025}, /* ; 00 (320x200,320x400,640x200,640x400) */
{9, 1305, 0, 1025}, /* ; 01 (320x350,640x350) */
{9, 1305, 0, 1025}, /* ; 02 (360x400,720x400) */
@@ -1410,7 +876,7 @@ static struct XGI330_LCDDataDesStruct xgifb_lcddes_1280x1024x75[] = {
};
/* 1280x1024x75Hz */
-static struct XGI330_LCDDataDesStruct XGI_CetLCDDes1280x1024x75Data[] = {
+static struct XGI_LCDDesStruct XGI_CetLCDDes1280x1024x75Data[] = {
{1368, 1008, 752, 711}, /* ; 00 (320x200,320x400,640x200,640x400) */
{1368, 1008, 729, 688}, /* ; 01 (320x350,640x350) */
{1408, 1048, 752, 711}, /* ; 02 (360x400,720x400) */
@@ -1432,8 +898,7 @@ static struct XGI330_LCDDataDesStruct2 XGI_NoScalingDesDatax75[] = {
{9, 825, 0, 601, 80, 3}, /* ; 05 (800x600x75Hz) */
{9, 1049, 0, 769, 96, 3}, /* ; 06 (1024x768x75Hz) */
{9, 1305, 0, 1025, 144, 3}, /* ; 07 (1280x1024x75Hz) */
- {9, 1457, 0, 1051, 112, 3}, /* ; 08 (1400x1050x60Hz)
- ;;[ycchen] 12/19/02 */
+ {9, 1457, 0, 1051, 112, 3}, /* ; 08 (1400x1050x60Hz)*/
{9, 1673, 0, 1201, 192, 3}, /* ; 09 (1600x1200x75Hz) */
{9, 1337, 0, 771, 112, 6} /* ; 0A (1280x768x60Hz) */
};
@@ -1737,7 +1202,7 @@ static unsigned char XGI330_Ren750pGroup3[] = {
0x18, 0x1D, 0x23, 0x28, 0x4C, 0xAA, 0x01
};
-static struct XGI330_LVDSDataStruct XGI_LVDS1024x768Data_1[] = {
+static struct SiS_LVDSData XGI_LVDS1024x768Data_1[] = {
{ 960, 438, 1344, 806}, /* 00 (320x200,320x400,640x200,640x400) */
{ 960, 388, 1344, 806}, /* 01 (320x350,640x350) */
{1040, 438, 1344, 806}, /* 02 (360x400,720x400) */
@@ -1748,7 +1213,7 @@ static struct XGI330_LVDSDataStruct XGI_LVDS1024x768Data_1[] = {
};
-static struct XGI330_LVDSDataStruct XGI_LVDS1024x768Data_2[] = {
+static struct SiS_LVDSData XGI_LVDS1024x768Data_2[] = {
{1344, 806, 1344, 806},
{1344, 806, 1344, 806},
{1344, 806, 1344, 806},
@@ -1760,7 +1225,7 @@ static struct XGI330_LVDSDataStruct XGI_LVDS1024x768Data_2[] = {
{800, 525, 1280, 813}
};
-static struct XGI330_LVDSDataStruct XGI_LVDS1280x1024Data_1[] = {
+static struct SiS_LVDSData XGI_LVDS1280x1024Data_1[] = {
{1048, 442, 1688, 1066},
{1048, 392, 1688, 1066},
{1048, 442, 1688, 1066},
@@ -1771,7 +1236,7 @@ static struct XGI330_LVDSDataStruct XGI_LVDS1280x1024Data_1[] = {
{1688, 1066, 1688, 1066}
};
-static struct XGI330_LVDSDataStruct XGI_LVDS1280x1024Data_2[] = {
+static struct SiS_LVDSData XGI_LVDS1280x1024Data_2[] = {
{1344, 806, 1344, 806},
{1344, 806, 1344, 806},
{1344, 806, 1344, 806},
@@ -1783,7 +1248,7 @@ static struct XGI330_LVDSDataStruct XGI_LVDS1280x1024Data_2[] = {
{800, 525, 1280, 813}
};
-static struct XGI330_LVDSDataStruct XGI_LVDS1400x1050Data_1[] = {
+static struct SiS_LVDSData XGI_LVDS1400x1050Data_1[] = {
{928, 416, 1688, 1066},
{928, 366, 1688, 1066},
{928, 416, 1688, 1066},
@@ -1795,7 +1260,7 @@ static struct XGI330_LVDSDataStruct XGI_LVDS1400x1050Data_1[] = {
{1688, 1066, 1688, 1066}
};
-static struct XGI330_LVDSDataStruct XGI_LVDS1400x1050Data_2[] = {
+static struct SiS_LVDSData XGI_LVDS1400x1050Data_2[] = {
{1688, 1066, 1688, 1066},
{1688, 1066, 1688, 1066},
{1688, 1066, 1688, 1066},
@@ -1808,7 +1273,7 @@ static struct XGI330_LVDSDataStruct XGI_LVDS1400x1050Data_2[] = {
};
/* ;;[ycchen] 12/05/02 LCDHTxLCDVT=2048x1320 */
-static struct XGI330_LVDSDataStruct XGI_LVDS1600x1200Data_1[] = {
+static struct SiS_LVDSData XGI_LVDS1600x1200Data_1[] = {
{1088, 520, 2048, 1320}, /* 00 (320x200,320x400,640x200,640x400) */
{1088, 470, 2048, 1320}, /* 01 (320x350,640x350) */
{1088, 520, 2048, 1320}, /* 02 (360x400,720x400) */
@@ -1821,7 +1286,7 @@ static struct XGI330_LVDSDataStruct XGI_LVDS1600x1200Data_1[] = {
{2048, 1320, 2048, 1320} /* 09 (1600x1200) */
};
-static struct XGI330_LVDSDataStruct XGI_LVDSNoScalingData[] = {
+static struct SiS_LVDSData XGI_LVDSNoScalingData[] = {
{ 800, 449, 800, 449}, /* 00 (320x200,320x400,640x200,640x400) */
{ 800, 449, 800, 449}, /* 01 (320x350,640x350) */
{ 800, 449, 800, 449}, /* 02 (360x400,720x400) */
@@ -1830,12 +1295,12 @@ static struct XGI330_LVDSDataStruct XGI_LVDSNoScalingData[] = {
{1056, 628, 1056, 628}, /* 05 (800x600x60Hz) */
{1344, 806, 1344, 806}, /* 06 (1024x768x60Hz) */
{1688, 1066, 1688, 1066}, /* 07 (1280x1024x60Hz) */
- {1688, 1066, 1688, 1066}, /* 08 (1400x1050x60Hz) ;;[ycchen] 12/19/02 */
+ {1688, 1066, 1688, 1066}, /* 08 (1400x1050x60Hz) */
{2160, 1250, 2160, 1250}, /* 09 (1600x1200x60Hz) */
{1688, 806, 1688, 806} /* 0A (1280x768x60Hz) */
};
-static struct XGI330_LVDSDataStruct XGI_LVDS1024x768Data_1x75[] = {
+static struct SiS_LVDSData XGI_LVDS1024x768Data_1x75[] = {
{ 960, 438, 1312, 800}, /* 00 (320x200,320x400,640x200,640x400) */
{ 960, 388, 1312, 800}, /* 01 (320x350,640x350) */
{1040, 438, 1312, 800}, /* 02 (360x400,720x400) */
@@ -1846,7 +1311,7 @@ static struct XGI330_LVDSDataStruct XGI_LVDS1024x768Data_1x75[] = {
};
-static struct XGI330_LVDSDataStruct XGI_LVDS1024x768Data_2x75[] = {
+static struct SiS_LVDSData XGI_LVDS1024x768Data_2x75[] = {
{1312, 800, 1312, 800}, /* ; 00 (320x200,320x400,640x200,640x400) */
{1312, 800, 1312, 800}, /* ; 01 (320x350,640x350) */
{1312, 800, 1312, 800}, /* ; 02 (360x400,720x400) */
@@ -1856,7 +1321,7 @@ static struct XGI330_LVDSDataStruct XGI_LVDS1024x768Data_2x75[] = {
{1312, 800, 1312, 800}, /* ; 06 (512x384,1024x768) */
};
-static struct XGI330_LVDSDataStruct XGI_LVDS1280x1024Data_1x75[] = {
+static struct SiS_LVDSData XGI_LVDS1280x1024Data_1x75[] = {
{1048, 442, 1688, 1066 }, /* ; 00 (320x200,320x400,640x200,640x400) */
{1048, 392, 1688, 1066 }, /* ; 01 (320x350,640x350) */
{1128, 442, 1688, 1066 }, /* ; 02 (360x400,720x400) */
@@ -1867,7 +1332,7 @@ static struct XGI330_LVDSDataStruct XGI_LVDS1280x1024Data_1x75[] = {
{1688, 1066, 1688, 1066 }, /* ; 06; 07 (640x512,1280x1024) */
};
-static struct XGI330_LVDSDataStruct XGI_LVDS1280x1024Data_2x75[] = {
+static struct SiS_LVDSData XGI_LVDS1280x1024Data_2x75[] = {
{1688, 1066, 1688, 1066 }, /* ; 00 (320x200,320x400,640x200,640x400) */
{1688, 1066, 1688, 1066 }, /* ; 01 (320x350,640x350) */
{1688, 1066, 1688, 1066 }, /* ; 02 (360x400,720x400) */
@@ -1878,7 +1343,7 @@ static struct XGI330_LVDSDataStruct XGI_LVDS1280x1024Data_2x75[] = {
{1688, 1066, 1688, 1066 }, /* ; 06; 07 (640x512,1280x1024) */
};
-static struct XGI330_LVDSDataStruct XGI_LVDSNoScalingDatax75[] = {
+static struct SiS_LVDSData XGI_LVDSNoScalingDatax75[] = {
{ 800, 449, 800, 449}, /* ; 00 (320x200,320x400,640x200,640x400) */
{ 800, 449, 800, 449}, /* ; 01 (320x350,640x350) */
{ 900, 449, 900, 449}, /* ; 02 (360x400,720x400) */
@@ -1893,7 +1358,7 @@ static struct XGI330_LVDSDataStruct XGI_LVDSNoScalingDatax75[] = {
{1688, 806, 1688, 806}, /* ; 0A (1280x768x75Hz) */
};
-static struct XGI330_LVDSDataStruct XGI_LVDS1024x768Des_1[] = {
+static struct SiS_LVDSData XGI_LVDS1024x768Des_1[] = {
{0, 1048, 0, 771}, /* 00 (320x200,320x400,640x200,640x400) */
{0, 1048, 0, 771}, /* 01 (320x350,640x350) */
{0, 1048, 0, 771}, /* 02 (360x400,720x400) */
@@ -1903,7 +1368,7 @@ static struct XGI330_LVDSDataStruct XGI_LVDS1024x768Des_1[] = {
{0, 1048, 805, 770} /* 06 (1024x768x60Hz) */
} ;
-static struct XGI330_LVDSDataStruct XGI_LVDS1024x768Des_2[] = {
+static struct SiS_LVDSData XGI_LVDS1024x768Des_2[] = {
{1142, 856, 622, 587}, /* 00 (320x200,320x400,640x200,640x400) */
{1142, 856, 597, 562}, /* 01 (320x350,640x350) */
{1142, 856, 622, 587}, /* 02 (360x400,720x400) */
@@ -1913,7 +1378,7 @@ static struct XGI330_LVDSDataStruct XGI_LVDS1024x768Des_2[] = {
{ 0, 1048, 805, 771} /* 06 (1024x768x60Hz) */
};
-static struct XGI330_LVDSDataStruct XGI_LVDS1024x768Des_3[] = {
+static struct SiS_LVDSData XGI_LVDS1024x768Des_3[] = {
{320, 24, 622, 587}, /* 00 (320x200,320x400,640x200,640x400) */
{320, 24, 597, 562}, /* 01 (320x350,640x350) */
{320, 24, 622, 587}, /* 02 (360x400,720x400) */
@@ -1921,7 +1386,7 @@ static struct XGI330_LVDSDataStruct XGI_LVDS1024x768Des_3[] = {
{320, 24, 722, 687} /* 04 (640x480x60Hz) */
};
-static struct XGI330_LVDSDataStruct XGI_LVDS1280x1024Des_1[] = {
+static struct SiS_LVDSData XGI_LVDS1280x1024Des_1[] = {
{0, 1328, 0, 1025}, /* 00 (320x200,320x400,640x200,640x400) */
{0, 1328, 0, 1025}, /* 01 (320x350,640x350) */
{0, 1328, 0, 1025}, /* 02 (360x400,720x400) */
@@ -1933,7 +1398,7 @@ static struct XGI330_LVDSDataStruct XGI_LVDS1280x1024Des_1[] = {
};
/* The Display setting for DE Mode Panel */
-static struct XGI330_LVDSDataStruct XGI_LVDS1280x1024Des_2[] = {
+static struct SiS_LVDSData XGI_LVDS1280x1024Des_2[] = {
{1368, 1008, 752, 711}, /* 00 (320x200,320x400,640x200,640x400) */
{1368, 1008, 729, 688}, /* 01 (320x350,640x350) */
{1408, 1048, 752, 711}, /* 02 (360x400,720x400) */
@@ -1944,7 +1409,7 @@ static struct XGI330_LVDSDataStruct XGI_LVDS1280x1024Des_2[] = {
{0000, 1328, 0, 1025} /* 07 (1280x1024x60Hz) */
};
-static struct XGI330_LVDSDataStruct XGI_LVDS1400x1050Des_1[] = {
+static struct SiS_LVDSData XGI_LVDS1400x1050Des_1[] = {
{0, 1448, 0, 1051}, /* 00 (320x200,320x400,640x200,640x400) */
{0, 1448, 0, 1051}, /* 01 (320x350,640x350) */
{0, 1448, 0, 1051}, /* 02 (360x400,720x400) */
@@ -1956,7 +1421,7 @@ static struct XGI330_LVDSDataStruct XGI_LVDS1400x1050Des_1[] = {
{0, 1448, 0, 1051} /* 08 (1400x1050x60Hz) */
};
-static struct XGI330_LVDSDataStruct XGI_LVDS1400x1050Des_2[] = {
+static struct SiS_LVDSData XGI_LVDS1400x1050Des_2[] = {
{1308, 1068, 781, 766}, /* 00 (320x200,320x400,640x200,640x400) */
{1308, 1068, 781, 766}, /* 01 (320x350,640x350) */
{1308, 1068, 781, 766}, /* 02 (360x400,720x400) */
@@ -1968,7 +1433,7 @@ static struct XGI330_LVDSDataStruct XGI_LVDS1400x1050Des_2[] = {
{ 0, 1448, 0, 1051} /* 08 (1400x1050x60Hz) */
};
-static struct XGI330_LVDSDataStruct XGI_LVDS1600x1200Des_1[] = {
+static struct SiS_LVDSData XGI_LVDS1600x1200Des_1[] = {
{0, 1664, 0, 1201}, /* 00 (320x200,320x400,640x200,640x400) */
{0, 1664, 0, 1201}, /* 01 (320x350,640x350) */
{0, 1664, 0, 1201}, /* 02 (360x400,720x400) */
@@ -1991,14 +1456,13 @@ static struct XGI330_LCDDataDesStruct2 XGI_LVDSNoScalingDesData[] = {
{0, 840, 627, 600, 128, 4}, /* 05 (800x600x60Hz) */
{0, 1048, 805, 770, 136, 6}, /* 06 (1024x768x60Hz) */
{0, 1328, 0, 1025, 112, 3}, /* 07 (1280x1024x60Hz) */
- {0, 1438, 0, 1051, 112, 3}, /* 08 (1400x1050x60Hz)
- ;;[ycchen] 12/19/02 */
+ {0, 1438, 0, 1051, 112, 3}, /* 08 (1400x1050x60Hz)*/
{0, 1664, 0, 1201, 192, 3}, /* 09 (1600x1200x60Hz) */
{0, 1328, 0, 0771, 112, 6} /* 0A (1280x768x60Hz) */
};
/* ; 1024x768 Full-screen */
-static struct XGI330_LVDSDataStruct XGI_LVDS1024x768Des_1x75[] = {
+static struct SiS_LVDSData XGI_LVDS1024x768Des_1x75[] = {
{0, 1040, 0, 769}, /* ; 00 (320x200,320x400,640x200,640x400) */
{0, 1040, 0, 769}, /* ; 01 (320x350,640x350) */
{0, 1040, 0, 769}, /* ; 02 (360x400,720x400) */
@@ -2009,7 +1473,7 @@ static struct XGI330_LVDSDataStruct XGI_LVDS1024x768Des_1x75[] = {
};
/* ; 1024x768 center-screen (Enh. Mode) */
-static struct XGI330_LVDSDataStruct XGI_LVDS1024x768Des_2x75[] = {
+static struct SiS_LVDSData XGI_LVDS1024x768Des_2x75[] = {
{1142, 856, 622, 587}, /* 00 (320x200,320x400,640x200,640x400) */
{1142, 856, 597, 562}, /* 01 (320x350,640x350) */
{1142, 856, 622, 587}, /* 02 (360x400,720x400) */
@@ -2020,7 +1484,7 @@ static struct XGI330_LVDSDataStruct XGI_LVDS1024x768Des_2x75[] = {
};
/* ; 1024x768 center-screen (St.Mode) */
-static struct XGI330_LVDSDataStruct XGI_LVDS1024x768Des_3x75[] = {
+static struct SiS_LVDSData XGI_LVDS1024x768Des_3x75[] = {
{320, 24, 622, 587}, /* ; 00 (320x200,320x400,640x200,640x400) */
{320, 24, 597, 562}, /* ; 01 (320x350,640x350) */
{320, 24, 622, 587}, /* ; 02 (360x400,720x400) */
@@ -2028,7 +1492,7 @@ static struct XGI330_LVDSDataStruct XGI_LVDS1024x768Des_3x75[] = {
{320, 24, 722, 687} /* ; 04 (640x480x60Hz) */
};
-static struct XGI330_LVDSDataStruct XGI_LVDS1280x1024Des_1x75[] = {
+static struct SiS_LVDSData XGI_LVDS1280x1024Des_1x75[] = {
{0, 1296, 0, 1025}, /* ; 00 (320x200,320x400,640x200,640x400) */
{0, 1296, 0, 1025}, /* ; 01 (320x350,640x350) */
{0, 1296, 0, 1025}, /* ; 02 (360x400,720x400) */
@@ -2040,8 +1504,8 @@ static struct XGI330_LVDSDataStruct XGI_LVDS1280x1024Des_1x75[] = {
};
/* The Display setting for DE Mode Panel */
-/* [ycchen] 02/18/03 Set DE as default */
-static struct XGI330_LVDSDataStruct XGI_LVDS1280x1024Des_2x75[] = {
+/* Set DE as default */
+static struct SiS_LVDSData XGI_LVDS1280x1024Des_2x75[] = {
{1368, 976, 752, 711}, /* ; 00 (320x200,320x400,640x200,640x400) */
{1368, 976, 729, 688}, /* ; 01 (320x350,640x350) */
{1408, 976, 752, 711}, /* ; 02 (360x400,720x400) */
@@ -2063,13 +1527,12 @@ static struct XGI330_LCDDataDesStruct2 XGI_LVDSNoScalingDesDatax75[] = {
{0, 816, 0, 601, 80, 3}, /* ; 05 (800x600x75Hz) */
{0, 1040, 0, 769, 96, 3}, /* ; 06 (1024x768x75Hz) */
{0, 1296, 0, 1025, 144, 3}, /* ; 07 (1280x1024x75Hz) */
- {0, 1448, 0, 1051, 112, 3}, /* ; 08 (1400x1050x75Hz)
- ;;[ycchen] 12/19/02 */
+ {0, 1448, 0, 1051, 112, 3}, /* ; 08 (1400x1050x75Hz) */
{0, 1664, 0, 1201, 192, 3}, /* ; 09 (1600x1200x75Hz) */
{0, 1328, 0, 771, 112, 6} /* ; 0A (1280x768x75Hz) */
};
-static struct XGI330_CHTVDataStruct XGI_CHTVUNTSCData[] = {
+static struct SiS_LVDSData XGI_CHTVUNTSCData[] = {
{ 840, 600, 840, 600},
{ 840, 600, 840, 600},
{ 840, 600, 840, 600},
@@ -2078,7 +1541,7 @@ static struct XGI330_CHTVDataStruct XGI_CHTVUNTSCData[] = {
{1064, 750, 1064, 750}
};
-static struct XGI330_CHTVDataStruct XGI_CHTVONTSCData[] = {
+static struct SiS_LVDSData XGI_CHTVONTSCData[] = {
{ 840, 525, 840, 525},
{ 840, 525, 840, 525},
{ 840, 525, 840, 525},
@@ -2087,7 +1550,7 @@ static struct XGI330_CHTVDataStruct XGI_CHTVONTSCData[] = {
{1040, 700, 1040, 700}
};
-static struct XGI330_CHTVDataStruct XGI_CHTVUPALData[] = {
+static struct SiS_LVDSData XGI_CHTVUPALData[] = {
{1008, 625, 1008, 625},
{1008, 625, 1008, 625},
{1008, 625, 1008, 625},
@@ -2096,7 +1559,7 @@ static struct XGI330_CHTVDataStruct XGI_CHTVUPALData[] = {
{ 936, 836, 936, 836}
};
-static struct XGI330_CHTVDataStruct XGI_CHTVOPALData[] = {
+static struct SiS_LVDSData XGI_CHTVOPALData[] = {
{1008, 625, 1008, 625},
{1008, 625, 1008, 625},
{1008, 625, 1008, 625},
@@ -2375,9 +1838,12 @@ static struct XGI330_LCDDataTablStruct XGI_LCDDataTable[] = {
{Panel_1024x768x75, 0x0019, 0x0001, 12}, /* XGI_ExtLCD1024x768x75Data */
{Panel_1024x768x75, 0x0019, 0x0000, 13}, /* XGI_StLCD1024x768x75Data */
{Panel_1024x768x75, 0x0018, 0x0010, 14}, /* XGI_CetLCD1024x768x75Data */
- {Panel_1280x1024x75, 0x0019, 0x0001, 15}, /* XGI_ExtLCD1280x1024x75Data*/
- {Panel_1280x1024x75, 0x0019, 0x0000, 16}, /* XGI_StLCD1280x1024x75Data */
- {Panel_1280x1024x75, 0x0018, 0x0010, 17}, /* XGI_CetLCD1280x1024x75Data*/
+ /* XGI_ExtLCD1280x1024x75Data */
+ {Panel_1280x1024x75, 0x0019, 0x0001, 15},
+ /* XGI_StLCD1280x1024x75Data */
+ {Panel_1280x1024x75, 0x0019, 0x0000, 16},
+ /* XGI_CetLCD1280x1024x75Data */
+ {Panel_1280x1024x75, 0x0018, 0x0010, 17},
{PanelRef75Hz, 0x0008, 0x0008, 18}, /* XGI_NoScalingDatax75 */
{0xFF, 0x0000, 0x0000, 0} /* End of table */
};
@@ -2396,9 +1862,12 @@ static struct XGI330_LCDDataTablStruct XGI_LCDDesDataTable[] = {
{Panel_1600x1200, 0x0019, 0x0001, 10}, /* XGI_ExtLCDDes1600x1200Data */
{Panel_1600x1200, 0x0019, 0x0000, 11}, /* XGI_StLCDDes1600x1200Data */
{PanelRef60Hz, 0x0008, 0x0008, 12}, /* XGI_NoScalingDesData */
- {Panel_1024x768x75, 0x0019, 0x0001, 13}, /*XGI_ExtLCDDes1024x768x75Data*/
- {Panel_1024x768x75, 0x0019, 0x0000, 14}, /* XGI_StLCDDes1024x768x75Data*/
- {Panel_1024x768x75, 0x0018, 0x0010, 15}, /*XGI_CetLCDDes1024x768x75Data*/
+ /* XGI_ExtLCDDes1024x768x75Data */
+ {Panel_1024x768x75, 0x0019, 0x0001, 13},
+ /* XGI_StLCDDes1024x768x75Data */
+ {Panel_1024x768x75, 0x0019, 0x0000, 14},
+ /* XGI_CetLCDDes1024x768x75Data */
+ {Panel_1024x768x75, 0x0018, 0x0010, 15},
/* XGI_ExtLCDDes1280x1024x75Data */
{Panel_1280x1024x75, 0x0019, 0x0001, 16},
/* XGI_StLCDDes1280x1024x75Data */
@@ -2435,8 +1904,10 @@ static struct XGI330_LCDDataTablStruct XGI_EPLLCDDataPtr[] = {
{PanelRef60Hz, 0x0008, 0x0008, 7}, /* XGI_LVDSNoScalingData */
{Panel_1024x768x75, 0x0018, 0x0000, 8}, /* XGI_LVDS1024x768Data_1x75 */
{Panel_1024x768x75, 0x0018, 0x0010, 9}, /* XGI_LVDS1024x768Data_2x75 */
- {Panel_1280x1024x75, 0x0018, 0x0000, 10}, /* XGI_LVDS1280x1024Data_1x75*/
- {Panel_1280x1024x75, 0x0018, 0x0010, 11}, /*XGI_LVDS1280x1024Data_2x75*/
+ /* XGI_LVDS1280x1024Data_1x75 */
+ {Panel_1280x1024x75, 0x0018, 0x0000, 10},
+ /* XGI_LVDS1280x1024Data_2x75 */
+ {Panel_1280x1024x75, 0x0018, 0x0010, 11},
{PanelRef75Hz, 0x0008, 0x0008, 12}, /* XGI_LVDSNoScalingDatax75 */
{0xFF, 0x0000, 0x0000, 0}
};
@@ -2454,8 +1925,10 @@ static struct XGI330_LCDDataTablStruct XGI_EPLLCDDesDataPtr[] = {
{Panel_1024x768x75, 0x0018, 0x0000, 9}, /* XGI_LVDS1024x768Des_1x75 */
{Panel_1024x768x75, 0x0618, 0x0410, 10}, /* XGI_LVDS1024x768Des_3x75 */
{Panel_1024x768x75, 0x0018, 0x0010, 11}, /* XGI_LVDS1024x768Des_2x75 */
- {Panel_1280x1024x75, 0x0018, 0x0000, 12}, /* XGI_LVDS1280x1024Des_1x75 */
- {Panel_1280x1024x75, 0x0018, 0x0010, 13}, /* XGI_LVDS1280x1024Des_2x75 */
+ /* XGI_LVDS1280x1024Des_1x75 */
+ {Panel_1280x1024x75, 0x0018, 0x0000, 12},
+ /* XGI_LVDS1280x1024Des_2x75 */
+ {Panel_1280x1024x75, 0x0018, 0x0010, 13},
{PanelRef75Hz, 0x0008, 0x0008, 14}, /* XGI_LVDSNoScalingDesDatax75 */
{0xFF, 0x0000, 0x0000, 0}
};
@@ -2508,70 +1981,70 @@ static unsigned short LCDLenList[] = {
/* Dual link only */
static struct XGI330_LCDCapStruct XGI_LCDDLCapList[] = {
/* LCDCap1024x768 */
- {Panel_1024x768, DefaultLCDCap, 0, 0x012, 0x88, 0x06, VCLK65_315,
+ {Panel_1024x768, DefaultLCDCap, 0, 0x88, 0x06, VCLK65_315,
0x6C, 0xC3, 0x35, 0x62, 0x02, 0x14, 0x0A, 0x02, 0x00,
0x30, 0x10, 0x5A, 0x10, 0x10, 0x0A, 0xC0, 0x28, 0x10},
/* LCDCap1280x1024 */
{Panel_1280x1024, XGI_LCDDualLink+DefaultLCDCap, StLCDBToA,
- 0x012, 0x70, 0x03, VCLK108_2_315,
+ 0x70, 0x03, VCLK108_2_315,
0x70, 0x44, 0xF8, 0x2F, 0x02, 0x14, 0x0A, 0x02, 0x00,
0x30, 0x10, 0x5A, 0x10, 0x10, 0x0A, 0xC0, 0x30, 0x10},
/* LCDCap1400x1050 */
{Panel_1400x1050, XGI_LCDDualLink+DefaultLCDCap, StLCDBToA,
- 0x012, 0x70, 0x03, VCLK108_2_315,
+ 0x70, 0x03, VCLK108_2_315,
0x70, 0x44, 0xF8, 0x2F, 0x02, 0x14, 0x0A, 0x02, 0x00,
0x30, 0x10, 0x5A, 0x10, 0x10, 0x0A, 0xC0, 0x30, 0x10},
/* LCDCap1600x1200 */
{Panel_1600x1200, XGI_LCDDualLink+DefaultLCDCap, LCDToFull,
- 0x012, 0xC0, 0x03, VCLK162,
+ 0xC0, 0x03, VCLK162,
0x43, 0x22, 0x70, 0x24, 0x02, 0x14, 0x0A, 0x02, 0x00,
0x30, 0x10, 0x5A, 0x10, 0x10, 0x0A, 0xC0, 0x30, 0x10},
/* LCDCap1024x768x75 */
- {Panel_1024x768x75, DefaultLCDCap, 0, 0x012, 0x60, 0, VCLK78_75,
+ {Panel_1024x768x75, DefaultLCDCap, 0, 0x60, 0, VCLK78_75,
0x2B, 0x61, 0x2B, 0x61, 0x02, 0x14, 0x0A, 0x02, 0x00,
0x30, 0x10, 0x5A, 0x10, 0x10, 0x0A, 0xC0, 0x28, 0x10},
/* LCDCap1280x1024x75 */
{Panel_1280x1024x75, XGI_LCDDualLink+DefaultLCDCap, StLCDBToA,
- 0x012, 0x90, 0x03, VCLK135_5,
+ 0x90, 0x03, VCLK135_5,
0x54, 0x42, 0x4A, 0x61, 0x02, 0x14, 0x0A, 0x02, 0x00,
0x30, 0x10, 0x5A, 0x10, 0x10, 0x0A, 0xC0, 0x30, 0x10},
/* LCDCapDefault */
- {0xFF, DefaultLCDCap, 0, 0x012, 0x88, 0x06, VCLK65_315,
+ {0xFF, DefaultLCDCap, 0, 0x88, 0x06, VCLK65_315,
0x6C, 0xC3, 0x35, 0x62, 0x02, 0x14, 0x0A, 0x02, 0x00,
0x30, 0x10, 0x5A, 0x10, 0x10, 0x0A, 0xC0, 0x28, 0x10}
};
static struct XGI330_LCDCapStruct XGI_LCDCapList[] = {
/* LCDCap1024x768 */
- {Panel_1024x768, DefaultLCDCap, 0, 0x012, 0x88, 0x06, VCLK65_315,
+ {Panel_1024x768, DefaultLCDCap, 0, 0x88, 0x06, VCLK65_315,
0x6C, 0xC3, 0x35, 0x62, 0x02, 0x14, 0x0A, 0x02, 0x00,
0x30, 0x10, 0x5A, 0x10, 0x10, 0x0A, 0xC0, 0x28, 0x10},
/* LCDCap1280x1024 */
{Panel_1280x1024, DefaultLCDCap, StLCDBToA,
- 0x012, 0x70, 0x03, VCLK108_2_315,
+ 0x70, 0x03, VCLK108_2_315,
0x70, 0x44, 0xF8, 0x2F, 0x02, 0x14, 0x0A, 0x02, 0x00,
0x30, 0x10, 0x5A, 0x10, 0x10, 0x0A, 0xC0, 0x30, 0x10},
/* LCDCap1400x1050 */
{Panel_1400x1050, DefaultLCDCap, StLCDBToA,
- 0x012, 0x70, 0x03, VCLK108_2_315,
+ 0x70, 0x03, VCLK108_2_315,
0x70, 0x44, 0xF8, 0x2F, 0x02, 0x14, 0x0A, 0x02, 0x00,
0x30, 0x10, 0x5A, 0x10, 0x10, 0x0A, 0xC0, 0x30, 0x10},
/* LCDCap1600x1200 */
{Panel_1600x1200, DefaultLCDCap, LCDToFull,
- 0x012, 0xC0, 0x03, VCLK162,
+ 0xC0, 0x03, VCLK162,
0x5A, 0x23, 0x5A, 0x23, 0x02, 0x14, 0x0A, 0x02, 0x00,
0x30, 0x10, 0x5A, 0x10, 0x10, 0x0A, 0xC0, 0x30, 0x10},
/* LCDCap1024x768x75 */
- {Panel_1024x768x75, DefaultLCDCap, 0, 0x012, 0x60, 0, VCLK78_75,
+ {Panel_1024x768x75, DefaultLCDCap, 0, 0x60, 0, VCLK78_75,
0x2B, 0x61, 0x2B, 0x61, 0x02, 0x14, 0x0A, 0x02, 0x00,
0x30, 0x10, 0x5A, 0x10, 0x10, 0x0A, 0xC0, 0x28, 0x10},
/* LCDCap1280x1024x75 */
{Panel_1280x1024x75, DefaultLCDCap, StLCDBToA,
- 0x012, 0x90, 0x03, VCLK135_5,
+ 0x90, 0x03, VCLK135_5,
0x54, 0x42, 0x4A, 0x61, 0x02, 0x14, 0x0A, 0x02, 0x00,
0x30, 0x10, 0x5A, 0x10, 0x10, 0x0A, 0xC0, 0x30, 0x10},
/* LCDCapDefault */
- {0xFF, DefaultLCDCap, 0, 0x012, 0x88, 0x06, VCLK65_315,
+ {0xFF, DefaultLCDCap, 0, 0x88, 0x06, VCLK65_315,
0x6C, 0xC3, 0x35, 0x62, 0x02, 0x14, 0x0A, 0x02, 0x00,
0x30, 0x10, 0x5A, 0x10, 0x10, 0x0A, 0xC0, 0x28, 0x10}
};
@@ -2770,49 +2243,7 @@ static struct SiS_ModeResInfo_S XGI330_ModeResInfo[] = {
{1152, 864, 8, 16}
};
-static unsigned char XGI330_OutputSelect = 0x40;
-static unsigned char XGI330_SoftSetting = 0x30;
-static unsigned char XGI330_SR07 = 0x18;
-
-static unsigned char XGI330_CR49[] = {0xaa, 0x88};
-static unsigned char XGI330_SR1F;
-static unsigned char XGI330_SR21 = 0xa3;
-static unsigned char XGI330_SR22 = 0xfb;
-static unsigned char XGI330_SR23 = 0xf6;
-static unsigned char XGI330_SR24 = 0xd;
-
-static unsigned char XGI330_CRT2Data_1_2;
-static unsigned char XGI330_CRT2Data_4_D;
-static unsigned char XGI330_CRT2Data_4_E;
-static unsigned char XGI330_CRT2Data_4_10 = 0x80;
-static unsigned short XGI330_RGBSenseData = 0xd1;
-static unsigned short XGI330_VideoSenseData = 0xb9;
-static unsigned short XGI330_YCSenseData = 0xb3;
-static unsigned short XGI330_RGBSenseData2 = 0x0190; /*301b*/
-static unsigned short XGI330_VideoSenseData2 = 0x0110;
-static unsigned short XGI330_YCSenseData2 = 0x016B;
-static unsigned char XG40_I2CDefinition;
-static unsigned char XG20_CR97 = 0x10 ;
-
-static unsigned char XG21_DVOSetting;
-static unsigned char XG21_CR2E;
-static unsigned char XG21_CR2F;
-static unsigned char XG21_CR46;
-static unsigned char XG21_CR47;
-
-static unsigned char XG27_CR97 = 0xC1 ;
-static unsigned char XG27_SR36 = 0x30 ;
-static unsigned char XG27_CR8F = 0x0C ;
-static unsigned char XG27_CRD0[] = {
- 0, 0, 0, 0, 0, 0, 0, 0x82, 0x00, 0x66, 0x01, 0x00
-};
-static unsigned char XG27_CRDE[2];
-static unsigned char XG27_SR40 = 0x04 ;
-static unsigned char XG27_SR41 = 0x00 ;
-
-static unsigned char Z11m_CR97 = 0x80 ;
-
-static struct XGI330_VCLKDataStruct XGI_VCLKData[] = {
+static struct SiS_VCLKData XGI_VCLKData[] = {
/* SR2B,SR2C,SR2D */
{0x1B, 0xE1, 25}, /* 00 (25.175MHz) */
{0x4E, 0xE4, 28}, /* 01 (28.322MHz) */
@@ -2905,7 +2336,7 @@ static struct XGI330_VCLKDataStruct XGI_VCLKData[] = {
{0xFF, 0x00, 0} /* End mark */
};
-static struct XGI330_VCLKDataStruct XGI_VBVCLKData[] = {
+static struct SiS_VCLKData XGI_VBVCLKData[] = {
{0x1B, 0xE1, 25}, /* 00 (25.175MHz) */
{0x4E, 0xE4, 28}, /* 01 (28.322MHz) */
{0x57, 0xE4, 31}, /* 02 (31.500MHz) */
@@ -2997,36 +2428,8 @@ static struct XGI330_VCLKDataStruct XGI_VBVCLKData[] = {
{0xFF, 0x00, 0} /* End mark */
};
-static unsigned char XGI301TVDelayList[] = {
- 0x22, /* ; 0 ExtNTSCDelay */
- 0x22, /* ; 1 StNTSCDelay */
- 0x22, /* ; 2 ExtPALDelay */
- 0x22, /* ; 3 StPALDelay */
- 0x88, /* ; 4 ExtHiTVDelay(1080i) */
- 0xBB, /* ; 5 StHiTVDelay(1080i) */
- 0x22, /* ; 6 ExtYPbPrDelay(525i) */
- 0x22, /* ; 7 StYPbPrDealy(525i) */
- 0x22, /* ; 8 ExtYPbPrDelay(525p) */
- 0x22, /* ; 9 StYPbPrDealy(525p) */
- 0x22, /* ; A ExtYPbPrDelay(750p) */
- 0x22 /* B StYPbPrDealy(750p) */
-};
-
-static unsigned char XGI301TVDelayList2[] = {
- 0x22, /* ; 0 ExtNTSCDelay */
- 0x22, /* ; 1 StNTSCDelay */
- 0x22, /* ; 2 ExtPALDelay */
- 0x22, /* ; 3 StPALDelay */
- 0x22, /* ; 4 ExtHiTVDelay */
- 0x22, /* ; 5 StHiTVDelay */
- 0x22, /* ; 6 ExtYPbPrDelay(525i) */
- 0x22, /* ; 7 StYPbPrDealy(525i) */
- 0x22, /* ; 8 ExtYPbPrDelay(525p) */
- 0x22, /* ; 9 StYPbPrDealy(525p) */
- 0x22, /* ; A ExtYPbPrDelay(750p) */
- 0x22 /* ; B StYPbPrDealy(750p) */
-};
-
+#define XGI301TVDelay 0x22
+#define XGI301LCDDelay 0x12
static unsigned char TVAntiFlickList[] = {/* NTSCAntiFlicker */
0x04, /* ; 0 Adaptive */
@@ -3213,3 +2616,4 @@ static struct XGI301C_Tap4TimingStruct YPbPr750pTap4Timing[] = {
}
}
};
+#endif
diff --git a/drivers/staging/xgifb/vb_util.c b/drivers/staging/xgifb/vb_util.c
index b5c99891ead4..1b452f8b6274 100644
--- a/drivers/staging/xgifb/vb_util.c
+++ b/drivers/staging/xgifb/vb_util.c
@@ -1,12 +1,4 @@
-#include <linux/io.h>
-#include <linux/types.h>
-
-#include "vb_def.h"
#include "vgatypes.h"
-#include "vb_struct.h"
-
-#include "XGIfb.h"
-
#include "vb_util.h"
void xgifb_reg_set(unsigned long port, u8 index, u8 data)
diff --git a/drivers/staging/xgifb/vgatypes.h b/drivers/staging/xgifb/vgatypes.h
index a7208e315815..ddf7776c295b 100644
--- a/drivers/staging/xgifb/vgatypes.h
+++ b/drivers/staging/xgifb/vgatypes.h
@@ -1,7 +1,6 @@
#ifndef _VGATYPES_
#define _VGATYPES_
-#include <linux/ioctl.h>
#include <linux/fb.h> /* for struct fb_var_screeninfo for sis.h */
#include "../../video/sis/vgatypes.h"
#include "../../video/sis/sis.h" /* for LCD_TYPE */
@@ -22,40 +21,6 @@ enum XGI_VB_CHIP_TYPE {
};
#endif
-
-#define XGI_LCD_TYPE
-/* Since the merge with video/sis the LCD_TYPEs are used from
- drivers/video/sis/sis.h . Nevertheless we keep this (for the moment) for
- future reference until the code is merged completely and we are sure
- nothing of this should be added to the sis.h header */
-#ifndef XGI_LCD_TYPE
-enum XGI_LCD_TYPE {
- LCD_INVALID = 0,
- LCD_320x480, /* FSTN, DSTN */
- LCD_640x480,
- LCD_640x480_2, /* FSTN, DSTN */
- LCD_640x480_3, /* FSTN, DSTN */
- LCD_800x600,
- LCD_848x480,
- LCD_1024x600,
- LCD_1024x768,
- LCD_1152x768,
- LCD_1152x864,
- LCD_1280x720,
- LCD_1280x768,
- LCD_1280x800,
- LCD_1280x960,
- LCD_1280x1024,
- LCD_1400x1050,
- LCD_1600x1200,
- LCD_1680x1050,
- LCD_1920x1440,
- LCD_2048x1536,
- LCD_CUSTOM,
- LCD_UNKNOWN
-};
-#endif
-
struct xgi_hw_device_info {
unsigned long ulExternalChip; /* NO VB or other video bridge*/
/* if ujVBChipID = VB_CHIP_UNKNOWN, */
@@ -66,8 +31,6 @@ struct xgi_hw_device_info {
unsigned long ulVideoMemorySize; /* size, in bytes, of the
memory on the board */
- unsigned char *pjIOAddress; /* base I/O address of VGA ports (0x3B0) */
-
unsigned char jChipType; /* Used to Identify Graphics Chip */
/* defined in the data structure type */
/* "XGI_CHIP_TYPE" */
diff --git a/drivers/staging/zcache/Kconfig b/drivers/staging/zcache/Kconfig
index 7048e01f0817..4881839be625 100644
--- a/drivers/staging/zcache/Kconfig
+++ b/drivers/staging/zcache/Kconfig
@@ -1,9 +1,6 @@
config ZCACHE
bool "Dynamic compression of swap pages and clean pagecache pages"
- # X86 dependency is because zsmalloc uses non-portable pte/tlb
- # functions
- depends on (CLEANCACHE || FRONTSWAP) && CRYPTO=y && X86
- select ZSMALLOC
+ depends on (CLEANCACHE || FRONTSWAP) && CRYPTO=y && ZSMALLOC=y
select CRYPTO_LZO
default n
help
diff --git a/drivers/staging/zcache/tmem.c b/drivers/staging/zcache/tmem.c
index 1ca66ea9b281..eaa90213457b 100644
--- a/drivers/staging/zcache/tmem.c
+++ b/drivers/staging/zcache/tmem.c
@@ -72,33 +72,49 @@ void tmem_register_pamops(struct tmem_pamops *m)
* the hashbucket lock must be held.
*/
-/* searches for object==oid in pool, returns locked object if found */
-static struct tmem_obj *tmem_obj_find(struct tmem_hashbucket *hb,
- struct tmem_oid *oidp)
+static struct tmem_obj
+*__tmem_obj_find(struct tmem_hashbucket*hb, struct tmem_oid *oidp,
+ struct rb_node **parent, struct rb_node ***link)
{
- struct rb_node *rbnode;
- struct tmem_obj *obj;
-
- rbnode = hb->obj_rb_root.rb_node;
- while (rbnode) {
- BUG_ON(RB_EMPTY_NODE(rbnode));
- obj = rb_entry(rbnode, struct tmem_obj, rb_tree_node);
+ struct rb_node *_parent = NULL, **rbnode;
+ struct tmem_obj *obj = NULL;
+
+ rbnode = &hb->obj_rb_root.rb_node;
+ while (*rbnode) {
+ BUG_ON(RB_EMPTY_NODE(*rbnode));
+ _parent = *rbnode;
+ obj = rb_entry(*rbnode, struct tmem_obj,
+ rb_tree_node);
switch (tmem_oid_compare(oidp, &obj->oid)) {
case 0: /* equal */
goto out;
case -1:
- rbnode = rbnode->rb_left;
+ rbnode = &(*rbnode)->rb_left;
break;
case 1:
- rbnode = rbnode->rb_right;
+ rbnode = &(*rbnode)->rb_right;
break;
}
}
+
+ if (parent)
+ *parent = _parent;
+ if (link)
+ *link = rbnode;
+
obj = NULL;
out:
return obj;
}
+
+/* searches for object==oid in pool, returns locked object if found */
+static struct tmem_obj *tmem_obj_find(struct tmem_hashbucket *hb,
+ struct tmem_oid *oidp)
+{
+ return __tmem_obj_find(hb, oidp, NULL, NULL);
+}
+
static void tmem_pampd_destroy_all_in_obj(struct tmem_obj *);
/* free an object that has no more pampds in it */
@@ -131,8 +147,7 @@ static void tmem_obj_init(struct tmem_obj *obj, struct tmem_hashbucket *hb,
struct tmem_oid *oidp)
{
struct rb_root *root = &hb->obj_rb_root;
- struct rb_node **new = &(root->rb_node), *parent = NULL;
- struct tmem_obj *this;
+ struct rb_node **new = NULL, *parent = NULL;
BUG_ON(pool == NULL);
atomic_inc(&pool->obj_count);
@@ -144,22 +159,10 @@ static void tmem_obj_init(struct tmem_obj *obj, struct tmem_hashbucket *hb,
obj->pampd_count = 0;
(*tmem_pamops.new_obj)(obj);
SET_SENTINEL(obj, OBJ);
- while (*new) {
- BUG_ON(RB_EMPTY_NODE(*new));
- this = rb_entry(*new, struct tmem_obj, rb_tree_node);
- parent = *new;
- switch (tmem_oid_compare(oidp, &this->oid)) {
- case 0:
- BUG(); /* already present; should never happen! */
- break;
- case -1:
- new = &(*new)->rb_left;
- break;
- case 1:
- new = &(*new)->rb_right;
- break;
- }
- }
+
+ if (__tmem_obj_find(hb, oidp, &parent, &new))
+ BUG();
+
rb_link_node(&obj->rb_tree_node, parent, new);
rb_insert_color(&obj->rb_tree_node, root);
}
diff --git a/drivers/staging/zcache/zcache-main.c b/drivers/staging/zcache/zcache-main.c
index 2734dacacbaf..c214977b4ab4 100644
--- a/drivers/staging/zcache/zcache-main.c
+++ b/drivers/staging/zcache/zcache-main.c
@@ -31,13 +31,11 @@
#include <linux/math64.h>
#include <linux/crypto.h>
#include <linux/string.h>
+#include <linux/idr.h>
#include "tmem.h"
#include "../zsmalloc/zsmalloc.h"
-#if (!defined(CONFIG_CLEANCACHE) && !defined(CONFIG_FRONTSWAP))
-#error "zcache is useless without CONFIG_CLEANCACHE or CONFIG_FRONTSWAP"
-#endif
#ifdef CONFIG_CLEANCACHE
#include <linux/cleancache.h>
#endif
@@ -53,15 +51,13 @@
(__GFP_FS | __GFP_NORETRY | __GFP_NOWARN | __GFP_NOMEMALLOC)
#endif
-#define MAX_POOLS_PER_CLIENT 16
-
#define MAX_CLIENTS 16
#define LOCAL_CLIENT ((uint16_t)-1)
MODULE_LICENSE("GPL");
struct zcache_client {
- struct tmem_pool *tmem_pools[MAX_POOLS_PER_CLIENT];
+ struct idr tmem_pools;
struct zs_pool *zspool;
bool allocated;
atomic_t refcount;
@@ -78,6 +74,17 @@ static inline uint16_t get_client_id_from_client(struct zcache_client *cli)
return cli - &zcache_clients[0];
}
+static struct zcache_client *get_zcache_client(uint16_t cli_id)
+{
+ if (cli_id == LOCAL_CLIENT)
+ return &zcache_host;
+
+ if ((unsigned int)cli_id < MAX_CLIENTS)
+ return &zcache_clients[cli_id];
+
+ return NULL;
+}
+
static inline bool is_local_client(struct zcache_client *cli)
{
return cli == &zcache_host;
@@ -110,6 +117,8 @@ static inline int zcache_comp_op(enum comp_op op,
case ZCACHE_COMPOP_DECOMPRESS:
ret = crypto_comp_decompress(tfm, src, slen, dst, dlen);
break;
+ default:
+ ret = -EINVAL;
}
put_cpu();
return ret;
@@ -602,16 +611,14 @@ out:
return;
}
-static void zbud_init(void)
+static void __init zbud_init(void)
{
int i;
INIT_LIST_HEAD(&zbud_buddied_list);
- zcache_zbud_buddied_count = 0;
- for (i = 0; i < NCHUNKS; i++) {
+
+ for (i = 0; i < NCHUNKS; i++)
INIT_LIST_HEAD(&zbud_unbuddied[i].list);
- zbud_unbuddied[i].count = 0;
- }
}
#ifdef CONFIG_SYSFS
@@ -693,14 +700,14 @@ static unsigned int zv_max_mean_zsize = (PAGE_SIZE / 8) * 5;
static atomic_t zv_curr_dist_counts[NCHUNKS];
static atomic_t zv_cumul_dist_counts[NCHUNKS];
-static struct zv_hdr *zv_create(struct zs_pool *pool, uint32_t pool_id,
+static unsigned long zv_create(struct zs_pool *pool, uint32_t pool_id,
struct tmem_oid *oid, uint32_t index,
void *cdata, unsigned clen)
{
struct zv_hdr *zv;
u32 size = clen + sizeof(struct zv_hdr);
int chunks = (size + (CHUNK_SIZE - 1)) >> CHUNK_SHIFT;
- void *handle = NULL;
+ unsigned long handle = 0;
BUG_ON(!irqs_disabled());
BUG_ON(chunks >= NCHUNKS);
@@ -709,7 +716,7 @@ static struct zv_hdr *zv_create(struct zs_pool *pool, uint32_t pool_id,
goto out;
atomic_inc(&zv_curr_dist_counts[chunks]);
atomic_inc(&zv_cumul_dist_counts[chunks]);
- zv = zs_map_object(pool, handle);
+ zv = zs_map_object(pool, handle, ZS_MM_WO);
zv->index = index;
zv->oid = *oid;
zv->pool_id = pool_id;
@@ -721,14 +728,14 @@ out:
return handle;
}
-static void zv_free(struct zs_pool *pool, void *handle)
+static void zv_free(struct zs_pool *pool, unsigned long handle)
{
unsigned long flags;
struct zv_hdr *zv;
uint16_t size;
int chunks;
- zv = zs_map_object(pool, handle);
+ zv = zs_map_object(pool, handle, ZS_MM_RW);
ASSERT_SENTINEL(zv, ZVH);
size = zv->size + sizeof(struct zv_hdr);
INVERT_SENTINEL(zv, ZVH);
@@ -743,14 +750,14 @@ static void zv_free(struct zs_pool *pool, void *handle)
local_irq_restore(flags);
}
-static void zv_decompress(struct page *page, void *handle)
+static void zv_decompress(struct page *page, unsigned long handle)
{
unsigned int clen = PAGE_SIZE;
char *to_va;
int ret;
struct zv_hdr *zv;
- zv = zs_map_object(zcache_host.zspool, handle);
+ zv = zs_map_object(zcache_host.zspool, handle, ZS_MM_RO);
BUG_ON(zv->size == 0);
ASSERT_SENTINEL(zv, ZVH);
to_va = kmap_atomic(page);
@@ -939,21 +946,14 @@ static struct tmem_pool *zcache_get_pool_by_id(uint16_t cli_id, uint16_t poolid)
struct tmem_pool *pool = NULL;
struct zcache_client *cli = NULL;
- if (cli_id == LOCAL_CLIENT)
- cli = &zcache_host;
- else {
- if (cli_id >= MAX_CLIENTS)
- goto out;
- cli = &zcache_clients[cli_id];
- if (cli == NULL)
- goto out;
- atomic_inc(&cli->refcount);
- }
- if (poolid < MAX_POOLS_PER_CLIENT) {
- pool = cli->tmem_pools[poolid];
- if (pool != NULL)
- atomic_inc(&pool->refcount);
- }
+ cli = get_zcache_client(cli_id);
+ if (!cli)
+ goto out;
+
+ atomic_inc(&cli->refcount);
+ pool = idr_find(&cli->tmem_pools, poolid);
+ if (pool != NULL)
+ atomic_inc(&pool->refcount);
out:
return pool;
}
@@ -971,13 +971,11 @@ static void zcache_put_pool(struct tmem_pool *pool)
int zcache_new_client(uint16_t cli_id)
{
- struct zcache_client *cli = NULL;
+ struct zcache_client *cli;
int ret = -1;
- if (cli_id == LOCAL_CLIENT)
- cli = &zcache_host;
- else if ((unsigned int)cli_id < MAX_CLIENTS)
- cli = &zcache_clients[cli_id];
+ cli = get_zcache_client(cli_id);
+
if (cli == NULL)
goto out;
if (cli->allocated)
@@ -987,6 +985,7 @@ int zcache_new_client(uint16_t cli_id)
cli->zspool = zs_create_pool("zcache", ZCACHE_GFP_MASK);
if (cli->zspool == NULL)
goto out;
+ idr_init(&cli->tmem_pools);
#endif
ret = 0;
out:
@@ -1035,45 +1034,38 @@ static int zcache_do_preload(struct tmem_pool *pool)
goto out;
if (unlikely(zcache_obj_cache == NULL))
goto out;
- preempt_disable();
+
+ /* IRQ has already been disabled. */
kp = &__get_cpu_var(zcache_preloads);
while (kp->nr < ARRAY_SIZE(kp->objnodes)) {
- preempt_enable_no_resched();
objnode = kmem_cache_alloc(zcache_objnode_cache,
ZCACHE_GFP_MASK);
if (unlikely(objnode == NULL)) {
zcache_failed_alloc++;
goto out;
}
- preempt_disable();
- kp = &__get_cpu_var(zcache_preloads);
- if (kp->nr < ARRAY_SIZE(kp->objnodes))
- kp->objnodes[kp->nr++] = objnode;
- else
- kmem_cache_free(zcache_objnode_cache, objnode);
+
+ kp->objnodes[kp->nr++] = objnode;
}
- preempt_enable_no_resched();
- obj = kmem_cache_alloc(zcache_obj_cache, ZCACHE_GFP_MASK);
- if (unlikely(obj == NULL)) {
- zcache_failed_alloc++;
- goto out;
+
+ if (!kp->obj) {
+ obj = kmem_cache_alloc(zcache_obj_cache, ZCACHE_GFP_MASK);
+ if (unlikely(obj == NULL)) {
+ zcache_failed_alloc++;
+ goto out;
+ }
+ kp->obj = obj;
}
- page = (void *)__get_free_page(ZCACHE_GFP_MASK);
- if (unlikely(page == NULL)) {
- zcache_failed_get_free_pages++;
- kmem_cache_free(zcache_obj_cache, obj);
- goto out;
+
+ if (!kp->page) {
+ page = (void *)__get_free_page(ZCACHE_GFP_MASK);
+ if (unlikely(page == NULL)) {
+ zcache_failed_get_free_pages++;
+ goto out;
+ }
+ kp->page = page;
}
- preempt_disable();
- kp = &__get_cpu_var(zcache_preloads);
- if (kp->obj == NULL)
- kp->obj = obj;
- else
- kmem_cache_free(zcache_obj_cache, obj);
- if (kp->page == NULL)
- kp->page = page;
- else
- free_page((unsigned long)page);
+
ret = 0;
out:
return ret;
@@ -1247,7 +1239,7 @@ static int zcache_pampd_get_data(char *data, size_t *bufsize, bool raw,
int ret = 0;
BUG_ON(is_ephemeral(pool));
- zv_decompress((struct page *)(data), pampd);
+ zv_decompress((struct page *)(data), (unsigned long)pampd);
return ret;
}
@@ -1282,7 +1274,7 @@ static void zcache_pampd_free(void *pampd, struct tmem_pool *pool,
atomic_dec(&zcache_curr_eph_pampd_count);
BUG_ON(atomic_read(&zcache_curr_eph_pampd_count) < 0);
} else {
- zv_free(cli->zspool, pampd);
+ zv_free(cli->zspool, (unsigned long)pampd);
atomic_dec(&zcache_curr_pers_pampd_count);
BUG_ON(atomic_read(&zcache_curr_pers_pampd_count) < 0);
}
@@ -1583,15 +1575,14 @@ static int zcache_put_page(int cli_id, int pool_id, struct tmem_oid *oidp,
else
zcache_failed_pers_puts++;
}
- zcache_put_pool(pool);
- preempt_enable_no_resched();
} else {
zcache_put_to_flush++;
if (atomic_read(&pool->obj_count) > 0)
/* the put fails whether the flush succeeds or not */
(void)tmem_flush_page(pool, oidp, index);
- zcache_put_pool(pool);
}
+
+ zcache_put_pool(pool);
out:
return ret;
}
@@ -1661,22 +1652,21 @@ static int zcache_flush_object(int cli_id, int pool_id,
static int zcache_destroy_pool(int cli_id, int pool_id)
{
struct tmem_pool *pool = NULL;
- struct zcache_client *cli = NULL;
+ struct zcache_client *cli;
int ret = -1;
if (pool_id < 0)
goto out;
- if (cli_id == LOCAL_CLIENT)
- cli = &zcache_host;
- else if ((unsigned int)cli_id < MAX_CLIENTS)
- cli = &zcache_clients[cli_id];
+
+ cli = get_zcache_client(cli_id);
if (cli == NULL)
goto out;
+
atomic_inc(&cli->refcount);
- pool = cli->tmem_pools[pool_id];
+ pool = idr_find(&cli->tmem_pools, pool_id);
if (pool == NULL)
goto out;
- cli->tmem_pools[pool_id] = NULL;
+ idr_remove(&cli->tmem_pools, pool_id);
/* wait for pool activity on other cpus to quiesce */
while (atomic_read(&pool->refcount) != 0)
;
@@ -1696,13 +1686,12 @@ static int zcache_new_pool(uint16_t cli_id, uint32_t flags)
int poolid = -1;
struct tmem_pool *pool;
struct zcache_client *cli = NULL;
+ int r;
- if (cli_id == LOCAL_CLIENT)
- cli = &zcache_host;
- else if ((unsigned int)cli_id < MAX_CLIENTS)
- cli = &zcache_clients[cli_id];
+ cli = get_zcache_client(cli_id);
if (cli == NULL)
goto out;
+
atomic_inc(&cli->refcount);
pool = kmalloc(sizeof(struct tmem_pool), GFP_ATOMIC);
if (pool == NULL) {
@@ -1710,20 +1699,25 @@ static int zcache_new_pool(uint16_t cli_id, uint32_t flags)
goto out;
}
- for (poolid = 0; poolid < MAX_POOLS_PER_CLIENT; poolid++)
- if (cli->tmem_pools[poolid] == NULL)
- break;
- if (poolid >= MAX_POOLS_PER_CLIENT) {
- pr_info("zcache: pool creation failed: max exceeded\n");
+ do {
+ r = idr_pre_get(&cli->tmem_pools, GFP_ATOMIC);
+ if (r != 1) {
+ kfree(pool);
+ pr_info("zcache: pool creation failed: out of memory\n");
+ goto out;
+ }
+ r = idr_get_new(&cli->tmem_pools, pool, &poolid);
+ } while (r == -EAGAIN);
+ if (r) {
+ pr_info("zcache: pool creation failed: error %d\n", r);
kfree(pool);
- poolid = -1;
goto out;
}
+
atomic_set(&pool->refcount, 0);
pool->client = cli;
pool->pool_id = poolid;
tmem_new_pool(pool, flags);
- cli->tmem_pools[poolid] = pool;
pr_info("zcache: created %s tmem pool, id=%d, client=%d\n",
flags & TMEM_POOL_PERSIST ? "persistent" : "ephemeral",
poolid, cli_id);
@@ -1835,7 +1829,7 @@ static int zcache_frontswap_poolid = -1;
* Swizzling increases objects per swaptype, increasing tmem concurrency
* for heavy swaploads. Later, larger nr_cpus -> larger SWIZ_BITS
* Setting SWIZ_BITS to 27 basically reconstructs the swap entry from
- * frontswap_get_page(), but has side-effects. Hence using 8.
+ * frontswap_load(), but has side-effects. Hence using 8.
*/
#define SWIZ_BITS 8
#define SWIZ_MASK ((1 << SWIZ_BITS) - 1)
@@ -1849,7 +1843,7 @@ static inline struct tmem_oid oswiz(unsigned type, u32 ind)
return oid;
}
-static int zcache_frontswap_put_page(unsigned type, pgoff_t offset,
+static int zcache_frontswap_store(unsigned type, pgoff_t offset,
struct page *page)
{
u64 ind64 = (u64)offset;
@@ -1870,7 +1864,7 @@ static int zcache_frontswap_put_page(unsigned type, pgoff_t offset,
/* returns 0 if the page was successfully gotten from frontswap, -1 if
* was not present (should never happen!) */
-static int zcache_frontswap_get_page(unsigned type, pgoff_t offset,
+static int zcache_frontswap_load(unsigned type, pgoff_t offset,
struct page *page)
{
u64 ind64 = (u64)offset;
@@ -1919,8 +1913,8 @@ static void zcache_frontswap_init(unsigned ignored)
}
static struct frontswap_ops zcache_frontswap_ops = {
- .put_page = zcache_frontswap_put_page,
- .get_page = zcache_frontswap_get_page,
+ .store = zcache_frontswap_store,
+ .load = zcache_frontswap_load,
.invalidate_page = zcache_frontswap_flush_page,
.invalidate_area = zcache_frontswap_flush_area,
.init = zcache_frontswap_init
@@ -1981,7 +1975,7 @@ static int __init enable_zcache_compressor(char *s)
__setup("zcache=", enable_zcache_compressor);
-static int zcache_comp_init(void)
+static int __init zcache_comp_init(void)
{
int ret = 0;
@@ -2021,7 +2015,7 @@ static int __init zcache_init(void)
goto out;
}
#endif /* CONFIG_SYSFS */
-#if defined(CONFIG_CLEANCACHE) || defined(CONFIG_FRONTSWAP)
+
if (zcache_enabled) {
unsigned int cpu;
@@ -2052,7 +2046,7 @@ static int __init zcache_init(void)
pr_err("zcache: can't create client\n");
goto out;
}
-#endif
+
#ifdef CONFIG_CLEANCACHE
if (zcache_enabled && use_cleancache) {
struct cleancache_ops old_ops;
diff --git a/drivers/staging/zram/Kconfig b/drivers/staging/zram/Kconfig
index 9d11a4cb99b7..be5abe8e7943 100644
--- a/drivers/staging/zram/Kconfig
+++ b/drivers/staging/zram/Kconfig
@@ -1,9 +1,6 @@
config ZRAM
tristate "Compressed RAM block device support"
- # X86 dependency is because zsmalloc uses non-portable pte/tlb
- # functions
- depends on BLOCK && SYSFS && X86
- select ZSMALLOC
+ depends on BLOCK && SYSFS && ZSMALLOC
select LZO_COMPRESS
select LZO_DECOMPRESS
default n
diff --git a/drivers/staging/zram/zram_drv.c b/drivers/staging/zram/zram_drv.c
index 685d612a627b..653b074035f7 100644
--- a/drivers/staging/zram/zram_drv.c
+++ b/drivers/staging/zram/zram_drv.c
@@ -135,7 +135,8 @@ static void zram_set_disksize(struct zram *zram, size_t totalram_bytes)
static void zram_free_page(struct zram *zram, size_t index)
{
- void *handle = zram->table[index].handle;
+ unsigned long handle = zram->table[index].handle;
+ u16 size = zram->table[index].size;
if (unlikely(!handle)) {
/*
@@ -149,24 +150,19 @@ static void zram_free_page(struct zram *zram, size_t index)
return;
}
- if (unlikely(zram_test_flag(zram, index, ZRAM_UNCOMPRESSED))) {
- __free_page(handle);
- zram_clear_flag(zram, index, ZRAM_UNCOMPRESSED);
- zram_stat_dec(&zram->stats.pages_expand);
- goto out;
- }
+ if (unlikely(size > max_zpage_size))
+ zram_stat_dec(&zram->stats.bad_compress);
zs_free(zram->mem_pool, handle);
- if (zram->table[index].size <= PAGE_SIZE / 2)
+ if (size <= PAGE_SIZE / 2)
zram_stat_dec(&zram->stats.good_compress);
-out:
zram_stat64_sub(zram, &zram->stats.compr_size,
zram->table[index].size);
zram_stat_dec(&zram->stats.pages_stored);
- zram->table[index].handle = NULL;
+ zram->table[index].handle = 0;
zram->table[index].size = 0;
}
@@ -182,22 +178,6 @@ static void handle_zero_page(struct bio_vec *bvec)
flush_dcache_page(page);
}
-static void handle_uncompressed_page(struct zram *zram, struct bio_vec *bvec,
- u32 index, int offset)
-{
- struct page *page = bvec->bv_page;
- unsigned char *user_mem, *cmem;
-
- user_mem = kmap_atomic(page);
- cmem = kmap_atomic(zram->table[index].handle);
-
- memcpy(user_mem + bvec->bv_offset, cmem + offset, bvec->bv_len);
- kunmap_atomic(cmem);
- kunmap_atomic(user_mem);
-
- flush_dcache_page(page);
-}
-
static inline int is_partial_io(struct bio_vec *bvec)
{
return bvec->bv_len != PAGE_SIZE;
@@ -209,7 +189,6 @@ static int zram_bvec_read(struct zram *zram, struct bio_vec *bvec,
int ret;
size_t clen;
struct page *page;
- struct zobj_header *zheader;
unsigned char *user_mem, *cmem, *uncmem = NULL;
page = bvec->bv_page;
@@ -227,12 +206,6 @@ static int zram_bvec_read(struct zram *zram, struct bio_vec *bvec,
return 0;
}
- /* Page is stored uncompressed since it's incompressible */
- if (unlikely(zram_test_flag(zram, index, ZRAM_UNCOMPRESSED))) {
- handle_uncompressed_page(zram, bvec, index, offset);
- return 0;
- }
-
if (is_partial_io(bvec)) {
/* Use a temporary buffer to decompress the page */
uncmem = kmalloc(PAGE_SIZE, GFP_KERNEL);
@@ -247,10 +220,10 @@ static int zram_bvec_read(struct zram *zram, struct bio_vec *bvec,
uncmem = user_mem;
clen = PAGE_SIZE;
- cmem = zs_map_object(zram->mem_pool, zram->table[index].handle);
+ cmem = zs_map_object(zram->mem_pool, zram->table[index].handle,
+ ZS_MM_RO);
- ret = lzo1x_decompress_safe(cmem + sizeof(*zheader),
- zram->table[index].size,
+ ret = lzo1x_decompress_safe(cmem, zram->table[index].size,
uncmem, &clen);
if (is_partial_io(bvec)) {
@@ -278,28 +251,18 @@ static int zram_read_before_write(struct zram *zram, char *mem, u32 index)
{
int ret;
size_t clen = PAGE_SIZE;
- struct zobj_header *zheader;
unsigned char *cmem;
+ unsigned long handle = zram->table[index].handle;
- if (zram_test_flag(zram, index, ZRAM_ZERO) ||
- !zram->table[index].handle) {
+ if (zram_test_flag(zram, index, ZRAM_ZERO) || !handle) {
memset(mem, 0, PAGE_SIZE);
return 0;
}
- cmem = zs_map_object(zram->mem_pool, zram->table[index].handle);
-
- /* Page is stored uncompressed since it's incompressible */
- if (unlikely(zram_test_flag(zram, index, ZRAM_UNCOMPRESSED))) {
- memcpy(mem, cmem, PAGE_SIZE);
- kunmap_atomic(cmem);
- return 0;
- }
-
- ret = lzo1x_decompress_safe(cmem + sizeof(*zheader),
- zram->table[index].size,
+ cmem = zs_map_object(zram->mem_pool, handle, ZS_MM_RO);
+ ret = lzo1x_decompress_safe(cmem, zram->table[index].size,
mem, &clen);
- zs_unmap_object(zram->mem_pool, zram->table[index].handle);
+ zs_unmap_object(zram->mem_pool, handle);
/* Should NEVER happen. Return bio error if it does. */
if (unlikely(ret != LZO_E_OK)) {
@@ -315,11 +278,9 @@ static int zram_bvec_write(struct zram *zram, struct bio_vec *bvec, u32 index,
int offset)
{
int ret;
- u32 store_offset;
size_t clen;
- void *handle;
- struct zobj_header *zheader;
- struct page *page, *page_store;
+ unsigned long handle;
+ struct page *page;
unsigned char *user_mem, *cmem, *src, *uncmem = NULL;
page = bvec->bv_page;
@@ -381,57 +342,21 @@ static int zram_bvec_write(struct zram *zram, struct bio_vec *bvec, u32 index,
goto out;
}
- /*
- * Page is incompressible. Store it as-is (uncompressed)
- * since we do not want to return too many disk write
- * errors which has side effect of hanging the system.
- */
- if (unlikely(clen > max_zpage_size)) {
- clen = PAGE_SIZE;
- page_store = alloc_page(GFP_NOIO | __GFP_HIGHMEM);
- if (unlikely(!page_store)) {
- pr_info("Error allocating memory for "
- "incompressible page: %u\n", index);
- ret = -ENOMEM;
- goto out;
- }
-
- store_offset = 0;
- zram_set_flag(zram, index, ZRAM_UNCOMPRESSED);
- zram_stat_inc(&zram->stats.pages_expand);
- handle = page_store;
- src = kmap_atomic(page);
- cmem = kmap_atomic(page_store);
- goto memstore;
- }
+ if (unlikely(clen > max_zpage_size))
+ zram_stat_inc(&zram->stats.bad_compress);
- handle = zs_malloc(zram->mem_pool, clen + sizeof(*zheader));
+ handle = zs_malloc(zram->mem_pool, clen);
if (!handle) {
pr_info("Error allocating memory for compressed "
"page: %u, size=%zu\n", index, clen);
ret = -ENOMEM;
goto out;
}
- cmem = zs_map_object(zram->mem_pool, handle);
-
-memstore:
-#if 0
- /* Back-reference needed for memory defragmentation */
- if (!zram_test_flag(zram, index, ZRAM_UNCOMPRESSED)) {
- zheader = (struct zobj_header *)cmem;
- zheader->table_idx = index;
- cmem += sizeof(*zheader);
- }
-#endif
+ cmem = zs_map_object(zram->mem_pool, handle, ZS_MM_WO);
memcpy(cmem, src, clen);
- if (unlikely(zram_test_flag(zram, index, ZRAM_UNCOMPRESSED))) {
- kunmap_atomic(cmem);
- kunmap_atomic(src);
- } else {
- zs_unmap_object(zram->mem_pool, handle);
- }
+ zs_unmap_object(zram->mem_pool, handle);
zram->table[index].handle = handle;
zram->table[index].size = clen;
@@ -592,14 +517,11 @@ void __zram_reset_device(struct zram *zram)
/* Free all pages that are still in this zram device */
for (index = 0; index < zram->disksize >> PAGE_SHIFT; index++) {
- void *handle = zram->table[index].handle;
+ unsigned long handle = zram->table[index].handle;
if (!handle)
continue;
- if (unlikely(zram_test_flag(zram, index, ZRAM_UNCOMPRESSED)))
- __free_page(handle);
- else
- zs_free(zram->mem_pool, handle);
+ zs_free(zram->mem_pool, handle);
}
vfree(zram->table);
@@ -724,7 +646,7 @@ static int create_device(struct zram *zram, int device_id)
zram->disk = alloc_disk(1);
if (!zram->disk) {
blk_cleanup_queue(zram->queue);
- pr_warning("Error allocating disk structure for device %d\n",
+ pr_warn("Error allocating disk structure for device %d\n",
device_id);
ret = -ENOMEM;
goto out;
@@ -755,7 +677,7 @@ static int create_device(struct zram *zram, int device_id)
ret = sysfs_create_group(&disk_to_dev(zram->disk)->kobj,
&zram_disk_attr_group);
if (ret < 0) {
- pr_warning("Error creating sysfs group");
+ pr_warn("Error creating sysfs group");
goto out;
}
@@ -789,7 +711,7 @@ static int __init zram_init(void)
int ret, dev_id;
if (num_devices > max_num_devices) {
- pr_warning("Invalid value for num_devices: %u\n",
+ pr_warn("Invalid value for num_devices: %u\n",
num_devices);
ret = -EINVAL;
goto out;
@@ -797,7 +719,7 @@ static int __init zram_init(void)
zram_major = register_blkdev(0, "zram");
if (zram_major <= 0) {
- pr_warning("Unable to get major number\n");
+ pr_warn("Unable to get major number\n");
ret = -EBUSY;
goto out;
}
diff --git a/drivers/staging/zram/zram_drv.h b/drivers/staging/zram/zram_drv.h
index fbe8ac98704c..572c0b1551d4 100644
--- a/drivers/staging/zram/zram_drv.h
+++ b/drivers/staging/zram/zram_drv.h
@@ -26,18 +26,6 @@
*/
static const unsigned max_num_devices = 32;
-/*
- * Stored at beginning of each compressed object.
- *
- * It stores back-reference to table entry which points to this
- * object. This is required to support memory defragmentation.
- */
-struct zobj_header {
-#if 0
- u32 table_idx;
-#endif
-};
-
/*-- Configurable parameters */
/* Default zram disk size: 25% of total RAM */
@@ -68,9 +56,6 @@ static const size_t max_zpage_size = PAGE_SIZE / 4 * 3;
/* Flags for zram pages (table[page_no].flags) */
enum zram_pageflags {
- /* Page is stored uncompressed */
- ZRAM_UNCOMPRESSED,
-
/* Page consists entirely of zeros */
ZRAM_ZERO,
@@ -81,11 +66,11 @@ enum zram_pageflags {
/* Allocated for each disk page */
struct table {
- void *handle;
+ unsigned long handle;
u16 size; /* object size (excluding header) */
u8 count; /* object ref count (not yet used) */
u8 flags;
-} __attribute__((aligned(4)));
+} __aligned(4);
struct zram_stats {
u64 compr_size; /* compressed size of pages stored */
@@ -98,7 +83,7 @@ struct zram_stats {
u32 pages_zero; /* no. of zero filled pages */
u32 pages_stored; /* no. of pages currently stored */
u32 good_compress; /* % of pages with compression ratio<=50% */
- u32 pages_expand; /* % of incompressible pages */
+ u32 bad_compress; /* % of pages with compression ratio>=75% */
};
struct zram {
diff --git a/drivers/staging/zram/zram_sysfs.c b/drivers/staging/zram/zram_sysfs.c
index a7f377175525..edb0ed4125d5 100644
--- a/drivers/staging/zram/zram_sysfs.c
+++ b/drivers/staging/zram/zram_sysfs.c
@@ -186,10 +186,8 @@ static ssize_t mem_used_total_show(struct device *dev,
u64 val = 0;
struct zram *zram = dev_to_zram(dev);
- if (zram->init_done) {
- val = zs_get_total_size_bytes(zram->mem_pool) +
- ((u64)(zram->stats.pages_expand) << PAGE_SHIFT);
- }
+ if (zram->init_done)
+ val = zs_get_total_size_bytes(zram->mem_pool);
return sprintf(buf, "%llu\n", val);
}
diff --git a/drivers/staging/zsmalloc/Kconfig b/drivers/staging/zsmalloc/Kconfig
index a5ab7200626f..908456565796 100644
--- a/drivers/staging/zsmalloc/Kconfig
+++ b/drivers/staging/zsmalloc/Kconfig
@@ -1,9 +1,5 @@
config ZSMALLOC
tristate "Memory allocator for compressed pages"
- # X86 dependency is because of the use of __flush_tlb_one and set_pte
- # in zsmalloc-main.c.
- # TODO: convert these to portable functions
- depends on X86
default n
help
zsmalloc is a slab-based memory allocator designed to store
diff --git a/drivers/staging/zsmalloc/zsmalloc-main.c b/drivers/staging/zsmalloc/zsmalloc-main.c
index 917461c66014..8b0bcb626a7f 100644
--- a/drivers/staging/zsmalloc/zsmalloc-main.c
+++ b/drivers/staging/zsmalloc/zsmalloc-main.c
@@ -10,6 +10,54 @@
* Released under the terms of GNU General Public License Version 2.0
*/
+
+/*
+ * This allocator is designed for use with zcache and zram. Thus, the
+ * allocator is supposed to work well under low memory conditions. In
+ * particular, it never attempts higher order page allocation which is
+ * very likely to fail under memory pressure. On the other hand, if we
+ * just use single (0-order) pages, it would suffer from very high
+ * fragmentation -- any object of size PAGE_SIZE/2 or larger would occupy
+ * an entire page. This was one of the major issues with its predecessor
+ * (xvmalloc).
+ *
+ * To overcome these issues, zsmalloc allocates a bunch of 0-order pages
+ * and links them together using various 'struct page' fields. These linked
+ * pages act as a single higher-order page i.e. an object can span 0-order
+ * page boundaries. The code refers to these linked pages as a single entity
+ * called zspage.
+ *
+ * Following is how we use various fields and flags of underlying
+ * struct page(s) to form a zspage.
+ *
+ * Usage of struct page fields:
+ * page->first_page: points to the first component (0-order) page
+ * page->index (union with page->freelist): offset of the first object
+ * starting in this page. For the first page, this is
+ * always 0, so we use this field (aka freelist) to point
+ * to the first free object in zspage.
+ * page->lru: links together all component pages (except the first page)
+ * of a zspage
+ *
+ * For _first_ page only:
+ *
+ * page->private (union with page->first_page): refers to the
+ * component page after the first page
+ * page->freelist: points to the first free object in zspage.
+ * Free objects are linked together using in-place
+ * metadata.
+ * page->objects: maximum number of objects we can store in this
+ * zspage (class->zspage_order * PAGE_SIZE / class->size)
+ * page->lru: links together first pages of various zspages.
+ * Basically forming list of zspages in a fullness group.
+ * page->mapping: class index and fullness group of the zspage
+ *
+ * Usage of struct page flags:
+ * PG_private: identifies the first component page
+ * PG_private2: identifies the last component page
+ *
+ */
+
#ifdef CONFIG_ZSMALLOC_DEBUG
#define DEBUG
#endif
@@ -45,12 +93,12 @@ static DEFINE_PER_CPU(struct mapping_area, zs_map_area);
static int is_first_page(struct page *page)
{
- return test_bit(PG_private, &page->flags);
+ return PagePrivate(page);
}
static int is_last_page(struct page *page)
{
- return test_bit(PG_private_2, &page->flags);
+ return PagePrivate2(page);
}
static void get_zspage_mapping(struct page *page, unsigned int *class_idx,
@@ -180,7 +228,7 @@ out:
* link together 3 PAGE_SIZE sized pages to form a zspage
* since then we can perfectly fit in 8 such objects.
*/
-static int get_zspage_order(int class_size)
+static int get_pages_per_zspage(int class_size)
{
int i, max_usedpc = 0;
/* zspage order which gives maximum used size per KB */
@@ -247,13 +295,11 @@ static void *obj_location_to_handle(struct page *page, unsigned long obj_idx)
}
/* Decode <page, obj_idx> pair from the given object handle */
-static void obj_handle_to_location(void *handle, struct page **page,
+static void obj_handle_to_location(unsigned long handle, struct page **page,
unsigned long *obj_idx)
{
- unsigned long hval = (unsigned long)handle;
-
- *page = pfn_to_page(hval >> OBJ_INDEX_BITS);
- *obj_idx = hval & OBJ_INDEX_MASK;
+ *page = pfn_to_page(handle >> OBJ_INDEX_BITS);
+ *obj_idx = handle & OBJ_INDEX_MASK;
}
static unsigned long obj_idx_to_offset(struct page *page,
@@ -354,7 +400,7 @@ static void init_zspage(struct page *first_page, struct size_class *class)
static struct page *alloc_zspage(struct size_class *class, gfp_t flags)
{
int i, error;
- struct page *first_page = NULL;
+ struct page *first_page = NULL, *uninitialized_var(prev_page);
/*
* Allocate individual pages and link them together as:
@@ -368,8 +414,8 @@ static struct page *alloc_zspage(struct size_class *class, gfp_t flags)
* identify the last page.
*/
error = -ENOMEM;
- for (i = 0; i < class->zspage_order; i++) {
- struct page *page, *prev_page;
+ for (i = 0; i < class->pages_per_zspage; i++) {
+ struct page *page;
page = alloc_page(flags);
if (!page)
@@ -377,7 +423,7 @@ static struct page *alloc_zspage(struct size_class *class, gfp_t flags)
INIT_LIST_HEAD(&page->lru);
if (i == 0) { /* first page */
- set_bit(PG_private, &page->flags);
+ SetPagePrivate(page);
set_page_private(page, 0);
first_page = page;
first_page->inuse = 0;
@@ -388,9 +434,8 @@ static struct page *alloc_zspage(struct size_class *class, gfp_t flags)
page->first_page = first_page;
if (i >= 2)
list_add(&page->lru, &prev_page->lru);
- if (i == class->zspage_order - 1) /* last page */
- set_bit(PG_private_2, &page->flags);
-
+ if (i == class->pages_per_zspage - 1) /* last page */
+ SetPagePrivate2(page);
prev_page = page;
}
@@ -398,7 +443,7 @@ static struct page *alloc_zspage(struct size_class *class, gfp_t flags)
first_page->freelist = obj_location_to_handle(first_page, 0);
/* Maximum number of objects we can store in this zspage */
- first_page->objects = class->zspage_order * PAGE_SIZE / class->size;
+ first_page->objects = class->pages_per_zspage * PAGE_SIZE / class->size;
error = 0; /* Success */
@@ -425,12 +470,51 @@ static struct page *find_get_zspage(struct size_class *class)
return page;
}
+static void zs_copy_map_object(char *buf, struct page *firstpage,
+ int off, int size)
+{
+ struct page *pages[2];
+ int sizes[2];
+ void *addr;
+
+ pages[0] = firstpage;
+ pages[1] = get_next_page(firstpage);
+ BUG_ON(!pages[1]);
+
+ sizes[0] = PAGE_SIZE - off;
+ sizes[1] = size - sizes[0];
+
+ /* copy object to per-cpu buffer */
+ addr = kmap_atomic(pages[0]);
+ memcpy(buf, addr + off, sizes[0]);
+ kunmap_atomic(addr);
+ addr = kmap_atomic(pages[1]);
+ memcpy(buf + sizes[0], addr, sizes[1]);
+ kunmap_atomic(addr);
+}
-/*
- * If this becomes a separate module, register zs_init() with
- * module_init(), zs_exit with module_exit(), and remove zs_initialized
-*/
-static int zs_initialized;
+static void zs_copy_unmap_object(char *buf, struct page *firstpage,
+ int off, int size)
+{
+ struct page *pages[2];
+ int sizes[2];
+ void *addr;
+
+ pages[0] = firstpage;
+ pages[1] = get_next_page(firstpage);
+ BUG_ON(!pages[1]);
+
+ sizes[0] = PAGE_SIZE - off;
+ sizes[1] = size - sizes[0];
+
+ /* copy per-cpu buffer to object */
+ addr = kmap_atomic(pages[0]);
+ memcpy(addr + off, buf, sizes[0]);
+ kunmap_atomic(addr);
+ addr = kmap_atomic(pages[1]);
+ memcpy(addr, buf + sizes[0], sizes[1]);
+ kunmap_atomic(addr);
+}
static int zs_cpu_notifier(struct notifier_block *nb, unsigned long action,
void *pcpu)
@@ -441,18 +525,23 @@ static int zs_cpu_notifier(struct notifier_block *nb, unsigned long action,
switch (action) {
case CPU_UP_PREPARE:
area = &per_cpu(zs_map_area, cpu);
- if (area->vm)
- break;
- area->vm = alloc_vm_area(2 * PAGE_SIZE, area->vm_ptes);
- if (!area->vm)
- return notifier_from_errno(-ENOMEM);
+ /*
+ * Make sure we don't leak memory if a cpu UP notification
+ * and zs_init() race and both call zs_cpu_up() on the same cpu
+ */
+ if (area->vm_buf)
+ return 0;
+ area->vm_buf = (char *)__get_free_page(GFP_KERNEL);
+ if (!area->vm_buf)
+ return -ENOMEM;
+ return 0;
break;
case CPU_DEAD:
case CPU_UP_CANCELED:
area = &per_cpu(zs_map_area, cpu);
- if (area->vm)
- free_vm_area(area->vm);
- area->vm = NULL;
+ if (area->vm_buf)
+ free_page((unsigned long)area->vm_buf);
+ area->vm_buf = NULL;
break;
}
@@ -490,7 +579,7 @@ fail:
struct zs_pool *zs_create_pool(const char *name, gfp_t flags)
{
- int i, error, ovhd_size;
+ int i, ovhd_size;
struct zs_pool *pool;
if (!name)
@@ -513,32 +602,13 @@ struct zs_pool *zs_create_pool(const char *name, gfp_t flags)
class->size = size;
class->index = i;
spin_lock_init(&class->lock);
- class->zspage_order = get_zspage_order(size);
+ class->pages_per_zspage = get_pages_per_zspage(size);
}
- /*
- * If this becomes a separate module, register zs_init with
- * module_init, and remove this block
- */
- if (!zs_initialized) {
- error = zs_init();
- if (error)
- goto cleanup;
- zs_initialized = 1;
- }
-
pool->flags = flags;
pool->name = name;
- error = 0; /* Success */
-
-cleanup:
- if (error) {
- zs_destroy_pool(pool);
- pool = NULL;
- }
-
return pool;
}
EXPORT_SYMBOL_GPL(zs_create_pool);
@@ -567,18 +637,14 @@ EXPORT_SYMBOL_GPL(zs_destroy_pool);
* zs_malloc - Allocate block of given size from pool.
* @pool: pool to allocate from
* @size: size of block to allocate
- * @page: page no. that holds the object
- * @offset: location of object within page
- *
- * On success, <page, offset> identifies block allocated
- * and 0 is returned. On failure, <page, offset> is set to
- * 0 and -ENOMEM is returned.
*
+ * On success, handle to the allocated object is returned,
+ * otherwise 0.
* Allocation requests with size > ZS_MAX_ALLOC_SIZE will fail.
*/
-void *zs_malloc(struct zs_pool *pool, size_t size)
+unsigned long zs_malloc(struct zs_pool *pool, size_t size)
{
- void *obj;
+ unsigned long obj;
struct link_free *link;
int class_idx;
struct size_class *class;
@@ -587,7 +653,7 @@ void *zs_malloc(struct zs_pool *pool, size_t size)
unsigned long m_objidx, m_offset;
if (unlikely(!size || size > ZS_MAX_ALLOC_SIZE))
- return NULL;
+ return 0;
class_idx = get_size_class_index(size);
class = &pool->size_class[class_idx];
@@ -600,14 +666,14 @@ void *zs_malloc(struct zs_pool *pool, size_t size)
spin_unlock(&class->lock);
first_page = alloc_zspage(class, pool->flags);
if (unlikely(!first_page))
- return NULL;
+ return 0;
set_zspage_mapping(first_page, class->index, ZS_EMPTY);
spin_lock(&class->lock);
- class->pages_allocated += class->zspage_order;
+ class->pages_allocated += class->pages_per_zspage;
}
- obj = first_page->freelist;
+ obj = (unsigned long)first_page->freelist;
obj_handle_to_location(obj, &m_page, &m_objidx);
m_offset = obj_idx_to_offset(m_page, m_objidx, class->size);
@@ -626,7 +692,7 @@ void *zs_malloc(struct zs_pool *pool, size_t size)
}
EXPORT_SYMBOL_GPL(zs_malloc);
-void zs_free(struct zs_pool *pool, void *obj)
+void zs_free(struct zs_pool *pool, unsigned long obj)
{
struct link_free *link;
struct page *first_page, *f_page;
@@ -653,13 +719,13 @@ void zs_free(struct zs_pool *pool, void *obj)
+ f_offset);
link->next = first_page->freelist;
kunmap_atomic(link);
- first_page->freelist = obj;
+ first_page->freelist = (void *)obj;
first_page->inuse--;
fullness = fix_fullness_group(pool, first_page);
if (fullness == ZS_EMPTY)
- class->pages_allocated -= class->zspage_order;
+ class->pages_allocated -= class->pages_per_zspage;
spin_unlock(&class->lock);
@@ -668,7 +734,22 @@ void zs_free(struct zs_pool *pool, void *obj)
}
EXPORT_SYMBOL_GPL(zs_free);
-void *zs_map_object(struct zs_pool *pool, void *handle)
+/**
+ * zs_map_object - get address of allocated object from handle.
+ * @pool: pool from which the object was allocated
+ * @handle: handle returned from zs_malloc
+ *
+ * Before using an object allocated from zs_malloc, it must be mapped using
+ * this function. When done with the object, it must be unmapped using
+ * zs_unmap_object.
+ *
+ * Only one object can be mapped per cpu at a time. There is no protection
+ * against nested mappings.
+ *
+ * This function returns with preemption and page faults disabled.
+*/
+void *zs_map_object(struct zs_pool *pool, unsigned long handle,
+ enum zs_mapmode mm)
{
struct page *page;
unsigned long obj_idx, off;
@@ -689,26 +770,20 @@ void *zs_map_object(struct zs_pool *pool, void *handle)
if (off + class->size <= PAGE_SIZE) {
/* this object is contained entirely within a page */
area->vm_addr = kmap_atomic(page);
- } else {
- /* this object spans two pages */
- struct page *nextp;
-
- nextp = get_next_page(page);
- BUG_ON(!nextp);
-
-
- set_pte(area->vm_ptes[0], mk_pte(page, PAGE_KERNEL));
- set_pte(area->vm_ptes[1], mk_pte(nextp, PAGE_KERNEL));
-
- /* We pre-allocated VM area so mapping can never fail */
- area->vm_addr = area->vm->addr;
+ return area->vm_addr + off;
}
- return area->vm_addr + off;
+ /* disable page faults to match kmap_atomic() return conditions */
+ pagefault_disable();
+
+ if (mm != ZS_MM_WO)
+ zs_copy_map_object(area->vm_buf, page, off, class->size);
+ area->vm_addr = NULL;
+ return area->vm_buf;
}
EXPORT_SYMBOL_GPL(zs_map_object);
-void zs_unmap_object(struct zs_pool *pool, void *handle)
+void zs_unmap_object(struct zs_pool *pool, unsigned long handle)
{
struct page *page;
unsigned long obj_idx, off;
@@ -718,6 +793,17 @@ void zs_unmap_object(struct zs_pool *pool, void *handle)
struct size_class *class;
struct mapping_area *area;
+ area = &__get_cpu_var(zs_map_area);
+ /* single-page object fastpath */
+ if (area->vm_addr) {
+ kunmap_atomic(area->vm_addr);
+ goto out;
+ }
+
+ /* no write fastpath */
+ if (area->vm_mm == ZS_MM_RO)
+ goto pfenable;
+
BUG_ON(!handle);
obj_handle_to_location(handle, &page, &obj_idx);
@@ -725,15 +811,12 @@ void zs_unmap_object(struct zs_pool *pool, void *handle)
class = &pool->size_class[class_idx];
off = obj_idx_to_offset(page, obj_idx, class->size);
- area = &__get_cpu_var(zs_map_area);
- if (off + class->size <= PAGE_SIZE) {
- kunmap_atomic(area->vm_addr);
- } else {
- set_pte(area->vm_ptes[0], __pte(0));
- set_pte(area->vm_ptes[1], __pte(0));
- __flush_tlb_one((unsigned long)area->vm_addr);
- __flush_tlb_one((unsigned long)area->vm_addr + PAGE_SIZE);
- }
+ zs_copy_unmap_object(area->vm_buf, page, off, class->size);
+
+pfenable:
+ /* enable page faults to match kunmap_atomic() return conditions */
+ pagefault_enable();
+out:
put_cpu_var(zs_map_area);
}
EXPORT_SYMBOL_GPL(zs_unmap_object);
@@ -749,3 +832,9 @@ u64 zs_get_total_size_bytes(struct zs_pool *pool)
return npages << PAGE_SHIFT;
}
EXPORT_SYMBOL_GPL(zs_get_total_size_bytes);
+
+module_init(zs_init);
+module_exit(zs_exit);
+
+MODULE_LICENSE("Dual BSD/GPL");
+MODULE_AUTHOR("Nitin Gupta <ngupta@vflare.org>");
diff --git a/drivers/staging/zsmalloc/zsmalloc.h b/drivers/staging/zsmalloc/zsmalloc.h
index 949384ee7491..de2e8bfbcc06 100644
--- a/drivers/staging/zsmalloc/zsmalloc.h
+++ b/drivers/staging/zsmalloc/zsmalloc.h
@@ -15,16 +15,28 @@
#include <linux/types.h>
+/*
+ * zsmalloc mapping modes
+ *
+ * NOTE: These only make a difference when a mapped object spans pages
+*/
+enum zs_mapmode {
+ ZS_MM_RW, /* normal read-write mapping */
+ ZS_MM_RO, /* read-only (no copy-out at unmap time) */
+ ZS_MM_WO /* write-only (no copy-in at map time) */
+};
+
struct zs_pool;
struct zs_pool *zs_create_pool(const char *name, gfp_t flags);
void zs_destroy_pool(struct zs_pool *pool);
-void *zs_malloc(struct zs_pool *pool, size_t size);
-void zs_free(struct zs_pool *pool, void *obj);
+unsigned long zs_malloc(struct zs_pool *pool, size_t size);
+void zs_free(struct zs_pool *pool, unsigned long obj);
-void *zs_map_object(struct zs_pool *pool, void *handle);
-void zs_unmap_object(struct zs_pool *pool, void *handle);
+void *zs_map_object(struct zs_pool *pool, unsigned long handle,
+ enum zs_mapmode mm);
+void zs_unmap_object(struct zs_pool *pool, unsigned long handle);
u64 zs_get_total_size_bytes(struct zs_pool *pool);
diff --git a/drivers/staging/zsmalloc/zsmalloc_int.h b/drivers/staging/zsmalloc/zsmalloc_int.h
index 92eefc663afc..528051767733 100644
--- a/drivers/staging/zsmalloc/zsmalloc_int.h
+++ b/drivers/staging/zsmalloc/zsmalloc_int.h
@@ -110,9 +110,9 @@ enum fullness_group {
static const int fullness_threshold_frac = 4;
struct mapping_area {
- struct vm_struct *vm;
- pte_t *vm_ptes[2];
- char *vm_addr;
+ char *vm_buf; /* copy buffer for objects that span pages */
+ char *vm_addr; /* address of kmap_atomic()'ed pages */
+ enum zs_mapmode vm_mm; /* mapping mode */
};
struct size_class {
@@ -124,7 +124,7 @@ struct size_class {
unsigned int index;
/* Number of PAGE_SIZE sized pages to combine to form a 'zspage' */
- int zspage_order;
+ int pages_per_zspage;
spinlock_t lock;