Changeset b4b534ac in mainline for uspace/drv/bus/usb/ehci/ehci_rh.h


Ignore:
Timestamp:
2016-07-22T08:24:47Z (8 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
f76d2c2
Parents:
5b18137 (diff), 8351f9a4 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge from lp:~jan.vesely/helenos/usb

File:
1 moved

Legend:

Unmodified
Added
Removed
  • uspace/drv/bus/usb/ehci/ehci_rh.h

    r5b18137 rb4b534ac  
    11/*
    2  * Copyright (c) 2011 Jan Vesely
     2 * Copyright (c) 2013 Jan Vesely
    33 * All rights reserved.
    44 *
     
    2626 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    2727 */
    28 /** @addtogroup drvusbuhci
     28/** @addtogroup drvusbehci
    2929 * @{
    3030 */
    3131/** @file
    32  * @brief UHCI driver
     32 * @brief EHCI driver
    3333 */
     34#ifndef DRV_EHCI_EHCI_RH_H
     35#define DRV_EHCI_EHCI_RH_H
     36
    3437#include <assert.h>
    35 #include <errno.h>
    36 #include <str_error.h>
    37 #include <stdio.h>
    38 #include <device/hw_res_parsed.h>
     38#include <sys/types.h>
    3939
    40 #include <usb/debug.h>
     40#include <usb/usb.h>
     41#include <usb/classes/hub.h>
     42#include <usb/host/usb_transfer_batch.h>
     43#include <usbvirt/virthub_base.h>
    4144
    42 #include "root_hub.h"
     45#include "ehci_regs.h"
    4346
    44 /** Root hub initialization
    45  * @param[in] instance RH structure to initialize
    46  * @param[in] fun DDF function representing UHCI root hub
    47  * @param[in] reg_addr Address of root hub status and control registers.
    48  * @param[in] reg_size Size of accessible address space.
    49  * @return Error code.
     47enum {
     48        EHCI_MAX_PORTS = 15,
     49};
     50
     51typedef struct {
     52        /** Virtual hub instance */
     53        virthub_base_t base;
     54        /** EHCI device registers */
     55        ehci_regs_t *registers;
     56        /** Number of downstream ports, EHCI limits this to 15 */
     57        unsigned port_count;
     58        /** USB hub descriptor describing the EHCI root hub */
     59        struct {
     60                usb_hub_descriptor_header_t header;
     61                uint8_t rempow[STATUS_BYTES(EHCI_MAX_PORTS) * 2];
     62        } __attribute__((packed)) hub_descriptor;
     63        /** interrupt transfer waiting for an actual interrupt to occur */
     64        usb_transfer_batch_t *unfinished_interrupt_transfer;
     65        bool reset_flag[EHCI_MAX_PORTS];
     66        bool resume_flag[EHCI_MAX_PORTS];
     67} ehci_rh_t;
     68
     69int ehci_rh_init(ehci_rh_t *instance, ehci_caps_regs_t *caps, ehci_regs_t *regs,
     70    const char *name);
     71int ehci_rh_schedule(ehci_rh_t *instance, usb_transfer_batch_t *batch);
     72int ehci_rh_interrupt(ehci_rh_t *instance);
     73
     74/** Get EHCI rh address.
     75 *
     76 * @param instance UHCI rh instance.
     77 * @return USB address assigned to the hub.
     78 * Wrapper for virtual hub address
    5079 */
    51 int
    52 rh_init(rh_t *instance, ddf_fun_t *fun, addr_range_t *regs, uintptr_t reg_addr,
    53     size_t reg_size)
     80static inline usb_address_t ehci_rh_get_address(ehci_rh_t *instance)
    5481{
    5582        assert(instance);
    56         assert(fun);
    57 
    58         /* Crop the PIO window to the absolute address range of UHCI I/O. */
    59         instance->pio_window.mem.base = 0;
    60         instance->pio_window.mem.size = 0;
    61         instance->pio_window.io.base = RNGABS(*regs);
    62         instance->pio_window.io.size = RNGSZ(*regs);
    63 
    64         /* Initialize resource structure */
    65         instance->resource_list.count = 1;
    66         instance->resource_list.resources = &instance->io_regs;
    67 
    68         instance->io_regs.type = IO_RANGE;
    69         instance->io_regs.res.io_range.address = reg_addr;
    70         instance->io_regs.res.io_range.size = reg_size;
    71         instance->io_regs.res.io_range.relative = true;
    72         instance->io_regs.res.io_range.endianness = LITTLE_ENDIAN;
    73 
    74         const int ret = ddf_fun_add_match_id(fun, "usb&uhci&root-hub", 100);
    75         if (ret != EOK) {
    76                 usb_log_error("Failed to add root hub match id: %s\n",
    77                     str_error(ret));
    78         }
    79         return ret;
     83        return virthub_base_get_address(&instance->base);
    8084}
     85#endif
    8186/**
    8287 * @}
Note: See TracChangeset for help on using the changeset viewer.