usb_asix: style cleanup
* While I was in the neighbourhood * No functional change
This commit is contained in:
@@ -187,6 +187,7 @@ ASIXDevice::Read(uint8 *buffer, size_t *numBytes)
|
|||||||
|
|
||||||
status_t result = gUSBModule->queue_bulk_v(fReadEndpoint,
|
status_t result = gUSBModule->queue_bulk_v(fReadEndpoint,
|
||||||
&rxData[startIndex], chunkCount, _ReadCallback, this);
|
&rxData[startIndex], chunkCount, _ReadCallback, this);
|
||||||
|
|
||||||
if (result != B_OK) {
|
if (result != B_OK) {
|
||||||
TRACE_ALWAYS("Error of queue_bulk_v request:%#010x\n", result);
|
TRACE_ALWAYS("Error of queue_bulk_v request:%#010x\n", result);
|
||||||
return result;
|
return result;
|
||||||
@@ -265,6 +266,7 @@ ASIXDevice::Write(const uint8 *buffer, size_t *numBytes)
|
|||||||
|
|
||||||
status_t result = gUSBModule->queue_bulk_v(fWriteEndpoint,
|
status_t result = gUSBModule->queue_bulk_v(fWriteEndpoint,
|
||||||
&txData[startIndex], chunkCount, _WriteCallback, this);
|
&txData[startIndex], chunkCount, _WriteCallback, this);
|
||||||
|
|
||||||
if (result != B_OK) {
|
if (result != B_OK) {
|
||||||
TRACE_ALWAYS("Error of queue_bulk_v request:%#010x\n", result);
|
TRACE_ALWAYS("Error of queue_bulk_v request:%#010x\n", result);
|
||||||
return result;
|
return result;
|
||||||
@@ -388,9 +390,10 @@ ASIXDevice::SetupDevice(bool deviceReplugged)
|
|||||||
// address (which should be at the same index) to make sure
|
// address (which should be at the same index) to make sure
|
||||||
if (memcmp(&address, &fMACAddress, sizeof(address)) != 0) {
|
if (memcmp(&address, &fMACAddress, sizeof(address)) != 0) {
|
||||||
TRACE_ALWAYS("Cannot replace device with MAC address:"
|
TRACE_ALWAYS("Cannot replace device with MAC address:"
|
||||||
"%02x:%02x:%02x:%02x:%02x:%02x\n",
|
"%02x:%02x:%02x:%02x:%02x:%02x\n", fMACAddress.ebyte[0],
|
||||||
fMACAddress.ebyte[0], fMACAddress.ebyte[1], fMACAddress.ebyte[2],
|
fMACAddress.ebyte[1], fMACAddress.ebyte[2],
|
||||||
fMACAddress.ebyte[3], fMACAddress.ebyte[4], fMACAddress.ebyte[5]);
|
fMACAddress.ebyte[3], fMACAddress.ebyte[4],
|
||||||
|
fMACAddress.ebyte[5]);
|
||||||
return B_BAD_VALUE; // is not the same
|
return B_BAD_VALUE; // is not the same
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
@@ -473,30 +476,26 @@ ASIXDevice::_SetupEndpoints()
|
|||||||
for (size_t ep = 0; ep < interface->endpoint_count; ep++) {
|
for (size_t ep = 0; ep < interface->endpoint_count; ep++) {
|
||||||
usb_endpoint_descriptor *epd = interface->endpoint[ep].descr;
|
usb_endpoint_descriptor *epd = interface->endpoint[ep].descr;
|
||||||
if ((epd->attributes & USB_ENDPOINT_ATTR_MASK)
|
if ((epd->attributes & USB_ENDPOINT_ATTR_MASK)
|
||||||
== USB_ENDPOINT_ATTR_INTERRUPT)
|
== USB_ENDPOINT_ATTR_INTERRUPT) {
|
||||||
{
|
|
||||||
notifyEndpoint = ep;
|
notifyEndpoint = ep;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((epd->attributes & USB_ENDPOINT_ATTR_MASK)
|
if ((epd->attributes & USB_ENDPOINT_ATTR_MASK)
|
||||||
!= USB_ENDPOINT_ATTR_BULK)
|
!= USB_ENDPOINT_ATTR_BULK) {
|
||||||
{
|
|
||||||
TRACE_ALWAYS("Error: USB endpoint type %#04x is unknown.\n",
|
TRACE_ALWAYS("Error: USB endpoint type %#04x is unknown.\n",
|
||||||
epd->attributes);
|
epd->attributes);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((epd->endpoint_address & USB_ENDPOINT_ADDR_DIR_IN)
|
if ((epd->endpoint_address & USB_ENDPOINT_ADDR_DIR_IN)
|
||||||
== USB_ENDPOINT_ADDR_DIR_IN)
|
== USB_ENDPOINT_ADDR_DIR_IN) {
|
||||||
{
|
|
||||||
readEndpoint = ep;
|
readEndpoint = ep;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((epd->endpoint_address & USB_ENDPOINT_ADDR_DIR_OUT)
|
if ((epd->endpoint_address & USB_ENDPOINT_ADDR_DIR_OUT)
|
||||||
== USB_ENDPOINT_ADDR_DIR_OUT)
|
== USB_ENDPOINT_ADDR_DIR_OUT) {
|
||||||
{
|
|
||||||
writeEndpoint = ep;
|
writeEndpoint = ep;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -504,8 +503,8 @@ ASIXDevice::_SetupEndpoints()
|
|||||||
|
|
||||||
if (notifyEndpoint == -1 || readEndpoint == -1 || writeEndpoint == -1) {
|
if (notifyEndpoint == -1 || readEndpoint == -1 || writeEndpoint == -1) {
|
||||||
TRACE_ALWAYS("Error: not all USB endpoints were found: "
|
TRACE_ALWAYS("Error: not all USB endpoints were found: "
|
||||||
"notify:%d; read:%d; write:%d\n",
|
"notify:%d; read:%d; write:%d\n", notifyEndpoint, readEndpoint,
|
||||||
notifyEndpoint, readEndpoint, writeEndpoint);
|
writeEndpoint);
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -524,9 +523,9 @@ ASIXDevice::ReadMACAddress(ether_address_t *address)
|
|||||||
{
|
{
|
||||||
size_t actual_length = 0;
|
size_t actual_length = 0;
|
||||||
status_t result = gUSBModule->send_request(fDevice,
|
status_t result = gUSBModule->send_request(fDevice,
|
||||||
USB_REQTYPE_VENDOR | USB_REQTYPE_DEVICE_IN,
|
USB_REQTYPE_VENDOR | USB_REQTYPE_DEVICE_IN, fReadNodeIDRequest,
|
||||||
fReadNodeIDRequest, 0, 0, sizeof(ether_address),
|
0, 0, sizeof(ether_address), address, &actual_length);
|
||||||
address, &actual_length);
|
|
||||||
if (result != B_OK) {
|
if (result != B_OK) {
|
||||||
TRACE_ALWAYS("Error of reading MAC address:%#010x\n", result);
|
TRACE_ALWAYS("Error of reading MAC address:%#010x\n", result);
|
||||||
return result;
|
return result;
|
||||||
@@ -549,14 +548,13 @@ ASIXDevice::ReadRXControlRegister(uint16 *rxcontrol)
|
|||||||
*rxcontrol = 0;
|
*rxcontrol = 0;
|
||||||
|
|
||||||
status_t result = gUSBModule->send_request(fDevice,
|
status_t result = gUSBModule->send_request(fDevice,
|
||||||
USB_REQTYPE_VENDOR | USB_REQTYPE_DEVICE_IN,
|
USB_REQTYPE_VENDOR | USB_REQTYPE_DEVICE_IN, READ_RX_CONTROL,
|
||||||
READ_RX_CONTROL, 0, 0,
|
0, 0, sizeof(*rxcontrol), rxcontrol, &actual_length);
|
||||||
sizeof(*rxcontrol), rxcontrol, &actual_length);
|
|
||||||
|
|
||||||
if (sizeof(*rxcontrol) != actual_length) {
|
if (sizeof(*rxcontrol) != actual_length) {
|
||||||
TRACE_ALWAYS("Mismatch during reading RX control register."
|
TRACE_ALWAYS("Mismatch during reading RX control register."
|
||||||
"Read %d bytes instead of %d.\n",
|
"Read %d bytes instead of %d.\n", actual_length,
|
||||||
actual_length, sizeof(*rxcontrol));
|
sizeof(*rxcontrol));
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
@@ -567,8 +565,8 @@ status_t
|
|||||||
ASIXDevice::WriteRXControlRegister(uint16 rxcontrol)
|
ASIXDevice::WriteRXControlRegister(uint16 rxcontrol)
|
||||||
{
|
{
|
||||||
status_t result = gUSBModule->send_request(fDevice,
|
status_t result = gUSBModule->send_request(fDevice,
|
||||||
USB_REQTYPE_VENDOR | USB_REQTYPE_DEVICE_OUT,
|
USB_REQTYPE_VENDOR | USB_REQTYPE_DEVICE_OUT, WRITE_RX_CONTROL,
|
||||||
WRITE_RX_CONTROL, rxcontrol, 0, 0, 0, 0);
|
rxcontrol, 0, 0, 0, 0);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -578,9 +576,8 @@ ASIXDevice::StopDevice()
|
|||||||
{
|
{
|
||||||
status_t result = WriteRXControlRegister(0);
|
status_t result = WriteRXControlRegister(0);
|
||||||
|
|
||||||
if (result != B_OK) {
|
if (result != B_OK)
|
||||||
TRACE_ALWAYS("Error of writing %#04x RX Control:%#010x\n", 0, result);
|
TRACE_ALWAYS("Error of writing %#04x RX Control:%#010x\n", 0, result);
|
||||||
}
|
|
||||||
|
|
||||||
TRACE_RET(result);
|
TRACE_RET(result);
|
||||||
return result;
|
return result;
|
||||||
@@ -681,9 +678,9 @@ ASIXDevice::ModifyMulticastTable(bool join, ether_address_t* group)
|
|||||||
// write multicast hash table
|
// write multicast hash table
|
||||||
size_t actualLength = 0;
|
size_t actualLength = 0;
|
||||||
result = gUSBModule->send_request(fDevice,
|
result = gUSBModule->send_request(fDevice,
|
||||||
USB_REQTYPE_VENDOR | USB_REQTYPE_DEVICE_OUT,
|
USB_REQTYPE_VENDOR | USB_REQTYPE_DEVICE_OUT, WRITE_MF_ARRAY,
|
||||||
WRITE_MF_ARRAY, 0, 0,
|
0, 0, hashLength, hashTable, &actualLength);
|
||||||
hashLength, hashTable, &actualLength);
|
|
||||||
if (result != B_OK) {
|
if (result != B_OK) {
|
||||||
TRACE_ALWAYS("Error writing hash table in MAR: %#010x.\n", result);
|
TRACE_ALWAYS("Error writing hash table in MAR: %#010x.\n", result);
|
||||||
return result;
|
return result;
|
||||||
|
|||||||
@@ -175,8 +175,8 @@ AX88172Device::StartDevice()
|
|||||||
|
|
||||||
for (size_t i = 0; i < sizeof(fIPG) / sizeof(fIPG[0]); i++) {
|
for (size_t i = 0; i < sizeof(fIPG) / sizeof(fIPG[0]); i++) {
|
||||||
status_t result = gUSBModule->send_request(fDevice,
|
status_t result = gUSBModule->send_request(fDevice,
|
||||||
USB_REQTYPE_VENDOR | USB_REQTYPE_DEVICE_OUT,
|
USB_REQTYPE_VENDOR | USB_REQTYPE_DEVICE_OUT, WRITE_IPG0,
|
||||||
WRITE_IPG0, 0, 0, sizeof(fIPG[i]), &fIPG[i], &actualLength);
|
0, 0, sizeof(fIPG[i]), &fIPG[i], &actualLength);
|
||||||
|
|
||||||
if (result != B_OK) {
|
if (result != B_OK) {
|
||||||
TRACE_ALWAYS("Error writing IPG%d: %#010x\n", i, result);
|
TRACE_ALWAYS("Error writing IPG%d: %#010x\n", i, result);
|
||||||
@@ -222,11 +222,13 @@ AX88172Device::OnNotify(uint32 actualLength)
|
|||||||
switch(fMII.ActivePHY()) {
|
switch(fMII.ActivePHY()) {
|
||||||
case PrimaryPHY:
|
case PrimaryPHY:
|
||||||
phyIndex = 1;
|
phyIndex = 1;
|
||||||
linkIsUp = (notification->btNN & LINK_STATE_PHY1) == LINK_STATE_PHY1;
|
linkIsUp = (notification->btNN & LINK_STATE_PHY1)
|
||||||
|
== LINK_STATE_PHY1;
|
||||||
break;
|
break;
|
||||||
case SecondaryPHY:
|
case SecondaryPHY:
|
||||||
phyIndex = 2;
|
phyIndex = 2;
|
||||||
linkIsUp = (notification->btNN & LINK_STATE_PHY2) == LINK_STATE_PHY2;
|
linkIsUp = (notification->btNN & LINK_STATE_PHY2)
|
||||||
|
== LINK_STATE_PHY2;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
case CurrentPHY:
|
case CurrentPHY:
|
||||||
|
|||||||
@@ -202,8 +202,8 @@ AX88178Device::SetupDevice(bool deviceReplugged)
|
|||||||
size_t actualLength = 0;
|
size_t actualLength = 0;
|
||||||
// get the "magic" word from EEPROM
|
// get the "magic" word from EEPROM
|
||||||
result = gUSBModule->send_request(fDevice,
|
result = gUSBModule->send_request(fDevice,
|
||||||
USB_REQTYPE_VENDOR | USB_REQTYPE_DEVICE_OUT,
|
USB_REQTYPE_VENDOR | USB_REQTYPE_DEVICE_OUT, WRITE_SROM_ENABLE,
|
||||||
WRITE_SROM_ENABLE, 0, 0, 0, 0, &actualLength);
|
0, 0, 0, 0, &actualLength);
|
||||||
|
|
||||||
if (result != B_OK) {
|
if (result != B_OK) {
|
||||||
TRACE_ALWAYS("Error of enabling SROM access:%#010x\n", result);
|
TRACE_ALWAYS("Error of enabling SROM access:%#010x\n", result);
|
||||||
@@ -212,9 +212,8 @@ AX88178Device::SetupDevice(bool deviceReplugged)
|
|||||||
|
|
||||||
uint16 eepromData = 0;
|
uint16 eepromData = 0;
|
||||||
status_t op_result = gUSBModule->send_request(fDevice,
|
status_t op_result = gUSBModule->send_request(fDevice,
|
||||||
USB_REQTYPE_VENDOR | USB_REQTYPE_DEVICE_IN,
|
USB_REQTYPE_VENDOR | USB_REQTYPE_DEVICE_IN, READ_SROM,
|
||||||
READ_SROM, 0x17, 0,
|
0x17, 0, sizeof(eepromData), &eepromData, &actualLength);
|
||||||
sizeof(eepromData), &eepromData, &actualLength);
|
|
||||||
|
|
||||||
if (op_result != B_OK) {
|
if (op_result != B_OK) {
|
||||||
TRACE_ALWAYS("Error of reading SROM data:%#010x\n", result);
|
TRACE_ALWAYS("Error of reading SROM data:%#010x\n", result);
|
||||||
@@ -222,13 +221,12 @@ AX88178Device::SetupDevice(bool deviceReplugged)
|
|||||||
|
|
||||||
if (actualLength != sizeof(eepromData)) {
|
if (actualLength != sizeof(eepromData)) {
|
||||||
TRACE_ALWAYS("Mismatch of reading SROM data."
|
TRACE_ALWAYS("Mismatch of reading SROM data."
|
||||||
"Read %d bytes instead of %d\n",
|
"Read %d bytes instead of %d\n", actualLength, sizeof(eepromData));
|
||||||
actualLength, sizeof(eepromData));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
result = gUSBModule->send_request(fDevice,
|
result = gUSBModule->send_request(fDevice,
|
||||||
USB_REQTYPE_VENDOR | USB_REQTYPE_DEVICE_OUT,
|
USB_REQTYPE_VENDOR | USB_REQTYPE_DEVICE_OUT, WRITE_SROM_DISABLE,
|
||||||
WRITE_SROM_DISABLE, 0, 0, 0, 0, &actualLength);
|
0, 0, 0, 0, &actualLength);
|
||||||
|
|
||||||
if (result != B_OK) {
|
if (result != B_OK) {
|
||||||
TRACE_ALWAYS("Error of disabling SROM access: %#010x\n", result);
|
TRACE_ALWAYS("Error of disabling SROM access: %#010x\n", result);
|
||||||
@@ -261,9 +259,8 @@ AX88178Device::SetupDevice(bool deviceReplugged)
|
|||||||
|
|
||||||
for (size_t i = from; i <= to; i++) {
|
for (size_t i = from; i <= to; i++) {
|
||||||
result = gUSBModule->send_request(fDevice,
|
result = gUSBModule->send_request(fDevice,
|
||||||
USB_REQTYPE_VENDOR | USB_REQTYPE_DEVICE_OUT,
|
USB_REQTYPE_VENDOR | USB_REQTYPE_DEVICE_OUT, WRITE_GPIOS,
|
||||||
WRITE_GPIOS, GPIOCommands[i].value,
|
GPIOCommands[i].value, 0, 0, 0, &actualLength);
|
||||||
0, 0, 0, &actualLength);
|
|
||||||
|
|
||||||
snooze(GPIOCommands[i].delay);
|
snooze(GPIOCommands[i].delay);
|
||||||
|
|
||||||
@@ -277,8 +274,8 @@ AX88178Device::SetupDevice(bool deviceReplugged)
|
|||||||
uint8 uSWReset = 0;
|
uint8 uSWReset = 0;
|
||||||
// finally a bit of exercises for SW reset register...
|
// finally a bit of exercises for SW reset register...
|
||||||
result = gUSBModule->send_request(fDevice,
|
result = gUSBModule->send_request(fDevice,
|
||||||
USB_REQTYPE_VENDOR | USB_REQTYPE_DEVICE_OUT,
|
USB_REQTYPE_VENDOR | USB_REQTYPE_DEVICE_OUT, WRITE_SOFT_RESET,
|
||||||
WRITE_SOFT_RESET, uSWReset, 0, 0, 0, &actualLength);
|
uSWReset, 0, 0, 0, &actualLength);
|
||||||
|
|
||||||
if (result != B_OK) {
|
if (result != B_OK) {
|
||||||
TRACE_ALWAYS("Error of SW reset to %#02x: %#010x\n", uSWReset, result);
|
TRACE_ALWAYS("Error of SW reset to %#02x: %#010x\n", uSWReset, result);
|
||||||
@@ -289,8 +286,8 @@ AX88178Device::SetupDevice(bool deviceReplugged)
|
|||||||
|
|
||||||
uSWReset = SW_RESET_PRL | SW_RESET_BIT6;
|
uSWReset = SW_RESET_PRL | SW_RESET_BIT6;
|
||||||
result = gUSBModule->send_request(fDevice,
|
result = gUSBModule->send_request(fDevice,
|
||||||
USB_REQTYPE_VENDOR | USB_REQTYPE_DEVICE_OUT,
|
USB_REQTYPE_VENDOR | USB_REQTYPE_DEVICE_OUT, WRITE_SOFT_RESET,
|
||||||
WRITE_SOFT_RESET, uSWReset, 0, 0, 0, &actualLength);
|
uSWReset, 0, 0, 0, &actualLength);
|
||||||
|
|
||||||
if (result != B_OK) {
|
if (result != B_OK) {
|
||||||
TRACE_ALWAYS("Error of SW reset to %#02x: %#010x\n", uSWReset, result);
|
TRACE_ALWAYS("Error of SW reset to %#02x: %#010x\n", uSWReset, result);
|
||||||
@@ -317,8 +314,8 @@ AX88178Device::StartDevice()
|
|||||||
{
|
{
|
||||||
size_t actualLength = 0;
|
size_t actualLength = 0;
|
||||||
status_t result = gUSBModule->send_request(fDevice,
|
status_t result = gUSBModule->send_request(fDevice,
|
||||||
USB_REQTYPE_VENDOR | USB_REQTYPE_DEVICE_OUT,
|
USB_REQTYPE_VENDOR | USB_REQTYPE_DEVICE_OUT, WRITE_IPGS,
|
||||||
WRITE_IPGS, 0, 0, sizeof(fIPG), fIPG, &actualLength);
|
0, 0, sizeof(fIPG), fIPG, &actualLength);
|
||||||
|
|
||||||
if (result != B_OK) {
|
if (result != B_OK) {
|
||||||
TRACE_ALWAYS("Error of writing IPGs:%#010x\n", result);
|
TRACE_ALWAYS("Error of writing IPGs:%#010x\n", result);
|
||||||
@@ -363,11 +360,13 @@ AX88178Device::OnNotify(uint32 actualLength)
|
|||||||
switch(fMII.ActivePHY()) {
|
switch(fMII.ActivePHY()) {
|
||||||
case PrimaryPHY:
|
case PrimaryPHY:
|
||||||
phyIndex = 1;
|
phyIndex = 1;
|
||||||
linkIsUp = (notification->btBB & LINK_STATE_PPLS) == LINK_STATE_PPLS;
|
linkIsUp = (notification->btBB & LINK_STATE_PPLS)
|
||||||
|
== LINK_STATE_PPLS;
|
||||||
break;
|
break;
|
||||||
case SecondaryPHY:
|
case SecondaryPHY:
|
||||||
phyIndex = 2;
|
phyIndex = 2;
|
||||||
linkIsUp = (notification->btBB & LINK_STATE_SPLS) == LINK_STATE_SPLS;
|
linkIsUp = (notification->btBB & LINK_STATE_SPLS)
|
||||||
|
== LINK_STATE_SPLS;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
case CurrentPHY:
|
case CurrentPHY:
|
||||||
@@ -396,9 +395,8 @@ AX88178Device::GetLinkState(ether_link_state *linkState)
|
|||||||
size_t actualLength = 0;
|
size_t actualLength = 0;
|
||||||
uint16 mediumStatus = 0;
|
uint16 mediumStatus = 0;
|
||||||
status_t result = gUSBModule->send_request(fDevice,
|
status_t result = gUSBModule->send_request(fDevice,
|
||||||
USB_REQTYPE_VENDOR | USB_REQTYPE_DEVICE_IN,
|
USB_REQTYPE_VENDOR | USB_REQTYPE_DEVICE_IN, READ_MEDIUM_STATUS,
|
||||||
READ_MEDIUM_STATUS, 0, 0, sizeof(mediumStatus),
|
0, 0, sizeof(mediumStatus), &mediumStatus, &actualLength);
|
||||||
&mediumStatus, &actualLength);
|
|
||||||
|
|
||||||
if (result != B_OK) {
|
if (result != B_OK) {
|
||||||
TRACE_ALWAYS("Error of reading medium status:%#010x.\n", result);
|
TRACE_ALWAYS("Error of reading medium status:%#010x.\n", result);
|
||||||
|
|||||||
@@ -290,11 +290,9 @@ AX88772Device::SetupDevice(bool deviceReplugged)
|
|||||||
|
|
||||||
size_t actualLength = 0;
|
size_t actualLength = 0;
|
||||||
result = gUSBModule->send_request(fDevice,
|
result = gUSBModule->send_request(fDevice,
|
||||||
USB_REQTYPE_VENDOR | USB_REQTYPE_DEVICE_OUT,
|
USB_REQTYPE_VENDOR | USB_REQTYPE_DEVICE_OUT, WRITE_MEDIUM_MODE,
|
||||||
WRITE_MEDIUM_MODE,
|
MEDIUM_STATE_FD | MEDIUM_STATE_BIT2 | MEDIUM_STATE_RFC
|
||||||
MEDIUM_STATE_FD | MEDIUM_STATE_BIT2 |
|
| MEDIUM_STATE_TFC | MEDIUM_STATE_RE | MEDIUM_STATE_PS_100,
|
||||||
MEDIUM_STATE_RFC| MEDIUM_STATE_TFC |
|
|
||||||
MEDIUM_STATE_RE | MEDIUM_STATE_PS_100,
|
|
||||||
0, 0, 0, &actualLength);
|
0, 0, 0, &actualLength);
|
||||||
|
|
||||||
if (result != B_OK) {
|
if (result != B_OK) {
|
||||||
@@ -313,8 +311,8 @@ AX88772Device::_SetupAX88772()
|
|||||||
// enable GPIO2 - magic from FreeBSD's if_axe
|
// enable GPIO2 - magic from FreeBSD's if_axe
|
||||||
uint16 GPIOs = GPIO_OO_2EN | GPIO_IO_2 | GPIO_RSE;
|
uint16 GPIOs = GPIO_OO_2EN | GPIO_IO_2 | GPIO_RSE;
|
||||||
status_t result = gUSBModule->send_request(fDevice,
|
status_t result = gUSBModule->send_request(fDevice,
|
||||||
USB_REQTYPE_VENDOR | USB_REQTYPE_DEVICE_OUT,
|
USB_REQTYPE_VENDOR | USB_REQTYPE_DEVICE_OUT, WRITE_GPIOS,
|
||||||
WRITE_GPIOS, GPIOs, 0, 0, 0, &actualLength);
|
GPIOs, 0, 0, 0, &actualLength);
|
||||||
|
|
||||||
if (result != B_OK) {
|
if (result != B_OK) {
|
||||||
TRACE_ALWAYS("Error of wrinting GPIOs: %#010x\n", result);
|
TRACE_ALWAYS("Error of wrinting GPIOs: %#010x\n", result);
|
||||||
@@ -323,8 +321,8 @@ AX88772Device::_SetupAX88772()
|
|||||||
|
|
||||||
// select PHY
|
// select PHY
|
||||||
bool useEmbeddedPHY = fMII.PHYID() == PHYIDEmbedded;
|
bool useEmbeddedPHY = fMII.PHYID() == PHYIDEmbedded;
|
||||||
uint16 selectPHY = useEmbeddedPHY ?
|
uint16 selectPHY = useEmbeddedPHY
|
||||||
SW_PHY_SEL_STATUS_INT : SW_PHY_SEL_STATUS_EXT;
|
? SW_PHY_SEL_STATUS_INT : SW_PHY_SEL_STATUS_EXT;
|
||||||
|
|
||||||
result = gUSBModule->send_request(fDevice,
|
result = gUSBModule->send_request(fDevice,
|
||||||
USB_REQTYPE_VENDOR | USB_REQTYPE_DEVICE_OUT,
|
USB_REQTYPE_VENDOR | USB_REQTYPE_DEVICE_OUT,
|
||||||
@@ -362,9 +360,8 @@ AX88772Device::_SetupAX88772()
|
|||||||
|
|
||||||
for (size_t i = from; i <= to; i++) {
|
for (size_t i = from; i <= to; i++) {
|
||||||
result = gUSBModule->send_request(fDevice,
|
result = gUSBModule->send_request(fDevice,
|
||||||
USB_REQTYPE_VENDOR | USB_REQTYPE_DEVICE_OUT,
|
USB_REQTYPE_VENDOR | USB_REQTYPE_DEVICE_OUT, WRITE_SOFT_RESET,
|
||||||
WRITE_SOFT_RESET, resetCommands[i].reset,
|
resetCommands[i].reset, 0, 0, 0, &actualLength);
|
||||||
0, 0, 0, &actualLength);
|
|
||||||
|
|
||||||
snooze(resetCommands[i].delay);
|
snooze(resetCommands[i].delay);
|
||||||
|
|
||||||
@@ -386,15 +383,15 @@ AX88772Device::_WakeupPHY()
|
|||||||
{
|
{
|
||||||
// select PHY
|
// select PHY
|
||||||
bool useEmbeddedPHY = fMII.PHYID() == PHYIDEmbedded;
|
bool useEmbeddedPHY = fMII.PHYID() == PHYIDEmbedded;
|
||||||
uint16 selectPHY = useEmbeddedPHY ?
|
uint16 selectPHY = useEmbeddedPHY
|
||||||
SW_PHY_SEL_STATUS_INT : SW_PHY_SEL_STATUS_EXT;
|
? SW_PHY_SEL_STATUS_INT : SW_PHY_SEL_STATUS_EXT;
|
||||||
|
|
||||||
selectPHY |= SW_PHY_SEL_STATUS_SS_MII | SW_PHY_SEL_STATUS_SS_ENB;
|
selectPHY |= SW_PHY_SEL_STATUS_SS_MII | SW_PHY_SEL_STATUS_SS_ENB;
|
||||||
|
|
||||||
size_t actualLength = 0;
|
size_t actualLength = 0;
|
||||||
status_t result = gUSBModule->send_request(fDevice,
|
status_t result = gUSBModule->send_request(fDevice,
|
||||||
USB_REQTYPE_VENDOR | USB_REQTYPE_DEVICE_OUT,
|
USB_REQTYPE_VENDOR | USB_REQTYPE_DEVICE_OUT, WRITE_PHY_SEL,
|
||||||
WRITE_PHY_SEL, selectPHY, 0, 0, 0, &actualLength);
|
selectPHY, 0, 0, 0, &actualLength);
|
||||||
snooze(31000);
|
snooze(31000);
|
||||||
|
|
||||||
TRACE("Selecting %s PHY[%#02x].\n",
|
TRACE("Selecting %s PHY[%#02x].\n",
|
||||||
@@ -417,9 +414,8 @@ AX88772Device::_WakeupPHY()
|
|||||||
|
|
||||||
for (size_t i = 0; i < _countof(resetCommands); i++) {
|
for (size_t i = 0; i < _countof(resetCommands); i++) {
|
||||||
result = gUSBModule->send_request(fDevice,
|
result = gUSBModule->send_request(fDevice,
|
||||||
USB_REQTYPE_VENDOR | USB_REQTYPE_DEVICE_OUT,
|
USB_REQTYPE_VENDOR | USB_REQTYPE_DEVICE_OUT, WRITE_SOFT_RESET,
|
||||||
WRITE_SOFT_RESET, resetCommands[i].reset,
|
resetCommands[i].reset, 0, 0, 0, &actualLength);
|
||||||
0, 0, 0, &actualLength);
|
|
||||||
|
|
||||||
snooze(resetCommands[i].delay);
|
snooze(resetCommands[i].delay);
|
||||||
|
|
||||||
@@ -440,8 +436,8 @@ AX88772Device::_SetupAX88772A()
|
|||||||
// Reload EEPROM
|
// Reload EEPROM
|
||||||
size_t actualLength = 0;
|
size_t actualLength = 0;
|
||||||
status_t result = gUSBModule->send_request(fDevice,
|
status_t result = gUSBModule->send_request(fDevice,
|
||||||
USB_REQTYPE_VENDOR | USB_REQTYPE_DEVICE_OUT,
|
USB_REQTYPE_VENDOR | USB_REQTYPE_DEVICE_OUT, WRITE_GPIOS,
|
||||||
WRITE_GPIOS, GPIO_RSE, 0, 0, 0, &actualLength);
|
GPIO_RSE, 0, 0, 0, &actualLength);
|
||||||
|
|
||||||
if (result != B_OK) {
|
if (result != B_OK) {
|
||||||
TRACE_ALWAYS("Error of reloading EEPROM: %#010x\n", result);
|
TRACE_ALWAYS("Error of reloading EEPROM: %#010x\n", result);
|
||||||
@@ -466,8 +462,8 @@ AX88772Device::_SetupAX88772B()
|
|||||||
// Reload EEPROM
|
// Reload EEPROM
|
||||||
size_t actualLength = 0;
|
size_t actualLength = 0;
|
||||||
status_t result = gUSBModule->send_request(fDevice,
|
status_t result = gUSBModule->send_request(fDevice,
|
||||||
USB_REQTYPE_VENDOR | USB_REQTYPE_DEVICE_OUT,
|
USB_REQTYPE_VENDOR | USB_REQTYPE_DEVICE_OUT, WRITE_GPIOS,
|
||||||
WRITE_GPIOS, GPIO_RSE, 0, 0, 0, &actualLength);
|
GPIO_RSE, 0, 0, 0, &actualLength);
|
||||||
|
|
||||||
if (result != B_OK) {
|
if (result != B_OK) {
|
||||||
TRACE_ALWAYS("Error of reloading EEPROM: %#010x\n", result);
|
TRACE_ALWAYS("Error of reloading EEPROM: %#010x\n", result);
|
||||||
@@ -491,8 +487,8 @@ AX88772Device::StartDevice()
|
|||||||
{
|
{
|
||||||
size_t actualLength = 0;
|
size_t actualLength = 0;
|
||||||
status_t result = gUSBModule->send_request(fDevice,
|
status_t result = gUSBModule->send_request(fDevice,
|
||||||
USB_REQTYPE_VENDOR | USB_REQTYPE_DEVICE_OUT,
|
USB_REQTYPE_VENDOR | USB_REQTYPE_DEVICE_OUT, WRITE_IPGS,
|
||||||
WRITE_IPGS, 0, 0, sizeof(fIPG), fIPG, &actualLength);
|
0, 0, sizeof(fIPG), fIPG, &actualLength);
|
||||||
|
|
||||||
if (result != B_OK) {
|
if (result != B_OK) {
|
||||||
TRACE_ALWAYS("Error of writing IPGs:%#010x\n", result);
|
TRACE_ALWAYS("Error of writing IPGs:%#010x\n", result);
|
||||||
@@ -560,11 +556,13 @@ AX88772Device::OnNotify(uint32 actualLength)
|
|||||||
switch(fMII.ActivePHY()) {
|
switch(fMII.ActivePHY()) {
|
||||||
case PrimaryPHY:
|
case PrimaryPHY:
|
||||||
phyIndex = 1;
|
phyIndex = 1;
|
||||||
linkIsUp = (notification->btBB & LINK_STATE_PPLS) == LINK_STATE_PPLS;
|
linkIsUp = (notification->btBB & LINK_STATE_PPLS)
|
||||||
|
== LINK_STATE_PPLS;
|
||||||
break;
|
break;
|
||||||
case SecondaryPHY:
|
case SecondaryPHY:
|
||||||
phyIndex = 2;
|
phyIndex = 2;
|
||||||
linkIsUp = (notification->btBB & LINK_STATE_SPLS) == LINK_STATE_SPLS;
|
linkIsUp = (notification->btBB & LINK_STATE_SPLS)
|
||||||
|
== LINK_STATE_SPLS;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
case CurrentPHY:
|
case CurrentPHY:
|
||||||
@@ -593,9 +591,8 @@ AX88772Device::GetLinkState(ether_link_state *linkState)
|
|||||||
size_t actualLength = 0;
|
size_t actualLength = 0;
|
||||||
uint16 mediumStatus = 0;
|
uint16 mediumStatus = 0;
|
||||||
status_t result = gUSBModule->send_request(fDevice,
|
status_t result = gUSBModule->send_request(fDevice,
|
||||||
USB_REQTYPE_VENDOR | USB_REQTYPE_DEVICE_IN,
|
USB_REQTYPE_VENDOR | USB_REQTYPE_DEVICE_IN, READ_MEDIUM_STATUS,
|
||||||
READ_MEDIUM_STATUS, 0, 0, sizeof(mediumStatus),
|
0, 0, sizeof(mediumStatus), &mediumStatus, &actualLength);
|
||||||
&mediumStatus, &actualLength);
|
|
||||||
|
|
||||||
if (result != B_OK) {
|
if (result != B_OK) {
|
||||||
TRACE_ALWAYS("Error of reading medium status:%#010x.\n", result);
|
TRACE_ALWAYS("Error of reading medium status:%#010x.\n", result);
|
||||||
@@ -604,8 +601,8 @@ AX88772Device::GetLinkState(ether_link_state *linkState)
|
|||||||
|
|
||||||
if (actualLength != sizeof(mediumStatus)) {
|
if (actualLength != sizeof(mediumStatus)) {
|
||||||
TRACE_ALWAYS("Mismatch of reading medium status."
|
TRACE_ALWAYS("Mismatch of reading medium status."
|
||||||
"Read %d bytes instead of %d\n",
|
"Read %d bytes instead of %d\n", actualLength,
|
||||||
actualLength, sizeof(mediumStatus));
|
sizeof(mediumStatus));
|
||||||
}
|
}
|
||||||
|
|
||||||
TRACE_FLOW("Medium status is %#04x\n", mediumStatus);
|
TRACE_FLOW("Medium status is %#04x\n", mediumStatus);
|
||||||
|
|||||||
Reference in New Issue
Block a user