[haiku-commits] r40846 - haiku/trunk/src/add-ons/kernel/drivers/network/wimax/usb_beceemwmx

  • From: kallisti5@xxxxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Sun, 6 Mar 2011 16:54:38 +0100 (CET)

Author: kallisti5
Date: 2011-03-06 16:54:37 +0100 (Sun, 06 Mar 2011)
New Revision: 40846
Changeset: http://dev.haiku-os.org/changeset/40846

Modified:
   
haiku/trunk/src/add-ons/kernel/drivers/network/wimax/usb_beceemwmx/BeceemCPU.cpp
   
haiku/trunk/src/add-ons/kernel/drivers/network/wimax/usb_beceemwmx/BeceemCPU.h
Log:
BeceemCPU style cleanup, little functional change

Modified: 
haiku/trunk/src/add-ons/kernel/drivers/network/wimax/usb_beceemwmx/BeceemCPU.cpp
===================================================================
--- 
haiku/trunk/src/add-ons/kernel/drivers/network/wimax/usb_beceemwmx/BeceemCPU.cpp
    2011-03-06 15:38:20 UTC (rev 40845)
+++ 
haiku/trunk/src/add-ons/kernel/drivers/network/wimax/usb_beceemwmx/BeceemCPU.cpp
    2011-03-06 15:54:37 UTC (rev 40846)
@@ -9,10 +9,10 @@
  *
  */
 
-#include "Settings.h"
+
 #include "BeceemCPU.h"
-
 #include "Driver.h"
+#include "Settings.h"
 
 
 BeceemCPU::BeceemCPU()
@@ -25,7 +25,7 @@
 BeceemCPU::CPUInit(WIMAX_DEVICE* swmxdevice)
 {
        TRACE("Debug: Init CPU handler\n");
-       pwmxdevice = swmxdevice;
+       fWmxDevice = swmxdevice;
        return B_OK;
 }
 
@@ -33,24 +33,25 @@
 status_t
 BeceemCPU::CPURun()
 {
-       unsigned int clkReg = 0;
+       unsigned int clockRegister = 0;
 
-       if (BizarroReadRegister(CLOCK_RESET_CNTRL_REG_1, sizeof(clkReg), 
&clkReg)
-                       != B_OK) {
-
+       // Read current clock register contents
+       if (BizarroReadRegister(CLOCK_RESET_CNTRL_REG_1,
+               sizeof(clockRegister), &clockRegister) != B_OK) {
                TRACE_ALWAYS("Error: Read of clock reset reg failure\n");
                return B_ERROR;
        }
 
-       if (pwmxdevice->CPUFlashBoot) {
-               clkReg &= (~(1<<30));
+       // Adjust clock register contents to start cpu
+       if (fWmxDevice->CPUFlashBoot) {
+               clockRegister &= (~(1<<30));
        } else {
-               clkReg |= (1<<30);
+               clockRegister |= (1<<30);
        }
 
-       if (BizarroWriteRegister(CLOCK_RESET_CNTRL_REG_1, sizeof(clkReg), 
&clkReg)
-                       != B_OK) {
-
+       // Write new clock register contents
+       if (BizarroWriteRegister(CLOCK_RESET_CNTRL_REG_1,
+               sizeof(clockRegister), &clockRegister) != B_OK) {
                TRACE_ALWAYS("Error: Write of clock reset reg failure\n");
                return B_ERROR;
        }
@@ -62,78 +63,84 @@
 status_t
 BeceemCPU::CPUReset()
 {
-       status_t        retval = B_OK;
        unsigned int value = 0;
        unsigned int uiResetValue = 0;
 
-       if (pwmxdevice->deviceChipID >= T3LPB)
+       if (fWmxDevice->deviceChipID >= T3LPB)
        {
                BizarroReadRegister(SYS_CFG, sizeof(value), &value);
                BizarroReadRegister(SYS_CFG, sizeof(value), &value);
                        // SYS_CFG register is write protected hence for 
modifying
                        // this reg value, it should be read twice before 
writing.
 
-               value = value | (pwmxdevice->syscfgBefFw & 0x00000060) ;
+               value = value | (fWmxDevice->syscfgBefFw & 0x00000060) ;
                        // making bit[6...5] same as was before f/w download. 
this
                        // setting forces the h/w to re-populated the SP RAM 
area
                        // with the string descriptor .
 
-               BizarroWriteRegister(SYS_CFG, sizeof(value), &value);
+               if (BizarroWriteRegister(SYS_CFG, sizeof(value), &value) != 
B_OK) {
+                       TRACE_ALWAYS("Error: unable to write SYS_CFG during 
reset\n");
+                       return B_ERROR;
+               }
        }
 
        /* Reset the UMA-B Device */
-       if (pwmxdevice->deviceChipID >= T3LPB)
+       if (fWmxDevice->deviceChipID >= T3LPB)
        {
-               // TRACE("Debug: Resetting UMA-B\n");
-               // retval = usb_reset_device(psIntfAdapter->udev);
-
-               if (retval != B_OK)
+               // Reset UMA-B
+               // TODO : USB reset needs implimented
+               /*
+               if (usb_reset_device(psIntfAdapter->udev) != B_OK)
                {
-                       TRACE_ALWAYS("Error: Reset failed\n");
-                       goto err_exit;
+                       TRACE_ALWAYS("Error: USB Reset failed\n");
+                       retrun B_ERROR;
                }
-               if (pwmxdevice->deviceChipID == BCS220_2 ||
-                       pwmxdevice->deviceChipID == BCS220_2BC ||
-                       pwmxdevice->deviceChipID == BCS250_BC ||
-                       pwmxdevice->deviceChipID == BCS220_3)
+               */
+
+               if (fWmxDevice->deviceChipID == BCS220_2 ||
+                       fWmxDevice->deviceChipID == BCS220_2BC ||
+                       fWmxDevice->deviceChipID == BCS250_BC ||
+                       fWmxDevice->deviceChipID == BCS220_3)
                {
-                       retval = BizarroReadRegister(HPM_CONFIG_LDO145,
-                                               sizeof(value), &value);
-
-                       if ( retval < 0)
-                       {
-                               TRACE_ALWAYS("Error: read failed with status: 
%d\n", retval);
-                               goto err_exit;
+                       if (BizarroReadRegister(HPM_CONFIG_LDO145,
+                               sizeof(value), &value) != B_OK) {
+                               TRACE_ALWAYS("Error: USB read failed during 
reset\n");
+                               return B_ERROR;
                        }
-                       // setting 0th bit
+                       // set 0th bit
                        value |= (1<<0);
-                       retval = BizarroWriteRegister(HPM_CONFIG_LDO145,
-                               sizeof(value), &value);
 
-                       if ( retval < 0)
-                       {
-                               TRACE_ALWAYS("Error: write failed with status: 
%d\n", retval);
-                               goto err_exit;
+                       if (BizarroWriteRegister(HPM_CONFIG_LDO145,
+                               sizeof(value), &value) != B_OK) {
+                               TRACE_ALWAYS("Error: USB write failed during 
reset\n");
+                               return B_ERROR;
                        }
                }
 
        }
        // TODO : ELSE OLDER CHIP ID's < T3LP see Misc.c:1048
 
-       if (pwmxdevice->CPUFlashBoot)
+       if (fWmxDevice->CPUFlashBoot)
        {
                // In flash boot mode MIPS state register has reverse polarity.
                // So just or with setting bit 30.
                // Make the MIPS in Reset state.
-               BizarroReadRegister(CLOCK_RESET_CNTRL_REG_1, 
sizeof(uiResetValue),
-                       &uiResetValue);
+               if (BizarroReadRegister(CLOCK_RESET_CNTRL_REG_1,
+                       sizeof(uiResetValue), &uiResetValue) != B_OK) {
+                       TRACE_ALWAYS("Error: read failed during FlashBoot 
device reset\n");
+                       return B_ERROR;
+               }
+               // set 30th bit
+               uiResetValue |=(1<<30);
 
-               uiResetValue |=(1<<30);
-               BizarroWriteRegister(CLOCK_RESET_CNTRL_REG_1, 
sizeof(uiResetValue),
-                       &uiResetValue);
+               if (BizarroWriteRegister(CLOCK_RESET_CNTRL_REG_1,
+                       sizeof(uiResetValue), &uiResetValue) != B_OK) {
+                       TRACE_ALWAYS("Error: write failed during FlashBoot 
device reset\n");
+                       return B_ERROR;
+               }
        }
 
-       if (pwmxdevice->deviceChipID >= T3LPB)
+       if (fWmxDevice->deviceChipID >= T3LPB)
        {
                uiResetValue = 0;
                        // WA for SYSConfig Issue.
@@ -144,14 +151,23 @@
                        BizarroReadRegister(SYS_CFG, sizeof(uiResetValue), 
&uiResetValue);
                                // Read SYSCFG Twice to make it writable.
                        uiResetValue &= (~(1<<4));
-                       BizarroWriteRegister(SYS_CFG, sizeof(uiResetValue), 
&uiResetValue);
+
+                       if (BizarroWriteRegister(SYS_CFG,
+                               sizeof(uiResetValue), &uiResetValue) != B_OK) {
+                               TRACE_ALWAYS("Error: unable to write SYS_CFG 
during reset\n");
+                               return B_ERROR;
+                       }
                }
 
        }
+
        uiResetValue = 0;
-       BizarroWriteRegister(0x0f01186c, sizeof(uiResetValue), &uiResetValue);
+       if (BizarroWriteRegister(0x0f01186c,
+               sizeof(uiResetValue), &uiResetValue) != B_OK) {
+               TRACE_ALWAYS("Error: unable to write reset to 0x0f01186c\n");
+               return B_ERROR;
+       }
 
-       err_exit :
-               return retval;
+       return B_OK;
 }
 

Modified: 
haiku/trunk/src/add-ons/kernel/drivers/network/wimax/usb_beceemwmx/BeceemCPU.h
===================================================================
--- 
haiku/trunk/src/add-ons/kernel/drivers/network/wimax/usb_beceemwmx/BeceemCPU.h  
    2011-03-06 15:38:20 UTC (rev 40845)
+++ 
haiku/trunk/src/add-ons/kernel/drivers/network/wimax/usb_beceemwmx/BeceemCPU.h  
    2011-03-06 15:54:37 UTC (rev 40846)
@@ -5,32 +5,40 @@
  *
  *     Description: Wrangle Beceem CPU control calls
  */
-
-#define CLOCK_RESET_CNTRL_REG_1 0x0F00000C
-
 #ifndef _USB_BECEEM_CPU_H_
 #define _USB_BECEEM_CPU_H_
 
+
 #include <ByteOrder.h>
 #include "DeviceStruct.h"
 
+
+#define CLOCK_RESET_CNTRL_REG_1 0x0F00000C
+
+
 class BeceemCPU
 {
 
 public:
-                    BeceemCPU();
-               status_t        CPUInit(WIMAX_DEVICE* swmxdevice);
-        status_t    CPURun();
-        status_t    CPUReset();
+                                                               BeceemCPU();
+                       status_t                        CPUInit(WIMAX_DEVICE* 
swmxdevice);
+                       status_t                        CPURun();
+                       status_t                        CPUReset();
 
 // yuck.  These are in a parent class
-virtual status_t    ReadRegister(unsigned int reg, size_t size, uint32_t* 
buffer){ return NULL; };
-virtual status_t    WriteRegister(unsigned int reg, size_t size, uint32_t* 
buffer){ return NULL; };
-virtual status_t    BizarroReadRegister(unsigned int reg, size_t size, 
uint32_t* buffer){ return NULL; };
-virtual status_t    BizarroWriteRegister(unsigned int reg, size_t size, 
uint32_t* buffer){ return NULL; };
+       virtual status_t                        ReadRegister(unsigned int reg, 
size_t size,
+                                                                       
uint32_t* buffer) { return NULL; };
+       virtual status_t                        WriteRegister(unsigned int reg, 
size_t size,
+                                                                       
uint32_t* buffer) { return NULL; };
+       virtual status_t                        BizarroReadRegister(unsigned 
int reg,
+                                                                       size_t 
size, uint32_t* buffer)
+                                                                               
{ return NULL; };
+       virtual status_t                        BizarroWriteRegister(unsigned 
int reg,
+                                                                       size_t 
size, uint32_t* buffer)
+                                                                               
{ return NULL; };
 
 private:
-               WIMAX_DEVICE*   pwmxdevice;
+                       WIMAX_DEVICE*           fWmxDevice;
 
 };
 #endif // _USB_BECEEM_CPU_H_


Other related posts:

  • » [haiku-commits] r40846 - haiku/trunk/src/add-ons/kernel/drivers/network/wimax/usb_beceemwmx - kallisti5