Changes in / [fefc27d:4fbcd2a] in mainline


Ignore:
Location:
uspace
Files:
7 edited

Legend:

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

    rfefc27d r4fbcd2a  
    4545
    4646static int interrupt_emulator(hc_t *instance);
    47 static void hc_gain_control(hc_t *instance);
    48 static void hc_init_hw(hc_t *instance);
    4947/*----------------------------------------------------------------------------*/
    5048int hc_register_hub(hc_t *instance, ddf_fun_t *hub_fun)
     
    7977        assert(instance);
    8078        int ret = EOK;
    81 #define CHECK_RET_RETURN(ret, message...) \
    82 if (ret != EOK) { \
    83         usb_log_error(message); \
    84         return ret; \
    85 } else (void)0
    8679
    8780        ret = pio_enable((void*)regs, reg_size, (void**)&instance->registers);
    88         CHECK_RET_RETURN(ret,
    89             "Failed(%d) to gain access to device registers: %s.\n",
    90             ret, str_error(ret));
    91 
     81        if (ret != EOK) {
     82                usb_log_error("Failed to gain access to device registers.\n");
     83                return ret;
     84        }
    9285        instance->ddf_instance = fun;
    9386        usb_device_keeper_init(&instance->manager);
    94         ret = bandwidth_init(&instance->bandwidth, BANDWIDTH_AVAILABLE_USB11,
    95             bandwidth_count_usb11);
    96         CHECK_RET_RETURN(ret, "Failed to initialize bandwidth allocator: %s.\n",
    97             ret, str_error(ret));
    9887
    9988        if (!interrupts) {
     
    10392        }
    10493
    105         hc_gain_control(instance);
    106 
    10794        rh_init(&instance->rh, dev, instance->registers);
    108 
    109         hc_init_hw(instance);
    11095
    11196        /* TODO: implement */
     
    132117                rh_interrupt(&instance->rh);
    133118
    134         usb_log_info("OHCI interrupt: %x.\n", status);
    135 
    136119        /* TODO: Check for further interrupt causes */
    137120        /* TODO: implement */
     
    143126        usb_log_info("Started interrupt emulator.\n");
    144127        while (1) {
    145                 const uint32_t status = instance->registers->interrupt_status;
     128                uint32_t status = instance->registers->interrupt_status;
    146129                instance->registers->interrupt_status = status;
    147130                hc_interrupt(instance, status);
     
    150133        return EOK;
    151134}
    152 /*----------------------------------------------------------------------------*/
    153 void hc_gain_control(hc_t *instance)
    154 {
    155         assert(instance);
    156         /* Interrupt routing enabled => smm driver is active */
    157         if (instance->registers->control & C_IR) {
    158                 usb_log_info("Found SMM driver requesting ownership change.\n");
    159                 instance->registers->command_status |= CS_OCR;
    160                 while (instance->registers->control & C_IR) {
    161                         async_usleep(1000);
    162                 }
    163                 usb_log_info("Ownership taken from SMM driver.\n");
    164                 return;
    165         }
    166 
    167         const unsigned hc_status =
    168             (instance->registers->control >> C_HCFS_SHIFT) & C_HCFS_MASK;
    169         /* Interrupt routing disabled && status != USB_RESET => BIOS active */
    170         if (hc_status != C_HCFS_RESET) {
    171                 usb_log_info("Found BIOS driver.\n");
    172                 if (hc_status == C_HCFS_OPERATIONAL) {
    173                         usb_log_info("HC operational(BIOS).\n");
    174                         return;
    175                 }
    176                 /* HC is suspended assert resume for 20ms */
    177                 instance->registers->control &= (C_HCFS_RESUME << C_HCFS_SHIFT);
    178                 async_usleep(20000);
    179                 return;
    180         }
    181 
    182         /* HC is in reset (hw startup) => no other driver
    183          * maintain reset for at least the time specified in USB spec (50 ms)*/
    184         async_usleep(50000);
    185 }
    186 /*----------------------------------------------------------------------------*/
    187 void hc_init_hw(hc_t *instance)
    188 {
    189         assert(instance);
    190         const uint32_t fm_interval = instance->registers->fm_interval;
    191         instance->registers->command_status = CS_HCR;
    192         async_usleep(10);
    193         instance->registers->fm_interval = fm_interval;
    194         assert((instance->registers->command_status & CS_HCR) == 0);
    195         /* hc is now in suspend state */
    196         /* TODO: init HCCA block */
    197         /* TODO: init queues */
    198         /* TODO: enable queues */
    199         /* TODO: enable interrupts */
    200         /* TODO: set periodic start to 90% */
    201 
    202         instance->registers->control &= (C_HCFS_OPERATIONAL << C_HCFS_SHIFT);
    203         usb_log_info("OHCI HC up and running.\n");
    204 }
    205135/**
    206136 * @}
  • uspace/drv/ohci/hc.h

    rfefc27d r4fbcd2a  
    4242#include <usb/usb.h>
    4343#include <usb/host/device_keeper.h>
    44 #include <usb/host/bandwidth.h>
    4544#include <usbhc_iface.h>
    4645
     
    5554        ddf_fun_t *ddf_instance;
    5655        usb_device_keeper_t manager;
    57         bandwidth_t bandwidth;
    5856        fid_t interrupt_emulator;
    5957} hc_t;
  • uspace/drv/ohci/iface.c

    rfefc27d r4fbcd2a  
    151151    size_t max_packet_size, unsigned int interval)
    152152{
    153         assert(fun);
    154         hc_t *hc = fun_to_hc(fun);
    155         assert(hc);
    156         if (address == hc->rh.address)
    157                 return EOK;
    158         const usb_speed_t speed =
    159                 usb_device_keeper_get_speed(&hc->manager, address);
    160         const size_t size = max_packet_size;
    161         usb_log_debug("Register endpoint %d:%d %s %s(%d) %zu(%zu) %u.\n",
    162             address, endpoint, usb_str_transfer_type(transfer_type),
    163             usb_str_speed(speed), direction, size, max_packet_size, interval);
    164         return bandwidth_reserve(&hc->bandwidth, address, endpoint, direction,
    165             speed, transfer_type, max_packet_size, size, interval);
     153        UNSUPPORTED("register_endpoint");
     154
     155        return ENOTSUP;
    166156}
    167157/*----------------------------------------------------------------------------*/
     
    178168    usb_endpoint_t endpoint, usb_direction_t direction)
    179169{
    180         assert(fun);
    181         hc_t *hc = fun_to_hc(fun);
    182         assert(hc);
    183         usb_log_debug("Unregister endpoint %d:%d %d.\n",
    184             address, endpoint, direction);
    185         return bandwidth_release(&hc->bandwidth, address, endpoint, direction);
     170        UNSUPPORTED("unregister_endpoint");
    186171
    187172        return ENOTSUP;
  • uspace/drv/ohci/ohci_regs.h

    rfefc27d r4fbcd2a  
    3939typedef struct ohci_regs
    4040{
    41         const volatile uint32_t revision;
     41        volatile uint32_t revision;
    4242        volatile uint32_t control;
    43 #define C_CSBR_MASK (0x3)
    44 #define C_CSBR_SHIFT (0)
    45 #define C_PLE (1 << 2)
    46 #define C_IE (1 << 3)
    47 #define C_CLE (1 << 4)
    48 #define C_BLE (1 << 5)
    49 
    50 #define C_HCFS_MASK (0x3)
    51 #define C_HCFS_SHIFT (6)
    52 #define C_HCFS_RESET (0x0)
    53 #define C_HCFS_OPERATIONAL (0x1)
    54 #define C_HCFS_RESUME (0x2)
    55 #define C_HCFS_SUSPEND (0x3)
    56 
    57 #define C_IR (1 << 8)
    58 #define C_RWC (1 << 9)
    59 #define C_RWE (1 << 10)
    60 
    6143        volatile uint32_t command_status;
    62 #define CS_HCR (1 << 0)
    63 #define CS_CLF (1 << 1)
    64 #define CS_BLF (1 << 2)
    65 #define CS_OCR (1 << 3)
    66 #define CS_SOC_MASK (0x3)
    67 #define CS_SOC_SHIFT (16)
    68 
    6944        volatile uint32_t interrupt_status;
    7045#define IS_SO (1 << 0)
     
    7651#define IS_RHSC (1 << 6)
    7752#define IS_OC (1 << 30)
    78 
    7953        volatile uint32_t interupt_enable;
    8054#define IE_SO   (1 << 0)
  • uspace/drv/ohci/root_hub.c

    rfefc27d r4fbcd2a  
    252252
    253253
    254         usb_log_info("OHCI root hub with %d ports.\n", instance->port_count);
     254        usb_log_info("OHCI root hub with %d ports.\n", regs->rh_desc_a & 0xff);
    255255
    256256        //start generic usb hub driver
     
    275275        if(port<1 || port>instance->port_count)
    276276                return EINVAL;
    277         uint32_t * uint32_buffer = (uint32_t*)request->transport_buffer;
     277        uint32_t * uint32_buffer = (uint32_t*)request->buffer;
    278278        request->transfered_size = 4;
    279279        uint32_buffer[0] = instance->registers->rh_port_status[port -1];
     
    292292static int process_get_hub_status_request(rh_t *instance,
    293293                usb_transfer_batch_t * request){
    294         uint32_t * uint32_buffer = (uint32_t*)request->transport_buffer;
     294        uint32_t * uint32_buffer = (uint32_t*)request->buffer;
    295295        //bits, 0,1,16,17
    296296        request->transfered_size = 4;
     
    457457        if(request->buffer_size != 1)
    458458                return EINVAL;
    459         request->transport_buffer[0] = 1;
     459        request->buffer[0] = 1;
    460460        request->transfered_size = 1;
    461461        return EOK;
  • uspace/drv/uhci-hcd/hc.c

    rfefc27d r4fbcd2a  
    241241        ret = bandwidth_init(&instance->bandwidth, BANDWIDTH_AVAILABLE_USB11,
    242242            bandwidth_count_usb11);
    243         assert(ret == EOK);
     243        assert(ret == true);
    244244
    245245        return EOK;
  • uspace/lib/usb/src/host/bandwidth.c

    rfefc27d r4fbcd2a  
    127127        instance->free = bandwidth;
    128128        instance->usage_fnc = usage_fnc;
    129         bool ht =
     129        return
    130130            hash_table_create(&instance->reserved, BUCKET_COUNT, MAX_KEYS, &op);
    131         return ht ? EOK : ENOMEM;
    132131}
    133132/*----------------------------------------------------------------------------*/
Note: See TracChangeset for help on using the changeset viewer.