Ignore:
File:
1 edited

Legend:

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

    rf123909 r67352d2  
    2626 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    2727 */
    28 /** @addtogroup drvusbuhcirh
     28/** @addtogroup usb
    2929 * @{
    3030 */
    3131/** @file
    32  * @brief UHCI root hub port routines
    33  */
    34 #include <libarch/ddi.h> /* pio_read and pio_write */
     32 * @brief UHCI driver
     33 */
    3534#include <errno.h>
    3635#include <str_error.h>
     
    3837
    3938#include <usb/usb.h>    /* usb_address_t */
     39#include <usb/usbdevice.h>
    4040#include <usb/hub.h>
     41#include <usb/request.h>
    4142#include <usb/debug.h>
     43#include <usb/recognise.h>
    4244
    4345#include "port.h"
     
    4850static int uhci_port_check(void *port);
    4951static int uhci_port_reset_enable(int portno, void *arg);
    50 static 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  */
    58 static 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  */
    70 static 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.
     52/*----------------------------------------------------------------------------*/
     53/** Initializes UHCI root hub port instance.
    7954 *
    8055 * @param[in] port Memory structure to use.
     
    8560 * @return Error code.
    8661 *
    87  * Creates and starts the polling fibril.
     62 * Starts the polling fibril.
    8863 */
    8964int uhci_port_init(uhci_port_t *port,
     
    11186        port->checker = fibril_create(uhci_port_check, port);
    11287        if (port->checker == 0) {
    113                 usb_log_error("%s: failed to create polling fibril.",
    114                     port->id_string);
     88                usb_log_error("Port(%p - %d): failed to launch root hub fibril.",
     89                    port->address, port->number);
    11590                return ENOMEM;
    11691        }
    11792
    11893        fibril_add_ready(port->checker);
    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.
     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.
    125100 *
    126101 * @param[in] port Memory structure to use.
     
    130105void uhci_port_fini(uhci_port_t *port)
    131106{
    132         assert(port);
    133         free(port->id_string);
    134107        /* TODO: Kill fibril here */
    135108        return;
     
    138111/** Periodically checks port status and reports new devices.
    139112 *
    140  * @param[in] port Port structure to use.
     113 * @param[in] port Memory structure to use.
    141114 * @return Error code.
    142115 */
     
    149122                async_usleep(instance->wait_period_usec);
    150123
    151                 /* Read register value */
     124                /* read register value */
    152125                port_status_t port_status = uhci_port_read_status(instance);
    153126
    154                 /* Print the value if it's interesting */
     127                /* print the value if it's interesting */
    155128                if (port_status & ~STATUS_ALWAYS_ONE)
    156129                        uhci_port_print_status(instance, port_status);
     
    204177 * @param arg Pointer to uhci_port_t of port with the new device.
    205178 * @return Error code.
    206  *
    207  * Resets and enables the ub port.
    208179 */
    209180int uhci_port_reset_enable(int portno, void *arg)
     
    243214}
    244215/*----------------------------------------------------------------------------*/
    245 /** Initialize and report connected device.
    246  *
    247  * @param[in] port Port structure to use.
     216/** Initializes and reports connected device.
     217 *
     218 * @param[in] port Memory structure to use.
    248219 * @param[in] speed Detected speed.
    249220 * @return Error code.
     
    276247}
    277248/*----------------------------------------------------------------------------*/
    278 /** Remove device.
    279  *
    280  * @param[in] port Memory structure to use.
    281  * @return Error code.
    282  *
    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).
     249/** Removes device.
     250 *
     251 * @param[in] port Memory structure to use.
     252 * @return Error code.
     253 *
     254 * Does not work DDF does not support device removal.
    286255 */
    287256int uhci_port_remove_device(uhci_port_t *port)
     
    292261}
    293262/*----------------------------------------------------------------------------*/
    294 /** Enable or disable root hub port.
    295  *
    296  * @param[in] port Port structure to use.
    297  * @param[in] enabled Port status to set.
     263/** Enables and disables port.
     264 *
     265 * @param[in] port Memory structure to use.
    298266 * @return Error code. (Always EOK)
    299267 */
     
    320288}
    321289/*----------------------------------------------------------------------------*/
    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  */
    328 void 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 }
    346290/**
    347291 * @}
Note: See TracChangeset for help on using the changeset viewer.