Changeset f123909 in mainline


Ignore:
Timestamp:
2011-03-13T23:10:50Z (13 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
3bd96bb
Parents:
a9f91cd
Message:

Doxygen fixes and refactoring.

UHCI root hub driver should be complete (except may be for the BUG)

Location:
uspace
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • uspace/doc/doxygroups.h

    ra9f91cd rf123909  
    253253         * @defgroup drvusbuhci UHCI driver
    254254         * @ingroup usb
    255          * @brief Driver for USB host controller UHCI.
     255         * @brief Drivers for USB UHCI host controller and root hub.
     256         */
     257
     258        /**
     259         * @defgroup drvusbuhcirh UHCI root hub driver
     260         * @ingroup drvusbuhci
     261         * @brief Driver for UHCI complaint root hub.
    256262         */
    257263
  • uspace/drv/ehci-hcd/main.c

    ra9f91cd rf123909  
    2727 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    2828 */
    29 /** @addtogroup usbdrvehci
     29/** @addtogroup drvusbehci
    3030 * @{
    3131 */
  • uspace/drv/uhci-rhd/main.c

    ra9f91cd 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 initialization routines
    3333 */
    3434#include <ddf/driver.h>
     
    4040#include <usb/debug.h>
    4141
    42 
    43 
    4442#include "root_hub.h"
    4543
     
    4745static int hc_get_my_registers(ddf_dev_t *dev,
    4846    uintptr_t *io_reg_address, size_t *io_reg_size);
     47#if 0
    4948/*----------------------------------------------------------------------------*/
    5049static int usb_iface_get_hc_handle(ddf_fun_t *fun, devman_handle_t *handle)
     
    6766        .interfaces[USB_DEV_IFACE] = &uhci_rh_usb_iface,
    6867};
     68#endif
    6969/*----------------------------------------------------------------------------*/
    70 /** Initializes a new ddf driver instance of UHCI root hub.
     70/** Initialize a new ddf driver instance of UHCI root hub.
    7171 *
    7272 * @param[in] device DDF instance of the device to initialize.
     
    8181
    8282        //device->ops = &uhci_rh_ops;
    83         (void) uhci_rh_ops;
    84 
    85         uhci_root_hub_t *rh = malloc(sizeof(uhci_root_hub_t));
    86         if (!rh) {
    87                 usb_log_error("Failed to allocate memory for driver instance.\n");
    88                 return ENOMEM;
    89         }
    90 
    9183        uintptr_t io_regs = 0;
    9284        size_t io_size = 0;
    9385
    9486        int ret = hc_get_my_registers(device, &io_regs, &io_size);
    95         assert(ret == EOK);
     87        if (ret != EOK) {
     88                usb_log_error("Failed(%d) to get registers from parent hc.",
     89                    ret);
     90        }
     91        usb_log_info("I/O regs at %#X (size %zu).\n", io_regs, io_size);
    9692
    97         /* TODO: verify values from hc */
    98         usb_log_info("I/O regs at 0x%X (size %zu).\n", io_regs, io_size);
     93        uhci_root_hub_t *rh = malloc(sizeof(uhci_root_hub_t));
     94        if (!rh) {
     95                usb_log_error("Failed to allocate driver instance.\n");
     96                return ENOMEM;
     97        }
     98
    9999        ret = uhci_root_hub_init(rh, (void*)io_regs, io_size, device);
    100100        if (ret != EOK) {
     
    119119};
    120120/*----------------------------------------------------------------------------*/
    121 /** Initializes global driver structures (NONE).
     121/** Initialize global driver structures (NONE).
    122122 *
    123123 * @param[in] argc Nmber of arguments in argv vector (ignored).
  • uspace/drv/uhci-rhd/port.c

    ra9f91cd 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
    33  */
     32 * @brief UHCI root hub port routines
     33 */
     34#include <libarch/ddi.h> /* pio_read and pio_write */
    3435#include <errno.h>
    3536#include <str_error.h>
     
    3738
    3839#include <usb/usb.h>    /* usb_address_t */
    39 #include <usb/usbdevice.h>
    4040#include <usb/hub.h>
    41 #include <usb/request.h>
    4241#include <usb/debug.h>
    43 #include <usb/recognise.h>
    4442
    4543#include "port.h"
     
    5048static int uhci_port_check(void *port);
    5149static int uhci_port_reset_enable(int portno, void *arg);
    52 /*----------------------------------------------------------------------------*/
    53 /** Initializes UHCI root hub port instance.
     50static void uhci_port_print_status(
     51    uhci_port_t *port, const port_status_t value);
     52
     53/** Register reading helper function.
     54 *
     55 * @param[in] port Structure to use.
     56 * @return Error code. (Always EOK)
     57 */
     58static inline port_status_t uhci_port_read_status(uhci_port_t *port)
     59{
     60        assert(port);
     61        return pio_read_16(port->address);
     62}
     63/*----------------------------------------------------------------------------*/
     64/** Register writing helper function.
     65 *
     66 * @param[in] port Structure to use.
     67 * @param[in] value New register value.
     68 * @return Error code. (Always EOK)
     69 */
     70static inline void uhci_port_write_status(
     71    uhci_port_t *port, port_status_t value)
     72{
     73        assert(port);
     74        pio_write_16(port->address, value);
     75}
     76
     77/*----------------------------------------------------------------------------*/
     78/** Initialize UHCI root hub port instance.
    5479 *
    5580 * @param[in] port Memory structure to use.
     
    6085 * @return Error code.
    6186 *
    62  * Starts the polling fibril.
     87 * Creates and starts the polling fibril.
    6388 */
    6489int uhci_port_init(uhci_port_t *port,
     
    86111        port->checker = fibril_create(uhci_port_check, port);
    87112        if (port->checker == 0) {
    88                 usb_log_error("Port(%p - %d): failed to launch root hub fibril.",
    89                     port->address, port->number);
     113                usb_log_error("%s: failed to create polling fibril.",
     114                    port->id_string);
    90115                return ENOMEM;
    91116        }
    92117
    93118        fibril_add_ready(port->checker);
    94         usb_log_debug("Port(%p - %d): Added fibril. %x\n",
    95             port->address, port->number, port->checker);
    96         return EOK;
    97 }
    98 /*----------------------------------------------------------------------------*/
    99 /** Finishes UHCI root hub port instance.
     119        usb_log_debug("%s: Started polling fibril(%x).\n",
     120            port->id_string, port->checker);
     121        return EOK;
     122}
     123/*----------------------------------------------------------------------------*/
     124/** Cleanup UHCI root hub port instance.
    100125 *
    101126 * @param[in] port Memory structure to use.
     
    105130void uhci_port_fini(uhci_port_t *port)
    106131{
     132        assert(port);
     133        free(port->id_string);
    107134        /* TODO: Kill fibril here */
    108135        return;
     
    111138/** Periodically checks port status and reports new devices.
    112139 *
    113  * @param[in] port Memory structure to use.
     140 * @param[in] port Port structure to use.
    114141 * @return Error code.
    115142 */
     
    122149                async_usleep(instance->wait_period_usec);
    123150
    124                 /* read register value */
     151                /* Read register value */
    125152                port_status_t port_status = uhci_port_read_status(instance);
    126153
    127                 /* print the value if it's interesting */
     154                /* Print the value if it's interesting */
    128155                if (port_status & ~STATUS_ALWAYS_ONE)
    129156                        uhci_port_print_status(instance, port_status);
     
    177204 * @param arg Pointer to uhci_port_t of port with the new device.
    178205 * @return Error code.
     206 *
     207 * Resets and enables the ub port.
    179208 */
    180209int uhci_port_reset_enable(int portno, void *arg)
     
    214243}
    215244/*----------------------------------------------------------------------------*/
    216 /** Initializes and reports connected device.
    217  *
    218  * @param[in] port Memory structure to use.
     245/** Initialize and report connected device.
     246 *
     247 * @param[in] port Port structure to use.
    219248 * @param[in] speed Detected speed.
    220249 * @return Error code.
     
    247276}
    248277/*----------------------------------------------------------------------------*/
    249 /** Removes device.
     278/** Remove device.
    250279 *
    251280 * @param[in] port Memory structure to use.
    252281 * @return Error code.
    253282 *
    254  * Does not work DDF does not support device removal.
     283 * Does not work, DDF does not support device removal.
     284 * Does not even free used USB address (it would be dangerous if tis driver
     285 * is still running).
    255286 */
    256287int uhci_port_remove_device(uhci_port_t *port)
     
    261292}
    262293/*----------------------------------------------------------------------------*/
    263 /** Enables and disables port.
    264  *
    265  * @param[in] port Memory structure to use.
     294/** Enable or disable root hub port.
     295 *
     296 * @param[in] port Port structure to use.
     297 * @param[in] enabled Port status to set.
    266298 * @return Error code. (Always EOK)
    267299 */
     
    288320}
    289321/*----------------------------------------------------------------------------*/
     322/** Print the port status value in a human friendly way
     323 *
     324 * @param[in] port Port structure to use.
     325 * @param[in] value Port register value to print.
     326 * @return Error code. (Always EOK)
     327 */
     328void uhci_port_print_status(uhci_port_t *port, const port_status_t value)
     329{
     330        assert(port);
     331        usb_log_debug2("%s Port status(%#x):%s%s%s%s%s%s%s%s%s%s%s.\n",
     332            port->id_string, value,
     333            (value & STATUS_SUSPEND) ? " SUSPENDED," : "",
     334            (value & STATUS_RESUME) ? " IN RESUME," : "",
     335            (value & STATUS_IN_RESET) ? " IN RESET," : "",
     336            (value & STATUS_LINE_D_MINUS) ? " VD-," : "",
     337            (value & STATUS_LINE_D_PLUS) ? " VD+," : "",
     338            (value & STATUS_LOW_SPEED) ? " LOWSPEED," : "",
     339            (value & STATUS_ENABLED_CHANGED) ? " ENABLED-CHANGE," : "",
     340            (value & STATUS_ENABLED) ? " ENABLED," : "",
     341            (value & STATUS_CONNECTED_CHANGED) ? " CONNECTED-CHANGE," : "",
     342            (value & STATUS_CONNECTED) ? " CONNECTED," : "",
     343            (value & STATUS_ALWAYS_ONE) ? " ALWAYS ONE" : " ERROR: NO ALWAYS ONE"
     344        );
     345}
    290346/**
    291347 * @}
  • uspace/drv/uhci-rhd/port.h

    ra9f91cd rf123909  
    11/*
    2  * Copyright (c) 2010 Jan Vesely
     2 * Copyright (c) 2011 Jan Vesely
    33 * All rights reserved.
    44 *
     
    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 port driver
     32 * @brief UHCI root hub port routines
    3333 */
    3434#ifndef DRV_UHCI_PORT_H
    3535#define DRV_UHCI_PORT_H
    3636
    37 #include <assert.h>
    3837#include <stdint.h>
     38#include <fibril.h>
    3939#include <ddf/driver.h>
    40 #include <libarch/ddi.h> /* pio_read and pio_write */
    41 #include <usb/usbdevice.h>
     40#include <usb/usbdevice.h> /* usb_hc_connection_t */
    4241
    4342typedef uint16_t port_status_t;
    44 
    4543#define STATUS_CONNECTED         (1 << 0)
    4644#define STATUS_CONNECTED_CHANGED (1 << 1)
     
    7472void uhci_port_fini(uhci_port_t *port);
    7573
    76 static inline port_status_t uhci_port_read_status(uhci_port_t *port)
    77 {
    78         assert(port);
    79         return pio_read_16(port->address);
    80 }
    81 
    82 static inline void uhci_port_write_status(
    83     uhci_port_t *port, port_status_t value)
    84 {
    85         assert(port);
    86         pio_write_16(port->address, value);
    87 }
    88 
    89 static inline void uhci_port_print_status(
    90     uhci_port_t *port, const port_status_t value)
    91 {
    92         assert(port);
    93         usb_log_debug2("%s Port status(%#x):%s%s%s%s%s%s%s%s%s%s%s.\n",
    94             port->id_string, value,
    95             (value & STATUS_SUSPEND) ? " SUSPENDED," : "",
    96             (value & STATUS_RESUME) ? " IN RESUME," : "",
    97             (value & STATUS_IN_RESET) ? " IN RESET," : "",
    98             (value & STATUS_LINE_D_MINUS) ? " VD-," : "",
    99             (value & STATUS_LINE_D_PLUS) ? " VD+," : "",
    100             (value & STATUS_LOW_SPEED) ? " LOWSPEED," : "",
    101             (value & STATUS_ENABLED_CHANGED) ? " ENABLED-CHANGE," : "",
    102             (value & STATUS_ENABLED) ? " ENABLED," : "",
    103             (value & STATUS_CONNECTED_CHANGED) ? " CONNECTED-CHANGE," : "",
    104             (value & STATUS_CONNECTED) ? " CONNECTED," : "",
    105             (value & STATUS_ALWAYS_ONE) ? " ALWAYS ONE" : " ERROR: NO ALWAYS ONE"
    106         );
    107 }
    10874#endif
    10975/**
  • uspace/drv/uhci-rhd/root_hub.c

    ra9f91cd 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
    42 /** Initializes UHCI root hub instance.
     40/** Initialize UHCI root hub instance.
    4341 *
    4442 * @param[in] instance Driver memory structure to use.
    4543 * @param[in] addr Address of I/O registers.
    4644 * @param[in] size Size of available I/O space.
    47  * @param[in] rh Pointer to ddf instance fo the root hub driver.
     45 * @param[in] rh Pointer to ddf instance of the root hub driver.
    4846 * @return Error code.
    4947 */
     
    6159        if (ret < 0) {
    6260                usb_log_error(
    63                     "Failed to gain access to port registers at %p\n", regs);
     61                    "Failed(%d) to gain access to port registers at %p\n",
     62                    ret, regs);
    6463                return ret;
    6564        }
    6665
    67         /* add fibrils for periodic port checks */
     66        /* Initialize root hub ports */
    6867        unsigned i = 0;
    6968        for (; i < UHCI_ROOT_HUB_PORT_COUNT; ++i) {
     
    8281}
    8382/*----------------------------------------------------------------------------*/
    84 /** Finishes UHCI root hub instance.
     83/** Cleanup UHCI root hub instance.
    8584 *
    86  * @param[in] instance Driver memory structure to use.
     85 * @param[in] instance Root hub structure to use.
    8786 * @return Error code.
    8887 */
  • uspace/drv/uhci-rhd/root_hub.h

    ra9f91cd rf123909  
    11/*
    2  * Copyright (c) 2010 Jan Vesely
     2 * Copyright (c) 2011 Jan Vesely
    33 * All rights reserved.
    44 *
     
    2626 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    2727 */
    28 /** @addtogroup usb
     28/** @addtogroup drvusbuhcirh
    2929 * @{
    3030 */
     
    3535#define DRV_UHCI_ROOT_HUB_H
    3636
    37 #include <fibril.h>
    3837#include <ddf/driver.h>
    3938
Note: See TracChangeset for help on using the changeset viewer.