Changeset 2ef036a in mainline for uspace/drv/uhci-hcd/uhci_hc.c


Ignore:
Timestamp:
2011-03-14T22:51:09Z (14 years ago)
Author:
Vojtech Horky <vojtechhorky@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
2180979
Parents:
7ffe82f (diff), fcf07e6 (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 development/ changes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/uhci-hcd/uhci_hc.c

    r7ffe82f r2ef036a  
    2626 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    2727 */
    28 /** @addtogroup usb
     28/** @addtogroup drvusbuhcihc
    2929 * @{
    3030 */
    3131/** @file
    32  * @brief UHCI driver
     32 * @brief UHCI Host controller driver routines
    3333 */
    3434#include <errno.h>
     
    5959        }
    6060};
    61 
    62 /** Gets USB address of the calling device.
    63  *
    64  * @param[in] fun UHCI hc function.
    65  * @param[in] handle Handle of the device seeking address.
    66  * @param[out] address Place to store found address.
    67  * @return Error code.
    68  */
    6961/*----------------------------------------------------------------------------*/
    7062static int uhci_hc_init_transfer_lists(uhci_hc_t *instance);
     
    7870    bool low_speed, usb_transfer_type_t transfer, size_t size);
    7971/*----------------------------------------------------------------------------*/
    80 /** Initializes UHCI hcd driver structure
     72/** Initialize UHCI hcd driver structure
    8173 *
    8274 * @param[in] instance Memory place to initialize.
     
    8678 * @return Error code.
    8779 * @note Should be called only once on any structure.
    88  */
    89 int uhci_hc_init(uhci_hc_t *instance, ddf_fun_t *fun, void *regs, size_t reg_size)
     80 *
     81 * Initializes memory structures, starts up hw, and launches debugger and
     82 * interrupt fibrils.
     83 */
     84int uhci_hc_init(uhci_hc_t *instance, ddf_fun_t *fun,
     85    void *regs, size_t reg_size, bool interrupts)
    9086{
    9187        assert(reg_size >= sizeof(regs_t));
     
    10096        } else (void) 0
    10197
     98        instance->hw_interrupts = interrupts;
    10299        /* Setup UHCI function. */
    103100        instance->ddf_instance = fun;
     
    118115
    119116        uhci_hc_init_hw(instance);
    120         instance->cleaner =
    121             fibril_create(uhci_hc_interrupt_emulator, instance);
    122         fibril_add_ready(instance->cleaner);
     117        if (!interrupts) {
     118                instance->cleaner =
     119                    fibril_create(uhci_hc_interrupt_emulator, instance);
     120                fibril_add_ready(instance->cleaner);
     121        }
    123122
    124123        instance->debug_checker = fibril_create(uhci_hc_debug_checker, instance);
     
    130129}
    131130/*----------------------------------------------------------------------------*/
    132 /** Initializes UHCI hcd hw resources.
     131/** Initialize UHCI hc hw resources.
    133132 *
    134133 * @param[in] instance UHCI structure to use.
     134 * For magic values see UHCI Design Guide
    135135 */
    136136void uhci_hc_init_hw(uhci_hc_t *instance)
     
    153153        pio_write_32(&registers->flbaseadd, pa);
    154154
    155         /* Enable all interrupts, but resume interrupt */
    156 //      pio_write_16(&instance->registers->usbintr,
    157 //          UHCI_INTR_CRC | UHCI_INTR_COMPLETE | UHCI_INTR_SHORT_PACKET);
     155        if (instance->hw_interrupts) {
     156                /* Enable all interrupts, but resume interrupt */
     157                pio_write_16(&instance->registers->usbintr,
     158                    UHCI_INTR_CRC | UHCI_INTR_COMPLETE | UHCI_INTR_SHORT_PACKET);
     159        }
    158160
    159161        uint16_t status = pio_read_16(&registers->usbcmd);
     
    166168}
    167169/*----------------------------------------------------------------------------*/
    168 /** Initializes UHCI hcd memory structures.
     170/** Initialize UHCI hc memory structures.
    169171 *
    170172 * @param[in] instance UHCI structure to use.
    171173 * @return Error code
    172174 * @note Should be called only once on any structure.
     175 *
     176 * Structures:
     177 *  - interrupt code (I/O addressses are customized per instance)
     178 *  - transfer lists (queue heads need to be accessible by the hw)
     179 *  - frame list page (needs to be one UHCI hw accessible 4K page)
    173180 */
    174181int uhci_hc_init_mem_structures(uhci_hc_t *instance)
     
    229236}
    230237/*----------------------------------------------------------------------------*/
    231 /** Initializes UHCI hcd transfer lists.
     238/** Initialize UHCI hc transfer lists.
    232239 *
    233240 * @param[in] instance UHCI structure to use.
    234241 * @return Error code
    235242 * @note Should be called only once on any structure.
     243 *
     244 * Initializes transfer lists and sets them in one chain to support proper
     245 * USB scheduling. Sets pointer table for quick access.
    236246 */
    237247int uhci_hc_init_transfer_lists(uhci_hc_t *instance)
     
    293303}
    294304/*----------------------------------------------------------------------------*/
    295 /** Schedules batch for execution.
     305/** Schedule batch for execution.
    296306 *
    297307 * @param[in] instance UHCI structure to use.
    298308 * @param[in] batch Transfer batch to schedule.
    299309 * @return Error code
     310 *
     311 * Checks for bandwidth availability and appends the batch to the proper queue.
    300312 */
    301313int uhci_hc_schedule(uhci_hc_t *instance, batch_t *batch)
     
    312324                return ENOTSUP;
    313325        }
    314         /* TODO: check available bandwith here */
     326        /* TODO: check available bandwidth here */
    315327
    316328        transfer_list_t *list =
     
    322334}
    323335/*----------------------------------------------------------------------------*/
    324 /** Takes action based on the interrupt cause.
     336/** Take action based on the interrupt cause.
    325337 *
    326338 * @param[in] instance UHCI structure to use.
    327  * @param[in] status Value of the stsatus regiser at the time of interrupt.
     339 * @param[in] status Value of the status register at the time of interrupt.
     340 *
     341 * Interrupt might indicate:
     342 * - transaction completed, either by triggering IOC, SPD, or an error
     343 * - some kind of device error
     344 * - resume from suspend state (not implemented)
    328345 */
    329346void uhci_hc_interrupt(uhci_hc_t *instance, uint16_t status)
     
    342359/** Polling function, emulates interrupts.
    343360 *
    344  * @param[in] arg UHCI structure to use.
    345  * @return EOK
     361 * @param[in] arg UHCI hc structure to use.
     362 * @return EOK (should never return)
    346363 */
    347364int uhci_hc_interrupt_emulator(void* arg)
     
    366383 *
    367384 * @param[in] arg UHCI structure to use.
    368  * @return EOK
     385 * @return EOK (should never return)
    369386 */
    370387int uhci_hc_debug_checker(void *arg)
     
    430447}
    431448/*----------------------------------------------------------------------------*/
    432 /** Checks transfer packets, for USB validity
     449/** Check transfer packets, for USB validity
    433450 *
    434451 * @param[in] low_speed Transfer speed.
    435452 * @param[in] transfer Transer type
    436453 * @param[in] size Maximum size of used packets
    437  * @return EOK
     454 * @return True if transaction is allowed by USB specs, false otherwise
    438455 */
    439456bool allowed_usb_packet(
Note: See TracChangeset for help on using the changeset viewer.