Changeset ffcc5776 in mainline


Ignore:
Timestamp:
2012-02-23T06:00:07Z (12 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
bfc5c9dd
Parents:
70922c2
Message:

ohci: Consider endian difference when accessing OHCI registers.

HC initialization works.
Root hub works.

Turn off work queues until memory structure endian is fixed.

Location:
uspace/drv/bus/usb/ohci
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/bus/usb/ohci/hc.c

    r70922c2 rffcc5776  
    5050{
    5151        { .cmd = CMD_MEM_READ_32, .dstarg = 1, .addr = NULL /*filled later*/ },
    52         { .cmd = CMD_BTEST, .srcarg = 1, .dstarg = 2, .value = OHCI_USED_INTERRUPTS },
     52        { .cmd = CMD_BTEST, .srcarg = 1, .dstarg = 2, .value = 0 /*filled later*/},
    5353        { .cmd = CMD_PREDICATE, .srcarg = 2, .value = 2 },
    5454        { .cmd = CMD_MEM_WRITE_A_32, .srcarg = 1, .addr = NULL /*filled later*/ },
     
    112112        void *address = (void*)&registers->interrupt_status;
    113113        cmds[0].addr = address;
     114        cmds[1].value = OHCI_USED_INTERRUPTS;
    114115        cmds[3].addr = address;
    115116        return EOK;
     
    308309        /* Check for root hub communication */
    309310        if (batch->ep->address == instance->rh.address) {
     311                usb_log_debug("OHCI root hub request.\n");
    310312                rh_request(&instance->rh, batch);
    311313                return EOK;
     
    511513
    512514        /* Enable queues */
    513         instance->registers->control |= (C_PLE | C_IE | C_CLE | C_BLE);
    514         usb_log_debug2("All queues enabled(%x).\n",
    515             instance->registers->control);
     515//      instance->registers->control |= (C_PLE | C_IE | C_CLE | C_BLE);
     516//      usb_log_debug2("All queues enabled(%x).\n",
     517//          instance->registers->control);
    516518
    517519        /* Enable interrupts */
     
    522524
    523525        /* Set periodic start to 90% */
    524         uint32_t frame_length = ((fm_interval >> FMI_FI_SHIFT) & FMI_FI_MASK);
    525         instance->registers->periodic_start = (frame_length / 10) * 9;
     526        const uint32_t frame_length = FMI_FL_GET(fm_interval);
     527        PS_SET(instance->registers->periodic_start, (frame_length / 10) * 9);
    526528        usb_log_debug2("All periodic start set to: %x(%u - 90%% of %d).\n",
    527             instance->registers->periodic_start,
    528             instance->registers->periodic_start, frame_length);
     529            PS_GET(instance->registers->periodic_start),
     530            PS_GET(instance->registers->periodic_start), frame_length);
    529531
    530532        C_HCFS_SET(instance->registers->control, C_HCFS_OPERATIONAL);
  • uspace/drv/bus/usb/ohci/main.c

    r70922c2 rffcc5776  
    8383int main(int argc, char *argv[])
    8484{
    85         usb_log_enable(USB_LOG_LEVEL_DEFAULT, NAME);
     85        sleep(5);
     86        usb_log_enable(USB_LOG_LEVEL_DEBUG2, NAME);
    8687        return ddf_driver_main(&ohci_driver);
    8788}
  • uspace/drv/bus/usb/ohci/ohci_regs.h

    r70922c2 rffcc5776  
    3535#define DRV_OHCI_OHCI_REGS_H
    3636#include <sys/types.h>
     37#include <byteorder.h>
     38
     39
     40/* assume OHCI regs are le */
     41#define host2ohci_reg(value) host2uint32_t_le(value)
     42#define ohci_reg2host(value) uint32_t_le2host(value)
    3743
    3844#define LEGACY_REGS_OFFSET 0x100
     
    4147typedef struct ohci_regs {
    4248        const ioport32_t revision;
    43 #define R_REVISION_MASK (0x3f)
    44 #define R_REVISION_SHIFT (0)
    45 #define R_LEGACY_FLAG   (0x80)
     49#define R_REVISION_(reg) (ohci_reg2host(reg) & 0x3f)
     50#define R_LEGACY_FLAG   host2ohci_reg(0x80)
    4651
    4752        ioport32_t control;
    48 #define C_CBSR_MASK (0x3) /* Control-bulk service ratio */
     53/* Control-bulk service ratio */
    4954#define C_CBSR_1_1  (0x0)
    5055#define C_CBSR_1_2  (0x1)
    5156#define C_CBSR_1_3  (0x2)
    5257#define C_CBSR_1_4  (0x3)
    53 #define C_CBSR_SHIFT (0)
    54 
    55 #define C_PLE (1 << 2)   /* Periodic list enable */
    56 #define C_IE  (1 << 3)   /* Isochronous enable */
    57 #define C_CLE (1 << 4)   /* Control list enable */
    58 #define C_BLE (1 << 5)   /* Bulk list enable */
    59 
    60 #define C_HCFS_MASK        (0x3) /* Host controller functional state */
     58#define C_CBSR_GET(reg) (ohci_reg2host(reg) & 0x3)
     59#define C_CBSR_SET(reg, value) \
     60do { \
     61    reg = (reg & host2ohci_reg(~0x3) | host2ohci_reg(value & 0x3)) \
     62} while (0)
     63
     64#define C_PLE host2ohci_reg(1 << 2)   /* Periodic list enable */
     65#define C_IE  host2ohci_reg(1 << 3)   /* Isochronous enable */
     66#define C_CLE host2ohci_reg(1 << 4)   /* Control list enable */
     67#define C_BLE host2ohci_reg(1 << 5)   /* Bulk list enable */
     68
     69/* Host controller functional state */
    6170#define C_HCFS_RESET       (0x0)
    6271#define C_HCFS_RESUME      (0x1)
    6372#define C_HCFS_OPERATIONAL (0x2)
    6473#define C_HCFS_SUSPEND     (0x3)
    65 #define C_HCFS_SHIFT       (6)
    66 
    67 #define C_HCFS_GET(reg) \
    68         ((reg >> C_HCFS_SHIFT) & C_HCFS_MASK)
    69 #define C_HCFS_SET(reg, hcfs_state) \
     74#define C_HCFS_GET(reg) ((ohci_reg2host(reg) >> 6) & 0x3)
     75#define C_HCFS_SET(reg, value) \
    7076do { \
    71         reg = (reg & ~(C_HCFS_MASK << C_HCFS_SHIFT)) \
    72             | ((hcfs_state & C_HCFS_MASK) << C_HCFS_SHIFT); \
     77    reg = (reg & host2ohci_reg(~(0x3 << 6))) \
     78        | host2ohci_reg((value & 0x3) << 6); \
    7379} while (0)
    7480
    75 
    76 #define C_IR  (1 << 8)   /* Interrupt routing, make sure it's 0 */
    77 #define C_RWC (1 << 9)   /* Remote wakeup connected, host specific */
    78 #define C_RWE (1 << 10)  /* Remote wakeup enable */
     81#define C_IR  host2ohci_reg(1 << 8)  /* Interrupt routing, make sure it's 0 */
     82#define C_RWC host2ohci_reg(1 << 9)  /* Remote wakeup connected, host specific */
     83#define C_RWE host2ohci_reg(1 << 10)  /* Remote wakeup enable */
    7984
    8085        ioport32_t command_status;
    81 #define CS_HCR (1 << 0)   /* Host controller reset */
    82 #define CS_CLF (1 << 1)   /* Control list filled */
    83 #define CS_BLF (1 << 2)   /* Bulk list filled */
    84 #define CS_OCR (1 << 3)   /* Ownership change request */
     86#define CS_HCR host2ohci_reg(1 << 0)   /* Host controller reset */
     87#define CS_CLF host2ohci_reg(1 << 1)   /* Control list filled */
     88#define CS_BLF host2ohci_reg(1 << 2)   /* Bulk list filled */
     89#define CS_OCR host2ohci_reg(1 << 3)   /* Ownership change request */
     90#if 0
    8591#define CS_SOC_MASK (0x3) /* Scheduling overrun count */
    8692#define CS_SOC_SHIFT (16)
     93#endif
    8794
    8895        /** Interupt enable/disable/status,
     
    93100        ioport32_t interrupt_enable;
    94101        ioport32_t interrupt_disable;
    95 #define I_SO   (1 << 0)   /* Scheduling overrun */
    96 #define I_WDH  (1 << 1)   /* Done head write-back */
    97 #define I_SF   (1 << 2)   /* Start of frame */
    98 #define I_RD   (1 << 3)   /* Resume detect */
    99 #define I_UE   (1 << 4)   /* Unrecoverable error */
    100 #define I_FNO  (1 << 5)   /* Frame number overflow */
    101 #define I_RHSC (1 << 6)   /* Root hub status change */
    102 #define I_OC   (1 << 30)  /* Ownership change */
    103 #define I_MI   (1 << 31)  /* Master interrupt (all/any interrupts) */
     102#define I_SO   host2ohci_reg(1 << 0)   /* Scheduling overrun */
     103#define I_WDH  host2ohci_reg(1 << 1)   /* Done head write-back */
     104#define I_SF   host2ohci_reg(1 << 2)   /* Start of frame */
     105#define I_RD   host2ohci_reg(1 << 3)   /* Resume detect */
     106#define I_UE   host2ohci_reg(1 << 4)   /* Unrecoverable error */
     107#define I_FNO  host2ohci_reg(1 << 5)   /* Frame number overflow */
     108#define I_RHSC host2ohci_reg(1 << 6)   /* Root hub status change */
     109#define I_OC   host2ohci_reg(1 << 30)  /* Ownership change */
     110#define I_MI   host2ohci_reg(1 << 31)  /* Master interrupt (any/all) */
    104111
    105112        /** HCCA pointer (see hw_struct hcca.h) */
     
    127134        /** Frame time and max packet size for all transfers */
    128135        ioport32_t fm_interval;
     136#define FMI_FL_GET(reg) (ohci_reg2host(reg) & 0x3fff)
     137#if 0   
    129138#define FMI_FI_MASK (0x3fff) /* Frame interval in bit times (should be 11999)*/
    130139#define FMI_FI_SHIFT (0)
     
    132141#define FMI_FSMPS_SHIFT (16)
    133142#define FMI_TOGGLE_FLAG (1 << 31)
     143#endif
    134144
    135145        /** Bit times remaining in current frame */
    136146        const ioport32_t fm_remaining;
     147#define FMR_R_GET(reg) (ohci_reg2host(reg) & 0x3fff)
     148#if 0   
    137149#define FMR_FR_MASK FMI_FI_MASK
    138150#define FMR_FR_SHIFT FMI_FI_SHIFT
    139151#define FMR_TOGGLE_FLAG FMI_TOGGLE_FLAG
    140 
     152#endif
    141153        /** Frame number */
    142154        const ioport32_t fm_number;
     155#if 0
    143156#define FMN_NUMBER_MASK (0xffff)
    144 
     157#endif
    145158        /** Remaining bit time in frame to start periodic transfers */
    146159        ioport32_t periodic_start;
    147 #define PS_PS_MASK (0x3fff) /* bit time when periodic get priority (0x3e67) */
     160#define PS_GET(reg) (ohci_reg2host(reg) & 0x3fff)
     161#define PS_SET(reg, value) \
     162do { \
     163        reg = (reg & host2ohci_reg(~0x3fff)) | host2ohci_reg(value & 0x3fff); \
     164} while (0)
    148165
    149166        /** Threshold for starting LS transaction */
    150167        ioport32_t ls_threshold;
    151 #define LST_LST_MASK (0x7fff)
     168//#define LST_LST_MASK (0x7fff)
    152169
    153170        /** The first root hub control register */
    154171        ioport32_t rh_desc_a;
    155 #define RHDA_NDS_MASK (0xff) /* Number of downstream ports, max 15 */
    156 #define RHDA_NDS_SHIFT (0)
    157 #define RHDA_PSM_FLAG  (1 << 8)  /* Power switching mode: 0-global, 1-per port*/
    158 #define RHDA_NPS_FLAG  (1 << 9)  /* No power switch: 1-power on, 0-use PSM*/
    159 #define RHDA_DT_FLAG   (1 << 10) /* 1-Compound device, must be 0 */
    160 #define RHDA_OCPM_FLAG (1 << 11) /* Over-current mode: 0-global, 1-per port */
    161 #define RHDA_NOCP_FLAG (1 << 12) /* OC control: 0-use OCPM, 1-OC off */
    162 #define RHDA_POTPGT_MASK (0xff)  /* Power on to power good time */
    163 #define RHDA_POTPGT_SHIFT (24)
     172/** Number of downstream ports, max 15 */
     173#define RHDA_NDS(reg) (ohci_reg2host(reg) & 0xff)
     174/** Power switching mode: 0-global, 1-per port*/
     175#define RHDA_PSM_FLAG  host2ohci_reg(1 << 8)
     176/** No power switch: 1-power on, 0-use PSM*/
     177#define RHDA_NPS_FLAG  host2ohci_reg(1 << 9)
     178/** 1-Compound device, must be 0 */
     179#define RHDA_DT_FLAG   host2ohci_reg(1 << 10)
     180/** Over-current mode: 0-global, 1-per port */
     181#define RHDA_OCPM_FLAG host2ohci_reg(1 << 11)
     182/** OC control: 0-use OCPM, 1-OC off */
     183#define RHDA_NOCP_FLAG host2ohci_reg(1 << 12)
     184/** Power on to power good time */
     185#define RHDA_POTPGT(reg) (ohci_reg2host(reg) >> 24)
    164186
    165187        /** The other root hub control register */
    166188        ioport32_t rh_desc_b;
    167 #define RHDB_DR_MASK (0xffff) /* Device removable mask */
    168 #define RHDB_DR_SHIFT (0)
    169 #define RHDB_PCC_MASK (0xffff) /* Power control mask */
    170 #define RHDB_PCC_SHIFT (16)
    171 
     189/** Device removable mask */
     190#define RHDB_DR_READ(reg) (ohci_reg2host(reg) & 0xffff)
     191#define RHDB_DR_WRITE(val) host2ohci_reg(val & 0xffff)
     192/** Power control mask */
     193#define RHDB_PCC_READ(reg) (ohci_reg2host(reg) >> 16)
     194#define RHDB_PCC_WRITE(val) host2ohci_reg(val << 16)
    172195/* Port device removable status */
    173 #define RHDB_DR_FLAG(port) (((1 << port) & RHDB_DR_MASK) << RHDB_DR_SHIFT)
     196#define RHDB_DR_FLAG(port) \
     197    host2ohci_reg(((1 << port) & RHDB_DR_MASK) << RHDB_DR_SHIFT)
    174198/* Port power control status: 1-per port power control, 0-global power switch */
    175 #define RHDB_PPC_FLAG(port) (((1 << port) & RHDB_DR_MASK) << RHDB_DR_SHIFT)
     199#define RHDB_PPC_FLAG(port) \
     200    host2ohci_reg(((1 << port) & RHDB_DR_MASK) << RHDB_DR_SHIFT)
    176201
    177202        /** Root hub status register */
    178203        ioport32_t rh_status;
    179 #define RHS_LPS_FLAG  (1 <<  0)/* read: 0,
    180                                 * write: 0-no effect,
    181                                 *        1-turn off port power for ports
    182                                 *        specified in PPCM(RHDB), or all ports,
    183                                 *        if power is set globally */
     204/* read: 0,
     205 * write: 0-no effect,
     206 *        1-turn off port power for ports
     207 *        specified in PPCM(RHDB), or all ports,
     208 *        if power is set globally */
     209#define RHS_LPS_FLAG  host2ohci_reg(1 <<  0)
    184210#define RHS_CLEAR_GLOBAL_POWER RHS_LPS_FLAG /* synonym for the above */
    185 #define RHS_OCI_FLAG  (1 <<  1)/* Over-current indicator, if per-port: 0 */
    186 #define RHS_DRWE_FLAG (1 << 15)/* read: 0-connect status change does not wake HC
    187                                 *       1-connect status change wakes HC
    188                                 * write: 1-set DRWE, 0-no effect */
     211/** Over-current indicator, if per-port: 0 */
     212#define RHS_OCI_FLAG  host2ohci_reg(1 <<  1)
     213
     214/* read: 0-connect status change does not wake HC
     215 *       1-connect status change wakes HC
     216 * write: 1-set DRWE, 0-no effect */
     217#define RHS_DRWE_FLAG host2ohci_reg(1 << 15)
    189218#define RHS_SET_DRWE RHS_DRWE_FLAG
    190 #define RHS_LPSC_FLAG (1 << 16)/* read: 0,
    191                                 * write: 0-no effect
    192                                 *        1-turn on port power for ports
    193                                 *        specified in PPCM(RHDB), or all ports,
    194                                 *        if power is set globally */
     219/* read: 0,
     220 * write: 0-no effect
     221 *        1-turn on port power for ports
     222 *        specified in PPCM(RHDB), or all ports,
     223 *        if power is set globally */
     224#define RHS_LPSC_FLAG host2ohci_reg(1 << 16)
    195225#define RHS_SET_GLOBAL_POWER RHS_LPSC_FLAG /* synonym for the above */
    196 #define RHS_OCIC_FLAG (1 << 17)/* Over-current indicator change   */
    197 #define RHS_CLEAR_DRWE (1 << 31)
     226/** Over-current change indicator*/
     227#define RHS_OCIC_FLAG host2ohci_reg(1 << 17)
     228#define RHS_CLEAR_DRWE host2ohci_reg(1 << 31)
    198229
    199230        /** Root hub per port status */
    200231        ioport32_t rh_port_status[];
    201 #define RHPS_CCS_FLAG (1 << 0) /* r: current connect status,
    202                                 * w: 1-clear port enable, 0-nothing */
     232#define RHPS_CCS_FLAG host2ohci_reg(1 << 0) /* r: current connect status,
     233                                               * w: 1-clear port enable, 0-N/S*/
    203234#define RHPS_CLEAR_PORT_ENABLE RHPS_CCS_FLAG
    204 #define RHPS_PES_FLAG (1 << 1) /* r: port enable status
    205                                 * w: 1-set port enable, 0-nothing */
     235#define RHPS_PES_FLAG host2ohci_reg(1 << 1) /* r: port enable status
     236                                              * w: 1-set port enable, 0-N/S */
    206237#define RHPS_SET_PORT_ENABLE RHPS_PES_FLAG
    207 #define RHPS_PSS_FLAG (1 << 2) /* r: port suspend status
    208                                 * w: 1-set port suspend, 0-nothing */
     238#define RHPS_PSS_FLAG host2ohci_reg(1 << 2) /* r: port suspend status
     239                                               * w: 1-set port suspend, 0-N/S */
    209240#define RHPS_SET_PORT_SUSPEND RHPS_PSS_FLAG
    210 #define RHPS_POCI_FLAG (1 << 3) /* r: port over-current (if reports are per-port
    211                                  * w: 1-clear port suspend (start resume
    212                                  *      if suspened)
    213                                  *    0-nothing */
     241#define RHPS_POCI_FLAG host2ohci_reg(1 << 3) /* r: port over-current
     242                                                * (if reports are per-port
     243                                                * w: 1-clear port suspend
     244                                                *  (start resume if suspened)
     245                                                *    0-nothing */
    214246#define RHPS_CLEAR_PORT_SUSPEND RHPS_POCI_FLAG
    215 #define RHPS_PRS_FLAG (1 << 4) /* r: port reset status
    216                                 * w: 1-set port reset, 0-nothing */
     247#define RHPS_PRS_FLAG host2ohci_reg(1 << 4) /* r: port reset status
     248                                               * w: 1-set port reset, 0-N/S */
    217249#define RHPS_SET_PORT_RESET RHPS_PRS_FLAG
    218 #define RHPS_PPS_FLAG (1 << 8) /* r: port power status
    219                                 * w: 1-set port power, 0-nothing */
     250#define RHPS_PPS_FLAG host2ohci_reg(1 << 8) /* r: port power status
     251                                              * w: 1-set port power, 0-N/S */
    220252#define RHPS_SET_PORT_POWER RHPS_PPS_FLAG
    221 #define RHPS_LSDA_FLAG (1 << 9) /* r: low speed device attached
    222                                  * w: 1-clear port power, 0-nothing */
     253#define RHPS_LSDA_FLAG host2ohci_reg(1 << 9) /* r: low speed device attached
     254                                                * w: 1-clear port power, 0-N/S*/
    223255#define RHPS_CLEAR_PORT_POWER RHPS_LSDA_FLAG
    224 #define RHPS_CSC_FLAG  (1 << 16) /* connect status change Write-Clean */
    225 #define RHPS_PESC_FLAG (1 << 17) /* port enable status change WC */
    226 #define RHPS_PSSC_FLAG (1 << 18) /* port suspend status change WC */
    227 #define RHPS_OCIC_FLAG (1 << 19) /* port over-current change WC */
    228 #define RHPS_PRSC_FLAG (1 << 20) /* port reset status change WC */
    229 #define RHPS_CHANGE_WC_MASK 0x1f0000
     256#define RHPS_CSC_FLAG  host2ohci_reg(1 << 16) /* connect status change WC */
     257#define RHPS_PESC_FLAG host2ohci_reg(1 << 17) /* port enable status change WC */
     258#define RHPS_PSSC_FLAG host2ohci_reg(1 << 18) /* port suspend status change WC */
     259#define RHPS_OCIC_FLAG host2ohci_reg(1 << 19) /* port over-current change WC */
     260#define RHPS_PRSC_FLAG host2ohci_reg(1 << 20) /* port reset status change WC */
     261#define RHPS_CHANGE_WC_MASK host2ohci_reg(0x1f0000)
     262/** OHCI designers were kind enough to make bits correspond to feature # */
     263#define RHPS_FEATURE_BIT(feature) host2ohci_reg(1 << feature)
    230264} __attribute__((packed)) ohci_regs_t;
    231265#endif
  • uspace/drv/bus/usb/ohci/root_hub.c

    r70922c2 rffcc5776  
    3333 */
    3434#include <assert.h>
     35#include <byteorder.h>
    3536#include <errno.h>
    3637#include <str_error.h>
    3738#include <fibril_synch.h>
    3839
     40#include <usb/usb.h>
    3941#include <usb/debug.h>
    4042#include <usb/dev/request.h>
    4143#include <usb/classes/hub.h>
    4244
    43 #include "root_hub.h"
    4445#include <usb/classes/classes.h>
    4546#include <usb/classes/hub.h>
    4647#include <usb/dev/driver.h>
    4748#include "ohci_regs.h"
     49#include "root_hub.h"
    4850
    4951/**
     
    122124{
    123125        assert(request);
     126        usb_log_debug("Sending interrupt vector(%zu) %hhx:%hhx.\n",
     127            size, ((uint8_t*)&mask)[0], ((uint8_t*)&mask)[1]);
    124128        usb_transfer_batch_finish_error(request, &mask, size, EOK);
    125129        usb_transfer_batch_destroy(request);
     
    150154
    151155        instance->registers = regs;
    152         instance->port_count =
    153             (instance->registers->rh_desc_a >> RHDA_NDS_SHIFT) & RHDA_NDS_MASK;
     156        instance->port_count = RHDA_NDS(instance->registers->rh_desc_a);
     157        usb_log_debug("rh_desc_a: %x.\n", instance->registers->rh_desc_a);
    154158        if (instance->port_count > 15) {
    155159                usb_log_warning("OHCI specification does not allow more than 15"
     
    184188
    185189        /* Control all ports by global switch and turn them off */
    186         instance->registers->rh_desc_b &= (RHDB_PCC_MASK << RHDB_PCC_SHIFT);
     190        instance->registers->rh_desc_b &= ~RHDB_PCC_WRITE(~0);
    187191        instance->registers->rh_status = RHS_CLEAR_GLOBAL_POWER;
    188192
    189193        /* Return control to per port state */
    190         instance->registers->rh_desc_b |=
    191                 ((1 << (instance->port_count + 1)) - 1) << RHDB_PCC_SHIFT;
     194        instance->registers->rh_desc_b |= RHDB_PCC_WRITE(~0);
    192195
    193196        /* Set per port over-current */
     
    226229                fibril_mutex_lock(&instance->guard);
    227230                assert(instance->unfinished_interrupt_transfer == NULL);
    228                 uint16_t mask = create_interrupt_mask(instance);
     231                const uint16_t mask = create_interrupt_mask(instance);
    229232                if (mask == 0) {
    230                         usb_log_debug("No changes...\n");
     233                        usb_log_debug("No changes(%hx)...\n", mask);
    231234                        instance->unfinished_interrupt_transfer = request;
    232235                } else {
     
    257260        if (instance->unfinished_interrupt_transfer) {
    258261                usb_log_debug("Finalizing interrupt transfer\n");
    259                 uint16_t mask = create_interrupt_mask(instance);
     262                const uint16_t mask = create_interrupt_mask(instance);
    260263                interrupt_request(instance->unfinished_interrupt_transfer,
    261264                    mask, instance->interrupt_mask_size);
     
    282285        instance->hub_descriptor_size = size;
    283286
    284         uint32_t hub_desc = instance->registers->rh_desc_a;
    285         uint32_t port_desc = instance->registers->rh_desc_b;
     287        const uint32_t hub_desc = instance->registers->rh_desc_a;
     288        const uint32_t port_desc = instance->registers->rh_desc_b;
    286289
    287290        /* bDescLength */
     
    305308        instance->descriptors.hub[4] = 0;
    306309        /* bPwrOn2PwrGood */
    307         instance->descriptors.hub[5] =
    308             (hub_desc >> RHDA_POTPGT_SHIFT) & RHDA_POTPGT_MASK;
     310        instance->descriptors.hub[5] = RHDA_POTPGT(hub_desc);
    309311        /* bHubContrCurrent, root hubs don't need no power. */
    310312        instance->descriptors.hub[6] = 0;
    311313
    312314        /* Device Removable and some legacy 1.0 stuff*/
    313         instance->descriptors.hub[7] =
    314             (port_desc >> RHDB_DR_SHIFT) & RHDB_DR_MASK & 0xff;
     315        instance->descriptors.hub[7] = RHDB_DR_READ(port_desc) & 0xff;
    315316        instance->descriptors.hub[8] = 0xff;
    316317        if (instance->interrupt_mask_size == 2) {
    317                 instance->descriptors.hub[8] =
    318                     (port_desc >> RHDB_DR_SHIFT) & RHDB_DR_MASK >> 8;
     318                instance->descriptors.hub[8] = RHDB_DR_READ(port_desc) >> 8;
    319319                instance->descriptors.hub[9]  = 0xff;
    320320                instance->descriptors.hub[10] = 0xff;
     
    375375                }
    376376        }
    377         /* USB is little endian */
    378         return host2uint32_t_le(mask);
     377        usb_log_debug2("OHCI root hub interrupt mask: %hx.\n", mask);
     378        return uint16_host2usb(mask);
    379379}
    380380/*----------------------------------------------------------------------------*/
     
    434434                        TRANSFER_END(request, EOVERFLOW);
    435435                } else {
    436                         uint16_t data =
     436                        const uint16_t data =
    437437                            uint16_host2usb(USB_DEVICE_STATUS_SELF_POWERED);
    438438                        TRANSFER_END_DATA(request, &data, sizeof(data));
     
    482482        usb_device_request_setup_packet_t *setup_request =
    483483            (usb_device_request_setup_packet_t *) request->setup_buffer;
    484         uint16_t setup_request_value = setup_request->value_high;
     484        const int setup_request_value = uint16_usb2host(setup_request->value);
    485485        switch (setup_request_value)
    486486        {
     
    568568        case USB_HUB_FEATURE_PORT_SUSPEND: //2
    569569        case USB_HUB_FEATURE_PORT_RESET:   //4
    570                 /* Nice thing is that these shifts correspond to the position
    571                  * of control bits in register */
    572                 instance->registers->rh_port_status[port - 1] = (1 << feature);
     570                usb_log_debug2(
     571                    "Setting port ENABLE, SUSPEND or RESET on port %zu.\n",
     572                    port);
     573                instance->registers->rh_port_status[port - 1] =
     574                    RHPS_FEATURE_BIT(feature);
    573575                return EOK;
    574576        default:
     
    624626        case USB_HUB_FEATURE_C_PORT_OVER_CURRENT: //19
    625627        case USB_HUB_FEATURE_C_PORT_RESET:        //20
    626                 /* Nice thing is that these shifts correspond to the position
    627                  * of control bits in register */
    628                 instance->registers->rh_port_status[port - 1] = (1 << feature);
     628                usb_log_debug2("Clearing port C_CONNECTION, C_ENABLE, "
     629                    "C_SUSPEND or C_RESET on port %zu.\n",
     630                    port);
     631                instance->registers->rh_port_status[port - 1] =
     632                    RHPS_FEATURE_BIT(feature);
    629633                return EOK;
    630634
     
    795799        case USB_DEVREQ_SET_CONFIGURATION:
    796800                usb_log_debug("USB_DEVREQ_SET_CONFIGURATION: %u\n",
    797                     setup_request->value);
     801                    uint16_usb2host(setup_request->value));
    798802                /* We have only one configuration, it's number is 1 */
    799803                if (uint16_usb2host(setup_request->value) != 1)
Note: See TracChangeset for help on using the changeset viewer.