Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2)  * Intel Wireless WiMAX Connection 2400m
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  * USB-specific i2400m driver definitions
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  * Copyright (C) 2007-2008 Intel Corporation. All rights reserved.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8)  * Redistribution and use in source and binary forms, with or without
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9)  * modification, are permitted provided that the following conditions
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10)  * are met:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12)  *   * Redistributions of source code must retain the above copyright
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13)  *     notice, this list of conditions and the following disclaimer.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14)  *   * Redistributions in binary form must reproduce the above copyright
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15)  *     notice, this list of conditions and the following disclaimer in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16)  *     the documentation and/or other materials provided with the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17)  *     distribution.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18)  *   * Neither the name of Intel Corporation nor the names of its
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19)  *     contributors may be used to endorse or promote products derived
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20)  *     from this software without specific prior written permission.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22)  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23)  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24)  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25)  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26)  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27)  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28)  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29)  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30)  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31)  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32)  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35)  * Intel Corporation <linux-wimax@intel.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36)  * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37)  * Yanir Lubetkin <yanirx.lubetkin@intel.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38)  *  - Initial implementation
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41)  * This driver implements the bus-specific part of the i2400m for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42)  * USB. Check i2400m.h for a generic driver description.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44)  * ARCHITECTURE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46)  * This driver listens to notifications sent from the notification
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47)  * endpoint (in usb-notif.c); when data is ready to read, the code in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48)  * there schedules a read from the device (usb-rx.c) and then passes
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49)  * the data to the generic RX code (rx.c).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51)  * When the generic driver needs to send data (network or control), it
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52)  * queues up in the TX FIFO (tx.c) and that will notify the driver
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53)  * through the i2400m->bus_tx_kick() callback
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54)  * (usb-tx.c:i2400mu_bus_tx_kick) which will send the items in the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55)  * FIFO queue.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57)  * This driver, as well, implements the USB-specific ops for the generic
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58)  * driver to be able to setup/teardown communication with the device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59)  * [i2400m_bus_dev_start() and i2400m_bus_dev_stop()], reseting the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60)  * device [i2400m_bus_reset()] and performing firmware upload
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61)  * [i2400m_bus_bm_cmd() and i2400_bus_bm_wait_for_ack()].
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) #ifndef __I2400M_USB_H__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) #define __I2400M_USB_H__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) #include "i2400m.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) #include <linux/kthread.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72)  * Error Density Count: cheapo error density (over time) counter
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74)  * Originally by Reinette Chatre <reinette.chatre@intel.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76)  * Embed an 'struct edc' somewhere. Each time there is a soft or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77)  * retryable error, call edc_inc() and check if the error top
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78)  * watermark has been reached.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) enum {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 	EDC_MAX_ERRORS = 10,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 	EDC_ERROR_TIMEFRAME = HZ,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) /* error density counter */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) struct edc {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 	unsigned long timestart;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 	u16 errorcount;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) struct i2400m_endpoint_cfg {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 	unsigned char bulk_out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 	unsigned char notification;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 	unsigned char reset_cold;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 	unsigned char bulk_in;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) static inline void edc_init(struct edc *edc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 	edc->timestart = jiffies;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104)  * edc_inc - report a soft error and check if we are over the watermark
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106)  * @edc: pointer to error density counter.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107)  * @max_err: maximum number of errors we can accept over the timeframe
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108)  * @timeframe: length of the timeframe (in jiffies).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110)  * Returns: !0 1 if maximum acceptable errors per timeframe has been
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111)  *     exceeded. 0 otherwise.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113)  * This is way to determine if the number of acceptable errors per time
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114)  * period has been exceeded. It is not accurate as there are cases in which
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115)  * this scheme will not work, for example if there are periodic occurrences
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116)  * of errors that straddle updates to the start time. This scheme is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117)  * sufficient for our usage.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119)  * To use, embed a 'struct edc' somewhere, initialize it with
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120)  * edc_init() and when an error hits:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122)  * if (do_something_fails_with_a_soft_error) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123)  *        if (edc_inc(&my->edc, MAX_ERRORS, MAX_TIMEFRAME))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124)  * 	           Ops, hard error, do something about it
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125)  *        else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126)  *                 Retry or ignore, depending on whatever
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127)  * }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) static inline int edc_inc(struct edc *edc, u16 max_err, u16 timeframe)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 	unsigned long now;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 	now = jiffies;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 	if (time_after(now, edc->timestart + timeframe)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 		edc->errorcount = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 		edc->timestart = now;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 	} else if (++edc->errorcount > max_err) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 		edc->errorcount = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 		edc->timestart = now;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 		return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) /* Host-Device interface for USB */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) enum {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 	I2400M_USB_BOOT_RETRIES = 3,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 	I2400MU_MAX_NOTIFICATION_LEN = 256,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) 	I2400MU_BLK_SIZE = 16,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) 	I2400MU_PL_SIZE_MAX = 0x3EFF,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) 	/* Device IDs */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) 	USB_DEVICE_ID_I6050 = 0x0186,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) 	USB_DEVICE_ID_I6050_2 = 0x0188,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) 	USB_DEVICE_ID_I6150 = 0x07d6,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 	USB_DEVICE_ID_I6150_2 = 0x07d7,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) 	USB_DEVICE_ID_I6150_3 = 0x07d9,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) 	USB_DEVICE_ID_I6250 = 0x0187,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163)  * struct i2400mu - descriptor for a USB connected i2400m
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165)  * @i2400m: bus-generic i2400m implementation; has to be first (see
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166)  *     it's documentation in i2400m.h).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168)  * @usb_dev: pointer to our USB device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170)  * @usb_iface: pointer to our USB interface
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172)  * @urb_edc: error density counter; used to keep a density-on-time tab
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173)  *     on how many soft (retryable or ignorable) errors we get. If we
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174)  *     go over the threshold, we consider the bus transport is failing
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175)  *     too much and reset.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177)  * @notif_urb: URB for receiving notifications from the device.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179)  * @tx_kthread: thread we use for data TX. We use a thread because in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180)  *     order to do deep power saving and put the device to sleep, we
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181)  *     need to call usb_autopm_*() [blocking functions].
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183)  * @tx_wq: waitqueue for the TX kthread to sleep when there is no data
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184)  *     to be sent; when more data is available, it is woken up by
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185)  *     i2400mu_bus_tx_kick().
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187)  * @rx_kthread: thread we use for data RX. We use a thread because in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188)  *     order to do deep power saving and put the device to sleep, we
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189)  *     need to call usb_autopm_*() [blocking functions].
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191)  * @rx_wq: waitqueue for the RX kthread to sleep when there is no data
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192)  *     to receive. When data is available, it is woken up by
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193)  *     usb-notif.c:i2400mu_notification_grok().
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195)  * @rx_pending_count: number of rx-data-ready notifications that were
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196)  *     still not handled by the RX kthread.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198)  * @rx_size: current RX buffer size that is being used.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200)  * @rx_size_acc: accumulator of the sizes of the previous read
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201)  *     transactions.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203)  * @rx_size_cnt: number of read transactions accumulated in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204)  *     @rx_size_acc.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206)  * @do_autopm: disable(0)/enable(>0) calling the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207)  *     usb_autopm_get/put_interface() barriers when executing
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208)  *     commands. See doc in i2400mu_suspend() for more information.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210)  * @rx_size_auto_shrink: if true, the rx_size is shrunk
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211)  *     automatically based on the average size of the received
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212)  *     transactions. This allows the receive code to allocate smaller
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213)  *     chunks of memory and thus reduce pressure on the memory
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214)  *     allocator by not wasting so much space. By default it is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215)  *     enabled.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217)  * @debugfs_dentry: hookup for debugfs files.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218)  *     These have to be in a separate directory, a child of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219)  *     (wimax_dev->debugfs_dentry) so they can be removed when the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220)  *     module unloads, as we don't keep each dentry.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) struct i2400mu {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) 	struct i2400m i2400m;		/* FIRST! See doc */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) 	struct usb_device *usb_dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) 	struct usb_interface *usb_iface;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) 	struct edc urb_edc;		/* Error density counter */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) 	struct i2400m_endpoint_cfg endpoint_cfg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) 	struct urb *notif_urb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) 	struct task_struct *tx_kthread;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) 	wait_queue_head_t tx_wq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) 	struct task_struct *rx_kthread;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) 	wait_queue_head_t rx_wq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) 	atomic_t rx_pending_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) 	size_t rx_size, rx_size_acc, rx_size_cnt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) 	atomic_t do_autopm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) 	u8 rx_size_auto_shrink;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) 	struct dentry *debugfs_dentry;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) 	unsigned i6050:1;	/* 1 if this is a 6050 based SKU */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) static inline
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) void i2400mu_init(struct i2400mu *i2400mu)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) 	i2400m_init(&i2400mu->i2400m);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) 	edc_init(&i2400mu->urb_edc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) 	init_waitqueue_head(&i2400mu->tx_wq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) 	atomic_set(&i2400mu->rx_pending_count, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) 	init_waitqueue_head(&i2400mu->rx_wq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) 	i2400mu->rx_size = PAGE_SIZE - sizeof(struct skb_shared_info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) 	atomic_set(&i2400mu->do_autopm, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) 	i2400mu->rx_size_auto_shrink = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) int i2400mu_notification_setup(struct i2400mu *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) void i2400mu_notification_release(struct i2400mu *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) int i2400mu_rx_setup(struct i2400mu *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) void i2400mu_rx_release(struct i2400mu *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) void i2400mu_rx_kick(struct i2400mu *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) int i2400mu_tx_setup(struct i2400mu *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) void i2400mu_tx_release(struct i2400mu *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) void i2400mu_bus_tx_kick(struct i2400m *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) ssize_t i2400mu_bus_bm_cmd_send(struct i2400m *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) 				const struct i2400m_bootrom_header *, size_t,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) 				int);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) ssize_t i2400mu_bus_bm_wait_for_ack(struct i2400m *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) 				    struct i2400m_bootrom_header *, size_t);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) #endif /* #ifndef __I2400M_USB_H__ */