Changeset 112d159 in mainline


Ignore:
Timestamp:
2011-04-09T13:14:51Z (13 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
ff0e354
Parents:
39db23f
Message:

Debug output and startup fixes

Location:
uspace/drv/ohci
Files:
3 edited

Legend:

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

    r39db23f r112d159  
    154154{
    155155        assert(instance);
    156         if (status == 0)
     156        if ((status & ~IS_SF) == 0) /* ignore sof status */
    157157                return;
    158158        if (status & IS_RHSC)
     
    192192{
    193193        assert(instance);
     194        /* Turn off legacy emulation */
     195        volatile uint32_t *ohci_emulation_reg =
     196            (uint32_t*)((char*)instance->registers + 0x100);
     197        usb_log_debug("OHCI legacy register %p: %x.\n",
     198                ohci_emulation_reg, *ohci_emulation_reg);
     199        *ohci_emulation_reg = 0;
     200
    194201        /* Interrupt routing enabled => smm driver is active */
    195202        if (instance->registers->control & C_IR) {
    196                 usb_log_info("Found SMM driver requesting ownership change.\n");
     203                usb_log_debug("SMM driver: request ownership change.\n");
    197204                instance->registers->command_status |= CS_OCR;
    198205                while (instance->registers->control & C_IR) {
    199206                        async_usleep(1000);
    200207                }
    201                 usb_log_info("Ownership taken from SMM driver.\n");
     208                usb_log_info("SMM driver: Ownership taken.\n");
    202209                return;
    203210        }
     
    207214        /* Interrupt routing disabled && status != USB_RESET => BIOS active */
    208215        if (hc_status != C_HCFS_RESET) {
    209                 usb_log_info("Found BIOS driver.\n");
     216                usb_log_debug("BIOS driver found.\n");
    210217                if (hc_status == C_HCFS_OPERATIONAL) {
    211                         usb_log_info("HC operational(BIOS).\n");
     218                        usb_log_info("BIOS driver: HC operational.\n");
    212219                        return;
    213220                }
     
    215222                instance->registers->control &= (C_HCFS_RESUME << C_HCFS_SHIFT);
    216223                async_usleep(20000);
     224                usb_log_info("BIOS driver: HC resumed.\n");
    217225                return;
    218226        }
     
    220228        /* HC is in reset (hw startup) => no other driver
    221229         * maintain reset for at least the time specified in USB spec (50 ms)*/
     230        usb_log_info("HC found in reset.\n");
    222231        async_usleep(50000);
    223 
    224         /* turn off legacy emulation */
    225         volatile uint32_t *ohci_emulation_reg =
    226             (uint32_t*)((char*)instance->registers + 0x100);
    227         usb_log_info("OHCI legacy register status %p: %x.\n",
    228                 ohci_emulation_reg, *ohci_emulation_reg);
    229         *ohci_emulation_reg = 0;
    230 
    231232}
    232233/*----------------------------------------------------------------------------*/
    233234void hc_init_hw(hc_t *instance)
    234235{
    235         assert(instance);
     236        /* OHCI guide page 42 */
     237        assert(instance);
     238        usb_log_debug2("Started hc initialization routine.\n");
     239
     240        /* Save contents of fm_interval register */
    236241        const uint32_t fm_interval = instance->registers->fm_interval;
    237 
    238         /* reset hc */
     242        usb_log_debug2("Old value of HcFmInterval: %x.\n", fm_interval);
     243
     244        /* Reset hc */
     245        usb_log_debug2("HC reset.\n");
     246        size_t time = 0;
    239247        instance->registers->command_status = CS_HCR;
    240         async_usleep(10);
    241 
    242         /* restore fm_interval */
     248        while (instance->registers->command_status & CS_HCR) {
     249                async_usleep(10);
     250                time += 10;
     251        }
     252        usb_log_debug2("HC reset complete in %zu us.\n", time);
     253
     254        /* Restore fm_interval */
    243255        instance->registers->fm_interval = fm_interval;
    244256        assert((instance->registers->command_status & CS_HCR) == 0);
    245257
    246258        /* hc is now in suspend state */
    247 
    248         /* enable queues */
     259        usb_log_debug2("HC should be in suspend state(%x).\n",
     260            instance->registers->control);
     261
     262        /* Enable queues */
    249263        instance->registers->control |= (C_PLE | C_IE | C_CLE | C_BLE);
    250         /* TODO: enable interrupts */
    251         /* set periodic start to 90% */
    252         instance->registers->periodic_start = (fm_interval / 10) * 9;
     264        usb_log_debug2("All queues enabled(%x).\n",
     265            instance->registers->control);
     266
     267        /* Disable interrupts */
     268        instance->registers->interrupt_disable = I_SF | I_OC;
     269        usb_log_debug2("Disabling interrupts: %x.\n",
     270            instance->registers->interrupt_disable);
     271        instance->registers->interrupt_disable = I_MI;
     272        usb_log_debug2("Enabled interrupts: %x.\n",
     273            instance->registers->interrupt_enable);
     274
     275        /* Set periodic start to 90% */
     276        uint32_t frame_length = ((fm_interval >> FMI_FI_SHIFT) & FMI_FI_MASK);
     277        instance->registers->periodic_start = (frame_length / 10) * 9;
     278        usb_log_debug2("All periodic start set to: %x(%u - 90%% of %d).\n",
     279            instance->registers->periodic_start,
     280            instance->registers->periodic_start, frame_length);
    253281
    254282        instance->registers->control &= (C_HCFS_OPERATIONAL << C_HCFS_SHIFT);
    255         usb_log_info("OHCI HC up and running.\n");
     283        usb_log_info("OHCI HC up and running(%x).\n",
     284            instance->registers->control);
    256285}
    257286/*----------------------------------------------------------------------------*/
  • uspace/drv/ohci/ohci_regs.h

    r39db23f r112d159  
    8484        /** Interupt enable/disable, reads give the same value, writing causes
    8585         * enable/disable */
    86         volatile uint32_t interupt_enable;
     86        volatile uint32_t interrupt_enable;
    8787        volatile uint32_t interrupt_disable;
    8888#define I_SO   (1 << 0)   /* Scheduling overrun */
     
    120120        /** Frame time and max packet size for all transfers */
    121121        volatile uint32_t fm_interval;
    122 #define FMI_FI_MASK (0x1fff) /* Frame interval in bit times (should be 11999)*/
     122#define FMI_FI_MASK (0x3fff) /* Frame interval in bit times (should be 11999)*/
    123123#define FMI_FI_SHIFT (0)
    124124#define FMI_FSMPS_MASK (0x7fff) /* Full speed max packet size */
     
    138138        /** Remaining bit time in frame to start periodic transfers */
    139139        volatile uint32_t periodic_start;
    140 #define PS_PS_MASK (0x1fff) /* bit time when periodic get priority (0x3e67) */
     140#define PS_PS_MASK (0x3fff) /* bit time when periodic get priority (0x3e67) */
    141141
    142142        /** Threshold for starting LS transaction */
  • uspace/drv/ohci/root_hub.c

    r39db23f r112d159  
    209209        instance->registers = regs;
    210210        instance->device = dev;
    211         instance->port_count = instance->registers->rh_desc_a & 0xff;
     211        instance->port_count =
     212            (instance->registers->rh_desc_a >> RHDA_NDS_SHIFT) & RHDA_NDS_MASK;
    212213        rh_init_descriptors(instance);
    213214        // set port power mode to no-power-switching
Note: See TracChangeset for help on using the changeset viewer.