2 * Beceem WiMax USB Driver
3 * Copyright 2010-2011 Haiku, Inc. All rights reserved.
4 * Distributed under the terms of the MIT license.
7 * Alexander von Gluck, <kallisti5@unixzen.com>
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"
27 #include "DeviceStruct.h"
29 #define MAX_USB_IO_RETRIES 1
30 #define MAX_USB_TRANSFER 255
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
; };
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();
59 status_t
PushConfig(uint32 loc
);
60 status_t
PushFirmware(uint32 loc
);
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
);
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;
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
);
104 vint32 fInsideNotify
;
108 const char * fDescription
;
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
;
124 sem_id fNotifyReadSem
;
125 sem_id fNotifyWriteSem
;
127 uint8
* fNotifyBuffer
;
128 uint32 fNotifyBufferLength
;
131 sem_id fLinkStateChangeSem
;
132 ether_address_t fMACAddress
;
137 #endif /*_USB_BECEEM_DEVICE_H_*/