3rdparty/licenseReport: Add seperate LGPL checks
[haiku.git] / src / add-ons / kernel / drivers / network / wwan / usb_beceemwmx / BeceemDevice.h
blob0adddfcedd44d08a363e6181afa97fa23127d825
1 /*
2 * Beceem WiMax USB Driver
3 * Copyright 2010-2011 Haiku, Inc. All rights reserved.
4 * Distributed under the terms of the MIT license.
6 * Authors:
7 * Alexander von Gluck, <kallisti5@unixzen.com>
9 * Partially using:
10 * USB Ethernet Control Model devices
11 * (c) 2008 by Michael Lotz, <mmlr@mlotz.ch>
12 * ASIX AX88172/AX88772/AX88178 USB 2.0 Ethernet Driver
13 * (c) 2008 by S.Zharski, <imker@gmx.li>
15 #ifndef _USB_BECEEM_DEVICE_H_
16 #define _USB_BECEEM_DEVICE_H_
18 #include <net/if_media.h>
19 #include <sys/ioctl.h>
21 #include "BeceemNVM.h"
22 #include "BeceemDDR.h"
23 #include "BeceemCPU.h"
24 #include "BeceemLED.h"
26 #include "Driver.h"
27 #include "DeviceStruct.h"
29 #define MAX_USB_IO_RETRIES 1
30 #define MAX_USB_TRANSFER 255
33 class BeceemDevice
35 public BeceemNVM,
36 public BeceemDDR,
37 public BeceemCPU,
38 public BeceemLED
41 public:
42 BeceemDevice(usb_device device,
43 const char *description);
44 virtual ~BeceemDevice();
46 status_t InitCheck() { return fStatus; };
48 status_t Open(uint32 flags);
49 bool IsOpen() { return fOpen; };
51 status_t Close();
52 status_t Free();
54 status_t Read(uint8 *buffer, size_t *numBytes);
55 status_t Write(const uint8 *buffer, size_t *numBytes);
56 status_t Control(uint32 op, void *buffer, size_t length);
57 status_t LoadConfig();
58 void DumpConfig();
59 status_t PushConfig(uint32 loc);
60 status_t PushFirmware(uint32 loc);
62 void Removed();
64 status_t CompareAndReattach(usb_device device);
65 virtual status_t SetupDevice(bool deviceReplugged);
67 status_t ReadRegister(uint32 reg,
68 size_t size, uint32* buffer);
69 status_t WriteRegister(uint32 reg,
70 size_t size, uint32* buffer);
71 status_t BizarroReadRegister(uint32 reg,
72 size_t size, uint32* buffer);
73 status_t BizarroWriteRegister(uint32 reg,
74 size_t size, uint32* buffer);
76 private:
77 static void _ReadCallback(void *cookie, int32 status,
78 void *data, uint32 actualLength);
79 static void _WriteCallback(void *cookie, int32 status,
80 void *data, uint32 actualLength);
81 static void _NotifyCallback(void *cookie, int32 status,
82 void *data, uint32 actualLength);
84 status_t _SetupEndpoints();
86 status_t IdentifyChipset();
88 static const int kFrameSize = 1518;
89 static const uint8 kRXHeaderSize = 3;
90 static const uint8 kTXHeaderSize = 2;
92 protected:
93 virtual status_t StartDevice() ;
94 virtual status_t StopDevice();
95 virtual status_t OnNotify(uint32 actualLength) ;
96 virtual status_t GetLinkState(ether_link_state *state) ;
97 virtual status_t SetPromiscuousMode(bool bOn);
98 virtual status_t ModifyMulticastTable(bool add, uint8 address);
101 // state tracking
102 status_t fStatus;
103 bool fOpen;
104 vint32 fInsideNotify;
105 usb_device fDevice;
106 uint16 fVendorID;
107 uint16 fProductID;
108 const char * fDescription;
109 bool fNonBlocking;
111 struct WIMAX_DEVICE *pwmxdevice;
112 // Our driver device struct
114 // pipes for notifications and data io
115 usb_pipe fNotifyEndpoint;
116 usb_pipe fReadEndpoint;
117 usb_pipe fWriteEndpoint;
119 // data stores for async usb transfers
120 uint32 fActualLengthRead;
121 uint32 fActualLengthWrite;
122 int32 fStatusRead;
123 int32 fStatusWrite;
124 sem_id fNotifyReadSem;
125 sem_id fNotifyWriteSem;
127 uint8 * fNotifyBuffer;
128 uint32 fNotifyBufferLength;
130 // connection data
131 sem_id fLinkStateChangeSem;
132 ether_address_t fMACAddress;
133 bool fHasConnection;
134 bool fTXBufferFull;
137 #endif /*_USB_BECEEM_DEVICE_H_*/