18c2ecf20Sopenharmony_ci/* 28c2ecf20Sopenharmony_ci * Intel Wireless WiMAX Connection 2400m 38c2ecf20Sopenharmony_ci * Declarations for bus-generic internal APIs 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * 68c2ecf20Sopenharmony_ci * Copyright (C) 2007-2008 Intel Corporation. All rights reserved. 78c2ecf20Sopenharmony_ci * 88c2ecf20Sopenharmony_ci * Redistribution and use in source and binary forms, with or without 98c2ecf20Sopenharmony_ci * modification, are permitted provided that the following conditions 108c2ecf20Sopenharmony_ci * are met: 118c2ecf20Sopenharmony_ci * 128c2ecf20Sopenharmony_ci * * Redistributions of source code must retain the above copyright 138c2ecf20Sopenharmony_ci * notice, this list of conditions and the following disclaimer. 148c2ecf20Sopenharmony_ci * * Redistributions in binary form must reproduce the above copyright 158c2ecf20Sopenharmony_ci * notice, this list of conditions and the following disclaimer in 168c2ecf20Sopenharmony_ci * the documentation and/or other materials provided with the 178c2ecf20Sopenharmony_ci * distribution. 188c2ecf20Sopenharmony_ci * * Neither the name of Intel Corporation nor the names of its 198c2ecf20Sopenharmony_ci * contributors may be used to endorse or promote products derived 208c2ecf20Sopenharmony_ci * from this software without specific prior written permission. 218c2ecf20Sopenharmony_ci * 228c2ecf20Sopenharmony_ci * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 238c2ecf20Sopenharmony_ci * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 248c2ecf20Sopenharmony_ci * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 258c2ecf20Sopenharmony_ci * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 268c2ecf20Sopenharmony_ci * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 278c2ecf20Sopenharmony_ci * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 288c2ecf20Sopenharmony_ci * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 298c2ecf20Sopenharmony_ci * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 308c2ecf20Sopenharmony_ci * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 318c2ecf20Sopenharmony_ci * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 328c2ecf20Sopenharmony_ci * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 338c2ecf20Sopenharmony_ci * 348c2ecf20Sopenharmony_ci * 358c2ecf20Sopenharmony_ci * Intel Corporation <linux-wimax@intel.com> 368c2ecf20Sopenharmony_ci * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com> 378c2ecf20Sopenharmony_ci * Yanir Lubetkin <yanirx.lubetkin@intel.com> 388c2ecf20Sopenharmony_ci * - Initial implementation 398c2ecf20Sopenharmony_ci * 408c2ecf20Sopenharmony_ci * 418c2ecf20Sopenharmony_ci * GENERAL DRIVER ARCHITECTURE 428c2ecf20Sopenharmony_ci * 438c2ecf20Sopenharmony_ci * The i2400m driver is split in the following two major parts: 448c2ecf20Sopenharmony_ci * 458c2ecf20Sopenharmony_ci * - bus specific driver 468c2ecf20Sopenharmony_ci * - bus generic driver (this part) 478c2ecf20Sopenharmony_ci * 488c2ecf20Sopenharmony_ci * The bus specific driver sets up stuff specific to the bus the 498c2ecf20Sopenharmony_ci * device is connected to (USB, PCI, tam-tam...non-authoritative 508c2ecf20Sopenharmony_ci * nor binding list) which is basically the device-model management 518c2ecf20Sopenharmony_ci * (probe/disconnect, etc), moving data from device to kernel and 528c2ecf20Sopenharmony_ci * back, doing the power saving details and reseting the device. 538c2ecf20Sopenharmony_ci * 548c2ecf20Sopenharmony_ci * For details on each bus-specific driver, see it's include file, 558c2ecf20Sopenharmony_ci * i2400m-BUSNAME.h 568c2ecf20Sopenharmony_ci * 578c2ecf20Sopenharmony_ci * The bus-generic functionality break up is: 588c2ecf20Sopenharmony_ci * 598c2ecf20Sopenharmony_ci * - Firmware upload: fw.c - takes care of uploading firmware to the 608c2ecf20Sopenharmony_ci * device. bus-specific driver just needs to provides a way to 618c2ecf20Sopenharmony_ci * execute boot-mode commands and to reset the device. 628c2ecf20Sopenharmony_ci * 638c2ecf20Sopenharmony_ci * - RX handling: rx.c - receives data from the bus-specific code and 648c2ecf20Sopenharmony_ci * feeds it to the network or WiMAX stack or uses it to modify 658c2ecf20Sopenharmony_ci * the driver state. bus-specific driver only has to receive 668c2ecf20Sopenharmony_ci * frames and pass them to this module. 678c2ecf20Sopenharmony_ci * 688c2ecf20Sopenharmony_ci * - TX handling: tx.c - manages the TX FIFO queue and provides means 698c2ecf20Sopenharmony_ci * for the bus-specific TX code to pull data from the FIFO 708c2ecf20Sopenharmony_ci * queue. bus-specific code just pulls frames from this module 718c2ecf20Sopenharmony_ci * to sends them to the device. 728c2ecf20Sopenharmony_ci * 738c2ecf20Sopenharmony_ci * - netdev glue: netdev.c - interface with Linux networking 748c2ecf20Sopenharmony_ci * stack. Pass around data frames, and configure when the 758c2ecf20Sopenharmony_ci * device is up and running or shutdown (through ifconfig up / 768c2ecf20Sopenharmony_ci * down). Bus-generic only. 778c2ecf20Sopenharmony_ci * 788c2ecf20Sopenharmony_ci * - control ops: control.c - implements various commands for 798c2ecf20Sopenharmony_ci * controlling the device. bus-generic only. 808c2ecf20Sopenharmony_ci * 818c2ecf20Sopenharmony_ci * - device model glue: driver.c - implements helpers for the 828c2ecf20Sopenharmony_ci * device-model glue done by the bus-specific layer 838c2ecf20Sopenharmony_ci * (setup/release the driver resources), turning the device on 848c2ecf20Sopenharmony_ci * and off, handling the device reboots/resets and a few simple 858c2ecf20Sopenharmony_ci * WiMAX stack ops. 868c2ecf20Sopenharmony_ci * 878c2ecf20Sopenharmony_ci * Code is also broken up in linux-glue / device-glue. 888c2ecf20Sopenharmony_ci * 898c2ecf20Sopenharmony_ci * Linux glue contains functions that deal mostly with gluing with the 908c2ecf20Sopenharmony_ci * rest of the Linux kernel. 918c2ecf20Sopenharmony_ci * 928c2ecf20Sopenharmony_ci * Device-glue are functions that deal mostly with the way the device 938c2ecf20Sopenharmony_ci * does things and talk the device's language. 948c2ecf20Sopenharmony_ci * 958c2ecf20Sopenharmony_ci * device-glue code is licensed BSD so other open source OSes can take 968c2ecf20Sopenharmony_ci * it to implement their drivers. 978c2ecf20Sopenharmony_ci * 988c2ecf20Sopenharmony_ci * 998c2ecf20Sopenharmony_ci * APIs AND HEADER FILES 1008c2ecf20Sopenharmony_ci * 1018c2ecf20Sopenharmony_ci * This bus generic code exports three APIs: 1028c2ecf20Sopenharmony_ci * 1038c2ecf20Sopenharmony_ci * - HDI (host-device interface) definitions common to all busses 1048c2ecf20Sopenharmony_ci * (include/linux/wimax/i2400m.h); these can be also used by user 1058c2ecf20Sopenharmony_ci * space code. 1068c2ecf20Sopenharmony_ci * - internal API for the bus-generic code 1078c2ecf20Sopenharmony_ci * - external API for the bus-specific drivers 1088c2ecf20Sopenharmony_ci * 1098c2ecf20Sopenharmony_ci * 1108c2ecf20Sopenharmony_ci * LIFE CYCLE: 1118c2ecf20Sopenharmony_ci * 1128c2ecf20Sopenharmony_ci * When the bus-specific driver probes, it allocates a network device 1138c2ecf20Sopenharmony_ci * with enough space for it's data structue, that must contain a 1148c2ecf20Sopenharmony_ci * &struct i2400m at the top. 1158c2ecf20Sopenharmony_ci * 1168c2ecf20Sopenharmony_ci * On probe, it needs to fill the i2400m members marked as [fill], as 1178c2ecf20Sopenharmony_ci * well as i2400m->wimax_dev.net_dev and call i2400m_setup(). The 1188c2ecf20Sopenharmony_ci * i2400m driver will only register with the WiMAX and network stacks; 1198c2ecf20Sopenharmony_ci * the only access done to the device is to read the MAC address so we 1208c2ecf20Sopenharmony_ci * can register a network device. 1218c2ecf20Sopenharmony_ci * 1228c2ecf20Sopenharmony_ci * The high-level call flow is: 1238c2ecf20Sopenharmony_ci * 1248c2ecf20Sopenharmony_ci * bus_probe() 1258c2ecf20Sopenharmony_ci * i2400m_setup() 1268c2ecf20Sopenharmony_ci * i2400m->bus_setup() 1278c2ecf20Sopenharmony_ci * boot rom initialization / read mac addr 1288c2ecf20Sopenharmony_ci * network / WiMAX stacks registration 1298c2ecf20Sopenharmony_ci * i2400m_dev_start() 1308c2ecf20Sopenharmony_ci * i2400m->bus_dev_start() 1318c2ecf20Sopenharmony_ci * i2400m_dev_initialize() 1328c2ecf20Sopenharmony_ci * 1338c2ecf20Sopenharmony_ci * The reverse applies for a disconnect() call: 1348c2ecf20Sopenharmony_ci * 1358c2ecf20Sopenharmony_ci * bus_disconnect() 1368c2ecf20Sopenharmony_ci * i2400m_release() 1378c2ecf20Sopenharmony_ci * i2400m_dev_stop() 1388c2ecf20Sopenharmony_ci * i2400m_dev_shutdown() 1398c2ecf20Sopenharmony_ci * i2400m->bus_dev_stop() 1408c2ecf20Sopenharmony_ci * network / WiMAX stack unregistration 1418c2ecf20Sopenharmony_ci * i2400m->bus_release() 1428c2ecf20Sopenharmony_ci * 1438c2ecf20Sopenharmony_ci * At this point, control and data communications are possible. 1448c2ecf20Sopenharmony_ci * 1458c2ecf20Sopenharmony_ci * While the device is up, it might reset. The bus-specific driver has 1468c2ecf20Sopenharmony_ci * to catch that situation and call i2400m_dev_reset_handle() to deal 1478c2ecf20Sopenharmony_ci * with it (reset the internal driver structures and go back to square 1488c2ecf20Sopenharmony_ci * one). 1498c2ecf20Sopenharmony_ci */ 1508c2ecf20Sopenharmony_ci 1518c2ecf20Sopenharmony_ci#ifndef __I2400M_H__ 1528c2ecf20Sopenharmony_ci#define __I2400M_H__ 1538c2ecf20Sopenharmony_ci 1548c2ecf20Sopenharmony_ci#include <linux/usb.h> 1558c2ecf20Sopenharmony_ci#include <linux/netdevice.h> 1568c2ecf20Sopenharmony_ci#include <linux/completion.h> 1578c2ecf20Sopenharmony_ci#include <linux/rwsem.h> 1588c2ecf20Sopenharmony_ci#include <linux/atomic.h> 1598c2ecf20Sopenharmony_ci#include <net/wimax.h> 1608c2ecf20Sopenharmony_ci#include <linux/wimax/i2400m.h> 1618c2ecf20Sopenharmony_ci#include <asm/byteorder.h> 1628c2ecf20Sopenharmony_ci 1638c2ecf20Sopenharmony_cienum { 1648c2ecf20Sopenharmony_ci/* netdev interface */ 1658c2ecf20Sopenharmony_ci /* 1668c2ecf20Sopenharmony_ci * Out of NWG spec (R1_v1.2.2), 3.3.3 ASN Bearer Plane MTU Size 1678c2ecf20Sopenharmony_ci * 1688c2ecf20Sopenharmony_ci * The MTU is 1400 or less 1698c2ecf20Sopenharmony_ci */ 1708c2ecf20Sopenharmony_ci I2400M_MAX_MTU = 1400, 1718c2ecf20Sopenharmony_ci}; 1728c2ecf20Sopenharmony_ci 1738c2ecf20Sopenharmony_ci/* Misc constants */ 1748c2ecf20Sopenharmony_cienum { 1758c2ecf20Sopenharmony_ci /* Size of the Boot Mode Command buffer */ 1768c2ecf20Sopenharmony_ci I2400M_BM_CMD_BUF_SIZE = 16 * 1024, 1778c2ecf20Sopenharmony_ci I2400M_BM_ACK_BUF_SIZE = 256, 1788c2ecf20Sopenharmony_ci}; 1798c2ecf20Sopenharmony_ci 1808c2ecf20Sopenharmony_cienum { 1818c2ecf20Sopenharmony_ci /* Maximum number of bus reset can be retried */ 1828c2ecf20Sopenharmony_ci I2400M_BUS_RESET_RETRIES = 3, 1838c2ecf20Sopenharmony_ci}; 1848c2ecf20Sopenharmony_ci 1858c2ecf20Sopenharmony_ci/** 1868c2ecf20Sopenharmony_ci * struct i2400m_poke_table - Hardware poke table for the Intel 2400m 1878c2ecf20Sopenharmony_ci * 1888c2ecf20Sopenharmony_ci * This structure will be used to create a device specific poke table 1898c2ecf20Sopenharmony_ci * to put the device in a consistent state at boot time. 1908c2ecf20Sopenharmony_ci * 1918c2ecf20Sopenharmony_ci * @address: The device address to poke 1928c2ecf20Sopenharmony_ci * 1938c2ecf20Sopenharmony_ci * @data: The data value to poke to the device address 1948c2ecf20Sopenharmony_ci * 1958c2ecf20Sopenharmony_ci */ 1968c2ecf20Sopenharmony_cistruct i2400m_poke_table{ 1978c2ecf20Sopenharmony_ci __le32 address; 1988c2ecf20Sopenharmony_ci __le32 data; 1998c2ecf20Sopenharmony_ci}; 2008c2ecf20Sopenharmony_ci 2018c2ecf20Sopenharmony_ci#define I2400M_FW_POKE(a, d) { \ 2028c2ecf20Sopenharmony_ci .address = cpu_to_le32(a), \ 2038c2ecf20Sopenharmony_ci .data = cpu_to_le32(d) \ 2048c2ecf20Sopenharmony_ci} 2058c2ecf20Sopenharmony_ci 2068c2ecf20Sopenharmony_ci 2078c2ecf20Sopenharmony_ci/** 2088c2ecf20Sopenharmony_ci * i2400m_reset_type - methods to reset a device 2098c2ecf20Sopenharmony_ci * 2108c2ecf20Sopenharmony_ci * @I2400M_RT_WARM: Reset without device disconnection, device handles 2118c2ecf20Sopenharmony_ci * are kept valid but state is back to power on, with firmware 2128c2ecf20Sopenharmony_ci * re-uploaded. 2138c2ecf20Sopenharmony_ci * @I2400M_RT_COLD: Tell the device to disconnect itself from the bus 2148c2ecf20Sopenharmony_ci * and reconnect. Renders all device handles invalid. 2158c2ecf20Sopenharmony_ci * @I2400M_RT_BUS: Tells the bus to reset the device; last measure 2168c2ecf20Sopenharmony_ci * used when both types above don't work. 2178c2ecf20Sopenharmony_ci */ 2188c2ecf20Sopenharmony_cienum i2400m_reset_type { 2198c2ecf20Sopenharmony_ci I2400M_RT_WARM, /* first measure */ 2208c2ecf20Sopenharmony_ci I2400M_RT_COLD, /* second measure */ 2218c2ecf20Sopenharmony_ci I2400M_RT_BUS, /* call in artillery */ 2228c2ecf20Sopenharmony_ci}; 2238c2ecf20Sopenharmony_ci 2248c2ecf20Sopenharmony_cistruct i2400m_reset_ctx; 2258c2ecf20Sopenharmony_cistruct i2400m_roq; 2268c2ecf20Sopenharmony_cistruct i2400m_barker_db; 2278c2ecf20Sopenharmony_ci 2288c2ecf20Sopenharmony_ci/** 2298c2ecf20Sopenharmony_ci * struct i2400m - descriptor for an Intel 2400m 2308c2ecf20Sopenharmony_ci * 2318c2ecf20Sopenharmony_ci * Members marked with [fill] must be filled out/initialized before 2328c2ecf20Sopenharmony_ci * calling i2400m_setup(). 2338c2ecf20Sopenharmony_ci * 2348c2ecf20Sopenharmony_ci * Note the @bus_setup/@bus_release, @bus_dev_start/@bus_dev_release 2358c2ecf20Sopenharmony_ci * call pairs are very much doing almost the same, and depending on 2368c2ecf20Sopenharmony_ci * the underlying bus, some stuff has to be put in one or the 2378c2ecf20Sopenharmony_ci * other. The idea of setup/release is that they setup the minimal 2388c2ecf20Sopenharmony_ci * amount needed for loading firmware, where us dev_start/stop setup 2398c2ecf20Sopenharmony_ci * the rest needed to do full data/control traffic. 2408c2ecf20Sopenharmony_ci * 2418c2ecf20Sopenharmony_ci * @bus_tx_block_size: [fill] USB imposes a 16 block size, but other 2428c2ecf20Sopenharmony_ci * busses will differ. So we have a tx_blk_size variable that the 2438c2ecf20Sopenharmony_ci * bus layer sets to tell the engine how much of that we need. 2448c2ecf20Sopenharmony_ci * 2458c2ecf20Sopenharmony_ci * @bus_tx_room_min: [fill] Minimum room required while allocating 2468c2ecf20Sopenharmony_ci * TX queue's buffer space for message header. USB requires 2478c2ecf20Sopenharmony_ci * 16 bytes. Refer to bus specific driver code for details. 2488c2ecf20Sopenharmony_ci * 2498c2ecf20Sopenharmony_ci * @bus_pl_size_max: [fill] Maximum payload size. 2508c2ecf20Sopenharmony_ci * 2518c2ecf20Sopenharmony_ci * @bus_setup: [optional fill] Function called by the bus-generic code 2528c2ecf20Sopenharmony_ci * [i2400m_setup()] to setup the basic bus-specific communications 2538c2ecf20Sopenharmony_ci * to the the device needed to load firmware. See LIFE CYCLE above. 2548c2ecf20Sopenharmony_ci * 2558c2ecf20Sopenharmony_ci * NOTE: Doesn't need to upload the firmware, as that is taken 2568c2ecf20Sopenharmony_ci * care of by the bus-generic code. 2578c2ecf20Sopenharmony_ci * 2588c2ecf20Sopenharmony_ci * @bus_release: [optional fill] Function called by the bus-generic 2598c2ecf20Sopenharmony_ci * code [i2400m_release()] to shutdown the basic bus-specific 2608c2ecf20Sopenharmony_ci * communications to the the device needed to load firmware. See 2618c2ecf20Sopenharmony_ci * LIFE CYCLE above. 2628c2ecf20Sopenharmony_ci * 2638c2ecf20Sopenharmony_ci * This function does not need to reset the device, just tear down 2648c2ecf20Sopenharmony_ci * all the host resources created to handle communication with 2658c2ecf20Sopenharmony_ci * the device. 2668c2ecf20Sopenharmony_ci * 2678c2ecf20Sopenharmony_ci * @bus_dev_start: [optional fill] Function called by the bus-generic 2688c2ecf20Sopenharmony_ci * code [i2400m_dev_start()] to do things needed to start the 2698c2ecf20Sopenharmony_ci * device. See LIFE CYCLE above. 2708c2ecf20Sopenharmony_ci * 2718c2ecf20Sopenharmony_ci * NOTE: Doesn't need to upload the firmware, as that is taken 2728c2ecf20Sopenharmony_ci * care of by the bus-generic code. 2738c2ecf20Sopenharmony_ci * 2748c2ecf20Sopenharmony_ci * @bus_dev_stop: [optional fill] Function called by the bus-generic 2758c2ecf20Sopenharmony_ci * code [i2400m_dev_stop()] to do things needed for stopping the 2768c2ecf20Sopenharmony_ci * device. See LIFE CYCLE above. 2778c2ecf20Sopenharmony_ci * 2788c2ecf20Sopenharmony_ci * This function does not need to reset the device, just tear down 2798c2ecf20Sopenharmony_ci * all the host resources created to handle communication with 2808c2ecf20Sopenharmony_ci * the device. 2818c2ecf20Sopenharmony_ci * 2828c2ecf20Sopenharmony_ci * @bus_tx_kick: [fill] Function called by the bus-generic code to let 2838c2ecf20Sopenharmony_ci * the bus-specific code know that there is data available in the 2848c2ecf20Sopenharmony_ci * TX FIFO for transmission to the device. 2858c2ecf20Sopenharmony_ci * 2868c2ecf20Sopenharmony_ci * This function cannot sleep. 2878c2ecf20Sopenharmony_ci * 2888c2ecf20Sopenharmony_ci * @bus_reset: [fill] Function called by the bus-generic code to reset 2898c2ecf20Sopenharmony_ci * the device in in various ways. Doesn't need to wait for the 2908c2ecf20Sopenharmony_ci * reset to finish. 2918c2ecf20Sopenharmony_ci * 2928c2ecf20Sopenharmony_ci * If warm or cold reset fail, this function is expected to do a 2938c2ecf20Sopenharmony_ci * bus-specific reset (eg: USB reset) to get the device to a 2948c2ecf20Sopenharmony_ci * working state (even if it implies device disconecction). 2958c2ecf20Sopenharmony_ci * 2968c2ecf20Sopenharmony_ci * Note the warm reset is used by the firmware uploader to 2978c2ecf20Sopenharmony_ci * reinitialize the device. 2988c2ecf20Sopenharmony_ci * 2998c2ecf20Sopenharmony_ci * IMPORTANT: this is called very early in the device setup 3008c2ecf20Sopenharmony_ci * process, so it cannot rely on common infrastructure being laid 3018c2ecf20Sopenharmony_ci * out. 3028c2ecf20Sopenharmony_ci * 3038c2ecf20Sopenharmony_ci * IMPORTANT: don't call reset on RT_BUS with i2400m->init_mutex 3048c2ecf20Sopenharmony_ci * held, as the .pre/.post reset handlers will deadlock. 3058c2ecf20Sopenharmony_ci * 3068c2ecf20Sopenharmony_ci * @bus_bm_retries: [fill] How many times shall a firmware upload / 3078c2ecf20Sopenharmony_ci * device initialization be retried? Different models of the same 3088c2ecf20Sopenharmony_ci * device might need different values, hence it is set by the 3098c2ecf20Sopenharmony_ci * bus-specific driver. Note this value is used in two places, 3108c2ecf20Sopenharmony_ci * i2400m_fw_dnload() and __i2400m_dev_start(); they won't become 3118c2ecf20Sopenharmony_ci * multiplicative (__i2400m_dev_start() calling N times 3128c2ecf20Sopenharmony_ci * i2400m_fw_dnload() and this trying N times to download the 3138c2ecf20Sopenharmony_ci * firmware), as if __i2400m_dev_start() only retries if the 3148c2ecf20Sopenharmony_ci * firmware crashed while initializing the device (not in a 3158c2ecf20Sopenharmony_ci * general case). 3168c2ecf20Sopenharmony_ci * 3178c2ecf20Sopenharmony_ci * @bus_bm_cmd_send: [fill] Function called to send a boot-mode 3188c2ecf20Sopenharmony_ci * command. Flags are defined in 'enum i2400m_bm_cmd_flags'. This 3198c2ecf20Sopenharmony_ci * is synchronous and has to return 0 if ok or < 0 errno code in 3208c2ecf20Sopenharmony_ci * any error condition. 3218c2ecf20Sopenharmony_ci * 3228c2ecf20Sopenharmony_ci * @bus_bm_wait_for_ack: [fill] Function called to wait for a 3238c2ecf20Sopenharmony_ci * boot-mode notification (that can be a response to a previously 3248c2ecf20Sopenharmony_ci * issued command or an asynchronous one). Will read until all the 3258c2ecf20Sopenharmony_ci * indicated size is read or timeout. Reading more or less data 3268c2ecf20Sopenharmony_ci * than asked for is an error condition. Return 0 if ok, < 0 errno 3278c2ecf20Sopenharmony_ci * code on error. 3288c2ecf20Sopenharmony_ci * 3298c2ecf20Sopenharmony_ci * The caller to this function will check if the response is a 3308c2ecf20Sopenharmony_ci * barker that indicates the device going into reset mode. 3318c2ecf20Sopenharmony_ci * 3328c2ecf20Sopenharmony_ci * @bus_fw_names: [fill] a NULL-terminated array with the names of the 3338c2ecf20Sopenharmony_ci * firmware images to try loading. This is made a list so we can 3348c2ecf20Sopenharmony_ci * support backward compatibility of firmware releases (eg: if we 3358c2ecf20Sopenharmony_ci * can't find the default v1.4, we try v1.3). In general, the name 3368c2ecf20Sopenharmony_ci * should be i2400m-fw-X-VERSION.sbcf, where X is the bus name. 3378c2ecf20Sopenharmony_ci * The list is tried in order and the first one that loads is 3388c2ecf20Sopenharmony_ci * used. The fw loader will set i2400m->fw_name to point to the 3398c2ecf20Sopenharmony_ci * active firmware image. 3408c2ecf20Sopenharmony_ci * 3418c2ecf20Sopenharmony_ci * @bus_bm_mac_addr_impaired: [fill] Set to true if the device's MAC 3428c2ecf20Sopenharmony_ci * address provided in boot mode is kind of broken and needs to 3438c2ecf20Sopenharmony_ci * be re-read later on. 3448c2ecf20Sopenharmony_ci * 3458c2ecf20Sopenharmony_ci * @bus_bm_pokes_table: [fill/optional] A table of device addresses 3468c2ecf20Sopenharmony_ci * and values that will be poked at device init time to move the 3478c2ecf20Sopenharmony_ci * device to the correct state for the type of boot/firmware being 3488c2ecf20Sopenharmony_ci * used. This table MUST be terminated with (0x000000, 3498c2ecf20Sopenharmony_ci * 0x00000000) or bad things will happen. 3508c2ecf20Sopenharmony_ci * 3518c2ecf20Sopenharmony_ci * 3528c2ecf20Sopenharmony_ci * @wimax_dev: WiMAX generic device for linkage into the kernel WiMAX 3538c2ecf20Sopenharmony_ci * stack. Due to the way a net_device is allocated, we need to 3548c2ecf20Sopenharmony_ci * force this to be the first field so that we can get from 3558c2ecf20Sopenharmony_ci * netdev_priv() the right pointer. 3568c2ecf20Sopenharmony_ci * 3578c2ecf20Sopenharmony_ci * @updown: the device is up and ready for transmitting control and 3588c2ecf20Sopenharmony_ci * data packets. This implies @ready (communication infrastructure 3598c2ecf20Sopenharmony_ci * with the device is ready) and the device's firmware has been 3608c2ecf20Sopenharmony_ci * loaded and the device initialized. 3618c2ecf20Sopenharmony_ci * 3628c2ecf20Sopenharmony_ci * Write to it only inside a i2400m->init_mutex protected area 3638c2ecf20Sopenharmony_ci * followed with a wmb(); rmb() before accesing (unless locked 3648c2ecf20Sopenharmony_ci * inside i2400m->init_mutex). Read access can be loose like that 3658c2ecf20Sopenharmony_ci * [just using rmb()] because the paths that use this also do 3668c2ecf20Sopenharmony_ci * other error checks later on. 3678c2ecf20Sopenharmony_ci * 3688c2ecf20Sopenharmony_ci * @ready: Communication infrastructure with the device is ready, data 3698c2ecf20Sopenharmony_ci * frames can start to be passed around (this is lighter than 3708c2ecf20Sopenharmony_ci * using the WiMAX state for certain hot paths). 3718c2ecf20Sopenharmony_ci * 3728c2ecf20Sopenharmony_ci * Write to it only inside a i2400m->init_mutex protected area 3738c2ecf20Sopenharmony_ci * followed with a wmb(); rmb() before accesing (unless locked 3748c2ecf20Sopenharmony_ci * inside i2400m->init_mutex). Read access can be loose like that 3758c2ecf20Sopenharmony_ci * [just using rmb()] because the paths that use this also do 3768c2ecf20Sopenharmony_ci * other error checks later on. 3778c2ecf20Sopenharmony_ci * 3788c2ecf20Sopenharmony_ci * @rx_reorder: 1 if RX reordering is enabled; this can only be 3798c2ecf20Sopenharmony_ci * set at probe time. 3808c2ecf20Sopenharmony_ci * 3818c2ecf20Sopenharmony_ci * @state: device's state (as reported by it) 3828c2ecf20Sopenharmony_ci * 3838c2ecf20Sopenharmony_ci * @state_wq: waitqueue that is woken up whenever the state changes 3848c2ecf20Sopenharmony_ci * 3858c2ecf20Sopenharmony_ci * @tx_lock: spinlock to protect TX members 3868c2ecf20Sopenharmony_ci * 3878c2ecf20Sopenharmony_ci * @tx_buf: FIFO buffer for TX; we queue data here 3888c2ecf20Sopenharmony_ci * 3898c2ecf20Sopenharmony_ci * @tx_in: FIFO index for incoming data. Note this doesn't wrap around 3908c2ecf20Sopenharmony_ci * and it is always greater than @tx_out. 3918c2ecf20Sopenharmony_ci * 3928c2ecf20Sopenharmony_ci * @tx_out: FIFO index for outgoing data 3938c2ecf20Sopenharmony_ci * 3948c2ecf20Sopenharmony_ci * @tx_msg: current TX message that is active in the FIFO for 3958c2ecf20Sopenharmony_ci * appending payloads. 3968c2ecf20Sopenharmony_ci * 3978c2ecf20Sopenharmony_ci * @tx_sequence: current sequence number for TX messages from the 3988c2ecf20Sopenharmony_ci * device to the host. 3998c2ecf20Sopenharmony_ci * 4008c2ecf20Sopenharmony_ci * @tx_msg_size: size of the current message being transmitted by the 4018c2ecf20Sopenharmony_ci * bus-specific code. 4028c2ecf20Sopenharmony_ci * 4038c2ecf20Sopenharmony_ci * @tx_pl_num: total number of payloads sent 4048c2ecf20Sopenharmony_ci * 4058c2ecf20Sopenharmony_ci * @tx_pl_max: maximum number of payloads sent in a TX message 4068c2ecf20Sopenharmony_ci * 4078c2ecf20Sopenharmony_ci * @tx_pl_min: minimum number of payloads sent in a TX message 4088c2ecf20Sopenharmony_ci * 4098c2ecf20Sopenharmony_ci * @tx_num: number of TX messages sent 4108c2ecf20Sopenharmony_ci * 4118c2ecf20Sopenharmony_ci * @tx_size_acc: number of bytes in all TX messages sent 4128c2ecf20Sopenharmony_ci * (this is different to net_dev's statistics as it also counts 4138c2ecf20Sopenharmony_ci * control messages). 4148c2ecf20Sopenharmony_ci * 4158c2ecf20Sopenharmony_ci * @tx_size_min: smallest TX message sent. 4168c2ecf20Sopenharmony_ci * 4178c2ecf20Sopenharmony_ci * @tx_size_max: biggest TX message sent. 4188c2ecf20Sopenharmony_ci * 4198c2ecf20Sopenharmony_ci * @rx_lock: spinlock to protect RX members and rx_roq_refcount. 4208c2ecf20Sopenharmony_ci * 4218c2ecf20Sopenharmony_ci * @rx_pl_num: total number of payloads received 4228c2ecf20Sopenharmony_ci * 4238c2ecf20Sopenharmony_ci * @rx_pl_max: maximum number of payloads received in a RX message 4248c2ecf20Sopenharmony_ci * 4258c2ecf20Sopenharmony_ci * @rx_pl_min: minimum number of payloads received in a RX message 4268c2ecf20Sopenharmony_ci * 4278c2ecf20Sopenharmony_ci * @rx_num: number of RX messages received 4288c2ecf20Sopenharmony_ci * 4298c2ecf20Sopenharmony_ci * @rx_size_acc: number of bytes in all RX messages received 4308c2ecf20Sopenharmony_ci * (this is different to net_dev's statistics as it also counts 4318c2ecf20Sopenharmony_ci * control messages). 4328c2ecf20Sopenharmony_ci * 4338c2ecf20Sopenharmony_ci * @rx_size_min: smallest RX message received. 4348c2ecf20Sopenharmony_ci * 4358c2ecf20Sopenharmony_ci * @rx_size_max: buggest RX message received. 4368c2ecf20Sopenharmony_ci * 4378c2ecf20Sopenharmony_ci * @rx_roq: RX ReOrder queues. (fw >= v1.4) When packets are received 4388c2ecf20Sopenharmony_ci * out of order, the device will ask the driver to hold certain 4398c2ecf20Sopenharmony_ci * packets until the ones that are received out of order can be 4408c2ecf20Sopenharmony_ci * delivered. Then the driver can release them to the host. See 4418c2ecf20Sopenharmony_ci * drivers/net/i2400m/rx.c for details. 4428c2ecf20Sopenharmony_ci * 4438c2ecf20Sopenharmony_ci * @rx_roq_refcount: refcount rx_roq. This refcounts any access to 4448c2ecf20Sopenharmony_ci * rx_roq thus preventing rx_roq being destroyed when rx_roq 4458c2ecf20Sopenharmony_ci * is being accessed. rx_roq_refcount is protected by rx_lock. 4468c2ecf20Sopenharmony_ci * 4478c2ecf20Sopenharmony_ci * @rx_reports: reports received from the device that couldn't be 4488c2ecf20Sopenharmony_ci * processed because the driver wasn't still ready; when ready, 4498c2ecf20Sopenharmony_ci * they are pulled from here and chewed. 4508c2ecf20Sopenharmony_ci * 4518c2ecf20Sopenharmony_ci * @rx_reports_ws: Work struct used to kick a scan of the RX reports 4528c2ecf20Sopenharmony_ci * list and to process each. 4538c2ecf20Sopenharmony_ci * 4548c2ecf20Sopenharmony_ci * @src_mac_addr: MAC address used to make ethernet packets be coming 4558c2ecf20Sopenharmony_ci * from. This is generated at i2400m_setup() time and used during 4568c2ecf20Sopenharmony_ci * the life cycle of the instance. See i2400m_fake_eth_header(). 4578c2ecf20Sopenharmony_ci * 4588c2ecf20Sopenharmony_ci * @init_mutex: Mutex used for serializing the device bringup 4598c2ecf20Sopenharmony_ci * sequence; this way if the device reboots in the middle, we 4608c2ecf20Sopenharmony_ci * don't try to do a bringup again while we are tearing down the 4618c2ecf20Sopenharmony_ci * one that failed. 4628c2ecf20Sopenharmony_ci * 4638c2ecf20Sopenharmony_ci * Can't reuse @msg_mutex because from within the bringup sequence 4648c2ecf20Sopenharmony_ci * we need to send messages to the device and thus use @msg_mutex. 4658c2ecf20Sopenharmony_ci * 4668c2ecf20Sopenharmony_ci * @msg_mutex: mutex used to send control commands to the device (we 4678c2ecf20Sopenharmony_ci * only allow one at a time, per host-device interface design). 4688c2ecf20Sopenharmony_ci * 4698c2ecf20Sopenharmony_ci * @msg_completion: used to wait for an ack to a control command sent 4708c2ecf20Sopenharmony_ci * to the device. 4718c2ecf20Sopenharmony_ci * 4728c2ecf20Sopenharmony_ci * @ack_skb: used to store the actual ack to a control command if the 4738c2ecf20Sopenharmony_ci * reception of the command was successful. Otherwise, a ERR_PTR() 4748c2ecf20Sopenharmony_ci * errno code that indicates what failed with the ack reception. 4758c2ecf20Sopenharmony_ci * 4768c2ecf20Sopenharmony_ci * Only valid after @msg_completion is woken up. Only updateable 4778c2ecf20Sopenharmony_ci * if @msg_completion is armed. Only touched by 4788c2ecf20Sopenharmony_ci * i2400m_msg_to_dev(). 4798c2ecf20Sopenharmony_ci * 4808c2ecf20Sopenharmony_ci * Protected by @rx_lock. In theory the command execution flow is 4818c2ecf20Sopenharmony_ci * sequential, but in case the device sends an out-of-phase or 4828c2ecf20Sopenharmony_ci * very delayed response, we need to avoid it trampling current 4838c2ecf20Sopenharmony_ci * execution. 4848c2ecf20Sopenharmony_ci * 4858c2ecf20Sopenharmony_ci * @bm_cmd_buf: boot mode command buffer for composing firmware upload 4868c2ecf20Sopenharmony_ci * commands. 4878c2ecf20Sopenharmony_ci * 4888c2ecf20Sopenharmony_ci * USB can't r/w to stack, vmalloc, etc...as well, we end up 4898c2ecf20Sopenharmony_ci * having to alloc/free a lot to compose commands, so we use these 4908c2ecf20Sopenharmony_ci * for stagging and not having to realloc all the time. 4918c2ecf20Sopenharmony_ci * 4928c2ecf20Sopenharmony_ci * This assumes the code always runs serialized. Only one thread 4938c2ecf20Sopenharmony_ci * can call i2400m_bm_cmd() at the same time. 4948c2ecf20Sopenharmony_ci * 4958c2ecf20Sopenharmony_ci * @bm_ack_buf: boot mode acknoledge buffer for staging reception of 4968c2ecf20Sopenharmony_ci * responses to commands. 4978c2ecf20Sopenharmony_ci * 4988c2ecf20Sopenharmony_ci * See @bm_cmd_buf. 4998c2ecf20Sopenharmony_ci * 5008c2ecf20Sopenharmony_ci * @work_queue: work queue for processing device reports. This 5018c2ecf20Sopenharmony_ci * workqueue cannot be used for processing TX or RX to the device, 5028c2ecf20Sopenharmony_ci * as from it we'll process device reports, which might require 5038c2ecf20Sopenharmony_ci * further communication with the device. 5048c2ecf20Sopenharmony_ci * 5058c2ecf20Sopenharmony_ci * @debugfs_dentry: hookup for debugfs files. 5068c2ecf20Sopenharmony_ci * These have to be in a separate directory, a child of 5078c2ecf20Sopenharmony_ci * (wimax_dev->debugfs_dentry) so they can be removed when the 5088c2ecf20Sopenharmony_ci * module unloads, as we don't keep each dentry. 5098c2ecf20Sopenharmony_ci * 5108c2ecf20Sopenharmony_ci * @fw_name: name of the firmware image that is currently being used. 5118c2ecf20Sopenharmony_ci * 5128c2ecf20Sopenharmony_ci * @fw_version: version of the firmware interface, Major.minor, 5138c2ecf20Sopenharmony_ci * encoded in the high word and low word (major << 16 | minor). 5148c2ecf20Sopenharmony_ci * 5158c2ecf20Sopenharmony_ci * @fw_hdrs: NULL terminated array of pointers to the firmware 5168c2ecf20Sopenharmony_ci * headers. This is only available during firmware load time. 5178c2ecf20Sopenharmony_ci * 5188c2ecf20Sopenharmony_ci * @fw_cached: Used to cache firmware when the system goes to 5198c2ecf20Sopenharmony_ci * suspend/standby/hibernation (as on resume we can't read it). If 5208c2ecf20Sopenharmony_ci * NULL, no firmware was cached, read it. If ~0, you can't read 5218c2ecf20Sopenharmony_ci * any firmware files (the system still didn't come out of suspend 5228c2ecf20Sopenharmony_ci * and failed to cache one), so abort; otherwise, a valid cached 5238c2ecf20Sopenharmony_ci * firmware to be used. Access to this variable is protected by 5248c2ecf20Sopenharmony_ci * the spinlock i2400m->rx_lock. 5258c2ecf20Sopenharmony_ci * 5268c2ecf20Sopenharmony_ci * @barker: barker type that the device uses; this is initialized by 5278c2ecf20Sopenharmony_ci * i2400m_is_boot_barker() the first time it is called. Then it 5288c2ecf20Sopenharmony_ci * won't change during the life cycle of the device and every time 5298c2ecf20Sopenharmony_ci * a boot barker is received, it is just verified for it being the 5308c2ecf20Sopenharmony_ci * same. 5318c2ecf20Sopenharmony_ci * 5328c2ecf20Sopenharmony_ci * @pm_notifier: used to register for PM events 5338c2ecf20Sopenharmony_ci * 5348c2ecf20Sopenharmony_ci * @bus_reset_retries: counter for the number of bus resets attempted for 5358c2ecf20Sopenharmony_ci * this boot. It's not for tracking the number of bus resets during 5368c2ecf20Sopenharmony_ci * the whole driver life cycle (from insmod to rmmod) but for the 5378c2ecf20Sopenharmony_ci * number of dev_start() executed until dev_start() returns a success 5388c2ecf20Sopenharmony_ci * (ie: a good boot means a dev_stop() followed by a successful 5398c2ecf20Sopenharmony_ci * dev_start()). dev_reset_handler() increments this counter whenever 5408c2ecf20Sopenharmony_ci * it is triggering a bus reset. It checks this counter to decide if a 5418c2ecf20Sopenharmony_ci * subsequent bus reset should be retried. dev_reset_handler() retries 5428c2ecf20Sopenharmony_ci * the bus reset until dev_start() succeeds or the counter reaches 5438c2ecf20Sopenharmony_ci * I2400M_BUS_RESET_RETRIES. The counter is cleared to 0 in 5448c2ecf20Sopenharmony_ci * dev_reset_handle() when dev_start() returns a success, 5458c2ecf20Sopenharmony_ci * ie: a successul boot is completed. 5468c2ecf20Sopenharmony_ci * 5478c2ecf20Sopenharmony_ci * @alive: flag to denote if the device *should* be alive. This flag is 5488c2ecf20Sopenharmony_ci * everything like @updown (see doc for @updown) except reflecting 5498c2ecf20Sopenharmony_ci * the device state *we expect* rather than the actual state as denoted 5508c2ecf20Sopenharmony_ci * by @updown. It is set 1 whenever @updown is set 1 in dev_start(). 5518c2ecf20Sopenharmony_ci * Then the device is expected to be alive all the time 5528c2ecf20Sopenharmony_ci * (i2400m->alive remains 1) until the driver is removed. Therefore 5538c2ecf20Sopenharmony_ci * all the device reboot events detected can be still handled properly 5548c2ecf20Sopenharmony_ci * by either dev_reset_handle() or .pre_reset/.post_reset as long as 5558c2ecf20Sopenharmony_ci * the driver presents. It is set 0 along with @updown in dev_stop(). 5568c2ecf20Sopenharmony_ci * 5578c2ecf20Sopenharmony_ci * @error_recovery: flag to denote if we are ready to take an error recovery. 5588c2ecf20Sopenharmony_ci * 0 for ready to take an error recovery; 1 for not ready. It is 5598c2ecf20Sopenharmony_ci * initialized to 1 while probe() since we don't tend to take any error 5608c2ecf20Sopenharmony_ci * recovery during probe(). It is decremented by 1 whenever dev_start() 5618c2ecf20Sopenharmony_ci * succeeds to indicate we are ready to take error recovery from now on. 5628c2ecf20Sopenharmony_ci * It is checked every time we wanna schedule an error recovery. If an 5638c2ecf20Sopenharmony_ci * error recovery is already in place (error_recovery was set 1), we 5648c2ecf20Sopenharmony_ci * should not schedule another one until the last one is done. 5658c2ecf20Sopenharmony_ci */ 5668c2ecf20Sopenharmony_cistruct i2400m { 5678c2ecf20Sopenharmony_ci struct wimax_dev wimax_dev; /* FIRST! See doc */ 5688c2ecf20Sopenharmony_ci 5698c2ecf20Sopenharmony_ci unsigned updown:1; /* Network device is up or down */ 5708c2ecf20Sopenharmony_ci unsigned boot_mode:1; /* is the device in boot mode? */ 5718c2ecf20Sopenharmony_ci unsigned sboot:1; /* signed or unsigned fw boot */ 5728c2ecf20Sopenharmony_ci unsigned ready:1; /* Device comm infrastructure ready */ 5738c2ecf20Sopenharmony_ci unsigned rx_reorder:1; /* RX reorder is enabled */ 5748c2ecf20Sopenharmony_ci u8 trace_msg_from_user; /* echo rx msgs to 'trace' pipe */ 5758c2ecf20Sopenharmony_ci /* typed u8 so /sys/kernel/debug/u8 can tweak */ 5768c2ecf20Sopenharmony_ci enum i2400m_system_state state; 5778c2ecf20Sopenharmony_ci wait_queue_head_t state_wq; /* Woken up when on state updates */ 5788c2ecf20Sopenharmony_ci 5798c2ecf20Sopenharmony_ci size_t bus_tx_block_size; 5808c2ecf20Sopenharmony_ci size_t bus_tx_room_min; 5818c2ecf20Sopenharmony_ci size_t bus_pl_size_max; 5828c2ecf20Sopenharmony_ci unsigned bus_bm_retries; 5838c2ecf20Sopenharmony_ci 5848c2ecf20Sopenharmony_ci int (*bus_setup)(struct i2400m *); 5858c2ecf20Sopenharmony_ci int (*bus_dev_start)(struct i2400m *); 5868c2ecf20Sopenharmony_ci void (*bus_dev_stop)(struct i2400m *); 5878c2ecf20Sopenharmony_ci void (*bus_release)(struct i2400m *); 5888c2ecf20Sopenharmony_ci void (*bus_tx_kick)(struct i2400m *); 5898c2ecf20Sopenharmony_ci int (*bus_reset)(struct i2400m *, enum i2400m_reset_type); 5908c2ecf20Sopenharmony_ci ssize_t (*bus_bm_cmd_send)(struct i2400m *, 5918c2ecf20Sopenharmony_ci const struct i2400m_bootrom_header *, 5928c2ecf20Sopenharmony_ci size_t, int flags); 5938c2ecf20Sopenharmony_ci ssize_t (*bus_bm_wait_for_ack)(struct i2400m *, 5948c2ecf20Sopenharmony_ci struct i2400m_bootrom_header *, size_t); 5958c2ecf20Sopenharmony_ci const char **bus_fw_names; 5968c2ecf20Sopenharmony_ci unsigned bus_bm_mac_addr_impaired:1; 5978c2ecf20Sopenharmony_ci const struct i2400m_poke_table *bus_bm_pokes_table; 5988c2ecf20Sopenharmony_ci 5998c2ecf20Sopenharmony_ci spinlock_t tx_lock; /* protect TX state */ 6008c2ecf20Sopenharmony_ci void *tx_buf; 6018c2ecf20Sopenharmony_ci size_t tx_in, tx_out; 6028c2ecf20Sopenharmony_ci struct i2400m_msg_hdr *tx_msg; 6038c2ecf20Sopenharmony_ci size_t tx_sequence, tx_msg_size; 6048c2ecf20Sopenharmony_ci /* TX stats */ 6058c2ecf20Sopenharmony_ci unsigned tx_pl_num, tx_pl_max, tx_pl_min, 6068c2ecf20Sopenharmony_ci tx_num, tx_size_acc, tx_size_min, tx_size_max; 6078c2ecf20Sopenharmony_ci 6088c2ecf20Sopenharmony_ci /* RX stuff */ 6098c2ecf20Sopenharmony_ci /* protect RX state and rx_roq_refcount */ 6108c2ecf20Sopenharmony_ci spinlock_t rx_lock; 6118c2ecf20Sopenharmony_ci unsigned rx_pl_num, rx_pl_max, rx_pl_min, 6128c2ecf20Sopenharmony_ci rx_num, rx_size_acc, rx_size_min, rx_size_max; 6138c2ecf20Sopenharmony_ci struct i2400m_roq *rx_roq; /* access is refcounted */ 6148c2ecf20Sopenharmony_ci struct kref rx_roq_refcount; /* refcount access to rx_roq */ 6158c2ecf20Sopenharmony_ci u8 src_mac_addr[ETH_HLEN]; 6168c2ecf20Sopenharmony_ci struct list_head rx_reports; /* under rx_lock! */ 6178c2ecf20Sopenharmony_ci struct work_struct rx_report_ws; 6188c2ecf20Sopenharmony_ci 6198c2ecf20Sopenharmony_ci struct mutex msg_mutex; /* serialize command execution */ 6208c2ecf20Sopenharmony_ci struct completion msg_completion; 6218c2ecf20Sopenharmony_ci struct sk_buff *ack_skb; /* protected by rx_lock */ 6228c2ecf20Sopenharmony_ci 6238c2ecf20Sopenharmony_ci void *bm_ack_buf; /* for receiving acks over USB */ 6248c2ecf20Sopenharmony_ci void *bm_cmd_buf; /* for issuing commands over USB */ 6258c2ecf20Sopenharmony_ci 6268c2ecf20Sopenharmony_ci struct workqueue_struct *work_queue; 6278c2ecf20Sopenharmony_ci 6288c2ecf20Sopenharmony_ci struct mutex init_mutex; /* protect bringup seq */ 6298c2ecf20Sopenharmony_ci struct i2400m_reset_ctx *reset_ctx; /* protected by init_mutex */ 6308c2ecf20Sopenharmony_ci 6318c2ecf20Sopenharmony_ci struct work_struct wake_tx_ws; 6328c2ecf20Sopenharmony_ci struct sk_buff *wake_tx_skb; 6338c2ecf20Sopenharmony_ci 6348c2ecf20Sopenharmony_ci struct work_struct reset_ws; 6358c2ecf20Sopenharmony_ci const char *reset_reason; 6368c2ecf20Sopenharmony_ci 6378c2ecf20Sopenharmony_ci struct work_struct recovery_ws; 6388c2ecf20Sopenharmony_ci 6398c2ecf20Sopenharmony_ci struct dentry *debugfs_dentry; 6408c2ecf20Sopenharmony_ci const char *fw_name; /* name of the current firmware image */ 6418c2ecf20Sopenharmony_ci unsigned long fw_version; /* version of the firmware interface */ 6428c2ecf20Sopenharmony_ci const struct i2400m_bcf_hdr **fw_hdrs; 6438c2ecf20Sopenharmony_ci struct i2400m_fw *fw_cached; /* protected by rx_lock */ 6448c2ecf20Sopenharmony_ci struct i2400m_barker_db *barker; 6458c2ecf20Sopenharmony_ci 6468c2ecf20Sopenharmony_ci struct notifier_block pm_notifier; 6478c2ecf20Sopenharmony_ci 6488c2ecf20Sopenharmony_ci /* counting bus reset retries in this boot */ 6498c2ecf20Sopenharmony_ci atomic_t bus_reset_retries; 6508c2ecf20Sopenharmony_ci 6518c2ecf20Sopenharmony_ci /* if the device is expected to be alive */ 6528c2ecf20Sopenharmony_ci unsigned alive; 6538c2ecf20Sopenharmony_ci 6548c2ecf20Sopenharmony_ci /* 0 if we are ready for error recovery; 1 if not ready */ 6558c2ecf20Sopenharmony_ci atomic_t error_recovery; 6568c2ecf20Sopenharmony_ci 6578c2ecf20Sopenharmony_ci}; 6588c2ecf20Sopenharmony_ci 6598c2ecf20Sopenharmony_ci 6608c2ecf20Sopenharmony_ci/* 6618c2ecf20Sopenharmony_ci * Bus-generic internal APIs 6628c2ecf20Sopenharmony_ci * ------------------------- 6638c2ecf20Sopenharmony_ci */ 6648c2ecf20Sopenharmony_ci 6658c2ecf20Sopenharmony_cistatic inline 6668c2ecf20Sopenharmony_cistruct i2400m *wimax_dev_to_i2400m(struct wimax_dev *wimax_dev) 6678c2ecf20Sopenharmony_ci{ 6688c2ecf20Sopenharmony_ci return container_of(wimax_dev, struct i2400m, wimax_dev); 6698c2ecf20Sopenharmony_ci} 6708c2ecf20Sopenharmony_ci 6718c2ecf20Sopenharmony_cistatic inline 6728c2ecf20Sopenharmony_cistruct i2400m *net_dev_to_i2400m(struct net_device *net_dev) 6738c2ecf20Sopenharmony_ci{ 6748c2ecf20Sopenharmony_ci return wimax_dev_to_i2400m(netdev_priv(net_dev)); 6758c2ecf20Sopenharmony_ci} 6768c2ecf20Sopenharmony_ci 6778c2ecf20Sopenharmony_ci/* 6788c2ecf20Sopenharmony_ci * Boot mode support 6798c2ecf20Sopenharmony_ci */ 6808c2ecf20Sopenharmony_ci 6818c2ecf20Sopenharmony_ci/** 6828c2ecf20Sopenharmony_ci * i2400m_bm_cmd_flags - flags to i2400m_bm_cmd() 6838c2ecf20Sopenharmony_ci * 6848c2ecf20Sopenharmony_ci * @I2400M_BM_CMD_RAW: send the command block as-is, without doing any 6858c2ecf20Sopenharmony_ci * extra processing for adding CRC. 6868c2ecf20Sopenharmony_ci */ 6878c2ecf20Sopenharmony_cienum i2400m_bm_cmd_flags { 6888c2ecf20Sopenharmony_ci I2400M_BM_CMD_RAW = 1 << 2, 6898c2ecf20Sopenharmony_ci}; 6908c2ecf20Sopenharmony_ci 6918c2ecf20Sopenharmony_ci/** 6928c2ecf20Sopenharmony_ci * i2400m_bri - Boot-ROM indicators 6938c2ecf20Sopenharmony_ci * 6948c2ecf20Sopenharmony_ci * Flags for i2400m_bootrom_init() and i2400m_dev_bootstrap() [which 6958c2ecf20Sopenharmony_ci * are passed from things like i2400m_setup()]. Can be combined with 6968c2ecf20Sopenharmony_ci * |. 6978c2ecf20Sopenharmony_ci * 6988c2ecf20Sopenharmony_ci * @I2400M_BRI_SOFT: The device rebooted already and a reboot 6998c2ecf20Sopenharmony_ci * barker received, proceed directly to ack the boot sequence. 7008c2ecf20Sopenharmony_ci * @I2400M_BRI_NO_REBOOT: Do not reboot the device and proceed 7018c2ecf20Sopenharmony_ci * directly to wait for a reboot barker from the device. 7028c2ecf20Sopenharmony_ci * @I2400M_BRI_MAC_REINIT: We need to reinitialize the boot 7038c2ecf20Sopenharmony_ci * rom after reading the MAC address. This is quite a dirty hack, 7048c2ecf20Sopenharmony_ci * if you ask me -- the device requires the bootrom to be 7058c2ecf20Sopenharmony_ci * initialized after reading the MAC address. 7068c2ecf20Sopenharmony_ci */ 7078c2ecf20Sopenharmony_cienum i2400m_bri { 7088c2ecf20Sopenharmony_ci I2400M_BRI_SOFT = 1 << 1, 7098c2ecf20Sopenharmony_ci I2400M_BRI_NO_REBOOT = 1 << 2, 7108c2ecf20Sopenharmony_ci I2400M_BRI_MAC_REINIT = 1 << 3, 7118c2ecf20Sopenharmony_ci}; 7128c2ecf20Sopenharmony_ci 7138c2ecf20Sopenharmony_civoid i2400m_bm_cmd_prepare(struct i2400m_bootrom_header *); 7148c2ecf20Sopenharmony_ciint i2400m_dev_bootstrap(struct i2400m *, enum i2400m_bri); 7158c2ecf20Sopenharmony_ciint i2400m_read_mac_addr(struct i2400m *); 7168c2ecf20Sopenharmony_ciint i2400m_bootrom_init(struct i2400m *, enum i2400m_bri); 7178c2ecf20Sopenharmony_ciint i2400m_is_boot_barker(struct i2400m *, const void *, size_t); 7188c2ecf20Sopenharmony_cistatic inline 7198c2ecf20Sopenharmony_ciint i2400m_is_d2h_barker(const void *buf) 7208c2ecf20Sopenharmony_ci{ 7218c2ecf20Sopenharmony_ci const __le32 *barker = buf; 7228c2ecf20Sopenharmony_ci return le32_to_cpu(*barker) == I2400M_D2H_MSG_BARKER; 7238c2ecf20Sopenharmony_ci} 7248c2ecf20Sopenharmony_civoid i2400m_unknown_barker(struct i2400m *, const void *, size_t); 7258c2ecf20Sopenharmony_ci 7268c2ecf20Sopenharmony_ci/* Make/grok boot-rom header commands */ 7278c2ecf20Sopenharmony_ci 7288c2ecf20Sopenharmony_cistatic inline 7298c2ecf20Sopenharmony_ci__le32 i2400m_brh_command(enum i2400m_brh_opcode opcode, unsigned use_checksum, 7308c2ecf20Sopenharmony_ci unsigned direct_access) 7318c2ecf20Sopenharmony_ci{ 7328c2ecf20Sopenharmony_ci return cpu_to_le32( 7338c2ecf20Sopenharmony_ci I2400M_BRH_SIGNATURE 7348c2ecf20Sopenharmony_ci | (direct_access ? I2400M_BRH_DIRECT_ACCESS : 0) 7358c2ecf20Sopenharmony_ci | I2400M_BRH_RESPONSE_REQUIRED /* response always required */ 7368c2ecf20Sopenharmony_ci | (use_checksum ? I2400M_BRH_USE_CHECKSUM : 0) 7378c2ecf20Sopenharmony_ci | (opcode & I2400M_BRH_OPCODE_MASK)); 7388c2ecf20Sopenharmony_ci} 7398c2ecf20Sopenharmony_ci 7408c2ecf20Sopenharmony_cistatic inline 7418c2ecf20Sopenharmony_civoid i2400m_brh_set_opcode(struct i2400m_bootrom_header *hdr, 7428c2ecf20Sopenharmony_ci enum i2400m_brh_opcode opcode) 7438c2ecf20Sopenharmony_ci{ 7448c2ecf20Sopenharmony_ci hdr->command = cpu_to_le32( 7458c2ecf20Sopenharmony_ci (le32_to_cpu(hdr->command) & ~I2400M_BRH_OPCODE_MASK) 7468c2ecf20Sopenharmony_ci | (opcode & I2400M_BRH_OPCODE_MASK)); 7478c2ecf20Sopenharmony_ci} 7488c2ecf20Sopenharmony_ci 7498c2ecf20Sopenharmony_cistatic inline 7508c2ecf20Sopenharmony_ciunsigned i2400m_brh_get_opcode(const struct i2400m_bootrom_header *hdr) 7518c2ecf20Sopenharmony_ci{ 7528c2ecf20Sopenharmony_ci return le32_to_cpu(hdr->command) & I2400M_BRH_OPCODE_MASK; 7538c2ecf20Sopenharmony_ci} 7548c2ecf20Sopenharmony_ci 7558c2ecf20Sopenharmony_cistatic inline 7568c2ecf20Sopenharmony_ciunsigned i2400m_brh_get_response(const struct i2400m_bootrom_header *hdr) 7578c2ecf20Sopenharmony_ci{ 7588c2ecf20Sopenharmony_ci return (le32_to_cpu(hdr->command) & I2400M_BRH_RESPONSE_MASK) 7598c2ecf20Sopenharmony_ci >> I2400M_BRH_RESPONSE_SHIFT; 7608c2ecf20Sopenharmony_ci} 7618c2ecf20Sopenharmony_ci 7628c2ecf20Sopenharmony_cistatic inline 7638c2ecf20Sopenharmony_ciunsigned i2400m_brh_get_use_checksum(const struct i2400m_bootrom_header *hdr) 7648c2ecf20Sopenharmony_ci{ 7658c2ecf20Sopenharmony_ci return le32_to_cpu(hdr->command) & I2400M_BRH_USE_CHECKSUM; 7668c2ecf20Sopenharmony_ci} 7678c2ecf20Sopenharmony_ci 7688c2ecf20Sopenharmony_cistatic inline 7698c2ecf20Sopenharmony_ciunsigned i2400m_brh_get_response_required( 7708c2ecf20Sopenharmony_ci const struct i2400m_bootrom_header *hdr) 7718c2ecf20Sopenharmony_ci{ 7728c2ecf20Sopenharmony_ci return le32_to_cpu(hdr->command) & I2400M_BRH_RESPONSE_REQUIRED; 7738c2ecf20Sopenharmony_ci} 7748c2ecf20Sopenharmony_ci 7758c2ecf20Sopenharmony_cistatic inline 7768c2ecf20Sopenharmony_ciunsigned i2400m_brh_get_direct_access(const struct i2400m_bootrom_header *hdr) 7778c2ecf20Sopenharmony_ci{ 7788c2ecf20Sopenharmony_ci return le32_to_cpu(hdr->command) & I2400M_BRH_DIRECT_ACCESS; 7798c2ecf20Sopenharmony_ci} 7808c2ecf20Sopenharmony_ci 7818c2ecf20Sopenharmony_cistatic inline 7828c2ecf20Sopenharmony_ciunsigned i2400m_brh_get_signature(const struct i2400m_bootrom_header *hdr) 7838c2ecf20Sopenharmony_ci{ 7848c2ecf20Sopenharmony_ci return (le32_to_cpu(hdr->command) & I2400M_BRH_SIGNATURE_MASK) 7858c2ecf20Sopenharmony_ci >> I2400M_BRH_SIGNATURE_SHIFT; 7868c2ecf20Sopenharmony_ci} 7878c2ecf20Sopenharmony_ci 7888c2ecf20Sopenharmony_ci 7898c2ecf20Sopenharmony_ci/* 7908c2ecf20Sopenharmony_ci * Driver / device setup and internal functions 7918c2ecf20Sopenharmony_ci */ 7928c2ecf20Sopenharmony_civoid i2400m_init(struct i2400m *); 7938c2ecf20Sopenharmony_ciint i2400m_reset(struct i2400m *, enum i2400m_reset_type); 7948c2ecf20Sopenharmony_civoid i2400m_netdev_setup(struct net_device *net_dev); 7958c2ecf20Sopenharmony_ciint i2400m_sysfs_setup(struct device_driver *); 7968c2ecf20Sopenharmony_civoid i2400m_sysfs_release(struct device_driver *); 7978c2ecf20Sopenharmony_ciint i2400m_tx_setup(struct i2400m *); 7988c2ecf20Sopenharmony_civoid i2400m_wake_tx_work(struct work_struct *); 7998c2ecf20Sopenharmony_civoid i2400m_tx_release(struct i2400m *); 8008c2ecf20Sopenharmony_ci 8018c2ecf20Sopenharmony_ciint i2400m_rx_setup(struct i2400m *); 8028c2ecf20Sopenharmony_civoid i2400m_rx_release(struct i2400m *); 8038c2ecf20Sopenharmony_ci 8048c2ecf20Sopenharmony_civoid i2400m_fw_cache(struct i2400m *); 8058c2ecf20Sopenharmony_civoid i2400m_fw_uncache(struct i2400m *); 8068c2ecf20Sopenharmony_ci 8078c2ecf20Sopenharmony_civoid i2400m_net_rx(struct i2400m *, struct sk_buff *, unsigned, const void *, 8088c2ecf20Sopenharmony_ci int); 8098c2ecf20Sopenharmony_civoid i2400m_net_erx(struct i2400m *, struct sk_buff *, enum i2400m_cs); 8108c2ecf20Sopenharmony_civoid i2400m_net_wake_stop(struct i2400m *); 8118c2ecf20Sopenharmony_cienum i2400m_pt; 8128c2ecf20Sopenharmony_ciint i2400m_tx(struct i2400m *, const void *, size_t, enum i2400m_pt); 8138c2ecf20Sopenharmony_ci 8148c2ecf20Sopenharmony_ci#ifdef CONFIG_DEBUG_FS 8158c2ecf20Sopenharmony_civoid i2400m_debugfs_add(struct i2400m *); 8168c2ecf20Sopenharmony_civoid i2400m_debugfs_rm(struct i2400m *); 8178c2ecf20Sopenharmony_ci#else 8188c2ecf20Sopenharmony_cistatic inline void i2400m_debugfs_add(struct i2400m *i2400m) {} 8198c2ecf20Sopenharmony_cistatic inline void i2400m_debugfs_rm(struct i2400m *i2400m) {} 8208c2ecf20Sopenharmony_ci#endif 8218c2ecf20Sopenharmony_ci 8228c2ecf20Sopenharmony_ci/* Initialize/shutdown the device */ 8238c2ecf20Sopenharmony_ciint i2400m_dev_initialize(struct i2400m *); 8248c2ecf20Sopenharmony_civoid i2400m_dev_shutdown(struct i2400m *); 8258c2ecf20Sopenharmony_ci 8268c2ecf20Sopenharmony_ciextern struct attribute_group i2400m_dev_attr_group; 8278c2ecf20Sopenharmony_ci 8288c2ecf20Sopenharmony_ci 8298c2ecf20Sopenharmony_ci/* HDI message's payload description handling */ 8308c2ecf20Sopenharmony_ci 8318c2ecf20Sopenharmony_cistatic inline 8328c2ecf20Sopenharmony_cisize_t i2400m_pld_size(const struct i2400m_pld *pld) 8338c2ecf20Sopenharmony_ci{ 8348c2ecf20Sopenharmony_ci return I2400M_PLD_SIZE_MASK & le32_to_cpu(pld->val); 8358c2ecf20Sopenharmony_ci} 8368c2ecf20Sopenharmony_ci 8378c2ecf20Sopenharmony_cistatic inline 8388c2ecf20Sopenharmony_cienum i2400m_pt i2400m_pld_type(const struct i2400m_pld *pld) 8398c2ecf20Sopenharmony_ci{ 8408c2ecf20Sopenharmony_ci return (I2400M_PLD_TYPE_MASK & le32_to_cpu(pld->val)) 8418c2ecf20Sopenharmony_ci >> I2400M_PLD_TYPE_SHIFT; 8428c2ecf20Sopenharmony_ci} 8438c2ecf20Sopenharmony_ci 8448c2ecf20Sopenharmony_cistatic inline 8458c2ecf20Sopenharmony_civoid i2400m_pld_set(struct i2400m_pld *pld, size_t size, 8468c2ecf20Sopenharmony_ci enum i2400m_pt type) 8478c2ecf20Sopenharmony_ci{ 8488c2ecf20Sopenharmony_ci pld->val = cpu_to_le32( 8498c2ecf20Sopenharmony_ci ((type << I2400M_PLD_TYPE_SHIFT) & I2400M_PLD_TYPE_MASK) 8508c2ecf20Sopenharmony_ci | (size & I2400M_PLD_SIZE_MASK)); 8518c2ecf20Sopenharmony_ci} 8528c2ecf20Sopenharmony_ci 8538c2ecf20Sopenharmony_ci 8548c2ecf20Sopenharmony_ci/* 8558c2ecf20Sopenharmony_ci * API for the bus-specific drivers 8568c2ecf20Sopenharmony_ci * -------------------------------- 8578c2ecf20Sopenharmony_ci */ 8588c2ecf20Sopenharmony_ci 8598c2ecf20Sopenharmony_cistatic inline 8608c2ecf20Sopenharmony_cistruct i2400m *i2400m_get(struct i2400m *i2400m) 8618c2ecf20Sopenharmony_ci{ 8628c2ecf20Sopenharmony_ci dev_hold(i2400m->wimax_dev.net_dev); 8638c2ecf20Sopenharmony_ci return i2400m; 8648c2ecf20Sopenharmony_ci} 8658c2ecf20Sopenharmony_ci 8668c2ecf20Sopenharmony_cistatic inline 8678c2ecf20Sopenharmony_civoid i2400m_put(struct i2400m *i2400m) 8688c2ecf20Sopenharmony_ci{ 8698c2ecf20Sopenharmony_ci dev_put(i2400m->wimax_dev.net_dev); 8708c2ecf20Sopenharmony_ci} 8718c2ecf20Sopenharmony_ci 8728c2ecf20Sopenharmony_ciint i2400m_dev_reset_handle(struct i2400m *, const char *); 8738c2ecf20Sopenharmony_ciint i2400m_pre_reset(struct i2400m *); 8748c2ecf20Sopenharmony_ciint i2400m_post_reset(struct i2400m *); 8758c2ecf20Sopenharmony_civoid i2400m_error_recovery(struct i2400m *); 8768c2ecf20Sopenharmony_ci 8778c2ecf20Sopenharmony_ci/* 8788c2ecf20Sopenharmony_ci * _setup()/_release() are called by the probe/disconnect functions of 8798c2ecf20Sopenharmony_ci * the bus-specific drivers. 8808c2ecf20Sopenharmony_ci */ 8818c2ecf20Sopenharmony_ciint i2400m_setup(struct i2400m *, enum i2400m_bri bm_flags); 8828c2ecf20Sopenharmony_civoid i2400m_release(struct i2400m *); 8838c2ecf20Sopenharmony_ci 8848c2ecf20Sopenharmony_ciint i2400m_rx(struct i2400m *, struct sk_buff *); 8858c2ecf20Sopenharmony_cistruct i2400m_msg_hdr *i2400m_tx_msg_get(struct i2400m *, size_t *); 8868c2ecf20Sopenharmony_civoid i2400m_tx_msg_sent(struct i2400m *); 8878c2ecf20Sopenharmony_ci 8888c2ecf20Sopenharmony_ci 8898c2ecf20Sopenharmony_ci/* 8908c2ecf20Sopenharmony_ci * Utility functions 8918c2ecf20Sopenharmony_ci */ 8928c2ecf20Sopenharmony_ci 8938c2ecf20Sopenharmony_cistatic inline 8948c2ecf20Sopenharmony_cistruct device *i2400m_dev(struct i2400m *i2400m) 8958c2ecf20Sopenharmony_ci{ 8968c2ecf20Sopenharmony_ci return i2400m->wimax_dev.net_dev->dev.parent; 8978c2ecf20Sopenharmony_ci} 8988c2ecf20Sopenharmony_ci 8998c2ecf20Sopenharmony_ciint i2400m_msg_check_status(const struct i2400m_l3l4_hdr *, char *, size_t); 9008c2ecf20Sopenharmony_ciint i2400m_msg_size_check(struct i2400m *, const struct i2400m_l3l4_hdr *, 9018c2ecf20Sopenharmony_ci size_t); 9028c2ecf20Sopenharmony_cistruct sk_buff *i2400m_msg_to_dev(struct i2400m *, const void *, size_t); 9038c2ecf20Sopenharmony_civoid i2400m_msg_to_dev_cancel_wait(struct i2400m *, int); 9048c2ecf20Sopenharmony_civoid i2400m_report_hook(struct i2400m *, const struct i2400m_l3l4_hdr *, 9058c2ecf20Sopenharmony_ci size_t); 9068c2ecf20Sopenharmony_civoid i2400m_report_hook_work(struct work_struct *); 9078c2ecf20Sopenharmony_ciint i2400m_cmd_enter_powersave(struct i2400m *); 9088c2ecf20Sopenharmony_ciint i2400m_cmd_exit_idle(struct i2400m *); 9098c2ecf20Sopenharmony_cistruct sk_buff *i2400m_get_device_info(struct i2400m *); 9108c2ecf20Sopenharmony_ciint i2400m_firmware_check(struct i2400m *); 9118c2ecf20Sopenharmony_ciint i2400m_set_idle_timeout(struct i2400m *, unsigned); 9128c2ecf20Sopenharmony_ci 9138c2ecf20Sopenharmony_cistatic inline 9148c2ecf20Sopenharmony_cistruct usb_endpoint_descriptor *usb_get_epd(struct usb_interface *iface, int ep) 9158c2ecf20Sopenharmony_ci{ 9168c2ecf20Sopenharmony_ci return &iface->cur_altsetting->endpoint[ep].desc; 9178c2ecf20Sopenharmony_ci} 9188c2ecf20Sopenharmony_ci 9198c2ecf20Sopenharmony_ciint i2400m_op_rfkill_sw_toggle(struct wimax_dev *, enum wimax_rf_state); 9208c2ecf20Sopenharmony_civoid i2400m_report_tlv_rf_switches_status(struct i2400m *, 9218c2ecf20Sopenharmony_ci const struct i2400m_tlv_rf_switches_status *); 9228c2ecf20Sopenharmony_ci 9238c2ecf20Sopenharmony_ci/* 9248c2ecf20Sopenharmony_ci * Helpers for firmware backwards compatibility 9258c2ecf20Sopenharmony_ci * 9268c2ecf20Sopenharmony_ci * As we aim to support at least the firmware version that was 9278c2ecf20Sopenharmony_ci * released with the previous kernel/driver release, some code will be 9288c2ecf20Sopenharmony_ci * conditionally executed depending on the firmware version. On each 9298c2ecf20Sopenharmony_ci * release, the code to support fw releases past the last two ones 9308c2ecf20Sopenharmony_ci * will be purged. 9318c2ecf20Sopenharmony_ci * 9328c2ecf20Sopenharmony_ci * By making it depend on this macros, it is easier to keep it a tab 9338c2ecf20Sopenharmony_ci * on what has to go and what not. 9348c2ecf20Sopenharmony_ci */ 9358c2ecf20Sopenharmony_cistatic inline 9368c2ecf20Sopenharmony_ciunsigned i2400m_le_v1_3(struct i2400m *i2400m) 9378c2ecf20Sopenharmony_ci{ 9388c2ecf20Sopenharmony_ci /* running fw is lower or v1.3 */ 9398c2ecf20Sopenharmony_ci return i2400m->fw_version <= 0x00090001; 9408c2ecf20Sopenharmony_ci} 9418c2ecf20Sopenharmony_ci 9428c2ecf20Sopenharmony_cistatic inline 9438c2ecf20Sopenharmony_ciunsigned i2400m_ge_v1_4(struct i2400m *i2400m) 9448c2ecf20Sopenharmony_ci{ 9458c2ecf20Sopenharmony_ci /* running fw is higher or v1.4 */ 9468c2ecf20Sopenharmony_ci return i2400m->fw_version >= 0x00090002; 9478c2ecf20Sopenharmony_ci} 9488c2ecf20Sopenharmony_ci 9498c2ecf20Sopenharmony_ci 9508c2ecf20Sopenharmony_ci/* 9518c2ecf20Sopenharmony_ci * Do a millisecond-sleep for allowing wireshark to dump all the data 9528c2ecf20Sopenharmony_ci * packets. Used only for debugging. 9538c2ecf20Sopenharmony_ci */ 9548c2ecf20Sopenharmony_cistatic inline 9558c2ecf20Sopenharmony_civoid __i2400m_msleep(unsigned ms) 9568c2ecf20Sopenharmony_ci{ 9578c2ecf20Sopenharmony_ci#if 1 9588c2ecf20Sopenharmony_ci#else 9598c2ecf20Sopenharmony_ci msleep(ms); 9608c2ecf20Sopenharmony_ci#endif 9618c2ecf20Sopenharmony_ci} 9628c2ecf20Sopenharmony_ci 9638c2ecf20Sopenharmony_ci 9648c2ecf20Sopenharmony_ci/* module initialization helpers */ 9658c2ecf20Sopenharmony_ciint i2400m_barker_db_init(const char *); 9668c2ecf20Sopenharmony_civoid i2400m_barker_db_exit(void); 9678c2ecf20Sopenharmony_ci 9688c2ecf20Sopenharmony_ci 9698c2ecf20Sopenharmony_ci 9708c2ecf20Sopenharmony_ci#endif /* #ifndef __I2400M_H__ */ 971