Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/uhci-rhd/root_hub.c

    rdced52a rf123909  
    2626 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    2727 */
    28 /** @addtogroup usb
     28/** @addtogroup drvusbuhcirh
    2929 * @{
    3030 */
    3131/** @file
    32  * @brief UHCI driver
     32 * @brief UHCI root hub driver
    3333 */
    3434#include <errno.h>
    35 #include <stdint.h>
    3635#include <ddi.h>
    37 #include <devman.h>
    3836#include <usb/debug.h>
    3937
    4038#include "root_hub.h"
    4139
     40/** Initialize UHCI root hub instance.
     41 *
     42 * @param[in] instance Driver memory structure to use.
     43 * @param[in] addr Address of I/O registers.
     44 * @param[in] size Size of available I/O space.
     45 * @param[in] rh Pointer to ddf instance of the root hub driver.
     46 * @return Error code.
     47 */
    4248int uhci_root_hub_init(
    4349  uhci_root_hub_t *instance, void *addr, size_t size, ddf_dev_t *rh)
     
    4753        int ret;
    4854
    49         /* allow access to root hub registers */
    50         assert(sizeof(port_status_t) * UHCI_ROOT_HUB_PORT_COUNT == size);
     55        /* Allow access to root hub port registers */
     56        assert(sizeof(port_status_t) * UHCI_ROOT_HUB_PORT_COUNT <= size);
    5157        port_status_t *regs;
    5258        ret = pio_enable(addr, size, (void**)&regs);
    53 
    5459        if (ret < 0) {
    55                 usb_log_error("Failed to gain access to port registers at %p\n", regs);
     60                usb_log_error(
     61                    "Failed(%d) to gain access to port registers at %p\n",
     62                    ret, regs);
    5663                return ret;
    5764        }
    5865
    59         /* add fibrils for periodic port checks */
     66        /* Initialize root hub ports */
    6067        unsigned i = 0;
    6168        for (; i < UHCI_ROOT_HUB_PORT_COUNT; ++i) {
    62                 /* mind pointer arithmetics */
     69                /* NOTE: mind pointer arithmetics here */
    6370                ret = uhci_port_init(
    64                   &instance->ports[i], regs + i, i, ROOT_HUB_WAIT_USEC, rh);
     71                    &instance->ports[i], regs + i, i, ROOT_HUB_WAIT_USEC, rh);
    6572                if (ret != EOK) {
    6673                        unsigned j = 0;
     
    7481}
    7582/*----------------------------------------------------------------------------*/
    76 int uhci_root_hub_fini( uhci_root_hub_t* instance )
     83/** Cleanup UHCI root hub instance.
     84 *
     85 * @param[in] instance Root hub structure to use.
     86 * @return Error code.
     87 */
     88int uhci_root_hub_fini(uhci_root_hub_t* instance)
    7789{
    78         assert( instance );
    79         // TODO:
    80         //destroy fibril here
    81         //disable access to registers
     90        assert(instance);
     91        unsigned i = 0;
     92        for (; i < UHCI_ROOT_HUB_PORT_COUNT; ++i) {
     93                uhci_port_fini(&instance->ports[i]);
     94        }
    8295        return EOK;
    8396}
Note: See TracChangeset for help on using the changeset viewer.